From 95559ab9551cfac0e65e9f4272446ed0c9653beb Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Sun, 4 Nov 2012 21:08:55 -0800 Subject: [PATCH] Imported Upstream version 4.0.1 --- ABOUT-NLS | 1282 ++ AUTHORS | 13 + COPYING | 674 + ChangeLog | 427 + ChangeLog.0 | 9885 +++++++++++ FUTURES | 67 + INSTALL | 234 + LIMITATIONS | 22 + Makefile.am | 204 + Makefile.in | 1075 ++ NEWS | 123 + NEWS.0 | 2542 +++ POSIX.STD | 43 + PROBLEMS | 15 + README | 94 + README_d/ChangeLog | 17 + README_d/ChangeLog.0 | 8 + README_d/README.VMS | 87 + README_d/README.bootstrap | 32 + README_d/README.multibyte | 29 + README_d/README.os2 | 22 + README_d/README.pc | 121 + README_d/README.solaris | 20 + README_d/README.tests | 45 + README_d/README.zos | 45 + TODO | 57 + aclocal.m4 | 973 ++ array.c | 1775 ++ awk.h | 1432 ++ awkgram.c | 8730 ++++++++++ awkgram.y | 6039 +++++++ awklib/ChangeLog | 14 + awklib/ChangeLog.0 | 180 + awklib/Makefile.am | 85 + awklib/Makefile.in | 636 + awklib/eg/data/BBS-list | 11 + awklib/eg/data/class_data1 | 3 + awklib/eg/data/class_data2 | 3 + awklib/eg/data/guide-mellow.po | 8 + awklib/eg/data/guide.po | 8 + awklib/eg/data/inventory-shipped | 17 + awklib/eg/lib/assert.awk | 20 + awklib/eg/lib/bits2str.awk | 16 + awklib/eg/lib/cliff_rand.awk | 14 + awklib/eg/lib/ctime.awk | 11 + awklib/eg/lib/ftrans.awk | 15 + awklib/eg/lib/getopt.awk | 80 + awklib/eg/lib/gettime.awk | 62 + awklib/eg/lib/grcat.c | 50 + awklib/eg/lib/groupawk.in | 85 + awklib/eg/lib/join.awk | 16 + awklib/eg/lib/libintl.awk | 14 + awklib/eg/lib/noassign.awk | 17 + awklib/eg/lib/ord.awk | 44 + awklib/eg/lib/passwdawk.in | 63 + awklib/eg/lib/pwcat.c | 41 + awklib/eg/lib/quicksort.awk | 33 + awklib/eg/lib/readable.awk | 17 + awklib/eg/lib/rewind.awk | 20 + awklib/eg/lib/round.awk | 29 + awklib/eg/lib/strtonum.awk | 57 + awklib/eg/lib/walkarray.awk | 9 + awklib/eg/lib/zerofile.awk | 19 + awklib/eg/misc/addresses.csv | 1 + awklib/eg/misc/arraymax.awk | 10 + awklib/eg/misc/arraymax.data | 5 + awklib/eg/misc/findpat.awk | 10 + awklib/eg/misc/findpat.data | 7 + awklib/eg/misc/simple-csv.awk | 10 + awklib/eg/network/PostAgent.sh | 9 + awklib/eg/network/coreserv.awk | 113 + awklib/eg/network/eliza.awk | 270 + awklib/eg/network/fingerclient.awk | 7 + awklib/eg/network/geturl.awk | 24 + awklib/eg/network/hello-serv.awk | 14 + awklib/eg/network/maze.awk | 73 + awklib/eg/network/mobag.awk | 72 + awklib/eg/network/panic.awk | 18 + awklib/eg/network/protbase.awk | 11 + awklib/eg/network/protbase.request | 7 + awklib/eg/network/protbase.result | 9 + awklib/eg/network/remconf.awk | 54 + awklib/eg/network/statist.awk | 85 + awklib/eg/network/stoxdata.txt | 4 + awklib/eg/network/stoxpred.awk | 116 + awklib/eg/network/testserv.awk | 12 + awklib/eg/network/urlchk.awk | 28 + awklib/eg/network/webgrab.awk | 6 + awklib/eg/prog/alarm.awk | 91 + awklib/eg/prog/anagram.awk | 50 + awklib/eg/prog/awksed.awk | 31 + awklib/eg/prog/cut.awk | 140 + awklib/eg/prog/dupword.awk | 21 + awklib/eg/prog/egrep.awk | 103 + awklib/eg/prog/extract.awk | 76 + awklib/eg/prog/guide.awk | 7 + awklib/eg/prog/histsort.awk | 15 + awklib/eg/prog/id.awk | 67 + awklib/eg/prog/igawk.sh | 138 + awklib/eg/prog/indirectcall.awk | 45 + awklib/eg/prog/labels.awk | 54 + awklib/eg/prog/split.awk | 57 + awklib/eg/prog/tee.awk | 42 + awklib/eg/prog/testbits.awk | 27 + awklib/eg/prog/translate.awk | 51 + awklib/eg/prog/uniq.awk | 120 + awklib/eg/prog/wc.awk | 69 + awklib/eg/prog/wordfreq.awk | 16 + awklib/extract.awk | 92 + awklib/stamp-eg | 2 + bisonfix.awk | 42 + builtin.c | 3364 ++++ cmd.h | 213 + command.c | 3695 ++++ command.y | 1680 ++ config.guess | 1500 ++ config.rpath | 672 + config.sub | 1616 ++ configh.in | 474 + configure | 12276 +++++++++++++ configure.ac | 363 + custom.h | 78 + debug.c | 5772 +++++++ depcomp | 584 + dfa.c | 4064 +++++ dfa.h | 109 + doc/ChangeLog | 60 + doc/ChangeLog.0 | 1032 ++ doc/Makefile.am | 112 + doc/Makefile.in | 804 + doc/README.card | 19 + doc/ad.block | 48 + doc/awkcard.in | 1974 +++ doc/awkforai.txt | 150 + doc/bc_notes | 323 + doc/cardfonts | 37 + doc/colors | 39 + doc/gawk.1 | 3810 ++++ doc/gawk.info | 27854 ++++++++++++++++++++++++++++++ doc/gawk.texi | 32521 +++++++++++++++++++++++++++++++++++ doc/gawkinet.info | 4397 +++++ doc/gawkinet.texi | 5187 ++++++ doc/general-program.eps | 153 + doc/general-program.fig | 25 + doc/general-program.pdf | Bin 0 -> 5588 bytes doc/igawk.1 | 73 + doc/lflashlight-small.xpic | 20 + doc/lflashlight.eps | 135 + doc/lflashlight.pdf | 56 + doc/macros | 211 + doc/no.colors | 31 + doc/process-flow.eps | 191 + doc/process-flow.fig | 37 + doc/process-flow.pdf | Bin 0 -> 6558 bytes doc/rflashlight-small.xpic | 26 + doc/rflashlight.eps | 141 + doc/rflashlight.pdf | 57 + doc/setter.outline | 77 + doc/statist.eps | 557 + doc/statist.jpg | Bin 0 -> 20400 bytes doc/statist.pdf | Bin 0 -> 5313 bytes doc/texinfo.tex | 9948 +++++++++++ eval.c | 2778 +++ eval_d.c | 27 + eval_p.c | 27 + ext.c | 302 + extension/ChangeLog | 9 + extension/ChangeLog.0 | 91 + extension/arrayparm.c | 83 + extension/dl.c | 92 + extension/doit | 1 + extension/filefuncs.c | 338 + extension/foo.awk | 9 + extension/fork.c | 104 + extension/ordchr.c | 98 + extension/readfile.c | 109 + extension/rwarray.awk | 28 + extension/rwarray.c | 462 + extension/steps | 23 + extension/testarg.awk | 7 + extension/testarg.c | 57 + extension/testarrayparm.awk | 10 + extension/testff.awk | 30 + extension/testfork.awk | 20 + extension/testordchr.awk | 6 + extension/xreadlink.c | 95 + extension/xreadlink.h | 23 + field.c | 1684 ++ floatcomp.c | 112 + floatmagic.h | 54 + gawkmisc.c | 57 + getopt.c | 1293 ++ getopt.h | 192 + getopt1.c | 195 + getopt_int.h | 130 + gettext.h | 289 + install-sh | 507 + io.c | 3237 ++++ m4/ChangeLog | 9 + m4/ChangeLog.0 | 180 + m4/arch.m4 | 74 + m4/codeset.m4 | 21 + m4/gettext.m4 | 383 + m4/glibc2.m4 | 30 + m4/glibc21.m4 | 30 + m4/iconv.m4 | 214 + m4/intdiv0.m4 | 70 + m4/intl.m4 | 259 + m4/intldir.m4 | 19 + m4/intlmacosx.m4 | 51 + m4/intmax.m4 | 33 + m4/intmax_t.m4 | 40 + m4/inttypes-pri.m4 | 36 + m4/inttypes.m4 | 30 + m4/inttypes_h.m4 | 31 + m4/isc-posix.m4 | 24 + m4/lcmessage.m4 | 30 + m4/lib-ld.m4 | 110 + m4/lib-link.m4 | 774 + m4/lib-prefix.m4 | 224 + m4/libsigsegv.m4 | 16 + m4/lock.m4 | 311 + m4/longdouble.m4 | 31 + m4/longlong.m4 | 48 + m4/nls.m4 | 32 + m4/po.m4 | 449 + m4/printf-posix.m4 | 44 + m4/progtest.m4 | 92 + m4/readline.m4 | 64 + m4/signed.m4 | 17 + m4/size_max.m4 | 62 + m4/socket.m4 | 85 + m4/stdint_h.m4 | 31 + m4/uintmax_t.m4 | 30 + m4/ulonglong.m4 | 48 + m4/visibility.m4 | 52 + m4/wchar_t.m4 | 20 + m4/wint_t.m4 | 20 + m4/xsize.m4 | 13 + main.c | 1463 ++ mbsupport.h | 94 + missing | 367 + missing_d/COPYING.LIB | 482 + missing_d/ChangeLog | 17 + missing_d/ChangeLog.0 | 171 + missing_d/README | 14 + missing_d/getaddrinfo.c | 112 + missing_d/getaddrinfo.h | 31 + missing_d/memcmp.c | 18 + missing_d/memcpy.c | 18 + missing_d/memmove.c | 139 + missing_d/memset.c | 20 + missing_d/mktime.c | 425 + missing_d/setenv.c | 178 + missing_d/snprintf.c | 202 + missing_d/strchr.c | 47 + missing_d/strcoll.c | 7 + missing_d/strerror.c | 37 + missing_d/strftime.c | 1475 ++ missing_d/strncasecmp.c | 97 + missing_d/strtod.c | 134 + missing_d/strtoul.c | 223 + missing_d/system.c | 27 + missing_d/tzset.c | 39 + missing_d/usleep.c | 17 + missing_d/wcmisc.c | 100 + mkinstalldirs | 161 + msg.c | 148 + node.c | 965 ++ pc/ChangeLog | 109 + pc/ChangeLog.0 | 680 + pc/Makefile | 392 + pc/Makefile.tst | 2080 +++ pc/awklib/igawk | 85 + pc/awklib/igawk.awk | 51 + pc/awklib/igawk.bat | 1 + pc/config.h | 597 + pc/config.sed | 279 + pc/configpk.sed | 9 + pc/gawk.def | 2 + pc/gawkmisc.pc | 606 + pc/getid.c | 37 + pc/install.awk | 62 + pc/make-config.bat | 6 + pc/mkinstal.sh | 33 + pc/popen.c | 244 + pc/popen.h | 17 + pc/testoutcmp.awk | 57 + po/ChangeLog | 21 + po/ChangeLog.0 | 127 + po/LINGUAS | 10 + po/Makefile.in.in | 444 + po/Makevars | 41 + po/POTFILES.in | 24 + po/README | 15 + po/Rules-quot | 47 + po/boldquot.sed | 10 + po/da.gmo | Bin 0 -> 48955 bytes po/da.po | 2249 +++ po/de.gmo | Bin 0 -> 52410 bytes po/de.po | 2215 +++ po/en@boldquot.header | 25 + po/en@quot.header | 22 + po/es.gmo | Bin 0 -> 51691 bytes po/es.po | 2392 +++ po/fi.gmo | Bin 0 -> 51928 bytes po/fi.po | 2276 +++ po/fr.gmo | Bin 0 -> 53536 bytes po/fr.po | 2187 +++ po/gawk.pot | 2049 +++ po/insert-header.sin | 23 + po/it.gmo | Bin 0 -> 44170 bytes po/it.po | 2164 +++ po/ja.gmo | Bin 0 -> 55401 bytes po/ja.po | 2133 +++ po/nl.gmo | Bin 0 -> 49531 bytes po/nl.po | 2270 +++ po/pl.gmo | Bin 0 -> 51712 bytes po/pl.po | 2362 +++ po/quot.sed | 6 + po/remove-potcdate.sin | 19 + po/stamp-po | 1 + po/sv.gmo | Bin 0 -> 48974 bytes po/sv.po | 2147 +++ posix/ChangeLog | 9 + posix/ChangeLog.0 | 174 + posix/gawkmisc.c | 276 + profile.c | 1374 ++ profile_p.c | 27 + protos.h | 148 + random.c | 542 + random.h | 50 + re.c | 611 + regcomp.c | 3932 +++++ regex.c | 82 + regex.h | 592 + regex_internal.c | 1750 ++ regex_internal.h | 806 + regexec.c | 4390 +++++ replace.c | 117 + test/ChangeLog | 92 + test/ChangeLog.0 | 1785 ++ test/Gentests | 113 + test/Gentests.vms | 102 + test/Makefile.am | 1511 ++ test/Makefile.in | 3062 ++++ test/Maketests | 1198 ++ test/README | 18 + test/aadelete1.awk | 19 + test/aadelete1.ok | 6 + test/aadelete2.awk | 10 + test/aadelete2.ok | 2 + test/aarray1.awk | 28 + test/aarray1.ok | 6 + test/aasort.awk | 34 + test/aasort.ok | 26 + test/aasorti.awk | 35 + test/aasorti.ok | 20 + test/addcomma.awk | 15 + test/addcomma.in | 7 + test/addcomma.ok | 7 + test/anchgsub.awk | 1 + test/anchgsub.in | 1 + test/anchgsub.ok | 1 + test/argarray.awk | 14 + test/argarray.in | 1 + test/argarray.ok | 9 + test/argtest.awk | 4 + test/argtest.ok | 4 + test/arrayparm.awk | 21 + test/arrayparm.ok | 2 + test/arrayprm2.awk | 67 + test/arrayprm2.ok | 0 test/arrayprm3.awk | 56 + test/arrayprm3.ok | 1 + test/arrayref.awk | 13 + test/arrayref.ok | 2 + test/arraysort.awk | 90 + test/arraysort.ok | 83 + test/arrymem1.awk | 81 + test/arrymem1.ok | 2 + test/arryref2.awk | 18 + test/arryref2.ok | 3 + test/arryref3.awk | 18 + test/arryref3.ok | 2 + test/arryref4.awk | 17 + test/arryref4.ok | 2 + test/arryref5.awk | 17 + test/arryref5.ok | 2 + test/arynasty.awk | 16 + test/arynasty.ok | 1 + test/arynocls.awk | 95 + test/arynocls.in | 30 + test/arynocls.ok | 0 test/aryprm1.awk | 9 + test/aryprm1.ok | 2 + test/aryprm2.awk | 8 + test/aryprm2.ok | 2 + test/aryprm3.awk | 10 + test/aryprm3.ok | 2 + test/aryprm4.awk | 7 + test/aryprm4.ok | 2 + test/aryprm5.awk | 6 + test/aryprm5.ok | 2 + test/aryprm6.awk | 7 + test/aryprm6.ok | 2 + test/aryprm7.awk | 6 + test/aryprm7.ok | 2 + test/aryprm8.awk | 22 + test/aryprm8.ok | 2 + test/arysubnm.awk | 1 + test/arysubnm.ok | 1 + test/asgext.awk | 1 + test/asgext.in | 3 + test/asgext.ok | 6 + test/asort.awk | 25 + test/asort.ok | 18 + test/asorti.awk | 27 + test/asorti.ok | 18 + test/awkpath.ok | 1 + test/back89.awk | 1 + test/back89.in | 2 + test/back89.ok | 1 + test/backgsub.awk | 4 + test/backgsub.in | 1 + test/backgsub.ok | 1 + test/backw.awk | 1 + test/backw.in | 3 + test/backw.ok | 3 + test/badargs.ok | 36 + test/beginfile1.awk | 19 + test/beginfile1.ok | 14 + test/beginfile2.in | 242 + test/beginfile2.ok | 93 + test/beginfile2.sh | 82 + test/binmode1.ok | 1 + test/childin.awk | 1 + test/childin.in | 1 + test/childin.ok | 1 + test/clobber.awk | 98 + test/clobber.ok | 1 + test/clos1way.awk | 21 + test/clos1way.ok | 26 + test/closebad.awk | 7 + test/closebad.ok | 3 + test/clsflnam.awk | 12 + test/clsflnam.in | 3 + test/clsflnam.ok | 1 + test/compare.awk | 13 + test/compare.in | 4 + test/compare.ok | 5 + test/compare2.awk | 165 + test/compare2.ok | 1 + test/concat1.awk | 78 + test/concat1.in | 4 + test/concat1.ok | 4 + test/concat2.awk | 8 + test/concat2.ok | 12 + test/concat3.awk | 1 + test/concat3.ok | 2 + test/concat4.awk | 9 + test/concat4.in | 2 + test/concat4.ok | 4 + test/convfmt.awk | 10 + test/convfmt.ok | 3 + test/datanonl.awk | 3 + test/datanonl.in | 1 + test/datanonl.ok | 1 + test/defref.awk | 1 + test/defref.ok | 3 + test/delargv.awk | 12 + test/delargv.ok | 3 + test/delarpm2.awk | 95 + test/delarpm2.ok | 2 + test/delarprm.awk | 50 + test/delarprm.ok | 0 test/delfunc.awk | 7 + test/delfunc.ok | 2 + test/delsub.awk | 2 + test/delsub.ok | 1 + test/devfd.in1 | 20 + test/devfd.in2 | 20 + test/devfd.in4 | 1 + test/devfd.in5 | 1 + test/devfd.ok | 2 + test/devfd1.awk | 11 + test/devfd1.ok | 40 + test/devfd2.ok | 40 + test/dfastress.awk | 1 + test/dfastress.ok | 1 + test/double1.awk | 4 + test/double1.ok | 2 + test/double2.awk | 46 + test/double2.ok | 4 + test/dtdgport.awk | 325 + test/dumpvars.in | 3 + test/dumpvars.ok | 24 + test/dynlj.awk | 1 + test/dynlj.ok | 1 + test/eofsplit.awk | 68 + test/eofsplit.ok | 0 test/exit.ok | 25 + test/exit.sh | 57 + test/exitval1.awk | 3 + test/exitval1.ok | 1 + test/exitval2.awk | 3 + test/exitval2.ok | 1 + test/exitval2.w32 | 3 + test/fcall_exit.awk | 24 + test/fcall_exit.ok | 2 + test/fcall_exit2.awk | 25 + test/fcall_exit2.in | 1 + test/fcall_exit2.ok | 2 + test/fflush.ok | 16 + test/fflush.sh | 16 + test/fieldwdth.awk | 2 + test/fieldwdth.in | 1 + test/fieldwdth.ok | 1 + test/fldchg.awk | 8 + test/fldchg.in | 1 + test/fldchg.ok | 3 + test/fldchgnf.awk | 1 + test/fldchgnf.in | 1 + test/fldchgnf.ok | 2 + test/fmtspcl.awk | 26 + test/fmtspcl.tok | 9 + test/fmttest.awk | 164 + test/fmttest.ok | 120 + test/fnamedat.awk | 1 + test/fnamedat.in | 1 + test/fnamedat.ok | 2 + test/fnarray.awk | 7 + test/fnarray.ok | 5 + test/fnarray2.awk | 5 + test/fnarray2.ok | 3 + test/fnarydel.awk | 60 + test/fnarydel.ok | 27 + test/fnaryscl.awk | 10 + test/fnaryscl.ok | 2 + test/fnasgnm.awk | 14 + test/fnasgnm.in | 1 + test/fnasgnm.ok | 2 + test/fnmisc.awk | 13 + test/fnmisc.ok | 3 + test/fnparydl.awk | 31 + test/fnparydl.ok | 10 + test/fordel.awk | 65 + test/fordel.ok | 0 test/forref.awk | 11 + test/forref.ok | 3 + test/forsimp.awk | 1 + test/forsimp.ok | 1 + test/fpat1.awk | 22 + test/fpat1.in | 2 + test/fpat1.ok | 25 + test/fpat2.awk | 11 + test/fpat2.ok | 3 + test/fpat3.awk | 10 + test/fpat3.in | 1 + test/fpat3.ok | 4 + test/fpatnull.awk | 2 + test/fpatnull.in | 1 + test/fpatnull.ok | 1 + test/fsbs.awk | 2 + test/fsbs.in | 1 + test/fsbs.ok | 1 + test/fsfwfs.awk | 1 + test/fsfwfs.in | 16 + test/fsfwfs.ok | 16 + test/fsrs.awk | 8 + test/fsrs.in | 7 + test/fsrs.ok | 5 + test/fsspcoln.awk | 41 + test/fsspcoln.in | 1 + test/fsspcoln.ok | 1 + test/fstabplus.awk | 2 + test/fstabplus.in | 1 + test/fstabplus.ok | 1 + test/funlen.awk | 69 + test/funlen.in | 8 + test/funlen.ok | 2 + test/funsemnl.awk | 3 + test/funsemnl.ok | 1 + test/funsmnam.awk | 6 + test/funsmnam.ok | 2 + test/funstack.awk | 981 ++ test/funstack.in | 206 + test/funstack.ok | 0 test/fwtest.awk | 2 + test/fwtest.in | 1 + test/fwtest.ok | 1 + test/fwtest2.awk | 59 + test/fwtest2.in | 12 + test/fwtest2.ok | 12 + test/fwtest3.awk | 1 + test/fwtest3.in | 1 + test/fwtest3.ok | 1 + test/gensub.awk | 7 + test/gensub.in | 2 + test/gensub.ok | 4 + test/gensub2.awk | 5 + test/gensub2.ok | 3 + test/getline.awk | 33 + test/getline.in | 3 + test/getline.ok | 8 + test/getline2.awk | 1 + test/getline2.ok | 2 + test/getline3.awk | 7 + test/getline3.ok | 1 + test/getline4.awk | 1 + test/getline4.in | 1 + test/getline4.ok | 1 + test/getlnbuf.awk | 18 + test/getlnbuf.in | 1708 ++ test/getlnbuf.ok | 1708 ++ test/getlndir.awk | 7 + test/getlndir.ok | 1 + test/getlnhd.awk | 10 + test/getlnhd.ok | 2 + test/getnr2tb.awk | 111 + test/getnr2tb.in | 6 + test/getnr2tb.ok | 6 + test/getnr2tm.awk | 75 + test/getnr2tm.in | 1 + test/getnr2tm.ok | 1 + test/gnuops2.awk | 72 + test/gnuops2.ok | 7 + test/gnuops3.awk | 14 + test/gnuops3.ok | 5 + test/gnureops.awk | 45 + test/gnureops.ok | 17 + test/gsubasgn.awk | 13 + test/gsubasgn.ok | 5 + test/gsubtest.awk | 9 + test/gsubtest.ok | 7 + test/gsubtst2.awk | 241 + test/gsubtst2.ok | 25 + test/gsubtst3.awk | 290 + test/gsubtst3.in | 57 + test/gsubtst3.ok | 60 + test/gsubtst4.awk | 242 + test/gsubtst4.ok | 33 + test/gsubtst5.awk | 97 + test/gsubtst5.in | 1 + test/gsubtst5.ok | 1 + test/gsubtst6.awk | 24 + test/gsubtst6.ok | 1 + test/gsubtst7.awk | 92 + test/gsubtst7.in | 1 + test/gsubtst7.ok | 1 + test/gsubtst8.awk | 5 + test/gsubtst8.in | 2 + test/gsubtst8.ok | 2 + test/gtlnbufv.awk | 2 + test/hex.awk | 22 + test/hex.ok | 6 + test/hsprint.awk | 71 + test/hsprint.ok | 66 + test/icasefs.awk | 43 + test/icasefs.ok | 6 + test/icasers.awk | 2 + test/icasers.in | 1 + test/icasers.ok | 2 + test/igncdym.awk | 56 + test/igncdym.in | 2 + test/igncdym.ok | 4 + test/igncfs.awk | 8 + test/igncfs.in | 2 + test/igncfs.ok | 2 + test/ignrcas2.awk | 13 + test/ignrcas2.ok | 1 + test/ignrcase.awk | 2 + test/ignrcase.in | 1 + test/ignrcase.ok | 1 + test/indirectcall.awk | 130 + test/indirectcall.in | 3 + test/indirectcall.ok | 18 + test/inftest.awk | 8 + test/inftest.ok | 105 + test/inputred.awk | 1 + test/inputred.ok | 1 + test/intest.awk | 4 + test/intest.ok | 1 + test/intformat.awk | 88 + test/intformat.ok | 2 + test/intprec.awk | 1 + test/intprec.ok | 1 + test/iobug1.awk | 53 + test/iobug1.ok | 0 test/lc_num1.awk | 19 + test/lc_num1.ok | 1 + test/leaddig.awk | 7 + test/leaddig.ok | 1 + test/leadnl.awk | 10 + test/leadnl.in | 9 + test/leadnl.ok | 8 + test/lib/awkpath.awk | 1 + test/lint.awk | 14 + test/lint.ok | 5 + test/lintold.awk | 21 + test/lintold.in | 1 + test/lintold.ok | 16 + test/lintwarn.awk | 38 + test/lintwarn.ok | 39 + test/litoct.awk | 1 + test/litoct.ok | 1 + test/localenl.ok | 4 + test/localenl.sh | 75 + test/longdbl.awk | 159 + test/longdbl.in | 2 + test/longdbl.ok | 2 + test/longsub.awk | 1 + test/longsub.in | 1 + test/longsub.ok | 1 + test/longwrds.awk | 27 + test/longwrds.in | 200 + test/longwrds.ok | 21 + test/manglprm.awk | 41 + test/manglprm.in | 1 + test/manglprm.ok | 1 + test/manyfiles.awk | 1 + test/manyfiles.ok | 1 + test/match1.awk | 9 + test/match1.ok | 6 + test/match2.awk | 6 + test/match2.ok | 2 + test/match3.awk | 46 + test/match3.in | 4 + test/match3.ok | 4 + test/math.awk | 10 + test/math.ok | 6 + test/mbfw1.awk | 40 + test/mbfw1.in | 4 + test/mbfw1.ok | 4 + test/mbprintf1.awk | 1 + test/mbprintf1.in | 2 + test/mbprintf1.ok | 2 + test/mbprintf2.awk | 4 + test/mbprintf2.ok | 2 + test/mbprintf3.awk | 1 + test/mbprintf3.in | 1 + test/mbprintf3.ok | 2 + test/mbstr1.awk | 4 + test/mbstr1.ok | 2 + test/membug1.awk | 1 + test/membug1.in | 2 + test/membug1.ok | 0 test/messages.awk | 9 + test/minusstr.awk | 1 + test/minusstr.ok | 1 + test/mixed1.ok | 3 + test/mmap8k.in | 143 + test/mtchi18n.awk | 1 + test/mtchi18n.in | 2 + test/mtchi18n.ok | 2 + test/nasty.awk | 92 + test/nasty.ok | 2 + test/nasty2.awk | 20 + test/nasty2.ok | 2 + test/nastyparm.awk | 41 + test/nastyparm.ok | 11 + test/negexp.awk | 1 + test/negexp.ok | 1 + test/negrange.awk | 7 + test/negrange.ok | 7 + test/nested.awk | 123 + test/nested.in | 1 + test/nested.ok | 2 + test/next.ok | 4 + test/next.sh | 20 + test/nfldstr.awk | 13 + test/nfldstr.in | 1 + test/nfldstr.ok | 0 test/nfneg.awk | 1 + test/nfneg.ok | 2 + test/nfset.awk | 1 + test/nfset.in | 5 + test/nfset.ok | 5 + test/nlfldsep.awk | 2 + test/nlfldsep.in | 5 + test/nlfldsep.ok | 13 + test/nlinstr.awk | 8 + test/nlinstr.in | 2 + test/nlinstr.ok | 1 + test/nlstrina.awk | 77 + test/nlstrina.ok | 3 + test/noeffect.awk | 5 + test/noeffect.ok | 4 + test/nofile.ok | 2 + test/nofmtch.awk | 1 + test/nofmtch.ok | 2 + test/noloop1.awk | 70 + test/noloop1.in | 1 + test/noloop1.ok | 0 test/noloop2.awk | 70 + test/noloop2.in | 1 + test/noloop2.ok | 0 test/nondec.awk | 1 + test/nondec.ok | 1 + test/nondec2.awk | 104 + test/nondec2.ok | 1 + test/nonl.awk | 1 + test/nonl.ok | 1 + test/noparms.awk | 1 + test/noparms.ok | 5 + test/nors.in | 1 + test/nors.ok | 2 + test/nulrsend.awk | 112 + test/nulrsend.in | 4 + test/nulrsend.ok | 2 + test/numindex.awk | 55 + test/numindex.in | 4 + test/numindex.ok | 1 + test/numsubstr.awk | 1 + test/numsubstr.in | 3 + test/numsubstr.ok | 3 + test/octsub.awk | 1 + test/octsub.ok | 1 + test/ofmt.awk | 53 + test/ofmt.in | 136 + test/ofmt.ok | 6 + test/ofmta.awk | 30 + test/ofmta.ok | 7 + test/ofmtbig.awk | 126 + test/ofmtbig.in | 3 + test/ofmtbig.ok | 2 + test/ofmtfidl.awk | 85 + test/ofmtfidl.in | 10 + test/ofmtfidl.ok | 10 + test/ofmts.awk | 2 + test/ofmts.in | 1 + test/ofmts.ok | 1 + test/onlynl.awk | 2 + test/onlynl.in | 4 + test/onlynl.ok | 0 test/opasnidx.awk | 1 + test/opasnidx.ok | 1 + test/opasnslf.awk | 6 + test/opasnslf.ok | 3 + test/out1.ok | 1 + test/out2.ok | 2 + test/out3.ok | 1 + test/paramdup.awk | 8 + test/paramdup.ok | 3 + test/paramres.awk | 6 + test/paramres.ok | 2 + test/paramtyp.awk | 20 + test/paramtyp.ok | 6 + test/parse1.awk | 35 + test/parse1.in | 1 + test/parse1.ok | 4 + test/parsefld.awk | 2 + test/parsefld.in | 1 + test/parsefld.ok | 2 + test/parseme.awk | 1 + test/parseme.ok | 5 + test/patsplit.awk | 26 + test/patsplit.ok | 56 + test/pcntplus.awk | 1 + test/pcntplus.ok | 1 + test/pid.awk | 49 + test/pid.ok | 3 + test/pid.sh | 3 + test/pipeio1.awk | 31 + test/pipeio1.ok | 2 + test/pipeio2.awk | 72 + test/pipeio2.in | 8 + test/pipeio2.ok | 14 + test/posix.awk | 69 + test/posix.in | 1 + test/posix.ok | 16 + test/posix2008sub.awk | 7 + test/posix2008sub.ok | 2 + test/poundbang.awk | 2 + test/prdupval.awk | 1 + test/prdupval.in | 1 + test/prdupval.ok | 1 + test/prec.awk | 7 + test/prec.ok | 1 + test/printf0.awk | 5 + test/printf0.ok | 1 + test/printf1.awk | 19 + test/printf1.ok | 7 + test/printfbad1.awk | 65 + test/printfbad1.ok | 5 + test/printfbad2.awk | 2 + test/printfbad2.in | 1 + test/printfbad2.ok | 3 + test/printfbad3.awk | 22 + test/printfbad3.ok | 1 + test/printfloat.awk | 62 + test/printlang.awk | 4 + test/prmarscl.awk | 6 + test/prmarscl.ok | 2 + test/prmreuse.awk | 14 + test/prmreuse.ok | 0 test/procinfs.awk | 7 + test/procinfs.ok | 3 + test/profile2.ok | 170 + test/profile3.awk | 9 + test/profile3.ok | 14 + test/prt1eval.awk | 6 + test/prt1eval.ok | 1 + test/prtoeval.awk | 4 + test/prtoeval.ok | 2 + test/pty1.awk | 54 + test/pty1.ok | 2 + test/rand.awk | 6 + test/rand.ok | 1 + test/range1.awk | 1 + test/range1.in | 2 + test/range1.ok | 1 + test/rebt8b1.awk | 138 + test/rebt8b1.ok | 16 + test/rebt8b2.awk | 88 + test/rebt8b2.ok | 511 + test/rebuf.awk | 73 + test/rebuf.in | 2350 +++ test/rebuf.ok | 1290 ++ test/redfilnm.awk | 98 + test/redfilnm.in | 1 + test/redfilnm.ok | 9 + test/reg/Obsolete/exp.awk | 1 + test/reg/Obsolete/exp.good | 2 + test/reg/Obsolete/exp.in | 0 test/reg/Obsolete/log.awk | 1 + test/reg/Obsolete/log.good | 4 + test/reg/Obsolete/log.in | 0 test/reg/exp-eq.awk | 1 + test/reg/exp-eq.good | 3 + test/reg/exp-eq.in | 3 + test/reg/func.awk | 1 + test/reg/func.good | 1 + test/reg/func.in | 0 test/reg/func2.awk | 2 + test/reg/func2.good | 2 + test/reg/func2.in | 0 test/regeq.awk | 29 + test/regeq.in | 2 + test/regeq.ok | 2 + test/regrange.awk | 30 + test/regrange.ok | 6 + test/regtest.sh | 18 + test/regx8bit.awk | 26 + test/regx8bit.ok | 7 + test/reindops.awk | 6 + test/reindops.in | 1 + test/reindops.ok | 1 + test/reint.awk | 1 + test/reint.in | 1 + test/reint.ok | 1 + test/reint2.awk | 1 + test/reint2.in | 1 + test/reint2.ok | 1 + test/reparse.awk | 7 + test/reparse.in | 1 + test/reparse.ok | 3 + test/resplit.awk | 1 + test/resplit.in | 1 + test/resplit.ok | 1 + test/rri1.awk | 1 + test/rri1.in | 1 + test/rri1.ok | 0 test/rs.awk | 2 + test/rs.in | 15 + test/rs.ok | 3 + test/rsnul1nl.awk | 2 + test/rsnul1nl.in | 3 + test/rsnul1nl.ok | 2 + test/rsnulbig.ok | 1 + test/rsnulbig2.ok | 1 + test/rsstart1.awk | 32 + test/rsstart1.in | 10000 +++++++++++ test/rsstart1.ok | 1 + test/rsstart2.awk | 2 + test/rsstart2.ok | 1 + test/rsstart3.ok | 1 + test/rstest1.awk | 7 + test/rstest1.ok | 2 + test/rstest2.awk | 6 + test/rstest2.ok | 1 + test/rstest3.awk | 73 + test/rstest3.ok | 0 test/rstest4.awk | 67 + test/rstest4.ok | 2 + test/rstest5.awk | 60 + test/rstest5.ok | 4 + test/rstest6.awk | 6 + test/rstest6.in | 1 + test/rstest6.ok | 1 + test/rswhite.awk | 2 + test/rswhite.in | 2 + test/rswhite.ok | 2 + test/rtlen.ok | 3 + test/rtlen.sh | 5 + test/rtlen01.ok | 3 + test/rtlen01.sh | 8 + test/scalar.awk | 4 + test/scalar.ok | 2 + test/sclforin.awk | 1 + test/sclforin.ok | 2 + test/sclifin.awk | 7 + test/sclifin.ok | 2 + test/shadow.awk | 21 + test/shadow.ok | 7 + test/sort1.awk | 127 + test/sort1.ok | 220 + test/sortempty.awk | 1 + test/sortempty.ok | 1 + test/sortfor.awk | 9 + test/sortfor.in | 289 + test/sortfor.ok | 578 + test/sortu.awk | 118 + test/sortu.ok | 50 + test/space.ok | 2 + test/splitarg4.awk | 138 + test/splitarg4.in | 11 + test/splitarg4.ok | 92 + test/splitargv.awk | 7 + test/splitargv.in | 7 + test/splitargv.ok | 7 + test/splitarr.awk | 5 + test/splitarr.ok | 1 + test/splitdef.awk | 7 + test/splitdef.ok | 1 + test/splitvar.awk | 5 + test/splitvar.in | 1 + test/splitvar.ok | 1 + test/splitwht.awk | 7 + test/splitwht.ok | 2 + test/sprintfc.awk | 1 + test/sprintfc.in | 3 + test/sprintfc.ok | 3 + test/strcat1.awk | 6 + test/strcat1.ok | 1 + test/strftime.awk | 19 + test/strftlng.awk | 11 + test/strftlng.ok | 58 + test/strnum1.awk | 35 + test/strnum1.ok | 2 + test/strtod.awk | 5 + test/strtod.in | 1 + test/strtod.ok | 2 + test/strtonum.awk | 6 + test/strtonum.ok | 4 + test/subamp.awk | 1 + test/subamp.in | 1 + test/subamp.ok | 1 + test/subi18n.awk | 68 + test/subi18n.ok | 2 + test/subsepnm.awk | 1 + test/subsepnm.ok | 1 + test/subslash.awk | 6 + test/subslash.ok | 1 + test/substr.awk | 14 + test/substr.ok | 10 + test/swaplns.awk | 7 + test/swaplns.in | 9 + test/swaplns.ok | 9 + test/switch2.awk | 59 + test/switch2.ok | 0 test/synerr1.awk | 4 + test/synerr1.ok | 3 + test/synerr2.awk | 47 + test/synerr2.ok | 3 + test/tradanch.awk | 2 + test/tradanch.in | 2 + test/tradanch.ok | 0 test/tweakfld.awk | 296 + test/tweakfld.in | 3 + test/tweakfld.ok | 3 + test/uninit2.awk | 2 + test/uninit2.ok | 4 + test/uninit3.awk | 7 + test/uninit3.ok | 3 + test/uninit4.awk | 13 + test/uninit4.ok | 10 + test/uninit5.awk | 111 + test/uninit5.ok | 9 + test/uninitialized.awk | 3 + test/uninitialized.ok | 1 + test/unterm.awk | 1 + test/unterm.ok | 5 + test/uparrfs.awk | 8 + test/uparrfs.in | 1 + test/uparrfs.ok | 4 + test/wideidx.awk | 7 + test/wideidx.in | 2 + test/wideidx.ok | 2 + test/wideidx2.awk | 89 + test/wideidx2.ok | 2 + test/widesub.awk | 12 + test/widesub.ok | 2 + test/widesub2.awk | 9 + test/widesub2.ok | 2 + test/widesub3.awk | 6 + test/widesub3.in | 2 + test/widesub3.ok | 4 + test/widesub4.awk | 54 + test/widesub4.ok | 10 + test/wjposer1.awk | 75 + test/wjposer1.in | 1527 ++ test/wjposer1.ok | 2068 +++ test/xref.awk | 139 + test/xref.original | 313 + test/zero2.awk | 5 + test/zero2.ok | 3 + test/zeroe0.awk | 40 + test/zeroe0.ok | 2 + test/zeroflag.awk | 1 + test/zeroflag.ok | 1 + version.c | 3 + version.in | 3 + vms/ChangeLog | 59 + vms/ChangeLog.0 | 699 + vms/descrip.mms | 322 + vms/fcntl.h | 10 + vms/gawk.cld | 79 + vms/gawk.hlp | 1676 ++ vms/gawkmisc.vms | 196 + vms/posix-cc.sh | 16 + vms/redirect.h | 133 + vms/unixlib.h | 27 + vms/varargs.h | 38 + vms/vms-conf.h | 667 + vms/vms.h | 88 + vms/vms_args.c | 417 + vms/vms_cli.c | 109 + vms/vms_fwrite.c | 214 + vms/vms_gawk.c | 293 + vms/vms_misc.c | 365 + vms/vms_popen.c | 347 + vms/vmsbuild.com | 163 + vms/vmstest.com | 1722 ++ xalloc.h | 336 + ylwrap | 223 + 1136 files changed, 288849 insertions(+) create mode 100644 ABOUT-NLS create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 ChangeLog.0 create mode 100644 FUTURES create mode 100644 INSTALL create mode 100644 LIMITATIONS create mode 100644 Makefile.am create mode 100644 Makefile.in create mode 100644 NEWS create mode 100644 NEWS.0 create mode 100644 POSIX.STD create mode 100644 PROBLEMS create mode 100644 README create mode 100644 README_d/ChangeLog create mode 100644 README_d/ChangeLog.0 create mode 100644 README_d/README.VMS create mode 100644 README_d/README.bootstrap create mode 100644 README_d/README.multibyte create mode 100644 README_d/README.os2 create mode 100644 README_d/README.pc create mode 100644 README_d/README.solaris create mode 100644 README_d/README.tests create mode 100644 README_d/README.zos create mode 100644 TODO create mode 100644 aclocal.m4 create mode 100644 array.c create mode 100644 awk.h create mode 100644 awkgram.c create mode 100644 awkgram.y create mode 100644 awklib/ChangeLog create mode 100644 awklib/ChangeLog.0 create mode 100644 awklib/Makefile.am create mode 100644 awklib/Makefile.in create mode 100644 awklib/eg/data/BBS-list create mode 100644 awklib/eg/data/class_data1 create mode 100644 awklib/eg/data/class_data2 create mode 100644 awklib/eg/data/guide-mellow.po create mode 100644 awklib/eg/data/guide.po create mode 100644 awklib/eg/data/inventory-shipped create mode 100644 awklib/eg/lib/assert.awk create mode 100644 awklib/eg/lib/bits2str.awk create mode 100644 awklib/eg/lib/cliff_rand.awk create mode 100644 awklib/eg/lib/ctime.awk create mode 100644 awklib/eg/lib/ftrans.awk create mode 100644 awklib/eg/lib/getopt.awk create mode 100644 awklib/eg/lib/gettime.awk create mode 100644 awklib/eg/lib/grcat.c create mode 100644 awklib/eg/lib/groupawk.in create mode 100644 awklib/eg/lib/join.awk create mode 100644 awklib/eg/lib/libintl.awk create mode 100644 awklib/eg/lib/noassign.awk create mode 100644 awklib/eg/lib/ord.awk create mode 100644 awklib/eg/lib/passwdawk.in create mode 100644 awklib/eg/lib/pwcat.c create mode 100644 awklib/eg/lib/quicksort.awk create mode 100644 awklib/eg/lib/readable.awk create mode 100644 awklib/eg/lib/rewind.awk create mode 100644 awklib/eg/lib/round.awk create mode 100644 awklib/eg/lib/strtonum.awk create mode 100644 awklib/eg/lib/walkarray.awk create mode 100644 awklib/eg/lib/zerofile.awk create mode 100644 awklib/eg/misc/addresses.csv create mode 100644 awklib/eg/misc/arraymax.awk create mode 100644 awklib/eg/misc/arraymax.data create mode 100644 awklib/eg/misc/findpat.awk create mode 100644 awklib/eg/misc/findpat.data create mode 100644 awklib/eg/misc/simple-csv.awk create mode 100644 awklib/eg/network/PostAgent.sh create mode 100644 awklib/eg/network/coreserv.awk create mode 100644 awklib/eg/network/eliza.awk create mode 100644 awklib/eg/network/fingerclient.awk create mode 100644 awklib/eg/network/geturl.awk create mode 100644 awklib/eg/network/hello-serv.awk create mode 100644 awklib/eg/network/maze.awk create mode 100644 awklib/eg/network/mobag.awk create mode 100644 awklib/eg/network/panic.awk create mode 100644 awklib/eg/network/protbase.awk create mode 100644 awklib/eg/network/protbase.request create mode 100644 awklib/eg/network/protbase.result create mode 100644 awklib/eg/network/remconf.awk create mode 100644 awklib/eg/network/statist.awk create mode 100644 awklib/eg/network/stoxdata.txt create mode 100644 awklib/eg/network/stoxpred.awk create mode 100644 awklib/eg/network/testserv.awk create mode 100644 awklib/eg/network/urlchk.awk create mode 100644 awklib/eg/network/webgrab.awk create mode 100644 awklib/eg/prog/alarm.awk create mode 100644 awklib/eg/prog/anagram.awk create mode 100644 awklib/eg/prog/awksed.awk create mode 100644 awklib/eg/prog/cut.awk create mode 100644 awklib/eg/prog/dupword.awk create mode 100644 awklib/eg/prog/egrep.awk create mode 100644 awklib/eg/prog/extract.awk create mode 100644 awklib/eg/prog/guide.awk create mode 100644 awklib/eg/prog/histsort.awk create mode 100644 awklib/eg/prog/id.awk create mode 100644 awklib/eg/prog/igawk.sh create mode 100644 awklib/eg/prog/indirectcall.awk create mode 100644 awklib/eg/prog/labels.awk create mode 100644 awklib/eg/prog/split.awk create mode 100644 awklib/eg/prog/tee.awk create mode 100644 awklib/eg/prog/testbits.awk create mode 100644 awklib/eg/prog/translate.awk create mode 100644 awklib/eg/prog/uniq.awk create mode 100644 awklib/eg/prog/wc.awk create mode 100644 awklib/eg/prog/wordfreq.awk create mode 100644 awklib/extract.awk create mode 100644 awklib/stamp-eg create mode 100644 bisonfix.awk create mode 100644 builtin.c create mode 100644 cmd.h create mode 100644 command.c create mode 100644 command.y create mode 100755 config.guess create mode 100755 config.rpath create mode 100755 config.sub create mode 100644 configh.in create mode 100755 configure create mode 100644 configure.ac create mode 100644 custom.h create mode 100644 debug.c create mode 100755 depcomp create mode 100644 dfa.c create mode 100644 dfa.h create mode 100644 doc/ChangeLog create mode 100644 doc/ChangeLog.0 create mode 100644 doc/Makefile.am create mode 100644 doc/Makefile.in create mode 100644 doc/README.card create mode 100644 doc/ad.block create mode 100644 doc/awkcard.in create mode 100644 doc/awkforai.txt create mode 100644 doc/bc_notes create mode 100644 doc/cardfonts create mode 100644 doc/colors create mode 100644 doc/gawk.1 create mode 100644 doc/gawk.info create mode 100644 doc/gawk.texi create mode 100644 doc/gawkinet.info create mode 100644 doc/gawkinet.texi create mode 100644 doc/general-program.eps create mode 100644 doc/general-program.fig create mode 100644 doc/general-program.pdf create mode 100644 doc/igawk.1 create mode 100644 doc/lflashlight-small.xpic create mode 100644 doc/lflashlight.eps create mode 100644 doc/lflashlight.pdf create mode 100644 doc/macros create mode 100644 doc/no.colors create mode 100644 doc/process-flow.eps create mode 100644 doc/process-flow.fig create mode 100644 doc/process-flow.pdf create mode 100644 doc/rflashlight-small.xpic create mode 100644 doc/rflashlight.eps create mode 100644 doc/rflashlight.pdf create mode 100644 doc/setter.outline create mode 100644 doc/statist.eps create mode 100644 doc/statist.jpg create mode 100644 doc/statist.pdf create mode 100644 doc/texinfo.tex create mode 100644 eval.c create mode 100644 eval_d.c create mode 100644 eval_p.c create mode 100644 ext.c create mode 100644 extension/ChangeLog create mode 100644 extension/ChangeLog.0 create mode 100644 extension/arrayparm.c create mode 100644 extension/dl.c create mode 100755 extension/doit create mode 100644 extension/filefuncs.c create mode 100644 extension/foo.awk create mode 100644 extension/fork.c create mode 100644 extension/ordchr.c create mode 100644 extension/readfile.c create mode 100644 extension/rwarray.awk create mode 100644 extension/rwarray.c create mode 100755 extension/steps create mode 100644 extension/testarg.awk create mode 100644 extension/testarg.c create mode 100644 extension/testarrayparm.awk create mode 100644 extension/testff.awk create mode 100644 extension/testfork.awk create mode 100644 extension/testordchr.awk create mode 100644 extension/xreadlink.c create mode 100644 extension/xreadlink.h create mode 100644 field.c create mode 100644 floatcomp.c create mode 100644 floatmagic.h create mode 100644 gawkmisc.c create mode 100644 getopt.c create mode 100644 getopt.h create mode 100644 getopt1.c create mode 100644 getopt_int.h create mode 100644 gettext.h create mode 100755 install-sh create mode 100644 io.c create mode 100644 m4/ChangeLog create mode 100644 m4/ChangeLog.0 create mode 100644 m4/arch.m4 create mode 100644 m4/codeset.m4 create mode 100644 m4/gettext.m4 create mode 100644 m4/glibc2.m4 create mode 100644 m4/glibc21.m4 create mode 100644 m4/iconv.m4 create mode 100644 m4/intdiv0.m4 create mode 100644 m4/intl.m4 create mode 100644 m4/intldir.m4 create mode 100644 m4/intlmacosx.m4 create mode 100644 m4/intmax.m4 create mode 100644 m4/intmax_t.m4 create mode 100644 m4/inttypes-pri.m4 create mode 100644 m4/inttypes.m4 create mode 100644 m4/inttypes_h.m4 create mode 100644 m4/isc-posix.m4 create mode 100644 m4/lcmessage.m4 create mode 100644 m4/lib-ld.m4 create mode 100644 m4/lib-link.m4 create mode 100644 m4/lib-prefix.m4 create mode 100644 m4/libsigsegv.m4 create mode 100644 m4/lock.m4 create mode 100644 m4/longdouble.m4 create mode 100644 m4/longlong.m4 create mode 100644 m4/nls.m4 create mode 100644 m4/po.m4 create mode 100644 m4/printf-posix.m4 create mode 100644 m4/progtest.m4 create mode 100644 m4/readline.m4 create mode 100644 m4/signed.m4 create mode 100644 m4/size_max.m4 create mode 100644 m4/socket.m4 create mode 100644 m4/stdint_h.m4 create mode 100644 m4/uintmax_t.m4 create mode 100644 m4/ulonglong.m4 create mode 100644 m4/visibility.m4 create mode 100644 m4/wchar_t.m4 create mode 100644 m4/wint_t.m4 create mode 100644 m4/xsize.m4 create mode 100644 main.c create mode 100644 mbsupport.h create mode 100755 missing create mode 100644 missing_d/COPYING.LIB create mode 100644 missing_d/ChangeLog create mode 100644 missing_d/ChangeLog.0 create mode 100644 missing_d/README create mode 100644 missing_d/getaddrinfo.c create mode 100644 missing_d/getaddrinfo.h create mode 100644 missing_d/memcmp.c create mode 100644 missing_d/memcpy.c create mode 100644 missing_d/memmove.c create mode 100644 missing_d/memset.c create mode 100644 missing_d/mktime.c create mode 100644 missing_d/setenv.c create mode 100644 missing_d/snprintf.c create mode 100644 missing_d/strchr.c create mode 100644 missing_d/strcoll.c create mode 100644 missing_d/strerror.c create mode 100644 missing_d/strftime.c create mode 100644 missing_d/strncasecmp.c create mode 100644 missing_d/strtod.c create mode 100644 missing_d/strtoul.c create mode 100644 missing_d/system.c create mode 100644 missing_d/tzset.c create mode 100644 missing_d/usleep.c create mode 100644 missing_d/wcmisc.c create mode 100755 mkinstalldirs create mode 100644 msg.c create mode 100644 node.c create mode 100644 pc/ChangeLog create mode 100644 pc/ChangeLog.0 create mode 100644 pc/Makefile create mode 100644 pc/Makefile.tst create mode 100644 pc/awklib/igawk create mode 100644 pc/awklib/igawk.awk create mode 100644 pc/awklib/igawk.bat create mode 100644 pc/config.h create mode 100644 pc/config.sed create mode 100644 pc/configpk.sed create mode 100644 pc/gawk.def create mode 100644 pc/gawkmisc.pc create mode 100644 pc/getid.c create mode 100644 pc/install.awk create mode 100755 pc/make-config.bat create mode 100644 pc/mkinstal.sh create mode 100644 pc/popen.c create mode 100644 pc/popen.h create mode 100644 pc/testoutcmp.awk create mode 100644 po/ChangeLog create mode 100644 po/ChangeLog.0 create mode 100644 po/LINGUAS create mode 100644 po/Makefile.in.in create mode 100644 po/Makevars create mode 100644 po/POTFILES.in create mode 100644 po/README create mode 100644 po/Rules-quot create mode 100644 po/boldquot.sed create mode 100644 po/da.gmo create mode 100644 po/da.po create mode 100644 po/de.gmo create mode 100644 po/de.po create mode 100644 po/en@boldquot.header create mode 100644 po/en@quot.header create mode 100644 po/es.gmo create mode 100644 po/es.po create mode 100644 po/fi.gmo create mode 100644 po/fi.po create mode 100644 po/fr.gmo create mode 100644 po/fr.po create mode 100644 po/gawk.pot create mode 100644 po/insert-header.sin create mode 100644 po/it.gmo create mode 100644 po/it.po create mode 100644 po/ja.gmo create mode 100644 po/ja.po create mode 100644 po/nl.gmo create mode 100644 po/nl.po create mode 100644 po/pl.gmo create mode 100644 po/pl.po create mode 100644 po/quot.sed create mode 100644 po/remove-potcdate.sin create mode 100644 po/stamp-po create mode 100644 po/sv.gmo create mode 100644 po/sv.po create mode 100644 posix/ChangeLog create mode 100644 posix/ChangeLog.0 create mode 100644 posix/gawkmisc.c create mode 100644 profile.c create mode 100644 profile_p.c create mode 100644 protos.h create mode 100644 random.c create mode 100644 random.h create mode 100644 re.c create mode 100644 regcomp.c create mode 100644 regex.c create mode 100644 regex.h create mode 100644 regex_internal.c create mode 100644 regex_internal.h create mode 100644 regexec.c create mode 100644 replace.c create mode 100644 test/ChangeLog create mode 100644 test/ChangeLog.0 create mode 100755 test/Gentests create mode 100644 test/Gentests.vms create mode 100644 test/Makefile.am create mode 100644 test/Makefile.in create mode 100644 test/Maketests create mode 100644 test/README create mode 100644 test/aadelete1.awk create mode 100644 test/aadelete1.ok create mode 100644 test/aadelete2.awk create mode 100644 test/aadelete2.ok create mode 100644 test/aarray1.awk create mode 100644 test/aarray1.ok create mode 100644 test/aasort.awk create mode 100644 test/aasort.ok create mode 100644 test/aasorti.awk create mode 100644 test/aasorti.ok create mode 100644 test/addcomma.awk create mode 100644 test/addcomma.in create mode 100644 test/addcomma.ok create mode 100644 test/anchgsub.awk create mode 100644 test/anchgsub.in create mode 100644 test/anchgsub.ok create mode 100644 test/argarray.awk create mode 100644 test/argarray.in create mode 100644 test/argarray.ok create mode 100644 test/argtest.awk create mode 100644 test/argtest.ok create mode 100644 test/arrayparm.awk create mode 100644 test/arrayparm.ok create mode 100644 test/arrayprm2.awk create mode 100644 test/arrayprm2.ok create mode 100644 test/arrayprm3.awk create mode 100644 test/arrayprm3.ok create mode 100644 test/arrayref.awk create mode 100644 test/arrayref.ok create mode 100644 test/arraysort.awk create mode 100644 test/arraysort.ok create mode 100644 test/arrymem1.awk create mode 100644 test/arrymem1.ok create mode 100644 test/arryref2.awk create mode 100644 test/arryref2.ok create mode 100644 test/arryref3.awk create mode 100644 test/arryref3.ok create mode 100644 test/arryref4.awk create mode 100644 test/arryref4.ok create mode 100644 test/arryref5.awk create mode 100644 test/arryref5.ok create mode 100644 test/arynasty.awk create mode 100644 test/arynasty.ok create mode 100644 test/arynocls.awk create mode 100644 test/arynocls.in create mode 100644 test/arynocls.ok create mode 100644 test/aryprm1.awk create mode 100644 test/aryprm1.ok create mode 100644 test/aryprm2.awk create mode 100644 test/aryprm2.ok create mode 100644 test/aryprm3.awk create mode 100644 test/aryprm3.ok create mode 100644 test/aryprm4.awk create mode 100644 test/aryprm4.ok create mode 100644 test/aryprm5.awk create mode 100644 test/aryprm5.ok create mode 100644 test/aryprm6.awk create mode 100644 test/aryprm6.ok create mode 100644 test/aryprm7.awk create mode 100644 test/aryprm7.ok create mode 100644 test/aryprm8.awk create mode 100644 test/aryprm8.ok create mode 100644 test/arysubnm.awk create mode 100644 test/arysubnm.ok create mode 100644 test/asgext.awk create mode 100644 test/asgext.in create mode 100644 test/asgext.ok create mode 100644 test/asort.awk create mode 100644 test/asort.ok create mode 100644 test/asorti.awk create mode 100644 test/asorti.ok create mode 100644 test/awkpath.ok create mode 100644 test/back89.awk create mode 100644 test/back89.in create mode 100644 test/back89.ok create mode 100644 test/backgsub.awk create mode 100644 test/backgsub.in create mode 100644 test/backgsub.ok create mode 100644 test/backw.awk create mode 100644 test/backw.in create mode 100644 test/backw.ok create mode 100644 test/badargs.ok create mode 100644 test/beginfile1.awk create mode 100644 test/beginfile1.ok create mode 100644 test/beginfile2.in create mode 100644 test/beginfile2.ok create mode 100755 test/beginfile2.sh create mode 100644 test/binmode1.ok create mode 100644 test/childin.awk create mode 100644 test/childin.in create mode 100644 test/childin.ok create mode 100644 test/clobber.awk create mode 100644 test/clobber.ok create mode 100644 test/clos1way.awk create mode 100644 test/clos1way.ok create mode 100644 test/closebad.awk create mode 100644 test/closebad.ok create mode 100644 test/clsflnam.awk create mode 100644 test/clsflnam.in create mode 100644 test/clsflnam.ok create mode 100644 test/compare.awk create mode 100644 test/compare.in create mode 100644 test/compare.ok create mode 100644 test/compare2.awk create mode 100644 test/compare2.ok create mode 100644 test/concat1.awk create mode 100644 test/concat1.in create mode 100644 test/concat1.ok create mode 100644 test/concat2.awk create mode 100644 test/concat2.ok create mode 100644 test/concat3.awk create mode 100644 test/concat3.ok create mode 100644 test/concat4.awk create mode 100644 test/concat4.in create mode 100644 test/concat4.ok create mode 100644 test/convfmt.awk create mode 100644 test/convfmt.ok create mode 100644 test/datanonl.awk create mode 100644 test/datanonl.in create mode 100644 test/datanonl.ok create mode 100644 test/defref.awk create mode 100644 test/defref.ok create mode 100644 test/delargv.awk create mode 100644 test/delargv.ok create mode 100644 test/delarpm2.awk create mode 100644 test/delarpm2.ok create mode 100644 test/delarprm.awk create mode 100644 test/delarprm.ok create mode 100644 test/delfunc.awk create mode 100644 test/delfunc.ok create mode 100644 test/delsub.awk create mode 100644 test/delsub.ok create mode 100644 test/devfd.in1 create mode 100644 test/devfd.in2 create mode 100644 test/devfd.in4 create mode 100644 test/devfd.in5 create mode 100644 test/devfd.ok create mode 100644 test/devfd1.awk create mode 100644 test/devfd1.ok create mode 100644 test/devfd2.ok create mode 100644 test/dfastress.awk create mode 100644 test/dfastress.ok create mode 100644 test/double1.awk create mode 100644 test/double1.ok create mode 100644 test/double2.awk create mode 100644 test/double2.ok create mode 100644 test/dtdgport.awk create mode 100644 test/dumpvars.in create mode 100644 test/dumpvars.ok create mode 100644 test/dynlj.awk create mode 100644 test/dynlj.ok create mode 100644 test/eofsplit.awk create mode 100644 test/eofsplit.ok create mode 100644 test/exit.ok create mode 100755 test/exit.sh create mode 100644 test/exitval1.awk create mode 100644 test/exitval1.ok create mode 100644 test/exitval2.awk create mode 100644 test/exitval2.ok create mode 100644 test/exitval2.w32 create mode 100644 test/fcall_exit.awk create mode 100644 test/fcall_exit.ok create mode 100644 test/fcall_exit2.awk create mode 100644 test/fcall_exit2.in create mode 100644 test/fcall_exit2.ok create mode 100644 test/fflush.ok create mode 100755 test/fflush.sh create mode 100644 test/fieldwdth.awk create mode 100644 test/fieldwdth.in create mode 100644 test/fieldwdth.ok create mode 100644 test/fldchg.awk create mode 100644 test/fldchg.in create mode 100644 test/fldchg.ok create mode 100644 test/fldchgnf.awk create mode 100644 test/fldchgnf.in create mode 100644 test/fldchgnf.ok create mode 100644 test/fmtspcl.awk create mode 100644 test/fmtspcl.tok create mode 100644 test/fmttest.awk create mode 100644 test/fmttest.ok create mode 100644 test/fnamedat.awk create mode 100644 test/fnamedat.in create mode 100644 test/fnamedat.ok create mode 100644 test/fnarray.awk create mode 100644 test/fnarray.ok create mode 100644 test/fnarray2.awk create mode 100644 test/fnarray2.ok create mode 100644 test/fnarydel.awk create mode 100644 test/fnarydel.ok create mode 100644 test/fnaryscl.awk create mode 100644 test/fnaryscl.ok create mode 100644 test/fnasgnm.awk create mode 100644 test/fnasgnm.in create mode 100644 test/fnasgnm.ok create mode 100644 test/fnmisc.awk create mode 100644 test/fnmisc.ok create mode 100644 test/fnparydl.awk create mode 100644 test/fnparydl.ok create mode 100644 test/fordel.awk create mode 100644 test/fordel.ok create mode 100644 test/forref.awk create mode 100644 test/forref.ok create mode 100644 test/forsimp.awk create mode 100644 test/forsimp.ok create mode 100644 test/fpat1.awk create mode 100644 test/fpat1.in create mode 100644 test/fpat1.ok create mode 100644 test/fpat2.awk create mode 100644 test/fpat2.ok create mode 100644 test/fpat3.awk create mode 100644 test/fpat3.in create mode 100644 test/fpat3.ok create mode 100644 test/fpatnull.awk create mode 100644 test/fpatnull.in create mode 100644 test/fpatnull.ok create mode 100644 test/fsbs.awk create mode 100644 test/fsbs.in create mode 100644 test/fsbs.ok create mode 100644 test/fsfwfs.awk create mode 100644 test/fsfwfs.in create mode 100644 test/fsfwfs.ok create mode 100644 test/fsrs.awk create mode 100644 test/fsrs.in create mode 100644 test/fsrs.ok create mode 100644 test/fsspcoln.awk create mode 100644 test/fsspcoln.in create mode 100644 test/fsspcoln.ok create mode 100644 test/fstabplus.awk create mode 100644 test/fstabplus.in create mode 100644 test/fstabplus.ok create mode 100644 test/funlen.awk create mode 100644 test/funlen.in create mode 100644 test/funlen.ok create mode 100644 test/funsemnl.awk create mode 100644 test/funsemnl.ok create mode 100644 test/funsmnam.awk create mode 100644 test/funsmnam.ok create mode 100644 test/funstack.awk create mode 100644 test/funstack.in create mode 100644 test/funstack.ok create mode 100644 test/fwtest.awk create mode 100644 test/fwtest.in create mode 100644 test/fwtest.ok create mode 100644 test/fwtest2.awk create mode 100644 test/fwtest2.in create mode 100644 test/fwtest2.ok create mode 100644 test/fwtest3.awk create mode 100644 test/fwtest3.in create mode 100644 test/fwtest3.ok create mode 100644 test/gensub.awk create mode 100644 test/gensub.in create mode 100644 test/gensub.ok create mode 100644 test/gensub2.awk create mode 100644 test/gensub2.ok create mode 100644 test/getline.awk create mode 100644 test/getline.in create mode 100644 test/getline.ok create mode 100644 test/getline2.awk create mode 100644 test/getline2.ok create mode 100644 test/getline3.awk create mode 100644 test/getline3.ok create mode 100644 test/getline4.awk create mode 100644 test/getline4.in create mode 100644 test/getline4.ok create mode 100644 test/getlnbuf.awk create mode 100644 test/getlnbuf.in create mode 100644 test/getlnbuf.ok create mode 100644 test/getlndir.awk create mode 100644 test/getlndir.ok create mode 100644 test/getlnhd.awk create mode 100644 test/getlnhd.ok create mode 100644 test/getnr2tb.awk create mode 100644 test/getnr2tb.in create mode 100644 test/getnr2tb.ok create mode 100644 test/getnr2tm.awk create mode 100644 test/getnr2tm.in create mode 100644 test/getnr2tm.ok create mode 100644 test/gnuops2.awk create mode 100644 test/gnuops2.ok create mode 100644 test/gnuops3.awk create mode 100644 test/gnuops3.ok create mode 100644 test/gnureops.awk create mode 100644 test/gnureops.ok create mode 100644 test/gsubasgn.awk create mode 100644 test/gsubasgn.ok create mode 100644 test/gsubtest.awk create mode 100644 test/gsubtest.ok create mode 100644 test/gsubtst2.awk create mode 100644 test/gsubtst2.ok create mode 100644 test/gsubtst3.awk create mode 100644 test/gsubtst3.in create mode 100644 test/gsubtst3.ok create mode 100644 test/gsubtst4.awk create mode 100644 test/gsubtst4.ok create mode 100644 test/gsubtst5.awk create mode 100644 test/gsubtst5.in create mode 100644 test/gsubtst5.ok create mode 100644 test/gsubtst6.awk create mode 100644 test/gsubtst6.ok create mode 100644 test/gsubtst7.awk create mode 100644 test/gsubtst7.in create mode 100644 test/gsubtst7.ok create mode 100644 test/gsubtst8.awk create mode 100644 test/gsubtst8.in create mode 100644 test/gsubtst8.ok create mode 100644 test/gtlnbufv.awk create mode 100644 test/hex.awk create mode 100644 test/hex.ok create mode 100644 test/hsprint.awk create mode 100644 test/hsprint.ok create mode 100644 test/icasefs.awk create mode 100644 test/icasefs.ok create mode 100644 test/icasers.awk create mode 100644 test/icasers.in create mode 100644 test/icasers.ok create mode 100644 test/igncdym.awk create mode 100644 test/igncdym.in create mode 100644 test/igncdym.ok create mode 100644 test/igncfs.awk create mode 100644 test/igncfs.in create mode 100644 test/igncfs.ok create mode 100644 test/ignrcas2.awk create mode 100644 test/ignrcas2.ok create mode 100644 test/ignrcase.awk create mode 100644 test/ignrcase.in create mode 100644 test/ignrcase.ok create mode 100644 test/indirectcall.awk create mode 100644 test/indirectcall.in create mode 100644 test/indirectcall.ok create mode 100644 test/inftest.awk create mode 100644 test/inftest.ok create mode 100644 test/inputred.awk create mode 100644 test/inputred.ok create mode 100644 test/intest.awk create mode 100644 test/intest.ok create mode 100644 test/intformat.awk create mode 100644 test/intformat.ok create mode 100644 test/intprec.awk create mode 100644 test/intprec.ok create mode 100644 test/iobug1.awk create mode 100644 test/iobug1.ok create mode 100644 test/lc_num1.awk create mode 100644 test/lc_num1.ok create mode 100644 test/leaddig.awk create mode 100644 test/leaddig.ok create mode 100644 test/leadnl.awk create mode 100644 test/leadnl.in create mode 100644 test/leadnl.ok create mode 100644 test/lib/awkpath.awk create mode 100644 test/lint.awk create mode 100644 test/lint.ok create mode 100644 test/lintold.awk create mode 100644 test/lintold.in create mode 100644 test/lintold.ok create mode 100644 test/lintwarn.awk create mode 100644 test/lintwarn.ok create mode 100644 test/litoct.awk create mode 100644 test/litoct.ok create mode 100644 test/localenl.ok create mode 100755 test/localenl.sh create mode 100644 test/longdbl.awk create mode 100644 test/longdbl.in create mode 100644 test/longdbl.ok create mode 100644 test/longsub.awk create mode 100644 test/longsub.in create mode 100644 test/longsub.ok create mode 100644 test/longwrds.awk create mode 100644 test/longwrds.in create mode 100644 test/longwrds.ok create mode 100644 test/manglprm.awk create mode 100644 test/manglprm.in create mode 100644 test/manglprm.ok create mode 100644 test/manyfiles.awk create mode 100644 test/manyfiles.ok create mode 100644 test/match1.awk create mode 100644 test/match1.ok create mode 100644 test/match2.awk create mode 100644 test/match2.ok create mode 100644 test/match3.awk create mode 100644 test/match3.in create mode 100644 test/match3.ok create mode 100644 test/math.awk create mode 100644 test/math.ok create mode 100644 test/mbfw1.awk create mode 100644 test/mbfw1.in create mode 100644 test/mbfw1.ok create mode 100644 test/mbprintf1.awk create mode 100644 test/mbprintf1.in create mode 100644 test/mbprintf1.ok create mode 100644 test/mbprintf2.awk create mode 100644 test/mbprintf2.ok create mode 100644 test/mbprintf3.awk create mode 100644 test/mbprintf3.in create mode 100644 test/mbprintf3.ok create mode 100644 test/mbstr1.awk create mode 100644 test/mbstr1.ok create mode 100644 test/membug1.awk create mode 100644 test/membug1.in create mode 100644 test/membug1.ok create mode 100644 test/messages.awk create mode 100644 test/minusstr.awk create mode 100644 test/minusstr.ok create mode 100644 test/mixed1.ok create mode 100644 test/mmap8k.in create mode 100644 test/mtchi18n.awk create mode 100644 test/mtchi18n.in create mode 100644 test/mtchi18n.ok create mode 100644 test/nasty.awk create mode 100644 test/nasty.ok create mode 100644 test/nasty2.awk create mode 100644 test/nasty2.ok create mode 100644 test/nastyparm.awk create mode 100644 test/nastyparm.ok create mode 100644 test/negexp.awk create mode 100644 test/negexp.ok create mode 100644 test/negrange.awk create mode 100644 test/negrange.ok create mode 100644 test/nested.awk create mode 100644 test/nested.in create mode 100644 test/nested.ok create mode 100644 test/next.ok create mode 100755 test/next.sh create mode 100644 test/nfldstr.awk create mode 100644 test/nfldstr.in create mode 100644 test/nfldstr.ok create mode 100644 test/nfneg.awk create mode 100644 test/nfneg.ok create mode 100644 test/nfset.awk create mode 100644 test/nfset.in create mode 100644 test/nfset.ok create mode 100644 test/nlfldsep.awk create mode 100644 test/nlfldsep.in create mode 100644 test/nlfldsep.ok create mode 100644 test/nlinstr.awk create mode 100644 test/nlinstr.in create mode 100644 test/nlinstr.ok create mode 100644 test/nlstrina.awk create mode 100644 test/nlstrina.ok create mode 100644 test/noeffect.awk create mode 100644 test/noeffect.ok create mode 100644 test/nofile.ok create mode 100644 test/nofmtch.awk create mode 100644 test/nofmtch.ok create mode 100644 test/noloop1.awk create mode 100644 test/noloop1.in create mode 100644 test/noloop1.ok create mode 100644 test/noloop2.awk create mode 100644 test/noloop2.in create mode 100644 test/noloop2.ok create mode 100644 test/nondec.awk create mode 100644 test/nondec.ok create mode 100644 test/nondec2.awk create mode 100644 test/nondec2.ok create mode 100644 test/nonl.awk create mode 100644 test/nonl.ok create mode 100644 test/noparms.awk create mode 100644 test/noparms.ok create mode 100644 test/nors.in create mode 100644 test/nors.ok create mode 100644 test/nulrsend.awk create mode 100644 test/nulrsend.in create mode 100644 test/nulrsend.ok create mode 100644 test/numindex.awk create mode 100644 test/numindex.in create mode 100644 test/numindex.ok create mode 100644 test/numsubstr.awk create mode 100644 test/numsubstr.in create mode 100644 test/numsubstr.ok create mode 100644 test/octsub.awk create mode 100644 test/octsub.ok create mode 100644 test/ofmt.awk create mode 100644 test/ofmt.in create mode 100644 test/ofmt.ok create mode 100644 test/ofmta.awk create mode 100644 test/ofmta.ok create mode 100644 test/ofmtbig.awk create mode 100644 test/ofmtbig.in create mode 100644 test/ofmtbig.ok create mode 100644 test/ofmtfidl.awk create mode 100644 test/ofmtfidl.in create mode 100644 test/ofmtfidl.ok create mode 100644 test/ofmts.awk create mode 100644 test/ofmts.in create mode 100644 test/ofmts.ok create mode 100644 test/onlynl.awk create mode 100644 test/onlynl.in create mode 100644 test/onlynl.ok create mode 100644 test/opasnidx.awk create mode 100644 test/opasnidx.ok create mode 100644 test/opasnslf.awk create mode 100644 test/opasnslf.ok create mode 100644 test/out1.ok create mode 100644 test/out2.ok create mode 100644 test/out3.ok create mode 100644 test/paramdup.awk create mode 100644 test/paramdup.ok create mode 100644 test/paramres.awk create mode 100644 test/paramres.ok create mode 100644 test/paramtyp.awk create mode 100644 test/paramtyp.ok create mode 100644 test/parse1.awk create mode 100644 test/parse1.in create mode 100644 test/parse1.ok create mode 100644 test/parsefld.awk create mode 100644 test/parsefld.in create mode 100644 test/parsefld.ok create mode 100644 test/parseme.awk create mode 100644 test/parseme.ok create mode 100644 test/patsplit.awk create mode 100644 test/patsplit.ok create mode 100644 test/pcntplus.awk create mode 100644 test/pcntplus.ok create mode 100644 test/pid.awk create mode 100644 test/pid.ok create mode 100755 test/pid.sh create mode 100644 test/pipeio1.awk create mode 100644 test/pipeio1.ok create mode 100644 test/pipeio2.awk create mode 100644 test/pipeio2.in create mode 100644 test/pipeio2.ok create mode 100644 test/posix.awk create mode 100644 test/posix.in create mode 100644 test/posix.ok create mode 100644 test/posix2008sub.awk create mode 100644 test/posix2008sub.ok create mode 100755 test/poundbang.awk create mode 100644 test/prdupval.awk create mode 100644 test/prdupval.in create mode 100644 test/prdupval.ok create mode 100644 test/prec.awk create mode 100644 test/prec.ok create mode 100644 test/printf0.awk create mode 100644 test/printf0.ok create mode 100644 test/printf1.awk create mode 100644 test/printf1.ok create mode 100644 test/printfbad1.awk create mode 100644 test/printfbad1.ok create mode 100644 test/printfbad2.awk create mode 100644 test/printfbad2.in create mode 100644 test/printfbad2.ok create mode 100644 test/printfbad3.awk create mode 100644 test/printfbad3.ok create mode 100644 test/printfloat.awk create mode 100644 test/printlang.awk create mode 100644 test/prmarscl.awk create mode 100644 test/prmarscl.ok create mode 100644 test/prmreuse.awk create mode 100644 test/prmreuse.ok create mode 100644 test/procinfs.awk create mode 100644 test/procinfs.ok create mode 100644 test/profile2.ok create mode 100644 test/profile3.awk create mode 100644 test/profile3.ok create mode 100644 test/prt1eval.awk create mode 100644 test/prt1eval.ok create mode 100644 test/prtoeval.awk create mode 100644 test/prtoeval.ok create mode 100644 test/pty1.awk create mode 100644 test/pty1.ok create mode 100644 test/rand.awk create mode 100644 test/rand.ok create mode 100755 test/range1.awk create mode 100644 test/range1.in create mode 100644 test/range1.ok create mode 100644 test/rebt8b1.awk create mode 100644 test/rebt8b1.ok create mode 100644 test/rebt8b2.awk create mode 100644 test/rebt8b2.ok create mode 100644 test/rebuf.awk create mode 100644 test/rebuf.in create mode 100644 test/rebuf.ok create mode 100644 test/redfilnm.awk create mode 100644 test/redfilnm.in create mode 100644 test/redfilnm.ok create mode 100644 test/reg/Obsolete/exp.awk create mode 100644 test/reg/Obsolete/exp.good create mode 100644 test/reg/Obsolete/exp.in create mode 100644 test/reg/Obsolete/log.awk create mode 100644 test/reg/Obsolete/log.good create mode 100644 test/reg/Obsolete/log.in create mode 100644 test/reg/exp-eq.awk create mode 100644 test/reg/exp-eq.good create mode 100644 test/reg/exp-eq.in create mode 100644 test/reg/func.awk create mode 100644 test/reg/func.good create mode 100644 test/reg/func.in create mode 100644 test/reg/func2.awk create mode 100644 test/reg/func2.good create mode 100644 test/reg/func2.in create mode 100644 test/regeq.awk create mode 100644 test/regeq.in create mode 100644 test/regeq.ok create mode 100644 test/regrange.awk create mode 100644 test/regrange.ok create mode 100755 test/regtest.sh create mode 100644 test/regx8bit.awk create mode 100644 test/regx8bit.ok create mode 100644 test/reindops.awk create mode 100644 test/reindops.in create mode 100644 test/reindops.ok create mode 100644 test/reint.awk create mode 100644 test/reint.in create mode 100644 test/reint.ok create mode 100644 test/reint2.awk create mode 100644 test/reint2.in create mode 100644 test/reint2.ok create mode 100644 test/reparse.awk create mode 100644 test/reparse.in create mode 100644 test/reparse.ok create mode 100644 test/resplit.awk create mode 100644 test/resplit.in create mode 100644 test/resplit.ok create mode 100644 test/rri1.awk create mode 100644 test/rri1.in create mode 100644 test/rri1.ok create mode 100644 test/rs.awk create mode 100644 test/rs.in create mode 100644 test/rs.ok create mode 100644 test/rsnul1nl.awk create mode 100644 test/rsnul1nl.in create mode 100644 test/rsnul1nl.ok create mode 100644 test/rsnulbig.ok create mode 100644 test/rsnulbig2.ok create mode 100644 test/rsstart1.awk create mode 100644 test/rsstart1.in create mode 100644 test/rsstart1.ok create mode 100644 test/rsstart2.awk create mode 100644 test/rsstart2.ok create mode 100644 test/rsstart3.ok create mode 100644 test/rstest1.awk create mode 100644 test/rstest1.ok create mode 100644 test/rstest2.awk create mode 100644 test/rstest2.ok create mode 100644 test/rstest3.awk create mode 100644 test/rstest3.ok create mode 100644 test/rstest4.awk create mode 100644 test/rstest4.ok create mode 100644 test/rstest5.awk create mode 100644 test/rstest5.ok create mode 100644 test/rstest6.awk create mode 100644 test/rstest6.in create mode 100644 test/rstest6.ok create mode 100644 test/rswhite.awk create mode 100644 test/rswhite.in create mode 100644 test/rswhite.ok create mode 100644 test/rtlen.ok create mode 100755 test/rtlen.sh create mode 100644 test/rtlen01.ok create mode 100755 test/rtlen01.sh create mode 100644 test/scalar.awk create mode 100644 test/scalar.ok create mode 100644 test/sclforin.awk create mode 100644 test/sclforin.ok create mode 100644 test/sclifin.awk create mode 100644 test/sclifin.ok create mode 100644 test/shadow.awk create mode 100644 test/shadow.ok create mode 100644 test/sort1.awk create mode 100644 test/sort1.ok create mode 100644 test/sortempty.awk create mode 100644 test/sortempty.ok create mode 100644 test/sortfor.awk create mode 100644 test/sortfor.in create mode 100644 test/sortfor.ok create mode 100644 test/sortu.awk create mode 100644 test/sortu.ok create mode 100644 test/space.ok create mode 100644 test/splitarg4.awk create mode 100644 test/splitarg4.in create mode 100644 test/splitarg4.ok create mode 100644 test/splitargv.awk create mode 100644 test/splitargv.in create mode 100644 test/splitargv.ok create mode 100644 test/splitarr.awk create mode 100644 test/splitarr.ok create mode 100644 test/splitdef.awk create mode 100644 test/splitdef.ok create mode 100644 test/splitvar.awk create mode 100644 test/splitvar.in create mode 100644 test/splitvar.ok create mode 100644 test/splitwht.awk create mode 100644 test/splitwht.ok create mode 100644 test/sprintfc.awk create mode 100644 test/sprintfc.in create mode 100644 test/sprintfc.ok create mode 100644 test/strcat1.awk create mode 100644 test/strcat1.ok create mode 100644 test/strftime.awk create mode 100644 test/strftlng.awk create mode 100644 test/strftlng.ok create mode 100644 test/strnum1.awk create mode 100644 test/strnum1.ok create mode 100644 test/strtod.awk create mode 100644 test/strtod.in create mode 100644 test/strtod.ok create mode 100644 test/strtonum.awk create mode 100644 test/strtonum.ok create mode 100644 test/subamp.awk create mode 100644 test/subamp.in create mode 100644 test/subamp.ok create mode 100644 test/subi18n.awk create mode 100644 test/subi18n.ok create mode 100644 test/subsepnm.awk create mode 100644 test/subsepnm.ok create mode 100644 test/subslash.awk create mode 100644 test/subslash.ok create mode 100644 test/substr.awk create mode 100644 test/substr.ok create mode 100644 test/swaplns.awk create mode 100644 test/swaplns.in create mode 100644 test/swaplns.ok create mode 100644 test/switch2.awk create mode 100644 test/switch2.ok create mode 100644 test/synerr1.awk create mode 100644 test/synerr1.ok create mode 100644 test/synerr2.awk create mode 100644 test/synerr2.ok create mode 100644 test/tradanch.awk create mode 100644 test/tradanch.in create mode 100644 test/tradanch.ok create mode 100644 test/tweakfld.awk create mode 100644 test/tweakfld.in create mode 100644 test/tweakfld.ok create mode 100644 test/uninit2.awk create mode 100644 test/uninit2.ok create mode 100644 test/uninit3.awk create mode 100644 test/uninit3.ok create mode 100644 test/uninit4.awk create mode 100644 test/uninit4.ok create mode 100644 test/uninit5.awk create mode 100644 test/uninit5.ok create mode 100644 test/uninitialized.awk create mode 100644 test/uninitialized.ok create mode 100644 test/unterm.awk create mode 100644 test/unterm.ok create mode 100644 test/uparrfs.awk create mode 100644 test/uparrfs.in create mode 100644 test/uparrfs.ok create mode 100644 test/wideidx.awk create mode 100644 test/wideidx.in create mode 100644 test/wideidx.ok create mode 100644 test/wideidx2.awk create mode 100644 test/wideidx2.ok create mode 100644 test/widesub.awk create mode 100644 test/widesub.ok create mode 100644 test/widesub2.awk create mode 100644 test/widesub2.ok create mode 100644 test/widesub3.awk create mode 100644 test/widesub3.in create mode 100644 test/widesub3.ok create mode 100644 test/widesub4.awk create mode 100644 test/widesub4.ok create mode 100644 test/wjposer1.awk create mode 100644 test/wjposer1.in create mode 100644 test/wjposer1.ok create mode 100644 test/xref.awk create mode 100644 test/xref.original create mode 100644 test/zero2.awk create mode 100644 test/zero2.ok create mode 100644 test/zeroe0.awk create mode 100644 test/zeroe0.ok create mode 100644 test/zeroflag.awk create mode 100644 test/zeroflag.ok create mode 100644 version.c create mode 100644 version.in create mode 100644 vms/ChangeLog create mode 100644 vms/ChangeLog.0 create mode 100644 vms/descrip.mms create mode 100644 vms/fcntl.h create mode 100644 vms/gawk.cld create mode 100644 vms/gawk.hlp create mode 100644 vms/gawkmisc.vms create mode 100755 vms/posix-cc.sh create mode 100644 vms/redirect.h create mode 100644 vms/unixlib.h create mode 100644 vms/varargs.h create mode 100644 vms/vms-conf.h create mode 100644 vms/vms.h create mode 100644 vms/vms_args.c create mode 100644 vms/vms_cli.c create mode 100644 vms/vms_fwrite.c create mode 100644 vms/vms_gawk.c create mode 100644 vms/vms_misc.c create mode 100644 vms/vms_popen.c create mode 100644 vms/vmsbuild.com create mode 100644 vms/vmstest.com create mode 100644 xalloc.h create mode 100644 ylwrap diff --git a/ABOUT-NLS b/ABOUT-NLS new file mode 100644 index 0000000..b1de1b6 --- /dev/null +++ b/ABOUT-NLS @@ -0,0 +1,1282 @@ +1 Notes on the Free Translation Project +*************************************** + +Free software is going international! The Free Translation Project is +a way to get maintainers of free software, translators, and users all +together, so that free software will gradually become able to speak many +languages. A few packages already provide translations for their +messages. + + If you found this `ABOUT-NLS' file inside a distribution, you may +assume that the distributed package does use GNU `gettext' internally, +itself available at your nearest GNU archive site. But you do _not_ +need to install GNU `gettext' prior to configuring, installing or using +this package with messages translated. + + Installers will find here some useful hints. These notes also +explain how users should proceed for getting the programs to use the +available translations. They tell how people wanting to contribute and +work on translations can contact the appropriate team. + +1.1 INSTALL Matters +=================== + +Some packages are "localizable" when properly installed; the programs +they contain can be made to speak your own native language. Most such +packages use GNU `gettext'. Other packages have their own ways to +internationalization, predating GNU `gettext'. + + By default, this package will be installed to allow translation of +messages. It will automatically detect whether the system already +provides the GNU `gettext' functions. Installers may use special +options at configuration time for changing the default behaviour. The +command: + + ./configure --disable-nls + +will _totally_ disable translation of messages. + + When you already have GNU `gettext' installed on your system and run +configure without an option for your new package, `configure' will +probably detect the previously built and installed `libintl' library +and will decide to use it. If not, you may have to to use the +`--with-libintl-prefix' option to tell `configure' where to look for it. + + Internationalized packages usually have many `po/LL.po' files, where +LL gives an ISO 639 two-letter code identifying the language. Unless +translations have been forbidden at `configure' time by using the +`--disable-nls' switch, all available translations are installed +together with the package. However, the environment variable `LINGUAS' +may be set, prior to configuration, to limit the installed set. +`LINGUAS' should then contain a space separated list of two-letter +codes, stating which languages are allowed. + +1.2 Using This Package +====================== + +As a user, if your language has been installed for this package, you +only have to set the `LANG' environment variable to the appropriate +`LL_CC' combination. If you happen to have the `LC_ALL' or some other +`LC_xxx' environment variables set, you should unset them before +setting `LANG', otherwise the setting of `LANG' will not have the +desired effect. Here `LL' is an ISO 639 two-letter language code, and +`CC' is an ISO 3166 two-letter country code. For example, let's +suppose that you speak German and live in Germany. At the shell +prompt, merely execute `setenv LANG de_DE' (in `csh'), +`export LANG; LANG=de_DE' (in `sh') or `export LANG=de_DE' (in `bash'). +This can be done from your `.login' or `.profile' file, once and for +all. + + You might think that the country code specification is redundant. +But in fact, some languages have dialects in different countries. For +example, `de_AT' is used for Austria, and `pt_BR' for Brazil. The +country code serves to distinguish the dialects. + + The locale naming convention of `LL_CC', with `LL' denoting the +language and `CC' denoting the country, is the one use on systems based +on GNU libc. On other systems, some variations of this scheme are +used, such as `LL' or `LL_CC.ENCODING'. You can get the list of +locales supported by your system for your language by running the +command `locale -a | grep '^LL''. + + Not all programs have translations for all languages. By default, an +English message is shown in place of a nonexistent translation. If you +understand other languages, you can set up a priority list of languages. +This is done through a different environment variable, called +`LANGUAGE'. GNU `gettext' gives preference to `LANGUAGE' over `LANG' +for the purpose of message handling, but you still need to have `LANG' +set to the primary language; this is required by other parts of the +system libraries. For example, some Swedish users who would rather +read translations in German than English for when Swedish is not +available, set `LANGUAGE' to `sv:de' while leaving `LANG' to `sv_SE'. + + Special advice for Norwegian users: The language code for Norwegian +bokma*l changed from `no' to `nb' recently (in 2003). During the +transition period, while some message catalogs for this language are +installed under `nb' and some older ones under `no', it's recommended +for Norwegian users to set `LANGUAGE' to `nb:no' so that both newer and +older translations are used. + + In the `LANGUAGE' environment variable, but not in the `LANG' +environment variable, `LL_CC' combinations can be abbreviated as `LL' +to denote the language's main dialect. For example, `de' is equivalent +to `de_DE' (German as spoken in Germany), and `pt' to `pt_PT' +(Portuguese as spoken in Portugal) in this context. + +1.3 Translating Teams +===================== + +For the Free Translation Project to be a success, we need interested +people who like their own language and write it well, and who are also +able to synergize with other translators speaking the same language. +Each translation team has its own mailing list. The up-to-date list of +teams can be found at the Free Translation Project's homepage, +`http://translationproject.org/', in the "Teams" area. + + If you'd like to volunteer to _work_ at translating messages, you +should become a member of the translating team for your own language. +The subscribing address is _not_ the same as the list itself, it has +`-request' appended. For example, speakers of Swedish can send a +message to `sv-request@li.org', having this message body: + + subscribe + + Keep in mind that team members are expected to participate +_actively_ in translations, or at solving translational difficulties, +rather than merely lurking around. If your team does not exist yet and +you want to start one, or if you are unsure about what to do or how to +get started, please write to `coordinator@translationproject.org' to +reach the coordinator for all translator teams. + + The English team is special. It works at improving and uniformizing +the terminology in use. Proven linguistic skills are praised more than +programming skills, here. + +1.4 Available Packages +====================== + +Languages are not equally supported in all packages. The following +matrix shows the current state of internationalization, as of June +2010. The matrix shows, in regard of each package, for which languages +PO files have been submitted to translation coordination, with a +translation percentage of at least 50%. + + Ready PO files af am an ar as ast az be be@latin bg bn_IN bs ca + +--------------------------------------------------+ + a2ps | [] [] | + aegis | | + ant-phone | | + anubis | | + aspell | [] [] | + bash | | + bfd | | + bibshelf | [] | + binutils | | + bison | | + bison-runtime | [] | + bluez-pin | [] [] | + bombono-dvd | | + buzztard | | + cflow | | + clisp | | + coreutils | [] [] | + cpio | | + cppi | | + cpplib | [] | + cryptsetup | | + dfarc | | + dialog | [] [] | + dico | | + diffutils | [] | + dink | | + doodle | | + e2fsprogs | [] | + enscript | [] | + exif | | + fetchmail | [] | + findutils | [] | + flex | [] | + freedink | | + gas | | + gawk | [] [] | + gcal | [] | + gcc | | + gettext-examples | [] [] [] [] | + gettext-runtime | [] [] | + gettext-tools | [] [] | + gip | [] | + gjay | | + gliv | [] | + glunarclock | [] [] | + gnubiff | | + gnucash | [] | + gnuedu | | + gnulib | | + gnunet | | + gnunet-gtk | | + gnutls | | + gold | | + gpe-aerial | | + gpe-beam | | + gpe-bluetooth | | + gpe-calendar | | + gpe-clock | [] | + gpe-conf | | + gpe-contacts | | + gpe-edit | | + gpe-filemanager | | + gpe-go | | + gpe-login | | + gpe-ownerinfo | [] | + gpe-package | | + gpe-sketchbook | | + gpe-su | [] | + gpe-taskmanager | [] | + gpe-timesheet | [] | + gpe-today | [] | + gpe-todo | | + gphoto2 | | + gprof | [] | + gpsdrive | | + gramadoir | | + grep | | + grub | [] [] | + gsasl | | + gss | | + gst-plugins-bad | [] | + gst-plugins-base | [] | + gst-plugins-good | [] | + gst-plugins-ugly | [] | + gstreamer | [] [] [] | + gtick | | + gtkam | [] | + gtkorphan | [] | + gtkspell | [] [] [] | + gutenprint | | + hello | [] | + help2man | | + hylafax | | + idutils | | + indent | [] [] | + iso_15924 | | + iso_3166 | [] [] [] [] [] [] [] | + iso_3166_2 | | + iso_4217 | | + iso_639 | [] [] [] [] | + iso_639_3 | | + jwhois | | + kbd | | + keytouch | [] | + keytouch-editor | | + keytouch-keyboa... | [] | + klavaro | [] | + latrine | | + ld | [] | + leafpad | [] [] | + libc | [] [] | + libexif | () | + libextractor | | + libgnutls | | + libgpewidget | | + libgpg-error | | + libgphoto2 | | + libgphoto2_port | | + libgsasl | | + libiconv | [] | + libidn | | + lifelines | | + liferea | [] [] | + lilypond | | + linkdr | [] | + lordsawar | | + lprng | | + lynx | [] | + m4 | | + mailfromd | | + mailutils | | + make | | + man-db | | + man-db-manpages | | + minicom | | + mkisofs | | + myserver | | + nano | [] [] | + opcodes | | + parted | | + pies | | + popt | | + psmisc | | + pspp | [] | + pwdutils | | + radius | [] | + recode | [] [] | + rosegarden | | + rpm | | + rush | | + sarg | | + screem | | + scrollkeeper | [] [] [] | + sed | [] [] | + sharutils | [] [] | + shishi | | + skencil | | + solfege | | + solfege-manual | | + soundtracker | | + sp | | + sysstat | | + tar | [] | + texinfo | | + tin | | + unicode-han-tra... | | + unicode-transla... | | + util-linux-ng | [] | + vice | | + vmm | | + vorbis-tools | | + wastesedge | | + wdiff | | + wget | [] [] | + wyslij-po | | + xchat | [] [] [] [] | + xdg-user-dirs | [] [] [] [] [] [] [] [] [] | + xkeyboard-config | [] [] | + +--------------------------------------------------+ + af am an ar as ast az be be@latin bg bn_IN bs ca + 6 0 1 2 3 19 1 10 3 28 3 1 38 + + crh cs da de el en en_GB en_ZA eo es et eu fa + +-------------------------------------------------+ + a2ps | [] [] [] [] [] [] [] | + aegis | [] [] [] | + ant-phone | [] () | + anubis | [] [] | + aspell | [] [] [] [] [] | + bash | [] [] [] | + bfd | [] | + bibshelf | [] [] [] | + binutils | [] | + bison | [] [] | + bison-runtime | [] [] [] [] | + bluez-pin | [] [] [] [] [] [] | + bombono-dvd | [] | + buzztard | [] [] [] | + cflow | [] [] | + clisp | [] [] [] [] | + coreutils | [] [] [] [] | + cpio | | + cppi | | + cpplib | [] [] [] | + cryptsetup | [] | + dfarc | [] [] [] | + dialog | [] [] [] [] [] | + dico | | + diffutils | [] [] [] [] [] [] | + dink | [] [] [] | + doodle | [] | + e2fsprogs | [] [] [] | + enscript | [] [] [] | + exif | () [] [] | + fetchmail | [] [] () [] [] [] | + findutils | [] [] [] | + flex | [] [] | + freedink | [] [] [] | + gas | [] | + gawk | [] [] [] | + gcal | [] | + gcc | [] [] | + gettext-examples | [] [] [] [] | + gettext-runtime | [] [] [] [] | + gettext-tools | [] [] [] | + gip | [] [] [] [] | + gjay | [] | + gliv | [] [] [] | + glunarclock | [] [] | + gnubiff | () | + gnucash | [] () () () () | + gnuedu | [] [] | + gnulib | [] [] | + gnunet | | + gnunet-gtk | [] | + gnutls | [] [] | + gold | [] | + gpe-aerial | [] [] [] [] | + gpe-beam | [] [] [] [] | + gpe-bluetooth | [] [] | + gpe-calendar | [] | + gpe-clock | [] [] [] [] | + gpe-conf | [] [] [] | + gpe-contacts | [] [] [] | + gpe-edit | [] [] | + gpe-filemanager | [] [] [] | + gpe-go | [] [] [] [] | + gpe-login | [] [] | + gpe-ownerinfo | [] [] [] [] | + gpe-package | [] [] [] | + gpe-sketchbook | [] [] [] [] | + gpe-su | [] [] [] [] | + gpe-taskmanager | [] [] [] [] | + gpe-timesheet | [] [] [] [] | + gpe-today | [] [] [] [] | + gpe-todo | [] [] [] | + gphoto2 | [] [] () [] [] [] | + gprof | [] [] [] | + gpsdrive | [] [] [] | + gramadoir | [] [] [] | + grep | [] | + grub | [] [] | + gsasl | [] | + gss | | + gst-plugins-bad | [] [] [] [] [] | + gst-plugins-base | [] [] [] [] [] | + gst-plugins-good | [] [] [] [] [] [] | + gst-plugins-ugly | [] [] [] [] [] [] | + gstreamer | [] [] [] [] [] | + gtick | [] () [] | + gtkam | [] [] () [] [] | + gtkorphan | [] [] [] [] | + gtkspell | [] [] [] [] [] [] [] | + gutenprint | [] [] [] | + hello | [] [] [] [] | + help2man | [] | + hylafax | [] [] | + idutils | [] [] | + indent | [] [] [] [] [] [] [] | + iso_15924 | [] () [] [] | + iso_3166 | [] [] [] [] () [] [] [] () | + iso_3166_2 | () | + iso_4217 | [] [] [] () [] [] | + iso_639 | [] [] [] [] () [] [] | + iso_639_3 | [] | + jwhois | [] | + kbd | [] [] [] [] [] | + keytouch | [] [] | + keytouch-editor | [] [] | + keytouch-keyboa... | [] | + klavaro | [] [] [] [] | + latrine | [] () | + ld | [] [] | + leafpad | [] [] [] [] [] [] | + libc | [] [] [] [] | + libexif | [] [] () | + libextractor | | + libgnutls | [] | + libgpewidget | [] [] | + libgpg-error | [] [] | + libgphoto2 | [] () | + libgphoto2_port | [] () [] | + libgsasl | | + libiconv | [] [] [] [] [] | + libidn | [] [] [] | + lifelines | [] () | + liferea | [] [] [] [] [] | + lilypond | [] [] [] | + linkdr | [] [] [] | + lordsawar | [] | + lprng | | + lynx | [] [] [] [] | + m4 | [] [] [] [] | + mailfromd | | + mailutils | [] | + make | [] [] [] | + man-db | | + man-db-manpages | | + minicom | [] [] [] [] | + mkisofs | | + myserver | | + nano | [] [] [] | + opcodes | [] [] | + parted | [] [] | + pies | | + popt | [] [] [] [] [] | + psmisc | [] [] [] | + pspp | [] | + pwdutils | [] | + radius | [] | + recode | [] [] [] [] [] [] | + rosegarden | () () () | + rpm | [] [] [] | + rush | | + sarg | | + screem | | + scrollkeeper | [] [] [] [] [] | + sed | [] [] [] [] [] [] | + sharutils | [] [] [] [] | + shishi | | + skencil | [] () [] | + solfege | [] [] [] | + solfege-manual | [] [] | + soundtracker | [] [] [] | + sp | [] | + sysstat | [] [] [] | + tar | [] [] [] [] | + texinfo | [] [] [] | + tin | [] [] | + unicode-han-tra... | | + unicode-transla... | | + util-linux-ng | [] [] [] [] | + vice | () () | + vmm | [] | + vorbis-tools | [] [] | + wastesedge | [] | + wdiff | [] [] | + wget | [] [] [] | + wyslij-po | | + xchat | [] [] [] [] [] | + xdg-user-dirs | [] [] [] [] [] [] [] [] [] | + xkeyboard-config | [] [] [] [] [] [] | + +-------------------------------------------------+ + crh cs da de el en en_GB en_ZA eo es et eu fa + 5 64 105 117 18 1 8 0 28 89 18 19 0 + + fi fr ga gl gu he hi hr hu hy id is it ja ka kn + +----------------------------------------------------+ + a2ps | [] [] [] [] | + aegis | [] [] | + ant-phone | [] [] | + anubis | [] [] [] [] | + aspell | [] [] [] [] | + bash | [] [] [] [] | + bfd | [] [] [] | + bibshelf | [] [] [] [] [] | + binutils | [] [] [] | + bison | [] [] [] [] | + bison-runtime | [] [] [] [] [] [] | + bluez-pin | [] [] [] [] [] [] [] [] | + bombono-dvd | [] | + buzztard | [] | + cflow | [] [] [] | + clisp | [] | + coreutils | [] [] [] [] [] | + cpio | [] [] [] [] | + cppi | [] [] | + cpplib | [] [] [] | + cryptsetup | [] [] [] | + dfarc | [] [] [] | + dialog | [] [] [] [] [] [] [] | + dico | | + diffutils | [] [] [] [] [] [] [] [] [] | + dink | [] | + doodle | [] [] | + e2fsprogs | [] [] | + enscript | [] [] [] [] | + exif | [] [] [] [] [] [] | + fetchmail | [] [] [] [] | + findutils | [] [] [] [] [] [] | + flex | [] [] [] | + freedink | [] [] [] | + gas | [] [] | + gawk | [] [] [] [] () [] | + gcal | [] | + gcc | [] | + gettext-examples | [] [] [] [] [] [] [] | + gettext-runtime | [] [] [] [] [] [] | + gettext-tools | [] [] [] [] | + gip | [] [] [] [] [] [] | + gjay | [] | + gliv | [] () | + glunarclock | [] [] [] [] | + gnubiff | () [] () | + gnucash | () () () () () [] | + gnuedu | [] [] | + gnulib | [] [] [] [] [] [] | + gnunet | | + gnunet-gtk | [] | + gnutls | [] [] | + gold | [] [] | + gpe-aerial | [] [] [] | + gpe-beam | [] [] [] [] | + gpe-bluetooth | [] [] [] [] | + gpe-calendar | [] [] | + gpe-clock | [] [] [] [] [] | + gpe-conf | [] [] [] [] | + gpe-contacts | [] [] [] [] | + gpe-edit | [] [] [] | + gpe-filemanager | [] [] [] [] | + gpe-go | [] [] [] [] [] | + gpe-login | [] [] [] | + gpe-ownerinfo | [] [] [] [] [] | + gpe-package | [] [] [] | + gpe-sketchbook | [] [] [] [] | + gpe-su | [] [] [] [] [] [] | + gpe-taskmanager | [] [] [] [] [] | + gpe-timesheet | [] [] [] [] [] | + gpe-today | [] [] [] [] [] [] [] | + gpe-todo | [] [] [] | + gphoto2 | [] [] [] [] [] [] | + gprof | [] [] [] [] | + gpsdrive | [] [] [] | + gramadoir | [] [] [] | + grep | [] [] | + grub | [] [] [] [] | + gsasl | [] [] [] [] [] | + gss | [] [] [] [] [] | + gst-plugins-bad | [] [] [] [] [] [] | + gst-plugins-base | [] [] [] [] [] [] | + gst-plugins-good | [] [] [] [] [] [] | + gst-plugins-ugly | [] [] [] [] [] [] | + gstreamer | [] [] [] [] [] | + gtick | [] [] [] [] [] | + gtkam | [] [] [] [] [] | + gtkorphan | [] [] [] | + gtkspell | [] [] [] [] [] [] [] [] [] | + gutenprint | [] [] [] [] | + hello | [] [] [] | + help2man | [] [] | + hylafax | [] | + idutils | [] [] [] [] [] [] | + indent | [] [] [] [] [] [] [] [] | + iso_15924 | [] () [] [] | + iso_3166 | [] () [] [] [] [] [] [] [] [] [] [] | + iso_3166_2 | () [] [] [] | + iso_4217 | [] () [] [] [] [] | + iso_639 | [] () [] [] [] [] [] [] [] | + iso_639_3 | () [] [] | + jwhois | [] [] [] [] [] | + kbd | [] [] | + keytouch | [] [] [] [] [] [] | + keytouch-editor | [] [] [] [] [] | + keytouch-keyboa... | [] [] [] [] [] | + klavaro | [] [] | + latrine | [] [] [] | + ld | [] [] [] [] | + leafpad | [] [] [] [] [] [] [] () | + libc | [] [] [] [] [] | + libexif | [] | + libextractor | | + libgnutls | [] [] | + libgpewidget | [] [] [] [] | + libgpg-error | [] [] | + libgphoto2 | [] [] [] | + libgphoto2_port | [] [] [] | + libgsasl | [] [] [] [] [] | + libiconv | [] [] [] [] [] [] | + libidn | [] [] [] [] | + lifelines | () | + liferea | [] [] [] [] | + lilypond | [] [] | + linkdr | [] [] [] [] [] | + lordsawar | | + lprng | [] | + lynx | [] [] [] [] [] | + m4 | [] [] [] [] [] [] | + mailfromd | | + mailutils | [] [] | + make | [] [] [] [] [] [] [] [] [] | + man-db | [] [] | + man-db-manpages | [] | + minicom | [] [] [] [] [] | + mkisofs | [] [] [] [] | + myserver | | + nano | [] [] [] [] [] [] | + opcodes | [] [] [] [] | + parted | [] [] [] [] | + pies | | + popt | [] [] [] [] [] [] [] [] [] | + psmisc | [] [] [] | + pspp | | + pwdutils | [] [] | + radius | [] [] | + recode | [] [] [] [] [] [] [] [] | + rosegarden | () () () () () | + rpm | [] [] | + rush | | + sarg | [] | + screem | [] [] | + scrollkeeper | [] [] [] [] | + sed | [] [] [] [] [] [] [] [] | + sharutils | [] [] [] [] [] [] [] | + shishi | [] | + skencil | [] | + solfege | [] [] [] [] | + solfege-manual | [] [] | + soundtracker | [] [] | + sp | [] () | + sysstat | [] [] [] [] [] | + tar | [] [] [] [] [] [] [] | + texinfo | [] [] [] [] | + tin | [] | + unicode-han-tra... | | + unicode-transla... | [] [] | + util-linux-ng | [] [] [] [] [] [] | + vice | () () () | + vmm | [] | + vorbis-tools | [] | + wastesedge | () () | + wdiff | [] | + wget | [] [] [] [] [] [] [] [] | + wyslij-po | [] [] [] | + xchat | [] [] [] [] [] [] [] [] [] | + xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] [] [] [] | + xkeyboard-config | [] [] [] [] [] | + +----------------------------------------------------+ + fi fr ga gl gu he hi hr hu hy id is it ja ka kn + 105 121 53 20 4 8 3 5 53 2 120 5 84 67 0 4 + + ko ku ky lg lt lv mk ml mn mr ms mt nb nds ne + +-----------------------------------------------+ + a2ps | [] | + aegis | | + ant-phone | | + anubis | [] [] | + aspell | [] | + bash | | + bfd | | + bibshelf | [] [] | + binutils | | + bison | [] | + bison-runtime | [] [] [] [] [] | + bluez-pin | [] [] [] [] [] | + bombono-dvd | | + buzztard | | + cflow | | + clisp | | + coreutils | [] | + cpio | | + cppi | | + cpplib | | + cryptsetup | | + dfarc | [] | + dialog | [] [] [] [] [] | + dico | | + diffutils | [] [] | + dink | | + doodle | | + e2fsprogs | | + enscript | | + exif | [] | + fetchmail | | + findutils | | + flex | | + freedink | [] | + gas | | + gawk | | + gcal | | + gcc | | + gettext-examples | [] [] [] [] | + gettext-runtime | [] | + gettext-tools | [] | + gip | [] [] | + gjay | | + gliv | | + glunarclock | [] | + gnubiff | | + gnucash | () () () () | + gnuedu | | + gnulib | | + gnunet | | + gnunet-gtk | | + gnutls | [] | + gold | | + gpe-aerial | [] | + gpe-beam | [] | + gpe-bluetooth | [] [] | + gpe-calendar | [] | + gpe-clock | [] [] [] [] [] | + gpe-conf | [] [] | + gpe-contacts | [] [] | + gpe-edit | [] | + gpe-filemanager | [] [] | + gpe-go | [] [] [] | + gpe-login | [] | + gpe-ownerinfo | [] [] | + gpe-package | [] [] | + gpe-sketchbook | [] [] | + gpe-su | [] [] [] [] [] [] | + gpe-taskmanager | [] [] [] [] [] [] | + gpe-timesheet | [] [] | + gpe-today | [] [] [] [] | + gpe-todo | [] [] | + gphoto2 | | + gprof | [] | + gpsdrive | | + gramadoir | | + grep | | + grub | | + gsasl | | + gss | | + gst-plugins-bad | [] [] [] [] | + gst-plugins-base | [] [] | + gst-plugins-good | [] [] | + gst-plugins-ugly | [] [] [] [] [] | + gstreamer | | + gtick | | + gtkam | [] | + gtkorphan | [] [] | + gtkspell | [] [] [] [] [] [] [] | + gutenprint | | + hello | [] [] [] | + help2man | | + hylafax | | + idutils | | + indent | | + iso_15924 | [] [] | + iso_3166 | [] [] () [] [] [] [] [] | + iso_3166_2 | | + iso_4217 | [] [] | + iso_639 | [] [] | + iso_639_3 | [] | + jwhois | [] | + kbd | | + keytouch | [] | + keytouch-editor | [] | + keytouch-keyboa... | [] | + klavaro | [] | + latrine | [] | + ld | | + leafpad | [] [] [] | + libc | [] | + libexif | | + libextractor | | + libgnutls | [] | + libgpewidget | [] [] | + libgpg-error | | + libgphoto2 | | + libgphoto2_port | | + libgsasl | | + libiconv | | + libidn | | + lifelines | | + liferea | | + lilypond | | + linkdr | | + lordsawar | | + lprng | | + lynx | | + m4 | | + mailfromd | | + mailutils | | + make | [] | + man-db | | + man-db-manpages | | + minicom | [] | + mkisofs | | + myserver | | + nano | [] [] | + opcodes | | + parted | | + pies | | + popt | [] [] [] | + psmisc | | + pspp | | + pwdutils | | + radius | | + recode | | + rosegarden | | + rpm | | + rush | | + sarg | | + screem | | + scrollkeeper | [] [] | + sed | | + sharutils | | + shishi | | + skencil | | + solfege | [] | + solfege-manual | | + soundtracker | | + sp | | + sysstat | [] | + tar | [] | + texinfo | [] | + tin | | + unicode-han-tra... | | + unicode-transla... | | + util-linux-ng | | + vice | | + vmm | | + vorbis-tools | | + wastesedge | | + wdiff | | + wget | [] | + wyslij-po | | + xchat | [] [] [] | + xdg-user-dirs | [] [] [] [] [] [] [] [] | + xkeyboard-config | [] [] [] | + +-----------------------------------------------+ + ko ku ky lg lt lv mk ml mn mr ms mt nb nds ne + 20 5 10 1 13 48 4 2 2 4 24 10 20 3 1 + + nl nn or pa pl ps pt pt_BR ro ru rw sk sl sq sr + +---------------------------------------------------+ + a2ps | [] [] [] [] [] [] [] [] | + aegis | [] [] [] | + ant-phone | [] [] | + anubis | [] [] [] | + aspell | [] [] [] [] [] | + bash | [] [] | + bfd | [] | + bibshelf | [] [] | + binutils | [] [] | + bison | [] [] [] | + bison-runtime | [] [] [] [] [] [] [] | + bluez-pin | [] [] [] [] [] [] [] [] | + bombono-dvd | [] () | + buzztard | [] [] | + cflow | [] | + clisp | [] [] | + coreutils | [] [] [] [] [] [] | + cpio | [] [] [] | + cppi | [] | + cpplib | [] | + cryptsetup | [] | + dfarc | [] | + dialog | [] [] [] [] | + dico | [] | + diffutils | [] [] [] [] [] [] | + dink | () | + doodle | [] [] | + e2fsprogs | [] [] | + enscript | [] [] [] [] [] | + exif | [] [] [] () [] | + fetchmail | [] [] [] [] | + findutils | [] [] [] [] [] | + flex | [] [] [] [] [] | + freedink | [] [] | + gas | | + gawk | [] [] [] [] | + gcal | | + gcc | [] | + gettext-examples | [] [] [] [] [] [] [] [] | + gettext-runtime | [] [] [] [] [] [] [] [] [] | + gettext-tools | [] [] [] [] [] [] | + gip | [] [] [] [] [] | + gjay | | + gliv | [] [] [] [] [] [] | + glunarclock | [] [] [] [] [] | + gnubiff | [] () | + gnucash | [] () () () | + gnuedu | [] | + gnulib | [] [] [] [] | + gnunet | | + gnunet-gtk | | + gnutls | [] [] | + gold | | + gpe-aerial | [] [] [] [] [] [] [] | + gpe-beam | [] [] [] [] [] [] [] | + gpe-bluetooth | [] [] | + gpe-calendar | [] [] [] [] | + gpe-clock | [] [] [] [] [] [] [] [] | + gpe-conf | [] [] [] [] [] [] [] | + gpe-contacts | [] [] [] [] [] | + gpe-edit | [] [] [] | + gpe-filemanager | [] [] [] | + gpe-go | [] [] [] [] [] [] [] [] | + gpe-login | [] [] | + gpe-ownerinfo | [] [] [] [] [] [] [] [] | + gpe-package | [] [] | + gpe-sketchbook | [] [] [] [] [] [] [] | + gpe-su | [] [] [] [] [] [] [] [] | + gpe-taskmanager | [] [] [] [] [] [] [] [] | + gpe-timesheet | [] [] [] [] [] [] [] [] | + gpe-today | [] [] [] [] [] [] [] [] | + gpe-todo | [] [] [] [] [] | + gphoto2 | [] [] [] [] [] [] [] [] | + gprof | [] [] [] | + gpsdrive | [] [] | + gramadoir | [] [] | + grep | [] [] [] [] | + grub | [] [] [] | + gsasl | [] [] [] [] | + gss | [] [] [] | + gst-plugins-bad | [] [] [] [] [] [] | + gst-plugins-base | [] [] [] [] [] | + gst-plugins-good | [] [] [] [] [] | + gst-plugins-ugly | [] [] [] [] [] [] | + gstreamer | [] [] [] [] [] | + gtick | [] [] [] | + gtkam | [] [] [] [] [] [] | + gtkorphan | [] | + gtkspell | [] [] [] [] [] [] [] [] [] [] | + gutenprint | [] [] | + hello | [] [] [] [] | + help2man | [] [] | + hylafax | [] | + idutils | [] [] [] [] [] | + indent | [] [] [] [] [] [] [] | + iso_15924 | [] [] [] [] | + iso_3166 | [] [] [] [] [] () [] [] [] [] [] [] [] [] | + iso_3166_2 | [] [] [] | + iso_4217 | [] [] [] [] [] [] [] [] | + iso_639 | [] [] [] [] [] [] [] [] [] | + iso_639_3 | [] [] | + jwhois | [] [] [] [] | + kbd | [] [] [] | + keytouch | [] [] [] | + keytouch-editor | [] [] [] | + keytouch-keyboa... | [] [] [] | + klavaro | [] [] | + latrine | [] [] | + ld | | + leafpad | [] [] [] [] [] [] [] [] [] | + libc | [] [] [] [] | + libexif | [] [] () [] | + libextractor | | + libgnutls | [] [] | + libgpewidget | [] [] [] | + libgpg-error | [] [] | + libgphoto2 | [] [] | + libgphoto2_port | [] [] [] [] [] | + libgsasl | [] [] [] [] [] | + libiconv | [] [] [] [] [] | + libidn | [] [] | + lifelines | [] [] | + liferea | [] [] [] [] [] () () [] | + lilypond | [] | + linkdr | [] [] [] | + lordsawar | | + lprng | [] | + lynx | [] [] [] | + m4 | [] [] [] [] [] | + mailfromd | [] | + mailutils | [] | + make | [] [] [] [] | + man-db | [] [] [] | + man-db-manpages | [] [] [] | + minicom | [] [] [] [] | + mkisofs | [] [] [] | + myserver | | + nano | [] [] [] [] | + opcodes | [] [] | + parted | [] [] [] [] | + pies | [] | + popt | [] [] [] [] | + psmisc | [] [] [] | + pspp | [] [] | + pwdutils | [] | + radius | [] [] [] | + recode | [] [] [] [] [] [] [] [] | + rosegarden | () () | + rpm | [] [] [] | + rush | [] [] | + sarg | | + screem | | + scrollkeeper | [] [] [] [] [] [] [] [] | + sed | [] [] [] [] [] [] [] [] [] | + sharutils | [] [] [] [] | + shishi | [] | + skencil | [] [] | + solfege | [] [] [] [] | + solfege-manual | [] [] [] | + soundtracker | [] | + sp | | + sysstat | [] [] [] [] | + tar | [] [] [] [] | + texinfo | [] [] [] [] | + tin | [] | + unicode-han-tra... | | + unicode-transla... | | + util-linux-ng | [] [] [] [] [] | + vice | [] | + vmm | [] | + vorbis-tools | [] [] | + wastesedge | [] | + wdiff | [] [] | + wget | [] [] [] [] [] [] [] | + wyslij-po | [] [] [] | + xchat | [] [] [] [] [] [] [] [] [] | + xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] [] [] [] [] | + xkeyboard-config | [] [] [] | + +---------------------------------------------------+ + nl nn or pa pl ps pt pt_BR ro ru rw sk sl sq sr + 135 10 4 7 105 1 29 62 47 91 3 54 46 9 37 + + sv sw ta te tg th tr uk vi wa zh_CN zh_HK zh_TW + +---------------------------------------------------+ + a2ps | [] [] [] [] [] | 27 + aegis | [] | 9 + ant-phone | [] [] [] [] | 9 + anubis | [] [] [] [] | 15 + aspell | [] [] [] | 20 + bash | [] [] [] | 12 + bfd | [] | 6 + bibshelf | [] [] [] | 16 + binutils | [] [] | 8 + bison | [] [] | 12 + bison-runtime | [] [] [] [] [] [] | 29 + bluez-pin | [] [] [] [] [] [] [] [] | 37 + bombono-dvd | [] | 4 + buzztard | [] | 7 + cflow | [] [] [] | 9 + clisp | | 10 + coreutils | [] [] [] [] | 22 + cpio | [] [] [] [] [] [] | 13 + cppi | [] [] | 5 + cpplib | [] [] [] [] [] [] | 14 + cryptsetup | [] [] | 7 + dfarc | [] | 9 + dialog | [] [] [] [] [] [] [] | 30 + dico | [] | 2 + diffutils | [] [] [] [] [] [] | 30 + dink | | 4 + doodle | [] [] | 7 + e2fsprogs | [] [] [] | 11 + enscript | [] [] [] [] | 17 + exif | [] [] [] | 16 + fetchmail | [] [] [] | 17 + findutils | [] [] [] [] [] | 20 + flex | [] [] [] [] | 15 + freedink | [] | 10 + gas | [] | 4 + gawk | [] [] [] [] | 18 + gcal | [] [] | 5 + gcc | [] [] [] | 7 + gettext-examples | [] [] [] [] [] [] [] | 34 + gettext-runtime | [] [] [] [] [] [] [] | 29 + gettext-tools | [] [] [] [] [] [] | 22 + gip | [] [] [] [] | 22 + gjay | [] | 3 + gliv | [] [] [] | 14 + glunarclock | [] [] [] [] [] | 19 + gnubiff | [] [] | 4 + gnucash | () [] () [] () | 10 + gnuedu | [] [] | 7 + gnulib | [] [] [] [] | 16 + gnunet | [] | 1 + gnunet-gtk | [] [] [] | 5 + gnutls | [] [] [] | 10 + gold | [] | 4 + gpe-aerial | [] [] [] | 18 + gpe-beam | [] [] [] | 19 + gpe-bluetooth | [] [] [] | 13 + gpe-calendar | [] [] [] [] | 12 + gpe-clock | [] [] [] [] [] | 28 + gpe-conf | [] [] [] [] | 20 + gpe-contacts | [] [] [] | 17 + gpe-edit | [] [] [] | 12 + gpe-filemanager | [] [] [] [] | 16 + gpe-go | [] [] [] [] [] | 25 + gpe-login | [] [] [] | 11 + gpe-ownerinfo | [] [] [] [] [] | 25 + gpe-package | [] [] [] | 13 + gpe-sketchbook | [] [] [] | 20 + gpe-su | [] [] [] [] [] | 30 + gpe-taskmanager | [] [] [] [] [] | 29 + gpe-timesheet | [] [] [] [] [] | 25 + gpe-today | [] [] [] [] [] [] | 30 + gpe-todo | [] [] [] [] | 17 + gphoto2 | [] [] [] [] [] | 24 + gprof | [] [] [] | 15 + gpsdrive | [] [] [] | 11 + gramadoir | [] [] [] | 11 + grep | [] [] [] | 10 + grub | [] [] [] | 14 + gsasl | [] [] [] [] | 14 + gss | [] [] [] | 11 + gst-plugins-bad | [] [] [] [] | 26 + gst-plugins-base | [] [] [] [] [] | 24 + gst-plugins-good | [] [] [] [] | 24 + gst-plugins-ugly | [] [] [] [] [] | 29 + gstreamer | [] [] [] [] | 22 + gtick | [] [] [] | 13 + gtkam | [] [] [] | 20 + gtkorphan | [] [] [] | 14 + gtkspell | [] [] [] [] [] [] [] [] [] | 45 + gutenprint | [] | 10 + hello | [] [] [] [] [] [] | 21 + help2man | [] [] | 7 + hylafax | [] | 5 + idutils | [] [] [] [] | 17 + indent | [] [] [] [] [] [] | 30 + iso_15924 | () [] () [] [] | 16 + iso_3166 | [] [] () [] [] () [] [] [] () | 53 + iso_3166_2 | () [] () [] | 9 + iso_4217 | [] () [] [] () [] [] | 26 + iso_639 | [] [] [] () [] () [] [] [] [] | 38 + iso_639_3 | [] () | 8 + jwhois | [] [] [] [] [] | 16 + kbd | [] [] [] [] [] | 15 + keytouch | [] [] [] | 16 + keytouch-editor | [] [] [] | 14 + keytouch-keyboa... | [] [] [] | 14 + klavaro | [] | 11 + latrine | [] [] [] | 10 + ld | [] [] [] [] | 11 + leafpad | [] [] [] [] [] [] | 33 + libc | [] [] [] [] [] | 21 + libexif | [] () | 7 + libextractor | [] | 1 + libgnutls | [] [] [] | 9 + libgpewidget | [] [] [] | 14 + libgpg-error | [] [] [] | 9 + libgphoto2 | [] [] | 8 + libgphoto2_port | [] [] [] [] | 14 + libgsasl | [] [] [] | 13 + libiconv | [] [] [] [] | 21 + libidn | () [] [] | 11 + lifelines | [] | 4 + liferea | [] [] [] | 21 + lilypond | [] | 7 + linkdr | [] [] [] [] [] | 17 + lordsawar | | 1 + lprng | [] | 3 + lynx | [] [] [] [] | 17 + m4 | [] [] [] [] | 19 + mailfromd | [] [] | 3 + mailutils | [] | 5 + make | [] [] [] [] | 21 + man-db | [] [] [] | 8 + man-db-manpages | | 4 + minicom | [] [] | 16 + mkisofs | [] [] | 9 + myserver | | 0 + nano | [] [] [] [] | 21 + opcodes | [] [] [] | 11 + parted | [] [] [] [] [] | 15 + pies | [] [] | 3 + popt | [] [] [] [] [] [] | 27 + psmisc | [] [] | 11 + pspp | | 4 + pwdutils | [] [] | 6 + radius | [] [] | 9 + recode | [] [] [] [] | 28 + rosegarden | () | 0 + rpm | [] [] [] | 11 + rush | [] [] | 4 + sarg | | 1 + screem | [] | 3 + scrollkeeper | [] [] [] [] [] | 27 + sed | [] [] [] [] [] | 30 + sharutils | [] [] [] [] [] | 22 + shishi | [] | 3 + skencil | [] [] | 7 + solfege | [] [] [] [] | 16 + solfege-manual | [] | 8 + soundtracker | [] [] [] | 9 + sp | [] | 3 + sysstat | [] [] | 15 + tar | [] [] [] [] [] [] | 23 + texinfo | [] [] [] [] [] | 17 + tin | | 4 + unicode-han-tra... | | 0 + unicode-transla... | | 2 + util-linux-ng | [] [] [] [] | 20 + vice | () () | 1 + vmm | [] | 4 + vorbis-tools | [] | 6 + wastesedge | | 2 + wdiff | [] [] | 7 + wget | [] [] [] [] [] | 26 + wyslij-po | [] [] | 8 + xchat | [] [] [] [] [] [] | 36 + xdg-user-dirs | [] [] [] [] [] [] [] [] [] [] | 63 + xkeyboard-config | [] [] [] | 22 + +---------------------------------------------------+ + 85 teams sv sw ta te tg th tr uk vi wa zh_CN zh_HK zh_TW + 178 domains 119 1 3 3 0 10 65 51 155 17 98 7 41 2618 + + Some counters in the preceding matrix are higher than the number of +visible blocks let us expect. This is because a few extra PO files are +used for implementing regional variants of languages, or language +dialects. + + For a PO file in the matrix above to be effective, the package to +which it applies should also have been internationalized and +distributed as such by its maintainer. There might be an observable +lag between the mere existence a PO file and its wide availability in a +distribution. + + If June 2010 seems to be old, you may fetch a more recent copy of +this `ABOUT-NLS' file on most GNU archive sites. The most up-to-date +matrix with full percentage details can be found at +`http://translationproject.org/extra/matrix.html'. + +1.5 Using `gettext' in new packages +=================================== + +If you are writing a freely available program and want to +internationalize it you are welcome to use GNU `gettext' in your +package. Of course you have to respect the GNU Library General Public +License which covers the use of the GNU `gettext' library. This means +in particular that even non-free programs can use `libintl' as a shared +library, whereas only free software can use `libintl' as a static +library or use modified versions of `libintl'. + + Once the sources are changed appropriately and the setup can handle +the use of `gettext' the only thing missing are the translations. The +Free Translation Project is also available for packages which are not +developed inside the GNU project. Therefore the information given above +applies also for every other Free Software Project. Contact +`coordinator@translationproject.org' to make the `.pot' files available +to the translation teams. + diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..fa9e7fe --- /dev/null +++ b/AUTHORS @@ -0,0 +1,13 @@ + Copyright (C) 2006, 2007 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + +Gawk was written by Paul Rubin, and finished by Paul Finlason and +Richard Stallman. + +David Trueman and Arnold Robbins took it over, with David doing most +of the work to make it compatible with new awk. + +Circa 1994, Arnold Robbins took over maintenance. diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..94a9ed0 --- /dev/null +++ b/COPYING @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..40a5c0e --- /dev/null +++ b/ChangeLog @@ -0,0 +1,427 @@ +2012-03-28 Arnold D. Robbins + + * 4.0.1: Release tar ball made. + +2012-03-28 Arnold D. Robbins + + * getopt.c: Add DJGPP to list of platforms where it's ok + to include . + * awkgram.y, builtin.c, ext.c, mbsupport.h, re.c: Update + copyright year. + +2012-03-21 Corinna Vinschen + + * getopt.c: Add Cygwin to list of platforms where it's ok + to include . + +2012-03-20 Arnold D. Robbins + + Get new getopt to work on Linux and C90 compilers: + + * getopt.c: Undef ELIDE_CODE for gawk. + (_getopt_internal_r): Init first.needs_free to 0. In test for -W + move executable code to after declarations for C90 compilers. + * getopt1.c: Undef ELIDE_CODE for gawk. + + Minor bug fix with printf, thanks to John Haque: + + * builtin.c (format_tree): Initialize base to zero at the top + of the while loop. + + Getting next tar ball ready: + + * configure.ac: Remove duplicate check for wcscoll. Thanks + to Stepan Kasal. + +2012-03-16 Arnold D. Robbins + + * getopt.c, getopt.h, getopt1.c, getopt_int.h, regcomp.c, + regex.c, regex.h, regex_internal.c, regex_internal.h, + regexec.c: Sync with GLIBC, what the heck. + +2012-03-14 Eli Zaretskii + + * mbsupport.h (btowc): Change for non-DJGPP. + * re.c (dfaerror): Add call to exit for DJGPP. + +2012-03-14 Arnold D. Robbins + + * regex_internal.c (re_string_skip_chars): Fix calculation of + remain_len with m.b. chars. Thanks to Stanislav Brabec + . + +2012-02-28 Arnold D. Robbins + + * main.c (init_groupset): Make `getgroups' failing a non-fatal + error. After all, what's the big deal? Should help on Plan 9. + +2012-02-27 Arnold D. Robbins + + * dfa.c (parse_bracket_exp): Revert changes 2012-02-15 to stay + in sync with grep. + * dfa.h (dfarerror): Add __attribute__ from grep. + +2012-02-15 Arnold D. Robbins + + Fix warnings from GCC 4.6.2 -Wall option. + + * awkgram.y (newline_eof): New function to replace body of + NEWLINE_EOF macro. + (yylex): Replace body of NEWLINE_EOF macro. + * dfa.c (parse_bracket_exp): Init variables to zero. + * ext.c (dummy, junk): Remove. + * regex_internal.c (re_string_reconstruct): Remove buf array. It was + set but not used. + +2012-02-10 Arnold D. Robbins + + * dfa.c: Sync with GNU grep. + +2012-02-07 Arnold D. Robbins + + * main.c (main): Move init of `output_fp' to before parsing of + program so that error messages from msg.c don't dump core. + Thanks to Michael Haardt . + +2012-01-13 Arnold D. Robbins + + * dfa.c [is_valid_unibtye_character]: Fix from GNU grep to + bug reported by me from Scott Deifik for DJGPP. + +2012-01-03 Arnold D. Robbins + + * dfa.c: Sync with GNU grep. + +2011-12-31 Arnold D. Robbins + + * awk.h [STREQ, STREQN]: Remove macros. + * awkgram.y, builtin.c, command.y, debug.c, eval.c, + io.c, msg.c: Change all uses to call strcmp, strncmp. + +2011-12-26 Arnold D. Robbins + + Finish Rational Range Interpretation (!) + + * dfa.c (match_mb_charset): Compare wide characters directly + instead of using wcscoll(). + * regexec.c (check_node_accept_byte): Ditto. + + Thanks to Paolo Bonzini for pointing these out. + +2011-12-06 John Haque + + * debug.c (source_find): Fix misplaced call to efree. + * profile.c (redir2str): Add a missing comma in the redirtab array. + * eval.c (r_interpret): Disallow call to exit if currule is undefined. + This avoids the possiblity of running END blocks more than once when + used in a user-defined sorted-in comparision function. + * array.c (sort_user_func): Adjust appropriately. + +2011-12-06 Arnold D. Robbins + + * awk.h, mbsupport.h: Changes for MBS support on DJGPP + and z/OS. + * io.c: Disable pty support on z/OS. + +2011-11-27 Arnold D. Robbins + + * dfa.c: Sync with GNU grep. + * dfa.h: Add _GL_ATTRIBUTE_PURE macro. Bleah. + +2011-11-14 John Haque + + * debug.c (set_breakpoint_at): Fix problem with setting + breakpoints in a switch statement. Thanks to Giorgio Palandri + for the bug report. + +2011-11-14 Arnold D. Robbins + + * mbsupport.h: Add check for HAVE_BTOWC, per Pat Rankin. + +2011-11-12 Eli Zaretskii + + * mbsupport.h: Additional glop for dfa.c in Windows environment. + +2011-11-01 Arnold D. Robbins + + * dfa.c: Move glop for ! MBS_SUPPORT to ... + * mbsupport.h: ... here. + * replace.c: Include missing_d/wcmisc.c if ! MBS_SUPPORT. + * regex_internal.h: Move include of mbsupport.h up and add + additional checks to avoid inclusion of wctype.h and wchar.h. + +2011-10-27 Arnold D. Robbins + + * builtin.c (do_strftime): Per Pat Rankin, instead of casting + fclock, use a long variable and check for negative or overflow. + +2011-10-25 Arnold D. Robbins + + * Makefile.am (dist-hook): Use `cd $(srcdir)/pc' so that + `make distcheck' works completely. + * builtin.c (do_strftime): Add cast to long int in check + for fclock < 0 for systems where time_t is unsigned (e.g., VMS). + +2011-10-25 Stefano Lattarini + + dist: generated file `version.c' is not removed by "make distclean" + + * Makefile.am (distcleancheck_listfiles): Define to ignore the + generated `version.c' file. + +2011-10-24 Arnold D. Robbins + + * dfa.c (wcscoll): Create for VMS. + * Makefile.am (dist-hook): Run sed scripts to make pc/config.h. + +2011-10-24 Eli Zaretskii + + * builtin.c [HAVE_POPEN_H]: Include "popen.h". + * README.git: Update for pc/ systems. + +2011-10-21 Arnold D. Robbins + + * Makefile.am (distcleancheck_listfiles): Added, per advice from + Stefano Lattarini . + * dfa.c: Additional faking of mbsupport for systems without it; + mainly VMS. + +2011-10-21 Stefano Lattarini + + * configure.ac (AM_C_PROTOTYPES): Remove call to this macro. + The comments in configure.ac said that the call to AM_C_PROTOTYPES + was needed for dfa.h, synced from GNU grep; but this statement is + not true anymore in grep since commit v2.5.4-24-g9b5e7d4 "replace + AC_CHECK_* with gnulib modules", dating back to 2009-11-26. Also, + the support for automatic de-ANSI-fication has been deprecated in + automake 1.11.2, and will be removed altogether in automake 1.12. + * vms/vms-conf.h (PROTOTYPES, __PROTOTYPES): Remove these #define, + they are not used anymore. + * pc/config.h (PROTOTYPES): Likewise. + +2011-10-18 Dave Pitts + + * dfa.c: Move some decls to the top of their functions for + C90 compilers. + +2011-10-18 Arnold D. Robbins + + * builtin.c (do_strftime): Add check for negative / overflowed + time_t value with fatal error. Thanks to Hermann Peifer + for the bug report. + * dfa.c (setbit_wc): Non-MBS version. Add a return false + since VMS compiler doesn't understand that abort doesn't return. + +2011-10-10 Arnold D. Robbins + + * builtin.c (do_sub): Init textlen to zero to avoid "may be + used unitialized" warning. Thanks to Corinna Vinschen for + pointing this out. + * eval.c (unwind_stack): Add parentheses around condition in while + to avoid overzealous warning from GCC. + +2011-09-30 Eli Zaretskii + + * io.c (remap_std_file): Fix non-portable code that caused + redirected "print" to fail if a previous read from standard input + returned EOF. Reported by David Millis . + (remap_std_file): Per Eli's suggestion, removed the leading close + of oldfd and will let dup2 do the close for us. + +2011-10-09 Arnold D. Robbins + + * dfa.c: Sync with GNU grep. + +2011-10-04 Arnold D. Robbins + + * awk.h, main.c (gawk_mb_cur_max): Make it a constant 1 when + MBS_SUPPORT isn't available to allow GCC dead code constant + expression computation and dead code elimination to help out. + +2011-10-02 Arnold D. Robbins + + * io.c (rsnullscan, get_a_record): Fix the cases where terminators + are incomplete when RS == "". Also fix the case where the new value + is shorter than the old one. Based on patch from Rogier + as submitted by Jeroen Schot + . + +2011-09-24 Arnold D. Robbins + + * eval.c, io.c, re.c: Fix some spelling errors. Thanks to + Jeroen Schot . + +2011-09-21 Arnold D. Robbins + + * dfa.c, mbsupport.h: Sync with GNU grep. Large amount of changes + that remove many ifdefs, moving many conditions for multibyte + support into regular C code and relying GCC's dead code optimization + to elimnate code that won't be needed. + * dfa.c: For gawk, add a number of additional defines so that things + will compile if MBS_SUPPORT is 0. + * array.c, awk.h, awkgram.y, builtin.c, eval.c, field.c, main.c, + node.c, re.c: Change `#ifdef MBS_SUPPORT' to `#if MBS_SUPPORT'. + * awk.h, regex_internal.h: Move NO_MBSUPPORT handling to ... + * mbsupport.h: ...here. + +2011-09-16 Arnold D. Robbins + + * dfa.c: Sync with GNU grep. + +2011-09-03 Arnold D. Robbins + + * dfa.c: Sync with GNU grep. + +2011-08-24 Arnold D. Robbins + + Fix pty co-process communication on Ubuntu GNU/Linux. + + * io.c: Add include of to get definition of TIOCSCTTY. + (two_way_open): Move call for this ioctl to after setsid() call. + +2011-08-23 Arnold D. Robbins + + * regex_internal.c (re_string_fetch_byte_case ): Remove + __attribute((pure)) since it causes failures with gcc -O2 + -fno-inline. Thanks to Neil Cahill + for reporting the bug. + +2011-08-10 John Haque + + BEGINFILE/ENDFILE related code redone. + + * awk.h (prev_frame_size, has_endfile, target_get_record, + target_newfile): New defines. + * awkgram.y (mk_program): Initialize has_endfile appropriately for + Op_get_record. + (parse_program): Initialize new jump targets for + Op_get_record and Op_newfile. + * eval.c (unwind_stack): Change argument to number of + items to be left in the stack. Adjust code. + (pop_fcall, pop_stack): New defines. + (setup_frame): Initialize prev_frame_size. + (exec_state, EXEC_STATE): New structure and typedef. + (exec_state_stack): New variable. + (push_exec_state, pop_exec_state): New functions to save and + later retrieve an execution state. + (r_interpret): Use the new functions and the defines in + cases Op_K_getline, Op_after_beginfile, Op_after_endfile, + Op_newfile and Op_K_exit. + * io.c (after_beginfile): When skipping a file using nextfile, + return zero in case there was an error opening the file. + (has_endfile): Nuke global variable. + (inrec): Add a second argument to pass errno to the calling + routine. + * debug.c (print_instruction): Update cases. + +2011-08-10 Arnold D. Robbins + + Fix (apparently long-standing) problem with FIELDWIDTHS. + Thanks to Johannes Meixner . + + * field.c (set_FIELDWIDTHS): Adjust calculations. + + Fix problem with FPAT, reported by "T. X. G." + + * awk.h (Regexp): Add new member 'non_empty'. + * field.c (fpat_parse_field): Save/restore local variable non_empty + from member in Regexp struct. + +2011-08-09 Arnold D. Robbins + + Fix pty issue reported by "T. X. G." + + * configure.ac: Check for setsid. + * awk.h: If not HAVE_SETSID define it as an empty macro. + * io.c (two_way_open): Call setsid if using pty's. + +2011-07-29 Eli Zaretskii + + * builtin.c (format_tree): Rename small -> small_flag, + big -> big_flag, bigbig -> bigbig_flag. Solves compilation errors + when building Gawk with libsigsegv on MS-Windows, see + https://lists.gnu.org/archive/html/bug-gawk/2011-07/msg00029.html. + +2011-07-28 Arnold D. Robbins + + * builtin.c (do_sub): Revert to gawk 3.1 behavior for backslash + handling. It was stupid to think I could break compatibility. + Thanks to John Ellson for raising + the issue. + +2011-07-26 John Haque + + * eval.c (r_interpret): In cases Op_var_assign and Op_field_assign, + include Op_K_getline_redir in the test for skipping the routine. + +2011-07-26 John Haque + + Fix handling of assign routines for 'getline var'. + Rework the previous fix for (g)sub. + + * awk.h: New define assign_ctxt for use in Op_var_assign + and Op_field_assign opcodes. Remove define AFTER_ASSIGN. + * awkgram.y (snode, mk_getline): Initialize assign_ctxt. + * builtin.c (do_sub): Adjust to take only the first two + arguments. + * eval.c (r_interpret): In cases Op_var_assign and Op_field_assign, + skip the routine as appropriate. Adjust case Op_sub_builtin. + * main.c (get_spec_varname): New function. + * debug.c (print_instruction): Use the new function to get + special variable name. + +2011-07-17 Arnold D. Robbins + + * main.c (varinit): Mark FPAT as NON_STANDARD. Thanks to + Wolfgang Seeberg for the report. + * Makefile.am (EXTRA_DIST): Add po/README, per advice from + Bruno Haible. + * dfa.c: Sync with GNU grep. + * xalloc.h (xzalloc): New function, from GNU grep, for dfa.c. + * README: Note that bug list is really a real mailing list. + +2011-07-16 Arnold D. Robbins + + * Makefile.am (AUTOMAKE_OPTIONS): Removed. + * configure.ac (AM_INIT_AUTOMAKE): Removed dist-bzip2 option, on + advice from Karl Berry. + +2011-07-15 John Haque + + * awk.h (Op_sub_builtin): New opcode. + (GSUB, GENSUB, AFTER_ASSIGN, LITERAL): New flags for + Op_sub_builtin. + * awkgram.y (struct tokentab): Change opcode to Op_sub_builtin + for sub, gsub and gensub. + (snode): Update processing of sub, gsub and gensub. + * builtin.c (do_sub, do_gsub, do_gensub): Nuke. + (sub_common): Renamed to do_sub. Relocate gensub argument + handling code from do_gensub to here; Simplify the code a + little bit. + * eval.c (r_interpret): Handle Op_sub_builtin. Avoid field + re-splitting or $0 rebuilding if (g)sub target string is + a field and no substitutions were done. + * pprint (profile.c): Add case for the new opcode. + * print_instruction (debug.c): Ditto. + +2011-07-15 Arnold D. Robbins + + * awk.h: Typo fix: "loner" --> longer. Thanks to Nelson Beebe. + * builtin.c (efwrite): Fix flushing test back to what it was + in 3.1.8. Thanks to Strefil for the problem + report. + * configure.ac: Bump version to 4.0.0a for stable branch. + +2011-06-24 Arnold D. Robbins + + * Makefile.am (EXTRA_DIST): Add ChangeLog.0. + * 4.0.0: Remake the tar ball. + +2011-06-23 Arnold D. Robbins + + * configure.ac: Update version to 4.0.0. + * configure: Regenerated. + * ChangeLog.0: Rotated ChangeLog into this file. + * ChangeLog: Created anew for gawk 4.0.0 and on. + * README: Bump version to 4.0.0. + * 4.0.0: Release tar ball made. diff --git a/ChangeLog.0 b/ChangeLog.0 new file mode 100644 index 0000000..af6bd99 --- /dev/null +++ b/ChangeLog.0 @@ -0,0 +1,9885 @@ +Mon Jun 20 20:33:26 2011 Arnold D. Robbins + + * dfa.c (dfaanalyze): Allocate the right number of leaves to + avoid crashes. Thanks to Jim Meyering. + +Mon Jun 20 20:22:35 2011 Arnold D. Robbins + + * dfa.c (setbit_c, setbit_case_fold_c): Compare btowc result against + WEOF. Thanks to Eli Zaretskii for pointing out the problem. + +Mon Jun 20 20:22:26 2011 Pat Rankin + + * dfa.c (addtok_wc): enclose prototype within #if MBS_SUPPORT. + +Fri Jun 17 11:09:22 2011 Arnold D. Robbins + + * Release 3.1.86: Final beta test tar ball for 4.0. + +Fri Jun 17 10:55:27 2011 Arnold D. Robbins + + Implement Rational Range Interpretation (RRI) directly in code. + + * regex.h [RE_RANGES_IGNORE_LOCALES]: Remove macro and its use. + * dfa.c (parse_bracket_exp): Remove use of RE_RANGES_IGNORE_LOCALES + and just do it in code. + (hard-locale.h): Remove include. + (hard_LC_COLLATE): Remove variable and its uses. + * re.c (resetup): Remove use of RE_RANGES_IGNORE_LOCALES. + * regcomp.c (build_range_exp): Remove use of RE_RANGES_IGNORE_LOCALES + and just do it in code. Remove cmp_buf array; it's no longer needed. + * Makefile.am (base_sources): Remove hard_locale.h and hard_locale.c. + * hard_locale.h, hard_locale.c: Removed from dist. + +Sun Jun 12 23:43:06 2011 Arnold D. Robbins + + * re.c (resetup): Always turn on RE_RANGES_IGNORE_LOCALES. + Add justifying comment with URLs for the relevant portions of + POSIX. Thanks to Paul Eggert for pointing out the happy change + to the rules and supplying the URLs. + +Wed Jun 8 22:41:30 2011 Arnold D. Robbins + + * regcomp.c (build_range_exp): Add check for RE_NO_EMPTY_RANGES + from GNULIB regcomp.c, courtesy of GNU grep. + +Wed Jun 8 22:10:03 2011 Arnold D. Robbins + + * dfa.c: Sync with GNU grep. + +Sun Jun 5 21:49:30 2011 Arnold D. Robbins + + * Release 3.1.85: Fourth beta test tar ball for 4.0. + +Sun Jun 5 21:39:17 2011 Arnold D. Robbins + + * field.c (fpat_parse_field): Bug fix. Thanks to + "Radoulov, Dimitre" for pointing + out the problem. + +Fri Jun 3 10:39:17 2011 Arnold D. Robbins + + * regcomp.c (build_range_exp): Make syntax the first argument, + for compatibility with gnulib version of the file. + +Wed Jun 1 06:29:27 2011 Pat Rankin + + * re.c (check_bracket_exp): Fix typo. + +Tue May 31 23:01:00 2011 John Haque + + * re.c (check_bracket_exp): Use mem* routines instead of str* + for searching. + * main.c (arg_assign): Disallow builtin or user-defined function + as the name of a variable. + * awkgram.y (check_special): Rework so can be called from + arg_assign. + +Tue May 31 22:23:41 2011 Arnold D. Robbins + + In order to attain the goal of having ranges act like they are + always in the C locale, bit the bullet and did the work in + the regex and dfa engines. The pre-processing routine was not + handling too many cases that a full regexp parser would catch. + + * regex.h [RE_RANGES_IGNORE_LOCALES]: New syntax bit. + (RE_SYNTAX_GNU_AWK): Use it. + * dfa.c (parse_bracket_exp): If the RE_RANGES_IGNORE_LOCALES + is set, ignore locales when building a range. + * re.c (expand_range): Remove function and declaration. + (add_char): Remove function and declaration. + (make_regexp): Remove use of expand_range. + (resetup): Add RE_RANGES_IGNORE_LOCALES if --traditional. + * regcomp.c (build_range_exp): Add syntax variable as last argument. + Add code to check for RE_RANGES_IGNORE_LOCALES and do the right thing. + Adjust all calls. + +Sun May 29 22:48:41 2011 Arnold D. Robbins + + * re.c (expand_range): Handle cases where expanded range + includes '\\' (and ']'). Thanks to Juergen Daubert . + Fatal error if end point is below start point ([z-a]), + thanks to John Haque. Don't repeat the last character in + the expansion. Thanks to Arnold Robbins. + +Fri May 27 10:01:17 2011 Arnold D. Robbins + + * Release 3.1.84: Third beta test tar ball for 4.0. + +Thu May 26 22:10:08 2011 Arnold D. Robbins + + * field.c (get_field): Enhance logic for setting NF if we're + using FPAT to parse fields. Can end up with weird cases. Thanks + to Pat Rankin for pointing them out. + +Mon May 23 22:06:13 2011 Arnold D. Robbins + + * awkgram.y: Allow newline after comma in range patterns, + per POSIX. Thanks to discussion in comp.lang.awk. (!!!) + +Mon May 23 22:02:46 2011 John Haque + + * ext.c (get_actual_argument): Change argument type from + Node_var_new to Node_var when used as a scalar. + +Sun May 22 11:56:40 2011 Arnold D. Robbins + + * main.c (varinit): Give FPAT a reasonable default value. + * field (get_field): Adjust test for at end of record to >=; + fpat_parse_field can go beyond when matching null regexps. + Thanks to Pat Rankin. + +Fri May 20 11:00:17 2011 Arnold D. Robbins + + * regex_internal.h (__attribute_warn_unused_result__): Always + ifdef out. Bleah. + +Thu May 19 17:13:18 2011 Arnold D. Robbins + + * Release 3.1.83: Second beta test tar ball for 4.0. + +Thu May 19 16:47:19 2011 Arnold D. Robbins + + * awkgram.y (dump_vars): Fix warning message. Thanks to Pat Rankin. + * main.c (usage): No space allowed after -d and -p. Also thanks + to Pat Rankin. + +Thu May 19 16:34:04 2011 Pat Rankin + + * regex_internal.h (__attribute_warn_unused_result__): Define with + empty expansion for !__GNUC__ configuration. + +Wed May 18 22:13:18 2011 Arnold D. Robbins + + * Release 3.1.82: Beta test tar ball for 4.0, we hope! + +Wed May 18 21:47:54 2011 Arnold D. Robbins + + * io.c (PIPES_SIMULATED): Simplify the case where PIPES_SIMULATED + is true but using temporary files - that code not needed anymore. + * regcomp.c, regex.h, regex_internal.c, regex_internal.h, + regexec.c: Sync with GLIBC. Why not. + +Mon May 16 17:55:25 2011 Arnold D. Robbins + + * awkgram.c: Regenerated using bison 2.5. + +Sat May 14 22:25:50 2011 Arnold D. Robbins + + * io.c (nextfile): Use `in_array' in main loop to see if element + of ARGV exists, instead of using `assoc_lookup'. The latter creates + the element! A day one bug! + * dfa.c (parse_bracket_exp): For z/OS init pattern manually. + +Mon May 9 16:30:49 2011 Arnold D. Robbins + + * array.c (sort_up_value_type): Remove unused variable ret. + (do_delete): Initialize local variables to silence warnings. + Thanks to Michal Jaegermann. + +Mon May 9 15:07:29 2011 Corinna Vinschen + + * awk.h: Remove cygwin code for libsigsegv. + +Sun May 8 20:38:03 2011 John Haque + + * eval.c (r_interpret): In case Op_sub_array, store only the + subarray index as 'vname'. + * array.c (make_aname): Redone for dynamic computation of + a subarray actual 'vname'. + (array_vname): Use make_aname() for (sub)array name. + (asort_actual): Performance optimization for asort(a). + +Sun May 8 20:29:17 2011 Arnold D. Robbins + + * debug.c (print_array): Sort in order of string indices, per + request from John Haque. + * array.c (sort_up_value_number): Use string value to provide + ordering when numeric values are equal. Ensures that tests come + out OK on different systems. + +Sun May 8 20:27:27 2011 Arnold D. Robbins + + * dfa.c: Sync with GNU grep. + * regex.h: Sync with GLIBC in preparation for submitting updates + back. + +Thu May 5 21:22:44 2011 Arnold D. Robbins + + * eval.c (r_interpret): PROCINFO sorting only takes effect + if not do_posix. + +Wed May 4 23:31:14 2011 Arnold D. Robbins + + Move array sorting to using predefined strings, add value sorting + by type of assignment. + + * array.c (sort_up_value_type, sort_down_value_type): New routines. + (asort_actual): Pass string value to assoc_list, not NODE *. + Make sure indices of new arrays have numeric value set also. + (sort_up_value_number): Don't break the tie based on string value. + (sort_selection): Removed. + (assoc_list): Third arg is string constant. Add name to table of + functions. Linear search it. + * awk.h (assoc_list): Fix declaration. + * debug.c (print_array): And use of assoc_list. + * eval.c (r_interpret): Ditto. + +Wed May 4 23:06:17 2011 John Haque + + * eval.c (setup_frame): Handle a Node_var in stack. Fixes + a problem when a Node_var_new as param becomes Node_var during + expresssion evaluation for a subsequent param. + +Wed May 4 23:04:06 2011 John Haque + + Fix the problem (crash) with disappearing array argument when + it is a subarray of another deleted array argument. + + * awk.h (struct exp_node): Nuke unused field sub.nodep.number. + New field sub.nodep.rn. + (parent_array): New definition for sub.nodep.rn to keep track + of the parent of a subarray. + * awkgram.y (mk_symbol): Initialize parent_array to NULL. + * eval.c (r_interpret): In the case Op_sub_array, assign + parent_array. + * array.c (get_array): Initialize parent_array to NULL when + a Node_var_new becomes a Node_var_array. + (assoc_find): Add a fourth argument for the previous node + of the returned bucket. + (in_array, assoc_lookup): Adjust calls to assoc_find(). + (adjust_fcall_stack): New routine to change a soon-to-be deleted + subarray parameter in the function call stack to a local array. + (do_delete): Simplify code, remove recursive usage. Call + adjust_fcall_stack() where appropriate. + (do_delete_loop): Call adjust_fcall_stack() before clearing the + array. + (asort_actual): Don't accept an array and its subarray as + arguments for asort() or asorti(). + (asort_actual, dup_table): For asort(), appropriately assign + parent_array when creating the result array. + * field.c (do_split, do_patsplit): An array and its subarray not + accepted for the second and the fourth arguments. Remove + unnecessary dupnode of the field seperator node. + + Unrelated: + * awkgram.y (LEX_DELETE, simple_variable): Change type argument + from Node_var_array to Node_var_new for calls to variable(). + * io.c (devopen): Fix parsing GAWK_MSEC_SLEEP env variable. + +Mon May 2 23:44:34 2011 Arnold D. Robbins + + * dfa.c (parse_bracket_exp): Sync with GNU grep, since we + now require C 90, go ahead and put non-constant values into + the array initializers. + +Mon May 2 23:37:09 2011 Corinna Vinschen + + * awk.h (small): Undef after include of to compile + builtin.c on Cygwin. + +Fri Apr 29 12:29:56 2011 Arnold D. Robbins + + * dfa.c: Sync with GNU grep, mainly typos in comments. + +Fri Apr 29 12:13:32 2011 Arnold D. Robbins + + * io.c (inetfile): Change ifdef to ifndef for have getaddrinfo. + Ooops. + +Fri Apr 29 11:49:38 2011 Arnold D. Robbins + + Per Pat Rankin, remove code related to GFMT_WORKAROUND and VAXCRTL. + + * builtin.c (sgfmt): Nuked. + (format_tree): Removed code related to GFMT_WORKAROUND and VAXCRTL. + * node.c (format_val): Revise comment. + +Fri Apr 29 11:33:08 2011 Arnold D. Robbins + + * awk.h (NUMIND): New flag, indicates numeric value of an + array index is current. + * array.c (awk_hash): Remove code for VAXC, it's no longer + needed. Per Pat Rankin. + (assoc_lookup): Only assign the numeric value if it's available. + (do_delete): Add comment about free_subs calling force_string. + (sort_force_index): Use NUMIND. + +Fri Apr 29 10:15:24 2011 John Haque + + * builtin.c: Relocate all codes from awkprintf.h. Restore + format_tree. + * debug.c (do_print_f): Adjust appropriately. Install fatal trap + for format_tree. + * Makefile.am (base_sources): Remove awkprintf.h. + + * array.c (assoc_list): Avoid possible crash; Remove unneeded + initialization of pre_func. + +Wed Apr 27 22:31:23 2011 Arnold D. Robbins + + * awk.h (ahash_dupnode): Merged into dupnode in node.c, change uses. + * array.c (ahash_unref): Merged into unref in node.c, change all uses. + * node.c (dupnode): Revised to support Node_ahash. + (unref): Ditto. + + Lots of code clean up in array.c: + + * array.c (AVG_CHAIN_MAX): Made unsigned. + (array_init): Use strtoul to convert value instead of doing it + manually. + (array_vname): Nuke code that could limit length of name. It + was never used. + (concat_exp): Make len unsigned, clean up the calculation. + (assoc_lookup): Set ahname_num in the index at time of element + creation. + (dup_table): Copy ahname_num also. + Other minor cleanups after code review. + +Sun Apr 24 15:39:19 2011 Arnold D. Robbins + + * NEWS.0: Moved all pre-4.0 news to here. + * NEWS: Shortened. + * Makefile.am (EXTRA_DIST): Add NEWS.0. + +Sun Apr 24 12:43:49 2011 John Haque + + * array.c (sort_user_func): Fix return value to match the + documentaion. + (sort_selection): Make user-specified comparison function with + the same name override default "unsorted" specification. + +Fri Apr 22 16:05:27 2011 John Haque + + * array.c (sort_user_func): New routine to handle user-defined + quicksort comparison function. + (assoc_list): Adjust for user-defined comparison function. + +Fri Apr 22 09:18:16 2011 Arnold D. Robbins + + * array.c (awk_hash): Force results into 32 bits for consistency + across platforms. Keeps the test suite happy. This may turn out + to be a bad idea in the long run. + +Mon Apr 18 10:18:26 2011 John Haque + + * array.c (assoc_list): New function to construct, and optionally + sort, a list of array elements. + (asort_actual): Use the new function to sort array elements. + (assoc_sort_inplace, assoc_from_list, merge_sort, merge): Nuked. + (sort_selection): Simplify handling of error and warning messages. + (sorted_in, sort_match): Nuked, related code in sort_selection() and + assoc_list(). + (sort_ignorecase, sort_up_index_ignrcase, sort_down_index_ignrcase, + sort_maybe_numeric_index, sort_cmp_nodes, cmp_func, sort_up_value, + sort_down_value): Nuked. Ignorecase handling done in the corresponding + non-ignorecase versions. + (cmp_string): New routine for string comparisons. + (sort_up_value_string, sort_down_value_string, sort_up_value_number, + sort_down_value_number, sort_force_index_number, + sort_force_value_number, sort_force_value_string): New routines. + * awk.h (struct exp_node): New field sub.hash.num to store the + numeric value of an array index. + (ahname_num): New define. + (SORT_CTXT): New typedef. + * awkgram.y (tokentab): Accept three args for asort() and asorti(). + (snode): Adjust for the extra args. + * eval.c (r_interpret): In case Op_arrayfor_init, call assoc_list() + for a list of array elements. + * debug.c (print_array): Call assoc_list() for a sorted list of array + elements. + +Wed Apr 13 10:17:37 2011 John Haque + + * builtin.c (do_strftime): Make the third argument to strftime + really work. + * io.c (redirect): Do not free `rp' after failure to open socket + in redirect_twoway. Fixes a double-free memory error. + +Thu Apr 7 21:38:08 2011 Arnold D. Robbins + + * array.c (merge): Use sort_cmp_nodes for asort/asorti. + See test/arraysort.awk test 1. + +Thu Apr 7 10:48:21 2011 Pat Rankin + + * array.c (sort_cmp_nodes): New routine. Unlike cmp_nodes, numbers + are less than strings instead of being formatted and then compared. + (sort_up_value): Use it. + +Sun Apr 3 22:18:26 2011 Arnold D. Robbins + + * README, FUTURE: Minor edits. + +Fri Apr 1 11:53:54 2011 Pat Rankin + + * array.c (sort_up_index_number): Fix the NODE arguments passed to + sort_up_index_string() when a tie breaker is needed. + +Fri Apr 1 11:49:17 2011 Arnold D. Robbins + + Change ISATTY macro to os_isatty function. + + * awk.h (ISATTY): Remove definition. + (os_isatty): Add declaration. + * debug.c, io.c, main.c: Change all calls. + +Thu Mar 31 22:57:36 2011 Arnold D. Robbins + + * Checklist: Updated. This is a git-only file. + * POSIX.STD: Revised some. + +Tue Mar 29 20:52:38 2011 John Haque + + * awkgram.y (LEXT_NEXT): Don't issue an error message if the next + statement is in a function (rule = 0). + + Always resolve the jump target for an exit statement at run-time. + This fixes a bug when the statement occurs in a function. + + * awk.h: New defines target_atexit and target_end. + * awkgram.y (LEX_EXIT): Initilize the jump targets. + * eval.c (r_interpret): Use current rule to choose the jump target + for Op_K_exit. + * debug.c (print_instruction): Adjust case Op_K_exit. + +Tue Mar 29 20:45:49 2011 Pat Rankin + + Move the code to support sorting `for (index in array)' from + eval.c to array.c, and implement several additional orderings. + + * array.c (comp_func, sorted_in, sort_ignorecase, + sort_up_index_ignrcase, sort_down_index_ignrcase): Move from eval.c. + (sort_up_index_string, sort_down_index_string): Move from eval.c + and rename from *_str to *_string. + (sort_selection, sort_match, sort_maybe_numeric_index, + sort_up_index_number, sort_down_index_number, + sort_up_value, sort_down_value): New routines. + * eval.c (sort_&c): Move to array.c. + (r_interpret: case Op_arrayfor_init): Call sort_maybe_numeric_index + before and after qsort. + * awk.h (qsort_compfunc): New typedef. + (sorted_in, sort_maybe_numeric_index): Declare. + +Fri Mar 25 13:15:36 2011 Arnold D. Robbins + + * awk.h: Move libsigsegv portability checks to here from main.c. + * eval.c (fcall_list, fcall_count): Move definitions to here + from main.c. + * io.c (do_find_source): Check against NULL in for loop. + * main.c: Lots of cleanup. Move some things out to other files, + add comments to some variable definitions. + (enum asgntype): To assign_type + (main): Remove decls of getopt variables, clean up comments. + Use emalloc and efree for libsigsegv stack. Remove check for SCCS + leading magic characters. + (add_preassign): Change allocassigns to alloc_assigns. + (init_locale): Change strdup calls to estrdup. + (save_argv): Make the routine static. + * version.in (version_string): Remove leading 4 SCCS magic characters. + +Wed Mar 2 08:15:02 2011 John Haque + + * array.c (asort_actual): Handle the case when the same array + is used as the source and destination. + * field.c (do_split): Make it fatal if attempting to use the same + array for both second and fourth arguments. + (do_patsplit): Ditto. + +Sun Feb 27 08:01:04 2011 Arnold D. Robbins + + Update copryright in all relevant files. + +Sat Feb 26 21:54:07 2011 Arnold D. Robbins + + * eval.c (sorted_in): Revise text of lint warning. + +Fri Feb 25 17:34:14 2011 Pat Rankin + + * eval.c (sorted_in): Remove incorrect unref() call. + +Wed Feb 23 21:48:20 2011 Arnold D. Robbins + + * main.c (main): Free extra_stack, to make valgrind happier. + +Tue Feb 22 12:04:09 2011 Arnold D. Robbins + + * main.c (UPDATE_YEAR): Move to 2011. Fix copyright. + +Tue Feb 15 17:11:26 2011 Pat Rankin + + * eval.c (sorted_in, sort_up_index_str, sort_down_index_str, + sort_up_index_ignrcase, sort_down_index_ignrcase, sort_ignorecase): + New functions to sort arrays for `for (index in array)' statements. + (r_interpret: case Op_arrayfor_init): Call sorted_in(). + +Wed Feb 16 07:12:50 2011 John Haque + + Fix line numbers in the lint, warning and error messages issued + by the parser. + + * awkgram.y (lintwarn_ln, warning_ln, error_ln): New local versions, + each accepts an additional line number argument. + (print_included_from): New function to seperate 'Included from ..' + message from yyerror. Use it in yyerror, and in the new functions. + (grammar): Use the local versions for messages. + (add_srcfile, include_source, dup_parms, func_install, param_sanity, + mk_binary, add_lint): Ditto. + (dup_params, include_source): Adjust arguments to pass line number. + * awk.h: New definition ATTRIBUTE_PRINTF_2. + + * awkgram.y (yylex): New variable warntab. Use it to issue only one + warning for the same non-standard special token in source. + (parse_program): Avoid spurious warnings. Don't call check_funcs if + yyparse aborts prematurely. + +Mon Feb 14 08:03:41 2011 John Haque + + * awkgram.y (regexp): Don't use tokstart in lint warning, it isn't + `\0' terminated. + (grammar): Copy update and assign routines from relevant variables into + instructions to avoid extra pointer dereferencing at run-time. + * awk.h (update_var, assign_var): new definitions. + * eval.c (r_interpret): Adjust cases Op_var_assign and Op_var_update. + +Sun Feb 13 20:22:47 2011 Eli Zaretskii + + * awkgram.y (add_srcfile): + * debug.c (source_find): Pass `path' and `src' to files_are_same. + * gawkmisc.c [__DJGPP__ || __MINGW32__]: Include pc/gawkmisc.pc, + for consistency with __EMX__ and pc/Makefile. + * debug.c (interpret, initialize_pager, prompt_continue) + (set_gawk_output): Use ISATTY instead of isatty. + * io.c (redirect, iop_alloc): Same. + * main.c (main): Same. + * awk.h (ISATTY): Trivial definition, if not defined elsewhere. + +Sun Feb 13 20:16:04 2011 Arnold D. Robbins + + * awkgram.y (check_funcs): Update warning about never called to say + "never called directly" since it could be called indirectly. + +Sun Feb 13 07:12:50 2011 John Haque + + * profile.c (pprint): In case Op_indirect_func_call, pop off + indirect var after function parameters. + Thanks to Hermann Peifer for the bug report. + * array.c (do_delete): Always free an empty sub-array name and node. + * ChangeLog: Fix typos. + +Fri Feb 11 10:26:25 2011 Arnold D. Robbins + + * io.c (remad_std_file): Close oldfd first, in case we've + run out of fd and do dup2 if the newfd isn't what we were + looking for. Thanks to Hermann Peifer for + the bug report. + +Thu Feb 10 21:31:36 2011 Andreas Buening + + * main.c (load_procinfo): Fix warning about unsed variables if we + don't have multiple groups. + * protos.h: Move decls for many standard functions here if + they aren't in the header files (OS/2) and bracket inside + #ifndef STDC_HEADERS. + * io.c (devopen): Remove decl of strtoul. + * field.c (set_FIELDWIDTHS): Same. + * awk.h: Always include protos.h. + +Tue Feb 8 22:46:22 2011 Arnold D. Robbins + + * array.c, builtin.c, eval.c: Equalize message strings and + fix a typo. Thanks to Benno Schulenberg . + +Mon Feb 7 11:23:33 2011 Arnold D. Robbins + + * awkgram.y (next_sourcefile): Comment out assertion that + lexeof is true; causes core dump on user typos of bad + characters which previous versions did not do. Thanks to + Pat Rankin for the report. + + * re.c (expand_range): Allow for ^ as first character + inside range. Thanks for Nelson Beebe for the bug report. + +Fri Feb 4 10:28:19 2011 Arnold D. Robbins + + * README.cvs: Udpated. + * Checklist: New file for storage in the git repository. + +Wed Feb 2 20:34:41 2011 Corinna Vinschen + + * awkgram.y (free_bc_internal): Remove unused variable. + +Tue Feb 1 23:13:10 2011 Arnold D. Robbins + + * bootstrap.sh: No need to find aclocal.m4, just touch it. + +Tue Feb 1 23:05:51 2011 Corinna Vinschen + + Make values of ctype macros into unsigned char to fix + warnings found on Cygwin / Newlib. + + * array.c (array_init): Add cast. + * awkgram.y: Ditto. + * awkprintf.h: Ditto. + * builtin.c (sub_common, nondec2awknum): Ditto. + * command.y: Ditto. + * eval.c (fmt_ok): Ditto. + * ext.c (make_builtin): Ditto. + * main.c (main, arg_assign): Ditto. + * re.c (check_bracket_exp): Ditto. + * node.c (r_force_number, parse_escape): Ditto. + (dump_wstr): Add unused attribute (unrelated). + +Tue Feb 1 23:01:40 2011 John Haque + + Fix switch debugging. + + * awkgram.y (LEX_SWITCH, case_statements, case_statement, + case_value): Linearize instructions to facilitate debugging. + (switch_body): Removed. + (yylex): Add LEX_CASE in special token processing. + (free_bc_internal): Remove case Op_K_switch. + * awk.h (OPCODE): Remove opcode Op_case_list. + * eval.c (r_interpret): Remove Op_K_switch. Add case + Op_K_case to handle switch. + Add cases Op_K_do, Op_K_while, Op_K_for, Op_K_arrayfor, Op_K_switch + and Op_K_default as no-ops, needed for pgawk. + * debug.c (print_instruction): Remove case Op_K_switch, + add case Op_K_case instead. + + Unrelated: + * awkgram.y (case_statements): As case values, "abc" and /abc/ + no longer considered as duplicates. + + Cleanup grammar and run-time code for switch and loops. + Jump targets for break and continue are now fixed, and known + at parse time. See ChangeLog entry dated Oct 21, 2010. + + * awk.h (OPCODE): Remove Op_push_loop and Op_pop_loop. + (loop_count): Remove definition. + * awkgram.y (fix_break_continue): Change calling parameters to + instruction list, break and continue targets. Adjust code. + (LEX_DO, LEX_WHILE, LEX_SWITCH, LEX_FOR): Simplify grammar. Use + Op_no_op as target for break. Adjust call to fix_break_continue. + (mk_for_loop): Ditto. + * eval.c (r_interpret): Nuke cases Op_push_loop and Op_pop_loop. + Simplify Op_K_break and Op_K_continue. Remove declaration of in_loop + and all loop detection code thereof. + * debug.c (pre_execute, post_execute): Adjust declarations and code. + (print_instruction): Nuke cases Op_push_loop and Op_pop_loop. + * eval.c (r_interpret): Adjust calls to pre_execute and post_execute. + * profile.c (pprint): Adjust cases Op_K_for, Op_K_do, Op_K_while, + Op_K_switch and Op_K_arrayfor. Add cases Op_K_case and Op_K_default. + Remove Op_push_loop and Op_pop_loop. + + Unrelated cleanup: + * awkgram.y (mk_condition): Don't include Op_K_if, Op_K_else and + Op_cond_exp if not profiling. + +Tue Feb 1 10:20:02 2011 Arnold D. Robbins + + * eval.c (r_interpret): Change magic string for array sorting. + +Sun Jan 30 21:49:53 2011 John Haque + + Add `isarray' built-in function. + + * awk.h (enum opcodeval): Op_push_arg: new opcode. + (do_isarray): Add declaration. + * awkgram.y (tokentab): Add new entry for `isarray' function. + (snode): Add handling for it. + * builtin.c (do_isarray): New function. + (do_length): Die if posix and get an array argument. + * debug.c (print_instruction): Handle Op_push_arg. + * profile.c (pprint): Likewise. + * eval.c (optypes, r_interpret): Likewise. + +Sun Jan 30 21:13:01 2011 Arnold D. Robbins + + * hard-locale.h: Synced to GNU grep. + * hard-locale.c: New file, brought in from GNU grep. + * Makefile.am (base_sources): Add hard-locale.c. + * dfa.h: Sync as much as possible to GNU grep. + * dfa.c: Sync as much as possible to GNU grep. + * builtin.c (do_strftime): Remove unneeded variable. + +Thu Jan 27 22:52:54 2011 Arnold D. Robbins + + * awk.h (comp_func): Add declaration. + * debug.c (comp_func): Make not static, and move to ... + * eval.c (comp_func): ... here. + (r_interpret): Add array sorting if magic index is + set in PROCINFO. + +Thu Jan 27 22:12:00 2011 Corinna Vinschen + + * Makefile.am: Remove $(EXEEXT) from 'awk' symlink. + +Thu Jan 27 21:21:13 2011 John Haque + + * eval.c (r_interpret): When in BEGINFILE or ENDFILE, add check for + `getline var < file' in cases Op_K_getline_redir and Op_K_getline. + + * awkgram.y (constant_fold): Code cleanups. Fix bug in the code for + string concatenation. + + * configure.ac: Remove unneeded extra call to AC_LANG. + +Thu Jan 27 15:00:42 2011 Arnold D. Robbins + + * eval.c: Fix up some comments. + * io.c (remap_std_file): New function. + (iop_close): Use it. + +Mon Jan 24 22:14:21 2011 Andreas Buening + + * debug.c: Bracket variables used with readline in #ifdef. + * dfa.c (add_utf8_anychar): Move inside ifdef. + +Mon Jan 24 22:05:26 2011 Arnold D. Robbins + + * re.c (make_regexp): Add separate variable for dfa syntax. + General formatting cleanup. + (research): General formatting cleanup. + (refree): Remove out of date comment. + (re_update): Comment the routine. + (check_bracket_exp): Improve check for range to not get [^-/] + kinds of things. Thanks to Nelson Beebe for pointing out the bug. + +Wed Jan 19 20:31:17 2011 Arnold D. Robbins + + * awk.h (is_valid_character): Add `& 0XFF' and remove casts to + unsigned chars in other files. Remove definition of this macro + in not MBS_SUPPORT case, since it wasn't being used. + (btowc_cache): New macro to index into the array and use the + same trick. Relies on ANSI C preprocessor semantics. + Fix all uses. + * builtin.c, node.c, io.c: Fix uses of these macros. + +Wed Jan 19 20:19:29 2011 Arnold D. Robbins + + * node.c (wstr2str): New function. + * awk.h: Declare it. + * builtin.c (is_wupper, is_wlower, to_wupper, to_wlower, + wide_change_case, wide_tolower, wide_toupper): New functions to + simplify wide character case conversions. + (do_tolower, do_toupper): Use wide_tolower, wide_toupper in multibyte + case. + (do_substr): Simplify code a little bit. + +Mon Jan 17 22:48:48 2011 Arnold D. Robbins + + * builtin.c (do_bindtextdomain): Change type of `the_result' + to const char* to kill compiler warnings. + * debug.c (source_find): Improve error message when file not + found. + * awkgram.y (get_src_buf): Add cast to value of `read' to + turn off compiler warnings on different systems. + +Mon Jan 10 21:40:05 2011 Andreas Buening + + * io.c (devopen): Handle opening of directories for OS/2. + +Mon Jan 10 21:37:49 2011 Arnold D. Robbins + + * awk.h: Rearrange includes of so it won't be + included for VMS, move definition of O_BINARY down. + +Sat Jan 8 23:00:37 2011 Arnold D. Robbins + + * awk.h: Include here. + * main.c, io.c: Remove includes of . + +2011-01-08 Eli Zaretskii + + * io.c (PIPES_SIMULATED) [__DJGPP__ || __MINGW32__]: Define. + (binmode): Define for __DJGPP__ and __MINGW32__ as well. + (gawk_popen) [!PIPES_SIMULATED]: Define for __DJGPP__ and + __MINGW32__ as well. + +Wed Jan 5 20:35:30 2011 Arnold D. Robbins + + * configure.ac: Move call to AC_LANG([C]) into here from + m4/readline.m4. + +Tue Jan 4 11:21:18 2011 Arnold D. Robbins + + Clean up some compiler warnings: + + * array.c (do_delete): Cast for printf. + * builtin.c (do_bindtextdomain): Casts for const char *. + * io.c (rs1scan): Cast for indexing of array. + * re.c (add_char): Remove unused variables. + +Fri Dec 31 11:05:11 2010 Michal Jaegermann + + * awk.h (strncasecmpmbs): Change parameters to const char *. + * builtin.c (strncasecmpmbs): Change parameters to const char *. + Add casts as appropriate in calls to other functions. + * eval.c (cmp_nodes): Add casts in calls to strncasecmpmbs. + * node.c (str2wstr): Ditto. + +Tue Dec 28 21:13:31 2010 Eli Zaretskii + + * gawkmisc.c: Restore inclusion of pc/gawkmisc.pc. + +Tue Dec 28 21:00:36 2010 Arnold D. Robbins + + * ext.c (make_builtin): Make first parameter const char *. + Adjust code inside to fit. + * awk.h (make_builtin): Adjust declaration. + +Mon Dec 27 19:55:10 2010 Arnold D. Robbins + + * io.c [AF_UNSPEC, AF_INET, AF_INET6]: Add definitions for systems + that don't define them. + (inetfile): Make IPv6 a fatal error if using the fake getaddrinfo, + since chances are good that IPv6 really isn't available. + +Sat Dec 25 19:36:27 2010 Arnold D. Robbins + + Fixes for z/OS. + + * awkgram.y (tokcompare): Change argument types to const void *. + (check_special): Add cast to void * in call to qsort. + * builtin.c (do_bindtextdomain): Change `directory' and `domain' + to const char *. + * custom.h (ZOS_USS): Undef HAVE_SYS_PARAM_H and HAVE_MCHECK_H. + Beats me why configure thinks it has those things. + +Fri Dec 24 12:56:46 2010 Arnold D. Robbins + + * custom.h: Remove defs for MIPS RiscOS. + * configure.ac, aclocal.m4: Updated to Autoconf 2.68. + +Wed Dec 22 21:21:28 2010 Arnold D. Robbins + + * gettext.h: Synchronized with gettext 0.18.1. + +2010-12-22 gettextize + + * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.18.1. + * ABOUT-NLS, config.rpath: Updated from gettext 0.18.1. + +Sun Dec 19 16:43:14 2010 Arnold D. Robbins + + * awk.h (update_PROCINFO_str, update_PROCINFO_num, make_str_node): + Change `char *' parameters to `const char *' to avoid some + compiler warnings. + * ext.c (do_ext): Remove cast in call to make_string. + * field.c (update_PROCINFO_str, update_PROCINFO_num): Adjust. + * main.c (init_args): Remove casts in calls to make_string. + * node.c (r_make_str_node): Add cast in assignment if ALREADY_MALLOCED. + +Sat Dec 18 20:12:59 2010 Eli Zaretskii + + * array.c, gawkmisc.c, io.c, main.c, regex_internal.h, + awkgram.y, awk.h, array.c: Remove OS2 and _MSC_VER defines. + +Sat Dec 18 19:56:17 2010 Arnold D. Robbins + + * builtin.c, eval.c, floatcomp.c, io.c: Remove all the crufty + old code for #ifdef CRAY. + +Thu Dec 16 11:06:50 2010 Arnold D. Robbins + + Put strftime() default format into PROCINFO["strftime"]. + + * awk.h (def_strftime_format): Declare const char[] array. + * main.c (def_strftime_format): Define it. + (load_procinfo): Load it into PROCINFO. + * builtin.c (do_strftime): Use value in PROCINFO for format + string if it's there. Remove old def_format static array. + +Mon Dec 13 17:12:44 2010 Arnold D. Robbins + + If not POSIX, turn [d-h] into [defgh]. + + * re.c (check_bracket_exp): Make warning about ranges under + lint control. + (expand_range): New routine to expand ranges. + (make_regexp): Check if might have range and call expand_range. + (add_char): New helper function for expand_range. + +Thu Dec 9 22:12:48 2010 Arnold D. Robbins + + * io.c: Restored changes of 1 July 2010 to allow /inet4 and /inet6; + they got lost amongst the merges. Fixed checking of do_sandbox. + Also, removed the option for raw IP sockets since it was never + implemented and wasn't going to be. + +Tue Dec 7 11:59:00 2010 Arnold D. Robbins + + * configure.ac: Remove test for return type of sprintf. Another + renegade from the late 1980's bites the dust! + * protos.h (sprintf): Remove declaration. + +Sun Dec 5 15:01:35 2010 Arnold D. Robbins + + * eval.c (grow_stack): Change env var to GAWK_STACKSIZE. + * awk.h, main.c, eval.c, profile.c: Removed features added + for those who are Strong In The Ways of the Source. + * debug.c (comp_func): Moved to here from eval.c, where it's + no longer needed. + +Sat Dec 4 21:44:38 2010 Arnold D. Robbins + + * node.c (init_btowc_cache): New function. + (btowc_cache): New array. + (str2wstr): Use is_valid_character in test instead of several isXXX + calls. + * awk.h [is_valid_character]: Macro to use btowc_cache. + * main.c (main): Call init_btowc_cache(). + * io.c (rs1scan): Add call to is_valid_character when processing + characters byte by byte. + +Wed Dec 1 08:10:21 2010 Arnold D. Robbins + + * awk.h, awkgram.y, debug.c: Change CONTEXT to AWK_CONTEXT + everywhere to avoid problems with libsigsegv on cygwin. + +Tue Nov 30 13:48:34 2010 Arnold D. Robbins + + * main.c (MRL): Removed variable, not used since Tandem code nuked. + (main): Fix argument parsing for -m. + (usage): Make -m undocumented (already is the doc/* files). + * io.c (MRL): Remove declaration. + +Mon Nov 29 21:59:21 2010 Arnold D. Robbins + + * re.c (check_bracket_exp): Add check and warning for ranges. + I may live to regret this. + +Mon Nov 29 20:09:18 2010 Eli Zaretskii + + * replace.c [!HAVE_STRFTIME]: For __MINGW32__, define + HAVE_STRFTIME while compiling missing_d/strftime.c. + +Thu Nov 25 20:12:28 2010 John Haque + + * awkgram.y (grammar): Bug fix in delete for loop efficiency hack. + * debug.c (do_info): Don't sort functions to avoid potential memory leak + in case A_FUNCTIONS. + + Plug more potential leaks in the debugger eval/condition commands: + * builtin.c (POP_TWO_SCALARS): New macro to free first scalar in case + of a fatal error in the next. + (do_index, do_atan2, do_lshift, do_rshift, do_and, do_or, do_xor): Use it + instead of two consecutive POP_SCALARs. + + Execution context related code cleanups. Also, added descriptive + comments for functions. + * awkgram.y (get_context): Nuked. + (push_context, pop_context, in_main_context): New functions. + (mk_program, parse_program, yylex): Updated. + * debug.c (condition_triggered, do_eval, parse_condition): Updated. + * eval.c (unwind_stack): Updated. + * main.c (main): Updated. + * awk.h (struct context): Removed member level, not needed. + + * eval.c (op_assign): Initialize r to NULL, and declare x only + if HAVE_FMOD not defined to remove GCC warnings. + +Thu Nov 25 08:32:31 2010 Arnold D. Robbins + + * eval.c (posix_compare): Do string comparison with strcoll() / + wcscoll(). + (cmp_nodes): Call it if do_posix. This may be a bad idea, + but what the heck. Standards compatibility uber alles! + +Wed Nov 24 20:09:23 2010 Arnold D. Robbins + + * ext.c (do_ext): Require definition of `plugin_is_GPL_compatible' + per GNU Coding standards. + +Sun Nov 21 14:23:58 2010 John Haque + + Debugger: Fix memory leak when quitting pager. + * awk.h (PUSH_BINDING, POP_BINDING): Generalize macro definitions. + * debug.c (print_array): save and restore bindings for pager. + free list in case of an early exit in the pager. + (do_dump_instructions): Don't sort functions to avoid potential + memory leak. + (execute_code): Adjust PUSH_BINDING and POP_BINDING macro invocations. + + * awkgram.y (func_call): Avoid reading freed memory for indirect var + name; do the special variable check before the call to 'variable'. + + * eval.c (r_interpret): Fixes and cleanups. Change TOP to TOP_SCALAR + in the case Op_store_field. + (assign_common, assign, compare): Nuked macros. + (cmp_scalar, op_assign): New functions as replacements for the macros. + +Fri Nov 19 11:57:28 2010 Arnold D. Robbins + + * bootstrap.sh, Makefile.am: Remove treatment of CVS. + * README.cvs: Updated further. + +Thu Nov 18 23:28:23 2010 Arnold D. Robbins + + * configure.ac: Remove `--enable-portals' option. I don't think + anyone ever used it. + * io.c (two_way_open): Remove the code for portals. + * README.cvs, README.git, bootstrap.sh: New files for storage + in the Git repository. + +Tue Nov 16 11:56:31 2010 Arnold D. Robbins + + * version.in: Removed descriptive comments. New features and + so on are documented in the documentation and in NEWS. + +Mon Nov 15 19:19:25 2010 Arnold D. Robbins + + * awkgram.y (LEX_LENGTH): Removed warning about length with + no argument being deprecated. + * awkprintf.h: Remove code for sun386. Fix %c to print multibyte + character instead of first byte. + * builtin.c (sub_common): Update commentary about POSIX. + * io.c (nextfile): Add MAYBE_NUM to FILENAME. + +Fri Nov 12 11:53:15 2010 Arnold D. Robbins + + * main.c (update_global_values): New routine, needed for correct + operation of --dump-variables. + * awk.h: Declared it. + * awkgram.y (get_varlist): Call it. + Thanks to Hermann Peifer for the bug report. + + * debug.c (find_subscript): Initialize `r' to NULL, per + Michal Jaegermann. + +Thu Nov 11 16:31:49 2010 Arnold D. Robbins + + * awk.h: Restore decls of strcasecmp, strncasecmp. + * builtin.c: Lots of general cleanups. + (sub_common): Actually enable POSIX rules! (Wasn't done right + earlier.) + +Thu Nov 4 14:08:29 2010 Arnold D. Robbins + + * array.c, awkgram.y, awkprintf.h, builtin.c, debug.c, eval.c, + field.c, io.c, main.c, node.c, profile.c, re.c: Remove register + keyword everywhere. + * node.c: Minor code cleanups. + +Wed Nov 3 08:29:15 2010 Arnold D. Robbins + + * node.c (free_wstr): If argument is null string or null field, + return. Thanks to Vojtech Vitek + +Tue Nov 2 16:45:06 2010 Arnold D. Robbins + + Straighten out options more. --lint --> -L, --lint-old --> -t + + * main.c (optlist, optab, main, usage): Adjusted approrpiately. + + Other: + * awk.h: Lots more general cleanup. + * builtin.c (strncasecmpmbs): Move mbstate vars into the routine. + * awk.h (strncasecmpmbs): Adjust declaration. + * eval.c (cmp_nodes): Adjust call. + * awkgram.y, command.y: Remove unused variables. + +Mon Nov 1 21:55:26 2010 Arnold D. Robbins + + * main.c (optlist, optab, main): Renamed -l option to -t + so can eventually merge in xgawk's -l option. + (usage): Adjusted approrpiately. + +Mon Nov 1 16:23:52 2010 Arnold D. Robbins + + * array.c, awk.h, custom.h, eval.c, gawkmisc.c, io.c, main.c, + protos.h, replace.c: Remove code related to: __amigaos__, + atarist, BeOS, _MSC_VER, MSDOS, TANDOM, WIN32, and anything + not for __STDC__. + +Sun Oct 31 21:49:22 2010 Arnold D. Robbins + + * awk.h: Start on cleaning up. Remove stuff for DOS, WIN32, + TANDEM, atarist, NeXT even! + +Sun Oct 31 05:56:23 2010 John Haque + + Add array of arrays. + + * awk.h (Op_sub_array): New opcode. + (POP_SCALAR, TOP_SCALAR): New macros. If the item is not a scalar, + make it a fatal error. + (POP_STRING, TOP_STRING): Use POP_SCALAR and TOP_SCALAR instead + of POP and TOP. + (force_string, force_number): Unrelated: simplify (remove) macros + for older gcc and non-gcc compilers. + * awkgram.y (grammar): New non-terminals for array subscripts. + delete array subscripts are handled differently than array subscripts + used as a variable. + (SUBSCRIPT): New terminal symbol to indicate end of subscripts. + (yylex): Return SUBSCRIPT after all the subscripts has been read. + (rules variable, LEX_DELETE and LEX_FOR): Adapt to these changes. + (sub_counter): New global to count the number of subscripts in a + delete statement. + (optimize_assignment): Adjust code for assignment to an array element. + * array.c (make_aname): New function to construct a sub-array name. + (get_array): Handle Node_val in the default case. + (concat_exp): Issue fatal error message if each expression is not a + scalar. + (assoc_clear): Recursively clear sub-arrays. + (do_delete, assoc_dump, assoc_sort_inplace, dup_table): + Handle array of arrays. + * builtin.c: Replace POP with POP_SCALAR as appropriate. + * eval.c (optypes): Add entry for Op_sub_array. + (r_interpret): Handle Op_sub_array. For case Op_subscript, increment + reference count only if the result is a scalar. If type is not a + scalar in Op_subscript_lhs, make it fatal. Adjust stack pointer + after a call to do_delete in Op_K_delete. Change POP(TOP) + to POP_SCALAR(TOP_SCALAR) as needed. + * profile.c (pprint): Add case for Op_sub_array. + * command.y (grammar): New non-terminals and rules to handle + array of arrays. + * debug.c (struct list_item): Redesigned. Field subs is NODE ** now, + new fields num_subs and sname. New flags OLD_IS_ARRAY and CUR_IS_ARRAY; + removed flag ARRAY_WATCH. Renamed macro IS_ARRAY() to WATCHING_ARRAY. + (do_info): Adapt to the structural changes in cases A_WATCH and + A_DISPLAY. + (print_array): New function to print contents of an array. + (print_subscript): New function to print an element of an array. + (do_print_var): Use the new functions to print an array element + and contents. + (do_set_var): Adapt to the structural changes in list_item for + an array element. + (delete_item, do_add_item, display): Ditto. + (add_item): Ditto. Use field symbol, not subs to store field number and + adjust accordingly everywhere. + Unrelated: handle function parameter correctly, watch and display now + prints the param name instead of the actual array name. + (find_subscript): New function. + (initialize_watch_item): Use the new function find_subscript + to locate an array element NODE. + (watchpoint_triggered): Redone. + (cmp_val): Redone. + (print_watch_code): Adjust code for printing subscript. + (print_instruction): Add case for Op_sub_array. + (serialize_subscript): New function. + (serialize): Use the new function to serialize watch and display + subscripts. + (unserialize_list_item): Adapt to the structural changes. Also, + simplify code. + (do_print_f): Redo code for printting array element. + (pre_execute_code, execute_code): Change POP to POP_SCALAR. + + Unrelated: + + * debug.c (unserialize_commands): New function for common code in + unserialize_breakpoint and unserialize_list_item. + (unserialize_breakpoint and unserialize_list_item): Use the new + function. + + * awkgram.y (grammar): Do not terminate parser if seen an empty(NULL) + subscript. Install null string as subscript and continue parsing. + (variable): Do not terminate parser if type is Node_func, change it + to Node_var_new temporarily. Simplifies grammar and allows parser to + continue. + + * command.y (yylex): Add history entry when blank line repeats + previous command. + + * debug.c (pp_args): Removed. Pretty-printing SUBSEP + seperated indexes can not be made to work reasonably in all cases. + (struct list_item): Removed field pp_subs. + (concat_args): Move to file command.y. + * command.y (grammar): Concatenate SUPSEP seperated indexes. + +Thu Oct 28 16:25:08 2010 Arnold D. Robbins + + Remove use of varargs.h everywhere: + + * awkgram.y (yyerror): Fixed. + * awk.h [CAN_USE_STADARG_H]: Removed, #error added if not available. + (snprintf, Func_print, msg, error, warning): Fix declarations. + * cmd.h (gprintf, d_error): Fix declaration. + * command.y (yyerror): Fixed. + * debug.c (d_error, gprintf): Fixed code. + * main.c (lintfunc): Fix declaration. + * msg.c (msg, warnning, error, r_fatal): Fixed code. + +Wed Oct 27 16:45:29 2010 Arnold D. Robbins + + * awk.h [P]: Finally, nuked the `P' macro. Removed definitions + and uses. + [HAVE_DOPRNT]: Removed check for this, now require vfprintf. + [BELL]: Nuked; require a compiler that supports '\a'. + * array.c, awkgram.y, awkprintf.h, builtin.c, cmd.h, command.y, + debug.c, eval.c, ext.c, field.c, io.c, main.c, protos.h [P]: + Remove all uses. + * node.c (r_force_number): Change check with strtod to `ptr == cpend', + SunOS 3.5 compatibility no longer concerns us. Removed the comment. + [P]: Removed all uses. + (parse_escape): Change from BELL to '\a'. + * profile.c (pp_string): Change from BELL to '\a'. + [P]: Removed all uses. + +Tue Oct 26 20:11:37 2010 Arnold D. Robbins + + * awkgram.y (fix_break_continue): New routine to make break and + continue instructions point to where they should jump to. Adjusted + grammar to call it for switch and loops. + * eval.c (r_interpret): For Op_K_break and Op_K_continue, jump + to pc->target_jmp. + * command.y (cmdtab, do_help): Translate the help messages. + * debug.c (option_list, option_help): Translate the help messages. + Elsewhere, clean up / add calls to gettext. + +Fri Oct 22 11:18:29 2010 Arnold D. Robbins + + * ChangeLog: Merged with ChangeLog.BYTECODE. + * Makefile.am (EXTRA_DIST): Removed ChangeLog.BYTECODE. + * ChangeLog.BYTECODE: Removed the file. + +Thu Oct 21 12:16:35 2010 Arnold D. Robbins + + Make break and continue outside a loop not allowed at all, + even with --traditional, as BWK awk no longer allows this. + + * eval.c (r_interpret): For Op_K_break and Op_K_continue, make + them fatal errors if not in a loop. + * awkgram.y (break_allowed, continue_allowed): New variables. + [BREAK, CONTINUE]: New flags for tokentab. + (yylex): If set, increment the corresponding variable. + (Grammar): Test variables when break/continue seen, decrement them + at the end of productions for loops and switch. + +Tue Oct 19 20:03:29 2010 Arnold D. Robbins + + * main.c (optab, usage): Remove --compat, --copyleft, and --usage extra + option aliases. + +Tue Oct 19 08:25:02 2010 Arnold D. Robbins + + * awkprintf.h (r_format_arg): Undouble "%" characters in + error messages. Thanks to Scott Deifik for catching the problem. + +Sat Oct 16 22:08:54 2010 Arnold Robbins + + Apply changes from John Haque: + + * awk.h [ASSIGNED]: Remove unused flag. + (Op_cond_pair_left): Remove. + * debug.c (print_instruction): Remove Op_cond_pair_left. + (do_trace_instruction): Fix print for Op_newfile. + (parse_condition): Improve code. + * eval.c (optypes): Add space to string for "!". + (r_interpret): Remove Op_cond_pair_left and Node_instruction cases. + Revise Op_cond_pair to handle left and right sides correctly. + Simple code fixes in some other cases. + * profile.c (pprint): Remove Op_cond_pair_left. Simplify Op_not. + +Fri Oct 15 14:17:09 2010 Arnold Robbins + + * awk.h (Op_cond_pair_left): New op for left side of condition pair. + * debug.c (print_instruction): Support it. + * profile.c (pprint): Ditto. + * eval.c (r_interpret): Split Op_cond_pair into two cases; they have + to be handled differently. + +Wed Oct 13 19:17:03 2010 Arnold D. Robbins + + * regex.h [RE_SYNTAX_AWK]: Add RE_CHAR_CLASSES, for compatibility + with modern Unix awk. + +Sun Oct 10 15:31:01 2010 Arnold D. Robbins + + * re.c (dfawarn): Do nothing in body, since gawk does it's + own checking. + +Sun Oct 10 15:30:34 2010 Arnold D. Robbins + + MERGE with bytecode version! Many many files changed / added. + +Sun Oct 3 08:41:25 2010 John Haque + + * Lots of files: Indirect function call, FPAT, BEGINFILE/ENDFILE + from gawk-devel. + + * awk.h (defrule): New enum for rule types. + (ruletab): Converts rule types to string constants. + * awkgram.y: Use rule types to simplify code in grammar. + * eval.c, debug.c, profile.c, awkgram.y routines: Update to use ruletab. + + * Lots of files: New debugger command eval for evaluation of + arbitrary (g)awk expression(s). + eval "awk statement(s)" + OR + eval p1, p2 + > awk statement + > more awk statement(s) + > end + p1, p2 are eval locals. + Conditional break/watch point: + break 1 "condition expression" + OR + break 1 + condition "condition expression" + + * command.y: grammar clean-ups. + (find_command): Redo to fix bugs in abbreviation/partial-string + search. + + * debug.c (command_source): New structure. Used to manage + sources for debugger commands. 'source file' command can now + include additional source commands. + + * awk.h: new enum type redirval for I/O redirection types; + remove redirection types from OPCODE. + * awkgram.y: Adjust grammar for redirection type changes. + (yylex, mk_getline): Update for redirection type changes. + * io.c (redirect, do_getline): Ditto. + * profile.c (redir2str): New function to convert redirection types + to string constants. + (pprint): Use new function redir2str. + * debug.c (print_instruction): Ditto. + * eval.c (optypes): Remove redirection types from table. + + * main.c (main): initialize do_optimize to 1, default optimizations. + do_optimize > 1 for -O (--optimize) command line option. + do_optimize = 0 turns off all optimizations, and is for debugging + purposes. + * awkgram.y: Updated. + + Lots of other cleanups and improvements. + +Thu Sep 16 09:44:47 2010 John Haque + + Lots of bug fixes & improvements, including work on + profiling. + +Wed Aug 18 22:15:06 2010 Arnold Robbins + + Lots of files: Sync fully with gawk-stable version, in particular + documentation edits and all ChangeLog files. + +Mon Aug 9 07:17:54 2010 John Haque + + Fix the case when runtime stack can have a INSTRUCTION pointer + while popping stack items (a next/nextfile statement inside a loop). + + * awk.h: new NODETYPE Node_instruction. Remove instruction pointer + from STACK_ITEM union, and all related macros. + * eval.c (r_interpret): wrap code (INSTRUCTION) pointer inside + a NODE for Op_push_loop. Change Op_pop_loop, Op_K_break + and Op_K_continue accordingly. + (unwind_stack): free Node_instruction. + (nodetypes): add new entry for Node_instruction. + +Thu Aug 5 15:05:22 2010 Arnold Robbins + + * awk.h: Remove redundant declaration of struct lconv loc; + * awkprintf.h: Move ifdef for HAVE_LOCALE_H inside case '\''. + * custom.h: Add macros for setenv and unsetenv for Z/OS. + * main.c (main): Remove three argument version for Tiny CC after + applying patches to local copy that fix the issue with environ. + +Mon Jul 26 07:23:01 2010 John Haque + + Started Byte Code version ChangeLog. + + * awk.h, eval.c, debug.c, profile.c: Renamed opcode Op_exit to + Op_atexit. Simplify exit value handling; use existing global + exit_val from main.c. + New opcode Op_stop. + + * msg.c: New variables fatal_tag_valid, fatal_tag. + (r_fatal): Use these new variables. + (err): Change myname from dgawk to gawk when debugging; + reflects the correct source of error messages. + + * builtin.c, msg.c: Change stdout to output_fp. + (do_fflush): Also flush output_fp if not stdout. + + * command.y (yylex, yyparse): (Much) improved error recovery. + + * awkgram.y (yylex): Add 'goto out' in 'check_special' + for do_traditional or do_posix check, lost somewhere + between 3.1.3 to 3.1.8. + (pop_var): New name remove_symbol to go with mk_symbol. + (install): New name install_symbol. + + * debug.c:(set_gawk_output): Improved handling of /dev files + including /dev/ttyN, /dev/pts/N. + (pre_execute): Renamed execute, a pre_hook in r_interpret. + (post_execute): New function, a post_hook in r_interpret; + used to detect non-local jumps (next, nextfile, exit) + with commands 'until' and 'finish', and to print the + returned value for finish. + (print_instruction): Redo function params initialization + when trace is on. Hopefully, correct this time around. + (close_all): New function to close all known files + during quit and restart. + + * eval.c(r_interpret): Redefine macro JUMPTO to include + post_hook from above, and use it exclusively to move to + the next instruction for execution. + + * debug.c (do_run): Trap gawk fatal errors. +Sun Sep 5 12:44:24 2010 Arnold D. Robbins + + * re.c (check_bracket_exp): Add `warned' flag to table and adjust + code to only warn once about each candidate. + (make_regexp): Always call check_bracket_exp, per discussion + on comp.lang.awk. + +Fri Aug 6 16:29:55 2010 Arnold D. Robbins + + * re.c (check_bracket_exp): Improved the code, again. + +Thu Aug 5 18:41:27 2010 Arnold D. Robbins + + * re.c (check_bracket_exp): Improved the code. + +Tue Aug 3 11:35:11 2010 Arnold D. Robbins + + * re.c (check_bracket_exp): New function. + (make_regexp): Call it if do_lint. + +Thu Jul 1 19:22:33 2010 Arnold D. Robbins + + Add support for /inet4/... and /inet6/... files. + + * io.c (socketopen): New parameter `family' for address family. + (inetfile): New function. Changed everywhere to use it and + the values it sets. + +Fri Jun 25 01:01:39 2010 Arnold D. Robbins + + * main.c (main): Added short option letters for all long options + that didn't have them so that they can be used in #!. This + reinstates -r, FWIW. + (usage): Revised message to list standard options first, then + options for extensions, sorted by short letter. + +Mon Jun 21 23:05:20 2010 Arnold D. Robbins + + New FPAT variable and patsplit built-in function. + + * awk.h (NODETYPE): Add Node_FPAT. + (FPAT_node, do_patsplit, set_FPAT): Declare. + (set_FPAT, update_PROCINFO_str, update_PROCINFO_num, + current_field_sep): New functions. + * awkgram.y (tokentab): Add patsplit. + (snode): Add code for do_patsplit to default third arg to FPAT. + (isnoeffect, isassignable): Add cases for Node_FPAT. + * eval.c (nodetypes): Add FPAT. + (r_tree_eval, r_get_lhs): Add cases for Node_FPAT. + * field.c (fpat_parse_field, update_PROCINFO_num, set_FPAT, + do_patsplit): New functions. + (update_PROCINFO): Renamed to update_PROCINFO_str. + (FPAT_re_yes_case, FPAT_re_no_case, FPAT_regexp): New variables. + (using_FIELDWIDTHS): Replaced with current_field_sep and all calls. + * io.c (set_RS): Call current_field_sep insead of using_fieldwidths. + * main.c (main): Use update_PROCINFO_str and update_PROCINFO_num + instead of manually updating the array. + (varinit): Add FPAT. + * profile.c (tree_eval, pp_lhs, is_scalar, pp_var): Add case for + Node_FPAT. + +Fri Jun 12 13:25:32 2009 Arnold D. Robbins + + Make command line arguments that are directories a warning. + They remain a fatal error if --posix or --traditional. + + * configure.ac: Remove the --disable-directories-fatal option. + * io.c (nextfile): Rationalize the code that handles directories, + including setting ERRNO correctly. + +Thu Feb 26 20:57:52 2009 Arnold D. Robbins + + Changes from August 2008 through February 2009 to add + BEGINFILE and ENDFILE, originally against 3.1.6, merged into + development version. + + * awk.h (in_beginfile_rule, in_endfile_rule): Add declarations. + * awkgram.y (beginfile_block, endfile_block): Add declarations. + (beginfile_or_endfile_rule, parsing_endfile_rule): New variables. + (LEX_BEGINFILE, LEX_ENDFILE): New tokens, new rules for those tokens. + (tokentab): Add new entries for BEGINFILE, ENDFILE. + (LEX_NEXTFILE): Allow nextfile in BEGINFILE rule. + (LEX_GETLINE): Allow only `getline var < file' inside BEGINFILE or + ENDFILE. + * eval.c (interpret): Check in_beginfile_rule and in_endfile_rule for + errors for next and nextfile. + (update_ERRNO_saved): When errno == 0, set to ERRNO to + null string. + (interpret): Allow nextfile in BEGINFILE rule. + (update_ERRNO_saved): Check errcode paramater, not global errno. + * io.c (beginfile_block, endfile_block, in_beginfile_rule, + in_endfile_rule): New variables. + (do_input): Set them. Update ERRNO only if not do_traditional. + Propogate error code down to fatal message. + (run_beginfile_rule, run_endfile_rule): New functions. + (iop_alloc): Use it instead of inline code. Add fourth argument + indicating that the open hooks should run. Adjust calls. Point is + to not call open hooks twice inside `nextfile'. + (do_nextfile): Check it and also in_beginfile_rule and only longjump + when both filebuf valid and not in a BEGINFILE rule. + (nextfile): Call run_beginfile_rule and run_endfile_rule as + appropriate. Reorder the logic to set ERRNO and allow BEGINFILE + to call nextfile to skip a bad data file. Adjust calls to + iop_open and find_open_hook. + (nextfile): Call iop_alloc if there's a BEGINFILE block in case + the hooks changed. + (find_open_hook): New function. + (get_a_record): On read error, just set *errcode and return. Let + higher level logic decide if it's fatal. + (inrec): Have error be fatal if traditional or if there isn't + an ENDFILE rule. + * profile.c (dump_prog): Add code for BEGINFILE / ENDFILE. + * awk.h (dump_prog): Adjust declaration. + * main.c (main): Adjust call to `dump_prog'. Check beginfile_block and + endfile_block also to be not NULL in order to call do_input. Thanks to + Steffen Schuler for pointing out the bug. + +Thu Feb 26 07:54:51 2009 Arnold D. Robbins + + Per advice from BWK and my own feelings, nuke additions from 2001 + of seek and tell functions. They were never documented anyway. + + * awk.h (do_seek, do_tell): Remove declarations. + (IOBUF): Remove save_start and rec_size members. + * awkgram.y (tokentab): Remove "seek" and "tell" entries. + * io.c (do_getline): Remove code setting save_start and rec_size. + (iop_alloc): Remove code initializing save_start and rec_size. + (do_seek, do_tell): Removed. + * configure.ac: Remove --enable-seektell option. + +Mon Feb 16 21:54:13 2009 Arnold D. Robbins + + * awkgram.y (tokentab): Enable switch / case by default. + * configure.ac: Remove test for --enable-switch. + +Thu Feb 12 22:06:17 2009 Arnold D. Robbins + + * main.c (optab): --gen-po becomes --gen-pot. -r goes away since it's + now on by default. + (usage): Similar changes. + * regex.h [RE_SYNTAX_GNU_AWK, RE_SYNTAX_POSIX_AWK]: Adjust to support + interval expressions. + [RE_DEBUG]: Nuke: it is no longer used. + * re.c (resetup): Adjust comment for do_intervals. + (reflags2str): Remove RE_DEBUG. + +Sat Jan 17 20:41:54 2009 Arnold D. Robbins + + * awk.h (WSTRCUR): Always define, no real need for ifdef. + * eval.c (flags2str): Similar. + * field.c (rebuild_record): Similar. + +Sat Jan 17 19:59:39 2009 Arnold D. Robbins + + Add indirect function calls. They require a special + syntax, which is an `@' in front of a function call. + + * awk.h (NODETYPE): New Node_indirect_function_call value. + (ASSIGNED): New flag value. + * eval.c (nodetype2str): Add new node type. + (flags2str): Add ASSIGNED. + (func_call): Test the node type to determine + what kind of call. Cache the function body if a real function + is called indirectly. Also get scoping right if called from a function. + LOTS of work here to get this code right! + (op_assign): Add ASSIGNED to flags. + * awkgram.y (function_call, direct_function_call): New productions for + creating indirect function calls. Only call func_use for direct call. + (yylex): Add case for '@'. Only return it if not posix or traditional. + * profile.c (tree_eval): Add case for Node_indirect_func_call. + (pp_func_call): Check type and print '@' for indirect call. + +Tue Dec 30 22:25:04 2008 Assaf Gordon + + * awk.h (do_sandbox): New variable declaration. + * main.c (do_sandbox): Variable definition. + (opttab): Add new option --sandbox. + (usage): Add to usage message. + * builtin.c (do_system): Disallow if sandboxed. + * io.c (redirect): Disallow redirections if sandboxed. + +Tue Dec 30 22:22:04 2008 Arnold D. Robbins + + * builtin.c (usage): Change --binary to --characters-as-bytes, + per Karl Berry. + +Thu Dec 18 05:29:46 2008 Steffen Schuler + + * field.c (*_parse_field): Add `sep_arr' argument and fill it. + * field.c (do_split): Add handling of fourth argument of awk + builtin `split'. + * field.c (get_field): Extend parse_field by default argument. + * awkgram.y (tokentab): Extend `split' entry with fourth argument. + +Wed Dec 17 09:54:00 2008 Arnold D. Robbins + + * main.c (do_binary): New variable for new option -b which + makes gawk not mess with multibyte strings. + (opttab): Add option entry for -b / --binary. + (main): If do_binary, set gawk_mb_cur_max to 1. + +Sat Oct 27 22:43:50 2007 Arnold D. Robbins + + * re.c (resetup): Add RE_INVALID_INTERVAL_ORD to syntax bits if + doing interval expressions. + +Thu Oct 25 23:11:10 2007 Arnold D. Robbins + + * awk.h (devopen): Add `isdir' pointer argument. + * io.c (devopen): Ditto. Adjust logic that checks for directory. + Adjust all calls. + * main.c (main): Adjust call to devopen. + +Sun Oct 3 23:18:44 2004 Arnold D. Robbins + + * dfa.c (lex): Enabled \s and \S escape sequences. + * regcomp.c (peek_token): Ditto. + +Tue Aug 3 13:29:53 2004 Arnold D. Robbins + + * builtin.c (sub_common): Make POSIX 2001 behavior the + default for `sub' and `gsub'. + +Wed Aug 21 13:39:08 2002 Dean Wakerly + + * main.c (main): Add short option letter 'r' for --re-interval. + Mainly for use in #! scripts. + +Wed Dec 26 22:03:48 2001 Arnold D. Robbins + + Nuke /dev/pid etc. special files! + + * awk.h (IOP_IS_INTERNAL, IOP_NO_FREE): Removed. Other defines + renumbered. + * io.c (iop_open, spec_setup, specfdopen, pidopen, useropen): Removed. + (do_input, redirect): Change uses of iop_open() to devopen() + + iop_alloc(). + (iop_close, get_a_record): Remove special handling for IOP_INTERNAL, + IOP_NO_FREE. + (devopen): Remove comment relating to iop_open. + Add fstat check for valid fd for /dev/fd/N. + +Sun Nov 4 10:27:58 2001 Arnold D. Robbins + + * awk.h, builtin.c, awkgram.y: Renamed mark/reset to tell/seek. + * acconfig.h: Add `#undef SEEK_TELL'. + * configure.in: Add `--enable-seektell' configure-time option. + * io.c (do_seek, do_tell): renamed from do_reset, do_mark. + +Thu Aug 16 12:21:28 2001 Arnold D. Robbins + + New feature, undocumented for now, use #define MARK_RESET to + to turn it on. New function val = mark("/some/file") to + save start position of current record. Use + reset("/some/file", pos) to go back to it. ONLY works + with getline. + + * awk.h (IOBUF): New members save_start and rec_size. + (do_mark, do_reset): Add declarations. + * awkgram.y (tokentab): Add entries for mark and reset. + * io.c (specsetup): Initialize save_start and rec_size. + (iop_alloc): Ditto. + (do_getline): Update them as appropriate. + (do_mark, do_reset): New functions. + +Fri Sep 17 12:42:42 2010 Arnold D. Robbins + + * regcomp.c (btowc): Changed to use mbrtowc. + +Wed Sep 15 08:26:55 2010 Arnold D. Robbins + + * dfa.c: Further sync with GNU grep. + +Tue Sep 14 09:53:55 2010 Arnold D. Robbins + + * node.c (str2wstr): Per advice from Ulrich Drepper, when converting, + if the current byte is isprint, isgraph, iscntrl or zero, then it + can't start a multibyte character. This can save many calls to + `mbrtowcs', and speed up the conversion considerably. + +Mon Sep 13 11:19:21 2010 Arnold D. Robbins + + * dfa.h, dfa.c: Sync with GNU grep. + * re.c (dfawarn): New routine for use by dfa. + +Sun Sep 12 22:17:02 2010 Arnold D. Robbins + + * profile.c (tree_eval): Fix comment on for ... delete array loop. + (pp_string_fp): Get escapes right on regex constant. + +Sun Sep 5 20:38:42 2010 John E. Haque + + * re.c (str2wstr): Decrement src_count when skipping bad bytes. + +Fri Aug 27 13:51:13 2010 Arnold D. Robbins + + * dfa.c: Sync with current GNU grep - minor edits only. + +Fri Aug 20 16:26:14 2010 Arnold D. Robbins + + * profile.c (tree_eval): Always parenthesize Node_cond_exp. + May add a few extra parens but guarantees the right semantics. + Thanks to Hermann Peifer for the bug report. + +Thu Aug 19 21:35:13 2010 Arnold D. Robbins + + * regex_internal.c (re_string_reconstruct): Move ifdef out to cover + variable declarations, to avoid "unused variable" warnings. + * regexec.c (check_arrival_add_next_nodes): Bracket declaration of + `err' with ifdef for the same reason. + + Thanks to avarab@gmail.com for the suggestions. + +Wed Aug 18 22:13:30 2010 Arnold D. Robbins + + * Makefile.am (AUTOMAKE_OPTIONS): Added. Other minor cleanups. + +Tue Aug 17 23:27:43 2010 Arnold D. Robbins + + * profile.c (pp_string_fp): Use different sets of escape characters + if printing a string or a regex, based on delimiter. Thanks to + Hermann Peifer for the bug report. + +Sun Aug 8 23:05:09 2010 Arnold D. Robbins + + * re.c (make_regexp): Don't allocate rp->dfareg unless + we're using dfa; causes a memory leak otherwise. Thanks to + Antonio Columbo for reporting the bug. + +Wed Jul 14 23:04:30 2010 Eli Zaretskii + + * dfa.c: Include langinfo.h only if HAVE_LANGINFO_CODESET is + defined. + +Wed Jul 14 23:00:19 2010 Arnold D. Robbins + + * awkgram.y (yylex): Allow a backslash before CR-LF to also + work for line continuation, for MS-DOS style source files. + Thanks to (Vincent Belaiche) for pointing this out. + +Wed Jul 14 22:31:53 2010 Arnold D. Robbins + + * node.c (str2wstr): Keep going if get a bad multibyte sequence. + Allows match to give correct answers for RSTART, RLENGTH. + Add a lint warning. Correctly set the length of the string + based on pointer subtraction. + +Wed Jun 16 21:52:09 2010 Arnold D. Robbins + + * awk.h (exec_count): Moved into NODE structure as standalone + element since count on `/pat/ { ... }' was wrong. Thanks to + Hermann Peifer for the bug report. + + Note to self: DO NOT propogate this to the byte-code version. + + Unrelated: + + * awkgram.y (matchop): Made left associative to match behavior + of other awks. + (print_expression_list): Simplified so that something like + `print ("a", "b") in B in A' will work. Again, to match what + other awks do. + +Fri Jun 4 15:56:59 2010 Arnold D. Robbins + + * dfa.c: Further merges with GNU grep. + +Thu May 20 22:20:32 2010 Stepan Kasal + + * Makefile.am [AUTOMAKE_OPTIONS]: Removed, contents now in ... + * configure.ac [AM_INIT_AUTOMAKE]: ... here. + Added dist-xz while I'm at it, per Karl Berry. + +Tue May 18 14:52:04 2010 Marcin Szewczyk + + * builtin.c (format_tree): Simplify code in pr_tail when multibyte + and %s or %d. + +Thu May 6 20:55:14 2010 Arnold D. Robbins + + * Release 3.1.8: Release tar file made. + +Fri Apr 30 11:37:54 2010 Arnold D. Robbins + + * configure.ac: Remove check for libsnprintf. + +Tue Apr 27 22:23:26 2010 Andreas Schwab + + * builtin.c (do_mktime): Make lint check more sane. + Fix overflow check. Removes GCC warning that Arnold + incorrectly didn't like. + +Mon Apr 26 20:16:07 2010 Arnold D. Robbins + + * ltmain.sh: Removed. + * builtin.c (do_mktime): Restored old code to match the + documentation. We now have a warning that we just have to + live with. Sigh. Stupid GCC. Added a lint warning though. + (format_tree): More code so that %'d acts like %d on systems + without . + * main.c (main): Add `&& #if defined(HAVE_LOCALE_H)' for + call to setlocale. + +Wed Apr 21 23:35:43 2010 Arnold D. Robbins + + * Makefile.am: Change quoting of -Dargs so that even tcsh + users will be happy. + * regex_internal.c (MAX): Add `#undef MAX', just in case. + * configure.ac: Don't look for libsigsegv on OSF/1, gives + us severe headaches. + +Tue Apr 20 12:01:01 2010 Arnold D. Robbins + + * dfa.h, dfa.c: Sync with GNU grep. The long-standing x{0} bug + is now gone. Matching UTF-8 with "." is now much faster. + * re.c (avoid_dfa): Remove call to dfabroken() which is now gone. + * builtin.c (do_mktime): Simplify check of values passed in to be + more readable and to avoid a weird compiler warning from GCC. + +Fri Apr 16 15:02:26 2010 Arnold D. Robbins + + * array.c (assoc_lookup): Add cast in error message to turn + off compiler warning. + * dfa.c (is_blank): New function. Use it everywhere instead of + ctype.h `isblank' macro which isn't available universally. + +Tue Apr 13 22:36:31 2010 Arnold D. Robbins + + * array.c, awkgram.y, builtin.c, dfa.c, eval.c, ext.c, main.c, + node.c, re.c: Remove old ISxxx and TOxxx macros in favor of + standard versions. ``We're two wild and crazy guys!'' + +Tue Apr 13 22:07:18 2010 Arnold D. Robbins + + * getopt.c, getopt.h, getopt1.c, getopt_int.h, regcomp.c, regex.c, + regex.h, regex_internal.c, regex_internal.h, regexec.c: Sync with + glibc. What the heck. + +Thu Apr 8 21:33:09 2010 Arnold D. Robbins + + * dfa.h, dfa.c: All leading indentation is now spaces only. Yet + another sync with grep. + +Thu Apr 8 20:45:25 2010 Arnold D. Robbins + + Move dfa internals into dfa.c and sync with grep. Avoids VMS and + z/OS compile problems in order to avoid cygwin issue when used + with ligsigsegv. ("Portability? We don't need no stinkin' + portability!") + + * dfa.h: Move all the internals into dfa.c. + (dfaalloc, dfamusts, dfabroken): Add declarations. + * dfa.c: Accept all the internals. + (dfaalloc, dfamusts, dfabroken): New functions. + * awk.h (Regexp): Use a `struct dfa *'. + * re.c (make_regexp): Call dfaalloc. Adjust uses of dfareg + in other routines. + (refree): Free the dfa struct too. + +Tue Apr 6 23:06:55 2010 Arnold D. Robbins + + * dfa.h, dfa.c: Further sync with GNU grep for enum change + and other misc changes. + +Tue Apr 6 20:13:45 2010 Michal Jaegermann + + * main.c: Wrap declarations and bodies of `catchsegv' and + `catchstackoverflow' in #ifdef HAVE_LIBSIGSEGV to avoid + "not used" warnings. + +Tue Apr 6 20:11:47 2010 Arnold D. Robbins + + * dfa.h: Move definition of token enum to dfa.c to avoid conflict + with Windows WCHAR introduced by libsigsegv. Thanks to Corinna + Vinschen. + * dfa.c: Enum body here. + (in_coll_range): z/OS fix: Initialize array to all zeros and assign + values instead of putting them into the initializer. Thanks to Dave + Pitts for reporting the problem. + +Fri Apr 2 12:32:40 2010 Arnold D. Robbins + + * dfa.c: Sync with grep 2.6.3. + +Wed Mar 31 15:50:34 2010 Arnold D. Robbins + + * dfa.c (dfaexec): Move decl of `saved_end' up to top of function. + Fixes compilation on C89 compilers. + +Mon Mar 29 08:40:29 2010 Arnold D. Robbins + + Remove local copy of libsigsegv. Use an external copy if available. + + * Makefile.am: Remove SEGVSUBDIR and SEGVINCLUDE. + * configure.ac: Remove previous code that handled the library and use + gl_LIBSIGSEGV library. + * custom.h: Remove code for HAVE_SIGSEGV_H. + * main.c: Move to HAVE_LIBSIGSEGV. + * libsigegv/ : Removed. + +Mon Mar 29 05:41:35 2010 Corinna Vinschen + + * dfa.c: Include hard-locale.h after xalloc.h because it needs + xmalloc. + * hard-locale.h (xmalloc): Remove declaration. + (hard_locale): Cast xmalloc to correct target type. + +Mon Mar 29 05:38:47 2010 Arnold D. Robbins + + * io.c: (two_way_open): In counting down retries, test for > 0 + instead of >= 0 since retries is unsigned. Thanks to Pat Rankin + for noticing. + * configure.ac: Remove use of -export-dynamic on cygwin. + +Thu Mar 25 21:48:13 2010 Arnold D. Robbins + + * dfa.c: Sync to grep 2.6.1. That's probably enough for now. + +Wed Mar 24 19:48:01 2010 Arnold D. Robbins + + * dfa.c: More sync with grep. + +Tue Mar 23 19:42:48 2010 Jeff Chua + + * io.c (two_way_open): Bug fix in management of timeout value. + +Tue Mar 23 19:40:04 2010 Arnold D. Robbins + + * dfa.h, dfa.c: Synced with released grep 2.6. Oh Frabjous Day! + Callou! Callay! + +Mon Mar 22 22:49:44 2010 Arnold D. Robbins + + * awkgram.c: Regenerated using bison 2.4.2. + +Fri Mar 19 10:19:20 2010 Arnold D. Robbins + + * dfa.c: Minor edits for compat with grep. + +Fri Mar 19 09:19:56 2010 Arnold D. Robbins + + * io.c (two_way_open): Cleanup new code for socket opens. + * replace.c: Include missing_d/usleep.c based HAVE_USLEEP. + * configure.ac: Add usleep to list of functions to look for. + +Thu Mar 18 23:30:33 2010 Arnold D. Robbins + + * dfa.h, dfa.c: Imported from GNU grep and merged. Passes "make test". + * xalloc.h: New file, needed by dfa.c. + * Makefile.am (base_sources ): Added xalloc.h. + +Thu Mar 18 07:29:45 2010 Jeff Chua + + * io.c (two_way_open): Make failure to open a socket a non-fatal error. + Allow the amount of time to sleep during socket retries to come from an + undocumented env variable giving time in milliseconds. + +Mon Mar 8 20:58:05 2010 Paolo Bonzini + + More fixes from GNU grep. + + * dfa.c (dfaexec): Remove register keywords. + (FETCH): Use do..while(0) idiom. + (parse_bracket_exp_mb): Return MBCSET. + (in_coll_range): New. + (lex): Assign return value of parse_bracket_exp_mb to lasttok, + return it. Use in_coll_range instead of regcomp/regexec. + +Mon Mar 8 20:36:35 2010 Jim Meyering + + Fixes from GNU grep development version: + + build: avoid shadowing warnings + * dfa.c (match_mb_charset): Rename parameter: s/index/idx/. + (check_matching_with_multibyte_ops, match_anychar): Likewise. + + build: avoid shadowing warning for unused "rs" + * dfa.c (transit_state): Remove dead stores; + Ignore transit_state_consume_1char return value. + + syntax: remove trailing blanks + * dfa.c: Remove trailing blanks, to ease synchronization with grep. + + clean-up: limit visibility of an internal function + * dfa.c (match_mb_charset): Declare static. + + build: rename local to avoid shadowing global, dfa + * dfa.c (dfamust): Rename parameter: s/dfa/d/. + +Thu Feb 18 22:44:01 2010 Arnold D. Robbins 0 + + * eval.c (push_args): Clear the stack to NULL pointers after mallocing + it. Fixes yesterday's problem when called from a rule. + See test/fcall_exit2.awk. Thanks to Seb . + +Wed Feb 17 23:19:32 2010 Arnold D. Robbins + + * eval.c (pop_fcall): Check that argument on stack is not NULL before + attempting to clear it; add comment explaining it. + (push_args): Set nodes to zero for argument to make sure that values + are NULL for testing later in pop_fcall. See test/fcall_exit.awk. + Thanks to Seb . + +Sun Jan 31 22:46:49 2010 Arnold D. Robbins + + * profile.c (prec_level): Add Node_regex to the switch so that + `! /xxx/' works. Thanks to Hermann Peifer for + reporting the bug. + +Thu Jan 28 17:40:14 2010 Arnold D. Robbins + + * configure, Makefile.am: Updated to Autoconf 2.65 and Automake 1.11.1, + libsigsegv 2.8. + +Thu Jan 21 23:24:56 2010 Arnold D. Robbins + + * profile.c (pprint): Separate out code for Node_switch_body and only + print the lnode; avoids printing the default case twice. Thanks to + Hermann Peifer for reporting the bug. + +Sun Jan 3 21:03:01 2010 Arnold D. Robbins + + * dfa.c: Added casts as needed to silence warnings about + signedness of pointers from GCC 4.x. + +Fri Jan 1 11:41:50 2010 Arnold D. Robbins + + * builtin.c (format_tree): At pr_tail, remember to take the precision + into account when determining how many characters to copy out. + Thanks to tczy for the bug report. + +Tue Dec 8 12:29:30 2009 Arnold D. Robbins + + * configure.ac, awk.h: Remove use of header file. + +Mon Dec 7 15:25:02 2009 Arnold D. Robbins + + * node.c (format_val): Use <= and >= in the comparisons with + LONG_xxx instead of < and > so that things work correctly on systems + with 64 bit integers. Thanks to Stephen Davies for pointing out + the problem. + +Sat Nov 21 23:14:59 2009 Arnold D. Robbins + + * builtin.c (format_tree): If there is not an actual thousands + separator character, don't let `quote_flag' have an effect. Fixes + test failure on Solaris 10, which bizarrely says to use the + thousands separator character every three digits, but then doesn't + actually supply one. Thanks to Nelson Beebe for the initial + report. + +Mon Nov 16 22:27:44 2009 Arnold D. Robbins + + * awk.h (getnode): If MPROF wrap body in parentheses; remove + incorrect trailing semicolon. + * bisonfix.awk: Convert "y.tab.c" to "awkgram.c" for those rare + instances where we need to use a debugger on the parser so + that gdb will find the right source file. + +2009-10-26 Andreas Schwab + + * io.c (iop_open): Set errno when rejecting a directory. + +Tue Oct 20 22:48:14 2009 Arnold D. Robbins + + * awkgram.y (constant_fold): Fix check for two strings to look + at `right->flags'. Fix division code to check for division by + zero first. Thanks to Stephen Davies + for both. + +Fri Oct 16 08:41:29 2009 Arnold D. Robbins + + * io.c (redirect): Do the close-on-exec setting before + attempt to get a FILE *. Thanks to Andreas Schwab. + +Wed Oct 14 23:25:47 2009 Arnold D. Robbins + + * io.c (redirect): When opening a file, set the close-on-exec flag. + Thanks to Chris Pearson for the bug report. + +Tue Oct 6 21:07:23 2009 Arnold D. Robbins + + * main.c (main): When an option requires an argument and we print a + message, call `usage' and exit. + + Fix all calls to `usage' to use EXIT_FAILURE and EXIT_SUCCESS + instead of 1 and 0. + +Sun Oct 4 21:46:11 2009 Arnold D. Robbins + + * main.c (main): Don't reset argv[0] to myname. In call + to `init_args', pass argv[0] if do_posix. Based on + Fedora bug report. + +Sun Oct 4 18:45:06 2009 Arnold D. Robbins + + * array.c (assoc_lookup): In lint warning, don't clobber + the character at the end of the subscript; instead use the + length to limit the number of characters printed. Thanks to + Nick Hobson . + +Sun Aug 30 22:40:12 2009 Arnold D. Robbins + + * builtin.c (do_length): Handle the case where Node_var_new + was passed in as a parameter via a function call parameter. + Thanks to Greg Johnson for reporting + the bug. + +Tue Aug 11 19:23:51 2009 Arnold D. Robbins + + * profile.c (parenthesize_expr): New function. + (tree_eval): Use it for Node_and and Node_or. Thanks to + Hermann Peifer for reporting the bug. + +Tue Aug 4 06:04:23 2009 Arnold D. Robbins + + * builtin.c (format_tree): zero_flag does not apply to + %c and %s conversions. Thanks to Mike Brennan and Thomas Dickey + for the bug report. + +Tue Jul 21 22:28:56 2009 Arnold D. Robbins + + * Release 3.1.7: Release tar file made. + +Fri Jul 17 08:35:10 2009 Arnold D. Robbins + + * awkgram.c: Rebuilt with current Bison (2.4.1). + +Thu Jul 9 22:55:17 2009 Arnold D. Robbins + + * (NEWS README array.c awk.h awkgram.y builtin.c configure + configure.ac custom.h dfa.c ext.c field.c floatcomp.c io.c + main.c node.c profile.c re.c replace.c): Update copyrights + and other prep for a release. + +Thu Jul 9 22:20:04 2009 Arnold D. Robbins + + * main.c (init_locale): New function to make a deep copy of the + struct lconv. Thanks to KIMURA Koichi + for the info. + * eval.c (r_tree_eval): Further improve Node_assign_concat code to + temporarily to keep reference counts correct and to get the + desired behavior. + +Mon Jul 6 20:29:12 2009 Arnold D. Robbins + + * floatmagic.h: Remove @ signs copied from Texinfo. + It would help if I were more awake. + +Sat Jul 4 21:55:18 2009 Arnold D. Robbins + + * Makefile.am (base_sources): Add floatmagic.h so it'll + go into the tar ball. + +Fri Jul 3 13:47:36 2009 Arnold D. Robbins + + * profile.c (is_scalar): Add Node_func_call to list. + (pp_concat): Make logic smarter for tree created by Node_assign_concat. + +Fri Jul 3 13:01:49 2009 Arnold D. Robbins + + * awkgram.y (optimize_concat): New function that applies + Node_assign_concat more generally. + * eval.c (r_tree_eval): Improve Node_assign_concat code to temporarily + increase the stref on `l' to avoid side effects during evaluation of + `r'. This makes test/nasty.awk work. Ouch. + +Tue Jun 30 22:10:37 2009 Arnold D. Robbins + + * floatmagic.h: New file. + * builtin.c (format_tree): Use functions defined in floatmagic.h. + +Tue Jun 30 21:57:47 2009 Arnold D. Robbins + + * configure.ac, Makefile.am: Add new --disable-libsigsegv command line + option to configure. + (LIBSIGSEGV, SEGVINCLUDE, SEGVSUBDIR): New variables that will be empty + if libsigsegv is disabled so nothing will happen, and that will have the + right values otherwise. They are then substituted into the Makefile. + +Wed Jun 24 23:00:10 2009 Arnold D. Robbins + + * bootstrap.sh: Revised. Now works again. We think. (CVS-only file) + +Wed Jun 24 21:57:30 2009 Arnold D. Robbins + + * custom.h: Move z/OS EXIT_FAILURE definition from here to ... + * awk.h: Here. Define at end after regular definition. + +Thu Jun 18 06:17:38 2009 Scott Deifik + + * awk.h: Don't define HAVE_SIGSEGV_H for DJGPP. + +Thu Jun 18 05:38:42 2009 Dave Pitts + + * custom.h: Changes needed for z/OS. + +Wed Jun 10 08:22:53 2009 Arnold D. Robbins + + * node.c (parse_escape): Add a lint warning if \x.. has more than two + hex digits. + +2009-06-08 gettextize + + * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.17. + +Mon Jun 8 22:13:49 2009 Arnold D. Robbins + + Update to Autoconf 2.63, Automake 1.11, Libtool 2.2.6a + + * ltmain.sh: New file. + * configure.ac: Changes to keep infrastructure tools happy. + * alocal.m4, configure: Regenerated. + * Makefile.in, */Makefile.in: Regenerated. + +Mon Jun 8 07:43:25 2009 John DuBois + + * builtin.c (mbc_byte_count, mbc_char_count): Make sure all declarations + come before executable code, for older compilers. + * dfa.c (insert): Ditto. + * io.c (devoopen): Ditto. + +Thu May 21 21:11:44 2009 Arnold D. Robbins + + Add simple constant folding. + + * awk.h (do_optimize): New declaration. + (calc_exp): Add declaration. + * eval.c (calc_exp): Make non-static. + * main.c (do_optimize): New variable. + (opttab): Add new entry for --optimize. + (main): Add 'O' to optlist and code for argument parsing. + (usage): Update for new option. + * awkgram.y (Node_concat, Node_exp, Node_times, Node_quotient, Node_mod, + Node_plus, Node_minus): Call `constant_fold' to create the node in + the tree. + (constant_fold): New function. + +Fri May 15 16:02:01 2009 Arnold D. Robbins + + * awk.h (getnode): For MPROF: Fix a typo. + +Fri May 15 14:10:44 2009 Arnold D. Robbins + + Function arguments cannot be reserved variable names, per POSIX. + + * main.c (struct varinit): Add flags member. + (varinit): Add values for flags member (one or both of NON_STANDARD + or NO_INSTALL). Add entries for the rest of the gawk variables and + sort them, so that the table can be searched by ... + (is_std_var): New routine to see if a name is a standard variable. + * awk.h (is_std_var): Add declaration. + * awkgram.y (func_install): Use new routine and issue error. + +Wed Apr 22 07:42:05 2009 Arnold D. Robbins + + * builtin.c (sub_common): In code for handling \ replacements, + first make sure that is within the range of parentheses sets + given, and then make sure that the subpattern start is not -1, meaning + that something actually matched. Thanks to Martin Olsson + for the bug report. + (do_length): Add a lint warning if `length' is passed an untyped + argument. + +Thu Apr 16 22:59:32 2009 Arnold D. Robbins + + * eval.c (func_call): Save nloops_active; if after function returns + the actual nloops_active is greater than the saved value, it means + there was a return inside the loop body, so pop off the necessary + number of loops. Bug reported by Aleksey Cheusov . + Gawk was not leaking memory - that is, things were still pointed + to, but memory use could keep on growing. + +Fri Mar 27 10:59:11 2009 Arnold D. Robbins + + * builtin.c (format_tree): Add lint warnings for fieldwidth and/or + precision in %%, and add lint warning for unknown format specifier + (e.g. %b). Thanks to "joanes.polus" for + the report. + +Wed Mar 18 18:15:41 2009 Pat Rankin + + * awk.h (EXIT_SUCCESS, EXIT_FAILURE): Move VMS-specific values + to vms/vms-conf.h. + (EXIT_FATAL): Define here instead of in msg.c. + * msg.c (EXIT_FATAL): Move definition to awk.h. + +Mon Mar 16 18:58:09 2009 Pat Rankin + + * main.c [#if HAVE_SIGSEGV_H]: For the #else case (VMS), + (stackoverflow_context_t): Dummy typedef for use in prototypes; + (stackoverflow_install_handler): Make macro expand to 0 rather + than nothing so that (void) cast on invocation of it works. + + * main.c (catchstackoverflow): Don't return 0 from void function. + +Wed Feb 25 21:34:14 2009 Arnold D. Robbins + + * awkgram.y (tokentab): Have only one copy of BEGIN / END. + (tokcompare): New function. + (check_special): Sort tokentab for EBCDIC systems. + +Sun Feb 15 22:39:30 2009 Arnold D. Robbins + + * profile.c (pp_delete): Print tree->exec_count to actually get + the value printed. Thanks to Hermann Peifer + for reporting the bug. + +Thu Feb 12 21:54:34 2009 Arnold D. Robbins + + * awkgram.y: Change to use EXIT_FAILURE. + * msg.c [EXIT_FATAL]: New macro. + * msg.c (r_fatal): Change to use EXIT_FATAL. + Thanks to Pat Rankin for pointing these out. + * re.c (reflags2str): Account for RE_SYNTAX_EMACS. + * awk.h: If not VMS, define HAVE_SIGSEGV_H. + * main.c: Check HAVE_SIGSEGV_H before including . If not + there, define dummy macros. + (catchsegv, catchstackoverflow): Remove unneeded comment. Add return 0 + for compilers that care. + +Mon Feb 9 05:24:52 2009 Arnold D. Robbins + + * awk.h [CONST]: Renamed CONSTANT to avoid conflict with libsigsegv + on Windows. + * awkgram.y, field.c, re.c: Update all uses. + +Tue Feb 3 22:46:59 2009 Arnold D. Robbins + + * io.c (do_close): Wrap updating of ERRNO in check for not + do_traditional. + +Sat Jan 31 23:14:00 2009 Arnold D. Robbins + + * builtin.c (format_tree): For '%s', don't count the multibyte + characters if we are just copying all the characters. Gives + big speedup. Thanks to Hirofumi Saito + for reporting the problem. + +Thu Jan 29 21:14:30 2009 Arnold D. Robbins + + * field.c (parse_field, re_parse_field, def_parse_field, + posix_def_parse_field, null_parse_field, sc_parse_field, + fw_parse_field): Add new last arg `in_middle'. Ignored by all + except re_parse_field. + (re_parse_field): Enhance logic to only allow ^ in a regex to match + if indeed at the beginning of a record. + (getfield): Adjust call to parse_field. + +Tue Jan 27 21:42:47 2009 Arnold D. Robbins + + Changes suggested by Toni Schilling , + as modified by feedback from Pat Rankin, and some help + from me. + + * awk.h [WEXITSTATUS]: Improve definition for MSC and VMS. + [EXIT_SUCCESS, EXIT_FAILURE]: Define if they aren't. + * io.c, main.c, profile.c: Switch to using EXIT_xxx instead of + 0 and 1. + (main): Use constants instead of 0/1 for exit_val variable. + * eval.c (interpret): Map exit value from `exit' statement into + success / fail constants for VMS for exit_val variable. + +Tue Jan 20 07:35:34 2009 Arnold D. Robbins + + * regex.h: Define __USE_GNU if not _LIBC; needed for non-GLIBC + systems such as, oh say, Mac OS X. + +Tue Jan 13 09:23:40 2009 Arnold D. Robbins + + * regex.c, regex_internal.h: Remove some changes that are no + longer needed after sync with GLIBC. + +Mon Jan 12 22:27:10 2009 Arnold D. Robbins + + Bi-annual sync with GLIBC. + + * regexec.c, regex.h, regex_internal.c, regcomp.c, regex_internal.h, + regex.c: Reapply any portability patches specific to gawk. + * getopt.c: Sync with GLIBC. + + Base versions: + getopt.c 1.57 Thu Jan 8 20:02:05 2009 + getopt.h 1.21 Fri Mar 19 00:19:32 2004 + getopt1.c 1.10 Tue Mar 9 10:35:37 2004 + getopt_int.h 1.1 Tue Mar 9 10:31:19 2004 + regex.c 1.129 Tue Sep 6 20:49:44 2005 + regexec.c 1.99 Thu Jan 8 20:02:06 2009 + regexec.c 1.99 Thu Jan 8 20:02:06 2009 + regex.h 1.43 Wed Jan 16 10:09:47 2008 + regex_internal.c 1.69 Thu Jan 8 20:02:06 2009 + regex_internal.h 1.76 Thu Jan 8 20:02:06 2009 + regcomp.c 1.120 Thu Jan 8 20:02:06 2009 + +Mon Jan 5 23:07:58 2009 Arnold D. Robbins + + * io.c (devopen): Add a retry to calls to socketopen. Tunable + via undocumented GAWK_SOCK_RETRIES environment variable. Based + on code from Juergen Kahrs after a + suggestion from Hermann Peifer . + +Mon Jan 5 22:48:39 2009 Arnold D. Robbins + + * io.c (redirect): A getline from a directory is no longer + fatal; instead it returns -1. Thanks to Paolo + for the report. + +Mon Dec 29 22:04:57 2008 Arnold D. Robbins + + * builtin.c (format_tree): Case for 's', improve logic for setting + the number of characters to copy, also at pr_tail. Based on + bug report by Hermann Peifer . + +Thu Dec 11 21:23:50 2008 Arnold D. Robbins + + * builtin.c (do_length): If the wide string has zero length + but the bytes are more than zero, use the number of bytes. + (do_index): Similar also: fall back to byte count if the + bytes don't make a wide-character string. + Bug reported by "Carlos G." + + (do_substr): If defaulting to length of rest of the string, + do it based on the wide char string if it's valid. + +Fri Dec 5 11:12:11 2008 Arnold D. Robbins + + * io.c (free_rp): New function. + (redirect): Improved logic for yesterday's change, including + use of free_rp. + (close_redir): Use free_rp. + +Thu Dec 4 22:35:05 2008 Arnold D. Robbins + + * io.c (redirect): Only put the new struct redirect into + the list if the file or pipe could actually be opened. Fixes + a bug with the wrong return value of close, noticed by + Seb . + * dfa.c (parse_bracket_exp_mb): Don't zero out work_mbc->chars + after we malloc'ed it. Fixes a leak found by valgrind when + using UTF-8. (Hmmm. This got fixed in January 2007; It seems + to have crept back into the code in the August 2007 merge with + GNU grep. Sigh.) + +Mon Oct 20 11:47:59 2008 Arnold D. Robbins + + * configure.ac: Add -g3 and -gdwarf-2 to CFLAGS if compiling with + GCC and doing development. Should have done this ages ago. + +Sun Aug 31 22:03:55 2008 Arnold D. Robbins + + * eval.c (set_BINMODE): Tighten up the code even more so + that it matches the documentation. + +Mon Aug 25 22:41:47 2008 Arnold D. Robbins + + * eval.c (set_BINMODE): Tighten up the code to only allow + certain reasonable values when setting BINMODE. + +Fri Aug 22 14:43:49 2008 Arnold D. Robbins + + * io.c (nextfile): Users Strong In The Ways Of The Source can use + non-existant files on the command line without it being a fatal error. + +Wed Jul 30 23:10:51 2008 Arnold D. Robbins + + * re.c (research): Don't ever use DFA if need_start. It can + break on some weird cases. Reported by + "T. X. G." . + +Wed Jul 30 22:27:20 2008 Arnold D. Robbins + + * builtin.c (do_match): Add MAYBE_NUM flag to elements of array + created by `match' since data could come from user. Similar + semantics to `split'. Thanks to Dr. Dirk Zimoch + for reporting the bug. + +Tue Jun 24 07:44:06 2008 Arnold D. Robbins + + * dfa.c (insert): Reworked for significant speed improvement + by Johan Walles . Imported from grep + bug list. + * profile.c (tree_eval): Do a return after all the built-in + variables instead of a break. Thanks again to Hermann Peifer + for finding the problem. + +Sun Jun 22 23:08:14 2008 Arnold D. Robbins + + * node.c (format_val): Restore old code to use %ld when the value + is within the range of a long; improves performance noticably for + applications that convert integers to strings. Use %.0f only for + integral values that are outside the range of a long. Thanks to + Hermann Peifer for pointing out the existence + of a problem. + +Fri May 23 12:08:24 2008 Arnold D. Robbins + + * dfa.c (epsclosure): Change type of `visited' from int to char for + potential speedup. Based on bug report to bug-grep list from + Johan Walles . + +Wed May 14 05:55:48 2008 Arnold D. Robbins + + * builtin.c (format_tree): For `%c' case, add a lint warning + if the value is greater than 255. + (mbc_byte_count, mbc_char_count): Remove unused variable `i'. + +Thu Apr 24 20:31:03 2008 Bruno Haible + + * main.c (main): Move call to catch SIGBUS to before installation of + libsigsegv handler, since on some systems libsigsegv installs its + own handler for SIGBUS. + [STACK_SIZE]: Add a constant instead of inline. ADR. + +Wed Apr 23 22:30:27 2008 Duncan Moore + + * builtin.c (state): Do as an integer array for systems that need it. + (do_rand, init_rand): Modify call to `initstate' as needed. + +Wed Apr 23 22:22:06 2008 Arnold D. Robbins + + * dfa.c (prednames): Add an extra zero to final initializer to + silence a compiler warning. Reported by Duncan Moore + . + +Wed Apr 23 21:36:06 2008 Steffen Schuler + + * field.c (fw_parse_field): Add code for multibyte case. + +Sat Mar 15 22:17:21 2008 Arnold D. Robbins + + * builtin.c (do_length): Handle the case of the parameter being + an array that was a function parameter. + +Tue Mar 11 22:49:11 2008 Kimura Koichi + + * builtin.c (format_tree): Fix call to mbc_byte_count to pass the + right number of characters based on the format type. + +Tue Mar 11 22:31:58 2008 Arnold D. Robbins + + * libsigsegv: Incorporated into the dist. + * Makefile.am (SUBDIRS): Added. Make it first so that the library + is built before gawk is. + (LDADD): Add the library. + (AM_CPPFLAGS): Add -I option to find header. + * configure.ac: Add call to AC_CONFIG_SUBDIRS for libsigsegv. + * main.c (catchsegv, catchstackoverflow): New functions. + (main): Call into sigsegv library with them. + +Tue Mar 4 21:02:25 2008 Arnold D. Robbins + + * builtin.c (mbc_char_count, mbc_byte_count): New functions to return + the number of m.b. chars there are and the number of bytes needed to + copy them. + (format_tree): Use them for %s and %c cases to adjust precision and + for copying characters at pr_tail label. + +Thu Feb 14 14:05:01 2008 Arnold D. Robbins + + * main.c (init_args): Adjust type of third arg to remove warning from + GCC 4.2, add cast in call to make_string. Bleah. + +Fri Jan 25 12:13:39 2008 Dave Pitts + + * README_d/README.zos: New file. + * Makefile.am: Add sed on y.tab.c to convert older Bison "parse error" + messages to "syntax error" messages. + * configure.ac: Added ZOS_USS changes. + * m4/arch.m4: Added ZOS_USS changes. + * m4/inttypes_h.m4: Added ZOS_USS changes. + * m4/inttypes.m4: Added ZOS_USS changes. + * m4/stdint_h.m4: Added ZOS_USS changes. + * awkgram.y: Added USE_EBCDIC changes for EBCDIC collating sequence. + * awk.h: Added ZOS_USS compile changes. + * eval.c: Added EBCDIC casetable and ZOS_USS changes. + * regcomp.c: Added btowc function for ZOS_USS. + * regex.h: Changed __string to __cstring to avoid ZOS_USS header usage. + * regex_internal.h: Added ZOS_USS changes and type defines. + +Sun Jan 13 08:16:38 2008 Arnold D. Robbins + + * dfa.c (epsclosure): Replace MALLOC + zero-out-loop with CALLOC for + large potential speedup, based on bug report to bug-grep list from + Johan Walles . + (dfaanalyze): Made a similar change. + +Fri Dec 21 11:22:16 2007 Arnold D. Robbins + + * profile.c (pprint): Add a missing `#ifdef PROFILING'. + +Thu Dec 13 22:19:19 2007 Arnold D. Robbins + + * profile.c (parenthesize): Remove "!" from output string. + (tree_eval): Fix quotes for delete array case. + (pp_var): New function, call it as appropriate everywhere else. + +Fri Nov 30 11:11:52 2007 Arnold D. Robbins + + * io.c (socketopen): Use NULL as first argument to `getaddrinfo' + if any_remote_host is true. Should help on Non-GLIBC systems. + +Thu Nov 15 22:01:36 2007 Arnold D. Robbins + + * io.c (two_way_open): Case for ptys. Change search for letters + to avoid ASCII / EBCDIC problems. + +Mon Oct 22 08:49:05 2007 Arnold D. Robbins + + * Release 3.1.6: Release tar file made. + +Sun Oct 14 23:19:12 2007 Ralf Wildenhues + + * Makefile.am: Avoid GNU make-specific `make -C'. + +Sun Oct 14 19:37:01 2007 Arnold D. Robbins + + * configure.ac: Add check for `atexit', needed by replacement + version of `snprintf'. + +Sun Sep 30 21:50:59 2007 Arnold D. Robbins + + Rationalize locale's influence on %'g, strtonum, and input. + + * awk.h (use_lc_numeric): Add declaration. + * builtin.c (format_tree): Add check for quote_flag and set + LC_NUMERIC so that The Right Thing gets done, then reset it. + (do_strtonum): Pass use_lc_numeric as second arg to isnondecimal. + * main.c (main): Have do_posix set use_lc_numeric also. + +Thu Sep 27 21:36:23 2007 Stepan Kasal + + * configure.ac: Do not instantiate version.c; remove the hack + to keep version.c from being removed upon `make distclean'. + * Makefile.am (version.c): New rule. + (.c.i, SUFFIXES): Remove, `.i' is unused. + (MAINTAINERCLEANFILES): Remove awkgram.c; Automake takes care of that. + +Wed Sep 26 14:40:13 2007 Eli Zaretskii + + * builtin.c (format_tree): Handle non-standard snprintf that + returns a negative value when the buffer is too small. + +Tue Sep 25 23:27:41 2007 Arnold D. Robbins + + * ChangeLog: Removed all leading spaces. Fixed up formatting of + entries to have capital letter after the colon. Fixed a number of + entries to have the '*' in the right place. ASCII instead of ascii. + Capitalize Linux. (Is this anal-retentive or what? Sheesh.) + +Tue Sep 25 08:24:11 2007 KIMURA Koichi + + * awk.h: Add include of for Visual Studio. + * regex_internal.h: Do the right thing for replacing alloca. + +Sat Sep 22 23:26:27 2007 Arnold D. Robbins + + * field.c (set_FIELDWIDTHS): Restore behavior of 3.1.4 that allowed + FIELDWIDTHS to be "" without crashing, and such a value has NF = 0. + Yet Another Dark Corner. Thanks to Glenn Zazulia + for pointing out the problem. + + Unrelated: + + * builtin.c (format_free): Make `quote_flag' not sticky. Thanks to + Ulrich Drepper for pointing this out. + * main.c (main): Adjust calls to `setlocale' and `localeconv' so that + the %'d flag will work even if not using the locale's decimal point. + +Thu Sep 20 21:02:41 2007 Arnold D. Robbins + + * array.c (hash, awk_hash, gst_hash_string): Add fourth argument + pointer to retrieve code. Only assign a value if not NULL. + Fix most places to pass NULL for fourth argument. + (assoc_lookup): Save the code in the node for use in growing the + array later. + (grow_table): Use the saved code instead of recomputing each time. + * awk.h (NODE hash): Add `code' member and `ahcode' macro. + (hash): Revise declaration. + * awkgram.y: Revise calls to `hash'. + +Tue Aug 21 17:47:07 2007 Arnold D. Robbins + + * main.c (copyleft): Cite version 3 of the license. + * dfa.c: Minor edits to sync with grep 2.5.3. + +Sat Aug 11 22:48:11 2007 Arnold D. Robbins + + * COPYING: Replaced with GPL 3. + * All other relevent files: Upgraded to GPL 3. + +Fri Aug 3 15:01:38 2007 Andrew J. Schorr + + * builtin.c (format_tree): Free `obuf' before call to `fatal' + to keep valgrind happy. + +Mon Jun 4 01:12:21 2007 Arnold D. Robbins + + * All relevant files: Updated copyright year to 2007. + +Mon May 28 08:06:15 2007 Arnold D. Robbins + + * main.c (use_lc_numeric): New variable, true for new + option `--use-lc-numeric'. + (optab): Add option "use-lc-numeric". + (usage): Add to usage message. + (main): Allow the --use-lc-numeric option to also use the + local decimal point. + +Fri May 18 16:26:00 2007 Arnold D. Robbins + + * awk.h (_TANDME_SOURCE): Add test for ! _SCO_DS for + SCO systems. Thanks to John DuBois + +Tue May 15 13:14:04 2007 Arnold D. Robbins + + General capability suggested by Michael May . + + * configure.ac: New option --disable-directories-fatal. Makes gawk + silently skip directories on the command line. + * io.c (iop_open): Add fourth parameter, pointer to flag which is set + to true if the file is a directory. In this case, close the fd and + return NULL. + (nextfile): Modify call to iop_open. Add logic to check for directory + and skip if --disable-directories-fatal was used. If the configure flag + was not used, then if do_traditional also skip. + (redirect): Modify call to iop_open and call fatal if isdir is true. + +Mon May 7 14:51:54 2007 Arnold D. Robbins + + * POSIX.STD: Updated. + +Wed May 2 19:29:56 2007 Stepan Kasal + + Revert precedence of concatenation and | getline. + From mail dated 2005-10-31. + + * awkgram.y (common_exp): Move the two rules for naked regexp and + the rule for "(...) in arr" to ... + (non_post_simp_exp): ... here ... + (simp_exp): ... and here, respectively. Fixes test/parsefld.awk/. + (simp_exp_nc): New nonterminal, needed to fix the + precedence of concatenation over "|getline". + (common_exp): Can also start with simp_exp_nc. + +Tue May 1 19:53:11 2007 Arnold D. Robbins + + Work around problem with /ab{0}c/. + * dfa.h (struct dfa): Add member `broken'. + * dfa.c (dfainit): Initialize it to false. + (lex): Set it if `minrep == maxrep && minrep == 0'. + * re.c (avoid_dfa): Check flag and return TRUE if set. + +Tue May 1 05:34:53 2007 Arnold D. Robbins + + * configure.ac: Add calls to AM_LANGINFO_CODESET, and gt_LC_MESSAGES. + Thanks to Matthew Burgess . + +Sun Apr 29 22:55:12 2007 Arnold D. Robbins + + * regcomp.c (utf8_sb_map): Remove const if not __GNUC__ >= 3. + * regex_internal.h (re_dfa_t): Bracket bizarre macro call with + check for _LIBC. + Thanks to Nelson Beebe for finding both problems. + +Sun Apr 29 13:10:31 2007 Arnold D. Robbins + + * builtin.c (do_strftime): Add optional third argument to strftime() + which if non-zero or non-null means to use UTC. + * awkgram.y (tokentab): Allow three arguments to strftime. + +Fri Apr 27 11:44:27 2007 Arnold D. Robbins + + * README.cvs, bootstrap.sh: Added to CVS archive, not for + inclusion in tarballs. + +Fri Apr 20 16:48:30 2007 Pat Rankin + + * awk.h: Move inclusion of redirect.h before HAVE_func blocks. + +Tue Apr 24 21:55:36 2007 Arnold D. Robbins + + * re.c (research): In the multibyte case, fall back to the full + matcher if need_start, since there are bugs in the dfa matcher + in some obscure cases. Sigh. + * builtin.c (format_tree): When using %.0f instead of %d, assert + that we're not malloc-ing zero. + +Tue Apr 17 21:51:40 2007 Arnold D. Robbins + + Portability fixes for lsbcc from Nelson Beebe. + + * configure.ac: Check for stddef.h header. + * regex.h: Use check and include header to get size_t definition. + * main.c: Update UPDATE_YEAR, add #ifdef for HAVE_MTRACE. + +Tue Apr 17 13:49:13 2007 Arnold D. Robbins + + * configure.ac: Add test for struct sockaddr_storage. + * io.c: Add macro to redefine sockaddr_storage as sockaddr. + +Tue Apr 17 05:45:19 2007 Arnold D. Robbins + + * io.c (get_a_record): Make it static, to match declaration at the + top of the file. (Thank you GCC for not reporting this. Grr.) + +Fri Apr 13 00:29:24 2007 Arnold D. Robbins + + * replace.c: Only include missing/getaddrinfo.c if HAVE_SOCKETS + is defined. Avoids problems on VMS. Thanks to Pat Rankin. + +Tue Apr 10 18:53:04 2007 Arnold D. Robbins + + * awkgram.y, builtin.c, eval.c, ext.c, field.c, io.c, + node.c: Added some sanity to the lint warnings, to only + print them once if they are syntactic or of the type where + they don't need to be repeated. Switch to `short' instead + of `int', and in general use a variable named `warned', for + consistency. + +Sun Apr 8 16:49:28 2007 Arnold D. Robbins + + * awkgram.y: Add guard code to ifdef out "signed" for VMS. Thanks for + the heads-up to Pat Rankin. + * regcomp.c (utf8_sb_map, init_dfa): Move non-GCC code to initialize + this array into code, to preserve word-size independance. + * configure.ac: Add check for . + * io.c: Include if we have it, instead of keyed off + Tandem, needed on some Unix systems. + * awk.h, main.c, msg.c, awkgram.y: Move to use of CAN_USE_STDARG_H + instead of continuously repeating check for header and defined STDC + and STDC. Thanks to Pat Rankin. + +Fri Apr 6 15:28:09 2007 Arnold D. Robbins + + * builtin.c (do_length): Only print `length(array)' lint warning once. + * node.c (dump_wstr): Restore from being ifdef'ed out. Useful in case + it needs to be called from a debugger. + * regcomp.c (utf8_sb_map): Fix gcc-specific code. + * awk.h (snprintf): Add declaration in case not available on the system. + (Ceil, Floor): Add macros changing the name for VMS, in an attempt to + fix linkage problems. + * io.c: Simplify includes for internet headers and for getaddrinfo + defines. + +Wed Apr 4 23:38:24 2007 Arnold D. Robbins + + * io.c [AI_ADDRCONFIG]: Add a definition in case it's not available. + * main.c (usage): Add comment for translators to add translation + bug report address. + +Wed Apr 4 18:26:45 2007 Pat Rankin + + * regexec.c (build_trtrable): Add missing #if HAVE_ALLOCA. + +Thu Mar 29 19:30:20 2007 Pat Rankin + + * re.c (make_regexp): Cast casetable to RE_TRANSLATE_TYPE. + +Mon Mar 19 12:35:00 2007 Arnold D. Robbins + + Finish removing references to STRTOD_NOT_C89. + + * awk.h (gawk_strtod): Use now if there is no strtod. + * replace.c (strtod.c): Include if there is no strtod. + * configure.ac [GAWK_AC_FUNC_STRTOD_C89]: Removed. + +Mon Mar 19 12:17:16 2007 Kimura Koichi + + * dfa.c (dfaexec): Add check for half-width katakana characters in + character classes in ShiftJIS locale. + From mail originally sent Mon, 01 Aug 2005 09:07:55 +0900 + +Fri Mar 9 11:53:25 2007 Arnold D. Robbins + + * field.c (rebuild_record): Assert that wide string is off when + creating new fields. Inspired by Karel Zak. + +Fri Mar 9 11:26:01 2007 Matthew Woehlke + + * io.c (get_a_record): Limit the max amount read to SSIZE_MAX. Needed + on Tandem systems where this amount is incredibly small. + +Tue Mar 6 08:17:49 2007 Paul Eggert + + * node.c (is_ieee_magic_val): Don't rely on strncasecmp; it mishandles + ASCII bytes in some locales. + (get_ieee_magic_val): Use strtod if it works, relying on our handbuilt + code only if it doesn't work. This is more likely to do the right + thing with strings like "-nan". + +Tue Feb 27 20:51:29 2007 Arnold D. Robbins + + * configure.ac (AM_PROG_CC_STDC): Removed, per email suggestion + from Stepan Kasal some time ago. + +Tue Feb 27 20:44:07 2007 Aleksey Cheusov + + * awk.h: Revise checks for MEMCPY_ULONG and MEMSET_ULONG + for MS Interix using MSVC. + * configure.ac (AC_CHECK_FUNCS): Add checks for memcopy_ulong + and memset_ulong. + From mail dated Tue Aug 30 12:38:39 2005. + +Mon Feb 26 12:47:10 2007 Tony Leneis + + * dfa.c (dfacomp): Check that regexp is non-zero in length + also. Avoids problems with empty regex and IGNORECASE on + systems where `malloc(0)' returns a non-NULL pointer. + From mail dated Wed, 26 Oct 2005 15:42:07 -0700. + +Wed Feb 21 10:23:12 2007 Arnold D. Robbins + + * floatcomp.c (Floor, Ceil): Restore correct expression for Cray. + Then ifdef out the whole business, since it's likely to be obsolete. + Thanks to Paul Eggert. + +Mon Feb 19 12:28:47 2007 Arnold D. Robbins + + * node.c (format_val): Simplify code: always format the value + ourselves. Use %.0f if the value is integral. + * floatcomp.c (dval_out_of_range): Remove function, not needed. + (awknum_fraction_bits): Removed. + (adjust_uint): New function, defined IFF have uintmax_t. + * builtin.c (tmp_integer): Use adjust_uint. + Move include of and ... + * awk.h: to here. + (awknum_fraction_bits): Removed. + (adjust_uint): Declare, or define as do-nothing macro. + +Sun Feb 18 17:43:33 2007 Arnold D. Robbins + + * node.c, floatcomp.c: Add include of to get + correct declarations of math functions. + * configure.ac: If doing development, add -DYYDEBUG and also + -fno-builtin for GCC. + +Wed Feb 14 19:42:08 2007 Arnold D. Robbins + + Add support for special infinity and NaN values in non-POSIX + mode, and in POSIX mode, just call system `strtod'. + + * configure.ac [GAWK_AC_FUNC_STRTOD_C89]: Comment out. + * node.c (is_ieee_magic_val, get_ieee_magic_val): New functions. + (r_force_number): Adapt logic and use new functions. + +Tue Feb 13 13:02:32 2007 Arnold D. Robbins + + Move Paul's numeric stuff to a separate file to make code cleaner. + + * floatcomp.c (awknum_fraction_bits): New variable. + (Floor, Ceil): Functions, moved here from macros in builtin.c. + (dval_out_of_range): New function for checking if double is in range + of long. + (FLT_RADIX, FLT_MANT_DIG, DBL_MANT_DIG, AWKSMALL_MANT_DIG, + AWKNUM_MANT_DIG, AWKNUM_FRACTION_BITS): Moved here from awk.h. + * awk.h: Add decls of stuff now in floatcomp.c. + * Makefile.am[base_sources]: Add floatcomp.c. + * builtin.c (tmp_integer): Refer to `awknum_fraction_bits' + instead of AWKNUM_FRACTION_BITS. + * node.c (format_val): Call `dval_out_of_range' instead of + inline coding the test. + +2007-02-06 Paul Eggert + + * node.c (format_val): Fix bug when handling numbers close to + LONG_MIN and LONG_MAX. + * awk.h (FLT_RADIX, FLT_MANT_DIG, DBL_MANT_DIG, AWKSMALL_MANT_DIG, + AWKNUM_MANT_DIG, AWKNUM_FRACTION_BITS): Moved here from builtin.c. + * builtin.c: Move those macros to awk.h. + * awk.h (DBL_FRACTION_BITS): New macro. + +Fri Feb 9 13:40:10 2007 Matthew Woehlke + + More Tandem fixes. + + * configure.ac: Check in Tandem's zrldsrl library for dlopen. + * regex_internal.h: Move include into ifdef. + * regexec.c: Bracket alloca uses. Fix GCC use of `?:'. + +Fri Feb 9 13:30:15 2007 Arnold D. Robbins + + * replace.c: Add include of snprintf.c. Ooops! + * configure.ac: Add check for mkstemp and tmpfile for replacement + snprintf.c. + +Tue Feb 6 14:33:51 2007 Arnold D. Robbins + + * node.c (format_val): Restructure a bit to remove need for and + use of goto. + +Sun Feb 4 16:35:21 2007 Arnold D. Robbins + + * awkgram.y (field_spec, opt_incdec): New terminals. + (variable): Change definition of field reference to use field_spec. + See test/parse1.awk. + +Thu Feb 1 17:38:38 2007 Arnold D. Robbins + + * main.c: Allow YYDEBUG to enable the `-D' option, not just + GAWKDEBUG. + +Wed Jan 31 19:30:26 2007 Arnold D. Robbins + + * node.c (format_val): Restore my test for numeric values + being representable, as it includes more conditions than + Andrew's, pending a thorough review of undealt-with emails on + the topic. + * regexec.c (proceed_next_node): Move check for NULL to after + variable declarations inside initial `if'. + +Wed Jan 31 19:25:21 2007 Andrew J. Schorr + + * configure.ac (getaddrinfo): Improve test, since this function + can be in libsocket on some systems. + +Mon Jan 29 15:33:10 2007 Andrew J. Schorr + + * Makefile.am (valgrind): Also call new valgrind-scan target. + +Mon Jan 29 12:44:54 2007 Andreas Schwab + + * dfa.c (copytoks): Adjust index into multibyte csets when + copying an MBCSET token. + +Fri Jan 26 20:01:38 2007 Andrew J. Schorr + + * node.c (format_val): Test whether a numeric value is integral + simply by converting it to long and then back again, and checking + if the value matches. That's more robust than trying to test + whether the floating-point value is representable as a long. + * builtin.c (format_tree): Fix buffer overflow bug, off-by-one errors + in checking snprintf return codes, and use "%.0f" to implement "%d" + formatting. For octal or hex formatting, test whether the value + is integral by trying to convert back to floating point and seeing + if the value matches. This is more robust than trying to test + whether the floating-point value is representable as an integer. + +Tue Jan 23 17:49:28 2007 Arnold D. Robbins + + * io.c (socketopen): Initialize socketfd to avoid "may be used + uninitialized" warning. + * regexec.c (regexec, re_search_stub): Removed unused variable `dfa'. + * builtin.c (wide_tolower_toupper): Fix signedness of pointer in + allocation calls and in call to make_str_node. + +Mon Jan 22 12:57:19 2007 Kimura Koichi + + Deal with halfwidth katakana in SJIS locale inside character ranges. + Based on http://sources.redhat.com/bugzilla/show_bug.cgi?id=1149. + Changes affect non-__LIBC code only. + + * regcomp.c (re_compile_fastmap_iter): Handle half-size characters. + * regexec.c (check_node_accept_bytes): Same. + +Thu Jan 18 22:19:01 2007 Karel Zak + + * node.c (free_wstr): Assert that type is Node_val. + +Thu Jan 18 12:18:47 2007 Arnold D. Robbins + + * regcomp.c (re_compile_fastmap_iter): Declare `dfa' to be + be volatile. Fixes valgrind problem with the ignrcase test. + Sheesh. Gawk should now be valgrind-clean. We hope. + +Mon Jan 15 14:28:04 2007 Arnold D. Robbins + + Use getaddrinfo instead of gethostbyname, to handle IPV6 + format addresses. Based on patch submitted by + Jan Pazdziora . + + * configure.ac: Add getaddrinfo to list of checked functions. + * configh.in, configure: Regenerated. + * io.c: Rework includes based on HAVE_GETADDRINFO. + (socketopen): Reworked for getaddrinfo. + (devopen): Modified for new socketopen. + * replace.c: Include getaddrinfo.c if necessary. + +Sun Jan 14 12:19:53 2007 Arnold D. Robbins + + * awkgram.y: For bad name in array subscripting, build a + valid node anyway to avoid invalid reads reported by valgrind. + * dfa.c (parse_bracket_exp_mb): Remove assignment of NULL + to work_mbc->chars, was losing data malloc'ed earlier. Thanks + to valgrind. + (state_index): Alway initialize d->states[i].mbps elements to zero. + (dfafree): Free allocated d->states[i].mbps.elems if needed. + * regex.c: Try harder to undef alloca. + * regex_internal.h (__mempcpy): Undef before redefinining for + more recent versions of GLIBC. + +Sat Jan 13 22:10:43 2007 Arnold D. Robbins + + * node.c (str2wstr): For count of zero from mbrtowc, set count to 1 + and fall through to code that copies. Originally from Paul Eggert. + + Unrelated: + * configure.ac: Add call to AC_USE_SYSTEM_EXTENSIONS, should help + on Tandem. This lets us remove AC_AIX and AC_MINIX. + + From Matthew Woehlke for Tandem: + + * awk.h (_TANDEM_SOURCE): Also define _XOPEN_SOURCE_EXTENDED. + * io.c (_TANDEM_SOURCE): Include more headers. + +Sat Jan 13 21:53:48 2007 Ralf Wildenhues + + * field.c (set_FIELDWIDTHS): Avoid writing one past the end of + the array. + * node.c (r_force_number): Avoid reading uninitialized variable. + +Sat Jan 13 21:37:15 2007 Arnold D. Robbins + + * Makefile.am (valgrind): New target based on idea from + Ralf Wildenhues for running valgrind on test suite. + +Sat Jan 13 21:24:54 2007 Ralf Wildenhues + + Enable more `--lint-old' warnings. + * awkgram.y: Warning about multiple BEGIN or END rules, + `index in array' outside of for loops, multidimensional arrays. + * field.c (set_FS): Warn about regex FS. + * node.c (parse_escape): Warn about `\b', `\f', `\r'. + +Sat Jan 13 20:56:56 2007 Arnold D. Robbins + + * node.c (wcasestrstr): Revert use of continue, reinstate goto. + Thanks to Andrew Schorr. + (free_wstr): Move zeroing of wsptr and wslen and clearing of flag + back outside the if. + * field.c (rebuild_record): In loop that copies fields to new record, + add call to `free_wstr'. This ensures that flag values are correct + and avoids double free later. Thanks to Karel Zak for pointing out + the problem. + +Fri Jan 12 14:01:51 2007 Dmitry V. Levin + + * builtin.c (do_match): In addition to "gawk_mb_cur_max > 1" check, + check for positive string length. + +Fri Jan 12 13:57:20 2007 Arnold D. Robbins + + Sync with GLIBC. Bi-annual this time. + + * regexec.c, regex.h, regex_internal.c, regcomp.c: + Reapply any portability patches specific to gawk. + * regex_internal.h (build_wcs_upper_buffer): Fix return type + in declaration. Reapply any portability patches specific to gawk. + * regex.c: Add definitions for `bool', `true' and `false'. + Define `alloca' to something invalid to keep it from linking + in case a usage of `alloca' slipped through. Reapply any portability + patches specific to gawk. + + Base versions: + getopt1.c 1.10 Tue Mar 9 10:35:37 2004 + getopt.c 1.55 Fri Mar 24 10:59:56 2006 + getopt.h 1.21 Fri Mar 19 00:19:32 2004 + getopt_int.h 1.1 Tue Mar 9 10:31:19 2004 + regex.c 1.129 Fri Mar 24 10:59:57 2006 + regexec.c 1.97 Fri Mar 24 10:59:57 2006 + regex.h 1.40 Mon Sep 25 20:03:05 2006 + regex_internal.c 1.67 Mon Sep 25 20:03:05 2006 + regex_internal.h 1.73 Fri Mar 24 10:59:57 2006 + regcomp.c 1.112 Fri Mar 24 10:59:57 2006 + +Fri Jan 12 12:28:51 2007 Arnold D. Robbins + + * ABOUT-NLS, INSTALL, Makefile.in, aclocal.m4, config.guess, + config.rpath, config.sub, configh.in, configure, configure.ac, + depcomp, gettext.h, install-sh, missing, mkinstalldirs, ylwrap: + Updated to current autotools, Autoconf 2.61, Automake 1.10, + gettext 0.16.1. + +Thu Jan 4 18:23:50 2007 Dmitry V. Levin + + * node.c (free_wstr): Zero wstptr and wstlen only if WSTRCUR + flag is set. + (str2wstr): Replace invalid `free' call with `free_wstr' call. + +Thu Jan 4 16:49:21 2007 Arnold D. Robbins + + * builtin.c (do_match): Move freeing of wc_indices to outside if. + Thanks to Sven Wegener for the report. + +Thu Dec 21 14:32:13 2006 Arnold D. Robbins + + * main.c (arg_assign): Reassign the '=' only if not initing. + * profile.c (varname): Deleted. + (pp_concat): New function to print concatenations. + (tree_eval): Don't use `varname' anymore. Use `pp_concat'. + +Mon Dec 11 12:43:04 2006 Arnold D. Robbins + + * builtin.c (sub_common): Clear numeric flags on result + unconditionally. + * node.c (wcasestr): Replace `goto' with `continue'. + +Thu Nov 30 15:54:07 2006 Bruno Haible . + + * builtin.c: Change use of HAVE_LC_MESSAGES to defined(LC_MESSAGES). + Bruno suggested only for dcngettext, I did it everywhere (ADR). + +Wed Sep 6 02:04:32 2006 Andrew J. Schorr + + * awkgram.y (get_src_buf): Adjust `source' and `sourceline' to + correctly handle mixed -f and --source options. + +Mon Aug 28 21:17:20 2006 Arnold D. Robbins + + * AUTHORS, FUTURES, LIMITATIONS, NEWS, POSIX.STD, PROBLEMS, README: + Added FSF copyright for no other reason than to satisfy the flunkies + running Savannah. + * Makefile.am: Removed `ansi2knr' from AUTOMAKE_OPTIONS also. + +Fri Aug 11 15:07:45 2006 Arnold D. Robbins + + * field.c (set_field, rebuild_record, set_record): Remove calls to + `free_wstr' since they're not needed. + +Sat Aug 5 22:04:24 2006 Arnold D. Robbins + + * node.c (unref): Call `free_wstr' for fields also. Thanks to + Andrew Schorr. + +Tue Jul 4 22:43:05 2006 Arnold D. Robbins + + * eval.c (interpret): Node_assign_concat case: Turn off NUMBER and + NUMCUR flags in result. Sheesh. Thanks to + for finding the problem. + +Mon Jul 3 22:49:44 2006 Pat Rankin + + * main.c (load_environ): When AWKPATH is missing from ENVIRON[], + try to find it with getenv("AWKPATH") before resorting to DEFPATH. + Suggested by Galen Tackett. + +Mon Jul 3 00:27:59 2006 Arnold D. Robbins + + * io.c (INTERNAL_HANDLE): New constant for use by `iop_alloc' + when allocating an internal IOBUF. + (pidopen, useropen): Use it. + (iop_alloc): Add check for it and just return iop. + +Fri Jun 23 15:48:34 2006 Arnold D. Robbins + + * awkgram.y (subn): At end for `do_sprintf' check, verify + that lnode is not NULL before using it to assign through. + +Sun Jun 18 22:27:25 2006 Arnold D. Robbins + + Repair internal names like /dev/user, /dev/pid, as well as /dev/fd/N, + which have been broken for a long time but noone noticed. + + * io.c (is_internal): New macro to check for internal file like + `/dev/user'. + (spec_setup): Reduce to two parameters, allocate logic is always true. + Add IOP_NO_FREE to flag. + (pidopen, useropen): Return `IOBUF *' instead of int. Fix + logic to test if `iop' parameter is NULL and if so to allocate it. + (specfdopen,): Return `IOBUF *' instead of int. Fix + logic to test if `iop' parameter is NULL and if so to allocate it. + Don't set IOP_NO_FREE in flag. + (iop_open): Remove `IOBUF iob' field from `struct internal' and its use + and the use of `spec_setup' from the code here. Change the check in the + call to the open function to look for NULL. + (get_a_record): Use `is_internal' in initial check for filling the + buffer to not try to call `read' on internal files. If true, set + the IOP_AT_EOF in the flag and return EOF. + +Fri Mar 24 13:05:56 2006 Arnold D. Robbins + + * awkgram.y (get_src_buf): Remove function argument types from + declaration of `readfunc' to avoid bugaboos with VMS declaration + of `read' system call. + +Fri Mar 10 06:28:23 2006 Arnold D. Robbins + + * awk.h (free_wstr): New declaration if MBS_SUPPORT, empty macro + otherwise. + * node.c (free_wstr): New function, inside MBS_SUPPORT. Frees the wide + string part of a node. Provided so that it can be used consistently + everywhere. + (format_val, r_dupnode, mk_number, make_str_node, unref): Use it. + * builtin.c (sub_common): Call `free_wstr' instead of doing it manually. + * eval.c (r_tree_eval): Same in Node_assign_concat case. + * field.c (set_field, rebuild_record, set_record): Add calls to + `free_wstr'. + +Mon Feb 13 22:45:34 2006 Arnold D. Robbins + + * eval.c (r_tree_eval): Node_assign_concat. Release any + wide string value and reset the WSTRCUR flag. Based on + bug report by Karel Zak. + +2006-01-03 Paul Eggert + + * Makefile.am (awkgram.c): Use $(AWK), not awk, so that the rule + works on Solaris too (e.g., Solaris 10). Problem reported by + Andrew J. Schorr. + +Mon Dec 19 05:39:46 2005 Arnold D. Robbins + + * node.c (format_val): Account for overlow of conversion + from double to long. Shows up worse on 64-bit systems. + +Wed Dec 14 18:57:34 2005 Arnold D. Robbins + + * eval.c (set_BINMODE): Fix logic of test for no numeric value. + Makes `gawk -v BINMODE=1 ...' work again. Thanks to Eli Zaretskii + for pointing out the problem. + +Wed Oct 19 10:58:27 2005 Arnold D. Robbins + + * main.c (main, arg_init): Only use the locale's decimal + point if do_posix is set. Too many people the world over + have complained about this. + +Fri Oct 7 13:54:09 2005 Arnold D. Robbins + + Enhancement to fix from 23 Sept 2005, suggested by Pat Rankin. + + * awkgram.y (one_line_close): New function, closes open FILE * used + by `read_one_line'. + (fp): Static FILE * used by `read_one_line' and `one_line_close'. + * awkgram.y (read_one_line): Simplify check for call to `fdopen'. + (get_src_buf): New variable `closefunc' which is a pointer to a + function implementing the `close' system call interface. + +Fri Oct 7 13:23:29 2005 Arnold D. Robbins + + * field.c (set_FIELDWIDTHS): Fix off-by-one error in assignment + of sentinel value at end of FIELDWIDTHS array. + +Fri Sep 23 16:05:13 2005 Arnold D. Robbins + + * awkgram.y (read_one_line): New function, mainly for debugging, + that reads one line of data at a time to pass back as a buffer. + Emulates the variable-length record filesystem of VMS, where + we first saw the problem fixed here. + (get_src_buf): New variable `readfunc' which is a pointer to a + function implementing the `read' system call interface. Based on + an environment variable, use `read_one_line' instead of `read' + for testing. Make the test for expanding the buffer smarter, + so that it doesn't grow unnecessarily. + + Thanks to Galen Tackett (tackett_galen@bah.com) for reporting + the problem and to Anders Wallin and Pat Rankin for help + tracing and reproducing the problem and testing the fix. + +Fri Sep 9 15:06:07 2005 Arnold D. Robbins + + * hard-locale.h (xmalloc): Move declaration to file scope + for non-glibc systems and gcc 4. Thanks to Kito Danya Dietrich + . + +Thu Aug 25 22:40:40 2005 Arnold D. Robbins + + * regcomp.c (build_range_exp): Avoid `btowc' for single-byte + characters. Fedora Core 2, maybe others, have a broken version + that can't handle values > 127. + +Fri Aug 19 16:13:28 2005 Arnold D. Robbins + + * regexec.c (proceed_next_node): Added a band-aid check at the + top of the first `if' to make sure that `mctx->state_log[*pidx]' + isn't NULL. + +Fri Aug 12 13:10:33 2005 Arnold D. Robbins + + * io.c (iop_alloc): Only free `iop' if it was malloc'ed in + the first place. + +Tue Jul 26 21:46:16 2005 Arnold D. Robbins + + * Release 3.1.5: Release tar file made. + +Tue Jul 26 21:44:54 2005 Arnold D. Robbins + + Copyright dates on all relevant files updated to 2005. + +Wed Jul 6 17:09:02 2005 Arnold D. Robbins + + Minor cleanups: + + * io.c (do_index): Remove unused variables `mbclen', `mbs1' and `mbs2'. + * node.c (wstrstr): Remove unsed variable `j'. + (dump_wstr): `#ifdef' out, not currently needed. + * eval.c (op_assign): Move decl of `t1' and `t2' into a separate block + for the `! HAVE_FMOD' case. Keeps the compiler quiet. Similar for + `ltemp'. + +Wed Jul 6 16:51:31 2005 Arnold D. Robbins + + * io.c (close_io): Now takes pointer to boolean parameter indicating + if there was a problem closing standard output or standard error. + Update it in the right places. + * awk.h (close_io): Update the declaration. + * main.c (main): New variable `stdio_problem'. Pass it to `close_io'. + Check the result and exit non-zero if there was a problem. + (usage, version): Print warning message if problems with stdout. + + Unrelated: + + * main.c (main): For call to `setlocale' for LC_MESSAGES, just use + `#ifdef LC_MESSAGES'. Per Bruno Haible . + +Wed Jul 6 16:44:58 2005 Jim Meyering + + * main.c (init_fds): If any of the STDIN_FILENO, STDOUT_FILENO, + STDERR_FILENO are initially closed, reopen them with permissions + contrary to common usage so that any reasonable attempt to use + them will evoke the same sort of error as reading or writing to + a closed file descriptor would. + +Mon Jul 4 09:38:29 2005 Arnold D. Robbins + + More multibyte fixes from Kimura Koichi, . + + * node.c (format_val, r_dupnode): Spell `wstptr' correctly. + * regex_internal.c (build_wcs_upper_buffer): Label `offsets_needed' + should not be inside `#ifdef _LIBC'. + * regcomp.c (build_charclass): Fix declaration of `class_name' in + prototype to not be unsigned. + +Thu Jun 30 11:52:34 2005 Arnold D. Robbins + + * profile.c (tree_eval): Node_not: Remember to print the exclamation + point! Thanks to Dan Nielsen + for the bug report. + * mbsupport.h: Fix spelling of HAVE_ISWUPPER. Thanks to + Kimura Koichi, . + +Sun Jun 26 16:37:59 2005 Arnold D. Robbins + + Unrelated changes: + + * builtin.c (do_length): Allow array argument to length(). + Returns number of elements in array. + + * awkgram.y (yylex): Ignore carriage returns in source code. Sigh. + +Wed Jun 15 22:12:15 2005 Arnold D. Robbins + + * node.c (isnondecimal): Check loc.decimal_point before using it. + Avoids problems with command line assignment when locale info may + not be set up all the way yet. + +Wed Jun 15 21:59:54 2005 Arnold D. Robbins + + * node.c (make_str_node): If working with multibyte characters, while + parsing string constants, keep multibyte characters together. This + avoids problems in cases where one of the bytes is backslash. Initial + patch supplied by Kimura Koichi, . + +Tue Jun 14 21:50:37 2005 Andrew J. Schorr + + Use Exponentiation By Squaring for integer powers for ^ and ^=. + + * eval.c (calc_exp, cal_exp_posint): New functions. + (r_tree_eval): Use them. + +Fri Jun 3 12:15:54 2005 Arnold D. Robbins + + * configure.ac: Further change the hack at the end so that + it works on Mac OS X `sed'. Sigh. + +Thu Jun 2 22:44:01 2005 Arnold D. Robbins + + * configure.ac (TYPE_SOCKLEN_T): Use `int' as default type if can't + figure one out. + * awkgram.y: Warn that `//' is not a C++ comment. (:-) + +Thu Jun 2 20:55:27 2005 Arnold D. Robbins + + From: Benno Schulenberg + + * eval.c (func_call): Take message out of gettext call since it's for + debugging. + * ext.c (get_actual_argument): Fix formatting of message. + +Wed May 25 09:19:37 2005 Arnold D. Robbins + + * configure.ac: Change hack at end that fixes Makefile to keep + version.c to use `sed' and not `ed'. More portable to OS/2, probably + other systems. + +Mon May 23 09:01:26 2005 Arnold D. Robbins + + Portability help from Jim Meyering. + + * io.c: Rework ifdefs for and . Test them + individually. + * configure.ac: Add AC_C_RESTRICT and code for socklen_t from rsync. + Check for isascii and btowc for regex. + +Sat May 14 22:49:54 2005 Arnold D. Robbins + + * wait_any (errno): Remove decl. + * gawk_popen: The pipe-simulated but not VMS or DOS version. Remove + decl/use of `strdup' in favor of `emalloc' and `strcpy'. + +Wed May 11 18:33:30 2005 Arnold D. Robbins + + All files: Updated address of FSF to: + + 51 Franklin Street, Fifth Floor + Cambridge, MA 02110-1301 + +Wed May 11 18:19:03 2005 Jim Meyering + + * configure.ac: Use AM_GNU_GETTEXT([external]). + Reflect upgrade to gettext-0.14.4. + Reflect renaming of `jm_'-prefixed macros. + (AC_CONFIG_FILES): Remove intl/Makefile. + + * Makefile.am (SUBDIRS): Remove intl. + (AM_CPPFLAGS): Remove -Iintl. + +Wed May 11 11:42:06 2005 Arnold D. Robbins + + Straighten out mess with `isblank' which is C99 function. + + * configure.ac: Remove check for `isblank' in call to AC_CHECK_FUNCS. + * regex_internal.h: #ifdef out definition of `isblank' and provide + `is_blank' function a la dfa.c. + * field.c: Ditto. + * regcomp.c: #ifdef use of `isblank' and add `is_blank' use instead. + +Mon May 9 08:29:37 2005 Arnold D. Robbins + + * configure.ac: Add type check for `socklen_t', fixes compile + warning on AMD/64 Linux. + * io.c (socketopen): Change type of socket length variables + to `socklen_t' from `size_t'. + +Thu May 5 22:00:03 2005 John E. Haque + + * io.c (iop_alloc): Let an input processor hook installed via + `register_open_hooks' open its own fd in case gawk does not know + how to open it. + (iop_open): Call `os_close_on_exec' after `iop_alloc'. + ADR: If `iop_alloc' returns NULL but the fd is valid, close + the fd to avoid an fd leak. + +Mon May 2 08:05:59 2005 Arnold D. Robbins + + * eval.c (update_ERRNO): Don't use `return' in a `void' function. + * awk.h (AWKNUM): Back out use of `long double' based on LDBL_MANT_DIG. + * builtin.c (tmp_integer): Back out extra ifdefs. + +Fri Apr 29 13:01:05 2005 Arnold D. Robbins + + * configure.ac: Look for `isblank' function. + * field.c: Add define for `isblank' if we don't have it. + +Fri Apr 29 12:01:33 2005 Julian Foad + + From grep. Doesn't seem to affect awk. + + * dfa.c (lex): Fix bug #9519: "echo do^re | grep do^re" was + failing to find a match. [Towards end, set `lasttok' before + returning `c'.] + +Fri Apr 29 00:28:46 2005 Arnold D. Robbins + + * configure.ac: Jump through an amazingly convoluted hoop to get + config.status to keep version.c upon `make distclean'. Seems to + work though. + +Thu Apr 28 23:40:02 2005 Stepan Kasal + + * configure.ac (PRINTF_HAS_F_FORMAT): Some cosmetic changes. + (custom.h): Don't cat custom.h at the end of config.h; instead, use + AH_BOTTOM([#include "custom.h"]) + * awklib/Makefile.am (AM_CPPFLAGS): Add $(top_srcdir) so that + custom.h can be found. + +Thu Apr 28 23:21:22 2005 Jim Meyering + + * field.c (set_FIELDWIDTHS): Tighten up the code to accept FIELDWIDTHS + values in [1..INT_MAX], e.g., detect overflow and invalid strings, + and reject strings starting with `-'. + +Thu Apr 28 23:05:33 2005 Stepan Kasal + + * dfa.c (parse_bracket_exp_mb): Shorten one part of the code, to get + closer to grep's copy. + +Thu Apr 28 23:00:58 2005 Pat Rankin + + * builtin.c (format_tree) [#if VAXCRTL]: For floating point + formatting, reject zero_flag if using old VAXCRTL run-time + library to avoid getting erroneous results which appear as if + numerically incorrect (due to an embedded space in some cases, + extra trailing zeroes in others) rather than just misformatted. + `hsprint' test still fails, but not as badly. + +Thu Apr 28 19:12:03 2005 Arnold D. Robbins + + * re.c (reflags2str): Add three new RE_ flags from current regex.h + to bring the table up to date. + + * builtin.c (format_tree): Save 2 spare bytes instead of one. Suggested + by Stepan Kasal. + +Thu Apr 28 18:16:09 2005 Andrew J. Schorr + + * awk.h (IOBUF): Add new fields `opaque', `get_record', and + *close_func', to support insertion of an alternate input processor. + This is used by the XML extension. + (register_deferred_variable, register_open_hook, update_ERRNO_saved): + Declare new functions. + (load_environ, load_procinfo): Remove declarations -- these functions + are no longer global, since we use register_deferred_variable instead. + * awkgram.y (register_deferred_variable): New function to allow + calling code to register special variable names that trigger a callback + upon the first reference. This is now used to implement ENVIRON + and PROCINFO. + (variable): Search the list of deferred variables instead of hardcoded + tests for ENVIRON and PROCINFO. + * eval.c (set_BINMODE): Fix spelling of "arbitrary" in warning message. + (update_ERRNO_saved): New function that allows the caller to specify + the errno value instead of using the current value. + (update_ERRNO): Implement by calling update_ERRNO_saved(errno). + * io.c (iop_close): Call `iop->close_func' if non-NULL. + (close_redir): Should save `errno' value, otherwise `lintwarn' messages + might update it. Then use `update_ERRNO_saved' to set ERRNO. + (do_getline): Call `update_ERRNO_saved' to set ERRNO based on the + error code returned by the redirect function (instead of the current + value of errno). Similarly, use `update_ERRNO_saved' to set ERRNO + based on the value returned by `get_a_record'. But add a special + check to avoid updating ERRNO if `get_a_record' returns an error + code value of -1 (this is used by the XML extension which already + sets ERRNO before returning). + (register_open_hook): New function to register a function to be + called whenever a new data file is opened. This can be used to + install a special input processor (as in the XML extension). + (iop_alloc): Call registered open hook. + (get_a_record): If a `get_record' method has been set, call that instead. + * main.c (init_vars): Use `register_deferred_variable' to implement + ENVIRON and PROCINFO. + (load_environ, load_procinfo): Now static instead of global. + * doc/gawk.texi: Document new internal functions `update_ERRNO_saved', + `register_deferred_variable', and `register_open_hook'. + +Thu Apr 28 10:50:10 2005 Arnold D. Robbins + + * array.c (assoc_find, do_delete): Change incorrect uses of STREQN + to memcmp. + * builtin.c (do_index): Same. + * field.c (set_FS): Same. + * io.c (redirect, getredirect, do_close, set_RS): Same. + * re.c (reisstring): Same. + +Wed Apr 27 21:35:57 2005 Arnold D. Robbins + + Allow for long double. Initial changes from Jean-Marc Saffroy + . + + * awk.h (AWKNUM): If have long doubles (LDBL_MANT_DIG), define AWKNUM + as long double, otherwise just use double. + * builtin.c (format_tree): Change type of tmpval to double. + (do_strtonum): Same for `d' and types used in casts. + (tmp_integer): Don't do bit shifting if have long doubles. + + Unrelated, from Andrew J. Schorr: + + * io.c (close_one): Check for RED_FILE|RED_WRITE, not just RED_FILE. + +Mon Apr 25 12:23:18 2005 Andrew J. Schorr + + * eval.c (r_tree_eval): In Node_assign_concat case, when copying string + constants, include the terminating zero byte. + +Fri Apr 1 06:26:31 2005 Arnold D. Robbins + + Update to Automake 1.9.5. + + * INSTALL, aclocal.m4, depcomp, install-sh, missing, + mkinstalldirs, ylwrap: Updated. + + Unrelated: + + * builtin.c (do_tolower, do_toupper): Remove old code + based on 8-bit character table. + +Wed Feb 23 08:23:22 2005 Arnold D. Robbins + + * bisonfix.awk: New file, fixes continued #ifdef for dumb compilers. + * Makefile.am (awkgram.c): Fix rule to use it. + (EXTRA_DIST): Include bisonfix.awk. + +Tue Feb 22 21:18:50 2005 Arnold D. Robbins + + * random.h: Remove include of config.h and move it to ... + * random.c: Here. Move include of random.h back to where it was. + + * regcomp.c, regex.c, regexec.c: NUKED all use of alloca not inside + `_LIBC' ifdef. Hooray! + +Sat Feb 19 20:13:28 2005 Pat Rankin + + Workarounds for bugs and missing C89 features in old VAX C compiler. + + * regex_internal.h "mbsupport.h": Suppress inclusion if NO_MBSUPPORT + is defined. + [MB_CUR_MAX]: Define as 1 if mbsupport.h hasn't defined it. + [ER_ERRMSG, ERRMSG_TYPE, ERRMSG_OFFSET, ERRMSG_SEPARATOR]: New macros + conditionalized upon gawk's NO_TOKEN_PASTING macro. + * regcomp.c: Use them. + (parse_dup_op): Use alternate initialization of start_token if + RE_TOKEN_INIT_BUG is defined. + * regexec.c (proceed_next_node): Compare push_fail_stack() result + explicitly against REG_NOERROR rather than implicitly against 0. + +Sat Feb 19 20:05:50 2005 Pat Rankin + + * dfa.c "mbsupport.h": Suppress inclusion if NO_MBSUPPORT is defined. + +Wed Feb 16 20:43:07 2005 Pat Rankin + + * awk.h "mbsupport.h": Suppress inclusion if NO_MBSUPPORT is defined. + * regex.h : Guard inclusion with HAVE_SYS_TYPES_H. + * regex.c : Likewise. + * random.c "random.h": Include this first to get config.h setup. + : Guard inclusion with HAVE_FCNTL_H. + : Guard inclusion with HAVE_UNISTD_H. + * io.c [#if defined(MSDOS) ||... defined(__CYGWIN__)]: Splice the + backslash continuation back into one long line. + +Wed Feb 16 10:11:21 2005 Arnold D. Robbins + + * node.c (unref, format_val): Add assertions checking that both + `tmp->wstptr != NULL' and `(tmp->flags & WSTRCUR) != 0' before + freeing `tmp->wstptr'. Thanks to kimura.koichi@canon.co.jp. + + * random.c (HAVE_UNISTD_H): Conditionalize include of . + Thanks to Scott Deifik . + +Sun Feb 13 18:24:50 2005 Arnold D. Robbins + + * io.c (socketopen): Move `#ifdef MSG_PEEK' up to above + declarations too. Thanks to Michal Jaegermann. + + * config.guess, config.sub: Updated from Savannah. + +Thu Feb 10 15:48:48 2005 Arnold D. Robbins + + * regex_internal.c (re_dfa_add_node): Remove variable `type' + and just use `token.type' directly in RE_ENABLE_I18N code below. + Saves a compiler warning, and a good compiler will handle it anyway. + * regexec.c (check_arrival_add_next_nodes): Move decl of `err' + inside #ifdef RE_ENABLE_I18N code where it's used. + * awkgram.y (yylex): Add casts to int before use of `strlen' results + for printf-style precision. Avoid a compiler warning. + * io.c (redirect, do_close): Same for use of tmp->stlen. + + Thanks to Michal Jaegermann . + +Wed Feb 9 10:19:15 2005 Stepan Kasal + + * Makefile.am (datadir, libexecdir): Removed. + (awkdatadir): Renamed to pkgdatadir. + (pkgdatadir, LDADD): Use the make syntax to refer to other variables, + not @...@. + +Wed Feb 9 10:05:46 2005 Arnold D. Robbins + + * node.c (r_dupnode): Assign NULL to r->wstr after `getnode'. + Fix count of bytes to copy in call to `memcpy'. + Thanks to Kimura Koichi, . + +Tue Feb 8 19:26:22 2005 Pat Rankin + + * regcomp.c (init_dfa): Avoid strcasecmp() since regex.c doesn't + use awk.h and none of the assorted other included header files + are guaranteed to declare it. + (parse_expression): Modify casts for the string arguments passed to + build_charclass_op() to fix char * vs unsigned char * mismatch. + (parse_bracket_exp): Likewise add cast for the string argument + passed to build_charclass(). + +Mon Feb 7 15:04:09 2005 Arnold D. Robbins + + * eval.c (make_scalar): Don't use P() macro in definition. + Thanks to Juergen Kahrs . + +Wed Feb 2 16:36:19 2005 Arnold D. Robbins + + * main.c (main): Call `close_io', without its result affecting + the exit status. Super small, super dark corner. + + See test/exitval2.awk. + +Tue Feb 1 11:58:29 2005 Arnold D. Robbins + + * regex.h (__APPLE_CC__): Removed test and definition of __restrict. + Not needed for current MacOS X compiler. + +Sun Jan 30 13:56:37 2005 Arnold D. Robbins + + Fresh merge with CVS regex routines. Fixes handling of \B. + See tests/gnureop3.awk and also + http://sources.redhat.com/bugzilla/show_bug.cgi?id=693. + + CVS base versions: + + * regcomp.c: Version 1.92, Thu Jan 27 19:05:20 2005. + * regexec.c: Version 1.77, Thu Jan 27 19:06:34 2005. + * regex_internal.c: Version 1.49, Thu Jan 27 19:07:15 2005. + * regex_internal.h: Version 1.60, Wed Jan 26 22:40:50 2005. + * regexec.c: Version 1.77, Thu Jan 27 19:06:34 2005. + +Sat Jan 22 22:30:40 2005 Arnold D. Robbins + + Reinstate patch of 18 Nov 2001, for VMS, at least: + + * random.c (srandomdev): ifdef-out. Lots of compile time + problems on multiple platforms, and gawk doesn't even + use the routine. The heck with fine-grained solutions. + +Thu Jan 20 14:15:32 2005 Arnold D. Robbins + + * awkgram.y (LEX_FOR): Free NAME tokens in transformation of + `for (iggy in foo) delete foo[iggy]' into `delete foo'. + Thanks and a tip of the hatlo to Valgrind. + + * dfa.c (_): Clean up stuff here by just including "gettext.h". + Per Bruno Haible. + +Wed Jan 19 18:29:23 2005 Arnold D. Robbins + + * awkgram.y (yylex): Improve parsing of numeric constants + and hex values, via a push from Paul Eggert. See test/hex.awk. + + * regex_internal.c (re_node_set_alloc): If `size' is 0, just + zero out the structure. From valgrind. + +Tue Jan 18 17:23:25 2005 Arnold D. Robbins + + Make gawk multibyte aware. This means that index(), length(), + substr() and match() all work in terms of characters, not bytes. + + * awk.h (NODE): Add `wsp' and `wslen' elements to value for wide + string. + (WSTRCUR, wstptr, wstlen, force_wstring): New macros. + (str2wstr, wstrstr, wcasestrstr): New declarations. + * builtin.c (do_index, do_length, do_substr, do_match): Handle wide + strings. + * eval.c (flags2str): Add WSTRCUR. + * node.c (format_val, r_dupnode, mk_number, make_str_node, unref): + Add code to deal with wide strings. + (str2wstr, dump_wstr, wstrstr, wcasestrstr): New functions. + +Sun Jan 16 15:10:35 2005 Arnold D. Robbins + + * random.h (int32_t): Define this type. + +Thu Jan 13 14:38:13 2005 Arnold D. Robbins + + Cause `configure --disable-nls' to still allow locale-correct + formating of numeric values. + + * builtin.c (format_tree): Change #ifdefs to only test HAVE_LOCALE_H. + Improve code for ' flag so that extraneous separator is not included if + number of digits is multiple of locale separater count (3, 6, 9, etc.) + * dfa.c (dfaparse): Change ifdef to only test #ifdef LC_COLLATE. + * eval.c (fmt_ok): Remove ENABLE_NLS from #ifdef test. + * gettext.h: Include on both sides of test. Should really + be factored out. + * main.c (loc): Remove ENABLE_NLS from #ifdef test. + (main): Same in call to localeconv(). + * node.c (isnondecimal): Remove ENABLE_NLS from #ifdef test. + + Unrelated: + + * regcomp.c (init_dfa): Change `codeset' to `codeset_name' in two + places. + +Mon Jan 10 11:49:56 2005 Arnold D. Robbins + + Annual sync with glibc. + + * getopt_int.h: New file. + * Makefile.am (base_sources): Add it. + * getopt.h, getopt.c, getopt1.c: Updated. + * regcomp.c, regex.c, regex.h, regex_internal.c, regex_internal.h, + regexec.c: Updated. + + Original versions: + + getopt_int.h, 1.1, Tue Mar 9 10:31:19 2004 + getopt1.c, 1.10, Tue Mar 9 10:35:37 2004 + getopt.h, 1.21, Fri Mar 19 00:19:32 2004 + getopt.c, 1.53, Wed Mar 10 23:13:26 2004 + regcomp.c, 1.87, Mon Dec 6 02:56:42 2004 + regex.c, 1.126, Fri Jan 30 05:19:58 2004 + regex.h, 1.33, Thu Nov 18 23:50:57 2004 + regex_internal.c, 1.46, Thu Jan 6 20:59:49 2005 + regex_internal.h, 1.57, Mon Dec 27 16:29:05 2004 + regexec.c, 1.75, Mon Dec 27 16:29:52 2004 + + * regex.h: Add check for __APPLE_CC__ and definition of __restrict. + * regex.c: Add check for _MSC_VER and include . + * regex_internal.h (_RE_ENABLE_I18N): Change test. + (re_realloc): Add check/fix for SunOS 4.1.x. + * regex_internal.c (build_wcs_upper_buffer): ifdef label + `offsets_needed', add cast in call to `wcrtomb'. + * regcomp.c (build_charclass, build_charclass_op): Remove `unsigned' + from declarations of `char *' params. + (regerror): Remove use of mempcpy. + (peek_token): Disallow \s and \S for gawk. + (build_charclass): Change decl of `class_name' and use it directly. + Nuke variable `name'. + (build_charclass_op): Change decl of `class_name' and `extra'. + +Thu Jan 6 16:44:32 2005 Arnold D. Robbins + + Improve autoconfiscation stuff for wide character use. + + * builtin.c (do_tolower, do_toupper): Conditionally compile + call to `wide_tolower_toupper'. + (wide_tolower_toupper): Conditionally compile typedefs and function. + * mbsupport.h: Add check for having `wint_t', and `iswlower', + `iswupper', `towlower' and `towupper'. + * configure.ac (HAVE_WINT_T): Add test. + (AC_CHECK_FUNCS): Add `wint_t', `iswlower', `iswupper', `towlower' + and `towupper'. + + Unrelated change: + + * hard-locale.h (hard_locale): Add decl of `xmalloc' to prevent + redeclaration problems on some compilers. + +Wed Jan 5 10:20:17 2005 Arnold D. Robbins + + Update to Bison 2.0. + + * bisonfix.sed: Removed, no longer needed. + * Makefile.am (EXTRA_DIST): Removed bisonfix.sed. + (awkgram.c): Fix build rule. + * awkgram.c: Regenerated. + +Tue Jan 4 18:47:56 2005 Arnold D. Robbins + + Update to Automake 1.9.4. + + * alocal.m4, config.guess, config.sub, install-sh: Updated. + +Mon Jan 3 14:08:27 2005 Arnold D. Robbins + + Update to Automake 1.9.3. + + * INSTALL, alocal.m4, config.guess, config.sub, depcomp, + install-sh, missing, ylwrap: Updated. + +Mon Jan 3 11:23:36 2005 Arnold D. Robbins + + Fix obscure issue. ^ in RS should only match at the very + beginning of the input. Essentially, the file is one long + string. To do this, use the `not_bol' flag in the `struct + pattern_buffer'. Thanks to Stepan Kasal for pointing out the + problem and to Andreas Schwab for pointing out the mechanism + for a solution. + + * awk.h (RE_NEED_START, RE_NO_BOL): New flags for `research'. + (IOP_AT_START): New flag for IOBUF. + (research): Last parameter is now `flags'. + * builtin.c (do_match, sub_common): Change calls to `research'. + * eval.c (interpret, match_op): Same. + * field.c (re_parse_field): Same. + * io.c (spec_setup): Add IOP_AT_START flag. + (iop_alloc): Same. + (rsrescan): Modify logic to check IOP_AT_START and if not on to + add RE_NO_BOL to flags value in call to `research'. + (get_a_record): Clear IOP_AT_START upon return from `*matchrec'. + (iopflags2str): Add IOP_AT_START to table. Also IOP_CLOSED, + which was missing. (Ooops.) + * re.c (research): Last paramater is now flags. Modify logic to + handle RE_NO_BOL case by setting the right bit initially. Clean + up control flow so that it's cleared before returning. If RE_NO_BOL, + don't bother with the dfa matcher, as it doesn't have an analogous + capability. + +Wed Dec 22 12:33:48 2004 Arnold D. Robbins + + For --exec, don't allow x=y assignments where filenames would be. + Do allow -v. This is because we assume --exec is used mainly for + CGI stuff and we don't want var assigns to affect the code. + + Suggested by Stepan Kasal; motivated by reading about web security. + + * main.c (disallow_var_assigns): New variable. + (main): Set the var for --exec. + (arg_assign): Check it appropriately. + +Sun Dec 19 17:27:09 2004 Arnold D. Robbins + + * builtin.c (do_gensub): Make `global' flag smarter, such that + a string numeric constant (e.g., "3") acts like a numeric + constant. + * node.c (r_force_number): Not really related: Only set NUMCUR + if we actually convert some digits. + +Sun Dec 19 16:08:50 2004 Arnold D. Robbins + + * dfa.h, dfa.c: Synchronize with what's happening in GNU grep + development. Effectively only minor whitespace changes and some + slight code motion of ifdefs and includes. + * hard-locale.h: New file, extracted from old dfa.c. + * Makefile.am (base_sources): Add hard-locale.h. + +Sun Dec 19 11:13:45 2004 Arnold D. Robbins + + * io.c (socketopen): Change type of `readle' and `namelen' + variables to size_t. For QNX, but a good idea anyway. Thanks + to `Anthony' (rz1a@mail.ru). + +Mon Dec 6 11:11:22 2004 Arnold D. Robbins + + Undid change of Mar 9 2004, to add gofast patch. It gets things + wrong for gawk. This removes the bandaid of ifdef-ing out the + main check. Eventually this'll all get straightened out in the + GNU grep code. + + * dfa.c (buf_offset): Removed. + (SKIP_REMAINS_MB_IF_INITIAL_STATE): Removed use of buf_offset, do + free `mblen_buf', `inputwcs'. + (match_anychar, match_mb_charset, transit_state_consume_1char, + transit_state): Remove use of buf_offset in mblen_buf. + (dfaexec): Use `free' and `malloc', not `realloc'. + +Mon Dec 6 10:55:37 2004 Fumitoshi UKAI + + Forwarded from james@nocrew.org, the Debian contact. + + * dfa.c (parse_bracket_exp_mb): + 1. Build range correctly when IGNORECASE for [a-a] to also get 'A'. + 2. For [:lower:] and [:upper:], if ignoring case, set type string + to "alpha". This parallels code in the regex routines. + 3. Reset wc1 to EOF when parsing bracket expressions. + +Mon Nov 29 18:36:25 2004 Arnold D. Robbins + + * io.c (redirect): When allocating a new struct redirect, set + rp->pid to -1, not 0, so that code checking for EOF on an + input pipe works correctly. + +Thu Nov 25 14:22:41 2004 Stepan Kasal + + * Makefile.am (MAINTAINERCLEANFILES): Add. + * version.in (version_string): Use PACKAGE_STRING. + +Tue Nov 23 17:27:38 2004 Stepan Kasal + + * re.c: Fix a typo in a comment. + +Mon Nov 22 16:47:00 2004 Arnold D. Robbins + + * awkgram.y (yylex): Add lint check for tawk style modifiers on + regexes, /.../i and /.../s. Not that it'll help anyone. + +Wed Oct 27 14:25:18 2004 Stepan Kasal + + * builtin.c (do_tolower, do_toupper): Fix the wide char handling, + especially when the lowercased char doesn't ocuppy the same + number of bytes as its uppercase equivalent. Make use of ... + (wide_tolower_toupper): ... this new static function. + +Mon Oct 25 11:51:14 2004 Arnold D. Robbins + + * builtin.c (bchunk, bchunk_one, cksize): Change type of `olen' + to size_t from long. It is the 21st century now, after all... + Thanks to Stepan Kasal. + +Mon Oct 11 10:49:09 2004 Arnold D. Robbins + + * awkgram.y (yylex): Improve lint warnings for non-decimal constants. + * node.c (isnondecimal): Made a little smarter, thanks to Stepan Kasal. + +Thu Oct 7 21:59:38 2004 Arnold D. Robbins + + * dfa.c (dfamust): Redo fix of 22 Sep to match code from + current GNU grep. + +Sun Oct 3 23:06:00 2004 Arnold D. Robbins + + * node.c (isnondecimal): Made smarter, so that 0xEE does + register as non-decimal. Added parameter to indicate use of + locale's decimal point and changed declaration and callers. + +Tue Sep 28 18:38:17 2004 Arnold D. Robbins + + * node.c (isnondecimal): New function, now smarter. + * awk.h (isnondecimal): Changed from macro to function. + +Wed Sep 22 11:24:46 2004 Arnold D. Robbins + + * dfa.c (dfamust): At end, check results of `malloc'. + Based on bug report from Sorav Bansal + for grep. + +Mon Sep 20 13:18:18 2004 Arnold D. Robbins + + New --exec option. Needed for gawk CGI scripts to prevent + arbitrary options and/or source getting passed in from the web. + + * main.c (optab): New long option, --exec. + (main): Catch it. Like -f but end option processing. + (usage): Add it to the usage message. + + Thanks to John DuBois and Don Stokes for their input. + + Unrelated: + + * dfa.c (dfaexec): Disabled caching into buffer that bypasses + multibyte initialization, since it can get things wrong. Thanks + to Andreas Schwab . + +Mon Sep 20 12:59:42 2004 Andreas Schwab + + * awkgram.y (nextc): Check for end of lexer buffer before + advancing ring buffer index. + +Wed Sep 8 09:54:53 2004 Arnold D. Robbins + + * main.c (main): Force LC_NUMERIC locale to "C" before parsing + the program, since a variable assignment with -v can leave the + locale set incorrectly. + + Thanks to Sirix for reporting the problem. + +Wed Aug 25 18:55:30 2004 Arnold D. Robbins + + * main.c (UPDATE_YEAR): New constant at top of file, where we + won't miss it. + (copyleft): Use it. + +Sun Aug 22 17:26:39 2004 Stepan Kasal + + Define gawk_mb_cur_max even if there is no mbs support, as + ``const int'' and assign 1 to it. + This fixes a bug in re.c where #ifdef MBS_SUPPORT was missing. + + * awk.h (gawk_mb_cur_max): Declare. + * main.c (gawk_mb_cur_max): Define. + * awkgram.y (nextc_is_1stbyte): Without mbs support, define to 1. + * builtin.c (index_multibyte_buffer): Define a dummy function + when there is no mbs support. + * awkgram.y, builtin.c, re.c: Remove some `#ifdef MBS_SUPPORT'. + +Sun Aug 15 22:08:04 2004 Arnold D. Robbins + + Import current FreeBSD random.c. Make it work for gawk. + Needed for cases where long is more than 32 bits. + + * random.c: Imported from FreeBSD. Header includes tweaked. + * random.h: Typdef gawk_uint32_t appropriately and #define uint32_t + to it. + * configure.ac: Add calls to AC_CHECK_SIZEOF for unsigned int + and unsigned long. + + Started with + http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/stdlib/random.c + Thanks to Andreas Schwab for the pointer. + +Thu Aug 12 13:09:53 2004 Arnold D. Robbins + + * main.c (copyleft): Fix copyright year. + +Mon Aug 2 12:18:15 2004 Arnold D. Robbins + + * Release 3.1.4: Release tar file made. + +Mon Aug 2 12:17:40 2004 Arnold D. Robbins + + * configure.ac: Fix the hack. Do the sed on `Makefile', + not `Makefile.in'. Sigh. + +Sun Aug 1 14:48:30 2004 Arnold D. Robbins + + * configure.ac: MAJOR HACK: At end, remove version.c from Makefile.in + variable `CONFIG_CLEAN_FILES' so that `make distclean' doesn't + remove version.c. + +Mon Jul 19 17:07:27 2004 Arnold D. Robbins + + * config.guess, config.sub: Updated from Savannah CVS. + +Fri Jul 16 10:59:07 2004 Arnold D. Robbins + + * re.c (make_regexp): Bracket code using `gawk_mb_cur_max' + inside `#ifdef MBS_SUPPORT'. + +Thu Jul 15 12:36:25 2004 Arnold D. Robbins + + * dfa.c (parse_bracket_exp_mb): If doing case folding, + include the other case for regular characters inside [...]. + + * re.c (make_regexp): Smarten up handling of IGNORECASE, + particularly for multibyte character sets. Sigh. + +Wed Jul 14 16:25:23 2004 John Haque + + * eval.c (interpret): For `Node_K_return', use `copynode' + and not `dupnode' for non-PERM, non-TEMP values. + (func_call): Don't add TEMP flag to returned value. + + These two fix a problem uncovered by the July 8 change in + `assoc_lookup'. + +Wed Jul 14 16:14:09 2004 Arnold D. Robbins + + * awkgram.y (node_common): Add check `lexeme >= lexptr_begin', + from valgrind run. + +Wed Jul 14 16:00:51 2004 John Haque + + * io.c (rsrescan): Fix off by one error at end of record. + +Thu Jul 8 16:59:51 2004 Stepan Kasal + + * awkgram.y (output_redir): Make sure not to dereference NULL + pointer. The bug was triggered by the following code: + + gawk 'BEGIN{print "date" |& getline}' + + No test case created, beacuse of the following: + Correct interpretation involves executing "1" or "0" -- as the user + may have defined this, we would have to override this in the test + script. It's not worth the hassle. + +Thu Jul 8 12:59:49 2004 Arnold D. Robbins + + * awk.h (load_casetable): Name changed from `load_ignorecase'. + * eval.c (load_casetable): Name changed from `load_ignorecase'. + Fix all uses. + +Thu Jul 8 12:32:13 2004 John Haque + + * awkgram.y (get_src_buf): Fix off-by-one error to avoid "does not end + in newline" messages. + * array.c (assoc_lookup): Small performance hack: for TEMP subs nodes, + use its string memory for ahname. + * ext.c (get_actual_argument): Minor code cleanup. + * builtin.c (do_lshift, do_rshift, do_and, do_or, do_xor, do_compl): + fixed to issue "non-numeric argument" lint warnings before using + `force_number'. + +Mon Jun 21 16:53:35 2004 Arnold D. Robbins + + More changes from John Haque to rationalize extension functions. + + * awk.h (get_curfunc_arg_count): Name changed from + `get_curfunc_parm_count'. + * eval.c (get_curfunc_arg_count): Ditto, body redone to count actual + args passed at call time. + * ext.c (get_argument): Update range check. + (get_actual_argument): Simplify the code. + +Mon Jun 14 14:01:16 2004 Arnold D. Robbins + + Changes from John Haque and ADR to rationalize extension functions. + + * awk.h (check_special, get_curfunc_parm_count, get_actual_argument): + new function declarations. + (get_scalar_argument, get_array_argument): New macros. + * awkgram.y (check_special): New function. + (yylex): Use `check_special' to search `tokentab'. + (dump_funcs): Always count functions, in order to get dynamic ones. + Removed bogus use of `static' on `tab' variable. + * eval.c (struct fcall): Change type of `count' to `size_t'. + (get_curfunc_parm_count): New function. + (push_args): Set `r->rnode' to NULL for local variable. + * ext.c (make_builtin): Add sanity checking for presence and + name of new function, and that it's not a redefinition. + (get_argument): Check that requested arg is within range of actual + number of parameters. Also clean up logic for Node_var_new, + Node_var_array, Node_array_ref. + (get_actual_argument): New function. + * profile.c (pp_builtin): Better handling of dynamic extension function. + +Sun Jun 13 14:32:22 2004 Arnold D. Robbins + + * io.c (redirect): Conditionalize checking for process recovery + on `#ifdef PIPES_SIMULATED'. Needed for MS-DOS and VMS. + * builtin.c (tmp_integer): Change bracketing of magic test to + `#ifdef HAVE_UINTMAX_T' which is more general and more correct. + +Wed Jun 9 21:36:01 2004 Arnold D. Robbins + + * re.c (make_regexp): Add dfa matching into IGNORECASE handling. + +Tue Jun 8 15:38:56 2004 Arnold D. Robbins + + * awk.h (casetable): Remove `const'. + * eval.c (casetable): Remove `const'. + (load_ignorecase): New function. Loads locale-correct values in + upper 128 bytes. + (set_IGNORECASE): Call `load_ignorecase'. + +Tue Jun 8 14:04:19 2004 Arnold D. Robbins + + * awkgram.y (get_src_buf): Make sure that value from + `optimal_bufsize' is reasonable. Increase it if not. + +Tue Jun 8 13:54:28 2004 John E. Haque + + * awkgram.y (statement:LEX_FOR): Fix bug in loop to `delete a' + optimization. + * io.c (format_tree): Check for out of range values for + positional specifiers. + +Mon Jun 7 17:02:48 2004 Arnold D. Robbins + + * builtin.c (tmp_integer): Bracket the magic test inside + `#ifndef VMS'. + + * awk.h (child_catcher): Remove declaration. + * main.c (main): Remove `signal' calls for SIGCLD, SIGCHLD. + * io.c (child_died, child_signo, child_catcher): Removed. + (get_a_record): Remove code checking for death of child. + (redirect): If `rp' matches and is at EOF and type is input + pipe, and `rp->pid' is not -1, call `wait_any' to reap the + child. This is a heuristic, but it works pretty well. + +Sun Jun 6 18:35:17 2004 Arnold D. Robbins + + * io.c (get_a_record): Restore use of `memmove' instead of + memcpy. Otherwise some tests break on some systems. We think. + (child_died): Don't reset signal handler; breaks on some S5 systems. + (get_a_record): Reset handler if child_died. Still flaky on Solaris. + * configure.ac (version.c): Made from version.in again, for + non-Unix systems. + * Makefile.am (base_sources): Add version.c back. + * version.in: Include config.h for definition of const. + * main.c (version_string): Add back declaration, don't + include "version.i". + (main): Don't install child_catcher on Sun. (HACK) + +Thu Jun 3 14:06:06 2004 Arnold D. Robbins + + * main.c (version_string): Removed declaration, since + version.i is included directly. + * version.in: Removed test for definition of const. + +Tue Jun 1 19:23:53 2004 Stepan Kasal + + * Makefile.am (base_sources): Don't mention version.c, so that + it doesn't get distributed. + * po/POTFILES.in: Remove version.c + * configure.ac: Create version.i from version.in. + * main.c: Include version.i. + +Tue Jun 1 18:33:32 2004 Arnold D. Robbins + + Fix problem reported by Stephen Marchant + on Thu, 30 Oct 2003 13:11:42 -0500. + + * regex_internal.h (re_realloc): Allow for SunOS pre-Standard C + `realloc' which doesn't accept NULL pointers. + * awk.h (erealloc): Same. + + Unrelated. Change suggested by Peter Sobisch , have + PROCINFO["version"] be the version of gawk: + + * main.c (load_procinfo): Add in version. + + Unrelated: Avoid warning: + + * main.c (main): Cast calls to `bindtextdomain' and `textdomain' to + void. Avoids diagnostic with `configure --disable-nls'. + * dfa.c (check_matching_with_multibyte_ops): Remove unneeded nested + #ifdef, per Scott Deifik (scottd@amgen.com). Also fix some spelling + errors in comments. + +Tue Jun 1 18:26:45 2004 Paul Eggert + + Fix a bug reported by Mike Romaniw + to bug-gnu-utils on 2003-09-27: compl(compl(0xf0f)) returned 0xfff + on hosts with 64-bit uintmax_t and 64-bit IEEE-764 double, due to + rounding errors. + + * doc/gawk.texi (Bitwise Functions): Leading nonzero bits are + removed in order to fit the result into a C 'double' without rounding + error. + * builtin.c: Include if available. + (FLT_RADIX, FLT_MANT_DIG, DBL_MANT_DIG): Define if not already defined. + (AWKSMALL_MANT_DIG, AWKNUM_MANT_DIG, AWKNUM_FRACTION_BITS): New macros. + (tmp_integer): New function. + (do_lshift, do_rshift, do_and, do_or, do_xor, do_compl): Use them. + +Tue Jun 1 17:40:47 2004 Stepan Kasal + + * eval.c (push_args): Set var_value to Nnull_string for + local variables. + +Mon May 31 11:49:20 2004 Stepan Kasal + + * replace.c: #undef DEBUG before including mktime.c, it has + different meaning there. + +Mon May 31 08:25:30 2004 Arnold D. Robbins + + * array.c (get_actual): Add extra error message for `delete f' + inside body of function `f'. + +Mon May 3 09:53:34 2004 Arnold D. Robbins + + * Makefile.in, */Makefile.in: Updated to automake 1.8.4. + * config.guess, config.sub: Same. + * aclocal.m4, depcomp, install-sh: Same. + +Mon May 3 09:24:45 2004 Arnold D. Robbins + + * configure.ac: Look for missing `strtoul'. + * replace.c: Include missing_d/stroul.c if not HAVE_STRTOUL. + * io.c (devopen): Use `strtoul' instead of `strtod' for + extracting fd number from "/dev/fd/N". (Thanks to Jim Meyering.) + * field.c (set_FIELDWIDTHS): Use `strtoul' instead of `strtod' + when parsing FIELDWIDTHS values. (Thanks to Jim Meyering.) + +Mon Apr 19 20:12:57 2004 Arnold D. Robbins + + * Makefile.in, */Makefile.in: Updated to automake 1.8.3. + * config.guess, config.sub: Same. + +2004-03-18 Stepan Kasal + + * eval.c (make_scalar): Comment clarification. + + * array.c (get_actual): Remove the condition ``canfatal'' + before ``cant_happen()''; if the data are consistent, we + simply cannot get there with a non-func Node_param_list, + no matter whether we are called via get_array or not. + + * awkgram.y (variable): Make one longer message, to help translators. + +Tue Mar 9 17:34:10 2004 Arnold D. Robbins + + Adapted `gofast' patch from Redhat Enterprise version of grep + to current dfa.c. + + * dfa.c (buf_offset): New variable. + (SKIP_REMAINS_MB_IF_INITIAL_STATE): Modified to use it, don't + free `mblen_buf', `inputwcs'. + (match_anychar, match_mb_charset, transit_state_consume_1char, + transit_state): Use buf_offset in mblen_buf. + (dfaexec): Realloc things instead of free and malloc. + +Thu Mar 4 16:46:55 2004 Arnold D. Robbins + + * configure.ac (AC_FUNC_MBRTOWC): Added. + (AC_CHECK_FUNCS): Removed `mbrtwoc'. + (REGEX_MALLOC): Removed. Not needed for new regex* routines. + + * re.c (research): Removed comment and check for return of -2 + since that was for old regex using alloca or REGEX_MALLOC. + +Wed Mar 3 17:10:16 2004 Arnold D. Robbins + + * io.c (close_one): Don't close stdout or stderr; can happen if + /dev/stdout or /dev/stderr are used in redirection and all the + open files get used. + +Sun Feb 29 12:17:37 2004 Arnold D. Robbins + + * regcomp.c (build_charclass, build_charclass_op): Change type of + `class_name' parameter to `const char *' from `const unsigned char *' + and adjust callers. + +Thu Feb 26 15:20:22 2004 Arnold D. Robbins + + * awkgram.y (get_src_buf): Rewritten to better manage input and + supplying newlines on command line programs. Fixes problems reading + source files on Cygwin. + + Unrelated fixes from mary1john8@earthlink.net: + + * node.c (format_val): For no malloc case, free s->stptr if necessary. + * io.c (nextfile): Add missing call to `unref(FILENAME_node->var_value)' + for no files case. + (close_redir): Remove file from redirection list even if fp is + stdout or stderr. + +Tue Feb 24 12:11:34 2004 Arnold D. Robbins + + * regex_internal.c (build_wcs_upper_buffer): Enclose `offsets_needed' + label in `#ifdef _LIBC' to silence `unused label' compiler warning. + +Tue Feb 24 11:57:18 2004 Nelson H.F. Beebe + + * regcomp.c (parse_expression): Add cast to (unsigned char *) in calls + to `build_charclass_op'. + * regex_internal.c (build_wcs_buffer): Add cast to char* in call to + `wcrtomb'. + * regex_internal.h (bitset_not, bitset_merge, bitset_not_merge, + bitset_mask, re_string_char_size_a, re_string_wchar_at, + re_string_elem_size_at): Change to use prototypes. + (re_string_char_size_at, re_string_wchar_at, re_string_elem_size_at): + Declare as `internal_function'. + + * Makefile.am: Add rule to make .i files. This assists in debugging. + * awk.h (m_tree_eval): Add casts to NULL. (Some compilers are just + dumb. ADR) + +Mon Feb 23 15:58:39 2004 Arnold D. Robbins + + Clean up occupied process slots of children that have died: + + * awk.h (child_catcher): New function, declare it. + * main.c (main): Catch SIGCHLD/SIGCLD with `child_catcher'. + * io.c (child_died): New static variable. + (child_catcher): New function, sets `child_died', reinstalls self + as signal handler. + (close_rp): New function: isolates actual fp/iop closing logic. + (close_redir): Call `close_rp'. + (get_a_record): Check `child_died' and call `wait_any(0)' if so. + Add descriptive comment. + + Unrelated clean up: + + * eval.c (fcalls): Renamed from `fcall_list'. All uses changed. + (pop_fcall, push_args, dump_fcall_stack): Adjusted to use indexing + on `fcalls' instead of a pointer into it. Avoids hassles if `fcalls' + is realloc-ed during recursive tree_evals. Thanks to BWK. + + * config.guess, config.sub: Updated from Savannah. + +2004-02-19 gettextize + + * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.14.1. + +Wed Feb 18 12:40:09 2004 Arnold D. Robbins + + * awkgram.y (rule): Use `msg' not `warning' for `must have an + an action part' message. `warning' is wrong, since it's a real error. + +Mon Feb 16 12:17:39 2004 Arnold D. Robbins + + * main.c, eval.c, builtin.c: Change test for `#ifdef HAVE_LOCALE_H' + to `#if ENABLE_NLS && defined(HAVE_LOCALE_H)' so that builds with + `configure --disable-nls' will actually work on non-glibc systems. + +Thu Feb 12 02:05:34 2004 Stepan Kasal + + Lots of misc changes from Stepan Kasal integrated. + + * array.c: Various variables and parameters of static functions + changed from int to long, in order to prevent overflow. + + * eval.c (make_scalar): New function; takes care of everything + that has to be done when a node of type Node_var_new or + Node_array_ref changes to a scalar variable. + (tree_eval, get_lhs): Call it. + (tree_eval): From now on, tree_eval(NULL) doesn't work; + it reports an internal error. + * awk.h (m_tree_eval): Likewise for the two macro versions. + * awkgram.y (statement): Make sure the Node_K_return's lnode is + always the return value, never NULL. + + * Makefile.am (install-exec-hook, uninstall-links): Make use of + $(VERSION). + (INCLUDES): Renamed to AM_CPPFLAGS. + (AM_CPPFLAGS): The file libintl.h is generated in the + build subdirectory intl, not in the directory $(srcdir)/intl. + (diffout): New target is an alias for ``make -C test diffout.'' + * awklib/Makefile.am (INCLUDES): Renamed to AM_CPPFLAGS. + + * README_d/README.hpux: Change the whitespace in the appended patch, + so that it applies to the current source. + * posix/gawkmisc.c: Change a tab to a space (needed for the above). + + Make version control more in the style of current autotools: + + * configure.ac: Remove obsolete versions of macros: + AM_INIT_AUTOMAKE doesn't need any parameters. + AC_OUTPUT shouldn't have any parameters either. + Its parameters go to a new macro: AC_CONFIG_FILES. + AC_CONFIG_HEADERS moved near the end of the file. + * configure.ac: Add [version.c:version.in] to AC_CONFIG_FILES + * version.in: Modify for autoconf substitutions. + * version.c: Remove, it's generated at configure time now. + * fixvers, patchlev.h, unsupported/tandem/ptchlvl.h: Nuke and ... + * Makefile.am, main.c: ... forget them. + +Mon Feb 9 12:57:00 2004 Arnold D. Robbins + + * awk.h builtin.c eval.c field.c (HUGE): Changed to `UNLIMITED'. + Avoids possible conflict with constant in svid-mode math.h. Thanks to + Roman.Putanowicz@iecn.u-nancy.fr for pointing out the problem. + +Fri Feb 6 12:09:55 2004 Arnold D. Robbins + + * configure.ac: Check for `wctype', `wcscoll' and `iswctype'. + * mbsupport.h: New file. Merges and centralizes testing for MBS support. + * Makefile.am (base_sources): Add mbsupport.h to list. + * dfa.c, dfa.h, awk.h (MBS_SUPPORT): Include "mbsupport.h" and use the + test there. + * regex_internal (RE_ENABLE_I18N): Same. + + * Makefile.am (CLEANFILES): Added. + +Thu Feb 5 18:05:12 2004 Arnold D. Robbins + + * configure.ac (HAVE_WCTYPE_T): New test code added. + * dfa.h (wctype_t): Define if system doesn't. Needed here too + for other files that include dfa.h. + * dfa.c (wctype_t): Define if system doesn't. + (lex): Manually fill in arrays used for char class range testing + so will work on c89 and older compilers. + (parse_bracket_exp_mb): Split up an assignment to avoid type complaints. + + * main.c (main): When checking for `close_io' failure, only set + `exit_val' to 1 if not already exiting. + + * regcomp.c (regerror): Remove use of mempcpy. Generates too + many compiler warnings. + * configure.ac (AC_CHECK_FUNCS): Don't bother checking for it. + +Wed Feb 4 17:34:47 2004 Arnold D. Robbins + + * getopt.h (__THROW): Only define it if C++. The __GNU_PREREQ + macro is a major headache. + +2004-02-02 Paolo Bonzini + + * regexec.c (check_matching): Add P_MATCH_FIRST parameter. + (re_search_internal): Pass new parameter to check_matching. + (check_matching): Unless a parenthesized group is found at the + beginning of the regexp, advance P_MATCH_FIRST until we entered + a state different from the initial state. + +Mon Feb 2 15:52:37 2004 Arnold D. Robbins + + * re.c (research): Change last param to re_search to pass + NULL if `need_start' is false. May give us a marginal speed gain. + +Thu Jan 29 17:04:51 2004 Arnold D. Robbins + + * builtin.c (sub_common): Fix logic for `&' in replacement for + multibyte case. Simplify code a bit. + +Tue Jan 20 10:41:45 2004 Arnold D. Robbins + + * configure.ac: Add check for `memmove'. + * replace.c: Include missing_d/memmove.c if don't have `memmove'. + +Sun Jan 18 12:01:29 2004 Arnold D. Robbins + + * builtin.c (sub_common): Add comment and support for 2001 POSIX + behavior when --posix in effect. The masses have been + clamoring for this one. + +2004-01-16 gettextize + + * configure.ac (AM_GNU_GETTEXT_VERSION): Bump to 0.13.1. + * intl/*: Updated to 0.13.1. + +Fri Jan 16 08:16:38 2004 Arnold D. Robbins + + * getopt.h, getopt.c, getopt1.c: Synced to GLIBC version: + getopt.c: 1.51 + getopt.h: 1.18 + getopt1.c: 1.9 + +Thu Jan 15 15:28:48 2004 Arnold D. Robbins + + Here we go again: + + * regcomp.c, regex.h, regex.c, regex_internal.h, regex_internal.c, + regexec.c: Sync to GLIBC version, but with bug fixes. GLIBC + CVS versions: + + regcomp.c: 1.76 + regexec.c: 1.55 + regex.c: 1.125 + regex.h: 1.30 + regex_internal.c: 1.39 + regex_internal.h: 1.45 + regexec.c: 1.55 + + * acinclude.m4: Removed, not needed for automake 1.8.x. + * configure.ac: Updated to autoconf 2.59. + + Everything else updated to automake 1.8x and autoconf 2.59. + +Wed Jan 14 14:26:36 2004 Arnold D. Robbins + + * dfa.c, dfa.h: Updated manually with most of the changes in + grep 2.5.1. That version lost the ability to match newlines + in the data, so the merge had to be done by hand. Sigh. + +2004-01-12 Paolo Bonzini + + ALLOCA patch from + http://sources.redhat.com/ml/libc-alpha/2004-01/msg00099.html + added. + + * regcomp.c [_LIBC && !RE_ENABLE_I18N]: + Drop code to support this, it is never true. + (build_range_exp) [!_LIBC]: Do not create a range + in MBCSET for a single-byte character set. + (build_range_exp) [_LIBC]: Do not create a range + in MBCSET for a single-byte character set without + collation elements. + (init_dfa): Do not conditionalize on _LIBC, it + just makes the code less clear. + (parse_bracket_exp): Use NON_MATCH variable in + addition to "mbcset->non_match", not as an + alternative. + (build_charclass_op): Rename NOT parameter to + NON_MATCH, use it instead of declaring a variable. + (parse_bracket_exp) [!_LIBC]: Pass NULL for MBCSET + if the character set is single-byte. + +Wed Jan 7 15:23:04 2004 Arnold D. Robbins + + * awkgram.y (mk_rexp): Set n->re_cnt to 1. Makes reinstated + dfa code actually take effect! Don't know how I missed this. + + Unrelated: sync regex code to glibc. + + * regcomp.c, regex.h, regex.c, regex_internal.h, regex_internal.c, + regexec.c: Sync to GLIBC version, but with bug fixes. GLIBC + CVS versions: + + regcomp.c: 1.74 + regex.c: 1.124 + regex.h: 1.30 + regex_internal.c: 1.39 + regex_internal.h: 1.43 + regexec.c: 1.55 + + * regcomp.c (peek_token): Temporarily, we hope, disable \s and \S + operators. Too much trouble to document right now. + * dfa.c (lex): Add code for \s and \S but disable it until + next release. + +Wed Dec 24 15:28:57 2003 Arnold D. Robbins + + * eval.c (r_tree_eval): For Node_assign_concat, add + call `free_temp(r)'. Thanks to mary1john8@earthlink.net. + +Mon Dec 1 10:25:52 2003 Arnold D. Robbins + + CONSTVAL not needed if we test PERM instead. Thanks to + mary1john8@earthlink.net. See test/concat3.awk. + + * awk.h [CONSTVAL]: Removed. + * eval.c (flag2str): Removed CONSTVAL from table. + (r_tree_eval): For Node_assign_concat, it's enough to check + if l->flags has PERM clear. + * awkgram.y (yylex): Removed use of CONSTVAL for YSTRING and YNUMBER. + +Mon Nov 3 16:33:26 2003 Arnold D. Robbins + + * awkgram.y (get_src_buf): Replace `memmove' with `memcpy' for + marginal portability gain to older systems. + * io.c (get_a_record): Ditto. + +Sun Nov 2 15:59:27 2003 Arnold D. Robbins + + * awk.h [CONSTVAL]: Renamed from `STRCONST'. + * eval.c (flags2str): Fix in table. + (r_tree_eval): For Node_assign_concat, check for the flag for + both left and right hand sides. Also add a `force_string' call + for the right hand side and the left hand side. + * awkgram.y (yylex): Change flag value for YSTRING and add use + of flag for YNUMBER. + +Wed Oct 29 14:23:29 2003 Arnold D. Robbins + + * awk.h [STRCONST]: New flag value. + * eval.c (flags2str): Add it to table. + (r_tree_eval): For Node_assign_concat, check for the flag so that + we don't clobber string constants given: + s = "" + s = s something + * awkgram.y (yylex): For YSTRING, set STRCONST flag. + +Tue Oct 28 18:00:00 2003 Arnold D. Robbins + + Force SUBSEP to always have a string value. Per bug report + from mary1john8@earthlink.net. + + * awk.h (NODETYPE): New type, Node_SUBSEP. + (set_SUBSEP): Add declaration. + * awkgram.y (isnoeffect, isassignable): Add Node_SUBSPEP case. + * array.c (set_SUBSEP): New function. + * eval.c (nodetypes): Add Node_SUBSEP. + (r_tree_eval, r_get_lhs): Add code for Node_SUBSEP. + * main.c (varinit): Use Node_SUBSEP as type for SUBSEP. + * profile.c (tree_eval, pp_lhs, is_scalar, prec_level): Handle + Node_SUBSEP. + +Tue Oct 7 09:26:33 2003 Arnold D. Robbins + + * awk.h (NODETYPE): New member `Node_assign_concat'. + * awkgram.y (exp): Look for case of `x = x y' and if so, create a + Node_assign_concat. + * eval.c (interpret): Add case for Node_assign_concat. + * profile.c (prec_level): Ditto. + (tree_eval): Ditto. For variables, call new function `vname' to + print name; handles varname field for -v variables, which end up + including the value. + (vname): New function. + +Wed Sep 24 17:32:31 2003 Arnold D. Robbins + + Speed up `avoid_dfa' kludge, at least a little: + + * awk.h (struct Regexp): Add `has_anchor' member. Make it and + `dfa' member shorts; keeps space the same. + * re.c (make_regexp): Set `has_anchor' member correctly. + (avoid_dfa): Test for `has_anchor' member instead of searching + for it each time. + +Sun Sep 21 18:34:32 2003 Arnold D. Robbins + + * builtin.c (state): Only needs to be 256 bytes, initstate() can't + use any more than that. Well whadayaknow. + (do_rand, do_srand): Call `setstate' after calling `initstate'. + +Tue Sep 16 15:44:29 2003 Arnold D. Robbins + + * eval.c (interpret): For Node_K_switch, add kludge_need_start stuff + as used in `match_op'. Sigh. + * re.c (make_regexp): Add `no_dfa' variable, which is true if + GAWK_NO_DFA exists in the environment. This enables run time + testing of things with/without the dfa matcher. + +Mon Sep 15 18:36:38 2003 Arnold D. Robbins + + After much soul searching, reinstated old dfa code. The performance + of the new regex is just disastrous. Sigh. + + * awk.h (re_cnt): Reinstated old definition. + (struct Regexp): Added `dfareg' and `dfa' members. + (make_regexp): New last parameter in function, changed decl. + (avoid_dfa): Added declaration. + * awkgram.y (regexp, mk_rexp): Added use of `re_cnt'. Fixed call + to `make_regexp'. + * Makefile.am: Add dfa.h and dfa.c. + * eval.c (match_op): Complexified: added call to `avoid_dfa' and + `kludge_need_start' variable where used to pass FALSE as last parameter + of research(). + * field.c (set_FS): Fixed call to `make_regexp'. + * io.c (get_a_record, set_RS): Fixed calls to `make_regexp'. + * re.c (make_regexp): Added last paramter (`dfa') to function. + Complexified the code. + (re_update): Fixed call to `make_regexp'. + (research): Complexified the code, added calls to dfa stuff. + (dfaerror): New function. + (re_update): Fixed call to `make_regexp'. + (avoid_dfa): New function. + +Tue Sep 9 15:57:38 2003 Arnold D. Robbins + + * awkgram.y (get_src_buf): Fix calculation of `offset' when shifting + source lines around. In general, improve handling of things when + moving the source code line around. What a mess this code is. + +Mon Sep 8 19:08:55 2003 Arnold D. Robbins + + * eval.c (fmt_ok): Make provision for %F format and printf %'f flag + here too. + +2003-07-23 Christophe Bisiere (tiny change) + + * posix/regex.h (RE_TRANSLATE_TYPE): Define it to "unsigned char," + to avoid problems at hosts with signed char. + * posix/regexec.c (re_search_internal): Don't say + "unsigned RE_TRANSLATE_TYPE." + +Thu Aug 28 11:09:41 2003 Arnold D. Robbins + + * io.c (nextfile): Change use of variable `files' to make it + clearer that it's a boolean flag. + +Tue Aug 26 22:58:15 2003 Arnold D. Robbins + + * io.c (useropen): Add `defined (HAVE_GETGROUPS)' as first test + in `#ifdef'. Brings things in sync with same test in main.c and awk.h. + +Tue Aug 26 22:49:37 2003 Arnold D. Robbins + + * dbug.h: New file. + + * array.c, awkgram.y, builtin.c, eval.c, ext.c, field.c, io.c, + main.c, msg.c, node.c, profile.c, re.c: Converted to use + Fred Fish's `dbug' library. By default compiled out, thus + not affecting speed. + + For the nonce, the `dbug' library itself is not shipped with + gawk, since I expect no-one else but me to be using it. + +Thu Aug 21 23:15:36 2003 Arnold D. Robbins + + * awkgram.y (numfiles): Change extern decl to long, to match what's + in main.c. Keeps things working on 64-bit systems. Thanks to bug + report from Jan Oravec . + +Wed Aug 20 14:53:47 2003 Arnold D. Robbins + + * eval.c (genflags2str): Move test for out-of-space inside test + for is the bit set. + +Mon Aug 11 11:26:51 2003 Arnold D. Robbins + + * regcomp.c (parse_bracket_exp): If `build_charclass' fails, just pass + its value on as the return value. + +Sun Aug 10 16:59:14 2003 Arnold D. Robbins + + * regcomp.c (build_range_exp): Make sure we don't + get WEOF on range characters. + +Tue Aug 5 21:49:32 2003 Arnold D. Robbins + + * array.c (get_actual): In `case Node_param_list' add test for + `&& (symbol->flags & FUNC) == 0' to the if. + +Sun Jul 13 18:28:38 2003 Arnold D. Robbins + + Further bug fix: + + * awkgram.y (variable): Give the new variable an lnode + of Nnull_string if it's not an array, even if it is + a Node_var_new. + +Fri Jul 11 09:32:21 2003 Arnold D. Robbins + + Bug fix: + + * eval.c (r_tree_eval): For Node_array_ref, set + tree->orig_array->var_value to Nnull_string too. + + Unrelated i18n and POSIX change: + + * configure.ac: Add check for local printf supporting %F format. + * awk.h (loc): New variable declaration. + * main.c (loc): Defined. + (main): Call `localeconv' to set loc. + * io.c (format_tree): Add support for printf quote flag, %'d for + decimal formats (not %e, %E), adds thousand separator into value. + +2003-07-10 Paul Eggert + + * io.c (two_way_open): If /bin/sh cannot be executed, exit + with status 126 consistently. + +Mon Jul 7 11:01:43 2003 Arnold D. Robbins + + * Release 3.1.3: Release tar file made. + +Mon Jul 7 09:55:49 2003 Arnold D. Robbins + + * main.c (copyleft, usage): Make sure to fflush output fp. Per Jim + Meyering, if error, exit non-zero. + * ext.c (get_argument): Fix array paramater handling. + +2003-07-06 Paul Eggert + + * builtin.c (do_substr): Issue better diagnostics when + d_substr and d_length are NaN, or when 0 < d_length < 1. + Be careful when comparing double to SIZE_MAX, as + the comparison might return the "wrong" answer when + `(double) SIZE_MAX' is a number that is not equal to + SIZE_MAX. + (do_gensub): Watch out for HOW values that are out of range + or are NaN. + (do_dcngettext): dcngettext wants an argument of type + unsigned long, not long, so use a value of that type. + +Fri Jul 4 10:58:02 2003 Arnold D. Robbins + + * main.c (main): Make option letter 'D' fall through into default + unknown case if not debugging. Let's us have just one version of + `optlist'. + +Thu Jun 26 15:25:57 2003 Arnold D. Robbins + + * array.c (get_actual): Undo Stepan Kasal change of 2003-06-17. + See test/match2.awk. + +Wed Jun 25 15:26:08 2003 Arnold D. Robbins + + * builtin.c (do_rand): Change calculation so that result + obeys constraint: 0 <= N < 1. This is per history and POSIX. + Thanks to Nelson Beebe (beebe@math.utah.edu) for reporting + this issue. + +Mon Jun 23 15:13:39 2003 Arnold D. Robbins + + * io.c (rs1scan): Per advice from Bruno Haible, it's safe + to skip the multibyte checking code if RS is '\n'. See + the comment in the code. Big performance improvement for + multibyte locales. + +2003-06-20 Stepan Kasal + + * eval.c (comp_func): If memcmp returns 0, we have to compare + the lengths. + +2003-06-19 Stepan Kasal + + * eval.c (interpret) : Use NULL, not 0, to + initialize the variable list. + (comp_func): Array indices no longer are string values, + you have to use ahname_str, ahname_len. + +Tue Jun 17 11:53:46 2003 Arnold D. Robbins + + * array.c (get_actual): Make check for isparam + smarter: also check for FUNC flag. + +2003-06-17 Stepan Kasal + + * array.c (get_actual): Even if canfatal is FALSE, don't + tolerate existence of things which can't happen. + +Mon Jun 16 16:21:44 2003 Arnold D. Robbins + + * configure.ac: Removed m4/Makefile. + * m4/Makefile.am: Removed. + +2003-06-16 gettextize + + * configure.ac (AC_OUTPUT): Add m4/Makefile. + (AM_GNU_GETTEXT_VERSION): Bump to 0.12.1. + +Sun Jun 15 20:45:43 2003 Arnold D. Robbins + + * io.c (get_a_record): Enhance logic to fill buffers to include + `|| no_data_left(iop)'. + (rs1scan): Fix logic for setting recm fields for multibyte + character case. + +2003-06-10 Stepan Kasal + + * awkgram.y (release_all_vars): Do not try to release a value of + Node_var_new; after get_lhs, use the lhs directly, do not try + to do (*lhs)->var_value; the Node_var case doesn't need + special treatment. + * builtin.c (do_match): `get_param' is successful iff it returns + Node_var_array---if the variable was new, get_param has already + changed the type. + * field.c (do_split): Likewise. + +Sun Jun 15 19:36:35 2003 Arnold D. Robbins + + * node.c (r_dupnode): Typo fix in hash tables: stptr -> ahname_str. + Thanks to mary1john8@earthlink.net. + * array.c (get_actual): Add `if (canfatal)' before call to + `cant_happen'. + +Sun Jun 15 19:25:49 2003 Patrick T.J. McPhee + + * awk.h (memcpy_ulong): Add ! WIN32 to ifdefs. + +Mon Jun 9 18:38:20 2003 Arnold D. Robbins + + * custom.h (hpux): Added stuff to (hopefully) get `tzset' + declared on HP/UX 10 and up. + +Mon Jun 9 17:12:24 2003 Patrick T.J. McPhee + + * awk.h (ATTRIBUTE_EXPORTED): New macro for dynamic libs on Windows32. + * CONVMFTidx, stack_ptr, do_lint, lintfunc: Now have this attribute. + +Mon Jun 9 13:11:33 2003 Arnold D. Robbins + + Clean up of Stepan's patches. + + * array.c (get_actual): Renamed from r_get_array. Added second + param canfatal if routine should print fatal message when not an array. + (get_actual): Renamed 'prm' to `isparam'. + (array_vname): Add static msglen var; only realloc string if it grows. + Don't use `s += sprintf(...)'. No good on old systems where sprintf + returns char *. Minor formatting cleanups. + (do_adump): Restored separate `a' and `r' variables; helps for debugging. + + * awk.h (SCALAR, UNINITIALIZED): Removed entirely, renumbered other flags. + (get_array, get_param): New macros, calls get_actual. + (get_actual): Declaration changed from that of r_get_array. + + * awkgram.y (release_all_vars): Restored previous version of code; new + version isn't right for Node_xx variables. + (variable): Minor code cleanup for readability. + + * builtin.c (do_match): Use get_param and print our own message when + third parameter is not an array. + + * eval.c: Added a few comments here and there, removed some no longer + needed comments. + + * field.c (do_split): Use get_param and print our own message when + second parameter is not an array. + +Mon Jun 9 11:46:21 2003 Arnold D. Robbins + + * array.c (do_delete): Initialize hash1 and last to keep gcc -Wall happy. + * io.c (rsnullscan): Comment out label skip_leading for same reason. + +Wed May 28 08:31:23 CEST 2003 Stepan Kasal + + * eval.c (forloops_active, in_function): Nuked. + (pop_all_forloops, pop_fcall_stack): Are now inline. + +Wed May 28 07:58:35 2003 Stepan Kasal + + * field.c, awk.h (Null_field): No longer static. + * field.c (init_fields): Initial value of $0 can be Nnull_string, + no need to copy it. + * eval.c (r_get_lhs) : Test for uninitialized field, + which is Nnull_string for $0 and Null_field for $(>0). + * builtin.c (do_print_rec): Test for uninitialized $0. + +Tue May 27 17:03:02 2003 Stepan Kasal + + * awk.h (Node_var_new): New node type for variables which can be + either scalar or array. From now on, Node_var is always scalar. + (Node_gvar_ref): Nuked, its role can be taken by Node_array_ref. + (orig_var): Removed, orig_array is enough. + (SCALAR, UNINITIALIZED): Flags nuked. + (var_uninitialized): New macro to distinguish uninitialized vars; + used in several other macros. + * array.c (r_get_array, array_vname, do_adump): Adapt to the + above changes. + * awkgram.y, eval.c, field.c, main.c, node.c, profile.c: Ditto. + +Tue May 27 14:27:50 2003 Stepan Kasal + + * array.c (r_get_array): New function, which goes all the way + through Node_param_list to actual Node_var_array; if it encounters + non scalar Node_var, it changes it to Node_var_array. + (in_array, do_delete, do_delete_loop, do_adump, assoc_sort_inplace): + Use get_array. + (assoc_lookup): The parameter must be a Node_var_array. + * awk.h (get_array, r_get_array): Declare the new function and define + a macro to speed it up. + * builtin.c (do_match): Use get_array. + * eval.c (interpret) : Ditto. + (r_get_lhs) : Ditto. + * field.c (do_split): Ditto. + +Tue May 27 08:23:51 2003 Stepan Kasal + + Changed node->vname meaning for type Node_array_ref and Node_gvar_ref. + It contains only the reference name; one has to (recursively) follow + node->prev_array to find out the call history for the array. + + * array.c (array_vname): New function to print the array name. + (assoc_lookup, do_delete): Use array_vname. + * eval.c (interpret, r_tree_eval, r_get_lhs): Use array_vname. + (push_args, pop_fcall): Things have simplified. + * awk.h (array_vname): Declare. + (prev_array): Define. + +Sun Jun 8 11:25:36 2003 Stepan Kasal + + * awkgram.y (append_right): When using savetail, remember that it + is not necessarily the tail of the list---it's just a pointer to + the last chunk appended. + +Thu Jun 5 12:01:41 2003 Arnold D. Robbins + + * builtin.c (do_strtonum): Make `strtonum(13)' work. + +Wed Jun 4 17:07:06 2003 Corinna Vinschen + + * io.c (binmode): Include function for __CYGWIN__ too. + +Tue Jun 3 12:40:50 2003 Arnold D. Robbins + + * eval.c (interpret): Node_K_switch. For regex case, don't + call `free_temp' on the result of `force_string' if it's equal to + switch_value. Thanks to John DuBois + for finding the problem. + +Sun Jun 1 13:08:22 2003 Arnold D. Robbins + + * builtin.c (format_tree): For %c, force precision to 1. + +Wed May 28 11:55:48 2003 Arnold D. Robbins + + * awkgram.y (isnoeffect, isassignable): Add Node_TEXTDOMAIN to + switches in both functions. + +Wed May 28 11:38:59 2003 Stepan Kasal + + * awkgram.y (switch_body): Remove rule ``switch_body:/*empty/'' + as ``switch_body:case_statements'' covers it---this disambiguation + fixes a reduce/reduce conflict. + +Sun May 25 16:23:43 2003 Corinna Vinschen + + * configure.ac: Remove linking against /usr/lib/automode.o. + * configure: Regenerate. + +Sun May 25 15:19:19 2003 Stepan Kasal + + * awk.h (get_lhs): For an initialized Node_var, you may return + the address of var_value pointer, no matter whether reference + bit was set or not. We were silly slowing down most of the + assignements. + + * (get_a_record): After grow_iop_buffer, move recm.rt_start even + if recm.len == 0. + +Mon May 19 16:55:59 2003 Arnold D. Robbins + + Code for C-style switch statements. Initial version contributed by + Michael Benzinger . + + Disabled by default, use `configure --enable-switch' to turn it on. + + * configure.ac: New AC_ARG_ENABLE for switch statements. + * awk.h (NODETYPE): New types for switch, case, default keywords + and respective lists. + * awkgram.y: New productions for switch statement. Does checking to + avoid duplicate cases. + * eval.c (nodetypes): New entries for new NODETYPEs. + (interpret): New code to do switch execution. + * profile.c (pprint): New code to print switch statements. + +Mon May 19 15:05:43 2003 Arnold D. Robbins + + * configure.ac: Renamed from configure.in. + * fixvers: Now looks in configure.ac. + * Makefile.am: Now cites configure.ac. + + * Misc other: Updated to Automake 1.7.5. + +Sun May 18 12:03:56 2003 Arnold D. Robbins + + * array.c (do_delete_loop): Fix bracing of logic for + tests. + +Wed May 14 09:01:16 2003 Stepan Kasal + + Misc patches: + + * builtin.c (do_match): If third parameter to `match' is supplied, + store all subexpressions which are applicable, even though there + are some unused between them. + + * awkgram.y (yylex): When returning from unterminated REGEXP + (which is /* kludge */), take care to fake a yylval, to + prevent ``internal error'' later. + +Sun May 11 15:51:00 2003 Stepan Kasal + + * io.c (rsnullscan, get_a_record): Boundary condition bug fixes. + +Sun May 11 15:15:20 2003 Scott Deifik + + * awk.h: Add decls for `memcpy_ulong', `memset_ulong', and + MSC defines. + * regex.c: Include if MSC for size_t. + +Mon May 5 15:11:06 2003 Arnold D. Robbins + + * io.c (get_a_record): Only tweak RT's value in place if the current + RS scanner is the same as the last one. Bug report submitted by + John DuBois (). + +Fri May 2 14:39:48 2003 Arnold D. Robbins + + * io.c (get_a_record): Add logic at end to be smart about setting + RT. Saves considerable time, esp for default case where RS = "\n". + +Wed Apr 30 11:44:38 2003 Arnold D. Robbins + + * field.c (do_split): Add check and code for Node_gvar_ref. + * array.c (in_array, do_delete, asort_actual): Same. + * builtin.c (do_split): Same for 3rd arg array parameter. + * eval.c (interpret): Same for Node_K_array_for. + (push_args): Same for evaluating extra args. + +Tue Apr 29 15:54:28 2003 Arnold D. Robbins + + Record reading code redone/simplified considerably. + + * awk.h (IOBUF): Removed total field, no longer used. + * io.c (at_eof, has_data, no_data_left): New macros. + (RECVALUE, SCANSTATE): New enumerated types. + (rs1get_a_record, rsnull_get_a_record, rsre_get_a_record): Removed. + (get_a_record): Rewritten, again. Now contains just buffer and + record code; searching code moved into these functions: + (rs1scan, rsnullscan, rsrescan): New functions to scan a buffer + for record contents and terminator. Fill in values in: + (struct recmatch): Holds found record and terminator. + (spec_setup): Set iop->dataend to indicate data is already in buffer. + (nextfile, inrec): Use new macros instead of flag and pointer tests. + (set_RS): Set scanning function instead of record function. + + FWIW, it all passes `make test'. + +Sun Apr 27 21:02:39 2003 Arnold D. Robbins + + * io.c (do_close): At end, if do_posix return 0. See comment in code. + +Tue Apr 15 09:56:03 2003 Isamu Hasegawa + + * configure.in: Check existence of wcrtomb, and wcscoll. + * configh.in: Likewise. + * configure: Re-generate. + Thanks to Kimura Koichi for reporting. + +Sun Apr 13 16:02:10 2003 Arnold D. Robbins + + * main.c (main): Add call to `setlocale' for LC_NUMERIC after program is + parsed. + (arg_assign): Switch back to "C" locale for LC_NUMERIC for command + line assignments; this is per POSIX that period is decimal point for + program and command line assignments and the locale's separator + applies for input, output, and string to number conversion. + +2003-03-26 Paul Eggert + + * builtin.c [HAVE_INTTYPES_H]: Include . + [!HAVE_INTTYPES_H && HAVE_STDINT_H]: Include . + (CHAR_BIT, INTMAX_MIN, UINTMAX_MAX): Define if the system does not. + (TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): New macros, taken from + coreutils and many other GNU utilities. + (format_tree): When formatting, use widest possible integers + rather than settling with 'long'. + (do_lshift, do_rshift, do_and, do_or, do_xor, do_compl): Likewise, + when doing bitwise operations. + * configure.in (jm_AC_TYPE_LONG_LONG, jm_AC_TYPE_UNSIGNED_LONG_LONG, + jm_AC_TYPE_INTMAX_T, jm_AC_TYPE_UINTMAX_T): Add, since the mainline + code now needs this. + * doc/gawk.texi (Control Letters, Bitwise Functions): Document this. + * m4/intmax_t.m4: New file, taken from coreutils (but renamed to + avoid collision with our m4/inttypes.m4). + * m4/longlong.m4: New file, taken from coreutils. + * m4/uintmax_t.m4, m4/ulonglong.m4: Remove; superseded by the above + new m4 files. + + * builtin.c (BITS_PER_BYTE): Remove; use CHAR_BIT instead, since + it's the standard name. + (do_lshift, do_rshift): Complain if the shift width is exactly equal + to the word size, too. + +Thu Mar 27 10:44:11 2003 Arnold D. Robbins + + * io.c (rs1_get_a_record, rsnull_get_a_record, rsre_get_a_record): + Enhance check for no data left in file to be only if file has + non-zero size. Linux files such as /proc/filesystems stat as a + regular file of size 0, but actually have contents. Ugh. + Thanks to Martin Schlemmer for the bug report. + +Wed Mar 26 12:19:32 2003 Arnold D. Robbins + + * builtin.c (format_tree): Add a lint warning at label `out_of_range'. + +Tue Mar 25 12:24:38 2003 Arnold D. Robbins + + * awkgram.y (variable): For array subscript, if NAME is in the + symbol table, but not a variable, array, or parameter, generate + a syntax error. + (isarray): New function, tests if a symbol can be an array. + + * custom.h: Add check for HP/UX, needed for GCC. + +Mon Mar 17 09:21:09 2003 Arnold D. Robbins + + Allow simultaneous manipulation of a global array directly + and when passed as a parameter. + + * awk.h (Node_gvar_ref): New nodetype. + [orig_var]: New macro. + * array.c (do_delete_loop, do_delete): Add logic to handle + seeing Node_gvar_ref. + * eval.c (nodetypes): Add Node_gvar_ref. + (r_tree_eval, r_get_lhs): Add Node_gvar_ref case. + +Wed Mar 19 14:10:31 2003 Arnold D. Robbins + + This time for sure. + -- Bullwinkle + + * Release 3.1.2: Release tar file made. + +Wed Mar 19 14:08:11 2003 Arnold D. Robbins + + * awkgram.y: Production `program --> program error'. Add a return so + that we don't produce an infinite stream of error messages. + Thanks to Michael Mauch for pointing this out. + +Wed Mar 19 13:45:50 2003 Corinna Vinschen + + * regex.c [RE_ENBABLE_I18N]: Remove definition; the one in + regex_internal.h is better and makes things work with Cygwin. + +Tue Mar 11 11:54:20 2003 Arnold D. Robbins + + * regex_internal.h: Don't include after was + included in regex.c, since it could redefine RE_DUP_MAX to a lower + value. + (bitset_set, bitset_clear, bitset_contain): Use 1UL instead of 1 in + left shift operations. + * regex.c: Include before + * regcomp.c (re_compile_fastmap_iter, init_word_char, parse_expression): + Use 1UL instead of 1 in left shift operations. + +Mon Mar 10 15:45:37 2003 Corinna Vinschen + + * configure.in: Update CYGWIN case to add /usr/lib/automode.o. + +Thu Mar 6 11:07:36 2003 Arnold D. Robbins + + Updated to automake 1.7.3. + + * config.guess, config.sub: Updated from prep. + * Makefile.am (AUTOMAKE_OPTIONS): Add dist-bzip2 to get .bz2 files. + +Tue Mar 4 10:40:46 2003 Arnold D. Robbins + + * version.in: Added goop for K&R compilers; forgot that I have to fix + this file which then is used to create version.c. + +Mon Mar 3 17:00:44 2003 Arnold D. Robbins + + * configure.in: New option --disable-lint. + * awk.h (do_lint, do_lint_old): Conditionally declare based on NO_LINT. + * eval.c (set_LINT): Ifdef out body if NO_LINT. + * main.c (do_lint, do_lint_old): Conditionally compile properly. + (main): Handle --lint argument code. + +Fri Feb 28 10:43:07 2003 Arnold D. Robbins + + * main.c (main): Add LC_TIME to the things that get set with + setlocale(). + * builtin.c (format_tree): Change test of `n0-- <= 0' to ==, avoids + VMS diagnostic. + +Thu Feb 27 17:48:29 2003 Pat Rankin + + * regexec.c (proceed_next_node): Cast re_string_get_buffer to char *. + (get_subexp): Likewise. + +Tue Feb 25 12:33:41 2003 Arnold D. Robbins + + * regex_internal.h, regex_internal.c, regcomp.c, regexec.c: + Make MB_CUR_MAX into thread local variable re_mb_cur_max. + + Unrelated, from Scott Deifik: + + * io.c (grow_iop_buffer): Add checks for overflow of new buffer size. + +Mon Feb 24 13:30:59 2003 Arnold D. Robbins + + * awk.h (gawk_mb_cur_max): Declared: + * main.c (gawk_mb_cur_max): Defined, init to 1. + (main): Initialize gawk_mb_cur_max. + * awkgram.y, builtin.c, eval.c, field.c, io.c, re.c (mb_cur_max): + Replaces all instances of MB_CUR_MAX, which is a function call (!) + in glibc. Big speed up, especially for -Fx case, where x is a + single character. + + Unrelated: + + * awkgram.y (rule): For non-existent action, use a Node_K_print_rec + node. + +Sun Feb 23 15:45:20 2003 Arnold D. Robbins + + Speed up plain `print' and `print $0': + + * awk.h (Node_K_print_rec): New node type. + (do_print_rec): Declare function. + * awkgram.y (simple_stmt): Create humongous test for plain `print' + or `print $0', and if so, use a Node_K_print_rec for it. Modify + test for lint message. + * builtin.c (redirect_to_fp): New function for common code to get fp + and rp for do_print{,f,_rec} functions. + (do_print): Use redirect_to_fp(). + (do_printf): Use redirect_to_fp(). + (do_print_rec): New function to just print $0 from field_arr[0] + directly; will rebuild the record first if necessary. + * eval.c (nodetypes): Add Node_K_print_rec. + (interpret): Add Node_K_print_rec case. + * profile.c (pprint): Add Node_K_print_rec case. + (pp_print_stmt): If null lnode, print "$0" else print the lnode. + + Unrelated: + + * regex_internal.h: Add ENABLE_NLS to the condition for using + gettext so that --disable-nls really disables it. + +Sat Feb 23 22:46:00 2003 Arnold D. Robbins + + * io.c (rs1_get_a_record, rsnull_get_a_record, rsre_get_a_record): + Modify buffer-filling algorithm to always read one or more multiples + of the blocksize (iop->readsize). + (grow_iop_buffer): Make sure there's room for the current partially + read record and one disk block buffer. + +Thu Feb 20 22:02:00 2003 Arnold D. Robbins + + * re.c (research): Fix typo in cast of precision value to int. + * regex.h, regex.c, re_internal.h, re_internal.c, regcomp.c, regexec.c: + synced to GLIBC source, maintaining K&R portability changes, and bug + fixes, although losing ability to compile each file separately. + * Makefile.am (SOURCES): Moved placement of regex source files from here ... + (EXTRA_DIST): ... to here. + +Tue Feb 18 14:17:33 2003 Arnold D. Robbins + + * re.c (research): Cast precision value to int. + * builtin.c (format_tree): For toofew, cast field width value to int. + * io.c (rsre_get_a_record): Initialize restart and reend. Add a variable + to make sure they're set before used at end of function. + (iopflags2str): Removed decl at top and made not static so that GCC + stops complaining that it's defined but not used. Bleah. + +Mon Feb 17 11:02:34 2003 Arnold D. Robbins + + * config.guess, config.sub: Updated from prep. + +Sun Feb 16 15:47:15 2003 Scott Deifik + + * awk.h (format_tree, make_str_node): Changed decls to match how + they are called. + * builtin.c (format_tree, sub_common): Same. + * node.c (make_str_node): Same. + +Wed Feb 5 14:18:01 2003 Arnold D. Robbins + + * awk.h: Removed duplicate decl of set_prof_file(). Removed + undef of const for non-ANSI C; config.h should handle it. + * msg.c (set_loc): Use srcfile and srcline in regular code to shut up + stupid SGI compiler. + +Tue Feb 4 14:28:06 2003 Arnold D. Robbins + + All relevant files: Copyright year updated to 2003. + +Tue Feb 4 13:40:41 2003 Martin C. Brown + + * intl/libgnuintl.h: Preprocessor fixes for MacOS X. + * regex.h: Ditto. + +Tue Feb 4 13:39:37 2003 Arnold D. Robbins + + * awkgram.y (builtin_func): New string for use in rationalizing + function parsing and installation code. + +Sun Feb 2 16:00:55 2003 Arnold D. Robbins + + Cache function body code pointer so that only have to find it the + first time a function is called. This potential for optimization + brought to my attention by Stepan Kasal. + + * awk.h [funcbody]: New macro. + * awkgram.y (FUNC_CALL): Set $$->funcbody to NULL. + * eval.c (func_call): Changed to take top-level Node_func_call as the + single parameter. Do the lookup and caching. + (r_tree_eval): Change how func_call() is called in switch. + * profile.c (pp_func_call): Similar changes. + (tree_eval): Ditto. + +Sun Feb 2 15:32:42 2003 Stepan Kasal + + ADR: More grammar rationalization/repair from Stepan. + + * awkgram.y (common_exp, simp_exp): The rule from getline (without + pipe) has been moved from common_exp to simp_exp. + + The redirection of print statements reworked. The idea comes from + mawk-1.3.3; much thanks to Michael Brennan! + + * awkgram.y (IO_OUT, IO_IN): New tokens. + (APPEND_OP, TWOWAYIO): Swallowed by the above ones. + (in_print, in_parens): New static variables, to trace whether + IO_OUT is expected. + (yylex): Emit the new tokens, update in_parens on '(' and ')'. + (exp): The print command(s) reworked. + (oputput_redir): Reworked. + (print_expression_list): New non-terminal. + (rexp, rexpression_list opt_rexpression_list): Nuked. + (exp, simp_exp): ``cmd|getline'' rule changed to + ``cmd IO_IN getline'' and moved from exp to simp_exp. + + Unrelated: + + * awkgram.y (variable): Don't return Node_func, issue a fatal + error instead. + * eval.c (r_tree_eval, r_get_lhs): Omit special checks for Node_func, + nodes of this type cannot get into the program tree. + * profile.c (tree_eval, pp_lhs): Likewise. + +Thu Jan 30 17:42:05 2003 Stepan Kasal + + ADR: Applied lots of patches from Stepan. + + * array.c (do_delete_loop): Call after_assign for the loop index. + * field.c (do_split): The third argument to split(), sep, has to be + evaluated and the result dupnoded before assoc_clear is called, + similarily as src. And we needn't to evaluate the third argument + if it's CONSTant regex and the first parameter is null string. + * awk.h (dupnode): Changed to macro, function renamed to r_dupnode. + * node.c (dupnode, r_dupnode): Rename. + * awkgram.y (parms_shadow): Return bool value, ... + (shadow_funcs): ... which will enable us to end the program if + lintfunc is fatal. + (program): Cleanup of the rules defining the ``program'' non-terminal. + (start, program, rule): No value associated, + expression_value is now treated similarily as begin_block and end_block. + (pattern, rule): Bison actions for non-terminal `pattern' now + add a new rule to the appropriate Node_rule_list, action for + non-terminal `rule' now only adds the associated code block + to the rnode of Node_rule_node. + (io_allowed): Renamed to !begin_or_end_rule. + (append_pattern): New function, adds new Node_rule_node to a rule_list. + (mkrangenode): Deleted, this tiny function was called only once. + (function_body): Non-terminal replaced by `action'. + (statements, action, statement): `statements' can now be empty; + both callers had to accomodate to this. + (statements): Don't call isnoeffect($2->type) if + $2 happens to be NULL. + +Mon Jan 27 14:12:19 2003 Arnold D. Robbins + + * io.c (iop_close): Based on report by Stepan Kasal and because of + his changes, don't call reset_record() when saving a copy of contents + of $0. + * awkgram.y: Improved function parsing error messages for case where + user uses a builtin name as a function name. Based on error report + by Stepan Kasal. + * ext.c (make_builtin): Set FUNC flag for new function. Based on error + report by Stepan Kasal. + +Mon Jan 27 14:06:20 2003 Stepan Kasal + + * field.c (reset_record): No longer call set_record(), the code is + moved to the function body. Do not set MAYBE_NUM. + (set_record): Call reset_record() to perform the common tasks. + The prototype has changed, change awk.h and all callers. + +Mon Jan 27 10:50:03 2003 Arnold D. Robbins + + * awk.h (NODE): `proc' renamed to `builtin,' to fix a conflict + on some systems. Replaced on all spots where it was used. + +Sun Jan 26 11:52:01 2003 Arnold D. Robbins + + * awk.h [NUMSUBPATS]: New macro. + * builtin.c (do_match): Use it in loop that fills in subpattern info. + * eval.c (r_tree_eval): For Node_assign, don't call free_temp(), + as assign_val() contains dupnode(), which would clear the TEMP + flag. From Stepan Kasal . + * config.sub: Updated from prep. + +Sun Jan 19 22:34:01 2003 Arnold D. Robbins + + * awk.h (do_asorti): Add declaration. + * awkgram.y (tokentab): Add asorti() function to table. + * array.c (ASORT_TYPE): New enumerated type for VALUE or INDEX array + sorting. + (assoc_sort_inplace): New second arg of type ASORT_TYPE. Additional code + to rearrange array so rest of merge-sorting works; basically values are + tossed and index moved into value spot. + (asort_actual): Renamed from do_asort(). Takes new ASORT_TYPE argument. + (do_asort): Calls asort_actual(tree, VALUE). + (do_asorti): Calls asort_actual(tree, INDEX). + + * main.c (load_procinfo): Free groupset array when done with it. + +Thu Jan 16 18:30:50 2003 Arnold D. Robbins + + * builtin.c (do_match): Revised to provide start and length + indices in array 3rd parameter. + * config.guess, config.sub: Updated from prep. + +Thu Jan 2 11:09:12 2003 Arnold D. Robbins + + Updated to bison 1.875. + +Tue Dec 31 17:14:45 2002 Arnold D. Robbins + + Updated things to automake 1.7.2 and autoconf 2.57. + +Tue Dec 31 16:54:44 2002 Arnold D. Robbins + + * awk.h [IOP_CLOSED]: New flag. + * io.c (iop_close): Set IOP_CLOSED flag. + (inrec): Check for IOP_CLOSED; if set return EOF. + (rs1_get_a_record, rsnull_get_a_record): Check for EOF before + refilling buffers. + (rsre_get_a_record): Ditto. Also, set RT before updating pointers in IOP. + * Makefile.am (efence): New target to compile with Electric Fence. + +2002-12-23 Kaveh R. Ghazi + + * awk.h (catchsig): Delete prototype. + * main.c (catchsig): Make static and remove excess argument. + (main): Delete unnecessary casts. + * io.c (rs1_get_a_record, rsnull_get_a_record): Mark parameter + with ATTRIBUTE_UNUSED. + +Mon Dec 23 11:54:07 2002 Arnold D. Robbins + + * regex_internal.h, regex_internal.c, regcomp.c, regexec.c, version.c: + Fixed to compile, once again, under K&R compilers. + * io.c (grow_iop_buffer): Fix calculation of new size to + first subtract 2, double, then add 2 back in. + +Fri Dec 20 11:48:42 2002 Arnold D. Robbins + + get_a_record split into three routines. + + * awk.h (IOBUF): Structure reworked for new code. + * io.c (get_a_record): Now a pointer to different functions. + (rs1_get_a_record, rsnull_get_a_record, rsre_get_a_record): New functions. + (iop_alloc, iop_close): Reworked for new structure. + (do_getline, inrec): Modifiend for new EOF condition. + (iopflags2str): New routine. + +Fri Dec 20 11:05:50 2002 Isamu Hasegawa + + * regex.c, regex_internal.c, regex_internal.h: Changes to allow separate + compilation of the reg*c files. + * regcomp.c: Fix bug in using translation tables with [[:upper:]] etc. + * Makefile.am: Move regex files into sources from EXTRA_DIST. (ADR) + +Mon Dec 9 14:20:42 2002 Stepan Kasal + + * main.c (main): When processing option '-f' don't ignore spaces + if optarg points at the beginning of the current argument + (like ``gawk -f " " file''). + +2002-11-30 Kaveh R. Ghazi + + * awkgram.y (stopme): Mark parameter with ATTRIBUTE_UNUSED. + (yyerror): Add ATTRIBUTE_PRINTF_1. + * builtin.c (do_systime, do_rand): Likewise. + * field.c (set_field, re_parse_field, def_parse_field, + posix_def_parse_field, null_parse_field, sc_parse_field, + fw_parse_field): Likewise. + * io.c (pidopen, useropen): Likewise. + * main.c (catchsig): Likewise. + * profile.c (init_profiling): Likewise. + * awk.h (err): Add ATTRIBUTE_PRINTF. + * msg.c (err): Delete redundant prototype. Fix format specifier. + +Wed Nov 27 06:04:20 2002 Pat Rankin + + * ext.c [#if !DYNAMIC] (do_ext): Cast string value for error node. + +Sun Nov 24 18:23:29 2002 Arnold D. Robbins + + From Paul Eggert, with some edits by me. + + * builtin.c (do_substr): Consistently use floating point + values for lint messages, so they should be printed pretty + much as the user saw them. Check for overflow before + converting floating point to integer. Do the right thing with + NaNs. + + Check for index out-of-range before checking for length + out-of-range, to avoid some nasty effects if address + arithmetic overflows (e.g., indx + length < index). + + Allow zero-length substrings when checking for lint if + do_lint == LINT_INVALID. + +Sun Nov 24 18:21:06 2002 Arnold D. Robbins + + * awk.h (LINT_ALL, LINT_INVALID): New constants. + * main.c (main): Allow --lint=invalid which restricts warning to + things that aren't valid. + * eval.c (set_LINT): Update setting logic. + +Wed Nov 20 13:14:58 2002 Arnold D. Robbins + + * awk.h (lintfunc): Improve ifdef for attribute to only + work for GCC 3.2 and later. + * io.c (PIPES_SIMULATED): Don't define if on AIX, which + does define TANDEM in one of its header files. Ugh. + +Tue Nov 19 15:33:55 2002 Arnold D. Robbins + + * builtin.c (do_substr): Use %lu in warnings instead of %d. + +Mon Nov 18 14:42:53 2002 Arnold D. Robbins + + * config.guess: Synced from ftp.gnu.org. + * config.sub: Ditto. + +Sun Nov 17 21:32:49 2002 Arnold D. Robbins + + Updated things to automake 1.7.1. + +Sun Nov 3 14:33:30 2002 Arnold D. Robbins + + * eval.c (r_get_lhs): For variables, always clear UNINITIALIZED, + since the variable is about to be assigned to. From Stepan Kasal. + +Fri Nov 1 11:19:01 2002 Arnold D. Robbins + + * awk.h (lintfunc): Can only supply attributes for a function + pointer if GCC >= 3. Added ifdefs. Bah, humbug. + +2002-10-30 Kaveh R. Ghazi + + * array.c (array_init, concat_exp, assoc_find, do_delete): + Const-ify. + * awk.h (redirect, set_record, pp_func, pp_string_fp, format_val, + parse_escape, make_regexp, research, reisstring, remaybelong): + Likewise. + * awkgram.y (dumpintlstr, dumpintlstr2, func_use, dup_parms, + var_comp, finfo, fcompare, func_use, dumpintlstr, dumpintlstr2): + Likewise. + * builtin.c (stdfile, do_fflush, do_index, category_table): + Likewise. + * eval.c (push_forloop, push_args, PUSH_BINDING, RESTORE_BINDING, + cmp_nodes, op_assign, loop_info, fcall, fmt_ok, set_LINT, + comp_func): Likewise. + * ext.c (do_ext): Likewise. + * field.c (set_record): Likewise. + * io.c (gawk_popen, two_way_open, binmode, redirect, getredirect, + fatal): Likewise. + * node.c (values, format_val, make_str_node, parse_escape): Likewise. + * profile.c (pp_string, pp_match_op, pp_func, pp_string, + pp_string_fp): Likewise. + * re.c (make_regexp, research, reisstring, remaybelong): Likewise. + +2002-10-30 Kaveh R. Ghazi + + * awk.h (__attribute__, ATTRIBUTE_UNUSED, ATTRIBUTE_NORETURN, + ATTRIBUTE_PRINTF, ATTRIBUTE_PRINTF_1, __extension__): Define. + (emalloc, erealloc): Fix format specifier warnings. + (do_nextfile):Mark with ATTRIBUTE_NORETURN. + (getredirect): Const-ify. + (msg, error, warning, r_fatal, lintfunc): Mark with + ATTRIBUTE_PRINTF_1. + (r_fatal): Mark with ATTRIBUTE_NORETURN. + * builtin.c (format_tree): Fix format specifier warning. + * eval.c (interpret): Likewise. + * main.c (usage, copyleft, catchsig, nostalgia, version): Mark + with ATTRIBUTE_NORETURN. + * profile.c (dump_and_exit): Likewise. + +2002-10-29 Kaveh R. Ghazi + + * array.c (array_init): Use ISDIGIT, not isdigit. + * awk.h (m_tree_eval, force_number, force_string): Use + __extension__ in statement expressions. + * main.c (lintfunc): Fix !__SDTC__ case. + * regex_internal.c (calc_state_hash): Fix inline declaration. + * regexec.c (proceed_next_node): Cast assignment to correct type. + +2002-10-29 Kaveh R. Ghazi + + * awk.h (exp_node, Func_ptr): Add prototype arguments. + * awkgram.y (yystype, token, getfname, nextc, pushback, + allow_newline, yylex): Likewise. + * io.c (wait_any): Likewise. + * profile.c (indent_in, indent_out): Likewise. + * random.h (random): Likewise. + +2002-10-29 Kaveh R. Ghazi + + * array.c (grow_table): Const-ify. + * awk.h (RE_TRANSLATE_TYPE): Define. + (flagtab, casetable): Const-ify. + (getfname, shadow_funcs, redflags2str): Prototype. + (flags2str, genflags2str, nodetype2str, redflags2str, set_loc, + msg, error, warning, r_fatal): Const-ify. + * awkgram.y (tokentab, snode): Likewise. + * builtin.c (format_tree, do_strftime, + localecategory_from_argument): Likewise. + * eval.c (casetable, nodetypes, nodetype2str, flags2str, + genflags2str): Likewise. + * io.c (redflags2str, socketopen): Likewise. + * main.c (varfile, version_string, lintfunc, optab, copyleft, + varinit, init_vars): Likewise. + * msg.c (srcfile, msg, warning, error, set_loc, r_fatal): + Likewise. + * profile.c (pp_op_assign, pp_match_op, pp_redir): Likewise. + * random.c (sccsid): Likewise. + * version.c, version.in (version_string): Likewise. + +Tue Oct 29 10:50:52 2002 Arnold D. Robbins + + * configure.in: Update version in AC_INIT and AM_INIT_AUTOMAKE + * fixvers: Make grep for pattern a little smarter. + +Mon Oct 28 16:35:39 2002 Arnold D. Robbins + + * awk.h (hash): Now a function pointer. + * array.c (gst_hash_string, scramble): New functions. + (awk_hash): Renamed from hash. + (hash): Now a function pointer. + (array_init): Change hash function based on environment for + experimentation. + +Mon Oct 28 13:21:20 2002 Arnold D. Robbins + + Applied lots of patches from Stepan Kasal, tweaked as needed + for current code base. + + * node.c (dupnode): When n->stref overfows, flag the node as PERM. + Same for n->ahname_ref. + (unref): Remove the check for n->stref == LONG_MAX and + n->ahname_ref == LONG_MAX. + * awk.h (make_string): The third argument to make_str_node changed + from FALSE to 0, it's not Boolean. + (free_temp): Evaluate the argument only once, so that we + can call free_temp(tree_eval(n)) for achieving side effects. + (load_environ, load_procinfo): Changed return type to NODE *. + * main.c (load_environ): The ENVIRON_node should be created with type + Node_var_array and lnode set to NULL. Return pointer to the created node + and create an empty hash even on TANDEM. + (load_procinfo): Same mods for PROCINFO_node. + (init_args): ARGV_node should also have lnode set to NULL. + * eval.c (r_tree_eval): case Node_assign moved just above the other + assignment cases. + (op_assign): ++ and -- cases merged with += and -=, respectively. + (push_args): Evaluate all args, even in cases where more args are + supplied then required. + (interpret): In case Node_K_forarray, flag the variable + num_elems also as volatile, so that it survives longjmp() and + can be trusted when linting code. + (r_get_lhs): Case Node_param_list was unreachable (unless + something breaks really badly), remove it; + (r_tree_eval): Case Node_var_array removed from the last switch, + it was caught in the first switch above. + * profile.c (tree_eval): Again, case Node_var_array was caught above. + * awkgram.y (variable): Code simplified, making use of the above + changes. + * field.c (sc_parse_field): IGNORECASE only applies to regex based + field-splitting, so remove code that pays attention to it. + (do_split): Don't use parse_field if RS_is_null. + (set_FS): Beware of FS == "\\" even if RS_is_null. + + Code changes to make things work better: + * field.c (set_FS): Don't use cmp_nodes() to compare old and new + value of FS, that uses IGNORECASE, which is a bad idea. Improve + logic for choosing sc_parse_field. Ensure that when RS_is_null + but using a single character, that we do pay attention to + case when doing regex splitting. + * io.c (set_RS): Don't use cmp_nodes() to compare old and new + value of RS, that uses IGNORECASE, which is a bad idea. + +Mon Oct 28 09:43:14 2002 Arnold D. Robbins + + * recomp.c (parse_expression): Change return statement into + two so it'll compile for SGI cc. + + * awk.h (STR, CUR): Changed to STRCUR and NUMCUR respectively, + to avoid conflict with STR on some System V systems. Changed + in all source files. + +Thu Oct 24 16:14:34 2002 Arnold D. Robbins + + * array.c (AVG_CHAIN_MAX): Now a variable, to allow easy experimentation. + (array_init): Pulls a new value from env var AVG_CHAIN_MAX if it + exists and sets the variable. + * awk.h: Add declaration for array_init(). + * main.c (main): Call array_init(). + +Tue Oct 22 11:23:56 2002 Arnold D. Robbins + + * bisonfix.sed: Updated for current bison. Death to alloca! + +2002-10-21 Isamu Hasegawa + + * builtin.c (tolower, toupper): Add casts to char* to fix some + compiler warnings. + * eval.c (cmp_nodes): Ditto. + * regcomp.c (peek_token_bracket): Skip the byte already read. + +Wed Oct 16 15:02:09 2002 Arnold D. Robbins + + * io.c (set_RS): Make sure to always call set_FS(). + +2002-10-11 Isamu Hasegawa + + * regcomp.c (re_compile_fastmap_iter): Remove the handling + OP_CONTEXT_NODE. + (regfree): Likewise. + (create_initial_state): Likewise. + (analyze): Remove the substitutions which became useless. + (calc_first): Likewise. + (calc_epsdest): Use edests of OP_BACK_REF in case that it has + epsilon destination. + (duplicate_node_closure): New function. + (duplicate_node): Remove the handling OP_CONTEXT_NODE. + (calc_inveclosure): Likewise. + (calc_eclosure): Likewise. + (calc_eclosure_iter): Invoke duplicate_node_closure instead of + direct invocation of duplicate_node. + (parse): Don't use comma operator in the return to avoid compiler + warning. + (parse_reg_exp): Likewise. + (parse_branch): Likewise. + (parse_expression): Likewise. + (parse_sub_exp): Likewise. + (parse_dup_op): Likewise. + * regex_internal.c (re_dfa_add_node): Remove the substitutions + which became useless. + (create_ci_newstate): Remove the handling OP_CONTEXT_NODE. + (create_cd_newstate): Likewise. + * posix/regex_internal.h (re_token_type_t): Remove the obsolete type. + (re_token_t): Likewise. + (re_dfa_t): Likewise. + (re_node_set_remove): New macro. + * regexec.c (check_matching): Remove the handling + OP_CONTEXT_NODE. + (check_halt_node_context): Likewise. + (proceed_next_node): Likewise. + (pop_fail_stack): Fix the memory leak. + (set_regs): Likewise. + (free_fail_stack_return): New function. + (sift_states_backward): Fix the memory leak. Remove the handling + OP_CONTEXT_NODE. + (update_cur_sifted_state): Append some if clause to avoid redundant + call. + (sub_epsilon_src_nodes): Use IS_EPSILON_NODE since it might be a + back reference. + (check_dst_limits): Remove the handling OP_CONTEXT_NODE. + (check_subexp_limits): Likewise. + (search_subexp): Likewise. + (sift_states_bkref): Likewise. + (transit_state_mb): Likewise. + (transit_state_bkref_loop): Likewise. + (transit_state_bkref_loop): Likewise. + (group_nodes_into_DFAstates): Likewise. + (check_node_accept): Likewise. + (sift_ctx_init): Add initializing. + +Tue Oct 15 14:18:53 2002 Arnold D. Robbins + + * eval.c (set_IGNORECASE): Call set_RS() instead of + set_FS_if_not_FIELDWIDTHS(). The former calls the latter + for us, and also makes IGNORECASE affect RS like it's supposed to. + * field.c (FS_re_yes_case, FS_re_no_case): New variables. + (set_FS): Smarten up routine to not recompile FS_regexp if all + that's changed is IGNORECASE or if switching back to FS from + FIELDWIDTHS. Significant speed-up for cases where IGNORECASE + is assigned to for every record. + * io.c (RS_re_yes_case, RS_re_no_case): New variables. + (set_RS): Similar changes as to set_FS(). In particular, + IGNORECASE changing now affects record splitting too. + * re.c (refree): Set rp->pat.tranaslate to NULL. It comes + from casetable and shouldn't be freed. (Strictly necessary + only for old regex, but a good idea anyway). + Also, call regfree(& rp->pat) instead of manually free()ing + things, since there's dynamically allocated stuff hiding in + the buffer. Avoids a memory leak. + +Mon Oct 14 12:02:39 2002 Arnold D. Robbins + + Major space reduction in array management. Overhead reduced + to two NODE's per element from three. + + * awk.h (ahash): Union is gone. + (hash.ref): New union member. + (ahnext): New definition into hash union. + (ahvalue): New definition into hash union. + (ahname_str): New member, points into hash union. + (ahname_len): New member, points into hash union. + (ahname_ref): New member, points into hash union. + * array.c: Replaces uses of ahname member with string and + length. Set the reference count correctly to 1 on new nodes. + * eval.c (interpret): Case for Node_K_arrayfor. dupnode() the + array indices, and set loop variable to new value made via + make_string(). + * node.c (unref, dupnode): Node_ahash nodes are now also + reference counted, a la strings. Similar code is used to + increment/decrement the counts, and/or copy nodes as + needed. + + Unrelated: + * awk.h (forsub): Removed. Not used. + +Sun Oct 13 16:58:27 2002 Stepan Kasal + + * profile.c (pprint): #undef the temporary defines at the end + of the case. + * eval.c (interpret): Likewise. + (assign_val): We can unref() before doing dupnode(). + Also, move the check for NF < 0 from here ... + * field.c (set_NF): ... to here. + * main.c (varinit): No need to call set_NF(). + * awkgram.y (statements): Don't be so generous when concatenating + `statements' with a `statement'. + + +2002-10-13 Isamu Hasegawa + + * regcomp.c: Synced with development sources. + * regex_internal.c: Synced with development sources. + * regex_internal.h: Synced with development sources. + * regexec.c: Synced with development sources. + +Sun Oct 13 21:35:35 2002 Arnold D. Robbins + + * awk.h (NODE): Reflags is now unsigned long for: + (exec_count): Defined to be sub.nodep.reflags. Using `number' + broke pgawk. + * profile.c (Node_K_delete_loop): Print out as a for loop + with a comment that it's internally the same as `delete array'. + * eval.c (Node_K_delete_loop): Increment the exec_count. Ooops. + * configure.in (AM_GNU_GETTEXT_VERSION): New macro call. + * custom.h: Updated description of the file at the top. + +Thu Oct 10 16:39:51 2002 Arnold D. Robbins + + * awk.h (vname, exec_count): Now macros into different + parts of the NODE structure that can be safely used for them. + Saves 16 bytes per NODE. + * eval.c: Changed use of `vname' to `varname' to avoid new + macro. + * main.c (lintfunc): Made ifdefed decls match awk.h. + * eval.c (comp_func): Use memcmp instead of strcmp. + * configure.in (AC_CONFIG_HEADER): Physically append custom.h + to config.h to avoid subdir compiliation problems. + +Sun Oct 6 17:36:15 2002 Arnold D. Robbins + + Updated to automake 1.7 and bison 1.50. + + * INSTALL: Replaced with current version from automake 1.7. + * config.guess: Replaced with current version from automake 1.7. + * config.sub: Replaced with current version from automake 1.7. + * depcomp: Replaced with current version from automake 1.7. + * doc/texinfo.tex: Replaced with current version from automake 1.7. + * install-sh: Replaced with current version from automake 1.7. + * missing: Replaced with current version from automake 1.7. + * mkinstalldirs: Replaced with current version from automake 1.7. + * ylwrap: Replaced with current version from automake 1.7. + + * configure.in (DYNAMIC): Updated AC_DEFINE(DYNAMIC) to + three-argument form for autoheader. + * acinclude.m4: Removed includes of jm-mktime.m4 and + largefile.m4, which are now standard parts of Autoconf. + + * Makefile.in: Regenerated. + * aclocal.m4: Regenerated. + * awkgram.c: Regenerated. + * awklib/Makefile.in: Regenerated. + * configure: Regenerated. + * doc/Makefile.in: Regenerated. + * test/Makefile.in: Regenerated. + +Sun Sep 29 16:47:49 2002 Arnold D. Robbins + + * custom.h (__WIN32__): Added from gnuwin32 project, via + Stepan Kasal. + + * awkgram.y: For tawk compatibility, added `delete(array)'. + To remain undocumented, since it's WAY non-standard. + +Sun Sep 22 22:23:50 2002 Arnold D. Robbins + + * awk.h (re_cnt): Removed, not needed since no dfa code. + * awkgram.y (regexp, a_regexp): Removed use of re_cnt. + * re.c (re_update): Ditto. + +Thu Sep 19 10:55:37 2002 Arnold D. Robbins + + * io.c (binmode): Create function if defined(WIN32) also. + + Updated to gettext 0.11.5, autoconf 2.54 and automake 1.6.3. + + * aclocal.m4: Regenerated. + * m4/codeset.m4: Updated. + * m4/gettext.m4: Updated. + * m4/glibc21.m4: Updated. + * m4/iconv.m4: Updated. + * m4/lcmessage.m4: Updated. + * m4/lib-ld.m4: Updated. + * m4/lib-link.m4: Updated. + * m4/lib-prefix.m4: Updated. + * m4/progtest.m4: Updated. + * po/Makefile.in.in: Updated. + * po/Rules-quot: Updated. + * po/boldquot.sed: Updated. + * po/en@boldquot.header: Updated. + * po/en@quot.header: Updated. + * po/insert-header.sin: Updated. + * po/quot.sed: Updated. + * po/remove-potcdate.sin: Updated. + +Tue Sep 17 23:46:01 2002 Arnold D. Robbins + + * configure.in: Moved override of INSTALL to just after + AC_INIT so that it takes effect. Necessary for Autoconf 2.5x. + +Mon Sep 16 16:40:57 2002 Stepan Kasal + + * awkgram.y (want_assign): Removed. + (SLASH_BEFORE_EQUAL, ASSIGN): New terminals; ``/='' is now + formed from these two. + (a_slash): New non-terminal, representing either '/' or + SLASH_BEFORE_EQUAL. + (assign_operator): New non-terminal, replaces ASSIGNOP. + (REGEXP): yylex now eats the terminating '/' before + returning REGEXP token. + (exp): The check for C-like comments moved from here + (regexp): ... to here. + (common_exp): New non-terminal; contains common parts of exp + and rexp. (a_relop, relop_or_less): New non-terminals. + (rexp): Some rules updated to be analogous to exp. + (output_redir): Can contain only common_exp, not exp in general. + +Mon Sep 16 22:51:51 2002 Arnold D. Robbins + + * io.c (two_way_open): Move label use_pipes outsidef of ifdef, + just in case. + +Thu Sep 12 15:11:28 2002 Arnold D. Robbins + + * awkgram.y (getfname): Return NULL if not found, remove + fatal error. Could be an extension function. + (dump_funcs): Walk symbol table counting functions before + mallocing table, since there could be extension functions, + func_count could be too small. + * profile.c (pp_builtin): Handle NULL return from getfname(). + Print it as "extension_function()" if so. + +Tue Sep 10 17:33:48 2002 Arnold D. Robbins + + Minor code simplification. + + * awk.h (in_array): Change return type to NODE*. + (assoc_exists): Remove declaration. + * array.c (in_array): Change return type to NODE *. + Return value is pointer to element value or NULL. + (assoc_exists): Removed function. + * eval.c (r_tree_eval): Case Node_in_array, change value + to test return of in_array() against NULL. + * io.c (pty_vs_pipes): Change test to make a tmp_string() + of the index and call in_array(). Add free_temp() of + subscript and free() of full_index (oops). + +2002-09-10 Isamu Hasegawa + + * posix/regcomp.c: Wrap #include wchar.h and wctype.h in #if. + (build_range_exp): Add castings to strlen invocations. + (build_collating_symbol): Restore the type of characters from "char" + to "unsigned char", and supplement castings. + (build_collating_symbol): Likewise. + (build_equiv_class): Likewise. + (build_charclass): Likewise. + (seek_collating_symbol_entry): Likewise. + (parse_bracket_exp): Likewise. + (build_word_op): Supplement a casting. + * posix/regex_internal.c: Wrap #include wchar.h and wctype.h in #if. + (re_string_allocate): Fix castings. + (re_string_construct): Likewise. + (re_string_construct_common): Likewise. + (re_string_realloc_buffers): Likewise. + (build_wcs_buffer): Likewise. + (build_wcs_upper_buffer): Likewise. + (re_string_skip_chars): Likewise. + (re_string_reconstruct): Likewise. + * posix/regex_internal.h: Restore the type of characters in + re_string_t and bracket_elem_t from "char" to "unsigned char". + (re_string_elem_size_at): Fix castings. + * posix/regexec.c: Wrap #include wchar.h and wctype.h in #if. + (transit_state_bkref_loop): Restore the type of characters from + "char" to "unsigned char", and append a cast to "char*" pointer in + array subscript. + (check_node_accept_bytes): Likewise. + (find_collation_sequence_value): Likewise. + +Thu Sep 5 13:15:09 2002 Arnold D. Robbins + + * re.c (remaybelong): New routine. + (reisstring): Simplified the code a bit. + * awk.h (remaybelong): Declaration added. + * io.c (get_a_record): Change fourth grungy special case to + use remaybelong() instead of strchr() on last character. + +Wed Sep 4 13:20:26 2002 Arnold D. Robbins + + * io.c (do_input): Recode guts of main loop to be easier + to trace with a debugger. + (get_a_record): Fourth grungy special case for RE-based + record splitting added. See explanatory comments there + and test/rebuf.awk. + +2002-09-03 Isamu Hasegawa + + * posix/regcomp.c (regcomp): Append "__restrict" modifier to avoid + warnings of some compilers. + (build_collating_symbol): Change the type of characters from + "unsigned char" to "char", and append a cast to "char*" pointer in + array subscript. + (build_collating_symbol): Likewise. + (build_equiv_class): Likewise. + (build_charclass): Likewise. + (re_compile_pattern): Remove incorrect cast. + (re_compile_fastmap_iter): Change the type of characters from + "unsigned char" to "char", and append a cast to "char*" pointer + in array subscript. + (parse_bracket_exp): Likewise. + * posix/regex_internal.c (re_string_construct_common): Likewise. + (re_string_allocate): Likewise. + (re_string_construct): Likewise. + (re_string_realloc_buffers): Likewise. + (build_wcs_buffer): Likewise. + (re_string_reconstruct): Likewise. + * posix/regex_internal.h: Change the type of characters in + re_string_t and bracket_elem_t from "unsigned char" to "char". + * posix/regexec.c (regexec): Append "__restrict" modifier to avoid + warnings of some compilers. + (transit_state_bkref_loop): Change the type of characters from + "unsigned char" to "char", and append a cast to "char*" pointer in + array subscript. + (check_node_accept_bytes): Likewise. + (find_collation_sequence_value): Likewise. + +Wed Aug 21 15:40:36 2002 Corinna Vinschen + + * configure.in: Define --without-libintl-prefix and + --without-libiconv-prefix for Cygwin by default. + * Makefile.am: Call fixvers from $(srcdir). + * awk.h: Don't define O_BINARY on Cygwin. + +Wed Aug 21 15:31:57 2002 Andreas Buening + + * configure.in (AC_OBJEXT, AC_EXEEXT): Added. Removed OS/2 goo. + * Makefile.am (check-local): Add $(EXEEXT) suffixes, remove OS/2 goo. + * regcomp.c, regex_internal.c, regexec.c: Conditionalize include of + and on RE_ENABLE_I18N. + +Wed Aug 21 14:43:57 2002 Arnold D. Robbins + + * gettext.h (ENABLE_NLS): Add include of locale.h so that things + compile even without optimization. Sheesh. + * io.c (two_way_open, pty_vs_pipes): Conditionalize pty code on + HAVE_TERMIOS_H. + +Thu Aug 8 22:16:10 2002 Arnold D. Robbins + + * main.c (main): Force LC_NUMERIC locale to "C", esp. for + M$ systems. Ugh. + +Wed Aug 7 13:42:01 2002 Arnold D. Robbins + + * io.c (get_a_record): Improve test for newlines at beginning of + record but with nothing following it. See test/nulrsend. + +Mon Aug 5 10:12:39 2002 Arnold D. Robbins + + Add option to use ptys instead of pipes for |&. + Basic plumbing originally from Paolo Bonzini . + + * awk.h (RED_PTY): New flag. + (assoc_exists): Add declaration. + * array.c (in_array): Use FALSE not zero for return value. + (assoc_exists): New routine to find and return value for an index + in an array. + * configure.in: Test for termios.h and stropts.h, and grantpt function. + * io.c: Include termios.h and stropts.h if available. + (redflags2str): Add RED_PTY to table. + (redirect): Add RED_PTY to flags turned off when searching. + (close_redir): Close write channel for two-way pipes + that use ptys by sending an EOF. + (two_way_open): If pty_vs_pipe(), use pty's to open two-way pipes as + they are line-buffered by default --> alleviates deadlock problems. + If fails, fall back to using pipes. + (pty_vs_pipe): New function. + * main.c (arg_assign): Clean up English in some of the error messages. + +Sun Aug 4 00:37:38 2002 Stepan Kasal + + * re.c (make_regexp): Don't pass the error message returned by + re_compile_pattern() to gettext(); it's already gettextized. + (make_regexp): Minor reformat of code. + +Wed Jul 31 23:50:31 2002 Arnold D. Robbins + + Removed dfa code from gawk since not really needed with new regex. + + * Makefile.am: Removed dfa.h and dfa.c. + * awk.h (struct Regexp): Removed `dfareg' and `dfa' members. + (make_regexp): Last parameter in function went away, changed decl. + (avoid_dfa): Removed declaration. + * awkgram.y: Fixed call to make_regexp(). + * eval.c (match_op): Simplified: removed call to avoid_dfa() and + `kludge_need_start' variable. Instead, pass FALSE as last parameter + of research(). + * field.c (set_FS): Fixed call to make_regexp(). + * io.c (get_a_record, set_RS): Fixed calls to make_regexp(). + * re.c (make_regexp): Removed last paramter (`dfa') from function. + Simplified the code. + (research): Simplified the code, removed calls to dfa stuff. + (dfaerror): Removed function. + (re_update): Fixed call to make_regexp(). + (avoid_dfa): Removed function. + +Thu Jul 25 21:55:45 2002 Arnold D. Robbins + + * regcomp.c, regex_internal.c, regex_internal.h, regexec.c: Bug + fixes from Isamu Hasegawa and Stepan Kasal + applied. + +Sat Jul 6 23:28:37 2002 Arnold D. Robbins + + * awkgram.y (yyerror): Change text of unexpected newline message to + include end of string. + +Mon Jun 17 17:58:55 2002 Arnold D. Robbins + + * field.c (do_split): Per Michal Jaegermann, move free_temp(fs) + above label `out'. + +Tue Jun 11 23:26:09 2002 Paul Eggert + + Update to autoconf 2.53 and automake 1.6.1. + + * acconfig.h: Removed. + * m4/isc-posix.m4: Removed. + * m4/jm-mktime.m4: Removed. + * m4/largefile.m4: Removed. + * m4/ssize_t.m4: Removed. + * ansi2knr.c: Updated. + * depcomp: Updated. + * install-sh: Updated. + * missing: Updated. + * mkinstalldirs: Updated. + * ylwrap: Updated. + + * configure.in: Improved quoting. + * acinclude.m4: Use `m4_sinclude', not antiquated `sinclude'. + +Tue Jun 11 23:08:40 2002 Arnold D. Robbins + + * configure.in: Add `getgrent' to list of functions checked + so that awklib/grcat is compiled correctly. + +Tue Jun 11 22:18:42 2002 Stepan Kasal + + Improve argument parsing and -v assignment. + + * awk.h (struct src): Add additional enum values. + (arg_assign): Return type and arg list changes. + * io.c (nextfile): Add extra arg in call to `arg_assign'. + * main.c (pre_assign): Nuked. + (allocfiles): New variable. + (srcfiles_add, preassigns_add): New macros. + (main): Logic cleaned up. + (add_src): New function. + + Use `size_t' for optimal_bufsize function. + + * awkgram.y (yylex): `len' is now size_t. + * pc/gawkmisc.pc (optimal_bufsize): Change return type to size_t. + * posix/gawkmisc.c (optimal_bufsize): Change return type to size_t. + * unsupported/atari/gawkmisc.atr (optimal_bufsize): Change return type + to size_t. + * unsupported/tandem/tmisc.c (optimal_bufsize): Change return type to size_t. + * vms/gawkmisc.vms (optimal_bufsize): Change return type to size_t. + * README_d/README.hpux: New file. + +Fri May 24 12:23:01 2002 Arnold D. Robbins + + * profile.c (init_profiling): Remove default initialization + of `prof_fp' to stderr. Per Stepan Kasal . + +Wed May 15 15:39:17 2002 Arnold D. Robbins + + Work through builtin operations to make sure that + anything that might have side effects gets dealt with. + + * array.c (do_delete): Evaluate subscript first before + checking if something is or isn't an array. + * builtin.c (sub_common): Evaluate replacement text, and + free it if no match of regex in source text. + +Wed May 15 15:30:34 2002 Arnold D. Robbins + + Switch to new version of regex from IBM Japan. + + * regcomp.c: New file. + * regex.c: Replaced with new version. + * regex.h: Replaced with new version. + * regex_internal.c: New file. + * regex_internal.h: New file. + * regexec.c: New file. + * Makefile.am (EXTRA_SOURCES): New files added. + +Tue May 14 17:04:05 2002 Arnold D. Robbins + + * awk.h (): Move check and include into gettext.h. + * gettext.h (): Add check and include per patch from + Bruno Haible. + + * field.c (do_split): When checking for split of null string, + evaluate seperator if it's not FS, since could have side effects. + At end, free_temp(fs), not free_temp(sep). + Both of these thanks to Stepan Kasal . + +Mon May 13 00:41:31 2002 Arnold D. Robbins + + * custom.h (ultrix): Add define GETGROUPS_NOT_STANDARD. + * main.c (init_groupset): For GETGROUPS_NOT_STANDARD, use old way + to set `ngroups'. + +2002-05-10 Andreas Schwab + + * dfa.c (parse_bracket_exp_mb): Fix warning. + +Thu May 9 22:28:32 2002 Arnold D. Robbins + + * builtin.c (sub_common): Fix logic for match of null strings to + get correct semantics. See test/gsubtst2.*. + * field.c (do_split): Minor code cleanup; the third arg to split() + is set to be FS by the grammar, so don't need to check it for NULL. + Thanks to Stepan Kasal . + * awk.h (locale.h): Move include before that of "gettext.h" for systems + that define functions that gettext.h would use when NLS is disabled. + Per bug report from Ayamura Kikuchi . + +Tue May 7 17:31:01 2002 Arnold D. Robbins + + Miscellanious patches courtesy of Stepan Kasal . + + * field.c, main.c: Tidy up some comments. + * field.c (set_FIELDWIDTHS): Init fw_alloc to 4 so it isn't + immediately realloced. + * main.c (load_procinfo): Check value of FS/FIELDWIDTHS for + value of PROCINFO["FS"]. + * awk.h (set_FS_if_not_FIELDWIDTHS): Removed decl. + * field.c (set_FS_if_not_FIELDWIDTHS): Removed function. + * eval.c (set_IGNORECASE): Use inline code checking `using_fieldwidths()'. + * io.c (set_IGNORECASE): Ditto. + +Sun May 5 14:28:34 2002 Arnold D. Robbins + + Fix a memory leak in array for loops if the body contains a + `next' or `nextfile' statement. The changes maintain a stack + of active for loops that is pushed and popped for each loop, + and popped entirely for `next', `nextfile', etc. + + * eval.c (forloops_active, pop_forloop, pop_all_forloops, push_forloop): + new functions. + (interpret): Case Node_K_arrayfor, call push and pop functions. + Case Node_rule_list: Pop loops and pop fcalls after longjmp. + Cases Node_K_next, Node_K_nextfile, Node_K_break and + Node_K_continue, removed check before longjmp. + Case Node_K_exit: Add loop check. + (loop_stack, nloops, nloops_active): New variables that implement + the stack. + +Wed May 1 16:41:32 2002 Arnold D. Robbins + + * Release 3.1.1: Release tar file made. + +Wed May 1 16:07:49 2002 Arnold D. Robbins + + * getopt.c: Installed latest version from glibc. + +Sun Apr 28 17:19:07 2002 Arnold D. Robbins + + * fixvers: Changed patterns to allow test versions of the + form `gawk-3.1.1a'. + * patchlev.h: Patchlevel is now a string constant. + * main.c (version): Print patchlevel using %s, not %d. + * Makefile.am: Rework DEFPATH stuff and datadir stuff yet again. + + * config.sub: Updated with current version from ftp.gnu.org. + * config.guess: Ditto. + + Upgrade to gettext-0.11.2: + + * ABOUT-NLS: Replaced with version from gettext 0.11.2. + * config.rpath: Replaced with version from gettext 0.11.2. + * intl/*: Replaced with version from gettext 0.11.2. + * po/Makefile.in.in: Replaced with version from gettext 0.11.2. + * po/Makevars.template: Replaced with version from gettext 0.11.2. + * po/Rules-quot: Replaced with version from gettext 0.11.2. + * po/boldquot.sed: Replaced with version from gettext 0.11.2. + * po/en@boldquot.header: Replaced with version from gettext 0.11.2. + * po/en@quot.header: Replaced with version from gettext 0.11.2. + * po/insert-header.sin: Replaced with version from gettext 0.11.2. + * po/quot.sed: Replaced with version from gettext 0.11.2. + * po/remove-potcdate.sin: Replaced with version from gettext 0.11.2. + * m4/codeset.m4: Replaced with version from gettext 0.11.2. + * m4/gettext.m4: Replaced with version from gettext 0.11.2. + * m4/glibc21.m4: Replaced with version from gettext 0.11.2. + * m4/iconv.m4: Replaced with version from gettext 0.11.2. + * m4/isc-posix.m4: Replaced with version from gettext 0.11.2. + * m4/lcmessage.m4: Replaced with version from gettext 0.11.2. + * m4/lib-ld.m4: Replaced with version from gettext 0.11.2. + * m4/lib-link.m4: Replaced with version from gettext 0.11.2. + * m4/lib-prefix.m4: Replaced with version from gettext 0.11.2. + * m4/progtest.m4: Replaced with version from gettext 0.11.2. + +Wed Apr 17 15:09:45 2002 Arnold D. Robbins + + * regex.c (PREFIX): Change test for token concatenation ability + to `#ifdef HAVE_STRINGIZE'. If a cpp has one, it ought to have + the other. + +Tue Apr 16 12:26:06 2002 Arnold D. Robbins + + * profile.c (tree_eval): Make unary minus case smarter, + use is_scalar test and if false parenthesize expression. + Add Node_TEXTDOMAIN case. + (pp_lhs, is_scalar, prec_level): Add Node_TEXTDOMAIN cases. + +Thu Apr 11 21:28:33 2002 Arnold D. Robbins + + * array.c (do_adump): Spelling fix in output message. + * builtin.c: Ditto, in multiple routines. + (do_toupper, do_tolower): Add cast to size_t in assigment to mbclen + for some compilers. + * re.c (research): Fix way returning is done to silence some + compiler diagnostics. + +Wed Apr 10 19:30:51 2002 Arnold D. Robbins + + * Makefile.am (datadir): Set directly to have `/awk'. + (DEFPATH): Go back to using $(datadir) for path. + +Tue Apr 9 17:34:09 2002 Arnold D. Robbins + + Upgraded to gettext 0.11.1. + + * Makefile.am (LDADD): Use @LIBINTL@ instead of @INTLLIBS@. + * ABOUT-NLS: Version from 0.11.1. + * config.rpath: Version from 0.11.1. + * aclocal.m4: Regenerated based on new files. + * intl/*: Replaced with version from 0.11.1. + * m4/ChangeLog: New file. + * m4/codeset.m4: New file. + * m4/gettext.m4: Version from 0.11.1. + * po/ChangeLog: New file. + * po/Makefile.in.in: Version from 0.11.1. + * po/remove-potcdate.sin: New file. + +Mon Apr 8 22:22:58 2002 Arnold D. Robbins + + * Makefile.am (libexecdir): Set directly to have `/awk'. + (DEFPATH): Use $(pkgdatadir) for path. + (install-exec-hook): Add version link for pgawk. + (uninstall-links): Remove pgawk version link. + +Wed Mar 20 13:44:21 2002 Isamu Hasegawa + + * regex.c (__alignof__): Definition for non-GCC compilers. + +Sun Mar 17 17:41:55 2002 Arnold D. Robbins + + * io.c (do_pathopen): Malloc buffers to hold constructed + filenames: No Arbitrary Limits! Thanks to keoki@techie.com + for the bug report. + +Sun Mar 10 16:59:06 2002 Scott Deifik + + * awk.h (LOCALEDIR): Provide a definition in case not using + i18n stuff. + +Wed Mar 6 18:14:44 2002 Arnold D. Robbins + + * main.c (usage): Add some explanatory text and examples at end. + +Sun Mar 3 16:42:50 2002 Arnold D. Robbins + + * getopt.h, getopt.c, getopt1.c: Update to current version + from glibc CVS. + +Fri Feb 22 15:53:38 2002 Isamu Hasegawa + + * dfa.c (fetch_wc): Fix type from wchar_t to wint_t. + (parse_bracket_exp_mb): Likewise. + * regex.c (extract_number): Retrieve the sign information from + byte-code in case of AIX. + +Thu Feb 21 16:44:24 2002 Arnold D. Robbins + + * re.c (resetup): Moved setting re_max_failures into regex.c. + * regex.c (re_max_failures): Set to really big if REGEX_MALLOC + defined. Do this in both places that define re_max_failures. + +Thu Feb 21 19:02:22 2002 Isamu Hasegawa + + * builtin.c (sub_common): Avoid index_multibyte_buffer invocation + in single byte character environments. + +Thu Feb 21 10:08:56 2002 Isamu Hasegawa + + * dfa.c (parse_bracket_exp_mb): For ':', use wctype_t in MALLOC, + not wchar_t. + +Thu Feb 21 09:52:16 2002 Arnold D. Robbins + + Upgraded to automake 1.5 and gettext-0.11. + Also bug fix to multibyte code. + + * ABOUT-NLS: Upgraded. + * config.guess, config.sub, config.rpath, gettext.h, ylwrap: New files. + * Makefile.am: Added above to appropriate places. + * awk.h: Replace libintl.h and macros with include of gettext.h. + (emalloc, erealloc): Add num bytes to error message, put string inside _(). + (index_multibyte_buffer): Removed decl. + * awklib/Makefile.am: Use $(EXEEXT) for grcat and pwcat targets. + * builtin.c (index_multibyte_buffer): Made static to this file. + (sub_common): Add checks that replacement string is length > 0 so + that we don't try to malloc(0): this fails on some systems. + * configure.in (AM_GNU_GETTEXT): Update macro for gettext 0.11. + (ALL_LINGUAS): Removed. + * m4/codeset.m4: New file. + * m4/gettext.m4: Updated. + * m4/glibc21.m4: New file. + * m4/iconv.m4: New file. + * m4/isc-posix.m4: New file. + * m4/lcmessage.m4: Updated. + * m4/lib-ld.m4: New file. + * m4/lib-link.m4: New file. + * m4/lib-prefix.m4: New file. + * m4/progtest.m4: Updated. + * intl/*: Replaced with version from gettext 0.11. + * po/*: Revised for gettext 0.11. + +Mon Feb 18 14:42:39 2002 Arnold D. Robbins + + * builtin.c (nondec2awknum): Change assert to runtime check + in case user passed in bad data. + +2002-02-17 Paul Eggert + + * re.c (resetup): Try to avoid silly limitation of regex.c by + setting re_max_failures to the largest reasonable value. + +Sun Feb 17 14:57:43 2002 Arnold D. Robbins + + * builtin.c (research): If re_search() returns -2, the + match failed since regex couldn't allocate enough memory + for what it needed. Fail with a fatal message instead. + This is a workaround, not a fix, but I don't mess with + regex.[ch]. + +Fri Feb 8 16:01:11 2002 Arnold D. Robbins + + * awkgram.y (LEX_FOR): Fix case of array loop with body of single + delete statement to actually check the right things to make the + optimization. + * profile.c (tree_eval): Add case for Node_K_delete_loop. + (prec_level): Ditto. + +Mon Feb 4 10:38:00 2002 Bruno Haible + + * awk.h (dcngettext): New macro. + (do_dcngettext): New declaration. + * awkgram.y (tokentab): Add dcngettext. + (snode): Add a warning for incorrect use of dcngettext. + (dumpintlstr): fflush at the end, not in the middle. + (dumpintlstr2): New function. + * builtin.c (localecategory_from_argument): New function, extracted + from do_dcgettext. + (do_dcgettext): Call it. + (do_dcngettext): New function. + +Sun Feb 3 17:56:20 2002 Bruno Haible + + * builtin.c (do_bindtextdomain): Don't free the same variable twice. + * main.c (main): Call setlocale for LC_MESSAGE, to make dcgettext + function work on glibc systems. + +Wed Jan 23 15:03:36 2002 Andreas Buening + + * configure.in (PATH_SEPARATOR): Code added for OS/2. + Makefile.am (PATH_SEPARATOR): Added. + (DEFPATH): Make use of PATH_SEPARATOR. + +Wed Jan 23 14:46:04 2002 Arnold D. Robbins + + * awkgram.y (yylex): Add test for lasttok != '$' when looking + at _"...". See comments in code. + +Wed Aug 15 07:43:10 2001 Isamu Hasegawa + + * regex.c : Implements the codes for exactn_bin to work correctly + in multibyte environments, in case of invalid multibyte sequence. + +Wed Aug 15 07:36:56 2001 Isamu Hasegawa + + * regex.c : Implements the codes for charset/charset_not to + work in multibyte environments. + +Wed Aug 15 05:04:34 2001 Isamu Hasegawa + + * regex.c : Add some comments. + +Wed Aug 15 05:04:15 2001 Isamu Hasegawa + + * regex.c (count_mbs_length): New function, check the mutibyte + strings and count how many wchar_t the substring occupy. + (CHAR_T): New macro, character type depending on + environments(singlebyte/multibyte). + (UCHAR_T): New macro, unsigned character type. + (COMPILED_BUFFER_VAR): New macro, the buffer containing + the compiled buffer. + Adapt singlebyte/multibyte environments with CHAR_T, UCHAR_T, + and COMPILED_BUFFER_VAR. + +Mon Jun 25 09:00:41 2001 Isamu Hasegawa + + * regex.c : Reorganize code to build code twice. byte_* are + for single byte, wcs_* are for multibyte character sets. + Chose functions according to current locale dynamically. + * regex.c (convert_mbs_to_wcs): New function, convert multibyte + strings to wide character strings for multibyte environments. + +Fri Jun 22 05:43:50 2001 Isamu Hasegawa + + * regex.c (MBS_SUPPORT): New macro, defined if the environment + can handle multibyte characters. + (OFFSET_ADDRESS_SIZE): Offset address size in the + compiled buffer. + Rewrite offset addresses with OFFSET_ADDRESS_SIZE. + +Thu Apr 26 08:03:17 2001 Isamu Hasegawa + + * builtin.c (index_multibyte_buffer): Inspect the buffer and write + the index. + (sub_common): In multibyte environment, skip multibyte characters + when we check special characters. + * awk.h (index_multibyte_buffer): Add prototype. + * eval.c (cmp_nodes): In multibyte environment, compare per character. + * field.c (re_parse_field): In multibyte environment, avoid to + call research() on invalid boundary. + (sc_parse_field): In multibyte environment, avoid to compare on + invalid boundary. + (null_parse_field): In multibyte environment, split per + character, not per byte. + * io.c (get_a_record): In multibyte environment, avoid to compare + on invalid boundary. + +Wed Apr 25 08:29:47 2001 Isamu Hasegawa + + * awk.h (strncasecmpmbs): Add prototype. + * builtin.c (strncasecmpmbs): New function like strncasecmp but for + multibyte strings. + (do_index): In multibyte environment, compare per character. + * builtin.c (do_tolower): In multibyte environment, user towlower + instead of TOLOWER. + (do_toupper): In multibyte environment, user towupper instead + of TOUPPER. + +Tue Apr 24 10:38:06 2001 Isamu Hasegawa + + In multibyte environments, handle multibyte characters as single + characters in bracket expressions. + + * dfa.h (mb_char_classes): New structure. + (mbcsets): New variable. + (nmbcsets): New variable. + (mbcsets_alloc): New variable. + * dfa.c (prtok): Handle MBCSET. + (fetch_wc): New function to fetch a wide character. + (parse_bracket_exp_mb): New function to handle multibyte character + in lex(). + (lex): Invoke parse_bracket_exp_mb() for multibyte bracket expression. + (atom): Handle MBCSET. + (epsclosure): Likewise. + (dfaanalyze): Likewise. + (dfastate): Likewise. + (match_mb_charset): New function to judge whether a bracket match + with a multibyte character. + (check_matching_with_multibyte_ops): Handle MBCSET. + (dfainit): Initialize new variables. + (dfafree): Free new variables. + +Mon Apr 23 01:40:09 2001 Isamu Hasegawa + + Implement the mechanism to match with multibyte characters, + and use it for `period' in multibyte environments. + + * dfa.h (mbps): New variable. + * dfa.c (prtok): Handle ANYCHAR. + (lex): Use ANYCHAR for `period' in multibyte environments. + (atom): Handle ANYCHAR. + (state_index): Initialize mbps in multibyte environments. + (epsclosure): Handle ANYCHAR. + (dfaanalyze): Handle ANYCHAR. + (dfastate): Handle ANYCHAR. + (realloc_trans_if_necessary): New function. + (transit_state_singlebyte): New function. + (match_anychar): New function. + (check_matching_with_multibyte_ops): New function. + (transit_state_consume_1char): New function. + (transit_state): New function. + (dfaexec): Invoke transit_state if expression can match with + a multibyte character in multibyte environments. + (dfamust): Handle ANYCHAR. + +Fri Apr 20 11:31:24 2001 Isamu Hasegawa + + Avoid incorrect state transition in multibyte environments. + + * dfa.h (nmultibyte_prop): New variable. + (multibyte_prop): New variable. + * dfa.c (addtok): Set inputwcs. + (dfastate): Avoid incorrect state transition in multibyte + environments. + (dfaexec): Likewise. + (dfainit): Init multibyte_prop. + (dfafree): Free multibyte_prop. + (inputwcs): New variable. + (mblen_buf): New variable contains the amount of remain byte + of corresponding multibyte character in the input string. + +Fri Apr 20 06:28:59 2001 Isamu Hasegawa + + Handle a multibyte character followed by '*', '+', and '{n,m}' + correctly. + + * dfa.c (update_mb_len_index): New function. + Support for multibyte string. + (FETCH): Call update_mb_len_index. + (lex): Check cur_mb_index not to misunderstand multibyte characters. + (atom): Make a tree from a multibyte character. + (dfaparse): Initialize new variables. + (mbs): New variable. + (cur_mb_len): New variable. + (cur_mb_index): New variable. + +Thu Apr 19 09:32:47 2001 Isamu Hasegawa + + * awkgram.y (cur_mbstate): New varialble containing means current + shift state. + (cur_char_ring): New varialbe reffering the buffer which contains + last some character from the buffer. + (cur_ring_idx): New variable containing the current index on + cur_char_ring. + (nextc_is_1stbyte): New macro, means that last nextc() return a + singlebyte character or 1st byte of a multibyte character. + (nextc): Check the buffer and update cur_ring_char in multibyte + environments. + (pushback): Adjust cur_ring_idx in multibyte environments. + (yylex): Add check whether nextc() returned 1st-byte in multibyte + environments. + * re.c (make_regexp): In multibyte environment, skip multibyte + characters when we check special characters. + +Wed Apr 18 07:58:20 2001 Isamu Hasegawa + + * awk.h (MBS_SUPPORT): New flag, means supporting multibyte strings. + * configure.in : Add check for wchar.h, wctype.h, mbrtowc, and mbrlen. + +Wed Jan 16 16:32:40 2002 Arnold D. Robbins + + * builtin.c (do_strtonum): Simplified. Check first if the + value matches a non-decimal number, and if so convert it. + Otherwise do a regular force_number. + +Mon Jan 7 22:12:15 2002 Arnold D. Robbins + + * awkgram.y (statement): Moved delete, print, and expressions into + new non-terminal `simple_stmt'. Allow opt_simple_stmt in the + first and third part of a for loop, per latest POSIX, which documents + an otherwise undocumented historical oddity in Unix awk. This has + the pleasant side effect of making line numbers more accurate for + messages involving delete statements. + (opt_simple_stmt, simple_stmt): New non-terminals. + + Based on bug report from drj@pobox.com. + +Mon Dec 24 14:04:02 2001 Arnold D. Robbins + + * configure.in: Changes for VMS with new strftime: + (AC_HEADER_TIME): Added. + (AC_CHECK_HEADERS): Check for sys/time.h. + (TIME_T_IN_SYS_TYPES_H): Add header check. + * acconfig.h (TIME_T_IN_SYS_TYPES_H): Added. + +Wed Dec 19 16:01:58 2001 Peter J. Farley III + + * configure.in: Add MS-DOS to getpgrp special case. + * dfa.c, getopt.c, regex.c: Fix code to work with --disable-nls. + +Wed Dec 19 15:59:25 2001 Eli Zaretskii + + * profile.c (init_profiling_signals) [__DJGPP__]: Use SIGINT + instead of SIGHUP and SIGQUIT instead of SIGUSR1. + +Tue Dec 18 20:56:07 2001 Andreas Buening + + More OS/2 stuff. + + * awk.h (O_BINARY): Don't redefine for EMX. + * io.c (gawk_popen): Add __EMX__ in case compiling DOS executable. + * configure.in: Add OS/2 to case for manual GETPGRP_VOID. + +Tue Dec 4 17:54:30 2001 Arnold D. Robbins + + New configure time option, --with-whiny-user-strftime. + + * configure.in (AC_ARG_WITH): Add appropriate code for autoconf. + * accondig.h (USE_INCLUDED_STRFTIME): Add #undef for it. + * custom.h (USE_INCLUDED_STRFTIME): Set things up write. + +Tue Dec 4 16:44:07 2001 Andreas Buening + + Mongo patch for updated OS/2 support. + + * awk.h (TOUPPER, TOLOWER): Define only if not already defined. + * awkgram.y (extproc feature): Add ifdef for __EMX__. + * gawkmisc.c (__EMX__): Include pc/gawkmisc.c directly. + * io.c (__EMX__): Added for a number of places in addition to OS2 def. + (two_way_open): Added OS/2 specific code added that uses spawn. + (gawk_popen): Ditto. + +Mon Dec 3 14:07:56 2001 Arnold D. Robbins + + Fix use of getgroups to use dynamic memory, solves + problem of systems where NGROUPS_MAX lies. + + * awk.h (groupset, ngroups): New extern variables. + * configure.in (AC_CHECK_FUNCS): Add getgroups to list. + * io.c (user_open): Use global ngroups and groupset variables, + don't call getgroups here. + * main.c (init_groupset): New function to init global + vars using malloc. Declare it at top. + (main): Call init_groupset(). + (load_procinfo): Use global ngroups and groupset variables. + +Sun Nov 18 11:56:01 2001 Arnold D. Robbins + + * random.c (srandomdev): ifdef-out. Lots of compile time + problems on multiple platforms, and gawk doesn't even + use the routine. The heck with fine-grained solutions. + +Wed Nov 14 16:12:40 2001 Pat Rankin + + * builtin.c (bchunk_one): Use `ofre < 1' instead of `ofre <= 0' + to avoid compiler complaint about suspicious comparison for + unsigned variable. (`ofre == 0' ought to suffice...) + +Tue Nov 13 17:27:52 2001 Arnold D. Robbins + + * awkgram.y (yyerror): Fix the code to behave like it + used to. Keep "no arbitrary limits" by mallocing the + buffer and freeing it. + +Wed Nov 7 16:46:20 2001 Arnold D. Robbins + + * awkgram.y (yyerror): Remove dependency upon buf[] to + hold prepended space and `^' pointer. Avoids core dumps + for long source lines. + +Sat Nov 3 22:27:21 2001 Arnold D. Robbins + + * m4/strtod.m4: Add missing `#endif'. Oops. + +Mon Oct 29 14:53:57 2001 Arnold D. Robbins + + * awkgram.y: Add semicolons in calls to count_args(). + Apparently bisoon adds a semicolon to each body + automatically and byacc doesn't. + +Sun Oct 28 16:53:18 2001 Arnold D. Robbins + + * builtin.c (format_tree): Fix off-by-one error in "ran out + for this one" diagnostic. Also fix lint check for too many + arguments vs. count in format string. + +Wed Oct 10 11:01:47 2001 Arnold D. Robbins + + * fixvers: Check that files exist before doing `cmp', in + case they're in a source code system and aren't there. + Fix from Grant Erickson (gerickson@brocade.com). + +Thu Oct 4 18:20:36 2001 Arnold D. Robbins + + * eval.c (r_tree_eval): For comparison, dupnode() results of + evaluation so that we can hang on to them and avoid memory + corruption. Change calls to free_temp() to unref(). + +Tue Sep 25 15:19:53 2001 Arnold D. Robbins + + * io.c (iop_open): Only call os_close_on_exec() for + fd > fileno(stderr). + +2001-09-07 Paul Eggert + + * io.c (redirect): When deciding to use the fdopen bug hack, + use "__sun" rather than "solaris". No compilers predefine + "solaris", but both GCC and Sun C predefine "__sun". + +Thu Aug 30 15:17:12 2001 Arnold D. Robbins + + * main.c (copyleft): Use a printf %d for last year of update + to avoid translation strings changing when the file + is updated from now on. Suggestion from Ulrich Drepper. + +Thu Aug 23 14:01:14 2001 Arnold D. Robbins + + * awkgram.y (unary minus production): Add check that value + isn't a string. Based on bug report from drj@pobox.com. + * profile.c (tree_eval): For node_val, only test NUMBER + to see if value is numeric, not NUM|NUMBER. + +Thu Aug 16 12:21:28 2001 Arnold D. Robbins + + * configure.in (ALL_LINGUAS): Added `fr' and `tr'. + * po/fr.po, po/tr.fo: New files. + +2001-08-13 Paul Eggert + + This patch fixes a bug that causes gawk to rewind standard + input incorrectly. It also removes all instances of fseek, + from the gawk source proper, which should make gawk a bit + more portable. + + (The original patch removed off_t & lseek too, but I need + that for something else. ADR.) + + * posix/gawkmisc.c (optimal_bufsize): + Don't use lseek on the input, because that might change + its state. Instead, just check whether it is a regular file. + This obviates the need to invoke isatty. + (Also, fix a spelling error in the first line of the source.) + * pc/gawkmisc.pc, unsupported/atari/gawkmisc.atr: Likewise. + + * awk.h (S_ISREG): Move this macro here ... + * io.c (S_ISREG): from here. + + * protos.h (fseek): Remove prototype; no longer used. + +Fri Aug 3 13:38:54 2001 Arnold D. Robbins + + * array.c (assoc_lookup): Change assert test on type to real test + to protect against FS[1] = "x" kinds of things. It'd be better + to do this in the grammar, but this is easier and just as + effective. + + Undid BECAMEARRAY changes of 25 June 2001 in favor of correct code: + * eval.c (pop_fcall): Change test and comment for freeing n->vname. + (flags2str): Removed BECAMEARRAY entry. + * awk.h (BECAMEARRAY): Removed define. + * array.c (assoc_lookup): Removed setting of BECAMEARRAY flag. + +Mon Jul 23 17:33:13 2001 Arnold D. Robbins + + * io.c (get_a_record): Handle case where RS = "" and input file + is only newlines. See test/onlynl. Bug report by + Michel Jouvin . + +Wed Jul 4 18:34:19 2001 Arnold D. Robbins + + * eval.c (assign_val): Don't allow negative values for NF. + * field.c (set_NF): Robustify field-freeing code to make sure + values are always positive. + +Sun Jul 1 19:15:01 2001 Arnold D. Robbins + + * builtin.c (do_index): If second string is "", return 1. + +Mon Jun 25 19:34:24 2001 Arnold D. Robbins + + Further rationalization of treatment of dynamic regexes, + so that profiling code works correctly. + + * awk.h (NODETYPE): New type, Node_dynregex. + * awkgram.y (mk_rexp): Use Node_dynregex. + * eval.c (nodetypes): Add Node_dynregex. + (r_tree_eval): Add Node_dynregex to case for match_op(). + * profile.c (tree_eval): Add Node_dynregex to case for pp_match_op(). + (pp_match_op): Handle Node_dynregex, simplify cases for ~ and !~. + * re.c (re_update): Add assertion that type is Node_regex when flags + indicate CONST. + + New lint warning. + + * awkgram.y (yylex): Added lint warning that constant with leading + zero is treated as octal or hex. + + Generalized code for those who are Strong In The Ways of the Source. + + * awk.h: New boolean variable. + * main.c (main): Set it. + * eval.c (interpret): For arrays, check it. Remove variable 'first', + not needed anymore. + * profile.c (pp_string_fp): Enable printing of non-ASCII characters + verbatim if variable set. + + Fix memory corruption on SCO for array vars as params changed globally. + + * awk.h (BECAMEARRAY): New flag. + * array.c (assoc_lookup): Set the flag as appropriate. + * eval.c (flags2str): Add the flag. + (pop_fcall): Check the flag, don't free memory if set. + +Wed Jun 13 18:07:06 2001 Arnold D. Robbins + + * eval.c (fmt_index): Actually call erealloc() to grow fmt_list + if that's really necessary. Bug report from David Jones, + djones@zoonami.com. + +Sun Jun 10 14:24:48 2001 Arnold D. Robbins + + * profile.c (pp_match_op): Rationalized the code. + +Thu Jun 7 11:54:36 2001 Arnold D. Robbins + + * awk.h (O_BINARY): Don't define if already defined + (as is true for cygwin/gcc --- oops). + +Sun Jun 3 13:04:44 2001 Arnold D. Robbins + + * Release 3.1.0: Release tar file made. And there was + rejoicing. + +Wed Apr 25 11:44:07 2001 Arnold Robbins + + * Makefile.am (AM_MAKEFLAGS): Add definition per advice from + Nelson Beebe. + +Tue Apr 24 14:28:00 2001 Arnold Robbins + + * io.c (devopen): Patch from Jeurgen to robustify pulling + out hostname, port numbers, etc, to avoid any buffer overrun + problems. + +Mon Apr 23 10:26:38 2001 Arnold Robbins + + * awkgram.y: Fix grammar so that `print ... |& ".." |& getline' + dies with a parse-time error message. + +Sun Apr 22 16:46:48 2001 Arnold Robbins + + * io.c (socketopen): Fix from Juergen in recursive call. + +Thu Apr 19 18:39:20 2001 Pat Rankin + + * awk.h: Really fix logic around include of . + + * awk.h (callresult): New name for `result' macro. + * eval.c (r_get_lhs, case Node_builtin): Use it. + +Thu Apr 19 16:31:09 2001 Pat Rankin + + * io.c: Move code around to allow compilation with DEC C. + +Thu Apr 19 16:21:56 2001 Arnold D. Robbins + + * random.h: Move decl of random() here. + * random.c: Remove decl of random(). + +Mon Apr 9 11:41:58 2001 Arnold D. Robbins + + * dfa.c (dfainit): Initialize more members in the structure, + based on bug report in bug.gnu.utils by aaronl@vitelus.com + (Aaron Lehmann). + * awk.h: Fix logic around include of . + +Thu Apr 5 20:12:05 2001 Pat Rankin + + * dfa.c: For VMS, #include instead of . + * missing_d/mktime.c: Likewise. + + * random.c: Reorder include directives to get gawk config info + from random.h sooner. + [fcntl.h]: Guard #include with HAVE_FCNTL_H test. + [unistd.h]: Guard #include with HAVE_UNISTD_H test. + + * random.c (srandomdev): Skip /dev/urandom usage if O_RDONLY + is not defined. + +Tue Mar 20 11:07:11 2001 Arnold D. Robbins + + * awkgram.y (function_body): Add opt_nls to end of production. + +Tue Mar 20 09:30:32 2001 Pat Rankin + + * awk.h (BROKEN_STRNCASECMP): Add decl of strcasecmp. + * io.c (two_way_open): Add `return FALSE;' for fussy compilers. + +Sun Mar 18 15:10:56 2001 Arnold D. Robbins + + * io.c (gawk_pclose): Set the exit value for close correctly + if the pipe died with a signal. + +Wed Mar 7 11:28:52 2001 Arnold D. Robbins + + * io.c (get_a_record): Correctly handle the case of a leading + single newline at the front of the file when RS = "". + +2001-02-26 Paul Eggert + + * COPYING: Incorporate latest version from FSF, which fixes a Y2k bug. + + * builtin.c (do_mktime): Allow the user to specify the + tm_isdst member as an optional trailing integer, and to + specify "out-of-range" members. Check for overflow when + subtracting 1 from month or 1900 from year. Allow years just + past INT_MAX, as they work on some hosts when INT_MAX - 1900 + is representable as an int. + + * doc/gawk.1, doc/gawk.texi: Document the above changes. + Also, document that the origin-zero Gregorian calendar is used. + Fix confusing wording about "midnight" by replacing it with 00:00 + ("midnight" is also 24:00, the end of the day). + Mention the typical range for time stamps. + Do not assume that years are nonnegative and are less than 10,000. + Suggest TZ=UTC0 instead of TZ=GMT0, as that's how recent versions + of GNU date behave. + GMT is not always the time of day in Greenwich these days. + Fix typos: "Emporer/Era", "1980's", "1970's". + + * m4/largefile.m4: Synchronized with latest version. + +Tue Feb 27 12:10:11 2001 Arnold D. Robbins + + * profile.c (pp_in_array): Change test to tree->type == Node_expression_list. + +Wed Feb 7 14:46:50 2001 Arnold D. Robbins + + * awkgram.y (LEX_FOR): Allow newline after `;' in for loops. + Per bug report from Brian Kernighan, bwk@research.bell-labs.com. + +Tue Feb 6 18:35:27 2001 Martin C. Brown + + * io.c (socket_open): Conditionalize various options based on + ifdef. Needed for BeOS port. + +Tue Feb 6 18:17:13 2001 Michal Jaegermann + + * regex.c (re_match_2_internal): Case maybe_pop_jump, for + charset and not_charset: Change cast from (unsigned char) + to (unsigned). Catches last 8 chars with high bit set + if backtracking. See test/rebt8b1.awk, test/rebt8b2.awk. + +Tue Feb 6 11:20:21 2001 Arnold D. Robbins + + Have `for (iggy in foo)' save the elements and loop over them. + Make sorted for loops a dynamic test instead of a compile time test. + Still requires being Strong In The Ways Of The Source. + + * awk.h: (struct search): Removed. + (assoc_scan, assoc_next): Removed declarations. + * array.c (assoc_scan, assoc_next): Removed functions. + * eval.c (interpret): Remove Node_K_array_sorted_for. Change code + at Node_K_arrayfor. + (nodetypes): Remove Node_K_array_sorted_for. + * configure.in: Removed array sorting test. + * awkgram.y: Removed sorted_in keyword and associated code. + +Sun Feb 4 14:57:49 2001 Arnold D. Robbins + + * eval.c (interpret): Use tree->rnode->exec_count to hold count of + times if was true. + profile.c (interpret): Ditto. + * main.c (pre_assign): Gross hack. malloc fresh copy of assign so can + clear the '=', otherwise screws up profiling print out. + +Sun Jan 28 16:16:02 2001 Arnold D. Robbins + + Per request from Nelson Beebe, SIGHUP to pgawk dumps profile + and function call stack and exits, SIGUSR1 dumps and continues + running. + + * eval.c (dump_fcall_stack): New function, dumps awk function call + stack. + * awk.h (dump_fcall_stack): Add declaration. + (init_profiling_signals): Ditto. + * main.c (main): Call init_profiling_signals. + * profile.c (init_profiling_signals, dump_and_exit, just_dump): New + functions. + +Sun Jan 28 15:50:02 2001 Eli Zaretskii + + * io.c (gawk_popen): Restore the mode of stdin before running the + child process and switch it back if BINMODE is in effect after the + child returns. + (redirect): Restore the mode of stdin before running the child + process. + (close_redir): Switch mode of stdin back to binary if BINMODE is + in effect, after the child returns. + + * builtin.c (do_system): Restore the mode of stdin before running + the child process and switch it back if BINMODE is in effect after + the child returns. + + * awk.h (os_restore_mode): Add prototype. + +Thu Jan 18 14:03:06 2001 Arnold D. Robbins + + * custom.h, README_d/README.ultrix: Fixes for Ultrix + from Juergen Kahrs. + +Wed Jan 17 11:03:40 2001 Eli Zaretskii + + * io.c (redirect) [F_GETFL && O_APPEND]: Use binmode in the call + to fdopen. + +Mon Jan 15 16:29:52 2001 Arnold D. Robbins + + * profile.c (prec_level): Made Node_K_getline higher than < + but lower than others. Allows use of getline with redirection + inside an if. + +Wed Jan 10 15:35:06 2001 Arnold D. Robbins + + * eval.c (set_BINMODE): Rationalized string assignment. + +Sun Jan 7 15:26:16 2001 Arnold D. Robbins + + * getopt.h: Removed names in prototypes for getopt_long + and getopt_long_only, fixes problems on MINGW32. + +Thu Jan 4 10:13:46 2001 Arnold D. Robbins + + * configure.in: Add check for mcheck.h + * main.c: Include mcheck.h if have it. + (main): If TIDYMEM turned on in environment, also call mtrace(). + +Wed Jan 3 16:41:33 2001 Arnold D. Robbins + + Fixed minor memory leaks. + * re.c (re_update): When IGNORECASE changed, unref(t->re_text). + * eval.c (pop_fcall): Fix the logic to correctly free the vname + when copying array args back to their underlying source. + + Fixed massive memory leaks. + * node.c (dupnode): If PERM is set, do nothing. + (unref): Fix logic. Always turn off TEMP. Check just for MALLOC + when incrementing the stref. + * array.c (assoc_lookup): Turn off PERM also when saving subscript. + * builtin.c (sub_common): Turn off PERM also when making private copy + of string. + + Add a minor memory cleanup facility (undocumented): + * awk.h (do_tidy_mem, release_all_vars): Add declarations. + * main.c (do_tidy_mem): Add declaration. + (main): If $TIDYMEM exists, do_tidy_mem is true, and call mtrace(). + * awkgram.y (release_all_vars): New function. + +Sun Dec 31 10:47:37 2000 Arnold D. Robbins + + * awkgram.y (in_end_rule): Renamed `parsing_end_rule' to avoid + conflict with global var of same name. + +Sun Dec 24 10:36:54 2000 Eli Zaretskii + + * awkgram.y (snode): Reword the error message about the number of + arguments for a builtin, so as not to use the English `s' as a + plural suffix. + +Tue Dec 12 08:38:03 2000 Arnold D. Robbins + + * ext.c (do_ext): ifdef out use of `dummy'. Duh. + * regex.c (re_error_msgid): Revert to array of `char *' so that can + compile on K&R compilers. Fix all uses appropriately. + (re_error_msgid_idx): Removed. + +Fri Dec 8 11:47:26 2000 Arnold D. Robbins + + * ext.c (dummy): Make gcc specific via ifdef. + * builtin.c (do_dcgettext): Make conditional compilation smarter. + * msg.c (warning, error, r_fatal): Finish switching back to + multi-version function header. + +Wed Dec 6 13:28:58 2000 Arnold D. Robbins + + * random.h: Include to get ssize_t definition. + * awkgram.y (yyerror): Restore multi-version function header, + it seems that what ansi2knr produces doesn't quite do the + job on old compilers. + msg.c (msg): Ditto. + +Tue Dec 5 15:05:35 2000 Arnold D. Robbins + + * configure.in (AC_C_INLINE): Added macro call. + * Makefile.am (LN): Define it for install hooks. + +Sun Dec 3 17:28:53 2000 Arnold D. Robbins + + * awk.h (os_setbinmode): Declare new function. + (setmode): Remove definition: conflicts with MacOS X. + * main.c (main): Change call of setmode to os_setbindmode. + + * builtin.c (do_dcgettext): Improve ifdef for code, fixes MacOS X. + * custom.h (__APPLE__): Force definition of HAVE_MKTIME, won't + link otherwise. Harumph. + +Sun Nov 26 11:58:52 2000 Arnold D. Robbins + + * builtin.c (do_dcgettext, do_bindtextdomain): Add calls to + free_temp the various arguments. Sigh. + * io.c (yylex): Nuked bstart variable, put all uses of mend variable + into TANDEM ifdef. + * main.c (load_environ): Removed cp variable, value never used. + * random.c: Remvoed uses of `inline' keyword. + * Makefile.am (install-exec-hook, uninstall-local): New targets. + Adds creation of gawk-X.Y.Z and awk links, as in 3.0.x. + * configure.in (GAWK_AC_TYPE_SSIZE_T): Added. + m4/ssize_t.m4: New file. + +Wed Nov 22 14:47:18 2000 Arnold D. Robbins + + After consultation with Brian Kernighan and Michael Brennan, + nuked the abort keyword. + + * awk.h (Node_K_abort): Removed. + * eval.c (aborting): Removed decl. + (interpret): Removed Node_K_abort case. + * io.c (do_input): Removed checks for aborting. + * main.c (aborting): Removed. + (main): Removed checks for aborting. + * profile.c (pprint): Removed Node_K_abort case. + * awk.y (LEX_ABORT): All stuff removed. + +Wed Nov 22 10:45:57 2000 Arnold D. Robbins + + * ext.c (dummy): Move inside #ifdef DYNAMIC. Helps on + PCs and other platforms that don't do dynamic loading. + * awk.h (RED_TCP): New flag, means use shutdown. + io.c (redflags2str): Add RED_TCP. + (SHUT_RD, SHUT_WR, SHUT_RDWR): Add conditional defines. + (redirect): Add RED_TCP to tflag if appropriate. Add more + #ifdef HAVE_SOCKETS as needed. + (close_redir): If RED_TCP set, shutdown(2) on each end of the socket. + +Tue Nov 21 16:25:41 2000 Arnold D. Robbins + + * awk.y: for (iggy in foo) loops: Add test that index + in delete statement is a simple variable. + +Tue Nov 14 16:11:39 2000 Arnold D. Robbins + + * awk.h: Add appropriate conditional versions of the gettext + functions if we don't have or if ENABLE_NLS + is not defined or zero. + * configure.in: Add check for libintl.h header. + + From Scott Deifik for PCs. + * awk.h (lintwarn): Call set_loc unconditionally, makes + compilation work on PCs. + * builtin.c (do_dcgettext): Compile out cat_tab and code + if not ENABLE_NLS. + * ext.c: For MSC, no long long variable. + * random.c: Use clock() instead of gettimeofday(). + * builtin.c: Fixed prototypes for new random functions (ADR). + +Sun Nov 12 17:45:44 2000 Arnold D. Robbins + + * builtin.c (parse_next_arg): Fix call to >= num_args so + running out of args check is correct, instead of core dumping. + (format_tree): Save and restore `the_args' and `args_size' + if a nested call is in progress, see explanatory comment. + See also tests/addcomma. + * Makefile.am: Fix things so that gawk/pgawk built first, + even if `make check' called before make. Add some + commentary. + +Wed Nov 8 14:39:20 2000 Arnold D. Robbins + + * configure.in: Only add -rdynamic for Linux. + * dfa.h, dfa.c: Upgraded to versions in grep 2.4.2. + +Tue Nov 7 18:17:17 2000 Arnold D. Robbins + + * All: Switched to ANSI function headers and added + `ansi2knr' automake option. Really cool. + +Tue Nov 7 16:57:49 2000 Arnold D. Robbins + + * io.c (redirect): Check for O_APPEND in flags when doing + fdopen() of /dev/fd/N. Thanks to bug report from + "John H. DuBois III" . + +Tue Nov 7 14:09:14 2000 Arnold D. Robbins + + * awk.h (os_is_setuid): Declare function. + * main.c (main): Call it if do_lint and warn if true. + * awkgram.y (tokentab): + - Made sure all extensions are actually marked as such. Ouch. + - Changed "sort" to "asort". Potential to break too much old code. + * getopt.h, getopt.c, getopt1.c: Replaced with current versions + from glibc CVS archive. + +Mon Nov 6 18:14:33 2000 Arnold D. Robbins + + * random.c: Replaced with recent version from FreeBSD. + +Mon Nov 6 15:37:12 2000 Arnold D. Robbins + + Major simplification of automake machinery. + + * configure.in: + - INSTALL is forced only if not provided in environment + - lots of Makefile.in files removed since move to automake 1.4a + * Makefile.am, */Makefile.am: Moved directories that don't need + the automake machinery into EXTRA_DIST as appropriate and + removed the Makefile{,.am,.in} files as needed. + * eval_p.c, profile_p.c: New files to make it easier with automake + to compile pgawk. + +Tue Oct 24 12:20:18 2000 Arnold D. Robbins + + * awkgram.y (valinfo, var_comp, dump_vars): New functions to dump + the list of global variables. + * awk.h: Declare dump_vars. + * main.c (optab): New option "dump-variables". + (main): Code to handle it, set the output file and then call + dump_vars() at the end. + (usage): New option added to usage message. + +Sat Oct 21 22:59:59 2000 Arnold D. Robbins + + * awkgram.y (parms_shadow): For a function, check if any + parameters shadow global variables and print a warning. + (shadow_funcs): Go through all functions and call parms_shadow(). + (isnoeffect, isassignable): Add Node_LINT and NODE_BINMODE. + * main.c (main): If do_lint, call shadow_funcs(). + * awk.h: Add declaration of shadow_funcs(). + * configure.in: Added m4/Makefile and awklib/eg/network/Makefile + to list of generated makefiles. + +Tue Oct 17 10:47:35 2000 Arnold D. Robbins + + * array.c (assoc_lookup): Reverted change that did dupnode of + array indices. Creates significant problems if index is + numeric value and CONVFMT changes. Added fix to set + bucket->ahname->stfmt to -1 so that force_string never recalculates + the string value, and also turned off NUM and turned on STR. + See test/arynasty.awk. + +Mon Oct 16 12:21:26 2000 Arnold D. Robbins + + * All: Cleaned up various lint warnings for consistent phrasing. + * awk.y (in_end_rule): New variable for warning about unredirected + getline. It's ok in a BEGIN, but not in an END. + +Sun Oct 15 14:14:05 2000 Arnold D. Robbins + + * field.c (set_FS): Add lint warning for FS = "". + (do_split): Ditto for 3rd arg = "". + +Fri Oct 13 09:17:04 2000 Arnold D. Robbins + + * io.c (close_redir): Clear rp->fp on all closes. Remove + rp from list if either closing both ends or both ends + have been closed separately. Add exitwarn message for + co-process. + (flush_io): Add warning message if fflush of co-process + fails. Rationalize return value to either 0 or -1. + * builtin.c (do_gensub): 3rd arg of zero generates a + warning. + (do_fflush): Rationalize return value: -1 for unopen or read-only + redirection, status of fflush otherwise. + +Wed Oct 11 22:11:19 2000 Arnold D. Robbins + + * awk.y (for loop): Check that there is a body as + part of the `is it a delete statement' check. + +Thu Oct 5 11:56:42 2000 Arnold D. Robbins + + * awk.h, awkgram.y, configure.in, eval.c: Enabled + `for (i in_sorted array)' loops for those who + are Strong In The Way Of The Source. So there. + +Mon Oct 2 10:09:32 2000 Arnold D. Robbins + + * io.c (do_close): Make close(x) for non-open x return -1 + and update ERRNO. close(FILENAME) no longer does anything + magic; this is all for better consistency with other awks + and is more logical, anyway. + +Thu Sep 28 17:27:16 2000 Arnold D. Robbins + + * io.c (close_one): Added a lint warning if it becomes + necessary to start multiplexing fd's, per ancient suggestion + from Scott Deifik, . + +Tue Sep 26 14:41:41 2000 Arnold D. Robbins + + * profile.c: Move enum for redirection placement to top + of file, and make the value a parameter to pp_redir. + Fix all the calls. This gets `|&' right everywhere. + +Sun Sep 24 16:38:04 2000 Arnold D. Robbins + + * awk.h (freenode): Set the flags straight to UNINITIALIZED. + * node.c (unref): Fix test for MALLOC|TEMP to test the + actual flags, not zero. + * builtin.c (format_tree): ala print and concat, dupnode + the temp nodes from tree_evaling the arguments. See + test/nasty2.awk. + +Mon Sep 18 10:16:58 2000 Arnold D. Robbins + + * awkgram.y (snode): Make match 3rd arg and close 2nd arg fatal + errors if --tradtional. + +Thu Sep 14 12:22:42 2000 Arnold D. Robbins + + * eval.c (update_ERRNO): Call gettext on result of strerror. + i18n rules. + +Wed Sep 13 14:56:11 2000 Arnold D. Robbins + + * eval.c (r_tree_eval): Case for Node_concat. Dupnode the + strings ala do_print to get more consistent results. + Compare gawk 3.0.6 to nawk/mawk on test/nasty.awk. + Thanks to Andrew Sumner (andrewsumner@yahoo.com) for + pointing this one out. + +Wed Sep 13 10:06:47 2000 Arnold D. Robbins + + * io.c (two_way_close_type): New enumerated type. + (close_redir): New third param of type two_way_close_type. + Add smarts to two-way case for different close types. + Only remove it from the redir list if closing is for both ends. + (gawk_pclose): Check that rp->iop != NULL before closing, + all three versions. + * awkgram.y (tokentab): Allow 2nd argument to close. + (snode): Add lint warning. + +Sun Sep 10 14:16:10 2000 Arnold D. Robbins + + * field.c (set_FIELDWIDTHS): Generate a fatal error upon + encountering a negative width. + +Sun Sep 10 10:37:35 2000 Arnold D. Robbins + + * awkgram.y (snode): If first argument to dcgettext is a + string constant and --gen-po, dump the string constant to + the .po file too. + * main.c (nostalgia): Add call to fflush(stderr). + * eval.c (r_tree_eval): Add entries for Node_LINT and for + NODE_TEXTDOMAIN. + +Thu Sep 7 10:46:20 2000 Arnold D. Robbins + + * builtin.c (do_dcgettext): Per suggestion from Ulrich Drepper, + make the awk interface: + + str = dcgettext(string [, domain [, category]]) + +Wed Sep 6 16:28:12 2000 Arnold D. Robbins + + Bring gettext features out to the awk level! + + * awk.h: Add declarations of new functions `do_dcgettext' + `do_bindtextdomain', `set_TEXTDOMAIN' and variables + `TEXTDOMAIN', `TEXTDOMAIN_node'. New NODETYPE enum + `Node_TEXTDOMAIN'. + * eval.c (nodetypes): Add Node_TEXTDOMAIN at end. + (set_TEXTDOMAIN): New function. + (r_get_lhs): Add case for Node_TEXTDOMAIN. + * main.c (varinit): Add entry for TEXTDOMAIN. + * node.c (format_val): If INTLSTR use dcgettext of string + and TEXTDOMAIN. + * awkgram.y (tokentab): Add entries for "dcgettext" and + "bindtextdomain". + * builtin.c (do_dcgettext, do_bindtextdomain): New functions. + +Tue Sep 5 17:01:34 2000 Arnold D. Robbins + + * profile.c (pp_string_fp): Use lower case versions of + isascii and isprint to avoid printing high-bit-set + characters. Make it smarter to break strings at 70 + chars or after embedded newline, for --gen-po. + Fix the calls to it everywhere for new boolean option + to yes/no break lines. + * m4/strtod.m4: New file, defines GAWK_AC_FUNC_STRTOD_C89. + * configure.in: GAWK_AC_FUNC_STRTOD_C89 call added + * acinclude.m4: Include strtod.m4. + * acconfig.h: Add entry for STRTOD_NOT_C89. + Remove entries for BITOPS and NON_DEC_DATA. + * missing/missing.c: Add check for STRTOD_NOT_C89, use ours + if set. + * missing/strtod.c: Make smarter for input like 0x345. + * awk.h: [STRTOD_NOT_C89]: Define strtod gawk_strtod to get + our version. Avoids linker weirdness. + +Mon Sep 4 09:16:43 2000 Arnold D. Robbins + + * field.c (set_record): Fix from Utz-Uwe Haus + to make sure there's + always enough room in the record. + * builtin.c (nondec2awknum): Fix octal conversions to exit + when hitting a non-digit, and not go to decimal. Make + check for non-octal better. Based on bug report from + Morris_Lee@tvratings.com. + +Sun Sep 3 13:52:11 2000 Arnold D. Robbins + + * builtin.c (format_tree): Allow positional parameters for + %*.* kinds of things. + + Made octal/hex constants and strtonum on by default. Made + --enable-non-decimal-data a runtime switch `--non-decimal-data'. + + * configure.in: Removed AC_ARG_ENABLE for --enable-bitops and + --enable-non-decimal-data. + In .developing check, remove the AC_DEFINEs. + * awk.h: Decls for bitwise functions now there by default. + Add decl of `do_non_decimal_data'. + * main.c (do_non_decimal_data): New variable + (optlist): Add new entry for `--non-decimal-data'. + (main): Turn off `do_non_decimal_data' if `do_traditional'. + (usage): Add the new option. + * node.c (r_force_number): Make check for non-decimal data a + runtime check based on do_non_decimal_data. + * awkgram.y (yylex): Make non-decimal constants a runtime check. + * builtin.c: Remove the ifdefs around the bit functions and + nondec2awknum. + +Tue Aug 29 18:45:56 2000 Arnold D. Robbins + + * configure.in: Go back to ARRAYDEBUG if .developing set. + * awkgram.y: Use ARRAYDEBUG for adump(), use multiple tests + for stopme(). + +Mon Aug 28 17:09:06 2000 Arnold D. Robbins + + * field.c (do_split): Add check for first arg is null string, + if so, skip the work and return zero. + +Mon Aug 14 23:01:55 2000 Arnold D. Robbins + + Add %COUNT$... handling to printf. + + * awk.h (printf_count): New define in NODE structure. + (format_tree): Added decl. + * awkgram.y (count_args): New function to set printf_count in + a node. + [print productions]: Call the function. + * (snode): For do_sprintf, call count_args, set the count + in the lnode. + * builtin.c (format_tree): New fourth arg is argument count. + Add smarts to handle the `$' in a format. + * (do_sprintf): Use new argument to format_tree. + node.c (format_val): Ditto. + +Sun Aug 13 11:10:41 2000 Arnold D. Robbins + + Changes from Alan J. Broder (ajb@woti.com): + - Array third arg to match puts subtexts into the array: + + * awk.y (tokentab): "match" gets third arg, and lint warning + * builtin.c (do_match): If third arg there, fill it with subtexts + + - New builtin sort function: + + * awk.h (do_sort): Declared. + * array.c (do_sort, dup_table, merge, merge_sort, assoc_from_list, + assoc_sort_inplace): New functions. + + * eval.c (tree_eval): In debug code, make uninitialized var + a warning, not a fatal error. Breaks too many things. + +Wed Aug 9 10:51:41 2000 Arnold D. Robbins + + * eval.c (func_call): Increment the exec_count on the + function's node; this allows printing a call count for + functions. + profile.c (pp_func): Print the count for functions. + * ALL: Changed DEBUG to GAWKDEBUG in all gawk files, so that + I don't get regex/dfa debugging. In some cases, changed + memory-related stuff to MEMDEBUG. Still have work to do. + * awk.h, node.c, profile.c: Removed exec_count_init variable; + code has been cleaned up to not need different values for + profiling/not profiling. + +Thu Jul 5 21:10:59 2000 Arnold D. Robbins + + * eval.c (casetable): Removed the USE_PURE_ASCII stuff; it + was never documented. Latin 1 forever. + * main.c (main): Only call `init_profiling' after arg parsing + if `do_profiling' is still false. Avoids resetting `prof_fp' + back to stderr. + +2000-02-17 Akim Demaille + + * m4: New directory. + * acinclude.m4: Removed, replaced by m4/*.m4. + * Makefile.am: Adjusted. + Added ACLOCAL_AMFLAGS. + * configure.in Adjusted. + Use AC_SYS_LARGEFILE not GAWK_AC_SYS_LARGEFILE, jm_FUNC_MKTIME, + not GAWK_FUNC_MKTIME. + * acconfig.h: Removed _FILE_OFFSET_BITS, _LARGEFILE_SOURCE and + _LARGE_FILES now templated by m4/largefile.m4. + +2000-02-15 Arnold Robbins + + * MOVED TO AUTOMAKE AND GETTEXT. + Just about every file touched. Work done by Arno Peters. + +Sun Jan 2 14:48:23 2000 Arnold D. Robbins + + First edit of the new millenium! + * awk.y (yylex): If lint checking, be obnoxious about gotos. + +Mon Oct 25 19:12:02 1999 Arnold D. Robbins + + * awk.h: Remove C_ALLOCA ifdef. + * main.c (main): Remove C_ALLOCA code. + * io.c (do_input): Ditto. + +Mon Aug 9 17:36:24 1999 Arnold D. Robbins + + * bisonfix.sed: Unconditionally #undef YYSTACK_USE_ALLOCA. + * configure.in: Remove all alloca and ALLOCA related stuff. + * Makefile.in: Ditto. + +Thu Jul 29 18:32:05 1999 Arnold D. Robbins + + * awk.h (NODE): exec_count now in #ifndef NO_PROFILING. + * Makefile.in: Changes to only recompile eval.c and profile.c to a + special version for profiling. + * custom.h [MSC_VER]: Turn on NO_PROFILING to omit the exec_count + and save space. + * node.c (more_nodes): Move setting of exec_count to + #ifndef NO_PROFILING. + +Thu Jul 1 12:12:05 1999 Arnold D. Robbins + + * configure.in (AC_PREREQ): Update to 2.13. + GAWK_AC_C_STRINGIZE: convert to AC_C_STRINGIZE. + * aclocal.m4 (GAWK_AC_C_STRINGIZE): Remove definition, now + part of autoconf. + * acconfig.h (HAVE_STRINGIZE): Ditto. + +Wed Apr 28 11:08:05 1999 Arnold D. Robbins + + * array.c (assoc_lookup): Fix call to free_temp(subs) to after + last use of subs. + +Sun Apr 25 16:48:06 1999 Arnold D. Robbins + + * io.c (redirect): Add lint warning when same file is used for + > and >>. + +Thu Apr 22 15:05:30 1999 Arnold D. Robbins + + * array.c (assoc_lookup): Fix call to fatal to lintwarn instead. + * node.c (r_force_number): Use `0 &&' to disable warnings about + conversions: they're overzealous, methinks. + +Thu Apr 8 14:27:58 1999 Arnold D. Robbins + + New features for profiling: + + * awk.h (NODE): Add `exec_count' member. + (freenode): Clear `exec_count' upon free. + * awk.y (func_count): New variable, counts total number of functions. + (func_install): Increment func_count. + (struct finfo): Information for use in sorting functions when + pretty printing. + (fcompare): Compare two finfo structures. + (dump_funcs): Print the functions in sorted order for profiling. + (getfname): Return the name of a builtin function. + * eval.c (INCREMENT): New macro for counting execution of nodes. + (interpret): Call INCREMENT() appropriately. + * main.c (do_profiling): New flag if doing profiling. + `--profiling': New option added to getopt_long machinery. + (main): For profiled version, set do_profile and output file. + Call `dump_prog' and `dump_funcs' if do_profiling at end. + (usage): Add new argument. + * node.c (more_nodes, freenode): Set exec_count to zero. + * profile.c: New file, does pretty printing and prints counts. + * Makefile.in: Update to create two versions of gawk, regular + and `pgawk' which does profiling. + +Wed Mar 10 21:38:14 1999 Arnold D. Robbins + + * io.c (close_redir): Use update_ERRNO() instead of manually + doing it. + +Mon Dec 21 15:58:21 1998 Arnold D. Robbins + + * configure.in: Add BeOS to list of cases where we hardwire + GETPGRP_VOID. + custom.h: Remove the #define from __be_os case. Cleaner to + do it all in configure. Based on email from Martin C. Brown, + mc@whoever.com. + +Mon Nov 30 20:52:52 1998 Arnold D. Robbins + + * eval.c (update_ERRNO): New function, mainly for use by + extension functions. + * awk.h: Add decl. + +Tue Nov 24 18:13:29 1998 Arnold D. Robbins + + * Changes based on submission from Christos Zoulas at D.E. Shaw + that adds the following features: + - checking for use of uninitialized variables + - checking if a string that's not a number converts to 0 + - ability to load a dynamic library to add built-ins + - VERSION variable (may or may not stay) + Additional change: + - --lint=fatal makes lint errors become fatal + - LINT="fatal" has the same effect, any other positive + value makes lint errors be just warnings + * Makefile.in (includedir): New variable for gawk header files + (ext.c, ext.o): New source and object files + (OTHERS, extension): New directory for macro with example extension + (install): Install header files + * acconfig.h (DYNAMIC): New macro, true if can do dynamic loading + * array.c (assoc_lookup): New parameter `reference' is true if we + want to do reference checking. Add appropriate reference checking + code. + * awk.h (UNITITIALIZED): New flag + (lintfunc): Function pointer for correct function to use + (lintwarn): New macro to produce warnings + (result): New macro for func call result, used in commented out + code in eval.c. + (getnode, freenode): Revised to set UNINITIALIZED. + (get_lhs): Third arg for reference checking, change all calls + -- Add appropriate decls of new/changed functions + * awk.y (tokentab): New builtin "extension" for adding extensions + (node_common): Set flags to UNINITIALIZED for Node_var. + * configure.in (dynamic linking): New check. Probably should + be a separate macro. + * eval.c (flag2str): Add UNINITIALIZED to the table. + (r_tree_eval): Add checks for UNINITIALIZED. + (push_args): Appropriate changes for UNINITIALIZED to work. + (r_get_lhs): New third argument for reference checking. + (set_LINT): Add code to handle setting `lintfunc' appropriately. + * ext.c: New file, for doing dynamic library extensions. + * extension/*: New directory with simple example code. + * main.c (VERSION_node, EXTENSION_node): New nodes for new vars. + (optab): Change for "lint" to allow optional argument. + (lintfunc): Definition. + (main): Add case in option processing for --lint. + (varinit): Add entries for VERSION and EXTENSION. + * node.c (r_force_number): Checks that string really is a number. + (morenodes): Set UNITIALIZED in the flags. + * re.c (all): Change `result' to `res' globally to avoid conflict + with new macro. + * GLOBAL: Change lint calls to warning() to lintwarn(). + * GLOBAL: Change all calls to get_lhs() to have 3rd arg. + * GLOBAL: Change all calls to assoc_lookup() to have 3rd arg. + +Sun Nov 22 17:07:39 1998 Arnold D. Robbins + + * patchlev.h: Renamed from patchlevel.h to make life + easier for the PC guys. + (main.c): Changed to include patchlev.h. + (Makefile.in): Changed to ref patchlev.h where needed. + +Sat Nov 7 21:29:52 1998 Arnold D. Robbins + + * eval.c (r_get_lhs): case Node_field_spec. Fix the lint + warnings for field reference of null string or non-numeric value. + When turned on, $0 generated a warning! Oops. + +Thu Nov 5 16:58:38 1998 Arnold D. Robbins + + * main.c (init_fds): New function to pre-open 0, 1, and 2 on + /dev/null if they're not open. Robustness, more or less. + (main): Call init_fds. + * io.c (str2mode): Add smarts for two-letter strings + such as "rw", "r+", "wr", "w+" and "a+". + +Mon Nov 2 16:55:46 1998 Arnold D. Robbins + + * builtin.c (do_*): Added lint checks for non-numeric + and/or non-string arguments, as appropriate. This should + have been done long ago. + +Tue Oct 20 21:56:06 1998 Arnold D. Robbins + + * awk.h (LINT_node): New variable for LINT special var + (Node_LINT): New node type. + (set_LINT): Declare function. + * main.c (varinit): Add LINT variable. + (usage): Print an emphatic pointer to the manual for bug reports. + * eval.c (nodetypes): New entry for Node_LINT. + (r_get_lhs): Case added for Node_LINT. + (set_LINT): Set do_lint from LINT variable. + +Mon Oct 19 22:35:46 1998 Arnold D. Robbins + + * configure.in: For GCC, add -Wall to get warnings for development. + * Makefile.in (awktab.c): Move sed stuff to separate script. + * bisonfix.sed: New script, with old fix and Solaris x86 fix. + * awk.h (nodetype2str): Add declaration. + (load_procinfo): Add declaration. + +Tue Oct 13 22:28:56 1998 Arnold D. Robbins + + Changes to make PROCINFO["FS"] reflect the use of FIELDWIDTHS or FS. + + * eval.c (assign_val): New function that does the mechanics of + assignment + * main.c (load_procinfo): Add setting of PROCINFO["FS"] to "FS". + * field.c (update_PROCINFO): New function to update the array. + (set_FS): Call update_PROCINFO. + (set_FIELDWIDTHS): Ditto. + +Sun Sep 27 10:18:05 1998 Arnold D. Robbins + + * awk.h (reisstring): New prototype. + * re.c (reisstring): New function, returns true if the re did + a simple string match. This is rather simplistic in its logic. + * io.c (get_a_record): In the case that RS is a regexp, AND + the re matched at the exact end of the buffer, add a call to + `reisstring' in case it's a simple string match. If so, we + don't need to read more into the buffer because we don't + have a regex like `x.*y' that might extend longer. + This should be very helpful for interactive /inet clients + where something like `RS = "\r\n"' happens. + +Thu Aug 13 22:07:40 1998 Arnold D. Robbins + + * io.c (socketopen): Fixes from Juergen Kahrs to socket + opening code for "any host". + +Tue Jul 14 19:02:33 1998 Arnold D. Robbins + + * aclocal.m4 (GAWK_AC_LIB_SOCKETS): Removed the caching; + configure gave different results the second time it was run! + +Fri Jul 10 09:11:06 1998 Arnold D. Robbins + + * eval.c (interpret): Minor cleanups: add variable name to + fatal error Node_K_array_for and other minor changes. + +Mon Jun 22 16:53:34 1998 Arnold D. Robbins + + * Makefile.in (tags, TAGS): Add $(LIBSRC). + +Tue Jun 2 15:23:05 1998 Arnold D. Robbins + + * io.c (devopen): Relax previous change, don't require "any", + just that a port be there. The user can put 0 if they + don't care. + +Wed May 27 21:33:45 1998 Arnold D. Robbins + + * io.c (devopen): For /inet, require that local and remote + ports and the remote hostname be there, and that `any' + be used for a port if they don't care. + +Thu May 21 14:13:46 1998 Arnold D. Robbins + + * node.c (parse_escape): Add warning that is always on + for \q for any unknown q inside string or regex constant. + I got bit by this myself once too often. Or else I'm + just getting old and senile. + +Mon May 4 12:42:49 1998 Arnold D. Robbins + + * awk.h (NODETYPE): Sorted the Node_xxx entries for the + builtin variables. Gotta look nice, don't we? + * eval.c (nodetypes): Ditto. + (genflags2str): Added code to check that we don't + overflow the static buffer. This is just a debugging + routine, not worth the hassle of dynamic allocation. + +Mon Mar 2 16:06:16 1998 Arnold D. Robbins + + * Makefile.in (dist): Remove any embedded copied RCS or CVS + directories. + +Mon Feb 23 00:09:52 1998 Arnold D. Robbins + + * awk.h (genflags2str): Add declaration. + * eval.c (genflags2str): New function. + (flags2str): Use new general purpose function. + * io.c (redflags2str): Same. + +Sun Feb 22 23:57:29 1998 Arnold D. Robbins + + Significant changes to add two-way i/o and sockets!!! + + * Makefile.in: Add @SOCKET_LIBS@ to LIBS variable. + * acconfig.h: Add HAVE_SOCKETS and HAVE_PORTALS defs. + * aclocal.m4: New macro GAWK_AC_LIB_SOCKETS. + * awk.h: New node type, Node_redirect_twoway, and new redirection + flags: RED_TWOWAY, and RED_SOCKET. + * awk.y (parser): Add TWOWAYIO token and appropriate productions. + (yylex): Recognize `|&' token if not traditional. + * builtin.c (do_print, do_printf): Flush buffer if TWOWAYIO. + * configure.in: Add header checks for networking header files, + add --enable-portals switch, call GAWK_AC_LIB_SOCKETS + * eval.c (nodetypes): Add string constant for Node_redirect_twoway. + * io.c (redflags2str): New function. + (redirect): Better error message in default case, add code for + Node_redirect_twoway. + (socketopen): New function. + (iop_open, devopen): Add recognition of `/inet/...'. + (two_way_open): New function. + +Sat Dec 13 21:15:07 1997 Arnold D. Robbins + + * awk.h (struct node): New member, `param_list' in union `x', becomes + `node->parmlist' in the code. + * awk.y (func_install): Rearranged a bit, to build up a list of + the function parameter names and to save it in the `parmlist' field. + * eval.c (push_args): New parameter, `varnames', which is the list + of variable names. Use this to set the vname field of each + parameter's value as it's created. Special case arrays to include + where they came from, mainly for array vs. scalar diagnostics. + (r_tree_eval): Don't set the `vname' field for parameters. + (pop_fcall): Free the `vname' field if it's an array. + (func_call): Pass in the `parmlist' field to call of push_args(). + (r_get_lhs): For Node_subscript, change error message to use + the `vname' field. + (stopme): New do-nothing function for use with debugging code + and setting breakpoints. + +Thu Dec 4 15:18:17 1997 Arnold D. Robbins + + * awk.y: Fixed several lint checks and moved some into + test for do_lint_old. + * eval.c (fmt_index): Add value of bad format spec to + error message. + +Tue Nov 18 22:19:02 1997 Arnold D. Robbins + + * Makefile.in (install): Strip the installed binary. + From Anatoly A. Orehovsky (tolik@mpeks.tomsk.su). + +Sun Nov 16 22:12:39 1997 Arnold D. Robbins + + * array.c (in_array, assoc_lookup): Add symbol->vname to + fatal calls for scalar in array context. + +Wed Nov 12 22:18:33 1997 Arnold D. Robbins + + * awk.h [ISASCII]: On all IS* macros, add cast to unsigned char. + [TOUPPER, TOLOWER]: New macros using unsigned char. + * awk.y: Change to use of IS* vs. is* macros. + * builtin.c (nondec2awknum): Change to use of IS* vs. is* macros, + change casts for casetable[] from int to unsigned char. + use new TOLOWER, TOUPPER macros + * dfa.c [ISASCII]: On all IS* macros, add cast to unsigned char. + (lex): Change isdigit to ISDIGIT. + [TOUPPER, TOLOWER]: New macros using unsigned char, now used. + * eval.c (fmt_ok): Change to use of IS* vs. is* macros. + * field.c (sc_parse_field): Change to use of IS* vs. is* macros, + change casts for casetable[] from int to unsigned char. + (set_FS): Change to use of IS* vs. is* macros. + * io.c (get_a_record): Change to use of IS* vs. is* macros, + change casts for casetable[] from int to unsigned char. + * main.c (main): Change to use of IS* vs. is* macros. + * node.c (r_force_number, parse_escape): Change to use of IS* vs. + is* macros. + * re.c (make_regexp): Change to use of IS* vs. is* macros. + * regex.c [ISASCII]: On all IS* macros, add cast to unsigned char. + +Sun Oct 19 12:36:47 1997 Arnold D. Robbins + + * ALL: Change email address to arnold@gnu.org in all relevant places. + +Wed Oct 15 03:38:12 1997 Arnold D. Robbins + + * awk.y (yylex): Don't allow newlines after ? or : if do_posix. + +Thu Oct 9 19:28:39 1997 Arnold D. Robbins + + * custom.h [SEQUENT]: Removed; not needed any more since the + mmap code was ripped out. + +Wed Oct 8 17:22:03 1997 Arnold D. Robbins + + * configure.in: Remove check for madvise; don't need it any more + after nuking use of mmap. + +Tue Oct 7 11:14:21 1997 Arnold D. Robbins + + * eval.c (flags2str): Made the code table driven. Shortened a lot. + +Tue Sep 30 20:59:17 1997 Arnold D. Robbins + + * eval.c (r_get_lhs): case Node_field_spec. Add lint warnings + for field reference of null string or non-numeric value. + Based on patch submitted by Alan Broder, ajb@dtmr.com. + +Wed Sep 24 20:47:59 1997 Arnold D. Robbins + + * custom.h [TANDEM]: New changes. Finishes up Tandem + integration. + +Mon Sep 22 00:42:34 1997 Arnold D. Robbins + + * custom.h [__be_os]: Remove BROKEN_TOKEN definition. + * dfa.c, dfa.h: Change `token' to `dfa_token' to avoid BeOS + compile problems. + +Thu Aug 7 22:35:17 1997 Arnold D. Robbins + + Changes for BeOS from mc@whoever.com + + * awk.h (strncasecmp): Bracket prototype. + custom.h [__be_os]: New stuff. + dfa.h, dfa.c [BROKEN_TOK]: New ifdefs to use dfa_token, not token. + +Fri Aug 1 13:32:49 1997 Arnold D. Robbins + + Tandem changes: + + * awk.h [TANDEM]: Misc additions, as needed. + * io.c (get_a_record): Changes for fixed length records; not used + on other systems. + * main.c (MRL): New variable, TANDEM specific. + (main): Update handling -mr option for TANDEM. + (load_environ): Comment out whole routine if TANDEM. + missing.c [TANDEM]: New includes. + gawkmisc.c [TANDEM]: Include `tmiscc'. + +Wed Jul 30 19:53:52 1997 Arnold D. Robbins + + Close-on-exec changes: + + * awk.h: (os_close_on_exec, os_isdir): New functions. + * gawkmisc.c: Add include fcntl.h. + * configure.in [AC_CHECK_HEADERS]: Add fcntl.h. + * io.c (devopen, iop_open): Change to use os_isdir(), not S_IFDIR(). + (redirect, devopen, iop_open, gawk_popen): Change all calls to + fcntl() to os_close_on_exec(). + +Tue Jul 29 11:09:45 1997 Arnold D. Robbins + + * eval.c (set_BINMODE): Fixed check for digits to use isdigit() + instead of looping over digits and using strchr(). Duh. + +Sat Jul 26 22:52:08 1997 Arnold D. Robbins + + * eval.c (set_BINMODE): Fix so that `-v BINMODE=w' works. + * node.c (r_force_number): Add decl of strtod(); makes things + work on MIPS. + * Makefile.in (install-strip): New target. + +Fri Jul 18 13:28:05 1997 Arnold D. Robbins + + * io.c (redirect, devopen, iop_open, gawk_popen): Set the + close-on-exec flag on all files and pipes opened for I/O. + Keeps children run via system() or other pipes from running out + of file descriptors. + + (Reported by Kenny McCormack, gazelle@yin.interaccess.com.) + +Tue Jul 8 22:18:00 1997 Arnold D. Robbins + + * awk.y [LEX_NEXT]: Removed support for `next file' as two words. + +Tue Jul 8 06:46:32 1997 Arnold D. Robbins + + * dfa.c: Changes from pjr@jet.UK (Paul J Rippin) from an old + bug report against 2.14.0 that speed up initialization and + rewrite the inner loop into readable code. + +Thu Jul 3 11:44:50 1997 Arnold D. Robbins + + * Atari support moved into new `unsupported' directory. + awk.h, Makefile.in, gawkmisc.c, and missing.c modified. + +Sun Jun 29 14:17:37 1997 Arnold D. Robbins + + * awk.y (exp): Fixed warning about `x = /foo/'. + +Wed Jun 25 09:07:57 1997 Arnold D. Robbins + + * PORTS: Removed from distribution. + * Makefile.in (MISC): Removed PORTS. + +Sun Jun 22 11:52:57 1997 Arnold D. Robbins + + BINMODE changes. + + * awk.h (Node_BINMODE): Added. + (struct redirect): Added mode field to save for io.c:close_one(). + (BINMODE, BINMODE_node, set_BINMODE): Add declarations. + * awk.y (isnoeffect): Add Node_BINMODE. + * eval.c (nodetypes): Add Node_BINMODE string. + (r_tree_eval, r_get_lhs): Add cases for Node_BINMODE. + (set_BINMODE): New function. + * io.c (binmode): New function. + (nextfile, redirect, gawk_popen): Add calls to binmode(). + * main.c (BINMODE, BINMODE_node): Add decls. + (main): Add call to setmode() if BINMODE is set. + (varinit): Add entry for BINMODE. + +Wed Jun 4 21:52:25 1997 Arnold D. Robbins + + * configure.in [AC_FUNC_MMAP]: Removed call. + * awk.h [struct iobuf]: Removed IOP_MMAPED flag and `getrec' member. + * io.c: Removed all mmap related code. + +Sun Apr 27 16:23:56 1997 Arnold D. Robbins + + * aclocal.m4 [GAWK_AC_FUNC_MKTIME]: New macro. + * configure.in (GAWK_AC_FUNC_MKTIME): Call it. + +Thu Apr 24 23:25:06 1997 Arnold D. Robbins + + * io.c (devopen): Remove stat test for /dev/foo files. Finally. + +Fri Jul 26 09:23:15 1996 Arnold D. Robbins + + Changes to add an abort statement, a la tawk. + + * awk.h (Node_K_abort): New enum value for NODETYPE. + * main.c (aborting): New flag variable. + (main): Add logic to handle aborting. + * eval.c (interpret): Add case for Node_K_abort. + * io.c (do_input): If aborting, break loop. + * awk.y (tokentab): Add entry for "abort" keyword + (PRODUCTIONS): Add production for LEX_ABORT. + +Wed Jul 24 12:49:52 1996 Arnold D. Robbins + + First cut at changes for i18n. + + * awk.h (do_intl): Declare new flag variable. + [INTLSTR]: New flag def. + (m_tree_eval): Fix definitions for INTLSTR. + (force_string): Fix definitions for INTLSTR. + * awk.y (yylex): Add _"..." for international strings. + (dumpintlstr): New function. + * main.c (do_intl): Define new flag variable. + (optab): Add "gen-po" entry. + (main): If do_intl, exit, don't run the program. + (gawkoption): Add "gen-po" entry. + * node.c (r_force_string): Call gettext if flags indicate INTLSTR. + +Thu Mar 14 06:29:42 1996 Arnold D. Robbins + + * awk.h (do_mktime): Added declaration of new function. + * builtin.c (do_mktime): New function. + * awk.y (tokentab): Added "mktime" to list of gawk extensions. + * missing.c [HAVE_MKTIME]: Added include of mktime.c if needed. + +Mon Feb 26 22:32:19 1996 Arnold D. Robbins + + * io.c (pidopen, useropen): Added warnings to use PROCINFO[], + not special files. + * main.c (load_procinfo): New function. + * awk.y (variable): Added call to load_procinfo() function. + +Mon Aug 7 15:23:00 2000 Arnold D. Robbins + + * Release 3.0.6: Release tar file made. + +Thu Aug 3 17:47:53 2000 Greg McGary + + * regex.c: Patches for gcc bounded pointer handling. + +Thu Aug 3 13:09:09 2000 Arnold D. Robbins + + * array.c (in_array, do_delete): Fix tests for index equality + when searching through the array to work correctly when + index is "". + +Fri Jul 14 21:40:17 2000 Pat Rankin + + * builtin.c (format_tree): Workaround a DEC C V5.7 bug by + splitting `strcpy() + 3' into two expressions (the builtin + inline strcpy evidently has erroneous return type of void * + instead of char *; reputedly fixed in V6.1). + + * eval.c (C): New macro. + [casetable]: Use it to add explicit casts for the character + values outside the range of 0 to 127. + * missing/strncasecmp.c [C, charmap]: Likewise. + + * io.c (redirect): Add EIO check on failed open for VMS. + +Fri Jul 14 11:57:23 2000 Arnold D. Robbins + + Efficiency hack: turn `for (iggy in foo) delete foo[iggy]' + into moral equivalent of `delete foo'. + + * array.c (do_delete_loop): New routine. + * awk.h [NODETYPE]: New Node_K_delete_loop value. + Add declaration of do_delete_loop. + * awk.y [LEX_FOR]: Fix code to recognize special case. + * eval.c (nodetypes): New entry for Node_K_delete_loop. + (interpret): Add case for Node_K_delete_loop, add more + diagnostic info in default (cant_happen) case. + +Tue Jul 11 22:15:10 2000 Pat Rankin + + * awk.y (nextc): Recast unsigned char values back to int to + prevent VAX C from truncating EOF to 255. + +Tue Jul 11 14:08:23 2000 Arnold D. Robbins + + * array.c (do_delete): Switch to string comparison, not + cmp_nodes. + (assoc_find): Add call to force_string on subscript. + * eval.c (interpret): Case Node_K_arrayfor: check for + Node_array_ref and fetch original_array. Yowser. + +Fri Jun 30 21:57:00 2000 Arnold D. Robbins + + * array.c (assoc_lookup): Don't force the subscript + to be a string. Not a good idea after the change + to using dupnode. + +Sun Jun 25 15:08:19 2000 Arnold D. Robbins + + * Release 3.0.5: Release tar file made. + +Wed Jun 14 13:03:45 2000 Arnold D. Robbins + + * field.c (set_record): Manage a private buffer for $0. + Keeps things safe in case `getline var' rearranges the + IOBUF's contents that $0 is still pointing into. + +Tue Jun 13 16:27:55 2000 Paul Eggert + + Upgrade to latest and greatest version of largefile code. + + * configure.in (AC_CANONICAL_HOST): Remove. + (GAWK_AC_SYS_LARGEFILE): Defer until after AC_MINIX, + to avoid autoconf warnings. + + Rewrite largefile configuration so that we don't need to run + getconf and don't need AC_CANONICAL_HOST. + * config.guess, config.sub: Remove these files. + * Makefile.in (MISC): Remove config.guess, config.sub. + * m4/largefile.m4 (GAWK_AC_SYS_LARGEFILE_FLAGS, + GAWK_AC_SYS_LARGEFILE_SPACE_APPEND): Remove. + (GAWK_AC_SYS_LARGEFILE_TEST_INCLUDES): New macro. + (GAWK_AC_SYS_LARGEFILE_MACRO_VALUE): Change arguments from + CODE-TO-SET-DEFAULT to VALUE, INCLUDES, FUNCTION-BODY. + All uses changed. + Instead of inspecting the output of getconf, try to compile the + test program without and with the macro definition. + (GAWK_AC_SYS_LARGEFILE): Do not require AC_CANONICAL_HOST or check + for getconf. Instead, check for the needed flags by compiling + test programs. + + (GAWK_AC_SYS_LARGEFILE): Define _XOPEN_SOURCE to be 500 to + work around glibc 2.1.3 bug. + + (GAWK_AC_SYS_LARGEFILE_FLAGS): Don't use -n32 on IRIX if the + installer said otherwise. + + (GAWK_AC_SYS_LARGEFILE_FLAGS): Work around a bug in the QNX shell, + which doesn't propagate exit status of failed commands inside + shell assignments. + +Wed Jun 7 13:23:09 2000 Arnold D. Robbins + + * Updated copyright dates in appropriate files. + +Mon May 22 17:29:43 2000 Arnold D. Robbins + + * Makefile.in (clean): Get `*/core' too. + +Sun May 7 16:33:05 2000 Arnold D. Robbins + + * array.c (concat_exp): Change ref to `lnode->stlen' and + `lnode->stptr' for SUBSEP to use `var_value->...'. + +Tue May 2 09:54:29 2000 Arnold D. Robbins + + Fix referencing freed memory as shown by test/arynocls.* tests. + * awk.h [Node_array_ref]: New node type. + [orig_array]: New macro element in NODE structure. + * field.c (do_split): Handle case for Node_array_ref, fetch + the original array. + * array.c (in_array, do_delete): Ditto. + * eval.c (nodetypes[]): Add Node_array_ref string. + (r_tree_eval): Handle case for Node_array_ref. + (push_args): Push arrays as Node_array_ref, and pass them on. + (pop_fcall): Don't unref lnode if it's an array when releasing + local arguments. Check for both Node_array and Node_array_ref. + (r_get_lhs): Choke on Node_array_ref as for Node_array. + For Node_subscript, handle Node_array_ref. + +Tue May 2 09:52:12 2000 Bruno Haible + + * io.c (redirect): After reopening a `struct redirect', move it to + the head of the list. + +Sun Apr 2 17:51:40 2000 Arnold D. Robbins + + * re.c (re_update): Check if IGNORECASE has changed, and + if so recompute the re. See test/igncdym.awk. + +Mon Mar 20 16:18:34 2000 Arnold D. Robbins + + * io.c (set_RS): Added a lint warning about multicharacter RS, + per suggestion from Akim DeMaille (akim@epita.fr). + +Sun Feb 13 14:40:32 2000 Arnold D. Robbins + + * eval.c (push_args): Fix from Nide Naoyuki , + re-assign `f' in case tree_eval moved fcall_list around. + +Sun Feb 6 11:39:33 2000 Arnold D. Robbins + + * eval.c (op_assign): Fix it right. For ++ and --, get the lhs + in the operations, do the op, and then return. For += etc, + get the rhs FIRST, since the lhs can move around as a result, + *then* get the lhs and do the operation. See test/opasnidx.awk. + +Tue Feb 1 18:41:40 2000 Arnold D. Robbins + + * eval.c (op_assign): Reget the rval after regetting + the left hand side. See test/opasnslf.awk for why. + +Thu Jan 27 18:06:31 2000 Arnold D. Robbins + + * awk.y (yylex): Made ']' not one of the characters + that sets `want_assign' to false. `a[i] /= 2' was + broken. Per bug report from Kristofer T. Karas + . + +Wed Dec 22 15:06:37 1999 Arnold D. Robbins + + * awk.y: Removed declarations of functions before + definition of `tokentab[]'. They're redundant with + what's in awk.h. + +Thu Dec 9 17:01:07 1999 Arnold D. Robbins + + * node.c (parse_escape): Add lint warning for unrecognized + escape sequences. + +Mon Dec 6 15:17:34 1999 Arnold D. Robbins + + * main.c (usage): Changed bug reporting email addresses to + be a reference to `Bugs' node in the online and printed + doc, instead. + +Thu Dec 2 13:08:18 1999 Arnold D. Robbins + + * builtin.c (do_compl): Test `d' for negative inside the do_lint + test, not uval. Ooops. + +Fri Nov 26 10:58:36 1999 Arnold D. Robbins + + * array.c (assoc_find): ALWAYS compare indexes as strings, + don't use cmp_nodes in case they are numeric. Oh my. + Talk about a Day 1 bug! + +Tue Nov 23 11:58:53 1999 Arnold D. Robbins + + * regex.c (SYNTAX): Cast argument to `unsigned char' instead of + &-ing with 0xFF. Hopefully somewhat more portable, ala 21 Nov 99 + changes to awk.y. + +Sun Nov 21 22:25:27 1999 Paul Eggert + + * aclocal.m4 (AC_SYS_LARGEFILE_FLAGS): Work around a + problem with the QNX 4.25 shell, which doesn't propagate exit + status of failed commands inside shell assignments. + +Sun Nov 21 20:33:35 1999 Arnold D. Robbins + + * awk.h (nextc): Remove declaration, don't need it here. + awk.y (nextc): Cast values to unsigned char so that latin-1 + characters in strings don't turn themselves into EOF. + Most notably y-umlaut, which is decimal 255. + +Mon Nov 1 20:00:25 1999 Arnold D. Robbins + + * regex.c (init_syntax_once): Move below definition of + ISALNUM etc., then use ISALNUM to init the table, so that + the word ops will work if i18n'ed. + (SYNTAX): And subscript with 0xFF for Latin-1 characters. + +Mon Oct 25 18:37:13 1999 Arnold D. Robbins + + * awk.h, main.c, io.c: Undo previous changes (22 Oct 1999). + * main.c (main): Move call to `init_fields()' to before + arg parsing. This allows `-v NF=blah' to work ok. + +Fri Oct 22 17:43:40 1999 Arnold D. Robbins + + * main.c (arg_assign): Add new arg, `initing' for icky special + casing of -v of special variables. Use it to check for NF. + May need to add other cases later. + (pre_assign): Change call arg_assign, passing initing=TRUE; + io.c (nextfile): Change call arg_assign, passing initing=FALSE; + awk.h: Change prototype for arg_assign. + +Tue Oct 19 16:06:48 1999 Paul Eggert + + * io.c (close_redir): Don't munge errno between setting it and + using it. + +Wed Oct 6 17:47:47 1999 Arnold D. Robbins + + * main.c (arg_assign): Return NULL on bad variable. Allows + things like `./3x=stuff' to work as a filename. + +Thu Sep 23 21:35:46 1999 Paul Eggert + + * aclocal.m4 (GAWK_AC_SYS_LARGEFILE_FLAGS): Work around GCC + 2.95.1 bug in HP-UX 10.20 or later. (Had to fix the fix. ADR. :-) + +Tue Sep 21 13:31:36 1999 Arnold D. Robbins + + * builtin.c (format_tree): For '0', only set zero_flag if we + haven't seen the field width or precision yet. + +Mon Aug 9 13:06:01 1999 Arnold D. Robbins + + * array.c (assoc_lookup): Removed code that gave each array + a private copy of each index. Balloons memory usage for + no good reason that I can see. Just use dupnode in all + cases. + * configure.in: Check for $srcdir/.developing adds extra + defines for my testing/debugging use. Yes, hack alert. + +Sun Aug 1 11:02:02 1999 Arnold D. Robbins + + * node.c (dupnode): Turn off FIELD when copying nodes. + * array.c (do_adump, assoc_dump): New functions for array debugging. + * awk.y (tokentab): Conditionally add "adump" function for debugging. + * awk.h: Delcare new functions. + +Thu Jul 29 23:26:40 1999 Arnold D. Robbins + + From wsanchez@apple.com: + * Makefile.in (install-strip): New target, coding stds. compatibility. + * config.guess, config.sub: Add MacOS X recognition. + +Thu Jul 29 19:09:19 1999 Arnold D. Robbins + + * awk.y (func_install): Make `function foo(foo)' a fatal error. + eval.c (r_tree_eval): Diagnose use of a function name as a + variable inside the function. + +Sun Jul 4 16:53:14 1999 Arnold D. Robbins + + * eval.c (eval_condition): Add extra braces to avoid + gcc warning. I'm not going to bother for the library + code like dfa and regex. + +Wed Jun 30 16:14:36 1999 Arnold D. Robbins + + * Release 3.0.4: Release tar file made. This time for sure. + +Wed Jun 30 16:10:11 1999 Arnold D. Robbins + + * awk.h: Add include of , and comment about config.h + having to be included before any system headers. Otherwise, + with egcs-2.91.66 and later on Linux systems, and possibly + others, things break badly, due to the LFS macros. + * awk.y, builtin.c, eval.c, field.c, io.c: Removed include + of assert.h + +Wed Jun 9 11:39:19 1999 Paul Eggert + + Port the large-file code to AIX, HP-UX, and IRIX. + Add cross-compilation support for large files. + + * config.guess, config.sub: New files. + + * configure.in (AC_CANONICAL_HOST): + Add; GAWK_AC_SYS_LARGEFILE needs this. + (GAWK_AC_SYS_LARGEFILE): Renamed from GAWK_AC_LARGE_FILES. + + * aclocal.m4 (GAWK_AC_SYS_LARGEFILE): Renamed from GAWK_AC_LARGE_FILES. + Add support for AIX and HP-UX. + (GAWK_AC_SYS_LARGEFILE_FLAGS, GAWK_AC_SYS_LARGEFILE_SPACE_APPEND, + GAWK_AC_SYS_LARGEFILE_MACRO_VALUE): New macros. + + * acconfig.h (_FILE_OFFSET_BITS, _LARGEFILE_SOURCE, _LARGE_FILES): + New macros. + + * Makefile.in (MISC): Add config.guess and config.sub so they get + included in the distribution. + +Wed Jun 9 11:29:29 1999 Paul Eggert + + * io.c (iop_alloc): Don't mmap files whose sizes don't fit in `int'. + [ This isn't really needed, as HAVE_MMAP is #undef'ed at the top, + but it's there in case people want to take their life in their hands. ] + +Sun Jun 6 11:28:07 1999 Arnold D. Robbins + + * BETA Release 3.0.46: Release tar file made. + +Wed Jun 2 14:36:24 1999 Arnold D. Robbins + + * PORTS: Updated with a more recent list of systems + that gawk compiles and tests ok on. + +Tue Jun 1 14:24:59 1999 Arnold D. Robbins + + * BETA Release 3.0.45: Release tar file made. + +Tue May 25 16:32:37 1999 Arnold D. Robbins + + * builtin.c (format_tree): More smarts for weird cases, such as + zero precisions and zero values used with the `#' flag. + Thanks to Andreas Schwab (schwab@gnu.org) for pointing these out. + +Wed May 19 14:02:54 1999 Arnold D. Robbins + + * io.c (do_close): Move test for `close(FILENAME)' to after + loop through all open redirections. Fixes problems in obscure + cases with redirections in END rules. + +Sun May 16 14:08:39 1999 Arnold D. Robbins + + * awk.y (yylex): Fix group of characters including ',' to + set want_assign = FALSE. Fixes bizarre parsing problems in + function call lists, for example. + * io.c (get_a_record): Repair logic for single-leading-newline + case. + +Tue May 11 16:48:11 1999 Arnold D. Robbins + + * aclocal.m4 (GAWK_AC_AIX_TWEAK): New macro. + * configure.in: Call it + * Makefile.in: (awklib/all): Pass CFLAGS on to sub-make so + that password programs will get AIX magic defines. Avoids + having to tweak program code for those in doc/gawk.texi. + +Mon May 3 16:56:23 1999 Arnold D. Robbins + + * array.c (do_delete): Don't free_temp(subs) until after all + references to it are finished. + +Mon May 3 13:41:16 1999 Arnold D. Robbins + + * BETA Release 3.0.44: Release tar file made. + +Sun May 2 18:25:43 1999 Arnold D. Robbins + + * io.c (get_a_record): Do a really good job of stripping newlines + from the front of records when RS = "" and there's only one + newline at the front of the file, which the regex didn't catch. + +Wed Apr 28 12:27:49 1999 Arnold D. Robbins + + * configure.in: More HP stuff: fix the manual alloca code so that + gawk will compile and link on HP systems. See the comments. + +Sun Apr 25 13:39:16 1999 Arnold D. Robbins + + * Makefile.in (gawk): Add $(CFLAGS) to linking step. + * configure.in: Correctly do AC_FUNC_GETPGRP on HP systems too. + +Tue Apr 13 20:21:00 1999 Arnold D. Robbins + + * BETA Release 3.0.43: Release tar file made. + +Tue Apr 13 19:02:20 1999 Arnold D. Robbins + + * io.c (useropen, pidopen): Add casts to int on arguments to + silence gcc warnings. + * regex.c (regcomp,regexec,regfree): Add ifdef for APPLE. + +Thu Feb 4 10:38:02 1999 Arnold D. Robbins + + * custom.h: Hacks for BeOS. Not documented in the manual right now. + * configure.in: Hacks for BeOS. Check for HP-UX and define C_ALLOCA + if not using gcc. I wish they'd just fix bison already. + +Sun Dec 20 16:57:38 1998 Arnold D. Robbins + + * BETA Release 3.0.42: Release tar file made. + +Sun Nov 15 21:05:39 1998 Arnold D. Robbins + + * io.c (gawk_popen): Add WIN32 to list of systems that use + the non-real-pipe version. From the PC gawk guys. + +Wed Nov 4 11:32:24 1998 Arnold D. Robbins + + * BETA Release 3.0.41: Release tar file made. + +Tue Nov 3 16:24:35 1998 Arnold D. Robbins + + * eval.c (r_get_lhs): Fix the cases for the special variables, + don't unref their current value if it's the same as the internal + copy; perhaps the current one is used in a concatenation or some + other expression somewhere higher up in the call chain. Ouch. + See test/getnr2tm.awk. + +Sun Nov 1 15:24:52 1998 Arnold D. Robbins + + * builtin.c (format_tree): Improve handling of zero-fill + when a precision is present. See test/zeroflag.awk. + +Wed Oct 28 20:40:17 1998 Arnold D. Robbins + + * eval.c (r_tree_eval): Case for Node_concat. Get lengths + separately, in case one expression has a side effect that + that changes another. Ugly, but it keeps gawk from core + dumping. See test/nasty.awk. + +Sun Oct 18 21:27:24 1998 Arnold D. Robbins + + * awk.y (append_right): Bug fix, if `list' or `new' are NULL, + return `list', so that things don't break too badly. + * regex.c (re_compile_fastmap): Remove unused variable `num_regs'. + +Thu Oct 8 19:36:57 1998 Arnold D. Robbins + + * BETA Release 3.0.40: Release tar file made. + +Mon Jul 27 10:14:33 1998 Arnold D. Robbins + + * node.c (parse_escape): Remove assignment with side effects + from ISXDIGIT test. Thanks to "Mihai T. LAZARESCU" + for pointing this out. + +Mon Apr 27 11:31:32 1998 Arnold D. Robbins + + * main.c (usage): Fix the email address for the bug list. + (copyleft): Update the copyright year. + +Mon Mar 23 21:22:32 1998 Arnold D. Robbins + + * eval.c (r_get_lhs): Make sure that values of type + Node_param_list don't have the FUNC flag set. This means + we don't allow the use of a function name as a variable or + array from within the function. + +Sun Mar 22 19:12:32 1998 Paul Eggert + + * aclocal.m4 (GAWK_AC_LARGE_FILES): New macro that checks for + large file support, and updates CPPFLAGS, LDFLAGS, LIBS as + needed. + * configure.in: Call GAWK_AC_LARGE_FILES. + * Makefile.in (CPPFLAGS, LDFLAGS): Let autoconf configure. + (COMPFLAGS): Add $(CPPFLAGS). + +Mon Mar 16 14:06:41 1998 Arnold D. Robbins + + * field.c (using_FIELDWIDTHS): New macro. + (using_fieldwidths): Use new macro. + (do_split): In case for FS_DFLT, also check that + we're not using FIELDWIDTHS. Otherwise, split() would use + FIELDWIDTHS, not current value of FS. Oops. + +Sun Nov 16 20:08:59 1997 Arnold D. Robbins + + * builtin.c (sub_common): Fix for count of matches in gsub + from Geert.Debyser@esat.kuleuven.ac.be. + +Wed Oct 15 03:38:12 1997 Arnold D. Robbins + + * field.c (set_FS): Use `sc_parsefield' if the value of FS is not + alphabetic OR if not ignoring case. Bug fix if IGNORECASE + is true and FS happens to be '^'. Sheesh, talk about obscure. + (rebuild_record): Add more smarts to the code that sets up the + fields. Thanks to Alan J. Broder (ajb@dtmr.com). + +Sun Oct 5 11:56:52 1997 Arnold D. Robbins + + * configure.in: If ISC add -D_SYSV3 to CFLAGS, per email from + Mario Vanoni (vanonim@dial.eunet.ch). + +Fri Sep 26 00:57:49 1997 Arnold D. Robbins + + * awk.y (append_right): Return if either list is NULL. Prevents + syntax errors from causing core dumps. + +Wed Sep 17 15:34:15 1997 Arnold D. Robbins + + * field.c (rebuild_record): Set things up so that all fields point + into the new record and release any changed fields without + causing memory leaks. Avoids problems when fields are extended + with the value of $0 or other fields and then $0 is assigned to. + +Mon Sep 15 16:12:55 1997 Arnold D. Robbins + + * builtin.c (do_print): When testing for NUMBER, make sure + it's not a string too. Thanks to Michael Brennan for + clarifying the semantics. + +Sun Sep 14 19:55:12 1997 Arnold D. Robbins + + * node.c (format_val): Always format values ourselves: avoids + problems if OFMT is bizarre, like %s. + +Sun Sep 14 00:08:53 1997 Arnold D. Robbins + + * io.c (get_a_record): Replace all occurrences of the test + `grRS == FALSE' with `RS_is_null' which makes ` RS = "\0" ' + actually work, is clearer code, and actually makes use of + the `RS_is_null' variable! + +Sun Aug 17 07:15:12 1997 Arnold D. Robbins + + * field.c (set_FS): Change logic to always set parse_field, even + if FS hasn't changed. Thanks to Igor Sheyn for catching this. + +Wed Aug 6 21:04:37 1997 Arnold D. Robbins + + * io.c (VMS et al gawk_popen): Use pclose, not fclose, if + iop_alloc fails. + +Wed Jul 30 19:53:52 1997 Arnold D. Robbins + + * awk.y [variable]: Fix case for subscript if $3 == NULL. + +Sun Jul 27 22:47:30 1997 Arnold D. Robbins + + * awk.y (get_src_buf): Don't close file if it's stdin. + +Sun Jul 27 22:47:15 1997 Pat Rankin + + * io.c (#if VMS: vmsrtl_fileno): New routine. + (#if VMS: fileno): New macro substituted for stdio one. + +Thu Jul 17 20:05:59 1997 Arnold D. Robbins + + * builtin.c (do_print): When OFMT != CONVFMT, create a new + temporary node with just the numeric value valid and format it, + and use that for printing. Avoids memory corruption. + +Wed Jul 16 10:01:16 1997 Arnold D. Robbins + + * regex.c: When SYNTAX_TABLE is defined, but not emacs, then + CHAR_SET_SIZE is not defined, though used in regcomp. It should + be taken out of #ifdef SYNTAX_TABLE. Fix from bug group, from + Akim Demaille, demaille@inf.enst.fr. + * awk.h (isnondecimal): Make test a little smarter. + * builtin.c (nondec2awknum): Add bailout for decimal numbers, e.g. + `00.1'. Fix from Larry Schwimmer . + +Thu Jun 19 19:00:40 1997 Arnold D. Robbins + + * eval.c (interpret): case Node_K_next, Node_K_nextfile: fatal + error if called from BEGIN or END. + (Fixed completely Mon May 3 13:31:42 1999.) + +Mon Jun 9 22:40:04 1997 Arnold D. Robbins + + * builtin.c (nondec2awknum): Allow `f' and `F' in hexadecimal numbers. + Gotta get more sleep... + * array.c (assoc_lookup): Fix from Tom Karzes (karzes@equator.com) + for memory leak when forcing type to Node_var_array. + +Thu May 15 12:49:08 1997 Arnold D. Robbins + + * Release 3.0.3: Release tar file made. + +Wed May 14 08:06:08 1997 Arnold D. Robbins + + * io.c (do_close): Add lint warning if closing something that + isn't open. + +Tue May 13 12:14:12 1997 Arnold D. Robbins + + * random.c, builtin.c: Remove __GLIBC__ tests, since it breaks + `make test'. I prefer consistency across platforms. + * Makefile.in (gawk): Undid April 25 changes and added comment. + Putting COMPLAGS in breaks with -g on VMS POSIX. + +Sun May 11 14:48:04 1997 Darrell Hankerson + + * io.c [MSC_VER]: Add cases for WIN32. + * regex.c [MSC_VER]: Add cases for WIN32. + +Sun May 11 07:04:01 1997 Arnold D. Robbins + + * builtin.c (do_print): In the loop that evaluates each expression + to be printed, do a dupnode to avoid bizarre output. Thanks to + Michal for finding this problem. + * awk.y (yylex): Fix scanning of hexadecimal constants. + +Wed May 7 15:09:25 1997 Arnold D. Robbins + + * io.c (get_a_record): Fix casetable indexing with cast to int. + Keeps Michal happy. + +Tue May 6 16:40:19 1997 Arnold D. Robbins + + * eval.c (func_call): Removed unneeded variables. + +Mon May 5 21:17:37 1997 Pat Rankin + + * missing/strftime.c [case 'v', VMS_EXT]: For VMS date format, two + digit day of month should not be zero padded on the 1st through + the 9th. + +Mon May 5 06:33:47 1997 Arnold D. Robbins + + * regex.h, regex.c: Merge with current GLIBC version. + +Mon May 5 06:33:47 1997 Pat Rankin + + * io.c (nextfile): Move the check for null return from iop_open + in the normal case and add one for the "no args" case. + +Fri Apr 25 16:52:33 1997 Arnold D. Robbins + + * array.c (grow_table): Add a bunch more large primes so arrays + can get really big. Thanks to christos@deshaw.com. + * all files: Remove ifdef'ed out code and update copyrights. + * Makefile.in (gawk): Add $(COMPFLAGS) to command line. + * eval.c (flags2str): Added case for FIELD. + +Thu Apr 24 22:39:23 1997 Arnold D. Robbins + + * COPYING: Changed to current official version from FSF. + * regex.c: Merge with GLIBC version. + * awk.h [_GNU_SOURCE]: Bracket definition inside ifdef. + (NODE.source_line): Move name member out of `x' union and + into `nodep'; avoids problems doing diagnostics. + (nondec2num): Put decl into #if BITOPS || NONDECDATA + * posix/gawkmisc.c, missing/system.c, missing/strtod.c, + missing/strerror.c: Move to generic GPL statement at top. + * builtin.c (nondec2num): Put into #if BITOPS || NONDECDATA + +Wed Apr 23 22:14:14 1997 Arnold D. Robbins + + * dfa.c: Misc changes for really pedantic SGI compilers. + * builtin.c: Bracket defs of random() etc for GLIBC. + * random.c: Bracket whole file for GLIBC. + * configure.in: Extra goop for GETPGRP test for VMS POSIX. + * custom.h [VMS]: Remove hard definition of GETPGRP_VOID. + +Fri Apr 18 07:55:47 1997 Arnold D. Robbins + + * BETA Release 3.0.34: Release tar file made. + +Tue Apr 15 21:35:45 1997 Arnold D. Robbins + + NEW UNDOCUMENTED FEATURE. USE THE SOURCE LUKE! + * acconfig.h [NONDECDATA]: New macro. + * awk.h: Add decl of do_strtonum. + * awk.y (tokentab): Add entry for strtonum function. + * builtin.c (do_strtonum): New function. + * configure.in (non-decimal-data): New --enable-* option. + * node.c (r_force_number): Change to allow non-decimal data inside + ifdef NONDECDATA. + +Tue Apr 15 06:32:50 1997 Pat Rankin + + * missing/strftime.c (malloc, realloc, getenv, strchr): Only + declare these when STDC_HEADERS is not defined. + : Include these when STDC_HEADERS is defined. + * awk.h (freenode, tree_eval, m_tree_eval): Reorganize definitions. + * alloca.c (malloc): If malloc is already defined as a macro, + presumeably by config.h, don't define or declare it. + +Wed Apr 9 22:45:27 1997 Arnold D. Robbins + + * Makefile.in [COMPFLAGS]: Per suggestion from Karl Berry, put + $(CFLAGS) last. + +Tue Apr 8 23:54:46 1997 Arnold D. Robbins + + * eval.c (interpret): For Node_K_break and Node_K_continue, if + treating them like `next', also check the function call stack + and pop it if necessary. + +Mon Apr 7 18:22:37 1997 Arnold D. Robbins + + * awk.h: Add decls of new routines do_compl() and set_loc(). + * awk.y (tokentab): Add entry for "compl" function. + * builtin.c (do_compl): New function to do ones complement. + (do_substr): Rationalized yet again, now notices negative start + and length parameters. + * eval.c (push_args): Fix if call_list gets realloc'ed in the + middle of things. Avoids crash for deeply nested function calls. + * main.c (catch_sig): Add call to set_loc(). + * msg.c (set_loc, srcfile, srcline): New function and private + variables to help out in tracing down source of error messages. + +Fri Mar 28 08:42:27 1997 Arnold D. Robbins + + * io.c (iop_alloc, iop_close): Undo changes of Feb 11, apparently + other cleanups in io.c made mmap stuff start working again. + BAH! It's a mess, the test suite still fails. I'm leaving the + mmap stuff undefined for now. It'll probably get ripped out in 3.1. + +Thu Mar 27 08:48:57 1997 Arnold D. Robbins + + * custom.h [_SEQUENT_]: Undef HAVE_MMAP. + +Wed Mar 26 09:08:16 1997 Arnold D. Robbins + + * io.c (iop_alloc): Fix definition to make it static. + +Mon Mar 24 23:09:07 1997 Arnold D. Robbins + + * field.c (init_fields, etc..): More clean up use of Null_field + and the various flags. + * node.c (unref): If a field, free the node itself. Fixes + memory leak problems. + +Sun Mar 23 22:51:09 1997 Arnold D. Robbins + + * awk.h [FIELD]: New flag for node->flags field. + * builtin.c (sub_common): If FIELD is set, dup the string. + * field.c (init_fields): Set up a new Null_field global var. + (init_fields, set_field, set_record) use the FIELD flag. + (getfield): Use Null_field instead of private variable. + * io.c (wait_any): Comment out calls to pclose and iop_close, + caused weird race conditions. See test/pipeio1.awk. Thanks + to Darrell Hankerson for tracing this one down. + +Tue Mar 18 20:57:18 1997 Arnold D. Robbins + + * dfa.c (inboth): Free templist; plugs memory leak. + * field.c (init_fields, grow_fields_arr, set_field, rebuild_record, + set_record): Remove PERM flag from entries in fields_arr[]. Fixes + nasty memory leak. + +Tue Mar 18 06:33:00 1997 Arnold D. Robbins + + * awk.y (dup_parms): Robustified against parameter errors. + +Sun Mar 16 21:31:40 1997 Arnold D. Robbins + + NEW UNDOCUMENTED FEATURE. USE THE SOURCE LUKE! + * acconfig.h [BITOPS]: New macro. If set, do octal & hex and bit ops. + * awk.h [isnondecimal]: New macro, and decl of new functions. + * awk.y (yylex): Add recognition of octal and hex constants. + * builtin.c (do_and, do_or, do_xor, do_lshift, do_rshift): New + functions that do bit operations. + (nondec2awknum): New function to convert octal or hex to double. + * configure.in: Add AC_ARG_ENABLE for bit operations. + * node.c (r_force_number): Add octal and hex conversion. + +Sun Mar 16 21:28:56 1997 Arnold D. Robbins + + * awk.h [IOP_NOFREE_OBJ]: New macro. + * io.c (iop_open, iop_alloc): Add new third parameter, which is + either NULL, meaning allocate a new IOP, or the address of one + already allocated. Have a static one in the `nextfile' + routine, and use the IOP_NOFREE_OBJ flag for it. All of this + keeps us from reading freed memory. The `swaplns' test fails + otherwise. + (iop_close): If IOP_NOFREE_OBJ is set, don't free the IOBUF. + +Wed Feb 26 06:21:02 1997 Arnold D. Robbins + + * eval.c (in_function, pop_fcall_stack, pop_fcall, push_args): + New functions. These manage "frames" of awk function call arguments. + The problem is that a `next' or a `nextfile' from a function + leaks memory. These changes allow us to free up that memory. + (interpret): for Node_K_next and Node_K_nextfile, check if in + a function call and free all function call frames. + +Fri Feb 21 06:23:19 1997 Arnold D. Robbins + + Misc changes from Katsuyuki Okabe : + + * builtin.c (do_substr): Change a %d to %ld in warning message. + * eval.c (op_assign): Fix format string for warning about %=. + +Wed Feb 19 23:29:02 1997 Arnold D. Robbins + + * main.c (main): Add do_intervals to condition that causes + resetup() to be called again. Makes the --re-interval option + actually work. What a concept. + +Fri Feb 14 09:47:31 1997 Arnold D. Robbins + + * io.c [#include "awk.h"]: Undef HAVE_MMAP to just use the old code. + Something is causing a file descriptor leak, and this is getting to + be just too much hair. I reserve the right to rip out the mmap + code entirely at a future date. + +Tue Feb 11 06:28:29 1997 Arnold D. Robbins + + * io.c (iop_alloc): For an mmap'ed file, close the file descriptor, + and then touch each page to get a private copy. Fixes nasty case + of truncating our input file. + (iop_close): Don't call close on mmap'ed file. + +Wed Feb 5 17:59:04 1997 Arnold D. Robbins + + * eval.c (interpret): For Node_K_delete, just call do_delete; let + it handle the case of `delete array'. + * array.c (do_delete): Changed to handle case of `delete array', + and made smarter if the array is actually an uninitialized + parameter. + +Sun Jan 26 22:58:29 1997 Arnold D. Robbins + + * getopt.h, getopt.c, getopt1.c: Replaced with new versions from + GLIBC 2. + +Sun Jan 19 23:37:03 1997 Arnold D. Robbins + + * eval.c (nodetype2str): Not static, for debugging. + (flags2str): New function for debugging. + * field.c (get_field): Add new var that is like Nnull_string but + does not have numeric attributes, so that new fields are strings. + (set_record): Turn off PERM flag before unrefing fields and field 0. + * array.c (in_array): Always evaluate subscript, could have + side effects. + * builtin.c (do_strftime): Way increase size of buffer to make sure + we don't have overflow problem. Keeps Paul Eggert happy. + * custom.h [__amigaos__]: Define fork to vfork. From Fred Fish. + * dfa.c: Move include of config.h to top, for RSXNT. From Kai + Uwe Rommel. + (ISALPHA, etc): Change from Jacob Engelbrecht (jaen@novo.dk) + to better handle non-ASCII environments. + * gawkmisc.c: Remove amigados case, posix should now work fine. + * amiga/*: Nuked per previous entry. + * Makefile.in: Removed all references to amiga + * io.c [HAVE_SYS_PARAM_H]: Add #undef RE_DUP_MAX to avoid + spurious conflict with regex.h. + (flush_io): Remove amiga ifdefs, not needed anymore. + (spec_setup): Set getrec field for special files. Fix from + Mark Gray (markgray@pdt.net). + * node.c (more_nodes): Fix to get the last entry in the array. + +Wed Jan 8 17:42:37 1997 Andreas Schwab + + * io.c (mmap_get_record): Fix return value if file ends without + record separator. + +Fri Jan 3 19:57:16 1997 Pat Rankin + + * awk.y (get_src_buf): Test for an empty source file by detecting + an initial read of 0 bytes rather than by relying on info from + stat(). + +Wed Dec 25 11:25:22 1996 Arnold D. Robbins + + * Release 3.0.2: Release tar file made. + +Wed Dec 25 11:17:32 1996 Arnold D. Robbins + + * Makefile.in (install, uninstall): Use $(srcdir)/patchlevel.h. + Thanks to Richard Levitte, LeViMS@stacken.kth.se. + (install): Remove chmod command; let $(INSTALL_PROGRAM) use -m. + +Mon Dec 23 20:36:59 1996 Pat Rankin + + * custom.h (#if VMS_POSIX): Define GETPGRP_VOID. + +Fri Dec 20 08:59:55 1996 Arnold D. Robbins + + * getopt.c, getopt1.c: Comment out the `#if defined (_LIBC) || + !defined (__GNU_LIBRARY__)' and `#endif' to force use of this + getopt, even on systems like Linux. This will be handled + better in 3.1 / glibc 2. + +Thu Dec 19 22:52:39 1996 Arnold D. Robbins + + * awk.y (yylex): In several places, after yyerror(), add call to + exit(). Otherwise, infinite messages. This should probably + be handled better. + +Wed Dec 18 22:42:10 1996 Darrel Hankerson + + * getopt.c (_getopt_internal): If 'W' and ';', if optind == argc, + return c, don't fall through. + +Wed Dec 18 10:09:44 1996 Arnold D. Robbins + + * configure.in [AC_PREREQ]: Update to 2.12 in order to switch to + autoconf 2.12. Lots of other files will be rebuilt automatically. + [AM_SANITY_CHECK_CC]: Removed, autoconf does it now. + * aclocal.m4 [AM_SANITY_CHECK_CC]: Removed, autoconf does it now. + +Tue Dec 17 22:23:16 1996 Arnold D. Robbins + + * builtin.c (do_strftime): Fix case if format string is "". + Also fix it if format is not "" but result of strftime is "". + See comments in code. + +Tue Dec 10 23:09:26 1996 Arnold D. Robbins + + * Release 3.0.1: Release tar file made. + +Tue Dec 10 22:39:41 1996 Arnold D. Robbins + + * Makefile.in (dist): Add dependency on `info'. Remove line that + does makeinfo. + (install): Use $(LN) not $(LN_S) to link gawk gawk-version. + +Sun Dec 8 07:53:44 1996 Arnold D. Robbins + + * Makefile.in (gawk): Took COMPFLAGS out of link line for help + on VMS posix. Shouldn't (I hope) affect anything else. + +Thu Nov 28 11:52:24 1996 Arnold D. Robbins + + * configure.in (AC_PROG_INSTALL): Set INSTALL to install-sh. + +Tue Nov 26 22:42:00 1996 Arnold D. Robbins + + * PORTS: Updated list of systems. + * Makefile.in (install): Fix some typos and add some improvements + for Ultrix. + +Sun Nov 24 22:16:26 1996 Arnold D. Robbins + + * builtin.c (do_printf): If no args, fatal error. Return silently + if --traditional. + +Thu Nov 7 20:54:43 1996 Arnold D. Robbins + + * io.c (inrec): Make sure EOF hasn't already happened before + trying to read; prevents accessing freed buffer. Thanks to + Michal Jaegermann. + * Makefile.in [AWKSRC]: Add random.h. + * random.h: New file, redefines names of the `random' functions. + * random.c, builtin.c: Add include of random.h. + +Thu Nov 7 09:06:21 1996 Arnold D. Robbins + + * awk.y (snode): Undo 4 Oct change, put do_split code back. + * field.c (do_split): Restore old code; add test for CONST, so + that re_parse_field is used if third arg to split is a regexp + constant. + +Mon Nov 4 12:57:11 1996 Arnold D. Robbins + + * main.c (main): Research -m[fr] options don't need literal '=' + characters. Brian's documentation was confusing. Fixed, not + that anyone actually uses these options with gawk. + +Sun Nov 3 11:23:21 1996 Arnold D. Robbins + + * field.c (def_parse_field): Add \n to list of acceptable white space. + (posix_def_parse_field): New routine, just like def_parse_field(), + but only allows space and tab as separators. + (do_split, set_FS): Make appropriate choice between the two + *def_parse_field() routines. + +Fri Oct 25 10:13:06 1996 Arnold D. Robbins + + * configure.in: Remove test for random. + * Makefile.in: Add random.c to list of files always compiled. + * missing.c: Remove HAVE_RANDOM test. + * builtin.c: Remove ifdef's for HAVE_RANDOM. + [GAWK_RAND_MAX]: Use constant we know works with our random(). + * random.c: New file - moved from missing/ directory. + +Wed Oct 23 19:46:01 1996 Pat Rankin + + * builtin.c (do_tolower, do_toupper): Add `unsigned char *' casts. + +Tue Oct 22 21:27:52 1996 Arnold D. Robbins + + * builtin.c [GAWK_RANDOM_MAX]: Try to make definition a bit + smarter; don't use RAND_MAX if it's equal to SHRT_MAX, blows + things up. + +Tue Oct 22 08:49:20 1996 Arnold D. Robbins + + * main.c (copyleft): Update copyright date to 1996. + * Too many files to list: Update copyright date to 1996. + +Sun Oct 20 12:21:09 1996 Arnold D. Robbins + + * awk.y, dfa.c, eval.c, io.c, re.c: Added various FIXME comments. + +Sat Oct 19 22:06:42 1996 Arnold D. Robbins + + * eval.c (nodetype2str): Make static, add prototype. + * field.c (sc_parse_field): Cast array subscripts to int to + shut up gcc warnings. + * gawkmisc.c: Add prototype for xmalloc. + * awk.h: Add prototype for getredirect. + * builtin.c (do_fflush): Remove extern decl of getredirect. + * io.c (get_a_record, mmap_get_record): Change decl of rs to int, + to shut up gcc warnings. + * awk.y (isassignable): Add a default to switch to quiet gcc. + * getopt.c (_getopt_internal): Give default value to `indfound'. + +Fri Oct 18 09:00:49 1996 Arnold D. Robbins + + * regex.h [RE_SYNTAX_AWK]: Add RE_CONTEXT_INDEP_ANCHORS. + +Thu Oct 17 22:32:55 1996 Arnold D. Robbins + + * aclocal.m4 [AM_SANITY_CHECK_CC]: Added. + * configure.in: Use it. + +Thu Oct 17 21:43:25 1996 Arnold D. Robbins + + * configure.in: Add checks for locale.h and setlocale(). + * awk.h: Include locale.h and define out setlocale() if not available. + * main.c (main): Call setlocale(). + * builtin.c (do_tolower, do_toupper): Use unsigned char pointers, + to get other charsets right in different locales. + +Wed Oct 16 21:32:53 1996 Arnold D. Robbins + + * builtin.c (format_tree): Change initial buffer size to 512 + and use a constant. Allows large values of %f per bug report + from sheyn@cs.bu.edu. + +Wed Oct 16 21:22:08 1996 Arnold D. Robbins + + * Makefile.in [MISC]: Removed TAGS and tags. + (local-distclean): Added TAGS and tags. + (maintainer-clean): Removed TAGS and tags. + +Wed Oct 16 12:28:43 1996 Arnold D. Robbins + + * main.c (version): Add call to copyleft(), per new standards. + version.c: Fix text of version string to match new standards. + +Sun Oct 6 22:19:45 1996 Arnold D. Robbins + + * regex.c: Updated to Emacs 19.34b base. + +Sun Oct 6 21:57:34 1996 Arnold D. Robbins + + * re.c (make_regexp): Fixed to handle \8 and \9 in the middle + of a regexp. + +Fri Oct 4 10:26:16 1996 Arnold D. Robbins + + * awk.y (snode): Remove case for do_split; always making the + third arg a Node_regex is wrong. + * field.c (do_split): Rationalized to distinguish `/ /' from `" "'. + Generally fixed up. + * node.c (parse_escape): Allow single digit \x escapes. + +1996-10-02 Paul Eggert + + * builtin.c (format_tree): Fix bug in %d and %i format: NaNs, and + values in the range LONG_MAX+1 .. ULONG_MAX, were mishandled. + Don't assume that double values <= -1 are converted to unsigned + long in the expected way; the C Standard doesn't guarantee this. + +1996-10-02 Paul Eggert + + * awk.h (INT_MAX): Remove unused symbol. + +Mon Sep 30 22:19:11 1996 Arnold D. Robbins + + * getopt.c (_getopt_internal): If 'W' is in the optstring followed + by a ';' then search through the long opts table. This makes + `-W foo=bar' same as `--foo=bar'. + * main.c (main): 'W' now prints an error message. + (gawk_option): Deleted the routine. + +Sun Sep 29 23:04:54 1996 Arnold D. Robbins + + * builtin.c (sub_common): Fix several bugs with gsub when + matching null strings. See test/gsubtest.awk. + +Fri Sep 20 17:35:54 1996 Pat Rankin + + * alloca.c (NULL): Don't define if has already done so. + +Fri Sep 20 11:54:31 1996 Arnold D. Robbins + + * builtin.c (do_print): Evaluate all the expressions first and + then print them. Avoids surprising behavior. See test/prtoeval.awk + for an example. + +Tue Sep 10 06:21:40 1996 Arnold D. Robbins + + * awk.h [FUNC]: New flag, marks a Node_parameter_list as really + being the function name; allows more checking in awk.y. + * awk.y (isassignable): Now takes a NODE * instead of a type, to + check if a function parameter is marked FUNC, then it's the function + name, which is not assignable. Fix call from snode(). + (function_prologue): Mark function name as FUNC. + (yyerror): Don't call exit() anymore; gawk will now report + all syntax errors. + +Sun Sep 1 19:36:30 1996 Arnold D. Robbins + + * field.c (rebuild_record): After building new field 0, go through + all old fields, and if they used to point into the old one, + have them point into the new one. Then turn off PERM flag before + unref-ing field 0. + +Wed Aug 28 19:13:34 1996 Arnold D. Robbins + + * eval.c (set_IGNORECASE): Correctly parenthesize bit operations + in test and fix logic for string value. + +Wed Aug 28 22:06:33 1996 Arnold D. Robbins + + * main.c (usage): Add email addresses for bug reporting, per + change in GNU Coding Standards from RMS. + +Sun Aug 11 23:13:22 1996 Arnold D. Robbins + + * Makefile.in (install): Correct use of $(INSTALL_PROGRAM). + +Thu Aug 8 23:29:43 1996 Arnold D. Robbins + + * parse.y (isassignable): New function, checks in type can + be assigned to. + (snode): Changed checking for 3rd arg of gsub to be more + general, supersedes earlier change. + +Thu Aug 8 13:58:26 1996 Arnold D. Robbins + + * parse.y (snode): If third arg to sub or gsub is builtin + function, complain, since can't substitute into result. + * eval.c (r_get_lhs): Diagnose Node_builtin as an error, instead + of falling through into default case and using cant_happen(). + +Thu Aug 1 07:13:14 1996 Arnold D. Robbins + + * regex.h [RE_DEBUG]: New macro. + [RE_SYNTAX_GNU_AWK]: Add RE_DEBUG. + [RE_SYNTAX_POSIX_AWK]: Add RE_INTERVALS. + * regex.c (re_set_syntax): Add #ifdef DEBUG code to turn on `debug' + flag if RE_DEBUG set, and turn off debug if not set and debug + was on. + * main.c (main): Remove `do_intervals = TRUE' from `if (do_posix)', + it's now handled in the definition of RE_SYNTAX_POSIX_AWK. + +Mon Jul 29 17:49:07 1996 Pat Rankin + + * io.c (O_ACCMODE): Define it if doesn't. + +Mon Jul 29 12:02:48 1996 Arnold D. Robbins + + * eval.c (set_IGNORECASE): Made somewhat smarter. gawk -v IGNORECASE=0 + was acting the same as -v IGNORECASE=1. Thanks to Darrell Hankerson + for the bug report. + +Fri Jul 26 12:04:43 1996 Arnold D. Robbins + + * awk.h (format_val): Add declaration of new routine. + * node.c (format_val): New routine, abstracts old guts of + r_forcestring; accepts format string and index as additional params. + (r_force_string): Changed to call format_val. + * builtin.c (do_print): Don't tree_eval the tree twice in case + OFMTidx != CONVFMTidx; doing so could cause side effects + (from bug report by Tobias Rettstadt, xassp@ipds.uni-kiel.de). + Instead, call format_val. + +Mon Jul 22 21:59:15 1996 Arnold D. Robbins + + * io.c (iop_close): Change check for "is $0 in the input buffer" + to use `< (iop->buf + iop->secsiz + iop->size)' instead of + `< iop->end'. The latter is bogus if EOF has been hit on the + file. Fix from Darrel Hankerson based on bug report by + Charles Howes (howes@grid.direct.ca). See test/eofsplit.awk. + +Thu Jul 18 19:43:20 1996 Arnold D. Robbins + + * builtin.c (sub_common): Backed out change of Feb 14 in favor of: + (do_gensub): Changed to use make_string and then to |= TEMP + flag, based on bug report and patch from Katsuyuki Okabe, + hgc02147@niftyserve.or.jp. + +Thu Jul 18 19:23:53 1996 Arnold D. Robbins + + * custom.h: Added ifdef for QNX, based on bug report from + Michael Hunter, mphunter@qnx.com. + +Mon Jul 15 09:31:01 1996 Arnold D. Robbins + + * io.c (redirect): When finding the rp pointer, if it's not + NULL, set str = rp->value. This gets the '\0' terminated + version. Motivated by bug report from John Hawkinson + (jhawk@bbnplanet.com). + +Sun Jul 14 18:40:26 1996 Arnold D. Robbins + + * configure.in: Added call to AC_CHECK_LIB(m, fmod), since + apparently some systems have fmod in the math library. + Portability: The Holy Grail. Sigh. + +Sun Jul 14 18:08:01 1996 Arnold D. Robbins + + * awk.h: Add Jim Meyerings ISASCII etc hacks for ctype macros. + * builtin.c (do_toupper, do_tolower, sub_common): Changed to use + upper-case versions of ctype macros. + * main.c (main): Ditto. + * node.c (r_force_number, parse_escape): Ditto. + +Sun Jul 14 06:34:18 1996 Arnold D. Robbins + + * field.c (set_record): Made it always do the PERM flag. + Fixes cases where $0 is assigned to, e.g. by gsub, keeps + the fields valid. + (get_field): Removed the call to reset_record in + case where ! field0_valid. We want to leave the fields alone + if they've been changed. + +Thu Jul 11 23:04:20 1996 Arnold D. Robbins + + * io.c (devopen): Change tests of (flag & O_fooONLY) to + (flag & O_ACCMODE) == O_fooONLY. Per (long standing) bug + report from Chapman Flack. + (close_redir): Change final conditional to just (status != 0) + so that ERRNO always set; the warning had its own `if (do_lint)' + anyway. + * eval.c (do_split): Force type of array to be Node_var_array + instead of Node_var. Per (long standing) bug report from + Chapman Flack. + +Thu Jul 11 22:17:14 1996 Arnold D. Robbins + + * Makefile.in (install): Added symlink of gawk to awk if + no awk in $(bindir). + (LN_S): New variable for symlinking. + (uninstall): Remove awk if it's the same gawk. + * Configure.in: Added call to AC_PROG_LN_S for Makefile.in. + +Sun Jul 7 15:47:13 1996 Arnold D. Robbins + + * main.c (main): Made `--posix' turn on interval expressions. + Gawk now matches its documentation. (What a concept!) + +Wed Jul 3 15:02:48 1996 Arnold D. Robbins + + * regex.h, regex.c: Upgraded to changes from Emacs 19.31. + +Fri May 17 08:46:07 1996 Arnold D. Robbins + + * io.c (get_a_record): Added `continued' flag. Fix from + Darrell Hankerson for when RS = "\n|something". + +Wed May 15 02:34:55 1996 Arnold D. Robbins + + * Makefile.in (awklib/all): Now depends on gawk, fixes problem + with parallel make. + +Tue May 14 15:02:52 1996 Arnold D. Robbins + + * builtin.c (format_tree): Fix handling of '*' to deal with + negative value for fieldwidth -- make positive and turn on + left justify. Per bug report from Michael Brennan. + +Sun May 12 20:42:06 1996 Arnold D. Robbins + + * eval.c (r_get_lhs): case Node_subscript. Check if array name + is actually a function, fatal error if so. + +Sun May 5 10:11:52 1996 Arnold D. Robbins + + * io.c (redirect): Call flush_io() before creating a new output pipe, + per bug report from Brian Kernighan (bwk@research.bell-labs.com). + +Fri Mar 15 06:38:33 1996 Arnold D. Robbins + + * Makefile.in (install): Use $(INSTALL_PROGRAM), not $(INSTALL). + (local-distclean): Add `*~' to list of files to be removed. + (CFLAGS): Now contains just @CFLAGS@. + (COMPFLAGS): Replaces use of CFLAGS, has CFLAGS plus all the + other stuff. + +Wed Mar 13 14:19:38 1996 Arnold D. Robbins + + * io.c (mmap_get_record): Fixed to not place sentinel at end + of mmap'ed object. Won't work if file is exact multiple of + disk block size. See comments in code for more info. + Thanks to Rick Adams (rick@uunet.uu.net) for help in testing. + +Sun Mar 10 22:50:23 1996 Arnold D. Robbins + + * io.c (do_close): Notice if we were called as `close(FILENAME)' + and arrange to close the current input file. This turns out + to be easy to do, just call `nextfile(TRUE)'. Based on bug report + from Pascal A. Dupuis, . + +Thu Mar 7 08:08:51 1996 Arnold D. Robbins + + * field.c (init_fields, grow_fields, set_field, rebuild_record): + Nuke the `nodes' array everywhere. Anytime a field is unref'ed, + allocate a new node that is a copy of Nnull_string. This avoids + subtle memory management problems when doing a lot of assignment + to fields, and tweaking of NF. Make sure that fields_arr[0] always + has a type of Node_val! + * field.c (set_NF): If NF is decremented, clear fields between + NF and parse_high_water, otherwise if NF incremented, clear + fields between parse_high_water and NF. + * eval.c (nodetype2str): New function, used for diagnostics. + (interpret): Use nodetype2str when finding invalid node. + +Mon Mar 4 09:02:28 1996 Arnold D. Robbins + + * builtin.c (do_toupper, do_tolower): Use isascii along with + isupper/islower before changing case, in case characters have + the high bit set. This is a hack. + +Mon Feb 26 22:24:44 1996 Arnold D. Robbins + + * builtin.c (sub_common): If no match, and called from gensub, + don't free the temporary string, since the tmp_number then + writes over it. + +Sun Feb 25 23:13:01 1996 Arnold D. Robbins + + * builtin.c (format_tree): Fixed %c to treat user input as + numeric also by adding test for MAYBE_NUM. + +Tue Feb 20 12:25:50 1996 Arnold D. Robbins + + * configure.in: Added AC_FUNC_MMAP call and add madvise to + list of functions to look for. + * awk.h [IOP_ISMAPPED]: New flag value for mmap support and new + `getrec' structure member in struct iobuf. + * io.c (iop_alloc, iop_close): Changed to map/unmap input file + into memory if possible. + (mmap_get_record): New function to actually retrieve the + record from mmaped file. + +Thu Feb 1 08:56:46 1996 Arnold D. Robbins + + * builtin.c (do_substr): Fixed lint message to use indx+1 when + start position is past end of string. + +Sun Jan 28 07:00:56 1996 Arnold D. Robbins + + * builtin.c (do_substr): Rationalized handling of missing length + argument, as well as various accompanying lint warnings. Previous + code was slightly bogus. Talk about your Day 1 bugs. + +Thu Jan 25 14:09:11 1996 Arnold D. Robbins + + * builtin.c (do_substr): If length exceeds length of actual + string, do computation of needed substring length *after* + the lint warning. + +Wed Jan 24 10:06:16 1996 Arnold D. Robbins + + * Makefile.in (gawk): Add $(CFLAGS) to link line. + (Makefile): Target depends on the Makefile.in files. + (OTHERS): Added TAGS and tags to the distribution. + (local-distclean): New rule. + (distclean): Use it. + (maintainer-clean): Don't `make distclean' before running submakes, + since that removes makefiles needed for the submakes. + * builtin.c (do_strftime): Remove hard coded limit on length of result. + Based on code from Paul Eggert (eggert@twinsun.com). + +Mon Jan 22 13:16:37 1996 Arnold D. Robbins + + * main.c (usage): Takes new fp parameter which is either + stdout for `--help' (per the GNU Coding Standards) or stderr + if an error occurs. Fix all calls. + (version): Prints to stdout per the coding stds. + (copyleft): Prints to stdout now, not stderr, and exits. + +Fri Jan 19 08:10:29 1996 Arnold D. Robbins + + * regex.h [RE_GNU_AWK]: Added RE_CONTEXT_INDEP_OPS to set of + bits we turn off for regular operation. Breaks things like + /^+[0-9]+/ to match a literal `+' at the beginning of, say, + a phone number. + +Wed Jan 10 23:19:36 1996 Arnold D. Robbins + + * 3.0.0 polished up and release tar file made. + +Wed Dec 27 11:46:16 1995 Arnold D. Robbins + + * 2.94.0 released to porting group (no, I haven't been good + about this file; I'll do better once 3.0 is released). + +Mon Aug 28 23:04:30 1995 Arnold D. Robbins + + * awk.h updated for NeXT - bracket TRUE/FALSE + * io.c (get_a_record): Removed shadowing of 'start' in + * Makefile.in and doc/Makefile.in: Fixed to use gawk.1 and gawk.texi, + instead of gawk.1.in and gawk.texi.in. + +Mon Aug 25 11:04:30 1995 Arnold D. Robbins + + * 2.90.0 released to porting group. + +Fri Aug 18 12:43:31 1995 Arnold D. Robbins + + * ChangeLog created. diff --git a/FUTURES b/FUTURES new file mode 100644 index 0000000..6b57056 --- /dev/null +++ b/FUTURES @@ -0,0 +1,67 @@ + Copyright (C) 2005, 2006, 2010, 2011 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + +This file lists future projects and enhancements for gawk. Items are listed +in roughly the order they will be done for a given release. This file is +mainly for use by the developers to help keep themselves on track, please +don't bug us too much about schedules or what all this really means. + +For 4.1 +======= + Merge gawk/pgawk/dgawk into one executable + + Consider removing use of and/or need for the protos.h file. + + Consider moving var_value info into Node_var itself + to reduce memory usage. + + Merge xmlgawk -l feature + + Merge xmlgawk XML extensions + + Integrate MPFR to provide high precision arithmetic. + + Continue code reviews / code cleanup + + Consider making gawk output +nan for NaN values so that it + will accept its own output as input. + +For 4.2 +======= + Implement designed API for loadable modules + + Redo the loadable modules interface from the awk level. + + Rework management of array index storage. (Partially DONE.) + + DBM storage of awk arrays. Try to allow multiple dbm packages. + + ? Move the loadable modules interface to libtool. + + ? Add an optional base to strtonum, allowing 2-36. + + ? Optional third argument for index indicating where to start the + search. + + ?? A RECLEN variable for fixed-length record input. PROCINFO["RS"] + would be "RS" or "RECLEN" depending upon what's in use. + + ?? Use a new or improved dfa and/or regex library. + + ??? Gnulib + +Probably never: +=============== + Do an optimization pass over parse tree? + + Consider integrating Fred Fish's DBUG library into gawk. + + Make awk '/foo/' files... run at egrep speeds (how?) + + ? Have strftime() pay attention to the value of ENVIRON["TZ"] + + Add a lint check if the return value of a function is used but + the function did not supply a value. diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..5458714 --- /dev/null +++ b/INSTALL @@ -0,0 +1,234 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006 Free Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' if +you want to change it or regenerate `configure' using a newer version +of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. + + Running `configure' might take a while. While running, it prints + some messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + +You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you can use GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + With a non-GNU `make', it is safer to compile the package for one +architecture at a time in the source code directory. After you have +installed the package for one architecture, use `make distclean' before +reconfiguring for another architecture. + +Installation Names +================== + +By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/LIMITATIONS b/LIMITATIONS new file mode 100644 index 0000000..719f018 --- /dev/null +++ b/LIMITATIONS @@ -0,0 +1,22 @@ + Copyright (C) 2005, 2006 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + +This file describes limits of gawk on a Unix system (although it +is variable even then). Non-Unix systems may have other limits. + +# of fields in a record: MAX_LONG +Length of input record: MAX_INT +Length of output record: unlimited +Size of a field: MAX_INT +Size of a printf string: MAX_INT +Size of a literal string: MAX_INT +Characters in a character class: 2^(# of bits per byte) +# of file redirections: unlimited +# of pipe redirections: min(# of processes per user, # of open files) +double-precision floating point +Length of source line: unlimited +Number of input records in one file: MAX_LONG +Number of input records total: MAX_LONG diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..aeff42f --- /dev/null +++ b/Makefile.am @@ -0,0 +1,204 @@ +# +# Makefile.am --- automake input file for gawk +# +# Copyright (C) 2000-2011 the Free Software Foundation, Inc. +# +# This file is part of GAWK, the GNU implementation of the +# AWK Programming Language. +# +# GAWK is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# + +## process this file with automake to produce Makefile.in + +# This variable insures that aclocal runs +# correctly after changing configure.ac +ACLOCAL_AMFLAGS = -I m4 + +# This insures that make flags get passed down to child makes. +AM_MAKEFLAGS = 'CFLAGS=$(CFLAGS)' 'LDFLAGS=$(LDFLAGS)' + +# Stuff to include in the dist that doesn't need it's own +# Makefile.am files +EXTRA_DIST = \ + ChangeLog.0 \ + COPYING \ + FUTURES \ + INSTALL \ + LIMITATIONS \ + NEWS \ + NEWS.0 \ + POSIX.STD \ + PROBLEMS \ + README_d \ + bisonfix.awk \ + config.guess \ + config.rpath \ + config.sub \ + depcomp \ + extension \ + m4 \ + missing \ + missing_d \ + po/README \ + pc \ + posix \ + regcomp.c \ + regex_internal.c \ + regex_internal.h \ + regexec.c \ + version.in \ + vms \ + ylwrap + +# It's OK for the generated file `version.c' not to be removed by +# "make distclean". +distcleancheck_listfiles = \ + find . -type f -print | grep -v '^\./version\.c$$' + +# The order to do things in. +# Build explicitly in "." in order to build gawk first, so +# that `make check' without a prior `make' works. +SUBDIRS = \ + . \ + awklib \ + doc \ + po \ + test + +# what to make and install +bin_PROGRAMS = gawk pgawk dgawk + +# sources for both gawk and pgawk +base_sources = \ + array.c \ + awk.h \ + awkgram.y \ + builtin.c \ + custom.h \ + dfa.c \ + dfa.h \ + ext.c \ + field.c \ + floatcomp.c \ + floatmagic.h \ + gawkmisc.c \ + getopt.c \ + getopt.h \ + getopt1.c \ + getopt_int.h \ + gettext.h \ + io.c \ + mbsupport.h \ + main.c \ + msg.c \ + node.c \ + protos.h \ + random.c \ + random.h \ + re.c \ + regex.c \ + regex.h \ + replace.c \ + version.c \ + xalloc.h + +gawk_SOURCES = $(base_sources) eval.c profile.c +pgawk_SOURCES = $(base_sources) eval_p.c profile_p.c +dgawk_SOURCES = $(base_sources) eval_d.c profile.c cmd.h command.y debug.c + +# Get extra libs as needed, Automake will supply LIBINTL and SOCKET_LIBS. +LDADD = $(LIBSIGSEGV) $(LIBINTL) $(SOCKET_LIBS) +dgawk_LDADD = $(LDADD) @LIBREADLINE@ + +# Directory for gawk's data files. Automake supplies datadir. +pkgdatadir = $(datadir)/awk + +# stuff for compiling gawk/pgawk +DEFPATH='".$(PATH_SEPARATOR)$(pkgdatadir)"' + +DEFS= -DDEFPATH=$(DEFPATH) -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"$(datadir)/locale"' + +# Get rid of core files when cleaning +CLEANFILES = core core.* + +MAINTAINERCLEANFILES = version.c + +# We want hard links for install-exec-hook, below +LN= ln + +# First, add a link from gawk to gawk-X.Y.Z. +# Same for pgawk. +# +# For GNU systems where gawk is awk, add a link to awk. +# (This is done universally, which may not always be right, but +# there's no easy way to distinguish GNU from non-GNU systems.) +install-exec-hook: + (cd $(DESTDIR)$(bindir); \ + $(LN) gawk$(EXEEXT) gawk-$(VERSION)$(EXEEXT) 2>/dev/null ; \ + $(LN) pgawk$(EXEEXT) pgawk-$(VERSION)$(EXEEXT) 2>/dev/null ; \ + if [ ! -f awk ]; \ + then $(LN_S) gawk$(EXEEXT) awk; \ + fi; exit 0) + +# Undo the above when uninstalling +uninstall-links: + (cd $(DESTDIR)$(bindir); \ + if [ -f awk ] && cmp awk gawk$(EXEEXT) > /dev/null; then rm -f awk; fi ; \ + rm -f gawk-$(VERSION)$(EXEEXT) pgawk-$(VERSION)$(EXEEXT); exit 0) + +uninstall-recursive: uninstall-links + +# force there to be a gawk executable before running tests +check-local: gawk$(EXEEXT) pgawk$(EXEEXT) + +# A little extra clean up when making distributions. +# And additional set up for the pc directory. +dist-hook: + cd $(distdir)/extension ; rm -f *.o *.so + cd $(srcdir)/pc ; \ + sed -n -f configpk.sed < ../configure.ac > tmp.sed ; \ + sed -f config.sed < ../configh.in > config.tmp ; \ + sed -f tmp.sed < config.tmp > config.h ; \ + $(RM) tmp.sed config.tmp + +# Special rules for individual files +# Use of awk instead of $(AWK) is deliberate, in case gawk doesn't build +# or work correctly. +awkgram.c: awkgram.y + $(YACC) $(AM_YFLAGS) $(YFLAGS) $< + sed 's/parse error/syntax error/g' < y.tab.c | awk -f $(srcdir)/bisonfix.awk awkgram > $*.c && rm y.tab.c + if test -f y.tab.h; then \ + if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \ + else :; fi + +version.c: config.status version.in + $(SHELL) ./config.status --file=version.c:version.in + +command.c: command.y + $(YACC) -p zz $< + sed 's/parse error/syntax error/g' < y.tab.c | awk -f $(srcdir)/bisonfix.awk command > $*.c && rm y.tab.c + +# This is for my development & testing. +efence: gawk + $(CC) $(LDFLAGS) -o gawk $$(ls *.o | grep -v '_p.o$$') $(LIBS) -lefence + +diffout valgrind-scan: + @cd test && $(MAKE) $(AM_MAKEFLAGS) $@ + +valgrind: + cd test; rm -f log.[0-9]*; \ + make check AWK="valgrind --leak-check=full --log-file=log.%p ../gawk"; \ + make valgrind-scan diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..c8208d9 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,1075 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# +# Makefile.am --- automake input file for gawk +# +# Copyright (C) 2000-2011 the Free Software Foundation, Inc. +# +# This file is part of GAWK, the GNU implementation of the +# AWK Programming Language. +# +# GAWK is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# + +VPATH = @srcdir@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +bin_PROGRAMS = gawk$(EXEEXT) pgawk$(EXEEXT) dgawk$(EXEEXT) +subdir = . +DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/configh.in \ + $(top_srcdir)/configure ABOUT-NLS AUTHORS COPYING ChangeLog \ + INSTALL NEWS TODO awkgram.c command.c config.guess \ + config.rpath config.sub depcomp install-sh missing \ + mkinstalldirs ylwrap +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/arch.m4 \ + $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ + $(top_srcdir)/m4/intmax_t.m4 $(top_srcdir)/m4/inttypes_h.m4 \ + $(top_srcdir)/m4/isc-posix.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ + $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libsigsegv.m4 \ + $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/m4/readline.m4 $(top_srcdir)/m4/socket.m4 \ + $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ + $(top_srcdir)/m4/ulonglong.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno config.status.lineno +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(bindir)" +PROGRAMS = $(bin_PROGRAMS) +am__objects_1 = array.$(OBJEXT) awkgram.$(OBJEXT) builtin.$(OBJEXT) \ + dfa.$(OBJEXT) ext.$(OBJEXT) field.$(OBJEXT) \ + floatcomp.$(OBJEXT) gawkmisc.$(OBJEXT) getopt.$(OBJEXT) \ + getopt1.$(OBJEXT) io.$(OBJEXT) main.$(OBJEXT) msg.$(OBJEXT) \ + node.$(OBJEXT) random.$(OBJEXT) re.$(OBJEXT) regex.$(OBJEXT) \ + replace.$(OBJEXT) version.$(OBJEXT) +am_dgawk_OBJECTS = $(am__objects_1) eval_d.$(OBJEXT) profile.$(OBJEXT) \ + command.$(OBJEXT) debug.$(OBJEXT) +dgawk_OBJECTS = $(am_dgawk_OBJECTS) +am__DEPENDENCIES_1 = +am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +dgawk_DEPENDENCIES = $(am__DEPENDENCIES_2) +am_gawk_OBJECTS = $(am__objects_1) eval.$(OBJEXT) profile.$(OBJEXT) +gawk_OBJECTS = $(am_gawk_OBJECTS) +gawk_LDADD = $(LDADD) +gawk_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_pgawk_OBJECTS = $(am__objects_1) eval_p.$(OBJEXT) \ + profile_p.$(OBJEXT) +pgawk_OBJECTS = $(am_pgawk_OBJECTS) +pgawk_LDADD = $(LDADD) +pgawk_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS) +YLWRAP = $(top_srcdir)/ylwrap +SOURCES = $(dgawk_SOURCES) $(gawk_SOURCES) $(pgawk_SOURCES) +DIST_SOURCES = $(dgawk_SOURCES) $(gawk_SOURCES) $(pgawk_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-dvi-recursive install-exec-recursive \ + install-html-recursive install-info-recursive \ + install-pdf-recursive install-ps-recursive install-recursive \ + installcheck-recursive installdirs-recursive pdf-recursive \ + ps-recursive uninstall-recursive +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ + $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ + distdir dist dist-all distcheck +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d "$(distdir)" \ + || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr "$(distdir)"; }; } +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.xz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print + +# Directory for gawk's data files. Automake supplies datadir. +pkgdatadir = $(datadir)/awk +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = -DDEFPATH=$(DEFPATH) -DHAVE_CONFIG_H -DGAWK -DLOCALEDIR='"$(datadir)/locale"' +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GREP = @GREP@ +HAVE_LIBSIGSEGV = @HAVE_LIBSIGSEGV@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +LDFLAGS = @LDFLAGS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBREADLINE = @LIBREADLINE@ +LIBS = @LIBS@ +LIBSIGSEGV = @LIBSIGSEGV@ +LIBSIGSEGV_PREFIX = @LIBSIGSEGV_PREFIX@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +LTLIBSIGSEGV = @LTLIBSIGSEGV@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSUB = @POSUB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOCKET_LIBS = @SOCKET_LIBS@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ + +# This variable insures that aclocal runs +# correctly after changing configure.ac +ACLOCAL_AMFLAGS = -I m4 + +# This insures that make flags get passed down to child makes. +AM_MAKEFLAGS = 'CFLAGS=$(CFLAGS)' 'LDFLAGS=$(LDFLAGS)' + +# Stuff to include in the dist that doesn't need it's own +# Makefile.am files +EXTRA_DIST = \ + ChangeLog.0 \ + COPYING \ + FUTURES \ + INSTALL \ + LIMITATIONS \ + NEWS \ + NEWS.0 \ + POSIX.STD \ + PROBLEMS \ + README_d \ + bisonfix.awk \ + config.guess \ + config.rpath \ + config.sub \ + depcomp \ + extension \ + m4 \ + missing \ + missing_d \ + po/README \ + pc \ + posix \ + regcomp.c \ + regex_internal.c \ + regex_internal.h \ + regexec.c \ + version.in \ + vms \ + ylwrap + + +# It's OK for the generated file `version.c' not to be removed by +# "make distclean". +distcleancheck_listfiles = \ + find . -type f -print | grep -v '^\./version\.c$$' + + +# The order to do things in. +# Build explicitly in "." in order to build gawk first, so +# that `make check' without a prior `make' works. +SUBDIRS = \ + . \ + awklib \ + doc \ + po \ + test + + +# sources for both gawk and pgawk +base_sources = \ + array.c \ + awk.h \ + awkgram.y \ + builtin.c \ + custom.h \ + dfa.c \ + dfa.h \ + ext.c \ + field.c \ + floatcomp.c \ + floatmagic.h \ + gawkmisc.c \ + getopt.c \ + getopt.h \ + getopt1.c \ + getopt_int.h \ + gettext.h \ + io.c \ + mbsupport.h \ + main.c \ + msg.c \ + node.c \ + protos.h \ + random.c \ + random.h \ + re.c \ + regex.c \ + regex.h \ + replace.c \ + version.c \ + xalloc.h + +gawk_SOURCES = $(base_sources) eval.c profile.c +pgawk_SOURCES = $(base_sources) eval_p.c profile_p.c +dgawk_SOURCES = $(base_sources) eval_d.c profile.c cmd.h command.y debug.c + +# Get extra libs as needed, Automake will supply LIBINTL and SOCKET_LIBS. +LDADD = $(LIBSIGSEGV) $(LIBINTL) $(SOCKET_LIBS) +dgawk_LDADD = $(LDADD) @LIBREADLINE@ + +# stuff for compiling gawk/pgawk +DEFPATH = '".$(PATH_SEPARATOR)$(pkgdatadir)"' + +# Get rid of core files when cleaning +CLEANFILES = core core.* +MAINTAINERCLEANFILES = version.c + +# We want hard links for install-exec-hook, below +LN = ln +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +.SUFFIXES: .c .o .obj .y +am--refresh: + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ + $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + $(am__cd) $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +$(am__aclocal_m4_deps): + +config.h: stamp-h1 + @if test ! -f $@; then \ + rm -f stamp-h1; \ + $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ + else :; fi + +stamp-h1: $(srcdir)/configh.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status config.h +$(srcdir)/configh.in: $(am__configure_deps) + ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +dgawk$(EXEEXT): $(dgawk_OBJECTS) $(dgawk_DEPENDENCIES) + @rm -f dgawk$(EXEEXT) + $(LINK) $(dgawk_OBJECTS) $(dgawk_LDADD) $(LIBS) +gawk$(EXEEXT): $(gawk_OBJECTS) $(gawk_DEPENDENCIES) + @rm -f gawk$(EXEEXT) + $(LINK) $(gawk_OBJECTS) $(gawk_LDADD) $(LIBS) +pgawk$(EXEEXT): $(pgawk_OBJECTS) $(pgawk_DEPENDENCIES) + @rm -f pgawk$(EXEEXT) + $(LINK) $(pgawk_OBJECTS) $(pgawk_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/array.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awkgram.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/builtin.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/command.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debug.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dfa.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eval.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eval_d.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eval_p.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ext.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/field.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/floatcomp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gawkmisc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msg.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/node.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/profile.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/profile_p.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/random.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/re.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regex.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/replace.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.y.c: + $(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE) + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +$(RECURSIVE_CLEAN_TARGETS): + @fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) configh.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) configh.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) configh.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) configh.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(am__remove_distdir) + test -d "$(distdir)" || mkdir "$(distdir)" + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-hook + -test -n "$(am__skip_mode_fix)" \ + || find "$(distdir)" -type d ! -perm -755 \ + -exec chmod u+rwx,go+rx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r "$(distdir)" +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-lzma: distdir + tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma + $(am__remove_distdir) +dist-xz: distdir + tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.lzma*) \ + lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ + *.tar.xz*) \ + xz -dc $(distdir).tar.xz | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + test -d $(distdir)/_build || exit 0; \ + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && am__cwd=`pwd` \ + && $(am__cd) $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ + && cd "$$am__cwd" \ + || exit 1 + $(am__remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' +distuninstallcheck: + @$(am__cd) '$(distuninstallcheck_dir)' \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-local +check: check-recursive +all-am: Makefile $(PROGRAMS) config.h +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -rm -f awkgram.c + -rm -f command.c + -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) +clean: clean-recursive + +clean-am: clean-binPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-hdr distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: install-binPROGRAMS + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-exec-hook +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-binPROGRAMS + +.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check-am \ + ctags-recursive install-am install-exec-am install-strip \ + tags-recursive + +.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ + all all-am am--refresh check check-am check-local clean \ + clean-binPROGRAMS clean-generic ctags ctags-recursive dist \ + dist-all dist-bzip2 dist-gzip dist-hook dist-lzma dist-shar \ + dist-tarZ dist-xz dist-zip distcheck distclean \ + distclean-compile distclean-generic distclean-hdr \ + distclean-tags distcleancheck distdir distuninstallcheck dvi \ + dvi-am html html-am info info-am install install-am \ + install-binPROGRAMS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-exec-hook \ + install-html install-html-am install-info install-info-am \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags tags-recursive \ + uninstall uninstall-am uninstall-binPROGRAMS + + +# First, add a link from gawk to gawk-X.Y.Z. +# Same for pgawk. +# +# For GNU systems where gawk is awk, add a link to awk. +# (This is done universally, which may not always be right, but +# there's no easy way to distinguish GNU from non-GNU systems.) +install-exec-hook: + (cd $(DESTDIR)$(bindir); \ + $(LN) gawk$(EXEEXT) gawk-$(VERSION)$(EXEEXT) 2>/dev/null ; \ + $(LN) pgawk$(EXEEXT) pgawk-$(VERSION)$(EXEEXT) 2>/dev/null ; \ + if [ ! -f awk ]; \ + then $(LN_S) gawk$(EXEEXT) awk; \ + fi; exit 0) + +# Undo the above when uninstalling +uninstall-links: + (cd $(DESTDIR)$(bindir); \ + if [ -f awk ] && cmp awk gawk$(EXEEXT) > /dev/null; then rm -f awk; fi ; \ + rm -f gawk-$(VERSION)$(EXEEXT) pgawk-$(VERSION)$(EXEEXT); exit 0) + +uninstall-recursive: uninstall-links + +# force there to be a gawk executable before running tests +check-local: gawk$(EXEEXT) pgawk$(EXEEXT) + +# A little extra clean up when making distributions. +# And additional set up for the pc directory. +dist-hook: + cd $(distdir)/extension ; rm -f *.o *.so + cd $(srcdir)/pc ; \ + sed -n -f configpk.sed < ../configure.ac > tmp.sed ; \ + sed -f config.sed < ../configh.in > config.tmp ; \ + sed -f tmp.sed < config.tmp > config.h ; \ + $(RM) tmp.sed config.tmp + +# Special rules for individual files +# Use of awk instead of $(AWK) is deliberate, in case gawk doesn't build +# or work correctly. +awkgram.c: awkgram.y + $(YACC) $(AM_YFLAGS) $(YFLAGS) $< + sed 's/parse error/syntax error/g' < y.tab.c | awk -f $(srcdir)/bisonfix.awk awkgram > $*.c && rm y.tab.c + if test -f y.tab.h; then \ + if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \ + else :; fi + +version.c: config.status version.in + $(SHELL) ./config.status --file=version.c:version.in + +command.c: command.y + $(YACC) -p zz $< + sed 's/parse error/syntax error/g' < y.tab.c | awk -f $(srcdir)/bisonfix.awk command > $*.c && rm y.tab.c + +# This is for my development & testing. +efence: gawk + $(CC) $(LDFLAGS) -o gawk $$(ls *.o | grep -v '_p.o$$') $(LIBS) -lefence + +diffout valgrind-scan: + @cd test && $(MAKE) $(AM_MAKEFLAGS) $@ + +valgrind: + cd test; rm -f log.[0-9]*; \ + make check AWK="valgrind --leak-check=full --log-file=log.%p ../gawk"; \ + make valgrind-scan + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..453270d --- /dev/null +++ b/NEWS @@ -0,0 +1,123 @@ + Copyright (C) 2010, 2011, 2012 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + +Changes from 4.0.0 to 4.0.1 +--------------------------- + +1. The default handling of backslash in sub() and gsub() has been reverted to + the behavior of 3.1. It was silly to think I could break compatibility that + way, even for standards compliance. + +2. Completed the implementation of Rational Range Interpretation. + +3. Failure to get the group set is no longer a fatal error. + +4. Lots of minor bugs fixed and portability clean-ups along the way. See + the ChangeLog for details. + +Changes from 3.1.8 to 4.0.0 +--------------------------- + +1. The special files /dev/pid, /dev/ppid, /dev/pgrpid and /dev/user are + now completely gone. Use PROCINFO instead. + +2. The POSIX 2008 behavior for `sub' and `gsub' are now the default. + THIS CHANGES BEHAVIOR!!!! + +3. The \s and \S escape sequences are now recognized in regular expressions. + +4. The split() function accepts an optional fourth argument which is an array + to hold the values of the separators. + +5. The new -b / --characters-as-bytes option means "hands off my data"; gawk + won't try to treat input as a multibyte string. + +6. There is a new --sandbox option; see the doc. + +7. Indirect function calls are now available. + +8. Interval expressions are now part of default regular expressions for + GNU Awk syntax. + +9. --gen-po is now correctly named --gen-pot. + +10. switch / case is now enabled by default. There's no longer a need + for a configure-time option. + +11. Gawk now supports BEGINFILE and ENDFILE. See the doc for details. + +12. Directories named on the command line now produce a warning, not + a fatal error, unless --posix or --traditional. + +13. The new FPAT variable allows you to specify a regexp that matches + the fields, instead of matching the field separator. The new patsplit() + function gives the same capability for splitting. + +14. All long options now have short options, for use in `#!' scripts. + +15. Support for IPv6 is added via the /inet6/... special file. /inet4/... + forces IPv4 and /inet chooses the system default (probably IPv4). + +16. Added a warning for /[:space:]/ that should be /[[:space:]]/. + +17. Merged with John Haque's byte code internals. Adds dgawk debugger and + possibly improved performance. + +18. `break' and `continue' are no longer valid outside a loop, even with + --traditional. + +19. POSIX character classes work with --traditional (BWK awk supports them). + +20. Nuked redundant --compat, --copyleft, and --usage long options. + +21. Arrays of arrays added. See the doc. + +22. Per the GNU Coding Standards, dynamic extensions must now define + a global symbol indicating that they are GPL-compatible. See + the documentation and example extensions. + THIS CHANGES BEHAVIOR!!!! + +23. In POSIX mode, string comparisons use strcoll/wcscoll. + THIS CHANGES BEHAVIOR!!!! + +24. The option for raw sockets was removed, since it was never implemented. + +25. Gawk now treats ranges of the form [d-h] as if they were in the C + locale, no matter what kind of regexp is being used, and even if + --posix. The latest POSIX standard allows this, and the documentation + has been updated. Maybe this will stop all the questions about + [a-z] matching uppercase letters. + THIS CHANGES BEHAVIOR!!!! + +26. PROCINFO["strftime"] now holds the default format for strftime(). + +27. Updated to latest infrastructure: Autoconf 2.68, Automake 1.11.1, + Gettext 0.18.1, Bison 2.5. + +28. Many code cleanups. Removed code for many old, unsupported systems: + - Atari + - Amiga + - BeOS + - Cray + - MIPS RiscOS + - MS-DOS with Microsoft Compiler + - MS-Windows with Microsoft Compiler + - NeXT + - SunOS 3.x, Sun 386 (Road Runner) + - Tandem (non-POSIX) + - Prestandard VAX C compiler for VAX/VMS + - Probably others that I've forgotten + +29. If PROCINFO["sorted_in"] exists, for(iggy in foo) loops sort the + indices before looping over them. The value of this element + provides control over how the indices are sorted before the loop + traversal starts. See the manual. + +30. A new isarray() function exists to distinguish if an item is an array + or not, to make it possible to traverse multidimensional arrays. + +31. asort() and asorti() take a third argument specifying how to sort. + See the doc. diff --git a/NEWS.0 b/NEWS.0 new file mode 100644 index 0000000..54e4dc0 --- /dev/null +++ b/NEWS.0 @@ -0,0 +1,2542 @@ + Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, + 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + +Changes from 3.1.7 to 3.1.8 +--------------------------- +1. The zero flag no longer applies to %c and %s; apparently the standards + changed at some point. + +2. Updated to latest infrastructure: Autoconf 2.65, Automake 1.11.1, + libtool 2.2.6b, Bison 2.4.2. + +3. Failure to open a socket is no longer a fatal error. + +4. dfa.h and dfa.c are now more-or-less in sync with GNU grep, for the first + time in many years. + +5. Gawk no longer includes its own copy of libsigsegv but it will use it if + installed on the build system. The --disable-libsigsegv configure option + is now gone. + +6. The ' flag (%'d) is now just ignored on systems that can't support it. + +7. Lots of bug fixes, see the ChangeLog. + +Changes from 3.1.6 to 3.1.7 +--------------------------- +1. Gawk now has support for z/OS (IBM S/390 architecture). + +2. Gawk now handles multibyte strings better in [s]printf with field + widths and such. + +3. Gawk now uses libsigsegv to print a message before core dumping. This + handles infinite recursion of an awk function a little better. + Use of the library can be disabled at configure time with the + --disable-libsigsegv option for unusual systems. + +4. The handling of BINMODE is now somewhat more sane. + +5. A getline from a directory is no longer fatal; instead it returns -1. + +6. Per POSIX, special variable names (like FS) cannot be used as function + parameter names. + +7. The new -O / --optimize option enables simple constant folding on + the parse tree during parsing. We hope that with time the number + of optimizations will increase. + +8. Updated to the latest autotools: Autoconf 2.63, Automake 1.11, + Libtool 2.2.6a, and Gettext 0.17. Also latest Bison: 2.4.1. + +9. Some improvement in testing for isinf / isnan in builtin.c. + +10. Improved the handling of `a = a b c' to be more general. + +11. Locale handling for %'d should now work on certain non-Unix / + non-Linux systems. + +12. Lots of bugs fixed, see the ChangeLog for the details. + +Changes from 3.1.5 to 3.1.6 +--------------------------- + +1. `gawk 'program' /non/existant/file' no longer core dumps. + +2. Too many people the world over have complained about gawk's use of the + locale's decimal point for parsing input data instead of the traditional + period. So, even though gawk was being nicely standards-compliant, in + a Triumph For The Users, gawk now only uses the locale's decimal point + if --posix is supplied or if POSIXLY_CORRECT is set. It is the sincere + hope that this change will eliminate this FAQ from being asked. + +3. `gawk -v BINMODE=1 ...' works again. + +4. Internal file names like `/dev/user' now work again. (Note that these + file names are obsolete and will go away eventually.) + +5. Problems with wide strings in non "C" locales have been straightened + out everywhere. (At least, we think so.) + +6. Use of `ansi2knr' is no longer supported. Please use an ANSI C compiler. + +7. Updated to Autoconf 2.61, Automake 1.10, and Gettext 0.16.1. + +8. The getopt* and regex* files were synchronized with current GLIBC CVS. + See the ChangeLog for the versions and minor edits made. + +9. There are additional --lint-old warnings. + +10. Gawk now uses getaddrinfo(3) to look up names and IP addresses. This + allows the use of an IPv6 format address and paves the way for + eventual addition of `/inet6/...' and `/inet4/...' hostnames. + +11. We believe gawk to now be valgrind clean. At least when run against + the test suite. + +12. A number of issues dealing with the formatting and printing of very + large numbers in integer formats have been dealt with and fixed. + +13. Gawk now converts "+inf", "-inf", "+nan" and "-nan" into the corresponding + magic IEEE floating point values. Only those strings (case independent) + work. With --posix, gawk calls the system strtod directly. You asked + for it, you got it, you deal with it. + +14. Defining YYDEBUG enables the -D command line option. + +15. Gawk should now work out of the box on Tandem NSK/OSS systems. + +16. Lint messages rationalized: many more of the messages are now printed + only once, instead of every time they are encountered. + +17. The strftime() function now accepts an optional third argument, which + if non-zero or non-null, indicates that the time should be formatted + as UTC instead of as local time. + +18. The precedence of concatenation and `| getline' (in something like + "echo " "date" | getline stuff) has been reverted to the earlier + behavior and now once again matches Unix awk. + +19. New configure time flag --disable-directories-fatal which causes + gawk to silently skip directories on the command line. This behavior + is also enabled for --traditional, since it's what Unix awk does. + +20. A new option, --use-lc-numeric, forces use of the locale's decimal + point without the rest of the draconian restrictions imposed by + --posix. This softens somewhat the stance taken in item #2. + +21. Everything relevant has been updated to the GPL 3. + +22. Array growth should be faster now, at no cost in space. + +23. Lots more tests. + +24. One new translation. + +25. Various bugs fixed, see the ChangeLog for details. + +Changes from 3.1.4 to 3.1.5 +--------------------------- + +1. The random() suite has been updated to a current FreeBSD version, which + works on systems with > 32-bit ints. + +2. A new option, `--exec' has been added. It's like -f but ends option + processing. It also disables `x=y' variable assignments, but not -v. + It's needed mainly for CGI scripts, so that source code can't be + passed in as part of the URL. + +3. dfa.[ch] have been synced with GNU grep development. This also fixes + multiple regex matching problems in multibyte locales. + +4. Updated to Automake 1.9.5. + +5. Updated to Bison 2.0. + +6. The getopt* and regex* files were synchronized with current GLIBC CVS. + See the ChangeLog for the versions and minor edits made. + +7. `configure --disable-nls' now disables just gawk's own translations. + Gawk continues to work with the locale's numeric formatting. This + includes a bug fix in handling the printf ' flag (e.g., %'d). + +8. Gawk is now multibyte aware. This means that index(), length(), + substr() and match() all work in terms of characters, not bytes. + +9. Gawk is now smarter about parsing numeric constants in corner cases. + +11. Not closing open redirections no longer causes gawk to exit non-zero. + +10. The VMS port has been updated. + +11. Changes from Andrew Schorr at the xmlgawk project to provide for + open hooks from extensions are now included. This will let the + xmlgawk extension work in the standard gawk. + +12. Updated to gettext 0.14.4. Gawk no longer includes its own copy + of the gettext `intl' library, following current GNU practice to + rely on there being an external version thereof. + +13. A regexp of the form `//' will now generate a warning that it + is not a C++ comment from --lint (awk.y). + +14. The ^ and ^= operators with an integer exponent now use Exponentiation + by Squaring. This simultaneously fixes a problem with ^= and a negative + integer exponent. + +15. length(array) now returns the number of elements in the array. This is + is a non-standard extension that will fail in POSIX mode. + +16. Carriage return characters are now ignored in program source code. + +17. Four new translations added. + +18. Various minor bugs fixed. See the ChangeLog for the details. + +Changes from 3.1.3 to 3.1.4 +--------------------------- + +1. Gawk now supports the POSIX %F format, falling back to %f if the local + system printf doesn't handle it. + +2. Gawk now supports the ' flag in printf. E.g., %'d in a locale with thousands + separators includes the thousands separator in the value, e.g. 12,345. + + This has one problem; the ' flag is next to impossible to use on the + command line, without major quoting games. Oh well, TANSTAAFL. + +3. The dfa code has been reinstated; the performance degradation was + just too awful. Sigh. (For fun, use `export GAWK_NO_DFA=1' to + see the difference.) + +4. The special case `x = x y' is now recognized in the grammar, and gawk + now uses `realloc' to append the new value to the end of the existing + one. This can speed up the common case of appending onto a string. + +5. The dfa code was upgraded with most of the fixes from grep 2.5.1, and + the regex code was upgraded with GLIBC as mid-January 2004. The regex + code is faster than it was, but still not as fast as the dfa code, so + the dfa code stays in. The getopt code was also synced to current GLIBC. + +6. Support code upgraded to Automake 1.8.5, Autoconf 2.59, and gettext 0.14.1. + +7. When --posix is in effect, sub/gsub now follow the 2001 POSIX behavior. + Yippee. This is even documented in the manual. + +8. Gawk will now recover children that have died (input pipelines, two-way + pipes), upon detecting EOF from them, thus avoiding filling + up the process table. Open file descriptors are not recovered + (unfortunately), since that could break awk semantics. See the + ChangeLog and the source code for the details. + +9. Handling of numbers like `0,1' in non-American locales ought to + work correctly now. + +10. IGNORECASE is now locale-aware for characters with values above 128. + The dfa matcher is now used for IGNORECASE matches too. + +11. Dynamic function loading is better. The documentation has been improved + and some new APIs for use by dynamic functions have been added. + +12. Gawk now has a fighting chance of working on older systems, + a la SunOS 4.1.x. + +13. Issues with multibyte support on HP-UX are now resolved. `configure' now + disables such support there, since it's not up to what gawk needs. + +14. There are now even more tests in the test suite. + +15. Various bugs fixed; see ChangeLog for the details. + +Changes from 3.1.2 to 3.1.3 +--------------------------- + +1. Gawk now follows POSIX in handling of local numeric formats for + input, output and number/string conversions. + +2. Multibyte detection improved. See README_d/README.multibyte for more + info about multibyte locales. + +3. Handling of `close' made more POSIX-compliant for POSIXLY_CORRECT, + see the documentation. + +4. The record reading code was redone, again. This time it's much + better. Really! + +5. For RS = "\n" and RS = "", gawk now only sets RT when it has changed. + This provides considerable performance improvement. + +6. `match' now sets all the subscripts in the third argument array + correctly, even if not all subexpressions matched. + +7. Updated to Automake 1.7.5. configure.in renamed configure.ac. + +8. C-style switch statements are available, but must be enabled at + compile time via `configure --enable-switch'. For 3.2 they'll be + enabled by default. Thanks to Michael Benzinger for the initial + code. + +9. %c now always prints no more than one character, whatever + precision is provided. + +10. strtonum() now works again. + +11. Gawk is now much better about scalar/array typing of global + uninitiailzed variables passed as parameters. Once the parameter + is then used one way or the other, the global var's type is + adjusted accordingly. Thanks to Stepan Kasal for the original + (considerable) changes. + +12. Dynamic function loading under Windows32 should now be possible. See + README_d/README.pcdynamic. Thanks to Patrick T.J. McPhee for the changes. + +13. Updated to gettext 0.12.1. + +14. Gawk now follows historical practice and POSIX for the return + value of `rand': It's now 0 <= N < 1. + +Changes from 3.1.1 to 3.1.2 +--------------------------- + +1. Loops of the form: + + for (iggy in foo) + next + + no longer leak memory. + +2. gawk -v FIELDWIDTHS="..." now sets PROCINFO["FS"] correctly. + +3. All builtin operations and functions should now fully evaluate their + arguments so that side effects take place correctly. + +4. Fixed a logic bug in gsub/gensub for matches to null strings that occurred + later in the string after a nonnull match. + +5. getgroups code now works on Ultrix again. + +6. Completely new version of the full GNU regex engine now in place. + +7. Argument parsing and variable assignment has been cleaned up. + +8. An I/O bug on HP-UX has been documented and worked around. See + README_d/README.hpux. + +9. awklib/grcat should now compile correctly. + +10. Updated to automake 1.7.3, autoconf 2.57 and gettext 0.11.5 ; thanks to + Paul Eggert for the initial automake and autoconf work. + +11. As a result of #6, removed the use of the dfa code from GNU grep. + +12. It is now possible to use ptys for |& two-way pipes instead of + pipes. The basic plumbing for this was provided by Paolo Bonzini. + To make this happen: + + command = "unix command etc" + PROCINFO[command, "pty"] = 1 + + print ... |& command + command |& getline stuff + + In other words, set the element in PROCINFO *before* opening the + two-way pipe, and then gawk will use ptys instead of pipes. + + On systems without ptys or where all the ptys are in use, gawk + will fall back to using plain pipes. + +13. Fixed a regex matching across buffer boundaries bug, with a + heuristic. See io.c:rsre_get_a_record. + +14. Profiling no longer dumps core if there are extension functions in place. + +15. Grammar and scanner cleaned up, courtesy of Stepen Kasal, to hopefully + once and for all fix the `/=' operator vs. `/=.../' regex ambiguity. + Lots of other grammar simplifications applied, as well. + +16. BINMODE should work now on more Windows ports. + +17. Updated to bison 1.875. Includes fix to bisonfix.sed script. + +18. The NODE structure is now 20% (8 bytes) smaller (on x86, anyway), which + should help conserve memory. + +19. Builds not in the source directory should work again. + +20. Arrays now use 2 NODE's per element instead of three. Combined with + #18, (on the x86) this reduces the overhead from 120 bytes per element + to just 64 bytes: almost a 50% improvement. + +21. Programs that make heavy use of changing IGNORECASE should now be + much faster, particularly if using a regular expression for FS or RS. + IGNORECASE now correctly affects RS regex record splitting, as well. + +22. IGNORECASE no longer affects single-character field splitting (FS = "c"), + or single-character record splitting (RS = "c"). + + This cleans up some weird behavior, and makes gawk better match the + documentation, which says it only affects regex-based field splitting + and record splitting. + + The documentation on this was improved, too. + +23. The framework in test/ has been simplified, making it much easier to + add new tests while keeping the size of Makefile.am reasonable. Thanks + for this to Stepan Kasal. + +24. --lint=invalid causes lint warnings only about stuff that's actually + invalid. This needs additional work. + +25. More translations. + +26. The `get_a_record' routine has been revamped (currently by splitting it + into three variants). This should improve long-term maintainability. + +27. `match' now adds more entries to 3rd array arg: + match("the big dog", /([a-z]+) ([a-z]+) ([a-z]+)/, data) + fills in variables: + data[1, "start"], data[1, "length"], and so on. + +28. New `asorti' function with same interface as `asort', but sorts indices + instead of values. + +29. Documentation updated to FDL 1.2. + +30. New `configure' option --disable-lint at compile time disables lint + checking. With GCC dead-code-elimination, cuts almost 200K off the + executable size on GNU/Linux x86. Presumably speeds up runtime. + + Using this will cause some of the tests in the test suite to fail. + This option may be removed at a later date. + +31. Various minor cleanups, see the ChangeLog for details. + +Changes from 3.1.0 to 3.1.1 +--------------------------- + +1. Six new translations. + +2. Having more than 4 different values for OFMT and/or CONVFMT now works. + +3. The handling of dynamic regexes is now more more sane, esp. w.r.t. + the profiling code. The profiling code has been fixed in several + places. + +4. The return value of index("", "") is now 1. + +5. Gawk should no longer close fd 0 in child processes. + +6. Fixed test for strtod semantics and regenerated configure. + +7. Gawk can now be built with byacc; an accidental bison dependency was + removed. + +8. `yyerror' will no longer dump core on long source lines. + +9. Gawk now correctly queries getgroups(2) to figure out how many groups + the process has. + +10. New configure option to force use of included strftime, e.g. on + Solaris systems. See `./configure --help' for the details. Replaced + the included strftime.c with the one from textutils. + +11. OS/2 port has been updated. + +12. Multi-byte character support has been added, courtesy of IBM Japan. + +13. The `for (iggy in foo) delete foo[iggy]' -> `delete foo' optimisation + now works. + +14. Upgraded to gettext 0.11.2 and automake 1.5. + +15. Full gettext compatibility (new dcngettext function). + +16. The O'Reilly copyedits and indexing changes for the documentation have + been folded into the texinfo version of the manuals. + +17. A humongously long value for the AWKPATH environment variable will no + longer dump core. + +18. Configuration / Installation issues have been straightened out in + Makefile.am. + +Changes from 3.0.6 to 3.1.0 +--------------------------- + +1. A new PROCINFO array provides info about the process. The non-I/O /dev/xxx + files are now obsolete, and their use always generates a warning. + +2. A new `mktime' builtin function was added for creating time stamps. The + `mktime' function written in awk was removed from the user's guide. + +3. New `--gen-po' option creates GNU gettext .po files for strings marked + with a leading underscore. + +4. Gawk now completely interprets special file names internally, ignoring the + existence of real /dev/stdin, /dev/stdout files, etc. + +5. The mmap code was removed. It was a worthwhile experiment that just + didn't work out. + +6. The BINMODE variable is new; on non-UNIX systems it affects how gawk + opens files for text vs. binary. + +7. The atari port is now unsupported. + +8. Gawk no longer supports `next file' as two words. + +9. On systems that support it, gawk now sets the `close on exec' flag on all + files and pipes it opens. This makes sure that child processes run via + `system' or pipes have plenty of file descriptors available. + +10. New ports: Tandem and BeOS. The Tandem port is unsupported. + +11. If `--posix' is in effect, newlines are not allowed after ?:. + +12. Weird OFMT/CONVFMT formats no longer cause fatal errors. + +13. Diagnostics about array parameters now include the parameter's name, + not just its number. + +14. configure should now automatically add -D_SYSV3 for ISC Unix. + (This seems to have made it into the gawk 3.0.x line long ago.) + +15. It is now possible to open a two-way pipe via the `|&' operator. + See the discussion in the manual about putting `sort' into such a pipeline, + though. (NOTE! This is borrowed from ksh: it is not the same as + the same operator in csh!) + +16. The `close' function now takes an optional second string argument + that allows closing one or the other end of the two-way pipe to + a co-process. This is needed to use `sort' in a co-process, see + the doc. + +17. If TCP/IP is available, special file names beginning with `/inet' + can be used with `|&' for IPC. Thanks to Juergen Kahrs for the initial + code. + +18. With `--enable-portals' on the configure command line, gawk will also + treat file names that start with `/p/' as a 4.4 BSD type portal file, + i.e., a two-way pipe for `|&'. + +19. Unrecognized escapes, such as "\q" now always generate a warning. + +20. The LINT variable is new; it provides dynamic control over the --lint + option. + +21. Lint warnings can be made fatal by using --lint=fatal or `LINT = "fatal"'. + Use this if you're really serious about portable code. + +22. Due to an enhanced sed script, there is no longer any need to worry + about finding or using alloca. alloca.c is thus now gone. + +23. A number of lint warnings have been added. Most notably, gawk will + detect if a variable is used before assigned to. Warnings for + when a string that isn't a number gets converted to a number are + in the code but disabled; they seem to be too picky in practice. + + Also, gawk will now warn about function parameter names that shadow + global variable names. + +24. It is now possible to dynamically add builtin functions on systems + that support dlopen. This facility is not (yet) as portable or well + integrated as it might be. *** WARNING *** THIS FEATURE WILL EVOLVE! + +25. There are *many* new tests in the test suite. + +26. Profiling has been added! A separate version of gawk, named pgawk, is + built and generates a run-time execution profile. The --profile option + can be used to change the default output file. In regular gawk, this + option pretty-prints the parse tree. + +27. Gawk has been internationalized, using GNU gettext. Translations for + future distributions are most welcome. Simultaneously, gawk was switched + over to using automake. You need Automake 1.4a (from the CVS archive) + if you want to muck with the Makefile.am files. + +28. New `asort' function for sorting arrays. See the doc for details. + +29. The match function takes an optional array third argument to hold + the text matched by parenthesized sub-expressions. + +30. The bit op functions and octal and hex source code constants are on by + default, no longer a configure-time option. Recognition of non-decimal + data is now enabled at runtime with --non-decimal-data command line option. + +31. Internationalization features available at the awk level: new TEXTDOMAIN + variable and `bindtextdomain' and `dcgettext' functions. printf formats + may contain the "%2$3.5d" kind of notation for use in translations. See + the texinfo manual for details. + +32. The return value from `close' has been rationalized. Most notably, + closing something that wasn't open returns -1 but remains non-fatal. + +33. The array effeciency change from 3.0.5 was reverted; the semantics were + not right. Additionally, index values of previously stored elements + can no longer change dynamically. + +34. The new option --dump-variables dumps a list of all global variables and + their final types and values to a file you give, or to `awkvars.out'. + +35. Gawk now uses a recent version of random.c courtesy of the FreeBSD + project. + +36. The gawk source code now uses ANSI C function definitions (new style), + with ansi2knr to translate code for old compilers. + +37. `for (iggy in foo)' loops should be more robust now in the face of + adding/deleting elements in the middle; they loop over just the elements + that are present in the array when the loop starts. + +Changes from 3.0.5 to 3.0.6 +--------------------------- + +This is a bug fix release only, pending further development on 3.1.0. + +Bugs fixed and changes made: + +1. Subscripting an array with a variable that is just a number no + longer magically converts the variable into a string. + +2. Similarly, running a `for (iggy in foo)' loop where `foo' is a + function parameter now works correctly. + +3. Similarly, `i = ""; v[i] = a; if (i in v) ...' now works again. + +4. Gawk now special cases `for (iggy in foo) delete foo[iggy]' and + treats it as the moral equivalent of `delete foo'. This should be + a major efficiency win when portably deleting large arrays. + +5. VMS port brought up to date. + +Changes from 3.0.4 to 3.0.5 +--------------------------- + +This is a bug fix release only, pending further development on 3.1.0. + +Bugs Fixed: + + 1. `function foo(foo)' is now a fatal error. + + 2. Array indexing is now much more efficient: where possible, only one + copy of an index string is kept, even if used in multiple arrays. + + 3. Support was added for MacOS X and an `install-strip' target. + + 4. [s]printf formatting for `0' flag and floating point formats now + works correctly. + + 5. HP-UX large file support with GCC 2.95.1 now works. + + 6. Arguments that contain `=' but that aren't syntactically valid are + now treated as filenames, instead of as fatal errors. + + 7. `-v NF=foo' now works. + + 8. Non-ascii alphanumeric characters are now treated as such in the + right locales by regex.c. Similarly, a Latin-1 y-umlaut (decimal + value 255) in the program text no longer acts like EOF. + + 9. Array indexes are always compared as strings; fixes an obscure bug + when user input gets used for the `x in array' test. + +10. The usage message now points users to the documentation for how + to report bugs. + +11. `/=' now works after an array. + +12. `b += b += 1' now works correctly. + +13. IGNORECASE changing with calls `match' now works better. (Fix for + semi-obscure bug.) + +14. Multicharacter values for RS now generate a lint warning. + +15. The gawk open file caching is now much more efficient. + +16. Global arrays passed to functions are now managed better. In particular, + test/arynocls.awk won't crash referencing freed memory. + +17. In obscure cases, `getline var' can no longer clobber $0. + +Changes from 3.0.3 to 3.0.4 +--------------------------- + +This is a bug fix release only, pending further development on 3.1.0. + +Bugs Fixed: + + 1. A memory leak when turning a function parameter into an array was + fixed. + + 2. The non-decimal data option now works correctly. + + 3. Using an empty pair of brackets as an array subscript no longer causes + a core dump during parsing. In general, syntax errors should not + cause core dumps any more. + + 4. Standard input is no longer closed if it provides program source, + avoiding strange I/O problems. + + 5. Memory corruption during printing with `print' has been fixed. + + 6. The gsub function now correctly counts the number of matches. + + 7. A typo in doc/Makefile.in has been fixed, making installation work. + + 8. Calling `next' or `nextfile' from a BEGIN or END rule is now fatal. + + 9. Subtle problems in rebuilding $0 when fields were changed have been + fixed. + +10. `FS = FS' now correctly turns off the use of FIELDWIDTHS. + +11. Gawk now parses fields correctly when FS is a single character. + +12. It is now possible for RS to be the NUL character ("\0"). + +13. Weird problems with number conversions on MIPS and other systems + have been fixed. + +14. When parsing using FIELDWIDTHS is in effect, `split' with no third + argument will still use the value of FS. + +15. Large File Support for Solaris, HP-UX, AIX, and IRIX is now enabled at + compile time, thanks to Paul Eggert. + +16. Attempting to use the name of a function as a variable or array + from within the function is now caught as a fatal error, instead + of as a core dump. + +17. A bug in parsing hex escapes was fixed. + +18. A weird bug with concatenation where one expression has side effects + that changes another was fixed. + +19. printf/sprintf now behave much better for uses of the '0' and '#' flags + and with precisions and field widths. + +20. Further strangenesses with concatenation and multiple accesses of some + of the special variables was fixed. + +21. The Atari port is marked as no longer supported. + +22. Build problems on HP-UX have been fixed. + +23. Minor fixes and additional explanations added to the documentation. + +24. For RS = "", even a single leading newline is now correctly stripped. + +25. Obscure parsing problems for regex constants like /=.../ fixed, so + that a regex constant is recognized, and not the /= operator. + +26. Fixed a bug when closing a redirection that matched the current + or last FILENAME. + +27. Build problems on AIX fixed. + +Changes from 3.0.2 to 3.0.3 +--------------------------- + +The horrendous per-record memory leak introduced in 3.0.1 is gone, finally. + +The `amiga' directory is now gone; Amiga support is now entirely handled +by the POSIX support. + +Windows32 support has been added in the `pc' directory. See `README_d/README.pc' +for more info. + +The mmap changes are disabled in io.c, and will be removed entirely +in the next big release. They were an interesting experiment that just +really didn't work in practice. + +A minor memory leak that occurred when using `next' from within a +function has also been fixed. + +Problems with I/O from sub-processes via a pipe are now gone. + +Using "/dev/pid" and the other special /dev files no longer causes a core dump. + +The files regex.h, regex.c, getopt.h, getopt.c, and getopt1.c have been +merged with the versions in GNU libc. Thanks to Ulrich Drepper for his help. + +Some new undocumented features have been added. Use the source, Luke! +It is not clear yet whether these will ever be fully supported. + +Array performance should be much better for very very large arrays. "Virtual +memory required, real memory helpful." + +builtin.c:do_substr rationalized, again. + +The --re-interval option now works as advertised. + +The license text on some of the missing/* files is now generic. + +Lots more new test cases. + +Lots of other small bugs fixed, see the ChangeLog files for details. + +Changes from 3.0.1 to 3.0.2 +--------------------------- + +Gawk now uses autoconf 2.12. + +strftime now behaves correctly if passed an empty format string or if +the string formats to an empty result string. + +Several minor compilation and installation problems have been fixed. + +Minor page break issues in the user's guide have been fixed. + +Lexical errors no longer repeat ad infinitum. + +Changes from 3.0.0 to 3.0.1 +--------------------------- + +Troff source for a handy-dandy five color reference card is now provided. +Thanks to SSC for their macros. + +Gawk now behaves like Unix awk and mawk, in that newline acts as white +space for separating fields and for `split', by default. In posix mode, +only space and tab separate fields. The documentation has been updated to +reflect this. + +Tons and tons of small bugs fixed and new tests added, see the ChangeLogs. + +Lots fewer compile time warnings from gcc -Wall. Remaining ones aren't +worth fixing. + +Gawk now pays some attention to the locale settings. + +Fixes to gsub to catch several corner cases. + +The `print' statement now evaluates all expressions first, and then +prints them. This leads to less suprising behaviour if any expression has +output side effects. + +Miscellanious improvements in regex.h and regex.c. + +Gawk will now install itself as gawk-M.N.P in $(bindir), and link +`gawk' to it. This makes it easy to have multiple versions of gawk +simultaneously. It will also now install itself as `awk' in $(bindir) +if there is no `awk' there. This is in addition to installing itself as +`gawk'. This change benefits the Hurd, and possibly other systems. One +day, gawk will drop the `g', but not yet. + +`--posix' turns on interval expressions. Gawk now matches its documentation. + +`close(FILENAME)' now does something meaningful. + +Field management code in field.c majorly overhauled, several times. + +The gensub code has been fixed, several bugs are now gone. + +Gawk will use mmap for data file input if it is available. + +The printf/sprintf code has been improved. + +Minor issues in Makefile setup worked on and improved. + +builtin.c:do_substr rationalized. + +Regex matching fixed so that /+[0-9]/ now matches the leading +. + +For building on vms, the default compiler is now DEC C rather than VAX C. + +Changes from 2.15.6 to 3.0.0 +---------------------------- + +Fixed spelling of `Programming' in the copyright notice in all the files. + +New --re-interval option to turn on interval expressions. They're off +by default, except for --posix, to avoid breaking old programs. + +Passing regexp constants as parameters to user defined functions now +generates a lint warning. + +Several obscure regexp bugs fixed; alas, a small number remain. + +The manual has been thoroughly revised. It's now almost 50% bigger than +it used to be. + +The `+' modifier in printf is now reset correctly for each item. + +The do_unix variable is now named do_traditional. + +Handling of \ in sub and gsub rationalized (somewhat, see the manual for +the gory [and I do mean gory] details). + +IGNORECASE now uses ISO 8859-1 Latin-1 instead of straight ASCII. See the +source for how to revert to pure ASCII. + +--lint will now warn if an assignment occurs in a conditional context. +This may become obnoxious enough to need turning off in the future, but +"it seemed like a good idea at the time." + +%hf and %Lf are now diagnosed as invalid in printf, just like %lf. + +Gawk no longer incorrectly closes stdin in child processes used in +input pipelines. + +For integer formats, gawk now correctly treats the precision as the +number of digits to print, not the number of characters. + +gawk is now much better at catching the use of scalar values when +arrays are needed, both in function calls and the `x in y' constructs. + +New gensub function added. See the manual. + +If do_tradtional is true, octal and hex escapes in regexp constants are +treated literally. This matches historical behavior. + +yylex/nextc fixed so that even null characters can be included +in the source code. + +do_format now handles cases where a format specifier doesn't end in +a control letter. --lint reports an error. + +strftime() now uses a default time format equivalent to that of the +Unix date command, thus it can be called with no arguments. + +Gawk now catches functions that are used but not defined at parse time +instead of at run time. (This is a lint error, making it fatal could break +old code.) + +Arrays that max out are now handled correctly. + +Integer formats outside the range of an unsigned long are now detected +correctly using the SunOS 4.x cc compiler. + +--traditional option added as new preferred name for --compat, in keeping +with GCC. + +--lint-old option added, so that warnings about things not in old awk +are only given if explicitly asked for. + +`next file' has changed to one word, `nextfile'. `next file' is still +accepted but generates a lint warning. `next file' will go away eventually. + +Gawk with --lint will now notice empty source files and empty data files. + +Amiga support using the Unix emulation added. Thanks to fnf@ninemoons.com. + +test/Makefile is now "parallel-make safe". + +Gawk now uses POSIX regexps + GNU regex ops by default. --posix goes to +pure posix regexps, and --compat goes to traditional Unix regexps. However, +interval expressions, even though specified by POSIX, are turned off by +default, to avoid breaking old code. + +IGNORECASE now applies to string comparison as well as regexp operations. + +The AT&T Bell Labs Research awk fflush builtin function is now supported. +fflush is extended to flush stdout if no arg and everything if given +the null string as an argument. + +If RS is more than one character, it is treated as a regular expression +and records are delimited accordingly. The variable RT is set to the record +terminator string. This is disabled in compatibility mode. + +If FS is set to the null string (or the third arg. of split() is the null +string), splitting is done at every single character. This is disabled in +compatibility mode. + +Gawk now uses the Autoconf generated configure script, doing away with all +the config/* files and the machinery that went with them. The Makefile.in +has also changed accordingly, complete with all the standard GNU Makefile +targets. (Non-unix systems may still have their own config.h and Makefile; +see the appropriate README_d/README.* and/or subdirectory.) + +The source code has been cleaned up somewhat and the formatting improved. + +Changes from 2.15.5 to 2.15.6 +----------------------------- + +Copyrights updated on all changed files. + +test directory enhanced with four new tests. + +Gawk now generates a warning for \x without following hexadecimal digits. +In this case, it returns 'x', not \0. + +Several fixes in main.c related to variable initialization: + CONVFMT has a default value + resetup is called before initializing variables + the varinit table fixed up a bit (see the comments) + +gawk.1 updated with new BUG REPORTS section. + +A plain `print' inside a BEGIN or END now generates a lint warning (awk.y). + +Small fix in iop.c:get_a_record to avoid reading uninitialized memory. + +awk.y:yylex now does a better job of handling things if the source file +does not end in a newline. Probably there is more work to be done. + +Memory leaks fixed in awk.y, particularly in cases of duplicate function +parameters. Also, calling a function doesn't leak memory during parsing. + +Empty function bodies are now allowed (awk.y). + +Gawk now detects duplicate parameter names in functions (awk.y). + +New function `error' in msg.c added for use from awk.y. + +eval.c:r_get_lhs now checks if its argument is a parameter on the stack, +and pulls down the real variable. This catches more 'using an array as +a scalar' kinds of errors. + +main.c recovers C alloca space after parsing, this is important for +bison-based parsers. re.c recovers C alloca space after doing an research. +[Changes from Pat Rankin] + +builtin.c now declares the random() related functions based on +RANDOM_MISSING from config.h. [Suggested by Pat Rankin] + +awk.h now handles alloca correctly for HP-UX. [Kaveh Ghazi] + +regex.h and config/cray60 updated for Unicos 8.0. [Hal Peterson] + +Fixed re.c and dfa.c so that gawk no longer leaks memory when using +lots of dynamic regexps. + +Removed dependency on signed chars from `idx' variable in awk.h. Gawk +now passes its test suite if compiled with `gcc -fno-signed-char'. + +Fixed warning on close in io.c to go under lint control. Too many people +have complained about the spurious message, particularly when closing a +child pipeline early. + +Gawk now correctly handles RS = "" when input is from a terminal +(iop.c:get_a_record). + +Config file added for GNU. + +gawk 'BEGIN { exit 1 } ; END { exit }' now exits 1, as it should +(eval.c:interpret). + +sub and gsub now follow posix, \ escapes both & and \. Each \ must +be doubled initially in the program to get it into the string. +Thanks to Mike Brennan for pointing this out (builtin.c:sub_common). + +If FS is "", gawk behaves like mawk and nawk, making the whole record be $1. +Yet Another Dark Corner. Sigh (field.c:def_parse_field). + +Gawk now correctly recomputes string values for numbers if CONVFMT has +changed (awk.h:force_string, node.c:r_force_string). + +A regexp of the form `/* this looks like a comment but is not */' will +now generate a warning from --lint (awk.y). + +Gawk will no longer core dump if given an empty input file (awk.y:get_src_buf, +iop.c:optimal_bufsize). + +A printf format of the form %lf is handled correctly. The `l' generates +a lint warning (builtin.c:format_tree) [Thanks to Mark Moraes]. + +Lynxos config file added. + +`continue' outside a loop treated as `next' only in compatibility mode, +instead of by default; recent att nawk chokes on this now. `break' +outside a loop now treated as `next' in compatibility mode (eval.c). + +Bug fix in string concatenation, an arbitrary number of expressions +are allowed (eval.c). + +$1 += $2 now works correctly (eval.c). + +Changing IGNORECASE no longer resets field-splitting to FS if it was +using FIELDWIDTHS (eval.c, field.c). + +Major enhancement: $0 and NF for last record read are now preserved +into the END rule (io.c). + +Regexp fixes: + /./ now matches a newline (regex.h) + ^ and $ match beginning and end of string only, not any embedded + newlines (re.c) + regex.c should compile and work ok on 64-bit mips/sgi machines + +Changes from 2.15.4 to 2.15.5 +----------------------------- + +FUTURES file updated and re-arranged some with more rational schedule. + +Many prototypes handled better for ANSI C in protos.h. + +getopt.c updated somewhat. + +test/Makefile now removes junk directory, `bardargtest' renamed `badargs.' + +Bug fix in iop.c for RS = "". Eat trailing newlines off of record separator. + +Bug fix in Makefile.bsd44, use leading tab in actions. + +Fix in field.c:set_FS for FS == "\\" and IGNORECASE != 0. + +Config files updated or added: + cray60, DEC OSF/1 2.0, Utek, sgi405, next21, next30, atari/config.h, + sco. + +Fix in io.c for ENFILE as well as EMFILE, update decl of groupset to +include OSF/1. + +Rationalized printing as integers if numbers are outside the range of a long. +Changes to node.c:force_string and builtin.c. + +Made internal NF, NR, and FNR variables longs instead of ints. + +Add LIMITS_H_MISSING stuff to config.in and awk.h, and default defs for +INT_MAX and LONG_MAX, if no limits.h file. Add a standard decl of +the time() function for __STDC__. From ghazi@noc.rutgers.edu. + +Fix tree_eval in awk.h and r_tree_eval in eval.c to deal better with +function parameters, particularly ones that are arrays. + +Fix eval.c to print out array names of arrays used in scalar contexts. + +Fix eval.c in interpret to zero out source and sourceline initially. This +does a better job of providing source file and line number information. + +Fix to re_parse_field in field.c to not use isspace when RS = "", but rather +to explicitly look for blank and tab. + +Fix to sc_parse_field in field.c to catch the case of the FS character at the +end of a record. + +Lots of miscellanious bug fixes for memory leaks, courtesy Mark Moraes, +also fixes for arrays. + +io.c fixed to warn about lack of explicit closes if --lint. + +Updated missing/strftime.c to match posted strftime 6.2. + +Bug fix in builtin.c, in case of non-match in sub_common. + +Updated constant used for division in builtin.c:do_rand for DEC Alpha +and CRAY Y-MP. + +POSIXLY_CORRECT in the environment turns on --posix (fixed in main.c). + +Updated srandom prototype and calls in builtin.c. + +Fix awk.y to enforce posix semantics of unary +: result is numeric. + +Fix array.c to not rearrange the hash chain upon finding an index in +the array. This messed things up in cases like: + for (index1 in array) { + blah + if (index2 in array) # blew away the for + stuff + } + +Fixed spelling errors in the man page. + +Fixes in awk.y so that + gawk '' /path/to/file +will work without core dumping or finding parse errors. + +Fix main.c so that --lint will fuss about an empty program. +Yet another fix for argument parsing in the case of unrecognized options. + +Bug fix in dfa.c to not attempt to free null pointers. + +Bug fix in builtin.c to only use DEFAULT_G_PRECISION for %g or %G. + +Bug fix in field.c to achieve call by value semantics for split. + +Changes from 2.15.3 to 2.15.4 +----------------------------- + +Lots of lint fixes, and do_sprintf made mostly ANSI C compatible. + +Man page updated and edited. + +Copyrights updated. + +Arrays now grow dynamically, initially scaling up by an order of magnitude + and then doubling, up to ~ 64K. This should keep gawk's performance + graceful under heavy load. + +New `delete array' feature added. Only documented in the man page. + +Switched to dfa and regex suites from grep-2.0. These offer the ability to + move to POSIX regexps in the next release. + +Disabled GNU regex ops. + +Research awk -m option now recognized. It does nothing in gawk, since gawk + has no static limits. Only documented in the man page. + +New bionic (faster, better, stronger than before) hashing function. + +Bug fix in argument handling. `gawk -X' now notices there was no program. + Additional bug fixes to make --compat and --lint work again. + +Many changes for systems where sizeof(int) != sizeof(void *). + +Add explicit alloca(0) in io.c to recover space from C alloca. + +Fixed file descriptor leak in io.c. + +The --version option now follows the GNU coding standards and exits. + +Fixed several prototypes in protos.h. + +Several tests updated. On Solaris, warn that the out? tests will fail. + +Configuration files for SunOS with cc and Solaris 2.x added. + +Improved error messages in awk.y on gawk extensions if do_unix or do_compat. + +INSTALL file added. + +Fixed Atari Makefile and several VMS specific changes. + +Better conversion of numbers to strings on systems with broken sprintfs. + +Changes from 2.15.2 to 2.15.3 +----------------------------- + +Increased HASHSIZE to a decent number, 127 was way too small. + +FILENAME is now the null string in a BEGIN rule. + +Argument processing fixed for invalid options and missing arguments. + +This version will build on VMS. This included a fix to close all files + and pipes opened with redirections before closing stdout and stderr. + +More getpgrp() defines. + +Changes for BSD44: in io.c and Makefile.bsd44. + +All directories in the distribution are now writable. + +Separated LDFLAGS and CFLAGS in Makefile. CFLAGS can now be overridden by + user. + +Make dist now builds compressed archives ending in .gz and runs doschk. + +Amiga port. + +New getopt.c fixes Alpha OSF/1 problem. + +Make clean now removes possible test output. + +Improved algorithm for multiple adjacent string concatenations leads to + performance improvements. + +Fix nasty bug whereby command-line assignments, both with -v and at run time, + could create variables with syntactically illegal names. + +Fix obscure bug in printf with %0 flag and filling. + +Add a lint check for substr if provided length exceeds remaining characters + in string. + +Update atari support. + +PC support enhanced to include support for both DOS and OS/2. (Lots more + #ifdefs. Sigh.) + +Config files for Hitachi Unix and OSF/1, courtesy of Yoko Morishita + (morisita@sra.co.jp) + +Changes from 2.15.1 to 2.15.2 +----------------------------- + +Additions to the FUTURES file. + +Document undefined order of output when using both standard output + and /dev/stdout or any of the /dev output files that gawk emulates in + the absence of OS support. + +Clean up the distribution generation in Makefile.in: the info files are + now included, the distributed files are marked read-only and patched + distributions are now unpacked in a directory named with the patch level. + +Changes from 2.15 to 2.15.1 +--------------------------- + +Close stdout and stderr before all redirections on program exit. This allows + detection of write errors and also fixes the messages test on Solaris 2.x. + +Removed YYMAXDEPTH define in awk.y which was limiting the parser stack depth. + +Changes to config/bsd44, Makefile.bsd44 and configure to bring it into line + with the BSD4.4 release. + +Changed Makefile to use prefix, exec_prefix, bindir etc. + +make install now installs info files. + +make install now sets permissions on installed files. + +Make targets added: uninstall, distclean, mostlyclean and realclean. + +Added config.h to cleaner and clobber make targets. + +Changes to config/{hpux8x,sysv3,sysv4,ultrix41} to deal with alloca(). + +Change to getopt.h for portability. + +Added more special cases to the getpgrp() call. + +Added README.ibmrt-aos and config/ibmrt-aos. + +Changes from 2.14 to 2.15 +--------------------------- + +Command-line source can now be mixed with library functions. + +ARGIND variable tracks index in ARGV of FILENAME. + +GNU style long options in addition to short options. + +Plan 9 style special files interpreted by gawk: + /dev/pid + /dev/ppid + /dev/pgrpid + /dev/user + $1 = getuid + $2 = geteuid + $3 = getgid + $4 = getegid + $5 ... $NF = getgroups if supported + +ERRNO variable contains error string if getline or close fails. + +Very old options -a and -e have gone away. + +Inftest has been removed from the default target in test/Makefile -- the + results were too machine specific and resulted in too many false alarms. + +A README.amiga has been added. + +The "too many arguments supplied for format string" warning message is only + in effect under the lint option. + +Code improvements in dfa.c. + +Fixed all reported bugs: + + Writes are checked for failure (such as full filesystem). + + Stopped (at least some) runaway error messages. + + gsub(/^/, "x") does the right thing for $0 of 0, 1, or more length. + + close() on a command being piped to a getline now works properly. + + The input record will no longer be freed upon an explicit close() + of the input file. + + A NUL character in FS now works. + + In a substitute, \\& now means a literal backslash followed by what + was matched. + + Integer overflow of substring length in substr() is caught. + + An input record without a newline termination is handled properly. + + In io.c, check is against only EMFILE so that system file table + is not filled. + + Renamed all files with names longer than 14 characters. + + Escaped characters in regular expressions were being lost when + IGNORECASE was used. + + Long source lines were not being handled properly. + + Sourcefiles that ended in a tab but no newline were bombing. + + Patterns that could match zero characters in split() were not working + properly. + + The parsedebug option was not working. + + The grammar was being a bit too lenient, allowing some very dubious + programs to pass. + + Compilation with DEBUG defined now works. + + A variable read in with getline was not being treated as a potential + number. + + Array subscripts were not always of string type. + + +Changes from 2.13.2 to 2.14 +--------------------------- + +Updated manual! + +Added "next file" to skip efficiently to the next input file. + +Fixed potential of overflowing buffer in do_sprintf(). + +Plugged small memory leak in sub_common(). + +EOF on a redirect is now "sticky" -- it can only be cleared by close()ing + the pipe or file. + +Now works if used via a #! /bin/gawk line at the top of an executable file + when that line ends with whitespace. + +Added some checks to the grammar to catch redefinition of builtin functions. + This could eventually be the basis for an extension to allow redefining + functions, but in the mean time it's a good error catching facility. + +Negative integer exponents now work. + +Modified do_system() to make sure it had a non-null string to be passed + to system(3). Thus, system("") will flush any pending output but not go + through the overhead of forking an un-needed shell. + +A fix to floating point comparisons so that NaNs compare right on IEEE systems. + +Added code to make sure we're not opening directories for reading and such. + +Added code to do better diagnoses of weird or null file names. + +Allow continue outside of a loop, unless in strict posix mode. Lint option + will issue warning. + +New missing/strftime.c. There has been one change that affects gawk. Posix + now defines a %V conversion so the vms conversion has been changed to %v. + If this version is used with gawk -Wlint and they use %V in a call to + strftime, they'll get a warning. + +Error messages now conform to GNU standard (I hope). + +Changed comparisons to conform to the description found in the file POSIX. + This is inconsistent with the current POSIX draft, but that is broken. + Hopefully the final POSIX standard will conform to this version. + (Alas, this will have to wait for 1003.2b, which will be a revision to + the 1003.2 standard. That standard has been frozen with the broken + comparison rules.) + +The length of a string was a short and now is a size_t. + +Updated VMS help. + +Added quite a few new tests to the test suite and deleted many due to lack of + written releases. Test output is only removed if it is identical to the + "good" output. + +Fixed a couple of bugs for reference to $0 when $0 is "" -- particularly in + a BEGIN block. + +Fixed premature freeing in construct "$0 = $0". + +Removed the call to wait_any() in gawk_popen(), since on at least some systems, + if gawk's input was from a pipe, the predecessor process in the pipe was a + child of gawk and this caused a deadlock. + +Regexp can (once again) match a newline, if given explicitly. + +nextopen() makes sure file name is null terminated. + +Fixed VMS pipe simulation. Improved VMS I/O performance. + +Catch . used in variable names. + +Fixed bug in getline without redirect from a file -- it was quitting after the + first EOF, rather than trying the next file. + +Fixed bug in treatment of backslash at the end of a string -- it was bombing + rather than doing something sensible. It is not clear what this should mean, + but for now I issue a warning and take it as a literal backslash. + +Moved setting of regexp syntax to before the option parsing in main(), to + handle things like -v FS='[.,;]' + +Fixed bug when NF is set by user -- fields_arr must be expanded if necessary + and "new" fields must be initialized. + +Fixed several bugs in [g]sub() for no match found or the match is 0-length. + +Fixed bug where in gsub() a pattern anchored at the beginning would still + substitute throughout the string. + +make test does not assume that . is in PATH. + +Fixed bug when a field beyond the end of the record was requested after + $0 was altered (directly or indirectly). + +Fixed bug for assignment to field beyond end of record -- the assigned value + was not found on subsequent reference to that field. + +Fixed bug for FS a regexp and it matches at the end of a record. + +Fixed memory leak for an array local to a function. + +Fixed hanging of pipe redirection to getline + +Fixed coredump on access to $0 inside BEGIN block. + +Fixed treatment of RS = "". It now parses the fields correctly and strips + leading whitespace from a record if FS is a space. + +Fixed faking of /dev/stdin. + +Fixed problem with x += x + +Use of scalar as array and vice versa is now detected. + +IGNORECASE now obeyed for FS (even if FS is a single alphabetic character). + +Switch to GPL version 2. + +Renamed awk.tab.c to awktab.c for MSDOS and VMS tar programs. + +Renamed this file (CHANGES) to NEWS. + +Use fmod() instead of modf() and provide FMOD_MISSING #define to undo + this change. + +Correct the volatile declarations in eval.c. + +Avoid errant closing of the file descriptors for stdin, stdout and stderr. + +Be more flexible about where semi-colons can occur in programs. + +Check for write errors on all output, not just on close(). + +Eliminate the need for missing/{strtol.c,vprintf.c}. + +Use GNU getopt and eliminate missing/getopt.c. + +More "lint" checking. + + +Changes from 2.13.1 to 2.13.2 +----------------------------- + +Toward conformity with GNU standards, configure is a link to mkconf, the latter + to disappear in the next major release. + +Update to config/bsd43. + +Added config/apollo, config/msc60, config/cray2-50, config/interactive2.2 + +sgi33.cc added for compilation using cc rather than gcc. + +Ultrix41 now propagates to config.h properly -- as part of a general + mechanism in configure for kludges -- #define anything from a config file + just gets tacked onto the end of config.h -- to be used sparingly. + +Got rid of an unnecessary and troublesome declaration of vprintf(). + +Small improvement in locality of error messages. + +Try to diagnose use of array as scalar and vice versa -- to be improved in + the future. + +Fix for last bug fix for Cray division code--sigh. + +More changes to test suite to explicitly use sh. Also get rid of + a few generated files. + +Fixed off-by-one bug in string concatenation code. + +Fix for use of array that is passed in from a previous function parameter. + Addition to test suite for above. + +A number of changes associated with changing NF and access to fields + beyond the end of the current record. + +Change to missing/memcmp.c to avoid seg. fault on zero length input. + +Updates to test suite (including some inadvertently left out of the last patch) + to invoke sh explicitly (rather than rely on #!/bin/sh) and remove some + junk files. test/chem/good updated to correspond to bug fixes. + +Changes from 2.13.0 to 2.13.1 +----------------------------- + +More configs and PORTS. + +Fixed bug wherein a simple division produced an erroneous FPE, caused by + the Cray division workaround -- that code is now #ifdef'd only for + Cray *and* fixed. + +Fixed bug in modulus implementation -- it was very close to the above + code, so I noticed it. + +Fixed portability problem with limits.h in missing.c + +Fixed portability problem with tzname and daylight -- define TZNAME_MISSING + if strftime() is missing and tzname is also. + +Better support for Latin-1 character set. + +Fixed portability problem in test Makefile. + +Updated PROBLEMS file. + +=============================== gawk-2.13 released ========================= +Changes from 2.12.42 to 2.12.43 +------------------------------- + +Typo in awk.y + +Fixed up strftime.3 and added doc. for %V. + +Changes from 2.12.41 to 2.12.42 +------------------------------- + +Fixed bug in devopen() -- if you had write permission in /dev, + it would just create /dev/stdout etc.!! + +Final (?) VMS update. + +Make NeXT use GFMT_WORKAROUND + +Fixed bug in sub_common() for substitute on zero-length match. Improved the + code a bit while I was at it. + +Fixed grammar so that $i++ parses as ($i)++ + +Put support/* back in the distribution (didn't I already do this?!) + +Changes from 2.12.40 to 2.12.41 +------------------------------- + +VMS workaround for broken %g format. + +Changes from 2.12.39 to 2.12.40 +------------------------------- + +Minor man page update. + +Fixed latent bug in redirect(). + +Changes from 2.12.38 to 2.12.39 +------------------------------- + +Updates to test suite -- remove dependence on changing gawk.1 man page. + +Changes from 2.12.37 to 2.12.38 +------------------------------- + +Fixed bug in use of *= without whitespace following. + +VMS update. + +Updates to man page. + +Option handling updates in main.c + +test/manyfiles redone and added to bigtest. + +Fixed latent (on Sun) bug in handling of save_fs. + +Changes from 2.12.36 to 2.12.37 +------------------------------- + +Update REL in Makefile-dist. Incorporate test suite into main distribution. + +Minor fix in regtest. + +Changes from 2.12.35 to 2.12.36 +------------------------------- + +Release takes on dual personality -- 2.12.36 and 2.13.0 -- any further + patches before public release won't count for 2.13, although they will for + 2.12 -- be careful to avoid confusion! patchlevel.h will be the last thing + to change. + +Cray updates to deal with arithmetic problems. + +Minor test suite updates. + +Fixed latent bug in parser (freeing memory). + +Changes from 2.12.34 to 2.12.35 +------------------------------- + +VMS updates. + +Flush stdout at top of err() and stderr at bottom. + +Fixed bug in eval_condition() -- it wasn't testing for MAYBE_NUM and + doing the force_number(). + +Included the missing manyfiles.awk and a new test to catch the above bug which + I am amazed wasn't already caught by the test suite -- it's pretty basic. + +Changes from 2.12.33 to 2.12.34 +------------------------------- + +Atari updates -- including bug fix. + +More VMS updates -- also nuke vms/version.com. + +Fixed bug in handling of large numbers of redirections -- it was probably never + tested before (blush!). + +Minor rearrangement of code in r_force_number(). + +Made chem and regtest tests a bit more portable (Ultrix again). + +Added another test -- manyfiles -- not invoked under any other test -- very Unix + specific. + +Rough beginning of LIMITATIONS file -- need my AWK book to complete it. + +Changes from 2.12.32 to 2.12.33 +------------------------------- + +Expunge debug.? from various files. + +Remove vestiges of Floor and Ceil kludge. + +Special case integer division -- mainly for Cray, but maybe someone else + will benefit. + +Workaround for iop_close closing an output pipe descriptor on Cray -- + not conditional since I think it may fix a bug on SGI as well and I don't + think it can hurt elsewhere. + +Fixed memory leak in assoc_lookup(). + +Small cleanup in test suite. + +Changes from 2.12.31 to 2.12.32 +------------------------------- + +Nuked debug.c and debugging flag -- there are better ways. + +Nuked version.sh and version.c in subdirectories. + +Fixed bug in handling of IGNORECASE. + +Fixed bug when FIELDWIDTHS was set via -v option. + +Fixed (obscure) bug when $0 is assigned a numerical value. + +Fixed so that escape sequences in command-line assignments work (as it already + said in the comment). + +Added a few cases to test suite. + +Moved support/* back into distribution. + +VMS updates. + +Changes from 2.12.30 to 2.12.31 +------------------------------- + +Cosmetic manual page changes. + +Updated sunos3 config. + +Small changes in test suite including renaming files over 14 chars. in length. + +Changes from 2.12.29 to 2.12.30 +------------------------------- + +Bug fix for many string concatenations in a row. + +Changes from 2.12.28 to 2.12.29 +------------------------------- + +Minor cleanup in awk.y + +Minor VMS update. + +Minor atari update. + +Changes from 2.12.27 to 2.12.28 +------------------------------- + +Got rid of the debugging goop in eval.c -- there are better ways. + +Sequent port. + +VMS changes left out of the last patch -- sigh! config/vms.h renamed + to config/vms-conf.h. + +Fixed missing/tzset.c + +Removed use of gcvt() and GCVT_MISSING -- turns out it was no faster than + sprintf("%g") and caused all sorts of portability headaches. + +Tuned get_field() -- it was unnecessarily parsing the whole record on reference + to $0. + +Tuned interpret() a bit in the rule_node loop. + +In r_force_number(), worked around bug in Uglix strtod() and got rid of + ugly do{}while(0) at Michal's urging. + +Replaced do_deref() and deref with unref(node) -- much cleaner and a bit faster. + +Got rid of assign_number() -- contrary to comment, it was no faster than + just making a new node and freeing the old one. + +Replaced make_number() and tmp_number() with macros that call mk_number(). + +Changed freenode() and newnode() into macros -- the latter is getnode() + which calls more_nodes() as necessary. + +Changes from 2.12.26 to 2.12.27 +------------------------------- + +Completion of Cray 2 port (includes a kludge for floor() and ceil() + that may go or be changed -- I think that it may just be working around + a bug in chem that is being tweaked on the Cray). + +More VMS updates. + +Moved kludge over yacc's insertion of malloc and realloc declarations + from protos.h to the Makefile. + +Added a lisp interpreter in awk to the test suite. (Invoked under + bigtest.) + +Cleanup in r_force_number() -- I had never gotten around to a thorough + profile of the cache code and it turns out to be not worth it. + +Performance boost -- do lazy force_number()'ing for fields etc. i.e. + flag them (MAYBE_NUM) and call force_number only as necessary. + +Changes from 2.12.25 to 2.12.26 +------------------------------- + +Rework of regexp stuff so that dynamic regexps have reasonable + performance -- string used for compiled regexp is stored and + compared to new string -- if same, no recompilation is necessary. + Also, very dynamic regexps cause dfa-based searching to be turned + off. + +Code in dev_open() is back to returning fileno(std*) rather than + dup()ing it. This will be documented. Sorry for the run-around + on this. + +Minor atari updates. + +Minor vms update. + +Missing file from MSDOS port. + +Added warning (under lint) if third arg. of [g]sub is a constant and + handle it properly in the code (i.e. return how many matches). + +Changes from 2.12.24 to 2.12.25 +------------------------------- + +MSDOS port. + +Non-consequential changes to regexp variables in preparation for + a more serious change to fix a serious performance problem. + +Changes from 2.12.23 to 2.12.24 +------------------------------- + +Fixed bug in output flushing introduced a few patches back. This caused + serious performance losses. + +Changes from 2.12.22 to 2.12.23 +------------------------------- + +Accidentally left config/cray2-60 out of last patch. + +Added some missing dependencies to Makefile. + +Cleaned up mkconf a bit; made yacc the default parser (no alloca needed, + right?); added rs6000 hook for signed characters. + +Made regex.c with NO_ALLOCA undefined work. + +Fixed bug in dfa.c for systems where free(NULL) bombs. + +Deleted a few cant_happen()'s that *really* can't hapen. + +Changes from 2.12.21 to 2.12.22 +------------------------------- + +Added to config stuff the ability to choose YACC rather than bison. + +Fixed CHAR_UNSIGNED in config.h-dist. + +Second arg. of strtod() is char ** rather than const char **. + +stackb is now initially malloc()'ed since it may be realloc()'ed. + +VMS updates. + +Added SIZE_T_MISSING to config stuff and a default typedef to awk.h. + (Maybe it is not needed on any current systems??) + +re_compile_pattern()'s size is now size_t unconditionally. + +Changes from 2.12.20 to 2.12.21 +------------------------------- + +Corrected missing/gcvt.c. + +Got rid of use of dup2() and thus DUP_MISSING. + +Updated config/sgi33. + +Turned on (and fixed) in cmp_nodes() the behaviour that I *hope* will be in + POSIX 1003.2 for relational comparisons. + +Small updates to test suite. + +Changes from 2.12.19 to 2.12.20 +------------------------------- + +Sloppy, sloppy, sloppy!! I didn't even try to compile the last two + patches. This one fixes goofs in regex.c. + +Changes from 2.12.18 to 2.12.19 +------------------------------- + +Cleanup of last patch. + +Changes from 2.12.17 to 2.12.18 +------------------------------- + +Makefile renamed to Makefile-dist. + +Added alloca() configuration to mkconf. (A bit kludgey.) Just + add a single line containing ALLOCA_PW, ALLOCA_S or ALLOCA_C + to the appropriate config file to have Makefile-dist edited + accordingly. + +Reorganized output flushing to correspond with new semantics of + devopen() on "/dev/std*" etc. + +Fixed rest of last goof!! + +Save and restore errno in do_pathopen(). + +Miscellaneous atari updates. + +Get rid of the trailing comma in the NODETYPE definition (Cray + compiler won't take it). + +Try to make the use of `const' consistent since Cray compiler is + fussy about that. See the changes to `basename' and `myname'. + +It turns out that, according to section 3.8.3 (Macro Replacement) + of the ANSI Standard: ``If there are sequences of preprocessing + tokens within the list of arguments that would otherwise act as + preprocessing directives, the behavior is undefined.'' That means + that you cannot count on the behavior of the declaration of + re_compile_pattern in awk.h, and indeed the Cray compiler chokes on it. + +Replaced alloca with malloc/realloc/free in regex.c. It was much simpler + than expected. (Inside NO_ALLOCA for now -- by default no alloca.) + +Added a configuration file, config/cray60, for Unicos-6.0. + +Changes from 2.12.16 to 2.12.17 +------------------------------- + +Ooops. Goofed signal use in last patch. + +Changes from 2.12.15 to 2.12.16 +------------------------------- + +RENAMED *_dir to just * (e.g. missing_dir). + +Numerous VMS changes. + +Proper inclusion of atari and vms files. + +Added experimental (ifdef'd out) RELAXED_CONTINUATION and DEFAULT_FILETYPE + -- please comment on these! + +Moved pathopen() to io.c (sigh). + +Put local directory ahead in default AWKPATH. + +Added facility in mkconf to echo comments on stdout: lines beginning + with "#echo " will have the remainder of the line echoed when mkconf is run. + Any lines starting with "#" will otherwise be treated as comments. The + intent is to be able to say: + "#echo Make sure you uncomment alloca.c in the Makefile" + or the like. + +Prototype fix for V.4 + +Fixed version_string to not print leading @(#). + +Fixed FIELDWIDTHS to work with strict (turned out to be easy). + +Fixed conf for V.2. + +Changed semantics of /dev/fd/n to be like on real /dev/fd. + +Several configuration and updates in the makefile. + +Updated manpage. + +Include tzset.c and system.c from missing_dir that were accidently left out of + the last patch. + +Fixed bug in cmdline variable assignment -- arg was getting freed(!) in + call to variable. + +Backed out of parse-time constant folding for now, until I can figure out + how to do it right. + +Fixed devopen() so that getline <"-" works. + +Changes from 2.12.14 to 2.12.15 +------------------------------- + +Changed config/* to a condensed form that can be used with mkconf to generate + a config.h from config.h-dist -- much easier to maintain. Please check + carefully against what you had before for a particular system and report + any problems. vms.h remains separate since the stuff at the bottom + didn't quite fit the mkconf model -- hopefully cleared up later. + +Fixed bug in grammar -- didn't allow function definition to be separated from + other rules by a semi-colon. + +VMS fix to #includes in missing.c -- should we just be including awk.h? + +Updated README for texinfo.tex version. + +Updating of copyright in all .[chy] files. + +Added but commented out Michal's fix to strftime. + +Added tzset() emulation based on Rick Adams' code. Added TZSET_MISSING to + config.h-dist. + +Added strftime.3 man page for missing_dir + +More posix: func, **, **= don't work in -W posix + +More lint: ^, ^= not in old awk + +gawk.1: removed ref to -DNO_DEV_FD, other minor updating. + +Style change: pushbak becomes pushback() in yylex(). + +Changes from 2.12.13 to 2.12.14 +------------------------------- + +Better (?) organization of awk.h -- attempt to keep all system dependencies + near the top and move some of the non-general things out of the config.h + files. + +Change to handling of SYSTEM_MISSING. + +Small change to ultrix config. + +Do "/dev/fd/*" etc. checking at runtime. + +First pass at VMS port. + +Improvements to error handling (when lexeme spans buffers). + +Fixed backslash handling -- why didn't I notice this sooner? + +Added programs from book to test suite and new target "bigtest" to Makefile. + +Changes from 2.12.12 to 2.12.13 +------------------------------- + +Recognize OFS and ORS specially so that OFS = 9 works without efficiency hit. + Took advantage of opportunity to tune do_print*() for about 10% win on a + print with 5 args (i.e. small but significant). + +Somewhat pervasive changes to reconcile CONVFMT vs. OFMT. + +Better initialization of builtin vars. + +Make config/* consistent wrt STRTOL_MISSING. + +Small portability improvement to alloca.s + +Improvements to lint code in awk.y + +Replaced strtol() with a better one by Chris Torek. + +Changes from 2.12.11 to 2.12.12 +------------------------------- + +Added PORTS file to record successful ports. + +Added #define const to nothing if not STDC and added const to strtod() header. + +Added * to printf capabilities and partially implemented ' ' and '+' (has an + effect for %d only, silently ignored for other formats). I'm afraid that's + as far as I want to go before I look at a complete replacement for + do_sprintf(). + +Added warning for /regexp/ on LHS of MATCHOP. + +Changes from 2.12.10 to 2.12.11 +------------------------------- + +Small Makefile improvements. + +Some remaining nits from the NeXT port. + +Got rid of bcopy() define in awk.h -- not needed anymore (??) + +Changed private in builtin.c -- it is special on Sequent. + +Added subset implementation of strtol() and STRTOL_MISSING. + +A little bit of cleanup in debug.c, dfa.c. + +Changes from 2.12.9 to 2.12.10 +------------------------------ + +Redid compatability checking and checking for # of args. + +Removed all references to variables[] from outside awk.y, in preparation + for a more abstract interface to the symbol table. + +Got rid of a remaining use of bcopy() in regex.c. + +Changes from 2.12.8 to 2.12.9 +----------------------------- + +Portability improvements for atari, next and decstation. + +Bug fix in substr() -- wasn't handling 3rd arg. of -1 properly. + +Manpage updates. + +Moved support from src release to doc release. + +Updated FUTURES file. + +Added some "lint" warnings. + +Changes from 2.12.7 to 2.12.8 +----------------------------- + +Changed time() to systime(). + +Changed warning() in snode() to fatal(). + +strftime() now defaults second arg. to current time. + +Changes from 2.12.6 to 2.12.7 +----------------------------- + +Fixed bug in sub_common() involving inadequate allocation of a buffer. + +Added some missing files to the Makefile. + +Changes from 2.12.5 to 2.12.6 +----------------------------- + +Fixed bug wherein non-redirected getline could call iop_close() just + prior to a call from do_input(). + +Fixed bug in handling of /dev/stdout and /dev/stderr. + +Changes from 2.12.4 to 2.12.5 +----------------------------- + +Updated README and support directory. + +Changes from 2.12.3 to 2.12.4 +----------------------------- + +Updated CHANGES and TODO (should have been done in previous 2 patches). + +Changes from 2.12.2 to 2.12.3 +----------------------------- + +Brought regex.c and alloca.s into line with current FSF versions. + +Changes from 2.12.1 to 2.12.2 +----------------------------- + +Portability improvements; mostly moving system prototypes out of awk.h + +Introduction of strftime. + +Use of CONVFMT. + +Changes from 2.12 to 2.12.1 +----------------------------- + +Consolidated treatment of command-line assignments (thus correcting the +-v treatment). + +Rationalized builtin-variable handling into a table-driven process, thus +simplifying variable() and eliminating spc_var(). + +Fixed bug in handling of command-line source that ended in a newline. + +Simplified install() and lookup(). + +Did away with double-mallocing of identifiers and now free second and later +instances of a name, after the first gets installed into the symbol table. + +Treat IGNORECASE specially, simplifying a lot of code, and allowing +checking against strict conformance only on setting it, rather than on each +pattern match. + +Fixed regexp matching when IGNORECASE is non-zero (broken when dfa.c was +added). + +Fixed bug where $0 was not being marked as valid, even after it was rebuilt. +This caused mangling of $0. + + +Changes from 2.11.1 to 2.12 +----------------------------- + +Makefile: + +Portability improvements in Makefile. +Move configuration stuff into config.h + +FSF files: + +Synchronized alloca.[cs] and regex.[ch] with FSF. + +array.c: + +Rationalized hash routines into one with a different algorithm. +delete() now works if the array is a local variable. +Changed interface of assoc_next() and avoided dereferencing past the end of the + array. + +awk.h: + +Merged non-prototype and prototype declarations in awk.h. +Expanded tree_eval #define to short-circuit more calls of r_tree_eval(). + +awk.y: + +Delinted some of the code in the grammar. +Fixed and improved some of the error message printing. +Changed to accomodate unlimited length source lines. +Line continuation now works as advertised. +Source lines can be arbitrarily long. +Refined grammar hacks so that /= assignment works. Regular expressions + starting with /= are recognized at the beginning of a line, after && or || + and after ~ or !~. More contexts can be added if necessary. +Fixed IGNORECASE (multiple scans for backslash). +Condensed expression_lists in array references. +Detect and warn for correct # args in builtin functions -- call most of them + with a fixed number (i.e. fill in defaults at parse-time rather than at + run-time). +Load ENVIRON only if it is referenced (detected at parse-time). +Treat NF, FS, RS, NR, FNR specially at parse time, to improve run time. +Fold constant expressions at parse time. +Do make_regexp() on third arg. of split() at parse tiem if it is a constant. + +builtin.c: + +srand() returns 0 the first time called. +Replaced alloca() with malloc() in do_sprintf(). +Fixed setting of RSTART and RLENGTH in do_match(). +Got rid of get_{one,two,three} and allowance for variable # of args. at + run-time -- this is now done at parse-time. +Fixed latent bug in [g]sub whereby changes to $0 would never get made. +Rewrote much of sub_common() for simplicity and performance. +Added ctime() and time() builtin functions (unless -DSTRICT). ctime() returns + a time string like the C function, given the number of seconds since the epoch + and time() returns the current time in seconds. +do_sprintf() now checks for mismatch between format string and number of + arguments supplied. + +dfa.c + +This is borrowed (almost unmodified) from GNU grep to provide faster searches. + +eval.c + +Node_var, Node_var_array and Node_param_list handled from macro rather + than in r_tree_eval(). +Changed cmp_nodes() to not do a force_number() -- this, combined with a + force_number() on ARGV[] and ENVIRON[] brings it into line with other awks +Greatly simplified cmp_nodes(). +Separated out Node_NF, Node_FS, Node_RS, Node_NR and Node_FNR in get_lhs(). +All adjacent string concatenations now done at once. + +field.c + +Added support for FIELDWIDTHS. +Fixed bug in get_field() whereby changes to a field were not always + properly reflected in $0. +Reordered tests in parse_field() so that reference off the end of the buffer + doesn't happen. +set_FS() now sets *parse_field i.e. routine to call depending on type of FS. +It also does make_regexp() for FS if needed. get_field() passes FS_regexp + to re_parse_field(), as does do_split(). +Changes to set_field() and set_record() to avoid malloc'ing and free'ing the + field nodes repeatedly. The fields now just point into $0 unless they are + assigned to another variable or changed. force_number() on the field is + *only* done when the field is needed. + +gawk.1 + +Fixed troff formatting problem on .TP lines. + +io.c + +Moved some code out into iop.c. +Output from pipes and system() calls is properly synchronized. +Status from pipe close properly returned. +Bug in getline with no redirect fixed. + +iop.c + +This file contains a totally revamped get_a_record and associated code. + +main.c + +Command line programs no longer use a temporary file. +Therefore, tmpnam() no longer required. +Deprecated -a and -e options -- they will go away in the next release, + but for now they cause a warning. +Moved -C, -V, -c options to -W ala posix. +Added -W posix option: throw out \x +Added -W lint option. + + +node.c + +force_number() now allows pure numerics to have leading whitespace. +Added make_string facility to optimize case of adding an already malloc'd + string. +Cleaned up and simplified do_deref(). +Fixed bug in handling of stref==255 in do_deref(). + +re.c + +contains the interface to regexp code + +Changes from 2.11.1 to FSF version of same +------------------------------------------ +Thu Jan 4 14:19:30 1990 Jim Kingdon (kingdon at albert) + + * Makefile (YACC): Add -y to bison part. + + * missing.c: Add #include . + +Sun Dec 24 16:16:05 1989 David J. MacKenzie (djm at hobbes.ai.mit.edu) + + * Makefile: Add (commented out) default defines for Sony News. + + * awk.h: Move declaration of vprintf so it will compile when + -DVPRINTF_MISSING is defined. + +Mon Nov 13 18:54:08 1989 Robert J. Chassell (bob at apple-gunkies.ai.mit.edu) + + * gawk.texinfo: changed @-commands that are not part of the + standard, currently released texinfmt.el to those that are. + Otherwise, only people with the as-yet unreleased makeinfo.c can + format this file. + +Changes from 2.11beta to 2.11.1 (production) +-------------------------------------------- + +Went from "beta" to production status!!! + +Now flushes stdout before closing pipes or redirected files to +synchronize output. + +MS-DOS changes added in. + +Signal handler return type parameterized in Makefile and awk.h and +some lint removed. debug.c cleaned up. + +Fixed FS splitting to never match null strings, per book. + +Correction to the manual's description of FS. + +Some compilers break on char *foo = "string" + 4 so fixed version.sh and +main.c. + +Changes from 2.10beta to 2.11beta +--------------------------------- + +This release fixes all reported bugs that we could reproduce. Probably +some of the changes are not documented here. + +The next release will probably not be a beta release! + +The most important change is the addition of the -nostalgia option. :-) + +The documentation has been improved and brought up-to-date. + +There has been a lot of general cleaning up of the code that is not otherwise +documented here. There has been a movement toward using standard-conforming +library routines and providing them (in missing.d) for systems lacking them. +Improved (hopefully) configuration through Makfile modifications and missing.c. +In particular, straightened out confusion over vprintf #defines, declarations +etc. + +Deleted RCS log comments from source, to reduce source size by about one third. +Most of them were horribly out-of-date, anyway. + +Renamed source files to reflect (for the most part) their contents. + +More and improved error messages. Cleanup and fixes to yyerror(). +String constants are not altered in input buffer, so error messages come out +better. Fixed usage message. Make use of ANSI C strerror() function +(provided). + +Plugged many more memory leaks. The memory consumption is now quite +reasonable over a wide range of programs. + +Uses volatile declaration if STDC > 0 to avoid problems due to longjmp. + +New -a and -e options to use awk or egrep style regexps, respectively, +since POSIX says awk should use egrep regexps. Default is -a. + +Added -v option for setting variables before the first file is encountered. +Version information now uses -V and copyleft uses -C. + +Added a patchlevel.h file and its use for -V and -C. + +Append_right() optimized for major improvement to programs with a *lot* +of statements. + +Operator precedence has been corrected to match draft Posix. + +Tightened up grammar for builtin functions so that only length +may be called without arguments or parentheses. + +/regex/ is now a normal expression that can appear in any expression +context. + +Allow /= to begin a regexp. Allow ..[../..].. in a regexp. + +Allow empty compound statements ({}). + +Made return and next illegal outside a function and in BEGIN/END respectively. + +Division by zero is now illegal and causes a fatal error. + +Fixed exponentiation so that x ^ 0 and x ^= 0 both return 1. + +Fixed do_sqrt, do_log, and do_exp to do argument/return checking and +print an error message, per the manual. + +Fixed main to catch SIGSEGV to get source and data file line numbers. + +Fixed yyerror to print the ^ at the beginning of the bad token, not the end. + +Fix to substr() builtin: it was failing if the arguments +weren't already strings. + +Added new node value flag NUMERIC to indicate that a variable is +purely a number as opposed to type NUM which indicates that +the node's numeric value is valid. This is set in make_number(), +tmp_number and r_force_number() when appropriate and used in +cmp_nodes(). This fixed a bug in comparison of variables that had +numeric prefixes. The new code uses strtod() and eliminates is_a_number(). +A simple strtod() is provided for systems lacking one. It does no +overflow checking, so could be improved. + +Simplification and efficiency improvement in force_string. + +Added performance tweak in r_force_number(). + +Fixed a bug with nested loops and break/continue in functions. + +Fixed inconsistency in handling of empty fields when $0 has to be rebuilt. +Happens to simplify rebuild_record(). + +Cleaned up the code associated with opening a pipe for reading. Gawk +now has its own popen routine (gawk_popen) that allocates an IOBUF +and keeps track of the pid of the child process. gawk_pclose +marks the appropriate child as defunct in the right struct redirect. + +Cleaned up and fixed close_redir(). + +Fixed an obscure bug to do with redirection. Intermingled ">" and ">>" +redirects did not output in a predictable order. + +Improved handling of output buffering: now all print[f]s redirected to a tty +or pipe are flushed immediately and non-redirected output to a tty is flushed +before the next input record is read. + +Fixed a bug in get_a_record() where bcopy() could have copied over +a random pointer. + +Fixed a bug when RS="" and records separated by multiple blank lines. + +Got rid of SLOWIO code which was out-of-date anyway. + +Fix in get_field() for case where $0 is changed and then $(n) are +changed and then $0 is used. + +Fixed infinite loop on failure to open file for reading from getline. +Now handles redirect file open failures properly. + +Filenames such as /dev/stdin now allowed on the command line as well as +in redirects. + +Fixed so that gawk '$1' where $1 is a zero tests false. + +Fixed parsing so that `RLENGTH -1' parses the same as `RLENGTH - 1', +for example. + +The return from a user-defined function now defaults to the Null node. +This fixes a core-dump-causing bug when the return value of a function +is used and that function returns no value. + +Now catches floating point exceptions to avoid core dumps. + +Bug fix for deleting elements of an array -- under some conditions, it was +deleting more than one element at a time. + +Fix in AWKPATH code for running off the end of the string. + +Fixed handling of precision in *printf calls. %0.2d now works properly, +as does %c. [s]printf now recognizes %i and %X. + +Fixed a bug in printing of very large (>240) strings. + +Cleaned up erroneous behaviour for RS == "". + +Added IGNORECASE support to index(). + +Simplified and fixed newnode/freenode. + +Fixed reference to $(anything) in a BEGIN block. + +Eliminated use of USG rand48(). + +Bug fix in force_string for machines with 16-bit ints. + +Replaced use of mktemp() with tmpnam() and provided a partial implementation of +the latter for systems that don't have it. + +Added a portability check for includes in io.c. + +Minor portability fix in alloc.c plus addition of xmalloc(). + +Portability fix: on UMAX4.2, st_blksize is zero for a pipe, thus breaking +iop_alloc() -- fixed. + +Workaround for compiler bug on Sun386i in do_sprintf. + +More and improved prototypes in awk.h. + +Consolidated C escape parsing code into one place. + +strict flag is now turned on only when invoked with compatability option. +It now applies to fewer things. + +Changed cast of f._ptr in vprintf.c from (unsigned char *) to (char *). +Hopefully this is right for the systems that use this code (I don't). + +Support for pipes under MSDOS added. diff --git a/POSIX.STD b/POSIX.STD new file mode 100644 index 0000000..1555d7b --- /dev/null +++ b/POSIX.STD @@ -0,0 +1,43 @@ + Copyright (C) 1992, 1995, 1998, 2001, 2006, 2007, 2010, 2011 + Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. +-------------------------------------------------------------------------- +Thu Mar 31 22:31:57 IST 2011 +============================ +This file documents several things related to the 2008 POSIX standard +that I noted after reviewing it. + +1. POSIX leaves undefined what happens for something like + + awk '{ print ; exit }' if=42 /etc/passwd + + Mawk diagnoses this. Gawk and BWK awk do not. This doesn't seem to be + worth the effort to add the code, but at least I'm aware of it. + +2. The 2001-2004 standards accidentally required support for hexadecimal + floating point constants and for Infinity and Not-A-Number (NaN) values. + + The 2008 standard now explicitly allows, but does not require, such + support. + + More discussion is provided in the node `POSIX Floating Point Problems' + in gawk.texi. + +3. String comparison with <, <= etc is supposed to take the locale's collating + sequence into account. By default gawk doesn't do this. Rather, gawk + will do this only if --posix is in effect. + +The following things aren't described by POSIX but ought to be: + +1. The value of $0 in an END rule + +2. The return value of a function that either does return with no value + or that falls off the end of the function body. + +3. What happens with substr() if start is <= 0, or greater than the length + of the string, or if length is <= 0. + +4. Whether "next" can be invoked from a function body. diff --git a/PROBLEMS b/PROBLEMS new file mode 100644 index 0000000..072d56e --- /dev/null +++ b/PROBLEMS @@ -0,0 +1,15 @@ + Copyright (C) 2005, 2006 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + +This is a list of known problems in gawk 3.1. +I don't know when this will be fixed, if ever. See also FUTURES +and the gawk.texi doc for other things that need doing. + +1. The interactions with the lexer and yyerror need reworking. It is possible + to get line numbers that are one line off if --compat or --posix is + true and either `nextfile' or `delete array' are used. + + Really the whole lexical analysis stuff needs reworking. diff --git a/README b/README new file mode 100644 index 0000000..b752c65 --- /dev/null +++ b/README @@ -0,0 +1,94 @@ + Copyright (C) 2005, 2006, 2007, 2009, 2010, 2011, 2012 + Free Software Foundation, Inc. + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. + +README: + +This is GNU Awk 4.0.1. It is upwardly compatible with Brian Kernighan's +version of Unix awk. It is almost completely compliant with the +2008 POSIX 1003.1 standard for awk. (See the note below about POSIX.) + +This is a bug fix release. See NEWS and ChangeLog for details. + +Work to be done is described briefly in the FUTURES file. Changes in this +version are summarized in the NEWS file. Please read the LIMITATIONS file. + +Read the file POSIX.STD for a discussion of issues where the standard +says one thing but gawk does something different. + +To format the documentation with TeX, use at least version 2010-12-23.17 +of texinfo.tex. There is a usable copy of texinfo.tex in the doc directory. + +INSTALLATION: + +Check whether there is a system-specific README file for your system under +the `README_d' directory. If there's something there that you should +have read and didn't, and you bug me about it, I'm going to yell at you. + +See the file INSTALL for installation instructions. + +If you have neither bison nor yacc, use the awkgram.c file here. It was +generated with bison, and has no proprietary code in it. (Note that +modifying awkgram.y without bison or yacc will be difficult, at best. +You might want to get a copy of bison from the FSF too.) + +If you have an MS-DOS, MS-Windows, or OS/2 system, use the stuff in the `pc' +directory. Similarly, there is a separate directory for VMS. + +Appendix B of ``GAWK: Effective Awk Programming'' discusses configuration +in detail. The configuration process is based on GNU Autoconf and +Automake. + +After successful compilation, do `make check' to run the test suite. +There should be no output from the `cmp' invocations except in the +cases where there are small differences in floating point values, and +possibly in the case of strftime. Several of the tests ignore errors +on purpose; those are not a problem. If there are other differences, +please investigate and report the problem. + +PRINTING THE MANUAL + +The `doc' directory contains a recent version of texinfo.tex, which will +be necessary for printing the manual. Use `make dvi' to get a DVI file +from the manual. In the `doc' directory, use `make postscript' to get +PostScript versions of the manual, the man page, and the reference card. +Use `make pdf' to get PDF versions of the manuals, the man page and +the reference card. + +BUG REPORTS AND FIXES (Un*x systems): + +Please coordinate changes through Arnold Robbins. In particular, see +the section in the manual on reporting bugs. Note that comp.lang.awk +is about the worst place to post a gawk bug report. Please, use the +mechanisms outlined in the manual. + +Email should be sent to bug-gawk@gnu.org. This is now a separate mailing +list at GNU Central. The advantage to using this address is that bug +reports are archived at GNU Central. + +Arnold Robbins + +BUG REPORTS AND FIXES, non-Unix systems: + +MS-DOS with DJGPP: + Scott Deifik + scottd.mail@sbcglobal.net + +MS-Windows with MinGW: + Eli Zaretskii + eliz@gnu.org + +OS/2: + Andreas Buening + andreas.buening@nexgo.de + +VMS: + Pat Rankin + r.pat.rankin@gmail.com + +z/OS (OS/390): + Dave Pitts + dpitts@cozx.com diff --git a/README_d/ChangeLog b/README_d/ChangeLog new file mode 100644 index 0000000..b29f67a --- /dev/null +++ b/README_d/ChangeLog @@ -0,0 +1,17 @@ +2012-03-28 Arnold D. Robbins + + * 4.0.1: Release tar ball made. + +2011-07-29 Arnold D. Robbins + + * README.pc: Add download location info for DJGPP version. + +2011-07-15 Arnold D. Robbins + + * README.solaris: Info added on using the Solaris C compiler. + +2011-06-23 Arnold D. Robbins + + * ChangeLog.0: Rotated ChangeLog into this file. + * ChangeLog: Created anew for gawk 4.0.0 and on. + * 4.0.0: Release tar ball made. diff --git a/README_d/ChangeLog.0 b/README_d/ChangeLog.0 new file mode 100644 index 0000000..8cea065 --- /dev/null +++ b/README_d/ChangeLog.0 @@ -0,0 +1,8 @@ +2010-12-18 Eli Zaretskii + + * README.pc: Update and simplify. Remove lots of + outdated stuff for systems and configurations no longer supported. + +2010-12-18 Arnold Robbins + + * ChangeLog: Created. diff --git a/README_d/README.VMS b/README_d/README.VMS new file mode 100644 index 0000000..b47cb0f --- /dev/null +++ b/README_d/README.VMS @@ -0,0 +1,87 @@ + +Compiling GAWK on VMS: + + There's a DCL command procedure that will issue all the necessary +CC and LINK commands, and there's also a Makefile for use with the MMS +utility. From the source directory, use either + |$ @[.VMS]VMSBUILD.COM +or + |$ MMS/DECRIPTION=[.VMS]DECSRIP.MMS GAWK + +DEC C -- use either vmsbuild.com or descrip.mms as is. +VAX C -- use `@vmsbuild VAXC' or `MMS/MACRO=("VAXC")'. On a system + with both VAX C and DEC C installed where DEC C is the default, + use `MMS/MACRO=("VAXC","CC=CC/VAXC")' for the MMS variant; for + the vmsbuild.com variant, any need for `/VAXC' will be detected + automatically. +GNU C -- use `@vmsbuild GNUC' or `MMS/MACRO=("GNUC")'. On a system + where the GCC command is not already defined, use either + `@vmsbuild GNUC DO_GNUC_SETUP' or + `MMS/MACRO=("GNUC","DO_GNUC_SETUP")'. + + Tested under Alpha/VMS V7.1 using DEC C V6.4. GAWK should work +without modifications for VMS V4.6 and up. + + +Installing GAWK on VMS: + + All that's needed is a 'foreign' command, which is a DCL symbol +whose value begins with a dollar sign. + |$ GAWK :== $device:[directory]GAWK +(Substitute the actual location of gawk.exe for 'device:[directory]'.) +That symbol should be placed in the user's login.com or in the system- +wide sylogin.com procedure so that it will be defined every time the +user logs on. + + Optionally, the help entry can be loaded into a VMS help library. + |$ LIBRARY/HELP SYS$HELP:HELPLIB [.VMS]GAWK.HLP +(You may want to substitute a site-specific help library rather than +the standard VMS library 'HELPLIB'.) After loading the help text, + |$ HELP GAWK +will provide information about both the gawk implementation and the +awk programming language. + + The logical name AWK_LIBRARY can designate a default location +for awk program files. For the '-f' option, if the specified filename +has no device or directory path information in it, Gawk will look in +the current directory first, then in the directory specified by the +translation of AWK_LIBRARY if it the file wasn't found. If the file +still isn't found, then ".awk" will be appended and the file access +will be re-tried. If AWK_LIBRARY is not defined, that portion of the +file search will fail benignly. + + +Running GAWK on VMS: + + Command line parsing and quoting conventions are significantly +different on VMS, so examples in _The_GAWK_Manual_ or the awk book +often need minor changes. They *are* minor though, and all the awk +programs should run correctly. + + Here are a couple of trivial tests: + |$ gawk -- "BEGIN {print ""Hello, World!""}" + |$ gawk -"W" version !could also be -"W version" or "-W version" +Note that upper- and mixed-case text must be quoted. + + The VMS port of Gawk includes a DCL-style interface in addition +to the original shell-style interface. See the help entry for details. +One side-effect of dual command line parsing is that if there's only a +single parameter (as in the quoted string program above), the command +becomes ambiguous. To work-around this, the normally optional "--" +flag is required to force shell rather than DCL parsing. If any other +dash-type options (or multiple parameters such as data files to be +processed) are present, there is no ambiguity and "--" can be omitted. + + The logical name AWKPATH can be used to override the default +search path of "SYS$DISK:[],AWK_LIBRARY:" when looking for awk program +files specified by the '-f' option. The format of AWKPATH is a comma- +separated list of directory specifications. When defining it, the +value should be quoted so that it retains a single translation, not a +multi-translation RMS searchlist. + +------------------------------ +Thu Jun 18 05:22:10 IDT 2009 +============================ + +On OpenVMS V7.3 (Alpha) the "manyfiles" test is known to fail. The reason +is not (yet) known. diff --git a/README_d/README.bootstrap b/README_d/README.bootstrap new file mode 100644 index 0000000..152bbef --- /dev/null +++ b/README_d/README.bootstrap @@ -0,0 +1,32 @@ +Tue Dec 6 21:33:19 IST 2011 +============================ + +As documented in the mail below, if you are using a system without any +version of awk installed, you will have bootstrapping problems (i.e., running +configure). The solution is to install mawk or Brian Kernighan's awk +first. + +Arnold Robbins +------------------------------------ +From: Simon Josefsson +To: bug-gawk@gnu.org +Date: Sat, 19 Nov 2011 15:24:22 +0100 +Message-ID: <87r514faw9.fsf@latte.josefsson.org> +Subject: [bug-gawk] building gawk requires an awk? + +Hello, + +I was not able to build gawk 4.0.0 on a GNU/Hurd machine that didn't +have any awk, the ./configure script failed at the end: + +config.status: creating Makefile +./config.status: line 1169: awk: command not found +config.status: error: could not create Makefile + +Is this a known bootstrapping issue? Same happened for 3.1.8. I looked +in README but didn't find anything obvious. + +Btw, building 'mawk' first and then gawk 4.0.0 works. Running self +checks didn't work because there is no 'cmp' on the system either... + +/Simon diff --git a/README_d/README.multibyte b/README_d/README.multibyte new file mode 100644 index 0000000..135ba86 --- /dev/null +++ b/README_d/README.multibyte @@ -0,0 +1,29 @@ +Fri Jun 3 12:20:17 IDT 2005 +============================ + +As noted in the NEWS file, as of 3.1.5, gawk uses character values instead +of byte values for `index', `length', `substr' and `match'. This works +in multibyte and unicode locales. + +Wed Jun 18 16:47:31 IDT 2003 +============================ + +Multibyte locales can cause occasional weirdness, in particular with +ranges inside brackets: /[....]/. Something that works great for ASCII +will choke for, e.g., en_US.UTF-8. One such program is test/gsubtst5.awk. + +By default, the test suite runs with LC_ALL=C and LANG=C. You +can change this by doing (from a Bourne-style shell): + + $ GAWKLOCALE=some_locale make check + +Then the test suite will set LC_ALL and LANG to the given locale. + +As of this writing, this works for en_US.UTF-8, and all tests +pass except gsubtst5. + +For the normal case of RS = "\n", the locale is largely irrelevant. +For other single byte record separators, using LC_ALL=C will give you +much better performance when reading records. Otherwise, gawk has to +make several function calls, *per input character* to find the record +terminator. You have been warned. diff --git a/README_d/README.os2 b/README_d/README.os2 new file mode 100644 index 0000000..7171daf --- /dev/null +++ b/README_d/README.os2 @@ -0,0 +1,22 @@ +Date: Mon, 16 Aug 2010 08:19:37 +0200 +From: Andreas =?iso-8859-1?Q?B=FCning?= +To: Aharon Robbins +Subject: Re: how alive is OS/2? + +Hello! + +Aharon Robbins schrieb: + +> Is OS/2 still viable? Or can I look to start removing support for it +> also? + +I apologize for the late response. Yes, OS/2 is still "alive" in some sense. +At least, licenses are still sold but under the name "eComStation" (eCS) +instead of OS/2. The (only) distributor is a small company "Serenity Systems", +see www.ecomstation.com for details. + +So I would be pleased if you don't remove the code during the next years. :-) + +Thanks. + +Andreas diff --git a/README_d/README.pc b/README_d/README.pc new file mode 100644 index 0000000..f8addb0 --- /dev/null +++ b/README_d/README.pc @@ -0,0 +1,121 @@ +This is the README for GNU awk 4 under Windows32, OS/2, and DOS. + + Gawk has been compiled and tested under OS/2, DOS, and Windows32 using +the GNU development tools from DJ Delorie (DJGPP; DOS with special +support for long filenames on Windows), Eberhard Mattes (EMX; OS/2, +DOS, and Windows32 with rsxnt), and Jan-Jaap van der Heijden and Mumit Khan +(Mingw32; Windows32). + + The Cygwin environment (http://cygwin.com) may also be used +to compile and run gawk under Windows. For Cygwin, building and +installation is the same as under Unix: + + tar -xvpzf gawk-4.0.x.tar.gz + cd gawk-4.0.x + ./configure && make + +The `configure' step takes a long time, but works otherwise. + +******************************** N O T E ********************************** +* The `|&' operator only works when gawk is compiled for Cygwin. Neither * +* socket support nor two-way pipes work in any other Windows environment! * +*************************************************************************** + +Building gawk +------------- + +Copy the files in the `pc' directory (EXCEPT for `ChangeLog') to the +directory with the rest of the gawk sources. (The subdirectories of +`pc' need not be copied.) The Makefile contains a configuration +section with comments, and may need to be edited in order to work +with your make utility. + +The "prefix" line in the Makefile is used during the install of gawk +(and in building igawk.bat and igawk.cmd). Since the libraries for +gawk will be installed under $(prefix)/lib/awk (e.g., /gnu/lib/awk), +it is convenient to have this directory in DEFPATH of config.h. + +The makefile contains a number of targets for building various DOS and +OS/2 versions. A list of targets will be printed if the make command is +given without a target. As an example, to build gawk using the djgpp +tools, enter "make djgpp". + + +Testing and installing gawk +--------------------------- + +The command "make test" (and possibly "make install") requires several +Unix-like tools, including an sh-like shell, sed, cp, and cmp. Only +dmake and GNU make are known to work on "make test". + +There are two methods for the install: Method 1 uses a typical Unix-like +approach and requires cat, cp, mkdir, sed, and sh; method 2 uses gawk +and batch files. See the configuration section of the makefile. + +The file test/Makefile will need some editing (especially for DOS). A +sample makefile with comments appears in pc/Makefile.tst, and can be +used to modify test/Makefile for your platform. In addition, some +files in the test directory may need to have their end-of-line markers +converted, as described in Makefile.tst. + +As with building gawk, the OS, shell, and long filename issues come into +play when testing, too. If you are testing gawk on a LFN aware system with +some LFN aware tools, you may have problems if the shell that you specify in +test/Makefile is not LFN aware. This problem will apply whether or not +you are building a LFN aware gawk. See the comments in pc/Makefile.tst +for more information on this. + +It is routine to install by hand, but note that the install target also +builds igawk.bat and igawk.cmd, which are used to add an include +facility to gawk (and which require sh). + + +Gawk thanks +----------- + +The DOS maintainers wish to express their thanks to Eli Zaretskii + for his work and for the many conversations concerning +gawk, make, and djgpp. His FAQ for djgpp is essential reading, and he +was always willing to answer our questions (even when we didn't read +the relevant portions of the FAQ :). + +We are indebted to Juan Grigera for +additional help on changes for Windows32. + + +---- +If you have any problems with the DOS or OS/2 versions of Gawk, +please send bug reports (along with the version and compiler used) to + + Scott Deifik, scottd.mail@sbcglobal.net (DOS versions) +or + andreas.buening@nexgo.de (OS/2 version) + +Support for Windows32 started in gawk-3.0.3. + +---- +From: Eric Pement +Newsgroups: comp.lang.awk +Subject: djgpp Gawk ver. 4.0 available +Date: Tue, 26 Jul 2011 06:42:00 -0700 (PDT) +MS Windows users: + +The DJGPP compilation of GNU awk v4.0.0 is now available here: + + ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/gwk400b.zip + +For those who don't know the difference between the DGJPP compile and +other versions compiled for Windows, the most noticeable to me is that +it supports Unix-style use of 'single' and "double" quoting. Example: + + [c:\tmp]> :: normal Windows awk requires complex quoting + [c:\tmp]> gawk "BEGIN{ print \"hello, world\" }" + hello, world + [c:\tmp]> :: DJGPP compile of awk permits Unix quoting in CMD + [c:\tmp]> djgawk 'BEGIN{ print "hello, world" }' + hello, world + +Syntactic sugar? Sure. But it makes life easier in a Windows +environment, and without installing Cygwin ... + +Eric P. diff --git a/README_d/README.solaris b/README_d/README.solaris new file mode 100644 index 0000000..639ca2c --- /dev/null +++ b/README_d/README.solaris @@ -0,0 +1,20 @@ +Fri Jul 15 14:24:00 IDT 2011 +============================ +It looks like you need to use + + -Xc -D_XPG4_2 + +on Solaris 10 with the Sun C compiler when compiling gawk in order for +libsigsegv to be found correctly, and + + -Xc -D_XPG4_2 -Duint64_t=upad64_t + +on Solaris 9. + +Tue Apr 20 11:33:20 IDT 2010 +============================ +The lc_num1 test fails on Solaris 10 systems. This is a bug with Solaris, +not gawk. + +Arnold Robbins +arnold@skeeve.com diff --git a/README_d/README.tests b/README_d/README.tests new file mode 100644 index 0000000..4b3d74b --- /dev/null +++ b/README_d/README.tests @@ -0,0 +1,45 @@ +Date: Sat, 22 Apr 2000 06:07:06 -0600 (MDT) +From: "Nelson H. F. Beebe" +Cc: beebe@math.utah.edu, sysstaff@math.utah.edu, othmer@math.utah.edu +Subject: gawk-3.0.4 and a GNU/Linux gotcha + +Yesterday, I was assisting a colleague install some software on his +GNU/Linux machine for which uname -r reports 2.2.14. + +A (mis)feature of this system, which I've never encountered before, +broke the build of one of my programs, and also of gawk-3.0.4. + +Namely, the kernel will not execute anything that resides in /tmp, +though it will if the same script is in /usr/tmp! + +% cat /tmp/foo.sh +#! /bin/sh +echo hello + +ls -l /tmp/foo.sh +-rwxr-xr-x 1 othmer math 22 Apr 21 10:34 /tmp/foo.sh* + +% /tmp/foo.sh +bash: /tmp/foo.sh: Permission denied + +% cp /tmp/foo.sh /usr/tmp + +% /usr/tmp/foo.sh +hello + +Thus, programs that do a temporary install in /tmp, as some of mine do +in order to run the validation suite, will fail. + +gawk-3.0.4, and likely other gawk versions, hits this problem too. It +fails because test/poundbang starts with + +#! /tmp/gawk -f + +I tracked down where it comes from: + +% grep /tmp /etc/fstab +/dev/hda3 /tmp ext2 rw,nosuid,noexec,nouser,auto,async,nodev 1 1 + !!!!!! + +Since this is done via a mount command, potentially ANY directory tree +could be mounted with noexec. diff --git a/README_d/README.zos b/README_d/README.zos new file mode 100644 index 0000000..361a8ae --- /dev/null +++ b/README_d/README.zos @@ -0,0 +1,45 @@ +Fri Dec 24 10:58:16 2010 +Dave Pitts +---------------------------- + +GAWK on z/OS + +1. To unpack the tarball: + + $ gunzip -c gawk-4.0.0.tar.gz | pax -rv from=ISO8859-1,to=IBM-1047 + + This will extract the files and convert them from ASCII to EBCDIC. + + If you do not have the gunzip program on your system you can perform + the operation on another system and copy the tar file to z/OS. Then + unpack as follows: + + $ pax -rv from=ISO8859-1,to=IBM-1047 -f gawk-4.0.0.tar + + +2. To Build + + $ ./configure CC=c89 + $ make + + You will get compilation warnings of the form: + + WARNING CBC3343 ./dfa.c:332 Redeclaration of dfasyntax differs from + previous declaration on line 404 of "./dfa.h". + + Because the IBM compiler complains when a function is decalared using + prototypes in the header and is defined without prototypes in the code + these warnings can be ignored. + + +3. To Install: + + $ make install + + +4. To Test (optional): + + $ make check + + NOTE: Since the test suite was defined for an ASCII and IEEE floating point + environment several of the tests will fail under z/OS. diff --git a/TODO b/TODO new file mode 100644 index 0000000..ab38248 --- /dev/null +++ b/TODO @@ -0,0 +1,57 @@ +Add debugger commands to reference card +Review all FIXME and TODO comments + +FIX regular field splitting to use FPAT algorithm. + +Look at function order within files. + +regex.h - remove underscores in param names (for 4.1) + +Really make failure to open a socket a non-fatal error (for 4.1). + +?? Scope IDs for IPv6 addresses ?? + +------ + +Code Review: +awkgram.y +awkprintf.h +cmd.h +command.y +debug.c +eval.c +ext.c +field.c +floatcomp.c +floatmagic.h +gawkmisc.c +io.c +profile.c +protos.h + +DONE: +awk.h +array.c +builtin.c +node.c +mbsupport.h +xalloc.h +version.c +re.c +replace.c +msg.c +hard-locale.h +custom.h +main.c + +------ + +Add in gawk/mp + +Design and implement I/O plugin API. + +Implement C function call API per man pages + +xgawk features (@load, -l, others) + +Add tests for patches in emails diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..742da61 --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,973 @@ +# generated automatically by aclocal 1.11.1 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, +[m4_warning([this file was generated for autoconf 2.68. +You have another version of autoconf. It may work, but is not guaranteed to. +If you have problems, you may need to regenerate the build system entirely. +To do so, use the procedure documented by the package, typically `autoreconf'.])]) + +# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +# (This private macro should not be called outside this file.) +AC_DEFUN([AM_AUTOMAKE_VERSION], +[am__api_version='1.11' +dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to +dnl require some minimum version. Point them to the right macro. +m4_if([$1], [1.11.1], [], + [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl +]) + +# _AM_AUTOCONF_VERSION(VERSION) +# ----------------------------- +# aclocal traces this macro to find the Autoconf version. +# This is a private macro too. Using m4_define simplifies +# the logic in aclocal, which can simply ignore this definition. +m4_define([_AM_AUTOCONF_VERSION], []) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. +# This function is AC_REQUIREd by AM_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], +[AM_AUTOMAKE_VERSION([1.11.1])dnl +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 9 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE])dnl +AC_SUBST([$1_FALSE])dnl +_AM_SUBST_NOTMAKE([$1_TRUE])dnl +_AM_SUBST_NOTMAKE([$1_FALSE])dnl +m4_define([_AM_COND_VALUE_$1], [$2])dnl +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 10 + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "GCJ", or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], UPC, [depcc="$UPC" am_compiler_list=], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + am__universal=false + m4_case([$1], [CC], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac], + [CXX], + [case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac]) + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH])dnl +_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +#serial 5 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[{ + # Autoconf 2.62 quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; + esac + shift + for mf + do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done + done +} +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Do all the work for Automake. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2008, 2009 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 16 + +# This macro actually does too much. Some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.62])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl +dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. +m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, + [m4_fatal([AC_INIT should be called with package and version arguments])])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl +]) +_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl +dnl The `parallel-tests' driver may need to know about EXEEXT, so add the +dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro +dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. +AC_CONFIG_COMMANDS_PRE(dnl +[m4_provide_if([_AM_COMPILER_EXEEXT], + [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl +]) + +dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not +dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further +dnl mangled by Autoconf and run in a shell conditional statement. +m4_define([_AC_COMPILER_EXEEXT], +m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_arg=$1 +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) + +# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +if test x"${install_sh}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi +AC_SUBST(install_sh)]) + +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo this is the am__doit target +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# Ignore all kinds of additional output from `make'. +case `$am_make -s -f confmf 2> /dev/null` in #( +*the\ am__doit\ target*) + am__include=include + am__quote= + _am_result=GNU + ;; +esac +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + case `$am_make -s -f confmf 2> /dev/null` in #( + *the\ am__doit\ target*) + am__include=.include + am__quote="\"" + _am_result=BSD + ;; + esac +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- + +# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 6 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([missing])dnl +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_MKDIR_P +# --------------- +# Check for `mkdir -p'. +AC_DEFUN([AM_PROG_MKDIR_P], +[AC_PREREQ([2.60])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, +dnl while keeping a definition of mkdir_p for backward compatibility. +dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. +dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of +dnl Makefile.ins that do not define MKDIR_P, so we do our own +dnl adjustment using top_builddir (which is defined more often than +dnl MKDIR_P). +AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl +case $mkdir_p in + [[\\/$]]* | ?:[[\\/]]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac +]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 4 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# Check to make sure that the build environment is sane. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 +# Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 5 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[[\\\"\#\$\&\'\`$am_lf]]*) + AC_MSG_ERROR([unsafe absolute working directory name]);; +esac +case $srcdir in + *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) + AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; +esac + +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# AM_PROG_INSTALL_STRIP +# --------------------- +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Copyright (C) 2006, 2008 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# _AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. +# This macro is traced by Automake. +AC_DEFUN([_AM_SUBST_NOTMAKE]) + +# AM_SUBST_NOTMAKE(VARIABLE) +# --------------------------- +# Public sister of _AM_SUBST_NOTMAKE. +AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004, 2005 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + +m4_include([m4/arch.m4]) +m4_include([m4/codeset.m4]) +m4_include([m4/gettext.m4]) +m4_include([m4/iconv.m4]) +m4_include([m4/intlmacosx.m4]) +m4_include([m4/intmax_t.m4]) +m4_include([m4/inttypes_h.m4]) +m4_include([m4/isc-posix.m4]) +m4_include([m4/lcmessage.m4]) +m4_include([m4/lib-ld.m4]) +m4_include([m4/lib-link.m4]) +m4_include([m4/lib-prefix.m4]) +m4_include([m4/libsigsegv.m4]) +m4_include([m4/longlong.m4]) +m4_include([m4/nls.m4]) +m4_include([m4/po.m4]) +m4_include([m4/progtest.m4]) +m4_include([m4/readline.m4]) +m4_include([m4/socket.m4]) +m4_include([m4/stdint_h.m4]) +m4_include([m4/uintmax_t.m4]) +m4_include([m4/ulonglong.m4]) diff --git a/array.c b/array.c new file mode 100644 index 0000000..e814e97 --- /dev/null +++ b/array.c @@ -0,0 +1,1775 @@ +/* + * array.c - routines for associative arrays. + */ + +/* + * Copyright (C) 1986, 1988, 1989, 1991-2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "awk.h" + +/* + * Tree walks (``for (iggy in foo)'') and array deletions use expensive + * linear searching. So what we do is start out with small arrays and + * grow them as needed, so that our arrays are hopefully small enough, + * most of the time, that they're pretty full and we're not looking at + * wasted space. + * + * The decision is made to grow the array if the average chain length is + * ``too big''. This is defined as the total number of entries in the table + * divided by the size of the array being greater than some constant. + * + * We make the constant a variable, so that it can be tweaked + * via environment variable. + */ + +static size_t AVG_CHAIN_MAX = 2; /* Modern machines are bigger, reduce this from 10. */ + +static size_t SUBSEPlen; +static char *SUBSEP; + +static NODE *assoc_find(NODE *symbol, NODE *subs, unsigned long hash1, NODE **last); +static void grow_table(NODE *symbol); + +static unsigned long gst_hash_string(const char *str, size_t len, unsigned long hsize, size_t *code); +static unsigned long scramble(unsigned long x); +static unsigned long awk_hash(const char *s, size_t len, unsigned long hsize, size_t *code); + +unsigned long (*hash)(const char *s, size_t len, unsigned long hsize, size_t *code) = awk_hash; + +/* qsort comparison function */ +static int sort_up_index_string(const void *, const void *); +static int sort_down_index_string(const void *, const void *); +static int sort_up_index_number(const void *, const void *); +static int sort_down_index_number(const void *, const void *); +static int sort_up_value_string(const void *, const void *); +static int sort_down_value_string(const void *, const void *); +static int sort_up_value_number(const void *, const void *); +static int sort_down_value_number(const void *, const void *); +static int sort_up_value_type(const void *, const void *); +static int sort_down_value_type(const void *, const void *); + +/* array_init --- check relevant environment variables */ + +void +array_init() +{ + const char *val; + char *endptr; + size_t newval; + + if ((val = getenv("AVG_CHAIN_MAX")) != NULL && isdigit((unsigned char) *val)) { + newval = strtoul(val, & endptr, 10); + if (endptr != val && newval > 0) + AVG_CHAIN_MAX = newval; + } + + if ((val = getenv("AWK_HASH")) != NULL && strcmp(val, "gst") == 0) + hash = gst_hash_string; +} + +/* make_aname --- construct a 'vname' for a (sub)array */ + +static char * +make_aname(const NODE *symbol) +{ + static char *aname = NULL; + static size_t alen; + static size_t max_alen; +#define SLEN 256 + + if (symbol->parent_array != NULL) { + size_t slen; + + (void) make_aname(symbol->parent_array); + slen = strlen(symbol->vname); /* subscript in parent array */ + if (alen + slen + 4 > max_alen) { /* sizeof("[\"\"]") = 4 */ + max_alen = alen + slen + 4 + SLEN; + erealloc(aname, char *, (max_alen + 1) * sizeof(char *), "make_aname"); + } + alen += sprintf(aname + alen, "[\"%s\"]", symbol->vname); + } else { + alen = strlen(symbol->vname); + if (aname == NULL) { + max_alen = alen + SLEN; + emalloc(aname, char *, (max_alen + 1) * sizeof(char *), "make_aname"); + } else if (alen > max_alen) { + max_alen = alen + SLEN; + erealloc(aname, char *, (max_alen + 1) * sizeof(char *), "make_aname"); + } + memcpy(aname, symbol->vname, alen + 1); + } + return aname; +#undef SLEN +} + +/* + * array_vname --- print the name of the array + * + * Returns a pointer to a statically maintained dynamically allocated string. + * It's appropriate for printing the name once; if the caller wants + * to save it, they have to make a copy. + */ + +char * +array_vname(const NODE *symbol) +{ + static char *message = NULL; + static size_t msglen = 0; + char *s; + size_t len; + int n; + const NODE *save_symbol = symbol; + const char *from = _("from %s"); + const char *aname; + + if (symbol->type != Node_array_ref + || symbol->orig_array->type != Node_var_array + ) { + if (symbol->type != Node_var_array || symbol->parent_array == NULL) + return symbol->vname; + return make_aname(symbol); + } + + /* First, we have to compute the length of the string: */ + + len = 2; /* " (" */ + n = 0; + while (symbol->type == Node_array_ref) { + len += strlen(symbol->vname); + n++; + symbol = symbol->prev_array; + } + + /* Get the (sub)array name */ + if (symbol->parent_array == NULL) + aname = symbol->vname; + else + aname = make_aname(symbol); + len += strlen(aname); + + /* + * Each node contributes by strlen(from) minus the length + * of "%s" in the translation (which is at least 2) + * plus 2 for ", " or ")\0"; this adds up to strlen(from). + */ + len += n * strlen(from); + + /* (Re)allocate memory: */ + if (message == NULL) { + emalloc(message, char *, len, "array_vname"); + msglen = len; + } else if (len > msglen) { + erealloc(message, char *, len, "array_vname"); + msglen = len; + } /* else + current buffer can hold new name */ + + /* We're ready to print: */ + symbol = save_symbol; + s = message; + /* + * Ancient systems have sprintf() returning char *, not int. + * If you have one of those, use sprintf(..); s += strlen(s) instead. + */ + + s += sprintf(s, "%s (", symbol->vname); + for (;;) { + symbol = symbol->prev_array; + if (symbol->type != Node_array_ref) + break; + s += sprintf(s, from, symbol->vname); + s += sprintf(s, ", "); + } + s += sprintf(s, from, aname); + strcpy(s, ")"); + + return message; +} + + +/* + * get_array --- proceed to the actual Node_var_array, + * change Node_var_new to an array. + * If canfatal and type isn't good, die fatally, + * otherwise return the final actual value. + */ + +NODE * +get_array(NODE *symbol, int canfatal) +{ + NODE *save_symbol = symbol; + int isparam = FALSE; + + if (symbol->type == Node_param_list && (symbol->flags & FUNC) == 0) { + save_symbol = symbol = GET_PARAM(symbol->param_cnt); + isparam = TRUE; + if (symbol->type == Node_array_ref) + symbol = symbol->orig_array; + } + + switch (symbol->type) { + case Node_var_new: + symbol->type = Node_var_array; + symbol->var_array = NULL; + symbol->parent_array = NULL; /* main array has no parent */ + /* fall through */ + case Node_var_array: + break; + + case Node_array_ref: + case Node_param_list: + if ((symbol->flags & FUNC) == 0) + cant_happen(); + /* else + fall through */ + + default: + /* notably Node_var but catches also e.g. FS[1] = "x" */ + if (canfatal) { + if (symbol->type == Node_val) + fatal(_("attempt to use a scalar value as array")); + + if ((symbol->flags & FUNC) != 0) + fatal(_("attempt to use function `%s' as an array"), + save_symbol->vname); + else if (isparam) + fatal(_("attempt to use scalar parameter `%s' as an array"), + save_symbol->vname); + else + fatal(_("attempt to use scalar `%s' as an array"), + save_symbol->vname); + } else + break; + } + + return symbol; +} + + +/* set_SUBSEP --- update SUBSEP related variables when SUBSEP assigned to */ + +void +set_SUBSEP() +{ + SUBSEP = force_string(SUBSEP_node->var_value)->stptr; + SUBSEPlen = SUBSEP_node->var_value->stlen; +} + +/* concat_exp --- concatenate expression list into a single string */ + +NODE * +concat_exp(int nargs, int do_subsep) +{ + /* do_subsep is false for Node-concat */ + NODE *r; + char *str; + char *s; + size_t len; + size_t subseplen = 0; + int i; + extern NODE **args_array; + + if (nargs == 1) + return POP_STRING(); + + if (do_subsep) + subseplen = SUBSEPlen; + + len = 0; + for (i = 1; i <= nargs; i++) { + r = POP(); + if (r->type == Node_var_array) { + while (--i > 0) + DEREF(args_array[i]); /* avoid memory leak */ + fatal(_("attempt to use array `%s' in a scalar context"), array_vname(r)); + } + args_array[i] = force_string(r); + len += r->stlen; + } + len += (nargs - 1) * subseplen; + + emalloc(str, char *, len + 2, "concat_exp"); + + r = args_array[nargs]; + memcpy(str, r->stptr, r->stlen); + s = str + r->stlen; + DEREF(r); + for (i = nargs - 1; i > 0; i--) { + if (subseplen == 1) + *s++ = *SUBSEP; + else if (subseplen > 0) { + memcpy(s, SUBSEP, subseplen); + s += subseplen; + } + r = args_array[i]; + memcpy(s, r->stptr, r->stlen); + s += r->stlen; + DEREF(r); + } + + return make_str_node(str, len, ALREADY_MALLOCED); +} + + +/* assoc_clear --- flush all the values in symbol[] */ + +void +assoc_clear(NODE *symbol) +{ + long i; + NODE *bucket, *next; + + if (symbol->var_array == NULL) + return; + + for (i = 0; i < symbol->array_size; i++) { + for (bucket = symbol->var_array[i]; bucket != NULL; bucket = next) { + next = bucket->ahnext; + if (bucket->ahvalue->type == Node_var_array) { + NODE *r = bucket->ahvalue; + assoc_clear(r); /* recursively clear all sub-arrays */ + efree(r->vname); + freenode(r); + } else + unref(bucket->ahvalue); + + unref(bucket); /* unref() will free the ahname_str */ + } + symbol->var_array[i] = NULL; + } + efree(symbol->var_array); + symbol->var_array = NULL; + symbol->array_size = symbol->table_size = 0; + symbol->flags &= ~ARRAYMAXED; +} + +/* awk_hash --- calculate the hash function of the string in subs */ + +static unsigned long +awk_hash(const char *s, size_t len, unsigned long hsize, size_t *code) +{ + unsigned long h = 0; + unsigned long htmp; + + /* + * Ozan Yigit's original sdbm hash, copied from Margo Seltzers + * db package. + * + * This is INCREDIBLY ugly, but fast. We break the string up into + * 8 byte units. On the first time through the loop we get the + * "leftover bytes" (strlen % 8). On every other iteration, we + * perform 8 HASHC's so we handle all 8 bytes. Essentially, this + * saves us 7 cmp & branch instructions. If this routine is + * heavily used enough, it's worth the ugly coding. + */ + + /* + * Even more speed: + * #define HASHC h = *s++ + 65599 * h + * Because 65599 = pow(2, 6) + pow(2, 16) - 1 we multiply by shifts + * + * 4/2011: Force the results to 32 bits, to get the same + * result on both 32- and 64-bit systems. This may be a + * bad idea. + */ +#define HASHC htmp = (h << 6); \ + h = *s++ + htmp + (htmp << 10) - h ; \ + htmp &= 0xFFFFFFFF; \ + h &= 0xFFFFFFFF + + h = 0; + + /* "Duff's Device" */ + if (len > 0) { + size_t loop = (len + 8 - 1) >> 3; + + switch (len & (8 - 1)) { + case 0: + do { /* All fall throughs */ + HASHC; + case 7: HASHC; + case 6: HASHC; + case 5: HASHC; + case 4: HASHC; + case 3: HASHC; + case 2: HASHC; + case 1: HASHC; + } while (--loop); + } + } + + if (code != NULL) + *code = h; + + if (h >= hsize) + h %= hsize; + return h; +} + +/* assoc_find --- locate symbol[subs] */ + +static NODE * /* NULL if not found */ +assoc_find(NODE *symbol, NODE *subs, unsigned long hash1, NODE **last) +{ + NODE *bucket, *prev; + const char *s1_str; + size_t s1_len; + NODE *s2; + + for (prev = NULL, bucket = symbol->var_array[hash1]; bucket != NULL; + prev = bucket, bucket = bucket->ahnext) { + /* + * This used to use cmp_nodes() here. That's wrong. + * Array indices are strings; compare as such, always! + */ + s1_str = bucket->ahname_str; + s1_len = bucket->ahname_len; + s2 = subs; + + if (s1_len == s2->stlen) { + if (s1_len == 0 /* "" is a valid index */ + || memcmp(s1_str, s2->stptr, s1_len) == 0) + break; + } + } + if (last != NULL) + *last = prev; + return bucket; +} + +/* in_array --- test whether the array element symbol[subs] exists or not, + * return pointer to value if it does. + */ + +NODE * +in_array(NODE *symbol, NODE *subs) +{ + unsigned long hash1; + NODE *ret; + + assert(symbol->type == Node_var_array); + + if (symbol->var_array == NULL) + return NULL; + + hash1 = hash(subs->stptr, subs->stlen, (unsigned long) symbol->array_size, NULL); + ret = assoc_find(symbol, subs, hash1, NULL); + return (ret ? ret->ahvalue : NULL); +} + +/* + * assoc_lookup: + * Find SYMBOL[SUBS] in the assoc array. Install it with value "" if it + * isn't there. Returns a pointer ala get_lhs to where its value is stored. + * + * SYMBOL is the address of the node (or other pointer) being dereferenced. + * SUBS is a number or string used as the subscript. + */ + +NODE ** +assoc_lookup(NODE *symbol, NODE *subs, int reference) +{ + unsigned long hash1; + NODE *bucket; + size_t code; + + assert(symbol->type == Node_var_array); + + (void) force_string(subs); + + if (symbol->var_array == NULL) { + symbol->array_size = symbol->table_size = 0; /* sanity */ + symbol->flags &= ~ARRAYMAXED; + grow_table(symbol); + hash1 = hash(subs->stptr, subs->stlen, + (unsigned long) symbol->array_size, & code); + } else { + hash1 = hash(subs->stptr, subs->stlen, + (unsigned long) symbol->array_size, & code); + bucket = assoc_find(symbol, subs, hash1, NULL); + if (bucket != NULL) + return &(bucket->ahvalue); + } + + if (do_lint && reference) { + lintwarn(_("reference to uninitialized element `%s[\"%.*s\"]'"), + array_vname(symbol), (int)subs->stlen, subs->stptr); + } + + /* It's not there, install it. */ + if (do_lint && subs->stlen == 0) + lintwarn(_("subscript of array `%s' is null string"), + array_vname(symbol)); + + /* first see if we would need to grow the array, before installing */ + symbol->table_size++; + if ((symbol->flags & ARRAYMAXED) == 0 + && (symbol->table_size / symbol->array_size) > AVG_CHAIN_MAX) { + grow_table(symbol); + /* have to recompute hash value for new size */ + hash1 = code % (unsigned long) symbol->array_size; + } + + getnode(bucket); + bucket->type = Node_ahash; + + /* + * Freeze this string value --- it must never + * change, no matter what happens to the value + * that created it or to CONVFMT, etc. + * + * One day: Use an atom table to track array indices, + * and avoid the extra memory overhead. + */ + bucket->flags |= MALLOC; + bucket->ahname_ref = 1; + + emalloc(bucket->ahname_str, char *, subs->stlen + 2, "assoc_lookup"); + bucket->ahname_len = subs->stlen; + memcpy(bucket->ahname_str, subs->stptr, subs->stlen); + bucket->ahname_str[bucket->ahname_len] = '\0'; + bucket->ahvalue = Nnull_string; + + bucket->ahnext = symbol->var_array[hash1]; + bucket->ahcode = code; + + /* + * Set the numeric value for the index if it's available. Useful + * for numeric sorting by index. Do this only if the numeric + * value is available, instead of all the time, since doing it + * all the time is a big performance hit for something that may + * never be used. + */ + if ((subs->flags & NUMCUR) != 0) { + bucket->ahname_num = subs->numbr; + bucket->flags |= NUMIND; + } + + /* hook it into the symbol table */ + symbol->var_array[hash1] = bucket; + return &(bucket->ahvalue); +} + + +/* adjust_fcall_stack: remove subarray(s) of symbol[] from + * function call stack. + */ + +static void +adjust_fcall_stack(NODE *symbol, int nsubs) +{ + NODE *func, *r, *n; + NODE **sp; + int pcount; + + /* + * Solve the nasty problem of disappearing subarray arguments: + * + * function f(c, d) { delete c; .. use non-existent array d .. } + * BEGIN { a[0][0] = 1; f(a, a[0]); .. } + * + * The fix is to convert 'd' to a local empty array; This has + * to be done before clearing the parent array to avoid referring to + * already free-ed memory. + * + * Similar situations exist for builtins accepting more than + * one array argument: split, patsplit, asort and asorti. For example: + * + * BEGIN { a[0][0] = 1; split("abc", a, "", a[0]) } + * + * These cases do not involve the function call stack, and are + * handled individually in their respective routines. + */ + + func = frame_ptr->func_node; + if (func == NULL) /* in main */ + return; + pcount = func->lnode->param_cnt; + sp = frame_ptr->stack; + + for (; pcount > 0; pcount--) { + r = *sp++; + if (r->type != Node_array_ref + || r->orig_array->type != Node_var_array) + continue; + n = r->orig_array; + + /* Case 1 */ + if (n == symbol + && symbol->parent_array != NULL + && nsubs > 0 + ) { + /* 'symbol' is a subarray, and 'r' is the same subarray: + * + * function f(c, d) { delete c[0]; .. } + * BEGIN { a[0][0] = 1; f(a, a[0]); .. } + * + * But excludes cases like (nsubs = 0): + * + * function f(c, d) { delete c; ..} + * BEGIN { a[0][0] = 1; f(a[0], a[0]); ...} + */ + char *save; +local_array: + save = r->vname; + memset(r, '\0', sizeof(NODE)); + r->vname = save; + r->type = Node_var_array; + continue; + } + + /* Case 2 */ + for (n = n->parent_array; n != NULL; n = n->parent_array) { + assert(n->type == Node_var_array); + if (n == symbol) { + /* 'r' is a subarray of 'symbol': + * + * function f(c, d) { delete c; .. use d as array .. } + * BEGIN { a[0][0] = 1; f(a, a[0]); .. } + * OR + * BEGIN { a[0][0][0][0] = 1; f(a[0], a[0][0][0]); .. } + * + */ + + goto local_array; + } + } + } +} + + +/* do_delete --- perform `delete array[s]' */ + +/* + * `symbol' is array + * `nsubs' is number of subscripts + */ + +void +do_delete(NODE *symbol, int nsubs) +{ + unsigned long hash1 = 0; + NODE *subs, *bucket, *last, *r; + int i; + + assert(symbol->type == Node_var_array); + subs = bucket = last = r = NULL; /* silence the compiler */ + + /* + * The force_string() call is needed to make sure that + * the string subscript is reasonable. For example, with it: + * + * $ ./gawk --posix 'BEGIN { CONVFMT="%ld"; delete a[1.233]}' + * gawk: cmd. line:1: fatal: `%l' is not permitted in POSIX awk formats + * + * Without it, the code does not fail. + */ + +#define free_subs(n) \ +do { \ + NODE *s = PEEK(n - 1); \ + if (s->type == Node_val) { \ + (void) force_string(s); /* may have side effects ? */ \ + DEREF(s); \ + } \ +} while (--n > 0) + + if (nsubs == 0) { /* delete array */ + adjust_fcall_stack(symbol, 0); /* fix function call stack; See above. */ + assoc_clear(symbol); + return; + } + + /* NB: subscripts are in reverse order on stack */ + + for (i = nsubs; i > 0; i--) { + subs = PEEK(i - 1); + if (subs->type != Node_val) { + free_subs(i); + fatal(_("attempt to use array `%s' in a scalar context"), array_vname(subs)); + } + (void) force_string(subs); + + last = NULL; /* shut up gcc -Wall */ + hash1 = 0; /* ditto */ + bucket = NULL; /* array may be empty */ + + if (symbol->var_array != NULL) { + hash1 = hash(subs->stptr, subs->stlen, + (unsigned long) symbol->array_size, NULL); + bucket = assoc_find(symbol, subs, hash1, &last); + } + + if (bucket == NULL) { + if (do_lint) + lintwarn(_("delete: index `%s' not in array `%s'"), + subs->stptr, array_vname(symbol)); + /* avoid memory leak, free all subs */ + free_subs(i); + return; + } + + if (i > 1) { + if (bucket->ahvalue->type != Node_var_array) { + /* e.g.: a[1] = 1; delete a[1][1] */ + free_subs(i); + fatal(_("attempt to use scalar `%s[\"%.*s\"]' as an array"), + array_vname(symbol), + (int) bucket->ahname_len, + bucket->ahname_str); + } + symbol = bucket->ahvalue; + } + DEREF(subs); + } + + r = bucket->ahvalue; + if (r->type == Node_var_array) { + adjust_fcall_stack(r, nsubs); /* fix function call stack; See above. */ + assoc_clear(r); + /* cleared a sub-array, free Node_var_array */ + efree(r->vname); + freenode(r); + } else + unref(r); + + if (last != NULL) + last->ahnext = bucket->ahnext; + else + symbol->var_array[hash1] = bucket->ahnext; + + unref(bucket); /* unref() will free the ahname_str */ + symbol->table_size--; + if (symbol->table_size <= 0) { + symbol->table_size = symbol->array_size = 0; + symbol->flags &= ~ARRAYMAXED; + if (symbol->var_array != NULL) { + efree(symbol->var_array); + symbol->var_array = NULL; + } + } + +#undef free_subs +} + + +/* do_delete_loop --- simulate ``for (iggy in foo) delete foo[iggy]'' */ + +/* + * The primary hassle here is that `iggy' needs to have some arbitrary + * array index put in it before we can clear the array, we can't + * just replace the loop with `delete foo'. + */ + +void +do_delete_loop(NODE *symbol, NODE **lhs) +{ + long i; + + assert(symbol->type == Node_var_array); + + if (symbol->var_array == NULL) + return; + + /* get first index value */ + for (i = 0; i < symbol->array_size; i++) { + if (symbol->var_array[i] != NULL) { + unref(*lhs); + *lhs = make_string(symbol->var_array[i]->ahname_str, + symbol->var_array[i]->ahname_len); + break; + } + } + + /* blast the array in one shot */ + adjust_fcall_stack(symbol, 0); + assoc_clear(symbol); +} + +/* grow_table --- grow a hash table */ + +static void +grow_table(NODE *symbol) +{ + NODE **old, **new, *chain, *next; + int i, j; + unsigned long hash1; + unsigned long oldsize, newsize, k; + /* + * This is an array of primes. We grow the table by an order of + * magnitude each time (not just doubling) so that growing is a + * rare operation. We expect, on average, that it won't happen + * more than twice. When things are very large (> 8K), we just + * double more or less, instead of just jumping from 8K to 64K. + */ + static const long sizes[] = { + 13, 127, 1021, 8191, 16381, 32749, 65497, 131101, 262147, + 524309, 1048583, 2097169, 4194319, 8388617, 16777259, 33554467, + 67108879, 134217757, 268435459, 536870923, 1073741827 + }; + + /* find next biggest hash size */ + newsize = oldsize = symbol->array_size; + for (i = 0, j = sizeof(sizes)/sizeof(sizes[0]); i < j; i++) { + if (oldsize < sizes[i]) { + newsize = sizes[i]; + break; + } + } + + if (newsize == oldsize) { /* table already at max (!) */ + symbol->flags |= ARRAYMAXED; + return; + } + + /* allocate new table */ + emalloc(new, NODE **, newsize * sizeof(NODE *), "grow_table"); + memset(new, '\0', newsize * sizeof(NODE *)); + + /* brand new hash table, set things up and return */ + if (symbol->var_array == NULL) { + symbol->table_size = 0; + goto done; + } + + /* old hash table there, move stuff to new, free old */ + old = symbol->var_array; + for (k = 0; k < oldsize; k++) { + if (old[k] == NULL) + continue; + + for (chain = old[k]; chain != NULL; chain = next) { + next = chain->ahnext; + hash1 = chain->ahcode % newsize; + + /* remove from old list, add to new */ + chain->ahnext = new[hash1]; + new[hash1] = chain; + } + } + efree(old); + +done: + /* + * note that symbol->table_size does not change if an old array, + * and is explicitly set to 0 if a new one. + */ + symbol->var_array = new; + symbol->array_size = newsize; +} + +/* pr_node --- print simple node info */ + +static void +pr_node(NODE *n) +{ + if ((n->flags & NUMBER) != 0) + printf("%s %g p: %p", flags2str(n->flags), n->numbr, n); + else + printf("%s %.*s p: %p", flags2str(n->flags), + (int) n->stlen, n->stptr, n); +} + + +static void +indent(int indent_level) +{ + int k; + for (k = 0; k < indent_level; k++) + putchar('\t'); +} + +/* assoc_dump --- dump the contents of an array */ + +NODE * +assoc_dump(NODE *symbol, int indent_level) +{ + long i; + NODE *bucket; + + indent(indent_level); + if (symbol->var_array == NULL) { + printf(_("%s: empty (null)\n"), symbol->vname); + return make_number((AWKNUM) 0); + } + + if (symbol->table_size == 0) { + printf(_("%s: empty (zero)\n"), symbol->vname); + return make_number((AWKNUM) 0); + } + + printf(_("%s: table_size = %d, array_size = %d\n"), symbol->vname, + (int) symbol->table_size, (int) symbol->array_size); + + for (i = 0; i < symbol->array_size; i++) { + for (bucket = symbol->var_array[i]; bucket != NULL; + bucket = bucket->ahnext) { + indent(indent_level); + printf("%s: I: [len %d <%.*s> p: %p] V: [", + symbol->vname, + (int) bucket->ahname_len, + (int) bucket->ahname_len, + bucket->ahname_str, + bucket->ahname_str); + if (bucket->ahvalue->type == Node_var_array) { + printf("\n"); + assoc_dump(bucket->ahvalue, indent_level + 1); + indent(indent_level); + } else + pr_node(bucket->ahvalue); + printf("]\n"); + } + } + + return make_number((AWKNUM) 0); +} + +/* do_adump --- dump an array: interface to assoc_dump */ + +NODE * +do_adump(int nargs) +{ + NODE *r, *a; + + a = POP(); + if (a->type == Node_param_list) { + printf(_("%s: is parameter\n"), a->vname); + a = GET_PARAM(a->param_cnt); + } + if (a->type == Node_array_ref) { + printf(_("%s: array_ref to %s\n"), a->vname, + a->orig_array->vname); + a = a->orig_array; + } + if (a->type != Node_var_array) + fatal(_("adump: argument not an array")); + r = assoc_dump(a, 0); + return r; +} + +/* + * The following functions implement the builtin + * asort function. Initial work by Alan J. Broder, + * ajb@woti.com. + */ + +/* dup_table --- recursively duplicate input array "symbol" */ + +static NODE * +dup_table(NODE *symbol, NODE *newsymb) +{ + NODE **old, **new, *chain, *bucket; + long i; + unsigned long cursize; + + /* find the current hash size */ + cursize = symbol->array_size; + + new = NULL; + + /* input is a brand new hash table, so there's nothing to copy */ + if (symbol->var_array == NULL) + newsymb->table_size = 0; + else { + /* old hash table there, dupnode stuff into a new table */ + + /* allocate new table */ + emalloc(new, NODE **, cursize * sizeof(NODE *), "dup_table"); + memset(new, '\0', cursize * sizeof(NODE *)); + + /* do the copying/dupnode'ing */ + old = symbol->var_array; + for (i = 0; i < cursize; i++) { + if (old[i] != NULL) { + for (chain = old[i]; chain != NULL; + chain = chain->ahnext) { + /* get a node for the linked list */ + getnode(bucket); + bucket->type = Node_ahash; + bucket->flags |= MALLOC; + bucket->ahname_ref = 1; + bucket->ahcode = chain->ahcode; + if ((chain->flags & NUMIND) != 0) { + bucket->ahname_num = chain->ahname_num; + bucket->flags |= NUMIND; + } + + /* + * copy the corresponding name and + * value from the original input list + */ + emalloc(bucket->ahname_str, char *, chain->ahname_len + 2, "dup_table"); + bucket->ahname_len = chain->ahname_len; + + memcpy(bucket->ahname_str, chain->ahname_str, chain->ahname_len); + bucket->ahname_str[bucket->ahname_len] = '\0'; + + if (chain->ahvalue->type == Node_var_array) { + NODE *r; + getnode(r); + r->type = Node_var_array; + r->vname = estrdup(chain->ahname_str, chain->ahname_len); + r->parent_array = newsymb; + bucket->ahvalue = dup_table(chain->ahvalue, r); + } else + bucket->ahvalue = dupnode(chain->ahvalue); + + /* + * put the node on the corresponding + * linked list in the new table + */ + bucket->ahnext = new[i]; + new[i] = bucket; + } + } + } + newsymb->table_size = symbol->table_size; + } + + newsymb->var_array = new; + newsymb->array_size = cursize; + newsymb->flags = symbol->flags; /* ARRAYMAXED */ + return newsymb; +} + + +/* asort_actual --- do the actual work to sort the input array */ + +static NODE * +asort_actual(int nargs, SORT_CTXT ctxt) +{ + NODE *array, *dest = NULL, *result; + NODE *r, *subs, *s; + NODE **list, **ptr; +#define TSIZE 100 /* an arbitrary amount */ + static char buf[TSIZE+2]; + unsigned long num_elems, i; + const char *sort_str; + + if (nargs == 3) /* 3rd optional arg */ + s = POP_STRING(); + else + s = Nnull_string; /* "" => default sorting */ + + s = force_string(s); + sort_str = s->stptr; + if (s->stlen == 0) { /* default sorting */ + if (ctxt == ASORT) + sort_str = "@val_type_asc"; + else + sort_str = "@ind_str_asc"; + } + + + if (nargs >= 2) { /* 2nd optional arg */ + dest = POP_PARAM(); + if (dest->type != Node_var_array) { + fatal(ctxt == ASORT ? + _("asort: second argument not an array") : + _("asorti: second argument not an array")); + } + } + + array = POP_PARAM(); + if (array->type != Node_var_array) { + fatal(ctxt == ASORT ? + _("asort: first argument not an array") : + _("asorti: first argument not an array")); + } + + if (dest != NULL) { + for (r = dest->parent_array; r != NULL; r = r->parent_array) { + if (r == array) + fatal(ctxt == ASORT ? + _("asort: cannot use a subarray of first arg for second arg") : + _("asorti: cannot use a subarray of first arg for second arg")); + } + for (r = array->parent_array; r != NULL; r = r->parent_array) { + if (r == dest) + fatal(ctxt == ASORT ? + _("asort: cannot use a subarray of second arg for first arg") : + _("asorti: cannot use a subarray of second arg for first arg")); + } + } + + num_elems = array->table_size; + if (num_elems == 0 || array->var_array == NULL) { /* source array is empty */ + if (dest != NULL && dest != array) + assoc_clear(dest); + return make_number((AWKNUM) 0); + } + + /* sorting happens inside assoc_list */ + list = assoc_list(array, sort_str, ctxt); + DEREF(s); + + /* + * Must not assoc_clear() the source array before constructing + * the output array. assoc_list() does not duplicate array values + * which are needed for asort(). + */ + + if (dest != NULL && dest != array) { + assoc_clear(dest); + result = dest; + } else { + /* use 'result' as a temporary destination array */ + getnode(result); + memset(result, '\0', sizeof(NODE)); + result->type = Node_var_array; + result->vname = array->vname; + result->parent_array = array->parent_array; + } + + subs = make_str_node(buf, TSIZE, ALREADY_MALLOCED); /* fake it */ + subs->flags &= ~MALLOC; /* safety */ + for (i = 1, ptr = list; i <= num_elems; i++) { + sprintf(buf, "%lu", i); + subs->stlen = strlen(buf); + /* make number valid in case this array gets sorted later */ + subs->numbr = i; + subs->flags |= NUMCUR; + r = *ptr++; + if (ctxt == ASORTI) { + /* + * We want the indices of the source array as values + * of the 'result' array. + */ + *assoc_lookup(result, subs, FALSE) = + make_string(r->ahname_str, r->ahname_len); + } else { + NODE *val; + + /* We want the values of the source array. */ + + val = r->ahvalue; + if (result != dest) { + /* optimization for dest = NULL or dest = array */ + + if (val->type == Node_var_array) { + /* update subarray index in parent array */ + efree(val->vname); + val->vname = estrdup(subs->stptr, subs->stlen); + } + *assoc_lookup(result, subs, FALSE) = val; + r->ahvalue = Nnull_string; + } else { + if (val->type == Node_val) + *assoc_lookup(result, subs, FALSE) = dupnode(val); + else { + NODE *arr; + + /* + * There isn't any reference counting for + * subarrays, so recursively copy subarrays + * using dup_table(). + */ + getnode(arr); + arr->type = Node_var_array; + arr->var_array = NULL; + arr->vname = estrdup(subs->stptr, subs->stlen); + arr->parent_array = array; /* actual parent, not the temporary one. */ + *assoc_lookup(result, subs, FALSE) = dup_table(val, arr); + } + } + } + + unref(r); + } + + freenode(subs); /* stptr(buf) not malloc-ed */ + efree(list); + + if (result != dest) { + /* dest == NULL or dest == array */ + assoc_clear(array); + *array = *result; /* copy result into array */ + freenode(result); + } /* else + result == dest + dest != NULL and dest != array */ + + return make_number((AWKNUM) num_elems); +} +#undef TSIZE + +/* do_asort --- sort array by value */ + +NODE * +do_asort(int nargs) +{ + return asort_actual(nargs, ASORT); +} + +/* do_asorti --- sort array by index */ + +NODE * +do_asorti(int nargs) +{ + return asort_actual(nargs, ASORTI); +} + +/* + * cmp_string --- compare two strings; logic similar to cmp_nodes() in eval.c + * except the extra case-sensitive comparison when the case-insensitive + * result is a match. + */ + +static int +cmp_string(const NODE *n1, const NODE *n2) +{ + char *s1, *s2; + size_t len1, len2; + int ret; + size_t lmin; + + assert(n1->type == n2->type); + if (n1->type == Node_ahash) { + s1 = n1->ahname_str; + len1 = n1->ahname_len; + s2 = n2->ahname_str; + len2 = n2->ahname_len; + } else { + s1 = n1->stptr; + len1 = n1->stlen; + s2 = n2->stptr; + len2 = n2->stlen; + } + + if (len1 == 0) + return len2 == 0 ? 0 : -1; + if (len2 == 0) + return 1; + + /* len1 > 0 && len2 > 0 */ + lmin = len1 < len2 ? len1 : len2; + + if (IGNORECASE) { + const unsigned char *cp1 = (const unsigned char *) s1; + const unsigned char *cp2 = (const unsigned char *) s2; + +#if MBS_SUPPORT + if (gawk_mb_cur_max > 1) { + ret = strncasecmpmbs((const unsigned char *) cp1, + (const unsigned char *) cp2, lmin); + } else +#endif + for (ret = 0; lmin-- > 0 && ret == 0; cp1++, cp2++) + ret = casetable[*cp1] - casetable[*cp2]; + if (ret != 0) + return ret; + /* + * If case insensitive result is "they're the same", + * use case sensitive comparison to force distinct order. + */ + } + + ret = memcmp(s1, s2, lmin); + if (ret != 0 || len1 == len2) + return ret; + return (len1 < len2) ? -1 : 1; +} + + +/* sort_up_index_string --- qsort comparison function; ascending index strings. */ + +static int +sort_up_index_string(const void *p1, const void *p2) +{ + const NODE *t1, *t2; + + /* Array indices are strings */ + t1 = *((const NODE *const *) p1); + t2 = *((const NODE *const *) p2); + return cmp_string(t1, t2); +} + + +/* sort_down_index_string --- descending index strings */ + +static int +sort_down_index_string(const void *p1, const void *p2) +{ + /* + * Negation versus transposed arguments: when all keys are + * distinct, as with array indices here, either method will + * transform an ascending sort into a descending one. But if + * there are equal keys--such as when IGNORECASE is honored-- + * that get disambiguated into a determisitc order, negation + * will reverse those but transposed arguments would retain + * their relative order within the rest of the reversed sort. + */ + return -sort_up_index_string(p1, p2); +} + + +/* sort_up_index_number --- qsort comparison function; ascending index numbers. */ + +static int +sort_up_index_number(const void *p1, const void *p2) +{ + const NODE *n1, *n2; + int ret; + + n1 = *((const NODE *const *) p1); + n2 = *((const NODE *const *) p2); + + if (n1->ahname_num < n2->ahname_num) + ret = -1; + else + ret = (n1->ahname_num > n2->ahname_num); + + /* break a tie with the index string itself */ + if (ret == 0) + return cmp_string(n1, n2); + return ret; +} + + +/* sort_down_index_number --- qsort comparison function; descending index numbers */ + +static int +sort_down_index_number(const void *p1, const void *p2) +{ + return -sort_up_index_number(p1, p2); +} + + +/* sort_up_value_string --- qsort comparison function; ascending value string */ + +static int +sort_up_value_string(const void *p1, const void *p2) +{ + const NODE *t1, *t2; + NODE *n1, *n2; + + /* we're passed a pair of index (array subscript) nodes */ + t1 = *(const NODE *const *) p1; + t2 = *(const NODE *const *) p2; + + /* and we want to compare the element values they refer to */ + n1 = t1->ahvalue; + n2 = t2->ahvalue; + + if (n1->type == Node_var_array) { + /* return 0 if n2 is a sub-array too, else return 1 */ + return (n2->type != Node_var_array); + } + if (n2->type == Node_var_array) + return -1; /* n1 (scalar) < n2 (sub-array) */ + + /* n1 and n2 both have string values; See sort_force_value_string(). */ + return cmp_string(n1, n2); +} + + +/* sort_down_value_string --- descending value string */ + +static int +sort_down_value_string(const void *p1, const void *p2) +{ + return -sort_up_value_string(p1, p2); +} + +/* sort_up_value_number --- qsort comparison function; ascending value number */ + +static int +sort_up_value_number(const void *p1, const void *p2) +{ + const NODE *t1, *t2; + NODE *n1, *n2; + int ret; + + /* we're passed a pair of index (array subscript) nodes */ + t1 = *(const NODE *const *) p1; + t2 = *(const NODE *const *) p2; + + /* and we want to compare the element values they refer to */ + n1 = t1->ahvalue; + n2 = t2->ahvalue; + + if (n1->type == Node_var_array) { + /* return 0 if n2 is a sub-array too, else return 1 */ + return (n2->type != Node_var_array); + } + if (n2->type == Node_var_array) + return -1; /* n1 (scalar) < n2 (sub-array) */ + + /* n1 and n2 both Node_val, and force_number'ed */ + if (n1->numbr < n2->numbr) + ret = -1; + else + ret = (n1->numbr > n2->numbr); + + if (ret == 0) { + /* + * Use string value to guarantee same sort order on all + * versions of qsort(). + */ + n1 = force_string(n1); + n2 = force_string(n2); + ret = cmp_string(n1, n2); + } + + return ret; +} + +/* sort_down_value_number --- descending value number */ + +static int +sort_down_value_number(const void *p1, const void *p2) +{ + return -sort_up_value_number(p1, p2); +} + +/* sort_up_value_type --- qsort comparison function; ascending value type */ + +static int +sort_up_value_type(const void *p1, const void *p2) +{ + const NODE *t1, *t2; + NODE *n1, *n2; + + /* we're passed a pair of index (array subscript) nodes */ + t1 = *(const NODE *const *) p1; + t2 = *(const NODE *const *) p2; + + /* and we want to compare the element values they refer to */ + n1 = t1->ahvalue; + n2 = t2->ahvalue; + + /* 1. Arrays vs. scalar, scalar is less than array */ + if (n1->type == Node_var_array) { + /* return 0 if n2 is a sub-array too, else return 1 */ + return (n2->type != Node_var_array); + } + if (n2->type == Node_var_array) { + return -1; /* n1 (scalar) < n2 (sub-array) */ + } + + /* two scalars */ + /* 2. Resolve MAYBE_NUM, so that have only NUMBER or STRING */ + if ((n1->flags & MAYBE_NUM) != 0) + (void) force_number(n1); + if ((n2->flags & MAYBE_NUM) != 0) + (void) force_number(n2); + + if ((n1->flags & NUMBER) != 0 && (n2->flags & NUMBER) != 0) { + if (n1->numbr < n2->numbr) + return -1; + else if (n1->numbr > n2->numbr) + return 1; + else + return 0; + } + + /* 3. All numbers are less than all strings. This is aribitrary. */ + if ((n1->flags & NUMBER) != 0 && (n2->flags & STRING) != 0) { + return -1; + } else if ((n1->flags & STRING) != 0 && (n2->flags & NUMBER) != 0) { + return 1; + } + + /* 4. Two strings */ + return cmp_string(n1, n2); +} + +/* sort_down_value_type --- descending value type */ + +static int +sort_down_value_type(const void *p1, const void *p2) +{ + return -sort_up_value_type(p1, p2); +} + +/* sort_user_func --- user defined qsort comparison function */ + +static int +sort_user_func(const void *p1, const void *p2) +{ + const NODE *t1, *t2; + NODE *idx1, *idx2, *val1, *val2; + AWKNUM ret; + INSTRUCTION *code; + + t1 = *((const NODE *const *) p1); + t2 = *((const NODE *const *) p2); + + idx1 = make_string(t1->ahname_str, t1->ahname_len); + idx2 = make_string(t2->ahname_str, t2->ahname_len); + val1 = t1->ahvalue; + val2 = t2->ahvalue; + + code = TOP()->code_ptr; /* comparison function call instructions */ + + /* setup 4 arguments to comp_func() */ + PUSH(idx1); + if (val1->type == Node_val) + UPREF(val1); + PUSH(val1); + PUSH(idx2); + if (val2->type == Node_val) + UPREF(val2); + PUSH(val2); + + /* execute the comparison function */ + (void) interpret(code); + + /* return value of the comparison function */ + POP_NUMBER(ret); + + return (ret < 0.0) ? -1 : (ret > 0.0); +} + +/* sort_force_index_number -- pre-process list items for sorting indices as numbers */ + +static void +sort_force_index_number(NODE **list, size_t num_elems) +{ + size_t i; + NODE *r; + static NODE temp_node; + + for (i = 0; i < num_elems; i++) { + r = list[i]; + + if ((r->flags & NUMIND) != 0) /* once in a lifetime is plenty */ + continue; + temp_node.type = Node_val; + temp_node.stptr = r->ahname_str; + temp_node.stlen = r->ahname_len; + temp_node.flags = 0; /* only interested in the return value of r_force_number */ + r->ahname_num = r_force_number(& temp_node); + r->flags |= NUMIND; + } +} + +/* sort_force_value_number -- pre-process list items for sorting values as numbers */ + +static void +sort_force_value_number(NODE **list, size_t num_elems) +{ + size_t i; + NODE *r, *val; + + for (i = 0; i < num_elems; i++) { + r = list[i]; + val = r->ahvalue; + if (val->type == Node_val) + (void) force_number(val); + } +} + +/* sort_force_value_string -- pre-process list items for sorting values as strings */ + +static void +sort_force_value_string(NODE **list, size_t num_elems) +{ + size_t i; + NODE *r, *val; + + for (i = 0; i < num_elems; i++) { + r = list[i]; + val = r->ahvalue; + if (val->type == Node_val) + r->ahvalue = force_string(val); + } +} + +/* assoc_list -- construct, and optionally sort, a list of array elements */ + +NODE ** +assoc_list(NODE *array, const char *sort_str, SORT_CTXT sort_ctxt) +{ + typedef void (*qsort_prefunc)(NODE **, size_t); + typedef int (*qsort_compfunc)(const void *, const void *); + + static const struct qsort_funcs { + const char *name; + qsort_compfunc comp_func; + qsort_prefunc pre_func; /* pre-processing of list items */ + } sort_funcs[] = { + { "@ind_str_asc", sort_up_index_string, 0 }, + { "@ind_num_asc", sort_up_index_number, sort_force_index_number }, + { "@val_str_asc", sort_up_value_string, sort_force_value_string }, + { "@val_num_asc", sort_up_value_number, sort_force_value_number }, + { "@ind_str_desc", sort_down_index_string, 0 }, + { "@ind_num_desc", sort_down_index_number, sort_force_index_number }, + { "@val_str_desc", sort_down_value_string, sort_force_value_string }, + { "@val_num_desc", sort_down_value_number, sort_force_value_number }, + { "@val_type_asc", sort_up_value_type, 0 }, + { "@val_type_desc", sort_down_value_type, 0 }, + { "@unsorted", 0, 0 }, + }; + NODE **list; + NODE *r; + size_t num_elems, i, j; + qsort_compfunc cmp_func = 0; + qsort_prefunc pre_func = 0; + INSTRUCTION *code = NULL; + int qi; + extern int currule; + + num_elems = array->table_size; + assert(num_elems > 0); + + for (qi = 0, j = sizeof(sort_funcs)/sizeof(sort_funcs[0]); qi < j; qi++) { + if (strcmp(sort_funcs[qi].name, sort_str) == 0) + break; + } + + if (qi >= 0 && qi < j) { + cmp_func = sort_funcs[qi].comp_func; + pre_func = sort_funcs[qi].pre_func; + + } else { /* unrecognized */ + NODE *f; + const char *sp; + + assert(sort_str != NULL); + + for (sp = sort_str; *sp != '\0' + && ! isspace((unsigned char) *sp); sp++) + continue; + + /* empty string or string with space(s) not valid as function name */ + if (sp == sort_str || *sp != '\0') + fatal(_("`%s' is invalid as a function name"), sort_str); + + f = lookup(sort_str); + if (f == NULL || f->type != Node_func) + fatal(_("sort comparison function `%s' is not defined"), sort_str); + + cmp_func = sort_user_func; + /* pre_func is still NULL */ + + /* make function call instructions */ + code = bcalloc(Op_func_call, 2, 0); + code->func_body = f; + code->func_name = NULL; /* not needed, func_body already assigned */ + (code + 1)->expr_count = 4; /* function takes 4 arguments */ + code->nexti = bcalloc(Op_stop, 1, 0); + + /* make non-redirected getline, exit, `next' and `nextfile' fatal in + * callback function by setting currule in interpret() + * to undefined (0). + */ + + (code + 1)->inrule = currule; /* save current rule */ + currule = 0; + + PUSH_CODE(code); + } + + /* allocate space for array; the extra space is used in for(i in a) opcode (eval.c) */ + emalloc(list, NODE **, (num_elems + 1) * sizeof(NODE *), "assoc_list"); + + /* populate it */ + for (i = j = 0; i < array->array_size; i++) + for (r = array->var_array[i]; r != NULL; r = r->ahnext) + list[j++] = dupnode(r); + list[num_elems] = NULL; + + if (! cmp_func) /* unsorted */ + return list; + + /* special pre-processing of list items */ + if (pre_func) + pre_func(list, num_elems); + + qsort(list, num_elems, sizeof(NODE *), cmp_func); /* shazzam! */ + + if (cmp_func == sort_user_func) { + code = POP_CODE(); + currule = (code + 1)->inrule; /* restore current rule */ + bcfree(code->nexti); /* Op_stop */ + bcfree(code); /* Op_func_call */ + } + + return list; +} + + +/* +From bonzini@gnu.org Mon Oct 28 16:05:26 2002 +Date: Mon, 28 Oct 2002 13:33:03 +0100 +From: Paolo Bonzini +To: arnold@skeeve.com +Subject: Hash function +Message-ID: <20021028123303.GA6832@biancaneve> + +Here is the hash function I'm using in GNU Smalltalk. The scrambling is +needed if you use powers of two as the table sizes. If you use primes it +is not needed. + +To use double-hashing with power-of-two size, you should use the +_gst_hash_string(str, len) as the primary hash and +scramble(_gst_hash_string (str, len)) | 1 as the secondary hash. + +Paolo + +*/ +/* + * ADR: Slightly modified to work w/in the context of gawk. + */ + +static unsigned long +gst_hash_string(const char *str, size_t len, unsigned long hsize, size_t *code) +{ + unsigned long hashVal = 1497032417; /* arbitrary value */ + unsigned long ret; + + while (len--) { + hashVal += *str++; + hashVal += (hashVal << 10); + hashVal ^= (hashVal >> 6); + } + + ret = scramble(hashVal); + + if (code != NULL) + *code = ret; + + if (ret >= hsize) + ret %= hsize; + + return ret; +} + +static unsigned long +scramble(unsigned long x) +{ + if (sizeof(long) == 4) { + int y = ~x; + + x += (y << 10) | (y >> 22); + x += (x << 6) | (x >> 26); + x -= (x << 16) | (x >> 16); + } else { + x ^= (~x) >> 31; + x += (x << 21) | (x >> 11); + x += (x << 5) | (x >> 27); + x += (x << 27) | (x >> 5); + x += (x << 31); + } + + return x; +} diff --git a/awk.h b/awk.h new file mode 100644 index 0000000..3574e58 --- /dev/null +++ b/awk.h @@ -0,0 +1,1432 @@ +/* + * awk.h -- Definitions for gawk. + */ + +/* + * Copyright (C) 1986, 1988, 1989, 1991-2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* ------------------------------ Includes ------------------------------ */ + +/* + * config.h absolutely, positively, *M*U*S*T* be included before + * any system headers. Otherwise, extreme death, destruction + * and loss of life results. + */ +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE 1 /* enable GNU extensions */ +#endif /* _GNU_SOURCE */ + +#if defined(_TANDEM_SOURCE) && ! defined(_SCO_DS) +#define _XOPEN_SOURCE_EXTENDED 1 +#endif + +#include +#include +#ifdef HAVE_LIMITS_H +#include +#endif /* HAVE_LIMITS_H */ +#include +#include + +#include "gettext.h" +#define _(msgid) gettext(msgid) +#define N_(msgid) msgid + +#if ! (defined(HAVE_LIBINTL_H) && defined(ENABLE_NLS) && ENABLE_NLS > 0) +#ifndef LOCALEDIR +#define LOCALEDIR NULL +#endif /* LOCALEDIR */ +#endif + +#if !defined(__STDC__) || __STDC__ < 1 +#error "gawk no longer supports non-C89 environments (no __STDC__ or __STDC__ < 1)" +#endif + +#if defined(HAVE_STDARG_H) +#include +#else +#error "gawk no longer supports . Please update your compiler and runtime" +#endif +#include +#include +#include +#if ! defined(errno) +extern int errno; +#endif + +#ifdef STDC_HEADERS +#include +#endif /* not STDC_HEADERS */ + +#include "mbsupport.h" /* defines MBS_SUPPORT */ + +#if MBS_SUPPORT +/* We can handle multibyte strings. */ +#include +#include +#endif + +#ifdef STDC_HEADERS +#include +#endif + +#undef CHARBITS +#undef INTBITS + +#if !defined(ZOS_USS) +#if HAVE_INTTYPES_H +# include +#endif +#if HAVE_STDINT_H +# include +#endif +#endif /* !ZOS_USS */ + +/* ----------------- System dependencies (with more includes) -----------*/ + +/* This section is the messiest one in the file, not a lot that can be done */ + +#define MALLOC_ARG_T size_t + +#ifndef VMS +#ifdef HAVE_FCNTL_H +#include +#endif +#include +#include +#else /* VMS */ +#include +#include +#include /* avoid in io.c */ +/* debug.c needs this; when _DECC_V4_SOURCE is defined (as it is + in our config.h [vms/vms-conf.h]), off_t won't get declared */ +# if !defined(__OFF_T) && !defined(_OFF_T) +# if defined(____OFF_T) || defined(___OFF_T) +typedef __off_t off_t; /* __off_t is either int or __int64 */ +# else +typedef int off_t; +# endif +# endif +#endif /* VMS */ + +#if ! defined(S_ISREG) && defined(S_IFREG) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#endif + +#include "protos.h" + +#ifdef HAVE_STRING_H +#include +#ifdef NEED_MEMORY_H +#include +#endif /* NEED_MEMORY_H */ +#else /* not HAVE_STRING_H */ +#ifdef HAVE_STRINGS_H +#include +#endif /* HAVE_STRINGS_H */ +#endif /* not HAVE_STRING_H */ + +#if HAVE_UNISTD_H +#include +#endif /* HAVE_UNISTD_H */ + +#ifdef VMS +#include +#include "vms/redirect.h" +#endif /*VMS*/ + +#ifndef O_BINARY +#define O_BINARY 0 +#endif + +#ifndef HAVE_VPRINTF +#error "you lose: you need a system with vfprintf" +#endif /* HAVE_VPRINTF */ + +#ifndef HAVE_SETLOCALE +#define setlocale(locale, val) /* nothing */ +#endif /* HAVE_SETLOCALE */ + +#ifndef HAVE_SETSID +#define setsid() /* nothing */ +#endif /* HAVE_SETSID */ + +#if HAVE_MEMCPY_ULONG +extern char *memcpy_ulong(char *dest, const char *src, unsigned long l); +#define memcpy memcpy_ulong +#endif +#if HAVE_MEMSET_ULONG +extern void *memset_ulong(void *dest, int val, unsigned long l); +#define memset memset_ulong +#endif + +#ifdef HAVE_LIBSIGSEGV +#include +#else +typedef void *stackoverflow_context_t; +#define sigsegv_install_handler(catchsegv) signal(SIGSEGV, catchsig) +/* define as 0 rather than empty so that (void) cast on it works */ +#define stackoverflow_install_handler(catchstackoverflow, extra_stack, STACK_SIZE) 0 +#endif + +/* use this as lintwarn("...") + this is a hack but it gives us the right semantics */ +#define lintwarn (*(set_loc(__FILE__, __LINE__),lintfunc)) + +#include "regex.h" +#include "dfa.h" +typedef struct Regexp { + struct re_pattern_buffer pat; + struct re_registers regs; + struct dfa *dfareg; + short dfa; + short has_anchor; /* speed up of avoid_dfa kludge, temporary */ + short non_empty; /* for use in fpat_parse_field */ +} Regexp; +#define RESTART(rp,s) (rp)->regs.start[0] +#define REEND(rp,s) (rp)->regs.end[0] +#define SUBPATSTART(rp,s,n) (rp)->regs.start[n] +#define SUBPATEND(rp,s,n) (rp)->regs.end[n] +#define NUMSUBPATS(rp,s) (rp)->regs.num_regs + +/* regexp matching flags: */ +#define RE_NEED_START 1 /* need to know start/end of match */ +#define RE_NO_BOL 2 /* not allowed to match ^ in regexp */ + +/* Stuff for losing systems. */ +#if !defined(HAVE_STRTOD) +extern double gawk_strtod(); +#define strtod gawk_strtod +#endif + +#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) +# define __attribute__(x) +#endif + +#ifndef ATTRIBUTE_UNUSED +#define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +#endif /* ATTRIBUTE_UNUSED */ + +#ifndef ATTRIBUTE_NORETURN +#define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +#endif /* ATTRIBUTE_NORETURN */ + +#ifndef ATTRIBUTE_PRINTF +#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) +#define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2) +#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3) +#endif /* ATTRIBUTE_PRINTF */ + +/* We use __extension__ in some places to suppress -pedantic warnings + about GCC extensions. This feature didn't work properly before + gcc 2.8. */ +#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) +#define __extension__ +#endif + +/* ------------------ Constants, Structures, Typedefs ------------------ */ + +#define AWKNUM double + +#ifndef TRUE +/* a bit hackneyed, but what the heck */ +#define TRUE 1 +#define FALSE 0 +#endif + +#define LINT_INVALID 1 /* only warn about invalid */ +#define LINT_ALL 2 /* warn about all things */ + +enum defrule {BEGIN = 1, Rule, END, BEGINFILE, ENDFILE, + MAXRULE /* sentinel, not legal */ }; +extern const char *const ruletab[]; + + +typedef enum nodevals { + /* illegal entry == 0 */ + Node_illegal, + + Node_val, /* node is a value - type in flags */ + Node_regex, /* a regexp, text, compiled, flags, etc */ + Node_dynregex, /* a dynamic regexp */ + + /* symbol table values */ + Node_var, /* scalar variable, lnode is value */ + Node_var_array, /* array is ptr to elements, table_size num of eles */ + Node_var_new, /* newly created variable, may become an array */ + Node_param_list, /* lnode is a variable, rnode is more list */ + Node_func, /* lnode is param. list, rnode is body */ + + Node_hashnode, /* an identifier in the symbol table */ + Node_ahash, /* an array element */ + Node_array_ref, /* array passed by ref as parameter */ + + /* program execution -- stack item types */ + Node_arrayfor, + Node_frame, + Node_instruction, + + Node_final /* sentry value, not legal */ +} NODETYPE; + + +struct exp_instruction; + +/* + * NOTE - this struct is a rather kludgey -- it is packed to minimize + * space usage, at the expense of cleanliness. Alter at own risk. + */ +typedef struct exp_node { + union { + struct { + union { + struct exp_node *lptr; + struct exp_instruction *li; + long ll; + } l; + union { + struct exp_node *rptr; + Regexp *preg; + struct exp_node **av; + void (*uptr)(void); + struct exp_instruction *ri; + } r; + union { + struct exp_node *extra; + void (*aptr)(void); + long xl; + char **param_list; + } x; + char *name; + struct exp_node *rn; + unsigned long reflags; +# define CASE 1 +# define CONSTANT 2 +# define FS_DFLT 4 + } nodep; + struct { + AWKNUM fltnum; /* this is here for optimal packing of + * the structure on many machines + */ + char *sp; + size_t slen; + long sref; + int idx; +#if MBS_SUPPORT + wchar_t *wsp; + size_t wslen; +#endif + } val; + struct { + AWKNUM num; + struct exp_node *next; + char *name; + size_t length; + struct exp_node *value; + long ref; + size_t code; + } hash; +#define hnext sub.hash.next +#define hname sub.hash.name +#define hlength sub.hash.length +#define hvalue sub.hash.value + +#define ahnext sub.hash.next +#define ahname_str sub.hash.name +#define ahname_len sub.hash.length +#define ahname_num sub.hash.num +#define ahvalue sub.hash.value +#define ahname_ref sub.hash.ref +#define ahcode sub.hash.code + } sub; + NODETYPE type; + unsigned short flags; +# define MALLOC 1 /* can be free'd */ +# define PERM 2 /* can't be free'd */ +# define STRING 4 /* assigned as string */ +# define STRCUR 8 /* string value is current */ +# define NUMCUR 16 /* numeric value is current */ +# define NUMBER 32 /* assigned as number */ +# define MAYBE_NUM 64 /* user input: if NUMERIC then + * a NUMBER */ +# define ARRAYMAXED 128 /* array is at max size */ +# define FUNC 256 /* this parameter is really a + * function name; see awkgram.y */ +# define FIELD 512 /* this is a field */ +# define INTLSTR 1024 /* use localized version */ +# define NUMIND 2048 /* numeric val of index is current */ +# define WSTRCUR 4096 /* wide str value is current */ +} NODE; + + +#define vname sub.nodep.name + +#define lnode sub.nodep.l.lptr +#define nextp sub.nodep.l.lptr +#define rnode sub.nodep.r.rptr + +#define param_cnt sub.nodep.l.ll +#define param vname + +#define parmlist sub.nodep.x.param_list +#define code_ptr sub.nodep.r.ri + +#define re_reg sub.nodep.r.preg +#define re_flags sub.nodep.reflags +#define re_text lnode +#define re_exp sub.nodep.x.extra +#define re_cnt flags + +#define stptr sub.val.sp +#define stlen sub.val.slen +#define valref sub.val.sref +#define stfmt sub.val.idx + +#define wstptr sub.val.wsp +#define wstlen sub.val.wslen + +#define numbr sub.val.fltnum + +/* Node_frame: */ +#define stack sub.nodep.r.av +#define func_node sub.nodep.x.extra +#define prev_frame_size sub.nodep.reflags +#define reti sub.nodep.l.li + +/* Node_var: */ +#define var_value lnode +#define var_update sub.nodep.r.uptr +#define var_assign sub.nodep.x.aptr + +/* Node_var_array: */ +#define var_array sub.nodep.r.av +#define array_size sub.nodep.l.ll +#define table_size sub.nodep.x.xl +#define parent_array sub.nodep.rn + +/* Node_array_ref: */ +#define orig_array lnode +#define prev_array rnode + +/* --------------------------------lint warning types----------------------------*/ +typedef enum lintvals { + LINT_illegal, + LINT_assign_in_cond, + LINT_no_effect +} LINTTYPE; + +/* --------------------------------Instruction ---------------------------------- */ + +typedef enum opcodeval { + /* illegal entry == 0 */ + Op_illegal, + + /* binary operators */ + Op_times, + Op_times_i, + Op_quotient, + Op_quotient_i, + Op_mod, + Op_mod_i, + Op_plus, + Op_plus_i, + Op_minus, + Op_minus_i, + Op_exp, + Op_exp_i, + Op_concat, + + /* line range instruction pair */ + Op_line_range, /* flags for Op_cond_pair */ + Op_cond_pair, /* conditional pair */ + + Op_subscript, + Op_sub_array, + + /* unary operators */ + Op_preincrement, + Op_predecrement, + Op_postincrement, + Op_postdecrement, + Op_unary_minus, + Op_field_spec, + + /* unary relationals */ + Op_not, + + /* assignments */ + Op_assign, + Op_store_var, /* simple variable assignment optimization */ + Op_store_sub, /* array[subscript] assignment optimization */ + Op_store_field, /* $n assignment optimization */ + Op_assign_times, + Op_assign_quotient, + Op_assign_mod, + Op_assign_plus, + Op_assign_minus, + Op_assign_exp, + Op_assign_concat, + + /* boolean binaries */ + Op_and, /* a left subexpression in && */ + Op_and_final, /* right subexpression of && */ + Op_or, + Op_or_final, + + /* binary relationals */ + Op_equal, + Op_notequal, + Op_less, + Op_greater, + Op_leq, + Op_geq, + Op_match, + Op_match_rec, /* match $0 */ + Op_nomatch, + + Op_rule, + + /* keywords */ + Op_K_case, + Op_K_default, + Op_K_break, + Op_K_continue, + Op_K_print, + Op_K_print_rec, + Op_K_printf, + Op_K_next, + Op_K_exit, + Op_K_return, + Op_K_delete, + Op_K_delete_loop, + Op_K_getline_redir, + Op_K_getline, + Op_K_nextfile, + + Op_builtin, + Op_sub_builtin, /* sub, gsub and gensub */ + Op_in_array, /* boolean test of membership in array */ + + /* function call instruction */ + Op_func_call, + Op_indirect_func_call, + + Op_push, /* scalar variable */ + Op_push_arg, /* variable type (scalar or array) argument to built-in */ + Op_push_i, /* number, string */ + Op_push_re, /* regex */ + Op_push_array, + Op_push_param, + Op_push_lhs, + Op_subscript_lhs, + Op_field_spec_lhs, + Op_no_op, /* jump target */ + Op_pop, /* pop an item from the runtime stack */ + Op_jmp, + Op_jmp_true, + Op_jmp_false, + Op_get_record, + Op_newfile, + Op_arrayfor_init, + Op_arrayfor_incr, + Op_arrayfor_final, + + Op_var_update, /* update value of NR, NF or FNR */ + Op_var_assign, + Op_field_assign, + Op_after_beginfile, + Op_after_endfile, + + Op_ext_func, + Op_func, + + Op_exec_count, + Op_breakpoint, + Op_lint, + Op_atexit, + Op_stop, + + /* parsing (yylex and yyparse), should never appear in valid compiled code */ + Op_token, + Op_symbol, + Op_list, + + /* program structures -- for use in the profiler/pretty printer */ + Op_K_do, + Op_K_for, + Op_K_arrayfor, + Op_K_while, + Op_K_switch, + Op_K_if, + Op_K_else, + Op_K_function, + Op_cond_exp, + Op_final /* sentry value, not legal */ +} OPCODE; + +enum redirval { + /* I/O redirections */ + redirect_output = 1, + redirect_append, + redirect_pipe, + redirect_pipein, + redirect_input, + redirect_twoway +}; + +struct break_point; + +typedef struct exp_instruction { + struct exp_instruction *nexti; + union { + NODE *dn; + struct exp_instruction *di; + NODE *(*fptr)(int); + long dl; + char *name; + } d; + + union { + long xl; + NODE *xn; + void (*aptr)(void); + struct exp_instruction *xi; + struct break_point *bpt; + } x; + + short source_line; + OPCODE opcode; +} INSTRUCTION; + +#define func_name d.name + +#define memory d.dn +#define builtin d.fptr +#define builtin_idx d.dl + +#define expr_count x.xl + +#define target_continue d.di +#define target_jmp d.di +#define target_break x.xi + +/* Op_sub_builtin */ +#define sub_flags d.dl +#define GSUB 0x01 /* builtin is gsub */ +#define GENSUB 0x02 /* builtin is gensub */ +#define LITERAL 0x04 /* target is a literal string */ + + +/* Op_K_exit */ +#define target_end d.di +#define target_atexit x.xi + +/* Op_newfile, Op_K_getline, Op_nextfile */ +#define target_endfile x.xi + +/* Op_newfile */ +#define target_get_record x.xi + +/* Op_get_record, Op_K_nextfile */ +#define target_newfile d.di + +/* Op_K_getline */ +#define target_beginfile d.di + +/* Op_get_record */ +#define has_endfile x.xl + +/* Op_token */ +#define lextok d.name + +/* Op_rule */ +#define in_rule x.xl +#define source_file d.name + + /* Op_K_case, Op_K_default */ +#define case_stmt x.xi +#define case_exp d.di +#define stmt_start case_exp +#define stmt_end case_stmt +#define match_exp x.xl + +#define target_stmt x.xi + +/* Op_K_switch */ +#define switch_end x.xi +#define switch_start d.di + +/* Op_K_getline, Op_K_getline_redir */ +#define into_var x.xl + +/* Op_K_getline_redir, Op_K_print, Op_K_print_rec, Op_K_printf */ +#define redir_type d.dl + +/* Op_arrayfor_incr */ +#define array_var x.xn + +/* Op_line_range */ +#define triggered x.xl + +/* Op_cond_pair */ +#define line_range x.xi + +/* Op_func_call, Op_func */ +#define func_body x.xn + +/* Op_func_call */ +#define inrule d.dl + +/* Op_subscript */ +#define sub_count d.dl + +/* Op_push_lhs, Op_subscript_lhs, Op_field_spec_lhs */ +#define do_reference x.xl + +/* Op_list, Op_rule, Op_func */ +#define lasti d.di +#define firsti x.xi + +/* Op_rule, Op_func */ +#define last_line x.xl +#define first_line source_line + +/* Op_lint */ +#define lint_type d.dl + +/* Op_field_spec_lhs */ +#define target_assign d.di + +/* Op_var_assign */ +#define assign_var x.aptr + +/* Op_var_update */ +#define update_var x.aptr + +/* Op_field_assign */ +#define field_assign x.aptr + +/* Op_field_assign, Op_var_assign */ +#define assign_ctxt d.dl + +/* Op_concat */ +#define concat_flag d.dl +#define CSUBSEP 1 +#define CSVAR 2 + +/* Op_breakpoint */ +#define break_pt x.bpt + +/*------------------ pretty printing/profiling --------*/ +/* Op_exec_count */ +#define exec_count d.dl + +/* Op_K_while */ +#define while_body d.di + +/* Op_K_do */ +#define doloop_cond d.di + +/* Op_K_for */ +#define forloop_cond d.di +#define forloop_body x.xi + +/* Op_K_if */ +#define branch_if d.di +#define branch_else x.xi + +/* Op_K_else */ +#define branch_end x.xi + +/* Op_line_range */ +#define condpair_left d.di +#define condpair_right x.xi + +typedef struct iobuf { + const char *name; /* filename */ + int fd; /* file descriptor */ + struct stat sbuf; /* stat buf */ + char *buf; /* start data buffer */ + char *off; /* start of current record in buffer */ + char *dataend; /* first byte in buffer to hold new data, + NULL if not read yet */ + char *end; /* end of buffer */ + size_t readsize; /* set from fstat call */ + size_t size; /* buffer size */ + ssize_t count; /* amount read last time */ + size_t scanoff; /* where we were in the buffer when we had + to regrow/refill */ + + void *opaque; /* private data for open hooks */ + int (*get_record)(char **out, struct iobuf *, int *errcode); + void (*close_func)(struct iobuf *); /* open and close hooks */ + + int errcode; + + int flag; +# define IOP_IS_TTY 1 +# define IOP_NOFREE_OBJ 2 +# define IOP_AT_EOF 4 +# define IOP_CLOSED 8 +# define IOP_AT_START 16 +} IOBUF; + +typedef void (*Func_ptr)(void); + +/* structure used to dynamically maintain a linked-list of open files/pipes */ +struct redirect { + unsigned int flag; +# define RED_FILE 1 +# define RED_PIPE 2 +# define RED_READ 4 +# define RED_WRITE 8 +# define RED_APPEND 16 +# define RED_NOBUF 32 +# define RED_USED 64 /* closed temporarily to reuse fd */ +# define RED_EOF 128 +# define RED_TWOWAY 256 +# define RED_PTY 512 +# define RED_SOCKET 1024 +# define RED_TCP 2048 + char *value; + FILE *fp; + FILE *ifp; /* input fp, needed for PIPES_SIMULATED */ + IOBUF *iop; + int pid; + int status; + struct redirect *prev; + struct redirect *next; + const char *mode; +}; + +/* + * structure for our source, either a command line string or a source file. + */ + +typedef struct srcfile { + struct srcfile *next; + struct srcfile *prev; + + enum srctype { SRC_CMDLINE = 1, SRC_STDIN, SRC_FILE, SRC_INC } stype; + char *src; /* name on command line or inclde statement */ + char *fullpath; /* full path after AWKPATH search */ + time_t mtime; + struct stat sbuf; + int srclines; /* no of lines in source */ + size_t bufsize; + char *buf; + int *line_offset; /* offset to the beginning of each line */ + int fd; + int maxlen; /* size of the longest line */ + + char *lexptr; + char *lexend; + char *lexeme; + char *lexptr_begin; + int lasttok; +} SRCFILE; + +/* structure for execution context */ +typedef struct context { + INSTRUCTION pools; + NODE symbols; + INSTRUCTION rule_list; + SRCFILE srcfiles; + int sourceline; + char *source; + void (*install_func)(char *); + struct context *prev; +} AWK_CONTEXT; + +/* for debugging purposes */ +struct flagtab { + int val; + const char *name; +}; + +#ifndef LONG_MAX +#define LONG_MAX ((long)(~(1L << (sizeof (long) * 8 - 1)))) +#endif +#ifndef ULONG_MAX +#define ULONG_MAX (~(unsigned long)0) +#endif +#ifndef LONG_MIN +#define LONG_MIN ((long)(-LONG_MAX - 1L)) +#endif +#define UNLIMITED LONG_MAX + +/* -------------------------- External variables -------------------------- */ +/* gawk builtin variables */ +extern long NF; +extern long NR; +extern long FNR; +extern int BINMODE; +extern int IGNORECASE; +extern int RS_is_null; +extern char *OFS; +extern int OFSlen; +extern char *ORS; +extern int ORSlen; +extern char *OFMT; +extern char *CONVFMT; +extern int CONVFMTidx; +extern int OFMTidx; +extern char *TEXTDOMAIN; +extern NODE *BINMODE_node, *CONVFMT_node, *FIELDWIDTHS_node, *FILENAME_node; +extern NODE *FNR_node, *FS_node, *IGNORECASE_node, *NF_node; +extern NODE *NR_node, *OFMT_node, *OFS_node, *ORS_node, *RLENGTH_node; +extern NODE *RSTART_node, *RS_node, *RT_node, *SUBSEP_node, *PROCINFO_node; +extern NODE *LINT_node, *ERRNO_node, *TEXTDOMAIN_node, *FPAT_node; +extern NODE *Nnull_string; +extern NODE *Null_field; +extern NODE **fields_arr; +extern int sourceline; +extern char *source; + +#if __GNUC__ < 2 +extern NODE *_t; /* used as temporary in tree_eval */ +#endif +extern NODE *_r; /* used as temporary in stack macros */ + +extern NODE *nextfree; +extern int field0_valid; +extern int do_traditional; +extern int do_posix; +extern int do_intervals; +extern int do_intl; +extern int do_non_decimal_data; +extern int do_profiling; +extern int do_dump_vars; +extern int do_tidy_mem; +extern int do_sandbox; +extern int do_optimize; +extern int use_lc_numeric; +extern int exit_val; + +#ifdef NO_LINT +#define do_lint 0 +#define do_lint_old 0 +#else +extern int do_lint; +extern int do_lint_old; +#endif +#if MBS_SUPPORT +extern int gawk_mb_cur_max; +#else +#define gawk_mb_cur_max (1) +#endif + +#if defined (HAVE_GETGROUPS) && defined(NGROUPS_MAX) && NGROUPS_MAX > 0 +extern GETGROUPS_T *groupset; +extern int ngroups; +#endif + +#ifdef HAVE_LOCALE_H +extern struct lconv loc; +#endif /* HAVE_LOCALE_H */ + +extern const char *myname; +extern const char def_strftime_format[]; + +extern char quote; +extern char *defpath; +extern char envsep; + +extern char casetable[]; /* for case-independent regexp matching */ + +/* + * Provide a way for code to know which program is executing: + * gawk vs dgawk vs pgawk. + */ +enum exe_mode { exe_normal = 1, exe_debugging, exe_profiling }; +extern enum exe_mode which_gawk; /* (defined in eval.c) */ + +/* ------------------------- Runtime stack -------------------------------- */ + +typedef union stack_item { + NODE *rptr; /* variable etc. */ + NODE **lptr; /* address of a variable etc. */ +} STACK_ITEM; + +extern STACK_ITEM *stack_ptr; +extern NODE *frame_ptr; +extern STACK_ITEM *stack_bottom; +extern STACK_ITEM *stack_top; + +#define decr_sp() (stack_ptr--) +#define incr_sp() ((stack_ptr < stack_top) ? ++stack_ptr : grow_stack()) +#define stack_adj(n) (stack_ptr += (n)) +#define stack_empty() (stack_ptr < stack_bottom) + +#define POP() decr_sp()->rptr +#define POP_ADDRESS() decr_sp()->lptr +#define PEEK(n) (stack_ptr - (n))->rptr +#define TOP() stack_ptr->rptr /* same as PEEK(0) */ +#define TOP_ADDRESS() stack_ptr->lptr +#define PUSH(r) (void) (incr_sp()->rptr = (r)) +#define PUSH_ADDRESS(l) (void) (incr_sp()->lptr = (l)) +#define REPLACE(r) (void) (stack_ptr->rptr = (r)) +#define REPLACE_ADDRESS(l) (void) (stack_ptr->lptr = (l)) + + +/* function param */ +#define GET_PARAM(n) frame_ptr->stack[n] + +/* + * UPREF and DEREF --- simplified versions of dupnode and unref + * UPREF does not handle FIELD node. Most appropriate use is + * for elements on the runtime stack. When in doubt, use dupnode. + */ + +#define DEREF(r) ( _r = (r), (!(_r->flags & PERM) && (--_r->valref == 0)) ? unref(_r) : (void)0 ) + +#if __GNUC__ >= 2 +#define UPREF(r) ({ NODE *_t = (r); !(_t->flags & PERM) && _t->valref++;}) + +#define POP_ARRAY() ({ NODE *_t = POP(); \ + _t->type == Node_var_array ? \ + _t : get_array(_t, TRUE); }) + +#define POP_PARAM() ({ NODE *_t = POP(); \ + _t->type == Node_var_array ? \ + _t : get_array(_t, FALSE); }) + +#define POP_NUMBER(x) ({ NODE *_t = POP_SCALAR(); \ + x = force_number(_t); DEREF(_t); }) +#define TOP_NUMBER(x) ({ NODE *_t = TOP_SCALAR(); \ + x = force_number(_t); DEREF(_t); }) + +#define POP_SCALAR() ({ NODE *_t = POP(); _t->type != Node_var_array ? _t \ + : (fatal(_("attempt to use array `%s' in a scalar context"), array_vname(_t)), _t);}) +#define TOP_SCALAR() ({ NODE *_t = TOP(); _t->type != Node_var_array ? _t \ + : (fatal(_("attempt to use array `%s' in a scalar context"), array_vname(_t)), _t);}) + +#else /* not __GNUC__ */ + +#define UPREF(r) (_t = (r), !(_t->flags & PERM) && _t->valref++) + +#define POP_ARRAY() (_t = POP(), \ + _t->type == Node_var_array ? \ + _t : get_array(_t, TRUE)) + +#define POP_PARAM() (_t = POP(), \ + _t->type == Node_var_array ? \ + _t : get_array(_t, FALSE)) + +#define POP_NUMBER(x) (_t = POP_SCALAR(), \ + x = force_number(_t), DEREF(_t)) +#define TOP_NUMBER(x) (_t = TOP_SCALAR(), \ + x = force_number(_t), DEREF(_t)) + +#define POP_SCALAR() (_t = POP(), _t->type != Node_var_array ? _t \ + : (fatal(_("attempt to use array `%s' in a scalar context"), array_vname(_t)), _t)) +#define TOP_SCALAR() (_t = TOP(), _t->type != Node_var_array ? _t \ + : (fatal(_("attempt to use array `%s' in a scalar context"), array_vname(_t)), _t)) + +#endif /* __GNUC__ */ + + +#define POP_STRING() force_string(POP_SCALAR()) +#define TOP_STRING() force_string(TOP_SCALAR()) + +/* ------------------------- Pseudo-functions ------------------------- */ + +#define is_identchar(c) (isalnum(c) || (c) == '_') + +#define var_uninitialized(n) ((n)->var_value == Nnull_string) + +#define get_lhs(n, r) (n)->type == Node_var && ! var_uninitialized(n) ? \ + &((n)->var_value) : r_get_lhs((n), (r)) + +#ifdef MPROF +#define getnode(n) emalloc((n), NODE *, sizeof(NODE), "getnode"), \ + (n)->flags = 0 +#define freenode(n) efree(n) +#else /* not MPROF */ +#define getnode(n) (void) (nextfree ? \ + (n = nextfree, nextfree = nextfree->nextp) \ + : (n = more_nodes())) +#define freenode(n) ((n)->flags = 0, (n)->nextp = nextfree, nextfree = (n)) +#endif /* not MPROF */ + +#define make_number(x) mk_number((x), (unsigned int)(MALLOC|NUMCUR|NUMBER)) + +#define make_string(s, l) r_make_str_node((s), (size_t) (l), 0) +#define make_str_node(s, l, f) r_make_str_node((s), (size_t) (l), (f)) + +#define SCAN 1 +#define ALREADY_MALLOCED 2 + +#define cant_happen() r_fatal("internal error line %d, file: %s", \ + __LINE__, __FILE__) + +#define emalloc(var,ty,x,str) (void)((var=(ty)malloc((MALLOC_ARG_T)(x))) ||\ + (fatal(_("%s: %s: can't allocate %ld bytes of memory (%s)"),\ + (str), #var, (long) (x), strerror(errno)),0)) +#define erealloc(var,ty,x,str) (void)((var = (ty)realloc((char *)var, (MALLOC_ARG_T)(x))) \ + ||\ + (fatal(_("%s: %s: can't allocate %ld bytes of memory (%s)"),\ + (str), #var, (long) (x), strerror(errno)),0)) + +#define efree(p) free(p) + +#ifdef GAWKDEBUG +#define force_number r_force_number +#define force_string r_force_string +#else /* not GAWKDEBUG */ +#if __GNUC__ >= 2 +#define force_number(n) __extension__ ({NODE *_tn = (n);\ + (_tn->flags & NUMCUR) ? _tn->numbr : r_force_number(_tn);}) + +#define force_string(s) __extension__ ({NODE *_ts = (s);\ + ((_ts->flags & STRCUR) && \ + (_ts->stfmt == -1 || _ts->stfmt == CONVFMTidx)) ?\ + _ts : format_val(CONVFMT, CONVFMTidx, _ts);}) +#else /* not __GNUC__ */ +#define force_number r_force_number +#define force_string r_force_string +#endif /* __GNUC__ */ +#endif /* GAWKDEBUG */ + +#define fatal set_loc(__FILE__, __LINE__), r_fatal + +extern jmp_buf fatal_tag; +extern int fatal_tag_valid; + +#define PUSH_BINDING(stack, tag, val) \ +if (val++) \ + memcpy((char *) (stack), (const char *) tag, sizeof(jmp_buf)) +#define POP_BINDING(stack, tag, val) \ +if (--val) \ + memcpy((char *) tag, (const char *) (stack), sizeof(jmp_buf)) + +/* ------------- Function prototypes or defs (as appropriate) ------------- */ +typedef int (*Func_print)(FILE *, const char *, ...); + +/* array.c */ +typedef enum sort_context { SORTED_IN = 1, ASORT, ASORTI } SORT_CTXT; +extern NODE **assoc_list(NODE *array, const char *sort_str, SORT_CTXT sort_ctxt); +extern NODE *get_array(NODE *symbol, int canfatal); +extern char *array_vname(const NODE *symbol); +extern void array_init(void); +extern void set_SUBSEP(void); +extern NODE *concat_exp(int nargs, int do_subsep); +extern void ahash_unref(NODE *tmp); +extern void assoc_clear(NODE *symbol); +extern NODE *in_array(NODE *symbol, NODE *subs); +extern NODE **assoc_lookup(NODE *symbol, NODE *subs, int reference); +extern void do_delete(NODE *symbol, int nsubs); +extern void do_delete_loop(NODE *symbol, NODE **lhs); +extern NODE *assoc_dump(NODE *symbol, int indent_level); +extern NODE *do_adump(int nargs); +extern NODE *do_asort(int nargs); +extern NODE *do_asorti(int nargs); +extern unsigned long (*hash)(const char *s, size_t len, unsigned long hsize, size_t *code); +/* awkgram.c */ +extern NODE *mk_symbol(NODETYPE type, NODE *value); +extern NODE *install_symbol(char *name, NODE *value); +extern NODE *remove_symbol(char *name); +extern NODE *lookup(const char *name); +extern NODE *variable(char *name, NODETYPE type); +extern int parse_program(INSTRUCTION **pcode); +extern void dump_funcs(void); +extern void dump_vars(const char *fname); +extern void release_all_vars(void); +extern const char *getfname(NODE *(*)(int)); +extern NODE *stopme(int nargs); +extern void shadow_funcs(void); +extern int check_special(const char *name); +extern int foreach_func(int (*)(INSTRUCTION *, void *), int, void *); +extern INSTRUCTION *bcalloc(OPCODE op, int size, int srcline); +extern void bcfree(INSTRUCTION *); +extern SRCFILE *add_srcfile(int stype, char *src, SRCFILE *curr, int *already_included, int *errcode); +extern void register_deferred_variable(const char *name, NODE *(*load_func)(void)); +extern int files_are_same(char *path, SRCFILE *src); +extern void valinfo(NODE *n, Func_print print_func, FILE *fp); +extern void print_vars(Func_print print_func, FILE *fp); +extern AWK_CONTEXT *new_context(void); +extern void push_context(AWK_CONTEXT *ctxt); +extern void pop_context(); +extern int in_main_context(); +extern void free_context(AWK_CONTEXT *ctxt, int ); +extern void append_symbol(char *name); + +/* builtin.c */ +extern double double_to_int(double d); +extern NODE *do_exp(int nargs); +extern NODE *do_fflush(int nargs); +extern NODE *do_index(int nargs); +extern NODE *do_int(int nargs); +extern NODE *do_isarray(int nargs); +extern NODE *do_length(int nargs); +extern NODE *do_log(int nargs); +extern NODE *do_mktime(int nargs); +extern NODE *do_sprintf(int nargs); +extern void do_printf(int nargs, int redirtype); +extern void print_simple(NODE *tree, FILE *fp); +extern NODE *do_sqrt(int nargs); +extern NODE *do_substr(int nargs); +extern NODE *do_strftime(int nargs); +extern NODE *do_systime(int nargs); +extern NODE *do_system(int nargs); +extern void do_print(int nargs, int redirtype); +extern void do_print_rec(int args, int redirtype); +extern NODE *do_tolower(int nargs); +extern NODE *do_toupper(int nargs); +extern NODE *do_atan2(int nargs); +extern NODE *do_sin(int nargs); +extern NODE *do_cos(int nargs); +extern NODE *do_rand(int nargs); +extern NODE *do_srand(int nargs); +extern NODE *do_match(int nargs); +extern NODE *do_sub(int nargs, unsigned int flags); +extern NODE *format_tree(const char *, size_t, NODE **, long); +extern NODE *do_lshift(int nargs); +extern NODE *do_rshift(int nargs); +extern NODE *do_and(int nargs); +extern NODE *do_or(int nargs); +extern NODE *do_xor(int nargs); +extern NODE *do_compl(int nargs); +extern NODE *do_strtonum(int nargs); +extern AWKNUM nondec2awknum(char *str, size_t len); +extern NODE *do_dcgettext(int nargs); +extern NODE *do_dcngettext(int nargs); +extern NODE *do_bindtextdomain(int nargs); +#if MBS_SUPPORT +extern int strncasecmpmbs(const unsigned char *, + const unsigned char *, size_t); +#endif +/* eval.c */ +extern void PUSH_CODE(INSTRUCTION *cp); +extern INSTRUCTION *POP_CODE(void); +extern int interpret(INSTRUCTION *); +extern int cmp_nodes(NODE *, NODE *); +extern void set_IGNORECASE(void); +extern void set_OFS(void); +extern void set_ORS(void); +extern void set_OFMT(void); +extern void set_CONVFMT(void); +extern void set_BINMODE(void); +extern void set_LINT(void); +extern void set_TEXTDOMAIN(void); +extern void update_ERRNO(void); +extern void update_ERRNO_saved(int); +extern void update_NR(void); +extern void update_NF(void); +extern void update_FNR(void); +extern const char *redflags2str(int); +extern const char *flags2str(int); +extern const char *genflags2str(int flagval, const struct flagtab *tab); +extern const char *nodetype2str(NODETYPE type); +extern void load_casetable(void); + +extern AWKNUM calc_exp(AWKNUM x1, AWKNUM x2); +extern const char *opcode2str(OPCODE type); +extern const char *op2str(OPCODE type); +extern NODE **r_get_lhs(NODE *n, int reference); +extern STACK_ITEM *grow_stack(void); +#ifdef PROFILING +extern void dump_fcall_stack(FILE *fp); +#endif +/* ext.c */ +NODE *do_ext(int nargs); +#ifdef DYNAMIC +void make_builtin(const char *, NODE *(*)(int), int); +size_t get_curfunc_arg_count(void); +NODE *get_argument(int); +NODE *get_actual_argument(int, int, int); +#define get_scalar_argument(i, opt) get_actual_argument((i), (opt), FALSE) +#define get_array_argument(i, opt) get_actual_argument((i), (opt), TRUE) +#endif +/* field.c */ +extern void init_fields(void); +extern void set_record(const char *buf, int cnt); +extern void reset_record(void); +extern void set_NF(void); +extern NODE **get_field(long num, Func_ptr *assign); +extern NODE *do_split(int nargs); +extern NODE *do_patsplit(int nargs); +extern void set_FS(void); +extern void set_RS(void); +extern void set_FIELDWIDTHS(void); +extern void set_FPAT(void); +extern void update_PROCINFO_str(const char *subscript, const char *str); +extern void update_PROCINFO_num(const char *subscript, AWKNUM val); + +typedef enum { + Using_FS, + Using_FIELDWIDTHS, + Using_FPAT +} field_sep_type; +extern field_sep_type current_field_sep(void); + +/* gawkmisc.c */ +extern char *gawk_name(const char *filespec); +extern void os_arg_fixup(int *argcp, char ***argvp); +extern int os_devopen(const char *name, int flag); +extern void os_close_on_exec(int fd, const char *name, const char *what, const char *dir); +extern int os_isatty(int fd); +extern int os_isdir(int fd); +extern int os_is_setuid(void); +extern int os_setbinmode(int fd, int mode); +extern void os_restore_mode(int fd); +extern size_t optimal_bufsize(int fd, struct stat *sbuf); +extern int ispath(const char *file); +extern int isdirpunct(int c); + +/* io.c */ +extern void register_open_hook(void *(*open_func)(IOBUF *)); +extern void set_FNR(void); +extern void set_NR(void); + +extern struct redirect *redirect(NODE *redir_exp, int redirtype, int *errflg); +extern NODE *do_close(int nargs); +extern int flush_io(void); +extern int close_io(int *stdio_problem); +extern int devopen(const char *name, const char *mode); +extern int srcopen(SRCFILE *s); +extern char *find_source(const char *src, struct stat *stb, int *errcode); +extern NODE *do_getline_redir(int intovar, int redirtype); +extern NODE *do_getline(int intovar, IOBUF *iop); +extern struct redirect *getredirect(const char *str, int len); +extern int inrec(IOBUF *iop, int *errcode); +extern int nextfile(IOBUF **curfile, int skipping); +/* main.c */ +extern int arg_assign(char *arg, int initing); +extern int is_std_var(const char *var); +extern char *estrdup(const char *str, size_t len); +extern void update_global_values(); +/* msg.c */ +extern void gawk_exit(int status); +extern void err(const char *s, const char *emsg, va_list argp) ATTRIBUTE_PRINTF(2, 0); +extern void msg (const char *mesg, ...) ATTRIBUTE_PRINTF_1; +extern void error (const char *mesg, ...) ATTRIBUTE_PRINTF_1; +extern void warning (const char *mesg, ...) ATTRIBUTE_PRINTF_1; +extern void set_loc (const char *file, int line); +extern void r_fatal (const char *mesg, ...) ATTRIBUTE_PRINTF_1; +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2) +extern void (*lintfunc) (const char *mesg, ...) ATTRIBUTE_PRINTF_1; +#else +extern void (*lintfunc) (const char *mesg, ...); +#endif +/* profile.c */ +extern void init_profiling(int *flag, const char *def_file); +extern void init_profiling_signals(void); +extern void set_prof_file(const char *filename); +extern void dump_prog(INSTRUCTION *code); +extern char *pp_number(AWKNUM d); +extern char *pp_string(const char *in_str, size_t len, int delim); +extern char *pp_node(NODE *n); +extern int pp_func(INSTRUCTION *pc, void *); +extern void pp_string_fp(Func_print print_func, FILE *fp, const char *str, + size_t namelen, int delim, int breaklines); +/* node.c */ +extern AWKNUM r_force_number(NODE *n); +extern NODE *format_val(const char *format, int index, NODE *s); +extern NODE *r_force_string(NODE *s); +extern NODE *dupnode(NODE *n); +extern NODE *mk_number(AWKNUM x, unsigned int flags); +extern NODE *r_make_str_node(const char *s, unsigned long len, int scan); +extern NODE *more_nodes(void); +extern void unref(NODE *tmp); +extern int parse_escape(const char **string_ptr); +#if MBS_SUPPORT +extern NODE *str2wstr(NODE *n, size_t **ptr); +extern NODE *wstr2str(NODE *n); +#define force_wstring(n) str2wstr(n, NULL) +extern const wchar_t *wstrstr(const wchar_t *haystack, size_t hs_len, + const wchar_t *needle, size_t needle_len); +extern const wchar_t *wcasestrstr(const wchar_t *haystack, size_t hs_len, + const wchar_t *needle, size_t needle_len); +extern void free_wstr(NODE *n); +extern wint_t btowc_cache[]; +#define btowc_cache(x) btowc_cache[(x)&0xFF] +extern void init_btowc_cache(); +#define is_valid_character(b) (btowc_cache[(b)&0xFF] != WEOF) +#else +#define free_wstr(NODE) /* empty */ +#endif +/* re.c */ +extern Regexp *make_regexp(const char *s, size_t len, int ignorecase, int dfa, int canfatal); +extern int research(Regexp *rp, char *str, int start, size_t len, int flags); +extern void refree(Regexp *rp); +extern void reg_error(const char *s); +extern Regexp *re_update(NODE *t); +extern void resyntax(int syntax); +extern void resetup(void); +extern int avoid_dfa(NODE *re, char *str, size_t len); +extern int reisstring(const char *text, size_t len, Regexp *re, const char *buf); +extern int remaybelong(const char *text, size_t len); +extern int isnondecimal(const char *str, int use_locale); + +/* floatcomp.c */ +#ifdef VMS /* VMS linker weirdness? */ +#define Ceil gawk_ceil +#define Floor gawk_floor +#endif + +extern AWKNUM Floor(AWKNUM n); +extern AWKNUM Ceil(AWKNUM n); +#ifdef HAVE_UINTMAX_T +extern uintmax_t adjust_uint(uintmax_t n); +#else +#define adjust_uint(n) (n) +#endif + +#define INVALID_HANDLE (-1) + +#ifdef HAVE_SYS_WAIT_H +#include +#endif +#ifndef WEXITSTATUS +#if defined(VMS) +#define WEXITSTATUS(stat_val) (stat_val) +#else /* ! defined(VMS) */ +#define WEXITSTATUS(stat_val) ((((unsigned) (stat_val)) >> 8) & 0xFF) +#endif /* ! defined(VMS)) */ +#endif /* WEXITSTATUS */ + +/* EXIT_SUCCESS and EXIT_FAILURE normally come from */ +#ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +#endif +#ifndef EXIT_FAILURE +# define EXIT_FAILURE 1 +#endif +/* EXIT_FATAL is specific to gawk, not part of Standard C */ +#ifndef EXIT_FATAL +# define EXIT_FATAL 2 +#endif + +/* For z/OS, from Dave Pitts. EXIT_FAILURE is normally 8, make it 1. */ +#ifdef ZOS_USS +#undef DYNAMIC + +#ifdef EXIT_FAILURE +#undef EXIT_FAILURE +#endif + +#define EXIT_FAILURE 1 +#endif diff --git a/awkgram.c b/awkgram.c new file mode 100644 index 0000000..0b43918 --- /dev/null +++ b/awkgram.c @@ -0,0 +1,8730 @@ +/* A Bison parser, made by GNU Bison 2.5. */ + +/* Bison implementation for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.5" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + + + +/* Copy the first part of user declarations. */ + +/* Line 268 of yacc.c */ +#line 26 "awkgram.y" + +#ifdef GAWKDEBUG +#define YYDEBUG 12 +#endif + +#include "awk.h" + +#if defined(__STDC__) && __STDC__ < 1 /* VMS weirdness, maybe elsewhere */ +#define signed /**/ +#endif + +static void yyerror(const char *m, ...) ATTRIBUTE_PRINTF_1; +static void error_ln(int line, const char *m, ...) ATTRIBUTE_PRINTF_2; +static void lintwarn_ln(int line, const char *m, ...) ATTRIBUTE_PRINTF_2; +static void warning_ln(int line, const char *m, ...) ATTRIBUTE_PRINTF_2; +static char *get_src_buf(void); +static int yylex(void); +int yyparse(void); +static INSTRUCTION *snode(INSTRUCTION *subn, INSTRUCTION *op); +static int func_install(INSTRUCTION *fp, INSTRUCTION *def); +static void pop_params(NODE *params); +static NODE *make_param(char *pname); +static NODE *mk_rexp(INSTRUCTION *exp); +static void append_param(char *pname); +static int dup_parms(INSTRUCTION *fp, NODE *func); +static void param_sanity(INSTRUCTION *arglist); +static int parms_shadow(INSTRUCTION *pc, int *shadow); +static int isnoeffect(OPCODE type); +static INSTRUCTION *make_assignable(INSTRUCTION *ip); +static void dumpintlstr(const char *str, size_t len); +static void dumpintlstr2(const char *str1, size_t len1, const char *str2, size_t len2); +static int isarray(NODE *n); +static int include_source(INSTRUCTION *file); +static void next_sourcefile(void); +static char *tokexpand(void); + +#define instruction(t) bcalloc(t, 1, 0) + +static INSTRUCTION *mk_program(void); +static INSTRUCTION *append_rule(INSTRUCTION *pattern, INSTRUCTION *action); +static INSTRUCTION *mk_condition(INSTRUCTION *cond, INSTRUCTION *ifp, INSTRUCTION *true_branch, + INSTRUCTION *elsep, INSTRUCTION *false_branch); +static INSTRUCTION *mk_expression_list(INSTRUCTION *list, INSTRUCTION *s1); +static INSTRUCTION *mk_for_loop(INSTRUCTION *forp, INSTRUCTION *init, INSTRUCTION *cond, + INSTRUCTION *incr, INSTRUCTION *body); +static void fix_break_continue(INSTRUCTION *list, INSTRUCTION *b_target, INSTRUCTION *c_target); +static INSTRUCTION *mk_binary(INSTRUCTION *s1, INSTRUCTION *s2, INSTRUCTION *op); +static INSTRUCTION *mk_boolean(INSTRUCTION *left, INSTRUCTION *right, INSTRUCTION *op); +static INSTRUCTION *mk_assignment(INSTRUCTION *lhs, INSTRUCTION *rhs, INSTRUCTION *op); +static INSTRUCTION *mk_getline(INSTRUCTION *op, INSTRUCTION *opt_var, INSTRUCTION *redir, int redirtype); +static NODE *make_regnode(int type, NODE *exp); +static int count_expressions(INSTRUCTION **list, int isarg); +static INSTRUCTION *optimize_assignment(INSTRUCTION *exp); +static void add_lint(INSTRUCTION *list, LINTTYPE linttype); + +enum defref { FUNC_DEFINE, FUNC_USE }; +static void func_use(const char *name, enum defref how); +static void check_funcs(void); +static void free_bcpool(INSTRUCTION *pl); + +static ssize_t read_one_line(int fd, void *buffer, size_t count); +static int one_line_close(int fd); + +static void (*install_func)(char *) = NULL; + +static int want_source = FALSE; +static int want_regexp; /* lexical scanning kludge */ +static int can_return; /* parsing kludge */ +static int rule = 0; + +const char *const ruletab[] = { + "?", + "BEGIN", + "Rule", + "END", + "BEGINFILE", + "ENDFILE", +}; + +static int in_print = FALSE; /* lexical scanning kludge for print */ +static int in_parens = 0; /* lexical scanning kludge for print */ +static int sub_counter = 0; /* array dimension counter for use in delete */ +static char *lexptr = NULL; /* pointer to next char during parsing */ +static char *lexend; +static char *lexptr_begin; /* keep track of where we were for error msgs */ +static char *lexeme; /* beginning of lexeme for debugging */ +static int lexeof; /* seen EOF for current source? */ +static char *thisline = NULL; +static int in_braces = 0; /* count braces for firstline, lastline in an 'action' */ +static int lastline = 0; +static int firstline = 0; +static SRCFILE *sourcefile = NULL; /* current program source */ +static int lasttok = 0; +static int eof_warned = FALSE; /* GLOBAL: want warning for each file */ +static int break_allowed; /* kludge for break */ +static int continue_allowed; /* kludge for continue */ + + +#define END_FILE -1000 +#define END_SRC -2000 + +#define YYDEBUG_LEXER_TEXT (lexeme) +static int param_counter; +static NODE *func_params; /* list of parameters for the current function */ +static char *tokstart = NULL; +static char *tok = NULL; +static char *tokend; +static int errcount = 0; + +static NODE *symbol_list; +extern void destroy_symbol(char *name); + +static long func_count; /* total number of functions */ + +#define HASHSIZE 1021 /* this constant only used here */ +NODE *variables[HASHSIZE]; +static int var_count; /* total number of global variables */ + +extern char *source; +extern int sourceline; +extern SRCFILE *srcfiles; +extern INSTRUCTION *rule_list; +extern int max_args; + +static INSTRUCTION *rule_block[sizeof(ruletab)]; + +static INSTRUCTION *ip_rec; +static INSTRUCTION *ip_newfile; +static INSTRUCTION *ip_atexit = NULL; +static INSTRUCTION *ip_end; +static INSTRUCTION *ip_endfile; +static INSTRUCTION *ip_beginfile; + +static inline INSTRUCTION *list_create(INSTRUCTION *x); +static inline INSTRUCTION *list_append(INSTRUCTION *l, INSTRUCTION *x); +static inline INSTRUCTION *list_prepend(INSTRUCTION *l, INSTRUCTION *x); +static inline INSTRUCTION *list_merge(INSTRUCTION *l1, INSTRUCTION *l2); + +extern double fmod(double x, double y); +/* + * This string cannot occur as a real awk identifier. + * Use it as a special token to make function parsing + * uniform, but if it's seen, don't install the function. + * e.g. + * function split(x) { return x } + * function x(a) { return a } + * should only produce one error message, and not core dump. + */ +static char builtin_func[] = "@builtin"; + +#define YYSTYPE INSTRUCTION * + + +/* Line 268 of yacc.c */ +#line 225 "awkgram.c" + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + FUNC_CALL = 258, + NAME = 259, + REGEXP = 260, + FILENAME = 261, + YNUMBER = 262, + YSTRING = 263, + RELOP = 264, + IO_OUT = 265, + IO_IN = 266, + ASSIGNOP = 267, + ASSIGN = 268, + MATCHOP = 269, + CONCAT_OP = 270, + SUBSCRIPT = 271, + LEX_BEGIN = 272, + LEX_END = 273, + LEX_IF = 274, + LEX_ELSE = 275, + LEX_RETURN = 276, + LEX_DELETE = 277, + LEX_SWITCH = 278, + LEX_CASE = 279, + LEX_DEFAULT = 280, + LEX_WHILE = 281, + LEX_DO = 282, + LEX_FOR = 283, + LEX_BREAK = 284, + LEX_CONTINUE = 285, + LEX_PRINT = 286, + LEX_PRINTF = 287, + LEX_NEXT = 288, + LEX_EXIT = 289, + LEX_FUNCTION = 290, + LEX_BEGINFILE = 291, + LEX_ENDFILE = 292, + LEX_GETLINE = 293, + LEX_NEXTFILE = 294, + LEX_IN = 295, + LEX_AND = 296, + LEX_OR = 297, + INCREMENT = 298, + DECREMENT = 299, + LEX_BUILTIN = 300, + LEX_LENGTH = 301, + LEX_EOF = 302, + LEX_INCLUDE = 303, + LEX_EVAL = 304, + NEWLINE = 305, + SLASH_BEFORE_EQUAL = 306, + UNARY = 307 + }; +#endif +/* Tokens. */ +#define FUNC_CALL 258 +#define NAME 259 +#define REGEXP 260 +#define FILENAME 261 +#define YNUMBER 262 +#define YSTRING 263 +#define RELOP 264 +#define IO_OUT 265 +#define IO_IN 266 +#define ASSIGNOP 267 +#define ASSIGN 268 +#define MATCHOP 269 +#define CONCAT_OP 270 +#define SUBSCRIPT 271 +#define LEX_BEGIN 272 +#define LEX_END 273 +#define LEX_IF 274 +#define LEX_ELSE 275 +#define LEX_RETURN 276 +#define LEX_DELETE 277 +#define LEX_SWITCH 278 +#define LEX_CASE 279 +#define LEX_DEFAULT 280 +#define LEX_WHILE 281 +#define LEX_DO 282 +#define LEX_FOR 283 +#define LEX_BREAK 284 +#define LEX_CONTINUE 285 +#define LEX_PRINT 286 +#define LEX_PRINTF 287 +#define LEX_NEXT 288 +#define LEX_EXIT 289 +#define LEX_FUNCTION 290 +#define LEX_BEGINFILE 291 +#define LEX_ENDFILE 292 +#define LEX_GETLINE 293 +#define LEX_NEXTFILE 294 +#define LEX_IN 295 +#define LEX_AND 296 +#define LEX_OR 297 +#define INCREMENT 298 +#define DECREMENT 299 +#define LEX_BUILTIN 300 +#define LEX_LENGTH 301 +#define LEX_EOF 302 +#define LEX_INCLUDE 303 +#define LEX_EVAL 304 +#define NEWLINE 305 +#define SLASH_BEFORE_EQUAL 306 +#define UNARY 307 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + + +/* Copy the second part of user declarations. */ + + +/* Line 343 of yacc.c */ +#line 371 "awkgram.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static int +YYID (int yyi) +#else +static int +YYID (yyi) + int yyi; +#endif +{ + return yyi; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow && (! defined __cplusplus || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +# define YYCOPY_NEEDED 1 + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 2 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 1157 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 74 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 65 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 185 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 330 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 307 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 62, 2, 2, 65, 61, 2, 2, + 66, 67, 59, 57, 54, 58, 2, 60, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 53, 73, + 55, 2, 56, 52, 68, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 69, 2, 70, 64, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 71, 2, 72, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48, 49, 50, 51, 63 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 4, 7, 10, 13, 16, 19, 22, + 25, 30, 32, 35, 37, 38, 40, 45, 47, 49, + 51, 53, 59, 61, 63, 65, 68, 70, 72, 73, + 81, 82, 86, 88, 90, 91, 94, 97, 99, 102, + 105, 109, 111, 121, 128, 137, 146, 159, 171, 173, + 176, 179, 182, 185, 189, 190, 195, 198, 199, 204, + 205, 210, 215, 217, 218, 220, 221, 224, 227, 233, + 238, 240, 243, 246, 248, 250, 252, 254, 256, 260, + 261, 262, 266, 273, 283, 285, 288, 289, 291, 292, + 295, 296, 298, 300, 304, 306, 309, 313, 314, 316, + 317, 319, 321, 325, 327, 330, 334, 338, 342, 346, + 350, 354, 358, 362, 368, 370, 372, 374, 377, 379, + 381, 383, 385, 387, 389, 392, 394, 398, 402, 406, + 410, 414, 418, 422, 425, 428, 434, 439, 443, 447, + 451, 455, 459, 463, 465, 468, 472, 477, 482, 484, + 486, 488, 491, 494, 496, 498, 501, 504, 506, 509, + 514, 515, 517, 518, 521, 523, 526, 528, 532, 534, + 537, 540, 542, 545, 547, 551, 553, 555, 556, 559, + 562, 564, 565, 567, 569, 571 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int16 yyrhs[] = +{ + 75, 0, -1, -1, 75, 76, -1, 75, 104, -1, + 75, 47, -1, 75, 1, -1, 78, 79, -1, 78, + 88, -1, 82, 79, -1, 68, 48, 77, 88, -1, + 6, -1, 6, 1, -1, 1, -1, -1, 112, -1, + 112, 54, 105, 112, -1, 17, -1, 18, -1, 36, + -1, 37, -1, 132, 87, 133, 135, 105, -1, 4, + -1, 3, -1, 81, -1, 68, 49, -1, 45, -1, + 46, -1, -1, 35, 83, 80, 66, 107, 134, 105, + -1, -1, 86, 85, 5, -1, 60, -1, 51, -1, + -1, 87, 89, -1, 87, 1, -1, 104, -1, 136, + 105, -1, 136, 105, -1, 132, 87, 133, -1, 103, + -1, 23, 66, 112, 134, 105, 132, 96, 105, 133, + -1, 26, 66, 112, 134, 105, 89, -1, 27, 105, + 89, 26, 66, 112, 134, 105, -1, 28, 66, 4, + 40, 129, 134, 105, 89, -1, 28, 66, 95, 136, + 105, 112, 136, 105, 95, 134, 105, 89, -1, 28, + 66, 95, 136, 105, 136, 105, 95, 134, 105, 89, + -1, 90, -1, 29, 88, -1, 30, 88, -1, 33, + 88, -1, 39, 88, -1, 34, 109, 88, -1, -1, + 21, 91, 109, 88, -1, 92, 88, -1, -1, 99, + 93, 100, 101, -1, -1, 22, 4, 94, 123, -1, + 22, 66, 4, 67, -1, 112, -1, -1, 92, -1, + -1, 96, 97, -1, 96, 1, -1, 24, 98, 137, + 105, 87, -1, 25, 137, 105, 87, -1, 7, -1, + 58, 7, -1, 57, 7, -1, 8, -1, 84, -1, + 31, -1, 32, -1, 110, -1, 66, 111, 134, -1, + -1, -1, 10, 102, 116, -1, 19, 66, 112, 134, + 105, 89, -1, 19, 66, 112, 134, 105, 89, 20, + 105, 89, -1, 50, -1, 104, 50, -1, -1, 104, + -1, -1, 55, 117, -1, -1, 108, -1, 4, -1, + 108, 138, 4, -1, 1, -1, 108, 1, -1, 108, + 138, 1, -1, -1, 112, -1, -1, 111, -1, 112, + -1, 111, 138, 112, -1, 1, -1, 111, 1, -1, + 111, 1, 112, -1, 111, 138, 1, -1, 130, 113, + 112, -1, 112, 41, 112, -1, 112, 42, 112, -1, + 112, 14, 112, -1, 112, 40, 129, -1, 112, 115, + 112, -1, 112, 52, 112, 53, 112, -1, 116, -1, + 13, -1, 12, -1, 51, 13, -1, 9, -1, 55, + -1, 114, -1, 56, -1, 117, -1, 118, -1, 116, + 117, -1, 119, -1, 117, 64, 117, -1, 117, 59, + 117, -1, 117, 60, 117, -1, 117, 61, 117, -1, + 117, 57, 117, -1, 117, 58, 117, -1, 38, 122, + 106, -1, 130, 43, -1, 130, 44, -1, 66, 111, + 134, 40, 129, -1, 116, 11, 38, 122, -1, 118, + 64, 117, -1, 118, 59, 117, -1, 118, 60, 117, + -1, 118, 61, 117, -1, 118, 57, 117, -1, 118, + 58, 117, -1, 84, -1, 62, 117, -1, 66, 112, + 134, -1, 45, 66, 110, 134, -1, 46, 66, 110, + 134, -1, 46, -1, 120, -1, 130, -1, 43, 130, + -1, 44, 130, -1, 7, -1, 8, -1, 58, 117, + -1, 57, 117, -1, 121, -1, 68, 121, -1, 3, + 66, 110, 134, -1, -1, 130, -1, -1, 124, 16, + -1, 125, -1, 124, 125, -1, 126, -1, 69, 111, + 70, -1, 126, -1, 127, 126, -1, 127, 16, -1, + 4, -1, 4, 128, -1, 129, -1, 65, 119, 131, + -1, 43, -1, 44, -1, -1, 71, 105, -1, 72, + 105, -1, 67, -1, -1, 136, -1, 73, -1, 53, + -1, 54, 105, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 218, 218, 220, 225, 226, 230, 242, 246, 257, + 265, 273, 281, 283, 289, 290, 292, 318, 329, 340, + 346, 355, 365, 367, 369, 380, 385, 386, 391, 390, + 420, 419, 452, 454, 459, 460, 473, 478, 479, 483, + 485, 487, 494, 584, 626, 668, 781, 788, 795, 805, + 814, 823, 832, 847, 863, 862, 874, 886, 886, 982, + 982, 1007, 1030, 1036, 1037, 1043, 1044, 1051, 1056, 1068, + 1082, 1084, 1090, 1095, 1097, 1105, 1107, 1116, 1117, 1125, + 1130, 1130, 1141, 1145, 1153, 1154, 1157, 1159, 1164, 1165, + 1172, 1174, 1178, 1184, 1191, 1193, 1195, 1202, 1203, 1209, + 1210, 1215, 1217, 1222, 1224, 1226, 1228, 1234, 1241, 1243, + 1245, 1261, 1271, 1278, 1280, 1285, 1287, 1289, 1297, 1299, + 1304, 1306, 1311, 1313, 1315, 1368, 1370, 1372, 1374, 1376, + 1378, 1380, 1382, 1405, 1410, 1415, 1440, 1446, 1448, 1450, + 1452, 1454, 1456, 1461, 1465, 1496, 1498, 1504, 1510, 1523, + 1524, 1525, 1530, 1535, 1539, 1543, 1555, 1568, 1573, 1609, + 1627, 1628, 1634, 1635, 1640, 1642, 1649, 1666, 1683, 1685, + 1692, 1697, 1705, 1719, 1731, 1740, 1744, 1748, 1752, 1756, + 1760, 1763, 1765, 1769, 1773, 1777 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "FUNC_CALL", "NAME", "REGEXP", + "FILENAME", "YNUMBER", "YSTRING", "RELOP", "IO_OUT", "IO_IN", "ASSIGNOP", + "ASSIGN", "MATCHOP", "CONCAT_OP", "SUBSCRIPT", "LEX_BEGIN", "LEX_END", + "LEX_IF", "LEX_ELSE", "LEX_RETURN", "LEX_DELETE", "LEX_SWITCH", + "LEX_CASE", "LEX_DEFAULT", "LEX_WHILE", "LEX_DO", "LEX_FOR", "LEX_BREAK", + "LEX_CONTINUE", "LEX_PRINT", "LEX_PRINTF", "LEX_NEXT", "LEX_EXIT", + "LEX_FUNCTION", "LEX_BEGINFILE", "LEX_ENDFILE", "LEX_GETLINE", + "LEX_NEXTFILE", "LEX_IN", "LEX_AND", "LEX_OR", "INCREMENT", "DECREMENT", + "LEX_BUILTIN", "LEX_LENGTH", "LEX_EOF", "LEX_INCLUDE", "LEX_EVAL", + "NEWLINE", "SLASH_BEFORE_EQUAL", "'?'", "':'", "','", "'<'", "'>'", + "'+'", "'-'", "'*'", "'/'", "'%'", "'!'", "UNARY", "'^'", "'$'", "'('", + "')'", "'@'", "'['", "']'", "'{'", "'}'", "';'", "$accept", "program", + "rule", "source", "pattern", "action", "func_name", "lex_builtin", + "function_prologue", "$@1", "regexp", "$@2", "a_slash", "statements", + "statement_term", "statement", "non_compound_stmt", "$@3", "simple_stmt", + "$@4", "$@5", "opt_simple_stmt", "case_statements", "case_statement", + "case_value", "print", "print_expression_list", "output_redir", "$@6", + "if_statement", "nls", "opt_nls", "input_redir", "opt_param_list", + "param_list", "opt_exp", "opt_expression_list", "expression_list", "exp", + "assign_operator", "relop_or_less", "a_relop", "common_exp", "simp_exp", + "simp_exp_nc", "non_post_simp_exp", "func_call", "direct_func_call", + "opt_variable", "delete_subscript_list", "delete_subscript", + "delete_exp_list", "bracketed_exp_list", "subscript", "subscript_list", + "simple_variable", "variable", "opt_incdec", "l_brace", "r_brace", + "r_paren", "opt_semi", "semi", "colon", "comma", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, + 305, 306, 63, 58, 44, 60, 62, 43, 45, 42, + 47, 37, 33, 307, 94, 36, 40, 41, 64, 91, + 93, 123, 125, 59 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 74, 75, 75, 75, 75, 75, 76, 76, 76, + 76, 77, 77, 77, 78, 78, 78, 78, 78, 78, + 78, 79, 80, 80, 80, 80, 81, 81, 83, 82, + 85, 84, 86, 86, 87, 87, 87, 88, 88, 89, + 89, 89, 89, 89, 89, 89, 89, 89, 89, 90, + 90, 90, 90, 90, 91, 90, 90, 93, 92, 94, + 92, 92, 92, 95, 95, 96, 96, 96, 97, 97, + 98, 98, 98, 98, 98, 99, 99, 100, 100, 101, + 102, 101, 103, 103, 104, 104, 105, 105, 106, 106, + 107, 107, 108, 108, 108, 108, 108, 109, 109, 110, + 110, 111, 111, 111, 111, 111, 111, 112, 112, 112, + 112, 112, 112, 112, 112, 113, 113, 113, 114, 114, + 115, 115, 116, 116, 116, 117, 117, 117, 117, 117, + 117, 117, 117, 117, 117, 117, 118, 118, 118, 118, + 118, 118, 118, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 119, 119, 119, 119, 120, 120, 121, + 122, 122, 123, 123, 124, 124, 125, 126, 127, 127, + 128, 129, 129, 130, 130, 131, 131, 131, 132, 133, + 134, 135, 135, 136, 137, 138 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 2, 2, 2, 2, 2, 2, 2, + 4, 1, 2, 1, 0, 1, 4, 1, 1, 1, + 1, 5, 1, 1, 1, 2, 1, 1, 0, 7, + 0, 3, 1, 1, 0, 2, 2, 1, 2, 2, + 3, 1, 9, 6, 8, 8, 12, 11, 1, 2, + 2, 2, 2, 3, 0, 4, 2, 0, 4, 0, + 4, 4, 1, 0, 1, 0, 2, 2, 5, 4, + 1, 2, 2, 1, 1, 1, 1, 1, 3, 0, + 0, 3, 6, 9, 1, 2, 0, 1, 0, 2, + 0, 1, 1, 3, 1, 2, 3, 0, 1, 0, + 1, 1, 3, 1, 2, 3, 3, 3, 3, 3, + 3, 3, 3, 5, 1, 1, 1, 2, 1, 1, + 1, 1, 1, 1, 2, 1, 3, 3, 3, 3, + 3, 3, 3, 2, 2, 5, 4, 3, 3, 3, + 3, 3, 3, 1, 2, 3, 4, 4, 1, 1, + 1, 2, 2, 1, 1, 2, 2, 1, 2, 4, + 0, 1, 0, 2, 1, 2, 1, 3, 1, 2, + 2, 1, 2, 1, 3, 1, 1, 0, 2, 2, + 1, 0, 1, 1, 1, 2 +}; + +/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 2, 0, 1, 6, 0, 171, 153, 154, 17, 18, + 28, 19, 20, 160, 0, 0, 0, 148, 5, 84, + 33, 0, 0, 32, 0, 0, 0, 0, 3, 0, + 0, 143, 30, 4, 15, 114, 122, 123, 125, 149, + 157, 173, 150, 0, 0, 168, 0, 172, 0, 88, + 161, 151, 152, 0, 0, 0, 156, 150, 155, 144, + 0, 177, 150, 103, 0, 101, 0, 158, 86, 183, + 7, 8, 37, 34, 86, 9, 0, 85, 118, 0, + 0, 0, 0, 0, 86, 119, 121, 120, 0, 0, + 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 116, 115, 133, 134, 0, 0, 0, + 0, 101, 0, 170, 169, 23, 22, 26, 27, 0, + 0, 24, 0, 132, 0, 0, 0, 175, 176, 174, + 104, 86, 180, 0, 0, 145, 13, 0, 0, 87, + 178, 0, 38, 31, 110, 111, 108, 109, 0, 0, + 112, 160, 130, 131, 127, 128, 129, 126, 141, 142, + 138, 139, 140, 137, 117, 107, 159, 167, 25, 0, + 89, 146, 147, 105, 185, 0, 106, 102, 12, 10, + 36, 0, 54, 0, 0, 0, 86, 0, 0, 0, + 75, 76, 0, 97, 0, 86, 35, 48, 0, 57, + 41, 62, 34, 181, 86, 0, 16, 136, 94, 92, + 0, 0, 135, 0, 97, 59, 0, 0, 0, 0, + 63, 49, 50, 51, 0, 98, 52, 179, 56, 0, + 0, 86, 182, 39, 113, 86, 95, 0, 0, 0, + 162, 0, 0, 0, 0, 171, 64, 0, 53, 0, + 79, 77, 40, 21, 29, 96, 93, 86, 55, 60, + 0, 164, 166, 61, 86, 86, 0, 0, 86, 0, + 80, 58, 0, 163, 165, 0, 0, 0, 0, 0, + 78, 0, 82, 65, 43, 0, 86, 0, 86, 81, + 86, 0, 86, 0, 86, 63, 0, 67, 0, 0, + 66, 0, 44, 45, 63, 0, 83, 70, 73, 0, + 0, 74, 0, 184, 86, 42, 0, 86, 72, 71, + 86, 34, 86, 0, 34, 0, 0, 47, 0, 46 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 1, 28, 138, 29, 70, 120, 121, 30, 48, + 31, 76, 32, 141, 71, 196, 197, 214, 198, 229, + 240, 247, 291, 300, 312, 199, 250, 271, 281, 200, + 139, 140, 123, 210, 211, 224, 109, 110, 201, 108, + 87, 88, 35, 36, 37, 38, 39, 40, 49, 259, + 260, 261, 45, 46, 47, 41, 42, 129, 202, 203, + 135, 231, 204, 314, 134 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -269 +static const yytype_int16 yypact[] = +{ + -269, 335, -269, -269, -31, -24, -269, -269, -269, -269, + -269, -269, -269, 12, 12, 12, -19, -12, -269, -269, + -269, 978, 978, -269, 978, 1023, 804, 21, -269, 115, + -21, -269, -269, 8, 1062, 952, -20, 330, -269, -269, + -269, -269, 246, 736, 804, -269, 2, -269, 205, 15, + -269, -269, -269, 736, 736, 70, 52, 80, 52, 52, + 978, 147, -269, -269, 50, 308, 174, -269, 64, -269, + -269, -269, 8, -269, 64, -269, 129, -269, -269, 978, + 143, 978, 978, 978, 64, -269, -269, -269, 978, 112, + -20, 978, 978, 978, 978, 978, 978, 978, 978, 978, + 978, 978, 978, -269, -269, -269, -269, 141, 978, 90, + 152, 1101, 48, -269, -269, -269, -269, -269, -269, 111, + 105, -269, 978, -269, 90, 90, 308, -269, -269, -269, + 978, 64, -269, 134, 830, -269, -269, 13, -16, 8, + -269, 552, -269, -269, 53, -269, 142, 300, 1081, 978, + 103, 12, 185, 185, 52, 52, 52, 52, 185, 185, + 52, 52, 52, 52, -269, 1101, -269, -269, -269, 63, + -20, -269, -269, 1101, -269, 143, -269, 1101, -269, -269, + -269, 121, -269, 6, 130, 137, 64, 139, -16, -16, + -269, -269, -16, 978, -16, 64, -269, -269, -16, -269, + -269, 1101, -269, 127, 64, 978, 1101, -269, -269, -269, + 90, 118, -269, 978, 978, -269, 180, 978, 978, 665, + 875, -269, -269, -269, -16, 1101, -269, -269, -269, 598, + 552, 64, -269, -269, 1101, 64, -269, 28, 308, -16, + -24, 140, 308, 308, 189, -14, -269, 127, -269, 804, + 201, -269, -269, -269, -269, -269, -269, 64, -269, -269, + 14, -269, -269, -269, 64, 64, 158, 143, 64, 50, + -269, -269, 665, -269, -269, -21, 665, 978, 90, 710, + 134, 978, 198, -269, -269, 308, 64, 1056, 64, 952, + 64, 60, 64, 665, 64, 907, 665, -269, 119, 177, + -269, 155, -269, -269, 907, 90, -269, -269, -269, 224, + 228, -269, 177, -269, 64, -269, 90, 64, -269, -269, + 64, -269, 64, 665, -269, 406, 665, -269, 479, -269 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -269, -269, -269, -269, -269, 208, -269, -269, -269, -269, + -58, -269, -269, -193, 72, -171, -269, -269, -189, -269, + -269, -268, -269, -269, -269, -269, -269, -269, -269, -269, + 45, 37, -269, -269, -269, 38, -48, -23, -1, -269, + -269, -269, -26, 44, -269, 217, -269, 1, 102, -269, + -269, -3, -39, -269, -269, -72, -2, -269, -28, -213, + -49, -269, -25, -47, 66 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -101 +static const yytype_int16 yytable[] = +{ + 34, 73, 73, 64, 74, 124, 125, 114, 145, 230, + 215, 50, 51, 52, 178, 133, 5, 252, 113, 57, + 57, 112, 57, 62, 4, 65, 267, 305, 67, 255, + 273, 246, 256, 57, 19, 43, 316, 91, 92, 93, + 94, 95, 111, 111, 96, 44, 33, 53, 244, 130, + 68, 130, 111, 111, 54, 44, 67, 69, 77, 126, + 166, 297, 78, -11, 208, 56, 58, 209, 59, 66, + 122, 44, 216, 4, 72, 171, 172, 25, 144, 90, + 146, 147, 148, 44, 298, 299, -11, 150, 315, 57, + 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, + 57, 282, 131, 212, 131, 284, 246, 165, 85, 86, + 19, 142, -101, 74, 19, 246, 96, 132, 167, 236, + 57, 149, 303, 105, 106, 306, 307, 308, 325, 173, + -90, 328, -86, 177, 143, 152, 153, 154, 155, 156, + 157, 158, 159, 160, 161, 162, 163, 5, 206, 50, + 151, 78, 327, 130, 164, 329, 79, 132, -101, -101, + 168, 235, -100, 74, 74, 19, 170, 74, 174, 74, + 20, 169, 131, 74, 175, 136, 309, 310, 232, 23, + 137, 251, 80, 72, 241, -91, 68, 213, 69, 257, + 127, 128, 225, 264, 265, 278, 217, 85, 86, 74, + 69, 262, -100, 218, 234, 220, 131, 263, 115, 116, + 179, 270, 238, 225, 74, 266, 242, 243, 290, -100, + 280, 262, 268, 219, 277, -100, 269, 195, 111, 286, + 313, 318, 227, 72, 72, 319, 292, 72, 75, 72, + 311, 233, 61, 72, 93, 94, 95, 283, 65, 96, + 117, 118, 239, 207, 288, 289, 317, 274, 103, 104, + 221, 222, 294, 0, 223, 320, 226, 322, 253, 72, + 228, 0, 254, 119, 0, 0, 285, 237, 287, 57, + 0, 0, 0, 0, 72, 0, 0, 57, 0, 105, + 106, 0, 0, 0, 272, 0, 248, 107, 0, 0, + 0, 275, 276, 0, 0, 279, 0, 0, 0, 78, + 0, 258, 0, 0, 79, 0, 0, 78, 0, 0, + 0, 0, 79, 293, 0, 295, 0, 296, 301, 302, + 0, 304, 0, 90, 0, 2, 3, 0, 4, 5, + 80, 81, 6, 7, 0, 0, 0, 0, 80, 81, + 82, 321, 8, 9, 323, 85, 86, 324, 0, 326, + 83, 0, 0, 85, 86, 0, 0, 0, 0, 0, + 10, 11, 12, 13, 0, 132, 0, 0, 14, 15, + 16, 17, 18, 0, 0, 19, 20, 97, 98, 99, + 100, 101, 21, 22, 102, 23, 0, 24, 0, 0, + 25, 26, 0, 27, 0, 0, -14, 180, -14, 4, + 5, 0, 0, 6, 7, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 181, 0, 182, 183, 184, + -69, -69, 185, 186, 187, 188, 189, 190, 191, 192, + 193, 0, 0, 0, 13, 194, 0, 0, 0, 14, + 15, 16, 17, 0, 0, 0, -69, 20, 0, 0, + 0, 0, 0, 21, 22, 0, 23, 0, 24, 0, + 0, 25, 26, 0, 55, 0, 0, 68, -69, 69, + 180, 0, 4, 5, 0, 0, 6, 7, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 181, 0, + 182, 183, 184, -68, -68, 185, 186, 187, 188, 189, + 190, 191, 192, 193, 0, 0, 0, 13, 194, 0, + 0, 0, 14, 15, 16, 17, 0, 0, 0, -68, + 20, 0, 0, 0, 0, 0, 21, 22, 0, 23, + 0, 24, 0, 0, 25, 26, 0, 55, 0, 0, + 68, -68, 69, 180, 0, 4, 5, 0, 0, 6, + 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 181, 0, 182, 183, 184, 0, 0, 185, 186, + 187, 188, 189, 190, 191, 192, 193, 0, 0, 0, + 13, 194, 0, 0, 0, 14, 15, 16, 17, 63, + 0, 4, 5, 20, 0, 6, 7, 0, -99, 21, + 22, 0, 23, 0, 24, 0, 0, 25, 26, 0, + 55, 0, 0, 68, 195, 69, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, + 0, 14, 15, 16, 17, 0, 0, 0, -99, 20, + 0, 0, 0, 0, 0, 21, 22, 0, 23, 0, + 24, 0, 0, 25, 249, -99, 55, 0, 4, 5, + 0, -99, 6, 7, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 181, 0, 182, 183, 184, 0, + 0, 185, 186, 187, 188, 189, 190, 191, 192, 193, + 0, 0, 0, 13, 194, 0, 0, 0, 14, 15, + 16, 17, 0, 4, 5, 0, 20, 6, 7, 0, + 0, 0, 21, 22, 0, 23, 0, 24, 0, 0, + 25, 26, 0, 55, 0, 0, 68, 63, 69, 4, + 5, 0, 0, 6, 7, 0, 0, 0, 13, 0, + 0, 0, 0, 14, 15, 16, 17, 0, 0, 0, + 0, 20, 0, 0, 0, 0, 0, 21, 22, 0, + 23, 0, 24, 0, 13, 25, 26, 0, 55, 14, + 15, 16, 17, 69, 0, 0, 0, 20, 0, 0, + 0, 0, 0, 21, 22, 0, 23, 0, 24, 0, + 0, 25, 26, -99, 55, 63, 0, 4, 5, 0, + 0, 6, 7, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 176, 0, 4, 5, 0, 0, 6, 7, 0, + 0, 0, 13, 0, 0, 0, 0, 14, 15, 16, + 17, 0, 0, 0, 0, 20, 0, 0, 0, 0, + 0, 21, 22, 0, 23, 0, 24, 0, 13, 25, + 26, 0, 55, 14, 15, 16, 17, 0, 4, 245, + 0, 20, 6, 7, 0, 0, 0, 21, 22, 0, + 23, 0, 24, 0, 0, 25, 26, 183, 55, 0, + 0, 0, 0, 0, 0, 0, 190, 191, 0, 0, + 4, 5, 0, 13, 6, 7, 0, 0, 14, 15, + 16, 17, 0, 0, 0, 0, 20, 0, 0, 183, + 0, 0, 21, 22, 0, 23, 0, 24, 190, 191, + 25, 26, 0, 55, 0, 13, 0, 0, 0, 0, + 14, 15, 16, 17, 0, 4, 5, 0, 20, 6, + 7, 0, 0, 89, 21, 22, 0, 23, 0, 24, + 0, 0, 25, 26, 0, 55, 0, 0, 0, 0, + 0, 4, 5, 0, 0, 6, 7, 0, 0, 0, + 13, 0, 0, 0, 0, 14, 15, 16, 17, 0, + 0, 0, 0, 20, 0, 0, 0, 0, 0, 21, + 22, 0, 23, 0, 24, 0, 13, 25, 26, 0, + 55, 14, 15, 16, 17, 0, 4, 5, 0, 20, + 6, 7, 0, 0, 0, 21, 22, 0, 23, 0, + 24, 0, 0, 25, 26, 0, 55, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 78, 14, 15, 16, 17, + 79, 78, 0, 0, 20, 0, 79, 0, 0, 0, + 21, 22, 0, 23, 0, 24, 0, 0, 25, 60, + 78, 55, 0, 0, 0, 79, 80, 81, 82, 0, + 0, 0, 80, 81, 82, 0, 0, 0, 83, 0, + 78, 85, 86, 0, 83, 79, 84, 85, 86, 0, + 0, 80, 81, 82, 0, 0, 0, 0, 0, 69, + 0, 0, 0, 83, 205, 0, 85, 86, 0, 0, + 0, 80, 81, 82, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 83, 0, 0, 85, 86 +}; + +#define yypact_value_is_default(yystate) \ + ((yystate) == (-269)) + +#define yytable_value_is_error(yytable_value) \ + ((yytable_value) == (-101)) + +static const yytype_int16 yycheck[] = +{ + 1, 29, 30, 26, 29, 53, 54, 46, 80, 202, + 4, 13, 14, 15, 1, 64, 4, 230, 16, 21, + 22, 44, 24, 25, 3, 26, 40, 295, 27, 1, + 16, 220, 4, 35, 50, 66, 304, 57, 58, 59, + 60, 61, 43, 44, 64, 69, 1, 66, 219, 1, + 71, 1, 53, 54, 66, 69, 55, 73, 50, 60, + 109, 1, 9, 50, 1, 21, 22, 4, 24, 48, + 55, 69, 66, 3, 29, 124, 125, 65, 79, 35, + 81, 82, 83, 69, 24, 25, 73, 88, 301, 91, + 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, + 102, 272, 54, 175, 54, 276, 295, 108, 55, 56, + 50, 74, 9, 138, 50, 304, 64, 67, 70, 1, + 122, 84, 293, 43, 44, 296, 7, 8, 321, 130, + 67, 324, 72, 134, 5, 91, 92, 93, 94, 95, + 96, 97, 98, 99, 100, 101, 102, 4, 149, 151, + 38, 9, 323, 1, 13, 326, 14, 67, 55, 56, + 49, 210, 10, 188, 189, 50, 122, 192, 131, 194, + 51, 66, 54, 198, 40, 1, 57, 58, 203, 60, + 6, 229, 40, 138, 4, 67, 71, 66, 73, 238, + 43, 44, 193, 242, 243, 267, 66, 55, 56, 224, + 73, 240, 50, 66, 205, 66, 54, 67, 3, 4, + 138, 10, 213, 214, 239, 26, 217, 218, 20, 67, + 269, 260, 247, 186, 66, 73, 249, 72, 229, 278, + 53, 7, 195, 188, 189, 7, 285, 192, 30, 194, + 298, 204, 25, 198, 59, 60, 61, 275, 249, 64, + 45, 46, 214, 151, 279, 281, 305, 260, 12, 13, + 188, 189, 287, -1, 192, 312, 194, 316, 231, 224, + 198, -1, 235, 68, -1, -1, 277, 211, 279, 281, + -1, -1, -1, -1, 239, -1, -1, 289, -1, 43, + 44, -1, -1, -1, 257, -1, 224, 51, -1, -1, + -1, 264, 265, -1, -1, 268, -1, -1, -1, 9, + -1, 239, -1, -1, 14, -1, -1, 9, -1, -1, + -1, -1, 14, 286, -1, 288, -1, 290, 291, 292, + -1, 294, -1, 289, -1, 0, 1, -1, 3, 4, + 40, 41, 7, 8, -1, -1, -1, -1, 40, 41, + 42, 314, 17, 18, 317, 55, 56, 320, -1, 322, + 52, -1, -1, 55, 56, -1, -1, -1, -1, -1, + 35, 36, 37, 38, -1, 67, -1, -1, 43, 44, + 45, 46, 47, -1, -1, 50, 51, 57, 58, 59, + 60, 61, 57, 58, 64, 60, -1, 62, -1, -1, + 65, 66, -1, 68, -1, -1, 71, 1, 73, 3, + 4, -1, -1, 7, 8, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 19, -1, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, -1, -1, -1, 38, 39, -1, -1, -1, 43, + 44, 45, 46, -1, -1, -1, 50, 51, -1, -1, + -1, -1, -1, 57, 58, -1, 60, -1, 62, -1, + -1, 65, 66, -1, 68, -1, -1, 71, 72, 73, + 1, -1, 3, 4, -1, -1, 7, 8, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 19, -1, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, -1, -1, -1, 38, 39, -1, + -1, -1, 43, 44, 45, 46, -1, -1, -1, 50, + 51, -1, -1, -1, -1, -1, 57, 58, -1, 60, + -1, 62, -1, -1, 65, 66, -1, 68, -1, -1, + 71, 72, 73, 1, -1, 3, 4, -1, -1, 7, + 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 19, -1, 21, 22, 23, -1, -1, 26, 27, + 28, 29, 30, 31, 32, 33, 34, -1, -1, -1, + 38, 39, -1, -1, -1, 43, 44, 45, 46, 1, + -1, 3, 4, 51, -1, 7, 8, -1, 10, 57, + 58, -1, 60, -1, 62, -1, -1, 65, 66, -1, + 68, -1, -1, 71, 72, 73, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 38, -1, -1, -1, + -1, 43, 44, 45, 46, -1, -1, -1, 50, 51, + -1, -1, -1, -1, -1, 57, 58, -1, 60, -1, + 62, -1, -1, 65, 66, 67, 68, -1, 3, 4, + -1, 73, 7, 8, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 19, -1, 21, 22, 23, -1, + -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, + -1, -1, -1, 38, 39, -1, -1, -1, 43, 44, + 45, 46, -1, 3, 4, -1, 51, 7, 8, -1, + -1, -1, 57, 58, -1, 60, -1, 62, -1, -1, + 65, 66, -1, 68, -1, -1, 71, 1, 73, 3, + 4, -1, -1, 7, 8, -1, -1, -1, 38, -1, + -1, -1, -1, 43, 44, 45, 46, -1, -1, -1, + -1, 51, -1, -1, -1, -1, -1, 57, 58, -1, + 60, -1, 62, -1, 38, 65, 66, -1, 68, 43, + 44, 45, 46, 73, -1, -1, -1, 51, -1, -1, + -1, -1, -1, 57, 58, -1, 60, -1, 62, -1, + -1, 65, 66, 67, 68, 1, -1, 3, 4, -1, + -1, 7, 8, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 1, -1, 3, 4, -1, -1, 7, 8, -1, + -1, -1, 38, -1, -1, -1, -1, 43, 44, 45, + 46, -1, -1, -1, -1, 51, -1, -1, -1, -1, + -1, 57, 58, -1, 60, -1, 62, -1, 38, 65, + 66, -1, 68, 43, 44, 45, 46, -1, 3, 4, + -1, 51, 7, 8, -1, -1, -1, 57, 58, -1, + 60, -1, 62, -1, -1, 65, 66, 22, 68, -1, + -1, -1, -1, -1, -1, -1, 31, 32, -1, -1, + 3, 4, -1, 38, 7, 8, -1, -1, 43, 44, + 45, 46, -1, -1, -1, -1, 51, -1, -1, 22, + -1, -1, 57, 58, -1, 60, -1, 62, 31, 32, + 65, 66, -1, 68, -1, 38, -1, -1, -1, -1, + 43, 44, 45, 46, -1, 3, 4, -1, 51, 7, + 8, -1, -1, 11, 57, 58, -1, 60, -1, 62, + -1, -1, 65, 66, -1, 68, -1, -1, -1, -1, + -1, 3, 4, -1, -1, 7, 8, -1, -1, -1, + 38, -1, -1, -1, -1, 43, 44, 45, 46, -1, + -1, -1, -1, 51, -1, -1, -1, -1, -1, 57, + 58, -1, 60, -1, 62, -1, 38, 65, 66, -1, + 68, 43, 44, 45, 46, -1, 3, 4, -1, 51, + 7, 8, -1, -1, -1, 57, 58, -1, 60, -1, + 62, -1, -1, 65, 66, -1, 68, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 9, 43, 44, 45, 46, + 14, 9, -1, -1, 51, -1, 14, -1, -1, -1, + 57, 58, -1, 60, -1, 62, -1, -1, 65, 66, + 9, 68, -1, -1, -1, 14, 40, 41, 42, -1, + -1, -1, 40, 41, 42, -1, -1, -1, 52, -1, + 9, 55, 56, -1, 52, 14, 54, 55, 56, -1, + -1, 40, 41, 42, -1, -1, -1, -1, -1, 73, + -1, -1, -1, 52, 53, -1, 55, 56, -1, -1, + -1, 40, 41, 42, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 52, -1, -1, 55, 56 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 75, 0, 1, 3, 4, 7, 8, 17, 18, + 35, 36, 37, 38, 43, 44, 45, 46, 47, 50, + 51, 57, 58, 60, 62, 65, 66, 68, 76, 78, + 82, 84, 86, 104, 112, 116, 117, 118, 119, 120, + 121, 129, 130, 66, 69, 126, 127, 128, 83, 122, + 130, 130, 130, 66, 66, 68, 117, 130, 117, 117, + 66, 119, 130, 1, 111, 112, 48, 121, 71, 73, + 79, 88, 104, 132, 136, 79, 85, 50, 9, 14, + 40, 41, 42, 52, 54, 55, 56, 114, 115, 11, + 117, 57, 58, 59, 60, 61, 64, 57, 58, 59, + 60, 61, 64, 12, 13, 43, 44, 51, 113, 110, + 111, 112, 111, 16, 126, 3, 4, 45, 46, 68, + 80, 81, 55, 106, 110, 110, 112, 43, 44, 131, + 1, 54, 67, 134, 138, 134, 1, 6, 77, 104, + 105, 87, 105, 5, 112, 129, 112, 112, 112, 105, + 112, 38, 117, 117, 117, 117, 117, 117, 117, 117, + 117, 117, 117, 117, 13, 112, 134, 70, 49, 66, + 117, 134, 134, 112, 105, 40, 1, 112, 1, 88, + 1, 19, 21, 22, 23, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 39, 72, 89, 90, 92, 99, + 103, 112, 132, 133, 136, 53, 112, 122, 1, 4, + 107, 108, 129, 66, 91, 4, 66, 66, 66, 105, + 66, 88, 88, 88, 109, 112, 88, 105, 88, 93, + 87, 135, 136, 105, 112, 134, 1, 138, 112, 109, + 94, 4, 112, 112, 89, 4, 92, 95, 88, 66, + 100, 110, 133, 105, 105, 1, 4, 134, 88, 123, + 124, 125, 126, 67, 134, 134, 26, 40, 136, 111, + 10, 101, 105, 16, 125, 105, 105, 66, 129, 105, + 134, 102, 89, 132, 89, 112, 134, 112, 136, 116, + 20, 96, 134, 105, 136, 105, 105, 1, 24, 25, + 97, 105, 105, 89, 105, 95, 89, 7, 8, 57, + 58, 84, 98, 53, 137, 133, 95, 134, 7, 7, + 137, 105, 134, 105, 105, 87, 105, 89, 87, 89 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ + +#define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* This macro is provided for backward compatibility. */ + +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +#else +static void +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule) +#else +static void +yy_reduce_print (yyvsp, yyrule) + YYSTYPE *yyvsp; + int yyrule; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) +{ + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = 0; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + + /* There are many possibilities here to consider: + - Assume YYFAIL is not used. It's too flawed to consider. See + + for details. YYERROR is fine as it does not invoke this + function. + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) + { + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } + + yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; +} +#endif /* YYERROR_VERBOSE */ + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + YYUSE (yyvaluep); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yypact_value_is_default (yyn)) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yytable_value_is_error (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 3: + +/* Line 1806 of yacc.c */ +#line 221 "awkgram.y" + { + rule = 0; + yyerrok; + } + break; + + case 5: + +/* Line 1806 of yacc.c */ +#line 227 "awkgram.y" + { + next_sourcefile(); + } + break; + + case 6: + +/* Line 1806 of yacc.c */ +#line 231 "awkgram.y" + { + rule = 0; + /* + * If errors, give up, don't produce an infinite + * stream of syntax error messages. + */ + /* yyerrok; */ + } + break; + + case 7: + +/* Line 1806 of yacc.c */ +#line 243 "awkgram.y" + { + (void) append_rule((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); + } + break; + + case 8: + +/* Line 1806 of yacc.c */ +#line 247 "awkgram.y" + { + if (rule != Rule) { + msg(_("%s blocks must have an action part"), ruletab[rule]); + errcount++; + } else if ((yyvsp[(1) - (2)]) == NULL) { + msg(_("each rule must have a pattern or an action part")); + errcount++; + } else /* pattern rule with non-empty pattern */ + (void) append_rule((yyvsp[(1) - (2)]), NULL); + } + break; + + case 9: + +/* Line 1806 of yacc.c */ +#line 258 "awkgram.y" + { + can_return = FALSE; + if ((yyvsp[(1) - (2)]) && func_install((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])) < 0) + YYABORT; + func_params = NULL; + yyerrok; + } + break; + + case 10: + +/* Line 1806 of yacc.c */ +#line 266 "awkgram.y" + { + want_source = FALSE; + yyerrok; + } + break; + + case 11: + +/* Line 1806 of yacc.c */ +#line 274 "awkgram.y" + { + if (include_source((yyvsp[(1) - (1)])) < 0) + YYABORT; + efree((yyvsp[(1) - (1)])->lextok); + bcfree((yyvsp[(1) - (1)])); + (yyval) = NULL; + } + break; + + case 12: + +/* Line 1806 of yacc.c */ +#line 282 "awkgram.y" + { (yyval) = NULL; } + break; + + case 13: + +/* Line 1806 of yacc.c */ +#line 284 "awkgram.y" + { (yyval) = NULL; } + break; + + case 14: + +/* Line 1806 of yacc.c */ +#line 289 "awkgram.y" + { (yyval) = NULL; rule = Rule; } + break; + + case 15: + +/* Line 1806 of yacc.c */ +#line 291 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); rule = Rule; } + break; + + case 16: + +/* Line 1806 of yacc.c */ +#line 293 "awkgram.y" + { + INSTRUCTION *tp; + + add_lint((yyvsp[(1) - (4)]), LINT_assign_in_cond); + add_lint((yyvsp[(4) - (4)]), LINT_assign_in_cond); + + tp = instruction(Op_no_op); + list_prepend((yyvsp[(1) - (4)]), bcalloc(Op_line_range, !!do_profiling + 1, 0)); + (yyvsp[(1) - (4)])->nexti->triggered = FALSE; + (yyvsp[(1) - (4)])->nexti->target_jmp = (yyvsp[(4) - (4)])->nexti; + + list_append((yyvsp[(1) - (4)]), instruction(Op_cond_pair)); + (yyvsp[(1) - (4)])->lasti->line_range = (yyvsp[(1) - (4)])->nexti; + (yyvsp[(1) - (4)])->lasti->target_jmp = tp; + + list_append((yyvsp[(4) - (4)]), instruction(Op_cond_pair)); + (yyvsp[(4) - (4)])->lasti->line_range = (yyvsp[(1) - (4)])->nexti; + (yyvsp[(4) - (4)])->lasti->target_jmp = tp; + if (do_profiling) { + ((yyvsp[(1) - (4)])->nexti + 1)->condpair_left = (yyvsp[(1) - (4)])->lasti; + ((yyvsp[(1) - (4)])->nexti + 1)->condpair_right = (yyvsp[(4) - (4)])->lasti; + } + (yyval) = list_append(list_merge((yyvsp[(1) - (4)]), (yyvsp[(4) - (4)])), tp); + rule = Rule; + } + break; + + case 17: + +/* Line 1806 of yacc.c */ +#line 319 "awkgram.y" + { + static int begin_seen = 0; + if (do_lint_old && ++begin_seen == 2) + warning_ln((yyvsp[(1) - (1)])->source_line, + _("old awk does not support multiple `BEGIN' or `END' rules")); + + (yyvsp[(1) - (1)])->in_rule = rule = BEGIN; + (yyvsp[(1) - (1)])->source_file = source; + (yyval) = (yyvsp[(1) - (1)]); + } + break; + + case 18: + +/* Line 1806 of yacc.c */ +#line 330 "awkgram.y" + { + static int end_seen = 0; + if (do_lint_old && ++end_seen == 2) + warning_ln((yyvsp[(1) - (1)])->source_line, + _("old awk does not support multiple `BEGIN' or `END' rules")); + + (yyvsp[(1) - (1)])->in_rule = rule = END; + (yyvsp[(1) - (1)])->source_file = source; + (yyval) = (yyvsp[(1) - (1)]); + } + break; + + case 19: + +/* Line 1806 of yacc.c */ +#line 341 "awkgram.y" + { + (yyvsp[(1) - (1)])->in_rule = rule = BEGINFILE; + (yyvsp[(1) - (1)])->source_file = source; + (yyval) = (yyvsp[(1) - (1)]); + } + break; + + case 20: + +/* Line 1806 of yacc.c */ +#line 347 "awkgram.y" + { + (yyvsp[(1) - (1)])->in_rule = rule = ENDFILE; + (yyvsp[(1) - (1)])->source_file = source; + (yyval) = (yyvsp[(1) - (1)]); + } + break; + + case 21: + +/* Line 1806 of yacc.c */ +#line 356 "awkgram.y" + { + if ((yyvsp[(2) - (5)]) == NULL) + (yyval) = list_create(instruction(Op_no_op)); + else + (yyval) = (yyvsp[(2) - (5)]); + } + break; + + case 22: + +/* Line 1806 of yacc.c */ +#line 366 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 23: + +/* Line 1806 of yacc.c */ +#line 368 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 24: + +/* Line 1806 of yacc.c */ +#line 370 "awkgram.y" + { + yyerror(_("`%s' is a built-in function, it cannot be redefined"), + tokstart); + (yyvsp[(1) - (1)])->opcode = Op_symbol; /* Op_symbol instead of Op_token so that + * free_bc_internal does not try to free it + */ + (yyvsp[(1) - (1)])->lextok = builtin_func; + (yyval) = (yyvsp[(1) - (1)]); + /* yyerrok; */ + } + break; + + case 25: + +/* Line 1806 of yacc.c */ +#line 381 "awkgram.y" + { (yyval) = (yyvsp[(2) - (2)]); } + break; + + case 28: + +/* Line 1806 of yacc.c */ +#line 391 "awkgram.y" + { + param_counter = 0; + func_params = NULL; + } + break; + + case 29: + +/* Line 1806 of yacc.c */ +#line 396 "awkgram.y" + { + NODE *t; + + (yyvsp[(1) - (7)])->source_file = source; + t = make_param((yyvsp[(3) - (7)])->lextok); + (yyvsp[(3) - (7)])->lextok = NULL; + bcfree((yyvsp[(3) - (7)])); + t->flags |= FUNC; + t->rnode = func_params; + func_params = t; + (yyval) = (yyvsp[(1) - (7)]); + can_return = TRUE; + /* check for duplicate parameter names */ + if (dup_parms((yyvsp[(1) - (7)]), t)) + errcount++; + } + break; + + case 30: + +/* Line 1806 of yacc.c */ +#line 420 "awkgram.y" + { ++want_regexp; } + break; + + case 31: + +/* Line 1806 of yacc.c */ +#line 422 "awkgram.y" + { + NODE *n, *exp; + char *re; + size_t len; + + re = (yyvsp[(3) - (3)])->lextok; + len = strlen(re); + if (do_lint) { + if (len == 0) + lintwarn_ln((yyvsp[(3) - (3)])->source_line, + _("regexp constant `//' looks like a C++ comment, but is not")); + else if ((re)[0] == '*' && (re)[len-1] == '*') + /* possible C comment */ + lintwarn_ln((yyvsp[(3) - (3)])->source_line, + _("regexp constant `/%s/' looks like a C comment, but is not"), re); + } + + exp = make_str_node(re, len, ALREADY_MALLOCED); + n = make_regnode(Node_regex, exp); + if (n == NULL) { + unref(exp); + YYABORT; + } + (yyval) = (yyvsp[(3) - (3)]); + (yyval)->opcode = Op_match_rec; + (yyval)->memory = n; + } + break; + + case 32: + +/* Line 1806 of yacc.c */ +#line 453 "awkgram.y" + { bcfree((yyvsp[(1) - (1)])); } + break; + + case 34: + +/* Line 1806 of yacc.c */ +#line 459 "awkgram.y" + { (yyval) = NULL; } + break; + + case 35: + +/* Line 1806 of yacc.c */ +#line 461 "awkgram.y" + { + if ((yyvsp[(2) - (2)]) == NULL) + (yyval) = (yyvsp[(1) - (2)]); + else { + add_lint((yyvsp[(2) - (2)]), LINT_no_effect); + if ((yyvsp[(1) - (2)]) == NULL) + (yyval) = (yyvsp[(2) - (2)]); + else + (yyval) = list_merge((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); + } + yyerrok; + } + break; + + case 36: + +/* Line 1806 of yacc.c */ +#line 474 "awkgram.y" + { (yyval) = NULL; } + break; + + case 39: + +/* Line 1806 of yacc.c */ +#line 484 "awkgram.y" + { (yyval) = NULL; } + break; + + case 40: + +/* Line 1806 of yacc.c */ +#line 486 "awkgram.y" + { (yyval) = (yyvsp[(2) - (3)]); } + break; + + case 41: + +/* Line 1806 of yacc.c */ +#line 488 "awkgram.y" + { + if (do_profiling) + (yyval) = list_prepend((yyvsp[(1) - (1)]), instruction(Op_exec_count)); + else + (yyval) = (yyvsp[(1) - (1)]); + } + break; + + case 42: + +/* Line 1806 of yacc.c */ +#line 495 "awkgram.y" + { + INSTRUCTION *dflt, *curr = NULL, *cexp, *cstmt; + INSTRUCTION *ip, *nextc, *tbreak; + const char **case_values = NULL; + int maxcount = 128; + int case_count = 0; + int i; + + tbreak = instruction(Op_no_op); + cstmt = list_create(tbreak); + cexp = list_create(instruction(Op_pop)); + dflt = instruction(Op_jmp); + dflt->target_jmp = tbreak; /* if no case match and no explicit default */ + + if ((yyvsp[(7) - (9)]) != NULL) { + curr = (yyvsp[(7) - (9)])->nexti; + bcfree((yyvsp[(7) - (9)])); /* Op_list */ + } /* else + curr = NULL; */ + + for(; curr != NULL; curr = nextc) { + INSTRUCTION *caseexp = curr->case_exp; + INSTRUCTION *casestmt = curr->case_stmt; + + nextc = curr->nexti; + if (curr->opcode == Op_K_case) { + if (caseexp->opcode == Op_push_i) { + /* a constant scalar */ + char *caseval; + caseval = force_string(caseexp->memory)->stptr; + for (i = 0; i < case_count; i++) { + if (strcmp(caseval, case_values[i]) == 0) + error_ln(curr->source_line, + _("duplicate case values in switch body: %s"), caseval); + } + + if (case_values == NULL) + emalloc(case_values, const char **, sizeof(char *) * maxcount, "statement"); + else if (case_count >= maxcount) { + maxcount += 128; + erealloc(case_values, const char **, sizeof(char*) * maxcount, "statement"); + } + case_values[case_count++] = caseval; + } else { + /* match a constant regex against switch expression. */ + (curr + 1)->match_exp = TRUE; + } + curr->stmt_start = casestmt->nexti; + curr->stmt_end = casestmt->lasti; + (void) list_prepend(cexp, curr); + (void) list_prepend(cexp, caseexp); + } else { + if (dflt->target_jmp != tbreak) + error_ln(curr->source_line, + _("duplicate `default' detected in switch body")); + else + dflt->target_jmp = casestmt->nexti; + + if (do_profiling) { + curr->stmt_start = casestmt->nexti; + curr->stmt_end = casestmt->lasti; + (void) list_prepend(cexp, curr); + } else + bcfree(curr); + } + + cstmt = list_merge(casestmt, cstmt); + } + + if (case_values != NULL) + efree(case_values); + + ip = (yyvsp[(3) - (9)]); + if (do_profiling) { + (void) list_prepend(ip, (yyvsp[(1) - (9)])); + (void) list_prepend(ip, instruction(Op_exec_count)); + (yyvsp[(1) - (9)])->target_break = tbreak; + ((yyvsp[(1) - (9)]) + 1)->switch_start = cexp->nexti; + ((yyvsp[(1) - (9)]) + 1)->switch_end = cexp->lasti; + }/* else + $1 is NULL */ + + (void) list_append(cexp, dflt); + (void) list_merge(ip, cexp); + (yyval) = list_merge(ip, cstmt); + + break_allowed--; + fix_break_continue(ip, tbreak, NULL); + } + break; + + case 43: + +/* Line 1806 of yacc.c */ +#line 585 "awkgram.y" + { + /* + * ----------------- + * tc: + * cond + * ----------------- + * [Op_jmp_false tb ] + * ----------------- + * body + * ----------------- + * [Op_jmp tc ] + * tb:[Op_no_op ] + */ + + INSTRUCTION *ip, *tbreak, *tcont; + + tbreak = instruction(Op_no_op); + add_lint((yyvsp[(3) - (6)]), LINT_assign_in_cond); + tcont = (yyvsp[(3) - (6)])->nexti; + ip = list_append((yyvsp[(3) - (6)]), instruction(Op_jmp_false)); + ip->lasti->target_jmp = tbreak; + + if (do_profiling) { + (void) list_append(ip, instruction(Op_exec_count)); + (yyvsp[(1) - (6)])->target_break = tbreak; + (yyvsp[(1) - (6)])->target_continue = tcont; + ((yyvsp[(1) - (6)]) + 1)->while_body = ip->lasti; + (void) list_prepend(ip, (yyvsp[(1) - (6)])); + }/* else + $1 is NULL */ + + if ((yyvsp[(6) - (6)]) != NULL) + (void) list_merge(ip, (yyvsp[(6) - (6)])); + (void) list_append(ip, instruction(Op_jmp)); + ip->lasti->target_jmp = tcont; + (yyval) = list_append(ip, tbreak); + + break_allowed--; + continue_allowed--; + fix_break_continue(ip, tbreak, tcont); + } + break; + + case 44: + +/* Line 1806 of yacc.c */ +#line 627 "awkgram.y" + { + /* + * ----------------- + * z: + * body + * ----------------- + * tc: + * cond + * ----------------- + * [Op_jmp_true | z ] + * tb:[Op_no_op ] + */ + + INSTRUCTION *ip, *tbreak, *tcont; + + tbreak = instruction(Op_no_op); + tcont = (yyvsp[(6) - (8)])->nexti; + add_lint((yyvsp[(6) - (8)]), LINT_assign_in_cond); + if ((yyvsp[(3) - (8)]) != NULL) + ip = list_merge((yyvsp[(3) - (8)]), (yyvsp[(6) - (8)])); + else + ip = list_prepend((yyvsp[(6) - (8)]), instruction(Op_no_op)); + if (do_profiling) + (void) list_prepend(ip, instruction(Op_exec_count)); + (void) list_append(ip, instruction(Op_jmp_true)); + ip->lasti->target_jmp = ip->nexti; + (yyval) = list_append(ip, tbreak); + + break_allowed--; + continue_allowed--; + fix_break_continue(ip, tbreak, tcont); + + if (do_profiling) { + (yyvsp[(1) - (8)])->target_break = tbreak; + (yyvsp[(1) - (8)])->target_continue = tcont; + ((yyvsp[(1) - (8)]) + 1)->doloop_cond = tcont; + (yyval) = list_prepend(ip, (yyvsp[(1) - (8)])); + bcfree((yyvsp[(4) - (8)])); + } /* else + $1 and $4 are NULLs */ + } + break; + + case 45: + +/* Line 1806 of yacc.c */ +#line 669 "awkgram.y" + { + INSTRUCTION *ip; + char *var_name = (yyvsp[(3) - (8)])->lextok; + + if ((yyvsp[(8) - (8)]) != NULL + && (yyvsp[(8) - (8)])->lasti->opcode == Op_K_delete + && (yyvsp[(8) - (8)])->lasti->expr_count == 1 + && (yyvsp[(8) - (8)])->nexti->opcode == Op_push + && ((yyvsp[(8) - (8)])->nexti->memory->type != Node_var || !((yyvsp[(8) - (8)])->nexti->memory->var_update)) + && strcmp((yyvsp[(8) - (8)])->nexti->memory->vname, var_name) == 0 + ) { + + /* Efficiency hack. Recognize the special case of + * + * for (iggy in foo) + * delete foo[iggy] + * + * and treat it as if it were + * + * delete foo + * + * Check that the body is a `delete a[i]' statement, + * and that both the loop var and array names match. + */ + NODE *arr = NULL; + + ip = (yyvsp[(8) - (8)])->nexti->nexti; + if ((yyvsp[(5) - (8)])->nexti->opcode == Op_push && (yyvsp[(5) - (8)])->lasti == (yyvsp[(5) - (8)])->nexti) + arr = (yyvsp[(5) - (8)])->nexti->memory; + if (arr != NULL + && ip->opcode == Op_no_op + && ip->nexti->opcode == Op_push_array + && strcmp(ip->nexti->memory->vname, arr->vname) == 0 + && ip->nexti->nexti == (yyvsp[(8) - (8)])->lasti + ) { + (void) make_assignable((yyvsp[(8) - (8)])->nexti); + (yyvsp[(8) - (8)])->lasti->opcode = Op_K_delete_loop; + (yyvsp[(8) - (8)])->lasti->expr_count = 0; + if ((yyvsp[(1) - (8)]) != NULL) + bcfree((yyvsp[(1) - (8)])); + efree(var_name); + bcfree((yyvsp[(3) - (8)])); + bcfree((yyvsp[(4) - (8)])); + bcfree((yyvsp[(5) - (8)])); + (yyval) = (yyvsp[(8) - (8)]); + } else + goto regular_loop; + } else { + INSTRUCTION *tbreak, *tcont; + + /* [ Op_push_array a ] + * [ Op_arrayfor_init | ib ] + * ic:[ Op_arrayfor_incr | ib ] + * [ Op_var_assign if any ] + * + * body + * + * [Op_jmp | ic ] + * ib:[Op_arrayfor_final ] + */ +regular_loop: + ip = (yyvsp[(5) - (8)]); + ip->nexti->opcode = Op_push_array; + + tbreak = instruction(Op_arrayfor_final); + (yyvsp[(4) - (8)])->opcode = Op_arrayfor_incr; + (yyvsp[(4) - (8)])->array_var = variable(var_name, Node_var); + (yyvsp[(4) - (8)])->target_jmp = tbreak; + tcont = (yyvsp[(4) - (8)]); + (yyvsp[(3) - (8)])->opcode = Op_arrayfor_init; + (yyvsp[(3) - (8)])->target_jmp = tbreak; + (void) list_append(ip, (yyvsp[(3) - (8)])); + + if (do_profiling) { + (yyvsp[(1) - (8)])->opcode = Op_K_arrayfor; + (yyvsp[(1) - (8)])->target_continue = tcont; + (yyvsp[(1) - (8)])->target_break = tbreak; + (void) list_append(ip, (yyvsp[(1) - (8)])); + } /* else + $1 is NULL */ + + /* add update_FOO instruction if necessary */ + if ((yyvsp[(4) - (8)])->array_var->type == Node_var && (yyvsp[(4) - (8)])->array_var->var_update) { + (void) list_append(ip, instruction(Op_var_update)); + ip->lasti->update_var = (yyvsp[(4) - (8)])->array_var->var_update; + } + (void) list_append(ip, (yyvsp[(4) - (8)])); + + /* add set_FOO instruction if necessary */ + if ((yyvsp[(4) - (8)])->array_var->type == Node_var && (yyvsp[(4) - (8)])->array_var->var_assign) { + (void) list_append(ip, instruction(Op_var_assign)); + ip->lasti->assign_var = (yyvsp[(4) - (8)])->array_var->var_assign; + } + + if (do_profiling) { + (void) list_append(ip, instruction(Op_exec_count)); + ((yyvsp[(1) - (8)]) + 1)->forloop_cond = (yyvsp[(4) - (8)]); + ((yyvsp[(1) - (8)]) + 1)->forloop_body = ip->lasti; + } + + if ((yyvsp[(8) - (8)]) != NULL) + (void) list_merge(ip, (yyvsp[(8) - (8)])); + + (void) list_append(ip, instruction(Op_jmp)); + ip->lasti->target_jmp = (yyvsp[(4) - (8)]); + (yyval) = list_append(ip, tbreak); + fix_break_continue(ip, tbreak, tcont); + } + + break_allowed--; + continue_allowed--; + } + break; + + case 46: + +/* Line 1806 of yacc.c */ +#line 782 "awkgram.y" + { + (yyval) = mk_for_loop((yyvsp[(1) - (12)]), (yyvsp[(3) - (12)]), (yyvsp[(6) - (12)]), (yyvsp[(9) - (12)]), (yyvsp[(12) - (12)])); + + break_allowed--; + continue_allowed--; + } + break; + + case 47: + +/* Line 1806 of yacc.c */ +#line 789 "awkgram.y" + { + (yyval) = mk_for_loop((yyvsp[(1) - (11)]), (yyvsp[(3) - (11)]), (INSTRUCTION *) NULL, (yyvsp[(8) - (11)]), (yyvsp[(11) - (11)])); + + break_allowed--; + continue_allowed--; + } + break; + + case 48: + +/* Line 1806 of yacc.c */ +#line 796 "awkgram.y" + { + if (do_profiling) + (yyval) = list_prepend((yyvsp[(1) - (1)]), instruction(Op_exec_count)); + else + (yyval) = (yyvsp[(1) - (1)]); + } + break; + + case 49: + +/* Line 1806 of yacc.c */ +#line 806 "awkgram.y" + { + if (! break_allowed) + error_ln((yyvsp[(1) - (2)])->source_line, + _("`break' is not allowed outside a loop or switch")); + (yyvsp[(1) - (2)])->target_jmp = NULL; + (yyval) = list_create((yyvsp[(1) - (2)])); + + } + break; + + case 50: + +/* Line 1806 of yacc.c */ +#line 815 "awkgram.y" + { + if (! continue_allowed) + error_ln((yyvsp[(1) - (2)])->source_line, + _("`continue' is not allowed outside a loop")); + (yyvsp[(1) - (2)])->target_jmp = NULL; + (yyval) = list_create((yyvsp[(1) - (2)])); + + } + break; + + case 51: + +/* Line 1806 of yacc.c */ +#line 824 "awkgram.y" + { + /* if inside function (rule = 0), resolve context at run-time */ + if (rule && rule != Rule) + error_ln((yyvsp[(1) - (2)])->source_line, + _("`next' used in %s action"), ruletab[rule]); + (yyvsp[(1) - (2)])->target_jmp = ip_rec; + (yyval) = list_create((yyvsp[(1) - (2)])); + } + break; + + case 52: + +/* Line 1806 of yacc.c */ +#line 833 "awkgram.y" + { + if (do_traditional) + error_ln((yyvsp[(1) - (2)])->source_line, + _("`nextfile' is a gawk extension")); + + /* if inside function (rule = 0), resolve context at run-time */ + if (rule == BEGIN || rule == END || rule == ENDFILE) + error_ln((yyvsp[(1) - (2)])->source_line, + _("`nextfile' used in %s action"), ruletab[rule]); + + (yyvsp[(1) - (2)])->target_newfile = ip_newfile; + (yyvsp[(1) - (2)])->target_endfile = ip_endfile; + (yyval) = list_create((yyvsp[(1) - (2)])); + } + break; + + case 53: + +/* Line 1806 of yacc.c */ +#line 848 "awkgram.y" + { + /* Initialize the two possible jump targets, the actual target + * is resolved at run-time. + */ + (yyvsp[(1) - (3)])->target_end = ip_end; /* first instruction in end_block */ + (yyvsp[(1) - (3)])->target_atexit = ip_atexit; /* cleanup and go home */ + + if ((yyvsp[(2) - (3)]) == NULL) { + (yyval) = list_create((yyvsp[(1) - (3)])); + (void) list_prepend((yyval), instruction(Op_push_i)); + (yyval)->nexti->memory = Nnull_string; + } else + (yyval) = list_append((yyvsp[(2) - (3)]), (yyvsp[(1) - (3)])); + } + break; + + case 54: + +/* Line 1806 of yacc.c */ +#line 863 "awkgram.y" + { + if (! can_return) + yyerror(_("`return' used outside function context")); + } + break; + + case 55: + +/* Line 1806 of yacc.c */ +#line 866 "awkgram.y" + { + if ((yyvsp[(3) - (4)]) == NULL) { + (yyval) = list_create((yyvsp[(1) - (4)])); + (void) list_prepend((yyval), instruction(Op_push_i)); + (yyval)->nexti->memory = Nnull_string; + } else + (yyval) = list_append((yyvsp[(3) - (4)]), (yyvsp[(1) - (4)])); + } + break; + + case 57: + +/* Line 1806 of yacc.c */ +#line 886 "awkgram.y" + { in_print = TRUE; in_parens = 0; } + break; + + case 58: + +/* Line 1806 of yacc.c */ +#line 887 "awkgram.y" + { + /* + * Optimization: plain `print' has no expression list, so $3 is null. + * If $3 is NULL or is a bytecode list for $0 use Op_K_print_rec, + * which is faster for these two cases. + */ + + if ((yyvsp[(1) - (4)])->opcode == Op_K_print && + ((yyvsp[(3) - (4)]) == NULL + || ((yyvsp[(3) - (4)])->lasti->opcode == Op_field_spec + && (yyvsp[(3) - (4)])->nexti->nexti->nexti == (yyvsp[(3) - (4)])->lasti + && (yyvsp[(3) - (4)])->nexti->nexti->opcode == Op_push_i + && (yyvsp[(3) - (4)])->nexti->nexti->memory->type == Node_val + && (yyvsp[(3) - (4)])->nexti->nexti->memory->numbr == 0.0) + ) + ) { + static short warned = FALSE; + /* ----------------- + * output_redir + * [ redirect exp ] + * ----------------- + * expression_list + * ------------------ + * [Op_K_print_rec | NULL | redir_type | expr_count] + */ + + if ((yyvsp[(3) - (4)]) != NULL) { + bcfree((yyvsp[(3) - (4)])->lasti); /* Op_field_spec */ + (yyvsp[(3) - (4)])->nexti->nexti->memory->flags &= ~PERM; + (yyvsp[(3) - (4)])->nexti->nexti->memory->flags |= MALLOC; + unref((yyvsp[(3) - (4)])->nexti->nexti->memory); /* Node_val */ + bcfree((yyvsp[(3) - (4)])->nexti->nexti); /* Op_push_i */ + bcfree((yyvsp[(3) - (4)])->nexti); /* Op_list */ + bcfree((yyvsp[(3) - (4)])); /* Op_list */ + } else { + if (do_lint && (rule == BEGIN || rule == END) && ! warned) { + warned = TRUE; + lintwarn_ln((yyvsp[(1) - (4)])->source_line, + _("plain `print' in BEGIN or END rule should probably be `print \"\"'")); + } + } + + (yyvsp[(1) - (4)])->expr_count = 0; + (yyvsp[(1) - (4)])->opcode = Op_K_print_rec; + if ((yyvsp[(4) - (4)]) == NULL) { /* no redircetion */ + (yyvsp[(1) - (4)])->redir_type = 0; + (yyval) = list_create((yyvsp[(1) - (4)])); + } else { + INSTRUCTION *ip; + ip = (yyvsp[(4) - (4)])->nexti; + (yyvsp[(1) - (4)])->redir_type = ip->redir_type; + (yyvsp[(4) - (4)])->nexti = ip->nexti; + bcfree(ip); + (yyval) = list_append((yyvsp[(4) - (4)]), (yyvsp[(1) - (4)])); + } + } else { + /* ----------------- + * [ output_redir ] + * [ redirect exp ] + * ----------------- + * [ expression_list ] + * ------------------ + * [$1 | NULL | redir_type | expr_count] + * + */ + + if ((yyvsp[(4) - (4)]) == NULL) { /* no redirection */ + if ((yyvsp[(3) - (4)]) == NULL) { /* printf without arg */ + (yyvsp[(1) - (4)])->expr_count = 0; + (yyvsp[(1) - (4)])->redir_type = 0; + (yyval) = list_create((yyvsp[(1) - (4)])); + } else { + INSTRUCTION *t = (yyvsp[(3) - (4)]); + (yyvsp[(1) - (4)])->expr_count = count_expressions(&t, FALSE); + (yyvsp[(1) - (4)])->redir_type = 0; + (yyval) = list_append(t, (yyvsp[(1) - (4)])); + } + } else { + INSTRUCTION *ip; + ip = (yyvsp[(4) - (4)])->nexti; + (yyvsp[(1) - (4)])->redir_type = ip->redir_type; + (yyvsp[(4) - (4)])->nexti = ip->nexti; + bcfree(ip); + if ((yyvsp[(3) - (4)]) == NULL) { + (yyvsp[(1) - (4)])->expr_count = 0; + (yyval) = list_append((yyvsp[(4) - (4)]), (yyvsp[(1) - (4)])); + } else { + INSTRUCTION *t = (yyvsp[(3) - (4)]); + (yyvsp[(1) - (4)])->expr_count = count_expressions(&t, FALSE); + (yyval) = list_append(list_merge((yyvsp[(4) - (4)]), t), (yyvsp[(1) - (4)])); + } + } + } + } + break; + + case 59: + +/* Line 1806 of yacc.c */ +#line 982 "awkgram.y" + { sub_counter = 0; } + break; + + case 60: + +/* Line 1806 of yacc.c */ +#line 983 "awkgram.y" + { + char *arr = (yyvsp[(2) - (4)])->lextok; + + (yyvsp[(2) - (4)])->opcode = Op_push_array; + (yyvsp[(2) - (4)])->memory = variable(arr, Node_var_new); + + if ((yyvsp[(4) - (4)]) == NULL) { + static short warned = FALSE; + + if (do_lint && ! warned) { + warned = TRUE; + lintwarn_ln((yyvsp[(1) - (4)])->source_line, + _("`delete array' is a gawk extension")); + } + if (do_traditional) + error_ln((yyvsp[(1) - (4)])->source_line, + _("`delete array' is a gawk extension")); + (yyvsp[(1) - (4)])->expr_count = 0; + (yyval) = list_append(list_create((yyvsp[(2) - (4)])), (yyvsp[(1) - (4)])); + } else { + (yyvsp[(1) - (4)])->expr_count = sub_counter; + (yyval) = list_append(list_append((yyvsp[(4) - (4)]), (yyvsp[(2) - (4)])), (yyvsp[(1) - (4)])); + } + } + break; + + case 61: + +/* Line 1806 of yacc.c */ +#line 1012 "awkgram.y" + { + static short warned = FALSE; + char *arr = (yyvsp[(3) - (4)])->lextok; + + if (do_lint && ! warned) { + warned = TRUE; + lintwarn_ln((yyvsp[(1) - (4)])->source_line, + _("`delete(array)' is a non-portable tawk extension")); + } + if (do_traditional) { + error_ln((yyvsp[(1) - (4)])->source_line, + _("`delete array' is a gawk extension")); + } + (yyvsp[(3) - (4)])->memory = variable(arr, Node_var_new); + (yyvsp[(3) - (4)])->opcode = Op_push_array; + (yyvsp[(1) - (4)])->expr_count = 0; + (yyval) = list_append(list_create((yyvsp[(3) - (4)])), (yyvsp[(1) - (4)])); + } + break; + + case 62: + +/* Line 1806 of yacc.c */ +#line 1031 "awkgram.y" + { (yyval) = optimize_assignment((yyvsp[(1) - (1)])); } + break; + + case 63: + +/* Line 1806 of yacc.c */ +#line 1036 "awkgram.y" + { (yyval) = NULL; } + break; + + case 64: + +/* Line 1806 of yacc.c */ +#line 1038 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 65: + +/* Line 1806 of yacc.c */ +#line 1043 "awkgram.y" + { (yyval) = NULL; } + break; + + case 66: + +/* Line 1806 of yacc.c */ +#line 1045 "awkgram.y" + { + if ((yyvsp[(1) - (2)]) == NULL) + (yyval) = list_create((yyvsp[(2) - (2)])); + else + (yyval) = list_prepend((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); + } + break; + + case 67: + +/* Line 1806 of yacc.c */ +#line 1052 "awkgram.y" + { (yyval) = NULL; } + break; + + case 68: + +/* Line 1806 of yacc.c */ +#line 1057 "awkgram.y" + { + INSTRUCTION *casestmt = (yyvsp[(5) - (5)]); + if ((yyvsp[(5) - (5)]) == NULL) + casestmt = list_create(instruction(Op_no_op)); + if (do_profiling) + (void) list_prepend(casestmt, instruction(Op_exec_count)); + (yyvsp[(1) - (5)])->case_exp = (yyvsp[(2) - (5)]); + (yyvsp[(1) - (5)])->case_stmt = casestmt; + bcfree((yyvsp[(3) - (5)])); + (yyval) = (yyvsp[(1) - (5)]); + } + break; + + case 69: + +/* Line 1806 of yacc.c */ +#line 1069 "awkgram.y" + { + INSTRUCTION *casestmt = (yyvsp[(4) - (4)]); + if ((yyvsp[(4) - (4)]) == NULL) + casestmt = list_create(instruction(Op_no_op)); + if (do_profiling) + (void) list_prepend(casestmt, instruction(Op_exec_count)); + bcfree((yyvsp[(2) - (4)])); + (yyvsp[(1) - (4)])->case_stmt = casestmt; + (yyval) = (yyvsp[(1) - (4)]); + } + break; + + case 70: + +/* Line 1806 of yacc.c */ +#line 1083 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 71: + +/* Line 1806 of yacc.c */ +#line 1085 "awkgram.y" + { + (yyvsp[(2) - (2)])->memory->numbr = -(force_number((yyvsp[(2) - (2)])->memory)); + bcfree((yyvsp[(1) - (2)])); + (yyval) = (yyvsp[(2) - (2)]); + } + break; + + case 72: + +/* Line 1806 of yacc.c */ +#line 1091 "awkgram.y" + { + bcfree((yyvsp[(1) - (2)])); + (yyval) = (yyvsp[(2) - (2)]); + } + break; + + case 73: + +/* Line 1806 of yacc.c */ +#line 1096 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 74: + +/* Line 1806 of yacc.c */ +#line 1098 "awkgram.y" + { + (yyvsp[(1) - (1)])->opcode = Op_push_re; + (yyval) = (yyvsp[(1) - (1)]); + } + break; + + case 75: + +/* Line 1806 of yacc.c */ +#line 1106 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 76: + +/* Line 1806 of yacc.c */ +#line 1108 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 78: + +/* Line 1806 of yacc.c */ +#line 1118 "awkgram.y" + { + (yyval) = (yyvsp[(2) - (3)]); + } + break; + + case 79: + +/* Line 1806 of yacc.c */ +#line 1125 "awkgram.y" + { + in_print = FALSE; + in_parens = 0; + (yyval) = NULL; + } + break; + + case 80: + +/* Line 1806 of yacc.c */ +#line 1130 "awkgram.y" + { in_print = FALSE; in_parens = 0; } + break; + + case 81: + +/* Line 1806 of yacc.c */ +#line 1131 "awkgram.y" + { + if ((yyvsp[(1) - (3)])->redir_type == redirect_twoway + && (yyvsp[(3) - (3)])->lasti->opcode == Op_K_getline_redir + && (yyvsp[(3) - (3)])->lasti->redir_type == redirect_twoway) + yyerror(_("multistage two-way pipelines don't work")); + (yyval) = list_prepend((yyvsp[(3) - (3)]), (yyvsp[(1) - (3)])); + } + break; + + case 82: + +/* Line 1806 of yacc.c */ +#line 1142 "awkgram.y" + { + (yyval) = mk_condition((yyvsp[(3) - (6)]), (yyvsp[(1) - (6)]), (yyvsp[(6) - (6)]), NULL, NULL); + } + break; + + case 83: + +/* Line 1806 of yacc.c */ +#line 1147 "awkgram.y" + { + (yyval) = mk_condition((yyvsp[(3) - (9)]), (yyvsp[(1) - (9)]), (yyvsp[(6) - (9)]), (yyvsp[(7) - (9)]), (yyvsp[(9) - (9)])); + } + break; + + case 88: + +/* Line 1806 of yacc.c */ +#line 1164 "awkgram.y" + { (yyval) = NULL; } + break; + + case 89: + +/* Line 1806 of yacc.c */ +#line 1166 "awkgram.y" + { + bcfree((yyvsp[(1) - (2)])); + (yyval) = (yyvsp[(2) - (2)]); + } + break; + + case 92: + +/* Line 1806 of yacc.c */ +#line 1179 "awkgram.y" + { + append_param((yyvsp[(1) - (1)])->lextok); + (yyvsp[(1) - (1)])->lextok = NULL; + bcfree((yyvsp[(1) - (1)])); + } + break; + + case 93: + +/* Line 1806 of yacc.c */ +#line 1185 "awkgram.y" + { + append_param((yyvsp[(3) - (3)])->lextok); + (yyvsp[(3) - (3)])->lextok = NULL; + bcfree((yyvsp[(3) - (3)])); + yyerrok; + } + break; + + case 94: + +/* Line 1806 of yacc.c */ +#line 1192 "awkgram.y" + { /* func_params = NULL; */ } + break; + + case 95: + +/* Line 1806 of yacc.c */ +#line 1194 "awkgram.y" + { /* func_params = NULL; */ } + break; + + case 96: + +/* Line 1806 of yacc.c */ +#line 1196 "awkgram.y" + { /* func_params = NULL; */ } + break; + + case 97: + +/* Line 1806 of yacc.c */ +#line 1202 "awkgram.y" + { (yyval) = NULL; } + break; + + case 98: + +/* Line 1806 of yacc.c */ +#line 1204 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 99: + +/* Line 1806 of yacc.c */ +#line 1209 "awkgram.y" + { (yyval) = NULL; } + break; + + case 100: + +/* Line 1806 of yacc.c */ +#line 1211 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 101: + +/* Line 1806 of yacc.c */ +#line 1216 "awkgram.y" + { (yyval) = mk_expression_list(NULL, (yyvsp[(1) - (1)])); } + break; + + case 102: + +/* Line 1806 of yacc.c */ +#line 1218 "awkgram.y" + { + (yyval) = mk_expression_list((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])); + yyerrok; + } + break; + + case 103: + +/* Line 1806 of yacc.c */ +#line 1223 "awkgram.y" + { (yyval) = NULL; } + break; + + case 104: + +/* Line 1806 of yacc.c */ +#line 1225 "awkgram.y" + { (yyval) = NULL; } + break; + + case 105: + +/* Line 1806 of yacc.c */ +#line 1227 "awkgram.y" + { (yyval) = NULL; } + break; + + case 106: + +/* Line 1806 of yacc.c */ +#line 1229 "awkgram.y" + { (yyval) = NULL; } + break; + + case 107: + +/* Line 1806 of yacc.c */ +#line 1235 "awkgram.y" + { + if (do_lint && (yyvsp[(3) - (3)])->lasti->opcode == Op_match_rec) + lintwarn_ln((yyvsp[(2) - (3)])->source_line, + _("regular expression on right of assignment")); + (yyval) = mk_assignment((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); + } + break; + + case 108: + +/* Line 1806 of yacc.c */ +#line 1242 "awkgram.y" + { (yyval) = mk_boolean((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } + break; + + case 109: + +/* Line 1806 of yacc.c */ +#line 1244 "awkgram.y" + { (yyval) = mk_boolean((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } + break; + + case 110: + +/* Line 1806 of yacc.c */ +#line 1246 "awkgram.y" + { + if ((yyvsp[(1) - (3)])->lasti->opcode == Op_match_rec) + warning_ln((yyvsp[(2) - (3)])->source_line, + _("regular expression on left of `~' or `!~' operator")); + + if ((yyvsp[(3) - (3)])->lasti == (yyvsp[(3) - (3)])->nexti && (yyvsp[(3) - (3)])->nexti->opcode == Op_match_rec) { + (yyvsp[(2) - (3)])->memory = (yyvsp[(3) - (3)])->nexti->memory; + bcfree((yyvsp[(3) - (3)])->nexti); /* Op_match_rec */ + bcfree((yyvsp[(3) - (3)])); /* Op_list */ + (yyval) = list_append((yyvsp[(1) - (3)]), (yyvsp[(2) - (3)])); + } else { + (yyvsp[(2) - (3)])->memory = make_regnode(Node_dynregex, NULL); + (yyval) = list_append(list_merge((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])), (yyvsp[(2) - (3)])); + } + } + break; + + case 111: + +/* Line 1806 of yacc.c */ +#line 1262 "awkgram.y" + { + if (do_lint_old) + warning_ln((yyvsp[(2) - (3)])->source_line, + _("old awk does not support the keyword `in' except after `for'")); + (yyvsp[(3) - (3)])->nexti->opcode = Op_push_array; + (yyvsp[(2) - (3)])->opcode = Op_in_array; + (yyvsp[(2) - (3)])->expr_count = 1; + (yyval) = list_append(list_merge((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])), (yyvsp[(2) - (3)])); + } + break; + + case 112: + +/* Line 1806 of yacc.c */ +#line 1272 "awkgram.y" + { + if (do_lint && (yyvsp[(3) - (3)])->lasti->opcode == Op_match_rec) + lintwarn_ln((yyvsp[(2) - (3)])->source_line, + _("regular expression on right of comparison")); + (yyval) = list_append(list_merge((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)])), (yyvsp[(2) - (3)])); + } + break; + + case 113: + +/* Line 1806 of yacc.c */ +#line 1279 "awkgram.y" + { (yyval) = mk_condition((yyvsp[(1) - (5)]), (yyvsp[(2) - (5)]), (yyvsp[(3) - (5)]), (yyvsp[(4) - (5)]), (yyvsp[(5) - (5)])); } + break; + + case 114: + +/* Line 1806 of yacc.c */ +#line 1281 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 115: + +/* Line 1806 of yacc.c */ +#line 1286 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 116: + +/* Line 1806 of yacc.c */ +#line 1288 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 117: + +/* Line 1806 of yacc.c */ +#line 1290 "awkgram.y" + { + (yyvsp[(2) - (2)])->opcode = Op_assign_quotient; + (yyval) = (yyvsp[(2) - (2)]); + } + break; + + case 118: + +/* Line 1806 of yacc.c */ +#line 1298 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 119: + +/* Line 1806 of yacc.c */ +#line 1300 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 120: + +/* Line 1806 of yacc.c */ +#line 1305 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 121: + +/* Line 1806 of yacc.c */ +#line 1307 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 122: + +/* Line 1806 of yacc.c */ +#line 1312 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 123: + +/* Line 1806 of yacc.c */ +#line 1314 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 124: + +/* Line 1806 of yacc.c */ +#line 1316 "awkgram.y" + { + int count = 2; + int is_simple_var = FALSE; + + if ((yyvsp[(1) - (2)])->lasti->opcode == Op_concat) { + /* multiple (> 2) adjacent strings optimization */ + is_simple_var = ((yyvsp[(1) - (2)])->lasti->concat_flag & CSVAR); + count = (yyvsp[(1) - (2)])->lasti->expr_count + 1; + (yyvsp[(1) - (2)])->lasti->opcode = Op_no_op; + } else { + is_simple_var = ((yyvsp[(1) - (2)])->nexti->opcode == Op_push + && (yyvsp[(1) - (2)])->lasti == (yyvsp[(1) - (2)])->nexti); /* first exp. is a simple + * variable?; kludge for use + * in Op_assign_concat. + */ + } + + if (do_optimize > 1 + && (yyvsp[(1) - (2)])->nexti == (yyvsp[(1) - (2)])->lasti && (yyvsp[(1) - (2)])->nexti->opcode == Op_push_i + && (yyvsp[(2) - (2)])->nexti == (yyvsp[(2) - (2)])->lasti && (yyvsp[(2) - (2)])->nexti->opcode == Op_push_i + ) { + NODE *n1 = (yyvsp[(1) - (2)])->nexti->memory; + NODE *n2 = (yyvsp[(2) - (2)])->nexti->memory; + size_t nlen; + + (void) force_string(n1); + (void) force_string(n2); + nlen = n1->stlen + n2->stlen; + erealloc(n1->stptr, char *, nlen + 2, "constant fold"); + memcpy(n1->stptr + n1->stlen, n2->stptr, n2->stlen); + n1->stlen = nlen; + n1->stptr[nlen] = '\0'; + n1->flags &= ~(NUMCUR|NUMBER); + n1->flags |= (STRING|STRCUR); + + n2->flags &= ~PERM; + n2->flags |= MALLOC; + unref(n2); + bcfree((yyvsp[(2) - (2)])->nexti); + bcfree((yyvsp[(2) - (2)])); + (yyval) = (yyvsp[(1) - (2)]); + } else { + (yyval) = list_append(list_merge((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])), instruction(Op_concat)); + (yyval)->lasti->concat_flag = (is_simple_var ? CSVAR : 0); + (yyval)->lasti->expr_count = count; + if (count > max_args) + max_args = count; + } + } + break; + + case 126: + +/* Line 1806 of yacc.c */ +#line 1371 "awkgram.y" + { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } + break; + + case 127: + +/* Line 1806 of yacc.c */ +#line 1373 "awkgram.y" + { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } + break; + + case 128: + +/* Line 1806 of yacc.c */ +#line 1375 "awkgram.y" + { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } + break; + + case 129: + +/* Line 1806 of yacc.c */ +#line 1377 "awkgram.y" + { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } + break; + + case 130: + +/* Line 1806 of yacc.c */ +#line 1379 "awkgram.y" + { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } + break; + + case 131: + +/* Line 1806 of yacc.c */ +#line 1381 "awkgram.y" + { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } + break; + + case 132: + +/* Line 1806 of yacc.c */ +#line 1383 "awkgram.y" + { + /* + * In BEGINFILE/ENDFILE, allow `getline var < file' + */ + + if (rule == BEGINFILE || rule == ENDFILE) { + if ((yyvsp[(2) - (3)]) != NULL && (yyvsp[(3) - (3)]) != NULL) + ; /* all ok */ + else { + if ((yyvsp[(2) - (3)]) != NULL) + error_ln((yyvsp[(1) - (3)])->source_line, + _("`getline var' invalid inside `%s' rule"), ruletab[rule]); + else + error_ln((yyvsp[(1) - (3)])->source_line, + _("`getline' invalid inside `%s' rule"), ruletab[rule]); + } + } + if (do_lint && rule == END && (yyvsp[(3) - (3)]) == NULL) + lintwarn_ln((yyvsp[(1) - (3)])->source_line, + _("non-redirected `getline' undefined inside END action")); + (yyval) = mk_getline((yyvsp[(1) - (3)]), (yyvsp[(2) - (3)]), (yyvsp[(3) - (3)]), redirect_input); + } + break; + + case 133: + +/* Line 1806 of yacc.c */ +#line 1406 "awkgram.y" + { + (yyvsp[(2) - (2)])->opcode = Op_postincrement; + (yyval) = mk_assignment((yyvsp[(1) - (2)]), NULL, (yyvsp[(2) - (2)])); + } + break; + + case 134: + +/* Line 1806 of yacc.c */ +#line 1411 "awkgram.y" + { + (yyvsp[(2) - (2)])->opcode = Op_postdecrement; + (yyval) = mk_assignment((yyvsp[(1) - (2)]), NULL, (yyvsp[(2) - (2)])); + } + break; + + case 135: + +/* Line 1806 of yacc.c */ +#line 1416 "awkgram.y" + { + if (do_lint_old) { + warning_ln((yyvsp[(4) - (5)])->source_line, + _("old awk does not support the keyword `in' except after `for'")); + warning_ln((yyvsp[(4) - (5)])->source_line, + _("old awk does not support multidimensional arrays")); + } + (yyvsp[(5) - (5)])->nexti->opcode = Op_push_array; + (yyvsp[(4) - (5)])->opcode = Op_in_array; + if ((yyvsp[(2) - (5)]) == NULL) { /* error */ + errcount++; + (yyvsp[(4) - (5)])->expr_count = 0; + (yyval) = list_merge((yyvsp[(5) - (5)]), (yyvsp[(4) - (5)])); + } else { + INSTRUCTION *t = (yyvsp[(2) - (5)]); + (yyvsp[(4) - (5)])->expr_count = count_expressions(&t, FALSE); + (yyval) = list_append(list_merge(t, (yyvsp[(5) - (5)])), (yyvsp[(4) - (5)])); + } + } + break; + + case 136: + +/* Line 1806 of yacc.c */ +#line 1441 "awkgram.y" + { + (yyval) = mk_getline((yyvsp[(3) - (4)]), (yyvsp[(4) - (4)]), (yyvsp[(1) - (4)]), (yyvsp[(2) - (4)])->redir_type); + bcfree((yyvsp[(2) - (4)])); + } + break; + + case 137: + +/* Line 1806 of yacc.c */ +#line 1447 "awkgram.y" + { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } + break; + + case 138: + +/* Line 1806 of yacc.c */ +#line 1449 "awkgram.y" + { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } + break; + + case 139: + +/* Line 1806 of yacc.c */ +#line 1451 "awkgram.y" + { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } + break; + + case 140: + +/* Line 1806 of yacc.c */ +#line 1453 "awkgram.y" + { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } + break; + + case 141: + +/* Line 1806 of yacc.c */ +#line 1455 "awkgram.y" + { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } + break; + + case 142: + +/* Line 1806 of yacc.c */ +#line 1457 "awkgram.y" + { (yyval) = mk_binary((yyvsp[(1) - (3)]), (yyvsp[(3) - (3)]), (yyvsp[(2) - (3)])); } + break; + + case 143: + +/* Line 1806 of yacc.c */ +#line 1462 "awkgram.y" + { + (yyval) = list_create((yyvsp[(1) - (1)])); + } + break; + + case 144: + +/* Line 1806 of yacc.c */ +#line 1466 "awkgram.y" + { + if ((yyvsp[(2) - (2)])->opcode == Op_match_rec) { + (yyvsp[(2) - (2)])->opcode = Op_nomatch; + (yyvsp[(1) - (2)])->opcode = Op_push_i; + (yyvsp[(1) - (2)])->memory = mk_number(0.0, (PERM|NUMCUR|NUMBER)); + (yyval) = list_append(list_append(list_create((yyvsp[(1) - (2)])), + instruction(Op_field_spec)), (yyvsp[(2) - (2)])); + } else { + if (do_optimize > 1 && (yyvsp[(2) - (2)])->nexti == (yyvsp[(2) - (2)])->lasti + && (yyvsp[(2) - (2)])->nexti->opcode == Op_push_i + ) { + NODE *n = (yyvsp[(2) - (2)])->nexti->memory; + if ((n->flags & (STRCUR|STRING)) != 0) { + n->numbr = (AWKNUM) (n->stlen == 0); + n->flags &= ~(STRCUR|STRING); + n->flags |= (NUMCUR|NUMBER); + efree(n->stptr); + n->stptr = NULL; + n->stlen = 0; + } else + n->numbr = (AWKNUM) (n->numbr == 0.0); + bcfree((yyvsp[(1) - (2)])); + (yyval) = (yyvsp[(2) - (2)]); + } else { + (yyvsp[(1) - (2)])->opcode = Op_not; + add_lint((yyvsp[(2) - (2)]), LINT_assign_in_cond); + (yyval) = list_append((yyvsp[(2) - (2)]), (yyvsp[(1) - (2)])); + } + } + } + break; + + case 145: + +/* Line 1806 of yacc.c */ +#line 1497 "awkgram.y" + { (yyval) = (yyvsp[(2) - (3)]); } + break; + + case 146: + +/* Line 1806 of yacc.c */ +#line 1499 "awkgram.y" + { + (yyval) = snode((yyvsp[(3) - (4)]), (yyvsp[(1) - (4)])); + if ((yyval) == NULL) + YYABORT; + } + break; + + case 147: + +/* Line 1806 of yacc.c */ +#line 1505 "awkgram.y" + { + (yyval) = snode((yyvsp[(3) - (4)]), (yyvsp[(1) - (4)])); + if ((yyval) == NULL) + YYABORT; + } + break; + + case 148: + +/* Line 1806 of yacc.c */ +#line 1511 "awkgram.y" + { + static short warned1 = FALSE; + + if (do_lint && ! warned1) { + warned1 = TRUE; + lintwarn_ln((yyvsp[(1) - (1)])->source_line, + _("call of `length' without parentheses is not portable")); + } + (yyval) = snode(NULL, (yyvsp[(1) - (1)])); + if ((yyval) == NULL) + YYABORT; + } + break; + + case 151: + +/* Line 1806 of yacc.c */ +#line 1526 "awkgram.y" + { + (yyvsp[(1) - (2)])->opcode = Op_preincrement; + (yyval) = mk_assignment((yyvsp[(2) - (2)]), NULL, (yyvsp[(1) - (2)])); + } + break; + + case 152: + +/* Line 1806 of yacc.c */ +#line 1531 "awkgram.y" + { + (yyvsp[(1) - (2)])->opcode = Op_predecrement; + (yyval) = mk_assignment((yyvsp[(2) - (2)]), NULL, (yyvsp[(1) - (2)])); + } + break; + + case 153: + +/* Line 1806 of yacc.c */ +#line 1536 "awkgram.y" + { + (yyval) = list_create((yyvsp[(1) - (1)])); + } + break; + + case 154: + +/* Line 1806 of yacc.c */ +#line 1540 "awkgram.y" + { + (yyval) = list_create((yyvsp[(1) - (1)])); + } + break; + + case 155: + +/* Line 1806 of yacc.c */ +#line 1544 "awkgram.y" + { + if ((yyvsp[(2) - (2)])->lasti->opcode == Op_push_i + && ((yyvsp[(2) - (2)])->lasti->memory->flags & (STRCUR|STRING)) == 0) { + (yyvsp[(2) - (2)])->lasti->memory->numbr = -(force_number((yyvsp[(2) - (2)])->lasti->memory)); + (yyval) = (yyvsp[(2) - (2)]); + bcfree((yyvsp[(1) - (2)])); + } else { + (yyvsp[(1) - (2)])->opcode = Op_unary_minus; + (yyval) = list_append((yyvsp[(2) - (2)]), (yyvsp[(1) - (2)])); + } + } + break; + + case 156: + +/* Line 1806 of yacc.c */ +#line 1556 "awkgram.y" + { + /* + * was: $$ = $2 + * POSIX semantics: force a conversion to numeric type + */ + (yyvsp[(1) - (2)])->opcode = Op_plus_i; + (yyvsp[(1) - (2)])->memory = mk_number((AWKNUM) 0.0, (PERM|NUMCUR|NUMBER)); + (yyval) = list_append((yyvsp[(2) - (2)]), (yyvsp[(1) - (2)])); + } + break; + + case 157: + +/* Line 1806 of yacc.c */ +#line 1569 "awkgram.y" + { + func_use((yyvsp[(1) - (1)])->lasti->func_name, FUNC_USE); + (yyval) = (yyvsp[(1) - (1)]); + } + break; + + case 158: + +/* Line 1806 of yacc.c */ +#line 1574 "awkgram.y" + { + /* indirect function call */ + INSTRUCTION *f, *t; + char *name; + NODE *indirect_var; + static short warned = FALSE; + const char *msg = _("indirect function calls are a gawk extension"); + + if (do_traditional || do_posix) + yyerror("%s", msg); + else if (do_lint && ! warned) { + warned = TRUE; + lintwarn("%s", msg); + } + + f = (yyvsp[(2) - (2)])->lasti; + f->opcode = Op_indirect_func_call; + name = estrdup(f->func_name, strlen(f->func_name)); + if (is_std_var(name)) + yyerror(_("can not use special variable `%s' for indirect function call"), name); + indirect_var = variable(name, Node_var_new); + t = instruction(Op_push); + t->memory = indirect_var; + + /* prepend indirect var instead of appending to arguments (opt_expression_list), + * and pop it off in setup_frame (eval.c) (left to right evaluation order); Test case: + * f = "fun" + * @f(f="real_fun") + */ + + (yyval) = list_prepend((yyvsp[(2) - (2)]), t); + } + break; + + case 159: + +/* Line 1806 of yacc.c */ +#line 1610 "awkgram.y" + { + param_sanity((yyvsp[(3) - (4)])); + (yyvsp[(1) - (4)])->opcode = Op_func_call; + (yyvsp[(1) - (4)])->func_body = NULL; + if ((yyvsp[(3) - (4)]) == NULL) { /* no argument or error */ + ((yyvsp[(1) - (4)]) + 1)->expr_count = 0; + (yyval) = list_create((yyvsp[(1) - (4)])); + } else { + INSTRUCTION *t = (yyvsp[(3) - (4)]); + ((yyvsp[(1) - (4)]) + 1)->expr_count = count_expressions(&t, TRUE); + (yyval) = list_append(t, (yyvsp[(1) - (4)])); + } + } + break; + + case 160: + +/* Line 1806 of yacc.c */ +#line 1627 "awkgram.y" + { (yyval) = NULL; } + break; + + case 161: + +/* Line 1806 of yacc.c */ +#line 1629 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 162: + +/* Line 1806 of yacc.c */ +#line 1634 "awkgram.y" + { (yyval) = NULL; } + break; + + case 163: + +/* Line 1806 of yacc.c */ +#line 1636 "awkgram.y" + { (yyval) = (yyvsp[(1) - (2)]); } + break; + + case 164: + +/* Line 1806 of yacc.c */ +#line 1641 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 165: + +/* Line 1806 of yacc.c */ +#line 1643 "awkgram.y" + { + (yyval) = list_merge((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); + } + break; + + case 166: + +/* Line 1806 of yacc.c */ +#line 1650 "awkgram.y" + { + INSTRUCTION *ip = (yyvsp[(1) - (1)])->lasti; + int count = ip->sub_count; /* # of SUBSEP-seperated expressions */ + if (count > 1) { + /* change Op_subscript or Op_sub_array to Op_concat */ + ip->opcode = Op_concat; + ip->concat_flag = CSUBSEP; + ip->expr_count = count; + } else + ip->opcode = Op_no_op; + sub_counter++; /* count # of dimensions */ + (yyval) = (yyvsp[(1) - (1)]); + } + break; + + case 167: + +/* Line 1806 of yacc.c */ +#line 1667 "awkgram.y" + { + INSTRUCTION *t = (yyvsp[(2) - (3)]); + if ((yyvsp[(2) - (3)]) == NULL) { + error_ln((yyvsp[(3) - (3)])->source_line, + _("invalid subscript expression")); + /* install Null string as subscript. */ + t = list_create(instruction(Op_push_i)); + t->nexti->memory = Nnull_string; + (yyvsp[(3) - (3)])->sub_count = 1; + } else + (yyvsp[(3) - (3)])->sub_count = count_expressions(&t, FALSE); + (yyval) = list_append(t, (yyvsp[(3) - (3)])); + } + break; + + case 168: + +/* Line 1806 of yacc.c */ +#line 1684 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 169: + +/* Line 1806 of yacc.c */ +#line 1686 "awkgram.y" + { + (yyval) = list_merge((yyvsp[(1) - (2)]), (yyvsp[(2) - (2)])); + } + break; + + case 170: + +/* Line 1806 of yacc.c */ +#line 1693 "awkgram.y" + { (yyval) = (yyvsp[(1) - (2)]); } + break; + + case 171: + +/* Line 1806 of yacc.c */ +#line 1698 "awkgram.y" + { + char *var_name = (yyvsp[(1) - (1)])->lextok; + + (yyvsp[(1) - (1)])->opcode = Op_push; + (yyvsp[(1) - (1)])->memory = variable(var_name, Node_var_new); + (yyval) = list_create((yyvsp[(1) - (1)])); + } + break; + + case 172: + +/* Line 1806 of yacc.c */ +#line 1706 "awkgram.y" + { + NODE *n; + + char *arr = (yyvsp[(1) - (2)])->lextok; + if ((n = lookup(arr)) != NULL && ! isarray(n)) + yyerror(_("use of non-array as array")); + (yyvsp[(1) - (2)])->memory = variable(arr, Node_var_new); + (yyvsp[(1) - (2)])->opcode = Op_push_array; + (yyval) = list_prepend((yyvsp[(2) - (2)]), (yyvsp[(1) - (2)])); + } + break; + + case 173: + +/* Line 1806 of yacc.c */ +#line 1720 "awkgram.y" + { + INSTRUCTION *ip = (yyvsp[(1) - (1)])->nexti; + if (ip->opcode == Op_push + && ip->memory->type == Node_var + && ip->memory->var_update + ) { + (yyval) = list_prepend((yyvsp[(1) - (1)]), instruction(Op_var_update)); + (yyval)->nexti->update_var = ip->memory->var_update; + } else + (yyval) = (yyvsp[(1) - (1)]); + } + break; + + case 174: + +/* Line 1806 of yacc.c */ +#line 1732 "awkgram.y" + { + (yyval) = list_append((yyvsp[(2) - (3)]), (yyvsp[(1) - (3)])); + if ((yyvsp[(3) - (3)]) != NULL) + mk_assignment((yyvsp[(2) - (3)]), NULL, (yyvsp[(3) - (3)])); + } + break; + + case 175: + +/* Line 1806 of yacc.c */ +#line 1741 "awkgram.y" + { + (yyvsp[(1) - (1)])->opcode = Op_postincrement; + } + break; + + case 176: + +/* Line 1806 of yacc.c */ +#line 1745 "awkgram.y" + { + (yyvsp[(1) - (1)])->opcode = Op_postdecrement; + } + break; + + case 177: + +/* Line 1806 of yacc.c */ +#line 1748 "awkgram.y" + { (yyval) = NULL; } + break; + + case 179: + +/* Line 1806 of yacc.c */ +#line 1756 "awkgram.y" + { yyerrok; } + break; + + case 180: + +/* Line 1806 of yacc.c */ +#line 1760 "awkgram.y" + { yyerrok; } + break; + + case 183: + +/* Line 1806 of yacc.c */ +#line 1769 "awkgram.y" + { yyerrok; } + break; + + case 184: + +/* Line 1806 of yacc.c */ +#line 1773 "awkgram.y" + { (yyval) = (yyvsp[(1) - (1)]); yyerrok; } + break; + + case 185: + +/* Line 1806 of yacc.c */ +#line 1777 "awkgram.y" + { yyerrok; } + break; + + + +/* Line 1806 of yacc.c */ +#line 4250 "awkgram.c" + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) + { + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; + } +# undef YYSYNTAX_ERROR +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined(yyoverflow) || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + + +/* Line 2067 of yacc.c */ +#line 1779 "awkgram.y" + + +struct token { + const char *operator; /* text to match */ + OPCODE value; /* type */ + int class; /* lexical class */ + unsigned flags; /* # of args. allowed and compatability */ +# define ARGS 0xFF /* 0, 1, 2, 3 args allowed (any combination */ +# define A(n) (1<<(n)) +# define VERSION_MASK 0xFF00 /* old awk is zero */ +# define NOT_OLD 0x0100 /* feature not in old awk */ +# define NOT_POSIX 0x0200 /* feature not in POSIX */ +# define GAWKX 0x0400 /* gawk extension */ +# define RESX 0x0800 /* Bell Labs Research extension */ +# define BREAK 0x1000 /* break allowed inside */ +# define CONTINUE 0x2000 /* continue allowed inside */ + + NODE *(*ptr)(int); /* function that implements this keyword */ +}; + +#if 'a' == 0x81 /* it's EBCDIC */ +/* tokcompare --- lexicographically compare token names for sorting */ + +static int +tokcompare(const void *l, const void *r) +{ + struct token *lhs, *rhs; + + lhs = (struct token *) l; + rhs = (struct token *) r; + + return strcmp(lhs->operator, rhs->operator); +} +#endif + +/* + * Tokentab is sorted ASCII ascending order, so it can be binary searched. + * See check_special(), which sorts the table on EBCDIC systems. + * Function pointers come from declarations in awk.h. + */ + +static const struct token tokentab[] = { +{"BEGIN", Op_rule, LEX_BEGIN, 0, 0}, +{"BEGINFILE", Op_rule, LEX_BEGINFILE, GAWKX, 0}, +{"END", Op_rule, LEX_END, 0, 0}, +{"ENDFILE", Op_rule, LEX_ENDFILE, GAWKX, 0}, +#ifdef ARRAYDEBUG +{"adump", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_adump}, +#endif +{"and", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_and}, +{"asort", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3), do_asort}, +{"asorti", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3), do_asorti}, +{"atan2", Op_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_atan2}, +{"bindtextdomain", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2), do_bindtextdomain}, +{"break", Op_K_break, LEX_BREAK, 0, 0}, +{"case", Op_K_case, LEX_CASE, GAWKX, 0}, +{"close", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1)|A(2), do_close}, +{"compl", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_compl}, +{"continue", Op_K_continue, LEX_CONTINUE, 0, 0}, +{"cos", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_cos}, +{"dcgettext", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3), do_dcgettext}, +{"dcngettext", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3)|A(4)|A(5), do_dcngettext}, +{"default", Op_K_default, LEX_DEFAULT, GAWKX, 0}, +{"delete", Op_K_delete, LEX_DELETE, NOT_OLD, 0}, +{"do", Op_K_do, LEX_DO, NOT_OLD|BREAK|CONTINUE, 0}, +{"else", Op_K_else, LEX_ELSE, 0, 0}, +{"eval", Op_symbol, LEX_EVAL, 0, 0}, +{"exit", Op_K_exit, LEX_EXIT, 0, 0}, +{"exp", Op_builtin, LEX_BUILTIN, A(1), do_exp}, +{"extension", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_ext}, +{"fflush", Op_builtin, LEX_BUILTIN, RESX|A(0)|A(1), do_fflush}, +{"for", Op_K_for, LEX_FOR, BREAK|CONTINUE, 0}, +{"func", Op_func, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0}, +{"function",Op_func, LEX_FUNCTION, NOT_OLD, 0}, +{"gensub", Op_sub_builtin, LEX_BUILTIN, GAWKX|A(3)|A(4), 0}, +{"getline", Op_K_getline_redir, LEX_GETLINE, NOT_OLD, 0}, +{"gsub", Op_sub_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), 0}, +{"if", Op_K_if, LEX_IF, 0, 0}, +{"in", Op_symbol, LEX_IN, 0, 0}, +{"include", Op_symbol, LEX_INCLUDE, GAWKX, 0}, +{"index", Op_builtin, LEX_BUILTIN, A(2), do_index}, +{"int", Op_builtin, LEX_BUILTIN, A(1), do_int}, +{"isarray", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_isarray}, +{"length", Op_builtin, LEX_LENGTH, A(0)|A(1), do_length}, +{"log", Op_builtin, LEX_BUILTIN, A(1), do_log}, +{"lshift", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_lshift}, +{"match", Op_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_match}, +{"mktime", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_mktime}, +{"next", Op_K_next, LEX_NEXT, 0, 0}, +{"nextfile", Op_K_nextfile, LEX_NEXTFILE, GAWKX, 0}, +{"or", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_or}, +{"patsplit", Op_builtin, LEX_BUILTIN, GAWKX|A(2)|A(3)|A(4), do_patsplit}, +{"print", Op_K_print, LEX_PRINT, 0, 0}, +{"printf", Op_K_printf, LEX_PRINTF, 0, 0}, +{"rand", Op_builtin, LEX_BUILTIN, NOT_OLD|A(0), do_rand}, +{"return", Op_K_return, LEX_RETURN, NOT_OLD, 0}, +{"rshift", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_rshift}, +{"sin", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_sin}, +{"split", Op_builtin, LEX_BUILTIN, A(2)|A(3)|A(4), do_split}, +{"sprintf", Op_builtin, LEX_BUILTIN, 0, do_sprintf}, +{"sqrt", Op_builtin, LEX_BUILTIN, A(1), do_sqrt}, +{"srand", Op_builtin, LEX_BUILTIN, NOT_OLD|A(0)|A(1), do_srand}, +#if defined(GAWKDEBUG) || defined(ARRAYDEBUG) /* || ... */ +{"stopme", Op_builtin, LEX_BUILTIN, GAWKX|A(0), stopme}, +#endif +{"strftime", Op_builtin, LEX_BUILTIN, GAWKX|A(0)|A(1)|A(2)|A(3), do_strftime}, +{"strtonum", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_strtonum}, +{"sub", Op_sub_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), 0}, +{"substr", Op_builtin, LEX_BUILTIN, A(2)|A(3), do_substr}, +{"switch", Op_K_switch, LEX_SWITCH, GAWKX|BREAK, 0}, +{"system", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_system}, +{"systime", Op_builtin, LEX_BUILTIN, GAWKX|A(0), do_systime}, +{"tolower", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_tolower}, +{"toupper", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_toupper}, +{"while", Op_K_while, LEX_WHILE, BREAK|CONTINUE, 0}, +{"xor", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_xor}, +}; + +#if MBS_SUPPORT +/* Variable containing the current shift state. */ +static mbstate_t cur_mbstate; +/* Ring buffer containing current characters. */ +#define MAX_CHAR_IN_RING_BUFFER 8 +#define RING_BUFFER_SIZE (MAX_CHAR_IN_RING_BUFFER * MB_LEN_MAX) +static char cur_char_ring[RING_BUFFER_SIZE]; +/* Index for ring buffers. */ +static int cur_ring_idx; +/* This macro means that last nextc() return a singlebyte character + or 1st byte of a multibyte character. */ +#define nextc_is_1stbyte (cur_char_ring[cur_ring_idx] == 1) +#else /* MBS_SUPPORT */ +/* a dummy */ +#define nextc_is_1stbyte 1 +#endif /* MBS_SUPPORT */ + +/* getfname --- return name of a builtin function (for pretty printing) */ + +const char * +getfname(NODE *(*fptr)(int)) +{ + int i, j; + + j = sizeof(tokentab) / sizeof(tokentab[0]); + /* linear search, no other way to do it */ + for (i = 0; i < j; i++) + if (tokentab[i].ptr == fptr) + return tokentab[i].operator; + + return NULL; +} + +/* print_included_from --- print `Included from ..' file names and locations */ + +static void +print_included_from() +{ + int saveline, line; + SRCFILE *s; + + /* suppress current file name, line # from `.. included from ..' msgs */ + saveline = sourceline; + sourceline = 0; + + for (s = sourcefile; s != NULL && s->stype == SRC_INC; ) { + s = s->next; + if (s == NULL || s->fd <= INVALID_HANDLE) + continue; + line = s->srclines; + + /* if last token is NEWLINE, line number is off by 1. */ + if (s->lasttok == NEWLINE) + line--; + msg("%s %s:%d%c", + s->prev == sourcefile ? "In file included from" + : " from", + (s->stype == SRC_INC || + s->stype == SRC_FILE) ? s->src : "cmd. line", + line, + s->stype == SRC_INC ? ',' : ':' + ); + } + sourceline = saveline; +} + +/* warning_ln --- print a warning message with location */ + +static void +warning_ln(int line, const char *mesg, ...) +{ + va_list args; + int saveline; + + saveline = sourceline; + sourceline = line; + print_included_from(); + va_start(args, mesg); + err(_("warning: "), mesg, args); + va_end(args); + sourceline = saveline; +} + +/* lintwarn_ln --- print a lint warning and location */ + +static void +lintwarn_ln(int line, const char *mesg, ...) +{ + va_list args; + int saveline; + + saveline = sourceline; + sourceline = line; + print_included_from(); + va_start(args, mesg); + if (lintfunc == r_fatal) + err(_("fatal: "), mesg, args); + else + err(_("warning: "), mesg, args); + va_end(args); + sourceline = saveline; + if (lintfunc == r_fatal) + gawk_exit(EXIT_FATAL); +} + +/* error_ln --- print an error message and location */ + +static void +error_ln(int line, const char *m, ...) +{ + va_list args; + int saveline; + + saveline = sourceline; + sourceline = line; + print_included_from(); + errcount++; + va_start(args, m); + err("error: ", m, args); + va_end(args); + sourceline = saveline; +} + +/* yyerror --- print a syntax error message, show where */ + +static void +yyerror(const char *m, ...) +{ + va_list args; + const char *mesg = NULL; + char *bp, *cp; + char *scan; + char *buf; + int count; + static char end_of_file_line[] = "(END OF FILE)"; + char save; + + print_included_from(); + + errcount++; + /* Find the current line in the input file */ + if (lexptr && lexeme) { + if (thisline == NULL) { + cp = lexeme; + if (*cp == '\n') { + cp--; + mesg = _("unexpected newline or end of string"); + } + for (; cp != lexptr_begin && *cp != '\n'; --cp) + continue; + if (*cp == '\n') + cp++; + thisline = cp; + } + /* NL isn't guaranteed */ + bp = lexeme; + while (bp < lexend && *bp && *bp != '\n') + bp++; + } else { + thisline = end_of_file_line; + bp = thisline + strlen(thisline); + } + + /* + * Saving and restoring *bp keeps valgrind happy, + * since the guts of glibc uses strlen, even though + * we're passing an explict precision. Sigh. + * + * 8/2003: We may not need this anymore. + */ + save = *bp; + *bp = '\0'; + + msg("%.*s", (int) (bp - thisline), thisline); + + *bp = save; + va_start(args, m); + if (mesg == NULL) + mesg = m; + + count = (bp - thisline) + strlen(mesg) + 2 + 1; + emalloc(buf, char *, count, "yyerror"); + + bp = buf; + + if (lexptr != NULL) { + scan = thisline; + while (scan < lexeme) + if (*scan++ == '\t') + *bp++ = '\t'; + else + *bp++ = ' '; + *bp++ = '^'; + *bp++ = ' '; + } + strcpy(bp, mesg); + err("", buf, args); + va_end(args); + efree(buf); +} + +/* mk_program --- create a single list of instructions */ + +static INSTRUCTION * +mk_program() +{ + INSTRUCTION *cp, *tmp; + +#define begin_block rule_block[BEGIN] +#define end_block rule_block[END] +#define prog_block rule_block[Rule] +#define beginfile_block rule_block[BEGINFILE] +#define endfile_block rule_block[ENDFILE] + + if (end_block == NULL) + end_block = list_create(ip_end); + else + (void) list_prepend(end_block, ip_end); + + if (! in_main_context()) { + if (begin_block != NULL && prog_block != NULL) + cp = list_merge(begin_block, prog_block); + else + cp = (begin_block != NULL) ? begin_block : prog_block; + + if (cp != NULL) + (void) list_merge(cp, end_block); + else + cp = end_block; + + (void) list_append(cp, instruction(Op_stop)); + goto out; + } + + if (endfile_block == NULL) + endfile_block = list_create(ip_endfile); + else { + ip_rec->has_endfile = TRUE; + (void) list_prepend(endfile_block, ip_endfile); + } + + if (beginfile_block == NULL) + beginfile_block = list_create(ip_beginfile); + else + (void) list_prepend(beginfile_block, ip_beginfile); + + if (prog_block == NULL) { + if (end_block->nexti == end_block->lasti + && beginfile_block->nexti == beginfile_block->lasti + && endfile_block->nexti == endfile_block->lasti + ) { + /* no pattern-action and (real) end, beginfile or endfile blocks */ + bcfree(ip_rec); + bcfree(ip_newfile); + ip_rec = ip_newfile = NULL; + + list_append(beginfile_block, instruction(Op_after_beginfile)); + (void) list_append(endfile_block, instruction(Op_after_endfile)); + + if (begin_block == NULL) /* no program at all */ + cp = end_block; + else + cp = list_merge(begin_block, end_block); + (void) list_append(cp, ip_atexit); + (void) list_append(cp, instruction(Op_stop)); + + /* append beginfile_block and endfile_block for sole use + * in getline without redirection (Op_K_getline). + */ + + (void) list_merge(cp, beginfile_block); + (void) list_merge(cp, endfile_block); + + goto out; + + } else { + /* install a do-nothing prog block */ + prog_block = list_create(instruction(Op_no_op)); + } + } + + (void) list_append(endfile_block, instruction(Op_after_endfile)); + (void) list_prepend(prog_block, ip_rec); + (void) list_append(prog_block, instruction(Op_jmp)); + prog_block->lasti->target_jmp = ip_rec; + + list_append(beginfile_block, instruction(Op_after_beginfile)); + + cp = list_merge(beginfile_block, prog_block); + (void) list_prepend(cp, ip_newfile); + (void) list_merge(cp, endfile_block); + (void) list_merge(cp, end_block); + if (begin_block != NULL) + cp = list_merge(begin_block, cp); + + (void) list_append(cp, ip_atexit); + (void) list_append(cp, instruction(Op_stop)); + +out: + /* delete the Op_list, not needed */ + tmp = cp->nexti; + bcfree(cp); + return tmp; + +#undef begin_block +#undef end_block +#undef prog_block +#undef beginfile_block +#undef endfile_block +} + +/* parse_program --- read in the program and convert into a list of instructions */ + +int +parse_program(INSTRUCTION **pcode) +{ + int ret; + + /* pre-create non-local jump targets + * ip_end (Op_no_op) -- used as jump target for `exit' + * outside an END block. + */ + ip_end = instruction(Op_no_op); + + if (! in_main_context()) + ip_newfile = ip_rec = ip_atexit = ip_beginfile = ip_endfile = NULL; + else { + ip_endfile = instruction(Op_no_op); + ip_beginfile = instruction(Op_no_op); + ip_rec = instruction(Op_get_record); /* target for `next', also ip_newfile */ + ip_newfile = bcalloc(Op_newfile, 2, 0); /* target for `nextfile' */ + ip_newfile->target_jmp = ip_end; + ip_newfile->target_endfile = ip_endfile; + (ip_newfile + 1)->target_get_record = ip_rec; + ip_rec->target_newfile = ip_newfile; + ip_atexit = instruction(Op_atexit); /* target for `exit' in END block */ + } + + sourcefile = srcfiles->next; + lexeof = FALSE; + lexptr = NULL; + lasttok = 0; + memset(rule_block, 0, sizeof(ruletab) * sizeof(INSTRUCTION *)); + errcount = 0; + tok = tokstart != NULL ? tokstart : tokexpand(); + + ret = yyparse(); + *pcode = mk_program(); + + /* avoid false source indications */ + source = NULL; + sourceline = 0; + if (ret == 0) /* avoid spurious warning if parser aborted with YYABORT */ + check_funcs(); + + return (ret || errcount); +} + +/* do_add_srcfile --- add one item to srcfiles */ + +static SRCFILE * +do_add_srcfile(int stype, char *src, char *path, SRCFILE *thisfile) +{ + SRCFILE *s; + + emalloc(s, SRCFILE *, sizeof(SRCFILE), "do_add_srcfile"); + memset(s, 0, sizeof(SRCFILE)); + s->src = estrdup(src, strlen(src)); + s->fullpath = path; + s->stype = stype; + s->fd = INVALID_HANDLE; + s->next = thisfile; + s->prev = thisfile->prev; + thisfile->prev->next = s; + thisfile->prev = s; + return s; +} + +/* add_srcfile --- add one item to srcfiles after checking if + * a source file exists and not already in list. + */ + +SRCFILE * +add_srcfile(int stype, char *src, SRCFILE *thisfile, int *already_included, int *errcode) +{ + SRCFILE *s; + struct stat sbuf; + char *path; + int errno_val = 0; + + if (already_included) + *already_included = FALSE; + if (errcode) + *errcode = 0; + if (stype == SRC_CMDLINE || stype == SRC_STDIN) + return do_add_srcfile(stype, src, NULL, thisfile); + + path = find_source(src, &sbuf, &errno_val); + if (path == NULL) { + if (errcode) { + *errcode = errno_val; + return NULL; + } + fatal(_("can't open source file `%s' for reading (%s)"), + src, errno_val ? strerror(errno_val) : _("reason unknown")); + } + + for (s = srcfiles->next; s != srcfiles; s = s->next) { + if ((s->stype == SRC_FILE || s->stype == SRC_INC) + && files_are_same(path, s) + ) { + if (do_lint) { + int line = sourceline; + /* Kludge: the line number may be off for `@include file'. + * Since, this function is also used for '-f file' in main.c, + * sourceline > 1 check ensures that the call is at + * parse time. + */ + if (sourceline > 1 && lasttok == NEWLINE) + line--; + lintwarn_ln(line, _("already included source file `%s'"), src); + } + efree(path); + if (already_included) + *already_included = TRUE; + return NULL; + } + } + + s = do_add_srcfile(stype, src, path, thisfile); + s->sbuf = sbuf; + s->mtime = sbuf.st_mtime; + return s; +} + +/* include_source --- read program from source included using `@include' */ + +static int +include_source(INSTRUCTION *file) +{ + SRCFILE *s; + char *src = file->lextok; + int errcode; + int already_included; + + if (do_traditional || do_posix) { + error_ln(file->source_line, _("@include is a gawk extension")); + return -1; + } + + if (strlen(src) == 0) { + if (do_lint) + lintwarn_ln(file->source_line, _("empty filename after @include")); + return 0; + } + + s = add_srcfile(SRC_INC, src, sourcefile, &already_included, &errcode); + if (s == NULL) { + if (already_included) + return 0; + error_ln(file->source_line, + _("can't open source file `%s' for reading (%s)"), + src, errcode ? strerror(errcode) : _("reason unknown")); + return -1; + } + + /* save scanner state for the current sourcefile */ + sourcefile->srclines = sourceline; + sourcefile->lexptr = lexptr; + sourcefile->lexend = lexend; + sourcefile->lexptr_begin = lexptr_begin; + sourcefile->lexeme = lexeme; + sourcefile->lasttok = lasttok; + + /* included file becomes the current source */ + sourcefile = s; + lexptr = NULL; + sourceline = 0; + source = NULL; + lasttok = 0; + lexeof = FALSE; + eof_warned = FALSE; + return 0; +} + +/* next_sourcefile --- read program from the next source in srcfiles */ + +static void +next_sourcefile() +{ + static int (*closefunc)(int fd) = NULL; + + if (closefunc == NULL) { + char *cp = getenv("AWKREADFUNC"); + + /* If necessary, one day, test value for different functions. */ + if (cp == NULL) + closefunc = close; + else + closefunc = one_line_close; + } + + /* + * This won't be true if there's an invalid character in + * the source file or source string (e.g., user typo). + * Previous versions of gawk did not core dump in such a + * case. + * + * assert(lexeof == TRUE); + */ + lexeof = FALSE; + eof_warned = FALSE; + sourcefile->srclines = sourceline; /* total no of lines in current file */ + if (sourcefile->fd > INVALID_HANDLE) { + if (sourcefile->fd != fileno(stdin)) /* safety */ + (*closefunc)(sourcefile->fd); + sourcefile->fd = INVALID_HANDLE; + } + if (sourcefile->buf != NULL) { + efree(sourcefile->buf); + sourcefile->buf = NULL; + sourcefile->lexptr_begin = NULL; + } + + sourcefile = sourcefile->next; + if (sourcefile == srcfiles) + return; + + if (sourcefile->lexptr_begin != NULL) { + /* resume reading from already opened file (postponed to process '@include') */ + lexptr = sourcefile->lexptr; + lexend = sourcefile->lexend; + lasttok = sourcefile->lasttok; + lexptr_begin = sourcefile->lexptr_begin; + lexeme = sourcefile->lexeme; + sourceline = sourcefile->srclines; + source = sourcefile->src; + } else { + lexptr = NULL; + sourceline = 0; + source = NULL; + lasttok = 0; + } +} + +/* get_src_buf --- read the next buffer of source program */ + +static char * +get_src_buf() +{ + int n; + char *scan; + int newfile; + int savelen; + struct stat sbuf; + + /* + * No argument prototype on readfunc on purpose, + * avoids problems with some ancient systems where + * the types of arguments to read() aren't up to date. + */ + static ssize_t (*readfunc)() = 0; + + if (readfunc == NULL) { + char *cp = getenv("AWKREADFUNC"); + + /* If necessary, one day, test value for different functions. */ + if (cp == NULL) + /* + * cast is to remove warnings on systems with + * different return types for read. + */ + readfunc = ( ssize_t(*)() ) read; + else + readfunc = read_one_line; + } + + newfile = FALSE; + if (sourcefile == srcfiles) + return NULL; + + if (sourcefile->stype == SRC_CMDLINE) { + if (sourcefile->bufsize == 0) { + sourcefile->bufsize = strlen(sourcefile->src); + lexptr = lexptr_begin = lexeme = sourcefile->src; + lexend = lexptr + sourcefile->bufsize; + sourceline = 1; + if (sourcefile->bufsize == 0) { + /* + * Yet Another Special case: + * gawk '' /path/name + * Sigh. + */ + static short warned = FALSE; + + if (do_lint && ! warned) { + warned = TRUE; + lintwarn(_("empty program text on command line")); + } + lexeof = TRUE; + } + } else if (sourcefile->buf == NULL && *(lexptr-1) != '\n') { + /* + * The following goop is to ensure that the source + * ends with a newline and that the entire current + * line is available for error messages. + */ + int offset; + char *buf; + + offset = lexptr - lexeme; + for (scan = lexeme; scan > lexptr_begin; scan--) + if (*scan == '\n') { + scan++; + break; + } + savelen = lexptr - scan; + emalloc(buf, char *, savelen + 1, "get_src_buf"); + memcpy(buf, scan, savelen); + thisline = buf; + lexptr = buf + savelen; + *lexptr = '\n'; + lexeme = lexptr - offset; + lexptr_begin = buf; + lexend = lexptr + 1; + sourcefile->buf = buf; + } else + lexeof = TRUE; + return lexptr; + } + + if (sourcefile->fd <= INVALID_HANDLE) { + int fd; + int l; + + source = sourcefile->src; + if (source == NULL) + return NULL; + fd = srcopen(sourcefile); + if (fd <= INVALID_HANDLE) { + char *in; + + /* suppress file name and line no. in error mesg */ + in = source; + source = NULL; + error(_("can't open source file `%s' for reading (%s)"), + in, strerror(errno)); + errcount++; + lexeof = TRUE; + return sourcefile->src; + } + + sourcefile->fd = fd; + l = optimal_bufsize(fd, &sbuf); + /* + * Make sure that something silly like + * AWKBUFSIZE=8 make check + * works ok. + */ +#define A_DECENT_BUFFER_SIZE 128 + if (l < A_DECENT_BUFFER_SIZE) + l = A_DECENT_BUFFER_SIZE; +#undef A_DECENT_BUFFER_SIZE + sourcefile->bufsize = l; + newfile = TRUE; + emalloc(sourcefile->buf, char *, sourcefile->bufsize, "get_src_buf"); + lexptr = lexptr_begin = lexeme = sourcefile->buf; + savelen = 0; + sourceline = 1; + thisline = NULL; + } else { + /* + * Here, we retain the current source line in the beginning of the buffer. + */ + int offset; + for (scan = lexeme; scan > lexptr_begin; scan--) + if (*scan == '\n') { + scan++; + break; + } + + savelen = lexptr - scan; + offset = lexptr - lexeme; + + if (savelen > 0) { + /* + * Need to make sure we have room left for reading new text; + * grow the buffer (by doubling, an arbitrary choice), if the retained line + * takes up more than a certain percentage (50%, again an arbitrary figure) + * of the available space. + */ + + if (savelen > sourcefile->bufsize / 2) { /* long line or token */ + sourcefile->bufsize *= 2; + erealloc(sourcefile->buf, char *, sourcefile->bufsize, "get_src_buf"); + scan = sourcefile->buf + (scan - lexptr_begin); + lexptr_begin = sourcefile->buf; + } + + thisline = lexptr_begin; + memmove(thisline, scan, savelen); + lexptr = thisline + savelen; + lexeme = lexptr - offset; + } else { + savelen = 0; + lexptr = lexeme = lexptr_begin; + thisline = NULL; + } + } + + n = (*readfunc)(sourcefile->fd, lexptr, sourcefile->bufsize - savelen); + if (n == -1) { + error(_("can't read sourcefile `%s' (%s)"), + source, strerror(errno)); + errcount++; + lexeof = TRUE; + } else { + lexend = lexptr + n; + if (n == 0) { + static short warned = FALSE; + if (do_lint && newfile && ! warned){ + warned = TRUE; + sourceline = 0; + lintwarn(_("source file `%s' is empty"), source); + } + lexeof = TRUE; + } + } + return sourcefile->buf; +} + +/* tokadd --- add a character to the token buffer */ + +#define tokadd(x) (*tok++ = (x), tok == tokend ? tokexpand() : tok) + +/* tokexpand --- grow the token buffer */ + +static char * +tokexpand() +{ + static int toksize; + int tokoffset; + + if (tokstart != NULL) { + tokoffset = tok - tokstart; + toksize *= 2; + erealloc(tokstart, char *, toksize, "tokexpand"); + tok = tokstart + tokoffset; + } else { + toksize = 60; + emalloc(tokstart, char *, toksize, "tokexpand"); + tok = tokstart; + } + tokend = tokstart + toksize; + return tok; +} + +/* nextc --- get the next input character */ + +#if MBS_SUPPORT + +static int +nextc(void) +{ + if (gawk_mb_cur_max > 1) { +again: + if (lexeof) + return END_FILE; + if (lexptr == NULL || lexptr >= lexend) { + if (get_src_buf()) + goto again; + return END_SRC; + } + + /* Update the buffer index. */ + cur_ring_idx = (cur_ring_idx == RING_BUFFER_SIZE - 1)? 0 : + cur_ring_idx + 1; + + /* Did we already check the current character? */ + if (cur_char_ring[cur_ring_idx] == 0) { + /* No, we need to check the next character on the buffer. */ + int idx, work_ring_idx = cur_ring_idx; + mbstate_t tmp_state; + size_t mbclen; + + for (idx = 0 ; lexptr + idx < lexend ; idx++) { + tmp_state = cur_mbstate; + mbclen = mbrlen(lexptr, idx + 1, &tmp_state); + + if (mbclen == 1 || mbclen == (size_t)-1 || mbclen == 0) { + /* It is a singlebyte character, non-complete multibyte + character or EOF. We treat it as a singlebyte + character. */ + cur_char_ring[work_ring_idx] = 1; + break; + } else if (mbclen == (size_t)-2) { + /* It is not a complete multibyte character. */ + cur_char_ring[work_ring_idx] = idx + 1; + } else { + /* mbclen > 1 */ + cur_char_ring[work_ring_idx] = mbclen; + break; + } + work_ring_idx = (work_ring_idx == RING_BUFFER_SIZE - 1)? + 0 : work_ring_idx + 1; + } + cur_mbstate = tmp_state; + + /* Put a mark on the position on which we write next character. */ + work_ring_idx = (work_ring_idx == RING_BUFFER_SIZE - 1)? + 0 : work_ring_idx + 1; + cur_char_ring[work_ring_idx] = 0; + } + + return (int) (unsigned char) *lexptr++; + } else { + do { + if (lexeof) + return END_FILE; + if (lexptr && lexptr < lexend) + return ((int) (unsigned char) *lexptr++); + } while (get_src_buf()); + return END_SRC; + } +} + +#else /* MBS_SUPPORT */ + +int +nextc() +{ + do { + if (lexeof) + return END_FILE; + if (lexptr && lexptr < lexend) + return ((int) (unsigned char) *lexptr++); + } while (get_src_buf()); + return END_SRC; +} + +#endif /* MBS_SUPPORT */ + +/* pushback --- push a character back on the input */ + +static inline void +pushback(void) +{ +#if MBS_SUPPORT + if (gawk_mb_cur_max > 1) + cur_ring_idx = (cur_ring_idx == 0)? RING_BUFFER_SIZE - 1 : + cur_ring_idx - 1; +#endif + (! lexeof && lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr); +} + + +/* allow_newline --- allow newline after &&, ||, ? and : */ + +static void +allow_newline(void) +{ + int c; + + for (;;) { + c = nextc(); + if (c == END_FILE) { + pushback(); + break; + } + if (c == '#') { + while ((c = nextc()) != '\n' && c != END_FILE) + continue; + if (c == END_FILE) { + pushback(); + break; + } + } + if (c == '\n') + sourceline++; + if (! isspace(c)) { + pushback(); + break; + } + } +} + +/* newline_eof --- return newline or EOF as needed and adjust variables */ + +/* + * This routine used to be a macro, however GCC 4.6.2 warned about + * the result of a computation not being used. Converting to a function + * removes the warnings. + */ + +static int newline_eof() +{ + /* NB: a newline at end does not start a source line. */ + if (lasttok != NEWLINE) { + pushback(); + if (do_lint && ! eof_warned) { + lintwarn(_("source file does not end in newline")); + eof_warned = TRUE; + } + sourceline++; + return NEWLINE; + } + + sourceline--; + eof_warned = FALSE; + return LEX_EOF; +} + +/* yylex --- Read the input and turn it into tokens. */ + +static int +yylex(void) +{ + int c; + int seen_e = FALSE; /* These are for numbers */ + int seen_point = FALSE; + int esc_seen; /* for literal strings */ + int mid; + static int did_newline = FALSE; + char *tokkey; + int inhex = FALSE; + int intlstr = FALSE; + +#define GET_INSTRUCTION(op) bcalloc(op, 1, sourceline) + +#define NEWLINE_EOF newline_eof() + + yylval = (INSTRUCTION *) NULL; + if (lasttok == SUBSCRIPT) { + lasttok = 0; + return SUBSCRIPT; + } + + if (lasttok == LEX_EOF) /* error earlier in current source, must give up !! */ + return 0; + + c = nextc(); + if (c == END_SRC) + return 0; + if (c == END_FILE) + return lasttok = NEWLINE_EOF; + pushback(); + +#if defined __EMX__ + /* + * added for OS/2's extproc feature of cmd.exe + * (like #! in BSD sh) + */ + if (strncasecmp(lexptr, "extproc ", 8) == 0) { + while (*lexptr && *lexptr != '\n') + lexptr++; + } +#endif + + lexeme = lexptr; + thisline = NULL; + if (want_regexp) { + int in_brack = 0; /* count brackets, [[:alnum:]] allowed */ + /* + * Counting brackets is non-trivial. [[] is ok, + * and so is [\]], with a point being that /[/]/ as a regexp + * constant has to work. + * + * Do not count [ or ] if either one is preceded by a \. + * A `[' should be counted if + * a) it is the first one so far (in_brack == 0) + * b) it is the `[' in `[:' + * A ']' should be counted if not preceded by a \, since + * it is either closing `:]' or just a plain list. + * According to POSIX, []] is how you put a ] into a set. + * Try to handle that too. + * + * The code for \ handles \[ and \]. + */ + + want_regexp = FALSE; + tok = tokstart; + for (;;) { + c = nextc(); + + if (gawk_mb_cur_max == 1 || nextc_is_1stbyte) switch (c) { + case '[': + /* one day check for `.' and `=' too */ + if (nextc() == ':' || in_brack == 0) + in_brack++; + pushback(); + break; + case ']': + if (tokstart[0] == '[' + && (tok == tokstart + 1 + || (tok == tokstart + 2 + && tokstart[1] == '^'))) + /* do nothing */; + else + in_brack--; + break; + case '\\': + if ((c = nextc()) == END_FILE) { + pushback(); + yyerror(_("unterminated regexp ends with `\\' at end of file")); + goto end_regexp; /* kludge */ + } else if (c == '\n') { + sourceline++; + continue; + } else { + tokadd('\\'); + tokadd(c); + continue; + } + break; + case '/': /* end of the regexp */ + if (in_brack > 0) + break; +end_regexp: + yylval = GET_INSTRUCTION(Op_token); + yylval->lextok = estrdup(tokstart, tok - tokstart); + if (do_lint) { + int peek = nextc(); + + pushback(); + if (peek == 'i' || peek == 's') { + if (source) + lintwarn( + _("%s: %d: tawk regex modifier `/.../%c' doesn't work in gawk"), + source, sourceline, peek); + else + lintwarn( + _("tawk regex modifier `/.../%c' doesn't work in gawk"), + peek); + } + } + return lasttok = REGEXP; + case '\n': + pushback(); + yyerror(_("unterminated regexp")); + goto end_regexp; /* kludge */ + case END_FILE: + pushback(); + yyerror(_("unterminated regexp at end of file")); + goto end_regexp; /* kludge */ + } + tokadd(c); + } + } +retry: + + /* skipping \r is a hack, but windows is just too pervasive. sigh. */ + while ((c = nextc()) == ' ' || c == '\t' || c == '\r') + continue; + + lexeme = lexptr ? lexptr - 1 : lexptr; + thisline = NULL; + tok = tokstart; + +#if MBS_SUPPORT + if (gawk_mb_cur_max == 1 || nextc_is_1stbyte) +#endif + switch (c) { + case END_SRC: + return 0; + + case END_FILE: + return lasttok = NEWLINE_EOF; + + case '\n': + sourceline++; + return lasttok = NEWLINE; + + case '#': /* it's a comment */ + while ((c = nextc()) != '\n') { + if (c == END_FILE) + return lasttok = NEWLINE_EOF; + } + sourceline++; + return lasttok = NEWLINE; + + case '@': + return lasttok = '@'; + + case '\\': +#ifdef RELAXED_CONTINUATION + /* + * This code puports to allow comments and/or whitespace + * after the `\' at the end of a line used for continuation. + * Use it at your own risk. We think it's a bad idea, which + * is why it's not on by default. + */ + if (! do_traditional) { + /* strip trailing white-space and/or comment */ + while ((c = nextc()) == ' ' || c == '\t' || c == '\r') + continue; + if (c == '#') { + static short warned = FALSE; + + if (do_lint && ! warned) { + warned = TRUE; + lintwarn( + _("use of `\\ #...' line continuation is not portable")); + } + while ((c = nextc()) != '\n') + if (c == END_FILE) + break; + } + pushback(); + } +#endif /* RELAXED_CONTINUATION */ + c = nextc(); + if (c == '\r') /* allow MS-DOS files. bleah */ + c = nextc(); + if (c == '\n') { + sourceline++; + goto retry; + } else { + yyerror(_("backslash not last character on line")); + return lasttok = LEX_EOF; + } + break; + + case ':': + case '?': + yylval = GET_INSTRUCTION(Op_cond_exp); + if (! do_posix) + allow_newline(); + return lasttok = c; + + /* + * in_parens is undefined unless we are parsing a print + * statement (in_print), but why bother with a check? + */ + case ')': + in_parens--; + return lasttok = c; + + case '(': + in_parens++; + return lasttok = c; + case '$': + yylval = GET_INSTRUCTION(Op_field_spec); + return lasttok = c; + case '{': + if (++in_braces == 1) + firstline = sourceline; + case ';': + case ',': + case '[': + return lasttok = c; + case ']': + c = nextc(); + pushback(); + if (c == '[') { + yylval = GET_INSTRUCTION(Op_sub_array); + lasttok = ']'; + } else { + yylval = GET_INSTRUCTION(Op_subscript); + lasttok = SUBSCRIPT; /* end of subscripts */ + } + return ']'; + + case '*': + if ((c = nextc()) == '=') { + yylval = GET_INSTRUCTION(Op_assign_times); + return lasttok = ASSIGNOP; + } else if (do_posix) { + pushback(); + yylval = GET_INSTRUCTION(Op_times); + return lasttok = '*'; + } else if (c == '*') { + /* make ** and **= aliases for ^ and ^= */ + static int did_warn_op = FALSE, did_warn_assgn = FALSE; + + if (nextc() == '=') { + if (! did_warn_assgn) { + did_warn_assgn = TRUE; + if (do_lint) + lintwarn(_("POSIX does not allow operator `**='")); + if (do_lint_old) + warning(_("old awk does not support operator `**='")); + } + yylval = GET_INSTRUCTION(Op_assign_exp); + return ASSIGNOP; + } else { + pushback(); + if (! did_warn_op) { + did_warn_op = TRUE; + if (do_lint) + lintwarn(_("POSIX does not allow operator `**'")); + if (do_lint_old) + warning(_("old awk does not support operator `**'")); + } + yylval = GET_INSTRUCTION(Op_exp); + return lasttok = '^'; + } + } + pushback(); + yylval = GET_INSTRUCTION(Op_times); + return lasttok = '*'; + + case '/': + if (nextc() == '=') { + pushback(); + return lasttok = SLASH_BEFORE_EQUAL; + } + pushback(); + yylval = GET_INSTRUCTION(Op_quotient); + return lasttok = '/'; + + case '%': + if (nextc() == '=') { + yylval = GET_INSTRUCTION(Op_assign_mod); + return lasttok = ASSIGNOP; + } + pushback(); + yylval = GET_INSTRUCTION(Op_mod); + return lasttok = '%'; + + case '^': + { + static int did_warn_op = FALSE, did_warn_assgn = FALSE; + + if (nextc() == '=') { + if (do_lint_old && ! did_warn_assgn) { + did_warn_assgn = TRUE; + warning(_("operator `^=' is not supported in old awk")); + } + yylval = GET_INSTRUCTION(Op_assign_exp); + return lasttok = ASSIGNOP; + } + pushback(); + if (do_lint_old && ! did_warn_op) { + did_warn_op = TRUE; + warning(_("operator `^' is not supported in old awk")); + } + yylval = GET_INSTRUCTION(Op_exp); + return lasttok = '^'; + } + + case '+': + if ((c = nextc()) == '=') { + yylval = GET_INSTRUCTION(Op_assign_plus); + return lasttok = ASSIGNOP; + } + if (c == '+') { + yylval = GET_INSTRUCTION(Op_symbol); + return lasttok = INCREMENT; + } + pushback(); + yylval = GET_INSTRUCTION(Op_plus); + return lasttok = '+'; + + case '!': + if ((c = nextc()) == '=') { + yylval = GET_INSTRUCTION(Op_notequal); + return lasttok = RELOP; + } + if (c == '~') { + yylval = GET_INSTRUCTION(Op_nomatch); + return lasttok = MATCHOP; + } + pushback(); + yylval = GET_INSTRUCTION(Op_symbol); + return lasttok = '!'; + + case '<': + if (nextc() == '=') { + yylval = GET_INSTRUCTION(Op_leq); + return lasttok = RELOP; + } + yylval = GET_INSTRUCTION(Op_less); + pushback(); + return lasttok = '<'; + + case '=': + if (nextc() == '=') { + yylval = GET_INSTRUCTION(Op_equal); + return lasttok = RELOP; + } + yylval = GET_INSTRUCTION(Op_assign); + pushback(); + return lasttok = ASSIGN; + + case '>': + if ((c = nextc()) == '=') { + yylval = GET_INSTRUCTION(Op_geq); + return lasttok = RELOP; + } else if (c == '>') { + yylval = GET_INSTRUCTION(Op_symbol); + yylval->redir_type = redirect_append; + return lasttok = IO_OUT; + } + pushback(); + if (in_print && in_parens == 0) { + yylval = GET_INSTRUCTION(Op_symbol); + yylval->redir_type = redirect_output; + return lasttok = IO_OUT; + } + yylval = GET_INSTRUCTION(Op_greater); + return lasttok = '>'; + + case '~': + yylval = GET_INSTRUCTION(Op_match); + return lasttok = MATCHOP; + + case '}': + /* + * Added did newline stuff. Easier than + * hacking the grammar. + */ + if (did_newline) { + did_newline = FALSE; + if (--in_braces == 0) + lastline = sourceline; + return lasttok = c; + } + did_newline++; + --lexptr; /* pick up } next time */ + return lasttok = NEWLINE; + + case '"': + string: + esc_seen = FALSE; + while ((c = nextc()) != '"') { + if (c == '\n') { + pushback(); + yyerror(_("unterminated string")); + return lasttok = LEX_EOF; + } + if ((gawk_mb_cur_max == 1 || nextc_is_1stbyte) && + c == '\\') { + c = nextc(); + if (c == '\n') { + sourceline++; + continue; + } + esc_seen = TRUE; + if (! want_source || c != '"') + tokadd('\\'); + } + if (c == END_FILE) { + pushback(); + yyerror(_("unterminated string")); + return lasttok = LEX_EOF; + } + tokadd(c); + } + yylval = GET_INSTRUCTION(Op_token); + if (want_source) { + yylval->lextok = estrdup(tokstart, tok - tokstart); + return lasttok = FILENAME; + } + + yylval->opcode = Op_push_i; + yylval->memory = make_str_node(tokstart, + tok - tokstart, esc_seen ? SCAN : 0); + yylval->memory->flags &= ~MALLOC; + yylval->memory->flags |= PERM; + if (intlstr) { + yylval->memory->flags |= INTLSTR; + intlstr = FALSE; + if (do_intl) + dumpintlstr(yylval->memory->stptr, yylval->memory->stlen); + } + return lasttok = YSTRING; + + case '-': + if ((c = nextc()) == '=') { + yylval = GET_INSTRUCTION(Op_assign_minus); + return lasttok = ASSIGNOP; + } + if (c == '-') { + yylval = GET_INSTRUCTION(Op_symbol); + return lasttok = DECREMENT; + } + pushback(); + yylval = GET_INSTRUCTION(Op_minus); + return lasttok = '-'; + + case '.': + c = nextc(); + pushback(); + if (! isdigit(c)) + return lasttok = '.'; + else + c = '.'; + /* FALL THROUGH */ + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + /* It's a number */ + for (;;) { + int gotnumber = FALSE; + + tokadd(c); + switch (c) { + case 'x': + case 'X': + if (do_traditional) + goto done; + if (tok == tokstart + 2) { + int peek = nextc(); + + if (isxdigit(peek)) { + inhex = TRUE; + pushback(); /* following digit */ + } else { + pushback(); /* x or X */ + goto done; + } + } + break; + case '.': + /* period ends exponent part of floating point number */ + if (seen_point || seen_e) { + gotnumber = TRUE; + break; + } + seen_point = TRUE; + break; + case 'e': + case 'E': + if (inhex) + break; + if (seen_e) { + gotnumber = TRUE; + break; + } + seen_e = TRUE; + if ((c = nextc()) == '-' || c == '+') { + int c2 = nextc(); + + if (isdigit(c2)) { + tokadd(c); + tokadd(c2); + } else { + pushback(); /* non-digit after + or - */ + pushback(); /* + or - */ + pushback(); /* e or E */ + } + } else if (! isdigit(c)) { + pushback(); /* character after e or E */ + pushback(); /* e or E */ + } else { + pushback(); /* digit */ + } + break; + case 'a': + case 'A': + case 'b': + case 'B': + case 'c': + case 'C': + case 'D': + case 'd': + case 'f': + case 'F': + if (do_traditional || ! inhex) + goto done; + /* fall through */ + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + break; + default: + done: + gotnumber = TRUE; + } + if (gotnumber) + break; + c = nextc(); + } + pushback(); + + tokadd('\0'); + yylval = GET_INSTRUCTION(Op_push_i); + if (! do_traditional && isnondecimal(tokstart, FALSE)) { + if (do_lint) { + if (isdigit((unsigned char) tokstart[1])) /* not an 'x' or 'X' */ + lintwarn("numeric constant `%.*s' treated as octal", + (int) strlen(tokstart)-1, tokstart); + else if (tokstart[1] == 'x' || tokstart[1] == 'X') + lintwarn("numeric constant `%.*s' treated as hexadecimal", + (int) strlen(tokstart)-1, tokstart); + } + yylval->memory = mk_number(nondec2awknum(tokstart, strlen(tokstart)), + PERM|NUMCUR|NUMBER); + } else + yylval->memory = mk_number(atof(tokstart), PERM|NUMCUR|NUMBER); + return lasttok = YNUMBER; + + case '&': + if ((c = nextc()) == '&') { + yylval = GET_INSTRUCTION(Op_and); + allow_newline(); + return lasttok = LEX_AND; + } + pushback(); + yylval = GET_INSTRUCTION(Op_symbol); + return lasttok = '&'; + + case '|': + if ((c = nextc()) == '|') { + yylval = GET_INSTRUCTION(Op_or); + allow_newline(); + return lasttok = LEX_OR; + } else if (! do_traditional && c == '&') { + yylval = GET_INSTRUCTION(Op_symbol); + yylval->redir_type = redirect_twoway; + return lasttok = (in_print && in_parens == 0 ? IO_OUT : IO_IN); + } + pushback(); + if (in_print && in_parens == 0) { + yylval = GET_INSTRUCTION(Op_symbol); + yylval->redir_type = redirect_pipe; + return lasttok = IO_OUT; + } else { + yylval = GET_INSTRUCTION(Op_symbol); + yylval->redir_type = redirect_pipein; + return lasttok = IO_IN; + } + } + + if (c != '_' && ! isalpha(c)) { + yyerror(_("invalid char '%c' in expression"), c); + return lasttok = LEX_EOF; + } + + /* + * Lots of fog here. Consider: + * + * print "xyzzy"$_"foo" + * + * Without the check for ` lasttok != '$' ', this is parsed as + * + * print "xxyzz" $(_"foo") + * + * With the check, it is "correctly" parsed as three + * string concatenations. Sigh. This seems to be + * "more correct", but this is definitely one of those + * occasions where the interactions are funny. + */ + if (! do_traditional && c == '_' && lasttok != '$') { + if ((c = nextc()) == '"') { + intlstr = TRUE; + goto string; + } + pushback(); + c = '_'; + } + + /* it's some type of name-type-thing. Find its length. */ + tok = tokstart; + while (c != END_FILE && is_identchar(c)) { + tokadd(c); + c = nextc(); + } + tokadd('\0'); + pushback(); + + /* See if it is a special token. */ + if ((mid = check_special(tokstart)) >= 0) { + static int warntab[sizeof(tokentab) / sizeof(tokentab[0])]; + int class = tokentab[mid].class; + + if ((class == LEX_INCLUDE || class == LEX_EVAL) + && lasttok != '@') + goto out; + + if (do_lint) { + if ((tokentab[mid].flags & GAWKX) && ! (warntab[mid] & GAWKX)) { + lintwarn(_("`%s' is a gawk extension"), + tokentab[mid].operator); + warntab[mid] |= GAWKX; + } + if ((tokentab[mid].flags & RESX) && ! (warntab[mid] & RESX)) { + lintwarn(_("`%s' is a Bell Labs extension"), + tokentab[mid].operator); + warntab[mid] |= RESX; + } + if ((tokentab[mid].flags & NOT_POSIX) && ! (warntab[mid] & NOT_POSIX)) { + lintwarn(_("POSIX does not allow `%s'"), + tokentab[mid].operator); + warntab[mid] |= NOT_POSIX; + } + } + if (do_lint_old && (tokentab[mid].flags & NOT_OLD) + && ! (warntab[mid] & NOT_OLD) + ) { + warning(_("`%s' is not supported in old awk"), + tokentab[mid].operator); + warntab[mid] |= NOT_OLD; + } + + if (tokentab[mid].flags & BREAK) + break_allowed++; + if (tokentab[mid].flags & CONTINUE) + continue_allowed++; + + switch (class) { + case LEX_INCLUDE: + want_source = TRUE; + break; + case LEX_EVAL: + if (in_main_context()) + goto out; + emalloc(tokkey, char *, tok - tokstart + 1, "yylex"); + tokkey[0] = '@'; + memcpy(tokkey + 1, tokstart, tok - tokstart); + yylval = GET_INSTRUCTION(Op_token); + yylval->lextok = tokkey; + break; + + case LEX_FUNCTION: + case LEX_BEGIN: + case LEX_END: + case LEX_BEGINFILE: + case LEX_ENDFILE: + yylval = bcalloc(tokentab[mid].value, 3, sourceline); + break; + + case LEX_FOR: + case LEX_WHILE: + case LEX_DO: + case LEX_SWITCH: + if (! do_profiling) + return lasttok = class; + /* fall through */ + case LEX_CASE: + yylval = bcalloc(tokentab[mid].value, 2, sourceline); + break; + + default: + yylval = GET_INSTRUCTION(tokentab[mid].value); + if (class == LEX_BUILTIN || class == LEX_LENGTH) + yylval->builtin_idx = mid; + break; + } + return lasttok = class; + } +out: + tokkey = estrdup(tokstart, tok - tokstart); + if (*lexptr == '(') { + yylval = bcalloc(Op_token, 2, sourceline); + yylval->lextok = tokkey; + return lasttok = FUNC_CALL; + } else { + static short goto_warned = FALSE; + + yylval = GET_INSTRUCTION(Op_token); + yylval->lextok = tokkey; + +#define SMART_ALECK 1 + if (SMART_ALECK && do_lint + && ! goto_warned && strcasecmp(tokkey, "goto") == 0) { + goto_warned = TRUE; + lintwarn(_("`goto' considered harmful!\n")); + } + return lasttok = NAME; + } + +#undef GET_INSTRUCTION +#undef NEWLINE_EOF +} + +/* mk_symbol --- allocates a symbol for the symbol table. */ + +NODE * +mk_symbol(NODETYPE type, NODE *value) +{ + NODE *r; + + getnode(r); + r->type = type; + r->flags = MALLOC; + r->lnode = value; + r->rnode = NULL; + r->parent_array = NULL; + r->var_assign = (Func_ptr) 0; + return r; +} + +/* snode --- instructions for builtin functions. Checks for arg. count + and supplies defaults where possible. */ + +static INSTRUCTION * +snode(INSTRUCTION *subn, INSTRUCTION *r) +{ + INSTRUCTION *arg; + INSTRUCTION *ip; + NODE *n; + int nexp = 0; + int args_allowed; + int idx = r->builtin_idx; + + if (subn != NULL) { + INSTRUCTION *tp; + for (tp = subn->nexti; tp; tp = tp->nexti) { + tp = tp->lasti; + nexp++; + } + assert(nexp > 0); + } + + /* check against how many args. are allowed for this builtin */ + args_allowed = tokentab[idx].flags & ARGS; + if (args_allowed && (args_allowed & A(nexp)) == 0) { + yyerror(_("%d is invalid as number of arguments for %s"), + nexp, tokentab[idx].operator); + return NULL; + } + + /* special processing for sub, gsub and gensub */ + + if (tokentab[idx].value == Op_sub_builtin) { + const char *operator = tokentab[idx].operator; + + r->sub_flags = 0; + + arg = subn->nexti; /* first arg list */ + (void) mk_rexp(arg); + + if (strcmp(operator, "gensub") != 0) { + /* sub and gsub */ + + if (strcmp(operator, "gsub") == 0) + r->sub_flags |= GSUB; + + arg = arg->lasti->nexti; /* 2nd arg list */ + if (nexp == 2) { + INSTRUCTION *expr; + + expr = list_create(instruction(Op_push_i)); + expr->nexti->memory = mk_number((AWKNUM) 0.0, (PERM|NUMCUR|NUMBER)); + (void) mk_expression_list(subn, + list_append(expr, instruction(Op_field_spec))); + } + + arg = arg->lasti->nexti; /* third arg list */ + ip = arg->lasti; + if (ip->opcode == Op_push_i) { + if (do_lint) + lintwarn(_("%s: string literal as last arg of substitute has no effect"), + operator); + r->sub_flags |= LITERAL; + } else { + if (make_assignable(ip) == NULL) + yyerror(_("%s third parameter is not a changeable object"), + operator); + else + ip->do_reference = TRUE; + } + + r->expr_count = count_expressions(&subn, FALSE); + ip = subn->lasti; + + (void) list_append(subn, r); + + /* add after_assign code */ + if (ip->opcode == Op_push_lhs && ip->memory->type == Node_var && ip->memory->var_assign) { + (void) list_append(subn, instruction(Op_var_assign)); + subn->lasti->assign_ctxt = Op_sub_builtin; + subn->lasti->assign_var = ip->memory->var_assign; + } else if (ip->opcode == Op_field_spec_lhs) { + (void) list_append(subn, instruction(Op_field_assign)); + subn->lasti->assign_ctxt = Op_sub_builtin; + subn->lasti->field_assign = (Func_ptr) 0; + ip->target_assign = subn->lasti; + } + return subn; + + } else { + /* gensub */ + + r->sub_flags |= GENSUB; + if (nexp == 3) { + ip = instruction(Op_push_i); + ip->memory = mk_number((AWKNUM) 0.0, (PERM|NUMCUR|NUMBER)); + (void) mk_expression_list(subn, + list_append(list_create(ip), instruction(Op_field_spec))); + } + + r->expr_count = count_expressions(&subn, FALSE); + return list_append(subn, r); + } + } + + r->builtin = tokentab[idx].ptr; + + /* special case processing for a few builtins */ + + if (r->builtin == do_length) { + if (nexp == 0) { + /* no args. Use $0 */ + + INSTRUCTION *list; + r->expr_count = 1; + list = list_create(r); + (void) list_prepend(list, instruction(Op_field_spec)); + (void) list_prepend(list, instruction(Op_push_i)); + list->nexti->memory = mk_number((AWKNUM) 0.0, (PERM|NUMCUR|NUMBER)); + return list; + } else { + arg = subn->nexti; + if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push) + arg->nexti->opcode = Op_push_arg; /* argument may be array */ + } + } else if (r->builtin == do_isarray) { + arg = subn->nexti; + if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push) + arg->nexti->opcode = Op_push_arg; /* argument may be array */ + } else if (r->builtin == do_match) { + static short warned = FALSE; + + arg = subn->nexti->lasti->nexti; /* 2nd arg list */ + (void) mk_rexp(arg); + + if (nexp == 3) { /* 3rd argument there */ + if (do_lint && ! warned) { + warned = TRUE; + lintwarn(_("match: third argument is a gawk extension")); + } + if (do_traditional) { + yyerror(_("match: third argument is a gawk extension")); + return NULL; + } + + arg = arg->lasti->nexti; /* third arg list */ + ip = arg->lasti; + if (/*ip == arg->nexti && */ ip->opcode == Op_push) + ip->opcode = Op_push_array; + } + } else if (r->builtin == do_split) { + arg = subn->nexti->lasti->nexti; /* 2nd arg list */ + ip = arg->lasti; + if (ip->opcode == Op_push) + ip->opcode = Op_push_array; + if (nexp == 2) { + INSTRUCTION *expr; + expr = list_create(instruction(Op_push)); + expr->nexti->memory = FS_node; + (void) mk_expression_list(subn, expr); + } + arg = arg->lasti->nexti; + n = mk_rexp(arg); + if (nexp == 2) + n->re_flags |= FS_DFLT; + if (nexp == 4) { + arg = arg->lasti->nexti; + ip = arg->lasti; + if (ip->opcode == Op_push) + ip->opcode = Op_push_array; + } + } else if (r->builtin == do_patsplit) { + arg = subn->nexti->lasti->nexti; /* 2nd arg list */ + ip = arg->lasti; + if (ip->opcode == Op_push) + ip->opcode = Op_push_array; + if (nexp == 2) { + INSTRUCTION *expr; + expr = list_create(instruction(Op_push)); + expr->nexti->memory = FPAT_node; + (void) mk_expression_list(subn, expr); + } + arg = arg->lasti->nexti; + n = mk_rexp(arg); + if (nexp == 4) { + arg = arg->lasti->nexti; + ip = arg->lasti; + if (ip->opcode == Op_push) + ip->opcode = Op_push_array; + } + } else if (r->builtin == do_close) { + static short warned = FALSE; + if (nexp == 2) { + if (do_lint && ! warned) { + warned = TRUE; + lintwarn(_("close: second argument is a gawk extension")); + } + if (do_traditional) { + yyerror(_("close: second argument is a gawk extension")); + return NULL; + } + } + } else if (do_intl /* --gen-po */ + && r->builtin == do_dcgettext /* dcgettext(...) */ + && subn->nexti->lasti->opcode == Op_push_i /* 1st arg is constant */ + && (subn->nexti->lasti->memory->flags & STRCUR) != 0) { /* it's a string constant */ + /* ala xgettext, dcgettext("some string" ...) dumps the string */ + NODE *str = subn->nexti->lasti->memory; + + if ((str->flags & INTLSTR) != 0) + warning(_("use of dcgettext(_\"...\") is incorrect: remove leading underscore")); + /* don't dump it, the lexer already did */ + else + dumpintlstr(str->stptr, str->stlen); + } else if (do_intl /* --gen-po */ + && r->builtin == do_dcngettext /* dcngettext(...) */ + && subn->nexti->lasti->opcode == Op_push_i /* 1st arg is constant */ + && (subn->nexti->lasti->memory->flags & STRCUR) != 0 /* it's a string constant */ + && subn->nexti->lasti->nexti->lasti->opcode == Op_push_i /* 2nd arg is constant too */ + && (subn->nexti->lasti->nexti->lasti->memory->flags & STRCUR) != 0) { /* it's a string constant */ + /* ala xgettext, dcngettext("some string", "some plural" ...) dumps the string */ + NODE *str1 = subn->nexti->lasti->memory; + NODE *str2 = subn->nexti->lasti->nexti->lasti->memory; + + if (((str1->flags | str2->flags) & INTLSTR) != 0) + warning(_("use of dcngettext(_\"...\") is incorrect: remove leading underscore")); + else + dumpintlstr2(str1->stptr, str1->stlen, str2->stptr, str2->stlen); + } else if (r->builtin == do_asort || r->builtin == do_asorti) { + arg = subn->nexti; /* 1st arg list */ + ip = arg->lasti; + if (ip->opcode == Op_push) + ip->opcode = Op_push_array; + if (nexp >= 2) { + arg = ip->nexti; + ip = arg->lasti; + if (ip->opcode == Op_push) + ip->opcode = Op_push_array; + } + } +#ifdef ARRAYDEBUG + else if (r->builtin == do_adump) { + ip = subn->nexti->lasti; + if (ip->opcode == Op_push) + ip->opcode = Op_push_array; + } +#endif + + if (subn != NULL) { + r->expr_count = count_expressions(&subn, FALSE); + return list_append(subn, r); + } + + r->expr_count = 0; + return list_create(r); +} + +/* append_param --- append PNAME to the list of parameters + * for the current function. + */ + +static void +append_param(char *pname) +{ + static NODE *savetail = NULL; + NODE *p; + + p = make_param(pname); + if (func_params == NULL) { + func_params = p; + savetail = p; + } else if (savetail != NULL) { + savetail->rnode = p; + savetail = p; + } +} + +/* dup_parms --- return TRUE if there are duplicate parameters */ + +static int +dup_parms(INSTRUCTION *fp, NODE *func) +{ + NODE *np; + const char *fname, **names; + int count, i, j, dups; + NODE *params; + + if (func == NULL) /* error earlier */ + return TRUE; + + fname = func->param; + count = func->param_cnt; + params = func->rnode; + + if (count == 0) /* no args, no problem */ + return FALSE; + + if (params == NULL) /* error earlier */ + return TRUE; + + emalloc(names, const char **, count * sizeof(char *), "dup_parms"); + + i = 0; + for (np = params; np != NULL; np = np->rnode) { + if (np->param == NULL) { /* error earlier, give up, go home */ + efree(names); + return TRUE; + } + names[i++] = np->param; + } + + dups = 0; + for (i = 1; i < count; i++) { + for (j = 0; j < i; j++) { + if (strcmp(names[i], names[j]) == 0) { + dups++; + error_ln(fp->source_line, + _("function `%s': parameter #%d, `%s', duplicates parameter #%d"), + fname, i + 1, names[j], j+1); + } + } + } + + efree(names); + return (dups > 0 ? TRUE : FALSE); +} + +/* parms_shadow --- check if parameters shadow globals */ + +static int +parms_shadow(INSTRUCTION *pc, int *shadow) +{ + int pcount, i; + int ret = FALSE; + NODE *func; + char *fname; + + func = pc->func_body; + fname = func->lnode->param; + +#if 0 /* can't happen, already exited if error ? */ + if (fname == NULL || func == NULL) /* error earlier */ + return FALSE; +#endif + + pcount = func->lnode->param_cnt; + + if (pcount == 0) /* no args, no problem */ + return 0; + + source = pc->source_file; + sourceline = pc->source_line; + /* + * Use warning() and not lintwarn() so that can warn + * about all shadowed parameters. + */ + for (i = 0; i < pcount; i++) { + if (lookup(func->parmlist[i]) != NULL) { + warning( + _("function `%s': parameter `%s' shadows global variable"), + fname, func->parmlist[i]); + ret = TRUE; + } + } + + *shadow |= ret; + return 0; +} + + +/* + * install_symbol: + * Install a name in the symbol table, even if it is already there. + * Caller must check against redefinition if that is desired. + */ + + +NODE * +install_symbol(char *name, NODE *value) +{ + NODE *hp; + size_t len; + int bucket; + + if (install_func) + (*install_func)(name); + + var_count++; + len = strlen(name); + bucket = hash(name, len, (unsigned long) HASHSIZE, NULL); + getnode(hp); + hp->type = Node_hashnode; + hp->hnext = variables[bucket]; + variables[bucket] = hp; + hp->hlength = len; + hp->hvalue = value; + hp->hname = name; + hp->hvalue->vname = name; + return hp->hvalue; +} + +/* lookup --- find the most recent hash node for name installed by install_symbol */ + +NODE * +lookup(const char *name) +{ + NODE *bucket; + size_t len; + + len = strlen(name); + for (bucket = variables[hash(name, len, (unsigned long) HASHSIZE, NULL)]; + bucket != NULL; bucket = bucket->hnext) + if (bucket->hlength == len && strncmp(bucket->hname, name, len) == 0) + return bucket->hvalue; + return NULL; +} + +/* sym_comp --- compare two symbol (variable or function) names */ + +static int +sym_comp(const void *v1, const void *v2) +{ + const NODE *const *npp1, *const *npp2; + const NODE *n1, *n2; + int minlen; + + npp1 = (const NODE *const *) v1; + npp2 = (const NODE *const *) v2; + n1 = *npp1; + n2 = *npp2; + + if (n1->hlength > n2->hlength) + minlen = n1->hlength; + else + minlen = n2->hlength; + + return strncmp(n1->hname, n2->hname, minlen); +} + +/* valinfo --- dump var info */ + +void +valinfo(NODE *n, int (*print_func)(FILE *, const char *, ...), FILE *fp) +{ + if (n == Nnull_string) + print_func(fp, "uninitialized scalar\n"); + else if (n->flags & STRING) { + pp_string_fp(print_func, fp, n->stptr, n->stlen, '"', FALSE); + print_func(fp, "\n"); + } else if (n->flags & NUMBER) + print_func(fp, "%.17g\n", n->numbr); + else if (n->flags & STRCUR) { + pp_string_fp(print_func, fp, n->stptr, n->stlen, '"', FALSE); + print_func(fp, "\n"); + } else if (n->flags & NUMCUR) + print_func(fp, "%.17g\n", n->numbr); + else + print_func(fp, "?? flags %s\n", flags2str(n->flags)); +} + +/* get_varlist --- list of global variables */ + +NODE ** +get_varlist() +{ + int i, j; + NODE **table; + NODE *p; + + emalloc(table, NODE **, (var_count + 1) * sizeof(NODE *), "get_varlist"); + update_global_values(); + for (i = j = 0; i < HASHSIZE; i++) + for (p = variables[i]; p != NULL; p = p->hnext) + table[j++] = p; + assert(j == var_count); + + /* Shazzam! */ + qsort(table, j, sizeof(NODE *), sym_comp); + + table[j] = NULL; + return table; +} + +/* print_vars --- print names and values of global variables */ + +void +print_vars(int (*print_func)(FILE *, const char *, ...), FILE *fp) +{ + int i; + NODE **table; + NODE *p; + + table = get_varlist(); + for (i = 0; (p = table[i]) != NULL; i++) { + if (p->hvalue->type == Node_func) + continue; + print_func(fp, "%.*s: ", (int) p->hlength, p->hname); + if (p->hvalue->type == Node_var_array) + print_func(fp, "array, %ld elements\n", p->hvalue->table_size); + else if (p->hvalue->type == Node_var_new) + print_func(fp, "untyped variable\n"); + else if (p->hvalue->type == Node_var) + valinfo(p->hvalue->var_value, print_func, fp); + } + efree(table); +} + +/* dump_vars --- dump the symbol table */ + +void +dump_vars(const char *fname) +{ + FILE *fp; + + if (fname == NULL) + fp = stderr; + else if ((fp = fopen(fname, "w")) == NULL) { + warning(_("could not open `%s' for writing (%s)"), fname, strerror(errno)); + warning(_("sending variable list to standard error")); + fp = stderr; + } + + print_vars(fprintf, fp); + if (fp != stderr && fclose(fp) != 0) + warning(_("%s: close failed (%s)"), fname, strerror(errno)); +} + +/* release_all_vars --- free all variable memory */ + +void +release_all_vars() +{ + int i; + NODE *p, *next; + + for (i = 0; i < HASHSIZE; i++) { + for (p = variables[i]; p != NULL; p = next) { + next = p->hnext; + + if (p->hvalue->type == Node_func) + continue; + else if (p->hvalue->type == Node_var_array) + assoc_clear(p->hvalue); + else if (p->hvalue->type != Node_var_new) + unref(p->hvalue->var_value); + + efree(p->hname); + freenode(p->hvalue); + freenode(p); + } + } +} + +/* dump_funcs --- print all functions */ + +void +dump_funcs() +{ + if (func_count <= 0) + return; + + (void) foreach_func((int (*)(INSTRUCTION *, void *)) pp_func, TRUE, (void *) 0); +} + +/* shadow_funcs --- check all functions for parameters that shadow globals */ + +void +shadow_funcs() +{ + static int calls = 0; + int shadow = FALSE; + + if (func_count <= 0) + return; + + if (calls++ != 0) + fatal(_("shadow_funcs() called twice!")); + + (void) foreach_func((int (*)(INSTRUCTION *, void *)) parms_shadow, TRUE, &shadow); + + /* End with fatal if the user requested it. */ + if (shadow && lintfunc != warning) + lintwarn(_("there were shadowed variables.")); +} + +/* + * func_install: + * check if name is already installed; if so, it had better have Null value, + * in which case def is added as the value. Otherwise, install name with def + * as value. + * + * Extra work, build up and save a list of the parameter names in a table + * and hang it off params->parmlist. This is used to set the `vname' field + * of each function parameter during a function call. See eval.c. + */ + +static int +func_install(INSTRUCTION *func, INSTRUCTION *def) +{ + NODE *params; + NODE *r, *n, *thisfunc, *hp; + char **pnames = NULL; + char *fname; + int pcount = 0; + int i; + + params = func_params; + + /* check for function foo(foo) { ... }. bleah. */ + for (n = params->rnode; n != NULL; n = n->rnode) { + if (strcmp(n->param, params->param) == 0) { + error_ln(func->source_line, + _("function `%s': can't use function name as parameter name"), params->param); + return -1; + } else if (is_std_var(n->param)) { + error_ln(func->source_line, + _("function `%s': can't use special variable `%s' as a function parameter"), + params->param, n->param); + return -1; + } + } + + thisfunc = NULL; /* turn off warnings */ + + fname = params->param; + /* symbol table management */ + hp = remove_symbol(params->param); /* remove function name out of symbol table */ + if (hp != NULL) + freenode(hp); + r = lookup(fname); + if (r != NULL) { + error_ln(func->source_line, + _("function name `%s' previously defined"), fname); + return -1; + } else if (fname == builtin_func) /* not a valid function name */ + goto remove_params; + + /* add an implicit return at end; + * also used by 'return' command in debugger + */ + + (void) list_append(def, instruction(Op_push_i)); + def->lasti->memory = Nnull_string; + (void) list_append(def, instruction(Op_K_return)); + + if (do_profiling) + (void) list_prepend(def, instruction(Op_exec_count)); + + /* func->opcode is Op_func */ + (func + 1)->firsti = def->nexti; + (func + 1)->lasti = def->lasti; + (func + 2)->first_line = func->source_line; + (func + 2)->last_line = lastline; + + func->nexti = def->nexti; + bcfree(def); + + (void) list_append(rule_list, func + 1); /* debugging */ + + /* install the function */ + thisfunc = mk_symbol(Node_func, params); + (void) install_symbol(fname, thisfunc); + thisfunc->code_ptr = func; + func->func_body = thisfunc; + + for (n = params->rnode; n != NULL; n = n->rnode) + pcount++; + + if (pcount != 0) { + emalloc(pnames, char **, (pcount + 1) * sizeof(char *), "func_install"); + for (i = 0, n = params->rnode; i < pcount; i++, n = n->rnode) + pnames[i] = n->param; + pnames[pcount] = NULL; + } + thisfunc->parmlist = pnames; + + /* update lint table info */ + func_use(fname, FUNC_DEFINE); + + func_count++; /* used in profiler / pretty printer */ + +remove_params: + /* remove params from symbol table */ + pop_params(params->rnode); + return 0; +} + +/* remove_symbol --- remove a variable from the symbol table */ + +NODE * +remove_symbol(char *name) +{ + NODE *bucket, **save; + size_t len; + + len = strlen(name); + save = &(variables[hash(name, len, (unsigned long) HASHSIZE, NULL)]); + for (bucket = *save; bucket != NULL; bucket = bucket->hnext) { + if (len == bucket->hlength && strncmp(bucket->hname, name, len) == 0) { + var_count--; + *save = bucket->hnext; + return bucket; + } + save = &(bucket->hnext); + } + return NULL; +} + +/* pop_params --- remove list of function parameters from symbol table */ + +/* + * pop parameters out of the symbol table. do this in reverse order to + * avoid reading freed memory if there were duplicated parameters. + */ +static void +pop_params(NODE *params) +{ + NODE *hp; + if (params == NULL) + return; + pop_params(params->rnode); + hp = remove_symbol(params->param); + if (hp != NULL) + freenode(hp); +} + +/* make_param --- make NAME into a function parameter */ + +static NODE * +make_param(char *name) +{ + NODE *r; + + getnode(r); + r->type = Node_param_list; + r->rnode = NULL; + r->param_cnt = param_counter++; + return (install_symbol(name, r)); +} + +static struct fdesc { + char *name; + short used; + short defined; + struct fdesc *next; +} *ftable[HASHSIZE]; + +/* func_use --- track uses and definitions of functions */ + +static void +func_use(const char *name, enum defref how) +{ + struct fdesc *fp; + int len; + int ind; + + len = strlen(name); + ind = hash(name, len, HASHSIZE, NULL); + + for (fp = ftable[ind]; fp != NULL; fp = fp->next) { + if (strcmp(fp->name, name) == 0) { + if (how == FUNC_DEFINE) + fp->defined++; + else + fp->used++; + return; + } + } + + /* not in the table, fall through to allocate a new one */ + + emalloc(fp, struct fdesc *, sizeof(struct fdesc), "func_use"); + memset(fp, '\0', sizeof(struct fdesc)); + emalloc(fp->name, char *, len + 1, "func_use"); + strcpy(fp->name, name); + if (how == FUNC_DEFINE) + fp->defined++; + else + fp->used++; + fp->next = ftable[ind]; + ftable[ind] = fp; +} + +/* check_funcs --- verify functions that are called but not defined */ + +static void +check_funcs() +{ + struct fdesc *fp, *next; + int i; + + if (! in_main_context()) + goto free_mem; + + for (i = 0; i < HASHSIZE; i++) { + for (fp = ftable[i]; fp != NULL; fp = fp->next) { +#ifdef REALLYMEAN + /* making this the default breaks old code. sigh. */ + if (fp->defined == 0) { + error( + _("function `%s' called but never defined"), fp->name); + errcount++; + } +#else + if (do_lint && fp->defined == 0) + lintwarn( + _("function `%s' called but never defined"), fp->name); +#endif + if (do_lint && fp->used == 0) { + lintwarn(_("function `%s' defined but never called directly"), + fp->name); + } + } + } + +free_mem: + /* now let's free all the memory */ + for (i = 0; i < HASHSIZE; i++) { + for (fp = ftable[i]; fp != NULL; fp = next) { + next = fp->next; + efree(fp->name); + efree(fp); + } + ftable[i] = NULL; + } +} + +/* param_sanity --- look for parameters that are regexp constants */ + +static void +param_sanity(INSTRUCTION *arglist) +{ + INSTRUCTION *argl, *arg; + int i = 1; + + if (arglist == NULL) + return; + for (argl = arglist->nexti; argl; ) { + arg = argl->lasti; + if (arg->opcode == Op_match_rec) + warning_ln(arg->source_line, + _("regexp constant for parameter #%d yields boolean value"), i); + argl = arg->nexti; + i++; + } +} + +/* foreach_func --- execute given function for each awk function in symbol table. */ + +int +foreach_func(int (*pfunc)(INSTRUCTION *, void *), int sort, void *data) +{ + int i, j; + NODE *p; + int ret = 0; + + if (sort) { + NODE **tab; + + /* + * Walk through symbol table counting functions. + * Could be more than func_count if there are + * extension functions. + */ + for (i = j = 0; i < HASHSIZE; i++) { + for (p = variables[i]; p != NULL; p = p->hnext) { + if (p->hvalue->type == Node_func) { + j++; + } + } + } + + if (j == 0) + return 0; + + emalloc(tab, NODE **, j * sizeof(NODE *), "foreach_func"); + + /* now walk again, copying info */ + for (i = j = 0; i < HASHSIZE; i++) { + for (p = variables[i]; p != NULL; p = p->hnext) { + if (p->hvalue->type == Node_func) { + tab[j] = p; + j++; + } + } + } + + /* Shazzam! */ + qsort(tab, j, sizeof(NODE *), sym_comp); + + for (i = 0; i < j; i++) { + if ((ret = pfunc(tab[i]->hvalue->code_ptr, data)) != 0) + break; + } + + efree(tab); + return ret; + } + + /* unsorted */ + for (i = 0; i < HASHSIZE; i++) { + for (p = variables[i]; p != NULL; p = p->hnext) { + if (p->hvalue->type == Node_func + && (ret = pfunc(p->hvalue->code_ptr, data)) != 0) + return ret; + } + } + return 0; +} + +/* deferred variables --- those that are only defined if needed. */ + +/* + * Is there any reason to use a hash table for deferred variables? At the + * moment, there are only 1 to 3 such variables, so it may not be worth + * the overhead. If more modules start using this facility, it should + * probably be converted into a hash table. + */ + +static struct deferred_variable { + NODE *(*load_func)(void); + struct deferred_variable *next; + char name[1]; /* variable-length array */ +} *deferred_variables; + +/* register_deferred_variable --- add a var name and loading function to the list */ + +void +register_deferred_variable(const char *name, NODE *(*load_func)(void)) +{ + struct deferred_variable *dv; + size_t sl = strlen(name); + + emalloc(dv, struct deferred_variable *, sizeof(*dv)+sl, + "register_deferred_variable"); + dv->load_func = load_func; + dv->next = deferred_variables; + memcpy(dv->name, name, sl+1); + deferred_variables = dv; +} + +/* variable --- make sure NAME is in the symbol table */ + +NODE * +variable(char *name, NODETYPE type) +{ + NODE *r; + + if ((r = lookup(name)) != NULL) { + if (r->type == Node_func) { + error(_("function `%s' called with space between name and `(',\nor used as a variable or an array"), + r->vname); + errcount++; + r->type = Node_var_new; /* continue parsing instead of exiting */ + } + } else { + /* not found */ + struct deferred_variable *dv; + + for (dv = deferred_variables; TRUE; dv = dv->next) { + if (dv == NULL) { + /* + * This is the only case in which we may not free the string. + */ + if (type == Node_var) + r = mk_symbol(type, Nnull_string); + else + r = mk_symbol(type, (NODE *) NULL); + return install_symbol(name, r); + } + if (strcmp(name, dv->name) == 0) { + r = (*dv->load_func)(); + break; + } + } + } + efree(name); + return r; +} + +/* make_regnode --- make a regular expression node */ + +static NODE * +make_regnode(int type, NODE *exp) +{ + NODE *n; + + getnode(n); + memset(n, 0, sizeof(NODE)); + n->type = type; + n->re_cnt = 1; + + if (type == Node_regex) { + n->re_reg = make_regexp(exp->stptr, exp->stlen, FALSE, TRUE, FALSE); + if (n->re_reg == NULL) { + freenode(n); + return NULL; + } + n->re_exp = exp; + n->re_flags = CONSTANT; + } + return n; +} + + +/* mk_rexp --- make a regular expression constant */ + +static NODE * +mk_rexp(INSTRUCTION *list) +{ + INSTRUCTION *ip; + + ip = list->nexti; + if (ip == list->lasti && ip->opcode == Op_match_rec) + ip->opcode = Op_push_re; + else { + ip = instruction(Op_push_re); + ip->memory = make_regnode(Node_dynregex, NULL); + ip->nexti = list->lasti->nexti; + list->lasti->nexti = ip; + list->lasti = ip; + } + return ip->memory; +} + +/* isnoeffect --- when used as a statement, has no side effects */ + +static int +isnoeffect(OPCODE type) +{ + switch (type) { + case Op_times: + case Op_times_i: + case Op_quotient: + case Op_quotient_i: + case Op_mod: + case Op_mod_i: + case Op_plus: + case Op_plus_i: + case Op_minus: + case Op_minus_i: + case Op_subscript: + case Op_concat: + case Op_exp: + case Op_exp_i: + case Op_unary_minus: + case Op_field_spec: + case Op_and_final: + case Op_or_final: + case Op_equal: + case Op_notequal: + case Op_less: + case Op_greater: + case Op_leq: + case Op_geq: + case Op_match: + case Op_nomatch: + case Op_match_rec: + case Op_not: + case Op_in_array: + return TRUE; + default: + break; /* keeps gcc -Wall happy */ + } + + return FALSE; +} + +/* make_assignable --- make this operand an assignable one if posiible */ + +static INSTRUCTION * +make_assignable(INSTRUCTION *ip) +{ + switch (ip->opcode) { + case Op_push: + if (ip->memory->type == Node_param_list + && (ip->memory->flags & FUNC) != 0) + return NULL; + ip->opcode = Op_push_lhs; + return ip; + case Op_field_spec: + ip->opcode = Op_field_spec_lhs; + return ip; + case Op_subscript: + ip->opcode = Op_subscript_lhs; + return ip; + default: + break; /* keeps gcc -Wall happy */ + } + return NULL; +} + +/* stopme --- for debugging */ + +NODE * +stopme(int nargs ATTRIBUTE_UNUSED) +{ + return (NODE *) 0; +} + +/* dumpintlstr --- write out an initial .po file entry for the string */ + +static void +dumpintlstr(const char *str, size_t len) +{ + char *cp; + + /* See the GNU gettext distribution for details on the file format */ + + if (source != NULL) { + /* ala the gettext sources, remove leading `./'s */ + for (cp = source; cp[0] == '.' && cp[1] == '/'; cp += 2) + continue; + printf("#: %s:%d\n", cp, sourceline); + } + + printf("msgid "); + pp_string_fp(fprintf, stdout, str, len, '"', TRUE); + putchar('\n'); + printf("msgstr \"\"\n\n"); + fflush(stdout); +} + +/* dumpintlstr2 --- write out an initial .po file entry for the string and its plural */ + +static void +dumpintlstr2(const char *str1, size_t len1, const char *str2, size_t len2) +{ + char *cp; + + /* See the GNU gettext distribution for details on the file format */ + + if (source != NULL) { + /* ala the gettext sources, remove leading `./'s */ + for (cp = source; cp[0] == '.' && cp[1] == '/'; cp += 2) + continue; + printf("#: %s:%d\n", cp, sourceline); + } + + printf("msgid "); + pp_string_fp(fprintf, stdout, str1, len1, '"', TRUE); + putchar('\n'); + printf("msgid_plural "); + pp_string_fp(fprintf, stdout, str2, len2, '"', TRUE); + putchar('\n'); + printf("msgstr[0] \"\"\nmsgstr[1] \"\"\n\n"); + fflush(stdout); +} + +/* isarray --- can this type be subscripted? */ + +static int +isarray(NODE *n) +{ + switch (n->type) { + case Node_var_new: + case Node_var_array: + return TRUE; + case Node_param_list: + return (n->flags & FUNC) == 0; + case Node_array_ref: + cant_happen(); + break; + default: + break; /* keeps gcc -Wall happy */ + } + + return FALSE; +} + +/* mk_binary --- instructions for binary operators */ + +static INSTRUCTION * +mk_binary(INSTRUCTION *s1, INSTRUCTION *s2, INSTRUCTION *op) +{ + INSTRUCTION *ip1,*ip2; + AWKNUM res; + + ip2 = s2->nexti; + if (s2->lasti == ip2 && ip2->opcode == Op_push_i) { + /* do any numeric constant folding */ + ip1 = s1->nexti; + if (do_optimize > 1 + && ip1 == s1->lasti && ip1->opcode == Op_push_i + && (ip1->memory->flags & (STRCUR|STRING)) == 0 + && (ip2->memory->flags & (STRCUR|STRING)) == 0 + ) { + NODE *n1 = ip1->memory, *n2 = ip2->memory; + res = force_number(n1); + (void) force_number(n2); + switch (op->opcode) { + case Op_times: + res *= n2->numbr; + break; + case Op_quotient: + if (n2->numbr == 0.0) { + /* don't fatalize, allow parsing rest of the input */ + error_ln(op->source_line, _("division by zero attempted")); + goto regular; + } + + res /= n2->numbr; + break; + case Op_mod: + if (n2->numbr == 0.0) { + /* don't fatalize, allow parsing rest of the input */ + error_ln(op->source_line, _("division by zero attempted in `%%'")); + goto regular; + } +#ifdef HAVE_FMOD + res = fmod(res, n2->numbr); +#else /* ! HAVE_FMOD */ + (void) modf(res / n2->numbr, &res); + res = n1->numbr - res * n2->numbr; +#endif /* ! HAVE_FMOD */ + break; + case Op_plus: + res += n2->numbr; + break; + case Op_minus: + res -= n2->numbr; + break; + case Op_exp: + res = calc_exp(res, n2->numbr); + break; + default: + goto regular; + } + + op->opcode = Op_push_i; + op->memory = mk_number(res, (PERM|NUMCUR|NUMBER)); + n1->flags &= ~PERM; + n1->flags |= MALLOC; + n2->flags &= ~PERM; + n2->flags |= MALLOC; + unref(n1); + unref(n2); + bcfree(ip1); + bcfree(ip2); + bcfree(s1); + bcfree(s2); + return list_create(op); + } else { + /* do basic arithmetic optimisation */ + /* convert (Op_push_i Node_val) + (Op_plus) to (Op_plus_i Node_val) */ + switch (op->opcode) { + case Op_times: + op->opcode = Op_times_i; + break; + case Op_quotient: + op->opcode = Op_quotient_i; + break; + case Op_mod: + op->opcode = Op_mod_i; + break; + case Op_plus: + op->opcode = Op_plus_i; + break; + case Op_minus: + op->opcode = Op_minus_i; + break; + case Op_exp: + op->opcode = Op_exp_i; + break; + default: + goto regular; + } + + op->memory = ip2->memory; + bcfree(ip2); + bcfree(s2); /* Op_list */ + return list_append(s1, op); + } + } + +regular: + /* append lists s1, s2 and add `op' bytecode */ + (void) list_merge(s1, s2); + return list_append(s1, op); +} + +/* mk_boolean --- instructions for boolean and, or */ + +static INSTRUCTION * +mk_boolean(INSTRUCTION *left, INSTRUCTION *right, INSTRUCTION *op) +{ + INSTRUCTION *tp; + OPCODE opc, final_opc; + + opc = op->opcode; /* Op_and or Op_or */ + final_opc = (opc == Op_or) ? Op_or_final : Op_and_final; + + add_lint(right, LINT_assign_in_cond); + + tp = left->lasti; + + if (tp->opcode != final_opc) { /* x || y */ + list_append(right, instruction(final_opc)); + add_lint(left, LINT_assign_in_cond); + (void) list_append(left, op); + left->lasti->target_jmp = right->lasti; + + /* NB: target_stmt points to previous Op_and(Op_or) in a chain; + * target_stmt only used in the parser (see below). + */ + + left->lasti->target_stmt = left->lasti; + right->lasti->target_stmt = left->lasti; + } else { /* optimization for x || y || z || ... */ + INSTRUCTION *ip; + + op->opcode = final_opc; + (void) list_append(right, op); + op->target_stmt = tp; + tp->opcode = opc; + tp->target_jmp = op; + + /* update jump targets */ + for (ip = tp->target_stmt; ; ip = ip->target_stmt) { + assert(ip->opcode == opc); + assert(ip->target_jmp == tp); + /* if (ip->opcode == opc && ip->target_jmp == tp) */ + ip->target_jmp = op; + if (ip->target_stmt == ip) + break; + } + } + + return list_merge(left, right); +} + +/* mk_condition --- if-else and conditional */ + +static INSTRUCTION * +mk_condition(INSTRUCTION *cond, INSTRUCTION *ifp, INSTRUCTION *true_branch, + INSTRUCTION *elsep, INSTRUCTION *false_branch) +{ + /* + * ---------------- + * cond + * ---------------- + * t: [Op_jmp_false f ] + * ---------------- + * true_branch + * + * ---------------- + * [Op_jmp y] + * ---------------- + * f: + * false_branch + * ---------------- + * y: [Op_no_op] + * ---------------- + */ + + INSTRUCTION *ip; + + if (false_branch == NULL) { + false_branch = list_create(instruction(Op_no_op)); + if (elsep != NULL) { /* else { } */ + if (do_profiling) + (void) list_prepend(false_branch, elsep); + else + bcfree(elsep); + } + } else { + /* assert(elsep != NULL); */ + + /* avoid a series of no_op's: if .. else if .. else if .. */ + if (false_branch->lasti->opcode != Op_no_op) + (void) list_append(false_branch, instruction(Op_no_op)); + if (do_profiling) { + (void) list_prepend(false_branch, elsep); + false_branch->nexti->branch_end = false_branch->lasti; + (void) list_prepend(false_branch, instruction(Op_exec_count)); + } else + bcfree(elsep); + } + + (void) list_prepend(false_branch, instruction(Op_jmp)); + false_branch->nexti->target_jmp = false_branch->lasti; + + add_lint(cond, LINT_assign_in_cond); + ip = list_append(cond, instruction(Op_jmp_false)); + ip->lasti->target_jmp = false_branch->nexti->nexti; + + if (do_profiling) { + (void) list_prepend(ip, ifp); + (void) list_append(ip, instruction(Op_exec_count)); + ip->nexti->branch_if = ip->lasti; + ip->nexti->branch_else = false_branch->nexti; + } else + bcfree(ifp); + + if (true_branch != NULL) + list_merge(ip, true_branch); + return list_merge(ip, false_branch); +} + +enum defline { FIRST_LINE, LAST_LINE }; + +/* find_line -- find the first(last) line in a list of (pattern) instructions */ + +static int +find_line(INSTRUCTION *pattern, enum defline what) +{ + INSTRUCTION *ip; + int lineno = 0; + + for (ip = pattern->nexti; ip; ip = ip->nexti) { + if (what == LAST_LINE) { + if (ip->source_line > lineno) + lineno = ip->source_line; + } else { /* FIRST_LINE */ + if (ip->source_line > 0 + && (lineno == 0 || ip->source_line < lineno)) + lineno = ip->source_line; + } + if (ip == pattern->lasti) + break; + } + assert(lineno > 0); + return lineno; +} + +/* append_rule --- pattern-action instructions */ + +static INSTRUCTION * +append_rule(INSTRUCTION *pattern, INSTRUCTION *action) +{ + /* + * ---------------- + * pattern + * ---------------- + * [Op_jmp_false f ] + * ---------------- + * action + * ---------------- + * f: [Op_no_op ] + * ---------------- + */ + + INSTRUCTION *rp; + INSTRUCTION *tp; + INSTRUCTION *ip; + + if (rule != Rule) { + rp = pattern; + if (do_profiling) + (void) list_append(action, instruction(Op_no_op)); + (rp + 1)->firsti = action->nexti; + (rp + 1)->lasti = action->lasti; + (rp + 2)->first_line = pattern->source_line; + (rp + 2)->last_line = lastline; + ip = list_prepend(action, rp); + + } else { + rp = bcalloc(Op_rule, 3, 0); + rp->in_rule = Rule; + rp->source_file = source; + tp = instruction(Op_no_op); + + if (pattern == NULL) { + /* assert(action != NULL); */ + if (do_profiling) + (void) list_prepend(action, instruction(Op_exec_count)); + (rp + 1)->firsti = action->nexti; + (rp + 1)->lasti = tp; + (rp + 2)->first_line = firstline; + (rp + 2)->last_line = lastline; + rp->source_line = firstline; + ip = list_prepend(list_append(action, tp), rp); + } else { + (void) list_append(pattern, instruction(Op_jmp_false)); + pattern->lasti->target_jmp = tp; + (rp + 2)->first_line = find_line(pattern, FIRST_LINE); + rp->source_line = (rp + 2)->first_line; + if (action == NULL) { + (rp + 2)->last_line = find_line(pattern, LAST_LINE); + action = list_create(instruction(Op_K_print_rec)); + if (do_profiling) + (void) list_prepend(action, instruction(Op_exec_count)); + } else + (rp + 2)->last_line = lastline; + + if (do_profiling) { + (void) list_prepend(pattern, instruction(Op_exec_count)); + (void) list_prepend(action, instruction(Op_exec_count)); + } + (rp + 1)->firsti = action->nexti; + (rp + 1)->lasti = tp; + ip = list_append( + list_merge(list_prepend(pattern, rp), + action), + tp); + } + + } + + list_append(rule_list, rp + 1); + + if (rule_block[rule] == NULL) + rule_block[rule] = ip; + else + (void) list_merge(rule_block[rule], ip); + + return rule_block[rule]; +} + +/* mk_assignment --- assignment bytecodes */ + +static INSTRUCTION * +mk_assignment(INSTRUCTION *lhs, INSTRUCTION *rhs, INSTRUCTION *op) +{ + INSTRUCTION *tp; + INSTRUCTION *ip; + + tp = lhs->lasti; + switch (tp->opcode) { + case Op_field_spec: + tp->opcode = Op_field_spec_lhs; + break; + case Op_subscript: + tp->opcode = Op_subscript_lhs; + break; + case Op_push: + case Op_push_array: + tp->opcode = Op_push_lhs; + break; + default: + cant_happen(); + } + + tp->do_reference = (op->opcode != Op_assign); /* check for uninitialized reference */ + + if (rhs != NULL) + ip = list_merge(rhs, lhs); + else + ip = lhs; + + (void) list_append(ip, op); + + if (tp->opcode == Op_push_lhs + && tp->memory->type == Node_var + && tp->memory->var_assign + ) { + tp->do_reference = FALSE; /* no uninitialized reference checking + * for a special variable. + */ + (void) list_append(ip, instruction(Op_var_assign)); + ip->lasti->assign_var = tp->memory->var_assign; + } else if (tp->opcode == Op_field_spec_lhs) { + (void) list_append(ip, instruction(Op_field_assign)); + ip->lasti->field_assign = (Func_ptr) 0; + tp->target_assign = ip->lasti; + } + + return ip; +} + +/* optimize_assignment --- peephole optimization for assignment */ + +static INSTRUCTION * +optimize_assignment(INSTRUCTION *exp) +{ + INSTRUCTION *i1; + INSTRUCTION *i2; + INSTRUCTION *i3; + + /* + * Optimize assignment statements array[subs] = x; var = x; $n = x; + * string concatenation of the form s = s t. + * + * 1) Array element assignment array[subs] = x: + * Replaces Op_push_array + Op_subscript_lhs + Op_assign + Op_pop + * with single instruction Op_store_sub. + * Limitation: 1 dimension and sub is simple var/value. + * + * 2) Simple variable assignment var = x: + * Replaces Op_push_lhs + Op_assign + Op_pop with Op_store_var. + * + * 3) Field assignment $n = x: + * Replaces Op_field_spec_lhs + Op_assign + Op_field_assign + Op_pop + * with Op_store_field. + * + * 4) Optimization for string concatenation: + * For cases like x = x y, uses realloc to include y in x; + * also eliminates instructions Op_push_lhs and Op_pop. + */ + + /* + * N.B.: do not append Op_pop instruction to the returned + * instruction list if optimized. None of these + * optimized instructions pushes the r-value of assignment + * onto the runtime stack. + */ + + i2 = NULL; + i1 = exp->lasti; + + if ( ! do_optimize + || ( i1->opcode != Op_assign + && i1->opcode != Op_field_assign) + ) + return list_append(exp, instruction(Op_pop)); + + for (i2 = exp->nexti; i2 != i1; i2 = i2->nexti) { + switch (i2->opcode) { + case Op_concat: + if (i2->nexti->opcode == Op_push_lhs /* l.h.s is a simple variable */ + && (i2->concat_flag & CSVAR) /* 1st exp in r.h.s is a simple variable; + * see Op_concat in the grammer above. + */ + && i2->nexti->memory == exp->nexti->memory /* and the same as in l.h.s */ + && i2->nexti->nexti == i1 + && i1->opcode == Op_assign + ) { + /* s = s ... optimization */ + + /* avoid stuff like x = x (x = y) or x = x gsub(/./, "b", x); + * check for l-value reference to this variable in the r.h.s. + * Also, avoid function calls in general to guard against + * global variable assignment. + */ + + for (i3 = exp->nexti->nexti; i3 != i2; i3 = i3->nexti) { + if ((i3->opcode == Op_push_lhs && i3->memory == i2->nexti->memory) + || i3->opcode == Op_func_call) + return list_append(exp, instruction(Op_pop)); /* no optimization */ + } + + /* remove the variable from r.h.s */ + i3 = exp->nexti; + exp->nexti = i3->nexti; + bcfree(i3); + + if (--i2->expr_count == 1) /* one less expression in Op_concat */ + i2->opcode = Op_no_op; + + i3 = i2->nexti; + assert(i3->opcode == Op_push_lhs); + i3->opcode = Op_assign_concat; /* change Op_push_lhs to Op_assign_concat */ + i3->nexti = NULL; + bcfree(i1); /* Op_assign */ + exp->lasti = i3; /* update Op_list */ + return exp; + } + break; + + case Op_field_spec_lhs: + if (i2->nexti->opcode == Op_assign + && i2->nexti->nexti == i1 + && i1->opcode == Op_field_assign + ) { + /* $n = .. */ + i2->opcode = Op_store_field; + bcfree(i2->nexti); /* Op_assign */ + i2->nexti = NULL; + bcfree(i1); /* Op_field_assign */ + exp->lasti = i2; /* update Op_list */ + return exp; + } + break; + + case Op_push_array: + if (i2->nexti->nexti->opcode == Op_subscript_lhs) { + i3 = i2->nexti->nexti; + if (i3->sub_count == 1 + && i3->nexti == i1 + && i1->opcode == Op_assign + ) { + /* array[sub] = .. */ + i3->opcode = Op_store_sub; + i3->memory = i2->memory; + i3->expr_count = 1; /* sub_count shadows memory, + * so use expr_count instead. + */ + i3->nexti = NULL; + i2->opcode = Op_no_op; + bcfree(i1); /* Op_assign */ + exp->lasti = i3; /* update Op_list */ + return exp; + } + } + break; + + case Op_push_lhs: + if (i2->nexti == i1 + && i1->opcode == Op_assign + ) { + /* var = .. */ + i2->opcode = Op_store_var; + i2->nexti = NULL; + bcfree(i1); /* Op_assign */ + exp->lasti = i2; /* update Op_list */ + return exp; + } + break; + + default: + break; + } + } + + /* no optimization */ + return list_append(exp, instruction(Op_pop)); +} + + +/* mk_getline --- make instructions for getline */ + +static INSTRUCTION * +mk_getline(INSTRUCTION *op, INSTRUCTION *var, INSTRUCTION *redir, int redirtype) +{ + INSTRUCTION *ip; + INSTRUCTION *tp; + INSTRUCTION *asgn = NULL; + + /* + * getline [var] < [file] + * + * [ file (simp_exp)] + * [ [ var ] ] + * [ Op_K_getline_redir|NULL|redir_type|into_var] + * [ [var_assign] ] + * + */ + + if (redir == NULL) { + int sline = op->source_line; + bcfree(op); + op = bcalloc(Op_K_getline, 2, sline); + (op + 1)->target_endfile = ip_endfile; + (op + 1)->target_beginfile = ip_beginfile; + } + + if (var != NULL) { + tp = make_assignable(var->lasti); + assert(tp != NULL); + + /* check if we need after_assign bytecode */ + if (tp->opcode == Op_push_lhs + && tp->memory->type == Node_var + && tp->memory->var_assign + ) { + asgn = instruction(Op_var_assign); + asgn->assign_ctxt = op->opcode; + asgn->assign_var = tp->memory->var_assign; + } else if (tp->opcode == Op_field_spec_lhs) { + asgn = instruction(Op_field_assign); + asgn->assign_ctxt = op->opcode; + asgn->field_assign = (Func_ptr) 0; /* determined at run time */ + tp->target_assign = asgn; + } + if (redir != NULL) { + ip = list_merge(redir, var); + (void) list_append(ip, op); + } else + ip = list_append(var, op); + } else if (redir != NULL) + ip = list_append(redir, op); + else + ip = list_create(op); + op->into_var = (var != NULL); + op->redir_type = (redir != NULL) ? redirtype : 0; + + return (asgn == NULL ? ip : list_append(ip, asgn)); +} + + +/* mk_for_loop --- for loop bytecodes */ + +static INSTRUCTION * +mk_for_loop(INSTRUCTION *forp, INSTRUCTION *init, INSTRUCTION *cond, + INSTRUCTION *incr, INSTRUCTION *body) +{ + /* + * ------------------------ + * init (may be NULL) + * ------------------------ + * x: + * cond (Op_no_op if NULL) + * ------------------------ + * [ Op_jmp_false tb ] + * ------------------------ + * body (may be NULL) + * ------------------------ + * tc: + * incr (may be NULL) + * [ Op_jmp x ] + * ------------------------ + * tb:[ Op_no_op ] + */ + + INSTRUCTION *ip, *tbreak, *tcont; + INSTRUCTION *jmp; + INSTRUCTION *pp_cond; + INSTRUCTION *ret; + + tbreak = instruction(Op_no_op); + + if (cond != NULL) { + add_lint(cond, LINT_assign_in_cond); + pp_cond = cond->nexti; + ip = cond; + (void) list_append(ip, instruction(Op_jmp_false)); + ip->lasti->target_jmp = tbreak; + } else { + pp_cond = instruction(Op_no_op); + ip = list_create(pp_cond); + } + + if (init != NULL) + ip = list_merge(init, ip); + + if (do_profiling) { + (void) list_append(ip, instruction(Op_exec_count)); + (forp + 1)->forloop_cond = pp_cond; + (forp + 1)->forloop_body = ip->lasti; + } + + if (body != NULL) + (void) list_merge(ip, body); + + jmp = instruction(Op_jmp); + jmp->target_jmp = pp_cond; + if (incr == NULL) + tcont = jmp; + else { + tcont = incr->nexti; + (void) list_merge(ip, incr); + } + + (void) list_append(ip, jmp); + ret = list_append(ip, tbreak); + fix_break_continue(ret, tbreak, tcont); + + if (do_profiling) { + forp->target_break = tbreak; + forp->target_continue = tcont; + ret = list_prepend(ret, forp); + } /* else + forp is NULL */ + + return ret; +} + +/* add_lint --- add lint warning bytecode if needed */ + +static void +add_lint(INSTRUCTION *list, LINTTYPE linttype) +{ +#ifndef NO_LINT + INSTRUCTION *ip; + + switch (linttype) { + case LINT_assign_in_cond: + ip = list->lasti; + if (ip->opcode == Op_var_assign || ip->opcode == Op_field_assign) { + assert(ip != list->nexti); + for (ip = list->nexti; ip->nexti != list->lasti; ip = ip->nexti) + ; + } + + if (ip->opcode == Op_assign || ip->opcode == Op_assign_concat) { + list_append(list, instruction(Op_lint)); + list->lasti->lint_type = linttype; + } + break; + + case LINT_no_effect: + if (list->lasti->opcode == Op_pop && list->nexti != list->lasti) { + for (ip = list->nexti; ip->nexti != list->lasti; ip = ip->nexti) + ; + + if (do_lint) { /* compile-time warning */ + if (isnoeffect(ip->opcode)) + lintwarn_ln(ip->source_line, ("statement may have no effect")); + } + + if (ip->opcode == Op_push) { /* run-time warning */ + list_append(list, instruction(Op_lint)); + list->lasti->lint_type = linttype; + } + } + break; + + default: + break; + } +#endif +} + +/* mk_expression_list --- list of bytecode lists */ + +static INSTRUCTION * +mk_expression_list(INSTRUCTION *list, INSTRUCTION *s1) +{ + INSTRUCTION *r; + + /* we can't just combine all bytecodes, since we need to + * process individual expressions for a few builtins in snode() (-: + */ + + /* -- list of lists */ + /* [Op_list| ... ]------ + * | + * [Op_list| ... ] -- | + * ... | | + * ... <------- | + * [Op_list| ... ] -- | + * ... | | + * ... | | + * ... <------- -- + */ + + assert(s1 != NULL && s1->opcode == Op_list); + if (list == NULL) { + list = instruction(Op_list); + list->nexti = s1; + list->lasti = s1->lasti; + return list; + } + + /* append expression to the end of the list */ + + r = list->lasti; + r->nexti = s1; + list->lasti = s1->lasti; + return list; +} + +/* count_expressions --- fixup expression_list from mk_expression_list. + * returns no of expressions in list. isarg is true + * for function arguments. + */ + +static int +count_expressions(INSTRUCTION **list, int isarg) +{ + INSTRUCTION *expr; + INSTRUCTION *r = NULL; + int count = 0; + + if (*list == NULL) /* error earlier */ + return 0; + + for (expr = (*list)->nexti; expr; ) { + INSTRUCTION *t1, *t2; + t1 = expr->nexti; + t2 = expr->lasti; + if (isarg && t1 == t2 && t1->opcode == Op_push) + t1->opcode = Op_push_param; + if (++count == 1) + r = expr; + else + (void) list_merge(r, expr); + expr = t2->nexti; + } + + assert(count > 0); + if (! isarg && count > max_args) + max_args = count; + bcfree(*list); + *list = r; + return count; +} + +/* fix_break_continue --- fix up break & continue codes in loop bodies */ + +static void +fix_break_continue(INSTRUCTION *list, INSTRUCTION *b_target, INSTRUCTION *c_target) +{ + INSTRUCTION *ip; + + list->lasti->nexti = NULL; /* just to make sure */ + + for (ip = list->nexti; ip != NULL; ip = ip->nexti) { + switch (ip->opcode) { + case Op_K_break: + if (ip->target_jmp == NULL) + ip->target_jmp = b_target; + break; + + case Op_K_continue: + if (ip->target_jmp == NULL) + ip->target_jmp = c_target; + break; + + default: + /* this is to keep the compiler happy. sheesh. */ + break; + } + } +} + + +/* append_symbol --- append symbol to the list of symbols + * installed in the symbol table. + */ + +void +append_symbol(char *name) +{ + NODE *hp; + + /* N.B.: func_install removes func name and reinstalls it; + * and we get two entries for it here!. destroy_symbol() + * will find and destroy the Node_func which is what we want. + */ + + getnode(hp); + hp->hname = name; /* shallow copy */ + hp->hnext = symbol_list->hnext; + symbol_list->hnext = hp; +} + +/* release_symbol --- free symbol list and optionally remove symbol from symbol table */ + +void +release_symbols(NODE *symlist, int keep_globals) +{ + NODE *hp, *n; + + for (hp = symlist->hnext; hp != NULL; hp = n) { + if (! keep_globals) { + /* destroys globals, function, and params + * if still in symbol table and not removed by func_install + * due to syntax error. + */ + destroy_symbol(hp->hname); + } + n = hp->hnext; + freenode(hp); + } + symlist->hnext = NULL; +} + +/* destroy_symbol --- remove a symbol from symbol table +* and free all associated memory. +*/ + +void +destroy_symbol(char *name) +{ + NODE *symbol, *hp; + + symbol = lookup(name); + if (symbol == NULL) + return; + + if (symbol->type == Node_func) { + char **varnames; + NODE *func, *n; + + func = symbol; + varnames = func->parmlist; + if (varnames != NULL) + efree(varnames); + + /* function parameters of type Node_param_list */ + for (n = func->lnode->rnode; n != NULL; ) { + NODE *np; + np = n->rnode; + efree(n->param); + freenode(n); + n = np; + } + freenode(func->lnode); + func_count--; + + } else if (symbol->type == Node_var_array) + assoc_clear(symbol); + else if (symbol->type == Node_var) + unref(symbol->var_value); + + /* remove from symbol table */ + hp = remove_symbol(name); + efree(hp->hname); + freenode(hp->hvalue); + freenode(hp); +} + +#define pool_size d.dl +#define freei x.xi +static INSTRUCTION *pool_list; +static AWK_CONTEXT *curr_ctxt = NULL; + +/* new_context --- create a new execution context. */ + +AWK_CONTEXT * +new_context() +{ + AWK_CONTEXT *ctxt; + + emalloc(ctxt, AWK_CONTEXT *, sizeof(AWK_CONTEXT), "new_context"); + memset(ctxt, 0, sizeof(AWK_CONTEXT)); + ctxt->srcfiles.next = ctxt->srcfiles.prev = &ctxt->srcfiles; + ctxt->rule_list.opcode = Op_list; + ctxt->rule_list.lasti = &ctxt->rule_list; + return ctxt; +} + +/* set_context --- change current execution context. */ + +static void +set_context(AWK_CONTEXT *ctxt) +{ + pool_list = &ctxt->pools; + symbol_list = &ctxt->symbols; + srcfiles = &ctxt->srcfiles; + rule_list = &ctxt->rule_list; + install_func = ctxt->install_func; + curr_ctxt = ctxt; +} + +/* + * push_context: + * + * Switch to the given context after saving the current one. The set + * of active execution contexts forms a stack; the global or main context + * is at the bottom of the stack. + */ + +void +push_context(AWK_CONTEXT *ctxt) +{ + ctxt->prev = curr_ctxt; + /* save current source and sourceline */ + if (curr_ctxt != NULL) { + curr_ctxt->sourceline = sourceline; + curr_ctxt->source = source; + } + sourceline = 0; + source = NULL; + set_context(ctxt); +} + +/* pop_context --- switch to previous execution context. */ + +void +pop_context() +{ + AWK_CONTEXT *ctxt; + + assert(curr_ctxt != NULL); + ctxt = curr_ctxt->prev; + /* restore source and sourceline */ + sourceline = ctxt->sourceline; + source = ctxt->source; + set_context(ctxt); +} + +/* in_main_context --- are we in the main context ? */ + +int +in_main_context() +{ + assert(curr_ctxt != NULL); + return (curr_ctxt->prev == NULL); +} + +/* free_context --- free context structure and related data. */ + +void +free_context(AWK_CONTEXT *ctxt, int keep_globals) +{ + SRCFILE *s, *sn; + + if (ctxt == NULL) + return; + + assert(curr_ctxt != ctxt); + + /* free all code including function codes */ + free_bcpool(&ctxt->pools); + /* free symbols */ + release_symbols(&ctxt->symbols, keep_globals); + /* free srcfiles */ + for (s = &ctxt->srcfiles; s != &ctxt->srcfiles; s = sn) { + sn = s->next; + if (s->stype != SRC_CMDLINE && s->stype != SRC_STDIN) + efree(s->fullpath); + efree(s->src); + efree(s); + } + efree(ctxt); +} + +/* free_bc_internal --- free internal memory of an instruction. */ + +static void +free_bc_internal(INSTRUCTION *cp) +{ + NODE *m; + + switch(cp->opcode) { + case Op_func_call: + if (cp->func_name != NULL + && cp->func_name != builtin_func + ) + efree(cp->func_name); + break; + case Op_push_re: + case Op_match_rec: + case Op_match: + case Op_nomatch: + m = cp->memory; + if (m->re_reg != NULL) + refree(m->re_reg); + if (m->re_exp != NULL) + unref(m->re_exp); + if (m->re_text != NULL) + unref(m->re_text); + freenode(m); + break; + case Op_token: /* token lost during error recovery in yyparse */ + if (cp->lextok != NULL) + efree(cp->lextok); + break; + case Op_illegal: + cant_happen(); + default: + break; + } +} + + +/* INSTR_CHUNK must be > largest code size (3) */ +#define INSTR_CHUNK 127 + +/* bcfree --- deallocate instruction */ + +void +bcfree(INSTRUCTION *cp) +{ + cp->opcode = 0; + cp->nexti = pool_list->freei; + pool_list->freei = cp; +} + +/* bcalloc --- allocate a new instruction */ + +INSTRUCTION * +bcalloc(OPCODE op, int size, int srcline) +{ + INSTRUCTION *cp; + + if (size > 1) { + /* wide instructions Op_rule, Op_func_call .. */ + emalloc(cp, INSTRUCTION *, (size + 1) * sizeof(INSTRUCTION), "bcalloc"); + cp->pool_size = size; + cp->nexti = pool_list->nexti; + pool_list->nexti = cp++; + } else { + INSTRUCTION *pool; + + pool = pool_list->freei; + if (pool == NULL) { + INSTRUCTION *last; + emalloc(cp, INSTRUCTION *, (INSTR_CHUNK + 1) * sizeof(INSTRUCTION), "bcalloc"); + + cp->pool_size = INSTR_CHUNK; + cp->nexti = pool_list->nexti; + pool_list->nexti = cp; + pool = ++cp; + last = &pool[INSTR_CHUNK - 1]; + for (; cp <= last; cp++) { + cp->opcode = 0; + cp->nexti = cp + 1; + } + --cp; + cp->nexti = NULL; + } + cp = pool; + pool_list->freei = cp->nexti; + } + + memset(cp, 0, size * sizeof(INSTRUCTION)); + cp->opcode = op; + cp->source_line = srcline; + return cp; +} + +/* free_bcpool --- free list of instruction memory pools */ + +static void +free_bcpool(INSTRUCTION *pl) +{ + INSTRUCTION *pool, *tmp; + + for (pool = pl->nexti; pool != NULL; pool = tmp) { + INSTRUCTION *cp, *last; + long psiz; + psiz = pool->pool_size; + if (psiz == INSTR_CHUNK) + last = pool + psiz; + else + last = pool + 1; + for (cp = pool + 1; cp <= last ; cp++) { + if (cp->opcode != 0) + free_bc_internal(cp); + } + tmp = pool->nexti; + efree(pool); + } + memset(pl, 0, sizeof(INSTRUCTION)); +} + + +static inline INSTRUCTION * +list_create(INSTRUCTION *x) +{ + INSTRUCTION *l; + + l = instruction(Op_list); + l->nexti = x; + l->lasti = x; + return l; +} + +static inline INSTRUCTION * +list_append(INSTRUCTION *l, INSTRUCTION *x) +{ +#ifdef GAWKDEBUG + if (l->opcode != Op_list) + cant_happen(); +#endif + l->lasti->nexti = x; + l->lasti = x; + return l; +} + +static inline INSTRUCTION * +list_prepend(INSTRUCTION *l, INSTRUCTION *x) +{ +#ifdef GAWKDEBUG + if (l->opcode != Op_list) + cant_happen(); +#endif + x->nexti = l->nexti; + l->nexti = x; + return l; +} + +static inline INSTRUCTION * +list_merge(INSTRUCTION *l1, INSTRUCTION *l2) +{ +#ifdef GAWKDEBUG + if (l1->opcode != Op_list) + cant_happen(); + if (l2->opcode != Op_list) + cant_happen(); +#endif + l1->lasti->nexti = l2->nexti; + l1->lasti = l2->lasti; + bcfree(l2); + return l1; +} + +/* See if name is a special token. */ + +int +check_special(const char *name) +{ + int low, high, mid; + int i; +#if 'a' == 0x81 /* it's EBCDIC */ + static int did_sort = FALSE; + + if (! did_sort) { + qsort((void *) tokentab, + sizeof(tokentab) / sizeof(tokentab[0]), + sizeof(tokentab[0]), tokcompare); + did_sort = TRUE; + } +#endif + + low = 0; + high = (sizeof(tokentab) / sizeof(tokentab[0])) - 1; + while (low <= high) { + mid = (low + high) / 2; + i = *name - tokentab[mid].operator[0]; + if (i == 0) + i = strcmp(name, tokentab[mid].operator); + + if (i < 0) /* token < mid */ + high = mid - 1; + else if (i > 0) /* token > mid */ + low = mid + 1; + else { + if ((do_traditional && (tokentab[mid].flags & GAWKX)) + || (do_posix && (tokentab[mid].flags & NOT_POSIX))) + return -1; + return mid; + } + } + return -1; +} + +/* + * This provides a private version of functions that act like VMS's + * variable-length record filesystem, where there was a bug on + * certain source files. + */ + +static FILE *fp = NULL; + +/* read_one_line --- return one input line at a time. mainly for debugging. */ + +static ssize_t +read_one_line(int fd, void *buffer, size_t count) +{ + char buf[BUFSIZ]; + + /* Minor potential memory leak here. Too bad. */ + if (fp == NULL) { + fp = fdopen(fd, "r"); + if (fp == NULL) { + fprintf(stderr, "ugh. fdopen: %s\n", strerror(errno)); + gawk_exit(EXIT_FAILURE); + } + } + + if (fgets(buf, sizeof buf, fp) == NULL) + return 0; + + memcpy(buffer, buf, strlen(buf)); + return strlen(buf); +} + +/* one_line_close --- close the open file being read with read_one_line() */ + +static int +one_line_close(int fd) +{ + int ret; + + if (fp == NULL || fd != fileno(fp)) + fatal("debugging read/close screwed up!"); + + ret = fclose(fp); + fp = NULL; + return ret; +} + + diff --git a/awkgram.y b/awkgram.y new file mode 100644 index 0000000..f5d104d --- /dev/null +++ b/awkgram.y @@ -0,0 +1,6039 @@ +/* + * awkgram.y --- yacc/bison parser + */ + +/* + * Copyright (C) 1986, 1988, 1989, 1991-2012 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +%{ +#ifdef GAWKDEBUG +#define YYDEBUG 12 +#endif + +#include "awk.h" + +#if defined(__STDC__) && __STDC__ < 1 /* VMS weirdness, maybe elsewhere */ +#define signed /**/ +#endif + +static void yyerror(const char *m, ...) ATTRIBUTE_PRINTF_1; +static void error_ln(int line, const char *m, ...) ATTRIBUTE_PRINTF_2; +static void lintwarn_ln(int line, const char *m, ...) ATTRIBUTE_PRINTF_2; +static void warning_ln(int line, const char *m, ...) ATTRIBUTE_PRINTF_2; +static char *get_src_buf(void); +static int yylex(void); +int yyparse(void); +static INSTRUCTION *snode(INSTRUCTION *subn, INSTRUCTION *op); +static int func_install(INSTRUCTION *fp, INSTRUCTION *def); +static void pop_params(NODE *params); +static NODE *make_param(char *pname); +static NODE *mk_rexp(INSTRUCTION *exp); +static void append_param(char *pname); +static int dup_parms(INSTRUCTION *fp, NODE *func); +static void param_sanity(INSTRUCTION *arglist); +static int parms_shadow(INSTRUCTION *pc, int *shadow); +static int isnoeffect(OPCODE type); +static INSTRUCTION *make_assignable(INSTRUCTION *ip); +static void dumpintlstr(const char *str, size_t len); +static void dumpintlstr2(const char *str1, size_t len1, const char *str2, size_t len2); +static int isarray(NODE *n); +static int include_source(INSTRUCTION *file); +static void next_sourcefile(void); +static char *tokexpand(void); + +#define instruction(t) bcalloc(t, 1, 0) + +static INSTRUCTION *mk_program(void); +static INSTRUCTION *append_rule(INSTRUCTION *pattern, INSTRUCTION *action); +static INSTRUCTION *mk_condition(INSTRUCTION *cond, INSTRUCTION *ifp, INSTRUCTION *true_branch, + INSTRUCTION *elsep, INSTRUCTION *false_branch); +static INSTRUCTION *mk_expression_list(INSTRUCTION *list, INSTRUCTION *s1); +static INSTRUCTION *mk_for_loop(INSTRUCTION *forp, INSTRUCTION *init, INSTRUCTION *cond, + INSTRUCTION *incr, INSTRUCTION *body); +static void fix_break_continue(INSTRUCTION *list, INSTRUCTION *b_target, INSTRUCTION *c_target); +static INSTRUCTION *mk_binary(INSTRUCTION *s1, INSTRUCTION *s2, INSTRUCTION *op); +static INSTRUCTION *mk_boolean(INSTRUCTION *left, INSTRUCTION *right, INSTRUCTION *op); +static INSTRUCTION *mk_assignment(INSTRUCTION *lhs, INSTRUCTION *rhs, INSTRUCTION *op); +static INSTRUCTION *mk_getline(INSTRUCTION *op, INSTRUCTION *opt_var, INSTRUCTION *redir, int redirtype); +static NODE *make_regnode(int type, NODE *exp); +static int count_expressions(INSTRUCTION **list, int isarg); +static INSTRUCTION *optimize_assignment(INSTRUCTION *exp); +static void add_lint(INSTRUCTION *list, LINTTYPE linttype); + +enum defref { FUNC_DEFINE, FUNC_USE }; +static void func_use(const char *name, enum defref how); +static void check_funcs(void); +static void free_bcpool(INSTRUCTION *pl); + +static ssize_t read_one_line(int fd, void *buffer, size_t count); +static int one_line_close(int fd); + +static void (*install_func)(char *) = NULL; + +static int want_source = FALSE; +static int want_regexp; /* lexical scanning kludge */ +static int can_return; /* parsing kludge */ +static int rule = 0; + +const char *const ruletab[] = { + "?", + "BEGIN", + "Rule", + "END", + "BEGINFILE", + "ENDFILE", +}; + +static int in_print = FALSE; /* lexical scanning kludge for print */ +static int in_parens = 0; /* lexical scanning kludge for print */ +static int sub_counter = 0; /* array dimension counter for use in delete */ +static char *lexptr = NULL; /* pointer to next char during parsing */ +static char *lexend; +static char *lexptr_begin; /* keep track of where we were for error msgs */ +static char *lexeme; /* beginning of lexeme for debugging */ +static int lexeof; /* seen EOF for current source? */ +static char *thisline = NULL; +static int in_braces = 0; /* count braces for firstline, lastline in an 'action' */ +static int lastline = 0; +static int firstline = 0; +static SRCFILE *sourcefile = NULL; /* current program source */ +static int lasttok = 0; +static int eof_warned = FALSE; /* GLOBAL: want warning for each file */ +static int break_allowed; /* kludge for break */ +static int continue_allowed; /* kludge for continue */ + + +#define END_FILE -1000 +#define END_SRC -2000 + +#define YYDEBUG_LEXER_TEXT (lexeme) +static int param_counter; +static NODE *func_params; /* list of parameters for the current function */ +static char *tokstart = NULL; +static char *tok = NULL; +static char *tokend; +static int errcount = 0; + +static NODE *symbol_list; +extern void destroy_symbol(char *name); + +static long func_count; /* total number of functions */ + +#define HASHSIZE 1021 /* this constant only used here */ +NODE *variables[HASHSIZE]; +static int var_count; /* total number of global variables */ + +extern char *source; +extern int sourceline; +extern SRCFILE *srcfiles; +extern INSTRUCTION *rule_list; +extern int max_args; + +static INSTRUCTION *rule_block[sizeof(ruletab)]; + +static INSTRUCTION *ip_rec; +static INSTRUCTION *ip_newfile; +static INSTRUCTION *ip_atexit = NULL; +static INSTRUCTION *ip_end; +static INSTRUCTION *ip_endfile; +static INSTRUCTION *ip_beginfile; + +static inline INSTRUCTION *list_create(INSTRUCTION *x); +static inline INSTRUCTION *list_append(INSTRUCTION *l, INSTRUCTION *x); +static inline INSTRUCTION *list_prepend(INSTRUCTION *l, INSTRUCTION *x); +static inline INSTRUCTION *list_merge(INSTRUCTION *l1, INSTRUCTION *l2); + +extern double fmod(double x, double y); +/* + * This string cannot occur as a real awk identifier. + * Use it as a special token to make function parsing + * uniform, but if it's seen, don't install the function. + * e.g. + * function split(x) { return x } + * function x(a) { return a } + * should only produce one error message, and not core dump. + */ +static char builtin_func[] = "@builtin"; + +#define YYSTYPE INSTRUCTION * +%} + +%token FUNC_CALL NAME REGEXP FILENAME +%token YNUMBER YSTRING +%token RELOP IO_OUT IO_IN +%token ASSIGNOP ASSIGN MATCHOP CONCAT_OP +%token SUBSCRIPT +%token LEX_BEGIN LEX_END LEX_IF LEX_ELSE LEX_RETURN LEX_DELETE +%token LEX_SWITCH LEX_CASE LEX_DEFAULT LEX_WHILE LEX_DO LEX_FOR LEX_BREAK LEX_CONTINUE +%token LEX_PRINT LEX_PRINTF LEX_NEXT LEX_EXIT LEX_FUNCTION +%token LEX_BEGINFILE LEX_ENDFILE +%token LEX_GETLINE LEX_NEXTFILE +%token LEX_IN +%token LEX_AND LEX_OR INCREMENT DECREMENT +%token LEX_BUILTIN LEX_LENGTH +%token LEX_EOF +%token LEX_INCLUDE LEX_EVAL +%token NEWLINE + +/* Lowest to highest */ +%right ASSIGNOP ASSIGN SLASH_BEFORE_EQUAL +%right '?' ':' +%left LEX_OR +%left LEX_AND +%left LEX_GETLINE +%nonassoc LEX_IN +%left FUNC_CALL LEX_BUILTIN LEX_LENGTH +%nonassoc ',' +%left MATCHOP +%nonassoc RELOP '<' '>' IO_IN IO_OUT +%left CONCAT_OP +%left YSTRING YNUMBER +%left '+' '-' +%left '*' '/' '%' +%right '!' UNARY +%right '^' +%left INCREMENT DECREMENT +%left '$' +%left '(' ')' +%% + +program + : /* empty */ + | program rule + { + rule = 0; + yyerrok; + } + | program nls + | program LEX_EOF + { + next_sourcefile(); + } + | program error + { + rule = 0; + /* + * If errors, give up, don't produce an infinite + * stream of syntax error messages. + */ + /* yyerrok; */ + } + ; + +rule + : pattern action + { + (void) append_rule($1, $2); + } + | pattern statement_term + { + if (rule != Rule) { + msg(_("%s blocks must have an action part"), ruletab[rule]); + errcount++; + } else if ($1 == NULL) { + msg(_("each rule must have a pattern or an action part")); + errcount++; + } else /* pattern rule with non-empty pattern */ + (void) append_rule($1, NULL); + } + | function_prologue action + { + can_return = FALSE; + if ($1 && func_install($1, $2) < 0) + YYABORT; + func_params = NULL; + yyerrok; + } + | '@' LEX_INCLUDE source statement_term + { + want_source = FALSE; + yyerrok; + } + ; + +source + : FILENAME + { + if (include_source($1) < 0) + YYABORT; + efree($1->lextok); + bcfree($1); + $$ = NULL; + } + | FILENAME error + { $$ = NULL; } + | error + { $$ = NULL; } + ; + +pattern + : /* empty */ + { $$ = NULL; rule = Rule; } + | exp + { $$ = $1; rule = Rule; } + | exp ',' opt_nls exp + { + INSTRUCTION *tp; + + add_lint($1, LINT_assign_in_cond); + add_lint($4, LINT_assign_in_cond); + + tp = instruction(Op_no_op); + list_prepend($1, bcalloc(Op_line_range, !!do_profiling + 1, 0)); + $1->nexti->triggered = FALSE; + $1->nexti->target_jmp = $4->nexti; + + list_append($1, instruction(Op_cond_pair)); + $1->lasti->line_range = $1->nexti; + $1->lasti->target_jmp = tp; + + list_append($4, instruction(Op_cond_pair)); + $4->lasti->line_range = $1->nexti; + $4->lasti->target_jmp = tp; + if (do_profiling) { + ($1->nexti + 1)->condpair_left = $1->lasti; + ($1->nexti + 1)->condpair_right = $4->lasti; + } + $$ = list_append(list_merge($1, $4), tp); + rule = Rule; + } + | LEX_BEGIN + { + static int begin_seen = 0; + if (do_lint_old && ++begin_seen == 2) + warning_ln($1->source_line, + _("old awk does not support multiple `BEGIN' or `END' rules")); + + $1->in_rule = rule = BEGIN; + $1->source_file = source; + $$ = $1; + } + | LEX_END + { + static int end_seen = 0; + if (do_lint_old && ++end_seen == 2) + warning_ln($1->source_line, + _("old awk does not support multiple `BEGIN' or `END' rules")); + + $1->in_rule = rule = END; + $1->source_file = source; + $$ = $1; + } + | LEX_BEGINFILE + { + $1->in_rule = rule = BEGINFILE; + $1->source_file = source; + $$ = $1; + } + | LEX_ENDFILE + { + $1->in_rule = rule = ENDFILE; + $1->source_file = source; + $$ = $1; + } + ; + +action + : l_brace statements r_brace opt_semi opt_nls + { + if ($2 == NULL) + $$ = list_create(instruction(Op_no_op)); + else + $$ = $2; + } + ; + +func_name + : NAME + { $$ = $1; } + | FUNC_CALL + { $$ = $1; } + | lex_builtin + { + yyerror(_("`%s' is a built-in function, it cannot be redefined"), + tokstart); + $1->opcode = Op_symbol; /* Op_symbol instead of Op_token so that + * free_bc_internal does not try to free it + */ + $1->lextok = builtin_func; + $$ = $1; + /* yyerrok; */ + } + | '@' LEX_EVAL + { $$ = $2; } + ; + +lex_builtin + : LEX_BUILTIN + | LEX_LENGTH + ; + +function_prologue + : LEX_FUNCTION + { + param_counter = 0; + func_params = NULL; + } + func_name '(' opt_param_list r_paren opt_nls + { + NODE *t; + + $1->source_file = source; + t = make_param($3->lextok); + $3->lextok = NULL; + bcfree($3); + t->flags |= FUNC; + t->rnode = func_params; + func_params = t; + $$ = $1; + can_return = TRUE; + /* check for duplicate parameter names */ + if (dup_parms($1, t)) + errcount++; + } + ; + +regexp + /* + * In this rule, want_regexp tells yylex that the next thing + * is a regexp so it should read up to the closing slash. + */ + : a_slash + { ++want_regexp; } + REGEXP /* The terminating '/' is consumed by yylex(). */ + { + NODE *n, *exp; + char *re; + size_t len; + + re = $3->lextok; + len = strlen(re); + if (do_lint) { + if (len == 0) + lintwarn_ln($3->source_line, + _("regexp constant `//' looks like a C++ comment, but is not")); + else if ((re)[0] == '*' && (re)[len-1] == '*') + /* possible C comment */ + lintwarn_ln($3->source_line, + _("regexp constant `/%s/' looks like a C comment, but is not"), re); + } + + exp = make_str_node(re, len, ALREADY_MALLOCED); + n = make_regnode(Node_regex, exp); + if (n == NULL) { + unref(exp); + YYABORT; + } + $$ = $3; + $$->opcode = Op_match_rec; + $$->memory = n; + } + ; + +a_slash + : '/' + { bcfree($1); } + | SLASH_BEFORE_EQUAL + ; + +statements + : /* empty */ + { $$ = NULL; } + | statements statement + { + if ($2 == NULL) + $$ = $1; + else { + add_lint($2, LINT_no_effect); + if ($1 == NULL) + $$ = $2; + else + $$ = list_merge($1, $2); + } + yyerrok; + } + | statements error + { $$ = NULL; } + ; + +statement_term + : nls + | semi opt_nls + ; + +statement + : semi opt_nls + { $$ = NULL; } + | l_brace statements r_brace + { $$ = $2; } + | if_statement + { + if (do_profiling) + $$ = list_prepend($1, instruction(Op_exec_count)); + else + $$ = $1; + } + | LEX_SWITCH '(' exp r_paren opt_nls l_brace case_statements opt_nls r_brace + { + INSTRUCTION *dflt, *curr = NULL, *cexp, *cstmt; + INSTRUCTION *ip, *nextc, *tbreak; + const char **case_values = NULL; + int maxcount = 128; + int case_count = 0; + int i; + + tbreak = instruction(Op_no_op); + cstmt = list_create(tbreak); + cexp = list_create(instruction(Op_pop)); + dflt = instruction(Op_jmp); + dflt->target_jmp = tbreak; /* if no case match and no explicit default */ + + if ($7 != NULL) { + curr = $7->nexti; + bcfree($7); /* Op_list */ + } /* else + curr = NULL; */ + + for(; curr != NULL; curr = nextc) { + INSTRUCTION *caseexp = curr->case_exp; + INSTRUCTION *casestmt = curr->case_stmt; + + nextc = curr->nexti; + if (curr->opcode == Op_K_case) { + if (caseexp->opcode == Op_push_i) { + /* a constant scalar */ + char *caseval; + caseval = force_string(caseexp->memory)->stptr; + for (i = 0; i < case_count; i++) { + if (strcmp(caseval, case_values[i]) == 0) + error_ln(curr->source_line, + _("duplicate case values in switch body: %s"), caseval); + } + + if (case_values == NULL) + emalloc(case_values, const char **, sizeof(char *) * maxcount, "statement"); + else if (case_count >= maxcount) { + maxcount += 128; + erealloc(case_values, const char **, sizeof(char*) * maxcount, "statement"); + } + case_values[case_count++] = caseval; + } else { + /* match a constant regex against switch expression. */ + (curr + 1)->match_exp = TRUE; + } + curr->stmt_start = casestmt->nexti; + curr->stmt_end = casestmt->lasti; + (void) list_prepend(cexp, curr); + (void) list_prepend(cexp, caseexp); + } else { + if (dflt->target_jmp != tbreak) + error_ln(curr->source_line, + _("duplicate `default' detected in switch body")); + else + dflt->target_jmp = casestmt->nexti; + + if (do_profiling) { + curr->stmt_start = casestmt->nexti; + curr->stmt_end = casestmt->lasti; + (void) list_prepend(cexp, curr); + } else + bcfree(curr); + } + + cstmt = list_merge(casestmt, cstmt); + } + + if (case_values != NULL) + efree(case_values); + + ip = $3; + if (do_profiling) { + (void) list_prepend(ip, $1); + (void) list_prepend(ip, instruction(Op_exec_count)); + $1->target_break = tbreak; + ($1 + 1)->switch_start = cexp->nexti; + ($1 + 1)->switch_end = cexp->lasti; + }/* else + $1 is NULL */ + + (void) list_append(cexp, dflt); + (void) list_merge(ip, cexp); + $$ = list_merge(ip, cstmt); + + break_allowed--; + fix_break_continue(ip, tbreak, NULL); + } + | LEX_WHILE '(' exp r_paren opt_nls statement + { + /* + * ----------------- + * tc: + * cond + * ----------------- + * [Op_jmp_false tb ] + * ----------------- + * body + * ----------------- + * [Op_jmp tc ] + * tb:[Op_no_op ] + */ + + INSTRUCTION *ip, *tbreak, *tcont; + + tbreak = instruction(Op_no_op); + add_lint($3, LINT_assign_in_cond); + tcont = $3->nexti; + ip = list_append($3, instruction(Op_jmp_false)); + ip->lasti->target_jmp = tbreak; + + if (do_profiling) { + (void) list_append(ip, instruction(Op_exec_count)); + $1->target_break = tbreak; + $1->target_continue = tcont; + ($1 + 1)->while_body = ip->lasti; + (void) list_prepend(ip, $1); + }/* else + $1 is NULL */ + + if ($6 != NULL) + (void) list_merge(ip, $6); + (void) list_append(ip, instruction(Op_jmp)); + ip->lasti->target_jmp = tcont; + $$ = list_append(ip, tbreak); + + break_allowed--; + continue_allowed--; + fix_break_continue(ip, tbreak, tcont); + } + | LEX_DO opt_nls statement LEX_WHILE '(' exp r_paren opt_nls + { + /* + * ----------------- + * z: + * body + * ----------------- + * tc: + * cond + * ----------------- + * [Op_jmp_true | z ] + * tb:[Op_no_op ] + */ + + INSTRUCTION *ip, *tbreak, *tcont; + + tbreak = instruction(Op_no_op); + tcont = $6->nexti; + add_lint($6, LINT_assign_in_cond); + if ($3 != NULL) + ip = list_merge($3, $6); + else + ip = list_prepend($6, instruction(Op_no_op)); + if (do_profiling) + (void) list_prepend(ip, instruction(Op_exec_count)); + (void) list_append(ip, instruction(Op_jmp_true)); + ip->lasti->target_jmp = ip->nexti; + $$ = list_append(ip, tbreak); + + break_allowed--; + continue_allowed--; + fix_break_continue(ip, tbreak, tcont); + + if (do_profiling) { + $1->target_break = tbreak; + $1->target_continue = tcont; + ($1 + 1)->doloop_cond = tcont; + $$ = list_prepend(ip, $1); + bcfree($4); + } /* else + $1 and $4 are NULLs */ + } + | LEX_FOR '(' NAME LEX_IN simple_variable r_paren opt_nls statement + { + INSTRUCTION *ip; + char *var_name = $3->lextok; + + if ($8 != NULL + && $8->lasti->opcode == Op_K_delete + && $8->lasti->expr_count == 1 + && $8->nexti->opcode == Op_push + && ($8->nexti->memory->type != Node_var || !($8->nexti->memory->var_update)) + && strcmp($8->nexti->memory->vname, var_name) == 0 + ) { + + /* Efficiency hack. Recognize the special case of + * + * for (iggy in foo) + * delete foo[iggy] + * + * and treat it as if it were + * + * delete foo + * + * Check that the body is a `delete a[i]' statement, + * and that both the loop var and array names match. + */ + NODE *arr = NULL; + + ip = $8->nexti->nexti; + if ($5->nexti->opcode == Op_push && $5->lasti == $5->nexti) + arr = $5->nexti->memory; + if (arr != NULL + && ip->opcode == Op_no_op + && ip->nexti->opcode == Op_push_array + && strcmp(ip->nexti->memory->vname, arr->vname) == 0 + && ip->nexti->nexti == $8->lasti + ) { + (void) make_assignable($8->nexti); + $8->lasti->opcode = Op_K_delete_loop; + $8->lasti->expr_count = 0; + if ($1 != NULL) + bcfree($1); + efree(var_name); + bcfree($3); + bcfree($4); + bcfree($5); + $$ = $8; + } else + goto regular_loop; + } else { + INSTRUCTION *tbreak, *tcont; + + /* [ Op_push_array a ] + * [ Op_arrayfor_init | ib ] + * ic:[ Op_arrayfor_incr | ib ] + * [ Op_var_assign if any ] + * + * body + * + * [Op_jmp | ic ] + * ib:[Op_arrayfor_final ] + */ +regular_loop: + ip = $5; + ip->nexti->opcode = Op_push_array; + + tbreak = instruction(Op_arrayfor_final); + $4->opcode = Op_arrayfor_incr; + $4->array_var = variable(var_name, Node_var); + $4->target_jmp = tbreak; + tcont = $4; + $3->opcode = Op_arrayfor_init; + $3->target_jmp = tbreak; + (void) list_append(ip, $3); + + if (do_profiling) { + $1->opcode = Op_K_arrayfor; + $1->target_continue = tcont; + $1->target_break = tbreak; + (void) list_append(ip, $1); + } /* else + $1 is NULL */ + + /* add update_FOO instruction if necessary */ + if ($4->array_var->type == Node_var && $4->array_var->var_update) { + (void) list_append(ip, instruction(Op_var_update)); + ip->lasti->update_var = $4->array_var->var_update; + } + (void) list_append(ip, $4); + + /* add set_FOO instruction if necessary */ + if ($4->array_var->type == Node_var && $4->array_var->var_assign) { + (void) list_append(ip, instruction(Op_var_assign)); + ip->lasti->assign_var = $4->array_var->var_assign; + } + + if (do_profiling) { + (void) list_append(ip, instruction(Op_exec_count)); + ($1 + 1)->forloop_cond = $4; + ($1 + 1)->forloop_body = ip->lasti; + } + + if ($8 != NULL) + (void) list_merge(ip, $8); + + (void) list_append(ip, instruction(Op_jmp)); + ip->lasti->target_jmp = $4; + $$ = list_append(ip, tbreak); + fix_break_continue(ip, tbreak, tcont); + } + + break_allowed--; + continue_allowed--; + } + | LEX_FOR '(' opt_simple_stmt semi opt_nls exp semi opt_nls opt_simple_stmt r_paren opt_nls statement + { + $$ = mk_for_loop($1, $3, $6, $9, $12); + + break_allowed--; + continue_allowed--; + } + | LEX_FOR '(' opt_simple_stmt semi opt_nls semi opt_nls opt_simple_stmt r_paren opt_nls statement + { + $$ = mk_for_loop($1, $3, (INSTRUCTION *) NULL, $8, $11); + + break_allowed--; + continue_allowed--; + } + | non_compound_stmt + { + if (do_profiling) + $$ = list_prepend($1, instruction(Op_exec_count)); + else + $$ = $1; + } + ; + +non_compound_stmt + : LEX_BREAK statement_term + { + if (! break_allowed) + error_ln($1->source_line, + _("`break' is not allowed outside a loop or switch")); + $1->target_jmp = NULL; + $$ = list_create($1); + + } + | LEX_CONTINUE statement_term + { + if (! continue_allowed) + error_ln($1->source_line, + _("`continue' is not allowed outside a loop")); + $1->target_jmp = NULL; + $$ = list_create($1); + + } + | LEX_NEXT statement_term + { + /* if inside function (rule = 0), resolve context at run-time */ + if (rule && rule != Rule) + error_ln($1->source_line, + _("`next' used in %s action"), ruletab[rule]); + $1->target_jmp = ip_rec; + $$ = list_create($1); + } + | LEX_NEXTFILE statement_term + { + if (do_traditional) + error_ln($1->source_line, + _("`nextfile' is a gawk extension")); + + /* if inside function (rule = 0), resolve context at run-time */ + if (rule == BEGIN || rule == END || rule == ENDFILE) + error_ln($1->source_line, + _("`nextfile' used in %s action"), ruletab[rule]); + + $1->target_newfile = ip_newfile; + $1->target_endfile = ip_endfile; + $$ = list_create($1); + } + | LEX_EXIT opt_exp statement_term + { + /* Initialize the two possible jump targets, the actual target + * is resolved at run-time. + */ + $1->target_end = ip_end; /* first instruction in end_block */ + $1->target_atexit = ip_atexit; /* cleanup and go home */ + + if ($2 == NULL) { + $$ = list_create($1); + (void) list_prepend($$, instruction(Op_push_i)); + $$->nexti->memory = Nnull_string; + } else + $$ = list_append($2, $1); + } + | LEX_RETURN + { + if (! can_return) + yyerror(_("`return' used outside function context")); + } opt_exp statement_term { + if ($3 == NULL) { + $$ = list_create($1); + (void) list_prepend($$, instruction(Op_push_i)); + $$->nexti->memory = Nnull_string; + } else + $$ = list_append($3, $1); + } + | simple_stmt statement_term + ; + + /* + * A simple_stmt exists to satisfy a constraint in the POSIX + * grammar allowing them to occur as the 1st and 3rd parts + * in a `for (...;...;...)' loop. This is a historical oddity + * inherited from Unix awk, not at all documented in the AK&W + * awk book. We support it, as this was reported as a bug. + * We don't bother to document it though. So there. + */ +simple_stmt + : print { in_print = TRUE; in_parens = 0; } print_expression_list output_redir + { + /* + * Optimization: plain `print' has no expression list, so $3 is null. + * If $3 is NULL or is a bytecode list for $0 use Op_K_print_rec, + * which is faster for these two cases. + */ + + if ($1->opcode == Op_K_print && + ($3 == NULL + || ($3->lasti->opcode == Op_field_spec + && $3->nexti->nexti->nexti == $3->lasti + && $3->nexti->nexti->opcode == Op_push_i + && $3->nexti->nexti->memory->type == Node_val + && $3->nexti->nexti->memory->numbr == 0.0) + ) + ) { + static short warned = FALSE; + /* ----------------- + * output_redir + * [ redirect exp ] + * ----------------- + * expression_list + * ------------------ + * [Op_K_print_rec | NULL | redir_type | expr_count] + */ + + if ($3 != NULL) { + bcfree($3->lasti); /* Op_field_spec */ + $3->nexti->nexti->memory->flags &= ~PERM; + $3->nexti->nexti->memory->flags |= MALLOC; + unref($3->nexti->nexti->memory); /* Node_val */ + bcfree($3->nexti->nexti); /* Op_push_i */ + bcfree($3->nexti); /* Op_list */ + bcfree($3); /* Op_list */ + } else { + if (do_lint && (rule == BEGIN || rule == END) && ! warned) { + warned = TRUE; + lintwarn_ln($1->source_line, + _("plain `print' in BEGIN or END rule should probably be `print \"\"'")); + } + } + + $1->expr_count = 0; + $1->opcode = Op_K_print_rec; + if ($4 == NULL) { /* no redircetion */ + $1->redir_type = 0; + $$ = list_create($1); + } else { + INSTRUCTION *ip; + ip = $4->nexti; + $1->redir_type = ip->redir_type; + $4->nexti = ip->nexti; + bcfree(ip); + $$ = list_append($4, $1); + } + } else { + /* ----------------- + * [ output_redir ] + * [ redirect exp ] + * ----------------- + * [ expression_list ] + * ------------------ + * [$1 | NULL | redir_type | expr_count] + * + */ + + if ($4 == NULL) { /* no redirection */ + if ($3 == NULL) { /* printf without arg */ + $1->expr_count = 0; + $1->redir_type = 0; + $$ = list_create($1); + } else { + INSTRUCTION *t = $3; + $1->expr_count = count_expressions(&t, FALSE); + $1->redir_type = 0; + $$ = list_append(t, $1); + } + } else { + INSTRUCTION *ip; + ip = $4->nexti; + $1->redir_type = ip->redir_type; + $4->nexti = ip->nexti; + bcfree(ip); + if ($3 == NULL) { + $1->expr_count = 0; + $$ = list_append($4, $1); + } else { + INSTRUCTION *t = $3; + $1->expr_count = count_expressions(&t, FALSE); + $$ = list_append(list_merge($4, t), $1); + } + } + } + } + + | LEX_DELETE NAME { sub_counter = 0; } delete_subscript_list + { + char *arr = $2->lextok; + + $2->opcode = Op_push_array; + $2->memory = variable(arr, Node_var_new); + + if ($4 == NULL) { + static short warned = FALSE; + + if (do_lint && ! warned) { + warned = TRUE; + lintwarn_ln($1->source_line, + _("`delete array' is a gawk extension")); + } + if (do_traditional) + error_ln($1->source_line, + _("`delete array' is a gawk extension")); + $1->expr_count = 0; + $$ = list_append(list_create($2), $1); + } else { + $1->expr_count = sub_counter; + $$ = list_append(list_append($4, $2), $1); + } + } + | LEX_DELETE '(' NAME ')' + /* + * this is for tawk compatibility. maybe the warnings + * should always be done. + */ + { + static short warned = FALSE; + char *arr = $3->lextok; + + if (do_lint && ! warned) { + warned = TRUE; + lintwarn_ln($1->source_line, + _("`delete(array)' is a non-portable tawk extension")); + } + if (do_traditional) { + error_ln($1->source_line, + _("`delete array' is a gawk extension")); + } + $3->memory = variable(arr, Node_var_new); + $3->opcode = Op_push_array; + $1->expr_count = 0; + $$ = list_append(list_create($3), $1); + } + | exp + { $$ = optimize_assignment($1); } + ; + +opt_simple_stmt + : /* empty */ + { $$ = NULL; } + | simple_stmt + { $$ = $1; } + ; + +case_statements + : /* empty */ + { $$ = NULL; } + | case_statements case_statement + { + if ($1 == NULL) + $$ = list_create($2); + else + $$ = list_prepend($1, $2); + } + | case_statements error + { $$ = NULL; } + ; + +case_statement + : LEX_CASE case_value colon opt_nls statements + { + INSTRUCTION *casestmt = $5; + if ($5 == NULL) + casestmt = list_create(instruction(Op_no_op)); + if (do_profiling) + (void) list_prepend(casestmt, instruction(Op_exec_count)); + $1->case_exp = $2; + $1->case_stmt = casestmt; + bcfree($3); + $$ = $1; + } + | LEX_DEFAULT colon opt_nls statements + { + INSTRUCTION *casestmt = $4; + if ($4 == NULL) + casestmt = list_create(instruction(Op_no_op)); + if (do_profiling) + (void) list_prepend(casestmt, instruction(Op_exec_count)); + bcfree($2); + $1->case_stmt = casestmt; + $$ = $1; + } + ; + +case_value + : YNUMBER + { $$ = $1; } + | '-' YNUMBER %prec UNARY + { + $2->memory->numbr = -(force_number($2->memory)); + bcfree($1); + $$ = $2; + } + | '+' YNUMBER %prec UNARY + { + bcfree($1); + $$ = $2; + } + | YSTRING + { $$ = $1; } + | regexp + { + $1->opcode = Op_push_re; + $$ = $1; + } + ; + +print + : LEX_PRINT + { $$ = $1; } + | LEX_PRINTF + { $$ = $1; } + ; + + /* + * Note: ``print(x)'' is already parsed by the first rule, + * so there is no good in covering it by the second one too. + */ +print_expression_list + : opt_expression_list + | '(' expression_list r_paren + { + $$ = $2; + } + ; + +output_redir + : /* empty */ + { + in_print = FALSE; + in_parens = 0; + $$ = NULL; + } + | IO_OUT { in_print = FALSE; in_parens = 0; } common_exp + { + if ($1->redir_type == redirect_twoway + && $3->lasti->opcode == Op_K_getline_redir + && $3->lasti->redir_type == redirect_twoway) + yyerror(_("multistage two-way pipelines don't work")); + $$ = list_prepend($3, $1); + } + ; + +if_statement + : LEX_IF '(' exp r_paren opt_nls statement + { + $$ = mk_condition($3, $1, $6, NULL, NULL); + } + | LEX_IF '(' exp r_paren opt_nls statement + LEX_ELSE opt_nls statement + { + $$ = mk_condition($3, $1, $6, $7, $9); + } + ; + +nls + : NEWLINE + | nls NEWLINE + ; + +opt_nls + : /* empty */ + | nls + ; + +input_redir + : /* empty */ + { $$ = NULL; } + | '<' simp_exp + { + bcfree($1); + $$ = $2; + } + ; + +opt_param_list + : /* empty */ + | param_list + ; + +param_list + : NAME + { + append_param($1->lextok); + $1->lextok = NULL; + bcfree($1); + } + | param_list comma NAME + { + append_param($3->lextok); + $3->lextok = NULL; + bcfree($3); + yyerrok; + } + | error + { /* func_params = NULL; */ } + | param_list error + { /* func_params = NULL; */ } + | param_list comma error + { /* func_params = NULL; */ } + ; + +/* optional expression, as in for loop */ +opt_exp + : /* empty */ + { $$ = NULL; } + | exp + { $$ = $1; } + ; + +opt_expression_list + : /* empty */ + { $$ = NULL; } + | expression_list + { $$ = $1; } + ; + +expression_list + : exp + { $$ = mk_expression_list(NULL, $1); } + | expression_list comma exp + { + $$ = mk_expression_list($1, $3); + yyerrok; + } + | error + { $$ = NULL; } + | expression_list error + { $$ = NULL; } + | expression_list error exp + { $$ = NULL; } + | expression_list comma error + { $$ = NULL; } + ; + +/* Expressions, not including the comma operator. */ +exp + : variable assign_operator exp %prec ASSIGNOP + { + if (do_lint && $3->lasti->opcode == Op_match_rec) + lintwarn_ln($2->source_line, + _("regular expression on right of assignment")); + $$ = mk_assignment($1, $3, $2); + } + | exp LEX_AND exp + { $$ = mk_boolean($1, $3, $2); } + | exp LEX_OR exp + { $$ = mk_boolean($1, $3, $2); } + | exp MATCHOP exp + { + if ($1->lasti->opcode == Op_match_rec) + warning_ln($2->source_line, + _("regular expression on left of `~' or `!~' operator")); + + if ($3->lasti == $3->nexti && $3->nexti->opcode == Op_match_rec) { + $2->memory = $3->nexti->memory; + bcfree($3->nexti); /* Op_match_rec */ + bcfree($3); /* Op_list */ + $$ = list_append($1, $2); + } else { + $2->memory = make_regnode(Node_dynregex, NULL); + $$ = list_append(list_merge($1, $3), $2); + } + } + | exp LEX_IN simple_variable + { + if (do_lint_old) + warning_ln($2->source_line, + _("old awk does not support the keyword `in' except after `for'")); + $3->nexti->opcode = Op_push_array; + $2->opcode = Op_in_array; + $2->expr_count = 1; + $$ = list_append(list_merge($1, $3), $2); + } + | exp a_relop exp %prec RELOP + { + if (do_lint && $3->lasti->opcode == Op_match_rec) + lintwarn_ln($2->source_line, + _("regular expression on right of comparison")); + $$ = list_append(list_merge($1, $3), $2); + } + | exp '?' exp ':' exp + { $$ = mk_condition($1, $2, $3, $4, $5); } + | common_exp + { $$ = $1; } + ; + +assign_operator + : ASSIGN + { $$ = $1; } + | ASSIGNOP + { $$ = $1; } + | SLASH_BEFORE_EQUAL ASSIGN /* `/=' */ + { + $2->opcode = Op_assign_quotient; + $$ = $2; + } + ; + +relop_or_less + : RELOP + { $$ = $1; } + | '<' + { $$ = $1; } + ; + +a_relop + : relop_or_less + { $$ = $1; } + | '>' + { $$ = $1; } + ; + +common_exp + : simp_exp + { $$ = $1; } + | simp_exp_nc + { $$ = $1; } + | common_exp simp_exp %prec CONCAT_OP + { + int count = 2; + int is_simple_var = FALSE; + + if ($1->lasti->opcode == Op_concat) { + /* multiple (> 2) adjacent strings optimization */ + is_simple_var = ($1->lasti->concat_flag & CSVAR); + count = $1->lasti->expr_count + 1; + $1->lasti->opcode = Op_no_op; + } else { + is_simple_var = ($1->nexti->opcode == Op_push + && $1->lasti == $1->nexti); /* first exp. is a simple + * variable?; kludge for use + * in Op_assign_concat. + */ + } + + if (do_optimize > 1 + && $1->nexti == $1->lasti && $1->nexti->opcode == Op_push_i + && $2->nexti == $2->lasti && $2->nexti->opcode == Op_push_i + ) { + NODE *n1 = $1->nexti->memory; + NODE *n2 = $2->nexti->memory; + size_t nlen; + + (void) force_string(n1); + (void) force_string(n2); + nlen = n1->stlen + n2->stlen; + erealloc(n1->stptr, char *, nlen + 2, "constant fold"); + memcpy(n1->stptr + n1->stlen, n2->stptr, n2->stlen); + n1->stlen = nlen; + n1->stptr[nlen] = '\0'; + n1->flags &= ~(NUMCUR|NUMBER); + n1->flags |= (STRING|STRCUR); + + n2->flags &= ~PERM; + n2->flags |= MALLOC; + unref(n2); + bcfree($2->nexti); + bcfree($2); + $$ = $1; + } else { + $$ = list_append(list_merge($1, $2), instruction(Op_concat)); + $$->lasti->concat_flag = (is_simple_var ? CSVAR : 0); + $$->lasti->expr_count = count; + if (count > max_args) + max_args = count; + } + } + ; + +simp_exp + : non_post_simp_exp + /* Binary operators in order of decreasing precedence. */ + | simp_exp '^' simp_exp + { $$ = mk_binary($1, $3, $2); } + | simp_exp '*' simp_exp + { $$ = mk_binary($1, $3, $2); } + | simp_exp '/' simp_exp + { $$ = mk_binary($1, $3, $2); } + | simp_exp '%' simp_exp + { $$ = mk_binary($1, $3, $2); } + | simp_exp '+' simp_exp + { $$ = mk_binary($1, $3, $2); } + | simp_exp '-' simp_exp + { $$ = mk_binary($1, $3, $2); } + | LEX_GETLINE opt_variable input_redir + { + /* + * In BEGINFILE/ENDFILE, allow `getline var < file' + */ + + if (rule == BEGINFILE || rule == ENDFILE) { + if ($2 != NULL && $3 != NULL) + ; /* all ok */ + else { + if ($2 != NULL) + error_ln($1->source_line, + _("`getline var' invalid inside `%s' rule"), ruletab[rule]); + else + error_ln($1->source_line, + _("`getline' invalid inside `%s' rule"), ruletab[rule]); + } + } + if (do_lint && rule == END && $3 == NULL) + lintwarn_ln($1->source_line, + _("non-redirected `getline' undefined inside END action")); + $$ = mk_getline($1, $2, $3, redirect_input); + } + | variable INCREMENT + { + $2->opcode = Op_postincrement; + $$ = mk_assignment($1, NULL, $2); + } + | variable DECREMENT + { + $2->opcode = Op_postdecrement; + $$ = mk_assignment($1, NULL, $2); + } + | '(' expression_list r_paren LEX_IN simple_variable + { + if (do_lint_old) { + warning_ln($4->source_line, + _("old awk does not support the keyword `in' except after `for'")); + warning_ln($4->source_line, + _("old awk does not support multidimensional arrays")); + } + $5->nexti->opcode = Op_push_array; + $4->opcode = Op_in_array; + if ($2 == NULL) { /* error */ + errcount++; + $4->expr_count = 0; + $$ = list_merge($5, $4); + } else { + INSTRUCTION *t = $2; + $4->expr_count = count_expressions(&t, FALSE); + $$ = list_append(list_merge(t, $5), $4); + } + } + ; + +/* Expressions containing "| getline" lose the ability to be on the + right-hand side of a concatenation. */ +simp_exp_nc + : common_exp IO_IN LEX_GETLINE opt_variable + { + $$ = mk_getline($3, $4, $1, $2->redir_type); + bcfree($2); + } + /* Binary operators in order of decreasing precedence. */ + | simp_exp_nc '^' simp_exp + { $$ = mk_binary($1, $3, $2); } + | simp_exp_nc '*' simp_exp + { $$ = mk_binary($1, $3, $2); } + | simp_exp_nc '/' simp_exp + { $$ = mk_binary($1, $3, $2); } + | simp_exp_nc '%' simp_exp + { $$ = mk_binary($1, $3, $2); } + | simp_exp_nc '+' simp_exp + { $$ = mk_binary($1, $3, $2); } + | simp_exp_nc '-' simp_exp + { $$ = mk_binary($1, $3, $2); } + ; + +non_post_simp_exp + : regexp + { + $$ = list_create($1); + } + | '!' simp_exp %prec UNARY + { + if ($2->opcode == Op_match_rec) { + $2->opcode = Op_nomatch; + $1->opcode = Op_push_i; + $1->memory = mk_number(0.0, (PERM|NUMCUR|NUMBER)); + $$ = list_append(list_append(list_create($1), + instruction(Op_field_spec)), $2); + } else { + if (do_optimize > 1 && $2->nexti == $2->lasti + && $2->nexti->opcode == Op_push_i + ) { + NODE *n = $2->nexti->memory; + if ((n->flags & (STRCUR|STRING)) != 0) { + n->numbr = (AWKNUM) (n->stlen == 0); + n->flags &= ~(STRCUR|STRING); + n->flags |= (NUMCUR|NUMBER); + efree(n->stptr); + n->stptr = NULL; + n->stlen = 0; + } else + n->numbr = (AWKNUM) (n->numbr == 0.0); + bcfree($1); + $$ = $2; + } else { + $1->opcode = Op_not; + add_lint($2, LINT_assign_in_cond); + $$ = list_append($2, $1); + } + } + } + | '(' exp r_paren + { $$ = $2; } + | LEX_BUILTIN '(' opt_expression_list r_paren + { + $$ = snode($3, $1); + if ($$ == NULL) + YYABORT; + } + | LEX_LENGTH '(' opt_expression_list r_paren + { + $$ = snode($3, $1); + if ($$ == NULL) + YYABORT; + } + | LEX_LENGTH + { + static short warned1 = FALSE; + + if (do_lint && ! warned1) { + warned1 = TRUE; + lintwarn_ln($1->source_line, + _("call of `length' without parentheses is not portable")); + } + $$ = snode(NULL, $1); + if ($$ == NULL) + YYABORT; + } + | func_call + | variable + | INCREMENT variable + { + $1->opcode = Op_preincrement; + $$ = mk_assignment($2, NULL, $1); + } + | DECREMENT variable + { + $1->opcode = Op_predecrement; + $$ = mk_assignment($2, NULL, $1); + } + | YNUMBER + { + $$ = list_create($1); + } + | YSTRING + { + $$ = list_create($1); + } + | '-' simp_exp %prec UNARY + { + if ($2->lasti->opcode == Op_push_i + && ($2->lasti->memory->flags & (STRCUR|STRING)) == 0) { + $2->lasti->memory->numbr = -(force_number($2->lasti->memory)); + $$ = $2; + bcfree($1); + } else { + $1->opcode = Op_unary_minus; + $$ = list_append($2, $1); + } + } + | '+' simp_exp %prec UNARY + { + /* + * was: $$ = $2 + * POSIX semantics: force a conversion to numeric type + */ + $1->opcode = Op_plus_i; + $1->memory = mk_number((AWKNUM) 0.0, (PERM|NUMCUR|NUMBER)); + $$ = list_append($2, $1); + } + ; + +func_call + : direct_func_call + { + func_use($1->lasti->func_name, FUNC_USE); + $$ = $1; + } + | '@' direct_func_call + { + /* indirect function call */ + INSTRUCTION *f, *t; + char *name; + NODE *indirect_var; + static short warned = FALSE; + const char *msg = _("indirect function calls are a gawk extension"); + + if (do_traditional || do_posix) + yyerror("%s", msg); + else if (do_lint && ! warned) { + warned = TRUE; + lintwarn("%s", msg); + } + + f = $2->lasti; + f->opcode = Op_indirect_func_call; + name = estrdup(f->func_name, strlen(f->func_name)); + if (is_std_var(name)) + yyerror(_("can not use special variable `%s' for indirect function call"), name); + indirect_var = variable(name, Node_var_new); + t = instruction(Op_push); + t->memory = indirect_var; + + /* prepend indirect var instead of appending to arguments (opt_expression_list), + * and pop it off in setup_frame (eval.c) (left to right evaluation order); Test case: + * f = "fun" + * @f(f="real_fun") + */ + + $$ = list_prepend($2, t); + } + ; + +direct_func_call + : FUNC_CALL '(' opt_expression_list r_paren + { + param_sanity($3); + $1->opcode = Op_func_call; + $1->func_body = NULL; + if ($3 == NULL) { /* no argument or error */ + ($1 + 1)->expr_count = 0; + $$ = list_create($1); + } else { + INSTRUCTION *t = $3; + ($1 + 1)->expr_count = count_expressions(&t, TRUE); + $$ = list_append(t, $1); + } + } + ; + +opt_variable + : /* empty */ + { $$ = NULL; } + | variable + { $$ = $1; } + ; + +delete_subscript_list + : /* empty */ + { $$ = NULL; } + | delete_subscript SUBSCRIPT + { $$ = $1; } + ; + +delete_subscript + : delete_exp_list + { $$ = $1; } + | delete_subscript delete_exp_list + { + $$ = list_merge($1, $2); + } + ; + +delete_exp_list + : bracketed_exp_list + { + INSTRUCTION *ip = $1->lasti; + int count = ip->sub_count; /* # of SUBSEP-seperated expressions */ + if (count > 1) { + /* change Op_subscript or Op_sub_array to Op_concat */ + ip->opcode = Op_concat; + ip->concat_flag = CSUBSEP; + ip->expr_count = count; + } else + ip->opcode = Op_no_op; + sub_counter++; /* count # of dimensions */ + $$ = $1; + } + ; + +bracketed_exp_list + : '[' expression_list ']' + { + INSTRUCTION *t = $2; + if ($2 == NULL) { + error_ln($3->source_line, + _("invalid subscript expression")); + /* install Null string as subscript. */ + t = list_create(instruction(Op_push_i)); + t->nexti->memory = Nnull_string; + $3->sub_count = 1; + } else + $3->sub_count = count_expressions(&t, FALSE); + $$ = list_append(t, $3); + } + ; + +subscript + : bracketed_exp_list + { $$ = $1; } + | subscript bracketed_exp_list + { + $$ = list_merge($1, $2); + } + ; + +subscript_list + : subscript SUBSCRIPT + { $$ = $1; } + ; + +simple_variable + : NAME + { + char *var_name = $1->lextok; + + $1->opcode = Op_push; + $1->memory = variable(var_name, Node_var_new); + $$ = list_create($1); + } + | NAME subscript_list + { + NODE *n; + + char *arr = $1->lextok; + if ((n = lookup(arr)) != NULL && ! isarray(n)) + yyerror(_("use of non-array as array")); + $1->memory = variable(arr, Node_var_new); + $1->opcode = Op_push_array; + $$ = list_prepend($2, $1); + } + ; + +variable + : simple_variable + { + INSTRUCTION *ip = $1->nexti; + if (ip->opcode == Op_push + && ip->memory->type == Node_var + && ip->memory->var_update + ) { + $$ = list_prepend($1, instruction(Op_var_update)); + $$->nexti->update_var = ip->memory->var_update; + } else + $$ = $1; + } + | '$' non_post_simp_exp opt_incdec + { + $$ = list_append($2, $1); + if ($3 != NULL) + mk_assignment($2, NULL, $3); + } + ; + +opt_incdec + : INCREMENT + { + $1->opcode = Op_postincrement; + } + | DECREMENT + { + $1->opcode = Op_postdecrement; + } + | /* empty */ { $$ = NULL; } + ; + +l_brace + : '{' opt_nls + ; + +r_brace + : '}' opt_nls { yyerrok; } + ; + +r_paren + : ')' { yyerrok; } + ; + +opt_semi + : /* empty */ + | semi + ; + +semi + : ';' { yyerrok; } + ; + +colon + : ':' { $$ = $1; yyerrok; } + ; + +comma + : ',' opt_nls { yyerrok; } + ; +%% + +struct token { + const char *operator; /* text to match */ + OPCODE value; /* type */ + int class; /* lexical class */ + unsigned flags; /* # of args. allowed and compatability */ +# define ARGS 0xFF /* 0, 1, 2, 3 args allowed (any combination */ +# define A(n) (1<<(n)) +# define VERSION_MASK 0xFF00 /* old awk is zero */ +# define NOT_OLD 0x0100 /* feature not in old awk */ +# define NOT_POSIX 0x0200 /* feature not in POSIX */ +# define GAWKX 0x0400 /* gawk extension */ +# define RESX 0x0800 /* Bell Labs Research extension */ +# define BREAK 0x1000 /* break allowed inside */ +# define CONTINUE 0x2000 /* continue allowed inside */ + + NODE *(*ptr)(int); /* function that implements this keyword */ +}; + +#if 'a' == 0x81 /* it's EBCDIC */ +/* tokcompare --- lexicographically compare token names for sorting */ + +static int +tokcompare(const void *l, const void *r) +{ + struct token *lhs, *rhs; + + lhs = (struct token *) l; + rhs = (struct token *) r; + + return strcmp(lhs->operator, rhs->operator); +} +#endif + +/* + * Tokentab is sorted ASCII ascending order, so it can be binary searched. + * See check_special(), which sorts the table on EBCDIC systems. + * Function pointers come from declarations in awk.h. + */ + +static const struct token tokentab[] = { +{"BEGIN", Op_rule, LEX_BEGIN, 0, 0}, +{"BEGINFILE", Op_rule, LEX_BEGINFILE, GAWKX, 0}, +{"END", Op_rule, LEX_END, 0, 0}, +{"ENDFILE", Op_rule, LEX_ENDFILE, GAWKX, 0}, +#ifdef ARRAYDEBUG +{"adump", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_adump}, +#endif +{"and", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_and}, +{"asort", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3), do_asort}, +{"asorti", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3), do_asorti}, +{"atan2", Op_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_atan2}, +{"bindtextdomain", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2), do_bindtextdomain}, +{"break", Op_K_break, LEX_BREAK, 0, 0}, +{"case", Op_K_case, LEX_CASE, GAWKX, 0}, +{"close", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1)|A(2), do_close}, +{"compl", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_compl}, +{"continue", Op_K_continue, LEX_CONTINUE, 0, 0}, +{"cos", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_cos}, +{"dcgettext", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3), do_dcgettext}, +{"dcngettext", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2)|A(3)|A(4)|A(5), do_dcngettext}, +{"default", Op_K_default, LEX_DEFAULT, GAWKX, 0}, +{"delete", Op_K_delete, LEX_DELETE, NOT_OLD, 0}, +{"do", Op_K_do, LEX_DO, NOT_OLD|BREAK|CONTINUE, 0}, +{"else", Op_K_else, LEX_ELSE, 0, 0}, +{"eval", Op_symbol, LEX_EVAL, 0, 0}, +{"exit", Op_K_exit, LEX_EXIT, 0, 0}, +{"exp", Op_builtin, LEX_BUILTIN, A(1), do_exp}, +{"extension", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_ext}, +{"fflush", Op_builtin, LEX_BUILTIN, RESX|A(0)|A(1), do_fflush}, +{"for", Op_K_for, LEX_FOR, BREAK|CONTINUE, 0}, +{"func", Op_func, LEX_FUNCTION, NOT_POSIX|NOT_OLD, 0}, +{"function",Op_func, LEX_FUNCTION, NOT_OLD, 0}, +{"gensub", Op_sub_builtin, LEX_BUILTIN, GAWKX|A(3)|A(4), 0}, +{"getline", Op_K_getline_redir, LEX_GETLINE, NOT_OLD, 0}, +{"gsub", Op_sub_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), 0}, +{"if", Op_K_if, LEX_IF, 0, 0}, +{"in", Op_symbol, LEX_IN, 0, 0}, +{"include", Op_symbol, LEX_INCLUDE, GAWKX, 0}, +{"index", Op_builtin, LEX_BUILTIN, A(2), do_index}, +{"int", Op_builtin, LEX_BUILTIN, A(1), do_int}, +{"isarray", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_isarray}, +{"length", Op_builtin, LEX_LENGTH, A(0)|A(1), do_length}, +{"log", Op_builtin, LEX_BUILTIN, A(1), do_log}, +{"lshift", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_lshift}, +{"match", Op_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), do_match}, +{"mktime", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_mktime}, +{"next", Op_K_next, LEX_NEXT, 0, 0}, +{"nextfile", Op_K_nextfile, LEX_NEXTFILE, GAWKX, 0}, +{"or", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_or}, +{"patsplit", Op_builtin, LEX_BUILTIN, GAWKX|A(2)|A(3)|A(4), do_patsplit}, +{"print", Op_K_print, LEX_PRINT, 0, 0}, +{"printf", Op_K_printf, LEX_PRINTF, 0, 0}, +{"rand", Op_builtin, LEX_BUILTIN, NOT_OLD|A(0), do_rand}, +{"return", Op_K_return, LEX_RETURN, NOT_OLD, 0}, +{"rshift", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_rshift}, +{"sin", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_sin}, +{"split", Op_builtin, LEX_BUILTIN, A(2)|A(3)|A(4), do_split}, +{"sprintf", Op_builtin, LEX_BUILTIN, 0, do_sprintf}, +{"sqrt", Op_builtin, LEX_BUILTIN, A(1), do_sqrt}, +{"srand", Op_builtin, LEX_BUILTIN, NOT_OLD|A(0)|A(1), do_srand}, +#if defined(GAWKDEBUG) || defined(ARRAYDEBUG) /* || ... */ +{"stopme", Op_builtin, LEX_BUILTIN, GAWKX|A(0), stopme}, +#endif +{"strftime", Op_builtin, LEX_BUILTIN, GAWKX|A(0)|A(1)|A(2)|A(3), do_strftime}, +{"strtonum", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_strtonum}, +{"sub", Op_sub_builtin, LEX_BUILTIN, NOT_OLD|A(2)|A(3), 0}, +{"substr", Op_builtin, LEX_BUILTIN, A(2)|A(3), do_substr}, +{"switch", Op_K_switch, LEX_SWITCH, GAWKX|BREAK, 0}, +{"system", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_system}, +{"systime", Op_builtin, LEX_BUILTIN, GAWKX|A(0), do_systime}, +{"tolower", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_tolower}, +{"toupper", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_toupper}, +{"while", Op_K_while, LEX_WHILE, BREAK|CONTINUE, 0}, +{"xor", Op_builtin, LEX_BUILTIN, GAWKX|A(2), do_xor}, +}; + +#if MBS_SUPPORT +/* Variable containing the current shift state. */ +static mbstate_t cur_mbstate; +/* Ring buffer containing current characters. */ +#define MAX_CHAR_IN_RING_BUFFER 8 +#define RING_BUFFER_SIZE (MAX_CHAR_IN_RING_BUFFER * MB_LEN_MAX) +static char cur_char_ring[RING_BUFFER_SIZE]; +/* Index for ring buffers. */ +static int cur_ring_idx; +/* This macro means that last nextc() return a singlebyte character + or 1st byte of a multibyte character. */ +#define nextc_is_1stbyte (cur_char_ring[cur_ring_idx] == 1) +#else /* MBS_SUPPORT */ +/* a dummy */ +#define nextc_is_1stbyte 1 +#endif /* MBS_SUPPORT */ + +/* getfname --- return name of a builtin function (for pretty printing) */ + +const char * +getfname(NODE *(*fptr)(int)) +{ + int i, j; + + j = sizeof(tokentab) / sizeof(tokentab[0]); + /* linear search, no other way to do it */ + for (i = 0; i < j; i++) + if (tokentab[i].ptr == fptr) + return tokentab[i].operator; + + return NULL; +} + +/* print_included_from --- print `Included from ..' file names and locations */ + +static void +print_included_from() +{ + int saveline, line; + SRCFILE *s; + + /* suppress current file name, line # from `.. included from ..' msgs */ + saveline = sourceline; + sourceline = 0; + + for (s = sourcefile; s != NULL && s->stype == SRC_INC; ) { + s = s->next; + if (s == NULL || s->fd <= INVALID_HANDLE) + continue; + line = s->srclines; + + /* if last token is NEWLINE, line number is off by 1. */ + if (s->lasttok == NEWLINE) + line--; + msg("%s %s:%d%c", + s->prev == sourcefile ? "In file included from" + : " from", + (s->stype == SRC_INC || + s->stype == SRC_FILE) ? s->src : "cmd. line", + line, + s->stype == SRC_INC ? ',' : ':' + ); + } + sourceline = saveline; +} + +/* warning_ln --- print a warning message with location */ + +static void +warning_ln(int line, const char *mesg, ...) +{ + va_list args; + int saveline; + + saveline = sourceline; + sourceline = line; + print_included_from(); + va_start(args, mesg); + err(_("warning: "), mesg, args); + va_end(args); + sourceline = saveline; +} + +/* lintwarn_ln --- print a lint warning and location */ + +static void +lintwarn_ln(int line, const char *mesg, ...) +{ + va_list args; + int saveline; + + saveline = sourceline; + sourceline = line; + print_included_from(); + va_start(args, mesg); + if (lintfunc == r_fatal) + err(_("fatal: "), mesg, args); + else + err(_("warning: "), mesg, args); + va_end(args); + sourceline = saveline; + if (lintfunc == r_fatal) + gawk_exit(EXIT_FATAL); +} + +/* error_ln --- print an error message and location */ + +static void +error_ln(int line, const char *m, ...) +{ + va_list args; + int saveline; + + saveline = sourceline; + sourceline = line; + print_included_from(); + errcount++; + va_start(args, m); + err("error: ", m, args); + va_end(args); + sourceline = saveline; +} + +/* yyerror --- print a syntax error message, show where */ + +static void +yyerror(const char *m, ...) +{ + va_list args; + const char *mesg = NULL; + char *bp, *cp; + char *scan; + char *buf; + int count; + static char end_of_file_line[] = "(END OF FILE)"; + char save; + + print_included_from(); + + errcount++; + /* Find the current line in the input file */ + if (lexptr && lexeme) { + if (thisline == NULL) { + cp = lexeme; + if (*cp == '\n') { + cp--; + mesg = _("unexpected newline or end of string"); + } + for (; cp != lexptr_begin && *cp != '\n'; --cp) + continue; + if (*cp == '\n') + cp++; + thisline = cp; + } + /* NL isn't guaranteed */ + bp = lexeme; + while (bp < lexend && *bp && *bp != '\n') + bp++; + } else { + thisline = end_of_file_line; + bp = thisline + strlen(thisline); + } + + /* + * Saving and restoring *bp keeps valgrind happy, + * since the guts of glibc uses strlen, even though + * we're passing an explict precision. Sigh. + * + * 8/2003: We may not need this anymore. + */ + save = *bp; + *bp = '\0'; + + msg("%.*s", (int) (bp - thisline), thisline); + + *bp = save; + va_start(args, m); + if (mesg == NULL) + mesg = m; + + count = (bp - thisline) + strlen(mesg) + 2 + 1; + emalloc(buf, char *, count, "yyerror"); + + bp = buf; + + if (lexptr != NULL) { + scan = thisline; + while (scan < lexeme) + if (*scan++ == '\t') + *bp++ = '\t'; + else + *bp++ = ' '; + *bp++ = '^'; + *bp++ = ' '; + } + strcpy(bp, mesg); + err("", buf, args); + va_end(args); + efree(buf); +} + +/* mk_program --- create a single list of instructions */ + +static INSTRUCTION * +mk_program() +{ + INSTRUCTION *cp, *tmp; + +#define begin_block rule_block[BEGIN] +#define end_block rule_block[END] +#define prog_block rule_block[Rule] +#define beginfile_block rule_block[BEGINFILE] +#define endfile_block rule_block[ENDFILE] + + if (end_block == NULL) + end_block = list_create(ip_end); + else + (void) list_prepend(end_block, ip_end); + + if (! in_main_context()) { + if (begin_block != NULL && prog_block != NULL) + cp = list_merge(begin_block, prog_block); + else + cp = (begin_block != NULL) ? begin_block : prog_block; + + if (cp != NULL) + (void) list_merge(cp, end_block); + else + cp = end_block; + + (void) list_append(cp, instruction(Op_stop)); + goto out; + } + + if (endfile_block == NULL) + endfile_block = list_create(ip_endfile); + else { + ip_rec->has_endfile = TRUE; + (void) list_prepend(endfile_block, ip_endfile); + } + + if (beginfile_block == NULL) + beginfile_block = list_create(ip_beginfile); + else + (void) list_prepend(beginfile_block, ip_beginfile); + + if (prog_block == NULL) { + if (end_block->nexti == end_block->lasti + && beginfile_block->nexti == beginfile_block->lasti + && endfile_block->nexti == endfile_block->lasti + ) { + /* no pattern-action and (real) end, beginfile or endfile blocks */ + bcfree(ip_rec); + bcfree(ip_newfile); + ip_rec = ip_newfile = NULL; + + list_append(beginfile_block, instruction(Op_after_beginfile)); + (void) list_append(endfile_block, instruction(Op_after_endfile)); + + if (begin_block == NULL) /* no program at all */ + cp = end_block; + else + cp = list_merge(begin_block, end_block); + (void) list_append(cp, ip_atexit); + (void) list_append(cp, instruction(Op_stop)); + + /* append beginfile_block and endfile_block for sole use + * in getline without redirection (Op_K_getline). + */ + + (void) list_merge(cp, beginfile_block); + (void) list_merge(cp, endfile_block); + + goto out; + + } else { + /* install a do-nothing prog block */ + prog_block = list_create(instruction(Op_no_op)); + } + } + + (void) list_append(endfile_block, instruction(Op_after_endfile)); + (void) list_prepend(prog_block, ip_rec); + (void) list_append(prog_block, instruction(Op_jmp)); + prog_block->lasti->target_jmp = ip_rec; + + list_append(beginfile_block, instruction(Op_after_beginfile)); + + cp = list_merge(beginfile_block, prog_block); + (void) list_prepend(cp, ip_newfile); + (void) list_merge(cp, endfile_block); + (void) list_merge(cp, end_block); + if (begin_block != NULL) + cp = list_merge(begin_block, cp); + + (void) list_append(cp, ip_atexit); + (void) list_append(cp, instruction(Op_stop)); + +out: + /* delete the Op_list, not needed */ + tmp = cp->nexti; + bcfree(cp); + return tmp; + +#undef begin_block +#undef end_block +#undef prog_block +#undef beginfile_block +#undef endfile_block +} + +/* parse_program --- read in the program and convert into a list of instructions */ + +int +parse_program(INSTRUCTION **pcode) +{ + int ret; + + /* pre-create non-local jump targets + * ip_end (Op_no_op) -- used as jump target for `exit' + * outside an END block. + */ + ip_end = instruction(Op_no_op); + + if (! in_main_context()) + ip_newfile = ip_rec = ip_atexit = ip_beginfile = ip_endfile = NULL; + else { + ip_endfile = instruction(Op_no_op); + ip_beginfile = instruction(Op_no_op); + ip_rec = instruction(Op_get_record); /* target for `next', also ip_newfile */ + ip_newfile = bcalloc(Op_newfile, 2, 0); /* target for `nextfile' */ + ip_newfile->target_jmp = ip_end; + ip_newfile->target_endfile = ip_endfile; + (ip_newfile + 1)->target_get_record = ip_rec; + ip_rec->target_newfile = ip_newfile; + ip_atexit = instruction(Op_atexit); /* target for `exit' in END block */ + } + + sourcefile = srcfiles->next; + lexeof = FALSE; + lexptr = NULL; + lasttok = 0; + memset(rule_block, 0, sizeof(ruletab) * sizeof(INSTRUCTION *)); + errcount = 0; + tok = tokstart != NULL ? tokstart : tokexpand(); + + ret = yyparse(); + *pcode = mk_program(); + + /* avoid false source indications */ + source = NULL; + sourceline = 0; + if (ret == 0) /* avoid spurious warning if parser aborted with YYABORT */ + check_funcs(); + + return (ret || errcount); +} + +/* do_add_srcfile --- add one item to srcfiles */ + +static SRCFILE * +do_add_srcfile(int stype, char *src, char *path, SRCFILE *thisfile) +{ + SRCFILE *s; + + emalloc(s, SRCFILE *, sizeof(SRCFILE), "do_add_srcfile"); + memset(s, 0, sizeof(SRCFILE)); + s->src = estrdup(src, strlen(src)); + s->fullpath = path; + s->stype = stype; + s->fd = INVALID_HANDLE; + s->next = thisfile; + s->prev = thisfile->prev; + thisfile->prev->next = s; + thisfile->prev = s; + return s; +} + +/* add_srcfile --- add one item to srcfiles after checking if + * a source file exists and not already in list. + */ + +SRCFILE * +add_srcfile(int stype, char *src, SRCFILE *thisfile, int *already_included, int *errcode) +{ + SRCFILE *s; + struct stat sbuf; + char *path; + int errno_val = 0; + + if (already_included) + *already_included = FALSE; + if (errcode) + *errcode = 0; + if (stype == SRC_CMDLINE || stype == SRC_STDIN) + return do_add_srcfile(stype, src, NULL, thisfile); + + path = find_source(src, &sbuf, &errno_val); + if (path == NULL) { + if (errcode) { + *errcode = errno_val; + return NULL; + } + fatal(_("can't open source file `%s' for reading (%s)"), + src, errno_val ? strerror(errno_val) : _("reason unknown")); + } + + for (s = srcfiles->next; s != srcfiles; s = s->next) { + if ((s->stype == SRC_FILE || s->stype == SRC_INC) + && files_are_same(path, s) + ) { + if (do_lint) { + int line = sourceline; + /* Kludge: the line number may be off for `@include file'. + * Since, this function is also used for '-f file' in main.c, + * sourceline > 1 check ensures that the call is at + * parse time. + */ + if (sourceline > 1 && lasttok == NEWLINE) + line--; + lintwarn_ln(line, _("already included source file `%s'"), src); + } + efree(path); + if (already_included) + *already_included = TRUE; + return NULL; + } + } + + s = do_add_srcfile(stype, src, path, thisfile); + s->sbuf = sbuf; + s->mtime = sbuf.st_mtime; + return s; +} + +/* include_source --- read program from source included using `@include' */ + +static int +include_source(INSTRUCTION *file) +{ + SRCFILE *s; + char *src = file->lextok; + int errcode; + int already_included; + + if (do_traditional || do_posix) { + error_ln(file->source_line, _("@include is a gawk extension")); + return -1; + } + + if (strlen(src) == 0) { + if (do_lint) + lintwarn_ln(file->source_line, _("empty filename after @include")); + return 0; + } + + s = add_srcfile(SRC_INC, src, sourcefile, &already_included, &errcode); + if (s == NULL) { + if (already_included) + return 0; + error_ln(file->source_line, + _("can't open source file `%s' for reading (%s)"), + src, errcode ? strerror(errcode) : _("reason unknown")); + return -1; + } + + /* save scanner state for the current sourcefile */ + sourcefile->srclines = sourceline; + sourcefile->lexptr = lexptr; + sourcefile->lexend = lexend; + sourcefile->lexptr_begin = lexptr_begin; + sourcefile->lexeme = lexeme; + sourcefile->lasttok = lasttok; + + /* included file becomes the current source */ + sourcefile = s; + lexptr = NULL; + sourceline = 0; + source = NULL; + lasttok = 0; + lexeof = FALSE; + eof_warned = FALSE; + return 0; +} + +/* next_sourcefile --- read program from the next source in srcfiles */ + +static void +next_sourcefile() +{ + static int (*closefunc)(int fd) = NULL; + + if (closefunc == NULL) { + char *cp = getenv("AWKREADFUNC"); + + /* If necessary, one day, test value for different functions. */ + if (cp == NULL) + closefunc = close; + else + closefunc = one_line_close; + } + + /* + * This won't be true if there's an invalid character in + * the source file or source string (e.g., user typo). + * Previous versions of gawk did not core dump in such a + * case. + * + * assert(lexeof == TRUE); + */ + lexeof = FALSE; + eof_warned = FALSE; + sourcefile->srclines = sourceline; /* total no of lines in current file */ + if (sourcefile->fd > INVALID_HANDLE) { + if (sourcefile->fd != fileno(stdin)) /* safety */ + (*closefunc)(sourcefile->fd); + sourcefile->fd = INVALID_HANDLE; + } + if (sourcefile->buf != NULL) { + efree(sourcefile->buf); + sourcefile->buf = NULL; + sourcefile->lexptr_begin = NULL; + } + + sourcefile = sourcefile->next; + if (sourcefile == srcfiles) + return; + + if (sourcefile->lexptr_begin != NULL) { + /* resume reading from already opened file (postponed to process '@include') */ + lexptr = sourcefile->lexptr; + lexend = sourcefile->lexend; + lasttok = sourcefile->lasttok; + lexptr_begin = sourcefile->lexptr_begin; + lexeme = sourcefile->lexeme; + sourceline = sourcefile->srclines; + source = sourcefile->src; + } else { + lexptr = NULL; + sourceline = 0; + source = NULL; + lasttok = 0; + } +} + +/* get_src_buf --- read the next buffer of source program */ + +static char * +get_src_buf() +{ + int n; + char *scan; + int newfile; + int savelen; + struct stat sbuf; + + /* + * No argument prototype on readfunc on purpose, + * avoids problems with some ancient systems where + * the types of arguments to read() aren't up to date. + */ + static ssize_t (*readfunc)() = 0; + + if (readfunc == NULL) { + char *cp = getenv("AWKREADFUNC"); + + /* If necessary, one day, test value for different functions. */ + if (cp == NULL) + /* + * cast is to remove warnings on systems with + * different return types for read. + */ + readfunc = ( ssize_t(*)() ) read; + else + readfunc = read_one_line; + } + + newfile = FALSE; + if (sourcefile == srcfiles) + return NULL; + + if (sourcefile->stype == SRC_CMDLINE) { + if (sourcefile->bufsize == 0) { + sourcefile->bufsize = strlen(sourcefile->src); + lexptr = lexptr_begin = lexeme = sourcefile->src; + lexend = lexptr + sourcefile->bufsize; + sourceline = 1; + if (sourcefile->bufsize == 0) { + /* + * Yet Another Special case: + * gawk '' /path/name + * Sigh. + */ + static short warned = FALSE; + + if (do_lint && ! warned) { + warned = TRUE; + lintwarn(_("empty program text on command line")); + } + lexeof = TRUE; + } + } else if (sourcefile->buf == NULL && *(lexptr-1) != '\n') { + /* + * The following goop is to ensure that the source + * ends with a newline and that the entire current + * line is available for error messages. + */ + int offset; + char *buf; + + offset = lexptr - lexeme; + for (scan = lexeme; scan > lexptr_begin; scan--) + if (*scan == '\n') { + scan++; + break; + } + savelen = lexptr - scan; + emalloc(buf, char *, savelen + 1, "get_src_buf"); + memcpy(buf, scan, savelen); + thisline = buf; + lexptr = buf + savelen; + *lexptr = '\n'; + lexeme = lexptr - offset; + lexptr_begin = buf; + lexend = lexptr + 1; + sourcefile->buf = buf; + } else + lexeof = TRUE; + return lexptr; + } + + if (sourcefile->fd <= INVALID_HANDLE) { + int fd; + int l; + + source = sourcefile->src; + if (source == NULL) + return NULL; + fd = srcopen(sourcefile); + if (fd <= INVALID_HANDLE) { + char *in; + + /* suppress file name and line no. in error mesg */ + in = source; + source = NULL; + error(_("can't open source file `%s' for reading (%s)"), + in, strerror(errno)); + errcount++; + lexeof = TRUE; + return sourcefile->src; + } + + sourcefile->fd = fd; + l = optimal_bufsize(fd, &sbuf); + /* + * Make sure that something silly like + * AWKBUFSIZE=8 make check + * works ok. + */ +#define A_DECENT_BUFFER_SIZE 128 + if (l < A_DECENT_BUFFER_SIZE) + l = A_DECENT_BUFFER_SIZE; +#undef A_DECENT_BUFFER_SIZE + sourcefile->bufsize = l; + newfile = TRUE; + emalloc(sourcefile->buf, char *, sourcefile->bufsize, "get_src_buf"); + lexptr = lexptr_begin = lexeme = sourcefile->buf; + savelen = 0; + sourceline = 1; + thisline = NULL; + } else { + /* + * Here, we retain the current source line in the beginning of the buffer. + */ + int offset; + for (scan = lexeme; scan > lexptr_begin; scan--) + if (*scan == '\n') { + scan++; + break; + } + + savelen = lexptr - scan; + offset = lexptr - lexeme; + + if (savelen > 0) { + /* + * Need to make sure we have room left for reading new text; + * grow the buffer (by doubling, an arbitrary choice), if the retained line + * takes up more than a certain percentage (50%, again an arbitrary figure) + * of the available space. + */ + + if (savelen > sourcefile->bufsize / 2) { /* long line or token */ + sourcefile->bufsize *= 2; + erealloc(sourcefile->buf, char *, sourcefile->bufsize, "get_src_buf"); + scan = sourcefile->buf + (scan - lexptr_begin); + lexptr_begin = sourcefile->buf; + } + + thisline = lexptr_begin; + memmove(thisline, scan, savelen); + lexptr = thisline + savelen; + lexeme = lexptr - offset; + } else { + savelen = 0; + lexptr = lexeme = lexptr_begin; + thisline = NULL; + } + } + + n = (*readfunc)(sourcefile->fd, lexptr, sourcefile->bufsize - savelen); + if (n == -1) { + error(_("can't read sourcefile `%s' (%s)"), + source, strerror(errno)); + errcount++; + lexeof = TRUE; + } else { + lexend = lexptr + n; + if (n == 0) { + static short warned = FALSE; + if (do_lint && newfile && ! warned){ + warned = TRUE; + sourceline = 0; + lintwarn(_("source file `%s' is empty"), source); + } + lexeof = TRUE; + } + } + return sourcefile->buf; +} + +/* tokadd --- add a character to the token buffer */ + +#define tokadd(x) (*tok++ = (x), tok == tokend ? tokexpand() : tok) + +/* tokexpand --- grow the token buffer */ + +static char * +tokexpand() +{ + static int toksize; + int tokoffset; + + if (tokstart != NULL) { + tokoffset = tok - tokstart; + toksize *= 2; + erealloc(tokstart, char *, toksize, "tokexpand"); + tok = tokstart + tokoffset; + } else { + toksize = 60; + emalloc(tokstart, char *, toksize, "tokexpand"); + tok = tokstart; + } + tokend = tokstart + toksize; + return tok; +} + +/* nextc --- get the next input character */ + +#if MBS_SUPPORT + +static int +nextc(void) +{ + if (gawk_mb_cur_max > 1) { +again: + if (lexeof) + return END_FILE; + if (lexptr == NULL || lexptr >= lexend) { + if (get_src_buf()) + goto again; + return END_SRC; + } + + /* Update the buffer index. */ + cur_ring_idx = (cur_ring_idx == RING_BUFFER_SIZE - 1)? 0 : + cur_ring_idx + 1; + + /* Did we already check the current character? */ + if (cur_char_ring[cur_ring_idx] == 0) { + /* No, we need to check the next character on the buffer. */ + int idx, work_ring_idx = cur_ring_idx; + mbstate_t tmp_state; + size_t mbclen; + + for (idx = 0 ; lexptr + idx < lexend ; idx++) { + tmp_state = cur_mbstate; + mbclen = mbrlen(lexptr, idx + 1, &tmp_state); + + if (mbclen == 1 || mbclen == (size_t)-1 || mbclen == 0) { + /* It is a singlebyte character, non-complete multibyte + character or EOF. We treat it as a singlebyte + character. */ + cur_char_ring[work_ring_idx] = 1; + break; + } else if (mbclen == (size_t)-2) { + /* It is not a complete multibyte character. */ + cur_char_ring[work_ring_idx] = idx + 1; + } else { + /* mbclen > 1 */ + cur_char_ring[work_ring_idx] = mbclen; + break; + } + work_ring_idx = (work_ring_idx == RING_BUFFER_SIZE - 1)? + 0 : work_ring_idx + 1; + } + cur_mbstate = tmp_state; + + /* Put a mark on the position on which we write next character. */ + work_ring_idx = (work_ring_idx == RING_BUFFER_SIZE - 1)? + 0 : work_ring_idx + 1; + cur_char_ring[work_ring_idx] = 0; + } + + return (int) (unsigned char) *lexptr++; + } else { + do { + if (lexeof) + return END_FILE; + if (lexptr && lexptr < lexend) + return ((int) (unsigned char) *lexptr++); + } while (get_src_buf()); + return END_SRC; + } +} + +#else /* MBS_SUPPORT */ + +int +nextc() +{ + do { + if (lexeof) + return END_FILE; + if (lexptr && lexptr < lexend) + return ((int) (unsigned char) *lexptr++); + } while (get_src_buf()); + return END_SRC; +} + +#endif /* MBS_SUPPORT */ + +/* pushback --- push a character back on the input */ + +static inline void +pushback(void) +{ +#if MBS_SUPPORT + if (gawk_mb_cur_max > 1) + cur_ring_idx = (cur_ring_idx == 0)? RING_BUFFER_SIZE - 1 : + cur_ring_idx - 1; +#endif + (! lexeof && lexptr && lexptr > lexptr_begin ? lexptr-- : lexptr); +} + + +/* allow_newline --- allow newline after &&, ||, ? and : */ + +static void +allow_newline(void) +{ + int c; + + for (;;) { + c = nextc(); + if (c == END_FILE) { + pushback(); + break; + } + if (c == '#') { + while ((c = nextc()) != '\n' && c != END_FILE) + continue; + if (c == END_FILE) { + pushback(); + break; + } + } + if (c == '\n') + sourceline++; + if (! isspace(c)) { + pushback(); + break; + } + } +} + +/* newline_eof --- return newline or EOF as needed and adjust variables */ + +/* + * This routine used to be a macro, however GCC 4.6.2 warned about + * the result of a computation not being used. Converting to a function + * removes the warnings. + */ + +static int newline_eof() +{ + /* NB: a newline at end does not start a source line. */ + if (lasttok != NEWLINE) { + pushback(); + if (do_lint && ! eof_warned) { + lintwarn(_("source file does not end in newline")); + eof_warned = TRUE; + } + sourceline++; + return NEWLINE; + } + + sourceline--; + eof_warned = FALSE; + return LEX_EOF; +} + +/* yylex --- Read the input and turn it into tokens. */ + +static int +yylex(void) +{ + int c; + int seen_e = FALSE; /* These are for numbers */ + int seen_point = FALSE; + int esc_seen; /* for literal strings */ + int mid; + static int did_newline = FALSE; + char *tokkey; + int inhex = FALSE; + int intlstr = FALSE; + +#define GET_INSTRUCTION(op) bcalloc(op, 1, sourceline) + +#define NEWLINE_EOF newline_eof() + + yylval = (INSTRUCTION *) NULL; + if (lasttok == SUBSCRIPT) { + lasttok = 0; + return SUBSCRIPT; + } + + if (lasttok == LEX_EOF) /* error earlier in current source, must give up !! */ + return 0; + + c = nextc(); + if (c == END_SRC) + return 0; + if (c == END_FILE) + return lasttok = NEWLINE_EOF; + pushback(); + +#if defined __EMX__ + /* + * added for OS/2's extproc feature of cmd.exe + * (like #! in BSD sh) + */ + if (strncasecmp(lexptr, "extproc ", 8) == 0) { + while (*lexptr && *lexptr != '\n') + lexptr++; + } +#endif + + lexeme = lexptr; + thisline = NULL; + if (want_regexp) { + int in_brack = 0; /* count brackets, [[:alnum:]] allowed */ + /* + * Counting brackets is non-trivial. [[] is ok, + * and so is [\]], with a point being that /[/]/ as a regexp + * constant has to work. + * + * Do not count [ or ] if either one is preceded by a \. + * A `[' should be counted if + * a) it is the first one so far (in_brack == 0) + * b) it is the `[' in `[:' + * A ']' should be counted if not preceded by a \, since + * it is either closing `:]' or just a plain list. + * According to POSIX, []] is how you put a ] into a set. + * Try to handle that too. + * + * The code for \ handles \[ and \]. + */ + + want_regexp = FALSE; + tok = tokstart; + for (;;) { + c = nextc(); + + if (gawk_mb_cur_max == 1 || nextc_is_1stbyte) switch (c) { + case '[': + /* one day check for `.' and `=' too */ + if (nextc() == ':' || in_brack == 0) + in_brack++; + pushback(); + break; + case ']': + if (tokstart[0] == '[' + && (tok == tokstart + 1 + || (tok == tokstart + 2 + && tokstart[1] == '^'))) + /* do nothing */; + else + in_brack--; + break; + case '\\': + if ((c = nextc()) == END_FILE) { + pushback(); + yyerror(_("unterminated regexp ends with `\\' at end of file")); + goto end_regexp; /* kludge */ + } else if (c == '\n') { + sourceline++; + continue; + } else { + tokadd('\\'); + tokadd(c); + continue; + } + break; + case '/': /* end of the regexp */ + if (in_brack > 0) + break; +end_regexp: + yylval = GET_INSTRUCTION(Op_token); + yylval->lextok = estrdup(tokstart, tok - tokstart); + if (do_lint) { + int peek = nextc(); + + pushback(); + if (peek == 'i' || peek == 's') { + if (source) + lintwarn( + _("%s: %d: tawk regex modifier `/.../%c' doesn't work in gawk"), + source, sourceline, peek); + else + lintwarn( + _("tawk regex modifier `/.../%c' doesn't work in gawk"), + peek); + } + } + return lasttok = REGEXP; + case '\n': + pushback(); + yyerror(_("unterminated regexp")); + goto end_regexp; /* kludge */ + case END_FILE: + pushback(); + yyerror(_("unterminated regexp at end of file")); + goto end_regexp; /* kludge */ + } + tokadd(c); + } + } +retry: + + /* skipping \r is a hack, but windows is just too pervasive. sigh. */ + while ((c = nextc()) == ' ' || c == '\t' || c == '\r') + continue; + + lexeme = lexptr ? lexptr - 1 : lexptr; + thisline = NULL; + tok = tokstart; + +#if MBS_SUPPORT + if (gawk_mb_cur_max == 1 || nextc_is_1stbyte) +#endif + switch (c) { + case END_SRC: + return 0; + + case END_FILE: + return lasttok = NEWLINE_EOF; + + case '\n': + sourceline++; + return lasttok = NEWLINE; + + case '#': /* it's a comment */ + while ((c = nextc()) != '\n') { + if (c == END_FILE) + return lasttok = NEWLINE_EOF; + } + sourceline++; + return lasttok = NEWLINE; + + case '@': + return lasttok = '@'; + + case '\\': +#ifdef RELAXED_CONTINUATION + /* + * This code puports to allow comments and/or whitespace + * after the `\' at the end of a line used for continuation. + * Use it at your own risk. We think it's a bad idea, which + * is why it's not on by default. + */ + if (! do_traditional) { + /* strip trailing white-space and/or comment */ + while ((c = nextc()) == ' ' || c == '\t' || c == '\r') + continue; + if (c == '#') { + static short warned = FALSE; + + if (do_lint && ! warned) { + warned = TRUE; + lintwarn( + _("use of `\\ #...' line continuation is not portable")); + } + while ((c = nextc()) != '\n') + if (c == END_FILE) + break; + } + pushback(); + } +#endif /* RELAXED_CONTINUATION */ + c = nextc(); + if (c == '\r') /* allow MS-DOS files. bleah */ + c = nextc(); + if (c == '\n') { + sourceline++; + goto retry; + } else { + yyerror(_("backslash not last character on line")); + return lasttok = LEX_EOF; + } + break; + + case ':': + case '?': + yylval = GET_INSTRUCTION(Op_cond_exp); + if (! do_posix) + allow_newline(); + return lasttok = c; + + /* + * in_parens is undefined unless we are parsing a print + * statement (in_print), but why bother with a check? + */ + case ')': + in_parens--; + return lasttok = c; + + case '(': + in_parens++; + return lasttok = c; + case '$': + yylval = GET_INSTRUCTION(Op_field_spec); + return lasttok = c; + case '{': + if (++in_braces == 1) + firstline = sourceline; + case ';': + case ',': + case '[': + return lasttok = c; + case ']': + c = nextc(); + pushback(); + if (c == '[') { + yylval = GET_INSTRUCTION(Op_sub_array); + lasttok = ']'; + } else { + yylval = GET_INSTRUCTION(Op_subscript); + lasttok = SUBSCRIPT; /* end of subscripts */ + } + return ']'; + + case '*': + if ((c = nextc()) == '=') { + yylval = GET_INSTRUCTION(Op_assign_times); + return lasttok = ASSIGNOP; + } else if (do_posix) { + pushback(); + yylval = GET_INSTRUCTION(Op_times); + return lasttok = '*'; + } else if (c == '*') { + /* make ** and **= aliases for ^ and ^= */ + static int did_warn_op = FALSE, did_warn_assgn = FALSE; + + if (nextc() == '=') { + if (! did_warn_assgn) { + did_warn_assgn = TRUE; + if (do_lint) + lintwarn(_("POSIX does not allow operator `**='")); + if (do_lint_old) + warning(_("old awk does not support operator `**='")); + } + yylval = GET_INSTRUCTION(Op_assign_exp); + return ASSIGNOP; + } else { + pushback(); + if (! did_warn_op) { + did_warn_op = TRUE; + if (do_lint) + lintwarn(_("POSIX does not allow operator `**'")); + if (do_lint_old) + warning(_("old awk does not support operator `**'")); + } + yylval = GET_INSTRUCTION(Op_exp); + return lasttok = '^'; + } + } + pushback(); + yylval = GET_INSTRUCTION(Op_times); + return lasttok = '*'; + + case '/': + if (nextc() == '=') { + pushback(); + return lasttok = SLASH_BEFORE_EQUAL; + } + pushback(); + yylval = GET_INSTRUCTION(Op_quotient); + return lasttok = '/'; + + case '%': + if (nextc() == '=') { + yylval = GET_INSTRUCTION(Op_assign_mod); + return lasttok = ASSIGNOP; + } + pushback(); + yylval = GET_INSTRUCTION(Op_mod); + return lasttok = '%'; + + case '^': + { + static int did_warn_op = FALSE, did_warn_assgn = FALSE; + + if (nextc() == '=') { + if (do_lint_old && ! did_warn_assgn) { + did_warn_assgn = TRUE; + warning(_("operator `^=' is not supported in old awk")); + } + yylval = GET_INSTRUCTION(Op_assign_exp); + return lasttok = ASSIGNOP; + } + pushback(); + if (do_lint_old && ! did_warn_op) { + did_warn_op = TRUE; + warning(_("operator `^' is not supported in old awk")); + } + yylval = GET_INSTRUCTION(Op_exp); + return lasttok = '^'; + } + + case '+': + if ((c = nextc()) == '=') { + yylval = GET_INSTRUCTION(Op_assign_plus); + return lasttok = ASSIGNOP; + } + if (c == '+') { + yylval = GET_INSTRUCTION(Op_symbol); + return lasttok = INCREMENT; + } + pushback(); + yylval = GET_INSTRUCTION(Op_plus); + return lasttok = '+'; + + case '!': + if ((c = nextc()) == '=') { + yylval = GET_INSTRUCTION(Op_notequal); + return lasttok = RELOP; + } + if (c == '~') { + yylval = GET_INSTRUCTION(Op_nomatch); + return lasttok = MATCHOP; + } + pushback(); + yylval = GET_INSTRUCTION(Op_symbol); + return lasttok = '!'; + + case '<': + if (nextc() == '=') { + yylval = GET_INSTRUCTION(Op_leq); + return lasttok = RELOP; + } + yylval = GET_INSTRUCTION(Op_less); + pushback(); + return lasttok = '<'; + + case '=': + if (nextc() == '=') { + yylval = GET_INSTRUCTION(Op_equal); + return lasttok = RELOP; + } + yylval = GET_INSTRUCTION(Op_assign); + pushback(); + return lasttok = ASSIGN; + + case '>': + if ((c = nextc()) == '=') { + yylval = GET_INSTRUCTION(Op_geq); + return lasttok = RELOP; + } else if (c == '>') { + yylval = GET_INSTRUCTION(Op_symbol); + yylval->redir_type = redirect_append; + return lasttok = IO_OUT; + } + pushback(); + if (in_print && in_parens == 0) { + yylval = GET_INSTRUCTION(Op_symbol); + yylval->redir_type = redirect_output; + return lasttok = IO_OUT; + } + yylval = GET_INSTRUCTION(Op_greater); + return lasttok = '>'; + + case '~': + yylval = GET_INSTRUCTION(Op_match); + return lasttok = MATCHOP; + + case '}': + /* + * Added did newline stuff. Easier than + * hacking the grammar. + */ + if (did_newline) { + did_newline = FALSE; + if (--in_braces == 0) + lastline = sourceline; + return lasttok = c; + } + did_newline++; + --lexptr; /* pick up } next time */ + return lasttok = NEWLINE; + + case '"': + string: + esc_seen = FALSE; + while ((c = nextc()) != '"') { + if (c == '\n') { + pushback(); + yyerror(_("unterminated string")); + return lasttok = LEX_EOF; + } + if ((gawk_mb_cur_max == 1 || nextc_is_1stbyte) && + c == '\\') { + c = nextc(); + if (c == '\n') { + sourceline++; + continue; + } + esc_seen = TRUE; + if (! want_source || c != '"') + tokadd('\\'); + } + if (c == END_FILE) { + pushback(); + yyerror(_("unterminated string")); + return lasttok = LEX_EOF; + } + tokadd(c); + } + yylval = GET_INSTRUCTION(Op_token); + if (want_source) { + yylval->lextok = estrdup(tokstart, tok - tokstart); + return lasttok = FILENAME; + } + + yylval->opcode = Op_push_i; + yylval->memory = make_str_node(tokstart, + tok - tokstart, esc_seen ? SCAN : 0); + yylval->memory->flags &= ~MALLOC; + yylval->memory->flags |= PERM; + if (intlstr) { + yylval->memory->flags |= INTLSTR; + intlstr = FALSE; + if (do_intl) + dumpintlstr(yylval->memory->stptr, yylval->memory->stlen); + } + return lasttok = YSTRING; + + case '-': + if ((c = nextc()) == '=') { + yylval = GET_INSTRUCTION(Op_assign_minus); + return lasttok = ASSIGNOP; + } + if (c == '-') { + yylval = GET_INSTRUCTION(Op_symbol); + return lasttok = DECREMENT; + } + pushback(); + yylval = GET_INSTRUCTION(Op_minus); + return lasttok = '-'; + + case '.': + c = nextc(); + pushback(); + if (! isdigit(c)) + return lasttok = '.'; + else + c = '.'; + /* FALL THROUGH */ + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + /* It's a number */ + for (;;) { + int gotnumber = FALSE; + + tokadd(c); + switch (c) { + case 'x': + case 'X': + if (do_traditional) + goto done; + if (tok == tokstart + 2) { + int peek = nextc(); + + if (isxdigit(peek)) { + inhex = TRUE; + pushback(); /* following digit */ + } else { + pushback(); /* x or X */ + goto done; + } + } + break; + case '.': + /* period ends exponent part of floating point number */ + if (seen_point || seen_e) { + gotnumber = TRUE; + break; + } + seen_point = TRUE; + break; + case 'e': + case 'E': + if (inhex) + break; + if (seen_e) { + gotnumber = TRUE; + break; + } + seen_e = TRUE; + if ((c = nextc()) == '-' || c == '+') { + int c2 = nextc(); + + if (isdigit(c2)) { + tokadd(c); + tokadd(c2); + } else { + pushback(); /* non-digit after + or - */ + pushback(); /* + or - */ + pushback(); /* e or E */ + } + } else if (! isdigit(c)) { + pushback(); /* character after e or E */ + pushback(); /* e or E */ + } else { + pushback(); /* digit */ + } + break; + case 'a': + case 'A': + case 'b': + case 'B': + case 'c': + case 'C': + case 'D': + case 'd': + case 'f': + case 'F': + if (do_traditional || ! inhex) + goto done; + /* fall through */ + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + break; + default: + done: + gotnumber = TRUE; + } + if (gotnumber) + break; + c = nextc(); + } + pushback(); + + tokadd('\0'); + yylval = GET_INSTRUCTION(Op_push_i); + if (! do_traditional && isnondecimal(tokstart, FALSE)) { + if (do_lint) { + if (isdigit((unsigned char) tokstart[1])) /* not an 'x' or 'X' */ + lintwarn("numeric constant `%.*s' treated as octal", + (int) strlen(tokstart)-1, tokstart); + else if (tokstart[1] == 'x' || tokstart[1] == 'X') + lintwarn("numeric constant `%.*s' treated as hexadecimal", + (int) strlen(tokstart)-1, tokstart); + } + yylval->memory = mk_number(nondec2awknum(tokstart, strlen(tokstart)), + PERM|NUMCUR|NUMBER); + } else + yylval->memory = mk_number(atof(tokstart), PERM|NUMCUR|NUMBER); + return lasttok = YNUMBER; + + case '&': + if ((c = nextc()) == '&') { + yylval = GET_INSTRUCTION(Op_and); + allow_newline(); + return lasttok = LEX_AND; + } + pushback(); + yylval = GET_INSTRUCTION(Op_symbol); + return lasttok = '&'; + + case '|': + if ((c = nextc()) == '|') { + yylval = GET_INSTRUCTION(Op_or); + allow_newline(); + return lasttok = LEX_OR; + } else if (! do_traditional && c == '&') { + yylval = GET_INSTRUCTION(Op_symbol); + yylval->redir_type = redirect_twoway; + return lasttok = (in_print && in_parens == 0 ? IO_OUT : IO_IN); + } + pushback(); + if (in_print && in_parens == 0) { + yylval = GET_INSTRUCTION(Op_symbol); + yylval->redir_type = redirect_pipe; + return lasttok = IO_OUT; + } else { + yylval = GET_INSTRUCTION(Op_symbol); + yylval->redir_type = redirect_pipein; + return lasttok = IO_IN; + } + } + + if (c != '_' && ! isalpha(c)) { + yyerror(_("invalid char '%c' in expression"), c); + return lasttok = LEX_EOF; + } + + /* + * Lots of fog here. Consider: + * + * print "xyzzy"$_"foo" + * + * Without the check for ` lasttok != '$' ', this is parsed as + * + * print "xxyzz" $(_"foo") + * + * With the check, it is "correctly" parsed as three + * string concatenations. Sigh. This seems to be + * "more correct", but this is definitely one of those + * occasions where the interactions are funny. + */ + if (! do_traditional && c == '_' && lasttok != '$') { + if ((c = nextc()) == '"') { + intlstr = TRUE; + goto string; + } + pushback(); + c = '_'; + } + + /* it's some type of name-type-thing. Find its length. */ + tok = tokstart; + while (c != END_FILE && is_identchar(c)) { + tokadd(c); + c = nextc(); + } + tokadd('\0'); + pushback(); + + /* See if it is a special token. */ + if ((mid = check_special(tokstart)) >= 0) { + static int warntab[sizeof(tokentab) / sizeof(tokentab[0])]; + int class = tokentab[mid].class; + + if ((class == LEX_INCLUDE || class == LEX_EVAL) + && lasttok != '@') + goto out; + + if (do_lint) { + if ((tokentab[mid].flags & GAWKX) && ! (warntab[mid] & GAWKX)) { + lintwarn(_("`%s' is a gawk extension"), + tokentab[mid].operator); + warntab[mid] |= GAWKX; + } + if ((tokentab[mid].flags & RESX) && ! (warntab[mid] & RESX)) { + lintwarn(_("`%s' is a Bell Labs extension"), + tokentab[mid].operator); + warntab[mid] |= RESX; + } + if ((tokentab[mid].flags & NOT_POSIX) && ! (warntab[mid] & NOT_POSIX)) { + lintwarn(_("POSIX does not allow `%s'"), + tokentab[mid].operator); + warntab[mid] |= NOT_POSIX; + } + } + if (do_lint_old && (tokentab[mid].flags & NOT_OLD) + && ! (warntab[mid] & NOT_OLD) + ) { + warning(_("`%s' is not supported in old awk"), + tokentab[mid].operator); + warntab[mid] |= NOT_OLD; + } + + if (tokentab[mid].flags & BREAK) + break_allowed++; + if (tokentab[mid].flags & CONTINUE) + continue_allowed++; + + switch (class) { + case LEX_INCLUDE: + want_source = TRUE; + break; + case LEX_EVAL: + if (in_main_context()) + goto out; + emalloc(tokkey, char *, tok - tokstart + 1, "yylex"); + tokkey[0] = '@'; + memcpy(tokkey + 1, tokstart, tok - tokstart); + yylval = GET_INSTRUCTION(Op_token); + yylval->lextok = tokkey; + break; + + case LEX_FUNCTION: + case LEX_BEGIN: + case LEX_END: + case LEX_BEGINFILE: + case LEX_ENDFILE: + yylval = bcalloc(tokentab[mid].value, 3, sourceline); + break; + + case LEX_FOR: + case LEX_WHILE: + case LEX_DO: + case LEX_SWITCH: + if (! do_profiling) + return lasttok = class; + /* fall through */ + case LEX_CASE: + yylval = bcalloc(tokentab[mid].value, 2, sourceline); + break; + + default: + yylval = GET_INSTRUCTION(tokentab[mid].value); + if (class == LEX_BUILTIN || class == LEX_LENGTH) + yylval->builtin_idx = mid; + break; + } + return lasttok = class; + } +out: + tokkey = estrdup(tokstart, tok - tokstart); + if (*lexptr == '(') { + yylval = bcalloc(Op_token, 2, sourceline); + yylval->lextok = tokkey; + return lasttok = FUNC_CALL; + } else { + static short goto_warned = FALSE; + + yylval = GET_INSTRUCTION(Op_token); + yylval->lextok = tokkey; + +#define SMART_ALECK 1 + if (SMART_ALECK && do_lint + && ! goto_warned && strcasecmp(tokkey, "goto") == 0) { + goto_warned = TRUE; + lintwarn(_("`goto' considered harmful!\n")); + } + return lasttok = NAME; + } + +#undef GET_INSTRUCTION +#undef NEWLINE_EOF +} + +/* mk_symbol --- allocates a symbol for the symbol table. */ + +NODE * +mk_symbol(NODETYPE type, NODE *value) +{ + NODE *r; + + getnode(r); + r->type = type; + r->flags = MALLOC; + r->lnode = value; + r->rnode = NULL; + r->parent_array = NULL; + r->var_assign = (Func_ptr) 0; + return r; +} + +/* snode --- instructions for builtin functions. Checks for arg. count + and supplies defaults where possible. */ + +static INSTRUCTION * +snode(INSTRUCTION *subn, INSTRUCTION *r) +{ + INSTRUCTION *arg; + INSTRUCTION *ip; + NODE *n; + int nexp = 0; + int args_allowed; + int idx = r->builtin_idx; + + if (subn != NULL) { + INSTRUCTION *tp; + for (tp = subn->nexti; tp; tp = tp->nexti) { + tp = tp->lasti; + nexp++; + } + assert(nexp > 0); + } + + /* check against how many args. are allowed for this builtin */ + args_allowed = tokentab[idx].flags & ARGS; + if (args_allowed && (args_allowed & A(nexp)) == 0) { + yyerror(_("%d is invalid as number of arguments for %s"), + nexp, tokentab[idx].operator); + return NULL; + } + + /* special processing for sub, gsub and gensub */ + + if (tokentab[idx].value == Op_sub_builtin) { + const char *operator = tokentab[idx].operator; + + r->sub_flags = 0; + + arg = subn->nexti; /* first arg list */ + (void) mk_rexp(arg); + + if (strcmp(operator, "gensub") != 0) { + /* sub and gsub */ + + if (strcmp(operator, "gsub") == 0) + r->sub_flags |= GSUB; + + arg = arg->lasti->nexti; /* 2nd arg list */ + if (nexp == 2) { + INSTRUCTION *expr; + + expr = list_create(instruction(Op_push_i)); + expr->nexti->memory = mk_number((AWKNUM) 0.0, (PERM|NUMCUR|NUMBER)); + (void) mk_expression_list(subn, + list_append(expr, instruction(Op_field_spec))); + } + + arg = arg->lasti->nexti; /* third arg list */ + ip = arg->lasti; + if (ip->opcode == Op_push_i) { + if (do_lint) + lintwarn(_("%s: string literal as last arg of substitute has no effect"), + operator); + r->sub_flags |= LITERAL; + } else { + if (make_assignable(ip) == NULL) + yyerror(_("%s third parameter is not a changeable object"), + operator); + else + ip->do_reference = TRUE; + } + + r->expr_count = count_expressions(&subn, FALSE); + ip = subn->lasti; + + (void) list_append(subn, r); + + /* add after_assign code */ + if (ip->opcode == Op_push_lhs && ip->memory->type == Node_var && ip->memory->var_assign) { + (void) list_append(subn, instruction(Op_var_assign)); + subn->lasti->assign_ctxt = Op_sub_builtin; + subn->lasti->assign_var = ip->memory->var_assign; + } else if (ip->opcode == Op_field_spec_lhs) { + (void) list_append(subn, instruction(Op_field_assign)); + subn->lasti->assign_ctxt = Op_sub_builtin; + subn->lasti->field_assign = (Func_ptr) 0; + ip->target_assign = subn->lasti; + } + return subn; + + } else { + /* gensub */ + + r->sub_flags |= GENSUB; + if (nexp == 3) { + ip = instruction(Op_push_i); + ip->memory = mk_number((AWKNUM) 0.0, (PERM|NUMCUR|NUMBER)); + (void) mk_expression_list(subn, + list_append(list_create(ip), instruction(Op_field_spec))); + } + + r->expr_count = count_expressions(&subn, FALSE); + return list_append(subn, r); + } + } + + r->builtin = tokentab[idx].ptr; + + /* special case processing for a few builtins */ + + if (r->builtin == do_length) { + if (nexp == 0) { + /* no args. Use $0 */ + + INSTRUCTION *list; + r->expr_count = 1; + list = list_create(r); + (void) list_prepend(list, instruction(Op_field_spec)); + (void) list_prepend(list, instruction(Op_push_i)); + list->nexti->memory = mk_number((AWKNUM) 0.0, (PERM|NUMCUR|NUMBER)); + return list; + } else { + arg = subn->nexti; + if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push) + arg->nexti->opcode = Op_push_arg; /* argument may be array */ + } + } else if (r->builtin == do_isarray) { + arg = subn->nexti; + if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push) + arg->nexti->opcode = Op_push_arg; /* argument may be array */ + } else if (r->builtin == do_match) { + static short warned = FALSE; + + arg = subn->nexti->lasti->nexti; /* 2nd arg list */ + (void) mk_rexp(arg); + + if (nexp == 3) { /* 3rd argument there */ + if (do_lint && ! warned) { + warned = TRUE; + lintwarn(_("match: third argument is a gawk extension")); + } + if (do_traditional) { + yyerror(_("match: third argument is a gawk extension")); + return NULL; + } + + arg = arg->lasti->nexti; /* third arg list */ + ip = arg->lasti; + if (/*ip == arg->nexti && */ ip->opcode == Op_push) + ip->opcode = Op_push_array; + } + } else if (r->builtin == do_split) { + arg = subn->nexti->lasti->nexti; /* 2nd arg list */ + ip = arg->lasti; + if (ip->opcode == Op_push) + ip->opcode = Op_push_array; + if (nexp == 2) { + INSTRUCTION *expr; + expr = list_create(instruction(Op_push)); + expr->nexti->memory = FS_node; + (void) mk_expression_list(subn, expr); + } + arg = arg->lasti->nexti; + n = mk_rexp(arg); + if (nexp == 2) + n->re_flags |= FS_DFLT; + if (nexp == 4) { + arg = arg->lasti->nexti; + ip = arg->lasti; + if (ip->opcode == Op_push) + ip->opcode = Op_push_array; + } + } else if (r->builtin == do_patsplit) { + arg = subn->nexti->lasti->nexti; /* 2nd arg list */ + ip = arg->lasti; + if (ip->opcode == Op_push) + ip->opcode = Op_push_array; + if (nexp == 2) { + INSTRUCTION *expr; + expr = list_create(instruction(Op_push)); + expr->nexti->memory = FPAT_node; + (void) mk_expression_list(subn, expr); + } + arg = arg->lasti->nexti; + n = mk_rexp(arg); + if (nexp == 4) { + arg = arg->lasti->nexti; + ip = arg->lasti; + if (ip->opcode == Op_push) + ip->opcode = Op_push_array; + } + } else if (r->builtin == do_close) { + static short warned = FALSE; + if (nexp == 2) { + if (do_lint && ! warned) { + warned = TRUE; + lintwarn(_("close: second argument is a gawk extension")); + } + if (do_traditional) { + yyerror(_("close: second argument is a gawk extension")); + return NULL; + } + } + } else if (do_intl /* --gen-po */ + && r->builtin == do_dcgettext /* dcgettext(...) */ + && subn->nexti->lasti->opcode == Op_push_i /* 1st arg is constant */ + && (subn->nexti->lasti->memory->flags & STRCUR) != 0) { /* it's a string constant */ + /* ala xgettext, dcgettext("some string" ...) dumps the string */ + NODE *str = subn->nexti->lasti->memory; + + if ((str->flags & INTLSTR) != 0) + warning(_("use of dcgettext(_\"...\") is incorrect: remove leading underscore")); + /* don't dump it, the lexer already did */ + else + dumpintlstr(str->stptr, str->stlen); + } else if (do_intl /* --gen-po */ + && r->builtin == do_dcngettext /* dcngettext(...) */ + && subn->nexti->lasti->opcode == Op_push_i /* 1st arg is constant */ + && (subn->nexti->lasti->memory->flags & STRCUR) != 0 /* it's a string constant */ + && subn->nexti->lasti->nexti->lasti->opcode == Op_push_i /* 2nd arg is constant too */ + && (subn->nexti->lasti->nexti->lasti->memory->flags & STRCUR) != 0) { /* it's a string constant */ + /* ala xgettext, dcngettext("some string", "some plural" ...) dumps the string */ + NODE *str1 = subn->nexti->lasti->memory; + NODE *str2 = subn->nexti->lasti->nexti->lasti->memory; + + if (((str1->flags | str2->flags) & INTLSTR) != 0) + warning(_("use of dcngettext(_\"...\") is incorrect: remove leading underscore")); + else + dumpintlstr2(str1->stptr, str1->stlen, str2->stptr, str2->stlen); + } else if (r->builtin == do_asort || r->builtin == do_asorti) { + arg = subn->nexti; /* 1st arg list */ + ip = arg->lasti; + if (ip->opcode == Op_push) + ip->opcode = Op_push_array; + if (nexp >= 2) { + arg = ip->nexti; + ip = arg->lasti; + if (ip->opcode == Op_push) + ip->opcode = Op_push_array; + } + } +#ifdef ARRAYDEBUG + else if (r->builtin == do_adump) { + ip = subn->nexti->lasti; + if (ip->opcode == Op_push) + ip->opcode = Op_push_array; + } +#endif + + if (subn != NULL) { + r->expr_count = count_expressions(&subn, FALSE); + return list_append(subn, r); + } + + r->expr_count = 0; + return list_create(r); +} + +/* append_param --- append PNAME to the list of parameters + * for the current function. + */ + +static void +append_param(char *pname) +{ + static NODE *savetail = NULL; + NODE *p; + + p = make_param(pname); + if (func_params == NULL) { + func_params = p; + savetail = p; + } else if (savetail != NULL) { + savetail->rnode = p; + savetail = p; + } +} + +/* dup_parms --- return TRUE if there are duplicate parameters */ + +static int +dup_parms(INSTRUCTION *fp, NODE *func) +{ + NODE *np; + const char *fname, **names; + int count, i, j, dups; + NODE *params; + + if (func == NULL) /* error earlier */ + return TRUE; + + fname = func->param; + count = func->param_cnt; + params = func->rnode; + + if (count == 0) /* no args, no problem */ + return FALSE; + + if (params == NULL) /* error earlier */ + return TRUE; + + emalloc(names, const char **, count * sizeof(char *), "dup_parms"); + + i = 0; + for (np = params; np != NULL; np = np->rnode) { + if (np->param == NULL) { /* error earlier, give up, go home */ + efree(names); + return TRUE; + } + names[i++] = np->param; + } + + dups = 0; + for (i = 1; i < count; i++) { + for (j = 0; j < i; j++) { + if (strcmp(names[i], names[j]) == 0) { + dups++; + error_ln(fp->source_line, + _("function `%s': parameter #%d, `%s', duplicates parameter #%d"), + fname, i + 1, names[j], j+1); + } + } + } + + efree(names); + return (dups > 0 ? TRUE : FALSE); +} + +/* parms_shadow --- check if parameters shadow globals */ + +static int +parms_shadow(INSTRUCTION *pc, int *shadow) +{ + int pcount, i; + int ret = FALSE; + NODE *func; + char *fname; + + func = pc->func_body; + fname = func->lnode->param; + +#if 0 /* can't happen, already exited if error ? */ + if (fname == NULL || func == NULL) /* error earlier */ + return FALSE; +#endif + + pcount = func->lnode->param_cnt; + + if (pcount == 0) /* no args, no problem */ + return 0; + + source = pc->source_file; + sourceline = pc->source_line; + /* + * Use warning() and not lintwarn() so that can warn + * about all shadowed parameters. + */ + for (i = 0; i < pcount; i++) { + if (lookup(func->parmlist[i]) != NULL) { + warning( + _("function `%s': parameter `%s' shadows global variable"), + fname, func->parmlist[i]); + ret = TRUE; + } + } + + *shadow |= ret; + return 0; +} + + +/* + * install_symbol: + * Install a name in the symbol table, even if it is already there. + * Caller must check against redefinition if that is desired. + */ + + +NODE * +install_symbol(char *name, NODE *value) +{ + NODE *hp; + size_t len; + int bucket; + + if (install_func) + (*install_func)(name); + + var_count++; + len = strlen(name); + bucket = hash(name, len, (unsigned long) HASHSIZE, NULL); + getnode(hp); + hp->type = Node_hashnode; + hp->hnext = variables[bucket]; + variables[bucket] = hp; + hp->hlength = len; + hp->hvalue = value; + hp->hname = name; + hp->hvalue->vname = name; + return hp->hvalue; +} + +/* lookup --- find the most recent hash node for name installed by install_symbol */ + +NODE * +lookup(const char *name) +{ + NODE *bucket; + size_t len; + + len = strlen(name); + for (bucket = variables[hash(name, len, (unsigned long) HASHSIZE, NULL)]; + bucket != NULL; bucket = bucket->hnext) + if (bucket->hlength == len && strncmp(bucket->hname, name, len) == 0) + return bucket->hvalue; + return NULL; +} + +/* sym_comp --- compare two symbol (variable or function) names */ + +static int +sym_comp(const void *v1, const void *v2) +{ + const NODE *const *npp1, *const *npp2; + const NODE *n1, *n2; + int minlen; + + npp1 = (const NODE *const *) v1; + npp2 = (const NODE *const *) v2; + n1 = *npp1; + n2 = *npp2; + + if (n1->hlength > n2->hlength) + minlen = n1->hlength; + else + minlen = n2->hlength; + + return strncmp(n1->hname, n2->hname, minlen); +} + +/* valinfo --- dump var info */ + +void +valinfo(NODE *n, int (*print_func)(FILE *, const char *, ...), FILE *fp) +{ + if (n == Nnull_string) + print_func(fp, "uninitialized scalar\n"); + else if (n->flags & STRING) { + pp_string_fp(print_func, fp, n->stptr, n->stlen, '"', FALSE); + print_func(fp, "\n"); + } else if (n->flags & NUMBER) + print_func(fp, "%.17g\n", n->numbr); + else if (n->flags & STRCUR) { + pp_string_fp(print_func, fp, n->stptr, n->stlen, '"', FALSE); + print_func(fp, "\n"); + } else if (n->flags & NUMCUR) + print_func(fp, "%.17g\n", n->numbr); + else + print_func(fp, "?? flags %s\n", flags2str(n->flags)); +} + +/* get_varlist --- list of global variables */ + +NODE ** +get_varlist() +{ + int i, j; + NODE **table; + NODE *p; + + emalloc(table, NODE **, (var_count + 1) * sizeof(NODE *), "get_varlist"); + update_global_values(); + for (i = j = 0; i < HASHSIZE; i++) + for (p = variables[i]; p != NULL; p = p->hnext) + table[j++] = p; + assert(j == var_count); + + /* Shazzam! */ + qsort(table, j, sizeof(NODE *), sym_comp); + + table[j] = NULL; + return table; +} + +/* print_vars --- print names and values of global variables */ + +void +print_vars(int (*print_func)(FILE *, const char *, ...), FILE *fp) +{ + int i; + NODE **table; + NODE *p; + + table = get_varlist(); + for (i = 0; (p = table[i]) != NULL; i++) { + if (p->hvalue->type == Node_func) + continue; + print_func(fp, "%.*s: ", (int) p->hlength, p->hname); + if (p->hvalue->type == Node_var_array) + print_func(fp, "array, %ld elements\n", p->hvalue->table_size); + else if (p->hvalue->type == Node_var_new) + print_func(fp, "untyped variable\n"); + else if (p->hvalue->type == Node_var) + valinfo(p->hvalue->var_value, print_func, fp); + } + efree(table); +} + +/* dump_vars --- dump the symbol table */ + +void +dump_vars(const char *fname) +{ + FILE *fp; + + if (fname == NULL) + fp = stderr; + else if ((fp = fopen(fname, "w")) == NULL) { + warning(_("could not open `%s' for writing (%s)"), fname, strerror(errno)); + warning(_("sending variable list to standard error")); + fp = stderr; + } + + print_vars(fprintf, fp); + if (fp != stderr && fclose(fp) != 0) + warning(_("%s: close failed (%s)"), fname, strerror(errno)); +} + +/* release_all_vars --- free all variable memory */ + +void +release_all_vars() +{ + int i; + NODE *p, *next; + + for (i = 0; i < HASHSIZE; i++) { + for (p = variables[i]; p != NULL; p = next) { + next = p->hnext; + + if (p->hvalue->type == Node_func) + continue; + else if (p->hvalue->type == Node_var_array) + assoc_clear(p->hvalue); + else if (p->hvalue->type != Node_var_new) + unref(p->hvalue->var_value); + + efree(p->hname); + freenode(p->hvalue); + freenode(p); + } + } +} + +/* dump_funcs --- print all functions */ + +void +dump_funcs() +{ + if (func_count <= 0) + return; + + (void) foreach_func((int (*)(INSTRUCTION *, void *)) pp_func, TRUE, (void *) 0); +} + +/* shadow_funcs --- check all functions for parameters that shadow globals */ + +void +shadow_funcs() +{ + static int calls = 0; + int shadow = FALSE; + + if (func_count <= 0) + return; + + if (calls++ != 0) + fatal(_("shadow_funcs() called twice!")); + + (void) foreach_func((int (*)(INSTRUCTION *, void *)) parms_shadow, TRUE, &shadow); + + /* End with fatal if the user requested it. */ + if (shadow && lintfunc != warning) + lintwarn(_("there were shadowed variables.")); +} + +/* + * func_install: + * check if name is already installed; if so, it had better have Null value, + * in which case def is added as the value. Otherwise, install name with def + * as value. + * + * Extra work, build up and save a list of the parameter names in a table + * and hang it off params->parmlist. This is used to set the `vname' field + * of each function parameter during a function call. See eval.c. + */ + +static int +func_install(INSTRUCTION *func, INSTRUCTION *def) +{ + NODE *params; + NODE *r, *n, *thisfunc, *hp; + char **pnames = NULL; + char *fname; + int pcount = 0; + int i; + + params = func_params; + + /* check for function foo(foo) { ... }. bleah. */ + for (n = params->rnode; n != NULL; n = n->rnode) { + if (strcmp(n->param, params->param) == 0) { + error_ln(func->source_line, + _("function `%s': can't use function name as parameter name"), params->param); + return -1; + } else if (is_std_var(n->param)) { + error_ln(func->source_line, + _("function `%s': can't use special variable `%s' as a function parameter"), + params->param, n->param); + return -1; + } + } + + thisfunc = NULL; /* turn off warnings */ + + fname = params->param; + /* symbol table management */ + hp = remove_symbol(params->param); /* remove function name out of symbol table */ + if (hp != NULL) + freenode(hp); + r = lookup(fname); + if (r != NULL) { + error_ln(func->source_line, + _("function name `%s' previously defined"), fname); + return -1; + } else if (fname == builtin_func) /* not a valid function name */ + goto remove_params; + + /* add an implicit return at end; + * also used by 'return' command in debugger + */ + + (void) list_append(def, instruction(Op_push_i)); + def->lasti->memory = Nnull_string; + (void) list_append(def, instruction(Op_K_return)); + + if (do_profiling) + (void) list_prepend(def, instruction(Op_exec_count)); + + /* func->opcode is Op_func */ + (func + 1)->firsti = def->nexti; + (func + 1)->lasti = def->lasti; + (func + 2)->first_line = func->source_line; + (func + 2)->last_line = lastline; + + func->nexti = def->nexti; + bcfree(def); + + (void) list_append(rule_list, func + 1); /* debugging */ + + /* install the function */ + thisfunc = mk_symbol(Node_func, params); + (void) install_symbol(fname, thisfunc); + thisfunc->code_ptr = func; + func->func_body = thisfunc; + + for (n = params->rnode; n != NULL; n = n->rnode) + pcount++; + + if (pcount != 0) { + emalloc(pnames, char **, (pcount + 1) * sizeof(char *), "func_install"); + for (i = 0, n = params->rnode; i < pcount; i++, n = n->rnode) + pnames[i] = n->param; + pnames[pcount] = NULL; + } + thisfunc->parmlist = pnames; + + /* update lint table info */ + func_use(fname, FUNC_DEFINE); + + func_count++; /* used in profiler / pretty printer */ + +remove_params: + /* remove params from symbol table */ + pop_params(params->rnode); + return 0; +} + +/* remove_symbol --- remove a variable from the symbol table */ + +NODE * +remove_symbol(char *name) +{ + NODE *bucket, **save; + size_t len; + + len = strlen(name); + save = &(variables[hash(name, len, (unsigned long) HASHSIZE, NULL)]); + for (bucket = *save; bucket != NULL; bucket = bucket->hnext) { + if (len == bucket->hlength && strncmp(bucket->hname, name, len) == 0) { + var_count--; + *save = bucket->hnext; + return bucket; + } + save = &(bucket->hnext); + } + return NULL; +} + +/* pop_params --- remove list of function parameters from symbol table */ + +/* + * pop parameters out of the symbol table. do this in reverse order to + * avoid reading freed memory if there were duplicated parameters. + */ +static void +pop_params(NODE *params) +{ + NODE *hp; + if (params == NULL) + return; + pop_params(params->rnode); + hp = remove_symbol(params->param); + if (hp != NULL) + freenode(hp); +} + +/* make_param --- make NAME into a function parameter */ + +static NODE * +make_param(char *name) +{ + NODE *r; + + getnode(r); + r->type = Node_param_list; + r->rnode = NULL; + r->param_cnt = param_counter++; + return (install_symbol(name, r)); +} + +static struct fdesc { + char *name; + short used; + short defined; + struct fdesc *next; +} *ftable[HASHSIZE]; + +/* func_use --- track uses and definitions of functions */ + +static void +func_use(const char *name, enum defref how) +{ + struct fdesc *fp; + int len; + int ind; + + len = strlen(name); + ind = hash(name, len, HASHSIZE, NULL); + + for (fp = ftable[ind]; fp != NULL; fp = fp->next) { + if (strcmp(fp->name, name) == 0) { + if (how == FUNC_DEFINE) + fp->defined++; + else + fp->used++; + return; + } + } + + /* not in the table, fall through to allocate a new one */ + + emalloc(fp, struct fdesc *, sizeof(struct fdesc), "func_use"); + memset(fp, '\0', sizeof(struct fdesc)); + emalloc(fp->name, char *, len + 1, "func_use"); + strcpy(fp->name, name); + if (how == FUNC_DEFINE) + fp->defined++; + else + fp->used++; + fp->next = ftable[ind]; + ftable[ind] = fp; +} + +/* check_funcs --- verify functions that are called but not defined */ + +static void +check_funcs() +{ + struct fdesc *fp, *next; + int i; + + if (! in_main_context()) + goto free_mem; + + for (i = 0; i < HASHSIZE; i++) { + for (fp = ftable[i]; fp != NULL; fp = fp->next) { +#ifdef REALLYMEAN + /* making this the default breaks old code. sigh. */ + if (fp->defined == 0) { + error( + _("function `%s' called but never defined"), fp->name); + errcount++; + } +#else + if (do_lint && fp->defined == 0) + lintwarn( + _("function `%s' called but never defined"), fp->name); +#endif + if (do_lint && fp->used == 0) { + lintwarn(_("function `%s' defined but never called directly"), + fp->name); + } + } + } + +free_mem: + /* now let's free all the memory */ + for (i = 0; i < HASHSIZE; i++) { + for (fp = ftable[i]; fp != NULL; fp = next) { + next = fp->next; + efree(fp->name); + efree(fp); + } + ftable[i] = NULL; + } +} + +/* param_sanity --- look for parameters that are regexp constants */ + +static void +param_sanity(INSTRUCTION *arglist) +{ + INSTRUCTION *argl, *arg; + int i = 1; + + if (arglist == NULL) + return; + for (argl = arglist->nexti; argl; ) { + arg = argl->lasti; + if (arg->opcode == Op_match_rec) + warning_ln(arg->source_line, + _("regexp constant for parameter #%d yields boolean value"), i); + argl = arg->nexti; + i++; + } +} + +/* foreach_func --- execute given function for each awk function in symbol table. */ + +int +foreach_func(int (*pfunc)(INSTRUCTION *, void *), int sort, void *data) +{ + int i, j; + NODE *p; + int ret = 0; + + if (sort) { + NODE **tab; + + /* + * Walk through symbol table counting functions. + * Could be more than func_count if there are + * extension functions. + */ + for (i = j = 0; i < HASHSIZE; i++) { + for (p = variables[i]; p != NULL; p = p->hnext) { + if (p->hvalue->type == Node_func) { + j++; + } + } + } + + if (j == 0) + return 0; + + emalloc(tab, NODE **, j * sizeof(NODE *), "foreach_func"); + + /* now walk again, copying info */ + for (i = j = 0; i < HASHSIZE; i++) { + for (p = variables[i]; p != NULL; p = p->hnext) { + if (p->hvalue->type == Node_func) { + tab[j] = p; + j++; + } + } + } + + /* Shazzam! */ + qsort(tab, j, sizeof(NODE *), sym_comp); + + for (i = 0; i < j; i++) { + if ((ret = pfunc(tab[i]->hvalue->code_ptr, data)) != 0) + break; + } + + efree(tab); + return ret; + } + + /* unsorted */ + for (i = 0; i < HASHSIZE; i++) { + for (p = variables[i]; p != NULL; p = p->hnext) { + if (p->hvalue->type == Node_func + && (ret = pfunc(p->hvalue->code_ptr, data)) != 0) + return ret; + } + } + return 0; +} + +/* deferred variables --- those that are only defined if needed. */ + +/* + * Is there any reason to use a hash table for deferred variables? At the + * moment, there are only 1 to 3 such variables, so it may not be worth + * the overhead. If more modules start using this facility, it should + * probably be converted into a hash table. + */ + +static struct deferred_variable { + NODE *(*load_func)(void); + struct deferred_variable *next; + char name[1]; /* variable-length array */ +} *deferred_variables; + +/* register_deferred_variable --- add a var name and loading function to the list */ + +void +register_deferred_variable(const char *name, NODE *(*load_func)(void)) +{ + struct deferred_variable *dv; + size_t sl = strlen(name); + + emalloc(dv, struct deferred_variable *, sizeof(*dv)+sl, + "register_deferred_variable"); + dv->load_func = load_func; + dv->next = deferred_variables; + memcpy(dv->name, name, sl+1); + deferred_variables = dv; +} + +/* variable --- make sure NAME is in the symbol table */ + +NODE * +variable(char *name, NODETYPE type) +{ + NODE *r; + + if ((r = lookup(name)) != NULL) { + if (r->type == Node_func) { + error(_("function `%s' called with space between name and `(',\nor used as a variable or an array"), + r->vname); + errcount++; + r->type = Node_var_new; /* continue parsing instead of exiting */ + } + } else { + /* not found */ + struct deferred_variable *dv; + + for (dv = deferred_variables; TRUE; dv = dv->next) { + if (dv == NULL) { + /* + * This is the only case in which we may not free the string. + */ + if (type == Node_var) + r = mk_symbol(type, Nnull_string); + else + r = mk_symbol(type, (NODE *) NULL); + return install_symbol(name, r); + } + if (strcmp(name, dv->name) == 0) { + r = (*dv->load_func)(); + break; + } + } + } + efree(name); + return r; +} + +/* make_regnode --- make a regular expression node */ + +static NODE * +make_regnode(int type, NODE *exp) +{ + NODE *n; + + getnode(n); + memset(n, 0, sizeof(NODE)); + n->type = type; + n->re_cnt = 1; + + if (type == Node_regex) { + n->re_reg = make_regexp(exp->stptr, exp->stlen, FALSE, TRUE, FALSE); + if (n->re_reg == NULL) { + freenode(n); + return NULL; + } + n->re_exp = exp; + n->re_flags = CONSTANT; + } + return n; +} + + +/* mk_rexp --- make a regular expression constant */ + +static NODE * +mk_rexp(INSTRUCTION *list) +{ + INSTRUCTION *ip; + + ip = list->nexti; + if (ip == list->lasti && ip->opcode == Op_match_rec) + ip->opcode = Op_push_re; + else { + ip = instruction(Op_push_re); + ip->memory = make_regnode(Node_dynregex, NULL); + ip->nexti = list->lasti->nexti; + list->lasti->nexti = ip; + list->lasti = ip; + } + return ip->memory; +} + +/* isnoeffect --- when used as a statement, has no side effects */ + +static int +isnoeffect(OPCODE type) +{ + switch (type) { + case Op_times: + case Op_times_i: + case Op_quotient: + case Op_quotient_i: + case Op_mod: + case Op_mod_i: + case Op_plus: + case Op_plus_i: + case Op_minus: + case Op_minus_i: + case Op_subscript: + case Op_concat: + case Op_exp: + case Op_exp_i: + case Op_unary_minus: + case Op_field_spec: + case Op_and_final: + case Op_or_final: + case Op_equal: + case Op_notequal: + case Op_less: + case Op_greater: + case Op_leq: + case Op_geq: + case Op_match: + case Op_nomatch: + case Op_match_rec: + case Op_not: + case Op_in_array: + return TRUE; + default: + break; /* keeps gcc -Wall happy */ + } + + return FALSE; +} + +/* make_assignable --- make this operand an assignable one if posiible */ + +static INSTRUCTION * +make_assignable(INSTRUCTION *ip) +{ + switch (ip->opcode) { + case Op_push: + if (ip->memory->type == Node_param_list + && (ip->memory->flags & FUNC) != 0) + return NULL; + ip->opcode = Op_push_lhs; + return ip; + case Op_field_spec: + ip->opcode = Op_field_spec_lhs; + return ip; + case Op_subscript: + ip->opcode = Op_subscript_lhs; + return ip; + default: + break; /* keeps gcc -Wall happy */ + } + return NULL; +} + +/* stopme --- for debugging */ + +NODE * +stopme(int nargs ATTRIBUTE_UNUSED) +{ + return (NODE *) 0; +} + +/* dumpintlstr --- write out an initial .po file entry for the string */ + +static void +dumpintlstr(const char *str, size_t len) +{ + char *cp; + + /* See the GNU gettext distribution for details on the file format */ + + if (source != NULL) { + /* ala the gettext sources, remove leading `./'s */ + for (cp = source; cp[0] == '.' && cp[1] == '/'; cp += 2) + continue; + printf("#: %s:%d\n", cp, sourceline); + } + + printf("msgid "); + pp_string_fp(fprintf, stdout, str, len, '"', TRUE); + putchar('\n'); + printf("msgstr \"\"\n\n"); + fflush(stdout); +} + +/* dumpintlstr2 --- write out an initial .po file entry for the string and its plural */ + +static void +dumpintlstr2(const char *str1, size_t len1, const char *str2, size_t len2) +{ + char *cp; + + /* See the GNU gettext distribution for details on the file format */ + + if (source != NULL) { + /* ala the gettext sources, remove leading `./'s */ + for (cp = source; cp[0] == '.' && cp[1] == '/'; cp += 2) + continue; + printf("#: %s:%d\n", cp, sourceline); + } + + printf("msgid "); + pp_string_fp(fprintf, stdout, str1, len1, '"', TRUE); + putchar('\n'); + printf("msgid_plural "); + pp_string_fp(fprintf, stdout, str2, len2, '"', TRUE); + putchar('\n'); + printf("msgstr[0] \"\"\nmsgstr[1] \"\"\n\n"); + fflush(stdout); +} + +/* isarray --- can this type be subscripted? */ + +static int +isarray(NODE *n) +{ + switch (n->type) { + case Node_var_new: + case Node_var_array: + return TRUE; + case Node_param_list: + return (n->flags & FUNC) == 0; + case Node_array_ref: + cant_happen(); + break; + default: + break; /* keeps gcc -Wall happy */ + } + + return FALSE; +} + +/* mk_binary --- instructions for binary operators */ + +static INSTRUCTION * +mk_binary(INSTRUCTION *s1, INSTRUCTION *s2, INSTRUCTION *op) +{ + INSTRUCTION *ip1,*ip2; + AWKNUM res; + + ip2 = s2->nexti; + if (s2->lasti == ip2 && ip2->opcode == Op_push_i) { + /* do any numeric constant folding */ + ip1 = s1->nexti; + if (do_optimize > 1 + && ip1 == s1->lasti && ip1->opcode == Op_push_i + && (ip1->memory->flags & (STRCUR|STRING)) == 0 + && (ip2->memory->flags & (STRCUR|STRING)) == 0 + ) { + NODE *n1 = ip1->memory, *n2 = ip2->memory; + res = force_number(n1); + (void) force_number(n2); + switch (op->opcode) { + case Op_times: + res *= n2->numbr; + break; + case Op_quotient: + if (n2->numbr == 0.0) { + /* don't fatalize, allow parsing rest of the input */ + error_ln(op->source_line, _("division by zero attempted")); + goto regular; + } + + res /= n2->numbr; + break; + case Op_mod: + if (n2->numbr == 0.0) { + /* don't fatalize, allow parsing rest of the input */ + error_ln(op->source_line, _("division by zero attempted in `%%'")); + goto regular; + } +#ifdef HAVE_FMOD + res = fmod(res, n2->numbr); +#else /* ! HAVE_FMOD */ + (void) modf(res / n2->numbr, &res); + res = n1->numbr - res * n2->numbr; +#endif /* ! HAVE_FMOD */ + break; + case Op_plus: + res += n2->numbr; + break; + case Op_minus: + res -= n2->numbr; + break; + case Op_exp: + res = calc_exp(res, n2->numbr); + break; + default: + goto regular; + } + + op->opcode = Op_push_i; + op->memory = mk_number(res, (PERM|NUMCUR|NUMBER)); + n1->flags &= ~PERM; + n1->flags |= MALLOC; + n2->flags &= ~PERM; + n2->flags |= MALLOC; + unref(n1); + unref(n2); + bcfree(ip1); + bcfree(ip2); + bcfree(s1); + bcfree(s2); + return list_create(op); + } else { + /* do basic arithmetic optimisation */ + /* convert (Op_push_i Node_val) + (Op_plus) to (Op_plus_i Node_val) */ + switch (op->opcode) { + case Op_times: + op->opcode = Op_times_i; + break; + case Op_quotient: + op->opcode = Op_quotient_i; + break; + case Op_mod: + op->opcode = Op_mod_i; + break; + case Op_plus: + op->opcode = Op_plus_i; + break; + case Op_minus: + op->opcode = Op_minus_i; + break; + case Op_exp: + op->opcode = Op_exp_i; + break; + default: + goto regular; + } + + op->memory = ip2->memory; + bcfree(ip2); + bcfree(s2); /* Op_list */ + return list_append(s1, op); + } + } + +regular: + /* append lists s1, s2 and add `op' bytecode */ + (void) list_merge(s1, s2); + return list_append(s1, op); +} + +/* mk_boolean --- instructions for boolean and, or */ + +static INSTRUCTION * +mk_boolean(INSTRUCTION *left, INSTRUCTION *right, INSTRUCTION *op) +{ + INSTRUCTION *tp; + OPCODE opc, final_opc; + + opc = op->opcode; /* Op_and or Op_or */ + final_opc = (opc == Op_or) ? Op_or_final : Op_and_final; + + add_lint(right, LINT_assign_in_cond); + + tp = left->lasti; + + if (tp->opcode != final_opc) { /* x || y */ + list_append(right, instruction(final_opc)); + add_lint(left, LINT_assign_in_cond); + (void) list_append(left, op); + left->lasti->target_jmp = right->lasti; + + /* NB: target_stmt points to previous Op_and(Op_or) in a chain; + * target_stmt only used in the parser (see below). + */ + + left->lasti->target_stmt = left->lasti; + right->lasti->target_stmt = left->lasti; + } else { /* optimization for x || y || z || ... */ + INSTRUCTION *ip; + + op->opcode = final_opc; + (void) list_append(right, op); + op->target_stmt = tp; + tp->opcode = opc; + tp->target_jmp = op; + + /* update jump targets */ + for (ip = tp->target_stmt; ; ip = ip->target_stmt) { + assert(ip->opcode == opc); + assert(ip->target_jmp == tp); + /* if (ip->opcode == opc && ip->target_jmp == tp) */ + ip->target_jmp = op; + if (ip->target_stmt == ip) + break; + } + } + + return list_merge(left, right); +} + +/* mk_condition --- if-else and conditional */ + +static INSTRUCTION * +mk_condition(INSTRUCTION *cond, INSTRUCTION *ifp, INSTRUCTION *true_branch, + INSTRUCTION *elsep, INSTRUCTION *false_branch) +{ + /* + * ---------------- + * cond + * ---------------- + * t: [Op_jmp_false f ] + * ---------------- + * true_branch + * + * ---------------- + * [Op_jmp y] + * ---------------- + * f: + * false_branch + * ---------------- + * y: [Op_no_op] + * ---------------- + */ + + INSTRUCTION *ip; + + if (false_branch == NULL) { + false_branch = list_create(instruction(Op_no_op)); + if (elsep != NULL) { /* else { } */ + if (do_profiling) + (void) list_prepend(false_branch, elsep); + else + bcfree(elsep); + } + } else { + /* assert(elsep != NULL); */ + + /* avoid a series of no_op's: if .. else if .. else if .. */ + if (false_branch->lasti->opcode != Op_no_op) + (void) list_append(false_branch, instruction(Op_no_op)); + if (do_profiling) { + (void) list_prepend(false_branch, elsep); + false_branch->nexti->branch_end = false_branch->lasti; + (void) list_prepend(false_branch, instruction(Op_exec_count)); + } else + bcfree(elsep); + } + + (void) list_prepend(false_branch, instruction(Op_jmp)); + false_branch->nexti->target_jmp = false_branch->lasti; + + add_lint(cond, LINT_assign_in_cond); + ip = list_append(cond, instruction(Op_jmp_false)); + ip->lasti->target_jmp = false_branch->nexti->nexti; + + if (do_profiling) { + (void) list_prepend(ip, ifp); + (void) list_append(ip, instruction(Op_exec_count)); + ip->nexti->branch_if = ip->lasti; + ip->nexti->branch_else = false_branch->nexti; + } else + bcfree(ifp); + + if (true_branch != NULL) + list_merge(ip, true_branch); + return list_merge(ip, false_branch); +} + +enum defline { FIRST_LINE, LAST_LINE }; + +/* find_line -- find the first(last) line in a list of (pattern) instructions */ + +static int +find_line(INSTRUCTION *pattern, enum defline what) +{ + INSTRUCTION *ip; + int lineno = 0; + + for (ip = pattern->nexti; ip; ip = ip->nexti) { + if (what == LAST_LINE) { + if (ip->source_line > lineno) + lineno = ip->source_line; + } else { /* FIRST_LINE */ + if (ip->source_line > 0 + && (lineno == 0 || ip->source_line < lineno)) + lineno = ip->source_line; + } + if (ip == pattern->lasti) + break; + } + assert(lineno > 0); + return lineno; +} + +/* append_rule --- pattern-action instructions */ + +static INSTRUCTION * +append_rule(INSTRUCTION *pattern, INSTRUCTION *action) +{ + /* + * ---------------- + * pattern + * ---------------- + * [Op_jmp_false f ] + * ---------------- + * action + * ---------------- + * f: [Op_no_op ] + * ---------------- + */ + + INSTRUCTION *rp; + INSTRUCTION *tp; + INSTRUCTION *ip; + + if (rule != Rule) { + rp = pattern; + if (do_profiling) + (void) list_append(action, instruction(Op_no_op)); + (rp + 1)->firsti = action->nexti; + (rp + 1)->lasti = action->lasti; + (rp + 2)->first_line = pattern->source_line; + (rp + 2)->last_line = lastline; + ip = list_prepend(action, rp); + + } else { + rp = bcalloc(Op_rule, 3, 0); + rp->in_rule = Rule; + rp->source_file = source; + tp = instruction(Op_no_op); + + if (pattern == NULL) { + /* assert(action != NULL); */ + if (do_profiling) + (void) list_prepend(action, instruction(Op_exec_count)); + (rp + 1)->firsti = action->nexti; + (rp + 1)->lasti = tp; + (rp + 2)->first_line = firstline; + (rp + 2)->last_line = lastline; + rp->source_line = firstline; + ip = list_prepend(list_append(action, tp), rp); + } else { + (void) list_append(pattern, instruction(Op_jmp_false)); + pattern->lasti->target_jmp = tp; + (rp + 2)->first_line = find_line(pattern, FIRST_LINE); + rp->source_line = (rp + 2)->first_line; + if (action == NULL) { + (rp + 2)->last_line = find_line(pattern, LAST_LINE); + action = list_create(instruction(Op_K_print_rec)); + if (do_profiling) + (void) list_prepend(action, instruction(Op_exec_count)); + } else + (rp + 2)->last_line = lastline; + + if (do_profiling) { + (void) list_prepend(pattern, instruction(Op_exec_count)); + (void) list_prepend(action, instruction(Op_exec_count)); + } + (rp + 1)->firsti = action->nexti; + (rp + 1)->lasti = tp; + ip = list_append( + list_merge(list_prepend(pattern, rp), + action), + tp); + } + + } + + list_append(rule_list, rp + 1); + + if (rule_block[rule] == NULL) + rule_block[rule] = ip; + else + (void) list_merge(rule_block[rule], ip); + + return rule_block[rule]; +} + +/* mk_assignment --- assignment bytecodes */ + +static INSTRUCTION * +mk_assignment(INSTRUCTION *lhs, INSTRUCTION *rhs, INSTRUCTION *op) +{ + INSTRUCTION *tp; + INSTRUCTION *ip; + + tp = lhs->lasti; + switch (tp->opcode) { + case Op_field_spec: + tp->opcode = Op_field_spec_lhs; + break; + case Op_subscript: + tp->opcode = Op_subscript_lhs; + break; + case Op_push: + case Op_push_array: + tp->opcode = Op_push_lhs; + break; + default: + cant_happen(); + } + + tp->do_reference = (op->opcode != Op_assign); /* check for uninitialized reference */ + + if (rhs != NULL) + ip = list_merge(rhs, lhs); + else + ip = lhs; + + (void) list_append(ip, op); + + if (tp->opcode == Op_push_lhs + && tp->memory->type == Node_var + && tp->memory->var_assign + ) { + tp->do_reference = FALSE; /* no uninitialized reference checking + * for a special variable. + */ + (void) list_append(ip, instruction(Op_var_assign)); + ip->lasti->assign_var = tp->memory->var_assign; + } else if (tp->opcode == Op_field_spec_lhs) { + (void) list_append(ip, instruction(Op_field_assign)); + ip->lasti->field_assign = (Func_ptr) 0; + tp->target_assign = ip->lasti; + } + + return ip; +} + +/* optimize_assignment --- peephole optimization for assignment */ + +static INSTRUCTION * +optimize_assignment(INSTRUCTION *exp) +{ + INSTRUCTION *i1; + INSTRUCTION *i2; + INSTRUCTION *i3; + + /* + * Optimize assignment statements array[subs] = x; var = x; $n = x; + * string concatenation of the form s = s t. + * + * 1) Array element assignment array[subs] = x: + * Replaces Op_push_array + Op_subscript_lhs + Op_assign + Op_pop + * with single instruction Op_store_sub. + * Limitation: 1 dimension and sub is simple var/value. + * + * 2) Simple variable assignment var = x: + * Replaces Op_push_lhs + Op_assign + Op_pop with Op_store_var. + * + * 3) Field assignment $n = x: + * Replaces Op_field_spec_lhs + Op_assign + Op_field_assign + Op_pop + * with Op_store_field. + * + * 4) Optimization for string concatenation: + * For cases like x = x y, uses realloc to include y in x; + * also eliminates instructions Op_push_lhs and Op_pop. + */ + + /* + * N.B.: do not append Op_pop instruction to the returned + * instruction list if optimized. None of these + * optimized instructions pushes the r-value of assignment + * onto the runtime stack. + */ + + i2 = NULL; + i1 = exp->lasti; + + if ( ! do_optimize + || ( i1->opcode != Op_assign + && i1->opcode != Op_field_assign) + ) + return list_append(exp, instruction(Op_pop)); + + for (i2 = exp->nexti; i2 != i1; i2 = i2->nexti) { + switch (i2->opcode) { + case Op_concat: + if (i2->nexti->opcode == Op_push_lhs /* l.h.s is a simple variable */ + && (i2->concat_flag & CSVAR) /* 1st exp in r.h.s is a simple variable; + * see Op_concat in the grammer above. + */ + && i2->nexti->memory == exp->nexti->memory /* and the same as in l.h.s */ + && i2->nexti->nexti == i1 + && i1->opcode == Op_assign + ) { + /* s = s ... optimization */ + + /* avoid stuff like x = x (x = y) or x = x gsub(/./, "b", x); + * check for l-value reference to this variable in the r.h.s. + * Also, avoid function calls in general to guard against + * global variable assignment. + */ + + for (i3 = exp->nexti->nexti; i3 != i2; i3 = i3->nexti) { + if ((i3->opcode == Op_push_lhs && i3->memory == i2->nexti->memory) + || i3->opcode == Op_func_call) + return list_append(exp, instruction(Op_pop)); /* no optimization */ + } + + /* remove the variable from r.h.s */ + i3 = exp->nexti; + exp->nexti = i3->nexti; + bcfree(i3); + + if (--i2->expr_count == 1) /* one less expression in Op_concat */ + i2->opcode = Op_no_op; + + i3 = i2->nexti; + assert(i3->opcode == Op_push_lhs); + i3->opcode = Op_assign_concat; /* change Op_push_lhs to Op_assign_concat */ + i3->nexti = NULL; + bcfree(i1); /* Op_assign */ + exp->lasti = i3; /* update Op_list */ + return exp; + } + break; + + case Op_field_spec_lhs: + if (i2->nexti->opcode == Op_assign + && i2->nexti->nexti == i1 + && i1->opcode == Op_field_assign + ) { + /* $n = .. */ + i2->opcode = Op_store_field; + bcfree(i2->nexti); /* Op_assign */ + i2->nexti = NULL; + bcfree(i1); /* Op_field_assign */ + exp->lasti = i2; /* update Op_list */ + return exp; + } + break; + + case Op_push_array: + if (i2->nexti->nexti->opcode == Op_subscript_lhs) { + i3 = i2->nexti->nexti; + if (i3->sub_count == 1 + && i3->nexti == i1 + && i1->opcode == Op_assign + ) { + /* array[sub] = .. */ + i3->opcode = Op_store_sub; + i3->memory = i2->memory; + i3->expr_count = 1; /* sub_count shadows memory, + * so use expr_count instead. + */ + i3->nexti = NULL; + i2->opcode = Op_no_op; + bcfree(i1); /* Op_assign */ + exp->lasti = i3; /* update Op_list */ + return exp; + } + } + break; + + case Op_push_lhs: + if (i2->nexti == i1 + && i1->opcode == Op_assign + ) { + /* var = .. */ + i2->opcode = Op_store_var; + i2->nexti = NULL; + bcfree(i1); /* Op_assign */ + exp->lasti = i2; /* update Op_list */ + return exp; + } + break; + + default: + break; + } + } + + /* no optimization */ + return list_append(exp, instruction(Op_pop)); +} + + +/* mk_getline --- make instructions for getline */ + +static INSTRUCTION * +mk_getline(INSTRUCTION *op, INSTRUCTION *var, INSTRUCTION *redir, int redirtype) +{ + INSTRUCTION *ip; + INSTRUCTION *tp; + INSTRUCTION *asgn = NULL; + + /* + * getline [var] < [file] + * + * [ file (simp_exp)] + * [ [ var ] ] + * [ Op_K_getline_redir|NULL|redir_type|into_var] + * [ [var_assign] ] + * + */ + + if (redir == NULL) { + int sline = op->source_line; + bcfree(op); + op = bcalloc(Op_K_getline, 2, sline); + (op + 1)->target_endfile = ip_endfile; + (op + 1)->target_beginfile = ip_beginfile; + } + + if (var != NULL) { + tp = make_assignable(var->lasti); + assert(tp != NULL); + + /* check if we need after_assign bytecode */ + if (tp->opcode == Op_push_lhs + && tp->memory->type == Node_var + && tp->memory->var_assign + ) { + asgn = instruction(Op_var_assign); + asgn->assign_ctxt = op->opcode; + asgn->assign_var = tp->memory->var_assign; + } else if (tp->opcode == Op_field_spec_lhs) { + asgn = instruction(Op_field_assign); + asgn->assign_ctxt = op->opcode; + asgn->field_assign = (Func_ptr) 0; /* determined at run time */ + tp->target_assign = asgn; + } + if (redir != NULL) { + ip = list_merge(redir, var); + (void) list_append(ip, op); + } else + ip = list_append(var, op); + } else if (redir != NULL) + ip = list_append(redir, op); + else + ip = list_create(op); + op->into_var = (var != NULL); + op->redir_type = (redir != NULL) ? redirtype : 0; + + return (asgn == NULL ? ip : list_append(ip, asgn)); +} + + +/* mk_for_loop --- for loop bytecodes */ + +static INSTRUCTION * +mk_for_loop(INSTRUCTION *forp, INSTRUCTION *init, INSTRUCTION *cond, + INSTRUCTION *incr, INSTRUCTION *body) +{ + /* + * ------------------------ + * init (may be NULL) + * ------------------------ + * x: + * cond (Op_no_op if NULL) + * ------------------------ + * [ Op_jmp_false tb ] + * ------------------------ + * body (may be NULL) + * ------------------------ + * tc: + * incr (may be NULL) + * [ Op_jmp x ] + * ------------------------ + * tb:[ Op_no_op ] + */ + + INSTRUCTION *ip, *tbreak, *tcont; + INSTRUCTION *jmp; + INSTRUCTION *pp_cond; + INSTRUCTION *ret; + + tbreak = instruction(Op_no_op); + + if (cond != NULL) { + add_lint(cond, LINT_assign_in_cond); + pp_cond = cond->nexti; + ip = cond; + (void) list_append(ip, instruction(Op_jmp_false)); + ip->lasti->target_jmp = tbreak; + } else { + pp_cond = instruction(Op_no_op); + ip = list_create(pp_cond); + } + + if (init != NULL) + ip = list_merge(init, ip); + + if (do_profiling) { + (void) list_append(ip, instruction(Op_exec_count)); + (forp + 1)->forloop_cond = pp_cond; + (forp + 1)->forloop_body = ip->lasti; + } + + if (body != NULL) + (void) list_merge(ip, body); + + jmp = instruction(Op_jmp); + jmp->target_jmp = pp_cond; + if (incr == NULL) + tcont = jmp; + else { + tcont = incr->nexti; + (void) list_merge(ip, incr); + } + + (void) list_append(ip, jmp); + ret = list_append(ip, tbreak); + fix_break_continue(ret, tbreak, tcont); + + if (do_profiling) { + forp->target_break = tbreak; + forp->target_continue = tcont; + ret = list_prepend(ret, forp); + } /* else + forp is NULL */ + + return ret; +} + +/* add_lint --- add lint warning bytecode if needed */ + +static void +add_lint(INSTRUCTION *list, LINTTYPE linttype) +{ +#ifndef NO_LINT + INSTRUCTION *ip; + + switch (linttype) { + case LINT_assign_in_cond: + ip = list->lasti; + if (ip->opcode == Op_var_assign || ip->opcode == Op_field_assign) { + assert(ip != list->nexti); + for (ip = list->nexti; ip->nexti != list->lasti; ip = ip->nexti) + ; + } + + if (ip->opcode == Op_assign || ip->opcode == Op_assign_concat) { + list_append(list, instruction(Op_lint)); + list->lasti->lint_type = linttype; + } + break; + + case LINT_no_effect: + if (list->lasti->opcode == Op_pop && list->nexti != list->lasti) { + for (ip = list->nexti; ip->nexti != list->lasti; ip = ip->nexti) + ; + + if (do_lint) { /* compile-time warning */ + if (isnoeffect(ip->opcode)) + lintwarn_ln(ip->source_line, ("statement may have no effect")); + } + + if (ip->opcode == Op_push) { /* run-time warning */ + list_append(list, instruction(Op_lint)); + list->lasti->lint_type = linttype; + } + } + break; + + default: + break; + } +#endif +} + +/* mk_expression_list --- list of bytecode lists */ + +static INSTRUCTION * +mk_expression_list(INSTRUCTION *list, INSTRUCTION *s1) +{ + INSTRUCTION *r; + + /* we can't just combine all bytecodes, since we need to + * process individual expressions for a few builtins in snode() (-: + */ + + /* -- list of lists */ + /* [Op_list| ... ]------ + * | + * [Op_list| ... ] -- | + * ... | | + * ... <------- | + * [Op_list| ... ] -- | + * ... | | + * ... | | + * ... <------- -- + */ + + assert(s1 != NULL && s1->opcode == Op_list); + if (list == NULL) { + list = instruction(Op_list); + list->nexti = s1; + list->lasti = s1->lasti; + return list; + } + + /* append expression to the end of the list */ + + r = list->lasti; + r->nexti = s1; + list->lasti = s1->lasti; + return list; +} + +/* count_expressions --- fixup expression_list from mk_expression_list. + * returns no of expressions in list. isarg is true + * for function arguments. + */ + +static int +count_expressions(INSTRUCTION **list, int isarg) +{ + INSTRUCTION *expr; + INSTRUCTION *r = NULL; + int count = 0; + + if (*list == NULL) /* error earlier */ + return 0; + + for (expr = (*list)->nexti; expr; ) { + INSTRUCTION *t1, *t2; + t1 = expr->nexti; + t2 = expr->lasti; + if (isarg && t1 == t2 && t1->opcode == Op_push) + t1->opcode = Op_push_param; + if (++count == 1) + r = expr; + else + (void) list_merge(r, expr); + expr = t2->nexti; + } + + assert(count > 0); + if (! isarg && count > max_args) + max_args = count; + bcfree(*list); + *list = r; + return count; +} + +/* fix_break_continue --- fix up break & continue codes in loop bodies */ + +static void +fix_break_continue(INSTRUCTION *list, INSTRUCTION *b_target, INSTRUCTION *c_target) +{ + INSTRUCTION *ip; + + list->lasti->nexti = NULL; /* just to make sure */ + + for (ip = list->nexti; ip != NULL; ip = ip->nexti) { + switch (ip->opcode) { + case Op_K_break: + if (ip->target_jmp == NULL) + ip->target_jmp = b_target; + break; + + case Op_K_continue: + if (ip->target_jmp == NULL) + ip->target_jmp = c_target; + break; + + default: + /* this is to keep the compiler happy. sheesh. */ + break; + } + } +} + + +/* append_symbol --- append symbol to the list of symbols + * installed in the symbol table. + */ + +void +append_symbol(char *name) +{ + NODE *hp; + + /* N.B.: func_install removes func name and reinstalls it; + * and we get two entries for it here!. destroy_symbol() + * will find and destroy the Node_func which is what we want. + */ + + getnode(hp); + hp->hname = name; /* shallow copy */ + hp->hnext = symbol_list->hnext; + symbol_list->hnext = hp; +} + +/* release_symbol --- free symbol list and optionally remove symbol from symbol table */ + +void +release_symbols(NODE *symlist, int keep_globals) +{ + NODE *hp, *n; + + for (hp = symlist->hnext; hp != NULL; hp = n) { + if (! keep_globals) { + /* destroys globals, function, and params + * if still in symbol table and not removed by func_install + * due to parse error. + */ + destroy_symbol(hp->hname); + } + n = hp->hnext; + freenode(hp); + } + symlist->hnext = NULL; +} + +/* destroy_symbol --- remove a symbol from symbol table +* and free all associated memory. +*/ + +void +destroy_symbol(char *name) +{ + NODE *symbol, *hp; + + symbol = lookup(name); + if (symbol == NULL) + return; + + if (symbol->type == Node_func) { + char **varnames; + NODE *func, *n; + + func = symbol; + varnames = func->parmlist; + if (varnames != NULL) + efree(varnames); + + /* function parameters of type Node_param_list */ + for (n = func->lnode->rnode; n != NULL; ) { + NODE *np; + np = n->rnode; + efree(n->param); + freenode(n); + n = np; + } + freenode(func->lnode); + func_count--; + + } else if (symbol->type == Node_var_array) + assoc_clear(symbol); + else if (symbol->type == Node_var) + unref(symbol->var_value); + + /* remove from symbol table */ + hp = remove_symbol(name); + efree(hp->hname); + freenode(hp->hvalue); + freenode(hp); +} + +#define pool_size d.dl +#define freei x.xi +static INSTRUCTION *pool_list; +static AWK_CONTEXT *curr_ctxt = NULL; + +/* new_context --- create a new execution context. */ + +AWK_CONTEXT * +new_context() +{ + AWK_CONTEXT *ctxt; + + emalloc(ctxt, AWK_CONTEXT *, sizeof(AWK_CONTEXT), "new_context"); + memset(ctxt, 0, sizeof(AWK_CONTEXT)); + ctxt->srcfiles.next = ctxt->srcfiles.prev = &ctxt->srcfiles; + ctxt->rule_list.opcode = Op_list; + ctxt->rule_list.lasti = &ctxt->rule_list; + return ctxt; +} + +/* set_context --- change current execution context. */ + +static void +set_context(AWK_CONTEXT *ctxt) +{ + pool_list = &ctxt->pools; + symbol_list = &ctxt->symbols; + srcfiles = &ctxt->srcfiles; + rule_list = &ctxt->rule_list; + install_func = ctxt->install_func; + curr_ctxt = ctxt; +} + +/* + * push_context: + * + * Switch to the given context after saving the current one. The set + * of active execution contexts forms a stack; the global or main context + * is at the bottom of the stack. + */ + +void +push_context(AWK_CONTEXT *ctxt) +{ + ctxt->prev = curr_ctxt; + /* save current source and sourceline */ + if (curr_ctxt != NULL) { + curr_ctxt->sourceline = sourceline; + curr_ctxt->source = source; + } + sourceline = 0; + source = NULL; + set_context(ctxt); +} + +/* pop_context --- switch to previous execution context. */ + +void +pop_context() +{ + AWK_CONTEXT *ctxt; + + assert(curr_ctxt != NULL); + ctxt = curr_ctxt->prev; + /* restore source and sourceline */ + sourceline = ctxt->sourceline; + source = ctxt->source; + set_context(ctxt); +} + +/* in_main_context --- are we in the main context ? */ + +int +in_main_context() +{ + assert(curr_ctxt != NULL); + return (curr_ctxt->prev == NULL); +} + +/* free_context --- free context structure and related data. */ + +void +free_context(AWK_CONTEXT *ctxt, int keep_globals) +{ + SRCFILE *s, *sn; + + if (ctxt == NULL) + return; + + assert(curr_ctxt != ctxt); + + /* free all code including function codes */ + free_bcpool(&ctxt->pools); + /* free symbols */ + release_symbols(&ctxt->symbols, keep_globals); + /* free srcfiles */ + for (s = &ctxt->srcfiles; s != &ctxt->srcfiles; s = sn) { + sn = s->next; + if (s->stype != SRC_CMDLINE && s->stype != SRC_STDIN) + efree(s->fullpath); + efree(s->src); + efree(s); + } + efree(ctxt); +} + +/* free_bc_internal --- free internal memory of an instruction. */ + +static void +free_bc_internal(INSTRUCTION *cp) +{ + NODE *m; + + switch(cp->opcode) { + case Op_func_call: + if (cp->func_name != NULL + && cp->func_name != builtin_func + ) + efree(cp->func_name); + break; + case Op_push_re: + case Op_match_rec: + case Op_match: + case Op_nomatch: + m = cp->memory; + if (m->re_reg != NULL) + refree(m->re_reg); + if (m->re_exp != NULL) + unref(m->re_exp); + if (m->re_text != NULL) + unref(m->re_text); + freenode(m); + break; + case Op_token: /* token lost during error recovery in yyparse */ + if (cp->lextok != NULL) + efree(cp->lextok); + break; + case Op_illegal: + cant_happen(); + default: + break; + } +} + + +/* INSTR_CHUNK must be > largest code size (3) */ +#define INSTR_CHUNK 127 + +/* bcfree --- deallocate instruction */ + +void +bcfree(INSTRUCTION *cp) +{ + cp->opcode = 0; + cp->nexti = pool_list->freei; + pool_list->freei = cp; +} + +/* bcalloc --- allocate a new instruction */ + +INSTRUCTION * +bcalloc(OPCODE op, int size, int srcline) +{ + INSTRUCTION *cp; + + if (size > 1) { + /* wide instructions Op_rule, Op_func_call .. */ + emalloc(cp, INSTRUCTION *, (size + 1) * sizeof(INSTRUCTION), "bcalloc"); + cp->pool_size = size; + cp->nexti = pool_list->nexti; + pool_list->nexti = cp++; + } else { + INSTRUCTION *pool; + + pool = pool_list->freei; + if (pool == NULL) { + INSTRUCTION *last; + emalloc(cp, INSTRUCTION *, (INSTR_CHUNK + 1) * sizeof(INSTRUCTION), "bcalloc"); + + cp->pool_size = INSTR_CHUNK; + cp->nexti = pool_list->nexti; + pool_list->nexti = cp; + pool = ++cp; + last = &pool[INSTR_CHUNK - 1]; + for (; cp <= last; cp++) { + cp->opcode = 0; + cp->nexti = cp + 1; + } + --cp; + cp->nexti = NULL; + } + cp = pool; + pool_list->freei = cp->nexti; + } + + memset(cp, 0, size * sizeof(INSTRUCTION)); + cp->opcode = op; + cp->source_line = srcline; + return cp; +} + +/* free_bcpool --- free list of instruction memory pools */ + +static void +free_bcpool(INSTRUCTION *pl) +{ + INSTRUCTION *pool, *tmp; + + for (pool = pl->nexti; pool != NULL; pool = tmp) { + INSTRUCTION *cp, *last; + long psiz; + psiz = pool->pool_size; + if (psiz == INSTR_CHUNK) + last = pool + psiz; + else + last = pool + 1; + for (cp = pool + 1; cp <= last ; cp++) { + if (cp->opcode != 0) + free_bc_internal(cp); + } + tmp = pool->nexti; + efree(pool); + } + memset(pl, 0, sizeof(INSTRUCTION)); +} + + +static inline INSTRUCTION * +list_create(INSTRUCTION *x) +{ + INSTRUCTION *l; + + l = instruction(Op_list); + l->nexti = x; + l->lasti = x; + return l; +} + +static inline INSTRUCTION * +list_append(INSTRUCTION *l, INSTRUCTION *x) +{ +#ifdef GAWKDEBUG + if (l->opcode != Op_list) + cant_happen(); +#endif + l->lasti->nexti = x; + l->lasti = x; + return l; +} + +static inline INSTRUCTION * +list_prepend(INSTRUCTION *l, INSTRUCTION *x) +{ +#ifdef GAWKDEBUG + if (l->opcode != Op_list) + cant_happen(); +#endif + x->nexti = l->nexti; + l->nexti = x; + return l; +} + +static inline INSTRUCTION * +list_merge(INSTRUCTION *l1, INSTRUCTION *l2) +{ +#ifdef GAWKDEBUG + if (l1->opcode != Op_list) + cant_happen(); + if (l2->opcode != Op_list) + cant_happen(); +#endif + l1->lasti->nexti = l2->nexti; + l1->lasti = l2->lasti; + bcfree(l2); + return l1; +} + +/* See if name is a special token. */ + +int +check_special(const char *name) +{ + int low, high, mid; + int i; +#if 'a' == 0x81 /* it's EBCDIC */ + static int did_sort = FALSE; + + if (! did_sort) { + qsort((void *) tokentab, + sizeof(tokentab) / sizeof(tokentab[0]), + sizeof(tokentab[0]), tokcompare); + did_sort = TRUE; + } +#endif + + low = 0; + high = (sizeof(tokentab) / sizeof(tokentab[0])) - 1; + while (low <= high) { + mid = (low + high) / 2; + i = *name - tokentab[mid].operator[0]; + if (i == 0) + i = strcmp(name, tokentab[mid].operator); + + if (i < 0) /* token < mid */ + high = mid - 1; + else if (i > 0) /* token > mid */ + low = mid + 1; + else { + if ((do_traditional && (tokentab[mid].flags & GAWKX)) + || (do_posix && (tokentab[mid].flags & NOT_POSIX))) + return -1; + return mid; + } + } + return -1; +} + +/* + * This provides a private version of functions that act like VMS's + * variable-length record filesystem, where there was a bug on + * certain source files. + */ + +static FILE *fp = NULL; + +/* read_one_line --- return one input line at a time. mainly for debugging. */ + +static ssize_t +read_one_line(int fd, void *buffer, size_t count) +{ + char buf[BUFSIZ]; + + /* Minor potential memory leak here. Too bad. */ + if (fp == NULL) { + fp = fdopen(fd, "r"); + if (fp == NULL) { + fprintf(stderr, "ugh. fdopen: %s\n", strerror(errno)); + gawk_exit(EXIT_FAILURE); + } + } + + if (fgets(buf, sizeof buf, fp) == NULL) + return 0; + + memcpy(buffer, buf, strlen(buf)); + return strlen(buf); +} + +/* one_line_close --- close the open file being read with read_one_line() */ + +static int +one_line_close(int fd) +{ + int ret; + + if (fp == NULL || fd != fileno(fp)) + fatal("debugging read/close screwed up!"); + + ret = fclose(fp); + fp = NULL; + return ret; +} + diff --git a/awklib/ChangeLog b/awklib/ChangeLog new file mode 100644 index 0000000..1be7b4b --- /dev/null +++ b/awklib/ChangeLog @@ -0,0 +1,14 @@ +2012-03-28 Arnold D. Robbins + + * 4.0.1: Release tar ball made. + +2011-06-24 Arnold D. Robbins + + * Makefile.am (EXTRA_DIST): Add ChangeLog.0. + * 4.0.0: Remake the tar ball. + +2011-06-23 Arnold D. Robbins + + * ChangeLog.0: Rotated ChangeLog into this file. + * ChangeLog: Created anew for gawk 4.0.0 and on. + * 4.0.0: Release tar ball made. diff --git a/awklib/ChangeLog.0 b/awklib/ChangeLog.0 new file mode 100644 index 0000000..e3f24da --- /dev/null +++ b/awklib/ChangeLog.0 @@ -0,0 +1,180 @@ +Mon Jan 10 21:40:05 2011 Andreas Buening + + * Makefile.am (AWKPROG): Get correct path to gawk executable. + +Fri Nov 19 11:53:16 2010 Arnold D. Robbins + + * Makefile.am: Remove special handling of CVS directories. + +Thu May 6 20:55:14 2010 Arnold D. Robbins + + * Release 3.1.8: Release tar file made. + +Tue Jul 21 22:28:56 2009 Arnold D. Robbins + + * Release 3.1.7: Release tar file made. + +Mon Oct 22 08:49:05 2007 Arnold D. Robbins + + * Release 3.1.6: Release tar file made. + +2007-05-25 Andreas Schwab + + * Makefile.am: Add missing dependencies on stamp-eg. + +Wed Mar 14 13:22:52 2007 Andrew J. Schorr + + * Makefile.am (AWKPROG): New macro to set locale sanely. + (stamp-eg): Use it instead of $AWK to do the extractions. + +Wed Mar 14 13:16:28 2007 Arnold D. Robbins + + * Makefile.am (clean-local): Remove `eg.old' also. + +Sat Jan 13 21:17:33 2007 Ralf Wildenhues + + * Makefile.am (stamp-eg): Allow rebuilding from a VPATH build. + +Tue Jul 26 21:46:16 2005 Arnold D. Robbins + + * Release 3.1.5: Release tar file made. + +Mon Jun 20 23:20:22 2005 Andreas Schwab + + * Makefile.am: Install pwcat and grcat in pkglibexecdir instead of + libexecdir. + +Wed Feb 9 10:13:27 2005 Arnold D. Robbins + + * Makefile.am (pkgdatadir, pkglibexecdir): Use $(datadir) and + $(libexecdir) instead of @datadir@ and @libexecdir@ for coolest + GNU Coding Standards compatibility and functionality. Per Stepan + Kasal. + +Tue Feb 8 18:57:08 2005 Arnold D. Robbins + + * Makefile.am (pkgdatadir, pkglibexecdir): New variables for compatibility + with current GNU Coding Standards. Fixed uses. Thanks to Stepan Kasal + and the discussion in bug-gnu-utils. + +Mon Aug 2 12:18:15 2004 Arnold D. Robbins + + * Release 3.1.4: Release tar file made. + +Thu Mar 18 17:43:59 2004 Arnold D. Robbins + + * Makefile.am (INCLUDES): Renamed to AM_CPPFLAGS. Per + Stepan Kasal. + +Mon Jul 7 11:01:43 2003 Arnold D. Robbins + + * Release 3.1.3: Release tar file made. + +Wed Mar 19 14:10:31 2003 Arnold D. Robbins + + This time for sure. + -- Bullwinkle + + * Release 3.1.2: Release tar file made. + +Thu Oct 10 13:24:09 2002 Arnold D. Robbins + + * Makefile.am (INCLUDES): Added to get .. for build dir + which will have config.h in it. + (grcat,pwcat): Use $(COMPILE) instead of $(CC) to get + $(INCLUDES) included. + +Tue Jun 11 23:43:36 2002 Arnold D. Robbins + + * Makefile.am (grcat): Add def for config.h and -I flag. + +Wed May 1 16:41:32 2002 Arnold D. Robbins + + * Release 3.1.1: Release tar file made. + +Wed Apr 17 15:20:27 2002 Arnold D. Robbins + + * Makefile.am (clean): Add *.exe to list of files to be cleaned. + +2002-01-27 Bruno Haible + + * eg/lib/libintl.awk (dcngettext): New function. + +Sun Jun 3 13:04:44 2001 Arnold D. Robbins + + * Release 3.1.0: Release tar file made. And there was + rejoicing. + +2001-02-26 Paul Eggert + + * Makefile.am (stamp-eg): Use $(AWK), not awk, as the + native awk might not work. + +2001-02-26 Andreas Schwab + + * Makefile.am: Install igawk as script. + +Mon Nov 6 15:29:08 2000 Arnold D. Robbins + + * Makefile.am: Fixed to have all functionality from before + the switch to automake. + * extract.awk: Updated to match version in the doc. + +Sat Jul 26 23:08:29 1997 Arnold D. Robbins + + * Makefile.in (install-strip): new target. + +Mon Aug 7 15:23:00 2000 Arnold D. Robbins + + * Release 3.0.6: Release tar file made. + +Sun Jun 25 15:08:19 2000 Arnold D. Robbins + + * Release 3.0.5: Release tar file made. + +Wed Jun 30 16:14:36 1999 Arnold D. Robbins + + * Release 3.0.4: Release tar file made. This time for sure. + +Thu May 15 12:49:08 1997 Arnold D. Robbins + + * Release 3.0.3: Release tar file made. + +Fri Apr 18 07:55:47 1997 Arnold D. Robbins + + * BETA Release 3.0.34: Release tar file made. + +Sun Apr 13 15:40:55 1997 Arnold D. Robbins + + * Makefile.in (install): fix second for loop to use $$i. Sigh. + +Wed Dec 25 11:25:22 1996 Arnold D. Robbins + + * Release 3.0.2: Release tar file made. + +Wed Dec 25 11:17:32 1996 Arnold D. Robbins + + * Makefile.in (install): remove chmod command; let + $(INSTALL_PROGRAM) use -m. + +Tue Dec 17 22:29:49 1996 Arnold D. Robbins + + * Makefile.in (install): fix installation of files in eg/lib. + +Tue Dec 10 23:09:26 1996 Arnold D. Robbins + + * Release 3.0.1: Release tar file made. + +Sun Oct 20 12:30:41 1996 Arnold D. Robbins + + * Makefile.in (install): minor tweaks for portability. + +Fri Mar 15 06:33:38 1996 Arnold D. Robbins + + * Makefile.in (pwcat, grcat): Add $(LDFLAGS). + (clean): add `*~' to list of files to be removed. + +Wed Jan 24 10:06:16 1996 Arnold D. Robbins + + * Makefile.in (clean): Remove $(AUXAWK). + (maintainer-clean): Depend on distclean, not the other way around. diff --git a/awklib/Makefile.am b/awklib/Makefile.am new file mode 100644 index 0000000..4ff1403 --- /dev/null +++ b/awklib/Makefile.am @@ -0,0 +1,85 @@ +# +# awklib/Makefile.am --- automake input file for gawk +# +# Copyright (C) 1995-2006 the Free Software Foundation, Inc. +# +# This file is part of GAWK, the GNU implementation of the +# AWK Programming Language. +# +# GAWK is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# + +## process this file with automake to produce Makefile.in + +EXTRA_DIST = ChangeLog ChangeLog.0 extract.awk eg $(srcdir)/stamp-eg +# With some locales, the script extract.awk fails. +# So we fix the locale to some sensible value. +AWKPROG = LC_ALL=C LANG=C $(abs_top_builddir)/gawk$(EXEEXT) + +# Get config.h from the build directory and custom.h from the source directory. +AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) + +pkgdatadir = $(datadir)/awk +pkglibexecdir = $(libexecdir)/awk + +bin_SCRIPTS = igawk +pkglibexec_PROGRAMS = pwcat grcat +AUXAWK = passwd.awk group.awk +nodist_grcat_SOURCES = grcat.c +nodist_pwcat_SOURCES = pwcat.c + +all: $(srcdir)/stamp-eg $(AUXPROGS) igawk $(AUXAWK) + +install-exec-hook: $(AUXAWK) + $(mkinstalldirs) $(DESTDIR)$(pkgdatadir) + for i in $(AUXAWK) $(srcdir)/eg/lib/*.awk ; do \ + progname=`echo $$i | sed 's;.*/;;'` ; \ + $(INSTALL_DATA) $$i $(DESTDIR)$(pkgdatadir)/$$progname ; \ + done + +# pkglibexecdir and pkgdatadir are removed in the top level Makefile's uninstall +uninstall-local: + rm -fr $(DESTDIR)$(pkglibexecdir)/* $(DESTDIR)$(pkgdatadir)/* + rm -f $(DESTDIR)$(bindir)/igawk + +clean-local: + rm -f $(AUXAWK) igawk *.exe + rm -fr eg.old + +$(srcdir)/stamp-eg: $(srcdir)/../doc/gawk.texi $(srcdir)/../doc/gawkinet.texi + cd $(srcdir) && \ + rm -fr eg && \ + rm -fr stamp-eg && \ + $(AWKPROG) -f extract.awk ../doc/gawk.texi ../doc/gawkinet.texi + @echo 'some makes are stupid and will not check a directory' > $(srcdir)/stamp-eg + @echo 'against a file, so this file is a place holder. gack.' >> $(srcdir)/stamp-eg + +$(srcdir)/eg/lib/pwcat.c $(srcdir)/eg/lib/grcat.c $(srcdir)/eg/prog/igawk.sh \ +$(srcdir)/eg/lib/passwdawk.in $(srcdir)/eg/lib/groupawk.in: stamp-eg; @: + +pwcat$(EXEEXT): $(srcdir)/eg/lib/pwcat.c + $(COMPILE) $(srcdir)/eg/lib/pwcat.c $(LDFLAGS) -o $@ + +grcat$(EXEEXT): $(srcdir)/eg/lib/grcat.c + $(COMPILE) $(srcdir)/eg/lib/grcat.c $(LDFLAGS) -o $@ + +igawk: $(srcdir)/eg/prog/igawk.sh + cp $(srcdir)/eg/prog/igawk.sh $@ ; chmod 755 $@ + +passwd.awk: $(srcdir)/eg/lib/passwdawk.in + sed 's;/usr/local/libexec/awk;$(pkglibexecdir);' < $(srcdir)/eg/lib/passwdawk.in > passwd.awk + +group.awk: $(srcdir)/eg/lib/groupawk.in + sed 's;/usr/local/libexec/awk;$(pkglibexecdir);' < $(srcdir)/eg/lib/groupawk.in > group.awk diff --git a/awklib/Makefile.in b/awklib/Makefile.in new file mode 100644 index 0000000..01511c3 --- /dev/null +++ b/awklib/Makefile.in @@ -0,0 +1,636 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# +# awklib/Makefile.am --- automake input file for gawk +# +# Copyright (C) 1995-2006 the Free Software Foundation, Inc. +# +# This file is part of GAWK, the GNU implementation of the +# AWK Programming Language. +# +# GAWK is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# + + +VPATH = @srcdir@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +pkglibexec_PROGRAMS = pwcat$(EXEEXT) grcat$(EXEEXT) +subdir = awklib +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/arch.m4 \ + $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ + $(top_srcdir)/m4/intmax_t.m4 $(top_srcdir)/m4/inttypes_h.m4 \ + $(top_srcdir)/m4/isc-posix.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ + $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libsigsegv.m4 \ + $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/m4/readline.m4 $(top_srcdir)/m4/socket.m4 \ + $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ + $(top_srcdir)/m4/ulonglong.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__installdirs = "$(DESTDIR)$(pkglibexecdir)" "$(DESTDIR)$(bindir)" +PROGRAMS = $(pkglibexec_PROGRAMS) +nodist_grcat_OBJECTS = grcat.$(OBJEXT) +grcat_OBJECTS = $(nodist_grcat_OBJECTS) +grcat_LDADD = $(LDADD) +nodist_pwcat_OBJECTS = pwcat.$(OBJEXT) +pwcat_OBJECTS = $(nodist_pwcat_OBJECTS) +pwcat_LDADD = $(LDADD) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +SCRIPTS = $(bin_SCRIPTS) +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(nodist_grcat_SOURCES) $(nodist_pwcat_SOURCES) +DIST_SOURCES = +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +pkgdatadir = $(datadir)/awk +pkglibexecdir = $(libexecdir)/awk +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GREP = @GREP@ +HAVE_LIBSIGSEGV = @HAVE_LIBSIGSEGV@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +LDFLAGS = @LDFLAGS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBREADLINE = @LIBREADLINE@ +LIBS = @LIBS@ +LIBSIGSEGV = @LIBSIGSEGV@ +LIBSIGSEGV_PREFIX = @LIBSIGSEGV_PREFIX@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +LTLIBSIGSEGV = @LTLIBSIGSEGV@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSUB = @POSUB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOCKET_LIBS = @SOCKET_LIBS@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +EXTRA_DIST = ChangeLog ChangeLog.0 extract.awk eg $(srcdir)/stamp-eg +# With some locales, the script extract.awk fails. +# So we fix the locale to some sensible value. +AWKPROG = LC_ALL=C LANG=C $(abs_top_builddir)/gawk$(EXEEXT) + +# Get config.h from the build directory and custom.h from the source directory. +AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) +bin_SCRIPTS = igawk +AUXAWK = passwd.awk group.awk +nodist_grcat_SOURCES = grcat.c +nodist_pwcat_SOURCES = pwcat.c +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu awklib/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu awklib/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-pkglibexecPROGRAMS: $(pkglibexec_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(pkglibexecdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibexecdir)" + @list='$(pkglibexec_PROGRAMS)'; test -n "$(pkglibexecdir)" || list=; \ + for p in $$list; do echo "$$p $$p"; done | \ + sed 's/$(EXEEXT)$$//' | \ + while read p p1; do if test -f $$p; \ + then echo "$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ + -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ + sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) files[d] = files[d] " " $$1; \ + else { print "f", $$3 "/" $$4, $$1; } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(pkglibexecdir)$$dir'"; \ + $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(pkglibexecdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-pkglibexecPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(pkglibexec_PROGRAMS)'; test -n "$(pkglibexecdir)" || list=; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ + -e 's/$$/$(EXEEXT)/' `; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(pkglibexecdir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(pkglibexecdir)" && rm -f $$files + +clean-pkglibexecPROGRAMS: + -test -z "$(pkglibexec_PROGRAMS)" || rm -f $(pkglibexec_PROGRAMS) +install-binSCRIPTS: $(bin_SCRIPTS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-binSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + test -n "$$list" || exit 0; \ + echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(bindir)" && rm -f $$files + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grcat.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwcat.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) $(SCRIPTS) +installdirs: + for dir in "$(DESTDIR)$(pkglibexecdir)" "$(DESTDIR)$(bindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-local clean-pkglibexecPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-binSCRIPTS install-pkglibexecPROGRAMS + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-exec-hook +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binSCRIPTS uninstall-local \ + uninstall-pkglibexecPROGRAMS + +.MAKE: install-am install-exec-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-local clean-pkglibexecPROGRAMS ctags distclean \ + distclean-compile distclean-generic distclean-tags distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-binSCRIPTS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-exec-hook \ + install-html install-html-am install-info install-info-am \ + install-man install-pdf install-pdf-am \ + install-pkglibexecPROGRAMS install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-binSCRIPTS \ + uninstall-local uninstall-pkglibexecPROGRAMS + + +all: $(srcdir)/stamp-eg $(AUXPROGS) igawk $(AUXAWK) + +install-exec-hook: $(AUXAWK) + $(mkinstalldirs) $(DESTDIR)$(pkgdatadir) + for i in $(AUXAWK) $(srcdir)/eg/lib/*.awk ; do \ + progname=`echo $$i | sed 's;.*/;;'` ; \ + $(INSTALL_DATA) $$i $(DESTDIR)$(pkgdatadir)/$$progname ; \ + done + +# pkglibexecdir and pkgdatadir are removed in the top level Makefile's uninstall +uninstall-local: + rm -fr $(DESTDIR)$(pkglibexecdir)/* $(DESTDIR)$(pkgdatadir)/* + rm -f $(DESTDIR)$(bindir)/igawk + +clean-local: + rm -f $(AUXAWK) igawk *.exe + rm -fr eg.old + +$(srcdir)/stamp-eg: $(srcdir)/../doc/gawk.texi $(srcdir)/../doc/gawkinet.texi + cd $(srcdir) && \ + rm -fr eg && \ + rm -fr stamp-eg && \ + $(AWKPROG) -f extract.awk ../doc/gawk.texi ../doc/gawkinet.texi + @echo 'some makes are stupid and will not check a directory' > $(srcdir)/stamp-eg + @echo 'against a file, so this file is a place holder. gack.' >> $(srcdir)/stamp-eg + +$(srcdir)/eg/lib/pwcat.c $(srcdir)/eg/lib/grcat.c $(srcdir)/eg/prog/igawk.sh \ +$(srcdir)/eg/lib/passwdawk.in $(srcdir)/eg/lib/groupawk.in: stamp-eg; @: + +pwcat$(EXEEXT): $(srcdir)/eg/lib/pwcat.c + $(COMPILE) $(srcdir)/eg/lib/pwcat.c $(LDFLAGS) -o $@ + +grcat$(EXEEXT): $(srcdir)/eg/lib/grcat.c + $(COMPILE) $(srcdir)/eg/lib/grcat.c $(LDFLAGS) -o $@ + +igawk: $(srcdir)/eg/prog/igawk.sh + cp $(srcdir)/eg/prog/igawk.sh $@ ; chmod 755 $@ + +passwd.awk: $(srcdir)/eg/lib/passwdawk.in + sed 's;/usr/local/libexec/awk;$(pkglibexecdir);' < $(srcdir)/eg/lib/passwdawk.in > passwd.awk + +group.awk: $(srcdir)/eg/lib/groupawk.in + sed 's;/usr/local/libexec/awk;$(pkglibexecdir);' < $(srcdir)/eg/lib/groupawk.in > group.awk + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/awklib/eg/data/BBS-list b/awklib/eg/data/BBS-list new file mode 100644 index 0000000..1007417 --- /dev/null +++ b/awklib/eg/data/BBS-list @@ -0,0 +1,11 @@ +aardvark 555-5553 1200/300 B +alpo-net 555-3412 2400/1200/300 A +barfly 555-7685 1200/300 A +bites 555-1675 2400/1200/300 A +camelot 555-0542 300 C +core 555-2912 1200/300 C +fooey 555-1234 2400/1200/300 B +foot 555-6699 1200/300 B +macfoo 555-6480 1200/300 A +sdace 555-3430 2400/1200/300 A +sabafoo 555-2127 1200/300 C diff --git a/awklib/eg/data/class_data1 b/awklib/eg/data/class_data1 new file mode 100644 index 0000000..864c284 --- /dev/null +++ b/awklib/eg/data/class_data1 @@ -0,0 +1,3 @@ +Biology_101 sum average data: 87.0 92.4 78.5 94.9 +Chemistry_305 sum average data: 75.2 98.3 94.7 88.2 +English_401 sum average data: 100.0 95.6 87.1 93.4 diff --git a/awklib/eg/data/class_data2 b/awklib/eg/data/class_data2 new file mode 100644 index 0000000..f5de0e2 --- /dev/null +++ b/awklib/eg/data/class_data2 @@ -0,0 +1,3 @@ +Biology_101 sum average sort rsort data: 87.0 92.4 78.5 94.9 +Chemistry_305 sum average sort rsort data: 75.2 98.3 94.7 88.2 +English_401 sum average sort rsort data: 100.0 95.6 87.1 93.4 diff --git a/awklib/eg/data/guide-mellow.po b/awklib/eg/data/guide-mellow.po new file mode 100644 index 0000000..98c388d --- /dev/null +++ b/awklib/eg/data/guide-mellow.po @@ -0,0 +1,8 @@ +#: guide.awk:4 +msgid "Don't Panic" +msgstr "Hey man, relax!" + +#: guide.awk:5 +msgid "The Answer Is" +msgstr "Like, the scoop is" + diff --git a/awklib/eg/data/guide.po b/awklib/eg/data/guide.po new file mode 100644 index 0000000..de21218 --- /dev/null +++ b/awklib/eg/data/guide.po @@ -0,0 +1,8 @@ +#: guide.awk:4 +msgid "Don't Panic" +msgstr "" + +#: guide.awk:5 +msgid "The Answer Is" +msgstr "" + diff --git a/awklib/eg/data/inventory-shipped b/awklib/eg/data/inventory-shipped new file mode 100644 index 0000000..6788a0e --- /dev/null +++ b/awklib/eg/data/inventory-shipped @@ -0,0 +1,17 @@ +Jan 13 25 15 115 +Feb 15 32 24 226 +Mar 15 24 34 228 +Apr 31 52 63 420 +May 16 34 29 208 +Jun 31 42 75 492 +Jul 24 34 67 436 +Aug 15 34 47 316 +Sep 13 55 37 277 +Oct 29 54 68 525 +Nov 20 87 82 577 +Dec 17 35 61 401 + +Jan 21 36 64 620 +Feb 26 58 80 652 +Mar 24 75 70 495 +Apr 21 70 74 514 diff --git a/awklib/eg/lib/assert.awk b/awklib/eg/lib/assert.awk new file mode 100644 index 0000000..75fd885 --- /dev/null +++ b/awklib/eg/lib/assert.awk @@ -0,0 +1,20 @@ +# assert --- assert that a condition is true. Otherwise exit. + +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# May, 1993 + +function assert(condition, string) +{ + if (! condition) { + printf("%s:%d: assertion failed: %s\n", + FILENAME, FNR, string) > "/dev/stderr" + _assert_exit = 1 + exit 1 + } +} + +END { + if (_assert_exit) + exit 1 +} diff --git a/awklib/eg/lib/bits2str.awk b/awklib/eg/lib/bits2str.awk new file mode 100644 index 0000000..9725ee8 --- /dev/null +++ b/awklib/eg/lib/bits2str.awk @@ -0,0 +1,16 @@ +# bits2str --- turn a byte into readable 1's and 0's + +function bits2str(bits, data, mask) +{ + if (bits == 0) + return "0" + + mask = 1 + for (; bits != 0; bits = rshift(bits, 1)) + data = (and(bits, mask) ? "1" : "0") data + + while ((length(data) % 8) != 0) + data = "0" data + + return data +} diff --git a/awklib/eg/lib/cliff_rand.awk b/awklib/eg/lib/cliff_rand.awk new file mode 100644 index 0000000..e6a793a --- /dev/null +++ b/awklib/eg/lib/cliff_rand.awk @@ -0,0 +1,14 @@ +# cliff_rand.awk --- generate Cliff random numbers +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# December 2000 + +BEGIN { _cliff_seed = 0.1 } + +function cliff_rand() +{ + _cliff_seed = (100 * log(_cliff_seed)) % 1 + if (_cliff_seed < 0) + _cliff_seed = - _cliff_seed + return _cliff_seed +} diff --git a/awklib/eg/lib/ctime.awk b/awklib/eg/lib/ctime.awk new file mode 100644 index 0000000..f37856c --- /dev/null +++ b/awklib/eg/lib/ctime.awk @@ -0,0 +1,11 @@ +# ctime.awk +# +# awk version of C ctime(3) function + +function ctime(ts, format) +{ + format = "%a %b %e %H:%M:%S %Z %Y" + if (ts == 0) + ts = systime() # use current time as default + return strftime(format, ts) +} diff --git a/awklib/eg/lib/ftrans.awk b/awklib/eg/lib/ftrans.awk new file mode 100644 index 0000000..1709ac8 --- /dev/null +++ b/awklib/eg/lib/ftrans.awk @@ -0,0 +1,15 @@ +# ftrans.awk --- handle data file transitions +# +# user supplies beginfile() and endfile() functions +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# November 1992 + +FNR == 1 { + if (_filename_ != "") + endfile(_filename_) + _filename_ = FILENAME + beginfile(FILENAME) +} + +END { endfile(_filename_) } diff --git a/awklib/eg/lib/getopt.awk b/awklib/eg/lib/getopt.awk new file mode 100644 index 0000000..0b81aa0 --- /dev/null +++ b/awklib/eg/lib/getopt.awk @@ -0,0 +1,80 @@ +# getopt.awk --- Do C library getopt(3) function in awk +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# +# Initial version: March, 1991 +# Revised: May, 1993 + +# External variables: +# Optind -- index in ARGV of first nonoption argument +# Optarg -- string value of argument to current option +# Opterr -- if nonzero, print our own diagnostic +# Optopt -- current option letter + +# Returns: +# -1 at end of options +# "?" for unrecognized option +# a character representing the current option + +# Private Data: +# _opti -- index in multi-flag option, e.g., -abc +function getopt(argc, argv, options, thisopt, i) +{ + if (length(options) == 0) # no options given + return -1 + + if (argv[Optind] == "--") { # all done + Optind++ + _opti = 0 + return -1 + } else if (argv[Optind] !~ /^-[^:[:space:]]/) { + _opti = 0 + return -1 + } + if (_opti == 0) + _opti = 2 + thisopt = substr(argv[Optind], _opti, 1) + Optopt = thisopt + i = index(options, thisopt) + if (i == 0) { + if (Opterr) + printf("%c -- invalid option\n", + thisopt) > "/dev/stderr" + if (_opti >= length(argv[Optind])) { + Optind++ + _opti = 0 + } else + _opti++ + return "?" + } + if (substr(options, i + 1, 1) == ":") { + # get option argument + if (length(substr(argv[Optind], _opti + 1)) > 0) + Optarg = substr(argv[Optind], _opti + 1) + else + Optarg = argv[++Optind] + _opti = 0 + } else + Optarg = "" + if (_opti == 0 || _opti >= length(argv[Optind])) { + Optind++ + _opti = 0 + } else + _opti++ + return thisopt +} +BEGIN { + Opterr = 1 # default is to diagnose + Optind = 1 # skip ARGV[0] + + # test program + if (_getopt_test) { + while ((_go_c = getopt(ARGC, ARGV, "ab:cd")) != -1) + printf("c = <%c>, optarg = <%s>\n", + _go_c, Optarg) + printf("non-option arguments:\n") + for (; Optind < ARGC; Optind++) + printf("\tARGV[%d] = <%s>\n", + Optind, ARGV[Optind]) + } +} diff --git a/awklib/eg/lib/gettime.awk b/awklib/eg/lib/gettime.awk new file mode 100644 index 0000000..95f9c32 --- /dev/null +++ b/awklib/eg/lib/gettime.awk @@ -0,0 +1,62 @@ +# gettimeofday.awk --- get the time of day in a usable format +# +# Arnold Robbins, arnold@skeeve.com, Public Domain, May 1993 +# + +# Returns a string in the format of output of date(1) +# Populates the array argument time with individual values: +# time["second"] -- seconds (0 - 59) +# time["minute"] -- minutes (0 - 59) +# time["hour"] -- hours (0 - 23) +# time["althour"] -- hours (0 - 12) +# time["monthday"] -- day of month (1 - 31) +# time["month"] -- month of year (1 - 12) +# time["monthname"] -- name of the month +# time["shortmonth"] -- short name of the month +# time["year"] -- year modulo 100 (0 - 99) +# time["fullyear"] -- full year +# time["weekday"] -- day of week (Sunday = 0) +# time["altweekday"] -- day of week (Monday = 0) +# time["dayname"] -- name of weekday +# time["shortdayname"] -- short name of weekday +# time["yearday"] -- day of year (0 - 365) +# time["timezone"] -- abbreviation of timezone name +# time["ampm"] -- AM or PM designation +# time["weeknum"] -- week number, Sunday first day +# time["altweeknum"] -- week number, Monday first day + +function gettimeofday(time, ret, now, i) +{ + # get time once, avoids unnecessary system calls + now = systime() + + # return date(1)-style output + ret = strftime("%a %b %e %H:%M:%S %Z %Y", now) + + # clear out target array + delete time + + # fill in values, force numeric values to be + # numeric by adding 0 + time["second"] = strftime("%S", now) + 0 + time["minute"] = strftime("%M", now) + 0 + time["hour"] = strftime("%H", now) + 0 + time["althour"] = strftime("%I", now) + 0 + time["monthday"] = strftime("%d", now) + 0 + time["month"] = strftime("%m", now) + 0 + time["monthname"] = strftime("%B", now) + time["shortmonth"] = strftime("%b", now) + time["year"] = strftime("%y", now) + 0 + time["fullyear"] = strftime("%Y", now) + 0 + time["weekday"] = strftime("%w", now) + 0 + time["altweekday"] = strftime("%u", now) + 0 + time["dayname"] = strftime("%A", now) + time["shortdayname"] = strftime("%a", now) + time["yearday"] = strftime("%j", now) + 0 + time["timezone"] = strftime("%Z", now) + time["ampm"] = strftime("%p", now) + time["weeknum"] = strftime("%U", now) + 0 + time["altweeknum"] = strftime("%W", now) + 0 + + return ret +} diff --git a/awklib/eg/lib/grcat.c b/awklib/eg/lib/grcat.c new file mode 100644 index 0000000..ff2913a --- /dev/null +++ b/awklib/eg/lib/grcat.c @@ -0,0 +1,50 @@ +/* + * grcat.c + * + * Generate a printable version of the group database + */ +/* + * Arnold Robbins, arnold@skeeve.com, May 1993 + * Public Domain + * December 2010, move to ANSI C definition for main(). + */ + +/* For OS/2, do nothing. */ +#if HAVE_CONFIG_H +#include +#endif + +#if defined (STDC_HEADERS) +#include +#endif + +#ifndef HAVE_GETGRENT +int main() { return 0; } +#else +#include +#include + +int +main(int argc, char **argv) +{ + struct group *g; + int i; + + while ((g = getgrent()) != NULL) { +#ifdef ZOS_USS + printf("%s:%ld:", g->gr_name, (long) g->gr_gid); +#else + printf("%s:%s:%ld:", g->gr_name, g->gr_passwd, + (long) g->gr_gid); +#endif + for (i = 0; g->gr_mem[i] != NULL; i++) { + printf("%s", g->gr_mem[i]); + if (g->gr_mem[i+1] != NULL) + putchar(','); + } + putchar('\n'); + } + endgrent(); + return 0; +} +#endif /* HAVE_GETGRENT */ diff --git a/awklib/eg/lib/groupawk.in b/awklib/eg/lib/groupawk.in new file mode 100644 index 0000000..0917b92 --- /dev/null +++ b/awklib/eg/lib/groupawk.in @@ -0,0 +1,85 @@ +# group.awk --- functions for dealing with the group file +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# May 1993 +# Revised October 2000 +# Revised December 2010 + +BEGIN \ +{ + # Change to suit your system + _gr_awklib = "/usr/local/libexec/awk/" +} + +function _gr_init( oldfs, oldrs, olddol0, grcat, + using_fw, using_fpat, n, a, i) +{ + if (_gr_inited) + return + + oldfs = FS + oldrs = RS + olddol0 = $0 + using_fw = (PROCINFO["FS"] == "FIELDWIDTHS") + using_fpat = (PROCINFO["FS"] == "FPAT") + FS = ":" + RS = "\n" + + grcat = _gr_awklib "grcat" + while ((grcat | getline) > 0) { + if ($1 in _gr_byname) + _gr_byname[$1] = _gr_byname[$1] "," $4 + else + _gr_byname[$1] = $0 + if ($3 in _gr_bygid) + _gr_bygid[$3] = _gr_bygid[$3] "," $4 + else + _gr_bygid[$3] = $0 + + n = split($4, a, "[ \t]*,[ \t]*") + for (i = 1; i <= n; i++) + if (a[i] in _gr_groupsbyuser) + _gr_groupsbyuser[a[i]] = \ + _gr_groupsbyuser[a[i]] " " $1 + else + _gr_groupsbyuser[a[i]] = $1 + + _gr_bycount[++_gr_count] = $0 + } + close(grcat) + _gr_count = 0 + _gr_inited++ + FS = oldfs + if (using_fw) + FIELDWIDTHS = FIELDWIDTHS + else if (using_fpat) + FPAT = FPAT + RS = oldrs + $0 = olddol0 +} +function getgrnam(group) +{ + _gr_init() + return _gr_byname[group] +} +function getgrgid(gid) +{ + _gr_init() + return _gr_bygid[gid] +} +function getgruser(user) +{ + _gr_init() + return _gr_groupsbyuser[user] +} +function getgrent() +{ + _gr_init() + if (++_gr_count in _gr_bycount) + return _gr_bycount[_gr_count] + return "" +} +function endgrent() +{ + _gr_count = 0 +} diff --git a/awklib/eg/lib/join.awk b/awklib/eg/lib/join.awk new file mode 100644 index 0000000..4a4ac92 --- /dev/null +++ b/awklib/eg/lib/join.awk @@ -0,0 +1,16 @@ +# join.awk --- join an array into a string +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# May 1993 + +function join(array, start, end, sep, result, i) +{ + if (sep == "") + sep = " " + else if (sep == SUBSEP) # magic value + sep = "" + result = array[start] + for (i = start + 1; i <= end; i++) + result = result sep array[i] + return result +} diff --git a/awklib/eg/lib/libintl.awk b/awklib/eg/lib/libintl.awk new file mode 100644 index 0000000..7efd2b4 --- /dev/null +++ b/awklib/eg/lib/libintl.awk @@ -0,0 +1,14 @@ +function bindtextdomain(dir, domain) +{ + return dir +} + +function dcgettext(string, domain, category) +{ + return string +} + +function dcngettext(string1, string2, number, domain, category) +{ + return (number == 1 ? string1 : string2) +} diff --git a/awklib/eg/lib/noassign.awk b/awklib/eg/lib/noassign.awk new file mode 100644 index 0000000..1f750ed --- /dev/null +++ b/awklib/eg/lib/noassign.awk @@ -0,0 +1,17 @@ +# noassign.awk --- library file to avoid the need for a +# special option that disables command-line assignments +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# October 1999 + +function disable_assigns(argc, argv, i) +{ + for (i = 1; i < argc; i++) + if (argv[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/) + argv[i] = ("./" argv[i]) +} + +BEGIN { + if (No_command_assign) + disable_assigns(ARGC, ARGV) +} diff --git a/awklib/eg/lib/ord.awk b/awklib/eg/lib/ord.awk new file mode 100644 index 0000000..be47e15 --- /dev/null +++ b/awklib/eg/lib/ord.awk @@ -0,0 +1,44 @@ +# ord.awk --- do ord and chr + +# Global identifiers: +# _ord_: numerical values indexed by characters +# _ord_init: function to initialize _ord_ +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# 16 January, 1992 +# 20 July, 1992, revised + +BEGIN { _ord_init() } + +function _ord_init( low, high, i, t) +{ + low = sprintf("%c", 7) # BEL is ascii 7 + if (low == "\a") { # regular ascii + low = 0 + high = 127 + } else if (sprintf("%c", 128 + 7) == "\a") { + # ascii, mark parity + low = 128 + high = 255 + } else { # ebcdic(!) + low = 0 + high = 255 + } + + for (i = low; i <= high; i++) { + t = sprintf("%c", i) + _ord_[t] = i + } +} +function ord(str, c) +{ + # only first character is of interest + c = substr(str, 1, 1) + return _ord_[c] +} + +function chr(c) +{ + # force c to be numeric by adding 0 + return sprintf("%c", c + 0) +} diff --git a/awklib/eg/lib/passwdawk.in b/awklib/eg/lib/passwdawk.in new file mode 100644 index 0000000..d2442ad --- /dev/null +++ b/awklib/eg/lib/passwdawk.in @@ -0,0 +1,63 @@ +# passwd.awk --- access password file information +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# May 1993 +# Revised October 2000 +# Revised December 2010 + +BEGIN { + # tailor this to suit your system + _pw_awklib = "/usr/local/libexec/awk/" +} + +function _pw_init( oldfs, oldrs, olddol0, pwcat, using_fw, using_fpat) +{ + if (_pw_inited) + return + + oldfs = FS + oldrs = RS + olddol0 = $0 + using_fw = (PROCINFO["FS"] == "FIELDWIDTHS") + using_fpat = (PROCINFO["FS"] == "FPAT") + FS = ":" + RS = "\n" + + pwcat = _pw_awklib "pwcat" + while ((pwcat | getline) > 0) { + _pw_byname[$1] = $0 + _pw_byuid[$3] = $0 + _pw_bycount[++_pw_total] = $0 + } + close(pwcat) + _pw_count = 0 + _pw_inited = 1 + FS = oldfs + if (using_fw) + FIELDWIDTHS = FIELDWIDTHS + else if (using_fpat) + FPAT = FPAT + RS = oldrs + $0 = olddol0 +} +function getpwnam(name) +{ + _pw_init() + return _pw_byname[name] +} +function getpwuid(uid) +{ + _pw_init() + return _pw_byuid[uid] +} +function getpwent() +{ + _pw_init() + if (_pw_count < _pw_total) + return _pw_bycount[++_pw_count] + return "" +} +function endpwent() +{ + _pw_count = 0 +} diff --git a/awklib/eg/lib/pwcat.c b/awklib/eg/lib/pwcat.c new file mode 100644 index 0000000..910e032 --- /dev/null +++ b/awklib/eg/lib/pwcat.c @@ -0,0 +1,41 @@ +/* + * pwcat.c + * + * Generate a printable version of the password database + */ +/* + * Arnold Robbins, arnold@skeeve.com, May 1993 + * Public Domain + * December 2010, move to ANSI C definition for main(). + */ + +#if HAVE_CONFIG_H +#include +#endif + +#include +#include + +#if defined (STDC_HEADERS) +#include +#endif + +int +main(int argc, char **argv) +{ + struct passwd *p; + + while ((p = getpwent()) != NULL) +#ifdef ZOS_USS + printf("%s:%ld:%ld:%s:%s\n", + p->pw_name, (long) p->pw_uid, + (long) p->pw_gid, p->pw_dir, p->pw_shell); +#else + printf("%s:%s:%ld:%ld:%s:%s:%s\n", + p->pw_name, p->pw_passwd, (long) p->pw_uid, + (long) p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell); +#endif + + endpwent(); + return 0; +} diff --git a/awklib/eg/lib/quicksort.awk b/awklib/eg/lib/quicksort.awk new file mode 100644 index 0000000..7a635d6 --- /dev/null +++ b/awklib/eg/lib/quicksort.awk @@ -0,0 +1,33 @@ +# quicksort.awk --- Quicksort algorithm, with user-supplied +# comparison function +# +# Arnold Robbins, arnoldskeeve.com, Public Domain +# January 2009 +# quicksort --- C.A.R. Hoare's quick sort algorithm. See Wikipedia +# or almost any algorithms or computer science text +# +# Adapted from K&R-II, page 110 + +function quicksort(data, left, right, less_than, i, last) +{ + if (left >= right) # do nothing if array contains fewer + return # than two elements + + quicksort_swap(data, left, int((left + right) / 2)) + last = left + for (i = left + 1; i <= right; i++) + if (@less_than(data[i], data[left])) + quicksort_swap(data, ++last, i) + quicksort_swap(data, left, last) + quicksort(data, left, last - 1, less_than) + quicksort(data, last + 1, right, less_than) +} + +# quicksort_swap --- helper function for quicksort, should really be inline + +function quicksort_swap(data, i, j, temp) +{ + temp = data[i] + data[i] = data[j] + data[j] = temp +} diff --git a/awklib/eg/lib/readable.awk b/awklib/eg/lib/readable.awk new file mode 100644 index 0000000..6942dcc --- /dev/null +++ b/awklib/eg/lib/readable.awk @@ -0,0 +1,17 @@ +# readable.awk --- library file to skip over unreadable files +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# October 2000 +# December 2010 + +BEGIN { + for (i = 1; i < ARGC; i++) { + if (ARGV[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/ \ + || ARGV[i] == "-" || ARGV[i] == "/dev/stdin") + continue # assignment or standard input + else if ((getline junk < ARGV[i]) < 0) # unreadable + delete ARGV[i] + else + close(ARGV[i]) + } +} diff --git a/awklib/eg/lib/rewind.awk b/awklib/eg/lib/rewind.awk new file mode 100644 index 0000000..a646eac --- /dev/null +++ b/awklib/eg/lib/rewind.awk @@ -0,0 +1,20 @@ +# rewind.awk --- rewind the current file and start over +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# September 2000 + +function rewind( i) +{ + # shift remaining arguments up + for (i = ARGC; i > ARGIND; i--) + ARGV[i] = ARGV[i-1] + + # make sure gawk knows to keep going + ARGC++ + + # make current file next to get done + ARGV[ARGIND+1] = FILENAME + + # do it + nextfile +} diff --git a/awklib/eg/lib/round.awk b/awklib/eg/lib/round.awk new file mode 100644 index 0000000..899645f --- /dev/null +++ b/awklib/eg/lib/round.awk @@ -0,0 +1,29 @@ +# round.awk --- do normal rounding +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# August, 1996 + +function round(x, ival, aval, fraction) +{ + ival = int(x) # integer part, int() truncates + + # see if fractional part + if (ival == x) # no fraction + return ival # ensure no decimals + + if (x < 0) { + aval = -x # absolute value + ival = int(aval) + fraction = aval - ival + if (fraction >= .5) + return int(x) - 1 # -2.5 --> -3 + else + return int(x) # -2.3 --> -2 + } else { + fraction = x - ival + if (fraction >= .5) + return ival + 1 + else + return ival + } +} diff --git a/awklib/eg/lib/strtonum.awk b/awklib/eg/lib/strtonum.awk new file mode 100644 index 0000000..a56ab50 --- /dev/null +++ b/awklib/eg/lib/strtonum.awk @@ -0,0 +1,57 @@ +# mystrtonum --- convert string to number + +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# February, 2004 + +function mystrtonum(str, ret, chars, n, i, k, c) +{ + if (str ~ /^0[0-7]*$/) { + # octal + n = length(str) + ret = 0 + for (i = 1; i <= n; i++) { + c = substr(str, i, 1) + if ((k = index("01234567", c)) > 0) + k-- # adjust for 1-basing in awk + + ret = ret * 8 + k + } + } else if (str ~ /^0[xX][[:xdigit:]]+/) { + # hexadecimal + str = substr(str, 3) # lop off leading 0x + n = length(str) + ret = 0 + for (i = 1; i <= n; i++) { + c = substr(str, i, 1) + c = tolower(c) + if ((k = index("0123456789", c)) > 0) + k-- # adjust for 1-basing in awk + else if ((k = index("abcdef", c)) > 0) + k += 9 + + ret = ret * 16 + k + } + } else if (str ~ \ + /^[-+]?([0-9]+([.][0-9]*([Ee][0-9]+)?)?|([.][0-9]+([Ee][-+]?[0-9]+)?))$/) { + # decimal number, possibly floating point + ret = str + 0 + } else + ret = "NOT-A-NUMBER" + + return ret +} + +# BEGIN { # gawk test harness +# a[1] = "25" +# a[2] = ".31" +# a[3] = "0123" +# a[4] = "0xdeadBEEF" +# a[5] = "123.45" +# a[6] = "1.e3" +# a[7] = "1.32" +# a[7] = "1.32E2" +# +# for (i = 1; i in a; i++) +# print a[i], strtonum(a[i]), mystrtonum(a[i]) +# } diff --git a/awklib/eg/lib/walkarray.awk b/awklib/eg/lib/walkarray.awk new file mode 100644 index 0000000..5e36f46 --- /dev/null +++ b/awklib/eg/lib/walkarray.awk @@ -0,0 +1,9 @@ +function walk_array(arr, name, i) +{ + for (i in arr) { + if (isarray(arr[i])) + walk_array(arr[i], (name "[" i "]")) + else + printf("%s[%s] = %s\n", name, i, arr[i]) + } +} diff --git a/awklib/eg/lib/zerofile.awk b/awklib/eg/lib/zerofile.awk new file mode 100644 index 0000000..8ea549c --- /dev/null +++ b/awklib/eg/lib/zerofile.awk @@ -0,0 +1,19 @@ +# zerofile.awk --- library file to process empty input files +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# June 2003 + +BEGIN { Argind = 0 } + +ARGIND > Argind + 1 { + for (Argind++; Argind < ARGIND; Argind++) + zerofile(ARGV[Argind], Argind) +} + +ARGIND != Argind { Argind = ARGIND } + +END { + if (ARGIND > Argind) + for (Argind++; Argind <= ARGIND; Argind++) + zerofile(ARGV[Argind], Argind) +} diff --git a/awklib/eg/misc/addresses.csv b/awklib/eg/misc/addresses.csv new file mode 100644 index 0000000..a9eee0b --- /dev/null +++ b/awklib/eg/misc/addresses.csv @@ -0,0 +1 @@ +Robbins,Arnold,"1234 A Pretty Street, NE",MyTown,MyState,12345-6789,USA diff --git a/awklib/eg/misc/arraymax.awk b/awklib/eg/misc/arraymax.awk new file mode 100644 index 0000000..20dd176 --- /dev/null +++ b/awklib/eg/misc/arraymax.awk @@ -0,0 +1,10 @@ +{ + if ($1 > max) + max = $1 + arr[$1] = $0 +} + +END { + for (x = 1; x <= max; x++) + print arr[x] +} diff --git a/awklib/eg/misc/arraymax.data b/awklib/eg/misc/arraymax.data new file mode 100644 index 0000000..dbee328 --- /dev/null +++ b/awklib/eg/misc/arraymax.data @@ -0,0 +1,5 @@ +5 I am the Five man +2 Who are you? The new number two! +4 . . . And four on the floor +1 Who is number one? +3 I three you. diff --git a/awklib/eg/misc/findpat.awk b/awklib/eg/misc/findpat.awk new file mode 100644 index 0000000..e9bef9e --- /dev/null +++ b/awklib/eg/misc/findpat.awk @@ -0,0 +1,10 @@ +{ + if ($1 == "FIND") + regex = $2 + else { + where = match($0, regex) + if (where != 0) + print "Match of", regex, "found at", + where, "in", $0 + } +} diff --git a/awklib/eg/misc/findpat.data b/awklib/eg/misc/findpat.data new file mode 100644 index 0000000..9f72969 --- /dev/null +++ b/awklib/eg/misc/findpat.data @@ -0,0 +1,7 @@ +FIND ru+n +My program runs +but not very quickly +FIND Melvin +JF+KM +This line is property of Reality Engineering Co. +Melvin was here. diff --git a/awklib/eg/misc/simple-csv.awk b/awklib/eg/misc/simple-csv.awk new file mode 100644 index 0000000..36cb4a6 --- /dev/null +++ b/awklib/eg/misc/simple-csv.awk @@ -0,0 +1,10 @@ +BEGIN { + FPAT = "([^,]+)|(\"[^\"]+\")" +} + +{ + print "NF = ", NF + for (i = 1; i <= NF; i++) { + printf("$%d = <%s>\n", i, $i) + } +} diff --git a/awklib/eg/network/PostAgent.sh b/awklib/eg/network/PostAgent.sh new file mode 100644 index 0000000..ccf9a68 --- /dev/null +++ b/awklib/eg/network/PostAgent.sh @@ -0,0 +1,9 @@ +#!/bin/sh +MobAg=/tmp/MobileAgent.$$ +# direct script to mobile agent file +cat > $MobAg +# execute agent concurrently +gawk -f $MobAg $MobAg > /dev/null & +# HTTP header, terminator and body +gawk 'BEGIN { print "\r\nAgent started" }' +rm $MobAg # delete script file of agent diff --git a/awklib/eg/network/coreserv.awk b/awklib/eg/network/coreserv.awk new file mode 100644 index 0000000..348568e --- /dev/null +++ b/awklib/eg/network/coreserv.awk @@ -0,0 +1,113 @@ +# CGI Library and core of a web server +# +# Juergen Kahrs, Juergen.Kahrs@vr-web.de +# with Arnold Robbins, arnold@gnu.org +# September 2000 + +# Global arrays +# GETARG --- arguments to CGI GET command +# MENU --- menu items (path names) +# PARAM --- parameters of form x=y + +# Optional variable MyHost contains host address +# Optional variable MyPort contains port number +# Needs TopHeader, TopDoc, TopFooter +# Sets MyPrefix, HttpService, Status, Reason + +BEGIN { + if (MyHost == "") { + "uname -n" | getline MyHost + close("uname -n") + } + if (MyPort == 0) MyPort = 8080 + HttpService = "/inet/tcp/" MyPort "/0/0" + MyPrefix = "http://" MyHost ":" MyPort + SetUpServer() + while ("awk" != "complex") { + # header lines are terminated this way + RS = ORS = "\r\n" + Status = 200 # this means OK + Reason = "OK" + Header = TopHeader + Document = TopDoc + Footer = TopFooter + if (GETARG["Method"] == "GET") { + HandleGET() + } else if (GETARG["Method"] == "HEAD") { + # not yet implemented + } else if (GETARG["Method"] != "") { + print "bad method", GETARG["Method"] + } + Prompt = Header Document Footer + print "HTTP/1.0", Status, Reason |& HttpService + print "Connection: Close" |& HttpService + print "Pragma: no-cache" |& HttpService + len = length(Prompt) + length(ORS) + print "Content-length:", len |& HttpService + print ORS Prompt |& HttpService + # ignore all the header lines + while ((HttpService |& getline) > 0) + continue + # stop talking to this client + close(HttpService) + # wait for new client request + HttpService |& getline + # do some logging + print systime(), strftime(), $0 + CGI_setup($1, $2, $3) + } +} + +function CGI_setup( method, uri, version, i) +{ + delete GETARG + delete MENU + delete PARAM + GETARG["Method"] = method + GETARG["URI"] = uri + GETARG["Version"] = version + + i = index(uri, "?") + if (i > 0) { # is there a "?" indicating a CGI request? + split(substr(uri, 1, i-1), MENU, "[/:]") + split(substr(uri, i+1), PARAM, "&") + for (i in PARAM) { + PARAM[i] = _CGI_decode(PARAM[i]) + j = index(PARAM[i], "=") + GETARG[substr(PARAM[i], 1, j-1)] = \ + substr(PARAM[i], j+1) + } + } else { # there is no "?", no need for splitting PARAMs + split(uri, MENU, "[/:]") + } + for (i in MENU) # decode characters in path + if (i > 4) # but not those in host name + MENU[i] = _CGI_decode(MENU[i]) +} +function _CGI_decode(str, hexdigs, i, pre, code1, code2, + val, result) +{ + hexdigs = "123456789abcdef" + + i = index(str, "%") + if (i == 0) # no work to do + return str + + do { + pre = substr(str, 1, i-1) # part before %xx + code1 = substr(str, i+1, 1) # first hex digit + code2 = substr(str, i+2, 1) # second hex digit + str = substr(str, i+3) # rest of string + + code1 = tolower(code1) + code2 = tolower(code2) + val = index(hexdigs, code1) * 16 \ + + index(hexdigs, code2) + + result = result pre sprintf("%c", val) + i = index(str, "%") + } while (i != 0) + if (length(str) > 0) + result = result str + return result +} diff --git a/awklib/eg/network/eliza.awk b/awklib/eg/network/eliza.awk new file mode 100644 index 0000000..15ee2c4 --- /dev/null +++ b/awklib/eg/network/eliza.awk @@ -0,0 +1,270 @@ +function SetUpServer() { + SetUpEliza() + TopHeader = \ + "An HTTP-based System with GAWK\ + \ + " + TopDoc = "\ +

Please choose one of the following actions:

\ +
" + TopFooter = "" +} +function HandleGET() { + # A real HTTP server would treat some parts of the URI as a file name. + # We take parts of the URI as menu choices and go on accordingly. + if(MENU[2] == "AboutServer") { + Document = "This is not a CGI script.\ + This is an httpd, an HTML file, and a CGI script all \ + in one GAWK script. It needs no separate www-server, \ + no installation, and no root privileges.\ +

To run it, do this:

    \ +
  • start this script with \"gawk -f httpserver.awk\",
  • \ +
  • and on the same host let your www browser open location\ + \"http://localhost:8080\"
  • \ +
\

\ Details of HTTP come from:

    \ +
  • Hethmon: Illustrated Guide to HTTP

    \ +
  • RFC 2068

JK 14.9.1997

" + } else if (MENU[2] == "AboutELIZA") { + Document = "This is an implementation of the famous ELIZA\ + program by Joseph Weizenbaum. It is written in GAWK and\ + uses an HTML GUI." + } else if (MENU[2] == "StartELIZA") { + gsub(/\+/, " ", GETARG["YouSay"]) + # Here we also have to substitute coded special characters + Document = "
" \ + "

" ElizaSays(GETARG["YouSay"]) "

\ +

\ +

" + } +} +function ElizaSays(YouSay) { + if (YouSay == "") { + cost = 0 + answer = "HI, IM ELIZA, TELL ME YOUR PROBLEM" + } else { + q = toupper(YouSay) + gsub("'", "", q) + if(q == qold) { + answer = "PLEASE DONT REPEAT YOURSELF !" + } else { + if (index(q, "SHUT UP") > 0) { + answer = "WELL, PLEASE PAY YOUR BILL. ITS EXACTLY ... $"\ + int(100*rand()+30+cost/100) + } else { + qold = q + w = "-" # no keyword recognized yet + for (i in k) { # search for keywords + if (index(q, i) > 0) { + w = i + break + } + } + if (w == "-") { # no keyword, take old subject + w = wold + subj = subjold + } else { # find subject + subj = substr(q, index(q, w) + length(w)+1) + wold = w + subjold = subj # remember keyword and subject + } + for (i in conj) + gsub(i, conj[i], q) # conjugation + # from all answers to this keyword, select one randomly + answer = r[indices[int(split(k[w], indices) * rand()) + 1]] + # insert subject into answer + gsub("_", subj, answer) + } + } + } + cost += length(answer) # for later payment : 1 cent per character + return answer +} +function SetUpEliza() { + srand() + wold = "-" + subjold = " " + + # table for conjugation + conj[" ARE " ] = " AM " + conj["WERE " ] = "WAS " + conj[" YOU " ] = " I " + conj["YOUR " ] = "MY " + conj[" IVE " ] =\ + conj[" I HAVE " ] = " YOU HAVE " + conj[" YOUVE " ] =\ + conj[" YOU HAVE "] = " I HAVE " + conj[" IM " ] =\ + conj[" I AM " ] = " YOU ARE " + conj[" YOURE " ] =\ + conj[" YOU ARE " ] = " I AM " + + # table of all answers + r[1] = "DONT YOU BELIEVE THAT I CAN _" + r[2] = "PERHAPS YOU WOULD LIKE TO BE ABLE TO _ ?" + r[3] = "YOU WANT ME TO BE ABLE TO _ ?" + r[4] = "PERHAPS YOU DONT WANT TO _ " + r[5] = "DO YOU WANT TO BE ABLE TO _ ?" + r[6] = "WHAT MAKES YOU THINK I AM _ ?" + r[7] = "DOES IT PLEASE YOU TO BELIEVE I AM _ ?" + r[8] = "PERHAPS YOU WOULD LIKE TO BE _ ?" + r[9] = "DO YOU SOMETIMES WISH YOU WERE _ ?" + r[10] = "DONT YOU REALLY _ ?" + r[11] = "WHY DONT YOU _ ?" + r[12] = "DO YOU WISH TO BE ABLE TO _ ?" + r[13] = "DOES THAT TROUBLE YOU ?" + r[14] = "TELL ME MORE ABOUT SUCH FEELINGS" + r[15] = "DO YOU OFTEN FEEL _ ?" + r[16] = "DO YOU ENJOY FEELING _ ?" + r[17] = "DO YOU REALLY BELIEVE I DONT _ ?" + r[18] = "PERHAPS IN GOOD TIME I WILL _ " + r[19] = "DO YOU WANT ME TO _ ?" + r[20] = "DO YOU THINK YOU SHOULD BE ABLE TO _ ?" + r[21] = "WHY CANT YOU _ ?" + r[22] = "WHY ARE YOU INTERESTED IN WHETHER OR NOT I AM _ ?" + r[23] = "WOULD YOU PREFER IF I WERE NOT _ ?" + r[24] = "PERHAPS IN YOUR FANTASIES I AM _ " + r[25] = "HOW DO YOU KNOW YOU CANT _ ?" + r[26] = "HAVE YOU TRIED ?" + r[27] = "PERHAPS YOU CAN NOW _ " + r[28] = "DID YOU COME TO ME BECAUSE YOU ARE _ ?" + r[29] = "HOW LONG HAVE YOU BEEN _ ?" + r[30] = "DO YOU BELIEVE ITS NORMAL TO BE _ ?" + r[31] = "DO YOU ENJOY BEING _ ?" + r[32] = "WE WERE DISCUSSING YOU -- NOT ME" + r[33] = "Oh, I _" + r[34] = "YOU'RE NOT REALLY TALKING ABOUT ME, ARE YOU ?" + r[35] = "WHAT WOULD IT MEAN TO YOU, IF YOU GOT _ ?" + r[36] = "WHY DO YOU WANT _ ?" + r[37] = "SUPPOSE YOU SOON GOT _" + r[38] = "WHAT IF YOU NEVER GOT _ ?" + r[39] = "I SOMETIMES ALSO WANT _" + r[40] = "WHY DO YOU ASK ?" + r[41] = "DOES THAT QUESTION INTEREST YOU ?" + r[42] = "WHAT ANSWER WOULD PLEASE YOU THE MOST ?" + r[43] = "WHAT DO YOU THINK ?" + r[44] = "ARE SUCH QUESTIONS IN YOUR MIND OFTEN ?" + r[45] = "WHAT IS IT THAT YOU REALLY WANT TO KNOW ?" + r[46] = "HAVE YOU ASKED ANYONE ELSE ?" + r[47] = "HAVE YOU ASKED SUCH QUESTIONS BEFORE ?" + r[48] = "WHAT ELSE COMES TO MIND WHEN YOU ASK THAT ?" + r[49] = "NAMES DON'T INTEREST ME" + r[50] = "I DONT CARE ABOUT NAMES -- PLEASE GO ON" + r[51] = "IS THAT THE REAL REASON ?" + r[52] = "DONT ANY OTHER REASONS COME TO MIND ?" + r[53] = "DOES THAT REASON EXPLAIN ANYTHING ELSE ?" + r[54] = "WHAT OTHER REASONS MIGHT THERE BE ?" + r[55] = "PLEASE DON'T APOLOGIZE !" + r[56] = "APOLOGIES ARE NOT NECESSARY" + r[57] = "WHAT FEELINGS DO YOU HAVE WHEN YOU APOLOGIZE ?" + r[58] = "DON'T BE SO DEFENSIVE" + r[59] = "WHAT DOES THAT DREAM SUGGEST TO YOU ?" + r[60] = "DO YOU DREAM OFTEN ?" + r[61] = "WHAT PERSONS APPEAR IN YOUR DREAMS ?" + r[62] = "ARE YOU DISTURBED BY YOUR DREAMS ?" + r[63] = "HOW DO YOU DO ... PLEASE STATE YOUR PROBLEM" + r[64] = "YOU DON'T SEEM QUITE CERTAIN" + r[65] = "WHY THE UNCERTAIN TONE ?" + r[66] = "CAN'T YOU BE MORE POSITIVE ?" + r[67] = "YOU AREN'T SURE ?" + r[68] = "DON'T YOU KNOW ?" + r[69] = "WHY NO _ ?" + r[70] = "DON'T SAY NO, IT'S ALWAYS SO NEGATIVE" + r[71] = "WHY NOT ?" + r[72] = "ARE YOU SURE ?" + r[73] = "WHY NO ?" + r[74] = "WHY ARE YOU CONCERNED ABOUT MY _ ?" + r[75] = "WHAT ABOUT YOUR OWN _ ?" + r[76] = "CAN'T YOU THINK ABOUT A SPECIFIC EXAMPLE ?" + r[77] = "WHEN ?" + r[78] = "WHAT ARE YOU THINKING OF ?" + r[79] = "REALLY, ALWAYS ?" + r[80] = "DO YOU REALLY THINK SO ?" + r[81] = "BUT YOU ARE NOT SURE YOU _ " + r[82] = "DO YOU DOUBT YOU _ ?" + r[83] = "IN WHAT WAY ?" + r[84] = "WHAT RESEMBLANCE DO YOU SEE ?" + r[85] = "WHAT DOES THE SIMILARITY SUGGEST TO YOU ?" + r[86] = "WHAT OTHER CONNECTION DO YOU SEE ?" + r[87] = "COULD THERE REALLY BE SOME CONNECTIONS ?" + r[88] = "HOW ?" + r[89] = "YOU SEEM QUITE POSITIVE" + r[90] = "ARE YOU SURE ?" + r[91] = "I SEE" + r[92] = "I UNDERSTAND" + r[93] = "WHY DO YOU BRING UP THE TOPIC OF FRIENDS ?" + r[94] = "DO YOUR FRIENDS WORRY YOU ?" + r[95] = "DO YOUR FRIENDS PICK ON YOU ?" + r[96] = "ARE YOU SURE YOU HAVE ANY FRIENDS ?" + r[97] = "DO YOU IMPOSE ON YOUR FRIENDS ?" + r[98] = "PERHAPS YOUR LOVE FOR FRIENDS WORRIES YOU" + r[99] = "DO COMPUTERS WORRY YOU ?" + r[100] = "ARE YOU TALKING ABOUT ME IN PARTICULAR ?" + r[101] = "ARE YOU FRIGHTENED BY MACHINES ?" + r[102] = "WHY DO YOU MENTION COMPUTERS ?" + r[103] = "WHAT DO YOU THINK MACHINES HAVE TO DO WITH YOUR PROBLEMS ?" + r[104] = "DON'T YOU THINK COMPUTERS CAN HELP PEOPLE ?" + r[105] = "WHAT IS IT ABOUT MACHINES THAT WORRIES YOU ?" + r[106] = "SAY, DO YOU HAVE ANY PSYCHOLOGICAL PROBLEMS ?" + r[107] = "WHAT DOES THAT SUGGEST TO YOU ?" + r[108] = "I SEE" + r[109] = "IM NOT SURE I UNDERSTAND YOU FULLY" + r[110] = "COME COME ELUCIDATE YOUR THOUGHTS" + r[111] = "CAN YOU ELABORATE ON THAT ?" + r[112] = "THAT IS QUITE INTERESTING" + r[113] = "WHY DO YOU HAVE PROBLEMS WITH MONEY ?" + r[114] = "DO YOU THINK MONEY IS EVERYTHING ?" + r[115] = "ARE YOU SURE THAT MONEY IS THE PROBLEM ?" + r[116] = "I THINK WE WANT TO TALK ABOUT YOU, NOT ABOUT ME" + r[117] = "WHAT'S ABOUT ME ?" + r[118] = "WHY DO YOU ALWAYS BRING UP MY NAME ?" + # table for looking up answers that + # fit to a certain keyword + k["CAN YOU"] = "1 2 3" + k["CAN I"] = "4 5" + k["YOU ARE"] =\ + k["YOURE"] = "6 7 8 9" + k["I DONT"] = "10 11 12 13" + k["I FEEL"] = "14 15 16" + k["WHY DONT YOU"] = "17 18 19" + k["WHY CANT I"] = "20 21" + k["ARE YOU"] = "22 23 24" + k["I CANT"] = "25 26 27" + k["I AM"] =\ + k["IM "] = "28 29 30 31" + k["YOU "] = "32 33 34" + k["I WANT"] = "35 36 37 38 39" + k["WHAT"] =\ + k["HOW"] =\ + k["WHO"] =\ + k["WHERE"] =\ + k["WHEN"] =\ + k["WHY"] = "40 41 42 43 44 45 46 47 48" + k["NAME"] = "49 50" + k["CAUSE"] = "51 52 53 54" + k["SORRY"] = "55 56 57 58" + k["DREAM"] = "59 60 61 62" + k["HELLO"] =\ + k["HI "] = "63" + k["MAYBE"] = "64 65 66 67 68" + k[" NO "] = "69 70 71 72 73" + k["YOUR"] = "74 75" + k["ALWAYS"] = "76 77 78 79" + k["THINK"] = "80 81 82" + k["LIKE"] = "83 84 85 86 87 88 89" + k["YES"] = "90 91 92" + k["FRIEND"] = "93 94 95 96 97 98" + k["COMPUTER"] = "99 100 101 102 103 104 105" + k["-"] = "106 107 108 109 110 111 112" + k["MONEY"] = "113 114 115" + k["ELIZA"] = "116 117 118" +} diff --git a/awklib/eg/network/fingerclient.awk b/awklib/eg/network/fingerclient.awk new file mode 100644 index 0000000..bcc2c94 --- /dev/null +++ b/awklib/eg/network/fingerclient.awk @@ -0,0 +1,7 @@ +BEGIN { + NetService = "/inet/tcp/0/localhost/finger" + print "var{name}" |& NetService + while ((NetService |& getline) > 0) + print $0 + close(NetService) +} diff --git a/awklib/eg/network/geturl.awk b/awklib/eg/network/geturl.awk new file mode 100644 index 0000000..53853e5 --- /dev/null +++ b/awklib/eg/network/geturl.awk @@ -0,0 +1,24 @@ +BEGIN { + if (ARGC != 2) { + print "GETURL - retrieve Web page via HTTP 1.0" + print "IN:\n the URL as a command-line parameter" + print "PARAM(S):\n -v Proxy=MyProxy" + print "OUT:\n the page content on stdout" + print " the page header on stderr" + print "JK 16.05.1997" + print "ADR 13.08.2000" + exit + } + URL = ARGV[1]; ARGV[1] = "" + if (Proxy == "") Proxy = "127.0.0.1" + if (ProxyPort == 0) ProxyPort = 80 + if (Method == "") Method = "GET" + HttpService = "/inet/tcp/0/" Proxy "/" ProxyPort + ORS = RS = "\r\n\r\n" + print Method " " URL " HTTP/1.0" |& HttpService + HttpService |& getline Header + print Header > "/dev/stderr" + while ((HttpService |& getline) > 0) + printf "%s", $0 + close(HttpService) +} diff --git a/awklib/eg/network/hello-serv.awk b/awklib/eg/network/hello-serv.awk new file mode 100644 index 0000000..003ee08 --- /dev/null +++ b/awklib/eg/network/hello-serv.awk @@ -0,0 +1,14 @@ +BEGIN { + RS = ORS = "\r\n" + HttpService = "/inet/tcp/8080/0/0" + Hello = "" \ + "A Famous Greeting" \ + "

Hello, world

" + Len = length(Hello) + length(ORS) + print "HTTP/1.0 200 OK" |& HttpService + print "Content-Length: " Len ORS |& HttpService + print Hello |& HttpService + while ((HttpService |& getline) > 0) + continue; + close(HttpService) +} diff --git a/awklib/eg/network/maze.awk b/awklib/eg/network/maze.awk new file mode 100644 index 0000000..97c535f --- /dev/null +++ b/awklib/eg/network/maze.awk @@ -0,0 +1,73 @@ +function SetUpServer() { + TopHeader = "Walk through a maze" + TopDoc = "\ +

Please choose one of the following actions:

\ + " + TopFooter = "" + srand() +} +function HandleGET() { + if (MENU[2] == "AboutServer") { + Document = "If your browser has a VRML 2 plugin,\ + this server shows you a simple VRML scene." + } else if (MENU[2] == "VRMLtest") { + XSIZE = YSIZE = 11 # initially, everything is wall + for (y = 0; y < YSIZE; y++) + for (x = 0; x < XSIZE; x++) + Maze[x, y] = "#" + delete Maze[0, 1] # entry is not wall + delete Maze[XSIZE-1, YSIZE-2] # exit is not wall + MakeMaze(1, 1) + Document = "\ +#VRML V2.0 utf8\n\ +Group {\n\ + children [\n\ + PointLight {\n\ + ambientIntensity 0.2\n\ + color 0.7 0.7 0.7\n\ + location 0.0 8.0 10.0\n\ + }\n\ + DEF B1 Background {\n\ + skyColor [0 0 0, 1.0 1.0 1.0 ]\n\ + skyAngle 1.6\n\ + groundColor [1 1 1, 0.8 0.8 0.8, 0.2 0.2 0.2 ]\n\ + groundAngle [ 1.2 1.57 ]\n\ + }\n\ + DEF Wall Shape {\n\ + geometry Box {size 1 1 1}\n\ + appearance Appearance { material Material { diffuseColor 0 0 1 } }\n\ + }\n\ + DEF Entry Viewpoint {\n\ + position 0.5 1.0 5.0\n\ + orientation 0.0 0.0 -1.0 0.52\n\ + }\n" + for (i in Maze) { + split(i, t, SUBSEP) + Document = Document " Transform { translation " + Document = Document t[1] " 0 -" t[2] " children USE Wall }\n" + } + Document = Document " ] # end of group for world\n}" + Reason = "OK" ORS "Content-type: model/vrml" + Header = Footer = "" + } +} +function MakeMaze(x, y) { + delete Maze[x, y] # here we are, we have no wall here + p = 0 # count unvisited fields in all directions + if (x-2 SUBSEP y in Maze) d[p++] = "-x" + if (x SUBSEP y-2 in Maze) d[p++] = "-y" + if (x+2 SUBSEP y in Maze) d[p++] = "+x" + if (x SUBSEP y+2 in Maze) d[p++] = "+y" + if (p>0) { # if there are unvisited fields, go there + p = int(p*rand()) # choose one unvisited field at random + if (d[p] == "-x") { delete Maze[x - 1, y]; MakeMaze(x - 2, y) + } else if (d[p] == "-y") { delete Maze[x, y - 1]; MakeMaze(x, y - 2) + } else if (d[p] == "+x") { delete Maze[x + 1, y]; MakeMaze(x + 2, y) + } else if (d[p] == "+y") { delete Maze[x, y + 1]; MakeMaze(x, y + 2) + } # we are back from recursion + MakeMaze(x, y); # try again while there are unvisited fields + } +} diff --git a/awklib/eg/network/mobag.awk b/awklib/eg/network/mobag.awk new file mode 100644 index 0000000..a8c5500 --- /dev/null +++ b/awklib/eg/network/mobag.awk @@ -0,0 +1,72 @@ +BEGIN { + if (ARGC != 2) { + print "MOBAG - a simple mobile agent" + print "CALL:\n gawk -f mobag.awk mobag.awk" + print "IN:\n the name of this script as a command-line parameter" + print "PARAM:\n -v MyOrigin=myhost.com" + print "OUT:\n the result on stdout" + print "JK 29.03.1998 01.04.1998" + exit + } + if (MyOrigin == "") { + "uname -n" | getline MyOrigin + close("uname -n") + } +} +#ReadMySelf +/^function / { FUNC = $2 } +/^END/ || /^#ReadMySelf/ { FUNC = $1 } +FUNC != "" { MOBFUN[FUNC] = MOBFUN[FUNC] RS $0 } +(FUNC != "") && (/^}/ || /^#EndOfMySelf/) \ + { FUNC = "" } +#EndOfMySelf +function migrate(Destination, MobCode, Label) { + MOBVAR["Label"] = Label + MOBVAR["Destination"] = Destination + RS = ORS = "\r\n" + HttpService = "/inet/tcp/0/" Destination + for (i in MOBFUN) + MobCode = (MobCode "\n" MOBFUN[i]) + MobCode = MobCode "\n\nBEGIN {" + for (i in MOBVAR) + MobCode = (MobCode "\n MOBVAR[\"" i "\"] = \"" MOBVAR[i] "\"") + MobCode = MobCode "\n}\n" + print "POST /cgi-bin/PostAgent.sh HTTP/1.0" |& HttpService + print "Content-length:", length(MobCode) ORS |& HttpService + printf "%s", MobCode |& HttpService + while ((HttpService |& getline) > 0) + print $0 + close(HttpService) +} +END { + if (ARGC != 2) exit # stop when called with wrong parameters + if (MyOrigin != "") # is this the originating host? + MyInit() # if so, initialize the application + else # we are on a host with migrated data + MyJob() # so we do our job +} +function MyInit() { + MOBVAR["MyOrigin"] = MyOrigin + MOBVAR["Machines"] = "localhost/80 max/80 moritz/80 castor/80" + split(MOBVAR["Machines"], Machines) # which host is the first? + migrate(Machines[1], "", "") # go to the first host + while (("/inet/tcp/8080/0/0" |& getline) > 0) # wait for result + print $0 # print result + close("/inet/tcp/8080/0/0") +} +function MyJob() { + # forget this host + sub(MOBVAR["Destination"], "", MOBVAR["Machines"]) + MOBVAR["Result"]=MOBVAR["Result"] SUBSEP SUBSEP MOBVAR["Destination"] ":" + while (("who" | getline) > 0) # who is logged in? + MOBVAR["Result"] = MOBVAR["Result"] SUBSEP $0 + close("who") + if (index(MOBVAR["Machines"], "/") > 0) { # any more machines to visit? + split(MOBVAR["Machines"], Machines) # which host is next? + migrate(Machines[1], "", "") # go there + } else { # no more machines + gsub(SUBSEP, "\n", MOBVAR["Result"]) # send result to origin + print MOBVAR["Result"] |& "/inet/tcp/0/" MOBVAR["MyOrigin"] "/8080" + close("/inet/tcp/0/" MOBVAR["MyOrigin"] "/8080") + } +} diff --git a/awklib/eg/network/panic.awk b/awklib/eg/network/panic.awk new file mode 100644 index 0000000..6db8c46 --- /dev/null +++ b/awklib/eg/network/panic.awk @@ -0,0 +1,18 @@ +BEGIN { + RS = ORS = "\r\n" + if (MyPort == 0) MyPort = 8080 + HttpService = "/inet/tcp/" MyPort "/0/0" + Hello = "Out Of Service" \ + "

" \ + "This site is temporarily out of service." \ + "

" + Len = length(Hello) + length(ORS) + while ("awk" != "complex") { + print "HTTP/1.0 200 OK" |& HttpService + print "Content-Length: " Len ORS |& HttpService + print Hello |& HttpService + while ((HttpService |& getline) > 0) + continue; + close(HttpService) + } +} diff --git a/awklib/eg/network/protbase.awk b/awklib/eg/network/protbase.awk new file mode 100644 index 0000000..f4a911c --- /dev/null +++ b/awklib/eg/network/protbase.awk @@ -0,0 +1,11 @@ +{ request = request "\n" $0 } + +END { + BLASTService = "/inet/tcp/0/www.ncbi.nlm.nih.gov/80" + printf "POST /cgi-bin/BLAST/nph-blast_report HTTP/1.0\n" |& BLASTService + printf "Content-Length: " length(request) "\n\n" |& BLASTService + printf request |& BLASTService + while ((BLASTService |& getline) > 0) + print $0 + close(BLASTService) +} diff --git a/awklib/eg/network/protbase.request b/awklib/eg/network/protbase.request new file mode 100644 index 0000000..4c5c3d2 --- /dev/null +++ b/awklib/eg/network/protbase.request @@ -0,0 +1,7 @@ +PROGRAM blastn +DATALIB month +EXPECT 0.75 +BEGIN +>GAWK310 the gawking gene GNU AWK +tgcttggctgaggagccataggacgagagcttcctggtgaagtgtgtttcttgaaatcat +caccaccatggacagcaaa diff --git a/awklib/eg/network/protbase.result b/awklib/eg/network/protbase.result new file mode 100644 index 0000000..a087af4 --- /dev/null +++ b/awklib/eg/network/protbase.result @@ -0,0 +1,9 @@ +Sequences producing significant alignments: (bits) Value + +gb|AC021182.14|AC021182 Homo sapiens chromosome 7 clone RP11-733... 38 0.20 +gb|AC021056.12|AC021056 Homo sapiens chromosome 3 clone RP11-115... 38 0.20 +emb|AL160278.10|AL160278 Homo sapiens chromosome 9 clone RP11-57... 38 0.20 +emb|AL391139.11|AL391139 Homo sapiens chromosome X clone RP11-35... 38 0.20 +emb|AL365192.6|AL365192 Homo sapiens chromosome 6 clone RP3-421H... 38 0.20 +emb|AL138812.9|AL138812 Homo sapiens chromosome 11 clone RP1-276... 38 0.20 +gb|AC073881.3|AC073881 Homo sapiens chromosome 15 clone CTD-2169... 38 0.20 diff --git a/awklib/eg/network/remconf.awk b/awklib/eg/network/remconf.awk new file mode 100644 index 0000000..ef92226 --- /dev/null +++ b/awklib/eg/network/remconf.awk @@ -0,0 +1,54 @@ +function SetUpServer() { + TopHeader = "Remote Configuration" + TopDoc = "\ +

Please choose one of the following actions:

\ + " + TopFooter = "" + if (ConfigFile == "") ConfigFile = "config.asc" +} +function HandleGET() { + if(MENU[2] == "AboutServer") { + Document = "This is a GUI for remote configuration of an\ + embedded system. It is is implemented as one GAWK script." + } else if (MENU[2] == "ReadConfig") { + RS = "\n" + while ((getline < ConfigFile) > 0) + config[$1] = $2; + close(ConfigFile) + RS = "\r\n" + Document = "Configuration has been read." + } else if (MENU[2] == "CheckConfig") { + Document = "" + for (i in config) + Document = Document "" \ + "" + Document = Document "
" i "" config[i] "
" + } else if (MENU[2] == "ChangeConfig") { + if ("Param" in GETARG) { # any parameter to set? + if (GETARG["Param"] in config) { # is parameter valid? + config[GETARG["Param"]] = GETARG["Value"] + Document = (GETARG["Param"] " = " GETARG["Value"] ".") + } else { + Document = "Parameter " GETARG["Param"] " is invalid." + } + } else { + Document = "

Change one parameter

\ + \ + \ + \ + \ +
ParameterValue
" + } + } else if (MENU[2] == "SaveConfig") { + for (i in config) + printf("%s %s\n", i, config[i]) > ConfigFile + close(ConfigFile) + Document = "Configuration has been saved." + } +} diff --git a/awklib/eg/network/statist.awk b/awklib/eg/network/statist.awk new file mode 100644 index 0000000..a4fc55c --- /dev/null +++ b/awklib/eg/network/statist.awk @@ -0,0 +1,85 @@ +function SetUpServer() { + TopHeader = "Statistics with GAWK" + TopDoc = "\ +

Please choose one of the following actions:

\ + " + TopFooter = "" + GnuPlot = "gnuplot 2>&1" + m1=m2=0; v1=v2=1; n1=n2=10 +} +function HandleGET() { + if(MENU[2] == "AboutServer") { + Document = "This is a GUI for a statistical computation.\ + It compares means and variances of two distributions.\ + It is implemented as one GAWK script and uses GNUPLOT." + } else if (MENU[2] == "EnterParameters") { + Document = "" + if ("m1" in GETARG) { # are there parameters to compare? + Document = Document "" + m1 = GETARG["m1"]; v1 = GETARG["v1"]; n1 = GETARG["n1"] + m2 = GETARG["m2"]; v2 = GETARG["v2"]; n2 = GETARG["n2"] + t = (m1-m2)/sqrt(v1/n1+v2/n2) + df = (v1/n1+v2/n2)*(v1/n1+v2/n2)/((v1/n1)*(v1/n1)/(n1-1) \ + + (v2/n2)*(v2/n2) /(n2-1)) + if (v1>v2) { + f = v1/v2 + df1 = n1 - 1 + df2 = n2 - 1 + } else { + f = v2/v1 + df1 = n2 - 1 + df2 = n1 - 1 + } + print "pt=ibeta(" df/2 ",0.5," df/(df+t*t) ")" |& GnuPlot + print "pF=2.0*ibeta(" df2/2 "," df1/2 "," \ + df2/(df2+df1*f) ")" |& GnuPlot + print "print pt, pF" |& GnuPlot + RS="\n"; GnuPlot |& getline; RS="\r\n" # $1 is pt, $2 is pF + print "invsqrt2pi=1.0/sqrt(2.0*pi)" |& GnuPlot + print "nd(x)=invsqrt2pi/sd*exp(-0.5*((x-mu)/sd)**2)" |& GnuPlot + print "set term png small color" |& GnuPlot + #print "set term postscript color" |& GnuPlot + #print "set term gif medium size 320,240" |& GnuPlot + print "set yrange[-0.3:]" |& GnuPlot + print "set label 'p(m1=m2) =" $1 "' at 0,-0.1 left" |& GnuPlot + print "set label 'p(v1=v2) =" $2 "' at 0,-0.2 left" |& GnuPlot + print "plot mu=" m1 ",sd=" sqrt(v1) ", nd(x) title 'sample 1',\ + mu=" m2 ",sd=" sqrt(v2) ", nd(x) title 'sample 2'" |& GnuPlot + print "quit" |& GnuPlot + GnuPlot |& getline Image + while ((GnuPlot |& getline) > 0) + Image = Image RS $0 + close(GnuPlot) + } + Document = Document "\ +

Do these samples have the same Gaussian distribution?

\ +
\ + \ + + \ + + \ + + \ + \ + + \ + + \ + + \ + \ +
1. Mean 1. Variance1. Count
2. Mean 2. Variance2. Count

" + } else if (MENU[2] ~ "Image") { + Reason = "OK" ORS "Content-type: image/png" + #Reason = "OK" ORS "Content-type: application/x-postscript" + #Reason = "OK" ORS "Content-type: image/gif" + Header = Footer = "" + Document = Image + } +} diff --git a/awklib/eg/network/stoxdata.txt b/awklib/eg/network/stoxdata.txt new file mode 100644 index 0000000..1b6d015 --- /dev/null +++ b/awklib/eg/network/stoxdata.txt @@ -0,0 +1,4 @@ +Date,Open,High,Low,Close,Volume +9-Oct-00,22.75,22.75,21.375,22.375,7888500 +6-Oct-00,23.8125,24.9375,21.5625,22,10701100 +5-Oct-00,24.4375,24.625,23.125,23.50,5810300 diff --git a/awklib/eg/network/stoxpred.awk b/awklib/eg/network/stoxpred.awk new file mode 100644 index 0000000..62744c1 --- /dev/null +++ b/awklib/eg/network/stoxpred.awk @@ -0,0 +1,116 @@ +function ReadQuotes() { + # Retrieve historical data for each ticker symbol + FS = "," + for (stock = 1; stock <= StockCount; stock++) { + URL = "http://chart.yahoo.com/table.csv?s=" name[stock] \ + "&a=" month "&b=" day "&c=" year-1 \ + "&d=" month "&e=" day "&f=" year \ + "g=d&q=q&y=0&z=" name[stock] "&x=.csv" + printf("GET " URL " HTTP/1.0\r\n\r\n") |& YahooData + while ((YahooData |& getline) > 0) { + if (NF == 6 && $1 ~ /Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec/) { + if (stock == 1) + days[++daycount] = $1; + quote[$1, stock] = $5 + } + } + close(YahooData) + } + FS = " " +} +function CleanUp() { + # clean up time series; eliminate incomplete data sets + for (d = 1; d <= daycount; d++) { + for (stock = 1; stock <= StockCount; stock++) + if (! ((days[d], stock) in quote)) + stock = StockCount + 10 + if (stock > StockCount + 1) + continue + datacount++ + for (stock = 1; stock <= StockCount; stock++) + data[datacount, stock] = int(0.5 + quote[days[d], stock]) + } + delete quote + delete days +} +function Prediction() { + # Predict each ticker symbol by prolonging yesterday's trend + for (stock = 1; stock <= StockCount; stock++) { + if (data[1, stock] > data[2, stock]) { + predict[stock] = "up" + } else if (data[1, stock] < data[2, stock]) { + predict[stock] = "down" + } else { + predict[stock] = "neutral" + } + if ((data[1, stock] > data[2, stock]) && (data[2, stock] > data[3, stock])) + hot[stock] = 1 + if ((data[1, stock] < data[2, stock]) && (data[2, stock] < data[3, stock])) + avoid[stock] = 1 + } + # Do a plausibility check: how many predictions proved correct? + for (s = 1; s <= StockCount; s++) { + for (d = 1; d <= datacount-2; d++) { + if (data[d+1, s] > data[d+2, s]) { + UpCount++ + } else if (data[d+1, s] < data[d+2, s]) { + DownCount++ + } else { + NeutralCount++ + } + if (((data[d, s] > data[d+1, s]) && (data[d+1, s] > data[d+2, s])) || + ((data[d, s] < data[d+1, s]) && (data[d+1, s] < data[d+2, s])) || + ((data[d, s] == data[d+1, s]) && (data[d+1, s] == data[d+2, s]))) + CorrectCount++ + } + } +} +function Report() { + # Generate report + report = "\nThis is your daily " + report = report "stock market report for "strftime("%A, %B %d, %Y")".\n" + report = report "Here are the predictions for today:\n\n" + for (stock = 1; stock <= StockCount; stock++) + report = report "\t" name[stock] "\t" predict[stock] "\n" + for (stock in hot) { + if (HotCount++ == 0) + report = report "\nThe most promising shares for today are these:\n\n" + report = report "\t" name[stock] "\t\thttp://biz.yahoo.com/n/" \ + tolower(substr(name[stock], 1, 1)) "/" tolower(name[stock]) ".html\n" + } + for (stock in avoid) { + if (AvoidCount++ == 0) + report = report "\nThe stock shares to avoid today are these:\n\n" + report = report "\t" name[stock] "\t\thttp://biz.yahoo.com/n/" \ + tolower(substr(name[stock], 1, 1)) "/" tolower(name[stock]) ".html\n" + } + report = report "\nThis sums up to " HotCount+0 " winners and " AvoidCount+0 + report = report " losers. When using this kind\nof prediction scheme for" + report = report " the 12 months which lie behind us,\nwe get " UpCount + report = report " 'ups' and " DownCount " 'downs' and " NeutralCount + report = report " 'neutrals'. Of all\nthese " UpCount+DownCount+NeutralCount + report = report " predictions " CorrectCount " proved correct next day.\n" + report = report "A success rate of "\ + int(100*CorrectCount/(UpCount+DownCount+NeutralCount)) "%.\n" + report = report "Random choice would have produced a 33% success rate.\n" + report = report "Disclaimer: Like every other prediction of the stock\n" + report = report "market, this report is, of course, complete nonsense.\n" + report = report "If you are stupid enough to believe these predictions\n" + report = report "you should visit a doctor who can treat your ailment." +} +function SendMail() { + # send report to customers + customer["uncle.scrooge@ducktown.gov"] = "Uncle Scrooge" + customer["more@utopia.org" ] = "Sir Thomas More" + customer["spinoza@denhaag.nl" ] = "Baruch de Spinoza" + customer["marx@highgate.uk" ] = "Karl Marx" + customer["keynes@the.long.run" ] = "John Maynard Keynes" + customer["bierce@devil.hell.org" ] = "Ambrose Bierce" + customer["laplace@paris.fr" ] = "Pierre Simon de Laplace" + for (c in customer) { + MailPipe = "mail -s 'Daily Stock Prediction Newsletter'" c + print "Good morning " customer[c] "," | MailPipe + print report "\n.\n" | MailPipe + close(MailPipe) + } +} diff --git a/awklib/eg/network/testserv.awk b/awklib/eg/network/testserv.awk new file mode 100644 index 0000000..812bfe6 --- /dev/null +++ b/awklib/eg/network/testserv.awk @@ -0,0 +1,12 @@ +BEGIN { + CGI_setup("GET", + "http://www.gnu.org/cgi-bin/foo?p1=stuff&p2=stuff%26junk" \ + "&percent=a %25 sign", + "1.0") + for (i in MENU) + printf "MENU[\"%s\"] = %s\n", i, MENU[i] + for (i in PARAM) + printf "PARAM[\"%s\"] = %s\n", i, PARAM[i] + for (i in GETARG) + printf "GETARG[\"%s\"] = %s\n", i, GETARG[i] +} diff --git a/awklib/eg/network/urlchk.awk b/awklib/eg/network/urlchk.awk new file mode 100644 index 0000000..6ddedfa --- /dev/null +++ b/awklib/eg/network/urlchk.awk @@ -0,0 +1,28 @@ +BEGIN { + if (ARGC != 2) { + print "URLCHK - check if URLs have changed" + print "IN:\n the file with URLs as a command-line parameter" + print " file contains URL, old length, new length" + print "PARAMS:\n -v Proxy=MyProxy -v ProxyPort=8080" + print "OUT:\n same as file with URLs" + print "JK 02.03.1998" + exit + } + URLfile = ARGV[1]; ARGV[1] = "" + if (Proxy != "") Proxy = " -v Proxy=" Proxy + if (ProxyPort != "") ProxyPort = " -v ProxyPort=" ProxyPort + while ((getline < URLfile) > 0) + Length[$1] = $3 + 0 + close(URLfile) # now, URLfile is read in and can be updated + GetHeader = "gawk " Proxy ProxyPort " -v Method=\"HEAD\" -f geturl.awk " + for (i in Length) { + GetThisHeader = GetHeader i " 2>&1" + while ((GetThisHeader | getline) > 0) + if (toupper($0) ~ /CONTENT-LENGTH/) NewLength = $2 + 0 + close(GetThisHeader) + print i, Length[i], NewLength > URLfile + if (Length[i] != NewLength) # report only changed URLs + print i, Length[i], NewLength + } + close(URLfile) +} diff --git a/awklib/eg/network/webgrab.awk b/awklib/eg/network/webgrab.awk new file mode 100644 index 0000000..4173880 --- /dev/null +++ b/awklib/eg/network/webgrab.awk @@ -0,0 +1,6 @@ +BEGIN { RS = "http://[#%&\\+\\-\\./0-9\\:;\\?A-Z_a-z\\~]*" } +RT != "" { + command = ("gawk -v Proxy=MyProxy -f geturl.awk " RT \ + " > doc" NR ".html") + print command +} diff --git a/awklib/eg/prog/alarm.awk b/awklib/eg/prog/alarm.awk new file mode 100644 index 0000000..53563d1 --- /dev/null +++ b/awklib/eg/prog/alarm.awk @@ -0,0 +1,91 @@ +# alarm.awk --- set an alarm +# +# Requires gettimeofday() library function +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# May 1993 +# Revised December 2010 + +# usage: alarm time [ "message" [ count [ delay ] ] ] + +BEGIN \ +{ + # Initial argument sanity checking + usage1 = "usage: alarm time ['message' [count [delay]]]" + usage2 = sprintf("\t(%s) time ::= hh:mm", ARGV[1]) + + if (ARGC < 2) { + print usage1 > "/dev/stderr" + print usage2 > "/dev/stderr" + exit 1 + } + switch (ARGC) { + case 5: + delay = ARGV[4] + 0 + # fall through + case 4: + count = ARGV[3] + 0 + # fall through + case 3: + message = ARGV[2] + break + default: + if (ARGV[1] !~ /[[:digit:]]?[[:digit:]]:[[:digit:]]{2}/) { + print usage1 > "/dev/stderr" + print usage2 > "/dev/stderr" + exit 1 + } + break + } + + # set defaults for once we reach the desired time + if (delay == 0) + delay = 180 # 3 minutes + if (count == 0) + count = 5 + if (message == "") + message = sprintf("\aIt is now %s!\a", ARGV[1]) + else if (index(message, "\a") == 0) + message = "\a" message "\a" + # split up alarm time + split(ARGV[1], atime, ":") + hour = atime[1] + 0 # force numeric + minute = atime[2] + 0 # force numeric + + # get current broken down time + gettimeofday(now) + + # if time given is 12-hour hours and it's after that + # hour, e.g., `alarm 5:30' at 9 a.m. means 5:30 p.m., + # then add 12 to real hour + if (hour < 12 && now["hour"] > hour) + hour += 12 + + # set target time in seconds since midnight + target = (hour * 60 * 60) + (minute * 60) + + # get current time in seconds since midnight + current = (now["hour"] * 60 * 60) + \ + (now["minute"] * 60) + now["second"] + + # how long to sleep for + naptime = target - current + if (naptime <= 0) { + print "time is in the past!" > "/dev/stderr" + exit 1 + } + # zzzzzz..... go away if interrupted + if (system(sprintf("sleep %d", naptime)) != 0) + exit 1 + + # time to notify! + command = sprintf("sleep %d", delay) + for (i = 1; i <= count; i++) { + print message + # if sleep command interrupted, go away + if (system(command) != 0) + break + } + + exit 0 +} diff --git a/awklib/eg/prog/anagram.awk b/awklib/eg/prog/anagram.awk new file mode 100644 index 0000000..7ca1455 --- /dev/null +++ b/awklib/eg/prog/anagram.awk @@ -0,0 +1,50 @@ +# anagram.awk --- An implementation of the anagram finding algorithm +# from Jon Bentley's "Programming Pearls", 2nd edition. +# Addison Wesley, 2000, ISBN 0-201-65788-0. +# Column 2, Problem C, section 2.8, pp 18-20. +# +# This program requires gawk 4.0 or newer. +# Required gawk-specific features: +# - True multidimensional arrays +# - split() with "" as separator splits out individual characters +# - asort() and asorti() functions +# +# See http://savannah.gnu.org/projects/gawk. +# +# Arnold Robbins +# arnold@skeeve.com +# Public Domain +# January, 2011 + +/'s$/ { next } # Skip possessives +{ + key = word2key($1) # Build signature + data[key][$1] = $1 # Store word with signature +} +# word2key --- split word apart into letters, sort, joining back together + +function word2key(word, a, i, n, result) +{ + n = split(word, a, "") + asort(a) + + for (i = 1; i <= n; i++) + result = result a[i] + + return result +} +END { + sort = "sort" + for (key in data) { + # Sort words with same key + nwords = asorti(data[key], words) + if (nwords == 1) + continue + + # And print. Minor glitch: trailing space at end of each line + for (j = 1; j <= nwords; j++) + printf("%s ", words[j]) | sort + print "" | sort + } + close(sort) +} diff --git a/awklib/eg/prog/awksed.awk b/awklib/eg/prog/awksed.awk new file mode 100644 index 0000000..d9f1771 --- /dev/null +++ b/awklib/eg/prog/awksed.awk @@ -0,0 +1,31 @@ +# awksed.awk --- do s/foo/bar/g using just print +# Thanks to Michael Brennan for the idea +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# August 1995 + +function usage() +{ + print "usage: awksed pat repl [files...]" > "/dev/stderr" + exit 1 +} + +BEGIN { + # validate arguments + if (ARGC < 3) + usage() + + RS = ARGV[1] + ORS = ARGV[2] + + # don't use arguments as files + ARGV[1] = ARGV[2] = "" +} + +# look ma, no hands! +{ + if (RT == "") + printf "%s", $0 + else + print +} diff --git a/awklib/eg/prog/cut.awk b/awklib/eg/prog/cut.awk new file mode 100644 index 0000000..fb4717c --- /dev/null +++ b/awklib/eg/prog/cut.awk @@ -0,0 +1,140 @@ +# cut.awk --- implement cut in awk +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# May 1993 + +# Options: +# -f list Cut fields +# -d c Field delimiter character +# -c list Cut characters +# +# -s Suppress lines without the delimiter +# +# Requires getopt() and join() library functions + +function usage( e1, e2) +{ + e1 = "usage: cut [-f list] [-d c] [-s] [files...]" + e2 = "usage: cut [-c list] [files...]" + print e1 > "/dev/stderr" + print e2 > "/dev/stderr" + exit 1 +} +BEGIN \ +{ + FS = "\t" # default + OFS = FS + while ((c = getopt(ARGC, ARGV, "sf:c:d:")) != -1) { + if (c == "f") { + by_fields = 1 + fieldlist = Optarg + } else if (c == "c") { + by_chars = 1 + fieldlist = Optarg + OFS = "" + } else if (c == "d") { + if (length(Optarg) > 1) { + printf("Using first character of %s" \ + " for delimiter\n", Optarg) > "/dev/stderr" + Optarg = substr(Optarg, 1, 1) + } + FS = Optarg + OFS = FS + if (FS == " ") # defeat awk semantics + FS = "[ ]" + } else if (c == "s") + suppress++ + else + usage() + } + + # Clear out options + for (i = 1; i < Optind; i++) + ARGV[i] = "" + if (by_fields && by_chars) + usage() + + if (by_fields == 0 && by_chars == 0) + by_fields = 1 # default + + if (fieldlist == "") { + print "cut: needs list for -c or -f" > "/dev/stderr" + exit 1 + } + + if (by_fields) + set_fieldlist() + else + set_charlist() +} +function set_fieldlist( n, m, i, j, k, f, g) +{ + n = split(fieldlist, f, ",") + j = 1 # index in flist + for (i = 1; i <= n; i++) { + if (index(f[i], "-") != 0) { # a range + m = split(f[i], g, "-") + if (m != 2 || g[1] >= g[2]) { + printf("bad field list: %s\n", + f[i]) > "/dev/stderr" + exit 1 + } + for (k = g[1]; k <= g[2]; k++) + flist[j++] = k + } else + flist[j++] = f[i] + } + nfields = j - 1 +} +function set_charlist( field, i, j, f, g, t, + filler, last, len) +{ + field = 1 # count total fields + n = split(fieldlist, f, ",") + j = 1 # index in flist + for (i = 1; i <= n; i++) { + if (index(f[i], "-") != 0) { # range + m = split(f[i], g, "-") + if (m != 2 || g[1] >= g[2]) { + printf("bad character list: %s\n", + f[i]) > "/dev/stderr" + exit 1 + } + len = g[2] - g[1] + 1 + if (g[1] > 1) # compute length of filler + filler = g[1] - last - 1 + else + filler = 0 + if (filler) + t[field++] = filler + t[field++] = len # length of field + last = g[2] + flist[j++] = field - 1 + } else { + if (f[i] > 1) + filler = f[i] - last - 1 + else + filler = 0 + if (filler) + t[field++] = filler + t[field++] = 1 + last = f[i] + flist[j++] = field - 1 + } + } + FIELDWIDTHS = join(t, 1, field - 1) + nfields = j - 1 +} +{ + if (by_fields && suppress && index($0, FS) != 0) + next + + for (i = 1; i <= nfields; i++) { + if ($flist[i] != "") { + printf "%s", $flist[i] + if (i < nfields && $flist[i+1] != "") + printf "%s", OFS + } + } + print "" +} diff --git a/awklib/eg/prog/dupword.awk b/awklib/eg/prog/dupword.awk new file mode 100644 index 0000000..047b99f --- /dev/null +++ b/awklib/eg/prog/dupword.awk @@ -0,0 +1,21 @@ +# dupword.awk --- find duplicate words in text +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# December 1991 +# Revised October 2000 + +{ + $0 = tolower($0) + gsub(/[^[:alnum:][:blank:]]/, " "); + $0 = $0 # re-split + if (NF == 0) + next + if ($1 == prev) + printf("%s:%d: duplicate %s\n", + FILENAME, FNR, $1) + for (i = 2; i <= NF; i++) + if ($i == $(i-1)) + printf("%s:%d: duplicate %s\n", + FILENAME, FNR, $i) + prev = $NF +} diff --git a/awklib/eg/prog/egrep.awk b/awklib/eg/prog/egrep.awk new file mode 100644 index 0000000..56d199c --- /dev/null +++ b/awklib/eg/prog/egrep.awk @@ -0,0 +1,103 @@ +# egrep.awk --- simulate egrep in awk +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# May 1993 + +# Options: +# -c count of lines +# -s silent - use exit value +# -v invert test, success if no match +# -i ignore case +# -l print filenames only +# -e argument is pattern +# +# Requires getopt and file transition library functions + +BEGIN { + while ((c = getopt(ARGC, ARGV, "ce:svil")) != -1) { + if (c == "c") + count_only++ + else if (c == "s") + no_print++ + else if (c == "v") + invert++ + else if (c == "i") + IGNORECASE = 1 + else if (c == "l") + filenames_only++ + else if (c == "e") + pattern = Optarg + else + usage() + } + if (pattern == "") + pattern = ARGV[Optind++] + + for (i = 1; i < Optind; i++) + ARGV[i] = "" + if (Optind >= ARGC) { + ARGV[1] = "-" + ARGC = 2 + } else if (ARGC - Optind > 1) + do_filenames++ + +# if (IGNORECASE) +# pattern = tolower(pattern) +} +#{ +# if (IGNORECASE) +# $0 = tolower($0) +#} +function beginfile(junk) +{ + fcount = 0 +} +function endfile(file) +{ + if (! no_print && count_only) { + if (do_filenames) + print file ":" fcount + else + print fcount + } + + total += fcount +} +{ + matches = ($0 ~ pattern) + if (invert) + matches = ! matches + + fcount += matches # 1 or 0 + + if (! matches) + next + + if (! count_only) { + if (no_print) + nextfile + + if (filenames_only) { + print FILENAME + nextfile + } + + if (do_filenames) + print FILENAME ":" $0 + else + print + } +} +END \ +{ + if (total == 0) + exit 1 + exit 0 +} +function usage( e) +{ + e = "Usage: egrep [-csvil] [-e pat] [files ...]" + e = e "\n\tegrep [-csvil] pat [files ...]" + print e > "/dev/stderr" + exit 1 +} diff --git a/awklib/eg/prog/extract.awk b/awklib/eg/prog/extract.awk new file mode 100644 index 0000000..dc10572 --- /dev/null +++ b/awklib/eg/prog/extract.awk @@ -0,0 +1,76 @@ +# extract.awk --- extract files and run programs +# from texinfo files +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# May 1993 +# Revised September 2000 + +BEGIN { IGNORECASE = 1 } + +/^@c(omment)?[ \t]+system/ \ +{ + if (NF < 3) { + e = (FILENAME ":" FNR) + e = (e ": badly formed `system' line") + print e > "/dev/stderr" + next + } + $1 = "" + $2 = "" + stat = system($0) + if (stat != 0) { + e = (FILENAME ":" FNR) + e = (e ": warning: system returned " stat) + print e > "/dev/stderr" + } +} +/^@c(omment)?[ \t]+file/ \ +{ + if (NF != 3) { + e = (FILENAME ":" FNR ": badly formed `file' line") + print e > "/dev/stderr" + next + } + if ($3 != curfile) { + if (curfile != "") + close(curfile) + curfile = $3 + } + + for (;;) { + if ((getline line) <= 0) + unexpected_eof() + if (line ~ /^@c(omment)?[ \t]+endfile/) + break + else if (line ~ /^@(end[ \t]+)?group/) + continue + else if (line ~ /^@c(omment+)?[ \t]+/) + continue + if (index(line, "@") == 0) { + print line > curfile + continue + } + n = split(line, a, "@") + # if a[1] == "", means leading @, + # don't add one back in. + for (i = 2; i <= n; i++) { + if (a[i] == "") { # was an @@ + a[i] = "@" + if (a[i+1] == "") + i++ + } + } + print join(a, 1, n, SUBSEP) > curfile + } +} +function unexpected_eof() +{ + printf("%s:%d: unexpected EOF or error\n", + FILENAME, FNR) > "/dev/stderr" + exit 1 +} + +END { + if (curfile) + close(curfile) +} diff --git a/awklib/eg/prog/guide.awk b/awklib/eg/prog/guide.awk new file mode 100644 index 0000000..a2dea1b --- /dev/null +++ b/awklib/eg/prog/guide.awk @@ -0,0 +1,7 @@ +BEGIN { + TEXTDOMAIN = "guide" + bindtextdomain(".") # for testing + print _"Don't Panic" + print _"The Answer Is", 42 + print "Pardon me, Zaphod who?" +} diff --git a/awklib/eg/prog/histsort.awk b/awklib/eg/prog/histsort.awk new file mode 100644 index 0000000..b156f67 --- /dev/null +++ b/awklib/eg/prog/histsort.awk @@ -0,0 +1,15 @@ +# histsort.awk --- compact a shell history file +# Thanks to Byron Rakitzis for the general idea +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# May 1993 + +{ + if (data[$0]++ == 0) + lines[++count] = $0 +} + +END { + for (i = 1; i <= count; i++) + print lines[i] +} diff --git a/awklib/eg/prog/id.awk b/awklib/eg/prog/id.awk new file mode 100644 index 0000000..8b60a24 --- /dev/null +++ b/awklib/eg/prog/id.awk @@ -0,0 +1,67 @@ +# id.awk --- implement id in awk +# +# Requires user and group library functions +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# May 1993 +# Revised February 1996 + +# output is: +# uid=12(foo) euid=34(bar) gid=3(baz) \ +# egid=5(blat) groups=9(nine),2(two),1(one) + +BEGIN \ +{ + uid = PROCINFO["uid"] + euid = PROCINFO["euid"] + gid = PROCINFO["gid"] + egid = PROCINFO["egid"] + + printf("uid=%d", uid) + pw = getpwuid(uid) + if (pw != "") { + split(pw, a, ":") + printf("(%s)", a[1]) + } + + if (euid != uid) { + printf(" euid=%d", euid) + pw = getpwuid(euid) + if (pw != "") { + split(pw, a, ":") + printf("(%s)", a[1]) + } + } + + printf(" gid=%d", gid) + pw = getgrgid(gid) + if (pw != "") { + split(pw, a, ":") + printf("(%s)", a[1]) + } + + if (egid != gid) { + printf(" egid=%d", egid) + pw = getgrgid(egid) + if (pw != "") { + split(pw, a, ":") + printf("(%s)", a[1]) + } + } + + for (i = 1; ("group" i) in PROCINFO; i++) { + if (i == 1) + printf(" groups=") + group = PROCINFO["group" i] + printf("%d", group) + pw = getgrgid(group) + if (pw != "") { + split(pw, a, ":") + printf("(%s)", a[1]) + } + if (("group" (i+1)) in PROCINFO) + printf(",") + } + + print "" +} diff --git a/awklib/eg/prog/igawk.sh b/awklib/eg/prog/igawk.sh new file mode 100644 index 0000000..03d1c99 --- /dev/null +++ b/awklib/eg/prog/igawk.sh @@ -0,0 +1,138 @@ +#! /bin/sh +# igawk --- like gawk but do @include processing +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# July 1993 +# December 2010, minor edits + +if [ "$1" = debug ] +then + set -x + shift +fi + +# A literal newline, so that program text is formatted correctly +n=' +' + +# Initialize variables to empty +program= +opts= + +while [ $# -ne 0 ] # loop over arguments +do + case $1 in + --) shift + break ;; + + -W) shift + # The ${x?'message here'} construct prints a + # diagnostic if $x is the null string + set -- -W"${@?'missing operand'}" + continue ;; + + -[vF]) opts="$opts $1 '${2?'missing operand'}'" + shift ;; + + -[vF]*) opts="$opts '$1'" ;; + + -f) program="$program$n@include ${2?'missing operand'}" + shift ;; + + -f*) f=$(expr "$1" : '-f\(.*\)') + program="$program$n@include $f" ;; + + -[W-]file=*) + f=$(expr "$1" : '-.file=\(.*\)') + program="$program$n@include $f" ;; + + -[W-]file) + program="$program$n@include ${2?'missing operand'}" + shift ;; + + -[W-]source=*) + t=$(expr "$1" : '-.source=\(.*\)') + program="$program$n$t" ;; + + -[W-]source) + program="$program$n${2?'missing operand'}" + shift ;; + + -[W-]version) + echo igawk: version 3.0 1>&2 + gawk --version + exit 0 ;; + + -[W-]*) opts="$opts '$1'" ;; + + *) break ;; + esac + shift +done + +if [ -z "$program" ] +then + program=${1?'missing program'} + shift +fi + +# At this point, `program' has the program. +expand_prog=' + +function pathto(file, i, t, junk) +{ + if (index(file, "/") != 0) + return file + + if (file == "-") + return file + + for (i = 1; i <= ndirs; i++) { + t = (pathlist[i] "/" file) + if ((getline junk < t) > 0) { + # found it + close(t) + return t + } + } + return "" +} +BEGIN { + path = ENVIRON["AWKPATH"] + ndirs = split(path, pathlist, ":") + for (i = 1; i <= ndirs; i++) { + if (pathlist[i] == "") + pathlist[i] = "." + } + stackptr = 0 + input[stackptr] = ARGV[1] # ARGV[1] is first file + + for (; stackptr >= 0; stackptr--) { + while ((getline < input[stackptr]) > 0) { + if (tolower($1) != "@include") { + print + continue + } + fpath = pathto($2) + if (fpath == "") { + printf("igawk:%s:%d: cannot find %s\n", + input[stackptr], FNR, $2) > "/dev/stderr" + continue + } + if (! (fpath in processed)) { + processed[fpath] = input[stackptr] + input[++stackptr] = fpath # push onto stack + } else + print $2, "included in", input[stackptr], + "already included in", + processed[fpath] > "/dev/stderr" + } + close(input[stackptr]) + } +}' # close quote ends `expand_prog' variable + +processed_program=$(gawk -- "$expand_prog" /dev/stdin << EOF +$program +EOF +) +eval gawk $opts -- '"$processed_program"' '"$@"' diff --git a/awklib/eg/prog/indirectcall.awk b/awklib/eg/prog/indirectcall.awk new file mode 100644 index 0000000..3ecb288 --- /dev/null +++ b/awklib/eg/prog/indirectcall.awk @@ -0,0 +1,45 @@ +# num_lt --- do a numeric less than comparison + +function num_lt(left, right) +{ + return ((left + 0) < (right + 0)) +} + +# num_ge --- do a numeric greater than or equal to comparison + +function num_ge(left, right) +{ + return ((left + 0) >= (right + 0)) +} +# do_sort --- sort the data according to `compare' +# and return it as a string + +function do_sort(first, last, compare, data, i, retval) +{ + delete data + for (i = 1; first <= last; first++) { + data[i] = $first + i++ + } + + quicksort(data, 1, i-1, compare) + + retval = data[1] + for (i = 2; i in data; i++) + retval = retval " " data[i] + + return retval +} +# sort --- sort the data in ascending order and return it as a string + +function sort(first, last) +{ + return do_sort(first, last, "num_lt") +} + +# rsort --- sort the data in descending order and return it as a string + +function rsort(first, last) +{ + return do_sort(first, last, "num_ge") +} diff --git a/awklib/eg/prog/labels.awk b/awklib/eg/prog/labels.awk new file mode 100644 index 0000000..abf53c3 --- /dev/null +++ b/awklib/eg/prog/labels.awk @@ -0,0 +1,54 @@ +# labels.awk --- print mailing labels +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# June 1992 +# December 2010, minor edits + +# Each label is 5 lines of data that may have blank lines. +# The label sheets have 2 blank lines at the top and 2 at +# the bottom. + +BEGIN { RS = "" ; MAXLINES = 100 } + +function printpage( i, j) +{ + if (Nlines <= 0) + return + + printf "\n\n" # header + + for (i = 1; i <= Nlines; i += 10) { + if (i == 21 || i == 61) + print "" + for (j = 0; j < 5; j++) { + if (i + j > MAXLINES) + break + printf " %-41s %s\n", line[i+j], line[i+j+5] + } + print "" + } + + printf "\n\n" # footer + + delete line +} + +# main rule +{ + if (Count >= 20) { + printpage() + Count = 0 + Nlines = 0 + } + n = split($0, a, "\n") + for (i = 1; i <= n; i++) + line[++Nlines] = a[i] + for (; i <= 5; i++) + line[++Nlines] = "" + Count++ +} + +END \ +{ + printpage() +} diff --git a/awklib/eg/prog/split.awk b/awklib/eg/prog/split.awk new file mode 100644 index 0000000..c907530 --- /dev/null +++ b/awklib/eg/prog/split.awk @@ -0,0 +1,57 @@ +# split.awk --- do split in awk +# +# Requires ord() and chr() library functions +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# May 1993 + +# usage: split [-num] [file] [outname] + +BEGIN { + outfile = "x" # default + count = 1000 + if (ARGC > 4) + usage() + + i = 1 + if (ARGV[i] ~ /^-[[:digit:]]+$/) { + count = -ARGV[i] + ARGV[i] = "" + i++ + } + # test argv in case reading from stdin instead of file + if (i in ARGV) + i++ # skip data file name + if (i in ARGV) { + outfile = ARGV[i] + ARGV[i] = "" + } + + s1 = s2 = "a" + out = (outfile s1 s2) +} +{ + if (++tcount > count) { + close(out) + if (s2 == "z") { + if (s1 == "z") { + printf("split: %s is too large to split\n", + FILENAME) > "/dev/stderr" + exit 1 + } + s1 = chr(ord(s1) + 1) + s2 = "a" + } + else + s2 = chr(ord(s2) + 1) + out = (outfile s1 s2) + tcount = 1 + } + print > out +} +function usage( e) +{ + e = "usage: split [-num] [file] [outname]" + print e > "/dev/stderr" + exit 1 +} diff --git a/awklib/eg/prog/tee.awk b/awklib/eg/prog/tee.awk new file mode 100644 index 0000000..639b9f8 --- /dev/null +++ b/awklib/eg/prog/tee.awk @@ -0,0 +1,42 @@ +# tee.awk --- tee in awk +# +# Copy standard input to all named output files. +# Append content if -a option is supplied. +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# May 1993 +# Revised December 1995 + +BEGIN \ +{ + for (i = 1; i < ARGC; i++) + copy[i] = ARGV[i] + + if (ARGV[1] == "-a") { + append = 1 + delete ARGV[1] + delete copy[1] + ARGC-- + } + if (ARGC < 2) { + print "usage: tee [-a] file ..." > "/dev/stderr" + exit 1 + } + ARGV[1] = "-" + ARGC = 2 +} +{ + # moving the if outside the loop makes it run faster + if (append) + for (i in copy) + print >> copy[i] + else + for (i in copy) + print > copy[i] + print +} +END \ +{ + for (i in copy) + close(copy[i]) +} diff --git a/awklib/eg/prog/testbits.awk b/awklib/eg/prog/testbits.awk new file mode 100644 index 0000000..143cd91 --- /dev/null +++ b/awklib/eg/prog/testbits.awk @@ -0,0 +1,27 @@ +# bits2str --- turn a byte into readable 1's and 0's + +function bits2str(bits, data, mask) +{ + if (bits == 0) + return "0" + + mask = 1 + for (; bits != 0; bits = rshift(bits, 1)) + data = (and(bits, mask) ? "1" : "0") data + + while ((length(data) % 8) != 0) + data = "0" data + + return data +} +BEGIN { + printf "123 = %s\n", bits2str(123) + printf "0123 = %s\n", bits2str(0123) + printf "0x99 = %s\n", bits2str(0x99) + comp = compl(0x99) + printf "compl(0x99) = %#x = %s\n", comp, bits2str(comp) + shift = lshift(0x99, 2) + printf "lshift(0x99, 2) = %#x = %s\n", shift, bits2str(shift) + shift = rshift(0x99, 2) + printf "rshift(0x99, 2) = %#x = %s\n", shift, bits2str(shift) +} diff --git a/awklib/eg/prog/translate.awk b/awklib/eg/prog/translate.awk new file mode 100644 index 0000000..cf7f389 --- /dev/null +++ b/awklib/eg/prog/translate.awk @@ -0,0 +1,51 @@ +# translate.awk --- do tr-like stuff +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# August 1989 +# February 2009 - bug fix + +# Bugs: does not handle things like: tr A-Z a-z, it has +# to be spelled out. However, if `to' is shorter than `from', +# the last character in `to' is used for the rest of `from'. + +function stranslate(from, to, target, lf, lt, ltarget, t_ar, i, c, + result) +{ + lf = length(from) + lt = length(to) + ltarget = length(target) + for (i = 1; i <= lt; i++) + t_ar[substr(from, i, 1)] = substr(to, i, 1) + if (lt < lf) + for (; i <= lf; i++) + t_ar[substr(from, i, 1)] = substr(to, lt, 1) + for (i = 1; i <= ltarget; i++) { + c = substr(target, i, 1) + if (c in t_ar) + c = t_ar[c] + result = result c + } + return result +} + +function translate(from, to) +{ + return $0 = stranslate(from, to, $0) +} + +# main program +BEGIN { + if (ARGC < 3) { + print "usage: translate from to" > "/dev/stderr" + exit + } + FROM = ARGV[1] + TO = ARGV[2] + ARGC = 2 + ARGV[1] = "-" +} + +{ + translate(FROM, TO) + print +} diff --git a/awklib/eg/prog/uniq.awk b/awklib/eg/prog/uniq.awk new file mode 100644 index 0000000..990387a --- /dev/null +++ b/awklib/eg/prog/uniq.awk @@ -0,0 +1,120 @@ +# uniq.awk --- do uniq in awk +# +# Requires getopt() and join() library functions +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# May 1993 + +function usage( e) +{ + e = "Usage: uniq [-udc [-n]] [+n] [ in [ out ]]" + print e > "/dev/stderr" + exit 1 +} + +# -c count lines. overrides -d and -u +# -d only repeated lines +# -u only nonrepeated lines +# -n skip n fields +# +n skip n characters, skip fields first + +BEGIN \ +{ + count = 1 + outputfile = "/dev/stdout" + opts = "udc0:1:2:3:4:5:6:7:8:9:" + while ((c = getopt(ARGC, ARGV, opts)) != -1) { + if (c == "u") + non_repeated_only++ + else if (c == "d") + repeated_only++ + else if (c == "c") + do_count++ + else if (index("0123456789", c) != 0) { + # getopt requires args to options + # this messes us up for things like -5 + if (Optarg ~ /^[[:digit:]]+$/) + fcount = (c Optarg) + 0 + else { + fcount = c + 0 + Optind-- + } + } else + usage() + } + + if (ARGV[Optind] ~ /^\+[[:digit:]]+$/) { + charcount = substr(ARGV[Optind], 2) + 0 + Optind++ + } + + for (i = 1; i < Optind; i++) + ARGV[i] = "" + + if (repeated_only == 0 && non_repeated_only == 0) + repeated_only = non_repeated_only = 1 + + if (ARGC - Optind == 2) { + outputfile = ARGV[ARGC - 1] + ARGV[ARGC - 1] = "" + } +} +function are_equal( n, m, clast, cline, alast, aline) +{ + if (fcount == 0 && charcount == 0) + return (last == $0) + + if (fcount > 0) { + n = split(last, alast) + m = split($0, aline) + clast = join(alast, fcount+1, n) + cline = join(aline, fcount+1, m) + } else { + clast = last + cline = $0 + } + if (charcount) { + clast = substr(clast, charcount + 1) + cline = substr(cline, charcount + 1) + } + + return (clast == cline) +} +NR == 1 { + last = $0 + next +} + +{ + equal = are_equal() + + if (do_count) { # overrides -d and -u + if (equal) + count++ + else { + printf("%4d %s\n", count, last) > outputfile + last = $0 + count = 1 # reset + } + next + } + + if (equal) + count++ + else { + if ((repeated_only && count > 1) || + (non_repeated_only && count == 1)) + print last > outputfile + last = $0 + count = 1 + } +} + +END { + if (do_count) + printf("%4d %s\n", count, last) > outputfile + else if ((repeated_only && count > 1) || + (non_repeated_only && count == 1)) + print last > outputfile + close(outputfile) +} diff --git a/awklib/eg/prog/wc.awk b/awklib/eg/prog/wc.awk new file mode 100644 index 0000000..95940ae --- /dev/null +++ b/awklib/eg/prog/wc.awk @@ -0,0 +1,69 @@ +# wc.awk --- count lines, words, characters +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# May 1993 + +# Options: +# -l only count lines +# -w only count words +# -c only count characters +# +# Default is to count lines, words, characters +# +# Requires getopt() and file transition library functions + +BEGIN { + # let getopt() print a message about + # invalid options. we ignore them + while ((c = getopt(ARGC, ARGV, "lwc")) != -1) { + if (c == "l") + do_lines = 1 + else if (c == "w") + do_words = 1 + else if (c == "c") + do_chars = 1 + } + for (i = 1; i < Optind; i++) + ARGV[i] = "" + + # if no options, do all + if (! do_lines && ! do_words && ! do_chars) + do_lines = do_words = do_chars = 1 + + print_total = (ARGC - i > 2) +} +function beginfile(file) +{ + lines = words = chars = 0 + fname = FILENAME +} +function endfile(file) +{ + tlines += lines + twords += words + tchars += chars + if (do_lines) + printf "\t%d", lines + if (do_words) + printf "\t%d", words + if (do_chars) + printf "\t%d", chars + printf "\t%s\n", fname +} +# do per line +{ + chars += length($0) + 1 # get newline + lines++ + words += NF +} +END { + if (print_total) { + if (do_lines) + printf "\t%d", tlines + if (do_words) + printf "\t%d", twords + if (do_chars) + printf "\t%d", tchars + print "\ttotal" + } +} diff --git a/awklib/eg/prog/wordfreq.awk b/awklib/eg/prog/wordfreq.awk new file mode 100644 index 0000000..6d7195e --- /dev/null +++ b/awklib/eg/prog/wordfreq.awk @@ -0,0 +1,16 @@ +# wordfreq.awk --- print list of word frequencies + +{ + $0 = tolower($0) # remove case distinctions + # remove punctuation + gsub(/[^[:alnum:]_[:blank:]]/, "", $0) + for (i = 1; i <= NF; i++) + freq[$i]++ +} + +END { + sort = "sort -k 2nr" + for (word in freq) + printf "%s\t%d\n", word, freq[word] | sort + close(sort) +} diff --git a/awklib/extract.awk b/awklib/extract.awk new file mode 100644 index 0000000..1b052e7 --- /dev/null +++ b/awklib/extract.awk @@ -0,0 +1,92 @@ +# extract.awk --- extract files and run programs +# from texinfo files +# +# Arnold Robbins, arnold@gnu.org, Public Domain +# May 1993 +# Revised September 2000 + +BEGIN { IGNORECASE = 1 } + +/^@c(omment)?[ \t]+system/ \ +{ + if (NF < 3) { + e = (FILENAME ":" FNR) + e = (e ": badly formed `system' line") + print e > "/dev/stderr" + next + } + $1 = "" + $2 = "" + stat = system($0) + if (stat != 0) { + e = (FILENAME ":" FNR) + e = (e ": warning: system returned " stat) + print e > "/dev/stderr" + } +} +/^@c(omment)?[ \t]+file/ \ +{ + if (NF != 3) { + e = (FILENAME ":" FNR ": badly formed `file' line") + print e > "/dev/stderr" + next + } + if ($3 != curfile) { + if (curfile != "") + close(curfile) + curfile = $3 + } + + for (;;) { + if ((getline line) <= 0) + unexpected_eof() + if (line ~ /^@c(omment)?[ \t]+endfile/) + break + else if (line ~ /^@(end[ \t]+)?group/) + continue + else if (line ~ /^@c(omment+)?[ \t]+/) + continue + if (index(line, "@") == 0) { + print line > curfile + continue + } + n = split(line, a, "@") + # if a[1] == "", means leading @, + # don't add one back in. + for (i = 2; i <= n; i++) { + if (a[i] == "") { # was an @@ + a[i] = "@" + if (a[i+1] == "") + i++ + } + } + print join(a, 1, n, SUBSEP) > curfile + } +} +function unexpected_eof() +{ + printf("%s:%d: unexpected EOF or error\n", + FILENAME, FNR) > "/dev/stderr" + exit 1 +} + +END { + if (curfile) + close(curfile) +} +# join.awk --- join an array into a string +# +# Arnold Robbins, arnold@gnu.org, Public Domain +# May 1993 + +function join(array, start, end, sep, result, i) +{ + if (sep == "") + sep = " " + else if (sep == SUBSEP) # magic value + sep = "" + result = array[start] + for (i = start + 1; i <= end; i++) + result = result sep array[i] + return result +} diff --git a/awklib/stamp-eg b/awklib/stamp-eg new file mode 100644 index 0000000..241abd9 --- /dev/null +++ b/awklib/stamp-eg @@ -0,0 +1,2 @@ +some makes are stupid and will not check a directory +against a file, so this file is a place holder. gack. diff --git a/bisonfix.awk b/bisonfix.awk new file mode 100644 index 0000000..a759d25 --- /dev/null +++ b/bisonfix.awk @@ -0,0 +1,42 @@ +# bisonfix.awk --- tweak awkgram.c for stupid compilers. + +# Copyright (C) 2005, 2009 the Free Software Foundation, Inc. +# +# This file is part of GAWK, the GNU implementation of the +# AWK Programming Language. +# +# GAWK is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +BEGIN { sfile = ARGV[1] ; delete ARGV[1] } + +/^#if.*\\$/ { + line = $0 + sub(/\\$/, "", line) + getline line2 + while (line2 ~ /\\$/) { + line = line line2 + sub(/\\$/, "", line) + getline line2 + } + line = line line2 + sub(/\\$/, "", line) + print line + next +} + +/^#line.*y\.tab\.c/ { sub(/y.tab/, sfile) } + +{ print } + diff --git a/builtin.c b/builtin.c new file mode 100644 index 0000000..44e0b85 --- /dev/null +++ b/builtin.c @@ -0,0 +1,3364 @@ +/* + * builtin.c - Builtin functions and various utility procedures. + */ + +/* + * Copyright (C) 1986, 1988, 1989, 1991-2012 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + + +#include "awk.h" +#if defined(HAVE_FCNTL_H) +#include +#endif +#include +#include "random.h" +#include "floatmagic.h" + +#if defined(HAVE_POPEN_H) +#include "popen.h" +#endif + +#ifndef CHAR_BIT +# define CHAR_BIT 8 +#endif + +/* The extra casts work around common compiler bugs. */ +#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) +/* The outer cast is needed to work around a bug in Cray C 5.0.3.0. + It is necessary at least when t == time_t. */ +#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \ + ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0)) +#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t))) + +#ifndef INTMAX_MIN +# define INTMAX_MIN TYPE_MINIMUM (intmax_t) +#endif +#ifndef UINTMAX_MAX +# define UINTMAX_MAX TYPE_MAXIMUM (uintmax_t) +#endif + +#ifndef SIZE_MAX /* C99 constant, can't rely on it everywhere */ +#define SIZE_MAX ((size_t) -1) +#endif + +#define DEFAULT_G_PRECISION 6 + +static size_t mbc_byte_count(const char *ptr, size_t numchars); +static size_t mbc_char_count(const char *ptr, size_t numbytes); + +/* Can declare these, since we always use the random shipped with gawk */ +extern char *initstate(unsigned long seed, char *state, long n); +extern char *setstate(char *state); +extern long random(void); +extern void srandom(unsigned long seed); + +extern NODE **args_array; +extern int max_args; +extern NODE **fields_arr; +extern int output_is_tty; +extern FILE *output_fp; + + +#define POP_TWO_SCALARS(s1, s2) \ +s2 = POP_SCALAR(); \ +s1 = POP(); \ +if ((s1)->type == Node_var_array) \ + DEREF(s2), fatal(_("attempt to use array `%s' in a scalar context"), array_vname(s1)), 0 + + +/* + * Since we supply the version of random(), we know what + * value to use here. + */ +#define GAWK_RANDOM_MAX 0x7fffffffL + +static void efwrite(const void *ptr, size_t size, size_t count, FILE *fp, + const char *from, struct redirect *rp, int flush); + +/* efwrite --- like fwrite, but with error checking */ + +static void +efwrite(const void *ptr, + size_t size, + size_t count, + FILE *fp, + const char *from, + struct redirect *rp, + int flush) +{ + errno = 0; + if (fwrite(ptr, size, count, fp) != count) + goto wrerror; + if (flush + && ((fp == stdout && output_is_tty) + || (rp != NULL && (rp->flag & RED_NOBUF)))) { + fflush(fp); + if (ferror(fp)) + goto wrerror; + } + return; + +wrerror: + fatal(_("%s to \"%s\" failed (%s)"), from, + rp ? rp->value : _("standard output"), + errno ? strerror(errno) : _("reason unknown")); +} + +/* do_exp --- exponential function */ + +NODE * +do_exp(int nargs) +{ + NODE *tmp; + double d, res; + + tmp = POP_SCALAR(); + if (do_lint && (tmp->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("exp: received non-numeric argument")); + d = force_number(tmp); + DEREF(tmp); + errno = 0; + res = exp(d); + if (errno == ERANGE) + warning(_("exp: argument %g is out of range"), d); + return make_number((AWKNUM) res); +} + +/* stdfile --- return fp for a standard file */ + +/* + * This function allows `fflush("/dev/stdout")' to work. + * The other files will be available via getredirect(). + * /dev/stdin is not included, since fflush is only for output. + */ + +static FILE * +stdfile(const char *name, size_t len) +{ + if (len == 11) { + if (strncmp(name, "/dev/stderr", 11) == 0) + return stderr; + else if (strncmp(name, "/dev/stdout", 11) == 0) + return stdout; + } + + return NULL; +} + +/* do_fflush --- flush output, either named file or pipe or everything */ + +NODE * +do_fflush(int nargs) +{ + struct redirect *rp; + NODE *tmp; + FILE *fp; + int status = 0; + const char *file; + + /* fflush() --- flush stdout */ + if (nargs == 0) { + if (output_fp != stdout) + (void) fflush(output_fp); + status = fflush(stdout); + return make_number((AWKNUM) status); + } + + tmp = POP_STRING(); + file = tmp->stptr; + + /* fflush("") --- flush all */ + if (tmp->stlen == 0) { + status = flush_io(); + DEREF(tmp); + return make_number((AWKNUM) status); + } + + rp = getredirect(tmp->stptr, tmp->stlen); + status = -1; + if (rp != NULL) { + if ((rp->flag & (RED_WRITE|RED_APPEND)) == 0) { + if (rp->flag & RED_PIPE) + warning(_("fflush: cannot flush: pipe `%s' opened for reading, not writing"), + file); + else + warning(_("fflush: cannot flush: file `%s' opened for reading, not writing"), + file); + DEREF(tmp); + return make_number((AWKNUM) status); + } + fp = rp->fp; + if (fp != NULL) + status = fflush(fp); + } else if ((fp = stdfile(tmp->stptr, tmp->stlen)) != NULL) { + status = fflush(fp); + } else { + status = -1; + warning(_("fflush: `%s' is not an open file, pipe or co-process"), file); + } + DEREF(tmp); + return make_number((AWKNUM) status); +} + +#if MBS_SUPPORT +/* strncasecmpmbs --- like strncasecmp (multibyte string version) */ + +int +strncasecmpmbs(const unsigned char *s1, const unsigned char *s2, size_t n) +{ + size_t i1, i2, mbclen1, mbclen2, gap; + wchar_t wc1, wc2; + mbstate_t mbs1, mbs2; + + memset(& mbs1, 0, sizeof(mbs1)); + memset(& mbs2, 0, sizeof(mbs2)); + + for (i1 = i2 = 0 ; i1 < n && i2 < n ;i1 += mbclen1, i2 += mbclen2) { + if (is_valid_character(s1[i1])) { + mbclen1 = 1; + wc1 = btowc_cache(s1[i1]); + } else { + mbclen1 = mbrtowc(& wc1, (const char *)s1 + i1, + n - i1, & mbs1); + if (mbclen1 == (size_t) -1 || mbclen1 == (size_t) -2 || mbclen1 == 0) { + /* We treat it as a singlebyte character. */ + mbclen1 = 1; + wc1 = btowc_cache(s1[i1]); + } + } + if (is_valid_character(s2[i2])) { + mbclen2 = 1; + wc2 = btowc_cache(s2[i2]); + } else { + mbclen2 = mbrtowc(& wc2, (const char *)s2 + i2, + n - i2, & mbs2); + if (mbclen2 == (size_t) -1 || mbclen2 == (size_t) -2 || mbclen2 == 0) { + /* We treat it as a singlebyte character. */ + mbclen2 = 1; + wc2 = btowc_cache(s2[i2]); + } + } + if ((gap = towlower(wc1) - towlower(wc2)) != 0) + /* s1 and s2 are not equivalent. */ + return gap; + } + /* s1 and s2 are equivalent. */ + return 0; +} + +/* Inspect the buffer `src' and write the index of each byte to `dest'. + Caller must allocate `dest'. + e.g. str = , , a, b, , , , c + where mb(i) means the `i'-th byte of a multibyte character. + dest = 1, 2, 1, 1, 1, 2, 3. 1 +*/ +static void +index_multibyte_buffer(char* src, char* dest, int len) +{ + int idx, prev_idx; + mbstate_t mbs, prevs; + + memset(& prevs, 0, sizeof(mbstate_t)); + for (idx = prev_idx = 0 ; idx < len ; idx++) { + size_t mbclen; + mbs = prevs; + mbclen = mbrlen(src + prev_idx, idx - prev_idx + 1, & mbs); + if (mbclen == (size_t) -1 || mbclen == 1 || mbclen == 0) { + /* singlebyte character. */ + mbclen = 1; + prev_idx = idx + 1; + } else if (mbclen == (size_t) -2) { + /* a part of a multibyte character. */ + mbclen = idx - prev_idx + 1; + } else if (mbclen > 1) { + /* the end of a multibyte character. */ + prev_idx = idx + 1; + prevs = mbs; + } else { + /* Can't reach. */ + } + dest[idx] = mbclen; + } +} +#else +/* a dummy function */ +static void +index_multibyte_buffer(char* src ATTRIBUTE_UNUSED, char* dest ATTRIBUTE_UNUSED, int len ATTRIBUTE_UNUSED) +{ + cant_happen(); +} +#endif + +/* do_index --- find index of a string */ + +NODE * +do_index(int nargs) +{ + NODE *s1, *s2; + const char *p1, *p2; + size_t l1, l2; + long ret; +#if MBS_SUPPORT + int do_single_byte = FALSE; + mbstate_t mbs1, mbs2; + + if (gawk_mb_cur_max > 1) { + memset(& mbs1, 0, sizeof(mbstate_t)); + memset(& mbs2, 0, sizeof(mbstate_t)); + } +#endif + + POP_TWO_SCALARS(s1, s2); + + if (do_lint) { + if ((s1->flags & (STRING|STRCUR)) == 0) + lintwarn(_("index: received non-string first argument")); + if ((s2->flags & (STRING|STRCUR)) == 0) + lintwarn(_("index: received non-string second argument")); + } + force_string(s1); + force_string(s2); + p1 = s1->stptr; + p2 = s2->stptr; + l1 = s1->stlen; + l2 = s2->stlen; + ret = 0; + + /* + * Icky special case, index(foo, "") should return 1, + * since both bwk awk and mawk do, and since match("foo", "") + * returns 1. This makes index("", "") work, too, fwiw. + */ + if (l2 == 0) { + ret = 1; + goto out; + } + +#if MBS_SUPPORT + if (gawk_mb_cur_max > 1) { + s1 = force_wstring(s1); + s2 = force_wstring(s2); + /* + * If we don't have valid wide character strings, use + * the real bytes. + */ + do_single_byte = ((s1->wstlen == 0 && s1->stlen > 0) + || (s2->wstlen == 0 && s2->stlen > 0)); + } +#endif + + /* IGNORECASE will already be false if posix */ + if (IGNORECASE) { + while (l1 > 0) { + if (l2 > l1) + break; +#if MBS_SUPPORT + if (! do_single_byte && gawk_mb_cur_max > 1) { + const wchar_t *pos; + + pos = wcasestrstr(s1->wstptr, s1->wstlen, s2->wstptr, s2->wstlen); + if (pos == NULL) + ret = 0; + else + ret = pos - s1->wstptr + 1; /* 1-based */ + goto out; + } else { +#endif + /* + * Could use tolower(*p1) == tolower(*p2) here. + * See discussion in eval.c as to why not. + */ + if (casetable[(unsigned char)*p1] == casetable[(unsigned char)*p2] + && (l2 == 1 || strncasecmp(p1, p2, l2) == 0)) { + ret = 1 + s1->stlen - l1; + break; + } + l1--; + p1++; +#if MBS_SUPPORT + } +#endif + } + } else { + while (l1 > 0) { + if (l2 > l1) + break; + if (*p1 == *p2 + && (l2 == 1 || (l2 > 0 && memcmp(p1, p2, l2) == 0))) { + ret = 1 + s1->stlen - l1; + break; + } +#if MBS_SUPPORT + if (! do_single_byte && gawk_mb_cur_max > 1) { + const wchar_t *pos; + + pos = wstrstr(s1->wstptr, s1->wstlen, s2->wstptr, s2->wstlen); + if (pos == NULL) + ret = 0; + else + ret = pos - s1->wstptr + 1; /* 1-based */ + goto out; + } else { + l1--; + p1++; + } +#else + l1--; + p1++; +#endif + } + } +out: + DEREF(s1); + DEREF(s2); + return make_number((AWKNUM) ret); +} + +/* double_to_int --- convert double to int, used several places */ + +double +double_to_int(double d) +{ + if (d >= 0) + d = Floor(d); + else + d = Ceil(d); + return d; +} + +/* do_int --- convert double to int for awk */ + +NODE * +do_int(int nargs) +{ + NODE *tmp; + double d; + + tmp = POP_SCALAR(); + if (do_lint && (tmp->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("int: received non-numeric argument")); + d = force_number(tmp); + d = double_to_int(d); + DEREF(tmp); + return make_number((AWKNUM) d); +} + +/* do_isarray --- check if argument is array */ + +NODE * +do_isarray(int nargs) +{ + NODE *tmp; + int ret = 1; + + tmp = POP(); + if (tmp->type != Node_var_array) { + ret = 0; + DEREF(tmp); + } + return make_number((AWKNUM) ret); +} + +/* do_length --- length of a string, array or $0 */ + +NODE * +do_length(int nargs) +{ + NODE *tmp; + size_t len; + + tmp = POP(); + if (tmp->type == Node_var_array) { + static short warned = FALSE; + + if (do_posix) + fatal(_("length: received array argument")); + if (do_lint && ! warned) { + warned = TRUE; + lintwarn(_("`length(array)' is a gawk extension")); + } + return make_number((AWKNUM) tmp->table_size); + } + + assert(tmp->type == Node_val); + + if (do_lint && (tmp->flags & (STRING|STRCUR)) == 0) + lintwarn(_("length: received non-string argument")); + (void) force_string(tmp); + +#if MBS_SUPPORT + if (gawk_mb_cur_max > 1) { + tmp = force_wstring(tmp); + len = tmp->wstlen; + /* + * If the bytes don't make a valid wide character + * string, fall back to the bytes themselves. + */ + if (len == 0 && tmp->stlen > 0) + len = tmp->stlen; + } else +#endif + len = tmp->stlen; + + DEREF(tmp); + return make_number((AWKNUM) len); +} + +/* do_log --- the log function */ + +NODE * +do_log(int nargs) +{ + NODE *tmp; + double d, arg; + + tmp = POP_SCALAR(); + if (do_lint && (tmp->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("log: received non-numeric argument")); + arg = (double) force_number(tmp); + if (arg < 0.0) + warning(_("log: received negative argument %g"), arg); + d = log(arg); + DEREF(tmp); + return make_number((AWKNUM) d); +} + + +/* + * format_tree() formats arguments of sprintf, + * and accordingly to a fmt_string providing a format like in + * printf family from C library. Returns a string node which value + * is a formatted string. Called by sprintf function. + * + * It is one of the uglier parts of gawk. Thanks to Michal Jaegermann + * for taming this beast and making it compatible with ANSI C. + */ + +NODE * +format_tree( + const char *fmt_string, + size_t n0, + NODE **the_args, + long num_args) +{ +/* copy 'l' bytes from 's' to 'obufout' checking for space in the process */ +/* difference of pointers should be of ptrdiff_t type, but let us be kind */ +#define bchunk(s, l) if (l) { \ + while ((l) > ofre) { \ + size_t olen = obufout - obuf; \ + erealloc(obuf, char *, osiz * 2, "format_tree"); \ + ofre += osiz; \ + osiz *= 2; \ + obufout = obuf + olen; \ + } \ + memcpy(obufout, s, (size_t) (l)); \ + obufout += (l); \ + ofre -= (l); \ +} + +/* copy one byte from 's' to 'obufout' checking for space in the process */ +#define bchunk_one(s) { \ + if (ofre < 1) { \ + size_t olen = obufout - obuf; \ + erealloc(obuf, char *, osiz * 2, "format_tree"); \ + ofre += osiz; \ + osiz *= 2; \ + obufout = obuf + olen; \ + } \ + *obufout++ = *s; \ + --ofre; \ +} + +/* Is there space for something L big in the buffer? */ +#define chksize(l) if ((l) >= ofre) { \ + size_t olen = obufout - obuf; \ + size_t delta = osiz+l-ofre; \ + erealloc(obuf, char *, osiz + delta, "format_tree"); \ + obufout = obuf + olen; \ + ofre += delta; \ + osiz += delta; \ +} + + size_t cur_arg = 0; + NODE *r = NULL; + int i; + int toofew = FALSE; + char *obuf, *obufout; + size_t osiz, ofre; + const char *chbuf; + const char *s0, *s1; + int cs1; + NODE *arg; + long fw, prec, argnum; + int used_dollar; + int lj, alt, big_flag, bigbig_flag, small_flag, have_prec, need_format; + long *cur = NULL; + uintmax_t uval; + int sgn; + int base; + /* + * Although this is an array, the elements serve two different + * purposes. The first element is the general buffer meant + * to hold the entire result string. The second one is a + * temporary buffer for large floating point values. They + * could just as easily be separate variables, and the + * code might arguably be clearer. + */ + struct { + char *buf; + size_t bufsize; + char stackbuf[30]; + } cpbufs[2]; +#define cpbuf cpbufs[0].buf + char *cend = &cpbufs[0].stackbuf[sizeof(cpbufs[0].stackbuf)]; + char *cp; + const char *fill; + AWKNUM tmpval; + char signchar = FALSE; + size_t len; + int zero_flag = FALSE; + int quote_flag = FALSE; + int ii, jj; + char *chp; + size_t copy_count, char_count; + static const char sp[] = " "; + static const char zero_string[] = "0"; + static const char lchbuf[] = "0123456789abcdef"; + static const char Uchbuf[] = "0123456789ABCDEF"; + +#define INITIAL_OUT_SIZE 512 + emalloc(obuf, char *, INITIAL_OUT_SIZE, "format_tree"); + obufout = obuf; + osiz = INITIAL_OUT_SIZE; + ofre = osiz - 2; + + cur_arg = 1; + + { + size_t k; + for (k = 0; k < sizeof(cpbufs)/sizeof(cpbufs[0]); k++) { + cpbufs[k].bufsize = sizeof(cpbufs[k].stackbuf); + cpbufs[k].buf = cpbufs[k].stackbuf; + } + } + + /* + * The point of this goop is to grow the buffer + * holding the converted number, so that large + * values don't overflow a fixed length buffer. + */ +#define PREPEND(CH) do { \ + if (cp == cpbufs[0].buf) { \ + char *prev = cpbufs[0].buf; \ + emalloc(cpbufs[0].buf, char *, 2*cpbufs[0].bufsize, \ + "format_tree"); \ + memcpy((cp = cpbufs[0].buf+cpbufs[0].bufsize), prev, \ + cpbufs[0].bufsize); \ + cpbufs[0].bufsize *= 2; \ + if (prev != cpbufs[0].stackbuf) \ + efree(prev); \ + cend = cpbufs[0].buf+cpbufs[0].bufsize; \ + } \ + *--cp = (CH); \ +} while(0) + + /* + * Check first for use of `count$'. + * If plain argument retrieval was used earlier, choke. + * Otherwise, return the requested argument. + * If not `count$' now, but it was used earlier, choke. + * If this format is more than total number of args, choke. + * Otherwise, return the current argument. + */ +#define parse_next_arg() { \ + if (argnum > 0) { \ + if (cur_arg > 1) { \ + msg(_("fatal: must use `count$' on all formats or none")); \ + goto out; \ + } \ + arg = the_args[argnum]; \ + } else if (used_dollar) { \ + msg(_("fatal: must use `count$' on all formats or none")); \ + arg = 0; /* shutup the compiler */ \ + goto out; \ + } else if (cur_arg >= num_args) { \ + arg = 0; /* shutup the compiler */ \ + toofew = TRUE; \ + break; \ + } else { \ + arg = the_args[cur_arg]; \ + cur_arg++; \ + } \ +} + + need_format = FALSE; + used_dollar = FALSE; + + s0 = s1 = fmt_string; + while (n0-- > 0) { + if (*s1 != '%') { + s1++; + continue; + } + need_format = TRUE; + bchunk(s0, s1 - s0); + s0 = s1; + cur = &fw; + fw = 0; + prec = 0; + base = 0; + argnum = 0; + have_prec = FALSE; + signchar = FALSE; + zero_flag = FALSE; + quote_flag = FALSE; + lj = alt = big_flag = bigbig_flag = small_flag = FALSE; + fill = sp; + cp = cend; + chbuf = lchbuf; + s1++; + +retry: + if (n0-- == 0) /* ran out early! */ + break; + + switch (cs1 = *s1++) { + case (-1): /* dummy case to allow for checking */ +check_pos: + if (cur != &fw) + break; /* reject as a valid format */ + goto retry; + case '%': + need_format = FALSE; + /* + * 29 Oct. 2002: + * The C99 standard pages 274 and 279 seem to imply that + * since there's no arg converted, the field width doesn't + * apply. The code already was that way, but this + * comment documents it, at least in the code. + */ + if (do_lint) { + const char *msg = NULL; + + if (fw && ! have_prec) + msg = _("field width is ignored for `%%' specifier"); + else if (fw == 0 && have_prec) + msg = _("precision is ignored for `%%' specifier"); + else if (fw && have_prec) + msg = _("field width and precision are ignored for `%%' specifier"); + + if (msg != NULL) + lintwarn("%s", msg); + } + bchunk_one("%"); + s0 = s1; + break; + + case '0': + /* + * Only turn on zero_flag if we haven't seen + * the field width or precision yet. Otherwise, + * screws up floating point formatting. + */ + if (cur == & fw) + zero_flag = TRUE; + if (lj) + goto retry; + /* FALL through */ + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (cur == NULL) + break; + if (prec >= 0) + *cur = cs1 - '0'; + /* + * with a negative precision *cur is already set + * to -1, so it will remain negative, but we have + * to "eat" precision digits in any case + */ + while (n0 > 0 && *s1 >= '0' && *s1 <= '9') { + --n0; + *cur = *cur * 10 + *s1++ - '0'; + } + if (prec < 0) /* negative precision is discarded */ + have_prec = FALSE; + if (cur == &prec) + cur = NULL; + if (n0 == 0) /* badly formatted control string */ + continue; + goto retry; + case '$': + if (do_traditional) { + msg(_("fatal: `$' is not permitted in awk formats")); + goto out; + } + + if (cur == &fw) { + argnum = fw; + fw = 0; + used_dollar = TRUE; + if (argnum <= 0) { + msg(_("fatal: arg count with `$' must be > 0")); + goto out; + } + if (argnum >= num_args) { + msg(_("fatal: arg count %ld greater than total number of supplied arguments"), argnum); + goto out; + } + } else { + msg(_("fatal: `$' not permitted after period in format")); + goto out; + } + + goto retry; + case '*': + if (cur == NULL) + break; + if (! do_traditional && isdigit((unsigned char) *s1)) { + int val = 0; + + for (; n0 > 0 && *s1 && isdigit((unsigned char) *s1); s1++, n0--) { + val *= 10; + val += *s1 - '0'; + } + if (*s1 != '$') { + msg(_("fatal: no `$' supplied for positional field width or precision")); + goto out; + } else { + s1++; + n0--; + } + if (val >= num_args) { + toofew = TRUE; + break; + } + arg = the_args[val]; + } else { + parse_next_arg(); + } + *cur = force_number(arg); + if (*cur < 0 && cur == &fw) { + *cur = -*cur; + lj++; + } + if (cur == &prec) { + if (*cur >= 0) + have_prec = TRUE; + else + have_prec = FALSE; + cur = NULL; + } + goto retry; + case ' ': /* print ' ' or '-' */ + /* 'space' flag is ignored */ + /* if '+' already present */ + if (signchar != FALSE) + goto check_pos; + /* FALL THROUGH */ + case '+': /* print '+' or '-' */ + signchar = cs1; + goto check_pos; + case '-': + if (prec < 0) + break; + if (cur == &prec) { + prec = -1; + goto retry; + } + fill = sp; /* if left justified then other */ + lj++; /* filling is ignored */ + goto check_pos; + case '.': + if (cur != &fw) + break; + cur = ≺ + have_prec = TRUE; + goto retry; + case '#': + alt = TRUE; + goto check_pos; + case '\'': +#if defined(HAVE_LOCALE_H) + /* allow quote_flag if there is a thousands separator. */ + if (loc.thousands_sep[0] != '\0') + quote_flag = TRUE; + goto check_pos; +#else + goto retry; +#endif + case 'l': + if (big_flag) + break; + else { + static short warned = FALSE; + + if (do_lint && ! warned) { + lintwarn(_("`l' is meaningless in awk formats; ignored")); + warned = TRUE; + } + if (do_posix) { + msg(_("fatal: `l' is not permitted in POSIX awk formats")); + goto out; + } + } + big_flag = TRUE; + goto retry; + case 'L': + if (bigbig_flag) + break; + else { + static short warned = FALSE; + + if (do_lint && ! warned) { + lintwarn(_("`L' is meaningless in awk formats; ignored")); + warned = TRUE; + } + if (do_posix) { + msg(_("fatal: `L' is not permitted in POSIX awk formats")); + goto out; + } + } + bigbig_flag = TRUE; + goto retry; + case 'h': + if (small_flag) + break; + else { + static short warned = FALSE; + + if (do_lint && ! warned) { + lintwarn(_("`h' is meaningless in awk formats; ignored")); + warned = TRUE; + } + if (do_posix) { + msg(_("fatal: `h' is not permitted in POSIX awk formats")); + goto out; + } + } + small_flag = TRUE; + goto retry; + case 'c': + need_format = FALSE; + parse_next_arg(); + /* user input that looks numeric is numeric */ + if ((arg->flags & (MAYBE_NUM|NUMBER)) == MAYBE_NUM) + (void) force_number(arg); + if (arg->flags & NUMBER) { + uval = (uintmax_t) arg->numbr; +#if MBS_SUPPORT + if (gawk_mb_cur_max > 1) { + char buf[100]; + wchar_t wc; + mbstate_t mbs; + size_t count; + + memset(& mbs, 0, sizeof(mbs)); + wc = uval; + + count = wcrtomb(buf, wc, & mbs); + if (count == 0 + || count == (size_t)-1 + || count == (size_t)-2) + goto out0; + + memcpy(cpbuf, buf, count); + prec = count; + cp = cpbuf; + goto pr_tail; + } +out0: + ; + /* else, + fall through */ +#endif + if (do_lint && uval > 255) { + lintwarn("[s]printf: value %g is too big for %%c format", + arg->numbr); + } + cpbuf[0] = uval; + prec = 1; + cp = cpbuf; + goto pr_tail; + } + /* + * As per POSIX, only output first character of a + * string value. Thus, we ignore any provided + * precision, forcing it to 1. (Didn't this + * used to work? 6/2003.) + */ + cp = arg->stptr; +#if MBS_SUPPORT + /* + * First character can be multiple bytes if + * it's a multibyte character. Grr. + */ + if (gawk_mb_cur_max > 1) { + mbstate_t state; + size_t count; + + memset(& state, 0, sizeof(state)); + count = mbrlen(cp, arg->stlen, & state); + if (count == 0 + || count == (size_t)-1 + || count == (size_t)-2) + goto out2; + prec = count; + goto pr_tail; + } +out2: + ; +#endif + prec = 1; + goto pr_tail; + case 's': + need_format = FALSE; + parse_next_arg(); + arg = force_string(arg); + if (fw == 0 && ! have_prec) + prec = arg->stlen; + else { + char_count = mbc_char_count(arg->stptr, arg->stlen); + if (! have_prec || prec > char_count) + prec = char_count; + } + cp = arg->stptr; + goto pr_tail; + case 'd': + case 'i': + need_format = FALSE; + parse_next_arg(); + tmpval = force_number(arg); + /* + * Check for Nan or Inf. + */ + if (isnan(tmpval) || isinf(tmpval)) + goto out_of_range; + else + tmpval = double_to_int(tmpval); + + /* + * ``The result of converting a zero value with a + * precision of zero is no characters.'' + */ + if (have_prec && prec == 0 && tmpval == 0) + goto pr_tail; + + if (tmpval < 0) { + tmpval = -tmpval; + sgn = TRUE; + } else { + if (tmpval == -0.0) + /* avoid printing -0 */ + tmpval = 0.0; + sgn = FALSE; + } + /* + * Use snprintf return value to tell if there + * is enough room in the buffer or not. + */ + while ((i = snprintf(cpbufs[1].buf, + cpbufs[1].bufsize, "%.0f", + tmpval)) >= + cpbufs[1].bufsize) { + if (cpbufs[1].buf == cpbufs[1].stackbuf) + cpbufs[1].buf = NULL; + if (i > 0) { + cpbufs[1].bufsize += ((i > cpbufs[1].bufsize) ? + i : cpbufs[1].bufsize); + } + else + cpbufs[1].bufsize *= 2; + assert(cpbufs[1].bufsize > 0); + erealloc(cpbufs[1].buf, char *, + cpbufs[1].bufsize, "format_tree"); + } + if (i < 1) + goto out_of_range; + chp = &cpbufs[1].buf[i-1]; + ii = jj = 0; + do { + PREPEND(*chp); + chp--; i--; +#if defined(HAVE_LOCALE_H) + if (quote_flag && loc.grouping[ii] && ++jj == loc.grouping[ii]) { + if (i) /* only add if more digits coming */ + PREPEND(loc.thousands_sep[0]); /* XXX - assumption it's one char */ + if (loc.grouping[ii+1] == 0) + jj = 0; /* keep using current val in loc.grouping[ii] */ + else if (loc.grouping[ii+1] == CHAR_MAX) + quote_flag = FALSE; + else { + ii++; + jj = 0; + } + } +#endif + } while (i > 0); + + /* add more output digits to match the precision */ + if (have_prec) { + while (cend - cp < prec) + PREPEND('0'); + } + + if (sgn) + PREPEND('-'); + else if (signchar) + PREPEND(signchar); + /* + * When to fill with zeroes is of course not simple. + * First: No zero fill if left-justifying. + * Next: There seem to be two cases: + * A '0' without a precision, e.g. %06d + * A precision with no field width, e.g. %.10d + * Any other case, we don't want to fill with zeroes. + */ + if (! lj + && ((zero_flag && ! have_prec) + || (fw == 0 && have_prec))) + fill = zero_string; + if (prec > fw) + fw = prec; + prec = cend - cp; + if (fw > prec && ! lj && fill != sp + && (*cp == '-' || signchar)) { + bchunk_one(cp); + cp++; + prec--; + fw--; + } + goto pr_tail; + case 'X': + chbuf = Uchbuf; /* FALL THROUGH */ + case 'x': + base += 6; /* FALL THROUGH */ + case 'u': + base += 2; /* FALL THROUGH */ + case 'o': + base += 8; + need_format = FALSE; + parse_next_arg(); + tmpval = force_number(arg); + + /* + * ``The result of converting a zero value with a + * precision of zero is no characters.'' + * + * If I remember the ANSI C standard, though, + * it says that for octal conversions + * the precision is artificially increased + * to add an extra 0 if # is supplied. + * Indeed, in C, + * printf("%#.0o\n", 0); + * prints a single 0. + */ + if (! alt && have_prec && prec == 0 && tmpval == 0) + goto pr_tail; + + if (tmpval < 0) { + uval = (uintmax_t) (intmax_t) tmpval; + if ((AWKNUM)(intmax_t)uval != + double_to_int(tmpval)) + goto out_of_range; + } else { + uval = (uintmax_t) tmpval; + if ((AWKNUM)uval != double_to_int(tmpval)) + goto out_of_range; + } + /* + * When to fill with zeroes is of course not simple. + * First: No zero fill if left-justifying. + * Next: There seem to be two cases: + * A '0' without a precision, e.g. %06d + * A precision with no field width, e.g. %.10d + * Any other case, we don't want to fill with zeroes. + */ + if (! lj + && ((zero_flag && ! have_prec) + || (fw == 0 && have_prec))) + fill = zero_string; + ii = jj = 0; + do { + PREPEND(chbuf[uval % base]); + uval /= base; +#if defined(HAVE_LOCALE_H) + if (base == 10 && quote_flag && loc.grouping[ii] && ++jj == loc.grouping[ii]) { + if (uval) /* only add if more digits coming */ + PREPEND(loc.thousands_sep[0]); /* XXX --- assumption it's one char */ + if (loc.grouping[ii+1] == 0) + jj = 0; /* keep using current val in loc.grouping[ii] */ + else if (loc.grouping[ii+1] == CHAR_MAX) + quote_flag = FALSE; + else { + ii++; + jj = 0; + } + } +#endif + } while (uval > 0); + + /* add more output digits to match the precision */ + if (have_prec) { + while (cend - cp < prec) + PREPEND('0'); + } + + if (alt && tmpval != 0) { + if (base == 16) { + PREPEND(cs1); + PREPEND('0'); + if (fill != sp) { + bchunk(cp, 2); + cp += 2; + fw -= 2; + } + } else if (base == 8) + PREPEND('0'); + } + base = 0; + if (prec > fw) + fw = prec; + prec = cend - cp; + pr_tail: + if (! lj) { + while (fw > prec) { + bchunk_one(fill); + fw--; + } + } + copy_count = prec; + if (fw == 0 && ! have_prec) + ; + else if (gawk_mb_cur_max > 1 && (cs1 == 's' || cs1 == 'c')) { + assert(cp == arg->stptr || cp == cpbuf); + copy_count = mbc_byte_count(arg->stptr, prec); + } + bchunk(cp, copy_count); + while (fw > prec) { + bchunk_one(fill); + fw--; + } + s0 = s1; + break; + + out_of_range: + /* out of range - emergency use of %g format */ + if (do_lint) + lintwarn(_("[s]printf: value %g is out of range for `%%%c' format"), + (double) tmpval, cs1); + cs1 = 'g'; + goto format_float; + + case 'F': +#if ! defined(PRINTF_HAS_F_FORMAT) || PRINTF_HAS_F_FORMAT != 1 + cs1 = 'f'; + /* FALL THROUGH */ +#endif + case 'g': + case 'G': + case 'e': + case 'f': + case 'E': + need_format = FALSE; + parse_next_arg(); + tmpval = force_number(arg); + format_float: + if (! have_prec) + prec = DEFAULT_G_PRECISION; + chksize(fw + prec + 9); /* 9 == slop */ + cp = cpbuf; + *cp++ = '%'; + if (lj) + *cp++ = '-'; + if (signchar) + *cp++ = signchar; + if (alt) + *cp++ = '#'; + if (zero_flag) + *cp++ = '0'; + if (quote_flag) + *cp++ = '\''; + strcpy(cp, "*.*"); + cp += 3; + *cp++ = cs1; + *cp = '\0'; +#if defined(LC_NUMERIC) + if (quote_flag && ! use_lc_numeric) + setlocale(LC_NUMERIC, ""); +#endif + { + int n; + while ((n = snprintf(obufout, ofre, cpbuf, + (int) fw, (int) prec, + (double) tmpval)) >= ofre) + chksize(n) + } +#if defined(LC_NUMERIC) + if (quote_flag && ! use_lc_numeric) + setlocale(LC_NUMERIC, "C"); +#endif + len = strlen(obufout); + ofre -= len; + obufout += len; + s0 = s1; + break; + default: + if (do_lint && isalpha(cs1)) + lintwarn(_("ignoring unknown format specifier character `%c': no argument converted"), cs1); + break; + } + if (toofew) { + msg("%s\n\t`%s'\n\t%*s%s", + _("fatal: not enough arguments to satisfy format string"), + fmt_string, (int) (s1 - fmt_string - 1), "", + _("^ ran out for this one")); + goto out; + } + } + if (do_lint) { + if (need_format) + lintwarn( + _("[s]printf: format specifier does not have control letter")); + if (cur_arg < num_args) + lintwarn( + _("too many arguments supplied for format string")); + } + bchunk(s0, s1 - s0); + r = make_str_node(obuf, obufout - obuf, ALREADY_MALLOCED); + obuf = NULL; +out: + { + size_t k; + size_t count = sizeof(cpbufs)/sizeof(cpbufs[0]); + for (k = 0; k < count; k++) { + if (cpbufs[k].buf != cpbufs[k].stackbuf) + efree(cpbufs[k].buf); + } + if (obuf != NULL) + efree(obuf); + } + if (r == NULL) + gawk_exit(EXIT_FATAL); + return r; +} + + +/* printf_common --- common code for sprintf and printf */ + +static NODE * +printf_common(int nargs) +{ + int i; + NODE *r, *tmp; + + assert(nargs <= max_args); + for (i = 1; i <= nargs; i++) { + tmp = args_array[nargs - i] = POP(); + if (tmp->type == Node_var_array) { + while (--i > 0) + DEREF(args_array[nargs - i]); + fatal(_("attempt to use array `%s' in a scalar context"), array_vname(tmp)); + } + } + + force_string(args_array[0]); + r = format_tree(args_array[0]->stptr, args_array[0]->stlen, args_array, nargs); + for (i = 0; i < nargs; i++) + DEREF(args_array[i]); + return r; +} + +/* do_sprintf --- perform sprintf */ + +NODE * +do_sprintf(int nargs) +{ + NODE *r; + r = printf_common(nargs); + if (r == NULL) + gawk_exit(EXIT_FATAL); + return r; +} + + +/* do_printf --- perform printf, including redirection */ + +void +do_printf(int nargs, int redirtype) +{ + FILE *fp = NULL; + NODE *tmp; + struct redirect *rp = NULL; + int errflg; /* not used, sigh */ + NODE *redir_exp = NULL; + + if (nargs == 0) { + if (do_traditional) { + if (do_lint) + lintwarn(_("printf: no arguments")); + if (redirtype != 0) { + redir_exp = TOP(); + if (redir_exp->type != Node_val) + fatal(_("attempt to use array `%s' in a scalar context"), array_vname(redir_exp)); + rp = redirect(redir_exp, redirtype, & errflg); + DEREF(redir_exp); + decr_sp(); + } + return; /* bwk accepts it silently */ + } + fatal(_("printf: no arguments")); + } + + if (redirtype != 0) { + redir_exp = PEEK(nargs); + if (redir_exp->type != Node_val) + fatal(_("attempt to use array `%s' in a scalar context"), array_vname(redir_exp)); + rp = redirect(redir_exp, redirtype, & errflg); + if (rp != NULL) + fp = rp->fp; + } else + fp = output_fp; + + tmp = printf_common(nargs); + if (redir_exp != NULL) { + DEREF(redir_exp); + decr_sp(); + } + if (tmp != NULL) { + if (fp == NULL) { + DEREF(tmp); + return; + } + efwrite(tmp->stptr, sizeof(char), tmp->stlen, fp, "printf", rp, TRUE); + if (rp != NULL && (rp->flag & RED_TWOWAY) != 0) + fflush(rp->fp); + DEREF(tmp); + } else + gawk_exit(EXIT_FATAL); +} + +/* do_sqrt --- do the sqrt function */ + +NODE * +do_sqrt(int nargs) +{ + NODE *tmp; + double arg; + + tmp = POP_SCALAR(); + if (do_lint && (tmp->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("sqrt: received non-numeric argument")); + arg = (double) force_number(tmp); + DEREF(tmp); + if (arg < 0.0) + warning(_("sqrt: called with negative argument %g"), arg); + return make_number((AWKNUM) sqrt(arg)); +} + +/* do_substr --- do the substr function */ + +NODE * +do_substr(int nargs) +{ + NODE *t1; + NODE *r; + size_t indx; + size_t length = 0; + double d_index = 0, d_length = 0; + size_t src_len; + + if (nargs == 3) + POP_NUMBER(d_length); + POP_NUMBER(d_index); + t1 = POP_STRING(); + + if (nargs == 3) { + if (! (d_length >= 1)) { + if (do_lint == LINT_ALL) + lintwarn(_("substr: length %g is not >= 1"), d_length); + else if (do_lint == LINT_INVALID && ! (d_length >= 0)) + lintwarn(_("substr: length %g is not >= 0"), d_length); + DEREF(t1); + return Nnull_string; + } + if (do_lint) { + if (double_to_int(d_length) != d_length) + lintwarn( + _("substr: non-integer length %g will be truncated"), + d_length); + + if (d_length > SIZE_MAX) + lintwarn( + _("substr: length %g too big for string indexing, truncating to %g"), + d_length, (double) SIZE_MAX); + } + if (d_length < SIZE_MAX) + length = d_length; + else + length = SIZE_MAX; + } + + /* the weird `! (foo)' tests help catch NaN values. */ + if (! (d_index >= 1)) { + if (do_lint) + lintwarn(_("substr: start index %g is invalid, using 1"), + d_index); + d_index = 1; + } + if (do_lint && double_to_int(d_index) != d_index) + lintwarn(_("substr: non-integer start index %g will be truncated"), + d_index); + + /* awk indices are from 1, C's are from 0 */ + if (d_index <= SIZE_MAX) + indx = d_index - 1; + else + indx = SIZE_MAX; + + if (nargs == 2) { /* third arg. missing */ + /* use remainder of string */ + length = t1->stlen - indx; /* default to bytes */ +#if MBS_SUPPORT + if (gawk_mb_cur_max > 1) { + t1 = force_wstring(t1); + if (t1->wstlen > 0) /* use length of wide char string if we have one */ + length = t1->wstlen - indx; + } +#endif + d_length = length; /* set here in case used in diagnostics, below */ + } + + if (t1->stlen == 0) { + /* substr("", 1, 0) produces a warning only if LINT_ALL */ + if (do_lint && (do_lint == LINT_ALL || ((indx | length) != 0))) + lintwarn(_("substr: source string is zero length")); + DEREF(t1); + return Nnull_string; + } + + /* get total len of input string, for following checks */ +#if MBS_SUPPORT + if (gawk_mb_cur_max > 1) { + t1 = force_wstring(t1); + src_len = t1->wstlen; + } else +#endif + src_len = t1->stlen; + + if (indx >= src_len) { + if (do_lint) + lintwarn(_("substr: start index %g is past end of string"), + d_index); + DEREF(t1); + return Nnull_string; + } + if (length > src_len - indx) { + if (do_lint) + lintwarn( + _("substr: length %g at start index %g exceeds length of first argument (%lu)"), + d_length, d_index, (unsigned long int) src_len); + length = src_len - indx; + } + +#if MBS_SUPPORT + /* force_wstring() already called */ + if (gawk_mb_cur_max == 1 || t1->wstlen == t1->stlen) + /* single byte case */ + r = make_string(t1->stptr + indx, length); + else { + /* multibyte case, more work */ + size_t result; + wchar_t *wp; + mbstate_t mbs; + char *substr, *cp; + + /* + * Convert the wide chars in t1->wstptr back into m.b. chars. + * This is pretty grotty, but it's the most straightforward + * way to do things. + */ + memset(& mbs, 0, sizeof(mbs)); + emalloc(substr, char *, (length * gawk_mb_cur_max) + 2, "do_substr"); + wp = t1->wstptr + indx; + for (cp = substr; length > 0; length--) { + result = wcrtomb(cp, *wp, & mbs); + if (result == (size_t) -1) /* what to do? break seems best */ + break; + cp += result; + wp++; + } + *cp = '\0'; + r = make_str_node(substr, cp - substr, ALREADY_MALLOCED); + } +#else + r = make_string(t1->stptr + indx, length); +#endif + + DEREF(t1); + return r; +} + +/* do_strftime --- format a time stamp */ + +NODE * +do_strftime(int nargs) +{ + NODE *t1, *t2, *t3, *ret; + struct tm *tm; + time_t fclock; + long clock_val; + char *bufp; + size_t buflen, bufsize; + char buf[BUFSIZ]; + const char *format; + int formatlen; + int do_gmt; + NODE *val = NULL; + NODE *sub = NULL; + + /* set defaults first */ + format = def_strftime_format; /* traditional date format */ + formatlen = strlen(format); + (void) time(& fclock); /* current time of day */ + do_gmt = FALSE; + + if (PROCINFO_node != NULL) { + sub = make_string("strftime", 8); + val = in_array(PROCINFO_node, sub); + unref(sub); + + if (val != NULL) { + if (do_lint && (val->flags & STRING) == 0) + lintwarn(_("strftime: format value in PROCINFO[\"strftime\"] has numeric type")); + val = force_string(val); + format = val->stptr; + formatlen = val->stlen; + } + } + + t1 = t2 = t3 = NULL; + if (nargs > 0) { /* have args */ + NODE *tmp; + + if (nargs == 3) { + t3 = POP_SCALAR(); + if ((t3->flags & (NUMCUR|NUMBER)) != 0) + do_gmt = (t3->numbr != 0); + else + do_gmt = (t3->stlen > 0); + DEREF(t3); + } + + if (nargs >= 2) { + t2 = POP_SCALAR(); + if (do_lint && (t2->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("strftime: received non-numeric second argument")); + clock_val = (long) force_number(t2); + if (clock_val < 0) + fatal(_("strftime: second argument less than 0 or too big for time_t")); + fclock = (time_t) clock_val; + DEREF(t2); + } + + tmp = POP_SCALAR(); + if (do_lint && (tmp->flags & (STRING|STRCUR)) == 0) + lintwarn(_("strftime: received non-string first argument")); + t1 = force_string(tmp); + format = t1->stptr; + formatlen = t1->stlen; + if (formatlen == 0) { + if (do_lint) + lintwarn(_("strftime: received empty format string")); + DEREF(t1); + return make_string("", 0); + } + } + + if (do_gmt) + tm = gmtime(& fclock); + else + tm = localtime(& fclock); + + bufp = buf; + bufsize = sizeof(buf); + for (;;) { + *bufp = '\0'; + buflen = strftime(bufp, bufsize, format, tm); + /* + * buflen can be zero EITHER because there's not enough + * room in the string, or because the control command + * goes to the empty string. Make a reasonable guess that + * if the buffer is 1024 times bigger than the length of the + * format string, it's not failing for lack of room. + * Thanks to Paul Eggert for pointing out this issue. + */ + if (buflen > 0 || bufsize >= 1024 * formatlen) + break; + bufsize *= 2; + if (bufp == buf) + emalloc(bufp, char *, bufsize, "do_strftime"); + else + erealloc(bufp, char *, bufsize, "do_strftime"); + } + ret = make_string(bufp, buflen); + if (bufp != buf) + efree(bufp); + if (t1) + DEREF(t1); + return ret; +} + +/* do_systime --- get the time of day */ + +NODE * +do_systime(int nargs ATTRIBUTE_UNUSED) +{ + time_t lclock; + + (void) time(& lclock); + return make_number((AWKNUM) lclock); +} + +/* do_mktime --- turn a time string into a timestamp */ + +NODE * +do_mktime(int nargs) +{ + NODE *t1; + struct tm then; + long year; + int month, day, hour, minute, second, count; + int dst = -1; /* default is unknown */ + time_t then_stamp; + char save; + + t1 = POP_SCALAR(); + if (do_lint && (t1->flags & (STRING|STRCUR)) == 0) + lintwarn(_("mktime: received non-string argument")); + t1 = force_string(t1); + + save = t1->stptr[t1->stlen]; + t1->stptr[t1->stlen] = '\0'; + + count = sscanf(t1->stptr, "%ld %d %d %d %d %d %d", + & year, & month, & day, + & hour, & minute, & second, + & dst); + + if (do_lint /* Ready? Set! Go: */ + && ( (second < 0 || second > 60) + || (minute < 0 || minute > 60) + || (hour < 0 || hour > 23) + || (day < 1 || day > 31) + || (month < 1 || month > 12) )) + lintwarn(_("mktime: at least one of the values is out of the default range")); + + t1->stptr[t1->stlen] = save; + DEREF(t1); + + if (count < 6 + || month == INT_MIN + || year < INT_MIN + 1900 + || year - 1900 > INT_MAX) + return make_number((AWKNUM) -1); + + memset(& then, '\0', sizeof(then)); + then.tm_sec = second; + then.tm_min = minute; + then.tm_hour = hour; + then.tm_mday = day; + then.tm_mon = month - 1; + then.tm_year = year - 1900; + then.tm_isdst = dst; + + then_stamp = mktime(& then); + return make_number((AWKNUM) then_stamp); +} + +/* do_system --- run an external command */ + +NODE * +do_system(int nargs) +{ + NODE *tmp; + int ret = 0; + char *cmd; + char save; + + if (do_sandbox) + fatal(_("'system' function not allowed in sandbox mode")); + + (void) flush_io(); /* so output is synchronous with gawk's */ + tmp = POP_SCALAR(); + if (do_lint && (tmp->flags & (STRING|STRCUR)) == 0) + lintwarn(_("system: received non-string argument")); + cmd = force_string(tmp)->stptr; + + if (cmd && *cmd) { + /* insure arg to system is zero-terminated */ + save = cmd[tmp->stlen]; + cmd[tmp->stlen] = '\0'; + + os_restore_mode(fileno(stdin)); + ret = system(cmd); + if (ret != -1) + ret = WEXITSTATUS(ret); + if ((BINMODE & 1) != 0) + os_setbinmode(fileno(stdin), O_BINARY); + + cmd[tmp->stlen] = save; + } + DEREF(tmp); + return make_number((AWKNUM) ret); +} + +extern NODE **fmt_list; /* declared in eval.c */ + +/* do_print --- print items, separated by OFS, terminated with ORS */ + +void +do_print(int nargs, int redirtype) +{ + struct redirect *rp = NULL; + int errflg; /* not used, sigh */ + FILE *fp = NULL; + int i; + NODE *redir_exp = NULL; + NODE *tmp; + + assert(nargs <= max_args); + + if (redirtype != 0) { + redir_exp = PEEK(nargs); + if (redir_exp->type != Node_val) + fatal(_("attempt to use array `%s' in a scalar context"), array_vname(redir_exp)); + rp = redirect(redir_exp, redirtype, & errflg); + if (rp != NULL) + fp = rp->fp; + } else + fp = output_fp; + + for (i = 1; i <= nargs; i++) { + tmp = args_array[i] = POP(); + if (tmp->type == Node_var_array) { + while (--i > 0) + DEREF(args_array[i]); + fatal(_("attempt to use array `%s' in a scalar context"), array_vname(tmp)); + } + if (do_lint && tmp->type == Node_var_new) + lintwarn(_("reference to uninitialized variable `%s'"), + tmp->vname); + if ((tmp->flags & (NUMBER|STRING)) == NUMBER) { + if (OFMTidx == CONVFMTidx) + (void) force_string(tmp); + else + args_array[i] = format_val(OFMT, OFMTidx, tmp); + } + } + + if (redir_exp != NULL) { + DEREF(redir_exp); + decr_sp(); + } + + if (fp == NULL) { + for (i = nargs; i > 0; i--) + DEREF(args_array[i]); + return; + } + + for (i = nargs; i > 0; i--) { + efwrite(args_array[i]->stptr, sizeof(char), args_array[i]->stlen, fp, "print", rp, FALSE); + DEREF(args_array[i]); + if (i != 1 && OFSlen > 0) + efwrite(OFS, sizeof(char), (size_t) OFSlen, + fp, "print", rp, FALSE); + + } + if (ORSlen > 0) + efwrite(ORS, sizeof(char), (size_t) ORSlen, fp, "print", rp, TRUE); + + if (rp != NULL && (rp->flag & RED_TWOWAY) != 0) + fflush(rp->fp); +} + +/* do_print_rec --- special case printing of $0, for speed */ + +void +do_print_rec(int nargs, int redirtype) +{ + FILE *fp = NULL; + NODE *f0; + struct redirect *rp = NULL; + int errflg; /* not used, sigh */ + NODE *redir_exp = NULL; + + assert(nargs == 0); + if (redirtype != 0) { + redir_exp = TOP(); + rp = redirect(redir_exp, redirtype, & errflg); + if (rp != NULL) + fp = rp->fp; + DEREF(redir_exp); + decr_sp(); + } else + fp = output_fp; + + if (fp == NULL) + return; + + if (! field0_valid) + (void) get_field(0L, NULL); /* rebuild record */ + + f0 = fields_arr[0]; + + if (do_lint && f0 == Nnull_string) + lintwarn(_("reference to uninitialized field `$%d'"), 0); + + efwrite(f0->stptr, sizeof(char), f0->stlen, fp, "print", rp, FALSE); + + if (ORSlen > 0) + efwrite(ORS, sizeof(char), (size_t) ORSlen, fp, "print", rp, TRUE); + + if (rp != NULL && (rp->flag & RED_TWOWAY) != 0) + fflush(rp->fp); +} + +#if MBS_SUPPORT + +/* is_wupper --- function version of iswupper for passing function pointers */ + +static int +is_wupper(wchar_t c) +{ + return iswupper(c); +} + +/* is_wlower --- function version of iswlower for passing function pointers */ + +static int +is_wlower(wchar_t c) +{ + return iswlower(c); +} + +/* to_wupper --- function version of towupper for passing function pointers */ + +static int +to_wlower(wchar_t c) +{ + return towlower(c); +} + +/* to_wlower --- function version of towlower for passing function pointers */ + +static int +to_wupper(wchar_t c) +{ + return towupper(c); +} + +/* wide_change_case --- generic case converter for wide characters */ + +static void +wide_change_case(wchar_t *wstr, + size_t wlen, + int (*is_x)(wchar_t c), + int (*to_y)(wchar_t c)) +{ + size_t i; + wchar_t *wcp; + + for (i = 0, wcp = wstr; i < wlen; i++, wcp++) + if (is_x(*wcp)) + *wcp = to_y(*wcp); +} + +/* wide_toupper --- map a wide string to upper case */ + +static void +wide_toupper(wchar_t *wstr, size_t wlen) +{ + wide_change_case(wstr, wlen, is_wlower, to_wupper); +} + +/* wide_tolower --- map a wide string to lower case */ + +static void +wide_tolower(wchar_t *wstr, size_t wlen) +{ + wide_change_case(wstr, wlen, is_wupper, to_wlower); +} +#endif + +/* do_tolower --- lower case a string */ + +NODE * +do_tolower(int nargs) +{ + NODE *t1, *t2; + + t1 = POP_SCALAR(); + if (do_lint && (t1->flags & (STRING|STRCUR)) == 0) + lintwarn(_("tolower: received non-string argument")); + t1 = force_string(t1); + t2 = make_string(t1->stptr, t1->stlen); + + if (gawk_mb_cur_max == 1) { + unsigned char *cp, *cp2; + + for (cp = (unsigned char *)t2->stptr, + cp2 = (unsigned char *)(t2->stptr + t2->stlen); + cp < cp2; cp++) + if (isupper(*cp)) + *cp = tolower(*cp); + } +#if MBS_SUPPORT + else { + force_wstring(t2); + wide_tolower(t2->wstptr, t2->wstlen); + wstr2str(t2); + } +#endif + + DEREF(t1); + return t2; +} + +/* do_toupper --- upper case a string */ + +NODE * +do_toupper(int nargs) +{ + NODE *t1, *t2; + + t1 = POP_SCALAR(); + if (do_lint && (t1->flags & (STRING|STRCUR)) == 0) + lintwarn(_("toupper: received non-string argument")); + t1 = force_string(t1); + t2 = make_string(t1->stptr, t1->stlen); + + if (gawk_mb_cur_max == 1) { + unsigned char *cp, *cp2; + + for (cp = (unsigned char *)t2->stptr, + cp2 = (unsigned char *)(t2->stptr + t2->stlen); + cp < cp2; cp++) + if (islower(*cp)) + *cp = toupper(*cp); + } +#if MBS_SUPPORT + else { + force_wstring(t2); + wide_toupper(t2->wstptr, t2->wstlen); + wstr2str(t2); + } +#endif + + DEREF(t1); + return t2; +} + +/* do_atan2 --- do the atan2 function */ + +NODE * +do_atan2(int nargs) +{ + NODE *t1, *t2; + double d1, d2; + + POP_TWO_SCALARS(t1, t2); + if (do_lint) { + if ((t1->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("atan2: received non-numeric first argument")); + if ((t2->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("atan2: received non-numeric second argument")); + } + d1 = force_number(t1); + d2 = force_number(t2); + DEREF(t1); + DEREF(t2); + return make_number((AWKNUM) atan2(d1, d2)); +} + +/* do_sin --- do the sin function */ + +NODE * +do_sin(int nargs) +{ + NODE *tmp; + double d; + + tmp = POP_SCALAR(); + if (do_lint && (tmp->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("sin: received non-numeric argument")); + d = sin((double) force_number(tmp)); + DEREF(tmp); + return make_number((AWKNUM) d); +} + +/* do_cos --- do the cos function */ + +NODE * +do_cos(int nargs) +{ + NODE *tmp; + double d; + + tmp = POP_SCALAR(); + if (do_lint && (tmp->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("cos: received non-numeric argument")); + d = cos((double) force_number(tmp)); + DEREF(tmp); + return make_number((AWKNUM) d); +} + +/* do_rand --- do the rand function */ + +static int firstrand = TRUE; +/* Some systems require this array to be integer aligned. Sigh. */ +#define SIZEOF_STATE 256 +static uint32_t istate[SIZEOF_STATE/sizeof(uint32_t)]; +static char *const state = (char *const) istate; + +/* ARGSUSED */ +NODE * +do_rand(int nargs ATTRIBUTE_UNUSED) +{ + if (firstrand) { + (void) initstate((unsigned) 1, state, SIZEOF_STATE); + /* don't need to srandom(1), initstate() does it for us. */ + firstrand = FALSE; + setstate(state); + } + /* + * Per historical practice and POSIX, return value N is + * + * 0 <= n < 1 + */ + return make_number((AWKNUM) (random() % GAWK_RANDOM_MAX) / GAWK_RANDOM_MAX); +} + +/* do_srand --- seed the random number generator */ + +NODE * +do_srand(int nargs) +{ + NODE *tmp; + static long save_seed = 1; + long ret = save_seed; /* SVR4 awk srand returns previous seed */ + + if (firstrand) { + (void) initstate((unsigned) 1, state, SIZEOF_STATE); + /* don't need to srandom(1), we're changing the seed below */ + firstrand = FALSE; + (void) setstate(state); + } + + if (nargs == 0) + srandom((unsigned int) (save_seed = (long) time((time_t *) 0))); + else { + tmp = POP_SCALAR(); + if (do_lint && (tmp->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("srand: received non-numeric argument")); + srandom((unsigned int) (save_seed = (long) force_number(tmp))); + DEREF(tmp); + } + return make_number((AWKNUM) ret); +} + +/* do_match --- match a regexp, set RSTART and RLENGTH, + * optional third arg is array filled with text of + * subpatterns enclosed in parens and start and len info. + */ + +NODE * +do_match(int nargs) +{ + NODE *tre, *t1, *dest, *it; + int rstart, len, ii; + int rlength; + Regexp *rp; + regoff_t s; + char *start; + char *buf = NULL; + char buff[100]; + size_t amt, oldamt = 0, ilen, slen; + char *subsepstr; + size_t subseplen; + + dest = NULL; + if (nargs == 3) { /* 3rd optional arg for the subpatterns */ + dest = POP_PARAM(); + if (dest->type != Node_var_array) + fatal(_("match: third argument is not an array")); + assoc_clear(dest); + } + tre = POP(); + rp = re_update(tre); + t1 = POP_STRING(); + + rstart = research(rp, t1->stptr, 0, t1->stlen, RE_NEED_START); + if (rstart >= 0) { /* match succeded */ + size_t *wc_indices = NULL; + + rlength = REEND(rp, t1->stptr) - RESTART(rp, t1->stptr); /* byte length */ +#if MBS_SUPPORT + if (rlength > 0 && gawk_mb_cur_max > 1) { + t1 = str2wstr(t1, & wc_indices); + rlength = wc_indices[rstart + rlength - 1] - wc_indices[rstart] + 1; + rstart = wc_indices[rstart]; + } +#endif + rstart++; /* now it's 1-based indexing */ + + /* Build the array only if the caller wants the optional subpatterns */ + if (dest != NULL) { + subsepstr = SUBSEP_node->var_value->stptr; + subseplen = SUBSEP_node->var_value->stlen; + + for (ii = 0; ii < NUMSUBPATS(rp, t1->stptr); ii++) { + /* + * Loop over all the subpats; some of them may have + * matched even if all of them did not. + */ + if ((s = SUBPATSTART(rp, t1->stptr, ii)) != -1) { + size_t subpat_start; + size_t subpat_len; + NODE **lhs; + NODE *sub; + + start = t1->stptr + s; + subpat_start = s; + subpat_len = len = SUBPATEND(rp, t1->stptr, ii) - s; +#if MBS_SUPPORT + if (len > 0 && gawk_mb_cur_max > 1) { + subpat_start = wc_indices[s]; + subpat_len = wc_indices[s + len - 1] - subpat_start + 1; + } +#endif + + it = make_string(start, len); + it->flags |= MAYBE_NUM; /* user input */ + + sub = make_number((AWKNUM) (ii)); + lhs = assoc_lookup(dest, sub, FALSE); + unref(*lhs); + *lhs = it; + unref(sub); + + sprintf(buff, "%d", ii); + ilen = strlen(buff); + amt = ilen + subseplen + strlen("length") + 2; + + if (oldamt == 0) { + emalloc(buf, char *, amt, "do_match"); + } else if (amt > oldamt) { + erealloc(buf, char *, amt, "do_match"); + } + oldamt = amt; + memcpy(buf, buff, ilen); + memcpy(buf + ilen, subsepstr, subseplen); + memcpy(buf + ilen + subseplen, "start", 6); + + slen = ilen + subseplen + 5; + + it = make_number((AWKNUM) subpat_start + 1); + sub = make_string(buf, slen); + lhs = assoc_lookup(dest, sub, FALSE); + unref(*lhs); + *lhs = it; + unref(sub); + + memcpy(buf, buff, ilen); + memcpy(buf + ilen, subsepstr, subseplen); + memcpy(buf + ilen + subseplen, "length", 7); + + slen = ilen + subseplen + 6; + + it = make_number((AWKNUM) subpat_len); + sub = make_string(buf, slen); + lhs = assoc_lookup(dest, sub, FALSE); + unref(*lhs); + *lhs = it; + unref(sub); + } + } + + efree(buf); + } + if (wc_indices != NULL) + efree(wc_indices); + } else { /* match failed */ + rstart = 0; + rlength = -1; + } + + DEREF(t1); + unref(RSTART_node->var_value); + RSTART_node->var_value = make_number((AWKNUM) rstart); + unref(RLENGTH_node->var_value); + RLENGTH_node->var_value = make_number((AWKNUM) rlength); + return make_number((AWKNUM) rstart); +} + +/* do_sub --- do the work for sub, gsub, and gensub */ + +/* + * Gsub can be tricksy; particularly when handling the case of null strings. + * The following awk code was useful in debugging problems. It is too bad + * that it does not readily translate directly into the C code, below. + * + * #! /usr/local/bin/mawk -f + * + * BEGIN { + * TRUE = 1; FALSE = 0 + * print "--->", mygsub("abc", "b+", "FOO") + * print "--->", mygsub("abc", "x*", "X") + * print "--->", mygsub("abc", "b*", "X") + * print "--->", mygsub("abc", "c", "X") + * print "--->", mygsub("abc", "c+", "X") + * print "--->", mygsub("abc", "x*$", "X") + * } + * + * function mygsub(str, regex, replace, origstr, newstr, eosflag, nonzeroflag) + * { + * origstr = str; + * eosflag = nonzeroflag = FALSE + * while (match(str, regex)) { + * if (RLENGTH > 0) { # easy case + * nonzeroflag = TRUE + * if (RSTART == 1) { # match at front of string + * newstr = newstr replace + * } else { + * newstr = newstr substr(str, 1, RSTART-1) replace + * } + * str = substr(str, RSTART+RLENGTH) + * } else if (nonzeroflag) { + * # last match was non-zero in length, and at the + * # current character, we get a zero length match, + * # which we don't really want, so skip over it + * newstr = newstr substr(str, 1, 1) + * str = substr(str, 2) + * nonzeroflag = FALSE + * } else { + * # 0-length match + * if (RSTART == 1) { + * newstr = newstr replace substr(str, 1, 1) + * str = substr(str, 2) + * } else { + * return newstr str replace + * } + * } + * if (length(str) == 0) + * if (eosflag) + * break + * else + * eosflag = TRUE + * } + * if (length(str) > 0) + * newstr = newstr str # rest of string + * + * return newstr + * } + */ + +/* + * 1/2004: The gawk sub/gsub behavior dates from 1996, when we proposed it + * for POSIX. The proposal fell through the cracks, and the 2001 POSIX + * standard chose a more simple behavior. + * + * The relevant text is to be found on lines 6394-6407 (pages 166, 167) of the + * 2001 standard: + * + * sub(ere, repl[, in ]) + * Substitute the string repl in place of the first instance of the extended regular + * expression ERE in string in and return the number of substitutions. An ampersand + * ('&') appearing in the string repl shall be replaced by the string from in that + * matches the ERE. An ampersand preceded with a backslash ('\') shall be + * interpreted as the literal ampersand character. An occurrence of two consecutive + * backslashes shall be interpreted as just a single literal backslash character. Any + * other occurrence of a backslash (for example, preceding any other character) shall + * be treated as a literal backslash character. Note that if repl is a string literal (the + * lexical token STRING; see Grammar (on page 170)), the handling of the + * ampersand character occurs after any lexical processing, including any lexical + * backslash escape sequence processing. If in is specified and it is not an lvalue (see + * Expressions in awk (on page 156)), the behavior is undefined. If in is omitted, awk + * shall use the current record ($0) in its place. + * + * 11/2010: The text in the 2008 standard is the same as just quoted. However, POSIX behavior + * is now the default. This can change the behavior of awk programs. The old behavior + * is not available. + */ + +/* + * NB: `howmany' conflicts with a SunOS 4.x macro in . + */ + +NODE * +do_sub(int nargs, unsigned int flags) +{ + char *scan; + char *bp, *cp; + char *buf = NULL; + size_t buflen; + char *matchend; + size_t len; + char *matchstart; + char *text; + size_t textlen = 0; + char *repl; + char *replend; + size_t repllen; + int sofar; + int ampersands; + int matches = 0; + Regexp *rp; + NODE *s; /* subst. pattern */ + NODE *t; /* string to make sub. in; $0 if none given */ + NODE *tmp; + NODE **lhs = NULL; + long how_many = 1; /* one substitution for sub, also gensub default */ + int global; + long current; + int lastmatchnonzero; + char *mb_indices = NULL; + + if ((flags & GENSUB) != 0) { + double d; + NODE *t1; + + tmp = PEEK(3); + rp = re_update(tmp); + + t = POP_STRING(); /* original string */ + + t1 = POP_SCALAR(); /* value of global flag */ + if ((t1->flags & (STRCUR|STRING)) != 0) { + if (t1->stlen > 0 && (t1->stptr[0] == 'g' || t1->stptr[0] == 'G')) + how_many = -1; + else { + d = force_number(t1); + + if ((t1->flags & NUMCUR) != 0) + goto set_how_many; + + how_many = 1; + } + } else { + d = force_number(t1); +set_how_many: + if (d < 1) + how_many = 1; + else if (d < LONG_MAX) + how_many = d; + else + how_many = LONG_MAX; + if (d == 0) + warning(_("gensub: third argument of 0 treated as 1")); + } + DEREF(t1); + + } else { + + /* take care of regexp early, in case re_update is fatal */ + + tmp = PEEK(2); + rp = re_update(tmp); + + if ((flags & GSUB) != 0) + how_many = -1; + + /* original string */ + + if ((flags & LITERAL) != 0) + t = POP_STRING(); + else { + lhs = POP_ADDRESS(); + t = force_string(*lhs); + } + } + + global = (how_many == -1); + + s = POP_STRING(); /* replacement text */ + decr_sp(); /* regexp, already updated above */ + + /* do the search early to avoid work on non-match */ + if (research(rp, t->stptr, 0, t->stlen, RE_NEED_START) == -1 || + RESTART(rp, t->stptr) > t->stlen) + goto done; + + t->flags |= STRING; + + text = t->stptr; + textlen = t->stlen; + buflen = textlen + 2; + + repl = s->stptr; + replend = repl + s->stlen; + repllen = replend - repl; + emalloc(buf, char *, buflen + 2, "do_sub"); + buf[buflen] = '\0'; + buf[buflen + 1] = '\0'; + ampersands = 0; + + /* + * Some systems' malloc() can't handle being called with an + * argument of zero. Thus we have to have some special case + * code to check for `repllen == 0'. This can occur for + * something like: + * sub(/foo/, "", mystring) + * for example. + */ + if (gawk_mb_cur_max > 1 && repllen > 0) { + emalloc(mb_indices, char *, repllen * sizeof(char), "do_sub"); + index_multibyte_buffer(repl, mb_indices, repllen); + } + + for (scan = repl; scan < replend; scan++) { + if ((gawk_mb_cur_max == 1 || (repllen > 0 && mb_indices[scan - repl] == 1)) + && (*scan == '&')) { + repllen--; + ampersands++; + } else if (*scan == '\\') { + if (flags & GENSUB) { /* gensub, behave sanely */ + if (isdigit((unsigned char) scan[1])) { + ampersands++; + scan++; + } else { /* \q for any q --> q */ + repllen--; + scan++; + } + } else if (do_posix) { + /* \& --> &, \\ --> \ */ + if (scan[1] == '&' || scan[1] == '\\') { + repllen--; + scan++; + } /* else + leave alone, it goes into the output */ + } else { + /* gawk default behavior since 1996 */ + if (strncmp(scan, "\\\\\\&", 4) == 0) { + /* \\\& --> \& */ + repllen -= 2; + scan += 3; + } else if (strncmp(scan, "\\\\&", 3) == 0) { + /* \\& --> \ */ + ampersands++; + repllen--; + scan += 2; + } else if (scan[1] == '&') { + /* \& --> & */ + repllen--; + scan++; + } /* else + leave alone, it goes into the output */ + } + } + } + + lastmatchnonzero = FALSE; + bp = buf; + for (current = 1;; current++) { + matches++; + matchstart = t->stptr + RESTART(rp, t->stptr); + matchend = t->stptr + REEND(rp, t->stptr); + + /* + * create the result, copying in parts of the original + * string + */ + len = matchstart - text + repllen + + ampersands * (matchend - matchstart); + sofar = bp - buf; + while (buflen < (sofar + len + 1)) { + buflen *= 2; + erealloc(buf, char *, buflen, "sub_common"); + bp = buf + sofar; + } + for (scan = text; scan < matchstart; scan++) + *bp++ = *scan; + if (global || current == how_many) { + /* + * If the current match matched the null string, + * and the last match didn't and did a replacement, + * and the match of the null string is at the front of + * the text (meaning right after end of the previous + * replacement), then skip this one. + */ + if (matchstart == matchend + && lastmatchnonzero + && matchstart == text) { + lastmatchnonzero = FALSE; + matches--; + goto empty; + } + /* + * If replacing all occurrences, or this is the + * match we want, copy in the replacement text, + * making substitutions as we go. + */ + for (scan = repl; scan < replend; scan++) + if (*scan == '&' + /* + * Don't test repllen here. A simple "&" could + * end up with repllen == 0. + */ + && (gawk_mb_cur_max == 1 + || mb_indices[scan - repl] == 1) + ) { + for (cp = matchstart; cp < matchend; cp++) + *bp++ = *cp; + } else if (*scan == '\\' + && (gawk_mb_cur_max == 1 + || (repllen > 0 && mb_indices[scan - repl] == 1)) + ) { + if (flags & GENSUB) { /* gensub, behave sanely */ + if (isdigit((unsigned char) scan[1])) { + int dig = scan[1] - '0'; + if (dig < NUMSUBPATS(rp, t->stptr) && SUBPATSTART(rp, tp->stptr, dig) != -1) { + char *start, *end; + + start = t->stptr + + SUBPATSTART(rp, t->stptr, dig); + end = t->stptr + + SUBPATEND(rp, t->stptr, dig); + + for (cp = start; cp < end; cp++) + *bp++ = *cp; + } + scan++; + } else /* \q for any q --> q */ + *bp++ = *++scan; + } else if (do_posix) { + /* \& --> &, \\ --> \ */ + if (scan[1] == '&' || scan[1] == '\\') + scan++; + *bp++ = *scan; + } else { + /* gawk default behavior since 1996 */ + if (strncmp(scan, "\\\\\\&", 4) == 0) { + /* \\\& --> \& */ + *bp++ = '\\'; + *bp++ = '&'; + scan += 3; + } else if (strncmp(scan, "\\\\&", 3) == 0) { + /* \\& --> \ */ + *bp++ = '\\'; + for (cp = matchstart; cp < matchend; cp++) + *bp++ = *cp; + scan += 2; + } else if (scan[1] == '&') { + /* \& --> & */ + *bp++ = '&'; + scan++; + } else + *bp++ = *scan; + } + } else + *bp++ = *scan; + if (matchstart != matchend) + lastmatchnonzero = TRUE; + } else { + /* + * don't want this match, skip over it by copying + * in current text. + */ + for (cp = matchstart; cp < matchend; cp++) + *bp++ = *cp; + } + empty: + /* catch the case of gsub(//, "blah", whatever), i.e. empty regexp */ + if (matchstart == matchend && matchend < text + textlen) { + *bp++ = *matchend; + matchend++; + } + textlen = text + textlen - matchend; + text = matchend; + + if ((current >= how_many && ! global) + || ((long) textlen <= 0 && matchstart == matchend) + || research(rp, t->stptr, text - t->stptr, textlen, RE_NEED_START) == -1) + break; + + } + sofar = bp - buf; + if (buflen - sofar - textlen - 1) { + buflen = sofar + textlen + 2; + erealloc(buf, char *, buflen, "do_sub"); + bp = buf + sofar; + } + for (scan = matchend; scan < text + textlen; scan++) + *bp++ = *scan; + *bp = '\0'; + textlen = bp - buf; + + if (mb_indices != NULL) + efree(mb_indices); + +done: + DEREF(s); + + if ((matches == 0 || (flags & LITERAL) != 0) && buf != NULL) + efree(buf); + + if (flags & GENSUB) { + if (matches > 0) { + /* return the result string */ + DEREF(t); + return make_str_node(buf, textlen, ALREADY_MALLOCED); + } + + /* return the original string */ + return t; + } + + /* For a string literal, must not change the original string. */ + if (flags & LITERAL) + DEREF(t); + else if (matches > 0) { + unref(*lhs); + *lhs = make_str_node(buf, textlen, ALREADY_MALLOCED); + } + + return make_number((AWKNUM) matches); +} + + +/* make_integer - Convert an integer to a number node. */ + +static NODE * +make_integer(uintmax_t n) +{ + n = adjust_uint(n); + + return make_number((AWKNUM) n); +} + +/* do_lshift --- perform a << operation */ + +NODE * +do_lshift(int nargs) +{ + NODE *s1, *s2; + uintmax_t uval, ushift, res; + AWKNUM val, shift; + + POP_TWO_SCALARS(s1, s2); + if (do_lint) { + if ((s1->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("lshift: received non-numeric first argument")); + if ((s2->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("lshift: received non-numeric second argument")); + } + val = force_number(s1); + shift = force_number(s2); + if (do_lint) { + if (val < 0 || shift < 0) + lintwarn(_("lshift(%lf, %lf): negative values will give strange results"), val, shift); + if (double_to_int(val) != val || double_to_int(shift) != shift) + lintwarn(_("lshift(%lf, %lf): fractional values will be truncated"), val, shift); + if (shift >= sizeof(uintmax_t) * CHAR_BIT) + lintwarn(_("lshift(%lf, %lf): too large shift value will give strange results"), val, shift); + } + + DEREF(s1); + DEREF(s2); + + uval = (uintmax_t) val; + ushift = (uintmax_t) shift; + + res = uval << ushift; + return make_integer(res); +} + +/* do_rshift --- perform a >> operation */ + +NODE * +do_rshift(int nargs) +{ + NODE *s1, *s2; + uintmax_t uval, ushift, res; + AWKNUM val, shift; + + POP_TWO_SCALARS(s1, s2); + if (do_lint) { + if ((s1->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("rshift: received non-numeric first argument")); + if ((s2->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("rshift: received non-numeric second argument")); + } + val = force_number(s1); + shift = force_number(s2); + if (do_lint) { + if (val < 0 || shift < 0) + lintwarn(_("rshift(%lf, %lf): negative values will give strange results"), val, shift); + if (double_to_int(val) != val || double_to_int(shift) != shift) + lintwarn(_("rshift(%lf, %lf): fractional values will be truncated"), val, shift); + if (shift >= sizeof(uintmax_t) * CHAR_BIT) + lintwarn(_("rshift(%lf, %lf): too large shift value will give strange results"), val, shift); + } + + DEREF(s1); + DEREF(s2); + + uval = (uintmax_t) val; + ushift = (uintmax_t) shift; + + res = uval >> ushift; + return make_integer(res); +} + +/* do_and --- perform an & operation */ + +NODE * +do_and(int nargs) +{ + NODE *s1, *s2; + uintmax_t uleft, uright, res; + AWKNUM left, right; + + POP_TWO_SCALARS(s1, s2); + if (do_lint) { + if ((s1->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("and: received non-numeric first argument")); + if ((s2->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("and: received non-numeric second argument")); + } + left = force_number(s1); + right = force_number(s2); + if (do_lint) { + if (left < 0 || right < 0) + lintwarn(_("and(%lf, %lf): negative values will give strange results"), left, right); + if (double_to_int(left) != left || double_to_int(right) != right) + lintwarn(_("and(%lf, %lf): fractional values will be truncated"), left, right); + } + + DEREF(s1); + DEREF(s2); + + uleft = (uintmax_t) left; + uright = (uintmax_t) right; + + res = uleft & uright; + return make_integer(res); +} + +/* do_or --- perform an | operation */ + +NODE * +do_or(int nargs) +{ + NODE *s1, *s2; + uintmax_t uleft, uright, res; + AWKNUM left, right; + + POP_TWO_SCALARS(s1, s2); + if (do_lint) { + if ((s1->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("or: received non-numeric first argument")); + if ((s2->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("or: received non-numeric second argument")); + } + left = force_number(s1); + right = force_number(s2); + if (do_lint) { + if (left < 0 || right < 0) + lintwarn(_("or(%lf, %lf): negative values will give strange results"), left, right); + if (double_to_int(left) != left || double_to_int(right) != right) + lintwarn(_("or(%lf, %lf): fractional values will be truncated"), left, right); + } + + DEREF(s1); + DEREF(s2); + + uleft = (uintmax_t) left; + uright = (uintmax_t) right; + + res = uleft | uright; + return make_integer(res); +} + +/* do_xor --- perform an ^ operation */ + +NODE * +do_xor(int nargs) +{ + NODE *s1, *s2; + uintmax_t uleft, uright, res; + AWKNUM left, right; + + POP_TWO_SCALARS(s1, s2); + left = force_number(s1); + right = force_number(s2); + + if (do_lint) { + if ((s1->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("xor: received non-numeric first argument")); + if ((s2->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("xor: received non-numeric second argument")); + } + left = force_number(s1); + right = force_number(s2); + if (do_lint) { + if (left < 0 || right < 0) + lintwarn(_("xor(%lf, %lf): negative values will give strange results"), left, right); + if (double_to_int(left) != left || double_to_int(right) != right) + lintwarn(_("xor(%lf, %lf): fractional values will be truncated"), left, right); + } + + DEREF(s1); + DEREF(s2); + + uleft = (uintmax_t) left; + uright = (uintmax_t) right; + + res = uleft ^ uright; + return make_integer(res); +} + +/* do_compl --- perform a ~ operation */ + +NODE * +do_compl(int nargs) +{ + NODE *tmp; + double d; + uintmax_t uval; + + tmp = POP_SCALAR(); + if (do_lint && (tmp->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("compl: received non-numeric argument")); + d = force_number(tmp); + DEREF(tmp); + + if (do_lint) { + if ((tmp->flags & (NUMCUR|NUMBER)) == 0) + lintwarn(_("compl: received non-numeric argument")); + if (d < 0) + lintwarn(_("compl(%lf): negative value will give strange results"), d); + if (double_to_int(d) != d) + lintwarn(_("compl(%lf): fractional value will be truncated"), d); + } + + uval = (uintmax_t) d; + uval = ~ uval; + return make_integer(uval); +} + +/* do_strtonum --- the strtonum function */ + +NODE * +do_strtonum(int nargs) +{ + NODE *tmp; + AWKNUM d; + + tmp = POP_SCALAR(); + if ((tmp->flags & (NUMBER|NUMCUR)) != 0) + d = (AWKNUM) force_number(tmp); + else if (isnondecimal(tmp->stptr, use_lc_numeric)) + d = nondec2awknum(tmp->stptr, tmp->stlen); + else + d = (AWKNUM) force_number(tmp); + + DEREF(tmp); + return make_number((AWKNUM) d); +} + +/* nondec2awknum --- convert octal or hex value to double */ + +/* + * Because of awk's concatenation rules and the way awk.y:yylex() + * collects a number, this routine has to be willing to stop on the + * first invalid character. + */ + +AWKNUM +nondec2awknum(char *str, size_t len) +{ + AWKNUM retval = 0.0; + char save; + short val; + char *start = str; + + if (*str == '0' && (str[1] == 'x' || str[1] == 'X')) { + /* + * User called strtonum("0x") or some such, + * so just quit early. + */ + if (len <= 2) + return (AWKNUM) 0.0; + + for (str += 2, len -= 2; len > 0; len--, str++) { + switch (*str) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + val = *str - '0'; + break; + case 'a': + case 'b': + case 'c': + case 'd': + case 'e': + case 'f': + val = *str - 'a' + 10; + break; + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + val = *str - 'A' + 10; + break; + default: + goto done; + } + retval = (retval * 16) + val; + } + } else if (*str == '0') { + for (; len > 0; len--) { + if (! isdigit((unsigned char) *str)) + goto done; + else if (*str == '8' || *str == '9') { + str = start; + goto decimal; + } + retval = (retval * 8) + (*str - '0'); + str++; + } + } else { +decimal: + save = str[len]; + retval = strtod(str, NULL); + str[len] = save; + } +done: + return retval; +} + +/* do_dcgettext, do_dcngettext --- handle i18n translations */ + +#if ENABLE_NLS && defined(LC_MESSAGES) && HAVE_DCGETTEXT + +static int +localecategory_from_argument(NODE *t) +{ + static const struct category_table { + int val; + const char *name; + } cat_tab[] = { +#ifdef LC_ALL + { LC_ALL, "LC_ALL" }, +#endif /* LC_ALL */ +#ifdef LC_COLLATE + { LC_COLLATE, "LC_COLLATE" }, +#endif /* LC_COLLATE */ +#ifdef LC_CTYPE + { LC_CTYPE, "LC_CTYPE" }, +#endif /* LC_CTYPE */ +#ifdef LC_MESSAGES + { LC_MESSAGES, "LC_MESSAGES" }, +#endif /* LC_MESSAGES */ +#ifdef LC_MONETARY + { LC_MONETARY, "LC_MONETARY" }, +#endif /* LC_MONETARY */ +#ifdef LC_NUMERIC + { LC_NUMERIC, "LC_NUMERIC" }, +#endif /* LC_NUMERIC */ +#ifdef LC_RESPONSE + { LC_RESPONSE, "LC_RESPONSE" }, +#endif /* LC_RESPONSE */ +#ifdef LC_TIME + { LC_TIME, "LC_TIME" }, +#endif /* LC_TIME */ + }; + + if (t != NULL) { + int low, high, i, mid; + char *category; + int lc_cat = -1; + + category = t->stptr; + + /* binary search the table */ + low = 0; + high = (sizeof(cat_tab) / sizeof(cat_tab[0])) - 1; + while (low <= high) { + mid = (low + high) / 2; + i = strcmp(category, cat_tab[mid].name); + + if (i < 0) /* category < mid */ + high = mid - 1; + else if (i > 0) /* category > mid */ + low = mid + 1; + else { + lc_cat = cat_tab[mid].val; + break; + } + } + if (lc_cat == -1) /* not there */ + fatal(_("dcgettext: `%s' is not a valid locale category"), category); + + return lc_cat; + } else + return LC_MESSAGES; +} + +#endif + +/* + * awk usage is + * + * str = dcgettext(string [, domain [, category]]) + * str = dcngettext(string1, string2, number [, domain [, category]]) + * + * Default domain is TEXTDOMAIN, default category is LC_MESSAGES. + */ + +NODE * +do_dcgettext(int nargs) +{ + NODE *tmp, *t1, *t2 = NULL; + char *string; + char *the_result; +#if ENABLE_NLS && defined(LC_MESSAGES) && HAVE_DCGETTEXT + int lc_cat; + char *domain; + + if (nargs == 3) { /* third argument */ + tmp = POP_STRING(); + lc_cat = localecategory_from_argument(tmp); + DEREF(tmp); + } else + lc_cat = LC_MESSAGES; + + if (nargs >= 2) { /* second argument */ + t2 = POP_STRING(); + domain = t2->stptr; + } else + domain = TEXTDOMAIN; +#else + if (nargs == 3) { + tmp = POP_STRING(); + DEREF(tmp); + } + if (nargs >= 2) { + t2 = POP_STRING(); + DEREF(t2); + } +#endif + + t1 = POP_STRING(); /* first argument */ + string = t1->stptr; + +#if ENABLE_NLS && defined(LC_MESSAGES) && HAVE_DCGETTEXT + the_result = dcgettext(domain, string, lc_cat); + if (t2 != NULL) + DEREF(t2); +#else + the_result = string; +#endif + DEREF(t1); + return make_string(the_result, strlen(the_result)); +} + + +NODE * +do_dcngettext(int nargs) +{ + NODE *tmp, *t1, *t2, *t3; + char *string1, *string2; + unsigned long number; + AWKNUM d; + char *the_result; + +#if ENABLE_NLS && defined(LC_MESSAGES) && HAVE_DCGETTEXT + int lc_cat; + char *domain; + + if (nargs == 5) { /* fifth argument */ + tmp = POP_STRING(); + lc_cat = localecategory_from_argument(tmp); + DEREF(tmp); + } else + lc_cat = LC_MESSAGES; + + t3 = NULL; + if (nargs >= 4) { /* fourth argument */ + t3 = POP_STRING(); + domain = t3->stptr; + } else + domain = TEXTDOMAIN; +#else + if (nargs == 5) { + tmp = POP_STRING(); + DEREF(tmp); + } + if (nargs >= 4) { + t3 = POP_STRING(); + DEREF(t3); + } +#endif + + POP_NUMBER(d); /* third argument */ + number = (unsigned long) double_to_int(d); + t2 = POP_STRING(); /* second argument */ + string2 = t2->stptr; + t1 = POP_STRING(); /* first argument */ + string1 = t1->stptr; + +#if ENABLE_NLS && defined(LC_MESSAGES) && HAVE_DCGETTEXT + + the_result = dcngettext(domain, string1, string2, number, lc_cat); + if (t3 != NULL) + DEREF(t3); +#else + the_result = (number == 1 ? string1 : string2); +#endif + DEREF(t1); + DEREF(t2); + return make_string(the_result, strlen(the_result)); +} + +/* do_bindtextdomain --- set the directory for a text domain */ + +/* + * awk usage is + * + * binding = bindtextdomain(dir [, domain]) + * + * If dir is "", pass NULL to C version. + * Default domain is TEXTDOMAIN. + */ + +NODE * +do_bindtextdomain(int nargs) +{ + NODE *t1, *t2; + const char *directory, *domain; + const char *the_result; + + t1 = t2 = NULL; + /* set defaults */ + directory = NULL; + domain = TEXTDOMAIN; + + if (nargs == 2) { /* second argument */ + t2 = POP_STRING(); + domain = (const char *) t2->stptr; + } + + /* first argument */ + t1 = POP_STRING(); + if (t1->stlen > 0) + directory = (const char *) t1->stptr; + + the_result = bindtextdomain(domain, directory); + + DEREF(t1); + if (t2 != NULL) + DEREF(t2); + + return make_string(the_result, strlen(the_result)); +} + + +/* mbc_byte_count --- return number of bytes for corresponding numchars multibyte characters */ + +static size_t +mbc_byte_count(const char *ptr, size_t numchars) +{ +#if MBS_SUPPORT + mbstate_t cur_state; + size_t sum = 0; + int mb_len; + + memset(& cur_state, 0, sizeof(cur_state)); + + assert(gawk_mb_cur_max > 1); + mb_len = mbrlen(ptr, numchars * gawk_mb_cur_max, &cur_state); + if (mb_len <= 0) + return numchars; /* no valid m.b. char */ + + for (; numchars > 0; numchars--) { + mb_len = mbrlen(ptr, numchars * gawk_mb_cur_max, &cur_state); + if (mb_len <= 0) + break; + sum += mb_len; + ptr += mb_len; + } + + return sum; +#else + return numchars; +#endif +} + +/* mbc_char_count --- return number of m.b. chars in string, up to numbytes bytes */ + +static size_t +mbc_char_count(const char *ptr, size_t numbytes) +{ +#if MBS_SUPPORT + mbstate_t cur_state; + size_t sum = 0; + int mb_len; + + if (gawk_mb_cur_max == 1) + return numbytes; + + memset(& cur_state, 0, sizeof(cur_state)); + + mb_len = mbrlen(ptr, numbytes * gawk_mb_cur_max, &cur_state); + if (mb_len <= 0) + return numbytes; /* no valid m.b. char */ + + for (; numbytes > 0; numbytes--) { + mb_len = mbrlen(ptr, numbytes * gawk_mb_cur_max, &cur_state); + if (mb_len <= 0) + break; + sum++; + ptr += mb_len; + } + + return sum; +#else + return numbytes; +#endif +} diff --git a/cmd.h b/cmd.h new file mode 100644 index 0000000..a0c1788 --- /dev/null +++ b/cmd.h @@ -0,0 +1,213 @@ +/* + * cmd.h - definitions for command parser + */ + +/* + * Copyright (C) 2004, 2010, 2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#ifdef HAVE_LIBREADLINE +#include +#include +extern char **command_completion(const char *text, int start, int end); +extern void initialize_pager(FILE *fp); /* debug.c */ +extern NODE **get_varlist(void); +extern char **get_parmlist(void); +#else +#define initialize_pager(x) /* nothing */ +#define add_history(x) /* nothing */ +#endif + +extern int gprintf(FILE *fp, const char *format, ...); +extern jmp_buf pager_quit_tag; +extern int pager_quit_tag_valid; + +extern int output_is_tty; +extern int input_fd; +extern int input_from_tty; +extern FILE *out_fp; +extern char *dPrompt; +extern char *commands_Prompt; +extern char *eval_Prompt; +extern char *dgawk_Prompt; + +enum argtype { + D_illegal, + + /* commands */ + D_backtrace, + D_break, + D_clear, + D_commands, + D_condition, + D_continue, + D_delete, + D_disable, + D_display, + D_down, + D_dump, + D_enable, + D_end, + D_eval, + D_finish, + D_frame, + D_help, + D_ignore, + D_info, + D_list, + D_next, + D_nexti, + D_option, + D_print, + D_printf, + D_quit, + D_return, + D_run, + D_save, + D_set, + D_silent, + D_source, + D_step, + D_stepi, + D_tbreak, + D_trace, + D_undisplay, + D_until, + D_unwatch, + D_up, + D_watch, + + /* arguments */ + D_argument, + D_int, + D_string, + D_variable, + D_node, + D_field, + D_array, + D_subscript, + D_func, + D_range +}; + +/* non-number arguments to commands */ + +enum nametypeval { + A_ARGS = 1, + A_BREAK, + A_DEL, + A_DISPLAY, + A_FRAME, + A_FUNCTIONS, + A_LOCALS, + A_ONCE, + A_SOURCE, + A_SOURCES, + A_TRACE_ON, + A_TRACE_OFF, + A_VARIABLES, + A_WATCH +}; + +typedef struct cmd_argument { + struct cmd_argument *next; + enum argtype type; + union { + long lval; + char *sval; + NODE *nodeval; + } value; + +#define a_int value.lval /* type = D_int or D_range */ +#define a_argument value.lval /* type = D_argument */ +#define a_string value.sval /* type = D_string, D_array, D_subscript or D_variable */ +#define a_node value.nodeval /* type = D_node, D_field or D_func */ + + int a_count; /* subscript count for D_subscript and D_array */ +} CMDARG; + +typedef int (*Func_cmd)(CMDARG *, int); + +struct cmdtoken { + const char *name; + char *abbrvn; /* abbreviation */ + enum argtype type; + int class; + Func_cmd cf_ptr; + const char *help_txt; +}; + +/* command.c */ +extern void free_cmdarg(CMDARG *list); +extern Func_cmd get_command(int ctype); +extern const char *get_command_name(int ctype); + +/* debug.c */ +extern void d_error(const char *mesg, ...); + +/* command.c */ +extern int find_option(char *name); +extern void option_help(void); +extern char *(*read_a_line)(const char *prompt); +extern char *read_commands_string(const char *prompt); +extern int in_cmd_src(const char *); +extern int get_eof_status(void); +extern void push_cmd_src(int fd, int istty, char * (*readfunc)(const char *), int (*closefunc)(int), int cmd, int eofstatus); +extern int pop_cmd_src(void); +extern int has_break_or_watch_point(int *pnum, int any); +extern int do_list(CMDARG *arg, int cmd); +extern int do_info(CMDARG *arg, int cmd); +extern int do_print_var(CMDARG *arg, int cmd); +extern int do_backtrace(CMDARG *arg, int cmd); +extern int do_breakpoint(CMDARG *arg, int cmd); +extern int do_tmp_breakpoint(CMDARG *arg, int cmd); +extern int do_delete_breakpoint(CMDARG *arg, int cmd); +extern int do_enable_breakpoint(CMDARG *arg, int cmd); +extern int do_disable_breakpoint(CMDARG *arg, int cmd) ; +extern int do_ignore_breakpoint(CMDARG *arg, int cmd) ; +extern int do_run(CMDARG *arg, int cmd); +extern int do_quit(CMDARG *arg, int cmd); +extern int do_continue(CMDARG *arg, int cmd); +extern int do_step(CMDARG *arg, int cmd) ; +extern int do_stepi(CMDARG *arg, int cmd) ; +extern int do_next(CMDARG *arg, int cmd); +extern int do_nexti(CMDARG *arg, int cmd); +extern int do_clear(CMDARG *arg, int cmd); +extern int do_finish(CMDARG *arg, int cmd) ; +extern int do_help(CMDARG *arg, int cmd) ; +extern int do_up(CMDARG *arg, int cmd); +extern int do_down(CMDARG *arg, int cmd); +extern int do_frame(CMDARG *arg, int cmd); +extern int do_until(CMDARG *arg, int cmd); +extern int do_set_var(CMDARG *arg, int cmd); +extern int do_return(CMDARG *arg, int cmd); +extern int do_display(CMDARG *arg, int cmd); +extern int do_undisplay(CMDARG *arg, int cmd); +extern int do_watch(CMDARG *arg, int cmd); +extern int do_unwatch(CMDARG *arg, int cmd); +extern int do_dump_instructions(CMDARG *arg, int cmd); +extern int do_trace_instruction(CMDARG *arg, int cmd); +extern int do_option(CMDARG *arg, int cmd); +extern int do_commands(CMDARG *arg, int cmd); +extern int do_print_f(CMDARG *arg, int cmd); +extern int do_source(CMDARG *arg, int cmd); +extern int do_save(CMDARG *arg, int cmd); +extern int do_eval(CMDARG *arg, int cmd); +extern int do_condition(CMDARG *arg, int cmd); diff --git a/command.c b/command.c new file mode 100644 index 0000000..3664eee --- /dev/null +++ b/command.c @@ -0,0 +1,3695 @@ +/* A Bison parser, made by GNU Bison 2.5. */ + +/* Bison implementation for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.5" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse zzparse +#define yylex zzlex +#define yyerror zzerror +#define yylval zzlval +#define yychar zzchar +#define yydebug zzdebug +#define yynerrs zznerrs + + +/* Copy the first part of user declarations. */ + +/* Line 268 of yacc.c */ +#line 26 "command.y" + +#include "awk.h" +#include "cmd.h" + +#if 0 +#define YYDEBUG 12 +int yydebug = 2; +#endif + +static int yylex(void); +static void yyerror(const char *mesg, ...); + +static int find_command(const char *token, size_t toklen); + +static int want_nodeval = FALSE; + +static int cmd_idx = -1; /* index of current command in cmd table */ +static int repeat_idx = -1; /* index of last repeatable command in command table */ +static CMDARG *arg_list = NULL; /* list of arguments */ +static long errcount = 0; +static char *lexptr_begin = NULL; +static int in_commands = FALSE; +static int num_dim; + +static int in_eval = FALSE; +static const char start_EVAL[] = "function @eval(){"; +static const char end_EVAL[] = "}"; +static CMDARG *append_statement(CMDARG *alist, char *stmt); +static char *next_word(char *p, int len, char **endp); +static NODE *concat_args(CMDARG *a, int count); + +#ifdef HAVE_LIBREADLINE +static void history_expand_line(char **line); +static char *command_generator(const char *text, int state); +static char *srcfile_generator(const char *text, int state); +static char *argument_generator(const char *text, int state); +static char *variable_generator(const char *text, int state); +extern char *option_generator(const char *text, int state); +static int this_cmd = D_illegal; +#else +#define history_expand_line(p) /* nothing */ +static int rl_inhibit_completion; /* dummy variable */ +#endif + +struct argtoken { + const char *name; + enum argtype cmd; + enum nametypeval value; +}; + +/* + * These two should be static, but there are some compilers that + * don't like the static keyword with an empty size. Therefore give + * them names that are less likely to conflict with the rest of gawk. + */ +#define argtab zz_debug_argtab +#define cmdtab zz_debug_cmdtab + +extern struct argtoken argtab[]; +extern struct cmdtoken cmdtab[]; + +static CMDARG *mk_cmdarg(enum argtype type); +static void append_cmdarg(CMDARG *arg); +static int find_argument(CMDARG *arg); +#define YYSTYPE CMDARG * + + +/* Line 268 of yacc.c */ +#line 147 "command.c" + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + D_BACKTRACE = 258, + D_BREAK = 259, + D_CLEAR = 260, + D_CONTINUE = 261, + D_DELETE = 262, + D_DISABLE = 263, + D_DOWN = 264, + D_ENABLE = 265, + D_FINISH = 266, + D_FRAME = 267, + D_HELP = 268, + D_IGNORE = 269, + D_INFO = 270, + D_LIST = 271, + D_NEXT = 272, + D_NEXTI = 273, + D_PRINT = 274, + D_PRINTF = 275, + D_QUIT = 276, + D_RETURN = 277, + D_RUN = 278, + D_SET = 279, + D_STEP = 280, + D_STEPI = 281, + D_TBREAK = 282, + D_UP = 283, + D_UNTIL = 284, + D_DISPLAY = 285, + D_UNDISPLAY = 286, + D_WATCH = 287, + D_UNWATCH = 288, + D_DUMP = 289, + D_TRACE = 290, + D_INT = 291, + D_STRING = 292, + D_NODE = 293, + D_VARIABLE = 294, + D_OPTION = 295, + D_COMMANDS = 296, + D_END = 297, + D_SILENT = 298, + D_SOURCE = 299, + D_SAVE = 300, + D_EVAL = 301, + D_CONDITION = 302, + D_STATEMENT = 303 + }; +#endif +/* Tokens. */ +#define D_BACKTRACE 258 +#define D_BREAK 259 +#define D_CLEAR 260 +#define D_CONTINUE 261 +#define D_DELETE 262 +#define D_DISABLE 263 +#define D_DOWN 264 +#define D_ENABLE 265 +#define D_FINISH 266 +#define D_FRAME 267 +#define D_HELP 268 +#define D_IGNORE 269 +#define D_INFO 270 +#define D_LIST 271 +#define D_NEXT 272 +#define D_NEXTI 273 +#define D_PRINT 274 +#define D_PRINTF 275 +#define D_QUIT 276 +#define D_RETURN 277 +#define D_RUN 278 +#define D_SET 279 +#define D_STEP 280 +#define D_STEPI 281 +#define D_TBREAK 282 +#define D_UP 283 +#define D_UNTIL 284 +#define D_DISPLAY 285 +#define D_UNDISPLAY 286 +#define D_WATCH 287 +#define D_UNWATCH 288 +#define D_DUMP 289 +#define D_TRACE 290 +#define D_INT 291 +#define D_STRING 292 +#define D_NODE 293 +#define D_VARIABLE 294 +#define D_OPTION 295 +#define D_COMMANDS 296 +#define D_END 297 +#define D_SILENT 298 +#define D_SOURCE 299 +#define D_SAVE 300 +#define D_EVAL 301 +#define D_CONDITION 302 +#define D_STATEMENT 303 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef int YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + + +/* Copy the second part of user declarations. */ + + +/* Line 343 of yacc.c */ +#line 285 "command.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static int +YYID (int yyi) +#else +static int +YYID (yyi) + int yyi; +#endif +{ + return yyi; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow && (! defined __cplusplus || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +# define YYCOPY_NEEDED 1 + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 2 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 203 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 59 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 55 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 156 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 203 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 303 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 58, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 57, 2, 2, 2, + 2, 2, 2, 53, 50, 54, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 51, 2, + 2, 49, 2, 2, 52, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 55, 2, 56, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, + 45, 46, 47, 48 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint16 yyprhs[] = +{ + 0, 0, 3, 4, 7, 9, 12, 15, 17, 19, + 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, + 41, 43, 45, 46, 51, 52, 53, 58, 62, 66, + 69, 71, 73, 75, 78, 81, 84, 88, 91, 92, + 96, 97, 101, 104, 107, 110, 113, 114, 120, 123, + 124, 128, 129, 133, 134, 139, 142, 145, 148, 151, + 154, 156, 158, 161, 162, 167, 169, 171, 173, 175, + 176, 178, 180, 183, 187, 189, 190, 192, 194, 196, + 197, 199, 203, 205, 206, 208, 210, 214, 218, 219, + 220, 224, 226, 227, 233, 237, 238, 240, 241, 243, + 244, 246, 247, 249, 251, 254, 256, 259, 263, 265, + 268, 272, 274, 276, 278, 280, 284, 286, 287, 289, + 291, 293, 295, 297, 301, 305, 309, 313, 314, 316, + 318, 320, 322, 325, 328, 330, 334, 336, 340, 344, + 346, 349, 351, 354, 357, 359, 362, 365, 366, 368, + 369, 371, 373, 376, 378, 381, 384 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 60, 0, -1, -1, 60, 61, -1, 113, -1, 71, + 113, -1, 1, 113, -1, 6, -1, 17, -1, 18, + -1, 25, -1, 26, -1, 31, -1, 33, -1, 8, + -1, 7, -1, 28, -1, 9, -1, 3, -1, 12, + -1, 4, -1, 27, -1, -1, 46, 66, 81, 113, + -1, -1, -1, 68, 48, 69, 113, -1, 67, 68, + 42, -1, 46, 66, 84, -1, 13, 94, -1, 21, + -1, 23, -1, 11, -1, 62, 109, -1, 64, 110, + -1, 15, 37, -1, 14, 111, 36, -1, 10, 95, + -1, -1, 19, 72, 97, -1, -1, 20, 73, 99, + -1, 16, 100, -1, 29, 87, -1, 5, 87, -1, + 65, 88, -1, -1, 24, 74, 107, 49, 108, -1, + 40, 85, -1, -1, 22, 75, 93, -1, -1, 30, + 76, 91, -1, -1, 32, 77, 107, 79, -1, 63, + 102, -1, 34, 92, -1, 44, 37, -1, 45, 37, + -1, 41, 80, -1, 42, -1, 43, -1, 35, 37, + -1, -1, 47, 111, 78, 79, -1, 70, -1, 83, + -1, 109, -1, 1, -1, -1, 82, -1, 39, -1, + 82, 39, -1, 82, 50, 39, -1, 1, -1, -1, + 84, -1, 1, -1, 38, -1, -1, 37, -1, 37, + 49, 37, -1, 37, -1, -1, 111, -1, 86, -1, + 37, 51, 111, -1, 37, 51, 86, -1, -1, -1, + 111, 89, 79, -1, 86, -1, -1, 37, 51, 111, + 90, 79, -1, 37, 51, 86, -1, -1, 107, -1, + -1, 37, -1, -1, 108, -1, -1, 37, -1, 102, + -1, 37, 102, -1, 107, -1, 52, 39, -1, 52, + 39, 106, -1, 96, -1, 97, 96, -1, 97, 50, + 96, -1, 1, -1, 38, -1, 107, -1, 98, -1, + 99, 50, 98, -1, 1, -1, -1, 53, -1, 54, + -1, 111, -1, 86, -1, 101, -1, 37, 51, 111, + -1, 37, 51, 86, -1, 37, 51, 101, -1, 111, + 54, 111, -1, -1, 103, -1, 1, -1, 111, -1, + 101, -1, 103, 111, -1, 103, 101, -1, 108, -1, + 104, 50, 108, -1, 1, -1, 55, 104, 56, -1, + 55, 104, 1, -1, 105, -1, 106, 105, -1, 39, + -1, 57, 38, -1, 39, 106, -1, 38, -1, 53, + 38, -1, 54, 38, -1, -1, 111, -1, -1, 112, + -1, 36, -1, 53, 36, -1, 36, -1, 53, 36, + -1, 54, 36, -1, 58, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 106, 106, 108, 126, 127, 177, 184, 185, 186, + 187, 188, 192, 193, 194, 195, 199, 200, 201, 202, + 206, 207, 212, 216, 235, 242, 242, 249, 265, 279, + 280, 281, 282, 283, 284, 290, 302, 303, 304, 304, + 305, 305, 306, 307, 308, 309, 310, 310, 311, 312, + 312, 313, 313, 314, 314, 315, 316, 317, 322, 327, + 353, 363, 368, 380, 380, 388, 402, 415, 416, 422, + 423, 427, 428, 429, 430, 436, 437, 438, 443, 454, + 455, 460, 468, 485, 486, 487, 488, 489, 494, 495, + 495, 496, 497, 497, 498, 503, 504, 509, 510, 515, + 516, 519, 521, 525, 526, 541, 542, 547, 555, 556, + 557, 558, 562, 563, 567, 568, 569, 574, 575, 577, + 584, 585, 586, 587, 588, 589, 593, 606, 607, 608, + 612, 613, 614, 615, 619, 621, 623, 627, 642, 646, + 648, 653, 654, 663, 673, 675, 682, 695, 696, 702, + 703, 708, 714, 723, 725, 727, 735 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "D_BACKTRACE", "D_BREAK", "D_CLEAR", + "D_CONTINUE", "D_DELETE", "D_DISABLE", "D_DOWN", "D_ENABLE", "D_FINISH", + "D_FRAME", "D_HELP", "D_IGNORE", "D_INFO", "D_LIST", "D_NEXT", "D_NEXTI", + "D_PRINT", "D_PRINTF", "D_QUIT", "D_RETURN", "D_RUN", "D_SET", "D_STEP", + "D_STEPI", "D_TBREAK", "D_UP", "D_UNTIL", "D_DISPLAY", "D_UNDISPLAY", + "D_WATCH", "D_UNWATCH", "D_DUMP", "D_TRACE", "D_INT", "D_STRING", + "D_NODE", "D_VARIABLE", "D_OPTION", "D_COMMANDS", "D_END", "D_SILENT", + "D_SOURCE", "D_SAVE", "D_EVAL", "D_CONDITION", "D_STATEMENT", "'='", + "','", "':'", "'@'", "'+'", "'-'", "'['", "']'", "'$'", "'\\n'", + "$accept", "input", "line", "control_cmd", "d_cmd", "frame_cmd", + "break_cmd", "set_want_nodeval", "eval_prologue", "statement_list", "@1", + "eval_cmd", "command", "$@2", "$@3", "$@4", "$@5", "$@6", "$@7", "$@8", + "condition_exp", "commands_arg", "opt_param_list", "param_list", + "opt_string_node", "string_node", "option_args", "func_name", "location", + "break_args", "$@9", "$@10", "opt_variable", "opt_string", "opt_node", + "help_args", "enable_args", "print_exp", "print_args", "printf_exp", + "printf_args", "list_args", "integer_range", "opt_integer_list", + "integer_list", "exp_list", "subscript", "subscript_list", "variable", + "node", "opt_plus_integer", "opt_integer", "plus_integer", "integer", + "nls", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, + 295, 296, 297, 298, 299, 300, 301, 302, 303, 61, + 44, 58, 64, 43, 45, 91, 93, 36, 10 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 59, 60, 60, 61, 61, 61, 62, 62, 62, + 62, 62, 63, 63, 63, 63, 64, 64, 64, 64, + 65, 65, 66, 67, 68, 69, 68, 70, 70, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 72, 71, + 73, 71, 71, 71, 71, 71, 74, 71, 71, 75, + 71, 76, 71, 77, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 78, 71, 71, 79, 80, 80, 81, + 81, 82, 82, 82, 82, 83, 83, 83, 84, 85, + 85, 85, 86, 87, 87, 87, 87, 87, 88, 89, + 88, 88, 90, 88, 88, 91, 91, 92, 92, 93, + 93, 94, 94, 95, 95, 96, 96, 96, 97, 97, + 97, 97, 98, 98, 99, 99, 99, 100, 100, 100, + 100, 100, 100, 100, 100, 100, 101, 102, 102, 102, + 103, 103, 103, 103, 104, 104, 104, 105, 105, 106, + 106, 107, 107, 107, 108, 108, 108, 109, 109, 110, + 110, 111, 111, 112, 112, 112, 113 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 2, 1, 2, 2, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 4, 0, 0, 4, 3, 3, 2, + 1, 1, 1, 2, 2, 2, 3, 2, 0, 3, + 0, 3, 2, 2, 2, 2, 0, 5, 2, 0, + 3, 0, 3, 0, 4, 2, 2, 2, 2, 2, + 1, 1, 2, 0, 4, 1, 1, 1, 1, 0, + 1, 1, 2, 3, 1, 0, 1, 1, 1, 0, + 1, 3, 1, 0, 1, 1, 3, 3, 0, 0, + 3, 1, 0, 5, 3, 0, 1, 0, 1, 0, + 1, 0, 1, 1, 2, 1, 2, 3, 1, 2, + 3, 1, 1, 1, 1, 3, 1, 0, 1, 1, + 1, 1, 1, 3, 3, 3, 3, 0, 1, 1, + 1, 1, 2, 2, 1, 3, 1, 3, 3, 1, + 2, 1, 2, 2, 1, 2, 2, 0, 1, 0, + 1, 1, 2, 1, 2, 2, 1 +}; + +/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 2, 0, 1, 0, 18, 20, 83, 7, 15, 14, + 17, 0, 32, 19, 101, 0, 0, 117, 8, 9, + 38, 40, 30, 49, 31, 46, 10, 11, 21, 16, + 83, 51, 12, 53, 13, 97, 0, 79, 0, 60, + 61, 0, 0, 22, 0, 156, 3, 147, 0, 149, + 88, 24, 65, 0, 4, 6, 151, 82, 0, 85, + 44, 84, 129, 0, 37, 131, 103, 128, 130, 102, + 29, 0, 35, 82, 118, 119, 121, 42, 122, 120, + 0, 0, 99, 0, 43, 95, 0, 98, 56, 62, + 80, 48, 68, 59, 67, 148, 57, 58, 0, 63, + 33, 55, 153, 0, 0, 34, 150, 82, 91, 45, + 89, 0, 5, 0, 152, 104, 133, 132, 0, 36, + 0, 111, 141, 0, 0, 108, 39, 105, 116, 112, + 114, 41, 113, 144, 0, 0, 50, 100, 0, 52, + 96, 0, 0, 74, 78, 71, 0, 70, 28, 0, + 154, 155, 0, 0, 27, 25, 82, 87, 86, 126, + 124, 125, 123, 0, 139, 143, 106, 142, 0, 109, + 0, 145, 146, 0, 77, 54, 66, 76, 81, 23, + 72, 0, 64, 94, 92, 90, 0, 136, 0, 134, + 140, 107, 110, 115, 47, 73, 0, 26, 138, 0, + 137, 93, 135 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 1, 46, 47, 48, 49, 50, 98, 51, 111, + 186, 52, 53, 80, 81, 83, 82, 85, 86, 149, + 175, 93, 146, 147, 176, 177, 91, 59, 60, 109, + 153, 196, 139, 88, 136, 70, 64, 125, 126, 130, + 131, 77, 65, 66, 67, 188, 164, 165, 127, 137, + 94, 105, 68, 106, 54 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -151 +static const yytype_int16 yypact[] = +{ + -151, 145, -151, -34, -151, -151, 50, -151, -151, -151, + -151, 10, -151, -151, -10, 59, -9, 43, -151, -151, + -151, -151, -151, -151, -151, -151, -151, -151, -151, -151, + 50, -151, -151, -151, -151, -8, -6, 14, 12, -151, + -151, 22, 23, -151, 59, -151, -151, 59, 13, 36, + 64, -151, -151, -34, -151, -151, -151, 24, 47, -151, + -151, -151, -151, 13, -151, -151, -151, 59, 48, -151, + -151, 80, -151, 67, 47, -151, -151, -151, -151, 48, + 4, 19, 69, -20, -151, -20, -20, -151, -151, -151, + 70, -151, -151, -151, -151, -151, -151, -151, 16, -151, + -151, -151, -151, 84, 85, -151, -151, 73, -151, -151, + -151, 40, -151, 74, -151, -151, -151, 48, 59, -151, + 74, -151, 71, 89, 91, -151, 42, -151, -151, -151, + -151, 81, -151, -151, 92, 94, -151, -151, 86, -151, + -151, 6, 96, -151, -151, -151, -34, 75, -151, 6, + -151, -151, 74, 6, -151, -151, -151, -151, -151, -151, + -151, -151, 48, 31, -151, 71, 71, -151, 52, -151, + -17, -151, -151, 69, -151, -151, -151, -151, -151, -151, + -151, 95, -151, -151, -151, -151, -34, -151, 17, -151, + -151, 71, -151, -151, -151, -151, 6, -151, -151, 69, + -151, -151, -151 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -151, -151, -151, -151, -151, -151, -151, -151, -151, -151, + -151, -151, -151, -151, -151, -151, -151, -151, -151, -151, + -119, -151, -151, -151, -151, 38, -151, -15, 108, -151, + -151, -151, -151, -151, -151, -151, -151, -90, -151, -31, + -151, -151, -14, -25, -151, -151, -150, -26, -77, -147, + 97, -151, -5, -151, -3 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -148 +static const yytype_int16 yytable[] = +{ + 55, 61, 76, 78, 132, 121, 138, 174, 140, 141, + 71, 62, 79, 92, 62, 190, 189, 143, 198, 122, + 128, 129, 122, 101, 45, 61, 194, 69, 72, 87, + 182, 89, 187, 95, 185, 108, 169, 124, 115, 99, + 124, 190, 95, 122, 144, 110, 56, 63, 56, 56, + 112, 90, 202, 116, 144, 145, 123, 129, 122, 96, + 97, 124, 117, 58, -75, 58, 58, 199, -127, 133, + -147, -127, 102, 200, -69, 113, 124, 201, 192, 56, + 73, 122, 154, 114, 134, 135, 56, 57, 155, 103, + 104, 122, 168, 132, 123, 56, 74, 75, 157, 124, + 56, 107, 118, 58, 123, 160, 161, 133, 158, 124, + 56, 156, 58, 159, 180, 162, 119, 58, 120, 142, + 150, 151, 134, 135, 152, 181, 163, 58, 166, 167, + 171, 170, 172, 178, 195, 173, 148, 183, 84, 193, + 191, 0, 0, 179, 100, 2, 3, 184, 4, 5, + 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 0, 0, 197, 0, 37, 38, 39, 40, 41, + 42, 43, 44, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 45 +}; + +#define yypact_value_is_default(yystate) \ + ((yystate) == (-151)) + +#define yytable_value_is_error(yytable_value) \ + YYID (0) + +static const yytype_int16 yycheck[] = +{ + 3, 6, 17, 17, 81, 1, 83, 1, 85, 86, + 15, 1, 17, 1, 1, 165, 163, 1, 1, 39, + 1, 38, 39, 48, 58, 30, 173, 37, 37, 37, + 149, 37, 1, 38, 153, 50, 126, 57, 63, 44, + 57, 191, 47, 39, 38, 50, 36, 37, 36, 36, + 53, 37, 199, 67, 38, 39, 52, 38, 39, 37, + 37, 57, 67, 53, 58, 53, 53, 50, 58, 38, + 58, 58, 36, 56, 58, 51, 57, 196, 168, 36, + 37, 39, 42, 36, 53, 54, 36, 37, 48, 53, + 54, 39, 50, 170, 52, 36, 53, 54, 113, 57, + 36, 37, 54, 53, 52, 120, 120, 38, 113, 57, + 36, 37, 53, 118, 39, 120, 36, 53, 51, 49, + 36, 36, 53, 54, 51, 50, 55, 53, 39, 38, + 38, 50, 38, 37, 39, 49, 98, 152, 30, 170, + 166, -1, -1, 146, 47, 0, 1, 152, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, -1, -1, 186, -1, 40, 41, 42, 43, 44, + 45, 46, 47, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 58 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 60, 0, 1, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 40, 41, 42, + 43, 44, 45, 46, 47, 58, 61, 62, 63, 64, + 65, 67, 70, 71, 113, 113, 36, 37, 53, 86, + 87, 111, 1, 37, 95, 101, 102, 103, 111, 37, + 94, 111, 37, 37, 53, 54, 86, 100, 101, 111, + 72, 73, 75, 74, 87, 76, 77, 37, 92, 37, + 37, 85, 1, 80, 109, 111, 37, 37, 66, 111, + 109, 102, 36, 53, 54, 110, 112, 37, 86, 88, + 111, 68, 113, 51, 36, 102, 101, 111, 54, 36, + 51, 1, 39, 52, 57, 96, 97, 107, 1, 38, + 98, 99, 107, 38, 53, 54, 93, 108, 107, 91, + 107, 107, 49, 1, 38, 39, 81, 82, 84, 78, + 36, 36, 51, 89, 42, 48, 37, 86, 111, 111, + 86, 101, 111, 55, 105, 106, 39, 38, 50, 96, + 50, 38, 38, 49, 1, 79, 83, 84, 37, 113, + 39, 50, 79, 86, 111, 79, 69, 1, 104, 108, + 105, 106, 96, 98, 108, 39, 90, 113, 1, 50, + 56, 79, 108 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* Like YYERROR except do call yyerror. This remains here temporarily + to ease the transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. However, + YYFAIL appears to be in use. Nevertheless, it is formally deprecated + in Bison 2.4.2's NEWS entry, where a plan to phase it out is + discussed. */ + +#define YYFAIL goto yyerrlab +#if defined YYFAIL + /* This is here to suppress warnings from the GCC cpp's + -Wunused-macros. Normally we don't worry about that warning, but + some users do, and we want to make it easy for users to remove + YYFAIL uses, which will produce warnings from Bison 2.5. */ +#endif + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* This macro is provided for backward compatibility. */ + +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (YYLEX_PARAM) +#else +# define YYLEX yylex () +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +#else +static void +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule) +#else +static void +yy_reduce_print (yyvsp, yyrule) + YYSTYPE *yyvsp; + int yyrule; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) +{ + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = 0; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + + /* There are many possibilities here to consider: + - Assume YYFAIL is not used. It's too flawed to consider. See + + for details. YYERROR is fine as it does not invoke this + function. + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) + { + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } + + yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; +} +#endif /* YYERROR_VERBOSE */ + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +#else +static void +yydestruct (yymsg, yytype, yyvaluep) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; +#endif +{ + YYUSE (yyvaluep); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + + +/* Prevent warnings from -Wmissing-prototypes. */ +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (void); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + +/* Number of syntax errors so far. */ +int yynerrs; + + +/*----------. +| yyparse. | +`----------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ || defined __cplusplus || defined _MSC_VER) +int +yyparse (void) +#else +int +yyparse () + +#endif +#endif +{ + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yypact_value_is_default (yyn)) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yytable_value_is_error (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 3: + +/* Line 1806 of yacc.c */ +#line 109 "command.y" + { + cmd_idx = -1; + want_nodeval = FALSE; + if (lexptr_begin != NULL) { + if (input_from_tty && lexptr_begin[0] != '\0') + add_history(lexptr_begin); + efree(lexptr_begin); + lexptr_begin = NULL; + } + if (arg_list != NULL) { + free_cmdarg(arg_list); + arg_list = NULL; + } + } + break; + + case 5: + +/* Line 1806 of yacc.c */ +#line 128 "command.y" + { + if (errcount == 0 && cmd_idx >= 0) { + Func_cmd cmdfunc; + int terminate = FALSE; + CMDARG *args; + int ctype = 0; + + ctype = cmdtab[cmd_idx].type; + + /* a blank line repeats previous command + * (list, next, nexti, step, stepi and continue without arguments). + * save the index in the command table; used in yylex + */ + if ((ctype == D_list + || ctype == D_next + || ctype == D_step + || ctype == D_nexti + || ctype == D_stepi + || ctype == D_continue) + && arg_list == NULL + && ! in_commands + && input_from_tty + ) + repeat_idx = cmd_idx; + else + repeat_idx = -1; + + /* call the command handler; reset the globals arg_list, cmd_idx, + * since this handler could invoke yyparse again. + * call do_commands for the list of commands in `commands'; + * arg_list isn't freed on return. + */ + + cmdfunc = cmdtab[cmd_idx].cf_ptr; + if (in_commands) + cmdfunc = do_commands; + cmd_idx = -1; + want_nodeval = FALSE; + + args = arg_list; + arg_list = NULL; + + terminate = (*cmdfunc)(args, ctype); + if (! in_commands || ctype == D_commands) + free_cmdarg(args); + if (terminate) + YYACCEPT; + } + } + break; + + case 6: + +/* Line 1806 of yacc.c */ +#line 178 "command.y" + { + yyerrok; + } + break; + + case 22: + +/* Line 1806 of yacc.c */ +#line 212 "command.y" + { want_nodeval = TRUE; } + break; + + case 23: + +/* Line 1806 of yacc.c */ +#line 217 "command.y" + { + if (errcount == 0) { + /* don't free arg_list; passed on to statement_list + * non-terminal (empty rule action). See below. + */ + if (input_from_tty) { + dPrompt = eval_Prompt; + fprintf(out_fp, _("Type (g)awk statement(s). End with the command \"end\"\n")); + rl_inhibit_completion = 1; + } + cmd_idx = -1; + in_eval = TRUE; + } + } + break; + + case 24: + +/* Line 1806 of yacc.c */ +#line 235 "command.y" + { + (yyval) = append_statement(arg_list, (char *) start_EVAL); + if (read_a_line == read_commands_string) /* unserializing 'eval' in 'commands' */ + (yyval)->a_string[0] = '\0'; + free_cmdarg(arg_list); + arg_list = NULL; + } + break; + + case 25: + +/* Line 1806 of yacc.c */ +#line 242 "command.y" + { (yyval) = append_statement((yyvsp[(1) - (2)]), lexptr_begin); } + break; + + case 26: + +/* Line 1806 of yacc.c */ +#line 243 "command.y" + { + (yyval) = (yyvsp[(3) - (4)]); + } + break; + + case 27: + +/* Line 1806 of yacc.c */ +#line 250 "command.y" + { + arg_list = append_statement((yyvsp[(2) - (3)]), (char *) end_EVAL); + if (read_a_line == read_commands_string) { /* unserializing 'eval' in 'commands' */ + char *str = arg_list->a_string; + size_t len = strlen(str); + assert(len > 2 && str[len - 2] == '}'); + str[len - 2] = '\0'; + } + if (input_from_tty) { + dPrompt = in_commands ? commands_Prompt : dgawk_Prompt; + rl_inhibit_completion = 0; + } + cmd_idx = find_command("eval", 4); + in_eval = FALSE; + } + break; + + case 28: + +/* Line 1806 of yacc.c */ +#line 266 "command.y" + { + NODE *n; + CMDARG *arg; + n = (yyvsp[(3) - (3)])->a_node; + arg = append_statement(NULL, (char *) start_EVAL); + (void) append_statement(arg, n->stptr); + (void) append_statement(arg, (char *) end_EVAL); + free_cmdarg(arg_list); + arg_list = arg; + } + break; + + case 34: + +/* Line 1806 of yacc.c */ +#line 285 "command.y" + { + if (cmdtab[cmd_idx].class == D_FRAME + && (yyvsp[(2) - (2)]) != NULL && (yyvsp[(2) - (2)])->a_int < 0) + yyerror(_("invalid frame number: %d"), (yyvsp[(2) - (2)])->a_int); + } + break; + + case 35: + +/* Line 1806 of yacc.c */ +#line 291 "command.y" + { + int idx = find_argument((yyvsp[(2) - (2)])); + if (idx < 0) + yyerror(_("info: invalid option - \"%s\""), (yyvsp[(2) - (2)])->a_string); + else { + efree((yyvsp[(2) - (2)])->a_string); + (yyvsp[(2) - (2)])->a_string = NULL; + (yyvsp[(2) - (2)])->type = D_argument; + (yyvsp[(2) - (2)])->a_argument = argtab[idx].value; + } + } + break; + + case 38: + +/* Line 1806 of yacc.c */ +#line 304 "command.y" + { want_nodeval = TRUE; } + break; + + case 40: + +/* Line 1806 of yacc.c */ +#line 305 "command.y" + { want_nodeval = TRUE; } + break; + + case 46: + +/* Line 1806 of yacc.c */ +#line 310 "command.y" + { want_nodeval = TRUE; } + break; + + case 49: + +/* Line 1806 of yacc.c */ +#line 312 "command.y" + { want_nodeval = TRUE; } + break; + + case 51: + +/* Line 1806 of yacc.c */ +#line 313 "command.y" + { want_nodeval = TRUE; } + break; + + case 53: + +/* Line 1806 of yacc.c */ +#line 314 "command.y" + { want_nodeval = TRUE; } + break; + + case 57: + +/* Line 1806 of yacc.c */ +#line 318 "command.y" + { + if (in_cmd_src((yyvsp[(2) - (2)])->a_string)) + yyerror(_("source \"%s\": already sourced."), (yyvsp[(2) - (2)])->a_string); + } + break; + + case 58: + +/* Line 1806 of yacc.c */ +#line 323 "command.y" + { + if (! input_from_tty) + yyerror(_("save \"%s\": command not permitted."), (yyvsp[(2) - (2)])->a_string); + } + break; + + case 59: + +/* Line 1806 of yacc.c */ +#line 328 "command.y" + { + int type = 0; + int num; + + if ((yyvsp[(2) - (2)]) != NULL) + num = (yyvsp[(2) - (2)])->a_int; + + if (errcount != 0) + ; + else if (in_commands) + yyerror(_("Can't use command `commands' for breakpoint/watchpoint commands")); + else if ((yyvsp[(2) - (2)]) == NULL && ! (type = has_break_or_watch_point(&num, TRUE))) + yyerror(_("no breakpoint/watchpoint has been set yet")); + else if ((yyvsp[(2) - (2)]) != NULL && ! (type = has_break_or_watch_point(&num, FALSE))) + yyerror(_("invalid breakpoint/watchpoint number")); + if (type) { + in_commands = TRUE; + if (input_from_tty) { + dPrompt = commands_Prompt; + fprintf(out_fp, _("Type commands for when %s %d is hit, one per line.\n"), + (type == D_break) ? "breakpoint" : "watchpoint", num); + fprintf(out_fp, _("End with the command \"end\"\n")); + } + } + } + break; + + case 60: + +/* Line 1806 of yacc.c */ +#line 354 "command.y" + { + if (! in_commands) + yyerror(_("`end' valid only in command `commands' or `eval'")); + else { + if (input_from_tty) + dPrompt = dgawk_Prompt; + in_commands = FALSE; + } + } + break; + + case 61: + +/* Line 1806 of yacc.c */ +#line 364 "command.y" + { + if (! in_commands) + yyerror(_("`silent' valid only in command `commands'")); + } + break; + + case 62: + +/* Line 1806 of yacc.c */ +#line 369 "command.y" + { + int idx = find_argument((yyvsp[(2) - (2)])); + if (idx < 0) + yyerror(_("trace: invalid option - \"%s\""), (yyvsp[(2) - (2)])->a_string); + else { + efree((yyvsp[(2) - (2)])->a_string); + (yyvsp[(2) - (2)])->a_string = NULL; + (yyvsp[(2) - (2)])->type = D_argument; + (yyvsp[(2) - (2)])->a_argument = argtab[idx].value; + } + } + break; + + case 63: + +/* Line 1806 of yacc.c */ +#line 380 "command.y" + { want_nodeval = TRUE; } + break; + + case 64: + +/* Line 1806 of yacc.c */ +#line 381 "command.y" + { + int type; + int num = (yyvsp[(2) - (4)])->a_int; + type = has_break_or_watch_point(&num, FALSE); + if (! type) + yyerror(_("condition: invalid breakpoint/watchpoint number")); + } + break; + + case 65: + +/* Line 1806 of yacc.c */ +#line 389 "command.y" + { + if (in_commands) { + /* Prepend command 'eval' to argument list */ + CMDARG *arg; + arg = mk_cmdarg(D_string); + arg->a_string = estrdup("eval", 4); + arg->next = arg_list; + arg_list = arg; + } + } + break; + + case 66: + +/* Line 1806 of yacc.c */ +#line 403 "command.y" + { + if ((yyvsp[(1) - (1)]) != NULL) { + NODE *n = (yyvsp[(1) - (1)])->a_node; + (yyvsp[(1) - (1)])->type = D_string; + (yyvsp[(1) - (1)])->a_string = n->stptr; + freenode(n); + } + (yyval) = (yyvsp[(1) - (1)]); + } + break; + + case 68: + +/* Line 1806 of yacc.c */ +#line 417 "command.y" + { (yyval) = NULL; } + break; + + case 69: + +/* Line 1806 of yacc.c */ +#line 422 "command.y" + { (yyval) = NULL; } + break; + + case 74: + +/* Line 1806 of yacc.c */ +#line 431 "command.y" + { (yyval) = NULL; } + break; + + case 75: + +/* Line 1806 of yacc.c */ +#line 436 "command.y" + { (yyval) = NULL; } + break; + + case 77: + +/* Line 1806 of yacc.c */ +#line 439 "command.y" + { (yyval) = NULL; } + break; + + case 78: + +/* Line 1806 of yacc.c */ +#line 444 "command.y" + { + NODE *n; + n = (yyvsp[(1) - (1)])->a_node; + if ((n->flags & STRING) == 0) + yyerror(_("argument not a string")); + } + break; + + case 79: + +/* Line 1806 of yacc.c */ +#line 454 "command.y" + { (yyval) = NULL; } + break; + + case 80: + +/* Line 1806 of yacc.c */ +#line 456 "command.y" + { + if (find_option((yyvsp[(1) - (1)])->a_string) < 0) + yyerror(_("option: invalid parameter - \"%s\""), (yyvsp[(1) - (1)])->a_string); + } + break; + + case 81: + +/* Line 1806 of yacc.c */ +#line 461 "command.y" + { + if (find_option((yyvsp[(1) - (3)])->a_string) < 0) + yyerror(_("option: invalid parameter - \"%s\""), (yyvsp[(1) - (3)])->a_string); + } + break; + + case 82: + +/* Line 1806 of yacc.c */ +#line 469 "command.y" + { + NODE *n; + n = lookup((yyvsp[(1) - (1)])->a_string); + if (n == NULL || n->type != Node_func) + yyerror(_("no such function - \"%s\""), (yyvsp[(1) - (1)])->a_string); + else { + (yyvsp[(1) - (1)])->type = D_func; + efree((yyvsp[(1) - (1)])->a_string); + (yyvsp[(1) - (1)])->a_string = NULL; + (yyvsp[(1) - (1)])->a_node = n; + } + } + break; + + case 83: + +/* Line 1806 of yacc.c */ +#line 485 "command.y" + { (yyval) = NULL; } + break; + + case 88: + +/* Line 1806 of yacc.c */ +#line 494 "command.y" + { (yyval) = NULL; } + break; + + case 89: + +/* Line 1806 of yacc.c */ +#line 495 "command.y" + { want_nodeval = TRUE; } + break; + + case 92: + +/* Line 1806 of yacc.c */ +#line 497 "command.y" + { want_nodeval = TRUE; } + break; + + case 95: + +/* Line 1806 of yacc.c */ +#line 503 "command.y" + { (yyval) = NULL; } + break; + + case 97: + +/* Line 1806 of yacc.c */ +#line 509 "command.y" + { (yyval) = NULL; } + break; + + case 99: + +/* Line 1806 of yacc.c */ +#line 515 "command.y" + { (yyval) = NULL; } + break; + + case 104: + +/* Line 1806 of yacc.c */ +#line 527 "command.y" + { + int idx = find_argument((yyvsp[(1) - (2)])); + if (idx < 0) + yyerror(_("enable: invalid option - \"%s\""), (yyvsp[(1) - (2)])->a_string); + else { + efree((yyvsp[(1) - (2)])->a_string); + (yyvsp[(1) - (2)])->a_string = NULL; + (yyvsp[(1) - (2)])->type = D_argument; + (yyvsp[(1) - (2)])->a_argument = argtab[idx].value; + } + } + break; + + case 106: + +/* Line 1806 of yacc.c */ +#line 543 "command.y" + { + (yyvsp[(2) - (2)])->type = D_array; /* dump all items */ + (yyvsp[(2) - (2)])->a_count = 0; + } + break; + + case 107: + +/* Line 1806 of yacc.c */ +#line 548 "command.y" + { + (yyvsp[(2) - (3)])->type = D_array; + (yyvsp[(2) - (3)])->a_count = num_dim; + } + break; + + case 117: + +/* Line 1806 of yacc.c */ +#line 574 "command.y" + { (yyval) = NULL; } + break; + + case 118: + +/* Line 1806 of yacc.c */ +#line 576 "command.y" + { (yyval) = NULL; } + break; + + case 119: + +/* Line 1806 of yacc.c */ +#line 578 "command.y" + { + CMDARG *a; + a = mk_cmdarg(D_int); + a->a_int = -1; + append_cmdarg(a); + } + break; + + case 126: + +/* Line 1806 of yacc.c */ +#line 594 "command.y" + { + if ((yyvsp[(1) - (3)])->a_int > (yyvsp[(3) - (3)])->a_int) + yyerror(_("invalid range specification: %d - %d"), + (yyvsp[(1) - (3)])->a_int, (yyvsp[(3) - (3)])->a_int); + else + (yyvsp[(1) - (3)])->type = D_range; + (yyval) = (yyvsp[(1) - (3)]); + } + break; + + case 127: + +/* Line 1806 of yacc.c */ +#line 606 "command.y" + { (yyval) = NULL; } + break; + + case 134: + +/* Line 1806 of yacc.c */ +#line 620 "command.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 135: + +/* Line 1806 of yacc.c */ +#line 622 "command.y" + { (yyval) = (yyvsp[(1) - (3)]); } + break; + + case 137: + +/* Line 1806 of yacc.c */ +#line 628 "command.y" + { + CMDARG *a; + NODE *subs; + int count = 0; + + for (a = (yyvsp[(2) - (3)]); a != NULL; a = a->next) + count++; + subs = concat_args((yyvsp[(2) - (3)]), count); + free_cmdarg((yyvsp[(2) - (3)])->next); + (yyvsp[(2) - (3)])->next = NULL; + (yyvsp[(2) - (3)])->type = D_node; + (yyvsp[(2) - (3)])->a_node = subs; + (yyval) = (yyvsp[(2) - (3)]); + } + break; + + case 139: + +/* Line 1806 of yacc.c */ +#line 647 "command.y" + { (yyval) = (yyvsp[(1) - (1)]); num_dim = 1; } + break; + + case 140: + +/* Line 1806 of yacc.c */ +#line 649 "command.y" + { (yyval) = (yyvsp[(1) - (2)]); num_dim++; } + break; + + case 142: + +/* Line 1806 of yacc.c */ +#line 655 "command.y" + { + NODE *n = (yyvsp[(2) - (2)])->a_node; + if ((n->flags & NUMBER) == 0) + yyerror(_("non-numeric value for field number")); + else + (yyvsp[(2) - (2)])->type = D_field; + (yyval) = (yyvsp[(2) - (2)]); + } + break; + + case 143: + +/* Line 1806 of yacc.c */ +#line 664 "command.y" + { + /* a_string is array name, a_count is dimension count */ + (yyvsp[(1) - (2)])->type = D_subscript; + (yyvsp[(1) - (2)])->a_count = num_dim; + (yyval) = (yyvsp[(1) - (2)]); + } + break; + + case 144: + +/* Line 1806 of yacc.c */ +#line 674 "command.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 145: + +/* Line 1806 of yacc.c */ +#line 676 "command.y" + { + NODE *n = (yyvsp[(2) - (2)])->a_node; + if ((n->flags & NUMBER) == 0) + yyerror(_("non-numeric value found, numeric expected")); + (yyval) = (yyvsp[(2) - (2)]); + } + break; + + case 146: + +/* Line 1806 of yacc.c */ +#line 683 "command.y" + { + NODE *n = (yyvsp[(2) - (2)])->a_node; + if ((n->flags & NUMBER) == 0) + yyerror(_("non-numeric value found, numeric expected")); + else + (yyvsp[(2) - (2)])->a_node->numbr = - n->numbr; + (yyval) = (yyvsp[(2) - (2)]); + } + break; + + case 147: + +/* Line 1806 of yacc.c */ +#line 695 "command.y" + { (yyval) = NULL; } + break; + + case 148: + +/* Line 1806 of yacc.c */ +#line 697 "command.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 149: + +/* Line 1806 of yacc.c */ +#line 702 "command.y" + { (yyval) = NULL; } + break; + + case 150: + +/* Line 1806 of yacc.c */ +#line 704 "command.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 151: + +/* Line 1806 of yacc.c */ +#line 709 "command.y" + { + if ((yyvsp[(1) - (1)])->a_int == 0) + yyerror(_("non-zero integer value")); + (yyval) = (yyvsp[(1) - (1)]); + } + break; + + case 152: + +/* Line 1806 of yacc.c */ +#line 715 "command.y" + { + if ((yyvsp[(2) - (2)])->a_int == 0) + yyerror(_("non-zero integer value")); + (yyval) = (yyvsp[(2) - (2)]); + } + break; + + case 153: + +/* Line 1806 of yacc.c */ +#line 724 "command.y" + { (yyval) = (yyvsp[(1) - (1)]); } + break; + + case 154: + +/* Line 1806 of yacc.c */ +#line 726 "command.y" + { (yyval) = (yyvsp[(2) - (2)]); } + break; + + case 155: + +/* Line 1806 of yacc.c */ +#line 728 "command.y" + { + (yyvsp[(2) - (2)])->a_int = - (yyvsp[(2) - (2)])->a_int; + (yyval) = (yyvsp[(2) - (2)]); + } + break; + + case 156: + +/* Line 1806 of yacc.c */ +#line 736 "command.y" + { + if (lexptr_begin != NULL) { + if (input_from_tty && lexptr_begin[0] != '\0') + add_history(lexptr_begin); + efree(lexptr_begin); + lexptr_begin = NULL; + } + } + break; + + + +/* Line 1806 of yacc.c */ +#line 2541 "command.c" + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) + { + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; + } +# undef YYSYNTAX_ERROR +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined(yyoverflow) || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + + +/* Line 2067 of yacc.c */ +#line 746 "command.y" + + + +/* append_statement --- append 'stmt' to the list of eval awk statements */ + +static CMDARG * +append_statement(CMDARG *alist, char *stmt) +{ + CMDARG *a, *arg; + char *s; + int len, slen, ssize; + +#define EVALSIZE 512 + + if (stmt == start_EVAL) { + len = sizeof(start_EVAL); + for (a = alist; a != NULL; a = a->next) + len += strlen(a->a_string) + 1; /* 1 for ',' */ + len += EVALSIZE; + + emalloc(s, char *, (len + 2) * sizeof(char), "append_statement"); + arg = mk_cmdarg(D_string); + arg->a_string = s; + arg->a_count = len; /* kludge */ + + slen = sizeof("function @eval(") - 1; + memcpy(s, start_EVAL, slen); + + for (a = alist; a != NULL; a = a->next) { + len = strlen(a->a_string); + memcpy(s + slen, a->a_string, len); + slen += len; + if (a->next != NULL) + s[slen++] = ','; + } + s[slen++] = ')'; + s[slen++] = '{'; + s[slen] = '\0'; + return arg; + } + + len = strlen(stmt) + 1; /* 1 for newline */ + s = alist->a_string; + slen = strlen(s); + ssize = alist->a_count; + if (len > ssize - slen) { + ssize = slen + len + EVALSIZE; + erealloc(s, char *, (ssize + 2) * sizeof(char), "append_statement"); + alist->a_string = s; + alist->a_count = ssize; + } + memcpy(s + slen, stmt, len); + slen += len; + if (slen >= 2 && s[slen - 2] != '\n') { + s[slen - 1] = '\n'; + s[slen] = '\0'; + } + + if (stmt == end_EVAL) + erealloc(alist->a_string, char *, slen + 2, "append_statement"); + return alist; + +#undef EVALSIZE +} + + +/* command names sorted in ascending order */ + +struct cmdtoken cmdtab[] = { +{ "backtrace", "bt", D_backtrace, D_BACKTRACE, do_backtrace, + gettext_noop("backtrace [N] - print trace of all or N innermost (outermost if N < 0) frames.") }, +{ "break", "b", D_break, D_BREAK, do_breakpoint, + gettext_noop("break [[filename:]N|function] - set breakpoint at the specified location.") }, +{ "clear", "", D_clear, D_CLEAR, do_clear, + gettext_noop("clear [[filename:]N|function] - delete breakpoints previously set.") }, +{ "commands", "", D_commands, D_COMMANDS, do_commands, + gettext_noop("commands [num] - starts a list of commands to be executed at a breakpoint(watchpoint) hit.") }, +{ "condition", "", D_condition, D_CONDITION, do_condition, + gettext_noop("condition num [expr] - set or clear breakpoint or watchpoint condition.") }, +{ "continue", "c", D_continue, D_CONTINUE, do_continue, + gettext_noop("continue [COUNT] - continue program being debugged.") }, +{ "delete", "d", D_delete, D_DELETE, do_delete_breakpoint, + gettext_noop("delete [breakpoints] [range] - delete specified breakpoints.") }, +{ "disable", "", D_disable, D_DISABLE, do_disable_breakpoint, + gettext_noop("disable [breakpoints] [range] - disable specified breakpoints.") }, +{ "display", "", D_display, D_DISPLAY, do_display, + gettext_noop("display [var] - print value of variable each time the program stops.") }, +{ "down", "", D_down, D_DOWN, do_down, + gettext_noop("down [N] - move N frames down the stack.") }, +{ "dump", "", D_dump, D_DUMP, do_dump_instructions, + gettext_noop("dump [filename] - dump instructions to file or stdout.") }, +{ "enable", "e", D_enable, D_ENABLE, do_enable_breakpoint, + gettext_noop("enable [once|del] [breakpoints] [range] - enable specified breakpoints.") }, +{ "end", "", D_end, D_END, do_commands, + gettext_noop("end - end a list of commands or awk statements.") }, +{ "eval", "", D_eval, D_EVAL, do_eval, + gettext_noop("eval stmt|[p1, p2, ...] - evaluate awk statement(s).") }, +{ "finish", "", D_finish, D_FINISH, do_finish, + gettext_noop("finish - execute until selected stack frame returns.") }, +{ "frame", "f", D_frame, D_FRAME, do_frame, + gettext_noop("frame [N] - select and print stack frame number N.") }, +{ "help", "h", D_help, D_HELP, do_help, + gettext_noop("help [command] - print list of commands or explanation of command.") }, +{ "ignore", "", D_ignore, D_IGNORE, do_ignore_breakpoint, + gettext_noop("ignore N COUNT - set ignore-count of breakpoint number N to COUNT.") }, +{ "info", "i", D_info, D_INFO, do_info, + gettext_noop("info topic - source|sources|variables|functions|break|frame|args|locals|display|watch.") }, +{ "list", "l", D_list, D_LIST, do_list, + gettext_noop("list [-|+|[filename:]lineno|function|range] - list specified line(s).") }, +{ "next", "n", D_next, D_NEXT, do_next, + gettext_noop("next [COUNT] - step program, proceeding through subroutine calls.") }, +{ "nexti", "ni", D_nexti, D_NEXTI, do_nexti, + gettext_noop("nexti [COUNT] - step one instruction, but proceed through subroutine calls.") }, +{ "option", "o", D_option, D_OPTION, do_option, + gettext_noop("option [name[=value]] - set or display debugger option(s).") }, +{ "print", "p", D_print, D_PRINT, do_print_var, + gettext_noop("print var [var] - print value of a variable or array.") }, +{ "printf", "", D_printf, D_PRINTF, do_print_f, + gettext_noop("printf format, [arg], ... - formatted output.") }, +{ "quit", "q", D_quit, D_QUIT, do_quit, + gettext_noop("quit - exit debugger.") }, +{ "return", "", D_return, D_RETURN, do_return, + gettext_noop("return [value] - make selected stack frame return to its caller.") }, +{ "run", "r", D_run, D_RUN, do_run, + gettext_noop("run - start or restart executing program.") }, +#ifdef HAVE_LIBREADLINE +{ "save", "", D_save, D_SAVE, do_save, + gettext_noop("save filename - save commands from the session to file.") }, +#endif +{ "set", "", D_set, D_SET, do_set_var, + gettext_noop("set var = value - assign value to a scalar variable.") }, +{ "silent", "", D_silent, D_SILENT, do_commands, + gettext_noop("silent - suspends usual message when stopped at a breakpoint/watchpoint.") }, +{ "source", "", D_source, D_SOURCE, do_source, + gettext_noop("source file - execute commands from file.") }, +{ "step", "s", D_step, D_STEP, do_step, + gettext_noop("step [COUNT] - step program until it reaches a different source line.") }, +{ "stepi", "si", D_stepi, D_STEPI, do_stepi, + gettext_noop("stepi [COUNT] - step one instruction exactly.") }, +{ "tbreak", "t", D_tbreak, D_TBREAK, do_tmp_breakpoint, + gettext_noop("tbreak [[filename:]N|function] - set a temporary breakpoint.") }, +{ "trace", "", D_trace, D_TRACE, do_trace_instruction, + gettext_noop("trace on|off - print instruction before executing.") }, +{ "undisplay", "", D_undisplay, D_UNDISPLAY, do_undisplay, + gettext_noop("undisplay [N] - remove variable(s) from automatic display list.") }, +{ "until", "u", D_until, D_UNTIL, do_until, + gettext_noop("until [[filename:]N|function] - execute until program reaches a different line or line N within current frame.") }, +{ "unwatch", "", D_unwatch, D_UNWATCH, do_unwatch, + gettext_noop("unwatch [N] - remove variable(s) from watch list.") }, +{ "up", "", D_up, D_UP, do_up, + gettext_noop("up [N] - move N frames up the stack.") }, +{ "watch", "w", D_watch, D_WATCH, do_watch, + gettext_noop("watch var - set a watchpoint for a variable.") }, +{ NULL, NULL, D_illegal, 0, (Func_cmd) 0, + NULL }, +}; + +struct argtoken argtab[] = { + { "args", D_info, A_ARGS }, + { "break", D_info, A_BREAK }, + { "del", D_enable, A_DEL }, + { "display", D_info, A_DISPLAY }, + { "frame", D_info, A_FRAME }, + { "functions", D_info, A_FUNCTIONS }, + { "locals", D_info, A_LOCALS }, + { "off", D_trace, A_TRACE_OFF }, + { "on", D_trace, A_TRACE_ON }, + { "once", D_enable, A_ONCE }, + { "source", D_info, A_SOURCE }, + { "sources", D_info, A_SOURCES }, + { "variables", D_info, A_VARIABLES }, + { "watch", D_info, A_WATCH }, + { NULL, D_illegal, 0 }, +}; + + +/* get_command --- return command handler function */ + +Func_cmd +get_command(int ctype) +{ + int i; + for (i = 0; cmdtab[i].name != NULL; i++) { + if (cmdtab[i].type == ctype) + return cmdtab[i].cf_ptr; + } + return (Func_cmd) 0; +} + +/* get_command_name --- return command name given it's type */ + +const char * +get_command_name(int ctype) +{ + int i; + for (i = 0; cmdtab[i].name != NULL; i++) { + if (cmdtab[i].type == ctype) + return cmdtab[i].name; + } + return NULL; +} + +/* mk_cmdarg --- make an argument for command */ + +static CMDARG * +mk_cmdarg(enum argtype type) +{ + CMDARG *arg; + emalloc(arg, CMDARG *, sizeof(CMDARG), "mk_cmdarg"); + memset(arg, 0, sizeof(CMDARG)); + arg->type = type; + return arg; +} + +/* append_cmdarg --- append ARG to the list of arguments for the current command */ + +static void +append_cmdarg(CMDARG *arg) +{ + static CMDARG *savetail; + + if (arg_list == NULL) + arg_list = arg; + else + savetail->next = arg; + savetail = arg; +} + +/* free_cmdarg --- free all arguments in LIST */ + +void +free_cmdarg(CMDARG *list) +{ + CMDARG *arg, *nexta; + + for (arg = list; arg != NULL; arg = nexta) { + nexta = arg->next; + + switch (arg->type) { + case D_variable: + case D_subscript: + case D_array: + case D_string: + if (arg->a_string != NULL) + efree(arg->a_string); + break; + case D_node: + case D_field: + unref(arg->a_node); + break; + default: + break; + } + efree(arg); + } +} + +/* yyerror --- print a syntax error message */ + +static void +yyerror(const char *mesg, ...) +{ + va_list args; + va_start(args, mesg); + fprintf(out_fp, _("error: ")); + vfprintf(out_fp, mesg, args); + fprintf(out_fp, "\n"); + va_end(args); + errcount++; + repeat_idx = -1; +} + + +/* yylex --- read a command and turn it into tokens */ + +static int +yylex(void) +{ + static char *lexptr = NULL; + static char *lexend; + int c; + char *tokstart; + size_t toklen; + + yylval = (CMDARG *) NULL; + + if (errcount > 0 && lexptr_begin == NULL) { + /* fake a new line */ + errcount = 0; + return '\n'; + } + + if (lexptr_begin == NULL) { +again: + lexptr_begin = read_a_line(dPrompt); + if (lexptr_begin == NULL) { /* EOF or error */ + if (get_eof_status() == EXIT_FATAL) + exit(EXIT_FATAL); + if (get_eof_status() == EXIT_FAILURE) { + static int seen_eof = 0; + + /* force a quit, and let do_quit (in debug.c) exit */ + if (! seen_eof) { + if (errno != 0) { + fprintf(stderr, _("can't read command (%s)\n"), strerror(errno)); + exit_val = EXIT_FAILURE; + } /* else + exit_val = EXIT_SUCCESS; */ + + seen_eof = 1; + return '\n'; /* end current command if any */ + } else if (seen_eof++ == 1) { + cmd_idx = find_command("quit", 4); + return D_QUIT; /* 'quit' token */ + } else + return '\n'; /* end command 'quit' */ + } + if (errno != 0) + d_error(_("can't read command (%s)"), strerror(errno)); + if (pop_cmd_src() == 0) + goto again; + exit(EXIT_FATAL); /* shouldn't happen */ + } + + if (! in_commands && ! in_eval /* history expansion off in 'commands' and 'eval' */ + && input_from_tty + ) + history_expand_line(&lexptr_begin); + + lexptr = lexptr_begin; + lexend = lexptr + strlen(lexptr); + if (*lexptr == '\0' /* blank line */ + && repeat_idx >= 0 + && input_from_tty + && ! in_eval + ) { +#ifdef HAVE_LIBREADLINE + HIST_ENTRY *h; + h = previous_history(); + if (h != NULL) + add_history(h->line); +#endif + cmd_idx = repeat_idx; + return cmdtab[cmd_idx].class; /* repeat last command */ + } + repeat_idx = -1; + } + + c = *lexptr; + + while (c == ' ' || c == '\t') + c = *++lexptr; + + if (! input_from_tty && c == '#') + return '\n'; + + tokstart = lexptr; + if (lexptr >= lexend) + return '\n'; + + if (cmd_idx < 0) { /* need a command */ + if (c == '?' && tokstart[1] == '\0' && ! in_eval) { + lexptr++; + cmd_idx = find_command("help", 4); + return D_HELP; + } + + while (c != '\0' && c != ' ' && c != '\t') { + if (! isalpha(c) && ! in_eval) { + yyerror(_("invalid character in command")); + return '\n'; + } + c = *++lexptr; + } + + toklen = lexptr - tokstart; + + if (in_eval) { + if (toklen == 3 + && tokstart[3] == '\0' + && tokstart[0] == 'e' + && tokstart[1] == 'n' + && tokstart[2] == 'd' + ) { + cmd_idx = find_command(tokstart, toklen); + return D_END; + } + lexptr = lexend; + return D_STATEMENT; + } + + cmd_idx = find_command(tokstart, toklen); + if (cmd_idx >= 0) { + if (in_commands && cmdtab[cmd_idx].type != D_eval) { + /* add the actual command string (lexptr_begin) to + * arg_list; command string for 'eval' prepended to the arg_list + * in the grammer above (see eval_cmd non-terminal). + */ + CMDARG *arg; + arg = mk_cmdarg(D_string); + arg->a_string = estrdup(lexptr_begin, lexend - lexptr_begin); + append_cmdarg(arg); + } + return cmdtab[cmd_idx].class; + } else { + yyerror(_("unknown command - \"%.*s\", try help"), toklen, tokstart); + return '\n'; + } + } + + c = *lexptr; + + if (cmdtab[cmd_idx].type == D_option) { + if (c == '=') + return *lexptr++; + } else if (c == '-' || c == '+' || c == ':' || c == '|') + return *lexptr++; + + if (c == '"') { + char *str, *p; + int flags = ALREADY_MALLOCED; + int esc_seen = FALSE; + + toklen = lexend - lexptr; + emalloc(str, char *, toklen + 2, "yylex"); + p = str; + + while ((c = *++lexptr) != '"') { + if (lexptr == lexend) { +err: + efree(str); + yyerror(_("unterminated string")); + return '\n'; + } + if (c == '\\') { + c = *++lexptr; + esc_seen = TRUE; + if (want_nodeval || c != '"') + *p++ = '\\'; + } + if (lexptr == lexend) + goto err; + *p++ = c; + } + lexptr++; + *p = '\0'; + + if (! want_nodeval) { + yylval = mk_cmdarg(D_string); + yylval->a_string = estrdup(str, p - str); + append_cmdarg(yylval); + return D_STRING; + } else { /* awk string */ + if (esc_seen) + flags |= SCAN; + yylval = mk_cmdarg(D_node); + yylval->a_node = make_str_node(str, p - str, flags); + append_cmdarg(yylval); + return D_NODE; + } + } + + if (! want_nodeval) { + while ((c = *++lexptr) != '\0' && c != ':' && c != '-' + && c != ' ' && c != '\t' && c != '=') + ; + + /* Is it an integer? */ + if (isdigit((unsigned char) tokstart[0]) && cmdtab[cmd_idx].type != D_option) { + char *end; + long l; + + errno = 0; + l = strtol(tokstart, &end, 0); + if (errno != 0) { + yyerror(_("%s"), strerror(errno)); + errno = 0; + return '\n'; + } + + if (lexptr == end) { + yylval = mk_cmdarg(D_int); + yylval->a_int = l; + append_cmdarg(yylval); + return D_INT; + } + } + + /* Must be string */ + yylval = mk_cmdarg(D_string); + yylval->a_string = estrdup(tokstart, lexptr - tokstart); + append_cmdarg(yylval); + return D_STRING; + } + + /* assert(want_nodval == TRUE); */ + + /* look for awk number */ + + if (isdigit((unsigned char) tokstart[0])) { + double d; + + errno = 0; + d = strtod(tokstart, &lexptr); + if (errno != 0) { + yyerror(strerror(errno)); + errno = 0; + return '\n'; + } + yylval = mk_cmdarg(D_node); + yylval->a_node = make_number(d); + append_cmdarg(yylval); + return D_NODE; + } + + c = *lexptr; + if (c == '$' || c == '@' + || c == '[' || c == ']' + || c == ',' || c == '=') + return *lexptr++; + + if (c != '_' && ! isalpha(c)) { + yyerror(_("invalid character")); + return '\n'; + } + + while (isalnum(c) || c == '_') + c = *++lexptr; + toklen = lexptr - tokstart; + + /* awk variable */ + yylval = mk_cmdarg(D_variable); + yylval->a_string = estrdup(tokstart, toklen); + append_cmdarg(yylval); + return D_VARIABLE; +} + +/* find_argument --- find index in 'argtab' for a command option */ + +static int +find_argument(CMDARG *arg) +{ + /* non-number argument */ + int idx; + char *name, *p; + size_t len; + assert(cmd_idx >= 0); + name = arg->a_string; + len = strlen(name); + for (idx = 0; (p = (char *) argtab[idx].name) != NULL; idx++) { + if (cmdtab[cmd_idx].type == argtab[idx].cmd + && *p == *name + && strlen(p) == len + && strncmp(p, name, len) == 0 + ) + return idx; + } + return -1; /* invalid option */ +} + +/* concat_args --- concatenate argument strings into a single string NODE */ + +static NODE * +concat_args(CMDARG *arg, int count) +{ + NODE *n; + NODE **tmp; + char *str, *subsep, *p; + long len, subseplen; + int i; + + if (count == 1) { + n = force_string(arg->a_node); + return dupnode(n); + } + + emalloc(tmp, NODE **, count * sizeof(NODE *), "concat_args"); + subseplen = SUBSEP_node->var_value->stlen; + subsep = SUBSEP_node->var_value->stptr; + len = -subseplen; + + for (i = 0; i < count; i++) { + n = force_string(arg->a_node); + len += n->stlen + subseplen; + tmp[i] = n; + arg = arg->next; + } + + emalloc(str, char *, len + 2, "concat_args"); + n = tmp[0]; + memcpy(str, n->stptr, n->stlen); + p = str + n->stlen; + for (i = 1; i < count; i++) { + if (subseplen == 1) + *p++ = *subsep; + else if (subseplen > 0) { + memcpy(p, subsep, subseplen); + p += subseplen; + } + + n = tmp[i]; + memcpy(p, n->stptr, n->stlen); + p += n->stlen; + } + str[len] = '\0'; + efree(tmp); + return make_str_node(str, len, ALREADY_MALLOCED); +} + +/* find_command --- find the index in 'cmdtab' using exact, + * abbreviation or unique partial match + */ + +static int +find_command(const char *token, size_t toklen) +{ + char *name, *abrv; + int i, k; + int try_exact = TRUE; + int abrv_match = -1; + int partial_match = -1; + +#if 'a' == 0x81 /* it's EBCDIC */ + /* make sure all lower case characters in token (sorting + * isn't the solution in this case) + */ + for (i = 0; i < toklen; i++) { + if (token[i] != tolower(token[i])) + return -1; + } +#endif + + k = sizeof(cmdtab)/sizeof(cmdtab[0]) - 1; + for (i = 0; i < k; i++) { + name = (char *) cmdtab[i].name; + if (try_exact && *token == *name + && toklen == strlen(name) + && strncmp(name, token, toklen) == 0 + ) + return i; + if (*name > *token) + try_exact = FALSE; + if (abrv_match < 0) { + abrv = cmdtab[i].abbrvn; + if (abrv[0] == token[0]) { + if (toklen == 1 && ! abrv[1]) + abrv_match = i; + else if (toklen == 2 && abrv[1] == token[1]) + abrv_match = i; + } + } + if (! try_exact && abrv_match >= 0) + return abrv_match; + if (partial_match < 0) { + if (*token == *name + && toklen < strlen(name) + && strncmp(name, token, toklen) == 0 + ) { + if ((i == k - 1 || strncmp(cmdtab[i + 1].name, token, toklen) != 0) + && (i == 0 || strncmp(cmdtab[i - 1].name, token, toklen) != 0) + ) + partial_match = i; + } + } + } + return partial_match; +} + +/* do_help -- help command */ + +int +do_help(CMDARG *arg, int cmd) +{ + int i; + if (arg == NULL) { + initialize_pager(out_fp); + if (setjmp(pager_quit_tag) == 0) { + for (i = 0; cmdtab[i].name != NULL; i++) { + gprintf(out_fp, "%s:\n", cmdtab[i].name); + gprintf(out_fp, "\t%s\n", _(cmdtab[i].help_txt)); + } + } + } else if (arg->type == D_string) { + char *name; + name = arg->a_string; + i = find_command(name, strlen(name)); + if (i >= 0) { + fprintf(out_fp, "%s\n", cmdtab[i].help_txt); + if (strcmp(cmdtab[i].name, "option") == 0) + option_help(); + } else + fprintf(out_fp, _("undefined command: %s\n"), name); + } + + return FALSE; +} + + +/* next_word --- find the next word in a line to complete + * (word seperation characters are space and tab). + */ + +static char * +next_word(char *p, int len, char **endp) +{ + char *q; + int i; + + if (p == NULL || len <= 0) + return NULL; + for (i = 0; i < len; i++, p++) + if (*p != ' ' && *p != '\t') + break; + if (i == len) + return NULL; + if (endp != NULL) { + for (i++, q = p + 1; i < len; i++, q++) + if (*q == ' ' || *q == '\t') + break; + *endp = q; + } + return p; +} + +#ifdef HAVE_LIBREADLINE + +/* command_completion --- attempt to complete based on the word number in line; + * try to complete on command names if this is the first word; for the next + * word(s), the type of completion depends on the command name (first word). + */ + +#ifndef RL_READLINE_VERSION /* < 4.2a */ +#define rl_completion_matches(x, y) completion_matches((char *) (x), (y)) +#endif + + +char ** +command_completion(const char *text, int start, int end) +{ + char *cmdtok, *e; + int idx; + int len; + + rl_attempted_completion_over = TRUE; /* no default filename completion please */ + + this_cmd = D_illegal; + len = start; + if ((cmdtok = next_word(rl_line_buffer, len, &e)) == NULL) /* no first word yet */ + return rl_completion_matches(text, command_generator); + len -= (e - rl_line_buffer); + + idx = find_command(cmdtok, e - cmdtok); + if (idx < 0) + return NULL; + this_cmd = cmdtab[idx].type; + + if (! next_word(e, len, NULL)) { + switch (this_cmd) { + case D_break: + case D_list: + case D_until: + case D_tbreak: + case D_clear: + return rl_completion_matches(text, srcfile_generator); + case D_info: + case D_enable: + case D_trace: + case D_help: + return rl_completion_matches(text, argument_generator); + case D_option: + return rl_completion_matches(text, option_generator); + case D_print: + case D_printf: + case D_set: + case D_display: + case D_watch: + return rl_completion_matches(text, variable_generator); + default: + return NULL; + } + } + if (this_cmd == D_print || this_cmd == D_printf) + return rl_completion_matches(text, variable_generator); + return NULL; +} + +/* command_generator --- generator function for command completion */ + +static char * +command_generator(const char *text, int state) +{ + static size_t textlen; + static int idx = 0; + char *name; + + if (! state) { /* first time */ + textlen = strlen(text); + idx = 0; + } + while ((name = (char *) cmdtab[idx].name) != NULL) { + idx++; + if (strncmp(name, text, textlen) == 0) + return estrdup(name, strlen(name)); + } + return NULL; +} + +/* srcfile_generator --- generator function for source file completion */ + +static char * +srcfile_generator(const char *text, int state) +{ + static size_t textlen; + static SRCFILE *s; + char *name; + extern SRCFILE *srcfiles; + + if (! state) { /* first time */ + textlen = strlen(text); + s = srcfiles->next; + } + while (s != srcfiles) { + if (s->stype != SRC_FILE && s->stype != SRC_INC) { + s = s->next; + continue; + } + name = s->src; + s = s->next; + if (strncmp(name, text, textlen) == 0) + return estrdup(name, strlen(name)); + } + return NULL; +} + +/* argument_generator --- generator function for non-number argument completion */ + +static char * +argument_generator(const char *text, int state) +{ + static size_t textlen; + static int idx; + char *name; + + if (! state) { /* first time */ + textlen = strlen(text); + idx = 0; + } + + if (this_cmd == D_help) { + while ((name = (char *) cmdtab[idx++].name) != NULL) { + if (strncmp(name, text, textlen) == 0) + return estrdup(name, strlen(name)); + } + } else { + while ((name = (char *) argtab[idx].name) != NULL) { + if (this_cmd != argtab[idx++].cmd) + continue; + if (strncmp(name, text, textlen) == 0) + return estrdup(name, strlen(name)); + } + } + return NULL; +} + +/* variable_generator --- generator function for variable name completion */ + +static char * +variable_generator(const char *text, int state) +{ + static size_t textlen; + static int idx = 0; + static char **pnames = NULL; + static NODE **var_table = NULL; + char *name; + NODE *hp; + + if (! state) { /* first time */ + textlen = strlen(text); + if (var_table != NULL) + efree(var_table); + var_table = get_varlist(); + idx = 0; + pnames = get_parmlist(); /* names of function params in + * current context; the array + * is NULL terminated in + * awkgram.y (func_install). + */ + } + + /* function params */ + while (pnames != NULL) { + name = pnames[idx]; + if (name == NULL) { + pnames = NULL; /* don't try to match params again */ + idx = 0; + break; + } + idx++; + if (strncmp(name, text, textlen) == 0) + return estrdup(name, strlen(name)); + } + + /* globals */ + while ((hp = var_table[idx]) != NULL) { + idx++; + if (hp->hvalue->type == Node_func) + continue; + if (strncmp(hp->hname, text, textlen) == 0) + return estrdup(hp->hname, hp->hlength); + } + return NULL; +} + +/* history_expand_line --- history expand the LINE */ + +static void +history_expand_line(char **line) +{ + int ret; + char *expansion; + + if (! *line || input_fd != 0 || ! input_from_tty) + return; + using_history(); + ret = history_expand(*line, &expansion); + if (ret < 0 || ret == 2) + efree(expansion); + else { + efree(*line); + *line = expansion; + } +} + +#endif + + diff --git a/command.y b/command.y new file mode 100644 index 0000000..676a545 --- /dev/null +++ b/command.y @@ -0,0 +1,1680 @@ +/* + * command.y - yacc/bison parser for debugger command + */ + +/* + * Copyright (C) 2004, 2010, 2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +%{ +#include "awk.h" +#include "cmd.h" + +#if 0 +#define YYDEBUG 12 +int yydebug = 2; +#endif + +static int yylex(void); +static void yyerror(const char *mesg, ...); + +static int find_command(const char *token, size_t toklen); + +static int want_nodeval = FALSE; + +static int cmd_idx = -1; /* index of current command in cmd table */ +static int repeat_idx = -1; /* index of last repeatable command in command table */ +static CMDARG *arg_list = NULL; /* list of arguments */ +static long errcount = 0; +static char *lexptr_begin = NULL; +static int in_commands = FALSE; +static int num_dim; + +static int in_eval = FALSE; +static const char start_EVAL[] = "function @eval(){"; +static const char end_EVAL[] = "}"; +static CMDARG *append_statement(CMDARG *alist, char *stmt); +static char *next_word(char *p, int len, char **endp); +static NODE *concat_args(CMDARG *a, int count); + +#ifdef HAVE_LIBREADLINE +static void history_expand_line(char **line); +static char *command_generator(const char *text, int state); +static char *srcfile_generator(const char *text, int state); +static char *argument_generator(const char *text, int state); +static char *variable_generator(const char *text, int state); +extern char *option_generator(const char *text, int state); +static int this_cmd = D_illegal; +#else +#define history_expand_line(p) /* nothing */ +static int rl_inhibit_completion; /* dummy variable */ +#endif + +struct argtoken { + const char *name; + enum argtype cmd; + enum nametypeval value; +}; + +/* + * These two should be static, but there are some compilers that + * don't like the static keyword with an empty size. Therefore give + * them names that are less likely to conflict with the rest of gawk. + */ +#define argtab zz_debug_argtab +#define cmdtab zz_debug_cmdtab + +extern struct argtoken argtab[]; +extern struct cmdtoken cmdtab[]; + +static CMDARG *mk_cmdarg(enum argtype type); +static void append_cmdarg(CMDARG *arg); +static int find_argument(CMDARG *arg); +#define YYSTYPE CMDARG * +%} + +%token D_BACKTRACE D_BREAK D_CLEAR D_CONTINUE D_DELETE D_DISABLE D_DOWN +%token D_ENABLE D_FINISH D_FRAME D_HELP D_IGNORE D_INFO D_LIST +%token D_NEXT D_NEXTI D_PRINT D_PRINTF D_QUIT D_RETURN D_RUN D_SET +%token D_STEP D_STEPI D_TBREAK D_UP D_UNTIL +%token D_DISPLAY D_UNDISPLAY D_WATCH D_UNWATCH +%token D_DUMP D_TRACE +%token D_INT D_STRING D_NODE D_VARIABLE +%token D_OPTION D_COMMANDS D_END D_SILENT D_SOURCE +%token D_SAVE D_EVAL D_CONDITION +%token D_STATEMENT + +%% + +input + : /* empty */ + | input line + { + cmd_idx = -1; + want_nodeval = FALSE; + if (lexptr_begin != NULL) { + if (input_from_tty && lexptr_begin[0] != '\0') + add_history(lexptr_begin); + efree(lexptr_begin); + lexptr_begin = NULL; + } + if (arg_list != NULL) { + free_cmdarg(arg_list); + arg_list = NULL; + } + } + ; + +line + : nls + | command nls + { + if (errcount == 0 && cmd_idx >= 0) { + Func_cmd cmdfunc; + int terminate = FALSE; + CMDARG *args; + int ctype = 0; + + ctype = cmdtab[cmd_idx].type; + + /* a blank line repeats previous command + * (list, next, nexti, step, stepi and continue without arguments). + * save the index in the command table; used in yylex + */ + if ((ctype == D_list + || ctype == D_next + || ctype == D_step + || ctype == D_nexti + || ctype == D_stepi + || ctype == D_continue) + && arg_list == NULL + && ! in_commands + && input_from_tty + ) + repeat_idx = cmd_idx; + else + repeat_idx = -1; + + /* call the command handler; reset the globals arg_list, cmd_idx, + * since this handler could invoke yyparse again. + * call do_commands for the list of commands in `commands'; + * arg_list isn't freed on return. + */ + + cmdfunc = cmdtab[cmd_idx].cf_ptr; + if (in_commands) + cmdfunc = do_commands; + cmd_idx = -1; + want_nodeval = FALSE; + + args = arg_list; + arg_list = NULL; + + terminate = (*cmdfunc)(args, ctype); + if (! in_commands || ctype == D_commands) + free_cmdarg(args); + if (terminate) + YYACCEPT; + } + } + | error nls + { + yyerrok; + } + ; + +control_cmd + : D_CONTINUE + | D_NEXT + | D_NEXTI + | D_STEP + | D_STEPI + ; + +d_cmd + : D_UNDISPLAY + | D_UNWATCH + | D_DISABLE + | D_DELETE + ; + +frame_cmd + : D_UP + | D_DOWN + | D_BACKTRACE + | D_FRAME + ; + +break_cmd + : D_BREAK + | D_TBREAK + ; + +/* mid-rule action buried in non-terminal to avoid conflict */ +set_want_nodeval + : { want_nodeval = TRUE; } + ; + +eval_prologue + : D_EVAL set_want_nodeval opt_param_list nls + { + if (errcount == 0) { + /* don't free arg_list; passed on to statement_list + * non-terminal (empty rule action). See below. + */ + if (input_from_tty) { + dPrompt = eval_Prompt; + fprintf(out_fp, _("Type (g)awk statement(s). End with the command \"end\"\n")); + rl_inhibit_completion = 1; + } + cmd_idx = -1; + in_eval = TRUE; + } + } + ; + +statement_list + : /* empty */ + { + $$ = append_statement(arg_list, (char *) start_EVAL); + if (read_a_line == read_commands_string) /* unserializing 'eval' in 'commands' */ + $$->a_string[0] = '\0'; + free_cmdarg(arg_list); + arg_list = NULL; + } + | statement_list D_STATEMENT { $$ = append_statement($1, lexptr_begin); } nls + { + $$ = $3; + } + ; + +eval_cmd + : eval_prologue statement_list D_END + { + arg_list = append_statement($2, (char *) end_EVAL); + if (read_a_line == read_commands_string) { /* unserializing 'eval' in 'commands' */ + char *str = arg_list->a_string; + size_t len = strlen(str); + assert(len > 2 && str[len - 2] == '}'); + str[len - 2] = '\0'; + } + if (input_from_tty) { + dPrompt = in_commands ? commands_Prompt : dgawk_Prompt; + rl_inhibit_completion = 0; + } + cmd_idx = find_command("eval", 4); + in_eval = FALSE; + } + | D_EVAL set_want_nodeval string_node + { + NODE *n; + CMDARG *arg; + n = $3->a_node; + arg = append_statement(NULL, (char *) start_EVAL); + (void) append_statement(arg, n->stptr); + (void) append_statement(arg, (char *) end_EVAL); + free_cmdarg(arg_list); + arg_list = arg; + } + ; + +command + : D_HELP help_args + | D_QUIT + | D_RUN + | D_FINISH + | control_cmd opt_plus_integer + | frame_cmd opt_integer + { + if (cmdtab[cmd_idx].class == D_FRAME + && $2 != NULL && $2->a_int < 0) + yyerror(_("invalid frame number: %d"), $2->a_int); + } + | D_INFO D_STRING + { + int idx = find_argument($2); + if (idx < 0) + yyerror(_("info: invalid option - \"%s\""), $2->a_string); + else { + efree($2->a_string); + $2->a_string = NULL; + $2->type = D_argument; + $2->a_argument = argtab[idx].value; + } + } + | D_IGNORE plus_integer D_INT + | D_ENABLE enable_args + | D_PRINT { want_nodeval = TRUE; } print_args + | D_PRINTF { want_nodeval = TRUE; } printf_args + | D_LIST list_args + | D_UNTIL location + | D_CLEAR location + | break_cmd break_args + | D_SET { want_nodeval = TRUE; } variable '=' node + | D_OPTION option_args + | D_RETURN { want_nodeval = TRUE; } opt_node + | D_DISPLAY { want_nodeval = TRUE; } opt_variable + | D_WATCH { want_nodeval = TRUE; } variable condition_exp + | d_cmd opt_integer_list + | D_DUMP opt_string + | D_SOURCE D_STRING + { + if (in_cmd_src($2->a_string)) + yyerror(_("source \"%s\": already sourced."), $2->a_string); + } + | D_SAVE D_STRING + { + if (! input_from_tty) + yyerror(_("save \"%s\": command not permitted."), $2->a_string); + } + | D_COMMANDS commands_arg + { + int type = 0; + int num; + + if ($2 != NULL) + num = $2->a_int; + + if (errcount != 0) + ; + else if (in_commands) + yyerror(_("Can't use command `commands' for breakpoint/watchpoint commands")); + else if ($2 == NULL && ! (type = has_break_or_watch_point(&num, TRUE))) + yyerror(_("no breakpoint/watchpoint has been set yet")); + else if ($2 != NULL && ! (type = has_break_or_watch_point(&num, FALSE))) + yyerror(_("invalid breakpoint/watchpoint number")); + if (type) { + in_commands = TRUE; + if (input_from_tty) { + dPrompt = commands_Prompt; + fprintf(out_fp, _("Type commands for when %s %d is hit, one per line.\n"), + (type == D_break) ? "breakpoint" : "watchpoint", num); + fprintf(out_fp, _("End with the command \"end\"\n")); + } + } + } + | D_END + { + if (! in_commands) + yyerror(_("`end' valid only in command `commands' or `eval'")); + else { + if (input_from_tty) + dPrompt = dgawk_Prompt; + in_commands = FALSE; + } + } + | D_SILENT + { + if (! in_commands) + yyerror(_("`silent' valid only in command `commands'")); + } + | D_TRACE D_STRING + { + int idx = find_argument($2); + if (idx < 0) + yyerror(_("trace: invalid option - \"%s\""), $2->a_string); + else { + efree($2->a_string); + $2->a_string = NULL; + $2->type = D_argument; + $2->a_argument = argtab[idx].value; + } + } + | D_CONDITION plus_integer { want_nodeval = TRUE; } condition_exp + { + int type; + int num = $2->a_int; + type = has_break_or_watch_point(&num, FALSE); + if (! type) + yyerror(_("condition: invalid breakpoint/watchpoint number")); + } + | eval_cmd + { + if (in_commands) { + /* Prepend command 'eval' to argument list */ + CMDARG *arg; + arg = mk_cmdarg(D_string); + arg->a_string = estrdup("eval", 4); + arg->next = arg_list; + arg_list = arg; + } + } + ; + +condition_exp + : opt_string_node + { + if ($1 != NULL) { + NODE *n = $1->a_node; + $1->type = D_string; + $1->a_string = n->stptr; + freenode(n); + } + $$ = $1; + } + ; + +commands_arg + : opt_plus_integer + | error + { $$ = NULL; } + ; + +opt_param_list + : /* empty */ + { $$ = NULL; } + | param_list + ; + +param_list + : D_VARIABLE + | param_list D_VARIABLE + | param_list ',' D_VARIABLE + | error + { $$ = NULL; } + ; + +opt_string_node + : /* empty */ + { $$ = NULL; } + | string_node + | error + { $$ = NULL; } + ; + +string_node + : D_NODE + { + NODE *n; + n = $1->a_node; + if ((n->flags & STRING) == 0) + yyerror(_("argument not a string")); + } + ; + +option_args + : /* empty */ + { $$ = NULL; } + | D_STRING + { + if (find_option($1->a_string) < 0) + yyerror(_("option: invalid parameter - \"%s\""), $1->a_string); + } + | D_STRING '=' D_STRING + { + if (find_option($1->a_string) < 0) + yyerror(_("option: invalid parameter - \"%s\""), $1->a_string); + } + ; + +func_name + : D_STRING + { + NODE *n; + n = lookup($1->a_string); + if (n == NULL || n->type != Node_func) + yyerror(_("no such function - \"%s\""), $1->a_string); + else { + $1->type = D_func; + efree($1->a_string); + $1->a_string = NULL; + $1->a_node = n; + } + } + ; + +location + : /* empty */ + { $$ = NULL; } + | plus_integer + | func_name + | D_STRING ':' plus_integer + | D_STRING ':' func_name + ; + +break_args + : /* empty */ + { $$ = NULL; } + | plus_integer { want_nodeval = TRUE; } condition_exp + | func_name + | D_STRING ':' plus_integer { want_nodeval = TRUE; } condition_exp + | D_STRING ':' func_name + ; + +opt_variable + : /* empty */ + { $$ = NULL; } + | variable + ; + +opt_string + : /* empty */ + { $$ = NULL; } + | D_STRING + ; + +opt_node + : /* empty */ + { $$ = NULL; } + | node + ; + +help_args + : /* empty */ + | D_STRING + ; + +enable_args + : opt_integer_list + | D_STRING opt_integer_list + { + int idx = find_argument($1); + if (idx < 0) + yyerror(_("enable: invalid option - \"%s\""), $1->a_string); + else { + efree($1->a_string); + $1->a_string = NULL; + $1->type = D_argument; + $1->a_argument = argtab[idx].value; + } + } + ; + +print_exp + : variable + | '@' D_VARIABLE + { + $2->type = D_array; /* dump all items */ + $2->a_count = 0; + } + | '@' D_VARIABLE subscript_list /* dump sub-array items*/ + { + $2->type = D_array; + $2->a_count = num_dim; + } + ; + +print_args + : print_exp + | print_args print_exp + | print_args ',' print_exp + | error + ; + +printf_exp + : D_NODE + | variable + ; + +printf_args + : printf_exp + | printf_args ',' printf_exp + | error + ; + +list_args + : /* empty */ + { $$ = NULL; } + | '+' + { $$ = NULL; } + | '-' + { + CMDARG *a; + a = mk_cmdarg(D_int); + a->a_int = -1; + append_cmdarg(a); + } + | plus_integer + | func_name + | integer_range + | D_STRING ':' plus_integer + | D_STRING ':' func_name + | D_STRING ':' integer_range + ; + +integer_range + : plus_integer '-' plus_integer + { + if ($1->a_int > $3->a_int) + yyerror(_("invalid range specification: %d - %d"), + $1->a_int, $3->a_int); + else + $1->type = D_range; + $$ = $1; + } + ; + +opt_integer_list + : /* empty */ + { $$ = NULL; } + | integer_list + | error + ; + +integer_list + : plus_integer + | integer_range + | integer_list plus_integer + | integer_list integer_range + ; + +exp_list + : node + { $$ = $1; } + | exp_list ',' node + { $$ = $1; } + | error + ; + +subscript + : '[' exp_list ']' + { + CMDARG *a; + NODE *subs; + int count = 0; + + for (a = $2; a != NULL; a = a->next) + count++; + subs = concat_args($2, count); + free_cmdarg($2->next); + $2->next = NULL; + $2->type = D_node; + $2->a_node = subs; + $$ = $2; + } + | '[' exp_list error + ; + +subscript_list + : subscript + { $$ = $1; num_dim = 1; } + | subscript_list subscript + { $$ = $1; num_dim++; } + ; + +variable + : D_VARIABLE + | '$' D_NODE + { + NODE *n = $2->a_node; + if ((n->flags & NUMBER) == 0) + yyerror(_("non-numeric value for field number")); + else + $2->type = D_field; + $$ = $2; + } + | D_VARIABLE subscript_list + { + /* a_string is array name, a_count is dimension count */ + $1->type = D_subscript; + $1->a_count = num_dim; + $$ = $1; + } + ; + +node + : D_NODE + { $$ = $1; } + | '+' D_NODE + { + NODE *n = $2->a_node; + if ((n->flags & NUMBER) == 0) + yyerror(_("non-numeric value found, numeric expected")); + $$ = $2; + } + | '-' D_NODE + { + NODE *n = $2->a_node; + if ((n->flags & NUMBER) == 0) + yyerror(_("non-numeric value found, numeric expected")); + else + $2->a_node->numbr = - n->numbr; + $$ = $2; + } + ; + +opt_plus_integer + : /* empty */ + { $$ = NULL; } + | plus_integer + { $$ = $1; } + ; + +opt_integer + : /* empty */ + { $$ = NULL; } + | integer + { $$ = $1; } + ; + +plus_integer + : D_INT + { + if ($1->a_int == 0) + yyerror(_("non-zero integer value")); + $$ = $1; + } + | '+' D_INT + { + if ($2->a_int == 0) + yyerror(_("non-zero integer value")); + $$ = $2; + } + ; + +integer + : D_INT + { $$ = $1; } + | '+' D_INT + { $$ = $2; } + | '-' D_INT + { + $2->a_int = - $2->a_int; + $$ = $2; + } + ; + +nls + : '\n' + { + if (lexptr_begin != NULL) { + if (input_from_tty && lexptr_begin[0] != '\0') + add_history(lexptr_begin); + efree(lexptr_begin); + lexptr_begin = NULL; + } + } + ; + +%% + + +/* append_statement --- append 'stmt' to the list of eval awk statements */ + +static CMDARG * +append_statement(CMDARG *alist, char *stmt) +{ + CMDARG *a, *arg; + char *s; + int len, slen, ssize; + +#define EVALSIZE 512 + + if (stmt == start_EVAL) { + len = sizeof(start_EVAL); + for (a = alist; a != NULL; a = a->next) + len += strlen(a->a_string) + 1; /* 1 for ',' */ + len += EVALSIZE; + + emalloc(s, char *, (len + 2) * sizeof(char), "append_statement"); + arg = mk_cmdarg(D_string); + arg->a_string = s; + arg->a_count = len; /* kludge */ + + slen = sizeof("function @eval(") - 1; + memcpy(s, start_EVAL, slen); + + for (a = alist; a != NULL; a = a->next) { + len = strlen(a->a_string); + memcpy(s + slen, a->a_string, len); + slen += len; + if (a->next != NULL) + s[slen++] = ','; + } + s[slen++] = ')'; + s[slen++] = '{'; + s[slen] = '\0'; + return arg; + } + + len = strlen(stmt) + 1; /* 1 for newline */ + s = alist->a_string; + slen = strlen(s); + ssize = alist->a_count; + if (len > ssize - slen) { + ssize = slen + len + EVALSIZE; + erealloc(s, char *, (ssize + 2) * sizeof(char), "append_statement"); + alist->a_string = s; + alist->a_count = ssize; + } + memcpy(s + slen, stmt, len); + slen += len; + if (slen >= 2 && s[slen - 2] != '\n') { + s[slen - 1] = '\n'; + s[slen] = '\0'; + } + + if (stmt == end_EVAL) + erealloc(alist->a_string, char *, slen + 2, "append_statement"); + return alist; + +#undef EVALSIZE +} + + +/* command names sorted in ascending order */ + +struct cmdtoken cmdtab[] = { +{ "backtrace", "bt", D_backtrace, D_BACKTRACE, do_backtrace, + gettext_noop("backtrace [N] - print trace of all or N innermost (outermost if N < 0) frames.") }, +{ "break", "b", D_break, D_BREAK, do_breakpoint, + gettext_noop("break [[filename:]N|function] - set breakpoint at the specified location.") }, +{ "clear", "", D_clear, D_CLEAR, do_clear, + gettext_noop("clear [[filename:]N|function] - delete breakpoints previously set.") }, +{ "commands", "", D_commands, D_COMMANDS, do_commands, + gettext_noop("commands [num] - starts a list of commands to be executed at a breakpoint(watchpoint) hit.") }, +{ "condition", "", D_condition, D_CONDITION, do_condition, + gettext_noop("condition num [expr] - set or clear breakpoint or watchpoint condition.") }, +{ "continue", "c", D_continue, D_CONTINUE, do_continue, + gettext_noop("continue [COUNT] - continue program being debugged.") }, +{ "delete", "d", D_delete, D_DELETE, do_delete_breakpoint, + gettext_noop("delete [breakpoints] [range] - delete specified breakpoints.") }, +{ "disable", "", D_disable, D_DISABLE, do_disable_breakpoint, + gettext_noop("disable [breakpoints] [range] - disable specified breakpoints.") }, +{ "display", "", D_display, D_DISPLAY, do_display, + gettext_noop("display [var] - print value of variable each time the program stops.") }, +{ "down", "", D_down, D_DOWN, do_down, + gettext_noop("down [N] - move N frames down the stack.") }, +{ "dump", "", D_dump, D_DUMP, do_dump_instructions, + gettext_noop("dump [filename] - dump instructions to file or stdout.") }, +{ "enable", "e", D_enable, D_ENABLE, do_enable_breakpoint, + gettext_noop("enable [once|del] [breakpoints] [range] - enable specified breakpoints.") }, +{ "end", "", D_end, D_END, do_commands, + gettext_noop("end - end a list of commands or awk statements.") }, +{ "eval", "", D_eval, D_EVAL, do_eval, + gettext_noop("eval stmt|[p1, p2, ...] - evaluate awk statement(s).") }, +{ "finish", "", D_finish, D_FINISH, do_finish, + gettext_noop("finish - execute until selected stack frame returns.") }, +{ "frame", "f", D_frame, D_FRAME, do_frame, + gettext_noop("frame [N] - select and print stack frame number N.") }, +{ "help", "h", D_help, D_HELP, do_help, + gettext_noop("help [command] - print list of commands or explanation of command.") }, +{ "ignore", "", D_ignore, D_IGNORE, do_ignore_breakpoint, + gettext_noop("ignore N COUNT - set ignore-count of breakpoint number N to COUNT.") }, +{ "info", "i", D_info, D_INFO, do_info, + gettext_noop("info topic - source|sources|variables|functions|break|frame|args|locals|display|watch.") }, +{ "list", "l", D_list, D_LIST, do_list, + gettext_noop("list [-|+|[filename:]lineno|function|range] - list specified line(s).") }, +{ "next", "n", D_next, D_NEXT, do_next, + gettext_noop("next [COUNT] - step program, proceeding through subroutine calls.") }, +{ "nexti", "ni", D_nexti, D_NEXTI, do_nexti, + gettext_noop("nexti [COUNT] - step one instruction, but proceed through subroutine calls.") }, +{ "option", "o", D_option, D_OPTION, do_option, + gettext_noop("option [name[=value]] - set or display debugger option(s).") }, +{ "print", "p", D_print, D_PRINT, do_print_var, + gettext_noop("print var [var] - print value of a variable or array.") }, +{ "printf", "", D_printf, D_PRINTF, do_print_f, + gettext_noop("printf format, [arg], ... - formatted output.") }, +{ "quit", "q", D_quit, D_QUIT, do_quit, + gettext_noop("quit - exit debugger.") }, +{ "return", "", D_return, D_RETURN, do_return, + gettext_noop("return [value] - make selected stack frame return to its caller.") }, +{ "run", "r", D_run, D_RUN, do_run, + gettext_noop("run - start or restart executing program.") }, +#ifdef HAVE_LIBREADLINE +{ "save", "", D_save, D_SAVE, do_save, + gettext_noop("save filename - save commands from the session to file.") }, +#endif +{ "set", "", D_set, D_SET, do_set_var, + gettext_noop("set var = value - assign value to a scalar variable.") }, +{ "silent", "", D_silent, D_SILENT, do_commands, + gettext_noop("silent - suspends usual message when stopped at a breakpoint/watchpoint.") }, +{ "source", "", D_source, D_SOURCE, do_source, + gettext_noop("source file - execute commands from file.") }, +{ "step", "s", D_step, D_STEP, do_step, + gettext_noop("step [COUNT] - step program until it reaches a different source line.") }, +{ "stepi", "si", D_stepi, D_STEPI, do_stepi, + gettext_noop("stepi [COUNT] - step one instruction exactly.") }, +{ "tbreak", "t", D_tbreak, D_TBREAK, do_tmp_breakpoint, + gettext_noop("tbreak [[filename:]N|function] - set a temporary breakpoint.") }, +{ "trace", "", D_trace, D_TRACE, do_trace_instruction, + gettext_noop("trace on|off - print instruction before executing.") }, +{ "undisplay", "", D_undisplay, D_UNDISPLAY, do_undisplay, + gettext_noop("undisplay [N] - remove variable(s) from automatic display list.") }, +{ "until", "u", D_until, D_UNTIL, do_until, + gettext_noop("until [[filename:]N|function] - execute until program reaches a different line or line N within current frame.") }, +{ "unwatch", "", D_unwatch, D_UNWATCH, do_unwatch, + gettext_noop("unwatch [N] - remove variable(s) from watch list.") }, +{ "up", "", D_up, D_UP, do_up, + gettext_noop("up [N] - move N frames up the stack.") }, +{ "watch", "w", D_watch, D_WATCH, do_watch, + gettext_noop("watch var - set a watchpoint for a variable.") }, +{ NULL, NULL, D_illegal, 0, (Func_cmd) 0, + NULL }, +}; + +struct argtoken argtab[] = { + { "args", D_info, A_ARGS }, + { "break", D_info, A_BREAK }, + { "del", D_enable, A_DEL }, + { "display", D_info, A_DISPLAY }, + { "frame", D_info, A_FRAME }, + { "functions", D_info, A_FUNCTIONS }, + { "locals", D_info, A_LOCALS }, + { "off", D_trace, A_TRACE_OFF }, + { "on", D_trace, A_TRACE_ON }, + { "once", D_enable, A_ONCE }, + { "source", D_info, A_SOURCE }, + { "sources", D_info, A_SOURCES }, + { "variables", D_info, A_VARIABLES }, + { "watch", D_info, A_WATCH }, + { NULL, D_illegal, 0 }, +}; + + +/* get_command --- return command handler function */ + +Func_cmd +get_command(int ctype) +{ + int i; + for (i = 0; cmdtab[i].name != NULL; i++) { + if (cmdtab[i].type == ctype) + return cmdtab[i].cf_ptr; + } + return (Func_cmd) 0; +} + +/* get_command_name --- return command name given it's type */ + +const char * +get_command_name(int ctype) +{ + int i; + for (i = 0; cmdtab[i].name != NULL; i++) { + if (cmdtab[i].type == ctype) + return cmdtab[i].name; + } + return NULL; +} + +/* mk_cmdarg --- make an argument for command */ + +static CMDARG * +mk_cmdarg(enum argtype type) +{ + CMDARG *arg; + emalloc(arg, CMDARG *, sizeof(CMDARG), "mk_cmdarg"); + memset(arg, 0, sizeof(CMDARG)); + arg->type = type; + return arg; +} + +/* append_cmdarg --- append ARG to the list of arguments for the current command */ + +static void +append_cmdarg(CMDARG *arg) +{ + static CMDARG *savetail; + + if (arg_list == NULL) + arg_list = arg; + else + savetail->next = arg; + savetail = arg; +} + +/* free_cmdarg --- free all arguments in LIST */ + +void +free_cmdarg(CMDARG *list) +{ + CMDARG *arg, *nexta; + + for (arg = list; arg != NULL; arg = nexta) { + nexta = arg->next; + + switch (arg->type) { + case D_variable: + case D_subscript: + case D_array: + case D_string: + if (arg->a_string != NULL) + efree(arg->a_string); + break; + case D_node: + case D_field: + unref(arg->a_node); + break; + default: + break; + } + efree(arg); + } +} + +/* yyerror --- print a syntax error message */ + +static void +yyerror(const char *mesg, ...) +{ + va_list args; + va_start(args, mesg); + fprintf(out_fp, _("error: ")); + vfprintf(out_fp, mesg, args); + fprintf(out_fp, "\n"); + va_end(args); + errcount++; + repeat_idx = -1; +} + + +/* yylex --- read a command and turn it into tokens */ + +static int +yylex(void) +{ + static char *lexptr = NULL; + static char *lexend; + int c; + char *tokstart; + size_t toklen; + + yylval = (CMDARG *) NULL; + + if (errcount > 0 && lexptr_begin == NULL) { + /* fake a new line */ + errcount = 0; + return '\n'; + } + + if (lexptr_begin == NULL) { +again: + lexptr_begin = read_a_line(dPrompt); + if (lexptr_begin == NULL) { /* EOF or error */ + if (get_eof_status() == EXIT_FATAL) + exit(EXIT_FATAL); + if (get_eof_status() == EXIT_FAILURE) { + static int seen_eof = 0; + + /* force a quit, and let do_quit (in debug.c) exit */ + if (! seen_eof) { + if (errno != 0) { + fprintf(stderr, _("can't read command (%s)\n"), strerror(errno)); + exit_val = EXIT_FAILURE; + } /* else + exit_val = EXIT_SUCCESS; */ + + seen_eof = 1; + return '\n'; /* end current command if any */ + } else if (seen_eof++ == 1) { + cmd_idx = find_command("quit", 4); + return D_QUIT; /* 'quit' token */ + } else + return '\n'; /* end command 'quit' */ + } + if (errno != 0) + d_error(_("can't read command (%s)"), strerror(errno)); + if (pop_cmd_src() == 0) + goto again; + exit(EXIT_FATAL); /* shouldn't happen */ + } + + if (! in_commands && ! in_eval /* history expansion off in 'commands' and 'eval' */ + && input_from_tty + ) + history_expand_line(&lexptr_begin); + + lexptr = lexptr_begin; + lexend = lexptr + strlen(lexptr); + if (*lexptr == '\0' /* blank line */ + && repeat_idx >= 0 + && input_from_tty + && ! in_eval + ) { +#ifdef HAVE_LIBREADLINE + HIST_ENTRY *h; + h = previous_history(); + if (h != NULL) + add_history(h->line); +#endif + cmd_idx = repeat_idx; + return cmdtab[cmd_idx].class; /* repeat last command */ + } + repeat_idx = -1; + } + + c = *lexptr; + + while (c == ' ' || c == '\t') + c = *++lexptr; + + if (! input_from_tty && c == '#') + return '\n'; + + tokstart = lexptr; + if (lexptr >= lexend) + return '\n'; + + if (cmd_idx < 0) { /* need a command */ + if (c == '?' && tokstart[1] == '\0' && ! in_eval) { + lexptr++; + cmd_idx = find_command("help", 4); + return D_HELP; + } + + while (c != '\0' && c != ' ' && c != '\t') { + if (! isalpha(c) && ! in_eval) { + yyerror(_("invalid character in command")); + return '\n'; + } + c = *++lexptr; + } + + toklen = lexptr - tokstart; + + if (in_eval) { + if (toklen == 3 + && tokstart[3] == '\0' + && tokstart[0] == 'e' + && tokstart[1] == 'n' + && tokstart[2] == 'd' + ) { + cmd_idx = find_command(tokstart, toklen); + return D_END; + } + lexptr = lexend; + return D_STATEMENT; + } + + cmd_idx = find_command(tokstart, toklen); + if (cmd_idx >= 0) { + if (in_commands && cmdtab[cmd_idx].type != D_eval) { + /* add the actual command string (lexptr_begin) to + * arg_list; command string for 'eval' prepended to the arg_list + * in the grammer above (see eval_cmd non-terminal). + */ + CMDARG *arg; + arg = mk_cmdarg(D_string); + arg->a_string = estrdup(lexptr_begin, lexend - lexptr_begin); + append_cmdarg(arg); + } + return cmdtab[cmd_idx].class; + } else { + yyerror(_("unknown command - \"%.*s\", try help"), toklen, tokstart); + return '\n'; + } + } + + c = *lexptr; + + if (cmdtab[cmd_idx].type == D_option) { + if (c == '=') + return *lexptr++; + } else if (c == '-' || c == '+' || c == ':' || c == '|') + return *lexptr++; + + if (c == '"') { + char *str, *p; + int flags = ALREADY_MALLOCED; + int esc_seen = FALSE; + + toklen = lexend - lexptr; + emalloc(str, char *, toklen + 2, "yylex"); + p = str; + + while ((c = *++lexptr) != '"') { + if (lexptr == lexend) { +err: + efree(str); + yyerror(_("unterminated string")); + return '\n'; + } + if (c == '\\') { + c = *++lexptr; + esc_seen = TRUE; + if (want_nodeval || c != '"') + *p++ = '\\'; + } + if (lexptr == lexend) + goto err; + *p++ = c; + } + lexptr++; + *p = '\0'; + + if (! want_nodeval) { + yylval = mk_cmdarg(D_string); + yylval->a_string = estrdup(str, p - str); + append_cmdarg(yylval); + return D_STRING; + } else { /* awk string */ + if (esc_seen) + flags |= SCAN; + yylval = mk_cmdarg(D_node); + yylval->a_node = make_str_node(str, p - str, flags); + append_cmdarg(yylval); + return D_NODE; + } + } + + if (! want_nodeval) { + while ((c = *++lexptr) != '\0' && c != ':' && c != '-' + && c != ' ' && c != '\t' && c != '=') + ; + + /* Is it an integer? */ + if (isdigit((unsigned char) tokstart[0]) && cmdtab[cmd_idx].type != D_option) { + char *end; + long l; + + errno = 0; + l = strtol(tokstart, &end, 0); + if (errno != 0) { + yyerror(_("%s"), strerror(errno)); + errno = 0; + return '\n'; + } + + if (lexptr == end) { + yylval = mk_cmdarg(D_int); + yylval->a_int = l; + append_cmdarg(yylval); + return D_INT; + } + } + + /* Must be string */ + yylval = mk_cmdarg(D_string); + yylval->a_string = estrdup(tokstart, lexptr - tokstart); + append_cmdarg(yylval); + return D_STRING; + } + + /* assert(want_nodval == TRUE); */ + + /* look for awk number */ + + if (isdigit((unsigned char) tokstart[0])) { + double d; + + errno = 0; + d = strtod(tokstart, &lexptr); + if (errno != 0) { + yyerror(strerror(errno)); + errno = 0; + return '\n'; + } + yylval = mk_cmdarg(D_node); + yylval->a_node = make_number(d); + append_cmdarg(yylval); + return D_NODE; + } + + c = *lexptr; + if (c == '$' || c == '@' + || c == '[' || c == ']' + || c == ',' || c == '=') + return *lexptr++; + + if (c != '_' && ! isalpha(c)) { + yyerror(_("invalid character")); + return '\n'; + } + + while (isalnum(c) || c == '_') + c = *++lexptr; + toklen = lexptr - tokstart; + + /* awk variable */ + yylval = mk_cmdarg(D_variable); + yylval->a_string = estrdup(tokstart, toklen); + append_cmdarg(yylval); + return D_VARIABLE; +} + +/* find_argument --- find index in 'argtab' for a command option */ + +static int +find_argument(CMDARG *arg) +{ + /* non-number argument */ + int idx; + char *name, *p; + size_t len; + assert(cmd_idx >= 0); + name = arg->a_string; + len = strlen(name); + for (idx = 0; (p = (char *) argtab[idx].name) != NULL; idx++) { + if (cmdtab[cmd_idx].type == argtab[idx].cmd + && *p == *name + && strlen(p) == len + && strncmp(p, name, len) == 0 + ) + return idx; + } + return -1; /* invalid option */ +} + +/* concat_args --- concatenate argument strings into a single string NODE */ + +static NODE * +concat_args(CMDARG *arg, int count) +{ + NODE *n; + NODE **tmp; + char *str, *subsep, *p; + long len, subseplen; + int i; + + if (count == 1) { + n = force_string(arg->a_node); + return dupnode(n); + } + + emalloc(tmp, NODE **, count * sizeof(NODE *), "concat_args"); + subseplen = SUBSEP_node->var_value->stlen; + subsep = SUBSEP_node->var_value->stptr; + len = -subseplen; + + for (i = 0; i < count; i++) { + n = force_string(arg->a_node); + len += n->stlen + subseplen; + tmp[i] = n; + arg = arg->next; + } + + emalloc(str, char *, len + 2, "concat_args"); + n = tmp[0]; + memcpy(str, n->stptr, n->stlen); + p = str + n->stlen; + for (i = 1; i < count; i++) { + if (subseplen == 1) + *p++ = *subsep; + else if (subseplen > 0) { + memcpy(p, subsep, subseplen); + p += subseplen; + } + + n = tmp[i]; + memcpy(p, n->stptr, n->stlen); + p += n->stlen; + } + str[len] = '\0'; + efree(tmp); + return make_str_node(str, len, ALREADY_MALLOCED); +} + +/* find_command --- find the index in 'cmdtab' using exact, + * abbreviation or unique partial match + */ + +static int +find_command(const char *token, size_t toklen) +{ + char *name, *abrv; + int i, k; + int try_exact = TRUE; + int abrv_match = -1; + int partial_match = -1; + +#if 'a' == 0x81 /* it's EBCDIC */ + /* make sure all lower case characters in token (sorting + * isn't the solution in this case) + */ + for (i = 0; i < toklen; i++) { + if (token[i] != tolower(token[i])) + return -1; + } +#endif + + k = sizeof(cmdtab)/sizeof(cmdtab[0]) - 1; + for (i = 0; i < k; i++) { + name = (char *) cmdtab[i].name; + if (try_exact && *token == *name + && toklen == strlen(name) + && strncmp(name, token, toklen) == 0 + ) + return i; + if (*name > *token) + try_exact = FALSE; + if (abrv_match < 0) { + abrv = cmdtab[i].abbrvn; + if (abrv[0] == token[0]) { + if (toklen == 1 && ! abrv[1]) + abrv_match = i; + else if (toklen == 2 && abrv[1] == token[1]) + abrv_match = i; + } + } + if (! try_exact && abrv_match >= 0) + return abrv_match; + if (partial_match < 0) { + if (*token == *name + && toklen < strlen(name) + && strncmp(name, token, toklen) == 0 + ) { + if ((i == k - 1 || strncmp(cmdtab[i + 1].name, token, toklen) != 0) + && (i == 0 || strncmp(cmdtab[i - 1].name, token, toklen) != 0) + ) + partial_match = i; + } + } + } + return partial_match; +} + +/* do_help -- help command */ + +int +do_help(CMDARG *arg, int cmd) +{ + int i; + if (arg == NULL) { + initialize_pager(out_fp); + if (setjmp(pager_quit_tag) == 0) { + for (i = 0; cmdtab[i].name != NULL; i++) { + gprintf(out_fp, "%s:\n", cmdtab[i].name); + gprintf(out_fp, "\t%s\n", _(cmdtab[i].help_txt)); + } + } + } else if (arg->type == D_string) { + char *name; + name = arg->a_string; + i = find_command(name, strlen(name)); + if (i >= 0) { + fprintf(out_fp, "%s\n", cmdtab[i].help_txt); + if (strcmp(cmdtab[i].name, "option") == 0) + option_help(); + } else + fprintf(out_fp, _("undefined command: %s\n"), name); + } + + return FALSE; +} + + +/* next_word --- find the next word in a line to complete + * (word seperation characters are space and tab). + */ + +static char * +next_word(char *p, int len, char **endp) +{ + char *q; + int i; + + if (p == NULL || len <= 0) + return NULL; + for (i = 0; i < len; i++, p++) + if (*p != ' ' && *p != '\t') + break; + if (i == len) + return NULL; + if (endp != NULL) { + for (i++, q = p + 1; i < len; i++, q++) + if (*q == ' ' || *q == '\t') + break; + *endp = q; + } + return p; +} + +#ifdef HAVE_LIBREADLINE + +/* command_completion --- attempt to complete based on the word number in line; + * try to complete on command names if this is the first word; for the next + * word(s), the type of completion depends on the command name (first word). + */ + +#ifndef RL_READLINE_VERSION /* < 4.2a */ +#define rl_completion_matches(x, y) completion_matches((char *) (x), (y)) +#endif + + +char ** +command_completion(const char *text, int start, int end) +{ + char *cmdtok, *e; + int idx; + int len; + + rl_attempted_completion_over = TRUE; /* no default filename completion please */ + + this_cmd = D_illegal; + len = start; + if ((cmdtok = next_word(rl_line_buffer, len, &e)) == NULL) /* no first word yet */ + return rl_completion_matches(text, command_generator); + len -= (e - rl_line_buffer); + + idx = find_command(cmdtok, e - cmdtok); + if (idx < 0) + return NULL; + this_cmd = cmdtab[idx].type; + + if (! next_word(e, len, NULL)) { + switch (this_cmd) { + case D_break: + case D_list: + case D_until: + case D_tbreak: + case D_clear: + return rl_completion_matches(text, srcfile_generator); + case D_info: + case D_enable: + case D_trace: + case D_help: + return rl_completion_matches(text, argument_generator); + case D_option: + return rl_completion_matches(text, option_generator); + case D_print: + case D_printf: + case D_set: + case D_display: + case D_watch: + return rl_completion_matches(text, variable_generator); + default: + return NULL; + } + } + if (this_cmd == D_print || this_cmd == D_printf) + return rl_completion_matches(text, variable_generator); + return NULL; +} + +/* command_generator --- generator function for command completion */ + +static char * +command_generator(const char *text, int state) +{ + static size_t textlen; + static int idx = 0; + char *name; + + if (! state) { /* first time */ + textlen = strlen(text); + idx = 0; + } + while ((name = (char *) cmdtab[idx].name) != NULL) { + idx++; + if (strncmp(name, text, textlen) == 0) + return estrdup(name, strlen(name)); + } + return NULL; +} + +/* srcfile_generator --- generator function for source file completion */ + +static char * +srcfile_generator(const char *text, int state) +{ + static size_t textlen; + static SRCFILE *s; + char *name; + extern SRCFILE *srcfiles; + + if (! state) { /* first time */ + textlen = strlen(text); + s = srcfiles->next; + } + while (s != srcfiles) { + if (s->stype != SRC_FILE && s->stype != SRC_INC) { + s = s->next; + continue; + } + name = s->src; + s = s->next; + if (strncmp(name, text, textlen) == 0) + return estrdup(name, strlen(name)); + } + return NULL; +} + +/* argument_generator --- generator function for non-number argument completion */ + +static char * +argument_generator(const char *text, int state) +{ + static size_t textlen; + static int idx; + char *name; + + if (! state) { /* first time */ + textlen = strlen(text); + idx = 0; + } + + if (this_cmd == D_help) { + while ((name = (char *) cmdtab[idx++].name) != NULL) { + if (strncmp(name, text, textlen) == 0) + return estrdup(name, strlen(name)); + } + } else { + while ((name = (char *) argtab[idx].name) != NULL) { + if (this_cmd != argtab[idx++].cmd) + continue; + if (strncmp(name, text, textlen) == 0) + return estrdup(name, strlen(name)); + } + } + return NULL; +} + +/* variable_generator --- generator function for variable name completion */ + +static char * +variable_generator(const char *text, int state) +{ + static size_t textlen; + static int idx = 0; + static char **pnames = NULL; + static NODE **var_table = NULL; + char *name; + NODE *hp; + + if (! state) { /* first time */ + textlen = strlen(text); + if (var_table != NULL) + efree(var_table); + var_table = get_varlist(); + idx = 0; + pnames = get_parmlist(); /* names of function params in + * current context; the array + * is NULL terminated in + * awkgram.y (func_install). + */ + } + + /* function params */ + while (pnames != NULL) { + name = pnames[idx]; + if (name == NULL) { + pnames = NULL; /* don't try to match params again */ + idx = 0; + break; + } + idx++; + if (strncmp(name, text, textlen) == 0) + return estrdup(name, strlen(name)); + } + + /* globals */ + while ((hp = var_table[idx]) != NULL) { + idx++; + if (hp->hvalue->type == Node_func) + continue; + if (strncmp(hp->hname, text, textlen) == 0) + return estrdup(hp->hname, hp->hlength); + } + return NULL; +} + +/* history_expand_line --- history expand the LINE */ + +static void +history_expand_line(char **line) +{ + int ret; + char *expansion; + + if (! *line || input_fd != 0 || ! input_from_tty) + return; + using_history(); + ret = history_expand(*line, &expansion); + if (ret < 0 || ret == 2) + efree(expansion); + else { + efree(*line); + *line = expansion; + } +} + +#endif + diff --git a/config.guess b/config.guess new file mode 100755 index 0000000..850a1a4 --- /dev/null +++ b/config.guess @@ -0,0 +1,1500 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, +# Inc. + +timestamp='2006-07-02' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + x86:Interix*:[3456]*) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + EM64T:Interix*:[3456]*) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + or32:Linux:*:*) + echo or32-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-gnu + exit ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^LIBC/{ + s: ::g + p + }'`" + test x"${LIBC}" != x && { + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit + } + test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/config.rpath b/config.rpath new file mode 100755 index 0000000..17298f2 --- /dev/null +++ b/config.rpath @@ -0,0 +1,672 @@ +#! /bin/sh +# Output a system dependent set of variables, describing how to set the +# run time search path of shared libraries in an executable. +# +# Copyright 1996-2010 Free Software Foundation, Inc. +# Taken from GNU libtool, 2001 +# Originally by Gordon Matzigkeit , 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# The first argument passed to this file is the canonical host specification, +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld +# should be set by the caller. +# +# The set of defined variables is at the end of this script. + +# Known limitations: +# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer +# than 256 bytes, otherwise the compiler driver will dump core. The only +# known workaround is to choose shorter directory names for the build +# directory and/or the installation directory. + +# All known linkers require a `.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a +shrext=.so + +host="$1" +host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +# Code taken from libtool.m4's _LT_CC_BASENAME. + +for cc_temp in $CC""; do + case $cc_temp in + compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; + distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; + \-*) ;; + *) break;; + esac +done +cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` + +# Code taken from libtool.m4's _LT_COMPILER_PIC. + +wl= +if test "$GCC" = yes; then + wl='-Wl,' +else + case "$host_os" in + aix*) + wl='-Wl,' + ;; + darwin*) + case $cc_basename in + xlc*) + wl='-Wl,' + ;; + esac + ;; + mingw* | cygwin* | pw32* | os2* | cegcc*) + ;; + hpux9* | hpux10* | hpux11*) + wl='-Wl,' + ;; + irix5* | irix6* | nonstopux*) + wl='-Wl,' + ;; + newsos6) + ;; + linux* | k*bsd*-gnu) + case $cc_basename in + ecc*) + wl='-Wl,' + ;; + icc* | ifort*) + wl='-Wl,' + ;; + lf95*) + wl='-Wl,' + ;; + pgcc | pgf77 | pgf90) + wl='-Wl,' + ;; + ccc*) + wl='-Wl,' + ;; + como) + wl='-lopt=' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + wl='-Wl,' + ;; + esac + ;; + esac + ;; + osf3* | osf4* | osf5*) + wl='-Wl,' + ;; + rdos*) + ;; + solaris*) + wl='-Wl,' + ;; + sunos4*) + wl='-Qoption ld ' + ;; + sysv4 | sysv4.2uw2* | sysv4.3*) + wl='-Wl,' + ;; + sysv4*MP*) + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + wl='-Wl,' + ;; + unicos*) + wl='-Wl,' + ;; + uts4*) + ;; + esac +fi + +# Code taken from libtool.m4's _LT_LINKER_SHLIBS. + +hardcode_libdir_flag_spec= +hardcode_libdir_separator= +hardcode_direct=no +hardcode_minus_L=no + +case "$host_os" in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd*) + with_gnu_ld=no + ;; +esac + +ld_shlibs=yes +if test "$with_gnu_ld" = yes; then + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + # Unlike libtool, we use -rpath here, not --rpath, since the documented + # option of GNU ld is called -rpath, not --rpath. + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + case "$host_os" in + aix[3-9]*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + fi + ;; + amigaos*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we cannot use + # them. + ld_shlibs=no + ;; + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + cygwin* | mingw* | pw32* | cegcc*) + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + interix[3-9]*) + hardcode_direct=no + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + gnu* | linux* | k*bsd*-gnu) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + netbsd*) + ;; + solaris*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) + ld_shlibs=no + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' + else + ld_shlibs=no + fi + ;; + esac + ;; + sunos4*) + hardcode_direct=yes + ;; + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + : + else + ld_shlibs=no + fi + ;; + esac + if test "$ld_shlibs" = no; then + hardcode_libdir_flag_spec= + fi +else + case "$host_os" in + aix3*) + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + aix[4-9]*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + else + aix_use_runtimelinking=no + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + ;; + esac + fi + hardcode_direct=yes + hardcode_libdir_separator=':' + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + hardcode_direct=unsupported + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + ;; + esac + fi + # Begin _LT_AC_SYS_LIBPATH_AIX. + echo 'int main () { return 0; }' > conftest.c + ${CC} ${LDFLAGS} conftest.c -o conftest + aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + if test -z "$aix_libpath"; then + aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` + fi + if test -z "$aix_libpath"; then + aix_libpath="/usr/lib:/lib" + fi + rm -f conftest.c conftest + # End _LT_AC_SYS_LIBPATH_AIX. + if test "$aix_use_runtimelinking" = yes; then + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + else + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + fi + fi + ;; + amigaos*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + bsdi[45]*) + ;; + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + libext=lib + ;; + darwin* | rhapsody*) + hardcode_direct=no + if test "$GCC" = yes ; then + : + else + case $cc_basename in + xlc*) + ;; + *) + ld_shlibs=no + ;; + esac + fi + ;; + dgux*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + freebsd1*) + ld_shlibs=no + ;; + freebsd2.2*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + freebsd2*) + hardcode_direct=yes + hardcode_minus_L=yes + ;; + freebsd* | dragonfly*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + hpux9*) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + hpux10*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + fi + ;; + hpux11*) + if test "$with_gnu_ld" = no; then + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + case $host_cpu in + hppa*64*|ia64*) + hardcode_direct=no + ;; + *) + hardcode_direct=yes + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + irix5* | irix6* | nonstopux*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + netbsd*) + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + ;; + newsos6) + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + openbsd*) + if test -f /usr/libexec/ld.so; then + hardcode_direct=yes + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + else + case "$host_os" in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + else + ld_shlibs=no + fi + ;; + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + ;; + osf3*) + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + osf4* | osf5*) + if test "$GCC" = yes; then + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + # Both cc and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + solaris*) + hardcode_libdir_flag_spec='-R$libdir' + ;; + sunos4*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + ;; + sysv4) + case $host_vendor in + sni) + hardcode_direct=yes # is this really true??? + ;; + siemens) + hardcode_direct=no + ;; + motorola) + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + ;; + sysv4.3*) + ;; + sysv4*MP*) + if test -d /usr/nec; then + ld_shlibs=yes + fi + ;; + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) + ;; + sysv5* | sco3.2v5* | sco5v6*) + hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' + hardcode_libdir_separator=':' + ;; + uts4*) + hardcode_libdir_flag_spec='-L$libdir' + ;; + *) + ld_shlibs=no + ;; + esac +fi + +# Check dynamic linker characteristics +# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER. +# Unlike libtool.m4, here we don't care about _all_ names of the library, but +# only about the one the linker finds when passed -lNAME. This is the last +# element of library_names_spec in libtool.m4, or possibly two of them if the +# linker has special search rules. +library_names_spec= # the last element of library_names_spec in libtool.m4 +libname_spec='lib$name' +case "$host_os" in + aix3*) + library_names_spec='$libname.a' + ;; + aix[4-9]*) + library_names_spec='$libname$shrext' + ;; + amigaos*) + library_names_spec='$libname.a' + ;; + beos*) + library_names_spec='$libname$shrext' + ;; + bsdi[45]*) + library_names_spec='$libname$shrext' + ;; + cygwin* | mingw* | pw32* | cegcc*) + shrext=.dll + library_names_spec='$libname.dll.a $libname.lib' + ;; + darwin* | rhapsody*) + shrext=.dylib + library_names_spec='$libname$shrext' + ;; + dgux*) + library_names_spec='$libname$shrext' + ;; + freebsd1*) + ;; + freebsd* | dragonfly*) + case "$host_os" in + freebsd[123]*) + library_names_spec='$libname$shrext$versuffix' ;; + *) + library_names_spec='$libname$shrext' ;; + esac + ;; + gnu*) + library_names_spec='$libname$shrext' + ;; + hpux9* | hpux10* | hpux11*) + case $host_cpu in + ia64*) + shrext=.so + ;; + hppa*64*) + shrext=.sl + ;; + *) + shrext=.sl + ;; + esac + library_names_spec='$libname$shrext' + ;; + interix[3-9]*) + library_names_spec='$libname$shrext' + ;; + irix5* | irix6* | nonstopux*) + library_names_spec='$libname$shrext' + case "$host_os" in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; + *) libsuff= shlibsuff= ;; + esac + ;; + esac + ;; + linux*oldld* | linux*aout* | linux*coff*) + ;; + linux* | k*bsd*-gnu) + library_names_spec='$libname$shrext' + ;; + knetbsd*-gnu) + library_names_spec='$libname$shrext' + ;; + netbsd*) + library_names_spec='$libname$shrext' + ;; + newsos6) + library_names_spec='$libname$shrext' + ;; + nto-qnx*) + library_names_spec='$libname$shrext' + ;; + openbsd*) + library_names_spec='$libname$shrext$versuffix' + ;; + os2*) + libname_spec='$name' + shrext=.dll + library_names_spec='$libname.a' + ;; + osf3* | osf4* | osf5*) + library_names_spec='$libname$shrext' + ;; + rdos*) + ;; + solaris*) + library_names_spec='$libname$shrext' + ;; + sunos4*) + library_names_spec='$libname$shrext$versuffix' + ;; + sysv4 | sysv4.3*) + library_names_spec='$libname$shrext' + ;; + sysv4*MP*) + library_names_spec='$libname$shrext' + ;; + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + library_names_spec='$libname$shrext' + ;; + uts4*) + library_names_spec='$libname$shrext' + ;; +esac + +sed_quote_subst='s/\(["`$\\]\)/\\\1/g' +escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` +shlibext=`echo "$shrext" | sed -e 's,^\.,,'` +escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` +escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` + +LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <. Submit a context +# diff and a properly formatted ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ + uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | mcore \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | mt \ + | msp430 \ + | nios | nios2 \ + | ns16k | ns32k \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | score \ + | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nios-* | nios2-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa-* \ + | ymp-* \ + | z8k-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16c) + basic_machine=cr16c-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/configh.in b/configh.in new file mode 100644 index 0000000..5ab1832 --- /dev/null +++ b/configh.in @@ -0,0 +1,474 @@ +/* configh.in. Generated from configure.ac by autoheader. */ + +/* dynamic loading is possible */ +#undef DYNAMIC + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +#undef ENABLE_NLS + +/* Define to the type of elements in the array set by `getgroups'. Usually + this is either `int' or `gid_t'. */ +#undef GETGROUPS_T + +/* Define to 1 if the `getpgrp' function requires zero arguments. */ +#undef GETPGRP_VOID + +/* Define to 1 if you have the `alarm' function. */ +#undef HAVE_ALARM + +/* Define to 1 if you have the header file. */ +#undef HAVE_ARPA_INET_H + +/* Define to 1 if you have the `atexit' function. */ +#undef HAVE_ATEXIT + +/* Define to 1 if you have the `btowc' function. */ +#undef HAVE_BTOWC + +/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the + CoreFoundation framework. */ +#undef HAVE_CFLOCALECOPYCURRENT + +/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in + the CoreFoundation framework. */ +#undef HAVE_CFPREFERENCESCOPYAPPVALUE + +/* Define if the GNU dcgettext() function is already present or preinstalled. + */ +#undef HAVE_DCGETTEXT + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +#undef HAVE_DECL_TZNAME + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +#undef HAVE_DOPRNT + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the `fmod' function. */ +#undef HAVE_FMOD + +/* have getaddrinfo */ +#undef HAVE_GETADDRINFO + +/* Define to 1 if you have the `getgrent' function. */ +#undef HAVE_GETGRENT + +/* Define to 1 if you have the `getgroups' function. */ +#undef HAVE_GETGROUPS + +/* Define if the GNU gettext() function is already present or preinstalled. */ +#undef HAVE_GETTEXT + +/* Define to 1 if you have the `grantpt' function. */ +#undef HAVE_GRANTPT + +/* Define if you have the iconv() function and it works. */ +#undef HAVE_ICONV + +/* Define if you have the 'intmax_t' type in or . */ +#undef HAVE_INTMAX_T + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define if exists, doesn't clash with , and + declares uintmax_t. */ +#undef HAVE_INTTYPES_H_WITH_UINTMAX + +/* Define to 1 if you have the `isascii' function. */ +#undef HAVE_ISASCII + +/* Define to 1 if you have the `iswctype' function. */ +#undef HAVE_ISWCTYPE + +/* Define to 1 if you have the `iswlower' function. */ +#undef HAVE_ISWLOWER + +/* Define to 1 if you have the `iswupper' function. */ +#undef HAVE_ISWUPPER + +/* Define if you have and nl_langinfo(CODESET). */ +#undef HAVE_LANGINFO_CODESET + +/* Define if your file defines LC_MESSAGES. */ +#undef HAVE_LC_MESSAGES + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBINTL_H + +/* Define to 1 if you have the `m' library (-lm). */ +#undef HAVE_LIBM + +/* Define to 1 if you have a fully functional readline library. */ +#undef HAVE_LIBREADLINE + +/* Define if you have the libsigsegv library. */ +#undef HAVE_LIBSIGSEGV + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LOCALE_H + +/* Define if you have the 'long long' type. */ +#undef HAVE_LONG_LONG + +/* Define to 1 if the system has the type `long long int'. */ +#undef HAVE_LONG_LONG_INT + +/* Define to 1 if you have the `mbrlen' function. */ +#undef HAVE_MBRLEN + +/* Define to 1 if mbrtowc and mbstate_t are properly declared. */ +#undef HAVE_MBRTOWC + +/* Define to 1 if you have the header file. */ +#undef HAVE_MCHECK_H + +/* Define to 1 if you have the `memcmp' function. */ +#undef HAVE_MEMCMP + +/* Define to 1 if you have the `memcpy' function. */ +#undef HAVE_MEMCPY + +/* Define to 1 if you have the `memcpy_ulong' function. */ +#undef HAVE_MEMCPY_ULONG + +/* Define to 1 if you have the `memmove' function. */ +#undef HAVE_MEMMOVE + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#undef HAVE_MEMSET + +/* Define to 1 if you have the `memset_ulong' function. */ +#undef HAVE_MEMSET_ULONG + +/* Define to 1 if you have the `mkstemp' function. */ +#undef HAVE_MKSTEMP + +/* we have the mktime function */ +#undef HAVE_MKTIME + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETDB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_IN_H + +/* Define to 1 if you have the `setenv' function. */ +#undef HAVE_SETENV + +/* Define to 1 if you have the `setlocale' function. */ +#undef HAVE_SETLOCALE + +/* Define to 1 if you have the `setsid' function. */ +#undef HAVE_SETSID + +/* Define to 1 if you have the `snprintf' function. */ +#undef HAVE_SNPRINTF + +/* newer systems define this type here */ +#undef HAVE_SOCKADDR_STORAGE + +/* we have sockets on this system */ +#undef HAVE_SOCKETS + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDARG_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDDEF_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define if exists, doesn't clash with , and declares + uintmax_t. */ +#undef HAVE_STDINT_H_WITH_UINTMAX + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strchr' function. */ +#undef HAVE_STRCHR + +/* Define to 1 if you have the `strcoll' function. */ +#undef HAVE_STRCOLL + +/* Define to 1 if you have the `strerror' function. */ +#undef HAVE_STRERROR + +/* Define to 1 if you have the `strftime' function. */ +#undef HAVE_STRFTIME + +/* Define to 1 if cpp supports the ANSI # stringizing operator. */ +#undef HAVE_STRINGIZE + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strncasecmp' function. */ +#undef HAVE_STRNCASECMP + +/* Define to 1 if you have the header file. */ +#undef HAVE_STROPTS_H + +/* Define to 1 if you have the `strtod' function. */ +#undef HAVE_STRTOD + +/* Define to 1 if you have the `strtoul' function. */ +#undef HAVE_STRTOUL + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_BLKSIZE + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#undef HAVE_STRUCT_TM_TM_ZONE + +/* Define to 1 if your `struct stat' has `st_blksize'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLKSIZE' instead. */ +#undef HAVE_ST_BLKSIZE + +/* Define to 1 if you have the `system' function. */ +#undef HAVE_SYSTEM + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#undef HAVE_SYS_WAIT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_TERMIOS_H + +/* Define to 1 if you have the `tmpfile' function. */ +#undef HAVE_TMPFILE + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#undef HAVE_TM_ZONE + +/* Define to 1 if you have the `towlower' function. */ +#undef HAVE_TOWLOWER + +/* Define to 1 if you have the `towupper' function. */ +#undef HAVE_TOWUPPER + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +#undef HAVE_TZNAME + +/* Define to 1 if you have the `tzset' function. */ +#undef HAVE_TZSET + +/* Define if you have the 'uintmax_t' type in or . */ +#undef HAVE_UINTMAX_T + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define if you have the 'unsigned long long' type. */ +#undef HAVE_UNSIGNED_LONG_LONG + +/* Define to 1 if the system has the type `unsigned long long int'. */ +#undef HAVE_UNSIGNED_LONG_LONG_INT + +/* Define to 1 if you have the `usleep' function. */ +#undef HAVE_USLEEP + +/* Define to 1 if you have the `vprintf' function. */ +#undef HAVE_VPRINTF + +/* Define to 1 if you have the header file. */ +#undef HAVE_WCHAR_H + +/* Define to 1 if you have the `wcrtomb' function. */ +#undef HAVE_WCRTOMB + +/* Define to 1 if you have the `wcscoll' function. */ +#undef HAVE_WCSCOLL + +/* Define to 1 if you have the `wctype' function. */ +#undef HAVE_WCTYPE + +/* Define to 1 if you have the header file. */ +#undef HAVE_WCTYPE_H + +/* systems should define this type here */ +#undef HAVE_WCTYPE_T + +/* systems should define this type here */ +#undef HAVE_WINT_T + +/* disable lint checks */ +#undef NO_LINT + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if *printf supports %F format */ +#undef PRINTF_HAS_F_FORMAT + +/* Define as the return type of signal handlers (`int' or `void'). */ +#undef RETSIGTYPE + +/* The size of `unsigned int', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_INT + +/* The size of `unsigned long', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_LONG + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* some systems define this type here */ +#undef TIME_T_IN_SYS_TYPES_H + +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Define to 1 if your declares `struct tm'. */ +#undef TM_IN_SYS_TIME + +/* force use of our version of strftime */ +#undef USE_INCLUDED_STRFTIME + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif + + +/* Version number of package */ +#undef VERSION + +/* Number of bits in a file offset, on hosts where this is settable. */ +#undef _FILE_OFFSET_BITS + +/* Define for large files, on AIX-style hosts. */ +#undef _LARGE_FILES + +/* Define to 1 if on MINIX. */ +#undef _MINIX + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +#undef _POSIX_1_SOURCE + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +#undef _POSIX_SOURCE + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +# undef __CHAR_UNSIGNED__ +#endif + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `int' if doesn't define. */ +#undef gid_t + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif + +/* Define to long or long long if and don't define. */ +#undef intmax_t + +/* Define to `int' if does not define. */ +#undef pid_t + +/* Define to the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported directly. */ +#undef restrict +/* Work around a bug in Sun C++: it does not support _Restrict or + __restrict__, even though the corresponding Sun C compiler ends up with + "#define restrict _Restrict" or "#define restrict __restrict__" in the + previous line. Perhaps some future version of Sun C++ will work with + restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ +#if defined __SUNPRO_CC && !defined __RESTRICT +# define _Restrict +# define __restrict__ +#endif + +/* Define to `unsigned int' if does not define. */ +#undef size_t + +/* type to use in place of socklen_t if not defined */ +#undef socklen_t + +/* Define to `int' if does not define. */ +#undef ssize_t + +/* Define to `int' if doesn't define. */ +#undef uid_t + +/* Define to unsigned long or unsigned long long if and + don't define. */ +#undef uintmax_t + +#include "custom.h" diff --git a/configure b/configure new file mode 100755 index 0000000..54c4431 --- /dev/null +++ b/configure @@ -0,0 +1,12276 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.68 for GNU Awk 4.0.1. +# +# Report bugs to . +# +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + # Preserve -v and -x to the replacement shell. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; + esac + exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org and bug-gawk@gnu.org +$0: about your system, including any error possibly output +$0: before this message. Then install a modern shell, or +$0: manually run the script under such a shell if you do +$0: have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='GNU Awk' +PACKAGE_TARNAME='gawk' +PACKAGE_VERSION='4.0.1' +PACKAGE_STRING='GNU Awk 4.0.1' +PACKAGE_BUGREPORT='bug-gawk@gnu.org' +PACKAGE_URL='http://www.gnu.org/software/gawk/' + +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +gt_needs= +ac_header_list= +ac_func_list= +ac_subst_vars='am__EXEEXT_FALSE +am__EXEEXT_TRUE +LTLIBOBJS +LIBREADLINE +SOCKET_LIBS +LIBSIGSEGV_PREFIX +LTLIBSIGSEGV +LIBSIGSEGV +HAVE_LIBSIGSEGV +LIBOBJS +POSUB +LTLIBINTL +LIBINTL +INTLLIBS +LTLIBICONV +LIBICONV +INTL_MACOSX_LIBS +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build +XGETTEXT_EXTRA_OPTIONS +MSGMERGE +XGETTEXT_015 +XGETTEXT +GMSGFMT_015 +MSGFMT_015 +GMSGFMT +MSGFMT +GETTEXT_MACRO_VERSION +USE_NLS +LN_S +YFLAGS +YACC +EGREP +GREP +CPP +am__fastdepCC_FALSE +am__fastdepCC_TRUE +CCDEPMODE +AMDEPBACKSLASH +AMDEP_FALSE +AMDEP_TRUE +am__quote +am__include +DEPDIR +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +am__untar +am__tar +AMTAR +am__leading_dot +SET_MAKE +AWK +mkdir_p +MKDIR_P +INSTALL_STRIP_PROGRAM +STRIP +install_sh +MAKEINFO +AUTOHEADER +AUTOMAKE +AUTOCONF +ACLOCAL +VERSION +PACKAGE +CYGPATH_W +am__isrc +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +with_whiny_user_strftime +enable_lint +enable_dependency_tracking +enable_largefile +enable_nls +with_gnu_ld +enable_rpath +with_libiconv_prefix +with_libintl_prefix +with_libsigsegv_prefix +with_readline +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP +YACC +YFLAGS' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used" >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures GNU Awk 4.0.1 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/gawk] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of GNU Awk 4.0.1:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --disable-lint Disable gawk lint checking + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + --disable-largefile omit support for large files + --disable-nls do not use Native Language Support + --disable-rpath do not hardcode runtime library paths + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-whiny-user-strftime Force use of included version of strftime for deficient systems + --with-gnu-ld assume the C compiler uses GNU ld default=no + --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib + --without-libiconv-prefix don't search for libiconv in includedir and libdir + --with-libintl-prefix[=DIR] search for libintl in DIR/include and DIR/lib + --without-libintl-prefix don't search for libintl in includedir and libdir + --with-libsigsegv-prefix[=DIR] search for libsigsegv in DIR/include and DIR/lib + --without-libsigsegv-prefix don't search for libsigsegv in includedir and libdir + --with-readline=DIR look for the readline library in DIR + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + YACC The `Yet Another Compiler Compiler' implementation to use. + Defaults to the first program found out of: `bison -y', `byacc', + `yacc'. + YFLAGS The list of arguments that will be passed by default to $YACC. + This script will default YFLAGS to the empty string to avoid a + default value of `-d' given by some make applications. + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to . +GNU Awk home page: . +General help using GNU software: . +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +GNU Awk configure 4.0.1 +generated by GNU Autoconf 2.68 + +Copyright (C) 2010 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} +( $as_echo "## ------------------------------- ## +## Report this to bug-gawk@gnu.org ## +## ------------------------------- ##" + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_check_type LINENO TYPE VAR INCLUDES +# ------------------------------------------- +# Tests whether TYPE exists after having included INCLUDES, setting cache +# variable VAR accordingly. +ac_fn_c_check_type () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof ($2)) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof (($2))) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + eval "$3=yes" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_type + +# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES +# -------------------------------------------- +# Tries to find the compile-time value of EXPR in a program that includes +# INCLUDES, setting VAR accordingly. Returns whether the value could be +# computed +ac_fn_c_compute_int () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=0 ac_mid=0 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid; break +else + as_fn_arith $ac_mid + 1 && ac_lo=$as_val + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=-1 ac_mid=-1 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=$ac_mid; break +else + as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + ac_lo= ac_hi= +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid +else + as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in #(( +?*) eval "$3=\$ac_lo"; ac_retval=0 ;; +'') ac_retval=1 ;; +esac + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +static long int longval () { return $2; } +static unsigned long int ulongval () { return $2; } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (($2) < 0) + { + long int i = longval (); + if (i != ($2)) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ($2)) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + echo >>conftest.val; read $3 &5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_func + +# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES +# ---------------------------------------------------- +# Tries to find if the field MEMBER exists in type AGGR, after including +# INCLUDES, setting cache variable VAR accordingly. +ac_fn_c_check_member () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 +$as_echo_n "checking for $2.$3... " >&6; } +if eval \${$4+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () +{ +static $2 ac_aggr; +if (ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$4=yes" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () +{ +static $2 ac_aggr; +if (sizeof ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$4=yes" +else + eval "$4=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$4 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_member + +# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES +# --------------------------------------------- +# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR +# accordingly. +ac_fn_c_check_decl () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + as_decl_name=`echo $2|sed 's/ *(.*//'` + as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 +$as_echo_n "checking whether $as_decl_name is declared... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +#ifndef $as_decl_name +#ifdef __cplusplus + (void) $as_decl_use; +#else + (void) $as_decl_name; +#endif +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_decl +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by GNU Awk $as_me 4.0.1, which was +generated by GNU Autoconf 2.68. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +gt_needs="$gt_needs " +as_fn_append ac_header_list " sys/time.h" +as_fn_append ac_header_list " unistd.h" +as_fn_append ac_func_list " alarm" +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +# This is a hack. Different versions of install on different systems +# are just too different. Chuck it and use install-sh. +# +# If the user supplies $INSTALL, figure they know what they're doing. +# +# With Autoconf 2.5x, this needs to come very early on, but *after* +# the INIT macro. Sigh. + +if test "x$INSTALL" = "x" +then + INSTALL="$srcdir/install-sh -c" + export INSTALL +fi + + +am__api_version='1.11' + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if ${ac_cv_path_install+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 +$as_echo_n "checking whether build environment is sane... " >&6; } +# Just in case +sleep 1 +echo timestamp > conftest.file +# Reject unsafe characters in $srcdir or the absolute working directory +# name. Accept space and tab only in the latter. +am_lf=' +' +case `pwd` in + *[\\\"\#\$\&\'\`$am_lf]*) + as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; +esac +case $srcdir in + *[\\\"\#\$\&\'\`$am_lf\ \ ]*) + as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; +esac + +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t "$srcdir/configure" conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + as_fn_error $? "ls -t appears to fail. Make sure there is not a broken +alias in your environment" "$LINENO" 5 + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + as_fn_error $? "newly created file is older than distributed files! +Check your system clock" "$LINENO" 5 +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. +# By default was `s,x,x', remove it if useless. +ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' +program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +if test x"${MISSING+set}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; + *) + MISSING="\${SHELL} $am_aux_dir/missing" ;; + esac +fi +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 +$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +if test x"${install_sh}" != xset; then + case $am_aux_dir in + *\ * | *\ *) + install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; + *) + install_sh="\${SHELL} $am_aux_dir/install-sh" + esac +fi + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 +$as_echo "$STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_STRIP="strip" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 +$as_echo "$ac_ct_STRIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 +$as_echo_n "checking for a thread-safe mkdir -p... " >&6; } +if test -z "$MKDIR_P"; then + if ${ac_cv_path_mkdir+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in mkdir gmkdir; do + for ac_exec_ext in '' $ac_executable_extensions; do + { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( + 'mkdir (GNU coreutils) '* | \ + 'mkdir (coreutils) '* | \ + 'mkdir (fileutils) '4.1*) + ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext + break 3;; + esac + done + done + done +IFS=$as_save_IFS + +fi + + test -d ./--version && rmdir ./--version + if test "${ac_cv_path_mkdir+set}" = set; then + MKDIR_P="$ac_cv_path_mkdir -p" + else + # As a last resort, use the slow shell script. Don't cache a + # value for MKDIR_P within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + MKDIR_P="$ac_install_sh -d" + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 +$as_echo "$MKDIR_P" >&6; } + +mkdir_p="$MKDIR_P" +case $mkdir_p in + [\\/$]* | ?:[\\/]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_AWK+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AWK="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 +$as_echo "$AWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +if test "`cd $srcdir && pwd`" != "`pwd`"; then + # Use -I$(srcdir) only when $(srcdir) != ., so that make's output + # is not polluted with repeated "-I." + am__isrc=' -I$(srcdir)' + # test to see if srcdir already configured + if test -f $srcdir/config.status; then + as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + fi +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE='gawk' + VERSION='4.0.1' + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + + + + + + + + +# Check whether --with-whiny-user-strftime was given. +if test "${with_whiny_user_strftime+set}" = set; then : + withval=$with_whiny_user_strftime; if test "$withval" = yes + then + +$as_echo "#define USE_INCLUDED_STRFTIME 1" >>confdefs.h + + fi + +fi + +# Check whether --enable-lint was given. +if test "${enable_lint+set}" = set; then : + enableval=$enable_lint; if test "$enableval" = no + then + +$as_echo "#define NO_LINT 1" >>confdefs.h + + fi + +fi + + +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo this is the am__doit target +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 +$as_echo_n "checking for style of include used by $am_make... " >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# Ignore all kinds of additional output from `make'. +case `$am_make -s -f confmf 2> /dev/null` in #( +*the\ am__doit\ target*) + am__include=include + am__quote= + _am_result=GNU + ;; +esac +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + case `$am_make -s -f confmf 2> /dev/null` in #( + *the\ am__doit\ target*) + am__include=.include + am__quote="\"" + _am_result=BSD + ;; + esac +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 +$as_echo "$_am_result" >&6; } +rm -f confinc confmf + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then : + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CC" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CC_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" +if test "x$ac_cv_header_minix_config_h" = xyes; then : + MINIX=yes +else + MINIX= +fi + + + if test "$MINIX" = yes; then + +$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h + + +$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h + + +$as_echo "#define _MINIX 1" >>confdefs.h + + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 +$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } +if ${ac_cv_safe_to_define___extensions__+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +# define __EXTENSIONS__ 1 + $ac_includes_default +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_safe_to_define___extensions__=yes +else + ac_cv_safe_to_define___extensions__=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 +$as_echo "$ac_cv_safe_to_define___extensions__" >&6; } + test $ac_cv_safe_to_define___extensions__ = yes && + $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h + + $as_echo "#define _ALL_SOURCE 1" >>confdefs.h + + $as_echo "#define _GNU_SOURCE 1" >>confdefs.h + + $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h + + $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +for ac_prog in 'bison -y' byacc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_YACC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$YACC"; then + ac_cv_prog_YACC="$YACC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_YACC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +YACC=$ac_cv_prog_YACC +if test -n "$YACC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YACC" >&5 +$as_echo "$YACC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$YACC" && break +done +test -n "$YACC" || YACC="yacc" + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 +$as_echo_n "checking whether ln -s works... " >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 +$as_echo "no, using $LN_S" >&6; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CC" am_compiler_list= + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 +$as_echo_n "checking dependency style of $depcc... " >&6; } +if ${am_cv_CC_dependencies_compiler_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + am__universal=false + case " $depcc " in #( + *\ -arch\ *\ -arch\ *) am__universal=true ;; + esac + + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. Also, some Intel + # versions had trouble with output in subdirs + am__obj=sub/conftest.${OBJEXT-o} + am__minus_obj="-o $am__obj" + case $depmode in + gcc) + # This depmode causes a compiler race in universal mode. + test "$am__universal" = false || continue + ;; + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + msvisualcpp | msvcmsys) + # This compiler won't grok `-c -o', but also, the minuso test has + # not run yet. These depmodes are late enough in the game, and + # so weak that their functioning should not be impacted. + am__obj=conftest.${OBJEXT-o} + am__minus_obj= + ;; + none) break ;; + esac + if depmode=$depmode \ + source=sub/conftest.c object=$am__obj \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep $am__obj sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 +$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } +set x ${MAKE-make} +ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + SET_MAKE= +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + + +# This is mainly for my use during testing and development. +# Yes, it's a bit of a hack. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for special development options" >&5 +$as_echo_n "checking for special development options... " >&6; } +if test -f $srcdir/.developing +then + # add other debug flags as appropriate, save GAWKDEBUG for emergencies + CFLAGS="$CFLAGS -DARRAYDEBUG -DYYDEBUG" + if grep dbug $srcdir/.developing + then + CFLAGS="$CFLAGS -DDBUG" + LIBS="$LIBS dbug/libdbug.a" + fi + # turn on compiler warnings if we're doing development + # enable debugging using macros also + if test "$GCC" = yes + then + CFLAGS="$CFLAGS -Wall -fno-builtin -g3 -gdwarf-2" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for z/OS USS compilation" >&5 +$as_echo_n "checking for z/OS USS compilation... " >&6; } +if test "OS/390" = "`uname`" +then + CFLAGS="$CFLAGS -D_ALL_SOURCE -DZOS_USS -DUSE_EBCDIC" + # Must rebuild awkgram.c and command.c from Bison for EBCDIC + rm -f awkgram.c command.c + ac_cv_zos_uss=yes +else + ac_cv_zos_uss=no +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ac_cv_zos_uss}" >&5 +$as_echo "${ac_cv_zos_uss}" >&6; } + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for strerror in -lcposix" >&5 +$as_echo_n "checking for strerror in -lcposix... " >&6; } +if ${ac_cv_lib_cposix_strerror+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lcposix $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char strerror (); +int +main () +{ +return strerror (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_cposix_strerror=yes +else + ac_cv_lib_cposix_strerror=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cposix_strerror" >&5 +$as_echo "$ac_cv_lib_cposix_strerror" >&6; } +if test "x$ac_cv_lib_cposix_strerror" = xyes; then : + LIBS="$LIBS -lcposix" +fi + + + +# Check whether --enable-largefile was given. +if test "${enable_largefile+set}" = set; then : + enableval=$enable_largefile; +fi + +if test "$enable_largefile" != no; then + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 +$as_echo_n "checking for special C compiler options needed for large files... " >&6; } +if ${ac_cv_sys_largefile_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_sys_largefile_CC=no + if test "$GCC" != yes; then + ac_save_CC=$CC + while :; do + # IRIX 6.2 and later do not support large files by default, + # so use the C compiler's -n32 option if that helps. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF + if ac_fn_c_try_compile "$LINENO"; then : + break +fi +rm -f core conftest.err conftest.$ac_objext + CC="$CC -n32" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_largefile_CC=' -n32'; break +fi +rm -f core conftest.err conftest.$ac_objext + break + done + CC=$ac_save_CC + rm -f conftest.$ac_ext + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 +$as_echo "$ac_cv_sys_largefile_CC" >&6; } + if test "$ac_cv_sys_largefile_CC" != no; then + CC=$CC$ac_cv_sys_largefile_CC + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 +$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } +if ${ac_cv_sys_file_offset_bits+:} false; then : + $as_echo_n "(cached) " >&6 +else + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_file_offset_bits=no; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _FILE_OFFSET_BITS 64 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_file_offset_bits=64; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cv_sys_file_offset_bits=unknown + break +done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 +$as_echo "$ac_cv_sys_file_offset_bits" >&6; } +case $ac_cv_sys_file_offset_bits in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits +_ACEOF +;; +esac +rm -rf conftest* + if test $ac_cv_sys_file_offset_bits = unknown; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 +$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } +if ${ac_cv_sys_large_files+:} false; then : + $as_echo_n "(cached) " >&6 +else + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_large_files=no; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _LARGE_FILES 1 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_large_files=1; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cv_sys_large_files=unknown + break +done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 +$as_echo "$ac_cv_sys_large_files" >&6; } +case $ac_cv_sys_large_files in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _LARGE_FILES $ac_cv_sys_large_files +_ACEOF +;; +esac +rm -rf conftest* + fi +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for AIX compilation hacks" >&5 +$as_echo_n "checking for AIX compilation hacks... " >&6; } +if ${gawk_cv_aix_hack+:} false; then : + $as_echo_n "(cached) " >&6 +else + +if test -d /lpp +then + CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED=1 -DGAWK_AIX=1" + gawk_cv_aix_hack=yes +else + gawk_cv_aix_hack=no +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${gawk_cv_aix_hack}" >&5 +$as_echo "${gawk_cv_aix_hack}" >&6; } + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Linux/Alpha compilation hacks" >&5 +$as_echo_n "checking for Linux/Alpha compilation hacks... " >&6; } +if ${gawk_cv_linux_alpha_hack+:} false; then : + $as_echo_n "(cached) " >&6 +else + +if test "Linux" = "`uname`" && test "alpha" = "`uname -m`" +then + # this isn't necessarily always true, + # the vendor's compiler is also often found + if test "$GCC" = yes + then + CFLAGS="$CFLAGS -mieee" + gawk_cv_linux_alpha_hack=yes + else + gawk_cv_linux_alpha_hack=no + fi +else + gawk_cv_linux_alpha_hack=no +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${gawk_cv_linux_alpha_hack}" >&5 +$as_echo "${gawk_cv_linux_alpha_hack}" >&6; } + + +if test "$ISC" = 1 # will be set by test for ISC +then + CFLAGS="$CFLAGS -D_SYSV3" +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +case `(uname) 2> /dev/null` in +*CYGWIN*) + with_libiconv_prefix=no + with_libintl_prefix=no + ;; +*) + ;; +esac + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NLS is requested" >&5 +$as_echo_n "checking whether NLS is requested... " >&6; } + # Check whether --enable-nls was given. +if test "${enable_nls+set}" = set; then : + enableval=$enable_nls; USE_NLS=$enableval +else + USE_NLS=yes +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5 +$as_echo "$USE_NLS" >&6; } + + + + + GETTEXT_MACRO_VERSION=0.18 + + + + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "msgfmt", so it can be a program name with args. +set dummy msgfmt; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_MSGFMT+:} false; then : + $as_echo_n "(cached) " >&6 +else + case "$MSGFMT" in + [\\/]* | ?:[\\/]*) + ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + echo "$as_me: trying $ac_dir/$ac_word..." >&5 + if $ac_dir/$ac_word --statistics /dev/null >&5 2>&1 && + (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + ac_cv_path_MSGFMT="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" + test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT=":" + ;; +esac +fi +MSGFMT="$ac_cv_path_MSGFMT" +if test "$MSGFMT" != ":"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGFMT" >&5 +$as_echo "$MSGFMT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + # Extract the first word of "gmsgfmt", so it can be a program name with args. +set dummy gmsgfmt; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_GMSGFMT+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $GMSGFMT in + [\\/]* | ?:[\\/]*) + ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_GMSGFMT="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT" + ;; +esac +fi +GMSGFMT=$ac_cv_path_GMSGFMT +if test -n "$GMSGFMT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GMSGFMT" >&5 +$as_echo "$GMSGFMT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + + case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;; + *) MSGFMT_015=$MSGFMT ;; + esac + + case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;; + *) GMSGFMT_015=$GMSGFMT ;; + esac + + + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "xgettext", so it can be a program name with args. +set dummy xgettext; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_XGETTEXT+:} false; then : + $as_echo_n "(cached) " >&6 +else + case "$XGETTEXT" in + [\\/]* | ?:[\\/]*) + ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + echo "$as_me: trying $ac_dir/$ac_word..." >&5 + if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&5 2>&1 && + (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then + ac_cv_path_XGETTEXT="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" + test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":" + ;; +esac +fi +XGETTEXT="$ac_cv_path_XGETTEXT" +if test "$XGETTEXT" != ":"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XGETTEXT" >&5 +$as_echo "$XGETTEXT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + rm -f messages.po + + case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;; + *) XGETTEXT_015=$XGETTEXT ;; + esac + + + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "msgmerge", so it can be a program name with args. +set dummy msgmerge; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_MSGMERGE+:} false; then : + $as_echo_n "(cached) " >&6 +else + case "$MSGMERGE" in + [\\/]* | ?:[\\/]*) + ac_cv_path_MSGMERGE="$MSGMERGE" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + echo "$as_me: trying $ac_dir/$ac_word..." >&5 + if $ac_dir/$ac_word --update -q /dev/null /dev/null >&5 2>&1; then + ac_cv_path_MSGMERGE="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" + test -z "$ac_cv_path_MSGMERGE" && ac_cv_path_MSGMERGE=":" + ;; +esac +fi +MSGMERGE="$ac_cv_path_MSGMERGE" +if test "$MSGMERGE" != ":"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MSGMERGE" >&5 +$as_echo "$MSGMERGE" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$localedir" || localedir='${datadir}/locale' + + + test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= + + + ac_config_commands="$ac_config_commands po-directories" + + + + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if ${ac_cv_build+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if ${ac_cv_host+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + + +# Check whether --with-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then : + withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi + +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5 +$as_echo_n "checking for ld used by GCC... " >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 +$as_echo_n "checking for GNU ld... " >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 +$as_echo_n "checking for non-GNU ld... " >&6; } +fi +if ${acl_cv_path_LD+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in + *GNU* | *'with BFD'*) + test "$with_gnu_ld" != no && break ;; + *) + test "$with_gnu_ld" != yes && break ;; + esac + fi + done + IFS="$ac_save_ifs" +else + acl_cv_path_LD="$LD" # Let the user override the test with a path. +fi +fi + +LD="$acl_cv_path_LD" +if test -n "$LD"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 +$as_echo "$LD" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } +if ${acl_cv_prog_gnu_ld+:} false; then : + $as_echo_n "(cached) " >&6 +else + # I'd rather use --version here, but apparently some GNU ld's only accept -v. +case `$LD -v 2>&1 &5 +$as_echo "$acl_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$acl_cv_prog_gnu_ld + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5 +$as_echo_n "checking for shared library run path origin... " >&6; } +if ${acl_cv_rpath+:} false; then : + $as_echo_n "(cached) " >&6 +else + + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ + ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5 +$as_echo "$acl_cv_rpath" >&6; } + wl="$acl_cv_wl" + acl_libext="$acl_cv_libext" + acl_shlibext="$acl_cv_shlibext" + acl_libname_spec="$acl_cv_libname_spec" + acl_library_names_spec="$acl_cv_library_names_spec" + acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + acl_hardcode_direct="$acl_cv_hardcode_direct" + acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" + # Check whether --enable-rpath was given. +if test "${enable_rpath+set}" = set; then : + enableval=$enable_rpath; : +else + enable_rpath=yes +fi + + + + + acl_libdirstem=lib + acl_libdirstem2= + case "$host_os" in + solaris*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit host" >&5 +$as_echo_n "checking for 64-bit host... " >&6; } +if ${gl_cv_solaris_64bit+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#ifdef _LP64 +sixtyfour bits +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "sixtyfour bits" >/dev/null 2>&1; then : + gl_cv_solaris_64bit=yes +else + gl_cv_solaris_64bit=no +fi +rm -f conftest* + + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_solaris_64bit" >&5 +$as_echo "$gl_cv_solaris_64bit" >&6; } + if test $gl_cv_solaris_64bit = yes; then + acl_libdirstem=lib/64 + case "$host_cpu" in + sparc*) acl_libdirstem2=lib/sparcv9 ;; + i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; + esac + fi + ;; + *) + searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` + if test -n "$searchpath"; then + acl_save_IFS="${IFS= }"; IFS=":" + for searchdir in $searchpath; do + if test -d "$searchdir"; then + case "$searchdir" in + */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; + */../ | */.. ) + # Better ignore directories of this form. They are misleading. + ;; + *) searchdir=`cd "$searchdir" && pwd` + case "$searchdir" in + */lib64 ) acl_libdirstem=lib64 ;; + esac ;; + esac + fi + done + IFS="$acl_save_IFS" + fi + ;; + esac + test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" + + + + + + + + + + + + + use_additional=yes + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + +# Check whether --with-libiconv-prefix was given. +if test "${with_libiconv_prefix+set}" = set; then : + withval=$with_libiconv_prefix; + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + if test "$acl_libdirstem2" != "$acl_libdirstem" \ + && ! test -d "$withval/$acl_libdirstem"; then + additional_libdir="$withval/$acl_libdirstem2" + fi + fi + fi + +fi + + LIBICONV= + LTLIBICONV= + INCICONV= + LIBICONV_PREFIX= + HAVE_LIBICONV= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='iconv ' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIBICONV="${LIBICONV}${LIBICONV:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$value" + else + : + fi + else + found_dir= + found_la= + found_so= + found_a= + eval libname=\"$acl_libname_spec\" # typically: libname=lib$name + if test -n "$acl_shlibext"; then + shrext=".$acl_shlibext" # typically: shrext=.so + else + shrext= + fi + if test $use_additional = yes; then + dir="$additional_libdir" + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIBICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + if test "$enable_rpath" = no \ + || test "X$found_dir" = "X/usr/$acl_libdirstem" \ + || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + else + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + if test "$acl_hardcode_direct" = yes; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + else + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + haveit= + for x in $LDFLAGS $LIBICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir" + fi + if test "$acl_hardcode_minus_L" != no; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" + else + LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + LIBICONV="${LIBICONV}${LIBICONV:+ }$found_a" + else + LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir -l$name" + fi + fi + additional_includedir= + case "$found_dir" in + */$acl_libdirstem | */$acl_libdirstem/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` + if test "$name" = 'iconv'; then + LIBICONV_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + */$acl_libdirstem2 | */$acl_libdirstem2/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` + if test "$name" = 'iconv'; then + LIBICONV_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INCICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + INCICONV="${INCICONV}${INCICONV:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + if test -n "$found_la"; then + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ + && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ + || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIBICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LIBICONV="${LIBICONV}${LIBICONV:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIBICONV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + LIBICONV="${LIBICONV}${LIBICONV:+ }$dep" + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$dep" + ;; + esac + done + fi + else + LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$acl_hardcode_libdir_separator"; then + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" + else + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + for found_dir in $ltrpathdirs; do + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-R$found_dir" + done + fi + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFPreferencesCopyAppValue" >&5 +$as_echo_n "checking for CFPreferencesCopyAppValue... " >&6; } +if ${gt_cv_func_CFPreferencesCopyAppValue+:} false; then : + $as_echo_n "(cached) " >&6 +else + gt_save_LIBS="$LIBS" + LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +CFPreferencesCopyAppValue(NULL, NULL) + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gt_cv_func_CFPreferencesCopyAppValue=yes +else + gt_cv_func_CFPreferencesCopyAppValue=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS="$gt_save_LIBS" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFPreferencesCopyAppValue" >&5 +$as_echo "$gt_cv_func_CFPreferencesCopyAppValue" >&6; } + if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then + +$as_echo "#define HAVE_CFPREFERENCESCOPYAPPVALUE 1" >>confdefs.h + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFLocaleCopyCurrent" >&5 +$as_echo_n "checking for CFLocaleCopyCurrent... " >&6; } +if ${gt_cv_func_CFLocaleCopyCurrent+:} false; then : + $as_echo_n "(cached) " >&6 +else + gt_save_LIBS="$LIBS" + LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +CFLocaleCopyCurrent(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gt_cv_func_CFLocaleCopyCurrent=yes +else + gt_cv_func_CFLocaleCopyCurrent=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS="$gt_save_LIBS" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFLocaleCopyCurrent" >&5 +$as_echo "$gt_cv_func_CFLocaleCopyCurrent" >&6; } + if test $gt_cv_func_CFLocaleCopyCurrent = yes; then + +$as_echo "#define HAVE_CFLOCALECOPYCURRENT 1" >>confdefs.h + + fi + INTL_MACOSX_LIBS= + if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then + INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" + fi + + + + + + + LIBINTL= + LTLIBINTL= + POSUB= + + case " $gt_needs " in + *" need-formatstring-macros "*) gt_api_version=3 ;; + *" need-ngettext "*) gt_api_version=2 ;; + *) gt_api_version=1 ;; + esac + gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" + gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" + + if test "$USE_NLS" = "yes"; then + gt_use_preinstalled_gnugettext=no + + + if test $gt_api_version -ge 3; then + gt_revision_test_code=' +#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) +#endif +typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; +' + else + gt_revision_test_code= + fi + if test $gt_api_version -ge 2; then + gt_expression_test_code=' + * ngettext ("", "", 0)' + else + gt_expression_test_code= + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU gettext in libc" >&5 +$as_echo_n "checking for GNU gettext in libc... " >&6; } +if eval \${$gt_func_gnugettext_libc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +$gt_revision_test_code +extern int _nl_msg_cat_cntr; +extern int *_nl_domain_bindings; +int +main () +{ +bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$gt_func_gnugettext_libc=yes" +else + eval "$gt_func_gnugettext_libc=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$gt_func_gnugettext_libc + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + + if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then + + + + + + am_save_CPPFLAGS="$CPPFLAGS" + + for element in $INCICONV; do + haveit= + for x in $CPPFLAGS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" + fi + done + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 +$as_echo_n "checking for iconv... " >&6; } +if ${am_cv_func_iconv+:} false; then : + $as_echo_n "(cached) " >&6 +else + + am_cv_func_iconv="no, consider installing GNU libiconv" + am_cv_lib_iconv=no + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + am_cv_func_iconv=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if test "$am_cv_func_iconv" != yes; then + am_save_LIBS="$LIBS" + LIBS="$LIBS $LIBICONV" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + am_cv_lib_iconv=yes + am_cv_func_iconv=yes +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS="$am_save_LIBS" + fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv" >&5 +$as_echo "$am_cv_func_iconv" >&6; } + if test "$am_cv_func_iconv" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working iconv" >&5 +$as_echo_n "checking for working iconv... " >&6; } +if ${am_cv_func_iconv_works+:} false; then : + $as_echo_n "(cached) " >&6 +else + + am_save_LIBS="$LIBS" + if test $am_cv_lib_iconv = yes; then + LIBS="$LIBS $LIBICONV" + fi + if test "$cross_compiling" = yes; then : + case "$host_os" in + aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; + *) am_cv_func_iconv_works="guessing yes" ;; + esac +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include +int main () +{ + /* Test against AIX 5.1 bug: Failures are not distinguishable from successful + returns. */ + { + iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); + if (cd_utf8_to_88591 != (iconv_t)(-1)) + { + static const char input[] = "\342\202\254"; /* EURO SIGN */ + char buf[10]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_utf8_to_88591, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + return 1; + } + } + /* Test against Solaris 10 bug: Failures are not distinguishable from + successful returns. */ + { + iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); + if (cd_ascii_to_88591 != (iconv_t)(-1)) + { + static const char input[] = "\263"; + char buf[10]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_ascii_to_88591, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + return 1; + } + } +#if 0 /* This bug could be worked around by the caller. */ + /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ + { + iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); + if (cd_88591_to_utf8 != (iconv_t)(-1)) + { + static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; + char buf[50]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_88591_to_utf8, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if ((int)res > 0) + return 1; + } + } +#endif + /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is + provided. */ + if (/* Try standardized names. */ + iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) + /* Try IRIX, OSF/1 names. */ + && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) + /* Try AIX names. */ + && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) + /* Try HP-UX names. */ + && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) + return 1; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + am_cv_func_iconv_works=yes +else + am_cv_func_iconv_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + LIBS="$am_save_LIBS" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv_works" >&5 +$as_echo "$am_cv_func_iconv_works" >&6; } + case "$am_cv_func_iconv_works" in + *no) am_func_iconv=no am_cv_lib_iconv=no ;; + *) am_func_iconv=yes ;; + esac + else + am_func_iconv=no am_cv_lib_iconv=no + fi + if test "$am_func_iconv" = yes; then + +$as_echo "#define HAVE_ICONV 1" >>confdefs.h + + fi + if test "$am_cv_lib_iconv" = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5 +$as_echo_n "checking how to link with libiconv... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5 +$as_echo "$LIBICONV" >&6; } + else + CPPFLAGS="$am_save_CPPFLAGS" + LIBICONV= + LTLIBICONV= + fi + + + + + + + + + + + + use_additional=yes + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + +# Check whether --with-libintl-prefix was given. +if test "${with_libintl_prefix+set}" = set; then : + withval=$with_libintl_prefix; + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + if test "$acl_libdirstem2" != "$acl_libdirstem" \ + && ! test -d "$withval/$acl_libdirstem"; then + additional_libdir="$withval/$acl_libdirstem2" + fi + fi + fi + +fi + + LIBINTL= + LTLIBINTL= + INCINTL= + LIBINTL_PREFIX= + HAVE_LIBINTL= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='intl ' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIBINTL="${LIBINTL}${LIBINTL:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$value" + else + : + fi + else + found_dir= + found_la= + found_so= + found_a= + eval libname=\"$acl_libname_spec\" # typically: libname=lib$name + if test -n "$acl_shlibext"; then + shrext=".$acl_shlibext" # typically: shrext=.so + else + shrext= + fi + if test $use_additional = yes; then + dir="$additional_libdir" + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIBINTL; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + if test "$enable_rpath" = no \ + || test "X$found_dir" = "X/usr/$acl_libdirstem" \ + || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" + else + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + if test "$acl_hardcode_direct" = yes; then + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" + else + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + haveit= + for x in $LDFLAGS $LIBINTL; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir" + fi + if test "$acl_hardcode_minus_L" != no; then + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so" + else + LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + LIBINTL="${LIBINTL}${LIBINTL:+ }$found_a" + else + LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir -l$name" + fi + fi + additional_includedir= + case "$found_dir" in + */$acl_libdirstem | */$acl_libdirstem/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` + if test "$name" = 'intl'; then + LIBINTL_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + */$acl_libdirstem2 | */$acl_libdirstem2/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` + if test "$name" = 'intl'; then + LIBINTL_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INCINTL; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + INCINTL="${INCINTL}${INCINTL:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + if test -n "$found_la"; then + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ + && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ + || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIBINTL; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LIBINTL="${LIBINTL}${LIBINTL:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIBINTL; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + LIBINTL="${LIBINTL}${LIBINTL:+ }$dep" + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$dep" + ;; + esac + done + fi + else + LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name" + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$acl_hardcode_libdir_separator"; then + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBINTL="${LIBINTL}${LIBINTL:+ }$flag" + else + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBINTL="${LIBINTL}${LIBINTL:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + for found_dir in $ltrpathdirs; do + LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-R$found_dir" + done + fi + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU gettext in libintl" >&5 +$as_echo_n "checking for GNU gettext in libintl... " >&6; } +if eval \${$gt_func_gnugettext_libintl+:} false; then : + $as_echo_n "(cached) " >&6 +else + gt_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $INCINTL" + gt_save_LIBS="$LIBS" + LIBS="$LIBS $LIBINTL" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +$gt_revision_test_code +extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias (const char *); +int +main () +{ +bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("") + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$gt_func_gnugettext_libintl=yes" +else + eval "$gt_func_gnugettext_libintl=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then + LIBS="$LIBS $LIBICONV" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +$gt_revision_test_code +extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias (const char *); +int +main () +{ +bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("") + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + LIBINTL="$LIBINTL $LIBICONV" + LTLIBINTL="$LTLIBINTL $LTLIBICONV" + eval "$gt_func_gnugettext_libintl=yes" + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + fi + CPPFLAGS="$gt_save_CPPFLAGS" + LIBS="$gt_save_LIBS" +fi +eval ac_res=\$$gt_func_gnugettext_libintl + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + fi + + if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ + || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ + && test "$PACKAGE" != gettext-runtime \ + && test "$PACKAGE" != gettext-tools; }; then + gt_use_preinstalled_gnugettext=yes + else + LIBINTL= + LTLIBINTL= + INCINTL= + fi + + + + if test -n "$INTL_MACOSX_LIBS"; then + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" + LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" + fi + fi + + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + +$as_echo "#define ENABLE_NLS 1" >>confdefs.h + + else + USE_NLS=no + fi + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use NLS" >&5 +$as_echo_n "checking whether to use NLS... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5 +$as_echo "$USE_NLS" >&6; } + if test "$USE_NLS" = "yes"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking where the gettext function comes from" >&5 +$as_echo_n "checking where the gettext function comes from... " >&6; } + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then + gt_source="external libintl" + else + gt_source="libc" + fi + else + gt_source="included intl directory" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_source" >&5 +$as_echo "$gt_source" >&6; } + fi + + if test "$USE_NLS" = "yes"; then + + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libintl" >&5 +$as_echo_n "checking how to link with libintl... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBINTL" >&5 +$as_echo "$LIBINTL" >&6; } + + for element in $INCINTL; do + haveit= + for x in $CPPFLAGS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" + fi + done + + fi + + +$as_echo "#define HAVE_GETTEXT 1" >>confdefs.h + + +$as_echo "#define HAVE_DCGETTEXT 1" >>confdefs.h + + fi + + POSUB=po + fi + + + + INTLLIBS="$LIBINTL" + + + + + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nl_langinfo and CODESET" >&5 +$as_echo_n "checking for nl_langinfo and CODESET... " >&6; } +if ${am_cv_langinfo_codeset+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +char* cs = nl_langinfo(CODESET); return !cs; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + am_cv_langinfo_codeset=yes +else + am_cv_langinfo_codeset=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_langinfo_codeset" >&5 +$as_echo "$am_cv_langinfo_codeset" >&6; } + if test $am_cv_langinfo_codeset = yes; then + +$as_echo "#define HAVE_LANGINFO_CODESET 1" >>confdefs.h + + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LC_MESSAGES" >&5 +$as_echo_n "checking for LC_MESSAGES... " >&6; } +if ${gt_cv_val_LC_MESSAGES+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +return LC_MESSAGES + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + gt_cv_val_LC_MESSAGES=yes +else + gt_cv_val_LC_MESSAGES=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gt_cv_val_LC_MESSAGES" >&5 +$as_echo "$gt_cv_val_LC_MESSAGES" >&6; } + if test $gt_cv_val_LC_MESSAGES = yes; then + +$as_echo "#define HAVE_LC_MESSAGES 1" >>confdefs.h + + fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5 +$as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; } +if ${ac_cv_header_sys_wait_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#ifndef WEXITSTATUS +# define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8) +#endif +#ifndef WIFEXITED +# define WIFEXITED(stat_val) (((stat_val) & 255) == 0) +#endif + +int +main () +{ + int s; + wait (&s); + s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_sys_wait_h=yes +else + ac_cv_header_sys_wait_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_wait_h" >&5 +$as_echo "$ac_cv_header_sys_wait_h" >&6; } +if test $ac_cv_header_sys_wait_h = yes; then + +$as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 +$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } +if ${ac_cv_header_time+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_time=yes +else + ac_cv_header_time=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 +$as_echo "$ac_cv_header_time" >&6; } +if test $ac_cv_header_time = yes; then + +$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h + +fi + +for ac_header in arpa/inet.h fcntl.h limits.h locale.h libintl.h mcheck.h \ + netdb.h netinet/in.h stdarg.h stddef.h string.h \ + sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h \ + termios.h stropts.h wchar.h wctype.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +if test "$ac_cv_header_string_h" = yes +then + for ac_header in memory.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "memory.h" "ac_cv_header_memory_h" "$ac_includes_default" +if test "x$ac_cv_header_memory_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_MEMORY_H 1 +_ACEOF + +fi + +done + +else + for ac_header in strings.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "strings.h" "ac_cv_header_strings_h" "$ac_includes_default" +if test "x$ac_cv_header_strings_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_STRINGS_H 1 +_ACEOF + +fi + +done + +fi + +ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" +if test "x$ac_cv_type_pid_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define pid_t int +_ACEOF + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 +$as_echo_n "checking return type of signal handlers... " >&6; } +if ${ac_cv_type_signal+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include + +int +main () +{ +return *(signal (0, 0)) (0) == 1; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_type_signal=int +else + ac_cv_type_signal=void +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 +$as_echo "$ac_cv_type_signal" >&6; } + +cat >>confdefs.h <<_ACEOF +#define RETSIGTYPE $ac_cv_type_signal +_ACEOF + + +ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" +if test "x$ac_cv_type_size_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned int +_ACEOF + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5 +$as_echo_n "checking for uid_t in sys/types.h... " >&6; } +if ${ac_cv_type_uid_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "uid_t" >/dev/null 2>&1; then : + ac_cv_type_uid_t=yes +else + ac_cv_type_uid_t=no +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5 +$as_echo "$ac_cv_type_uid_t" >&6; } +if test $ac_cv_type_uid_t = no; then + +$as_echo "#define uid_t int" >>confdefs.h + + +$as_echo "#define gid_t int" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking type of array argument to getgroups" >&5 +$as_echo_n "checking type of array argument to getgroups... " >&6; } +if ${ac_cv_type_getgroups+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_type_getgroups=cross +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Thanks to Mike Rendell for this test. */ +$ac_includes_default +#define NGID 256 +#undef MAX +#define MAX(x, y) ((x) > (y) ? (x) : (y)) + +int +main () +{ + gid_t gidset[NGID]; + int i, n; + union { gid_t gval; long int lval; } val; + + val.lval = -1; + for (i = 0; i < NGID; i++) + gidset[i] = val.gval; + n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1, + gidset); + /* Exit non-zero if getgroups seems to require an array of ints. This + happens when gid_t is short int but getgroups modifies an array + of ints. */ + return n > 0 && gidset[n] != val.gval; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_type_getgroups=gid_t +else + ac_cv_type_getgroups=int +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +if test $ac_cv_type_getgroups = cross; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "getgroups.*int.*gid_t" >/dev/null 2>&1; then : + ac_cv_type_getgroups=gid_t +else + ac_cv_type_getgroups=int +fi +rm -f conftest* + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_getgroups" >&5 +$as_echo "$ac_cv_type_getgroups" >&6; } + +cat >>confdefs.h <<_ACEOF +#define GETGROUPS_T $ac_cv_type_getgroups +_ACEOF + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for long long int" >&5 +$as_echo_n "checking for long long int... " >&6; } +if ${ac_cv_type_long_long_int+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +long long int ll = 9223372036854775807ll; + long long int nll = -9223372036854775807LL; + typedef int a[((-9223372036854775807LL < 0 + && 0 < 9223372036854775807ll) + ? 1 : -1)]; + int i = 63; +int +main () +{ +long long int llmax = 9223372036854775807ll; + return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) + | (llmax / ll) | (llmax % ll)); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_type_long_long_int=yes +else + ac_cv_type_long_long_int=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_long_long_int" >&5 +$as_echo "$ac_cv_type_long_long_int" >&6; } + if test $ac_cv_type_long_long_int = yes; then + +$as_echo "#define HAVE_LONG_LONG_INT 1" >>confdefs.h + + fi + + + + ac_cv_type_long_long=$ac_cv_type_long_long_int + if test $ac_cv_type_long_long = yes; then + +$as_echo "#define HAVE_LONG_LONG 1" >>confdefs.h + + fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unsigned long long int" >&5 +$as_echo_n "checking for unsigned long long int... " >&6; } +if ${ac_cv_type_unsigned_long_long_int+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +unsigned long long int ull = 18446744073709551615ULL; + typedef int a[(18446744073709551615ULL <= (unsigned long long int) -1 + ? 1 : -1)]; + int i = 63; +int +main () +{ +unsigned long long int ullmax = 18446744073709551615ull; + return (ull << 63 | ull >> 63 | ull << i | ull >> i + | ullmax / ull | ullmax % ull); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_type_unsigned_long_long_int=yes +else + ac_cv_type_unsigned_long_long_int=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_unsigned_long_long_int" >&5 +$as_echo "$ac_cv_type_unsigned_long_long_int" >&6; } + if test $ac_cv_type_unsigned_long_long_int = yes; then + +$as_echo "#define HAVE_UNSIGNED_LONG_LONG_INT 1" >>confdefs.h + + fi + + + + ac_cv_type_unsigned_long_long=$ac_cv_type_unsigned_long_long_int + if test $ac_cv_type_unsigned_long_long = yes; then + +$as_echo "#define HAVE_UNSIGNED_LONG_LONG 1" >>confdefs.h + + fi + + + if test "OS/390" = "`uname`" + then + gl_cv_header_inttypes_h=no + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inttypes.h" >&5 +$as_echo_n "checking for inttypes.h... " >&6; } +if ${gl_cv_header_inttypes_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +uintmax_t i = (uintmax_t) -1; return !i; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_header_inttypes_h=yes +else + gl_cv_header_inttypes_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_inttypes_h" >&5 +$as_echo "$gl_cv_header_inttypes_h" >&6; } + if test $gl_cv_header_inttypes_h = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_INTTYPES_H_WITH_UINTMAX 1 +_ACEOF + + fi + fi + + + if test "OS/390" = "`uname`" + then + gl_cv_header_stdint_h=no + else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdint.h" >&5 +$as_echo_n "checking for stdint.h... " >&6; } +if ${gl_cv_header_stdint_h+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ +uintmax_t i = (uintmax_t) -1; return !i; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gl_cv_header_stdint_h=yes +else + gl_cv_header_stdint_h=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_header_stdint_h" >&5 +$as_echo "$gl_cv_header_stdint_h" >&6; } + if test $gl_cv_header_stdint_h = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE_STDINT_H_WITH_UINTMAX 1 +_ACEOF + + fi + fi + + + + + if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then + + test $ac_cv_type_long_long = yes \ + && ac_type='long long' \ + || ac_type='long' + +cat >>confdefs.h <<_ACEOF +#define intmax_t $ac_type +_ACEOF + + else + +$as_echo "#define HAVE_INTMAX_T 1" >>confdefs.h + + fi + + + + + if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then + + test $ac_cv_type_unsigned_long_long = yes \ + && ac_type='unsigned long long' \ + || ac_type='unsigned long' + +cat >>confdefs.h <<_ACEOF +#define uintmax_t $ac_type +_ACEOF + + else + +$as_echo "#define HAVE_UINTMAX_T 1" >>confdefs.h + + fi + +ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default" +if test "x$ac_cv_type_ssize_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define ssize_t int +_ACEOF + +fi + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned int" >&5 +$as_echo_n "checking size of unsigned int... " >&6; } +if ${ac_cv_sizeof_unsigned_int+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned int))" "ac_cv_sizeof_unsigned_int" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_unsigned_int" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (unsigned int) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_unsigned_int=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_int" >&5 +$as_echo "$ac_cv_sizeof_unsigned_int" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_UNSIGNED_INT $ac_cv_sizeof_unsigned_int +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned long" >&5 +$as_echo_n "checking size of unsigned long... " >&6; } +if ${ac_cv_sizeof_unsigned_long+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned long))" "ac_cv_sizeof_unsigned_long" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_unsigned_long" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (unsigned long) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_unsigned_long=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_long" >&5 +$as_echo "$ac_cv_sizeof_unsigned_long" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_UNSIGNED_LONG $ac_cv_sizeof_unsigned_long +_ACEOF + + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ + + time_t foo; + foo = 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +$as_echo "#define TIME_T_IN_SYS_TYPES_H 1" >>confdefs.h + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ + + wctype_t foo; + foo = 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +$as_echo "#define HAVE_WCTYPE_T 1" >>confdefs.h + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ + + wint_t foo; + foo = 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +$as_echo "#define HAVE_WINT_T 1" >>confdefs.h + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +int +main () +{ + + struct sockaddr_storage foo; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +$as_echo "#define HAVE_SOCKADDR_STORAGE 1" >>confdefs.h + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + + + + + + + ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include +#include +" +if test "x$ac_cv_type_socklen_t" = xyes; then : + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socklen_t equivalent" >&5 +$as_echo_n "checking for socklen_t equivalent... " >&6; } + if ${rsync_cv_socklen_t_equiv+:} false; then : + $as_echo_n "(cached) " >&6 +else + + # Systems have either "struct sockaddr *" or + # "void *" as the second argument to getpeername + rsync_cv_socklen_t_equiv= + for arg2 in "struct sockaddr" void; do + for t in int size_t unsigned long "unsigned long"; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +#include + + int getpeername (int, $arg2 *, $t *); + +int +main () +{ + + $t len; + getpeername(0,0,&len); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + rsync_cv_socklen_t_equiv="$t" + break + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done + done + + if test "x$rsync_cv_socklen_t_equiv" = x; then + rsync_cv_socklen_t_equiv=int + fi + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $rsync_cv_socklen_t_equiv" >&5 +$as_echo "$rsync_cv_socklen_t_equiv" >&6; } + +cat >>confdefs.h <<_ACEOF +#define socklen_t $rsync_cv_socklen_t_equiv +_ACEOF + +fi + + + +for ac_func in vprintf +do : + ac_fn_c_check_func "$LINENO" "vprintf" "ac_cv_func_vprintf" +if test "x$ac_cv_func_vprintf" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_VPRINTF 1 +_ACEOF + +ac_fn_c_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt" +if test "x$ac_cv_func__doprnt" = xyes; then : + +$as_echo "#define HAVE_DOPRNT 1" >>confdefs.h + +fi + +fi +done + + + + + + for ac_header in $ac_header_list +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + + + + for ac_func in $ac_func_list +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working mktime" >&5 +$as_echo_n "checking for working mktime... " >&6; } +if ${ac_cv_func_working_mktime+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_working_mktime=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Test program from Paul Eggert and Tony Leneis. */ +#ifdef TIME_WITH_SYS_TIME +# include +# include +#else +# ifdef HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + +#include +#include + +#ifdef HAVE_UNISTD_H +# include +#endif + +#ifndef HAVE_ALARM +# define alarm(X) /* empty */ +#endif + +/* Work around redefinition to rpl_putenv by other config tests. */ +#undef putenv + +static time_t time_t_max; +static time_t time_t_min; + +/* Values we'll use to set the TZ environment variable. */ +static const char *tz_strings[] = { + (const char *) 0, "TZ=GMT0", "TZ=JST-9", + "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00" +}; +#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0])) + +/* Return 0 if mktime fails to convert a date in the spring-forward gap. + Based on a problem report from Andreas Jaeger. */ +static int +spring_forward_gap () +{ + /* glibc (up to about 1998-10-07) failed this test. */ + struct tm tm; + + /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0" + instead of "TZ=America/Vancouver" in order to detect the bug even + on systems that don't support the Olson extension, or don't have the + full zoneinfo tables installed. */ + putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0"); + + tm.tm_year = 98; + tm.tm_mon = 3; + tm.tm_mday = 5; + tm.tm_hour = 2; + tm.tm_min = 0; + tm.tm_sec = 0; + tm.tm_isdst = -1; + return mktime (&tm) != (time_t) -1; +} + +static int +mktime_test1 (time_t now) +{ + struct tm *lt; + return ! (lt = localtime (&now)) || mktime (lt) == now; +} + +static int +mktime_test (time_t now) +{ + return (mktime_test1 (now) + && mktime_test1 ((time_t) (time_t_max - now)) + && mktime_test1 ((time_t) (time_t_min + now))); +} + +static int +irix_6_4_bug () +{ + /* Based on code from Ariel Faigon. */ + struct tm tm; + tm.tm_year = 96; + tm.tm_mon = 3; + tm.tm_mday = 0; + tm.tm_hour = 0; + tm.tm_min = 0; + tm.tm_sec = 0; + tm.tm_isdst = -1; + mktime (&tm); + return tm.tm_mon == 2 && tm.tm_mday == 31; +} + +static int +bigtime_test (int j) +{ + struct tm tm; + time_t now; + tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j; + now = mktime (&tm); + if (now != (time_t) -1) + { + struct tm *lt = localtime (&now); + if (! (lt + && lt->tm_year == tm.tm_year + && lt->tm_mon == tm.tm_mon + && lt->tm_mday == tm.tm_mday + && lt->tm_hour == tm.tm_hour + && lt->tm_min == tm.tm_min + && lt->tm_sec == tm.tm_sec + && lt->tm_yday == tm.tm_yday + && lt->tm_wday == tm.tm_wday + && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst) + == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst)))) + return 0; + } + return 1; +} + +static int +year_2050_test () +{ + /* The correct answer for 2050-02-01 00:00:00 in Pacific time, + ignoring leap seconds. */ + unsigned long int answer = 2527315200UL; + + struct tm tm; + time_t t; + tm.tm_year = 2050 - 1900; + tm.tm_mon = 2 - 1; + tm.tm_mday = 1; + tm.tm_hour = tm.tm_min = tm.tm_sec = 0; + tm.tm_isdst = -1; + + /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0" + instead of "TZ=America/Vancouver" in order to detect the bug even + on systems that don't support the Olson extension, or don't have the + full zoneinfo tables installed. */ + putenv ((char*) "TZ=PST8PDT,M4.1.0,M10.5.0"); + + t = mktime (&tm); + + /* Check that the result is either a failure, or close enough + to the correct answer that we can assume the discrepancy is + due to leap seconds. */ + return (t == (time_t) -1 + || (0 < t && answer - 120 <= t && t <= answer + 120)); +} + +int +main () +{ + time_t t, delta; + int i, j; + + /* This test makes some buggy mktime implementations loop. + Give up after 60 seconds; a mktime slower than that + isn't worth using anyway. */ + alarm (60); + + for (;;) + { + t = (time_t_max << 1) + 1; + if (t <= time_t_max) + break; + time_t_max = t; + } + time_t_min = - ((time_t) ~ (time_t) 0 == (time_t) -1) - time_t_max; + + delta = time_t_max / 997; /* a suitable prime number */ + for (i = 0; i < N_STRINGS; i++) + { + if (tz_strings[i]) + putenv ((char*) tz_strings[i]); + + for (t = 0; t <= time_t_max - delta; t += delta) + if (! mktime_test (t)) + return 1; + if (! (mktime_test ((time_t) 1) + && mktime_test ((time_t) (60 * 60)) + && mktime_test ((time_t) (60 * 60 * 24)))) + return 1; + + for (j = 1; ; j <<= 1) + if (! bigtime_test (j)) + return 1; + else if (INT_MAX / 2 < j) + break; + if (! bigtime_test (INT_MAX)) + return 1; + } + return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ()); +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_working_mktime=yes +else + ac_cv_func_working_mktime=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_working_mktime" >&5 +$as_echo "$ac_cv_func_working_mktime" >&6; } +if test $ac_cv_func_working_mktime = no; then + case " $LIBOBJS " in + *" mktime.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS mktime.$ac_objext" + ;; +esac + +fi + +case "$ac_cv_func_working_mktime" in +yes) +$as_echo "#define HAVE_MKTIME 1" >>confdefs.h + + ;; +esac + +ac_fn_c_check_func "$LINENO" "getaddrinfo" "ac_cv_func_getaddrinfo" +if test "x$ac_cv_func_getaddrinfo" = xyes; then : + +$as_echo "#define HAVE_GETADDRINFO 1" >>confdefs.h + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getaddrinfo in -lsocket" >&5 +$as_echo_n "checking for getaddrinfo in -lsocket... " >&6; } +if ${ac_cv_lib_socket_getaddrinfo+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsocket $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char getaddrinfo (); +int +main () +{ +return getaddrinfo (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_socket_getaddrinfo=yes +else + ac_cv_lib_socket_getaddrinfo=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_getaddrinfo" >&5 +$as_echo "$ac_cv_lib_socket_getaddrinfo" >&6; } +if test "x$ac_cv_lib_socket_getaddrinfo" = xyes; then : + +$as_echo "#define HAVE_GETADDRINFO 1" >>confdefs.h + +fi + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fmod in -lm" >&5 +$as_echo_n "checking for fmod in -lm... " >&6; } +if ${ac_cv_lib_m_fmod+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char fmod (); +int +main () +{ +return fmod (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_m_fmod=yes +else + ac_cv_lib_m_fmod=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_fmod" >&5 +$as_echo "$ac_cv_lib_m_fmod" >&6; } +if test "x$ac_cv_lib_m_fmod" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBM 1 +_ACEOF + + LIBS="-lm $LIBS" + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for isinf in -lm" >&5 +$as_echo_n "checking for isinf in -lm... " >&6; } +if ${ac_cv_lib_m_isinf+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char isinf (); +int +main () +{ +return isinf (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_m_isinf=yes +else + ac_cv_lib_m_isinf=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_isinf" >&5 +$as_echo "$ac_cv_lib_m_isinf" >&6; } +if test "x$ac_cv_lib_m_isinf" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBM 1 +_ACEOF + + LIBS="-lm $LIBS" + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ismod in -lm" >&5 +$as_echo_n "checking for ismod in -lm... " >&6; } +if ${ac_cv_lib_m_ismod+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char ismod (); +int +main () +{ +return ismod (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_m_ismod=yes +else + ac_cv_lib_m_ismod=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_ismod" >&5 +$as_echo "$ac_cv_lib_m_ismod" >&6; } +if test "x$ac_cv_lib_m_ismod" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBM 1 +_ACEOF + + LIBS="-lm $LIBS" + +fi + +case `uname` in +OSF1) : ;; +*) + + + + + + + + + + + + + + + use_additional=yes + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + +# Check whether --with-libsigsegv-prefix was given. +if test "${with_libsigsegv_prefix+set}" = set; then : + withval=$with_libsigsegv_prefix; + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + if test "$acl_libdirstem2" != "$acl_libdirstem" \ + && ! test -d "$withval/$acl_libdirstem"; then + additional_libdir="$withval/$acl_libdirstem2" + fi + fi + fi + +fi + + LIBSIGSEGV= + LTLIBSIGSEGV= + INCSIGSEGV= + LIBSIGSEGV_PREFIX= + HAVE_LIBSIGSEGV= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='sigsegv ' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIBSIGSEGV="${LIBSIGSEGV}${LIBSIGSEGV:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIBSIGSEGV="${LTLIBSIGSEGV}${LTLIBSIGSEGV:+ }$value" + else + : + fi + else + found_dir= + found_la= + found_so= + found_a= + eval libname=\"$acl_libname_spec\" # typically: libname=lib$name + if test -n "$acl_shlibext"; then + shrext=".$acl_shlibext" # typically: shrext=.so + else + shrext= + fi + if test $use_additional = yes; then + dir="$additional_libdir" + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIBSIGSEGV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + LTLIBSIGSEGV="${LTLIBSIGSEGV}${LTLIBSIGSEGV:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + if test "$enable_rpath" = no \ + || test "X$found_dir" = "X/usr/$acl_libdirstem" \ + || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then + LIBSIGSEGV="${LIBSIGSEGV}${LIBSIGSEGV:+ }$found_so" + else + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + if test "$acl_hardcode_direct" = yes; then + LIBSIGSEGV="${LIBSIGSEGV}${LIBSIGSEGV:+ }$found_so" + else + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + LIBSIGSEGV="${LIBSIGSEGV}${LIBSIGSEGV:+ }$found_so" + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + haveit= + for x in $LDFLAGS $LIBSIGSEGV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIBSIGSEGV="${LIBSIGSEGV}${LIBSIGSEGV:+ }-L$found_dir" + fi + if test "$acl_hardcode_minus_L" != no; then + LIBSIGSEGV="${LIBSIGSEGV}${LIBSIGSEGV:+ }$found_so" + else + LIBSIGSEGV="${LIBSIGSEGV}${LIBSIGSEGV:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + LIBSIGSEGV="${LIBSIGSEGV}${LIBSIGSEGV:+ }$found_a" + else + LIBSIGSEGV="${LIBSIGSEGV}${LIBSIGSEGV:+ }-L$found_dir -l$name" + fi + fi + additional_includedir= + case "$found_dir" in + */$acl_libdirstem | */$acl_libdirstem/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` + if test "$name" = 'sigsegv'; then + LIBSIGSEGV_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + */$acl_libdirstem2 | */$acl_libdirstem2/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` + if test "$name" = 'sigsegv'; then + LIBSIGSEGV_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INCSIGSEGV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + INCSIGSEGV="${INCSIGSEGV}${INCSIGSEGV:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + if test -n "$found_la"; then + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ + && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ + || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIBSIGSEGV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LIBSIGSEGV="${LIBSIGSEGV}${LIBSIGSEGV:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIBSIGSEGV; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + LTLIBSIGSEGV="${LTLIBSIGSEGV}${LTLIBSIGSEGV:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + LIBSIGSEGV="${LIBSIGSEGV}${LIBSIGSEGV:+ }$dep" + LTLIBSIGSEGV="${LTLIBSIGSEGV}${LTLIBSIGSEGV:+ }$dep" + ;; + esac + done + fi + else + LIBSIGSEGV="${LIBSIGSEGV}${LIBSIGSEGV:+ }-l$name" + LTLIBSIGSEGV="${LTLIBSIGSEGV}${LTLIBSIGSEGV:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$acl_hardcode_libdir_separator"; then + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBSIGSEGV="${LIBSIGSEGV}${LIBSIGSEGV:+ }$flag" + else + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIBSIGSEGV="${LIBSIGSEGV}${LIBSIGSEGV:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + for found_dir in $ltrpathdirs; do + LTLIBSIGSEGV="${LTLIBSIGSEGV}${LTLIBSIGSEGV:+ }-R$found_dir" + done + fi + + + + + + + + ac_save_CPPFLAGS="$CPPFLAGS" + + for element in $INCSIGSEGV; do + haveit= + for x in $CPPFLAGS; do + + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + eval x=\"$x\" + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" + + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" + fi + done + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libsigsegv" >&5 +$as_echo_n "checking for libsigsegv... " >&6; } +if ${ac_cv_libsigsegv+:} false; then : + $as_echo_n "(cached) " >&6 +else + + ac_save_LIBS="$LIBS" + case " $LIBSIGSEGV" in + *" -l"*) LIBS="$LIBS $LIBSIGSEGV" ;; + *) LIBS="$LIBSIGSEGV $LIBS" ;; + esac + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +sigsegv_deinstall_handler(); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_libsigsegv=yes +else + ac_cv_libsigsegv='no, consider installing GNU libsigsegv' +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + LIBS="$ac_save_LIBS" + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libsigsegv" >&5 +$as_echo "$ac_cv_libsigsegv" >&6; } + if test "$ac_cv_libsigsegv" = yes; then + HAVE_LIBSIGSEGV=yes + +$as_echo "#define HAVE_LIBSIGSEGV 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libsigsegv" >&5 +$as_echo_n "checking how to link with libsigsegv... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBSIGSEGV" >&5 +$as_echo "$LIBSIGSEGV" >&6; } + else + HAVE_LIBSIGSEGV=no + CPPFLAGS="$ac_save_CPPFLAGS" + LIBSIGSEGV= + LTLIBSIGSEGV= + LIBSIGSEGV_PREFIX= + fi + + + + + + + + gl_cv_lib_sigsegv="$ac_cv_libsigsegv" + + ;; +esac + +# Need the check for mkstemp and tmpfile for missing_d/snprintf.c. +for ac_func in atexit btowc fmod getgrent getgroups grantpt \ + isascii iswctype iswlower iswupper mbrlen \ + memcmp memcpy memcpy_ulong memmove memset \ + memset_ulong mkstemp setenv setlocale setsid snprintf strchr \ + strerror strftime strncasecmp strcoll strtod strtoul \ + system tmpfile towlower towupper tzset usleep wcrtomb \ + wcscoll wctype +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc and mbstate_t are properly declared" >&5 +$as_echo_n "checking whether mbrtowc and mbstate_t are properly declared... " >&6; } +if ${ac_cv_func_mbrtowc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +wchar_t wc; + char const s[] = ""; + size_t n = 1; + mbstate_t state; + return ! (sizeof state && (mbrtowc) (&wc, s, n, &state)); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_func_mbrtowc=yes +else + ac_cv_func_mbrtowc=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mbrtowc" >&5 +$as_echo "$ac_cv_func_mbrtowc" >&6; } + if test $ac_cv_func_mbrtowc = yes; then + +$as_echo "#define HAVE_MBRTOWC 1" >>confdefs.h + + fi + + +ac_fn_c_check_header_mongrel "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default" +if test "x$ac_cv_header_dlfcn_h" = xyes; then : + +$as_echo "#define DYNAMIC 1" >>confdefs.h + + if test "$GCC" = yes + then + # Add others here as appropriate, + # one day use GNU libtool. + # 3/2010: Used to have cygwin here but removed since + # we get complaints that -export-dynamic doesn't work. + if uname | $EGREP -i 'linux|freebsd' > /dev/null + then + LDFLAGS="$LDFLAGS -export-dynamic" + fi + fi + + # Check this separately. Some systems have dlopen + # in libc. Notably freebsd and cygwin. + # HP-NSK has it in zrldsrl + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5 +$as_echo_n "checking for library containing dlopen... " >&6; } +if ${ac_cv_search_dlopen+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +for ac_lib in '' dl zrldsrl; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_dlopen=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_dlopen+:} false; then : + break +fi +done +if ${ac_cv_search_dlopen+:} false; then : + +else + ac_cv_search_dlopen=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5 +$as_echo "$ac_cv_search_dlopen" >&6; } +ac_res=$ac_cv_search_dlopen +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + + +fi + + + +case `(uname) 2> /dev/null` in +*VMS*|*BeOS*|*OS/2*|*MS-DOS*) + +$as_echo "#define GETPGRP_VOID 1" >>confdefs.h + + ;; +*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getpgrp requires zero arguments" >&5 +$as_echo_n "checking whether getpgrp requires zero arguments... " >&6; } +if ${ac_cv_func_getpgrp_void+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Use it with a single arg. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +getpgrp (0); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_func_getpgrp_void=no +else + ac_cv_func_getpgrp_void=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getpgrp_void" >&5 +$as_echo "$ac_cv_func_getpgrp_void" >&6; } +if test $ac_cv_func_getpgrp_void = yes; then + +$as_echo "#define GETPGRP_VOID 1" >>confdefs.h + +fi + + ;; +esac + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for printf %F format" >&5 +$as_echo_n "checking for printf %F format... " >&6; } +if test "$cross_compiling" = yes; then : + has_f_format=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +#include + +int main() +{ + char buf[100]; + + sprintf(buf, "%F", 123.45); + + if (strcmp(buf, "123.450000") == 0) + return 0; + else + return 1; +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + has_f_format=yes +else + has_f_format=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +if test "$has_f_format" = yes; then + +$as_echo "#define PRINTF_HAS_F_FORMAT 1" >>confdefs.h + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $has_f_format" >&5 +$as_echo "$has_f_format" >&6; } + + +gawk_have_sockets=no +# Check for system-dependent location of socket libraries + +SOCKET_LIBS= +if test "$ISC" = yes; then + SOCKET_LIBS="-lnsl_s -linet" +else + # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X + # libraries were built with DECnet support. And karl@cs.umb.edu says + # the Alpha needs dnet_stub (dnet does not exist). + # + # ADR: Is this needed just for sockets??? +# AC_CHECK_LIB(dnet, dnet_ntoa, [SOCKET_LIBS="$SOCKET_LIBS -ldnet"]) +# if test $ac_cv_lib_dnet_ntoa = no; then +# AC_CHECK_LIB(dnet_stub, dnet_ntoa, +# [SOCKET_LIBS="$SOCKET_LIBS -ldnet_stub"]) +# fi + + # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, + # to get the SysV transport functions. + # chad@anasazi.com says the Pyramid MIS-ES running DC/OSx (SVR4) + # needs -lnsl. + # The nsl library prevents programs from opening the X display + # on Irix 5.2, according to dickey@clark.net. + ac_fn_c_check_func "$LINENO" "gethostbyname" "ac_cv_func_gethostbyname" +if test "x$ac_cv_func_gethostbyname" = xyes; then : + +fi + + if test $ac_cv_func_gethostbyname = no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5 +$as_echo_n "checking for gethostbyname in -lnsl... " >&6; } +if ${ac_cv_lib_nsl_gethostbyname+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lnsl $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char gethostbyname (); +int +main () +{ +return gethostbyname (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_nsl_gethostbyname=yes +else + ac_cv_lib_nsl_gethostbyname=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostbyname" >&5 +$as_echo "$ac_cv_lib_nsl_gethostbyname" >&6; } +if test "x$ac_cv_lib_nsl_gethostbyname" = xyes; then : + SOCKET_LIBS="$SOCKET_LIBS -lnsl" +fi + + fi + + # lieder@skyler.mavd.honeywell.com says without -lsocket, + # socket/setsockopt and other routines are undefined under SCO ODT + # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary + # on later versions), says simon@lia.di.epfl.ch: it contains + # gethostby* variants that don't use the nameserver (or something). + # -lsocket must be given before -lnsl if both are needed. + # We assume that if connect needs -lnsl, so does gethostbyname. + ac_fn_c_check_func "$LINENO" "connect" "ac_cv_func_connect" +if test "x$ac_cv_func_connect" = xyes; then : + +fi + + if test $ac_cv_func_connect = no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for connect in -lsocket" >&5 +$as_echo_n "checking for connect in -lsocket... " >&6; } +if ${ac_cv_lib_socket_connect+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsocket $SOCKET_LIBS $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char connect (); +int +main () +{ +return connect (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_socket_connect=yes +else + ac_cv_lib_socket_connect=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_connect" >&5 +$as_echo "$ac_cv_lib_socket_connect" >&6; } +if test "x$ac_cv_lib_socket_connect" = xyes; then : + SOCKET_LIBS="-lsocket $SOCKET_LIBS" + gawk_have_sockets=yes +fi + + else + gawk_have_sockets=yes + fi +fi + +if test "${gawk_have_sockets}" = "yes" +then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the socket library calls" >&5 +$as_echo_n "checking where to find the socket library calls... " >&6; } + case "${SOCKET_LIBS}" in + ?*) gawk_lib_loc="${SOCKET_LIBS}" ;; + *) gawk_lib_loc="the standard library" ;; + esac + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${gawk_lib_loc}" >&5 +$as_echo "${gawk_lib_loc}" >&6; } + + +$as_echo "#define HAVE_SOCKETS 1" >>confdefs.h + +fi + + + + +# Check whether --with-readline was given. +if test "${with_readline+set}" = set; then : + withval=$with_readline; _do_readline=$withval +else + _do_readline=yes +fi + + + if test "$_do_readline" != "no" ; then + if test -d "$withval" ; then + CPPFLAGS="${CPPFLAGS} -I$withval/include" + LDFLAGS="${LDFLAGS} -L$withval/lib" + fi + + for _termcap in "" "-ltermcap" "-lcurses" "-lncurses" ; do + _readline_save_libs=$LIBS + _combo="-lreadline${_termcap:+ $_termcap}" + LIBS="$LIBS $_combo" + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether readline via \"$_combo\" is present and sane" >&5 +$as_echo_n "checking whether readline via \"$_combo\" is present and sane... " >&6; } + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +#include +#include +#include + +int +main () +{ + +rl_completion_func_t *completer; +add_history("foobar"); +rl_catch_signals=0; +rl_inhibit_completion=0; +rl_attempted_completion_function=NULL; +rl_completion_matches(NULL,NULL); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + _found_readline=yes +else + _found_readline=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_found_readline" >&5 +$as_echo "$_found_readline" >&6; } + + LIBS=$_readline_save_libs + + if test $_found_readline = yes ; then + +$as_echo "#define HAVE_LIBREADLINE 1" >>confdefs.h + + LIBREADLINE=$_combo + + break + fi + done + + unset _termcap + unset _readline_save_libs + unset _combo + unset _found_readline + fi + + +ac_fn_c_check_member "$LINENO" "struct stat" "st_blksize" "ac_cv_member_struct_stat_st_blksize" "$ac_includes_default" +if test "x$ac_cv_member_struct_stat_st_blksize" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 +_ACEOF + + +$as_echo "#define HAVE_ST_BLKSIZE 1" >>confdefs.h + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 +$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } +if ${ac_cv_header_time+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_time=yes +else + ac_cv_header_time=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 +$as_echo "$ac_cv_header_time" >&6; } +if test $ac_cv_header_time = yes; then + +$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 +$as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } +if ${ac_cv_struct_tm+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include + +int +main () +{ +struct tm tm; + int *p = &tm.tm_sec; + return !p; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_struct_tm=time.h +else + ac_cv_struct_tm=sys/time.h +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5 +$as_echo "$ac_cv_struct_tm" >&6; } +if test $ac_cv_struct_tm = sys/time.h; then + +$as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h + +fi + +ac_fn_c_check_member "$LINENO" "struct tm" "tm_zone" "ac_cv_member_struct_tm_tm_zone" "#include +#include <$ac_cv_struct_tm> + +" +if test "x$ac_cv_member_struct_tm_tm_zone" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_TM_TM_ZONE 1 +_ACEOF + + +fi + +if test "$ac_cv_member_struct_tm_tm_zone" = yes; then + +$as_echo "#define HAVE_TM_ZONE 1" >>confdefs.h + +else + ac_fn_c_check_decl "$LINENO" "tzname" "ac_cv_have_decl_tzname" "#include +" +if test "x$ac_cv_have_decl_tzname" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_TZNAME $ac_have_decl +_ACEOF + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tzname" >&5 +$as_echo_n "checking for tzname... " >&6; } +if ${ac_cv_var_tzname+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#if !HAVE_DECL_TZNAME +extern char *tzname[]; +#endif + +int +main () +{ +return tzname[0][0]; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_var_tzname=yes +else + ac_cv_var_tzname=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_tzname" >&5 +$as_echo "$ac_cv_var_tzname" >&6; } + if test $ac_cv_var_tzname = yes; then + +$as_echo "#define HAVE_TZNAME 1" >>confdefs.h + + fi +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether char is unsigned" >&5 +$as_echo_n "checking whether char is unsigned... " >&6; } +if ${ac_cv_c_char_unsigned+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(((char) -1) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_char_unsigned=no +else + ac_cv_c_char_unsigned=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_char_unsigned" >&5 +$as_echo "$ac_cv_c_char_unsigned" >&6; } +if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then + $as_echo "#define __CHAR_UNSIGNED__ 1" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 +$as_echo_n "checking for an ANSI C-conforming const... " >&6; } +if ${ac_cv_c_const+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset cs; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *pcpcc; + char **ppc; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + pcpcc = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + if (s) return 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + if (!foo) return 0; + } + return !cs[0] && !zero.x; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_const=yes +else + ac_cv_c_const=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 +$as_echo "$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then + +$as_echo "#define const /**/" >>confdefs.h + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5 +$as_echo_n "checking for C/C++ restrict keyword... " >&6; } +if ${ac_cv_c_restrict+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_restrict=no + # The order here caters to the fact that C++ does not require restrict. + for ac_kw in __restrict __restrict__ _Restrict restrict; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +typedef int * int_ptr; + int foo (int_ptr $ac_kw ip) { + return ip[0]; + } +int +main () +{ +int s[1]; + int * $ac_kw t = s; + t[0] = 0; + return foo(t) + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_restrict=$ac_kw +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_restrict" != no && break + done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5 +$as_echo "$ac_cv_c_restrict" >&6; } + + case $ac_cv_c_restrict in + restrict) ;; + no) $as_echo "#define restrict /**/" >>confdefs.h + ;; + *) cat >>confdefs.h <<_ACEOF +#define restrict $ac_cv_c_restrict +_ACEOF + ;; + esac + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 +$as_echo_n "checking for inline... " >&6; } +if ${ac_cv_c_inline+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef __cplusplus +typedef int foo_t; +static $ac_kw foo_t static_foo () {return 0; } +$ac_kw foo_t foo () {return 0; } +#endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_inline=$ac_kw +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_inline" != no && break +done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 +$as_echo "$ac_cv_c_inline" >&6; } + +case $ac_cv_c_inline in + inline | yes) ;; + *) + case $ac_cv_c_inline in + no) ac_val=;; + *) ac_val=$ac_cv_c_inline;; + esac + cat >>confdefs.h <<_ACEOF +#ifndef __cplusplus +#define inline $ac_val +#endif +_ACEOF + ;; +esac + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for preprocessor stringizing operator" >&5 +$as_echo_n "checking for preprocessor stringizing operator... " >&6; } +if ${ac_cv_c_stringize+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define x(y) #y + +char *s = x(teststring); +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "#teststring" >/dev/null 2>&1; then : + ac_cv_c_stringize=no +else + ac_cv_c_stringize=yes +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stringize" >&5 +$as_echo "$ac_cv_c_stringize" >&6; } +if test $ac_cv_c_stringize = yes; then + +$as_echo "#define HAVE_STRINGIZE 1" >>confdefs.h + +fi + + +ac_config_headers="$ac_config_headers config.h:configh.in" + + + +ac_config_files="$ac_config_files Makefile awklib/Makefile doc/Makefile po/Makefile.in test/Makefile" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + if test -n "$EXEEXT"; then + am__EXEEXT_TRUE= + am__EXEEXT_FALSE='#' +else + am__EXEEXT_TRUE='#' + am__EXEEXT_FALSE= +fi + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + as_fn_error $? "conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + as_fn_error $? "conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -p' + fi +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in #( + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by GNU Awk $as_me 4.0.1, which was +generated by GNU Autoconf 2.68. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to . +GNU Awk home page: . +General help using GNU software: ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +GNU Awk config.status 4.0.1 +configured by $0, generated by GNU Autoconf 2.68, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2010 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' +AWK='$AWK' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# +# INIT-COMMANDS +# +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" +# Capture the value of obsolete ALL_LINGUAS because we need it to compute + # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it + # from automake < 1.5. + eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' + # Capture the value of LINGUAS because we need it to compute CATALOGS. + LINGUAS="${LINGUAS-%UNSET%}" + + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "po-directories") CONFIG_COMMANDS="$CONFIG_COMMANDS po-directories" ;; + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:configh.in" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "awklib/Makefile") CONFIG_FILES="$CONFIG_FILES awklib/Makefile" ;; + "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; + "po/Makefile.in") CONFIG_FILES="$CONFIG_FILES po/Makefile.in" ;; + "test/Makefile") CONFIG_FILES="$CONFIG_FILES test/Makefile" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi +# Compute "$ac_file"'s index in $config_headers. +_am_arg="$ac_file" +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $_am_arg | $_am_arg:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$_am_arg" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 +$as_echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || { + # Autoconf 2.62 quotes --file arguments for eval, but not when files + # are listed without --file. Let's play safe and only enable the eval + # if we detect the quoting. + case $CONFIG_FILES in + *\'*) eval set x "$CONFIG_FILES" ;; + *) set x $CONFIG_FILES ;; + esac + shift + for mf + do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # Grep'ing the whole file is not good either: AIX grep has a line + # limit of 2048, but all sed's we know have understand at least 4000. + if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then + dirpart=`$as_dirname -- "$mf" || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_dirname -- "$file" || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir=$dirpart/$fdir; as_fn_mkdir_p + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done + done +} + ;; + "po-directories":C) + for ac_file in $CONFIG_FILES; do + # Support "outfile[:infile[:infile...]]" + case "$ac_file" in + *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + esac + # PO directories have a Makefile.in generated from Makefile.in.in. + case "$ac_file" in */Makefile.in) + # Adjust a relative srcdir. + ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` + ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" + ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` + # In autoconf-2.13 it is called $ac_given_srcdir. + # In autoconf-2.50 it is called $srcdir. + test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" + case "$ac_given_srcdir" in + .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; + /*) top_srcdir="$ac_given_srcdir" ;; + *) top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + # Treat a directory as a PO directory if and only if it has a + # POTFILES.in file. This allows packages to have multiple PO + # directories under different names or in different locations. + if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then + rm -f "$ac_dir/POTFILES" + test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" + cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" + POMAKEFILEDEPS="POTFILES.in" + # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend + # on $ac_dir but don't depend on user-specified configuration + # parameters. + if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then + # The LINGUAS file contains the set of available languages. + if test -n "$OBSOLETE_ALL_LINGUAS"; then + test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" + fi + ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` + # Hide the ALL_LINGUAS assigment from automake < 1.5. + eval 'ALL_LINGUAS''=$ALL_LINGUAS_' + POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" + else + # The set of available languages was given in configure.in. + # Hide the ALL_LINGUAS assigment from automake < 1.5. + eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' + fi + # Compute POFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) + # Compute UPDATEPOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) + # Compute DUMMYPOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) + # Compute GMOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) + case "$ac_given_srcdir" in + .) srcdirpre= ;; + *) srcdirpre='$(srcdir)/' ;; + esac + POFILES= + UPDATEPOFILES= + DUMMYPOFILES= + GMOFILES= + for lang in $ALL_LINGUAS; do + POFILES="$POFILES $srcdirpre$lang.po" + UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" + DUMMYPOFILES="$DUMMYPOFILES $lang.nop" + GMOFILES="$GMOFILES $srcdirpre$lang.gmo" + done + # CATALOGS depends on both $ac_dir and the user's LINGUAS + # environment variable. + INST_LINGUAS= + if test -n "$ALL_LINGUAS"; then + for presentlang in $ALL_LINGUAS; do + useit=no + if test "%UNSET%" != "$LINGUAS"; then + desiredlanguages="$LINGUAS" + else + desiredlanguages="$ALL_LINGUAS" + fi + for desiredlang in $desiredlanguages; do + # Use the presentlang catalog if desiredlang is + # a. equal to presentlang, or + # b. a variant of presentlang (because in this case, + # presentlang can be used as a fallback for messages + # which are not translated in the desiredlang catalog). + case "$desiredlang" in + "$presentlang"*) useit=yes;; + esac + done + if test $useit = yes; then + INST_LINGUAS="$INST_LINGUAS $presentlang" + fi + done + fi + CATALOGS= + if test -n "$INST_LINGUAS"; then + for lang in $INST_LINGUAS; do + CATALOGS="$CATALOGS $lang.gmo" + done + fi + test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" + sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" + for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do + if test -f "$f"; then + case "$f" in + *.orig | *.bak | *~) ;; + *) cat "$f" >> "$ac_dir/Makefile" ;; + esac + fi + done + fi + ;; + esac + done ;; + + esac +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..bc317cf --- /dev/null +++ b/configure.ac @@ -0,0 +1,363 @@ +dnl +dnl configure.ac --- autoconf input file for gawk +dnl +dnl Copyright (C) 1995-2012 the Free Software Foundation, Inc. +dnl +dnl This file is part of GAWK, the GNU implementation of the +dnl AWK Programming Language. +dnl +dnl GAWK is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl GAWK is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +dnl + +dnl Process this file with autoconf to produce a configure script. + +AC_INIT([GNU Awk], 4.0.1, bug-gawk@gnu.org, gawk) + +# This is a hack. Different versions of install on different systems +# are just too different. Chuck it and use install-sh. +# +# If the user supplies $INSTALL, figure they know what they're doing. +# +# With Autoconf 2.5x, this needs to come very early on, but *after* +# the INIT macro. Sigh. + +if test "x$INSTALL" = "x" +then + INSTALL="$srcdir/install-sh -c" + export INSTALL +fi + +AC_PREREQ(2.68) +AM_INIT_AUTOMAKE([1.11 dist-xz]) + +AC_CONFIG_MACRO_DIR([m4]) + +dnl Additional argument stuff +AC_ARG_WITH(whiny-user-strftime, [ --with-whiny-user-strftime Force use of included version of strftime for deficient systems], + if test "$withval" = yes + then + AC_DEFINE(USE_INCLUDED_STRFTIME, 1, + [force use of our version of strftime]) + fi +) +AC_ARG_ENABLE([lint], [ --disable-lint Disable gawk lint checking], + if test "$enableval" = no + then + AC_DEFINE(NO_LINT, 1, [disable lint checks]) + fi +) + +AC_USE_SYSTEM_EXTENSIONS + +dnl checks for programs +AC_PROG_EGREP +AC_PROG_YACC +AC_PROG_LN_S +AC_PROG_CC +AC_PROG_CPP + +AC_OBJEXT +AC_EXEEXT + +AC_PROG_INSTALL +AC_PROG_MAKE_SET + +# This is mainly for my use during testing and development. +# Yes, it's a bit of a hack. +AC_MSG_CHECKING([for special development options]) +if test -f $srcdir/.developing +then + # add other debug flags as appropriate, save GAWKDEBUG for emergencies + CFLAGS="$CFLAGS -DARRAYDEBUG -DYYDEBUG" + if grep dbug $srcdir/.developing + then + CFLAGS="$CFLAGS -DDBUG" + LIBS="$LIBS dbug/libdbug.a" + fi + # turn on compiler warnings if we're doing development + # enable debugging using macros also + if test "$GCC" = yes + then + CFLAGS="$CFLAGS -Wall -fno-builtin -g3 -gdwarf-2" + fi + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi + +AC_SUBST(CFLAGS) + +dnl checks for systems +AC_ZOS_USS +AC_ISC_POSIX +AC_SYS_LARGEFILE +GAWK_AC_AIX_TWEAK +GAWK_AC_LINUX_ALPHA + +if test "$ISC" = 1 # will be set by test for ISC +then +dnl need -D_SYSV3 for ISC + CFLAGS="$CFLAGS -D_SYSV3" +fi + +dnl Set the programming language for checks. Fortunately, +dnl this only needs to be set once, since everything is in C. +AC_LANG([C]) + +dnl Cygwin doesn't like to get libs with full paths +dnl since that overrides linking against DLLs. +case `(uname) 2> /dev/null` in +*CYGWIN*) + with_libiconv_prefix=no + with_libintl_prefix=no + ;; +*) + ;; +esac + +dnl initialize GNU gettext +AM_GNU_GETTEXT([external]) +AM_GNU_GETTEXT_VERSION([0.18.1]) +AM_LANGINFO_CODESET +gt_LC_MESSAGES + +dnl checks for header files +AC_HEADER_STDC +AC_HEADER_SYS_WAIT +AC_HEADER_TIME +AC_CHECK_HEADERS(arpa/inet.h fcntl.h limits.h locale.h libintl.h mcheck.h \ + netdb.h netinet/in.h stdarg.h stddef.h string.h \ + sys/ioctl.h sys/param.h sys/socket.h sys/time.h unistd.h \ + termios.h stropts.h wchar.h wctype.h) + +if test "$ac_cv_header_string_h" = yes +then + AC_CHECK_HEADERS(memory.h) +else + AC_CHECK_HEADERS(strings.h) +fi + +dnl checks for typedefs +AC_TYPE_PID_T +AC_TYPE_SIGNAL +AC_SIZE_T +AC_TYPE_GETGROUPS +gl_AC_TYPE_LONG_LONG +gl_AC_TYPE_UNSIGNED_LONG_LONG +gl_AC_TYPE_INTMAX_T +gl_AC_TYPE_UINTMAX_T +AC_CHECK_TYPE(ssize_t, int) +AC_CHECK_SIZEOF(unsigned int) +AC_CHECK_SIZEOF(unsigned long) +dnl see if time_t is defined in +AC_TRY_COMPILE([#include ],[ + time_t foo; + foo = 0; +], + AC_DEFINE(TIME_T_IN_SYS_TYPES_H, 1, + [some systems define this type here])) +dnl check for wctype_t in +AC_TRY_COMPILE([#include ],[ + wctype_t foo; + foo = 0; +], + AC_DEFINE(HAVE_WCTYPE_T, 1, [systems should define this type here])) +dnl check for wint_t in +AC_TRY_COMPILE([#include ],[ + wint_t foo; + foo = 0; +], + AC_DEFINE(HAVE_WINT_T, 1, [systems should define this type here])) +dnl check for sockaddr_storage +AC_TRY_COMPILE([#include +#include ],[ + struct sockaddr_storage foo; +], + AC_DEFINE(HAVE_SOCKADDR_STORAGE, 1, [newer systems define this type here])) + +dnl Borrwed from rsync, thanks to to Jim Meyering. + +dnl Check for socklen_t: historically on BSD it is an int, and in +dnl POSIX 1g it is a type of its own, but some platforms use different +dnl types for the argument to getsockopt, getpeername, etc. So we +dnl have to test to find something that will work. + +dnl This is no good, because passing the wrong pointer on C compilers is +dnl likely to only generate a warning, not an error. + +AC_DEFUN([TYPE_SOCKLEN_T], +[ + AC_CHECK_TYPE([socklen_t], ,[ + AC_MSG_CHECKING([for socklen_t equivalent]) + AC_CACHE_VAL([rsync_cv_socklen_t_equiv], + [ + # Systems have either "struct sockaddr *" or + # "void *" as the second argument to getpeername + rsync_cv_socklen_t_equiv= + for arg2 in "struct sockaddr" void; do + for t in int size_t unsigned long "unsigned long"; do + AC_TRY_COMPILE([ +#include +#include + + int getpeername (int, $arg2 *, $t *); + ],[ + $t len; + getpeername(0,0,&len); + ],[ + rsync_cv_socklen_t_equiv="$t" + break + ]) + done + done + + if test "x$rsync_cv_socklen_t_equiv" = x; then +dnl Some systems get this. Default to int. -- ADR +dnl AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) + rsync_cv_socklen_t_equiv=int + fi + ]) + AC_MSG_RESULT($rsync_cv_socklen_t_equiv) + AC_DEFINE_UNQUOTED(socklen_t, $rsync_cv_socklen_t_equiv, + [type to use in place of socklen_t if not defined])], + [#include +#include ]) +]) +TYPE_SOCKLEN_T + +dnl checks for functions +AC_FUNC_VPRINTF +AC_FUNC_MKTIME +case "$ac_cv_func_working_mktime" in +yes) AC_DEFINE(HAVE_MKTIME, 1, [we have the mktime function]) + ;; +esac + +AC_CHECK_FUNC(getaddrinfo, [AC_DEFINE(HAVE_GETADDRINFO, 1, [have getaddrinfo])], + [AC_CHECK_LIB(socket, getaddrinfo, + [AC_DEFINE(HAVE_GETADDRINFO, 1, + [have getaddrinfo])])]) + +AC_CHECK_LIB(m, fmod) +AC_CHECK_LIB(m, isinf) +AC_CHECK_LIB(m, ismod) +dnl Don't look for libsigsegv on OSF/1, gives us severe headaches +case `uname` in +OSF1) : ;; +*) + gl_LIBSIGSEGV + ;; +esac + +# Need the check for mkstemp and tmpfile for missing_d/snprintf.c. +AC_CHECK_FUNCS(atexit btowc fmod getgrent getgroups grantpt \ + isascii iswctype iswlower iswupper mbrlen \ + memcmp memcpy memcpy_ulong memmove memset \ + memset_ulong mkstemp setenv setlocale setsid snprintf strchr \ + strerror strftime strncasecmp strcoll strtod strtoul \ + system tmpfile towlower towupper tzset usleep wcrtomb \ + wcscoll wctype) +dnl this check is for both mbrtowc and the mbstate_t type, which is good +AC_FUNC_MBRTOWC + +dnl check for dynamic linking +dnl This is known to be very primitive +AC_CHECK_HEADER(dlfcn.h, + [AC_DEFINE([DYNAMIC], 1, [dynamic loading is possible]) + if test "$GCC" = yes + then + # Add others here as appropriate, + # one day use GNU libtool. + # 3/2010: Used to have cygwin here but removed since + # we get complaints that -export-dynamic doesn't work. + if uname | $EGREP -i 'linux|freebsd' > /dev/null + then + LDFLAGS="$LDFLAGS -export-dynamic" + fi + fi + + # Check this separately. Some systems have dlopen + # in libc. Notably freebsd and cygwin. + # HP-NSK has it in zrldsrl + AC_SEARCH_LIBS(dlopen, dl zrldsrl) +]) + +dnl check for how to use getpgrp +dnl have to hardwire it for VMS POSIX. Sigh. +dnl ditto for BeOS, OS/2, and MS-DOS. +case `(uname) 2> /dev/null` in +*VMS*|*BeOS*|*OS/2*|*MS-DOS*) + AC_DEFINE(GETPGRP_VOID, 1, + [Define to 1 if the getpgrp function requires zero arguments.]) + ;; +*) AC_FUNC_GETPGRP + ;; +esac + +dnl check for printf %F format +AC_MSG_CHECKING([for printf %F format]) +AC_RUN_IFELSE([ +AC_LANG_SOURCE([ +#include + +int main() +{ + char buf[[100]]; + + sprintf(buf, "%F", 123.45); + + if (strcmp(buf, "123.450000") == 0) + return 0; + else + return 1; +} +])], + has_f_format=yes, + has_f_format=no, + has_f_format=no dnl Cross-compiling, assuming the worst. +) +if test "$has_f_format" = yes; then + AC_DEFINE(PRINTF_HAS_F_FORMAT, 1, [Define to 1 if *printf supports %F format]) +fi +AC_MSG_RESULT($has_f_format) + +dnl check for sockets +GAWK_AC_LIB_SOCKETS + +dnl check for readline support +GNUPG_CHECK_READLINE + +dnl checks for structure members +AC_STRUCT_ST_BLKSIZE +AC_HEADER_TIME +AC_STRUCT_TM +AC_STRUCT_TIMEZONE + +dnl checks for compiler characteristics +AC_C_CHAR_UNSIGNED +AC_C_CONST +AC_C_RESTRICT +AC_C_INLINE +AC_C_STRINGIZE + +AC_CONFIG_HEADERS([config.h:configh.in]) +AH_BOTTOM([#include "custom.h"]) + +AC_CONFIG_FILES(Makefile + awklib/Makefile + doc/Makefile + po/Makefile.in + test/Makefile) +AC_OUTPUT diff --git a/custom.h b/custom.h new file mode 100644 index 0000000..36b4aa0 --- /dev/null +++ b/custom.h @@ -0,0 +1,78 @@ +/* + * custom.h + * + * This file is for use on systems where Autoconf isn't quite able to + * get things right. It is appended to the bottom of config.h by configure, + * in order to override definitions from Autoconf that are erroneous. See + * the manual for more information. + * + * If you make additions to this file for your system, please send me + * the information, to arnold@skeeve.com. + */ + +/* + * Copyright (C) 1995-2004, 2008, 2009, 2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* for VMS POSIX, from Pat Rankin, r.pat.rankin@gmail.com */ +#ifdef VMS_POSIX +#undef VMS +#include "vms/redirect.h" +#endif + +/* For QNX, based on submission from Michael Hunter, mphunter@qnx.com */ +#ifdef __QNX__ +#define GETPGRP_VOID 1 +#endif + +/* For MacOS X, which is almost BSD Unix */ +#ifdef __APPLE__ +#define HAVE_MKTIME 1 +#endif + +/* For ULTRIX 4.3 */ +#ifdef ultrix +#define HAVE_MKTIME 1 +#define GETGROUPS_NOT_STANDARD 1 +#endif + +/* For whiny users */ +#ifdef USE_INCLUDED_STRFTIME +#undef HAVE_STRFTIME +#endif + +/* For HP/UX with gcc */ +#if defined(hpux) || defined(_HPUX_SOURCE) +#undef HAVE_TZSET +#define HAVE_TZSET 1 +#define _TZSET 1 +#endif + +/* For z/OS, from Dave Pitts */ +#ifdef ZOS_USS +#undef HAVE_DLFCN_H +#undef HAVE_SYS_PARAM_H +#undef HAVE_MCHECK_H +#undef HAVE_SETENV +#define setenv zos_setenv +#define unsetenv zos_unsetenv +extern int setenv(const char *name, const char *value, int rewrite); +extern int unsetenv(const char *name); +#endif diff --git a/debug.c b/debug.c new file mode 100644 index 0000000..1cfbac4 --- /dev/null +++ b/debug.c @@ -0,0 +1,5772 @@ +/* + * debug.c - gawk debugger + */ + +/* + * Copyright (C) 2004, 2010, 2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#include "awk.h" +#include "cmd.h" + +#ifndef O_RDONLY +#include /* open() */ +#endif + +extern int exiting; +extern SRCFILE *srcfiles; +extern INSTRUCTION *rule_list; +extern INSTRUCTION *code_block; +extern NODE **fcall_list; +extern long fcall_count; +extern FILE *output_fp; +extern IOBUF *curfile; +extern const char *command_file; +extern const char *get_spec_varname(Func_ptr fptr); +extern int r_interpret(INSTRUCTION *); +extern int zzparse(void); +#define read_command() (void) zzparse() + +extern int free_instruction(INSTRUCTION *, int *); +extern void destroy_symbol(char *name); +extern const char *redir2str(int redirtype); + +static char *linebuf = NULL; /* used to print a single line of source */ +static size_t linebuf_len; + +FILE *out_fp; +char *dPrompt; +char *commands_Prompt = "> "; /* breakpoint or watchpoint commands list */ +char *eval_Prompt = "@> "; /* awk statement(s) */ + +int input_from_tty = FALSE; +int input_fd; + +static SRCFILE *cur_srcfile; +static long cur_frame = 0; +static INSTRUCTION *cur_pc; +int cur_rule = 0; + +static int prog_running = FALSE; + +struct condition { + INSTRUCTION *code; + AWK_CONTEXT *ctxt; + char *expr; +}; + +struct commands_item { + struct commands_item *next; + struct commands_item *prev; + int cmd; + char *cmd_string; + CMDARG *arg; +}; + +/* breakpoint structure */ +typedef struct break_point { + struct break_point *next; + struct break_point *prev; + int number; + + long ignore_count; + long hit_count; + char *src; + INSTRUCTION *bpi; /* Op_breakpoint */ + + struct commands_item commands; /* list of commands to run */ + int silent; + + struct condition cndn; + + short flags; +#define BP_ENABLE 1 +#define BP_ENABLE_ONCE 2 /* enable once */ +#define BP_TEMP 4 +#define BP_IGNORE 8 + +} BREAKPOINT; + +static BREAKPOINT breakpoints = { &breakpoints, &breakpoints, 0 }; + +#ifdef HAVE_LIBREADLINE +/* do_save -- save command */ +static int sess_history_base = 0; +#endif + +/* 'list' command */ +static int last_printed_line = 0; +static int last_print_count; /* # of lines printed */ + +/* watch or display item */ +struct list_item { + struct list_item *next; + struct list_item *prev; + int number; /* item number */ + + NODE *symbol; /* variable or function param */ + NODE **subs; /* subscripts */ + int num_subs; /* subscript(dimension) count */ + char *sname; /* symbol or param name */ + + long fcall_count; + + struct commands_item commands; + int silent; + struct condition cndn; + + /* This is for the value of the watched item */ + union { + NODE *n; + long l; + } value[2]; +#define cur_value value[0].n +#define cur_size value[0].l +#define old_value value[1].n +#define old_size value[1].l + + int flags; +#define PARAM 1 +#define SUBSCRIPT 2 +#define FIELD_NUM 4 +#define OLD_IS_ARRAY 8 /* old item is array */ +#define CUR_IS_ARRAY 16 /* current item is array */ +}; + +#define IS_PARAM(d) (((d)->flags & PARAM) != 0) +#define IS_SUBSCRIPT(d) (((d)->flags & SUBSCRIPT) != 0) +#define IS_FIELD(d) (((d)->flags & FIELD_NUM) != 0) +#define WATCHING_ARRAY(d) (((d)->flags & CUR_IS_ARRAY) != 0) + +static struct list_item display_list = { &display_list, &display_list, 0 }; +static struct list_item watch_list = { &watch_list, &watch_list, 0 }; + + +/* Structure to maintain data for processing debugger commands */ + +static struct { + long fcall_count; /* 'finish', 'until', 'next', 'step', 'nexti' commands */ + int sourceline; /* source line number last + * time we stopped execution, + * used by next, until and step commands + */ + char *source; /* next, until and step */ + + INSTRUCTION *pc; /* 'until' and 'return' commands */ + int repeat_count; /* 'step', 'next', 'stepi', 'nexti' commands */ + int print_frame; /* print frame info, 'finish' and 'until' */ + int print_ret; /* print returned value, 'finish' */ + int break_point; /* non-zero (breakpoint number) if stopped at break point */ + int watch_point; /* non-zero (watchpoint number) if stopped at watch point */ + + int (*check_func)(INSTRUCTION **); /* function to decide when to suspend + * awk interpreter and return control + * to debugger command interpreter. + */ + + enum argtype command; /* command type */ +} stop; + + +/* restart related stuff */ +extern char **d_argv; /* copy of argv array */ +static int need_restart = FALSE; +enum { BREAK=1, WATCH, DISPLAY, HISTORY, OPTION }; +static const char *const env_variable[] = { +"", +"DGAWK_BREAK", +"DGAWK_WATCH", +"DGAWK_DISPLAY", +"DGAWK_HISTORY", +"DGAWK_OPTION", +}; +static void serialize(int ); +static void unserialize(int ); +static const char *commands_string = NULL; +static int commands_string_len = 0; +static char line_sep; +#define FSEP (char)'\037' +#define RSEP (char)'\036' +#define CSEP (char)'\035' + + +/* debugger option */ +struct dbg_option { + const char *name; + int *num_val; + char **str_val; + void (*assign)(const char *); + const char *help_txt; +}; + +#define DEFAULT_HISTFILE "./.dgawk_history" +#define DEFAULT_OPTFILE "./.dgawkrc" +#define DEFAULT_PROMPT "dgawk> " +#define DEFAULT_LISTSIZE 15 +#define DEFAULT_HISTSIZE 100 + +static void set_gawk_output(const char *file); +static void set_prompt(const char *value); +static void set_listsize(const char *value); +static void set_trace(const char *value); +static void set_save_history(const char *value); +static void set_save_options(const char *value); +static void set_history_size(const char *value); +static const char *options_file = DEFAULT_OPTFILE; +#ifdef HAVE_LIBREADLINE +static const char *history_file = DEFAULT_HISTFILE; +#endif + +/* keep all option variables in one place */ + +static char *output_file = "/dev/stdout"; /* gawk output redirection */ +char *dgawk_Prompt = NULL; /* initialized in interpret */ +static int list_size = DEFAULT_LISTSIZE; /* # of lines that 'list' prints */ +static int do_trace = FALSE; +static int do_save_history = TRUE; +static int do_save_options = TRUE; +static int history_size = DEFAULT_HISTSIZE; /* max # of lines in history file */ + +static const struct dbg_option option_list[] = { +{"history_size", &history_size, NULL, &set_history_size, + gettext_noop("set or show the number of lines to keep in history file.") }, +{"listsize", &list_size, NULL, &set_listsize, + gettext_noop("set or show the list command window size.") }, +{"outfile", NULL, &output_file, &set_gawk_output, + gettext_noop("set or show gawk output file.") }, +{"prompt", NULL, &dgawk_Prompt, &set_prompt, + gettext_noop("set or show debugger prompt."), }, +{"save_history", &do_save_history, NULL, &set_save_history, + gettext_noop("(un)set or show saving of command history (value=on|off).") }, +{"save_options", &do_save_options, NULL, &set_save_options, + gettext_noop("(un)set or show saving of options (value=on|off).") }, +{"trace", &do_trace, NULL, &set_trace, + gettext_noop("(un)set or show instruction tracing (value=on|off).") }, +{0, NULL, NULL, NULL, 0}, +}; + +static void save_options(const char *file); + + +/* pager */ +jmp_buf pager_quit_tag; +int pager_quit_tag_valid; +static int screen_width = INT_MAX; /* no of columns */ +static int screen_height = INT_MAX; /* no of rows */ +static int pager_lines_printed = 0; /* no of lines printed so far */ + +static void restart(int run) ATTRIBUTE_NORETURN; +static void close_all(void); +static int open_readfd(const char *file); +static int find_lines(SRCFILE *s); +static SRCFILE *source_find(char *src); +static int print_lines(char *src, int start_line, int nlines); +static void print_symbol(NODE *r, int isparam); +static NODE *find_frame(long num); +static NODE *find_param(const char *name, long num, char **pname); +static NODE *find_symbol(const char *name, char **pname); +static NODE *find_array(const char *name); +static void print_field(long field_num); +static int print_function(INSTRUCTION *pc, void *); +static void print_frame(NODE *func, char *src, int srcline); +static void print_numbered_frame(long num); +static void print_cur_frame_and_sourceline(void); +static INSTRUCTION *find_rule(char *src, long lineno); +static INSTRUCTION *mk_breakpoint(char *src, int srcline); +static int execute_commands(struct commands_item *commands); +static void delete_commands_item(struct commands_item *c); +static NODE *execute_code(volatile INSTRUCTION *code); +static int pre_execute_code(INSTRUCTION **pi); +static int parse_condition(int type, int num, char *expr); +static BREAKPOINT *add_breakpoint(INSTRUCTION *, INSTRUCTION *, char *, int); +static BREAKPOINT *set_breakpoint_next(INSTRUCTION *rp, INSTRUCTION *ip); +static BREAKPOINT *set_breakpoint_at(INSTRUCTION *, int, int); +static int set_breakpoint(CMDARG *arg, int temporary); +static void delete_breakpoint(BREAKPOINT *b); +static BREAKPOINT *find_breakpoint(long num); +static void display(struct list_item *d); +static struct list_item *find_item(struct list_item *list, long num); +static struct list_item *add_item(struct list_item *list, int type, NODE *symbol, char *pname); +static void delete_item(struct list_item *d); +static int breakpoint_triggered(BREAKPOINT *b); +static int watchpoint_triggered(struct list_item *w); + +static void print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump); +static void next_command(); +static char *g_readline(const char *prompt); +static int prompt_yes_no(const char *, char , int , FILE *); + +static struct pf_data { + Func_print print_func; + int defn; + FILE *fp; +} pf_data; + +char * (*read_a_line)(const char *) = 0; /* reads a line of input */ + +struct command_source +{ + int fd; + int is_tty; + char * (*read_func)(const char *); + int (*close_func)(int); + int eof_status; /* see push_cmd_src */ + int cmd; /* D_source or 0 */ + char *str; /* sourced file */ + struct command_source *next; +}; + +static struct command_source *cmd_src = NULL; + +#define get_param_count(f) (f)->lnode->param_cnt +#define get_params(f) (f)->parmlist + + +#define CHECK_PROG_RUNNING() \ + do { \ + if (! prog_running) { \ + d_error(_("program not running.")); \ + return FALSE; \ + } \ + } while (FALSE) + + +/* g_readline -- read a line of text; the interface is like 'readline' but + * without any command-line editing; used when not compiled with + * readline support and/or input is not from terminal (prompt set to NULL). + */ + +static char * +g_readline(const char *prompt) +{ + char *line; + size_t line_size = 100; + static char buf[2]; + char *p, *end; + int n; + + if (input_from_tty && prompt && *prompt) + fprintf(out_fp, "%s", prompt); + + emalloc(line, char *, line_size + 1, "g_readline"); + p = line; + end = line + line_size; + while ((n = read(input_fd, buf, 1)) > 0) { + if (buf[0] == '\n') { + if (p > line && p[-1] == '\r') + p--; + break; + } + if (p == end) { + erealloc(line, char *, 2 * line_size + 1, "g_readline"); + p = line + line_size; + line_size *= 2; + end = line + line_size; + } + *p++ = buf[0]; + } + if (n == -1 || (n == 0 && p == line)) { + efree(line); + return NULL; + } + *p = '\0'; + return line; +} + + +/* d_error --- print an error message */ + +void +d_error(const char *mesg, ...) +{ + va_list args; + va_start(args, mesg); + fprintf(out_fp, _("error: ")); + vfprintf(out_fp, mesg, args); + fprintf(out_fp, "\n"); + va_end(args); +} + +/* find_lines --- find the positions of the lines in the source file. */ + +static int +find_lines(SRCFILE *s) +{ + char *buf, *p, *end; + int n; + int ofs = 0; + int *pos; + int pos_size; + int maxlen = 0; + int numlines = 0; + char lastchar = '\0'; + + emalloc(buf, char *, s->bufsize, "find_lines"); + pos_size = s->srclines; + emalloc(s->line_offset, int *, (pos_size + 2) * sizeof(int), "find_lines"); + pos = s->line_offset; + pos[0] = 0; + + while ((n = read(s->fd, buf, s->bufsize)) > 0) { + end = buf + n; + lastchar = buf[n - 1]; + p = buf; + while (p < end) { + if (*p++ == '\n') { + if (++numlines > pos_size) { + erealloc(s->line_offset, int *, (2 * pos_size + 2) * sizeof(int), "find_lines"); + pos = s->line_offset + pos_size; + pos_size *= 2; + } + *++pos = ofs + (p - buf); + if ((pos[0] - pos[-1]) > maxlen) + maxlen = pos[0] - pos[-1]; /* length including NEWLINE */ + } + } + ofs += n; + } + efree(buf); + + if (n == -1) { + d_error(_("can't read source file `%s' (%s)"), + s->src, strerror(errno)); + return -1; + } + if (ofs <= 0) { + fprintf(out_fp, _("source file `%s' is empty.\n"), s->src); + return -1; + } + + if (lastchar != '\n') { + /* fake a NEWLINE at end */ + *++pos = ofs + 1; + numlines++; + if ((pos[0] - pos[-1]) > maxlen) + maxlen = pos[0] - pos[-1]; + } + s->maxlen = maxlen; + s->srclines = numlines; + return 0; +} + +/* source_find --- return the SRCFILE struct for the source 'src' */ + +static SRCFILE * +source_find(char *src) +{ + SRCFILE *s; + struct stat sbuf; + char *path; + int errno_val = 0; + + if (src == NULL || *src == '\0') { + d_error(_("no current source file.")); + return NULL; + } + + if (cur_srcfile->src == src) /* strcmp(cur_srcfile->src, src) == 0 */ + return cur_srcfile; + + for (s = srcfiles->next; s != srcfiles; s = s->next) { + if ((s->stype == SRC_FILE || s->stype == SRC_INC) + && strcmp(s->src, src) == 0) + return s; + } + + path = find_source(src, &sbuf, &errno_val); + if (path != NULL) { + for (s = srcfiles->next; s != srcfiles; s = s->next) { + if ((s->stype == SRC_FILE || s->stype == SRC_INC) + && files_are_same(path, s)) { + efree(path); + return s; + } + } + efree(path); + } + + d_error(_("cannot find source file named `%s' (%s)"), src, strerror(errno_val)); + return NULL; +} + +/* print_lines --- print source lines, and update 'cur_srcfile' */ + +static int +print_lines(char *src, int start_line, int nlines) +{ + SRCFILE *s; + int *pos; + int i; + struct stat sbuf; + + s = source_find(src); + if (s == NULL) + return -1; + if (s->fd <= INVALID_HANDLE && (s->fd = srcopen(s)) <= INVALID_HANDLE) { + d_error(_("can't open source file `%s' for reading (%s)"), + src, strerror(errno)); + return -1; + } + + if (fstat(s->fd, &sbuf) == 0 && s->mtime < sbuf.st_mtime) { + fprintf(out_fp, _("WARNING: source file `%s' modified since program compilation.\n"), + src); + efree(s->line_offset); + s->line_offset = NULL; + s->mtime = sbuf.st_mtime; + + /* reopen source file */ + close(s->fd); + s->fd = INVALID_HANDLE; + if ((s->fd = srcopen(s)) <= INVALID_HANDLE) { + d_error(_("can't open source file `%s' for reading (%s)"), + src, strerror(errno)); + return -1; + } + } + + if (s->line_offset == NULL && find_lines(s) != 0) + return -1; + if (start_line < 1 || start_line > s->srclines) { + d_error(_("line number %d out of range; `%s' has %d lines"), + start_line, src, s->srclines); + return -1; + } + + assert(nlines > 0); + if ((start_line + nlines - 1) > s->srclines) + nlines = s->srclines - start_line + 1; + + pos = s->line_offset; + if (lseek(s->fd, (off_t) pos[start_line - 1], SEEK_SET) < 0) { + d_error("%s: %s", src, strerror(errno)); + return -1; + } + + if (linebuf == NULL) { + emalloc(linebuf, char *, s->maxlen + 20, "print_lines"); /* 19 for line # */ + linebuf_len = s->maxlen; + } else if (linebuf_len < s->maxlen) { + erealloc(linebuf, char *, s->maxlen + 20, "print_lines"); + linebuf_len = s->maxlen; + } + + for (i = start_line; i < start_line + nlines; i++) { + int supposed_len, len; + char *p; + + sprintf(linebuf, "%-8d", i); + + /* mark the line about to be executed with =>; nlines > 1 + * condition makes sure that we are in list command + */ + if (nlines > 1) { + BREAKPOINT *b; + int has_bpt = FALSE; + for (b = breakpoints.prev; b != &breakpoints; b = b->prev) { + if (src == b->src && i == b->bpi->source_line) { + has_bpt = TRUE; + break; + } + } + if (prog_running && src == source && i == sourceline) { + if (has_bpt) + sprintf(linebuf, "%-4d:b=>", i); + else + sprintf(linebuf, "%-4d =>", i); + } else if (has_bpt) + sprintf(linebuf, "%-4d:b ", i); + } + + p = linebuf + strlen(linebuf); + supposed_len = pos[i] - pos[i - 1]; + len = read(s->fd, p, supposed_len); + switch (len) { + case -1: + d_error(_("can't read source file `%s' (%s)"), + src, strerror(errno)); + return -1; + + case 0: + d_error(_("unexpected eof while reading file `%s', line %d"), + src, i); + return -1; + + default: + if (i == s->srclines && p[len - 1] != '\n') + p[len++] = '\n'; +#if 0 + if (len != supposed_len || p[len - 1] != '\n') { + d_error(_("source file `%s' modified since start of program execution"), + src); + return -1; + } +#endif + len += (p - linebuf); + if (fwrite(linebuf, sizeof(char), len, out_fp) != len) + return -1; + } + } + + if (cur_srcfile != s) { + if (cur_srcfile->fd != INVALID_HANDLE) { + close(cur_srcfile->fd); + cur_srcfile->fd = INVALID_HANDLE; + } + cur_srcfile = s; + } + return (i - 1); /* no of lines printed */ +} + +/* do_list --- list command */ + +int +do_list(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + long line_first, line_last; + long count = list_size; + INSTRUCTION *rp; + char *src = cur_srcfile->src; + + line_first = last_printed_line + 1; /* default or no arg */ + if (arg == NULL) /* list or list + */ + goto list; + + switch (arg->type) { + case D_int: /* list n or list - */ + if (arg->a_int < 0) { /* list - */ + line_first = last_printed_line - last_print_count - list_size + 1; + if (line_first < 1) { + if (last_printed_line != last_print_count) + line_first = 1; + else + return FALSE; + } + } else { +line: + line_first = arg->a_int - list_size / 2; + if (line_first < 1) + line_first = 1; + } + break; + + case D_range: /* list m-n */ +range: + line_first = arg->a_int; + arg = arg->next; + assert(arg != NULL); + assert(arg->type == D_int); + count = arg->a_int - line_first + 1; + break; + + case D_string: + src = arg->a_string; + if (arg->next != NULL) { + arg = arg->next; + if (arg->type == D_int) /* list file:n */ + goto line; + else if (arg->type == D_range) /* list file:m-n */ + goto range; + else if (arg->type == D_func) /* list file:function */ + goto func; + else + line_first = 1; + } else + line_first = 1; + break; + + case D_func: /* list function */ +func: + rp = arg->a_node->code_ptr; + src = rp->source_file; + line_first = rp->source_line - list_size / 2; + if (line_first < 1) + line_first = 1; + break; + + default: + break; + } + +list: + line_last = print_lines(src, line_first, count); + if (line_last != -1) { + last_printed_line = line_last; + last_print_count = line_last - line_first + 1; + } + return FALSE; +} + +/* do_info --- info command */ + +int +do_info(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + if (arg == NULL || arg->type != D_argument) + return FALSE; + + switch (arg->a_argument) { + case A_SOURCE: + fprintf(out_fp, _("Current source file: %s\n"), cur_srcfile->src); + fprintf(out_fp, _("Number of lines: %d\n"), cur_srcfile->srclines); + break; + + case A_SOURCES: + { + SRCFILE *s; + for (s = srcfiles->next; s != srcfiles; s = s->next) { + fprintf(out_fp, _("Source file (lines): %s (%d)\n"), + (s->stype == SRC_FILE || s->stype == SRC_INC) ? s->src + : "cmd. line", + s->srclines); + } + } + break; + + case A_BREAK: + initialize_pager(out_fp); + if (setjmp(pager_quit_tag) == 0) { + BREAKPOINT *b; + struct commands_item *c; + + gprintf(out_fp, _("Number Disp Enabled Location\n\n")); + for (b = breakpoints.prev; b != &breakpoints; b = b->prev) { + char *disp = "keep"; + if (b->flags & BP_ENABLE_ONCE) + disp = "dis"; + else if(b->flags & BP_TEMP) + disp = "del"; + gprintf(out_fp, "%-6d %-4.4s %-7.7s file %s, line #%d\n", + b->number, disp, (b->flags & BP_ENABLE) ? "yes" : "no", + b->src, b->bpi->source_line); + if (b->hit_count > 0) + gprintf(out_fp, _("\tno of hits = %ld\n"), b->hit_count); + if (b->flags & BP_IGNORE) + gprintf(out_fp, _("\tignore next %ld hit(s)\n"), b->ignore_count); + if (b->cndn.code != NULL) + gprintf(out_fp, _("\tstop condition: %s\n"), b->cndn.expr); + if (b->commands.next != &b->commands) + gprintf(out_fp, _("\tcommands:\n")); + for (c = b->commands.next; c != &b->commands; c = c->next) { + gprintf(out_fp, "\t%s\n", c->cmd_string); + if (c->cmd == D_eval) { + char *start, *end; + CMDARG *a = c->arg; + start = strchr(a->a_string, '{'); + end = strrchr(a->a_string, '}'); + if (start == NULL || end == NULL) + continue; + start++; + *end = '\0'; + gprintf(out_fp, "%s", start); /* FIXME: translate ? */ + *end = '}'; + } + } + } + } + break; + + case A_FRAME: + CHECK_PROG_RUNNING(); + fprintf(out_fp, _("Current frame: ")); + print_numbered_frame(cur_frame); + if (cur_frame < fcall_count) { + fprintf(out_fp, _("Called by frame: ")); + print_numbered_frame(cur_frame + 1); + } + if (cur_frame > 0) { + fprintf(out_fp, _("Caller of frame: ")); + print_numbered_frame(cur_frame - 1); + } + break; + + case A_ARGS: + case A_LOCALS: + { + NODE *f, *func; + INSTRUCTION *pc; + int arg_count, pcount; + int i, from, to; + char **pnames; + + CHECK_PROG_RUNNING(); + f = find_frame(cur_frame); + func = f->func_node; + if (func == NULL) { + /* print ARGV ? */ + fprintf(out_fp, _("None in main().\n")); + return FALSE; + } + + pcount = get_param_count(func); /* # of defined params */ + pnames = get_params(func); /* param names */ + + pc = (INSTRUCTION *) f->reti; /* Op_func_call instruction */ + arg_count = (pc + 1)->expr_count; /* # of arguments supplied */ + + if (arg_count > pcount) /* extra args */ + arg_count = pcount; + if (arg->a_argument == A_ARGS) { + from = 0; + to = arg_count - 1; + } else { + from = arg_count; + to = pcount - 1; + } + + for (i = from; i <= to; i++) { + NODE *r; + r = f->stack[i]; + if (r->type == Node_array_ref) + r = r->orig_array; + fprintf(out_fp, "%s = ", pnames[i]); + print_symbol(r, TRUE); + } + if (to < from) + fprintf(out_fp, "%s", + arg->a_argument == A_ARGS ? + _("No arguments.\n") : + _("No locals.\n")); + } + break; + + case A_VARIABLES: + initialize_pager(out_fp); + if (setjmp(pager_quit_tag) == 0) { + gprintf(out_fp, _("All defined variables:\n\n")); + print_vars(gprintf, out_fp); + } + break; + + case A_FUNCTIONS: + initialize_pager(out_fp); + if (setjmp(pager_quit_tag) == 0) { + gprintf(out_fp, _("All defined functions:\n\n")); + pf_data.print_func = gprintf; + pf_data.fp = out_fp; + pf_data.defn = TRUE; + (void) foreach_func((int (*)(INSTRUCTION *, void *)) print_function, + FALSE, /* sort */ + &pf_data /* data */ + ); + } + break; + + case A_DISPLAY: + case A_WATCH: + initialize_pager(out_fp); + if (setjmp(pager_quit_tag) == 0) { + struct list_item *d, *list; + + if (arg->a_argument == A_DISPLAY) { + list = &display_list; + gprintf(out_fp, _("Auto-display variables:\n\n")); + } else { + list = &watch_list; + gprintf(out_fp, _("Watch variables:\n\n")); + } + for (d = list->prev; d != list; d = d->prev) { + int i; + struct commands_item *c; + NODE *symbol = d->symbol; + + if (IS_SUBSCRIPT(d)) { + gprintf(out_fp, "%d:\t%s", d->number, d->sname); + for (i = 0; i < d->num_subs; i++) { + NODE *sub; + sub = d->subs[i]; + gprintf(out_fp, "[\"%s\"]", sub->stptr); + } + gprintf(out_fp, "\n"); + } else if (IS_FIELD(d)) + gprintf(out_fp, "%d:\t$%ld\n", d->number, (long) symbol->numbr); + else + gprintf(out_fp, "%d:\t%s\n", d->number, d->sname); + if (d->cndn.code != NULL) + gprintf(out_fp, _("\tstop condition: %s\n"), d->cndn.expr); + if (d->commands.next != &d->commands) + gprintf(out_fp, _("\tcommands:\n")); + for (c = d->commands.next; c != &d->commands; c = c->next) { + gprintf(out_fp, "\t%s\n", c->cmd_string); + if (c->cmd == D_eval) { + char *start, *end; + CMDARG *a = c->arg; + start = strchr(a->a_string, '{'); + end = strrchr(a->a_string, '}'); + if (start == NULL || end == NULL) + continue; + start++; + *end = '\0'; + gprintf(out_fp, "%s", start); /* FIXME: translate ? */ + *end = '}'; + } + } + + } + } + break; + + default: + break; + } + + return FALSE; +} + +/* print_symbol --- print a symbol table entry */ + +static void +print_symbol(NODE *r, int isparam) +{ + switch (r->type) { + case Node_var_new: + fprintf(out_fp, "untyped variable\n"); + break; + case Node_var: + if (! isparam && r->var_update) + r->var_update(); + valinfo(r->var_value, fprintf, out_fp); + break; + case Node_var_array: + fprintf(out_fp, "array, %ld elements\n", r->table_size); + break; + case Node_func: + fprintf(out_fp, "`function'\n"); + break; + default: + break; + } +} + +/* find_frame --- find frame given a frame number */ + +static NODE * +find_frame(long num) +{ + assert(num >= 0); + if (num == 0) + return frame_ptr; + + assert(prog_running == TRUE); + assert(num <= fcall_count); + assert(fcall_list[num] != NULL); + return fcall_list[num]; +} + +/* find_param --- find a function parameter in a given frame number */ + +static NODE * +find_param(const char *name, long num, char **pname) +{ + NODE *r = NULL; + NODE *f; + + if (pname) + *pname = NULL; + + if (num < 0 || num > fcall_count || name == NULL) + return NULL; + f = find_frame(num); + if (f->func_node != NULL) { /* in function */ + NODE *func; + char **pnames; + int i, pcount; + + func = f->func_node; + pnames = get_params(func); + pcount = get_param_count(func); + + for (i = 0; i < pcount; i++) { + if (strcmp(name, pnames[i]) == 0) { + r = f->stack[i]; + if (r->type == Node_array_ref) + r = r->orig_array; + if (pname) + *pname = pnames[i]; + break; + } + } + } + return r; +} + +/* find_symbol --- find a symbol in current context */ + +static +NODE *find_symbol(const char *name, char **pname) +{ + NODE *r = NULL; + + if (pname) + *pname = NULL; + if (prog_running) + r = find_param(name, cur_frame, pname); + if (r == NULL) + r = lookup(name); + if (r == NULL) + fprintf(out_fp, _("no symbol `%s' in current context\n"), name); + return r; +} + +/* find_array -- find an array in current context */ + +static NODE * +find_array(const char *name) +{ + NODE *r; + r = find_symbol(name, NULL); + if (r != NULL && r->type != Node_var_array) { + fprintf(out_fp, _("`%s' is not an array\n"), name); + return NULL; + } + return r; +} + +/* print_field --- print the value of $n */ + +static void +print_field(long field_num) +{ + NODE **lhs; + lhs = get_field(field_num, NULL); + if (*lhs == Null_field || *lhs == Nnull_string) + fprintf(out_fp, _("$%ld = uninitialized field\n"), field_num); + else { + fprintf(out_fp, "$%ld = ", field_num); + valinfo(*lhs, fprintf, out_fp); + } +} + +/* print_array --- print the contents of an array */ + +static int +print_array(volatile NODE *arr, char *arr_name) +{ + NODE *bucket; + NODE **list; + int i; + size_t num_elems = 0; + volatile NODE *r; + volatile int ret = 0; + volatile jmp_buf pager_quit_tag_stack; + + if (arr->var_array == NULL || arr->table_size == 0) { + gprintf(out_fp, _("array `%s' is empty\n"), arr_name); + return 0; + } + + num_elems = arr->table_size; + + /* sort indices, sub_arrays are also sorted! */ + list = assoc_list((NODE *) arr, "@ind_str_asc", SORTED_IN); + + PUSH_BINDING(pager_quit_tag_stack, pager_quit_tag, pager_quit_tag_valid); + if (setjmp(pager_quit_tag) == 0) { + for (i = 0; ret == 0 && i < num_elems; i++) { + bucket = list[i]; + r = bucket->ahvalue; + if (r->type == Node_var_array) + ret = print_array(r, r->vname); + else { + gprintf(out_fp, "%s[\"%s\"] = ", arr_name, bucket->ahname_str); + valinfo((NODE *) r, gprintf, out_fp); + } + } + } else + ret = 1; + + POP_BINDING(pager_quit_tag_stack, pager_quit_tag, pager_quit_tag_valid); + + for (i = 0; i < num_elems; i++) + unref(list[i]); + efree(list); + + return ret; +} + +/* print_subscript --- print an array element */ + +static void +print_subscript(NODE *arr, char *arr_name, CMDARG *a, int count) +{ + NODE *r, *subs; + + subs = a->a_node; + r = in_array(arr, subs); + if (r == NULL) + fprintf(out_fp, _("[\"%s\"] not in array `%s'\n"), subs->stptr, arr_name); + else if (r->type == Node_var_array) { + if (count > 1) + print_subscript(r, r->vname, a->next, count - 1); + else { + /* print # of elements in array */ + fprintf(out_fp, "%s = ", r->vname); + print_symbol(r, FALSE); + } + } else { + fprintf(out_fp, "%s[\"%s\"] = ", arr_name, subs->stptr); + valinfo(r, fprintf, out_fp); + } +} + +/* do_print_var --- print command */ + +int +do_print_var(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + NODE *r; + CMDARG *a; + char *name, *pname; + + for (a = arg; a != NULL; a = a->next) { + switch (a->type) { + case D_variable: + name = a->a_string; + if ((r = find_symbol(name, &pname)) != NULL) { + fprintf(out_fp, "%s = ", name); + print_symbol(r, (pname != NULL)); + } + break; + + case D_subscript: + assert(a->a_count > 0); + name = a->a_string; + r = find_array(name); + if (r != NULL) + print_subscript(r, name, a->next, a->a_count); + break; + + case D_array: + name = a->a_string; + if ((r = find_array(name)) != NULL) { + int count = a->a_count; + for (; count > 0; count--) { + NODE *value, *subs; + a = a->next; + subs = a->a_node; + value = in_array(r, subs); + if (value == NULL) { + fprintf(out_fp, _("[\"%s\"] not in array `%s'\n"), + subs->stptr, name); + break; + } else if (value->type != Node_var_array) { + fprintf(out_fp, _("`%s[\"%s\"]' is not an array\n"), + name, subs->stptr); + break; + } else { + r = value; + name = r->vname; + } + } + if (count == 0) { + initialize_pager(out_fp); + print_array((volatile NODE *) r, name); + } + } + break; + + case D_field: + print_field(a->a_node->numbr); + break; + + default: + /* notably D_node, subscript for invalid array name; skip */ + break; + } + } + return FALSE; +} + +/* do_set_var --- set command */ + +int +do_set_var(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + NODE *r, *val; + NODE **lhs; + char *name, *pname; + + switch (arg->type) { + case D_variable: + name = arg->a_string; + arg = arg->next; + val = arg->a_node; + + if ((r = find_symbol(name, &pname)) == NULL) + break; + + switch (r->type) { + case Node_var_new: + r->type = Node_var; + r->var_value = Nnull_string; + /* fall through */ + case Node_var: + lhs = &r->var_value; + unref(*lhs); + *lhs = dupnode(val); + if (pname == NULL && r->var_assign != NULL) + r->var_assign(); + fprintf(out_fp, "%s = ", name); + print_symbol(r, (pname != NULL)); + break; + + default: + d_error(_("`%s' is not a scalar variable"), name); + break; + } + break; + + case D_subscript: + { + NODE *subs, *value; + int count = arg->a_count; + + assert(count > 0); + name = arg->a_string; + r = find_array(name); + if (r == NULL) + break; + for (; count > 0; count--) { + arg = arg->next; + subs = arg->a_node; + value = in_array(r, subs); + + if (count == 1) { + if (value != NULL && value->type == Node_var_array) + d_error(_("attempt to use array `%s[\"%s\"]' in a scalar context"), + name, subs->stptr); + else { + arg = arg->next; + val = arg->a_node; + lhs = assoc_lookup(r, subs, FALSE); + unref(*lhs); + *lhs = dupnode(val); + fprintf(out_fp, "%s[\"%s\"] = ", name, subs->stptr); + valinfo(*lhs, fprintf, out_fp); + } + } else { + if (value == NULL) { + NODE *array; + + getnode(array); + array->type = Node_var_array; + array->var_array = NULL; + array->vname = estrdup(subs->stptr, subs->stlen); + *assoc_lookup(r, subs, FALSE) = array; + r = array; + } else if (value->type != Node_var_array) { + d_error(_("attempt to use scalar `%s[\"%s\"]' as array"), + name, subs->stptr); + break; + } else { + r = value; + name = r->vname; + } + } + } + } + break; + + case D_field: + { + long field_num; + Func_ptr assign = NULL; + + field_num = (long) arg->a_node->numbr; + assert(field_num >= 0); + arg = arg->next; + val = arg->a_node; + lhs = get_field(field_num, &assign); + unref(*lhs); + *lhs = dupnode(val); + if (assign) + assign(); + print_field(field_num); + } + break; + + default: + break; + } + return FALSE; +} + +/* find_item --- find an item in the watch/display list */ + +static struct list_item * +find_item(struct list_item *list, long num) +{ + struct list_item *d; + + if (num <= 0) + return NULL; + for (d = list->next; d != list; d = d->next) { + if (d->number == num) + return d; + } + return NULL; +} + +/* delete_item --- delete an item from the watch/display list */ + +static void +delete_item(struct list_item *d) +{ + struct commands_item *c; + int i; + + if (IS_SUBSCRIPT(d)) { + for (i = 0; i < d->num_subs; i++) + unref(d->subs[i]); + efree(d->subs); + } else if (IS_FIELD(d)) + unref(d->symbol); + + if ((d->flags & CUR_IS_ARRAY) == 0) + unref(d->cur_value); + if ((d->flags & OLD_IS_ARRAY) == 0) + unref(d->old_value); + + /* delete commands */ + for (c = d->commands.next; c != &d->commands; c = c->next) { + c = c->prev; + delete_commands_item(c->next); + } + + free_context(d->cndn.ctxt, FALSE); + if (d->cndn.expr != NULL) + efree(d->cndn.expr); + + d->next->prev = d->prev; + d->prev->next = d->next; + efree(d); +} + +/* add_item --- craete a watch/display item and add it to the list */ + +static struct list_item * +add_item(struct list_item *list, int type, NODE *symbol, char *pname) +{ + struct list_item *d; + + emalloc(d, struct list_item *, sizeof(struct list_item), "add_item"); + memset(d, 0, sizeof(struct list_item)); + d->commands.next = d->commands.prev = &d->commands; + + d->number = ++list->number; + d->sname = symbol->vname; + if (pname != NULL) { /* function param */ + d->sname = pname; + d->flags |= PARAM; + d->fcall_count = fcall_count - cur_frame; + } + + if (type == D_field) { /* field number */ + d->symbol = symbol; + d->flags |= FIELD_NUM; + } else if (type == D_subscript) { /* subscript */ + d->symbol = symbol; + d->flags |= SUBSCRIPT; + } else /* array or variable */ + d->symbol = symbol; + + /* add to list */ + d->next = list->next; + d->prev = list; + list->next = d; + d->next->prev = d; + return d; +} + +/* do_add_item --- add an item to the watch/display list */ + +static struct list_item * +do_add_item(struct list_item *list, CMDARG *arg) +{ + NODE *symbol = NULL; + char *name, *pname = NULL; + struct list_item *item = NULL; + + switch (arg->type) { + case D_subscript: + case D_variable: + name = arg->a_string; + if ((symbol = find_symbol(name, &pname)) == NULL) + return NULL; + if (symbol->type == Node_func) { + d_error(_("`%s' is a function"), name); + return NULL; + } + if (arg->type == D_subscript && symbol->type != Node_var_array) { + d_error(_("`%s' is not an array\n"), name); + return NULL; + } + + item = add_item(list, arg->type, symbol, pname); + if (item != NULL && arg->type == D_subscript) { + NODE **subs; + int count = arg->a_count; + int i; + + assert(count > 0); + emalloc(subs, NODE **, count * sizeof(NODE *), "do_add_item"); + for (i = 0; i < count; i++) { + arg = arg->next; + subs[i] = dupnode(arg->a_node); + (void) force_string(subs[i]); + } + item->subs = subs; + item->num_subs = count; + } + break; + + case D_field: + symbol = dupnode(arg->a_node); + item = add_item(list, D_field, symbol, NULL); + break; + + default: + break; + } + + /* watch condition if any */ + if (list == &watch_list) { + arg = arg->next; + if (item != NULL && arg != NULL) { + if (parse_condition(D_watch, item->number, arg->a_string) == 0) + arg->a_string = NULL; /* don't let free_cmdarg free it */ + else + fprintf(out_fp, _("watchpoint %d is unconditional\n"), item->number); + } + } + return item; +} + +/* do_delete_item --- delete a watch/display item from list. */ + +static void +do_delete_item(struct list_item *list, CMDARG *arg) +{ + if (arg == NULL) { + while (list->next != list) + delete_item(list->next); + } + + for (; arg != NULL; arg = arg->next) { + struct list_item *d; + if (arg->type == D_range) { + long i, j; + + i = arg->a_int; + arg = arg->next; + j = arg->a_int; + if (j > list->number) + j = list->number; + for (; i <= j; i++) { + if ((d = find_item(list, i)) != NULL) + delete_item(d); + } + } else { + if ((d = find_item(list, arg->a_int)) == NULL) { + /* split into two for easier message translation */ + if (list == &display_list) + d_error(_("No display item numbered %ld"), + arg->a_int); + else + d_error(_("No watch item numbered %ld"), + arg->a_int); + } else + delete_item(d); + } + } +} + +/* display --- print an item from the auto-display list */ + +static void +display(struct list_item *d) +{ + NODE *symbol; + + symbol = d->symbol; + if (IS_PARAM(d) && (d->fcall_count != (fcall_count - cur_frame))) + return; + + if (IS_SUBSCRIPT(d)) { + NODE *sub, *r; + int i = 0, count = d->num_subs; + for (i = 0; i < count; i++) { + sub = d->subs[i]; + r = in_array(symbol, sub); + if (r == NULL) { + fprintf(out_fp, _("%d: [\"%s\"] not in array `%s'\n"), + d->number, sub->stptr, d->sname); + break; + } + if (r->type == Node_var_array) { + symbol = r; + if (i == count - 1) /* it's a sub-array */ + goto print_sym; /* print # of elements in sub-array */ + } else { + if (i != count - 1) + return; /* FIXME msg and delete item ? */ + fprintf(out_fp, "%d: %s[\"%s\"] = ", d->number, + d->sname, sub->stptr); + valinfo(r, fprintf, out_fp); + } + } + } else if (IS_FIELD(d)) { + NODE *r = d->symbol; + fprintf(out_fp, "%d: ", d->number); + print_field(r->numbr); + } else { +print_sym: + fprintf(out_fp, "%d: %s = ", d->number, d->sname); + print_symbol(symbol, IS_PARAM(d)); + } +} + + +/* do_display --- display command */ + +int +do_display(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + struct list_item *d; + + if (arg == NULL) { + /* display all items */ + for (d = display_list.prev; d != &display_list; d = d->prev) + display(d); + return FALSE; + } + + if ((d = do_add_item(&display_list, arg)) != NULL) + display(d); + + return FALSE; +} + +/* do_undisplay --- undisplay command */ + +int +do_undisplay(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + do_delete_item(&display_list, arg); + return FALSE; +} + +/* condition_triggered --- test if a condition expression is true */ + +static int +condition_triggered(struct condition *cndn) +{ + NODE *r; + int di; + + assert(cndn != NULL); + if (cndn->code == NULL) + return TRUE; + + push_context(cndn->ctxt); + r = execute_code((volatile INSTRUCTION *) cndn->code); + pop_context(); /* switch to prev context */ + if (r == NULL) /* fatal error */ + return FALSE; /* not triggered */ + + force_number(r); + di = (r->numbr != 0.0); + DEREF(r); + return di; +} + + + +static int +find_subscript(struct list_item *item, NODE **ptr) +{ + NODE *symbol = item->symbol; + NODE *sub, *r; + int i = 0, count = item->num_subs; + + r = *ptr = NULL; + for (i = 0; i < count; i++) { + sub = item->subs[i]; + r = in_array(symbol, sub); + if (r == NULL) + return 0; + if (r->type == Node_var_array) + symbol = r; + else if (i < count - 1) + return -1; + } + *ptr = r; + return 0; +} + +/* cmp_val --- compare values of watched item, returns TRUE if different; */ + +static int +cmp_val(struct list_item *w, NODE *old, NODE *new) +{ + /* + * case old new result + * ------------------------------ + * 1: NULL ARRAY TRUE + * 2: NULL SCALAR TRUE + * 3: NULL NULL FALSE + * 4: SCALAR SCALAR cmp_node + * 5: SCALAR ARRAY TRUE + * 6: SCALAR NULL TRUE + * 7: ARRAY SCALAR TRUE + * 8: ARRAY ARRAY compare size + * 9: ARRAY NULL TRUE + */ + + if (WATCHING_ARRAY(w)) { + long size = 0; + if (! new) /* 9 */ + return TRUE; + if (new->type == Node_val) /* 7 */ + return TRUE; + /* new->type == Node_var_array */ /* 8 */ + if (new->var_array != NULL) + size = new->table_size; + if (w->cur_size == size) + return FALSE; + return TRUE; + } + + if (! old && ! new) /* 3 */ + return FALSE; + if ((! old && new) /* 1, 2 */ + || (old && ! new)) /* 6 */ + return TRUE; + + if (new->type == Node_var_array) /* 5 */ + return TRUE; + return cmp_nodes(old, new); /* 4 */ +} + +/* watchpoint_triggered --- check if we should stop at this watchpoint; + * update old and current values accordingly. + */ + +static int +watchpoint_triggered(struct list_item *w) +{ + NODE *symbol; + NODE *t1, *t2; + + symbol = w->symbol; + if (IS_PARAM(w) && (w->fcall_count != (fcall_count - cur_frame))) + return 0; /* parameter with same name in a different function */ + if (! condition_triggered(&w->cndn)) + return 0; + + t1 = w->cur_value; + t2 = (NODE *) 0; + if (IS_SUBSCRIPT(w)) + (void) find_subscript(w, &t2); + else if (IS_FIELD(w)) { + long field_num; + field_num = (long) w->symbol->numbr; + t2 = *get_field(field_num, NULL); + } else { + switch (symbol->type) { + case Node_var: + t2 = symbol->var_value; + break; + case Node_var_array: + t2 = symbol; + break; + case Node_var_new: + break; + default: + cant_happen(); + } + } + + if (! cmp_val(w, t1, t2)) + return 0; + + /* update old and current values */ + + if ((w->flags & OLD_IS_ARRAY) == 0) + unref(w->old_value); + w->flags &= ~OLD_IS_ARRAY; + if (WATCHING_ARRAY(w)) { /* 7, 8, 9 */ + w->old_size = w->cur_size; + w->flags |= OLD_IS_ARRAY; + if (! t2) { + w->flags &= ~CUR_IS_ARRAY; + w->cur_value = 0; + } else if (t2->type == Node_val) { + w->flags &= ~CUR_IS_ARRAY; + w->cur_value = dupnode(t2); + } else + w->cur_size = (t2->var_array != NULL) ? t2->table_size : 0; + } else if (! t1) { /* 1, 2 */ + w->old_value = 0; + /* new != NULL */ + if (t2->type == Node_val) + w->cur_value = dupnode(t2); + else { + w->flags |= CUR_IS_ARRAY; + w->cur_size = (t2->var_array != NULL) ? t2->table_size : 0; + } + } else /* if (t1->type == Node_val) */ { /* 4, 5, 6 */ + w->old_value = w->cur_value; + if (! t2) + w->cur_value = 0; + else if (t2->type == Node_var_array) { + w->flags |= CUR_IS_ARRAY; + w->cur_size = (t2->var_array != NULL) ? t2->table_size : 0; + } else + w->cur_value = dupnode(t2); + } + + return w->number; +} + +/* initialize_watch_item --- initialize current value of a watched item */ + +static int +initialize_watch_item(struct list_item *w) +{ + NODE *t, *r; + NODE *symbol = w->symbol; + + if (IS_SUBSCRIPT(w)) { + if (find_subscript(w, &r) == -1) { + d_error(_("attempt to use scalar value as array")); + return -1; + } + + if (r == NULL) + w->cur_value = (NODE *) 0; + else if (r->type == Node_var_array) { /* it's a sub-array */ + w->flags |= CUR_IS_ARRAY; + w->cur_size = (r->var_array != NULL) ? r->table_size : 0; + } else + w->cur_value = dupnode(r); + } else if (IS_FIELD(w)) { + long field_num; + t = w->symbol; + field_num = (long) t->numbr; + r = *get_field(field_num, NULL); + w->cur_value = dupnode(r); + } else { + if (symbol->type == Node_var_new) + w->cur_value = (NODE *) 0; + else if (symbol->type == Node_var) { + r = symbol->var_value; + w->cur_value = dupnode(r); + } else if (symbol->type == Node_var_array) { + w->flags |= CUR_IS_ARRAY; + w->cur_size = (symbol->var_array != NULL) ? symbol->table_size : 0; + } /* else + can't happen */ + } + return 0; +} + +/* do_watch --- watch command */ + +int +do_watch(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + struct list_item *w; + NODE *symbol, *sub; + int i; + + w = do_add_item(&watch_list, arg); + if (w == NULL) + return FALSE; + + if (initialize_watch_item(w) == -1) { + delete_item(w); + return FALSE; + } + + fprintf(out_fp, "Watchpoint %d: ", w->number); + symbol = w->symbol; + +/* FIXME: common code also in print_watch_item */ + if (IS_SUBSCRIPT(w)) { + fprintf(out_fp, "%s", w->sname); + for (i = 0; i < w->num_subs; i++) { + sub = w->subs[i]; + fprintf(out_fp, "[\"%s\"]", sub->stptr); + } + fprintf(out_fp, "\n"); + } else if (IS_FIELD(w)) + fprintf(out_fp, "$%ld\n", (long) symbol->numbr); + else + fprintf(out_fp, "%s\n", w->sname); + + return FALSE; +} + +/* do_unwatch --- unwatch command */ + +int +do_unwatch(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + do_delete_item(&watch_list, arg); + return FALSE; +} + +/* callback from pop_frame in eval.c */ + +void +frame_popped() +{ + struct list_item *item; + + /* delete all out of scope watchpoints */ + for (item = watch_list.next; item != &watch_list; item = item->next) { + if (IS_PARAM(item) && (item->fcall_count > fcall_count)) { + fprintf(out_fp, + _("Watchpoint %d deleted because parameter is out of scope.\n"), + item->number); + item = item->prev; + delete_item(item->next); + } + } + + /* delete all out of scope display items */ + for (item = display_list.next; item != &display_list; item = item->next) { + if (IS_PARAM(item) && (item->fcall_count > fcall_count)) { + fprintf(out_fp, + _("Display %d deleted because parameter is out of scope.\n"), + item->number); + item = item->prev; + delete_item(item->next); + } + } +} + +/* print_function --- print function name, parameters, and optionally + * file and line number. + */ + +static int +print_function(INSTRUCTION *pc, void *x) +{ + NODE *func; + int i, pcount; + char **pnames; + struct pf_data *data = (struct pf_data *) x; + int defn = data->defn; + Func_print print_func = data->print_func; + FILE *fp = data->fp; + + func = pc->func_body; + pcount = get_param_count(func); + pnames = get_params(func); + + print_func(fp, "%s(", func->lnode->param); + for (i = 0; i < pcount; i++) { + print_func(fp, "%s", pnames[i]); + if (i < pcount - 1) + print_func(fp, ", "); + } + print_func(fp, ")"); + if (defn) + print_func(fp, _(" in file `%s', line %d\n"), + pc->source_file, pc->source_line); + return 0; +} + +/* print_frame --- print function name, parameters, + * source and line number of where it is + * executing. + */ + +static void +print_frame(NODE *func, char *src, int srcline) +{ + if (func == NULL) + fprintf(out_fp, "main()"); + else { + pf_data.print_func = fprintf; + pf_data.fp = out_fp; + pf_data.defn = FALSE; + (void) print_function(func->code_ptr, &pf_data); + } + fprintf(out_fp, _(" at `%s':%d"), src, srcline); +} + +/* print_numbered_frame --- print a frame given its number */ + +static void +print_numbered_frame(long num) +{ + NODE *f; + + assert(prog_running == TRUE); + f = find_frame(num); + if (num == 0) { + fprintf(out_fp, "#%ld\t ", num); + print_frame(f->func_node, source, sourceline); + } else { + fprintf(out_fp, _("#%ld\tin "), num); + print_frame(f->func_node, f->vname, + ((INSTRUCTION *) find_frame(num - 1)->reti)->source_line); + } + fprintf(out_fp, "\n"); +} + +/* do_backtrace --- backtrace command */ + +int +do_backtrace(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + long cur = 0; + long last = fcall_count; + + CHECK_PROG_RUNNING(); + if (arg != NULL && arg->type == D_int) { + long count = arg->a_int; + + /* frame_ptr (frame #0), fcall_list[1, 2, ... fcall_count] => total count */ + if (count >= 0) { + /* toward outermost frame #fcall_count */ + last = count - 1; + if (last > fcall_count) + last = fcall_count; + } else { + /* toward innermost frame #0 */ + cur = 1 + fcall_count + count; + if (cur < 0) + cur = 0; + } + } + + for (; cur <= last; cur++) { + print_numbered_frame(cur); + } + if (cur <= fcall_count) + fprintf(out_fp, _("More stack frames follow ...\n")); + return FALSE; +} + +/* print_cur_frame_and_sourceline --- print current frame, and + * current source line. + */ + +static void +print_cur_frame_and_sourceline() +{ + NODE *f; + int srcline; + char *src; + + assert(prog_running == TRUE); + f = find_frame(cur_frame); + if (cur_frame == 0) { + src = source; + srcline = sourceline; + } else { + f = find_frame(cur_frame); + src = f->vname; + srcline = ((INSTRUCTION *) find_frame(cur_frame - 1)->reti)->source_line; + } + + fprintf(out_fp, (cur_frame > 0 ? _("#%ld\tin ") : "#%ld\t "), cur_frame); + print_frame(f->func_node, src, srcline); + fprintf(out_fp, "\n"); + print_lines(src, srcline, 1); + last_printed_line = srcline - list_size / 2; + if (last_printed_line < 0) + last_printed_line = 0; +} + +/* do_frame --- frame command */ + +int +do_frame(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + CHECK_PROG_RUNNING(); + if (arg && arg->type == D_int) { + if (arg->a_int < 0 || arg->a_int > fcall_count) { + d_error(_("invalid frame number")); + return FALSE; + } + cur_frame = arg->a_int; + } + print_cur_frame_and_sourceline(); + return FALSE; +} + +/* do_up --- up command */ + +int +do_up(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + CHECK_PROG_RUNNING(); + if (arg != NULL && arg->type == D_int) + cur_frame += arg->a_int; + else + cur_frame++; + if (cur_frame < 0) + cur_frame = 0; + else if (cur_frame > fcall_count) + cur_frame = fcall_count; + print_cur_frame_and_sourceline(); + return FALSE; +} + +/* do_down --- down command */ + +int +do_down(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + CHECK_PROG_RUNNING(); + if (arg != NULL && arg->type == D_int) + cur_frame -= arg->a_int; + else + cur_frame--; + if (cur_frame < 0) + cur_frame = 0; + else if (cur_frame > fcall_count) + cur_frame = fcall_count; + print_cur_frame_and_sourceline(); + return FALSE; +} + +/* find_rule --- find a rule or function in file 'src' containing + * source line 'lineno' + */ + +static INSTRUCTION * +find_rule(char *src, long lineno) +{ + INSTRUCTION *rp; + + assert(lineno > 0); + for (rp = rule_list->nexti; rp != NULL; rp = rp->nexti) { + if ((rp - 1)->source_file == src + && lineno >= (rp + 1)->first_line + && lineno <= (rp + 1)->last_line) + return (rp - 1); + } + return NULL; +} + +/* mk_breakpoint --- create a breakpoint instruction and the corresponding + * breakpoint structure. + */ + +static INSTRUCTION * +mk_breakpoint(char *src, int srcline) +{ + INSTRUCTION *bp; + BREAKPOINT *b; + + bp = bcalloc(Op_breakpoint, 1, srcline); + emalloc(b, BREAKPOINT *, sizeof(BREAKPOINT), "mk_breakpoint"); + memset(&b->cndn, 0, sizeof(struct condition)); + b->commands.next = b->commands.prev = &b->commands; + b->silent = FALSE; + + + b->number = ++watch_list.number; /* breakpoints and watchpoints use same counter */ + b->ignore_count = 0; + b->hit_count = 0; + b->flags = BP_ENABLE; + b->src = src; + bp->break_pt = b; + b->bpi = bp; + + /* prepend to list */ + b->next = breakpoints.next; + b->prev = &breakpoints; + breakpoints.next = b; + b->next->prev = b; + return bp; +} + +/* delete_breakpoint --- delete a breakpoint structure and + * disable the breakpoint instruction. + */ + +static void +delete_breakpoint(BREAKPOINT *b) +{ + INSTRUCTION *pc = b->bpi; + struct commands_item *c; + + /* N.B.: easiest thing to do is to turn Op_breakpoint into a no-op; + * deleteing the instruction is not that simple, + * since could have reference to it somewhere else (e.g. cur_pc). + */ + + pc->opcode = Op_no_op; + pc->source_line = 0; + pc->break_pt = NULL; + + /* delete commands */ + for (c = b->commands.next; c != &b->commands; c = c->next) { + c = c->prev; + delete_commands_item(c->next); + } + + free_context(b->cndn.ctxt, FALSE); + if (b->cndn.expr != NULL) + efree(b->cndn.expr); + + /* remove from list */ + b->next->prev = b->prev; + b->prev->next = b->next; + efree(b); +} + +/* find_breakpoint --- find the breakpoint structure from a breakpoint number */ + +static BREAKPOINT * +find_breakpoint(long num) +{ + BREAKPOINT *b; + + if (num <= 0) + return NULL; + + for (b = breakpoints.next; b != &breakpoints; b = b->next) { + if (b->number == num) + return b; + } + return NULL; +} + +/* add_breakpoint --- add a breakpoint instruction between PREVP and IP */ + +static BREAKPOINT * +add_breakpoint(INSTRUCTION *prevp, INSTRUCTION *ip, char *src, int silent) +{ + BREAKPOINT *b; + INSTRUCTION *bp; + int lineno = ip->source_line; + + /* add new breakpoint instruction at the end of + * already set breakpoints at this line number. + */ + + while (ip->opcode == Op_breakpoint && ip->source_line == lineno) { + if (! silent) { + b = ip->break_pt; + /* + * This is more verbose that it might otherwise be, + * in order to provide easily translatable strings. + */ + if (b->flags & BP_ENABLE) { + if (b->flags & BP_IGNORE) + fprintf(out_fp, + _("Note: breakpoint %d (enabled, ignore next %ld hits), also set at %s:%d"), + b->number, + b->ignore_count, + b->src, + lineno); + else + fprintf(out_fp, + _("Note: breakpoint %d (enabled), also set at %s:%d"), + b->number, + b->src, + lineno); + } else { + if (b->flags & BP_IGNORE) + fprintf(out_fp, + _("Note: breakpoint %d (disabled, ignore next %ld hits), also set at %s:%d"), + b->number, + b->ignore_count, + b->src, + lineno); + else + fprintf(out_fp, + _("Note: breakpoint %d (disabled), also set at %s:%d"), + b->number, + b->src, + lineno); + } + } + prevp = ip; + ip = ip->nexti; + } + + assert(ip->source_line == lineno); + + bp = mk_breakpoint(src, lineno); + prevp->nexti = bp; + bp->nexti = ip; + b = bp->break_pt; + if (! silent) + fprintf(out_fp, _("Breakpoint %d set at file `%s', line %d\n"), + b->number, src, lineno); + return b; +} + +/* set_breakpoint_at --- set a breakpoint at given line number*/ + +static BREAKPOINT * +set_breakpoint_at(INSTRUCTION *rp, int lineno, int silent) +{ + INSTRUCTION *ip, *prevp; + + for (prevp = rp, ip = rp->nexti; ip; prevp = ip, ip = ip->nexti) { + if (ip->opcode == Op_K_case) { + INSTRUCTION *i1, *i2; + + /* Special case: the code line numbers for a switch do not form + * a monotonically increasing sequence. Check if the line # is between + * the first and last statements of the case block before continuing + * the search. + */ + for (i2 = ip->stmt_start, i1 = i2->nexti; i2 != ip->stmt_end; + i2 = i1, i1 = i1->nexti) { + if (i1->source_line >= lineno) + return add_breakpoint(i2, i1, rp->source_file, silent); + if (i1 == ip->stmt_end) + break; + } + } + + if (ip->source_line >= lineno) + return add_breakpoint(prevp, ip, rp->source_file, silent); + if (ip == (rp + 1)->lasti) + break; + } + return NULL; +} + +/* set_breakpoint_next --- set a breakpoint at the next instruction */ + +static BREAKPOINT * +set_breakpoint_next(INSTRUCTION *rp, INSTRUCTION *ip) +{ + INSTRUCTION *prevp; + + if (ip == (rp + 1)->lasti) + return NULL; + prevp = ip; + if (ip->opcode != Op_breakpoint) + ip = ip->nexti; + for (; ip; prevp = ip, ip = ip->nexti) { + if (ip->source_line > 0) + return add_breakpoint(prevp, ip, rp->source_file, FALSE); + if (ip == (rp + 1)->lasti) + break; + } + return NULL; +} + +/* set_breakpoint --- set a breakpoint */ + +static int +set_breakpoint(CMDARG *arg, int temporary) +{ + int lineno; + BREAKPOINT *b = NULL; + INSTRUCTION *rp, *ip; + NODE *func; + SRCFILE *s = cur_srcfile; + char *src = cur_srcfile->src; + + if (arg == NULL) { +/* +* (From GDB Documentation): +* +* When called without any arguments, break sets a breakpoint at the next instruction +* to be executed in the selected stack frame (see section Examining the Stack). +* In any selected frame but the innermost, this makes your program stop as soon +* as control returns to that frame. This is similar to the effect of a finish command +* in the frame inside the selected frame--except that finish does not leave an +* active breakpoint. If you use break without an argument in the innermost frame, +* GDB stops the next time it reaches the current location; this may be useful +* inside loops. +* GDB normally ignores breakpoints when it resumes execution, until at least +* one instruction has been executed. If it did not do this, +* you would be unable to proceed past a breakpoint without first disabling the +* breakpoint. This rule applies whether or not the breakpoint already existed +* when your program stopped. +*/ + CHECK_PROG_RUNNING(); + if (cur_frame == 0) { + src = source; + ip = cur_pc; + } else { + NODE *f; + f = find_frame(cur_frame); + src = f->vname; + ip = (INSTRUCTION *) find_frame(cur_frame - 1)->reti; /* Op_func_call */ + } + rp = find_rule(src, ip->source_line); + assert(rp != NULL); + if ((b = set_breakpoint_next(rp, ip)) == NULL) + fprintf(out_fp, _("Can't set breakpoint in file `%s'\n"), src); + else { + if (cur_frame == 0) { /* stop next time */ + b->flags |= BP_IGNORE; + b->ignore_count = 1; + } + if (temporary) + b->flags |= BP_TEMP; + } + return FALSE; + } + + /* arg != NULL */ + + switch (arg->type) { + case D_string: /* break filename:lineno|function */ + s = source_find(arg->a_string); + arg = arg->next; + if (s == NULL || arg == NULL + || (arg->type != D_int && arg->type != D_func)) + return FALSE; + src = s->src; + if (arg->type == D_func) /* break filename:function */ + goto func; + else + /* fall through */ + case D_int: /* break lineno */ + lineno = (int) arg->a_int; + if (lineno <= 0 || lineno > s->srclines) + d_error(_("line number %d in file `%s' out of range"), lineno, src); + else { + rp = find_rule(src, lineno); + if (rp == NULL) + fprintf(out_fp, _("Can't find rule!!!\n")); + if (rp == NULL || (b = set_breakpoint_at(rp, lineno, FALSE)) == NULL) + fprintf(out_fp, _("Can't set breakpoint at `%s':%d\n"), + src, lineno); + if (b != NULL && temporary) + b->flags |= BP_TEMP; + } + break; + + case D_func: /* break function */ +func: + func = arg->a_node; + rp = func->code_ptr; + if ((b = set_breakpoint_at(rp, rp->source_line, FALSE)) == NULL) + fprintf(out_fp, _("Can't set breakpoint in function `%s'\n"), + func->lnode->param); + else if (temporary) + b->flags |= BP_TEMP; + lineno = b->bpi->source_line; + break; + + default: + return FALSE; + } + /* condition if any */ + arg = arg->next; + if (b != NULL && arg != NULL) { + if (parse_condition(D_break, b->number, arg->a_string) == 0) + arg->a_string = NULL; /* don't let free_cmdarg free it */ + else + fprintf(out_fp, _("breakpoint %d set at file `%s', line %d is unconditional\n"), + b->number, src, lineno); + } + return FALSE; +} + + +/* breakpoint_triggered --- check if we should stop at this breakpoint */ + +static int +breakpoint_triggered(BREAKPOINT *b) +{ + if ((b->flags & BP_ENABLE) == 0) + return 0; + if ((b->flags & BP_IGNORE) != 0) { + if (--b->ignore_count <= 0) + b->flags &= ~BP_IGNORE; + return 0; + } + + if (! condition_triggered(&b->cndn)) + return 0; + + b->hit_count++; + if (b->flags & BP_ENABLE_ONCE) { + b->flags &= ~BP_ENABLE_ONCE; + b->flags &= ~BP_ENABLE; + } + return b->number; +} + +/* do_breakpoint --- break command */ + +int +do_breakpoint(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + return set_breakpoint(arg, FALSE); +} + +/* do_tmp_breakpoint --- tbreak command */ + +int +do_tmp_breakpoint(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + return set_breakpoint(arg, TRUE); +} + +/* do_clear --- clear command */ + +int +do_clear(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + int lineno; + BREAKPOINT *b; + INSTRUCTION *rp, *ip; + NODE *func; + SRCFILE *s = cur_srcfile; + char *src = cur_srcfile->src; + int bp_found = FALSE; + + if (arg == NULL) { /* clear */ + CHECK_PROG_RUNNING(); + if (cur_frame == 0) { + lineno = sourceline; + src = source; + } else { + NODE *f; + f = find_frame(cur_frame); + src = f->vname; + lineno = ((INSTRUCTION *) find_frame(cur_frame - 1)->reti)->source_line; + } + goto delete_bp; + } + + switch (arg->type) { + case D_string: /* clear filename:lineno|function */ + s = source_find(arg->a_string); + arg = arg->next; + if (s == NULL || arg == NULL || + (arg->type != D_int && arg->type != D_func)) + return FALSE; + src = s->src; + if (arg->type == D_func) + goto func; + /* else + fall through */ + case D_int: /* clear lineno */ + lineno = (int) arg->a_int; + if (lineno <= 0 || lineno > s->srclines) { + d_error(_("line number %d in file `%s' out of range"), lineno, src); + return FALSE; + } + break; + + case D_func: /* clear function */ +func: + func = arg->a_node; + rp = func->code_ptr; + for (ip = rp->nexti; ip; ip = ip->nexti) { + if (ip->source_line <= 0) + continue; + if (ip->opcode != Op_breakpoint) + break; + b = ip->break_pt; + if (++bp_found == 1) + fprintf(out_fp, _("Deleted breakpoint %d"), b->number); + else + fprintf(out_fp, ", %d", b->number); + delete_breakpoint(b); + } + if (! bp_found) + fprintf(out_fp, _("No breakpoint(s) at entry to function `%s'\n"), + func->lnode->param); + else + fprintf(out_fp, "\n"); + /* fall through */ + default: + return FALSE; + } + +delete_bp: + rp = find_rule(src, lineno); + if (rp != NULL) { + for (ip = rp->nexti; ip; ip = ip->nexti) { + if (ip->opcode == Op_breakpoint && ip->source_line == lineno) { + b = ip->break_pt; + if (++bp_found == 1) + fprintf(out_fp, _("Deleted breakpoint %d"), b->number); + else + fprintf(out_fp, ", %d", b->number); + delete_breakpoint(b); + } + if (ip == (rp + 1)->lasti) + break; + } + } + + if (! bp_found) + fprintf(out_fp, _("No breakpoint at file `%s', line #%d\n"), + src, (int) lineno); + else + fprintf(out_fp, "\n"); + return FALSE; +} + +/* enable_breakpoint --- enable a breakpoint and set its disposition */ + +static inline void +enable_breakpoint(BREAKPOINT *b, short disp) +{ + b->flags &= ~(BP_ENABLE_ONCE|BP_TEMP); + b->flags |= BP_ENABLE; + if (disp) + b->flags |= disp; +} + +/* do_enable_breakpoint --- enable command */ + +int +do_enable_breakpoint(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + BREAKPOINT *b; + short disp = 0; + + if (arg != NULL && arg->type == D_argument) { + if (arg->a_argument == A_DEL) /* del */ + disp = BP_TEMP; + else /* once */ + disp = BP_ENABLE_ONCE; + arg = arg->next; + } + + if (arg == NULL) { /* enable [once|del] */ + for (b = breakpoints.next; b != &breakpoints; b = b->next) + enable_breakpoint(b, disp); + } + + for (; arg != NULL; arg = arg->next) { + if (arg->type == D_range) { + long i, j; + + i = arg->a_int; + arg = arg->next; + j = arg->a_int; + if (j > breakpoints.number) + j = breakpoints.number; + for (; i <= j; i++) { + if ((b = find_breakpoint(i)) != NULL) + enable_breakpoint(b, disp); + } + } else { + assert(arg->type == D_int); + if ((b = find_breakpoint(arg->a_int)) == NULL) + d_error(_("invalid breakpoint number")); + else + enable_breakpoint(b, disp); + } + } + return FALSE; +} + +/* do_delete_breakpoint --- delete command */ + +int +do_delete_breakpoint(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + if (arg == NULL) { + int delete_all = TRUE; + delete_all = prompt_yes_no( + _("Delete all breakpoints? (y or n) "), + _("y")[0], TRUE, out_fp); + + if (delete_all) { + while (breakpoints.next != &breakpoints) + delete_breakpoint(breakpoints.next); + } + } + + for (; arg != NULL; arg = arg->next) { + BREAKPOINT *b; + if (arg->type == D_range) { + long i, j; + + i = arg->a_int; + arg = arg->next; + j = arg->a_int; + if (j > breakpoints.number) + j = breakpoints.number; + for (; i <= j; i++) { + if ((b = find_breakpoint(i)) != NULL) + delete_breakpoint(b); + } + } else { + if ((b = find_breakpoint(arg->a_int)) == NULL) + d_error(_("invalid breakpoint number")); + else + delete_breakpoint(b); + } + } + return FALSE; +} + +/* do_ignore_breakpoint --- ignore command */ + +int +do_ignore_breakpoint(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + BREAKPOINT *b; + + if (arg == NULL || arg->type != D_int + || arg->next == NULL || arg->next->type != D_int) + return FALSE; + + if ((b = find_breakpoint(arg->a_int)) == NULL) + d_error(_("invalid breakpoint number")); + else { + b->ignore_count = arg->next->a_int; + if (b->ignore_count > 0) { + b->flags |= BP_IGNORE; + fprintf(out_fp, _("Will ignore next %ld crossing(s) of breakpoint %d.\n"), + b->ignore_count, b->number); + } else { + b->flags &= ~BP_IGNORE; + fprintf(out_fp, _("Will stop next time breakpoint %d is reached.\n"), + b->number); + } + } + return FALSE; +} + +/* do_disable_breakpoint --- disable command */ + +int +do_disable_breakpoint(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + BREAKPOINT *b; + + if (arg == NULL) { + /* disable all */ + for (b = breakpoints.next; b != &breakpoints; b = b->next) + b->flags &= ~BP_ENABLE; + } + + for (; arg != NULL; arg = arg->next) { + if (arg->type == D_range) { + long i, j; + + i = arg->a_int; + arg = arg->next; + j = arg->a_int; + if (j > breakpoints.number) + j = breakpoints.number; + for (; i <= j; i++) + if ((b = find_breakpoint(i)) != NULL) + b->flags &= ~BP_ENABLE; + } else { + if ((b = find_breakpoint(arg->a_int)) == NULL) + d_error(_("invalid breakpoint number")); + else + b->flags &= ~BP_ENABLE; + } + } + return FALSE; +} + +#ifdef HAVE_LIBREADLINE + +/* get_parmlist --- list of function params in current context */ + +char ** +get_parmlist() +{ + NODE *func; + + if (! prog_running) + return NULL; + func = find_frame(cur_frame)->func_node; + if (func == NULL) /* in main */ + return NULL; + return func->parmlist; +} + +/* initialize_readline --- initialize readline */ + +static void +initialize_readline() +{ + /* tell readline which stream to use for output, + * default input stream is stdin. + */ + rl_outstream = out_fp; + + /* allow conditional parsing of the ~/.inputrc file. */ + rl_readline_name = "gawk"; + + /* our completion function. */ + rl_attempted_completion_function = command_completion; + + read_a_line = readline; +} +#else +#define initialize_readline() /* nothing */ +#endif + + +/* interpret --- debugger entry point */ + +int +interpret(INSTRUCTION *pc) +{ + char *run; + + input_fd = fileno(stdin); + out_fp = stdout; + if (os_isatty(input_fd)) + input_from_tty = TRUE; + if (input_fd == 0 && input_from_tty) + initialize_readline(); + + if (! read_a_line) + read_a_line = g_readline; + + push_cmd_src(input_fd, input_from_tty, read_a_line, 0, 0, EXIT_FATAL); + + setbuf(out_fp, (char *) NULL); + for (cur_srcfile = srcfiles->prev; cur_srcfile != srcfiles; + cur_srcfile = cur_srcfile->prev) { + if (cur_srcfile->stype == SRC_FILE + || cur_srcfile->stype == SRC_INC) + break; + } + + if (cur_srcfile == srcfiles) { + fprintf(out_fp, _("Can only debug programs provided with the `-f' option.\n")); + exit(EXIT_FAILURE); + } + + dgawk_Prompt = estrdup(DEFAULT_PROMPT, strlen(DEFAULT_PROMPT)); + dPrompt = dgawk_Prompt; + + memset(&stop, 0, sizeof(stop)); + stop.command = D_illegal; + + if ((run = getenv("DGAWK_RESTART")) != NULL) { + /* We are restarting; restore state (breakpoints, history etc.) + * passed as environment variables and optionally execute the run command. + */ + unserialize(BREAK); + unserialize(WATCH); + unserialize(DISPLAY); + unserialize(HISTORY); + unserialize(OPTION); + unsetenv("DGAWK_RESTART"); + fprintf(out_fp, "Restarting ...\n"); + if (run[0] == 'T') + (void) do_run(NULL, 0); + + } else if (command_file != NULL) { + /* run commands from a file (--command=file or -R file) */ + int fd; + fd = open_readfd(command_file); + if (fd == INVALID_HANDLE) { + fprintf(stderr, _("can't open source file `%s' for reading (%s)"), + command_file, strerror(errno)); + exit(EXIT_FAILURE); + } + push_cmd_src(fd, FALSE, g_readline, close, 0, EXIT_FAILURE); + cmd_src->str = estrdup(command_file, strlen(command_file)); + + } else { + int fd; + +#ifdef HAVE_LIBREADLINE + (void) read_history(history_file); + sess_history_base = history_length; +#endif + + /* read saved options */ + fd = open_readfd(options_file); + if (fd > INVALID_HANDLE) + push_cmd_src(fd, FALSE, g_readline, close, 0, EXIT_SUCCESS); + } + + /* start the command interpreter */ + read_command(); /* yyparse */ + return EXIT_SUCCESS; +} + + +/* N.B.: ignore breakpoints and watchpoints for return command */ + +/* check_watchpoint --- check if any watchpoint triggered */ + +static int +check_watchpoint() +{ + struct list_item *w; + + if (stop.command == D_return) + return FALSE; + for (w = watch_list.prev; w != &watch_list; w = w->prev) { + int wnum = watchpoint_triggered(w); + if (wnum > 0) { + stop.watch_point = wnum; + stop.print_frame = TRUE; + return TRUE; + } + } + return FALSE; +} + +/* check_breakpoint --- check if breakpoint triggered */ + +static int +check_breakpoint(INSTRUCTION **pi) +{ + INSTRUCTION *pc; + + pc = *pi; + if (stop.command == D_return) + return FALSE; + if (pc->opcode == Op_breakpoint) { + int bnum; + *pi = pc->nexti; /* skip past the breakpoint instruction; + * interpreter doesn't process Op_breakpoint. + */ + bnum = breakpoint_triggered(pc->break_pt); + if (bnum > 0) { + stop.break_point = bnum; + stop.print_frame = TRUE; + return TRUE; + } + } + return FALSE; +} + +/* restart --- restart the debugger */ + +static void +restart(int run) +{ + /* save state in the environment after serialization */ + serialize(BREAK); + serialize(WATCH); + serialize(DISPLAY); + serialize(HISTORY); + serialize(OPTION); + + /* tell the new process to restore state from the environment */ + setenv("DGAWK_RESTART", (run ? "TRUE" : "FALSE"), 1); + + /* close all open files */ + close_all(); + + /* start a new process replacing the current process */ + execvp(d_argv[0], d_argv); + + /* execvp failed !!! */ + fprintf(out_fp, _("Failed to restart debugger")); + exit(EXIT_FAILURE); +} + +/* do_run --- run command */ + +int +do_run(CMDARG *arg ATTRIBUTE_UNUSED, int cmd ATTRIBUTE_UNUSED) +{ + if (prog_running) { + if (! input_from_tty) + need_restart = TRUE; /* handled later */ + else { + need_restart = prompt_yes_no( + _("Program already running. Restart from beginning (y/n)? "), + _("y")[0], FALSE, out_fp); + + if (! need_restart) { + fprintf(out_fp, _("Program not restarted\n")); + return FALSE; + } + } + } + + if (need_restart) { + /* avoid endless cycles of restarting */ + if (command_file != NULL) { + /* input_from_tty = FALSE */ + fprintf(stderr, _("error: cannot restart, operation not allowed\n")); + exit(EXIT_FAILURE); + } + + if (cmd_src->cmd == D_source) { + /* input_from_tty = FALSE */ + fprintf(out_fp, _("error (%s): cannot restart, ignoring rest of the commands\n"), cmd_src->str); + pop_cmd_src(); + return FALSE; + } + + restart(TRUE); /* does not return */ + } + + fprintf(out_fp, _("Starting program: \n")); + + prog_running = TRUE; + fatal_tag_valid = TRUE; + if (setjmp(fatal_tag) == 0) + (void) r_interpret(code_block); + + fatal_tag_valid = FALSE; + prog_running = FALSE; + fprintf(out_fp, _("Program exited %s with exit value: %d\n"), + (! exiting && exit_val != EXIT_SUCCESS) ? "abnormally" + : "normally", + exit_val); + need_restart = TRUE; + return FALSE; +} + +/* do_quit --- quit command */ + +int +do_quit(CMDARG *arg ATTRIBUTE_UNUSED, int cmd ATTRIBUTE_UNUSED) +{ + int terminate = TRUE; + if (prog_running) + terminate = prompt_yes_no( + _("The program is running. Exit anyway (y/n)? "), + _("y")[0], TRUE, out_fp); + if (terminate) { + close_all(); + do_trace = FALSE; /* don't save 'trace on' */ + +#ifdef HAVE_LIBREADLINE + if (do_save_history && input_from_tty) { + int ret; + ret = write_history(history_file); + if (ret == 0 && history_length > history_size) + (void) history_truncate_file(history_file, history_size); + } +#endif + if (do_save_options && input_from_tty) + save_options(options_file); + + exit(exit_val); + } + return FALSE; +} + +/* do_continue --- continue command */ + +int +do_continue(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + BREAKPOINT *b; + + CHECK_PROG_RUNNING(); + if (! arg || arg->type != D_int) + return TRUE; + + /* arg is breakpoint ignore count if stopped at a breakpoint */ + if (! stop.break_point) { + fprintf(out_fp, _("Not stopped at any breakpoint; argument ignored.\n")); + return TRUE; + } + b = find_breakpoint(stop.break_point); + if (b == NULL) { + d_error(_("invalid breakpoint number %d."), stop.break_point); + return FALSE; + } + b->flags |= BP_IGNORE; + b->ignore_count = arg->a_int; + fprintf(out_fp, _("Will ignore next %ld crossings of breakpoint %d.\n"), + b->ignore_count, stop.break_point); + return TRUE; +} + +/* next_step --- common code for next and step commands */ + +static int +next_step(CMDARG *arg, int cmd) +{ + CHECK_PROG_RUNNING(); + if (arg != NULL && arg->type == D_int) + stop.repeat_count = arg->a_int; + else + stop.repeat_count = 1; + stop.command = cmd; + return TRUE; +} + +/* check_step --- process step command, return TRUE if stopping */ + +static int +check_step(INSTRUCTION **pi) +{ + if (fcall_count != stop.fcall_count) { + stop.fcall_count = fcall_count; + stop.sourceline = sourceline; + stop.source = source; + stop.print_frame = TRUE; + return (--stop.repeat_count == 0); + } + + if (source != stop.source) { + stop.source = source; + stop.sourceline = sourceline; + return (--stop.repeat_count == 0); + } + + if (sourceline != stop.sourceline) { + stop.sourceline = sourceline; + return (--stop.repeat_count == 0); + } + return FALSE; +} + +/* do_step -- process step command, return TRUE if stopping */ + +int +do_step(CMDARG *arg, int cmd) +{ + int ret; + ret = next_step(arg, cmd); + if (ret) { + stop.fcall_count = fcall_count; + stop.source = source; + stop.sourceline = sourceline; + stop.check_func = check_step; + } + return ret; +} + +/* do_stepi -- process stepi command, return TRUE if stopping */ + +static int +check_stepi(INSTRUCTION **pi) +{ + return (--stop.repeat_count == 0); +} + +/* do_stepi -- stepi command */ + +int +do_stepi(CMDARG *arg, int cmd) +{ + int ret; + ret = next_step(arg, cmd); + if (ret) + stop.check_func = check_stepi; + return ret; +} + + +/* check_next -- process next command returning TRUE if stopping */ + +static int +check_next(INSTRUCTION **pi) +{ + /* make sure not to step inside function calls */ + + if (fcall_count < stop.fcall_count) { + stop.fcall_count = fcall_count; + stop.sourceline = sourceline; + stop.source = source; + stop.print_frame = TRUE; + return (--stop.repeat_count == 0); + } + + if (fcall_count == stop.fcall_count) { + if (source != stop.source) { + stop.source = source; + stop.sourceline = sourceline; + return (--stop.repeat_count == 0); + } + if (sourceline != stop.sourceline) { + stop.sourceline = sourceline; + return (--stop.repeat_count == 0); + } + } + +#if 0 + /* redundant ? */ + if (fcall_count > stop.fcall_count) { + stop.source = source; + stop.sourceline = sourceline; + } +#endif + + return FALSE; +} + +/* do_next -- next command */ + +int +do_next(CMDARG *arg, int cmd) +{ + int ret; + + ret = next_step(arg, cmd); + if (ret) { + stop.source = source; + stop.sourceline = sourceline; + stop.fcall_count = fcall_count; + stop.check_func = check_next; + } + return ret; +} + +/* check_nexti --- process nexti command, returns TRUE if stopping */ + +static int +check_nexti(INSTRUCTION **pi) +{ + + /* make sure not to step inside function calls */ + + if (fcall_count < stop.fcall_count) { + stop.print_frame = TRUE; + stop.fcall_count = fcall_count; + } + return (fcall_count == stop.fcall_count + && --stop.repeat_count == 0); +} + +/* do_nexti -- nexti command */ + +int +do_nexti(CMDARG *arg, int cmd) +{ + int ret; + + ret = next_step(arg, cmd); + if (ret) { + stop.fcall_count = fcall_count; + stop.check_func = check_nexti; + } + return ret; +} + +/* check_finish --- process finish command, returns TRUE if stopping */ + +static int +check_finish(INSTRUCTION **pi) +{ + if (fcall_count == stop.fcall_count) { + stop.print_frame = TRUE; + return TRUE; + } + return FALSE; +} + +/* do_finish --- finish command */ + +int +do_finish(CMDARG *arg ATTRIBUTE_UNUSED, int cmd) +{ + CHECK_PROG_RUNNING(); + if (cur_frame == fcall_count) { + fprintf(out_fp, + _("'finish' not meaningful in the outermost frame main()\n")); + return FALSE; + } + stop.fcall_count = fcall_count - cur_frame - 1; + assert(stop.fcall_count >= 0); + fprintf(out_fp, _("Run till return from ")); + print_numbered_frame(cur_frame); + stop.check_func = check_finish; + stop.command = cmd; + stop.print_ret = TRUE; + return TRUE; +} + +/* check_return --- process return, returns TRUE if stopping */ + +static int +check_return(INSTRUCTION **pi) +{ + assert(fcall_count >= stop.fcall_count); + + if (fcall_count == stop.fcall_count) { + stop.print_frame = TRUE; + return TRUE; + } + + if (fcall_count > stop.fcall_count) { /* innermost frame just returned */ + /* force this one to return too */ + NODE *func; + + func = find_frame(cur_frame)->func_node; + assert(func != NULL); + *pi = (func->code_ptr + 1)->lasti; + /* assert((*pi)->opcode == Op_K_return); */ + } + + return FALSE; +} + +/* do_return --- return command */ + +int +do_return(CMDARG *arg, int cmd) +{ + NODE *func; + + CHECK_PROG_RUNNING(); + func = find_frame(cur_frame)->func_node; + if (func == NULL) { + fprintf(out_fp, _("'return' not meaningful in the outermost frame main()\n")); + return FALSE; + } + + stop.fcall_count = fcall_count - cur_frame - 1; + assert(stop.fcall_count >= 0); + stop.pc = (func->code_ptr + 1)->lasti; + assert(stop.pc->opcode == Op_K_return); + stop.command = cmd; + + stop.check_func = check_return; + + if (arg != NULL && arg->type == D_node) { /* optional return value */ + NODE *n; + n = dupnode(arg->a_node); + PUSH(n); + } else + PUSH(Nnull_string); + + return TRUE; +} + +/* check_until --- process until, returns TRUE if stopping */ + +int +check_until(INSTRUCTION **pi) +{ + if (fcall_count < stop.fcall_count) { /* current stack frame returned */ + stop.print_frame = TRUE; + return TRUE; + } else if (fcall_count == stop.fcall_count) { + if (stop.pc && *pi == stop.pc) /* until location */ + return TRUE; + if (stop.sourceline > 0 /* until */ + && source == stop.source + && sourceline > stop.sourceline) + return TRUE; + } + return FALSE; +} + +/* do_until --- until command */ + +int +do_until(CMDARG *arg, int cmd) +{ + SRCFILE *s = cur_srcfile; + char *src = cur_srcfile->src; + int lineno; + INSTRUCTION *rp, *ip; + NODE *func; + + CHECK_PROG_RUNNING(); + stop.pc = NULL; + stop.sourceline = 0; + + if (arg == NULL) { /* until without argument */ + + /* GDB doc.: continue running until a source line past the current line, + * in the current stack frame, is reached. Is used to avoid single + * stepping through a loop more than once. ... + * This means that when you reach the end of a loop after single + * stepping though it, until makes your program continue execution + * until it exits the loop. In contrast, a next command at the end + * of a loop simply steps back to the beginning of the loop, which + * forces you to step through the next iteration. + */ + + stop.source = source; + stop.sourceline = sourceline; + stop.fcall_count = fcall_count - cur_frame; + stop.check_func = check_until; + stop.command = cmd; + return TRUE; + } + + /* GDB: until location - continue running program until + * either the specified location is reached, or the + * current stack frame returns. + */ + + switch (arg->type) { + case D_string: /* until filename : lineno|function */ + s = source_find(arg->a_string); + arg = arg->next; + if (s == NULL || arg == NULL + || (arg->type != D_int && arg->type != D_func)) + return FALSE; + src = s->src; + if (arg->type == D_func) + goto func; + /* else + fall through */ + case D_int: /* until lineno */ + lineno = arg->a_int; + if (lineno <= 0 || lineno > s->srclines) { + d_error(_("line number %d in file `%s' out of range"), + lineno, src); + return FALSE; + } + break; + + case D_func: /* until function */ +func: + func = arg->a_node; + rp = func->code_ptr; + for (ip = rp->nexti; ip; ip = ip->nexti) { + if (ip->opcode != Op_breakpoint && ip->source_line > 0) { + stop.pc = ip; + stop.fcall_count = fcall_count - cur_frame; + stop.check_func = check_until; + stop.command = cmd; + return TRUE; + } + } + fprintf(out_fp, _("Can't find specified location in function `%s'\n"), + func->lnode->param); + /* fall through */ + default: + return FALSE; + } + + if ((rp = find_rule(src, lineno)) == NULL) { + d_error(_("invalid source line %d in file `%s'"), lineno, src); + return FALSE; + } + + for (ip = rp->nexti; ip; ip = ip->nexti) { + if (ip->opcode != Op_breakpoint && ip->source_line >= lineno) { + stop.pc = ip; + stop.fcall_count = fcall_count - cur_frame; + stop.check_func = check_until; + stop.command = cmd; + return TRUE; + } + if (ip == (rp + 1)->lasti) + break; + } + fprintf(out_fp, _("Can't find specified location %d in file `%s'\n"), + lineno, src); + return FALSE; +} + +/* print_watch_item --- print watched item name, old and current values */ + +static void +print_watch_item(struct list_item *w) +{ + NODE *symbol, *sub; + int i; + + symbol = w->symbol; + if (IS_SUBSCRIPT(w)) { + fprintf(out_fp, "%s", w->sname); + for (i = 0; i < w->num_subs; i++) { + sub = w->subs[i]; + fprintf(out_fp, "[\"%s\"]", sub->stptr); + } + fprintf(out_fp, "\n"); + } else if (IS_FIELD(w)) + fprintf(out_fp, "$%ld\n", (long) symbol->numbr); + else + fprintf(out_fp, "%s\n", w->sname); + + +#define print_value(X, S, V) \ +if (X) \ + fprintf(out_fp, "array, %ld elements\n", w->S); \ +else if (! w->V) \ + fprintf(out_fp, IS_SUBSCRIPT(w) ? \ + _("element not in array\n") : _("untyped variable\n")); \ +else \ + valinfo(w->V, fprintf, out_fp); + + fprintf(out_fp, " Old value: "); + print_value((w->flags & OLD_IS_ARRAY), old_size, old_value); + fprintf(out_fp, " New value: "); + print_value((w->flags & CUR_IS_ARRAY), cur_size, cur_value); + +#undef print_value +} + +/* next_command --- (optionally) print stoppage location and reason; + * also fetch next debug command from the user. + */ + +static void +next_command() +{ + static int last_rule = 0; + struct list_item *d = NULL, *w = NULL; + BREAKPOINT *b = NULL; + SRCFILE *s; + + if (source == NULL) { + stop.command = D_illegal; + stop.check_func = NULL; + return; + } + + if (stop.break_point) { + b = find_breakpoint(stop.break_point); + assert(b != NULL); + if (b->silent) + goto no_output; + } else if (stop.watch_point) { + w = find_item(&watch_list, stop.watch_point); + if (w->silent) + goto no_output; + } + + if (cur_rule != last_rule) { + fprintf(out_fp, _("Stopping in %s ...\n"), ruletab[cur_rule]); + last_rule = cur_rule; + } + + if (b != NULL) + fprintf(out_fp, "Breakpoint %d, ", b->number); + else if (w != NULL) { + fprintf(out_fp, "Watchpoint %d: ", w->number); + print_watch_item(w); + } + + /* frame info */ + if (stop.print_frame) { + print_frame(frame_ptr->func_node, source, sourceline); + fprintf(out_fp, "\n"); + stop.print_frame = FALSE; + } + + (void) print_lines(source, sourceline, 1); + + /* automatic display of variables */ + for (d = display_list.prev; d != &display_list; d = d->prev) + display(d); + +no_output: + /* update last_printed_line, so that output of 'list' is + * centered around current sourceline + */ + + last_printed_line = sourceline - list_size / 2; + if (last_printed_line < 0) + last_printed_line = 0; + + /* update current source file */ + s = source_find(source); + if (cur_srcfile != s) { + if (cur_srcfile->fd != INVALID_HANDLE) { + close(cur_srcfile->fd); + cur_srcfile->fd = INVALID_HANDLE; + } + cur_srcfile = s; + } + + stop.command = D_illegal; + stop.check_func = NULL; + + if (b != NULL) { + int ret; + ret = execute_commands(&b->commands); + if ((b->flags & BP_TEMP) != 0) + delete_breakpoint(b); + if (ret) /* resume execution */ + return; + } else if (w != NULL && execute_commands(&w->commands)) + return; + + read_command(); /* zzparse */ +} + +/* post_execute --- post_hook in the interpreter */ + +void +post_execute(INSTRUCTION *pc) +{ + if (! in_main_context()) + return; + + switch (pc->opcode) { + case Op_K_next: + case Op_K_nextfile: + case Op_K_exit: + if (stop.command == D_finish) { + /* cancel finish command */ + stop.print_ret = FALSE; + stop.print_frame = FALSE; + stop.command = D_illegal; + stop.check_func = NULL; + fprintf(out_fp, _("'finish' not meaningful with non-local jump '%s'\n"), + op2str(pc->opcode)); + } else if (stop.command == D_until) { + /* cancel until command */ + stop.print_frame = FALSE; + stop.command = D_illegal; + stop.check_func = NULL; + fprintf(out_fp, _("'until' not meaningful with non-local jump '%s'\n"), + op2str(pc->opcode)); + } + break; + + case Op_K_return: + if (stop.command == D_finish + && fcall_count == stop.fcall_count + && stop.print_ret + ) { + NODE *r; + /* print the returned value before it disappears. */ + r = TOP(); + fprintf(out_fp, "Returned value = "); + valinfo(r, fprintf, out_fp); + stop.print_ret = FALSE; + } + break; + + case Op_newfile: + case Op_get_record: + return; + + default: + break; + } +} + +/* pre_execute --- pre_hook, called by the interpreter before execution; + * checks if execution needs to be suspended and control + * transferred to the debugger. + */ + +int +pre_execute(INSTRUCTION **pi) +{ + static int cant_stop = FALSE; + NODE *m; + + if (! in_main_context()) + return pre_execute_code(pi); + + cur_pc = *pi; + stop.break_point = 0; + stop.watch_point = 0; + cur_frame = 0; + + if (do_trace + && cur_pc->opcode != Op_breakpoint + && stop.command != D_return + ) + print_instruction(cur_pc, fprintf, out_fp, FALSE); + +/* N.B.: For Op_field_spec_lhs must execute instructions upto Op_field_assign + * as a group before stopping. Otherwise, watch/print of field variables + * yield surprising results. Ditto for Op_push_lhs for special variables + * (upto Op_var_assign, the set_FOO routine). + */ + + switch (cur_pc->opcode) { + case Op_field_spec_lhs: + cant_stop = TRUE; + break; + + case Op_field_assign: + cant_stop = FALSE; + return TRUE; /* may stop at next instruction */ + + case Op_push_lhs: + m = cur_pc->memory; + if (m->type == Node_var && m->var_assign) + cant_stop = TRUE; + break; + + case Op_arrayfor_incr: /* can have special var as array variable !!! */ + m = cur_pc->array_var; + if (m->type == Node_var && m->var_assign) + cant_stop = TRUE; + break; + + case Op_var_assign: + cant_stop = FALSE; + return TRUE; /* may stop at next instruction */ + + case Op_rule: + cur_rule = cur_pc->in_rule; + return TRUE; + + case Op_func: + case Op_ext_func: + case Op_var_update: + return TRUE; + + case Op_breakpoint: + break; /* processed later in check_breakpoint() */ + + default: + if (cur_pc->source_line <= 0) + return TRUE; + break; + } + + if (cant_stop) + return TRUE; + + assert(sourceline > 0); + + if (check_breakpoint(pi) + || check_watchpoint() + || (stop.check_func && stop.check_func(pi))) { + next_command(); /* return to debugger interface */ + if (stop.command == D_return) + *pi = stop.pc; /* jump to this instruction */ + } + + /* if cur_pc == *pi, interpreter executes cur_pc; + * Otherwise, jumps to instruction *pi. + */ + return (cur_pc == *pi); +} + +/* print_memory --- print a scalar value */ + +static void +print_memory(NODE *m, char **fparms, Func_print print_func, FILE *fp) +{ + switch (m->type) { + case Node_val: + if (m == Nnull_string) + print_func(fp, "Nnull_string"); + else if ((m->flags & NUMBER) != 0) + print_func(fp, "%g", m->numbr); + else if ((m->flags & STRING) != 0) + pp_string_fp(print_func, fp, m->stptr, m->stlen, '"', FALSE); + else if ((m->flags & NUMCUR) != 0) + print_func(fp, "%g", m->numbr); + else if ((m->flags & STRCUR) != 0) + pp_string_fp(print_func, fp, m->stptr, m->stlen, '"', FALSE); + else + print_func(fp, "-?-"); + print_func(fp, " [%s]", flags2str(m->flags)); + break; + + case Node_regex: + pp_string_fp(print_func, fp, m->re_exp->stptr, m->re_exp->stlen, '/', FALSE); + break; + + case Node_dynregex: + break; + + case Node_param_list: + assert(fparms != NULL); + print_func(fp, "%s", fparms[m->param_cnt]); + break; + + case Node_var: + case Node_var_new: + case Node_var_array: + print_func(fp, "%s", m->vname); + break; + + default: + print_func(fp, "?"); /* can't happen */ + } +} + +/* print_instruction --- print a bytecode */ + +static void +print_instruction(INSTRUCTION *pc, Func_print print_func, FILE *fp, int in_dump) +{ + static char **fparms = NULL; + int pcount = 0; + NODE *func = NULL; + static int noffset = 0; + + if (noffset == 0) { + static char buf[50]; + /* offset for 2nd to last lines in a multi-line output */ + noffset = sprintf(buf, "[ :%p] %-20.20s: ", pc, opcode2str(pc->opcode)); + } + + if (pc->opcode == Op_func) { + func = pc->func_body; + fparms = get_params(func); + pcount = get_param_count(func); + if (in_dump) { + int j; + print_func(fp, "\n\t# Function: %s (", func->lnode->param); + for (j = 0; j < pcount; j++) { + print_func(fp, "%s", fparms[j]); + if (j < pcount - 1) + print_func(fp, ", "); + } + print_func(fp, ")\n\n"); + } + } else if (pc->opcode == Op_ext_func) { + func = pc->func_body; + fparms = get_params(func); + pcount = get_param_count(func); + if (in_dump) + print_func(fp, "\n\t# Extension function: %s (... %d params ...)\n\n", + func->lnode->param, pcount); + } else if (pc->opcode == Op_rule) { + if (in_dump) + print_func(fp, "\n\t# %s\n\n", ruletab[pc->in_rule]); + } + + if (pc->opcode == Op_newfile) + print_func(fp, "\n"); + + if (pc->source_line <= 0) + print_func(fp, "[ :%p] %-20.20s: ", pc, opcode2str(pc->opcode)); + else + print_func(fp, "[%6d:%p] %-20.20s: ", + pc->source_line, pc, opcode2str(pc->opcode)); + + if (prog_running && ! in_dump) { + /* find params in the current frame */ + func = find_frame(0)->func_node; + if (func != NULL) + fparms = get_params(func); + /* else + fparms = NULL; */ + } + + + switch (pc->opcode) { + case Op_var_update: + print_func(fp, "[update_%s()]\n", get_spec_varname(pc->update_var)); + break; + + case Op_var_assign: + print_func(fp, "[set_%s()]", get_spec_varname(pc->assign_var)); + if (pc->assign_ctxt != 0) + print_func(fp, " [assign_ctxt = %s]", opcode2str(pc->assign_ctxt)); + print_func(fp, "\n"); + break; + + case Op_field_assign: + print_func(fp, "[%s]\n", pc->field_assign == reset_record ? + "reset_record()" : "invalidate_field0()"); + break; + + case Op_field_spec_lhs: + print_func(fp, "[target_assign = %p] [do_reference = %s]\n", + pc->target_assign, pc->do_reference ? "TRUE" : "FALSE"); + break; + + case Op_ext_func: + print_func(fp, "[param_cnt = %d]\n", pcount); + break; + + case Op_func: + print_func(fp, "[param_cnt = %d] [source_file = %s]\n", pcount, + pc->source_file ? pc->source_file : "cmd. line"); + break; + + case Op_K_getline_redir: + print_func(fp, "[into_var = %s] [redir_type = \"%s\"]\n", + pc->into_var ? "TRUE" : "FALSE", + redir2str(pc->redir_type)); + break; + + case Op_K_getline: + print_func(fp, "[into_var = %s]\n", pc->into_var ? "TRUE" : "FALSE"); + print_func(fp, "%*s[target_beginfile = %p] [target_endfile = %p]\n", + noffset, "", + (pc + 1)->target_beginfile, (pc + 1)->target_endfile); + break; + + case Op_K_print_rec: + print_func(fp, "[redir_type = \"%s\"]\n", redir2str(pc->redir_type)); + break; + + case Op_K_print: + case Op_K_printf: + print_func(fp, "[expr_count = %ld] [redir_type = \"%s\"]\n", + pc->expr_count, redir2str(pc->redir_type)); + break; + + case Op_indirect_func_call: + case Op_func_call: + print_func(fp, "[func_name = %s] [arg_count = %ld]\n", + pc->func_name, (pc + 1)->expr_count); + break; + + case Op_K_nextfile: + print_func(fp, "[target_newfile = %p] [target_endfile = %p]\n", + pc->target_newfile, pc->target_endfile); + break; + + case Op_newfile: + print_func(fp, "[target_jmp = %p] [target_endfile = %p]\n", + pc->target_jmp, pc->target_endfile); + print_func(fp, "%*s[target_get_record = %p]\n", + noffset, "", (pc + 1)->target_get_record); + break; + + case Op_get_record: + print_func(fp, "[target_newfile = %p]\n", pc->target_newfile); + break; + + case Op_jmp: + case Op_jmp_false: + case Op_jmp_true: + case Op_and: + case Op_or: + case Op_K_next: + case Op_arrayfor_init: + case Op_K_break: + case Op_K_continue: + print_func(fp, "[target_jmp = %p]\n", pc->target_jmp); + break; + case Op_K_exit: + print_func(fp, "[target_end = %p] [target_atexit = %p]\n", + pc->target_end, pc->target_atexit); + break; + + case Op_K_case: + print_func(fp, "[target_jmp = %p] [match_exp = %s]\n", + pc->target_jmp, (pc + 1)->match_exp ? "TRUE" : "FALSE"); + break; + + case Op_arrayfor_incr: + print_func(fp, "[array_var = %s] [target_jmp = %p]\n", + pc->array_var->type == Node_param_list ? + fparms[pc->array_var->param_cnt] : pc->array_var->vname, + pc->target_jmp); + break; + + case Op_line_range: + print_func(fp, "[triggered = %ld] [target_jmp = %p]\n", + pc->triggered, pc->target_jmp); + break; + + case Op_cond_pair: + print_func(fp, "[line_range = %p] [target_jmp = %p]\n", + pc->line_range, pc->target_jmp); + break; + + case Op_sub_builtin: + { + const char *fname = "sub"; + static const struct flagtab values[] = { + { GSUB, "GSUB" }, + { GENSUB, "GENSUB" }, + { LITERAL, "LITERAL" }, + { 0, NULL } + }; + + if (pc->sub_flags & GSUB) + fname = "gsub"; + else if (pc->sub_flags & GENSUB) + fname = "gensub"; + print_func(fp, "%s [arg_count = %ld] [sub_flags = %s]\n", + fname, pc->expr_count, + genflags2str(pc->sub_flags, values)); + } + break; + + case Op_builtin: + { + const char *fname = getfname(pc->builtin); + if (fname == NULL) + print_func(fp, "(extension func) [arg_count = %ld]\n", pc->expr_count); + else + print_func(fp, "%s [arg_count = %ld]\n", fname, pc->expr_count); + } + break; + + case Op_subscript: + case Op_sub_array: + print_func(fp, "[sub_count = %ld]\n", pc->sub_count); + break; + + case Op_store_sub: + print_memory(pc->memory, fparms, print_func, fp); + print_func(fp, " [sub_count = %ld]\n", pc->expr_count); + break; + + case Op_subscript_lhs: + print_func(fp, "[sub_count = %ld] [do_reference = %s]\n", + pc->sub_count, + pc->do_reference ? "TRUE" : "FALSE"); + break; + + case Op_K_delete: + case Op_in_array: + print_func(fp, "[expr_count = %ld]\n", pc->expr_count); + break; + + case Op_concat: + /* NB: concat_flag CSVAR only used in grammar, don't display it */ + print_func(fp, "[expr_count = %ld] [concat_flag = %s]\n", + pc->expr_count, + (pc->concat_flag & CSUBSEP) ? "CSUBSEP" : "0"); + break; + + case Op_rule: + print_func(fp, "[in_rule = %s] [source_file = %s]\n", + ruletab[pc->in_rule], + pc->source_file ? pc->source_file : "cmd. line"); + break; + + case Op_lint: + { + static const char *const linttypetab[] = { + "LINT_illegal", + "LINT_assign_in_cond", + "LINT_no_effect" + }; + print_func(fp, "[lint_type = %s]\n", linttypetab[pc->lint_type]); + } + break; + + case Op_exec_count: + print_func(fp, "[exec_count = %ld]\n", pc->exec_count); + break; + + case Op_store_var: + case Op_push_lhs: + print_memory(pc->memory, fparms, print_func, fp); + print_func(fp, " [do_reference = %s]\n", + pc->do_reference ? "TRUE" : "FALSE"); + break; + + case Op_push_i: + case Op_push: + case Op_push_arg: + case Op_push_param: + case Op_push_array: + case Op_push_re: + case Op_match_rec: + case Op_match: + case Op_nomatch: + case Op_plus_i: + case Op_minus_i: + case Op_times_i: + case Op_exp_i: + case Op_quotient_i: + case Op_mod_i: + case Op_assign_concat: + print_memory(pc->memory, fparms, print_func, fp); + /* fall through */ + default: + print_func(fp, "\n"); + break; + } +} + +/* do_trace_instruction --- trace command */ + +int +do_trace_instruction(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + if (arg != NULL && arg->type == D_argument + && arg->a_argument == A_TRACE_ON) + do_trace = TRUE; + else + do_trace = FALSE; + return FALSE; +} + +/* print_code --- print a list of instructions */ + +static int +print_code(INSTRUCTION *pc, void *x) +{ + struct pf_data *data = (struct pf_data *) x; + for (; pc != NULL; pc = pc->nexti) + print_instruction(pc, data->print_func, data->fp, data->defn /* in_dump */); + return 0; +} + +/* do_dump_instructions --- dump command */ + +int +do_dump_instructions(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + FILE *fp; + + if (arg != NULL && arg->type == D_string) { + /* dump to a file */ + if ((fp = fopen(arg->a_string, "w")) == NULL) { + d_error(_("could not open `%s' for writing (%s)"), + arg->a_string, strerror(errno)); + return FALSE; + } + pf_data.print_func = fprintf; + pf_data.fp = fp; + pf_data.defn = TRUE; /* in_dump = TRUE */ + (void) print_code(code_block, &pf_data); + (void) foreach_func((int (*)(INSTRUCTION *, void *)) print_code, + FALSE, /* sort */ + &pf_data /* data */ + ); + fclose(fp); + return FALSE; + } + + initialize_pager(out_fp); + if (setjmp(pager_quit_tag) == 0) { + pf_data.print_func = gprintf; + pf_data.fp = out_fp; + pf_data.defn = TRUE; /* in_dump = TRUE */ + (void) print_code(code_block, &pf_data); + (void) foreach_func((int (*)(INSTRUCTION *, void *)) print_code, + FALSE, /* sort */ + &pf_data /* data */ + ); + } + return FALSE; +} + +/* do_save --- save command */ + +int +do_save(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ +#ifdef HAVE_LIBREADLINE + FILE *fp; + HIST_ENTRY **hist_list; + int i; + + if ((fp = fopen(arg->a_string, "w")) == NULL) { + d_error(_("could not open `%s' for writing (%s)"), + arg->a_string, strerror(errno)); + return FALSE; + } + + hist_list = history_list(); + if (hist_list && history_length > sess_history_base) { + for (i = sess_history_base; hist_list[i] != NULL; i++) { + char *line; + line = hist_list[i]->line; + + /* exclude save commands; + * N.B.: this test may fail if there is another + * command with the same first 2 letters. + */ + + if (strlen(line) > 1 + && strncmp(line, "sa", 2) == 0) + continue; + + fprintf(fp, "%s\n", line); + } + } + fclose(fp); +#endif + return FALSE; +} + +/* do_option --- option command */ + +int +do_option(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + const struct dbg_option *opt; + char *name, *value; + + if (arg == NULL) { /* display all available options and corresponding values */ + for (opt = option_list; opt->name; opt++) { + if (opt->str_val != NULL) + fprintf(out_fp, "%s = \"%s\"\n", opt->name, *(opt->str_val)); + else + fprintf(out_fp, "%s = %d\n", opt->name, *(opt->num_val)); + } + return FALSE; + } + + name = arg->a_string; + arg = arg->next; + value = arg ? arg->a_string : NULL; + + for (opt = option_list; opt->name; opt++) { /* linear search */ + if (strcmp(name, opt->name) == 0) + break; + } + if (! opt->name) + return FALSE; + + if (value == NULL) { /* display current setting */ + if (opt->str_val != NULL) + fprintf(out_fp, "%s = \"%s\"\n", opt->name, *(opt->str_val)); + else + fprintf(out_fp, "%s = %d\n", opt->name, *(opt->num_val)); + } else + (*(opt->assign))(value); + return FALSE; +} + + +#ifdef HAVE_LIBREADLINE + +/* initialize_pager --- initialize our idea of the terminal size */ + +void +initialize_pager(FILE *fp) +{ + if (! os_isatty(fileno(fp)) || ! input_from_tty || input_fd != 0) { + screen_width = INT_MAX; + screen_height = INT_MAX; + } else { + /* get the terminal size from readline. */ + + rl_reset_terminal(NULL); /* N.B.: NULL argument means + * "use TERM env variable for terminal name". + */ + rl_get_screen_size(&screen_height, &screen_width); + if (screen_height <= 1) + screen_height = INT_MAX; + if (screen_width <= 1) + screen_width = INT_MAX; + } + pager_lines_printed = 0; +} +#endif + +static void +prompt_continue(FILE *fp) +{ + int quit_pager = FALSE; + + if (os_isatty(fileno(fp)) && input_fd == 0) + quit_pager = prompt_yes_no( + _("\t------[Enter] to continue or q [Enter] to quit------"), + _("q")[0], FALSE, fp); + if (quit_pager) + longjmp(pager_quit_tag, 1); + pager_lines_printed = 0; +} + +/* gprintf --- like fprintf but allows paging */ + +int +gprintf(FILE *fp, const char *format, ...) +{ + va_list args; + static char *buf = NULL; + static size_t buflen = 0; + static int bl = 0; + char *p, *q; + int nchar; + +#define GPRINTF_BUFSIZ 512 + if (buf == NULL) { + buflen = GPRINTF_BUFSIZ; + emalloc(buf, char *, (buflen + 2) * sizeof(char), "gprintf"); + } else if (buflen - bl < GPRINTF_BUFSIZ/2) { + buflen += GPRINTF_BUFSIZ; + erealloc(buf, char *, (buflen + 2) * sizeof(char), "gprintf"); + } +#undef GPRINTF_BUFSIZ + + while (TRUE) { + va_start(args, format); + nchar = vsnprintf(buf + bl, buflen - bl, format, args); + va_end(args); + if (nchar == 0) + return 0; + if (nchar > 0 && nchar < buflen - bl) { + bl += nchar; + if (buf[bl-1] != '\n') /* buffer output until see a newline at end */ + return nchar; + break; + } + + /* enlarge buffer, and try again */ + buflen *= 2; + erealloc(buf, char *, (buflen + 2) * sizeof(char), "gprintf"); + } + + bl = 0; + for (p = buf; (q = strchr(p, '\n')) != NULL; p = q + 1) { + int sz = (int) (q - p); + + while (sz > 0) { + int cnt; + cnt = sz > screen_width ? screen_width : sz; + + /* do not print partial line before scrolling */ + if (cnt < sz && (pager_lines_printed == (screen_height - 2))) + prompt_continue(fp); + + if (fwrite(p, sizeof(char), cnt, fp) != cnt) + return -1; + if (cnt == sz) + break; + else { + if (++pager_lines_printed == (screen_height - 1)) + prompt_continue(fp); + sz -= screen_width; + assert(sz > 0); + p += cnt; + } + } + + fprintf(fp, "\n"); + if (++pager_lines_printed == (screen_height - 1)) + prompt_continue(fp); + p++; + } + return nchar; +} + + +static int +serialize_subscript(char *buf, int buflen, struct list_item *item) +{ + int bl = 0, nchar, i; + NODE *sub; + + nchar = snprintf(buf, buflen, "%d%c%d%c%s%c%d%c", + item->number, FSEP, D_subscript, FSEP, item->sname, FSEP, + item->num_subs, FSEP); + if (nchar <= 0) + return 0; + else if (nchar >= buflen) /* need larger buffer */ + return nchar; + bl += nchar; + for (i = 0; i < item->num_subs; i++) { + sub = item->subs[i]; + nchar = snprintf(buf + bl, buflen - bl, "%lu%c%s%c", + (unsigned long) sub->stlen, FSEP, sub->stptr, FSEP); + if (nchar <= 0) + return 0; + bl += nchar; + if (bl >= buflen) /* need larger buffer */ + return bl; + } + return bl; +} + + + +/* serialize --- convert a list structure to a byte stream and + * save in environment. + */ + +static void +serialize(int type) +{ +#ifndef HAVE_LIBREADLINE +#define HIST_ENTRY void +#define history_list() NULL +#endif + + static char *buf = NULL; + static int buflen = 0; + int bl; + BREAKPOINT *b = NULL; + struct list_item *wd = NULL; + HIST_ENTRY **hist_list = NULL; + int hist_index = 0; + struct dbg_option *opt = NULL; + struct commands_item *commands = NULL, *c; + int cnum = 0; + struct condition *cndn = NULL; + void *ptr, *end_ptr; +#ifdef HAVE_LIBREADLINE + HIST_ENTRY *h = NULL; +#endif + + switch (type) { + case BREAK: + end_ptr = (void *) &breakpoints; + ptr = (void *) breakpoints.prev; + break; + case WATCH: + end_ptr = (void *) &watch_list; + ptr = (void *) watch_list.prev; + break; + case DISPLAY: + end_ptr = (void *) &display_list; + ptr = (void *) display_list.prev; + break; + case HISTORY: + hist_list = history_list(); + if (hist_list == NULL) /* empty history list */ + return; + end_ptr = NULL; + ptr = (void *) hist_list[0]; + break; + case OPTION: + { + int n; + n = sizeof(option_list)/sizeof(option_list[0]); + end_ptr = (void *) &option_list[n - 1]; + ptr = (void *) option_list; + } + break; + + default: + return; + } + + if (type != HISTORY && ptr == end_ptr) /* empty list */ + return; + +#define SERIALIZE_BUFSIZ 512 + + if (buf == NULL) { /* first time */ + buflen = SERIALIZE_BUFSIZ; + emalloc(buf, char *, buflen + 2, "serialize"); + } + bl = 0; + + while (ptr != end_ptr) { + int nchar = 0; + if (buflen - bl < SERIALIZE_BUFSIZ/2) { +enlarge_buffer: + buflen *= 2; + erealloc(buf, char *, buflen + 2, "serialize"); + } + +#undef SERIALIZE_BUFSIZ + + /* field seperator is FSEP ('\037'), and the record separator is RSEP ('\036') */ + + switch (type) { + case BREAK: + b = (BREAKPOINT *) ptr; + + /* src source_line flags ignore_count hit_count number; + * commands and condition processed later in the end switch + */ + + nchar = snprintf(buf + bl, buflen - bl, + "%s%c%d%c%d%c%d%c%d%c%d%c", + b->src, FSEP, b->bpi->source_line, FSEP, b->flags, FSEP, + (int) b->ignore_count, FSEP, + (int) b->hit_count, FSEP, b->number, FSEP); + cnum = b->number; + commands = &b->commands; + cndn = &b->cndn; + break; + case DISPLAY: + case WATCH: + wd = (struct list_item *) ptr; + + /* subscript -- number type sname num_subs subs(stlen + stptr) [commands [condition]] + * variable -- number type sname [commands [condition]] + * field -- number type symbol(numbr) [commands [condition]] + */ + + if (IS_PARAM(wd)) /* exclude parameters */ + nchar = 0; + else if (IS_SUBSCRIPT(wd)) + nchar = serialize_subscript(buf + bl, buflen - bl, wd); + else if (IS_FIELD(wd)) + nchar = snprintf(buf + bl, buflen - bl, "%d%c%d%c%d%c", + wd->number, FSEP, D_field, FSEP, (int) wd->symbol->numbr, FSEP); + else + nchar = snprintf(buf + bl, buflen - bl, "%d%c%d%c%s%c", + wd->number, FSEP, D_variable, FSEP, wd->sname, FSEP); + cnum = wd->number; + commands = &wd->commands; + cndn = &wd->cndn; + break; + case HISTORY: +#ifdef HAVE_LIBREADLINE + h = (HIST_ENTRY *) ptr; + nchar = strlen(h->line); + if (nchar >= buflen - bl) + goto enlarge_buffer; + strcpy(buf + bl, h->line); +#endif + break; + case OPTION: + opt = (struct dbg_option *) ptr; + if (opt->num_val != NULL) + nchar = snprintf(buf + bl, buflen - bl, + "%s%c%d%c", opt->name, FSEP, *(opt->num_val), FSEP); + else + nchar = snprintf(buf + bl, buflen - bl, + "%s%c%s%c", opt->name, FSEP, *(opt->str_val), FSEP); + break; + default: + break; + } + + if (nchar == 0) /* skip empty history lines etc.*/ + ; + else if (nchar > 0 && nchar < buflen - bl) { + bl += nchar; + buf[bl] = RSEP; /* record */ + buf[++bl] = '\0'; + } else + goto enlarge_buffer; + + switch (type) { + case BREAK: + case WATCH: + /* recreate the `commands' command strings including the `commands' + * and `end' commands; command seperator is '\034'. + * re-parsed in unserialize to recover the commands list. + * Alternatively, one could encode(serialize) each command and it's arguments. + */ + + bl--; /* undo RSEP from above */ + + /* compute required room in buffer */ + nchar = 0; + for (c = commands->next; c != commands; c = c->next) { + nchar += (strlen(c->cmd_string) + 1); + if (c->cmd == D_eval) { + CMDARG *a = c->arg; + nchar += (strlen(a->a_string) + 1); /* awk statements */ + nchar += (strlen("end") + 1); + } + } + + if (nchar > 0) { /* non-empty commands list */ + nchar += (strlen("commands ") + 20 + strlen("end") + 2); /* 20 for cnum (an int) */ + if (nchar > buflen - bl) { + buflen = bl + nchar; + erealloc(buf, char *, buflen + 3, "serialize"); + } + nchar = sprintf(buf + bl, "commands %d", cnum); + bl += nchar; + buf[bl++] = CSEP; + for (c = commands->next; c != commands; c = c->next) { + nchar = strlen(c->cmd_string); + memcpy(buf + bl, c->cmd_string, nchar); + bl += nchar; + buf[bl++] = CSEP; + + if (c->cmd == D_eval) { + CMDARG *a = c->arg; + nchar = strlen(a->a_string); /* statements */ + memcpy(buf + bl, a->a_string, nchar); + bl += nchar; + buf[bl++] = CSEP; + nchar = strlen("end"); /* end of 'eval' */ + memcpy(buf + bl, "end", nchar); + bl += nchar; + buf[bl++] = CSEP; + } + } + nchar = strlen("end"); /* end of 'commands' */ + memcpy(buf + bl, "end", nchar); + bl += nchar; + } + buf[bl++] = FSEP; /* field */ + buf[bl++] = RSEP; /* record */ + buf[bl] = '\0'; + + /* condition expression */ + if (cndn->expr) { + bl--; /* undo RSEP from above */ + nchar = strlen(cndn->expr); + if (nchar > buflen - bl) { + buflen = bl + nchar; + erealloc(buf, char *, buflen + 3, "serialize"); + } + memcpy(buf + bl, cndn->expr, nchar); + bl += nchar; + buf[bl++] = FSEP; /* field */ + buf[bl++] = RSEP; /* record */ + buf[bl] = '\0'; + } + + ptr = (type == BREAK) ? (void *) b->prev : (void *) wd->prev; + break; + case DISPLAY: + ptr = (void *) wd->prev; + break; + case HISTORY: + ptr = (void *) hist_list[++hist_index]; + break; + case OPTION: + ptr = (void *) (++opt); + break; + default: + break; + } + } + + if (bl > 0) /* non-empty list */ + setenv(env_variable[type], buf, 1); +} + + +static void +unserialize_commands(char *str, int str_len) +{ + if (str_len <= 0 || str == NULL) + return; + commands_string = str; + commands_string_len = str_len; + push_cmd_src(INVALID_HANDLE, FALSE, read_commands_string, 0, 0, EXIT_FATAL); + line_sep = CSEP; + read_command(); /* forced to return in do_commands */ + pop_cmd_src(); +} + + +/* unserialize_list_item --- create a list_item structure from unserialized data */ + +static struct list_item * +unserialize_list_item(struct list_item *list, char **pstr, int *pstr_len, int field_cnt) +{ + int num, type, i; + struct list_item *l; + NODE *symbol = NULL; + int sub_cnt = 0, cnt; + NODE **subs = NULL; + + /* subscript -- number type sname num_subs subs [commands [condition]] + * variable -- number type sname [commands [condition]] + * field -- number type symbol(numbr) commands [commands [condition]] + */ + + num = strtol(pstr[0], NULL, 0); + type = strtol(pstr[1], NULL, 0); + + if (type == D_field) { + int field_num; + field_num = strtol(pstr[2], NULL, 0); + symbol = make_number((AWKNUM) field_num); + cnt = 3; + } else { + char *name; + name = estrdup(pstr[2], pstr_len[2]); + symbol = find_symbol(name, NULL); + efree(name); + if (symbol == NULL) + return NULL; + cnt = 3; + if (type == D_subscript) { + int sub_len; + sub_cnt = strtol(pstr[3], NULL, 0); + emalloc(subs, NODE **, sub_cnt * sizeof(NODE *), "unserialize_list_item"); + cnt++; + for (i = 0; i < sub_cnt; i++) { + sub_len = strtol(pstr[cnt], NULL, 0); + subs[i] = make_string(pstr[cnt + 1], sub_len); + cnt += 2; + } + } + } + + l = add_item(list, type, symbol, NULL); + if (type == D_subscript) { + l->num_subs = sub_cnt; + l->subs = subs; + } + l->number = num; /* keep same item number across executions */ + + if (list == &watch_list) { + initialize_watch_item(l); + /* unserialize watchpoint `commands' */ + unserialize_commands(pstr[cnt], pstr_len[cnt]); + cnt++; + if (field_cnt > cnt) { + char *expr; + expr = estrdup(pstr[cnt], pstr_len[cnt]); + if (parse_condition(D_watch, l->number, expr) != 0) + efree(expr); + } + if (num > list->number) /* update list number counter */ + list->number = num; + } else + list->number = num; + + return l; +} + +/* unserialize_breakpoint --- create a breakpoint structure from unserialized data */ + +static BREAKPOINT * +unserialize_breakpoint(char **pstr, int *pstr_len, int field_cnt) +{ + char *src; + int lineno; + BREAKPOINT *b = NULL; + INSTRUCTION *rp; + SRCFILE *s; + + /* src source_line flags ignore_count hit_count number commands [condition] */ + + src = estrdup(pstr[0], pstr_len[0]); + s = source_find(src); + efree(src); + if (s == NULL) + return NULL; + src = s->src; + lineno = strtol(pstr[1], NULL, 0); + if (lineno <= 0 || lineno > s->srclines) + return NULL; + rp = find_rule(src, lineno); + if (rp == NULL + || (b = set_breakpoint_at(rp, lineno, TRUE)) == NULL + ) + return NULL; + + b->flags = strtol(pstr[2], NULL, 0); + b->ignore_count = strtol(pstr[3], NULL, 0); + b->hit_count = strtol(pstr[4], NULL, 0); + b->number = strtol(pstr[5], NULL, 0); /* same number as previous run */ + + if (field_cnt > 6) /* unserialize breakpoint `commands' */ + unserialize_commands(pstr[6], pstr_len[6]); + + if (field_cnt > 7) { /* condition expression */ + char *expr; + expr = estrdup(pstr[7], pstr_len[7]); + if (parse_condition(D_break, b->number, expr) != 0) + efree(expr); + } + + if (b->number > watch_list.number) /* watch and break has same number counter */ + watch_list.number = b->number; /* update counter */ + return b; +} + +/* unserialize_option --- set a debugger option from unserialized data. */ + +static struct dbg_option * +unserialize_option(char **pstr, int *pstr_len, int field_cnt ATTRIBUTE_UNUSED) +{ + const struct dbg_option *opt; + + for (opt = option_list; opt->name; opt++) { + if (strncmp(pstr[0], opt->name, pstr_len[0]) == 0) { + char *value; + + value = estrdup(pstr[1], pstr_len[1]); + (*(opt->assign))(value); + efree(value); + return ((struct dbg_option *) opt); + } + } + return NULL; +} + +/* unserialize -- reconstruct list from serialized data stored in + * environment variable. + */ + +static void +unserialize(int type) +{ + char *val; + char *p, *q, *r, *s; +#define MAX_FIELD 30 + static char *pstr[MAX_FIELD]; + static int pstr_len[MAX_FIELD]; + + val = getenv(env_variable[type]); + if (val == NULL) + return; + + for (p = val; (q = strchr(p, RSEP)) != NULL; p = q + 1) { + int field_cnt = 0; + if (type == HISTORY) { + *q = '\0'; + add_history(p); + *q = RSEP; + continue; + } + + r = p; + while ((s = strchr(r, FSEP)) != NULL && s < q) { + pstr[field_cnt] = r; + pstr_len[field_cnt] = (int) (s - r); + r = s + 1; + field_cnt++; + if (field_cnt == MAX_FIELD) +#ifdef GAWKDEBUG + fatal("Increase MAX_FIELD and recompile.\n"); +#else + return; +#endif + } + + switch (type) { + case BREAK: + (void) unserialize_breakpoint(pstr, pstr_len, field_cnt); + break; + case DISPLAY: + (void) unserialize_list_item(&display_list, pstr, pstr_len, field_cnt); + break; + case WATCH: + (void) unserialize_list_item(&watch_list, pstr, pstr_len, field_cnt); + break; + case OPTION: + (void) unserialize_option(pstr, pstr_len, field_cnt); + break; + case HISTORY: + /* processed at the beginning of for loop */ + break; + default: + break; + } + } + +#ifdef HAVE_LIBREADLINE + if (type == HISTORY) + sess_history_base = history_length; +#endif + + unsetenv(env_variable[type]); +#undef MAX_FIELD +} + +static int +prompt_yes_no(const char *mesg, char res_true, int res_default, FILE *fp) +{ + char *in_str; + int ret = res_default; /* default */ + + if (input_from_tty) { + fprintf(fp, "%s", _(mesg)); + in_str = read_a_line(NULL); + if (in_str == NULL) /* EOF */ + exit(EXIT_FAILURE); + ret = (*in_str == res_true); + efree(in_str); + } + return ret; +} + +/* has_break_or_watch_point --- check if given breakpoint or watchpoint + * number exists. When flag any is TRUE, + * check if any breakpoint/watchpoint + * has been set (ignores num). Returns + * type (breakpoint or watchpoint) or 0. + */ + +int +has_break_or_watch_point(int *pnum, int any) +{ + BREAKPOINT *b = NULL; + struct list_item *w = NULL; + + if (any) { + if (breakpoints.next != &breakpoints) + b = breakpoints.next; + if (watch_list.next != &watch_list) + w = watch_list.next; + + if (! b && ! w) + return 0; + if (b && ! w) { + *pnum = b->number; + return D_break; + } + if (w && ! b) { + *pnum = w->number; + return D_watch; + } + if (w->number > b->number) { + *pnum = w->number; + return D_watch; + } + *pnum = b->number; + return D_break; + } + + /* N.B: breakpoints and watchpoints get numbers from a single + * counter/sequencer watch_list.number. + */ + + for (b = breakpoints.next; b != &breakpoints; b = b->next) { + if (b->number == *pnum) + return D_break; + } + for (w = watch_list.next; w != &watch_list; w = w->next) { + if (w->number == *pnum) + return D_watch; + } + + return 0; +} + +/* delete_commands_item --- delete item(command) from `commands' list. */ + +static void +delete_commands_item(struct commands_item *c) +{ + efree(c->cmd_string); + free_cmdarg(c->arg); + c->next->prev = c->prev; + c->prev->next = c->next; + efree(c); +} + +/* do_commands --- commands command */ + +int +do_commands(CMDARG *arg, int cmd) +{ + static BREAKPOINT *b; + static struct list_item *w; + static struct commands_item *commands; + struct commands_item *c; + + if (cmd == D_commands) { + int num, type; + if (arg == NULL) + type = has_break_or_watch_point(&num, TRUE); + else { + num = arg->a_int; + type = has_break_or_watch_point(&num, FALSE); + } + b = NULL; + w = NULL; + if (type == D_break) + b = find_breakpoint(num); + else if (type == D_watch) + w = find_item(&watch_list, num); + assert((b != NULL) || (w != NULL)); + commands = (b != NULL) ? &b->commands : &w->commands; + + /* delete current commands */ + for (c = commands->next; c != commands; c = c->next) { + c = c->prev; + delete_commands_item(c->next); + } + return FALSE; + + } else if (cmd == D_end) { + commands = NULL; + if (read_a_line == read_commands_string) /* unserializig commands */ + return TRUE; /* done unserializing, terminate zzparse() */ + return FALSE; + + } else if (cmd == D_silent) { + if (b != NULL) + b->silent = TRUE; + else if (w != NULL) + w->silent = TRUE; + /* we also append silent command to the list for use + * in `info break(watch)', and to simplify + * serialization/unserialization of commands. + */ + } + + assert(commands != NULL); + + emalloc(c, struct commands_item *, sizeof(struct commands_item), "do_commands"); + c->next = NULL; + c->cmd = cmd; + + /* N.B.: first arg is the command string, see command.y */ + c->cmd_string = arg->a_string; + c->arg = arg->next; /* actual arguments to the command */ + efree(arg); + + /* append to the list */ + c->prev = commands->prev; + c->next = commands; + commands->prev = c; + c->prev->next = c; + return FALSE; +} + +/* execute_commands --- execute breakpoint/watchpoint commands, the first + * command that resumes execution terminates + * commands processing. + */ + +static int +execute_commands(struct commands_item *commands) +{ + struct commands_item *c; + Func_cmd cmd_ptr; + int ret = FALSE; + + for (c = commands->next; c != commands; c = c->next) { + if (c->cmd == D_silent) + continue; + cmd_ptr = get_command(c->cmd); /* command handler */ + ret = (*cmd_ptr)(c->arg, c->cmd); + if (ret) /* resume execution (continue, next etc.) */ + break; + } + return ret; +} + +/* do_print_f --- printf command */ + +int +do_print_f(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + int count = 0; + int i; + CMDARG *a; + NODE **tmp; + char *name; + NODE *r; + volatile jmp_buf fatal_tag_stack; + + /* count maximum required size for tmp */ + for (a = arg; a != NULL ; a = a->next) + count++; + emalloc(tmp, NODE **, count * sizeof(NODE *), "do_print_f"); + + for (i = 0, a = arg; a != NULL ; i++, a = a->next) { + switch (a->type) { + case D_variable: + name = a->a_string; + r = find_symbol(name, NULL); + if (r == NULL) + goto done; + if (r->type == Node_var_new) + tmp[i] = Nnull_string; + else if (r->type != Node_var) { + d_error(_("`%s' is not a scalar variable"), name); + goto done; + } else + tmp[i] = r->var_value; + break; + case D_field: + { + long field_num; + r = a->a_node; + field_num = (long) r->numbr; + tmp[i] = *get_field(field_num, NULL); + } + break; + case D_subscript: + { + int cnt = a->a_count; + name = a->a_string; + r = find_array(name); + if (r == NULL) + goto done; + + for (; cnt > 0; cnt--) { + NODE *value, *subs; + a = a->next; + subs = a->a_node; + value = in_array(r, subs); + if (cnt == 1) { + if (value == NULL) + tmp[i] = Nnull_string; /* FIXME: goto done ? */ + else if (value->type == Node_var_array) { + d_error(_("attempt to use array `%s[\"%s\"]' in a scalar context"), + name, subs->stptr); + goto done; + } else + tmp[i] = value; + } else { + if (value == NULL) { + d_error(_("[\"%s\"] not in array `%s'"), + subs->stptr, name); + goto done; + } else if (value->type != Node_var_array) { + d_error(_("attempt to use scalar `%s[\"%s\"]' as array"), + name, subs->stptr); + goto done; + } else { + r = value; + name = r->vname; + } + } + } + } + break; + case D_node: + tmp[i] = a->a_node; + break; + default: + break; + } + } + + force_string(tmp[0]); + + PUSH_BINDING(fatal_tag_stack, fatal_tag, fatal_tag_valid); + if (setjmp(fatal_tag) == 0) + r = format_tree(tmp[0]->stptr, tmp[0]->stlen, tmp, i); + else { + /* fatal error, restore exit_val of program */ + exit_val = EXIT_SUCCESS; + r = NULL; + } + POP_BINDING(fatal_tag_stack, fatal_tag, fatal_tag_valid); + + if (r != NULL) { + (void) fwrite(r->stptr, sizeof(char), r->stlen, out_fp); + unref(r); + } +done: + efree(tmp); + return FALSE; +} + +/* do_source --- source command */ + +int +do_source(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + int fd; + char *file = arg->a_string; + + fd = open_readfd(file); + if (fd <= INVALID_HANDLE) { + d_error(_("can't open source file `%s' for reading (%s)"), + file, strerror(errno)); + return FALSE; + } + + push_cmd_src(fd, FALSE, g_readline, close, D_source, EXIT_SUCCESS); + cmd_src->str = estrdup(file, strlen(file)); + return FALSE; +} + +/* open_readfd --- open a file for reading */ + +static int +open_readfd(const char *file) +{ + int fd; + + fd = open(file, O_RDONLY); + if (fd <= INVALID_HANDLE) + return INVALID_HANDLE; + else if (os_isdir(fd)) { + (void) close(fd); + errno = EISDIR; + return INVALID_HANDLE; + } + return fd; +} + +/* find_option --- check if option name is valid */ + +int +find_option(char *name) +{ + const char *p; + int idx; + + for (idx = 0; (p = option_list[idx].name); idx++) { + if (strcmp(p, name) == 0) + return idx; + } + return -1; +} + +/* option_help --- display help text for debugger options */ + +void +option_help() +{ + const struct dbg_option *opt; + + for (opt = option_list; opt->name; opt++) + fprintf(out_fp, "\t%-15.15s - %s\n", opt->name, _(opt->help_txt)); +} + +#ifdef HAVE_LIBREADLINE + +/* option_generator --- generator function for option name completion */ + +char * +option_generator(const char *text, int state) +{ + static size_t textlen; + static int idx; + const char *name; + + if (! state) { /* first time */ + textlen = strlen(text); + idx = 0; + } + + while ((name = option_list[idx++].name)) { + if (strncmp(name, text, textlen) == 0) + return estrdup(name, strlen(name)); + } + return NULL; +} + +#endif + +/* set_gawk_output --- redirect gawk (normal) output */ + +static void +set_gawk_output(const char *file) +{ + int fd = INVALID_HANDLE; + FILE *fp = NULL; + + if (output_fp != stdout) { + if (output_fp != stderr) { + fclose(output_fp); + efree(output_file); + } + output_fp = stdout; + output_is_tty = os_isatty(fileno(stdout)); + output_file = "/dev/stdout"; + } + + if (file == NULL || file[0] == '\0') + return; + + errno = 0; + if ((fd = os_devopen(file, O_WRONLY)) != INVALID_HANDLE) { + fp = fdopen(fd, "w"); + if (fp == NULL) + close(fd); + + } else if (strncmp(file, "/dev/", 5) == 0) { + char *cp = (char *) file + 5; + + if (strcmp(cp, "stdout") == 0) + return; + if (strcmp(cp, "stderr") == 0) { + output_fp = stderr; + output_file = "/dev/stderr"; + output_is_tty = os_isatty(fileno(stderr)); + return; + } + + if (strncmp(cp, "fd/", 3) == 0) { + cp += 3; + fd = (int) strtoul(cp, NULL, 10); + if (errno == 0 && fd > INVALID_HANDLE) { + fp = fdopen(fd, "w"); + if (fp == NULL) + fd = INVALID_HANDLE; + } else + fd = INVALID_HANDLE; + } else { + /* /dev/ttyN, /dev/pts/N, /dev/null etc. */ + fd = open(file, O_WRONLY); + } + + if (fd > INVALID_HANDLE && fp == NULL) { + fp = fdopen(fd, "w"); + if (fp == NULL) + close(fd); + } + + } else { + /* regular file */ + fp = fopen(file, "w"); + } + + if (fp != NULL) { + output_fp = fp; + output_file = estrdup(file, strlen(file)); + setbuf(fp, (char *) NULL); + output_is_tty = os_isatty(fileno(fp)); + } else { + d_error(_("could not open `%s' for writing (%s)"), + file, + errno != 0 ? strerror(errno) : _("reason unknown")); + fprintf(out_fp, _("sending output to stdout\n")); + } +} + +/* set_prompt --- set debugger prompt */ + +static void +set_prompt(const char *value) +{ + efree(dgawk_Prompt); + dgawk_Prompt = estrdup(value, strlen(value)); + dPrompt = dgawk_Prompt; +} + +/* set_option_flag --- convert option string to flag value */ + +static int +set_option_flag(const char *value) +{ + long n; + if (strcmp(value, "on") == 0) + return TRUE; + if (strcmp(value, "off") == 0) + return FALSE; + errno = 0; + n = strtol(value, NULL, 0); + return (errno == 0 && n != 0); +} + +/* set_option_num --- set integer option value from string */ + +static void +set_option_num(int *pnum, const char *value) +{ + long n; + errno = 0; + n = strtol(value, NULL, 0); + if (errno == 0 && n > 0) + *pnum = n; + else + d_error(_("invalid number")); +} + +/* set_listsize --- set list output window size */ + +static void +set_listsize(const char *value) +{ + set_option_num(&list_size, value); +} + +/* set_trace --- set instruction tracing on or off */ + +static void +set_trace(const char *value) +{ + do_trace = set_option_flag(value); +} + +/* set_save_history --- save history on exit */ + +static void +set_save_history(const char *value) +{ + do_save_history = set_option_flag(value); +} + +/* set_save_options --- save options on exit */ + +static void +set_save_options(const char *value) +{ + do_save_options = set_option_flag(value); +} + +/* set_history_size --- maximum entries in history file */ + +static void +set_history_size(const char *value) +{ + set_option_num(&history_size, value); +} + + +/* read_commands_string --- one of the many ways zzlex fetches a line to parse; + * this one is used to parse `commands' string during + * unserialization. + */ + +char * +read_commands_string(const char *prompt ATTRIBUTE_UNUSED) +{ + char *p, *end, *line; + + if (commands_string == NULL) + return NULL; + + p = (char *) commands_string; + end = (char *) commands_string + commands_string_len; + for (; p < end; p++) { + if (*p == line_sep) { + line = estrdup(commands_string, p - commands_string); + commands_string = p + 1; + commands_string_len = end - commands_string; + return line; + } + } + + line = estrdup(commands_string, commands_string_len); + commands_string = NULL; + commands_string_len = 0; + return line; +} + +/* save_options --- save current options to file */ + +static void +save_options(const char *file) +{ + FILE *fp; + const struct dbg_option *opt; + + fp = fopen(file, "w"); + if (fp == NULL) + return; + + for (opt = option_list; opt->name; opt++) { + if (opt->str_val != NULL) + fprintf(fp, "option %s = \"%s\"\n", opt->name, *(opt->str_val)); + else + fprintf(fp, "option %s = %d\n", opt->name, *(opt->num_val)); + } + fclose(fp); + chmod(file, 0600); +} + +/* close_all --- close all open files */ + +static void +close_all() +{ + int stdio_problem; + struct command_source *cs; + + (void) nextfile(&curfile, TRUE); /* close input data file */ + (void) close_io(&stdio_problem); + if (cur_srcfile->fd != INVALID_HANDLE) { + close(cur_srcfile->fd); + cur_srcfile->fd = INVALID_HANDLE; + } + for (cs = cmd_src; cs != NULL; cs = cs->next) { + if (cs->close_func && cs->fd != INVALID_HANDLE) { + cs->close_func(cs->fd); + cs->fd = INVALID_HANDLE; + } + } + + set_gawk_output(NULL); /* closes output_fp if not stdout */ +} + +/* install_params --- install function parameters into the symbol table */ + +static void +install_params(NODE *func) +{ + NODE *np; + + if (func == NULL) + return; + /* function parameters of type Node_param_list */ + np = func->lnode; + for (np = np->rnode; np != NULL; np = np->rnode) + install_symbol(np->param, np); +} + +/* remove_params --- remove function parameters out of the symbol table */ + +static void +remove_params(NODE *func) +{ + NODE *np; + + if (func == NULL) + return; + np = func->lnode; + for (np = np->rnode; np != NULL; np = np->rnode) + remove_symbol(np->param); +} + +/* pre_execute_code --- pre_hook for execute_code, called by pre_execute */ + +static int +pre_execute_code(INSTRUCTION **pi) +{ + INSTRUCTION *ei = *pi; + + switch (ei->opcode) { + case Op_K_exit: + case Op_K_next: + case Op_K_nextfile: + case Op_K_getline: /* getline without redirection */ + d_error(_("`%s' not allowed in current context;" + " statement ignored"), + op2str(ei->opcode)); + *pi = ei->nexti; + break; + case Op_K_return: + if (ei->nexti != NULL) { /* not an implicit return */ + NODE *r; + d_error(_("`return' not allowed in current context;" + " statement ignored")); + /* throw away return value already pushed onto stack */ + r = POP_SCALAR(); + DEREF(r); + *pi = ei->nexti; + } + break; + default: + break; + } + return (ei == *pi); +} + +extern INSTRUCTION *unwind_stack(long n); + +static NODE * +execute_code(volatile INSTRUCTION *code) +{ + volatile NODE *r = NULL; + volatile jmp_buf fatal_tag_stack; + long save_stack_size; + + /* We use one global stack for all contexts. + * Save # of items in stack; in case of + * a fatal error, pop stack until it has that many items. + */ + save_stack_size = (stack_ptr - stack_bottom) + 1; + + PUSH_BINDING(fatal_tag_stack, fatal_tag, fatal_tag_valid); + if (setjmp(fatal_tag) == 0) { + (void) r_interpret((INSTRUCTION *) code); + r = POP_SCALAR(); + } else /* fatal error */ + (void) unwind_stack(save_stack_size); + + POP_BINDING(fatal_tag_stack, fatal_tag, fatal_tag_valid); + + if (exit_val != EXIT_SUCCESS) { /* must be EXIT_FATAL? */ + exit_val = EXIT_SUCCESS; + return NULL; + } + return (NODE *) r; +} + +/* do_eval --- eval command */ + +int +do_eval(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + NODE *r, *ret_val; + NODE *f = NULL; + NODE *this_frame = NULL, *this_func = NULL; + NODE **sp; + INSTRUCTION *eval, *code = NULL; + AWK_CONTEXT *ctxt; + char **save_parmlist = NULL; + int ecount = 0, pcount = 0; + int ret; + + if (prog_running) { + this_frame = find_frame(0); + this_func = this_frame->func_node; + } + + install_params(this_func); /* expose current function parameters to eval */ + ctxt = new_context(); + ctxt->install_func = append_symbol; /* keep track of newly installed globals */ + push_context(ctxt); + (void) add_srcfile(SRC_CMDLINE, arg->a_string, srcfiles, NULL, NULL); + ret = parse_program(&code); + remove_params(this_func); + if (ret != 0) { + pop_context(); /* switch to prev context */ + free_context(ctxt, FALSE /* keep_globals */); + return FALSE; + } + + f = lookup("@eval"); + assert(f != NULL); + if (this_func == NULL) { /* in main */ + /* do a function call */ + eval = bcalloc(Op_func_call, 2, 0); + eval->source_file = cur_srcfile->src; + eval->func_body = f; + eval->func_name = NULL; /* not needed, func_body already assigned */ + (eval + 1)->expr_count = 0; + eval->nexti = bcalloc(Op_stop, 1, 0); + + } else { + /* execute as a part of the current function */ + int i; + char **varnames; + INSTRUCTION *t; + NODE *np; + + eval = f->code_ptr; /* Op_func */ + eval->source_file = cur_srcfile->src; + /* turn implicit Op_K_return into Op_stop */ + t = (eval + 1)->lasti; /* Op_K_return */ + t->opcode = Op_stop; + + /* add or append eval locals to the current frame stack */ + ecount = f->lnode->param_cnt; /* eval local count */ + pcount = this_func->lnode->param_cnt; + save_parmlist = this_func->parmlist; + + if (ecount > 0) { + if (pcount == 0) + emalloc(this_frame->stack, NODE **, ecount * sizeof(NODE *), "do_eval"); + else + erealloc(this_frame->stack, NODE **, (pcount + ecount) * sizeof(NODE *), "do_eval"); + + emalloc(varnames, char **, (pcount + ecount + 1) * sizeof(char *), "do_eval"); + if (pcount > 0) + memcpy(varnames, save_parmlist, pcount * sizeof(char *)); + for (np = f->lnode->rnode, i = 0; np != NULL; np = np->rnode, i++) { + varnames[pcount + i] = np->param; + np->param_cnt += pcount; /* appending eval locals: fixup param_cnt */ + } + varnames[pcount + ecount] = NULL; + sp = this_frame->stack + pcount; + for (i = 0; i < ecount; i++) { + getnode(r); + memset(r, 0, sizeof(NODE)); + *sp++ = r; + /* local variable */ + r->type = Node_var_new; + r->vname = varnames[pcount + i]; + } + + this_func->parmlist = varnames; + this_func->lnode->param_cnt += ecount; + } + } + +#if 0 + pf_data.print_func = fprintf; + pf_data.fp = out_fp; + pf_data.defn = FALSE; /* in_dump = FALSE */ + (void) print_code(f->code_ptr, &pf_data); +#endif + + ret_val = execute_code((volatile INSTRUCTION *) eval); + + if (ret_val != NULL) + DEREF(ret_val); /* throw away return value */ + /* else + fatal error */ + + if (this_func != NULL && ecount > 0) { + int i; + + /* undo frame manipulation from above */ + + /* free eval locals */ + sp = this_frame->stack + pcount; + for (i = ecount; i > 0; i--) { + r = *sp; + if (r->type == Node_var) /* eval local variable */ + DEREF(r->var_value); + else if (r->type == Node_var_array) /* eval local array */ + assoc_clear(r); + freenode(r); + *sp++ = (NODE *) 0; + } + if (pcount == 0) { + efree(this_frame->stack); + this_frame->stack = NULL; + } /* else + restore_frame() will free it */ + + efree(this_func->parmlist); + this_func->parmlist = save_parmlist; + this_func->lnode->param_cnt -= ecount; + } + + /* always destroy symbol "@eval", however destroy all newly installed + * globals only if fatal error in r_interpret (r == NULL). + */ + + pop_context(); /* switch to prev context */ + free_context(ctxt, (ret_val != NULL)); /* free all instructions and optionally symbols */ + if (ret_val != NULL) + destroy_symbol("@eval"); /* destroy "@eval" */ + return FALSE; +} + +/* +GDB Documentation: + ... When you use condition, GDB checks expression +immediately for syntactic correctness, and to determine whether symbols +in it have referents in the context of your breakpoint. If expression +uses symbols not referenced in the context of the breakpoint, GDB prints +an error message: + + No symbol "foo" in current context. +*/ + +static int invalid_symbol = 0; + +void +check_symbol(char *name) +{ + invalid_symbol++; + d_error(_("No symbol `%s' in current context"), name); + /* install anyway, but keep track of it */ + append_symbol(name); +} + +/* parse_condition --- compile a condition expression */ + +static int +parse_condition(int type, int num, char *expr) +{ + INSTRUCTION *code = NULL; + AWK_CONTEXT *ctxt = NULL; + int ret; + BREAKPOINT *b; + struct list_item *w; + NODE *this_func = NULL; + INSTRUCTION *it, *stop, *rule; + struct condition *cndn = NULL; + + if (type == D_break && (b = find_breakpoint(num)) != NULL) { + INSTRUCTION *rp; + cndn = &b->cndn; + rp = find_rule(b->src, b->bpi->source_line); + if (rp != NULL && rp->opcode == Op_func) + this_func = rp->func_body; + } else if (type == D_watch && (w = find_item(&watch_list, num)) != NULL) { + cndn = &w->cndn; + this_func = find_frame(cur_frame)->func_node; + } + + if (cndn == NULL) + return -1; + if (expr == NULL) + goto out; /* delete condition */ + + install_params(this_func); + ctxt = new_context(); + invalid_symbol = 0; + ctxt->install_func = check_symbol; + push_context(ctxt); + (void) add_srcfile(SRC_CMDLINE, expr, srcfiles, NULL, NULL); + ret = parse_program(&code); + remove_params(this_func); + pop_context(); + + if (ret != 0 || invalid_symbol) { + free_context(ctxt, FALSE /* keep_globals */); + return -1; + } + + /* condition expression is parsed as awk pattern without + * any action. The code is then modified to end up with + * a `1.0' on stack when the expression is true, `0.0' otherwise. + */ + + assert(code != NULL); + rule = ctxt->rule_list.nexti; + stop = bcalloc(Op_stop, 1, 0); + + it = rule->firsti; /* Op_K_print_rec */ + assert(it->opcode == Op_K_print_rec); + it->opcode = Op_push_i; + it->memory = mk_number((AWKNUM) 1.0, PERM|NUMBER|NUMCUR); + it->nexti = bcalloc(Op_jmp, 1, 0); + it->nexti->target_jmp = stop; + it->nexti->nexti = rule->lasti; + + it = rule->lasti; /* Op_no_op, target for Op_jmp_false */ + assert(it->opcode == Op_no_op); + it->opcode = Op_push_i; + it->memory = mk_number((AWKNUM) 0.0, PERM|NUMBER|NUMCUR); + it->nexti = stop; + +out: + if (cndn->expr != NULL) + efree(cndn->expr); + free_context(cndn->ctxt, FALSE); + cndn->code = code; + cndn->expr = expr; + cndn->ctxt = ctxt; + + return 0; +} + +/* do_condition --- condition command */ + +int +do_condition(CMDARG *arg, int cmd ATTRIBUTE_UNUSED) +{ + int type, num; + char *expr = NULL; + + num = arg->a_int; + type = has_break_or_watch_point(&num, FALSE); + if (! type) + return FALSE; + arg = arg->next; /* condition expression */ + if (arg != NULL) + expr = arg->a_string; + if (parse_condition(type, num, expr) == 0 && arg != NULL) + arg->a_string = NULL; /* don't let free_cmdarg free it */ + return FALSE; +} + +/* in_cmd_src --- check if filename already in cmd_src */ + +int +in_cmd_src(const char *filename) +{ + struct command_source *cs; + for (cs = cmd_src; cs != NULL; cs = cs->next) { + if (cs->str != NULL && strcmp(cs->str, filename) == 0) + return TRUE; + } + return FALSE; +} + +int +get_eof_status() +{ + if (cmd_src == NULL) + return EXIT_FATAL; + return cmd_src->eof_status; +} + +void +push_cmd_src( + int fd, + int istty, + char * (*readfunc)(const char *), + int (*closefunc)(int), + int ctype, + int eofstatus) +{ + struct command_source *cs; + emalloc(cs, struct command_source *, sizeof(struct command_source), "push_cmd_src"); + cs->fd = fd; + cs->is_tty = istty; + cs->read_func = readfunc; + cs->close_func = closefunc; + cs->cmd = ctype; + + /* eof_status = EXIT_FATAL - exit with status EXIT_FATAL on EOF or error. + * = EXIT_FAILURE - exit status EXIT_FAILURE on error. + * = EXIT_SUCCESS - don't exit on EOF or error. + */ + cs->eof_status = eofstatus; + cs->str = NULL; + cs->next = cmd_src; + cmd_src = cs; + + input_fd = fd; + input_from_tty = istty; + read_a_line = readfunc; +} + +int +pop_cmd_src() +{ + struct command_source *cs; + + if (cmd_src->next == NULL) + return -1; + + cs = cmd_src; + cmd_src = cs->next; + if (cs->close_func && cs->fd != INVALID_HANDLE) + cs->close_func(cs->fd); + if (cs->str != NULL) + efree(cs->str); + efree(cs); + + input_fd = cmd_src->fd; + input_from_tty = cmd_src->is_tty; + read_a_line = cmd_src->read_func; + return 0; +} diff --git a/depcomp b/depcomp new file mode 100755 index 0000000..ca5ea4e --- /dev/null +++ b/depcomp @@ -0,0 +1,584 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2006-10-15.18 + +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software +# Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +case $1 in + '') + echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by `PROGRAMS ARGS'. + object Object file output by `PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputing dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit $? + ;; +esac + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. +## Unfortunately, FreeBSD c89 acceptance of flags depends upon +## the command line argument order; so add the flags where they +## appear in depend2.am. Note that the slowdown incurred here +## affects only configure: in makefiles, %FASTDEP% shortcuts this. + for arg + do + case $arg in + -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; + *) set fnord "$@" "$arg" ;; + esac + shift # fnord + shift # $arg + done + "$@" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the `deleted header file' problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory +## that the space means something, we add a space to the output as +## well. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like `#:fec' to the end of the + # dependency line. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> $depfile + echo >> $depfile + + # The second pass generates a dummy entry for each header file. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> $depfile + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts `$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` + tmpdepfile="$stripped.u" + if test "$libtool" = yes; then + "$@" -Wc,-M + else + "$@" -M + fi + stat=$? + + if test -f "$tmpdepfile"; then : + else + stripped=`echo "$stripped" | sed 's,^.*/,,'` + tmpdepfile="$stripped.u" + fi + + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + + if test -f "$tmpdepfile"; then + outname="$stripped.o" + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" + sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +icc) + # Intel's C compiler understands `-MD -MF file'. However on + # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c + # ICC 7.0 will fill foo.d with something like + # foo.o: sub/foo.c + # foo.o: sub/foo.h + # which is wrong. We want: + # sub/foo.o: sub/foo.c + # sub/foo.o: sub/foo.h + # sub/foo.c: + # sub/foo.h: + # ICC 7.1 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using \ : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | + sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp2) + # The "hp" stanza above does not work with aCC (C++) and HP's ia64 + # compilers, which have integrated preprocessors. The correct option + # to use with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + # Much of this is similar to the tru64 case; see comments there. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir.libs/$base.d + "$@" -Wc,+Maked + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + "$@" +Maked + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" + # Add `dependent.h:' lines. + sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" "$tmpdepfile2" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + + if test "$libtool" = yes; then + # With Tru64 cc, shared objects can also be used to make a + # static library. This mechanism is used in libtool 1.4 series to + # handle both shared and static libraries in a single compilation. + # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. + # + # With libtool 1.5 this exception was removed, and libtool now + # generates 2 separate objects for the 2 libraries. These two + # compilations output dependencies in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 + tmpdepfile2=$dir$base.o.d # libtool 1.5 + tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 + tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.o.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + tmpdepfile4=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for `:' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. + "$@" $dashmflag | + sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no + for arg in "$@"; do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + sed '1,2d' "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E | + sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + "$@" || exit $? + IFS=" " + for arg + do + case "$arg" in + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/dfa.c b/dfa.c new file mode 100644 index 0000000..64ce8f7 --- /dev/null +++ b/dfa.c @@ -0,0 +1,4064 @@ +/* dfa.c - deterministic extended regexp routines for GNU + Copyright (C) 1988, 1998, 2000, 2002, 2004-2005, 2007-2012 Free Software + Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., + 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA */ + +/* Written June, 1988 by Mike Haertel + Modified July, 1988 by Arthur David Olson to assist BMG speedups */ + +#include +#include +#include +#include + +#ifndef VMS +#include +#else +#include +#endif +#include +#include +#include +#if HAVE_SETLOCALE +#include +#endif + +#define STREQ(a, b) (strcmp (a, b) == 0) + +/* ISASCIIDIGIT differs from isdigit, as follows: + - Its arg may be any int or unsigned int; it need not be an unsigned char. + - It's guaranteed to evaluate its argument exactly once. + - It's typically faster. + Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that + only '0' through '9' are digits. Prefer ISASCIIDIGIT to isdigit unless + it's important to use the locale's definition of `digit' even when the + host does not conform to Posix. */ +#define ISASCIIDIGIT(c) ((unsigned) (c) - '0' <= 9) + +/* gettext.h ensures that we don't use gettext if ENABLE_NLS is not defined */ +#include "gettext.h" +#define _(str) gettext (str) + +#include "mbsupport.h" /* defines MBS_SUPPORT to 1 or 0, as appropriate */ +#if MBS_SUPPORT +/* We can handle multibyte strings. */ +#include +#include + +#if HAVE_LANGINFO_CODESET +# include +#endif +#endif + +#ifdef GAWK +#define bool int +#define true (1) +#define false (0) +#endif /* GAWK */ + +#include "regex.h" +#include "dfa.h" +#include "xalloc.h" + +#ifdef GAWK +static int +is_blank (int c) +{ + return (c == ' ' || c == '\t'); +} +#endif /* GAWK */ + +/* HPUX, define those as macros in sys/param.h */ +#ifdef setbit +# undef setbit +#endif +#ifdef clrbit +# undef clrbit +#endif + +/* Number of bits in an unsigned char. */ +#ifndef CHARBITS +# define CHARBITS 8 +#endif + +/* First integer value that is greater than any character code. */ +#define NOTCHAR (1 << CHARBITS) + +/* INTBITS need not be exact, just a lower bound. */ +#ifndef INTBITS +# define INTBITS (CHARBITS * sizeof (int)) +#endif + +/* Number of ints required to hold a bit for every character. */ +#define CHARCLASS_INTS ((NOTCHAR + INTBITS - 1) / INTBITS) + +/* Sets of unsigned characters are stored as bit vectors in arrays of ints. */ +typedef int charclass[CHARCLASS_INTS]; + +/* Convert a possibly-signed character to an unsigned character. This is + a bit safer than casting to unsigned char, since it catches some type + errors that the cast doesn't. */ +static inline unsigned char to_uchar (char ch) { return ch; } + +/* Contexts tell us whether a character is a newline or a word constituent. + Word-constituent characters are those that satisfy iswalnum(), plus '_'. + + A state also stores a context value, which is nonzero if its + predecessors always matches a newline or a word constituent. + The definition of a state's context is a bit unclear, but will be + modified soon anyway. */ + +#define CTX_NONE 1 +#define CTX_LETTER 2 +#define CTX_NEWLINE 4 +#define CTX_ANY 7 + +/* Sometimes characters can only be matched depending on the surrounding + context. Such context decisions depend on what the previous character + was, and the value of the current (lookahead) character. Context + dependent constraints are encoded as 8 bit integers. Each bit that + is set indicates that the constraint succeeds in the corresponding + context. + + bit 7 - previous and current are newlines + bit 6 - previous was newline, current isn't + bit 5 - previous wasn't newline, current is + bit 4 - neither previous nor current is a newline + bit 3 - previous and current are word-constituents + bit 2 - previous was word-constituent, current isn't + bit 1 - previous wasn't word-constituent, current is + bit 0 - neither previous nor current is word-constituent + + The macro SUCCEEDS_IN_CONTEXT determines whether a given constraint + succeeds in a particular context. Prev is the context value for + the previous character, curr is the context value for the lookahead + character. */ +#define MATCHES_NEWLINE_CONTEXT(constraint, prev, curr) \ + ((constraint) & \ + 1 << (((prev & CTX_NEWLINE) ? 2 : 0) + ((curr & CTX_NEWLINE) ? 1 : 0) + 4)) +#define MATCHES_LETTER_CONTEXT(constraint, prev, curr) \ + ((constraint) & \ + 1 << (((prev & CTX_LETTER) ? 2 : 0) + ((curr & CTX_LETTER) ? 1 : 0))) +#define SUCCEEDS_IN_CONTEXT(constraint, prev, curr) \ + (MATCHES_NEWLINE_CONTEXT(constraint, prev, curr) \ + && MATCHES_LETTER_CONTEXT(constraint, prev, curr)) + +/* The following macros give information about what a constraint depends on. */ +#define PREV_NEWLINE_DEPENDENT(constraint) \ + (((constraint) & 0xc0) >> 2 != ((constraint) & 0x30)) +#define PREV_LETTER_DEPENDENT(constraint) \ + (((constraint) & 0x0c) >> 2 != ((constraint) & 0x03)) + +/* Tokens that match the empty string subject to some constraint actually + work by applying that constraint to determine what may follow them, + taking into account what has gone before. The following values are + the constraints corresponding to the special tokens previously defined. */ +#define NO_CONSTRAINT 0xff +#define BEGLINE_CONSTRAINT 0xcf +#define ENDLINE_CONSTRAINT 0xaf +#define BEGWORD_CONSTRAINT 0xf2 +#define ENDWORD_CONSTRAINT 0xf4 +#define LIMWORD_CONSTRAINT 0xf6 +#define NOTLIMWORD_CONSTRAINT 0xf9 + +/* The regexp is parsed into an array of tokens in postfix form. Some tokens + are operators and others are terminal symbols. Most (but not all) of these + codes are returned by the lexical analyzer. */ +typedef enum +{ + END = -1, /* END is a terminal symbol that matches the + end of input; any value of END or less in + the parse tree is such a symbol. Accepting + states of the DFA are those that would have + a transition on END. */ + + /* Ordinary character values are terminal symbols that match themselves. */ + + EMPTY = NOTCHAR, /* EMPTY is a terminal symbol that matches + the empty string. */ + + BACKREF, /* BACKREF is generated by \; it + is not completely handled. If the scanner + detects a transition on backref, it returns + a kind of "semi-success" indicating that + the match will have to be verified with + a backtracking matcher. */ + + BEGLINE, /* BEGLINE is a terminal symbol that matches + the empty string if it is at the beginning + of a line. */ + + ENDLINE, /* ENDLINE is a terminal symbol that matches + the empty string if it is at the end of + a line. */ + + BEGWORD, /* BEGWORD is a terminal symbol that matches + the empty string if it is at the beginning + of a word. */ + + ENDWORD, /* ENDWORD is a terminal symbol that matches + the empty string if it is at the end of + a word. */ + + LIMWORD, /* LIMWORD is a terminal symbol that matches + the empty string if it is at the beginning + or the end of a word. */ + + NOTLIMWORD, /* NOTLIMWORD is a terminal symbol that + matches the empty string if it is not at + the beginning or end of a word. */ + + QMARK, /* QMARK is an operator of one argument that + matches zero or one occurences of its + argument. */ + + STAR, /* STAR is an operator of one argument that + matches the Kleene closure (zero or more + occurrences) of its argument. */ + + PLUS, /* PLUS is an operator of one argument that + matches the positive closure (one or more + occurrences) of its argument. */ + + REPMN, /* REPMN is a lexical token corresponding + to the {m,n} construct. REPMN never + appears in the compiled token vector. */ + + CAT, /* CAT is an operator of two arguments that + matches the concatenation of its + arguments. CAT is never returned by the + lexical analyzer. */ + + OR, /* OR is an operator of two arguments that + matches either of its arguments. */ + + LPAREN, /* LPAREN never appears in the parse tree, + it is only a lexeme. */ + + RPAREN, /* RPAREN never appears in the parse tree. */ + + ANYCHAR, /* ANYCHAR is a terminal symbol that matches + any multibyte (or single byte) characters. + It is used only if MB_CUR_MAX > 1. */ + + MBCSET, /* MBCSET is similar to CSET, but for + multibyte characters. */ + + WCHAR, /* Only returned by lex. wctok contains + the wide character representation. */ + + CSET /* CSET and (and any value greater) is a + terminal symbol that matches any of a + class of characters. */ +} token; + + +/* States of the recognizer correspond to sets of positions in the parse + tree, together with the constraints under which they may be matched. + So a position is encoded as an index into the parse tree together with + a constraint. */ +typedef struct +{ + unsigned int index; /* Index into the parse array. */ + unsigned int constraint; /* Constraint for matching this position. */ +} position; + +/* Sets of positions are stored as arrays. */ +typedef struct +{ + position *elems; /* Elements of this position set. */ + size_t nelem; /* Number of elements in this set. */ + size_t alloc; /* Number of elements allocated in ELEMS. */ +} position_set; + +/* Sets of leaves are also stored as arrays. */ +typedef struct +{ + unsigned int *elems; /* Elements of this position set. */ + size_t nelem; /* Number of elements in this set. */ +} leaf_set; + +/* A state of the dfa consists of a set of positions, some flags, + and the token value of the lowest-numbered position of the state that + contains an END token. */ +typedef struct +{ + int hash; /* Hash of the positions of this state. */ + position_set elems; /* Positions this state could match. */ + unsigned char context; /* Context from previous state. */ + char backref; /* True if this state matches a \. */ + unsigned char constraint; /* Constraint for this state to accept. */ + int first_end; /* Token value of the first END in elems. */ + position_set mbps; /* Positions which can match multibyte + characters. e.g. period. + These staff are used only if + MB_CUR_MAX > 1. */ +} dfa_state; + +/* A bracket operator. + e.g. [a-c], [[:alpha:]], etc. */ +struct mb_char_classes +{ + int cset; + int invert; + wchar_t *chars; /* Normal characters. */ + int nchars; + wctype_t *ch_classes; /* Character classes. */ + int nch_classes; + wchar_t *range_sts; /* Range characters (start of the range). */ + wchar_t *range_ends; /* Range characters (end of the range). */ + int nranges; + char **equivs; /* Equivalent classes. */ + int nequivs; + char **coll_elems; + int ncoll_elems; /* Collating elements. */ +}; + +/* A compiled regular expression. */ +struct dfa +{ + /* Fields filled by the scanner. */ + charclass *charclasses; /* Array of character sets for CSET tokens. */ + int cindex; /* Index for adding new charclasses. */ + int calloc; /* Number of charclasses currently allocated. */ + + /* Fields filled by the parser. */ + token *tokens; /* Postfix parse array. */ + int tindex; /* Index for adding new tokens. */ + int talloc; /* Number of tokens currently allocated. */ + int depth; /* Depth required of an evaluation stack + used for depth-first traversal of the + parse tree. */ + int nleaves; /* Number of leaves on the parse tree. */ + int nregexps; /* Count of parallel regexps being built + with dfaparse(). */ + unsigned int mb_cur_max; /* Cached value of MB_CUR_MAX. */ + int utf8_anychar_classes[5]; /* To lower ANYCHAR in UTF-8 locales. */ + + /* The following are used only if MB_CUR_MAX > 1. */ + + /* The value of multibyte_prop[i] is defined by following rule. + if tokens[i] < NOTCHAR + bit 0 : tokens[i] is the first byte of a character, including + single-byte characters. + bit 1 : tokens[i] is the last byte of a character, including + single-byte characters. + + if tokens[i] = MBCSET + ("the index of mbcsets correspnd to this operator" << 2) + 3 + + e.g. + tokens + = 'single_byte_a', 'multi_byte_A', single_byte_b' + = 'sb_a', 'mb_A(1st byte)', 'mb_A(2nd byte)', 'mb_A(3rd byte)', 'sb_b' + multibyte_prop + = 3 , 1 , 0 , 2 , 3 + */ + int nmultibyte_prop; + int *multibyte_prop; + + /* Array of the bracket expression in the DFA. */ + struct mb_char_classes *mbcsets; + int nmbcsets; + int mbcsets_alloc; + + /* Fields filled by the state builder. */ + dfa_state *states; /* States of the dfa. */ + int sindex; /* Index for adding new states. */ + int salloc; /* Number of states currently allocated. */ + + /* Fields filled by the parse tree->NFA conversion. */ + position_set *follows; /* Array of follow sets, indexed by position + index. The follow of a position is the set + of positions containing characters that + could conceivably follow a character + matching the given position in a string + matching the regexp. Allocated to the + maximum possible position index. */ + int searchflag; /* True if we are supposed to build a searching + as opposed to an exact matcher. A searching + matcher finds the first and shortest string + matching a regexp anywhere in the buffer, + whereas an exact matcher finds the longest + string matching, but anchored to the + beginning of the buffer. */ + + /* Fields filled by dfaexec. */ + int tralloc; /* Number of transition tables that have + slots so far. */ + int trcount; /* Number of transition tables that have + actually been built. */ + int **trans; /* Transition tables for states that can + never accept. If the transitions for a + state have not yet been computed, or the + state could possibly accept, its entry in + this table is NULL. */ + int **realtrans; /* Trans always points to realtrans + 1; this + is so trans[-1] can contain NULL. */ + int **fails; /* Transition tables after failing to accept + on a state that potentially could do so. */ + int *success; /* Table of acceptance conditions used in + dfaexec and computed in build_state. */ + int *newlines; /* Transitions on newlines. The entry for a + newline in any transition table is always + -1 so we can count lines without wasting + too many cycles. The transition for a + newline is stored separately and handled + as a special case. Newline is also used + as a sentinel at the end of the buffer. */ + struct dfamust *musts; /* List of strings, at least one of which + is known to appear in any r.e. matching + the dfa. */ +}; + +/* Some macros for user access to dfa internals. */ + +/* ACCEPTING returns true if s could possibly be an accepting state of r. */ +#define ACCEPTING(s, r) ((r).states[s].constraint) + +/* ACCEPTS_IN_CONTEXT returns true if the given state accepts in the + specified context. */ +#define ACCEPTS_IN_CONTEXT(prev, curr, state, dfa) \ + SUCCEEDS_IN_CONTEXT((dfa).states[state].constraint, prev, curr) + +static void dfamust (struct dfa *dfa); +static void regexp (void); + +/* These two macros are identical to the ones in gnulib's xalloc.h, + except that they not to case the result to "(t *)", and thus may + be used via type-free CALLOC and MALLOC macros. */ +#undef XNMALLOC +#undef XCALLOC + +/* Allocate memory for N elements of type T, with error checking. */ +/* extern t *XNMALLOC (size_t n, typename t); */ +# define XNMALLOC(n, t) \ + (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t))) + +/* Allocate memory for N elements of type T, with error checking, + and zero it. */ +/* extern t *XCALLOC (size_t n, typename t); */ +# define XCALLOC(n, t) \ + (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t))) + +#define CALLOC(p, n) do { (p) = XCALLOC (n, *(p)); } while (0) +#define MALLOC(p, n) do { (p) = XNMALLOC (n, *(p)); } while (0) +#define REALLOC(p, n) do {(p) = xnrealloc (p, n, sizeof (*(p))); } while (0) + +/* Reallocate an array of type *P if N_ALLOC is <= N_REQUIRED. */ +#define REALLOC_IF_NECESSARY(p, n_alloc, n_required) \ + do \ + { \ + if ((n_alloc) <= (n_required)) \ + { \ + size_t new_n_alloc = (n_required) + !(p); \ + (p) = x2nrealloc (p, &new_n_alloc, sizeof (*(p))); \ + (n_alloc) = new_n_alloc; \ + } \ + } \ + while (false) + + +#ifdef DEBUG + +static void +prtok (token t) +{ + char const *s; + + if (t < 0) + fprintf(stderr, "END"); + else if (t < NOTCHAR) + fprintf(stderr, "%c", t); + else + { + switch (t) + { + case EMPTY: s = "EMPTY"; break; + case BACKREF: s = "BACKREF"; break; + case BEGLINE: s = "BEGLINE"; break; + case ENDLINE: s = "ENDLINE"; break; + case BEGWORD: s = "BEGWORD"; break; + case ENDWORD: s = "ENDWORD"; break; + case LIMWORD: s = "LIMWORD"; break; + case NOTLIMWORD: s = "NOTLIMWORD"; break; + case QMARK: s = "QMARK"; break; + case STAR: s = "STAR"; break; + case PLUS: s = "PLUS"; break; + case CAT: s = "CAT"; break; + case OR: s = "OR"; break; + case LPAREN: s = "LPAREN"; break; + case RPAREN: s = "RPAREN"; break; + case ANYCHAR: s = "ANYCHAR"; break; + case MBCSET: s = "MBCSET"; break; + default: s = "CSET"; break; + } + fprintf(stderr, "%s", s); + } +} +#endif /* DEBUG */ + +/* Stuff pertaining to charclasses. */ + +static int +tstbit (unsigned int b, charclass const c) +{ + return c[b / INTBITS] & 1 << b % INTBITS; +} + +static void +setbit (unsigned int b, charclass c) +{ + c[b / INTBITS] |= 1 << b % INTBITS; +} + +static void +clrbit (unsigned int b, charclass c) +{ + c[b / INTBITS] &= ~(1 << b % INTBITS); +} + +static void +copyset (charclass const src, charclass dst) +{ + memcpy (dst, src, sizeof (charclass)); +} + +static void +zeroset (charclass s) +{ + memset (s, 0, sizeof (charclass)); +} + +static void +notset (charclass s) +{ + int i; + + for (i = 0; i < CHARCLASS_INTS; ++i) + s[i] = ~s[i]; +} + +static int +equal (charclass const s1, charclass const s2) +{ + return memcmp (s1, s2, sizeof (charclass)) == 0; +} + +/* A pointer to the current dfa is kept here during parsing. */ +static struct dfa *dfa; + +/* Find the index of charclass s in dfa->charclasses, or allocate a new charclass. */ +static int +charclass_index (charclass const s) +{ + int i; + + for (i = 0; i < dfa->cindex; ++i) + if (equal(s, dfa->charclasses[i])) + return i; + REALLOC_IF_NECESSARY(dfa->charclasses, dfa->calloc, dfa->cindex + 1); + ++dfa->cindex; + copyset(s, dfa->charclasses[i]); + return i; +} + +/* Syntax bits controlling the behavior of the lexical analyzer. */ +static reg_syntax_t syntax_bits, syntax_bits_set; + +/* Flag for case-folding letters into sets. */ +static int case_fold; + +/* End-of-line byte in data. */ +static unsigned char eolbyte; + +/* Cache of char-context values. */ +static int sbit[NOTCHAR]; + +/* Set of characters considered letters. */ +static charclass letters; + +/* Set of characters that are newline. */ +static charclass newline; + +/* Add this to the test for whether a byte is word-constituent, since on + BSD-based systems, many values in the 128..255 range are classified as + alphabetic, while on glibc-based systems, they are not. */ +#ifdef __GLIBC__ +# define is_valid_unibyte_character(c) 1 +#else +# define is_valid_unibyte_character(c) (! (MBS_SUPPORT && btowc (c) == WEOF)) +#endif + +/* Return non-zero if C is a 'word-constituent' byte; zero otherwise. */ +#define IS_WORD_CONSTITUENT(C) \ + (is_valid_unibyte_character (C) && (isalnum (C) || (C) == '_')) + +static int +char_context (unsigned char c) +{ + if (c == eolbyte || c == 0) + return CTX_NEWLINE; + if (IS_WORD_CONSTITUENT (c)) + return CTX_LETTER; + return CTX_NONE; +} + +static int +wchar_context(wint_t wc) +{ + if (wc == (wchar_t)eolbyte || wc == 0) + return CTX_NEWLINE; + if (wc == L'_' || iswalnum (wc)) + return CTX_LETTER; + return CTX_NONE; +} + +/* Entry point to set syntax options. */ +void +dfasyntax (reg_syntax_t bits, int fold, unsigned char eol) +{ + unsigned int i; + + syntax_bits_set = 1; + syntax_bits = bits; + case_fold = fold; + eolbyte = eol; + + for (i = 0; i < NOTCHAR; ++i) + { + sbit[i] = char_context (i); + switch (sbit[i]) + { + case CTX_LETTER: + setbit (i, letters); + break; + case CTX_NEWLINE: + setbit (i, newline); + break; + } + } +} + +/* Set a bit in the charclass for the given wchar_t. Do nothing if WC + is represented by a multi-byte sequence. Even for MB_CUR_MAX == 1, + this may happen when folding case in weird Turkish locales where + dotless i/dotted I are not included in the chosen character set. + Return whether a bit was set in the charclass. */ +#if MBS_SUPPORT +static bool +setbit_wc (wint_t wc, charclass c) +{ + int b = wctob (wc); + if (b == EOF) + return false; + + setbit (b, c); + return true; +} + +/* Set a bit in the charclass for the given single byte character, + if it is valid in the current character set. */ +static void +setbit_c (int b, charclass c) +{ + /* Do nothing if b is invalid in this character set. */ + if (MB_CUR_MAX > 1 && btowc (b) == WEOF) + return; + setbit (b, c); +} +#else +# define setbit_c setbit +static inline bool +setbit_wc (wint_t wc, charclass c) +{ + abort (); + /*NOTREACHED*/ + return false; +} +#endif + +/* Like setbit_c, but if case is folded, set both cases of a letter. For + MB_CUR_MAX > 1, the resulting charset is only used as an optimization, + and the caller takes care of setting the appropriate field of struct + mb_char_classes. */ +static void +setbit_case_fold_c (int b, charclass c) +{ + if (MB_CUR_MAX > 1) + { + wint_t wc = btowc (b); + if (wc == WEOF) + return; + setbit (b, c); + if (case_fold && iswalpha (wc)) + setbit_wc (iswupper (wc) ? towlower (wc) : towupper (wc), c); + } + else + { + setbit (b, c); + if (case_fold && isalpha (b)) + setbit_c (isupper (b) ? tolower (b) : toupper (b), c); + } +} + + + +/* UTF-8 encoding allows some optimizations that we can't otherwise + assume in a multibyte encoding. */ +static inline int +using_utf8 (void) +{ + static int utf8 = -1; + if (utf8 == -1) + { +#if defined HAVE_LANGINFO_CODESET && MBS_SUPPORT + utf8 = (STREQ (nl_langinfo (CODESET), "UTF-8")); +#else + utf8 = 0; +#endif + } + + return utf8; +} + +/* Lexical analyzer. All the dross that deals with the obnoxious + GNU Regex syntax bits is located here. The poor, suffering + reader is referred to the GNU Regex documentation for the + meaning of the @#%!@#%^!@ syntax bits. */ + +static char const *lexptr; /* Pointer to next input character. */ +static int lexleft; /* Number of characters remaining. */ +static token lasttok; /* Previous token returned; initially END. */ +static int laststart; /* True if we're separated from beginning or (, | + only by zero-width characters. */ +static int parens; /* Count of outstanding left parens. */ +static int minrep, maxrep; /* Repeat counts for {m,n}. */ + +static int cur_mb_len = 1; /* Length of the multibyte representation of + wctok. */ +/* These variables are used only if (MB_CUR_MAX > 1). */ +static mbstate_t mbs; /* Mbstate for mbrlen(). */ +static wchar_t wctok; /* Wide character representation of the current + multibyte character. */ +static unsigned char *mblen_buf;/* Correspond to the input buffer in dfaexec(). + Each element store the amount of remain + byte of corresponding multibyte character + in the input string. A element's value + is 0 if corresponding character is a + single byte chracter. + e.g. input : 'a', , , + mblen_buf : 0, 3, 2, 1 + */ +static wchar_t *inputwcs; /* Wide character representation of input + string in dfaexec(). + The length of this array is same as + the length of input string(char array). + inputstring[i] is a single-byte char, + or 1st byte of a multibyte char. + And inputwcs[i] is the codepoint. */ +static unsigned char const *buf_begin; /* reference to begin in dfaexec(). */ +static unsigned char const *buf_end; /* reference to end in dfaexec(). */ + + +#if MBS_SUPPORT +/* Note that characters become unsigned here. */ +# define FETCH_WC(c, wc, eoferr) \ + do { \ + if (! lexleft) \ + { \ + if ((eoferr) != 0) \ + dfaerror (eoferr); \ + else \ + return lasttok = END; \ + } \ + else \ + { \ + wchar_t _wc; \ + cur_mb_len = mbrtowc(&_wc, lexptr, lexleft, &mbs); \ + if (cur_mb_len <= 0) \ + { \ + cur_mb_len = 1; \ + --lexleft; \ + (wc) = (c) = to_uchar (*lexptr++); \ + } \ + else \ + { \ + lexptr += cur_mb_len; \ + lexleft -= cur_mb_len; \ + (wc) = _wc; \ + (c) = wctob(wc); \ + } \ + } \ + } while(0) + +# define FETCH(c, eoferr) \ + do { \ + wint_t wc; \ + FETCH_WC(c, wc, eoferr); \ + } while(0) + +#else +/* Note that characters become unsigned here. */ +# define FETCH(c, eoferr) \ + do { \ + if (! lexleft) \ + { \ + if ((eoferr) != 0) \ + dfaerror (eoferr); \ + else \ + return lasttok = END; \ + } \ + (c) = to_uchar (*lexptr++); \ + --lexleft; \ + } while(0) + +# define FETCH_WC(c, unused, eoferr) FETCH (c, eoferr) + +#endif /* MBS_SUPPORT */ + +typedef int predicate (int); + +/* The following list maps the names of the Posix named character classes + to predicate functions that determine whether a given character is in + the class. The leading [ has already been eaten by the lexical analyzer. */ +struct dfa_ctype { + const char *name; + predicate *func; + bool single_byte_only; +}; + +static const struct dfa_ctype prednames[] = { + { "alpha", isalpha, false }, + { "upper", isupper, false }, + { "lower", islower, false }, + { "digit", isdigit, true }, + { "xdigit", isxdigit, true }, + { "space", isspace, false }, + { "punct", ispunct, false }, + { "alnum", isalnum, false }, + { "print", isprint, false }, + { "graph", isgraph, false }, + { "cntrl", iscntrl, false }, + { "blank", is_blank, false }, + { NULL, NULL, false } +}; + +static const struct dfa_ctype * _GL_ATTRIBUTE_PURE +find_pred (const char *str) +{ + unsigned int i; + for (i = 0; prednames[i].name; ++i) + if (STREQ (str, prednames[i].name)) + break; + + return &prednames[i]; +} + +/* Multibyte character handling sub-routine for lex. + This function parse a bracket expression and build a struct + mb_char_classes. */ +static token +parse_bracket_exp (void) +{ + int invert; + int c, c1, c2; + charclass ccl; + + /* Used to warn about [:space:]. + Bit 0 = first character is a colon. + Bit 1 = last character is a colon. + Bit 2 = includes any other character but a colon. + Bit 3 = includes ranges, char/equiv classes or collation elements. */ + int colon_warning_state; + + wint_t wc; + wint_t wc2; + wint_t wc1 = 0; + + /* Work area to build a mb_char_classes. */ + struct mb_char_classes *work_mbc; + int chars_al, range_sts_al, range_ends_al, ch_classes_al, + equivs_al, coll_elems_al; + + chars_al = 0; + range_sts_al = range_ends_al = 0; + ch_classes_al = equivs_al = coll_elems_al = 0; + if (MB_CUR_MAX > 1) + { + REALLOC_IF_NECESSARY(dfa->mbcsets, dfa->mbcsets_alloc, dfa->nmbcsets + 1); + + /* dfa->multibyte_prop[] hold the index of dfa->mbcsets. + We will update dfa->multibyte_prop[] in addtok(), because we can't + decide the index in dfa->tokens[]. */ + + /* Initialize work area. */ + work_mbc = &(dfa->mbcsets[dfa->nmbcsets++]); + memset (work_mbc, 0, sizeof *work_mbc); + } + else + work_mbc = NULL; + + memset (ccl, 0, sizeof ccl); + FETCH_WC (c, wc, _("unbalanced [")); + if (c == '^') + { + FETCH_WC (c, wc, _("unbalanced [")); + invert = 1; + } + else + invert = 0; + + colon_warning_state = (c == ':'); + do + { + c1 = EOF; /* mark c1 is not initialized". */ + colon_warning_state &= ~2; + + /* Note that if we're looking at some other [:...:] construct, + we just treat it as a bunch of ordinary characters. We can do + this because we assume regex has checked for syntax errors before + dfa is ever called. */ + if (c == '[' && (syntax_bits & RE_CHAR_CLASSES)) + { +#define BRACKET_BUFFER_SIZE 128 + char str[BRACKET_BUFFER_SIZE]; + FETCH_WC (c1, wc1, _("unbalanced [")); + + /* If pattern contains `[[:', `[[.', or `[[='. */ + if (c1 == ':' + /* TODO: handle `[[.' and `[[=' also for MB_CUR_MAX == 1. */ + || (MB_CUR_MAX > 1 && (c1 == '.' || c1 == '=')) + ) + { + size_t len = 0; + for (;;) + { + FETCH_WC (c, wc, _("unbalanced [")); + if ((c == c1 && *lexptr == ']') || lexleft == 0) + break; + if (len < BRACKET_BUFFER_SIZE) + str[len++] = c; + else + /* This is in any case an invalid class name. */ + str[0] = '\0'; + } + str[len] = '\0'; + + /* Fetch bracket. */ + FETCH_WC (c, wc, _("unbalanced [")); + if (c1 == ':') + /* build character class. */ + { + char const *class + = (case_fold && (STREQ (str, "upper") + || STREQ (str, "lower")) + ? "alpha" + : str); + const struct dfa_ctype *pred = find_pred (class); + if (!pred) + dfaerror(_("invalid character class")); + + if (MB_CUR_MAX > 1 && !pred->single_byte_only) + { + /* Store the character class as wctype_t. */ + wctype_t wt = wctype (class); + + REALLOC_IF_NECESSARY(work_mbc->ch_classes, + ch_classes_al, + work_mbc->nch_classes + 1); + work_mbc->ch_classes[work_mbc->nch_classes++] = wt; + } + + for (c2 = 0; c2 < NOTCHAR; ++c2) + if (pred->func(c2)) + setbit_case_fold_c (c2, ccl); + } + + else if (MBS_SUPPORT && (c1 == '=' || c1 == '.')) + { + char *elem; + MALLOC(elem, len + 1); + strncpy(elem, str, len + 1); + + if (c1 == '=') + /* build equivalent class. */ + { + REALLOC_IF_NECESSARY(work_mbc->equivs, + equivs_al, + work_mbc->nequivs + 1); + work_mbc->equivs[work_mbc->nequivs++] = elem; + } + + if (c1 == '.') + /* build collating element. */ + { + REALLOC_IF_NECESSARY(work_mbc->coll_elems, + coll_elems_al, + work_mbc->ncoll_elems + 1); + work_mbc->coll_elems[work_mbc->ncoll_elems++] = elem; + } + } + colon_warning_state |= 8; + + /* Fetch new lookahead character. */ + FETCH_WC (c1, wc1, _("unbalanced [")); + continue; + } + + /* We treat '[' as a normal character here. c/c1/wc/wc1 + are already set up. */ + } + + if (c == '\\' && (syntax_bits & RE_BACKSLASH_ESCAPE_IN_LISTS)) + FETCH_WC(c, wc, _("unbalanced [")); + + if (c1 == EOF) + FETCH_WC(c1, wc1, _("unbalanced [")); + + if (c1 == '-') + /* build range characters. */ + { + FETCH_WC(c2, wc2, _("unbalanced [")); + if (c2 == ']') + { + /* In the case [x-], the - is an ordinary hyphen, + which is left in c1, the lookahead character. */ + lexptr -= cur_mb_len; + lexleft += cur_mb_len; + } + } + + if (c1 == '-' && c2 != ']') + { + if (c2 == '\\' + && (syntax_bits & RE_BACKSLASH_ESCAPE_IN_LISTS)) + FETCH_WC(c2, wc2, _("unbalanced [")); + + if (MB_CUR_MAX > 1) + { + /* When case folding map a range, say [m-z] (or even [M-z]) + to the pair of ranges, [m-z] [M-Z]. */ + REALLOC_IF_NECESSARY(work_mbc->range_sts, + range_sts_al, work_mbc->nranges + 1); + REALLOC_IF_NECESSARY(work_mbc->range_ends, + range_ends_al, work_mbc->nranges + 1); + work_mbc->range_sts[work_mbc->nranges] = + case_fold ? towlower(wc) : (wchar_t)wc; + work_mbc->range_ends[work_mbc->nranges++] = + case_fold ? towlower(wc2) : (wchar_t)wc2; + +#ifndef GREP + if (case_fold && (iswalpha(wc) || iswalpha(wc2))) + { + REALLOC_IF_NECESSARY(work_mbc->range_sts, + range_sts_al, work_mbc->nranges + 1); + work_mbc->range_sts[work_mbc->nranges] = towupper(wc); + REALLOC_IF_NECESSARY(work_mbc->range_ends, + range_ends_al, work_mbc->nranges + 1); + work_mbc->range_ends[work_mbc->nranges++] = towupper(wc2); + } +#endif + } + else + { + c1 = c; + if (case_fold) + { + c1 = tolower (c1); + c2 = tolower (c2); + } + for (c = c1; c <= c2; c++) + setbit_case_fold_c (c, ccl); + } + + colon_warning_state |= 8; + FETCH_WC(c1, wc1, _("unbalanced [")); + continue; + } + + colon_warning_state |= (c == ':') ? 2 : 4; + + if (MB_CUR_MAX == 1) + { + setbit_case_fold_c (c, ccl); + continue; + } + + if (case_fold && iswalpha(wc)) + { + wc = towlower(wc); + if (!setbit_wc (wc, ccl)) + { + REALLOC_IF_NECESSARY(work_mbc->chars, chars_al, + work_mbc->nchars + 1); + work_mbc->chars[work_mbc->nchars++] = wc; + } +#ifdef GREP + continue; +#else + wc = towupper(wc); +#endif + } + if (!setbit_wc (wc, ccl)) + { + REALLOC_IF_NECESSARY(work_mbc->chars, chars_al, + work_mbc->nchars + 1); + work_mbc->chars[work_mbc->nchars++] = wc; + } + } + while ((wc = wc1, (c = c1) != ']')); + + if (colon_warning_state == 7) + dfawarn (_("character class syntax is [[:space:]], not [:space:]")); + + if (MB_CUR_MAX > 1) + { + static charclass zeroclass; + work_mbc->invert = invert; + work_mbc->cset = equal(ccl, zeroclass) ? -1 : charclass_index(ccl); + return MBCSET; + } + + if (invert) + { + assert(MB_CUR_MAX == 1); + notset(ccl); + if (syntax_bits & RE_HAT_LISTS_NOT_NEWLINE) + clrbit(eolbyte, ccl); + } + + return CSET + charclass_index(ccl); +} + +static token +lex (void) +{ + unsigned int c, c2; + int backslash = 0; + charclass ccl; + int i; + + /* Basic plan: We fetch a character. If it's a backslash, + we set the backslash flag and go through the loop again. + On the plus side, this avoids having a duplicate of the + main switch inside the backslash case. On the minus side, + it means that just about every case begins with + "if (backslash) ...". */ + for (i = 0; i < 2; ++i) + { + if (MB_CUR_MAX > 1) + { + FETCH_WC (c, wctok, NULL); + if ((int)c == EOF) + goto normal_char; + } + else + FETCH(c, NULL); + + switch (c) + { + case '\\': + if (backslash) + goto normal_char; + if (lexleft == 0) + dfaerror(_("unfinished \\ escape")); + backslash = 1; + break; + + case '^': + if (backslash) + goto normal_char; + if (syntax_bits & RE_CONTEXT_INDEP_ANCHORS + || lasttok == END + || lasttok == LPAREN + || lasttok == OR) + return lasttok = BEGLINE; + goto normal_char; + + case '$': + if (backslash) + goto normal_char; + if (syntax_bits & RE_CONTEXT_INDEP_ANCHORS + || lexleft == 0 + || (syntax_bits & RE_NO_BK_PARENS + ? lexleft > 0 && *lexptr == ')' + : lexleft > 1 && lexptr[0] == '\\' && lexptr[1] == ')') + || (syntax_bits & RE_NO_BK_VBAR + ? lexleft > 0 && *lexptr == '|' + : lexleft > 1 && lexptr[0] == '\\' && lexptr[1] == '|') + || ((syntax_bits & RE_NEWLINE_ALT) + && lexleft > 0 && *lexptr == '\n')) + return lasttok = ENDLINE; + goto normal_char; + + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (backslash && !(syntax_bits & RE_NO_BK_REFS)) + { + laststart = 0; + return lasttok = BACKREF; + } + goto normal_char; + + case '`': + if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) + return lasttok = BEGLINE; /* FIXME: should be beginning of string */ + goto normal_char; + + case '\'': + if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) + return lasttok = ENDLINE; /* FIXME: should be end of string */ + goto normal_char; + + case '<': + if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) + return lasttok = BEGWORD; + goto normal_char; + + case '>': + if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) + return lasttok = ENDWORD; + goto normal_char; + + case 'b': + if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) + return lasttok = LIMWORD; + goto normal_char; + + case 'B': + if (backslash && !(syntax_bits & RE_NO_GNU_OPS)) + return lasttok = NOTLIMWORD; + goto normal_char; + + case '?': + if (syntax_bits & RE_LIMITED_OPS) + goto normal_char; + if (backslash != ((syntax_bits & RE_BK_PLUS_QM) != 0)) + goto normal_char; + if (!(syntax_bits & RE_CONTEXT_INDEP_OPS) && laststart) + goto normal_char; + return lasttok = QMARK; + + case '*': + if (backslash) + goto normal_char; + if (!(syntax_bits & RE_CONTEXT_INDEP_OPS) && laststart) + goto normal_char; + return lasttok = STAR; + + case '+': + if (syntax_bits & RE_LIMITED_OPS) + goto normal_char; + if (backslash != ((syntax_bits & RE_BK_PLUS_QM) != 0)) + goto normal_char; + if (!(syntax_bits & RE_CONTEXT_INDEP_OPS) && laststart) + goto normal_char; + return lasttok = PLUS; + + case '{': + if (!(syntax_bits & RE_INTERVALS)) + goto normal_char; + if (backslash != ((syntax_bits & RE_NO_BK_BRACES) == 0)) + goto normal_char; + if (!(syntax_bits & RE_CONTEXT_INDEP_OPS) && laststart) + goto normal_char; + + if (syntax_bits & RE_NO_BK_BRACES) + { + /* Scan ahead for a valid interval; if it's not valid, + treat it as a literal '{'. */ + int lo = -1, hi = -1; + char const *p = lexptr; + char const *lim = p + lexleft; + for (; p != lim && ISASCIIDIGIT (*p); p++) + lo = (lo < 0 ? 0 : lo * 10) + *p - '0'; + if (p != lim && *p == ',') + while (++p != lim && ISASCIIDIGIT (*p)) + hi = (hi < 0 ? 0 : hi * 10) + *p - '0'; + else + hi = lo; + if (p == lim || *p != '}' + || lo < 0 || RE_DUP_MAX < hi || (0 <= hi && hi < lo)) + goto normal_char; + } + + minrep = 0; + /* Cases: + {M} - exact count + {M,} - minimum count, maximum is infinity + {M,N} - M through N */ + FETCH(c, _("unfinished repeat count")); + if (ISASCIIDIGIT (c)) + { + minrep = c - '0'; + for (;;) + { + FETCH(c, _("unfinished repeat count")); + if (! ISASCIIDIGIT (c)) + break; + minrep = 10 * minrep + c - '0'; + } + } + else + dfaerror(_("malformed repeat count")); + if (c == ',') + { + FETCH (c, _("unfinished repeat count")); + if (! ISASCIIDIGIT (c)) + maxrep = -1; + else + { + maxrep = c - '0'; + for (;;) + { + FETCH (c, _("unfinished repeat count")); + if (! ISASCIIDIGIT (c)) + break; + maxrep = 10 * maxrep + c - '0'; + } + if (0 <= maxrep && maxrep < minrep) + dfaerror (_("malformed repeat count")); + } + } + else + maxrep = minrep; + if (!(syntax_bits & RE_NO_BK_BRACES)) + { + if (c != '\\') + dfaerror(_("malformed repeat count")); + FETCH(c, _("unfinished repeat count")); + } + if (c != '}') + dfaerror(_("malformed repeat count")); + laststart = 0; + return lasttok = REPMN; + + case '|': + if (syntax_bits & RE_LIMITED_OPS) + goto normal_char; + if (backslash != ((syntax_bits & RE_NO_BK_VBAR) == 0)) + goto normal_char; + laststart = 1; + return lasttok = OR; + + case '\n': + if (syntax_bits & RE_LIMITED_OPS + || backslash + || !(syntax_bits & RE_NEWLINE_ALT)) + goto normal_char; + laststart = 1; + return lasttok = OR; + + case '(': + if (backslash != ((syntax_bits & RE_NO_BK_PARENS) == 0)) + goto normal_char; + ++parens; + laststart = 1; + return lasttok = LPAREN; + + case ')': + if (backslash != ((syntax_bits & RE_NO_BK_PARENS) == 0)) + goto normal_char; + if (parens == 0 && syntax_bits & RE_UNMATCHED_RIGHT_PAREN_ORD) + goto normal_char; + --parens; + laststart = 0; + return lasttok = RPAREN; + + case '.': + if (backslash) + goto normal_char; + if (MB_CUR_MAX > 1) + { + /* In multibyte environment period must match with a single + character not a byte. So we use ANYCHAR. */ + laststart = 0; + return lasttok = ANYCHAR; + } + zeroset(ccl); + notset(ccl); + if (!(syntax_bits & RE_DOT_NEWLINE)) + clrbit(eolbyte, ccl); + if (syntax_bits & RE_DOT_NOT_NULL) + clrbit('\0', ccl); + laststart = 0; + return lasttok = CSET + charclass_index(ccl); + + case 's': + case 'S': + if (!backslash || (syntax_bits & RE_NO_GNU_OPS)) + goto normal_char; + zeroset(ccl); + for (c2 = 0; c2 < NOTCHAR; ++c2) + if (isspace(c2)) + setbit(c2, ccl); + if (c == 'S') + notset(ccl); + laststart = 0; + return lasttok = CSET + charclass_index(ccl); + + case 'w': + case 'W': + if (!backslash || (syntax_bits & RE_NO_GNU_OPS)) + goto normal_char; + zeroset(ccl); + for (c2 = 0; c2 < NOTCHAR; ++c2) + if (IS_WORD_CONSTITUENT(c2)) + setbit(c2, ccl); + if (c == 'W') + notset(ccl); + laststart = 0; + return lasttok = CSET + charclass_index(ccl); + + case '[': + if (backslash) + goto normal_char; + laststart = 0; + return lasttok = parse_bracket_exp(); + + default: + normal_char: + laststart = 0; + /* For multibyte character sets, folding is done in atom. Always + return WCHAR. */ + if (MB_CUR_MAX > 1) + return lasttok = WCHAR; + + if (case_fold && isalpha(c)) + { + zeroset(ccl); + setbit_case_fold_c (c, ccl); + return lasttok = CSET + charclass_index(ccl); + } + + return lasttok = c; + } + } + + /* The above loop should consume at most a backslash + and some other character. */ + abort(); + return END; /* keeps pedantic compilers happy. */ +} + +/* Recursive descent parser for regular expressions. */ + +static token tok; /* Lookahead token. */ +static int depth; /* Current depth of a hypothetical stack + holding deferred productions. This is + used to determine the depth that will be + required of the real stack later on in + dfaanalyze(). */ + +static void +addtok_mb (token t, int mbprop) +{ + if (MB_CUR_MAX > 1) + { + REALLOC_IF_NECESSARY(dfa->multibyte_prop, dfa->nmultibyte_prop, + dfa->tindex + 1); + dfa->multibyte_prop[dfa->tindex] = mbprop; + } + + REALLOC_IF_NECESSARY(dfa->tokens, dfa->talloc, dfa->tindex + 1); + dfa->tokens[dfa->tindex++] = t; + + switch (t) + { + case QMARK: + case STAR: + case PLUS: + break; + + case CAT: + case OR: + --depth; + break; + + default: + ++dfa->nleaves; + case EMPTY: + ++depth; + break; + } + if (depth > dfa->depth) + dfa->depth = depth; +} + +static void addtok_wc (wint_t wc); + +/* Add the given token to the parse tree, maintaining the depth count and + updating the maximum depth if necessary. */ +static void +addtok (token t) +{ + if (MB_CUR_MAX > 1 && t == MBCSET) + { + bool need_or = false; + struct mb_char_classes *work_mbc = &dfa->mbcsets[dfa->nmbcsets - 1]; + + /* Extract wide characters into alternations for better performance. + This does not require UTF-8. */ + if (!work_mbc->invert) + { + int i; + for (i = 0; i < work_mbc->nchars; i++) + { + addtok_wc (work_mbc->chars[i]); + if (need_or) + addtok (OR); + need_or = true; + } + work_mbc->nchars = 0; + } + + /* UTF-8 allows treating a simple, non-inverted MBCSET like a CSET. */ + if (work_mbc->invert + || (!using_utf8() && work_mbc->cset != -1) + || work_mbc->nchars != 0 + || work_mbc->nch_classes != 0 + || work_mbc->nranges != 0 + || work_mbc->nequivs != 0 + || work_mbc->ncoll_elems != 0) + { + addtok_mb (MBCSET, ((dfa->nmbcsets - 1) << 2) + 3); + if (need_or) + addtok (OR); + } + else + { + /* Characters have been handled above, so it is possible + that the mbcset is empty now. Do nothing in that case. */ + if (work_mbc->cset != -1) + { + assert (using_utf8 ()); + addtok (CSET + work_mbc->cset); + if (need_or) + addtok (OR); + } + } + } + else + { + addtok_mb (t, 3); + } +} + +#if MBS_SUPPORT +/* We treat a multibyte character as a single atom, so that DFA + can treat a multibyte character as a single expression. + + e.g. We construct following tree from "". + + */ +static void +addtok_wc (wint_t wc) +{ + unsigned char buf[MB_LEN_MAX]; + mbstate_t s; + int i; + memset (&s, 0, sizeof s); + cur_mb_len = wcrtomb ((char *) buf, wc, &s); + + /* This is merely stop-gap. When cur_mb_len is 0 or negative, + buf[0] is undefined, yet skipping the addtok_mb call altogether + can result in heap corruption. */ + if (cur_mb_len <= 0) + buf[0] = 0; + + addtok_mb(buf[0], cur_mb_len == 1 ? 3 : 1); + for (i = 1; i < cur_mb_len; i++) + { + addtok_mb(buf[i], i == cur_mb_len - 1 ? 2 : 0); + addtok(CAT); + } +} +#else +static void addtok_wc (wint_t wc) {} +#endif + +static void +add_utf8_anychar (void) +{ +#if MBS_SUPPORT + static const charclass utf8_classes[5] = { + { 0, 0, 0, 0, ~0, ~0, 0, 0 }, /* 80-bf: non-lead bytes */ + { ~0, ~0, ~0, ~0, 0, 0, 0, 0 }, /* 00-7f: 1-byte sequence */ + { 0, 0, 0, 0, 0, 0, 0xfffffffcU, 0 }, /* c2-df: 2-byte sequence */ + { 0, 0, 0, 0, 0, 0, 0, 0xffff }, /* e0-ef: 3-byte sequence */ + { 0, 0, 0, 0, 0, 0, 0, 0xff0000 } /* f0-f7: 4-byte sequence */ + }; + const unsigned int n = sizeof (utf8_classes) / sizeof (utf8_classes[0]); + unsigned int i; + + /* Define the five character classes that are needed below. */ + if (dfa->utf8_anychar_classes[0] == 0) + for (i = 0; i < n; i++) + { + charclass c; + copyset (utf8_classes[i], c); + if (i == 1) + { + if (!(syntax_bits & RE_DOT_NEWLINE)) + clrbit (eolbyte, c); + if (syntax_bits & RE_DOT_NOT_NULL) + clrbit ('\0', c); + } + dfa->utf8_anychar_classes[i] = CSET + charclass_index(c); + } + + /* A valid UTF-8 character is + + ([0x00-0x7f] + |[0xc2-0xdf][0x80-0xbf] + |[0xe0-0xef[0x80-0xbf][0x80-0xbf] + |[0xf0-f7][0x80-0xbf][0x80-0xbf][0x80-0xbf]) + + which I'll write more concisely "B|CA|DAA|EAAA". Factor the [0x00-0x7f] + and you get "B|(C|(D|EA)A)A". And since the token buffer is in reverse + Polish notation, you get "B C D E A CAT OR A CAT OR A CAT OR". */ + for (i = 1; i < n; i++) + addtok (dfa->utf8_anychar_classes[i]); + while (--i > 1) + { + addtok (dfa->utf8_anychar_classes[0]); + addtok (CAT); + addtok (OR); + } +#endif +} + +/* The grammar understood by the parser is as follows. + + regexp: + regexp OR branch + branch + + branch: + branch closure + closure + + closure: + closure QMARK + closure STAR + closure PLUS + closure REPMN + atom + + atom: + + + ANYCHAR + MBCSET + CSET + BACKREF + BEGLINE + ENDLINE + BEGWORD + ENDWORD + LIMWORD + NOTLIMWORD + LPAREN regexp RPAREN + + + The parser builds a parse tree in postfix form in an array of tokens. */ + +static void +atom (void) +{ + if (0) + { + /* empty */ + } + else if (MBS_SUPPORT && tok == WCHAR) + { + addtok_wc (case_fold ? towlower(wctok) : wctok); +#ifndef GREP + if (case_fold && iswalpha(wctok)) + { + addtok_wc (towupper(wctok)); + addtok (OR); + } +#endif + + tok = lex(); + } + else if (MBS_SUPPORT && tok == ANYCHAR && using_utf8()) + { + /* For UTF-8 expand the period to a series of CSETs that define a valid + UTF-8 character. This avoids using the slow multibyte path. I'm + pretty sure it would be both profitable and correct to do it for + any encoding; however, the optimization must be done manually as + it is done above in add_utf8_anychar. So, let's start with + UTF-8: it is the most used, and the structure of the encoding + makes the correctness more obvious. */ + add_utf8_anychar(); + tok = lex(); + } + else if ((tok >= 0 && tok < NOTCHAR) || tok >= CSET || tok == BACKREF + || tok == BEGLINE || tok == ENDLINE || tok == BEGWORD +#if MBS_SUPPORT + || tok == ANYCHAR || tok == MBCSET +#endif /* MBS_SUPPORT */ + || tok == ENDWORD || tok == LIMWORD || tok == NOTLIMWORD) + { + addtok(tok); + tok = lex(); + } + else if (tok == LPAREN) + { + tok = lex(); + regexp(); + if (tok != RPAREN) + dfaerror(_("unbalanced (")); + tok = lex(); + } + else + addtok(EMPTY); +} + +/* Return the number of tokens in the given subexpression. */ +static int _GL_ATTRIBUTE_PURE +nsubtoks (int tindex) +{ + int ntoks1; + + switch (dfa->tokens[tindex - 1]) + { + default: + return 1; + case QMARK: + case STAR: + case PLUS: + return 1 + nsubtoks(tindex - 1); + case CAT: + case OR: + ntoks1 = nsubtoks(tindex - 1); + return 1 + ntoks1 + nsubtoks(tindex - 1 - ntoks1); + } +} + +/* Copy the given subexpression to the top of the tree. */ +static void +copytoks (int tindex, int ntokens) +{ + int i; + + for (i = 0; i < ntokens; ++i) + { + addtok(dfa->tokens[tindex + i]); + /* Update index into multibyte csets. */ + if (MB_CUR_MAX > 1 && dfa->tokens[tindex + i] == MBCSET) + dfa->multibyte_prop[dfa->tindex - 1] = dfa->multibyte_prop[tindex + i]; + } +} + +static void +closure (void) +{ + int tindex, ntokens, i; + + atom(); + while (tok == QMARK || tok == STAR || tok == PLUS || tok == REPMN) + if (tok == REPMN && (minrep || maxrep)) + { + ntokens = nsubtoks(dfa->tindex); + tindex = dfa->tindex - ntokens; + if (maxrep < 0) + addtok(PLUS); + if (minrep == 0) + addtok(QMARK); + for (i = 1; i < minrep; ++i) + { + copytoks(tindex, ntokens); + addtok(CAT); + } + for (; i < maxrep; ++i) + { + copytoks(tindex, ntokens); + addtok(QMARK); + addtok(CAT); + } + tok = lex(); + } + else if (tok == REPMN) + { + dfa->tindex -= nsubtoks(dfa->tindex); + tok = lex(); + closure(); + } + else + { + addtok(tok); + tok = lex(); + } +} + +static void +branch (void) +{ + closure(); + while (tok != RPAREN && tok != OR && tok >= 0) + { + closure(); + addtok(CAT); + } +} + +static void +regexp (void) +{ + branch(); + while (tok == OR) + { + tok = lex(); + branch(); + addtok(OR); + } +} + +/* Main entry point for the parser. S is a string to be parsed, len is the + length of the string, so s can include NUL characters. D is a pointer to + the struct dfa to parse into. */ +void +dfaparse (char const *s, size_t len, struct dfa *d) +{ + dfa = d; + lexptr = s; + lexleft = len; + lasttok = END; + laststart = 1; + parens = 0; + if (MB_CUR_MAX > 1) + { + cur_mb_len = 0; + memset(&mbs, 0, sizeof mbs); + } + + if (! syntax_bits_set) + dfaerror(_("no syntax specified")); + + tok = lex(); + depth = d->depth; + + regexp(); + + if (tok != END) + dfaerror(_("unbalanced )")); + + addtok(END - d->nregexps); + addtok(CAT); + + if (d->nregexps) + addtok(OR); + + ++d->nregexps; +} + +/* Some primitives for operating on sets of positions. */ + +/* Copy one set to another; the destination must be large enough. */ +static void +copy (position_set const *src, position_set *dst) +{ + REALLOC_IF_NECESSARY(dst->elems, dst->alloc, src->nelem); + memcpy(dst->elems, src->elems, sizeof(dst->elems[0]) * src->nelem); + dst->nelem = src->nelem; +} + +static void +alloc_position_set (position_set *s, size_t size) +{ + MALLOC(s->elems, size); + s->alloc = size; + s->nelem = 0; +} + +/* Insert position P in set S. S is maintained in sorted order on + decreasing index. If there is already an entry in S with P.index + then merge (logically-OR) P's constraints into the one in S. + S->elems must point to an array large enough to hold the resulting set. */ +static void +insert (position p, position_set *s) +{ + int count = s->nelem; + int lo = 0, hi = count; + int i; + while (lo < hi) + { + int mid = ((unsigned) lo + (unsigned) hi) >> 1; + if (s->elems[mid].index > p.index) + lo = mid + 1; + else + hi = mid; + } + + if (lo < count && p.index == s->elems[lo].index) + { + s->elems[lo].constraint |= p.constraint; + return; + } + + REALLOC_IF_NECESSARY(s->elems, s->alloc, count + 1); + for (i = count; i > lo; i--) + s->elems[i] = s->elems[i - 1]; + s->elems[lo] = p; + ++s->nelem; +} + +/* Merge two sets of positions into a third. The result is exactly as if + the positions of both sets were inserted into an initially empty set. */ +static void +merge (position_set const *s1, position_set const *s2, position_set *m) +{ + int i = 0, j = 0; + + REALLOC_IF_NECESSARY(m->elems, m->alloc, s1->nelem + s2->nelem); + m->nelem = 0; + while (i < s1->nelem && j < s2->nelem) + if (s1->elems[i].index > s2->elems[j].index) + m->elems[m->nelem++] = s1->elems[i++]; + else if (s1->elems[i].index < s2->elems[j].index) + m->elems[m->nelem++] = s2->elems[j++]; + else + { + m->elems[m->nelem] = s1->elems[i++]; + m->elems[m->nelem++].constraint |= s2->elems[j++].constraint; + } + while (i < s1->nelem) + m->elems[m->nelem++] = s1->elems[i++]; + while (j < s2->nelem) + m->elems[m->nelem++] = s2->elems[j++]; +} + +/* Delete a position from a set. */ +static void +delete (position p, position_set *s) +{ + int i; + + for (i = 0; i < s->nelem; ++i) + if (p.index == s->elems[i].index) + break; + if (i < s->nelem) + for (--s->nelem; i < s->nelem; ++i) + s->elems[i] = s->elems[i + 1]; +} + +/* Find the index of the state corresponding to the given position set with + the given preceding context, or create a new state if there is no such + state. Context tells whether we got here on a newline or letter. */ +static int +state_index (struct dfa *d, position_set const *s, int context) +{ + int hash = 0; + int constraint; + int i, j; + + context &= ~CTX_NONE; + for (i = 0; i < s->nelem; ++i) + hash ^= s->elems[i].index + s->elems[i].constraint; + + /* Try to find a state that exactly matches the proposed one. */ + for (i = 0; i < d->sindex; ++i) + { + if (hash != d->states[i].hash || s->nelem != d->states[i].elems.nelem + || context != d->states[i].context) + continue; + for (j = 0; j < s->nelem; ++j) + if (s->elems[j].constraint + != d->states[i].elems.elems[j].constraint + || s->elems[j].index != d->states[i].elems.elems[j].index) + break; + if (j == s->nelem) + return i; + } + + /* We'll have to create a new state. */ + REALLOC_IF_NECESSARY(d->states, d->salloc, d->sindex + 1); + d->states[i].hash = hash; + alloc_position_set(&d->states[i].elems, s->nelem); + copy(s, &d->states[i].elems); + d->states[i].context = context; + d->states[i].backref = 0; + d->states[i].constraint = 0; + d->states[i].first_end = 0; + if (MBS_SUPPORT) + { + d->states[i].mbps.nelem = 0; + d->states[i].mbps.elems = NULL; + } + for (j = 0; j < s->nelem; ++j) + if (d->tokens[s->elems[j].index] < 0) + { + constraint = s->elems[j].constraint; + if (SUCCEEDS_IN_CONTEXT(constraint, context, CTX_NONE) + || SUCCEEDS_IN_CONTEXT(constraint, context, CTX_NEWLINE) + || SUCCEEDS_IN_CONTEXT(constraint, context, CTX_LETTER)) + d->states[i].constraint |= constraint; + if (! d->states[i].first_end) + d->states[i].first_end = d->tokens[s->elems[j].index]; + } + else if (d->tokens[s->elems[j].index] == BACKREF) + { + d->states[i].constraint = NO_CONSTRAINT; + d->states[i].backref = 1; + } + + ++d->sindex; + + return i; +} + +/* Find the epsilon closure of a set of positions. If any position of the set + contains a symbol that matches the empty string in some context, replace + that position with the elements of its follow labeled with an appropriate + constraint. Repeat exhaustively until no funny positions are left. + S->elems must be large enough to hold the result. */ +static void +epsclosure (position_set *s, struct dfa const *d) +{ + int i, j; + char *visited; /* array of booleans, enough to use char, not int */ + position p, old; + + CALLOC(visited, d->tindex); + + for (i = 0; i < s->nelem; ++i) + if (d->tokens[s->elems[i].index] >= NOTCHAR + && d->tokens[s->elems[i].index] != BACKREF +#if MBS_SUPPORT + && d->tokens[s->elems[i].index] != ANYCHAR + && d->tokens[s->elems[i].index] != MBCSET +#endif + && d->tokens[s->elems[i].index] < CSET) + { + old = s->elems[i]; + p.constraint = old.constraint; + delete(s->elems[i], s); + if (visited[old.index]) + { + --i; + continue; + } + visited[old.index] = 1; + switch (d->tokens[old.index]) + { + case BEGLINE: + p.constraint &= BEGLINE_CONSTRAINT; + break; + case ENDLINE: + p.constraint &= ENDLINE_CONSTRAINT; + break; + case BEGWORD: + p.constraint &= BEGWORD_CONSTRAINT; + break; + case ENDWORD: + p.constraint &= ENDWORD_CONSTRAINT; + break; + case LIMWORD: + p.constraint &= LIMWORD_CONSTRAINT; + break; + case NOTLIMWORD: + p.constraint &= NOTLIMWORD_CONSTRAINT; + break; + default: + break; + } + for (j = 0; j < d->follows[old.index].nelem; ++j) + { + p.index = d->follows[old.index].elems[j].index; + insert(p, s); + } + /* Force rescan to start at the beginning. */ + i = -1; + } + + free(visited); +} + +/* Returns the set of contexts for which there is at least one + character included in C. */ + +static int +charclass_context(charclass c) +{ + int context = 0; + unsigned int j; + + if (tstbit(eolbyte, c)) + context |= CTX_NEWLINE; + + for (j = 0; j < CHARCLASS_INTS; ++j) + { + if (c[j] & letters[j]) + context |= CTX_LETTER; + if (c[j] & ~(letters[j] | newline[j])) + context |= CTX_NONE; + } + + return context; +} + +/* Returns the subset of POSSIBLE_CONTEXTS on which the position set S + depends. Each context in the set of returned contexts (let's call it + SC) may have a different follow set than other contexts in SC, and + also different from the follow set of the complement set. However, + all contexts in the complement set will have the same follow set. */ + +static int _GL_ATTRIBUTE_PURE +state_separate_contexts (position_set *s, int possible_contexts) +{ + int separate_context = 0; + unsigned int j; + + for (j = 0; j < s->nelem; ++j) + { + if ((possible_contexts & CTX_NEWLINE) + && PREV_NEWLINE_DEPENDENT(s->elems[j].constraint)) + separate_context |= CTX_NEWLINE; + if ((possible_contexts & CTX_LETTER) + && PREV_LETTER_DEPENDENT(s->elems[j].constraint)) + separate_context |= CTX_LETTER; + } + + return separate_context; +} + + +/* Perform bottom-up analysis on the parse tree, computing various functions. + Note that at this point, we're pretending constructs like \< are real + characters rather than constraints on what can follow them. + + Nullable: A node is nullable if it is at the root of a regexp that can + match the empty string. + * EMPTY leaves are nullable. + * No other leaf is nullable. + * A QMARK or STAR node is nullable. + * A PLUS node is nullable if its argument is nullable. + * A CAT node is nullable if both its arguments are nullable. + * An OR node is nullable if either argument is nullable. + + Firstpos: The firstpos of a node is the set of positions (nonempty leaves) + that could correspond to the first character of a string matching the + regexp rooted at the given node. + * EMPTY leaves have empty firstpos. + * The firstpos of a nonempty leaf is that leaf itself. + * The firstpos of a QMARK, STAR, or PLUS node is the firstpos of its + argument. + * The firstpos of a CAT node is the firstpos of the left argument, union + the firstpos of the right if the left argument is nullable. + * The firstpos of an OR node is the union of firstpos of each argument. + + Lastpos: The lastpos of a node is the set of positions that could + correspond to the last character of a string matching the regexp at + the given node. + * EMPTY leaves have empty lastpos. + * The lastpos of a nonempty leaf is that leaf itself. + * The lastpos of a QMARK, STAR, or PLUS node is the lastpos of its + argument. + * The lastpos of a CAT node is the lastpos of its right argument, union + the lastpos of the left if the right argument is nullable. + * The lastpos of an OR node is the union of the lastpos of each argument. + + Follow: The follow of a position is the set of positions that could + correspond to the character following a character matching the node in + a string matching the regexp. At this point we consider special symbols + that match the empty string in some context to be just normal characters. + Later, if we find that a special symbol is in a follow set, we will + replace it with the elements of its follow, labeled with an appropriate + constraint. + * Every node in the firstpos of the argument of a STAR or PLUS node is in + the follow of every node in the lastpos. + * Every node in the firstpos of the second argument of a CAT node is in + the follow of every node in the lastpos of the first argument. + + Because of the postfix representation of the parse tree, the depth-first + analysis is conveniently done by a linear scan with the aid of a stack. + Sets are stored as arrays of the elements, obeying a stack-like allocation + scheme; the number of elements in each set deeper in the stack can be + used to determine the address of a particular set's array. */ +void +dfaanalyze (struct dfa *d, int searchflag) +{ + int *nullable; /* Nullable stack. */ + int *nfirstpos; /* Element count stack for firstpos sets. */ + position *firstpos; /* Array where firstpos elements are stored. */ + int *nlastpos; /* Element count stack for lastpos sets. */ + position *lastpos; /* Array where lastpos elements are stored. */ + position_set tmp; /* Temporary set for merging sets. */ + position_set merged; /* Result of merging sets. */ + int separate_contexts; /* Context wanted by some position. */ + int *o_nullable; + int *o_nfirst, *o_nlast; + position *o_firstpos, *o_lastpos; + int i, j; + position *pos; + +#ifdef DEBUG + fprintf(stderr, "dfaanalyze:\n"); + for (i = 0; i < d->tindex; ++i) + { + fprintf(stderr, " %d:", i); + prtok(d->tokens[i]); + } + putc('\n', stderr); +#endif + + d->searchflag = searchflag; + + MALLOC(nullable, d->depth); + o_nullable = nullable; + MALLOC(nfirstpos, d->depth); + o_nfirst = nfirstpos; + MALLOC(firstpos, d->nleaves); + o_firstpos = firstpos, firstpos += d->nleaves; + MALLOC(nlastpos, d->depth); + o_nlast = nlastpos; + MALLOC(lastpos, d->nleaves); + o_lastpos = lastpos, lastpos += d->nleaves; + alloc_position_set(&merged, d->nleaves); + + CALLOC(d->follows, d->tindex); + + for (i = 0; i < d->tindex; ++i) + { + switch (d->tokens[i]) + { + case EMPTY: + /* The empty set is nullable. */ + *nullable++ = 1; + + /* The firstpos and lastpos of the empty leaf are both empty. */ + *nfirstpos++ = *nlastpos++ = 0; + break; + + case STAR: + case PLUS: + /* Every element in the firstpos of the argument is in the follow + of every element in the lastpos. */ + tmp.nelem = nfirstpos[-1]; + tmp.elems = firstpos; + pos = lastpos; + for (j = 0; j < nlastpos[-1]; ++j) + { + merge(&tmp, &d->follows[pos[j].index], &merged); + copy(&merged, &d->follows[pos[j].index]); + } + + case QMARK: + /* A QMARK or STAR node is automatically nullable. */ + if (d->tokens[i] != PLUS) + nullable[-1] = 1; + break; + + case CAT: + /* Every element in the firstpos of the second argument is in the + follow of every element in the lastpos of the first argument. */ + tmp.nelem = nfirstpos[-1]; + tmp.elems = firstpos; + pos = lastpos + nlastpos[-1]; + for (j = 0; j < nlastpos[-2]; ++j) + { + merge(&tmp, &d->follows[pos[j].index], &merged); + copy(&merged, &d->follows[pos[j].index]); + } + + /* The firstpos of a CAT node is the firstpos of the first argument, + union that of the second argument if the first is nullable. */ + if (nullable[-2]) + nfirstpos[-2] += nfirstpos[-1]; + else + firstpos += nfirstpos[-1]; + --nfirstpos; + + /* The lastpos of a CAT node is the lastpos of the second argument, + union that of the first argument if the second is nullable. */ + if (nullable[-1]) + nlastpos[-2] += nlastpos[-1]; + else + { + pos = lastpos + nlastpos[-2]; + for (j = nlastpos[-1] - 1; j >= 0; --j) + pos[j] = lastpos[j]; + lastpos += nlastpos[-2]; + nlastpos[-2] = nlastpos[-1]; + } + --nlastpos; + + /* A CAT node is nullable if both arguments are nullable. */ + nullable[-2] = nullable[-1] && nullable[-2]; + --nullable; + break; + + case OR: + /* The firstpos is the union of the firstpos of each argument. */ + nfirstpos[-2] += nfirstpos[-1]; + --nfirstpos; + + /* The lastpos is the union of the lastpos of each argument. */ + nlastpos[-2] += nlastpos[-1]; + --nlastpos; + + /* An OR node is nullable if either argument is nullable. */ + nullable[-2] = nullable[-1] || nullable[-2]; + --nullable; + break; + + default: + /* Anything else is a nonempty position. (Note that special + constructs like \< are treated as nonempty strings here; + an "epsilon closure" effectively makes them nullable later. + Backreferences have to get a real position so we can detect + transitions on them later. But they are nullable. */ + *nullable++ = d->tokens[i] == BACKREF; + + /* This position is in its own firstpos and lastpos. */ + *nfirstpos++ = *nlastpos++ = 1; + --firstpos, --lastpos; + firstpos->index = lastpos->index = i; + firstpos->constraint = lastpos->constraint = NO_CONSTRAINT; + + /* Allocate the follow set for this position. */ + alloc_position_set(&d->follows[i], 1); + break; + } +#ifdef DEBUG + /* ... balance the above nonsyntactic #ifdef goo... */ + fprintf(stderr, "node %d:", i); + prtok(d->tokens[i]); + putc('\n', stderr); + fprintf(stderr, nullable[-1] ? " nullable: yes\n" : " nullable: no\n"); + fprintf(stderr, " firstpos:"); + for (j = nfirstpos[-1] - 1; j >= 0; --j) + { + fprintf(stderr, " %d:", firstpos[j].index); + prtok(d->tokens[firstpos[j].index]); + } + fprintf(stderr, "\n lastpos:"); + for (j = nlastpos[-1] - 1; j >= 0; --j) + { + fprintf(stderr, " %d:", lastpos[j].index); + prtok(d->tokens[lastpos[j].index]); + } + putc('\n', stderr); +#endif + } + + /* For each follow set that is the follow set of a real position, replace + it with its epsilon closure. */ + for (i = 0; i < d->tindex; ++i) + if (d->tokens[i] < NOTCHAR || d->tokens[i] == BACKREF +#if MBS_SUPPORT + || d->tokens[i] == ANYCHAR + || d->tokens[i] == MBCSET +#endif + || d->tokens[i] >= CSET) + { +#ifdef DEBUG + fprintf(stderr, "follows(%d:", i); + prtok(d->tokens[i]); + fprintf(stderr, "):"); + for (j = d->follows[i].nelem - 1; j >= 0; --j) + { + fprintf(stderr, " %d:", d->follows[i].elems[j].index); + prtok(d->tokens[d->follows[i].elems[j].index]); + } + putc('\n', stderr); +#endif + copy(&d->follows[i], &merged); + epsclosure(&merged, d); + copy(&merged, &d->follows[i]); + } + + /* Get the epsilon closure of the firstpos of the regexp. The result will + be the set of positions of state 0. */ + merged.nelem = 0; + for (i = 0; i < nfirstpos[-1]; ++i) + insert(firstpos[i], &merged); + epsclosure(&merged, d); + + /* Build the initial state. */ + d->salloc = 1; + d->sindex = 0; + MALLOC(d->states, d->salloc); + + separate_contexts = state_separate_contexts(&merged, CTX_NEWLINE); + state_index(d, &merged, separate_contexts); + + free(o_nullable); + free(o_nfirst); + free(o_firstpos); + free(o_nlast); + free(o_lastpos); + free(merged.elems); +} + + +/* Find, for each character, the transition out of state s of d, and store + it in the appropriate slot of trans. + + We divide the positions of s into groups (positions can appear in more + than one group). Each group is labeled with a set of characters that + every position in the group matches (taking into account, if necessary, + preceding context information of s). For each group, find the union + of the its elements' follows. This set is the set of positions of the + new state. For each character in the group's label, set the transition + on this character to be to a state corresponding to the set's positions, + and its associated backward context information, if necessary. + + If we are building a searching matcher, we include the positions of state + 0 in every state. + + The collection of groups is constructed by building an equivalence-class + partition of the positions of s. + + For each position, find the set of characters C that it matches. Eliminate + any characters from C that fail on grounds of backward context. + + Search through the groups, looking for a group whose label L has nonempty + intersection with C. If L - C is nonempty, create a new group labeled + L - C and having the same positions as the current group, and set L to + the intersection of L and C. Insert the position in this group, set + C = C - L, and resume scanning. + + If after comparing with every group there are characters remaining in C, + create a new group labeled with the characters of C and insert this + position in that group. */ +void +dfastate (int s, struct dfa *d, int trans[]) +{ + leaf_set *grps; /* As many as will ever be needed. */ + charclass *labels; /* Labels corresponding to the groups. */ + int ngrps = 0; /* Number of groups actually used. */ + position pos; /* Current position being considered. */ + charclass matches; /* Set of matching characters. */ + int matchesf; /* True if matches is nonempty. */ + charclass intersect; /* Intersection with some label set. */ + int intersectf; /* True if intersect is nonempty. */ + charclass leftovers; /* Stuff in the label that didn't match. */ + int leftoversf; /* True if leftovers is nonempty. */ + position_set follows; /* Union of the follows of some group. */ + position_set tmp; /* Temporary space for merging sets. */ + int possible_contexts; /* Contexts that this group can match. */ + int separate_contexts; /* Context that new state wants to know. */ + int state; /* New state. */ + int state_newline; /* New state on a newline transition. */ + int state_letter; /* New state on a letter transition. */ + int next_isnt_1st_byte = 0; /* Flag if we can't add state0. */ + int i, j, k; + + MALLOC (grps, NOTCHAR); + MALLOC (labels, NOTCHAR); + + zeroset(matches); + + for (i = 0; i < d->states[s].elems.nelem; ++i) + { + pos = d->states[s].elems.elems[i]; + if (d->tokens[pos.index] >= 0 && d->tokens[pos.index] < NOTCHAR) + setbit(d->tokens[pos.index], matches); + else if (d->tokens[pos.index] >= CSET) + copyset(d->charclasses[d->tokens[pos.index] - CSET], matches); + else if (MBS_SUPPORT + && (d->tokens[pos.index] == ANYCHAR + || d->tokens[pos.index] == MBCSET)) + /* MB_CUR_MAX > 1 */ + { + /* ANYCHAR and MBCSET must match with a single character, so we + must put it to d->states[s].mbps, which contains the positions + which can match with a single character not a byte. */ + if (d->states[s].mbps.nelem == 0) + alloc_position_set(&d->states[s].mbps, 1); + insert(pos, &(d->states[s].mbps)); + continue; + } + else + continue; + + /* Some characters may need to be eliminated from matches because + they fail in the current context. */ + if (pos.constraint != 0xFF) + { + if (! MATCHES_NEWLINE_CONTEXT(pos.constraint, + d->states[s].context & CTX_NEWLINE, + CTX_NEWLINE)) + clrbit(eolbyte, matches); + if (! MATCHES_NEWLINE_CONTEXT(pos.constraint, + d->states[s].context & CTX_NEWLINE, 0)) + for (j = 0; j < CHARCLASS_INTS; ++j) + matches[j] &= newline[j]; + if (! MATCHES_LETTER_CONTEXT(pos.constraint, + d->states[s].context & CTX_LETTER, + CTX_LETTER)) + for (j = 0; j < CHARCLASS_INTS; ++j) + matches[j] &= ~letters[j]; + if (! MATCHES_LETTER_CONTEXT(pos.constraint, + d->states[s].context & CTX_LETTER, 0)) + for (j = 0; j < CHARCLASS_INTS; ++j) + matches[j] &= letters[j]; + + /* If there are no characters left, there's no point in going on. */ + for (j = 0; j < CHARCLASS_INTS && !matches[j]; ++j) + continue; + if (j == CHARCLASS_INTS) + continue; + } + + for (j = 0; j < ngrps; ++j) + { + /* If matches contains a single character only, and the current + group's label doesn't contain that character, go on to the + next group. */ + if (d->tokens[pos.index] >= 0 && d->tokens[pos.index] < NOTCHAR + && !tstbit(d->tokens[pos.index], labels[j])) + continue; + + /* Check if this group's label has a nonempty intersection with + matches. */ + intersectf = 0; + for (k = 0; k < CHARCLASS_INTS; ++k) + (intersect[k] = matches[k] & labels[j][k]) ? (intersectf = 1) : 0; + if (! intersectf) + continue; + + /* It does; now find the set differences both ways. */ + leftoversf = matchesf = 0; + for (k = 0; k < CHARCLASS_INTS; ++k) + { + /* Even an optimizing compiler can't know this for sure. */ + int match = matches[k], label = labels[j][k]; + + (leftovers[k] = ~match & label) ? (leftoversf = 1) : 0; + (matches[k] = match & ~label) ? (matchesf = 1) : 0; + } + + /* If there were leftovers, create a new group labeled with them. */ + if (leftoversf) + { + copyset(leftovers, labels[ngrps]); + copyset(intersect, labels[j]); + MALLOC(grps[ngrps].elems, d->nleaves); + memcpy(grps[ngrps].elems, grps[j].elems, + sizeof (grps[j].elems[0]) * grps[j].nelem); + grps[ngrps].nelem = grps[j].nelem; + ++ngrps; + } + + /* Put the position in the current group. The constraint is + irrelevant here. */ + grps[j].elems[grps[j].nelem++] = pos.index; + + /* If every character matching the current position has been + accounted for, we're done. */ + if (! matchesf) + break; + } + + /* If we've passed the last group, and there are still characters + unaccounted for, then we'll have to create a new group. */ + if (j == ngrps) + { + copyset(matches, labels[ngrps]); + zeroset(matches); + MALLOC(grps[ngrps].elems, d->nleaves); + grps[ngrps].nelem = 1; + grps[ngrps].elems[0] = pos.index; + ++ngrps; + } + } + + alloc_position_set(&follows, d->nleaves); + alloc_position_set(&tmp, d->nleaves); + + /* If we are a searching matcher, the default transition is to a state + containing the positions of state 0, otherwise the default transition + is to fail miserably. */ + if (d->searchflag) + { + /* Find the state(s) corresponding to the positions of state 0. */ + copy(&d->states[0].elems, &follows); + separate_contexts = state_separate_contexts(&follows, CTX_ANY); + state = state_index(d, &follows, 0); + if (separate_contexts & CTX_NEWLINE) + state_newline = state_index(d, &follows, CTX_NEWLINE); + else + state_newline = state; + if (separate_contexts & CTX_LETTER) + state_letter = state_index(d, &follows, CTX_LETTER); + else + state_letter = state; + + for (i = 0; i < NOTCHAR; ++i) + trans[i] = (IS_WORD_CONSTITUENT(i)) ? state_letter : state; + trans[eolbyte] = state_newline; + } + else + for (i = 0; i < NOTCHAR; ++i) + trans[i] = -1; + + for (i = 0; i < ngrps; ++i) + { + follows.nelem = 0; + + /* Find the union of the follows of the positions of the group. + This is a hideously inefficient loop. Fix it someday. */ + for (j = 0; j < grps[i].nelem; ++j) + for (k = 0; k < d->follows[grps[i].elems[j]].nelem; ++k) + insert(d->follows[grps[i].elems[j]].elems[k], &follows); + + if (d->mb_cur_max > 1) + { + /* If a token in follows.elems is not 1st byte of a multibyte + character, or the states of follows must accept the bytes + which are not 1st byte of the multibyte character. + Then, if a state of follows encounter a byte, it must not be + a 1st byte of a multibyte character nor single byte character. + We cansel to add state[0].follows to next state, because + state[0] must accept 1st-byte + + For example, we assume is a certain single byte + character, is a certain multibyte character, and the + codepoint of equals the 2nd byte of the codepoint of + . + When state[0] accepts , state[i] transit to state[i+1] + by accepting accepts 1st byte of , and state[i+1] + accepts 2nd byte of , if state[i+1] encounter the + codepoint of , it must not be but 2nd byte of + , so we cannot add state[0]. */ + + next_isnt_1st_byte = 0; + for (j = 0; j < follows.nelem; ++j) + { + if (!(d->multibyte_prop[follows.elems[j].index] & 1)) + { + next_isnt_1st_byte = 1; + break; + } + } + } + + /* If we are building a searching matcher, throw in the positions + of state 0 as well. */ + if (d->searchflag + && (! MBS_SUPPORT + || (d->mb_cur_max == 1 || !next_isnt_1st_byte))) + for (j = 0; j < d->states[0].elems.nelem; ++j) + insert(d->states[0].elems.elems[j], &follows); + + /* Find out if the new state will want any context information. */ + possible_contexts = charclass_context(labels[i]); + separate_contexts = state_separate_contexts(&follows, possible_contexts); + + /* Find the state(s) corresponding to the union of the follows. */ + state = state_index(d, &follows, 0); + if (separate_contexts & CTX_NEWLINE) + state_newline = state_index(d, &follows, CTX_NEWLINE); + else + state_newline = state; + if (separate_contexts & CTX_LETTER) + state_letter = state_index(d, &follows, CTX_LETTER); + else + state_letter = state; + + /* Set the transitions for each character in the current label. */ + for (j = 0; j < CHARCLASS_INTS; ++j) + for (k = 0; k < INTBITS; ++k) + if (labels[i][j] & 1 << k) + { + int c = j * INTBITS + k; + + if (c == eolbyte) + trans[c] = state_newline; + else if (IS_WORD_CONSTITUENT(c)) + trans[c] = state_letter; + else if (c < NOTCHAR) + trans[c] = state; + } + } + + for (i = 0; i < ngrps; ++i) + free(grps[i].elems); + free(follows.elems); + free(tmp.elems); + free(grps); + free(labels); +} + +/* Some routines for manipulating a compiled dfa's transition tables. + Each state may or may not have a transition table; if it does, and it + is a non-accepting state, then d->trans[state] points to its table. + If it is an accepting state then d->fails[state] points to its table. + If it has no table at all, then d->trans[state] is NULL. + TODO: Improve this comment, get rid of the unnecessary redundancy. */ + +static void +build_state (int s, struct dfa *d) +{ + int *trans; /* The new transition table. */ + int i; + + /* Set an upper limit on the number of transition tables that will ever + exist at once. 1024 is arbitrary. The idea is that the frequently + used transition tables will be quickly rebuilt, whereas the ones that + were only needed once or twice will be cleared away. */ + if (d->trcount >= 1024) + { + for (i = 0; i < d->tralloc; ++i) + { + free(d->trans[i]); + free(d->fails[i]); + d->trans[i] = d->fails[i] = NULL; + } + d->trcount = 0; + } + + ++d->trcount; + + /* Set up the success bits for this state. */ + d->success[s] = 0; + if (ACCEPTS_IN_CONTEXT(d->states[s].context, CTX_NEWLINE, s, *d)) + d->success[s] |= CTX_NEWLINE; + if (ACCEPTS_IN_CONTEXT(d->states[s].context, CTX_LETTER, s, *d)) + d->success[s] |= CTX_LETTER; + if (ACCEPTS_IN_CONTEXT(d->states[s].context, CTX_NONE, s, *d)) + d->success[s] |= CTX_NONE; + + MALLOC(trans, NOTCHAR); + dfastate(s, d, trans); + + /* Now go through the new transition table, and make sure that the trans + and fail arrays are allocated large enough to hold a pointer for the + largest state mentioned in the table. */ + for (i = 0; i < NOTCHAR; ++i) + if (trans[i] >= d->tralloc) + { + int oldalloc = d->tralloc; + + while (trans[i] >= d->tralloc) + d->tralloc *= 2; + REALLOC(d->realtrans, d->tralloc + 1); + d->trans = d->realtrans + 1; + REALLOC(d->fails, d->tralloc); + REALLOC(d->success, d->tralloc); + REALLOC(d->newlines, d->tralloc); + while (oldalloc < d->tralloc) + { + d->trans[oldalloc] = NULL; + d->fails[oldalloc++] = NULL; + } + } + + /* Keep the newline transition in a special place so we can use it as + a sentinel. */ + d->newlines[s] = trans[eolbyte]; + trans[eolbyte] = -1; + + if (ACCEPTING(s, *d)) + d->fails[s] = trans; + else + d->trans[s] = trans; +} + +static void +build_state_zero (struct dfa *d) +{ + d->tralloc = 1; + d->trcount = 0; + CALLOC(d->realtrans, d->tralloc + 1); + d->trans = d->realtrans + 1; + CALLOC(d->fails, d->tralloc); + MALLOC(d->success, d->tralloc); + MALLOC(d->newlines, d->tralloc); + build_state(0, d); +} + +/* Multibyte character handling sub-routines for dfaexec. */ + +/* Initial state may encounter the byte which is not a single byte character + nor 1st byte of a multibyte character. But it is incorrect for initial + state to accept such a byte. + For example, in sjis encoding the regular expression like "\\" accepts + the codepoint 0x5c, but should not accept the 2nd byte of the codepoint + 0x815c. Then Initial state must skip the bytes which are not a single byte + character nor 1st byte of a multibyte character. */ +#define SKIP_REMAINS_MB_IF_INITIAL_STATE(s, p) \ + if (s == 0) \ + { \ + while (inputwcs[p - buf_begin] == 0 \ + && mblen_buf[p - buf_begin] > 0 \ + && (unsigned char const *) p < buf_end) \ + ++p; \ + if ((char *) p >= end) \ + { \ + free(mblen_buf); \ + free(inputwcs); \ + *end = saved_end; \ + return NULL; \ + } \ + } + +static void +realloc_trans_if_necessary(struct dfa *d, int new_state) +{ + /* Make sure that the trans and fail arrays are allocated large enough + to hold a pointer for the new state. */ + if (new_state >= d->tralloc) + { + int oldalloc = d->tralloc; + + while (new_state >= d->tralloc) + d->tralloc *= 2; + REALLOC(d->realtrans, d->tralloc + 1); + d->trans = d->realtrans + 1; + REALLOC(d->fails, d->tralloc); + REALLOC(d->success, d->tralloc); + REALLOC(d->newlines, d->tralloc); + while (oldalloc < d->tralloc) + { + d->trans[oldalloc] = NULL; + d->fails[oldalloc++] = NULL; + } + } +} + +/* Return values of transit_state_singlebyte(), and + transit_state_consume_1char. */ +typedef enum +{ + TRANSIT_STATE_IN_PROGRESS, /* State transition has not finished. */ + TRANSIT_STATE_DONE, /* State transition has finished. */ + TRANSIT_STATE_END_BUFFER /* Reach the end of the buffer. */ +} status_transit_state; + +/* Consume a single byte and transit state from 's' to '*next_state'. + This function is almost same as the state transition routin in dfaexec(). + But state transition is done just once, otherwise matching succeed or + reach the end of the buffer. */ +static status_transit_state +transit_state_singlebyte (struct dfa *d, int s, unsigned char const *p, + int *next_state) +{ + int *t; + int works = s; + + status_transit_state rval = TRANSIT_STATE_IN_PROGRESS; + + while (rval == TRANSIT_STATE_IN_PROGRESS) + { + if ((t = d->trans[works]) != NULL) + { + works = t[*p]; + rval = TRANSIT_STATE_DONE; + if (works < 0) + works = 0; + } + else if (works < 0) + { + if (p == buf_end) + { + /* At the moment, it must not happen. */ + abort (); + } + works = 0; + } + else if (d->fails[works]) + { + works = d->fails[works][*p]; + rval = TRANSIT_STATE_DONE; + } + else + { + build_state(works, d); + } + } + *next_state = works; + return rval; +} + +/* Match a "." against the current context. buf_begin[IDX] is the + current position. Return the length of the match, in bytes. + POS is the position of the ".". */ +static int +match_anychar (struct dfa *d, int s, position pos, int idx) +{ + int context; + wchar_t wc; + int mbclen; + + wc = inputwcs[idx]; + mbclen = (mblen_buf[idx] == 0)? 1 : mblen_buf[idx]; + + /* Check syntax bits. */ + if (wc == (wchar_t)eolbyte) + { + if (!(syntax_bits & RE_DOT_NEWLINE)) + return 0; + } + else if (wc == (wchar_t)'\0') + { + if (syntax_bits & RE_DOT_NOT_NULL) + return 0; + } + + context = wchar_context(wc); + if (!SUCCEEDS_IN_CONTEXT(pos.constraint, d->states[s].context, context)) + return 0; + + return mbclen; +} + +/* Match a bracket expression against the current context. + buf_begin[IDX] is the current position. + Return the length of the match, in bytes. + POS is the position of the bracket expression. */ +static int +match_mb_charset (struct dfa *d, int s, position pos, int idx) +{ + int i; + int match; /* Flag which represent that matching succeed. */ + int match_len; /* Length of the character (or collating element) + with which this operator match. */ + int op_len; /* Length of the operator. */ + char buffer[128]; + + /* Pointer to the structure to which we are currently refering. */ + struct mb_char_classes *work_mbc; + + int context; + wchar_t wc; /* Current refering character. */ + + wc = inputwcs[idx]; + + /* Check syntax bits. */ + if (wc == (wchar_t)eolbyte) + { + if (!(syntax_bits & RE_DOT_NEWLINE)) + return 0; + } + else if (wc == (wchar_t)'\0') + { + if (syntax_bits & RE_DOT_NOT_NULL) + return 0; + } + + context = wchar_context(wc); + if (!SUCCEEDS_IN_CONTEXT(pos.constraint, d->states[s].context, context)) + return 0; + + /* Assign the current refering operator to work_mbc. */ + work_mbc = &(d->mbcsets[(d->multibyte_prop[pos.index]) >> 2]); + match = !work_mbc->invert; + match_len = (mblen_buf[idx] == 0)? 1 : mblen_buf[idx]; + + /* Match in range 0-255? */ + if (wc < NOTCHAR && work_mbc->cset != -1 + && tstbit((unsigned char)wc, d->charclasses[work_mbc->cset])) + goto charset_matched; + + /* match with a character class? */ + for (i = 0; inch_classes; i++) + { + if (iswctype((wint_t)wc, work_mbc->ch_classes[i])) + goto charset_matched; + } + + strncpy(buffer, (char const *) buf_begin + idx, match_len); + buffer[match_len] = '\0'; + + /* match with an equivalent class? */ + for (i = 0; inequivs; i++) + { + op_len = strlen(work_mbc->equivs[i]); + strncpy(buffer, (char const *) buf_begin + idx, op_len); + buffer[op_len] = '\0'; + if (strcoll(work_mbc->equivs[i], buffer) == 0) + { + match_len = op_len; + goto charset_matched; + } + } + + /* match with a collating element? */ + for (i = 0; incoll_elems; i++) + { + op_len = strlen(work_mbc->coll_elems[i]); + strncpy(buffer, (char const *) buf_begin + idx, op_len); + buffer[op_len] = '\0'; + + if (strcoll(work_mbc->coll_elems[i], buffer) == 0) + { + match_len = op_len; + goto charset_matched; + } + } + + /* match with a range? */ + for (i = 0; inranges; i++) + { + if (work_mbc->range_sts[i] <= wc && + wc <= work_mbc->range_ends[i]) + goto charset_matched; + } + + /* match with a character? */ + for (i = 0; inchars; i++) + { + if (wc == work_mbc->chars[i]) + goto charset_matched; + } + + match = !match; + + charset_matched: + return match ? match_len : 0; +} + +/* Check each of `d->states[s].mbps.elem' can match or not. Then return the + array which corresponds to `d->states[s].mbps.elem' and each element of + the array contains the amount of the bytes with which the element can + match. + `idx' is the index from the buf_begin, and it is the current position + in the buffer. + Caller MUST free the array which this function return. */ +static int* +check_matching_with_multibyte_ops (struct dfa *d, int s, int idx) +{ + int i; + int* rarray; + + MALLOC(rarray, d->states[s].mbps.nelem); + for (i = 0; i < d->states[s].mbps.nelem; ++i) + { + position pos = d->states[s].mbps.elems[i]; + switch(d->tokens[pos.index]) + { + case ANYCHAR: + rarray[i] = match_anychar(d, s, pos, idx); + break; + case MBCSET: + rarray[i] = match_mb_charset(d, s, pos, idx); + break; + default: + break; /* cannot happen. */ + } + } + return rarray; +} + +/* Consume a single character and enumerate all of the positions which can + be next position from the state `s'. + `match_lens' is the input. It can be NULL, but it can also be the output + of check_matching_with_multibyte_ops() for optimization. + `mbclen' and `pps' are the output. `mbclen' is the length of the + character consumed, and `pps' is the set this function enumerate. */ +static status_transit_state +transit_state_consume_1char (struct dfa *d, int s, unsigned char const **pp, + int *match_lens, int *mbclen, position_set *pps) +{ + int i, j; + int s1, s2; + int* work_mbls; + status_transit_state rs = TRANSIT_STATE_DONE; + + /* Calculate the length of the (single/multi byte) character + to which p points. */ + *mbclen = (mblen_buf[*pp - buf_begin] == 0)? 1 + : mblen_buf[*pp - buf_begin]; + + /* Calculate the state which can be reached from the state `s' by + consuming `*mbclen' single bytes from the buffer. */ + s1 = s; + for (i = 0; i < *mbclen; i++) + { + s2 = s1; + rs = transit_state_singlebyte(d, s2, (*pp)++, &s1); + } + /* Copy the positions contained by `s1' to the set `pps'. */ + copy(&(d->states[s1].elems), pps); + + /* Check (inputed)match_lens, and initialize if it is NULL. */ + if (match_lens == NULL && d->states[s].mbps.nelem != 0) + work_mbls = check_matching_with_multibyte_ops(d, s, *pp - buf_begin); + else + work_mbls = match_lens; + + /* Add all of the positions which can be reached from `s' by consuming + a single character. */ + for (i = 0; i < d->states[s].mbps.nelem ; i++) + { + if (work_mbls[i] == *mbclen) + for (j = 0; j < d->follows[d->states[s].mbps.elems[i].index].nelem; + j++) + insert(d->follows[d->states[s].mbps.elems[i].index].elems[j], + pps); + } + + if (match_lens == NULL && work_mbls != NULL) + free(work_mbls); + return rs; +} + +/* Transit state from s, then return new state and update the pointer of the + buffer. This function is for some operator which can match with a multi- + byte character or a collating element (which may be multi characters). */ +static int +transit_state (struct dfa *d, int s, unsigned char const **pp) +{ + int s1; + int mbclen; /* The length of current input multibyte character. */ + int maxlen = 0; + int i, j; + int *match_lens = NULL; + int nelem = d->states[s].mbps.nelem; /* Just a alias. */ + position_set follows; + unsigned char const *p1 = *pp; + wchar_t wc; + + if (nelem > 0) + /* This state has (a) multibyte operator(s). + We check whether each of them can match or not. */ + { + /* Note: caller must free the return value of this function. */ + match_lens = check_matching_with_multibyte_ops(d, s, *pp - buf_begin); + + for (i = 0; i < nelem; i++) + /* Search the operator which match the longest string, + in this state. */ + { + if (match_lens[i] > maxlen) + maxlen = match_lens[i]; + } + } + + if (nelem == 0 || maxlen == 0) + /* This state has no multibyte operator which can match. + We need to check only one single byte character. */ + { + status_transit_state rs; + rs = transit_state_singlebyte(d, s, *pp, &s1); + + /* We must update the pointer if state transition succeeded. */ + if (rs == TRANSIT_STATE_DONE) + ++*pp; + + free(match_lens); + return s1; + } + + /* This state has some operators which can match a multibyte character. */ + alloc_position_set(&follows, d->nleaves); + + /* `maxlen' may be longer than the length of a character, because it may + not be a character but a (multi character) collating element. + We enumerate all of the positions which `s' can reach by consuming + `maxlen' bytes. */ + transit_state_consume_1char(d, s, pp, match_lens, &mbclen, &follows); + + wc = inputwcs[*pp - mbclen - buf_begin]; + s1 = state_index(d, &follows, wchar_context (wc)); + realloc_trans_if_necessary(d, s1); + + while (*pp - p1 < maxlen) + { + transit_state_consume_1char(d, s1, pp, NULL, &mbclen, &follows); + + for (i = 0; i < nelem ; i++) + { + if (match_lens[i] == *pp - p1) + for (j = 0; + j < d->follows[d->states[s1].mbps.elems[i].index].nelem; j++) + insert(d->follows[d->states[s1].mbps.elems[i].index].elems[j], + &follows); + } + + wc = inputwcs[*pp - mbclen - buf_begin]; + s1 = state_index(d, &follows, wchar_context (wc)); + realloc_trans_if_necessary(d, s1); + } + free(match_lens); + free(follows.elems); + return s1; +} + + +/* Initialize mblen_buf and inputwcs with data from the next line. */ + +static void +prepare_wc_buf (const char *begin, const char *end) +{ +#if MBS_SUPPORT + unsigned char eol = eolbyte; + size_t remain_bytes, i; + + buf_begin = (unsigned char *) begin; + + remain_bytes = 0; + for (i = 0; i < end - begin + 1; i++) + { + if (remain_bytes == 0) + { + remain_bytes + = mbrtowc(inputwcs + i, begin + i, end - begin - i + 1, &mbs); + if (remain_bytes < 1 + || remain_bytes == (size_t) -1 + || remain_bytes == (size_t) -2 + || (remain_bytes == 1 && inputwcs[i] == (wchar_t)begin[i])) + { + remain_bytes = 0; + inputwcs[i] = (wchar_t)begin[i]; + mblen_buf[i] = 0; + if (begin[i] == eol) + break; + } + else + { + mblen_buf[i] = remain_bytes; + remain_bytes--; + } + } + else + { + mblen_buf[i] = remain_bytes; + inputwcs[i] = 0; + remain_bytes--; + } + } + + buf_end = (unsigned char *) (begin + i); + mblen_buf[i] = 0; + inputwcs[i] = 0; /* sentinel */ +#endif /* MBS_SUPPORT */ +} + +/* Search through a buffer looking for a match to the given struct dfa. + Find the first occurrence of a string matching the regexp in the + buffer, and the shortest possible version thereof. Return a pointer to + the first character after the match, or NULL if none is found. BEGIN + points to the beginning of the buffer, and END points to the first byte + after its end. Note however that we store a sentinel byte (usually + newline) in *END, so the actual buffer must be one byte longer. + When ALLOW_NL is nonzero, newlines may appear in the matching string. + If COUNT is non-NULL, increment *COUNT once for each newline processed. + Finally, if BACKREF is non-NULL set *BACKREF to indicate whether we + encountered a back-reference (1) or not (0). The caller may use this + to decide whether to fall back on a backtracking matcher. */ +char * +dfaexec (struct dfa *d, char const *begin, char *end, + int allow_nl, int *count, int *backref) +{ + int s, s1; /* Current state. */ + unsigned char const *p; /* Current input character. */ + int **trans, *t; /* Copy of d->trans so it can be optimized + into a register. */ + unsigned char eol = eolbyte; /* Likewise for eolbyte. */ + unsigned char saved_end; + + if (! d->tralloc) + build_state_zero(d); + + s = s1 = 0; + p = (unsigned char const *) begin; + trans = d->trans; + saved_end = *(unsigned char *) end; + *end = eol; + + if (d->mb_cur_max > 1) + { + MALLOC(mblen_buf, end - begin + 2); + MALLOC(inputwcs, end - begin + 2); + memset(&mbs, 0, sizeof(mbstate_t)); + prepare_wc_buf ((const char *) p, end); + } + + for (;;) + { + if (d->mb_cur_max > 1) + while ((t = trans[s]) != NULL) + { + if (p > buf_end) + break; + s1 = s; + SKIP_REMAINS_MB_IF_INITIAL_STATE(s, p); + + if (d->states[s].mbps.nelem == 0) + { + s = t[*p++]; + continue; + } + + /* Falling back to the glibc matcher in this case gives + better performance (up to 25% better on [a-z], for + example) and enables support for collating symbols and + equivalence classes. */ + if (backref) + { + *backref = 1; + free(mblen_buf); + free(inputwcs); + *end = saved_end; + return (char *) p; + } + + /* Can match with a multibyte character (and multi character + collating element). Transition table might be updated. */ + s = transit_state(d, s, &p); + trans = d->trans; + } + else + { + while ((t = trans[s]) != NULL) + { + s1 = t[*p++]; + if ((t = trans[s1]) == NULL) + { + int tmp = s; s = s1; s1 = tmp; /* swap */ + break; + } + s = t[*p++]; + } + } + + if (s >= 0 && (char *) p <= end && d->fails[s]) + { + if (d->success[s] & sbit[*p]) + { + if (backref) + *backref = (d->states[s].backref != 0); + if (d->mb_cur_max > 1) + { + free(mblen_buf); + free(inputwcs); + } + *end = saved_end; + return (char *) p; + } + + s1 = s; + if (d->mb_cur_max > 1) + { + /* Can match with a multibyte character (and multicharacter + collating element). Transition table might be updated. */ + s = transit_state(d, s, &p); + trans = d->trans; + } + else + s = d->fails[s][*p++]; + continue; + } + + /* If the previous character was a newline, count it. */ + if ((char *) p <= end && p[-1] == eol) + { + if (count) + ++*count; + + if (d->mb_cur_max > 1) + prepare_wc_buf ((const char *) p, end); + } + + /* Check if we've run off the end of the buffer. */ + if ((char *) p > end) + { + if (d->mb_cur_max > 1) + { + free(mblen_buf); + free(inputwcs); + } + *end = saved_end; + return NULL; + } + + if (s >= 0) + { + build_state(s, d); + trans = d->trans; + continue; + } + + if (p[-1] == eol && allow_nl) + { + s = d->newlines[s1]; + continue; + } + + s = 0; + } +} + +static void +free_mbdata (struct dfa *d) +{ + unsigned int i; + + free(d->multibyte_prop); + d->multibyte_prop = NULL; + + for (i = 0; i < d->nmbcsets; ++i) + { + unsigned int j; + struct mb_char_classes *p = &(d->mbcsets[i]); + free(p->chars); + free(p->ch_classes); + free(p->range_sts); + free(p->range_ends); + + for (j = 0; j < p->nequivs; ++j) + free(p->equivs[j]); + free(p->equivs); + + for (j = 0; j < p->ncoll_elems; ++j) + free(p->coll_elems[j]); + free(p->coll_elems); + } + + free(d->mbcsets); + d->mbcsets = NULL; + d->nmbcsets = 0; +} + +/* Initialize the components of a dfa that the other routines don't + initialize for themselves. */ +void +dfainit (struct dfa *d) +{ + memset (d, 0, sizeof *d); + + d->calloc = 1; + MALLOC(d->charclasses, d->calloc); + + d->talloc = 1; + MALLOC(d->tokens, d->talloc); + + d->mb_cur_max = MB_CUR_MAX; + + if (d->mb_cur_max > 1) + { + d->nmultibyte_prop = 1; + MALLOC(d->multibyte_prop, d->nmultibyte_prop); + d->mbcsets_alloc = 1; + MALLOC(d->mbcsets, d->mbcsets_alloc); + } +} + +static void +dfaoptimize (struct dfa *d) +{ + unsigned int i; + + if (!MBS_SUPPORT || !using_utf8()) + return; + + for (i = 0; i < d->tindex; ++i) + { + switch(d->tokens[i]) + { + case ANYCHAR: + /* Lowered. */ + abort (); + case MBCSET: + /* Requires multi-byte algorithm. */ + return; + default: + break; + } + } + + free_mbdata (d); + d->mb_cur_max = 1; +} + +/* Parse and analyze a single string of the given length. */ +void +dfacomp (char const *s, size_t len, struct dfa *d, int searchflag) +{ + dfainit(d); + dfaparse(s, len, d); + dfamust(d); + dfaoptimize(d); + dfaanalyze(d, searchflag); +} + +/* Free the storage held by the components of a dfa. */ +void +dfafree (struct dfa *d) +{ + int i; + struct dfamust *dm, *ndm; + + free(d->charclasses); + free(d->tokens); + + if (d->mb_cur_max > 1) + free_mbdata(d); + + for (i = 0; i < d->sindex; ++i) { + free(d->states[i].elems.elems); + if (MBS_SUPPORT) + free(d->states[i].mbps.elems); + } + free(d->states); + for (i = 0; i < d->tindex; ++i) + free(d->follows[i].elems); + free(d->follows); + for (i = 0; i < d->tralloc; ++i) + { + free(d->trans[i]); + free(d->fails[i]); + } + free(d->realtrans); + free(d->fails); + free(d->newlines); + free(d->success); + for (dm = d->musts; dm; dm = ndm) + { + ndm = dm->next; + free(dm->must); + free(dm); + } +} + +/* Having found the postfix representation of the regular expression, + try to find a long sequence of characters that must appear in any line + containing the r.e. + Finding a "longest" sequence is beyond the scope here; + we take an easy way out and hope for the best. + (Take "(ab|a)b"--please.) + + We do a bottom-up calculation of sequences of characters that must appear + in matches of r.e.'s represented by trees rooted at the nodes of the postfix + representation: + sequences that must appear at the left of the match ("left") + sequences that must appear at the right of the match ("right") + lists of sequences that must appear somewhere in the match ("in") + sequences that must constitute the match ("is") + + When we get to the root of the tree, we use one of the longest of its + calculated "in" sequences as our answer. The sequence we find is returned in + d->must (where "d" is the single argument passed to "dfamust"); + the length of the sequence is returned in d->mustn. + + The sequences calculated for the various types of node (in pseudo ANSI c) + are shown below. "p" is the operand of unary operators (and the left-hand + operand of binary operators); "q" is the right-hand operand of binary + operators. + + "ZERO" means "a zero-length sequence" below. + + Type left right is in + ---- ---- ----- -- -- + char c # c # c # c # c + + ANYCHAR ZERO ZERO ZERO ZERO + + MBCSET ZERO ZERO ZERO ZERO + + CSET ZERO ZERO ZERO ZERO + + STAR ZERO ZERO ZERO ZERO + + QMARK ZERO ZERO ZERO ZERO + + PLUS p->left p->right ZERO p->in + + CAT (p->is==ZERO)? (q->is==ZERO)? (p->is!=ZERO && p->in plus + p->left : q->right : q->is!=ZERO) ? q->in plus + p->is##q->left p->right##q->is p->is##q->is : p->right##q->left + ZERO + + OR longest common longest common (do p->is and substrings common to + leading trailing q->is have same p->in and q->in + (sub)sequence (sub)sequence length and + of p->left of p->right content) ? + and q->left and q->right p->is : NULL + + If there's anything else we recognize in the tree, all four sequences get set + to zero-length sequences. If there's something we don't recognize in the tree, + we just return a zero-length sequence. + + Break ties in favor of infrequent letters (choosing 'zzz' in preference to + 'aaa')? + + And. . .is it here or someplace that we might ponder "optimizations" such as + egrep 'psi|epsilon' -> egrep 'psi' + egrep 'pepsi|epsilon' -> egrep 'epsi' + (Yes, we now find "epsi" as a "string + that must occur", but we might also + simplify the *entire* r.e. being sought) + grep '[c]' -> grep 'c' + grep '(ab|a)b' -> grep 'ab' + grep 'ab*' -> grep 'a' + grep 'a*b' -> grep 'b' + + There are several issues: + + Is optimization easy (enough)? + + Does optimization actually accomplish anything, + or is the automaton you get from "psi|epsilon" (for example) + the same as the one you get from "psi" (for example)? + + Are optimizable r.e.'s likely to be used in real-life situations + (something like 'ab*' is probably unlikely; something like is + 'psi|epsilon' is likelier)? */ + +static char * +icatalloc (char *old, char const *new) +{ + char *result; + size_t oldsize = old == NULL ? 0 : strlen (old); + size_t newsize = new == NULL ? 0 : strlen (new); + if (newsize == 0) + return old; + result = xrealloc (old, oldsize + newsize + 1); + strcpy (result + oldsize, new); + return result; +} + +static char * +icpyalloc (char const *string) +{ + return icatalloc (NULL, string); +} + +static char * _GL_ATTRIBUTE_PURE +istrstr (char const *lookin, char const *lookfor) +{ + char const *cp; + size_t len; + + len = strlen(lookfor); + for (cp = lookin; *cp != '\0'; ++cp) + if (strncmp(cp, lookfor, len) == 0) + return (char *) cp; + return NULL; +} + +static void +freelist (char **cpp) +{ + int i; + + if (cpp == NULL) + return; + for (i = 0; cpp[i] != NULL; ++i) + { + free(cpp[i]); + cpp[i] = NULL; + } +} + +static char ** +enlist (char **cpp, char *new, size_t len) +{ + int i, j; + + if (cpp == NULL) + return NULL; + if ((new = icpyalloc(new)) == NULL) + { + freelist(cpp); + return NULL; + } + new[len] = '\0'; + /* Is there already something in the list that's new (or longer)? */ + for (i = 0; cpp[i] != NULL; ++i) + if (istrstr(cpp[i], new) != NULL) + { + free(new); + return cpp; + } + /* Eliminate any obsoleted strings. */ + j = 0; + while (cpp[j] != NULL) + if (istrstr(new, cpp[j]) == NULL) + ++j; + else + { + free(cpp[j]); + if (--i == j) + break; + cpp[j] = cpp[i]; + cpp[i] = NULL; + } + /* Add the new string. */ + REALLOC(cpp, i + 2); + cpp[i] = new; + cpp[i + 1] = NULL; + return cpp; +} + +/* Given pointers to two strings, return a pointer to an allocated + list of their distinct common substrings. Return NULL if something + seems wild. */ +static char ** +comsubs (char *left, char const *right) +{ + char **cpp; + char *lcp; + char *rcp; + size_t i, len; + + if (left == NULL || right == NULL) + return NULL; + cpp = malloc(sizeof *cpp); + if (cpp == NULL) + return NULL; + cpp[0] = NULL; + for (lcp = left; *lcp != '\0'; ++lcp) + { + len = 0; + rcp = strchr (right, *lcp); + while (rcp != NULL) + { + for (i = 1; lcp[i] != '\0' && lcp[i] == rcp[i]; ++i) + continue; + if (i > len) + len = i; + rcp = strchr (rcp + 1, *lcp); + } + if (len == 0) + continue; + { + char **p = enlist (cpp, lcp, len); + if (p == NULL) + { + freelist (cpp); + cpp = NULL; + break; + } + cpp = p; + } + } + return cpp; +} + +static char ** +addlists (char **old, char **new) +{ + int i; + + if (old == NULL || new == NULL) + return NULL; + for (i = 0; new[i] != NULL; ++i) + { + old = enlist(old, new[i], strlen(new[i])); + if (old == NULL) + break; + } + return old; +} + +/* Given two lists of substrings, return a new list giving substrings + common to both. */ +static char ** +inboth (char **left, char **right) +{ + char **both; + char **temp; + int lnum, rnum; + + if (left == NULL || right == NULL) + return NULL; + both = malloc(sizeof *both); + if (both == NULL) + return NULL; + both[0] = NULL; + for (lnum = 0; left[lnum] != NULL; ++lnum) + { + for (rnum = 0; right[rnum] != NULL; ++rnum) + { + temp = comsubs(left[lnum], right[rnum]); + if (temp == NULL) + { + freelist(both); + return NULL; + } + both = addlists(both, temp); + freelist(temp); + free(temp); + if (both == NULL) + return NULL; + } + } + return both; +} + +typedef struct +{ + char **in; + char *left; + char *right; + char *is; +} must; + +static void +resetmust (must *mp) +{ + mp->left[0] = mp->right[0] = mp->is[0] = '\0'; + freelist(mp->in); +} + +static void +dfamust (struct dfa *d) +{ + must *musts; + must *mp; + char *result; + int ri; + int i; + int exact; + token t; + static must must0; + struct dfamust *dm; + static char empty_string[] = ""; + + result = empty_string; + exact = 0; + MALLOC (musts, d->tindex + 1); + mp = musts; + for (i = 0; i <= d->tindex; ++i) + mp[i] = must0; + for (i = 0; i <= d->tindex; ++i) + { + mp[i].in = xmalloc(sizeof *mp[i].in); + mp[i].left = xmalloc(2); + mp[i].right = xmalloc(2); + mp[i].is = xmalloc(2); + mp[i].left[0] = mp[i].right[0] = mp[i].is[0] = '\0'; + mp[i].in[0] = NULL; + } +#ifdef DEBUG + fprintf(stderr, "dfamust:\n"); + for (i = 0; i < d->tindex; ++i) + { + fprintf(stderr, " %d:", i); + prtok(d->tokens[i]); + } + putc('\n', stderr); +#endif + for (ri = 0; ri < d->tindex; ++ri) + { + switch (t = d->tokens[ri]) + { + case LPAREN: + case RPAREN: + assert (!"neither LPAREN nor RPAREN may appear here"); + case EMPTY: + case BEGLINE: + case ENDLINE: + case BEGWORD: + case ENDWORD: + case LIMWORD: + case NOTLIMWORD: + case BACKREF: + resetmust(mp); + break; + case STAR: + case QMARK: + assert (musts < mp); + --mp; + resetmust(mp); + break; + case OR: + assert (&musts[2] <= mp); + { + char **new; + must *lmp; + must *rmp; + int j, ln, rn, n; + + rmp = --mp; + lmp = --mp; + /* Guaranteed to be. Unlikely, but. . . */ + if (!STREQ (lmp->is, rmp->is)) + lmp->is[0] = '\0'; + /* Left side--easy */ + i = 0; + while (lmp->left[i] != '\0' && lmp->left[i] == rmp->left[i]) + ++i; + lmp->left[i] = '\0'; + /* Right side */ + ln = strlen(lmp->right); + rn = strlen(rmp->right); + n = ln; + if (n > rn) + n = rn; + for (i = 0; i < n; ++i) + if (lmp->right[ln - i - 1] != rmp->right[rn - i - 1]) + break; + for (j = 0; j < i; ++j) + lmp->right[j] = lmp->right[(ln - i) + j]; + lmp->right[j] = '\0'; + new = inboth(lmp->in, rmp->in); + if (new == NULL) + goto done; + freelist(lmp->in); + free(lmp->in); + lmp->in = new; + } + break; + case PLUS: + assert (musts < mp); + --mp; + mp->is[0] = '\0'; + break; + case END: + assert (mp == &musts[1]); + for (i = 0; musts[0].in[i] != NULL; ++i) + if (strlen(musts[0].in[i]) > strlen(result)) + result = musts[0].in[i]; + if (STREQ (result, musts[0].is)) + exact = 1; + goto done; + case CAT: + assert (&musts[2] <= mp); + { + must *lmp; + must *rmp; + + rmp = --mp; + lmp = --mp; + /* In. Everything in left, plus everything in + right, plus catenation of + left's right and right's left. */ + lmp->in = addlists(lmp->in, rmp->in); + if (lmp->in == NULL) + goto done; + if (lmp->right[0] != '\0' && + rmp->left[0] != '\0') + { + char *tp; + + tp = icpyalloc(lmp->right); + tp = icatalloc(tp, rmp->left); + lmp->in = enlist(lmp->in, tp, strlen(tp)); + free(tp); + if (lmp->in == NULL) + goto done; + } + /* Left-hand */ + if (lmp->is[0] != '\0') + { + lmp->left = icatalloc(lmp->left, + rmp->left); + if (lmp->left == NULL) + goto done; + } + /* Right-hand */ + if (rmp->is[0] == '\0') + lmp->right[0] = '\0'; + lmp->right = icatalloc(lmp->right, rmp->right); + if (lmp->right == NULL) + goto done; + /* Guaranteed to be */ + if (lmp->is[0] != '\0' && rmp->is[0] != '\0') + { + lmp->is = icatalloc(lmp->is, rmp->is); + if (lmp->is == NULL) + goto done; + } + else + lmp->is[0] = '\0'; + } + break; + default: + if (t < END) + { + assert (!"oops! t >= END"); + } + else if (t == '\0') + { + /* not on *my* shift */ + goto done; + } + else if (t >= CSET + || !MBS_SUPPORT + || t == ANYCHAR + || t == MBCSET + ) + { + /* easy enough */ + resetmust(mp); + } + else + { + /* plain character */ + resetmust(mp); + mp->is[0] = mp->left[0] = mp->right[0] = t; + mp->is[1] = mp->left[1] = mp->right[1] = '\0'; + mp->in = enlist(mp->in, mp->is, (size_t)1); + if (mp->in == NULL) + goto done; + } + break; + } +#ifdef DEBUG + fprintf(stderr, " node: %d:", ri); + prtok(d->tokens[ri]); + fprintf(stderr, "\n in:"); + for (i = 0; mp->in[i]; ++i) + fprintf(stderr, " \"%s\"", mp->in[i]); + fprintf(stderr, "\n is: \"%s\"\n", mp->is); + fprintf(stderr, " left: \"%s\"\n", mp->left); + fprintf(stderr, " right: \"%s\"\n", mp->right); +#endif + ++mp; + } + done: + if (strlen(result)) + { + MALLOC(dm, 1); + dm->exact = exact; + MALLOC(dm->must, strlen(result) + 1); + strcpy(dm->must, result); + dm->next = d->musts; + d->musts = dm; + } + mp = musts; + for (i = 0; i <= d->tindex; ++i) + { + freelist(mp[i].in); + free(mp[i].in); + free(mp[i].left); + free(mp[i].right); + free(mp[i].is); + } + free(mp); +} + +struct dfa * +dfaalloc (void) +{ + return xmalloc (sizeof (struct dfa)); +} + +struct dfamust * _GL_ATTRIBUTE_PURE +dfamusts (struct dfa const *d) +{ + return d->musts; +} + +/* vim:set shiftwidth=2: */ diff --git a/dfa.h b/dfa.h new file mode 100644 index 0000000..bffa519 --- /dev/null +++ b/dfa.h @@ -0,0 +1,109 @@ +/* dfa.h - declarations for GNU deterministic regexp compiler + Copyright (C) 1988, 1998, 2007, 2009-2011 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., + 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA */ + +/* Written June, 1988 by Mike Haertel */ + +#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6) || __STRICT_ANSI__ +# define __attribute__(x) +#endif + +/* The __pure__ attribute was added in gcc 2.96. */ +#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +#else +# define _GL_ATTRIBUTE_PURE /* empty */ +#endif + +/* Element of a list of strings, at least one of which is known to + appear in any R.E. matching the DFA. */ +struct dfamust +{ + int exact; + char *must; + struct dfamust *next; +}; + +/* The dfa structure. It is completely opaque. */ +struct dfa; + +/* Entry points. */ + +/* Allocate a struct dfa. The struct dfa is completely opaque. + The returned pointer should be passed directly to free() after + calling dfafree() on it. */ +extern struct dfa *dfaalloc (void); + +/* Return the dfamusts associated with a dfa. */ +extern struct dfamust *dfamusts (struct dfa const *); + +/* dfasyntax() takes three arguments; the first sets the syntax bits described + earlier in this file, the second sets the case-folding flag, and the + third specifies the line terminator. */ +extern void dfasyntax (reg_syntax_t, int, unsigned char); + +/* Compile the given string of the given length into the given struct dfa. + Final argument is a flag specifying whether to build a searching or an + exact matcher. */ +extern void dfacomp (char const *, size_t, struct dfa *, int); + +/* Search through a buffer looking for a match to the given struct dfa. + Find the first occurrence of a string matching the regexp in the + buffer, and the shortest possible version thereof. Return a pointer to + the first character after the match, or NULL if none is found. BEGIN + points to the beginning of the buffer, and END points to the first byte + after its end. Note however that we store a sentinel byte (usually + newline) in *END, so the actual buffer must be one byte longer. + When NEWLINE is nonzero, newlines may appear in the matching string. + If COUNT is non-NULL, increment *COUNT once for each newline processed. + Finally, if BACKREF is non-NULL set *BACKREF to indicate whether we + encountered a back-reference (1) or not (0). The caller may use this + to decide whether to fall back on a backtracking matcher. */ +extern char *dfaexec (struct dfa *d, char const *begin, char *end, + int newline, int *count, int *backref); + +/* Free the storage held by the components of a struct dfa. */ +extern void dfafree (struct dfa *); + +/* Entry points for people who know what they're doing. */ + +/* Initialize the components of a struct dfa. */ +extern void dfainit (struct dfa *); + +/* Incrementally parse a string of given length into a struct dfa. */ +extern void dfaparse (char const *, size_t, struct dfa *); + +/* Analyze a parsed regexp; second argument tells whether to build a searching + or an exact matcher. */ +extern void dfaanalyze (struct dfa *, int); + +/* Compute, for each possible character, the transitions out of a given + state, storing them in an array of integers. */ +extern void dfastate (int, struct dfa *, int []); + +/* Error handling. */ + +/* dfawarn() is called by the regexp routines whenever a regex is compiled + that likely doesn't do what the user wanted. It takes a single + argument, a NUL-terminated string describing the situation. The user + must supply a dfawarn. */ +extern void dfawarn (const char *); + +/* dfaerror() is called by the regexp routines whenever an error occurs. It + takes a single argument, a NUL-terminated string describing the error. + The user must supply a dfaerror. */ +extern void dfaerror (const char *) __attribute__ ((noreturn)); diff --git a/doc/ChangeLog b/doc/ChangeLog new file mode 100644 index 0000000..202cc51 --- /dev/null +++ b/doc/ChangeLog @@ -0,0 +1,60 @@ +2012-03-28 Arnold D. Robbins + + * 4.0.1: Release tar ball made. + +2012-02-10 Arnold D. Robbins + + * gawk.texi, awkcard.in: Bump patch level. + * texinfo.tex: Updated from Texinfo CVS. + +2011-12-06 Arnold D. Robbins + + * gawk.texi: Various typo fixes from mailing list. + +2011-11-10 Arnold D. Robbins + + * gawk.1: Fix some .BR to be .B. + +2011-11-08 Arnold D. Robbins + + * gawk.texi: Further improvement in the discussion of sorted array + traversal. Some sections reordered and text edited to suit. + +2011-11-06 Arnold D. Robbins + + * gawk.texi: Try to improve discussion of sorted array + traversal. + +2011-09-24 Arnold D. Robbins + + * gawk.1: Fix some spelling errors. Thanks to + Jeroen Schot . + * gawk.texi: Some minor fixes. + +2011-07-28 Arnold D. Robbins + + * gawk.texi (Gory Details): Restore text on historical behavior + etc. and add explanation on gawk 4.0.x. + +2011-07-17 Arnold D. Robbins + + * gawk.texi: Add reference in node Expressions to node Precedence, + based on suggestion from Dan Jacobson dated 4 Jun 2001. + +2011-07-17 Paul Eggert + + * gawk.texi: Warn up-front (indirectly) that plain gawk is not + compatible with SVR4 awk and with POSIX awk. Describe how + gawk differs from the GNU standard in its interpretation of + POSIXLY_CORRECT. (From mail dated 15 May 2001). + +2011-06-24 Arnold D. Robbins + + * Makefile.am (EXTRA_DIST): Add ChangeLog.0. + * 4.0.0: Remake the tar ball. + +2011-06-23 Arnold D. Robbins + + * ChangeLog.0: Rotated ChangeLog into this file. + * ChangeLog: Created anew for gawk 4.0.0 and on. + * 4.0.0: Release tar ball made. diff --git a/doc/ChangeLog.0 b/doc/ChangeLog.0 new file mode 100644 index 0000000..8b32325 --- /dev/null +++ b/doc/ChangeLog.0 @@ -0,0 +1,1032 @@ +Mon Jun 13 22:28:02 2011 Arnold D. Robbins + + * gawk.texi: Document that POSIX now says [a-z] is undefined outside + the C and POSIX locales, so gawk treats it as the Good Lord intended + in all cases. Thanks to Paul Eggert for letting me know about this + and providing URLs to cite. + +Fri May 27 09:59:38 2011 Arnold D. Robbins + + * gawk.1, gawk.texi: Minor edits w.r.t. the bug reporting address. + +Wed May 25 22:03:53 2011 Arnold D. Robbins + + * gawk.1, gawk.texi: Straighten out owners of the different + Windows ports. + +Thu May 19 17:52:46 2011 Arnold D. Robbins + + * gawk.texi: Igawk, have pathto check for "-". + Thanks to Steffen Schuler , + from email dated 27, December 2008. + +Thu May 19 16:57:28 2011 Arnold D. Robbins + + * gawk.texi, gawk.1, awkcard.in: Revised to reflect the reality + that -d and -p don't allow a space before the file name. + Thanks to Pat Rankin. + +Mon May 16 16:40:50 2011 Arnold D. Robbins + + * gawk.texi: Remove last vestiges of old PROCINFO sorting + description. + +Mon May 9 15:58:33 2011 Arnold D. Robbins + + * gawk.texi: Finish array sorting and do a spell check. + +Fri May 6 13:21:20 2011 Arnold D. Robbins + + * gawk.texi: Finish edits after full read through. + * gawk.1: Update array sorting information. + +Wed May 4 23:39:09 2011 Arnold D. Robbins + + * gawk.texi: Start at revamping array sorting doc. Still + needs work. + +Wed Apr 27 21:49:23 2011 Arnold D. Robbins + + * gawk.1: Minor edit. + * awkcard.in: Document third arg to asort and asorti. + +Thu Apr 7 21:55:27 2011 Arnold D. Robbins + + * gawk.texi (Nextfile Function): Removed, along with all references, + since only gawk and MKS awk allow next from a function, so this + function was useless for most people. Strange that noone noticed. + I wonder who really reads the doc? + + Lots of other fixes have been going in too. + +Sun Mar 27 21:10:55 2011 Pat Rankin + + * gawk.texi (Builit-in Variables: PROCINFO array, Scanning All + Elements of an Array: `for' statement): Update the documentation + for PROCINFO["sorted_in"]; add "ascending index number", + "descending index string", "ascending value", and "descending + value" as supported sort orderings. + * gawk.1 (PROCINFO array): Update PROCINFO["sorted_in"] to + reflect that the value matters, and list the supported sort orders. + +Tue Feb 15 17:11:26 2011 Pat Rankin + + * gawk.texi (Builit-in Variables: PROCINFO array, Scanning All + Elements of an Array: `for' statement): Document that the value + of PROCINFO["sorted_in"] matters; sort orders "ascending index + string", "descending index string", and "unsorted" are supported. + +Sun Feb 13 19:58:35 2011 Arnold D. Robbins + + * awkcard.in, gawk.1, gawk.texi, gawkinet.texi: Fix typos + and spelling errors. + +Thu Feb 10 21:48:18 2011 Pat Rankin + + * gawk.texi: Update VMS section. + +Thu Feb 10 21:31:36 2011 Andreas Buening + + * gawk.texi: Update OS/2 information. + +Thu Feb 10 21:06:14 2011 Arnold D. Robbins + + * lflashlight-small.xpic: Renamed from lflashlight.small.xpic. + * rflashlight-small.xpic: Renamed from rflashlight.small.xpic. + * Makefile.am (EXTRA_DIST): Adjusted. + +Tue Feb 1 10:21:22 2011 Arnold D. Robbins + + * gawk.texi, awkcard.in, gawk.1: Document isarray function, + magic string in PROCINFO for array sorting. Needs a little + more work in gawk.texi. + +Mon Jan 10 21:52:21 2011 Arnold D. Robbins + + * lflashlight.small.xpic, rflashlight.small.xpic: Original + source files for flashlight files from xpic tool. + It only took over 10 years to put them into the dist. + * Makefile.am (EXTRA_DIST): Add the new files. + +Thu Jan 6 22:13:11 2011 Arnold D. Robbins + + * gawk.texi: Replace xpic figures in Appendix D with figures + from xfig. + * general-program.eps, general-program.fig, general-program.pdf, + process-flow.eps, process-flow.fig, process-flow.pdf: New files. + * Makefile.am (EXTRA_DIST): Add the new files. + +Wed Jan 5 14:33:51 2011 Arnold D. Robbins + + * Makefile.am: Sanitize making of different PDF files. + +Sun Jan 2 20:30:37 2011 Arnold D. Robbins + + * texinfo.tex: Update to latest from texinfo CVS repository. + +Tue Dec 28 21:46:21 2010 Arnold D. Robbins + + * README.DGAWK: Removed, since there is now a chapter on the + debugger. + * Makefile.am (EXTRA_DIST): Remove README.DGAWK. + +Tue Dec 28 07:13:20 2010 John Haque + + * gawk.texi: Update dgawk examples. Document condition command + without an expression. Fix a typo. + +Tue Dec 21 10:06:05 2010 Arnold D. Robbins + + * Makefile.am (pdf): Renamed from `all-pdf'. Much more logical + and easier to remember. + +Sat Dec 18 20:14:58 2010 Eli Zaretskii + + * gawk.texi (DOS Quoting): Fix a typo. + (Top, PC Installation): Remove "PC Dynamic" from the menus. + (PC Installation, PC Compiling, PC Using): Remove obsolete stuff. + Fix whitespace between sentences. Add indexing. + (PC Testing): New node, stuff moved from "PC Compiling". + (PC Dynamic): Node removed. + (Cygwin): Fix wording. + (MSYS): Fix whitespace between sentences. + +Thu Dec 9 22:27:53 2010 Arnold D. Robbins + + * awkcard.in, gawk.1, gawk.texi, gawkinet.texi: Remove discussion + of raw option in making sockets, since it was never implemented. + +Wed Dec 1 21:39:15 2010 Arnold D. Robbins + + * awkcard.in, gawk.1: Document arrays of arrays. + * gawk.texi: General progress. + +Mon Nov 8 22:24:21 2010 Arnold D. Robbins + + * gawk.1: Minor fix from Jari Aalto + to help Emacs fontification. + +Tue Nov 2 12:15:56 2010 Arnold D. Robbins + + * awkcard.in, gawk.1, gawk.texi: --lint --> -L, + --lint-old --> -t. + +Mon Nov 1 22:01:26 2010 Arnold D. Robbins + + * awkcard.in, gawk.1, gawk.texi: -l renamed -t. + +Sat Oct 30 05:53:25 2010 John Haque + + * gawk.texi: Added section on Array of Arrays. + +Sat Oct 23 20:36:58 2010 Arnold D. Robbins + + * awkcard.in: Updated, cleaned up. + * gawk.1: Updated, some clean up. + +Wed Sep 22 05:29:43 2010 Arnold D. Robbins + + * gawk.texi: Added section on @include files. + +Wed Aug 18 22:14:19 2010 Arnold D. Robbins + + * gawk.texi: Minor edits. + * Makefile.am (LN): Use `ln -f' when installing link for + pgawk.1. Thanks to Peter Breitenlohner . + +Thu Jul 1 21:29:25 2010 Arnold D. Robbins + + * gawk.texi, gawk.1, awkcard.in: Document `/inet4' and `/inet6'. + +Sun Jun 27 21:58:47 2010 Arnold D. Robbins + + * gawk.texi, gawk.1, awkcard.in: Document all short options. + +Wed Jun 2 22:06:22 2010 Arnold D. Robbins + + * gawk.texi, gawk.1, awkcard.in: Document FPAT variable and patsplit + function. + +Fri Jun 12 13:28:24 2009 Arnold D. Robbins + + * gawk.texi, gawk.1: Remove --disable-directories-fatal configuration + option. + +Thu Feb 26 20:36:18 2009 Arnold D. Robbins + + * gawk.texi, gawk.1, awkcard.in: Document BEGINFILE and ENDFILE. + +Mon Feb 16 21:53:22 2009 Arnold D. Robbins + + * gawk.texi: Document switch statements as always available. + * gawk.1: Ditto. + * awkcard.in: Ditto. + +Thu Feb 12 22:36:32 2009 Arnold D. Robbins + + * gawk.texi: Document that interval expressions are now on by default. + Also that --gen-po is now --gen-pot. + * gawk.1: Ditto. + * awkcard.in: Ditto. + +Sat Jan 17 20:03:43 2009 Arnold D. Robbins + + * gawk.texi: Document indirect function calls. + * gawk.1: Ditto. + * awkcard.in: Ditto. + +Tue Dec 30 22:22:04 2008 Assaf Gordon + + * gawk.texi: Document new --sandbox option. + * gawk.1: Ditto. + * awkcard.in: Ditto. + +Tue Dec 30 22:21:11 2008 Arnold D. Robbins + + * gawk.texi: Change --binary to --characters-as-bytes, per Karl Berry. + * gawk.1: Ditto. + * awkcard.in: Ditto. + +Thu Dec 18 05:30:13 2008 Steffen Schuler + + * gawk.texi: Documented fourth parameter of split(). + * gawk.1: Ditto. + * awkcard.in: Ditto. + +Thu Dec 18 05:16:48 2008 Arnold D. Robbins + + * gawk.texi: Minimally document `-b' / --binary. + * gawk.1: Ditto. + * awkcard.in: Ditto. + +Sun Nov 16 22:03:50 2008 Arnold D. Robbins + + * gawk.texi: Fully documented `-r' as synonym for --re-interval. + * gawk.1: Ditto. + * awkcard.in: Ditto. + +Tue Aug 3 13:35:15 2004 Arnold D. Robbins + + * gawk.texi: Document that gawk now uses the 2001 POSIX + rules for `sub' and `gsub'. + +Wed Dec 26 22:15:05 2001 Arnold D. Robbins + + * gawk.texi: Documented that process special files are gone. + * gawk.1: Ditto. + * awkcard.in: Ditto. + +Thu May 6 20:55:14 2010 Arnold D. Robbins + + * Release 3.1.8: Release tar file made. + +Tue Apr 20 11:48:31 2010 Arnold D. Robbins + + * texinfo.tex: Update to latest from texinfo git repository. + * gawk.texi, gawk.1, awkcard.in: Update version and copyright dates. + +Thu Mar 25 21:51:58 2010 Arnold D. Robbins + + * gawk.1: Clarify the socket timeout environment variables. + +Wed Mar 10 21:28:12 2010 Arnold D. Robbins + + * gawk.texi: Reworded 'index in array' so that there's no chance of + someone using 'index' as a real subscript. Thanks to Hermann + Peifer for the push. + +Thu Feb 4 20:54:48 2010 Arnold D. Robbins + + * gawk.texi: Multiple cleanups and bringing of things up to date. + * gawk.1: Ditto, only not as much. + * Makefile.am: New `all-pdf' target to make PDF files of manpage + and reference card. + +Tue Aug 4 06:07:35 2009 Arnold D. Robbins + + * gawk.texi, gawk.1, awkcard.in: Document that 0 flag in + printf applies only to the numeric formats. + +Tue Aug 4 05:58:52 2009 Arnold D. Robbins + + * texinfo.tex: Updated to current version. + +Tue Jul 21 22:28:56 2009 Arnold D. Robbins + + * Release 3.1.7: Release tar file made. + +Tue Jul 21 22:20:25 2009 Arnold D. Robbins + + * gawk.texi, awkcard.in: Update mawk site information now + that Thomas Dickey is maintaining it. + +Mon Jul 13 07:53:32 2009 Arnold D. Robbins + + * Makefile.am (SEDME2): New macro, used in making awkcard.ps, + removes last empty page. Finally! + +Fri Jul 10 10:35:29 2009 Arnold D. Robbins + + * awkcard.in: Rearrange items for better formatting and + organization. + * gawk.texi (Exit Status): New node to document exit values. + (Exit Statement): Give portability advice about exit value. + +Wed Jul 8 08:55:50 2009 Arnold D. Robbins + + * awkcard.in: Really fix table option for --verbose. Other + fixes and improvements, including document %'d flag. + +Tue Jul 7 09:13:02 2009 Arnold D. Robbins + + * awkcard.in: Fix table option for --verbose. + +Mon Jun 8 00:40:26 2009 Tommi Vainikainen + + * gawk.1: Bug fix to restore space between paragraphs at + entry for "--". + +Thu May 21 21:09:59 2009 Arnold D. Robbins + + * gawk.1, awkcard.in: Document new -O / --optimize option. + * gawk.texi (Options): Likewise. + +Fri May 15 14:34:37 2009 Arnold D. Robbins + + * gawk.texi (User-defined): Document that you can't use + the name of a built-in variable as a function parameter. + +Sat May 2 23:36:10 2009 Arnold D. Robbins + + * gawk.texi (Other Versions): Add Quiktrim awk. + (How to Contribute): Change things to point to awk.info. + +Mon Apr 6 22:29:47 2009 Arnold D. Robbins + + * awkcard.in: Bell Labs awk also supports fflush() + and fflush(""). Thanks to Steffen Schuler + . + +Mon Mar 30 21:26:04 2009 Arnold D. Robbins + + * gawk.texi (Simple Server): Fix bug since 3.1.0 where error + message from typo was in the middle of the HandleGet function. + Thanks to Tim Menzies for catching this. + +Mon Feb 9 22:11:16 2009 Arnold D. Robbins + + * gawk.texi (Translate Program): Bug fix in stranslate + function from Steffen Schuler . + +Tue Feb 3 22:06:10 2009 Arnold D. Robbins + + * gawk.texi (Regexp Field Splitting): Documented dark corner + of ^ in FS. + +Sat Jan 17 20:37:12 2009 Arnold D. Robbins + + * gawk.texi (Plain Getline): Bug fix in code. Thanks to + Steffen Schuler . + +Mon Jan 5 22:47:42 2009 Arnold D. Robbins + + * gawk.1, awkcard.in: Document that getline returns 1 + on sucess. Thanks to Paolo for + the report. + +Fri Dec 26 14:45:39 2008 Arnold D. Robbins + + * gawk.texi, gawkinet.texi: Update to FDL 1.3. + +Mon Dec 1 21:20:39 2008 Arnold D. Robbins + + * gawk.texi (File Checking): Correct the text at the end; getline + isn't fatal, period, not related to POSIX. Thanks to + Seb for pointing this out. + (Round-Function): Change initial return when equal to return ival, + which lops off any digits, e.g. if given 121.0. Thanks to + Timothy J. Stefanski . + +Fri Aug 1 17:34:55 2008 Arnold D. Robbins + + * gawk.texi (Signature Program): Added new subsection. + +Thu Jul 31 21:38:08 2008 Arnold D. Robbins + + * gawk.texi (Variable Typing): Document that array elements created + by `match' also get strnum attribute. + +Mon Jun 2 22:47:08 2008 Arnold D. Robbins + + * gawk.texi (Control Letters): Add a note about %c only + taking values from 0 to 255. + (DOS Quoting): New node. + +Thu Jan 31 16:17:27 2008 Arnold D. Robbins + + * gawk.texi, gawkinet.texi: Updated the Back-Cover text per + latest from the FSF. + +Fri Jan 25 12:13:39 2008 Dave Pitts + + * gawk.texi (pwcat.c, grcat.c): Added ZOS_USS changes. + +Mon Jan 14 05:30:16 2008 Arnold D. Robbins + + * gawk.texi: Add maintainer contact info for z/OS. + +Mon Oct 22 08:49:05 2007 Arnold D. Robbins + + * Release 3.1.6: Release tar file made. + +Fri Oct 19 04:13:33 2007 Arnold D. Robbins + + * gawk.1: Add length(array) to list of extensions at end. + Revise date. + +Thu Oct 18 08:40:59 2007 Arnold D. Robbins + + * texinfo.tex: Updated to version from Texinfo 4.11. + +Sun Oct 14 20:37:59 2007 Arnold D. Robbins + + * awkcard.in: Fix version numbers and copyright info, minor + cleanups to format nicely. + +Sun Sep 30 22:30:05 2007 Arnold D. Robbins + + * gawk.texi (Conversion): Add table describing locale decimal + point versus period. + +Sat Sep 8 23:53:46 2007 Arnold D. Robbins + + * gawk.texi: A number of minor fixes based on suggestions + from Jack Kelley . + +Sat Aug 11 22:46:14 2007 Arnold D. Robbins + + * gawk.texi (Copying): Move to GPL 3. + +Wed May 30 17:11:19 2007 Arnold D. Robbins + + * Makefile.am (CLEANFILES): Added, so that even "make distclean" + will do the right thing. + (clean): Removed, let automake to do it. + +Tue May 29 22:49:16 2007 Arnold D. Robbins + + * gawk.texi: Document --use-lc-numeric. Document that some + VMS systems come with an old version of gawk. + +Mon May 28 08:21:51 2007 Arnold D. Robbins + + * gawk.1, awkcard.in: Document --use-lc-numeric. + +Tue May 15 13:27:38 2007 Arnold D. Robbins + + * gawk.texi, gawk.1: Documented --disable-directories-fatal + configure option. + +Wed May 9 21:50:44 2007 Arnold D. Robbins + + * gawk.1: Reviewed and updated, minor typos fixed. + * awkcard.in: Added mention of %F. + +Wed May 2 19:55:02 2007 Arnold D. Robbins + + * gawk.texi: Cleaned up discussion of string concatenation + where needed, including a note about the mixed treatment + of `"echo " "date" | getline'. Sigh. + +Sun Apr 29 13:33:27 2007 Arnold D. Robbins + + * gawk.texi (Time Functions): Update description of strftime + for third utc-flag argument. Other minor fixes. + * gawk.1, awkcard.in: Same. + +Tue Apr 3 22:47:40 2007 Arnold D. Robbins + + * gawk.texi (New Ports): Update list of files for all of + regex that should not be messed with lightly. + +Wed Mar 21 09:02:53 2007 Arnold D. Robbins + + * gawk.texi: Removed last vestiges of arnold@gnu.org + email address. + +Wed Mar 7 13:06:31 2007 Arnold D. Robbins + + * gawk.texi (Getopt Function): Add a note that user level + code must clear out ARGV from 1 to Optind. + Thanks to Matthew.Hall1@VerizonWireless.com, from mail + dated Tue, 02 Aug 2005 09:04:37 -0700. + +Wed Mar 7 08:48:02 2007 Arnold D. Robbins + + * gawk.texi: Fix my personal email address. Sheesh. + Thanks again to Sahak Petrosyan . + +Tue Mar 6 09:13:38 2007 Arnold D. Robbins + + * gawk.texi: Fix link to online version of the manual. + Thanks to Sahak Petrosyan . + +Wed Feb 14 19:40:33 2007 Arnold D. Robbins + + * gawk.texi: Add discussion of magic values for Inf, NaN, + and hexadecimal floating point in appendix on numbers. + Other minor updates for date, trademarks, etc. + +Sun Jan 21 12:59:33 2007 "Ennio-(Sr)" + + * gawk.1: Add note that locale settings can influence the + choice of decimal point character. + +Sat Jan 13 22:43:39 2007 Ralf Wildenhues + + * gawk.texi: Fix some typos. + * gawkinet.texi: Likewise. + +Sat Jan 13 21:25:28 2007 Ralf Wildenhues + + * awkcard.in: next is POSIX. + * gawk.texi: V7/SVR3.1: Mention assignable `$0', `var in index' + as expression. Specify `FS' limitation. + +Fri Jan 12 12:28:51 2007 Arnold D. Robbins + + * texinfo.tex: Updated upon move to current autotools. + +Thu Jan 4 19:56:45 2007 Arnold D. Robbins + + * gawk.1: Applied patch from Eric Raymond to stop his stupid + automated email kvetching about the wonders of docbook. + +2006-07-29 Paul Eggert + + * gawk.texi: Document that `$$0++--' isn't valid even though it + is unambiguous according to the Awk grammar. This is in response + to Open Group XCU ERN 86 + . + +Fri Oct 21 12:50:19 2005 Arnold D. Robbins + + Better support for PDF, thanks to Marty Leisner + for the prodding. + + * Makefile.am: Add lflashlight.pdf, rflashlight.pdf, statist.pdf + to EXTRADIST and add gawk.pdf and gawkinet.pdf to list of files + to remove for `clean'. + * lflashlight.pdf, rflashlight.pdf, statist.pdf: New files, created + with `epstopdf foo.eps > foo.pdf'. + +Tue Jul 26 21:46:16 2005 Arnold D. Robbins + + * Release 3.1.5: Release tar file made. + +Sun Jun 26 16:24:07 2005 Arnold D. Robbins + + * gawk.texi: Document `length(array)'. + * gawk.1: Ditto. + * awkcard.in: Ditto. + +Mon May 23 20:56:32 2005 Arnold D. Robbins + + * gawk.texi: Removed references to `--with-included-gettext'. + +Fri Apr 1 06:25:30 2005 Arnold D. Robbins + + * texinfo.tex: Updated to version 2005-01-30.17. + +Wed Feb 9 11:39:38 2005 Arnold D. Robbins + + * Makefile.am: Per Stepan Kasal, removed html rules, since + Automake does it for us. + +Tue Jan 4 18:47:34 2005 Arnold D. Robbins + + * texinfo.tex: Updated to version 2004-11-25.16. + +Mon Jan 3 14:09:57 2005 Arnold D. Robbins + + * texinfo.tex: Updated to version 2004-10-31.06. + +Wed Sep 22 11:40:06 2004 Arnold D. Robbins + + * gawk.1, gawk.texi, awkcard.in: Documented new --exec option. + +Mon Aug 2 12:18:15 2004 Arnold D. Robbins + + * Release 3.1.4: Release tar file made. + +Wed Jul 28 17:03:16 2004 Arnold D. Robbins + + * Makefile.am (TROFF): Add -U flag to invocation. Makes it + possible to format ref card from a build directory that isn't + the source directory. + (distclean): Removed target. Let automake handle it. + +Tue Jun 15 12:21:09 2004 Arnold D. Robbins + + * texinfo.tex: Updated to version 2004-06-14.14. + * gawk.texi (Dynamic Extensions): Text revised to follow + current implementation: new APIs, info on `n->param_cnt' + fixed. + + Also in all index entries where comma does not separate + primary, secondary or tertiary terms, replaced the comma + with @comma{} and removed the corresponding comments. + +Mon May 31 09:11:01 2004 Arnold D. Robbins + + * ad.block, awkcard.in, cardfonts, colors, no.colors: Change + old email address to current one. + +Mon May 3 09:54:46 2004 Arnold D. Robbins + + * texinfo.tex: Updated to version from Automake 1.8.4. + +Mon Mar 22 10:53:13 2004 Arnold D. Robbins + + * texinfo.tex: Updated. + +Tue Jan 6 17:38:40 2004 Arnold D. Robbins + + * texinfo.tex: Updated. + * gawk.texi: All @strong{Note:} changed to `@quotation NOTE'. + +Mon Jul 7 11:01:43 2003 Arnold D. Robbins + + * Release 3.1.3: Release tar file made. + +Mon Jun 9 16:06:30 2003 Arnold D. Robbins + + * gawk.texi: Set automatic-xref-title and change all cross + references to be of the single-argument type. Made all + @node lines have just the node name. + + Should have done both of these years ago. + +Sun May 11 16:08:58 2003 Arnold D. Robbins + + * Makefile.am (html, gawk.html, gawkinet.html): New targets. + +Mon Mar 31 17:15:23 2003 Arnold D. Robbins + + * Makefile.am (install-data-hook, uninstall-hook): Added code to + hard link gawk.1 to pgawk.1 upon install and remove pgawk.1 upon + uninstall. Avoids MANPATH search problems, etc. etc. + (man_MANS): Removed pgawk.1 from the list. + * pgawk.1: Removed. + +Wed Mar 19 14:10:31 2003 Arnold D. Robbins + + This time for sure. + -- Bullwinkle + + * Release 3.1.2: Release tar file made. + +Tue Mar 11 11:22:36 2003 Arnold D. Robbins + + * Makefile.am (man_MANS): Add pgawk.1. + * pgawk.1: New file, does `.so gawk.1' so that `man pgawk' will work. + Thanks to Nelson Beebe for pointing the need for this. + +Sun Feb 9 09:45:06 2003 Arnold D. Robbins + + * gawk.texi, gawkinet.texi: Per Karl Berry, change dircategory + to follow current standards. In gawkinet.texi, remove + bracketing ifinfo. + +Thu Feb 6 12:06:22 2003 Arnold D. Robbins + + * texinfo.tex: Updated to version 2003-02-03.16 from Texinfo 4.5. + +Tue Feb 4 15:21:46 2003 Arnold D. Robbins + + * awkcard.in: Redid the page-breaking. + +Tue Feb 4 14:28:06 2003 Arnold D. Robbins + + All relevant files: Copyright year updated to 2003. + +Sun Jan 26 11:13:01 2003 Arnold D. Robbins + + * texinfo.tex: Updated to version 2003-01-24.17 from prep. + * gawk.texi: Documented asorti(), new elements in match() 3rd arg, + misc cleanups. Updated to FDL 1.2. + * awkcard.in, gawk.1: Ditto for asorti(), match(). + * gawkinet.texi: Updated to FDL 1.2. + +Thu Jan 16 18:34:54 2003 Arnold D. Robbins + + * texinfo.tex: Updated to version 2003-01-12.11 from prep. + +Sun Nov 24 17:55:23 2002 Arnold D. Robbins + + * texinfo.tex: Updated to version 2002-11-05.11 from Texinfo 4.3. + +Sun Nov 17 21:34:35 2002 Arnold D. Robbins + + * texinfo.tex: Updated to version 2002-10-13.14 from automake 1.7.1. + +Fri Nov 1 11:25:00 2002 Arnold D. Robbins + + From Kaveh Ghazi: + + * gawk.texi (grcat.c): Include stdlib.h. + (main): Fix format specifier warnings. + * gawk.texi (pwcat.c): Include config.h/stdlib.h. + (main): Fix format specifier warnings. + +Tue Jun 11 23:08:04 2002 Arnold D. Robbins + + * gawk.texi: Fix grcat code ifdef for HAVE_GETGRENT. + +2002-05-09 Paul Eggert + + [ ADR: Some minor post-patch editing was required. ] + + * gawk.texi (igawk): Do not put temporary files in /tmp, as that + has some security problems. This fixes a problem originally + reported by Jarno Huuskonen via solar@openwall.com. + + Fix the following problems with igawk while we're at it. + + * Report missing operands of options; this fixes e.g. an + infinite loop with "igawk -W". + + * Check for --source and -Wsource only, not -.source (which matches + errors). Similarly for other multichar options. + + * Do not use 'echo', as that mishandles backslashes. + +Mon May 13 01:25:40 2002 Arnold D. Robbins + + * gawkinet.texi: Change `ifinfo' to `ifnottex' around + the Top node. Thanks to Eli Zaretskii. + +Wed May 1 16:41:32 2002 Arnold D. Robbins + + * Release 3.1.1: Release tar file made. + +Tue Apr 16 13:26:13 2002 Arnold D. Robbins + + * gawk.texi: FINALLY. All O'Reilly production and + indexing changes integrated. Index reviewed and + cleaned up. + * gawkinet.texi: Ditto. + * awkcard.in: Redid page breaking. + * Makefile.am (clean): Add `awkcard.tr' to list of files + that are removed. + (distclean): Depend on clean to REALLY GET `awkcard.tr'. + Sheesh. + +Mon Apr 15 14:43:51 2002 Arnold D. Robbins + + * texinfo.tex: Updated to version from Texinfo 4.2. + * gawk.texi: Modified to use new @copying command. + * gawkinet.texi: Ditto. + +Wed Mar 20 17:07:50 2002 Arnold D. Robbins + + * texinfo.tex: Updated to version from Texinfo 4.1. + +2002-02-10 Paul Eggert + + * gawk.texi (Word Sorting): Don't use sort +1, as POSIX 1003.1-2001 + no longer allows it. Use sort -k instead. + +2002-01-27 Bruno Haible + + * gawk.texi: Document the dcngettext function. + * awkcard.in: Likewise. + * gawk.1: Likewise. + +Mon Jan 28 18:41:02 2002 Arnold D. Robbins + + * gawkinet.texi, Makefile.am: Removed User Friendly cartoon. + Sigh. + +Wed Dec 19 16:00:39 2001 Eli Zaretskii + + * gawk.texi (Profiling): Describe the signals used for profile + dumping in the DJGPP version. + +Mon Sep 3 18:30:13 2001 Arnold D. Robbins + + * gawk.texi (Top): Put in @ifnottex so that makeinfo + --html is now happy. + +Sun Jun 3 13:04:44 2001 Arnold D. Robbins + + * Release 3.1.0: Release tar file made. And there was + rejoicing. + +Mon May 14 19:57:31 2001 Arnold D. Robbins + + * gawk.texi, gawkinet.texi: Versions for distribution + put in place. + * gawk.1, awkcard.in: Minor edits for consistency of + usage, formatting. + +Wed Nov 22 14:57:59 2000 Arnold D. Robbins + + * gawk.texi, gawk.1, awkcard.in: Removed all documentation + of abort. + +Sun Aug 13 11:23:50 2000 Arnold D. Robbins + + * gawk.texi, gawk.1, awkcard.in: documented sort function + and optional third argument to match. + +Sun Aug 13 00:40:41 2000 Arnold D. Robbins + + * gawk.texi: hardwired publisher info. + * publisher.texi: Removed. Not needed any more. + * gawkinet.texi: Added title page stuff. + +Thu Jul 5 21:05:57 2000 Arnold D. Robbins + + * gawk.texi: moved to use of @command, @option everywhere + appropriate. Removed all @page and @group in anticipation + of re-page breaking. Updated stuff for install-info. + Added FDL. + +Tue Nov 10 11:42:26 1998 Arnold D. Robbins + + * publisher.texi: new file with publisher related info. + * Makefile.in: updated dvi and postscript targets to make + them lots smarter about not reformatting if need be. + +Mon Aug 7 15:23:00 2000 Arnold D. Robbins + + * Release 3.0.6: Release tar file made. + +Sun Jun 25 15:08:19 2000 Arnold D. Robbins + + * Release 3.0.5: Release tar file made. + +Wed May 17 19:04:54 2000 Arnold D. Robbins + + * gawk.texi, gawk.1, awkcard.in: Documented %u. Ooops. + +Tue May 2 11:44:13 2000 Arnold D. Robbins + + * texinfo.tex: Updated to version 1999-10-01.07. + * gawk.texi: Redid page breaking for new texinfo.tex. + +Thu Apr 6 12:32:49 2000 Arnold D. Robbins + + * gawk.texi: Change info dir file entry to `(gawk)' from + `(gawk.info)'. + * Makefile.in [$(infodir)/gawk.info]: Fix grep test is + accordance with above. + +Sun Feb 13 15:36:32 2000 Paul Eggert + + * gawk.texi: Mention that arithmetic is done in double + precision floating point, and point to Goldberg's paper for + people who want to know more. Fix some other minor floating + point discussion issues. + +Wed Nov 3 17:04:35 1999 Arnold D. Robbins + + * gawk.1: Lots of troff ``lint'' from Paul Eggert. Not all + of his changes, just the ones I thought worth doing. + +Mon Oct 11 16:53:54 1999 Arnold D. Robbins + + * Makefile.in (gawk.dvi): Put $(srcdir) first in TEXINPUTS, + and also just use texi2dvi, don't run texindex and tex + manually. Doing so is no longer necessary. + +Mon Aug 9 13:06:01 1999 Arnold D. Robbins + + * gawk.texi: New node `Array Efficiency' on the best use + of subscripting to avoid memory bloat. + +Thu Jul 29 23:15:34 1999 Arnold D. Robbins + + * Makefile.in ($(infodir)/gawk.info): Removed loop around + $(INSTALL_DATA), since there's only one Info file to install, + install it directly. + +Wed Jun 30 16:14:36 1999 Arnold D. Robbins + + * Release 3.0.4: Release tar file made. This time for sure. + +Wed Oct 7 21:59:33 1998 Arnold D. Robbins + + * texinfo.tex: Updated to version 2.227, from Texinfo 3.12. + +Sun Oct 19 12:26:08 1997 Arnold D. Robbins + + * ALL: change references to arnold@gnu.ai.mit.edu to arnold@gnu.org. + +Tue Sep 23 10:31:17 1997 Arnold D. Robbins + + * texinfo.tex: Updated to version 2.218, from Texinfo 3.11. + +Fri Jul 4 08:19:00 1997 Arnold D. Robbins + + * Makefile.in ($(infodir)/gawk.info): Don't make dependent upon + gawk.info, in case installed one is newer. Instead, check that + an installed gawk.info exists and is identical to current one. + If so, just exit; otherwise do the install. + +Wed Jul 2 14:55:12 1997 Arnold D. Robbins + + * Makefile.in ($(infodir)/gawk.info): typo fix. + +Thu May 15 12:49:08 1997 Arnold D. Robbins + + * Release 3.0.3: Release tar file made. + +Fri Apr 18 07:55:47 1997 Arnold D. Robbins + + * BETA Release 3.0.34: Release tar file made. + +Sun Apr 13 15:39:20 1997 Arnold D. Robbins + + * Makefile.in ($(infodir)/gawk.info): exit 0 in case install-info + fails. + +Thu Jan 2 23:17:53 1997 Fred Fish + + * Makefile.in (awkcard.tr): Use ':' chars to separate parts of + sed command, since $(srcdir) may expand to something with '/' + characters in it, which confuses sed terribly. + * gawk.texi (Amiga Installation): Note change of configuration + from "m68k-cbm-amigados" to "m68k-amigaos". Point ftp users + towards current ADE distribution and not obsolete Aminet + "gcc" distribution. Change "FreshFish" to "Geek Gadgets". + +Wed Dec 25 11:25:22 1996 Arnold D. Robbins + + * Release 3.0.2: Release tar file made. + +Wed Dec 25 11:17:32 1996 Arnold D. Robbins + + * Makefile.in ($(mandir)/igawk$(manext),$(mandir)/gawk$(manext)): + remove chmod command; let $(INSTALL_DATA) use -m. + +Tue Dec 17 22:38:28 1996 Arnold D. Robbins + + * Makefile.in (gawk.info,gawk.dvi,postscript): run makeinfo, TeX, + and/or troff against files in $(srcdir). Thanks to Ulrich Drepper. + ($(infodir)/gawk.info): use --info-dir to install-info, not + --infodir. + +Tue Dec 10 23:09:26 1996 Arnold D. Robbins + + * Release 3.0.1: Release tar file made. + +Mon Dec 9 12:48:54 1996 Arnold D. Robbins + + * no.colors: new file from Michal for old troffs. + * Makefile.in [AWKCARD]: changes to parameterize old/new troff. + +Sun Dec 1 15:04:56 1996 Arnold D. Robbins + + * texinfo.tex: Updated to version 2.193, from Karl Berry. + +Tue Nov 26 22:57:15 1996 Arnold D. Robbins + + * Makefile.in ($(infodir)/gawk.info): Change option in call + to `install-info' to `--info-dir' from `--infodir'. + +Mon Nov 4 13:30:39 1996 Arnold D. Robbins + + * Makefile.in: updates for reference card. + (ad.block, awkcard.in, cardfonts, colors, macros, setter.outline): + new files for reference card. + +Wed Oct 16 12:43:02 1996 Arnold D. Robbins + + * texinfo.tex: Updated to version 2.185, from texinfo-3.9 dist. + +Sun Aug 11 23:12:08 1996 Arnold D. Robbins + + * Makefile.in ($(infodir)/gawk.info): correct use of + $(INSTALL_DATA) and remove chmod command. + +Thu Jul 11 22:06:50 1996 Arnold D. Robbins + + * Makefile.in ($(mandir)/gawk.$(ext), $(mandir)/igawk.$(ext)): + made dependant on files in $(srcdir). + +Fri Mar 15 06:45:35 1996 Arnold D. Robbins + + * Makefile.in (clean): add `*~' to list of files to be removed. + +Thu Jan 25 23:40:15 1996 Arnold D. Robbins + + * Makefile.in (dvi): run texindex and tex an extra time. + This gets the cross references right. Sigh. + +Wed Jan 24 11:51:54 1996 Arnold D. Robbins + + * Makefile.in (maintainer-clean): + Depend on distclean, not the other way around. + Output warning message as per GNU standards. diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..744b70a --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,112 @@ +# +# doc/Makefile.am --- automake input file for gawk +# +# Copyright (C) 2000, 2001, 2002, 2004, 2005, 2007, 2010, 2011 +# the Free Software Foundation, Inc. +# +# This file is part of GAWK, the GNU implementation of the +# AWK Programming Language. +# +# GAWK is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# + +## process this file with automake to produce Makefile.in + +info_TEXINFOS = gawk.texi gawkinet.texi + +man_MANS = gawk.1 igawk.1 + +EXTRA_DIST = ChangeLog ChangeLog.0 README.card ad.block setter.outline \ + awkcard.in awkforai.txt texinfo.tex cardfonts \ + general-program.eps general-program.fig general-program.pdf \ + process-flow.eps process-flow.fig process-flow.pdf \ + macros colors no.colors $(man_MANS) \ + lflashlight-small.xpic lflashlight.eps lflashlight.pdf \ + rflashlight-small.xpic rflashlight.eps rflashlight.pdf \ + statist.jpg statist.eps statist.pdf \ + bc_notes + +# Get rid of generated files when cleaning +CLEANFILES = *.ps *.html *.dvi *~ awkcard.nc awkcard.tr gawk.pdf gawkinet.pdf awkcard.pdf gawk.1.pdf igawk.1.pdf + +MAKEINFO = @MAKEINFO@ --no-split --force + +TROFF = groff -t -Tps -U +SEDME = sed -e "s/^level0 restore/level0 restore flashme 100 72 moveto (Copyright `date '+%m-%d-%y %T'`, FSF, Inc. (all)) show/" \ + -e "s/^\/level0 save def/\/level0 save def 30 -48 translate/" +SEDME2 = sed '/%%Page: 10 10/,/0 Cg EP/d' + +CARDSRC = $(srcdir)/macros $(srcdir)/cardfonts $(srcdir)/colors awkcard.tr +CARDSRC_N = $(srcdir)/macros $(srcdir)/cardfonts $(srcdir)/no.colors awkcard.tr +CARDFILES= $(CARDSRC) ad.block awkcard.in setter.outline + +# Use this if your troff can correctly handle macros from 'colors' file +AWKCARD = awkcard.ps + +# Uncomment the following definition of AWKCARD if your troff can produce +# Postscript but still has troubles with macros from 'colors'. As this +# is not groff you will have to change TROFF macro as well. Do not forget +# to ensure that awkcard.tr is processed by tbl. +#AWKCARD = awkcard.nc + +# The following is patterned after the main Makefile.am. The point is to +# make pgawk.1 a link to gawk.1 in the installed man directory. + +# We want hard links for install-data-hook, below +LN= ln -f + +# Link gawk.1 to pgawk.1 +install-data-hook: + (cd $(DESTDIR)$(man1dir); \ + $(LN) gawk.1 pgawk.1 2>/dev/null ; \ + exit 0) + +# Undo the above when uninstalling +uninstall-hook: + cd $(DESTDIR)$(man1dir); rm -f pgawk.1 ; exit 0 + +postscript: gawk.ps gawkinet.ps gawk.1.ps igawk.1.ps $(AWKCARD) + +pdf: postscript gawk.pdf gawkinet.pdf awkcard.pdf gawk.1.pdf igawk.1.pdf + +gawk.ps: gawk.dvi + dvips -o gawk.ps gawk.dvi + +gawkinet.ps: gawkinet.dvi + dvips -o gawkinet.ps gawkinet.dvi + +gawk.1.ps: gawk.1 + -groff -man $(srcdir)/gawk.1 > gawk.1.ps + +gawk.1.pdf: gawk.1.ps + ps2pdf gawk.1.ps gawk.1.pdf + +igawk.1.ps: igawk.1 + -groff -man $(srcdir)/igawk.1 > igawk.1.ps + +igawk.1.pdf: igawk.1.ps + ps2pdf igawk.1.ps igawk.1.pdf + +awkcard.tr: awkcard.in + sed 's:SRCDIR:$(srcdir):' < $(srcdir)/awkcard.in > awkcard.tr + +awkcard.ps: $(CARDFILES) + $(TROFF) $(CARDSRC) | $(SEDME) | cat $(srcdir)/setter.outline - | $(SEDME2) > awkcard.ps + +awkcard.nc: $(CARDFILES) + $(TROFF) $(CARDSRC_N) | $(SEDME) | cat $(srcdir)/setter.outline - | $(SEDME2) > awkcard.ps && touch awkcard.nc + +awkcard.pdf: awkcard.ps + ps2pdf awkcard.ps awkcard.pdf diff --git a/doc/Makefile.in b/doc/Makefile.in new file mode 100644 index 0000000..2d3dbae --- /dev/null +++ b/doc/Makefile.in @@ -0,0 +1,804 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# +# doc/Makefile.am --- automake input file for gawk +# +# Copyright (C) 2000, 2001, 2002, 2004, 2005, 2007, 2010, 2011 +# the Free Software Foundation, Inc. +# +# This file is part of GAWK, the GNU implementation of the +# AWK Programming Language. +# +# GAWK is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = doc +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ChangeLog \ + texinfo.tex +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/arch.m4 \ + $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ + $(top_srcdir)/m4/intmax_t.m4 $(top_srcdir)/m4/inttypes_h.m4 \ + $(top_srcdir)/m4/isc-posix.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ + $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libsigsegv.m4 \ + $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/m4/readline.m4 $(top_srcdir)/m4/socket.m4 \ + $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ + $(top_srcdir)/m4/ulonglong.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +SOURCES = +DIST_SOURCES = +INFO_DEPS = $(srcdir)/gawk.info $(srcdir)/gawkinet.info +am__TEXINFO_TEX_DIR = $(srcdir) +DVIS = gawk.dvi gawkinet.dvi +PDFS = gawk.pdf gawkinet.pdf +PSS = gawk.ps gawkinet.ps +HTMLS = gawk.html gawkinet.html +TEXINFOS = gawk.texi gawkinet.texi +TEXI2DVI = texi2dvi +TEXI2PDF = $(TEXI2DVI) --pdf --batch +MAKEINFOHTML = $(MAKEINFO) --html +AM_MAKEINFOHTMLFLAGS = $(AM_MAKEINFOFLAGS) +DVIPS = dvips +am__installdirs = "$(DESTDIR)$(infodir)" "$(DESTDIR)$(man1dir)" +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +man1dir = $(mandir)/man1 +NROFF = nroff +MANS = $(man_MANS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GREP = @GREP@ +HAVE_LIBSIGSEGV = @HAVE_LIBSIGSEGV@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +LDFLAGS = @LDFLAGS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBREADLINE = @LIBREADLINE@ +LIBS = @LIBS@ +LIBSIGSEGV = @LIBSIGSEGV@ +LIBSIGSEGV_PREFIX = @LIBSIGSEGV_PREFIX@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +LTLIBSIGSEGV = @LTLIBSIGSEGV@ +MAKEINFO = @MAKEINFO@ --no-split --force +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSUB = @POSUB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOCKET_LIBS = @SOCKET_LIBS@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +info_TEXINFOS = gawk.texi gawkinet.texi +man_MANS = gawk.1 igawk.1 +EXTRA_DIST = ChangeLog ChangeLog.0 README.card ad.block setter.outline \ + awkcard.in awkforai.txt texinfo.tex cardfonts \ + general-program.eps general-program.fig general-program.pdf \ + process-flow.eps process-flow.fig process-flow.pdf \ + macros colors no.colors $(man_MANS) \ + lflashlight-small.xpic lflashlight.eps lflashlight.pdf \ + rflashlight-small.xpic rflashlight.eps rflashlight.pdf \ + statist.jpg statist.eps statist.pdf \ + bc_notes + + +# Get rid of generated files when cleaning +CLEANFILES = *.ps *.html *.dvi *~ awkcard.nc awkcard.tr gawk.pdf gawkinet.pdf awkcard.pdf gawk.1.pdf igawk.1.pdf +TROFF = groff -t -Tps -U +SEDME = sed -e "s/^level0 restore/level0 restore flashme 100 72 moveto (Copyright `date '+%m-%d-%y %T'`, FSF, Inc. (all)) show/" \ + -e "s/^\/level0 save def/\/level0 save def 30 -48 translate/" + +SEDME2 = sed '/%%Page: 10 10/,/0 Cg EP/d' +CARDSRC = $(srcdir)/macros $(srcdir)/cardfonts $(srcdir)/colors awkcard.tr +CARDSRC_N = $(srcdir)/macros $(srcdir)/cardfonts $(srcdir)/no.colors awkcard.tr +CARDFILES = $(CARDSRC) ad.block awkcard.in setter.outline + +# Use this if your troff can correctly handle macros from 'colors' file +AWKCARD = awkcard.ps + +# Uncomment the following definition of AWKCARD if your troff can produce +# Postscript but still has troubles with macros from 'colors'. As this +# is not groff you will have to change TROFF macro as well. Do not forget +# to ensure that awkcard.tr is processed by tbl. +#AWKCARD = awkcard.nc + +# The following is patterned after the main Makefile.am. The point is to +# make pgawk.1 a link to gawk.1 in the installed man directory. + +# We want hard links for install-data-hook, below +LN = ln -f +all: all-am + +.SUFFIXES: +.SUFFIXES: .dvi .html .info .pdf .ps .texi +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu doc/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +.texi.info: + restore=: && backupdir="$(am__leading_dot)am$$$$" && \ + am__cwd=`pwd` && $(am__cd) $(srcdir) && \ + rm -rf $$backupdir && mkdir $$backupdir && \ + if ($(MAKEINFO) --version) >/dev/null 2>&1; then \ + for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \ + if test -f $$f; then mv $$f $$backupdir; restore=mv; else :; fi; \ + done; \ + else :; fi && \ + cd "$$am__cwd"; \ + if $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ + -o $@ $<; \ + then \ + rc=0; \ + $(am__cd) $(srcdir); \ + else \ + rc=$$?; \ + $(am__cd) $(srcdir) && \ + $$restore $$backupdir/* `echo "./$@" | sed 's|[^/]*$$||'`; \ + fi; \ + rm -rf $$backupdir; exit $$rc + +.texi.dvi: + TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ + MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ + $(TEXI2DVI) $< + +.texi.pdf: + TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ + MAKEINFO='$(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)' \ + $(TEXI2PDF) $< + +.texi.html: + rm -rf $(@:.html=.htp) + if $(MAKEINFOHTML) $(AM_MAKEINFOHTMLFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) \ + -o $(@:.html=.htp) $<; \ + then \ + rm -rf $@; \ + if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \ + mv $(@:.html=) $@; else mv $(@:.html=.htp) $@; fi; \ + else \ + if test ! -d $(@:.html=.htp) && test -d $(@:.html=); then \ + rm -rf $(@:.html=); else rm -Rf $(@:.html=.htp) $@; fi; \ + exit 1; \ + fi +$(srcdir)/gawk.info: gawk.texi +gawk.dvi: gawk.texi +gawk.pdf: gawk.texi +gawk.html: gawk.texi +$(srcdir)/gawkinet.info: gawkinet.texi +gawkinet.dvi: gawkinet.texi +gawkinet.pdf: gawkinet.texi +gawkinet.html: gawkinet.texi +.dvi.ps: + TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \ + $(DVIPS) -o $@ $< + +uninstall-dvi-am: + @$(NORMAL_UNINSTALL) + @list='$(DVIS)'; test -n "$(dvidir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(dvidir)/$$f'"; \ + rm -f "$(DESTDIR)$(dvidir)/$$f"; \ + done + +uninstall-html-am: + @$(NORMAL_UNINSTALL) + @list='$(HTMLS)'; test -n "$(htmldir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " rm -rf '$(DESTDIR)$(htmldir)/$$f'"; \ + rm -rf "$(DESTDIR)$(htmldir)/$$f"; \ + done + +uninstall-info-am: + @$(PRE_UNINSTALL) + @if test -d '$(DESTDIR)$(infodir)' && \ + (install-info --version && \ + install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \ + list='$(INFO_DEPS)'; \ + for file in $$list; do \ + relfile=`echo "$$file" | sed 's|^.*/||'`; \ + echo " install-info --info-dir='$(DESTDIR)$(infodir)' --remove '$(DESTDIR)$(infodir)/$$relfile'"; \ + if install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$$relfile"; \ + then :; else test ! -f "$(DESTDIR)$(infodir)/$$relfile" || exit 1; fi; \ + done; \ + else :; fi + @$(NORMAL_UNINSTALL) + @list='$(INFO_DEPS)'; \ + for file in $$list; do \ + relfile=`echo "$$file" | sed 's|^.*/||'`; \ + relfile_i=`echo "$$relfile" | sed 's|\.info$$||;s|$$|.i|'`; \ + (if test -d "$(DESTDIR)$(infodir)" && cd "$(DESTDIR)$(infodir)"; then \ + echo " cd '$(DESTDIR)$(infodir)' && rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]"; \ + rm -f $$relfile $$relfile-[0-9] $$relfile-[0-9][0-9] $$relfile_i[0-9] $$relfile_i[0-9][0-9]; \ + else :; fi); \ + done + +uninstall-pdf-am: + @$(NORMAL_UNINSTALL) + @list='$(PDFS)'; test -n "$(pdfdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(pdfdir)/$$f'"; \ + rm -f "$(DESTDIR)$(pdfdir)/$$f"; \ + done + +uninstall-ps-am: + @$(NORMAL_UNINSTALL) + @list='$(PSS)'; test -n "$(psdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(psdir)/$$f'"; \ + rm -f "$(DESTDIR)$(psdir)/$$f"; \ + done + +dist-info: $(INFO_DEPS) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + list='$(INFO_DEPS)'; \ + for base in $$list; do \ + case $$base in \ + $(srcdir)/*) base=`echo "$$base" | sed "s|^$$srcdirstrip/||"`;; \ + esac; \ + if test -f $$base; then d=.; else d=$(srcdir); fi; \ + base_i=`echo "$$base" | sed 's|\.info$$||;s|$$|.i|'`; \ + for file in $$d/$$base $$d/$$base-[0-9] $$d/$$base-[0-9][0-9] $$d/$$base_i[0-9] $$d/$$base_i[0-9][0-9]; do \ + if test -f $$file; then \ + relfile=`expr "$$file" : "$$d/\(.*\)"`; \ + test -f "$(distdir)/$$relfile" || \ + cp -p $$file "$(distdir)/$$relfile"; \ + else :; fi; \ + done; \ + done + +mostlyclean-aminfo: + -rm -rf gawk.aux gawk.cp gawk.cps gawk.fn gawk.ky gawk.kys gawk.log gawk.pg \ + gawk.pgs gawk.tmp gawk.toc gawk.tp gawk.tps gawk.vr \ + gawkinet.aux gawkinet.cp gawkinet.cps gawkinet.fn \ + gawkinet.ky gawkinet.kys gawkinet.log gawkinet.pg \ + gawkinet.pgs gawkinet.tmp gawkinet.toc gawkinet.tp \ + gawkinet.tps gawkinet.vr + +clean-aminfo: + -test -z "gawk.dvi gawk.pdf gawk.ps gawk.html gawkinet.dvi gawkinet.pdf \ + gawkinet.ps gawkinet.html" \ + || rm -rf gawk.dvi gawk.pdf gawk.ps gawk.html gawkinet.dvi gawkinet.pdf \ + gawkinet.ps gawkinet.html + +maintainer-clean-aminfo: + @list='$(INFO_DEPS)'; for i in $$list; do \ + i_i=`echo "$$i" | sed 's|\.info$$||;s|$$|.i|'`; \ + echo " rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]"; \ + rm -f $$i $$i-[0-9] $$i-[0-9][0-9] $$i_i[0-9] $$i_i[0-9][0-9]; \ + done +install-man1: $(man_MANS) + @$(NORMAL_INSTALL) + test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)" + @list=''; test -n "$(man1dir)" || exit 0; \ + { for i in $$list; do echo "$$i"; done; \ + l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.1[a-z]*$$/p'; \ + } | while read p; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; echo "$$p"; \ + done | \ + sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ + sed 'N;N;s,\n, ,g' | { \ + list=; while read file base inst; do \ + if test "$$base" = "$$inst"; then list="$$list $$file"; else \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ + fi; \ + done; \ + for i in $$list; do echo "$$i"; done | $(am__base_list) | \ + while read files; do \ + test -z "$$files" || { \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ + done; } + +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list=''; test -n "$(man1dir)" || exit 0; \ + files=`{ for i in $$list; do echo "$$i"; done; \ + l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ + sed -n '/\.1[a-z]*$$/p'; \ + } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ + -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ + test -z "$$files" || { \ + echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(man1dir)" && rm -f $$files; } +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @list='$(MANS)'; if test -n "$$list"; then \ + list=`for p in $$list; do \ + if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ + if test -n "$$list" && \ + grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ + echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ + grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ + echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ + echo " typically \`make maintainer-clean' will remove them" >&2; \ + exit 1; \ + else :; fi; \ + else :; fi + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" distdir="$(distdir)" \ + dist-info +check-am: all-am +check: check-am +all-am: Makefile $(INFO_DEPS) $(MANS) +installdirs: + for dir in "$(DESTDIR)$(infodir)" "$(DESTDIR)$(man1dir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-aminfo clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: $(DVIS) + +html: html-am + +html-am: $(HTMLS) + +info: info-am + +info-am: $(INFO_DEPS) + +install-data-am: install-info-am install-man + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-data-hook +install-dvi: install-dvi-am + +install-dvi-am: $(DVIS) + @$(NORMAL_INSTALL) + test -z "$(dvidir)" || $(MKDIR_P) "$(DESTDIR)$(dvidir)" + @list='$(DVIS)'; test -n "$(dvidir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(dvidir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(dvidir)" || exit $$?; \ + done +install-exec-am: + +install-html: install-html-am + +install-html-am: $(HTMLS) + @$(NORMAL_INSTALL) + test -z "$(htmldir)" || $(MKDIR_P) "$(DESTDIR)$(htmldir)" + @list='$(HTMLS)'; list2=; test -n "$(htmldir)" || list=; \ + for p in $$list; do \ + if test -f "$$p" || test -d "$$p"; then d=; else d="$(srcdir)/"; fi; \ + $(am__strip_dir) \ + if test -d "$$d$$p"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(htmldir)/$$f'"; \ + $(MKDIR_P) "$(DESTDIR)$(htmldir)/$$f" || exit 1; \ + echo " $(INSTALL_DATA) '$$d$$p'/* '$(DESTDIR)$(htmldir)/$$f'"; \ + $(INSTALL_DATA) "$$d$$p"/* "$(DESTDIR)$(htmldir)/$$f" || exit $$?; \ + else \ + list2="$$list2 $$d$$p"; \ + fi; \ + done; \ + test -z "$$list2" || { echo "$$list2" | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(htmldir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(htmldir)" || exit $$?; \ + done; } +install-info: install-info-am + +install-info-am: $(INFO_DEPS) + @$(NORMAL_INSTALL) + test -z "$(infodir)" || $(MKDIR_P) "$(DESTDIR)$(infodir)" + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \ + for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + esac; \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + file_i=`echo "$$file" | sed 's|\.info$$||;s|$$|.i|'`; \ + for ifile in $$d/$$file $$d/$$file-[0-9] $$d/$$file-[0-9][0-9] \ + $$d/$$file_i[0-9] $$d/$$file_i[0-9][0-9] ; do \ + if test -f $$ifile; then \ + echo "$$ifile"; \ + else : ; fi; \ + done; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(infodir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(infodir)" || exit $$?; done + @$(POST_INSTALL) + @if (install-info --version && \ + install-info --version 2>&1 | sed 1q | grep -i -v debian) >/dev/null 2>&1; then \ + list='$(INFO_DEPS)'; test -n "$(infodir)" || list=; \ + for file in $$list; do \ + relfile=`echo "$$file" | sed 's|^.*/||'`; \ + echo " install-info --info-dir='$(DESTDIR)$(infodir)' '$(DESTDIR)$(infodir)/$$relfile'";\ + install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$$relfile" || :;\ + done; \ + else : ; fi +install-man: install-man1 + +install-pdf: install-pdf-am + +install-pdf-am: $(PDFS) + @$(NORMAL_INSTALL) + test -z "$(pdfdir)" || $(MKDIR_P) "$(DESTDIR)$(pdfdir)" + @list='$(PDFS)'; test -n "$(pdfdir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pdfdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(pdfdir)" || exit $$?; done +install-ps: install-ps-am + +install-ps-am: $(PSS) + @$(NORMAL_INSTALL) + test -z "$(psdir)" || $(MKDIR_P) "$(DESTDIR)$(psdir)" + @list='$(PSS)'; test -n "$(psdir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(psdir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(psdir)" || exit $$?; done +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-aminfo \ + maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-aminfo mostlyclean-generic + +pdf-am: $(PDFS) + +ps: ps-am + +ps-am: $(PSS) + +uninstall-am: uninstall-dvi-am uninstall-html-am uninstall-info-am \ + uninstall-man uninstall-pdf-am uninstall-ps-am + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) uninstall-hook +uninstall-man: uninstall-man1 + +.MAKE: install-am install-data-am install-strip uninstall-am + +.PHONY: all all-am check check-am clean clean-aminfo clean-generic \ + dist-info distclean distclean-generic distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-data-hook install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-man1 \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-aminfo \ + maintainer-clean-generic mostlyclean mostlyclean-aminfo \ + mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am \ + uninstall-dvi-am uninstall-hook uninstall-html-am \ + uninstall-info-am uninstall-man uninstall-man1 \ + uninstall-pdf-am uninstall-ps-am + + +# Link gawk.1 to pgawk.1 +install-data-hook: + (cd $(DESTDIR)$(man1dir); \ + $(LN) gawk.1 pgawk.1 2>/dev/null ; \ + exit 0) + +# Undo the above when uninstalling +uninstall-hook: + cd $(DESTDIR)$(man1dir); rm -f pgawk.1 ; exit 0 + +postscript: gawk.ps gawkinet.ps gawk.1.ps igawk.1.ps $(AWKCARD) + +pdf: postscript gawk.pdf gawkinet.pdf awkcard.pdf gawk.1.pdf igawk.1.pdf + +gawk.ps: gawk.dvi + dvips -o gawk.ps gawk.dvi + +gawkinet.ps: gawkinet.dvi + dvips -o gawkinet.ps gawkinet.dvi + +gawk.1.ps: gawk.1 + -groff -man $(srcdir)/gawk.1 > gawk.1.ps + +gawk.1.pdf: gawk.1.ps + ps2pdf gawk.1.ps gawk.1.pdf + +igawk.1.ps: igawk.1 + -groff -man $(srcdir)/igawk.1 > igawk.1.ps + +igawk.1.pdf: igawk.1.ps + ps2pdf igawk.1.ps igawk.1.pdf + +awkcard.tr: awkcard.in + sed 's:SRCDIR:$(srcdir):' < $(srcdir)/awkcard.in > awkcard.tr + +awkcard.ps: $(CARDFILES) + $(TROFF) $(CARDSRC) | $(SEDME) | cat $(srcdir)/setter.outline - | $(SEDME2) > awkcard.ps + +awkcard.nc: $(CARDFILES) + $(TROFF) $(CARDSRC_N) | $(SEDME) | cat $(srcdir)/setter.outline - | $(SEDME2) > awkcard.ps && touch awkcard.nc + +awkcard.pdf: awkcard.ps + ps2pdf awkcard.ps awkcard.pdf + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/doc/README.card b/doc/README.card new file mode 100644 index 0000000..ef77cda --- /dev/null +++ b/doc/README.card @@ -0,0 +1,19 @@ +Mon Dec 9 12:45:48 EST 1996 + +The AWK reference card included here requires a modern version of troff +(ditroff). GNU Troff (groff) is known to work. + +If your troff is able to produce Postscript but does not know how to +properly use the macros from `colors' file then try to uncomment in +Makefile the defintion which sets AWKCARD to awkcard.nc (no colors). +This will definitely require changes to the TROFF macro and you have to +ensure that the tbl preprocessor is called. For example, the following +modifications on NeXT: + +TROFF = tbl +SEDME = ptroff -t | sed -e \ + "s/^level0 restore/level0 restore flashme 100 72 moveto\ + (Copyright `date`, FSF, Inc. (all)) show/" \ + -e "s/^\/level0 save def/\/level0 save def 30 -48 translate/" + +will produce a correctly formatted, albeit monochromatic, reference card. diff --git a/doc/ad.block b/doc/ad.block new file mode 100644 index 0000000..6093c45 --- /dev/null +++ b/doc/ad.block @@ -0,0 +1,48 @@ +.\" AWK Reference Card --- Arnold Robbins, arnold@skeeve.com +.\" This file is the Ad block (included in cover) +.\" +.\" Copyright (C) 1996, 1998, 2000, 2001, 2003 Free Software Foundation, Inc. +.\" +.\" Permission is granted to make and distribute verbatim copies of +.\" this reference card provided the copyright notice and this permission +.\" notice are preserved on all copies. +.\" +.\" Permission is granted to process this file through troff and print the +.\" results, provided the printed document carries copying permission +.\" notice identical to this one except for the removal of this paragraph +.\" (this paragraph not being relevant to the printed reference card). +.\" +.\" Permission is granted to copy and distribute modified versions of this +.\" reference card under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" Permission is granted to copy and distribute translations of this +.\" reference card into another language, under the above conditions for +.\" modified versions, except that this permission notice may be stated in +.\" a translation approved by the Foundation. +.\" +.ft HB +.ps 10 +.vs 12 +.ES +.nf +.ce 7 +\*(CBFree Software Foundation, Inc. +.ft H +51 Franklin Street, Fifth Floor +Boston, MA 02110-1301 USA +Phone: +1-617-542-5942 +Fax (including Japan): +1-617-542-2652 +E-mail: gnu@gnu.org +URL: http://www.gnu.org + +.ce 5 +.ft HB +\*(CGSource Distributions on CD-ROM +.\" Deluxe Distributions +Emacs, Make and GDB Manuals +Emacs and GDB References\*(CX +.EB "\f(HBOTHER FSF PRODUCTS:\*(FR" +.ps +.vs diff --git a/doc/awkcard.in b/doc/awkcard.in new file mode 100644 index 0000000..22b4716 --- /dev/null +++ b/doc/awkcard.in @@ -0,0 +1,1974 @@ +.\" AWK Reference Card --- Arnold Robbins, arnold@skeeve.com +.\" +.\" Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, +.\" 2003, 2004, 2005, 2007, 2009, 2010, 2011, 2012 +.\" Free Software Foundation, Inc. +.\" +.\" Permission is granted to make and distribute verbatim copies of +.\" this reference card provided the copyright notice and this permission +.\" notice are preserved on all copies. +.\" +.\" Permission is granted to process this file through troff and print the +.\" results, provided the printed document carries copying permission +.\" notice identical to this one except for the removal of this paragraph +.\" (this paragraph not being relevant to the printed reference card). +.\" +.\" Permission is granted to copy and distribute modified versions of this +.\" reference card under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" Permission is granted to copy and distribute translations of this +.\" reference card into another language, under the above conditions for +.\" modified versions, except that this permission notice may be stated in +.\" a translation approved by the Foundation. +.\" +.\" Strings to save typing +.ds AK \*(FCawk\*(FR +.ds GK \*(FCgawk\*(FR +.ds PK \*(FCpgawk\*(FR +.ds NK Bell Labs \*(FCawk\*(FR +.ds MK \*(FCmawk\*(FR +.\" +.\" +.de TD\" tab defaults +.ta .2i .78i 1i 1.2i 1.4i 1.7i +.. +.de TE +.TD +.. + +.sp +.ce +\*(CD\f(HB\s+8AWK REFERENCE\s0\*(FR +.sp +.\" --- Table Of Contents +.ta 2.4i 2.6iR +.lc . +.ES +.in +.2i +.nf +\*(FRAction Statements 9 +Arrays 7 +Awk Program Execution 5 +Bit Manipulation Functions (\*(GK) 17 +Bug Reports 2 +Closing Redirections 13 +Command Line Arguments (standard) 2 +Command Line Arguments (\*(GK) 3 +Command Line Arguments (\*(MK) 4 +Conversions And Comparisons 8 +Copying Permissions 18 +Definitions 2 +Dynamic Extensions (\*(GK) 17 +Environment Variables (\*(GK) 11 +Escape Sequences 9 +Expressions 7 +Fields 10 +FTP/HTTP Information 18 +Historical Features (\*(GK) 10 +Input Control 13 +Internationalization (\*(GK) 18 +Lines And Statements 4 +Localization (\*(GK) 12 +Numeric Functions 15 +Output Control 13 +Pattern Elements 8 +Printf Formats 14 +Records 10 +Regular Expressions 11 +Signals (\*(PK) 4 +Special Filenames 12 +String Functions 16 +Time Functions (\*(GK) 17 +Type Functions (\*(GK) 18 +User-defined Functions 15 +Variables 5\*(CX +.in -.2i +.EB "\s+2\f(HBCONTENTS\*(FR\s0" +.sp .4 +.TD +.fi +\*(CD\*(FRArnold Robbins wrote this reference card. +We thank +Brian Kernighan and Michael Brennan who reviewed it. +.sp .4 +.SL +.sp .4 +.so SRCDIR/ad.block +.\" a subtlety here; this line changes color. We rely on it +.\" also to provide a blank line. +\*(CD +.SL +.nf +\*(FRCopyright \(co 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +2005, 2007, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. +.nf +.BT + + +.\" +.\" +.\" --- Definitions +.fi +.ES +\*(CDThis card describes POSIX AWK, as well as three +freely available \*(AK implementations +(see \fHFTP/HTTP Information\fP below). +\*(CLCommon extensions (in two or more versions) are printed in light blue. +\*(CBFeatures specific to just one version\(emusually GNU AWK (\*(GK)\(emare +printed in dark blue. +\*(CRExceptions and deprecated features are printed in red. +\*(CDFeatures mandated by POSIX are printed in black. +.sp .5 +Several type faces are used to clarify the meaning: +.br +.nr IN \w'\(bu ' +\(bu \*(FC\*(CN\fP is used for computer input. +.br +.fi +.in +\n(INu +.ti -\n(INu +\(bu\|\^\*(FI\*(IN\fP is used for emphasis, to indicate user input and for syntactic +placeholders, such as \*(FIvariable\fP or \*(FIaction\fP. +.in -\n(INu +.br +\(bu \*(RN is used for explanatory text. +.sp .5 +\*(FInumber\fP \- a floating point number as in ANSI C, such as +\*(FC3\*(FR, +\*(FC2.3\*(FR, +\*(FC.4\*(FR, +\*(FC1.4e2\*(FR +or +\*(FC4.1E5\*(FR. +\*(CBNumbers may also be given in octal or hexadecimal: e.g., +\*(FC011\*(FR or \*(FC0x11\*(FR.\*(CD +.sp .5 +\*(FIescape sequences\fP \- a special sequence of characters beginning +with a backslash, used to describe otherwise unprintable characters. +(See \fHEscape Sequences\fP below.) +.sp .5 +\*(FIstring\fP \- a group of characters enclosed in double quotes. +Strings may contain \*(FIescape sequences\*(FR. +.sp .5 +\*(FIregexp\fP \- a regular expression, either a regexp constant +enclosed in forward slashes, or a dynamic regexp computed at run-time. +Regexp constants may contain \*(FIescape sequences\*(FR. +.sp .5 +\*(FIname\fP \- a variable, array or function name. +.sp .5 +\*(FIentry\fP(\*(FIN\fP) \- entry \*(FIentry\fP in section \*(FIN\fP of the +Unix reference manual. +.sp .5 +\*(FIpattern\fP \- an expression describing an input record to be matched. +.sp .5 +\*(FIaction\fP \- statements to execute when an input record is matched. +.sp .5 +\*(FIrule\fP \- a pattern-action pair, where the pattern or action may +be missing.\*(CX +.EB "\s+2\f(HBDEFINITIONS\*(FR\s0" + +.\" +.\" +.\" --- Command Line Arguments +.ES +.fi +\*(CDCommand line arguments control setting the field separator, +setting variables before the \*(FCBEGIN\fP rule is run, and +the location of AWK program source code. +Implementation-specific command line arguments change +the behavior of the running interpreter. +.sp .5 +.TS +expand; +l lw(2.0i). +\*(FC\-F \*(FIfs\*(FR Use \*(FIfs\fP for the input field separator. +\*(FC\-v\*(FI var\*(FC\^=\^\*(FIval\*(FR T{ +Assign the value \*(FIval\*(FR to the variable \*(FIvar\*(FR +before execution of the program begins. Such +variable values are available to the \*(FCBEGIN\fP rule. +T} +\*(FC\-f \*(FIprog-file\*(FR T{ +Read the AWK program source from the file +\*(FIprog-file\*(FR, instead of from the first command +line argument. Multiple \*(FC\-f\*(FR options may be used. +T} +\*(FC\-\^\-\*(FR Signal the end of options.\*(CX +.TE +.EB "\s+2\f(HBCOMMAND LINE ARGUMENTS (standard)\*(FR\s0" + +.\" --- Bug Reports +.ES +.fi +\*(CDIf you find a bug in this reference card, please report it via electronic +mail to \*(FCbug-gawk@gnu.org\*(FR.\*(CX +.EB "\s+2\f(HBBUG REPORTS\*(FR\s0" + +.BT + +.\" +.\" +.\" --- Command Line Arguments (gawk) +.ES +.fi +\*(CDLong options may abbreviated as long as the abbreviation +remains unique. +You may use ``\*(FC\-W \*(FIoption\*(FR'' +for full POSIX compliance. +.sp .5 +.ig +.\" This option is left undocumented, on purpose. +\*(FC\-\^\-nostalgia\*(FR%T{ +provide a moment of nostalgia for +long time \*(AK users. +T} +.. +.de TI \" table item +.ti -4n +\\$1 +.br +.. +.TS +expand, tab(%); +l lw(1.3i). +\*(FC\-\^\-assign \*(FIvar\*(FC\^=\^\*(FIval\*(FR%Same as \*(FC\-v\fP. +\*(FC\-\^\-field-separator \*(FIfs\*(FR%Same as \*(FC\-F\fP. +\*(FC\-\^\-file \*(FIprog-file%\*(FRSame as \*(FC\-f\fP. +.TE +.in +4n +.TI "\*(FC\-b\*(FR, \*(FC\-\^\-characters\-as\-bytes\*(FR +Treat all input data as single-byte characters. I.e., +don't attempt to +process strings as multibyte characters. +Overridden by \*(FC\-\^\-posix\*(FR. +.TI "\*(FC\-c\*(FR, \*(FC\-\^\-traditional\*(FR +Disable \*(GK-specific extensions. +.TI "\*(FC\-C\*(FR, \*(FC\-\^\-copyright\*(FR +Print the short version of the GNU +copyright information on \*(FCstdout\*(FR. +.TI "\*(FC\-d\*(FR[\*(FIfile\*(FR], \*(FC\-\^\-dump-variables\*(FR[\*(FC=\*(FIfile\*(FR] +Print a sorted list of global variables, +their types and final values to +\*(FIfile\*(FR. +If no \*(FIfile\*(FR +is provided, \*(FCgawk\*(FR +uses \*(FCawkvars.out\*(FR. +.TI "\*(FC-e '\*(FItext\*(FC'\*(FR, \*(FC\-\^\-source '\*(FItext\*(FC'\*(FR +Use \*(FItext\*(FR as AWK program source code. +.TI "\*(FC\-E \*(FIfile\*(FR, \*(FC\-\^\-exec \*(FIfile\*(FR +Read program text from \*(FIfile\fP. No other +options are processed. +Also disables command-line variable assignments. +Useful with \*(FC#!\fP. +.TI "\*(FC\-g\*(FR, \*(FC\-\^\-gen\-pot\*(FR +Process the program and print a GNU \*(FCgettext\*(FR +format \*(FC\&.pot\*(FR file on standard output, +containing the text of all strings that were marked +for localization. +.TI "\*(FC\-h\*(FR, \*(FC\-\^\-help\*(FR +Print a short summary of the available +options on \*(FCstdout\*(FR, then exit zero. +.TI "\*(FC\-L \*(FR[\*(FC\*(FIvalue\*(FR], \*(FC\-\^\-lint\*(FR[\*(FC=\*(FIvalue\*(FR] +Warn about dubious or non-portable constructs. +If \*(FIvalue\*(FR is +\*(FCfatal\*(FR, +lint warnings become fatal errors. +If \*(FIvalue\*(FR is +\*(FCinvalid\*(FR, +only issue warnings about things that are +actually invalid (not fully implemented yet). +.TI "\*(FC\-n\*(FR, \*(FC\-\^\-non\-decimal\-data\*(FR +Recognize octal and hexadecimal values in input data. +\*(FIUse this option with great caution!\*(FR +.TI "\*(FC\-N\*(FR, \*(FC\-\^\-use\-lc\-numeric\*(FR +Force use of the locale's decimal point character when parsing input data. +.TI "\*(FC\-O\*(FR, \*(FC\-\^\-optimize\*(FR +Enable some internal optimizations. +.TI "\*(FC\-p\*(FR[\*(FC\*(FIfile\*(FR], \*(FC\-\^\-profile\*(FR[\*(FC=\*(FIfile\*(FR] +Send profiling data to \*(FIfile\*(FR +(default: \*(FCawkprof.out\*(FR). +With \*(GK, +the profile is just a ``pretty printed'' version of the program. +With \*(PK, +the profile contains execution counts in the left margin +of each statement in the program. +.TI "\*(FC\-P\*(FR, \*(FC\-\^\-posix\*(FR +Disable common and GNU extensions. +.TI "\*(FC\-R \*(FIfile\*(FR, \*(FC\-\^\-command \*(FIfile\*(FR" +\*(FCdgawk\*(FR only. +Read stored debugger commands from \*(FIfile\*(FR. +.TI "\*(FC\-r\*(FR, \*(FC\-\^\-re\-interval\*(FR +Enable \*(FIinterval expressions\*(FR in regular +expression matching (see \fHRegular +Expressions\fP below). Useful if +\*(FC\-\^\-traditional\*(FR is specified. +.TI "\*(FC\-S\*(FR, \*(FC\-\^\-sandbox\*(FR +Disable the \*(FCsystem()\*(FR function, +input redirection with \*(FCgetline\*(FR, +output redirection with \*(FCprint\*(FR and \*(FCprintf\*(FR, +and dynamic extensions loading.\*(CB +.in -4n +.EB "\s+2\f(HBCOMMAND LINE ARGUMENTS (\*(GK\f(HB)\*(FR\s0" + +.BT + +.\" +.\" +.\" --- Command Line Arguments (gawk) continued +.ES +.fi +.in +4n +.TI "\*(FC-t\*(FR, \*(FC\-\^\-lint\-old\*(FR +Warn about constructs that are not +portable to the original version of +Unix \*(AK. +.TI "\*(FC\-V\*(FR, \*(FC\-\^\-version\*(FR +Print version \" information +info +on \*(FCstdout\fP +and exit zero. +.in -4n +.sp .5 +.fi +In compatibility mode, +any other options are flagged as invalid, but are otherwise ignored. +Normally, if there is program text, unknown +options are passed on to the AWK program in +\*(FCARGV\*(FR +for processing.\*(CB +.EB "\s+2\f(HBCOMMAND LINE ARGUMENTS (\*(GK\f(HB)\*(FR\s0" + +.\" +.\" +.\" --- Command Line Arguments (mawk) +.ES +.fi +\*(CDThe following options are specific to \*(MK. +.sp .5 +.fi +.TS +expand; +l lw(1.8i). +\*(FC\-W dump\*(FR T{ +Print an assembly listing of the program to +\*(FCstdout\fP and exit zero. +T} +\*(FC\-W exec \*(FIfile\*(FR T{ +Read program text from \*(FIfile\fP. No other +options are processed. Useful with \*(FC#!\fP. +T} +\*(FC\-W interactive\*(FR T{ +Unbuffer \*(FCstdout\fP and line buffer \*(FCstdin\fP. +Lines are always records, ignoring \*(FCRS\fP. +T} +\*(FC\-W posix_space\*(FR T{ +\*(FC\en\*(FR separates fields when \*(FCRS = "\^"\fP. +T} +\*(FC\-W sprintf=\*(FInum\*(FR T{ +Adjust the size of \*(MK's internal +\*(FCsprintf\*(FR buffer. +T} +\*(FC\-W version\*(FR T{ +Print version and copyright on +\*(FCstdout\fP and limit information on \*(FCstderr\fP +and exit zero. +T} +.TE +.sp .5 +.fi +The options may be abbreviated using just the first letter, e.g., +\*(FC\-We\*(FR, +\*(FC\-Wv\*(FR +and so on.\*(CB +.EB "\s+2\f(HBCOMMAND LINE ARGUMENTS (\*(MK\f(HB)\*(FR\s0" +.sp .7 +.\" --- Signals (pgawk) +.ES +.fi +\*(CD\*(PK accepts two signals. +\*(FCSIGUSR1\fP dumps a profile and function call stack to the +profile file. It then continues to run. +\*(FCSIGHUP\fP is similar, but exits.\*(CB +.EB "\s+2\f(HBSIGNALS (\*(PK\f(HB)\*(FR\s0" + +.\" --- Lines And Statements +.ES +.fi +\*(CDAWK is a line-oriented language. The pattern comes first, and then the +action. Action statements are enclosed in \*(FC{\fP and \*(FC}\*(FR. +Either the pattern or the action may be missing, but +not both. If the pattern is missing, the action is +executed for every input record. +A missing action is equivalent to +.sp .5 + \*(FC{ print }\fP +.sp .5 +which prints the entire record. +.sp .5 +Comments begin with the \*(FC#\*(FR character, and continue until the +end of the line. +Normally, a statement ends with a newline, but lines ending in +a ``,'', +\*(FC{\*(FR, +\*(CB\*(FC?\*(FR, +\*(FC:\*(FR,\*(CD +\*(FC&&\*(FR +or +\*(FC||\*(FR +are automatically continued. +Lines ending in \*(FCdo\fP or \*(FCelse\fP +also have their statements automatically continued on the following line. +In other cases, a line can be continued by ending it with a ``\e'', +in which case the newline is ignored. However, a ``\e'' after a +\*(FC#\*(FR is not special. +.sp .5 +Multiple statements may be put on one line by separating them with a ``;''. +This applies to both the statements within the action part of a +pattern-action pair (the usual case) +and to the pattern-action statements themselves.\*(CX +.EB "\s+2\f(HBLINES AND STATEMENTS\*(FR\s0" +.BT + +.\" --- Awk Program Execution +.ES +.fi +\*(CDAWK programs are a sequence of pattern-action statements +and optional function definitions. +.sp .5 + \*(CB\*(FC@include "\*(FIfilename\*(FC"\*(CD +.br + \*(FIpattern\*(FC { \*(FIaction statements\*(FC }\*(FR +.br + \*(FCfunction \*(FIname\*(FC(\*(FIparameter list\*(FC) { \*(FIstatements\*(FC }\*(FR +.sp .5 +\*(AK first reads the program source from the +\*(FIprog-file\*(FR(s), if specified, +\*(CBfrom arguments to \*(FC\-\^\-source\*(FR,\*(CD +or from the first non-option argument on the command line. +The program text is read as if all the \*(FIprog-file\*(FR(s) +\*(CBand command line +source texts\*(CD had been concatenated. +.sp +\*(GK includes files named on \*(FC@include\*(FR lines. +Nested includes are allowed.\*(CD +.sp .5 +AWK programs execute in the following order. +First, all variable assignments specified via the \*(FC\-v\fP +option are performed. +Next, \*(AK executes the code in the +\*(FCBEGIN\fP rules(s), if any, and then proceeds to read +the files \*(FC1\fP through \*(FCARGC \- 1\fP in the \*(FCARGV\fP array. +(Adjusting \*(FCARGC\fP and \*(FCARGV\fP thus provides control over +the input files that will be processed.) +If there are no files named on the command line, +\*(AK reads the standard input. +.sp .5 +If a command line argument has the form +\*(FIvar\*(FC=\*(FIval\*(FR, +it is treated as a variable assignment. The variable +\*(FIvar\fP will be assigned the value \*(FIval\*(FR. +(This happens after any \*(FCBEGIN\fP rule(s) have been run.) +... delete this paragraph if no space +Command line variable assignment +is most useful for dynamically assigning values to the variables +\*(AK uses to control how input is broken into fields and records. It +is also useful for controlling state if multiple passes are needed over +a single data file. +.sp .5 +If the value of a particular element of \*(FCARGV\fP is empty +(\*(FC"\^"\*(FR), \*(AK skips over it. +.sp .5 +\*(CBFor each input file, +if a \*(FCBEGINFILE\fP rule exists, \*(GK executes the associated code +before processing the contents of the file. Similarly, \*(GK executes +the code associated with \*(FCENDFILE\fP after processing the file.\*(CD +.sp .5 +For each record in the input, \*(AK tests to see if it matches any +\*(FIpattern\fP in the AWK program. +For each pattern that the record matches, the associated +\*(FIaction\fP is executed. +The patterns are tested in the order they occur in the program. +.sp .5 +Finally, after all the input is exhausted, +\*(AK executes the code in the \*(FCEND\fP rule(s), if any. +.sp .5 +If a program only has a \*(FCBEGIN\fP rule, no input files are processed. +If a program only has an \*(FCEND\fP rule, the input is read. +\*(CX +.EB "\s+2\f(HBAWK PROGRAM EXECUTION\*(FR\s0" +.sp .5 +.\" --- Variables +.ES +.fi +.TS +expand; +l lw(2i). +\*(CD\*(FCARGC\fP T{ +Number of command line arguments. +T} +\*(CB\*(FCARGIND\fP T{ +Index in \*(FCARGV\fP of current data file.\*(CD +T} +\*(FCARGV\fP T{ +Array of command line arguments. Indexed from +0 to \*(FCARGC\fP \- 1. Dynamically changing the +contents of \*(FCARGV\fP can control the files used +for data. +T} +\*(CL\*(FCBINMODE\fP T{ +Controls ``binary'' mode for all file I/O. Values of 1, 2, or 3, +indicate input, output, or all files, respectively, should use binary +I/O. \*(CR(Not \*(NK.) \*(CLApplies only to non-POSIX systems. +\*(CBFor \*(GK, string values of \*(FC"r"\fP, or \*(FC"w"\fP specify +that input files, or output files, respectively, should use binary I/O. +Use \*(FC"rw"\fP or \*(FC"wr"\fP for all files.\*(CX +T} +.TE +.EB "\s+2\f(HBVARIABLES\*(FR\s0" +.BT + +.\" --- Variables (continued) +.ES +.fi +.TS +expand; +l lw(2i). +\*(FCCONVFMT\fP T{ +Conversion format for numbers, default value +is \*(FC"%.6g"\*(FR. +T} +\*(FCENVIRON\fP T{ +Array containing the current environment. +it is indexed by the environment +variables, each element being the value of +that variable. +T} +\*(CB\*(FCERRNO\fP T{ +String describing the error if a +\*(FCgetline\*(FR +redirection or read +fails, or if +\*(FCclose()\*(FR fails. +T} +\*(FCFIELDWIDTHS\fP T{ +Whitespace separated list of field widths. Used +to parse the input into fields of fixed width, +instead of the value of \*(FCFS\fP.\*(CD +T} +\*(FCFILENAME\fP T{ +Name of the current input file. If no files given +on the command line, \*(FCFILENAME\fP is ``\-''. +\*(FCFILENAME\fP is undefined inside the \*(FCBEGIN\fP rule +(unless set by \*(FCgetline\fP). +T} +\*(FCFNR\fP T{ +Record number in current input file. +T} +\*(CB\*(FCFPAT\fP T{ +Regular expression describing field contents. +Used to parse the input based on the fields +instead of the field separator.\*(CD +T} +\*(FCFS\fP T{ +Input field separator, a space by default +(see \fHFields\fP above). +T} +\*(CB\*(FCIGNORECASE\fP T{ +If non-zero, all regular expression and string +operations ignore case. +Array subscripting +is \*(FInot\*(FR affected. +However, the +\*(FCasort()\*(FR +and +\*(FCasorti()\*(FR +function are affected. +T} +\*(CB\*(FCLINT\fP T{ +Provides dynamic control of the \*(FC\-\^\-lint\fP +option from within an AWK program. +When true, \*(GK +prints lint warnings. +When assigned the string value \*(FC"fatal"\*(FR, +lint warnings become fatal errors. +Any other true value just prints warnings.\*(CD +T} +\*(FCNF\fP T{ +Number of fields in the current input record. +T} +\*(FCNR\fP T{ +Total number of input records seen so far.\*(CX +T} +\*(CD\*(FCOFMT\fP T{ +Output format for numbers, \*(FC"%.6g"\*(FR, by default. +T} +\*(FCOFS\fP T{ +Output field separator, a space by default. +T} +\*(FCORS\fP T{ +Output record separator, a newline by default. +T} +\*(CB\*(FCPROCINFO\fP T{ +Elements of this array provide access to information +about the running AWK program. See +\*(AM for details.\*(CD +T} +\*(FCRLENGTH\fP T{ +Length of the string matched by \*(FCmatch()\*(FR; +\-1 if no match. +T} +\*(FCRS\fP T{ +Input record separator, a newline by default +(see \fHRecords\fP above). +T} +\*(FCRSTART\fP T{ +Index of the first character matched by +\*(FCmatch()\*(FR; 0 if no match. +T} +\*(CB\*(FCRT\fP T{ +Record terminator. \*(GK sets \*(FCRT\fP to the input +text that matched the character or regular +expression specified by \*(FCRS\*(FR.\*(CD +T} +\*(FCSUBSEP\fP T{ +Character(s) used to separate multiple subscripts +in array elements, by default \*(FC"\e034"\*(FR. (See +\fHArrays\fP below). +T} +\*(CB\*(FCTEXTDOMAIN\fP T{ +The internationalization text domain, +for finding the localized +translations of the program's strings.\*(CX +T} +.TE +.EB "\s+2\f(HBVARIABLES (continued)\*(FR\s0" + +.BT + +.\" --- Arrays +.ES +.fi +\*(CDAn array subscript is an expression between square brackets +(\*(FC[ \*(FRand \*(FC]\*(FR). +If the expression is a list +(\*(FIexpr\*(FC, \*(FIexpr \*(FR...), +then the subscript is a string consisting of the +concatenation of the (string) value of each expression, +separated by the value of the \*(FCSUBSEP\fP variable. +This simulates multi-dimensional +arrays. For example: +.nf +.sp .5 + \*(FCi = "A";\^ j = "B";\^ k = "C" + x[i, j, k] = "hello, world\en"\*(FR +.sp .5 +.fi +assigns \*(FC"hello, world\en"\*(FR to the element of the array +\*(FCx\fP +indexed by the string \*(FC"A\e034B\e034C"\*(FR. All arrays in AWK +are associative, i.e., indexed by string values. +.sp .5 +Use the special operator \*(FCin\fP in an \*(FCif\fP +or \*(FCwhile\fP statement to see if a particular value is +an array index. +.sp .5 +.nf + \*(FCif (val in array) + print array[val]\*(FR +.sp .5 +.fi +If the array has multiple subscripts, use +\*(FC(i, j) in array\*(FR. +.sp .5 +Use the \*(FCin\fP construct in a \*(FCfor\fP +loop to iterate over all the elements of an array. +.sp .5 +Use the \*(FCdelete\fP statement to delete an +element from an array. +\*(CLSpecifying just the array name without a subscript in +the \*(FCdelete\fP +statement deletes the entire contents of an array. +.sp .5 +\*(CB\*(GK provides true multidimensional arrays. +Such arrays need not be ``rectangular'' as in C or C++. For example: +.sp .5 +.nf + \*(FCa[1] = 5; a[2][1] = 6; a[2][2] = 7\*(FR\*(CX +.fi +.EB "\s+2\f(HBARRAYS\*(FR\s0" + +.\" --- Expressions +.ES +.fi +\*(CDExpressions are used as patterns, for controlling conditional action +statements, and to produce parameter values when calling functions. +Expressions may also be used as simple statements, +particularly if they have side-effects such as assignment. +Expressions mix \*(FIoperands\fP and \*(FIoperators\fP. Operands are +constants, fields, variables, array elements, and the return +values from function calls (both built-in and user-defined). +.sp .5 +Regexp constants (\*(FC/\*(FIpat\*(FC/\*(FR), when used as simple expressions, +i.e., not used on the right-hand side of +\*(FC~\fP and \*(FC!~\fP, or as arguments to the +\*(CB\*(FCgensub()\fP,\*(CD +\*(FCgsub()\fP, +\*(FCmatch()\fP, +\*(CB\*(FCpatsplit()\fP,\*(CD +\*(FCsplit()\fP, +and +\*(FCsub()\fP, +functions, mean \*(FC$0 ~ /\*(FIpat\*(FC/\*(FR. +.sp .5 +The AWK operators, in order of decreasing precedence, are: +.sp .5 +.fi +.TS +expand; +l lw(1.8i). +\*(FC(\&...)\*(FR Grouping +\*(FC$\fP Field reference +\*(FC++ \-\^\-\fP T{ +Increment and decrement, +prefix and postfix +T} +\*(FC^\fP \*(CL\*(FC**\*(FR\*(CD Exponentiation +\*(FC+ \- !\fP Unary plus, unary minus, and logical negation +\*(FC* / %\fP Multiplication, division, and modulus +\*(FC+ \-\fP Addition and subtraction +\*(FIspace\fP String concatenation +\*(FC< >\fP Less than, greater than +\*(FC<= >=\fP Less than or equal, greater than or equal +\*(FC!= ==\fP Not equal, equal +\*(FC~ !~\fP Regular expression match, negated match +\*(FCin\fP Array membership +\*(FC&&\fP Logical AND, short circuit +\*(FC||\fP Logical OR, short circuit +\*(FC?\^:\fP In-line conditional expression +.T& +l s +l lw(1.8i). +\*(FC=\0+=\0\-=\0*=\0/=\0%=\0^=\0\*(CL**=\*(CD\fP + Assignment operators\*(CX +.TE +.EB "\s+2\f(HBEXPRESSIONS\*(FR\s0" + +.BT + +.\" --- Conversions and Comparisons +.ES +.fi +\*(CDVariables and fields may be (floating point) numbers, strings or both. +Context determines how a variable's value is interpreted. If used in +a numeric expression, it will be treated as a number, if used as a string +it will be treated as a string. +.sp .5 +To force a variable to be treated as a number, add 0 to it; to force it +to be treated as a string, concatenate it with the null string. +.sp .5 +When a string must be converted to a number, the conversion is accomplished +using \*(FIstrtod\*(FR(3). +A number is converted to a string by using the value of \*(FCCONVFMT\fP +as a format string for \*(FIsprintf\*(FR(3), +with the numeric value of the variable as the argument. +However, even though all numbers in AWK are floating-point, +integral values are \*(FIalways\fP converted as integers. +.sp .5 +Comparisons are performed as follows: +If two variables are numeric, they are compared numerically. +If one value is numeric and the other has a string value that is a +``numeric string,'' then comparisons are also done numerically. +Otherwise, the numeric value is converted to a string, and a string +comparison is performed. +Two strings are compared, of course, as strings. +.sp .5 +Note that string constants, such as \*(FC"57"\fP, are \*(FInot\fP +numeric strings, they are string constants. The idea of ``numeric string'' +only applies to fields, \*(FCgetline\fP input, +\*(FCFILENAME\*(FR, \*(FCARGV\fP elements, \*(FCENVIRON\fP +elements and the elements of an array created by \*(FCsplit()\fP +\*(CBor \*(FCpatsplit()\fP\*(CD that are numeric strings. +The basic idea is that \*(FIuser input\*(FR, +and only user input, that looks numeric, +should be treated that way.\*(CD +.sp .5 +Uninitialized variables have the numeric value 0 and the string value +\*(FC"\^"\fP +(the null, or empty, string).\*(CX +.EB "\s+2\f(HBCONVERSIONS AND COMPARISONS\*(FR\s0" + +.\" --- Pattern Elements +.ES +.fi +\*(CDAWK patterns may be one of the following. +.sp .5 +.nf + \*(FCBEGIN + END + \*(CBBEGINFILE + ENDFILE\*(CD + \*(FIexpression + pat1\*(FC,\*(FIpat2\*(FR +.sp .5 +.fi +\*(FCBEGIN\fP and \*(FCEND\fP are special patterns that provide start-up +and clean-up actions respectively. They must have actions. There can +be multiple \*(FCBEGIN\fP and \*(FCEND\fP rules; they are merged and +executed as if there had just been one large rule. They may occur anywhere +in a program, including different source files. +.sp .5 +\*(CB\*(FCBEGINFILE\*(FR and \*(FCENDFILE\*(FR are special patterns that +execute before the first record of each file and after the last record +of each file, respectively. In the \*(FCBEGINFILE\*(FR rule, the \*(FCERRNO\*(FR +variable is non-null if there is a problem with the file; the code should use +\*(FCnextfile\*(FR to skip the file if desired. Otherwise \*(GK exits with +its usual fatal error. The actions for multiple +\*(FCBEGINFILE\*(FR and \*(FCENDFILE\*(FR patterns are merged.\*(CD +.sp .5 +Expression patterns can be any expression, as described +under \fHExpressions\fP. +.sp .5 +The \*(FIpat1\*(FC,\*(FIpat2\*(FR pattern +is called a \*(FIrange pattern\*(FR. +It matches all input records starting with a record that matches +\*(FIpat1\*(FR, and continuing until a record that matches +\*(FIpat2\*(FR, inclusive. +It does not combine with any other pattern expression.\*(CX +.EB "\s+2\f(HBPATTERN ELEMENTS\*(FR\s0" + +.BT + +.\" --- Action Statements +.ES +.fi +.in +.2i +.ti -.2i +\*(CD\*(FCbreak\*(FR +.br +Break out of the nearest enclosing +\*(CB\*(FCswitch\fP statement, or\*(CD +\*(FCdo\*(FR, \*(FCfor\*(FR, or \*(FCwhile\*(FR loop. +.ti -.2i +\*(FCcontinue\*(FR +.br +Skip the rest of the loop body. +Evaluate the \*(FIcondition\*(FR +part of the nearest enclosing \*(FCdo\*(FR or \*(FCwhile\*(FR loop, +or go to the \*(FIincr\*(FR part of a \*(FCfor\*(FR loop. +.ti -.2i +\*(FCdelete \*(FIarray\^\*(FC[\^\*(FIindex\^\*(FC]\*(FR +.br +Delete element \*(FIindex\*(FR from array \*(FIarray\*(FR. +.ti -.2i +\*(CL\*(FCdelete \*(FIarray\^\*(FR +.br +Delete all elements from array \*(FIarray\*(FR.\*(CD +.ti -.2i +\*(FCdo \*(FIstatement \*(FCwhile (\*(FIcondition\*(FC)\*(FR +.br +Execute \*(FIstatement\*(FR while \*(FIcondition\*(FR is true. +The \*(FIstatement\*(FR is always executed at least once. +.ti -.2i +\*(FCexit\*(FR [ \*(FIexpression\*(FR ] +.br +Terminate input record processing. +Execute the \*(FCEND\*(FR rule(s) if present. +If present, \*(FIexpression\*(FR becomes \*(AK's return value. +.ti -.2i +\*(FCfor (\*(FIinit\*(FC; \*(FIcond\*(FC; \*(FIincr\*(FC) \*(FIstatement\*(FR +.br +Execute \*(FIinit\*(FR. +Evaluate \*(FIcond\*(FR. +If it is true, execute \*(FIstatement\*(FR. +Execute \*(FIincr\*(FR before going back to the top to +re-evaluate \*(FIcond\*(FR. +Any of the three may be omitted. +A missing \*(FIcond\*(FR is considered to be true. +.ti -.2i +\*(FCfor (\*(FIvar \*(FCin\*(FI array\*(FC) \*(FIstatement\*(FR +.br +Execute \*(FIstatement\*(FR once for each subscript in \*(FIarray\*(FR, +with \*(FIvar\*(FR set to a different subscript each time through +the loop. +.ti -.2i +\*(CD\*(FCif (\*(FIcondition\*(FC) \*(FIstatement1\*(FR [ \*(FCelse\*(FI statement2\*(FR ] +.br +If \*(FIcondition\*(FR is true, execute \*(FIstatement1\*(FR, +otherwise execute \*(FIstatement2\*(FR. Each \*(FCelse\*(FR +matches the closest \*(FCif\*(FR. +.ti -.2i +\*(FCnext\*(FR See \fHInput Control.\fP +.ti -.2i +\*(CL\*(FCnextfile\*(FR See \fHInput Control.\fP\*(CD +.in -.2i +.\" --- Start switch statement +\*(CB\*(FCswitch (\*(FIexpression\*(FC) { +.br +case \*(FIconstant\*(FC|\*(FIregular expression\*(FC: \*(FIstatement(s) +.br +\*(FCdefault: \*(FIstatement(s) +.br +\*(FC}\*(FR +.in +.2i +.br +Switch on \*(FIexpression\*(FR, +execute \*(FIcase\*(FR if matched, default if not. +The \*(FCdefault\fP label and associated statements are optional.\*(CD +.ti -.2i +.\" --- End switch statement +\*(FCwhile (\*(FIcondition\*(FC) \*(FIstatement \*(FR +.br +While \*(FIcondition\*(FR is true, execute \*(FIstatement\*(FR. +.ti -.2i +\*(FC{ \*(FIstatements \*(FC}\*(FR +.br +A list of statements enclosed in braces can be used anywhere +that a single statement would otherwise be used.\*(CX +.in -.2i +.EB "\s+2\f(HBACTION STATEMENTS\*(FR\s0" + +.\" --- Escape Sequences +.ES +.fi +\*(CDWithin strings constants (\*(FC"..."\fP) and regexp +constants (\*(FC/.../\fP), escape sequences may be used to +generate otherwise unprintable characters. This table lists +the available escape sequences. +.sp .5 +.TS +center, tab(~); +lp8 lp8 lp8 lp8. +\*(FC\ea\fP~alert (bell)~\*(FC\er\fP~carriage return +\*(FC\eb\fP~backspace~\*(FC\et\fP~horizontal tab +\*(FC\ef\fP~form feed~\*(FC\ev\fP~vertical tab +\*(FC\en\fP~newline~\*(FC\e\e\fP~backslash +\*(FC\e\*(FIddd\*(FR~octal value \*(FIddd\fP~\*(CL\*(FC\ex\*(FIhh\*(FR~hex value \*(FIhh\fP\*(CD +\*(FC\e"\fP~double quote~\*(FC\e/\fP~forward slash\*(CX +.TE +.EB "\s+2\f(HBESCAPE SEQUENCES\*(FR\s0" +.BT + +.\" --- Records +.ES +.fi +\*(CDNormally, records are separated by newline characters. +Assigning values to the built-in variable \*(FCRS\*(FR +controls how records are separated. +If \*(FCRS\fP is any single character, that character separates records. +\*(CLOtherwise, \*(FCRS\fP is a regular expression. +\*(CR(Not \*(NK.)\*(CL +Text in the input that matches this +regular expression separates the record. +\*(CB\*(GK sets \*(FCRT\*(FR to the value of the +input text that matched the regular expression. +The value of \*(FCIGNORECASE\fP +also affects how records are separated when +\*(FCRS\fP is a regular expression.\*(CD +If \*(FCRS\fP is set to the null string, +then records are separated by one or more blank lines. +When \*(FCRS\fP is set to the null string, +the newline character always acts as +a field separator, in addition to whatever value +\*(FCFS\fP may have. +\*(CB\*(MK does not apply exceptional rules to \*(FCFS\fP +when \*(FCRS = "\^"\fP.\*(CX +.EB "\s+2\f(HBRECORDS\*(FR\s0" + +.\" --- Fields +.ES +.fi +\*(CDAs each input record is read, \*(AK splits the record into +\*(FIfields\*(FR, using the value of the \*(FCFS\fP +variable as the field separator. +If \*(FCFS\fP is a single character, +fields are separated by that character. +\*(CLIf \*(FCFS\fP is the null string, +then each individual character becomes a separate field.\*(CD +Otherwise, \*(FCFS\fP is expected to be a full regular expression. +In the special case that \*(FCFS\fP +is a single space, fields are separated +by runs of spaces and/or tabs +\*(CLand/or newlines\*(CD. +Leading and trailing whitespace are ignored. +\*(CBThe value of \*(FCIGNORECASE\fP +also affects how fields are split when +\*(FCFS\fP is a regular expression.\*(CD +.sp .5 +\*(CBIf the \*(FCFIELDWIDTHS\fP +variable is set to a space-separated list of numbers, each field is +expected to have a fixed width, and \*(GK +splits up the record using the specified widths. +The value of \*(FCFS\fP is ignored. +Assigning a new value to \*(FCFS\fP or \*(FCFPAT\fP +overrides the use of \*(FCFIELDWIDTHS\*(FR. +and restores the default behavior. +.sp .5 +Similarly, if the +\*(FCFPAT\fP +variable is set to a string representing a regular expression, +each field is made up of text that matches that regular expression. In +this case, the regular expression describes the fields themselves, +instead of the text that separates the fields. +Assigning a new value to +\*(FCFS\fP +or +\*(FCFIELDWIDTHS\fP +overrides the use of +\*(FCFPAT\fP.\*(CD +.sp .5 +Each field in the input record may be referenced by its position, +\*(FC$1\*(FR, \*(FC$2\*(FR and so on. +\*(FC$0\fP is the whole record. +Fields may also be assigned new values. +.sp .5 +The variable \*(FCNF\fP +is set to the total number of fields in the input record. +.sp .5 +References to non-existent fields (i.e., fields after \*(FC$NF\*(FR) +produce the null-string. However, assigning to a non-existent field +(e.g., \*(FC$(NF+2) = 5\*(FR) increases the value of +\*(FCNF\*(FR, creates any intervening fields with the null string as their value, +and causes the value of \*(FC$0\fP +to be recomputed with the fields being separated by the +value of \*(FCOFS\*(FR. +References to negative numbered fields cause a fatal error. +Decreasing the value of \*(FCNF\fP causes the trailing fields to be lost +\*(CR(not \*(NK).\*(CX +.EB "\s+2\f(HBFIELDS\*(FR\s0" + +.\" --- Historical Features +.ES +.fi +\*(CDIt is possible to call the \*(FClength()\fP +built-in function not only with no argument, but even without parentheses. +Doing so, however, is poor practice, +and \*(GK +issues a warning about its use if \*(FC\-\^\-lint\fP +is specified on the command line.\*(CB +.EB "\s+2\f(HBHISTORICAL FEATURES (\*(GK\f(HB)\*(FR\s0" +.BT + +.\" --- Regular Expressions +.ES +.fi +\*(CDRegular expressions are the extended kind originally defined by +\*(FCegrep\fP. +\*(CB\*(GK supports additional GNU operators. +A \*(FIword-constituent\fP character is a letter, digit, or +underscore (\*(FC_\fP).\*(CD +.sp .5 +.TS +center, tab(~); +cp8 sp8 +cp8 sp8 +lp8|lp8. +.\" .vs 10 +_ +Summary of Regular Expressions +In Decreasing Precedence +_ +\*(FC(\^\*(FIr\*(FC)\*(FR~regular expression (for grouping) +\*(FIc\*(FR~if non-special char, matches itself +\*(FC\e\*(FI\^c\*(FR~turn off special meaning of \*(FIc\fP +\*(FC^\*(FR~beginning of string (note: \*(FInot\fP line) +\*(FC$\*(FR~end of string (note: \*(FInot\fP line) +\*(FC.\*(FR~any single character, including newline +\*(FC[\*(FR...\*(FC]\*(FR~any one character in ... or range +\*(FC[^\*(FR...\*(FC]\*(FR~any one character not in ... or range +\*(CB\*(FC\ey\*(FR~word boundary +\*(FC\eB\*(FR~middle of a word +\*(FC\e<\*(FR~beginning of a word +\*(FC\e>\*(FR~end of a word +\*(FC\es\*(FR~any whitespace character +\*(FC\eS\*(FR~any non-whitespace character +\*(FC\ew\*(FR~any word-constituent character +\*(FC\eW\*(FR~any non-word-constituent character +\*(FC\e`\*(FR~beginning of a string +\*(FC\e'\*(FR~end of a string\*(CD +\*(FIr\*(FC*\*(FR~zero or more occurrences of \*(FIr\*(FR +\*(FIr\*(FC+\*(FR~one or more occurrences of \*(FIr\*(FR +\*(FIr\*(FC?\*(FR~zero or one occurrences of \*(FIr\*(FR +\*(FIr\*(FC{\*(FIn\*(FC,\*(FIm\*(FC}\*(FR~\*(FIn\fP to \*(FIm\fP occurrences of \*(FIr\*(FR \*(CR(POSIX: see note below)\*(CD +\*(FIr1\*(FC|\|\*(FIr2\*(FR~\*(FIr1\*(FR or \*(FIr2\*(FR +.TE +.sp .5 +.fi +\*(CRThe \*(FIr\*(FC{\*(FIn\*(FC,\*(FIm\*(FC}\*(FR notation is called an +\*(FIinterval expression\fP. POSIX mandates it for AWK regexps, but +most \*(AKs don't implement it.\*(CX +.sp .5 +\*(CDIn regular expressions, within character ranges +(\*(FC[\*(FR...\*(FC]\*(FR), +the notation \*(FC[[:\*(FIclass\*(FC:]]\*(FR defines character classes\*(CD: +.sp .5 +.TS +center, tab(~); +lp8 lp8 lp8 lp8. +\*(FCalnum\*(FR~alphanumeric~\*(FClower\*(FR~lowercase +\*(FCalpha\*(FR~alphabetic~\*(FCprint\*(FR~printable +\*(FCblank\*(FR~space or tab~\*(FCpunct\*(FR~punctuation +\*(FCcntrl\*(FR~control~\*(FCspace\*(FR~whitespace +\*(FCdigit\*(FR~decimal~\*(FCupper\*(FR~uppercase +\*(FCgraph\*(FR~non-spaces~\*(FCxdigit\*(FR~hexadecimal\*(CX +.TE +.fi +.EB "\s+2\f(HBREGULAR EXPRESSIONS\*(FR\s0" + +.\" --- Environment Variables +.ES +.fi +\*(CDThe environment variable \*(FCAWKPATH\fP specifies a search path to use +when finding source files named with the \*(FC\-f\fP +option. +The default path is +\*(FC".:/usr/local/share/awk"\*(FR. +.\" if this variable does not exist. +.\" (The actual directory may vary, +.\" depending upon how \*(GK was built and installed.) +If a file name given to the \*(FC\-f\fP option contains a ``/'' character, +no path search is performed. +.sp .5 +.PP +For socket communication, +\*(FCGAWK_SOCK_RETRIES\fP +controls the number of retries, and +\*(FCGAWK_MSEC_SLEEP\fP controls +the interval between retries. +The interval is in milliseconds. On systems that do not support +\*(FIusleep\fP(3), +the value is rounded up to an integral number of seconds. +.sp .5 +If \*(FCPOSIXLY_CORRECT\fP exists +.\" in the environment, +then \*(GK +behaves exactly as if the \*(FC\-\^\-posix\fP option had been given.\*(CB +.EB "\s+2\f(HBENVIRONMENT VARIABLES (\*(GK\f(HB)\*(FR\s0" +.BT + +.\" --- Localization +.ES +.fi +\*(CDThere are several steps involved in producing and running a localizable +\*(AK program. +.sp .5 +1. Add a \*(FCBEGIN\*(FR action to assign a value to the +\*(FCTEXTDOMAIN\*(FR variable to set the text domain for +your program. +.sp .3 +.ti +5n +\*(FCBEGIN { TEXTDOMAIN = "myprog" }\*(FR +.sp .3 +This allows \*(GK to find the \*(FC\&.mo\*(FR +file associated with your program. +Without this step, \*(GK uses the \*(FCmessages\*(FR text domain, +which probably won't work. +.sp .5 +2. Mark all strings that should be translated with leading underscores. +.sp .5 +3. Use the +\*(FCbindtextdomain()\*(FR, +\*(FCdcgettext()\*(FR, +and/or +\*(FCdcngettext()\*(FR +functions in your program, as appropriate. +.sp .5 +4. Run +.sp .3 +.ti +3n +\*(FCgawk\0\-\^\-gen\-pot\0\-f\0myprog.awk\0>\0myprog.pot\*(FR +.sp .3 +to generate a \*(FC\&.pot\*(FR +file for your program. +.sp .5 +5. Provide appropriate translations, and build and install a corresponding +\*(FC\&.mo\*(FR file. +.sp .5 +The internationalization features are described in full detail in \*(AM.\*(CB +.EB "\s+2\f(HBLOCALIZATION (\*(GK\f(HB)\*(FR\s0" + +.\" --- Special Filenames +.ES +.fi +\*(CDAll three \*(FCawk\fP implementations +recognize certain special filenames internally +when doing I/O redirection from either \*(FCprint\fP +or \*(FCprintf\fP into a file or via \*(FCgetline\fP +from a file. +These filenames +provide access to open file descriptors inherited from the +parent process. They +may also be used on the command line to name data files. +The filenames are: +.sp .5 +.TS +expand; +l lw(2i). +\*(FC"\-"\fP standard input +\*(FC/dev/stdin\fP standard input \*(CR(not \*(MK)\*(CD +\*(FC/dev/stdout\fP standard output +\*(FC/dev/stderr\fP standard error output +.TE +.sp .5 +.fi +\*(CBThe following names are specific to \*(GK. +.sp .5 +.in +.2i +.ti -.2i +\*(FC/dev/fd/\^\*(FIn\*(FR +.br +File associated with the open file descriptor \*(FIn\*(FR. +.ti -.2i +\*(FC/inet/tcp/\*(FIlport\*(FC/\*(FIrhost\*(FC/\*(FIrport\*(FR +.br +.ti -.2i +\*(FC/inet4/tcp/\*(FIlport\*(FC/\*(FIrhost\*(FC/\*(FIrport\*(FR +.br +.ti -.2i +\*(FC/inet6/tcp/\*(FIlport\*(FC/\*(FIrhost\*(FC/\*(FIrport\*(FR +.br +Files for TCP/IP connections on local port \*(FIlport\*(FR to +remote host \*(FIrhost\*(FR on remote port \*(FIrport\*(FR. +Use a port of \*(FC0\*(FR to have the system pick a port. +Use \*(FC/inet4\fP to force an IPv4 connection, +and \*(FC/inet6\fP to force an IPv6 connection. +Plain \*(FC/inet\fP uses the system default (probably IPv4). +Usable only with the \*(FC|&\*(FR two-way I/O operator. +.ti -.2i +\*(FC/inet/udp/\*(FIlport\*(FC/\*(FIrhost\*(FC/\*(FIrport\*(FR +.br +.ti -.2i +\*(FC/inet4/udp/\*(FIlport\*(FC/\*(FIrhost\*(FC/\*(FIrport\*(FR +.br +.ti -.2i +\*(FC/inet6/udp/\*(FIlport\*(FC/\*(FIrhost\*(FC/\*(FIrport\*(FR +.br +Similar, but use UDP/IP instead of TCP/IP.\*(CL +.in -.2i +.EB "\s+2\f(HBSPECIAL FILENAMES\*(FR\s0" + +.BT + +.\" --- Input Control +.ES +.fi +.TS +expand; +l lw(1.8i). +\*(FCgetline\fP T{ +Set \*(FC$0\fP from next record; +set \*(FCNF\*(FR, \*(FCNR\*(FR, \*(FCFNR\*(FR. +T} +\*(FCgetline < \*(FIfile\*(FR Set \*(FC$0\fP from next record of \*(FIfile\*(FR; set \*(FCNF\*(FR. +\*(FCgetline \*(FIv\*(FR T{ +Set \*(FIv\fP from next input record; +set \*(FCNR\*(FR, \*(FCFNR\*(FR. +T} +\*(FCgetline \*(FIv \*(FC< \*(FIfile\*(FR Set \*(FIv\fP from next record of \*(FIfile\*(FR. +\*(FIcmd \*(FC| getline\*(FR Pipe into \*(FCgetline\*(FR; set \*(FC$0\*(FR, \*(FCNF\*(FR. +\*(FIcmd \*(FC| getline \*(FIv\*(FR Pipe into \*(FCgetline\*(FR; set \*(FIv\*(FR. +\*(CB\*(FIcmd \*(FC|& getline\*(FR Co-process pipe into \*(FCgetline\*(FR; set \*(FC$0\*(FR, \*(FCNF\*(FR. +.TE +.fi +.in +.2i +.ti -.2i +\*(FIcmd \*(FC|& getline \*(FIv\*(FR +.br +Co-process pipe into \*(FCgetline\*(FR; set \*(FIv\*(FR. +.ti -.2i +\*(CD\*(FCnext\fP +.br +Stop processing the current input +record. Read next input record and +start over with the first pattern in the +program. Upon end of the input data, +execute any \*(FCEND\fP rule(s). +.br +.ti -.2i +\*(CL\*(FCnextfile\fP +.br +Stop processing the current input file. +The next input record comes from the +next input file. \*(FCFILENAME\fP \*(CBand +\*(FCARGIND\fP\*(CL are updated, \*(FCFNR\fP is reset to 1, +and processing starts over with the first +pattern in the AWK program. Upon end +of input data, execute any \*(FCEND\fP rule(s).\*(CD +.in -.2i +.sp .5 +.fi +\*(FCgetline\*(FR returns 1 on success, 0 on end of file, and \-1 on an error. +\*(CBUpon an error, \*(FCERRNO\*(FR contains a string describing +the problem.\*(CX +.EB "\s+2\f(HBINPUT CONTROL\*(FR\s0" + +.\" --- Output Control +.ES +.fi +.in +.2i +.ti -.2i +\*(CL\*(FCfflush(\*(FR[\*(FIfile\^\*(FR]\*(FC)\*(FR +.br +Flush any buffers associated +with the open output file or pipe \*(FIfile\*(FR.\*(CD +\*(CBIf no \*(FIfile\fP, then flush standard output. +If \*(FIfile\fP is null, then flush all open output files and pipes +(\*(GK and \*(NK)\*(CD. +.ti -.2i +\*(FCprint\fP +.br +Print the current record. Terminate output record +with \*(FCORS\fP. +.ti -.2i +\*(FCprint \*(FIexpr-list\*(FR +.br +Print expressions. Each expression is separated +by the value of \*(FCOFS\fP. Terminate the output record +with \*(FCORS\fP. +.ti -.2i +\*(FCprintf \*(FIfmt\*(FC, \*(FIexpr-list\*(FR +.br +Format and print (see \fHPrintf Formats\fP below). +.ti -.2i +\*(FCsystem(\*(FIcmd\*(FC)\*(FR +.br +Execute the command \*(FIcmd\*(FR, +and return the exit status +\*(CR(may not be available on non-POSIX systems)\*(CD. +.sp .5 +.in -.2i +I/O redirections may be used with both \*(FCprint\fP and \*(FCprintf\fP. +.sp .5 +.in +.2i +.ti -.2i +\*(CD\*(FCprint "hello" > \*(FIfile\*(FR +.br +Print data to \*(FIfile\fP. The first time the file is written to, it +is truncated. Subsequent commands append data. +.ti -.2i +\*(FCprint "hello" >> \*(FIfile\*(FR +.br +Append data to \*(FIfile\fP. The previous contents of \*(FIfile\*(FR are not lost. +.ti -.2i +\*(FCprint "hello" | \*(FIcmd\*(FR +.br +Print data down a pipeline to \*(FIcmd\*(FR. +.ti -.2i +\*(CB\*(FCprint "hello" |& \*(FIcmd\*(FR +.br +Print data down a pipeline to co-process \*(FIcmd\*(FR.\*(CX +.in -.2i +.EB "\s+2\f(HBOUTPUT CONTROL\*(FR\s0" + +.\" --- Closing Redirections +.ES +.fi +.in +.2i +.ti -.2i +\*(CD\*(FCclose(\*(FIfile\*(FC)\*(FR +.br +Close input or output file, pipe \*(CBor co-process.\*(CD +.ti -.2i +\*(CB\*(FCclose(\*(FIcommand\*(FC, \*(FIhow\*(FC)\*(FR +.br +Close one end of co-process pipe. +Use \*(FC"to"\*(FR for the write end, or +\*(FC"from"\*(FR for the read end.\*(CD +.in -.2i +.sp .5 +On success, \*(FCclose()\*(FR returns zero for a file, or the exit status for a process. +It returns \-1 if \*(FIfile\*(FR +was never opened, or +if there was a system problem. +\*(CB\*(FCERRNO\*(FR describes +the error.\*(CX +.EB "\s+2\f(HBCLOSING REDIRECTIONS\*(FR\s0" + +.BT + +.\" --- Printf Formats +.ES +.fi +\*(CDThe \*(FCprintf\fP statement and +\*(FCsprintf()\fP function +accept the following conversion specification formats: +.sp .5 +.nf +\*(FC%c\fP An \s-1ASCII\s+1 character +\*(FC%d\fP, \*(FC%i\fP A decimal number (the integer part) +\*(FC%e\fP A floating point number of the form + \*(FC[\-]d.dddddde[+\^\-]dd\*(FR +\*(FC%E\fP Like \*(FC%e\fP, but use \*(FCE\fP instead of \*(FCe\*(FR +\*(FC%f\fP A floating point number of the form + \*(FC[\-]ddd.dddddd\*(FR +\*(FC%F\fP Like \*(FC%f\fP, but use capital letters for infinity and + not-a-number values. +\*(FC%g\fP Use \*(FC%e\fP or \*(FC%f\fP, whichever is shorter, with + nonsignificant zeros suppressed +\*(FC%G\fP Like \*(FC%g\fP, but use \*(FC%E\fP instead of \*(FC%e\*(FR +\*(FC%o\fP An unsigned octal integer +\*(FC%u\fP An unsigned decimal integer +\*(FC%s\fP A character string +\*(FC%x\fP An unsigned hexadecimal integer +\*(FC%X\fP Like \*(FC%x\fP, but use \*(FCABCDEF\fP for 10\(en15 +\*(FC%%\fP A literal \*(FC%\fP; no argument is converted +.sp .5 +.fi +Optional, additional parameters may lie between the \*(FC%\fP +and the control letter: +.sp .5 +.TS +expand; +l lw(2.2i). +\*(CB\*(FIcount\*(FC$\*(FR T{ +Use the +\*(FIcount\*(FR'th +argument at this point in the formatting +(a \*(FIpositional specifier\*(FR). +Use in translated versions of +format strings, not in the original text of an AWK program.\*(CD +T} +\*(FC\-\fP T{ +Left-justify the expression within its field. +T} +\*(FIspace\fP T{ +For numeric conversions, prefix positive values +with a space and negative values with a +minus sign. +T} +\*(FC+\fP T{ +Use before the \*(FIwidth\fP modifier to always +supply a sign for numeric conversions, even if +the data to be formatted is positive. The \*(FC+\fP +overrides the space modifier. +T} +\*(FC#\fP T{ +Use an ``alternate form'' for some control letters: +T} + \*(FC%o\*(FR T{ +Supply a leading zero. +T} + \*(FC%x\*(FR, \*(FC%X\*(FR T{ +Supply a leading \*(FC0x\*(FR or \*(FC0X\*(FR for a nonzero result. +T} + \*(FC%e\*(FR, \*(FC%E\*(FR, \*(FC%f\*(FR T{ +The result always has a decimal point. +T} + \*(FC%g\*(FR, \*(FC%G\*(FR T{ +Trailing zeros are not removed. +T} +\*(FC0\fP T{ +Pad output with zeros instead of spaces. +This applies only to the numeric output formats. +Only has an effect when the field width is wider +than the value to be printed. +T} +\*(CB\*(FC'\*(FR T{ +Use the locale's thousands separator for \*(FC%d\fP, \*(FC%i\fP, and \*(FC%u\fP.\*(CD +T} +\*(FIwidth\fP T{ +Pad the field to this width. The field is normally +padded with spaces. If the \*(FC0\fP flag has been used, +pad with zeros. +T} +\*(FC.\*(FIprec\*(FR T{ +Precision. +The meaning of the \*(FIprec\*(FR varies by control letter: +T} + \*(FC%d\*(FR, \*(FC%o\*(FR, \*(FC%i\*(FR, + \*(FC%u\*(FR, \*(FC%x\*(FR, \*(FC%X\fP T{ +The minimum number of digits to print. +T} + \*(FC%e\*(FR, \*(FC%E\*(FR, \*(FC%f\*(FR T{ +The number of digits to print to the right of the decimal point. +T} + \*(FC%g\*(FR, \*(FC%G\fP T{ +The maximum number of significant digits. +T} + \*(FC%s\fP T{ +The maximum number of characters to print. +T} +.TE +.sp .5 +.fi +Use a +\*(FC*\fP in place of either the \*(FIwidth\fP or \*(FIprec\fP +specifications to take their values from +the \*(FCprintf\fP or \*(FCsprintf()\*(FR argument list. +\*(CBUse \*(FC*\*(FIn\*(FC$\*(FR to use positional specifiers +with a dynamic width or precision.\*(CX +.EB "\s+2\f(HBPRINTF FORMATS\*(FR\s0" + + +.BT + +.\" --- User-defined Functions +.ES +.fi +\*(CDFunctions in AWK are defined as follows: +.sp .5 +.nf + \*(FCfunction \*(FIname\*(FC(\*(FIparameter list\*(FC) + { + \*(FIstatements + \*(FC}\*(FR +.sp .5 +.fi +Functions are executed when they are called from within expressions +in either patterns or actions. Actual parameters supplied in the function +call instantiate the formal parameters declared in the function. +Arrays are passed by reference, other variables are passed by value. +.sp .5 +Local variables are declared as extra parameters +in the parameter list. The convention is to separate local variables from +real parameters by extra spaces in the parameter list. For example: +.sp .5 +.nf + \*(FC# a and b are local + function f(p, q, a, b) + { + \&..... + } +.sp .3 + /abc/ { ... ; f(1, 2) ; ... }\*(FR +.fi +.sp .5 +The left parenthesis in a function call is required +to immediately follow the function name +without any intervening whitespace. +This is to avoid a syntactic ambiguity with the concatenation operator. +This restriction does not apply to the built-in functions. +.sp .5 +Functions may call each other and may be recursive. +Function parameters used as local variables are initialized +to the null string and the number zero upon function invocation. +.sp .5 +\*(CBFunctions may be called indirectly. To do this, assign +the name of the function to be called, as a string, to a variable. +Then use the variable as if it were the name of a function, prefixed with +an ``at'' sign, like so:\*(FC +.nf +.sp .5 + function myfunc() + { + print "myfunc called" + } +.sp .3 + { + the_func = "myfunc" + @the_func() + } +.fi +.sp .5 +\*(FR\*(CDUse \*(FCreturn\fP to return a value from a function. The return value +is undefined if no value is provided, or if the function returns by +``falling off'' the end. +.sp .5 +\*(CLThe word +\*(FCfunc\fP +may be used in place of +\*(FCfunction\*(FR. +\*(CRThis usage is deprecated.\*(CX +.EB "\s+2\f(HBUSER-DEFINED FUNCTIONS\*(FR\s0" +.sp .6 +.\" --- Built-in Numeric Functions +.ES +.fi +.TS +expand; +l lw(2i). +\*(CD\*(FCatan2(\*(FIy\*(FC, \*(FIx\*(FC)\*(FR The arctangent of \*(FIy/x\fP in radians. +\*(FCcos(\*(FIexpr\*(FC)\*(FR The cosine of \*(FIexpr\fP, which is in radians. +\*(FCexp(\*(FIexpr\*(FC)\*(FR The exponential function (\*(FIe \*(FC^ \*(FIx\*(FR). +\*(FCint(\*(FIexpr\*(FC)\*(FR Truncate to integer. +\*(FClog(\*(FIexpr\*(FC)\*(FR The natural logarithm function (base \*(FIe\^\*(FR). +\*(FCrand()\fP A random number between 0 and 1 (0 \(<= \*(FIN\fP < 1). +\*(FCsin(\*(FIexpr\*(FC)\*(FR The sine of \*(FIexpr\fP, which is in radians. +\*(FCsqrt(\*(FIexpr\*(FC)\*(FR The square root function. +\&\*(FCsrand(\*(FR[\*(FIexpr\^\*(FR]\*(FC)\*(FR T{ +Use \*(FIexpr\fP as the new seed for the random number +generator. If no \*(FIexpr\fP, the time of day is used. +Return the random number +generator's previous seed.\*(CX +T} +.TE +.EB "\s+2\f(HBNUMERIC FUNCTIONS\*(FR\s0" +.BT + +.\" --- Built-in String Functions +.ES +.fi +.in +.2i +.ti -.2i +\*(CB\*(FCasort(\*(FIs \*(FR[\*(FC,\*(FI d \*(FR[\*(FC,\*(FI comp\*(FR]]\*(FC)\*(FR +.br +Sort the source array \*(FIs\*(FR, replacing the indices with numeric +values 1 through \*(FIn\*(FR (the number of elements in the array), +and return the number of elements. +If destination \*(FId\*(FR is supplied, copy \*(FIs\*(FR to \*(FId\*(FR, +sort \*(FId\*(FR, and leave \*(FIs\*(FR unchanged. +Use \*(FIcomp\*(FR to compare indices and elements.\*(CD +.ti -.2i +\*(CB\*(FCasorti(\*(FIs \*(FR[\*(FC,\*(FI d \*(FR[\*(FC,\*(FI comp\*(FR]]\*(FC)\*(FR +.br +Like \*(FCasort()\*(FR, but sort on the indices, not +the values. The original values are thrown array, so provide a +second array to preserve the first.\*(CD +.ti -.2i +\*(CB\*(FCgensub(\*(FIr\*(FC, \*(FIs\*(FC, \*(FIh \*(FR[\*(FC, \*(FIt\*(FR]\*(FC)\*(FR +.br +Search the target string +\*(FIt\fP for matches of the regular expression \*(FIr\*(FR. If +\*(FIh\fP is a string beginning with \*(FCg\fP or \*(FCG\*(FR, +replace all matches of \*(FIr\fP with \*(FIs\*(FR. Otherwise, \*(FIh\fP +is a number indicating which match of \*(FIr\fP to replace. +If \*(FIt\fP is not supplied, use \*(FC$0\fP instead. Within the +replacement text \*(FIs\*(FR, the sequence \*(FC\e\*(FIn\*(FR, +where \*(FIn\fP is a digit from 1 to 9, may be used to indicate just +the text that matched the \*(FIn\*(FRth parenthesized subexpression. +The sequence \*(FC\e0\fP represents the entire matched text, as does +the character \*(FC&\*(FR. Unlike \*(FCsub()\fP and \*(FCgsub()\*(FR, +the modified string is returned as the result of the function, +and the original target string is \*(FInot\fP changed.\*(CD +.ti -.2i +\*(FCgsub(\*(FIr\*(FC, \*(FIs \*(FR[\*(FC, \*(FIt\*(FR]\*(FC)\*(FR +.br +For each substring matching the +regular expression \*(FIr\fP in the string \*(FIt\*(FR, substitute the +string \*(FIs\*(FR, and return the number of substitutions. If +\*(FIt\fP is not supplied, use \*(FC$0\*(FR. An \*(FC&\fP in the +replacement text is replaced with the text that was actually matched. +Use \*(FC\e&\fP to get a literal \*(FC&\*(FR. See \*(AM +for a fuller discussion of the rules for \*(FC&\*(FR's and backslashes +in the replacement text of \*(CB\*(FCgensub()\*(FR,\*(CD \*(FCsub()\*(FR +and \*(FCgsub()\*(FR +.ti -.2i +\*(FCindex(\*(FIs\*(FC, \*(FIt\*(FC)\*(FR +.br +Return the index of the string +\*(FIt\fP in the string \*(FIs\*(FR, or 0 if \*(FIt\fP is not present. +.ti -.2i +\*(FClength(\*(FR[\*(FIs\*(FR]\*(FC)\*(FR +.br +Return the length of the string +\*(FIs\*(FR, or the length of \*(FC$0\fP if \*(FIs\fP is not supplied. +\*(CLWith an array argument, return the number of elements +in the array.\*(CD +.ti -.2i +\*(FCmatch(\*(FIs\*(FC, \*(FIr \*(CB\*(FR[\*(FC, \*(FIa\*(FR]\*(CD\*(FC)\*(FR +.br +Return the position in +\*(FIs\fP where the regular expression \*(FIr\fP occurs, or 0 if +\*(FIr\fP is not present, and set the values of variables +\*(FCRSTART\fP +and \*(FCRLENGTH\*(FR. +\*(CBIf \*(FIa\*(FR is supplied, the text matching all of \*(FIr\*(FR +is placed in \*(FIa\*(FC[0]\*(FR. If there were parenthesized +subexpressions, the matching texts are placed +in \*(FIa\*(FC[1]\*(FR, \*(FIa\*(FC[2]\*(FR, and so on. +Subscripts +\*(FCa[\*(FIn\^\*(FC, "start"]\*(FR, +and +\*(FCa[\*(FIn\^\*(FC, "length"]\*(FR +provide the starting index in the string and length +respectively, of each matching substring.\*(CD +.ti -.2i +\*(CB\*(FCpatsplit(\*(FIs\*(FC, \*(FIa \*(FR[\*(FC, \*(FIr \*(CB\*(FR[\*(FC, \*(FIseps \*(FR] \*(FR] \*(FC)\*(FR +.br +Split the string +\*(FIs\fP into the array \*(FIa\fP +and the array \*(FIseps\fP of separator strings +using the regular expression \*(FIr\*(FR, +and return the number of fields. +Element values are the portions of \*(FIs\fP that matched \*(FIr\fP. +The value of \*(FIseps\fP[\*(FIi\fP] is the separator that appeared in +front of \*(FIa\fP[\*(FIi\fP+1]. +If \*(FIr\fP is omitted, use \*(FCFPAT\fP instead. +Clear the arrays \*(FIa\fP and \*(FIseps\fP first. +Splitting behaves identically to field splitting with \*(FCFPAT\fP.\*(CD +.ti -.2i +\*(FCsplit(\*(FIs\*(FC, \*(FIa \*(FR[\*(FC, \*(FIr \*(CB\*(FR[\*(FC, \*(FIseps \*(FR]\*(CD \*(FR] \*(FC)\*(FR +.br +Split the string +\*(FIs\fP into the array \*(FIa\fP \*(CBand the array \*(FIseps\fP of separator strings\*(CD +using the regular expression \*(FIr\*(FR, +and return the number of fields. If \*(FIr\fP is omitted, use \*(FCFS\fP +instead. +Clear the \*(FIa\fP \*(CBand \*(FIseps\fP\*(CD first. +Splitting behaves identically to field splitting. +(See \fHFields\fP, above.) +.ti -.2i +\*(FCsprintf(\*(FIfmt\*(FC, \*(FIexpr-list\*(FC)\*(FR +.br +Print \*(FIexpr-list\fP +according to \*(FIfmt\*(FR, and return the result.\*(CX +.in -.2i +.EB "\s+2\f(HBSTRING FUNCTIONS\*(FR\s0" + +.BT + +.\" --- Built-in String Functions +.ES +.fi +.in +.2i +.ti -.2i +\*(CB\*(FCstrtonum(\*(FIs\*(FC)\*(FR +.br +Examine \*(FIs\*(FR, and return its numeric value. +If \*(FIs\*(FR begins with a leading \*(FC0\*(FR, +\*(FCstrtonum()\*(FR assumes that \*(FIs\*(FR +is an octal number. +If \*(FIs\*(FR begins with a leading \*(FC0x\*(FR +or \*(FC0X\*(FR, \*(FCstrtonum()\*(FR assumes that +\*(FIs\*(FR is a hexadecimal number. Otherwise, the +number is treated as decimal.\*(CD +.ti -.2i +\*(FCsub(\*(FIr\*(FC, \*(FIs \*(FR[\*(FC, \*(FIt\*(FR]\*(FC)\*(FR +.br +Just like +\*(FCgsub()\*(FR, but replace only the first matching substring.\*(CX +.ti -.2i +\*(CD\*(FCsubstr(\*(FIs\*(FC, \*(FIi \*(FR[\*(FC, \*(FIn\*(FR]\*(FC)\*(FR +.br +Return the at most +\*(FIn\*(FR-character substring of \*(FIs\fP starting at \*(FIi\*(FR. +If \*(FIn\fP is omitted, use the rest of \*(FIs\fP. +.ti -.2i +\*(FCtolower(\*(FIstr\*(FC)\*(FR +.br +Return a copy of the string \*(FIstr\*(FR, +with all the uppercase characters in \*(FIstr\fP translated to their +corresponding lowercase counterparts. Non-alphabetic characters are +left unchanged. +.ti -.2i +\*(FCtoupper(\*(FIstr\*(FC)\*(FR +.br +Return a copy of the string \*(FIstr\*(FR, +with all the lowercase characters in \*(FIstr\fP translated to their +corresponding uppercase counterparts. Non-alphabetic characters are +left unchanged.\*(CX +.in -.2i +.EB "\s+2\f(HBSTRING FUNCTIONS (continued)\*(FR\s0" +.sp .6 +.\" --- Built-in Time Functions +.ES +.fi +\*(CD\*(GK +provides the following functions for obtaining time stamps and +formatting them. +.sp .5 +.fi +.in +.2i +.ti -.2i +\*(FCmktime(\*(FIdatespec\*(FC)\*(FR +.br +Convert \*(FIdatespec\fP into a time +stamp of the same form as returned by \*(FCsystime()\*(FR +and return it. +The \*(FIdatespec\fP is a string of the form +\*(FC"\*(FIYYYY MM DD HH MM SS[ DST]\*(FC"\*(FR. +.ti -.2i +\*(FCstrftime(\*(FR[\*(FIformat \*(FR[\*(FC, \*(FItimestamp\*(FR[\*(FC, \*(FIutc-flag\*(FR]]]\*(FC)\*(FR +.br +Format \*(FItimestamp\fP +according to the specification in \*(FIformat\*(FR. The +\*(FItimestamp\fP should be of the same form as returned by +\*(FCsystime()\*(FR. +If \*(FIutc-flag\*(FR +is present and is non-zero or non-null, the result +is in UTC, otherwise the result is in local time. +If \*(FItimestamp\fP is missing, the current time of day is used. If +\*(FIformat\fP is missing, use \*(FCPROCINFO["strftime"]\fP. +The default value is +equivalent to the output +of \*(FIdate\*(FR(1). +.ti -.2i +\*(FCsystime()\fP +.br +Return the current time of day as the number of +seconds since the Epoch.\*(CB +.in -.2i +.EB "\s+2\f(HBTIME FUNCTIONS (\*(GK\f(HB)\*(FR\s0" +.sp .6 +.\" --- Built-in Bit Manipulation Functions +.ES +.fi +\*(CD\*(GK +provides the following functions for doing bitwise operations. +.sp .5 +.fi +.in +.2i +.ti -.2i +\*(FCand(\*(FIv1\*(FC, \*(FIv2\*(FC)\*(FR +.br +Return the bitwise AND of the values provided by +\*(FIv1\*(FR and \*(FIv2\*(FR. +.ti -.2i +\*(FCcompl(\*(FIval\*(FC)\*(FR +.br +Return the bitwise complement of +\*(FIval\*(FR. +.ti -.2i +\*(FClshift(\*(FIval\*(FC, \*(FIcount\*(FC)\*(FR +.br +Return the value of \*(FIval\*(FR, +shifted left by \*(FIcount\*(FR bits. +.ti -.2i +\*(FCor(\*(FIv1\*(FC, \*(FIv2\*(FC)\*(FR +.br +Return the bitwise OR of the values provided by +\*(FIv1\*(FR and \*(FIv2\*(FR. +.ti -.2i +\*(FCrshift(\*(FIval\*(FC, \*(FIcount\*(FC)\*(FR +.br +Return the value of \*(FIval\*(FR, +shifted right by \*(FIcount\*(FR bits. +.ti -.2i +\*(FCxor(\*(FIv1\*(FC, \*(FIv2\*(FC)\*(FR +.br +Return the bitwise XOR of the values provided by +\*(FIv1\*(FR and \*(FIv2\*(FR.\*(CB +.in -.2i +.EB "\s+2\f(HBBIT MANIPULATION FUNCTIONS (\*(GK\f(HB)\*(FR\s0" +.sp .6 +.\" --- Extensions +.ES +.fi +.in +.2i +.ti -.2i +\*(CD\*(FCextension(\*(FIlib\*(FC, \*(FIfunc\*(FC)\*(FR +.br +Dynamically load the shared library +\*(FIlib\*(FR +and call +\*(FIfunc\*(FR +in it to initialize the library. +This adds new built-in functions to \*(GK. +It returns the value returned by +\*(FIfunc\*(FR.\*(CB +.in -.2i +.EB "\s+2\f(HBDYNAMIC EXTENSIONS (\*(GK\f(HB)\*(FR\s0" +.BT + +.\" --- Type Functions +.ES +.fi +.in +.2i +.ti -.2i +\*(CD\*(FCisarray(\*(FIx\*(FC)\*(FR +.br +Return true if \*(FIx\fP is an array, false otherwise.\*(CB +.in -.2i +.EB "\s+2\f(HBTYPE FUNCTIONS (\*(GK\f(HB)\*(FR\s0" +.sp .5 +.\" --- Built-in Internationalization Functions +.ES +.fi +\*(CD\*(GK +provides the following functions for runtime message translation. +.in +.2i +.sp .5 +.ti -.2i +\*(FCbindtextdomain(\*(FIdirectory \*(FR[\*(FC, \*(FIdomain\*(FR]\*(FC)\*(FR +.br +Specify the directory where \*(GK looks for the \*(FC\&.mo\*(FR +files, in case they +will not or cannot be placed in the ``standard'' locations +(e.g., during testing). +Return the directory where \*(FIdomain\*(FR is ``bound.'' +.sp .5 +The default \*(FIdomain\*(FR is the value of \*(FCTEXTDOMAIN\*(FR. +When \*(FIdirectory\*(FR is the null string (\*(FC"\^"\*(FR), +\*(FCbindtextdomain()\*(FR returns the current binding for the +given \*(FIdomain\*(FR. +.ti -.2i +\*(FCdcgettext(\*(FIstring \*(FR[\*(FC, \*(FIdomain \*(FR[\*(FC, \*(FIcategory\*(FR]]\*(FC)\*(FR +.br +Return the translation of \*(FIstring\*(FR in text domain +\*(FIdomain\*(FR for locale category \*(FIcategory\*(FR. +The default value for \*(FIdomain\*(FR is the current value of \*(FCTEXTDOMAIN\*(FR. +The default value for \*(FIcategory\*(FR is \*(FC"LC_MESSAGES"\*(FR. +.sp .5 +If you supply a value for \*(FIcategory\*(FR, it must be a string equal to +one of the known locale categories. +You must also supply a text domain. Use \*(FCTEXTDOMAIN\*(FR +to use the current domain. +.ti -.2i +\*(FCdcngettext(\*(FIstring1\*(FC, \*(FIstring2\*(FC, \*(FInumber\*(FR [\*(FC, \*(FIdom \*(FR[\*(FC, \*(FIcat\*(FR]]\*(FC)\*(FR +.br +Return the plural form used for \*(FInumber\*(FR of the translation of +\*(FIstring1\*(FR and \*(FIstring2\*(FR in text domain +\*(FIdom\*(FR for locale category \*(FIcat\*(FR. +The default value for \*(FIdom\*(FR is the current value of \*(FCTEXTDOMAIN\*(FR. +The default for \*(FC"LC_MESSAGES"\*(FR +is \*(FIcat\*(FR. +.sp .5 +If you supply a value for \*(FIcat\*(FR, it must be a string equal to +one of the known locale categories. +You must also supply a text domain. Use \*(FCTEXTDOMAIN\*(FR +to use the current domain.\*(CB +.in -.2i +.EB "\s+2\f(HBINTERNATIONALIZATION (\*(GK\f(HB)\*(FR\s0" +.sp .5 +.\" --- FTP/HTTP Information +.ES +.nf +\*(CDHost: \*(FCftp.gnu.org\*(FR +File: \*(FC/gnu/gawk/gawk-4.0.1.tar.gz\fP +.in +.2i +.fi +GNU \*(AK (\*(GK). There may be a later version. +.in -.2i +.nf +.sp .4 +\*(FChttp://www.cs.princeton.edu/~bwk/btl.mirror/ +awk.tar.gz\fP +.in +.2i +.fi +\*(NK. This version requires an ANSI C compiler; +GCC (the GNU Compiler Collection) works well. +.in -.2i +.nf +.sp .4 +... Host: \*(FCftp.whidbey.net\*(FR +... File: \*(FC/pub/brennan/mawk1.3.3.tar.gz\fP +... \*(FChttp://www.skeeve.com/gawk/mawk1.3.3.tar.gz\fP +Host: \*(FCinvisible-island.net\*(FR +File: \*(FC/mawk/mawk.tar.gz\fP +.in +.2i +.fi +Michael Brennan's \*(MK. Thomas Dickey now +maintains it.\*(CX +.in -.2i +.EB "\s+2\f(HBFTP/HTTP INFORMATION\*(FR\s0" +.sp .5 +.\" --- Copying Permissions +.ES +.fi +\*(CDCopyright \(co 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +2007, 2009, 2010, 2011 Free Software Foundation, Inc. +.sp .5 +Permission is granted to make and distribute verbatim copies of this +reference card provided the copyright notice and this permission notice +are preserved on all copies. +.sp .5 +Permission is granted to copy and distribute modified versions of this +reference card under the conditions for verbatim copying, provided that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. +.sp .5 +Permission is granted to copy and distribute translations of this +reference card into another language, under the above conditions for +modified versions, except that this permission notice may be stated in a +translation approved by the Foundation.\*(CX +.EB "\s+2\f(HBCOPYING PERMISSIONS\*(FR\s0" +.\" Need the BT here to get the final page number + +.ig +.ES +\*(CX +.sp 10 +.EB "\s+2\f(HBNOTES\*(FR\s0" +.. + +.BT diff --git a/doc/awkforai.txt b/doc/awkforai.txt new file mode 100644 index 0000000..3fca320 --- /dev/null +++ b/doc/awkforai.txt @@ -0,0 +1,150 @@ +Draft for ACM SIGPLAN Patterns (Language Trends) + +1996 + +Why GAWK for AI? + +Ronald P. Loui + +Most people are surprised when I tell them what language we use in our +undergraduate AI programming class. That's understandable. We use +GAWK. GAWK, Gnu's version of Aho, Weinberger, and Kernighan's old +pattern scanning language isn't even viewed as a programming language by +most people. Like PERL and TCL, most prefer to view it as a "scripting +language." It has no objects; it is not functional; it does no built-in +logic programming. Their surprise turns to puzzlement when I confide +that (a) while the students are allowed to use any language they want; +(b) with a single exception, the best work consistently results from +those working in GAWK. (footnote: The exception was a PASCAL +programmer who is now an NSF graduate fellow getting a Ph.D. in +mathematics at Harvard.) Programmers in C, C++, and LISP haven't even +been close (we have not seen work in PROLOG or JAVA). + +Why GAWK? + +There are some quick answers that have to do with the pragmatics of +undergraduate programming. Then there are more instructive answers that +might be valuable to those who debate programming paradigms or to those +who study the history of AI languages. And there are some deep +philosophical answers that expose the nature of reasoning and symbolic +AI. I think the answers, especially the last ones, can be even more +surprising than the observed effectiveness of GAWK for AI. + +First it must be confessed that PERL programmers can cobble together AI +projects well, too. Most of GAWK's attractiveness is reproduced in +PERL, and the success of PERL forebodes some of the success of GAWK. +Both are powerful string-processing languages that allow the programmer +to exploit many of the features of a UNIX environment. Both provide +powerful constructions for manipulating a wide variety of data in +reasonably efficient ways. Both are interpreted, which can reduce +development time. Both have short learning curves. The GAWK manual can +be consumed in a single lab session and the language can be mastered by +the next morning by the average student. GAWK's automatic +initialization, implicit coercion, I/O support and lack of pointers +forgive many of the mistakes that young programmers are likely to make. +Those who have seen C but not mastered it are happy to see that GAWK +retains some of the same sensibilities while adding what must be +regarded as spoonsful of syntactic sugar. Some will argue that +PERL has superior functionality, but for quick AI applications, the +additional functionality is rarely missed. In fact, PERL's terse syntax +is not friendly when regular expressions begin to proliferate and +strings contain fragments of HTML, WWW addresses, or shell commands. +PERL provides new ways of doing things, but not necessarily ways of +doing new things. + +In the end, despite minor difference, both PERL and GAWK minimize +programmer time. Neither really provides the programmer the setting in +which to worry about minimizing run-time. + +There are further simple answers. Probably the best is the fact that +increasingly, undergraduate AI programming is involving the Web. Oren +Etzioni (University of Washington, Seattle) has for a while been arguing +that the "softbot" is replacing the mechanical engineers' robot as the +most glamorous AI testbed. If the artifact whose behavior needs to be +controlled in an intelligent way is the software agent, then a language +that is well-suited to controlling the software environment is the +appropriate language. That would imply a scripting language. If the +robot is KAREL, then the right language is "turn left; turn right." If +the robot is Netscape, then the right language is something that can +generate "netscape -remote 'openURL(http://cs.wustl.edu/~loui)'" with +elan. + +Of course, there are deeper answers. Jon Bentley found two pearls in +GAWK: its regular expressions and its associative arrays. GAWK asks +the programmer to use the file system for data organization and the +operating system for debugging tools and subroutine libraries. There is +no issue of user-interface. This forces the programmer to return to the +question of what the program does, not how it looks. There is no time +spent programming a binsort when the data can be shipped to /bin/sort +in no time. (footnote: I am reminded of my IBM colleague Ben Grosof's +advice for Palo Alto: Don't worry about whether it's highway 101 or 280. +Don't worry if you have to head south for an entrance to go north. Just +get on the highway as quickly as possible.) + +There are some similarities between GAWK and LISP that are illuminating. +Both provided a powerful uniform data structure (the associative array +implemented as a hash table for GAWK and the S-expression, or list of +lists, for LISP). Both were well-supported in their environments (GAWK +being a child of UNIX, and LISP being the heart of lisp machines). Both +have trivial syntax and find their power in the programmer's willingness +to use the simple blocks to build a complex approach. + +Deeper still, is the nature of AI programming. AI is about +functionality and exploratory programming. It is about bottom-up design +and the building of ambitions as greater behaviors can be demonstrated. +Woe be to the top-down AI programmer who finds that the bottom-level +refinements, "this subroutine parses the sentence," cannot actually be +implemented. Woe be to the programmer who perfects the data structures +for that heapsort when the whole approach to the high-level problem +needs to be rethought, and the code is sent to the junkheap the next day. + +AI programming requires high-level thinking. There have always been a few +gifted programmers who can write high-level programs in assembly language. +Most however need the ambient abstraction to have a higher floor. + +Now for the surprising philosophical answers. First, AI has discovered +that brute-force combinatorics, as an approach to generating intelligent +behavior, does not often provide the solution. Chess, neural nets, and +genetic programming show the limits of brute computation. The +alternative is clever program organization. (footnote: One might add +that the former are the AI approaches that work, but that is easily +dismissed: those are the AI approaches that work in general, precisely +because cleverness is problem-specific.) So AI programmers always want +to maximize the content of their program, not optimize the efficiency +of an approach. They want minds, not insects. Instead of enumerating +large search spaces, they define ways of reducing search, ways of +bringing different knowledge to the task. A language that maximizes +what the programmer can attempt rather than one that provides tremendous +control over how to attempt it, will be the AI choice in the end. + +Second, inference is merely the expansion of notation. No matter whether +the logic that underlies an AI program is fuzzy, probabilistic, deontic, +defeasible, or deductive, the logic merely defines how strings can be +transformed into other strings. A language that provides the best +support for string processing in the end provides the best support for +logic, for the exploration of various logics, and for most forms of +symbolic processing that AI might choose to call "reasoning" instead of +"logic." The implication is that PROLOG, which saves the AI programmer +from having to write a unifier, saves perhaps two dozen lines of GAWK +code at the expense of strongly biasing the logic and representational +expressiveness of any approach. + +I view these last two points as news not only to the programming language +community, but also to much of the AI community that has not reflected on +the past decade's lessons. + +In the puny language, GAWK, which Aho, Weinberger, and Kernighan thought +not much more important than grep or sed, I find lessons in AI's trends, +AI's history, and the foundations of AI. What I have found not only +surprising but also hopeful, is that when I have approached the AI +people who still enjoy programming, some of them are not the least bit +surprised. + + +R. Loui (loui@ai.wustl.edu) is Associate Professor of Computer Science, +at Washington University in St. Louis. He has published in AI Journal, +Computational Intelligence, ACM SIGART, AI Magazine, AI and Law, the ACM +Computing Surveys Symposium on AI, Cognitive Science, Minds and +Machines, Journal of Philosophy, and is on this year's program +committees for AAAI (National AI conference) and KR (Knowledge +Representation and Reasoning). diff --git a/doc/bc_notes b/doc/bc_notes new file mode 100644 index 0000000..b548cec --- /dev/null +++ b/doc/bc_notes @@ -0,0 +1,323 @@ +Op Codes +======== + Op_illegal, /* illegal entry == 0 */ + + /* binary operators */ + Op_times, + Op_times_i, all _i operators here are used to optimise arithmetic + Op_quotient, by converting push, push , op to just push, op_i + Op_quotient_i, + Op_mod, + Op_mod_i, + Op_plus, + Op_plus_i, + Op_minus, + Op_minus_i, + Op_exp, + Op_exp_i, + Op_concat, + + /* line range instruction pairs */ + Op_line_range, /* flags for Op_cond_pair */ + Op_cond_pair, /* conditional pair */ + + Op_subscript, calculate array subscript + + /* unary operators */ + Op_preincrement, + Op_predecrement, + Op_postincrement, + Op_postdecrement, + Op_unary_minus, + Op_field_spec, usage: push #, field_spec -> $# + + /* unary relationals */ + Op_not, + + /* assignments */ + Op_assign, simple assign + Op_assign_times, *= etc + Op_assign_quotient, + Op_assign_mod, + Op_assign_plus, + Op_assign_minus, + Op_assign_exp, + Op_assign_concat, optimised concatenation + + /* boolean binaries */ + Op_and, /* a left subexpression in && */ + Op_and_final, /* right subexpression of && */ + Op_or, + Op_or_final, + + /* binary relationals */ + Op_equal, + Op_notequal, + Op_less, + Op_greater, + Op_leq, + Op_geq, + Op_match, + Op_match_rec, /* match $0 */ + Op_nomatch, + + Op_rule, + + /* keywords */ + Op_K_case, + Op_K_default, + Op_K_break, + Op_K_continue, + Op_K_print, + Op_K_print_rec, + Op_K_printf, + Op_K_next, + Op_K_exit, + Op_K_return, + Op_K_delete, + Op_K_delete_loop, + Op_K_getline, + Op_K_nextfile, + + Op_builtin, + Op_in_array, /* boolean test of membership in array */ + + /* function call instruction pairs */ + Op_func_call, + + Op_push, /* variable */ + Op_push_i, /* number, string */ + Op_push_re, /* regex */ + Op_push_array, + Op_push_param, + Op_push_lhs, var assignment + Op_subscript_lhs, array assignment + Op_field_spec_lhs, field assignment + Op_no_op, /* jump target */ + Op_pop, /* pop an item from the runtime stack */ + Op_jmp, + Op_jmp_true, + Op_jmp_false, + Op_push_loop, /* break (continue) target for loop */ + Op_pop_loop, end of loop + Op_get_record, read next input line + Op_newfile, open next input file + Op_arrayfor_init, initialise array for loop + Op_arrayfor_incr, next in array for loop + Op_arrayfor_final, end of array loop + + Op_var_update, /* update value of NR, NF or FNR */ + Op_var_assign, + Op_field_assign, + + Op_ext_func, + Op_func, + + Op_exec_count, debugging etc + Op_breakpoint, + Op_lint, + Op_exit, /* end of instructions, contains final exit value */ + + /*--------- end proper opcodes -------*/ + + /* program structures */ + Op_K_do, + Op_K_for, + Op_K_arrayfor, + Op_K_while, + Op_K_switch, + Op_K_if, + Op_K_else, + Op_K_function, + Op_cond_exp, + Op_list, + Op_case_list, + + /* I/O redirection for print statements */ + Op_redirect_output, + Op_redirect_append, + Op_redirect_pipe, + Op_redirect_pipein, + Op_redirect_input, + Op_redirect_twoway, + + Op_final /* sentry value, not legal */ + + +INSTRUCTIONs +============ + +typedef struct exp_instruction { + struct exp_instruction *nexti; + union { + NODE *dn; + struct exp_instruction *di; + NODE *(*fptr) P((int)); + long dl; + char *name; + } d; + + union { + long xl; + NODE *xn; + void (*aptr) P((void)); + struct exp_instruction *xi; + struct break_point *bpt; + } x; + + short source_line; + OPCODE opcode; +} INSTRUCTION; + +#define lextok d.name +#define func_name d.name + +#define memory d.dn +#define builtin d.fptr +#define builtin_idx d.dl + +#define expr_count x.xl + +#define target_continue d.di +#define target_jmp d.di +#define target_break x.xi + +/* Op_rule */ +#define in_rule x.xl +#define source_file d.name + +/* Op_K_case, Op_K_default */ +#define target_stmt x.xi + +/* Op_case_list, Op_K_switch */ +#define case_val d.di +#define case_stmt x.xi +#define switch_dflt x.xi +#define switch_body d.di /* pretty printing and profiling */ + +/* Op_K_exit */ +#define target_exit x.xi + +/* Op_exit */ +#define exit_value d.dl + +/* Op_K_getline */ +#define into_var x.xl + +/* Op_K_getline, Op_K_print, Op_K_print_rec, Op_K_printf */ +#define redir_type d.dl + +/* Op_arrayfor_incr */ +#define array_var x.xn + +/* Op_line_range */ +#define triggered x.xl + +/* Op_cond_pair */ +#define line_range x.xi + +/* Op_func_call, Op_func */ +#define func_body x.xn + +/* Op_subscript */ +#define sub_count d.dl + +/* Op_push_lhs, Op_subscript_lhs, Op_field_spec_lhs */ +#define do_reference x.xl + +/* Op_list, Op_rule, Op_func */ +#define lasti d.di +#define firsti x.xi + +/* Op_rule, Op_func */ +#define last_line x.xl +#define first_line source_line + +/* Op_lint */ +#define lint_type d.dl + +/* Op_field_spec_lhs */ +#define target_assign d.di + +/* Op_field_assign */ +#define field_assign x.aptr + +/* Op_concat */ +#define var_concat d.dl + +/* Op_breakpoint */ +#define break_pt x.bpt + +/*------------------ pretty printing/profiling --------*/ + +/* Op_exec_count */ +#define exec_count d.dl + +/* Op_K_while */ +#define while_body d.di + +/* Op_K_do */ +#define doloop_cond d.di + +/* Op_K_for */ +#define forloop_cond d.di +#define forloop_body x.xi + +/* Op_K_if */ +#define branch_if d.di +#define branch_else x.xi + +/* Op_K_else */ +#define branch_end x.xi + +/* Op_line_range */ +#define condpair_left d.di +#define condpair_right x.xi + +Programs consist of a list of INSTRUCTIONs linked by nexti pointers. +Each source statement generates a list of INSTRUCTIONs which are then in turn linked to create the program list. + +The list for a given source statement is delimited by the lasti (last INSTRUCTION) pointer. +(The first INSTRUCTION in any rule is identified by the firsti pointer. This is only used in profiling (I think).) + +Each INSTRUCTION can be linked to a NODE via the d.dn (memory) pointer. + +The BEGIN rule(s) are prepended to the program list and the END rule(s) are appended to complete the program build process. + +At run-time, the "virtual machine" walks the program list using the nexti pointers. + +The list_xxx functions are used to create and manipulate these INSTRUCTION lists. + +list_create creates an INSTRUCTION with opcode Op_list and nexti and lasti pointers pointing to itself (an empty list). + +list_append adds a single INSTRUCTION to the end of an existing list and list_prepend does the same at the start of an existing list. +list_merge adds one list to the end of another (and frees the "header" INSTRUCTION of the added list); + +The list_append, list_prepend and list_merge functions reset the nexti and lasti pointers as needed. + + + +Run-time Stack +============== + +Stack is allocated in eval.c line 1040 with an initial 256 (NODE) entries. +If this stack fills, additional blocks of 256 entries are added. + +The various push operators add NODE entries to the stack for processing by subsequent operators. +Once a stack variable is used and no longer required, it is popped off and (if temporary) freed. +Current stack position is in stack_ptr. + +Most operators (eg builtin functions) expect all of their "arguments" to be on the stack. +Some operators (eg Op_plus_i etc) expect one operand on the stack and another in the NODE linked to the +operator via the d.dn (memory) pointer. + + +Debugger +======== +The dgawk debugger usage is described in README.DGAWK. I suggest that we make -DBCDEBUG a default setting (or remove the ifdefs) +so that the dump and trace commands are always available. + +dgawk operates in exactly the same way as gawk except that it offers the ability to dump the program list, to step through the program list, to set breakpoints and to view variables etc. + +dgawk uses exactly the same "virtual machine" as gawk so the results are identical. The only difference is that dgawk checks to see if any debug action is required before executing each INSTRUCTION. + diff --git a/doc/cardfonts b/doc/cardfonts new file mode 100644 index 0000000..0f528e1 --- /dev/null +++ b/doc/cardfonts @@ -0,0 +1,37 @@ +.\" AWK Reference Card --- Arnold Robbins, arnold@skeeve.com +.\" cardfonts --- this file sets the fonts to use for the reference card +.\" +.\" Copyright (C) 1996 Free Software Foundation, Inc. +.\" +.\" Permission is granted to make and distribute verbatim copies of +.\" this reference card provided the copyright notice and this permission +.\" notice are preserved on all copies. +.\" +.\" Permission is granted to process this file through troff and print the +.\" results, provided the printed document carries copying permission +.\" notice identical to this one except for the removal of this paragraph +.\" (this paragraph not being relevant to the printed reference card). +.\" +.\" Permission is granted to copy and distribute modified versions of this +.\" reference card under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" Permission is granted to copy and distribute translations of this +.\" reference card into another language, under the above conditions for +.\" modified versions, except that this permission notice may be stated in +.\" a translation approved by the Foundation. +.\" +.ig +Strings for inline font change. +FR - font roman +FI - font italic +FC - font courier +.. +.ds FR \fR +.ds FI \fI +.ds FC \f(CB +.ds RN Times Roman +.ds IN Times Italic +.ds CN Courier Bold +.ds AM \fIGAWK: Effective AWK Programming\fP diff --git a/doc/colors b/doc/colors new file mode 100644 index 0000000..97dbff7 --- /dev/null +++ b/doc/colors @@ -0,0 +1,39 @@ +.\" AWK Reference Card --- Arnold Robbins, arnold@skeeve.com +.\" This file sets the colors to use. +.\" +.\" Copyright (C) 1996,97,99 Free Software Foundation, Inc. +.\" +.\" Permission is granted to make and distribute verbatim copies of +.\" this reference card provided the copyright notice and this permission +.\" notice are preserved on all copies. +.\" +.\" Permission is granted to process this file through troff and print the +.\" results, provided the printed document carries copying permission +.\" notice identical to this one except for the removal of this paragraph +.\" (this paragraph not being relevant to the printed reference card). +.\" +.\" Permission is granted to copy and distribute modified versions of this +.\" reference card under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" Permission is granted to copy and distribute translations of this +.\" reference card into another language, under the above conditions for +.\" modified versions, except that this permission notice may be stated in +.\" a translation approved by the Foundation. +.\" +.ig +Strings for inline color change. +CR - color red +CG - color green +CL - color light blue +CB - color blue +CD - color dark, i.e. black +CX - color boX, i.e. for the surrounding boxes (red for now) +.. +.ds CR \X'ps: exec 0 .96 .65 0 setcmykcolor' +.ds CG \X'ps: exec 1.0 0 .51 .43 setcmykcolor' +.ds CL \X'ps: exec .69 .34 0 0 setcmykcolor' +.ds CB \X'ps: exec 1 .72 0 .06 setcmykcolor' +.ds CD \X'ps: exec 1 1 1 1 setcmykcolor' +.ds CX \*(CG diff --git a/doc/gawk.1 b/doc/gawk.1 new file mode 100644 index 0000000..e26f9a2 --- /dev/null +++ b/doc/gawk.1 @@ -0,0 +1,3810 @@ +.ds PX \s-1POSIX\s+1 +.ds UX \s-1UNIX\s+1 +.ds AN \s-1ANSI\s+1 +.ds GN \s-1GNU\s+1 +.ds AK \s-1AWK\s+1 +.ds EP \fIGAWK: Effective AWK Programming\fP +.if !\n(.g \{\ +. if !\w|\*(lq| \{\ +. ds lq `` +. if \w'\(lq' .ds lq "\(lq +. \} +. if !\w|\*(rq| \{\ +. ds rq '' +. if \w'\(rq' .ds rq "\(rq +. \} +.\} +.TH GAWK 1 "Nov 10 2011" "Free Software Foundation" "Utility Commands" +.SH NAME +gawk \- pattern scanning and processing language +.SH SYNOPSIS +.B gawk +[ \*(PX or \*(GN style options ] +.B \-f +.I program-file +[ +.B \-\^\- +] file .\|.\|. +.br +.B gawk +[ \*(PX or \*(GN style options ] +[ +.B \-\^\- +] +.I program-text +file .\|.\|. +.sp +.B pgawk +[ \*(PX or \*(GN style options ] +.B \-f +.I program-file +[ +.B \-\^\- +] file .\|.\|. +.br +.B pgawk +[ \*(PX or \*(GN style options ] +[ +.B \-\^\- +] +.I program-text +file .\|.\|. +.sp +.B dgawk +[ \*(PX or \*(GN style options ] +.B \-f +.I program-file +[ +.B \-\^\- +] file .\|.\|. +.SH DESCRIPTION +.I Gawk +is the \*(GN Project's implementation of the \*(AK programming language. +It conforms to the definition of the language in +the \*(PX 1003.1 Standard. +This version in turn is based on the description in +.IR "The AWK Programming Language" , +by Aho, Kernighan, and Weinberger. +.I Gawk +provides the additional features found in the current version +of \*(UX +.I awk +and a number of \*(GN-specific extensions. +.PP +The command line consists of options to +.I gawk +itself, the \*(AK program text (if not supplied via the +.B \-f +or +.B \-\^\-file +options), and values to be made +available in the +.B ARGC +and +.B ARGV +pre-defined \*(AK variables. +.PP +.I Pgawk +is the profiling version of +.IR gawk . +It is identical in every way to +.IR gawk , +except that programs run more slowly, +and it automatically produces an execution profile in the file +.B awkprof.out +when done. +See the +.B \-\^\-profile +option, below. +.PP +.I Dgawk +is an +.I awk +debugger. Instead of running the program directly, it loads the +AWK source code and then prompts for debugging commands. +Unlike +.IR gawk " and " pgawk ", " dgawk +only processes AWK program source provided with the +.B \-f +option. +The debugger is documented in \*(EP. +.SH OPTION FORMAT +.PP +.I Gawk +options may be either traditional \*(PX-style one letter options, +or \*(GN-style long options. \*(PX options start with a single \*(lq\-\*(rq, +while long options start with \*(lq\-\^\-\*(rq. +Long options are provided for both \*(GN-specific features and +for \*(PX-mandated features. +.PP +.IR Gawk - +specific options are typically used in long-option form. +Arguments to long options are either joined with the option +by an +.B = +sign, with no intervening spaces, or they may be provided in the +next command line argument. +Long options may be abbreviated, as long as the abbreviation +remains unique. +.PP +Additionally, each long option has a corresponding short +option, so that the option's functionality may be used from +within +.B #! +executable scripts. +.SH OPTIONS +.PP +.I Gawk +accepts the following options. +Standard options are listed first, followed by options for +.I gawk +extensions, listed alphabetically by short option. +.TP +.PD 0 +.BI \-f " program-file" +.TP +.PD +.BI \-\^\-file " program-file" +Read the \*(AK program source from the file +.IR program-file , +instead of from the first command line argument. +Multiple +.B \-f +(or +.BR \-\^\-file ) +options may be used. +.TP +.PD 0 +.BI \-F " fs" +.TP +.PD +.BI \-\^\-field-separator " fs" +Use +.I fs +for the input field separator (the value of the +.B FS +predefined +variable). +.TP +.PD 0 +\fB\-v\fI var\fB\^=\^\fIval\fR +.TP +.PD +\fB\-\^\-assign \fIvar\fB\^=\^\fIval\fR +Assign the value +.I val +to the variable +.IR var , +before execution of the program begins. +Such variable values are available to the +.B BEGIN +block of an \*(AK program. +.ig +.TP +.PD 0 +.BI \-mf " NNN" +.TP +.PD +.BI \-mr " NNN" +Set various memory limits to the value +.IR NNN . +The +.B f +flag sets the maximum number of fields, and the +.B r +flag sets the maximum record size. These two flags and the +.B \-m +option are from an earlier version of the Bell Laboratories +research version of \*(UX +.IR awk . +They are ignored by +.IR gawk , +since +.I gawk +has no pre-defined limits. +(Current versions of the Bell Laboratories +.I awk +no longer accept them.) +.. +.TP +.PD 0 +.B \-b +.TP +.PD +.B \-\^\-characters\-as\-bytes +Treat all input data as single-byte characters. In other words, +don't pay any attention to the locale information when attempting to +process strings as multibyte characters. +The +.B "\-\^\-posix" +option overrides this one. +.TP +.PD 0 +.B \-c +.TP +.PD +.B \-\^\-traditional +Run in +.I compatibility +mode. In compatibility mode, +.I gawk +behaves identically to \*(UX +.IR awk ; +none of the \*(GN-specific extensions are recognized. +.\" The use of +.\" .B \-\^\-traditional +.\" is preferred over the other forms of this option. +See +.BR "GNU EXTENSIONS" , +below, for more information. +.TP +.PD 0 +.B \-C +.TP +.PD +.B \-\^\-copyright +Print the short version of the \*(GN copyright information message on +the standard output and exit successfully. +.TP +.PD 0 +\fB\-d\fR[\fIfile\fR] +.TP +.PD +\fB\-\^\-dump-variables\fR[\fB=\fIfile\fR] +Print a sorted list of global variables, their types and final values to +.IR file . +If no +.I file +is provided, +.I gawk +uses a file named +.B awkvars.out +in the current directory. +.sp .5 +Having a list of all the global variables is a good way to look for +typographical errors in your programs. +You would also use this option if you have a large program with a lot of +functions, and you want to be sure that your functions don't +inadvertently use global variables that you meant to be local. +(This is a particularly easy mistake to make with simple variable +names like +.BR i , +.BR j , +and so on.) +.TP +.PD 0 +.BI "\-e " program-text +.TP +.PD +.BI \-\^\-source " program-text" +Use +.I program-text +as \*(AK program source code. +This option allows the easy intermixing of library functions (used via the +.B \-f +and +.B \-\^\-file +options) with source code entered on the command line. +It is intended primarily for medium to large \*(AK programs used +in shell scripts. +.TP +.PD 0 +.BI "\-E " file +.TP +.PD +.BI \-\^\-exec " file" +Similar to +.BR \-f , +however, this is option is the last one processed. +This should be used with +.B #! +scripts, particularly for CGI applications, to avoid +passing in options or source code (!) on the command line +from a URL. +This option disables command-line variable assignments. +.TP +.PD 0 +.B \-g +.TP +.PD +.B \-\^\-gen\-pot +Scan and parse the \*(AK program, and generate a \*(GN +.B \&.pot +(Portable Object Template) +format file on standard output with entries for all localizable +strings in the program. The program itself is not executed. +See the \*(GN +.I gettext +distribution for more information on +.B \&.pot +files. +.TP +.PD 0 +.B \-h +.TP +.PD +.B \-\^\-help +Print a relatively short summary of the available options on +the standard output. +(Per the +.IR "GNU Coding Standards" , +these options cause an immediate, successful exit.) +.TP +.PD 0 +.BR "\-L " [ \fIvalue\fR ] +.TP +.PD +.BR \-\^\-lint [ =\fIvalue\fR ] +Provide warnings about constructs that are +dubious or non-portable to other \*(AK implementations. +With an optional argument of +.BR fatal , +lint warnings become fatal errors. +This may be drastic, but its use will certainly encourage the +development of cleaner \*(AK programs. +With an optional argument of +.BR invalid , +only warnings about things that are +actually invalid are issued. (This is not fully implemented yet.) +.TP +.PD 0 +.B \-n +.TP +.PD +.B "\-\^\-non\-decimal\-data" +Recognize octal and hexadecimal values in input data. +.I "Use this option with great caution!" +.TP +.PD 0 +.B \-N +.TP +.PD +.B \-\^\-use\-lc\-numeric +This forces +.I gawk +to use the locale's decimal point character when parsing input data. +Although the POSIX standard requires this behavior, and +.I gawk +does so when +.B \-\^\-posix +is in effect, the default is to follow traditional behavior and use a +period as the decimal point, even in locales where the period is not the +decimal point character. This option overrides the default behavior, +without the full draconian strictness of the +.B \-\^\-posix +option. +.ig +.\" This option is left undocumented, on purpose. +.TP +.PD 0 +.B "\-W nostalgia" +.TP +.PD +.B \-\^\-nostalgia +Provide a moment of nostalgia for long time +.I awk +users. +.. +.TP +.PD 0 +.B \-O +.TP +.PD +.B \-\^\-optimize +Enable optimizations upon the internal representation of the program. +Currently, this includes just simple constant-folding. The +.I gawk +maintainer hopes to add additional optimizations over time. +.TP +.PD 0 +\fB\-p\fR[\fIprof_file\fR] +.TP +.PD +\fB\-\^\-profile\fR[\fB=\fIprof_file\fR] +Send profiling data to +.IR prof_file . +The default is +.BR awkprof.out . +When run with +.IR gawk , +the profile is just a \*(lqpretty printed\*(rq version of the program. +When run with +.IR pgawk , +the profile contains execution counts of each statement in the program +in the left margin and function call counts for each user-defined function. +.TP +.PD 0 +.B \-P +.TP +.PD +.B \-\^\-posix +This turns on +.I compatibility +mode, with the following additional restrictions: +.RS +.TP "\w'\(bu'u+1n" +\(bu +.B \ex +escape sequences are not recognized. +.TP +\(bu +Only space and tab act as field separators when +.B FS +is set to a single space, newline does not. +.TP +\(bu +You cannot continue lines after +.B ? +and +.BR : . +.TP +\(bu +The synonym +.B func +for the keyword +.B function +is not recognized. +.TP +\(bu +The operators +.B ** +and +.B **= +cannot be used in place of +.B ^ +and +.BR ^= . +.TP +\(bu +The +.B fflush() +function is not available. +.RE +.TP +.PD 0 +.B \-r +.TP +.PD +.B \-\^\-re\-interval +Enable the use of +.I "interval expressions" +in regular expression matching +(see +.BR "Regular Expressions" , +below). +Interval expressions were not traditionally available in the +\*(AK language. The \*(PX standard added them, to make +.I awk +and +.I egrep +consistent with each other. +They are enabled by default, but this option remains for use with +.BR \-\^-traditional . +.TP +.PD 0 +.B \-R +.TP +.PD +.BI \-\^\-command " file" +.I Dgawk +only. Read stored debugger commands from +.IR file . +.TP +.PD 0 +.BI \-S +.TP +.PD +.BI \-\^\-sandbox +Runs +.I gawk +in sandbox mode, disabling the +.B system() +function, input redirection with +.BR getline , +output redirection with +.BR print " and " printf , +and loading dynamic extensions. +Command execution (through pipelines) is also disabled. +This effectively blocks a script from accessing local resources +(except for the files specified on the command line). +.TP +.PD 0 +.B \-t +.TP +.PD +.B \-\^\-lint\-old +Provide warnings about constructs that are +not portable to the original version of Unix +.IR awk . +.TP +.PD 0 +.B \-V +.TP +.PD +.B \-\^\-version +Print version information for this particular copy of +.I gawk +on the standard output. +This is useful mainly for knowing if the current copy of +.I gawk +on your system +is up to date with respect to whatever the Free Software Foundation +is distributing. +This is also useful when reporting bugs. +(Per the +.IR "GNU Coding Standards" , +these options cause an immediate, successful exit.) +.TP +.B \-\^\- +Signal the end of options. This is useful to allow further arguments to the +\*(AK program itself to start with a \*(lq\-\*(rq. +This provides consistency with the argument parsing convention used +by most other \*(PX programs. +.PP +In compatibility mode, +any other options are flagged as invalid, but are otherwise ignored. +In normal operation, as long as program text has been supplied, unknown +options are passed on to the \*(AK program in the +.B ARGV +array for processing. This is particularly useful for running \*(AK +programs via the \*(lq#!\*(rq executable interpreter mechanism. +.SH AWK PROGRAM EXECUTION +.PP +An \*(AK program consists of a sequence of pattern-action statements +and optional function definitions. +.RS +.PP +\fB@include "\fIfilename\fB" +\fIpattern\fB { \fIaction statements\fB }\fR +.br +\fBfunction \fIname\fB(\fIparameter list\fB) { \fIstatements\fB }\fR +.RE +.PP +.I Gawk +first reads the program source from the +.IR program-file (s) +if specified, +from arguments to +.BR \-\^\-source , +or from the first non-option argument on the command line. +The +.B \-f +and +.B \-\^\-source +options may be used multiple times on the command line. +.I Gawk +reads the program text as if all the +.IR program-file s +and command line source texts +had been concatenated together. This is useful for building libraries +of \*(AK functions, without having to include them in each new \*(AK +program that uses them. It also provides the ability to mix library +functions with command line programs. +.PP +In addition, lines beginning with +.B @include +may be used to include other source files into your program, +making library use even easier. +.PP +The environment variable +.B AWKPATH +specifies a search path to use when finding source files named with +the +.B \-f +option. If this variable does not exist, the default path is +\fB".:/usr/local/share/awk"\fR. +(The actual directory may vary, depending upon how +.I gawk +was built and installed.) +If a file name given to the +.B \-f +option contains a \*(lq/\*(rq character, no path search is performed. +.PP +.I Gawk +executes \*(AK programs in the following order. +First, +all variable assignments specified via the +.B \-v +option are performed. +Next, +.I gawk +compiles the program into an internal form. +Then, +.I gawk +executes the code in the +.B BEGIN +block(s) (if any), +and then proceeds to read +each file named in the +.B ARGV +array (up to +.BR ARGV[ARGC] ). +If there are no files named on the command line, +.I gawk +reads the standard input. +.PP +If a filename on the command line has the form +.IB var = val +it is treated as a variable assignment. The variable +.I var +will be assigned the value +.IR val . +(This happens after any +.B BEGIN +block(s) have been run.) +Command line variable assignment +is most useful for dynamically assigning values to the variables +\*(AK uses to control how input is broken into fields and records. +It is also useful for controlling state if multiple passes are needed over +a single data file. +.PP +If the value of a particular element of +.B ARGV +is empty (\fB""\fR), +.I gawk +skips over it. +.PP +For each input file, +if a +.B BEGINFILE +rule exists, +.I gawk +executes the associated code +before processing the contents of the file. Similarly, +.I gawk +executes +the code associated with +.B ENDFILE +after processing the file. +.PP +For each record in the input, +.I gawk +tests to see if it matches any +.I pattern +in the \*(AK program. +For each pattern that the record matches, the associated +.I action +is executed. +The patterns are tested in the order they occur in the program. +.PP +Finally, after all the input is exhausted, +.I gawk +executes the code in the +.B END +block(s) (if any). +.SS Command Line Directories +.PP +According to POSIX, files named on the +.I awk +command line must be +text files. The behavior is ``undefined'' if they are not. Most versions +of +.I awk +treat a directory on the command line as a fatal error. +.PP +Starting with version 4.0 of +.IR gawk , +a directory on the command line +produces a warning, but is otherwise skipped. If either of the +.B \-\^\-posix +or +.B \-\^\-traditional +options is given, then +.I gawk +reverts to +treating directories on the command line as a fatal error. +.SH VARIABLES, RECORDS AND FIELDS +\*(AK variables are dynamic; they come into existence when they are +first used. Their values are either floating-point numbers or strings, +or both, +depending upon how they are used. \*(AK also has one dimensional +arrays; arrays with multiple dimensions may be simulated. +Several pre-defined variables are set as a program +runs; these are described as needed and summarized below. +.SS Records +Normally, records are separated by newline characters. You can control how +records are separated by assigning values to the built-in variable +.BR RS . +If +.B RS +is any single character, that character separates records. +Otherwise, +.B RS +is a regular expression. Text in the input that matches this +regular expression separates the record. +However, in compatibility mode, +only the first character of its string +value is used for separating records. +If +.B RS +is set to the null string, then records are separated by +blank lines. +When +.B RS +is set to the null string, the newline character always acts as +a field separator, in addition to whatever value +.B FS +may have. +.SS Fields +.PP +As each input record is read, +.I gawk +splits the record into +.IR fields , +using the value of the +.B FS +variable as the field separator. +If +.B FS +is a single character, fields are separated by that character. +If +.B FS +is the null string, then each individual character becomes a +separate field. +Otherwise, +.B FS +is expected to be a full regular expression. +In the special case that +.B FS +is a single space, fields are separated +by runs of spaces and/or tabs and/or newlines. +(But see the section +.BR "POSIX COMPATIBILITY" , +below). +.BR NOTE : +The value of +.B IGNORECASE +(see below) also affects how fields are split when +.B FS +is a regular expression, and how records are separated when +.B RS +is a regular expression. +.PP +If the +.B FIELDWIDTHS +variable is set to a space separated list of numbers, each field is +expected to have fixed width, and +.I gawk +splits up the record using the specified widths. The value of +.B FS +is ignored. +Assigning a new value to +.B FS +or +.B FPAT +overrides the use of +.BR FIELDWIDTHS . +.PP +Similarly, if the +.B FPAT +variable is set to a string representing a regular expression, +each field is made up of text that matches that regular expression. In +this case, the regular expression describes the fields themselves, +instead of the text that separates the fields. +Assigning a new value to +.B FS +or +.B FIELDWIDTHS +overrides the use of +.BR FPAT . +.PP +Each field in the input record may be referenced by its position, +.BR $1 , +.BR $2 , +and so on. +.B $0 +is the whole record. +Fields need not be referenced by constants: +.RS +.PP +.ft B +n = 5 +.br +print $n +.ft R +.RE +.PP +prints the fifth field in the input record. +.PP +The variable +.B NF +is set to the total number of fields in the input record. +.PP +References to non-existent fields (i.e. fields after +.BR $NF ) +produce the null-string. However, assigning to a non-existent field +(e.g., +.BR "$(NF+2) = 5" ) +increases the value of +.BR NF , +creates any intervening fields with the null string as their value, and +causes the value of +.B $0 +to be recomputed, with the fields being separated by the value of +.BR OFS . +References to negative numbered fields cause a fatal error. +Decrementing +.B NF +causes the values of fields past the new value to be lost, and the value of +.B $0 +to be recomputed, with the fields being separated by the value of +.BR OFS . +.PP +Assigning a value to an existing field +causes the whole record to be rebuilt when +.B $0 +is referenced. +Similarly, assigning a value to +.B $0 +causes the record to be resplit, creating new +values for the fields. +.SS Built-in Variables +.PP +.IR Gawk\^ "'s" +built-in variables are: +.PP +.TP "\w'\fBFIELDWIDTHS\fR'u+1n" +.B ARGC +The number of command line arguments (does not include options to +.IR gawk , +or the program source). +.TP +.B ARGIND +The index in +.B ARGV +of the current file being processed. +.TP +.B ARGV +Array of command line arguments. The array is indexed from +0 to +.B ARGC +\- 1. +Dynamically changing the contents of +.B ARGV +can control the files used for data. +.TP +.B BINMODE +On non-POSIX systems, specifies use of \*(lqbinary\*(rq mode for all file I/O. +Numeric values of 1, 2, or 3, specify that input files, output files, or +all files, respectively, should use binary I/O. +String values of \fB"r"\fR, or \fB"w"\fR specify that input files, or output files, +respectively, should use binary I/O. +String values of \fB"rw"\fR or \fB"wr"\fR specify that all files +should use binary I/O. +Any other string value is treated as \fB"rw"\fR, but generates a warning message. +.TP +.B CONVFMT +The conversion format for numbers, \fB"%.6g"\fR, by default. +.TP +.B ENVIRON +An array containing the values of the current environment. +The array is indexed by the environment variables, each element being +the value of that variable (e.g., \fBENVIRON["HOME"]\fP might be +.BR /home/arnold ). +Changing this array does not affect the environment seen by programs which +.I gawk +spawns via redirection or the +.B system() +function. +.TP +.B ERRNO +If a system error occurs either doing a redirection for +.BR getline , +during a read for +.BR getline , +or during a +.BR close() , +then +.B ERRNO +will contain +a string describing the error. +The value is subject to translation in non-English locales. +.TP +.B FIELDWIDTHS +A whitespace separated list of field widths. When set, +.I gawk +parses the input into fields of fixed width, instead of using the +value of the +.B FS +variable as the field separator. +See +.BR Fields , +above. +.TP +.B FILENAME +The name of the current input file. +If no files are specified on the command line, the value of +.B FILENAME +is \*(lq\-\*(rq. +However, +.B FILENAME +is undefined inside the +.B BEGIN +block +(unless set by +.BR getline ). +.TP +.B FNR +The input record number in the current input file. +.TP +.B FPAT +A regular expression describing the contents of the +fields in a record. +When set, +.I gawk +parses the input into fields, where the fields match the +regular expression, instead of using the +value of the +.B FS +variable as the field separator. +See +.BR Fields , +above. +.TP +.B FS +The input field separator, a space by default. See +.BR Fields , +above. +.TP +.B IGNORECASE +Controls the case-sensitivity of all regular expression +and string operations. If +.B IGNORECASE +has a non-zero value, then string comparisons and +pattern matching in rules, +field splitting with +.B FS +and +.BR FPAT , +record separating with +.BR RS , +regular expression +matching with +.B ~ +and +.BR !~ , +and the +.BR gensub() , +.BR gsub() , +.BR index() , +.BR match() , +.BR patsplit() , +.BR split() , +and +.B sub() +built-in functions all ignore case when doing regular expression +operations. +.BR NOTE : +Array subscripting is +.I not +affected. +However, the +.B asort() +and +.B asorti() +functions are affected. +.sp .5 +Thus, if +.B IGNORECASE +is not equal to zero, +.B /aB/ +matches all of the strings \fB"ab"\fP, \fB"aB"\fP, \fB"Ab"\fP, +and \fB"AB"\fP. +As with all \*(AK variables, the initial value of +.B IGNORECASE +is zero, so all regular expression and string +operations are normally case-sensitive. +.TP +.B LINT +Provides dynamic control of the +.B \-\^\-lint +option from within an \*(AK program. +When true, +.I gawk +prints lint warnings. When false, it does not. +When assigned the string value \fB"fatal"\fP, +lint warnings become fatal errors, exactly like +.BR \-\^\-lint=fatal . +Any other true value just prints warnings. +.TP +.B NF +The number of fields in the current input record. +.TP +.B NR +The total number of input records seen so far. +.TP +.B OFMT +The output format for numbers, \fB"%.6g"\fR, by default. +.TP +.B OFS +The output field separator, a space by default. +.TP +.B ORS +The output record separator, by default a newline. +.TP +.B PROCINFO +The elements of this array provide access to information about the +running \*(AK program. +On some systems, +there may be elements in the array, \fB"group1"\fP through +\fB"group\fIn\fB"\fR for some +.IR n , +which is the number of supplementary groups that the process has. +Use the +.B in +operator to test for these elements. +The following elements are guaranteed to be available: +.RS +.TP \w'\fBPROCINFO["version"]\fR'u+1n +\fBPROCINFO["egid"]\fP +the value of the +.IR getegid (2) +system call. +.TP +\fBPROCINFO["strftime"]\fP +The default time format string for +.BR strftime() . +.TP +\fBPROCINFO["euid"]\fP +the value of the +.IR geteuid (2) +system call. +.TP +\fBPROCINFO["FS"]\fP +\fB"FS"\fP if field splitting with +.B FS +is in effect, +\fB"FPAT"\fP if field splitting with +.B FPAT +is in effect, +or \fB"FIELDWIDTHS"\fP if field splitting with +.B FIELDWIDTHS +is in effect. +.TP +\fBPROCINFO["gid"]\fP +the value of the +.IR getgid (2) +system call. +.TP +\fBPROCINFO["pgrpid"]\fP +the process group ID of the current process. +.TP +\fBPROCINFO["pid"]\fP +the process ID of the current process. +.TP +\fBPROCINFO["ppid"]\fP +the parent process ID of the current process. +.TP +\fBPROCINFO["uid"]\fP +the value of the +.IR getuid (2) +system call. +.TP +\fBPROCINFO["sorted_in"]\fP +If this element exists in +.BR PROCINFO , +then its value controls the order in which array elements +are traversed in +.B for +loops. +Supported values are +\fB"@ind_str_asc"\fR, +\fB"@ind_num_asc"\fR, +\fB"@val_type_asc"\fR, +\fB"@val_str_asc"\fR, +\fB"@val_num_asc"\fR, +\fB"@ind_str_desc"\fR, +\fB"@ind_num_desc"\fR, +\fB"@val_type_desc"\fR, +\fB"@val_str_desc"\fR, +\fB"@val_num_desc"\fR, +and +\fB"@unsorted"\fR. +The value can also be the name of any comparison function defined +as follows: +.PP +.RS +\fBfunction cmp_func(i1, v1, i2, v2)\fR +.RE +.PP +where +.I i1 +and +.I i2 +are the indices, and +.I v1 +and +.I v2 +are the +corresponding values of the two elements being compared. +It should return a number less than, equal to, or greater than 0, +depending on how the elements of the array are to be ordered. +.TP +\fBPROCINFO["version"]\fP +the version of +.IR gawk . +.RE +.TP +.B RS +The input record separator, by default a newline. +.TP +.B RT +The record terminator. +.I Gawk +sets +.B RT +to the input text that matched the character or regular expression +specified by +.BR RS . +.TP +.B RSTART +The index of the first character matched by +.BR match() ; +0 if no match. +(This implies that character indices start at one.) +.TP +.B RLENGTH +The length of the string matched by +.BR match() ; +\-1 if no match. +.TP +.B SUBSEP +The character used to separate multiple subscripts in array +elements, by default \fB"\e034"\fR. +.TP +.B TEXTDOMAIN +The text domain of the \*(AK program; used to find the localized +translations for the program's strings. +.SS Arrays +.PP +Arrays are subscripted with an expression between square brackets +.RB ( [ " and " ] ). +If the expression is an expression list +.RI ( expr ", " expr " .\|.\|.)" +then the array subscript is a string consisting of the +concatenation of the (string) value of each expression, +separated by the value of the +.B SUBSEP +variable. +This facility is used to simulate multiply dimensioned +arrays. For example: +.PP +.RS +.ft B +i = "A";\^ j = "B";\^ k = "C" +.br +x[i, j, k] = "hello, world\en" +.ft R +.RE +.PP +assigns the string \fB"hello, world\en"\fR to the element of the array +.B x +which is indexed by the string \fB"A\e034B\e034C"\fR. All arrays in \*(AK +are associative, i.e. indexed by string values. +.PP +The special operator +.B in +may be used to test if an array has an index consisting of a particular +value: +.PP +.RS +.ft B +.nf +if (val in array) + print array[val] +.fi +.ft +.RE +.PP +If the array has multiple subscripts, use +.BR "(i, j) in array" . +.PP +The +.B in +construct may also be used in a +.B for +loop to iterate over all the elements of an array. +.PP +An element may be deleted from an array using the +.B delete +statement. +The +.B delete +statement may also be used to delete the entire contents of an array, +just by specifying the array name without a subscript. +.PP +.I gawk +supports true multidimensional arrays. It does not require that +such arrays be ``rectangular'' as in C or C++. +For example: +.RS +.ft B +.nf +a[1] = 5 +a[2][1] = 6 +a[2][2] = 7 +.fi +.ft +.RE +.SS Variable Typing And Conversion +.PP +Variables and fields +may be (floating point) numbers, or strings, or both. How the +value of a variable is interpreted depends upon its context. If used in +a numeric expression, it will be treated as a number; if used as a string +it will be treated as a string. +.PP +To force a variable to be treated as a number, add 0 to it; to force it +to be treated as a string, concatenate it with the null string. +.PP +When a string must be converted to a number, the conversion is accomplished +using +.IR strtod (3). +A number is converted to a string by using the value of +.B CONVFMT +as a format string for +.IR sprintf (3), +with the numeric value of the variable as the argument. +However, even though all numbers in \*(AK are floating-point, +integral values are +.I always +converted as integers. Thus, given +.PP +.RS +.ft B +.nf +CONVFMT = "%2.2f" +a = 12 +b = a "" +.fi +.ft R +.RE +.PP +the variable +.B b +has a string value of \fB"12"\fR and not \fB"12.00"\fR. +.PP +.BR NOTE : +When operating in POSIX mode (such as with the +.B \-\^\-posix +command line option), +beware that locale settings may interfere with the way +decimal numbers are treated: the decimal separator of the numbers you +are feeding to +.I gawk +must conform to what your locale would expect, be it +a comma (,) or a period (.). +.PP +.I Gawk +performs comparisons as follows: +If two variables are numeric, they are compared numerically. +If one value is numeric and the other has a string value that is a +\*(lqnumeric string,\*(rq then comparisons are also done numerically. +Otherwise, the numeric value is converted to a string and a string +comparison is performed. +Two strings are compared, of course, as strings. +.PP +Note that string constants, such as \fB"57"\fP, are +.I not +numeric strings, they are string constants. +The idea of \*(lqnumeric string\*(rq +only applies to fields, +.B getline +input, +.BR FILENAME , +.B ARGV +elements, +.B ENVIRON +elements and the elements of an array created by +.B split() +or +.B patsplit() +that are numeric strings. +The basic idea is that +.IR "user input" , +and only user input, that looks numeric, +should be treated that way. +.PP +Uninitialized variables have the numeric value 0 and the string value "" +(the null, or empty, string). +.SS Octal and Hexadecimal Constants +You may use C-style octal and hexadecimal constants in your AWK +program source code. +For example, the octal value +.B 011 +is equal to decimal +.BR 9 , +and the hexadecimal value +.B 0x11 +is equal to decimal 17. +.SS String Constants +.PP +String constants in \*(AK are sequences of characters enclosed +between double quotes (like \fB"value"\fR). Within strings, certain +.I "escape sequences" +are recognized, as in C. These are: +.PP +.TP "\w'\fB\e\^\fIddd\fR'u+1n" +.B \e\e +A literal backslash. +.TP +.B \ea +The \*(lqalert\*(rq character; usually the \s-1ASCII\s+1 \s-1BEL\s+1 character. +.TP +.B \eb +backspace. +.TP +.B \ef +form-feed. +.TP +.B \en +newline. +.TP +.B \er +carriage return. +.TP +.B \et +horizontal tab. +.TP +.B \ev +vertical tab. +.TP +.BI \ex "\^hex digits" +The character represented by the string of hexadecimal digits following +the +.BR \ex . +As in \*(AN C, all following hexadecimal digits are considered part of +the escape sequence. +(This feature should tell us something about language design by committee.) +E.g., \fB"\ex1B"\fR is the \s-1ASCII\s+1 \s-1ESC\s+1 (escape) character. +.TP +.BI \e ddd +The character represented by the 1-, 2-, or 3-digit sequence of octal +digits. +E.g., \fB"\e033"\fR is the \s-1ASCII\s+1 \s-1ESC\s+1 (escape) character. +.TP +.BI \e c +The literal character +.IR c\^ . +.PP +The escape sequences may also be used inside constant regular expressions +(e.g., +.B "/[\ \et\ef\en\er\ev]/" +matches whitespace characters). +.PP +In compatibility mode, the characters represented by octal and +hexadecimal escape sequences are treated literally when used in +regular expression constants. Thus, +.B /a\e52b/ +is equivalent to +.BR /a\e*b/ . +.SH PATTERNS AND ACTIONS +\*(AK is a line-oriented language. The pattern comes first, and then the +action. Action statements are enclosed in +.B { +and +.BR } . +Either the pattern may be missing, or the action may be missing, but, +of course, not both. If the pattern is missing, the action is +executed for every single record of input. +A missing action is equivalent to +.RS +.PP +.B "{ print }" +.RE +.PP +which prints the entire record. +.PP +Comments begin with the +.B # +character, and continue until the +end of the line. +Blank lines may be used to separate statements. +Normally, a statement ends with a newline, however, this is not the +case for lines ending in +a comma, +.BR { , +.BR ? , +.BR : , +.BR && , +or +.BR || . +Lines ending in +.B do +or +.B else +also have their statements automatically continued on the following line. +In other cases, a line can be continued by ending it with a \*(lq\e\*(rq, +in which case the newline is ignored. +.PP +Multiple statements may +be put on one line by separating them with a \*(lq;\*(rq. +This applies to both the statements within the action part of a +pattern-action pair (the usual case), +and to the pattern-action statements themselves. +.SS Patterns +\*(AK patterns may be one of the following: +.PP +.RS +.nf +.B BEGIN +.B END +.B BEGINFILE +.B ENDFILE +.BI / "regular expression" / +.I "relational expression" +.IB pattern " && " pattern +.IB pattern " || " pattern +.IB pattern " ? " pattern " : " pattern +.BI ( pattern ) +.BI ! " pattern" +.IB pattern1 ", " pattern2 +.fi +.RE +.PP +.B BEGIN +and +.B END +are two special kinds of patterns which are not tested against +the input. +The action parts of all +.B BEGIN +patterns are merged as if all the statements had +been written in a single +.B BEGIN +block. They are executed before any +of the input is read. Similarly, all the +.B END +blocks are merged, +and executed when all the input is exhausted (or when an +.B exit +statement is executed). +.B BEGIN +and +.B END +patterns cannot be combined with other patterns in pattern expressions. +.B BEGIN +and +.B END +patterns cannot have missing action parts. +.PP +.B BEGINFILE +and +.B ENDFILE +are additional special patterns whose bodies are executed +before reading the first record of each command line input file +and after reading the last record of each file. +Inside the +.B BEGINFILE +rule, the value of +.B ERRNO +will be the empty string if the file could be opened successfully. +Otherwise, there is some problem with the file and the code should +use +.B nextfile +to skip it. If that is not done, +.I gawk +produces its usual fatal error for files that cannot be opened. +.PP +For +.BI / "regular expression" / +patterns, the associated statement is executed for each input record that matches +the regular expression. +Regular expressions are the same as those in +.IR egrep (1), +and are summarized below. +.PP +A +.I "relational expression" +may use any of the operators defined below in the section on actions. +These generally test whether certain fields match certain regular expressions. +.PP +The +.BR && , +.BR || , +and +.B ! +operators are logical AND, logical OR, and logical NOT, respectively, as in C. +They do short-circuit evaluation, also as in C, and are used for combining +more primitive pattern expressions. As in most languages, parentheses +may be used to change the order of evaluation. +.PP +The +.B ?\^: +operator is like the same operator in C. If the first pattern is true +then the pattern used for testing is the second pattern, otherwise it is +the third. Only one of the second and third patterns is evaluated. +.PP +The +.IB pattern1 ", " pattern2 +form of an expression is called a +.IR "range pattern" . +It matches all input records starting with a record that matches +.IR pattern1 , +and continuing until a record that matches +.IR pattern2 , +inclusive. It does not combine with any other sort of pattern expression. +.SS Regular Expressions +Regular expressions are the extended kind found in +.IR egrep . +They are composed of characters as follows: +.TP "\w'\fB[^\fIabc.\|.\|.\fB]\fR'u+2n" +.I c +matches the non-metacharacter +.IR c . +.TP +.I \ec +matches the literal character +.IR c . +.TP +.B . +matches any character +.I including +newline. +.TP +.B ^ +matches the beginning of a string. +.TP +.B $ +matches the end of a string. +.TP +.BI [ abc.\|.\|. ] +character list, matches any of the characters +.IR abc.\|.\|. . +.TP +\fB[^\fIabc.\|.\|.\fB]\fR +negated character list, matches any character except +.IR abc.\|.\|. . +.TP +.IB r1 | r2 +alternation: matches either +.I r1 +or +.IR r2 . +.TP +.I r1r2 +concatenation: matches +.IR r1 , +and then +.IR r2 . +.TP +.IB r\^ + +matches one or more +.IR r\^ "'s." +.TP +.IB r * +matches zero or more +.IR r\^ "'s." +.TP +.IB r\^ ? +matches zero or one +.IR r\^ "'s." +.TP +.BI ( r ) +grouping: matches +.IR r . +.TP +.PD 0 +.IB r { n } +.TP +.PD 0 +.IB r { n ,} +.TP +.PD +.IB r { n , m } +One or two numbers inside braces denote an +.IR "interval expression" . +If there is one number in the braces, the preceding regular expression +.I r +is repeated +.I n +times. If there are two numbers separated by a comma, +.I r +is repeated +.I n +to +.I m +times. +If there is one number followed by a comma, then +.I r +is repeated at least +.I n +times. +.TP +.B \ey +matches the empty string at either the beginning or the +end of a word. +.TP +.B \eB +matches the empty string within a word. +.TP +.B \e< +matches the empty string at the beginning of a word. +.TP +.B \e> +matches the empty string at the end of a word. +.TP +.B \es +matches any whitespace character. +.TP +.B \eS +matches any nonwhitespace character. +.TP +.B \ew +matches any word-constituent character (letter, digit, or underscore). +.TP +.B \eW +matches any character that is not word-constituent. +.TP +.B \e` +matches the empty string at the beginning of a buffer (string). +.TP +.B \e' +matches the empty string at the end of a buffer. +.PP +The escape sequences that are valid in string constants (see below) +are also valid in regular expressions. +.PP +.I "Character classes" +are a feature introduced in the \*(PX standard. +A character class is a special notation for describing +lists of characters that have a specific attribute, but where the +actual characters themselves can vary from country to country and/or +from character set to character set. For example, the notion of what +is an alphabetic character differs in the USA and in France. +.PP +A character class is only valid in a regular expression +.I inside +the brackets of a character list. Character classes consist of +.BR [: , +a keyword denoting the class, and +.BR :] . +The character +classes defined by the \*(PX standard are: +.TP "\w'\fB[:alnum:]\fR'u+2n" +.B [:alnum:] +Alphanumeric characters. +.TP +.B [:alpha:] +Alphabetic characters. +.TP +.B [:blank:] +Space or tab characters. +.TP +.B [:cntrl:] +Control characters. +.TP +.B [:digit:] +Numeric characters. +.TP +.B [:graph:] +Characters that are both printable and visible. +(A space is printable, but not visible, while an +.B a +is both.) +.TP +.B [:lower:] +Lowercase alphabetic characters. +.TP +.B [:print:] +Printable characters (characters that are not control characters.) +.TP +.B [:punct:] +Punctuation characters (characters that are not letter, digits, +control characters, or space characters). +.TP +.B [:space:] +Space characters (such as space, tab, and formfeed, to name a few). +.TP +.B [:upper:] +Uppercase alphabetic characters. +.TP +.B [:xdigit:] +Characters that are hexadecimal digits. +.PP +For example, before the \*(PX standard, to match alphanumeric +characters, you would have had to write +.BR /[A\-Za\-z0\-9]/ . +If your character set had other alphabetic characters in it, this would not +match them, and if your character set collated differently from +\s-1ASCII\s+1, this might not even match the +\s-1ASCII\s+1 alphanumeric characters. +With the \*(PX character classes, you can write +.BR /[[:alnum:]]/ , +and this matches +the alphabetic and numeric characters in your character set, +no matter what it is. +.PP +Two additional special sequences can appear in character lists. +These apply to non-\s-1ASCII\s+1 character sets, which can have single symbols +(called +.IR "collating elements" ) +that are represented with more than one +character, as well as several characters that are equivalent for +.IR collating , +or sorting, purposes. (E.g., in French, a plain \*(lqe\*(rq +and a grave-accented \*(lqe\h'-\w:e:u'\`\*(rq are equivalent.) +.TP +Collating Symbols +A collating symbol is a multi-character collating element enclosed in +.B [. +and +.BR .] . +For example, if +.B ch +is a collating element, then +.B [[.ch.]] +is a regular expression that matches this collating element, while +.B [ch] +is a regular expression that matches either +.B c +or +.BR h . +.TP +Equivalence Classes +An equivalence class is a locale-specific name for a list of +characters that are equivalent. The name is enclosed in +.B [= +and +.BR =] . +For example, the name +.B e +might be used to represent all of +\*(lqe,\*(rq \*(lqe\h'-\w:e:u'\',\*(rq and \*(lqe\h'-\w:e:u'\`.\*(rq +In this case, +.B [[=e=]] +is a regular expression +that matches any of +.BR e , +.BR "e\h'-\w:e:u'\'" , +or +.BR "e\h'-\w:e:u'\`" . +.PP +These features are very valuable in non-English speaking locales. +The library functions that +.I gawk +uses for regular expression matching +currently only recognize \*(PX character classes; they do not recognize +collating symbols or equivalence classes. +.PP +The +.BR \ey , +.BR \eB , +.BR \e< , +.BR \e> , +.BR \es , +.BR \eS , +.BR \ew , +.BR \eW , +.BR \e` , +and +.B \e' +operators are specific to +.IR gawk ; +they are extensions based on facilities in the \*(GN regular expression libraries. +.PP +The various command line options +control how +.I gawk +interprets characters in regular expressions. +.TP +No options +In the default case, +.I gawk +provide all the facilities of +\*(PX regular expressions and the \*(GN regular expression operators described above. +.TP +.B \-\^\-posix +Only \*(PX regular expressions are supported, the \*(GN operators are not special. +(E.g., +.B \ew +matches a literal +.BR w ). +.TP +.B \-\^\-traditional +Traditional Unix +.I awk +regular expressions are matched. The \*(GN operators +are not special, and interval expressions are not available. +Characters described by octal and hexadecimal escape sequences are +treated literally, even if they represent regular expression metacharacters. +.TP +.B \-\^\-re\-interval +Allow interval expressions in regular expressions, even if +.B \-\^\-traditional +has been provided. +.SS Actions +Action statements are enclosed in braces, +.B { +and +.BR } . +Action statements consist of the usual assignment, conditional, and looping +statements found in most languages. The operators, control statements, +and input/output statements +available are patterned after those in C. +.SS Operators +.PP +The operators in \*(AK, in order of decreasing precedence, are +.PP +.TP "\w'\fB*= /= %= ^=\fR'u+1n" +.BR ( \&.\|.\|. ) +Grouping +.TP +.B $ +Field reference. +.TP +.B "++ \-\^\-" +Increment and decrement, both prefix and postfix. +.TP +.B ^ +Exponentiation (\fB**\fR may also be used, and \fB**=\fR for +the assignment operator). +.TP +.B "+ \- !" +Unary plus, unary minus, and logical negation. +.TP +.B "* / %" +Multiplication, division, and modulus. +.TP +.B "+ \-" +Addition and subtraction. +.TP +.I space +String concatenation. +.TP +.B "| |&" +Piped I/O for +.BR getline , +.BR print , +and +.BR printf . +.TP +.B "< > <= >= != ==" +The regular relational operators. +.TP +.B "~ !~" +Regular expression match, negated match. +.BR NOTE : +Do not use a constant regular expression +.RB ( /foo/ ) +on the left-hand side of a +.B ~ +or +.BR !~ . +Only use one on the right-hand side. The expression +.BI "/foo/ ~ " exp +has the same meaning as \fB(($0 ~ /foo/) ~ \fIexp\fB)\fR. +This is usually +.I not +what was intended. +.TP +.B in +Array membership. +.TP +.B && +Logical AND. +.TP +.B || +Logical OR. +.TP +.B ?: +The C conditional expression. This has the form +.IB expr1 " ? " expr2 " : " expr3\c +\&. +If +.I expr1 +is true, the value of the expression is +.IR expr2 , +otherwise it is +.IR expr3 . +Only one of +.I expr2 +and +.I expr3 +is evaluated. +.TP +.B "= += \-= *= /= %= ^=" +Assignment. Both absolute assignment +.BI ( var " = " value ) +and operator-assignment (the other forms) are supported. +.SS Control Statements +.PP +The control statements are +as follows: +.PP +.RS +.nf +\fBif (\fIcondition\fB) \fIstatement\fR [ \fBelse\fI statement \fR] +\fBwhile (\fIcondition\fB) \fIstatement \fR +\fBdo \fIstatement \fBwhile (\fIcondition\fB)\fR +\fBfor (\fIexpr1\fB; \fIexpr2\fB; \fIexpr3\fB) \fIstatement\fR +\fBfor (\fIvar \fBin\fI array\fB) \fIstatement\fR +\fBbreak\fR +\fBcontinue\fR +\fBdelete \fIarray\^\fB[\^\fIindex\^\fB]\fR +\fBdelete \fIarray\^\fR +\fBexit\fR [ \fIexpression\fR ] +\fB{ \fIstatements \fB}\fR +\fBswitch (\fIexpression\fB) { +\fBcase \fIvalue\fB|\fIregex\fB : \fIstatement +\&.\^.\^. +\fR[ \fBdefault: \fIstatement \fR] +\fB}\fR +.fi +.RE +.SS "I/O Statements" +.PP +The input/output statements are as follows: +.PP +.TP "\w'\fBprintf \fIfmt, expr-list\fR'u+1n" +\fBclose(\fIfile \fR[\fB, \fIhow\fR]\fB)\fR +Close file, pipe or co-process. +The optional +.I how +should only be used when closing one end of a +two-way pipe to a co-process. +It must be a string value, either +\fB"to"\fR or \fB"from"\fR. +.TP +.B getline +Set +.B $0 +from next input record; set +.BR NF , +.BR NR , +.BR FNR . +.TP +.BI "getline <" file +Set +.B $0 +from next record of +.IR file ; +set +.BR NF . +.TP +.BI getline " var" +Set +.I var +from next input record; set +.BR NR , +.BR FNR . +.TP +.BI getline " var" " <" file +Set +.I var +from next record of +.IR file . +.TP +\fIcommand\fB | getline \fR[\fIvar\fR] +Run +.I command +piping the output either into +.B $0 +or +.IR var , +as above. +.TP +\fIcommand\fB |& getline \fR[\fIvar\fR] +Run +.I command +as a co-process +piping the output either into +.B $0 +or +.IR var , +as above. +Co-processes are a +.I gawk +extension. +.RI ( command +can also be a socket. See the subsection +.BR "Special File Names" , +below.) +.TP +.B next +Stop processing the current input record. The next input record +is read and processing starts over with the first pattern in the +\*(AK program. If the end of the input data is reached, the +.B END +block(s), if any, are executed. +.TP +.B "nextfile" +Stop processing the current input file. The next input record read +comes from the next input file. +.B FILENAME +and +.B ARGIND +are updated, +.B FNR +is reset to 1, and processing starts over with the first pattern in the +\*(AK program. If the end of the input data is reached, the +.B END +block(s), if any, are executed. +.TP +.B print +Print the current record. +The output record is terminated with the value of the +.B ORS +variable. +.TP +.BI print " expr-list" +Print expressions. +Each expression is separated by the value of the +.B OFS +variable. +The output record is terminated with the value of the +.B ORS +variable. +.TP +.BI print " expr-list" " >" file +Print expressions on +.IR file . +Each expression is separated by the value of the +.B OFS +variable. The output record is terminated with the value of the +.B ORS +variable. +.TP +.BI printf " fmt, expr-list" +Format and print. +See \fBThe \fIprintf \fBStatement\fR, below. +.TP +.BI printf " fmt, expr-list" " >" file +Format and print on +.IR file . +.TP +.BI system( cmd-line ) +Execute the command +.IR cmd-line , +and return the exit status. +(This may not be available on non-\*(PX systems.) +.TP +\&\fBfflush(\fR[\fIfile\^\fR]\fB)\fR +Flush any buffers associated with the open output file or pipe +.IR file . +If +.I file +is missing, then flush standard output. +If +.I file +is the null string, +then flush all open output files and pipes. +.PP +Additional output redirections are allowed for +.B print +and +.BR printf . +.TP +.BI "print .\|.\|. >>" " file" +Appends output to the +.IR file . +.TP +.BI "print .\|.\|. |" " command" +Writes on a pipe. +.TP +.BI "print .\|.\|. |&" " command" +Sends data to a co-process or socket. +(See also the subsection +.BR "Special File Names" , +below.) +.PP +The +.B getline +command returns 1 on success, 0 on end of file, and \-1 on an error. +Upon an error, +.B ERRNO +contains a string describing the problem. +.PP +.BR NOTE : +Failure in opening a two-way socket will result in a non-fatal error being +returned to the calling function. If using a pipe, co-process, or socket to +.BR getline , +or from +.B print +or +.B printf +within a loop, you +.I must +use +.B close() +to create new instances of the command or socket. +\*(AK does not automatically close pipes, sockets, or co-processes when +they return EOF. +.SS The \fIprintf\fP\^ Statement +.PP +The \*(AK versions of the +.B printf +statement and +.B sprintf() +function +(see below) +accept the following conversion specification formats: +.TP "\w'\fB%g\fR, \fB%G\fR'u+2n" +.B %c +A single character. +If the argument used for +.B %c +is numeric, it is treated as a character and printed. +Otherwise, the argument is assumed to be a string, and the only first +character of that string is printed. +.TP +.BR "%d" "," " %i" +A decimal number (the integer part). +.TP +.BR %e , " %E" +A floating point number of the form +.BR [\-]d.dddddde[+\^\-]dd . +The +.B %E +format uses +.B E +instead of +.BR e . +.TP +.BR %f , " %F" +A floating point number of the form +.BR [\-]ddd.dddddd . +If the system library supports it, +.B %F +is available as well. This is like +.BR %f , +but uses capital letters for special \*(lqnot a number\*(rq +and \*(lqinfinity\*(rq values. If +.B %F +is not available, +.I gawk +uses +.BR %f . +.TP +.BR %g , " %G" +Use +.B %e +or +.B %f +conversion, whichever is shorter, with nonsignificant zeros suppressed. +The +.B %G +format uses +.B %E +instead of +.BR %e . +.TP +.B %o +An unsigned octal number (also an integer). +.TP +.PD +.B %u +An unsigned decimal number (again, an integer). +.TP +.B %s +A character string. +.TP +.BR %x , " %X" +An unsigned hexadecimal number (an integer). +The +.B %X +format uses +.B ABCDEF +instead of +.BR abcdef . +.TP +.B %% +A single +.B % +character; no argument is converted. +.PP +Optional, additional parameters may lie between the +.B % +and the control letter: +.TP +.IB count $ +Use the +.IR count "'th" +argument at this point in the formatting. +This is called a +.I "positional specifier" +and +is intended primarily for use in translated versions of +format strings, not in the original text of an AWK program. +It is a +.I gawk +extension. +.TP +.B \- +The expression should be left-justified within its field. +.TP +.I space +For numeric conversions, prefix positive values with a space, and +negative values with a minus sign. +.TP +.B + +The plus sign, used before the width modifier (see below), +says to always supply a sign for numeric conversions, even if the data +to be formatted is positive. The +.B + +overrides the space modifier. +.TP +.B # +Use an \*(lqalternate form\*(rq for certain control letters. +For +.BR %o , +supply a leading zero. +For +.BR %x , +and +.BR %X , +supply a leading +.B 0x +or +.B 0X +for +a nonzero result. +For +.BR %e , +.BR %E , +.B %f +and +.BR %F , +the result always contains a +decimal point. +For +.BR %g , +and +.BR %G , +trailing zeros are not removed from the result. +.TP +.B 0 +A leading +.B 0 +(zero) acts as a flag, that indicates output should be +padded with zeroes instead of spaces. +This applies only to the numeric output formats. +This flag only has an effect when the field width is wider than the +value to be printed. +.TP +.I width +The field should be padded to this width. The field is normally padded +with spaces. If the +.B 0 +flag has been used, it is padded with zeroes. +.TP +.BI \&. prec +A number that specifies the precision to use when printing. +For the +.BR %e , +.BR %E , +.B %f +and +.BR %F , +formats, this specifies the +number of digits you want printed to the right of the decimal point. +For the +.BR %g , +and +.B %G +formats, it specifies the maximum number +of significant digits. For the +.BR %d , +.BR %i , +.BR %o , +.BR %u , +.BR %x , +and +.B %X +formats, it specifies the minimum number of +digits to print. For +.BR %s , +it specifies the maximum number of +characters from the string that should be printed. +.PP +The dynamic +.I width +and +.I prec +capabilities of the \*(AN C +.B printf() +routines are supported. +A +.B * +in place of either the +.B width +or +.B prec +specifications causes their values to be taken from +the argument list to +.B printf +or +.BR sprintf() . +To use a positional specifier with a dynamic width or precision, +supply the +.IB count $ +after the +.B * +in the format string. +For example, \fB"%3$*2$.*1$s"\fP. +.SS Special File Names +.PP +When doing I/O redirection from either +.B print +or +.B printf +into a file, +or via +.B getline +from a file, +.I gawk +recognizes certain special filenames internally. These filenames +allow access to open file descriptors inherited from +.IR gawk\^ "'s" +parent process (usually the shell). +These file names may also be used on the command line to name data files. +The filenames are: +.TP "\w'\fB/dev/stdout\fR'u+1n" +.B /dev/stdin +The standard input. +.TP +.B /dev/stdout +The standard output. +.TP +.B /dev/stderr +The standard error output. +.TP +.BI /dev/fd/\^ n +The file associated with the open file descriptor +.IR n . +.PP +These are particularly useful for error messages. For example: +.PP +.RS +.ft B +print "You blew it!" > "/dev/stderr" +.ft R +.RE +.PP +whereas you would otherwise have to use +.PP +.RS +.ft B +print "You blew it!" | "cat 1>&2" +.ft R +.RE +.PP +The following special filenames may be used with the +.B |& +co-process operator for creating TCP/IP network connections: +.TP +.PD 0 +.BI /inet/tcp/ lport / rhost / rport +.TP +.PD 0 +.BI /inet4/tcp/ lport / rhost / rport +.TP +.PD +.BI /inet6/tcp/ lport / rhost / rport +Files for a TCP/IP connection on local port +.I lport +to +remote host +.I rhost +on remote port +.IR rport . +Use a port of +.B 0 +to have the system pick a port. +Use +.B /inet4 +to force an IPv4 connection, +and +.B /inet6 +to force an IPv6 connection. +Plain +.B /inet +uses the system default (most likely IPv4). +.TP +.PD 0 +.BI /inet/udp/ lport / rhost / rport +.TP +.PD 0 +.BI /inet4/udp/ lport / rhost / rport +.TP +.PD +.BI /inet6/udp/ lport / rhost / rport +Similar, but use UDP/IP instead of TCP/IP. +.SS Numeric Functions +.PP +\*(AK has the following built-in arithmetic functions: +.PP +.TP "\w'\fBsrand(\fR[\fIexpr\^\fR]\fB)\fR'u+1n" +.BI atan2( y , " x" ) +Return the arctangent of +.I y/x +in radians. +.TP +.BI cos( expr ) +Return the cosine of +.IR expr , +which is in radians. +.TP +.BI exp( expr ) +The exponential function. +.TP +.BI int( expr ) +Truncate to integer. +.TP +.BI log( expr ) +The natural logarithm function. +.TP +.B rand() +Return a random number +.IR N , +between 0 and 1, +such that 0 \(<= \fIN\fP < 1. +.TP +.BI sin( expr ) +Return the sine of +.IR expr , +which is in radians. +.TP +.BI sqrt( expr ) +The square root function. +.TP +\&\fBsrand(\fR[\fIexpr\^\fR]\fB)\fR +Use +.I expr +as the new seed for the random number generator. If no +.I expr +is provided, use the time of day. +The return value is the previous seed for the random +number generator. +.SS String Functions +.PP +.I Gawk +has the following built-in string functions: +.PP +.TP "\w'\fBsprintf(\^\fIfmt\fB\^, \fIexpr-list\^\fB)\fR'u+1n" +\fBasort(\fIs \fR[\fB, \fId\fR [\fB, \fIhow\fR] ]\fB)\fR +Return the number of elements in the source +array +.IR s . +Sort +the contents of +.I s +using +.IR gawk\^ "'s" +normal rules for +comparing values, and replace the indices of the +sorted values +.I s +with sequential +integers starting with 1. If the optional +destination array +.I d +is specified, then +first duplicate +.I s +into +.IR d , +and then sort +.IR d , +leaving the indices of the +source array +.I s +unchanged. The optional string +.I how +controls the direction and the comparison mode. +Valid values for +.I how +are +any of the strings valid for +\fBPROCINFO["sorted_in"]\fR. +It can also be the name of a user-defined +comparison function as described in +\fBPROCINFO["sorted_in"]\fR. +.TP "\w'\fBsprintf(\^\fIfmt\fB\^, \fIexpr-list\^\fB)\fR'u+1n" +\fBasorti(\fIs \fR[\fB, \fId\fR [\fB, \fIhow\fR] ]\fB)\fR +Return the number of elements in the source +array +.IR s . +The behavior is the same as that of +.BR asort() , +except that the array +.I indices +are used for sorting, not the array values. +When done, the array is indexed numerically, and +the values are those of the original indices. +The original values are lost; thus provide +a second array if you wish to preserve the original. +The purpose of the optional string +.I how +is the same as described in +.B asort() +above. +.TP +\fBgensub(\fIr\fB, \fIs\fB, \fIh \fR[\fB, \fIt\fR]\fB)\fR +Search the target string +.I t +for matches of the regular expression +.IR r . +If +.I h +is a string beginning with +.B g +or +.BR G , +then replace all matches of +.I r +with +.IR s . +Otherwise, +.I h +is a number indicating which match of +.I r +to replace. +If +.I t +is not supplied, use +.B $0 +instead. +Within the replacement text +.IR s , +the sequence +.BI \e n\fR, +where +.I n +is a digit from 1 to 9, may be used to indicate just the text that +matched the +.IR n 'th +parenthesized subexpression. The sequence +.B \e0 +represents the entire matched text, as does the character +.BR & . +Unlike +.B sub() +and +.BR gsub() , +the modified string is returned as the result of the function, +and the original target string is +.I not +changed. +.TP "\w'\fBsprintf(\^\fIfmt\fB\^, \fIexpr-list\^\fB)\fR'u+1n" +\fBgsub(\fIr\fB, \fIs \fR[\fB, \fIt\fR]\fB)\fR +For each substring matching the regular expression +.I r +in the string +.IR t , +substitute the string +.IR s , +and return the number of substitutions. +If +.I t +is not supplied, use +.BR $0 . +An +.B & +in the replacement text is replaced with the text that was actually matched. +Use +.B \e& +to get a literal +.BR & . +(This must be typed as \fB"\e\e&"\fP; +see \*(EP +for a fuller discussion of the rules for +.BR & 's +and backslashes in the replacement text of +.BR sub() , +.BR gsub() , +and +.BR gensub() .) +.TP +.BI index( s , " t" ) +Return the index of the string +.I t +in the string +.IR s , +or 0 if +.I t +is not present. +(This implies that character indices start at one.) +.TP +\fBlength(\fR[\fIs\fR]\fB) +Return the length of the string +.IR s , +or the length of +.B $0 +if +.I s +is not supplied. +As a non-standard extension, with an array argument, +.B length() +returns the number of elements in the array. +.TP +\fBmatch(\fIs\fB, \fIr \fR[\fB, \fIa\fR]\fB)\fR +Return the position in +.I s +where the regular expression +.I r +occurs, or 0 if +.I r +is not present, and set the values of +.B RSTART +and +.BR RLENGTH . +Note that the argument order is the same as for the +.B ~ +operator: +.IB str " ~" +.IR re . +.ft R +If array +.I a +is provided, +.I a +is cleared and then elements 1 through +.I n +are filled with the portions of +.I s +that match the corresponding parenthesized +subexpression in +.IR r . +The 0'th element of +.I a +contains the portion +of +.I s +matched by the entire regular expression +.IR r . +Subscripts +\fBa[\fIn\^\fB, "start"]\fR, +and +\fBa[\fIn\^\fB, "length"]\fR +provide the starting index in the string and length +respectively, of each matching substring. +.TP +\fBpatsplit(\fIs\fB, \fIa \fR[\fB, \fIr\fR [\fB, \fIseps\fR] ]\fB)\fR +Split the string +.I s +into the array +.I a +and the separators array +.I seps +on the regular expression +.IR r , +and return the number of fields. +Element values are the portions of +.I s +that matched +.IR r . +The value of +.I seps[i] +is the separator that appeared in +front of +.IR a[i+1] . +If +.I r +is omitted, +.B FPAT +is used instead. +The arrays +.I a +and +.I seps +are cleared first. +Splitting behaves identically to field splitting with +.BR FPAT , +described above. +.TP +\fBsplit(\fIs\fB, \fIa \fR[\fB, \fIr\fR [\fB, \fIseps\fR] ]\fB)\fR +Split the string +.I s +into the array +.I a +and the separators array +.I seps +on the regular expression +.IR r , +and return the number of fields. If +.I r +is omitted, +.B FS +is used instead. +The arrays +.I a +and +.I seps +are cleared first. +.I seps[i] +is the field separator matched by +.I r +between +.I a[i] +and +.IR a[i+1] . +If +.I r +is a single space, then leading whitespace in +.I s +goes into the extra array element +.I seps[0] +and trailing whitespace goes into the extra array element +.IR seps[n] , +where +.I n +is the return value of +.IR "split(s, a, r, seps)" . +Splitting behaves identically to field splitting, described above. +.TP +.BI sprintf( fmt , " expr-list" ) +Prints +.I expr-list +according to +.IR fmt , +and returns the resulting string. +.TP +.BI strtonum( str ) +Examine +.IR str , +and return its numeric value. +If +.I str +begins +with a leading +.BR 0 , +.B strtonum() +assumes that +.I str +is an octal number. +If +.I str +begins +with a leading +.B 0x +or +.BR 0X , +.B strtonum() +assumes that +.I str +is a hexadecimal number. +Otherwise, decimal is assumed. +.TP +\fBsub(\fIr\fB, \fIs \fR[\fB, \fIt\fR]\fB)\fR +Just like +.BR gsub() , +but replace only the first matching substring. +.TP +\fBsubstr(\fIs\fB, \fIi \fR[\fB, \fIn\fR]\fB)\fR +Return the at most +.IR n -character +substring of +.I s +starting at +.IR i . +If +.I n +is omitted, use the rest of +.IR s . +.TP +.BI tolower( str ) +Return a copy of the string +.IR str , +with all the uppercase characters in +.I str +translated to their corresponding lowercase counterparts. +Non-alphabetic characters are left unchanged. +.TP +.BI toupper( str ) +Return a copy of the string +.IR str , +with all the lowercase characters in +.I str +translated to their corresponding uppercase counterparts. +Non-alphabetic characters are left unchanged. +.PP +.I Gawk +is multibyte aware. This means that +.BR index() , +.BR length() , +.B substr() +and +.B match() +all work in terms of characters, not bytes. +.SS Time Functions +Since one of the primary uses of \*(AK programs is processing log files +that contain time stamp information, +.I gawk +provides the following functions for obtaining time stamps and +formatting them. +.PP +.TP "\w'\fBsystime()\fR'u+1n" +\fBmktime(\fIdatespec\fB)\fR +Turn +.I datespec +into a time stamp of the same form as returned by +.BR systime() , +and return the result. +The +.I datespec +is a string of the form +.IR "YYYY MM DD HH MM SS[ DST]" . +The contents of the string are six or seven numbers representing respectively +the full year including century, +the month from 1 to 12, +the day of the month from 1 to 31, +the hour of the day from 0 to 23, +the minute from 0 to 59, +the second from 0 to 60, +and an optional daylight saving flag. +The values of these numbers need not be within the ranges specified; +for example, an hour of \-1 means 1 hour before midnight. +The origin-zero Gregorian calendar is assumed, +with year 0 preceding year 1 and year \-1 preceding year 0. +The time is assumed to be in the local timezone. +If the daylight saving flag is positive, +the time is assumed to be daylight saving time; +if zero, the time is assumed to be standard time; +and if negative (the default), +.B mktime() +attempts to determine whether daylight saving time is in effect +for the specified time. +If +.I datespec +does not contain enough elements or if the resulting time +is out of range, +.B mktime() +returns \-1. +.TP +\fBstrftime(\fR[\fIformat \fR[\fB, \fItimestamp\fR[\fB, \fIutc-flag\fR]]]\fB)\fR +Format +.I timestamp +according to the specification in +.IR format . +If +.I utc-flag +is present and is non-zero or non-null, the result +is in UTC, otherwise the result is in local time. +The +.I timestamp +should be of the same form as returned by +.BR systime() . +If +.I timestamp +is missing, the current time of day is used. +If +.I format +is missing, a default format equivalent to the output of +.IR date (1) +is used. +The default format is available in +.BR PROCINFO["strftime"] . +See the specification for the +.B strftime() +function in \*(AN C for the format conversions that are +guaranteed to be available. +.TP +.B systime() +Return the current time of day as the number of seconds since the Epoch +(1970-01-01 00:00:00 UTC on \*(PX systems). +.SS Bit Manipulations Functions +.I Gawk +supplies the following bit manipulation functions. +They work by converting double-precision floating point +values to +.B uintmax_t +integers, doing the operation, and then converting the +result back to floating point. +The functions are: +.TP "\w'\fBrshift(\fIval\fB, \fIcount\fB)\fR'u+2n" +\fBand(\fIv1\fB, \fIv2\fB)\fR +Return the bitwise AND of the values provided by +.I v1 +and +.IR v2 . +.TP +\fBcompl(\fIval\fB)\fR +Return the bitwise complement of +.IR val . +.TP +\fBlshift(\fIval\fB, \fIcount\fB)\fR +Return the value of +.IR val , +shifted left by +.I count +bits. +.TP +\fBor(\fIv1\fB, \fIv2\fB)\fR +Return the bitwise OR of the values provided by +.I v1 +and +.IR v2 . +.TP +\fBrshift(\fIval\fB, \fIcount\fB)\fR +Return the value of +.IR val , +shifted right by +.I count +bits. +.TP +\fBxor(\fIv1\fB, \fIv2\fB)\fR +Return the bitwise XOR of the values provided by +.I v1 +and +.IR v2 . +.PP +.SS Type Function +The following function is for use with multidimensional arrays. +.TP +\fBisarray(\fIx\fB)\fR +Return true if +.I x +is an array, false otherwise. +.SS Internationalization Functions +The following functions may be used from within your AWK program for +translating strings at run-time. +For full details, see \*(EP. +.TP +\fBbindtextdomain(\fIdirectory \fR[\fB, \fIdomain\fR]\fB)\fR +Specify the directory where +.I gawk +looks for the +.B \&.mo +files, in case they +will not or cannot be placed in the ``standard'' locations +(e.g., during testing). +It returns the directory where +.I domain +is ``bound.'' +.sp .5 +The default +.I domain +is the value of +.BR TEXTDOMAIN . +If +.I directory +is the null string (\fB""\fR), then +.B bindtextdomain() +returns the current binding for the +given +.IR domain . +.TP +\fBdcgettext(\fIstring \fR[\fB, \fIdomain \fR[\fB, \fIcategory\fR]]\fB)\fR +Return the translation of +.I string +in text domain +.I domain +for locale category +.IR category . +The default value for +.I domain +is the current value of +.BR TEXTDOMAIN . +The default value for +.I category +is \fB"LC_MESSAGES"\fR. +.sp .5 +If you supply a value for +.IR category , +it must be a string equal to +one of the known locale categories described +in \*(EP. +You must also supply a text domain. Use +.B TEXTDOMAIN +if you want to use the current domain. +.TP +\fBdcngettext(\fIstring1 \fR, \fIstring2 \fR, \fInumber \fR[\fB, \fIdomain \fR[\fB, \fIcategory\fR]]\fB)\fR +Return the plural form used for +.I number +of the translation of +.I string1 +and +.I string2 +in +text domain +.I domain +for locale category +.IR category . +The default value for +.I domain +is the current value of +.BR TEXTDOMAIN . +The default value for +.I category +is \fB"LC_MESSAGES"\fR. +.sp .5 +If you supply a value for +.IR category , +it must be a string equal to +one of the known locale categories described +in \*(EP. +You must also supply a text domain. Use +.B TEXTDOMAIN +if you want to use the current domain. +.SH USER-DEFINED FUNCTIONS +Functions in \*(AK are defined as follows: +.PP +.RS +\fBfunction \fIname\fB(\fIparameter list\fB) { \fIstatements \fB}\fR +.RE +.PP +Functions are executed when they are called from within expressions +in either patterns or actions. Actual parameters supplied in the function +call are used to instantiate the formal parameters declared in the function. +Arrays are passed by reference, other variables are passed by value. +.PP +Since functions were not originally part of the \*(AK language, the provision +for local variables is rather clumsy: They are declared as extra parameters +in the parameter list. The convention is to separate local variables from +real parameters by extra spaces in the parameter list. For example: +.PP +.RS +.ft B +.nf +function f(p, q, a, b) # a and b are local +{ + \&.\|.\|. +} + +/abc/ { .\|.\|. ; f(1, 2) ; .\|.\|. } +.fi +.ft R +.RE +.PP +The left parenthesis in a function call is required +to immediately follow the function name, +without any intervening whitespace. +This avoids a syntactic ambiguity with the concatenation operator. +This restriction does not apply to the built-in functions listed above. +.PP +Functions may call each other and may be recursive. +Function parameters used as local variables are initialized +to the null string and the number zero upon function invocation. +.PP +Use +.BI return " expr" +to return a value from a function. The return value is undefined if no +value is provided, or if the function returns by \*(lqfalling off\*(rq the +end. +.PP +As a +.I gawk +extension, functions may be called indirectly. To do this, assign +the name of the function to be called, as a string, to a variable. +Then use the variable as if it were the name of a function, prefixed with an +.B @ +sign, like so: +.RS +.ft B +.nf +function myfunc() +{ + print "myfunc called" + \&.\|.\|. +} + +{ .\|.\|. + the_func = "myfunc" + @the_func() # call through the_func to myfunc + .\|.\|. +} +.fi +.ft R +.RE +.PP +If +.B \-\^\-lint +has been provided, +.I gawk +warns about calls to undefined functions at parse time, +instead of at run time. +Calling an undefined function at run time is a fatal error. +.PP +The word +.B func +may be used in place of +.BR function . +.SH DYNAMICALLY LOADING NEW FUNCTIONS +You can dynamically add new built-in functions to the running +.I gawk +interpreter. +The full details are beyond the scope of this manual page; +see \*(EP for the details. +.PP +.TP 8 +\fBextension(\fIobject\fB, \fIfunction\fB)\fR +Dynamically link the shared object file named by +.IR object , +and invoke +.I function +in that object, to perform initialization. +These should both be provided as strings. +Return the value returned by +.IR function . +.PP +Using this feature at the C level is not pretty, but +it is unlikely to go away. Additional mechanisms may +be added at some point. +.SH SIGNALS +.I pgawk +accepts two signals. +.B SIGUSR1 +causes it to dump a profile and function call stack to the +profile file, which is either +.BR awkprof.out , +or whatever file was named with the +.B \-\^\-profile +option. It then continues to run. +.B SIGHUP +causes +.I pgawk +to dump the profile and function call stack and then exit. +.SH INTERNATIONALIZATION +.PP +String constants are sequences of characters enclosed in double +quotes. In non-English speaking environments, it is possible to mark +strings in the \*(AK program as requiring translation to the local +natural language. Such strings are marked in the \*(AK program with +a leading underscore (\*(lq_\*(rq). For example, +.sp +.RS +.ft B +gawk 'BEGIN { print "hello, world" }' +.RE +.sp +.ft R +always prints +.BR "hello, world" . +But, +.sp +.RS +.ft B +gawk 'BEGIN { print _"hello, world" }' +.RE +.sp +.ft R +might print +.B "bonjour, monde" +in France. +.PP +There are several steps involved in producing and running a localizable +\*(AK program. +.TP "\w'4.'u+2n" +1. +Add a +.B BEGIN +action to assign a value to the +.B TEXTDOMAIN +variable to set the text domain to a name associated with your program: +.sp +.RS +.ft B +BEGIN { TEXTDOMAIN = "myprog" } +.ft R +.RE +.sp +This allows +.I gawk +to find the +.B \&.mo +file associated with your program. +Without this step, +.I gawk +uses the +.B messages +text domain, +which likely does not contain translations for your program. +.TP +2. +Mark all strings that should be translated with leading underscores. +.TP +3. +If necessary, use the +.B dcgettext() +and/or +.B bindtextdomain() +functions in your program, as appropriate. +.TP +4. +Run +.B "gawk \-\^\-gen\-pot \-f myprog.awk > myprog.pot" +to generate a +.B \&.po +file for your program. +.TP +5. +Provide appropriate translations, and build and install the corresponding +.B \&.mo +files. +.PP +The internationalization features are described in full detail in \*(EP. +.SH POSIX COMPATIBILITY +A primary goal for +.I gawk +is compatibility with the \*(PX standard, as well as with the +latest version of \*(UX +.IR awk . +To this end, +.I gawk +incorporates the following user visible +features which are not described in the \*(AK book, +but are part of the Bell Laboratories version of +.IR awk , +and are in the \*(PX standard. +.PP +The book indicates that command line variable assignment happens when +.I awk +would otherwise open the argument as a file, which is after the +.B BEGIN +block is executed. However, in earlier implementations, when such an +assignment appeared before any file names, the assignment would happen +.I before +the +.B BEGIN +block was run. Applications came to depend on this \*(lqfeature.\*(rq +When +.I awk +was changed to match its documentation, the +.B \-v +option for assigning variables before program execution was added to +accommodate applications that depended upon the old behavior. +(This feature was agreed upon by both the Bell Laboratories and the \*(GN developers.) +.PP +When processing arguments, +.I gawk +uses the special option \*(lq\-\^\-\*(rq to signal the end of +arguments. +In compatibility mode, it warns about but otherwise ignores +undefined options. +In normal operation, such arguments are passed on to the \*(AK program for +it to process. +.PP +The \*(AK book does not define the return value of +.BR srand() . +The \*(PX standard +has it return the seed it was using, to allow keeping track +of random number sequences. Therefore +.B srand() +in +.I gawk +also returns its current seed. +.PP +Other new features are: +The use of multiple +.B \-f +options (from MKS +.IR awk ); +the +.B ENVIRON +array; the +.BR \ea , +and +.B \ev +escape sequences (done originally in +.I gawk +and fed back into the Bell Laboratories version); the +.B tolower() +and +.B toupper() +built-in functions (from the Bell Laboratories version); and the \*(AN C conversion specifications in +.B printf +(done first in the Bell Laboratories version). +.SH HISTORICAL FEATURES +There is one feature of historical \*(AK implementations that +.I gawk +supports: +It is possible to call the +.B length() +built-in function not only with no argument, but even without parentheses! +Thus, +.RS +.PP +.ft B +a = length # Holy Algol 60, Batman! +.ft R +.RE +.PP +is the same as either of +.RS +.PP +.ft B +a = length() +.br +a = length($0) +.ft R +.RE +.PP +Using this feature is poor practice, and +.I gawk +issues a warning about its use if +.B \-\^\-lint +is specified on the command line. +.SH GNU EXTENSIONS +.I Gawk +has a number of extensions to \*(PX +.IR awk . +They are described in this section. All the extensions described here +can be disabled by +invoking +.I gawk +with the +.B \-\^\-traditional +or +.B \-\^\-posix +options. +.PP +The following features of +.I gawk +are not available in +\*(PX +.IR awk . +.\" Environment vars and startup stuff +.TP "\w'\(bu'u+1n" +\(bu +No path search is performed for files named via the +.B \-f +option. Therefore the +.B AWKPATH +environment variable is not special. +.\" POSIX and language recognition issues +.TP +\(bu +There is no facility for doing file inclusion +.RI ( gawk 's +.B @include +mechanism). +.TP +\(bu +The +.B \ex +escape sequence. +(Disabled with +.BR \-\^\-posix .) +.TP +\(bu +The +.B fflush() +function. +(Disabled with +.BR \-\^\-posix .) +.TP +\(bu +The ability to continue lines after +.B ? +and +.BR : . +(Disabled with +.BR \-\^\-posix .) +.TP +\(bu +Octal and hexadecimal constants in AWK programs. +.\" Special variables +.TP +\(bu +The +.BR ARGIND , +.BR BINMODE , +.BR ERRNO , +.BR LINT , +.B RT +and +.B TEXTDOMAIN +variables are not special. +.TP +\(bu +The +.B IGNORECASE +variable and its side-effects are not available. +.TP +\(bu +The +.B FIELDWIDTHS +variable and fixed-width field splitting. +.TP +\(bu +The +.B FPAT +variable and field splitting based on field values. +.TP +\(bu +The +.B PROCINFO +array is not available. +.\" I/O stuff +.TP +\(bu +The use of +.B RS +as a regular expression. +.TP +\(bu +The special file names available for I/O redirection are not recognized. +.TP +\(bu +The +.B |& +operator for creating co-processes. +.TP +\(bu +The +.B BEGINFILE +and +.B ENDFILE +special patterns are not available. +.\" Changes to standard awk functions +.TP +\(bu +The ability to split out individual characters using the null string +as the value of +.BR FS , +and as the third argument to +.BR split() . +.TP +\(bu +An optional fourth argument to +.B split() +to receive the separator texts. +.TP +\(bu +The optional second argument to the +.B close() +function. +.TP +\(bu +The optional third argument to the +.B match() +function. +.TP +\(bu +The ability to use positional specifiers with +.B printf +and +.BR sprintf() . +.TP +\(bu +The ability to pass an array to +.BR length() . +.\" New keywords or changes to keywords +.TP +\(bu +The use of +.BI delete " array" +to delete the entire contents of an array. +.TP +\(bu +The use of +.B "nextfile" +to abandon processing of the current input file. +.\" New functions +.TP +\(bu +The +.BR and() , +.BR asort() , +.BR asorti() , +.BR bindtextdomain() , +.BR compl() , +.BR dcgettext() , +.BR dcngettext() , +.BR gensub() , +.BR lshift() , +.BR mktime() , +.BR or() , +.BR patsplit() , +.BR rshift() , +.BR strftime() , +.BR strtonum() , +.B systime() +and +.B xor() +functions. +.\" I18N stuff +.TP +\(bu +Localizable strings. +.\" Extending gawk +.TP +\(bu +Adding new built-in functions dynamically with the +.B extension() +function. +.PP +The \*(AK book does not define the return value of the +.B close() +function. +.IR Gawk\^ "'s" +.B close() +returns the value from +.IR fclose (3), +or +.IR pclose (3), +when closing an output file or pipe, respectively. +It returns the process's exit status when closing an input pipe. +The return value is \-1 if the named file, pipe +or co-process was not opened with a redirection. +.PP +When +.I gawk +is invoked with the +.B \-\^\-traditional +option, +if the +.I fs +argument to the +.B \-F +option is \*(lqt\*(rq, then +.B FS +is set to the tab character. +Note that typing +.B "gawk \-F\et \&.\|.\|." +simply causes the shell to quote the \*(lqt,\*(rq and does not pass +\*(lq\et\*(rq to the +.B \-F +option. +Since this is a rather ugly special case, it is not the default behavior. +This behavior also does not occur if +.B \-\^\-posix +has been specified. +To really get a tab character as the field separator, it is best to use +single quotes: +.BR "gawk \-F'\et' \&.\|.\|." . +.ig +.PP +If +.I gawk +was compiled for debugging, it +accepts the following additional options: +.TP +.PD 0 +.B \-Y +.TP +.PD +.B \-\^\-parsedebug +Turn on +.IR yacc (1) +or +.IR bison (1) +debugging output during program parsing. +This option should only be of interest to the +.I gawk +maintainers, and may not even be compiled into +.IR gawk . +.. +.SH ENVIRONMENT VARIABLES +The +.B AWKPATH +environment variable can be used to provide a list of directories that +.I gawk +searches when looking for files named via the +.B \-f +and +.B \-\^\-file +options. +.PP +For socket communication, two special environment variables can be used to control the number of retries +.RB ( GAWK_SOCK_RETRIES ), +and the interval between retries +.RB ( GAWK_MSEC_SLEEP ). +The interval is in milliseconds. On systems that do not support +.IR usleep (3), +the value is rounded up to an integral number of seconds. +.PP +If +.B POSIXLY_CORRECT +exists in the environment, then +.I gawk +behaves exactly as if +.B \-\^\-posix +had been specified on the command line. +If +.B \-\^\-lint +has been specified, +.I gawk +issues a warning message to this effect. +.SH EXIT STATUS +If the +.B exit +statement is used with a value, +then +.I gawk +exits with +the numeric value given to it. +.PP +Otherwise, if there were no problems during execution, +.I gawk +exits with the value of the C constant +.BR EXIT_SUCCESS . +This is usually zero. +.PP +If an error occurs, +.I gawk +exits with the value of +the C constant +.BR EXIT_FAILURE . +This is usually one. +.PP +If +.I gawk +exits because of a fatal error, the exit +status is 2. On non-POSIX systems, this value may be mapped to +.BR EXIT_FAILURE . +.SH VERSION INFORMATION +This man page documents +.IR gawk , +version 4.0. +.SH AUTHORS +The original version of \*(UX +.I awk +was designed and implemented by Alfred Aho, +Peter Weinberger, and Brian Kernighan of Bell Laboratories. Brian Kernighan +continues to maintain and enhance it. +.PP +Paul Rubin and Jay Fenlason, +of the Free Software Foundation, wrote +.IR gawk , +to be compatible with the original version of +.I awk +distributed in Seventh Edition \*(UX. +John Woods contributed a number of bug fixes. +David Trueman, with contributions +from Arnold Robbins, made +.I gawk +compatible with the new version of \*(UX +.IR awk . +Arnold Robbins is the current maintainer. +.PP +The initial DOS port was done by Conrad Kwok and Scott Garfinkle. +Scott Deifik maintains the port to MS-DOS using DJGPP. +Eli Zaretskii maintains the port to MS-Windows using MinGW. +Pat Rankin did the +port to VMS, and Michal Jaegermann did the port to the Atari ST. +The port to OS/2 was done by Kai Uwe Rommel, with contributions and +help from Darrel Hankerson. +Andreas Buening now maintains the OS/2 port. +The late Fred Fish supplied support for the Amiga, +and Martin Brown provided the BeOS port. +Stephen Davies provided the original Tandem port, and +Matthew Woehlke provided changes for Tandem's POSIX-compliant systems. +Dave Pitts provided the port to z/OS. +.PP +See the +.I README +file in the +.I gawk +distribution for up-to-date information about maintainers +and which ports are currently supported. +.SH BUG REPORTS +If you find a bug in +.IR gawk , +please send electronic mail to +.BR bug-gawk@gnu.org . +Please include your operating system and its revision, the version of +.I gawk +(from +.BR "gawk \-\^\-version" ), +which C compiler you used to compile it, and a test program +and data that are as small as possible for reproducing the problem. +.PP +Before sending a bug report, please do the following things. First, verify that +you have the latest version of +.IR gawk . +Many bugs (usually subtle ones) are fixed at each release, and if +yours is out of date, the problem may already have been solved. +Second, please see if setting the environment variable +.B LC_ALL +to +.B LC_ALL=C +causes things to behave as you expect. If so, it's a locale issue, +and may or may not really be a bug. +Finally, please read this man page and the reference manual carefully to +be sure that what you think is a bug really is, instead of just a quirk +in the language. +.PP +Whatever you do, do +.B NOT +post a bug report in +.BR comp.lang.awk . +While the +.I gawk +developers occasionally read this newsgroup, posting bug reports there +is an unreliable way to report bugs. Instead, please use the electronic mail +addresses given above. +.PP +If you're using a GNU/Linux or BSD-based system, +you may wish to submit a bug report to the vendor of your distribution. +That's fine, but please send a copy to the official email address as well, +since there's no guarantee that the bug report will be forwarded to the +.I gawk +maintainer. +.SH BUGS +The +.B \-F +option is not necessary given the command line variable assignment feature; +it remains only for backwards compatibility. +.PP +Syntactically invalid single character programs tend to overflow +the parse stack, generating a rather unhelpful message. Such programs +are surprisingly difficult to diagnose in the completely general case, +and the effort to do so really is not worth it. +.SH SEE ALSO +.IR egrep (1), +.IR getpid (2), +.IR getppid (2), +.IR getpgrp (2), +.IR getuid (2), +.IR geteuid (2), +.IR getgid (2), +.IR getegid (2), +.IR getgroups (2), +.IR usleep (3) +.PP +.IR "The AWK Programming Language" , +Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger, +Addison-Wesley, 1988. ISBN 0-201-07981-X. +.PP +\*(EP, +Edition 4.0, shipped with the +.I gawk +source. +The current version of this document is available online at +.BR http://www.gnu.org/software/gawk/manual . +.SH EXAMPLES +.nf +Print and sort the login names of all users: + +.ft B + BEGIN { FS = ":" } + { print $1 | "sort" } + +.ft R +Count lines in a file: + +.ft B + { nlines++ } + END { print nlines } + +.ft R +Precede each line by its number in the file: + +.ft B + { print FNR, $0 } + +.ft R +Concatenate and line number (a variation on a theme): + +.ft B + { print NR, $0 } + +.ft R +Run an external command for particular lines of data: + +.ft B + tail \-f access_log | + awk '/myhome.html/ { system("nmap " $1 ">> logdir/myhome.html") }' +.ft R +.fi +.SH ACKNOWLEDGEMENTS +Brian Kernighan of Bell Laboratories +provided valuable assistance during testing and debugging. +We thank him. +.SH COPYING PERMISSIONS +Copyright \(co 1989, 1991, 1992, 1993, 1994, 1995, 1996, +1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2007, 2009, +2010, 2011 +Free Software Foundation, Inc. +.PP +Permission is granted to make and distribute verbatim copies of +this manual page provided the copyright notice and this permission +notice are preserved on all copies. +.ig +Permission is granted to process this file through troff and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual page). +.. +.PP +Permission is granted to copy and distribute modified versions of this +manual page under the conditions for verbatim copying, provided that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. +.PP +Permission is granted to copy and distribute translations of this +manual page into another language, under the above conditions for +modified versions, except that this permission notice may be stated in +a translation approved by the Foundation. diff --git a/doc/gawk.info b/doc/gawk.info new file mode 100644 index 0000000..a33027c --- /dev/null +++ b/doc/gawk.info @@ -0,0 +1,27854 @@ +This is gawk.info, produced by makeinfo version 4.13 from gawk.texi. + +INFO-DIR-SECTION Text creation and manipulation +START-INFO-DIR-ENTRY +* Gawk: (gawk). A text scanning and processing language. +END-INFO-DIR-ENTRY +INFO-DIR-SECTION Individual utilities +START-INFO-DIR-ENTRY +* awk: (gawk)Invoking gawk. Text scanning and processing. +END-INFO-DIR-ENTRY + + Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2007, 2009, 2010, 2011, 2012 Free +Software Foundation, Inc. + + + This is Edition 4 of `GAWK: Effective AWK Programming: A User's +Guide for GNU Awk', for the 4.0.1 (or later) version of the GNU +implementation of AWK. + + Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with the +Invariant Sections being "GNU General Public License", the Front-Cover +texts being (a) (see below), and with the Back-Cover Texts being (b) +(see below). A copy of the license is included in the section entitled +"GNU Free Documentation License". + + a. "A GNU Manual" + + b. "You have the freedom to copy and modify this GNU manual. Buying + copies from the FSF supports it in developing GNU and promoting + software freedom." + + +File: gawk.info, Node: Top, Next: Foreword, Up: (dir) + +General Introduction +******************** + +This file documents `awk', a program that you can use to select +particular records in a file and perform operations upon them. + + Copyright (C) 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2007, 2009, 2010, 2011, 2012 Free +Software Foundation, Inc. + + + This is Edition 4 of `GAWK: Effective AWK Programming: A User's +Guide for GNU Awk', for the 4.0.1 (or later) version of the GNU +implementation of AWK. + + Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with the +Invariant Sections being "GNU General Public License", the Front-Cover +texts being (a) (see below), and with the Back-Cover Texts being (b) +(see below). A copy of the license is included in the section entitled +"GNU Free Documentation License". + + a. "A GNU Manual" + + b. "You have the freedom to copy and modify this GNU manual. Buying + copies from the FSF supports it in developing GNU and promoting + software freedom." + +* Menu: + +* Foreword:: Some nice words about this + Info file. +* Preface:: What this Info file is about; brief + history and acknowledgments. +* Getting Started:: A basic introduction to using + `awk'. How to run an `awk' + program. Command-line syntax. +* Invoking Gawk:: How to run `gawk'. +* Regexp:: All about matching things using regular + expressions. +* Reading Files:: How to read files and manipulate fields. +* Printing:: How to print using `awk'. Describes + the `print' and `printf' + statements. Also describes redirection of + output. +* Expressions:: Expressions are the basic building blocks + of statements. +* Patterns and Actions:: Overviews of patterns and actions. +* Arrays:: The description and use of arrays. Also + includes array-oriented control statements. +* Functions:: Built-in and user-defined functions. +* Internationalization:: Getting `gawk' to speak your + language. +* Advanced Features:: Stuff for advanced users, specific to + `gawk'. +* Library Functions:: A Library of `awk' Functions. +* Sample Programs:: Many `awk' programs with complete + explanations. +* Debugger:: The `dgawk' debugger. +* Language History:: The evolution of the `awk' + language. +* Installation:: Installing `gawk' under various + operating systems. +* Notes:: Notes about `gawk' extensions and + possible future work. +* Basic Concepts:: A very quick introduction to programming + concepts. +* Glossary:: An explanation of some unfamiliar terms. +* Copying:: Your right to copy and distribute + `gawk'. +* GNU Free Documentation License:: The license for this Info file. +* Index:: Concept and Variable Index. + +* History:: The history of `gawk' and + `awk'. +* Names:: What name to use to find `awk'. +* This Manual:: Using this Info file. Includes + sample input files that you can use. +* Conventions:: Typographical Conventions. +* Manual History:: Brief history of the GNU project and this + Info file. +* How To Contribute:: Helping to save the world. +* Acknowledgments:: Acknowledgments. +* Running gawk:: How to run `gawk' programs; + includes command-line syntax. +* One-shot:: Running a short throwaway `awk' + program. +* Read Terminal:: Using no input files (input from terminal + instead). +* Long:: Putting permanent `awk' programs in + files. +* Executable Scripts:: Making self-contained `awk' + programs. +* Comments:: Adding documentation to `gawk' + programs. +* Quoting:: More discussion of shell quoting issues. +* DOS Quoting:: Quoting in Windows Batch Files. +* Sample Data Files:: Sample data files for use in the + `awk' programs illustrated in this + Info file. +* Very Simple:: A very simple example. +* Two Rules:: A less simple one-line example using two + rules. +* More Complex:: A more complex example. +* Statements/Lines:: Subdividing or combining statements into + lines. +* Other Features:: Other Features of `awk'. +* When:: When to use `gawk' and when to use + other things. +* Command Line:: How to run `awk'. +* Options:: Command-line options and their meanings. +* Other Arguments:: Input file names and variable assignments. +* Naming Standard Input:: How to specify standard input with other + files. +* Environment Variables:: The environment variables `gawk' + uses. +* AWKPATH Variable:: Searching directories for `awk' + programs. +* Other Environment Variables:: The environment variables. +* Exit Status:: `gawk''s exit status. +* Include Files:: Including other files into your program. +* Obsolete:: Obsolete Options and/or features. +* Undocumented:: Undocumented Options and Features. +* Regexp Usage:: How to Use Regular Expressions. +* Escape Sequences:: How to write nonprinting characters. +* Regexp Operators:: Regular Expression Operators. +* Bracket Expressions:: What can go between `[...]'. +* GNU Regexp Operators:: Operators specific to GNU software. +* Case-sensitivity:: How to do case-insensitive matching. +* Leftmost Longest:: How much text matches. +* Computed Regexps:: Using Dynamic Regexps. +* Records:: Controlling how data is split into records. +* Fields:: An introduction to fields. +* Nonconstant Fields:: Nonconstant Field Numbers. +* Changing Fields:: Changing the Contents of a Field. +* Field Separators:: The field separator and how to change it. +* Default Field Splitting:: How fields are normally separated. +* Regexp Field Splitting:: Using regexps as the field separator. +* Single Character Fields:: Making each character a separate field. +* Command Line Field Separator:: Setting `FS' from the command-line. +* Field Splitting Summary:: Some final points and a summary table. +* Constant Size:: Reading constant width data. +* Splitting By Content:: Defining Fields By Content +* Multiple Line:: Reading multi-line records. +* Getline:: Reading files under explicit program + control using the `getline' function. +* Plain Getline:: Using `getline' with no arguments. +* Getline/Variable:: Using `getline' into a variable. +* Getline/File:: Using `getline' from a file. +* Getline/Variable/File:: Using `getline' into a variable from a + file. +* Getline/Pipe:: Using `getline' from a pipe. +* Getline/Variable/Pipe:: Using `getline' into a variable from a + pipe. +* Getline/Coprocess:: Using `getline' from a coprocess. +* Getline/Variable/Coprocess:: Using `getline' into a variable from a + coprocess. +* Getline Notes:: Important things to know about + `getline'. +* Getline Summary:: Summary of `getline' Variants. +* Command line directories:: What happens if you put a directory on the + command line. +* Print:: The `print' statement. +* Print Examples:: Simple examples of `print' statements. +* Output Separators:: The output separators and how to change + them. +* OFMT:: Controlling Numeric Output With + `print'. +* Printf:: The `printf' statement. +* Basic Printf:: Syntax of the `printf' statement. +* Control Letters:: Format-control letters. +* Format Modifiers:: Format-specification modifiers. +* Printf Examples:: Several examples. +* Redirection:: How to redirect output to multiple files + and pipes. +* Special Files:: File name interpretation in `gawk'. + `gawk' allows access to inherited + file descriptors. +* Special FD:: Special files for I/O. +* Special Network:: Special files for network communications. +* Special Caveats:: Things to watch out for. +* Close Files And Pipes:: Closing Input and Output Files and Pipes. +* Values:: Constants, Variables, and Regular + Expressions. +* Constants:: String, numeric and regexp constants. +* Scalar Constants:: Numeric and string constants. +* Nondecimal-numbers:: What are octal and hex numbers. +* Regexp Constants:: Regular Expression constants. +* Using Constant Regexps:: When and how to use a regexp constant. +* Variables:: Variables give names to values for later + use. +* Using Variables:: Using variables in your programs. +* Assignment Options:: Setting variables on the command-line and a + summary of command-line syntax. This is an + advanced method of input. +* Conversion:: The conversion of strings to numbers and + vice versa. +* All Operators:: `gawk''s operators. +* Arithmetic Ops:: Arithmetic operations (`+', `-', + etc.) +* Concatenation:: Concatenating strings. +* Assignment Ops:: Changing the value of a variable or a + field. +* Increment Ops:: Incrementing the numeric value of a + variable. +* Truth Values and Conditions:: Testing for true and false. +* Truth Values:: What is ``true'' and what is ``false''. +* Typing and Comparison:: How variables acquire types and how this + affects comparison of numbers and strings + with `<', etc. +* Variable Typing:: String type versus numeric type. +* Comparison Operators:: The comparison operators. +* POSIX String Comparison:: String comparison with POSIX rules. +* Boolean Ops:: Combining comparison expressions using + boolean operators `||' (``or''), + `&&' (``and'') and `!' (``not''). +* Conditional Exp:: Conditional expressions select between two + subexpressions under control of a third + subexpression. +* Function Calls:: A function call is an expression. +* Precedence:: How various operators nest. +* Locales:: How the locale affects things. +* Pattern Overview:: What goes into a pattern. +* Regexp Patterns:: Using regexps as patterns. +* Expression Patterns:: Any expression can be used as a pattern. +* Ranges:: Pairs of patterns specify record ranges. +* BEGIN/END:: Specifying initialization and cleanup + rules. +* Using BEGIN/END:: How and why to use BEGIN/END rules. +* I/O And BEGIN/END:: I/O issues in BEGIN/END rules. +* BEGINFILE/ENDFILE:: Two special patterns for advanced control. +* Empty:: The empty pattern, which matches every + record. +* Using Shell Variables:: How to use shell variables with + `awk'. +* Action Overview:: What goes into an action. +* Statements:: Describes the various control statements in + detail. +* If Statement:: Conditionally execute some `awk' + statements. +* While Statement:: Loop until some condition is satisfied. +* Do Statement:: Do specified action while looping until + some condition is satisfied. +* For Statement:: Another looping statement, that provides + initialization and increment clauses. +* Switch Statement:: Switch/case evaluation for conditional + execution of statements based on a value. +* Break Statement:: Immediately exit the innermost enclosing + loop. +* Continue Statement:: Skip to the end of the innermost enclosing + loop. +* Next Statement:: Stop processing the current input record. +* Nextfile Statement:: Stop processing the current file. +* Exit Statement:: Stop execution of `awk'. +* Built-in Variables:: Summarizes the built-in variables. +* User-modified:: Built-in variables that you change to + control `awk'. +* Auto-set:: Built-in variables where `awk' + gives you information. +* ARGC and ARGV:: Ways to use `ARGC' and `ARGV'. +* Array Basics:: The basics of arrays. +* Array Intro:: Introduction to Arrays +* Reference to Elements:: How to examine one element of an array. +* Assigning Elements:: How to change an element of an array. +* Array Example:: Basic Example of an Array +* Scanning an Array:: A variation of the `for' statement. It + loops through the indices of an array's + existing elements. +* Controlling Scanning:: Controlling the order in which arrays are + scanned. +* Delete:: The `delete' statement removes an + element from an array. +* Numeric Array Subscripts:: How to use numbers as subscripts in + `awk'. +* Uninitialized Subscripts:: Using Uninitialized variables as + subscripts. +* Multi-dimensional:: Emulating multidimensional arrays in + `awk'. +* Multi-scanning:: Scanning multidimensional arrays. +* Arrays of Arrays:: True multidimensional arrays. +* Built-in:: Summarizes the built-in functions. +* Calling Built-in:: How to call built-in functions. +* Numeric Functions:: Functions that work with numbers, including + `int()', `sin()' and + `rand()'. +* String Functions:: Functions for string manipulation, such as + `split()', `match()' and + `sprintf()'. +* Gory Details:: More than you want to know about `\' + and `&' with `sub()', + `gsub()', and `gensub()'. +* I/O Functions:: Functions for files and shell commands. +* Time Functions:: Functions for dealing with timestamps. +* Bitwise Functions:: Functions for bitwise operations. +* Type Functions:: Functions for type information. +* I18N Functions:: Functions for string translation. +* User-defined:: Describes User-defined functions in detail. +* Definition Syntax:: How to write definitions and what they + mean. +* Function Example:: An example function definition and what it + does. +* Function Caveats:: Things to watch out for. +* Calling A Function:: Don't use spaces. +* Variable Scope:: Controlling variable scope. +* Pass By Value/Reference:: Passing parameters. +* Return Statement:: Specifying the value a function returns. +* Dynamic Typing:: How variable types can change at runtime. +* Indirect Calls:: Choosing the function to call at runtime. +* I18N and L10N:: Internationalization and Localization. +* Explaining gettext:: How GNU `gettext' works. +* Programmer i18n:: Features for the programmer. +* Translator i18n:: Features for the translator. +* String Extraction:: Extracting marked strings. +* Printf Ordering:: Rearranging `printf' arguments. +* I18N Portability:: `awk'-level portability issues. +* I18N Example:: A simple i18n example. +* Gawk I18N:: `gawk' is also internationalized. +* Nondecimal Data:: Allowing nondecimal input data. +* Array Sorting:: Facilities for controlling array traversal + and sorting arrays. +* Controlling Array Traversal:: How to use PROCINFO["sorted_in"]. +* Array Sorting Functions:: How to use `asort()' and + `asorti()'. +* Two-way I/O:: Two-way communications with another + process. +* TCP/IP Networking:: Using `gawk' for network + programming. +* Profiling:: Profiling your `awk' programs. +* Library Names:: How to best name private global variables + in library functions. +* General Functions:: Functions that are of general use. +* Strtonum Function:: A replacement for the built-in + `strtonum()' function. +* Assert Function:: A function for assertions in `awk' + programs. +* Round Function:: A function for rounding if `sprintf()' + does not do it correctly. +* Cliff Random Function:: The Cliff Random Number Generator. +* Ordinal Functions:: Functions for using characters as numbers + and vice versa. +* Join Function:: A function to join an array into a string. +* Gettimeofday Function:: A function to get formatted times. +* Data File Management:: Functions for managing command-line data + files. +* Filetrans Function:: A function for handling data file + transitions. +* Rewind Function:: A function for rereading the current file. +* File Checking:: Checking that data files are readable. +* Empty Files:: Checking for zero-length files. +* Ignoring Assigns:: Treating assignments as file names. +* Getopt Function:: A function for processing command-line + arguments. +* Passwd Functions:: Functions for getting user information. +* Group Functions:: Functions for getting group information. +* Walking Arrays:: A function to walk arrays of arrays. +* Running Examples:: How to run these examples. +* Clones:: Clones of common utilities. +* Cut Program:: The `cut' utility. +* Egrep Program:: The `egrep' utility. +* Id Program:: The `id' utility. +* Split Program:: The `split' utility. +* Tee Program:: The `tee' utility. +* Uniq Program:: The `uniq' utility. +* Wc Program:: The `wc' utility. +* Miscellaneous Programs:: Some interesting `awk' programs. +* Dupword Program:: Finding duplicated words in a document. +* Alarm Program:: An alarm clock. +* Translate Program:: A program similar to the `tr' + utility. +* Labels Program:: Printing mailing labels. +* Word Sorting:: A program to produce a word usage count. +* History Sorting:: Eliminating duplicate entries from a + history file. +* Extract Program:: Pulling out programs from Texinfo source + files. +* Simple Sed:: A Simple Stream Editor. +* Igawk Program:: A wrapper for `awk' that includes + files. +* Anagram Program:: Finding anagrams from a dictionary. +* Signature Program:: People do amazing things with too much time + on their hands. +* Debugging:: Introduction to `dgawk'. +* Debugging Concepts:: Debugging In General. +* Debugging Terms:: Additional Debugging Concepts. +* Awk Debugging:: Awk Debugging. +* Sample dgawk session:: Sample `dgawk' session. +* dgawk invocation:: `dgawk' Invocation. +* Finding The Bug:: Finding The Bug. +* List of Debugger Commands:: Main `dgawk' Commands. +* Breakpoint Control:: Control of breakpoints. +* Dgawk Execution Control:: Control of execution. +* Viewing And Changing Data:: Viewing and changing data. +* Dgawk Stack:: Dealing with the stack. +* Dgawk Info:: Obtaining information about the program and + the debugger state. +* Miscellaneous Dgawk Commands:: Miscellaneous Commands. +* Readline Support:: Readline Support. +* Dgawk Limitations:: Limitations and future plans. +* V7/SVR3.1:: The major changes between V7 and System V + Release 3.1. +* SVR4:: Minor changes between System V Releases 3.1 + and 4. +* POSIX:: New features from the POSIX standard. +* BTL:: New features from Brian Kernighan's version + of `awk'. +* POSIX/GNU:: The extensions in `gawk' not in + POSIX `awk'. +* Common Extensions:: Common Extensions Summary. +* Ranges and Locales:: How locales used to affect regexp ranges. +* Contributors:: The major contributors to `gawk'. +* Gawk Distribution:: What is in the `gawk' distribution. +* Getting:: How to get the distribution. +* Extracting:: How to extract the distribution. +* Distribution contents:: What is in the distribution. +* Unix Installation:: Installing `gawk' under various + versions of Unix. +* Quick Installation:: Compiling `gawk' under Unix. +* Additional Configuration Options:: Other compile-time options. +* Configuration Philosophy:: How it's all supposed to work. +* Non-Unix Installation:: Installation on Other Operating Systems. +* PC Installation:: Installing and Compiling `gawk' on + MS-DOS and OS/2. +* PC Binary Installation:: Installing a prepared distribution. +* PC Compiling:: Compiling `gawk' for MS-DOS, + Windows32, and OS/2. +* PC Testing:: Testing `gawk' on PC systems. +* PC Using:: Running `gawk' on MS-DOS, Windows32 + and OS/2. +* Cygwin:: Building and running `gawk' for + Cygwin. +* MSYS:: Using `gawk' In The MSYS + Environment. +* VMS Installation:: Installing `gawk' on VMS. +* VMS Compilation:: How to compile `gawk' under VMS. +* VMS Installation Details:: How to install `gawk' under VMS. +* VMS Running:: How to run `gawk' under VMS. +* VMS Old Gawk:: An old version comes with some VMS systems. +* Bugs:: Reporting Problems and Bugs. +* Other Versions:: Other freely available `awk' + implementations. +* Compatibility Mode:: How to disable certain `gawk' + extensions. +* Additions:: Making Additions To `gawk'. +* Accessing The Source:: Accessing the Git repository. +* Adding Code:: Adding code to the main body of + `gawk'. +* New Ports:: Porting `gawk' to a new operating + system. +* Dynamic Extensions:: Adding new built-in functions to + `gawk'. +* Internals:: A brief look at some `gawk' + internals. +* Plugin License:: A note about licensing. +* Sample Library:: A example of new functions. +* Internal File Description:: What the new functions will do. +* Internal File Ops:: The code for internal file operations. +* Using Internal File Ops:: How to use an external extension. +* Future Extensions:: New features that may be implemented one + day. +* Basic High Level:: The high level view. +* Basic Data Typing:: A very quick intro to data types. +* Floating Point Issues:: Stuff to know about floating-point numbers. +* String Conversion Precision:: The String Value Can Lie. +* Unexpected Results:: Floating Point Numbers Are Not Abstract + Numbers. +* POSIX Floating Point Problems:: Standards Versus Existing Practice. + + To Miriam, for making me complete. + + To Chana, for the joy you bring us. + + To Rivka, for the exponential increase. + + To Nachum, for the added dimension. + + To Malka, for the new beginning. + +File: gawk.info, Node: Foreword, Next: Preface, Prev: Top, Up: Top + +Foreword +******** + +Arnold Robbins and I are good friends. We were introduced in 1990 by +circumstances--and our favorite programming language, AWK. The +circumstances started a couple of years earlier. I was working at a new +job and noticed an unplugged Unix computer sitting in the corner. No +one knew how to use it, and neither did I. However, a couple of days +later it was running, and I was `root' and the one-and-only user. That +day, I began the transition from statistician to Unix programmer. + + On one of many trips to the library or bookstore in search of books +on Unix, I found the gray AWK book, a.k.a. Aho, Kernighan and +Weinberger, `The AWK Programming Language', Addison-Wesley, 1988. +AWK's simple programming paradigm--find a pattern in the input and then +perform an action--often reduced complex or tedious data manipulations +to few lines of code. I was excited to try my hand at programming in +AWK. + + Alas, the `awk' on my computer was a limited version of the +language described in the AWK book. I discovered that my computer had +"old `awk'" and the AWK book described "new `awk'." I learned that +this was typical; the old version refused to step aside or relinquish +its name. If a system had a new `awk', it was invariably called +`nawk', and few systems had it. The best way to get a new `awk' was to +`ftp' the source code for `gawk' from `prep.ai.mit.edu'. `gawk' was a +version of new `awk' written by David Trueman and Arnold, and available +under the GNU General Public License. + + (Incidentally, it's no longer difficult to find a new `awk'. `gawk' +ships with GNU/Linux, and you can download binaries or source code for +almost any system; my wife uses `gawk' on her VMS box.) + + My Unix system started out unplugged from the wall; it certainly was +not plugged into a network. So, oblivious to the existence of `gawk' +and the Unix community in general, and desiring a new `awk', I wrote my +own, called `mawk'. Before I was finished I knew about `gawk', but it +was too late to stop, so I eventually posted to a `comp.sources' +newsgroup. + + A few days after my posting, I got a friendly email from Arnold +introducing himself. He suggested we share design and algorithms and +attached a draft of the POSIX standard so that I could update `mawk' to +support language extensions added after publication of the AWK book. + + Frankly, if our roles had been reversed, I would not have been so +open and we probably would have never met. I'm glad we did meet. He +is an AWK expert's AWK expert and a genuinely nice person. Arnold +contributes significant amounts of his expertise and time to the Free +Software Foundation. + + This book is the `gawk' reference manual, but at its core it is a +book about AWK programming that will appeal to a wide audience. It is +a definitive reference to the AWK language as defined by the 1987 Bell +Laboratories release and codified in the 1992 POSIX Utilities standard. + + On the other hand, the novice AWK programmer can study a wealth of +practical programs that emphasize the power of AWK's basic idioms: data +driven control-flow, pattern matching with regular expressions, and +associative arrays. Those looking for something new can try out +`gawk''s interface to network protocols via special `/inet' files. + + The programs in this book make clear that an AWK program is +typically much smaller and faster to develop than a counterpart written +in C. Consequently, there is often a payoff to prototype an algorithm +or design in AWK to get it running quickly and expose problems early. +Often, the interpreted performance is adequate and the AWK prototype +becomes the product. + + The new `pgawk' (profiling `gawk'), produces program execution +counts. I recently experimented with an algorithm that for n lines of +input, exhibited ~ C n^2 performance, while theory predicted ~ C n log n +behavior. A few minutes poring over the `awkprof.out' profile +pinpointed the problem to a single line of code. `pgawk' is a welcome +addition to my programmer's toolbox. + + Arnold has distilled over a decade of experience writing and using +AWK programs, and developing `gawk', into this book. If you use AWK or +want to learn how, then read this book. + + Michael Brennan + Author of `mawk' + March, 2001 + + +File: gawk.info, Node: Preface, Next: Getting Started, Prev: Foreword, Up: Top + +Preface +******* + +Several kinds of tasks occur repeatedly when working with text files. +You might want to extract certain lines and discard the rest. Or you +may need to make changes wherever certain patterns appear, but leave +the rest of the file alone. Writing single-use programs for these +tasks in languages such as C, C++, or Java is time-consuming and +inconvenient. Such jobs are often easier with `awk'. The `awk' +utility interprets a special-purpose programming language that makes it +easy to handle simple data-reformatting jobs. + + The GNU implementation of `awk' is called `gawk'; if you invoke it +with the proper options or environment variables (*note Options::), it +is fully compatible with the POSIX(1) specification of the `awk' +language and with the Unix version of `awk' maintained by Brian +Kernighan. This means that all properly written `awk' programs should +work with `gawk'. Thus, we usually don't distinguish between `gawk' +and other `awk' implementations. + + Using `awk' allows you to: + + * Manage small, personal databases + + * Generate reports + + * Validate data + + * Produce indexes and perform other document preparation tasks + + * Experiment with algorithms that you can adapt later to other + computer languages + + In addition, `gawk' provides facilities that make it easy to: + + * Extract bits and pieces of data for processing + + * Sort data + + * Perform simple network communications + + This Info file teaches you about the `awk' language and how you can +use it effectively. You should already be familiar with basic system +commands, such as `cat' and `ls',(2) as well as basic shell facilities, +such as input/output (I/O) redirection and pipes. + + Implementations of the `awk' language are available for many +different computing environments. This Info file, while describing the +`awk' language in general, also describes the particular implementation +of `awk' called `gawk' (which stands for "GNU awk"). `gawk' runs on a +broad range of Unix systems, ranging from Intel(R)-architecture +PC-based computers up through large-scale systems, such as Crays. +`gawk' has also been ported to Mac OS X, Microsoft Windows (all +versions) and OS/2 PCs, and VMS. (Some other, obsolete systems to +which `gawk' was once ported are no longer supported and the code for +those systems has been removed.) + +* Menu: + +* History:: The history of `gawk' and + `awk'. +* Names:: What name to use to find `awk'. +* This Manual:: Using this Info file. Includes sample + input files that you can use. +* Conventions:: Typographical Conventions. +* Manual History:: Brief history of the GNU project and this + Info file. +* How To Contribute:: Helping to save the world. +* Acknowledgments:: Acknowledgments. + + ---------- Footnotes ---------- + + (1) The 2008 POSIX standard can be found online at +`http://www.opengroup.org/onlinepubs/9699919799/'. + + (2) These commands are available on POSIX-compliant systems, as well +as on traditional Unix-based systems. If you are using some other +operating system, you still need to be familiar with the ideas of I/O +redirection and pipes. + + +File: gawk.info, Node: History, Next: Names, Up: Preface + +History of `awk' and `gawk' +=========================== + + Recipe For A Programming Language + + 1 part `egrep' 1 part `snobol' + 2 parts `ed' 3 parts C + + Blend all parts well using `lex' and `yacc'. Document minimally + and release. + + After eight years, add another part `egrep' and two more parts C. + Document very well and release. + + The name `awk' comes from the initials of its designers: Alfred V. +Aho, Peter J. Weinberger and Brian W. Kernighan. The original version +of `awk' was written in 1977 at AT&T Bell Laboratories. In 1985, a new +version made the programming language more powerful, introducing +user-defined functions, multiple input streams, and computed regular +expressions. This new version became widely available with Unix System +V Release 3.1 (1987). The version in System V Release 4 (1989) added +some new features and cleaned up the behavior in some of the "dark +corners" of the language. The specification for `awk' in the POSIX +Command Language and Utilities standard further clarified the language. +Both the `gawk' designers and the original Bell Laboratories `awk' +designers provided feedback for the POSIX specification. + + Paul Rubin wrote the GNU implementation, `gawk', in 1986. Jay +Fenlason completed it, with advice from Richard Stallman. John Woods +contributed parts of the code as well. In 1988 and 1989, David +Trueman, with help from me, thoroughly reworked `gawk' for compatibility +with the newer `awk'. Circa 1994, I became the primary maintainer. +Current development focuses on bug fixes, performance improvements, +standards compliance, and occasionally, new features. + + In May of 1997, Ju"rgen Kahrs felt the need for network access from +`awk', and with a little help from me, set about adding features to do +this for `gawk'. At that time, he also wrote the bulk of `TCP/IP +Internetworking with `gawk'' (a separate document, available as part of +the `gawk' distribution). His code finally became part of the main +`gawk' distribution with `gawk' version 3.1. + + John Haque rewrote the `gawk' internals, in the process providing an +`awk'-level debugger. This version became available as `gawk' version +4.0, in 2011. + + *Note Contributors::, for a complete list of those who made +important contributions to `gawk'. + + +File: gawk.info, Node: Names, Next: This Manual, Prev: History, Up: Preface + +A Rose by Any Other Name +======================== + +The `awk' language has evolved over the years. Full details are +provided in *note Language History::. The language described in this +Info file is often referred to as "new `awk'" (`nawk'). + + Because of this, there are systems with multiple versions of `awk'. +Some systems have an `awk' utility that implements the original version +of the `awk' language and a `nawk' utility for the new version. Others +have an `oawk' version for the "old `awk'" language and plain `awk' for +the new one. Still others only have one version, which is usually the +new one.(1) + + All in all, this makes it difficult for you to know which version of +`awk' you should run when writing your programs. The best advice we +can give here is to check your local documentation. Look for `awk', +`oawk', and `nawk', as well as for `gawk'. It is likely that you +already have some version of new `awk' on your system, which is what +you should use when running your programs. (Of course, if you're +reading this Info file, chances are good that you have `gawk'!) + + Throughout this Info file, whenever we refer to a language feature +that should be available in any complete implementation of POSIX `awk', +we simply use the term `awk'. When referring to a feature that is +specific to the GNU implementation, we use the term `gawk'. + + ---------- Footnotes ---------- + + (1) Often, these systems use `gawk' for their `awk' implementation! + + +File: gawk.info, Node: This Manual, Next: Conventions, Prev: Names, Up: Preface + +Using This Book +=============== + +The term `awk' refers to a particular program as well as to the +language you use to tell this program what to do. When we need to be +careful, we call the language "the `awk' language," and the program +"the `awk' utility." This Info file explains both how to write +programs in the `awk' language and how to run the `awk' utility. The +term "`awk' program" refers to a program written by you in the `awk' +programming language. + + Primarily, this Info file explains the features of `awk' as defined +in the POSIX standard. It does so in the context of the `gawk' +implementation. While doing so, it also attempts to describe important +differences between `gawk' and other `awk' implementations.(1) Finally, +any `gawk' features that are not in the POSIX standard for `awk' are +noted. + + There are subsections labeled as *Advanced Notes* scattered +throughout the Info file. They add a more complete explanation of +points that are relevant, but not likely to be of interest on first +reading. All appear in the index, under the heading "advanced +features." + + Most of the time, the examples use complete `awk' programs. Some of +the more advanced sections show only the part of the `awk' program that +illustrates the concept currently being described. + + While this Info file is aimed principally at people who have not been +exposed to `awk', there is a lot of information here that even the `awk' +expert should find useful. In particular, the description of POSIX +`awk' and the example programs in *note Library Functions::, and in +*note Sample Programs::, should be of interest. + + *note Getting Started::, provides the essentials you need to know to +begin using `awk'. + + *note Invoking Gawk::, describes how to run `gawk', the meaning of +its command-line options, and how it finds `awk' program source files. + + *note Regexp::, introduces regular expressions in general, and in +particular the flavors supported by POSIX `awk' and `gawk'. + + *note Reading Files::, describes how `awk' reads your data. It +introduces the concepts of records and fields, as well as the `getline' +command. I/O redirection is first described here. Network I/O is also +briefly introduced here. + + *note Printing::, describes how `awk' programs can produce output +with `print' and `printf'. + + *note Expressions::, describes expressions, which are the basic +building blocks for getting most things done in a program. + + *note Patterns and Actions::, describes how to write patterns for +matching records, actions for doing something when a record is matched, +and the built-in variables `awk' and `gawk' use. + + *note Arrays::, covers `awk''s one-and-only data structure: +associative arrays. Deleting array elements and whole arrays is also +described, as well as sorting arrays in `gawk'. It also describes how +`gawk' provides arrays of arrays. + + *note Functions::, describes the built-in functions `awk' and `gawk' +provide, as well as how to define your own functions. + + *note Internationalization::, describes special features in `gawk' +for translating program messages into different languages at runtime. + + *note Advanced Features::, describes a number of `gawk'-specific +advanced features. Of particular note are the abilities to have +two-way communications with another process, perform TCP/IP networking, +and profile your `awk' programs. + + *note Library Functions::, and *note Sample Programs::, provide many +sample `awk' programs. Reading them allows you to see `awk' solving +real problems. + + *note Debugger::, describes the `awk' debugger, `dgawk'. + + *note Language History::, describes how the `awk' language has +evolved since its first release to present. It also describes how +`gawk' has acquired features over time. + + *note Installation::, describes how to get `gawk', how to compile it +on POSIX-compatible systems, and how to compile and use it on different +non-POSIX systems. It also describes how to report bugs in `gawk' and +where to get other freely available `awk' implementations. + + *note Notes::, describes how to disable `gawk''s extensions, as well +as how to contribute new code to `gawk', how to write extension +libraries, and some possible future directions for `gawk' development. + + *note Basic Concepts::, provides some very cursory background +material for those who are completely unfamiliar with computer +programming. Also centralized there is a discussion of some of the +issues surrounding floating-point numbers. + + The *note Glossary::, defines most, if not all, the significant +terms used throughout the book. If you find terms that you aren't +familiar with, try looking them up here. + + *note Copying::, and *note GNU Free Documentation License::, present +the licenses that cover the `gawk' source code and this Info file, +respectively. + + ---------- Footnotes ---------- + + (1) All such differences appear in the index under the entry +"differences in `awk' and `gawk'." + + +File: gawk.info, Node: Conventions, Next: Manual History, Prev: This Manual, Up: Preface + +Typographical Conventions +========================= + +This Info file is written in Texinfo (http://texinfo.org), the GNU +documentation formatting language. A single Texinfo source file is +used to produce both the printed and online versions of the +documentation. This minor node briefly documents the typographical +conventions used in Texinfo. + + Examples you would type at the command-line are preceded by the +common shell primary and secondary prompts, `$' and `>'. Input that +you type is shown `like this'. Output from the command is preceded by +the glyph "-|". This typically represents the command's standard +output. Error messages, and other output on the command's standard +error, are preceded by the glyph "error-->". For example: + + $ echo hi on stdout + -| hi on stdout + $ echo hello on stderr 1>&2 + error--> hello on stderr + + Characters that you type at the keyboard look `like this'. In +particular, there are special characters called "control characters." +These are characters that you type by holding down both the `CONTROL' +key and another key, at the same time. For example, a `Ctrl-d' is typed +by first pressing and holding the `CONTROL' key, next pressing the `d' +key and finally releasing both keys. + +Dark Corners +............ + + Dark corners are basically fractal -- no matter how much you + illuminate, there's always a smaller but darker one. + Brian Kernighan + + Until the POSIX standard (and `GAWK: Effective AWK Programming'), +many features of `awk' were either poorly documented or not documented +at all. Descriptions of such features (often called "dark corners") +are noted in this Info file with "(d.c.)". They also appear in the +index under the heading "dark corner." + + As noted by the opening quote, though, any coverage of dark corners +is, by definition, incomplete. + + Extensions to the standard `awk' language that are supported by more +than one `awk' implementation are marked "(c.e.)," and listed in the +index under "common extensions" and "extensions, common." + + +File: gawk.info, Node: Manual History, Next: How To Contribute, Prev: Conventions, Up: Preface + +The GNU Project and This Book +============================= + +The Free Software Foundation (FSF) is a nonprofit organization dedicated +to the production and distribution of freely distributable software. +It was founded by Richard M. Stallman, the author of the original Emacs +editor. GNU Emacs is the most widely used version of Emacs today. + + The GNU(1) Project is an ongoing effort on the part of the Free +Software Foundation to create a complete, freely distributable, +POSIX-compliant computing environment. The FSF uses the "GNU General +Public License" (GPL) to ensure that their software's source code is +always available to the end user. A copy of the GPL is included for +your reference (*note Copying::). The GPL applies to the C language +source code for `gawk'. To find out more about the FSF and the GNU +Project online, see the GNU Project's home page (http://www.gnu.org). +This Info file may also be read from their web site +(http://www.gnu.org/software/gawk/manual/). + + A shell, an editor (Emacs), highly portable optimizing C, C++, and +Objective-C compilers, a symbolic debugger and dozens of large and +small utilities (such as `gawk'), have all been completed and are +freely available. The GNU operating system kernel (the HURD), has been +released but remains in an early stage of development. + + Until the GNU operating system is more fully developed, you should +consider using GNU/Linux, a freely distributable, Unix-like operating +system for Intel(R), Power Architecture, Sun SPARC, IBM S/390, and other +systems.(2) Many GNU/Linux distributions are available for download +from the Internet. + + (There are numerous other freely available, Unix-like operating +systems based on the Berkeley Software Distribution, and some of them +use recent versions of `gawk' for their versions of `awk'. NetBSD +(http://www.netbsd.org), FreeBSD (http://www.freebsd.org), and OpenBSD +(http://www.openbsd.org) are three of the most popular ones, but there +are others.) + + The Info file itself has gone through a number of previous editions. +Paul Rubin wrote the very first draft of `The GAWK Manual'; it was +around 40 pages in size. Diane Close and Richard Stallman improved it, +yielding a version that was around 90 pages long and barely described +the original, "old" version of `awk'. + + I started working with that version in the fall of 1988. As work on +it progressed, the FSF published several preliminary versions (numbered +0.X). In 1996, Edition 1.0 was released with `gawk' 3.0.0. The FSF +published the first two editions under the title `The GNU Awk User's +Guide'. + + This edition maintains the basic structure of the previous editions. +For Edition 4.0, the content has been thoroughly reviewed and updated. +All references to versions prior to 4.0 have been removed. Of +significant note for this edition is *note Debugger::. + + `GAWK: Effective AWK Programming' will undoubtedly continue to +evolve. An electronic version comes with the `gawk' distribution from +the FSF. If you find an error in this Info file, please report it! +*Note Bugs::, for information on submitting problem reports +electronically. + + ---------- Footnotes ---------- + + (1) GNU stands for "GNU's not Unix." + + (2) The terminology "GNU/Linux" is explained in the *note Glossary::. + + +File: gawk.info, Node: How To Contribute, Next: Acknowledgments, Prev: Manual History, Up: Preface + +How to Contribute +================= + +As the maintainer of GNU `awk', I once thought that I would be able to +manage a collection of publicly available `awk' programs and I even +solicited contributions. Making things available on the Internet helps +keep the `gawk' distribution down to manageable size. + + The initial collection of material, such as it is, is still available +at `ftp://ftp.freefriends.org/arnold/Awkstuff'. In the hopes of doing +something more broad, I acquired the `awk.info' domain. + + However, I found that I could not dedicate enough time to managing +contributed code: the archive did not grow and the domain went unused +for several years. + + Fortunately, late in 2008, a volunteer took on the task of setting up +an `awk'-related web site--`http://awk.info'--and did a very nice job. + + If you have written an interesting `awk' program, or have written a +`gawk' extension that you would like to share with the rest of the +world, please see `http://awk.info/?contribute' for how to contribute +it to the web site. + + +File: gawk.info, Node: Acknowledgments, Prev: How To Contribute, Up: Preface + +Acknowledgments +=============== + +The initial draft of `The GAWK Manual' had the following +acknowledgments: + + Many people need to be thanked for their assistance in producing + this manual. Jay Fenlason contributed many ideas and sample + programs. Richard Mlynarik and Robert Chassell gave helpful + comments on drafts of this manual. The paper `A Supplemental + Document for `awk'' by John W. Pierce of the Chemistry Department + at UC San Diego, pinpointed several issues relevant both to `awk' + implementation and to this manual, that would otherwise have + escaped us. + + I would like to acknowledge Richard M. Stallman, for his vision of a +better world and for his courage in founding the FSF and starting the +GNU Project. + + Earlier editions of this Info file had the following +acknowledgements: + + The following people (in alphabetical order) provided helpful + comments on various versions of this book, Rick Adams, Dr. Nelson + H.F. Beebe, Karl Berry, Dr. Michael Brennan, Rich Burridge, Claire + Cloutier, Diane Close, Scott Deifik, Christopher ("Topher") Eliot, + Jeffrey Friedl, Dr. Darrel Hankerson, Michal Jaegermann, Dr. + Richard J. LeBlanc, Michael Lijewski, Pat Rankin, Miriam Robbins, + Mary Sheehan, and Chuck Toporek. + + Robert J. Chassell provided much valuable advice on the use of + Texinfo. He also deserves special thanks for convincing me _not_ + to title this Info file `How To Gawk Politely'. Karl Berry helped + significantly with the TeX part of Texinfo. + + I would like to thank Marshall and Elaine Hartholz of Seattle and + Dr. Bert and Rita Schreiber of Detroit for large amounts of quiet + vacation time in their homes, which allowed me to make significant + progress on this Info file and on `gawk' itself. + + Phil Hughes of SSC contributed in a very important way by loaning + me his laptop GNU/Linux system, not once, but twice, which allowed + me to do a lot of work while away from home. + + David Trueman deserves special credit; he has done a yeoman job of + evolving `gawk' so that it performs well and without bugs. + Although he is no longer involved with `gawk', working with him on + this project was a significant pleasure. + + The intrepid members of the GNITS mailing list, and most notably + Ulrich Drepper, provided invaluable help and feedback for the + design of the internationalization features. + + Chuck Toporek, Mary Sheehan, and Claire Coutier of O'Reilly & + Associates contributed significant editorial help for this Info + file for the 3.1 release of `gawk'. + + Dr. Nelson Beebe, Andreas Buening, Antonio Colombo, Stephen Davies, +Scott Deifik, John H. DuBois III, Darrel Hankerson, Michal Jaegermann, +Ju"rgen Kahrs, Dave Pitts, Stepan Kasal, Pat Rankin, Andrew Schorr, +Corinna Vinschen, Anders Wallin, and Eli Zaretskii (in alphabetical +order) make up the current `gawk' "crack portability team." Without +their hard work and help, `gawk' would not be nearly the fine program +it is today. It has been and continues to be a pleasure working with +this team of fine people. + + John Haque contributed the modifications to convert `gawk' into a +byte-code interpreter, including the debugger. Stephen Davies +contributed to the effort to bring the byte-code changes into the +mainstream code base. Efraim Yawitz contributed the initial text of +*note Debugger::. + + I would like to thank Brian Kernighan for invaluable assistance +during the testing and debugging of `gawk', and for ongoing help and +advice in clarifying numerous points about the language. We could not +have done nearly as good a job on either `gawk' or its documentation +without his help. + + I must thank my wonderful wife, Miriam, for her patience through the +many versions of this project, for her proofreading, and for sharing me +with the computer. I would like to thank my parents for their love, +and for the grace with which they raised and educated me. Finally, I +also must acknowledge my gratitude to G-d, for the many opportunities +He has sent my way, as well as for the gifts He has given me with which +to take advantage of those opportunities. + + +Arnold Robbins +Nof Ayalon +ISRAEL +March, 2011 + + +File: gawk.info, Node: Getting Started, Next: Invoking Gawk, Prev: Preface, Up: Top + +1 Getting Started with `awk' +**************************** + +The basic function of `awk' is to search files for lines (or other +units of text) that contain certain patterns. When a line matches one +of the patterns, `awk' performs specified actions on that line. `awk' +keeps processing input lines in this way until it reaches the end of +the input files. + + Programs in `awk' are different from programs in most other +languages, because `awk' programs are "data-driven"; that is, you +describe the data you want to work with and then what to do when you +find it. Most other languages are "procedural"; you have to describe, +in great detail, every step the program is to take. When working with +procedural languages, it is usually much harder to clearly describe the +data your program will process. For this reason, `awk' programs are +often refreshingly easy to read and write. + + When you run `awk', you specify an `awk' "program" that tells `awk' +what to do. The program consists of a series of "rules". (It may also +contain "function definitions", an advanced feature that we will ignore +for now. *Note User-defined::.) Each rule specifies one pattern to +search for and one action to perform upon finding the pattern. + + Syntactically, a rule consists of a pattern followed by an action. +The action is enclosed in curly braces to separate it from the pattern. +Newlines usually separate rules. Therefore, an `awk' program looks +like this: + + PATTERN { ACTION } + PATTERN { ACTION } + ... + +* Menu: + +* Running gawk:: How to run `gawk' programs; includes + command-line syntax. +* Sample Data Files:: Sample data files for use in the `awk' + programs illustrated in this Info file. +* Very Simple:: A very simple example. +* Two Rules:: A less simple one-line example using two + rules. +* More Complex:: A more complex example. +* Statements/Lines:: Subdividing or combining statements into + lines. +* Other Features:: Other Features of `awk'. +* When:: When to use `gawk' and when to use + other things. + + +File: gawk.info, Node: Running gawk, Next: Sample Data Files, Up: Getting Started + +1.1 How to Run `awk' Programs +============================= + +There are several ways to run an `awk' program. If the program is +short, it is easiest to include it in the command that runs `awk', like +this: + + awk 'PROGRAM' INPUT-FILE1 INPUT-FILE2 ... + + When the program is long, it is usually more convenient to put it in +a file and run it with a command like this: + + awk -f PROGRAM-FILE INPUT-FILE1 INPUT-FILE2 ... + + This minor node discusses both mechanisms, along with several +variations of each. + +* Menu: + +* One-shot:: Running a short throwaway `awk' + program. +* Read Terminal:: Using no input files (input from terminal + instead). +* Long:: Putting permanent `awk' programs in + files. +* Executable Scripts:: Making self-contained `awk' programs. +* Comments:: Adding documentation to `gawk' + programs. +* Quoting:: More discussion of shell quoting issues. + + +File: gawk.info, Node: One-shot, Next: Read Terminal, Up: Running gawk + +1.1.1 One-Shot Throwaway `awk' Programs +--------------------------------------- + +Once you are familiar with `awk', you will often type in simple +programs the moment you want to use them. Then you can write the +program as the first argument of the `awk' command, like this: + + awk 'PROGRAM' INPUT-FILE1 INPUT-FILE2 ... + +where PROGRAM consists of a series of PATTERNS and ACTIONS, as +described earlier. + + This command format instructs the "shell", or command interpreter, +to start `awk' and use the PROGRAM to process records in the input +file(s). There are single quotes around PROGRAM so the shell won't +interpret any `awk' characters as special shell characters. The quotes +also cause the shell to treat all of PROGRAM as a single argument for +`awk', and allow PROGRAM to be more than one line long. + + This format is also useful for running short or medium-sized `awk' +programs from shell scripts, because it avoids the need for a separate +file for the `awk' program. A self-contained shell script is more +reliable because there are no other files to misplace. + + *note Very Simple::, presents several short, self-contained programs. + + +File: gawk.info, Node: Read Terminal, Next: Long, Prev: One-shot, Up: Running gawk + +1.1.2 Running `awk' Without Input Files +--------------------------------------- + +You can also run `awk' without any input files. If you type the +following command line: + + awk 'PROGRAM' + +`awk' applies the PROGRAM to the "standard input", which usually means +whatever you type on the terminal. This continues until you indicate +end-of-file by typing `Ctrl-d'. (On other operating systems, the +end-of-file character may be different. For example, on OS/2, it is +`Ctrl-z'.) + + As an example, the following program prints a friendly piece of +advice (from Douglas Adams's `The Hitchhiker's Guide to the Galaxy'), +to keep you from worrying about the complexities of computer +programming(1) (`BEGIN' is a feature we haven't discussed yet): + + $ awk "BEGIN { print \"Don't Panic!\" }" + -| Don't Panic! + + This program does not read any input. The `\' before each of the +inner double quotes is necessary because of the shell's quoting +rules--in particular because it mixes both single quotes and double +quotes.(2) + + This next simple `awk' program emulates the `cat' utility; it copies +whatever you type on the keyboard to its standard output (why this +works is explained shortly). + + $ awk '{ print }' + Now is the time for all good men + -| Now is the time for all good men + to come to the aid of their country. + -| to come to the aid of their country. + Four score and seven years ago, ... + -| Four score and seven years ago, ... + What, me worry? + -| What, me worry? + Ctrl-d + + ---------- Footnotes ---------- + + (1) If you use Bash as your shell, you should execute the command +`set +H' before running this program interactively, to disable the C +shell-style command history, which treats `!' as a special character. +We recommend putting this command into your personal startup file. + + (2) Although we generally recommend the use of single quotes around +the program text, double quotes are needed here in order to put the +single quote into the message. + + +File: gawk.info, Node: Long, Next: Executable Scripts, Prev: Read Terminal, Up: Running gawk + +1.1.3 Running Long Programs +--------------------------- + +Sometimes your `awk' programs can be very long. In this case, it is +more convenient to put the program into a separate file. In order to +tell `awk' to use that file for its program, you type: + + awk -f SOURCE-FILE INPUT-FILE1 INPUT-FILE2 ... + + The `-f' instructs the `awk' utility to get the `awk' program from +the file SOURCE-FILE. Any file name can be used for SOURCE-FILE. For +example, you could put the program: + + BEGIN { print "Don't Panic!" } + +into the file `advice'. Then this command: + + awk -f advice + +does the same thing as this one: + + awk "BEGIN { print \"Don't Panic!\" }" + +This was explained earlier (*note Read Terminal::). Note that you +don't usually need single quotes around the file name that you specify +with `-f', because most file names don't contain any of the shell's +special characters. Notice that in `advice', the `awk' program did not +have single quotes around it. The quotes are only needed for programs +that are provided on the `awk' command line. + + If you want to clearly identify your `awk' program files as such, +you can add the extension `.awk' to the file name. This doesn't affect +the execution of the `awk' program but it does make "housekeeping" +easier. + + +File: gawk.info, Node: Executable Scripts, Next: Comments, Prev: Long, Up: Running gawk + +1.1.4 Executable `awk' Programs +------------------------------- + +Once you have learned `awk', you may want to write self-contained `awk' +scripts, using the `#!' script mechanism. You can do this on many +systems.(1) For example, you could update the file `advice' to look +like this: + + #! /bin/awk -f + + BEGIN { print "Don't Panic!" } + +After making this file executable (with the `chmod' utility), simply +type `advice' at the shell and the system arranges to run `awk'(2) as +if you had typed `awk -f advice': + + $ chmod +x advice + $ advice + -| Don't Panic! + +(We assume you have the current directory in your shell's search path +variable [typically `$PATH']. If not, you may need to type `./advice' +at the shell.) + + Self-contained `awk' scripts are useful when you want to write a +program that users can invoke without their having to know that the +program is written in `awk'. + +Advanced Notes: Portability Issues with `#!' +-------------------------------------------- + +Some systems limit the length of the interpreter name to 32 characters. +Often, this can be dealt with by using a symbolic link. + + You should not put more than one argument on the `#!' line after the +path to `awk'. It does not work. The operating system treats the rest +of the line as a single argument and passes it to `awk'. Doing this +leads to confusing behavior--most likely a usage diagnostic of some +sort from `awk'. + + Finally, the value of `ARGV[0]' (*note Built-in Variables::) varies +depending upon your operating system. Some systems put `awk' there, +some put the full pathname of `awk' (such as `/bin/awk'), and some put +the name of your script (`advice'). (d.c.) Don't rely on the value of +`ARGV[0]' to provide your script name. + + ---------- Footnotes ---------- + + (1) The `#!' mechanism works on GNU/Linux systems, BSD-based systems +and commercial Unix systems. + + (2) The line beginning with `#!' lists the full file name of an +interpreter to run and an optional initial command-line argument to +pass to that interpreter. The operating system then runs the +interpreter with the given argument and the full argument list of the +executed program. The first argument in the list is the full file name +of the `awk' program. The rest of the argument list contains either +options to `awk', or data files, or both. Note that on many systems +`awk' may be found in `/usr/bin' instead of in `/bin'. Caveat Emptor. + + +File: gawk.info, Node: Comments, Next: Quoting, Prev: Executable Scripts, Up: Running gawk + +1.1.5 Comments in `awk' Programs +-------------------------------- + +A "comment" is some text that is included in a program for the sake of +human readers; it is not really an executable part of the program. +Comments can explain what the program does and how it works. Nearly all +programming languages have provisions for comments, as programs are +typically hard to understand without them. + + In the `awk' language, a comment starts with the sharp sign +character (`#') and continues to the end of the line. The `#' does not +have to be the first character on the line. The `awk' language ignores +the rest of a line following a sharp sign. For example, we could have +put the following into `advice': + + # This program prints a nice friendly message. It helps + # keep novice users from being afraid of the computer. + BEGIN { print "Don't Panic!" } + + You can put comment lines into keyboard-composed throwaway `awk' +programs, but this usually isn't very useful; the purpose of a comment +is to help you or another person understand the program when reading it +at a later time. + + CAUTION: As mentioned in *note One-shot::, you can enclose small + to medium programs in single quotes, in order to keep your shell + scripts self-contained. When doing so, _don't_ put an apostrophe + (i.e., a single quote) into a comment (or anywhere else in your + program). The shell interprets the quote as the closing quote for + the entire program. As a result, usually the shell prints a + message about mismatched quotes, and if `awk' actually runs, it + will probably print strange messages about syntax errors. For + example, look at the following: + + $ awk '{ print "hello" } # let's be cute' + > + + The shell sees that the first two quotes match, and that a new + quoted object begins at the end of the command line. It therefore + prompts with the secondary prompt, waiting for more input. With + Unix `awk', closing the quoted string produces this result: + + $ awk '{ print "hello" } # let's be cute' + > ' + error--> awk: can't open file be + error--> source line number 1 + + Putting a backslash before the single quote in `let's' wouldn't + help, since backslashes are not special inside single quotes. The + next node describes the shell's quoting rules. + + +File: gawk.info, Node: Quoting, Prev: Comments, Up: Running gawk + +1.1.6 Shell-Quoting Issues +-------------------------- + +* Menu: + +* DOS Quoting:: Quoting in Windows Batch Files. + + For short to medium length `awk' programs, it is most convenient to +enter the program on the `awk' command line. This is best done by +enclosing the entire program in single quotes. This is true whether +you are entering the program interactively at the shell prompt, or +writing it as part of a larger shell script: + + awk 'PROGRAM TEXT' INPUT-FILE1 INPUT-FILE2 ... + + Once you are working with the shell, it is helpful to have a basic +knowledge of shell quoting rules. The following rules apply only to +POSIX-compliant, Bourne-style shells (such as Bash, the GNU Bourne-Again +Shell). If you use the C shell, you're on your own. + + * Quoted items can be concatenated with nonquoted items as well as + with other quoted items. The shell turns everything into one + argument for the command. + + * Preceding any single character with a backslash (`\') quotes that + character. The shell removes the backslash and passes the quoted + character on to the command. + + * Single quotes protect everything between the opening and closing + quotes. The shell does no interpretation of the quoted text, + passing it on verbatim to the command. It is _impossible_ to + embed a single quote inside single-quoted text. Refer back to + *note Comments::, for an example of what happens if you try. + + * Double quotes protect most things between the opening and closing + quotes. The shell does at least variable and command substitution + on the quoted text. Different shells may do additional kinds of + processing on double-quoted text. + + Since certain characters within double-quoted text are processed + by the shell, they must be "escaped" within the text. Of note are + the characters `$', ``', `\', and `"', all of which must be + preceded by a backslash within double-quoted text if they are to + be passed on literally to the program. (The leading backslash is + stripped first.) Thus, the example seen in *note Read Terminal::, + is applicable: + + $ awk "BEGIN { print \"Don't Panic!\" }" + -| Don't Panic! + + Note that the single quote is not special within double quotes. + + * Null strings are removed when they occur as part of a non-null + command-line argument, while explicit non-null objects are kept. + For example, to specify that the field separator `FS' should be + set to the null string, use: + + awk -F "" 'PROGRAM' FILES # correct + + Don't use this: + + awk -F"" 'PROGRAM' FILES # wrong! + + In the second case, `awk' will attempt to use the text of the + program as the value of `FS', and the first file name as the text + of the program! This results in syntax errors at best, and + confusing behavior at worst. + + Mixing single and double quotes is difficult. You have to resort to +shell quoting tricks, like this: + + $ awk 'BEGIN { print "Here is a single quote <'"'"'>" }' + -| Here is a single quote <'> + +This program consists of three concatenated quoted strings. The first +and the third are single-quoted, the second is double-quoted. + + This can be "simplified" to: + + $ awk 'BEGIN { print "Here is a single quote <'\''>" }' + -| Here is a single quote <'> + +Judge for yourself which of these two is the more readable. + + Another option is to use double quotes, escaping the embedded, +`awk'-level double quotes: + + $ awk "BEGIN { print \"Here is a single quote <'>\" }" + -| Here is a single quote <'> + +This option is also painful, because double quotes, backslashes, and +dollar signs are very common in more advanced `awk' programs. + + A third option is to use the octal escape sequence equivalents +(*note Escape Sequences::) for the single- and double-quote characters, +like so: + + $ awk 'BEGIN { print "Here is a single quote <\47>" }' + -| Here is a single quote <'> + $ awk 'BEGIN { print "Here is a double quote <\42>" }' + -| Here is a double quote <"> + +This works nicely, except that you should comment clearly what the +escapes mean. + + A fourth option is to use command-line variable assignment, like +this: + + $ awk -v sq="'" 'BEGIN { print "Here is a single quote <" sq ">" }' + -| Here is a single quote <'> + + If you really need both single and double quotes in your `awk' +program, it is probably best to move it into a separate file, where the +shell won't be part of the picture, and you can say what you mean. + + +File: gawk.info, Node: DOS Quoting, Up: Quoting + +1.1.6.1 Quoting in MS-Windows Batch Files +......................................... + +Although this Info file generally only worries about POSIX systems and +the POSIX shell, the following issue arises often enough for many users +that it is worth addressing. + + The "shells" on Microsoft Windows systems use the double-quote +character for quoting, and make it difficult or impossible to include an +escaped double-quote character in a command-line script. The following +example, courtesy of Jeroen Brink, shows how to print all lines in a +file surrounded by double quotes: + + gawk "{ print \"\042\" $0 \"\042\" }" FILE + + +File: gawk.info, Node: Sample Data Files, Next: Very Simple, Prev: Running gawk, Up: Getting Started + +1.2 Data Files for the Examples +=============================== + +Many of the examples in this Info file take their input from two sample +data files. The first, `BBS-list', represents a list of computer +bulletin board systems together with information about those systems. +The second data file, called `inventory-shipped', contains information +about monthly shipments. In both files, each line is considered to be +one "record". + + In the data file `BBS-list', each record contains the name of a +computer bulletin board, its phone number, the board's baud rate(s), +and a code for the number of hours it is operational. An `A' in the +last column means the board operates 24 hours a day. A `B' in the last +column means the board only operates on evening and weekend hours. A +`C' means the board operates only on weekends: + + aardvark 555-5553 1200/300 B + alpo-net 555-3412 2400/1200/300 A + barfly 555-7685 1200/300 A + bites 555-1675 2400/1200/300 A + camelot 555-0542 300 C + core 555-2912 1200/300 C + fooey 555-1234 2400/1200/300 B + foot 555-6699 1200/300 B + macfoo 555-6480 1200/300 A + sdace 555-3430 2400/1200/300 A + sabafoo 555-2127 1200/300 C + + The data file `inventory-shipped' represents information about +shipments during the year. Each record contains the month, the number +of green crates shipped, the number of red boxes shipped, the number of +orange bags shipped, and the number of blue packages shipped, +respectively. There are 16 entries, covering the 12 months of last year +and the first four months of the current year. + + Jan 13 25 15 115 + Feb 15 32 24 226 + Mar 15 24 34 228 + Apr 31 52 63 420 + May 16 34 29 208 + Jun 31 42 75 492 + Jul 24 34 67 436 + Aug 15 34 47 316 + Sep 13 55 37 277 + Oct 29 54 68 525 + Nov 20 87 82 577 + Dec 17 35 61 401 + + Jan 21 36 64 620 + Feb 26 58 80 652 + Mar 24 75 70 495 + Apr 21 70 74 514 + + If you are reading this in GNU Emacs using Info, you can copy the +regions of text showing these sample files into your own test files. +This way you can try out the examples shown in the remainder of this +document. You do this by using the command `M-x write-region' to copy +text from the Info file into a file for use with `awk' (*Note +Miscellaneous File Operations: (emacs)Misc File Ops, for more +information). Using this information, create your own `BBS-list' and +`inventory-shipped' files and practice what you learn in this Info file. + + If you are using the stand-alone version of Info, see *note Extract +Program::, for an `awk' program that extracts these data files from +`gawk.texi', the Texinfo source file for this Info file. + + +File: gawk.info, Node: Very Simple, Next: Two Rules, Prev: Sample Data Files, Up: Getting Started + +1.3 Some Simple Examples +======================== + +The following command runs a simple `awk' program that searches the +input file `BBS-list' for the character string `foo' (a grouping of +characters is usually called a "string"; the term "string" is based on +similar usage in English, such as "a string of pearls," or "a string of +cars in a train"): + + awk '/foo/ { print $0 }' BBS-list + +When lines containing `foo' are found, they are printed because +`print $0' means print the current line. (Just `print' by itself means +the same thing, so we could have written that instead.) + + You will notice that slashes (`/') surround the string `foo' in the +`awk' program. The slashes indicate that `foo' is the pattern to +search for. This type of pattern is called a "regular expression", +which is covered in more detail later (*note Regexp::). The pattern is +allowed to match parts of words. There are single quotes around the +`awk' program so that the shell won't interpret any of it as special +shell characters. + + Here is what this program prints: + + $ awk '/foo/ { print $0 }' BBS-list + -| fooey 555-1234 2400/1200/300 B + -| foot 555-6699 1200/300 B + -| macfoo 555-6480 1200/300 A + -| sabafoo 555-2127 1200/300 C + + In an `awk' rule, either the pattern or the action can be omitted, +but not both. If the pattern is omitted, then the action is performed +for _every_ input line. If the action is omitted, the default action +is to print all lines that match the pattern. + + Thus, we could leave out the action (the `print' statement and the +curly braces) in the previous example and the result would be the same: +`awk' prints all lines matching the pattern `foo'. By comparison, +omitting the `print' statement but retaining the curly braces makes an +empty action that does nothing (i.e., no lines are printed). + + Many practical `awk' programs are just a line or two. Following is a +collection of useful, short programs to get you started. Some of these +programs contain constructs that haven't been covered yet. (The +description of the program will give you a good idea of what is going +on, but please read the rest of the Info file to become an `awk' +expert!) Most of the examples use a data file named `data'. This is +just a placeholder; if you use these programs yourself, substitute your +own file names for `data'. For future reference, note that there is +often more than one way to do things in `awk'. At some point, you may +want to look back at these examples and see if you can come up with +different ways to do the same things shown here: + + * Print the length of the longest input line: + + awk '{ if (length($0) > max) max = length($0) } + END { print max }' data + + * Print every line that is longer than 80 characters: + + awk 'length($0) > 80' data + + The sole rule has a relational expression as its pattern and it + has no action--so the default action, printing the record, is used. + + * Print the length of the longest line in `data': + + expand data | awk '{ if (x < length()) x = length() } + END { print "maximum line length is " x }' + + The input is processed by the `expand' utility to change TABs into + spaces, so the widths compared are actually the right-margin + columns. + + * Print every line that has at least one field: + + awk 'NF > 0' data + + This is an easy way to delete blank lines from a file (or rather, + to create a new file similar to the old file but from which the + blank lines have been removed). + + * Print seven random numbers from 0 to 100, inclusive: + + awk 'BEGIN { for (i = 1; i <= 7; i++) + print int(101 * rand()) }' + + * Print the total number of bytes used by FILES: + + ls -l FILES | awk '{ x += $5 } + END { print "total bytes: " x }' + + * Print the total number of kilobytes used by FILES: + + ls -l FILES | awk '{ x += $5 } + END { print "total K-bytes:", x / 1024 }' + + * Print a sorted list of the login names of all users: + + awk -F: '{ print $1 }' /etc/passwd | sort + + * Count the lines in a file: + + awk 'END { print NR }' data + + * Print the even-numbered lines in the data file: + + awk 'NR % 2 == 0' data + + If you use the expression `NR % 2 == 1' instead, the program would + print the odd-numbered lines. + + +File: gawk.info, Node: Two Rules, Next: More Complex, Prev: Very Simple, Up: Getting Started + +1.4 An Example with Two Rules +============================= + +The `awk' utility reads the input files one line at a time. For each +line, `awk' tries the patterns of each of the rules. If several +patterns match, then several actions are run in the order in which they +appear in the `awk' program. If no patterns match, then no actions are +run. + + After processing all the rules that match the line (and perhaps +there are none), `awk' reads the next line. (However, *note Next +Statement::, and also *note Nextfile Statement::). This continues +until the program reaches the end of the file. For example, the +following `awk' program contains two rules: + + /12/ { print $0 } + /21/ { print $0 } + +The first rule has the string `12' as the pattern and `print $0' as the +action. The second rule has the string `21' as the pattern and also +has `print $0' as the action. Each rule's action is enclosed in its +own pair of braces. + + This program prints every line that contains the string `12' _or_ +the string `21'. If a line contains both strings, it is printed twice, +once by each rule. + + This is what happens if we run this program on our two sample data +files, `BBS-list' and `inventory-shipped': + + $ awk '/12/ { print $0 } + > /21/ { print $0 }' BBS-list inventory-shipped + -| aardvark 555-5553 1200/300 B + -| alpo-net 555-3412 2400/1200/300 A + -| barfly 555-7685 1200/300 A + -| bites 555-1675 2400/1200/300 A + -| core 555-2912 1200/300 C + -| fooey 555-1234 2400/1200/300 B + -| foot 555-6699 1200/300 B + -| macfoo 555-6480 1200/300 A + -| sdace 555-3430 2400/1200/300 A + -| sabafoo 555-2127 1200/300 C + -| sabafoo 555-2127 1200/300 C + -| Jan 21 36 64 620 + -| Apr 21 70 74 514 + +Note how the line beginning with `sabafoo' in `BBS-list' was printed +twice, once for each rule. + + +File: gawk.info, Node: More Complex, Next: Statements/Lines, Prev: Two Rules, Up: Getting Started + +1.5 A More Complex Example +========================== + +Now that we've mastered some simple tasks, let's look at what typical +`awk' programs do. This example shows how `awk' can be used to +summarize, select, and rearrange the output of another utility. It uses +features that haven't been covered yet, so don't worry if you don't +understand all the details: + + LC_ALL=C ls -l | awk '$6 == "Nov" { sum += $5 } + END { print sum }' + + This command prints the total number of bytes in all the files in the +current directory that were last modified in November (of any year). +The `ls -l' part of this example is a system command that gives you a +listing of the files in a directory, including each file's size and the +date the file was last modified. Its output looks like this: + + -rw-r--r-- 1 arnold user 1933 Nov 7 13:05 Makefile + -rw-r--r-- 1 arnold user 10809 Nov 7 13:03 awk.h + -rw-r--r-- 1 arnold user 983 Apr 13 12:14 awk.tab.h + -rw-r--r-- 1 arnold user 31869 Jun 15 12:20 awkgram.y + -rw-r--r-- 1 arnold user 22414 Nov 7 13:03 awk1.c + -rw-r--r-- 1 arnold user 37455 Nov 7 13:03 awk2.c + -rw-r--r-- 1 arnold user 27511 Dec 9 13:07 awk3.c + -rw-r--r-- 1 arnold user 7989 Nov 7 13:03 awk4.c + +The first field contains read-write permissions, the second field +contains the number of links to the file, and the third field +identifies the owner of the file. The fourth field identifies the group +of the file. The fifth field contains the size of the file in bytes. +The sixth, seventh, and eighth fields contain the month, day, and time, +respectively, that the file was last modified. Finally, the ninth field +contains the file name.(1) + + The `$6 == "Nov"' in our `awk' program is an expression that tests +whether the sixth field of the output from `ls -l' matches the string +`Nov'. Each time a line has the string `Nov' for its sixth field, the +action `sum += $5' is performed. This adds the fifth field (the file's +size) to the variable `sum'. As a result, when `awk' has finished +reading all the input lines, `sum' is the total of the sizes of the +files whose lines matched the pattern. (This works because `awk' +variables are automatically initialized to zero.) + + After the last line of output from `ls' has been processed, the +`END' rule executes and prints the value of `sum'. In this example, +the value of `sum' is 80600. + + These more advanced `awk' techniques are covered in later sections +(*note Action Overview::). Before you can move on to more advanced +`awk' programming, you have to know how `awk' interprets your input and +displays your output. By manipulating fields and using `print' +statements, you can produce some very useful and impressive-looking +reports. + + ---------- Footnotes ---------- + + (1) The `LC_ALL=C' is needed to produce this traditional-style +output from `ls'. + + +File: gawk.info, Node: Statements/Lines, Next: Other Features, Prev: More Complex, Up: Getting Started + +1.6 `awk' Statements Versus Lines +================================= + +Most often, each line in an `awk' program is a separate statement or +separate rule, like this: + + awk '/12/ { print $0 } + /21/ { print $0 }' BBS-list inventory-shipped + + However, `gawk' ignores newlines after any of the following symbols +and keywords: + + , { ? : || && do else + +A newline at any other point is considered the end of the statement.(1) + + If you would like to split a single statement into two lines at a +point where a newline would terminate it, you can "continue" it by +ending the first line with a backslash character (`\'). The backslash +must be the final character on the line in order to be recognized as a +continuation character. A backslash is allowed anywhere in the +statement, even in the middle of a string or regular expression. For +example: + + awk '/This regular expression is too long, so continue it\ + on the next line/ { print $1 }' + +We have generally not used backslash continuation in our sample +programs. `gawk' places no limit on the length of a line, so backslash +continuation is never strictly necessary; it just makes programs more +readable. For this same reason, as well as for clarity, we have kept +most statements short in the sample programs presented throughout the +Info file. Backslash continuation is most useful when your `awk' +program is in a separate source file instead of entered from the +command line. You should also note that many `awk' implementations are +more particular about where you may use backslash continuation. For +example, they may not allow you to split a string constant using +backslash continuation. Thus, for maximum portability of your `awk' +programs, it is best not to split your lines in the middle of a regular +expression or a string. + + CAUTION: _Backslash continuation does not work as described with + the C shell._ It works for `awk' programs in files and for + one-shot programs, _provided_ you are using a POSIX-compliant + shell, such as the Unix Bourne shell or Bash. But the C shell + behaves differently! There, you must use two backslashes in a + row, followed by a newline. Note also that when using the C + shell, _every_ newline in your `awk' program must be escaped with + a backslash. To illustrate: + + % awk 'BEGIN { \ + ? print \\ + ? "hello, world" \ + ? }' + -| hello, world + + Here, the `%' and `?' are the C shell's primary and secondary + prompts, analogous to the standard shell's `$' and `>'. + + Compare the previous example to how it is done with a + POSIX-compliant shell: + + $ awk 'BEGIN { + > print \ + > "hello, world" + > }' + -| hello, world + + `awk' is a line-oriented language. Each rule's action has to begin +on the same line as the pattern. To have the pattern and action on +separate lines, you _must_ use backslash continuation; there is no +other option. + + Another thing to keep in mind is that backslash continuation and +comments do not mix. As soon as `awk' sees the `#' that starts a +comment, it ignores _everything_ on the rest of the line. For example: + + $ gawk 'BEGIN { print "dont panic" # a friendly \ + > BEGIN rule + > }' + error--> gawk: cmd. line:2: BEGIN rule + error--> gawk: cmd. line:2: ^ parse error + +In this case, it looks like the backslash would continue the comment +onto the next line. However, the backslash-newline combination is never +even noticed because it is "hidden" inside the comment. Thus, the +`BEGIN' is noted as a syntax error. + + When `awk' statements within one rule are short, you might want to +put more than one of them on a line. This is accomplished by +separating the statements with a semicolon (`;'). This also applies to +the rules themselves. Thus, the program shown at the start of this +minor node could also be written this way: + + /12/ { print $0 } ; /21/ { print $0 } + + NOTE: The requirement that states that rules on the same line must + be separated with a semicolon was not in the original `awk' + language; it was added for consistency with the treatment of + statements within an action. + + ---------- Footnotes ---------- + + (1) The `?' and `:' referred to here is the three-operand +conditional expression described in *note Conditional Exp::. Splitting +lines after `?' and `:' is a minor `gawk' extension; if `--posix' is +specified (*note Options::), then this extension is disabled. + + +File: gawk.info, Node: Other Features, Next: When, Prev: Statements/Lines, Up: Getting Started + +1.7 Other Features of `awk' +=========================== + +The `awk' language provides a number of predefined, or "built-in", +variables that your programs can use to get information from `awk'. +There are other variables your program can set as well to control how +`awk' processes your data. + + In addition, `awk' provides a number of built-in functions for doing +common computational and string-related operations. `gawk' provides +built-in functions for working with timestamps, performing bit +manipulation, for runtime string translation (internationalization), +determining the type of a variable, and array sorting. + + As we develop our presentation of the `awk' language, we introduce +most of the variables and many of the functions. They are described +systematically in *note Built-in Variables::, and *note Built-in::. + + +File: gawk.info, Node: When, Prev: Other Features, Up: Getting Started + +1.8 When to Use `awk' +===================== + +Now that you've seen some of what `awk' can do, you might wonder how +`awk' could be useful for you. By using utility programs, advanced +patterns, field separators, arithmetic statements, and other selection +criteria, you can produce much more complex output. The `awk' language +is very useful for producing reports from large amounts of raw data, +such as summarizing information from the output of other utility +programs like `ls'. (*Note More Complex::.) + + Programs written with `awk' are usually much smaller than they would +be in other languages. This makes `awk' programs easy to compose and +use. Often, `awk' programs can be quickly composed at your keyboard, +used once, and thrown away. Because `awk' programs are interpreted, you +can avoid the (usually lengthy) compilation part of the typical +edit-compile-test-debug cycle of software development. + + Complex programs have been written in `awk', including a complete +retargetable assembler for eight-bit microprocessors (*note Glossary::, +for more information), and a microcode assembler for a special-purpose +Prolog computer. While the original `awk''s capabilities were strained +by tasks of such complexity, modern versions are more capable. Even +Brian Kernighan's version of `awk' has fewer predefined limits, and +those that it has are much larger than they used to be. + + If you find yourself writing `awk' scripts of more than, say, a few +hundred lines, you might consider using a different programming +language. Emacs Lisp is a good choice if you need sophisticated string +or pattern matching capabilities. The shell is also good at string and +pattern matching; in addition, it allows powerful use of the system +utilities. More conventional languages, such as C, C++, and Java, offer +better facilities for system programming and for managing the complexity +of large programs. Programs in these languages may require more lines +of source code than the equivalent `awk' programs, but they are easier +to maintain and usually run more efficiently. + + +File: gawk.info, Node: Invoking Gawk, Next: Regexp, Prev: Getting Started, Up: Top + +2 Running `awk' and `gawk' +************************** + +This major node covers how to run awk, both POSIX-standard and +`gawk'-specific command-line options, and what `awk' and `gawk' do with +non-option arguments. It then proceeds to cover how `gawk' searches +for source files, reading standard input along with other files, +`gawk''s environment variables, `gawk''s exit status, using include +files, and obsolete and undocumented options and/or features. + + Many of the options and features described here are discussed in +more detail later in the Info file; feel free to skip over things in +this major node that don't interest you right now. + +* Menu: + +* Command Line:: How to run `awk'. +* Options:: Command-line options and their meanings. +* Other Arguments:: Input file names and variable assignments. +* Naming Standard Input:: How to specify standard input with other + files. +* Environment Variables:: The environment variables `gawk' uses. +* Exit Status:: `gawk''s exit status. +* Include Files:: Including other files into your program. +* Obsolete:: Obsolete Options and/or features. +* Undocumented:: Undocumented Options and Features. + + +File: gawk.info, Node: Command Line, Next: Options, Up: Invoking Gawk + +2.1 Invoking `awk' +================== + +There are two ways to run `awk'--with an explicit program or with one +or more program files. Here are templates for both of them; items +enclosed in [...] in these templates are optional: + + awk [OPTIONS] -f progfile [`--'] FILE ... + awk [OPTIONS] [`--'] 'PROGRAM' FILE ... + + Besides traditional one-letter POSIX-style options, `gawk' also +supports GNU long options. + + It is possible to invoke `awk' with an empty program: + + awk '' datafile1 datafile2 + +Doing so makes little sense, though; `awk' exits silently when given an +empty program. (d.c.) If `--lint' has been specified on the command +line, `gawk' issues a warning that the program is empty. + + +File: gawk.info, Node: Options, Next: Other Arguments, Prev: Command Line, Up: Invoking Gawk + +2.2 Command-Line Options +======================== + +Options begin with a dash and consist of a single character. GNU-style +long options consist of two dashes and a keyword. The keyword can be +abbreviated, as long as the abbreviation allows the option to be +uniquely identified. If the option takes an argument, then the keyword +is either immediately followed by an equals sign (`=') and the +argument's value, or the keyword and the argument's value are separated +by whitespace. If a particular option with a value is given more than +once, it is the last value that counts. + + Each long option for `gawk' has a corresponding POSIX-style short +option. The long and short options are interchangeable in all contexts. +The following list describes options mandated by the POSIX standard: + +`-F FS' +`--field-separator FS' + Set the `FS' variable to FS (*note Field Separators::). + +`-f SOURCE-FILE' +`--file SOURCE-FILE' + Read `awk' program source from SOURCE-FILE instead of in the first + non-option argument. This option may be given multiple times; the + `awk' program consists of the concatenation the contents of each + specified SOURCE-FILE. + +`-v VAR=VAL' +`--assign VAR=VAL' + Set the variable VAR to the value VAL _before_ execution of the + program begins. Such variable values are available inside the + `BEGIN' rule (*note Other Arguments::). + + The `-v' option can only set one variable, but it can be used more + than once, setting another variable each time, like this: `awk + -v foo=1 -v bar=2 ...'. + + CAUTION: Using `-v' to set the values of the built-in + variables may lead to surprising results. `awk' will reset + the values of those variables as it needs to, possibly + ignoring any predefined value you may have given. + +`-W GAWK-OPT' + Provide an implementation-specific option. This is the POSIX + convention for providing implementation-specific options. These + options also have corresponding GNU-style long options. Note that + the long options may be abbreviated, as long as the abbreviations + remain unique. The full list of `gawk'-specific options is + provided next. + +`--' + Signal the end of the command-line options. The following + arguments are not treated as options even if they begin with `-'. + This interpretation of `--' follows the POSIX argument parsing + conventions. + + This is useful if you have file names that start with `-', or in + shell scripts, if you have file names that will be specified by + the user that could start with `-'. It is also useful for passing + options on to the `awk' program; see *note Getopt Function::. + + The following list describes `gawk'-specific options: + +`-b' +`--characters-as-bytes' + Cause `gawk' to treat all input data as single-byte characters. + Normally, `gawk' follows the POSIX standard and attempts to process + its input data according to the current locale. This can often + involve converting multibyte characters into wide characters + (internally), and can lead to problems or confusion if the input + data does not contain valid multibyte characters. This option is + an easy way to tell `gawk': "hands off my data!". + +`-c' +`--traditional' + Specify "compatibility mode", in which the GNU extensions to the + `awk' language are disabled, so that `gawk' behaves just like + Brian Kernighan's version `awk'. *Note POSIX/GNU::, which + summarizes the extensions. Also see *note Compatibility Mode::. + +`-C' +`--copyright' + Print the short version of the General Public License and then + exit. + +`-d[FILE]' +`--dump-variables[=FILE]' + Print a sorted list of global variables, their types, and final + values to FILE. If no FILE is provided, print this list to the + file named `awkvars.out' in the current directory. No space is + allowed between the `-d' and FILE, if FILE is supplied. + + Having a list of all global variables is a good way to look for + typographical errors in your programs. You would also use this + option if you have a large program with a lot of functions, and + you want to be sure that your functions don't inadvertently use + global variables that you meant to be local. (This is a + particularly easy mistake to make with simple variable names like + `i', `j', etc.) + +`-e PROGRAM-TEXT' +`--source PROGRAM-TEXT' + Provide program source code in the PROGRAM-TEXT. This option + allows you to mix source code in files with source code that you + enter on the command line. This is particularly useful when you + have library functions that you want to use from your command-line + programs (*note AWKPATH Variable::). + +`-E FILE' +`--exec FILE' + Similar to `-f', read `awk' program text from FILE. There are two + differences from `-f': + + * This option terminates option processing; anything else on + the command line is passed on directly to the `awk' program. + + * Command-line variable assignments of the form `VAR=VALUE' are + disallowed. + + This option is particularly necessary for World Wide Web CGI + applications that pass arguments through the URL; using this + option prevents a malicious (or other) user from passing in + options, assignments, or `awk' source code (via `--source') to the + CGI application. This option should be used with `#!' scripts + (*note Executable Scripts::), like so: + + #! /usr/local/bin/gawk -E + + AWK PROGRAM HERE ... + +`-g' +`--gen-pot' + Analyze the source program and generate a GNU `gettext' Portable + Object Template file on standard output for all string constants + that have been marked for translation. *Note + Internationalization::, for information about this option. + +`-h' +`--help' + Print a "usage" message summarizing the short and long style + options that `gawk' accepts and then exit. + +`-L [value]' +`--lint[=value]' + Warn about constructs that are dubious or nonportable to other + `awk' implementations. Some warnings are issued when `gawk' first + reads your program. Others are issued at runtime, as your program + executes. With an optional argument of `fatal', lint warnings + become fatal errors. This may be drastic, but its use will + certainly encourage the development of cleaner `awk' programs. + With an optional argument of `invalid', only warnings about things + that are actually invalid are issued. (This is not fully + implemented yet.) + + Some warnings are only printed once, even if the dubious + constructs they warn about occur multiple times in your `awk' + program. Thus, when eliminating problems pointed out by `--lint', + you should take care to search for all occurrences of each + inappropriate construct. As `awk' programs are usually short, + doing so is not burdensome. + +`-n' +`--non-decimal-data' + Enable automatic interpretation of octal and hexadecimal values in + input data (*note Nondecimal Data::). + + CAUTION: This option can severely break old programs. Use + with care. + +`-N' +`--use-lc-numeric' + Force the use of the locale's decimal point character when parsing + numeric input data (*note Locales::). + +`-O' +`--optimize' + Enable some optimizations on the internal representation of the + program. At the moment this includes just simple constant + folding. The `gawk' maintainer hopes to add more optimizations + over time. + +`-p[FILE]' +`--profile[=FILE]' + Enable profiling of `awk' programs (*note Profiling::). By + default, profiles are created in a file named `awkprof.out'. The + optional FILE argument allows you to specify a different file name + for the profile file. No space is allowed between the `-p' and + FILE, if FILE is supplied. + + When run with `gawk', the profile is just a "pretty printed" + version of the program. When run with `pgawk', the profile + contains execution counts for each statement in the program in the + left margin, and function call counts for each function. + +`-P' +`--posix' + Operate in strict POSIX mode. This disables all `gawk' extensions + (just like `--traditional') and disables all extensions not + allowed by POSIX. *Note Common Extensions::, for a summary of the + extensions in `gawk' that are disabled by this option. Also, the + following additional restrictions apply: + + * Newlines do not act as whitespace to separate fields when + `FS' is equal to a single space (*note Fields::). + + * Newlines are not allowed after `?' or `:' (*note Conditional + Exp::). + + * Specifying `-Ft' on the command-line does not set the value + of `FS' to be a single TAB character (*note Field + Separators::). + + * The locale's decimal point character is used for parsing input + data (*note Locales::). + + If you supply both `--traditional' and `--posix' on the command + line, `--posix' takes precedence. `gawk' also issues a warning if + both options are supplied. + +`-r' +`--re-interval' + Allow interval expressions (*note Regexp Operators::) in regexps. + This is now `gawk''s default behavior. Nevertheless, this option + remains both for backward compatibility, and for use in + combination with the `--traditional' option. + +`-R FILE' +`--command=FILE' + `dgawk' only. Read `dgawk' debugger options and commands from + FILE. *Note Dgawk Info::, for more information. + +`-S' +`--sandbox' + Disable the `system()' function, input redirections with `getline', + output redirections with `print' and `printf', and dynamic + extensions. This is particularly useful when you want to run + `awk' scripts from questionable sources and need to make sure the + scripts can't access your system (other than the specified input + data file). + +`-t' +`--lint-old' + Warn about constructs that are not available in the original + version of `awk' from Version 7 Unix (*note V7/SVR3.1::). + +`-V' +`--version' + Print version information for this particular copy of `gawk'. + This allows you to determine if your copy of `gawk' is up to date + with respect to whatever the Free Software Foundation is currently + distributing. It is also useful for bug reports (*note Bugs::). + + As long as program text has been supplied, any other options are +flagged as invalid with a warning message but are otherwise ignored. + + In compatibility mode, as a special case, if the value of FS supplied +to the `-F' option is `t', then `FS' is set to the TAB character +(`"\t"'). This is true only for `--traditional' and not for `--posix' +(*note Field Separators::). + + The `-f' option may be used more than once on the command line. If +it is, `awk' reads its program source from all of the named files, as +if they had been concatenated together into one big file. This is +useful for creating libraries of `awk' functions. These functions can +be written once and then retrieved from a standard place, instead of +having to be included into each individual program. (As mentioned in +*note Definition Syntax::, function names must be unique.) + + With standard `awk', library functions can still be used, even if +the program is entered at the terminal, by specifying `-f /dev/tty'. +After typing your program, type `Ctrl-d' (the end-of-file character) to +terminate it. (You may also use `-f -' to read program source from the +standard input but then you will not be able to also use the standard +input as a source of data.) + + Because it is clumsy using the standard `awk' mechanisms to mix +source file and command-line `awk' programs, `gawk' provides the +`--source' option. This does not require you to pre-empt the standard +input for your source code; it allows you to easily mix command-line +and library source code (*note AWKPATH Variable::). The `--source' +option may also be used multiple times on the command line. + + If no `-f' or `--source' option is specified, then `gawk' uses the +first non-option command-line argument as the text of the program +source code. + + If the environment variable `POSIXLY_CORRECT' exists, then `gawk' +behaves in strict POSIX mode, exactly as if you had supplied the +`--posix' command-line option. Many GNU programs look for this +environment variable to suppress extensions that conflict with POSIX, +but `gawk' behaves differently: it suppresses all extensions, even +those that do not conflict with POSIX, and behaves in strict POSIX +mode. If `--lint' is supplied on the command line and `gawk' turns on +POSIX mode because of `POSIXLY_CORRECT', then it issues a warning +message indicating that POSIX mode is in effect. You would typically +set this variable in your shell's startup file. For a +Bourne-compatible shell (such as Bash), you would add these lines to +the `.profile' file in your home directory: + + POSIXLY_CORRECT=true + export POSIXLY_CORRECT + + For a C shell-compatible shell,(1) you would add this line to the +`.login' file in your home directory: + + setenv POSIXLY_CORRECT true + + Having `POSIXLY_CORRECT' set is not recommended for daily use, but +it is good for testing the portability of your programs to other +environments. + + ---------- Footnotes ---------- + + (1) Not recommended. + + +File: gawk.info, Node: Other Arguments, Next: Naming Standard Input, Prev: Options, Up: Invoking Gawk + +2.3 Other Command-Line Arguments +================================ + +Any additional arguments on the command line are normally treated as +input files to be processed in the order specified. However, an +argument that has the form `VAR=VALUE', assigns the value VALUE to the +variable VAR--it does not specify a file at all. (See *note Assignment +Options::.) + + All these arguments are made available to your `awk' program in the +`ARGV' array (*note Built-in Variables::). Command-line options and +the program text (if present) are omitted from `ARGV'. All other +arguments, including variable assignments, are included. As each +element of `ARGV' is processed, `gawk' sets the variable `ARGIND' to +the index in `ARGV' of the current element. + + The distinction between file name arguments and variable-assignment +arguments is made when `awk' is about to open the next input file. At +that point in execution, it checks the file name to see whether it is +really a variable assignment; if so, `awk' sets the variable instead of +reading a file. + + Therefore, the variables actually receive the given values after all +previously specified files have been read. In particular, the values of +variables assigned in this fashion are _not_ available inside a `BEGIN' +rule (*note BEGIN/END::), because such rules are run before `awk' +begins scanning the argument list. + + The variable values given on the command line are processed for +escape sequences (*note Escape Sequences::). (d.c.) + + In some earlier implementations of `awk', when a variable assignment +occurred before any file names, the assignment would happen _before_ +the `BEGIN' rule was executed. `awk''s behavior was thus inconsistent; +some command-line assignments were available inside the `BEGIN' rule, +while others were not. Unfortunately, some applications came to depend +upon this "feature." When `awk' was changed to be more consistent, the +`-v' option was added to accommodate applications that depended upon +the old behavior. + + The variable assignment feature is most useful for assigning to +variables such as `RS', `OFS', and `ORS', which control input and +output formats before scanning the data files. It is also useful for +controlling state if multiple passes are needed over a data file. For +example: + + awk 'pass == 1 { PASS 1 STUFF } + pass == 2 { PASS 2 STUFF }' pass=1 mydata pass=2 mydata + + Given the variable assignment feature, the `-F' option for setting +the value of `FS' is not strictly necessary. It remains for historical +compatibility. + + +File: gawk.info, Node: Naming Standard Input, Next: Environment Variables, Prev: Other Arguments, Up: Invoking Gawk + +2.4 Naming Standard Input +========================= + +Often, you may wish to read standard input together with other files. +For example, you may wish to read one file, read standard input coming +from a pipe, and then read another file. + + The way to name the standard input, with all versions of `awk', is +to use a single, standalone minus sign or dash, `-'. For example: + + SOME_COMMAND | awk -f myprog.awk file1 - file2 + +Here, `awk' first reads `file1', then it reads the output of +SOME_COMMAND, and finally it reads `file2'. + + You may also use `"-"' to name standard input when reading files +with `getline' (*note Getline/File::). + + In addition, `gawk' allows you to specify the special file name +`/dev/stdin', both on the command line and with `getline'. Some other +versions of `awk' also support this, but it is not standard. (Some +operating systems provide a `/dev/stdin' file in the file system, +however, `gawk' always processes this file name itself.) + + +File: gawk.info, Node: Environment Variables, Next: Exit Status, Prev: Naming Standard Input, Up: Invoking Gawk + +2.5 The Environment Variables `gawk' Uses +========================================= + +A number of environment variables influence how `gawk' behaves. + +* Menu: + +* AWKPATH Variable:: Searching directories for `awk' + programs. +* Other Environment Variables:: The environment variables. + + +File: gawk.info, Node: AWKPATH Variable, Next: Other Environment Variables, Up: Environment Variables + +2.5.1 The `AWKPATH' Environment Variable +---------------------------------------- + +The previous minor node described how `awk' program files can be named +on the command-line with the `-f' option. In most `awk' +implementations, you must supply a precise path name for each program +file, unless the file is in the current directory. But in `gawk', if +the file name supplied to the `-f' option does not contain a `/', then +`gawk' searches a list of directories (called the "search path"), one +by one, looking for a file with the specified name. + +The search path is a string consisting of directory names separated by +colons. `gawk' gets its search path from the `AWKPATH' environment +variable. If that variable does not exist, `gawk' uses a default path, +`.:/usr/local/share/awk'.(1) + + The search path feature is particularly useful for building libraries +of useful `awk' functions. The library files can be placed in a +standard directory in the default path and then specified on the +command line with a short file name. Otherwise, the full file name +would have to be typed for each file. + + By using both the `--source' and `-f' options, your command-line +`awk' programs can use facilities in `awk' library files (*note Library +Functions::). Path searching is not done if `gawk' is in compatibility +mode. This is true for both `--traditional' and `--posix'. *Note +Options::. + + NOTE: To include the current directory in the path, either place + `.' explicitly in the path or write a null entry in the path. (A + null entry is indicated by starting or ending the path with a + colon or by placing two colons next to each other (`::').) This + path search mechanism is similar to the shell's. + + However, `gawk' always looks in the current directory _before_ + searching `AWKPATH', so there is no real reason to include the + current directory in the search path. + + If `AWKPATH' is not defined in the environment, `gawk' places its +default search path into `ENVIRON["AWKPATH"]'. This makes it easy to +determine the actual search path that `gawk' will use from within an +`awk' program. + + While you can change `ENVIRON["AWKPATH"]' within your `awk' program, +this has no effect on the running program's behavior. This makes +sense: the `AWKPATH' environment variable is used to find the program +source files. Once your program is running, all the files have been +found, and `gawk' no longer needs to use `AWKPATH'. + + ---------- Footnotes ---------- + + (1) Your version of `gawk' may use a different directory; it will +depend upon how `gawk' was built and installed. The actual directory is +the value of `$(datadir)' generated when `gawk' was configured. You +probably don't need to worry about this, though. + + +File: gawk.info, Node: Other Environment Variables, Prev: AWKPATH Variable, Up: Environment Variables + +2.5.2 Other Environment Variables +--------------------------------- + +A number of other environment variables affect `gawk''s behavior, but +they are more specialized. Those in the following list are meant to be +used by regular users. + +`POSIXLY_CORRECT' + Causes `gawk' to switch POSIX compatibility mode, disabling all + traditional and GNU extensions. *Note Options::. + +`GAWK_SOCK_RETRIES' + Controls the number of time `gawk' will attempt to retry a two-way + TCP/IP (socket) connection before giving up. *Note TCP/IP + Networking::. + +`GAWK_MSEC_SLEEP' + Specifies the interval between connection retries, in + milliseconds. On systems that do not support the `usleep()' system + call, the value is rounded up to an integral number of seconds. + + The environment variables in the following list are meant for use by +the `gawk' developers for testing and tuning. They are subject to +change. The variables are: + +`AVG_CHAIN_MAX' + The average number of items `gawk' will maintain on a hash chain + for managing arrays. + +`AWK_HASH' + If this variable exists with a value of `gst', `gawk' will switch + to using the hash function from GNU Smalltalk for managing arrays. + This function may be marginally faster than the standard function. + +`AWKREADFUNC' + If this variable exists, `gawk' switches to reading source files + one line at a time, instead of reading in blocks. This exists for + debugging problems on filesystems on non-POSIX operating systems + where I/O is performed in records, not in blocks. + +`GAWK_NO_DFA' + If this variable exists, `gawk' does not use the DFA regexp matcher + for "does it match" kinds of tests. This can cause `gawk' to be + slower. Its purpose is to help isolate differences between the two + regexp matchers that `gawk' uses internally. (There aren't + supposed to be differences, but occasionally theory and practice + don't coordinate with each other.) + +`GAWK_STACKSIZE' + This specifies the amount by which `gawk' should grow its internal + evaluation stack, when needed. + +`TIDYMEM' + If this variable exists, `gawk' uses the `mtrace()' library calls + from GNU LIBC to help track down possible memory leaks. + + +File: gawk.info, Node: Exit Status, Next: Include Files, Prev: Environment Variables, Up: Invoking Gawk + +2.6 `gawk''s Exit Status +======================== + +If the `exit' statement is used with a value (*note Exit Statement::), +then `gawk' exits with the numeric value given to it. + + Otherwise, if there were no problems during execution, `gawk' exits +with the value of the C constant `EXIT_SUCCESS'. This is usually zero. + + If an error occurs, `gawk' exits with the value of the C constant +`EXIT_FAILURE'. This is usually one. + + If `gawk' exits because of a fatal error, the exit status is 2. On +non-POSIX systems, this value may be mapped to `EXIT_FAILURE'. + + +File: gawk.info, Node: Include Files, Next: Obsolete, Prev: Exit Status, Up: Invoking Gawk + +2.7 Including Other Files Into Your Program +=========================================== + +This minor node describes a feature that is specific to `gawk'. + + The `@include' keyword can be used to read external `awk' source +files. This gives you the ability to split large `awk' source files +into smaller, more manageable pieces, and also lets you reuse common +`awk' code from various `awk' scripts. In other words, you can group +together `awk' functions, used to carry out specific tasks, into +external files. These files can be used just like function libraries, +using the `@include' keyword in conjunction with the `AWKPATH' +environment variable. + + Let's see an example. We'll start with two (trivial) `awk' scripts, +namely `test1' and `test2'. Here is the `test1' script: + + BEGIN { + print "This is script test1." + } + +and here is `test2': + + @include "test1" + BEGIN { + print "This is script test2." + } + + Running `gawk' with `test2' produces the following result: + + $ gawk -f test2 + -| This is file test1. + -| This is file test2. + + `gawk' runs the `test2' script which includes `test1' using the +`@include' keyword. So, to include external `awk' source files you just +use `@include' followed by the name of the file to be included, +enclosed in double quotes. + + NOTE: Keep in mind that this is a language construct and the file + name cannot be a string variable, but rather just a literal string + in double quotes. + + The files to be included may be nested; e.g., given a third script, +namely `test3': + + @include "test2" + BEGIN { + print "This is script test3." + } + +Running `gawk' with the `test3' script produces the following results: + + $ gawk -f test3 + -| This is file test1. + -| This is file test2. + -| This is file test3. + + The file name can, of course, be a pathname. For example: + + @include "../io_funcs" + +or: + + @include "/usr/awklib/network" + +are valid. The `AWKPATH' environment variable can be of great value +when using `@include'. The same rules for the use of the `AWKPATH' +variable in command-line file searches (*note AWKPATH Variable::) apply +to `@include' also. + + This is very helpful in constructing `gawk' function libraries. If +you have a large script with useful, general purpose `awk' functions, +you can break it down into library files and put those files in a +special directory. You can then include those "libraries," using +either the full pathnames of the files, or by setting the `AWKPATH' +environment variable accordingly and then using `@include' with just +the file part of the full pathname. Of course you can have more than +one directory to keep library files; the more complex the working +environment is, the more directories you may need to organize the files +to be included. + + Given the ability to specify multiple `-f' options, the `@include' +mechanism is not strictly necessary. However, the `@include' keyword +can help you in constructing self-contained `gawk' programs, thus +reducing the need for writing complex and tedious command lines. In +particular, `@include' is very useful for writing CGI scripts to be run +from web pages. + + As mentioned in *note AWKPATH Variable::, the current directory is +always searched first for source files, before searching in `AWKPATH', +and this also applies to files named with `@include'. + + +File: gawk.info, Node: Obsolete, Next: Undocumented, Prev: Include Files, Up: Invoking Gawk + +2.8 Obsolete Options and/or Features +==================================== + +This minor node describes features and/or command-line options from +previous releases of `gawk' that are either not available in the +current version or that are still supported but deprecated (meaning that +they will _not_ be in the next release). + + The process-related special files `/dev/pid', `/dev/ppid', +`/dev/pgrpid', and `/dev/user' were deprecated in `gawk' 3.1, but still +worked. As of version 4.0, they are no longer interpreted specially by +`gawk'. (Use `PROCINFO' instead; see *note Auto-set::.) + + +File: gawk.info, Node: Undocumented, Prev: Obsolete, Up: Invoking Gawk + +2.9 Undocumented Options and Features +===================================== + + Use the Source, Luke! + Obi-Wan + + This minor node intentionally left blank. + + +File: gawk.info, Node: Regexp, Next: Reading Files, Prev: Invoking Gawk, Up: Top + +3 Regular Expressions +********************* + +A "regular expression", or "regexp", is a way of describing a set of +strings. Because regular expressions are such a fundamental part of +`awk' programming, their format and use deserve a separate major node. + + A regular expression enclosed in slashes (`/') is an `awk' pattern +that matches every input record whose text belongs to that set. The +simplest regular expression is a sequence of letters, numbers, or both. +Such a regexp matches any string that contains that sequence. Thus, +the regexp `foo' matches any string containing `foo'. Therefore, the +pattern `/foo/' matches any input record containing the three +characters `foo' _anywhere_ in the record. Other kinds of regexps let +you specify more complicated classes of strings. + +* Menu: + +* Regexp Usage:: How to Use Regular Expressions. +* Escape Sequences:: How to write nonprinting characters. +* Regexp Operators:: Regular Expression Operators. +* Bracket Expressions:: What can go between `[...]'. +* GNU Regexp Operators:: Operators specific to GNU software. +* Case-sensitivity:: How to do case-insensitive matching. +* Leftmost Longest:: How much text matches. +* Computed Regexps:: Using Dynamic Regexps. + + +File: gawk.info, Node: Regexp Usage, Next: Escape Sequences, Up: Regexp + +3.1 How to Use Regular Expressions +================================== + +A regular expression can be used as a pattern by enclosing it in +slashes. Then the regular expression is tested against the entire text +of each record. (Normally, it only needs to match some part of the +text in order to succeed.) For example, the following prints the +second field of each record that contains the string `foo' anywhere in +it: + + $ awk '/foo/ { print $2 }' BBS-list + -| 555-1234 + -| 555-6699 + -| 555-6480 + -| 555-2127 + + Regular expressions can also be used in matching expressions. These +expressions allow you to specify the string to match against; it need +not be the entire current input record. The two operators `~' and `!~' +perform regular expression comparisons. Expressions using these +operators can be used as patterns, or in `if', `while', `for', and `do' +statements. (*Note Statements::.) For example: + + EXP ~ /REGEXP/ + +is true if the expression EXP (taken as a string) matches REGEXP. The +following example matches, or selects, all input records with the +uppercase letter `J' somewhere in the first field: + + $ awk '$1 ~ /J/' inventory-shipped + -| Jan 13 25 15 115 + -| Jun 31 42 75 492 + -| Jul 24 34 67 436 + -| Jan 21 36 64 620 + + So does this: + + awk '{ if ($1 ~ /J/) print }' inventory-shipped + + This next example is true if the expression EXP (taken as a +character string) does _not_ match REGEXP: + + EXP !~ /REGEXP/ + + The following example matches, or selects, all input records whose +first field _does not_ contain the uppercase letter `J': + + $ awk '$1 !~ /J/' inventory-shipped + -| Feb 15 32 24 226 + -| Mar 15 24 34 228 + -| Apr 31 52 63 420 + -| May 16 34 29 208 + ... + + When a regexp is enclosed in slashes, such as `/foo/', we call it a +"regexp constant", much like `5.27' is a numeric constant and `"foo"' +is a string constant. + + +File: gawk.info, Node: Escape Sequences, Next: Regexp Operators, Prev: Regexp Usage, Up: Regexp + +3.2 Escape Sequences +==================== + +Some characters cannot be included literally in string constants +(`"foo"') or regexp constants (`/foo/'). Instead, they should be +represented with "escape sequences", which are character sequences +beginning with a backslash (`\'). One use of an escape sequence is to +include a double-quote character in a string constant. Because a plain +double quote ends the string, you must use `\"' to represent an actual +double-quote character as a part of the string. For example: + + $ awk 'BEGIN { print "He said \"hi!\" to her." }' + -| He said "hi!" to her. + + The backslash character itself is another character that cannot be +included normally; you must write `\\' to put one backslash in the +string or regexp. Thus, the string whose contents are the two +characters `"' and `\' must be written `"\"\\"'. + + Other escape sequences represent unprintable characters such as TAB +or newline. While there is nothing to stop you from entering most +unprintable characters directly in a string constant or regexp constant, +they may look ugly. + + The following table lists all the escape sequences used in `awk' and +what they represent. Unless noted otherwise, all these escape sequences +apply to both string constants and regexp constants: + +`\\' + A literal backslash, `\'. + +`\a' + The "alert" character, `Ctrl-g', ASCII code 7 (BEL). (This + usually makes some sort of audible noise.) + +`\b' + Backspace, `Ctrl-h', ASCII code 8 (BS). + +`\f' + Formfeed, `Ctrl-l', ASCII code 12 (FF). + +`\n' + Newline, `Ctrl-j', ASCII code 10 (LF). + +`\r' + Carriage return, `Ctrl-m', ASCII code 13 (CR). + +`\t' + Horizontal TAB, `Ctrl-i', ASCII code 9 (HT). + +`\v' + Vertical tab, `Ctrl-k', ASCII code 11 (VT). + +`\NNN' + The octal value NNN, where NNN stands for 1 to 3 digits between + `0' and `7'. For example, the code for the ASCII ESC (escape) + character is `\033'. + +`\xHH...' + The hexadecimal value HH, where HH stands for a sequence of + hexadecimal digits (`0'-`9', and either `A'-`F' or `a'-`f'). Like + the same construct in ISO C, the escape sequence continues until + the first nonhexadecimal digit is seen. (c.e.) However, using + more than two hexadecimal digits produces undefined results. (The + `\x' escape sequence is not allowed in POSIX `awk'.) + +`\/' + A literal slash (necessary for regexp constants only). This + sequence is used when you want to write a regexp constant that + contains a slash. Because the regexp is delimited by slashes, you + need to escape the slash that is part of the pattern, in order to + tell `awk' to keep processing the rest of the regexp. + +`\"' + A literal double quote (necessary for string constants only). + This sequence is used when you want to write a string constant + that contains a double quote. Because the string is delimited by + double quotes, you need to escape the quote that is part of the + string, in order to tell `awk' to keep processing the rest of the + string. + + In `gawk', a number of additional two-character sequences that begin +with a backslash have special meaning in regexps. *Note GNU Regexp +Operators::. + + In a regexp, a backslash before any character that is not in the +previous list and not listed in *note GNU Regexp Operators::, means +that the next character should be taken literally, even if it would +normally be a regexp operator. For example, `/a\+b/' matches the three +characters `a+b'. + + For complete portability, do not use a backslash before any +character not shown in the previous list. + + To summarize: + + * The escape sequences in the table above are always processed first, + for both string constants and regexp constants. This happens very + early, as soon as `awk' reads your program. + + * `gawk' processes both regexp constants and dynamic regexps (*note + Computed Regexps::), for the special operators listed in *note GNU + Regexp Operators::. + + * A backslash before any other character means to treat that + character literally. + +Advanced Notes: Backslash Before Regular Characters +--------------------------------------------------- + +If you place a backslash in a string constant before something that is +not one of the characters previously listed, POSIX `awk' purposely +leaves what happens as undefined. There are two choices: + +Strip the backslash out + This is what Brian Kernighan's `awk' and `gawk' both do. For + example, `"a\qc"' is the same as `"aqc"'. (Because this is such + an easy bug both to introduce and to miss, `gawk' warns you about + it.) Consider `FS = "[ \t]+\|[ \t]+"' to use vertical bars + surrounded by whitespace as the field separator. There should be + two backslashes in the string: `FS = "[ \t]+\\|[ \t]+"'.) + +Leave the backslash alone + Some other `awk' implementations do this. In such + implementations, typing `"a\qc"' is the same as typing `"a\\qc"'. + +Advanced Notes: Escape Sequences for Metacharacters +--------------------------------------------------- + +Suppose you use an octal or hexadecimal escape to represent a regexp +metacharacter. (See *note Regexp Operators::.) Does `awk' treat the +character as a literal character or as a regexp operator? + + Historically, such characters were taken literally. (d.c.) +However, the POSIX standard indicates that they should be treated as +real metacharacters, which is what `gawk' does. In compatibility mode +(*note Options::), `gawk' treats the characters represented by octal +and hexadecimal escape sequences literally when used in regexp +constants. Thus, `/a\52b/' is equivalent to `/a\*b/'. + + +File: gawk.info, Node: Regexp Operators, Next: Bracket Expressions, Prev: Escape Sequences, Up: Regexp + +3.3 Regular Expression Operators +================================ + +You can combine regular expressions with special characters, called +"regular expression operators" or "metacharacters", to increase the +power and versatility of regular expressions. + + The escape sequences described in *note Escape Sequences::, are +valid inside a regexp. They are introduced by a `\' and are recognized +and converted into corresponding real characters as the very first step +in processing regexps. + + Here is a list of metacharacters. All characters that are not escape +sequences and that are not listed in the table stand for themselves: + +`\' + This is used to suppress the special meaning of a character when + matching. For example, `\$' matches the character `$'. + +`^' + This matches the beginning of a string. For example, `^@chapter' + matches `@chapter' at the beginning of a string and can be used to + identify chapter beginnings in Texinfo source files. The `^' is + known as an "anchor", because it anchors the pattern to match only + at the beginning of the string. + + It is important to realize that `^' does not match the beginning of + a line embedded in a string. The condition is not true in the + following example: + + if ("line1\nLINE 2" ~ /^L/) ... + +`$' + This is similar to `^', but it matches only at the end of a string. + For example, `p$' matches a record that ends with a `p'. The `$' + is an anchor and does not match the end of a line embedded in a + string. The condition in the following example is not true: + + if ("line1\nLINE 2" ~ /1$/) ... + +`. (period)' + This matches any single character, _including_ the newline + character. For example, `.P' matches any single character + followed by a `P' in a string. Using concatenation, we can make a + regular expression such as `U.A', which matches any + three-character sequence that begins with `U' and ends with `A'. + + In strict POSIX mode (*note Options::), `.' does not match the NUL + character, which is a character with all bits equal to zero. + Otherwise, NUL is just another character. Other versions of `awk' + may not be able to match the NUL character. + +`[...]' + This is called a "bracket expression".(1) It matches any _one_ of + the characters that are enclosed in the square brackets. For + example, `[MVX]' matches any one of the characters `M', `V', or + `X' in a string. A full discussion of what can be inside the + square brackets of a bracket expression is given in *note Bracket + Expressions::. + +`[^ ...]' + This is a "complemented bracket expression". The first character + after the `[' _must_ be a `^'. It matches any characters _except_ + those in the square brackets. For example, `[^awk]' matches any + character that is not an `a', `w', or `k'. + +`|' + This is the "alternation operator" and it is used to specify + alternatives. The `|' has the lowest precedence of all the regular + expression operators. For example, `^P|[[:digit:]]' matches any + string that matches either `^P' or `[[:digit:]]'. This means it + matches any string that starts with `P' or contains a digit. + + The alternation applies to the largest possible regexps on either + side. + +`(...)' + Parentheses are used for grouping in regular expressions, as in + arithmetic. They can be used to concatenate regular expressions + containing the alternation operator, `|'. For example, + `@(samp|code)\{[^}]+\}' matches both `@code{foo}' and `@samp{bar}'. + (These are Texinfo formatting control sequences. The `+' is + explained further on in this list.) + +`*' + This symbol means that the preceding regular expression should be + repeated as many times as necessary to find a match. For example, + `ph*' applies the `*' symbol to the preceding `h' and looks for + matches of one `p' followed by any number of `h's. This also + matches just `p' if no `h's are present. + + The `*' repeats the _smallest_ possible preceding expression. + (Use parentheses if you want to repeat a larger expression.) It + finds as many repetitions as possible. For example, `awk + '/\(c[ad][ad]*r x\)/ { print }' sample' prints every record in + `sample' containing a string of the form `(car x)', `(cdr x)', + `(cadr x)', and so on. Notice the escaping of the parentheses by + preceding them with backslashes. + +`+' + This symbol is similar to `*', except that the preceding + expression must be matched at least once. This means that `wh+y' + would match `why' and `whhy', but not `wy', whereas `wh*y' would + match all three of these strings. The following is a simpler way + of writing the last `*' example: + + awk '/\(c[ad]+r x\)/ { print }' sample + +`?' + This symbol is similar to `*', except that the preceding + expression can be matched either once or not at all. For example, + `fe?d' matches `fed' and `fd', but nothing else. + +`{N}' +`{N,}' +`{N,M}' + One or two numbers inside braces denote an "interval expression". + If there is one number in the braces, the preceding regexp is + repeated N times. If there are two numbers separated by a comma, + the preceding regexp is repeated N to M times. If there is one + number followed by a comma, then the preceding regexp is repeated + at least N times: + + `wh{3}y' + Matches `whhhy', but not `why' or `whhhhy'. + + `wh{3,5}y' + Matches `whhhy', `whhhhy', or `whhhhhy', only. + + `wh{2,}y' + Matches `whhy' or `whhhy', and so on. + + Interval expressions were not traditionally available in `awk'. + They were added as part of the POSIX standard to make `awk' and + `egrep' consistent with each other. + + Initially, because old programs may use `{' and `}' in regexp + constants, `gawk' did _not_ match interval expressions in regexps. + + However, beginning with version 4.0, `gawk' does match interval + expressions by default. This is because compatibility with POSIX + has become more important to most `gawk' users than compatibility + with old programs. + + For programs that use `{' and `}' in regexp constants, it is good + practice to always escape them with a backslash. Then the regexp + constants are valid and work the way you want them to, using any + version of `awk'.(2) + + Finally, when `{' and `}' appear in regexp constants in a way that + cannot be interpreted as an interval expression (such as + `/q{a}/'), then they stand for themselves. + + In regular expressions, the `*', `+', and `?' operators, as well as +the braces `{' and `}', have the highest precedence, followed by +concatenation, and finally by `|'. As in arithmetic, parentheses can +change how operators are grouped. + + In POSIX `awk' and `gawk', the `*', `+', and `?' operators stand for +themselves when there is nothing in the regexp that precedes them. For +example, `/+/' matches a literal plus sign. However, many other +versions of `awk' treat such a usage as a syntax error. + + If `gawk' is in compatibility mode (*note Options::), interval +expressions are not available in regular expressions. + + ---------- Footnotes ---------- + + (1) In other literature, you may see a bracket expression referred +to as either a "character set", a "character class", or a "character +list". + + (2) Use two backslashes if you're using a string constant with a +regexp operator or function. + + +File: gawk.info, Node: Bracket Expressions, Next: GNU Regexp Operators, Prev: Regexp Operators, Up: Regexp + +3.4 Using Bracket Expressions +============================= + +As mentioned earlier, a bracket expression matches any character amongst +those listed between the opening and closing square brackets. + + Within a bracket expression, a "range expression" consists of two +characters separated by a hyphen. It matches any single character that +sorts between the two characters, based upon the system's native +character set. For example, `[0-9]' is equivalent to `[0123456789]'. +(See *note Ranges and Locales::, for an explanation of how the POSIX +standard and `gawk' have changed over time. This is mainly of +historical interest.) + + To include one of the characters `\', `]', `-', or `^' in a bracket +expression, put a `\' in front of it. For example: + + [d\]] + +matches either `d' or `]'. + + This treatment of `\' in bracket expressions is compatible with +other `awk' implementations and is also mandated by POSIX. The regular +expressions in `awk' are a superset of the POSIX specification for +Extended Regular Expressions (EREs). POSIX EREs are based on the +regular expressions accepted by the traditional `egrep' utility. + + "Character classes" are a feature introduced in the POSIX standard. +A character class is a special notation for describing lists of +characters that have a specific attribute, but the actual characters +can vary from country to country and/or from character set to character +set. For example, the notion of what is an alphabetic character +differs between the United States and France. + + A character class is only valid in a regexp _inside_ the brackets of +a bracket expression. Character classes consist of `[:', a keyword +denoting the class, and `:]'. *note table-char-classes:: lists the +character classes defined by the POSIX standard. + +Class Meaning +-------------------------------------------------------------------------- +`[:alnum:]' Alphanumeric characters. +`[:alpha:]' Alphabetic characters. +`[:blank:]' Space and TAB characters. +`[:cntrl:]' Control characters. +`[:digit:]' Numeric characters. +`[:graph:]' Characters that are both printable and visible. (A space is + printable but not visible, whereas an `a' is both.) +`[:lower:]' Lowercase alphabetic characters. +`[:print:]' Printable characters (characters that are not control + characters). +`[:punct:]' Punctuation characters (characters that are not letters, + digits, control characters, or space characters). +`[:space:]' Space characters (such as space, TAB, and formfeed, to name + a few). +`[:upper:]' Uppercase alphabetic characters. +`[:xdigit:]'Characters that are hexadecimal digits. + +Table 3.1: POSIX Character Classes + + For example, before the POSIX standard, you had to write +`/[A-Za-z0-9]/' to match alphanumeric characters. If your character +set had other alphabetic characters in it, this would not match them. +With the POSIX character classes, you can write `/[[:alnum:]]/' to +match the alphabetic and numeric characters in your character set. + + Two additional special sequences can appear in bracket expressions. +These apply to non-ASCII character sets, which can have single symbols +(called "collating elements") that are represented with more than one +character. They can also have several characters that are equivalent for +"collating", or sorting, purposes. (For example, in French, a plain "e" +and a grave-accented "e`" are equivalent.) These sequences are: + +Collating symbols + Multicharacter collating elements enclosed between `[.' and `.]'. + For example, if `ch' is a collating element, then `[[.ch.]]' is a + regexp that matches this collating element, whereas `[ch]' is a + regexp that matches either `c' or `h'. + +Equivalence classes + Locale-specific names for a list of characters that are equal. The + name is enclosed between `[=' and `=]'. For example, the name `e' + might be used to represent all of "e," "e`," and "e'." In this + case, `[[=e=]]' is a regexp that matches any of `e', `e'', or `e`'. + + These features are very valuable in non-English-speaking locales. + + CAUTION: The library functions that `gawk' uses for regular + expression matching currently recognize only POSIX character + classes; they do not recognize collating symbols or equivalence + classes. + + +File: gawk.info, Node: GNU Regexp Operators, Next: Case-sensitivity, Prev: Bracket Expressions, Up: Regexp + +3.5 `gawk'-Specific Regexp Operators +==================================== + +GNU software that deals with regular expressions provides a number of +additional regexp operators. These operators are described in this +minor node and are specific to `gawk'; they are not available in other +`awk' implementations. Most of the additional operators deal with word +matching. For our purposes, a "word" is a sequence of one or more +letters, digits, or underscores (`_'): + +`\s' + Matches any whitespace character. Think of it as shorthand for + `[[:space:]]'. + +`\S' + Matches any character that is not whitespace. Think of it as + shorthand for `[^[:space:]]'. + +`\w' + Matches any word-constituent character--that is, it matches any + letter, digit, or underscore. Think of it as shorthand for + `[[:alnum:]_]'. + +`\W' + Matches any character that is not word-constituent. Think of it + as shorthand for `[^[:alnum:]_]'. + +`\<' + Matches the empty string at the beginning of a word. For example, + `/\' + Matches the empty string at the end of a word. For example, + `/stow\>/' matches `stow' but not `stowaway'. + +`\y' + Matches the empty string at either the beginning or the end of a + word (i.e., the word boundar*y*). For example, `\yballs?\y' + matches either `ball' or `balls', as a separate word. + +`\B' + Matches the empty string that occurs between two word-constituent + characters. For example, `/\Brat\B/' matches `crate' but it does + not match `dirty rat'. `\B' is essentially the opposite of `\y'. + + There are two other operators that work on buffers. In Emacs, a +"buffer" is, naturally, an Emacs buffer. For other programs, `gawk''s +regexp library routines consider the entire string to match as the +buffer. The operators are: + +`\`' + Matches the empty string at the beginning of a buffer (string). + +`\'' + Matches the empty string at the end of a buffer (string). + + Because `^' and `$' always work in terms of the beginning and end of +strings, these operators don't add any new capabilities for `awk'. +They are provided for compatibility with other GNU software. + + In other GNU software, the word-boundary operator is `\b'. However, +that conflicts with the `awk' language's definition of `\b' as +backspace, so `gawk' uses a different letter. An alternative method +would have been to require two backslashes in the GNU operators, but +this was deemed too confusing. The current method of using `\y' for the +GNU `\b' appears to be the lesser of two evils. + + The various command-line options (*note Options::) control how +`gawk' interprets characters in regexps: + +No options + In the default case, `gawk' provides all the facilities of POSIX + regexps and the GNU regexp operators described in *note Regexp + Operators::. + +`--posix' + Only POSIX regexps are supported; the GNU operators are not special + (e.g., `\w' matches a literal `w'). Interval expressions are + allowed. + +`--traditional' + Traditional Unix `awk' regexps are matched. The GNU operators are + not special, and interval expressions are not available. The + POSIX character classes (`[[:alnum:]]', etc.) are supported, as + Brian Kernighan's `awk' does support them. Characters described + by octal and hexadecimal escape sequences are treated literally, + even if they represent regexp metacharacters. + +`--re-interval' + Allow interval expressions in regexps, if `--traditional' has been + provided. Otherwise, interval expressions are available by + default. + + +File: gawk.info, Node: Case-sensitivity, Next: Leftmost Longest, Prev: GNU Regexp Operators, Up: Regexp + +3.6 Case Sensitivity in Matching +================================ + +Case is normally significant in regular expressions, both when matching +ordinary characters (i.e., not metacharacters) and inside bracket +expressions. Thus, a `w' in a regular expression matches only a +lowercase `w' and not an uppercase `W'. + + The simplest way to do a case-independent match is to use a bracket +expression--for example, `[Ww]'. However, this can be cumbersome if +you need to use it often, and it can make the regular expressions harder +to read. There are two alternatives that you might prefer. + + One way to perform a case-insensitive match at a particular point in +the program is to convert the data to a single case, using the +`tolower()' or `toupper()' built-in string functions (which we haven't +discussed yet; *note String Functions::). For example: + + tolower($1) ~ /foo/ { ... } + +converts the first field to lowercase before matching against it. This +works in any POSIX-compliant `awk'. + + Another method, specific to `gawk', is to set the variable +`IGNORECASE' to a nonzero value (*note Built-in Variables::). When +`IGNORECASE' is not zero, _all_ regexp and string operations ignore +case. Changing the value of `IGNORECASE' dynamically controls the +case-sensitivity of the program as it runs. Case is significant by +default because `IGNORECASE' (like most variables) is initialized to +zero: + + x = "aB" + if (x ~ /ab/) ... # this test will fail + + IGNORECASE = 1 + if (x ~ /ab/) ... # now it will succeed + + In general, you cannot use `IGNORECASE' to make certain rules +case-insensitive and other rules case-sensitive, because there is no +straightforward way to set `IGNORECASE' just for the pattern of a +particular rule.(1) To do this, use either bracket expressions or +`tolower()'. However, one thing you can do with `IGNORECASE' only is +dynamically turn case-sensitivity on or off for all the rules at once. + + `IGNORECASE' can be set on the command line or in a `BEGIN' rule +(*note Other Arguments::; also *note Using BEGIN/END::). Setting +`IGNORECASE' from the command line is a way to make a program +case-insensitive without having to edit it. + + Both regexp and string comparison operations are affected by +`IGNORECASE'. + + In multibyte locales, the equivalences between upper- and lowercase +characters are tested based on the wide-character values of the +locale's character set. Otherwise, the characters are tested based on +the ISO-8859-1 (ISO Latin-1) character set. This character set is a +superset of the traditional 128 ASCII characters, which also provides a +number of characters suitable for use with European languages.(2) + + The value of `IGNORECASE' has no effect if `gawk' is in +compatibility mode (*note Options::). Case is always significant in +compatibility mode. + + ---------- Footnotes ---------- + + (1) Experienced C and C++ programmers will note that it is possible, +using something like `IGNORECASE = 1 && /foObAr/ { ... }' and +`IGNORECASE = 0 || /foobar/ { ... }'. However, this is somewhat +obscure and we don't recommend it. + + (2) If you don't understand this, don't worry about it; it just +means that `gawk' does the right thing. + + +File: gawk.info, Node: Leftmost Longest, Next: Computed Regexps, Prev: Case-sensitivity, Up: Regexp + +3.7 How Much Text Matches? +========================== + +Consider the following: + + echo aaaabcd | awk '{ sub(/a+/, ""); print }' + + This example uses the `sub()' function (which we haven't discussed +yet; *note String Functions::) to make a change to the input record. +Here, the regexp `/a+/' indicates "one or more `a' characters," and the +replacement text is `'. + + The input contains four `a' characters. `awk' (and POSIX) regular +expressions always match the leftmost, _longest_ sequence of input +characters that can match. Thus, all four `a' characters are replaced +with `' in this example: + + $ echo aaaabcd | awk '{ sub(/a+/, ""); print }' + -| bcd + + For simple match/no-match tests, this is not so important. But when +doing text matching and substitutions with the `match()', `sub()', +`gsub()', and `gensub()' functions, it is very important. *Note String +Functions::, for more information on these functions. Understanding +this principle is also important for regexp-based record and field +splitting (*note Records::, and also *note Field Separators::). + + +File: gawk.info, Node: Computed Regexps, Prev: Leftmost Longest, Up: Regexp + +3.8 Using Dynamic Regexps +========================= + +The righthand side of a `~' or `!~' operator need not be a regexp +constant (i.e., a string of characters between slashes). It may be any +expression. The expression is evaluated and converted to a string if +necessary; the contents of the string are then used as the regexp. A +regexp computed in this way is called a "dynamic regexp": + + BEGIN { digits_regexp = "[[:digit:]]+" } + $0 ~ digits_regexp { print } + +This sets `digits_regexp' to a regexp that describes one or more digits, +and tests whether the input record matches this regexp. + + NOTE: When using the `~' and `!~' operators, there is a difference + between a regexp constant enclosed in slashes and a string + constant enclosed in double quotes. If you are going to use a + string constant, you have to understand that the string is, in + essence, scanned _twice_: the first time when `awk' reads your + program, and the second time when it goes to match the string on + the lefthand side of the operator with the pattern on the right. + This is true of any string-valued expression (such as + `digits_regexp', shown previously), not just string constants. + + What difference does it make if the string is scanned twice? The +answer has to do with escape sequences, and particularly with +backslashes. To get a backslash into a regular expression inside a +string, you have to type two backslashes. + + For example, `/\*/' is a regexp constant for a literal `*'. Only +one backslash is needed. To do the same thing with a string, you have +to type `"\\*"'. The first backslash escapes the second one so that +the string actually contains the two characters `\' and `*'. + + Given that you can use both regexp and string constants to describe +regular expressions, which should you use? The answer is "regexp +constants," for several reasons: + + * String constants are more complicated to write and more difficult + to read. Using regexp constants makes your programs less + error-prone. Not understanding the difference between the two + kinds of constants is a common source of errors. + + * It is more efficient to use regexp constants. `awk' can note that + you have supplied a regexp and store it internally in a form that + makes pattern matching more efficient. When using a string + constant, `awk' must first convert the string into this internal + form and then perform the pattern matching. + + * Using regexp constants is better form; it shows clearly that you + intend a regexp match. + +Advanced Notes: Using `\n' in Bracket Expressions of Dynamic Regexps +-------------------------------------------------------------------- + +Some commercial versions of `awk' do not allow the newline character to +be used inside a bracket expression for a dynamic regexp: + + $ awk '$0 ~ "[ \t\n]"' + error--> awk: newline in character class [ + error--> ]... + error--> source line number 1 + error--> context is + error--> >>> <<< + + But a newline in a regexp constant works with no problem: + + $ awk '$0 ~ /[ \t\n]/' + here is a sample line + -| here is a sample line + Ctrl-d + + `gawk' does not have this problem, and it isn't likely to occur +often in practice, but it's worth noting for future reference. + + +File: gawk.info, Node: Reading Files, Next: Printing, Prev: Regexp, Up: Top + +4 Reading Input Files +********************* + +In the typical `awk' program, `awk' reads all input either from the +standard input (by default, this is the keyboard, but often it is a +pipe from another command) or from files whose names you specify on the +`awk' command line. If you specify input files, `awk' reads them in +order, processing all the data from one before going on to the next. +The name of the current input file can be found in the built-in variable +`FILENAME' (*note Built-in Variables::). + + The input is read in units called "records", and is processed by the +rules of your program one record at a time. By default, each record is +one line. Each record is automatically split into chunks called +"fields". This makes it more convenient for programs to work on the +parts of a record. + + On rare occasions, you may need to use the `getline' command. The +`getline' command is valuable, both because it can do explicit input +from any number of files, and because the files used with it do not +have to be named on the `awk' command line (*note Getline::). + +* Menu: + +* Records:: Controlling how data is split into records. +* Fields:: An introduction to fields. +* Nonconstant Fields:: Nonconstant Field Numbers. +* Changing Fields:: Changing the Contents of a Field. +* Field Separators:: The field separator and how to change it. +* Constant Size:: Reading constant width data. +* Splitting By Content:: Defining Fields By Content +* Multiple Line:: Reading multi-line records. +* Getline:: Reading files under explicit program control + using the `getline' function. +* Command line directories:: What happens if you put a directory on the + command line. + + +File: gawk.info, Node: Records, Next: Fields, Up: Reading Files + +4.1 How Input Is Split into Records +=================================== + +The `awk' utility divides the input for your `awk' program into records +and fields. `awk' keeps track of the number of records that have been +read so far from the current input file. This value is stored in a +built-in variable called `FNR'. It is reset to zero when a new file is +started. Another built-in variable, `NR', records the total number of +input records read so far from all data files. It starts at zero, but +is never automatically reset to zero. + + Records are separated by a character called the "record separator". +By default, the record separator is the newline character. This is why +records are, by default, single lines. A different character can be +used for the record separator by assigning the character to the +built-in variable `RS'. + + Like any other variable, the value of `RS' can be changed in the +`awk' program with the assignment operator, `=' (*note Assignment +Ops::). The new record-separator character should be enclosed in +quotation marks, which indicate a string constant. Often the right +time to do this is at the beginning of execution, before any input is +processed, so that the very first record is read with the proper +separator. To do this, use the special `BEGIN' pattern (*note +BEGIN/END::). For example: + + awk 'BEGIN { RS = "/" } + { print $0 }' BBS-list + +changes the value of `RS' to `"/"', before reading any input. This is +a string whose first character is a slash; as a result, records are +separated by slashes. Then the input file is read, and the second rule +in the `awk' program (the action with no pattern) prints each record. +Because each `print' statement adds a newline at the end of its output, +this `awk' program copies the input with each slash changed to a +newline. Here are the results of running the program on `BBS-list': + + $ awk 'BEGIN { RS = "/" } + > { print $0 }' BBS-list + -| aardvark 555-5553 1200 + -| 300 B + -| alpo-net 555-3412 2400 + -| 1200 + -| 300 A + -| barfly 555-7685 1200 + -| 300 A + -| bites 555-1675 2400 + -| 1200 + -| 300 A + -| camelot 555-0542 300 C + -| core 555-2912 1200 + -| 300 C + -| fooey 555-1234 2400 + -| 1200 + -| 300 B + -| foot 555-6699 1200 + -| 300 B + -| macfoo 555-6480 1200 + -| 300 A + -| sdace 555-3430 2400 + -| 1200 + -| 300 A + -| sabafoo 555-2127 1200 + -| 300 C + -| + +Note that the entry for the `camelot' BBS is not split. In the +original data file (*note Sample Data Files::), the line looks like +this: + + camelot 555-0542 300 C + +It has one baud rate only, so there are no slashes in the record, +unlike the others which have two or more baud rates. In fact, this +record is treated as part of the record for the `core' BBS; the newline +separating them in the output is the original newline in the data file, +not the one added by `awk' when it printed the record! + + Another way to change the record separator is on the command line, +using the variable-assignment feature (*note Other Arguments::): + + awk '{ print $0 }' RS="/" BBS-list + +This sets `RS' to `/' before processing `BBS-list'. + + Using an unusual character such as `/' for the record separator +produces correct behavior in the vast majority of cases. However, the +following (extreme) pipeline prints a surprising `1': + + $ echo | awk 'BEGIN { RS = "a" } ; { print NF }' + -| 1 + + There is one field, consisting of a newline. The value of the +built-in variable `NF' is the number of fields in the current record. + + Reaching the end of an input file terminates the current input +record, even if the last character in the file is not the character in +`RS'. (d.c.) + + The empty string `""' (a string without any characters) has a +special meaning as the value of `RS'. It means that records are +separated by one or more blank lines and nothing else. *Note Multiple +Line::, for more details. + + If you change the value of `RS' in the middle of an `awk' run, the +new value is used to delimit subsequent records, but the record +currently being processed, as well as records already processed, are not +affected. + + After the end of the record has been determined, `gawk' sets the +variable `RT' to the text in the input that matched `RS'. + + When using `gawk', the value of `RS' is not limited to a +one-character string. It can be any regular expression (*note +Regexp::). (c.e.) In general, each record ends at the next string that +matches the regular expression; the next record starts at the end of +the matching string. This general rule is actually at work in the +usual case, where `RS' contains just a newline: a record ends at the +beginning of the next matching string (the next newline in the input), +and the following record starts just after the end of this string (at +the first character of the following line). The newline, because it +matches `RS', is not part of either record. + + When `RS' is a single character, `RT' contains the same single +character. However, when `RS' is a regular expression, `RT' contains +the actual input text that matched the regular expression. + + If the input file ended without any text that matches `RS', `gawk' +sets `RT' to the null string. + + The following example illustrates both of these features. It sets +`RS' equal to a regular expression that matches either a newline or a +series of one or more uppercase letters with optional leading and/or +trailing whitespace: + + $ echo record 1 AAAA record 2 BBBB record 3 | + > gawk 'BEGIN { RS = "\n|( *[[:upper:]]+ *)" } + > { print "Record =", $0, "and RT =", RT }' + -| Record = record 1 and RT = AAAA + -| Record = record 2 and RT = BBBB + -| Record = record 3 and RT = + -| + +The final line of output has an extra blank line. This is because the +value of `RT' is a newline, and the `print' statement supplies its own +terminating newline. *Note Simple Sed::, for a more useful example of +`RS' as a regexp and `RT'. + + If you set `RS' to a regular expression that allows optional +trailing text, such as `RS = "abc(XYZ)?"' it is possible, due to +implementation constraints, that `gawk' may match the leading part of +the regular expression, but not the trailing part, particularly if the +input text that could match the trailing part is fairly long. `gawk' +attempts to avoid this problem, but currently, there's no guarantee +that this will never happen. + + NOTE: Remember that in `awk', the `^' and `$' anchor + metacharacters match the beginning and end of a _string_, and not + the beginning and end of a _line_. As a result, something like + `RS = "^[[:upper:]]"' can only match at the beginning of a file. + This is because `gawk' views the input file as one long string + that happens to contain newline characters in it. It is thus best + to avoid anchor characters in the value of `RS'. + + The use of `RS' as a regular expression and the `RT' variable are +`gawk' extensions; they are not available in compatibility mode (*note +Options::). In compatibility mode, only the first character of the +value of `RS' is used to determine the end of the record. + +Advanced Notes: `RS = "\0"' Is Not Portable +------------------------------------------- + +There are times when you might want to treat an entire data file as a +single record. The only way to make this happen is to give `RS' a +value that you know doesn't occur in the input file. This is hard to +do in a general way, such that a program always works for arbitrary +input files. + + You might think that for text files, the NUL character, which +consists of a character with all bits equal to zero, is a good value to +use for `RS' in this case: + + BEGIN { RS = "\0" } # whole file becomes one record? + + `gawk' in fact accepts this, and uses the NUL character for the +record separator. However, this usage is _not_ portable to other `awk' +implementations. + + All other `awk' implementations(1) store strings internally as +C-style strings. C strings use the NUL character as the string +terminator. In effect, this means that `RS = "\0"' is the same as `RS += ""'. (d.c.) + + The best way to treat a whole file as a single record is to simply +read the file in, one record at a time, concatenating each record onto +the end of the previous ones. + + ---------- Footnotes ---------- + + (1) At least that we know about. + + +File: gawk.info, Node: Fields, Next: Nonconstant Fields, Prev: Records, Up: Reading Files + +4.2 Examining Fields +==================== + +When `awk' reads an input record, the record is automatically "parsed" +or separated by the `awk' utility into chunks called "fields". By +default, fields are separated by "whitespace", like words in a line. +Whitespace in `awk' means any string of one or more spaces, TABs, or +newlines;(1) other characters, such as formfeed, vertical tab, etc., +that are considered whitespace by other languages, are _not_ considered +whitespace by `awk'. + + The purpose of fields is to make it more convenient for you to refer +to these pieces of the record. You don't have to use them--you can +operate on the whole record if you want--but fields are what make +simple `awk' programs so powerful. + + A dollar-sign (`$') is used to refer to a field in an `awk' program, +followed by the number of the field you want. Thus, `$1' refers to the +first field, `$2' to the second, and so on. (Unlike the Unix shells, +the field numbers are not limited to single digits. `$127' is the one +hundred twenty-seventh field in the record.) For example, suppose the +following is a line of input: + + This seems like a pretty nice example. + +Here the first field, or `$1', is `This', the second field, or `$2', is +`seems', and so on. Note that the last field, `$7', is `example.'. +Because there is no space between the `e' and the `.', the period is +considered part of the seventh field. + + `NF' is a built-in variable whose value is the number of fields in +the current record. `awk' automatically updates the value of `NF' each +time it reads a record. No matter how many fields there are, the last +field in a record can be represented by `$NF'. So, `$NF' is the same +as `$7', which is `example.'. If you try to reference a field beyond +the last one (such as `$8' when the record has only seven fields), you +get the empty string. (If used in a numeric operation, you get zero.) + + The use of `$0', which looks like a reference to the "zero-th" +field, is a special case: it represents the whole input record when you +are not interested in specific fields. Here are some more examples: + + $ awk '$1 ~ /foo/ { print $0 }' BBS-list + -| fooey 555-1234 2400/1200/300 B + -| foot 555-6699 1200/300 B + -| macfoo 555-6480 1200/300 A + -| sabafoo 555-2127 1200/300 C + +This example prints each record in the file `BBS-list' whose first +field contains the string `foo'. The operator `~' is called a +"matching operator" (*note Regexp Usage::); it tests whether a string +(here, the field `$1') matches a given regular expression. + + By contrast, the following example looks for `foo' in _the entire +record_ and prints the first field and the last field for each matching +input record: + + $ awk '/foo/ { print $1, $NF }' BBS-list + -| fooey B + -| foot B + -| macfoo A + -| sabafoo C + + ---------- Footnotes ---------- + + (1) In POSIX `awk', newlines are not considered whitespace for +separating fields. + + +File: gawk.info, Node: Nonconstant Fields, Next: Changing Fields, Prev: Fields, Up: Reading Files + +4.3 Nonconstant Field Numbers +============================= + +The number of a field does not need to be a constant. Any expression in +the `awk' language can be used after a `$' to refer to a field. The +value of the expression specifies the field number. If the value is a +string, rather than a number, it is converted to a number. Consider +this example: + + awk '{ print $NR }' + +Recall that `NR' is the number of records read so far: one in the first +record, two in the second, etc. So this example prints the first field +of the first record, the second field of the second record, and so on. +For the twentieth record, field number 20 is printed; most likely, the +record has fewer than 20 fields, so this prints a blank line. Here is +another example of using expressions as field numbers: + + awk '{ print $(2*2) }' BBS-list + + `awk' evaluates the expression `(2*2)' and uses its value as the +number of the field to print. The `*' sign represents multiplication, +so the expression `2*2' evaluates to four. The parentheses are used so +that the multiplication is done before the `$' operation; they are +necessary whenever there is a binary operator in the field-number +expression. This example, then, prints the hours of operation (the +fourth field) for every line of the file `BBS-list'. (All of the `awk' +operators are listed, in order of decreasing precedence, in *note +Precedence::.) + + If the field number you compute is zero, you get the entire record. +Thus, `$(2-2)' has the same value as `$0'. Negative field numbers are +not allowed; trying to reference one usually terminates the program. +(The POSIX standard does not define what happens when you reference a +negative field number. `gawk' notices this and terminates your +program. Other `awk' implementations may behave differently.) + + As mentioned in *note Fields::, `awk' stores the current record's +number of fields in the built-in variable `NF' (also *note Built-in +Variables::). The expression `$NF' is not a special feature--it is the +direct consequence of evaluating `NF' and using its value as a field +number. + + +File: gawk.info, Node: Changing Fields, Next: Field Separators, Prev: Nonconstant Fields, Up: Reading Files + +4.4 Changing the Contents of a Field +==================================== + +The contents of a field, as seen by `awk', can be changed within an +`awk' program; this changes what `awk' perceives as the current input +record. (The actual input is untouched; `awk' _never_ modifies the +input file.) Consider the following example and its output: + + $ awk '{ nboxes = $3 ; $3 = $3 - 10 + > print nboxes, $3 }' inventory-shipped + -| 25 15 + -| 32 22 + -| 24 14 + ... + +The program first saves the original value of field three in the +variable `nboxes'. The `-' sign represents subtraction, so this +program reassigns field three, `$3', as the original value of field +three minus ten: `$3 - 10'. (*Note Arithmetic Ops::.) Then it prints +the original and new values for field three. (Someone in the warehouse +made a consistent mistake while inventorying the red boxes.) + + For this to work, the text in field `$3' must make sense as a +number; the string of characters must be converted to a number for the +computer to do arithmetic on it. The number resulting from the +subtraction is converted back to a string of characters that then +becomes field three. *Note Conversion::. + + When the value of a field is changed (as perceived by `awk'), the +text of the input record is recalculated to contain the new field where +the old one was. In other words, `$0' changes to reflect the altered +field. Thus, this program prints a copy of the input file, with 10 +subtracted from the second field of each line: + + $ awk '{ $2 = $2 - 10; print $0 }' inventory-shipped + -| Jan 3 25 15 115 + -| Feb 5 32 24 226 + -| Mar 5 24 34 228 + ... + + It is also possible to also assign contents to fields that are out +of range. For example: + + $ awk '{ $6 = ($5 + $4 + $3 + $2) + > print $6 }' inventory-shipped + -| 168 + -| 297 + -| 301 + ... + +We've just created `$6', whose value is the sum of fields `$2', `$3', +`$4', and `$5'. The `+' sign represents addition. For the file +`inventory-shipped', `$6' represents the total number of parcels +shipped for a particular month. + + Creating a new field changes `awk''s internal copy of the current +input record, which is the value of `$0'. Thus, if you do `print $0' +after adding a field, the record printed includes the new field, with +the appropriate number of field separators between it and the previously +existing fields. + + This recomputation affects and is affected by `NF' (the number of +fields; *note Fields::). For example, the value of `NF' is set to the +number of the highest field you create. The exact format of `$0' is +also affected by a feature that has not been discussed yet: the "output +field separator", `OFS', used to separate the fields (*note Output +Separators::). + + Note, however, that merely _referencing_ an out-of-range field does +_not_ change the value of either `$0' or `NF'. Referencing an +out-of-range field only produces an empty string. For example: + + if ($(NF+1) != "") + print "can't happen" + else + print "everything is normal" + +should print `everything is normal', because `NF+1' is certain to be +out of range. (*Note If Statement::, for more information about +`awk''s `if-else' statements. *Note Typing and Comparison::, for more +information about the `!=' operator.) + + It is important to note that making an assignment to an existing +field changes the value of `$0' but does not change the value of `NF', +even when you assign the empty string to a field. For example: + + $ echo a b c d | awk '{ OFS = ":"; $2 = "" + > print $0; print NF }' + -| a::c:d + -| 4 + +The field is still there; it just has an empty value, denoted by the +two colons between `a' and `c'. This example shows what happens if you +create a new field: + + $ echo a b c d | awk '{ OFS = ":"; $2 = ""; $6 = "new" + > print $0; print NF }' + -| a::c:d::new + -| 6 + +The intervening field, `$5', is created with an empty value (indicated +by the second pair of adjacent colons), and `NF' is updated with the +value six. + + Decrementing `NF' throws away the values of the fields after the new +value of `NF' and recomputes `$0'. (d.c.) Here is an example: + + $ echo a b c d e f | awk '{ print "NF =", NF; + > NF = 3; print $0 }' + -| NF = 6 + -| a b c + + CAUTION: Some versions of `awk' don't rebuild `$0' when `NF' is + decremented. Caveat emptor. + + Finally, there are times when it is convenient to force `awk' to +rebuild the entire record, using the current value of the fields and +`OFS'. To do this, use the seemingly innocuous assignment: + + $1 = $1 # force record to be reconstituted + print $0 # or whatever else with $0 + +This forces `awk' to rebuild the record. It does help to add a +comment, as we've shown here. + + There is a flip side to the relationship between `$0' and the +fields. Any assignment to `$0' causes the record to be reparsed into +fields using the _current_ value of `FS'. This also applies to any +built-in function that updates `$0', such as `sub()' and `gsub()' +(*note String Functions::). + +Advanced Notes: Understanding `$0' +---------------------------------- + +It is important to remember that `$0' is the _full_ record, exactly as +it was read from the input. This includes any leading or trailing +whitespace, and the exact whitespace (or other characters) that +separate the fields. + + It is a not-uncommon error to try to change the field separators in +a record simply by setting `FS' and `OFS', and then expecting a plain +`print' or `print $0' to print the modified record. + + But this does not work, since nothing was done to change the record +itself. Instead, you must force the record to be rebuilt, typically +with a statement such as `$1 = $1', as described earlier. + + +File: gawk.info, Node: Field Separators, Next: Constant Size, Prev: Changing Fields, Up: Reading Files + +4.5 Specifying How Fields Are Separated +======================================= + +* Menu: + +* Default Field Splitting:: How fields are normally separated. +* Regexp Field Splitting:: Using regexps as the field separator. +* Single Character Fields:: Making each character a separate field. +* Command Line Field Separator:: Setting `FS' from the command-line. +* Field Splitting Summary:: Some final points and a summary table. + + The "field separator", which is either a single character or a +regular expression, controls the way `awk' splits an input record into +fields. `awk' scans the input record for character sequences that +match the separator; the fields themselves are the text between the +matches. + + In the examples that follow, we use the bullet symbol (*) to +represent spaces in the output. If the field separator is `oo', then +the following line: + + moo goo gai pan + +is split into three fields: `m', `*g', and `*gai*pan'. Note the +leading spaces in the values of the second and third fields. + + The field separator is represented by the built-in variable `FS'. +Shell programmers take note: `awk' does _not_ use the name `IFS' that +is used by the POSIX-compliant shells (such as the Unix Bourne shell, +`sh', or Bash). + + The value of `FS' can be changed in the `awk' program with the +assignment operator, `=' (*note Assignment Ops::). Often the right +time to do this is at the beginning of execution before any input has +been processed, so that the very first record is read with the proper +separator. To do this, use the special `BEGIN' pattern (*note +BEGIN/END::). For example, here we set the value of `FS' to the string +`","': + + awk 'BEGIN { FS = "," } ; { print $2 }' + +Given the input line: + + John Q. Smith, 29 Oak St., Walamazoo, MI 42139 + +this `awk' program extracts and prints the string `*29*Oak*St.'. + + Sometimes the input data contains separator characters that don't +separate fields the way you thought they would. For instance, the +person's name in the example we just used might have a title or suffix +attached, such as: + + John Q. Smith, LXIX, 29 Oak St., Walamazoo, MI 42139 + +The same program would extract `*LXIX', instead of `*29*Oak*St.'. If +you were expecting the program to print the address, you would be +surprised. The moral is to choose your data layout and separator +characters carefully to prevent such problems. (If the data is not in +a form that is easy to process, perhaps you can massage it first with a +separate `awk' program.) + + +File: gawk.info, Node: Default Field Splitting, Next: Regexp Field Splitting, Up: Field Separators + +4.5.1 Whitespace Normally Separates Fields +------------------------------------------ + +Fields are normally separated by whitespace sequences (spaces, TABs, +and newlines), not by single spaces. Two spaces in a row do not +delimit an empty field. The default value of the field separator `FS' +is a string containing a single space, `" "'. If `awk' interpreted +this value in the usual way, each space character would separate +fields, so two spaces in a row would make an empty field between them. +The reason this does not happen is that a single space as the value of +`FS' is a special case--it is taken to specify the default manner of +delimiting fields. + + If `FS' is any other single character, such as `","', then each +occurrence of that character separates two fields. Two consecutive +occurrences delimit an empty field. If the character occurs at the +beginning or the end of the line, that too delimits an empty field. The +space character is the only single character that does not follow these +rules. + + +File: gawk.info, Node: Regexp Field Splitting, Next: Single Character Fields, Prev: Default Field Splitting, Up: Field Separators + +4.5.2 Using Regular Expressions to Separate Fields +-------------------------------------------------- + +The previous node discussed the use of single characters or simple +strings as the value of `FS'. More generally, the value of `FS' may be +a string containing any regular expression. In this case, each match +in the record for the regular expression separates fields. For +example, the assignment: + + FS = ", \t" + +makes every area of an input line that consists of a comma followed by a +space and a TAB into a field separator. (`\t' is an "escape sequence" +that stands for a TAB; *note Escape Sequences::, for the complete list +of similar escape sequences.) + + For a less trivial example of a regular expression, try using single +spaces to separate fields the way single commas are used. `FS' can be +set to `"[ ]"' (left bracket, space, right bracket). This regular +expression matches a single space and nothing else (*note Regexp::). + + There is an important difference between the two cases of `FS = " "' +(a single space) and `FS = "[ \t\n]+"' (a regular expression matching +one or more spaces, TABs, or newlines). For both values of `FS', +fields are separated by "runs" (multiple adjacent occurrences) of +spaces, TABs, and/or newlines. However, when the value of `FS' is +`" "', `awk' first strips leading and trailing whitespace from the +record and then decides where the fields are. For example, the +following pipeline prints `b': + + $ echo ' a b c d ' | awk '{ print $2 }' + -| b + +However, this pipeline prints `a' (note the extra spaces around each +letter): + + $ echo ' a b c d ' | awk 'BEGIN { FS = "[ \t\n]+" } + > { print $2 }' + -| a + +In this case, the first field is "null" or empty. + + The stripping of leading and trailing whitespace also comes into +play whenever `$0' is recomputed. For instance, study this pipeline: + + $ echo ' a b c d' | awk '{ print; $2 = $2; print }' + -| a b c d + -| a b c d + +The first `print' statement prints the record as it was read, with +leading whitespace intact. The assignment to `$2' rebuilds `$0' by +concatenating `$1' through `$NF' together, separated by the value of +`OFS'. Because the leading whitespace was ignored when finding `$1', +it is not part of the new `$0'. Finally, the last `print' statement +prints the new `$0'. + + There is an additional subtlety to be aware of when using regular +expressions for field splitting. It is not well-specified in the POSIX +standard, or anywhere else, what `^' means when splitting fields. Does +the `^' match only at the beginning of the entire record? Or is each +field separator a new string? It turns out that different `awk' +versions answer this question differently, and you should not rely on +any specific behavior in your programs. (d.c.) + + As a point of information, Brian Kernighan's `awk' allows `^' to +match only at the beginning of the record. `gawk' also works this way. +For example: + + $ echo 'xxAA xxBxx C' | + > gawk -F '(^x+)|( +)' '{ for (i = 1; i <= NF; i++) + > printf "-->%s<--\n", $i }' + -| --><-- + -| -->AA<-- + -| -->xxBxx<-- + -| -->C<-- + + +File: gawk.info, Node: Single Character Fields, Next: Command Line Field Separator, Prev: Regexp Field Splitting, Up: Field Separators + +4.5.3 Making Each Character a Separate Field +-------------------------------------------- + +There are times when you may want to examine each character of a record +separately. This can be done in `gawk' by simply assigning the null +string (`""') to `FS'. (c.e.) In this case, each individual character +in the record becomes a separate field. For example: + + $ echo a b | gawk 'BEGIN { FS = "" } + > { + > for (i = 1; i <= NF; i = i + 1) + > print "Field", i, "is", $i + > }' + -| Field 1 is a + -| Field 2 is + -| Field 3 is b + + Traditionally, the behavior of `FS' equal to `""' was not defined. +In this case, most versions of Unix `awk' simply treat the entire record +as only having one field. (d.c.) In compatibility mode (*note +Options::), if `FS' is the null string, then `gawk' also behaves this +way. + + +File: gawk.info, Node: Command Line Field Separator, Next: Field Splitting Summary, Prev: Single Character Fields, Up: Field Separators + +4.5.4 Setting `FS' from the Command Line +---------------------------------------- + +`FS' can be set on the command line. Use the `-F' option to do so. +For example: + + awk -F, 'PROGRAM' INPUT-FILES + +sets `FS' to the `,' character. Notice that the option uses an +uppercase `F' instead of a lowercase `f'. The latter option (`-f') +specifies a file containing an `awk' program. Case is significant in +command-line options: the `-F' and `-f' options have nothing to do with +each other. You can use both options at the same time to set the `FS' +variable _and_ get an `awk' program from a file. + + The value used for the argument to `-F' is processed in exactly the +same way as assignments to the built-in variable `FS'. Any special +characters in the field separator must be escaped appropriately. For +example, to use a `\' as the field separator on the command line, you +would have to type: + + # same as FS = "\\" + awk -F\\\\ '...' files ... + +Because `\' is used for quoting in the shell, `awk' sees `-F\\'. Then +`awk' processes the `\\' for escape characters (*note Escape +Sequences::), finally yielding a single `\' to use for the field +separator. + + As a special case, in compatibility mode (*note Options::), if the +argument to `-F' is `t', then `FS' is set to the TAB character. If you +type `-F\t' at the shell, without any quotes, the `\' gets deleted, so +`awk' figures that you really want your fields to be separated with +TABs and not `t's. Use `-v FS="t"' or `-F"[t]"' on the command line if +you really do want to separate your fields with `t's. + + As an example, let's use an `awk' program file called `baud.awk' +that contains the pattern `/300/' and the action `print $1': + + /300/ { print $1 } + + Let's also set `FS' to be the `-' character and run the program on +the file `BBS-list'. The following command prints a list of the names +of the bulletin boards that operate at 300 baud and the first three +digits of their phone numbers: + + $ awk -F- -f baud.awk BBS-list + -| aardvark 555 + -| alpo + -| barfly 555 + -| bites 555 + -| camelot 555 + -| core 555 + -| fooey 555 + -| foot 555 + -| macfoo 555 + -| sdace 555 + -| sabafoo 555 + +Note the second line of output. The second line in the original file +looked like this: + + alpo-net 555-3412 2400/1200/300 A + + The `-' as part of the system's name was used as the field +separator, instead of the `-' in the phone number that was originally +intended. This demonstrates why you have to be careful in choosing +your field and record separators. + + Perhaps the most common use of a single character as the field +separator occurs when processing the Unix system password file. On +many Unix systems, each user has a separate entry in the system password +file, one line per user. The information in these lines is separated +by colons. The first field is the user's login name and the second is +the user's (encrypted or shadow) password. A password file entry might +look like this: + + arnold:xyzzy:2076:10:Arnold Robbins:/home/arnold:/bin/bash + + The following program searches the system password file and prints +the entries for users who have no password: + + awk -F: '$2 == ""' /etc/passwd + + +File: gawk.info, Node: Field Splitting Summary, Prev: Command Line Field Separator, Up: Field Separators + +4.5.5 Field-Splitting Summary +----------------------------- + +It is important to remember that when you assign a string constant as +the value of `FS', it undergoes normal `awk' string processing. For +example, with Unix `awk' and `gawk', the assignment `FS = "\.."' +assigns the character string `".."' to `FS' (the backslash is +stripped). This creates a regexp meaning "fields are separated by +occurrences of any two characters." If instead you want fields to be +separated by a literal period followed by any single character, use `FS += "\\.."'. + + The following table summarizes how fields are split, based on the +value of `FS' (`==' means "is equal to"): + +`FS == " "' + Fields are separated by runs of whitespace. Leading and trailing + whitespace are ignored. This is the default. + +`FS == ANY OTHER SINGLE CHARACTER' + Fields are separated by each occurrence of the character. Multiple + successive occurrences delimit empty fields, as do leading and + trailing occurrences. The character can even be a regexp + metacharacter; it does not need to be escaped. + +`FS == REGEXP' + Fields are separated by occurrences of characters that match + REGEXP. Leading and trailing matches of REGEXP delimit empty + fields. + +`FS == ""' + Each individual character in the record becomes a separate field. + (This is a `gawk' extension; it is not specified by the POSIX + standard.) + +Advanced Notes: Changing `FS' Does Not Affect the Fields +-------------------------------------------------------- + +According to the POSIX standard, `awk' is supposed to behave as if each +record is split into fields at the time it is read. In particular, +this means that if you change the value of `FS' after a record is read, +the value of the fields (i.e., how they were split) should reflect the +old value of `FS', not the new one. + + However, many older implementations of `awk' do not work this way. +Instead, they defer splitting the fields until a field is actually +referenced. The fields are split using the _current_ value of `FS'! +(d.c.) This behavior can be difficult to diagnose. The following +example illustrates the difference between the two methods. (The +`sed'(1) command prints just the first line of `/etc/passwd'.) + + sed 1q /etc/passwd | awk '{ FS = ":" ; print $1 }' + +which usually prints: + + root + +on an incorrect implementation of `awk', while `gawk' prints something +like: + + root:nSijPlPhZZwgE:0:0:Root:/: + +Advanced Notes: `FS' and `IGNORECASE' +------------------------------------- + +The `IGNORECASE' variable (*note User-modified::) affects field +splitting _only_ when the value of `FS' is a regexp. It has no effect +when `FS' is a single character, even if that character is a letter. +Thus, in the following code: + + FS = "c" + IGNORECASE = 1 + $0 = "aCa" + print $1 + +The output is `aCa'. If you really want to split fields on an +alphabetic character while ignoring case, use a regexp that will do it +for you. E.g., `FS = "[c]"'. In this case, `IGNORECASE' will take +effect. + + ---------- Footnotes ---------- + + (1) The `sed' utility is a "stream editor." Its behavior is also +defined by the POSIX standard. + + +File: gawk.info, Node: Constant Size, Next: Splitting By Content, Prev: Field Separators, Up: Reading Files + +4.6 Reading Fixed-Width Data +============================ + +(This minor node discusses an advanced feature of `awk'. If you are a +novice `awk' user, you might want to skip it on the first reading.) + +`gawk' provides a facility for dealing with fixed-width fields with no +distinctive field separator. For example, data of this nature arises +in the input for old Fortran programs where numbers are run together, +or in the output of programs that did not anticipate the use of their +output as input for other programs. + + An example of the latter is a table where all the columns are lined +up by the use of a variable number of spaces and _empty fields are just +spaces_. Clearly, `awk''s normal field splitting based on `FS' does +not work well in this case. Although a portable `awk' program can use +a series of `substr()' calls on `$0' (*note String Functions::), this +is awkward and inefficient for a large number of fields. + + The splitting of an input record into fixed-width fields is +specified by assigning a string containing space-separated numbers to +the built-in variable `FIELDWIDTHS'. Each number specifies the width +of the field, _including_ columns between fields. If you want to +ignore the columns between fields, you can specify the width as a +separate field that is subsequently ignored. It is a fatal error to +supply a field width that is not a positive number. The following data +is the output of the Unix `w' utility. It is useful to illustrate the +use of `FIELDWIDTHS': + + 10:06pm up 21 days, 14:04, 23 users + User tty login idle JCPU PCPU what + hzuo ttyV0 8:58pm 9 5 vi p24.tex + hzang ttyV3 6:37pm 50 -csh + eklye ttyV5 9:53pm 7 1 em thes.tex + dportein ttyV6 8:17pm 1:47 -csh + gierd ttyD3 10:00pm 1 elm + dave ttyD4 9:47pm 4 4 w + brent ttyp0 26Jun91 4:46 26:46 4:41 bash + dave ttyq4 26Jun9115days 46 46 wnewmail + + The following program takes the above input, converts the idle time +to number of seconds, and prints out the first two fields and the +calculated idle time: + + NOTE: This program uses a number of `awk' features that haven't + been introduced yet. + + BEGIN { FIELDWIDTHS = "9 6 10 6 7 7 35" } + NR > 2 { + idle = $4 + sub(/^ */, "", idle) # strip leading spaces + if (idle == "") + idle = 0 + if (idle ~ /:/) { + split(idle, t, ":") + idle = t[1] * 60 + t[2] + } + if (idle ~ /days/) + idle *= 24 * 60 * 60 + + print $1, $2, idle + } + + Running the program on the data produces the following results: + + hzuo ttyV0 0 + hzang ttyV3 50 + eklye ttyV5 0 + dportein ttyV6 107 + gierd ttyD3 1 + dave ttyD4 0 + brent ttyp0 286 + dave ttyq4 1296000 + + Another (possibly more practical) example of fixed-width input data +is the input from a deck of balloting cards. In some parts of the +United States, voters mark their choices by punching holes in computer +cards. These cards are then processed to count the votes for any +particular candidate or on any particular issue. Because a voter may +choose not to vote on some issue, any column on the card may be empty. +An `awk' program for processing such data could use the `FIELDWIDTHS' +feature to simplify reading the data. (Of course, getting `gawk' to +run on a system with card readers is another story!) + + Assigning a value to `FS' causes `gawk' to use `FS' for field +splitting again. Use `FS = FS' to make this happen, without having to +know the current value of `FS'. In order to tell which kind of field +splitting is in effect, use `PROCINFO["FS"]' (*note Auto-set::). The +value is `"FS"' if regular field splitting is being used, or it is +`"FIELDWIDTHS"' if fixed-width field splitting is being used: + + if (PROCINFO["FS"] == "FS") + REGULAR FIELD SPLITTING ... + else if (PROCINFO["FS"] == "FIELDWIDTHS") + FIXED-WIDTH FIELD SPLITTING ... + else + CONTENT-BASED FIELD SPLITTING ... (see next minor node) + + This information is useful when writing a function that needs to +temporarily change `FS' or `FIELDWIDTHS', read some records, and then +restore the original settings (*note Passwd Functions::, for an example +of such a function). + + +File: gawk.info, Node: Splitting By Content, Next: Multiple Line, Prev: Constant Size, Up: Reading Files + +4.7 Defining Fields By Content +============================== + +(This minor node discusses an advanced feature of `awk'. If you are a +novice `awk' user, you might want to skip it on the first reading.) + +Normally, when using `FS', `gawk' defines the fields as the parts of +the record that occur in between each field separator. In other words, +`FS' defines what a field _is not_, instead of what a field _is_. +However, there are times when you really want to define the fields by +what they are, and not by what they are not. + + The most notorious such case is so-called "comma separated value" +(CSV) data. Many spreadsheet programs, for example, can export their +data into text files, where each record is terminated with a newline, +and fields are separated by commas. If only commas separated the data, +there wouldn't be an issue. The problem comes when one of the fields +contains an _embedded_ comma. While there is no formal standard +specification for CSV data(1), in such cases, most programs embed the +field in double quotes. So we might have data like this: + + Robbins,Arnold,"1234 A Pretty Street, NE",MyTown,MyState,12345-6789,USA + + The `FPAT' variable offers a solution for cases like this. The +value of `FPAT' should be a string that provides a regular expression. +This regular expression describes the contents of each field. + + In the case of CSV data as presented above, each field is either +"anything that is not a comma," or "a double quote, anything that is +not a double quote, and a closing double quote." If written as a +regular expression constant (*note Regexp::), we would have +`/([^,]+)|("[^"]+")/'. Writing this as a string requires us to escape +the double quotes, leading to: + + FPAT = "([^,]+)|(\"[^\"]+\")" + + Putting this to use, here is a simple program to parse the data: + + BEGIN { + FPAT = "([^,]+)|(\"[^\"]+\")" + } + + { + print "NF = ", NF + for (i = 1; i <= NF; i++) { + printf("$%d = <%s>\n", i, $i) + } + } + + When run, we get the following: + + $ gawk -f simple-csv.awk addresses.csv + NF = 7 + $1 = + $2 = + $3 = <"1234 A Pretty Street, NE"> + $4 = + $5 = + $6 = <12345-6789> + $7 = + + Note the embedded comma in the value of `$3'. + + A straightforward improvement when processing CSV data of this sort +would be to remove the quotes when they occur, with something like this: + + if (substr($i, 1, 1) == "\"") { + len = length($i) + $i = substr($i, 2, len - 2) # Get text within the two quotes + } + + As with `FS', the `IGNORECASE' variable (*note User-modified::) +affects field splitting with `FPAT'. + + Similar to `FIELDWIDTHS', the value of `PROCINFO["FS"]' will be +`"FPAT"' if content-based field splitting is being used. + + NOTE: Some programs export CSV data that contains embedded + newlines between the double quotes. `gawk' provides no way to + deal with this. Since there is no formal specification for CSV + data, there isn't much more to be done; the `FPAT' mechanism + provides an elegant solution for the majority of cases, and the + `gawk' maintainer is satisfied with that. + + As written, the regexp used for `FPAT' requires that each field have +a least one character. A straightforward modification (changing +changed the first `+' to `*') allows fields to be empty: + + FPAT = "([^,]*)|(\"[^\"]+\")" + + Finally, the `patsplit()' function makes the same functionality +available for splitting regular strings (*note String Functions::). + + ---------- Footnotes ---------- + + (1) At least, we don't know of one. + + +File: gawk.info, Node: Multiple Line, Next: Getline, Prev: Splitting By Content, Up: Reading Files + +4.8 Multiple-Line Records +========================= + +In some databases, a single line cannot conveniently hold all the +information in one entry. In such cases, you can use multiline +records. The first step in doing this is to choose your data format. + + One technique is to use an unusual character or string to separate +records. For example, you could use the formfeed character (written +`\f' in `awk', as in C) to separate them, making each record a page of +the file. To do this, just set the variable `RS' to `"\f"' (a string +containing the formfeed character). Any other character could equally +well be used, as long as it won't be part of the data in a record. + + Another technique is to have blank lines separate records. By a +special dispensation, an empty string as the value of `RS' indicates +that records are separated by one or more blank lines. When `RS' is set +to the empty string, each record always ends at the first blank line +encountered. The next record doesn't start until the first nonblank +line that follows. No matter how many blank lines appear in a row, they +all act as one record separator. (Blank lines must be completely +empty; lines that contain only whitespace do not count.) + + You can achieve the same effect as `RS = ""' by assigning the string +`"\n\n+"' to `RS'. This regexp matches the newline at the end of the +record and one or more blank lines after the record. In addition, a +regular expression always matches the longest possible sequence when +there is a choice (*note Leftmost Longest::). So the next record +doesn't start until the first nonblank line that follows--no matter how +many blank lines appear in a row, they are considered one record +separator. + + There is an important difference between `RS = ""' and `RS = +"\n\n+"'. In the first case, leading newlines in the input data file +are ignored, and if a file ends without extra blank lines after the +last record, the final newline is removed from the record. In the +second case, this special processing is not done. (d.c.) + + Now that the input is separated into records, the second step is to +separate the fields in the record. One way to do this is to divide each +of the lines into fields in the normal manner. This happens by default +as the result of a special feature. When `RS' is set to the empty +string, _and_ `FS' is set to a single character, the newline character +_always_ acts as a field separator. This is in addition to whatever +field separations result from `FS'.(1) + + The original motivation for this special exception was probably to +provide useful behavior in the default case (i.e., `FS' is equal to +`" "'). This feature can be a problem if you really don't want the +newline character to separate fields, because there is no way to +prevent it. However, you can work around this by using the `split()' +function to break up the record manually (*note String Functions::). +If you have a single character field separator, you can work around the +special feature in a different way, by making `FS' into a regexp for +that single character. For example, if the field separator is a +percent character, instead of `FS = "%"', use `FS = "[%]"'. + + Another way to separate fields is to put each field on a separate +line: to do this, just set the variable `FS' to the string `"\n"'. +(This single character separator matches a single newline.) A +practical example of a data file organized this way might be a mailing +list, where each entry is separated by blank lines. Consider a mailing +list in a file named `addresses', which looks like this: + + Jane Doe + 123 Main Street + Anywhere, SE 12345-6789 + + John Smith + 456 Tree-lined Avenue + Smallville, MW 98765-4321 + ... + +A simple program to process this file is as follows: + + # addrs.awk --- simple mailing list program + + # Records are separated by blank lines. + # Each line is one field. + BEGIN { RS = "" ; FS = "\n" } + + { + print "Name is:", $1 + print "Address is:", $2 + print "City and State are:", $3 + print "" + } + + Running the program produces the following output: + + $ awk -f addrs.awk addresses + -| Name is: Jane Doe + -| Address is: 123 Main Street + -| City and State are: Anywhere, SE 12345-6789 + -| + -| Name is: John Smith + -| Address is: 456 Tree-lined Avenue + -| City and State are: Smallville, MW 98765-4321 + -| + ... + + *Note Labels Program::, for a more realistic program that deals with +address lists. The following table summarizes how records are split, +based on the value of `RS'. (`==' means "is equal to.") + +`RS == "\n"' + Records are separated by the newline character (`\n'). In effect, + every line in the data file is a separate record, including blank + lines. This is the default. + +`RS == ANY SINGLE CHARACTER' + Records are separated by each occurrence of the character. + Multiple successive occurrences delimit empty records. + +`RS == ""' + Records are separated by runs of blank lines. When `FS' is a + single character, then the newline character always serves as a + field separator, in addition to whatever value `FS' may have. + Leading and trailing newlines in a file are ignored. + +`RS == REGEXP' + Records are separated by occurrences of characters that match + REGEXP. Leading and trailing matches of REGEXP delimit empty + records. (This is a `gawk' extension; it is not specified by the + POSIX standard.) + + In all cases, `gawk' sets `RT' to the input text that matched the +value specified by `RS'. But if the input file ended without any text +that matches `RS', then `gawk' sets `RT' to the null string. + + ---------- Footnotes ---------- + + (1) When `FS' is the null string (`""') or a regexp, this special +feature of `RS' does not apply. It does apply to the default field +separator of a single space: `FS = " "'. + + +File: gawk.info, Node: Getline, Next: Command line directories, Prev: Multiple Line, Up: Reading Files + +4.9 Explicit Input with `getline' +================================= + +So far we have been getting our input data from `awk''s main input +stream--either the standard input (usually your terminal, sometimes the +output from another program) or from the files specified on the command +line. The `awk' language has a special built-in command called +`getline' that can be used to read input under your explicit control. + + The `getline' command is used in several different ways and should +_not_ be used by beginners. The examples that follow the explanation +of the `getline' command include material that has not been covered +yet. Therefore, come back and study the `getline' command _after_ you +have reviewed the rest of this Info file and have a good knowledge of +how `awk' works. + + The `getline' command returns one if it finds a record and zero if +it encounters the end of the file. If there is some error in getting a +record, such as a file that cannot be opened, then `getline' returns +-1. In this case, `gawk' sets the variable `ERRNO' to a string +describing the error that occurred. + + In the following examples, COMMAND stands for a string value that +represents a shell command. + + NOTE: When `--sandbox' is specified (*note Options::), reading + lines from files, pipes and coprocesses is disabled. + +* Menu: + +* Plain Getline:: Using `getline' with no arguments. +* Getline/Variable:: Using `getline' into a variable. +* Getline/File:: Using `getline' from a file. +* Getline/Variable/File:: Using `getline' into a variable from a + file. +* Getline/Pipe:: Using `getline' from a pipe. +* Getline/Variable/Pipe:: Using `getline' into a variable from a + pipe. +* Getline/Coprocess:: Using `getline' from a coprocess. +* Getline/Variable/Coprocess:: Using `getline' into a variable from a + coprocess. +* Getline Notes:: Important things to know about `getline'. +* Getline Summary:: Summary of `getline' Variants. + + +File: gawk.info, Node: Plain Getline, Next: Getline/Variable, Up: Getline + +4.9.1 Using `getline' with No Arguments +--------------------------------------- + +The `getline' command can be used without arguments to read input from +the current input file. All it does in this case is read the next +input record and split it up into fields. This is useful if you've +finished processing the current record, but want to do some special +processing on the next record _right now_. For example: + + { + if ((t = index($0, "/*")) != 0) { + # value of `tmp' will be "" if t is 1 + tmp = substr($0, 1, t - 1) + u = index(substr($0, t + 2), "*/") + offset = t + 2 + while (u == 0) { + if (getline <= 0) { + m = "unexpected EOF or error" + m = (m ": " ERRNO) + print m > "/dev/stderr" + exit + } + u = index($0, "*/") + offset = 0 + } + # substr() expression will be "" if */ + # occurred at end of line + $0 = tmp substr($0, offset + u + 2) + } + print $0 + } + + This `awk' program deletes C-style comments (`/* ... */') from the +input. By replacing the `print $0' with other statements, you could +perform more complicated processing on the decommented input, such as +searching for matches of a regular expression. (This program has a +subtle problem--it does not work if one comment ends and another begins +on the same line.) + + This form of the `getline' command sets `NF', `NR', `FNR', and the +value of `$0'. + + NOTE: The new value of `$0' is used to test the patterns of any + subsequent rules. The original value of `$0' that triggered the + rule that executed `getline' is lost. By contrast, the `next' + statement reads a new record but immediately begins processing it + normally, starting with the first rule in the program. *Note Next + Statement::. + + +File: gawk.info, Node: Getline/Variable, Next: Getline/File, Prev: Plain Getline, Up: Getline + +4.9.2 Using `getline' into a Variable +------------------------------------- + +You can use `getline VAR' to read the next record from `awk''s input +into the variable VAR. No other processing is done. For example, +suppose the next line is a comment or a special string, and you want to +read it without triggering any rules. This form of `getline' allows +you to read that line and store it in a variable so that the main +read-a-line-and-check-each-rule loop of `awk' never sees it. The +following example swaps every two lines of input: + + { + if ((getline tmp) > 0) { + print tmp + print $0 + } else + print $0 + } + +It takes the following list: + + wan + tew + free + phore + +and produces these results: + + tew + wan + phore + free + + The `getline' command used in this way sets only the variables `NR' +and `FNR' (and of course, VAR). The record is not split into fields, +so the values of the fields (including `$0') and the value of `NF' do +not change. + + +File: gawk.info, Node: Getline/File, Next: Getline/Variable/File, Prev: Getline/Variable, Up: Getline + +4.9.3 Using `getline' from a File +--------------------------------- + +Use `getline < FILE' to read the next record from FILE. Here FILE is a +string-valued expression that specifies the file name. `< FILE' is +called a "redirection" because it directs input to come from a +different place. For example, the following program reads its input +record from the file `secondary.input' when it encounters a first field +with a value equal to 10 in the current input file: + + { + if ($1 == 10) { + getline < "secondary.input" + print + } else + print + } + + Because the main input stream is not used, the values of `NR' and +`FNR' are not changed. However, the record it reads is split into +fields in the normal manner, so the values of `$0' and the other fields +are changed, resulting in a new value of `NF'. + + According to POSIX, `getline < EXPRESSION' is ambiguous if +EXPRESSION contains unparenthesized operators other than `$'; for +example, `getline < dir "/" file' is ambiguous because the +concatenation operator is not parenthesized. You should write it as +`getline < (dir "/" file)' if you want your program to be portable to +all `awk' implementations. + + +File: gawk.info, Node: Getline/Variable/File, Next: Getline/Pipe, Prev: Getline/File, Up: Getline + +4.9.4 Using `getline' into a Variable from a File +------------------------------------------------- + +Use `getline VAR < FILE' to read input from the file FILE, and put it +in the variable VAR. As above, FILE is a string-valued expression that +specifies the file from which to read. + + In this version of `getline', none of the built-in variables are +changed and the record is not split into fields. The only variable +changed is VAR.(1) For example, the following program copies all the +input files to the output, except for records that say +`@include FILENAME'. Such a record is replaced by the contents of the +file FILENAME: + + { + if (NF == 2 && $1 == "@include") { + while ((getline line < $2) > 0) + print line + close($2) + } else + print + } + + Note here how the name of the extra input file is not built into the +program; it is taken directly from the data, specifically from the +second field on the `@include' line. + + The `close()' function is called to ensure that if two identical +`@include' lines appear in the input, the entire specified file is +included twice. *Note Close Files And Pipes::. + + One deficiency of this program is that it does not process nested +`@include' statements (i.e., `@include' statements in included files) +the way a true macro preprocessor would. *Note Igawk Program::, for a +program that does handle nested `@include' statements. + + ---------- Footnotes ---------- + + (1) This is not quite true. `RT' could be changed if `RS' is a +regular expression. + + +File: gawk.info, Node: Getline/Pipe, Next: Getline/Variable/Pipe, Prev: Getline/Variable/File, Up: Getline + +4.9.5 Using `getline' from a Pipe +--------------------------------- + +The output of a command can also be piped into `getline', using +`COMMAND | getline'. In this case, the string COMMAND is run as a +shell command and its output is piped into `awk' to be used as input. +This form of `getline' reads one record at a time from the pipe. For +example, the following program copies its input to its output, except +for lines that begin with `@execute', which are replaced by the output +produced by running the rest of the line as a shell command: + + { + if ($1 == "@execute") { + tmp = substr($0, 10) # Remove "@execute" + while ((tmp | getline) > 0) + print + close(tmp) + } else + print + } + +The `close()' function is called to ensure that if two identical +`@execute' lines appear in the input, the command is run for each one. +*Note Close Files And Pipes::. Given the input: + + foo + bar + baz + @execute who + bletch + +the program might produce: + + foo + bar + baz + arnold ttyv0 Jul 13 14:22 + miriam ttyp0 Jul 13 14:23 (murphy:0) + bill ttyp1 Jul 13 14:23 (murphy:0) + bletch + +Notice that this program ran the command `who' and printed the previous +result. (If you try this program yourself, you will of course get +different results, depending upon who is logged in on your system.) + + This variation of `getline' splits the record into fields, sets the +value of `NF', and recomputes the value of `$0'. The values of `NR' +and `FNR' are not changed. + + According to POSIX, `EXPRESSION | getline' is ambiguous if +EXPRESSION contains unparenthesized operators other than `$'--for +example, `"echo " "date" | getline' is ambiguous because the +concatenation operator is not parenthesized. You should write it as +`("echo " "date") | getline' if you want your program to be portable to +all `awk' implementations. + + NOTE: Unfortunately, `gawk' has not been consistent in its + treatment of a construct like `"echo " "date" | getline'. Most + versions, including the current version, treat it at as `("echo " + "date") | getline'. (This how Brian Kernighan's `awk' behaves.) + Some versions changed and treated it as `"echo " ("date" | + getline)'. (This is how `mawk' behaves.) In short, _always_ use + explicit parentheses, and then you won't have to worry. + + +File: gawk.info, Node: Getline/Variable/Pipe, Next: Getline/Coprocess, Prev: Getline/Pipe, Up: Getline + +4.9.6 Using `getline' into a Variable from a Pipe +------------------------------------------------- + +When you use `COMMAND | getline VAR', the output of COMMAND is sent +through a pipe to `getline' and into the variable VAR. For example, the +following program reads the current date and time into the variable +`current_time', using the `date' utility, and then prints it: + + BEGIN { + "date" | getline current_time + close("date") + print "Report printed on " current_time + } + + In this version of `getline', none of the built-in variables are +changed and the record is not split into fields. + + According to POSIX, `EXPRESSION | getline VAR' is ambiguous if +EXPRESSION contains unparenthesized operators other than `$'; for +example, `"echo " "date" | getline VAR' is ambiguous because the +concatenation operator is not parenthesized. You should write it as +`("echo " "date") | getline VAR' if you want your program to be +portable to other `awk' implementations. + + +File: gawk.info, Node: Getline/Coprocess, Next: Getline/Variable/Coprocess, Prev: Getline/Variable/Pipe, Up: Getline + +4.9.7 Using `getline' from a Coprocess +-------------------------------------- + +Input into `getline' from a pipe is a one-way operation. The command +that is started with `COMMAND | getline' only sends data _to_ your +`awk' program. + + On occasion, you might want to send data to another program for +processing and then read the results back. `gawk' allows you to start +a "coprocess", with which two-way communications are possible. This is +done with the `|&' operator. Typically, you write data to the +coprocess first and then read results back, as shown in the following: + + print "SOME QUERY" |& "db_server" + "db_server" |& getline + +which sends a query to `db_server' and then reads the results. + + The values of `NR' and `FNR' are not changed, because the main input +stream is not used. However, the record is split into fields in the +normal manner, thus changing the values of `$0', of the other fields, +and of `NF'. + + Coprocesses are an advanced feature. They are discussed here only +because this is the minor node on `getline'. *Note Two-way I/O::, +where coprocesses are discussed in more detail. + + +File: gawk.info, Node: Getline/Variable/Coprocess, Next: Getline Notes, Prev: Getline/Coprocess, Up: Getline + +4.9.8 Using `getline' into a Variable from a Coprocess +------------------------------------------------------ + +When you use `COMMAND |& getline VAR', the output from the coprocess +COMMAND is sent through a two-way pipe to `getline' and into the +variable VAR. + + In this version of `getline', none of the built-in variables are +changed and the record is not split into fields. The only variable +changed is VAR. + + Coprocesses are an advanced feature. They are discussed here only +because this is the minor node on `getline'. *Note Two-way I/O::, +where coprocesses are discussed in more detail. + + +File: gawk.info, Node: Getline Notes, Next: Getline Summary, Prev: Getline/Variable/Coprocess, Up: Getline + +4.9.9 Points to Remember About `getline' +---------------------------------------- + +Here are some miscellaneous points about `getline' that you should bear +in mind: + + * When `getline' changes the value of `$0' and `NF', `awk' does + _not_ automatically jump to the start of the program and start + testing the new record against every pattern. However, the new + record is tested against any subsequent rules. + + * Many `awk' implementations limit the number of pipelines that an + `awk' program may have open to just one. In `gawk', there is no + such limit. You can open as many pipelines (and coprocesses) as + the underlying operating system permits. + + * An interesting side effect occurs if you use `getline' without a + redirection inside a `BEGIN' rule. Because an unredirected + `getline' reads from the command-line data files, the first + `getline' command causes `awk' to set the value of `FILENAME'. + Normally, `FILENAME' does not have a value inside `BEGIN' rules, + because you have not yet started to process the command-line data + files. (d.c.) (*Note BEGIN/END::, also *note Auto-set::.) + + * Using `FILENAME' with `getline' (`getline < FILENAME') is likely + to be a source for confusion. `awk' opens a separate input stream + from the current input file. However, by not using a variable, + `$0' and `NR' are still updated. If you're doing this, it's + probably by accident, and you should reconsider what it is you're + trying to accomplish. + + * *note Getline Summary::, presents a table summarizing the + `getline' variants and which variables they can affect. It is + worth noting that those variants which do not use redirection can + cause `FILENAME' to be updated if they cause `awk' to start + reading a new input file. + + +File: gawk.info, Node: Getline Summary, Prev: Getline Notes, Up: Getline + +4.9.10 Summary of `getline' Variants +------------------------------------ + +*note table-getline-variants:: summarizes the eight variants of +`getline', listing which built-in variables are set by each one, and +whether the variant is standard or a `gawk' extension. + +Variant Effect Standard / + Extension +------------------------------------------------------------------------- +`getline' Sets `$0', `NF', `FNR', Standard + and `NR' +`getline' VAR Sets VAR, `FNR', and `NR' Standard +`getline <' FILE Sets `$0' and `NF' Standard +`getline VAR < FILE' Sets VAR Standard +COMMAND `| getline' Sets `$0' and `NF' Standard +COMMAND `| getline' VAR Sets VAR Standard +COMMAND `|& getline' Sets `$0' and `NF' Extension +COMMAND `|& getline' Sets VAR Extension +VAR + +Table 4.1: getline Variants and What They Set + + +File: gawk.info, Node: Command line directories, Prev: Getline, Up: Reading Files + +4.10 Directories On The Command Line +==================================== + +According to the POSIX standard, files named on the `awk' command line +must be text files. It is a fatal error if they are not. Most +versions of `awk' treat a directory on the command line as a fatal +error. + + By default, `gawk' produces a warning for a directory on the command +line, but otherwise ignores it. If either of the `--posix' or +`--traditional' options is given, then `gawk' reverts to treating a +directory on the command line as a fatal error. + + +File: gawk.info, Node: Printing, Next: Expressions, Prev: Reading Files, Up: Top + +5 Printing Output +***************** + +One of the most common programming actions is to "print", or output, +some or all of the input. Use the `print' statement for simple output, +and the `printf' statement for fancier formatting. The `print' +statement is not limited when computing _which_ values to print. +However, with two exceptions, you cannot specify _how_ to print +them--how many columns, whether to use exponential notation or not, and +so on. (For the exceptions, *note Output Separators::, and *note +OFMT::.) For printing with specifications, you need the `printf' +statement (*note Printf::). + + Besides basic and formatted printing, this major node also covers +I/O redirections to files and pipes, introduces the special file names +that `gawk' processes internally, and discusses the `close()' built-in +function. + +* Menu: + +* Print:: The `print' statement. +* Print Examples:: Simple examples of `print' statements. +* Output Separators:: The output separators and how to change them. +* OFMT:: Controlling Numeric Output With `print'. +* Printf:: The `printf' statement. +* Redirection:: How to redirect output to multiple files and + pipes. +* Special Files:: File name interpretation in `gawk'. + `gawk' allows access to inherited file + descriptors. +* Close Files And Pipes:: Closing Input and Output Files and Pipes. + + +File: gawk.info, Node: Print, Next: Print Examples, Up: Printing + +5.1 The `print' Statement +========================= + +The `print' statement is used for producing output with simple, +standardized formatting. Specify only the strings or numbers to print, +in a list separated by commas. They are output, separated by single +spaces, followed by a newline. The statement looks like this: + + print ITEM1, ITEM2, ... + +The entire list of items may be optionally enclosed in parentheses. The +parentheses are necessary if any of the item expressions uses the `>' +relational operator; otherwise it could be confused with an output +redirection (*note Redirection::). + + The items to print can be constant strings or numbers, fields of the +current record (such as `$1'), variables, or any `awk' expression. +Numeric values are converted to strings and then printed. + + The simple statement `print' with no items is equivalent to `print +$0': it prints the entire current record. To print a blank line, use +`print ""', where `""' is the empty string. To print a fixed piece of +text, use a string constant, such as `"Don't Panic"', as one item. If +you forget to use the double-quote characters, your text is taken as an +`awk' expression, and you will probably get an error. Keep in mind +that a space is printed between any two items. + + +File: gawk.info, Node: Print Examples, Next: Output Separators, Prev: Print, Up: Printing + +5.2 `print' Statement Examples +============================== + +Each `print' statement makes at least one line of output. However, it +isn't limited to only one line. If an item value is a string +containing a newline, the newline is output along with the rest of the +string. A single `print' statement can make any number of lines this +way. + + The following is an example of printing a string that contains +embedded newlines (the `\n' is an escape sequence, used to represent +the newline character; *note Escape Sequences::): + + $ awk 'BEGIN { print "line one\nline two\nline three" }' + -| line one + -| line two + -| line three + + The next example, which is run on the `inventory-shipped' file, +prints the first two fields of each input record, with a space between +them: + + $ awk '{ print $1, $2 }' inventory-shipped + -| Jan 13 + -| Feb 15 + -| Mar 15 + ... + + A common mistake in using the `print' statement is to omit the comma +between two items. This often has the effect of making the items run +together in the output, with no space. The reason for this is that +juxtaposing two string expressions in `awk' means to concatenate them. +Here is the same program, without the comma: + + $ awk '{ print $1 $2 }' inventory-shipped + -| Jan13 + -| Feb15 + -| Mar15 + ... + + To someone unfamiliar with the `inventory-shipped' file, neither +example's output makes much sense. A heading line at the beginning +would make it clearer. Let's add some headings to our table of months +(`$1') and green crates shipped (`$2'). We do this using the `BEGIN' +pattern (*note BEGIN/END::) so that the headings are only printed once: + + awk 'BEGIN { print "Month Crates" + print "----- ------" } + { print $1, $2 }' inventory-shipped + +When run, the program prints the following: + + Month Crates + ----- ------ + Jan 13 + Feb 15 + Mar 15 + ... + +The only problem, however, is that the headings and the table data +don't line up! We can fix this by printing some spaces between the two +fields: + + awk 'BEGIN { print "Month Crates" + print "----- ------" } + { print $1, " ", $2 }' inventory-shipped + + Lining up columns this way can get pretty complicated when there are +many columns to fix. Counting spaces for two or three columns is +simple, but any more than this can take up a lot of time. This is why +the `printf' statement was created (*note Printf::); one of its +specialties is lining up columns of data. + + NOTE: You can continue either a `print' or `printf' statement + simply by putting a newline after any comma (*note + Statements/Lines::). + + +File: gawk.info, Node: Output Separators, Next: OFMT, Prev: Print Examples, Up: Printing + +5.3 Output Separators +===================== + +As mentioned previously, a `print' statement contains a list of items +separated by commas. In the output, the items are normally separated +by single spaces. However, this doesn't need to be the case; a single +space is simply the default. Any string of characters may be used as +the "output field separator" by setting the built-in variable `OFS'. +The initial value of this variable is the string `" "'--that is, a +single space. + + The output from an entire `print' statement is called an "output +record". Each `print' statement outputs one output record, and then +outputs a string called the "output record separator" (or `ORS'). The +initial value of `ORS' is the string `"\n"'; i.e., a newline character. +Thus, each `print' statement normally makes a separate line. + + In order to change how output fields and records are separated, +assign new values to the variables `OFS' and `ORS'. The usual place to +do this is in the `BEGIN' rule (*note BEGIN/END::), so that it happens +before any input is processed. It can also be done with assignments on +the command line, before the names of the input files, or using the +`-v' command-line option (*note Options::). The following example +prints the first and second fields of each input record, separated by a +semicolon, with a blank line added after each newline: + + $ awk 'BEGIN { OFS = ";"; ORS = "\n\n" } + > { print $1, $2 }' BBS-list + -| aardvark;555-5553 + -| + -| alpo-net;555-3412 + -| + -| barfly;555-7685 + ... + + If the value of `ORS' does not contain a newline, the program's +output runs together on a single line. + + +File: gawk.info, Node: OFMT, Next: Printf, Prev: Output Separators, Up: Printing + +5.4 Controlling Numeric Output with `print' +=========================================== + +When printing numeric values with the `print' statement, `awk' +internally converts the number to a string of characters and prints +that string. `awk' uses the `sprintf()' function to do this conversion +(*note String Functions::). For now, it suffices to say that the +`sprintf()' function accepts a "format specification" that tells it how +to format numbers (or strings), and that there are a number of +different ways in which numbers can be formatted. The different format +specifications are discussed more fully in *note Control Letters::. + + The built-in variable `OFMT' contains the default format +specification that `print' uses with `sprintf()' when it wants to +convert a number to a string for printing. The default value of `OFMT' +is `"%.6g"'. The way `print' prints numbers can be changed by +supplying different format specifications as the value of `OFMT', as +shown in the following example: + + $ awk 'BEGIN { + > OFMT = "%.0f" # print numbers as integers (rounds) + > print 17.23, 17.54 }' + -| 17 18 + +According to the POSIX standard, `awk''s behavior is undefined if +`OFMT' contains anything but a floating-point conversion specification. +(d.c.) + + +File: gawk.info, Node: Printf, Next: Redirection, Prev: OFMT, Up: Printing + +5.5 Using `printf' Statements for Fancier Printing +================================================== + +For more precise control over the output format than what is provided +by `print', use `printf'. With `printf' you can specify the width to +use for each item, as well as various formatting choices for numbers +(such as what output base to use, whether to print an exponent, whether +to print a sign, and how many digits to print after the decimal point). +You do this by supplying a string, called the "format string", that +controls how and where to print the other arguments. + +* Menu: + +* Basic Printf:: Syntax of the `printf' statement. +* Control Letters:: Format-control letters. +* Format Modifiers:: Format-specification modifiers. +* Printf Examples:: Several examples. + + +File: gawk.info, Node: Basic Printf, Next: Control Letters, Up: Printf + +5.5.1 Introduction to the `printf' Statement +-------------------------------------------- + +A simple `printf' statement looks like this: + + printf FORMAT, ITEM1, ITEM2, ... + +The entire list of arguments may optionally be enclosed in parentheses. +The parentheses are necessary if any of the item expressions use the `>' +relational operator; otherwise, it can be confused with an output +redirection (*note Redirection::). + + The difference between `printf' and `print' is the FORMAT argument. +This is an expression whose value is taken as a string; it specifies +how to output each of the other arguments. It is called the "format +string". + + The format string is very similar to that in the ISO C library +function `printf()'. Most of FORMAT is text to output verbatim. +Scattered among this text are "format specifiers"--one per item. Each +format specifier says to output the next item in the argument list at +that place in the format. + + The `printf' statement does not automatically append a newline to +its output. It outputs only what the format string specifies. So if a +newline is needed, you must include one in the format string. The +output separator variables `OFS' and `ORS' have no effect on `printf' +statements. For example: + + $ awk 'BEGIN { + > ORS = "\nOUCH!\n"; OFS = "+" + > msg = "Dont Panic!" + > printf "%s\n", msg + > }' + -| Dont Panic! + +Here, neither the `+' nor the `OUCH' appear in the output message. + + +File: gawk.info, Node: Control Letters, Next: Format Modifiers, Prev: Basic Printf, Up: Printf + +5.5.2 Format-Control Letters +---------------------------- + +A format specifier starts with the character `%' and ends with a +"format-control letter"--it tells the `printf' statement how to output +one item. The format-control letter specifies what _kind_ of value to +print. The rest of the format specifier is made up of optional +"modifiers" that control _how_ to print the value, such as the field +width. Here is a list of the format-control letters: + +`%c' + Print a number as an ASCII character; thus, `printf "%c", 65' + outputs the letter `A'. The output for a string value is the first + character of the string. + + NOTE: The POSIX standard says the first character of a string + is printed. In locales with multibyte characters, `gawk' + attempts to convert the leading bytes of the string into a + valid wide character and then to print the multibyte encoding + of that character. Similarly, when printing a numeric value, + `gawk' allows the value to be within the numeric range of + values that can be held in a wide character. + + Other `awk' versions generally restrict themselves to printing + the first byte of a string or to numeric values within the + range of a single byte (0-255). + +`%d, %i' + Print a decimal integer. The two control letters are equivalent. + (The `%i' specification is for compatibility with ISO C.) + +`%e, %E' + Print a number in scientific (exponential) notation; for example: + + printf "%4.3e\n", 1950 + + prints `1.950e+03', with a total of four significant figures, + three of which follow the decimal point. (The `4.3' represents + two modifiers, discussed in the next node.) `%E' uses `E' instead + of `e' in the output. + +`%f' + Print a number in floating-point notation. For example: + + printf "%4.3f", 1950 + + prints `1950.000', with a total of four significant figures, three + of which follow the decimal point. (The `4.3' represents two + modifiers, discussed in the next node.) + + On systems supporting IEEE 754 floating point format, values + representing negative infinity are formatted as `-inf' or + `-infinity', and positive infinity as `inf' and `infinity'. The + special "not a number" value formats as `-nan' or `nan'. + +`%F' + Like `%f' but the infinity and "not a number" values are spelled + using uppercase letters. + + The `%F' format is a POSIX extension to ISO C; not all systems + support it. On those that don't, `gawk' uses `%f' instead. + +`%g, %G' + Print a number in either scientific notation or in floating-point + notation, whichever uses fewer characters; if the result is + printed in scientific notation, `%G' uses `E' instead of `e'. + +`%o' + Print an unsigned octal integer (*note Nondecimal-numbers::). + +`%s' + Print a string. + +`%u' + Print an unsigned decimal integer. (This format is of marginal + use, because all numbers in `awk' are floating-point; it is + provided primarily for compatibility with C.) + +`%x, %X' + Print an unsigned hexadecimal integer; `%X' uses the letters `A' + through `F' instead of `a' through `f' (*note + Nondecimal-numbers::). + +`%%' + Print a single `%'. This does not consume an argument and it + ignores any modifiers. + + NOTE: When using the integer format-control letters for values + that are outside the range of the widest C integer type, `gawk' + switches to the `%g' format specifier. If `--lint' is provided on + the command line (*note Options::), `gawk' warns about this. + Other versions of `awk' may print invalid values or do something + else entirely. (d.c.) + + +File: gawk.info, Node: Format Modifiers, Next: Printf Examples, Prev: Control Letters, Up: Printf + +5.5.3 Modifiers for `printf' Formats +------------------------------------ + +A format specification can also include "modifiers" that can control +how much of the item's value is printed, as well as how much space it +gets. The modifiers come between the `%' and the format-control letter. +We will use the bullet symbol "*" in the following examples to represent +spaces in the output. Here are the possible modifiers, in the order in +which they may appear: + +`N$' + An integer constant followed by a `$' is a "positional specifier". + Normally, format specifications are applied to arguments in the + order given in the format string. With a positional specifier, + the format specification is applied to a specific argument, + instead of what would be the next argument in the list. + Positional specifiers begin counting with one. Thus: + + printf "%s %s\n", "don't", "panic" + printf "%2$s %1$s\n", "panic", "don't" + + prints the famous friendly message twice. + + At first glance, this feature doesn't seem to be of much use. It + is in fact a `gawk' extension, intended for use in translating + messages at runtime. *Note Printf Ordering::, which describes how + and why to use positional specifiers. For now, we will not use + them. + +`-' + The minus sign, used before the width modifier (see later on in + this list), says to left-justify the argument within its specified + width. Normally, the argument is printed right-justified in the + specified width. Thus: + + printf "%-4s", "foo" + + prints `foo*'. + +`SPACE' + For numeric conversions, prefix positive values with a space and + negative values with a minus sign. + +`+' + The plus sign, used before the width modifier (see later on in + this list), says to always supply a sign for numeric conversions, + even if the data to format is positive. The `+' overrides the + space modifier. + +`#' + Use an "alternate form" for certain control letters. For `%o', + supply a leading zero. For `%x' and `%X', supply a leading `0x' + or `0X' for a nonzero result. For `%e', `%E', `%f', and `%F', the + result always contains a decimal point. For `%g' and `%G', + trailing zeros are not removed from the result. + +`0' + A leading `0' (zero) acts as a flag that indicates that output + should be padded with zeros instead of spaces. This applies only + to the numeric output formats. This flag only has an effect when + the field width is wider than the value to print. + +`'' + A single quote or apostrophe character is a POSIX extension to ISO + C. It indicates that the integer part of a floating point value, + or the entire part of an integer decimal value, should have a + thousands-separator character in it. This only works in locales + that support such characters. For example: + + $ cat thousands.awk Show source program + -| BEGIN { printf "%'d\n", 1234567 } + $ LC_ALL=C gawk -f thousands.awk + -| 1234567 Results in "C" locale + $ LC_ALL=en_US.UTF-8 gawk -f thousands.awk + -| 1,234,567 Results in US English UTF locale + + For more information about locales and internationalization issues, + see *note Locales::. + + NOTE: The `'' flag is a nice feature, but its use complicates + things: it becomes difficult to use it in command-line + programs. For information on appropriate quoting tricks, see + *note Quoting::. + +`WIDTH' + This is a number specifying the desired minimum width of a field. + Inserting any number between the `%' sign and the format-control + character forces the field to expand to this width. The default + way to do this is to pad with spaces on the left. For example: + + printf "%4s", "foo" + + prints `*foo'. + + The value of WIDTH is a minimum width, not a maximum. If the item + value requires more than WIDTH characters, it can be as wide as + necessary. Thus, the following: + + printf "%4s", "foobar" + + prints `foobar'. + + Preceding the WIDTH with a minus sign causes the output to be + padded with spaces on the right, instead of on the left. + +`.PREC' + A period followed by an integer constant specifies the precision + to use when printing. The meaning of the precision varies by + control letter: + + `%d', `%i', `%o', `%u', `%x', `%X' + Minimum number of digits to print. + + `%e', `%E', `%f', `%F' + Number of digits to the right of the decimal point. + + `%g', `%G' + Maximum number of significant digits. + + `%s' + Maximum number of characters from the string that should + print. + + Thus, the following: + + printf "%.4s", "foobar" + + prints `foob'. + + The C library `printf''s dynamic WIDTH and PREC capability (for +example, `"%*.*s"') is supported. Instead of supplying explicit WIDTH +and/or PREC values in the format string, they are passed in the +argument list. For example: + + w = 5 + p = 3 + s = "abcdefg" + printf "%*.*s\n", w, p, s + +is exactly equivalent to: + + s = "abcdefg" + printf "%5.3s\n", s + +Both programs output `**abc'. Earlier versions of `awk' did not +support this capability. If you must use such a version, you may +simulate this feature by using concatenation to build up the format +string, like so: + + w = 5 + p = 3 + s = "abcdefg" + printf "%" w "." p "s\n", s + +This is not particularly easy to read but it does work. + + C programmers may be used to supplying additional `l', `L', and `h' +modifiers in `printf' format strings. These are not valid in `awk'. +Most `awk' implementations silently ignore them. If `--lint' is +provided on the command line (*note Options::), `gawk' warns about +their use. If `--posix' is supplied, their use is a fatal error. + + +File: gawk.info, Node: Printf Examples, Prev: Format Modifiers, Up: Printf + +5.5.4 Examples Using `printf' +----------------------------- + +The following simple example shows how to use `printf' to make an +aligned table: + + awk '{ printf "%-10s %s\n", $1, $2 }' BBS-list + +This command prints the names of the bulletin boards (`$1') in the file +`BBS-list' as a string of 10 characters that are left-justified. It +also prints the phone numbers (`$2') next on the line. This produces +an aligned two-column table of names and phone numbers, as shown here: + + $ awk '{ printf "%-10s %s\n", $1, $2 }' BBS-list + -| aardvark 555-5553 + -| alpo-net 555-3412 + -| barfly 555-7685 + -| bites 555-1675 + -| camelot 555-0542 + -| core 555-2912 + -| fooey 555-1234 + -| foot 555-6699 + -| macfoo 555-6480 + -| sdace 555-3430 + -| sabafoo 555-2127 + + In this case, the phone numbers had to be printed as strings because +the numbers are separated by a dash. Printing the phone numbers as +numbers would have produced just the first three digits: `555'. This +would have been pretty confusing. + + It wasn't necessary to specify a width for the phone numbers because +they are last on their lines. They don't need to have spaces after +them. + + The table could be made to look even nicer by adding headings to the +tops of the columns. This is done using the `BEGIN' pattern (*note +BEGIN/END::) so that the headers are only printed once, at the +beginning of the `awk' program: + + awk 'BEGIN { print "Name Number" + print "---- ------" } + { printf "%-10s %s\n", $1, $2 }' BBS-list + + The above example mixes `print' and `printf' statements in the same +program. Using just `printf' statements can produce the same results: + + awk 'BEGIN { printf "%-10s %s\n", "Name", "Number" + printf "%-10s %s\n", "----", "------" } + { printf "%-10s %s\n", $1, $2 }' BBS-list + +Printing each column heading with the same format specification used +for the column elements ensures that the headings are aligned just like +the columns. + + The fact that the same format specification is used three times can +be emphasized by storing it in a variable, like this: + + awk 'BEGIN { format = "%-10s %s\n" + printf format, "Name", "Number" + printf format, "----", "------" } + { printf format, $1, $2 }' BBS-list + + At this point, it would be a worthwhile exercise to use the `printf' +statement to line up the headings and table data for the +`inventory-shipped' example that was covered earlier in the minor node +on the `print' statement (*note Print::). + + +File: gawk.info, Node: Redirection, Next: Special Files, Prev: Printf, Up: Printing + +5.6 Redirecting Output of `print' and `printf' +============================================== + +So far, the output from `print' and `printf' has gone to the standard +output, usually the screen. Both `print' and `printf' can also send +their output to other places. This is called "redirection". + + NOTE: When `--sandbox' is specified (*note Options::), redirecting + output to files and pipes is disabled. + + A redirection appears after the `print' or `printf' statement. +Redirections in `awk' are written just like redirections in shell +commands, except that they are written inside the `awk' program. + + There are four forms of output redirection: output to a file, output +appended to a file, output through a pipe to another command, and output +to a coprocess. They are all shown for the `print' statement, but they +work identically for `printf': + +`print ITEMS > OUTPUT-FILE' + This redirection prints the items into the output file named + OUTPUT-FILE. The file name OUTPUT-FILE can be any expression. + Its value is changed to a string and then used as a file name + (*note Expressions::). + + When this type of redirection is used, the OUTPUT-FILE is erased + before the first output is written to it. Subsequent writes to + the same OUTPUT-FILE do not erase OUTPUT-FILE, but append to it. + (This is different from how you use redirections in shell scripts.) + If OUTPUT-FILE does not exist, it is created. For example, here + is how an `awk' program can write a list of BBS names to one file + named `name-list', and a list of phone numbers to another file + named `phone-list': + + $ awk '{ print $2 > "phone-list" + > print $1 > "name-list" }' BBS-list + $ cat phone-list + -| 555-5553 + -| 555-3412 + ... + $ cat name-list + -| aardvark + -| alpo-net + ... + + Each output file contains one name or number per line. + +`print ITEMS >> OUTPUT-FILE' + This redirection prints the items into the pre-existing output file + named OUTPUT-FILE. The difference between this and the single-`>' + redirection is that the old contents (if any) of OUTPUT-FILE are + not erased. Instead, the `awk' output is appended to the file. + If OUTPUT-FILE does not exist, then it is created. + +`print ITEMS | COMMAND' + It is possible to send output to another program through a pipe + instead of into a file. This redirection opens a pipe to + COMMAND, and writes the values of ITEMS through this pipe to + another process created to execute COMMAND. + + The redirection argument COMMAND is actually an `awk' expression. + Its value is converted to a string whose contents give the shell + command to be run. For example, the following produces two files, + one unsorted list of BBS names, and one list sorted in reverse + alphabetical order: + + awk '{ print $1 > "names.unsorted" + command = "sort -r > names.sorted" + print $1 | command }' BBS-list + + The unsorted list is written with an ordinary redirection, while + the sorted list is written by piping through the `sort' utility. + + The next example uses redirection to mail a message to the mailing + list `bug-system'. This might be useful when trouble is + encountered in an `awk' script run periodically for system + maintenance: + + report = "mail bug-system" + print "Awk script failed:", $0 | report + m = ("at record number " FNR " of " FILENAME) + print m | report + close(report) + + The message is built using string concatenation and saved in the + variable `m'. It's then sent down the pipeline to the `mail' + program. (The parentheses group the items to concatenate--see + *note Concatenation::.) + + The `close()' function is called here because it's a good idea to + close the pipe as soon as all the intended output has been sent to + it. *Note Close Files And Pipes::, for more information. + + This example also illustrates the use of a variable to represent a + FILE or COMMAND--it is not necessary to always use a string + constant. Using a variable is generally a good idea, because (if + you mean to refer to that same file or command) `awk' requires + that the string value be spelled identically every time. + +`print ITEMS |& COMMAND' + This redirection prints the items to the input of COMMAND. The + difference between this and the single-`|' redirection is that the + output from COMMAND can be read with `getline'. Thus COMMAND is a + "coprocess", which works together with, but subsidiary to, the + `awk' program. + + This feature is a `gawk' extension, and is not available in POSIX + `awk'. *Note Getline/Coprocess::, for a brief discussion. *Note + Two-way I/O::, for a more complete discussion. + + Redirecting output using `>', `>>', `|', or `|&' asks the system to +open a file, pipe, or coprocess only if the particular FILE or COMMAND +you specify has not already been written to by your program or if it +has been closed since it was last written to. + + It is a common error to use `>' redirection for the first `print' to +a file, and then to use `>>' for subsequent output: + + # clear the file + print "Don't panic" > "guide.txt" + ... + # append + print "Avoid improbability generators" >> "guide.txt" + +This is indeed how redirections must be used from the shell. But in +`awk', it isn't necessary. In this kind of case, a program should use +`>' for all the `print' statements, since the output file is only +opened once. (It happens that if you mix `>' and `>>' that output is +produced in the expected order. However, mixing the operators for the +same file is definitely poor style, and is confusing to readers of your +program.) + + Many older `awk' implementations limit the number of pipelines that +an `awk' program may have open to just one! In `gawk', there is no +such limit. `gawk' allows a program to open as many pipelines as the +underlying operating system permits. + +Advanced Notes: Piping into `sh' +-------------------------------- + +A particularly powerful way to use redirection is to build command lines +and pipe them into the shell, `sh'. For example, suppose you have a +list of files brought over from a system where all the file names are +stored in uppercase, and you wish to rename them to have names in all +lowercase. The following program is both simple and efficient: + + { printf("mv %s %s\n", $0, tolower($0)) | "sh" } + + END { close("sh") } + + The `tolower()' function returns its argument string with all +uppercase characters converted to lowercase (*note String Functions::). +The program builds up a list of command lines, using the `mv' utility +to rename the files. It then sends the list to the shell for execution. + + +File: gawk.info, Node: Special Files, Next: Close Files And Pipes, Prev: Redirection, Up: Printing + +5.7 Special File Names in `gawk' +================================ + +`gawk' provides a number of special file names that it interprets +internally. These file names provide access to standard file +descriptors and TCP/IP networking. + +* Menu: + +* Special FD:: Special files for I/O. +* Special Network:: Special files for network communications. +* Special Caveats:: Things to watch out for. + + +File: gawk.info, Node: Special FD, Next: Special Network, Up: Special Files + +5.7.1 Special Files for Standard Descriptors +-------------------------------------------- + +Running programs conventionally have three input and output streams +already available to them for reading and writing. These are known as +the "standard input", "standard output", and "standard error output". +These streams are, by default, connected to your keyboard and screen, +but they are often redirected with the shell, via the `<', `<<', `>', +`>>', `>&', and `|' operators. Standard error is typically used for +writing error messages; the reason there are two separate streams, +standard output and standard error, is so that they can be redirected +separately. + + In other implementations of `awk', the only way to write an error +message to standard error in an `awk' program is as follows: + + print "Serious error detected!" | "cat 1>&2" + +This works by opening a pipeline to a shell command that can access the +standard error stream that it inherits from the `awk' process. This is +far from elegant, and it is also inefficient, because it requires a +separate process. So people writing `awk' programs often don't do +this. Instead, they send the error messages to the screen, like this: + + print "Serious error detected!" > "/dev/tty" + +(`/dev/tty' is a special file supplied by the operating system that is +connected to your keyboard and screen. It represents the "terminal,"(1) +which on modern systems is a keyboard and screen, not a serial console.) +This usually has the same effect but not always: although the standard +error stream is usually the screen, it can be redirected; when that +happens, writing to the screen is not correct. In fact, if `awk' is +run from a background job, it may not have a terminal at all. Then +opening `/dev/tty' fails. + + `gawk' provides special file names for accessing the three standard +streams. (c.e.). It also provides syntax for accessing any other +inherited open files. If the file name matches one of these special +names when `gawk' redirects input or output, then it directly uses the +stream that the file name stands for. These special file names work +for all operating systems that `gawk' has been ported to, not just +those that are POSIX-compliant: + +`/dev/stdin' + The standard input (file descriptor 0). + +`/dev/stdout' + The standard output (file descriptor 1). + +`/dev/stderr' + The standard error output (file descriptor 2). + +`/dev/fd/N' + The file associated with file descriptor N. Such a file must be + opened by the program initiating the `awk' execution (typically + the shell). Unless special pains are taken in the shell from which + `gawk' is invoked, only descriptors 0, 1, and 2 are available. + + The file names `/dev/stdin', `/dev/stdout', and `/dev/stderr' are +aliases for `/dev/fd/0', `/dev/fd/1', and `/dev/fd/2', respectively. +However, they are more self-explanatory. The proper way to write an +error message in a `gawk' program is to use `/dev/stderr', like this: + + print "Serious error detected!" > "/dev/stderr" + + Note the use of quotes around the file name. Like any other +redirection, the value must be a string. It is a common error to omit +the quotes, which leads to confusing results. + + Finally, using the `close()' function on a file name of the form +`"/dev/fd/N"', for file descriptor numbers above two, will actually +close the given file descriptor. + + The `/dev/stdin', `/dev/stdout', and `/dev/stderr' special files are +also recognized internally by several other versions of `awk'. + + ---------- Footnotes ---------- + + (1) The "tty" in `/dev/tty' stands for "Teletype," a serial terminal. + + +File: gawk.info, Node: Special Network, Next: Special Caveats, Prev: Special FD, Up: Special Files + +5.7.2 Special Files for Network Communications +---------------------------------------------- + +`gawk' programs can open a two-way TCP/IP connection, acting as either +a client or a server. This is done using a special file name of the +form: + + `/NET-TYPE/PROTOCOL/LOCAL-PORT/REMOTE-HOST/REMOTE-PORT' + + The NET-TYPE is one of `inet', `inet4' or `inet6'. The PROTOCOL is +one of `tcp' or `udp', and the other fields represent the other +essential pieces of information for making a networking connection. +These file names are used with the `|&' operator for communicating with +a coprocess (*note Two-way I/O::). This is an advanced feature, +mentioned here only for completeness. Full discussion is delayed until +*note TCP/IP Networking::. + + +File: gawk.info, Node: Special Caveats, Prev: Special Network, Up: Special Files + +5.7.3 Special File Name Caveats +------------------------------- + +Here is a list of things to bear in mind when using the special file +names that `gawk' provides: + + * Recognition of these special file names is disabled if `gawk' is in + compatibility mode (*note Options::). + + * `gawk' _always_ interprets these special file names. For example, + using `/dev/fd/4' for output actually writes on file descriptor 4, + and not on a new file descriptor that is `dup()''ed from file + descriptor 4. Most of the time this does not matter; however, it + is important to _not_ close any of the files related to file + descriptors 0, 1, and 2. Doing so results in unpredictable + behavior. + + +File: gawk.info, Node: Close Files And Pipes, Prev: Special Files, Up: Printing + +5.8 Closing Input and Output Redirections +========================================= + +If the same file name or the same shell command is used with `getline' +more than once during the execution of an `awk' program (*note +Getline::), the file is opened (or the command is executed) the first +time only. At that time, the first record of input is read from that +file or command. The next time the same file or command is used with +`getline', another record is read from it, and so on. + + Similarly, when a file or pipe is opened for output, `awk' remembers +the file name or command associated with it, and subsequent writes to +the same file or command are appended to the previous writes. The file +or pipe stays open until `awk' exits. + + This implies that special steps are necessary in order to read the +same file again from the beginning, or to rerun a shell command (rather +than reading more output from the same command). The `close()' function +makes these things possible: + + close(FILENAME) + +or: + + close(COMMAND) + + The argument FILENAME or COMMAND can be any expression. Its value +must _exactly_ match the string that was used to open the file or start +the command (spaces and other "irrelevant" characters included). For +example, if you open a pipe with this: + + "sort -r names" | getline foo + +then you must close it with this: + + close("sort -r names") + + Once this function call is executed, the next `getline' from that +file or command, or the next `print' or `printf' to that file or +command, reopens the file or reruns the command. Because the +expression that you use to close a file or pipeline must exactly match +the expression used to open the file or run the command, it is good +practice to use a variable to store the file name or command. The +previous example becomes the following: + + sortcom = "sort -r names" + sortcom | getline foo + ... + close(sortcom) + +This helps avoid hard-to-find typographical errors in your `awk' +programs. Here are some of the reasons for closing an output file: + + * To write a file and read it back later on in the same `awk' + program. Close the file after writing it, then begin reading it + with `getline'. + + * To write numerous files, successively, in the same `awk' program. + If the files aren't closed, eventually `awk' may exceed a system + limit on the number of open files in one process. It is best to + close each one when the program has finished writing it. + + * To make a command finish. When output is redirected through a + pipe, the command reading the pipe normally continues to try to + read input as long as the pipe is open. Often this means the + command cannot really do its work until the pipe is closed. For + example, if output is redirected to the `mail' program, the + message is not actually sent until the pipe is closed. + + * To run the same program a second time, with the same arguments. + This is not the same thing as giving more input to the first run! + + For example, suppose a program pipes output to the `mail' program. + If it outputs several lines redirected to this pipe without closing + it, they make a single message of several lines. By contrast, if + the program closes the pipe after each line of output, then each + line makes a separate message. + + If you use more files than the system allows you to have open, +`gawk' attempts to multiplex the available open files among your data +files. `gawk''s ability to do this depends upon the facilities of your +operating system, so it may not always work. It is therefore both good +practice and good portability advice to always use `close()' on your +files when you are done with them. In fact, if you are using a lot of +pipes, it is essential that you close commands when done. For example, +consider something like this: + + { + ... + command = ("grep " $1 " /some/file | my_prog -q " $3) + while ((command | getline) > 0) { + PROCESS OUTPUT OF command + } + # need close(command) here + } + + This example creates a new pipeline based on data in _each_ record. +Without the call to `close()' indicated in the comment, `awk' creates +child processes to run the commands, until it eventually runs out of +file descriptors for more pipelines. + + Even though each command has finished (as indicated by the +end-of-file return status from `getline'), the child process is not +terminated;(1) more importantly, the file descriptor for the pipe is +not closed and released until `close()' is called or `awk' exits. + + `close()' will silently do nothing if given an argument that does +not represent a file, pipe or coprocess that was opened with a +redirection. + + Note also that `close(FILENAME)' has no "magic" effects on the +implicit loop that reads through the files named on the command line. +It is, more likely, a close of a file that was never opened, so `awk' +silently does nothing. + + When using the `|&' operator to communicate with a coprocess, it is +occasionally useful to be able to close one end of the two-way pipe +without closing the other. This is done by supplying a second argument +to `close()'. As in any other call to `close()', the first argument is +the name of the command or special file used to start the coprocess. +The second argument should be a string, with either of the values +`"to"' or `"from"'. Case does not matter. As this is an advanced +feature, a more complete discussion is delayed until *note Two-way +I/O::, which discusses it in more detail and gives an example. + +Advanced Notes: Using `close()''s Return Value +---------------------------------------------- + +In many versions of Unix `awk', the `close()' function is actually a +statement. It is a syntax error to try and use the return value from +`close()': (d.c.) + + command = "..." + command | getline info + retval = close(command) # syntax error in many Unix awks + + `gawk' treats `close()' as a function. The return value is -1 if +the argument names something that was never opened with a redirection, +or if there is a system problem closing the file or process. In these +cases, `gawk' sets the built-in variable `ERRNO' to a string describing +the problem. + + In `gawk', when closing a pipe or coprocess (input or output), the +return value is the exit status of the command.(2) Otherwise, it is the +return value from the system's `close()' or `fclose()' C functions when +closing input or output files, respectively. This value is zero if the +close succeeds, or -1 if it fails. + + The POSIX standard is very vague; it says that `close()' returns +zero on success and nonzero otherwise. In general, different +implementations vary in what they report when closing pipes; thus the +return value cannot be used portably. (d.c.) In POSIX mode (*note +Options::), `gawk' just returns zero when closing a pipe. + + ---------- Footnotes ---------- + + (1) The technical terminology is rather morbid. The finished child +is called a "zombie," and cleaning up after it is referred to as +"reaping." + + (2) This is a full 16-bit value as returned by the `wait()' system +call. See the system manual pages for information on how to decode this +value. + + +File: gawk.info, Node: Expressions, Next: Patterns and Actions, Prev: Printing, Up: Top + +6 Expressions +************* + +Expressions are the basic building blocks of `awk' patterns and +actions. An expression evaluates to a value that you can print, test, +or pass to a function. Additionally, an expression can assign a new +value to a variable or a field by using an assignment operator. + + An expression can serve as a pattern or action statement on its own. +Most other kinds of statements contain one or more expressions that +specify the data on which to operate. As in other languages, +expressions in `awk' include variables, array references, constants, +and function calls, as well as combinations of these with various +operators. + +* Menu: + +* Values:: Constants, Variables, and Regular Expressions. +* All Operators:: `gawk''s operators. +* Truth Values and Conditions:: Testing for true and false. +* Function Calls:: A function call is an expression. +* Precedence:: How various operators nest. +* Locales:: How the locale affects things. + + +File: gawk.info, Node: Values, Next: All Operators, Up: Expressions + +6.1 Constants, Variables and Conversions +======================================== + +Expressions are built up from values and the operations performed upon +them. This minor node describes the elementary objects which provide +the values used in expressions. + +* Menu: + +* Constants:: String, numeric and regexp constants. +* Using Constant Regexps:: When and how to use a regexp constant. +* Variables:: Variables give names to values for later use. +* Conversion:: The conversion of strings to numbers and vice + versa. + + +File: gawk.info, Node: Constants, Next: Using Constant Regexps, Up: Values + +6.1.1 Constant Expressions +-------------------------- + +The simplest type of expression is the "constant", which always has the +same value. There are three types of constants: numeric, string, and +regular expression. + + Each is used in the appropriate context when you need a data value +that isn't going to change. Numeric constants can have different +forms, but are stored identically internally. + +* Menu: + +* Scalar Constants:: Numeric and string constants. +* Nondecimal-numbers:: What are octal and hex numbers. +* Regexp Constants:: Regular Expression constants. + + +File: gawk.info, Node: Scalar Constants, Next: Nondecimal-numbers, Up: Constants + +6.1.1.1 Numeric and String Constants +.................................... + +A "numeric constant" stands for a number. This number can be an +integer, a decimal fraction, or a number in scientific (exponential) +notation.(1) Here are some examples of numeric constants that all have +the same value: + + 105 + 1.05e+2 + 1050e-1 + + A string constant consists of a sequence of characters enclosed in +double-quotation marks. For example: + + "parrot" + +represents the string whose contents are `parrot'. Strings in `gawk' +can be of any length, and they can contain any of the possible +eight-bit ASCII characters including ASCII NUL (character code zero). +Other `awk' implementations may have difficulty with some character +codes. + + ---------- Footnotes ---------- + + (1) The internal representation of all numbers, including integers, +uses double precision floating-point numbers. On most modern systems, +these are in IEEE 754 standard format. + + +File: gawk.info, Node: Nondecimal-numbers, Next: Regexp Constants, Prev: Scalar Constants, Up: Constants + +6.1.1.2 Octal and Hexadecimal Numbers +..................................... + +In `awk', all numbers are in decimal; i.e., base 10. Many other +programming languages allow you to specify numbers in other bases, often +octal (base 8) and hexadecimal (base 16). In octal, the numbers go 0, +1, 2, 3, 4, 5, 6, 7, 10, 11, 12, etc. Just as `11', in decimal, is 1 +times 10 plus 1, so `11', in octal, is 1 times 8, plus 1. This equals 9 +in decimal. In hexadecimal, there are 16 digits. Since the everyday +decimal number system only has ten digits (`0'-`9'), the letters `a' +through `f' are used to represent the rest. (Case in the letters is +usually irrelevant; hexadecimal `a' and `A' have the same value.) +Thus, `11', in hexadecimal, is 1 times 16 plus 1, which equals 17 in +decimal. + + Just by looking at plain `11', you can't tell what base it's in. +So, in C, C++, and other languages derived from C, there is a special +notation to signify the base. Octal numbers start with a leading `0', +and hexadecimal numbers start with a leading `0x' or `0X': + +`11' + Decimal value 11. + +`011' + Octal 11, decimal value 9. + +`0x11' + Hexadecimal 11, decimal value 17. + + This example shows the difference: + + $ gawk 'BEGIN { printf "%d, %d, %d\n", 011, 11, 0x11 }' + -| 9, 11, 17 + + Being able to use octal and hexadecimal constants in your programs +is most useful when working with data that cannot be represented +conveniently as characters or as regular numbers, such as binary data +of various sorts. + + `gawk' allows the use of octal and hexadecimal constants in your +program text. However, such numbers in the input data are not treated +differently; doing so by default would break old programs. (If you +really need to do this, use the `--non-decimal-data' command-line +option; *note Nondecimal Data::.) If you have octal or hexadecimal +data, you can use the `strtonum()' function (*note String Functions::) +to convert the data into a number. Most of the time, you will want to +use octal or hexadecimal constants when working with the built-in bit +manipulation functions; see *note Bitwise Functions::, for more +information. + + Unlike some early C implementations, `8' and `9' are not valid in +octal constants; e.g., `gawk' treats `018' as decimal 18: + + $ gawk 'BEGIN { print "021 is", 021 ; print 018 }' + -| 021 is 17 + -| 18 + + Octal and hexadecimal source code constants are a `gawk' extension. +If `gawk' is in compatibility mode (*note Options::), they are not +available. + +Advanced Notes: A Constant's Base Does Not Affect Its Value +----------------------------------------------------------- + +Once a numeric constant has been converted internally into a number, +`gawk' no longer remembers what the original form of the constant was; +the internal value is always used. This has particular consequences +for conversion of numbers to strings: + + $ gawk 'BEGIN { printf "0x11 is <%s>\n", 0x11 }' + -| 0x11 is <17> + + +File: gawk.info, Node: Regexp Constants, Prev: Nondecimal-numbers, Up: Constants + +6.1.1.3 Regular Expression Constants +.................................... + +A regexp constant is a regular expression description enclosed in +slashes, such as `/^beginning and end$/'. Most regexps used in `awk' +programs are constant, but the `~' and `!~' matching operators can also +match computed or dynamic regexps (which are just ordinary strings or +variables that contain a regexp). + + +File: gawk.info, Node: Using Constant Regexps, Next: Variables, Prev: Constants, Up: Values + +6.1.2 Using Regular Expression Constants +---------------------------------------- + +When used on the righthand side of the `~' or `!~' operators, a regexp +constant merely stands for the regexp that is to be matched. However, +regexp constants (such as `/foo/') may be used like simple expressions. +When a regexp constant appears by itself, it has the same meaning as if +it appeared in a pattern, i.e., `($0 ~ /foo/)' (d.c.) *Note Expression +Patterns::. This means that the following two code segments: + + if ($0 ~ /barfly/ || $0 ~ /camelot/) + print "found" + +and: + + if (/barfly/ || /camelot/) + print "found" + +are exactly equivalent. One rather bizarre consequence of this rule is +that the following Boolean expression is valid, but does not do what +the user probably intended: + + # Note that /foo/ is on the left of the ~ + if (/foo/ ~ $1) print "found foo" + +This code is "obviously" testing `$1' for a match against the regexp +`/foo/'. But in fact, the expression `/foo/ ~ $1' really means `($0 ~ +/foo/) ~ $1'. In other words, first match the input record against the +regexp `/foo/'. The result is either zero or one, depending upon the +success or failure of the match. That result is then matched against +the first field in the record. Because it is unlikely that you would +ever really want to make this kind of test, `gawk' issues a warning +when it sees this construct in a program. Another consequence of this +rule is that the assignment statement: + + matches = /foo/ + +assigns either zero or one to the variable `matches', depending upon +the contents of the current input record. + + Constant regular expressions are also used as the first argument for +the `gensub()', `sub()', and `gsub()' functions, as the second argument +of the `match()' function, and as the third argument of the +`patsplit()' function (*note String Functions::). Modern +implementations of `awk', including `gawk', allow the third argument of +`split()' to be a regexp constant, but some older implementations do +not. (d.c.) This can lead to confusion when attempting to use regexp +constants as arguments to user-defined functions (*note User-defined::). +For example: + + function mysub(pat, repl, str, global) + { + if (global) + gsub(pat, repl, str) + else + sub(pat, repl, str) + return str + } + + { + ... + text = "hi! hi yourself!" + mysub(/hi/, "howdy", text, 1) + ... + } + + In this example, the programmer wants to pass a regexp constant to +the user-defined function `mysub', which in turn passes it on to either +`sub()' or `gsub()'. However, what really happens is that the `pat' +parameter is either one or zero, depending upon whether or not `$0' +matches `/hi/'. `gawk' issues a warning when it sees a regexp constant +used as a parameter to a user-defined function, since passing a truth +value in this way is probably not what was intended. + + +File: gawk.info, Node: Variables, Next: Conversion, Prev: Using Constant Regexps, Up: Values + +6.1.3 Variables +--------------- + +Variables are ways of storing values at one point in your program for +use later in another part of your program. They can be manipulated +entirely within the program text, and they can also be assigned values +on the `awk' command line. + +* Menu: + +* Using Variables:: Using variables in your programs. +* Assignment Options:: Setting variables on the command-line and a + summary of command-line syntax. This is an + advanced method of input. + + +File: gawk.info, Node: Using Variables, Next: Assignment Options, Up: Variables + +6.1.3.1 Using Variables in a Program +.................................... + +Variables let you give names to values and refer to them later. +Variables have already been used in many of the examples. The name of +a variable must be a sequence of letters, digits, or underscores, and +it may not begin with a digit. Case is significant in variable names; +`a' and `A' are distinct variables. + + A variable name is a valid expression by itself; it represents the +variable's current value. Variables are given new values with +"assignment operators", "increment operators", and "decrement +operators". *Note Assignment Ops::. In addition, the `sub()' and +`gsub()' functions can change a variable's value, and the `match()', +`patsplit()' and `split()' functions can change the contents of their +array parameters. *Note String Functions::. + + A few variables have special built-in meanings, such as `FS' (the +field separator), and `NF' (the number of fields in the current input +record). *Note Built-in Variables::, for a list of the built-in +variables. These built-in variables can be used and assigned just like +all other variables, but their values are also used or changed +automatically by `awk'. All built-in variables' names are entirely +uppercase. + + Variables in `awk' can be assigned either numeric or string values. +The kind of value a variable holds can change over the life of a +program. By default, variables are initialized to the empty string, +which is zero if converted to a number. There is no need to explicitly +"initialize" a variable in `awk', which is what you would do in C and +in most other traditional languages. + + +File: gawk.info, Node: Assignment Options, Prev: Using Variables, Up: Variables + +6.1.3.2 Assigning Variables on the Command Line +............................................... + +Any `awk' variable can be set by including a "variable assignment" +among the arguments on the command line when `awk' is invoked (*note +Other Arguments::). Such an assignment has the following form: + + VARIABLE=TEXT + +With it, a variable is set either at the beginning of the `awk' run or +in between input files. When the assignment is preceded with the `-v' +option, as in the following: + + -v VARIABLE=TEXT + +the variable is set at the very beginning, even before the `BEGIN' +rules execute. The `-v' option and its assignment must precede all the +file name arguments, as well as the program text. (*Note Options::, +for more information about the `-v' option.) Otherwise, the variable +assignment is performed at a time determined by its position among the +input file arguments--after the processing of the preceding input file +argument. For example: + + awk '{ print $n }' n=4 inventory-shipped n=2 BBS-list + +prints the value of field number `n' for all input records. Before the +first file is read, the command line sets the variable `n' equal to +four. This causes the fourth field to be printed in lines from +`inventory-shipped'. After the first file has finished, but before the +second file is started, `n' is set to two, so that the second field is +printed in lines from `BBS-list': + + $ awk '{ print $n }' n=4 inventory-shipped n=2 BBS-list + -| 15 + -| 24 + ... + -| 555-5553 + -| 555-3412 + ... + + Command-line arguments are made available for explicit examination by +the `awk' program in the `ARGV' array (*note ARGC and ARGV::). `awk' +processes the values of command-line assignments for escape sequences +(*note Escape Sequences::). (d.c.) + + +File: gawk.info, Node: Conversion, Prev: Variables, Up: Values + +6.1.4 Conversion of Strings and Numbers +--------------------------------------- + +Strings are converted to numbers and numbers are converted to strings, +if the context of the `awk' program demands it. For example, if the +value of either `foo' or `bar' in the expression `foo + bar' happens to +be a string, it is converted to a number before the addition is +performed. If numeric values appear in string concatenation, they are +converted to strings. Consider the following: + + two = 2; three = 3 + print (two three) + 4 + +This prints the (numeric) value 27. The numeric values of the +variables `two' and `three' are converted to strings and concatenated +together. The resulting string is converted back to the number 23, to +which 4 is then added. + + If, for some reason, you need to force a number to be converted to a +string, concatenate that number with the empty string, `""'. To force +a string to be converted to a number, add zero to that string. A +string is converted to a number by interpreting any numeric prefix of +the string as numerals: `"2.5"' converts to 2.5, `"1e3"' converts to +1000, and `"25fix"' has a numeric value of 25. Strings that can't be +interpreted as valid numbers convert to zero. + + The exact manner in which numbers are converted into strings is +controlled by the `awk' built-in variable `CONVFMT' (*note Built-in +Variables::). Numbers are converted using the `sprintf()' function +with `CONVFMT' as the format specifier (*note String Functions::). + + `CONVFMT''s default value is `"%.6g"', which prints a value with at +most six significant digits. For some applications, you might want to +change it to specify more precision. On most modern machines, 17 +digits is usually enough to capture a floating-point number's value +exactly.(1) + + Strange results can occur if you set `CONVFMT' to a string that +doesn't tell `sprintf()' how to format floating-point numbers in a +useful way. For example, if you forget the `%' in the format, `awk' +converts all numbers to the same constant string. + + As a special case, if a number is an integer, then the result of +converting it to a string is _always_ an integer, no matter what the +value of `CONVFMT' may be. Given the following code fragment: + + CONVFMT = "%2.2f" + a = 12 + b = a "" + +`b' has the value `"12"', not `"12.00"'. (d.c.) + + Prior to the POSIX standard, `awk' used the value of `OFMT' for +converting numbers to strings. `OFMT' specifies the output format to +use when printing numbers with `print'. `CONVFMT' was introduced in +order to separate the semantics of conversion from the semantics of +printing. Both `CONVFMT' and `OFMT' have the same default value: +`"%.6g"'. In the vast majority of cases, old `awk' programs do not +change their behavior. However, these semantics for `OFMT' are +something to keep in mind if you must port your new-style program to +older implementations of `awk'. We recommend that instead of changing +your programs, just port `gawk' itself. *Note Print::, for more +information on the `print' statement. + + And, once again, where you are can matter when it comes to converting +between numbers and strings. In *note Locales::, we mentioned that the +local character set and language (the locale) can affect how `gawk' +matches characters. The locale also affects numeric formats. In +particular, for `awk' programs, it affects the decimal point character. +The `"C"' locale, and most English-language locales, use the period +character (`.') as the decimal point. However, many (if not most) +European and non-English locales use the comma (`,') as the decimal +point character. + + The POSIX standard says that `awk' always uses the period as the +decimal point when reading the `awk' program source code, and for +command-line variable assignments (*note Other Arguments::). However, +when interpreting input data, for `print' and `printf' output, and for +number to string conversion, the local decimal point character is used. +Here are some examples indicating the difference in behavior, on a +GNU/Linux system: + + $ gawk 'BEGIN { printf "%g\n", 3.1415927 }' + -| 3.14159 + $ LC_ALL=en_DK gawk 'BEGIN { printf "%g\n", 3.1415927 }' + -| 3,14159 + $ echo 4,321 | gawk '{ print $1 + 1 }' + -| 5 + $ echo 4,321 | LC_ALL=en_DK gawk '{ print $1 + 1 }' + -| 5,321 + +The `en_DK' locale is for English in Denmark, where the comma acts as +the decimal point separator. In the normal `"C"' locale, `gawk' treats +`4,321' as `4', while in the Danish locale, it's treated as the full +number, 4.321. + + Some earlier versions of `gawk' fully complied with this aspect of +the standard. However, many users in non-English locales complained +about this behavior, since their data used a period as the decimal +point, so the default behavior was restored to use a period as the +decimal point character. You can use the `--use-lc-numeric' option +(*note Options::) to force `gawk' to use the locale's decimal point +character. (`gawk' also uses the locale's decimal point character when +in POSIX mode, either via `--posix', or the `POSIXLY_CORRECT' +environment variable.) + + *note table-locale-affects:: describes the cases in which the +locale's decimal point character is used and when a period is used. +Some of these features have not been described yet. + +Feature Default `--posix' or `--use-lc-numeric' +------------------------------------------------------------ +`%'g' Use locale Use locale +`%g' Use period Use locale +Input Use period Use locale +`strtonum()'Use period Use locale + +Table 6.1: Locale Decimal Point versus A Period + + Finally, modern day formal standards and IEEE standard floating point +representation can have an unusual but important effect on the way +`gawk' converts some special string values to numbers. The details are +presented in *note POSIX Floating Point Problems::. + + ---------- Footnotes ---------- + + (1) Pathological cases can require up to 752 digits (!), but we +doubt that you need to worry about this. + + +File: gawk.info, Node: All Operators, Next: Truth Values and Conditions, Prev: Values, Up: Expressions + +6.2 Operators: Doing Something With Values +========================================== + +This minor node introduces the "operators" which make use of the values +provided by constants and variables. + +* Menu: + +* Arithmetic Ops:: Arithmetic operations (`+', `-', + etc.) +* Concatenation:: Concatenating strings. +* Assignment Ops:: Changing the value of a variable or a field. +* Increment Ops:: Incrementing the numeric value of a variable. + + +File: gawk.info, Node: Arithmetic Ops, Next: Concatenation, Up: All Operators + +6.2.1 Arithmetic Operators +-------------------------- + +The `awk' language uses the common arithmetic operators when evaluating +expressions. All of these arithmetic operators follow normal +precedence rules and work as you would expect them to. + + The following example uses a file named `grades', which contains a +list of student names as well as three test scores per student (it's a +small class): + + Pat 100 97 58 + Sandy 84 72 93 + Chris 72 92 89 + +This program takes the file `grades' and prints the average of the +scores: + + $ awk '{ sum = $2 + $3 + $4 ; avg = sum / 3 + > print $1, avg }' grades + -| Pat 85 + -| Sandy 83 + -| Chris 84.3333 + + The following list provides the arithmetic operators in `awk', in +order from the highest precedence to the lowest: + +`- X' + Negation. + +`+ X' + Unary plus; the expression is converted to a number. + +`X ^ Y' +`X ** Y' + Exponentiation; X raised to the Y power. `2 ^ 3' has the value + eight; the character sequence `**' is equivalent to `^'. (c.e.) + +`X * Y' + Multiplication. + +`X / Y' + Division; because all numbers in `awk' are floating-point + numbers, the result is _not_ rounded to an integer--`3 / 4' has + the value 0.75. (It is a common mistake, especially for C + programmers, to forget that _all_ numbers in `awk' are + floating-point, and that division of integer-looking constants + produces a real number, not an integer.) + +`X % Y' + Remainder; further discussion is provided in the text, just after + this list. + +`X + Y' + Addition. + +`X - Y' + Subtraction. + + Unary plus and minus have the same precedence, the multiplication +operators all have the same precedence, and addition and subtraction +have the same precedence. + + When computing the remainder of `X % Y', the quotient is rounded +toward zero to an integer and multiplied by Y. This result is +subtracted from X; this operation is sometimes known as "trunc-mod." +The following relation always holds: + + b * int(a / b) + (a % b) == a + + One possibly undesirable effect of this definition of remainder is +that `X % Y' is negative if X is negative. Thus: + + -17 % 8 = -1 + + In other `awk' implementations, the signedness of the remainder may +be machine-dependent. + + NOTE: The POSIX standard only specifies the use of `^' for + exponentiation. For maximum portability, do not use the `**' + operator. + + +File: gawk.info, Node: Concatenation, Next: Assignment Ops, Prev: Arithmetic Ops, Up: All Operators + +6.2.2 String Concatenation +-------------------------- + + It seemed like a good idea at the time. + Brian Kernighan + + There is only one string operation: concatenation. It does not have +a specific operator to represent it. Instead, concatenation is +performed by writing expressions next to one another, with no operator. +For example: + + $ awk '{ print "Field number one: " $1 }' BBS-list + -| Field number one: aardvark + -| Field number one: alpo-net + ... + + Without the space in the string constant after the `:', the line +runs together. For example: + + $ awk '{ print "Field number one:" $1 }' BBS-list + -| Field number one:aardvark + -| Field number one:alpo-net + ... + + Because string concatenation does not have an explicit operator, it +is often necessary to insure that it happens at the right time by using +parentheses to enclose the items to concatenate. For example, you +might expect that the following code fragment concatenates `file' and +`name': + + file = "file" + name = "name" + print "something meaningful" > file name + +This produces a syntax error with some versions of Unix `awk'.(1) It is +necessary to use the following: + + print "something meaningful" > (file name) + + Parentheses should be used around concatenation in all but the most +common contexts, such as on the righthand side of `='. Be careful +about the kinds of expressions used in string concatenation. In +particular, the order of evaluation of expressions used for +concatenation is undefined in the `awk' language. Consider this +example: + + BEGIN { + a = "don't" + print (a " " (a = "panic")) + } + +It is not defined whether the assignment to `a' happens before or after +the value of `a' is retrieved for producing the concatenated value. +The result could be either `don't panic', or `panic panic'. + + The precedence of concatenation, when mixed with other operators, is +often counter-intuitive. Consider this example: + + $ awk 'BEGIN { print -12 " " -24 }' + -| -12-24 + + This "obviously" is concatenating -12, a space, and -24. But where +did the space disappear to? The answer lies in the combination of +operator precedences and `awk''s automatic conversion rules. To get +the desired result, write the program this way: + + $ awk 'BEGIN { print -12 " " (-24) }' + -| -12 -24 + + This forces `awk' to treat the `-' on the `-24' as unary. +Otherwise, it's parsed as follows: + + -12 (`" "' - 24) + => -12 (0 - 24) + => -12 (-24) + => -12-24 + + As mentioned earlier, when doing concatenation, _parenthesize_. +Otherwise, you're never quite sure what you'll get. + + ---------- Footnotes ---------- + + (1) It happens that Brian Kernighan's `awk', `gawk' and `mawk' all +"get it right," but you should not rely on this. + + +File: gawk.info, Node: Assignment Ops, Next: Increment Ops, Prev: Concatenation, Up: All Operators + +6.2.3 Assignment Expressions +---------------------------- + +An "assignment" is an expression that stores a (usually different) +value into a variable. For example, let's assign the value one to the +variable `z': + + z = 1 + + After this expression is executed, the variable `z' has the value +one. Whatever old value `z' had before the assignment is forgotten. + + Assignments can also store string values. For example, the +following stores the value `"this food is good"' in the variable +`message': + + thing = "food" + predicate = "good" + message = "this " thing " is " predicate + +This also illustrates string concatenation. The `=' sign is called an +"assignment operator". It is the simplest assignment operator because +the value of the righthand operand is stored unchanged. Most operators +(addition, concatenation, and so on) have no effect except to compute a +value. If the value isn't used, there's no reason to use the operator. +An assignment operator is different; it does produce a value, but even +if you ignore it, the assignment still makes itself felt through the +alteration of the variable. We call this a "side effect". + + The lefthand operand of an assignment need not be a variable (*note +Variables::); it can also be a field (*note Changing Fields::) or an +array element (*note Arrays::). These are all called "lvalues", which +means they can appear on the lefthand side of an assignment operator. +The righthand operand may be any expression; it produces the new value +that the assignment stores in the specified variable, field, or array +element. (Such values are called "rvalues".) + + It is important to note that variables do _not_ have permanent types. +A variable's type is simply the type of whatever value it happens to +hold at the moment. In the following program fragment, the variable +`foo' has a numeric value at first, and a string value later on: + + foo = 1 + print foo + foo = "bar" + print foo + +When the second assignment gives `foo' a string value, the fact that it +previously had a numeric value is forgotten. + + String values that do not begin with a digit have a numeric value of +zero. After executing the following code, the value of `foo' is five: + + foo = "a string" + foo = foo + 5 + + NOTE: Using a variable as a number and then later as a string can + be confusing and is poor programming style. The previous two + examples illustrate how `awk' works, _not_ how you should write + your programs! + + An assignment is an expression, so it has a value--the same value +that is assigned. Thus, `z = 1' is an expression with the value one. +One consequence of this is that you can write multiple assignments +together, such as: + + x = y = z = 5 + +This example stores the value five in all three variables (`x', `y', +and `z'). It does so because the value of `z = 5', which is five, is +stored into `y' and then the value of `y = z = 5', which is five, is +stored into `x'. + + Assignments may be used anywhere an expression is called for. For +example, it is valid to write `x != (y = 1)' to set `y' to one, and +then test whether `x' equals one. But this style tends to make +programs hard to read; such nesting of assignments should be avoided, +except perhaps in a one-shot program. + + Aside from `=', there are several other assignment operators that do +arithmetic with the old value of the variable. For example, the +operator `+=' computes a new value by adding the righthand value to the +old value of the variable. Thus, the following assignment adds five to +the value of `foo': + + foo += 5 + +This is equivalent to the following: + + foo = foo + 5 + +Use whichever makes the meaning of your program clearer. + + There are situations where using `+=' (or any assignment operator) +is _not_ the same as simply repeating the lefthand operand in the +righthand expression. For example: + + # Thanks to Pat Rankin for this example + BEGIN { + foo[rand()] += 5 + for (x in foo) + print x, foo[x] + + bar[rand()] = bar[rand()] + 5 + for (x in bar) + print x, bar[x] + } + +The indices of `bar' are practically guaranteed to be different, because +`rand()' returns different values each time it is called. (Arrays and +the `rand()' function haven't been covered yet. *Note Arrays::, and +see *note Numeric Functions::, for more information). This example +illustrates an important fact about assignment operators: the lefthand +expression is only evaluated _once_. It is up to the implementation as +to which expression is evaluated first, the lefthand or the righthand. +Consider this example: + + i = 1 + a[i += 2] = i + 1 + +The value of `a[3]' could be either two or four. + + *note table-assign-ops:: lists the arithmetic assignment operators. +In each case, the righthand operand is an expression whose value is +converted to a number. + +Operator Effect +-------------------------------------------------------------------------- +LVALUE `+=' INCREMENT Adds INCREMENT to the value of LVALUE. +LVALUE `-=' DECREMENT Subtracts DECREMENT from the value of LVALUE. +LVALUE `*=' Multiplies the value of LVALUE by COEFFICIENT. +COEFFICIENT +LVALUE `/=' DIVISOR Divides the value of LVALUE by DIVISOR. +LVALUE `%=' MODULUS Sets LVALUE to its remainder by MODULUS. +LVALUE `^=' POWER +LVALUE `**=' POWER Raises LVALUE to the power POWER. (c.e.) + +Table 6.2: Arithmetic Assignment Operators + + NOTE: Only the `^=' operator is specified by POSIX. For maximum + portability, do not use the `**=' operator. + +Advanced Notes: Syntactic Ambiguities Between `/=' and Regular Expressions +-------------------------------------------------------------------------- + +There is a syntactic ambiguity between the `/=' assignment operator and +regexp constants whose first character is an `='. (d.c.) This is most +notable in commercial `awk' versions. For example: + + $ awk /==/ /dev/null + error--> awk: syntax error at source line 1 + error--> context is + error--> >>> /= <<< + error--> awk: bailing out at source line 1 + +A workaround is: + + awk '/[=]=/' /dev/null + + `gawk' does not have this problem, nor do the other freely available +versions described in *note Other Versions::. + + +File: gawk.info, Node: Increment Ops, Prev: Assignment Ops, Up: All Operators + +6.2.4 Increment and Decrement Operators +--------------------------------------- + +"Increment" and "decrement operators" increase or decrease the value of +a variable by one. An assignment operator can do the same thing, so +the increment operators add no power to the `awk' language; however, +they are convenient abbreviations for very common operations. + + The operator used for adding one is written `++'. It can be used to +increment a variable either before or after taking its value. To +pre-increment a variable `v', write `++v'. This adds one to the value +of `v'--that new value is also the value of the expression. (The +assignment expression `v += 1' is completely equivalent.) Writing the +`++' after the variable specifies post-increment. This increments the +variable value just the same; the difference is that the value of the +increment expression itself is the variable's _old_ value. Thus, if +`foo' has the value four, then the expression `foo++' has the value +four, but it changes the value of `foo' to five. In other words, the +operator returns the old value of the variable, but with the side +effect of incrementing it. + + The post-increment `foo++' is nearly the same as writing `(foo += 1) +- 1'. It is not perfectly equivalent because all numbers in `awk' are +floating-point--in floating-point, `foo + 1 - 1' does not necessarily +equal `foo'. But the difference is minute as long as you stick to +numbers that are fairly small (less than 10e12). + + Fields and array elements are incremented just like variables. (Use +`$(i++)' when you want to do a field reference and a variable increment +at the same time. The parentheses are necessary because of the +precedence of the field reference operator `$'.) + + The decrement operator `--' works just like `++', except that it +subtracts one instead of adding it. As with `++', it can be used before +the lvalue to pre-decrement or after it to post-decrement. Following +is a summary of increment and decrement expressions: + +`++LVALUE' + Increment LVALUE, returning the new value as the value of the + expression. + +`LVALUE++' + Increment LVALUE, returning the _old_ value of LVALUE as the value + of the expression. + +`--LVALUE' + Decrement LVALUE, returning the new value as the value of the + expression. (This expression is like `++LVALUE', but instead of + adding, it subtracts.) + +`LVALUE--' + Decrement LVALUE, returning the _old_ value of LVALUE as the value + of the expression. (This expression is like `LVALUE++', but + instead of adding, it subtracts.) + +Advanced Notes: Operator Evaluation Order +----------------------------------------- + + Doctor, doctor! It hurts when I do this! + So don't do that! + Groucho Marx + +What happens for something like the following? + + b = 6 + print b += b++ + +Or something even stranger? + + b = 6 + b += ++b + b++ + print b + + In other words, when do the various side effects prescribed by the +postfix operators (`b++') take effect? When side effects happen is +"implementation defined". In other words, it is up to the particular +version of `awk'. The result for the first example may be 12 or 13, +and for the second, it may be 22 or 23. + + In short, doing things like this is not recommended and definitely +not anything that you can rely upon for portability. You should avoid +such things in your own programs. + + +File: gawk.info, Node: Truth Values and Conditions, Next: Function Calls, Prev: All Operators, Up: Expressions + +6.3 Truth Values and Conditions +=============================== + +In certain contexts, expression values also serve as "truth values;" +i.e., they determine what should happen next as the program runs. This +minor node describes how `awk' defines "true" and "false" and how +values are compared. + +* Menu: + +* Truth Values:: What is ``true'' and what is ``false''. +* Typing and Comparison:: How variables acquire types and how this + affects comparison of numbers and strings with + `<', etc. +* Boolean Ops:: Combining comparison expressions using boolean + operators `||' (``or''), `&&' + (``and'') and `!' (``not''). +* Conditional Exp:: Conditional expressions select between two + subexpressions under control of a third + subexpression. + + +File: gawk.info, Node: Truth Values, Next: Typing and Comparison, Up: Truth Values and Conditions + +6.3.1 True and False in `awk' +----------------------------- + +Many programming languages have a special representation for the +concepts of "true" and "false." Such languages usually use the special +constants `true' and `false', or perhaps their uppercase equivalents. +However, `awk' is different. It borrows a very simple concept of true +and false from C. In `awk', any nonzero numeric value _or_ any +nonempty string value is true. Any other value (zero or the null +string, `""') is false. The following program prints `A strange truth +value' three times: + + BEGIN { + if (3.1415927) + print "A strange truth value" + if ("Four Score And Seven Years Ago") + print "A strange truth value" + if (j = 57) + print "A strange truth value" + } + + There is a surprising consequence of the "nonzero or non-null" rule: +the string constant `"0"' is actually true, because it is non-null. +(d.c.) + + +File: gawk.info, Node: Typing and Comparison, Next: Boolean Ops, Prev: Truth Values, Up: Truth Values and Conditions + +6.3.2 Variable Typing and Comparison Expressions +------------------------------------------------ + + The Guide is definitive. Reality is frequently inaccurate. + The Hitchhiker's Guide to the Galaxy + + Unlike other programming languages, `awk' variables do not have a +fixed type. Instead, they can be either a number or a string, depending +upon the value that is assigned to them. We look now at how variables +are typed, and how `awk' compares variables. + +* Menu: + +* Variable Typing:: String type versus numeric type. +* Comparison Operators:: The comparison operators. +* POSIX String Comparison:: String comparison with POSIX rules. + + +File: gawk.info, Node: Variable Typing, Next: Comparison Operators, Up: Typing and Comparison + +6.3.2.1 String Type Versus Numeric Type +....................................... + +The 1992 POSIX standard introduced the concept of a "numeric string", +which is simply a string that looks like a number--for example, +`" +2"'. This concept is used for determining the type of a variable. +The type of the variable is important because the types of two variables +determine how they are compared. The various versions of the POSIX +standard did not get the rules quite right for several editions. +Fortunately, as of at least the 2008 standard (and possibly earlier), +the standard has been fixed, and variable typing follows these rules:(1) + + * A numeric constant or the result of a numeric operation has the + NUMERIC attribute. + + * A string constant or the result of a string operation has the + STRING attribute. + + * Fields, `getline' input, `FILENAME', `ARGV' elements, `ENVIRON' + elements, and the elements of an array created by `patsplit()', + `split()' and `match()' that are numeric strings have the STRNUM + attribute. Otherwise, they have the STRING attribute. + Uninitialized variables also have the STRNUM attribute. + + * Attributes propagate across assignments but are not changed by any + use. + + The last rule is particularly important. In the following program, +`a' has numeric type, even though it is later used in a string +operation: + + BEGIN { + a = 12.345 + b = a " is a cute number" + print b + } + + When two operands are compared, either string comparison or numeric +comparison may be used. This depends upon the attributes of the +operands, according to the following symmetric matrix: + + +--------------------------------------------- + | STRING NUMERIC STRNUM + -------+--------------------------------------------- + | + STRING | string string string + | + NUMERIC | string numeric numeric + | + STRNUM | string numeric numeric + -------+--------------------------------------------- + + The basic idea is that user input that looks numeric--and _only_ +user input--should be treated as numeric, even though it is actually +made of characters and is therefore also a string. Thus, for example, +the string constant `" +3.14"', when it appears in program source code, +is a string--even though it looks numeric--and is _never_ treated as +number for comparison purposes. + + In short, when one operand is a "pure" string, such as a string +constant, then a string comparison is performed. Otherwise, a numeric +comparison is performed. + + This point bears additional emphasis: All user input is made of +characters, and so is first and foremost of STRING type; input strings +that look numeric are additionally given the STRNUM attribute. Thus, +the six-character input string ` +3.14' receives the STRNUM attribute. +In contrast, the eight-character literal `" +3.14"' appearing in +program text is a string constant. The following examples print `1' +when the comparison between the two different constants is true, `0' +otherwise: + + $ echo ' +3.14' | gawk '{ print $0 == " +3.14" }' True + -| 1 + $ echo ' +3.14' | gawk '{ print $0 == "+3.14" }' False + -| 0 + $ echo ' +3.14' | gawk '{ print $0 == "3.14" }' False + -| 0 + $ echo ' +3.14' | gawk '{ print $0 == 3.14 }' True + -| 1 + $ echo ' +3.14' | gawk '{ print $1 == " +3.14" }' False + -| 0 + $ echo ' +3.14' | gawk '{ print $1 == "+3.14" }' True + -| 1 + $ echo ' +3.14' | gawk '{ print $1 == "3.14" }' False + -| 0 + $ echo ' +3.14' | gawk '{ print $1 == 3.14 }' True + -| 1 + + ---------- Footnotes ---------- + + (1) `gawk' has followed these rules for many years, and it is +gratifying that the POSIX standard is also now correct. + + +File: gawk.info, Node: Comparison Operators, Next: POSIX String Comparison, Prev: Variable Typing, Up: Typing and Comparison + +6.3.2.2 Comparison Operators +............................ + +"Comparison expressions" compare strings or numbers for relationships +such as equality. They are written using "relational operators", which +are a superset of those in C. *note table-relational-ops:: describes +them. + +Expression Result +-------------------------------------------------------------------------- +X `<' Y True if X is less than Y. +X `<=' Y True if X is less than or equal to Y. +X `>' Y True if X is greater than Y. +X `>=' Y True if X is greater than or equal to Y. +X `==' Y True if X is equal to Y. +X `!=' Y True if X is not equal to Y. +X `~' Y True if the string X matches the regexp denoted by Y. +X `!~' Y True if the string X does not match the regexp + denoted by Y. +SUBSCRIPT `in' True if the array ARRAY has an element with the +ARRAY subscript SUBSCRIPT. + +Table 6.3: Relational Operators + + Comparison expressions have the value one if true and zero if false. +When comparing operands of mixed types, numeric operands are converted +to strings using the value of `CONVFMT' (*note Conversion::). + + Strings are compared by comparing the first character of each, then +the second character of each, and so on. Thus, `"10"' is less than +`"9"'. If there are two strings where one is a prefix of the other, +the shorter string is less than the longer one. Thus, `"abc"' is less +than `"abcd"'. + + It is very easy to accidentally mistype the `==' operator and leave +off one of the `=' characters. The result is still valid `awk' code, +but the program does not do what is intended: + + if (a = b) # oops! should be a == b + ... + else + ... + +Unless `b' happens to be zero or the null string, the `if' part of the +test always succeeds. Because the operators are so similar, this kind +of error is very difficult to spot when scanning the source code. + + The following table of expressions illustrates the kind of comparison +`gawk' performs, as well as what the result of the comparison is: + +`1.5 <= 2.0' + numeric comparison (true) + +`"abc" >= "xyz"' + string comparison (false) + +`1.5 != " +2"' + string comparison (true) + +`"1e2" < "3"' + string comparison (true) + +`a = 2; b = "2"' +`a == b' + string comparison (true) + +`a = 2; b = " +2"' + +`a == b' + string comparison (false) + + In this example: + + $ echo 1e2 3 | awk '{ print ($1 < $2) ? "true" : "false" }' + -| false + +the result is `false' because both `$1' and `$2' are user input. They +are numeric strings--therefore both have the STRNUM attribute, +dictating a numeric comparison. The purpose of the comparison rules +and the use of numeric strings is to attempt to produce the behavior +that is "least surprising," while still "doing the right thing." + + String comparisons and regular expression comparisons are very +different. For example: + + x == "foo" + +has the value one, or is true if the variable `x' is precisely `foo'. +By contrast: + + x ~ /foo/ + +has the value one if `x' contains `foo', such as `"Oh, what a fool am +I!"'. + + The righthand operand of the `~' and `!~' operators may be either a +regexp constant (`/.../') or an ordinary expression. In the latter +case, the value of the expression as a string is used as a dynamic +regexp (*note Regexp Usage::; also *note Computed Regexps::). + + In modern implementations of `awk', a constant regular expression in +slashes by itself is also an expression. The regexp `/REGEXP/' is an +abbreviation for the following comparison expression: + + $0 ~ /REGEXP/ + + One special place where `/foo/' is _not_ an abbreviation for `$0 ~ +/foo/' is when it is the righthand operand of `~' or `!~'. *Note Using +Constant Regexps::, where this is discussed in more detail. + + +File: gawk.info, Node: POSIX String Comparison, Prev: Comparison Operators, Up: Typing and Comparison + +6.3.2.3 String Comparison With POSIX Rules +.......................................... + +The POSIX standard says that string comparison is performed based on +the locale's collating order. This is usually very different from the +results obtained when doing straight character-by-character +comparison.(1) + + Because this behavior differs considerably from existing practice, +`gawk' only implements it when in POSIX mode (*note Options::). Here +is an example to illustrate the difference, in an `en_US.UTF-8' locale: + + $ gawk 'BEGIN { printf("ABC < abc = %s\n", + > ("ABC" < "abc" ? "TRUE" : "FALSE")) }' + -| ABC < abc = TRUE + $ gawk --posix 'BEGIN { printf("ABC < abc = %s\n", + > ("ABC" < "abc" ? "TRUE" : "FALSE")) }' + -| ABC < abc = FALSE + + ---------- Footnotes ---------- + + (1) Technically, string comparison is supposed to behave the same +way as if the strings are compared with the C `strcoll()' function. + + +File: gawk.info, Node: Boolean Ops, Next: Conditional Exp, Prev: Typing and Comparison, Up: Truth Values and Conditions + +6.3.3 Boolean Expressions +------------------------- + +A "Boolean expression" is a combination of comparison expressions or +matching expressions, using the Boolean operators "or" (`||'), "and" +(`&&'), and "not" (`!'), along with parentheses to control nesting. +The truth value of the Boolean expression is computed by combining the +truth values of the component expressions. Boolean expressions are +also referred to as "logical expressions". The terms are equivalent. + + Boolean expressions can be used wherever comparison and matching +expressions can be used. They can be used in `if', `while', `do', and +`for' statements (*note Statements::). They have numeric values (one +if true, zero if false) that come into play if the result of the +Boolean expression is stored in a variable or used in arithmetic. + + In addition, every Boolean expression is also a valid pattern, so +you can use one as a pattern to control the execution of rules. The +Boolean operators are: + +`BOOLEAN1 && BOOLEAN2' + True if both BOOLEAN1 and BOOLEAN2 are true. For example, the + following statement prints the current input record if it contains + both `2400' and `foo': + + if ($0 ~ /2400/ && $0 ~ /foo/) print + + The subexpression BOOLEAN2 is evaluated only if BOOLEAN1 is true. + This can make a difference when BOOLEAN2 contains expressions that + have side effects. In the case of `$0 ~ /foo/ && ($2 == bar++)', + the variable `bar' is not incremented if there is no substring + `foo' in the record. + +`BOOLEAN1 || BOOLEAN2' + True if at least one of BOOLEAN1 or BOOLEAN2 is true. For + example, the following statement prints all records in the input + that contain _either_ `2400' or `foo' or both: + + if ($0 ~ /2400/ || $0 ~ /foo/) print + + The subexpression BOOLEAN2 is evaluated only if BOOLEAN1 is false. + This can make a difference when BOOLEAN2 contains expressions that + have side effects. + +`! BOOLEAN' + True if BOOLEAN is false. For example, the following program + prints `no home!' in the unusual event that the `HOME' environment + variable is not defined: + + BEGIN { if (! ("HOME" in ENVIRON)) + print "no home!" } + + (The `in' operator is described in *note Reference to Elements::.) + + The `&&' and `||' operators are called "short-circuit" operators +because of the way they work. Evaluation of the full expression is +"short-circuited" if the result can be determined part way through its +evaluation. + + Statements that use `&&' or `||' can be continued simply by putting +a newline after them. But you cannot put a newline in front of either +of these operators without using backslash continuation (*note +Statements/Lines::). + + The actual value of an expression using the `!' operator is either +one or zero, depending upon the truth value of the expression it is +applied to. The `!' operator is often useful for changing the sense of +a flag variable from false to true and back again. For example, the +following program is one way to print lines in between special +bracketing lines: + + $1 == "START" { interested = ! interested; next } + interested == 1 { print } + $1 == "END" { interested = ! interested; next } + +The variable `interested', as with all `awk' variables, starts out +initialized to zero, which is also false. When a line is seen whose +first field is `START', the value of `interested' is toggled to true, +using `!'. The next rule prints lines as long as `interested' is true. +When a line is seen whose first field is `END', `interested' is toggled +back to false.(1) + + NOTE: The `next' statement is discussed in *note Next Statement::. + `next' tells `awk' to skip the rest of the rules, get the next + record, and start processing the rules over again at the top. The + reason it's there is to avoid printing the bracketing `START' and + `END' lines. + + ---------- Footnotes ---------- + + (1) This program has a bug; it prints lines starting with `END'. How +would you fix it? + + +File: gawk.info, Node: Conditional Exp, Prev: Boolean Ops, Up: Truth Values and Conditions + +6.3.4 Conditional Expressions +----------------------------- + +A "conditional expression" is a special kind of expression that has +three operands. It allows you to use one expression's value to select +one of two other expressions. The conditional expression is the same +as in the C language, as shown here: + + SELECTOR ? IF-TRUE-EXP : IF-FALSE-EXP + +There are three subexpressions. The first, SELECTOR, is always +computed first. If it is "true" (not zero or not null), then +IF-TRUE-EXP is computed next and its value becomes the value of the +whole expression. Otherwise, IF-FALSE-EXP is computed next and its +value becomes the value of the whole expression. For example, the +following expression produces the absolute value of `x': + + x >= 0 ? x : -x + + Each time the conditional expression is computed, only one of +IF-TRUE-EXP and IF-FALSE-EXP is used; the other is ignored. This is +important when the expressions have side effects. For example, this +conditional expression examines element `i' of either array `a' or +array `b', and increments `i': + + x == y ? a[i++] : b[i++] + +This is guaranteed to increment `i' exactly once, because each time +only one of the two increment expressions is executed and the other is +not. *Note Arrays::, for more information about arrays. + + As a minor `gawk' extension, a statement that uses `?:' can be +continued simply by putting a newline after either character. However, +putting a newline in front of either character does not work without +using backslash continuation (*note Statements/Lines::). If `--posix' +is specified (*note Options::), then this extension is disabled. + + +File: gawk.info, Node: Function Calls, Next: Precedence, Prev: Truth Values and Conditions, Up: Expressions + +6.4 Function Calls +================== + +A "function" is a name for a particular calculation. This enables you +to ask for it by name at any point in the program. For example, the +function `sqrt()' computes the square root of a number. + + A fixed set of functions are "built-in", which means they are +available in every `awk' program. The `sqrt()' function is one of +these. *Note Built-in::, for a list of built-in functions and their +descriptions. In addition, you can define functions for use in your +program. *Note User-defined::, for instructions on how to do this. + + The way to use a function is with a "function call" expression, +which consists of the function name followed immediately by a list of +"arguments" in parentheses. The arguments are expressions that provide +the raw materials for the function's calculations. When there is more +than one argument, they are separated by commas. If there are no +arguments, just write `()' after the function name. The following +examples show function calls with and without arguments: + + sqrt(x^2 + y^2) one argument + atan2(y, x) two arguments + rand() no arguments + + CAUTION: Do not put any space between the function name and the + open-parenthesis! A user-defined function name looks just like + the name of a variable--a space would make the expression look + like concatenation of a variable with an expression inside + parentheses. With built-in functions, space before the + parenthesis is harmless, but it is best not to get into the habit + of using space to avoid mistakes with user-defined functions. + + Each function expects a particular number of arguments. For +example, the `sqrt()' function must be called with a single argument, +the number of which to take the square root: + + sqrt(ARGUMENT) + + Some of the built-in functions have one or more optional arguments. +If those arguments are not supplied, the functions use a reasonable +default value. *Note Built-in::, for full details. If arguments are +omitted in calls to user-defined functions, then those arguments are +treated as local variables and initialized to the empty string (*note +User-defined::). + + As an advanced feature, `gawk' provides indirect function calls, +which is a way to choose the function to call at runtime, instead of +when you write the source code to your program. We defer discussion of +this feature until later; see *note Indirect Calls::. + + Like every other expression, the function call has a value, which is +computed by the function based on the arguments you give it. In this +example, the value of `sqrt(ARGUMENT)' is the square root of ARGUMENT. +The following program reads numbers, one number per line, and prints the +square root of each one: + + $ awk '{ print "The square root of", $1, "is", sqrt($1) }' + 1 + -| The square root of 1 is 1 + 3 + -| The square root of 3 is 1.73205 + 5 + -| The square root of 5 is 2.23607 + Ctrl-d + + A function can also have side effects, such as assigning values to +certain variables or doing I/O. This program shows how the `match()' +function (*note String Functions::) changes the variables `RSTART' and +`RLENGTH': + + { + if (match($1, $2)) + print RSTART, RLENGTH + else + print "no match" + } + +Here is a sample run: + + $ awk -f matchit.awk + aaccdd c+ + -| 3 2 + foo bar + -| no match + abcdefg e + -| 5 1 + + +File: gawk.info, Node: Precedence, Next: Locales, Prev: Function Calls, Up: Expressions + +6.5 Operator Precedence (How Operators Nest) +============================================ + +"Operator precedence" determines how operators are grouped when +different operators appear close by in one expression. For example, +`*' has higher precedence than `+'; thus, `a + b * c' means to multiply +`b' and `c', and then add `a' to the product (i.e., `a + (b * c)'). + + The normal precedence of the operators can be overruled by using +parentheses. Think of the precedence rules as saying where the +parentheses are assumed to be. In fact, it is wise to always use +parentheses whenever there is an unusual combination of operators, +because other people who read the program may not remember what the +precedence is in this case. Even experienced programmers occasionally +forget the exact rules, which leads to mistakes. Explicit parentheses +help prevent any such mistakes. + + When operators of equal precedence are used together, the leftmost +operator groups first, except for the assignment, conditional, and +exponentiation operators, which group in the opposite order. Thus, `a +- b + c' groups as `(a - b) + c' and `a = b = c' groups as `a = (b = +c)'. + + Normally the precedence of prefix unary operators does not matter, +because there is only one way to interpret them: innermost first. +Thus, `$++i' means `$(++i)' and `++$x' means `++($x)'. However, when +another operator follows the operand, then the precedence of the unary +operators can matter. `$x^2' means `($x)^2', but `-x^2' means +`-(x^2)', because `-' has lower precedence than `^', whereas `$' has +higher precedence. Also, operators cannot be combined in a way that +violates the precedence rules; for example, `$$0++--' is not a valid +expression because the first `$' has higher precedence than the `++'; +to avoid the problem the expression can be rewritten as `$($0++)--'. + + This table presents `awk''s operators, in order of highest to lowest +precedence: + +`(...)' + Grouping. + +`$' + Field reference. + +`++ --' + Increment, decrement. + +`^ **' + Exponentiation. These operators group right-to-left. + +`+ - !' + Unary plus, minus, logical "not." + +`* / %' + Multiplication, division, remainder. + +`+ -' + Addition, subtraction. + +`String Concatenation' + There is no special symbol for concatenation. The operands are + simply written side by side (*note Concatenation::). + +`< <= == != > >= >> | |&' + Relational and redirection. The relational operators and the + redirections have the same precedence level. Characters such as + `>' serve both as relationals and as redirections; the context + distinguishes between the two meanings. + + Note that the I/O redirection operators in `print' and `printf' + statements belong to the statement level, not to expressions. The + redirection does not produce an expression that could be the + operand of another operator. As a result, it does not make sense + to use a redirection operator near another operator of lower + precedence without parentheses. Such combinations (for example, + `print foo > a ? b : c'), result in syntax errors. The correct + way to write this statement is `print foo > (a ? b : c)'. + +`~ !~' + Matching, nonmatching. + +`in' + Array membership. + +`&&' + Logical "and". + +`||' + Logical "or". + +`?:' + Conditional. This operator groups right-to-left. + +`= += -= *= /= %= ^= **=' + Assignment. These operators group right-to-left. + + NOTE: The `|&', `**', and `**=' operators are not specified by + POSIX. For maximum portability, do not use them. + + +File: gawk.info, Node: Locales, Prev: Precedence, Up: Expressions + +6.6 Where You Are Makes A Difference +==================================== + +Modern systems support the notion of "locales": a way to tell the +system about the local character set and language. + + Once upon a time, the locale setting used to affect regexp matching +(*note Ranges and Locales::), but this is no longer true. + + Locales can affect record splitting. For the normal case of `RS = +"\n"', the locale is largely irrelevant. For other single-character +record separators, setting `LC_ALL=C' in the environment will give you +much better performance when reading records. Otherwise, `gawk' has to +make several function calls, _per input character_, to find the record +terminator. + + According to POSIX, string comparison is also affected by locales +(similar to regular expressions). The details are presented in *note +POSIX String Comparison::. + + Finally, the locale affects the value of the decimal point character +used when `gawk' parses input data. This is discussed in detail in +*note Conversion::. + + +File: gawk.info, Node: Patterns and Actions, Next: Arrays, Prev: Expressions, Up: Top + +7 Patterns, Actions, and Variables +********************************** + +As you have already seen, each `awk' statement consists of a pattern +with an associated action. This major node describes how you build +patterns and actions, what kinds of things you can do within actions, +and `awk''s built-in variables. + + The pattern-action rules and the statements available for use within +actions form the core of `awk' programming. In a sense, everything +covered up to here has been the foundation that programs are built on +top of. Now it's time to start building something useful. + +* Menu: + +* Pattern Overview:: What goes into a pattern. +* Using Shell Variables:: How to use shell variables with `awk'. +* Action Overview:: What goes into an action. +* Statements:: Describes the various control statements in + detail. +* Built-in Variables:: Summarizes the built-in variables. + + +File: gawk.info, Node: Pattern Overview, Next: Using Shell Variables, Up: Patterns and Actions + +7.1 Pattern Elements +==================== + +* Menu: + +* Regexp Patterns:: Using regexps as patterns. +* Expression Patterns:: Any expression can be used as a pattern. +* Ranges:: Pairs of patterns specify record ranges. +* BEGIN/END:: Specifying initialization and cleanup rules. +* BEGINFILE/ENDFILE:: Two special patterns for advanced control. +* Empty:: The empty pattern, which matches every record. + + Patterns in `awk' control the execution of rules--a rule is executed +when its pattern matches the current input record. The following is a +summary of the types of `awk' patterns: + +`/REGULAR EXPRESSION/' + A regular expression. It matches when the text of the input record + fits the regular expression. (*Note Regexp::.) + +`EXPRESSION' + A single expression. It matches when its value is nonzero (if a + number) or non-null (if a string). (*Note Expression Patterns::.) + +`PAT1, PAT2' + A pair of patterns separated by a comma, specifying a range of + records. The range includes both the initial record that matches + PAT1 and the final record that matches PAT2. (*Note Ranges::.) + +`BEGIN' +`END' + Special patterns for you to supply startup or cleanup actions for + your `awk' program. (*Note BEGIN/END::.) + +`BEGINFILE' +`ENDFILE' + Special patterns for you to supply startup or cleanup actions to be + done on a per file basis. (*Note BEGINFILE/ENDFILE::.) + +`EMPTY' + The empty pattern matches every input record. (*Note Empty::.) + + +File: gawk.info, Node: Regexp Patterns, Next: Expression Patterns, Up: Pattern Overview + +7.1.1 Regular Expressions as Patterns +------------------------------------- + +Regular expressions are one of the first kinds of patterns presented in +this book. This kind of pattern is simply a regexp constant in the +pattern part of a rule. Its meaning is `$0 ~ /PATTERN/'. The pattern +matches when the input record matches the regexp. For example: + + /foo|bar|baz/ { buzzwords++ } + END { print buzzwords, "buzzwords seen" } + + +File: gawk.info, Node: Expression Patterns, Next: Ranges, Prev: Regexp Patterns, Up: Pattern Overview + +7.1.2 Expressions as Patterns +----------------------------- + +Any `awk' expression is valid as an `awk' pattern. The pattern matches +if the expression's value is nonzero (if a number) or non-null (if a +string). The expression is reevaluated each time the rule is tested +against a new input record. If the expression uses fields such as +`$1', the value depends directly on the new input record's text; +otherwise, it depends on only what has happened so far in the execution +of the `awk' program. + + Comparison expressions, using the comparison operators described in +*note Typing and Comparison::, are a very common kind of pattern. +Regexp matching and nonmatching are also very common expressions. The +left operand of the `~' and `!~' operators is a string. The right +operand is either a constant regular expression enclosed in slashes +(`/REGEXP/'), or any expression whose string value is used as a dynamic +regular expression (*note Computed Regexps::). The following example +prints the second field of each input record whose first field is +precisely `foo': + + $ awk '$1 == "foo" { print $2 }' BBS-list + +(There is no output, because there is no BBS site with the exact name +`foo'.) Contrast this with the following regular expression match, +which accepts any record with a first field that contains `foo': + + $ awk '$1 ~ /foo/ { print $2 }' BBS-list + -| 555-1234 + -| 555-6699 + -| 555-6480 + -| 555-2127 + + A regexp constant as a pattern is also a special case of an +expression pattern. The expression `/foo/' has the value one if `foo' +appears in the current input record. Thus, as a pattern, `/foo/' +matches any record containing `foo'. + + Boolean expressions are also commonly used as patterns. Whether the +pattern matches an input record depends on whether its subexpressions +match. For example, the following command prints all the records in +`BBS-list' that contain both `2400' and `foo': + + $ awk '/2400/ && /foo/' BBS-list + -| fooey 555-1234 2400/1200/300 B + + The following command prints all records in `BBS-list' that contain +_either_ `2400' or `foo' (or both, of course): + + $ awk '/2400/ || /foo/' BBS-list + -| alpo-net 555-3412 2400/1200/300 A + -| bites 555-1675 2400/1200/300 A + -| fooey 555-1234 2400/1200/300 B + -| foot 555-6699 1200/300 B + -| macfoo 555-6480 1200/300 A + -| sdace 555-3430 2400/1200/300 A + -| sabafoo 555-2127 1200/300 C + + The following command prints all records in `BBS-list' that do _not_ +contain the string `foo': + + $ awk '! /foo/' BBS-list + -| aardvark 555-5553 1200/300 B + -| alpo-net 555-3412 2400/1200/300 A + -| barfly 555-7685 1200/300 A + -| bites 555-1675 2400/1200/300 A + -| camelot 555-0542 300 C + -| core 555-2912 1200/300 C + -| sdace 555-3430 2400/1200/300 A + + The subexpressions of a Boolean operator in a pattern can be +constant regular expressions, comparisons, or any other `awk' +expressions. Range patterns are not expressions, so they cannot appear +inside Boolean patterns. Likewise, the special patterns `BEGIN', `END', +`BEGINFILE' and `ENDFILE', which never match any input record, are not +expressions and cannot appear inside Boolean patterns. + + The precedence of the different operators which can appear in +patterns is described in *note Precedence::. + + +File: gawk.info, Node: Ranges, Next: BEGIN/END, Prev: Expression Patterns, Up: Pattern Overview + +7.1.3 Specifying Record Ranges with Patterns +-------------------------------------------- + +A "range pattern" is made of two patterns separated by a comma, in the +form `BEGPAT, ENDPAT'. It is used to match ranges of consecutive input +records. The first pattern, BEGPAT, controls where the range begins, +while ENDPAT controls where the pattern ends. For example, the +following: + + awk '$1 == "on", $1 == "off"' myfile + +prints every record in `myfile' between `on'/`off' pairs, inclusive. + + A range pattern starts out by matching BEGPAT against every input +record. When a record matches BEGPAT, the range pattern is "turned on" +and the range pattern matches this record as well. As long as the +range pattern stays turned on, it automatically matches every input +record read. The range pattern also matches ENDPAT against every input +record; when this succeeds, the range pattern is turned off again for +the following record. Then the range pattern goes back to checking +BEGPAT against each record. + + The record that turns on the range pattern and the one that turns it +off both match the range pattern. If you don't want to operate on +these records, you can write `if' statements in the rule's action to +distinguish them from the records you are interested in. + + It is possible for a pattern to be turned on and off by the same +record. If the record satisfies both conditions, then the action is +executed for just that record. For example, suppose there is text +between two identical markers (e.g., the `%' symbol), each on its own +line, that should be ignored. A first attempt would be to combine a +range pattern that describes the delimited text with the `next' +statement (not discussed yet, *note Next Statement::). This causes +`awk' to skip any further processing of the current record and start +over again with the next input record. Such a program looks like this: + + /^%$/,/^%$/ { next } + { print } + +This program fails because the range pattern is both turned on and +turned off by the first line, which just has a `%' on it. To +accomplish this task, write the program in the following manner, using +a flag: + + /^%$/ { skip = ! skip; next } + skip == 1 { next } # skip lines with `skip' set + + In a range pattern, the comma (`,') has the lowest precedence of all +the operators (i.e., it is evaluated last). Thus, the following +program attempts to combine a range pattern with another, simpler test: + + echo Yes | awk '/1/,/2/ || /Yes/' + + The intent of this program is `(/1/,/2/) || /Yes/'. However, `awk' +interprets this as `/1/, (/2/ || /Yes/)'. This cannot be changed or +worked around; range patterns do not combine with other patterns: + + $ echo Yes | gawk '(/1/,/2/) || /Yes/' + error--> gawk: cmd. line:1: (/1/,/2/) || /Yes/ + error--> gawk: cmd. line:1: ^ syntax error + + +File: gawk.info, Node: BEGIN/END, Next: BEGINFILE/ENDFILE, Prev: Ranges, Up: Pattern Overview + +7.1.4 The `BEGIN' and `END' Special Patterns +-------------------------------------------- + +All the patterns described so far are for matching input records. The +`BEGIN' and `END' special patterns are different. They supply startup +and cleanup actions for `awk' programs. `BEGIN' and `END' rules must +have actions; there is no default action for these rules because there +is no current record when they run. `BEGIN' and `END' rules are often +referred to as "`BEGIN' and `END' blocks" by long-time `awk' +programmers. + +* Menu: + +* Using BEGIN/END:: How and why to use BEGIN/END rules. +* I/O And BEGIN/END:: I/O issues in BEGIN/END rules. + + +File: gawk.info, Node: Using BEGIN/END, Next: I/O And BEGIN/END, Up: BEGIN/END + +7.1.4.1 Startup and Cleanup Actions +................................... + +A `BEGIN' rule is executed once only, before the first input record is +read. Likewise, an `END' rule is executed once only, after all the +input is read. For example: + + $ awk ' + > BEGIN { print "Analysis of \"foo\"" } + > /foo/ { ++n } + > END { print "\"foo\" appears", n, "times." }' BBS-list + -| Analysis of "foo" + -| "foo" appears 4 times. + + This program finds the number of records in the input file `BBS-list' +that contain the string `foo'. The `BEGIN' rule prints a title for the +report. There is no need to use the `BEGIN' rule to initialize the +counter `n' to zero, since `awk' does this automatically (*note +Variables::). The second rule increments the variable `n' every time a +record containing the pattern `foo' is read. The `END' rule prints the +value of `n' at the end of the run. + + The special patterns `BEGIN' and `END' cannot be used in ranges or +with Boolean operators (indeed, they cannot be used with any operators). +An `awk' program may have multiple `BEGIN' and/or `END' rules. They +are executed in the order in which they appear: all the `BEGIN' rules +at startup and all the `END' rules at termination. `BEGIN' and `END' +rules may be intermixed with other rules. This feature was added in +the 1987 version of `awk' and is included in the POSIX standard. The +original (1978) version of `awk' required the `BEGIN' rule to be placed +at the beginning of the program, the `END' rule to be placed at the +end, and only allowed one of each. This is no longer required, but it +is a good idea to follow this template in terms of program organization +and readability. + + Multiple `BEGIN' and `END' rules are useful for writing library +functions, because each library file can have its own `BEGIN' and/or +`END' rule to do its own initialization and/or cleanup. The order in +which library functions are named on the command line controls the +order in which their `BEGIN' and `END' rules are executed. Therefore, +you have to be careful when writing such rules in library files so that +the order in which they are executed doesn't matter. *Note Options::, +for more information on using library functions. *Note Library +Functions::, for a number of useful library functions. + + If an `awk' program has only `BEGIN' rules and no other rules, then +the program exits after the `BEGIN' rule is run.(1) However, if an +`END' rule exists, then the input is read, even if there are no other +rules in the program. This is necessary in case the `END' rule checks +the `FNR' and `NR' variables. + + ---------- Footnotes ---------- + + (1) The original version of `awk' kept reading and ignoring input +until the end of the file was seen. + + +File: gawk.info, Node: I/O And BEGIN/END, Prev: Using BEGIN/END, Up: BEGIN/END + +7.1.4.2 Input/Output from `BEGIN' and `END' Rules +................................................. + +There are several (sometimes subtle) points to remember when doing I/O +from a `BEGIN' or `END' rule. The first has to do with the value of +`$0' in a `BEGIN' rule. Because `BEGIN' rules are executed before any +input is read, there simply is no input record, and therefore no +fields, when executing `BEGIN' rules. References to `$0' and the fields +yield a null string or zero, depending upon the context. One way to +give `$0' a real value is to execute a `getline' command without a +variable (*note Getline::). Another way is simply to assign a value to +`$0'. + + The second point is similar to the first but from the other +direction. Traditionally, due largely to implementation issues, `$0' +and `NF' were _undefined_ inside an `END' rule. The POSIX standard +specifies that `NF' is available in an `END' rule. It contains the +number of fields from the last input record. Most probably due to an +oversight, the standard does not say that `$0' is also preserved, +although logically one would think that it should be. In fact, `gawk' +does preserve the value of `$0' for use in `END' rules. Be aware, +however, that Brian Kernighan's `awk', and possibly other +implementations, do not. + + The third point follows from the first two. The meaning of `print' +inside a `BEGIN' or `END' rule is the same as always: `print $0'. If +`$0' is the null string, then this prints an empty record. Many long +time `awk' programmers use an unadorned `print' in `BEGIN' and `END' +rules, to mean `print ""', relying on `$0' being null. Although one +might generally get away with this in `BEGIN' rules, it is a very bad +idea in `END' rules, at least in `gawk'. It is also poor style, since +if an empty line is needed in the output, the program should print one +explicitly. + + Finally, the `next' and `nextfile' statements are not allowed in a +`BEGIN' rule, because the implicit +read-a-record-and-match-against-the-rules loop has not started yet. +Similarly, those statements are not valid in an `END' rule, since all +the input has been read. (*Note Next Statement::, and see *note +Nextfile Statement::.) + + +File: gawk.info, Node: BEGINFILE/ENDFILE, Next: Empty, Prev: BEGIN/END, Up: Pattern Overview + +7.1.5 The `BEGINFILE' and `ENDFILE' Special Patterns +---------------------------------------------------- + +This minor node describes a `gawk'-specific feature. + + Two special kinds of rule, `BEGINFILE' and `ENDFILE', give you +"hooks" into `gawk''s command-line file processing loop. As with the +`BEGIN' and `END' rules (*note BEGIN/END::), all `BEGINFILE' rules in a +program are merged, in the order they are read by `gawk', and all +`ENDFILE' rules are merged as well. + + The body of the `BEGINFILE' rules is executed just before `gawk' +reads the first record from a file. `FILENAME' is set to the name of +the current file, and `FNR' is set to zero. + + The `BEGINFILE' rule provides you the opportunity for two tasks that +would otherwise be difficult or impossible to perform: + + * You can test if the file is readable. Normally, it is a fatal + error if a file named on the command line cannot be opened for + reading. However, you can bypass the fatal error and move on to + the next file on the command line. + + You do this by checking if the `ERRNO' variable is not the empty + string; if so, then `gawk' was not able to open the file. In this + case, your program can execute the `nextfile' statement (*note + Nextfile Statement::). This causes `gawk' to skip the file + entirely. Otherwise, `gawk' exits with the usual fatal error. + + * If you have written extensions that modify the record handling (by + inserting an "open hook"), you can invoke them at this point, + before `gawk' has started processing the file. (This is a _very_ + advanced feature, currently used only by the XMLgawk project + (http://xmlgawk.sourceforge.net).) + + The `ENDFILE' rule is called when `gawk' has finished processing the +last record in an input file. For the last input file, it will be +called before any `END' rules. The `ENDFILE' rule is executed even for +empty input files. + + Normally, when an error occurs when reading input in the normal input +processing loop, the error is fatal. However, if an `ENDFILE' rule is +present, the error becomes non-fatal, and instead `ERRNO' is set. This +makes it possible to catch and process I/O errors at the level of the +`awk' program. + + The `next' statement (*note Next Statement::) is not allowed inside +either a `BEGINFILE' or and `ENDFILE' rule. The `nextfile' statement +(*note Nextfile Statement::) is allowed only inside a `BEGINFILE' rule, +but not inside an `ENDFILE' rule. + + The `getline' statement (*note Getline::) is restricted inside both +`BEGINFILE' and `ENDFILE'. Only the `getline VARIABLE < FILE' form is +allowed. + + `BEGINFILE' and `ENDFILE' are `gawk' extensions. In most other +`awk' implementations, or if `gawk' is in compatibility mode (*note +Options::), they are not special. + + +File: gawk.info, Node: Empty, Prev: BEGINFILE/ENDFILE, Up: Pattern Overview + +7.1.6 The Empty Pattern +----------------------- + +An empty (i.e., nonexistent) pattern is considered to match _every_ +input record. For example, the program: + + awk '{ print $1 }' BBS-list + +prints the first field of every record. + + +File: gawk.info, Node: Using Shell Variables, Next: Action Overview, Prev: Pattern Overview, Up: Patterns and Actions + +7.2 Using Shell Variables in Programs +===================================== + +`awk' programs are often used as components in larger programs written +in shell. For example, it is very common to use a shell variable to +hold a pattern that the `awk' program searches for. There are two ways +to get the value of the shell variable into the body of the `awk' +program. + + The most common method is to use shell quoting to substitute the +variable's value into the program inside the script. For example, in +the following program: + + printf "Enter search pattern: " + read pattern + awk "/$pattern/ "'{ nmatches++ } + END { print nmatches, "found" }' /path/to/data + +the `awk' program consists of two pieces of quoted text that are +concatenated together to form the program. The first part is +double-quoted, which allows substitution of the `pattern' shell +variable inside the quotes. The second part is single-quoted. + + Variable substitution via quoting works, but can be potentially +messy. It requires a good understanding of the shell's quoting rules +(*note Quoting::), and it's often difficult to correctly match up the +quotes when reading the program. + + A better method is to use `awk''s variable assignment feature (*note +Assignment Options::) to assign the shell variable's value to an `awk' +variable's value. Then use dynamic regexps to match the pattern (*note +Computed Regexps::). The following shows how to redo the previous +example using this technique: + + printf "Enter search pattern: " + read pattern + awk -v pat="$pattern" '$0 ~ pat { nmatches++ } + END { print nmatches, "found" }' /path/to/data + +Now, the `awk' program is just one single-quoted string. The +assignment `-v pat="$pattern"' still requires double quotes, in case +there is whitespace in the value of `$pattern'. The `awk' variable +`pat' could be named `pattern' too, but that would be more confusing. +Using a variable also provides more flexibility, since the variable can +be used anywhere inside the program--for printing, as an array +subscript, or for any other use--without requiring the quoting tricks +at every point in the program. + + +File: gawk.info, Node: Action Overview, Next: Statements, Prev: Using Shell Variables, Up: Patterns and Actions + +7.3 Actions +=========== + +An `awk' program or script consists of a series of rules and function +definitions interspersed. (Functions are described later. *Note +User-defined::.) A rule contains a pattern and an action, either of +which (but not both) may be omitted. The purpose of the "action" is to +tell `awk' what to do once a match for the pattern is found. Thus, in +outline, an `awk' program generally looks like this: + + [PATTERN] { ACTION } + PATTERN [{ ACTION }] + ... + function NAME(ARGS) { ... } + ... + + An action consists of one or more `awk' "statements", enclosed in +curly braces (`{...}'). Each statement specifies one thing to do. The +statements are separated by newlines or semicolons. The curly braces +around an action must be used even if the action contains only one +statement, or if it contains no statements at all. However, if you +omit the action entirely, omit the curly braces as well. An omitted +action is equivalent to `{ print $0 }': + + /foo/ { } match `foo', do nothing -- empty action + /foo/ match `foo', print the record -- omitted action + + The following types of statements are supported in `awk': + +Expressions + Call functions or assign values to variables (*note + Expressions::). Executing this kind of statement simply computes + the value of the expression. This is useful when the expression + has side effects (*note Assignment Ops::). + +Control statements + Specify the control flow of `awk' programs. The `awk' language + gives you C-like constructs (`if', `for', `while', and `do') as + well as a few special ones (*note Statements::). + +Compound statements + Consist of one or more statements enclosed in curly braces. A + compound statement is used in order to put several statements + together in the body of an `if', `while', `do', or `for' statement. + +Input statements + Use the `getline' command (*note Getline::). Also supplied in + `awk' are the `next' statement (*note Next Statement::), and the + `nextfile' statement (*note Nextfile Statement::). + +Output statements + Such as `print' and `printf'. *Note Printing::. + +Deletion statements + For deleting array elements. *Note Delete::. + + +File: gawk.info, Node: Statements, Next: Built-in Variables, Prev: Action Overview, Up: Patterns and Actions + +7.4 Control Statements in Actions +================================= + +"Control statements", such as `if', `while', and so on, control the +flow of execution in `awk' programs. Most of `awk''s control +statements are patterned after similar statements in C. + + All the control statements start with special keywords, such as `if' +and `while', to distinguish them from simple expressions. Many control +statements contain other statements. For example, the `if' statement +contains another statement that may or may not be executed. The +contained statement is called the "body". To include more than one +statement in the body, group them into a single "compound statement" +with curly braces, separating them with newlines or semicolons. + +* Menu: + +* If Statement:: Conditionally execute some `awk' + statements. +* While Statement:: Loop until some condition is satisfied. +* Do Statement:: Do specified action while looping until some + condition is satisfied. +* For Statement:: Another looping statement, that provides + initialization and increment clauses. +* Switch Statement:: Switch/case evaluation for conditional + execution of statements based on a value. +* Break Statement:: Immediately exit the innermost enclosing loop. +* Continue Statement:: Skip to the end of the innermost enclosing + loop. +* Next Statement:: Stop processing the current input record. +* Nextfile Statement:: Stop processing the current file. +* Exit Statement:: Stop execution of `awk'. + + +File: gawk.info, Node: If Statement, Next: While Statement, Up: Statements + +7.4.1 The `if'-`else' Statement +------------------------------- + +The `if'-`else' statement is `awk''s decision-making statement. It +looks like this: + + if (CONDITION) THEN-BODY [else ELSE-BODY] + +The CONDITION is an expression that controls what the rest of the +statement does. If the CONDITION is true, THEN-BODY is executed; +otherwise, ELSE-BODY is executed. The `else' part of the statement is +optional. The condition is considered false if its value is zero or +the null string; otherwise, the condition is true. Refer to the +following: + + if (x % 2 == 0) + print "x is even" + else + print "x is odd" + + In this example, if the expression `x % 2 == 0' is true (that is, if +the value of `x' is evenly divisible by two), then the first `print' +statement is executed; otherwise, the second `print' statement is +executed. If the `else' keyword appears on the same line as THEN-BODY +and THEN-BODY is not a compound statement (i.e., not surrounded by +curly braces), then a semicolon must separate THEN-BODY from the `else'. +To illustrate this, the previous example can be rewritten as: + + if (x % 2 == 0) print "x is even"; else + print "x is odd" + +If the `;' is left out, `awk' can't interpret the statement and it +produces a syntax error. Don't actually write programs this way, +because a human reader might fail to see the `else' if it is not the +first thing on its line. + + +File: gawk.info, Node: While Statement, Next: Do Statement, Prev: If Statement, Up: Statements + +7.4.2 The `while' Statement +--------------------------- + +In programming, a "loop" is a part of a program that can be executed +two or more times in succession. The `while' statement is the simplest +looping statement in `awk'. It repeatedly executes a statement as long +as a condition is true. For example: + + while (CONDITION) + BODY + +BODY is a statement called the "body" of the loop, and CONDITION is an +expression that controls how long the loop keeps running. The first +thing the `while' statement does is test the CONDITION. If the +CONDITION is true, it executes the statement BODY. (The CONDITION is +true when the value is not zero and not a null string.) After BODY has +been executed, CONDITION is tested again, and if it is still true, BODY +is executed again. This process repeats until the CONDITION is no +longer true. If the CONDITION is initially false, the body of the loop +is never executed and `awk' continues with the statement following the +loop. This example prints the first three fields of each record, one +per line: + + awk '{ + i = 1 + while (i <= 3) { + print $i + i++ + } + }' inventory-shipped + +The body of this loop is a compound statement enclosed in braces, +containing two statements. The loop works in the following manner: +first, the value of `i' is set to one. Then, the `while' statement +tests whether `i' is less than or equal to three. This is true when +`i' equals one, so the `i'-th field is printed. Then the `i++' +increments the value of `i' and the loop repeats. The loop terminates +when `i' reaches four. + + A newline is not required between the condition and the body; +however using one makes the program clearer unless the body is a +compound statement or else is very simple. The newline after the +open-brace that begins the compound statement is not required either, +but the program is harder to read without it. + + +File: gawk.info, Node: Do Statement, Next: For Statement, Prev: While Statement, Up: Statements + +7.4.3 The `do'-`while' Statement +-------------------------------- + +The `do' loop is a variation of the `while' looping statement. The +`do' loop executes the BODY once and then repeats the BODY as long as +the CONDITION is true. It looks like this: + + do + BODY + while (CONDITION) + + Even if the CONDITION is false at the start, the BODY is executed at +least once (and only once, unless executing BODY makes CONDITION true). +Contrast this with the corresponding `while' statement: + + while (CONDITION) + BODY + +This statement does not execute BODY even once if the CONDITION is +false to begin with. The following is an example of a `do' statement: + + { + i = 1 + do { + print $0 + i++ + } while (i <= 10) + } + +This program prints each input record 10 times. However, it isn't a +very realistic example, since in this case an ordinary `while' would do +just as well. This situation reflects actual experience; only +occasionally is there a real use for a `do' statement. + + +File: gawk.info, Node: For Statement, Next: Switch Statement, Prev: Do Statement, Up: Statements + +7.4.4 The `for' Statement +------------------------- + +The `for' statement makes it more convenient to count iterations of a +loop. The general form of the `for' statement looks like this: + + for (INITIALIZATION; CONDITION; INCREMENT) + BODY + +The INITIALIZATION, CONDITION, and INCREMENT parts are arbitrary `awk' +expressions, and BODY stands for any `awk' statement. + + The `for' statement starts by executing INITIALIZATION. Then, as +long as the CONDITION is true, it repeatedly executes BODY and then +INCREMENT. Typically, INITIALIZATION sets a variable to either zero or +one, INCREMENT adds one to it, and CONDITION compares it against the +desired number of iterations. For example: + + awk '{ + for (i = 1; i <= 3; i++) + print $i + }' inventory-shipped + +This prints the first three fields of each input record, with one field +per line. + + It isn't possible to set more than one variable in the +INITIALIZATION part without using a multiple assignment statement such +as `x = y = 0'. This makes sense only if all the initial values are +equal. (But it is possible to initialize additional variables by +writing their assignments as separate statements preceding the `for' +loop.) + + The same is true of the INCREMENT part. Incrementing additional +variables requires separate statements at the end of the loop. The C +compound expression, using C's comma operator, is useful in this +context but it is not supported in `awk'. + + Most often, INCREMENT is an increment expression, as in the previous +example. But this is not required; it can be any expression +whatsoever. For example, the following statement prints all the powers +of two between 1 and 100: + + for (i = 1; i <= 100; i *= 2) + print i + + If there is nothing to be done, any of the three expressions in the +parentheses following the `for' keyword may be omitted. Thus, +`for (; x > 0;)' is equivalent to `while (x > 0)'. If the CONDITION is +omitted, it is treated as true, effectively yielding an "infinite loop" +(i.e., a loop that never terminates). + + In most cases, a `for' loop is an abbreviation for a `while' loop, +as shown here: + + INITIALIZATION + while (CONDITION) { + BODY + INCREMENT + } + +The only exception is when the `continue' statement (*note Continue +Statement::) is used inside the loop. Changing a `for' statement to a +`while' statement in this way can change the effect of the `continue' +statement inside the loop. + + The `awk' language has a `for' statement in addition to a `while' +statement because a `for' loop is often both less work to type and more +natural to think of. Counting the number of iterations is very common +in loops. It can be easier to think of this counting as part of +looping rather than as something to do inside the loop. + + There is an alternate version of the `for' loop, for iterating over +all the indices of an array: + + for (i in array) + DO SOMETHING WITH array[i] + +*Note Scanning an Array::, for more information on this version of the +`for' loop. + + +File: gawk.info, Node: Switch Statement, Next: Break Statement, Prev: For Statement, Up: Statements + +7.4.5 The `switch' Statement +---------------------------- + +The `switch' statement allows the evaluation of an expression and the +execution of statements based on a `case' match. Case statements are +checked for a match in the order they are defined. If no suitable +`case' is found, the `default' section is executed, if supplied. + + Each `case' contains a single constant, be it numeric, string, or +regexp. The `switch' expression is evaluated, and then each `case''s +constant is compared against the result in turn. The type of constant +determines the comparison: numeric or string do the usual comparisons. +A regexp constant does a regular expression match against the string +value of the original expression. The general form of the `switch' +statement looks like this: + + switch (EXPRESSION) { + case VALUE OR REGULAR EXPRESSION: + CASE-BODY + default: + DEFAULT-BODY + } + + Control flow in the `switch' statement works as it does in C. Once a +match to a given case is made, the case statement bodies execute until +a `break', `continue', `next', `nextfile' or `exit' is encountered, or +the end of the `switch' statement itself. For example: + + switch (NR * 2 + 1) { + case 3: + case "11": + print NR - 1 + break + + case /2[[:digit:]]+/: + print NR + + default: + print NR + 1 + + case -1: + print NR * -1 + } + + Note that if none of the statements specified above halt execution +of a matched `case' statement, execution falls through to the next +`case' until execution halts. In the above example, for any case value +starting with `2' followed by one or more digits, the `print' statement +is executed and then falls through into the `default' section, +executing its `print' statement. In turn, the -1 case will also be +executed since the `default' does not halt execution. + + This `switch' statement is a `gawk' extension. If `gawk' is in +compatibility mode (*note Options::), it is not available. + + +File: gawk.info, Node: Break Statement, Next: Continue Statement, Prev: Switch Statement, Up: Statements + +7.4.6 The `break' Statement +--------------------------- + +The `break' statement jumps out of the innermost `for', `while', or +`do' loop that encloses it. The following example finds the smallest +divisor of any integer, and also identifies prime numbers: + + # find smallest divisor of num + { + num = $1 + for (div = 2; div * div <= num; div++) { + if (num % div == 0) + break + } + if (num % div == 0) + printf "Smallest divisor of %d is %d\n", num, div + else + printf "%d is prime\n", num + } + + When the remainder is zero in the first `if' statement, `awk' +immediately "breaks out" of the containing `for' loop. This means that +`awk' proceeds immediately to the statement following the loop and +continues processing. (This is very different from the `exit' +statement, which stops the entire `awk' program. *Note Exit +Statement::.) + + The following program illustrates how the CONDITION of a `for' or +`while' statement could be replaced with a `break' inside an `if': + + # find smallest divisor of num + { + num = $1 + for (div = 2; ; div++) { + if (num % div == 0) { + printf "Smallest divisor of %d is %d\n", num, div + break + } + if (div * div > num) { + printf "%d is prime\n", num + break + } + } + } + + The `break' statement is also used to break out of the `switch' +statement. This is discussed in *note Switch Statement::. + + The `break' statement has no meaning when used outside the body of a +loop or `switch'. However, although it was never documented, +historical implementations of `awk' treated the `break' statement +outside of a loop as if it were a `next' statement (*note Next +Statement::). (d.c.) Recent versions of Brian Kernighan's `awk' no +longer allow this usage, nor does `gawk'. + + +File: gawk.info, Node: Continue Statement, Next: Next Statement, Prev: Break Statement, Up: Statements + +7.4.7 The `continue' Statement +------------------------------ + +Similar to `break', the `continue' statement is used only inside `for', +`while', and `do' loops. It skips over the rest of the loop body, +causing the next cycle around the loop to begin immediately. Contrast +this with `break', which jumps out of the loop altogether. + + The `continue' statement in a `for' loop directs `awk' to skip the +rest of the body of the loop and resume execution with the +increment-expression of the `for' statement. The following program +illustrates this fact: + + BEGIN { + for (x = 0; x <= 20; x++) { + if (x == 5) + continue + printf "%d ", x + } + print "" + } + +This program prints all the numbers from 0 to 20--except for 5, for +which the `printf' is skipped. Because the increment `x++' is not +skipped, `x' does not remain stuck at 5. Contrast the `for' loop from +the previous example with the following `while' loop: + + BEGIN { + x = 0 + while (x <= 20) { + if (x == 5) + continue + printf "%d ", x + x++ + } + print "" + } + +This program loops forever once `x' reaches 5. + + The `continue' statement has no special meaning with respect to the +`switch' statement, nor does it have any meaning when used outside the +body of a loop. Historical versions of `awk' treated a `continue' +statement outside a loop the same way they treated a `break' statement +outside a loop: as if it were a `next' statement (*note Next +Statement::). (d.c.) Recent versions of Brian Kernighan's `awk' no +longer work this way, nor does `gawk'. + + +File: gawk.info, Node: Next Statement, Next: Nextfile Statement, Prev: Continue Statement, Up: Statements + +7.4.8 The `next' Statement +-------------------------- + +The `next' statement forces `awk' to immediately stop processing the +current record and go on to the next record. This means that no +further rules are executed for the current record, and the rest of the +current rule's action isn't executed. + + Contrast this with the effect of the `getline' function (*note +Getline::). That also causes `awk' to read the next record +immediately, but it does not alter the flow of control in any way +(i.e., the rest of the current action executes with a new input record). + + At the highest level, `awk' program execution is a loop that reads +an input record and then tests each rule's pattern against it. If you +think of this loop as a `for' statement whose body contains the rules, +then the `next' statement is analogous to a `continue' statement. It +skips to the end of the body of this implicit loop and executes the +increment (which reads another record). + + For example, suppose an `awk' program works only on records with +four fields, and it shouldn't fail when given bad input. To avoid +complicating the rest of the program, write a "weed out" rule near the +beginning, in the following manner: + + NF != 4 { + err = sprintf("%s:%d: skipped: NF != 4\n", FILENAME, FNR) + print err > "/dev/stderr" + next + } + +Because of the `next' statement, the program's subsequent rules won't +see the bad record. The error message is redirected to the standard +error output stream, as error messages should be. For more detail see +*note Special Files::. + + If the `next' statement causes the end of the input to be reached, +then the code in any `END' rules is executed. *Note BEGIN/END::. + + The `next' statement is not allowed inside `BEGINFILE' and `ENDFILE' +rules. *Note BEGINFILE/ENDFILE::. + + According to the POSIX standard, the behavior is undefined if the +`next' statement is used in a `BEGIN' or `END' rule. `gawk' treats it +as a syntax error. Although POSIX permits it, some other `awk' +implementations don't allow the `next' statement inside function bodies +(*note User-defined::). Just as with any other `next' statement, a +`next' statement inside a function body reads the next record and +starts processing it with the first rule in the program. + + +File: gawk.info, Node: Nextfile Statement, Next: Exit Statement, Prev: Next Statement, Up: Statements + +7.4.9 Using `gawk''s `nextfile' Statement +----------------------------------------- + +`gawk' provides the `nextfile' statement, which is similar to the +`next' statement. (c.e.) However, instead of abandoning processing of +the current record, the `nextfile' statement instructs `gawk' to stop +processing the current data file. + + The `nextfile' statement is a `gawk' extension. In most other `awk' +implementations, or if `gawk' is in compatibility mode (*note +Options::), `nextfile' is not special. + + Upon execution of the `nextfile' statement, any `ENDFILE' rules are +executed except in the case as mentioned below, `FILENAME' is updated +to the name of the next data file listed on the command line, `FNR' is +reset to one, `ARGIND' is incremented, any `BEGINFILE' rules are +executed, and processing starts over with the first rule in the program. +(`ARGIND' hasn't been introduced yet. *Note Built-in Variables::.) If +the `nextfile' statement causes the end of the input to be reached, +then the code in any `END' rules is executed. An exception to this is +when the `nextfile' is invoked during execution of any statement in an +`END' rule; In this case, it causes the program to stop immediately. +*Note BEGIN/END::. + + The `nextfile' statement is useful when there are many data files to +process but it isn't necessary to process every record in every file. +Normally, in order to move on to the next data file, a program has to +continue scanning the unwanted records. The `nextfile' statement +accomplishes this much more efficiently. + + In addition, `nextfile' is useful inside a `BEGINFILE' rule to skip +over a file that would otherwise cause `gawk' to exit with a fatal +error. In this case, `ENDFILE' rules are not executed. *Note +BEGINFILE/ENDFILE::. + + While one might think that `close(FILENAME)' would accomplish the +same as `nextfile', this isn't true. `close()' is reserved for closing +files, pipes, and coprocesses that are opened with redirections. It is +not related to the main processing that `awk' does with the files +listed in `ARGV'. + + The current version of the Brian Kernighan's `awk' (*note Other +Versions::) also supports `nextfile'. However, it doesn't allow the +`nextfile' statement inside function bodies (*note User-defined::). +`gawk' does; a `nextfile' inside a function body reads the next record +and starts processing it with the first rule in the program, just as +any other `nextfile' statement. + + +File: gawk.info, Node: Exit Statement, Prev: Nextfile Statement, Up: Statements + +7.4.10 The `exit' Statement +--------------------------- + +The `exit' statement causes `awk' to immediately stop executing the +current rule and to stop processing input; any remaining input is +ignored. The `exit' statement is written as follows: + + exit [RETURN CODE] + + When an `exit' statement is executed from a `BEGIN' rule, the +program stops processing everything immediately. No input records are +read. However, if an `END' rule is present, as part of executing the +`exit' statement, the `END' rule is executed (*note BEGIN/END::). If +`exit' is used in the body of an `END' rule, it causes the program to +stop immediately. + + An `exit' statement that is not part of a `BEGIN' or `END' rule +stops the execution of any further automatic rules for the current +record, skips reading any remaining input records, and executes the +`END' rule if there is one. Any `ENDFILE' rules are also skipped; they +are not executed. + + In such a case, if you don't want the `END' rule to do its job, set +a variable to nonzero before the `exit' statement and check that +variable in the `END' rule. *Note Assert Function::, for an example +that does this. + + If an argument is supplied to `exit', its value is used as the exit +status code for the `awk' process. If no argument is supplied, `exit' +causes `awk' to return a "success" status. In the case where an +argument is supplied to a first `exit' statement, and then `exit' is +called a second time from an `END' rule with no argument, `awk' uses +the previously supplied exit value. (d.c.) *Note Exit Status::, for +more information. + + For example, suppose an error condition occurs that is difficult or +impossible to handle. Conventionally, programs report this by exiting +with a nonzero status. An `awk' program can do this using an `exit' +statement with a nonzero argument, as shown in the following example: + + BEGIN { + if (("date" | getline date_now) <= 0) { + print "Can't get system date" > "/dev/stderr" + exit 1 + } + print "current date is", date_now + close("date") + } + + NOTE: For full portability, exit values should be between zero and + 126, inclusive. Negative values, and values of 127 or greater, + may not produce consistent results across different operating + systems. + + +File: gawk.info, Node: Built-in Variables, Prev: Statements, Up: Patterns and Actions + +7.5 Built-in Variables +====================== + +Most `awk' variables are available to use for your own purposes; they +never change unless your program assigns values to them, and they never +affect anything unless your program examines them. However, a few +variables in `awk' have special built-in meanings. `awk' examines some +of these automatically, so that they enable you to tell `awk' how to do +certain things. Others are set automatically by `awk', so that they +carry information from the internal workings of `awk' to your program. + + This minor node documents all the built-in variables of `gawk', most +of which are also documented in the chapters describing their areas of +activity. + +* Menu: + +* User-modified:: Built-in variables that you change to control + `awk'. +* Auto-set:: Built-in variables where `awk' gives + you information. +* ARGC and ARGV:: Ways to use `ARGC' and `ARGV'. + + +File: gawk.info, Node: User-modified, Next: Auto-set, Up: Built-in Variables + +7.5.1 Built-in Variables That Control `awk' +------------------------------------------- + +The following is an alphabetical list of variables that you can change +to control how `awk' does certain things. The variables that are +specific to `gawk' are marked with a pound sign (`#'). + +`BINMODE #' + On non-POSIX systems, this variable specifies use of binary mode + for all I/O. Numeric values of one, two, or three specify that + input files, output files, or all files, respectively, should use + binary I/O. A numeric value less than zero is treated as zero, + and a numeric value greater than three is treated as three. + Alternatively, string values of `"r"' or `"w"' specify that input + files and output files, respectively, should use binary I/O. A + string value of `"rw"' or `"wr"' indicates that all files should + use binary I/O. Any other string value is treated the same as + `"rw"', but causes `gawk' to generate a warning message. + `BINMODE' is described in more detail in *note PC Using::. + + This variable is a `gawk' extension. In other `awk' + implementations (except `mawk', *note Other Versions::), or if + `gawk' is in compatibility mode (*note Options::), it is not + special. + +`CONVFMT' + This string controls conversion of numbers to strings (*note + Conversion::). It works by being passed, in effect, as the first + argument to the `sprintf()' function (*note String Functions::). + Its default value is `"%.6g"'. `CONVFMT' was introduced by the + POSIX standard. + +`FIELDWIDTHS #' + This is a space-separated list of columns that tells `gawk' how to + split input with fixed columnar boundaries. Assigning a value to + `FIELDWIDTHS' overrides the use of `FS' and `FPAT' for field + splitting. *Note Constant Size::, for more information. + + If `gawk' is in compatibility mode (*note Options::), then + `FIELDWIDTHS' has no special meaning, and field-splitting + operations occur based exclusively on the value of `FS'. + +`FPAT #' + This is a regular expression (as a string) that tells `gawk' to + create the fields based on text that matches the regular + expression. Assigning a value to `FPAT' overrides the use of `FS' + and `FIELDWIDTHS' for field splitting. *Note Splitting By + Content::, for more information. + + If `gawk' is in compatibility mode (*note Options::), then `FPAT' + has no special meaning, and field-splitting operations occur based + exclusively on the value of `FS'. + +`FS' + This is the input field separator (*note Field Separators::). The + value is a single-character string or a multi-character regular + expression that matches the separations between fields in an input + record. If the value is the null string (`""'), then each + character in the record becomes a separate field. (This behavior + is a `gawk' extension. POSIX `awk' does not specify the behavior + when `FS' is the null string. Nonetheless, some other versions of + `awk' also treat `""' specially.) + + The default value is `" "', a string consisting of a single space. + As a special exception, this value means that any sequence of + spaces, TABs, and/or newlines is a single separator.(1) It also + causes spaces, TABs, and newlines at the beginning and end of a + record to be ignored. + + You can set the value of `FS' on the command line using the `-F' + option: + + awk -F, 'PROGRAM' INPUT-FILES + + If `gawk' is using `FIELDWIDTHS' or `FPAT' for field splitting, + assigning a value to `FS' causes `gawk' to return to the normal, + `FS'-based field splitting. An easy way to do this is to simply + say `FS = FS', perhaps with an explanatory comment. + +`IGNORECASE #' + If `IGNORECASE' is nonzero or non-null, then all string comparisons + and all regular expression matching are case independent. Thus, + regexp matching with `~' and `!~', as well as the `gensub()', + `gsub()', `index()', `match()', `patsplit()', `split()', and + `sub()' functions, record termination with `RS', and field + splitting with `FS' and `FPAT', all ignore case when doing their + particular regexp operations. However, the value of `IGNORECASE' + does _not_ affect array subscripting and it does not affect field + splitting when using a single-character field separator. *Note + Case-sensitivity::. + + If `gawk' is in compatibility mode (*note Options::), then + `IGNORECASE' has no special meaning. Thus, string and regexp + operations are always case-sensitive. + +`LINT #' + When this variable is true (nonzero or non-null), `gawk' behaves + as if the `--lint' command-line option is in effect. (*note + Options::). With a value of `"fatal"', lint warnings become fatal + errors. With a value of `"invalid"', only warnings about things + that are actually invalid are issued. (This is not fully + implemented yet.) Any other true value prints nonfatal warnings. + Assigning a false value to `LINT' turns off the lint warnings. + + This variable is a `gawk' extension. It is not special in other + `awk' implementations. Unlike the other special variables, + changing `LINT' does affect the production of lint warnings, even + if `gawk' is in compatibility mode. Much as the `--lint' and + `--traditional' options independently control different aspects of + `gawk''s behavior, the control of lint warnings during program + execution is independent of the flavor of `awk' being executed. + +`OFMT' + This string controls conversion of numbers to strings (*note + Conversion::) for printing with the `print' statement. It works + by being passed as the first argument to the `sprintf()' function + (*note String Functions::). Its default value is `"%.6g"'. + Earlier versions of `awk' also used `OFMT' to specify the format + for converting numbers to strings in general expressions; this is + now done by `CONVFMT'. + +`OFS' + This is the output field separator (*note Output Separators::). + It is output between the fields printed by a `print' statement. + Its default value is `" "', a string consisting of a single space. + +`ORS' + This is the output record separator. It is output at the end of + every `print' statement. Its default value is `"\n"', the newline + character. (*Note Output Separators::.) + +`RS' + This is `awk''s input record separator. Its default value is a + string containing a single newline character, which means that an + input record consists of a single line of text. It can also be + the null string, in which case records are separated by runs of + blank lines. If it is a regexp, records are separated by matches + of the regexp in the input text. (*Note Records::.) + + The ability for `RS' to be a regular expression is a `gawk' + extension. In most other `awk' implementations, or if `gawk' is + in compatibility mode (*note Options::), just the first character + of `RS''s value is used. + +`SUBSEP' + This is the subscript separator. It has the default value of + `"\034"' and is used to separate the parts of the indices of a + multidimensional array. Thus, the expression `foo["A", "B"]' + really accesses `foo["A\034B"]' (*note Multi-dimensional::). + +`TEXTDOMAIN #' + This variable is used for internationalization of programs at the + `awk' level. It sets the default text domain for specially marked + string constants in the source text, as well as for the + `dcgettext()', `dcngettext()' and `bindtextdomain()' functions + (*note Internationalization::). The default value of `TEXTDOMAIN' + is `"messages"'. + + This variable is a `gawk' extension. In other `awk' + implementations, or if `gawk' is in compatibility mode (*note + Options::), it is not special. + + ---------- Footnotes ---------- + + (1) In POSIX `awk', newline does not count as whitespace. + + +File: gawk.info, Node: Auto-set, Next: ARGC and ARGV, Prev: User-modified, Up: Built-in Variables + +7.5.2 Built-in Variables That Convey Information +------------------------------------------------ + +The following is an alphabetical list of variables that `awk' sets +automatically on certain occasions in order to provide information to +your program. The variables that are specific to `gawk' are marked +with a pound sign (`#'). + +`ARGC, ARGV' + The command-line arguments available to `awk' programs are stored + in an array called `ARGV'. `ARGC' is the number of command-line + arguments present. *Note Other Arguments::. Unlike most `awk' + arrays, `ARGV' is indexed from 0 to `ARGC' - 1. In the following + example: + + $ awk 'BEGIN { + > for (i = 0; i < ARGC; i++) + > print ARGV[i] + > }' inventory-shipped BBS-list + -| awk + -| inventory-shipped + -| BBS-list + + `ARGV[0]' contains `awk', `ARGV[1]' contains `inventory-shipped', + and `ARGV[2]' contains `BBS-list'. The value of `ARGC' is three, + one more than the index of the last element in `ARGV', because the + elements are numbered from zero. + + The names `ARGC' and `ARGV', as well as the convention of indexing + the array from 0 to `ARGC' - 1, are derived from the C language's + method of accessing command-line arguments. + + The value of `ARGV[0]' can vary from system to system. Also, you + should note that the program text is _not_ included in `ARGV', nor + are any of `awk''s command-line options. *Note ARGC and ARGV::, + for information about how `awk' uses these variables. (d.c.) + +`ARGIND #' + The index in `ARGV' of the current file being processed. Every + time `gawk' opens a new data file for processing, it sets `ARGIND' + to the index in `ARGV' of the file name. When `gawk' is + processing the input files, `FILENAME == ARGV[ARGIND]' is always + true. + + This variable is useful in file processing; it allows you to tell + how far along you are in the list of data files as well as to + distinguish between successive instances of the same file name on + the command line. + + While you can change the value of `ARGIND' within your `awk' + program, `gawk' automatically sets it to a new value when the next + file is opened. + + This variable is a `gawk' extension. In other `awk' + implementations, or if `gawk' is in compatibility mode (*note + Options::), it is not special. + +`ENVIRON' + An associative array containing the values of the environment. + The array indices are the environment variable names; the elements + are the values of the particular environment variables. For + example, `ENVIRON["HOME"]' might be `/home/arnold'. Changing this + array does not affect the environment passed on to any programs + that `awk' may spawn via redirection or the `system()' function. + + Some operating systems may not have environment variables. On + such systems, the `ENVIRON' array is empty (except for + `ENVIRON["AWKPATH"]', *note AWKPATH Variable::). + +`ERRNO #' + If a system error occurs during a redirection for `getline', + during a read for `getline', or during a `close()' operation, then + `ERRNO' contains a string describing the error. + + In addition, `gawk' clears `ERRNO' before opening each + command-line input file. This enables checking if the file is + readable inside a `BEGINFILE' pattern (*note BEGINFILE/ENDFILE::). + + Otherwise, `ERRNO' works similarly to the C variable `errno'. + Except for the case just mentioned, `gawk' _never_ clears it (sets + it to zero or `""'). Thus, you should only expect its value to be + meaningful when an I/O operation returns a failure value, such as + `getline' returning -1. You are, of course, free to clear it + yourself before doing an I/O operation. + + This variable is a `gawk' extension. In other `awk' + implementations, or if `gawk' is in compatibility mode (*note + Options::), it is not special. + +`FILENAME' + The name of the file that `awk' is currently reading. When no + data files are listed on the command line, `awk' reads from the + standard input and `FILENAME' is set to `"-"'. `FILENAME' is + changed each time a new file is read (*note Reading Files::). + Inside a `BEGIN' rule, the value of `FILENAME' is `""', since + there are no input files being processed yet.(1) (d.c.) Note, + though, that using `getline' (*note Getline::) inside a `BEGIN' + rule can give `FILENAME' a value. + +`FNR' + The current record number in the current file. `FNR' is + incremented each time a new record is read (*note Records::). It + is reinitialized to zero each time a new input file is started. + +`NF' + The number of fields in the current input record. `NF' is set + each time a new record is read, when a new field is created or + when `$0' changes (*note Fields::). + + Unlike most of the variables described in this node, assigning a + value to `NF' has the potential to affect `awk''s internal + workings. In particular, assignments to `NF' can be used to + create or remove fields from the current record. *Note Changing + Fields::. + +`NR' + The number of input records `awk' has processed since the + beginning of the program's execution (*note Records::). `NR' is + incremented each time a new record is read. + +`PROCINFO #' + The elements of this array provide access to information about the + running `awk' program. The following elements (listed + alphabetically) are guaranteed to be available: + + `PROCINFO["egid"]' + The value of the `getegid()' system call. + + `PROCINFO["euid"]' + The value of the `geteuid()' system call. + + `PROCINFO["FS"]' + This is `"FS"' if field splitting with `FS' is in effect, + `"FIELDWIDTHS"' if field splitting with `FIELDWIDTHS' is in + effect, or `"FPAT"' if field matching with `FPAT' is in + effect. + + `PROCINFO["gid"]' + The value of the `getgid()' system call. + + `PROCINFO["pgrpid"]' + The process group ID of the current process. + + `PROCINFO["pid"]' + The process ID of the current process. + + `PROCINFO["ppid"]' + The parent process ID of the current process. + + `PROCINFO["sorted_in"]' + If this element exists in `PROCINFO', its value controls the + order in which array indices will be processed by `for (index + in array) ...' loops. Since this is an advanced feature, we + defer the full description until later; see *note Scanning an + Array::. + + `PROCINFO["strftime"]' + The default time format string for `strftime()'. Assigning a + new value to this element changes the default. *Note Time + Functions::. + + `PROCINFO["uid"]' + The value of the `getuid()' system call. + + `PROCINFO["version"]' + The version of `gawk'. + + On some systems, there may be elements in the array, `"group1"' + through `"groupN"' for some N. N is the number of supplementary + groups that the process has. Use the `in' operator to test for + these elements (*note Reference to Elements::). + + The `PROCINFO' array is also used to cause coprocesses to + communicate over pseudo-ttys instead of through two-way pipes; + this is discussed further in *note Two-way I/O::. + + This array is a `gawk' extension. In other `awk' implementations, + or if `gawk' is in compatibility mode (*note Options::), it is not + special. + +`RLENGTH' + The length of the substring matched by the `match()' function + (*note String Functions::). `RLENGTH' is set by invoking the + `match()' function. Its value is the length of the matched + string, or -1 if no match is found. + +`RSTART' + The start-index in characters of the substring that is matched by + the `match()' function (*note String Functions::). `RSTART' is + set by invoking the `match()' function. Its value is the position + of the string where the matched substring starts, or zero if no + match was found. + +`RT #' + This is set each time a record is read. It contains the input text + that matched the text denoted by `RS', the record separator. + + This variable is a `gawk' extension. In other `awk' + implementations, or if `gawk' is in compatibility mode (*note + Options::), it is not special. + +Advanced Notes: Changing `NR' and `FNR' +--------------------------------------- + +`awk' increments `NR' and `FNR' each time it reads a record, instead of +setting them to the absolute value of the number of records read. This +means that a program can change these variables and their new values +are incremented for each record. (d.c.) The following example shows +this: + + $ echo '1 + > 2 + > 3 + > 4' | awk 'NR == 2 { NR = 17 } + > { print NR }' + -| 1 + -| 17 + -| 18 + -| 19 + +Before `FNR' was added to the `awk' language (*note V7/SVR3.1::), many +`awk' programs used this feature to track the number of records in a +file by resetting `NR' to zero when `FILENAME' changed. + + ---------- Footnotes ---------- + + (1) Some early implementations of Unix `awk' initialized `FILENAME' +to `"-"', even if there were data files to be processed. This behavior +was incorrect and should not be relied upon in your programs. + + +File: gawk.info, Node: ARGC and ARGV, Prev: Auto-set, Up: Built-in Variables + +7.5.3 Using `ARGC' and `ARGV' +----------------------------- + +*note Auto-set::, presented the following program describing the +information contained in `ARGC' and `ARGV': + + $ awk 'BEGIN { + > for (i = 0; i < ARGC; i++) + > print ARGV[i] + > }' inventory-shipped BBS-list + -| awk + -| inventory-shipped + -| BBS-list + +In this example, `ARGV[0]' contains `awk', `ARGV[1]' contains +`inventory-shipped', and `ARGV[2]' contains `BBS-list'. Notice that +the `awk' program is not entered in `ARGV'. The other command-line +options, with their arguments, are also not entered. This includes +variable assignments done with the `-v' option (*note Options::). +Normal variable assignments on the command line _are_ treated as +arguments and do show up in the `ARGV' array. Given the following +program in a file named `showargs.awk': + + BEGIN { + printf "A=%d, B=%d\n", A, B + for (i = 0; i < ARGC; i++) + printf "\tARGV[%d] = %s\n", i, ARGV[i] + } + END { printf "A=%d, B=%d\n", A, B } + +Running it produces the following: + + $ awk -v A=1 -f showargs.awk B=2 /dev/null + -| A=1, B=0 + -| ARGV[0] = awk + -| ARGV[1] = B=2 + -| ARGV[2] = /dev/null + -| A=1, B=2 + + A program can alter `ARGC' and the elements of `ARGV'. Each time +`awk' reaches the end of an input file, it uses the next element of +`ARGV' as the name of the next input file. By storing a different +string there, a program can change which files are read. Use `"-"' to +represent the standard input. Storing additional elements and +incrementing `ARGC' causes additional files to be read. + + If the value of `ARGC' is decreased, that eliminates input files +from the end of the list. By recording the old value of `ARGC' +elsewhere, a program can treat the eliminated arguments as something +other than file names. + + To eliminate a file from the middle of the list, store the null +string (`""') into `ARGV' in place of the file's name. As a special +feature, `awk' ignores file names that have been replaced with the null +string. Another option is to use the `delete' statement to remove +elements from `ARGV' (*note Delete::). + + All of these actions are typically done in the `BEGIN' rule, before +actual processing of the input begins. *Note Split Program::, and see +*note Tee Program::, for examples of each way of removing elements from +`ARGV'. The following fragment processes `ARGV' in order to examine, +and then remove, command-line options: + + BEGIN { + for (i = 1; i < ARGC; i++) { + if (ARGV[i] == "-v") + verbose = 1 + else if (ARGV[i] == "-q") + debug = 1 + else if (ARGV[i] ~ /^-./) { + e = sprintf("%s: unrecognized option -- %c", + ARGV[0], substr(ARGV[i], 2, 1)) + print e > "/dev/stderr" + } else + break + delete ARGV[i] + } + } + + To actually get the options into the `awk' program, end the `awk' +options with `--' and then supply the `awk' program's options, in the +following manner: + + awk -f myprog -- -v -q file1 file2 ... + + This is not necessary in `gawk'. Unless `--posix' has been +specified, `gawk' silently puts any unrecognized options into `ARGV' +for the `awk' program to deal with. As soon as it sees an unknown +option, `gawk' stops looking for other options that it might otherwise +recognize. The previous example with `gawk' would be: + + gawk -f myprog -q -v file1 file2 ... + +Because `-q' is not a valid `gawk' option, it and the following `-v' +are passed on to the `awk' program. (*Note Getopt Function::, for an +`awk' library function that parses command-line options.) + + +File: gawk.info, Node: Arrays, Next: Functions, Prev: Patterns and Actions, Up: Top + +8 Arrays in `awk' +***************** + +An "array" is a table of values called "elements". The elements of an +array are distinguished by their "indices". Indices may be either +numbers or strings. + + This major node describes how arrays work in `awk', how to use array +elements, how to scan through every element in an array, and how to +remove array elements. It also describes how `awk' simulates +multidimensional arrays, as well as some of the less obvious points +about array usage. The major node moves on to discuss `gawk''s facility +for sorting arrays, and ends with a brief description of `gawk''s +ability to support true multidimensional arrays. + + `awk' maintains a single set of names that may be used for naming +variables, arrays, and functions (*note User-defined::). Thus, you +cannot have a variable and an array with the same name in the same +`awk' program. + +* Menu: + +* Array Basics:: The basics of arrays. +* Delete:: The `delete' statement removes an element + from an array. +* Numeric Array Subscripts:: How to use numbers as subscripts in + `awk'. +* Uninitialized Subscripts:: Using Uninitialized variables as subscripts. +* Multi-dimensional:: Emulating multidimensional arrays in + `awk'. +* Arrays of Arrays:: True multidimensional arrays. + + +File: gawk.info, Node: Array Basics, Next: Delete, Up: Arrays + +8.1 The Basics of Arrays +======================== + +This minor node presents the basics: working with elements in arrays +one at a time, and traversing all of the elements in an array. + +* Menu: + +* Array Intro:: Introduction to Arrays +* Reference to Elements:: How to examine one element of an array. +* Assigning Elements:: How to change an element of an array. +* Array Example:: Basic Example of an Array +* Scanning an Array:: A variation of the `for' statement. It + loops through the indices of an array's + existing elements. +* Controlling Scanning:: Controlling the order in which arrays are + scanned. + + +File: gawk.info, Node: Array Intro, Next: Reference to Elements, Up: Array Basics + +8.1.1 Introduction to Arrays +---------------------------- + + Doing linear scans over an associative array is like trying to + club someone to death with a loaded Uzi. + Larry Wall + + The `awk' language provides one-dimensional arrays for storing +groups of related strings or numbers. Every `awk' array must have a +name. Array names have the same syntax as variable names; any valid +variable name would also be a valid array name. But one name cannot be +used in both ways (as an array and as a variable) in the same `awk' +program. + + Arrays in `awk' superficially resemble arrays in other programming +languages, but there are fundamental differences. In `awk', it isn't +necessary to specify the size of an array before starting to use it. +Additionally, any number or string in `awk', not just consecutive +integers, may be used as an array index. + + In most other languages, arrays must be "declared" before use, +including a specification of how many elements or components they +contain. In such languages, the declaration causes a contiguous block +of memory to be allocated for that many elements. Usually, an index in +the array must be a positive integer. For example, the index zero +specifies the first element in the array, which is actually stored at +the beginning of the block of memory. Index one specifies the second +element, which is stored in memory right after the first element, and +so on. It is impossible to add more elements to the array, because it +has room only for as many elements as given in the declaration. (Some +languages allow arbitrary starting and ending indices--e.g., `15 .. +27'--but the size of the array is still fixed when the array is +declared.) + + A contiguous array of four elements might look like the following +example, conceptually, if the element values are 8, `"foo"', `""', and +30: + + +---------+---------+--------+---------+ + | 8 | "foo" | "" | 30 | Value + +---------+---------+--------+---------+ + 0 1 2 3 Index + +Only the values are stored; the indices are implicit from the order of +the values. Here, 8 is the value at index zero, because 8 appears in the +position with zero elements before it. + + Arrays in `awk' are different--they are "associative". This means +that each array is a collection of pairs: an index and its corresponding +array element value: + + Index 3 Value 30 + Index 1 Value "foo" + Index 0 Value 8 + Index 2 Value "" + +The pairs are shown in jumbled order because their order is irrelevant. + + One advantage of associative arrays is that new pairs can be added +at any time. For example, suppose a tenth element is added to the array +whose value is `"number ten"'. The result is: + + Index 10 Value "number ten" + Index 3 Value 30 + Index 1 Value "foo" + Index 0 Value 8 + Index 2 Value "" + +Now the array is "sparse", which just means some indices are missing. +It has elements 0-3 and 10, but doesn't have elements 4, 5, 6, 7, 8, or +9. + + Another consequence of associative arrays is that the indices don't +have to be positive integers. Any number, or even a string, can be an +index. For example, the following is an array that translates words +from English to French: + + Index "dog" Value "chien" + Index "cat" Value "chat" + Index "one" Value "un" + Index 1 Value "un" + +Here we decided to translate the number one in both spelled-out and +numeric form--thus illustrating that a single array can have both +numbers and strings as indices. In fact, array subscripts are always +strings; this is discussed in more detail in *note Numeric Array +Subscripts::. Here, the number `1' isn't double-quoted, since `awk' +automatically converts it to a string. + + The value of `IGNORECASE' has no effect upon array subscripting. +The identical string value used to store an array element must be used +to retrieve it. When `awk' creates an array (e.g., with the `split()' +built-in function), that array's indices are consecutive integers +starting at one. (*Note String Functions::.) + + `awk''s arrays are efficient--the time to access an element is +independent of the number of elements in the array. + + +File: gawk.info, Node: Reference to Elements, Next: Assigning Elements, Prev: Array Intro, Up: Array Basics + +8.1.2 Referring to an Array Element +----------------------------------- + +The principal way to use an array is to refer to one of its elements. +An array reference is an expression as follows: + + ARRAY[INDEX-EXPRESSION] + +Here, ARRAY is the name of an array. The expression INDEX-EXPRESSION is +the index of the desired element of the array. + + The value of the array reference is the current value of that array +element. For example, `foo[4.3]' is an expression for the element of +array `foo' at index `4.3'. + + A reference to an array element that has no recorded value yields a +value of `""', the null string. This includes elements that have not +been assigned any value as well as elements that have been deleted +(*note Delete::). + + NOTE: A reference to an element that does not exist + _automatically_ creates that array element, with the null string + as its value. (In some cases, this is unfortunate, because it + might waste memory inside `awk'.) + + Novice `awk' programmers often make the mistake of checking if an + element exists by checking if the value is empty: + + # Check if "foo" exists in a: Incorrect! + if (a["foo"] != "") ... + + This is incorrect, since this will _create_ `a["foo"]' if it + didn't exist before! + + To determine whether an element exists in an array at a certain +index, use the following expression: + + IND in ARRAY + +This expression tests whether the particular index IND exists, without +the side effect of creating that element if it is not present. The +expression has the value one (true) if `ARRAY[IND]' exists and zero +(false) if it does not exist. For example, this statement tests +whether the array `frequencies' contains the index `2': + + if (2 in frequencies) + print "Subscript 2 is present." + + Note that this is _not_ a test of whether the array `frequencies' +contains an element whose _value_ is two. There is no way to do that +except to scan all the elements. Also, this _does not_ create +`frequencies[2]', while the following (incorrect) alternative does: + + if (frequencies[2] != "") + print "Subscript 2 is present." + + +File: gawk.info, Node: Assigning Elements, Next: Array Example, Prev: Reference to Elements, Up: Array Basics + +8.1.3 Assigning Array Elements +------------------------------ + +Array elements can be assigned values just like `awk' variables: + + ARRAY[INDEX-EXPRESSION] = VALUE + +ARRAY is the name of an array. The expression INDEX-EXPRESSION is the +index of the element of the array that is assigned a value. The +expression VALUE is the value to assign to that element of the array. + + +File: gawk.info, Node: Array Example, Next: Scanning an Array, Prev: Assigning Elements, Up: Array Basics + +8.1.4 Basic Array Example +------------------------- + +The following program takes a list of lines, each beginning with a line +number, and prints them out in order of line number. The line numbers +are not in order when they are first read--instead they are scrambled. +This program sorts the lines by making an array using the line numbers +as subscripts. The program then prints out the lines in sorted order +of their numbers. It is a very simple program and gets confused upon +encountering repeated numbers, gaps, or lines that don't begin with a +number: + + { + if ($1 > max) + max = $1 + arr[$1] = $0 + } + + END { + for (x = 1; x <= max; x++) + print arr[x] + } + + The first rule keeps track of the largest line number seen so far; +it also stores each line into the array `arr', at an index that is the +line's number. The second rule runs after all the input has been read, +to print out all the lines. When this program is run with the +following input: + + 5 I am the Five man + 2 Who are you? The new number two! + 4 . . . And four on the floor + 1 Who is number one? + 3 I three you. + +Its output is: + + 1 Who is number one? + 2 Who are you? The new number two! + 3 I three you. + 4 . . . And four on the floor + 5 I am the Five man + + If a line number is repeated, the last line with a given number +overrides the others. Gaps in the line numbers can be handled with an +easy improvement to the program's `END' rule, as follows: + + END { + for (x = 1; x <= max; x++) + if (x in arr) + print arr[x] + } + + +File: gawk.info, Node: Scanning an Array, Next: Controlling Scanning, Prev: Array Example, Up: Array Basics + +8.1.5 Scanning All Elements of an Array +--------------------------------------- + +In programs that use arrays, it is often necessary to use a loop that +executes once for each element of an array. In other languages, where +arrays are contiguous and indices are limited to positive integers, +this is easy: all the valid indices can be found by counting from the +lowest index up to the highest. This technique won't do the job in +`awk', because any number or string can be an array index. So `awk' +has a special kind of `for' statement for scanning an array: + + for (VAR in ARRAY) + BODY + +This loop executes BODY once for each index in ARRAY that the program +has previously used, with the variable VAR set to that index. + + The following program uses this form of the `for' statement. The +first rule scans the input records and notes which words appear (at +least once) in the input, by storing a one into the array `used' with +the word as index. The second rule scans the elements of `used' to +find all the distinct words that appear in the input. It prints each +word that is more than 10 characters long and also prints the number of +such words. *Note String Functions::, for more information on the +built-in function `length()'. + + # Record a 1 for each word that is used at least once + { + for (i = 1; i <= NF; i++) + used[$i] = 1 + } + + # Find number of distinct words more than 10 characters long + END { + for (x in used) { + if (length(x) > 10) { + ++num_long_words + print x + } + } + print num_long_words, "words longer than 10 characters" + } + +*Note Word Sorting::, for a more detailed example of this type. + + The order in which elements of the array are accessed by this +statement is determined by the internal arrangement of the array +elements within `awk' and normally cannot be controlled or changed. +This can lead to problems if new elements are added to ARRAY by +statements in the loop body; it is not predictable whether the `for' +loop will reach them. Similarly, changing VAR inside the loop may +produce strange results. It is best to avoid such things. + + +File: gawk.info, Node: Controlling Scanning, Prev: Scanning an Array, Up: Array Basics + +8.1.6 Using Predefined Array Scanning Orders +-------------------------------------------- + +By default, when a `for' loop traverses an array, the order is +undefined, meaning that the `awk' implementation determines the order +in which the array is traversed. This order is usually based on the +internal implementation of arrays and will vary from one version of +`awk' to the next. + + Often, though, you may wish to do something simple, such as +"traverse the array by comparing the indices in ascending order," or +"traverse the array by on comparing the values in descending order." +`gawk' provides two mechanisms which give you this control. + + * Set `PROCINFO["sorted_in"]' to one of a set of predefined values. + We describe this now. + + * Set `PROCINFO["sorted_in"]' to the name of a user-defined function + to be used for comparison of array elements. This advanced feature + is described later, in *note Array Sorting::. + + The following special values for `PROCINFO["sorted_in"]' are +available: + +`"@unsorted"' + Array elements are processed in arbitrary order, which is the + default `awk' behavior. + +`"@ind_str_asc"' + Order by indices compared as strings; this is the most basic sort. + (Internally, array indices are always strings, so with `a[2*5] = 1' + the index is `"10"' rather than numeric 10.) + +`"@ind_num_asc"' + Order by indices but force them to be treated as numbers in the + process. Any index with a non-numeric value will end up + positioned as if it were zero. + +`"@val_type_asc"' + Order by element values rather than indices. Ordering is by the + type assigned to the element (*note Typing and Comparison::). All + numeric values come before all string values, which in turn come + before all subarrays. (Subarrays have not been described yet; + *note Arrays of Arrays::). + +`"@val_str_asc"' + Order by element values rather than by indices. Scalar values are + compared as strings. Subarrays, if present, come out last. + +`"@val_num_asc"' + Order by element values rather than by indices. Scalar values are + compared as numbers. Subarrays, if present, come out last. When + numeric values are equal, the string values are used to provide an + ordering: this guarantees consistent results across different + versions of the C `qsort()' function,(1) which `gawk' uses + internally to perform the sorting. + +`"@ind_str_desc"' + Reverse order from the most basic sort. + +`"@ind_num_desc"' + Numeric indices ordered from high to low. + +`"@val_type_desc"' + Element values, based on type, in descending order. + +`"@val_str_desc"' + Element values, treated as strings, ordered from high to low. + Subarrays, if present, come out first. + +`"@val_num_desc"' + Element values, treated as numbers, ordered from high to low. + Subarrays, if present, come out first. + + The array traversal order is determined before the `for' loop starts +to run. Changing `PROCINFO["sorted_in"]' in the loop body will not +affect the loop. + + For example: + + $ gawk 'BEGIN { + > a[4] = 4 + > a[3] = 3 + > for (i in a) + > print i, a[i] + > }' + -| 4 4 + -| 3 3 + $ gawk 'BEGIN { + > PROCINFO["sorted_in"] = "@ind_str_asc" + > a[4] = 4 + > a[3] = 3 + > for (i in a) + > print i, a[i] + > }' + -| 3 3 + -| 4 4 + + When sorting an array by element values, if a value happens to be a +subarray then it is considered to be greater than any string or numeric +value, regardless of what the subarray itself contains, and all +subarrays are treated as being equal to each other. Their order +relative to each other is determined by their index strings. + + Here are some additional things to bear in mind about sorted array +traversal. + + * The value of `PROCINFO["sorted_in"]' is global. That is, it affects + all array traversal `for' loops. If you need to change it within + your own code, you should see if it's defined and save and restore + the value: + + ... + if ("sorted_in" in PROCINFO) { + save_sorted = PROCINFO["sorted_in"] + PROCINFO["sorted_in"] = "@val_str_desc" # or whatever + } + ... + if (save_sorted) + PROCINFO["sorted_in"] = save_sorted + + * As mentioned, the default array traversal order is represented by + `"@unsorted"'. You can also get the default behavior by assigning + the null string to `PROCINFO["sorted_in"]' or by just deleting the + `"sorted_in"' element from the `PROCINFO' array with the `delete' + statement. (The `delete' statement hasn't been described yet; + *note Delete::.) + + In addition, `gawk' provides built-in functions for sorting arrays; +see *note Array Sorting Functions::. + + ---------- Footnotes ---------- + + (1) When two elements compare as equal, the C `qsort()' function +does not guarantee that they will maintain their original relative +order after sorting. Using the string value to provide a unique +ordering when the numeric values are equal ensures that `gawk' behaves +consistently across different environments. + + +File: gawk.info, Node: Delete, Next: Numeric Array Subscripts, Prev: Array Basics, Up: Arrays + +8.2 The `delete' Statement +========================== + +To remove an individual element of an array, use the `delete' statement: + + delete ARRAY[INDEX-EXPRESSION] + + Once an array element has been deleted, any value the element once +had is no longer available. It is as if the element had never been +referred to or been given a value. The following is an example of +deleting elements in an array: + + for (i in frequencies) + delete frequencies[i] + +This example removes all the elements from the array `frequencies'. +Once an element is deleted, a subsequent `for' statement to scan the +array does not report that element and the `in' operator to check for +the presence of that element returns zero (i.e., false): + + delete foo[4] + if (4 in foo) + print "This will never be printed" + + It is important to note that deleting an element is _not_ the same +as assigning it a null value (the empty string, `""'). For example: + + foo[4] = "" + if (4 in foo) + print "This is printed, even though foo[4] is empty" + + It is not an error to delete an element that does not exist. +However, if `--lint' is provided on the command line (*note Options::), +`gawk' issues a warning message when an element that is not in the +array is deleted. + + All the elements of an array may be deleted with a single statement +(c.e.) by leaving off the subscript in the `delete' statement, as +follows: + + delete ARRAY + + This ability is a `gawk' extension; it is not available in +compatibility mode (*note Options::). + + Using this version of the `delete' statement is about three times +more efficient than the equivalent loop that deletes each element one +at a time. + + The following statement provides a portable but nonobvious way to +clear out an array:(1) + + split("", array) + + The `split()' function (*note String Functions::) clears out the +target array first. This call asks it to split apart the null string. +Because there is no data to split out, the function simply clears the +array and then returns. + + CAUTION: Deleting an array does not change its type; you cannot + delete an array and then use the array's name as a scalar (i.e., a + regular variable). For example, the following does not work: + + a[1] = 3 + delete a + a = 3 + + ---------- Footnotes ---------- + + (1) Thanks to Michael Brennan for pointing this out. + + +File: gawk.info, Node: Numeric Array Subscripts, Next: Uninitialized Subscripts, Prev: Delete, Up: Arrays + +8.3 Using Numbers to Subscript Arrays +===================================== + +An important aspect to remember about arrays is that _array subscripts +are always strings_. When a numeric value is used as a subscript, it +is converted to a string value before being used for subscripting +(*note Conversion::). This means that the value of the built-in +variable `CONVFMT' can affect how your program accesses elements of an +array. For example: + + xyz = 12.153 + data[xyz] = 1 + CONVFMT = "%2.2f" + if (xyz in data) + printf "%s is in data\n", xyz + else + printf "%s is not in data\n", xyz + +This prints `12.15 is not in data'. The first statement gives `xyz' a +numeric value. Assigning to `data[xyz]' subscripts `data' with the +string value `"12.153"' (using the default conversion value of +`CONVFMT', `"%.6g"'). Thus, the array element `data["12.153"]' is +assigned the value one. The program then changes the value of +`CONVFMT'. The test `(xyz in data)' generates a new string value from +`xyz'--this time `"12.15"'--because the value of `CONVFMT' only allows +two significant digits. This test fails, since `"12.15"' is different +from `"12.153"'. + + According to the rules for conversions (*note Conversion::), integer +values are always converted to strings as integers, no matter what the +value of `CONVFMT' may happen to be. So the usual case of the +following works: + + for (i = 1; i <= maxsub; i++) + do something with array[i] + + The "integer values always convert to strings as integers" rule has +an additional consequence for array indexing. Octal and hexadecimal +constants (*note Nondecimal-numbers::) are converted internally into +numbers, and their original form is forgotten. This means, for +example, that `array[17]', `array[021]', and `array[0x11]' all refer to +the same element! + + As with many things in `awk', the majority of the time things work +as one would expect them to. But it is useful to have a precise +knowledge of the actual rules since they can sometimes have a subtle +effect on your programs. + + +File: gawk.info, Node: Uninitialized Subscripts, Next: Multi-dimensional, Prev: Numeric Array Subscripts, Up: Arrays + +8.4 Using Uninitialized Variables as Subscripts +=============================================== + +Suppose it's necessary to write a program to print the input data in +reverse order. A reasonable attempt to do so (with some test data) +might look like this: + + $ echo 'line 1 + > line 2 + > line 3' | awk '{ l[lines] = $0; ++lines } + > END { + > for (i = lines-1; i >= 0; --i) + > print l[i] + > }' + -| line 3 + -| line 2 + + Unfortunately, the very first line of input data did not come out in +the output! + + Upon first glance, we would think that this program should have +worked. The variable `lines' is uninitialized, and uninitialized +variables have the numeric value zero. So, `awk' should have printed +the value of `l[0]'. + + The issue here is that subscripts for `awk' arrays are _always_ +strings. Uninitialized variables, when used as strings, have the value +`""', not zero. Thus, `line 1' ends up stored in `l[""]'. The +following version of the program works correctly: + + { l[lines++] = $0 } + END { + for (i = lines - 1; i >= 0; --i) + print l[i] + } + + Here, the `++' forces `lines' to be numeric, thus making the "old +value" numeric zero. This is then converted to `"0"' as the array +subscript. + + Even though it is somewhat unusual, the null string (`""') is a +valid array subscript. (d.c.) `gawk' warns about the use of the null +string as a subscript if `--lint' is provided on the command line +(*note Options::). + + +File: gawk.info, Node: Multi-dimensional, Next: Arrays of Arrays, Prev: Uninitialized Subscripts, Up: Arrays + +8.5 Multidimensional Arrays +=========================== + +* Menu: + +* Multi-scanning:: Scanning multidimensional arrays. + + A multidimensional array is an array in which an element is +identified by a sequence of indices instead of a single index. For +example, a two-dimensional array requires two indices. The usual way +(in most languages, including `awk') to refer to an element of a +two-dimensional array named `grid' is with `grid[X,Y]'. + + Multidimensional arrays are supported in `awk' through concatenation +of indices into one string. `awk' converts the indices into strings +(*note Conversion::) and concatenates them together, with a separator +between them. This creates a single string that describes the values +of the separate indices. The combined string is used as a single index +into an ordinary, one-dimensional array. The separator used is the +value of the built-in variable `SUBSEP'. + + For example, suppose we evaluate the expression `foo[5,12] = "value"' +when the value of `SUBSEP' is `"@"'. The numbers 5 and 12 are +converted to strings and concatenated with an `@' between them, +yielding `"5@12"'; thus, the array element `foo["5@12"]' is set to +`"value"'. + + Once the element's value is stored, `awk' has no record of whether +it was stored with a single index or a sequence of indices. The two +expressions `foo[5,12]' and `foo[5 SUBSEP 12]' are always equivalent. + + The default value of `SUBSEP' is the string `"\034"', which contains +a nonprinting character that is unlikely to appear in an `awk' program +or in most input data. The usefulness of choosing an unlikely +character comes from the fact that index values that contain a string +matching `SUBSEP' can lead to combined strings that are ambiguous. +Suppose that `SUBSEP' is `"@"'; then `foo["a@b", "c"]' and +`foo["a", "b@c"]' are indistinguishable because both are actually +stored as `foo["a@b@c"]'. + + To test whether a particular index sequence exists in a +multidimensional array, use the same operator (`in') that is used for +single dimensional arrays. Write the whole sequence of indices in +parentheses, separated by commas, as the left operand: + + (SUBSCRIPT1, SUBSCRIPT2, ...) in ARRAY + + The following example treats its input as a two-dimensional array of +fields; it rotates this array 90 degrees clockwise and prints the +result. It assumes that all lines have the same number of elements: + + { + if (max_nf < NF) + max_nf = NF + max_nr = NR + for (x = 1; x <= NF; x++) + vector[x, NR] = $x + } + + END { + for (x = 1; x <= max_nf; x++) { + for (y = max_nr; y >= 1; --y) + printf("%s ", vector[x, y]) + printf("\n") + } + } + +When given the input: + + 1 2 3 4 5 6 + 2 3 4 5 6 1 + 3 4 5 6 1 2 + 4 5 6 1 2 3 + +the program produces the following output: + + 4 3 2 1 + 5 4 3 2 + 6 5 4 3 + 1 6 5 4 + 2 1 6 5 + 3 2 1 6 + + +File: gawk.info, Node: Multi-scanning, Up: Multi-dimensional + +8.5.1 Scanning Multidimensional Arrays +-------------------------------------- + +There is no special `for' statement for scanning a "multidimensional" +array. There cannot be one, because, in truth, `awk' does not have +multidimensional arrays or elements--there is only a multidimensional +_way of accessing_ an array. + + However, if your program has an array that is always accessed as +multidimensional, you can get the effect of scanning it by combining +the scanning `for' statement (*note Scanning an Array::) with the +built-in `split()' function (*note String Functions::). It works in +the following manner: + + for (combined in array) { + split(combined, separate, SUBSEP) + ... + } + +This sets the variable `combined' to each concatenated combined index +in the array, and splits it into the individual indices by breaking it +apart where the value of `SUBSEP' appears. The individual indices then +become the elements of the array `separate'. + + Thus, if a value is previously stored in `array[1, "foo"]', then an +element with index `"1\034foo"' exists in `array'. (Recall that the +default value of `SUBSEP' is the character with code 034.) Sooner or +later, the `for' statement finds that index and does an iteration with +the variable `combined' set to `"1\034foo"'. Then the `split()' +function is called as follows: + + split("1\034foo", separate, "\034") + +The result is to set `separate[1]' to `"1"' and `separate[2]' to +`"foo"'. Presto! The original sequence of separate indices is +recovered. + + +File: gawk.info, Node: Arrays of Arrays, Prev: Multi-dimensional, Up: Arrays + +8.6 Arrays of Arrays +==================== + +`gawk' goes beyond standard `awk''s multidimensional array access and +provides true arrays of arrays. Elements of a subarray are referred to +by their own indices enclosed in square brackets, just like the +elements of the main array. For example, the following creates a +two-element subarray at index `1' of the main array `a': + + a[1][1] = 1 + a[1][2] = 2 + + This simulates a true two-dimensional array. Each subarray element +can contain another subarray as a value, which in turn can hold other +arrays as well. In this way, you can create arrays of three or more +dimensions. The indices can be any `awk' expression, including scalars +separated by commas (that is, a regular `awk' simulated +multidimensional subscript). So the following is valid in `gawk': + + a[1][3][1, "name"] = "barney" + + Each subarray and the main array can be of different length. In +fact, the elements of an array or its subarray do not all have to have +the same type. This means that the main array and any of its subarrays +can be non-rectangular, or jagged in structure. One can assign a scalar +value to the index `4' of the main array `a': + + a[4] = "An element in a jagged array" + + The terms "dimension", "row" and "column" are meaningless when +applied to such an array, but we will use "dimension" henceforth to +imply the maximum number of indices needed to refer to an existing +element. The type of any element that has already been assigned cannot +be changed by assigning a value of a different type. You have to first +delete the current element, which effectively makes `gawk' forget about +the element at that index: + + delete a[4] + a[4][5][6][7] = "An element in a four-dimensional array" + +This removes the scalar value from index `4' and then inserts a +subarray of subarray of subarray containing a scalar. You can also +delete an entire subarray or subarray of subarrays: + + delete a[4][5] + a[4][5] = "An element in subarray a[4]" + + But recall that you can not delete the main array `a' and then use it +as a scalar. + + The built-in functions which take array arguments can also be used +with subarrays. For example, the following code fragment uses `length()' +(*note String Functions::) to determine the number of elements in the +main array `a' and its subarrays: + + print length(a), length(a[1]), length(a[1][3]) + +This results in the following output for our main array `a': + + 2, 3, 1 + +The `SUBSCRIPT in ARRAY' expression (*note Reference to Elements::) +works similarly for both regular `awk'-style arrays and arrays of +arrays. For example, the tests `1 in a', `3 in a[1]', and `(1, "name") +in a[1][3]' all evaluate to one (true) for our array `a'. + + The `for (item in array)' statement (*note Scanning an Array::) can +be nested to scan all the elements of an array of arrays if it is +rectangular in structure. In order to print the contents (scalar +values) of a two-dimensional array of arrays (i.e., in which each +first-level element is itself an array, not necessarily of the same +length) you could use the following code: + + for (i in array) + for (j in array[i]) + print array[i][j] + + The `isarray()' function (*note Type Functions::) lets you test if +an array element is itself an array: + + for (i in array) { + if (isarray(array[i]) { + for (j in array[i]) { + print array[i][j] + } + } + } + + If the structure of a jagged array of arrays is known in advance, +you can often devise workarounds using control statements. For example, +the following code prints the elements of our main array `a': + + for (i in a) { + for (j in a[i]) { + if (j == 3) { + for (k in a[i][j]) + print a[i][j][k] + } else + print a[i][j] + } + } + +*Note Walking Arrays::, for a user-defined function that will "walk" an +arbitrarily-dimensioned array of arrays. + + Recall that a reference to an uninitialized array element yields a +value of `""', the null string. This has one important implication when +you intend to use a subarray as an argument to a function, as +illustrated by the following example: + + $ gawk 'BEGIN { split("a b c d", b[1]); print b[1][1] }' + error--> gawk: cmd. line:1: fatal: split: second argument is not an array + + The way to work around this is to first force `b[1]' to be an array +by creating an arbitrary index: + + $ gawk 'BEGIN { b[1][1] = ""; split("a b c d", b[1]); print b[1][1] }' + -| a + + +File: gawk.info, Node: Functions, Next: Internationalization, Prev: Arrays, Up: Top + +9 Functions +*********** + +This major node describes `awk''s built-in functions, which fall into +three categories: numeric, string, and I/O. `gawk' provides additional +groups of functions to work with values that represent time, do bit +manipulation, sort arrays, and internationalize and localize programs. + + Besides the built-in functions, `awk' has provisions for writing new +functions that the rest of a program can use. The second half of this +major node describes these "user-defined" functions. + +* Menu: + +* Built-in:: Summarizes the built-in functions. +* User-defined:: Describes User-defined functions in detail. +* Indirect Calls:: Choosing the function to call at runtime. + + +File: gawk.info, Node: Built-in, Next: User-defined, Up: Functions + +9.1 Built-in Functions +====================== + +"Built-in" functions are always available for your `awk' program to +call. This minor node defines all the built-in functions in `awk'; +some of these are mentioned in other sections but are summarized here +for your convenience. + +* Menu: + +* Calling Built-in:: How to call built-in functions. +* Numeric Functions:: Functions that work with numbers, including + `int()', `sin()' and `rand()'. +* String Functions:: Functions for string manipulation, such as + `split()', `match()' and + `sprintf()'. +* I/O Functions:: Functions for files and shell commands. +* Time Functions:: Functions for dealing with timestamps. +* Bitwise Functions:: Functions for bitwise operations. +* Type Functions:: Functions for type information. +* I18N Functions:: Functions for string translation. + + +File: gawk.info, Node: Calling Built-in, Next: Numeric Functions, Up: Built-in + +9.1.1 Calling Built-in Functions +-------------------------------- + +To call one of `awk''s built-in functions, write the name of the +function followed by arguments in parentheses. For example, `atan2(y + +z, 1)' is a call to the function `atan2()' and has two arguments. + + Whitespace is ignored between the built-in function name and the +open parenthesis, but nonetheless it is good practice to avoid using +whitespace there. User-defined functions do not permit whitespace in +this way, and it is easier to avoid mistakes by following a simple +convention that always works--no whitespace after a function name. + + Each built-in function accepts a certain number of arguments. In +some cases, arguments can be omitted. The defaults for omitted +arguments vary from function to function and are described under the +individual functions. In some `awk' implementations, extra arguments +given to built-in functions are ignored. However, in `gawk', it is a +fatal error to give extra arguments to a built-in function. + + When a function is called, expressions that create the function's +actual parameters are evaluated completely before the call is performed. +For example, in the following code fragment: + + i = 4 + j = sqrt(i++) + +the variable `i' is incremented to the value five before `sqrt()' is +called with a value of four for its actual parameter. The order of +evaluation of the expressions used for the function's parameters is +undefined. Thus, avoid writing programs that assume that parameters +are evaluated from left to right or from right to left. For example: + + i = 5 + j = atan2(i++, i *= 2) + + If the order of evaluation is left to right, then `i' first becomes +6, and then 12, and `atan2()' is called with the two arguments 6 and +12. But if the order of evaluation is right to left, `i' first becomes +10, then 11, and `atan2()' is called with the two arguments 11 and 10. + + +File: gawk.info, Node: Numeric Functions, Next: String Functions, Prev: Calling Built-in, Up: Built-in + +9.1.2 Numeric Functions +----------------------- + +The following list describes all of the built-in functions that work +with numbers. Optional parameters are enclosed in square +brackets ([ ]): + +`atan2(Y, X)' + Return the arctangent of `Y / X' in radians. You can use `pi = + atan2(0, -1)' to retrieve the value of pi. + +`cos(X)' + Return the cosine of X, with X in radians. + +`exp(X)' + Return the exponential of X (`e ^ X') or report an error if X is + out of range. The range of values X can have depends on your + machine's floating-point representation. + +`int(X)' + Return the nearest integer to X, located between X and zero and + truncated toward zero. + + For example, `int(3)' is 3, `int(3.9)' is 3, `int(-3.9)' is -3, + and `int(-3)' is -3 as well. + +`log(X)' + Return the natural logarithm of X, if X is positive; otherwise, + report an error. + +`rand()' + Return a random number. The values of `rand()' are uniformly + distributed between zero and one. The value could be zero but is + never one.(1) + + Often random integers are needed instead. Following is a + user-defined function that can be used to obtain a random + non-negative integer less than N: + + function randint(n) { + return int(n * rand()) + } + + The multiplication produces a random number greater than zero and + less than `n'. Using `int()', this result is made into an integer + between zero and `n' - 1, inclusive. + + The following example uses a similar function to produce random + integers between one and N. This program prints a new random + number for each input record: + + # Function to roll a simulated die. + function roll(n) { return 1 + int(rand() * n) } + + # Roll 3 six-sided dice and + # print total number of points. + { + printf("%d points\n", + roll(6)+roll(6)+roll(6)) + } + + CAUTION: In most `awk' implementations, including `gawk', + `rand()' starts generating numbers from the same starting + number, or "seed", each time you run `awk'.(2) Thus, a + program generates the same results each time you run it. The + numbers are random within one `awk' run but predictable from + run to run. This is convenient for debugging, but if you want + a program to do different things each time it is used, you + must change the seed to a value that is different in each + run. To do this, use `srand()'. + +`sin(X)' + Return the sine of X, with X in radians. + +`sqrt(X)' + Return the positive square root of X. `gawk' prints a warning + message if X is negative. Thus, `sqrt(4)' is 2. + +`srand([X])' + Set the starting point, or seed, for generating random numbers to + the value X. + + Each seed value leads to a particular sequence of random + numbers.(3) Thus, if the seed is set to the same value a second + time, the same sequence of random numbers is produced again. + + CAUTION: Different `awk' implementations use different + random-number generators internally. Don't expect the same + `awk' program to produce the same series of random numbers + when executed by different versions of `awk'. + + If the argument X is omitted, as in `srand()', then the current + date and time of day are used for a seed. This is the way to get + random numbers that are truly unpredictable. + + The return value of `srand()' is the previous seed. This makes it + easy to keep track of the seeds in case you need to consistently + reproduce sequences of random numbers. + + ---------- Footnotes ---------- + + (1) The C version of `rand()' on many Unix systems is known to +produce fairly poor sequences of random numbers. However, nothing +requires that an `awk' implementation use the C `rand()' to implement +the `awk' version of `rand()'. In fact, `gawk' uses the BSD `random()' +function, which is considerably better than `rand()', to produce random +numbers. + + (2) `mawk' uses a different seed each time. + + (3) Computer-generated random numbers really are not truly random. +They are technically known as "pseudorandom." This means that while +the numbers in a sequence appear to be random, you can in fact generate +the same sequence of random numbers over and over again. + + +File: gawk.info, Node: String Functions, Next: I/O Functions, Prev: Numeric Functions, Up: Built-in + +9.1.3 String-Manipulation Functions +----------------------------------- + +The functions in this minor node look at or change the text of one or +more strings. `gawk' understands locales (*note Locales::), and does +all string processing in terms of _characters_, not _bytes_. This +distinction is particularly important to understand for locales where +one character may be represented by multiple bytes. Thus, for example, +`length()' returns the number of characters in a string, and not the +number of bytes used to represent those characters, Similarly, +`index()' works with character indices, and not byte indices. + + In the following list, optional parameters are enclosed in square +brackets ([ ]). Several functions perform string substitution; the +full discussion is provided in the description of the `sub()' function, +which comes towards the end since the list is presented in alphabetic +order. Those functions that are specific to `gawk' are marked with a +pound sign (`#'): + +* Menu: + +* Gory Details:: More than you want to know about `\' and + `&' with `sub()', `gsub()', and + `gensub()'. + +`asort(SOURCE [, DEST [, HOW ] ]) #' + Return the number of elements in the array SOURCE. `gawk' sorts + the contents of SOURCE and replaces the indices of the sorted + values of SOURCE with sequential integers starting with one. If + the optional array DEST is specified, then SOURCE is duplicated + into DEST. DEST is then sorted, leaving the indices of SOURCE + unchanged. The optional third argument HOW is a string which + controls the rule for comparing values, and the sort direction. A + single space is required between the comparison mode, `string' or + `number', and the direction specification, `ascending' or + `descending'. You can omit direction and/or mode in which case it + will default to `ascending' and `string', respectively. An empty + string "" is the same as the default `"ascending string"' for the + value of HOW. If the `source' array contains subarrays as values, + they will come out last(first) in the `dest' array for + `ascending'(`descending') order specification. The value of + `IGNORECASE' affects the sorting. The third argument can also be + a user-defined function name in which case the value returned by + the function is used to order the array elements before + constructing the result array. *Note Array Sorting Functions::, + for more information. + + For example, if the contents of `a' are as follows: + + a["last"] = "de" + a["first"] = "sac" + a["middle"] = "cul" + + A call to `asort()': + + asort(a) + + results in the following contents of `a': + + a[1] = "cul" + a[2] = "de" + a[3] = "sac" + + In order to reverse the direction of the sorted results in the + above example, `asort()' can be called with three arguments as + follows: + + asort(a, a, "descending") + + The `asort()' function is described in more detail in *note Array + Sorting Functions::. `asort()' is a `gawk' extension; it is not + available in compatibility mode (*note Options::). + +`asorti(SOURCE [, DEST [, HOW ] ]) #' + Return the number of elements in the array SOURCE. It works + similarly to `asort()', however, the _indices_ are sorted, instead + of the values. (Here too, `IGNORECASE' affects the sorting.) + + The `asorti()' function is described in more detail in *note Array + Sorting Functions::. `asorti()' is a `gawk' extension; it is not + available in compatibility mode (*note Options::). + +`gensub(REGEXP, REPLACEMENT, HOW [, TARGET]) #' + Search the target string TARGET for matches of the regular + expression REGEXP. If HOW is a string beginning with `g' or `G' + (short for "global"), then replace all matches of REGEXP with + REPLACEMENT. Otherwise, HOW is treated as a number indicating + which match of REGEXP to replace. If no TARGET is supplied, use + `$0'. It returns the modified string as the result of the + function and the original target string is _not_ changed. + + `gensub()' is a general substitution function. It's purpose is to + provide more features than the standard `sub()' and `gsub()' + functions. + + `gensub()' provides an additional feature that is not available in + `sub()' or `gsub()': the ability to specify components of a regexp + in the replacement text. This is done by using parentheses in the + regexp to mark the components and then specifying `\N' in the + replacement text, where N is a digit from 1 to 9. For example: + + $ gawk ' + > BEGIN { + > a = "abc def" + > b = gensub(/(.+) (.+)/, "\\2 \\1", "g", a) + > print b + > }' + -| def abc + + As with `sub()', you must type two backslashes in order to get one + into the string. In the replacement text, the sequence `\0' + represents the entire matched text, as does the character `&'. + + The following example shows how you can use the third argument to + control which match of the regexp should be changed: + + $ echo a b c a b c | + > gawk '{ print gensub(/a/, "AA", 2) }' + -| a b c AA b c + + In this case, `$0' is the default target string. `gensub()' + returns the new string as its result, which is passed directly to + `print' for printing. + + If the HOW argument is a string that does not begin with `g' or + `G', or if it is a number that is less than or equal to zero, only + one substitution is performed. If HOW is zero, `gawk' issues a + warning message. + + If REGEXP does not match TARGET, `gensub()''s return value is the + original unchanged value of TARGET. + + `gensub()' is a `gawk' extension; it is not available in + compatibility mode (*note Options::). + +`gsub(REGEXP, REPLACEMENT [, TARGET])' + Search TARGET for _all_ of the longest, leftmost, _nonoverlapping_ + matching substrings it can find and replace them with REPLACEMENT. + The `g' in `gsub()' stands for "global," which means replace + everywhere. For example: + + { gsub(/Britain/, "United Kingdom"); print } + + replaces all occurrences of the string `Britain' with `United + Kingdom' for all input records. + + The `gsub()' function returns the number of substitutions made. If + the variable to search and alter (TARGET) is omitted, then the + entire input record (`$0') is used. As in `sub()', the characters + `&' and `\' are special, and the third argument must be assignable. + +`index(IN, FIND)' + Search the string IN for the first occurrence of the string FIND, + and return the position in characters where that occurrence begins + in the string IN. Consider the following example: + + $ awk 'BEGIN { print index("peanut", "an") }' + -| 3 + + If FIND is not found, `index()' returns zero. (Remember that + string indices in `awk' start at one.) + +`length([STRING])' + Return the number of characters in STRING. If STRING is a number, + the length of the digit string representing that number is + returned. For example, `length("abcde")' is five. By contrast, + `length(15 * 35)' works out to three. In this example, 15 * 35 = + 525, and 525 is then converted to the string `"525"', which has + three characters. + + If no argument is supplied, `length()' returns the length of `$0'. + + NOTE: In older versions of `awk', the `length()' function + could be called without any parentheses. Doing so is + considered poor practice, although the 2008 POSIX standard + explicitly allows it, to support historical practice. For + programs to be maximally portable, always supply the + parentheses. + + If `length()' is called with a variable that has not been used, + `gawk' forces the variable to be a scalar. Other implementations + of `awk' leave the variable without a type. (d.c.) Consider: + + $ gawk 'BEGIN { print length(x) ; x[1] = 1 }' + -| 0 + error--> gawk: fatal: attempt to use scalar `x' as array + + $ nawk 'BEGIN { print length(x) ; x[1] = 1 }' + -| 0 + + If `--lint' has been specified on the command line, `gawk' issues a + warning about this. + + With `gawk' and several other `awk' implementations, when given an + array argument, the `length()' function returns the number of + elements in the array. (c.e.) This is less useful than it might + seem at first, as the array is not guaranteed to be indexed from + one to the number of elements in it. If `--lint' is provided on + the command line (*note Options::), `gawk' warns that passing an + array argument is not portable. If `--posix' is supplied, using + an array argument is a fatal error (*note Arrays::). + +`match(STRING, REGEXP [, ARRAY])' + Search STRING for the longest, leftmost substring matched by the + regular expression, REGEXP and return the character position, or + "index", at which that substring begins (one, if it starts at the + beginning of STRING). If no match is found, return zero. + + The REGEXP argument may be either a regexp constant (`/.../') or a + string constant (`"..."'). In the latter case, the string is + treated as a regexp to be matched. *Note Computed Regexps::, for a + discussion of the difference between the two forms, and the + implications for writing your program correctly. + + The order of the first two arguments is backwards from most other + string functions that work with regular expressions, such as + `sub()' and `gsub()'. It might help to remember that for + `match()', the order is the same as for the `~' operator: `STRING + ~ REGEXP'. + + The `match()' function sets the built-in variable `RSTART' to the + index. It also sets the built-in variable `RLENGTH' to the length + in characters of the matched substring. If no match is found, + `RSTART' is set to zero, and `RLENGTH' to -1. + + For example: + + { + if ($1 == "FIND") + regex = $2 + else { + where = match($0, regex) + if (where != 0) + print "Match of", regex, "found at", + where, "in", $0 + } + } + + This program looks for lines that match the regular expression + stored in the variable `regex'. This regular expression can be + changed. If the first word on a line is `FIND', `regex' is + changed to be the second word on that line. Therefore, if given: + + FIND ru+n + My program runs + but not very quickly + FIND Melvin + JF+KM + This line is property of Reality Engineering Co. + Melvin was here. + + `awk' prints: + + Match of ru+n found at 12 in My program runs + Match of Melvin found at 1 in Melvin was here. + + If ARRAY is present, it is cleared, and then the zeroth element of + ARRAY is set to the entire portion of STRING matched by REGEXP. + If REGEXP contains parentheses, the integer-indexed elements of + ARRAY are set to contain the portion of STRING matching the + corresponding parenthesized subexpression. For example: + + $ echo foooobazbarrrrr | + > gawk '{ match($0, /(fo+).+(bar*)/, arr) + > print arr[1], arr[2] }' + -| foooo barrrrr + + In addition, multidimensional subscripts are available providing + the start index and length of each matched subexpression: + + $ echo foooobazbarrrrr | + > gawk '{ match($0, /(fo+).+(bar*)/, arr) + > print arr[1], arr[2] + > print arr[1, "start"], arr[1, "length"] + > print arr[2, "start"], arr[2, "length"] + > }' + -| foooo barrrrr + -| 1 5 + -| 9 7 + + There may not be subscripts for the start and index for every + parenthesized subexpression, since they may not all have matched + text; thus they should be tested for with the `in' operator (*note + Reference to Elements::). + + The ARRAY argument to `match()' is a `gawk' extension. In + compatibility mode (*note Options::), using a third argument is a + fatal error. + +`patsplit(STRING, ARRAY [, FIELDPAT [, SEPS ] ]) #' + Divide STRING into pieces defined by FIELDPAT and store the pieces + in ARRAY and the separator strings in the SEPS array. The first + piece is stored in `ARRAY[1]', the second piece in `ARRAY[2]', and + so forth. The third argument, FIELDPAT, is a regexp describing + the fields in STRING (just as `FPAT' is a regexp describing the + fields in input records). It may be either a regexp constant or a + string. If FIELDPAT is omitted, the value of `FPAT' is used. + `patsplit()' returns the number of elements created. `SEPS[I]' is + the separator string between `ARRAY[I]' and `ARRAY[I+1]'. Any + leading separator will be in `SEPS[0]'. + + The `patsplit()' function splits strings into pieces in a manner + similar to the way input lines are split into fields using `FPAT' + (*note Splitting By Content::. + + Before splitting the string, `patsplit()' deletes any previously + existing elements in the arrays ARRAY and SEPS. + + The `patsplit()' function is a `gawk' extension. In compatibility + mode (*note Options::), it is not available. + +`split(STRING, ARRAY [, FIELDSEP [, SEPS ] ])' + Divide STRING into pieces separated by FIELDSEP and store the + pieces in ARRAY and the separator strings in the SEPS array. The + first piece is stored in `ARRAY[1]', the second piece in + `ARRAY[2]', and so forth. The string value of the third argument, + FIELDSEP, is a regexp describing where to split STRING (much as + `FS' can be a regexp describing where to split input records; + *note Regexp Field Splitting::). If FIELDSEP is omitted, the + value of `FS' is used. `split()' returns the number of elements + created. SEPS is a `gawk' extension with `SEPS[I]' being the + separator string between `ARRAY[I]' and `ARRAY[I+1]'. If FIELDSEP + is a single space then any leading whitespace goes into `SEPS[0]' + and any trailing whitespace goes into `SEPS[N]' where N is the + return value of `split()' (that is, the number of elements in + ARRAY). + + The `split()' function splits strings into pieces in a manner + similar to the way input lines are split into fields. For example: + + split("cul-de-sac", a, "-", seps) + + splits the string `cul-de-sac' into three fields using `-' as the + separator. It sets the contents of the array `a' as follows: + + a[1] = "cul" + a[2] = "de" + a[3] = "sac" + + and sets the contents of the array `seps' as follows: + + seps[1] = "-" + seps[2] = "-" + + The value returned by this call to `split()' is three. + + As with input field-splitting, when the value of FIELDSEP is + `" "', leading and trailing whitespace is ignored in values + assigned to the elements of ARRAY but not in SEPS, and the elements + are separated by runs of whitespace. Also as with input + field-splitting, if FIELDSEP is the null string, each individual + character in the string is split into its own array element. + (c.e.) + + Note, however, that `RS' has no effect on the way `split()' works. + Even though `RS = ""' causes newline to also be an input field + separator, this does not affect how `split()' splits strings. + + Modern implementations of `awk', including `gawk', allow the third + argument to be a regexp constant (`/abc/') as well as a string. + (d.c.) The POSIX standard allows this as well. *Note Computed + Regexps::, for a discussion of the difference between using a + string constant or a regexp constant, and the implications for + writing your program correctly. + + Before splitting the string, `split()' deletes any previously + existing elements in the arrays ARRAY and SEPS. + + If STRING is null, the array has no elements. (So this is a + portable way to delete an entire array with one statement. *Note + Delete::.) + + If STRING does not match FIELDSEP at all (but is not null), ARRAY + has one element only. The value of that element is the original + STRING. + +`sprintf(FORMAT, EXPRESSION1, ...)' + Return (without printing) the string that `printf' would have + printed out with the same arguments (*note Printf::). For example: + + pival = sprintf("pi = %.2f (approx.)", 22/7) + + assigns the string `pi = 3.14 (approx.)' to the variable `pival'. + +`strtonum(STR) #' + Examine STR and return its numeric value. If STR begins with a + leading `0', `strtonum()' assumes that STR is an octal number. If + STR begins with a leading `0x' or `0X', `strtonum()' assumes that + STR is a hexadecimal number. For example: + + $ echo 0x11 | + > gawk '{ printf "%d\n", strtonum($1) }' + -| 17 + + Using the `strtonum()' function is _not_ the same as adding zero + to a string value; the automatic coercion of strings to numbers + works only for decimal data, not for octal or hexadecimal.(1) + + Note also that `strtonum()' uses the current locale's decimal point + for recognizing numbers (*note Locales::). + + `strtonum()' is a `gawk' extension; it is not available in + compatibility mode (*note Options::). + +`sub(REGEXP, REPLACEMENT [, TARGET])' + Search TARGET, which is treated as a string, for the leftmost, + longest substring matched by the regular expression REGEXP. + Modify the entire string by replacing the matched text with + REPLACEMENT. The modified string becomes the new value of TARGET. + Return the number of substitutions made (zero or one). + + The REGEXP argument may be either a regexp constant (`/.../') or a + string constant (`"..."'). In the latter case, the string is + treated as a regexp to be matched. *Note Computed Regexps::, for a + discussion of the difference between the two forms, and the + implications for writing your program correctly. + + This function is peculiar because TARGET is not simply used to + compute a value, and not just any expression will do--it must be a + variable, field, or array element so that `sub()' can store a + modified value there. If this argument is omitted, then the + default is to use and alter `$0'.(2) For example: + + str = "water, water, everywhere" + sub(/at/, "ith", str) + + sets `str' to `wither, water, everywhere', by replacing the + leftmost longest occurrence of `at' with `ith'. + + If the special character `&' appears in REPLACEMENT, it stands for + the precise substring that was matched by REGEXP. (If the regexp + can match more than one string, then this precise substring may + vary.) For example: + + { sub(/candidate/, "& and his wife"); print } + + changes the first occurrence of `candidate' to `candidate and his + wife' on each input line. Here is another example: + + $ awk 'BEGIN { + > str = "daabaaa" + > sub(/a+/, "C&C", str) + > print str + > }' + -| dCaaCbaaa + + This shows how `&' can represent a nonconstant string and also + illustrates the "leftmost, longest" rule in regexp matching (*note + Leftmost Longest::). + + The effect of this special character (`&') can be turned off by + putting a backslash before it in the string. As usual, to insert + one backslash in the string, you must write two backslashes. + Therefore, write `\\&' in a string constant to include a literal + `&' in the replacement. For example, the following shows how to + replace the first `|' on each line with an `&': + + { sub(/\|/, "\\&"); print } + + As mentioned, the third argument to `sub()' must be a variable, + field or array element. Some versions of `awk' allow the third + argument to be an expression that is not an lvalue. In such a + case, `sub()' still searches for the pattern and returns zero or + one, but the result of the substitution (if any) is thrown away + because there is no place to put it. Such versions of `awk' + accept expressions like the following: + + sub(/USA/, "United States", "the USA and Canada") + + For historical compatibility, `gawk' accepts such erroneous code. + However, using any other nonchangeable object as the third + parameter causes a fatal error and your program will not run. + + Finally, if the REGEXP is not a regexp constant, it is converted + into a string, and then the value of that string is treated as the + regexp to match. + +`substr(STRING, START [, LENGTH])' + Return a LENGTH-character-long substring of STRING, starting at + character number START. The first character of a string is + character number one.(3) For example, `substr("washington", 5, 3)' + returns `"ing"'. + + If LENGTH is not present, `substr()' returns the whole suffix of + STRING that begins at character number START. For example, + `substr("washington", 5)' returns `"ington"'. The whole suffix is + also returned if LENGTH is greater than the number of characters + remaining in the string, counting from character START. + + If START is less than one, `substr()' treats it as if it was one. + (POSIX doesn't specify what to do in this case: Brian Kernighan's + `awk' acts this way, and therefore `gawk' does too.) If START is + greater than the number of characters in the string, `substr()' + returns the null string. Similarly, if LENGTH is present but less + than or equal to zero, the null string is returned. + + The string returned by `substr()' _cannot_ be assigned. Thus, it + is a mistake to attempt to change a portion of a string, as shown + in the following example: + + string = "abcdef" + # try to get "abCDEf", won't work + substr(string, 3, 3) = "CDE" + + It is also a mistake to use `substr()' as the third argument of + `sub()' or `gsub()': + + gsub(/xyz/, "pdq", substr($0, 5, 20)) # WRONG + + (Some commercial versions of `awk' treat `substr()' as assignable, + but doing so is not portable.) + + If you need to replace bits and pieces of a string, combine + `substr()' with string concatenation, in the following manner: + + string = "abcdef" + ... + string = substr(string, 1, 2) "CDE" substr(string, 6) + +`tolower(STRING)' + Return a copy of STRING, with each uppercase character in the + string replaced with its corresponding lowercase character. + Nonalphabetic characters are left unchanged. For example, + `tolower("MiXeD cAsE 123")' returns `"mixed case 123"'. + +`toupper(STRING)' + Return a copy of STRING, with each lowercase character in the + string replaced with its corresponding uppercase character. + Nonalphabetic characters are left unchanged. For example, + `toupper("MiXeD cAsE 123")' returns `"MIXED CASE 123"'. + + ---------- Footnotes ---------- + + (1) Unless you use the `--non-decimal-data' option, which isn't +recommended. *Note Nondecimal Data::, for more information. + + (2) Note that this means that the record will first be regenerated +using the value of `OFS' if any fields have been changed, and that the +fields will be updated after the substitution, even if the operation is +a "no-op" such as `sub(/^/, "")'. + + (3) This is different from C and C++, in which the first character +is number zero. + + +File: gawk.info, Node: Gory Details, Up: String Functions + +9.1.3.1 More About `\' and `&' with `sub()', `gsub()', and `gensub()' +..................................................................... + +When using `sub()', `gsub()', or `gensub()', and trying to get literal +backslashes and ampersands into the replacement text, you need to +remember that there are several levels of "escape processing" going on. + + First, there is the "lexical" level, which is when `awk' reads your +program and builds an internal copy of it that can be executed. Then +there is the runtime level, which is when `awk' actually scans the +replacement string to determine what to generate. + + At both levels, `awk' looks for a defined set of characters that can +come after a backslash. At the lexical level, it looks for the escape +sequences listed in *note Escape Sequences::. Thus, for every `\' that +`awk' processes at the runtime level, you must type two backslashes at +the lexical level. When a character that is not valid for an escape +sequence follows the `\', Brian Kernighan's `awk' and `gawk' both +simply remove the initial `\' and put the next character into the +string. Thus, for example, `"a\qb"' is treated as `"aqb"'. + + At the runtime level, the various functions handle sequences of `\' +and `&' differently. The situation is (sadly) somewhat complex. +Historically, the `sub()' and `gsub()' functions treated the two +character sequence `\&' specially; this sequence was replaced in the +generated text with a single `&'. Any other `\' within the REPLACEMENT +string that did not precede an `&' was passed through unchanged. This +is illustrated in *note table-sub-escapes::. + + You type `sub()' sees `sub()' generates + ------- --------- -------------- + `\&' `&' the matched text + `\\&' `\&' a literal `&' + `\\\&' `\&' a literal `&' + `\\\\&' `\\&' a literal `\&' + `\\\\\&' `\\&' a literal `\&' + `\\\\\\&' `\\\&' a literal `\\&' + `\\q' `\q' a literal `\q' + +Table 9.1: Historical Escape Sequence Processing for `sub()' and +`gsub()' + +This table shows both the lexical-level processing, where an odd number +of backslashes becomes an even number at the runtime level, as well as +the runtime processing done by `sub()'. (For the sake of simplicity, +the rest of the following tables only show the case of even numbers of +backslashes entered at the lexical level.) + + The problem with the historical approach is that there is no way to +get a literal `\' followed by the matched text. + + The 1992 POSIX standard attempted to fix this problem. That standard +says that `sub()' and `gsub()' look for either a `\' or an `&' after +the `\'. If either one follows a `\', that character is output +literally. The interpretation of `\' and `&' then becomes as shown in +*note table-sub-posix-92::. + + You type `sub()' sees `sub()' generates + ------- --------- -------------- + `&' `&' the matched text + `\\&' `\&' a literal `&' + `\\\\&' `\\&' a literal `\', then the matched text + `\\\\\\&' `\\\&' a literal `\&' + +Table 9.2: 1992 POSIX Rules for sub and gsub Escape Sequence Processing + +This appears to solve the problem. Unfortunately, the phrasing of the +standard is unusual. It says, in effect, that `\' turns off the special +meaning of any following character, but for anything other than `\' and +`&', such special meaning is undefined. This wording leads to two +problems: + + * Backslashes must now be doubled in the REPLACEMENT string, breaking + historical `awk' programs. + + * To make sure that an `awk' program is portable, _every_ character + in the REPLACEMENT string must be preceded with a backslash.(1) + + Because of the problems just listed, in 1996, the `gawk' maintainer +submitted proposed text for a revised standard that reverts to rules +that correspond more closely to the original existing practice. The +proposed rules have special cases that make it possible to produce a +`\' preceding the matched text. This is shown in *note +table-sub-proposed::. + + You type `sub()' sees `sub()' generates + ------- --------- -------------- + `\\\\\\&' `\\\&' a literal `\&' + `\\\\&' `\\&' a literal `\', followed by the matched text + `\\&' `\&' a literal `&' + `\\q' `\q' a literal `\q' + `\\\\' `\\' `\\' + +Table 9.3: Proposed rules for sub and backslash + + In a nutshell, at the runtime level, there are now three special +sequences of characters (`\\\&', `\\&' and `\&') whereas historically +there was only one. However, as in the historical case, any `\' that +is not part of one of these three sequences is not special and appears +in the output literally. + + `gawk' 3.0 and 3.1 follow these proposed POSIX rules for `sub()' and +`gsub()'. The POSIX standard took much longer to be revised than was +expected in 1996. The 2001 standard does not follow the above rules. +Instead, the rules there are somewhat simpler. The results are similar +except for one case. + + The POSIX rules state that `\&' in the replacement string produces a +literal `&', `\\' produces a literal `\', and `\' followed by anything +else is not special; the `\' is placed straight into the output. These +rules are presented in *note table-posix-sub::. + + You type `sub()' sees `sub()' generates + ------- --------- -------------- + `\\\\\\&' `\\\&' a literal `\&' + `\\\\&' `\\&' a literal `\', followed by the matched text + `\\&' `\&' a literal `&' + `\\q' `\q' a literal `\q' + `\\\\' `\\' `\' + +Table 9.4: POSIX rules for `sub()' and `gsub()' + + The only case where the difference is noticeable is the last one: +`\\\\' is seen as `\\' and produces `\' instead of `\\'. + + Starting with version 3.1.4, `gawk' followed the POSIX rules when +`--posix' is specified (*note Options::). Otherwise, it continued to +follow the 1996 proposed rules, since that had been its behavior for +many years. + + When version 4.0.0, was released, the `gawk' maintainer made the +POSIX rules the default, breaking well over a decade's worth of +backwards compatibility.(2) Needless to say, this was a bad idea, and +as of version 4.0.1, `gawk' resumed its historical behavior, and only +follows the POSIX rules when `--posix' is given. + + The rules for `gensub()' are considerably simpler. At the runtime +level, whenever `gawk' sees a `\', if the following character is a +digit, then the text that matched the corresponding parenthesized +subexpression is placed in the generated output. Otherwise, no matter +what character follows the `\', it appears in the generated text and +the `\' does not, as shown in *note table-gensub-escapes::. + + You type `gensub()' sees `gensub()' generates + ------- ------------ ----------------- + `&' `&' the matched text + `\\&' `\&' a literal `&' + `\\\\' `\\' a literal `\' + `\\\\&' `\\&' a literal `\', then the matched text + `\\\\\\&' `\\\&' a literal `\&' + `\\q' `\q' a literal `q' + +Table 9.5: Escape Sequence Processing for `gensub()' + + Because of the complexity of the lexical and runtime level processing +and the special cases for `sub()' and `gsub()', we recommend the use of +`gawk' and `gensub()' when you have to do substitutions. + +Advanced Notes: Matching the Null String +---------------------------------------- + +In `awk', the `*' operator can match the null string. This is +particularly important for the `sub()', `gsub()', and `gensub()' +functions. For example: + + $ echo abc | awk '{ gsub(/m*/, "X"); print }' + -| XaXbXcX + +Although this makes a certain amount of sense, it can be surprising. + + ---------- Footnotes ---------- + + (1) This consequence was certainly unintended. + + (2) This was rather naive of him, despite there being a note in this +section indicating that the next major version would move to the POSIX +rules. + + +File: gawk.info, Node: I/O Functions, Next: Time Functions, Prev: String Functions, Up: Built-in + +9.1.4 Input/Output Functions +---------------------------- + +The following functions relate to input/output (I/O). Optional +parameters are enclosed in square brackets ([ ]): + +`close(FILENAME [, HOW])' + Close the file FILENAME for input or output. Alternatively, the + argument may be a shell command that was used for creating a + coprocess, or for redirecting to or from a pipe; then the + coprocess or pipe is closed. *Note Close Files And Pipes::, for + more information. + + When closing a coprocess, it is occasionally useful to first close + one end of the two-way pipe and then to close the other. This is + done by providing a second argument to `close()'. This second + argument should be one of the two string values `"to"' or `"from"', + indicating which end of the pipe to close. Case in the string does + not matter. *Note Two-way I/O::, which discusses this feature in + more detail and gives an example. + +`fflush([FILENAME])' + Flush any buffered output associated with FILENAME, which is + either a file opened for writing or a shell command for + redirecting output to a pipe or coprocess. (c.e.). + + Many utility programs "buffer" their output; i.e., they save + information to write to a disk file or the screen in memory until + there is enough for it to be worthwhile to send the data to the + output device. This is often more efficient than writing every + little bit of information as soon as it is ready. However, + sometimes it is necessary to force a program to "flush" its + buffers; that is, write the information to its destination, even + if a buffer is not full. This is the purpose of the `fflush()' + function--`gawk' also buffers its output and the `fflush()' + function forces `gawk' to flush its buffers. + + `fflush()' was added to Brian Kernighan's version of `awk' in + 1994; it is not part of the POSIX standard and is not available if + `--posix' has been specified on the command line (*note Options::). + + `gawk' extends the `fflush()' function in two ways. The first is + to allow no argument at all. In this case, the buffer for the + standard output is flushed. The second is to allow the null string + (`""') as the argument. In this case, the buffers for _all_ open + output files and pipes are flushed. Brian Kernighan's `awk' also + supports these extensions. + + `fflush()' returns zero if the buffer is successfully flushed; + otherwise, it returns -1. In the case where all buffers are + flushed, the return value is zero only if all buffers were flushed + successfully. Otherwise, it is -1, and `gawk' warns about the + problem FILENAME. + + `gawk' also issues a warning message if you attempt to flush a + file or pipe that was opened for reading (such as with `getline'), + or if FILENAME is not an open file, pipe, or coprocess. In such a + case, `fflush()' returns -1, as well. + +`system(COMMAND)' + Execute the operating-system command COMMAND and then return to + the `awk' program. Return COMMAND's exit status. + + For example, if the following fragment of code is put in your `awk' + program: + + END { + system("date | mail -s 'awk run done' root") + } + + the system administrator is sent mail when the `awk' program + finishes processing input and begins its end-of-input processing. + + Note that redirecting `print' or `printf' into a pipe is often + enough to accomplish your task. If you need to run many commands, + it is more efficient to simply print them down a pipeline to the + shell: + + while (MORE STUFF TO DO) + print COMMAND | "/bin/sh" + close("/bin/sh") + + However, if your `awk' program is interactive, `system()' is + useful for running large self-contained programs, such as a shell + or an editor. Some operating systems cannot implement the + `system()' function. `system()' causes a fatal error if it is not + supported. + + NOTE: When `--sandbox' is specified, the `system()' function + is disabled (*note Options::). + + +Advanced Notes: Interactive Versus Noninteractive Buffering +----------------------------------------------------------- + +As a side point, buffering issues can be even more confusing, depending +upon whether your program is "interactive", i.e., communicating with a +user sitting at a keyboard.(1) + + Interactive programs generally "line buffer" their output; i.e., they +write out every line. Noninteractive programs wait until they have a +full buffer, which may be many lines of output. Here is an example of +the difference: + + $ awk '{ print $1 + $2 }' + 1 1 + -| 2 + 2 3 + -| 5 + Ctrl-d + +Each line of output is printed immediately. Compare that behavior with +this example: + + $ awk '{ print $1 + $2 }' | cat + 1 1 + 2 3 + Ctrl-d + -| 2 + -| 5 + +Here, no output is printed until after the `Ctrl-d' is typed, because +it is all buffered and sent down the pipe to `cat' in one shot. + +Advanced Notes: Controlling Output Buffering with `system()' +------------------------------------------------------------ + +The `fflush()' function provides explicit control over output buffering +for individual files and pipes. However, its use is not portable to +many other `awk' implementations. An alternative method to flush output +buffers is to call `system()' with a null string as its argument: + + system("") # flush output + +`gawk' treats this use of the `system()' function as a special case and +is smart enough not to run a shell (or other command interpreter) with +the empty command. Therefore, with `gawk', this idiom is not only +useful, it is also efficient. While this method should work with other +`awk' implementations, it does not necessarily avoid starting an +unnecessary shell. (Other implementations may only flush the buffer +associated with the standard output and not necessarily all buffered +output.) + + If you think about what a programmer expects, it makes sense that +`system()' should flush any pending output. The following program: + + BEGIN { + print "first print" + system("echo system echo") + print "second print" + } + +must print: + + first print + system echo + second print + +and not: + + system echo + first print + second print + + If `awk' did not flush its buffers before calling `system()', you +would see the latter (undesirable) output. + + ---------- Footnotes ---------- + + (1) A program is interactive if the standard output is connected to +a terminal device. On modern systems, this means your keyboard and +screen. + + +File: gawk.info, Node: Time Functions, Next: Bitwise Functions, Prev: I/O Functions, Up: Built-in + +9.1.5 Time Functions +-------------------- + +`awk' programs are commonly used to process log files containing +timestamp information, indicating when a particular log record was +written. Many programs log their timestamp in the form returned by the +`time()' system call, which is the number of seconds since a particular +epoch. On POSIX-compliant systems, it is the number of seconds since +1970-01-01 00:00:00 UTC, not counting leap seconds.(1) All known +POSIX-compliant systems support timestamps from 0 through 2^31 - 1, +which is sufficient to represent times through 2038-01-19 03:14:07 UTC. +Many systems support a wider range of timestamps, including negative +timestamps that represent times before the epoch. + + In order to make it easier to process such log files and to produce +useful reports, `gawk' provides the following functions for working +with timestamps. They are `gawk' extensions; they are not specified in +the POSIX standard, nor are they in any other known version of `awk'.(2) +Optional parameters are enclosed in square brackets ([ ]): + +`mktime(DATESPEC)' + Turn DATESPEC into a timestamp in the same form as is returned by + `systime()'. It is similar to the function of the same name in + ISO C. The argument, DATESPEC, is a string of the form + `"YYYY MM DD HH MM SS [DST]"'. The string consists of six or + seven numbers representing, respectively, the full year including + century, the month from 1 to 12, the day of the month from 1 to + 31, the hour of the day from 0 to 23, the minute from 0 to 59, the + second from 0 to 60,(3) and an optional daylight-savings flag. + + The values of these numbers need not be within the ranges + specified; for example, an hour of -1 means 1 hour before midnight. + The origin-zero Gregorian calendar is assumed, with year 0 + preceding year 1 and year -1 preceding year 0. The time is + assumed to be in the local timezone. If the daylight-savings flag + is positive, the time is assumed to be daylight savings time; if + zero, the time is assumed to be standard time; and if negative + (the default), `mktime()' attempts to determine whether daylight + savings time is in effect for the specified time. + + If DATESPEC does not contain enough elements or if the resulting + time is out of range, `mktime()' returns -1. + +`strftime([FORMAT [, TIMESTAMP [, UTC-FLAG]]])' + Format the time specified by TIMESTAMP based on the contents of + the FORMAT string and return the result. It is similar to the + function of the same name in ISO C. If UTC-FLAG is present and is + either nonzero or non-null, the value is formatted as UTC + (Coordinated Universal Time, formerly GMT or Greenwich Mean Time). + Otherwise, the value is formatted for the local time zone. The + TIMESTAMP is in the same format as the value returned by the + `systime()' function. If no TIMESTAMP argument is supplied, + `gawk' uses the current time of day as the timestamp. If no + FORMAT argument is supplied, `strftime()' uses the value of + `PROCINFO["strftime"]' as the format string (*note Built-in + Variables::). The default string value is + `"%a %b %e %H:%M:%S %Z %Y"'. This format string produces output + that is equivalent to that of the `date' utility. You can assign + a new value to `PROCINFO["strftime"]' to change the default format. + +`systime()' + Return the current time as the number of seconds since the system + epoch. On POSIX systems, this is the number of seconds since + 1970-01-01 00:00:00 UTC, not counting leap seconds. It may be a + different number on other systems. + + The `systime()' function allows you to compare a timestamp from a +log file with the current time of day. In particular, it is easy to +determine how long ago a particular record was logged. It also allows +you to produce log records using the "seconds since the epoch" format. + + The `mktime()' function allows you to convert a textual +representation of a date and time into a timestamp. This makes it +easy to do before/after comparisons of dates and times, particularly +when dealing with date and time data coming from an external source, +such as a log file. + + The `strftime()' function allows you to easily turn a timestamp into +human-readable information. It is similar in nature to the `sprintf()' +function (*note String Functions::), in that it copies nonformat +specification characters verbatim to the returned string, while +substituting date and time values for format specifications in the +FORMAT string. + + `strftime()' is guaranteed by the 1999 ISO C standard(4) to support +the following date format specifications: + +`%a' + The locale's abbreviated weekday name. + +`%A' + The locale's full weekday name. + +`%b' + The locale's abbreviated month name. + +`%B' + The locale's full month name. + +`%c' + The locale's "appropriate" date and time representation. (This is + `%A %B %d %T %Y' in the `"C"' locale.) + +`%C' + The century part of the current year. This is the year divided by + 100 and truncated to the next lower integer. + +`%d' + The day of the month as a decimal number (01-31). + +`%D' + Equivalent to specifying `%m/%d/%y'. + +`%e' + The day of the month, padded with a space if it is only one digit. + +`%F' + Equivalent to specifying `%Y-%m-%d'. This is the ISO 8601 date + format. + +`%g' + The year modulo 100 of the ISO 8601 week number, as a decimal + number (00-99). For example, January 1, 1993 is in week 53 of + 1992. Thus, the year of its ISO 8601 week number is 1992, even + though its year is 1993. Similarly, December 31, 1973 is in week + 1 of 1974. Thus, the year of its ISO week number is 1974, even + though its year is 1973. + +`%G' + The full year of the ISO week number, as a decimal number. + +`%h' + Equivalent to `%b'. + +`%H' + The hour (24-hour clock) as a decimal number (00-23). + +`%I' + The hour (12-hour clock) as a decimal number (01-12). + +`%j' + The day of the year as a decimal number (001-366). + +`%m' + The month as a decimal number (01-12). + +`%M' + The minute as a decimal number (00-59). + +`%n' + A newline character (ASCII LF). + +`%p' + The locale's equivalent of the AM/PM designations associated with + a 12-hour clock. + +`%r' + The locale's 12-hour clock time. (This is `%I:%M:%S %p' in the + `"C"' locale.) + +`%R' + Equivalent to specifying `%H:%M'. + +`%S' + The second as a decimal number (00-60). + +`%t' + A TAB character. + +`%T' + Equivalent to specifying `%H:%M:%S'. + +`%u' + The weekday as a decimal number (1-7). Monday is day one. + +`%U' + The week number of the year (the first Sunday as the first day of + week one) as a decimal number (00-53). + +`%V' + The week number of the year (the first Monday as the first day of + week one) as a decimal number (01-53). The method for determining + the week number is as specified by ISO 8601. (To wit: if the week + containing January 1 has four or more days in the new year, then + it is week one; otherwise it is week 53 of the previous year and + the next week is week one.) + +`%w' + The weekday as a decimal number (0-6). Sunday is day zero. + +`%W' + The week number of the year (the first Monday as the first day of + week one) as a decimal number (00-53). + +`%x' + The locale's "appropriate" date representation. (This is `%A %B + %d %Y' in the `"C"' locale.) + +`%X' + The locale's "appropriate" time representation. (This is `%T' in + the `"C"' locale.) + +`%y' + The year modulo 100 as a decimal number (00-99). + +`%Y' + The full year as a decimal number (e.g., 2011). + +`%z' + The timezone offset in a +HHMM format (e.g., the format necessary + to produce RFC 822/RFC 1036 date headers). + +`%Z' + The time zone name or abbreviation; no characters if no time zone + is determinable. + +`%Ec %EC %Ex %EX %Ey %EY %Od %Oe %OH' +`%OI %Om %OM %OS %Ou %OU %OV %Ow %OW %Oy' + "Alternate representations" for the specifications that use only + the second letter (`%c', `%C', and so on).(5) (These facilitate + compliance with the POSIX `date' utility.) + +`%%' + A literal `%'. + + If a conversion specifier is not one of the above, the behavior is +undefined.(6) + + Informally, a "locale" is the geographic place in which a program is +meant to run. For example, a common way to abbreviate the date +September 4, 2012 in the United States is "9/4/12." In many countries +in Europe, however, it is abbreviated "4.9.12." Thus, the `%x' +specification in a `"US"' locale might produce `9/4/12', while in a +`"EUROPE"' locale, it might produce `4.9.12'. The ISO C standard +defines a default `"C"' locale, which is an environment that is typical +of what many C programmers are used to. + + For systems that are not yet fully standards-compliant, `gawk' +supplies a copy of `strftime()' from the GNU C Library. It supports +all of the just-listed format specifications. If that version is used +to compile `gawk' (*note Installation::), then the following additional +format specifications are available: + +`%k' + The hour (24-hour clock) as a decimal number (0-23). Single-digit + numbers are padded with a space. + +`%l' + The hour (12-hour clock) as a decimal number (1-12). Single-digit + numbers are padded with a space. + +`%s' + The time as a decimal timestamp in seconds since the epoch. + + + Additionally, the alternate representations are recognized but their +normal representations are used. + + The following example is an `awk' implementation of the POSIX `date' +utility. Normally, the `date' utility prints the current date and time +of day in a well-known format. However, if you provide an argument to +it that begins with a `+', `date' copies nonformat specifier characters +to the standard output and interprets the current time according to the +format specifiers in the string. For example: + + $ date '+Today is %A, %B %d, %Y.' + -| Today is Wednesday, March 30, 2011. + + Here is the `gawk' version of the `date' utility. It has a shell +"wrapper" to handle the `-u' option, which requires that `date' run as +if the time zone is set to UTC: + + #! /bin/sh + # + # date --- approximate the POSIX 'date' command + + case $1 in + -u) TZ=UTC0 # use UTC + export TZ + shift ;; + esac + + gawk 'BEGIN { + format = "%a %b %e %H:%M:%S %Z %Y" + exitval = 0 + + if (ARGC > 2) + exitval = 1 + else if (ARGC == 2) { + format = ARGV[1] + if (format ~ /^\+/) + format = substr(format, 2) # remove leading + + } + print strftime(format) + exit exitval + }' "$@" + + ---------- Footnotes ---------- + + (1) *Note Glossary::, especially the entries "Epoch" and "UTC." + + (2) The GNU `date' utility can also do many of the things described +here. Its use may be preferable for simple time-related operations in +shell scripts. + + (3) Occasionally there are minutes in a year with a leap second, +which is why the seconds can go up to 60. + + (4) Unfortunately, not every system's `strftime()' necessarily +supports all of the conversions listed here. + + (5) If you don't understand any of this, don't worry about it; these +facilities are meant to make it easier to "internationalize" programs. +Other internationalization features are described in *note +Internationalization::. + + (6) This is because ISO C leaves the behavior of the C version of +`strftime()' undefined and `gawk' uses the system's version of +`strftime()' if it's there. Typically, the conversion specifier either +does not appear in the returned string or appears literally. + + +File: gawk.info, Node: Bitwise Functions, Next: Type Functions, Prev: Time Functions, Up: Built-in + +9.1.6 Bit-Manipulation Functions +-------------------------------- + + I can explain it for you, but I can't understand it for you. + Anonymous + + Many languages provide the ability to perform "bitwise" operations +on two integer numbers. In other words, the operation is performed on +each successive pair of bits in the operands. Three common operations +are bitwise AND, OR, and XOR. The operations are described in *note +table-bitwise-ops::. + + Bit Operator + | AND | OR | XOR + |--+--+--+--+--+-- + Operands | 0 | 1 | 0 | 1 | 0 | 1 + ---------+--+--+--+--+--+-- + 0 | 0 0 | 0 1 | 0 1 + 1 | 0 1 | 1 1 | 1 0 + +Table 9.6: Bitwise Operations + + As you can see, the result of an AND operation is 1 only when _both_ +bits are 1. The result of an OR operation is 1 if _either_ bit is 1. +The result of an XOR operation is 1 if either bit is 1, but not both. +The next operation is the "complement"; the complement of 1 is 0 and +the complement of 0 is 1. Thus, this operation "flips" all the bits of +a given value. + + Finally, two other common operations are to shift the bits left or +right. For example, if you have a bit string `10111001' and you shift +it right by three bits, you end up with `00010111'.(1) If you start over +again with `10111001' and shift it left by three bits, you end up with +`11001000'. `gawk' provides built-in functions that implement the +bitwise operations just described. They are: + +`and(V1, V2)' + Return the bitwise AND of the values provided by V1 and V2. + +`compl(VAL)' + Return the bitwise complement of VAL. + +`lshift(VAL, COUNT)' + Return the value of VAL, shifted left by COUNT bits. + +`or(V1, V2)' + Return the bitwise OR of the values provided by V1 and V2. + +`rshift(VAL, COUNT)' + Return the value of VAL, shifted right by COUNT bits. + +`xor(V1, V2)' + Return the bitwise XOR of the values provided by V1 and V2. + + For all of these functions, first the double precision +floating-point value is converted to the widest C unsigned integer +type, then the bitwise operation is performed. If the result cannot be +represented exactly as a C `double', leading nonzero bits are removed +one by one until it can be represented exactly. The result is then +converted back into a C `double'. (If you don't understand this +paragraph, don't worry about it.) + + Here is a user-defined function (*note User-defined::) that +illustrates the use of these functions: + + # bits2str --- turn a byte into readable 1's and 0's + + function bits2str(bits, data, mask) + { + if (bits == 0) + return "0" + + mask = 1 + for (; bits != 0; bits = rshift(bits, 1)) + data = (and(bits, mask) ? "1" : "0") data + + while ((length(data) % 8) != 0) + data = "0" data + + return data + } + + BEGIN { + printf "123 = %s\n", bits2str(123) + printf "0123 = %s\n", bits2str(0123) + printf "0x99 = %s\n", bits2str(0x99) + comp = compl(0x99) + printf "compl(0x99) = %#x = %s\n", comp, bits2str(comp) + shift = lshift(0x99, 2) + printf "lshift(0x99, 2) = %#x = %s\n", shift, bits2str(shift) + shift = rshift(0x99, 2) + printf "rshift(0x99, 2) = %#x = %s\n", shift, bits2str(shift) + } + +This program produces the following output when run: + + $ gawk -f testbits.awk + -| 123 = 01111011 + -| 0123 = 01010011 + -| 0x99 = 10011001 + -| compl(0x99) = 0xffffff66 = 11111111111111111111111101100110 + -| lshift(0x99, 2) = 0x264 = 0000001001100100 + -| rshift(0x99, 2) = 0x26 = 00100110 + + The `bits2str()' function turns a binary number into a string. The +number `1' represents a binary value where the rightmost bit is set to +1. Using this mask, the function repeatedly checks the rightmost bit. +ANDing the mask with the value indicates whether the rightmost bit is 1 +or not. If so, a `"1"' is concatenated onto the front of the string. +Otherwise, a `"0"' is added. The value is then shifted right by one +bit and the loop continues until there are no more 1 bits. + + If the initial value is zero it returns a simple `"0"'. Otherwise, +at the end, it pads the value with zeros to represent multiples of +8-bit quantities. This is typical in modern computers. + + The main code in the `BEGIN' rule shows the difference between the +decimal and octal values for the same numbers (*note +Nondecimal-numbers::), and then demonstrates the results of the +`compl()', `lshift()', and `rshift()' functions. + + ---------- Footnotes ---------- + + (1) This example shows that 0's come in on the left side. For +`gawk', this is always true, but in some languages, it's possible to +have the left side fill with 1's. Caveat emptor. + + +File: gawk.info, Node: Type Functions, Next: I18N Functions, Prev: Bitwise Functions, Up: Built-in + +9.1.7 Getting Type Information +------------------------------ + +`gawk' provides a single function that lets you distinguish an array +from a scalar variable. This is necessary for writing code that +traverses every element of a true multidimensional array (*note Arrays +of Arrays::). + +`isarray(X)' + Return a true value if X is an array. Otherwise return false. + + +File: gawk.info, Node: I18N Functions, Prev: Type Functions, Up: Built-in + +9.1.8 String-Translation Functions +---------------------------------- + +`gawk' provides facilities for internationalizing `awk' programs. +These include the functions described in the following list. The +descriptions here are purposely brief. *Note Internationalization::, +for the full story. Optional parameters are enclosed in square +brackets ([ ]): + +`bindtextdomain(DIRECTORY [, DOMAIN])' + Set the directory in which `gawk' will look for message + translation files, in case they will not or cannot be placed in + the "standard" locations (e.g., during testing). It returns the + directory in which DOMAIN is "bound." + + The default DOMAIN is the value of `TEXTDOMAIN'. If DIRECTORY is + the null string (`""'), then `bindtextdomain()' returns the + current binding for the given DOMAIN. + +`dcgettext(STRING [, DOMAIN [, CATEGORY]])' + Return the translation of STRING in text domain DOMAIN for locale + category CATEGORY. The default value for DOMAIN is the current + value of `TEXTDOMAIN'. The default value for CATEGORY is + `"LC_MESSAGES"'. + +`dcngettext(STRING1, STRING2, NUMBER [, DOMAIN [, CATEGORY]])' + Return the plural form used for NUMBER of the translation of + STRING1 and STRING2 in text domain DOMAIN for locale category + CATEGORY. STRING1 is the English singular variant of a message, + and STRING2 the English plural variant of the same message. The + default value for DOMAIN is the current value of `TEXTDOMAIN'. + The default value for CATEGORY is `"LC_MESSAGES"'. + + +File: gawk.info, Node: User-defined, Next: Indirect Calls, Prev: Built-in, Up: Functions + +9.2 User-Defined Functions +========================== + +Complicated `awk' programs can often be simplified by defining your own +functions. User-defined functions can be called just like built-in +ones (*note Function Calls::), but it is up to you to define them, +i.e., to tell `awk' what they should do. + +* Menu: + +* Definition Syntax:: How to write definitions and what they mean. +* Function Example:: An example function definition and what it + does. +* Function Caveats:: Things to watch out for. +* Return Statement:: Specifying the value a function returns. +* Dynamic Typing:: How variable types can change at runtime. + + +File: gawk.info, Node: Definition Syntax, Next: Function Example, Up: User-defined + +9.2.1 Function Definition Syntax +-------------------------------- + +Definitions of functions can appear anywhere between the rules of an +`awk' program. Thus, the general form of an `awk' program is extended +to include sequences of rules _and_ user-defined function definitions. +There is no need to put the definition of a function before all uses of +the function. This is because `awk' reads the entire program before +starting to execute any of it. + + The definition of a function named NAME looks like this: + + function NAME([PARAMETER-LIST]) + { + BODY-OF-FUNCTION + } + +Here, NAME is the name of the function to define. A valid function +name is like a valid variable name: a sequence of letters, digits, and +underscores that doesn't start with a digit. Within a single `awk' +program, any particular name can only be used as a variable, array, or +function. + + PARAMETER-LIST is an optional list of the function's arguments and +local variable names, separated by commas. When the function is called, +the argument names are used to hold the argument values given in the +call. The local variables are initialized to the empty string. A +function cannot have two parameters with the same name, nor may it have +a parameter with the same name as the function itself. + + In addition, according to the POSIX standard, function parameters +cannot have the same name as one of the special built-in variables +(*note Built-in Variables::. Not all versions of `awk' enforce this +restriction. + + The BODY-OF-FUNCTION consists of `awk' statements. It is the most +important part of the definition, because it says what the function +should actually _do_. The argument names exist to give the body a way +to talk about the arguments; local variables exist to give the body +places to keep temporary values. + + Argument names are not distinguished syntactically from local +variable names. Instead, the number of arguments supplied when the +function is called determines how many argument variables there are. +Thus, if three argument values are given, the first three names in +PARAMETER-LIST are arguments and the rest are local variables. + + It follows that if the number of arguments is not the same in all +calls to the function, some of the names in PARAMETER-LIST may be +arguments on some occasions and local variables on others. Another way +to think of this is that omitted arguments default to the null string. + + Usually when you write a function, you know how many names you +intend to use for arguments and how many you intend to use as local +variables. It is conventional to place some extra space between the +arguments and the local variables, in order to document how your +function is supposed to be used. + + During execution of the function body, the arguments and local +variable values hide, or "shadow", any variables of the same names used +in the rest of the program. The shadowed variables are not accessible +in the function definition, because there is no way to name them while +their names have been taken away for the local variables. All other +variables used in the `awk' program can be referenced or set normally +in the function's body. + + The arguments and local variables last only as long as the function +body is executing. Once the body finishes, you can once again access +the variables that were shadowed while the function was running. + + The function body can contain expressions that call functions. They +can even call this function, either directly or by way of another +function. When this happens, we say the function is "recursive". The +act of a function calling itself is called "recursion". + + All the built-in functions return a value to their caller. +User-defined functions can do also, using the `return' statement, which +is described in detail in *note Return Statement::. Many of the +subsequent examples in this minor node use the `return' statement. + + In many `awk' implementations, including `gawk', the keyword +`function' may be abbreviated `func'. (c.e.) However, POSIX only +specifies the use of the keyword `function'. This actually has some +practical implications. If `gawk' is in POSIX-compatibility mode +(*note Options::), then the following statement does _not_ define a +function: + + func foo() { a = sqrt($1) ; print a } + +Instead it defines a rule that, for each record, concatenates the value +of the variable `func' with the return value of the function `foo'. If +the resulting string is non-null, the action is executed. This is +probably not what is desired. (`awk' accepts this input as +syntactically valid, because functions may be used before they are +defined in `awk' programs.(1)) + + To ensure that your `awk' programs are portable, always use the +keyword `function' when defining a function. + + ---------- Footnotes ---------- + + (1) This program won't actually run, since `foo()' is undefined. + + +File: gawk.info, Node: Function Example, Next: Function Caveats, Prev: Definition Syntax, Up: User-defined + +9.2.2 Function Definition Examples +---------------------------------- + +Here is an example of a user-defined function, called `myprint()', that +takes a number and prints it in a specific format: + + function myprint(num) + { + printf "%6.3g\n", num + } + +To illustrate, here is an `awk' rule that uses our `myprint' function: + + $3 > 0 { myprint($3) } + +This program prints, in our special format, all the third fields that +contain a positive number in our input. Therefore, when given the +following input: + + 1.2 3.4 5.6 7.8 + 9.10 11.12 -13.14 15.16 + 17.18 19.20 21.22 23.24 + +this program, using our function to format the results, prints: + + 5.6 + 21.2 + + This function deletes all the elements in an array: + + function delarray(a, i) + { + for (i in a) + delete a[i] + } + + When working with arrays, it is often necessary to delete all the +elements in an array and start over with a new list of elements (*note +Delete::). Instead of having to repeat this loop everywhere that you +need to clear out an array, your program can just call `delarray'. +(This guarantees portability. The use of `delete ARRAY' to delete the +contents of an entire array is a nonstandard extension.) + + The following is an example of a recursive function. It takes a +string as an input parameter and returns the string in backwards order. +Recursive functions must always have a test that stops the recursion. +In this case, the recursion terminates when the starting position is +zero, i.e., when there are no more characters left in the string. + + function rev(str, start) + { + if (start == 0) + return "" + + return (substr(str, start, 1) rev(str, start - 1)) + } + + If this function is in a file named `rev.awk', it can be tested this +way: + + $ echo "Don't Panic!" | + > gawk --source '{ print rev($0, length($0)) }' -f rev.awk + -| !cinaP t'noD + + The C `ctime()' function takes a timestamp and returns it in a +string, formatted in a well-known fashion. The following example uses +the built-in `strftime()' function (*note Time Functions::) to create +an `awk' version of `ctime()': + + # ctime.awk + # + # awk version of C ctime(3) function + + function ctime(ts, format) + { + format = "%a %b %e %H:%M:%S %Z %Y" + if (ts == 0) + ts = systime() # use current time as default + return strftime(format, ts) + } + + +File: gawk.info, Node: Function Caveats, Next: Return Statement, Prev: Function Example, Up: User-defined + +9.2.3 Calling User-Defined Functions +------------------------------------ + +This section describes how to call a user-defined function. + +* Menu: + +* Calling A Function:: Don't use spaces. +* Variable Scope:: Controlling variable scope. +* Pass By Value/Reference:: Passing parameters. + + +File: gawk.info, Node: Calling A Function, Next: Variable Scope, Up: Function Caveats + +9.2.3.1 Writing A Function Call +............................... + +"Calling a function" means causing the function to run and do its job. +A function call is an expression and its value is the value returned by +the function. + + A function call consists of the function name followed by the +arguments in parentheses. `awk' expressions are what you write in the +call for the arguments. Each time the call is executed, these +expressions are evaluated, and the values become the actual arguments. +For example, here is a call to `foo()' with three arguments (the first +being a string concatenation): + + foo(x y, "lose", 4 * z) + + CAUTION: Whitespace characters (spaces and TABs) are not allowed + between the function name and the open-parenthesis of the argument + list. If you write whitespace by mistake, `awk' might think that + you mean to concatenate a variable with an expression in + parentheses. However, it notices that you used a function name + and not a variable name, and reports an error. + + +File: gawk.info, Node: Variable Scope, Next: Pass By Value/Reference, Prev: Calling A Function, Up: Function Caveats + +9.2.3.2 Controlling Variable Scope +.................................. + +There is no way to make a variable local to a `{ ... }' block in `awk', +but you can make a variable local to a function. It is good practice to +do so whenever a variable is needed only in that function. + + To make a variable local to a function, simply declare the variable +as an argument after the actual function arguments (*note Definition +Syntax::). Look at the following example where variable `i' is a +global variable used by both functions `foo()' and `bar()': + + function bar() + { + for (i = 0; i < 3; i++) + print "bar's i=" i + } + + function foo(j) + { + i = j + 1 + print "foo's i=" i + bar() + print "foo's i=" i + } + + BEGIN { + i = 10 + print "top's i=" i + foo(0) + print "top's i=" i + } + + Running this script produces the following, because the `i' in +functions `foo()' and `bar()' and at the top level refer to the same +variable instance: + + top's i=10 + foo's i=1 + bar's i=0 + bar's i=1 + bar's i=2 + foo's i=3 + top's i=3 + + If you want `i' to be local to both `foo()' and `bar()' do as +follows (the extra-space before `i' is a coding convention to indicate +that `i' is a local variable, not an argument): + + function bar( i) + { + for (i = 0; i < 3; i++) + print "bar's i=" i + } + + function foo(j, i) + { + i = j + 1 + print "foo's i=" i + bar() + print "foo's i=" i + } + + BEGIN { + i = 10 + print "top's i=" i + foo(0) + print "top's i=" i + } + + Running the corrected script produces the following: + + top's i=10 + foo's i=1 + bar's i=0 + bar's i=1 + bar's i=2 + foo's i=1 + top's i=10 + + +File: gawk.info, Node: Pass By Value/Reference, Prev: Variable Scope, Up: Function Caveats + +9.2.3.3 Passing Function Arguments By Value Or By Reference +........................................................... + +In `awk', when you declare a function, there is no way to declare +explicitly whether the arguments are passed "by value" or "by +reference". + + Instead the passing convention is determined at runtime when the +function is called according to the following rule: + + * If the argument is an array variable, then it is passed by + reference, + + * Otherwise the argument is passed by value. + + Passing an argument by value means that when a function is called, it +is given a _copy_ of the value of this argument. The caller may use a +variable as the expression for the argument, but the called function +does not know this--it only knows what value the argument had. For +example, if you write the following code: + + foo = "bar" + z = myfunc(foo) + +then you should not think of the argument to `myfunc()' as being "the +variable `foo'." Instead, think of the argument as the string value +`"bar"'. If the function `myfunc()' alters the values of its local +variables, this has no effect on any other variables. Thus, if +`myfunc()' does this: + + function myfunc(str) + { + print str + str = "zzz" + print str + } + +to change its first argument variable `str', it does _not_ change the +value of `foo' in the caller. The role of `foo' in calling `myfunc()' +ended when its value (`"bar"') was computed. If `str' also exists +outside of `myfunc()', the function body cannot alter this outer value, +because it is shadowed during the execution of `myfunc()' and cannot be +seen or changed from there. + + However, when arrays are the parameters to functions, they are _not_ +copied. Instead, the array itself is made available for direct +manipulation by the function. This is usually termed "call by +reference". Changes made to an array parameter inside the body of a +function _are_ visible outside that function. + + NOTE: Changing an array parameter inside a function can be very + dangerous if you do not watch what you are doing. For example: + + function changeit(array, ind, nvalue) + { + array[ind] = nvalue + } + + BEGIN { + a[1] = 1; a[2] = 2; a[3] = 3 + changeit(a, 2, "two") + printf "a[1] = %s, a[2] = %s, a[3] = %s\n", + a[1], a[2], a[3] + } + + prints `a[1] = 1, a[2] = two, a[3] = 3', because `changeit' stores + `"two"' in the second element of `a'. + + Some `awk' implementations allow you to call a function that has not +been defined. They only report a problem at runtime when the program +actually tries to call the function. For example: + + BEGIN { + if (0) + foo() + else + bar() + } + function bar() { ... } + # note that `foo' is not defined + +Because the `if' statement will never be true, it is not really a +problem that `foo()' has not been defined. Usually, though, it is a +problem if a program calls an undefined function. + + If `--lint' is specified (*note Options::), `gawk' reports calls to +undefined functions. + + Some `awk' implementations generate a runtime error if you use the +`next' statement (*note Next Statement::) inside a user-defined +function. `gawk' does not have this limitation. + + +File: gawk.info, Node: Return Statement, Next: Dynamic Typing, Prev: Function Caveats, Up: User-defined + +9.2.4 The `return' Statement +---------------------------- + +As seen in several earlier examples, the body of a user-defined +function can contain a `return' statement. This statement returns +control to the calling part of the `awk' program. It can also be used +to return a value for use in the rest of the `awk' program. It looks +like this: + + return [EXPRESSION] + + The EXPRESSION part is optional. Due most likely to an oversight, +POSIX does not define what the return value is if you omit the +EXPRESSION. Technically speaking, this make the returned value +undefined, and therefore, unpredictable. In practice, though, all +versions of `awk' simply return the null string, which acts like zero +if used in a numeric context. + + A `return' statement with no value expression is assumed at the end +of every function definition. So if control reaches the end of the +function body, then technically, the function returns an unpredictable +value. In practice, it returns the empty string. `awk' does _not_ +warn you if you use the return value of such a function. + + Sometimes, you want to write a function for what it does, not for +what it returns. Such a function corresponds to a `void' function in +C, C++ or Java, or to a `procedure' in Ada. Thus, it may be +appropriate to not return any value; simply bear in mind that you +should not be using the return value of such a function. + + The following is an example of a user-defined function that returns +a value for the largest number among the elements of an array: + + function maxelt(vec, i, ret) + { + for (i in vec) { + if (ret == "" || vec[i] > ret) + ret = vec[i] + } + return ret + } + +You call `maxelt()' with one argument, which is an array name. The +local variables `i' and `ret' are not intended to be arguments; while +there is nothing to stop you from passing more than one argument to +`maxelt()', the results would be strange. The extra space before `i' +in the function parameter list indicates that `i' and `ret' are local +variables. You should follow this convention when defining functions. + + The following program uses the `maxelt()' function. It loads an +array, calls `maxelt()', and then reports the maximum number in that +array: + + function maxelt(vec, i, ret) + { + for (i in vec) { + if (ret == "" || vec[i] > ret) + ret = vec[i] + } + return ret + } + + # Load all fields of each record into nums. + { + for(i = 1; i <= NF; i++) + nums[NR, i] = $i + } + + END { + print maxelt(nums) + } + + Given the following input: + + 1 5 23 8 16 + 44 3 5 2 8 26 + 256 291 1396 2962 100 + -6 467 998 1101 + 99385 11 0 225 + +the program reports (predictably) that 99,385 is the largest value in +the array. + + +File: gawk.info, Node: Dynamic Typing, Prev: Return Statement, Up: User-defined + +9.2.5 Functions and Their Effects on Variable Typing +---------------------------------------------------- + +`awk' is a very fluid language. It is possible that `awk' can't tell +if an identifier represents a scalar variable or an array until runtime. +Here is an annotated sample program: + + function foo(a) + { + a[1] = 1 # parameter is an array + } + + BEGIN { + b = 1 + foo(b) # invalid: fatal type mismatch + + foo(x) # x uninitialized, becomes an array dynamically + x = 1 # now not allowed, runtime error + } + + Usually, such things aren't a big issue, but it's worth being aware +of them. + + +File: gawk.info, Node: Indirect Calls, Prev: User-defined, Up: Functions + +9.3 Indirect Function Calls +=========================== + +This section describes a `gawk'-specific extension. + + Often, you may wish to defer the choice of function to call until +runtime. For example, you may have different kinds of records, each of +which should be processed differently. + + Normally, you would have to use a series of `if'-`else' statements +to decide which function to call. By using "indirect" function calls, +you can specify the name of the function to call as a string variable, +and then call the function. Let's look at an example. + + Suppose you have a file with your test scores for the classes you +are taking. The first field is the class name. The following fields +are the functions to call to process the data, up to a "marker" field +`data:'. Following the marker, to the end of the record, are the +various numeric test scores. + + Here is the initial file; you wish to get the sum and the average of +your test scores: + + Biology_101 sum average data: 87.0 92.4 78.5 94.9 + Chemistry_305 sum average data: 75.2 98.3 94.7 88.2 + English_401 sum average data: 100.0 95.6 87.1 93.4 + + To process the data, you might write initially: + + { + class = $1 + for (i = 2; $i != "data:"; i++) { + if ($i == "sum") + sum() # processes the whole record + else if ($i == "average") + average() + ... # and so on + } + } + +This style of programming works, but can be awkward. With "indirect" +function calls, you tell `gawk' to use the _value_ of a variable as the +name of the function to call. + + The syntax is similar to that of a regular function call: an +identifier immediately followed by a left parenthesis, any arguments, +and then a closing right parenthesis, with the addition of a leading `@' +character: + + the_func = "sum" + result = @the_func() # calls the `sum' function + + Here is a full program that processes the previously shown data, +using indirect function calls. + + # indirectcall.awk --- Demonstrate indirect function calls + + # average --- return the average of the values in fields $first - $last + + function average(first, last, sum, i) + { + sum = 0; + for (i = first; i <= last; i++) + sum += $i + + return sum / (last - first + 1) + } + + # sum --- return the sum of the values in fields $first - $last + + function sum(first, last, ret, i) + { + ret = 0; + for (i = first; i <= last; i++) + ret += $i + + return ret + } + + These two functions expect to work on fields; thus the parameters +`first' and `last' indicate where in the fields to start and end. +Otherwise they perform the expected computations and are not unusual. + + # For each record, print the class name and the requested statistics + + { + class_name = $1 + gsub(/_/, " ", class_name) # Replace _ with spaces + + # find start + for (i = 1; i <= NF; i++) { + if ($i == "data:") { + start = i + 1 + break + } + } + + printf("%s:\n", class_name) + for (i = 2; $i != "data:"; i++) { + the_function = $i + printf("\t%s: <%s>\n", $i, @the_function(start, NF) "") + } + print "" + } + + This is the main processing for each record. It prints the class +name (with underscores replaced with spaces). It then finds the start +of the actual data, saving it in `start'. The last part of the code +loops through each function name (from `$2' up to the marker, `data:'), +calling the function named by the field. The indirect function call +itself occurs as a parameter in the call to `printf'. (The `printf' +format string uses `%s' as the format specifier so that we can use +functions that return strings, as well as numbers. Note that the result +from the indirect call is concatenated with the empty string, in order +to force it to be a string value.) + + Here is the result of running the program: + + $ gawk -f indirectcall.awk class_data1 + -| Biology 101: + -| sum: <352.8> + -| average: <88.2> + -| + -| Chemistry 305: + -| sum: <356.4> + -| average: <89.1> + -| + -| English 401: + -| sum: <376.1> + -| average: <94.025> + + The ability to use indirect function calls is more powerful than you +may think at first. The C and C++ languages provide "function +pointers," which are a mechanism for calling a function chosen at +runtime. One of the most well-known uses of this ability is the C +`qsort()' function, which sorts an array using the famous "quick sort" +algorithm (see the Wikipedia article +(http://en.wikipedia.org/wiki/Quick_sort) for more information). To +use this function, you supply a pointer to a comparison function. This +mechanism allows you to sort arbitrary data in an arbitrary fashion. + + We can do something similar using `gawk', like this: + + # quicksort.awk --- Quicksort algorithm, with user-supplied + # comparison function + # quicksort --- C.A.R. Hoare's quick sort algorithm. See Wikipedia + # or almost any algorithms or computer science text + + function quicksort(data, left, right, less_than, i, last) + { + if (left >= right) # do nothing if array contains fewer + return # than two elements + + quicksort_swap(data, left, int((left + right) / 2)) + last = left + for (i = left + 1; i <= right; i++) + if (@less_than(data[i], data[left])) + quicksort_swap(data, ++last, i) + quicksort_swap(data, left, last) + quicksort(data, left, last - 1, less_than) + quicksort(data, last + 1, right, less_than) + } + + # quicksort_swap --- helper function for quicksort, should really be inline + + function quicksort_swap(data, i, j, temp) + { + temp = data[i] + data[i] = data[j] + data[j] = temp + } + + The `quicksort()' function receives the `data' array, the starting +and ending indices to sort (`left' and `right'), and the name of a +function that performs a "less than" comparison. It then implements +the quick sort algorithm. + + To make use of the sorting function, we return to our previous +example. The first thing to do is write some comparison functions: + + # num_lt --- do a numeric less than comparison + + function num_lt(left, right) + { + return ((left + 0) < (right + 0)) + } + + # num_ge --- do a numeric greater than or equal to comparison + + function num_ge(left, right) + { + return ((left + 0) >= (right + 0)) + } + + The `num_ge()' function is needed to perform a descending sort; when +used to perform a "less than" test, it actually does the opposite +(greater than or equal to), which yields data sorted in descending +order. + + Next comes a sorting function. It is parameterized with the +starting and ending field numbers and the comparison function. It +builds an array with the data and calls `quicksort' appropriately, and +then formats the results as a single string: + + # do_sort --- sort the data according to `compare' + # and return it as a string + + function do_sort(first, last, compare, data, i, retval) + { + delete data + for (i = 1; first <= last; first++) { + data[i] = $first + i++ + } + + quicksort(data, 1, i-1, compare) + + retval = data[1] + for (i = 2; i in data; i++) + retval = retval " " data[i] + + return retval + } + + Finally, the two sorting functions call `do_sort()', passing in the +names of the two comparison functions: + + # sort --- sort the data in ascending order and return it as a string + + function sort(first, last) + { + return do_sort(first, last, "num_lt") + } + + # rsort --- sort the data in descending order and return it as a string + + function rsort(first, last) + { + return do_sort(first, last, "num_ge") + } + + Here is an extended version of the data file: + + Biology_101 sum average sort rsort data: 87.0 92.4 78.5 94.9 + Chemistry_305 sum average sort rsort data: 75.2 98.3 94.7 88.2 + English_401 sum average sort rsort data: 100.0 95.6 87.1 93.4 + + Finally, here are the results when the enhanced program is run: + + $ gawk -f quicksort.awk -f indirectcall.awk class_data2 + -| Biology 101: + -| sum: <352.8> + -| average: <88.2> + -| sort: <78.5 87.0 92.4 94.9> + -| rsort: <94.9 92.4 87.0 78.5> + -| + -| Chemistry 305: + -| sum: <356.4> + -| average: <89.1> + -| sort: <75.2 88.2 94.7 98.3> + -| rsort: <98.3 94.7 88.2 75.2> + -| + -| English 401: + -| sum: <376.1> + -| average: <94.025> + -| sort: <87.1 93.4 95.6 100.0> + -| rsort: <100.0 95.6 93.4 87.1> + + Remember that you must supply a leading `@' in front of an indirect +function call. + + Unfortunately, indirect function calls cannot be used with the +built-in functions. However, you can generally write "wrapper" +functions which call the built-in ones, and those can be called +indirectly. (Other than, perhaps, the mathematical functions, there is +not a lot of reason to try to call the built-in functions indirectly.) + + `gawk' does its best to make indirect function calls efficient. For +example, in the following case: + + for (i = 1; i <= n; i++) + @the_func() + +`gawk' will look up the actual function to call only once. + + +File: gawk.info, Node: Internationalization, Next: Advanced Features, Prev: Functions, Up: Top + +10 Internationalization with `gawk' +*********************************** + +Once upon a time, computer makers wrote software that worked only in +English. Eventually, hardware and software vendors noticed that if +their systems worked in the native languages of non-English-speaking +countries, they were able to sell more systems. As a result, +internationalization and localization of programs and software systems +became a common practice. + + For many years, the ability to provide internationalization was +largely restricted to programs written in C and C++. This major node +describes the underlying library `gawk' uses for internationalization, +as well as how `gawk' makes internationalization features available at +the `awk' program level. Having internationalization available at the +`awk' level gives software developers additional flexibility--they are +no longer forced to write in C or C++ when internationalization is a +requirement. + +* Menu: + +* I18N and L10N:: Internationalization and Localization. +* Explaining gettext:: How GNU `gettext' works. +* Programmer i18n:: Features for the programmer. +* Translator i18n:: Features for the translator. +* I18N Example:: A simple i18n example. +* Gawk I18N:: `gawk' is also internationalized. + + +File: gawk.info, Node: I18N and L10N, Next: Explaining gettext, Up: Internationalization + +10.1 Internationalization and Localization +========================================== + +"Internationalization" means writing (or modifying) a program once, in +such a way that it can use multiple languages without requiring further +source-code changes. "Localization" means providing the data necessary +for an internationalized program to work in a particular language. +Most typically, these terms refer to features such as the language used +for printing error messages, the language used to read responses, and +information related to how numerical and monetary values are printed +and read. + + +File: gawk.info, Node: Explaining gettext, Next: Programmer i18n, Prev: I18N and L10N, Up: Internationalization + +10.2 GNU `gettext' +================== + +The facilities in GNU `gettext' focus on messages; strings printed by a +program, either directly or via formatting with `printf' or +`sprintf()'.(1) + + When using GNU `gettext', each application has its own "text +domain". This is a unique name, such as `kpilot' or `gawk', that +identifies the application. A complete application may have multiple +components--programs written in C or C++, as well as scripts written in +`sh' or `awk'. All of the components use the same text domain. + + To make the discussion concrete, assume we're writing an application +named `guide'. Internationalization consists of the following steps, +in this order: + + 1. The programmer goes through the source for all of `guide''s + components and marks each string that is a candidate for + translation. For example, `"`-F': option required"' is a good + candidate for translation. A table with strings of option names + is not (e.g., `gawk''s `--profile' option should remain the same, + no matter what the local language). + + 2. The programmer indicates the application's text domain (`"guide"') + to the `gettext' library, by calling the `textdomain()' function. + + 3. Messages from the application are extracted from the source code + and collected into a portable object template file (`guide.pot'), + which lists the strings and their translations. The translations + are initially empty. The original (usually English) messages + serve as the key for lookup of the translations. + + 4. For each language with a translator, `guide.pot' is copied to a + portable object file (`.po') and translations are created and + shipped with the application. For example, there might be a + `fr.po' for a French translation. + + 5. Each language's `.po' file is converted into a binary message + object (`.mo') file. A message object file contains the original + messages and their translations in a binary format that allows + fast lookup of translations at runtime. + + 6. When `guide' is built and installed, the binary translation files + are installed in a standard place. + + 7. For testing and development, it is possible to tell `gettext' to + use `.mo' files in a different directory than the standard one by + using the `bindtextdomain()' function. + + 8. At runtime, `guide' looks up each string via a call to + `gettext()'. The returned string is the translated string if + available, or the original string if not. + + 9. If necessary, it is possible to access messages from a different + text domain than the one belonging to the application, without + having to switch the application's default text domain back and + forth. + + In C (or C++), the string marking and dynamic translation lookup are +accomplished by wrapping each string in a call to `gettext()': + + printf("%s", gettext("Don't Panic!\n")); + + The tools that extract messages from source code pull out all +strings enclosed in calls to `gettext()'. + + The GNU `gettext' developers, recognizing that typing `gettext(...)' +over and over again is both painful and ugly to look at, use the macro +`_' (an underscore) to make things easier: + + /* In the standard header file: */ + #define _(str) gettext(str) + + /* In the program text: */ + printf("%s", _("Don't Panic!\n")); + +This reduces the typing overhead to just three extra characters per +string and is considerably easier to read as well. + + There are locale "categories" for different types of locale-related +information. The defined locale categories that `gettext' knows about +are: + +`LC_MESSAGES' + Text messages. This is the default category for `gettext' + operations, but it is possible to supply a different one + explicitly, if necessary. (It is almost never necessary to supply + a different category.) + +`LC_COLLATE' + Text-collation information; i.e., how different characters and/or + groups of characters sort in a given language. + +`LC_CTYPE' + Character-type information (alphabetic, digit, upper- or + lowercase, and so on). This information is accessed via the POSIX + character classes in regular expressions, such as `/[[:alnum:]]/' + (*note Regexp Operators::). + +`LC_MONETARY' + Monetary information, such as the currency symbol, and whether the + symbol goes before or after a number. + +`LC_NUMERIC' + Numeric information, such as which characters to use for the + decimal point and the thousands separator.(2) + +`LC_RESPONSE' + Response information, such as how "yes" and "no" appear in the + local language, and possibly other information as well. + +`LC_TIME' + Time- and date-related information, such as 12- or 24-hour clock, + month printed before or after the day in a date, local month + abbreviations, and so on. + +`LC_ALL' + All of the above. (Not too useful in the context of `gettext'.) + + ---------- Footnotes ---------- + + (1) For some operating systems, the `gawk' port doesn't support GNU +`gettext'. Therefore, these features are not available if you are +using one of those operating systems. Sorry. + + (2) Americans use a comma every three decimal places and a period +for the decimal point, while many Europeans do exactly the opposite: +1,234.56 versus 1.234,56. + + +File: gawk.info, Node: Programmer i18n, Next: Translator i18n, Prev: Explaining gettext, Up: Internationalization + +10.3 Internationalizing `awk' Programs +====================================== + +`gawk' provides the following variables and functions for +internationalization: + +`TEXTDOMAIN' + This variable indicates the application's text domain. For + compatibility with GNU `gettext', the default value is + `"messages"'. + +`_"your message here"' + String constants marked with a leading underscore are candidates + for translation at runtime. String constants without a leading + underscore are not translated. + +`dcgettext(STRING [, DOMAIN [, CATEGORY]])' + Return the translation of STRING in text domain DOMAIN for locale + category CATEGORY. The default value for DOMAIN is the current + value of `TEXTDOMAIN'. The default value for CATEGORY is + `"LC_MESSAGES"'. + + If you supply a value for CATEGORY, it must be a string equal to + one of the known locale categories described in *note Explaining + gettext::. You must also supply a text domain. Use `TEXTDOMAIN' + if you want to use the current domain. + + CAUTION: The order of arguments to the `awk' version of the + `dcgettext()' function is purposely different from the order + for the C version. The `awk' version's order was chosen to + be simple and to allow for reasonable `awk'-style default + arguments. + +`dcngettext(STRING1, STRING2, NUMBER [, DOMAIN [, CATEGORY]])' + Return the plural form used for NUMBER of the translation of + STRING1 and STRING2 in text domain DOMAIN for locale category + CATEGORY. STRING1 is the English singular variant of a message, + and STRING2 the English plural variant of the same message. The + default value for DOMAIN is the current value of `TEXTDOMAIN'. + The default value for CATEGORY is `"LC_MESSAGES"'. + + The same remarks about argument order as for the `dcgettext()' + function apply. + +`bindtextdomain(DIRECTORY [, DOMAIN])' + Change the directory in which `gettext' looks for `.mo' files, in + case they will not or cannot be placed in the standard locations + (e.g., during testing). Return the directory in which DOMAIN is + "bound." + + The default DOMAIN is the value of `TEXTDOMAIN'. If DIRECTORY is + the null string (`""'), then `bindtextdomain()' returns the + current binding for the given DOMAIN. + + To use these facilities in your `awk' program, follow the steps +outlined in *note Explaining gettext::, like so: + + 1. Set the variable `TEXTDOMAIN' to the text domain of your program. + This is best done in a `BEGIN' rule (*note BEGIN/END::), or it can + also be done via the `-v' command-line option (*note Options::): + + BEGIN { + TEXTDOMAIN = "guide" + ... + } + + 2. Mark all translatable strings with a leading underscore (`_') + character. It _must_ be adjacent to the opening quote of the + string. For example: + + print _"hello, world" + x = _"you goofed" + printf(_"Number of users is %d\n", nusers) + + 3. If you are creating strings dynamically, you can still translate + them, using the `dcgettext()' built-in function: + + message = nusers " users logged in" + message = dcgettext(message, "adminprog") + print message + + Here, the call to `dcgettext()' supplies a different text domain + (`"adminprog"') in which to find the message, but it uses the + default `"LC_MESSAGES"' category. + + 4. During development, you might want to put the `.mo' file in a + private directory for testing. This is done with the + `bindtextdomain()' built-in function: + + BEGIN { + TEXTDOMAIN = "guide" # our text domain + if (Testing) { + # where to find our files + bindtextdomain("testdir") + # joe is in charge of adminprog + bindtextdomain("../joe/testdir", "adminprog") + } + ... + } + + + *Note I18N Example::, for an example program showing the steps to +create and use translations from `awk'. + + +File: gawk.info, Node: Translator i18n, Next: I18N Example, Prev: Programmer i18n, Up: Internationalization + +10.4 Translating `awk' Programs +=============================== + +Once a program's translatable strings have been marked, they must be +extracted to create the initial `.po' file. As part of translation, it +is often helpful to rearrange the order in which arguments to `printf' +are output. + + `gawk''s `--gen-pot' command-line option extracts the messages and +is discussed next. After that, `printf''s ability to rearrange the +order for `printf' arguments at runtime is covered. + +* Menu: + +* String Extraction:: Extracting marked strings. +* Printf Ordering:: Rearranging `printf' arguments. +* I18N Portability:: `awk'-level portability issues. + + +File: gawk.info, Node: String Extraction, Next: Printf Ordering, Up: Translator i18n + +10.4.1 Extracting Marked Strings +-------------------------------- + +Once your `awk' program is working, and all the strings have been +marked and you've set (and perhaps bound) the text domain, it is time +to produce translations. First, use the `--gen-pot' command-line +option to create the initial `.pot' file: + + $ gawk --gen-pot -f guide.awk > guide.pot + + When run with `--gen-pot', `gawk' does not execute your program. +Instead, it parses it as usual and prints all marked strings to +standard output in the format of a GNU `gettext' Portable Object file. +Also included in the output are any constant strings that appear as the +first argument to `dcgettext()' or as the first and second argument to +`dcngettext()'.(1) *Note I18N Example::, for the full list of steps to +go through to create and test translations for `guide'. + + ---------- Footnotes ---------- + + (1) The `xgettext' utility that comes with GNU `gettext' can handle +`.awk' files. + + +File: gawk.info, Node: Printf Ordering, Next: I18N Portability, Prev: String Extraction, Up: Translator i18n + +10.4.2 Rearranging `printf' Arguments +------------------------------------- + +Format strings for `printf' and `sprintf()' (*note Printf::) present a +special problem for translation. Consider the following:(1) + + printf(_"String `%s' has %d characters\n", + string, length(string))) + + A possible German translation for this might be: + + "%d Zeichen lang ist die Zeichenkette `%s'\n" + + The problem should be obvious: the order of the format +specifications is different from the original! Even though `gettext()' +can return the translated string at runtime, it cannot change the +argument order in the call to `printf'. + + To solve this problem, `printf' format specifiers may have an +additional optional element, which we call a "positional specifier". +For example: + + "%2$d Zeichen lang ist die Zeichenkette `%1$s'\n" + + Here, the positional specifier consists of an integer count, which +indicates which argument to use, and a `$'. Counts are one-based, and +the format string itself is _not_ included. Thus, in the following +example, `string' is the first argument and `length(string)' is the +second: + + $ gawk 'BEGIN { + > string = "Dont Panic" + > printf _"%2$d characters live in \"%1$s\"\n", + > string, length(string) + > }' + -| 10 characters live in "Dont Panic" + + If present, positional specifiers come first in the format +specification, before the flags, the field width, and/or the precision. + + Positional specifiers can be used with the dynamic field width and +precision capability: + + $ gawk 'BEGIN { + > printf("%*.*s\n", 10, 20, "hello") + > printf("%3$*2$.*1$s\n", 20, 10, "hello") + > }' + -| hello + -| hello + + NOTE: When using `*' with a positional specifier, the `*' comes + first, then the integer position, and then the `$'. This is + somewhat counterintuitive. + + `gawk' does not allow you to mix regular format specifiers and those +with positional specifiers in the same string: + + $ gawk 'BEGIN { printf _"%d %3$s\n", 1, 2, "hi" }' + error--> gawk: cmd. line:1: fatal: must use `count$' on all formats or none + + NOTE: There are some pathological cases that `gawk' may fail to + diagnose. In such cases, the output may not be what you expect. + It's still a bad idea to try mixing them, even if `gawk' doesn't + detect it. + + Although positional specifiers can be used directly in `awk' +programs, their primary purpose is to help in producing correct +translations of format strings into languages different from the one in +which the program is first written. + + ---------- Footnotes ---------- + + (1) This example is borrowed from the GNU `gettext' manual. + + +File: gawk.info, Node: I18N Portability, Prev: Printf Ordering, Up: Translator i18n + +10.4.3 `awk' Portability Issues +------------------------------- + +`gawk''s internationalization features were purposely chosen to have as +little impact as possible on the portability of `awk' programs that use +them to other versions of `awk'. Consider this program: + + BEGIN { + TEXTDOMAIN = "guide" + if (Test_Guide) # set with -v + bindtextdomain("/test/guide/messages") + print _"don't panic!" + } + +As written, it won't work on other versions of `awk'. However, it is +actually almost portable, requiring very little change: + + * Assignments to `TEXTDOMAIN' won't have any effect, since + `TEXTDOMAIN' is not special in other `awk' implementations. + + * Non-GNU versions of `awk' treat marked strings as the + concatenation of a variable named `_' with the string following + it.(1) Typically, the variable `_' has the null string (`""') as + its value, leaving the original string constant as the result. + + * By defining "dummy" functions to replace `dcgettext()', + `dcngettext()' and `bindtextdomain()', the `awk' program can be + made to run, but all the messages are output in the original + language. For example: + + function bindtextdomain(dir, domain) + { + return dir + } + + function dcgettext(string, domain, category) + { + return string + } + + function dcngettext(string1, string2, number, domain, category) + { + return (number == 1 ? string1 : string2) + } + + * The use of positional specifications in `printf' or `sprintf()' is + _not_ portable. To support `gettext()' at the C level, many + systems' C versions of `sprintf()' do support positional + specifiers. But it works only if enough arguments are supplied in + the function call. Many versions of `awk' pass `printf' formats + and arguments unchanged to the underlying C library version of + `sprintf()', but only one format and argument at a time. What + happens if a positional specification is used is anybody's guess. + However, since the positional specifications are primarily for use + in _translated_ format strings, and since non-GNU `awk's never + retrieve the translated string, this should not be a problem in + practice. + + ---------- Footnotes ---------- + + (1) This is good fodder for an "Obfuscated `awk'" contest. + + +File: gawk.info, Node: I18N Example, Next: Gawk I18N, Prev: Translator i18n, Up: Internationalization + +10.5 A Simple Internationalization Example +========================================== + +Now let's look at a step-by-step example of how to internationalize and +localize a simple `awk' program, using `guide.awk' as our original +source: + + BEGIN { + TEXTDOMAIN = "guide" + bindtextdomain(".") # for testing + print _"Don't Panic" + print _"The Answer Is", 42 + print "Pardon me, Zaphod who?" + } + +Run `gawk --gen-pot' to create the `.pot' file: + + $ gawk --gen-pot -f guide.awk > guide.pot + +This produces: + + #: guide.awk:4 + msgid "Don't Panic" + msgstr "" + + #: guide.awk:5 + msgid "The Answer Is" + msgstr "" + + This original portable object template file is saved and reused for +each language into which the application is translated. The `msgid' is +the original string and the `msgstr' is the translation. + + NOTE: Strings not marked with a leading underscore do not appear + in the `guide.pot' file. + + Next, the messages must be translated. Here is a translation to a +hypothetical dialect of English, called "Mellow":(1) + + $ cp guide.pot guide-mellow.po + ADD TRANSLATIONS TO guide-mellow.po ... + +Following are the translations: + + #: guide.awk:4 + msgid "Don't Panic" + msgstr "Hey man, relax!" + + #: guide.awk:5 + msgid "The Answer Is" + msgstr "Like, the scoop is" + + The next step is to make the directory to hold the binary message +object file and then to create the `guide.mo' file. The directory +layout shown here is standard for GNU `gettext' on GNU/Linux systems. +Other versions of `gettext' may use a different layout: + + $ mkdir en_US en_US/LC_MESSAGES + + The `msgfmt' utility does the conversion from human-readable `.po' +file to machine-readable `.mo' file. By default, `msgfmt' creates a +file named `messages'. This file must be renamed and placed in the +proper directory so that `gawk' can find it: + + $ msgfmt guide-mellow.po + $ mv messages en_US/LC_MESSAGES/guide.mo + + Finally, we run the program to test it: + + $ gawk -f guide.awk + -| Hey man, relax! + -| Like, the scoop is 42 + -| Pardon me, Zaphod who? + + If the three replacement functions for `dcgettext()', `dcngettext()' +and `bindtextdomain()' (*note I18N Portability::) are in a file named +`libintl.awk', then we can run `guide.awk' unchanged as follows: + + $ gawk --posix -f guide.awk -f libintl.awk + -| Don't Panic + -| The Answer Is 42 + -| Pardon me, Zaphod who? + + ---------- Footnotes ---------- + + (1) Perhaps it would be better if it were called "Hippy." Ah, well. + + +File: gawk.info, Node: Gawk I18N, Prev: I18N Example, Up: Internationalization + +10.6 `gawk' Can Speak Your Language +=================================== + +`gawk' itself has been internationalized using the GNU `gettext' +package. (GNU `gettext' is described in complete detail in *note (GNU +`gettext' utilities)Top:: gettext, GNU gettext tools.) As of this +writing, the latest version of GNU `gettext' is version 0.18.1 +(ftp://ftp.gnu.org/gnu/gettext/gettext-0.18.1.tar.gz). + + If a translation of `gawk''s messages exists, then `gawk' produces +usage messages, warnings, and fatal errors in the local language. + + +File: gawk.info, Node: Advanced Features, Next: Library Functions, Prev: Internationalization, Up: Top + +11 Advanced Features of `gawk' +****************************** + + Write documentation as if whoever reads it is a violent psychopath + who knows where you live. + Steve English, as quoted by Peter Langston + + This major node discusses advanced features in `gawk'. It's a bit +of a "grab bag" of items that are otherwise unrelated to each other. +First, a command-line option allows `gawk' to recognize nondecimal +numbers in input data, not just in `awk' programs. Then, `gawk''s +special features for sorting arrays are presented. Next, two-way I/O, +discussed briefly in earlier parts of this Info file, is described in +full detail, along with the basics of TCP/IP networking. Finally, +`gawk' can "profile" an `awk' program, making it possible to tune it +for performance. + + *note Dynamic Extensions::, discusses the ability to dynamically add +new built-in functions to `gawk'. As this feature is still immature +and likely to change, its description is relegated to an appendix. + +* Menu: + +* Nondecimal Data:: Allowing nondecimal input data. +* Array Sorting:: Facilities for controlling array traversal and + sorting arrays. +* Two-way I/O:: Two-way communications with another process. +* TCP/IP Networking:: Using `gawk' for network programming. +* Profiling:: Profiling your `awk' programs. + + +File: gawk.info, Node: Nondecimal Data, Next: Array Sorting, Up: Advanced Features + +11.1 Allowing Nondecimal Input Data +=================================== + +If you run `gawk' with the `--non-decimal-data' option, you can have +nondecimal constants in your input data: + + $ echo 0123 123 0x123 | + > gawk --non-decimal-data '{ printf "%d, %d, %d\n", + > $1, $2, $3 }' + -| 83, 123, 291 + + For this feature to work, write your program so that `gawk' treats +your data as numeric: + + $ echo 0123 123 0x123 | gawk '{ print $1, $2, $3 }' + -| 0123 123 0x123 + +The `print' statement treats its expressions as strings. Although the +fields can act as numbers when necessary, they are still strings, so +`print' does not try to treat them numerically. You may need to add +zero to a field to force it to be treated as a number. For example: + + $ echo 0123 123 0x123 | gawk --non-decimal-data ' + > { print $1, $2, $3 + > print $1 + 0, $2 + 0, $3 + 0 }' + -| 0123 123 0x123 + -| 83 123 291 + + Because it is common to have decimal data with leading zeros, and +because using this facility could lead to surprising results, the +default is to leave it disabled. If you want it, you must explicitly +request it. + + CAUTION: _Use of this option is not recommended._ It can break old + programs very badly. Instead, use the `strtonum()' function to + convert your data (*note Nondecimal-numbers::). This makes your + programs easier to write and easier to read, and leads to less + surprising results. + + +File: gawk.info, Node: Array Sorting, Next: Two-way I/O, Prev: Nondecimal Data, Up: Advanced Features + +11.2 Controlling Array Traversal and Array Sorting +================================================== + +`gawk' lets you control the order in which a `for (i in array)' loop +traverses an array. + + In addition, two built-in functions, `asort()' and `asorti()', let +you sort arrays based on the array values and indices, respectively. +These two functions also provide control over the sorting criteria used +to order the elements during sorting. + +* Menu: + +* Controlling Array Traversal:: How to use PROCINFO["sorted_in"]. +* Array Sorting Functions:: How to use `asort()' and `asorti()'. + + +File: gawk.info, Node: Controlling Array Traversal, Next: Array Sorting Functions, Up: Array Sorting + +11.2.1 Controlling Array Traversal +---------------------------------- + +By default, the order in which a `for (i in array)' loop scans an array +is not defined; it is generally based upon the internal implementation +of arrays inside `awk'. + + Often, though, it is desirable to be able to loop over the elements +in a particular order that you, the programmer, choose. `gawk' lets +you do this. + + *note Controlling Scanning::, describes how you can assign special, +pre-defined values to `PROCINFO["sorted_in"]' in order to control the +order in which `gawk' will traverse an array during a `for' loop. + + In addition, the value of `PROCINFO["sorted_in"]' can be a function +name. This lets you traverse an array based on any custom criterion. +The array elements are ordered according to the return value of this +function. The comparison function should be defined with at least four +arguments: + + function comp_func(i1, v1, i2, v2) + { + COMPARE ELEMENTS 1 AND 2 IN SOME FASHION + RETURN < 0; 0; OR > 0 + } + + Here, I1 and I2 are the indices, and V1 and V2 are the corresponding +values of the two elements being compared. Either V1 or V2, or both, +can be arrays if the array being traversed contains subarrays as values. +(*Note Arrays of Arrays::, for more information about subarrays.) The +three possible return values are interpreted as follows: + +`comp_func(i1, v1, i2, v2) < 0' + Index I1 comes before index I2 during loop traversal. + +`comp_func(i1, v1, i2, v2) == 0' + Indices I1 and I2 come together but the relative order with + respect to each other is undefined. + +`comp_func(i1, v1, i2, v2) > 0' + Index I1 comes after index I2 during loop traversal. + + Our first comparison function can be used to scan an array in +numerical order of the indices: + + function cmp_num_idx(i1, v1, i2, v2) + { + # numerical index comparison, ascending order + return (i1 - i2) + } + + Our second function traverses an array based on the string order of +the element values rather than by indices: + + function cmp_str_val(i1, v1, i2, v2) + { + # string value comparison, ascending order + v1 = v1 "" + v2 = v2 "" + if (v1 < v2) + return -1 + return (v1 != v2) + } + + The third comparison function makes all numbers, and numeric strings +without any leading or trailing spaces, come out first during loop +traversal: + + function cmp_num_str_val(i1, v1, i2, v2, n1, n2) + { + # numbers before string value comparison, ascending order + n1 = v1 + 0 + n2 = v2 + 0 + if (n1 == v1) + return (n2 == v2) ? (n1 - n2) : -1 + else if (n2 == v2) + return 1 + return (v1 < v2) ? -1 : (v1 != v2) + } + + Here is a main program to demonstrate how `gawk' behaves using each +of the previous functions: + + BEGIN { + data["one"] = 10 + data["two"] = 20 + data[10] = "one" + data[100] = 100 + data[20] = "two" + + f[1] = "cmp_num_idx" + f[2] = "cmp_str_val" + f[3] = "cmp_num_str_val" + for (i = 1; i <= 3; i++) { + printf("Sort function: %s\n", f[i]) + PROCINFO["sorted_in"] = f[i] + for (j in data) + printf("\tdata[%s] = %s\n", j, data[j]) + print "" + } + } + + Here are the results when the program is run: + + $ gawk -f compdemo.awk + -| Sort function: cmp_num_idx Sort by numeric index + -| data[two] = 20 + -| data[one] = 10 Both strings are numerically zero + -| data[10] = one + -| data[20] = two + -| data[100] = 100 + -| + -| Sort function: cmp_str_val Sort by element values as strings + -| data[one] = 10 + -| data[100] = 100 String 100 is less than string 20 + -| data[two] = 20 + -| data[10] = one + -| data[20] = two + -| + -| Sort function: cmp_num_str_val Sort all numeric values before all strings + -| data[one] = 10 + -| data[two] = 20 + -| data[100] = 100 + -| data[10] = one + -| data[20] = two + + Consider sorting the entries of a GNU/Linux system password file +according to login name. The following program sorts records by a +specific field position and can be used for this purpose: + + # sort.awk --- simple program to sort by field position + # field position is specified by the global variable POS + + function cmp_field(i1, v1, i2, v2) + { + # comparison by value, as string, and ascending order + return v1[POS] < v2[POS] ? -1 : (v1[POS] != v2[POS]) + } + + { + for (i = 1; i <= NF; i++) + a[NR][i] = $i + } + + END { + PROCINFO["sorted_in"] = "cmp_field" + if (POS < 1 || POS > NF) + POS = 1 + for (i in a) { + for (j = 1; j <= NF; j++) + printf("%s%c", a[i][j], j < NF ? ":" : "") + print "" + } + } + + The first field in each entry of the password file is the user's +login name, and the fields are separated by colons. Each record +defines a subarray, with each field as an element in the subarray. +Running the program produces the following output: + + $ gawk -vPOS=1 -F: -f sort.awk /etc/passwd + -| adm:x:3:4:adm:/var/adm:/sbin/nologin + -| apache:x:48:48:Apache:/var/www:/sbin/nologin + -| avahi:x:70:70:Avahi daemon:/:/sbin/nologin + ... + + The comparison should normally always return the same value when +given a specific pair of array elements as its arguments. If +inconsistent results are returned then the order is undefined. This +behavior can be exploited to introduce random order into otherwise +seemingly ordered data: + + function cmp_randomize(i1, v1, i2, v2) + { + # random order + return (2 - 4 * rand()) + } + + As mentioned above, the order of the indices is arbitrary if two +elements compare equal. This is usually not a problem, but letting the +tied elements come out in arbitrary order can be an issue, especially +when comparing item values. The partial ordering of the equal elements +may change during the next loop traversal, if other elements are added +or removed from the array. One way to resolve ties when comparing +elements with otherwise equal values is to include the indices in the +comparison rules. Note that doing this may make the loop traversal +less efficient, so consider it only if necessary. The following +comparison functions force a deterministic order, and are based on the +fact that the indices of two elements are never equal: + + function cmp_numeric(i1, v1, i2, v2) + { + # numerical value (and index) comparison, descending order + return (v1 != v2) ? (v2 - v1) : (i2 - i1) + } + + function cmp_string(i1, v1, i2, v2) + { + # string value (and index) comparison, descending order + v1 = v1 i1 + v2 = v2 i2 + return (v1 > v2) ? -1 : (v1 != v2) + } + + A custom comparison function can often simplify ordered loop +traversal, and the sky is really the limit when it comes to designing +such a function. + + When string comparisons are made during a sort, either for element +values where one or both aren't numbers, or for element indices handled +as strings, the value of `IGNORECASE' (*note Built-in Variables::) +controls whether the comparisons treat corresponding uppercase and +lowercase letters as equivalent or distinct. + + Another point to keep in mind is that in the case of subarrays the +element values can themselves be arrays; a production comparison +function should use the `isarray()' function (*note Type Functions::), +to check for this, and choose a defined sorting order for subarrays. + + All sorting based on `PROCINFO["sorted_in"]' is disabled in POSIX +mode, since the `PROCINFO' array is not special in that case. + + As a side note, sorting the array indices before traversing the +array has been reported to add 15% to 20% overhead to the execution +time of `awk' programs. For this reason, sorted array traversal is not +the default. + + +File: gawk.info, Node: Array Sorting Functions, Prev: Controlling Array Traversal, Up: Array Sorting + +11.2.2 Sorting Array Values and Indices with `gawk' +--------------------------------------------------- + +In most `awk' implementations, sorting an array requires writing a +`sort()' function. While this can be educational for exploring +different sorting algorithms, usually that's not the point of the +program. `gawk' provides the built-in `asort()' and `asorti()' +functions (*note String Functions::) for sorting arrays. For example: + + POPULATE THE ARRAY data + n = asort(data) + for (i = 1; i <= n; i++) + DO SOMETHING WITH data[i] + + After the call to `asort()', the array `data' is indexed from 1 to +some number N, the total number of elements in `data'. (This count is +`asort()''s return value.) `data[1]' <= `data[2]' <= `data[3]', and so +on. The comparison is based on the type of the elements (*note Typing +and Comparison::). All numeric values come before all string values, +which in turn come before all subarrays. + + An important side effect of calling `asort()' is that _the array's +original indices are irrevocably lost_. As this isn't always +desirable, `asort()' accepts a second argument: + + POPULATE THE ARRAY source + n = asort(source, dest) + for (i = 1; i <= n; i++) + DO SOMETHING WITH dest[i] + + In this case, `gawk' copies the `source' array into the `dest' array +and then sorts `dest', destroying its indices. However, the `source' +array is not affected. + + `asort()' accepts a third string argument to control comparison of +array elements. As with `PROCINFO["sorted_in"]', this argument may be +one of the predefined names that `gawk' provides (*note Controlling +Scanning::), or the name of a user-defined function (*note Controlling +Array Traversal::). + + NOTE: In all cases, the sorted element values consist of the + original array's element values. The ability to control + comparison merely affects the way in which they are sorted. + + Often, what's needed is to sort on the values of the _indices_ +instead of the values of the elements. To do that, use the `asorti()' +function. The interface is identical to that of `asort()', except that +the index values are used for sorting, and become the values of the +result array: + + { source[$0] = some_func($0) } + + END { + n = asorti(source, dest) + for (i = 1; i <= n; i++) { + Work with sorted indices directly: + DO SOMETHING WITH dest[i] + ... + Access original array via sorted indices: + DO SOMETHING WITH source[dest[i]] + } + } + + Similar to `asort()', in all cases, the sorted element values +consist of the original array's indices. The ability to control +comparison merely affects the way in which they are sorted. + + Sorting the array by replacing the indices provides maximal +flexibility. To traverse the elements in decreasing order, use a loop +that goes from N down to 1, either over the elements or over the +indices.(1) + + Copying array indices and elements isn't expensive in terms of +memory. Internally, `gawk' maintains "reference counts" to data. For +example, when `asort()' copies the first array to the second one, there +is only one copy of the original array elements' data, even though both +arrays use the values. + + Because `IGNORECASE' affects string comparisons, the value of +`IGNORECASE' also affects sorting for both `asort()' and `asorti()'. +Note also that the locale's sorting order does _not_ come into play; +comparisons are based on character values only.(2) Caveat Emptor. + + ---------- Footnotes ---------- + + (1) You may also use one of the predefined sorting names that sorts +in decreasing order. + + (2) This is true because locale-based comparison occurs only when in +POSIX compatibility mode, and since `asort()' and `asorti()' are `gawk' +extensions, they are not available in that case. + + +File: gawk.info, Node: Two-way I/O, Next: TCP/IP Networking, Prev: Array Sorting, Up: Advanced Features + +11.3 Two-Way Communications with Another Process +================================================ + + From: brennan@whidbey.com (Mike Brennan) + Newsgroups: comp.lang.awk + Subject: Re: Learn the SECRET to Attract Women Easily + Date: 4 Aug 1997 17:34:46 GMT + Message-ID: <5s53rm$eca@news.whidbey.com> + + On 3 Aug 1997 13:17:43 GMT, Want More Dates??? + wrote: + >Learn the SECRET to Attract Women Easily + > + >The SCENT(tm) Pheromone Sex Attractant For Men to Attract Women + + The scent of awk programmers is a lot more attractive to women than + the scent of perl programmers. + -- + Mike Brennan + + It is often useful to be able to send data to a separate program for +processing and then read the result. This can always be done with +temporary files: + + # Write the data for processing + tempfile = ("mydata." PROCINFO["pid"]) + while (NOT DONE WITH DATA) + print DATA | ("subprogram > " tempfile) + close("subprogram > " tempfile) + + # Read the results, remove tempfile when done + while ((getline newdata < tempfile) > 0) + PROCESS newdata APPROPRIATELY + close(tempfile) + system("rm " tempfile) + +This works, but not elegantly. Among other things, it requires that +the program be run in a directory that cannot be shared among users; +for example, `/tmp' will not do, as another user might happen to be +using a temporary file with the same name. + + However, with `gawk', it is possible to open a _two-way_ pipe to +another process. The second process is termed a "coprocess", since it +runs in parallel with `gawk'. The two-way connection is created using +the `|&' operator (borrowed from the Korn shell, `ksh'):(1) + + do { + print DATA |& "subprogram" + "subprogram" |& getline results + } while (DATA LEFT TO PROCESS) + close("subprogram") + + The first time an I/O operation is executed using the `|&' operator, +`gawk' creates a two-way pipeline to a child process that runs the +other program. Output created with `print' or `printf' is written to +the program's standard input, and output from the program's standard +output can be read by the `gawk' program using `getline'. As is the +case with processes started by `|', the subprogram can be any program, +or pipeline of programs, that can be started by the shell. + + There are some cautionary items to be aware of: + + * As the code inside `gawk' currently stands, the coprocess's + standard error goes to the same place that the parent `gawk''s + standard error goes. It is not possible to read the child's + standard error separately. + + * I/O buffering may be a problem. `gawk' automatically flushes all + output down the pipe to the coprocess. However, if the coprocess + does not flush its output, `gawk' may hang when doing a `getline' + in order to read the coprocess's results. This could lead to a + situation known as "deadlock", where each process is waiting for + the other one to do something. + + It is possible to close just one end of the two-way pipe to a +coprocess, by supplying a second argument to the `close()' function of +either `"to"' or `"from"' (*note Close Files And Pipes::). These +strings tell `gawk' to close the end of the pipe that sends data to the +coprocess or the end that reads from it, respectively. + + This is particularly necessary in order to use the system `sort' +utility as part of a coprocess; `sort' must read _all_ of its input +data before it can produce any output. The `sort' program does not +receive an end-of-file indication until `gawk' closes the write end of +the pipe. + + When you have finished writing data to the `sort' utility, you can +close the `"to"' end of the pipe, and then start reading sorted data +via `getline'. For example: + + BEGIN { + command = "LC_ALL=C sort" + n = split("abcdefghijklmnopqrstuvwxyz", a, "") + + for (i = n; i > 0; i--) + print a[i] |& command + close(command, "to") + + while ((command |& getline line) > 0) + print "got", line + close(command) + } + + This program writes the letters of the alphabet in reverse order, one +per line, down the two-way pipe to `sort'. It then closes the write +end of the pipe, so that `sort' receives an end-of-file indication. +This causes `sort' to sort the data and write the sorted data back to +the `gawk' program. Once all of the data has been read, `gawk' +terminates the coprocess and exits. + + As a side note, the assignment `LC_ALL=C' in the `sort' command +ensures traditional Unix (ASCII) sorting from `sort'. + + You may also use pseudo-ttys (ptys) for two-way communication +instead of pipes, if your system supports them. This is done on a +per-command basis, by setting a special element in the `PROCINFO' array +(*note Auto-set::), like so: + + command = "sort -nr" # command, save in convenience variable + PROCINFO[command, "pty"] = 1 # update PROCINFO + print ... |& command # start two-way pipe + ... + +Using ptys avoids the buffer deadlock issues described earlier, at some +loss in performance. If your system does not have ptys, or if all the +system's ptys are in use, `gawk' automatically falls back to using +regular pipes. + + ---------- Footnotes ---------- + + (1) This is very different from the same operator in the C shell. + + +File: gawk.info, Node: TCP/IP Networking, Next: Profiling, Prev: Two-way I/O, Up: Advanced Features + +11.4 Using `gawk' for Network Programming +========================================= + + `EMISTERED': + A host is a host from coast to coast, + and no-one can talk to host that's close, + unless the host that isn't close + is busy hung or dead. + + In addition to being able to open a two-way pipeline to a coprocess +on the same system (*note Two-way I/O::), it is possible to make a +two-way connection to another process on another system across an IP +network connection. + + You can think of this as just a _very long_ two-way pipeline to a +coprocess. The way `gawk' decides that you want to use TCP/IP +networking is by recognizing special file names that begin with one of +`/inet/', `/inet4/' or `/inet6'. + + The full syntax of the special file name is +`/NET-TYPE/PROTOCOL/LOCAL-PORT/REMOTE-HOST/REMOTE-PORT'. The +components are: + +NET-TYPE + Specifies the kind of Internet connection to make. Use `/inet4/' + to force IPv4, and `/inet6/' to force IPv6. Plain `/inet/' (which + used to be the only option) uses the system default, most likely + IPv4. + +PROTOCOL + The protocol to use over IP. This must be either `tcp', or `udp', + for a TCP or UDP IP connection, respectively. The use of TCP is + recommended for most applications. + +LOCAL-PORT + The local TCP or UDP port number to use. Use a port number of `0' + when you want the system to pick a port. This is what you should do + when writing a TCP or UDP client. You may also use a well-known + service name, such as `smtp' or `http', in which case `gawk' + attempts to determine the predefined port number using the C + `getaddrinfo()' function. + +REMOTE-HOST + The IP address or fully-qualified domain name of the Internet host + to which you want to connect. + +REMOTE-PORT + The TCP or UDP port number to use on the given REMOTE-HOST. + Again, use `0' if you don't care, or else a well-known service + name. + + NOTE: Failure in opening a two-way socket will result in a + non-fatal error being returned to the calling code. The value of + `ERRNO' indicates the error (*note Auto-set::). + + Consider the following very simple example: + + BEGIN { + Service = "/inet/tcp/0/localhost/daytime" + Service |& getline + print $0 + close(Service) + } + + This program reads the current date and time from the local system's +TCP `daytime' server. It then prints the results and closes the +connection. + + Because this topic is extensive, the use of `gawk' for TCP/IP +programming is documented separately. See *note (General +Introduction)Top:: gawkinet, TCP/IP Internetworking with `gawk', for a +much more complete introduction and discussion, as well as extensive +examples. + + +File: gawk.info, Node: Profiling, Prev: TCP/IP Networking, Up: Advanced Features + +11.5 Profiling Your `awk' Programs +================================== + +You may produce execution traces of your `awk' programs. This is done +with a specially compiled version of `gawk', called `pgawk' ("profiling +`gawk'"). + + `pgawk' is identical in every way to `gawk', except that when it has +finished running, it creates a profile of your program in a file named +`awkprof.out'. Because it is profiling, it also executes up to 45% +slower than `gawk' normally does. + + As shown in the following example, the `--profile' option can be +used to change the name of the file where `pgawk' will write the +profile: + + pgawk --profile=myprog.prof -f myprog.awk data1 data2 + +In the above example, `pgawk' places the profile in `myprog.prof' +instead of in `awkprof.out'. + + Here is a sample session showing a simple `awk' program, its input +data, and the results from running `pgawk'. First, the `awk' program: + + BEGIN { print "First BEGIN rule" } + + END { print "First END rule" } + + /foo/ { + print "matched /foo/, gosh" + for (i = 1; i <= 3; i++) + sing() + } + + { + if (/foo/) + print "if is true" + else + print "else is true" + } + + BEGIN { print "Second BEGIN rule" } + + END { print "Second END rule" } + + function sing( dummy) + { + print "I gotta be me!" + } + + Following is the input data: + + foo + bar + baz + foo + junk + + Here is the `awkprof.out' that results from running `pgawk' on this +program and data (this example also illustrates that `awk' programmers +sometimes have to work late): + + # gawk profile, created Sun Aug 13 00:00:15 2000 + + # BEGIN block(s) + + BEGIN { + 1 print "First BEGIN rule" + 1 print "Second BEGIN rule" + } + + # Rule(s) + + 5 /foo/ { # 2 + 2 print "matched /foo/, gosh" + 6 for (i = 1; i <= 3; i++) { + 6 sing() + } + } + + 5 { + 5 if (/foo/) { # 2 + 2 print "if is true" + 3 } else { + 3 print "else is true" + } + } + + # END block(s) + + END { + 1 print "First END rule" + 1 print "Second END rule" + } + + # Functions, listed alphabetically + + 6 function sing(dummy) + { + 6 print "I gotta be me!" + } + + This example illustrates many of the basic features of profiling +output. They are as follows: + + * The program is printed in the order `BEGIN' rule, `BEGINFILE' rule, + pattern/action rules, `ENDFILE' rule, `END' rule and functions, + listed alphabetically. Multiple `BEGIN' and `END' rules are + merged together, as are multiple `BEGINFILE' and `ENDFILE' rules. + + * Pattern-action rules have two counts. The first count, to the + left of the rule, shows how many times the rule's pattern was + _tested_. The second count, to the right of the rule's opening + left brace in a comment, shows how many times the rule's action + was _executed_. The difference between the two indicates how many + times the rule's pattern evaluated to false. + + * Similarly, the count for an `if'-`else' statement shows how many + times the condition was tested. To the right of the opening left + brace for the `if''s body is a count showing how many times the + condition was true. The count for the `else' indicates how many + times the test failed. + + * The count for a loop header (such as `for' or `while') shows how + many times the loop test was executed. (Because of this, you + can't just look at the count on the first statement in a rule to + determine how many times the rule was executed. If the first + statement is a loop, the count is misleading.) + + * For user-defined functions, the count next to the `function' + keyword indicates how many times the function was called. The + counts next to the statements in the body show how many times + those statements were executed. + + * The layout uses "K&R" style with TABs. Braces are used + everywhere, even when the body of an `if', `else', or loop is only + a single statement. + + * Parentheses are used only where needed, as indicated by the + structure of the program and the precedence rules. For example, + `(3 + 5) * 4' means add three plus five, then multiply the total + by four. However, `3 + 5 * 4' has no parentheses, and means `3 + + (5 * 4)'. + + * Parentheses are used around the arguments to `print' and `printf' + only when the `print' or `printf' statement is followed by a + redirection. Similarly, if the target of a redirection isn't a + scalar, it gets parenthesized. + + * `pgawk' supplies leading comments in front of the `BEGIN' and + `END' rules, the pattern/action rules, and the functions. + + + The profiled version of your program may not look exactly like what +you typed when you wrote it. This is because `pgawk' creates the +profiled version by "pretty printing" its internal representation of +the program. The advantage to this is that `pgawk' can produce a +standard representation. The disadvantage is that all source-code +comments are lost, as are the distinctions among multiple `BEGIN', +`END', `BEGINFILE', and `ENDFILE' rules. Also, things such as: + + /foo/ + +come out as: + + /foo/ { + print $0 + } + +which is correct, but possibly surprising. + + Besides creating profiles when a program has completed, `pgawk' can +produce a profile while it is running. This is useful if your `awk' +program goes into an infinite loop and you want to see what has been +executed. To use this feature, run `pgawk' in the background: + + $ pgawk -f myprog & + [1] 13992 + +The shell prints a job number and process ID number; in this case, +13992. Use the `kill' command to send the `USR1' signal to `pgawk': + + $ kill -USR1 13992 + +As usual, the profiled version of the program is written to +`awkprof.out', or to a different file if you use the `--profile' option. + + Along with the regular profile, as shown earlier, the profile +includes a trace of any active functions: + + # Function Call Stack: + + # 3. baz + # 2. bar + # 1. foo + # -- main -- + + You may send `pgawk' the `USR1' signal as many times as you like. +Each time, the profile and function call trace are appended to the +output profile file. + + If you use the `HUP' signal instead of the `USR1' signal, `pgawk' +produces the profile and the function call trace and then exits. + + When `pgawk' runs on MS-Windows systems, it uses the `INT' and +`QUIT' signals for producing the profile and, in the case of the `INT' +signal, `pgawk' exits. This is because these systems don't support the +`kill' command, so the only signals you can deliver to a program are +those generated by the keyboard. The `INT' signal is generated by the +`Ctrl-' or `Ctrl-' key, while the `QUIT' signal is generated +by the `Ctrl-<\>' key. + + Finally, regular `gawk' also accepts the `--profile' option. When +called this way, `gawk' "pretty prints" the program into `awkprof.out', +without any execution counts. + + +File: gawk.info, Node: Library Functions, Next: Sample Programs, Prev: Advanced Features, Up: Top + +12 A Library of `awk' Functions +******************************* + +*note User-defined::, describes how to write your own `awk' functions. +Writing functions is important, because it allows you to encapsulate +algorithms and program tasks in a single place. It simplifies +programming, making program development more manageable, and making +programs more readable. + + One valuable way to learn a new programming language is to _read_ +programs in that language. To that end, this major node and *note +Sample Programs::, provide a good-sized body of code for you to read, +and hopefully, to learn from. + + This major node presents a library of useful `awk' functions. Many +of the sample programs presented later in this Info file use these +functions. The functions are presented here in a progression from +simple to complex. + + *note Extract Program::, presents a program that you can use to +extract the source code for these example library functions and +programs from the Texinfo source for this Info file. (This has already +been done as part of the `gawk' distribution.) + + If you have written one or more useful, general-purpose `awk' +functions and would like to contribute them to the `awk' user +community, see *note How To Contribute::, for more information. + + The programs in this major node and in *note Sample Programs::, +freely use features that are `gawk'-specific. Rewriting these programs +for different implementations of `awk' is pretty straightforward. + + * Diagnostic error messages are sent to `/dev/stderr'. Use `| "cat + 1>&2"' instead of `> "/dev/stderr"' if your system does not have a + `/dev/stderr', or if you cannot use `gawk'. + + * A number of programs use `nextfile' (*note Nextfile Statement::) + to skip any remaining input in the input file. + + * Finally, some of the programs choose to ignore upper- and lowercase + distinctions in their input. They do so by assigning one to + `IGNORECASE'. You can achieve almost the same effect(1) by adding + the following rule to the beginning of the program: + + # ignore case + { $0 = tolower($0) } + + Also, verify that all regexp and string constants used in + comparisons use only lowercase letters. + +* Menu: + +* Library Names:: How to best name private global variables in + library functions. +* General Functions:: Functions that are of general use. +* Data File Management:: Functions for managing command-line data + files. +* Getopt Function:: A function for processing command-line + arguments. +* Passwd Functions:: Functions for getting user information. +* Group Functions:: Functions for getting group information. +* Walking Arrays:: A function to walk arrays of arrays. + + ---------- Footnotes ---------- + + (1) The effects are not identical. Output of the transformed record +will be in all lowercase, while `IGNORECASE' preserves the original +contents of the input record. + + +File: gawk.info, Node: Library Names, Next: General Functions, Up: Library Functions + +12.1 Naming Library Function Global Variables +============================================= + +Due to the way the `awk' language evolved, variables are either +"global" (usable by the entire program) or "local" (usable just by a +specific function). There is no intermediate state analogous to +`static' variables in C. + + Library functions often need to have global variables that they can +use to preserve state information between calls to the function--for +example, `getopt()''s variable `_opti' (*note Getopt Function::). Such +variables are called "private", since the only functions that need to +use them are the ones in the library. + + When writing a library function, you should try to choose names for +your private variables that will not conflict with any variables used by +either another library function or a user's main program. For example, +a name like `i' or `j' is not a good choice, because user programs +often use variable names like these for their own purposes. + + The example programs shown in this major node all start the names of +their private variables with an underscore (`_'). Users generally +don't use leading underscores in their variable names, so this +convention immediately decreases the chances that the variable name +will be accidentally shared with the user's program. + + In addition, several of the library functions use a prefix that helps +indicate what function or set of functions use the variables--for +example, `_pw_byname' in the user database routines (*note Passwd +Functions::). This convention is recommended, since it even further +decreases the chance of inadvertent conflict among variable names. +Note that this convention is used equally well for variable names and +for private function names.(1) + + As a final note on variable naming, if a function makes global +variables available for use by a main program, it is a good convention +to start that variable's name with a capital letter--for example, +`getopt()''s `Opterr' and `Optind' variables (*note Getopt Function::). +The leading capital letter indicates that it is global, while the fact +that the variable name is not all capital letters indicates that the +variable is not one of `awk''s built-in variables, such as `FS'. + + It is also important that _all_ variables in library functions that +do not need to save state are, in fact, declared local.(2) If this is +not done, the variable could accidentally be used in the user's +program, leading to bugs that are very difficult to track down: + + function lib_func(x, y, l1, l2) + { + ... + USE VARIABLE some_var # some_var should be local + ... # but is not by oversight + } + + A different convention, common in the Tcl community, is to use a +single associative array to hold the values needed by the library +function(s), or "package." This significantly decreases the number of +actual global names in use. For example, the functions described in +*note Passwd Functions::, might have used array elements +`PW_data["inited"]', `PW_data["total"]', `PW_data["count"]', and +`PW_data["awklib"]', instead of `_pw_inited', `_pw_awklib', `_pw_total', +and `_pw_count'. + + The conventions presented in this minor node are exactly that: +conventions. You are not required to write your programs this way--we +merely recommend that you do so. + + ---------- Footnotes ---------- + + (1) While all the library routines could have been rewritten to use +this convention, this was not done, in order to show how our own `awk' +programming style has evolved and to provide some basis for this +discussion. + + (2) `gawk''s `--dump-variables' command-line option is useful for +verifying this. + + +File: gawk.info, Node: General Functions, Next: Data File Management, Prev: Library Names, Up: Library Functions + +12.2 General Programming +======================== + +This minor node presents a number of functions that are of general +programming use. + +* Menu: + +* Strtonum Function:: A replacement for the built-in + `strtonum()' function. +* Assert Function:: A function for assertions in `awk' + programs. +* Round Function:: A function for rounding if `sprintf()' + does not do it correctly. +* Cliff Random Function:: The Cliff Random Number Generator. +* Ordinal Functions:: Functions for using characters as numbers and + vice versa. +* Join Function:: A function to join an array into a string. +* Gettimeofday Function:: A function to get formatted times. + + +File: gawk.info, Node: Strtonum Function, Next: Assert Function, Up: General Functions + +12.2.1 Converting Strings To Numbers +------------------------------------ + +The `strtonum()' function (*note String Functions::) is a `gawk' +extension. The following function provides an implementation for other +versions of `awk': + + # mystrtonum --- convert string to number + + function mystrtonum(str, ret, chars, n, i, k, c) + { + if (str ~ /^0[0-7]*$/) { + # octal + n = length(str) + ret = 0 + for (i = 1; i <= n; i++) { + c = substr(str, i, 1) + if ((k = index("01234567", c)) > 0) + k-- # adjust for 1-basing in awk + + ret = ret * 8 + k + } + } else if (str ~ /^0[xX][[:xdigit:]]+/) { + # hexadecimal + str = substr(str, 3) # lop off leading 0x + n = length(str) + ret = 0 + for (i = 1; i <= n; i++) { + c = substr(str, i, 1) + c = tolower(c) + if ((k = index("0123456789", c)) > 0) + k-- # adjust for 1-basing in awk + else if ((k = index("abcdef", c)) > 0) + k += 9 + + ret = ret * 16 + k + } + } else if (str ~ \ + /^[-+]?([0-9]+([.][0-9]*([Ee][0-9]+)?)?|([.][0-9]+([Ee][-+]?[0-9]+)?))$/) { + # decimal number, possibly floating point + ret = str + 0 + } else + ret = "NOT-A-NUMBER" + + return ret + } + + # BEGIN { # gawk test harness + # a[1] = "25" + # a[2] = ".31" + # a[3] = "0123" + # a[4] = "0xdeadBEEF" + # a[5] = "123.45" + # a[6] = "1.e3" + # a[7] = "1.32" + # a[7] = "1.32E2" + # + # for (i = 1; i in a; i++) + # print a[i], strtonum(a[i]), mystrtonum(a[i]) + # } + + The function first looks for C-style octal numbers (base 8). If the +input string matches a regular expression describing octal numbers, +then `mystrtonum()' loops through each character in the string. It +sets `k' to the index in `"01234567"' of the current octal digit. +Since the return value is one-based, the `k--' adjusts `k' so it can be +used in computing the return value. + + Similar logic applies to the code that checks for and converts a +hexadecimal value, which starts with `0x' or `0X'. The use of +`tolower()' simplifies the computation for finding the correct numeric +value for each hexadecimal digit. + + Finally, if the string matches the (rather complicated) regexp for a +regular decimal integer or floating-point number, the computation `ret += str + 0' lets `awk' convert the value to a number. + + A commented-out test program is included, so that the function can +be tested with `gawk' and the results compared to the built-in +`strtonum()' function. + + +File: gawk.info, Node: Assert Function, Next: Round Function, Prev: Strtonum Function, Up: General Functions + +12.2.2 Assertions +----------------- + +When writing large programs, it is often useful to know that a +condition or set of conditions is true. Before proceeding with a +particular computation, you make a statement about what you believe to +be the case. Such a statement is known as an "assertion". The C +language provides an `' header file and corresponding +`assert()' macro that the programmer can use to make assertions. If an +assertion fails, the `assert()' macro arranges to print a diagnostic +message describing the condition that should have been true but was +not, and then it kills the program. In C, using `assert()' looks this: + + #include + + int myfunc(int a, double b) + { + assert(a <= 5 && b >= 17.1); + ... + } + + If the assertion fails, the program prints a message similar to this: + + prog.c:5: assertion failed: a <= 5 && b >= 17.1 + + The C language makes it possible to turn the condition into a string +for use in printing the diagnostic message. This is not possible in +`awk', so this `assert()' function also requires a string version of +the condition that is being tested. Following is the function: + + # assert --- assert that a condition is true. Otherwise exit. + + function assert(condition, string) + { + if (! condition) { + printf("%s:%d: assertion failed: %s\n", + FILENAME, FNR, string) > "/dev/stderr" + _assert_exit = 1 + exit 1 + } + } + + END { + if (_assert_exit) + exit 1 + } + + The `assert()' function tests the `condition' parameter. If it is +false, it prints a message to standard error, using the `string' +parameter to describe the failed condition. It then sets the variable +`_assert_exit' to one and executes the `exit' statement. The `exit' +statement jumps to the `END' rule. If the `END' rules finds +`_assert_exit' to be true, it exits immediately. + + The purpose of the test in the `END' rule is to keep any other `END' +rules from running. When an assertion fails, the program should exit +immediately. If no assertions fail, then `_assert_exit' is still false +when the `END' rule is run normally, and the rest of the program's +`END' rules execute. For all of this to work correctly, `assert.awk' +must be the first source file read by `awk'. The function can be used +in a program in the following way: + + function myfunc(a, b) + { + assert(a <= 5 && b >= 17.1, "a <= 5 && b >= 17.1") + ... + } + +If the assertion fails, you see a message similar to the following: + + mydata:1357: assertion failed: a <= 5 && b >= 17.1 + + There is a small problem with this version of `assert()'. An `END' +rule is automatically added to the program calling `assert()'. +Normally, if a program consists of just a `BEGIN' rule, the input files +and/or standard input are not read. However, now that the program has +an `END' rule, `awk' attempts to read the input data files or standard +input (*note Using BEGIN/END::), most likely causing the program to +hang as it waits for input. + + There is a simple workaround to this: make sure that such a `BEGIN' +rule always ends with an `exit' statement. + + +File: gawk.info, Node: Round Function, Next: Cliff Random Function, Prev: Assert Function, Up: General Functions + +12.2.3 Rounding Numbers +----------------------- + +The way `printf' and `sprintf()' (*note Printf::) perform rounding +often depends upon the system's C `sprintf()' subroutine. On many +machines, `sprintf()' rounding is "unbiased," which means it doesn't +always round a trailing `.5' up, contrary to naive expectations. In +unbiased rounding, `.5' rounds to even, rather than always up, so 1.5 +rounds to 2 but 4.5 rounds to 4. This means that if you are using a +format that does rounding (e.g., `"%.0f"'), you should check what your +system does. The following function does traditional rounding; it +might be useful if your `awk''s `printf' does unbiased rounding: + + # round.awk --- do normal rounding + + function round(x, ival, aval, fraction) + { + ival = int(x) # integer part, int() truncates + + # see if fractional part + if (ival == x) # no fraction + return ival # ensure no decimals + + if (x < 0) { + aval = -x # absolute value + ival = int(aval) + fraction = aval - ival + if (fraction >= .5) + return int(x) - 1 # -2.5 --> -3 + else + return int(x) # -2.3 --> -2 + } else { + fraction = x - ival + if (fraction >= .5) + return ival + 1 + else + return ival + } + } + + # test harness + { print $0, round($0) } + + +File: gawk.info, Node: Cliff Random Function, Next: Ordinal Functions, Prev: Round Function, Up: General Functions + +12.2.4 The Cliff Random Number Generator +---------------------------------------- + +The Cliff random number generator +(http://mathworld.wolfram.com/CliffRandomNumberGenerator.html) is a +very simple random number generator that "passes the noise sphere test +for randomness by showing no structure." It is easily programmed, in +less than 10 lines of `awk' code: + + # cliff_rand.awk --- generate Cliff random numbers + + BEGIN { _cliff_seed = 0.1 } + + function cliff_rand() + { + _cliff_seed = (100 * log(_cliff_seed)) % 1 + if (_cliff_seed < 0) + _cliff_seed = - _cliff_seed + return _cliff_seed + } + + This algorithm requires an initial "seed" of 0.1. Each new value +uses the current seed as input for the calculation. If the built-in +`rand()' function (*note Numeric Functions::) isn't random enough, you +might try using this function instead. + + +File: gawk.info, Node: Ordinal Functions, Next: Join Function, Prev: Cliff Random Function, Up: General Functions + +12.2.5 Translating Between Characters and Numbers +------------------------------------------------- + +One commercial implementation of `awk' supplies a built-in function, +`ord()', which takes a character and returns the numeric value for that +character in the machine's character set. If the string passed to +`ord()' has more than one character, only the first one is used. + + The inverse of this function is `chr()' (from the function of the +same name in Pascal), which takes a number and returns the +corresponding character. Both functions are written very nicely in +`awk'; there is no real reason to build them into the `awk' interpreter: + + # ord.awk --- do ord and chr + + # Global identifiers: + # _ord_: numerical values indexed by characters + # _ord_init: function to initialize _ord_ + + BEGIN { _ord_init() } + + function _ord_init( low, high, i, t) + { + low = sprintf("%c", 7) # BEL is ascii 7 + if (low == "\a") { # regular ascii + low = 0 + high = 127 + } else if (sprintf("%c", 128 + 7) == "\a") { + # ascii, mark parity + low = 128 + high = 255 + } else { # ebcdic(!) + low = 0 + high = 255 + } + + for (i = low; i <= high; i++) { + t = sprintf("%c", i) + _ord_[t] = i + } + } + + Some explanation of the numbers used by `chr' is worthwhile. The +most prominent character set in use today is ASCII.(1) Although an +8-bit byte can hold 256 distinct values (from 0 to 255), ASCII only +defines characters that use the values from 0 to 127.(2) In the now +distant past, at least one minicomputer manufacturer used ASCII, but +with mark parity, meaning that the leftmost bit in the byte is always +1. This means that on those systems, characters have numeric values +from 128 to 255. Finally, large mainframe systems use the EBCDIC +character set, which uses all 256 values. While there are other +character sets in use on some older systems, they are not really worth +worrying about: + + function ord(str, c) + { + # only first character is of interest + c = substr(str, 1, 1) + return _ord_[c] + } + + function chr(c) + { + # force c to be numeric by adding 0 + return sprintf("%c", c + 0) + } + + #### test code #### + # BEGIN \ + # { + # for (;;) { + # printf("enter a character: ") + # if (getline var <= 0) + # break + # printf("ord(%s) = %d\n", var, ord(var)) + # } + # } + + An obvious improvement to these functions is to move the code for the +`_ord_init' function into the body of the `BEGIN' rule. It was written +this way initially for ease of development. There is a "test program" +in a `BEGIN' rule, to test the function. It is commented out for +production use. + + ---------- Footnotes ---------- + + (1) This is changing; many systems use Unicode, a very large +character set that includes ASCII as a subset. On systems with full +Unicode support, a character can occupy up to 32 bits, making simple +tests such as used here prohibitively expensive. + + (2) ASCII has been extended in many countries to use the values from +128 to 255 for country-specific characters. If your system uses these +extensions, you can simplify `_ord_init' to loop from 0 to 255. + + +File: gawk.info, Node: Join Function, Next: Gettimeofday Function, Prev: Ordinal Functions, Up: General Functions + +12.2.6 Merging an Array into a String +------------------------------------- + +When doing string processing, it is often useful to be able to join all +the strings in an array into one long string. The following function, +`join()', accomplishes this task. It is used later in several of the +application programs (*note Sample Programs::). + + Good function design is important; this function needs to be general +but it should also have a reasonable default behavior. It is called +with an array as well as the beginning and ending indices of the +elements in the array to be merged. This assumes that the array +indices are numeric--a reasonable assumption since the array was likely +created with `split()' (*note String Functions::): + + # join.awk --- join an array into a string + + function join(array, start, end, sep, result, i) + { + if (sep == "") + sep = " " + else if (sep == SUBSEP) # magic value + sep = "" + result = array[start] + for (i = start + 1; i <= end; i++) + result = result sep array[i] + return result + } + + An optional additional argument is the separator to use when joining +the strings back together. If the caller supplies a nonempty value, +`join()' uses it; if it is not supplied, it has a null value. In this +case, `join()' uses a single space as a default separator for the +strings. If the value is equal to `SUBSEP', then `join()' joins the +strings with no separator between them. `SUBSEP' serves as a "magic" +value to indicate that there should be no separation between the +component strings.(1) + + ---------- Footnotes ---------- + + (1) It would be nice if `awk' had an assignment operator for +concatenation. The lack of an explicit operator for concatenation +makes string operations more difficult than they really need to be. + + +File: gawk.info, Node: Gettimeofday Function, Prev: Join Function, Up: General Functions + +12.2.7 Managing the Time of Day +------------------------------- + +The `systime()' and `strftime()' functions described in *note Time +Functions::, provide the minimum functionality necessary for dealing +with the time of day in human readable form. While `strftime()' is +extensive, the control formats are not necessarily easy to remember or +intuitively obvious when reading a program. + + The following function, `gettimeofday()', populates a user-supplied +array with preformatted time information. It returns a string with the +current time formatted in the same way as the `date' utility: + + # gettimeofday.awk --- get the time of day in a usable format + + # Returns a string in the format of output of date(1) + # Populates the array argument time with individual values: + # time["second"] -- seconds (0 - 59) + # time["minute"] -- minutes (0 - 59) + # time["hour"] -- hours (0 - 23) + # time["althour"] -- hours (0 - 12) + # time["monthday"] -- day of month (1 - 31) + # time["month"] -- month of year (1 - 12) + # time["monthname"] -- name of the month + # time["shortmonth"] -- short name of the month + # time["year"] -- year modulo 100 (0 - 99) + # time["fullyear"] -- full year + # time["weekday"] -- day of week (Sunday = 0) + # time["altweekday"] -- day of week (Monday = 0) + # time["dayname"] -- name of weekday + # time["shortdayname"] -- short name of weekday + # time["yearday"] -- day of year (0 - 365) + # time["timezone"] -- abbreviation of timezone name + # time["ampm"] -- AM or PM designation + # time["weeknum"] -- week number, Sunday first day + # time["altweeknum"] -- week number, Monday first day + + function gettimeofday(time, ret, now, i) + { + # get time once, avoids unnecessary system calls + now = systime() + + # return date(1)-style output + ret = strftime("%a %b %e %H:%M:%S %Z %Y", now) + + # clear out target array + delete time + + # fill in values, force numeric values to be + # numeric by adding 0 + time["second"] = strftime("%S", now) + 0 + time["minute"] = strftime("%M", now) + 0 + time["hour"] = strftime("%H", now) + 0 + time["althour"] = strftime("%I", now) + 0 + time["monthday"] = strftime("%d", now) + 0 + time["month"] = strftime("%m", now) + 0 + time["monthname"] = strftime("%B", now) + time["shortmonth"] = strftime("%b", now) + time["year"] = strftime("%y", now) + 0 + time["fullyear"] = strftime("%Y", now) + 0 + time["weekday"] = strftime("%w", now) + 0 + time["altweekday"] = strftime("%u", now) + 0 + time["dayname"] = strftime("%A", now) + time["shortdayname"] = strftime("%a", now) + time["yearday"] = strftime("%j", now) + 0 + time["timezone"] = strftime("%Z", now) + time["ampm"] = strftime("%p", now) + time["weeknum"] = strftime("%U", now) + 0 + time["altweeknum"] = strftime("%W", now) + 0 + + return ret + } + + The string indices are easier to use and read than the various +formats required by `strftime()'. The `alarm' program presented in +*note Alarm Program::, uses this function. A more general design for +the `gettimeofday()' function would have allowed the user to supply an +optional timestamp value to use instead of the current time. + + +File: gawk.info, Node: Data File Management, Next: Getopt Function, Prev: General Functions, Up: Library Functions + +12.3 Data File Management +========================= + +This minor node presents functions that are useful for managing +command-line data files. + +* Menu: + +* Filetrans Function:: A function for handling data file transitions. +* Rewind Function:: A function for rereading the current file. +* File Checking:: Checking that data files are readable. +* Empty Files:: Checking for zero-length files. +* Ignoring Assigns:: Treating assignments as file names. + + +File: gawk.info, Node: Filetrans Function, Next: Rewind Function, Up: Data File Management + +12.3.1 Noting Data File Boundaries +---------------------------------- + +The `BEGIN' and `END' rules are each executed exactly once at the +beginning and end of your `awk' program, respectively (*note +BEGIN/END::). We (the `gawk' authors) once had a user who mistakenly +thought that the `BEGIN' rule is executed at the beginning of each data +file and the `END' rule is executed at the end of each data file. + + When informed that this was not the case, the user requested that we +add new special patterns to `gawk', named `BEGIN_FILE' and `END_FILE', +that would have the desired behavior. He even supplied us the code to +do so. + + Adding these special patterns to `gawk' wasn't necessary; the job +can be done cleanly in `awk' itself, as illustrated by the following +library program. It arranges to call two user-supplied functions, +`beginfile()' and `endfile()', at the beginning and end of each data +file. Besides solving the problem in only nine(!) lines of code, it +does so _portably_; this works with any implementation of `awk': + + # transfile.awk + # + # Give the user a hook for filename transitions + # + # The user must supply functions beginfile() and endfile() + # that each take the name of the file being started or + # finished, respectively. + + FILENAME != _oldfilename \ + { + if (_oldfilename != "") + endfile(_oldfilename) + _oldfilename = FILENAME + beginfile(FILENAME) + } + + END { endfile(FILENAME) } + + This file must be loaded before the user's "main" program, so that +the rule it supplies is executed first. + + This rule relies on `awk''s `FILENAME' variable that automatically +changes for each new data file. The current file name is saved in a +private variable, `_oldfilename'. If `FILENAME' does not equal +`_oldfilename', then a new data file is being processed and it is +necessary to call `endfile()' for the old file. Because `endfile()' +should only be called if a file has been processed, the program first +checks to make sure that `_oldfilename' is not the null string. The +program then assigns the current file name to `_oldfilename' and calls +`beginfile()' for the file. Because, like all `awk' variables, +`_oldfilename' is initialized to the null string, this rule executes +correctly even for the first data file. + + The program also supplies an `END' rule to do the final processing +for the last file. Because this `END' rule comes before any `END' rules +supplied in the "main" program, `endfile()' is called first. Once +again the value of multiple `BEGIN' and `END' rules should be clear. + + If the same data file occurs twice in a row on the command line, then +`endfile()' and `beginfile()' are not executed at the end of the first +pass and at the beginning of the second pass. The following version +solves the problem: + + # ftrans.awk --- handle data file transitions + # + # user supplies beginfile() and endfile() functions + + FNR == 1 { + if (_filename_ != "") + endfile(_filename_) + _filename_ = FILENAME + beginfile(FILENAME) + } + + END { endfile(_filename_) } + + *note Wc Program::, shows how this library function can be used and +how it simplifies writing the main program. + +Advanced Notes: So Why Does `gawk' have `BEGINFILE' and `ENDFILE'? +------------------------------------------------------------------ + +You are probably wondering, if `beginfile()' and `endfile()' functions +can do the job, why does `gawk' have `BEGINFILE' and `ENDFILE' patterns +(*note BEGINFILE/ENDFILE::)? + + Good question. Normally, if `awk' cannot open a file, this causes +an immediate fatal error. In this case, there is no way for a +user-defined function to deal with the problem, since the mechanism for +calling it relies on the file being open and at the first record. Thus, +the main reason for `BEGINFILE' is to give you a "hook" to catch files +that cannot be processed. `ENDFILE' exists for symmetry, and because +it provides an easy way to do per-file cleanup processing. + + +File: gawk.info, Node: Rewind Function, Next: File Checking, Prev: Filetrans Function, Up: Data File Management + +12.3.2 Rereading the Current File +--------------------------------- + +Another request for a new built-in function was for a `rewind()' +function that would make it possible to reread the current file. The +requesting user didn't want to have to use `getline' (*note Getline::) +inside a loop. + + However, as long as you are not in the `END' rule, it is quite easy +to arrange to immediately close the current input file and then start +over with it from the top. For lack of a better name, we'll call it +`rewind()': + + # rewind.awk --- rewind the current file and start over + + function rewind( i) + { + # shift remaining arguments up + for (i = ARGC; i > ARGIND; i--) + ARGV[i] = ARGV[i-1] + + # make sure gawk knows to keep going + ARGC++ + + # make current file next to get done + ARGV[ARGIND+1] = FILENAME + + # do it + nextfile + } + + This code relies on the `ARGIND' variable (*note Auto-set::), which +is specific to `gawk'. If you are not using `gawk', you can use ideas +presented in *note Filetrans Function::, to either update `ARGIND' on +your own or modify this code as appropriate. + + The `rewind()' function also relies on the `nextfile' keyword (*note +Nextfile Statement::). + + +File: gawk.info, Node: File Checking, Next: Empty Files, Prev: Rewind Function, Up: Data File Management + +12.3.3 Checking for Readable Data Files +--------------------------------------- + +Normally, if you give `awk' a data file that isn't readable, it stops +with a fatal error. There are times when you might want to just ignore +such files and keep going. You can do this by prepending the following +program to your `awk' program: + + # readable.awk --- library file to skip over unreadable files + + BEGIN { + for (i = 1; i < ARGC; i++) { + if (ARGV[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/ \ + || ARGV[i] == "-" || ARGV[i] == "/dev/stdin") + continue # assignment or standard input + else if ((getline junk < ARGV[i]) < 0) # unreadable + delete ARGV[i] + else + close(ARGV[i]) + } + } + + This works, because the `getline' won't be fatal. Removing the +element from `ARGV' with `delete' skips the file (since it's no longer +in the list). See also *note ARGC and ARGV::. + + +File: gawk.info, Node: Empty Files, Next: Ignoring Assigns, Prev: File Checking, Up: Data File Management + +12.3.4 Checking For Zero-length Files +------------------------------------- + +All known `awk' implementations silently skip over zero-length files. +This is a by-product of `awk''s implicit +read-a-record-and-match-against-the-rules loop: when `awk' tries to +read a record from an empty file, it immediately receives an end of +file indication, closes the file, and proceeds on to the next +command-line data file, _without_ executing any user-level `awk' +program code. + + Using `gawk''s `ARGIND' variable (*note Built-in Variables::), it is +possible to detect when an empty data file has been skipped. Similar +to the library file presented in *note Filetrans Function::, the +following library file calls a function named `zerofile()' that the +user must provide. The arguments passed are the file name and the +position in `ARGV' where it was found: + + # zerofile.awk --- library file to process empty input files + + BEGIN { Argind = 0 } + + ARGIND > Argind + 1 { + for (Argind++; Argind < ARGIND; Argind++) + zerofile(ARGV[Argind], Argind) + } + + ARGIND != Argind { Argind = ARGIND } + + END { + if (ARGIND > Argind) + for (Argind++; Argind <= ARGIND; Argind++) + zerofile(ARGV[Argind], Argind) + } + + The user-level variable `Argind' allows the `awk' program to track +its progress through `ARGV'. Whenever the program detects that +`ARGIND' is greater than `Argind + 1', it means that one or more empty +files were skipped. The action then calls `zerofile()' for each such +file, incrementing `Argind' along the way. + + The `Argind != ARGIND' rule simply keeps `Argind' up to date in the +normal case. + + Finally, the `END' rule catches the case of any empty files at the +end of the command-line arguments. Note that the test in the condition +of the `for' loop uses the `<=' operator, not `<'. + + As an exercise, you might consider whether this same problem can be +solved without relying on `gawk''s `ARGIND' variable. + + As a second exercise, revise this code to handle the case where an +intervening value in `ARGV' is a variable assignment. + + +File: gawk.info, Node: Ignoring Assigns, Prev: Empty Files, Up: Data File Management + +12.3.5 Treating Assignments as File Names +----------------------------------------- + +Occasionally, you might not want `awk' to process command-line variable +assignments (*note Assignment Options::). In particular, if you have a +file name that contain an `=' character, `awk' treats the file name as +an assignment, and does not process it. + + Some users have suggested an additional command-line option for +`gawk' to disable command-line assignments. However, some simple +programming with a library file does the trick: + + # noassign.awk --- library file to avoid the need for a + # special option that disables command-line assignments + + function disable_assigns(argc, argv, i) + { + for (i = 1; i < argc; i++) + if (argv[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/) + argv[i] = ("./" argv[i]) + } + + BEGIN { + if (No_command_assign) + disable_assigns(ARGC, ARGV) + } + + You then run your program this way: + + awk -v No_command_assign=1 -f noassign.awk -f yourprog.awk * + + The function works by looping through the arguments. It prepends +`./' to any argument that matches the form of a variable assignment, +turning that argument into a file name. + + The use of `No_command_assign' allows you to disable command-line +assignments at invocation time, by giving the variable a true value. +When not set, it is initially zero (i.e., false), so the command-line +arguments are left alone. + + +File: gawk.info, Node: Getopt Function, Next: Passwd Functions, Prev: Data File Management, Up: Library Functions + +12.4 Processing Command-Line Options +==================================== + +Most utilities on POSIX compatible systems take options on the command +line that can be used to change the way a program behaves. `awk' is an +example of such a program (*note Options::). Often, options take +"arguments"; i.e., data that the program needs to correctly obey the +command-line option. For example, `awk''s `-F' option requires a +string to use as the field separator. The first occurrence on the +command line of either `--' or a string that does not begin with `-' +ends the options. + + Modern Unix systems provide a C function named `getopt()' for +processing command-line arguments. The programmer provides a string +describing the one-letter options. If an option requires an argument, +it is followed in the string with a colon. `getopt()' is also passed +the count and values of the command-line arguments and is called in a +loop. `getopt()' processes the command-line arguments for option +letters. Each time around the loop, it returns a single character +representing the next option letter that it finds, or `?' if it finds +an invalid option. When it returns -1, there are no options left on +the command line. + + When using `getopt()', options that do not take arguments can be +grouped together. Furthermore, options that take arguments require +that the argument be present. The argument can immediately follow the +option letter, or it can be a separate command-line argument. + + Given a hypothetical program that takes three command-line options, +`-a', `-b', and `-c', where `-b' requires an argument, all of the +following are valid ways of invoking the program: + + prog -a -b foo -c data1 data2 data3 + prog -ac -bfoo -- data1 data2 data3 + prog -acbfoo data1 data2 data3 + + Notice that when the argument is grouped with its option, the rest of +the argument is considered to be the option's argument. In this +example, `-acbfoo' indicates that all of the `-a', `-b', and `-c' +options were supplied, and that `foo' is the argument to the `-b' +option. + + `getopt()' provides four external variables that the programmer can +use: + +`optind' + The index in the argument value array (`argv') where the first + nonoption command-line argument can be found. + +`optarg' + The string value of the argument to an option. + +`opterr' + Usually `getopt()' prints an error message when it finds an invalid + option. Setting `opterr' to zero disables this feature. (An + application might want to print its own error message.) + +`optopt' + The letter representing the command-line option. + + The following C fragment shows how `getopt()' might process +command-line arguments for `awk': + + int + main(int argc, char *argv[]) + { + ... + /* print our own message */ + opterr = 0; + while ((c = getopt(argc, argv, "v:f:F:W:")) != -1) { + switch (c) { + case 'f': /* file */ + ... + break; + case 'F': /* field separator */ + ... + break; + case 'v': /* variable assignment */ + ... + break; + case 'W': /* extension */ + ... + break; + case '?': + default: + usage(); + break; + } + } + ... + } + + As a side point, `gawk' actually uses the GNU `getopt_long()' +function to process both normal and GNU-style long options (*note +Options::). + + The abstraction provided by `getopt()' is very useful and is quite +handy in `awk' programs as well. Following is an `awk' version of +`getopt()'. This function highlights one of the greatest weaknesses in +`awk', which is that it is very poor at manipulating single characters. +Repeated calls to `substr()' are necessary for accessing individual +characters (*note String Functions::).(1) + + The discussion that follows walks through the code a bit at a time: + + # getopt.awk --- Do C library getopt(3) function in awk + + # External variables: + # Optind -- index in ARGV of first nonoption argument + # Optarg -- string value of argument to current option + # Opterr -- if nonzero, print our own diagnostic + # Optopt -- current option letter + + # Returns: + # -1 at end of options + # "?" for unrecognized option + # a character representing the current option + + # Private Data: + # _opti -- index in multi-flag option, e.g., -abc + + The function starts out with comments presenting a list of the +global variables it uses, what the return values are, what they mean, +and any global variables that are "private" to this library function. +Such documentation is essential for any program, and particularly for +library functions. + + The `getopt()' function first checks that it was indeed called with +a string of options (the `options' parameter). If `options' has a zero +length, `getopt()' immediately returns -1: + + function getopt(argc, argv, options, thisopt, i) + { + if (length(options) == 0) # no options given + return -1 + + if (argv[Optind] == "--") { # all done + Optind++ + _opti = 0 + return -1 + } else if (argv[Optind] !~ /^-[^:[:space:]]/) { + _opti = 0 + return -1 + } + + The next thing to check for is the end of the options. A `--' ends +the command-line options, as does any command-line argument that does +not begin with a `-'. `Optind' is used to step through the array of +command-line arguments; it retains its value across calls to +`getopt()', because it is a global variable. + + The regular expression that is used, `/^-[^:[:space:]/', checks for +a `-' followed by anything that is not whitespace and not a colon. If +the current command-line argument does not match this pattern, it is +not an option, and it ends option processing. Continuing on: + + if (_opti == 0) + _opti = 2 + thisopt = substr(argv[Optind], _opti, 1) + Optopt = thisopt + i = index(options, thisopt) + if (i == 0) { + if (Opterr) + printf("%c -- invalid option\n", + thisopt) > "/dev/stderr" + if (_opti >= length(argv[Optind])) { + Optind++ + _opti = 0 + } else + _opti++ + return "?" + } + + The `_opti' variable tracks the position in the current command-line +argument (`argv[Optind]'). If multiple options are grouped together +with one `-' (e.g., `-abx'), it is necessary to return them to the user +one at a time. + + If `_opti' is equal to zero, it is set to two, which is the index in +the string of the next character to look at (we skip the `-', which is +at position one). The variable `thisopt' holds the character, obtained +with `substr()'. It is saved in `Optopt' for the main program to use. + + If `thisopt' is not in the `options' string, then it is an invalid +option. If `Opterr' is nonzero, `getopt()' prints an error message on +the standard error that is similar to the message from the C version of +`getopt()'. + + Because the option is invalid, it is necessary to skip it and move +on to the next option character. If `_opti' is greater than or equal +to the length of the current command-line argument, it is necessary to +move on to the next argument, so `Optind' is incremented and `_opti' is +reset to zero. Otherwise, `Optind' is left alone and `_opti' is merely +incremented. + + In any case, because the option is invalid, `getopt()' returns `"?"'. +The main program can examine `Optopt' if it needs to know what the +invalid option letter actually is. Continuing on: + + if (substr(options, i + 1, 1) == ":") { + # get option argument + if (length(substr(argv[Optind], _opti + 1)) > 0) + Optarg = substr(argv[Optind], _opti + 1) + else + Optarg = argv[++Optind] + _opti = 0 + } else + Optarg = "" + + If the option requires an argument, the option letter is followed by +a colon in the `options' string. If there are remaining characters in +the current command-line argument (`argv[Optind]'), then the rest of +that string is assigned to `Optarg'. Otherwise, the next command-line +argument is used (`-xFOO' versus `-x FOO'). In either case, `_opti' is +reset to zero, because there are no more characters left to examine in +the current command-line argument. Continuing: + + if (_opti == 0 || _opti >= length(argv[Optind])) { + Optind++ + _opti = 0 + } else + _opti++ + return thisopt + } + + Finally, if `_opti' is either zero or greater than the length of the +current command-line argument, it means this element in `argv' is +through being processed, so `Optind' is incremented to point to the +next element in `argv'. If neither condition is true, then only +`_opti' is incremented, so that the next option letter can be processed +on the next call to `getopt()'. + + The `BEGIN' rule initializes both `Opterr' and `Optind' to one. +`Opterr' is set to one, since the default behavior is for `getopt()' to +print a diagnostic message upon seeing an invalid option. `Optind' is +set to one, since there's no reason to look at the program name, which +is in `ARGV[0]': + + BEGIN { + Opterr = 1 # default is to diagnose + Optind = 1 # skip ARGV[0] + + # test program + if (_getopt_test) { + while ((_go_c = getopt(ARGC, ARGV, "ab:cd")) != -1) + printf("c = <%c>, optarg = <%s>\n", + _go_c, Optarg) + printf("non-option arguments:\n") + for (; Optind < ARGC; Optind++) + printf("\tARGV[%d] = <%s>\n", + Optind, ARGV[Optind]) + } + } + + The rest of the `BEGIN' rule is a simple test program. Here is the +result of two sample runs of the test program: + + $ awk -f getopt.awk -v _getopt_test=1 -- -a -cbARG bax -x + -| c = , optarg = <> + -| c = , optarg = <> + -| c = , optarg = + -| non-option arguments: + -| ARGV[3] = + -| ARGV[4] = <-x> + + $ awk -f getopt.awk -v _getopt_test=1 -- -a -x -- xyz abc + -| c = , optarg = <> + error--> x -- invalid option + -| c = , optarg = <> + -| non-option arguments: + -| ARGV[4] = + -| ARGV[5] = + + In both runs, the first `--' terminates the arguments to `awk', so +that it does not try to interpret the `-a', etc., as its own options. + + NOTE: After `getopt()' is through, it is the responsibility of the + user level code to clear out all the elements of `ARGV' from 1 to + `Optind', so that `awk' does not try to process the command-line + options as file names. + + Several of the sample programs presented in *note Sample Programs::, +use `getopt()' to process their arguments. + + ---------- Footnotes ---------- + + (1) This function was written before `gawk' acquired the ability to +split strings into single characters using `""' as the separator. We +have left it alone, since using `substr()' is more portable. + + +File: gawk.info, Node: Passwd Functions, Next: Group Functions, Prev: Getopt Function, Up: Library Functions + +12.5 Reading the User Database +============================== + +The `PROCINFO' array (*note Built-in Variables::) provides access to +the current user's real and effective user and group ID numbers, and if +available, the user's supplementary group set. However, because these +are numbers, they do not provide very useful information to the average +user. There needs to be some way to find the user information +associated with the user and group ID numbers. This minor node +presents a suite of functions for retrieving information from the user +database. *Note Group Functions::, for a similar suite that retrieves +information from the group database. + + The POSIX standard does not define the file where user information is +kept. Instead, it provides the `' header file and several C +language subroutines for obtaining user information. The primary +function is `getpwent()', for "get password entry." The "password" +comes from the original user database file, `/etc/passwd', which stores +user information, along with the encrypted passwords (hence the name). + + While an `awk' program could simply read `/etc/passwd' directly, +this file may not contain complete information about the system's set +of users.(1) To be sure you are able to produce a readable and complete +version of the user database, it is necessary to write a small C +program that calls `getpwent()'. `getpwent()' is defined as returning +a pointer to a `struct passwd'. Each time it is called, it returns the +next entry in the database. When there are no more entries, it returns +`NULL', the null pointer. When this happens, the C program should call +`endpwent()' to close the database. Following is `pwcat', a C program +that "cats" the password database: + + /* + * pwcat.c + * + * Generate a printable version of the password database + */ + #include + #include + + int + main(int argc, char **argv) + { + struct passwd *p; + + while ((p = getpwent()) != NULL) + printf("%s:%s:%ld:%ld:%s:%s:%s\n", + p->pw_name, p->pw_passwd, (long) p->pw_uid, + (long) p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell); + + endpwent(); + return 0; + } + + If you don't understand C, don't worry about it. The output from +`pwcat' is the user database, in the traditional `/etc/passwd' format +of colon-separated fields. The fields are: + +Login name + The user's login name. + +Encrypted password + The user's encrypted password. This may not be available on some + systems. + +User-ID + The user's numeric user ID number. (On some systems it's a C + `long', and not an `int'. Thus we cast it to `long' for all + cases.) + +Group-ID + The user's numeric group ID number. (Similar comments about + `long' vs. `int' apply here.) + +Full name + The user's full name, and perhaps other information associated + with the user. + +Home directory + The user's login (or "home") directory (familiar to shell + programmers as `$HOME'). + +Login shell + The program that is run when the user logs in. This is usually a + shell, such as Bash. + + A few lines representative of `pwcat''s output are as follows: + + $ pwcat + -| root:3Ov02d5VaUPB6:0:1:Operator:/:/bin/sh + -| nobody:*:65534:65534::/: + -| daemon:*:1:1::/: + -| sys:*:2:2::/:/bin/csh + -| bin:*:3:3::/bin: + -| arnold:xyzzy:2076:10:Arnold Robbins:/home/arnold:/bin/sh + -| miriam:yxaay:112:10:Miriam Robbins:/home/miriam:/bin/sh + -| andy:abcca2:113:10:Andy Jacobs:/home/andy:/bin/sh + ... + + With that introduction, following is a group of functions for +getting user information. There are several functions here, +corresponding to the C functions of the same names: + + # passwd.awk --- access password file information + + BEGIN { + # tailor this to suit your system + _pw_awklib = "/usr/local/libexec/awk/" + } + + function _pw_init( oldfs, oldrs, olddol0, pwcat, using_fw, using_fpat) + { + if (_pw_inited) + return + + oldfs = FS + oldrs = RS + olddol0 = $0 + using_fw = (PROCINFO["FS"] == "FIELDWIDTHS") + using_fpat = (PROCINFO["FS"] == "FPAT") + FS = ":" + RS = "\n" + + pwcat = _pw_awklib "pwcat" + while ((pwcat | getline) > 0) { + _pw_byname[$1] = $0 + _pw_byuid[$3] = $0 + _pw_bycount[++_pw_total] = $0 + } + close(pwcat) + _pw_count = 0 + _pw_inited = 1 + FS = oldfs + if (using_fw) + FIELDWIDTHS = FIELDWIDTHS + else if (using_fpat) + FPAT = FPAT + RS = oldrs + $0 = olddol0 + } + + The `BEGIN' rule sets a private variable to the directory where +`pwcat' is stored. Because it is used to help out an `awk' library +routine, we have chosen to put it in `/usr/local/libexec/awk'; however, +you might want it to be in a different directory on your system. + + The function `_pw_init()' keeps three copies of the user information +in three associative arrays. The arrays are indexed by username +(`_pw_byname'), by user ID number (`_pw_byuid'), and by order of +occurrence (`_pw_bycount'). The variable `_pw_inited' is used for +efficiency, since `_pw_init()' needs to be called only once. + + Because this function uses `getline' to read information from +`pwcat', it first saves the values of `FS', `RS', and `$0'. It notes +in the variable `using_fw' whether field splitting with `FIELDWIDTHS' +is in effect or not. Doing so is necessary, since these functions +could be called from anywhere within a user's program, and the user may +have his or her own way of splitting records and fields. + + The `using_fw' variable checks `PROCINFO["FS"]', which is +`"FIELDWIDTHS"' if field splitting is being done with `FIELDWIDTHS'. +This makes it possible to restore the correct field-splitting mechanism +later. The test can only be true for `gawk'. It is false if using +`FS' or `FPAT', or on some other `awk' implementation. + + The code that checks for using `FPAT', using `using_fpat' and +`PROCINFO["FS"]' is similar. + + The main part of the function uses a loop to read database lines, +split the line into fields, and then store the line into each array as +necessary. When the loop is done, `_pw_init()' cleans up by closing +the pipeline, setting `_pw_inited' to one, and restoring `FS' (and +`FIELDWIDTHS' or `FPAT' if necessary), `RS', and `$0'. The use of +`_pw_count' is explained shortly. + + The `getpwnam()' function takes a username as a string argument. If +that user is in the database, it returns the appropriate line. +Otherwise, it relies on the array reference to a nonexistent element to +create the element with the null string as its value: + + function getpwnam(name) + { + _pw_init() + return _pw_byname[name] + } + + Similarly, the `getpwuid' function takes a user ID number argument. +If that user number is in the database, it returns the appropriate +line. Otherwise, it returns the null string: + + function getpwuid(uid) + { + _pw_init() + return _pw_byuid[uid] + } + + The `getpwent()' function simply steps through the database, one +entry at a time. It uses `_pw_count' to track its current position in +the `_pw_bycount' array: + + function getpwent() + { + _pw_init() + if (_pw_count < _pw_total) + return _pw_bycount[++_pw_count] + return "" + } + + The `endpwent()' function resets `_pw_count' to zero, so that +subsequent calls to `getpwent()' start over again: + + function endpwent() + { + _pw_count = 0 + } + + A conscious design decision in this suite is that each subroutine +calls `_pw_init()' to initialize the database arrays. The overhead of +running a separate process to generate the user database, and the I/O +to scan it, are only incurred if the user's main program actually calls +one of these functions. If this library file is loaded along with a +user's program, but none of the routines are ever called, then there is +no extra runtime overhead. (The alternative is move the body of +`_pw_init()' into a `BEGIN' rule, which always runs `pwcat'. This +simplifies the code but runs an extra process that may never be needed.) + + In turn, calling `_pw_init()' is not too expensive, because the +`_pw_inited' variable keeps the program from reading the data more than +once. If you are worried about squeezing every last cycle out of your +`awk' program, the check of `_pw_inited' could be moved out of +`_pw_init()' and duplicated in all the other functions. In practice, +this is not necessary, since most `awk' programs are I/O-bound, and +such a change would clutter up the code. + + The `id' program in *note Id Program::, uses these functions. + + ---------- Footnotes ---------- + + (1) It is often the case that password information is stored in a +network database. + + +File: gawk.info, Node: Group Functions, Next: Walking Arrays, Prev: Passwd Functions, Up: Library Functions + +12.6 Reading the Group Database +=============================== + +Much of the discussion presented in *note Passwd Functions::, applies +to the group database as well. Although there has traditionally been a +well-known file (`/etc/group') in a well-known format, the POSIX +standard only provides a set of C library routines (`' and +`getgrent()') for accessing the information. Even though this file may +exist, it may not have complete information. Therefore, as with the +user database, it is necessary to have a small C program that generates +the group database as its output. `grcat', a C program that "cats" the +group database, is as follows: + + /* + * grcat.c + * + * Generate a printable version of the group database + */ + #include + #include + + int + main(int argc, char **argv) + { + struct group *g; + int i; + + while ((g = getgrent()) != NULL) { + printf("%s:%s:%ld:", g->gr_name, g->gr_passwd, + (long) g->gr_gid); + for (i = 0; g->gr_mem[i] != NULL; i++) { + printf("%s", g->gr_mem[i]); + if (g->gr_mem[i+1] != NULL) + putchar(','); + } + putchar('\n'); + } + endgrent(); + return 0; + } + + Each line in the group database represents one group. The fields are +separated with colons and represent the following information: + +Group Name + The group's name. + +Group Password + The group's encrypted password. In practice, this field is never + used; it is usually empty or set to `*'. + +Group ID Number + The group's numeric group ID number; this number must be unique + within the file. (On some systems it's a C `long', and not an + `int'. Thus we cast it to `long' for all cases.) + +Group Member List + A comma-separated list of user names. These users are members of + the group. Modern Unix systems allow users to be members of + several groups simultaneously. If your system does, then there + are elements `"group1"' through `"groupN"' in `PROCINFO' for those + group ID numbers. (Note that `PROCINFO' is a `gawk' extension; + *note Built-in Variables::.) + + Here is what running `grcat' might produce: + + $ grcat + -| wheel:*:0:arnold + -| nogroup:*:65534: + -| daemon:*:1: + -| kmem:*:2: + -| staff:*:10:arnold,miriam,andy + -| other:*:20: + ... + + Here are the functions for obtaining information from the group +database. There are several, modeled after the C library functions of +the same names: + + # group.awk --- functions for dealing with the group file + + BEGIN \ + { + # Change to suit your system + _gr_awklib = "/usr/local/libexec/awk/" + } + + function _gr_init( oldfs, oldrs, olddol0, grcat, + using_fw, using_fpat, n, a, i) + { + if (_gr_inited) + return + + oldfs = FS + oldrs = RS + olddol0 = $0 + using_fw = (PROCINFO["FS"] == "FIELDWIDTHS") + using_fpat = (PROCINFO["FS"] == "FPAT") + FS = ":" + RS = "\n" + + grcat = _gr_awklib "grcat" + while ((grcat | getline) > 0) { + if ($1 in _gr_byname) + _gr_byname[$1] = _gr_byname[$1] "," $4 + else + _gr_byname[$1] = $0 + if ($3 in _gr_bygid) + _gr_bygid[$3] = _gr_bygid[$3] "," $4 + else + _gr_bygid[$3] = $0 + + n = split($4, a, "[ \t]*,[ \t]*") + for (i = 1; i <= n; i++) + if (a[i] in _gr_groupsbyuser) + _gr_groupsbyuser[a[i]] = \ + _gr_groupsbyuser[a[i]] " " $1 + else + _gr_groupsbyuser[a[i]] = $1 + + _gr_bycount[++_gr_count] = $0 + } + close(grcat) + _gr_count = 0 + _gr_inited++ + FS = oldfs + if (using_fw) + FIELDWIDTHS = FIELDWIDTHS + else if (using_fpat) + FPAT = FPAT + RS = oldrs + $0 = olddol0 + } + + The `BEGIN' rule sets a private variable to the directory where +`grcat' is stored. Because it is used to help out an `awk' library +routine, we have chosen to put it in `/usr/local/libexec/awk'. You +might want it to be in a different directory on your system. + + These routines follow the same general outline as the user database +routines (*note Passwd Functions::). The `_gr_inited' variable is used +to ensure that the database is scanned no more than once. The +`_gr_init()' function first saves `FS', `RS', and `$0', and then sets +`FS' and `RS' to the correct values for scanning the group information. +It also takes care to note whether `FIELDWIDTHS' or `FPAT' is being +used, and to restore the appropriate field splitting mechanism. + + The group information is stored is several associative arrays. The +arrays are indexed by group name (`_gr_byname'), by group ID number +(`_gr_bygid'), and by position in the database (`_gr_bycount'). There +is an additional array indexed by user name (`_gr_groupsbyuser'), which +is a space-separated list of groups to which each user belongs. + + Unlike the user database, it is possible to have multiple records in +the database for the same group. This is common when a group has a +large number of members. A pair of such entries might look like the +following: + + tvpeople:*:101:johnny,jay,arsenio + tvpeople:*:101:david,conan,tom,joan + + For this reason, `_gr_init()' looks to see if a group name or group +ID number is already seen. If it is, then the user names are simply +concatenated onto the previous list of users. (There is actually a +subtle problem with the code just presented. Suppose that the first +time there were no names. This code adds the names with a leading +comma. It also doesn't check that there is a `$4'.) + + Finally, `_gr_init()' closes the pipeline to `grcat', restores `FS' +(and `FIELDWIDTHS' or `FPAT' if necessary), `RS', and `$0', initializes +`_gr_count' to zero (it is used later), and makes `_gr_inited' nonzero. + + The `getgrnam()' function takes a group name as its argument, and if +that group exists, it is returned. Otherwise, it relies on the array +reference to a nonexistent element to create the element with the null +string as its value: + + function getgrnam(group) + { + _gr_init() + return _gr_byname[group] + } + + The `getgrgid()' function is similar; it takes a numeric group ID and +looks up the information associated with that group ID: + + function getgrgid(gid) + { + _gr_init() + return _gr_bygid[gid] + } + + The `getgruser()' function does not have a C counterpart. It takes a +user name and returns the list of groups that have the user as a member: + + function getgruser(user) + { + _gr_init() + return _gr_groupsbyuser[user] + } + + The `getgrent()' function steps through the database one entry at a +time. It uses `_gr_count' to track its position in the list: + + function getgrent() + { + _gr_init() + if (++_gr_count in _gr_bycount) + return _gr_bycount[_gr_count] + return "" + } + + The `endgrent()' function resets `_gr_count' to zero so that +`getgrent()' can start over again: + + function endgrent() + { + _gr_count = 0 + } + + As with the user database routines, each function calls `_gr_init()' +to initialize the arrays. Doing so only incurs the extra overhead of +running `grcat' if these functions are used (as opposed to moving the +body of `_gr_init()' into a `BEGIN' rule). + + Most of the work is in scanning the database and building the various +associative arrays. The functions that the user calls are themselves +very simple, relying on `awk''s associative arrays to do work. + + The `id' program in *note Id Program::, uses these functions. + + +File: gawk.info, Node: Walking Arrays, Prev: Group Functions, Up: Library Functions + +12.7 Traversing Arrays of Arrays +================================ + +*note Arrays of Arrays::, described how `gawk' provides arrays of +arrays. In particular, any element of an array may be either a scalar, +or another array. The `isarray()' function (*note Type Functions::) +lets you distinguish an array from a scalar. The following function, +`walk_array()', recursively traverses an array, printing each element's +indices and value. You call it with the array and a string +representing the name of the array: + + function walk_array(arr, name, i) + { + for (i in arr) { + if (isarray(arr[i])) + walk_array(arr[i], (name "[" i "]")) + else + printf("%s[%s] = %s\n", name, i, arr[i]) + } + } + +It works by looping over each element of the array. If any given +element is itself an array, the function calls itself recursively, +passing the subarray and a new string representing the current index. +Otherwise, the function simply prints the element's name, index, and +value. Here is a main program to demonstrate: + + BEGIN { + a[1] = 1 + a[2][1] = 21 + a[2][2] = 22 + a[3] = 3 + a[4][1][1] = 411 + a[4][2] = 42 + + walk_array(a, "a") + } + + When run, the program produces the following output: + + $ gawk -f walk_array.awk + -| a[4][1][1] = 411 + -| a[4][2] = 42 + -| a[1] = 1 + -| a[2][1] = 21 + -| a[2][2] = 22 + -| a[3] = 3 + + +File: gawk.info, Node: Sample Programs, Next: Debugger, Prev: Library Functions, Up: Top + +13 Practical `awk' Programs +*************************** + +*note Library Functions::, presents the idea that reading programs in a +language contributes to learning that language. This major node +continues that theme, presenting a potpourri of `awk' programs for your +reading enjoyment. + + Many of these programs use library functions presented in *note +Library Functions::. + +* Menu: + +* Running Examples:: How to run these examples. +* Clones:: Clones of common utilities. +* Miscellaneous Programs:: Some interesting `awk' programs. + + +File: gawk.info, Node: Running Examples, Next: Clones, Up: Sample Programs + +13.1 Running the Example Programs +================================= + +To run a given program, you would typically do something like this: + + awk -f PROGRAM -- OPTIONS FILES + +Here, PROGRAM is the name of the `awk' program (such as `cut.awk'), +OPTIONS are any command-line options for the program that start with a +`-', and FILES are the actual data files. + + If your system supports the `#!' executable interpreter mechanism +(*note Executable Scripts::), you can instead run your program directly: + + cut.awk -c1-8 myfiles > results + + If your `awk' is not `gawk', you may instead need to use this: + + cut.awk -- -c1-8 myfiles > results + + +File: gawk.info, Node: Clones, Next: Miscellaneous Programs, Prev: Running Examples, Up: Sample Programs + +13.2 Reinventing Wheels for Fun and Profit +========================================== + +This minor node presents a number of POSIX utilities implemented in +`awk'. Reinventing these programs in `awk' is often enjoyable, because +the algorithms can be very clearly expressed, and the code is usually +very concise and simple. This is true because `awk' does so much for +you. + + It should be noted that these programs are not necessarily intended +to replace the installed versions on your system. Nor may all of these +programs be fully compliant with the most recent POSIX standard. This +is not a problem; their purpose is to illustrate `awk' language +programming for "real world" tasks. + + The programs are presented in alphabetical order. + +* Menu: + +* Cut Program:: The `cut' utility. +* Egrep Program:: The `egrep' utility. +* Id Program:: The `id' utility. +* Split Program:: The `split' utility. +* Tee Program:: The `tee' utility. +* Uniq Program:: The `uniq' utility. +* Wc Program:: The `wc' utility. + + +File: gawk.info, Node: Cut Program, Next: Egrep Program, Up: Clones + +13.2.1 Cutting out Fields and Columns +------------------------------------- + +The `cut' utility selects, or "cuts," characters or fields from its +standard input and sends them to its standard output. Fields are +separated by TABs by default, but you may supply a command-line option +to change the field "delimiter" (i.e., the field-separator character). +`cut''s definition of fields is less general than `awk''s. + + A common use of `cut' might be to pull out just the login name of +logged-on users from the output of `who'. For example, the following +pipeline generates a sorted, unique list of the logged-on users: + + who | cut -c1-8 | sort | uniq + + The options for `cut' are: + +`-c LIST' + Use LIST as the list of characters to cut out. Items within the + list may be separated by commas, and ranges of characters can be + separated with dashes. The list `1-8,15,22-35' specifies + characters 1 through 8, 15, and 22 through 35. + +`-f LIST' + Use LIST as the list of fields to cut out. + +`-d DELIM' + Use DELIM as the field-separator character instead of the TAB + character. + +`-s' + Suppress printing of lines that do not contain the field delimiter. + + The `awk' implementation of `cut' uses the `getopt()' library +function (*note Getopt Function::) and the `join()' library function +(*note Join Function::). + + The program begins with a comment describing the options, the library +functions needed, and a `usage()' function that prints out a usage +message and exits. `usage()' is called if invalid arguments are +supplied: + + # cut.awk --- implement cut in awk + + # Options: + # -f list Cut fields + # -d c Field delimiter character + # -c list Cut characters + # + # -s Suppress lines without the delimiter + # + # Requires getopt() and join() library functions + + function usage( e1, e2) + { + e1 = "usage: cut [-f list] [-d c] [-s] [files...]" + e2 = "usage: cut [-c list] [files...]" + print e1 > "/dev/stderr" + print e2 > "/dev/stderr" + exit 1 + } + +The variables `e1' and `e2' are used so that the function fits nicely +on the screen. + + Next comes a `BEGIN' rule that parses the command-line options. It +sets `FS' to a single TAB character, because that is `cut''s default +field separator. The rule then sets the output field separator to be the +same as the input field separator. A loop using `getopt()' steps +through the command-line options. Exactly one of the variables +`by_fields' or `by_chars' is set to true, to indicate that processing +should be done by fields or by characters, respectively. When cutting +by characters, the output field separator is set to the null string: + + BEGIN \ + { + FS = "\t" # default + OFS = FS + while ((c = getopt(ARGC, ARGV, "sf:c:d:")) != -1) { + if (c == "f") { + by_fields = 1 + fieldlist = Optarg + } else if (c == "c") { + by_chars = 1 + fieldlist = Optarg + OFS = "" + } else if (c == "d") { + if (length(Optarg) > 1) { + printf("Using first character of %s" \ + " for delimiter\n", Optarg) > "/dev/stderr" + Optarg = substr(Optarg, 1, 1) + } + FS = Optarg + OFS = FS + if (FS == " ") # defeat awk semantics + FS = "[ ]" + } else if (c == "s") + suppress++ + else + usage() + } + + # Clear out options + for (i = 1; i < Optind; i++) + ARGV[i] = "" + + The code must take special care when the field delimiter is a space. +Using a single space (`" "') for the value of `FS' is incorrect--`awk' +would separate fields with runs of spaces, TABs, and/or newlines, and +we want them to be separated with individual spaces. Also remember +that after `getopt()' is through (as described in *note Getopt +Function::), we have to clear out all the elements of `ARGV' from 1 to +`Optind', so that `awk' does not try to process the command-line options +as file names. + + After dealing with the command-line options, the program verifies +that the options make sense. Only one or the other of `-c' and `-f' +should be used, and both require a field list. Then the program calls +either `set_fieldlist()' or `set_charlist()' to pull apart the list of +fields or characters: + + if (by_fields && by_chars) + usage() + + if (by_fields == 0 && by_chars == 0) + by_fields = 1 # default + + if (fieldlist == "") { + print "cut: needs list for -c or -f" > "/dev/stderr" + exit 1 + } + + if (by_fields) + set_fieldlist() + else + set_charlist() + } + + `set_fieldlist()' splits the field list apart at the commas into an +array. Then, for each element of the array, it looks to see if the +element is actually a range, and if so, splits it apart. The function +checks the range to make sure that the first number is smaller than the +second. Each number in the list is added to the `flist' array, which +simply lists the fields that will be printed. Normal field splitting +is used. The program lets `awk' handle the job of doing the field +splitting: + + function set_fieldlist( n, m, i, j, k, f, g) + { + n = split(fieldlist, f, ",") + j = 1 # index in flist + for (i = 1; i <= n; i++) { + if (index(f[i], "-") != 0) { # a range + m = split(f[i], g, "-") + if (m != 2 || g[1] >= g[2]) { + printf("bad field list: %s\n", + f[i]) > "/dev/stderr" + exit 1 + } + for (k = g[1]; k <= g[2]; k++) + flist[j++] = k + } else + flist[j++] = f[i] + } + nfields = j - 1 + } + + The `set_charlist()' function is more complicated than +`set_fieldlist()'. The idea here is to use `gawk''s `FIELDWIDTHS' +variable (*note Constant Size::), which describes constant-width input. +When using a character list, that is exactly what we have. + + Setting up `FIELDWIDTHS' is more complicated than simply listing the +fields that need to be printed. We have to keep track of the fields to +print and also the intervening characters that have to be skipped. For +example, suppose you wanted characters 1 through 8, 15, and 22 through +35. You would use `-c 1-8,15,22-35'. The necessary value for +`FIELDWIDTHS' is `"8 6 1 6 14"'. This yields five fields, and the +fields to print are `$1', `$3', and `$5'. The intermediate fields are +"filler", which is stuff in between the desired data. `flist' lists +the fields to print, and `t' tracks the complete field list, including +filler fields: + + function set_charlist( field, i, j, f, g, t, + filler, last, len) + { + field = 1 # count total fields + n = split(fieldlist, f, ",") + j = 1 # index in flist + for (i = 1; i <= n; i++) { + if (index(f[i], "-") != 0) { # range + m = split(f[i], g, "-") + if (m != 2 || g[1] >= g[2]) { + printf("bad character list: %s\n", + f[i]) > "/dev/stderr" + exit 1 + } + len = g[2] - g[1] + 1 + if (g[1] > 1) # compute length of filler + filler = g[1] - last - 1 + else + filler = 0 + if (filler) + t[field++] = filler + t[field++] = len # length of field + last = g[2] + flist[j++] = field - 1 + } else { + if (f[i] > 1) + filler = f[i] - last - 1 + else + filler = 0 + if (filler) + t[field++] = filler + t[field++] = 1 + last = f[i] + flist[j++] = field - 1 + } + } + FIELDWIDTHS = join(t, 1, field - 1) + nfields = j - 1 + } + + Next is the rule that actually processes the data. If the `-s' +option is given, then `suppress' is true. The first `if' statement +makes sure that the input record does have the field separator. If +`cut' is processing fields, `suppress' is true, and the field separator +character is not in the record, then the record is skipped. + + If the record is valid, then `gawk' has split the data into fields, +either using the character in `FS' or using fixed-length fields and +`FIELDWIDTHS'. The loop goes through the list of fields that should be +printed. The corresponding field is printed if it contains data. If +the next field also has data, then the separator character is written +out between the fields: + + { + if (by_fields && suppress && index($0, FS) != 0) + next + + for (i = 1; i <= nfields; i++) { + if ($flist[i] != "") { + printf "%s", $flist[i] + if (i < nfields && $flist[i+1] != "") + printf "%s", OFS + } + } + print "" + } + + This version of `cut' relies on `gawk''s `FIELDWIDTHS' variable to +do the character-based cutting. While it is possible in other `awk' +implementations to use `substr()' (*note String Functions::), it is +also extremely painful. The `FIELDWIDTHS' variable supplies an elegant +solution to the problem of picking the input line apart by characters. + + +File: gawk.info, Node: Egrep Program, Next: Id Program, Prev: Cut Program, Up: Clones + +13.2.2 Searching for Regular Expressions in Files +------------------------------------------------- + +The `egrep' utility searches files for patterns. It uses regular +expressions that are almost identical to those available in `awk' +(*note Regexp::). You invoke it as follows: + + egrep [ OPTIONS ] 'PATTERN' FILES ... + + The PATTERN is a regular expression. In typical usage, the regular +expression is quoted to prevent the shell from expanding any of the +special characters as file name wildcards. Normally, `egrep' prints +the lines that matched. If multiple file names are provided on the +command line, each output line is preceded by the name of the file and +a colon. + + The options to `egrep' are as follows: + +`-c' + Print out a count of the lines that matched the pattern, instead + of the lines themselves. + +`-s' + Be silent. No output is produced and the exit value indicates + whether the pattern was matched. + +`-v' + Invert the sense of the test. `egrep' prints the lines that do + _not_ match the pattern and exits successfully if the pattern is + not matched. + +`-i' + Ignore case distinctions in both the pattern and the input data. + +`-l' + Only print (list) the names of the files that matched, not the + lines that matched. + +`-e PATTERN' + Use PATTERN as the regexp to match. The purpose of the `-e' + option is to allow patterns that start with a `-'. + + This version uses the `getopt()' library function (*note Getopt +Function::) and the file transition library program (*note Filetrans +Function::). + + The program begins with a descriptive comment and then a `BEGIN' rule +that processes the command-line arguments with `getopt()'. The `-i' +(ignore case) option is particularly easy with `gawk'; we just use the +`IGNORECASE' built-in variable (*note Built-in Variables::): + + # egrep.awk --- simulate egrep in awk + # + # Options: + # -c count of lines + # -s silent - use exit value + # -v invert test, success if no match + # -i ignore case + # -l print filenames only + # -e argument is pattern + # + # Requires getopt and file transition library functions + + BEGIN { + while ((c = getopt(ARGC, ARGV, "ce:svil")) != -1) { + if (c == "c") + count_only++ + else if (c == "s") + no_print++ + else if (c == "v") + invert++ + else if (c == "i") + IGNORECASE = 1 + else if (c == "l") + filenames_only++ + else if (c == "e") + pattern = Optarg + else + usage() + } + + Next comes the code that handles the `egrep'-specific behavior. If no +pattern is supplied with `-e', the first nonoption on the command line +is used. The `awk' command-line arguments up to `ARGV[Optind]' are +cleared, so that `awk' won't try to process them as files. If no files +are specified, the standard input is used, and if multiple files are +specified, we make sure to note this so that the file names can precede +the matched lines in the output: + + if (pattern == "") + pattern = ARGV[Optind++] + + for (i = 1; i < Optind; i++) + ARGV[i] = "" + if (Optind >= ARGC) { + ARGV[1] = "-" + ARGC = 2 + } else if (ARGC - Optind > 1) + do_filenames++ + + # if (IGNORECASE) + # pattern = tolower(pattern) + } + + The last two lines are commented out, since they are not needed in +`gawk'. They should be uncommented if you have to use another version +of `awk'. + + The next set of lines should be uncommented if you are not using +`gawk'. This rule translates all the characters in the input line into +lowercase if the `-i' option is specified.(1) The rule is commented out +since it is not necessary with `gawk': + + #{ + # if (IGNORECASE) + # $0 = tolower($0) + #} + + The `beginfile()' function is called by the rule in `ftrans.awk' +when each new file is processed. In this case, it is very simple; all +it does is initialize a variable `fcount' to zero. `fcount' tracks how +many lines in the current file matched the pattern. Naming the +parameter `junk' shows we know that `beginfile()' is called with a +parameter, but that we're not interested in its value: + + function beginfile(junk) + { + fcount = 0 + } + + The `endfile()' function is called after each file has been +processed. It affects the output only when the user wants a count of +the number of lines that matched. `no_print' is true only if the exit +status is desired. `count_only' is true if line counts are desired. +`egrep' therefore only prints line counts if printing and counting are +enabled. The output format must be adjusted depending upon the number +of files to process. Finally, `fcount' is added to `total', so that we +know the total number of lines that matched the pattern: + + function endfile(file) + { + if (! no_print && count_only) { + if (do_filenames) + print file ":" fcount + else + print fcount + } + + total += fcount + } + + The following rule does most of the work of matching lines. The +variable `matches' is true if the line matched the pattern. If the user +wants lines that did not match, the sense of `matches' is inverted +using the `!' operator. `fcount' is incremented with the value of +`matches', which is either one or zero, depending upon a successful or +unsuccessful match. If the line does not match, the `next' statement +just moves on to the next record. + + A number of additional tests are made, but they are only done if we +are not counting lines. First, if the user only wants exit status +(`no_print' is true), then it is enough to know that _one_ line in this +file matched, and we can skip on to the next file with `nextfile'. +Similarly, if we are only printing file names, we can print the file +name, and then skip to the next file with `nextfile'. Finally, each +line is printed, with a leading file name and colon if necessary: + + { + matches = ($0 ~ pattern) + if (invert) + matches = ! matches + + fcount += matches # 1 or 0 + + if (! matches) + next + + if (! count_only) { + if (no_print) + nextfile + + if (filenames_only) { + print FILENAME + nextfile + } + + if (do_filenames) + print FILENAME ":" $0 + else + print + } + } + + The `END' rule takes care of producing the correct exit status. If +there are no matches, the exit status is one; otherwise it is zero: + + END \ + { + if (total == 0) + exit 1 + exit 0 + } + + The `usage()' function prints a usage message in case of invalid +options, and then exits: + + function usage( e) + { + e = "Usage: egrep [-csvil] [-e pat] [files ...]" + e = e "\n\tegrep [-csvil] pat [files ...]" + print e > "/dev/stderr" + exit 1 + } + + The variable `e' is used so that the function fits nicely on the +printed page. + + Just a note on programming style: you may have noticed that the `END' +rule uses backslash continuation, with the open brace on a line by +itself. This is so that it more closely resembles the way functions +are written. Many of the examples in this major node use this style. +You can decide for yourself if you like writing your `BEGIN' and `END' +rules this way or not. + + ---------- Footnotes ---------- + + (1) It also introduces a subtle bug; if a match happens, we output +the translated line, not the original. + + +File: gawk.info, Node: Id Program, Next: Split Program, Prev: Egrep Program, Up: Clones + +13.2.3 Printing out User Information +------------------------------------ + +The `id' utility lists a user's real and effective user ID numbers, +real and effective group ID numbers, and the user's group set, if any. +`id' only prints the effective user ID and group ID if they are +different from the real ones. If possible, `id' also supplies the +corresponding user and group names. The output might look like this: + + $ id + -| uid=500(arnold) gid=500(arnold) groups=6(disk),7(lp),19(floppy) + + This information is part of what is provided by `gawk''s `PROCINFO' +array (*note Built-in Variables::). However, the `id' utility provides +a more palatable output than just individual numbers. + + Here is a simple version of `id' written in `awk'. It uses the user +database library functions (*note Passwd Functions::) and the group +database library functions (*note Group Functions::): + + The program is fairly straightforward. All the work is done in the +`BEGIN' rule. The user and group ID numbers are obtained from +`PROCINFO'. The code is repetitive. The entry in the user database +for the real user ID number is split into parts at the `:'. The name is +the first field. Similar code is used for the effective user ID number +and the group numbers: + + # id.awk --- implement id in awk + # + # Requires user and group library functions + # output is: + # uid=12(foo) euid=34(bar) gid=3(baz) \ + # egid=5(blat) groups=9(nine),2(two),1(one) + + BEGIN \ + { + uid = PROCINFO["uid"] + euid = PROCINFO["euid"] + gid = PROCINFO["gid"] + egid = PROCINFO["egid"] + + printf("uid=%d", uid) + pw = getpwuid(uid) + if (pw != "") { + split(pw, a, ":") + printf("(%s)", a[1]) + } + + if (euid != uid) { + printf(" euid=%d", euid) + pw = getpwuid(euid) + if (pw != "") { + split(pw, a, ":") + printf("(%s)", a[1]) + } + } + + printf(" gid=%d", gid) + pw = getgrgid(gid) + if (pw != "") { + split(pw, a, ":") + printf("(%s)", a[1]) + } + + if (egid != gid) { + printf(" egid=%d", egid) + pw = getgrgid(egid) + if (pw != "") { + split(pw, a, ":") + printf("(%s)", a[1]) + } + } + + for (i = 1; ("group" i) in PROCINFO; i++) { + if (i == 1) + printf(" groups=") + group = PROCINFO["group" i] + printf("%d", group) + pw = getgrgid(group) + if (pw != "") { + split(pw, a, ":") + printf("(%s)", a[1]) + } + if (("group" (i+1)) in PROCINFO) + printf(",") + } + + print "" + } + + The test in the `for' loop is worth noting. Any supplementary +groups in the `PROCINFO' array have the indices `"group1"' through +`"groupN"' for some N, i.e., the total number of supplementary groups. +However, we don't know in advance how many of these groups there are. + + This loop works by starting at one, concatenating the value with +`"group"', and then using `in' to see if that value is in the array. +Eventually, `i' is incremented past the last group in the array and the +loop exits. + + The loop is also correct if there are _no_ supplementary groups; +then the condition is false the first time it's tested, and the loop +body never executes. + + +File: gawk.info, Node: Split Program, Next: Tee Program, Prev: Id Program, Up: Clones + +13.2.4 Splitting a Large File into Pieces +----------------------------------------- + +The `split' program splits large text files into smaller pieces. Usage +is as follows:(1) + + split [-COUNT] file [ PREFIX ] + + By default, the output files are named `xaa', `xab', and so on. Each +file has 1000 lines in it, with the likely exception of the last file. +To change the number of lines in each file, supply a number on the +command line preceded with a minus; e.g., `-500' for files with 500 +lines in them instead of 1000. To change the name of the output files +to something like `myfileaa', `myfileab', and so on, supply an +additional argument that specifies the file name prefix. + + Here is a version of `split' in `awk'. It uses the `ord()' and +`chr()' functions presented in *note Ordinal Functions::. + + The program first sets its defaults, and then tests to make sure +there are not too many arguments. It then looks at each argument in +turn. The first argument could be a minus sign followed by a number. +If it is, this happens to look like a negative number, so it is made +positive, and that is the count of lines. The data file name is +skipped over and the final argument is used as the prefix for the +output file names: + + # split.awk --- do split in awk + # + # Requires ord() and chr() library functions + # usage: split [-num] [file] [outname] + + BEGIN { + outfile = "x" # default + count = 1000 + if (ARGC > 4) + usage() + + i = 1 + if (ARGV[i] ~ /^-[[:digit:]]+$/) { + count = -ARGV[i] + ARGV[i] = "" + i++ + } + # test argv in case reading from stdin instead of file + if (i in ARGV) + i++ # skip data file name + if (i in ARGV) { + outfile = ARGV[i] + ARGV[i] = "" + } + + s1 = s2 = "a" + out = (outfile s1 s2) + } + + The next rule does most of the work. `tcount' (temporary count) +tracks how many lines have been printed to the output file so far. If +it is greater than `count', it is time to close the current file and +start a new one. `s1' and `s2' track the current suffixes for the file +name. If they are both `z', the file is just too big. Otherwise, `s1' +moves to the next letter in the alphabet and `s2' starts over again at +`a': + + { + if (++tcount > count) { + close(out) + if (s2 == "z") { + if (s1 == "z") { + printf("split: %s is too large to split\n", + FILENAME) > "/dev/stderr" + exit 1 + } + s1 = chr(ord(s1) + 1) + s2 = "a" + } + else + s2 = chr(ord(s2) + 1) + out = (outfile s1 s2) + tcount = 1 + } + print > out + } + +The `usage()' function simply prints an error message and exits: + + function usage( e) + { + e = "usage: split [-num] [file] [outname]" + print e > "/dev/stderr" + exit 1 + } + +The variable `e' is used so that the function fits nicely on the screen. + + This program is a bit sloppy; it relies on `awk' to automatically +close the last file instead of doing it in an `END' rule. It also +assumes that letters are contiguous in the character set, which isn't +true for EBCDIC systems. + + ---------- Footnotes ---------- + + (1) This is the traditional usage. The POSIX usage is different, but +not relevant for what the program aims to demonstrate. + + +File: gawk.info, Node: Tee Program, Next: Uniq Program, Prev: Split Program, Up: Clones + +13.2.5 Duplicating Output into Multiple Files +--------------------------------------------- + +The `tee' program is known as a "pipe fitting." `tee' copies its +standard input to its standard output and also duplicates it to the +files named on the command line. Its usage is as follows: + + tee [-a] file ... + + The `-a' option tells `tee' to append to the named files, instead of +truncating them and starting over. + + The `BEGIN' rule first makes a copy of all the command-line arguments +into an array named `copy'. `ARGV[0]' is not copied, since it is not +needed. `tee' cannot use `ARGV' directly, since `awk' attempts to +process each file name in `ARGV' as input data. + + If the first argument is `-a', then the flag variable `append' is +set to true, and both `ARGV[1]' and `copy[1]' are deleted. If `ARGC' is +less than two, then no file names were supplied and `tee' prints a +usage message and exits. Finally, `awk' is forced to read the standard +input by setting `ARGV[1]' to `"-"' and `ARGC' to two: + + # tee.awk --- tee in awk + # + # Copy standard input to all named output files. + # Append content if -a option is supplied. + # + BEGIN \ + { + for (i = 1; i < ARGC; i++) + copy[i] = ARGV[i] + + if (ARGV[1] == "-a") { + append = 1 + delete ARGV[1] + delete copy[1] + ARGC-- + } + if (ARGC < 2) { + print "usage: tee [-a] file ..." > "/dev/stderr" + exit 1 + } + ARGV[1] = "-" + ARGC = 2 + } + + The following single rule does all the work. Since there is no +pattern, it is executed for each line of input. The body of the rule +simply prints the line into each file on the command line, and then to +the standard output: + + { + # moving the if outside the loop makes it run faster + if (append) + for (i in copy) + print >> copy[i] + else + for (i in copy) + print > copy[i] + print + } + +It is also possible to write the loop this way: + + for (i in copy) + if (append) + print >> copy[i] + else + print > copy[i] + +This is more concise but it is also less efficient. The `if' is tested +for each record and for each output file. By duplicating the loop +body, the `if' is only tested once for each input record. If there are +N input records and M output files, the first method only executes N +`if' statements, while the second executes N`*'M `if' statements. + + Finally, the `END' rule cleans up by closing all the output files: + + END \ + { + for (i in copy) + close(copy[i]) + } + + +File: gawk.info, Node: Uniq Program, Next: Wc Program, Prev: Tee Program, Up: Clones + +13.2.6 Printing Nonduplicated Lines of Text +------------------------------------------- + +The `uniq' utility reads sorted lines of data on its standard input, +and by default removes duplicate lines. In other words, it only prints +unique lines--hence the name. `uniq' has a number of options. The +usage is as follows: + + uniq [-udc [-N]] [+N] [ INPUT FILE [ OUTPUT FILE ]] + + The options for `uniq' are: + +`-d' + Print only repeated lines. + +`-u' + Print only nonrepeated lines. + +`-c' + Count lines. This option overrides `-d' and `-u'. Both repeated + and nonrepeated lines are counted. + +`-N' + Skip N fields before comparing lines. The definition of fields is + similar to `awk''s default: nonwhitespace characters separated by + runs of spaces and/or TABs. + +`+N' + Skip N characters before comparing lines. Any fields specified + with `-N' are skipped first. + +`INPUT FILE' + Data is read from the input file named on the command line, + instead of from the standard input. + +`OUTPUT FILE' + The generated output is sent to the named output file, instead of + to the standard output. + + Normally `uniq' behaves as if both the `-d' and `-u' options are +provided. + + `uniq' uses the `getopt()' library function (*note Getopt Function::) +and the `join()' library function (*note Join Function::). + + The program begins with a `usage()' function and then a brief +outline of the options and their meanings in comments. The `BEGIN' +rule deals with the command-line arguments and options. It uses a trick +to get `getopt()' to handle options of the form `-25', treating such an +option as the option letter `2' with an argument of `5'. If indeed two +or more digits are supplied (`Optarg' looks like a number), `Optarg' is +concatenated with the option digit and then the result is added to zero +to make it into a number. If there is only one digit in the option, +then `Optarg' is not needed. In this case, `Optind' must be decremented +so that `getopt()' processes it next time. This code is admittedly a +bit tricky. + + If no options are supplied, then the default is taken, to print both +repeated and nonrepeated lines. The output file, if provided, is +assigned to `outputfile'. Early on, `outputfile' is initialized to the +standard output, `/dev/stdout': + + # uniq.awk --- do uniq in awk + # + # Requires getopt() and join() library functions + + function usage( e) + { + e = "Usage: uniq [-udc [-n]] [+n] [ in [ out ]]" + print e > "/dev/stderr" + exit 1 + } + + # -c count lines. overrides -d and -u + # -d only repeated lines + # -u only nonrepeated lines + # -n skip n fields + # +n skip n characters, skip fields first + + BEGIN \ + { + count = 1 + outputfile = "/dev/stdout" + opts = "udc0:1:2:3:4:5:6:7:8:9:" + while ((c = getopt(ARGC, ARGV, opts)) != -1) { + if (c == "u") + non_repeated_only++ + else if (c == "d") + repeated_only++ + else if (c == "c") + do_count++ + else if (index("0123456789", c) != 0) { + # getopt requires args to options + # this messes us up for things like -5 + if (Optarg ~ /^[[:digit:]]+$/) + fcount = (c Optarg) + 0 + else { + fcount = c + 0 + Optind-- + } + } else + usage() + } + + if (ARGV[Optind] ~ /^\+[[:digit:]]+$/) { + charcount = substr(ARGV[Optind], 2) + 0 + Optind++ + } + + for (i = 1; i < Optind; i++) + ARGV[i] = "" + + if (repeated_only == 0 && non_repeated_only == 0) + repeated_only = non_repeated_only = 1 + + if (ARGC - Optind == 2) { + outputfile = ARGV[ARGC - 1] + ARGV[ARGC - 1] = "" + } + } + + The following function, `are_equal()', compares the current line, +`$0', to the previous line, `last'. It handles skipping fields and +characters. If no field count and no character count are specified, +`are_equal()' simply returns one or zero depending upon the result of a +simple string comparison of `last' and `$0'. Otherwise, things get more +complicated. If fields have to be skipped, each line is broken into an +array using `split()' (*note String Functions::); the desired fields +are then joined back into a line using `join()'. The joined lines are +stored in `clast' and `cline'. If no fields are skipped, `clast' and +`cline' are set to `last' and `$0', respectively. Finally, if +characters are skipped, `substr()' is used to strip off the leading +`charcount' characters in `clast' and `cline'. The two strings are +then compared and `are_equal()' returns the result: + + function are_equal( n, m, clast, cline, alast, aline) + { + if (fcount == 0 && charcount == 0) + return (last == $0) + + if (fcount > 0) { + n = split(last, alast) + m = split($0, aline) + clast = join(alast, fcount+1, n) + cline = join(aline, fcount+1, m) + } else { + clast = last + cline = $0 + } + if (charcount) { + clast = substr(clast, charcount + 1) + cline = substr(cline, charcount + 1) + } + + return (clast == cline) + } + + The following two rules are the body of the program. The first one +is executed only for the very first line of data. It sets `last' equal +to `$0', so that subsequent lines of text have something to be compared +to. + + The second rule does the work. The variable `equal' is one or zero, +depending upon the results of `are_equal()''s comparison. If `uniq' is +counting repeated lines, and the lines are equal, then it increments +the `count' variable. Otherwise, it prints the line and resets `count', +since the two lines are not equal. + + If `uniq' is not counting, and if the lines are equal, `count' is +incremented. Nothing is printed, since the point is to remove +duplicates. Otherwise, if `uniq' is counting repeated lines and more +than one line is seen, or if `uniq' is counting nonrepeated lines and +only one line is seen, then the line is printed, and `count' is reset. + + Finally, similar logic is used in the `END' rule to print the final +line of input data: + + NR == 1 { + last = $0 + next + } + + { + equal = are_equal() + + if (do_count) { # overrides -d and -u + if (equal) + count++ + else { + printf("%4d %s\n", count, last) > outputfile + last = $0 + count = 1 # reset + } + next + } + + if (equal) + count++ + else { + if ((repeated_only && count > 1) || + (non_repeated_only && count == 1)) + print last > outputfile + last = $0 + count = 1 + } + } + + END { + if (do_count) + printf("%4d %s\n", count, last) > outputfile + else if ((repeated_only && count > 1) || + (non_repeated_only && count == 1)) + print last > outputfile + close(outputfile) + } + + +File: gawk.info, Node: Wc Program, Prev: Uniq Program, Up: Clones + +13.2.7 Counting Things +---------------------- + +The `wc' (word count) utility counts lines, words, and characters in +one or more input files. Its usage is as follows: + + wc [-lwc] [ FILES ... ] + + If no files are specified on the command line, `wc' reads its +standard input. If there are multiple files, it also prints total +counts for all the files. The options and their meanings are shown in +the following list: + +`-l' + Count only lines. + +`-w' + Count only words. A "word" is a contiguous sequence of + nonwhitespace characters, separated by spaces and/or TABs. + Luckily, this is the normal way `awk' separates fields in its + input data. + +`-c' + Count only characters. + + Implementing `wc' in `awk' is particularly elegant, since `awk' does +a lot of the work for us; it splits lines into words (i.e., fields) and +counts them, it counts lines (i.e., records), and it can easily tell us +how long a line is. + + This program uses the `getopt()' library function (*note Getopt +Function::) and the file-transition functions (*note Filetrans +Function::). + + This version has one notable difference from traditional versions of +`wc': it always prints the counts in the order lines, words, and +characters. Traditional versions note the order of the `-l', `-w', and +`-c' options on the command line, and print the counts in that order. + + The `BEGIN' rule does the argument processing. The variable +`print_total' is true if more than one file is named on the command +line: + + # wc.awk --- count lines, words, characters + + # Options: + # -l only count lines + # -w only count words + # -c only count characters + # + # Default is to count lines, words, characters + # + # Requires getopt() and file transition library functions + + BEGIN { + # let getopt() print a message about + # invalid options. we ignore them + while ((c = getopt(ARGC, ARGV, "lwc")) != -1) { + if (c == "l") + do_lines = 1 + else if (c == "w") + do_words = 1 + else if (c == "c") + do_chars = 1 + } + for (i = 1; i < Optind; i++) + ARGV[i] = "" + + # if no options, do all + if (! do_lines && ! do_words && ! do_chars) + do_lines = do_words = do_chars = 1 + + print_total = (ARGC - i > 2) + } + + The `beginfile()' function is simple; it just resets the counts of +lines, words, and characters to zero, and saves the current file name in +`fname': + + function beginfile(file) + { + lines = words = chars = 0 + fname = FILENAME + } + + The `endfile()' function adds the current file's numbers to the +running totals of lines, words, and characters.(1) It then prints out +those numbers for the file that was just read. It relies on +`beginfile()' to reset the numbers for the following data file: + + function endfile(file) + { + tlines += lines + twords += words + tchars += chars + if (do_lines) + printf "\t%d", lines + if (do_words) + printf "\t%d", words + if (do_chars) + printf "\t%d", chars + printf "\t%s\n", fname + } + + There is one rule that is executed for each line. It adds the length +of the record, plus one, to `chars'.(2) Adding one plus the record +length is needed because the newline character separating records (the +value of `RS') is not part of the record itself, and thus not included +in its length. Next, `lines' is incremented for each line read, and +`words' is incremented by the value of `NF', which is the number of +"words" on this line: + + # do per line + { + chars += length($0) + 1 # get newline + lines++ + words += NF + } + + Finally, the `END' rule simply prints the totals for all the files: + + END { + if (print_total) { + if (do_lines) + printf "\t%d", tlines + if (do_words) + printf "\t%d", twords + if (do_chars) + printf "\t%d", tchars + print "\ttotal" + } + } + + ---------- Footnotes ---------- + + (1) `wc' can't just use the value of `FNR' in `endfile()'. If you +examine the code in *note Filetrans Function::, you will see that `FNR' +has already been reset by the time `endfile()' is called. + + (2) Since `gawk' understands multibyte locales, this code counts +characters, not bytes. + + +File: gawk.info, Node: Miscellaneous Programs, Prev: Clones, Up: Sample Programs + +13.3 A Grab Bag of `awk' Programs +================================= + +This minor node is a large "grab bag" of miscellaneous programs. We +hope you find them both interesting and enjoyable. + +* Menu: + +* Dupword Program:: Finding duplicated words in a document. +* Alarm Program:: An alarm clock. +* Translate Program:: A program similar to the `tr' utility. +* Labels Program:: Printing mailing labels. +* Word Sorting:: A program to produce a word usage count. +* History Sorting:: Eliminating duplicate entries from a history + file. +* Extract Program:: Pulling out programs from Texinfo source + files. +* Simple Sed:: A Simple Stream Editor. +* Igawk Program:: A wrapper for `awk' that includes + files. +* Anagram Program:: Finding anagrams from a dictionary. +* Signature Program:: People do amazing things with too much time on + their hands. + + +File: gawk.info, Node: Dupword Program, Next: Alarm Program, Up: Miscellaneous Programs + +13.3.1 Finding Duplicated Words in a Document +--------------------------------------------- + +A common error when writing large amounts of prose is to accidentally +duplicate words. Typically you will see this in text as something like +"the the program does the following..." When the text is online, often +the duplicated words occur at the end of one line and the beginning of +another, making them very difficult to spot. + + This program, `dupword.awk', scans through a file one line at a time +and looks for adjacent occurrences of the same word. It also saves the +last word on a line (in the variable `prev') for comparison with the +first word on the next line. + + The first two statements make sure that the line is all lowercase, +so that, for example, "The" and "the" compare equal to each other. The +next statement replaces nonalphanumeric and nonwhitespace characters +with spaces, so that punctuation does not affect the comparison either. +The characters are replaced with spaces so that formatting controls +don't create nonsense words (e.g., the Texinfo `@code{NF}' becomes +`codeNF' if punctuation is simply deleted). The record is then resplit +into fields, yielding just the actual words on the line, and ensuring +that there are no empty fields. + + If there are no fields left after removing all the punctuation, the +current record is skipped. Otherwise, the program loops through each +word, comparing it to the previous one: + + # dupword.awk --- find duplicate words in text + { + $0 = tolower($0) + gsub(/[^[:alnum:][:blank:]]/, " "); + $0 = $0 # re-split + if (NF == 0) + next + if ($1 == prev) + printf("%s:%d: duplicate %s\n", + FILENAME, FNR, $1) + for (i = 2; i <= NF; i++) + if ($i == $(i-1)) + printf("%s:%d: duplicate %s\n", + FILENAME, FNR, $i) + prev = $NF + } + + +File: gawk.info, Node: Alarm Program, Next: Translate Program, Prev: Dupword Program, Up: Miscellaneous Programs + +13.3.2 An Alarm Clock Program +----------------------------- + + Nothing cures insomnia like a ringing alarm clock. + Arnold Robbins + + The following program is a simple "alarm clock" program. You give +it a time of day and an optional message. At the specified time, it +prints the message on the standard output. In addition, you can give it +the number of times to repeat the message as well as a delay between +repetitions. + + This program uses the `gettimeofday()' function from *note +Gettimeofday Function::. + + All the work is done in the `BEGIN' rule. The first part is argument +checking and setting of defaults: the delay, the count, and the message +to print. If the user supplied a message without the ASCII BEL +character (known as the "alert" character, `"\a"'), then it is added to +the message. (On many systems, printing the ASCII BEL generates an +audible alert. Thus when the alarm goes off, the system calls attention +to itself in case the user is not looking at the computer.) Just for a +change, this program uses a `switch' statement (*note Switch +Statement::), but the processing could be done with a series of +`if'-`else' statements instead. Here is the program: + + # alarm.awk --- set an alarm + # + # Requires gettimeofday() library function + # usage: alarm time [ "message" [ count [ delay ] ] ] + + BEGIN \ + { + # Initial argument sanity checking + usage1 = "usage: alarm time ['message' [count [delay]]]" + usage2 = sprintf("\t(%s) time ::= hh:mm", ARGV[1]) + + if (ARGC < 2) { + print usage1 > "/dev/stderr" + print usage2 > "/dev/stderr" + exit 1 + } + switch (ARGC) { + case 5: + delay = ARGV[4] + 0 + # fall through + case 4: + count = ARGV[3] + 0 + # fall through + case 3: + message = ARGV[2] + break + default: + if (ARGV[1] !~ /[[:digit:]]?[[:digit:]]:[[:digit:]]{2}/) { + print usage1 > "/dev/stderr" + print usage2 > "/dev/stderr" + exit 1 + } + break + } + + # set defaults for once we reach the desired time + if (delay == 0) + delay = 180 # 3 minutes + if (count == 0) + count = 5 + if (message == "") + message = sprintf("\aIt is now %s!\a", ARGV[1]) + else if (index(message, "\a") == 0) + message = "\a" message "\a" + + The next minor node of code turns the alarm time into hours and +minutes, converts it (if necessary) to a 24-hour clock, and then turns +that time into a count of the seconds since midnight. Next it turns +the current time into a count of seconds since midnight. The +difference between the two is how long to wait before setting off the +alarm: + + # split up alarm time + split(ARGV[1], atime, ":") + hour = atime[1] + 0 # force numeric + minute = atime[2] + 0 # force numeric + + # get current broken down time + gettimeofday(now) + + # if time given is 12-hour hours and it's after that + # hour, e.g., `alarm 5:30' at 9 a.m. means 5:30 p.m., + # then add 12 to real hour + if (hour < 12 && now["hour"] > hour) + hour += 12 + + # set target time in seconds since midnight + target = (hour * 60 * 60) + (minute * 60) + + # get current time in seconds since midnight + current = (now["hour"] * 60 * 60) + \ + (now["minute"] * 60) + now["second"] + + # how long to sleep for + naptime = target - current + if (naptime <= 0) { + print "time is in the past!" > "/dev/stderr" + exit 1 + } + + Finally, the program uses the `system()' function (*note I/O +Functions::) to call the `sleep' utility. The `sleep' utility simply +pauses for the given number of seconds. If the exit status is not zero, +the program assumes that `sleep' was interrupted and exits. If `sleep' +exited with an OK status (zero), then the program prints the message in +a loop, again using `sleep' to delay for however many seconds are +necessary: + + # zzzzzz..... go away if interrupted + if (system(sprintf("sleep %d", naptime)) != 0) + exit 1 + + # time to notify! + command = sprintf("sleep %d", delay) + for (i = 1; i <= count; i++) { + print message + # if sleep command interrupted, go away + if (system(command) != 0) + break + } + + exit 0 + } + + +File: gawk.info, Node: Translate Program, Next: Labels Program, Prev: Alarm Program, Up: Miscellaneous Programs + +13.3.3 Transliterating Characters +--------------------------------- + +The system `tr' utility transliterates characters. For example, it is +often used to map uppercase letters into lowercase for further +processing: + + GENERATE DATA | tr 'A-Z' 'a-z' | PROCESS DATA ... + + `tr' requires two lists of characters.(1) When processing the +input, the first character in the first list is replaced with the first +character in the second list, the second character in the first list is +replaced with the second character in the second list, and so on. If +there are more characters in the "from" list than in the "to" list, the +last character of the "to" list is used for the remaining characters in +the "from" list. + + Some time ago, a user proposed that a transliteration function should +be added to `gawk'. The following program was written to prove that +character transliteration could be done with a user-level function. +This program is not as complete as the system `tr' utility but it does +most of the job. + + The `translate' program demonstrates one of the few weaknesses of +standard `awk': dealing with individual characters is very painful, +requiring repeated use of the `substr()', `index()', and `gsub()' +built-in functions (*note String Functions::).(2) There are two +functions. The first, `stranslate()', takes three arguments: + +`from' + A list of characters from which to translate. + +`to' + A list of characters to which to translate. + +`target' + The string on which to do the translation. + + Associative arrays make the translation part fairly easy. `t_ar' +holds the "to" characters, indexed by the "from" characters. Then a +simple loop goes through `from', one character at a time. For each +character in `from', if the character appears in `target', it is +replaced with the corresponding `to' character. + + The `translate()' function simply calls `stranslate()' using `$0' as +the target. The main program sets two global variables, `FROM' and +`TO', from the command line, and then changes `ARGV' so that `awk' +reads from the standard input. + + Finally, the processing rule simply calls `translate()' for each +record: + + # translate.awk --- do tr-like stuff + # Bugs: does not handle things like: tr A-Z a-z, it has + # to be spelled out. However, if `to' is shorter than `from', + # the last character in `to' is used for the rest of `from'. + + function stranslate(from, to, target, lf, lt, ltarget, t_ar, i, c, + result) + { + lf = length(from) + lt = length(to) + ltarget = length(target) + for (i = 1; i <= lt; i++) + t_ar[substr(from, i, 1)] = substr(to, i, 1) + if (lt < lf) + for (; i <= lf; i++) + t_ar[substr(from, i, 1)] = substr(to, lt, 1) + for (i = 1; i <= ltarget; i++) { + c = substr(target, i, 1) + if (c in t_ar) + c = t_ar[c] + result = result c + } + return result + } + + function translate(from, to) + { + return $0 = stranslate(from, to, $0) + } + + # main program + BEGIN { + if (ARGC < 3) { + print "usage: translate from to" > "/dev/stderr" + exit + } + FROM = ARGV[1] + TO = ARGV[2] + ARGC = 2 + ARGV[1] = "-" + } + + { + translate(FROM, TO) + print + } + + While it is possible to do character transliteration in a user-level +function, it is not necessarily efficient, and we (the `gawk' authors) +started to consider adding a built-in function. However, shortly after +writing this program, we learned that the System V Release 4 `awk' had +added the `toupper()' and `tolower()' functions (*note String +Functions::). These functions handle the vast majority of the cases +where character transliteration is necessary, and so we chose to simply +add those functions to `gawk' as well and then leave well enough alone. + + An obvious improvement to this program would be to set up the `t_ar' +array only once, in a `BEGIN' rule. However, this assumes that the +"from" and "to" lists will never change throughout the lifetime of the +program. + + ---------- Footnotes ---------- + + (1) On some older systems, `tr' may require that the lists be +written as range expressions enclosed in square brackets (`[a-z]') and +quoted, to prevent the shell from attempting a file name expansion. +This is not a feature. + + (2) This program was written before `gawk' acquired the ability to +split each character in a string into separate array elements. + + +File: gawk.info, Node: Labels Program, Next: Word Sorting, Prev: Translate Program, Up: Miscellaneous Programs + +13.3.4 Printing Mailing Labels +------------------------------ + +Here is a "real world"(1) program. This script reads lists of names and +addresses and generates mailing labels. Each page of labels has 20 +labels on it, two across and 10 down. The addresses are guaranteed to +be no more than five lines of data. Each address is separated from the +next by a blank line. + + The basic idea is to read 20 labels worth of data. Each line of +each label is stored in the `line' array. The single rule takes care +of filling the `line' array and printing the page when 20 labels have +been read. + + The `BEGIN' rule simply sets `RS' to the empty string, so that `awk' +splits records at blank lines (*note Records::). It sets `MAXLINES' to +100, since 100 is the maximum number of lines on the page (20 * 5 = +100). + + Most of the work is done in the `printpage()' function. The label +lines are stored sequentially in the `line' array. But they have to +print horizontally; `line[1]' next to `line[6]', `line[2]' next to +`line[7]', and so on. Two loops are used to accomplish this. The +outer loop, controlled by `i', steps through every 10 lines of data; +this is each row of labels. The inner loop, controlled by `j', goes +through the lines within the row. As `j' goes from 0 to 4, `i+j' is +the `j'-th line in the row, and `i+j+5' is the entry next to it. The +output ends up looking something like this: + + line 1 line 6 + line 2 line 7 + line 3 line 8 + line 4 line 9 + line 5 line 10 + ... + +The `printf' format string `%-41s' left-aligns the data and prints it +within a fixed-width field. + + As a final note, an extra blank line is printed at lines 21 and 61, +to keep the output lined up on the labels. This is dependent on the +particular brand of labels in use when the program was written. You +will also note that there are two blank lines at the top and two blank +lines at the bottom. + + The `END' rule arranges to flush the final page of labels; there may +not have been an even multiple of 20 labels in the data: + + # labels.awk --- print mailing labels + + # Each label is 5 lines of data that may have blank lines. + # The label sheets have 2 blank lines at the top and 2 at + # the bottom. + + BEGIN { RS = "" ; MAXLINES = 100 } + + function printpage( i, j) + { + if (Nlines <= 0) + return + + printf "\n\n" # header + + for (i = 1; i <= Nlines; i += 10) { + if (i == 21 || i == 61) + print "" + for (j = 0; j < 5; j++) { + if (i + j > MAXLINES) + break + printf " %-41s %s\n", line[i+j], line[i+j+5] + } + print "" + } + + printf "\n\n" # footer + + delete line + } + + # main rule + { + if (Count >= 20) { + printpage() + Count = 0 + Nlines = 0 + } + n = split($0, a, "\n") + for (i = 1; i <= n; i++) + line[++Nlines] = a[i] + for (; i <= 5; i++) + line[++Nlines] = "" + Count++ + } + + END \ + { + printpage() + } + + ---------- Footnotes ---------- + + (1) "Real world" is defined as "a program actually used to get +something done." + + +File: gawk.info, Node: Word Sorting, Next: History Sorting, Prev: Labels Program, Up: Miscellaneous Programs + +13.3.5 Generating Word-Usage Counts +----------------------------------- + +When working with large amounts of text, it can be interesting to know +how often different words appear. For example, an author may overuse +certain words, in which case she might wish to find synonyms to +substitute for words that appear too often. This node develops a +program for counting words and presenting the frequency information in +a useful format. + + At first glance, a program like this would seem to do the job: + + # Print list of word frequencies + + { + for (i = 1; i <= NF; i++) + freq[$i]++ + } + + END { + for (word in freq) + printf "%s\t%d\n", word, freq[word] + } + + The program relies on `awk''s default field splitting mechanism to +break each line up into "words," and uses an associative array named +`freq', indexed by each word, to count the number of times the word +occurs. In the `END' rule, it prints the counts. + + This program has several problems that prevent it from being useful +on real text files: + + * The `awk' language considers upper- and lowercase characters to be + distinct. Therefore, "bartender" and "Bartender" are not treated + as the same word. This is undesirable, since in normal text, words + are capitalized if they begin sentences, and a frequency analyzer + should not be sensitive to capitalization. + + * Words are detected using the `awk' convention that fields are + separated just by whitespace. Other characters in the input + (except newlines) don't have any special meaning to `awk'. This + means that punctuation characters count as part of words. + + * The output does not come out in any useful order. You're more + likely to be interested in which words occur most frequently or in + having an alphabetized table of how frequently each word occurs. + + The first problem can be solved by using `tolower()' to remove case +distinctions. The second problem can be solved by using `gsub()' to +remove punctuation characters. Finally, we solve the third problem by +using the system `sort' utility to process the output of the `awk' +script. Here is the new version of the program: + + # wordfreq.awk --- print list of word frequencies + + { + $0 = tolower($0) # remove case distinctions + # remove punctuation + gsub(/[^[:alnum:]_[:blank:]]/, "", $0) + for (i = 1; i <= NF; i++) + freq[$i]++ + } + + END { + for (word in freq) + printf "%s\t%d\n", word, freq[word] + } + + Assuming we have saved this program in a file named `wordfreq.awk', +and that the data is in `file1', the following pipeline: + + awk -f wordfreq.awk file1 | sort -k 2nr + +produces a table of the words appearing in `file1' in order of +decreasing frequency. + + The `awk' program suitably massages the data and produces a word +frequency table, which is not ordered. The `awk' script's output is +then sorted by the `sort' utility and printed on the screen. + + The options given to `sort' specify a sort that uses the second +field of each input line (skipping one field), that the sort keys +should be treated as numeric quantities (otherwise `15' would come +before `5'), and that the sorting should be done in descending +(reverse) order. + + The `sort' could even be done from within the program, by changing +the `END' action to: + + END { + sort = "sort -k 2nr" + for (word in freq) + printf "%s\t%d\n", word, freq[word] | sort + close(sort) + } + + This way of sorting must be used on systems that do not have true +pipes at the command-line (or batch-file) level. See the general +operating system documentation for more information on how to use the +`sort' program. + + +File: gawk.info, Node: History Sorting, Next: Extract Program, Prev: Word Sorting, Up: Miscellaneous Programs + +13.3.6 Removing Duplicates from Unsorted Text +--------------------------------------------- + +The `uniq' program (*note Uniq Program::), removes duplicate lines from +_sorted_ data. + + Suppose, however, you need to remove duplicate lines from a data +file but that you want to preserve the order the lines are in. A good +example of this might be a shell history file. The history file keeps +a copy of all the commands you have entered, and it is not unusual to +repeat a command several times in a row. Occasionally you might want +to compact the history by removing duplicate entries. Yet it is +desirable to maintain the order of the original commands. + + This simple program does the job. It uses two arrays. The `data' +array is indexed by the text of each line. For each line, `data[$0]' +is incremented. If a particular line has not been seen before, then +`data[$0]' is zero. In this case, the text of the line is stored in +`lines[count]'. Each element of `lines' is a unique command, and the +indices of `lines' indicate the order in which those lines are +encountered. The `END' rule simply prints out the lines, in order: + + # histsort.awk --- compact a shell history file + # Thanks to Byron Rakitzis for the general idea + + { + if (data[$0]++ == 0) + lines[++count] = $0 + } + + END { + for (i = 1; i <= count; i++) + print lines[i] + } + + This program also provides a foundation for generating other useful +information. For example, using the following `print' statement in the +`END' rule indicates how often a particular command is used: + + print data[lines[i]], lines[i] + + This works because `data[$0]' is incremented each time a line is +seen. + + +File: gawk.info, Node: Extract Program, Next: Simple Sed, Prev: History Sorting, Up: Miscellaneous Programs + +13.3.7 Extracting Programs from Texinfo Source Files +---------------------------------------------------- + +The nodes *note Library Functions::, and *note Sample Programs::, are +the top level nodes for a large number of `awk' programs. If you want +to experiment with these programs, it is tedious to have to type them +in by hand. Here we present a program that can extract parts of a +Texinfo input file into separate files. + +This Info file is written in Texinfo (http://texinfo.org), the GNU +project's document formatting language. A single Texinfo source file +can be used to produce both printed and online documentation. The +Texinfo language is described fully, starting with *note (Texinfo)Top:: +texinfo,Texinfo--The GNU Documentation Format. + + For our purposes, it is enough to know three things about Texinfo +input files: + + * The "at" symbol (`@') is special in Texinfo, much as the backslash + (`\') is in C or `awk'. Literal `@' symbols are represented in + Texinfo source files as `@@'. + + * Comments start with either `@c' or `@comment'. The + file-extraction program works by using special comments that start + at the beginning of a line. + + * Lines containing `@group' and `@end group' commands bracket + example text that should not be split across a page boundary. + (Unfortunately, TeX isn't always smart enough to do things exactly + right, so we have to give it some help.) + + The following program, `extract.awk', reads through a Texinfo source +file and does two things, based on the special comments. Upon seeing +`@c system ...', it runs a command, by extracting the command text from +the control line and passing it on to the `system()' function (*note +I/O Functions::). Upon seeing `@c file FILENAME', each subsequent line +is sent to the file FILENAME, until `@c endfile' is encountered. The +rules in `extract.awk' match either `@c' or `@comment' by letting the +`omment' part be optional. Lines containing `@group' and `@end group' +are simply removed. `extract.awk' uses the `join()' library function +(*note Join Function::). + + The example programs in the online Texinfo source for `GAWK: +Effective AWK Programming' (`gawk.texi') have all been bracketed inside +`file' and `endfile' lines. The `gawk' distribution uses a copy of +`extract.awk' to extract the sample programs and install many of them +in a standard directory where `gawk' can find them. The Texinfo file +looks something like this: + + ... + This program has a @code{BEGIN} rule, + that prints a nice message: + + @example + @c file examples/messages.awk + BEGIN @{ print "Don't panic!" @} + @c end file + @end example + + It also prints some final advice: + + @example + @c file examples/messages.awk + END @{ print "Always avoid bored archeologists!" @} + @c end file + @end example + ... + + `extract.awk' begins by setting `IGNORECASE' to one, so that mixed +upper- and lowercase letters in the directives won't matter. + + The first rule handles calling `system()', checking that a command is +given (`NF' is at least three) and also checking that the command exits +with a zero exit status, signifying OK: + + # extract.awk --- extract files and run programs + # from texinfo files + + BEGIN { IGNORECASE = 1 } + + /^@c(omment)?[ \t]+system/ \ + { + if (NF < 3) { + e = (FILENAME ":" FNR) + e = (e ": badly formed `system' line") + print e > "/dev/stderr" + next + } + $1 = "" + $2 = "" + stat = system($0) + if (stat != 0) { + e = (FILENAME ":" FNR) + e = (e ": warning: system returned " stat) + print e > "/dev/stderr" + } + } + +The variable `e' is used so that the rule fits nicely on the screen. + + The second rule handles moving data into files. It verifies that a +file name is given in the directive. If the file named is not the +current file, then the current file is closed. Keeping the current file +open until a new file is encountered allows the use of the `>' +redirection for printing the contents, keeping open file management +simple. + + The `for' loop does the work. It reads lines using `getline' (*note +Getline::). For an unexpected end of file, it calls the +`unexpected_eof()' function. If the line is an "endfile" line, then it +breaks out of the loop. If the line is an `@group' or `@end group' +line, then it ignores it and goes on to the next line. Similarly, +comments within examples are also ignored. + + Most of the work is in the following few lines. If the line has no +`@' symbols, the program can print it directly. Otherwise, each +leading `@' must be stripped off. To remove the `@' symbols, the line +is split into separate elements of the array `a', using the `split()' +function (*note String Functions::). The `@' symbol is used as the +separator character. Each element of `a' that is empty indicates two +successive `@' symbols in the original line. For each two empty +elements (`@@' in the original file), we have to add a single `@' +symbol back in.(1) + + When the processing of the array is finished, `join()' is called +with the value of `SUBSEP', to rejoin the pieces back into a single +line. That line is then printed to the output file: + + /^@c(omment)?[ \t]+file/ \ + { + if (NF != 3) { + e = (FILENAME ":" FNR ": badly formed `file' line") + print e > "/dev/stderr" + next + } + if ($3 != curfile) { + if (curfile != "") + close(curfile) + curfile = $3 + } + + for (;;) { + if ((getline line) <= 0) + unexpected_eof() + if (line ~ /^@c(omment)?[ \t]+endfile/) + break + else if (line ~ /^@(end[ \t]+)?group/) + continue + else if (line ~ /^@c(omment+)?[ \t]+/) + continue + if (index(line, "@") == 0) { + print line > curfile + continue + } + n = split(line, a, "@") + # if a[1] == "", means leading @, + # don't add one back in. + for (i = 2; i <= n; i++) { + if (a[i] == "") { # was an @@ + a[i] = "@" + if (a[i+1] == "") + i++ + } + } + print join(a, 1, n, SUBSEP) > curfile + } + } + + An important thing to note is the use of the `>' redirection. +Output done with `>' only opens the file once; it stays open and +subsequent output is appended to the file (*note Redirection::). This +makes it easy to mix program text and explanatory prose for the same +sample source file (as has been done here!) without any hassle. The +file is only closed when a new data file name is encountered or at the +end of the input file. + + Finally, the function `unexpected_eof()' prints an appropriate error +message and then exits. The `END' rule handles the final cleanup, +closing the open file: + + function unexpected_eof() + { + printf("%s:%d: unexpected EOF or error\n", + FILENAME, FNR) > "/dev/stderr" + exit 1 + } + + END { + if (curfile) + close(curfile) + } + + ---------- Footnotes ---------- + + (1) This program was written before `gawk' had the `gensub()' +function. Consider how you might use it to simplify the code. + + +File: gawk.info, Node: Simple Sed, Next: Igawk Program, Prev: Extract Program, Up: Miscellaneous Programs + +13.3.8 A Simple Stream Editor +----------------------------- + +The `sed' utility is a stream editor, a program that reads a stream of +data, makes changes to it, and passes it on. It is often used to make +global changes to a large file or to a stream of data generated by a +pipeline of commands. While `sed' is a complicated program in its own +right, its most common use is to perform global substitutions in the +middle of a pipeline: + + command1 < orig.data | sed 's/old/new/g' | command2 > result + + Here, `s/old/new/g' tells `sed' to look for the regexp `old' on each +input line and globally replace it with the text `new', i.e., all the +occurrences on a line. This is similar to `awk''s `gsub()' function +(*note String Functions::). + + The following program, `awksed.awk', accepts at least two +command-line arguments: the pattern to look for and the text to replace +it with. Any additional arguments are treated as data file names to +process. If none are provided, the standard input is used: + + # awksed.awk --- do s/foo/bar/g using just print + # Thanks to Michael Brennan for the idea + + function usage() + { + print "usage: awksed pat repl [files...]" > "/dev/stderr" + exit 1 + } + + BEGIN { + # validate arguments + if (ARGC < 3) + usage() + + RS = ARGV[1] + ORS = ARGV[2] + + # don't use arguments as files + ARGV[1] = ARGV[2] = "" + } + + # look ma, no hands! + { + if (RT == "") + printf "%s", $0 + else + print + } + + The program relies on `gawk''s ability to have `RS' be a regexp, as +well as on the setting of `RT' to the actual text that terminates the +record (*note Records::). + + The idea is to have `RS' be the pattern to look for. `gawk' +automatically sets `$0' to the text between matches of the pattern. +This is text that we want to keep, unmodified. Then, by setting `ORS' +to the replacement text, a simple `print' statement outputs the text we +want to keep, followed by the replacement text. + + There is one wrinkle to this scheme, which is what to do if the last +record doesn't end with text that matches `RS'. Using a `print' +statement unconditionally prints the replacement text, which is not +correct. However, if the file did not end in text that matches `RS', +`RT' is set to the null string. In this case, we can print `$0' using +`printf' (*note Printf::). + + The `BEGIN' rule handles the setup, checking for the right number of +arguments and calling `usage()' if there is a problem. Then it sets +`RS' and `ORS' from the command-line arguments and sets `ARGV[1]' and +`ARGV[2]' to the null string, so that they are not treated as file names +(*note ARGC and ARGV::). + + The `usage()' function prints an error message and exits. Finally, +the single rule handles the printing scheme outlined above, using +`print' or `printf' as appropriate, depending upon the value of `RT'. + + +File: gawk.info, Node: Igawk Program, Next: Anagram Program, Prev: Simple Sed, Up: Miscellaneous Programs + +13.3.9 An Easy Way to Use Library Functions +------------------------------------------- + +In *note Include Files::, we saw how `gawk' provides a built-in +file-inclusion capability. However, this is a `gawk' extension. This +minor node provides the motivation for making file inclusion available +for standard `awk', and shows how to do it using a combination of shell +and `awk' programming. + + Using library functions in `awk' can be very beneficial. It +encourages code reuse and the writing of general functions. Programs are +smaller and therefore clearer. However, using library functions is +only easy when writing `awk' programs; it is painful when running them, +requiring multiple `-f' options. If `gawk' is unavailable, then so too +is the `AWKPATH' environment variable and the ability to put `awk' +functions into a library directory (*note Options::). It would be nice +to be able to write programs in the following manner: + + # library functions + @include getopt.awk + @include join.awk + ... + + # main program + BEGIN { + while ((c = getopt(ARGC, ARGV, "a:b:cde")) != -1) + ... + ... + } + + The following program, `igawk.sh', provides this service. It +simulates `gawk''s searching of the `AWKPATH' variable and also allows +"nested" includes; i.e., a file that is included with `@include' can +contain further `@include' statements. `igawk' makes an effort to only +include files once, so that nested includes don't accidentally include +a library function twice. + + `igawk' should behave just like `gawk' externally. This means it +should accept all of `gawk''s command-line arguments, including the +ability to have multiple source files specified via `-f', and the +ability to mix command-line and library source files. + + The program is written using the POSIX Shell (`sh') command +language.(1) It works as follows: + + 1. Loop through the arguments, saving anything that doesn't represent + `awk' source code for later, when the expanded program is run. + + 2. For any arguments that do represent `awk' text, put the arguments + into a shell variable that will be expanded. There are two cases: + + a. Literal text, provided with `--source' or `--source='. This + text is just appended directly. + + b. Source file names, provided with `-f'. We use a neat trick + and append `@include FILENAME' to the shell variable's + contents. Since the file-inclusion program works the way + `gawk' does, this gets the text of the file included into the + program at the correct point. + + 3. Run an `awk' program (naturally) over the shell variable's + contents to expand `@include' statements. The expanded program is + placed in a second shell variable. + + 4. Run the expanded program with `gawk' and any other original + command-line arguments that the user supplied (such as the data + file names). + + This program uses shell variables extensively: for storing +command-line arguments, the text of the `awk' program that will expand +the user's program, for the user's original program, and for the +expanded program. Doing so removes some potential problems that might +arise were we to use temporary files instead, at the cost of making the +script somewhat more complicated. + + The initial part of the program turns on shell tracing if the first +argument is `debug'. + + The next part loops through all the command-line arguments. There +are several cases of interest: + +`--' + This ends the arguments to `igawk'. Anything else should be + passed on to the user's `awk' program without being evaluated. + +`-W' + This indicates that the next option is specific to `gawk'. To make + argument processing easier, the `-W' is appended to the front of + the remaining arguments and the loop continues. (This is an `sh' + programming trick. Don't worry about it if you are not familiar + with `sh'.) + +`-v, -F' + These are saved and passed on to `gawk'. + +`-f, --file, --file=, -Wfile=' + The file name is appended to the shell variable `program' with an + `@include' statement. The `expr' utility is used to remove the + leading option part of the argument (e.g., `--file='). (Typical + `sh' usage would be to use the `echo' and `sed' utilities to do + this work. Unfortunately, some versions of `echo' evaluate escape + sequences in their arguments, possibly mangling the program text. + Using `expr' avoids this problem.) + +`--source, --source=, -Wsource=' + The source text is appended to `program'. + +`--version, -Wversion' + `igawk' prints its version number, runs `gawk --version' to get + the `gawk' version information, and then exits. + + If none of the `-f', `--file', `-Wfile', `--source', or `-Wsource' +arguments are supplied, then the first nonoption argument should be the +`awk' program. If there are no command-line arguments left, `igawk' +prints an error message and exits. Otherwise, the first argument is +appended to `program'. In any case, after the arguments have been +processed, `program' contains the complete text of the original `awk' +program. + + The program is as follows: + + #! /bin/sh + # igawk --- like gawk but do @include processing + + if [ "$1" = debug ] + then + set -x + shift + fi + + # A literal newline, so that program text is formatted correctly + n=' + ' + + # Initialize variables to empty + program= + opts= + + while [ $# -ne 0 ] # loop over arguments + do + case $1 in + --) shift + break ;; + + -W) shift + # The ${x?'message here'} construct prints a + # diagnostic if $x is the null string + set -- -W"${@?'missing operand'}" + continue ;; + + -[vF]) opts="$opts $1 '${2?'missing operand'}'" + shift ;; + + -[vF]*) opts="$opts '$1'" ;; + + -f) program="$program$n@include ${2?'missing operand'}" + shift ;; + + -f*) f=$(expr "$1" : '-f\(.*\)') + program="$program$n@include $f" ;; + + -[W-]file=*) + f=$(expr "$1" : '-.file=\(.*\)') + program="$program$n@include $f" ;; + + -[W-]file) + program="$program$n@include ${2?'missing operand'}" + shift ;; + + -[W-]source=*) + t=$(expr "$1" : '-.source=\(.*\)') + program="$program$n$t" ;; + + -[W-]source) + program="$program$n${2?'missing operand'}" + shift ;; + + -[W-]version) + echo igawk: version 3.0 1>&2 + gawk --version + exit 0 ;; + + -[W-]*) opts="$opts '$1'" ;; + + *) break ;; + esac + shift + done + + if [ -z "$program" ] + then + program=${1?'missing program'} + shift + fi + + # At this point, `program' has the program. + + The `awk' program to process `@include' directives is stored in the +shell variable `expand_prog'. Doing this keeps the shell script +readable. The `awk' program reads through the user's program, one line +at a time, using `getline' (*note Getline::). The input file names and +`@include' statements are managed using a stack. As each `@include' is +encountered, the current file name is "pushed" onto the stack and the +file named in the `@include' directive becomes the current file name. +As each file is finished, the stack is "popped," and the previous input +file becomes the current input file again. The process is started by +making the original file the first one on the stack. + + The `pathto()' function does the work of finding the full path to a +file. It simulates `gawk''s behavior when searching the `AWKPATH' +environment variable (*note AWKPATH Variable::). If a file name has a +`/' in it, no path search is done. Similarly, if the file name is +`"-"', then that string is used as-is. Otherwise, the file name is +concatenated with the name of each directory in the path, and an +attempt is made to open the generated file name. The only way to test +if a file can be read in `awk' is to go ahead and try to read it with +`getline'; this is what `pathto()' does.(2) If the file can be read, it +is closed and the file name is returned: + + expand_prog=' + + function pathto(file, i, t, junk) + { + if (index(file, "/") != 0) + return file + + if (file == "-") + return file + + for (i = 1; i <= ndirs; i++) { + t = (pathlist[i] "/" file) + if ((getline junk < t) > 0) { + # found it + close(t) + return t + } + } + return "" + } + + The main program is contained inside one `BEGIN' rule. The first +thing it does is set up the `pathlist' array that `pathto()' uses. +After splitting the path on `:', null elements are replaced with `"."', +which represents the current directory: + + BEGIN { + path = ENVIRON["AWKPATH"] + ndirs = split(path, pathlist, ":") + for (i = 1; i <= ndirs; i++) { + if (pathlist[i] == "") + pathlist[i] = "." + } + + The stack is initialized with `ARGV[1]', which will be `/dev/stdin'. +The main loop comes next. Input lines are read in succession. Lines +that do not start with `@include' are printed verbatim. If the line +does start with `@include', the file name is in `$2'. `pathto()' is +called to generate the full path. If it cannot, then the program +prints an error message and continues. + + The next thing to check is if the file is included already. The +`processed' array is indexed by the full file name of each included +file and it tracks this information for us. If the file is seen again, +a warning message is printed. Otherwise, the new file name is pushed +onto the stack and processing continues. + + Finally, when `getline' encounters the end of the input file, the +file is closed and the stack is popped. When `stackptr' is less than +zero, the program is done: + + stackptr = 0 + input[stackptr] = ARGV[1] # ARGV[1] is first file + + for (; stackptr >= 0; stackptr--) { + while ((getline < input[stackptr]) > 0) { + if (tolower($1) != "@include") { + print + continue + } + fpath = pathto($2) + if (fpath == "") { + printf("igawk:%s:%d: cannot find %s\n", + input[stackptr], FNR, $2) > "/dev/stderr" + continue + } + if (! (fpath in processed)) { + processed[fpath] = input[stackptr] + input[++stackptr] = fpath # push onto stack + } else + print $2, "included in", input[stackptr], + "already included in", + processed[fpath] > "/dev/stderr" + } + close(input[stackptr]) + } + }' # close quote ends `expand_prog' variable + + processed_program=$(gawk -- "$expand_prog" /dev/stdin << EOF + $program + EOF + ) + + The shell construct `COMMAND << MARKER' is called a "here document". +Everything in the shell script up to the MARKER is fed to COMMAND as +input. The shell processes the contents of the here document for +variable and command substitution (and possibly other things as well, +depending upon the shell). + + The shell construct `$(...)' is called "command substitution". The +output of the command inside the parentheses is substituted into the +command line. Because the result is used in a variable assignment, it +is saved as a single string, even if the results contain whitespace. + + The expanded program is saved in the variable `processed_program'. +It's done in these steps: + + 1. Run `gawk' with the `@include'-processing program (the value of + the `expand_prog' shell variable) on standard input. + + 2. Standard input is the contents of the user's program, from the + shell variable `program'. Its contents are fed to `gawk' via a + here document. + + 3. The results of this processing are saved in the shell variable + `processed_program' by using command substitution. + + The last step is to call `gawk' with the expanded program, along +with the original options and command-line arguments that the user +supplied. + + eval gawk $opts -- '"$processed_program"' '"$@"' + + The `eval' command is a shell construct that reruns the shell's +parsing process. This keeps things properly quoted. + + This version of `igawk' represents my fifth version of this program. +There are four key simplifications that make the program work better: + + * Using `@include' even for the files named with `-f' makes building + the initial collected `awk' program much simpler; all the + `@include' processing can be done once. + + * Not trying to save the line read with `getline' in the `pathto()' + function when testing for the file's accessibility for use with + the main program simplifies things considerably. + + * Using a `getline' loop in the `BEGIN' rule does it all in one + place. It is not necessary to call out to a separate loop for + processing nested `@include' statements. + + * Instead of saving the expanded program in a temporary file, + putting it in a shell variable avoids some potential security + problems. This has the disadvantage that the script relies upon + more features of the `sh' language, making it harder to follow for + those who aren't familiar with `sh'. + + Also, this program illustrates that it is often worthwhile to combine +`sh' and `awk' programming together. You can usually accomplish quite +a lot, without having to resort to low-level programming in C or C++, +and it is frequently easier to do certain kinds of string and argument +manipulation using the shell than it is in `awk'. + + Finally, `igawk' shows that it is not always necessary to add new +features to a program; they can often be layered on top. + + As an additional example of this, consider the idea of having two +files in a directory in the search path: + +`default.awk' + This file contains a set of default library functions, such as + `getopt()' and `assert()'. + +`site.awk' + This file contains library functions that are specific to a site or + installation; i.e., locally developed functions. Having a + separate file allows `default.awk' to change with new `gawk' + releases, without requiring the system administrator to update it + each time by adding the local functions. + + One user suggested that `gawk' be modified to automatically read +these files upon startup. Instead, it would be very simple to modify +`igawk' to do this. Since `igawk' can process nested `@include' +directives, `default.awk' could simply contain `@include' statements +for the desired library functions. + + ---------- Footnotes ---------- + + (1) Fully explaining the `sh' language is beyond the scope of this +book. We provide some minimal explanations, but see a good shell +programming book if you wish to understand things in more depth. + + (2) On some very old versions of `awk', the test `getline junk < t' +can loop forever if the file exists but is empty. Caveat emptor. + + +File: gawk.info, Node: Anagram Program, Next: Signature Program, Prev: Igawk Program, Up: Miscellaneous Programs + +13.3.10 Finding Anagrams From A Dictionary +------------------------------------------ + +An interesting programming challenge is to search for "anagrams" in a +word list (such as `/usr/share/dict/words' on many GNU/Linux systems). +One word is an anagram of another if both words contain the same letters +(for example, "babbling" and "blabbing"). + + An elegant algorithm is presented in Column 2, Problem C of Jon +Bentley's `Programming Pearls', second edition. The idea is to give +words that are anagrams a common signature, sort all the words together +by their signature, and then print them. Dr. Bentley observes that +taking the letters in each word and sorting them produces that common +signature. + + The following program uses arrays of arrays to bring together words +with the same signature and array sorting to print the words in sorted +order. + + # anagram.awk --- An implementation of the anagram finding algorithm + # from Jon Bentley's "Programming Pearls", 2nd edition. + # Addison Wesley, 2000, ISBN 0-201-65788-0. + # Column 2, Problem C, section 2.8, pp 18-20. + + /'s$/ { next } # Skip possessives + + The program starts with a header, and then a rule to skip +possessives in the dictionary file. The next rule builds up the data +structure. The first dimension of the array is indexed by the +signature; the second dimension is the word itself: + + { + key = word2key($1) # Build signature + data[key][$1] = $1 # Store word with signature + } + + The `word2key()' function creates the signature. It splits the word +apart into individual letters, sorts the letters, and then joins them +back together: + + # word2key --- split word apart into letters, sort, joining back together + + function word2key(word, a, i, n, result) + { + n = split(word, a, "") + asort(a) + + for (i = 1; i <= n; i++) + result = result a[i] + + return result + } + + Finally, the `END' rule traverses the array and prints out the +anagram lists. It sends the output to the system `sort' command, since +otherwise the anagrams would appear in arbitrary order: + + END { + sort = "sort" + for (key in data) { + # Sort words with same key + nwords = asorti(data[key], words) + if (nwords == 1) + continue + + # And print. Minor glitch: trailing space at end of each line + for (j = 1; j <= nwords; j++) + printf("%s ", words[j]) | sort + print "" | sort + } + close(sort) + } + + Here is some partial output when the program is run: + + $ gawk -f anagram.awk /usr/share/dict/words | grep '^b' + ... + babbled blabbed + babbler blabber brabble + babblers blabbers brabbles + babbling blabbing + babbly blabby + babel bable + babels beslab + babery yabber + ... + + +File: gawk.info, Node: Signature Program, Prev: Anagram Program, Up: Miscellaneous Programs + +13.3.11 And Now For Something Completely Different +-------------------------------------------------- + +The following program was written by Davide Brini and is published on +his website (http://backreference.org/2011/02/03/obfuscated-awk/). It +serves as his signature in the Usenet group `comp.lang.awk'. He +supplies the following copyright terms: + + Copyright (C) 2008 Davide Brini + + Copying and distribution of the code published in this page, with + or without modification, are permitted in any medium without + royalty provided the copyright notice and this notice are + preserved. + + Here is the program: + + awk 'BEGIN{O="~"~"~";o="=="=="==";o+=+o;x=O""O;while(X++<=x+o+o)c=c"%c"; + printf c,(x-O)*(x-O),x*(x-o)-o,x*(x-O)+x-O-o,+x*(x-O)-x+o,X*(o*o+O)+x-O, + X*(X-x)-o*o,(x+X)*o*o+o,x*(X-x)-O-O,x-O+(O+o+X+x)*(o+O),X*X-X*(x-O)-x+O, + O+X*(o*(o+O)+O),+x+O+X*o,x*(x-o),(o+X+x)*o*o-(x-O-O),O+(X-x)*(X+O),x-O}' + + We leave it to you to determine what the program does. + + +File: gawk.info, Node: Debugger, Next: Language History, Prev: Sample Programs, Up: Top + +14 `dgawk': The `awk' Debugger +****************************** + +It would be nice if computer programs worked perfectly the first time +they were run, but in real life, this rarely happens for programs of +any complexity. Thus, most programming languages have facilities +available for "debugging" programs, and now `awk' is no exception. + + The `dgawk' debugger is purposely modeled after the GNU Debugger +(GDB) (http://www.gnu.org/software/gdb/) command-line debugger. If you +are familiar with GDB, learning `dgawk' is easy. + +* Menu: + +* Debugging:: Introduction to `dgawk'. +* Sample dgawk session:: Sample `dgawk' session. +* List of Debugger Commands:: Main `dgawk' Commands. +* Readline Support:: Readline Support. +* Dgawk Limitations:: Limitations and future plans. + + +File: gawk.info, Node: Debugging, Next: Sample dgawk session, Up: Debugger + +14.1 Introduction to `dgawk' +============================ + +This minor node introduces debugging in general and begins the +discussion of debugging in `gawk'. + +* Menu: + +* Debugging Concepts:: Debugging In General. +* Debugging Terms:: Additional Debugging Concepts. +* Awk Debugging:: Awk Debugging. + + +File: gawk.info, Node: Debugging Concepts, Next: Debugging Terms, Up: Debugging + +14.1.1 Debugging In General +--------------------------- + +(If you have used debuggers in other languages, you may want to skip +ahead to the next section on the specific features of the `awk' +debugger.) + + Of course, a debugging program cannot remove bugs for you, since it +has no way of knowing what you or your users consider a "bug" and what +is a "feature." (Sometimes, we humans have a hard time with this +ourselves.) In that case, what can you expect from such a tool? The +answer to that depends on the language being debugged, but in general, +you can expect at least the following: + + * The ability to watch a program execute its instructions one by one, + giving you, the programmer, the opportunity to think about what is + happening on a time scale of seconds, minutes, or hours, rather + than the nanosecond time scale at which the code usually runs. + + * The opportunity to not only passively observe the operation of your + program, but to control it and try different paths of execution, + without having to change your source files. + + * The chance to see the values of data in the program at any point in + execution, and also to change that data on the fly, to see how that + affects what happens afterwards. (This often includes the ability + to look at internal data structures besides the variables you + actually defined in your code.) + + * The ability to obtain additional information about your program's + state or even its internal structure. + + All of these tools provide a great amount of help in using your own +skills and understanding of the goals of your program to find where it +is going wrong (or, for that matter, to better comprehend a perfectly +functional program that you or someone else wrote). + + +File: gawk.info, Node: Debugging Terms, Next: Awk Debugging, Prev: Debugging Concepts, Up: Debugging + +14.1.2 Additional Debugging Concepts +------------------------------------ + +Before diving in to the details, we need to introduce several important +concepts that apply to just about all debuggers, including `dgawk'. +The following list defines terms used throughout the rest of this +major node. + +"Stack Frame" + Programs generally call functions during the course of their + execution. One function can call another, or a function can call + itself (recursion). You can view the chain of called functions + (main program calls A, which calls B, which calls C), as a stack + of executing functions: the currently running function is the + topmost one on the stack, and when it finishes (returns), the next + one down then becomes the active function. Such a stack is termed + a "call stack". + + For each function on the call stack, the system maintains a data + area that contains the function's parameters, local variables, and + return value, as well as any other "bookkeeping" information + needed to manage the call stack. This data area is termed a + "stack frame". + + `gawk' also follows this model, and `dgawk' gives you access to + the call stack and to each stack frame. You can see the call + stack, as well as from where each function on the stack was + invoked. Commands that print the call stack print information about + each stack frame (as detailed later on). + +"Breakpoint" + During debugging, you often wish to let the program run until it + reaches a certain point, and then continue execution from there one + statement (or instruction) at a time. The way to do this is to set + a "breakpoint" within the program. A breakpoint is where the + execution of the program should break off (stop), so that you can + take over control of the program's execution. You can add and + remove as many breakpoints as you like. + +"Watchpoint" + A watchpoint is similar to a breakpoint. The difference is that + breakpoints are oriented around the code: stop when a certain + point in the code is reached. A watchpoint, however, specifies + that program execution should stop when a _data value_ is changed. + This is useful, since sometimes it happens that a variable + receives an erroneous value, and it's hard to track down where + this happens just by looking at the code. By using a watchpoint, + you can stop whenever a variable is assigned to, and usually find + the errant code quite quickly. + + +File: gawk.info, Node: Awk Debugging, Prev: Debugging Terms, Up: Debugging + +14.1.3 Awk Debugging +-------------------- + +Debugging an `awk' program has some specific aspects that are not +shared with other programming languages. + + First of all, the fact that `awk' programs usually take input +line-by-line from a file or files and operate on those lines using +specific rules makes it especially useful to organize viewing the +execution of the program in terms of these rules. As we will see, each +`awk' rule is treated almost like a function call, with its own +specific block of instructions. + + In addition, since `awk' is by design a very concise language, it is +easy to lose sight of everything that is going on "inside" each line of +`awk' code. The debugger provides the opportunity to look at the +individual primitive instructions carried out by the higher-level `awk' +commands. + + +File: gawk.info, Node: Sample dgawk session, Next: List of Debugger Commands, Prev: Debugging, Up: Debugger + +14.2 Sample `dgawk' session +=========================== + +In order to illustrate the use of `dgawk', let's look at a sample +debugging session. We will use the `awk' implementation of the POSIX +`uniq' command described earlier (*note Uniq Program::) as our example. + +* Menu: + +* dgawk invocation:: `dgawk' Invocation. +* Finding The Bug:: Finding The Bug. + + +File: gawk.info, Node: dgawk invocation, Next: Finding The Bug, Up: Sample dgawk session + +14.2.1 `dgawk' Invocation +------------------------- + +Starting `dgawk' is exactly like running `awk'. The file(s) containing +the program and any supporting code are given on the command line as +arguments to one or more `-f' options. (`dgawk' is not designed to +debug command-line programs, only programs contained in files.) In our +case, we call `dgawk' like this: + + $ dgawk -f getopt.awk -f join.awk -f uniq.awk inputfile + +where both `getopt.awk' and `uniq.awk' are in `$AWKPATH'. (Experienced +users of GDB or similar debuggers should note that this syntax is +slightly different from what they are used to. With `dgawk', the +arguments for running the program are given in the command line to the +debugger rather than as part of the `run' command at the debugger +prompt.) + + Instead of immediately running the program on `inputfile', as `gawk' +would ordinarily do, `dgawk' merely loads all the program source files, +compiles them internally, and then gives us a prompt: + + dgawk> + +from which we can issue commands to the debugger. At this point, no +code has been executed. + + +File: gawk.info, Node: Finding The Bug, Prev: dgawk invocation, Up: Sample dgawk session + +14.2.2 Finding The Bug +---------------------- + +Let's say that we are having a problem using (a faulty version of) +`uniq.awk' in the "field-skipping" mode, and it doesn't seem to be +catching lines which should be identical when skipping the first field, +such as: + + awk is a wonderful program! + gawk is a wonderful program! + + This could happen if we were thinking (C-like) of the fields in a +record as being numbered in a zero-based fashion, so instead of the +lines: + + clast = join(alast, fcount+1, n) + cline = join(aline, fcount+1, m) + +we wrote: + + clast = join(alast, fcount, n) + cline = join(aline, fcount, m) + + The first thing we usually want to do when trying to investigate a +problem like this is to put a breakpoint in the program so that we can +watch it at work and catch what it is doing wrong. A reasonable spot +for a breakpoint in `uniq.awk' is at the beginning of the function +`are_equal()', which compares the current line with the previous one. +To set the breakpoint, use the `b' (breakpoint) command: + + dgawk> b are_equal + -| Breakpoint 1 set at file `awklib/eg/prog/uniq.awk', line 64 + + The debugger tells us the file and line number where the breakpoint +is. Now type `r' or `run' and the program runs until it hits the +breakpoint for the first time: + + dgawk> r + -| Starting program: + -| Stopping in Rule ... + -| Breakpoint 1, are_equal(n, m, clast, cline, alast, aline) + at `awklib/eg/prog/uniq.awk':64 + -| 64 if (fcount == 0 && charcount == 0) + dgawk> + + Now we can look at what's going on inside our program. First of all, +let's see how we got to where we are. At the prompt, we type `bt' +(short for "backtrace"), and `dgawk' responds with a listing of the +current stack frames: + + dgawk> bt + -| #0 are_equal(n, m, clast, cline, alast, aline) + at `awklib/eg/prog/uniq.awk':69 + -| #1 in main() at `awklib/eg/prog/uniq.awk':89 + + This tells us that `are_equal()' was called by the main program at +line 89 of `uniq.awk'. (This is not a big surprise, since this is the +only call to `are_equal()' in the program, but in more complex +programs, knowing who called a function and with what parameters can be +the key to finding the source of the problem.) + + Now that we're in `are_equal()', we can start looking at the values +of some variables. Let's say we type `p n' (`p' is short for "print"). +We would expect to see the value of `n', a parameter to `are_equal()'. +Actually, `dgawk' gives us: + + dgawk> p n + -| n = untyped variable + +In this case, `n' is an uninitialized local variable, since the +function was called without arguments (*note Function Calls::). + + A more useful variable to display might be the current record: + + dgawk> p $0 + -| $0 = string ("gawk is a wonderful program!") + +This might be a bit puzzling at first since this is the second line of +our test input above. Let's look at `NR': + + dgawk> p NR + -| NR = number (2) + +So we can see that `are_equal()' was only called for the second record +of the file. Of course, this is because our program contained a rule +for `NR == 1': + + NR == 1 { + last = $0 + next + } + + OK, let's just check that that rule worked correctly: + + dgawk> p last + -| last = string ("awk is a wonderful program!") + + Everything we have done so far has verified that the program has +worked as planned, up to and including the call to `are_equal()', so +the problem must be inside this function. To investigate further, we +must begin "stepping through" the lines of `are_equal()'. We start by +typing `n' (for "next"): + + dgawk> n + -| 67 if (fcount > 0) { + + This tells us that `gawk' is now ready to execute line 67, which +decides whether to give the lines the special "field skipping" treatment +indicated by the `-f' command-line option. (Notice that we skipped +from where we were before at line 64 to here, since the condition in +line 64 + + if (fcount == 0 && charcount == 0) + +was false.) + + Continuing to step, we now get to the splitting of the current and +last records: + + dgawk> n + -| 68 n = split(last, alast) + dgawk> n + -| 69 m = split($0, aline) + + At this point, we should be curious to see what our records were +split into, so we try to look: + + dgawk> p n m alast aline + -| n = number (5) + -| m = number (5) + -| alast = array, 5 elements + -| aline = array, 5 elements + +(The `p' command can take more than one argument, similar to `awk''s +`print' statement.) + + This is kind of disappointing, though. All we found out is that +there are five elements in each of our arrays. Useful enough (we now +know that none of the words were accidentally left out), but what if we +want to see inside the array? + + The first choice would be to use subscripts: + + dgawk> p alast[0] + -| "0" not in array `alast' + +Oops! + + dgawk> p alast[1] + -| alast["1"] = string ("awk") + + This would be kind of slow for a 100-member array, though, so +`dgawk' provides a shortcut (reminiscent of another language not to be +mentioned): + + dgawk> p @alast + -| alast["1"] = string ("awk") + -| alast["2"] = string ("is") + -| alast["3"] = string ("a") + -| alast["4"] = string ("wonderful") + -| alast["5"] = string ("program!") + + It looks like we got this far OK. Let's take another step or two: + + dgawk> n + -| 70 clast = join(alast, fcount, n) + dgawk> n + -| 71 cline = join(aline, fcount, m) + + Well, here we are at our error (sorry to spoil the suspense). What +we had in mind was to join the fields starting from the second one to +make the virtual record to compare, and if the first field was numbered +zero, this would work. Let's look at what we've got: + + dgawk> p cline clast + -| cline = string ("gawk is a wonderful program!") + -| clast = string ("awk is a wonderful program!") + + Hey, those look pretty familiar! They're just our original, +unaltered, input records. A little thinking (the human brain is still +the best debugging tool), and we realize that we were off by one! + + We get out of `dgawk': + + dgawk> q + -| The program is running. Exit anyway (y/n)? y + +Then we get into an editor: + + clast = join(alast, fcount+1, n) + cline = join(aline, fcount+1, m) + +and problem solved! + + +File: gawk.info, Node: List of Debugger Commands, Next: Readline Support, Prev: Sample dgawk session, Up: Debugger + +14.3 Main `dgawk' Commands +========================== + +The `dgawk' command set can be divided into the following categories: + + * Breakpoint control + + * Execution control + + * Viewing and changing data + + * Working with the stack + + * Getting information + + * Miscellaneous + + Each of these are discussed in the following subsections. In the +following descriptions, commands which may be abbreviated show the +abbreviation on a second description line. A `dgawk' command name may +also be truncated if that partial name is unambiguous. `dgawk' has the +built-in capability to automatically repeat the previous command when +just hitting . This works for the commands `list', `next', +`nexti', `step', `stepi' and `continue' executed without any argument. + +* Menu: + +* Breakpoint Control:: Control of breakpoints. +* Dgawk Execution Control:: Control of execution. +* Viewing And Changing Data:: Viewing and changing data. +* Dgawk Stack:: Dealing with the stack. +* Dgawk Info:: Obtaining information about the program and + the debugger state. +* Miscellaneous Dgawk Commands:: Miscellaneous Commands. + + +File: gawk.info, Node: Breakpoint Control, Next: Dgawk Execution Control, Up: List of Debugger Commands + +14.3.1 Control Of Breakpoints +----------------------------- + +As we saw above, the first thing you probably want to do in a debugging +session is to get your breakpoints set up, since otherwise your program +will just run as if it was not under the debugger. The commands for +controlling breakpoints are: + +`break' [[FILENAME`:']N | FUNCTION] [`"EXPRESSION"'] +`b' [[FILENAME`:']N | FUNCTION] [`"EXPRESSION"'] + Without any argument, set a breakpoint at the next instruction to + be executed in the selected stack frame. Arguments can be one of + the following: + + N + Set a breakpoint at line number N in the current source file. + + FILENAME`:'N + Set a breakpoint at line number N in source file FILENAME. + + FUNCTION + Set a breakpoint at entry to (the first instruction of) + function FUNCTION. + + Each breakpoint is assigned a number which can be used to delete + it from the breakpoint list using the `delete' command. + + With a breakpoint, you may also supply a condition. This is an + `awk' expression (enclosed in double quotes) that `dgawk' + evaluates whenever the breakpoint is reached. If the condition is + true, then `dgawk' stops execution and prompts for a command. + Otherwise, `dgawk' continues executing the program. + +`clear' [[FILENAME`:']N | FUNCTION] + Without any argument, delete any breakpoint at the next instruction + to be executed in the selected stack frame. If the program stops at + a breakpoint, this deletes that breakpoint so that the program + does not stop at that location again. Arguments can be one of the + following: + + N + Delete breakpoint(s) set at line number N in the current + source file. + + FILENAME`:'N + Delete breakpoint(s) set at line number N in source file + FILENAME. + + FUNCTION + Delete breakpoint(s) set at entry to function FUNCTION. + +`condition' N `"EXPRESSION"' + Add a condition to existing breakpoint or watchpoint N. The + condition is an `awk' expression that `dgawk' evaluates whenever + the breakpoint or watchpoint is reached. If the condition is true, + then `dgawk' stops execution and prompts for a command. Otherwise, + `dgawk' continues executing the program. If the condition + expression is not specified, any existing condition is removed; + i.e., the breakpoint or watchpoint is made unconditional. + +`delete' [N1 N2 ...] [N-M] +`d' [N1 N2 ...] [N-M] + Delete specified breakpoints or a range of breakpoints. Deletes + all defined breakpoints if no argument is supplied. + +`disable' [N1 N2 ... | N-M] + Disable specified breakpoints or a range of breakpoints. Without + any argument, disables all breakpoints. + +`enable' [`del' | `once'] [N1 N2 ...] [N-M] +`e' [`del' | `once'] [N1 N2 ...] [N-M] + Enable specified breakpoints or a range of breakpoints. Without + any argument, enables all breakpoints. Optionally, you can + specify how to enable the breakpoint: + + `del' + Enable the breakpoint(s) temporarily, then delete it when the + program stops at the breakpoint. + + `once' + Enable the breakpoint(s) temporarily, then disable it when + the program stops at the breakpoint. + +`ignore' N COUNT + Ignore breakpoint number N the next COUNT times it is hit. + +`tbreak' [[FILENAME`:']N | FUNCTION] +`t' [[FILENAME`:']N | FUNCTION] + Set a temporary breakpoint (enabled for only one stop). The + arguments are the same as for `break'. + + +File: gawk.info, Node: Dgawk Execution Control, Next: Viewing And Changing Data, Prev: Breakpoint Control, Up: List of Debugger Commands + +14.3.2 Control of Execution +--------------------------- + +Now that your breakpoints are ready, you can start running the program +and observing its behavior. There are more commands for controlling +execution of the program than we saw in our earlier example: + +`commands' [N] +`silent' +... +`end' + Set a list of commands to be executed upon stopping at a + breakpoint or watchpoint. N is the breakpoint or watchpoint number. + Without a number, the last one set is used. The actual commands + follow, starting on the next line, and terminated by the `end' + command. If the command `silent' is in the list, the usual + messages about stopping at a breakpoint and the source line are + not printed. Any command in the list that resumes execution (e.g., + `continue') terminates the list (an implicit `end'), and + subsequent commands are ignored. For example: + + dgawk> commands + > silent + > printf "A silent breakpoint; i = %d\n", i + > info locals + > set i = 10 + > continue + > end + dgawk> + +`continue' [COUNT] +`c' [COUNT] + Resume program execution. If continued from a breakpoint and COUNT + is specified, ignores the breakpoint at that location the next + COUNT times before stopping. + +`finish' + Execute until the selected stack frame returns. Print the + returned value. + +`next' [COUNT] +`n' [COUNT] + Continue execution to the next source line, stepping over function + calls. The argument COUNT controls how many times to repeat the + action, as in `step'. + +`nexti' [COUNT] +`ni' [COUNT] + Execute one (or COUNT) instruction(s), stepping over function + calls. + +`return' [VALUE] + Cancel execution of a function call. If VALUE (either a string or a + number) is specified, it is used as the function's return value. + If used in a frame other than the innermost one (the currently + executing function, i.e., frame number 0), discard all inner + frames in addition to the selected one, and the caller of that + frame becomes the innermost frame. + +`run' +`r' + Start/restart execution of the program. When restarting, `dgawk' + retains the current breakpoints, watchpoints, command history, + automatic display variables, and debugger options. + +`step' [COUNT] +`s' [COUNT] + Continue execution until control reaches a different source line + in the current stack frame. `step' steps inside any function + called within the line. If the argument COUNT is supplied, steps + that many times before stopping, unless it encounters a breakpoint + or watchpoint. + +`stepi' [COUNT] +`si' [COUNT] + Execute one (or COUNT) instruction(s), stepping inside function + calls. (For illustration of what is meant by an "instruction" in + `gawk', see the output shown under `dump' in *note Miscellaneous + Dgawk Commands::.) + +`until' [[FILENAME`:']N | FUNCTION] +`u' [[FILENAME`:']N | FUNCTION] + Without any argument, continue execution until a line past the + current line in current stack frame is reached. With an argument, + continue execution until the specified location is reached, or the + current stack frame returns. + + +File: gawk.info, Node: Viewing And Changing Data, Next: Dgawk Stack, Prev: Dgawk Execution Control, Up: List of Debugger Commands + +14.3.3 Viewing and Changing Data +-------------------------------- + +The commands for viewing and changing variables inside of `gawk' are: + +`display' [VAR | `$'N] + Add variable VAR (or field `$N') to the display list. The value + of the variable or field is displayed each time the program stops. + Each variable added to the list is identified by a unique number: + + dgawk> display x + -| 10: x = 1 + + displays the assigned item number, the variable name and its + current value. If the display variable refers to a function + parameter, it is silently deleted from the list as soon as the + execution reaches a context where no such variable of the given + name exists. Without argument, `display' displays the current + values of items on the list. + +`eval "AWK STATEMENTS"' + Evaluate AWK STATEMENTS in the context of the running program. + You can do anything that an `awk' program would do: assign values + to variables, call functions, and so on. + +`eval' PARAM, ... +AWK STATEMENTS +`end' + This form of `eval' is similar, but it allows you to define "local + variables" that exist in the context of the AWK STATEMENTS, + instead of using variables or function parameters defined by the + program. + +`print' VAR1[`,' VAR2 ...] +`p' VAR1[`,' VAR2 ...] + Print the value of a `gawk' variable or field. Fields must be + referenced by constants: + + dgawk> print $3 + + This prints the third field in the input record (if the specified + field does not exist, it prints `Null field'). A variable can be + an array element, with the subscripts being constant values. To + print the contents of an array, prefix the name of the array with + the `@' symbol: + + gawk> print @a + + This prints the indices and the corresponding values for all + elements in the array `a'. + +`printf' FORMAT [`,' ARG ...] + Print formatted text. The FORMAT may include escape sequences, + such as `\n' (*note Escape Sequences::). No newline is printed + unless one is specified. + +`set' VAR`='VALUE + Assign a constant (number or string) value to an `awk' variable or + field. String values must be enclosed between double quotes + (`"..."'). + + You can also set special `awk' variables, such as `FS', `NF', + `NR', etc. + +`watch' VAR | `$'N [`"EXPRESSION"'] +`w' VAR | `$'N [`"EXPRESSION"'] + Add variable VAR (or field `$N') to the watch list. `dgawk' then + stops whenever the value of the variable or field changes. Each + watched item is assigned a number which can be used to delete it + from the watch list using the `unwatch' command. + + With a watchpoint, you may also supply a condition. This is an + `awk' expression (enclosed in double quotes) that `dgawk' + evaluates whenever the watchpoint is reached. If the condition is + true, then `dgawk' stops execution and prompts for a command. + Otherwise, `dgawk' continues executing the program. + +`undisplay' [N] + Remove item number N (or all items, if no argument) from the + automatic display list. + +`unwatch' [N] + Remove item number N (or all items, if no argument) from the watch + list. + + + +File: gawk.info, Node: Dgawk Stack, Next: Dgawk Info, Prev: Viewing And Changing Data, Up: List of Debugger Commands + +14.3.4 Dealing With The Stack +----------------------------- + +Whenever you run a program which contains any function calls, `gawk' +maintains a stack of all of the function calls leading up to where the +program is right now. You can see how you got to where you are, and +also move around in the stack to see what the state of things was in the +functions which called the one you are in. The commands for doing this +are: + +`backtrace' [COUNT] +`bt' [COUNT] + Print a backtrace of all function calls (stack frames), or + innermost COUNT frames if COUNT > 0. Print the outermost COUNT + frames if COUNT < 0. The backtrace displays the name and + arguments to each function, the source file name, and the line + number. + +`down' [COUNT] + Move COUNT (default 1) frames down the stack toward the innermost + frame. Then select and print the frame. + +`frame' [N] +`f' [N] + Select and print (frame number, function and argument names, + source file, and the source line) stack frame N. Frame 0 is the + currently executing, or "innermost", frame (function call), frame + 1 is the frame that called the innermost one. The highest numbered + frame is the one for the main program. + +`up' [COUNT] + Move COUNT (default 1) frames up the stack toward the outermost + frame. Then select and print the frame. + + +File: gawk.info, Node: Dgawk Info, Next: Miscellaneous Dgawk Commands, Prev: Dgawk Stack, Up: List of Debugger Commands + +14.3.5 Obtaining Information About The Program and The Debugger State +--------------------------------------------------------------------- + +Besides looking at the values of variables, there is often a need to get +other sorts of information about the state of your program and of the +debugging environment itself. `dgawk' has one command which provides +this information, appropriately called `info'. `info' is used with one +of a number of arguments that tell it exactly what you want to know: + +`info' WHAT +`i' WHAT + The value for WHAT should be one of the following: + + `args' + Arguments of the selected frame. + + `break' + List all currently set breakpoints. + + `display' + List all items in the automatic display list. + + `frame' + Description of the selected stack frame. + + `functions' + List all function definitions including source file names and + line numbers. + + `locals' + Local variables of the selected frame. + + `source' + The name of the current source file. Each time the program + stops, the current source file is the file containing the + current instruction. When `dgawk' first starts, the current + source file is the first file included via the `-f' option. + The `list FILENAME:LINENO' command can be used at any time to + change the current source. + + `sources' + List all program sources. + + `variables' + List all global variables. + + `watch' + List all items in the watch list. + + Additional commands give you control over the debugger, the ability +to save the debugger's state, and the ability to run debugger commands +from a file. The commands are: + +`option' [NAME[`='VALUE]] +`o' [NAME[`='VALUE]] + Without an argument, display the available debugger options and + their current values. `option NAME' shows the current value of the + named option. `option NAME=VALUE' assigns a new value to the named + option. The available options are: + + `history_size' + The maximum number of lines to keep in the history file + `./.dgawk_history'. The default is 100. + + `listsize' + The number of lines that `list' prints. The default is 15. + + `outfile' + Send `gawk' output to a file; debugger output still goes to + standard output. An empty string (`""') resets output to + standard output. + + `prompt' + The debugger prompt. The default is `dgawk> '. + + `save_history [on | off]' + Save command history to file `./.dgawk_history'. The default + is `on'. + + `save_options [on | off]' + Save current options to file `./.dgawkrc' upon exit. The + default is `on'. Options are read back in to the next + session upon startup. + + `trace [on | off]' + Turn instruction tracing on or off. The default is `off'. + +`save' FILENAME + Save the commands from the current session to the given file name, + so that they can be replayed using the `source' command. + +`source' FILENAME + Run command(s) from a file; an error in any command does not + terminate execution of subsequent commands. Comments (lines + starting with `#') are allowed in a command file. Empty lines are + ignored; they do _not_ repeat the last command. You can't restart + the program by having more than one `run' command in the file. + Also, the list of commands may include additional `source' + commands; however, `dgawk' will not source the same file more than + once in order to avoid infinite recursion. + + In addition to, or instead of the `source' command, you can use + the `-R FILE' or `--command=FILE' command-line options to execute + commands from a file non-interactively (*note Options::. + + +File: gawk.info, Node: Miscellaneous Dgawk Commands, Prev: Dgawk Info, Up: List of Debugger Commands + +14.3.6 Miscellaneous Commands +----------------------------- + +There are a few more commands which do not fit into the previous +categories, as follows: + +`dump' [FILENAME] + Dump bytecode of the program to standard output or to the file + named in FILENAME. This prints a representation of the internal + instructions which `gawk' executes to implement the `awk' commands + in a program. This can be very enlightening, as the following + partial dump of Davide Brini's obfuscated code (*note Signature + Program::) demonstrates: + + dgawk> dump + -| # BEGIN + -| + -| [ 2:0x89faef4] Op_rule : [in_rule = BEGIN] [source_file = brini.awk] + -| [ 3:0x89fa428] Op_push_i : "~" [PERM|STRING|STRCUR] + -| [ 3:0x89fa464] Op_push_i : "~" [PERM|STRING|STRCUR] + -| [ 3:0x89fa450] Op_match : + -| [ 3:0x89fa3ec] Op_store_var : O [do_reference = FALSE] + -| [ 4:0x89fa48c] Op_push_i : "==" [PERM|STRING|STRCUR] + -| [ 4:0x89fa4c8] Op_push_i : "==" [PERM|STRING|STRCUR] + -| [ 4:0x89fa4b4] Op_equal : + -| [ 4:0x89fa400] Op_store_var : o [do_reference = FALSE] + -| [ 5:0x89fa4f0] Op_push : o + -| [ 5:0x89fa4dc] Op_plus_i : 0 [PERM|NUMCUR|NUMBER] + -| [ 5:0x89fa414] Op_push_lhs : o [do_reference = TRUE] + -| [ 5:0x89fa4a0] Op_assign_plus : + -| [ :0x89fa478] Op_pop : + -| [ 6:0x89fa540] Op_push : O + -| [ 6:0x89fa554] Op_push_i : "" [PERM|STRING|STRCUR] + -| [ :0x89fa5a4] Op_no_op : + -| [ 6:0x89fa590] Op_push : O + -| [ :0x89fa5b8] Op_concat : [expr_count = 3] [concat_flag = 0] + -| [ 6:0x89fa518] Op_store_var : x [do_reference = FALSE] + -| [ 7:0x89fa504] Op_push_loop : [target_continue = 0x89fa568] [target_break = 0x89fa680] + -| [ 7:0x89fa568] Op_push_lhs : X [do_reference = TRUE] + -| [ 7:0x89fa52c] Op_postincrement : + -| [ 7:0x89fa5e0] Op_push : x + -| [ 7:0x89fa61c] Op_push : o + -| [ 7:0x89fa5f4] Op_plus : + -| [ 7:0x89fa644] Op_push : o + -| [ 7:0x89fa630] Op_plus : + -| [ 7:0x89fa5cc] Op_leq : + -| [ :0x89fa57c] Op_jmp_false : [target_jmp = 0x89fa680] + -| [ 7:0x89fa694] Op_push_i : "%c" [PERM|STRING|STRCUR] + -| [ :0x89fa6d0] Op_no_op : + -| [ 7:0x89fa608] Op_assign_concat : c + -| [ :0x89fa6a8] Op_jmp : [target_jmp = 0x89fa568] + -| [ :0x89fa680] Op_pop_loop : + -| + ... + -| + -| [ 8:0x89fa658] Op_K_printf : [expr_count = 17] [redir_type = ""] + -| [ :0x89fa374] Op_no_op : + -| [ :0x89fa3d8] Op_atexit : + -| [ :0x89fa6bc] Op_stop : + -| [ :0x89fa39c] Op_no_op : + -| [ :0x89fa3b0] Op_after_beginfile : + -| [ :0x89fa388] Op_no_op : + -| [ :0x89fa3c4] Op_after_endfile : + dgawk> + +`help' +`h' + Print a list of all of the `dgawk' commands with a short summary + of their usage. `help COMMAND' prints the information about the + command COMMAND. + +`list' [`-' | `+' | N | FILENAME`:'N | N-M | FUNCTION] +`l' [`-' | `+' | N | FILENAME`:'N | N-M | FUNCTION] + Print the specified lines (default 15) from the current source file + or the file named FILENAME. The possible arguments to `list' are + as follows: + + `-' + Print lines before the lines last printed. + + `+' + Print lines after the lines last printed. `list' without any + argument does the same thing. + + N + Print lines centered around line number N. + + N-M + Print lines from N to M. + + FILENAME`:'N + Print lines centered around line number N in source file + FILENAME. This command may change the current source file. + + FUNCTION + Print lines centered around beginning of the function + FUNCTION. This command may change the current source file. + +`quit' +`q' + Exit the debugger. Debugging is great fun, but sometimes we all + have to tend to other obligations in life, and sometimes we find + the bug, and are free to go on to the next one! As we saw above, + if you are running a program, `dgawk' warns you if you + accidentally type `q' or `quit', to make sure you really want to + quit. + +`trace' `on' | `off' + Turn on or off a continuous printing of instructions which are + about to be executed, along with printing the `awk' line which they + implement. The default is `off'. + + It is to be hoped that most of the "opcodes" in these instructions + are fairly self-explanatory, and using `stepi' and `nexti' while + `trace' is on will make them into familiar friends. + + + +File: gawk.info, Node: Readline Support, Next: Dgawk Limitations, Prev: List of Debugger Commands, Up: Debugger + +14.4 Readline Support +===================== + +If `dgawk' is compiled with the `readline' library, you can take +advantage of that library's command completion and history expansion +features. The following types of completion are available: + +Command completion + Command names. + +Source file name completion + Source file names. Relevant commands are `break', `clear', `list', + `tbreak', and `until'. + +Argument completion + Non-numeric arguments to a command. Relevant commands are + `enable' and `info'. + +Variable name completion + Global variable names, and function arguments in the current + context if the program is running. Relevant commands are `display', + `print', `set', and `watch'. + + + +File: gawk.info, Node: Dgawk Limitations, Prev: Readline Support, Up: Debugger + +14.5 Limitations and Future Plans +================================= + +We hope you find `dgawk' useful and enjoyable to work with, but as with +any program, especially in its early releases, it still has some +limitations. A few which are worth being aware of are: + + * At this point, `dgawk' does not give a detailed explanation of + what you did wrong when you type in something it doesn't like. + Rather, it just responds `syntax error'. When you do figure out + what your mistake was, though, you'll feel like a real guru. + + * If you perused the dump of opcodes in *note Miscellaneous Dgawk + Commands::, (or if you are already familiar with `gawk' internals), + you will realize that much of the internal manipulation of data in + `gawk', as in many interpreters, is done on a stack. `Op_push', + `Op_pop', etc., are the "bread and butter" of most `gawk' code. + Unfortunately, as of now, `dgawk' does not allow you to examine + the stack's contents. + + That is, the intermediate results of expression evaluation are on + the stack, but cannot be printed. Rather, only variables which + are defined in the program can be printed. Of course, a + workaround for this is to use more explicit variables at the + debugging stage and then change back to obscure, perhaps more + optimal code later. + + * There is no way to look "inside" the process of compiling regular + expressions to see if you got it right. As an `awk' programmer, + you are expected to know what `/[^[:alnum:][:blank:]]/' means. + + * `dgawk' is designed to be used by running a program (with all its + parameters) on the command line, as described in *note dgawk + invocation::. There is no way (as of now) to attach or "break in" + to a running program. This seems reasonable for a language which + is used mainly for quickly executing, short programs. + + * `dgawk' only accepts source supplied with the `-f' option. + + Look forward to a future release when these and other missing +features may be added, and of course feel free to try to add them +yourself! + + +File: gawk.info, Node: Language History, Next: Installation, Prev: Debugger, Up: Top + +Appendix A The Evolution of the `awk' Language +********************************************** + +This Info file describes the GNU implementation of `awk', which follows +the POSIX specification. Many long-time `awk' users learned `awk' +programming with the original `awk' implementation in Version 7 Unix. +(This implementation was the basis for `awk' in Berkeley Unix, through +4.3-Reno. Subsequent versions of Berkeley Unix, and some systems +derived from 4.4BSD-Lite, use various versions of `gawk' for their +`awk'.) This major node briefly describes the evolution of the `awk' +language, with cross-references to other parts of the Info file where +you can find more information. + +* Menu: + +* V7/SVR3.1:: The major changes between V7 and System V + Release 3.1. +* SVR4:: Minor changes between System V Releases 3.1 + and 4. +* POSIX:: New features from the POSIX standard. +* BTL:: New features from Brian Kernighan's version of + `awk'. +* POSIX/GNU:: The extensions in `gawk' not in POSIX + `awk'. +* Common Extensions:: Common Extensions Summary. +* Ranges and Locales:: How locales used to affect regexp ranges. +* Contributors:: The major contributors to `gawk'. + + +File: gawk.info, Node: V7/SVR3.1, Next: SVR4, Up: Language History + +A.1 Major Changes Between V7 and SVR3.1 +======================================= + +The `awk' language evolved considerably between the release of Version +7 Unix (1978) and the new version that was first made generally +available in System V Release 3.1 (1987). This minor node summarizes +the changes, with cross-references to further details: + + * The requirement for `;' to separate rules on a line (*note + Statements/Lines::). + + * User-defined functions and the `return' statement (*note + User-defined::). + + * The `delete' statement (*note Delete::). + + * The `do'-`while' statement (*note Do Statement::). + + * The built-in functions `atan2()', `cos()', `sin()', `rand()', and + `srand()' (*note Numeric Functions::). + + * The built-in functions `gsub()', `sub()', and `match()' (*note + String Functions::). + + * The built-in functions `close()' and `system()' (*note I/O + Functions::). + + * The `ARGC', `ARGV', `FNR', `RLENGTH', `RSTART', and `SUBSEP' + built-in variables (*note Built-in Variables::). + + * Assignable `$0' (*note Changing Fields::). + + * The conditional expression using the ternary operator `?:' (*note + Conditional Exp::). + + * The expression `INDEX-VARIABLE in ARRAY' outside of `for' + statements (*note Reference to Elements::). + + * The exponentiation operator `^' (*note Arithmetic Ops::) and its + assignment operator form `^=' (*note Assignment Ops::). + + * C-compatible operator precedence, which breaks some old `awk' + programs (*note Precedence::). + + * Regexps as the value of `FS' (*note Field Separators::) and as the + third argument to the `split()' function (*note String + Functions::), rather than using only the first character of `FS'. + + * Dynamic regexps as operands of the `~' and `!~' operators (*note + Regexp Usage::). + + * The escape sequences `\b', `\f', and `\r' (*note Escape + Sequences::). (Some vendors have updated their old versions of + `awk' to recognize `\b', `\f', and `\r', but this is not something + you can rely on.) + + * Redirection of input for the `getline' function (*note Getline::). + + * Multiple `BEGIN' and `END' rules (*note BEGIN/END::). + + * Multidimensional arrays (*note Multi-dimensional::). + + +File: gawk.info, Node: SVR4, Next: POSIX, Prev: V7/SVR3.1, Up: Language History + +A.2 Changes Between SVR3.1 and SVR4 +=================================== + +The System V Release 4 (1989) version of Unix `awk' added these features +(some of which originated in `gawk'): + + * The `ENVIRON' array (*note Built-in Variables::). + + * Multiple `-f' options on the command line (*note Options::). + + * The `-v' option for assigning variables before program execution + begins (*note Options::). + + * The `--' option for terminating command-line options. + + * The `\a', `\v', and `\x' escape sequences (*note Escape + Sequences::). + + * A defined return value for the `srand()' built-in function (*note + Numeric Functions::). + + * The `toupper()' and `tolower()' built-in string functions for case + translation (*note String Functions::). + + * A cleaner specification for the `%c' format-control letter in the + `printf' function (*note Control Letters::). + + * The ability to dynamically pass the field width and precision + (`"%*.*d"') in the argument list of the `printf' function (*note + Control Letters::). + + * The use of regexp constants, such as `/foo/', as expressions, where + they are equivalent to using the matching operator, as in `$0 ~ + /foo/' (*note Using Constant Regexps::). + + * Processing of escape sequences inside command-line variable + assignments (*note Assignment Options::). + + +File: gawk.info, Node: POSIX, Next: BTL, Prev: SVR4, Up: Language History + +A.3 Changes Between SVR4 and POSIX `awk' +======================================== + +The POSIX Command Language and Utilities standard for `awk' (1992) +introduced the following changes into the language: + + * The use of `-W' for implementation-specific options (*note + Options::). + + * The use of `CONVFMT' for controlling the conversion of numbers to + strings (*note Conversion::). + + * The concept of a numeric string and tighter comparison rules to go + with it (*note Typing and Comparison::). + + * The use of built-in variables as function parameter names is + forbidden (*note Definition Syntax::. + + * More complete documentation of many of the previously undocumented + features of the language. + + *Note Common Extensions::, for a list of common extensions not +permitted by the POSIX standard. + + The 2008 POSIX standard can be found online at +`http://www.opengroup.org/onlinepubs/9699919799/'. + + +File: gawk.info, Node: BTL, Next: POSIX/GNU, Prev: POSIX, Up: Language History + +A.4 Extensions in Brian Kernighan's `awk' +========================================= + +Brian Kernighan has made his version available via his home page (*note +Other Versions::). + + This minor node describes common extensions that originally appeared +in his version of `awk'. + + * The `**' and `**=' operators (*note Arithmetic Ops:: and *note + Assignment Ops::). + + * The use of `func' as an abbreviation for `function' (*note + Definition Syntax::). + + * The `fflush()' built-in function for flushing buffered output + (*note I/O Functions::). + + + *Note Common Extensions::, for a full list of the extensions +available in his `awk'. + + +File: gawk.info, Node: POSIX/GNU, Next: Common Extensions, Prev: BTL, Up: Language History + +A.5 Extensions in `gawk' Not in POSIX `awk' +=========================================== + +The GNU implementation, `gawk', adds a large number of features. They +can all be disabled with either the `--traditional' or `--posix' options +(*note Options::). + + A number of features have come and gone over the years. This minor +node summarizes the additional features over POSIX `awk' that are in +the current version of `gawk'. + + * Additional built-in variables: + + - The `ARGIND' `BINMODE', `ERRNO', `FIELDWIDTHS', `FPAT', + `IGNORECASE', `LINT', `PROCINFO', `RT', and `TEXTDOMAIN' + variables (*note Built-in Variables::). + + * Special files in I/O redirections: + + - The `/dev/stdin', `/dev/stdout', `/dev/stderr' and + `/dev/fd/N' special file names (*note Special Files::). + + - The `/inet', `/inet4', and `/inet6' special files for TCP/IP + networking using `|&' to specify which version of the IP + protocol to use. (*note TCP/IP Networking::). + + * Changes and/or additions to the language: + + - The `\x' escape sequence (*note Escape Sequences::). + + - Full support for both POSIX and GNU regexps (*note Regexp::). + + - The ability for `FS' and for the third argument to `split()' + to be null strings (*note Single Character Fields::). + + - The ability for `RS' to be a regexp (*note Records::). + + - The ability to use octal and hexadecimal constants in `awk' + program source code (*note Nondecimal-numbers::). + + - The `|&' operator for two-way I/O to a coprocess (*note + Two-way I/O::). + + - Indirect function calls (*note Indirect Calls::). + + - Directories on the command line produce a warning and are + skipped (*note Command line directories::). + + * New keywords: + + - The `BEGINFILE' and `ENDFILE' special patterns. (*note + BEGINFILE/ENDFILE::). + + - The ability to delete all of an array at once with `delete + ARRAY' (*note Delete::). + + - The `nextfile' statement (*note Nextfile Statement::). + + - The `switch' statement (*note Switch Statement::). + + * Changes to standard `awk' functions: + + - The optional second argument to `close()' that allows closing + one end of a two-way pipe to a coprocess (*note Two-way + I/O::). + + - POSIX compliance for `gsub()' and `sub()'. + + - The `length()' function accepts an array argument and returns + the number of elements in the array (*note String + Functions::). + + - The optional third argument to the `match()' function for + capturing text-matching subexpressions within a regexp (*note + String Functions::). + + - Positional specifiers in `printf' formats for making + translations easier (*note Printf Ordering::). + + - The `split()' function's additional optional fourth argument + which is an array to hold the text of the field separators. + (*note String Functions::). + + * Additional functions only in `gawk': + + - The `and()', `compl()', `lshift()', `or()', `rshift()', and + `xor()' functions for bit manipulation (*note Bitwise + Functions::). + + - The `asort()' and `asorti()' functions for sorting arrays + (*note Array Sorting::). + + - The `bindtextdomain()', `dcgettext()' and `dcngettext()' + functions for internationalization (*note Programmer i18n::). + + - The `extension()' built-in function and the ability to add + new functions dynamically (*note Dynamic Extensions::). + + - The `fflush()' function from Brian Kernighan's version of + `awk' (*note I/O Functions::). + + - The `gensub()', `patsplit()', and `strtonum()' functions for + more powerful text manipulation (*note String Functions::). + + - The `mktime()', `systime()', and `strftime()' functions for + working with timestamps (*note Time Functions::). + + * Changes and/or additions in the command-line options: + + - The `AWKPATH' environment variable for specifying a path + search for the `-f' command-line option (*note Options::). + + - The ability to use GNU-style long-named options that start + with `--' and the `--characters-as-bytes', `--compat', + `--dump-variables', `--exec', `--gen-pot', `--lint', + `--lint-old', `--non-decimal-data', `--posix', `--profile', + `--re-interval', `--sandbox', `--source', `--traditional', and + `--use-lc-numeric' options (*note Options::). + + * Support for the following obsolete systems was removed from the + code and the documentation for `gawk' version 4.0: + + - Amiga + + - Atari + + - BeOS + + - Cray + + - MIPS RiscOS + + - MS-DOS with the Microsoft Compiler + + - MS-Windows with the Microsoft Compiler + + - NeXT + + - SunOS 3.x, Sun 386 (Road Runner) + + - Tandem (non-POSIX) + + - Prestandard VAX C compiler for VAX/VMS + + + + +File: gawk.info, Node: Common Extensions, Next: Ranges and Locales, Prev: POSIX/GNU, Up: Language History + +A.6 Common Extensions Summary +============================= + +This minor node summarizes the common extensions supported by `gawk', +Brian Kernighan's `awk', and `mawk', the three most widely-used freely +available versions of `awk' (*note Other Versions::). + +Feature BWK Awk Mawk GNU Awk +-------------------------------------------------------- +`\x' Escape sequence X X X +`RS' as regexp X X +`FS' as null string X X X +`/dev/stdin' special file X X +`/dev/stdout' special file X X X +`/dev/stderr' special file X X X +`**' and `**=' operators X X +`func' keyword X X +`nextfile' statement X X X +`delete' without subscript X X X +`length()' of an array X X +`fflush()' function X X X +`BINMODE' variable X X + + +File: gawk.info, Node: Ranges and Locales, Next: Contributors, Prev: Common Extensions, Up: Language History + +A.7 Regexp Ranges and Locales: A Long Sad Story +=============================================== + +This minor node describes the confusing history of ranges within +regular expressions and their interactions with locales, and how this +affected different versions of `gawk'. + + The original Unix tools that worked with regular expressions defined +character ranges (such as `[a-z]') to match any character between the +first character in the range and the last character in the range, +inclusive. Ordering was based on the numeric value of each character +in the machine's native character set. Thus, on ASCII-based systems, +`[a-z]' matched all the lowercase letters, and only the lowercase +letters, since the numeric values for the letters from `a' through `z' +were contiguous. (On an EBCDIC system, the range `[a-z]' includes +additional, non-alphabetic characters as well.) + + Almost all introductory Unix literature explained range expressions +as working in this fashion, and in particular, would teach that the +"correct" way to match lowercase letters was with `[a-z]', and that +`[A-Z]' was the "correct" way to match uppercase letters. And indeed, +this was true. + + The 1993 POSIX standard introduced the idea of locales (*note +Locales::). Since many locales include other letters besides the plain +twenty-six letters of the American English alphabet, the POSIX standard +added character classes (*note Bracket Expressions::) as a way to match +different kinds of characters besides the traditional ones in the ASCII +character set. + + However, the standard _changed_ the interpretation of range +expressions. In the `"C"' and `"POSIX"' locales, a range expression +like `[a-dx-z]' is still equivalent to `[abcdxyz]', as in ASCII. But +outside those locales, the ordering was defined to be based on +"collation order". + + In many locales, `A' and `a' are both less than `B'. In other +words, these locales sort characters in dictionary order, and +`[a-dx-z]' is typically not equivalent to `[abcdxyz]'; instead it might +be equivalent to `[aBbCcdXxYyz]', for example. + + This point needs to be emphasized: Much literature teaches that you +should use `[a-z]' to match a lowercase character. But on systems with +non-ASCII locales, this also matched all of the uppercase characters +except `Z'! This was a continuous cause of confusion, even well into +the twenty-first century. + + To demonstrate these issues, the following example uses the `sub()' +function, which does text replacement (*note String Functions::). Here, +the intent is to remove trailing uppercase characters: + + $ echo something1234abc | gawk-3.1.8 '{ sub("[A-Z]*$", ""); print }' + -| something1234a + +This output is unexpected, since the `bc' at the end of +`something1234abc' should not normally match `[A-Z]*'. This result is +due to the locale setting (and thus you may not see it on your system). + + Similar considerations apply to other ranges. For example, `["-/]' +is perfectly valid in ASCII, but is not valid in many Unicode locales, +such as `en_US.UTF-8'. + + Early versions of `gawk' used regexp matching code that was not +locale aware, so ranges had their traditional interpretation. + + When `gawk' switched to using locale-aware regexp matchers, the +problems began; especially as both GNU/Linux and commercial Unix +vendors started implementing non-ASCII locales, _and making them the +default_. Perhaps the most frequently asked question became something +like "why does `[A-Z]' match lowercase letters?!?" + + This situation existed for close to 10 years, if not more, and the +`gawk' maintainer grew weary of trying to explain that `gawk' was being +nicely standards-compliant, and that the issue was in the user's +locale. During the development of version 4.0, he modified `gawk' to +always treat ranges in the original, pre-POSIX fashion, unless +`--posix' was used (*note Options::). + + Fortunately, shortly before the final release of `gawk' 4.0, the +maintainer learned that the 2008 standard had changed the definition of +ranges, such that outside the `"C"' and `"POSIX"' locales, the meaning +of range expressions was _undefined_.(1) + + By using this lovely technical term, the standard gives license to +implementors to implement ranges in whatever way they choose. The +`gawk' maintainer chose to apply the pre-POSIX meaning in all cases: +the default regexp matching; with `--traditional', and with `--posix'; +in all cases, `gawk' remains POSIX compliant. + + ---------- Footnotes ---------- + + (1) See the standard +(http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03_05) +and its rationale +(http://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap09.html#tag_21_09_03_05). + + +File: gawk.info, Node: Contributors, Prev: Ranges and Locales, Up: Language History + +A.8 Major Contributors to `gawk' +================================ + + Always give credit where credit is due. + Anonymous + + This minor node names the major contributors to `gawk' and/or this +Info file, in approximate chronological order: + + * Dr. Alfred V. Aho, Dr. Peter J. Weinberger, and Dr. Brian W. + Kernighan, all of Bell Laboratories, designed and implemented Unix + `awk', from which `gawk' gets the majority of its feature set. + + * Paul Rubin did the initial design and implementation in 1986, and + wrote the first draft (around 40 pages) of this Info file. + + * Jay Fenlason finished the initial implementation. + + * Diane Close revised the first draft of this Info file, bringing it + to around 90 pages. + + * Richard Stallman helped finish the implementation and the initial + draft of this Info file. He is also the founder of the FSF and + the GNU project. + + * John Woods contributed parts of the code (mostly fixes) in the + initial version of `gawk'. + + * In 1988, David Trueman took over primary maintenance of `gawk', + making it compatible with "new" `awk', and greatly improving its + performance. + + * Conrad Kwok, Scott Garfinkle, and Kent Williams did the initial + ports to MS-DOS with various versions of MSC. + + * Pat Rankin provided the VMS port and its documentation. + + * Hal Peterson provided help in porting `gawk' to Cray systems. + (This is no longer supported.) + + * Kai Uwe Rommel provided the initial port to OS/2 and its + documentation. + + * Michal Jaegermann provided the port to Atari systems and its + documentation. (This port is no longer supported.) He continues + to provide portability checking with DEC Alpha systems, and has + done a lot of work to make sure `gawk' works on non-32-bit systems. + + * Fred Fish provided the port to Amiga systems and its documentation. + (With Fred's sad passing, this is no longer supported.) + + * Scott Deifik currently maintains the MS-DOS port using DJGPP. + + * Eli Zaretskii currently maintains the MS-Windows port using MinGW. + + * Juan Grigera provided a port to Windows32 systems. (This is no + longer supported.) + + * For many years, Dr. Darrel Hankerson acted as coordinator for the + various ports to different PC platforms and created binary + distributions for various PC operating systems. He was also + instrumental in keeping the documentation up to date for the + various PC platforms. + + * Christos Zoulas provided the `extension()' built-in function for + dynamically adding new modules. + + * Ju"rgen Kahrs contributed the initial version of the TCP/IP + networking code and documentation, and motivated the inclusion of + the `|&' operator. + + * Stephen Davies provided the initial port to Tandem systems and its + documentation. (However, this is no longer supported.) He was + also instrumental in the initial work to integrate the byte-code + internals into the `gawk' code base. + + * Matthew Woehlke provided improvements for Tandem's POSIX-compliant + systems. + + * Martin Brown provided the port to BeOS and its documentation. + (This is no longer supported.) + + * Arno Peters did the initial work to convert `gawk' to use GNU + Automake and GNU `gettext'. + + * Alan J. Broder provided the initial version of the `asort()' + function as well as the code for the optional third argument to the + `match()' function. + + * Andreas Buening updated the `gawk' port for OS/2. + + * Isamu Hasegawa, of IBM in Japan, contributed support for multibyte + characters. + + * Michael Benzinger contributed the initial code for `switch' + statements. + + * Patrick T.J. McPhee contributed the code for dynamic loading in + Windows32 environments. (This is no longer supported) + + * John Haque reworked the `gawk' internals to use a byte-code engine, + providing the `dgawk' debugger for `awk' programs. + + * Efraim Yawitz contributed the original text for *note Debugger::. + + * Arnold Robbins has been working on `gawk' since 1988, at first + helping David Trueman, and as the primary maintainer since around + 1994. + + +File: gawk.info, Node: Installation, Next: Notes, Prev: Language History, Up: Top + +Appendix B Installing `gawk' +**************************** + +This appendix provides instructions for installing `gawk' on the +various platforms that are supported by the developers. The primary +developer supports GNU/Linux (and Unix), whereas the other ports are +contributed. *Note Bugs::, for the electronic mail addresses of the +people who did the respective ports. + +* Menu: + +* Gawk Distribution:: What is in the `gawk' distribution. +* Unix Installation:: Installing `gawk' under various + versions of Unix. +* Non-Unix Installation:: Installation on Other Operating Systems. +* Bugs:: Reporting Problems and Bugs. +* Other Versions:: Other freely available `awk' + implementations. + + +File: gawk.info, Node: Gawk Distribution, Next: Unix Installation, Up: Installation + +B.1 The `gawk' Distribution +=========================== + +This minor node describes how to get the `gawk' distribution, how to +extract it, and then what is in the various files and subdirectories. + +* Menu: + +* Getting:: How to get the distribution. +* Extracting:: How to extract the distribution. +* Distribution contents:: What is in the distribution. + + +File: gawk.info, Node: Getting, Next: Extracting, Up: Gawk Distribution + +B.1.1 Getting the `gawk' Distribution +------------------------------------- + +There are three ways to get GNU software: + + * Copy it from someone else who already has it. + + * Retrieve `gawk' from the Internet host `ftp.gnu.org', in the + directory `/gnu/gawk'. Both anonymous `ftp' and `http' access are + supported. If you have the `wget' program, you can use a command + like the following: + + wget http://ftp.gnu.org/gnu/gawk/gawk-4.0.1.tar.gz + + The GNU software archive is mirrored around the world. The +up-to-date list of mirror sites is available from the main FSF web site +(http://www.gnu.org/order/ftp.html). Try to use one of the mirrors; +they will be less busy, and you can usually find one closer to your +site. + + +File: gawk.info, Node: Extracting, Next: Distribution contents, Prev: Getting, Up: Gawk Distribution + +B.1.2 Extracting the Distribution +--------------------------------- + +`gawk' is distributed as several `tar' files compressed with different +compression programs: `gzip', `bzip2', and `xz'. For simplicity, the +rest of these instructions assume you are using the one compressed with +the GNU Zip program, `gzip'. + + Once you have the distribution (for example, `gawk-4.0.1.tar.gz'), +use `gzip' to expand the file and then use `tar' to extract it. You +can use the following pipeline to produce the `gawk' distribution: + + # Under System V, add 'o' to the tar options + gzip -d -c gawk-4.0.1.tar.gz | tar -xvpf - + + On a system with GNU `tar', you can let `tar' do the decompression +for you: + + tar -xvpzf gawk-4.0.1.tar.gz + +Extracting the archive creates a directory named `gawk-4.0.1' in the +current directory. + + The distribution file name is of the form `gawk-V.R.P.tar.gz'. The +V represents the major version of `gawk', the R represents the current +release of version V, and the P represents a "patch level", meaning +that minor bugs have been fixed in the release. The current patch +level is 1, but when retrieving distributions, you should get the +version with the highest version, release, and patch level. (Note, +however, that patch levels greater than or equal to 70 denote "beta" or +nonproduction software; you might not want to retrieve such a version +unless you don't mind experimenting.) If you are not on a Unix or +GNU/Linux system, you need to make other arrangements for getting and +extracting the `gawk' distribution. You should consult a local expert. + + +File: gawk.info, Node: Distribution contents, Prev: Extracting, Up: Gawk Distribution + +B.1.3 Contents of the `gawk' Distribution +----------------------------------------- + +The `gawk' distribution has a number of C source files, documentation +files, subdirectories, and files related to the configuration process +(*note Unix Installation::), as well as several subdirectories related +to different non-Unix operating systems: + +Various `.c', `.y', and `.h' files + The actual `gawk' source code. + +`README' +`README_d/README.*' + Descriptive files: `README' for `gawk' under Unix and the rest for + the various hardware and software combinations. + +`INSTALL' + A file providing an overview of the configuration and installation + process. + +`ChangeLog' + A detailed list of source code changes as bugs are fixed or + improvements made. + +`ChangeLog.0' + An older list of source code changes. + +`NEWS' + A list of changes to `gawk' since the last release or patch. + +`NEWS.0' + An older list of changes to `gawk'. + +`COPYING' + The GNU General Public License. + +`FUTURES' + A brief list of features and changes being contemplated for future + releases, with some indication of the time frame for the feature, + based on its difficulty. + +`LIMITATIONS' + A list of those factors that limit `gawk''s performance. Most of + these depend on the hardware or operating system software and are + not limits in `gawk' itself. + +`POSIX.STD' + A description of behaviors in the POSIX standard for `awk' which + are left undefined, or where `gawk' may not comply fully, as well + as a list of things that the POSIX standard should describe but + does not. + +`doc/awkforai.txt' + A short article describing why `gawk' is a good language for + Artificial Intelligence (AI) programming. + +`doc/bc_notes' + A brief description of `gawk''s "byte code" internals. + +`doc/README.card' +`doc/ad.block' +`doc/awkcard.in' +`doc/cardfonts' +`doc/colors' +`doc/macros' +`doc/no.colors' +`doc/setter.outline' + The `troff' source for a five-color `awk' reference card. A + modern version of `troff' such as GNU `troff' (`groff') is needed + to produce the color version. See the file `README.card' for + instructions if you have an older `troff'. + +`doc/gawk.1' + The `troff' source for a manual page describing `gawk'. This is + distributed for the convenience of Unix users. + +`doc/gawk.texi' + The Texinfo source file for this Info file. It should be + processed with TeX (via `texi2dvi' or `texi2pdf') to produce a + printed document, and with `makeinfo' to produce an Info or HTML + file. + +`doc/gawk.info' + The generated Info file for this Info file. + +`doc/gawkinet.texi' + The Texinfo source file for *note (General Introduction)Top:: + gawkinet, TCP/IP Internetworking with `gawk'. It should be + processed with TeX (via `texi2dvi' or `texi2pdf') to produce a + printed document and with `makeinfo' to produce an Info or HTML + file. + +`doc/gawkinet.info' + The generated Info file for `TCP/IP Internetworking with `gawk''. + +`doc/igawk.1' + The `troff' source for a manual page describing the `igawk' + program presented in *note Igawk Program::. + +`doc/Makefile.in' + The input file used during the configuration process to generate + the actual `Makefile' for creating the documentation. + +`Makefile.am' +`*/Makefile.am' + Files used by the GNU `automake' software for generating the + `Makefile.in' files used by `autoconf' and `configure'. + +`Makefile.in' +`aclocal.m4' +`configh.in' +`configure.ac' +`configure' +`custom.h' +`missing_d/*' +`m4/*' + These files and subdirectories are used when configuring `gawk' + for various Unix systems. They are explained in *note Unix + Installation::. + +`po/*' + The `po' library contains message translations. + +`awklib/extract.awk' +`awklib/Makefile.am' +`awklib/Makefile.in' +`awklib/eg/*' + The `awklib' directory contains a copy of `extract.awk' (*note + Extract Program::), which can be used to extract the sample + programs from the Texinfo source file for this Info file. It also + contains a `Makefile.in' file, which `configure' uses to generate + a `Makefile'. `Makefile.am' is used by GNU Automake to create + `Makefile.in'. The library functions from *note Library + Functions::, and the `igawk' program from *note Igawk Program::, + are included as ready-to-use files in the `gawk' distribution. + They are installed as part of the installation process. The rest + of the programs in this Info file are available in appropriate + subdirectories of `awklib/eg'. + +`posix/*' + Files needed for building `gawk' on POSIX-compliant systems. + +`pc/*' + Files needed for building `gawk' under MS-Windows and OS/2 (*note + PC Installation::, for details). + +`vms/*' + Files needed for building `gawk' under VMS (*note VMS + Installation::, for details). + +`test/*' + A test suite for `gawk'. You can use `make check' from the + top-level `gawk' directory to run your version of `gawk' against + the test suite. If `gawk' successfully passes `make check', then + you can be confident of a successful port. + + +File: gawk.info, Node: Unix Installation, Next: Non-Unix Installation, Prev: Gawk Distribution, Up: Installation + +B.2 Compiling and Installing `gawk' on Unix-like Systems +======================================================== + +Usually, you can compile and install `gawk' by typing only two +commands. However, if you use an unusual system, you may need to +configure `gawk' for your system yourself. + +* Menu: + +* Quick Installation:: Compiling `gawk' under Unix. +* Additional Configuration Options:: Other compile-time options. +* Configuration Philosophy:: How it's all supposed to work. + + +File: gawk.info, Node: Quick Installation, Next: Additional Configuration Options, Up: Unix Installation + +B.2.1 Compiling `gawk' for Unix-like Systems +-------------------------------------------- + +The normal installation steps should work on all modern commercial +Unix-derived systems, GNU/Linux, BSD-based systems, and the Cygwin +environment for MS-Windows. + + After you have extracted the `gawk' distribution, `cd' to +`gawk-4.0.1'. Like most GNU software, `gawk' is configured +automatically for your system by running the `configure' program. This +program is a Bourne shell script that is generated automatically using +GNU `autoconf'. (The `autoconf' software is described fully starting +with *note (Autoconf)Top:: autoconf,Autoconf--Generating Automatic +Configuration Scripts.) + + To configure `gawk', simply run `configure': + + sh ./configure + + This produces a `Makefile' and `config.h' tailored to your system. +The `config.h' file describes various facts about your system. You +might want to edit the `Makefile' to change the `CFLAGS' variable, +which controls the command-line options that are passed to the C +compiler (such as optimization levels or compiling for debugging). + + Alternatively, you can add your own values for most `make' variables +on the command line, such as `CC' and `CFLAGS', when running +`configure': + + CC=cc CFLAGS=-g sh ./configure + +See the file `INSTALL' in the `gawk' distribution for all the details. + + After you have run `configure' and possibly edited the `Makefile', +type: + + make + +Shortly thereafter, you should have an executable version of `gawk'. +That's all there is to it! To verify that `gawk' is working properly, +run `make check'. All of the tests should succeed. If these steps do +not work, or if any of the tests fail, check the files in the +`README_d' directory to see if you've found a known problem. If the +failure is not described there, please send in a bug report (*note +Bugs::). + + +File: gawk.info, Node: Additional Configuration Options, Next: Configuration Philosophy, Prev: Quick Installation, Up: Unix Installation + +B.2.2 Additional Configuration Options +-------------------------------------- + +There are several additional options you may use on the `configure' +command line when compiling `gawk' from scratch, including: + +`--disable-lint' + Disable all lint checking within `gawk'. The `--lint' and + `--lint-old' options (*note Options::) are accepted, but silently + do nothing. Similarly, setting the `LINT' variable (*note + User-modified::) has no effect on the running `awk' program. + + When used with GCC's automatic dead-code-elimination, this option + cuts almost 200K bytes off the size of the `gawk' executable on + GNU/Linux x86 systems. Results on other systems and with other + compilers are likely to vary. Using this option may bring you + some slight performance improvement. + + Using this option will cause some of the tests in the test suite + to fail. This option may be removed at a later date. + +`--disable-nls' + Disable all message-translation facilities. This is usually not + desirable, but it may bring you some slight performance + improvement. + +`--with-whiny-user-strftime' + Force use of the included version of the `strftime()' function for + deficient systems. + + Use the command `./configure --help' to see the full list of options +that `configure' supplies. + + +File: gawk.info, Node: Configuration Philosophy, Prev: Additional Configuration Options, Up: Unix Installation + +B.2.3 The Configuration Process +------------------------------- + +This minor node is of interest only if you know something about using +the C language and Unix-like operating systems. + + The source code for `gawk' generally attempts to adhere to formal +standards wherever possible. This means that `gawk' uses library +routines that are specified by the ISO C standard and by the POSIX +operating system interface standard. The `gawk' source code requires +using an ISO C compiler (the 1990 standard). + + Many Unix systems do not support all of either the ISO or the POSIX +standards. The `missing_d' subdirectory in the `gawk' distribution +contains replacement versions of those functions that are most likely +to be missing. + + The `config.h' file that `configure' creates contains definitions +that describe features of the particular operating system where you are +attempting to compile `gawk'. The three things described by this file +are: what header files are available, so that they can be correctly +included, what (supposedly) standard functions are actually available +in your C libraries, and various miscellaneous facts about your +operating system. For example, there may not be an `st_blksize' +element in the `stat' structure. In this case, `HAVE_ST_BLKSIZE' is +undefined. + + It is possible for your C compiler to lie to `configure'. It may do +so by not exiting with an error when a library function is not +available. To get around this, edit the file `custom.h'. Use an +`#ifdef' that is appropriate for your system, and either `#define' any +constants that `configure' should have defined but didn't, or `#undef' +any constants that `configure' defined and should not have. `custom.h' +is automatically included by `config.h'. + + It is also possible that the `configure' program generated by +`autoconf' will not work on your system in some other fashion. If you +do have a problem, the file `configure.ac' is the input for `autoconf'. +You may be able to change this file and generate a new version of +`configure' that works on your system (*note Bugs::, for information on +how to report problems in configuring `gawk'). The same mechanism may +be used to send in updates to `configure.ac' and/or `custom.h'. + + +File: gawk.info, Node: Non-Unix Installation, Next: Bugs, Prev: Unix Installation, Up: Installation + +B.3 Installation on Other Operating Systems +=========================================== + +This minor node describes how to install `gawk' on various non-Unix +systems. + +* Menu: + +* PC Installation:: Installing and Compiling `gawk' on + MS-DOS and OS/2. +* VMS Installation:: Installing `gawk' on VMS. + + +File: gawk.info, Node: PC Installation, Next: VMS Installation, Up: Non-Unix Installation + +B.3.1 Installation on PC Operating Systems +------------------------------------------ + +This minor node covers installation and usage of `gawk' on x86 machines +running MS-DOS, any version of MS-Windows, or OS/2. In this minor +node, the term "Windows32" refers to any of Microsoft +Windows-95/98/ME/NT/2000/XP/Vista/7. + + The limitations of MS-DOS (and MS-DOS shells under Windows32 or +OS/2) has meant that various "DOS extenders" are often used with +programs such as `gawk'. The varying capabilities of Microsoft Windows +3.1 and Windows32 can add to the confusion. For an overview of the +considerations, please refer to `README_d/README.pc' in the +distribution. + +* Menu: + +* PC Binary Installation:: Installing a prepared distribution. +* PC Compiling:: Compiling `gawk' for MS-DOS, + Windows32, and OS/2. +* PC Testing:: Testing `gawk' on PC systems. +* PC Using:: Running `gawk' on MS-DOS, Windows32 + and OS/2. +* Cygwin:: Building and running `gawk' for + Cygwin. +* MSYS:: Using `gawk' In The MSYS Environment. + + +File: gawk.info, Node: PC Binary Installation, Next: PC Compiling, Up: PC Installation + +B.3.1.1 Installing a Prepared Distribution for PC Systems +......................................................... + +If you have received a binary distribution prepared by the MS-DOS +maintainers, then `gawk' and the necessary support files appear under +the `gnu' directory, with executables in `gnu/bin', libraries in +`gnu/lib/awk', and manual pages under `gnu/man'. This is designed for +easy installation to a `/gnu' directory on your drive--however, the +files can be installed anywhere provided `AWKPATH' is set properly. +Regardless of the installation directory, the first line of `igawk.cmd' +and `igawk.bat' (in `gnu/bin') may need to be edited. + + The binary distribution contains a separate file describing the +contents. In particular, it may include more than one version of the +`gawk' executable. + + OS/2 (32 bit, EMX) binary distributions are prepared for the `/usr' +directory of your preferred drive. Set `UNIXROOT' to your installation +drive (e.g., `e:') if you want to install `gawk' onto another drive +than the hardcoded default `c:'. Executables appear in `/usr/bin', +libraries under `/usr/share/awk', manual pages under `/usr/man', +Texinfo documentation under `/usr/info', and NLS files under +`/usr/share/locale'. Note that the files can be installed anywhere +provided `AWKPATH' is set properly. + + If you already have a file `/usr/info/dir' from another package _do +not overwrite it!_ Instead enter the following commands at your prompt +(replace `x:' by your installation drive): + + install-info --info-dir=x:/usr/info x:/usr/info/gawk.info + install-info --info-dir=x:/usr/info x:/usr/info/gawkinet.info + + The binary distribution may contain a separate file containing +additional or more detailed installation instructions. + + +File: gawk.info, Node: PC Compiling, Next: PC Testing, Prev: PC Binary Installation, Up: PC Installation + +B.3.1.2 Compiling `gawk' for PC Operating Systems +................................................. + +`gawk' can be compiled for MS-DOS, Windows32, and OS/2 using the GNU +development tools from DJ Delorie (DJGPP: MS-DOS only) or Eberhard +Mattes (EMX: MS-DOS, Windows32 and OS/2). The file +`README_d/README.pc' in the `gawk' distribution contains additional +notes, and `pc/Makefile' contains important information on compilation +options. + + To build `gawk' for MS-DOS and Windows32, copy the files in the `pc' +directory (_except_ for `ChangeLog') to the directory with the rest of +the `gawk' sources, then invoke `make' with the appropriate target name +as an argument to build `gawk'. The `Makefile' copied from the `pc' +directory contains a configuration section with comments and may need +to be edited in order to work with your `make' utility. + + The `Makefile' supports a number of targets for building various +MS-DOS and Windows32 versions. A list of targets is printed if the +`make' command is given without a target. As an example, to build +`gawk' using the DJGPP tools, enter `make djgpp'. (The DJGPP tools +needed for the build may be found at +`ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/'.) To build a native +MS-Windows binary of `gawk', type `make mingw32'. + + The 32 bit EMX version of `gawk' works "out of the box" under OS/2. +However, it is highly recommended to use GCC 2.95.3 for the compilation. +In principle, it is possible to compile `gawk' the following way: + + $ ./configure + $ make + + This is not recommended, though. To get an OMF executable you should +use the following commands at your `sh' prompt: + + $ CFLAGS="-O2 -Zomf -Zmt" + $ export CFLAGS + $ LDFLAGS="-s -Zcrtdll -Zlinker /exepack:2 -Zlinker /pm:vio -Zstack 0x6000" + $ export LDFLAGS + $ RANLIB="echo" + $ export RANLIB + $ ./configure --prefix=c:/usr + $ make AR=emxomfar + + These are just suggestions for use with GCC 2.x. You may use any +other set of (self-consistent) environment variables and compiler flags. + + If you use GCC 2.95 it is recommended to use also: + + $ LIBS="-lgcc" + $ export LIBS + + You can also get an `a.out' executable if you prefer: + + $ CFLAGS="-O2 -Zmt" + $ export CFLAGS + $ LDFLAGS="-s -Zstack 0x6000" + $ LIBS="-lgcc" + $ unset RANLIB + $ ./configure --prefix=c:/usr + $ make + + NOTE: Compilation of `a.out' executables also works with GCC 3.2. + Versions later than GCC 3.2 have not been tested successfully. + + `make install' works as expected with the EMX build. + + NOTE: Ancient OS/2 ports of GNU `make' are not able to handle the + Makefiles of this package. If you encounter any problems with + `make', try GNU Make 3.79.1 or later versions. You should find + the latest version on `ftp://hobbes.nmsu.edu/pub/os2/'. + + +File: gawk.info, Node: PC Testing, Next: PC Using, Prev: PC Compiling, Up: PC Installation + +B.3.1.3 Testing `gawk' on PC Operating Systems +.............................................. + +Using `make' to run the standard tests and to install `gawk' requires +additional Unix-like tools, including `sh', `sed', and `cp'. In order +to run the tests, the `test/*.ok' files may need to be converted so +that they have the usual MS-DOS-style end-of-line markers. +Alternatively, run `make check CMP="diff -a"' to use GNU `diff' in text +mode instead of `cmp' to compare the resulting files. + + Most of the tests work properly with Stewartson's shell along with +the companion utilities or appropriate GNU utilities. However, some +editing of `test/Makefile' is required. It is recommended that you copy +the file `pc/Makefile.tst' over the file `test/Makefile' as a +replacement. Details can be found in `README_d/README.pc' and in the +file `pc/Makefile.tst'. + + On OS/2 the `pid' test fails because `spawnl()' is used instead of +`fork()'/`execl()' to start child processes. Also the `mbfw1' and +`mbprintf1' tests fail because the needed multibyte functionality is +not available. + + +File: gawk.info, Node: PC Using, Next: Cygwin, Prev: PC Testing, Up: PC Installation + +B.3.1.4 Using `gawk' on PC Operating Systems +............................................ + +With the exception of the Cygwin environment, the `|&' operator and +TCP/IP networking (*note TCP/IP Networking::) are not supported for +MS-DOS or MS-Windows. EMX (OS/2 only) does support at least the `|&' +operator. + + The MS-DOS and MS-Windows versions of `gawk' search for program +files as described in *note AWKPATH Variable::. However, semicolons +(rather than colons) separate elements in the `AWKPATH' variable. If +`AWKPATH' is not set or is empty, then the default search path for +MS-Windows and MS-DOS versions is `".;c:/lib/awk;c:/gnu/lib/awk"'. + + The search path for OS/2 (32 bit, EMX) is determined by the prefix +directory (most likely `/usr' or `c:/usr') that has been specified as +an option of the `configure' script like it is the case for the Unix +versions. If `c:/usr' is the prefix directory then the default search +path contains `.' and `c:/usr/share/awk'. Additionally, to support +binary distributions of `gawk' for OS/2 systems whose drive `c:' might +not support long file names or might not exist at all, there is a +special environment variable. If `UNIXROOT' specifies a drive then +this specific drive is also searched for program files. E.g., if +`UNIXROOT' is set to `e:' the complete default search path is +`".;c:/usr/share/awk;e:/usr/share/awk"'. + + An `sh'-like shell (as opposed to `command.com' under MS-DOS or +`cmd.exe' under MS-Windows or OS/2) may be useful for `awk' programming. +The DJGPP collection of tools includes an MS-DOS port of Bash, and +several shells are available for OS/2, including `ksh'. + + Under MS-Windows, OS/2 and MS-DOS, `gawk' (and many other text +programs) silently translate end-of-line `"\r\n"' to `"\n"' on input +and `"\n"' to `"\r\n"' on output. A special `BINMODE' variable +(c.e.) allows control over these translations and is interpreted as +follows: + + * If `BINMODE' is `"r"', or one, then binary mode is set on read + (i.e., no translations on reads). + + * If `BINMODE' is `"w"', or two, then binary mode is set on write + (i.e., no translations on writes). + + * If `BINMODE' is `"rw"' or `"wr"' or three, binary mode is set for + both read and write. + + * `BINMODE=NON-NULL-STRING' is the same as `BINMODE=3' (i.e., no + translations on reads or writes). However, `gawk' issues a warning + message if the string is not one of `"rw"' or `"wr"'. + +The modes for standard input and standard output are set one time only +(after the command line is read, but before processing any of the `awk' +program). Setting `BINMODE' for standard input or standard output is +accomplished by using an appropriate `-v BINMODE=N' option on the +command line. `BINMODE' is set at the time a file or pipe is opened +and cannot be changed mid-stream. + + The name `BINMODE' was chosen to match `mawk' (*note Other +Versions::). `mawk' and `gawk' handle `BINMODE' similarly; however, +`mawk' adds a `-W BINMODE=N' option and an environment variable that +can set `BINMODE', `RS', and `ORS'. The files `binmode[1-3].awk' +(under `gnu/lib/awk' in some of the prepared distributions) have been +chosen to match `mawk''s `-W BINMODE=N' option. These can be changed +or discarded; in particular, the setting of `RS' giving the fewest +"surprises" is open to debate. `mawk' uses `RS = "\r\n"' if binary +mode is set on read, which is appropriate for files with the +MS-DOS-style end-of-line. + + To illustrate, the following examples set binary mode on writes for +standard output and other files, and set `ORS' as the "usual" +MS-DOS-style end-of-line: + + gawk -v BINMODE=2 -v ORS="\r\n" ... + +or: + + gawk -v BINMODE=w -f binmode2.awk ... + +These give the same result as the `-W BINMODE=2' option in `mawk'. The +following changes the record separator to `"\r\n"' and sets binary mode +on reads, but does not affect the mode on standard input: + + gawk -v RS="\r\n" --source "BEGIN { BINMODE = 1 }" ... + +or: + + gawk -f binmode1.awk ... + +With proper quoting, in the first example the setting of `RS' can be +moved into the `BEGIN' rule. + + +File: gawk.info, Node: Cygwin, Next: MSYS, Prev: PC Using, Up: PC Installation + +B.3.1.5 Using `gawk' In The Cygwin Environment +.............................................. + +`gawk' can be built and used "out of the box" under MS-Windows if you +are using the Cygwin environment (http://www.cygwin.com). This +environment provides an excellent simulation of Unix, using the GNU +tools, such as Bash, the GNU Compiler Collection (GCC), GNU Make, and +other GNU programs. Compilation and installation for Cygwin is the +same as for a Unix system: + + tar -xvpzf gawk-4.0.1.tar.gz + cd gawk-4.0.1 + ./configure + make + + When compared to GNU/Linux on the same system, the `configure' step +on Cygwin takes considerably longer. However, it does finish, and then +the `make' proceeds as usual. + + NOTE: The `|&' operator and TCP/IP networking (*note TCP/IP + Networking::) are fully supported in the Cygwin environment. This + is not true for any other environment on MS-Windows. + + +File: gawk.info, Node: MSYS, Prev: Cygwin, Up: PC Installation + +B.3.1.6 Using `gawk' In The MSYS Environment +............................................ + +In the MSYS environment under MS-Windows, `gawk' automatically uses +binary mode for reading and writing files. Thus there is no need to +use the `BINMODE' variable. + + This can cause problems with other Unix-like components that have +been ported to MS-Windows that expect `gawk' to do automatic +translation of `"\r\n"', since it won't. Caveat Emptor! + + +File: gawk.info, Node: VMS Installation, Prev: PC Installation, Up: Non-Unix Installation + +B.3.2 How to Compile and Install `gawk' on VMS +---------------------------------------------- + +This node describes how to compile and install `gawk' under VMS. The +older designation "VMS" is used throughout to refer to OpenVMS. + +* Menu: + +* VMS Compilation:: How to compile `gawk' under VMS. +* VMS Installation Details:: How to install `gawk' under VMS. +* VMS Running:: How to run `gawk' under VMS. +* VMS Old Gawk:: An old version comes with some VMS systems. + + +File: gawk.info, Node: VMS Compilation, Next: VMS Installation Details, Up: VMS Installation + +B.3.2.1 Compiling `gawk' on VMS +............................... + +To compile `gawk' under VMS, there is a `DCL' command procedure that +issues all the necessary `CC' and `LINK' commands. There is also a +`Makefile' for use with the `MMS' utility. From the source directory, +use either: + + $ @[.VMS]VMSBUILD.COM + +or: + + $ MMS/DESCRIPTION=[.VMS]DESCRIP.MMS GAWK + + Older versions of `gawk' could be built with VAX C or GNU C on +VAX/VMS, as well as with DEC C, but that is no longer supported. DEC C +(also briefly known as "Compaq C" and now known as "HP C," but referred +to here as "DEC C") is required. Both `VMSBUILD.COM' and `DESCRIP.MMS' +contain some obsolete support for the older compilers but are set up to +use DEC C by default. + + `gawk' has been tested under Alpha/VMS 7.3-1 using Compaq C V6.4, +and on Alpha/VMS 7.3, Alpha/VMS 7.3-2, and IA64/VMS 8.3.(1) + + ---------- Footnotes ---------- + + (1) The IA64 architecture is also known as "Itanium." + + +File: gawk.info, Node: VMS Installation Details, Next: VMS Running, Prev: VMS Compilation, Up: VMS Installation + +B.3.2.2 Installing `gawk' on VMS +................................ + +To install `gawk', all you need is a "foreign" command, which is a +`DCL' symbol whose value begins with a dollar sign. For example: + + $ GAWK :== $disk1:[gnubin]GAWK + +Substitute the actual location of `gawk.exe' for `$disk1:[gnubin]'. The +symbol should be placed in the `login.com' of any user who wants to run +`gawk', so that it is defined every time the user logs on. +Alternatively, the symbol may be placed in the system-wide +`sylogin.com' procedure, which allows all users to run `gawk'. + + Optionally, the help entry can be loaded into a VMS help library: + + $ LIBRARY/HELP SYS$HELP:HELPLIB [.VMS]GAWK.HLP + +(You may want to substitute a site-specific help library rather than +the standard VMS library `HELPLIB'.) After loading the help text, the +command: + + $ HELP GAWK + +provides information about both the `gawk' implementation and the `awk' +programming language. + + The logical name `AWK_LIBRARY' can designate a default location for +`awk' program files. For the `-f' option, if the specified file name +has no device or directory path information in it, `gawk' looks in the +current directory first, then in the directory specified by the +translation of `AWK_LIBRARY' if the file is not found. If, after +searching in both directories, the file still is not found, `gawk' +appends the suffix `.awk' to the filename and retries the file search. +If `AWK_LIBRARY' has no definition, a default value of `SYS$LIBRARY:' +is used for it. + + +File: gawk.info, Node: VMS Running, Next: VMS Old Gawk, Prev: VMS Installation Details, Up: VMS Installation + +B.3.2.3 Running `gawk' on VMS +............................. + +Command-line parsing and quoting conventions are significantly different +on VMS, so examples in this Info file or from other sources often need +minor changes. They _are_ minor though, and all `awk' programs should +run correctly. + + Here are a couple of trivial tests: + + $ gawk -- "BEGIN {print ""Hello, World!""}" + $ gawk -"W" version + ! could also be -"W version" or "-W version" + +Note that uppercase and mixed-case text must be quoted. + + The VMS port of `gawk' includes a `DCL'-style interface in addition +to the original shell-style interface (see the help entry for details). +One side effect of dual command-line parsing is that if there is only a +single parameter (as in the quoted string program above), the command +becomes ambiguous. To work around this, the normally optional `--' +flag is required to force Unix-style parsing rather than `DCL' parsing. +If any other dash-type options (or multiple parameters such as data +files to process) are present, there is no ambiguity and `--' can be +omitted. + + The default search path, when looking for `awk' program files +specified by the `-f' option, is `"SYS$DISK:[],AWK_LIBRARY:"'. The +logical name `AWKPATH' can be used to override this default. The format +of `AWKPATH' is a comma-separated list of directory specifications. +When defining it, the value should be quoted so that it retains a single +translation and not a multitranslation `RMS' searchlist. + + +File: gawk.info, Node: VMS Old Gawk, Prev: VMS Running, Up: VMS Installation + +B.3.2.4 Some VMS Systems Have An Old Version of `gawk' +...................................................... + +Some versions of VMS have an old version of `gawk'. To access it, +define a symbol, as follows: + + $ gawk :== $sys$common:[syshlp.examples.tcpip.snmp]gawk.exe + + This is apparently version 2.15.6, which is extremely old. We +recommend compiling and using the current version. + + +File: gawk.info, Node: Bugs, Next: Other Versions, Prev: Non-Unix Installation, Up: Installation + +B.4 Reporting Problems and Bugs +=============================== + + There is nothing more dangerous than a bored archeologist. + The Hitchhiker's Guide to the Galaxy + + If you have problems with `gawk' or think that you have found a bug, +please report it to the developers; we cannot promise to do anything +but we might well want to fix it. + + Before reporting a bug, make sure you have actually found a real bug. +Carefully reread the documentation and see if it really says you can do +what you're trying to do. If it's not clear whether you should be able +to do something or not, report that too; it's a bug in the +documentation! + + Before reporting a bug or trying to fix it yourself, try to isolate +it to the smallest possible `awk' program and input data file that +reproduces the problem. Then send us the program and data file, some +idea of what kind of Unix system you're using, the compiler you used to +compile `gawk', and the exact results `gawk' gave you. Also say what +you expected to occur; this helps us decide whether the problem is +really in the documentation. + + Please include the version number of `gawk' you are using. You can +get this information with the command `gawk --version'. + + Once you have a precise problem, send email to . + + Using this address automatically sends a copy of your mail to me. +If necessary, I can be reached directly at . The +bug reporting address is preferred since the email list is archived at +the GNU Project. _All email should be in English, since that is my +native language._ + + CAUTION: Do _not_ try to report bugs in `gawk' by posting to the + Usenet/Internet newsgroup `comp.lang.awk'. While the `gawk' + developers do occasionally read this newsgroup, there is no + guarantee that we will see your posting. The steps described + above are the official recognized ways for reporting bugs. Really. + + NOTE: Many distributions of GNU/Linux and the various BSD-based + operating systems have their own bug reporting systems. If you + report a bug using your distribution's bug reporting system, + _please_ also send a copy to . + + This is for two reasons. First, while some distributions forward + bug reports "upstream" to the GNU mailing list, many don't, so + there is a good chance that the `gawk' maintainer won't even see + the bug report! Second, mail to the GNU list is archived, and + having everything at the GNU project keeps things self-contained + and not dependant on other web sites. + + Non-bug suggestions are always welcome as well. If you have +questions about things that are unclear in the documentation or are +just obscure features, ask me; I will try to help you out, although I +may not have the time to fix the problem. You can send me electronic +mail at the Internet address noted previously. + + If you find bugs in one of the non-Unix ports of `gawk', please send +an electronic mail message to the person who maintains that port. They +are named in the following list, as well as in the `README' file in the +`gawk' distribution. Information in the `README' file should be +considered authoritative if it conflicts with this Info file. + + The people maintaining the non-Unix ports of `gawk' are as follows: + +MS-DOS with DJGPP Scott Deifik, . +MS-Windows with MINGW Eli Zaretskii, . +OS/2 Andreas Buening, . +VMS Pat Rankin, +z/OS (OS/390) Dave Pitts, . + + If your bug is also reproducible under Unix, please send a copy of +your report to the email list as well. + + +File: gawk.info, Node: Other Versions, Prev: Bugs, Up: Installation + +B.5 Other Freely Available `awk' Implementations +================================================ + + It's kind of fun to put comments like this in your awk code. + `// Do C++ comments work? answer: yes! of course' + Michael Brennan + + There are a number of other freely available `awk' implementations. +This minor node briefly describes where to get them: + +Unix `awk' + Brian Kernighan, one of the original designers of Unix `awk', has + made his implementation of `awk' freely available. You can + retrieve this version via the World Wide Web from his home page + (http://www.cs.princeton.edu/~bwk). It is available in several + archive formats: + + Shell archive + `http://www.cs.princeton.edu/~bwk/btl.mirror/awk.shar' + + Compressed `tar' file + `http://www.cs.princeton.edu/~bwk/btl.mirror/awk.tar.gz' + + Zip file + `http://www.cs.princeton.edu/~bwk/btl.mirror/awk.zip' + + This version requires an ISO C (1990 standard) compiler; the C + compiler from GCC (the GNU Compiler Collection) works quite nicely. + + *Note Common Extensions::, for a list of extensions in this `awk' + that are not in POSIX `awk'. + +`mawk' + Michael Brennan wrote an independent implementation of `awk', + called `mawk'. It is available under the GPL (*note Copying::), + just as `gawk' is. + + The original distribution site for the `mawk' source code no + longer has it. A copy is available at + `http://www.skeeve.com/gawk/mawk1.3.3.tar.gz'. + + In 2009, Thomas Dickey took on `mawk' maintenance. Basic + information is available on the project's web page + (http://www.invisible-island.net/mawk/mawk.html). The download + URL is `http://invisible-island.net/datafiles/release/mawk.tar.gz'. + + Once you have it, `gunzip' may be used to decompress this file. + Installation is similar to `gawk''s (*note Unix Installation::). + + *Note Common Extensions::, for a list of extensions in `mawk' that + are not in POSIX `awk'. + +`awka' + Written by Andrew Sumner, `awka' translates `awk' programs into C, + compiles them, and links them with a library of functions that + provides the core `awk' functionality. It also has a number of + extensions. + + The `awk' translator is released under the GPL, and the library is + under the LGPL. + + To get `awka', go to `http://sourceforge.net/projects/awka'. + + The project seems to be frozen; no new code changes have been made + since approximately 2003. + +`pawk' + Nelson H.F. Beebe at the University of Utah has modified Brian + Kernighan's `awk' to provide timing and profiling information. It + is different from `pgawk' (*note Profiling::), in that it uses + CPU-based profiling, not line-count profiling. You may find it at + either `ftp://ftp.math.utah.edu/pub/pawk/pawk-20030606.tar.gz' or + `http://www.math.utah.edu/pub/pawk/pawk-20030606.tar.gz'. + +Busybox Awk + Busybox is a GPL-licensed program providing small versions of many + applications within a single executable. It is aimed at embedded + systems. It includes a full implementation of POSIX `awk'. When + building it, be careful not to do `make install' as it will + overwrite copies of other applications in your `/usr/local/bin'. + For more information, see the project's home page + (http://busybox.net). + +The OpenSolaris POSIX `awk' + The version of `awk' in `/usr/xpg4/bin' on Solaris is more-or-less + POSIX-compliant. It is based on the `awk' from Mortice Kern + Systems for PCs. The source code can be downloaded from the + OpenSolaris web site (http://www.opensolaris.org). This author + was able to make it compile and work under GNU/Linux with 1-2 + hours of work. Making it more generally portable (using GNU + Autoconf and/or Automake) would take more work, and this has not + been done, at least to our knowledge. + +`jawk' + This is an interpreter for `awk' written in Java. It claims to be + a full interpreter, although because it uses Java facilities for + I/O and for regexp matching, the language it supports is different + from POSIX `awk'. More information is available on the project's + home page (http://jawk.sourceforge.net). + +Libmawk + This is an embeddable `awk' interpreter derived from `mawk'. For + more information see `http://repo.hu/projects/libmawk/'. + +QSE Awk + This is an embeddable `awk' interpreter. For more information see + `http://code.google.com/p/qse/' and `http://awk.info/?tools/qse'. + +`QTawk' + This is an independent implementation of `awk' distributed under + the GPL. It has a large number of extensions over standard `awk' + and may not be 100% syntactically compatible with it. See + `http://www.quiktrim.org/QTawk.html' for more information, + including the manual and a download link. + +`xgawk' + XML `gawk'. This is a fork of the `gawk' 3.1.6 source base to + support processing XML files. It has a number of interesting + extensions which should one day be integrated into the main `gawk' + code base. For more information, see the XMLgawk project web site + (http://xmlgawk.sourceforge.net). + + + +File: gawk.info, Node: Notes, Next: Basic Concepts, Prev: Installation, Up: Top + +Appendix C Implementation Notes +******************************* + +This appendix contains information mainly of interest to implementers +and maintainers of `gawk'. Everything in it applies specifically to +`gawk' and not to other implementations. + +* Menu: + +* Compatibility Mode:: How to disable certain `gawk' + extensions. +* Additions:: Making Additions To `gawk'. +* Dynamic Extensions:: Adding new built-in functions to + `gawk'. +* Future Extensions:: New features that may be implemented one day. + + +File: gawk.info, Node: Compatibility Mode, Next: Additions, Up: Notes + +C.1 Downward Compatibility and Debugging +======================================== + +*Note POSIX/GNU::, for a summary of the GNU extensions to the `awk' +language and program. All of these features can be turned off by +invoking `gawk' with the `--traditional' option or with the `--posix' +option. + + If `gawk' is compiled for debugging with `-DDEBUG', then there is +one more option available on the command line: + +`-Y' +`--parsedebug' + Prints out the parse stack information as the program is being + parsed. + + This option is intended only for serious `gawk' developers and not +for the casual user. It probably has not even been compiled into your +version of `gawk', since it slows down execution. + + +File: gawk.info, Node: Additions, Next: Dynamic Extensions, Prev: Compatibility Mode, Up: Notes + +C.2 Making Additions to `gawk' +============================== + +If you find that you want to enhance `gawk' in a significant fashion, +you are perfectly free to do so. That is the point of having free +software; the source code is available and you are free to change it as +you want (*note Copying::). + + This minor node discusses the ways you might want to change `gawk' +as well as any considerations you should bear in mind. + +* Menu: + +* Accessing The Source:: Accessing the Git repository. +* Adding Code:: Adding code to the main body of + `gawk'. +* New Ports:: Porting `gawk' to a new operating + system. + + +File: gawk.info, Node: Accessing The Source, Next: Adding Code, Up: Additions + +C.2.1 Accessing The `gawk' Git Repository +----------------------------------------- + +As `gawk' is Free Software, the source code is always available. *note +Gawk Distribution::, describes how to get and build the formal, +released versions of `gawk'. + + However, if you want to modify `gawk' and contribute back your +changes, you will probably wish to work with the development version. +To do so, you will need to access the `gawk' source code repository. +The code is maintained using the Git distributed version control system +(http://git-scm.com/). You will need to install it if your system +doesn't have it. Once you have done so, use the command: + + git clone git://git.savannah.gnu.org/gawk.git + +This will clone the `gawk' repository. If you are behind a firewall +that will not allow you to use the Git native protocol, you can still +access the repository using: + + git clone http://git.savannah.gnu.org/r/gawk.git + + Once you have made changes, you can use `git diff' to produce a +patch, and send that to the `gawk' maintainer; see *note Bugs:: for how +to do that. + + Finally, if you cannot install Git (e.g., if it hasn't been ported +yet to your operating system), you can use the Git-CVS gateway to check +out a copy using CVS, as follows: + + cvs -d:pserver:anonymous@pserver.git.sv.gnu.org:/gawk.git co -d gawk master + + +File: gawk.info, Node: Adding Code, Next: New Ports, Prev: Accessing The Source, Up: Additions + +C.2.2 Adding New Features +------------------------- + +You are free to add any new features you like to `gawk'. However, if +you want your changes to be incorporated into the `gawk' distribution, +there are several steps that you need to take in order to make it +possible to include your changes: + + 1. Before building the new feature into `gawk' itself, consider + writing it as an extension module (*note Dynamic Extensions::). + If that's not possible, continue with the rest of the steps in + this list. + + 2. Be prepared to sign the appropriate paperwork. In order for the + FSF to distribute your changes, you must either place those + changes in the public domain and submit a signed statement to that + effect, or assign the copyright in your changes to the FSF. Both + of these actions are easy to do and _many_ people have done so + already. If you have questions, please contact me (*note Bugs::), + or . + + 3. Get the latest version. It is much easier for me to integrate + changes if they are relative to the most recent distributed + version of `gawk'. If your version of `gawk' is very old, I may + not be able to integrate them at all. (*Note Getting::, for + information on getting the latest version of `gawk'.) + + 4. See *note (Version)Top:: standards, GNU Coding Standards. This + document describes how GNU software should be written. If you + haven't read it, please do so, preferably _before_ starting to + modify `gawk'. (The `GNU Coding Standards' are available from the + GNU Project's web site + (http://www.gnu.org/prep/standards_toc.html). Texinfo, Info, and + DVI versions are also available.) + + 5. Use the `gawk' coding style. The C code for `gawk' follows the + instructions in the `GNU Coding Standards', with minor exceptions. + The code is formatted using the traditional "K&R" style, + particularly as regards to the placement of braces and the use of + TABs. In brief, the coding rules for `gawk' are as follows: + + * Use ANSI/ISO style (prototype) function headers when defining + functions. + + * Put the name of the function at the beginning of its own line. + + * Put the return type of the function, even if it is `int', on + the line above the line with the name and arguments of the + function. + + * Put spaces around parentheses used in control structures + (`if', `while', `for', `do', `switch', and `return'). + + * Do not put spaces in front of parentheses used in function + calls. + + * Put spaces around all C operators and after commas in + function calls. + + * Do not use the comma operator to produce multiple side + effects, except in `for' loop initialization and increment + parts, and in macro bodies. + + * Use real TABs for indenting, not spaces. + + * Use the "K&R" brace layout style. + + * Use comparisons against `NULL' and `'\0'' in the conditions of + `if', `while', and `for' statements, as well as in the `case's + of `switch' statements, instead of just the plain pointer or + character value. + + * Use the `TRUE', `FALSE' and `NULL' symbolic constants and the + character constant `'\0'' where appropriate, instead of `1' + and `0'. + + * Provide one-line descriptive comments for each function. + + * Do not use the `alloca()' function for allocating memory off + the stack. Its use causes more portability trouble than is + worth the minor benefit of not having to free the storage. + Instead, use `malloc()' and `free()'. + + * Do not use comparisons of the form `! strcmp(a, b)' or + similar. As Henry Spencer once said, "`strcmp()' is not a + boolean!" Instead, use `strcmp(a, b) == 0'. + + * If adding new bit flag values, use explicit hexadecimal + constants (`0x001', `0x002', `0x004', and son on) instead of + shifting one left by successive amounts (`(1<<0)', `(1<<1)', + and so on). + + NOTE: If I have to reformat your code to follow the coding + style used in `gawk', I may not bother to integrate your + changes at all. + + 6. Update the documentation. Along with your new code, please supply + new sections and/or chapters for this Info file. If at all + possible, please use real Texinfo, instead of just supplying + unformatted ASCII text (although even that is better than no + documentation at all). Conventions to be followed in `GAWK: + Effective AWK Programming' are provided after the `@bye' at the + end of the Texinfo source file. If possible, please update the + `man' page as well. + + You will also have to sign paperwork for your documentation + changes. + + 7. Submit changes as unified diffs. Use `diff -u -r -N' to compare + the original `gawk' source tree with your version. I recommend + using the GNU version of `diff'. Send the output produced by + either run of `diff' to me when you submit your changes. (*Note + Bugs::, for the electronic mail information.) + + Using this format makes it easy for me to apply your changes to the + master version of the `gawk' source code (using `patch'). If I + have to apply the changes manually, using a text editor, I may not + do so, particularly if there are lots of changes. + + 8. Include an entry for the `ChangeLog' file with your submission. + This helps further minimize the amount of work I have to do, + making it easier for me to accept patches. + + Although this sounds like a lot of work, please remember that while +you may write the new code, I have to maintain it and support it. If it +isn't possible for me to do that with a minimum of extra work, then I +probably will not. + + +File: gawk.info, Node: New Ports, Prev: Adding Code, Up: Additions + +C.2.3 Porting `gawk' to a New Operating System +---------------------------------------------- + +If you want to port `gawk' to a new operating system, there are several +steps: + + 1. Follow the guidelines in *note Adding Code::, concerning coding + style, submission of diffs, and so on. + + 2. Be prepared to sign the appropriate paperwork. In order for the + FSF to distribute your code, you must either place your code in + the public domain and submit a signed statement to that effect, or + assign the copyright in your code to the FSF. Both of these + actions are easy to do and _many_ people have done so already. If + you have questions, please contact me, or . + + 3. When doing a port, bear in mind that your code must coexist + peacefully with the rest of `gawk' and the other ports. Avoid + gratuitous changes to the system-independent parts of the code. If + at all possible, avoid sprinkling `#ifdef's just for your port + throughout the code. + + If the changes needed for a particular system affect too much of + the code, I probably will not accept them. In such a case, you + can, of course, distribute your changes on your own, as long as + you comply with the GPL (*note Copying::). + + 4. A number of the files that come with `gawk' are maintained by other + people. Thus, you should not change them unless it is for a very + good reason; i.e., changes are not out of the question, but + changes to these files are scrutinized extra carefully. The files + are `dfa.c', `dfa.h', `getopt1.c', `getopt.c', `getopt.h', + `install-sh', `mkinstalldirs', `regcomp.c', `regex.c', + `regexec.c', `regexex.c', `regex.h', `regex_internal.c', and + `regex_internal.h'. + + 5. Be willing to continue to maintain the port. Non-Unix operating + systems are supported by volunteers who maintain the code needed + to compile and run `gawk' on their systems. If noone volunteers to + maintain a port, it becomes unsupported and it may be necessary to + remove it from the distribution. + + 6. Supply an appropriate `gawkmisc.???' file. Each port has its own + `gawkmisc.???' that implements certain operating system specific + functions. This is cleaner than a plethora of `#ifdef's scattered + throughout the code. The `gawkmisc.c' in the main source + directory includes the appropriate `gawkmisc.???' file from each + subdirectory. Be sure to update it as well. + + Each port's `gawkmisc.???' file has a suffix reminiscent of the + machine or operating system for the port--for example, + `pc/gawkmisc.pc' and `vms/gawkmisc.vms'. The use of separate + suffixes, instead of plain `gawkmisc.c', makes it possible to move + files from a port's subdirectory into the main subdirectory, + without accidentally destroying the real `gawkmisc.c' file. + (Currently, this is only an issue for the PC operating system + ports.) + + 7. Supply a `Makefile' as well as any other C source and header files + that are necessary for your operating system. All your code + should be in a separate subdirectory, with a name that is the same + as, or reminiscent of, either your operating system or the + computer system. If possible, try to structure things so that it + is not necessary to move files out of the subdirectory into the + main source directory. If that is not possible, then be sure to + avoid using names for your files that duplicate the names of files + in the main source directory. + + 8. Update the documentation. Please write a section (or sections) + for this Info file describing the installation and compilation + steps needed to compile and/or install `gawk' for your system. + + Following these steps makes it much easier to integrate your changes +into `gawk' and have them coexist happily with other operating systems' +code that is already there. + + In the code that you supply and maintain, feel free to use a coding +style and brace layout that suits your taste. + + +File: gawk.info, Node: Dynamic Extensions, Next: Future Extensions, Prev: Additions, Up: Notes + +C.3 Adding New Built-in Functions to `gawk' +=========================================== + + Danger Will Robinson! Danger!! + Warning! Warning! + The Robot + + It is possible to add new built-in functions to `gawk' using +dynamically loaded libraries. This facility is available on systems +(such as GNU/Linux) that support the C `dlopen()' and `dlsym()' +functions. This minor node describes how to write and use dynamically +loaded extensions for `gawk'. Experience with programming in C or C++ +is necessary when reading this minor node. + + CAUTION: The facilities described in this minor node are very much + subject to change in a future `gawk' release. Be aware that you + may have to re-do everything, at some future time. + + If you have written your own dynamic extensions, be sure to + recompile them for each new `gawk' release. There is no guarantee + of binary compatibility between different releases, nor will there + ever be such a guarantee. + + NOTE: When `--sandbox' is specified, extensions are disabled + (*note Options::. + +* Menu: + +* Internals:: A brief look at some `gawk' internals. +* Plugin License:: A note about licensing. +* Sample Library:: A example of new functions. + + +File: gawk.info, Node: Internals, Next: Plugin License, Up: Dynamic Extensions + +C.3.1 A Minimal Introduction to `gawk' Internals +------------------------------------------------ + +The truth is that `gawk' was not designed for simple extensibility. +The facilities for adding functions using shared libraries work, but +are something of a "bag on the side." Thus, this tour is brief and +simplistic; would-be `gawk' hackers are encouraged to spend some time +reading the source code before trying to write extensions based on the +material presented here. Of particular note are the files `awk.h', +`builtin.c', and `eval.c'. Reading `awkgram.y' in order to see how the +parse tree is built would also be of use. + + With the disclaimers out of the way, the following types, structure +members, functions, and macros are declared in `awk.h' and are of use +when writing extensions. The next minor node shows how they are used: + +`AWKNUM' + An `AWKNUM' is the internal type of `awk' floating-point numbers. + Typically, it is a C `double'. + +`NODE' + Just about everything is done using objects of type `NODE'. These + contain both strings and numbers, as well as variables and arrays. + +`AWKNUM force_number(NODE *n)' + This macro forces a value to be numeric. It returns the actual + numeric value contained in the node. It may end up calling an + internal `gawk' function. + +`void force_string(NODE *n)' + This macro guarantees that a `NODE''s string value is current. It + may end up calling an internal `gawk' function. It also + guarantees that the string is zero-terminated. + +`void force_wstring(NODE *n)' + Similarly, this macro guarantees that a `NODE''s wide-string value + is current. It may end up calling an internal `gawk' function. + It also guarantees that the wide string is zero-terminated. + +`size_t get_curfunc_arg_count(void)' + This function returns the actual number of parameters passed to + the current function. Inside the code of an extension this can be + used to determine the maximum index which is safe to use with + `get_actual_argument'. If this value is greater than `nargs', the + function was called incorrectly from the `awk' program. + +`nargs' + Inside an extension function, this is the maximum number of + expected parameters, as set by the `make_builtin()' function. + +`n->stptr' +`n->stlen' + The data and length of a `NODE''s string value, respectively. The + string is _not_ guaranteed to be zero-terminated. If you need to + pass the string value to a C library function, save the value in + `n->stptr[n->stlen]', assign `'\0'' to it, call the routine, and + then restore the value. + +`n->wstptr' +`n->wstlen' + The data and length of a `NODE''s wide-string value, respectively. + Use `force_wstring()' to make sure these values are current. + +`n->type' + The type of the `NODE'. This is a C `enum'. Values should be one + of `Node_var', `Node_var_new', or `Node_var_array' for function + parameters. + +`n->vname' + The "variable name" of a node. This is not of much use inside + externally written extensions. + +`void assoc_clear(NODE *n)' + Clears the associative array pointed to by `n'. Make sure that + `n->type == Node_var_array' first. + +`NODE **assoc_lookup(NODE *symbol, NODE *subs, int reference)' + Finds, and installs if necessary, array elements. `symbol' is the + array, `subs' is the subscript. This is usually a value created + with `make_string()' (see below). `reference' should be `TRUE' if + it is an error to use the value before it is created. Typically, + `FALSE' is the correct value to use from extension functions. + +`NODE *make_string(char *s, size_t len)' + Take a C string and turn it into a pointer to a `NODE' that can be + stored appropriately. This is permanent storage; understanding of + `gawk' memory management is helpful. + +`NODE *make_number(AWKNUM val)' + Take an `AWKNUM' and turn it into a pointer to a `NODE' that can + be stored appropriately. This is permanent storage; understanding + of `gawk' memory management is helpful. + +`NODE *dupnode(NODE *n)' + Duplicate a node. In most cases, this increments an internal + reference count instead of actually duplicating the entire `NODE'; + understanding of `gawk' memory management is helpful. + +`void unref(NODE *n)' + This macro releases the memory associated with a `NODE' allocated + with `make_string()' or `make_number()'. Understanding of `gawk' + memory management is helpful. + +`void make_builtin(const char *name, NODE *(*func)(NODE *), int count)' + Register a C function pointed to by `func' as new built-in + function `name'. `name' is a regular C string. `count' is the + maximum number of arguments that the function takes. The function + should be written in the following manner: + + /* do_xxx --- do xxx function for gawk */ + + NODE * + do_xxx(int nargs) + { + ... + } + +`NODE *get_argument(int i)' + This function is called from within a C extension function to get + the `i'-th argument from the function call. The first argument is + argument zero. + +`NODE *get_actual_argument(int i,' +` int optional, int wantarray);' + This function retrieves a particular argument `i'. `wantarray' is + `TRUE' if the argument should be an array, `FALSE' otherwise. If + `optional' is `TRUE', the argument need not have been supplied. + If it wasn't, the return value is `NULL'. It is a fatal error if + `optional' is `TRUE' but the argument was not provided. + +`get_scalar_argument(i, opt)' + This is a convenience macro that calls `get_actual_argument()'. + +`get_array_argument(i, opt)' + This is a convenience macro that calls `get_actual_argument()'. + +`void update_ERRNO(void)' + This function is called from within a C extension function to set + the value of `gawk''s `ERRNO' variable, based on the current value + of the C `errno' global variable. It is provided as a convenience. + +`void update_ERRNO_saved(int errno_saved)' + This function is called from within a C extension function to set + the value of `gawk''s `ERRNO' variable, based on the error value + provided as the argument. It is provided as a convenience. + +`void register_deferred_variable(const char *name, NODE *(*load_func)(void))' + This function is called to register a function to be called when a + reference to an undefined variable with the given name is + encountered. The callback function will never be called if the + variable exists already, so, unless the calling code is running at + program startup, it should first check whether a variable of the + given name already exists. The argument function must return a + pointer to a `NODE' containing the newly created variable. This + function is used to implement the builtin `ENVIRON' and `PROCINFO' + arrays, so you can refer to them for examples. + +`void register_open_hook(void *(*open_func)(IOBUF *))' + This function is called to register a function to be called + whenever a new data file is opened, leading to the creation of an + `IOBUF' structure in `iop_alloc()'. After creating the new + `IOBUF', `iop_alloc()' will call (in reverse order of + registration, so the last function registered is called first) + each open hook until one returns non-`NULL'. If any hook returns + a non-`NULL' value, that value is assigned to the `IOBUF''s + `opaque' field (which will presumably point to a structure + containing additional state associated with the input processing), + and no further open hooks are called. + + The function called will most likely want to set the `IOBUF''s + `get_record' method to indicate that future input records should + be retrieved by calling that method instead of using the standard + `gawk' input processing. + + And the function will also probably want to set the `IOBUF''s + `close_func' method to be called when the file is closed to clean + up any state associated with the input. + + Finally, hook functions should be prepared to receive an `IOBUF' + structure where the `fd' field is set to `INVALID_HANDLE', meaning + that `gawk' was not able to open the file itself. In this case, + the hook function must be able to successfully open the file and + place a valid file descriptor there. + + Currently, for example, the hook function facility is used to + implement the XML parser shared library extension. For more info, + please look in `awk.h' and in `io.c'. + + An argument that is supposed to be an array needs to be handled with +some extra code, in case the array being passed in is actually from a +function parameter. + + The following boilerplate code shows how to do this: + + NODE *the_arg; + + /* assume need 3rd arg, 0-based */ + the_arg = get_array_argument(2, FALSE); + + Again, you should spend time studying the `gawk' internals; don't +just blindly copy this code. + + +File: gawk.info, Node: Plugin License, Next: Sample Library, Prev: Internals, Up: Dynamic Extensions + +C.3.2 Extension Licensing +------------------------- + +Every dynamic extension should define the global symbol +`plugin_is_GPL_compatible' to assert that it has been licensed under a +GPL-compatible license. If this symbol does not exist, `gawk' will +emit a fatal error and exit. + + The declared type of the symbol should be `int'. It does not need +to be in any allocated section, though. The code merely asserts that +the symbol exists in the global scope. Something like this is enough: + + int plugin_is_GPL_compatible; + + +File: gawk.info, Node: Sample Library, Prev: Plugin License, Up: Dynamic Extensions + +C.3.3 Example: Directory and File Operation Built-ins +----------------------------------------------------- + +Two useful functions that are not in `awk' are `chdir()' (so that an +`awk' program can change its directory) and `stat()' (so that an `awk' +program can gather information about a file). This minor node +implements these functions for `gawk' in an external extension library. + +* Menu: + +* Internal File Description:: What the new functions will do. +* Internal File Ops:: The code for internal file operations. +* Using Internal File Ops:: How to use an external extension. + + +File: gawk.info, Node: Internal File Description, Next: Internal File Ops, Up: Sample Library + +C.3.3.1 Using `chdir()' and `stat()' +.................................... + +This minor node shows how to use the new functions at the `awk' level +once they've been integrated into the running `gawk' interpreter. +Using `chdir()' is very straightforward. It takes one argument, the new +directory to change to: + + ... + newdir = "/home/arnold/funstuff" + ret = chdir(newdir) + if (ret < 0) { + printf("could not change to %s: %s\n", + newdir, ERRNO) > "/dev/stderr" + exit 1 + } + ... + + The return value is negative if the `chdir' failed, and `ERRNO' +(*note Built-in Variables::) is set to a string indicating the error. + + Using `stat()' is a bit more complicated. The C `stat()' function +fills in a structure that has a fair amount of information. The right +way to model this in `awk' is to fill in an associative array with the +appropriate information: + + file = "/home/arnold/.profile" + fdata[1] = "x" # force `fdata' to be an array + ret = stat(file, fdata) + if (ret < 0) { + printf("could not stat %s: %s\n", + file, ERRNO) > "/dev/stderr" + exit 1 + } + printf("size of %s is %d bytes\n", file, fdata["size"]) + + The `stat()' function always clears the data array, even if the +`stat()' fails. It fills in the following elements: + +`"name"' + The name of the file that was `stat()''ed. + +`"dev"' +`"ino"' + The file's device and inode numbers, respectively. + +`"mode"' + The file's mode, as a numeric value. This includes both the file's + type and its permissions. + +`"nlink"' + The number of hard links (directory entries) the file has. + +`"uid"' +`"gid"' + The numeric user and group ID numbers of the file's owner. + +`"size"' + The size in bytes of the file. + +`"blocks"' + The number of disk blocks the file actually occupies. This may not + be a function of the file's size if the file has holes. + +`"atime"' +`"mtime"' +`"ctime"' + The file's last access, modification, and inode update times, + respectively. These are numeric timestamps, suitable for + formatting with `strftime()' (*note Built-in::). + +`"pmode"' + The file's "printable mode." This is a string representation of + the file's type and permissions, such as what is produced by `ls + -l'--for example, `"drwxr-xr-x"'. + +`"type"' + A printable string representation of the file's type. The value + is one of the following: + + `"blockdev"' + `"chardev"' + The file is a block or character device ("special file"). + + `"directory"' + The file is a directory. + + `"fifo"' + The file is a named-pipe (also known as a FIFO). + + `"file"' + The file is just a regular file. + + `"socket"' + The file is an `AF_UNIX' ("Unix domain") socket in the + filesystem. + + `"symlink"' + The file is a symbolic link. + + Several additional elements may be present depending upon the +operating system and the type of the file. You can test for them in +your `awk' program by using the `in' operator (*note Reference to +Elements::): + +`"blksize"' + The preferred block size for I/O to the file. This field is not + present on all POSIX-like systems in the C `stat' structure. + +`"linkval"' + If the file is a symbolic link, this element is the name of the + file the link points to (i.e., the value of the link). + +`"rdev"' +`"major"' +`"minor"' + If the file is a block or character device file, then these values + represent the numeric device number and the major and minor + components of that number, respectively. + + +File: gawk.info, Node: Internal File Ops, Next: Using Internal File Ops, Prev: Internal File Description, Up: Sample Library + +C.3.3.2 C Code for `chdir()' and `stat()' +......................................... + +Here is the C code for these extensions. They were written for +GNU/Linux. The code needs some more work for complete portability to +other POSIX-compliant systems:(1) + + #include "awk.h" + + #include + + int plugin_is_GPL_compatible; + + /* do_chdir --- provide dynamically loaded chdir() builtin for gawk */ + + static NODE * + do_chdir(int nargs) + { + NODE *newdir; + int ret = -1; + + if (do_lint && get_curfunc_arg_count() != 1) + lintwarn("chdir: called with incorrect number of arguments"); + + newdir = get_scalar_argument(0, FALSE); + + The file includes the `"awk.h"' header file for definitions for the +`gawk' internals. It includes `' for access to the +`major()' and `minor'() macros. + + By convention, for an `awk' function `foo', the function that +implements it is called `do_foo'. The function should take a `int' +argument, usually called `nargs', that represents the number of defined +arguments for the function. The `newdir' variable represents the new +directory to change to, retrieved with `get_scalar_argument()'. Note +that the first argument is numbered zero. + + This code actually accomplishes the `chdir()'. It first forces the +argument to be a string and passes the string value to the `chdir()' +system call. If the `chdir()' fails, `ERRNO' is updated. + + (void) force_string(newdir); + ret = chdir(newdir->stptr); + if (ret < 0) + update_ERRNO(); + + Finally, the function returns the return value to the `awk' level: + + return make_number((AWKNUM) ret); + } + + The `stat()' built-in is more involved. First comes a function that +turns a numeric mode into a printable representation (e.g., 644 becomes +`-rw-r--r--'). This is omitted here for brevity: + + /* format_mode --- turn a stat mode field into something readable */ + + static char * + format_mode(unsigned long fmode) + { + ... + } + + Next comes the `do_stat()' function. It starts with variable +declarations and argument checking: + + /* do_stat --- provide a stat() function for gawk */ + + static NODE * + do_stat(int nargs) + { + NODE *file, *array, *tmp; + struct stat sbuf; + int ret; + NODE **aptr; + char *pmode; /* printable mode */ + char *type = "unknown"; + + if (do_lint && get_curfunc_arg_count() > 2) + lintwarn("stat: called with too many arguments"); + + Then comes the actual work. First, the function gets the arguments. +Then, it always clears the array. The code use `lstat()' (instead of +`stat()') to get the file information, in case the file is a symbolic +link. If there's an error, it sets `ERRNO' and returns: + + /* file is first arg, array to hold results is second */ + file = get_scalar_argument(0, FALSE); + array = get_array_argument(1, FALSE); + + /* empty out the array */ + assoc_clear(array); + + /* lstat the file, if error, set ERRNO and return */ + (void) force_string(file); + ret = lstat(file->stptr, & sbuf); + if (ret < 0) { + update_ERRNO(); + return make_number((AWKNUM) ret); + } + + Now comes the tedious part: filling in the array. Only a few of the +calls are shown here, since they all follow the same pattern: + + /* fill in the array */ + aptr = assoc_lookup(array, tmp = make_string("name", 4), FALSE); + *aptr = dupnode(file); + unref(tmp); + + aptr = assoc_lookup(array, tmp = make_string("mode", 4), FALSE); + *aptr = make_number((AWKNUM) sbuf.st_mode); + unref(tmp); + + aptr = assoc_lookup(array, tmp = make_string("pmode", 5), FALSE); + pmode = format_mode(sbuf.st_mode); + *aptr = make_string(pmode, strlen(pmode)); + unref(tmp); + + When done, return the `lstat()' return value: + + + return make_number((AWKNUM) ret); + } + + Finally, it's necessary to provide the "glue" that loads the new +function(s) into `gawk'. By convention, each library has a routine +named `dlload()' that does the job: + + /* dlload --- load new builtins in this library */ + + NODE * + dlload(NODE *tree, void *dl) + { + make_builtin("chdir", do_chdir, 1); + make_builtin("stat", do_stat, 2); + return make_number((AWKNUM) 0); + } + + And that's it! As an exercise, consider adding functions to +implement system calls such as `chown()', `chmod()', and `umask()'. + + ---------- Footnotes ---------- + + (1) This version is edited slightly for presentation. See +`extension/filefuncs.c' in the `gawk' distribution for the complete +version. + + +File: gawk.info, Node: Using Internal File Ops, Prev: Internal File Ops, Up: Sample Library + +C.3.3.3 Integrating the Extensions +.................................. + +Now that the code is written, it must be possible to add it at runtime +to the running `gawk' interpreter. First, the code must be compiled. +Assuming that the functions are in a file named `filefuncs.c', and IDIR +is the location of the `gawk' include files, the following steps create +a GNU/Linux shared library: + + $ gcc -fPIC -shared -DHAVE_CONFIG_H -c -O -g -IIDIR filefuncs.c + $ ld -o filefuncs.so -shared filefuncs.o + + Once the library exists, it is loaded by calling the `extension()' +built-in function. This function takes two arguments: the name of the +library to load and the name of a function to call when the library is +first loaded. This function adds the new functions to `gawk'. It +returns the value returned by the initialization function within the +shared library: + + # file testff.awk + BEGIN { + extension("./filefuncs.so", "dlload") + + chdir(".") # no-op + + data[1] = 1 # force `data' to be an array + print "Info for testff.awk" + ret = stat("testff.awk", data) + print "ret =", ret + for (i in data) + printf "data[\"%s\"] = %s\n", i, data[i] + print "testff.awk modified:", + strftime("%m %d %y %H:%M:%S", data["mtime"]) + + print "\nInfo for JUNK" + ret = stat("JUNK", data) + print "ret =", ret + for (i in data) + printf "data[\"%s\"] = %s\n", i, data[i] + print "JUNK modified:", strftime("%m %d %y %H:%M:%S", data["mtime"]) + } + + Here are the results of running the program: + + $ gawk -f testff.awk + -| Info for testff.awk + -| ret = 0 + -| data["size"] = 607 + -| data["ino"] = 14945891 + -| data["name"] = testff.awk + -| data["pmode"] = -rw-rw-r-- + -| data["nlink"] = 1 + -| data["atime"] = 1293993369 + -| data["mtime"] = 1288520752 + -| data["mode"] = 33204 + -| data["blksize"] = 4096 + -| data["dev"] = 2054 + -| data["type"] = file + -| data["gid"] = 500 + -| data["uid"] = 500 + -| data["blocks"] = 8 + -| data["ctime"] = 1290113572 + -| testff.awk modified: 10 31 10 12:25:52 + -| + -| Info for JUNK + -| ret = -1 + -| JUNK modified: 01 01 70 02:00:00 + + +File: gawk.info, Node: Future Extensions, Prev: Dynamic Extensions, Up: Notes + +C.4 Probable Future Extensions +============================== + + AWK is a language similar to PERL, only considerably more elegant. + Arnold Robbins + + Hey! + Larry Wall + + This minor node briefly lists extensions and possible improvements +that indicate the directions we are currently considering for `gawk'. +The file `FUTURES' in the `gawk' distribution lists these extensions as +well. + + Following is a list of probable future changes visible at the `awk' +language level: + +Loadable module interface + It is not clear that the `awk'-level interface to the modules + facility is as good as it should be. The interface needs to be + redesigned, particularly taking namespace issues into account, as + well as possibly including issues such as library search path order + and versioning. + +`RECLEN' variable for fixed-length records + Along with `FIELDWIDTHS', this would speed up the processing of + fixed-length records. `PROCINFO["RS"]' would be `"RS"' or + `"RECLEN"', depending upon which kind of record processing is in + effect. + +Databases + It may be possible to map a GDBM/NDBM/SDBM file into an `awk' + array. + +More `lint' warnings + There are more things that could be checked for portability. + + Following is a list of probable improvements that will make `gawk''s +source code easier to work with: + +Loadable module mechanics + The current extension mechanism works (*note Dynamic Extensions::), + but is rather primitive. It requires a fair amount of manual work + to create and integrate a loadable module. Nor is the current + mechanism as portable as might be desired. The GNU `libtool' + package provides a number of features that would make using + loadable modules much easier. `gawk' should be changed to use + `libtool'. + +Loadable module internals + The API to its internals that `gawk' "exports" should be revised. + Too many things are needlessly exposed. A new API should be + designed and implemented to make module writing easier. + +Better array subscript management + `gawk''s management of array subscript storage could use revamping, + so that using the same value to index multiple arrays only stores + one copy of the index value. + + Finally, the programs in the test suite could use documenting in +this Info file. + + *Note Additions::, if you are interested in tackling any of these +projects. + + +File: gawk.info, Node: Basic Concepts, Next: Glossary, Prev: Notes, Up: Top + +Appendix D Basic Programming Concepts +************************************* + +This major node attempts to define some of the basic concepts and terms +that are used throughout the rest of this Info file. As this Info file +is specifically about `awk', and not about computer programming in +general, the coverage here is by necessity fairly cursory and +simplistic. (If you need more background, there are many other +introductory texts that you should refer to instead.) + +* Menu: + +* Basic High Level:: The high level view. +* Basic Data Typing:: A very quick intro to data types. +* Floating Point Issues:: Stuff to know about floating-point numbers. + + +File: gawk.info, Node: Basic High Level, Next: Basic Data Typing, Up: Basic Concepts + +D.1 What a Program Does +======================= + +At the most basic level, the job of a program is to process some input +data and produce results. + + _______ + +------+ / \ +---------+ + | Data | -----> < Program > -----> | Results | + +------+ \_______/ +---------+ + + The "program" in the figure can be either a compiled program(1) +(such as `ls'), or it may be "interpreted". In the latter case, a +machine-executable program such as `awk' reads your program, and then +uses the instructions in your program to process the data. + + When you write a program, it usually consists of the following, very +basic set of steps: + + ______ + +----------------+ / More \ No +----------+ + | Initialization | -------> < Data > -------> | Clean Up | + +----------------+ ^ \ ? / +----------+ + | +--+-+ + | | Yes + | | + | V + | +---------+ + +-----+ Process | + +---------+ + +Initialization + These are the things you do before actually starting to process + data, such as checking arguments, initializing any data you need + to work with, and so on. This step corresponds to `awk''s `BEGIN' + rule (*note BEGIN/END::). + + If you were baking a cake, this might consist of laying out all the + mixing bowls and the baking pan, and making sure you have all the + ingredients that you need. + +Processing + This is where the actual work is done. Your program reads data, + one logical chunk at a time, and processes it as appropriate. + + In most programming languages, you have to manually manage the + reading of data, checking to see if there is more each time you + read a chunk. `awk''s pattern-action paradigm (*note Getting + Started::) handles the mechanics of this for you. + + In baking a cake, the processing corresponds to the actual labor: + breaking eggs, mixing the flour, water, and other ingredients, and + then putting the cake into the oven. + +Clean Up + Once you've processed all the data, you may have things you need to + do before exiting. This step corresponds to `awk''s `END' rule + (*note BEGIN/END::). + + After the cake comes out of the oven, you still have to wrap it in + plastic wrap to keep anyone from tasting it, as well as wash the + mixing bowls and utensils. + + An "algorithm" is a detailed set of instructions necessary to +accomplish a task, or process data. It is much the same as a recipe +for baking a cake. Programs implement algorithms. Often, it is up to +you to design the algorithm and implement it, simultaneously. + + The "logical chunks" we talked about previously are called "records", +similar to the records a company keeps on employees, a school keeps for +students, or a doctor keeps for patients. Each record has many +component parts, such as first and last names, date of birth, address, +and so on. The component parts are referred to as the "fields" of the +record. + + The act of reading data is termed "input", and that of generating +results, not too surprisingly, is termed "output". They are often +referred to together as "input/output," and even more often, as "I/O" +for short. (You will also see "input" and "output" used as verbs.) + + `awk' manages the reading of data for you, as well as the breaking +it up into records and fields. Your program's job is to tell `awk' +what to do with the data. You do this by describing "patterns" in the +data to look for, and "actions" to execute when those patterns are +seen. This "data-driven" nature of `awk' programs usually makes them +both easier to write and easier to read. + + ---------- Footnotes ---------- + + (1) Compiled programs are typically written in lower-level languages +such as C, C++, or Ada, and then translated, or "compiled", into a form +that the computer can execute directly. + + +File: gawk.info, Node: Basic Data Typing, Next: Floating Point Issues, Prev: Basic High Level, Up: Basic Concepts + +D.2 Data Values in a Computer +============================= + +In a program, you keep track of information and values in things called +"variables". A variable is just a name for a given value, such as +`first_name', `last_name', `address', and so on. `awk' has several +predefined variables, and it has special names to refer to the current +input record and the fields of the record. You may also group multiple +associated values under one name, as an array. + + Data, particularly in `awk', consists of either numeric values, such +as 42 or 3.1415927, or string values. String values are essentially +anything that's not a number, such as a name. Strings are sometimes +referred to as "character data", since they store the individual +characters that comprise them. Individual variables, as well as +numeric and string variables, are referred to as "scalar" values. +Groups of values, such as arrays, are not scalars. + + Within computers, there are two kinds of numeric values: "integers" +and "floating-point". In school, integer values were referred to as +"whole" numbers--that is, numbers without any fractional part, such as +1, 42, or -17. The advantage to integer numbers is that they represent +values exactly. The disadvantage is that their range is limited. On +most systems, this range is -2,147,483,648 to 2,147,483,647. However, +many systems now support a range from -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807. + + Integer values come in two flavors: "signed" and "unsigned". Signed +values may be negative or positive, with the range of values just +described. Unsigned values are always positive. On most systems, the +range is from 0 to 4,294,967,295. However, many systems now support a +range from 0 to 18,446,744,073,709,551,615. + + Floating-point numbers represent what are called "real" numbers; +i.e., those that do have a fractional part, such as 3.1415927. The +advantage to floating-point numbers is that they can represent a much +larger range of values. The disadvantage is that there are numbers +that they cannot represent exactly. `awk' uses "double precision" +floating-point numbers, which can hold more digits than "single +precision" floating-point numbers. Floating-point issues are discussed +more fully in *note Floating Point Issues::. + + At the very lowest level, computers store values as groups of binary +digits, or "bits". Modern computers group bits into groups of eight, +called "bytes". Advanced applications sometimes have to manipulate +bits directly, and `gawk' provides functions for doing so. + + While you are probably used to the idea of a number without a value +(i.e., zero), it takes a bit more getting used to the idea of +zero-length character data. Nevertheless, such a thing exists. It is +called the "null string". The null string is character data that has +no value. In other words, it is empty. It is written in `awk' programs +like this: `""'. + + Humans are used to working in decimal; i.e., base 10. In base 10, +numbers go from 0 to 9, and then "roll over" into the next column. +(Remember grade school? 42 is 4 times 10 plus 2.) + + There are other number bases though. Computers commonly use base 2 +or "binary", base 8 or "octal", and base 16 or "hexadecimal". In +binary, each column represents two times the value in the column to its +right. Each column may contain either a 0 or a 1. Thus, binary 1010 +represents 1 times 8, plus 0 times 4, plus 1 times 2, plus 0 times 1, +or decimal 10. Octal and hexadecimal are discussed more in *note +Nondecimal-numbers::. + + Programs are written in programming languages. Hundreds, if not +thousands, of programming languages exist. One of the most popular is +the C programming language. The C language had a very strong influence +on the design of the `awk' language. + + There have been several versions of C. The first is often referred +to as "K&R" C, after the initials of Brian Kernighan and Dennis Ritchie, +the authors of the first book on C. (Dennis Ritchie created the +language, and Brian Kernighan was one of the creators of `awk'.) + + In the mid-1980s, an effort began to produce an international +standard for C. This work culminated in 1989, with the production of +the ANSI standard for C. This standard became an ISO standard in 1990. +In 1999, a revised ISO C standard was approved and released. Where it +makes sense, POSIX `awk' is compatible with 1999 ISO C. + + +File: gawk.info, Node: Floating Point Issues, Prev: Basic Data Typing, Up: Basic Concepts + +D.3 Floating-Point Number Caveats +================================= + +As mentioned earlier, floating-point numbers represent what are called +"real" numbers, i.e., those that have a fractional part. `awk' uses +double precision floating-point numbers to represent all numeric +values. This minor node describes some of the issues involved in using +floating-point numbers. + + There is a very nice paper on floating-point arithmetic +(http://www.validlab.com/goldberg/paper.pdf) by David Goldberg, "What +Every Computer Scientist Should Know About Floating-point Arithmetic," +`ACM Computing Surveys' *23*, 1 (1991-03), 5-48. This is worth reading +if you are interested in the details, but it does require a background +in computer science. + +* Menu: + +* String Conversion Precision:: The String Value Can Lie. +* Unexpected Results:: Floating Point Numbers Are Not Abstract + Numbers. +* POSIX Floating Point Problems:: Standards Versus Existing Practice. + + +File: gawk.info, Node: String Conversion Precision, Next: Unexpected Results, Up: Floating Point Issues + +D.3.1 The String Value Can Lie +------------------------------ + +Internally, `awk' keeps both the numeric value (double precision +floating-point) and the string value for a variable. Separately, `awk' +keeps track of what type the variable has (*note Typing and +Comparison::), which plays a role in how variables are used in +comparisons. + + It is important to note that the string value for a number may not +reflect the full value (all the digits) that the numeric value actually +contains. The following program (`values.awk') illustrates this: + + { + sum = $1 + $2 + # see it for what it is + printf("sum = %.12g\n", sum) + # use CONVFMT + a = "<" sum ">" + print "a =", a + # use OFMT + print "sum =", sum + } + +This program shows the full value of the sum of `$1' and `$2' using +`printf', and then prints the string values obtained from both +automatic conversion (via `CONVFMT') and from printing (via `OFMT'). + + Here is what happens when the program is run: + + $ echo 3.654321 1.2345678 | awk -f values.awk + -| sum = 4.8888888 + -| a = <4.88889> + -| sum = 4.88889 + + This makes it clear that the full numeric value is different from +what the default string representations show. + + `CONVFMT''s default value is `"%.6g"', which yields a value with at +least six significant digits. For some applications, you might want to +change it to specify more precision. On most modern machines, most of +the time, 17 digits is enough to capture a floating-point number's +value exactly.(1) + + ---------- Footnotes ---------- + + (1) Pathological cases can require up to 752 digits (!), but we +doubt that you need to worry about this. + + +File: gawk.info, Node: Unexpected Results, Next: POSIX Floating Point Problems, Prev: String Conversion Precision, Up: Floating Point Issues + +D.3.2 Floating Point Numbers Are Not Abstract Numbers +----------------------------------------------------- + +Unlike numbers in the abstract sense (such as what you studied in high +school or college math), numbers stored in computers are limited in +certain ways. They cannot represent an infinite number of digits, nor +can they always represent things exactly. In particular, +floating-point numbers cannot always represent values exactly. Here is +an example: + + $ awk '{ printf("%010d\n", $1 * 100) }' + 515.79 + -| 0000051579 + 515.80 + -| 0000051579 + 515.81 + -| 0000051580 + 515.82 + -| 0000051582 + Ctrl-d + +This shows that some values can be represented exactly, whereas others +are only approximated. This is not a "bug" in `awk', but simply an +artifact of how computers represent numbers. + + Another peculiarity of floating-point numbers on modern systems is +that they often have more than one representation for the number zero! +In particular, it is possible to represent "minus zero" as well as +regular, or "positive" zero. + + This example shows that negative and positive zero are distinct +values when stored internally, but that they are in fact equal to each +other, as well as to "regular" zero: + + $ gawk 'BEGIN { mz = -0 ; pz = 0 + > printf "-0 = %g, +0 = %g, (-0 == +0) -> %d\n", mz, pz, mz == pz + > printf "mz == 0 -> %d, pz == 0 -> %d\n", mz == 0, pz == 0 + > }' + -| -0 = -0, +0 = 0, (-0 == +0) -> 1 + -| mz == 0 -> 1, pz == 0 -> 1 + + It helps to keep this in mind should you process numeric data that +contains negative zero values; the fact that the zero is negative is +noted and can affect comparisons. + + +File: gawk.info, Node: POSIX Floating Point Problems, Prev: Unexpected Results, Up: Floating Point Issues + +D.3.3 Standards Versus Existing Practice +---------------------------------------- + +Historically, `awk' has converted any non-numeric looking string to the +numeric value zero, when required. Furthermore, the original +definition of the language and the original POSIX standards specified +that `awk' only understands decimal numbers (base 10), and not octal +(base 8) or hexadecimal numbers (base 16). + + Changes in the language of the 2001 and 2004 POSIX standard can be +interpreted to imply that `awk' should support additional features. +These features are: + + * Interpretation of floating point data values specified in + hexadecimal notation (`0xDEADBEEF'). (Note: data values, _not_ + source code constants.) + + * Support for the special IEEE 754 floating point values "Not A + Number" (NaN), positive Infinity ("inf") and negative Infinity + ("-inf"). In particular, the format for these values is as + specified by the ISO 1999 C standard, which ignores case and can + allow machine-dependent additional characters after the `nan' and + allow either `inf' or `infinity'. + + The first problem is that both of these are clear changes to +historical practice: + + * The `gawk' maintainer feels that supporting hexadecimal floating + point values, in particular, is ugly, and was never intended by the + original designers to be part of the language. + + * Allowing completely alphabetic strings to have valid numeric + values is also a very severe departure from historical practice. + + The second problem is that the `gawk' maintainer feels that this +interpretation of the standard, which requires a certain amount of +"language lawyering" to arrive at in the first place, was not even +intended by the standard developers. In other words, "we see how you +got where you are, but we don't think that that's where you want to be." + + The 2008 POSIX standard added explicit wording to allow, but not +require, that `awk' support hexadecimal floating point values and +special values for "Not A Number" and infinity. + + Although the `gawk' maintainer continues to feel that providing +those features is inadvisable, nevertheless, on systems that support +IEEE floating point, it seems reasonable to provide _some_ way to +support NaN and Infinity values. The solution implemented in `gawk' is +as follows: + + * With the `--posix' command-line option, `gawk' becomes "hands + off." String values are passed directly to the system library's + `strtod()' function, and if it successfully returns a numeric + value, that is what's used.(1) By definition, the results are not + portable across different systems. They are also a little + surprising: + + $ echo nanny | gawk --posix '{ print $1 + 0 }' + -| nan + $ echo 0xDeadBeef | gawk --posix '{ print $1 + 0 }' + -| 3735928559 + + * Without `--posix', `gawk' interprets the four strings `+inf', + `-inf', `+nan', and `-nan' specially, producing the corresponding + special numeric values. The leading sign acts a signal to `gawk' + (and the user) that the value is really numeric. Hexadecimal + floating point is not supported (unless you also use + `--non-decimal-data', which is _not_ recommended). For example: + + $ echo nanny | gawk '{ print $1 + 0 }' + -| 0 + $ echo +nan | gawk '{ print $1 + 0 }' + -| nan + $ echo 0xDeadBeef | gawk '{ print $1 + 0 }' + -| 0 + + `gawk' does ignore case in the four special values. Thus `+nan' + and `+NaN' are the same. + + ---------- Footnotes ---------- + + (1) You asked for it, you got it. + + +File: gawk.info, Node: Glossary, Next: Copying, Prev: Basic Concepts, Up: Top + +Glossary +******** + +Action + A series of `awk' statements attached to a rule. If the rule's + pattern matches an input record, `awk' executes the rule's action. + Actions are always enclosed in curly braces. (*Note Action + Overview::.) + +Amazing `awk' Assembler + Henry Spencer at the University of Toronto wrote a retargetable + assembler completely as `sed' and `awk' scripts. It is thousands + of lines long, including machine descriptions for several eight-bit + microcomputers. It is a good example of a program that would have + been better written in another language. You can get it from + `http://awk.info/?awk100/aaa'. + +Ada + A programming language originally defined by the U.S. Department of + Defense for embedded programming. It was designed to enforce good + Software Engineering practices. + +Amazingly Workable Formatter (`awf') + Henry Spencer at the University of Toronto wrote a formatter that + accepts a large subset of the `nroff -ms' and `nroff -man' + formatting commands, using `awk' and `sh'. It is available from + `http://awk.info/?tools/awf'. + +Anchor + The regexp metacharacters `^' and `$', which force the match to + the beginning or end of the string, respectively. + +ANSI + The American National Standards Institute. This organization + produces many standards, among them the standards for the C and + C++ programming languages. These standards often become + international standards as well. See also "ISO." + +Array + A grouping of multiple values under the same name. Most languages + just provide sequential arrays. `awk' provides associative arrays. + +Assertion + A statement in a program that a condition is true at this point in + the program. Useful for reasoning about how a program is supposed + to behave. + +Assignment + An `awk' expression that changes the value of some `awk' variable + or data object. An object that you can assign to is called an + "lvalue". The assigned values are called "rvalues". *Note + Assignment Ops::. + +Associative Array + Arrays in which the indices may be numbers or strings, not just + sequential integers in a fixed range. + +`awk' Language + The language in which `awk' programs are written. + +`awk' Program + An `awk' program consists of a series of "patterns" and "actions", + collectively known as "rules". For each input record given to the + program, the program's rules are all processed in turn. `awk' + programs may also contain function definitions. + +`awk' Script + Another name for an `awk' program. + +Bash + The GNU version of the standard shell (the Bourne-Again SHell). + See also "Bourne Shell." + +BBS + See "Bulletin Board System." + +Bit + Short for "Binary Digit." All values in computer memory + ultimately reduce to binary digits: values that are either zero or + one. Groups of bits may be interpreted differently--as integers, + floating-point numbers, character data, addresses of other memory + objects, or other data. `awk' lets you work with floating-point + numbers and strings. `gawk' lets you manipulate bit values with + the built-in functions described in *note Bitwise Functions::. + + Computers are often defined by how many bits they use to represent + integer values. Typical systems are 32-bit systems, but 64-bit + systems are becoming increasingly popular, and 16-bit systems have + essentially disappeared. + +Boolean Expression + Named after the English mathematician Boole. See also "Logical + Expression." + +Bourne Shell + The standard shell (`/bin/sh') on Unix and Unix-like systems, + originally written by Steven R. Bourne. Many shells (Bash, `ksh', + `pdksh', `zsh') are generally upwardly compatible with the Bourne + shell. + +Built-in Function + The `awk' language provides built-in functions that perform various + numerical, I/O-related, and string computations. Examples are + `sqrt()' (for the square root of a number) and `substr()' (for a + substring of a string). `gawk' provides functions for timestamp + management, bit manipulation, array sorting, type checking, and + runtime string translation. (*Note Built-in::.) + +Built-in Variable + `ARGC', `ARGV', `CONVFMT', `ENVIRON', `FILENAME', `FNR', `FS', + `NF', `NR', `OFMT', `OFS', `ORS', `RLENGTH', `RSTART', `RS', and + `SUBSEP' are the variables that have special meaning to `awk'. In + addition, `ARGIND', `BINMODE', `ERRNO', `FIELDWIDTHS', `FPAT', + `IGNORECASE', `LINT', `PROCINFO', `RT', and `TEXTDOMAIN' are the + variables that have special meaning to `gawk'. Changing some of + them affects `awk''s running environment. (*Note Built-in + Variables::.) + +Braces + See "Curly Braces." + +Bulletin Board System + A computer system allowing users to log in and read and/or leave + messages for other users of the system, much like leaving paper + notes on a bulletin board. + +C + The system programming language that most GNU software is written + in. The `awk' programming language has C-like syntax, and this + Info file points out similarities between `awk' and C when + appropriate. + + In general, `gawk' attempts to be as similar to the 1990 version + of ISO C as makes sense. + +C++ + A popular object-oriented programming language derived from C. + +Character Set + The set of numeric codes used by a computer system to represent the + characters (letters, numbers, punctuation, etc.) of a particular + country or place. The most common character set in use today is + ASCII (American Standard Code for Information Interchange). Many + European countries use an extension of ASCII known as ISO-8859-1 + (ISO Latin-1). The Unicode character set (http://www.unicode.org) + is becoming increasingly popular and standard, and is particularly + widely used on GNU/Linux systems. + +CHEM + A preprocessor for `pic' that reads descriptions of molecules and + produces `pic' input for drawing them. It was written in `awk' by + Brian Kernighan and Jon Bentley, and is available from + `http://netlib.sandia.gov/netlib/typesetting/chem.gz'. + +Coprocess + A subordinate program with which two-way communications is + possible. + +Compiler + A program that translates human-readable source code into + machine-executable object code. The object code is then executed + directly by the computer. See also "Interpreter." + +Compound Statement + A series of `awk' statements, enclosed in curly braces. Compound + statements may be nested. (*Note Statements::.) + +Concatenation + Concatenating two strings means sticking them together, one after + another, producing a new string. For example, the string `foo' + concatenated with the string `bar' gives the string `foobar'. + (*Note Concatenation::.) + +Conditional Expression + An expression using the `?:' ternary operator, such as `EXPR1 ? + EXPR2 : EXPR3'. The expression EXPR1 is evaluated; if the result + is true, the value of the whole expression is the value of EXPR2; + otherwise the value is EXPR3. In either case, only one of EXPR2 + and EXPR3 is evaluated. (*Note Conditional Exp::.) + +Comparison Expression + A relation that is either true or false, such as `a < b'. + Comparison expressions are used in `if', `while', `do', and `for' + statements, and in patterns to select which input records to + process. (*Note Typing and Comparison::.) + +Curly Braces + The characters `{' and `}'. Curly braces are used in `awk' for + delimiting actions, compound statements, and function bodies. + +Dark Corner + An area in the language where specifications often were (or still + are) not clear, leading to unexpected or undesirable behavior. + Such areas are marked in this Info file with "(d.c.)" in the text + and are indexed under the heading "dark corner." + +Data Driven + A description of `awk' programs, where you specify the data you + are interested in processing, and what to do when that data is + seen. + +Data Objects + These are numbers and strings of characters. Numbers are + converted into strings and vice versa, as needed. (*Note + Conversion::.) + +Deadlock + The situation in which two communicating processes are each waiting + for the other to perform an action. + +Debugger + A program used to help developers remove "bugs" from (de-bug) + their programs. + +Double Precision + An internal representation of numbers that can have fractional + parts. Double precision numbers keep track of more digits than do + single precision numbers, but operations on them are sometimes + more expensive. This is the way `awk' stores numeric values. It + is the C type `double'. + +Dynamic Regular Expression + A dynamic regular expression is a regular expression written as an + ordinary expression. It could be a string constant, such as + `"foo"', but it may also be an expression whose value can vary. + (*Note Computed Regexps::.) + +Environment + A collection of strings, of the form NAME`='VAL, that each program + has available to it. Users generally place values into the + environment in order to provide information to various programs. + Typical examples are the environment variables `HOME' and `PATH'. + +Empty String + See "Null String." + +Epoch + The date used as the "beginning of time" for timestamps. Time + values in most systems are represented as seconds since the epoch, + with library functions available for converting these values into + standard date and time formats. + + The epoch on Unix and POSIX systems is 1970-01-01 00:00:00 UTC. + See also "GMT" and "UTC." + +Escape Sequences + A special sequence of characters used for describing nonprinting + characters, such as `\n' for newline or `\033' for the ASCII ESC + (Escape) character. (*Note Escape Sequences::.) + +Extension + An additional feature or change to a programming language or + utility not defined by that language's or utility's standard. + `gawk' has (too) many extensions over POSIX `awk'. + +FDL + See "Free Documentation License." + +Field + When `awk' reads an input record, it splits the record into pieces + separated by whitespace (or by a separator regexp that you can + change by setting the built-in variable `FS'). Such pieces are + called fields. If the pieces are of fixed length, you can use the + built-in variable `FIELDWIDTHS' to describe their lengths. If you + wish to specify the contents of fields instead of the field + separator, you can use the built-in variable `FPAT' to do so. + (*Note Field Separators::, *note Constant Size::, and *note + Splitting By Content::.) + +Flag + A variable whose truth value indicates the existence or + nonexistence of some condition. + +Floating-Point Number + Often referred to in mathematical terms as a "rational" or real + number, this is just a number that can have a fractional part. + See also "Double Precision" and "Single Precision." + +Format + Format strings are used to control the appearance of output in the + `strftime()' and `sprintf()' functions, and are used in the + `printf' statement as well. Also, data conversions from numbers + to strings are controlled by the format strings contained in the + built-in variables `CONVFMT' and `OFMT'. (*Note Control Letters::.) + +Free Documentation License + This document describes the terms under which this Info file is + published and may be copied. (*Note GNU Free Documentation + License::.) + +Function + A specialized group of statements used to encapsulate general or + program-specific tasks. `awk' has a number of built-in functions, + and also allows you to define your own. (*Note Functions::.) + +FSF + See "Free Software Foundation." + +Free Software Foundation + A nonprofit organization dedicated to the production and + distribution of freely distributable software. It was founded by + Richard M. Stallman, the author of the original Emacs editor. GNU + Emacs is the most widely used version of Emacs today. + +`gawk' + The GNU implementation of `awk'. + +General Public License + This document describes the terms under which `gawk' and its source + code may be distributed. (*Note Copying::.) + +GMT + "Greenwich Mean Time." This is the old term for UTC. It is the + time of day used internally for Unix and POSIX systems. See also + "Epoch" and "UTC." + +GNU + "GNU's not Unix". An on-going project of the Free Software + Foundation to create a complete, freely distributable, + POSIX-compliant computing environment. + +GNU/Linux + A variant of the GNU system using the Linux kernel, instead of the + Free Software Foundation's Hurd kernel. The Linux kernel is a + stable, efficient, full-featured clone of Unix that has been + ported to a variety of architectures. It is most popular on + PC-class systems, but runs well on a variety of other systems too. + The Linux kernel source code is available under the terms of the + GNU General Public License, which is perhaps its most important + aspect. + +GPL + See "General Public License." + +Hexadecimal + Base 16 notation, where the digits are `0'-`9' and `A'-`F', with + `A' representing 10, `B' representing 11, and so on, up to `F' for + 15. Hexadecimal numbers are written in C using a leading `0x', to + indicate their base. Thus, `0x12' is 18 (1 times 16 plus 2). + *Note Nondecimal-numbers::. + +I/O + Abbreviation for "Input/Output," the act of moving data into and/or + out of a running program. + +Input Record + A single chunk of data that is read in by `awk'. Usually, an + `awk' input record consists of one line of text. (*Note + Records::.) + +Integer + A whole number, i.e., a number that does not have a fractional + part. + +Internationalization + The process of writing or modifying a program so that it can use + multiple languages without requiring further source code changes. + +Interpreter + A program that reads human-readable source code directly, and uses + the instructions in it to process data and produce results. `awk' + is typically (but not always) implemented as an interpreter. See + also "Compiler." + +Interval Expression + A component of a regular expression that lets you specify repeated + matches of some part of the regexp. Interval expressions were not + originally available in `awk' programs. + +ISO + The International Standards Organization. This organization + produces international standards for many things, including + programming languages, such as C and C++. In the computer arena, + important standards like those for C, C++, and POSIX become both + American national and ISO international standards simultaneously. + This Info file refers to Standard C as "ISO C" throughout. + +Java + A modern programming language originally developed by Sun + Microsystems (now Oracle) supporting Object-Oriented programming. + Although usually implemented by compiling to the instructions for + a standard virtual machine (the JVM), the language can be compiled + to native code. + +Keyword + In the `awk' language, a keyword is a word that has special + meaning. Keywords are reserved and may not be used as variable + names. + + `gawk''s keywords are: `BEGIN', `BEGINFILE', `END', `ENDFILE', + `break', `case', `continue', `default' `delete', `do...while', + `else', `exit', `for...in', `for', `function', `func', `if', + `nextfile', `next', `switch', and `while'. + +Lesser General Public License + This document describes the terms under which binary library + archives or shared objects, and their source code may be + distributed. + +Linux + See "GNU/Linux." + +LGPL + See "Lesser General Public License." + +Localization + The process of providing the data necessary for an + internationalized program to work in a particular language. + +Logical Expression + An expression using the operators for logic, AND, OR, and NOT, + written `&&', `||', and `!' in `awk'. Often called Boolean + expressions, after the mathematician who pioneered this kind of + mathematical logic. + +Lvalue + An expression that can appear on the left side of an assignment + operator. In most languages, lvalues can be variables or array + elements. In `awk', a field designator can also be used as an + lvalue. + +Matching + The act of testing a string against a regular expression. If the + regexp describes the contents of the string, it is said to "match" + it. + +Metacharacters + Characters used within a regexp that do not stand for themselves. + Instead, they denote regular expression operations, such as + repetition, grouping, or alternation. + +No-op + An operation that does nothing. + +Null String + A string with no characters in it. It is represented explicitly in + `awk' programs by placing two double quote characters next to each + other (`""'). It can appear in input data by having two successive + occurrences of the field separator appear next to each other. + +Number + A numeric-valued data object. Modern `awk' implementations use + double precision floating-point to represent numbers. Ancient + `awk' implementations used single precision floating-point. + +Octal + Base-eight notation, where the digits are `0'-`7'. Octal numbers + are written in C using a leading `0', to indicate their base. + Thus, `013' is 11 (one times 8 plus 3). *Note + Nondecimal-numbers::. + +P1003.1, P1003.2 + See "POSIX." + +Pattern + Patterns tell `awk' which input records are interesting to which + rules. + + A pattern is an arbitrary conditional expression against which + input is tested. If the condition is satisfied, the pattern is + said to "match" the input record. A typical pattern might compare + the input record against a regular expression. (*Note Pattern + Overview::.) + +POSIX + The name for a series of standards that specify a Portable + Operating System interface. The "IX" denotes the Unix heritage of + these standards. The main standard of interest for `awk' users is + `IEEE Standard for Information Technology, Standard 1003.1-2008'. + The 2008 POSIX standard can be found online at + `http://www.opengroup.org/onlinepubs/9699919799/'. + +Precedence + The order in which operations are performed when operators are used + without explicit parentheses. + +Private + Variables and/or functions that are meant for use exclusively by + library functions and not for the main `awk' program. Special care + must be taken when naming such variables and functions. (*Note + Library Names::.) + +Range (of input lines) + A sequence of consecutive lines from the input file(s). A pattern + can specify ranges of input lines for `awk' to process or it can + specify single lines. (*Note Pattern Overview::.) + +Recursion + When a function calls itself, either directly or indirectly. As + long as this is not clear, refer to the entry for "recursion." If + this is clear, stop, and proceed to the next entry. + +Redirection + Redirection means performing input from something other than the + standard input stream, or performing output to something other + than the standard output stream. + + You can redirect input to the `getline' statement using the `<', + `|', and `|&' operators. You can redirect the output of the + `print' and `printf' statements to a file or a system command, + using the `>', `>>', `|', and `|&' operators. (*Note Getline::, + and *note Redirection::.) + +Regexp + See "Regular Expression." + +Regular Expression + A regular expression ("regexp" for short) is a pattern that + denotes a set of strings, possibly an infinite set. For example, + the regular expression `R.*xp' matches any string starting with + the letter `R' and ending with the letters `xp'. In `awk', + regular expressions are used in patterns and in conditional + expressions. Regular expressions may contain escape sequences. + (*Note Regexp::.) + +Regular Expression Constant + A regular expression constant is a regular expression written + within slashes, such as `/foo/'. This regular expression is chosen + when you write the `awk' program and cannot be changed during its + execution. (*Note Regexp Usage::.) + +Rule + A segment of an `awk' program that specifies how to process single + input records. A rule consists of a "pattern" and an "action". + `awk' reads an input record; then, for each rule, if the input + record satisfies the rule's pattern, `awk' executes the rule's + action. Otherwise, the rule does nothing for that input record. + +Rvalue + A value that can appear on the right side of an assignment + operator. In `awk', essentially every expression has a value. + These values are rvalues. + +Scalar + A single value, be it a number or a string. Regular variables are + scalars; arrays and functions are not. + +Search Path + In `gawk', a list of directories to search for `awk' program + source files. In the shell, a list of directories to search for + executable programs. + +Seed + The initial value, or starting point, for a sequence of random + numbers. + +`sed' + See "Stream Editor." + +Shell + The command interpreter for Unix and POSIX-compliant systems. The + shell works both interactively, and as a programming language for + batch files, or shell scripts. + +Short-Circuit + The nature of the `awk' logical operators `&&' and `||'. If the + value of the entire expression is determinable from evaluating just + the lefthand side of these operators, the righthand side is not + evaluated. (*Note Boolean Ops::.) + +Side Effect + A side effect occurs when an expression has an effect aside from + merely producing a value. Assignment expressions, increment and + decrement expressions, and function calls have side effects. + (*Note Assignment Ops::.) + +Single Precision + An internal representation of numbers that can have fractional + parts. Single precision numbers keep track of fewer digits than + do double precision numbers, but operations on them are sometimes + less expensive in terms of CPU time. This is the type used by + some very old versions of `awk' to store numeric values. It is + the C type `float'. + +Space + The character generated by hitting the space bar on the keyboard. + +Special File + A file name interpreted internally by `gawk', instead of being + handed directly to the underlying operating system--for example, + `/dev/stderr'. (*Note Special Files::.) + +Stream Editor + A program that reads records from an input stream and processes + them one or more at a time. This is in contrast with batch + programs, which may expect to read their input files in entirety + before starting to do anything, as well as with interactive + programs which require input from the user. + +String + A datum consisting of a sequence of characters, such as `I am a + string'. Constant strings are written with double quotes in the + `awk' language and may contain escape sequences. (*Note Escape + Sequences::.) + +Tab + The character generated by hitting the `TAB' key on the keyboard. + It usually expands to up to eight spaces upon output. + +Text Domain + A unique name that identifies an application. Used for grouping + messages that are translated at runtime into the local language. + +Timestamp + A value in the "seconds since the epoch" format used by Unix and + POSIX systems. Used for the `gawk' functions `mktime()', + `strftime()', and `systime()'. See also "Epoch" and "UTC." + +Unix + A computer operating system originally developed in the early + 1970's at AT&T Bell Laboratories. It initially became popular in + universities around the world and later moved into commercial + environments as a software development system and network server + system. There are many commercial versions of Unix, as well as + several work-alike systems whose source code is freely available + (such as GNU/Linux, NetBSD (http://www.netbsd.org), FreeBSD + (http://www.freebsd.org), and OpenBSD (http://www.openbsd.org)). + +UTC + The accepted abbreviation for "Universal Coordinated Time." This + is standard time in Greenwich, England, which is used as a + reference time for day and date calculations. See also "Epoch" + and "GMT." + +Whitespace + A sequence of space, TAB, or newline characters occurring inside + an input record or a string. + + +File: gawk.info, Node: Copying, Next: GNU Free Documentation License, Prev: Glossary, Up: Top + +GNU General Public License +************************** + + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. `http://fsf.org/' + + Everyone is permitted to copy and distribute verbatim copies of this + license document, but changing it is not allowed. + +Preamble +======== + +The GNU General Public License is a free, copyleft license for software +and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains +free software for all its users. We, the Free Software Foundation, use +the GNU General Public License for most of our software; it applies +also to any other work released this way by its authors. You can apply +it to your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you +have certain responsibilities if you distribute copies of the software, +or if you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the +manufacturer can do so. This is fundamentally incompatible with the +aim of protecting users' freedom to change the software. The +systematic pattern of such abuse occurs in the area of products for +individuals to use, which is precisely where it is most unacceptable. +Therefore, we have designed this version of the GPL to prohibit the +practice for those products. If such problems arise substantially in +other domains, we stand ready to extend this provision to those domains +in future versions of the GPL, as needed to protect the freedom of +users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + +TERMS AND CONDITIONS +==================== + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public + License. + + "Copyright" also means copyright-like laws that apply to other + kinds of works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this + License. Each licensee is addressed as "you". "Licensees" and + "recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the + work in a fashion requiring copyright permission, other than the + making of an exact copy. The resulting work is called a "modified + version" of the earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work + based on the Program. + + To "propagate" a work means to do anything with it that, without + permission, would make you directly or secondarily liable for + infringement under applicable copyright law, except executing it + on a computer or modifying a private copy. Propagation includes + copying, distribution (with or without modification), making + available to the public, and in some countries other activities as + well. + + To "convey" a work means any kind of propagation that enables other + parties to make or receive copies. Mere interaction with a user + through a computer network, with no transfer of a copy, is not + conveying. + + An interactive user interface displays "Appropriate Legal Notices" + to the extent that it includes a convenient and prominently visible + feature that (1) displays an appropriate copyright notice, and (2) + tells the user that there is no warranty for the work (except to + the extent that warranties are provided), that licensees may + convey the work under this License, and how to view a copy of this + License. If the interface presents a list of user commands or + options, such as a menu, a prominent item in the list meets this + criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work + for making modifications to it. "Object code" means any + non-source form of a work. + + A "Standard Interface" means an interface that either is an + official standard defined by a recognized standards body, or, in + the case of interfaces specified for a particular programming + language, one that is widely used among developers working in that + language. + + The "System Libraries" of an executable work include anything, + other than the work as a whole, that (a) is included in the normal + form of packaging a Major Component, but which is not part of that + Major Component, and (b) serves only to enable use of the work + with that Major Component, or to implement a Standard Interface + for which an implementation is available to the public in source + code form. A "Major Component", in this context, means a major + essential component (kernel, window system, and so on) of the + specific operating system (if any) on which the executable work + runs, or a compiler used to produce the work, or an object code + interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all + the source code needed to generate, install, and (for an executable + work) run the object code and to modify the work, including + scripts to control those activities. However, it does not include + the work's System Libraries, or general-purpose tools or generally + available free programs which are used unmodified in performing + those activities but which are not part of the work. For example, + Corresponding Source includes interface definition files + associated with source files for the work, and the source code for + shared libraries and dynamically linked subprograms that the work + is specifically designed to require, such as by intimate data + communication or control flow between those subprograms and other + parts of the work. + + The Corresponding Source need not include anything that users can + regenerate automatically from other parts of the Corresponding + Source. + + The Corresponding Source for a work in source code form is that + same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of + copyright on the Program, and are irrevocable provided the stated + conditions are met. This License explicitly affirms your unlimited + permission to run the unmodified Program. The output from running + a covered work is covered by this License only if the output, + given its content, constitutes a covered work. This License + acknowledges your rights of fair use or other equivalent, as + provided by copyright law. + + You may make, run and propagate covered works that you do not + convey, without conditions so long as your license otherwise + remains in force. You may convey covered works to others for the + sole purpose of having them make modifications exclusively for + you, or provide you with facilities for running those works, + provided that you comply with the terms of this License in + conveying all material for which you do not control copyright. + Those thus making or running the covered works for you must do so + exclusively on your behalf, under your direction and control, on + terms that prohibit them from making any copies of your + copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under + the conditions stated below. Sublicensing is not allowed; section + 10 makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological + measure under any applicable law fulfilling obligations under + article 11 of the WIPO copyright treaty adopted on 20 December + 1996, or similar laws prohibiting or restricting circumvention of + such measures. + + When you convey a covered work, you waive any legal power to forbid + circumvention of technological measures to the extent such + circumvention is effected by exercising rights under this License + with respect to the covered work, and you disclaim any intention + to limit operation or modification of the work as a means of + enforcing, against the work's users, your or third parties' legal + rights to forbid circumvention of technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you + receive it, in any medium, provided that you conspicuously and + appropriately publish on each copy an appropriate copyright notice; + keep intact all notices stating that this License and any + non-permissive terms added in accord with section 7 apply to the + code; keep intact all notices of the absence of any warranty; and + give all recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, + and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to + produce it from the Program, in the form of source code under the + terms of section 4, provided that you also meet all of these + conditions: + + a. The work must carry prominent notices stating that you + modified it, and giving a relevant date. + + b. The work must carry prominent notices stating that it is + released under this License and any conditions added under + section 7. This requirement modifies the requirement in + section 4 to "keep intact all notices". + + c. You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable + section 7 additional terms, to the whole of the work, and all + its parts, regardless of how they are packaged. This License + gives no permission to license the work in any other way, but + it does not invalidate such permission if you have separately + received it. + + d. If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has + interactive interfaces that do not display Appropriate Legal + Notices, your work need not make them do so. + + A compilation of a covered work with other separate and independent + works, which are not by their nature extensions of the covered + work, and which are not combined with it such as to form a larger + program, in or on a volume of a storage or distribution medium, is + called an "aggregate" if the compilation and its resulting + copyright are not used to limit the access or legal rights of the + compilation's users beyond what the individual works permit. + Inclusion of a covered work in an aggregate does not cause this + License to apply to the other parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms + of sections 4 and 5, provided that you also convey the + machine-readable Corresponding Source under the terms of this + License, in one of these ways: + + a. Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b. Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for + as long as you offer spare parts or customer support for that + product model, to give anyone who possesses the object code + either (1) a copy of the Corresponding Source for all the + software in the product that is covered by this License, on a + durable physical medium customarily used for software + interchange, for a price no more than your reasonable cost of + physically performing this conveying of source, or (2) access + to copy the Corresponding Source from a network server at no + charge. + + c. Convey individual copies of the object code with a copy of + the written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, + and only if you received the object code with such an offer, + in accord with subsection 6b. + + d. Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access + to the Corresponding Source in the same way through the same + place at no further charge. You need not require recipients + to copy the Corresponding Source along with the object code. + If the place to copy the object code is a network server, the + Corresponding Source may be on a different server (operated + by you or a third party) that supports equivalent copying + facilities, provided you maintain clear directions next to + the object code saying where to find the Corresponding Source. + Regardless of what server hosts the Corresponding Source, you + remain obligated to ensure that it is available for as long + as needed to satisfy these requirements. + + e. Convey the object code using peer-to-peer transmission, + provided you inform other peers where the object code and + Corresponding Source of the work are being offered to the + general public at no charge under subsection 6d. + + + A separable portion of the object code, whose source code is + excluded from the Corresponding Source as a System Library, need + not be included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means + any tangible personal property which is normally used for personal, + family, or household purposes, or (2) anything designed or sold for + incorporation into a dwelling. In determining whether a product + is a consumer product, doubtful cases shall be resolved in favor of + coverage. For a particular product received by a particular user, + "normally used" refers to a typical or common use of that class of + product, regardless of the status of the particular user or of the + way in which the particular user actually uses, or expects or is + expected to use, the product. A product is a consumer product + regardless of whether the product has substantial commercial, + industrial or non-consumer uses, unless such uses represent the + only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, + procedures, authorization keys, or other information required to + install and execute modified versions of a covered work in that + User Product from a modified version of its Corresponding Source. + The information must suffice to ensure that the continued + functioning of the modified object code is in no case prevented or + interfered with solely because modification has been made. + + If you convey an object code work under this section in, or with, + or specifically for use in, a User Product, and the conveying + occurs as part of a transaction in which the right of possession + and use of the User Product is transferred to the recipient in + perpetuity or for a fixed term (regardless of how the transaction + is characterized), the Corresponding Source conveyed under this + section must be accompanied by the Installation Information. But + this requirement does not apply if neither you nor any third party + retains the ability to install modified object code on the User + Product (for example, the work has been installed in ROM). + + The requirement to provide Installation Information does not + include a requirement to continue to provide support service, + warranty, or updates for a work that has been modified or + installed by the recipient, or for the User Product in which it + has been modified or installed. Access to a network may be denied + when the modification itself materially and adversely affects the + operation of the network or violates the rules and protocols for + communication across the network. + + Corresponding Source conveyed, and Installation Information + provided, in accord with this section must be in a format that is + publicly documented (and with an implementation available to the + public in source code form), and must require no special password + or key for unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of + this License by making exceptions from one or more of its + conditions. Additional permissions that are applicable to the + entire Program shall be treated as though they were included in + this License, to the extent that they are valid under applicable + law. If additional permissions apply only to part of the Program, + that part may be used separately under those permissions, but the + entire Program remains governed by this License without regard to + the additional permissions. + + When you convey a copy of a covered work, you may at your option + remove any additional permissions from that copy, or from any part + of it. (Additional permissions may be written to require their own + removal in certain cases when you modify the work.) You may place + additional permissions on material, added by you to a covered work, + for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material + you add to a covered work, you may (if authorized by the copyright + holders of that material) supplement the terms of this License + with terms: + + a. Disclaiming warranty or limiting liability differently from + the terms of sections 15 and 16 of this License; or + + b. Requiring preservation of specified reasonable legal notices + or author attributions in that material or in the Appropriate + Legal Notices displayed by works containing it; or + + c. Prohibiting misrepresentation of the origin of that material, + or requiring that modified versions of such material be + marked in reasonable ways as different from the original + version; or + + d. Limiting the use for publicity purposes of names of licensors + or authors of the material; or + + e. Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f. Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified + versions of it) with contractual assumptions of liability to + the recipient, for any liability that these contractual + assumptions directly impose on those licensors and authors. + + All other non-permissive additional terms are considered "further + restrictions" within the meaning of section 10. If the Program as + you received it, or any part of it, contains a notice stating that + it is governed by this License along with a term that is a further + restriction, you may remove that term. If a license document + contains a further restriction but permits relicensing or + conveying under this License, you may add to a covered work + material governed by the terms of that license document, provided + that the further restriction does not survive such relicensing or + conveying. + + If you add terms to a covered work in accord with this section, you + must place, in the relevant source files, a statement of the + additional terms that apply to those files, or a notice indicating + where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in + the form of a separately written license, or stated as exceptions; + the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly + provided under this License. Any attempt otherwise to propagate or + modify it is void, and will automatically terminate your rights + under this License (including any patent licenses granted under + the third paragraph of section 11). + + However, if you cease all violation of this License, then your + license from a particular copyright holder is reinstated (a) + provisionally, unless and until the copyright holder explicitly + and finally terminates your license, and (b) permanently, if the + copyright holder fails to notify you of the violation by some + reasonable means prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is + reinstated permanently if the copyright holder notifies you of the + violation by some reasonable means, this is the first time you have + received notice of violation of this License (for any work) from + that copyright holder, and you cure the violation prior to 30 days + after your receipt of the notice. + + Termination of your rights under this section does not terminate + the licenses of parties who have received copies or rights from + you under this License. If your rights have been terminated and + not permanently reinstated, you do not qualify to receive new + licenses for the same material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or + run a copy of the Program. Ancillary propagation of a covered work + occurring solely as a consequence of using peer-to-peer + transmission to receive a copy likewise does not require + acceptance. However, nothing other than this License grants you + permission to propagate or modify any covered work. These actions + infringe copyright if you do not accept this License. Therefore, + by modifying or propagating a covered work, you indicate your + acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically + receives a license from the original licensors, to run, modify and + propagate that work, subject to this License. You are not + responsible for enforcing compliance by third parties with this + License. + + An "entity transaction" is a transaction transferring control of an + organization, or substantially all assets of one, or subdividing an + organization, or merging organizations. If propagation of a + covered work results from an entity transaction, each party to that + transaction who receives a copy of the work also receives whatever + licenses to the work the party's predecessor in interest had or + could give under the previous paragraph, plus a right to + possession of the Corresponding Source of the work from the + predecessor in interest, if the predecessor has it or can get it + with reasonable efforts. + + You may not impose any further restrictions on the exercise of the + rights granted or affirmed under this License. For example, you + may not impose a license fee, royalty, or other charge for + exercise of rights granted under this License, and you may not + initiate litigation (including a cross-claim or counterclaim in a + lawsuit) alleging that any patent claim is infringed by making, + using, selling, offering for sale, or importing the Program or any + portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this + License of the Program or a work on which the Program is based. + The work thus licensed is called the contributor's "contributor + version". + + A contributor's "essential patent claims" are all patent claims + owned or controlled by the contributor, whether already acquired or + hereafter acquired, that would be infringed by some manner, + permitted by this License, of making, using, or selling its + contributor version, but do not include claims that would be + infringed only as a consequence of further modification of the + contributor version. For purposes of this definition, "control" + includes the right to grant patent sublicenses in a manner + consistent with the requirements of this License. + + Each contributor grants you a non-exclusive, worldwide, + royalty-free patent license under the contributor's essential + patent claims, to make, use, sell, offer for sale, import and + otherwise run, modify and propagate the contents of its + contributor version. + + In the following three paragraphs, a "patent license" is any + express agreement or commitment, however denominated, not to + enforce a patent (such as an express permission to practice a + patent or covenant not to sue for patent infringement). To + "grant" such a patent license to a party means to make such an + agreement or commitment not to enforce a patent against the party. + + If you convey a covered work, knowingly relying on a patent + license, and the Corresponding Source of the work is not available + for anyone to copy, free of charge and under the terms of this + License, through a publicly available network server or other + readily accessible means, then you must either (1) cause the + Corresponding Source to be so available, or (2) arrange to deprive + yourself of the benefit of the patent license for this particular + work, or (3) arrange, in a manner consistent with the requirements + of this License, to extend the patent license to downstream + recipients. "Knowingly relying" means you have actual knowledge + that, but for the patent license, your conveying the covered work + in a country, or your recipient's use of the covered work in a + country, would infringe one or more identifiable patents in that + country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or + arrangement, you convey, or propagate by procuring conveyance of, a + covered work, and grant a patent license to some of the parties + receiving the covered work authorizing them to use, propagate, + modify or convey a specific copy of the covered work, then the + patent license you grant is automatically extended to all + recipients of the covered work and works based on it. + + A patent license is "discriminatory" if it does not include within + the scope of its coverage, prohibits the exercise of, or is + conditioned on the non-exercise of one or more of the rights that + are specifically granted under this License. You may not convey a + covered work if you are a party to an arrangement with a third + party that is in the business of distributing software, under + which you make payment to the third party based on the extent of + your activity of conveying the work, and under which the third + party grants, to any of the parties who would receive the covered + work from you, a discriminatory patent license (a) in connection + with copies of the covered work conveyed by you (or copies made + from those copies), or (b) primarily for and in connection with + specific products or compilations that contain the covered work, + unless you entered into that arrangement, or that patent license + was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting + any implied license or other defenses to infringement that may + otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, + agreement or otherwise) that contradict the conditions of this + License, they do not excuse you from the conditions of this + License. If you cannot convey a covered work so as to satisfy + simultaneously your obligations under this License and any other + pertinent obligations, then as a consequence you may not convey it + at all. For example, if you agree to terms that obligate you to + collect a royalty for further conveying from those to whom you + convey the Program, the only way you could satisfy both those + terms and this License would be to refrain entirely from conveying + the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have + permission to link or combine any covered work with a work licensed + under version 3 of the GNU Affero General Public License into a + single combined work, and to convey the resulting work. The terms + of this License will continue to apply to the part which is the + covered work, but the special requirements of the GNU Affero + General Public License, section 13, concerning interaction through + a network will apply to the combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new + versions of the GNU General Public License from time to time. + Such new versions will be similar in spirit to the present + version, but may differ in detail to address new problems or + concerns. + + Each version is given a distinguishing version number. If the + Program specifies that a certain numbered version of the GNU + General Public License "or any later version" applies to it, you + have the option of following the terms and conditions either of + that numbered version or of any later version published by the + Free Software Foundation. If the Program does not specify a + version number of the GNU General Public License, you may choose + any version ever published by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future + versions of the GNU General Public License can be used, that + proxy's public statement of acceptance of a version permanently + authorizes you to choose that version for the Program. + + Later license versions may give you additional or different + permissions. However, no additional obligations are imposed on any + author or copyright holder as a result of your choosing to follow a + later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY + APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE + COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" + WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE + RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. + SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL + NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN + WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES + AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU + FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR + CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE + THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA + BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD + PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER + PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF + THE POSSIBILITY OF SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided + above cannot be given local legal effect according to their terms, + reviewing courts shall apply local law that most closely + approximates an absolute waiver of all civil liability in + connection with the Program, unless a warranty or assumption of + liability accompanies a copy of the Program in return for a fee. + + +END OF TERMS AND CONDITIONS +=========================== + +How to Apply These Terms to Your New Programs +============================================= + +If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES. + Copyright (C) YEAR NAME OF AUTHOR + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see `http://www.gnu.org/licenses/'. + + Also add information on how to contact you by electronic and paper +mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + PROGRAM Copyright (C) YEAR NAME OF AUTHOR + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + + The hypothetical commands `show w' and `show c' should show the +appropriate parts of the General Public License. Of course, your +program's commands might be different; for a GUI interface, you would +use an "about box". + + You should also get your employer (if you work as a programmer) or +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. For more information on this, and how to apply and follow +the GNU GPL, see `http://www.gnu.org/licenses/'. + + The GNU General Public License does not permit incorporating your +program into proprietary programs. If your program is a subroutine +library, you may consider it more useful to permit linking proprietary +applications with the library. If this is what you want to do, use the +GNU Lesser General Public License instead of this License. But first, +please read `http://www.gnu.org/philosophy/why-not-lgpl.html'. + + +File: gawk.info, Node: GNU Free Documentation License, Next: Index, Prev: Copying, Up: Top + +GNU Free Documentation License +****************************** + + Version 1.3, 3 November 2008 + + Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. + `http://fsf.org/' + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + 0. PREAMBLE + + The purpose of this License is to make a manual, textbook, or other + functional and useful document "free" in the sense of freedom: to + assure everyone the effective freedom to copy and redistribute it, + with or without modifying it, either commercially or + noncommercially. Secondarily, this License preserves for the + author and publisher a way to get credit for their work, while not + being considered responsible for modifications made by others. + + This License is a kind of "copyleft", which means that derivative + works of the document must themselves be free in the same sense. + It complements the GNU General Public License, which is a copyleft + license designed for free software. + + We have designed this License in order to use it for manuals for + free software, because free software needs free documentation: a + free program should come with manuals providing the same freedoms + that the software does. But this License is not limited to + software manuals; it can be used for any textual work, regardless + of subject matter or whether it is published as a printed book. + We recommend this License principally for works whose purpose is + instruction or reference. + + 1. APPLICABILITY AND DEFINITIONS + + This License applies to any manual or other work, in any medium, + that contains a notice placed by the copyright holder saying it + can be distributed under the terms of this License. Such a notice + grants a world-wide, royalty-free license, unlimited in duration, + to use that work under the conditions stated herein. The + "Document", below, refers to any such manual or work. Any member + of the public is a licensee, and is addressed as "you". You + accept the license if you copy, modify or distribute the work in a + way requiring permission under copyright law. + + A "Modified Version" of the Document means any work containing the + Document or a portion of it, either copied verbatim, or with + modifications and/or translated into another language. + + A "Secondary Section" is a named appendix or a front-matter section + of the Document that deals exclusively with the relationship of the + publishers or authors of the Document to the Document's overall + subject (or to related matters) and contains nothing that could + fall directly within that overall subject. (Thus, if the Document + is in part a textbook of mathematics, a Secondary Section may not + explain any mathematics.) The relationship could be a matter of + historical connection with the subject or with related matters, or + of legal, commercial, philosophical, ethical or political position + regarding them. + + The "Invariant Sections" are certain Secondary Sections whose + titles are designated, as being those of Invariant Sections, in + the notice that says that the Document is released under this + License. If a section does not fit the above definition of + Secondary then it is not allowed to be designated as Invariant. + The Document may contain zero Invariant Sections. If the Document + does not identify any Invariant Sections then there are none. + + The "Cover Texts" are certain short passages of text that are + listed, as Front-Cover Texts or Back-Cover Texts, in the notice + that says that the Document is released under this License. A + Front-Cover Text may be at most 5 words, and a Back-Cover Text may + be at most 25 words. + + A "Transparent" copy of the Document means a machine-readable copy, + represented in a format whose specification is available to the + general public, that is suitable for revising the document + straightforwardly with generic text editors or (for images + composed of pixels) generic paint programs or (for drawings) some + widely available drawing editor, and that is suitable for input to + text formatters or for automatic translation to a variety of + formats suitable for input to text formatters. A copy made in an + otherwise Transparent file format whose markup, or absence of + markup, has been arranged to thwart or discourage subsequent + modification by readers is not Transparent. An image format is + not Transparent if used for any substantial amount of text. A + copy that is not "Transparent" is called "Opaque". + + Examples of suitable formats for Transparent copies include plain + ASCII without markup, Texinfo input format, LaTeX input format, + SGML or XML using a publicly available DTD, and + standard-conforming simple HTML, PostScript or PDF designed for + human modification. Examples of transparent image formats include + PNG, XCF and JPG. Opaque formats include proprietary formats that + can be read and edited only by proprietary word processors, SGML or + XML for which the DTD and/or processing tools are not generally + available, and the machine-generated HTML, PostScript or PDF + produced by some word processors for output purposes only. + + The "Title Page" means, for a printed book, the title page itself, + plus such following pages as are needed to hold, legibly, the + material this License requires to appear in the title page. For + works in formats which do not have any title page as such, "Title + Page" means the text near the most prominent appearance of the + work's title, preceding the beginning of the body of the text. + + The "publisher" means any person or entity that distributes copies + of the Document to the public. + + A section "Entitled XYZ" means a named subunit of the Document + whose title either is precisely XYZ or contains XYZ in parentheses + following text that translates XYZ in another language. (Here XYZ + stands for a specific section name mentioned below, such as + "Acknowledgements", "Dedications", "Endorsements", or "History".) + To "Preserve the Title" of such a section when you modify the + Document means that it remains a section "Entitled XYZ" according + to this definition. + + The Document may include Warranty Disclaimers next to the notice + which states that this License applies to the Document. These + Warranty Disclaimers are considered to be included by reference in + this License, but only as regards disclaiming warranties: any other + implication that these Warranty Disclaimers may have is void and + has no effect on the meaning of this License. + + 2. VERBATIM COPYING + + You may copy and distribute the Document in any medium, either + commercially or noncommercially, provided that this License, the + copyright notices, and the license notice saying this License + applies to the Document are reproduced in all copies, and that you + add no other conditions whatsoever to those of this License. You + may not use technical measures to obstruct or control the reading + or further copying of the copies you make or distribute. However, + you may accept compensation in exchange for copies. If you + distribute a large enough number of copies you must also follow + the conditions in section 3. + + You may also lend copies, under the same conditions stated above, + and you may publicly display copies. + + 3. COPYING IN QUANTITY + + If you publish printed copies (or copies in media that commonly + have printed covers) of the Document, numbering more than 100, and + the Document's license notice requires Cover Texts, you must + enclose the copies in covers that carry, clearly and legibly, all + these Cover Texts: Front-Cover Texts on the front cover, and + Back-Cover Texts on the back cover. Both covers must also clearly + and legibly identify you as the publisher of these copies. The + front cover must present the full title with all words of the + title equally prominent and visible. You may add other material + on the covers in addition. Copying with changes limited to the + covers, as long as they preserve the title of the Document and + satisfy these conditions, can be treated as verbatim copying in + other respects. + + If the required texts for either cover are too voluminous to fit + legibly, you should put the first ones listed (as many as fit + reasonably) on the actual cover, and continue the rest onto + adjacent pages. + + If you publish or distribute Opaque copies of the Document + numbering more than 100, you must either include a + machine-readable Transparent copy along with each Opaque copy, or + state in or with each Opaque copy a computer-network location from + which the general network-using public has access to download + using public-standard network protocols a complete Transparent + copy of the Document, free of added material. If you use the + latter option, you must take reasonably prudent steps, when you + begin distribution of Opaque copies in quantity, to ensure that + this Transparent copy will remain thus accessible at the stated + location until at least one year after the last time you + distribute an Opaque copy (directly or through your agents or + retailers) of that edition to the public. + + It is requested, but not required, that you contact the authors of + the Document well before redistributing any large number of + copies, to give them a chance to provide you with an updated + version of the Document. + + 4. MODIFICATIONS + + You may copy and distribute a Modified Version of the Document + under the conditions of sections 2 and 3 above, provided that you + release the Modified Version under precisely this License, with + the Modified Version filling the role of the Document, thus + licensing distribution and modification of the Modified Version to + whoever possesses a copy of it. In addition, you must do these + things in the Modified Version: + + A. Use in the Title Page (and on the covers, if any) a title + distinct from that of the Document, and from those of + previous versions (which should, if there were any, be listed + in the History section of the Document). You may use the + same title as a previous version if the original publisher of + that version gives permission. + + B. List on the Title Page, as authors, one or more persons or + entities responsible for authorship of the modifications in + the Modified Version, together with at least five of the + principal authors of the Document (all of its principal + authors, if it has fewer than five), unless they release you + from this requirement. + + C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. + + D. Preserve all the copyright notices of the Document. + + E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. + + F. Include, immediately after the copyright notices, a license + notice giving the public permission to use the Modified + Version under the terms of this License, in the form shown in + the Addendum below. + + G. Preserve in that license notice the full lists of Invariant + Sections and required Cover Texts given in the Document's + license notice. + + H. Include an unaltered copy of this License. + + I. Preserve the section Entitled "History", Preserve its Title, + and add to it an item stating at least the title, year, new + authors, and publisher of the Modified Version as given on + the Title Page. If there is no section Entitled "History" in + the Document, create one stating the title, year, authors, + and publisher of the Document as given on its Title Page, + then add an item describing the Modified Version as stated in + the previous sentence. + + J. Preserve the network location, if any, given in the Document + for public access to a Transparent copy of the Document, and + likewise the network locations given in the Document for + previous versions it was based on. These may be placed in + the "History" section. You may omit a network location for a + work that was published at least four years before the + Document itself, or if the original publisher of the version + it refers to gives permission. + + K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the + section all the substance and tone of each of the contributor + acknowledgements and/or dedications given therein. + + L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section + titles. + + M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. + + N. Do not retitle any existing section to be Entitled + "Endorsements" or to conflict in title with any Invariant + Section. + + O. Preserve any Warranty Disclaimers. + + If the Modified Version includes new front-matter sections or + appendices that qualify as Secondary Sections and contain no + material copied from the Document, you may at your option + designate some or all of these sections as invariant. To do this, + add their titles to the list of Invariant Sections in the Modified + Version's license notice. These titles must be distinct from any + other section titles. + + You may add a section Entitled "Endorsements", provided it contains + nothing but endorsements of your Modified Version by various + parties--for example, statements of peer review or that the text + has been approved by an organization as the authoritative + definition of a standard. + + You may add a passage of up to five words as a Front-Cover Text, + and a passage of up to 25 words as a Back-Cover Text, to the end + of the list of Cover Texts in the Modified Version. Only one + passage of Front-Cover Text and one of Back-Cover Text may be + added by (or through arrangements made by) any one entity. If the + Document already includes a cover text for the same cover, + previously added by you or by arrangement made by the same entity + you are acting on behalf of, you may not add another; but you may + replace the old one, on explicit permission from the previous + publisher that added the old one. + + The author(s) and publisher(s) of the Document do not by this + License give permission to use their names for publicity for or to + assert or imply endorsement of any Modified Version. + + 5. COMBINING DOCUMENTS + + You may combine the Document with other documents released under + this License, under the terms defined in section 4 above for + modified versions, provided that you include in the combination + all of the Invariant Sections of all of the original documents, + unmodified, and list them all as Invariant Sections of your + combined work in its license notice, and that you preserve all + their Warranty Disclaimers. + + The combined work need only contain one copy of this License, and + multiple identical Invariant Sections may be replaced with a single + copy. If there are multiple Invariant Sections with the same name + but different contents, make the title of each such section unique + by adding at the end of it, in parentheses, the name of the + original author or publisher of that section if known, or else a + unique number. Make the same adjustment to the section titles in + the list of Invariant Sections in the license notice of the + combined work. + + In the combination, you must combine any sections Entitled + "History" in the various original documents, forming one section + Entitled "History"; likewise combine any sections Entitled + "Acknowledgements", and any sections Entitled "Dedications". You + must delete all sections Entitled "Endorsements." + + 6. COLLECTIONS OF DOCUMENTS + + You may make a collection consisting of the Document and other + documents released under this License, and replace the individual + copies of this License in the various documents with a single copy + that is included in the collection, provided that you follow the + rules of this License for verbatim copying of each of the + documents in all other respects. + + You may extract a single document from such a collection, and + distribute it individually under this License, provided you insert + a copy of this License into the extracted document, and follow + this License in all other respects regarding verbatim copying of + that document. + + 7. AGGREGATION WITH INDEPENDENT WORKS + + A compilation of the Document or its derivatives with other + separate and independent documents or works, in or on a volume of + a storage or distribution medium, is called an "aggregate" if the + copyright resulting from the compilation is not used to limit the + legal rights of the compilation's users beyond what the individual + works permit. When the Document is included in an aggregate, this + License does not apply to the other works in the aggregate which + are not themselves derivative works of the Document. + + If the Cover Text requirement of section 3 is applicable to these + copies of the Document, then if the Document is less than one half + of the entire aggregate, the Document's Cover Texts may be placed + on covers that bracket the Document within the aggregate, or the + electronic equivalent of covers if the Document is in electronic + form. Otherwise they must appear on printed covers that bracket + the whole aggregate. + + 8. TRANSLATION + + Translation is considered a kind of modification, so you may + distribute translations of the Document under the terms of section + 4. Replacing Invariant Sections with translations requires special + permission from their copyright holders, but you may include + translations of some or all Invariant Sections in addition to the + original versions of these Invariant Sections. You may include a + translation of this License, and all the license notices in the + Document, and any Warranty Disclaimers, provided that you also + include the original English version of this License and the + original versions of those notices and disclaimers. In case of a + disagreement between the translation and the original version of + this License or a notice or disclaimer, the original version will + prevail. + + If a section in the Document is Entitled "Acknowledgements", + "Dedications", or "History", the requirement (section 4) to + Preserve its Title (section 1) will typically require changing the + actual title. + + 9. TERMINATION + + You may not copy, modify, sublicense, or distribute the Document + except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense, or distribute it is void, + and will automatically terminate your rights under this License. + + However, if you cease all violation of this License, then your + license from a particular copyright holder is reinstated (a) + provisionally, unless and until the copyright holder explicitly + and finally terminates your license, and (b) permanently, if the + copyright holder fails to notify you of the violation by some + reasonable means prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is + reinstated permanently if the copyright holder notifies you of the + violation by some reasonable means, this is the first time you have + received notice of violation of this License (for any work) from + that copyright holder, and you cure the violation prior to 30 days + after your receipt of the notice. + + Termination of your rights under this section does not terminate + the licenses of parties who have received copies or rights from + you under this License. If your rights have been terminated and + not permanently reinstated, receipt of a copy of some or all of + the same material does not give you any rights to use it. + + 10. FUTURE REVISIONS OF THIS LICENSE + + The Free Software Foundation may publish new, revised versions of + the GNU Free Documentation License from time to time. Such new + versions will be similar in spirit to the present version, but may + differ in detail to address new problems or concerns. See + `http://www.gnu.org/copyleft/'. + + Each version of the License is given a distinguishing version + number. If the Document specifies that a particular numbered + version of this License "or any later version" applies to it, you + have the option of following the terms and conditions either of + that specified version or of any later version that has been + published (not as a draft) by the Free Software Foundation. If + the Document does not specify a version number of this License, + you may choose any version ever published (not as a draft) by the + Free Software Foundation. If the Document specifies that a proxy + can decide which future versions of this License can be used, that + proxy's public statement of acceptance of a version permanently + authorizes you to choose that version for the Document. + + 11. RELICENSING + + "Massive Multiauthor Collaboration Site" (or "MMC Site") means any + World Wide Web server that publishes copyrightable works and also + provides prominent facilities for anybody to edit those works. A + public wiki that anybody can edit is an example of such a server. + A "Massive Multiauthor Collaboration" (or "MMC") contained in the + site means any set of copyrightable works thus published on the MMC + site. + + "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 + license published by Creative Commons Corporation, a not-for-profit + corporation with a principal place of business in San Francisco, + California, as well as future copyleft versions of that license + published by that same organization. + + "Incorporate" means to publish or republish a Document, in whole or + in part, as part of another Document. + + An MMC is "eligible for relicensing" if it is licensed under this + License, and if all works that were first published under this + License somewhere other than this MMC, and subsequently + incorporated in whole or in part into the MMC, (1) had no cover + texts or invariant sections, and (2) were thus incorporated prior + to November 1, 2008. + + The operator of an MMC Site may republish an MMC contained in the + site under CC-BY-SA on the same site at any time before August 1, + 2009, provided the MMC is eligible for relicensing. + + +ADDENDUM: How to use this License for your documents +==================================================== + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and license +notices just after the title page: + + Copyright (C) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover + Texts. A copy of the license is included in the section entitled ``GNU + Free Documentation License''. + + If you have Invariant Sections, Front-Cover Texts and Back-Cover +Texts, replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with + the Front-Cover Texts being LIST, and with the Back-Cover Texts + being LIST. + + If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + + If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, to +permit their use in free software. + + +File: gawk.info, Node: Index, Prev: GNU Free Documentation License, Up: Top + +Index +***** + +[index] +* Menu: + +* ! (exclamation point), ! operator: Boolean Ops. (line 67) +* ! (exclamation point), ! operator <1>: Egrep Program. (line 170) +* ! (exclamation point), ! operator <2>: Ranges. (line 48) +* ! (exclamation point), ! operator: Precedence. (line 52) +* ! (exclamation point), != operator <1>: Precedence. (line 65) +* ! (exclamation point), != operator: Comparison Operators. + (line 11) +* ! (exclamation point), !~ operator <1>: Expression Patterns. + (line 24) +* ! (exclamation point), !~ operator <2>: Precedence. (line 80) +* ! (exclamation point), !~ operator <3>: Comparison Operators. + (line 11) +* ! (exclamation point), !~ operator <4>: Regexp Constants. (line 6) +* ! (exclamation point), !~ operator <5>: Computed Regexps. (line 6) +* ! (exclamation point), !~ operator <6>: Case-sensitivity. (line 26) +* ! (exclamation point), !~ operator: Regexp Usage. (line 19) +* " (double quote) <1>: Quoting. (line 37) +* " (double quote): Read Terminal. (line 25) +* " (double quote), regexp constants: Computed Regexps. (line 28) +* # (number sign), #! (executable scripts): Executable Scripts. + (line 6) +* # (number sign), #! (executable scripts), portability issues with: Executable Scripts. + (line 6) +* # (number sign), commenting: Comments. (line 6) +* $ (dollar sign): Regexp Operators. (line 35) +* $ (dollar sign), $ field operator <1>: Precedence. (line 43) +* $ (dollar sign), $ field operator: Fields. (line 19) +* $ (dollar sign), incrementing fields and arrays: Increment Ops. + (line 30) +* % (percent sign), % operator: Precedence. (line 55) +* % (percent sign), %= operator <1>: Precedence. (line 95) +* % (percent sign), %= operator: Assignment Ops. (line 129) +* & (ampersand), && operator <1>: Precedence. (line 86) +* & (ampersand), && operator: Boolean Ops. (line 57) +* & (ampersand), gsub()/gensub()/sub() functions and: Gory Details. + (line 6) +* ' (single quote) <1>: Quoting. (line 31) +* ' (single quote) <2>: Long. (line 33) +* ' (single quote): One-shot. (line 15) +* ' (single quote), vs. apostrophe: Comments. (line 27) +* ' (single quote), with double quotes: Quoting. (line 53) +* () (parentheses): Regexp Operators. (line 79) +* () (parentheses), pgawk program: Profiling. (line 141) +* * (asterisk), * operator, as multiplication operator: Precedence. + (line 55) +* * (asterisk), * operator, as regexp operator: Regexp Operators. + (line 87) +* * (asterisk), * operator, null strings, matching: Gory Details. + (line 164) +* * (asterisk), ** operator <1>: Precedence. (line 49) +* * (asterisk), ** operator: Arithmetic Ops. (line 81) +* * (asterisk), **= operator <1>: Precedence. (line 95) +* * (asterisk), **= operator: Assignment Ops. (line 129) +* * (asterisk), *= operator <1>: Precedence. (line 95) +* * (asterisk), *= operator: Assignment Ops. (line 129) +* + (plus sign): Regexp Operators. (line 102) +* + (plus sign), + operator: Precedence. (line 52) +* + (plus sign), ++ (decrement/increment operators): Increment Ops. + (line 11) +* + (plus sign), ++ operator <1>: Precedence. (line 46) +* + (plus sign), ++ operator: Increment Ops. (line 40) +* + (plus sign), += operator <1>: Precedence. (line 95) +* + (plus sign), += operator: Assignment Ops. (line 82) +* , (comma), in range patterns: Ranges. (line 6) +* - (hyphen), - operator: Precedence. (line 52) +* - (hyphen), -- (decrement/increment) operator: Precedence. (line 46) +* - (hyphen), -- operator: Increment Ops. (line 48) +* - (hyphen), -= operator <1>: Precedence. (line 95) +* - (hyphen), -= operator: Assignment Ops. (line 129) +* - (hyphen), filenames beginning with: Options. (line 59) +* - (hyphen), in bracket expressions: Bracket Expressions. (line 17) +* --assign option: Options. (line 32) +* --c option: Options. (line 78) +* --characters-as-bytes option: Options. (line 68) +* --command option: Options. (line 231) +* --copyright option: Options. (line 85) +* --disable-lint configuration option: Additional Configuration Options. + (line 9) +* --disable-nls configuration option: Additional Configuration Options. + (line 24) +* --dump-variables option <1>: Library Names. (line 45) +* --dump-variables option: Options. (line 90) +* --exec option: Options. (line 113) +* --field-separator option: Options. (line 21) +* --file option: Options. (line 25) +* --gen-pot option <1>: String Extraction. (line 6) +* --gen-pot option: Options. (line 135) +* --help option: Options. (line 142) +* --L option: Options. (line 245) +* --lint option <1>: Options. (line 147) +* --lint option: Command Line. (line 20) +* --lint-old option: Options. (line 245) +* --non-decimal-data option <1>: Nondecimal Data. (line 6) +* --non-decimal-data option: Options. (line 166) +* --non-decimal-data option, strtonum() function and: Nondecimal Data. + (line 36) +* --optimize option: Options. (line 179) +* --posix option: Options. (line 199) +* --posix option, --traditional option and: Options. (line 218) +* --profile option <1>: Profiling. (line 15) +* --profile option: Options. (line 186) +* --re-interval option: Options. (line 224) +* --sandbox option: Options. (line 236) +* --sandbox option, disabling system() function: I/O Functions. + (line 85) +* --sandbox option, input redirection with getline: Getline. (line 19) +* --sandbox option, output redirection with print, printf: Redirection. + (line 6) +* --source option: Options. (line 105) +* --traditional option: Options. (line 78) +* --traditional option, --posix option and: Options. (line 218) +* --use-lc-numeric option: Options. (line 174) +* --version option: Options. (line 250) +* --with-whiny-user-strftime configuration option: Additional Configuration Options. + (line 29) +* -b option: Options. (line 68) +* -C option: Options. (line 85) +* -d option: Options. (line 90) +* -E option: Options. (line 113) +* -e option: Options. (line 105) +* -F option: Command Line Field Separator. + (line 6) +* -f option: Options. (line 25) +* -F option: Options. (line 21) +* -f option: Long. (line 12) +* -F option, -Ft sets FS to TAB: Options. (line 258) +* -f option, on command line: Options. (line 263) +* -g option: Options. (line 135) +* -h option: Options. (line 142) +* -l option: Options. (line 147) +* -N option: Options. (line 174) +* -n option: Options. (line 166) +* -O option: Options. (line 179) +* -P option: Options. (line 199) +* -p option: Options. (line 186) +* -R option: Options. (line 231) +* -r option: Options. (line 224) +* -S option: Options. (line 236) +* -V option: Options. (line 250) +* -v option: Options. (line 32) +* -v option, variables, assigning: Assignment Options. (line 12) +* -W option: Options. (line 46) +* . (period): Regexp Operators. (line 43) +* .mo files: Explaining gettext. (line 41) +* .mo files, converting from .po: I18N Example. (line 62) +* .mo files, specifying directory of <1>: Programmer i18n. (line 47) +* .mo files, specifying directory of: Explaining gettext. (line 53) +* .po files <1>: Translator i18n. (line 6) +* .po files: Explaining gettext. (line 36) +* .po files, converting to .mo: I18N Example. (line 62) +* .pot files: Explaining gettext. (line 30) +* / (forward slash): Regexp. (line 10) +* / (forward slash), / operator: Precedence. (line 55) +* / (forward slash), /= operator <1>: Precedence. (line 95) +* / (forward slash), /= operator: Assignment Ops. (line 129) +* / (forward slash), /= operator, vs. /=.../ regexp constant: Assignment Ops. + (line 148) +* / (forward slash), patterns and: Expression Patterns. (line 24) +* /= operator vs. /=.../ regexp constant: Assignment Ops. (line 148) +* /dev/... special files (gawk): Special FD. (line 46) +* /dev/fd/N special files: Special FD. (line 46) +* /inet/... special files (gawk): TCP/IP Networking. (line 6) +* /inet4/... special files (gawk): TCP/IP Networking. (line 6) +* /inet6/... special files (gawk): TCP/IP Networking. (line 6) +* ; (semicolon): Statements/Lines. (line 91) +* ; (semicolon), AWKPATH variable and: PC Using. (line 11) +* ; (semicolon), separating statements in actions <1>: Statements. + (line 10) +* ; (semicolon), separating statements in actions: Action Overview. + (line 19) +* < (left angle bracket), < operator <1>: Precedence. (line 65) +* < (left angle bracket), < operator: Comparison Operators. + (line 11) +* < (left angle bracket), < operator (I/O): Getline/File. (line 6) +* < (left angle bracket), <= operator <1>: Precedence. (line 65) +* < (left angle bracket), <= operator: Comparison Operators. + (line 11) +* = (equals sign), = operator: Assignment Ops. (line 6) +* = (equals sign), == operator <1>: Precedence. (line 65) +* = (equals sign), == operator: Comparison Operators. + (line 11) +* > (right angle bracket), > operator <1>: Precedence. (line 65) +* > (right angle bracket), > operator: Comparison Operators. + (line 11) +* > (right angle bracket), > operator (I/O): Redirection. (line 22) +* > (right angle bracket), >= operator <1>: Precedence. (line 65) +* > (right angle bracket), >= operator: Comparison Operators. + (line 11) +* > (right angle bracket), >> operator (I/O) <1>: Precedence. (line 65) +* > (right angle bracket), >> operator (I/O): Redirection. (line 50) +* ? (question mark) regexp operator <1>: GNU Regexp Operators. + (line 59) +* ? (question mark) regexp operator: Regexp Operators. (line 111) +* ? (question mark), ?: operator: Precedence. (line 92) +* [] (square brackets): Regexp Operators. (line 55) +* \ (backslash) <1>: Regexp Operators. (line 18) +* \ (backslash) <2>: Quoting. (line 31) +* \ (backslash) <3>: Comments. (line 50) +* \ (backslash): Read Terminal. (line 25) +* \ (backslash), \" escape sequence: Escape Sequences. (line 76) +* \ (backslash), \' operator (gawk): GNU Regexp Operators. + (line 56) +* \ (backslash), \/ escape sequence: Escape Sequences. (line 69) +* \ (backslash), \< operator (gawk): GNU Regexp Operators. + (line 30) +* \ (backslash), \> operator (gawk): GNU Regexp Operators. + (line 34) +* \ (backslash), \` operator (gawk): GNU Regexp Operators. + (line 54) +* \ (backslash), \a escape sequence: Escape Sequences. (line 34) +* \ (backslash), \b escape sequence: Escape Sequences. (line 38) +* \ (backslash), \B operator (gawk): GNU Regexp Operators. + (line 43) +* \ (backslash), \f escape sequence: Escape Sequences. (line 41) +* \ (backslash), \n escape sequence: Escape Sequences. (line 44) +* \ (backslash), \NNN escape sequence: Escape Sequences. (line 56) +* \ (backslash), \r escape sequence: Escape Sequences. (line 47) +* \ (backslash), \S operator (gawk): GNU Regexp Operators. + (line 17) +* \ (backslash), \s operator (gawk): GNU Regexp Operators. + (line 13) +* \ (backslash), \t escape sequence: Escape Sequences. (line 50) +* \ (backslash), \v escape sequence: Escape Sequences. (line 53) +* \ (backslash), \W operator (gawk): GNU Regexp Operators. + (line 26) +* \ (backslash), \w operator (gawk): GNU Regexp Operators. + (line 21) +* \ (backslash), \x escape sequence: Escape Sequences. (line 61) +* \ (backslash), \y operator (gawk): GNU Regexp Operators. + (line 38) +* \ (backslash), as field separators: Command Line Field Separator. + (line 27) +* \ (backslash), continuing lines and <1>: Egrep Program. (line 220) +* \ (backslash), continuing lines and: Statements/Lines. (line 19) +* \ (backslash), continuing lines and, comments and: Statements/Lines. + (line 76) +* \ (backslash), continuing lines and, in csh: Statements/Lines. + (line 44) +* \ (backslash), gsub()/gensub()/sub() functions and: Gory Details. + (line 6) +* \ (backslash), in bracket expressions: Bracket Expressions. (line 17) +* \ (backslash), in escape sequences: Escape Sequences. (line 6) +* \ (backslash), in escape sequences, POSIX and: Escape Sequences. + (line 113) +* \ (backslash), regexp constants: Computed Regexps. (line 28) +* ^ (caret) <1>: GNU Regexp Operators. + (line 59) +* ^ (caret): Regexp Operators. (line 22) +* ^ (caret), ^ operator: Precedence. (line 49) +* ^ (caret), ^= operator <1>: Precedence. (line 95) +* ^ (caret), ^= operator: Assignment Ops. (line 129) +* ^ (caret), in bracket expressions: Bracket Expressions. (line 17) +* ^, in FS: Regexp Field Splitting. + (line 59) +* _ (underscore), _ C macro: Explaining gettext. (line 70) +* _ (underscore), in names of private variables: Library Names. + (line 29) +* _ (underscore), translatable string: Programmer i18n. (line 69) +* _gr_init() user-defined function: Group Functions. (line 82) +* _pw_init() user-defined function: Passwd Functions. (line 105) +* accessing fields: Fields. (line 6) +* account information <1>: Group Functions. (line 6) +* account information: Passwd Functions. (line 16) +* actions: Action Overview. (line 6) +* actions, control statements in: Statements. (line 6) +* actions, default: Very Simple. (line 34) +* actions, empty: Very Simple. (line 39) +* Ada programming language: Glossary. (line 20) +* adding, features to gawk: Adding Code. (line 6) +* adding, fields: Changing Fields. (line 53) +* adding, functions to gawk: Dynamic Extensions. (line 10) +* advanced features, buffering: I/O Functions. (line 98) +* advanced features, close() function: Close Files And Pipes. + (line 131) +* advanced features, constants, values of: Nondecimal-numbers. + (line 67) +* advanced features, data files as single record: Records. (line 175) +* advanced features, fixed-width data: Constant Size. (line 9) +* advanced features, FNR/NR variables: Auto-set. (line 207) +* advanced features, gawk: Advanced Features. (line 6) +* advanced features, gawk, network programming: TCP/IP Networking. + (line 6) +* advanced features, gawk, nondecimal input data: Nondecimal Data. + (line 6) +* advanced features, gawk, processes, communicating with: Two-way I/O. + (line 23) +* advanced features, network connections, See Also networks, connections: Advanced Features. + (line 6) +* advanced features, null strings, matching: Gory Details. (line 164) +* advanced features, operators, precedence: Increment Ops. (line 61) +* advanced features, piping into sh: Redirection. (line 143) +* advanced features, regexp constants: Assignment Ops. (line 148) +* advanced features, specifying field content: Splitting By Content. + (line 9) +* Aho, Alfred <1>: Contributors. (line 12) +* Aho, Alfred: History. (line 17) +* alarm clock example program: Alarm Program. (line 9) +* alarm.awk program: Alarm Program. (line 29) +* algorithms: Basic High Level. (line 66) +* Alpha (DEC): Manual History. (line 28) +* amazing awk assembler (aaa): Glossary. (line 12) +* amazingly workable formatter (awf): Glossary. (line 25) +* ambiguity, syntactic: /= operator vs. /=.../ regexp constant: Assignment Ops. + (line 148) +* ampersand (&), && operator <1>: Precedence. (line 86) +* ampersand (&), && operator: Boolean Ops. (line 57) +* ampersand (&), gsub()/gensub()/sub() functions and: Gory Details. + (line 6) +* anagram.awk program: Anagram Program. (line 22) +* AND bitwise operation: Bitwise Functions. (line 6) +* and Boolean-logic operator: Boolean Ops. (line 6) +* and() function (gawk): Bitwise Functions. (line 39) +* ANSI: Glossary. (line 35) +* archeologists: Bugs. (line 6) +* ARGC/ARGV variables <1>: ARGC and ARGV. (line 6) +* ARGC/ARGV variables: Auto-set. (line 11) +* ARGC/ARGV variables, command-line arguments: Other Arguments. + (line 12) +* ARGC/ARGV variables, portability and: Executable Scripts. (line 43) +* ARGIND variable: Auto-set. (line 40) +* ARGIND variable, command-line arguments: Other Arguments. (line 12) +* arguments, command-line <1>: ARGC and ARGV. (line 6) +* arguments, command-line <2>: Auto-set. (line 11) +* arguments, command-line: Other Arguments. (line 6) +* arguments, command-line, invoking awk: Command Line. (line 6) +* arguments, in function calls: Function Calls. (line 16) +* arguments, processing: Getopt Function. (line 6) +* arguments, retrieving: Internals. (line 120) +* arithmetic operators: Arithmetic Ops. (line 6) +* arrays: Arrays. (line 6) +* arrays, as parameters to functions: Pass By Value/Reference. + (line 47) +* arrays, associative: Array Intro. (line 50) +* arrays, associative, clearing: Internals. (line 75) +* arrays, associative, library functions and: Library Names. (line 57) +* arrays, deleting entire contents: Delete. (line 39) +* arrays, elements, assigning: Assigning Elements. (line 6) +* arrays, elements, deleting: Delete. (line 6) +* arrays, elements, installing: Internals. (line 79) +* arrays, elements, order of: Scanning an Array. (line 48) +* arrays, elements, referencing: Reference to Elements. + (line 6) +* arrays, elements, retrieving number of: String Functions. (line 29) +* arrays, for statement and: Scanning an Array. (line 20) +* arrays, IGNORECASE variable and: Array Intro. (line 92) +* arrays, indexing: Array Intro. (line 50) +* arrays, merging into strings: Join Function. (line 6) +* arrays, multidimensional: Multi-dimensional. (line 10) +* arrays, multidimensional, scanning: Multi-scanning. (line 11) +* arrays, names of: Arrays. (line 18) +* arrays, scanning: Scanning an Array. (line 6) +* arrays, sorting: Array Sorting Functions. + (line 6) +* arrays, sorting, IGNORECASE variable and: Array Sorting Functions. + (line 81) +* arrays, sparse: Array Intro. (line 71) +* arrays, subscripts: Numeric Array Subscripts. + (line 6) +* arrays, subscripts, uninitialized variables as: Uninitialized Subscripts. + (line 6) +* artificial intelligence, gawk and: Distribution contents. + (line 55) +* ASCII <1>: Glossary. (line 141) +* ASCII: Ordinal Functions. (line 45) +* asort() function (gawk) <1>: Array Sorting Functions. + (line 6) +* asort() function (gawk): String Functions. (line 29) +* asort() function (gawk), arrays, sorting: Array Sorting Functions. + (line 6) +* asorti() function (gawk): String Functions. (line 77) +* assert() function (C library): Assert Function. (line 6) +* assert() user-defined function: Assert Function. (line 28) +* assertions: Assert Function. (line 6) +* assignment operators: Assignment Ops. (line 6) +* assignment operators, evaluation order: Assignment Ops. (line 111) +* assignment operators, lvalues/rvalues: Assignment Ops. (line 32) +* assignments as filenames: Ignoring Assigns. (line 6) +* assoc_clear() internal function: Internals. (line 75) +* assoc_lookup() internal function: Internals. (line 79) +* associative arrays: Array Intro. (line 50) +* asterisk (*), * operator, as multiplication operator: Precedence. + (line 55) +* asterisk (*), * operator, as regexp operator: Regexp Operators. + (line 87) +* asterisk (*), * operator, null strings, matching: Gory Details. + (line 164) +* asterisk (*), ** operator <1>: Precedence. (line 49) +* asterisk (*), ** operator: Arithmetic Ops. (line 81) +* asterisk (*), **= operator <1>: Precedence. (line 95) +* asterisk (*), **= operator: Assignment Ops. (line 129) +* asterisk (*), *= operator <1>: Precedence. (line 95) +* asterisk (*), *= operator: Assignment Ops. (line 129) +* atan2() function: Numeric Functions. (line 11) +* awf (amazingly workable formatter) program: Glossary. (line 25) +* awk language, POSIX version: Assignment Ops. (line 136) +* awk programs <1>: Two Rules. (line 6) +* awk programs <2>: Executable Scripts. (line 6) +* awk programs: Getting Started. (line 12) +* awk programs, complex: When. (line 29) +* awk programs, documenting <1>: Library Names. (line 6) +* awk programs, documenting: Comments. (line 6) +* awk programs, examples of: Sample Programs. (line 6) +* awk programs, execution of: Next Statement. (line 16) +* awk programs, internationalizing <1>: Programmer i18n. (line 6) +* awk programs, internationalizing: I18N Functions. (line 6) +* awk programs, lengthy: Long. (line 6) +* awk programs, lengthy, assertions: Assert Function. (line 6) +* awk programs, location of: Options. (line 25) +* awk programs, one-line examples: Very Simple. (line 45) +* awk programs, profiling: Profiling. (line 6) +* awk programs, profiling, enabling: Options. (line 186) +* awk programs, running <1>: Long. (line 6) +* awk programs, running: Running gawk. (line 6) +* awk programs, running, from shell scripts: One-shot. (line 22) +* awk programs, running, without input files: Read Terminal. (line 17) +* awk programs, shell variables in: Using Shell Variables. + (line 6) +* awk, function of: Getting Started. (line 6) +* awk, gawk and <1>: This Manual. (line 14) +* awk, gawk and: Preface. (line 23) +* awk, history of: History. (line 17) +* awk, implementation issues, pipes: Redirection. (line 135) +* awk, implementations: Other Versions. (line 6) +* awk, implementations, limits: Getline Notes. (line 14) +* awk, invoking: Command Line. (line 6) +* awk, new vs. old: Names. (line 6) +* awk, new vs. old, OFMT variable: Conversion. (line 55) +* awk, POSIX and: Preface. (line 23) +* awk, POSIX and, See Also POSIX awk: Preface. (line 23) +* awk, regexp constants and: Comparison Operators. + (line 103) +* awk, See Also gawk: Preface. (line 36) +* awk, terms describing: This Manual. (line 6) +* awk, uses for <1>: When. (line 6) +* awk, uses for <2>: Getting Started. (line 12) +* awk, uses for: Preface. (line 23) +* awk, versions of <1>: V7/SVR3.1. (line 6) +* awk, versions of: Names. (line 10) +* awk, versions of, changes between SVR3.1 and SVR4: SVR4. (line 6) +* awk, versions of, changes between SVR4 and POSIX awk: POSIX. + (line 6) +* awk, versions of, changes between V7 and SVR3.1: V7/SVR3.1. (line 6) +* awk, versions of, See Also Brian Kernighan's awk <1>: Other Versions. + (line 13) +* awk, versions of, See Also Brian Kernighan's awk: BTL. (line 6) +* awk.h file (internal): Internals. (line 15) +* awka compiler for awk: Other Versions. (line 55) +* AWKNUM internal type: Internals. (line 19) +* AWKPATH environment variable <1>: PC Using. (line 11) +* AWKPATH environment variable: AWKPATH Variable. (line 6) +* awkprof.out file: Profiling. (line 10) +* awksed.awk program: Simple Sed. (line 25) +* awkvars.out file: Options. (line 90) +* b debugger command (alias for break): Breakpoint Control. (line 11) +* backslash (\) <1>: Regexp Operators. (line 18) +* backslash (\) <2>: Quoting. (line 31) +* backslash (\) <3>: Comments. (line 50) +* backslash (\): Read Terminal. (line 25) +* backslash (\), \" escape sequence: Escape Sequences. (line 76) +* backslash (\), \' operator (gawk): GNU Regexp Operators. + (line 56) +* backslash (\), \/ escape sequence: Escape Sequences. (line 69) +* backslash (\), \< operator (gawk): GNU Regexp Operators. + (line 30) +* backslash (\), \> operator (gawk): GNU Regexp Operators. + (line 34) +* backslash (\), \` operator (gawk): GNU Regexp Operators. + (line 54) +* backslash (\), \a escape sequence: Escape Sequences. (line 34) +* backslash (\), \b escape sequence: Escape Sequences. (line 38) +* backslash (\), \B operator (gawk): GNU Regexp Operators. + (line 43) +* backslash (\), \f escape sequence: Escape Sequences. (line 41) +* backslash (\), \n escape sequence: Escape Sequences. (line 44) +* backslash (\), \NNN escape sequence: Escape Sequences. (line 56) +* backslash (\), \r escape sequence: Escape Sequences. (line 47) +* backslash (\), \S operator (gawk): GNU Regexp Operators. + (line 17) +* backslash (\), \s operator (gawk): GNU Regexp Operators. + (line 13) +* backslash (\), \t escape sequence: Escape Sequences. (line 50) +* backslash (\), \v escape sequence: Escape Sequences. (line 53) +* backslash (\), \W operator (gawk): GNU Regexp Operators. + (line 26) +* backslash (\), \w operator (gawk): GNU Regexp Operators. + (line 21) +* backslash (\), \x escape sequence: Escape Sequences. (line 61) +* backslash (\), \y operator (gawk): GNU Regexp Operators. + (line 38) +* backslash (\), as field separators: Command Line Field Separator. + (line 27) +* backslash (\), continuing lines and <1>: Egrep Program. (line 220) +* backslash (\), continuing lines and: Statements/Lines. (line 19) +* backslash (\), continuing lines and, comments and: Statements/Lines. + (line 76) +* backslash (\), continuing lines and, in csh: Statements/Lines. + (line 44) +* backslash (\), gsub()/gensub()/sub() functions and: Gory Details. + (line 6) +* backslash (\), in bracket expressions: Bracket Expressions. (line 17) +* backslash (\), in escape sequences: Escape Sequences. (line 6) +* backslash (\), in escape sequences, POSIX and: Escape Sequences. + (line 113) +* backslash (\), regexp constants: Computed Regexps. (line 28) +* backtrace debugger command: Dgawk Stack. (line 13) +* BBS-list file: Sample Data Files. (line 6) +* Beebe, Nelson <1>: Other Versions. (line 69) +* Beebe, Nelson: Acknowledgments. (line 60) +* BEGIN pattern <1>: BEGIN/END. (line 6) +* BEGIN pattern <2>: Field Separators. (line 44) +* BEGIN pattern: Records. (line 29) +* BEGIN pattern, assert() user-defined function and: Assert Function. + (line 83) +* BEGIN pattern, Boolean patterns and: Expression Patterns. (line 73) +* BEGIN pattern, exit statement and: Exit Statement. (line 12) +* BEGIN pattern, getline and: Getline Notes. (line 19) +* BEGIN pattern, headings, adding: Print Examples. (line 43) +* BEGIN pattern, next/nextfile statements and <1>: Next Statement. + (line 45) +* BEGIN pattern, next/nextfile statements and: I/O And BEGIN/END. + (line 37) +* BEGIN pattern, OFS/ORS variables, assigning values to: Output Separators. + (line 20) +* BEGIN pattern, operators and: Using BEGIN/END. (line 17) +* BEGIN pattern, pgawk program: Profiling. (line 65) +* BEGIN pattern, print statement and: I/O And BEGIN/END. (line 16) +* BEGIN pattern, pwcat program: Passwd Functions. (line 143) +* BEGIN pattern, running awk programs and: Cut Program. (line 68) +* BEGIN pattern, TEXTDOMAIN variable and: Programmer i18n. (line 60) +* BEGINFILE pattern: BEGINFILE/ENDFILE. (line 6) +* BEGINFILE pattern, Boolean patterns and: Expression Patterns. + (line 73) +* beginfile() user-defined function: Filetrans Function. (line 62) +* Benzinger, Michael: Contributors. (line 97) +* Berry, Karl: Acknowledgments. (line 33) +* binary input/output: User-modified. (line 10) +* bindtextdomain() function (C library): Explaining gettext. (line 49) +* bindtextdomain() function (gawk) <1>: Programmer i18n. (line 47) +* bindtextdomain() function (gawk): I18N Functions. (line 12) +* bindtextdomain() function (gawk), portability and: I18N Portability. + (line 33) +* BINMODE variable <1>: PC Using. (line 34) +* BINMODE variable: User-modified. (line 10) +* bits2str() user-defined function: Bitwise Functions. (line 68) +* bitwise, complement: Bitwise Functions. (line 25) +* bitwise, operations: Bitwise Functions. (line 6) +* bitwise, shift: Bitwise Functions. (line 32) +* body, in actions: Statements. (line 10) +* body, in loops: While Statement. (line 14) +* Boolean expressions: Boolean Ops. (line 6) +* Boolean expressions, as patterns: Expression Patterns. (line 41) +* Boolean operators, See Boolean expressions: Boolean Ops. (line 6) +* Bourne shell, quoting rules for: Quoting. (line 18) +* braces ({}), actions and: Action Overview. (line 19) +* braces ({}), pgawk program: Profiling. (line 137) +* braces ({}), statements, grouping: Statements. (line 10) +* bracket expressions <1>: Bracket Expressions. (line 6) +* bracket expressions: Regexp Operators. (line 55) +* bracket expressions, character classes: Bracket Expressions. + (line 30) +* bracket expressions, collating elements: Bracket Expressions. + (line 69) +* bracket expressions, collating symbols: Bracket Expressions. + (line 76) +* bracket expressions, complemented: Regexp Operators. (line 63) +* bracket expressions, equivalence classes: Bracket Expressions. + (line 82) +* bracket expressions, non-ASCII: Bracket Expressions. (line 69) +* bracket expressions, range expressions: Bracket Expressions. + (line 6) +* break debugger command: Breakpoint Control. (line 11) +* break statement: Break Statement. (line 6) +* Brennan, Michael <1>: Other Versions. (line 6) +* Brennan, Michael <2>: Simple Sed. (line 25) +* Brennan, Michael <3>: Two-way I/O. (line 6) +* Brennan, Michael: Delete. (line 52) +* Brian Kernighan's awk, extensions <1>: Other Versions. (line 13) +* Brian Kernighan's awk, extensions: BTL. (line 6) +* Broder, Alan J.: Contributors. (line 88) +* Brown, Martin: Contributors. (line 82) +* BSD-based operating systems: Glossary. (line 611) +* bt debugger command (alias for backtrace): Dgawk Stack. (line 13) +* Buening, Andreas <1>: Bugs. (line 71) +* Buening, Andreas <2>: Contributors. (line 92) +* Buening, Andreas: Acknowledgments. (line 60) +* buffering, input/output <1>: Two-way I/O. (line 70) +* buffering, input/output: I/O Functions. (line 130) +* buffering, interactive vs. noninteractive: I/O Functions. (line 98) +* buffers, flushing: I/O Functions. (line 29) +* buffers, operators for: GNU Regexp Operators. + (line 48) +* bug reports, email address, bug-gawk@gnu.org: Bugs. (line 30) +* bug-gawk@gnu.org bug reporting address: Bugs. (line 30) +* built-in functions: Functions. (line 6) +* built-in functions, evaluation order: Calling Built-in. (line 30) +* built-in variables: Built-in Variables. (line 6) +* built-in variables, -v option, setting with: Options. (line 40) +* built-in variables, conveying information: Auto-set. (line 6) +* built-in variables, user-modifiable: User-modified. (line 6) +* Busybox Awk: Other Versions. (line 78) +* call by reference: Pass By Value/Reference. + (line 47) +* call by value: Pass By Value/Reference. + (line 18) +* caret (^) <1>: GNU Regexp Operators. + (line 59) +* caret (^): Regexp Operators. (line 22) +* caret (^), ^ operator: Precedence. (line 49) +* caret (^), ^= operator <1>: Precedence. (line 95) +* caret (^), ^= operator: Assignment Ops. (line 129) +* caret (^), in bracket expressions: Bracket Expressions. (line 17) +* case keyword: Switch Statement. (line 6) +* case sensitivity, array indices and: Array Intro. (line 92) +* case sensitivity, converting case: String Functions. (line 522) +* case sensitivity, example programs: Library Functions. (line 42) +* case sensitivity, gawk: Case-sensitivity. (line 26) +* case sensitivity, regexps and <1>: User-modified. (line 82) +* case sensitivity, regexps and: Case-sensitivity. (line 6) +* case sensitivity, string comparisons and: User-modified. (line 82) +* CGI, awk scripts for: Options. (line 113) +* character lists, See bracket expressions: Regexp Operators. (line 55) +* character sets (machine character encodings) <1>: Glossary. (line 141) +* character sets (machine character encodings): Ordinal Functions. + (line 45) +* character sets, See Also bracket expressions: Regexp Operators. + (line 55) +* characters, counting: Wc Program. (line 6) +* characters, transliterating: Translate Program. (line 6) +* characters, values of as numbers: Ordinal Functions. (line 6) +* Chassell, Robert J.: Acknowledgments. (line 33) +* chdir() function, implementing in gawk: Sample Library. (line 6) +* chem utility: Glossary. (line 151) +* chr() user-defined function: Ordinal Functions. (line 16) +* clear debugger command: Breakpoint Control. (line 36) +* Cliff random numbers: Cliff Random Function. + (line 6) +* cliff_rand() user-defined function: Cliff Random Function. + (line 12) +* close() function <1>: I/O Functions. (line 10) +* close() function <2>: Close Files And Pipes. + (line 18) +* close() function <3>: Getline/Pipe. (line 24) +* close() function: Getline/Variable/File. + (line 30) +* close() function, return values: Close Files And Pipes. + (line 131) +* close() function, two-way pipes and: Two-way I/O. (line 77) +* Close, Diane <1>: Contributors. (line 21) +* Close, Diane: Manual History. (line 41) +* close_func() input method: Internals. (line 160) +* collating elements: Bracket Expressions. (line 69) +* collating symbols: Bracket Expressions. (line 76) +* Colombo, Antonio: Acknowledgments. (line 60) +* columns, aligning: Print Examples. (line 70) +* columns, cutting: Cut Program. (line 6) +* comma (,), in range patterns: Ranges. (line 6) +* command line, arguments <1>: ARGC and ARGV. (line 6) +* command line, arguments <2>: Auto-set. (line 11) +* command line, arguments: Other Arguments. (line 6) +* command line, directories on: Command line directories. + (line 6) +* command line, formats: Running gawk. (line 12) +* command line, FS on, setting: Command Line Field Separator. + (line 6) +* command line, invoking awk from: Command Line. (line 6) +* command line, options <1>: Command Line Field Separator. + (line 6) +* command line, options <2>: Options. (line 6) +* command line, options: Long. (line 12) +* command line, options, end of: Options. (line 54) +* command line, variables, assigning on: Assignment Options. (line 6) +* command-line options, processing: Getopt Function. (line 6) +* command-line options, string extraction: String Extraction. (line 6) +* commands debugger command: Dgawk Execution Control. + (line 10) +* commenting: Comments. (line 6) +* commenting, backslash continuation and: Statements/Lines. (line 76) +* common extensions, ** operator: Arithmetic Ops. (line 36) +* common extensions, **= operator: Assignment Ops. (line 136) +* common extensions, /dev/stderr special file: Special FD. (line 46) +* common extensions, /dev/stdin special file: Special FD. (line 46) +* common extensions, /dev/stdout special file: Special FD. (line 46) +* common extensions, \x escape sequence: Escape Sequences. (line 61) +* common extensions, BINMODE variable: PC Using. (line 34) +* common extensions, delete to delete entire arrays: Delete. (line 39) +* common extensions, fflush() function: I/O Functions. (line 25) +* common extensions, func keyword: Definition Syntax. (line 83) +* common extensions, length() applied to an array: String Functions. + (line 196) +* common extensions, nextfile statement: Nextfile Statement. (line 6) +* common extensions, RS as a regexp: Records. (line 115) +* common extensions, single character fields: Single Character Fields. + (line 6) +* comp.lang.awk newsgroup: Bugs. (line 38) +* comparison expressions: Typing and Comparison. + (line 9) +* comparison expressions, as patterns: Expression Patterns. (line 14) +* comparison expressions, string vs. regexp: Comparison Operators. + (line 79) +* compatibility mode (gawk), extensions: POSIX/GNU. (line 6) +* compatibility mode (gawk), file names: Special Caveats. (line 9) +* compatibility mode (gawk), hexadecimal numbers: Nondecimal-numbers. + (line 60) +* compatibility mode (gawk), octal numbers: Nondecimal-numbers. + (line 60) +* compatibility mode (gawk), specifying: Options. (line 78) +* compiled programs <1>: Glossary. (line 161) +* compiled programs: Basic High Level. (line 14) +* compiling gawk for Cygwin: Cygwin. (line 6) +* compiling gawk for MS-DOS and MS-Windows: PC Compiling. (line 13) +* compiling gawk for VMS: VMS Compilation. (line 6) +* compiling gawk with EMX for OS/2: PC Compiling. (line 28) +* compl() function (gawk): Bitwise Functions. (line 42) +* complement, bitwise: Bitwise Functions. (line 25) +* compound statements, control statements and: Statements. (line 10) +* concatenating: Concatenation. (line 9) +* condition debugger command: Breakpoint Control. (line 54) +* conditional expressions: Conditional Exp. (line 6) +* configuration option, --disable-lint: Additional Configuration Options. + (line 9) +* configuration option, --disable-nls: Additional Configuration Options. + (line 24) +* configuration option, --with-whiny-user-strftime: Additional Configuration Options. + (line 29) +* configuration options, gawk: Additional Configuration Options. + (line 6) +* constants, nondecimal: Nondecimal Data. (line 6) +* constants, types of: Constants. (line 6) +* continue statement: Continue Statement. (line 6) +* control statements: Statements. (line 6) +* converting, case: String Functions. (line 522) +* converting, dates to timestamps: Time Functions. (line 74) +* converting, during subscripting: Numeric Array Subscripts. + (line 31) +* converting, numbers to strings <1>: Bitwise Functions. (line 107) +* converting, numbers to strings: Conversion. (line 6) +* converting, strings to numbers <1>: Bitwise Functions. (line 107) +* converting, strings to numbers: Conversion. (line 6) +* CONVFMT variable <1>: User-modified. (line 28) +* CONVFMT variable: Conversion. (line 29) +* CONVFMT variable, array subscripts and: Numeric Array Subscripts. + (line 6) +* coprocesses <1>: Two-way I/O. (line 44) +* coprocesses: Redirection. (line 102) +* coprocesses, closing: Close Files And Pipes. + (line 6) +* coprocesses, getline from: Getline/Coprocess. (line 6) +* cos() function: Numeric Functions. (line 15) +* counting: Wc Program. (line 6) +* csh utility: Statements/Lines. (line 44) +* csh utility, POSIXLY_CORRECT environment variable: Options. (line 305) +* csh utility, |& operator, comparison with: Two-way I/O. (line 44) +* ctime() user-defined function: Function Example. (line 72) +* currency symbols, localization: Explaining gettext. (line 103) +* custom.h file: Configuration Philosophy. + (line 30) +* cut utility: Cut Program. (line 6) +* cut.awk program: Cut Program. (line 45) +* d debugger command (alias for delete): Breakpoint Control. (line 63) +* d.c., See dark corner: Conventions. (line 38) +* dark corner <1>: Glossary. (line 193) +* dark corner <2>: Truth Values. (line 24) +* dark corner <3>: Assignment Ops. (line 148) +* dark corner: Conventions. (line 38) +* dark corner, ^, in FS: Regexp Field Splitting. + (line 59) +* dark corner, array subscripts: Uninitialized Subscripts. + (line 43) +* dark corner, break statement: Break Statement. (line 51) +* dark corner, close() function: Close Files And Pipes. + (line 131) +* dark corner, command-line arguments: Assignment Options. (line 43) +* dark corner, continue statement: Continue Statement. (line 43) +* dark corner, CONVFMT variable: Conversion. (line 40) +* dark corner, escape sequences: Other Arguments. (line 31) +* dark corner, escape sequences, for metacharacters: Escape Sequences. + (line 136) +* dark corner, exit statement: Exit Statement. (line 30) +* dark corner, field separators: Field Splitting Summary. + (line 47) +* dark corner, FILENAME variable <1>: Auto-set. (line 92) +* dark corner, FILENAME variable: Getline Notes. (line 19) +* dark corner, FNR/NR variables: Auto-set. (line 207) +* dark corner, format-control characters: Control Letters. (line 18) +* dark corner, FS as null string: Single Character Fields. + (line 20) +* dark corner, input files: Records. (line 98) +* dark corner, invoking awk: Command Line. (line 16) +* dark corner, length() function: String Functions. (line 182) +* dark corner, multiline records: Multiple Line. (line 35) +* dark corner, NF variable, decrementing: Changing Fields. (line 107) +* dark corner, OFMT variable: OFMT. (line 27) +* dark corner, regexp constants: Using Constant Regexps. + (line 6) +* dark corner, regexp constants, /= operator and: Assignment Ops. + (line 148) +* dark corner, regexp constants, as arguments to user-defined functions: Using Constant Regexps. + (line 43) +* dark corner, split() function: String Functions. (line 361) +* dark corner, strings, storing: Records. (line 191) +* dark corner, value of ARGV[0]: Auto-set. (line 35) +* data, fixed-width: Constant Size. (line 9) +* data-driven languages: Basic High Level. (line 83) +* database, group, reading: Group Functions. (line 6) +* database, users, reading: Passwd Functions. (line 6) +* date utility, GNU: Time Functions. (line 17) +* date utility, POSIX: Time Functions. (line 261) +* dates, converting to timestamps: Time Functions. (line 74) +* dates, information related to, localization: Explaining gettext. + (line 115) +* Davies, Stephen <1>: Contributors. (line 74) +* Davies, Stephen: Acknowledgments. (line 60) +* dcgettext() function (gawk) <1>: Programmer i18n. (line 19) +* dcgettext() function (gawk): I18N Functions. (line 22) +* dcgettext() function (gawk), portability and: I18N Portability. + (line 33) +* dcngettext() function (gawk) <1>: Programmer i18n. (line 36) +* dcngettext() function (gawk): I18N Functions. (line 28) +* dcngettext() function (gawk), portability and: I18N Portability. + (line 33) +* deadlocks: Two-way I/O. (line 70) +* debugger commands, b (break): Breakpoint Control. (line 11) +* debugger commands, backtrace: Dgawk Stack. (line 13) +* debugger commands, break: Breakpoint Control. (line 11) +* debugger commands, bt (backtrace): Dgawk Stack. (line 13) +* debugger commands, c (continue): Dgawk Execution Control. + (line 33) +* debugger commands, clear: Breakpoint Control. (line 36) +* debugger commands, commands: Dgawk Execution Control. + (line 10) +* debugger commands, condition: Breakpoint Control. (line 54) +* debugger commands, continue: Dgawk Execution Control. + (line 33) +* debugger commands, d (delete): Breakpoint Control. (line 63) +* debugger commands, delete: Breakpoint Control. (line 63) +* debugger commands, disable: Breakpoint Control. (line 68) +* debugger commands, display: Viewing And Changing Data. + (line 8) +* debugger commands, down: Dgawk Stack. (line 21) +* debugger commands, dump: Miscellaneous Dgawk Commands. + (line 9) +* debugger commands, e (enable): Breakpoint Control. (line 72) +* debugger commands, enable: Breakpoint Control. (line 72) +* debugger commands, end: Dgawk Execution Control. + (line 10) +* debugger commands, eval: Viewing And Changing Data. + (line 23) +* debugger commands, f (frame): Dgawk Stack. (line 25) +* debugger commands, finish: Dgawk Execution Control. + (line 39) +* debugger commands, frame: Dgawk Stack. (line 25) +* debugger commands, h (help): Miscellaneous Dgawk Commands. + (line 68) +* debugger commands, help: Miscellaneous Dgawk Commands. + (line 68) +* debugger commands, i (info): Dgawk Info. (line 12) +* debugger commands, ignore: Breakpoint Control. (line 86) +* debugger commands, info: Dgawk Info. (line 12) +* debugger commands, l (list): Miscellaneous Dgawk Commands. + (line 74) +* debugger commands, list: Miscellaneous Dgawk Commands. + (line 74) +* debugger commands, n (next): Dgawk Execution Control. + (line 43) +* debugger commands, next: Dgawk Execution Control. + (line 43) +* debugger commands, nexti: Dgawk Execution Control. + (line 49) +* debugger commands, ni (nexti): Dgawk Execution Control. + (line 49) +* debugger commands, o (option): Dgawk Info. (line 56) +* debugger commands, option: Dgawk Info. (line 56) +* debugger commands, p (print): Viewing And Changing Data. + (line 36) +* debugger commands, print: Viewing And Changing Data. + (line 36) +* debugger commands, printf: Viewing And Changing Data. + (line 54) +* debugger commands, q (quit): Miscellaneous Dgawk Commands. + (line 101) +* debugger commands, quit: Miscellaneous Dgawk Commands. + (line 101) +* debugger commands, r (run): Dgawk Execution Control. + (line 62) +* debugger commands, return: Dgawk Execution Control. + (line 54) +* debugger commands, run: Dgawk Execution Control. + (line 62) +* debugger commands, s (step): Dgawk Execution Control. + (line 68) +* debugger commands, set: Viewing And Changing Data. + (line 59) +* debugger commands, si (stepi): Dgawk Execution Control. + (line 76) +* debugger commands, silent: Dgawk Execution Control. + (line 10) +* debugger commands, step: Dgawk Execution Control. + (line 68) +* debugger commands, stepi: Dgawk Execution Control. + (line 76) +* debugger commands, t (tbreak): Breakpoint Control. (line 89) +* debugger commands, tbreak: Breakpoint Control. (line 89) +* debugger commands, trace: Miscellaneous Dgawk Commands. + (line 110) +* debugger commands, u (until): Dgawk Execution Control. + (line 83) +* debugger commands, undisplay: Viewing And Changing Data. + (line 80) +* debugger commands, until: Dgawk Execution Control. + (line 83) +* debugger commands, unwatch: Viewing And Changing Data. + (line 84) +* debugger commands, up: Dgawk Stack. (line 33) +* debugger commands, w (watch): Viewing And Changing Data. + (line 67) +* debugger commands, watch: Viewing And Changing Data. + (line 67) +* debugging gawk, bug reports: Bugs. (line 9) +* decimal point character, locale specific: Options. (line 215) +* decrement operators: Increment Ops. (line 35) +* default keyword: Switch Statement. (line 6) +* Deifik, Scott <1>: Bugs. (line 70) +* Deifik, Scott <2>: Contributors. (line 54) +* Deifik, Scott: Acknowledgments. (line 60) +* delete debugger command: Breakpoint Control. (line 63) +* delete statement: Delete. (line 6) +* deleting elements in arrays: Delete. (line 6) +* deleting entire arrays: Delete. (line 39) +* dgawk: Debugger. (line 6) +* differences between gawk and awk: String Functions. (line 196) +* differences in awk and gawk, ARGC/ARGV variables: ARGC and ARGV. + (line 88) +* differences in awk and gawk, ARGIND variable: Auto-set. (line 40) +* differences in awk and gawk, array elements, deleting: Delete. + (line 39) +* differences in awk and gawk, AWKPATH environment variable: AWKPATH Variable. + (line 6) +* differences in awk and gawk, BEGIN/END patterns: I/O And BEGIN/END. + (line 16) +* differences in awk and gawk, BINMODE variable <1>: PC Using. + (line 34) +* differences in awk and gawk, BINMODE variable: User-modified. + (line 23) +* differences in awk and gawk, close() function: Close Files And Pipes. + (line 81) +* differences in awk and gawk, ERRNO variable: Auto-set. (line 72) +* differences in awk and gawk, error messages: Special FD. (line 16) +* differences in awk and gawk, FIELDWIDTHS variable: User-modified. + (line 35) +* differences in awk and gawk, FPAT variable: User-modified. (line 45) +* differences in awk and gawk, function arguments (gawk): Calling Built-in. + (line 16) +* differences in awk and gawk, getline command: Getline. (line 19) +* differences in awk and gawk, IGNORECASE variable: User-modified. + (line 82) +* differences in awk and gawk, implementation limitations <1>: Redirection. + (line 135) +* differences in awk and gawk, implementation limitations: Getline Notes. + (line 14) +* differences in awk and gawk, indirect function calls: Indirect Calls. + (line 6) +* differences in awk and gawk, input/output operators <1>: Redirection. + (line 102) +* differences in awk and gawk, input/output operators: Getline/Coprocess. + (line 6) +* differences in awk and gawk, line continuations: Conditional Exp. + (line 34) +* differences in awk and gawk, LINT variable: User-modified. (line 98) +* differences in awk and gawk, match() function: String Functions. + (line 259) +* differences in awk and gawk, next/nextfile statements: Nextfile Statement. + (line 6) +* differences in awk and gawk, print/printf statements: Format Modifiers. + (line 13) +* differences in awk and gawk, PROCINFO array: Auto-set. (line 123) +* differences in awk and gawk, record separators: Records. (line 112) +* differences in awk and gawk, regexp constants: Using Constant Regexps. + (line 43) +* differences in awk and gawk, regular expressions: Case-sensitivity. + (line 26) +* differences in awk and gawk, RS/RT variables: Records. (line 167) +* differences in awk and gawk, RT variable: Auto-set. (line 196) +* differences in awk and gawk, single-character fields: Single Character Fields. + (line 6) +* differences in awk and gawk, split() function: String Functions. + (line 349) +* differences in awk and gawk, strings: Scalar Constants. (line 20) +* differences in awk and gawk, strings, storing: Records. (line 187) +* differences in awk and gawk, strtonum() function (gawk): String Functions. + (line 404) +* differences in awk and gawk, TEXTDOMAIN variable: User-modified. + (line 153) +* differences in awk and gawk, trunc-mod operation: Arithmetic Ops. + (line 66) +* directories, changing: Sample Library. (line 6) +* directories, command line: Command line directories. + (line 6) +* directories, searching <1>: Igawk Program. (line 368) +* directories, searching: AWKPATH Variable. (line 6) +* disable debugger command: Breakpoint Control. (line 68) +* display debugger command: Viewing And Changing Data. + (line 8) +* division: Arithmetic Ops. (line 44) +* do-while statement <1>: Do Statement. (line 6) +* do-while statement: Regexp Usage. (line 19) +* documentation, of awk programs: Library Names. (line 6) +* documentation, online: Manual History. (line 11) +* documents, searching: Dupword Program. (line 6) +* dollar sign ($): Regexp Operators. (line 35) +* dollar sign ($), $ field operator <1>: Precedence. (line 43) +* dollar sign ($), $ field operator: Fields. (line 19) +* dollar sign ($), incrementing fields and arrays: Increment Ops. + (line 30) +* double precision floating-point: Basic Data Typing. (line 36) +* double quote (") <1>: Quoting. (line 37) +* double quote ("): Read Terminal. (line 25) +* double quote ("), regexp constants: Computed Regexps. (line 28) +* down debugger command: Dgawk Stack. (line 21) +* Drepper, Ulrich: Acknowledgments. (line 52) +* DuBois, John: Acknowledgments. (line 60) +* dump debugger command: Miscellaneous Dgawk Commands. + (line 9) +* dupnode() internal function: Internals. (line 96) +* dupword.awk program: Dupword Program. (line 31) +* e debugger command (alias for enable): Breakpoint Control. (line 72) +* EBCDIC: Ordinal Functions. (line 45) +* egrep utility <1>: Egrep Program. (line 6) +* egrep utility: Bracket Expressions. (line 24) +* egrep.awk program: Egrep Program. (line 54) +* elements in arrays: Reference to Elements. + (line 6) +* elements in arrays, assigning: Assigning Elements. (line 6) +* elements in arrays, deleting: Delete. (line 6) +* elements in arrays, order of: Scanning an Array. (line 48) +* elements in arrays, scanning: Scanning an Array. (line 6) +* email address for bug reports, bug-gawk@gnu.org: Bugs. (line 30) +* EMISTERED: TCP/IP Networking. (line 6) +* empty pattern: Empty. (line 6) +* empty strings, See null strings: Regexp Field Splitting. + (line 43) +* enable debugger command: Breakpoint Control. (line 72) +* end debugger command: Dgawk Execution Control. + (line 10) +* END pattern: BEGIN/END. (line 6) +* END pattern, assert() user-defined function and: Assert Function. + (line 75) +* END pattern, backslash continuation and: Egrep Program. (line 220) +* END pattern, Boolean patterns and: Expression Patterns. (line 73) +* END pattern, exit statement and: Exit Statement. (line 12) +* END pattern, next/nextfile statements and <1>: Next Statement. + (line 45) +* END pattern, next/nextfile statements and: I/O And BEGIN/END. + (line 37) +* END pattern, operators and: Using BEGIN/END. (line 17) +* END pattern, pgawk program: Profiling. (line 65) +* END pattern, print statement and: I/O And BEGIN/END. (line 16) +* ENDFILE pattern: BEGINFILE/ENDFILE. (line 6) +* ENDFILE pattern, Boolean patterns and: Expression Patterns. (line 73) +* endfile() user-defined function: Filetrans Function. (line 62) +* endgrent() function (C library): Group Functions. (line 215) +* endgrent() user-defined function: Group Functions. (line 218) +* endpwent() function (C library): Passwd Functions. (line 210) +* endpwent() user-defined function: Passwd Functions. (line 213) +* ENVIRON array <1>: Internals. (line 149) +* ENVIRON array: Auto-set. (line 60) +* environment variables: Auto-set. (line 60) +* epoch, definition of: Glossary. (line 239) +* equals sign (=), = operator: Assignment Ops. (line 6) +* equals sign (=), == operator <1>: Precedence. (line 65) +* equals sign (=), == operator: Comparison Operators. + (line 11) +* EREs (Extended Regular Expressions): Bracket Expressions. (line 24) +* ERRNO variable <1>: Internals. (line 139) +* ERRNO variable <2>: TCP/IP Networking. (line 54) +* ERRNO variable <3>: Auto-set. (line 72) +* ERRNO variable <4>: BEGINFILE/ENDFILE. (line 26) +* ERRNO variable <5>: Close Files And Pipes. + (line 139) +* ERRNO variable: Getline. (line 19) +* error handling: Special FD. (line 16) +* error handling, ERRNO variable and: Auto-set. (line 72) +* error output: Special FD. (line 6) +* escape processing, gsub()/gensub()/sub() functions: Gory Details. + (line 6) +* escape sequences: Escape Sequences. (line 6) +* eval debugger command: Viewing And Changing Data. + (line 23) +* evaluation order: Increment Ops. (line 61) +* evaluation order, concatenation: Concatenation. (line 42) +* evaluation order, functions: Calling Built-in. (line 30) +* examining fields: Fields. (line 6) +* exclamation point (!), ! operator <1>: Egrep Program. (line 170) +* exclamation point (!), ! operator <2>: Precedence. (line 52) +* exclamation point (!), ! operator: Boolean Ops. (line 67) +* exclamation point (!), != operator <1>: Precedence. (line 65) +* exclamation point (!), != operator: Comparison Operators. + (line 11) +* exclamation point (!), !~ operator <1>: Expression Patterns. + (line 24) +* exclamation point (!), !~ operator <2>: Precedence. (line 80) +* exclamation point (!), !~ operator <3>: Comparison Operators. + (line 11) +* exclamation point (!), !~ operator <4>: Regexp Constants. (line 6) +* exclamation point (!), !~ operator <5>: Computed Regexps. (line 6) +* exclamation point (!), !~ operator <6>: Case-sensitivity. (line 26) +* exclamation point (!), !~ operator: Regexp Usage. (line 19) +* exit statement: Exit Statement. (line 6) +* exit status, of gawk: Exit Status. (line 6) +* exp() function: Numeric Functions. (line 18) +* expand utility: Very Simple. (line 69) +* expressions: Expressions. (line 6) +* expressions, as patterns: Expression Patterns. (line 6) +* expressions, assignment: Assignment Ops. (line 6) +* expressions, Boolean: Boolean Ops. (line 6) +* expressions, comparison: Typing and Comparison. + (line 9) +* expressions, conditional: Conditional Exp. (line 6) +* expressions, matching, See comparison expressions: Typing and Comparison. + (line 9) +* expressions, selecting: Conditional Exp. (line 6) +* Extended Regular Expressions (EREs): Bracket Expressions. (line 24) +* eXtensible Markup Language (XML): Internals. (line 160) +* extension() function (gawk): Using Internal File Ops. + (line 15) +* extensions, Brian Kernighan's awk <1>: Other Versions. (line 13) +* extensions, Brian Kernighan's awk: BTL. (line 6) +* extensions, common, ** operator: Arithmetic Ops. (line 36) +* extensions, common, **= operator: Assignment Ops. (line 136) +* extensions, common, /dev/stderr special file: Special FD. (line 46) +* extensions, common, /dev/stdin special file: Special FD. (line 46) +* extensions, common, /dev/stdout special file: Special FD. (line 46) +* extensions, common, \x escape sequence: Escape Sequences. (line 61) +* extensions, common, BINMODE variable: PC Using. (line 34) +* extensions, common, delete to delete entire arrays: Delete. (line 39) +* extensions, common, fflush() function: I/O Functions. (line 25) +* extensions, common, func keyword: Definition Syntax. (line 83) +* extensions, common, length() applied to an array: String Functions. + (line 196) +* extensions, common, nextfile statement: Nextfile Statement. (line 6) +* extensions, common, RS as a regexp: Records. (line 115) +* extensions, common, single character fields: Single Character Fields. + (line 6) +* extensions, in gawk, not in POSIX awk: POSIX/GNU. (line 6) +* extract.awk program: Extract Program. (line 78) +* extraction, of marked strings (internationalization): String Extraction. + (line 6) +* f debugger command (alias for frame): Dgawk Stack. (line 25) +* false, logical: Truth Values. (line 6) +* FDL (Free Documentation License): GNU Free Documentation License. + (line 6) +* features, adding to gawk: Adding Code. (line 6) +* features, advanced, See advanced features: Obsolete. (line 6) +* features, deprecated: Obsolete. (line 6) +* features, undocumented: Undocumented. (line 6) +* Fenlason, Jay <1>: Contributors. (line 19) +* Fenlason, Jay: History. (line 30) +* fflush() function: I/O Functions. (line 25) +* field numbers: Nonconstant Fields. (line 6) +* field operator $: Fields. (line 19) +* field operators, dollar sign as: Fields. (line 19) +* field separators <1>: User-modified. (line 56) +* field separators: Field Separators. (line 14) +* field separators, choice of: Field Separators. (line 50) +* field separators, FIELDWIDTHS variable and: User-modified. (line 35) +* field separators, FPAT variable and: User-modified. (line 45) +* field separators, in multiline records: Multiple Line. (line 41) +* field separators, on command line: Command Line Field Separator. + (line 6) +* field separators, POSIX and <1>: Field Splitting Summary. + (line 41) +* field separators, POSIX and: Fields. (line 6) +* field separators, regular expressions as <1>: Regexp Field Splitting. + (line 6) +* field separators, regular expressions as: Field Separators. (line 50) +* field separators, See Also OFS: Changing Fields. (line 64) +* field separators, spaces as: Cut Program. (line 109) +* fields <1>: Basic High Level. (line 71) +* fields <2>: Fields. (line 6) +* fields: Reading Files. (line 14) +* fields, adding: Changing Fields. (line 53) +* fields, changing contents of: Changing Fields. (line 6) +* fields, cutting: Cut Program. (line 6) +* fields, examining: Fields. (line 6) +* fields, number of: Fields. (line 33) +* fields, numbers: Nonconstant Fields. (line 6) +* fields, printing: Print Examples. (line 21) +* fields, separating: Field Separators. (line 14) +* fields, single-character: Single Character Fields. + (line 6) +* FIELDWIDTHS variable <1>: User-modified. (line 35) +* FIELDWIDTHS variable: Constant Size. (line 22) +* file descriptors: Special FD. (line 6) +* file names, distinguishing: Auto-set. (line 52) +* file names, in compatibility mode: Special Caveats. (line 9) +* file names, standard streams in gawk: Special FD. (line 46) +* FILENAME variable <1>: Auto-set. (line 92) +* FILENAME variable: Reading Files. (line 6) +* FILENAME variable, getline, setting with: Getline Notes. (line 19) +* filenames, assignments as: Ignoring Assigns. (line 6) +* files, .mo: Explaining gettext. (line 41) +* files, .mo, converting from .po: I18N Example. (line 62) +* files, .mo, specifying directory of <1>: Programmer i18n. (line 47) +* files, .mo, specifying directory of: Explaining gettext. (line 53) +* files, .po <1>: Translator i18n. (line 6) +* files, .po: Explaining gettext. (line 36) +* files, .po, converting to .mo: I18N Example. (line 62) +* files, .pot: Explaining gettext. (line 30) +* files, /dev/... special files: Special FD. (line 46) +* files, /inet/... (gawk): TCP/IP Networking. (line 6) +* files, /inet4/... (gawk): TCP/IP Networking. (line 6) +* files, /inet6/... (gawk): TCP/IP Networking. (line 6) +* files, as single records: Records. (line 196) +* files, awk programs in: Long. (line 6) +* files, awkprof.out: Profiling. (line 10) +* files, awkvars.out: Options. (line 90) +* files, closing: I/O Functions. (line 10) +* files, descriptors, See file descriptors: Special FD. (line 6) +* files, group: Group Functions. (line 6) +* files, information about, retrieving: Sample Library. (line 6) +* files, initialization and cleanup: Filetrans Function. (line 6) +* files, input, See input files: Read Terminal. (line 17) +* files, log, timestamps in: Time Functions. (line 6) +* files, managing: Data File Management. + (line 6) +* files, managing, data file boundaries: Filetrans Function. (line 6) +* files, message object: Explaining gettext. (line 41) +* files, message object, converting from portable object files: I18N Example. + (line 62) +* files, message object, specifying directory of <1>: Programmer i18n. + (line 47) +* files, message object, specifying directory of: Explaining gettext. + (line 53) +* files, multiple passes over: Other Arguments. (line 49) +* files, multiple, duplicating output into: Tee Program. (line 6) +* files, output, See output files: Close Files And Pipes. + (line 6) +* files, password: Passwd Functions. (line 16) +* files, portable object <1>: Translator i18n. (line 6) +* files, portable object: Explaining gettext. (line 36) +* files, portable object template: Explaining gettext. (line 30) +* files, portable object, converting to message object files: I18N Example. + (line 62) +* files, portable object, generating: Options. (line 135) +* files, processing, ARGIND variable and: Auto-set. (line 47) +* files, reading: Rewind Function. (line 6) +* files, reading, multiline records: Multiple Line. (line 6) +* files, searching for regular expressions: Egrep Program. (line 6) +* files, skipping: File Checking. (line 6) +* files, source, search path for: Igawk Program. (line 368) +* files, splitting: Split Program. (line 6) +* files, Texinfo, extracting programs from: Extract Program. (line 6) +* finish debugger command: Dgawk Execution Control. + (line 39) +* Fish, Fred: Contributors. (line 51) +* fixed-width data: Constant Size. (line 9) +* flag variables <1>: Tee Program. (line 20) +* flag variables: Boolean Ops. (line 67) +* floating-point, numbers <1>: Unexpected Results. (line 6) +* floating-point, numbers: Basic Data Typing. (line 21) +* floating-point, numbers, AWKNUM internal type: Internals. (line 19) +* FNR variable <1>: Auto-set. (line 102) +* FNR variable: Records. (line 6) +* FNR variable, changing: Auto-set. (line 207) +* for statement: For Statement. (line 6) +* for statement, in arrays: Scanning an Array. (line 20) +* force_number() internal function: Internals. (line 27) +* force_string() internal function: Internals. (line 32) +* force_wstring() internal function: Internals. (line 37) +* format specifiers, mixing regular with positional specifiers: Printf Ordering. + (line 57) +* format specifiers, printf statement: Control Letters. (line 6) +* format specifiers, strftime() function (gawk): Time Functions. + (line 87) +* format strings: Basic Printf. (line 15) +* formats, numeric output: OFMT. (line 6) +* formatting output: Printf. (line 6) +* forward slash (/): Regexp. (line 10) +* forward slash (/), / operator: Precedence. (line 55) +* forward slash (/), /= operator <1>: Precedence. (line 95) +* forward slash (/), /= operator: Assignment Ops. (line 129) +* forward slash (/), /= operator, vs. /=.../ regexp constant: Assignment Ops. + (line 148) +* forward slash (/), patterns and: Expression Patterns. (line 24) +* FPAT variable <1>: User-modified. (line 45) +* FPAT variable: Splitting By Content. + (line 26) +* frame debugger command: Dgawk Stack. (line 25) +* Free Documentation License (FDL): GNU Free Documentation License. + (line 6) +* Free Software Foundation (FSF) <1>: Glossary. (line 301) +* Free Software Foundation (FSF) <2>: Getting. (line 10) +* Free Software Foundation (FSF): Manual History. (line 6) +* FreeBSD: Glossary. (line 611) +* FS variable <1>: User-modified. (line 56) +* FS variable: Field Separators. (line 14) +* FS variable, --field-separator option and: Options. (line 21) +* FS variable, as null string: Single Character Fields. + (line 20) +* FS variable, as TAB character: Options. (line 211) +* FS variable, changing value of: Field Separators. (line 34) +* FS variable, running awk programs and: Cut Program. (line 68) +* FS variable, setting from command line: Command Line Field Separator. + (line 6) +* FS, containing ^: Regexp Field Splitting. + (line 59) +* FSF (Free Software Foundation) <1>: Glossary. (line 301) +* FSF (Free Software Foundation) <2>: Getting. (line 10) +* FSF (Free Software Foundation): Manual History. (line 6) +* function calls: Function Calls. (line 6) +* function calls, indirect: Indirect Calls. (line 6) +* function pointers: Indirect Calls. (line 6) +* functions, arrays as parameters to: Pass By Value/Reference. + (line 47) +* functions, built-in <1>: Functions. (line 6) +* functions, built-in: Function Calls. (line 10) +* functions, built-in, adding to gawk: Dynamic Extensions. (line 10) +* functions, built-in, evaluation order: Calling Built-in. (line 30) +* functions, defining: Definition Syntax. (line 6) +* functions, library: Library Functions. (line 6) +* functions, library, assertions: Assert Function. (line 6) +* functions, library, associative arrays and: Library Names. (line 57) +* functions, library, C library: Getopt Function. (line 6) +* functions, library, character values as numbers: Ordinal Functions. + (line 6) +* functions, library, Cliff random numbers: Cliff Random Function. + (line 6) +* functions, library, command-line options: Getopt Function. (line 6) +* functions, library, example program for using: Igawk Program. + (line 6) +* functions, library, group database, reading: Group Functions. + (line 6) +* functions, library, managing data files: Data File Management. + (line 6) +* functions, library, managing time: Gettimeofday Function. + (line 6) +* functions, library, merging arrays into strings: Join Function. + (line 6) +* functions, library, rounding numbers: Round Function. (line 6) +* functions, library, user database, reading: Passwd Functions. + (line 6) +* functions, names of <1>: Definition Syntax. (line 20) +* functions, names of: Arrays. (line 18) +* functions, recursive: Definition Syntax. (line 73) +* functions, return values, setting: Internals. (line 139) +* functions, string-translation: I18N Functions. (line 6) +* functions, undefined: Pass By Value/Reference. + (line 71) +* functions, user-defined: User-defined. (line 6) +* functions, user-defined, calling: Calling A Function. (line 6) +* functions, user-defined, counts: Profiling. (line 132) +* functions, user-defined, library of: Library Functions. (line 6) +* functions, user-defined, next/nextfile statements and <1>: Nextfile Statement. + (line 44) +* functions, user-defined, next/nextfile statements and: Next Statement. + (line 45) +* G-d: Acknowledgments. (line 81) +* Garfinkle, Scott: Contributors. (line 35) +* gawk, ARGIND variable in: Other Arguments. (line 12) +* gawk, awk and <1>: This Manual. (line 14) +* gawk, awk and: Preface. (line 23) +* gawk, bitwise operations in: Bitwise Functions. (line 39) +* gawk, break statement in: Break Statement. (line 51) +* gawk, built-in variables and: Built-in Variables. (line 14) +* gawk, character classes and: Bracket Expressions. (line 90) +* gawk, coding style in: Adding Code. (line 38) +* gawk, command-line options: GNU Regexp Operators. + (line 70) +* gawk, comparison operators and: Comparison Operators. + (line 50) +* gawk, configuring: Configuration Philosophy. + (line 6) +* gawk, configuring, options: Additional Configuration Options. + (line 6) +* gawk, continue statement in: Continue Statement. (line 43) +* gawk, distribution: Distribution contents. + (line 6) +* gawk, ERRNO variable in <1>: TCP/IP Networking. (line 54) +* gawk, ERRNO variable in <2>: Auto-set. (line 72) +* gawk, ERRNO variable in <3>: BEGINFILE/ENDFILE. (line 26) +* gawk, ERRNO variable in <4>: Close Files And Pipes. + (line 139) +* gawk, ERRNO variable in: Getline. (line 19) +* gawk, escape sequences: Escape Sequences. (line 125) +* gawk, extensions, disabling: Options. (line 199) +* gawk, features, adding: Adding Code. (line 6) +* gawk, features, advanced: Advanced Features. (line 6) +* gawk, fflush() function in: I/O Functions. (line 44) +* gawk, field separators and: User-modified. (line 77) +* gawk, FIELDWIDTHS variable in <1>: User-modified. (line 35) +* gawk, FIELDWIDTHS variable in: Constant Size. (line 22) +* gawk, file names in: Special Files. (line 6) +* gawk, format-control characters: Control Letters. (line 18) +* gawk, FPAT variable in <1>: User-modified. (line 45) +* gawk, FPAT variable in: Splitting By Content. + (line 26) +* gawk, function arguments and: Calling Built-in. (line 16) +* gawk, functions, adding: Dynamic Extensions. (line 10) +* gawk, hexadecimal numbers and: Nondecimal-numbers. (line 42) +* gawk, IGNORECASE variable in <1>: Array Sorting Functions. + (line 81) +* gawk, IGNORECASE variable in <2>: String Functions. (line 29) +* gawk, IGNORECASE variable in <3>: Array Intro. (line 92) +* gawk, IGNORECASE variable in <4>: User-modified. (line 82) +* gawk, IGNORECASE variable in: Case-sensitivity. (line 26) +* gawk, implementation issues: Notes. (line 6) +* gawk, implementation issues, debugging: Compatibility Mode. (line 6) +* gawk, implementation issues, downward compatibility: Compatibility Mode. + (line 6) +* gawk, implementation issues, limits: Getline Notes. (line 14) +* gawk, implementation issues, pipes: Redirection. (line 135) +* gawk, installing: Installation. (line 6) +* gawk, internals: Internals. (line 6) +* gawk, internationalization and, See internationalization: Internationalization. + (line 13) +* gawk, interpreter, adding code to: Using Internal File Ops. + (line 6) +* gawk, interval expressions and: Regexp Operators. (line 139) +* gawk, line continuation in: Conditional Exp. (line 34) +* gawk, LINT variable in: User-modified. (line 98) +* gawk, list of contributors to: Contributors. (line 6) +* gawk, MS-DOS version of: PC Using. (line 11) +* gawk, MS-Windows version of: PC Using. (line 11) +* gawk, newlines in: Statements/Lines. (line 12) +* gawk, octal numbers and: Nondecimal-numbers. (line 42) +* gawk, OS/2 version of: PC Using. (line 11) +* gawk, PROCINFO array in <1>: Two-way I/O. (line 116) +* gawk, PROCINFO array in <2>: Time Functions. (line 46) +* gawk, PROCINFO array in: Auto-set. (line 123) +* gawk, regexp constants and: Using Constant Regexps. + (line 28) +* gawk, regular expressions, case sensitivity: Case-sensitivity. + (line 26) +* gawk, regular expressions, operators: GNU Regexp Operators. + (line 6) +* gawk, regular expressions, precedence: Regexp Operators. (line 161) +* gawk, RT variable in <1>: Auto-set. (line 196) +* gawk, RT variable in <2>: Getline/Variable/File. + (line 10) +* gawk, RT variable in <3>: Multiple Line. (line 129) +* gawk, RT variable in: Records. (line 112) +* gawk, See Also awk: Preface. (line 36) +* gawk, source code, obtaining: Getting. (line 6) +* gawk, splitting fields and: Constant Size. (line 87) +* gawk, string-translation functions: I18N Functions. (line 6) +* gawk, TEXTDOMAIN variable in: User-modified. (line 153) +* gawk, timestamps: Time Functions. (line 6) +* gawk, uses for: Preface. (line 36) +* gawk, versions of, information about, printing: Options. (line 250) +* gawk, VMS version of: VMS Installation. (line 6) +* gawk, word-boundary operator: GNU Regexp Operators. + (line 63) +* General Public License (GPL): Glossary. (line 310) +* General Public License, See GPL: Manual History. (line 11) +* gensub() function (gawk) <1>: String Functions. (line 86) +* gensub() function (gawk): Using Constant Regexps. + (line 43) +* gensub() function (gawk), escape processing: Gory Details. (line 6) +* get_actual_argument() internal function: Internals. (line 125) +* get_argument() internal function: Internals. (line 120) +* get_array_argument() internal macro: Internals. (line 136) +* get_curfunc_arg_count() internal function: Internals. (line 42) +* get_record() input method: Internals. (line 160) +* get_scalar_argument() internal macro: Internals. (line 133) +* getaddrinfo() function (C library): TCP/IP Networking. (line 38) +* getgrent() function (C library): Group Functions. (line 6) +* getgrent() user-defined function: Group Functions. (line 6) +* getgrgid() function (C library): Group Functions. (line 186) +* getgrgid() user-defined function: Group Functions. (line 189) +* getgrnam() function (C library): Group Functions. (line 175) +* getgrnam() user-defined function: Group Functions. (line 180) +* getgruser() function (C library): Group Functions. (line 195) +* getgruser() function, user-defined: Group Functions. (line 198) +* getline command: Reading Files. (line 20) +* getline command, _gr_init() user-defined function: Group Functions. + (line 82) +* getline command, _pw_init() function: Passwd Functions. (line 154) +* getline command, coprocesses, using from <1>: Close Files And Pipes. + (line 6) +* getline command, coprocesses, using from: Getline/Coprocess. + (line 6) +* getline command, deadlock and: Two-way I/O. (line 70) +* getline command, explicit input with: Getline. (line 6) +* getline command, FILENAME variable and: Getline Notes. (line 19) +* getline command, return values: Getline. (line 19) +* getline command, variants: Getline Summary. (line 6) +* getline statement, BEGINFILE/ENDFILE patterns and: BEGINFILE/ENDFILE. + (line 54) +* getopt() function (C library): Getopt Function. (line 15) +* getopt() user-defined function: Getopt Function. (line 108) +* getpwent() function (C library): Passwd Functions. (line 16) +* getpwent() user-defined function: Passwd Functions. (line 16) +* getpwnam() function (C library): Passwd Functions. (line 177) +* getpwnam() user-defined function: Passwd Functions. (line 182) +* getpwuid() function (C library): Passwd Functions. (line 188) +* getpwuid() user-defined function: Passwd Functions. (line 192) +* gettext library: Explaining gettext. (line 6) +* gettext library, locale categories: Explaining gettext. (line 80) +* gettext() function (C library): Explaining gettext. (line 62) +* gettimeofday() user-defined function: Gettimeofday Function. + (line 16) +* GNITS mailing list: Acknowledgments. (line 52) +* GNU awk, See gawk: Preface. (line 49) +* GNU Free Documentation License: GNU Free Documentation License. + (line 6) +* GNU General Public License: Glossary. (line 310) +* GNU Lesser General Public License: Glossary. (line 397) +* GNU long options <1>: Options. (line 6) +* GNU long options: Command Line. (line 13) +* GNU long options, printing list of: Options. (line 142) +* GNU Project <1>: Glossary. (line 319) +* GNU Project: Manual History. (line 11) +* GNU/Linux <1>: Glossary. (line 611) +* GNU/Linux <2>: I18N Example. (line 55) +* GNU/Linux: Manual History. (line 28) +* GPL (General Public License) <1>: Glossary. (line 310) +* GPL (General Public License): Manual History. (line 11) +* GPL (General Public License), printing: Options. (line 85) +* grcat program: Group Functions. (line 16) +* Grigera, Juan: Contributors. (line 58) +* group database, reading: Group Functions. (line 6) +* group file: Group Functions. (line 6) +* groups, information about: Group Functions. (line 6) +* gsub() function <1>: String Functions. (line 139) +* gsub() function: Using Constant Regexps. + (line 43) +* gsub() function, arguments of: String Functions. (line 462) +* gsub() function, escape processing: Gory Details. (line 6) +* h debugger command (alias for help): Miscellaneous Dgawk Commands. + (line 68) +* Hankerson, Darrel <1>: Contributors. (line 61) +* Hankerson, Darrel: Acknowledgments. (line 60) +* Haque, John <1>: Contributors. (line 103) +* Haque, John: Acknowledgments. (line 60) +* Hartholz, Elaine: Acknowledgments. (line 38) +* Hartholz, Marshall: Acknowledgments. (line 38) +* Hasegawa, Isamu: Contributors. (line 94) +* help debugger command: Miscellaneous Dgawk Commands. + (line 68) +* hexadecimal numbers: Nondecimal-numbers. (line 6) +* hexadecimal values, enabling interpretation of: Options. (line 166) +* histsort.awk program: History Sorting. (line 25) +* Hughes, Phil: Acknowledgments. (line 43) +* HUP signal: Profiling. (line 204) +* hyphen (-), - operator: Precedence. (line 52) +* hyphen (-), -- (decrement/increment) operators: Precedence. (line 46) +* hyphen (-), -- operator: Increment Ops. (line 48) +* hyphen (-), -= operator <1>: Precedence. (line 95) +* hyphen (-), -= operator: Assignment Ops. (line 129) +* hyphen (-), filenames beginning with: Options. (line 59) +* hyphen (-), in bracket expressions: Bracket Expressions. (line 17) +* i debugger command (alias for info): Dgawk Info. (line 12) +* id utility: Id Program. (line 6) +* id.awk program: Id Program. (line 30) +* if statement <1>: If Statement. (line 6) +* if statement: Regexp Usage. (line 19) +* if statement, actions, changing: Ranges. (line 25) +* igawk.sh program: Igawk Program. (line 124) +* ignore debugger command: Breakpoint Control. (line 86) +* IGNORECASE variable <1>: Array Sorting Functions. + (line 81) +* IGNORECASE variable <2>: String Functions. (line 29) +* IGNORECASE variable <3>: Array Intro. (line 92) +* IGNORECASE variable <4>: User-modified. (line 82) +* IGNORECASE variable: Case-sensitivity. (line 26) +* IGNORECASE variable, array sorting and: Array Sorting Functions. + (line 81) +* IGNORECASE variable, array subscripts and: Array Intro. (line 92) +* IGNORECASE variable, in example programs: Library Functions. + (line 42) +* implementation issues, gawk: Notes. (line 6) +* implementation issues, gawk, debugging: Compatibility Mode. (line 6) +* implementation issues, gawk, limits <1>: Redirection. (line 135) +* implementation issues, gawk, limits: Getline Notes. (line 14) +* in operator <1>: Id Program. (line 93) +* in operator <2>: For Statement. (line 75) +* in operator <3>: Precedence. (line 83) +* in operator: Comparison Operators. + (line 11) +* in operator, arrays and <1>: Scanning an Array. (line 17) +* in operator, arrays and: Reference to Elements. + (line 37) +* increment operators: Increment Ops. (line 6) +* index() function: String Functions. (line 155) +* indexing arrays: Array Intro. (line 50) +* indirect function calls: Indirect Calls. (line 6) +* info debugger command: Dgawk Info. (line 12) +* initialization, automatic: More Complex. (line 38) +* input files: Reading Files. (line 6) +* input files, closing: Close Files And Pipes. + (line 6) +* input files, counting elements in: Wc Program. (line 6) +* input files, examples: Sample Data Files. (line 6) +* input files, reading: Reading Files. (line 6) +* input files, running awk without: Read Terminal. (line 6) +* input files, variable assignments and: Other Arguments. (line 19) +* input pipeline: Getline/Pipe. (line 6) +* input redirection: Getline/File. (line 6) +* input, data, nondecimal: Nondecimal Data. (line 6) +* input, explicit: Getline. (line 6) +* input, files, See input files: Multiple Line. (line 6) +* input, multiline records: Multiple Line. (line 6) +* input, splitting into records: Records. (line 6) +* input, standard <1>: Special FD. (line 6) +* input, standard: Read Terminal. (line 6) +* input/output, binary: User-modified. (line 10) +* input/output, from BEGIN and END: I/O And BEGIN/END. (line 6) +* input/output, two-way: Two-way I/O. (line 44) +* insomnia, cure for: Alarm Program. (line 6) +* installation, VMS: VMS Installation. (line 6) +* installing gawk: Installation. (line 6) +* INT signal (MS-Windows): Profiling. (line 207) +* int() function: Numeric Functions. (line 23) +* integers: Basic Data Typing. (line 21) +* integers, unsigned: Basic Data Typing. (line 30) +* interacting with other programs: I/O Functions. (line 63) +* internal constant, INVALID_HANDLE: Internals. (line 160) +* internal function, assoc_clear(): Internals. (line 75) +* internal function, assoc_lookup(): Internals. (line 79) +* internal function, dupnode(): Internals. (line 96) +* internal function, force_number(): Internals. (line 27) +* internal function, force_string(): Internals. (line 32) +* internal function, force_wstring(): Internals. (line 37) +* internal function, get_actual_argument(): Internals. (line 125) +* internal function, get_argument(): Internals. (line 120) +* internal function, get_curfunc_arg_count(): Internals. (line 42) +* internal function, iop_alloc(): Internals. (line 160) +* internal function, make_builtin(): Internals. (line 106) +* internal function, make_number(): Internals. (line 91) +* internal function, make_string(): Internals. (line 86) +* internal function, register_deferred_variable(): Internals. (line 149) +* internal function, register_open_hook(): Internals. (line 160) +* internal function, unref(): Internals. (line 101) +* internal function, update_ERRNO(): Internals. (line 139) +* internal function, update_ERRNO_saved(): Internals. (line 144) +* internal macro, get_array_argument(): Internals. (line 136) +* internal macro, get_scalar_argument(): Internals. (line 133) +* internal structure, IOBUF: Internals. (line 160) +* internal type, AWKNUM: Internals. (line 19) +* internal type, NODE: Internals. (line 23) +* internal variable, nargs: Internals. (line 49) +* internal variable, stlen: Internals. (line 53) +* internal variable, stptr: Internals. (line 53) +* internal variable, type: Internals. (line 66) +* internal variable, vname: Internals. (line 71) +* internal variable, wstlen: Internals. (line 61) +* internal variable, wstptr: Internals. (line 61) +* internationalization <1>: I18N and L10N. (line 6) +* internationalization: I18N Functions. (line 6) +* internationalization, localization <1>: Internationalization. + (line 13) +* internationalization, localization: User-modified. (line 153) +* internationalization, localization, character classes: Bracket Expressions. + (line 90) +* internationalization, localization, gawk and: Internationalization. + (line 13) +* internationalization, localization, locale categories: Explaining gettext. + (line 80) +* internationalization, localization, marked strings: Programmer i18n. + (line 14) +* internationalization, localization, portability and: I18N Portability. + (line 6) +* internationalizing a program: Explaining gettext. (line 6) +* interpreted programs <1>: Glossary. (line 361) +* interpreted programs: Basic High Level. (line 14) +* interval expressions: Regexp Operators. (line 116) +* INVALID_HANDLE internal constant: Internals. (line 160) +* inventory-shipped file: Sample Data Files. (line 32) +* IOBUF internal structure: Internals. (line 160) +* iop_alloc() internal function: Internals. (line 160) +* isarray() function (gawk): Type Functions. (line 11) +* ISO: Glossary. (line 372) +* ISO 8859-1: Glossary. (line 141) +* ISO Latin-1: Glossary. (line 141) +* Jacobs, Andrew: Passwd Functions. (line 90) +* Jaegermann, Michal <1>: Contributors. (line 46) +* Jaegermann, Michal: Acknowledgments. (line 60) +* Java implementation of awk: Other Versions. (line 96) +* Java programming language: Glossary. (line 380) +* jawk: Other Versions. (line 96) +* Jedi knights: Undocumented. (line 6) +* join() user-defined function: Join Function. (line 18) +* Kahrs, Ju"rgen <1>: Contributors. (line 70) +* Kahrs, Ju"rgen: Acknowledgments. (line 60) +* Kasal, Stepan: Acknowledgments. (line 60) +* Kenobi, Obi-Wan: Undocumented. (line 6) +* Kernighan, Brian <1>: Basic Data Typing. (line 74) +* Kernighan, Brian <2>: Other Versions. (line 13) +* Kernighan, Brian <3>: Contributors. (line 12) +* Kernighan, Brian <4>: BTL. (line 6) +* Kernighan, Brian <5>: Concatenation. (line 6) +* Kernighan, Brian <6>: Acknowledgments. (line 75) +* Kernighan, Brian <7>: Conventions. (line 34) +* Kernighan, Brian: History. (line 17) +* kill command, dynamic profiling: Profiling. (line 182) +* Knights, jedi: Undocumented. (line 6) +* Kwok, Conrad: Contributors. (line 35) +* l debugger command (alias for list): Miscellaneous Dgawk Commands. + (line 74) +* labels.awk program: Labels Program. (line 51) +* languages, data-driven: Basic High Level. (line 83) +* LC_ALL locale category: Explaining gettext. (line 120) +* LC_COLLATE locale category: Explaining gettext. (line 93) +* LC_CTYPE locale category: Explaining gettext. (line 97) +* LC_MESSAGES locale category: Explaining gettext. (line 87) +* LC_MESSAGES locale category, bindtextdomain() function (gawk): Programmer i18n. + (line 88) +* LC_MONETARY locale category: Explaining gettext. (line 103) +* LC_NUMERIC locale category: Explaining gettext. (line 107) +* LC_RESPONSE locale category: Explaining gettext. (line 111) +* LC_TIME locale category: Explaining gettext. (line 115) +* left angle bracket (<), < operator <1>: Precedence. (line 65) +* left angle bracket (<), < operator: Comparison Operators. + (line 11) +* left angle bracket (<), < operator (I/O): Getline/File. (line 6) +* left angle bracket (<), <= operator <1>: Precedence. (line 65) +* left angle bracket (<), <= operator: Comparison Operators. + (line 11) +* left shift, bitwise: Bitwise Functions. (line 32) +* leftmost longest match: Multiple Line. (line 26) +* length() function: String Functions. (line 166) +* Lesser General Public License (LGPL): Glossary. (line 397) +* LGPL (Lesser General Public License): Glossary. (line 397) +* libmawk: Other Versions. (line 104) +* libraries of awk functions: Library Functions. (line 6) +* libraries of awk functions, assertions: Assert Function. (line 6) +* libraries of awk functions, associative arrays and: Library Names. + (line 57) +* libraries of awk functions, character values as numbers: Ordinal Functions. + (line 6) +* libraries of awk functions, command-line options: Getopt Function. + (line 6) +* libraries of awk functions, example program for using: Igawk Program. + (line 6) +* libraries of awk functions, group database, reading: Group Functions. + (line 6) +* libraries of awk functions, managing, data files: Data File Management. + (line 6) +* libraries of awk functions, managing, time: Gettimeofday Function. + (line 6) +* libraries of awk functions, merging arrays into strings: Join Function. + (line 6) +* libraries of awk functions, rounding numbers: Round Function. + (line 6) +* libraries of awk functions, user database, reading: Passwd Functions. + (line 6) +* line breaks: Statements/Lines. (line 6) +* line continuations: Boolean Ops. (line 62) +* line continuations, gawk: Conditional Exp. (line 34) +* line continuations, in print statement: Print Examples. (line 76) +* line continuations, with C shell: More Complex. (line 30) +* lines, blank, printing: Print. (line 22) +* lines, counting: Wc Program. (line 6) +* lines, duplicate, removing: History Sorting. (line 6) +* lines, matching ranges of: Ranges. (line 6) +* lines, skipping between markers: Ranges. (line 43) +* lint checking: User-modified. (line 98) +* lint checking, array elements: Delete. (line 34) +* lint checking, array subscripts: Uninitialized Subscripts. + (line 43) +* lint checking, empty programs: Command Line. (line 16) +* lint checking, issuing warnings: Options. (line 147) +* lint checking, POSIXLY_CORRECT environment variable: Options. + (line 289) +* lint checking, undefined functions: Pass By Value/Reference. + (line 88) +* LINT variable: User-modified. (line 98) +* Linux <1>: Glossary. (line 611) +* Linux <2>: I18N Example. (line 55) +* Linux: Manual History. (line 28) +* list debugger command: Miscellaneous Dgawk Commands. + (line 74) +* local variables: Variable Scope. (line 6) +* locale categories: Explaining gettext. (line 80) +* locale decimal point character: Options. (line 215) +* locale, definition of: Locales. (line 6) +* localization: I18N and L10N. (line 6) +* localization, See internationalization, localization: I18N and L10N. + (line 6) +* log files, timestamps in: Time Functions. (line 6) +* log() function: Numeric Functions. (line 30) +* logical false/true: Truth Values. (line 6) +* logical operators, See Boolean expressions: Boolean Ops. (line 6) +* login information: Passwd Functions. (line 16) +* long options: Command Line. (line 13) +* loops: While Statement. (line 6) +* loops, continue statements and: For Statement. (line 64) +* loops, count for header: Profiling. (line 126) +* loops, exiting: Break Statement. (line 6) +* loops, See Also while statement: While Statement. (line 6) +* Lost In Space: Dynamic Extensions. (line 6) +* ls utility: More Complex. (line 15) +* lshift() function (gawk): Bitwise Functions. (line 45) +* lvalues/rvalues: Assignment Ops. (line 32) +* mailing labels, printing: Labels Program. (line 6) +* mailing list, GNITS: Acknowledgments. (line 52) +* make_builtin() internal function: Internals. (line 106) +* make_number() internal function: Internals. (line 91) +* make_string() internal function: Internals. (line 86) +* mark parity: Ordinal Functions. (line 45) +* marked string extraction (internationalization): String Extraction. + (line 6) +* marked strings, extracting: String Extraction. (line 6) +* Marx, Groucho: Increment Ops. (line 61) +* match() function: String Functions. (line 206) +* match() function, RSTART/RLENGTH variables: String Functions. + (line 223) +* matching, expressions, See comparison expressions: Typing and Comparison. + (line 9) +* matching, leftmost longest: Multiple Line. (line 26) +* matching, null strings: Gory Details. (line 164) +* mawk program: Other Versions. (line 35) +* McPhee, Patrick: Contributors. (line 100) +* memory, releasing: Internals. (line 101) +* message object files: Explaining gettext. (line 41) +* message object files, converting from portable object files: I18N Example. + (line 62) +* message object files, specifying directory of <1>: Programmer i18n. + (line 47) +* message object files, specifying directory of: Explaining gettext. + (line 53) +* metacharacters, escape sequences for: Escape Sequences. (line 132) +* mktime() function (gawk): Time Functions. (line 24) +* modifiers, in format specifiers: Format Modifiers. (line 6) +* monetary information, localization: Explaining gettext. (line 103) +* msgfmt utility: I18N Example. (line 62) +* n debugger command (alias for next): Dgawk Execution Control. + (line 43) +* names, arrays/variables <1>: Library Names. (line 6) +* names, arrays/variables: Arrays. (line 18) +* names, functions <1>: Library Names. (line 6) +* names, functions: Definition Syntax. (line 20) +* namespace issues <1>: Library Names. (line 6) +* namespace issues: Arrays. (line 18) +* namespace issues, functions: Definition Syntax. (line 20) +* nargs internal variable: Internals. (line 49) +* nawk utility: Names. (line 17) +* negative zero: Unexpected Results. (line 28) +* NetBSD: Glossary. (line 611) +* networks, programming: TCP/IP Networking. (line 6) +* networks, support for: Special Network. (line 6) +* newlines <1>: Boolean Ops. (line 67) +* newlines <2>: Options. (line 205) +* newlines: Statements/Lines. (line 6) +* newlines, as field separators: Default Field Splitting. + (line 6) +* newlines, as record separators: Records. (line 20) +* newlines, in dynamic regexps: Computed Regexps. (line 59) +* newlines, in regexp constants: Computed Regexps. (line 69) +* newlines, printing: Print Examples. (line 12) +* newlines, separating statements in actions <1>: Statements. (line 10) +* newlines, separating statements in actions: Action Overview. + (line 19) +* next debugger command: Dgawk Execution Control. + (line 43) +* next statement <1>: Next Statement. (line 6) +* next statement: Boolean Ops. (line 85) +* next statement, BEGIN/END patterns and: I/O And BEGIN/END. (line 37) +* next statement, BEGINFILE/ENDFILE patterns and: BEGINFILE/ENDFILE. + (line 49) +* next statement, user-defined functions and: Next Statement. (line 45) +* nextfile statement: Nextfile Statement. (line 6) +* nextfile statement, BEGIN/END patterns and: I/O And BEGIN/END. + (line 37) +* nextfile statement, BEGINFILE/ENDFILE patterns and: BEGINFILE/ENDFILE. + (line 26) +* nextfile statement, user-defined functions and: Nextfile Statement. + (line 44) +* nexti debugger command: Dgawk Execution Control. + (line 49) +* NF variable <1>: Auto-set. (line 107) +* NF variable: Fields. (line 33) +* NF variable, decrementing: Changing Fields. (line 107) +* ni debugger command (alias for nexti): Dgawk Execution Control. + (line 49) +* noassign.awk program: Ignoring Assigns. (line 15) +* NODE internal type: Internals. (line 23) +* nodes, duplicating: Internals. (line 96) +* not Boolean-logic operator: Boolean Ops. (line 6) +* NR variable <1>: Auto-set. (line 118) +* NR variable: Records. (line 6) +* NR variable, changing: Auto-set. (line 207) +* null strings <1>: Basic Data Typing. (line 50) +* null strings <2>: Truth Values. (line 6) +* null strings <3>: Regexp Field Splitting. + (line 43) +* null strings: Records. (line 102) +* null strings, array elements and: Delete. (line 27) +* null strings, as array subscripts: Uninitialized Subscripts. + (line 43) +* null strings, converting numbers to strings: Conversion. (line 21) +* null strings, matching: Gory Details. (line 164) +* null strings, quoting and: Quoting. (line 62) +* number sign (#), #! (executable scripts): Executable Scripts. + (line 6) +* number sign (#), #! (executable scripts), portability issues with: Executable Scripts. + (line 6) +* number sign (#), commenting: Comments. (line 6) +* numbers: Internals. (line 91) +* numbers, as array subscripts: Numeric Array Subscripts. + (line 6) +* numbers, as values of characters: Ordinal Functions. (line 6) +* numbers, Cliff random: Cliff Random Function. + (line 6) +* numbers, converting <1>: Bitwise Functions. (line 107) +* numbers, converting: Conversion. (line 6) +* numbers, converting, to strings: User-modified. (line 28) +* numbers, floating-point: Basic Data Typing. (line 21) +* numbers, floating-point, AWKNUM internal type: Internals. (line 19) +* numbers, hexadecimal: Nondecimal-numbers. (line 6) +* numbers, NODE internal type: Internals. (line 23) +* numbers, octal: Nondecimal-numbers. (line 6) +* numbers, random: Numeric Functions. (line 64) +* numbers, rounding: Round Function. (line 6) +* numeric, constants: Scalar Constants. (line 6) +* numeric, output format: OFMT. (line 6) +* numeric, strings: Variable Typing. (line 6) +* numeric, values: Internals. (line 27) +* o debugger command (alias for option): Dgawk Info. (line 56) +* oawk utility: Names. (line 17) +* obsolete features: Obsolete. (line 6) +* octal numbers: Nondecimal-numbers. (line 6) +* octal values, enabling interpretation of: Options. (line 166) +* OFMT variable <1>: User-modified. (line 115) +* OFMT variable <2>: Conversion. (line 55) +* OFMT variable: OFMT. (line 15) +* OFMT variable, POSIX awk and: OFMT. (line 27) +* OFS variable <1>: User-modified. (line 124) +* OFS variable <2>: Output Separators. (line 6) +* OFS variable: Changing Fields. (line 64) +* OpenBSD: Glossary. (line 611) +* OpenSolaris: Other Versions. (line 86) +* operating systems, BSD-based: Manual History. (line 28) +* operating systems, PC, gawk on: PC Using. (line 6) +* operating systems, PC, gawk on, installing: PC Installation. + (line 6) +* operating systems, porting gawk to: New Ports. (line 6) +* operating systems, See Also GNU/Linux, PC operating systems, Unix: Installation. + (line 6) +* operations, bitwise: Bitwise Functions. (line 6) +* operators, arithmetic: Arithmetic Ops. (line 6) +* operators, assignment: Assignment Ops. (line 6) +* operators, assignment, evaluation order: Assignment Ops. (line 111) +* operators, Boolean, See Boolean expressions: Boolean Ops. (line 6) +* operators, decrement/increment: Increment Ops. (line 6) +* operators, GNU-specific: GNU Regexp Operators. + (line 6) +* operators, input/output <1>: Precedence. (line 65) +* operators, input/output <2>: Redirection. (line 22) +* operators, input/output <3>: Getline/Coprocess. (line 6) +* operators, input/output <4>: Getline/Pipe. (line 6) +* operators, input/output: Getline/File. (line 6) +* operators, logical, See Boolean expressions: Boolean Ops. (line 6) +* operators, precedence <1>: Precedence. (line 6) +* operators, precedence: Increment Ops. (line 61) +* operators, relational, See operators, comparison: Typing and Comparison. + (line 9) +* operators, short-circuit: Boolean Ops. (line 57) +* operators, string: Concatenation. (line 9) +* operators, string-matching: Regexp Usage. (line 19) +* operators, string-matching, for buffers: GNU Regexp Operators. + (line 48) +* operators, word-boundary (gawk): GNU Regexp Operators. + (line 63) +* option debugger command: Dgawk Info. (line 56) +* options, command-line <1>: Command Line Field Separator. + (line 6) +* options, command-line <2>: Options. (line 6) +* options, command-line: Long. (line 12) +* options, command-line, end of: Options. (line 54) +* options, command-line, invoking awk: Command Line. (line 6) +* options, command-line, processing: Getopt Function. (line 6) +* options, deprecated: Obsolete. (line 6) +* options, long <1>: Options. (line 6) +* options, long: Command Line. (line 13) +* options, printing list of: Options. (line 142) +* OR bitwise operation: Bitwise Functions. (line 6) +* or Boolean-logic operator: Boolean Ops. (line 6) +* or() function (gawk): Bitwise Functions. (line 48) +* ord() user-defined function: Ordinal Functions. (line 16) +* order of evaluation, concatenation: Concatenation. (line 42) +* ORS variable <1>: User-modified. (line 129) +* ORS variable: Output Separators. (line 20) +* output field separator, See OFS variable: Changing Fields. (line 64) +* output record separator, See ORS variable: Output Separators. + (line 20) +* output redirection: Redirection. (line 6) +* output, buffering: I/O Functions. (line 29) +* output, duplicating into files: Tee Program. (line 6) +* output, files, closing: Close Files And Pipes. + (line 6) +* output, format specifier, OFMT: OFMT. (line 15) +* output, formatted: Printf. (line 6) +* output, pipes: Redirection. (line 57) +* output, printing, See printing: Printing. (line 6) +* output, records: Output Separators. (line 20) +* output, standard: Special FD. (line 6) +* p debugger command (alias for print): Viewing And Changing Data. + (line 36) +* P1003.1 POSIX standard: Glossary. (line 454) +* P1003.2 POSIX standard: Glossary. (line 454) +* parameters, number of: Internals. (line 49) +* parentheses (): Regexp Operators. (line 79) +* parentheses (), pgawk program: Profiling. (line 141) +* password file: Passwd Functions. (line 16) +* patsplit() function: String Functions. (line 293) +* patterns: Patterns and Actions. + (line 6) +* patterns, comparison expressions as: Expression Patterns. (line 14) +* patterns, counts: Profiling. (line 113) +* patterns, default: Very Simple. (line 34) +* patterns, empty: Empty. (line 6) +* patterns, expressions as: Regexp Patterns. (line 6) +* patterns, ranges in: Ranges. (line 6) +* patterns, regexp constants as: Expression Patterns. (line 36) +* patterns, types of: Pattern Overview. (line 15) +* pawk (profiling version of Brian Kernighan's awk): Other Versions. + (line 69) +* PC operating systems, gawk on: PC Using. (line 6) +* PC operating systems, gawk on, installing: PC Installation. (line 6) +* percent sign (%), % operator: Precedence. (line 55) +* percent sign (%), %= operator <1>: Precedence. (line 95) +* percent sign (%), %= operator: Assignment Ops. (line 129) +* period (.): Regexp Operators. (line 43) +* Perl: Future Extensions. (line 6) +* Peters, Arno: Contributors. (line 85) +* Peterson, Hal: Contributors. (line 40) +* pgawk program: Profiling. (line 6) +* pgawk program, awkprof.out file: Profiling. (line 10) +* pgawk program, dynamic profiling: Profiling. (line 174) +* pipes, closing: Close Files And Pipes. + (line 6) +* pipes, input: Getline/Pipe. (line 6) +* pipes, output: Redirection. (line 57) +* Pitts, Dave <1>: Bugs. (line 73) +* Pitts, Dave: Acknowledgments. (line 60) +* plus sign (+): Regexp Operators. (line 102) +* plus sign (+), + operator: Precedence. (line 52) +* plus sign (+), ++ (decrement/increment operators): Increment Ops. + (line 11) +* plus sign (+), ++ operator <1>: Precedence. (line 46) +* plus sign (+), ++ operator: Increment Ops. (line 40) +* plus sign (+), += operator <1>: Precedence. (line 95) +* plus sign (+), += operator: Assignment Ops. (line 82) +* pointers to functions: Indirect Calls. (line 6) +* portability: Escape Sequences. (line 94) +* portability, #! (executable scripts): Executable Scripts. (line 34) +* portability, ** operator and: Arithmetic Ops. (line 81) +* portability, **= operator and: Assignment Ops. (line 142) +* portability, ARGV variable: Executable Scripts. (line 43) +* portability, backslash continuation and: Statements/Lines. (line 30) +* portability, backslash in escape sequences: Escape Sequences. + (line 113) +* portability, close() function and: Close Files And Pipes. + (line 81) +* portability, data files as single record: Records. (line 175) +* portability, deleting array elements: Delete. (line 52) +* portability, example programs: Library Functions. (line 31) +* portability, fflush() function and: I/O Functions. (line 29) +* portability, functions, defining: Definition Syntax. (line 99) +* portability, gawk: New Ports. (line 6) +* portability, gettext library and: Explaining gettext. (line 10) +* portability, internationalization and: I18N Portability. (line 6) +* portability, length() function: String Functions. (line 175) +* portability, new awk vs. old awk: Conversion. (line 55) +* portability, next statement in user-defined functions: Pass By Value/Reference. + (line 91) +* portability, NF variable, decrementing: Changing Fields. (line 115) +* portability, operators: Increment Ops. (line 61) +* portability, operators, not in POSIX awk: Precedence. (line 98) +* portability, POSIXLY_CORRECT environment variable: Options. (line 310) +* portability, substr() function: String Functions. (line 512) +* portable object files <1>: Translator i18n. (line 6) +* portable object files: Explaining gettext. (line 36) +* portable object files, converting to message object files: I18N Example. + (line 62) +* portable object files, generating: Options. (line 135) +* portable object template files: Explaining gettext. (line 30) +* porting gawk: New Ports. (line 6) +* positional specifiers, printf statement <1>: Printf Ordering. + (line 6) +* positional specifiers, printf statement: Format Modifiers. (line 13) +* positional specifiers, printf statement, mixing with regular formats: Printf Ordering. + (line 57) +* positive zero: Unexpected Results. (line 28) +* POSIX awk <1>: Assignment Ops. (line 136) +* POSIX awk: This Manual. (line 14) +* POSIX awk, ** operator and: Precedence. (line 98) +* POSIX awk, **= operator and: Assignment Ops. (line 142) +* POSIX awk, < operator and: Getline/File. (line 26) +* POSIX awk, arithmetic operators and: Arithmetic Ops. (line 36) +* POSIX awk, backslashes in string constants: Escape Sequences. + (line 113) +* POSIX awk, BEGIN/END patterns: I/O And BEGIN/END. (line 16) +* POSIX awk, bracket expressions and: Bracket Expressions. (line 24) +* POSIX awk, bracket expressions and, character classes: Bracket Expressions. + (line 30) +* POSIX awk, break statement and: Break Statement. (line 51) +* POSIX awk, changes in awk versions: POSIX. (line 6) +* POSIX awk, continue statement and: Continue Statement. (line 43) +* POSIX awk, CONVFMT variable and: User-modified. (line 28) +* POSIX awk, date utility and: Time Functions. (line 261) +* POSIX awk, field separators and <1>: Field Splitting Summary. + (line 41) +* POSIX awk, field separators and: Fields. (line 6) +* POSIX awk, FS variable and: User-modified. (line 66) +* POSIX awk, function keyword in: Definition Syntax. (line 83) +* POSIX awk, functions and, gsub()/sub(): Gory Details. (line 54) +* POSIX awk, functions and, length(): String Functions. (line 175) +* POSIX awk, GNU long options and: Options. (line 15) +* POSIX awk, interval expressions in: Regexp Operators. (line 135) +* POSIX awk, next/nextfile statements and: Next Statement. (line 45) +* POSIX awk, numeric strings and: Variable Typing. (line 6) +* POSIX awk, OFMT variable and <1>: Conversion. (line 55) +* POSIX awk, OFMT variable and: OFMT. (line 27) +* POSIX awk, period (.), using: Regexp Operators. (line 50) +* POSIX awk, printf format strings and: Format Modifiers. (line 159) +* POSIX awk, regular expressions and: Regexp Operators. (line 161) +* POSIX awk, timestamps and: Time Functions. (line 6) +* POSIX awk, | I/O operator and: Getline/Pipe. (line 52) +* POSIX mode: Options. (line 199) +* POSIX, awk and: Preface. (line 23) +* POSIX, gawk extensions not included in: POSIX/GNU. (line 6) +* POSIX, programs, implementing in awk: Clones. (line 6) +* POSIXLY_CORRECT environment variable: Options. (line 289) +* precedence <1>: Precedence. (line 6) +* precedence: Increment Ops. (line 61) +* precedence, regexp operators: Regexp Operators. (line 156) +* print debugger command: Viewing And Changing Data. + (line 36) +* print statement: Printing. (line 16) +* print statement, BEGIN/END patterns and: I/O And BEGIN/END. (line 16) +* print statement, commas, omitting: Print Examples. (line 31) +* print statement, I/O operators in: Precedence. (line 71) +* print statement, line continuations and: Print Examples. (line 76) +* print statement, OFMT variable and: User-modified. (line 124) +* print statement, See Also redirection, of output: Redirection. + (line 17) +* print statement, sprintf() function and: Round Function. (line 6) +* printf debugger command: Viewing And Changing Data. + (line 54) +* printf statement <1>: Printf. (line 6) +* printf statement: Printing. (line 16) +* printf statement, columns, aligning: Print Examples. (line 70) +* printf statement, format-control characters: Control Letters. + (line 6) +* printf statement, I/O operators in: Precedence. (line 71) +* printf statement, modifiers: Format Modifiers. (line 6) +* printf statement, positional specifiers <1>: Printf Ordering. + (line 6) +* printf statement, positional specifiers: Format Modifiers. (line 13) +* printf statement, positional specifiers, mixing with regular formats: Printf Ordering. + (line 57) +* printf statement, See Also redirection, of output: Redirection. + (line 17) +* printf statement, sprintf() function and: Round Function. (line 6) +* printf statement, syntax of: Basic Printf. (line 6) +* printing: Printing. (line 6) +* printing, list of options: Options. (line 142) +* printing, mailing labels: Labels Program. (line 6) +* printing, unduplicated lines of text: Uniq Program. (line 6) +* printing, user information: Id Program. (line 6) +* private variables: Library Names. (line 11) +* processes, two-way communications with: Two-way I/O. (line 23) +* processing data: Basic High Level. (line 6) +* PROCINFO array <1>: Internals. (line 149) +* PROCINFO array <2>: Id Program. (line 15) +* PROCINFO array <3>: Group Functions. (line 6) +* PROCINFO array <4>: Passwd Functions. (line 6) +* PROCINFO array <5>: Two-way I/O. (line 116) +* PROCINFO array <6>: Time Functions. (line 46) +* PROCINFO array <7>: Auto-set. (line 123) +* PROCINFO array: Obsolete. (line 11) +* profiling awk programs: Profiling. (line 6) +* profiling awk programs, dynamically: Profiling. (line 174) +* profiling gawk, See pgawk program: Profiling. (line 6) +* program, definition of: Getting Started. (line 21) +* programmers, attractiveness of: Two-way I/O. (line 6) +* programming conventions, --non-decimal-data option: Nondecimal Data. + (line 36) +* programming conventions, ARGC/ARGV variables: Auto-set. (line 31) +* programming conventions, exit statement: Exit Statement. (line 38) +* programming conventions, function parameters: Return Statement. + (line 45) +* programming conventions, functions, calling: Calling Built-in. + (line 10) +* programming conventions, functions, writing: Definition Syntax. + (line 55) +* programming conventions, gawk internals: Internal File Ops. (line 33) +* programming conventions, private variable names: Library Names. + (line 23) +* programming language, recipe for: History. (line 6) +* Programming languages, Ada: Glossary. (line 20) +* programming languages, data-driven vs. procedural: Getting Started. + (line 12) +* Programming languages, Java: Glossary. (line 380) +* programming, basic steps: Basic High Level. (line 19) +* programming, concepts: Basic Concepts. (line 6) +* pwcat program: Passwd Functions. (line 23) +* q debugger command (alias for quit): Miscellaneous Dgawk Commands. + (line 101) +* QSE Awk: Other Versions. (line 108) +* question mark (?) regexp operator <1>: GNU Regexp Operators. + (line 59) +* question mark (?) regexp operator: Regexp Operators. (line 111) +* question mark (?), ?: operator: Precedence. (line 92) +* QuikTrim Awk: Other Versions. (line 112) +* quit debugger command: Miscellaneous Dgawk Commands. + (line 101) +* QUIT signal (MS-Windows): Profiling. (line 207) +* quoting <1>: Comments. (line 27) +* quoting <2>: Long. (line 26) +* quoting: Read Terminal. (line 25) +* quoting, rules for: Quoting. (line 6) +* quoting, tricks for: Quoting. (line 71) +* r debugger command (alias for run): Dgawk Execution Control. + (line 62) +* Rakitzis, Byron: History Sorting. (line 25) +* rand() function: Numeric Functions. (line 34) +* random numbers, Cliff: Cliff Random Function. + (line 6) +* random numbers, rand()/srand() functions: Numeric Functions. + (line 34) +* random numbers, seed of: Numeric Functions. (line 64) +* range expressions (regexps): Bracket Expressions. (line 6) +* range patterns: Ranges. (line 6) +* Rankin, Pat <1>: Bugs. (line 72) +* Rankin, Pat <2>: Contributors. (line 38) +* Rankin, Pat <3>: Assignment Ops. (line 100) +* Rankin, Pat: Acknowledgments. (line 60) +* readable data files, checking: File Checking. (line 6) +* readable.awk program: File Checking. (line 11) +* recipe for a programming language: History. (line 6) +* record separators <1>: User-modified. (line 134) +* record separators: Records. (line 14) +* record separators, changing: Records. (line 81) +* record separators, regular expressions as: Records. (line 112) +* record separators, with multiline records: Multiple Line. (line 10) +* records <1>: Basic High Level. (line 71) +* records: Reading Files. (line 14) +* records, multiline: Multiple Line. (line 6) +* records, printing: Print. (line 22) +* records, splitting input into: Records. (line 6) +* records, terminating: Records. (line 112) +* records, treating files as: Records. (line 196) +* recursive functions: Definition Syntax. (line 73) +* redirection of input: Getline/File. (line 6) +* redirection of output: Redirection. (line 6) +* reference counting, sorting arrays: Array Sorting Functions. + (line 75) +* regexp constants <1>: Comparison Operators. + (line 103) +* regexp constants <2>: Regexp Constants. (line 6) +* regexp constants: Regexp Usage. (line 57) +* regexp constants, /=.../, /= operator and: Assignment Ops. (line 148) +* regexp constants, as patterns: Expression Patterns. (line 36) +* regexp constants, in gawk: Using Constant Regexps. + (line 28) +* regexp constants, slashes vs. quotes: Computed Regexps. (line 28) +* regexp constants, vs. string constants: Computed Regexps. (line 38) +* regexp, See regular expressions: Regexp. (line 6) +* register_deferred_variable() internal function: Internals. (line 149) +* register_open_hook() internal function: Internals. (line 160) +* regular expressions: Regexp. (line 6) +* regular expressions as field separators: Field Separators. (line 50) +* regular expressions, anchors in: Regexp Operators. (line 22) +* regular expressions, as field separators: Regexp Field Splitting. + (line 6) +* regular expressions, as patterns <1>: Regexp Patterns. (line 6) +* regular expressions, as patterns: Regexp Usage. (line 6) +* regular expressions, as record separators: Records. (line 112) +* regular expressions, case sensitivity <1>: User-modified. (line 82) +* regular expressions, case sensitivity: Case-sensitivity. (line 6) +* regular expressions, computed: Computed Regexps. (line 6) +* regular expressions, constants, See regexp constants: Regexp Usage. + (line 57) +* regular expressions, dynamic: Computed Regexps. (line 6) +* regular expressions, dynamic, with embedded newlines: Computed Regexps. + (line 59) +* regular expressions, gawk, command-line options: GNU Regexp Operators. + (line 70) +* regular expressions, interval expressions and: Options. (line 224) +* regular expressions, leftmost longest match: Leftmost Longest. + (line 6) +* regular expressions, operators <1>: Regexp Operators. (line 6) +* regular expressions, operators: Regexp Usage. (line 19) +* regular expressions, operators, for buffers: GNU Regexp Operators. + (line 48) +* regular expressions, operators, for words: GNU Regexp Operators. + (line 6) +* regular expressions, operators, gawk: GNU Regexp Operators. + (line 6) +* regular expressions, operators, precedence of: Regexp Operators. + (line 156) +* regular expressions, searching for: Egrep Program. (line 6) +* relational operators, See comparison operators: Typing and Comparison. + (line 9) +* return debugger command: Dgawk Execution Control. + (line 54) +* return statement, user-defined functions: Return Statement. (line 6) +* return values, close() function: Close Files And Pipes. + (line 131) +* rev() user-defined function: Function Example. (line 52) +* rewind() user-defined function: Rewind Function. (line 16) +* right angle bracket (>), > operator <1>: Precedence. (line 65) +* right angle bracket (>), > operator: Comparison Operators. + (line 11) +* right angle bracket (>), > operator (I/O): Redirection. (line 22) +* right angle bracket (>), >= operator <1>: Precedence. (line 65) +* right angle bracket (>), >= operator: Comparison Operators. + (line 11) +* right angle bracket (>), >> operator (I/O) <1>: Precedence. (line 65) +* right angle bracket (>), >> operator (I/O): Redirection. (line 50) +* right shift, bitwise: Bitwise Functions. (line 32) +* Ritchie, Dennis: Basic Data Typing. (line 74) +* RLENGTH variable: Auto-set. (line 183) +* RLENGTH variable, match() function and: String Functions. (line 223) +* Robbins, Arnold <1>: Future Extensions. (line 6) +* Robbins, Arnold <2>: Bugs. (line 32) +* Robbins, Arnold <3>: Contributors. (line 108) +* Robbins, Arnold <4>: Alarm Program. (line 6) +* Robbins, Arnold <5>: Passwd Functions. (line 90) +* Robbins, Arnold <6>: Getline/Pipe. (line 36) +* Robbins, Arnold: Command Line Field Separator. + (line 80) +* Robbins, Bill: Getline/Pipe. (line 36) +* Robbins, Harry: Acknowledgments. (line 81) +* Robbins, Jean: Acknowledgments. (line 81) +* Robbins, Miriam <1>: Passwd Functions. (line 90) +* Robbins, Miriam <2>: Getline/Pipe. (line 36) +* Robbins, Miriam: Acknowledgments. (line 81) +* Robinson, Will: Dynamic Extensions. (line 6) +* robot, the: Dynamic Extensions. (line 6) +* Rommel, Kai Uwe: Contributors. (line 43) +* round() user-defined function: Round Function. (line 16) +* rounding numbers: Round Function. (line 6) +* RS variable <1>: User-modified. (line 134) +* RS variable: Records. (line 20) +* RS variable, multiline records and: Multiple Line. (line 17) +* rshift() function (gawk): Bitwise Functions. (line 51) +* RSTART variable: Auto-set. (line 189) +* RSTART variable, match() function and: String Functions. (line 223) +* RT variable <1>: Auto-set. (line 196) +* RT variable <2>: Getline/Variable/File. + (line 10) +* RT variable <3>: Multiple Line. (line 129) +* RT variable: Records. (line 112) +* Rubin, Paul <1>: Contributors. (line 16) +* Rubin, Paul: History. (line 30) +* rule, definition of: Getting Started. (line 21) +* run debugger command: Dgawk Execution Control. + (line 62) +* rvalues/lvalues: Assignment Ops. (line 32) +* s debugger command (alias for step): Dgawk Execution Control. + (line 68) +* sandbox mode: Options. (line 236) +* scalar values: Basic Data Typing. (line 13) +* Schorr, Andrew: Acknowledgments. (line 60) +* Schreiber, Bert: Acknowledgments. (line 38) +* Schreiber, Rita: Acknowledgments. (line 38) +* search paths <1>: VMS Running. (line 29) +* search paths <2>: PC Using. (line 11) +* search paths <3>: Igawk Program. (line 368) +* search paths: AWKPATH Variable. (line 6) +* search paths, for source files <1>: VMS Running. (line 29) +* search paths, for source files <2>: PC Using. (line 11) +* search paths, for source files <3>: Igawk Program. (line 368) +* search paths, for source files: AWKPATH Variable. (line 6) +* searching: String Functions. (line 155) +* searching, files for regular expressions: Egrep Program. (line 6) +* searching, for words: Dupword Program. (line 6) +* sed utility <1>: Glossary. (line 12) +* sed utility <2>: Simple Sed. (line 6) +* sed utility: Field Splitting Summary. + (line 47) +* semicolon (;): Statements/Lines. (line 91) +* semicolon (;), AWKPATH variable and: PC Using. (line 11) +* semicolon (;), separating statements in actions <1>: Statements. + (line 10) +* semicolon (;), separating statements in actions: Action Overview. + (line 19) +* separators, field: User-modified. (line 56) +* separators, field, FIELDWIDTHS variable and: User-modified. (line 35) +* separators, field, FPAT variable and: User-modified. (line 45) +* separators, field, POSIX and: Fields. (line 6) +* separators, for records <1>: User-modified. (line 134) +* separators, for records: Records. (line 14) +* separators, for records, regular expressions as: Records. (line 112) +* separators, for statements in actions: Action Overview. (line 19) +* separators, subscript: User-modified. (line 147) +* set debugger command: Viewing And Changing Data. + (line 59) +* shells, piping commands into: Redirection. (line 143) +* shells, quoting: Using Shell Variables. + (line 12) +* shells, quoting, rules for: Quoting. (line 18) +* shells, scripts: One-shot. (line 22) +* shells, variables: Using Shell Variables. + (line 6) +* shift, bitwise: Bitwise Functions. (line 32) +* short-circuit operators: Boolean Ops. (line 57) +* si debugger command (alias for stepi): Dgawk Execution Control. + (line 76) +* side effects <1>: Increment Ops. (line 11) +* side effects: Concatenation. (line 42) +* side effects, array indexing: Reference to Elements. + (line 42) +* side effects, asort() function: Array Sorting Functions. + (line 24) +* side effects, assignment expressions: Assignment Ops. (line 23) +* side effects, Boolean operators: Boolean Ops. (line 30) +* side effects, conditional expressions: Conditional Exp. (line 22) +* side effects, decrement/increment operators: Increment Ops. (line 11) +* side effects, FILENAME variable: Getline Notes. (line 19) +* side effects, function calls: Function Calls. (line 54) +* side effects, statements: Action Overview. (line 32) +* SIGHUP signal: Profiling. (line 204) +* SIGINT signal (MS-Windows): Profiling. (line 207) +* signals, HUP/SIGHUP: Profiling. (line 204) +* signals, INT/SIGINT (MS-Windows): Profiling. (line 207) +* signals, QUIT/SIGQUIT (MS-Windows): Profiling. (line 207) +* signals, USR1/SIGUSR1: Profiling. (line 182) +* SIGQUIT signal (MS-Windows): Profiling. (line 207) +* SIGUSR1 signal: Profiling. (line 182) +* silent debugger command: Dgawk Execution Control. + (line 10) +* sin() function: Numeric Functions. (line 75) +* single precision floating-point: Basic Data Typing. (line 36) +* single quote (') <1>: Quoting. (line 31) +* single quote (') <2>: Long. (line 33) +* single quote ('): One-shot. (line 15) +* single quote ('), vs. apostrophe: Comments. (line 27) +* single quote ('), with double quotes: Quoting. (line 53) +* single-character fields: Single Character Fields. + (line 6) +* Skywalker, Luke: Undocumented. (line 6) +* sleep utility: Alarm Program. (line 109) +* Solaris, POSIX-compliant awk: Other Versions. (line 86) +* sort function, arrays, sorting: Array Sorting Functions. + (line 6) +* sort utility: Word Sorting. (line 50) +* sort utility, coprocesses and: Two-way I/O. (line 83) +* sorting characters in different languages: Explaining gettext. + (line 93) +* source code, awka: Other Versions. (line 55) +* source code, Brian Kernighan's awk: Other Versions. (line 13) +* source code, Busybox Awk: Other Versions. (line 78) +* source code, gawk: Gawk Distribution. (line 6) +* source code, jawk: Other Versions. (line 96) +* source code, libmawk: Other Versions. (line 104) +* source code, mawk: Other Versions. (line 35) +* source code, mixing: Options. (line 105) +* source code, pawk: Other Versions. (line 69) +* source code, QSE Awk: Other Versions. (line 108) +* source code, QuikTrim Awk: Other Versions. (line 112) +* source code, Solaris awk: Other Versions. (line 86) +* source code, xgawk: Other Versions. (line 119) +* source files, search path for: Igawk Program. (line 368) +* sparse arrays: Array Intro. (line 71) +* Spencer, Henry: Glossary. (line 12) +* split utility: Split Program. (line 6) +* split() function: String Functions. (line 315) +* split() function, array elements, deleting: Delete. (line 57) +* split.awk program: Split Program. (line 30) +* sprintf() function <1>: String Functions. (line 380) +* sprintf() function: OFMT. (line 15) +* sprintf() function, OFMT variable and: User-modified. (line 124) +* sprintf() function, print/printf statements and: Round Function. + (line 6) +* sqrt() function: Numeric Functions. (line 78) +* square brackets ([]): Regexp Operators. (line 55) +* srand() function: Numeric Functions. (line 82) +* Stallman, Richard <1>: Glossary. (line 301) +* Stallman, Richard <2>: Contributors. (line 24) +* Stallman, Richard <3>: Acknowledgments. (line 18) +* Stallman, Richard: Manual History. (line 6) +* standard error: Special FD. (line 6) +* standard input <1>: Special FD. (line 6) +* standard input: Read Terminal. (line 6) +* standard output: Special FD. (line 6) +* stat() function, implementing in gawk: Sample Library. (line 6) +* statements, compound, control statements and: Statements. (line 10) +* statements, control, in actions: Statements. (line 6) +* statements, multiple: Statements/Lines. (line 91) +* step debugger command: Dgawk Execution Control. + (line 68) +* stepi debugger command: Dgawk Execution Control. + (line 76) +* stlen internal variable: Internals. (line 53) +* stptr internal variable: Internals. (line 53) +* stream editors <1>: Simple Sed. (line 6) +* stream editors: Field Splitting Summary. + (line 47) +* strftime() function (gawk): Time Functions. (line 47) +* string constants: Scalar Constants. (line 15) +* string constants, vs. regexp constants: Computed Regexps. (line 38) +* string extraction (internationalization): String Extraction. + (line 6) +* string operators: Concatenation. (line 9) +* string-matching operators: Regexp Usage. (line 19) +* strings: Internals. (line 86) +* strings, converting <1>: Bitwise Functions. (line 107) +* strings, converting: Conversion. (line 6) +* strings, converting, numbers to: User-modified. (line 28) +* strings, empty, See null strings: Records. (line 102) +* strings, extracting: String Extraction. (line 6) +* strings, for localization: Programmer i18n. (line 14) +* strings, length of: Scalar Constants. (line 20) +* strings, merging arrays into: Join Function. (line 6) +* strings, NODE internal type: Internals. (line 23) +* strings, null: Regexp Field Splitting. + (line 43) +* strings, numeric: Variable Typing. (line 6) +* strings, splitting: String Functions. (line 335) +* strtonum() function (gawk): String Functions. (line 387) +* strtonum() function (gawk), --non-decimal-data option and: Nondecimal Data. + (line 36) +* sub() function <1>: String Functions. (line 408) +* sub() function: Using Constant Regexps. + (line 43) +* sub() function, arguments of: String Functions. (line 462) +* sub() function, escape processing: Gory Details. (line 6) +* subscript separators: User-modified. (line 147) +* subscripts in arrays, multidimensional: Multi-dimensional. (line 10) +* subscripts in arrays, multidimensional, scanning: Multi-scanning. + (line 11) +* subscripts in arrays, numbers as: Numeric Array Subscripts. + (line 6) +* subscripts in arrays, uninitialized variables as: Uninitialized Subscripts. + (line 6) +* SUBSEP variable: User-modified. (line 147) +* SUBSEP variable, multidimensional arrays: Multi-dimensional. + (line 16) +* substr() function: String Functions. (line 481) +* Sumner, Andrew: Other Versions. (line 55) +* switch statement: Switch Statement. (line 6) +* syntactic ambiguity: /= operator vs. /=.../ regexp constant: Assignment Ops. + (line 148) +* system() function: I/O Functions. (line 63) +* systime() function (gawk): Time Functions. (line 64) +* t debugger command (alias for tbreak): Breakpoint Control. (line 89) +* tbreak debugger command: Breakpoint Control. (line 89) +* Tcl: Library Names. (line 57) +* TCP/IP: TCP/IP Networking. (line 6) +* TCP/IP, support for: Special Network. (line 6) +* tee utility: Tee Program. (line 6) +* tee.awk program: Tee Program. (line 26) +* terminating records: Records. (line 112) +* testbits.awk program: Bitwise Functions. (line 68) +* Texinfo <1>: Adding Code. (line 99) +* Texinfo <2>: Distribution contents. + (line 79) +* Texinfo <3>: Extract Program. (line 12) +* Texinfo <4>: Dupword Program. (line 17) +* Texinfo <5>: Library Functions. (line 22) +* Texinfo <6>: Sample Data Files. (line 66) +* Texinfo: Conventions. (line 6) +* Texinfo, chapter beginnings in files: Regexp Operators. (line 22) +* Texinfo, extracting programs from source files: Extract Program. + (line 6) +* text, printing: Print. (line 22) +* text, printing, unduplicated lines of: Uniq Program. (line 6) +* TEXTDOMAIN variable <1>: Programmer i18n. (line 9) +* TEXTDOMAIN variable: User-modified. (line 153) +* TEXTDOMAIN variable, BEGIN pattern and: Programmer i18n. (line 60) +* TEXTDOMAIN variable, portability and: I18N Portability. (line 20) +* textdomain() function (C library): Explaining gettext. (line 27) +* tilde (~), ~ operator <1>: Expression Patterns. (line 24) +* tilde (~), ~ operator <2>: Precedence. (line 80) +* tilde (~), ~ operator <3>: Comparison Operators. + (line 11) +* tilde (~), ~ operator <4>: Regexp Constants. (line 6) +* tilde (~), ~ operator <5>: Computed Regexps. (line 6) +* tilde (~), ~ operator <6>: Case-sensitivity. (line 26) +* tilde (~), ~ operator: Regexp Usage. (line 19) +* time, alarm clock example program: Alarm Program. (line 9) +* time, localization and: Explaining gettext. (line 115) +* time, managing: Gettimeofday Function. + (line 6) +* time, retrieving: Time Functions. (line 17) +* timestamps: Time Functions. (line 6) +* timestamps, converting dates to: Time Functions. (line 74) +* timestamps, formatted: Gettimeofday Function. + (line 6) +* tolower() function: String Functions. (line 523) +* toupper() function: String Functions. (line 529) +* tr utility: Translate Program. (line 6) +* trace debugger command: Miscellaneous Dgawk Commands. + (line 110) +* translate.awk program: Translate Program. (line 55) +* troubleshooting, --non-decimal-data option: Options. (line 166) +* troubleshooting, == operator: Comparison Operators. + (line 37) +* troubleshooting, awk uses FS not IFS: Field Separators. (line 29) +* troubleshooting, backslash before nonspecial character: Escape Sequences. + (line 113) +* troubleshooting, division: Arithmetic Ops. (line 44) +* troubleshooting, fatal errors, field widths, specifying: Constant Size. + (line 22) +* troubleshooting, fatal errors, printf format strings: Format Modifiers. + (line 159) +* troubleshooting, fflush() function: I/O Functions. (line 51) +* troubleshooting, function call syntax: Function Calls. (line 28) +* troubleshooting, gawk: Compatibility Mode. (line 6) +* troubleshooting, gawk, bug reports: Bugs. (line 9) +* troubleshooting, gawk, fatal errors, function arguments: Calling Built-in. + (line 16) +* troubleshooting, getline function: File Checking. (line 25) +* troubleshooting, gsub()/sub() functions: String Functions. (line 472) +* troubleshooting, match() function: String Functions. (line 288) +* troubleshooting, patsplit() function: String Functions. (line 311) +* troubleshooting, print statement, omitting commas: Print Examples. + (line 31) +* troubleshooting, printing: Redirection. (line 118) +* troubleshooting, quotes with file names: Special FD. (line 68) +* troubleshooting, readable data files: File Checking. (line 6) +* troubleshooting, regexp constants vs. string constants: Computed Regexps. + (line 38) +* troubleshooting, string concatenation: Concatenation. (line 27) +* troubleshooting, substr() function: String Functions. (line 499) +* troubleshooting, system() function: I/O Functions. (line 85) +* troubleshooting, typographical errors, global variables: Options. + (line 95) +* true, logical: Truth Values. (line 6) +* Trueman, David <1>: Contributors. (line 31) +* Trueman, David <2>: Acknowledgments. (line 47) +* Trueman, David: History. (line 30) +* trunc-mod operation: Arithmetic Ops. (line 66) +* truth values: Truth Values. (line 6) +* type conversion: Conversion. (line 21) +* type internal variable: Internals. (line 66) +* u debugger command (alias for until): Dgawk Execution Control. + (line 83) +* undefined functions: Pass By Value/Reference. + (line 71) +* underscore (_), _ C macro: Explaining gettext. (line 70) +* underscore (_), in names of private variables: Library Names. + (line 29) +* underscore (_), translatable string: Programmer i18n. (line 69) +* undisplay debugger command: Viewing And Changing Data. + (line 80) +* undocumented features: Undocumented. (line 6) +* Unicode: Glossary. (line 141) +* uninitialized variables, as array subscripts: Uninitialized Subscripts. + (line 6) +* uniq utility: Uniq Program. (line 6) +* uniq.awk program: Uniq Program. (line 65) +* Unix: Glossary. (line 611) +* Unix awk, backslashes in escape sequences: Escape Sequences. + (line 125) +* Unix awk, close() function and: Close Files And Pipes. + (line 131) +* Unix awk, password files, field separators and: Command Line Field Separator. + (line 72) +* Unix, awk scripts and: Executable Scripts. (line 6) +* UNIXROOT variable, on OS/2 systems: PC Using. (line 17) +* unref() internal function: Internals. (line 101) +* unsigned integers: Basic Data Typing. (line 30) +* until debugger command: Dgawk Execution Control. + (line 83) +* unwatch debugger command: Viewing And Changing Data. + (line 84) +* up debugger command: Dgawk Stack. (line 33) +* update_ERRNO() internal function: Internals. (line 139) +* update_ERRNO_saved() internal function: Internals. (line 144) +* user database, reading: Passwd Functions. (line 6) +* user-defined, functions: User-defined. (line 6) +* user-defined, functions, counts: Profiling. (line 132) +* user-defined, variables: Variables. (line 6) +* user-modifiable variables: User-modified. (line 6) +* users, information about, printing: Id Program. (line 6) +* users, information about, retrieving: Passwd Functions. (line 16) +* USR1 signal: Profiling. (line 182) +* values, numeric: Basic Data Typing. (line 13) +* values, string: Basic Data Typing. (line 13) +* variable typing: Typing and Comparison. + (line 9) +* variables <1>: Basic Data Typing. (line 6) +* variables: Other Features. (line 6) +* variables, assigning on command line: Assignment Options. (line 6) +* variables, built-in <1>: Built-in Variables. (line 6) +* variables, built-in: Using Variables. (line 20) +* variables, built-in, -v option, setting with: Options. (line 40) +* variables, built-in, conveying information: Auto-set. (line 6) +* variables, flag: Boolean Ops. (line 67) +* variables, getline command into, using <1>: Getline/Variable/Coprocess. + (line 6) +* variables, getline command into, using <2>: Getline/Variable/Pipe. + (line 6) +* variables, getline command into, using <3>: Getline/Variable/File. + (line 6) +* variables, getline command into, using: Getline/Variable. (line 6) +* variables, global, for library functions: Library Names. (line 11) +* variables, global, printing list of: Options. (line 90) +* variables, initializing: Using Variables. (line 20) +* variables, local: Variable Scope. (line 6) +* variables, names of: Arrays. (line 18) +* variables, private: Library Names. (line 11) +* variables, setting: Options. (line 32) +* variables, shadowing: Definition Syntax. (line 61) +* variables, types of: Assignment Ops. (line 40) +* variables, types of, comparison expressions and: Typing and Comparison. + (line 9) +* variables, uninitialized, as array subscripts: Uninitialized Subscripts. + (line 6) +* variables, user-defined: Variables. (line 6) +* vertical bar (|): Regexp Operators. (line 69) +* vertical bar (|), | operator (I/O) <1>: Precedence. (line 65) +* vertical bar (|), | operator (I/O): Getline/Pipe. (line 6) +* vertical bar (|), |& operator (I/O) <1>: Two-way I/O. (line 44) +* vertical bar (|), |& operator (I/O) <2>: Precedence. (line 65) +* vertical bar (|), |& operator (I/O): Getline/Coprocess. (line 6) +* vertical bar (|), || operator <1>: Precedence. (line 89) +* vertical bar (|), || operator: Boolean Ops. (line 57) +* Vinschen, Corinna: Acknowledgments. (line 60) +* vname internal variable: Internals. (line 71) +* w debugger command (alias for watch): Viewing And Changing Data. + (line 67) +* w utility: Constant Size. (line 22) +* walk_array() user-defined function: Walking Arrays. (line 14) +* Wall, Larry <1>: Future Extensions. (line 6) +* Wall, Larry: Array Intro. (line 6) +* Wallin, Anders: Acknowledgments. (line 60) +* warnings, issuing: Options. (line 147) +* watch debugger command: Viewing And Changing Data. + (line 67) +* wc utility: Wc Program. (line 6) +* wc.awk program: Wc Program. (line 46) +* Weinberger, Peter <1>: Contributors. (line 12) +* Weinberger, Peter: History. (line 17) +* while statement <1>: While Statement. (line 6) +* while statement: Regexp Usage. (line 19) +* whitespace, as field separators: Default Field Splitting. + (line 6) +* whitespace, functions, calling: Calling Built-in. (line 10) +* whitespace, newlines as: Options. (line 205) +* Williams, Kent: Contributors. (line 35) +* Woehlke, Matthew: Contributors. (line 79) +* Woods, John: Contributors. (line 28) +* word boundaries, matching: GNU Regexp Operators. + (line 38) +* word, regexp definition of: GNU Regexp Operators. + (line 6) +* word-boundary operator (gawk): GNU Regexp Operators. + (line 63) +* wordfreq.awk program: Word Sorting. (line 56) +* words, counting: Wc Program. (line 6) +* words, duplicate, searching for: Dupword Program. (line 6) +* words, usage counts, generating: Word Sorting. (line 6) +* wstlen internal variable: Internals. (line 61) +* wstptr internal variable: Internals. (line 61) +* xgawk: Other Versions. (line 119) +* xgettext utility: String Extraction. (line 13) +* XML (eXtensible Markup Language): Internals. (line 160) +* XOR bitwise operation: Bitwise Functions. (line 6) +* xor() function (gawk): Bitwise Functions. (line 54) +* Yawitz, Efraim: Contributors. (line 106) +* Zaretskii, Eli <1>: Bugs. (line 70) +* Zaretskii, Eli <2>: Contributors. (line 56) +* Zaretskii, Eli: Acknowledgments. (line 60) +* zero, negative vs. positive: Unexpected Results. (line 28) +* zerofile.awk program: Empty Files. (line 21) +* Zoulas, Christos: Contributors. (line 67) +* {} (braces), actions and: Action Overview. (line 19) +* {} (braces), pgawk program: Profiling. (line 137) +* {} (braces), statements, grouping: Statements. (line 10) +* | (vertical bar): Regexp Operators. (line 69) +* | (vertical bar), | operator (I/O) <1>: Precedence. (line 65) +* | (vertical bar), | operator (I/O) <2>: Redirection. (line 57) +* | (vertical bar), | operator (I/O): Getline/Pipe. (line 6) +* | (vertical bar), |& operator (I/O) <1>: Two-way I/O. (line 44) +* | (vertical bar), |& operator (I/O) <2>: Precedence. (line 65) +* | (vertical bar), |& operator (I/O) <3>: Redirection. (line 102) +* | (vertical bar), |& operator (I/O): Getline/Coprocess. (line 6) +* | (vertical bar), |& operator (I/O), pipes, closing: Close Files And Pipes. + (line 118) +* | (vertical bar), || operator <1>: Precedence. (line 89) +* | (vertical bar), || operator: Boolean Ops. (line 57) +* ~ (tilde), ~ operator <1>: Expression Patterns. (line 24) +* ~ (tilde), ~ operator <2>: Precedence. (line 80) +* ~ (tilde), ~ operator <3>: Comparison Operators. + (line 11) +* ~ (tilde), ~ operator <4>: Regexp Constants. (line 6) +* ~ (tilde), ~ operator <5>: Computed Regexps. (line 6) +* ~ (tilde), ~ operator <6>: Case-sensitivity. (line 26) +* ~ (tilde), ~ operator: Regexp Usage. (line 19) + + + +Tag Table: +Node: Top1352 +Node: Foreword30282 +Node: Preface34627 +Ref: Preface-Footnote-137680 +Ref: Preface-Footnote-237786 +Node: History38018 +Node: Names40409 +Ref: Names-Footnote-141886 +Node: This Manual41958 +Ref: This Manual-Footnote-146905 +Node: Conventions47005 +Node: Manual History49139 +Ref: Manual History-Footnote-152409 +Ref: Manual History-Footnote-252450 +Node: How To Contribute52524 +Node: Acknowledgments53668 +Node: Getting Started57999 +Node: Running gawk60378 +Node: One-shot61564 +Node: Read Terminal62789 +Ref: Read Terminal-Footnote-164439 +Ref: Read Terminal-Footnote-264715 +Node: Long64886 +Node: Executable Scripts66262 +Ref: Executable Scripts-Footnote-168131 +Ref: Executable Scripts-Footnote-268233 +Node: Comments68780 +Node: Quoting71247 +Node: DOS Quoting75870 +Node: Sample Data Files76545 +Node: Very Simple79577 +Node: Two Rules84176 +Node: More Complex86323 +Ref: More Complex-Footnote-189253 +Node: Statements/Lines89338 +Ref: Statements/Lines-Footnote-193800 +Node: Other Features94065 +Node: When94993 +Node: Invoking Gawk97140 +Node: Command Line98525 +Node: Options99308 +Ref: Options-Footnote-1112745 +Node: Other Arguments112770 +Node: Naming Standard Input115428 +Node: Environment Variables116522 +Node: AWKPATH Variable116966 +Ref: AWKPATH Variable-Footnote-1119563 +Node: Other Environment Variables119823 +Node: Exit Status122163 +Node: Include Files122838 +Node: Obsolete126323 +Node: Undocumented127009 +Node: Regexp127250 +Node: Regexp Usage128639 +Node: Escape Sequences130665 +Node: Regexp Operators136428 +Ref: Regexp Operators-Footnote-1143808 +Ref: Regexp Operators-Footnote-2143955 +Node: Bracket Expressions144053 +Ref: table-char-classes145943 +Node: GNU Regexp Operators148466 +Node: Case-sensitivity152189 +Ref: Case-sensitivity-Footnote-1155157 +Ref: Case-sensitivity-Footnote-2155392 +Node: Leftmost Longest155500 +Node: Computed Regexps156701 +Node: Reading Files160111 +Node: Records162052 +Ref: Records-Footnote-1170726 +Node: Fields170763 +Ref: Fields-Footnote-1173796 +Node: Nonconstant Fields173882 +Node: Changing Fields176084 +Node: Field Separators182065 +Node: Default Field Splitting184694 +Node: Regexp Field Splitting185811 +Node: Single Character Fields189153 +Node: Command Line Field Separator190212 +Node: Field Splitting Summary193653 +Ref: Field Splitting Summary-Footnote-1196845 +Node: Constant Size196946 +Node: Splitting By Content201530 +Ref: Splitting By Content-Footnote-1205256 +Node: Multiple Line205296 +Ref: Multiple Line-Footnote-1211143 +Node: Getline211322 +Node: Plain Getline213550 +Node: Getline/Variable215639 +Node: Getline/File216780 +Node: Getline/Variable/File218102 +Ref: Getline/Variable/File-Footnote-1219701 +Node: Getline/Pipe219788 +Node: Getline/Variable/Pipe222348 +Node: Getline/Coprocess223455 +Node: Getline/Variable/Coprocess224698 +Node: Getline Notes225412 +Node: Getline Summary227354 +Ref: table-getline-variants227697 +Node: Command line directories228553 +Node: Printing229178 +Node: Print230809 +Node: Print Examples232146 +Node: Output Separators234930 +Node: OFMT236690 +Node: Printf238048 +Node: Basic Printf238954 +Node: Control Letters240493 +Node: Format Modifiers244305 +Node: Printf Examples250314 +Node: Redirection253029 +Node: Special Files260013 +Node: Special FD260546 +Ref: Special FD-Footnote-1264171 +Node: Special Network264245 +Node: Special Caveats265095 +Node: Close Files And Pipes265891 +Ref: Close Files And Pipes-Footnote-1272914 +Ref: Close Files And Pipes-Footnote-2273062 +Node: Expressions273212 +Node: Values274344 +Node: Constants275020 +Node: Scalar Constants275700 +Ref: Scalar Constants-Footnote-1276559 +Node: Nondecimal-numbers276741 +Node: Regexp Constants279800 +Node: Using Constant Regexps280275 +Node: Variables283330 +Node: Using Variables283985 +Node: Assignment Options285709 +Node: Conversion287581 +Ref: table-locale-affects292957 +Ref: Conversion-Footnote-1293581 +Node: All Operators293690 +Node: Arithmetic Ops294320 +Node: Concatenation296825 +Ref: Concatenation-Footnote-1299618 +Node: Assignment Ops299738 +Ref: table-assign-ops304726 +Node: Increment Ops306134 +Node: Truth Values and Conditions309604 +Node: Truth Values310687 +Node: Typing and Comparison311736 +Node: Variable Typing312525 +Ref: Variable Typing-Footnote-1316422 +Node: Comparison Operators316544 +Ref: table-relational-ops316954 +Node: POSIX String Comparison320503 +Ref: POSIX String Comparison-Footnote-1321459 +Node: Boolean Ops321597 +Ref: Boolean Ops-Footnote-1325675 +Node: Conditional Exp325766 +Node: Function Calls327498 +Node: Precedence331092 +Node: Locales334761 +Node: Patterns and Actions335850 +Node: Pattern Overview336904 +Node: Regexp Patterns338573 +Node: Expression Patterns339116 +Node: Ranges342801 +Node: BEGIN/END345767 +Node: Using BEGIN/END346529 +Ref: Using BEGIN/END-Footnote-1349260 +Node: I/O And BEGIN/END349366 +Node: BEGINFILE/ENDFILE351648 +Node: Empty354541 +Node: Using Shell Variables354857 +Node: Action Overview357142 +Node: Statements359499 +Node: If Statement361353 +Node: While Statement362852 +Node: Do Statement364896 +Node: For Statement366052 +Node: Switch Statement369204 +Node: Break Statement371301 +Node: Continue Statement373291 +Node: Next Statement375084 +Node: Nextfile Statement377474 +Node: Exit Statement380019 +Node: Built-in Variables382435 +Node: User-modified383530 +Ref: User-modified-Footnote-1391556 +Node: Auto-set391618 +Ref: Auto-set-Footnote-1400909 +Node: ARGC and ARGV401114 +Node: Arrays404965 +Node: Array Basics406470 +Node: Array Intro407296 +Node: Reference to Elements411614 +Node: Assigning Elements413884 +Node: Array Example414375 +Node: Scanning an Array416107 +Node: Controlling Scanning418421 +Ref: Controlling Scanning-Footnote-1423354 +Node: Delete423670 +Ref: Delete-Footnote-1426105 +Node: Numeric Array Subscripts426162 +Node: Uninitialized Subscripts428345 +Node: Multi-dimensional429973 +Node: Multi-scanning433067 +Node: Arrays of Arrays434658 +Node: Functions439303 +Node: Built-in440125 +Node: Calling Built-in441203 +Node: Numeric Functions443191 +Ref: Numeric Functions-Footnote-1447023 +Ref: Numeric Functions-Footnote-2447380 +Ref: Numeric Functions-Footnote-3447428 +Node: String Functions447697 +Ref: String Functions-Footnote-1471194 +Ref: String Functions-Footnote-2471323 +Ref: String Functions-Footnote-3471571 +Node: Gory Details471658 +Ref: table-sub-escapes473337 +Ref: table-sub-posix-92474691 +Ref: table-sub-proposed476034 +Ref: table-posix-sub477384 +Ref: table-gensub-escapes478930 +Ref: Gory Details-Footnote-1480137 +Ref: Gory Details-Footnote-2480188 +Node: I/O Functions480339 +Ref: I/O Functions-Footnote-1486994 +Node: Time Functions487141 +Ref: Time Functions-Footnote-1498033 +Ref: Time Functions-Footnote-2498101 +Ref: Time Functions-Footnote-3498259 +Ref: Time Functions-Footnote-4498370 +Ref: Time Functions-Footnote-5498482 +Ref: Time Functions-Footnote-6498709 +Node: Bitwise Functions498975 +Ref: table-bitwise-ops499533 +Ref: Bitwise Functions-Footnote-1503693 +Node: Type Functions503877 +Node: I18N Functions504347 +Node: User-defined505974 +Node: Definition Syntax506778 +Ref: Definition Syntax-Footnote-1511688 +Node: Function Example511757 +Node: Function Caveats514351 +Node: Calling A Function514772 +Node: Variable Scope515887 +Node: Pass By Value/Reference517862 +Node: Return Statement521302 +Node: Dynamic Typing524283 +Node: Indirect Calls525018 +Node: Internationalization534703 +Node: I18N and L10N536129 +Node: Explaining gettext536815 +Ref: Explaining gettext-Footnote-1541881 +Ref: Explaining gettext-Footnote-2542065 +Node: Programmer i18n542230 +Node: Translator i18n546430 +Node: String Extraction547223 +Ref: String Extraction-Footnote-1548184 +Node: Printf Ordering548270 +Ref: Printf Ordering-Footnote-1551054 +Node: I18N Portability551118 +Ref: I18N Portability-Footnote-1553567 +Node: I18N Example553630 +Ref: I18N Example-Footnote-1556265 +Node: Gawk I18N556337 +Node: Advanced Features556954 +Node: Nondecimal Data558467 +Node: Array Sorting560050 +Node: Controlling Array Traversal560747 +Node: Array Sorting Functions568984 +Ref: Array Sorting Functions-Footnote-1572658 +Ref: Array Sorting Functions-Footnote-2572751 +Node: Two-way I/O572945 +Ref: Two-way I/O-Footnote-1578377 +Node: TCP/IP Networking578447 +Node: Profiling581291 +Node: Library Functions588765 +Ref: Library Functions-Footnote-1591772 +Node: Library Names591943 +Ref: Library Names-Footnote-1595414 +Ref: Library Names-Footnote-2595634 +Node: General Functions595720 +Node: Strtonum Function596673 +Node: Assert Function599603 +Node: Round Function602929 +Node: Cliff Random Function604472 +Node: Ordinal Functions605488 +Ref: Ordinal Functions-Footnote-1608558 +Ref: Ordinal Functions-Footnote-2608810 +Node: Join Function609019 +Ref: Join Function-Footnote-1610790 +Node: Gettimeofday Function610990 +Node: Data File Management614705 +Node: Filetrans Function615337 +Node: Rewind Function619476 +Node: File Checking620863 +Node: Empty Files621957 +Node: Ignoring Assigns624187 +Node: Getopt Function625740 +Ref: Getopt Function-Footnote-1637044 +Node: Passwd Functions637247 +Ref: Passwd Functions-Footnote-1646222 +Node: Group Functions646310 +Node: Walking Arrays654394 +Node: Sample Programs655963 +Node: Running Examples656628 +Node: Clones657356 +Node: Cut Program658580 +Node: Egrep Program668425 +Ref: Egrep Program-Footnote-1676198 +Node: Id Program676308 +Node: Split Program679924 +Ref: Split Program-Footnote-1683443 +Node: Tee Program683571 +Node: Uniq Program686374 +Node: Wc Program693803 +Ref: Wc Program-Footnote-1698069 +Ref: Wc Program-Footnote-2698269 +Node: Miscellaneous Programs698361 +Node: Dupword Program699549 +Node: Alarm Program701580 +Node: Translate Program706329 +Ref: Translate Program-Footnote-1710716 +Ref: Translate Program-Footnote-2710944 +Node: Labels Program711078 +Ref: Labels Program-Footnote-1714449 +Node: Word Sorting714533 +Node: History Sorting718417 +Node: Extract Program720256 +Ref: Extract Program-Footnote-1727739 +Node: Simple Sed727867 +Node: Igawk Program730929 +Ref: Igawk Program-Footnote-1746086 +Ref: Igawk Program-Footnote-2746287 +Node: Anagram Program746425 +Node: Signature Program749493 +Node: Debugger750593 +Node: Debugging751504 +Node: Debugging Concepts751917 +Node: Debugging Terms753773 +Node: Awk Debugging756396 +Node: Sample dgawk session757288 +Node: dgawk invocation757780 +Node: Finding The Bug758962 +Node: List of Debugger Commands765448 +Node: Breakpoint Control766759 +Node: Dgawk Execution Control770395 +Node: Viewing And Changing Data773746 +Node: Dgawk Stack777083 +Node: Dgawk Info778543 +Node: Miscellaneous Dgawk Commands782491 +Node: Readline Support787919 +Node: Dgawk Limitations788757 +Node: Language History790946 +Node: V7/SVR3.1792458 +Node: SVR4794779 +Node: POSIX796221 +Node: BTL797229 +Node: POSIX/GNU797963 +Node: Common Extensions803114 +Node: Ranges and Locales804221 +Ref: Ranges and Locales-Footnote-1808825 +Node: Contributors809046 +Node: Installation813308 +Node: Gawk Distribution814202 +Node: Getting814686 +Node: Extracting815512 +Node: Distribution contents817204 +Node: Unix Installation822426 +Node: Quick Installation823043 +Node: Additional Configuration Options825005 +Node: Configuration Philosophy826482 +Node: Non-Unix Installation828824 +Node: PC Installation829282 +Node: PC Binary Installation830581 +Node: PC Compiling832429 +Node: PC Testing835373 +Node: PC Using836549 +Node: Cygwin840734 +Node: MSYS841734 +Node: VMS Installation842248 +Node: VMS Compilation842851 +Ref: VMS Compilation-Footnote-1843858 +Node: VMS Installation Details843916 +Node: VMS Running845551 +Node: VMS Old Gawk847158 +Node: Bugs847632 +Node: Other Versions851484 +Node: Notes856765 +Node: Compatibility Mode857457 +Node: Additions858240 +Node: Accessing The Source859052 +Node: Adding Code860477 +Node: New Ports866444 +Node: Dynamic Extensions870557 +Node: Internals871933 +Node: Plugin License881036 +Node: Sample Library881670 +Node: Internal File Description882356 +Node: Internal File Ops886071 +Ref: Internal File Ops-Footnote-1890852 +Node: Using Internal File Ops890992 +Node: Future Extensions893369 +Node: Basic Concepts895873 +Node: Basic High Level896630 +Ref: Basic High Level-Footnote-1900665 +Node: Basic Data Typing900850 +Node: Floating Point Issues905375 +Node: String Conversion Precision906458 +Ref: String Conversion Precision-Footnote-1908158 +Node: Unexpected Results908267 +Node: POSIX Floating Point Problems910093 +Ref: POSIX Floating Point Problems-Footnote-1913798 +Node: Glossary913836 +Node: Copying938812 +Node: GNU Free Documentation License976369 +Node: Index1001506 + +End Tag Table diff --git a/doc/gawk.texi b/doc/gawk.texi new file mode 100644 index 0000000..83bd3b5 --- /dev/null +++ b/doc/gawk.texi @@ -0,0 +1,32521 @@ +\input texinfo @c -*-texinfo-*- +@c %**start of header (This is for running Texinfo on a region.) +@setfilename gawk.info +@settitle The GNU Awk User's Guide +@c %**end of header (This is for running Texinfo on a region.) + +@dircategory Text creation and manipulation +@direntry +* Gawk: (gawk). A text scanning and processing language. +@end direntry +@dircategory Individual utilities +@direntry +* awk: (gawk)Invoking gawk. Text scanning and processing. +@end direntry + +@set xref-automatic-section-title + +@c The following information should be updated here only! +@c This sets the edition of the document, the version of gawk it +@c applies to and all the info about who's publishing this edition + +@c These apply across the board. +@set UPDATE-MONTH February, 2012 +@set VERSION 4.0 +@set PATCHLEVEL 1 + +@set FSF + +@set TITLE GAWK: Effective AWK Programming +@set SUBTITLE A User's Guide for GNU Awk +@set EDITION 4 + +@iftex +@set DOCUMENT book +@set CHAPTER chapter +@set APPENDIX appendix +@set SECTION section +@set SUBSECTION subsection +@set DARKCORNER @inmargin{@image{lflashlight,1cm}, @image{rflashlight,1cm}} +@set COMMONEXT (c.e.) +@end iftex +@ifinfo +@set DOCUMENT Info file +@set CHAPTER major node +@set APPENDIX major node +@set SECTION minor node +@set SUBSECTION node +@set DARKCORNER (d.c.) +@set COMMONEXT (c.e.) +@end ifinfo +@ifhtml +@set DOCUMENT Web page +@set CHAPTER chapter +@set APPENDIX appendix +@set SECTION section +@set SUBSECTION subsection +@set DARKCORNER (d.c.) +@set COMMONEXT (c.e.) +@end ifhtml +@ifdocbook +@set DOCUMENT book +@set CHAPTER chapter +@set APPENDIX appendix +@set SECTION section +@set SUBSECTION subsection +@set DARKCORNER (d.c.) +@set COMMONEXT (c.e.) +@end ifdocbook +@ifplaintext +@set DOCUMENT book +@set CHAPTER chapter +@set APPENDIX appendix +@set SECTION section +@set SUBSECTION subsection +@set DARKCORNER (d.c.) +@set COMMONEXT (c.e.) +@end ifplaintext + +@c some special symbols +@iftex +@set LEQ @math{@leq} +@end iftex +@ifnottex +@set LEQ <= +@end ifnottex + +@ifnottex +@macro ii{text} +@i{\text\} +@end macro +@end ifnottex + +@c For HTML, spell out email addresses, to avoid problems with +@c address harvesters for spammers. +@ifhtml +@macro EMAIL{real,spelled} +``\spelled\'' +@end macro +@end ifhtml +@ifnothtml +@macro EMAIL{real,spelled} +@email{\real\} +@end macro +@end ifnothtml + +@set FN file name +@set FFN File Name +@set DF data file +@set DDF Data File +@set PVERSION version +@set CTL Ctrl + +@ignore +Some comments on the layout for TeX. +1. Use at least texinfo.tex 2000-09-06.09 +2. I have done A LOT of work to make this look good. There are `@page' commands + and use of `@group ... @end group' in a number of places. If you muck + with anything, it's your responsibility not to break the layout. +@end ignore + +@c merge the function and variable indexes into the concept index +@ifinfo +@synindex fn cp +@synindex vr cp +@end ifinfo +@iftex +@syncodeindex fn cp +@syncodeindex vr cp +@end iftex +@ifxml +@syncodeindex fn cp +@syncodeindex vr cp +@end ifxml + +@c If "finalout" is commented out, the printed output will show +@c black boxes that mark lines that are too long. Thus, it is +@c unwise to comment it out when running a master in case there are +@c overfulls which are deemed okay. + +@iftex +@finalout +@end iftex + +@copying +Copyright @copyright{} 1989, 1991, 1992, 1993, 1996, 1997, 1998, 1999, +2000, 2001, 2002, 2003, 2004, 2005, 2007, 2009, 2010, 2011, 2012 +Free Software Foundation, Inc. +@sp 2 + +This is Edition @value{EDITION} of @cite{@value{TITLE}: @value{SUBTITLE}}, +for the @value{VERSION}.@value{PATCHLEVEL} (or later) version of the GNU +implementation of AWK. + +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with the +Invariant Sections being ``GNU General Public License'', the Front-Cover +texts being (a) (see below), and with the Back-Cover Texts being (b) +(see below). A copy of the license is included in the section entitled +``GNU Free Documentation License''. + +@enumerate a +@item +``A GNU Manual'' + +@item +``You have the freedom to +copy and modify this GNU manual. Buying copies from the FSF +supports it in developing GNU and promoting software freedom.'' +@end enumerate +@end copying + +@c Comment out the "smallbook" for technical review. Saves +@c considerable paper. Remember to turn it back on *before* +@c starting the page-breaking work. + +@c 4/2002: Karl Berry recommends commenting out this and the +@c `@setchapternewpage odd', and letting users use `texi2dvi -t' +@c if they want to waste paper. +@c @smallbook + + +@c Uncomment this for the release. Leaving it off saves paper +@c during editing and review. +@setchapternewpage odd + +@titlepage +@title @value{TITLE} +@subtitle @value{SUBTITLE} +@subtitle Edition @value{EDITION} +@subtitle @value{UPDATE-MONTH} +@author Arnold D. Robbins + +@c Include the Distribution inside the titlepage environment so +@c that headings are turned off. Headings on and off do not work. + +@page +@vskip 0pt plus 1filll +``To boldly go where no man has gone before'' is a +Registered Trademark of Paramount Pictures Corporation. @* +@c sorry, i couldn't resist +@sp 3 +Published by: +@sp 1 + +Free Software Foundation @* +51 Franklin Street, Fifth Floor @* +Boston, MA 02110-1301 USA @* +Phone: +1-617-542-5942 @* +Fax: +1-617-542-2652 @* +Email: @email{gnu@@gnu.org} @* +URL: @uref{http://www.gnu.org/} @* + +@c This one is correct for gawk 3.1.0 from the FSF +ISBN 1-882114-28-0 @* +@sp 2 +@insertcopying +@end titlepage + +@c Thanks to Bob Chassell for directions on doing dedications. +@iftex +@headings off +@page +@w{ } +@sp 9 +@center @i{To Miriam, for making me complete.} +@sp 1 +@center @i{To Chana, for the joy you bring us.} +@sp 1 +@center @i{To Rivka, for the exponential increase.} +@sp 1 +@center @i{To Nachum, for the added dimension.} +@sp 1 +@center @i{To Malka, for the new beginning.} +@w{ } +@page +@w{ } +@page +@headings on +@end iftex + +@iftex +@headings off +@evenheading @thispage@ @ @ @strong{@value{TITLE}} @| @| +@oddheading @| @| @strong{@thischapter}@ @ @ @thispage +@end iftex + +@ifnottex +@ifnotxml +@node Top +@top General Introduction +@c Preface node should come right after the Top +@c node, in `unnumbered' sections, then the chapter, `What is gawk'. +@c Licensing nodes are appendices, they're not central to AWK. + +This file documents @command{awk}, a program that you can use to select +particular records in a file and perform operations upon them. + +@insertcopying + +@end ifnotxml +@end ifnottex + +@menu +* Foreword:: Some nice words about this + @value{DOCUMENT}. +* Preface:: What this @value{DOCUMENT} is about; brief + history and acknowledgments. +* Getting Started:: A basic introduction to using + @command{awk}. How to run an @command{awk} + program. Command-line syntax. +* Invoking Gawk:: How to run @command{gawk}. +* Regexp:: All about matching things using regular + expressions. +* Reading Files:: How to read files and manipulate fields. +* Printing:: How to print using @command{awk}. Describes + the @code{print} and @code{printf} + statements. Also describes redirection of + output. +* Expressions:: Expressions are the basic building blocks + of statements. +* Patterns and Actions:: Overviews of patterns and actions. +* Arrays:: The description and use of arrays. Also + includes array-oriented control statements. +* Functions:: Built-in and user-defined functions. +* Internationalization:: Getting @command{gawk} to speak your + language. +* Advanced Features:: Stuff for advanced users, specific to + @command{gawk}. +* Library Functions:: A Library of @command{awk} Functions. +* Sample Programs:: Many @command{awk} programs with complete + explanations. +* Debugger:: The @code{dgawk} debugger. +* Language History:: The evolution of the @command{awk} + language. +* Installation:: Installing @command{gawk} under various + operating systems. +* Notes:: Notes about @command{gawk} extensions and + possible future work. +* Basic Concepts:: A very quick introduction to programming + concepts. +* Glossary:: An explanation of some unfamiliar terms. +* Copying:: Your right to copy and distribute + @command{gawk}. +* GNU Free Documentation License:: The license for this @value{DOCUMENT}. +* Index:: Concept and Variable Index. + +@detailmenu +* History:: The history of @command{gawk} and + @command{awk}. +* Names:: What name to use to find @command{awk}. +* This Manual:: Using this @value{DOCUMENT}. Includes + sample input files that you can use. +* Conventions:: Typographical Conventions. +* Manual History:: Brief history of the GNU project and this + @value{DOCUMENT}. +* How To Contribute:: Helping to save the world. +* Acknowledgments:: Acknowledgments. +* Running gawk:: How to run @command{gawk} programs; + includes command-line syntax. +* One-shot:: Running a short throwaway @command{awk} + program. +* Read Terminal:: Using no input files (input from terminal + instead). +* Long:: Putting permanent @command{awk} programs in + files. +* Executable Scripts:: Making self-contained @command{awk} + programs. +* Comments:: Adding documentation to @command{gawk} + programs. +* Quoting:: More discussion of shell quoting issues. +* DOS Quoting:: Quoting in Windows Batch Files. +* Sample Data Files:: Sample data files for use in the + @command{awk} programs illustrated in this + @value{DOCUMENT}. +* Very Simple:: A very simple example. +* Two Rules:: A less simple one-line example using two + rules. +* More Complex:: A more complex example. +* Statements/Lines:: Subdividing or combining statements into + lines. +* Other Features:: Other Features of @command{awk}. +* When:: When to use @command{gawk} and when to use + other things. +* Command Line:: How to run @command{awk}. +* Options:: Command-line options and their meanings. +* Other Arguments:: Input file names and variable assignments. +* Naming Standard Input:: How to specify standard input with other + files. +* Environment Variables:: The environment variables @command{gawk} + uses. +* AWKPATH Variable:: Searching directories for @command{awk} + programs. +* Other Environment Variables:: The environment variables. +* Exit Status:: @command{gawk}'s exit status. +* Include Files:: Including other files into your program. +* Obsolete:: Obsolete Options and/or features. +* Undocumented:: Undocumented Options and Features. +* Regexp Usage:: How to Use Regular Expressions. +* Escape Sequences:: How to write nonprinting characters. +* Regexp Operators:: Regular Expression Operators. +* Bracket Expressions:: What can go between @samp{[...]}. +* GNU Regexp Operators:: Operators specific to GNU software. +* Case-sensitivity:: How to do case-insensitive matching. +* Leftmost Longest:: How much text matches. +* Computed Regexps:: Using Dynamic Regexps. +* Records:: Controlling how data is split into records. +* Fields:: An introduction to fields. +* Nonconstant Fields:: Nonconstant Field Numbers. +* Changing Fields:: Changing the Contents of a Field. +* Field Separators:: The field separator and how to change it. +* Default Field Splitting:: How fields are normally separated. +* Regexp Field Splitting:: Using regexps as the field separator. +* Single Character Fields:: Making each character a separate field. +* Command Line Field Separator:: Setting @code{FS} from the command-line. +* Field Splitting Summary:: Some final points and a summary table. +* Constant Size:: Reading constant width data. +* Splitting By Content:: Defining Fields By Content +* Multiple Line:: Reading multi-line records. +* Getline:: Reading files under explicit program + control using the @code{getline} function. +* Plain Getline:: Using @code{getline} with no arguments. +* Getline/Variable:: Using @code{getline} into a variable. +* Getline/File:: Using @code{getline} from a file. +* Getline/Variable/File:: Using @code{getline} into a variable from a + file. +* Getline/Pipe:: Using @code{getline} from a pipe. +* Getline/Variable/Pipe:: Using @code{getline} into a variable from a + pipe. +* Getline/Coprocess:: Using @code{getline} from a coprocess. +* Getline/Variable/Coprocess:: Using @code{getline} into a variable from a + coprocess. +* Getline Notes:: Important things to know about + @code{getline}. +* Getline Summary:: Summary of @code{getline} Variants. +* Command line directories:: What happens if you put a directory on the + command line. +* Print:: The @code{print} statement. +* Print Examples:: Simple examples of @code{print} statements. +* Output Separators:: The output separators and how to change + them. +* OFMT:: Controlling Numeric Output With + @code{print}. +* Printf:: The @code{printf} statement. +* Basic Printf:: Syntax of the @code{printf} statement. +* Control Letters:: Format-control letters. +* Format Modifiers:: Format-specification modifiers. +* Printf Examples:: Several examples. +* Redirection:: How to redirect output to multiple files + and pipes. +* Special Files:: File name interpretation in @command{gawk}. + @command{gawk} allows access to inherited + file descriptors. +* Special FD:: Special files for I/O. +* Special Network:: Special files for network communications. +* Special Caveats:: Things to watch out for. +* Close Files And Pipes:: Closing Input and Output Files and Pipes. +* Values:: Constants, Variables, and Regular + Expressions. +* Constants:: String, numeric and regexp constants. +* Scalar Constants:: Numeric and string constants. +* Nondecimal-numbers:: What are octal and hex numbers. +* Regexp Constants:: Regular Expression constants. +* Using Constant Regexps:: When and how to use a regexp constant. +* Variables:: Variables give names to values for later + use. +* Using Variables:: Using variables in your programs. +* Assignment Options:: Setting variables on the command-line and a + summary of command-line syntax. This is an + advanced method of input. +* Conversion:: The conversion of strings to numbers and + vice versa. +* All Operators:: @command{gawk}'s operators. +* Arithmetic Ops:: Arithmetic operations (@samp{+}, @samp{-}, + etc.) +* Concatenation:: Concatenating strings. +* Assignment Ops:: Changing the value of a variable or a + field. +* Increment Ops:: Incrementing the numeric value of a + variable. +* Truth Values and Conditions:: Testing for true and false. +* Truth Values:: What is ``true'' and what is ``false''. +* Typing and Comparison:: How variables acquire types and how this + affects comparison of numbers and strings + with @samp{<}, etc. +* Variable Typing:: String type versus numeric type. +* Comparison Operators:: The comparison operators. +* POSIX String Comparison:: String comparison with POSIX rules. +* Boolean Ops:: Combining comparison expressions using + boolean operators @samp{||} (``or''), + @samp{&&} (``and'') and @samp{!} (``not''). +* Conditional Exp:: Conditional expressions select between two + subexpressions under control of a third + subexpression. +* Function Calls:: A function call is an expression. +* Precedence:: How various operators nest. +* Locales:: How the locale affects things. +* Pattern Overview:: What goes into a pattern. +* Regexp Patterns:: Using regexps as patterns. +* Expression Patterns:: Any expression can be used as a pattern. +* Ranges:: Pairs of patterns specify record ranges. +* BEGIN/END:: Specifying initialization and cleanup + rules. +* Using BEGIN/END:: How and why to use BEGIN/END rules. +* I/O And BEGIN/END:: I/O issues in BEGIN/END rules. +* BEGINFILE/ENDFILE:: Two special patterns for advanced control. +* Empty:: The empty pattern, which matches every + record. +* Using Shell Variables:: How to use shell variables with + @command{awk}. +* Action Overview:: What goes into an action. +* Statements:: Describes the various control statements in + detail. +* If Statement:: Conditionally execute some @command{awk} + statements. +* While Statement:: Loop until some condition is satisfied. +* Do Statement:: Do specified action while looping until + some condition is satisfied. +* For Statement:: Another looping statement, that provides + initialization and increment clauses. +* Switch Statement:: Switch/case evaluation for conditional + execution of statements based on a value. +* Break Statement:: Immediately exit the innermost enclosing + loop. +* Continue Statement:: Skip to the end of the innermost enclosing + loop. +* Next Statement:: Stop processing the current input record. +* Nextfile Statement:: Stop processing the current file. +* Exit Statement:: Stop execution of @command{awk}. +* Built-in Variables:: Summarizes the built-in variables. +* User-modified:: Built-in variables that you change to + control @command{awk}. +* Auto-set:: Built-in variables where @command{awk} + gives you information. +* ARGC and ARGV:: Ways to use @code{ARGC} and @code{ARGV}. +* Array Basics:: The basics of arrays. +* Array Intro:: Introduction to Arrays +* Reference to Elements:: How to examine one element of an array. +* Assigning Elements:: How to change an element of an array. +* Array Example:: Basic Example of an Array +* Scanning an Array:: A variation of the @code{for} statement. It + loops through the indices of an array's + existing elements. +* Controlling Scanning:: Controlling the order in which arrays are + scanned. +* Delete:: The @code{delete} statement removes an + element from an array. +* Numeric Array Subscripts:: How to use numbers as subscripts in + @command{awk}. +* Uninitialized Subscripts:: Using Uninitialized variables as + subscripts. +* Multi-dimensional:: Emulating multidimensional arrays in + @command{awk}. +* Multi-scanning:: Scanning multidimensional arrays. +* Arrays of Arrays:: True multidimensional arrays. +* Built-in:: Summarizes the built-in functions. +* Calling Built-in:: How to call built-in functions. +* Numeric Functions:: Functions that work with numbers, including + @code{int()}, @code{sin()} and + @code{rand()}. +* String Functions:: Functions for string manipulation, such as + @code{split()}, @code{match()} and + @code{sprintf()}. +* Gory Details:: More than you want to know about @samp{\} + and @samp{&} with @code{sub()}, + @code{gsub()}, and @code{gensub()}. +* I/O Functions:: Functions for files and shell commands. +* Time Functions:: Functions for dealing with timestamps. +* Bitwise Functions:: Functions for bitwise operations. +* Type Functions:: Functions for type information. +* I18N Functions:: Functions for string translation. +* User-defined:: Describes User-defined functions in detail. +* Definition Syntax:: How to write definitions and what they + mean. +* Function Example:: An example function definition and what it + does. +* Function Caveats:: Things to watch out for. +* Calling A Function:: Don't use spaces. +* Variable Scope:: Controlling variable scope. +* Pass By Value/Reference:: Passing parameters. +* Return Statement:: Specifying the value a function returns. +* Dynamic Typing:: How variable types can change at runtime. +* Indirect Calls:: Choosing the function to call at runtime. +* I18N and L10N:: Internationalization and Localization. +* Explaining gettext:: How GNU @code{gettext} works. +* Programmer i18n:: Features for the programmer. +* Translator i18n:: Features for the translator. +* String Extraction:: Extracting marked strings. +* Printf Ordering:: Rearranging @code{printf} arguments. +* I18N Portability:: @command{awk}-level portability issues. +* I18N Example:: A simple i18n example. +* Gawk I18N:: @command{gawk} is also internationalized. +* Nondecimal Data:: Allowing nondecimal input data. +* Array Sorting:: Facilities for controlling array traversal + and sorting arrays. +* Controlling Array Traversal:: How to use PROCINFO["sorted_in"]. +* Array Sorting Functions:: How to use @code{asort()} and + @code{asorti()}. +* Two-way I/O:: Two-way communications with another + process. +* TCP/IP Networking:: Using @command{gawk} for network + programming. +* Profiling:: Profiling your @command{awk} programs. +* Library Names:: How to best name private global variables + in library functions. +* General Functions:: Functions that are of general use. +* Strtonum Function:: A replacement for the built-in + @code{strtonum()} function. +* Assert Function:: A function for assertions in @command{awk} + programs. +* Round Function:: A function for rounding if @code{sprintf()} + does not do it correctly. +* Cliff Random Function:: The Cliff Random Number Generator. +* Ordinal Functions:: Functions for using characters as numbers + and vice versa. +* Join Function:: A function to join an array into a string. +* Gettimeofday Function:: A function to get formatted times. +* Data File Management:: Functions for managing command-line data + files. +* Filetrans Function:: A function for handling data file + transitions. +* Rewind Function:: A function for rereading the current file. +* File Checking:: Checking that data files are readable. +* Empty Files:: Checking for zero-length files. +* Ignoring Assigns:: Treating assignments as file names. +* Getopt Function:: A function for processing command-line + arguments. +* Passwd Functions:: Functions for getting user information. +* Group Functions:: Functions for getting group information. +* Walking Arrays:: A function to walk arrays of arrays. +* Running Examples:: How to run these examples. +* Clones:: Clones of common utilities. +* Cut Program:: The @command{cut} utility. +* Egrep Program:: The @command{egrep} utility. +* Id Program:: The @command{id} utility. +* Split Program:: The @command{split} utility. +* Tee Program:: The @command{tee} utility. +* Uniq Program:: The @command{uniq} utility. +* Wc Program:: The @command{wc} utility. +* Miscellaneous Programs:: Some interesting @command{awk} programs. +* Dupword Program:: Finding duplicated words in a document. +* Alarm Program:: An alarm clock. +* Translate Program:: A program similar to the @command{tr} + utility. +* Labels Program:: Printing mailing labels. +* Word Sorting:: A program to produce a word usage count. +* History Sorting:: Eliminating duplicate entries from a + history file. +* Extract Program:: Pulling out programs from Texinfo source + files. +* Simple Sed:: A Simple Stream Editor. +* Igawk Program:: A wrapper for @command{awk} that includes + files. +* Anagram Program:: Finding anagrams from a dictionary. +* Signature Program:: People do amazing things with too much time + on their hands. +* Debugging:: Introduction to @command{dgawk}. +* Debugging Concepts:: Debugging In General. +* Debugging Terms:: Additional Debugging Concepts. +* Awk Debugging:: Awk Debugging. +* Sample dgawk session:: Sample @command{dgawk} session. +* dgawk invocation:: @command{dgawk} Invocation. +* Finding The Bug:: Finding The Bug. +* List of Debugger Commands:: Main @command{dgawk} Commands. +* Breakpoint Control:: Control of breakpoints. +* Dgawk Execution Control:: Control of execution. +* Viewing And Changing Data:: Viewing and changing data. +* Dgawk Stack:: Dealing with the stack. +* Dgawk Info:: Obtaining information about the program and + the debugger state. +* Miscellaneous Dgawk Commands:: Miscellaneous Commands. +* Readline Support:: Readline Support. +* Dgawk Limitations:: Limitations and future plans. +* V7/SVR3.1:: The major changes between V7 and System V + Release 3.1. +* SVR4:: Minor changes between System V Releases 3.1 + and 4. +* POSIX:: New features from the POSIX standard. +* BTL:: New features from Brian Kernighan's version + of @command{awk}. +* POSIX/GNU:: The extensions in @command{gawk} not in + POSIX @command{awk}. +* Common Extensions:: Common Extensions Summary. +* Ranges and Locales:: How locales used to affect regexp ranges. +* Contributors:: The major contributors to @command{gawk}. +* Gawk Distribution:: What is in the @command{gawk} distribution. +* Getting:: How to get the distribution. +* Extracting:: How to extract the distribution. +* Distribution contents:: What is in the distribution. +* Unix Installation:: Installing @command{gawk} under various + versions of Unix. +* Quick Installation:: Compiling @command{gawk} under Unix. +* Additional Configuration Options:: Other compile-time options. +* Configuration Philosophy:: How it's all supposed to work. +* Non-Unix Installation:: Installation on Other Operating Systems. +* PC Installation:: Installing and Compiling @command{gawk} on + MS-DOS and OS/2. +* PC Binary Installation:: Installing a prepared distribution. +* PC Compiling:: Compiling @command{gawk} for MS-DOS, + Windows32, and OS/2. +* PC Testing:: Testing @command{gawk} on PC systems. +* PC Using:: Running @command{gawk} on MS-DOS, Windows32 + and OS/2. +* Cygwin:: Building and running @command{gawk} for + Cygwin. +* MSYS:: Using @command{gawk} In The MSYS + Environment. +* VMS Installation:: Installing @command{gawk} on VMS. +* VMS Compilation:: How to compile @command{gawk} under VMS. +* VMS Installation Details:: How to install @command{gawk} under VMS. +* VMS Running:: How to run @command{gawk} under VMS. +* VMS Old Gawk:: An old version comes with some VMS systems. +* Bugs:: Reporting Problems and Bugs. +* Other Versions:: Other freely available @command{awk} + implementations. +* Compatibility Mode:: How to disable certain @command{gawk} + extensions. +* Additions:: Making Additions To @command{gawk}. +* Accessing The Source:: Accessing the Git repository. +* Adding Code:: Adding code to the main body of + @command{gawk}. +* New Ports:: Porting @command{gawk} to a new operating + system. +* Dynamic Extensions:: Adding new built-in functions to + @command{gawk}. +* Internals:: A brief look at some @command{gawk} + internals. +* Plugin License:: A note about licensing. +* Sample Library:: A example of new functions. +* Internal File Description:: What the new functions will do. +* Internal File Ops:: The code for internal file operations. +* Using Internal File Ops:: How to use an external extension. +* Future Extensions:: New features that may be implemented one + day. +* Basic High Level:: The high level view. +* Basic Data Typing:: A very quick intro to data types. +* Floating Point Issues:: Stuff to know about floating-point numbers. +* String Conversion Precision:: The String Value Can Lie. +* Unexpected Results:: Floating Point Numbers Are Not Abstract + Numbers. +* POSIX Floating Point Problems:: Standards Versus Existing Practice. +@end detailmenu +@end menu + +@c dedication for Info file +@ifinfo +@center To Miriam, for making me complete. +@sp 1 +@center To Chana, for the joy you bring us. +@sp 1 +@center To Rivka, for the exponential increase. +@sp 1 +@center To Nachum, for the added dimension. +@sp 1 +@center To Malka, for the new beginning. +@end ifinfo + +@summarycontents +@contents + +@node Foreword +@unnumbered Foreword + +Arnold Robbins and I are good friends. We were introduced +@c 11 years ago +in 1990 +by circumstances---and our favorite programming language, AWK. +The circumstances started a couple of years +earlier. I was working at a new job and noticed an unplugged +Unix computer sitting in the corner. No one knew how to use it, +and neither did I. However, +a couple of days later it was running, and +I was @code{root} and the one-and-only user. +That day, I began the transition from statistician to Unix programmer. + +On one of many trips to the library or bookstore in search of +books on Unix, I found the gray AWK book, a.k.a.@: Aho, Kernighan and +Weinberger, @cite{The AWK Programming Language}, Addison-Wesley, +1988. AWK's simple programming paradigm---find a pattern in the +input and then perform an action---often reduced complex or tedious +data manipulations to few lines of code. I was excited to try my +hand at programming in AWK. + +Alas, the @command{awk} on my computer was a limited version of the +language described in the AWK book. I discovered that my computer +had ``old @command{awk}'' and the AWK book described ``new @command{awk}.'' +I learned that this was typical; the old version refused to step +aside or relinquish its name. If a system had a new @command{awk}, it was +invariably called @command{nawk}, and few systems had it. +The best way to get a new @command{awk} was to @command{ftp} the source code for +@command{gawk} from @code{prep.ai.mit.edu}. @command{gawk} was a version of +new @command{awk} written by David Trueman and Arnold, and available under +the GNU General Public License. + +(Incidentally, +it's no longer difficult to find a new @command{awk}. @command{gawk} ships with +GNU/Linux, and you can download binaries or source code for almost +any system; my wife uses @command{gawk} on her VMS box.) + +My Unix system started out unplugged from the wall; it certainly was not +plugged into a network. So, oblivious to the existence of @command{gawk} +and the Unix community in general, and desiring a new @command{awk}, I wrote +my own, called @command{mawk}. +Before I was finished I knew about @command{gawk}, +but it was too late to stop, so I eventually posted +to a @code{comp.sources} newsgroup. + +A few days after my posting, I got a friendly email +from Arnold introducing +himself. He suggested we share design and algorithms and +attached a draft of the POSIX standard so +that I could update @command{mawk} to support language extensions added +after publication of the AWK book. + +Frankly, if our roles had +been reversed, I would not have been so open and we probably would +have never met. I'm glad we did meet. +He is an AWK expert's AWK expert and a genuinely nice person. +Arnold contributes significant amounts of his +expertise and time to the Free Software Foundation. + +This book is the @command{gawk} reference manual, but at its core it +is a book about AWK programming that +will appeal to a wide audience. +It is a definitive reference to the AWK language as defined by the +1987 Bell Laboratories release and codified in the 1992 POSIX Utilities +standard. + +On the other hand, the novice AWK programmer can study +a wealth of practical programs that emphasize +the power of AWK's basic idioms: +data driven control-flow, pattern matching with regular expressions, +and associative arrays. +Those looking for something new can try out @command{gawk}'s +interface to network protocols via special @file{/inet} files. + +The programs in this book make clear that an AWK program is +typically much smaller and faster to develop than +a counterpart written in C. +Consequently, there is often a payoff to prototype an +algorithm or design in AWK to get it running quickly and expose +problems early. Often, the interpreted performance is adequate +and the AWK prototype becomes the product. + +The new @command{pgawk} (profiling @command{gawk}), produces +program execution counts. +I recently experimented with an algorithm that for +@math{n} lines of input, exhibited +@tex +$\sim\! Cn^2$ +@end tex +@ifnottex +~ C n^2 +@end ifnottex +performance, while +theory predicted +@tex +$\sim\! Cn\log n$ +@end tex +@ifnottex +~ C n log n +@end ifnottex +behavior. A few minutes poring +over the @file{awkprof.out} profile pinpointed the problem to +a single line of code. @command{pgawk} is a welcome addition to +my programmer's toolbox. + +Arnold has distilled over a decade of experience writing and +using AWK programs, and developing @command{gawk}, into this book. If you use +AWK or want to learn how, then read this book. + +@display +Michael Brennan +Author of @command{mawk} +March, 2001 +@end display + +@node Preface +@unnumbered Preface +@c I saw a comment somewhere that the preface should describe the book itself, +@c and the introduction should describe what the book covers. +@c +@c 12/2000: Chuck wants the preface & intro combined. + +Several kinds of tasks occur repeatedly +when working with text files. +You might want to extract certain lines and discard the rest. +Or you may need to make changes wherever certain patterns appear, +but leave the rest of the file alone. +Writing single-use programs for these tasks in languages such as C, C++, +or Java is time-consuming and inconvenient. +Such jobs are often easier with @command{awk}. +The @command{awk} utility interprets a special-purpose programming language +that makes it easy to handle simple data-reformatting jobs. + +The GNU implementation of @command{awk} is called @command{gawk}; if you +invoke it with the proper options or environment variables +(@pxref{Options}), it is fully +compatible with +the POSIX@footnote{The 2008 POSIX standard can be found online at +@url{http://www.opengroup.org/onlinepubs/9699919799/}.} +specification of the @command{awk} language +and with the Unix version of @command{awk} maintained +by Brian Kernighan. +This means that all +properly written @command{awk} programs should work with @command{gawk}. +Thus, we usually don't distinguish between @command{gawk} and other +@command{awk} implementations. + +@cindex @command{awk}, POSIX and, See Also POSIX @command{awk} +@cindex @command{awk}, POSIX and +@cindex POSIX, @command{awk} and +@cindex @command{gawk}, @command{awk} and +@cindex @command{awk}, @command{gawk} and +@cindex @command{awk}, uses for +Using @command{awk} allows you to: + +@itemize @bullet +@item +Manage small, personal databases + +@item +Generate reports + +@item +Validate data + +@item +Produce indexes and perform other document preparation tasks + +@item +Experiment with algorithms that you can adapt later to other computer +languages +@end itemize + +@cindex @command{awk}, See Also @command{gawk} +@cindex @command{gawk}, See Also @command{awk} +@cindex @command{gawk}, uses for +In addition, +@command{gawk} +provides facilities that make it easy to: + +@itemize @bullet +@item +Extract bits and pieces of data for processing + +@item +Sort data + +@item +Perform simple network communications +@end itemize + +This @value{DOCUMENT} teaches you about the @command{awk} language and +how you can use it effectively. You should already be familiar with basic +system commands, such as @command{cat} and @command{ls},@footnote{These commands +are available on POSIX-compliant systems, as well as on traditional +Unix-based systems. If you are using some other operating system, you still need to +be familiar with the ideas of I/O redirection and pipes.} as well as basic shell +facilities, such as input/output (I/O) redirection and pipes. + +@cindex GNU @command{awk}, See @command{gawk} +Implementations of the @command{awk} language are available for many +different computing environments. This @value{DOCUMENT}, while describing +the @command{awk} language in general, also describes the particular +implementation of @command{awk} called @command{gawk} (which stands for +``GNU awk''). @command{gawk} runs on a broad range of Unix systems, +ranging from Intel@registeredsymbol{}-architecture PC-based computers +up through large-scale systems, +such as Crays. @command{gawk} has also been ported to Mac OS X, +Microsoft Windows (all versions) and OS/2 PCs, +and VMS. +(Some other, obsolete systems to which @command{gawk} was once ported +are no longer supported and the code for those systems +has been removed.) + +@menu +* History:: The history of @command{gawk} and + @command{awk}. +* Names:: What name to use to find @command{awk}. +* This Manual:: Using this @value{DOCUMENT}. Includes sample + input files that you can use. +* Conventions:: Typographical Conventions. +* Manual History:: Brief history of the GNU project and this + @value{DOCUMENT}. +* How To Contribute:: Helping to save the world. +* Acknowledgments:: Acknowledgments. +@end menu + +@node History +@unnumberedsec History of @command{awk} and @command{gawk} +@cindex recipe for a programming language +@cindex programming language, recipe for +@center Recipe For A Programming Language + +@multitable {2 parts} {1 part @code{egrep}} {1 part @code{snobol}} +@item @tab 1 part @code{egrep} @tab 1 part @code{snobol} +@item @tab 2 parts @code{ed} @tab 3 parts C +@end multitable + +@quotation +Blend all parts well using @code{lex} and @code{yacc}. +Document minimally and release. + +After eight years, add another part @code{egrep} and two +more parts C. Document very well and release. +@end quotation + +@cindex Aho, Alfred +@cindex Weinberger, Peter +@cindex Kernighan, Brian +@cindex @command{awk}, history of +The name @command{awk} comes from the initials of its designers: Alfred V.@: +Aho, Peter J.@: Weinberger and Brian W.@: Kernighan. The original version of +@command{awk} was written in 1977 at AT&T Bell Laboratories. +In 1985, a new version made the programming +language more powerful, introducing user-defined functions, multiple input +streams, and computed regular expressions. +This new version became widely available with Unix System V +Release 3.1 (1987). +The version in System V Release 4 (1989) added some new features and cleaned +up the behavior in some of the ``dark corners'' of the language. +The specification for @command{awk} in the POSIX Command Language +and Utilities standard further clarified the language. +Both the @command{gawk} designers and the original Bell Laboratories @command{awk} +designers provided feedback for the POSIX specification. + +@cindex Rubin, Paul +@cindex Fenlason, Jay +@cindex Trueman, David +Paul Rubin wrote the GNU implementation, @command{gawk}, in 1986. +Jay Fenlason completed it, with advice from Richard Stallman. John Woods +contributed parts of the code as well. In 1988 and 1989, David Trueman, with +help from me, thoroughly reworked @command{gawk} for compatibility +with the newer @command{awk}. +Circa 1994, I became the primary maintainer. +Current development focuses on bug fixes, +performance improvements, standards compliance, and occasionally, new features. + +In May of 1997, J@"urgen Kahrs felt the need for network access +from @command{awk}, and with a little help from me, set about adding +features to do this for @command{gawk}. At that time, he also +wrote the bulk of +@cite{TCP/IP Internetworking with @command{gawk}} +(a separate document, available as part of the @command{gawk} distribution). +His code finally became part of the main @command{gawk} distribution +with @command{gawk} @value{PVERSION} 3.1. + +John Haque rewrote the @command{gawk} internals, in the process providing +an @command{awk}-level debugger. This version became available as +@command{gawk} @value{PVERSION} 4.0, in 2011. + +@xref{Contributors}, +for a complete list of those who made important contributions to @command{gawk}. + +@node Names +@section A Rose by Any Other Name + +@cindex @command{awk}, new vs.@: old +The @command{awk} language has evolved over the years. Full details are +provided in @ref{Language History}. +The language described in this @value{DOCUMENT} +is often referred to as ``new @command{awk}'' (@command{nawk}). + +@cindex @command{awk}, versions of +Because of this, there are systems with multiple +versions of @command{awk}. +Some systems have an @command{awk} utility that implements the +original version of the @command{awk} language and a @command{nawk} utility +for the new version. +Others have an @command{oawk} version for the ``old @command{awk}'' +language and plain @command{awk} for the new one. Still others only +have one version, which is usually the new one.@footnote{Often, these systems +use @command{gawk} for their @command{awk} implementation!} + +@cindex @command{nawk} utility +@cindex @command{oawk} utility +All in all, this makes it difficult for you to know which version of +@command{awk} you should run when writing your programs. The best advice +we can give here is to check your local documentation. Look for @command{awk}, +@command{oawk}, and @command{nawk}, as well as for @command{gawk}. +It is likely that you already +have some version of new @command{awk} on your system, which is what +you should use when running your programs. (Of course, if you're reading +this @value{DOCUMENT}, chances are good that you have @command{gawk}!) + +Throughout this @value{DOCUMENT}, whenever we refer to a language feature +that should be available in any complete implementation of POSIX @command{awk}, +we simply use the term @command{awk}. When referring to a feature that is +specific to the GNU implementation, we use the term @command{gawk}. + +@node This Manual +@section Using This Book +@cindex @command{awk}, terms describing + +The term @command{awk} refers to a particular program as well as to the language you +use to tell this program what to do. When we need to be careful, we call +the language ``the @command{awk} language,'' +and the program ``the @command{awk} utility.'' +This @value{DOCUMENT} explains +both how to write programs in the @command{awk} language and how to +run the @command{awk} utility. +The term @dfn{@command{awk} program} refers to a program written by you in +the @command{awk} programming language. + +@cindex @command{gawk}, @command{awk} and +@cindex @command{awk}, @command{gawk} and +@cindex POSIX @command{awk} +Primarily, this @value{DOCUMENT} explains the features of @command{awk} +as defined in the POSIX standard. It does so in the context of the +@command{gawk} implementation. While doing so, it also +attempts to describe important differences between @command{gawk} +and other @command{awk} implementations.@footnote{All such differences +appear in the index under the +entry ``differences in @command{awk} and @command{gawk}.''} +Finally, any @command{gawk} features that are not in +the POSIX standard for @command{awk} are noted. + +@ifnotinfo +This @value{DOCUMENT} has the difficult task of being both a tutorial and a reference. +If you are a novice, feel free to skip over details that seem too complex. +You should also ignore the many cross-references; they are for the +expert user and for the online Info and HTML versions of the document. +@end ifnotinfo + +There are +subsections labeled +as @strong{Advanced Notes} +scattered throughout the @value{DOCUMENT}. +They add a more complete explanation of points that are relevant, but not likely +to be of interest on first reading. +All appear in the index, under the heading ``advanced features.'' + +Most of the time, the examples use complete @command{awk} programs. +Some of the more advanced sections show only the part of the @command{awk} +program that illustrates the concept currently being described. + +While this @value{DOCUMENT} is aimed principally at people who have not been +exposed +to @command{awk}, there is a lot of information here that even the @command{awk} +expert should find useful. In particular, the description of POSIX +@command{awk} and the example programs in +@ref{Library Functions}, and in +@ref{Sample Programs}, +should be of interest. + +@ref{Getting Started}, +provides the essentials you need to know to begin using @command{awk}. + +@ref{Invoking Gawk}, +describes how to run @command{gawk}, the meaning of its +command-line options, and how it finds @command{awk} +program source files. + +@ref{Regexp}, +introduces regular expressions in general, and in particular the flavors +supported by POSIX @command{awk} and @command{gawk}. + +@ref{Reading Files}, +describes how @command{awk} reads your data. +It introduces the concepts of records and fields, as well +as the @code{getline} command. +I/O redirection is first described here. +Network I/O is also briefly introduced here. + +@ref{Printing}, +describes how @command{awk} programs can produce output with +@code{print} and @code{printf}. + +@ref{Expressions}, +describes expressions, which are the basic building blocks +for getting most things done in a program. + +@ref{Patterns and Actions}, +describes how to write patterns for matching records, actions for +doing something when a record is matched, and the built-in variables +@command{awk} and @command{gawk} use. + +@ref{Arrays}, +covers @command{awk}'s one-and-only data structure: associative arrays. +Deleting array elements and whole arrays is also described, as well as +sorting arrays in @command{gawk}. It also describes how @command{gawk} +provides arrays of arrays. + +@ref{Functions}, +describes the built-in functions @command{awk} and +@command{gawk} provide, as well as how to define +your own functions. + +@ref{Internationalization}, +describes special features in @command{gawk} for translating program +messages into different languages at runtime. + +@ref{Advanced Features}, +describes a number of @command{gawk}-specific advanced features. +Of particular note +are the abilities to have two-way communications with another process, +perform TCP/IP networking, and +profile your @command{awk} programs. + +@ref{Library Functions}, and +@ref{Sample Programs}, +provide many sample @command{awk} programs. +Reading them allows you to see @command{awk} +solving real problems. + +@ref{Debugger}, describes the @command{awk} debugger, +@command{dgawk}. + +@ref{Language History}, +describes how the @command{awk} language has evolved since +its first release to present. It also describes how @command{gawk} +has acquired features over time. + +@ref{Installation}, +describes how to get @command{gawk}, how to compile it +on POSIX-compatible systems, +and how to compile and use it on different +non-POSIX systems. It also describes how to report bugs +in @command{gawk} and where to get other freely +available @command{awk} implementations. + +@ref{Notes}, +describes how to disable @command{gawk}'s extensions, as +well as how to contribute new code to @command{gawk}, +how to write extension libraries, and some possible +future directions for @command{gawk} development. + +@ref{Basic Concepts}, +provides some very cursory background material for those who +are completely unfamiliar with computer programming. +Also centralized there is a discussion of some of the issues +surrounding floating-point numbers. + +The +@ref{Glossary}, +defines most, if not all, the significant terms used +throughout the book. +If you find terms that you aren't familiar with, try looking them up here. + +@ref{Copying}, and +@ref{GNU Free Documentation License}, +present the licenses that cover the @command{gawk} source code +and this @value{DOCUMENT}, respectively. + +@node Conventions +@section Typographical Conventions + +@cindex Texinfo +This @value{DOCUMENT} is written in @uref{http://texinfo.org, Texinfo}, +the GNU documentation formatting language. +A single Texinfo source file is used to produce both the printed and online +versions of the documentation. +@ifnotinfo +Because of this, the typographical conventions +are slightly different than in other books you may have read. +@end ifnotinfo +@ifinfo +This @value{SECTION} briefly documents the typographical conventions used in Texinfo. +@end ifinfo + +Examples you would type at the command-line are preceded by the common +shell primary and secondary prompts, @samp{$} and @samp{>}. +Input that you type is shown @kbd{like this}. +Output from the command is preceded by the glyph ``@print{}''. +This typically represents the command's standard output. +Error messages, and other output on the command's standard error, are preceded +by the glyph ``@error{}''. For example: + +@example +$ @kbd{echo hi on stdout} +@print{} hi on stdout +$ @kbd{echo hello on stderr 1>&2} +@error{} hello on stderr +@end example + +@ifnotinfo +In the text, command names appear in @code{this font}, while code segments +appear in the same font and quoted, @samp{like this}. +Options look like this: @option{-f}. +Some things are +emphasized @emph{like this}, and if a point needs to be made +strongly, it is done @strong{like this}. The first occurrence of +a new term is usually its @dfn{definition} and appears in the same +font as the previous occurrence of ``definition'' in this sentence. +Finally, @value{FN}s are indicated like this: @file{/path/to/ourfile}. +@end ifnotinfo + +Characters that you type at the keyboard look @kbd{like this}. In particular, +there are special characters called ``control characters.'' These are +characters that you type by holding down both the @kbd{CONTROL} key and +another key, at the same time. For example, a @kbd{@value{CTL}-d} is typed +by first pressing and holding the @kbd{CONTROL} key, next +pressing the @kbd{d} key and finally releasing both keys. + +@c fakenode --- for prepinfo +@subsubheading Dark Corners +@cindex Kernighan, Brian +@quotation +@i{Dark corners are basically fractal --- no matter how much +you illuminate, there's always a smaller but darker one.}@* +Brian Kernighan +@end quotation + +@cindex d.c., See dark corner +@cindex dark corner +Until the POSIX standard (and @cite{@value{TITLE}}), +many features of @command{awk} were either poorly documented or not +documented at all. Descriptions of such features +(often called ``dark corners'') are noted in this @value{DOCUMENT} with +@iftex +the picture of a flashlight in the margin, as shown here. +@value{DARKCORNER} +@end iftex +@ifnottex +``(d.c.)''. +@end ifnottex +They also appear in the index under the heading ``dark corner.'' + +As noted by the opening quote, though, any +coverage of dark corners +is, by definition, incomplete. + +Extensions to the standard @command{awk} language that are supported by +more than one @command{awk} implementation are marked +``@value{COMMONEXT},'' and listed in the index under ``common extensions'' +and ``extensions, common.'' + +@node Manual History +@unnumberedsec The GNU Project and This Book + +@cindex FSF (Free Software Foundation) +@cindex Free Software Foundation (FSF) +@cindex Stallman, Richard +The Free Software Foundation (FSF) is a nonprofit organization dedicated +to the production and distribution of freely distributable software. +It was founded by Richard M.@: Stallman, the author of the original +Emacs editor. GNU Emacs is the most widely used version of Emacs today. + +@cindex GNU Project +@cindex GPL (General Public License) +@cindex General Public License, See GPL +@cindex documentation, online +The GNU@footnote{GNU stands for ``GNU's not Unix.''} +Project is an ongoing effort on the part of the Free Software +Foundation to create a complete, freely distributable, POSIX-compliant +computing environment. +The FSF uses the ``GNU General Public License'' (GPL) to ensure that +their software's +source code is always available to the end user. A +copy of the GPL is included +@ifnotinfo +in this @value{DOCUMENT} +@end ifnotinfo +for your reference +(@pxref{Copying}). +The GPL applies to the C language source code for @command{gawk}. +To find out more about the FSF and the GNU Project online, +see @uref{http://www.gnu.org, the GNU Project's home page}. +This @value{DOCUMENT} may also be read from +@uref{http://www.gnu.org/software/gawk/manual/, their web site}. + +A shell, an editor (Emacs), highly portable optimizing C, C++, and +Objective-C compilers, a symbolic debugger and dozens of large and +small utilities (such as @command{gawk}), have all been completed and are +freely available. The GNU operating +system kernel (the HURD), has been released but remains in an early +stage of development. + +@cindex Linux +@cindex GNU/Linux +@cindex operating systems, BSD-based +@cindex Alpha (DEC) +Until the GNU operating system is more fully developed, you should +consider using GNU/Linux, a freely distributable, Unix-like operating +system for Intel@registeredsymbol{}, +Power Architecture, +Sun SPARC, IBM S/390, and other +systems.@footnote{The terminology ``GNU/Linux'' is explained +in the @ref{Glossary}.} +Many GNU/Linux distributions are +available for download from the Internet. + +(There are numerous other freely available, Unix-like operating systems +based on the +Berkeley Software Distribution, and some of them use recent versions +of @command{gawk} for their versions of @command{awk}. +@uref{http://www.netbsd.org, NetBSD}, +@uref{http://www.freebsd.org, FreeBSD}, +and +@uref{http://www.openbsd.org, OpenBSD} +are three of the most popular ones, but there +are others.) + +@ifnotinfo +The @value{DOCUMENT} you are reading is actually free---at least, the +information in it is free to anyone. The machine-readable +source code for the @value{DOCUMENT} comes with @command{gawk}; anyone +may take this @value{DOCUMENT} to a copying machine and make as many +copies as they like. (Take a moment to check the Free Documentation +License in @ref{GNU Free Documentation License}.) +@end ifnotinfo + +@ignore +@cindex Close, Diane +The @value{DOCUMENT} itself has gone through several previous, +preliminary editions. +Paul Rubin wrote the very first draft of @cite{The GAWK Manual}; +it was around 40 pages in size. +Diane Close and Richard Stallman improved it, yielding the +version which I started working with in the fall of 1988. +It was around 90 pages long and barely described the original, ``old'' +version of @command{awk}. After substantial revision, the first version of +the @cite{The GAWK Manual} to be released was Edition 0.11 Beta in +October of 1989. The manual then underwent more substantial revision +for Edition 0.13 of December 1991. +David Trueman, Pat Rankin and Michal Jaegermann contributed sections +of the manual for Edition 0.13. +That edition was published by the +FSF as a bound book early in 1992. Since then there were several +minor revisions, notably Edition 0.14 of November 1992 that was published +by the FSF in January of 1993 and Edition 0.16 of August 1993. + +Edition 1.0 of @cite{GAWK: The GNU Awk User's Guide} represented a significant re-working +of @cite{The GAWK Manual}, with much additional material. +The FSF and I agreed that I was now the primary author. +@c I also felt that the manual needed a more descriptive title. + +In January 1996, SSC published Edition 1.0 under the title @cite{Effective AWK Programming}. +In February 1997, they published Edition 1.0.3 which had minor changes +as a ``second edition.'' +In 1999, the FSF published this same version as Edition 2 +of @cite{GAWK: The GNU Awk User's Guide}. + +Edition @value{EDITION} maintains the basic structure of Edition 1.0, +but with significant additional material, reflecting the host of new features +in @command{gawk} @value{PVERSION} @value{VERSION}. +Of particular note is +@ref{Array Sorting}, +@ref{Bitwise Functions}, +@ref{Internationalization}, +@ref{Advanced Features}, +and +@ref{Dynamic Extensions}. +@end ignore + +@cindex Close, Diane +The @value{DOCUMENT} itself has gone through a number of previous editions. +Paul Rubin wrote the very first draft of @cite{The GAWK Manual}; +it was around 40 pages in size. +Diane Close and Richard Stallman improved it, yielding a +version that was +around 90 pages long and barely described the original, ``old'' +version of @command{awk}. + +I started working with that version in the fall of 1988. +As work on it progressed, +the FSF published several preliminary versions (numbered 0.@var{x}). +In 1996, Edition 1.0 was released with @command{gawk} 3.0.0. +The FSF published the first two editions under +the title @cite{The GNU Awk User's Guide}. + +This edition maintains the basic structure of the previous editions. +For Edition 4.0, the content has been thoroughly reviewed +and updated. All references to versions prior to 4.0 have been +removed. +Of significant note for this edition is @ref{Debugger}. + +@cite{@value{TITLE}} will undoubtedly continue to evolve. +An electronic version +comes with the @command{gawk} distribution from the FSF. +If you find an error in this @value{DOCUMENT}, please report it! +@xref{Bugs}, for information on submitting +problem reports electronically. + +@node How To Contribute +@unnumberedsec How to Contribute + +As the maintainer of GNU @command{awk}, I once thought that I would be +able to manage a collection of publicly available @command{awk} programs +and I even solicited contributions. Making things available on the Internet +helps keep the @command{gawk} distribution down to manageable size. + +The initial collection of material, such as it is, is still available +at @uref{ftp://ftp.freefriends.org/arnold/Awkstuff}. In the hopes of +doing something more broad, I acquired the @code{awk.info} domain. + +However, I found that I could not dedicate enough time to managing +contributed code: the archive did not grow and the domain went unused +for several years. + +Fortunately, late in 2008, a volunteer took on the task of setting up +an @command{awk}-related web site---@uref{http://awk.info}---and did a very +nice job. + +If you have written an interesting @command{awk} program, or have written +a @command{gawk} extension that you would like to share with the rest +of the world, please see @uref{http://awk.info/?contribute} for how to +contribute it to the web site. + +@ignore +Other links: + +http://www.reddit.com/r/linux/comments/dtect/composing_music_in_awk/ +@end ignore + +@node Acknowledgments +@unnumberedsec Acknowledgments + +The initial draft of @cite{The GAWK Manual} had the following acknowledgments: + +@quotation +Many people need to be thanked for their assistance in producing this +manual. Jay Fenlason contributed many ideas and sample programs. Richard +Mlynarik and Robert Chassell gave helpful comments on drafts of this +manual. The paper @cite{A Supplemental Document for @command{awk}} by John W.@: +Pierce of the Chemistry Department at UC San Diego, pinpointed several +issues relevant both to @command{awk} implementation and to this manual, that +would otherwise have escaped us. +@end quotation + +@cindex Stallman, Richard +I would like to acknowledge Richard M.@: Stallman, for his vision of a +better world and for his courage in founding the FSF and starting the +GNU Project. + +Earlier editions of this @value{DOCUMENT} had the following acknowledgements: + +@quotation +The following people (in alphabetical order) +provided helpful comments on various +versions of this book, +Rick Adams, +Dr.@: Nelson H.F. Beebe, +Karl Berry, +Dr.@: Michael Brennan, +Rich Burridge, +Claire Cloutier, +Diane Close, +Scott Deifik, +Christopher (``Topher'') Eliot, +Jeffrey Friedl, +Dr.@: Darrel Hankerson, +Michal Jaegermann, +Dr.@: Richard J.@: LeBlanc, +Michael Lijewski, +Pat Rankin, +Miriam Robbins, +Mary Sheehan, +and +Chuck Toporek. + +@cindex Berry, Karl +@cindex Chassell, Robert J.@: +@c @cindex Texinfo +Robert J.@: Chassell provided much valuable advice on +the use of Texinfo. +He also deserves special thanks for +convincing me @emph{not} to title this @value{DOCUMENT} +@cite{How To Gawk Politely}. +Karl Berry helped significantly with the @TeX{} part of Texinfo. + +@cindex Hartholz, Marshall +@cindex Hartholz, Elaine +@cindex Schreiber, Bert +@cindex Schreiber, Rita +I would like to thank Marshall and Elaine Hartholz of Seattle and +Dr.@: Bert and Rita Schreiber of Detroit for large amounts of quiet vacation +time in their homes, which allowed me to make significant progress on +this @value{DOCUMENT} and on @command{gawk} itself. + +@cindex Hughes, Phil +Phil Hughes of SSC +contributed in a very important way by loaning me his laptop GNU/Linux +system, not once, but twice, which allowed me to do a lot of work while +away from home. + +@cindex Trueman, David +David Trueman deserves special credit; he has done a yeoman job +of evolving @command{gawk} so that it performs well and without bugs. +Although he is no longer involved with @command{gawk}, +working with him on this project was a significant pleasure. + +@cindex Drepper, Ulrich +@cindex GNITS mailing list +@cindex mailing list, GNITS +The intrepid members of the GNITS mailing list, and most notably Ulrich +Drepper, provided invaluable help and feedback for the design of the +internationalization features. + +Chuck Toporek, Mary Sheehan, and Claire Coutier of O'Reilly & Associates contributed +significant editorial help for this @value{DOCUMENT} for the +3.1 release of @command{gawk}. +@end quotation + +@cindex Beebe, Nelson +@cindex Buening, Andreas +@cindex Colombo, Antonio +@cindex Davies, Stephen +@cindex Deifik, Scott +@cindex DuBois, John +@cindex Hankerson, Darrel +@cindex Haque, John +@cindex Jaegermann, Michal +@cindex Kahrs, J@"urgen +@cindex Kasal, Stepan +@cindex Pitts, Dave +@cindex Rankin, Pat +@cindex Schorr, Andrew +@cindex Vinschen, Corinna +@cindex Wallin, Anders +@cindex Zaretskii, Eli +Dr.@: Nelson Beebe, +Andreas Buening, +Antonio Colombo, +Stephen Davies, +Scott Deifik, +John H. DuBois III, +Darrel Hankerson, +Michal Jaegermann, +J@"urgen Kahrs, +Dave Pitts, +Stepan Kasal, +Pat Rankin, +Andrew Schorr, +Corinna Vinschen, +Anders Wallin, +and Eli Zaretskii +(in alphabetical order) +make up the current +@command{gawk} ``crack portability team.'' Without their hard work and +help, @command{gawk} would not be nearly the fine program it is today. It +has been and continues to be a pleasure working with this team of fine +people. + +John Haque contributed the modifications to convert @command{gawk} +into a byte-code interpreter, including the debugger. Stephen Davies +contributed to the effort to bring the byte-code changes into the mainstream +code base. +Efraim Yawitz contributed the initial text of @ref{Debugger}. + +@cindex Kernighan, Brian +I would like to thank Brian Kernighan for invaluable assistance during the +testing and debugging of @command{gawk}, and for ongoing +help and advice in clarifying numerous points about the language. + We could not have done nearly as good a job on either @command{gawk} +or its documentation without his help. + +@cindex Robbins, Miriam +@cindex Robbins, Jean +@cindex Robbins, Harry +@cindex G-d +I must thank my wonderful wife, Miriam, for her patience through +the many versions of this project, for her proofreading, +and for sharing me with the computer. +I would like to thank my parents for their love, and for the grace with +which they raised and educated me. +Finally, I also must acknowledge my gratitude to G-d, for the many opportunities +He has sent my way, as well as for the gifts He has given me with which to +take advantage of those opportunities. +@sp 2 +@noindent +Arnold Robbins @* +Nof Ayalon @* +ISRAEL @* +March, 2011 + +@ignore +@c Try this +@iftex +@page +@headings off +@majorheading I@ @ @ @ The @command{awk} Language and @command{gawk} +Part I describes the @command{awk} language and @command{gawk} program in detail. +It starts with the basics, and continues through all of the features of @command{awk} +and @command{gawk}. It contains the following chapters: + +@itemize @bullet +@item +@ref{Getting Started}. + +@item +@ref{Regexp}. + +@item +@ref{Reading Files}. + +@item +@ref{Printing}. + +@item +@ref{Expressions}. + +@item +@ref{Patterns and Actions}. + +@item +@ref{Arrays}. + +@item +@ref{Functions}. + +@item +@ref{Internationalization}. + +@item +@ref{Advanced Features}. + +@item +@ref{Invoking Gawk}. +@end itemize + +@page +@evenheading @thispage@ @ @ @strong{@value{TITLE}} @| @| +@oddheading @| @| @strong{@thischapter}@ @ @ @thispage +@end iftex +@end ignore + +@node Getting Started +@chapter Getting Started with @command{awk} +@c @cindex script, definition of +@c @cindex rule, definition of +@c @cindex program, definition of +@c @cindex basic function of @command{awk} +@cindex @command{awk}, function of + +The basic function of @command{awk} is to search files for lines (or other +units of text) that contain certain patterns. When a line matches one +of the patterns, @command{awk} performs specified actions on that line. +@command{awk} keeps processing input lines in this way until it reaches +the end of the input files. + +@cindex @command{awk}, uses for +@cindex programming languages@comma{} data-driven vs.@: procedural +@cindex @command{awk} programs +Programs in @command{awk} are different from programs in most other languages, +because @command{awk} programs are @dfn{data-driven}; that is, you describe +the data you want to work with and then what to do when you find it. +Most other languages are @dfn{procedural}; you have to describe, in great +detail, every step the program is to take. When working with procedural +languages, it is usually much +harder to clearly describe the data your program will process. +For this reason, @command{awk} programs are often refreshingly easy to +read and write. + +@cindex program, definition of +@cindex rule, definition of +When you run @command{awk}, you specify an @command{awk} @dfn{program} that +tells @command{awk} what to do. The program consists of a series of +@dfn{rules}. (It may also contain @dfn{function definitions}, +an advanced feature that we will ignore for now. +@xref{User-defined}.) Each rule specifies one +pattern to search for and one action to perform +upon finding the pattern. + +Syntactically, a rule consists of a pattern followed by an action. The +action is enclosed in curly braces to separate it from the pattern. +Newlines usually separate rules. Therefore, an @command{awk} +program looks like this: + +@example +@var{pattern} @{ @var{action} @} +@var{pattern} @{ @var{action} @} +@dots{} +@end example + +@menu +* Running gawk:: How to run @command{gawk} programs; includes + command-line syntax. +* Sample Data Files:: Sample data files for use in the @command{awk} + programs illustrated in this @value{DOCUMENT}. +* Very Simple:: A very simple example. +* Two Rules:: A less simple one-line example using two + rules. +* More Complex:: A more complex example. +* Statements/Lines:: Subdividing or combining statements into + lines. +* Other Features:: Other Features of @command{awk}. +* When:: When to use @command{gawk} and when to use + other things. +@end menu + +@node Running gawk +@section How to Run @command{awk} Programs + +@cindex @command{awk} programs, running +There are several ways to run an @command{awk} program. If the program is +short, it is easiest to include it in the command that runs @command{awk}, +like this: + +@example +awk '@var{program}' @var{input-file1} @var{input-file2} @dots{} +@end example + +@cindex command line, formats +When the program is long, it is usually more convenient to put it in a file +and run it with a command like this: + +@example +awk -f @var{program-file} @var{input-file1} @var{input-file2} @dots{} +@end example + +This @value{SECTION} discusses both mechanisms, along with several +variations of each. + +@menu +* One-shot:: Running a short throwaway @command{awk} + program. +* Read Terminal:: Using no input files (input from terminal + instead). +* Long:: Putting permanent @command{awk} programs in + files. +* Executable Scripts:: Making self-contained @command{awk} programs. +* Comments:: Adding documentation to @command{gawk} + programs. +* Quoting:: More discussion of shell quoting issues. +@end menu + +@node One-shot +@subsection One-Shot Throwaway @command{awk} Programs + +Once you are familiar with @command{awk}, you will often type in simple +programs the moment you want to use them. Then you can write the +program as the first argument of the @command{awk} command, like this: + +@example +awk '@var{program}' @var{input-file1} @var{input-file2} @dots{} +@end example + +@noindent +where @var{program} consists of a series of @var{patterns} and +@var{actions}, as described earlier. + +@cindex single quote (@code{'}) +@cindex @code{'} (single quote) +This command format instructs the @dfn{shell}, or command interpreter, +to start @command{awk} and use the @var{program} to process records in the +input file(s). There are single quotes around @var{program} so +the shell won't interpret any @command{awk} characters as special shell +characters. The quotes also cause the shell to treat all of @var{program} as +a single argument for @command{awk}, and allow @var{program} to be more +than one line long. + +@cindex shells, scripts +@cindex @command{awk} programs, running, from shell scripts +This format is also useful for running short or medium-sized @command{awk} +programs from shell scripts, because it avoids the need for a separate +file for the @command{awk} program. A self-contained shell script is more +reliable because there are no other files to misplace. + +@ref{Very Simple}, +@ifnotinfo +later in this @value{CHAPTER}, +@end ifnotinfo +presents several short, +self-contained programs. + +@node Read Terminal +@subsection Running @command{awk} Without Input Files + +@cindex standard input +@cindex input, standard +@cindex input files, running @command{awk} without +You can also run @command{awk} without any input files. If you type the +following command line: + +@example +awk '@var{program}' +@end example + +@noindent +@command{awk} applies the @var{program} to the @dfn{standard input}, +which usually means whatever you type on the terminal. This continues +until you indicate end-of-file by typing @kbd{@value{CTL}-d}. +(On other operating systems, the end-of-file character may be different. +For example, on OS/2, it is @kbd{@value{CTL}-z}.) + +@cindex files, input, See input files +@cindex input files, running @command{awk} without +@cindex @command{awk} programs, running, without input files +As an example, the following program prints a friendly piece of advice +(from Douglas Adams's @cite{The Hitchhiker's Guide to the Galaxy}), +to keep you from worrying about the complexities of computer +programming@footnote{If you use Bash as your shell, you should execute +the command @samp{set +H} before running this program interactively, +to disable the C shell-style command history, which treats +@samp{!} as a special character. We recommend putting this command into +your personal startup file.} +(@code{BEGIN} is a feature we haven't discussed yet): + +@example +$ @kbd{awk "BEGIN @{ print \"Don't Panic!\" @}"} +@print{} Don't Panic! +@end example + +@cindex quoting +@cindex double quote (@code{"}) +@cindex @code{"} (double quote) +@cindex @code{\} (backslash) +@cindex backslash (@code{\}) +This program does not read any input. The @samp{\} before each of the +inner double quotes is necessary because of the shell's quoting +rules---in particular because it mixes both single quotes and +double quotes.@footnote{Although we generally recommend the use of single +quotes around the program text, double quotes are needed here in order to +put the single quote into the message.} + +This next simple @command{awk} program +emulates the @command{cat} utility; it copies whatever you type on the +keyboard to its standard output (why this works is explained shortly). + +@example +$ @kbd{awk '@{ print @}'} +@kbd{Now is the time for all good men} +@print{} Now is the time for all good men +@kbd{to come to the aid of their country.} +@print{} to come to the aid of their country. +@kbd{Four score and seven years ago, ...} +@print{} Four score and seven years ago, ... +@kbd{What, me worry?} +@print{} What, me worry? +@kbd{@value{CTL}-d} +@end example + +@node Long +@subsection Running Long Programs + +@cindex @command{awk} programs, running +@cindex @command{awk} programs, lengthy +@cindex files, @command{awk} programs in +Sometimes your @command{awk} programs can be very long. In this case, it is +more convenient to put the program into a separate file. In order to tell +@command{awk} to use that file for its program, you type: + +@example +awk -f @var{source-file} @var{input-file1} @var{input-file2} @dots{} +@end example + +@cindex @code{-f} option +@cindex command line, options +@cindex options, command-line +The @option{-f} instructs the @command{awk} utility to get the @command{awk} program +from the file @var{source-file}. Any @value{FN} can be used for +@var{source-file}. For example, you could put the program: + +@example +BEGIN @{ print "Don't Panic!" @} +@end example + +@noindent +into the file @file{advice}. Then this command: + +@example +awk -f advice +@end example + +@noindent +does the same thing as this one: + +@example +awk "BEGIN @{ print \"Don't Panic!\" @}" +@end example + +@cindex quoting +@noindent +This was explained earlier +(@pxref{Read Terminal}). +Note that you don't usually need single quotes around the @value{FN} that you +specify with @option{-f}, because most @value{FN}s don't contain any of the shell's +special characters. Notice that in @file{advice}, the @command{awk} +program did not have single quotes around it. The quotes are only needed +for programs that are provided on the @command{awk} command line. + +@c STARTOFRANGE sq1x +@cindex single quote (@code{'}) +@c STARTOFRANGE qs2x +@cindex @code{'} (single quote) +If you want to clearly identify your @command{awk} program files as such, +you can add the extension @file{.awk} to the @value{FN}. This doesn't +affect the execution of the @command{awk} program but it does make +``housekeeping'' easier. + +@node Executable Scripts +@subsection Executable @command{awk} Programs +@cindex @command{awk} programs +@cindex @code{#} (number sign), @code{#!} (executable scripts) +@cindex number sign (@code{#}), @code{#!} (executable scripts) +@cindex Unix, @command{awk} scripts and +@cindex @code{#} (number sign), @code{#!} (executable scripts), portability issues with +@cindex number sign (@code{#}), @code{#!} (executable scripts), portability issues with + +Once you have learned @command{awk}, you may want to write self-contained +@command{awk} scripts, using the @samp{#!} script mechanism. You can do +this on many systems.@footnote{The @samp{#!} mechanism works on +GNU/Linux systems, BSD-based systems and commercial Unix systems.} +For example, you could update the file @file{advice} to look like this: + +@example +#! /bin/awk -f + +BEGIN @{ print "Don't Panic!" @} +@end example + +@noindent +After making this file executable (with the @command{chmod} utility), +simply type @samp{advice} +at the shell and the system arranges to run @command{awk}@footnote{The +line beginning with @samp{#!} lists the full @value{FN} of an interpreter +to run and an optional initial command-line argument to pass to that +interpreter. The operating system then runs the interpreter with the given +argument and the full argument list of the executed program. The first argument +in the list is the full @value{FN} of the @command{awk} program. +The rest of the +argument list contains either options to @command{awk}, or @value{DF}s, +or both. Note that on many systems @command{awk} may be found in +@file{/usr/bin} instead of in @file{/bin}. Caveat Emptor.} as if you had +typed @samp{awk -f advice}: + +@example +$ @kbd{chmod +x advice} +$ @kbd{advice} +@print{} Don't Panic! +@end example + +@noindent +(We assume you have the current directory in your shell's search +path variable [typically @code{$PATH}]. If not, you may need +to type @samp{./advice} at the shell.) + +Self-contained @command{awk} scripts are useful when you want to write a +program that users can invoke without their having to know that the program is +written in @command{awk}. + +@c fakenode --- for prepinfo +@subheading Advanced Notes: Portability Issues with @samp{#!} +@cindex portability, @code{#!} (executable scripts) + +Some systems limit the length of the interpreter name to 32 characters. +Often, this can be dealt with by using a symbolic link. + +You should not put more than one argument on the @samp{#!} +line after the path to @command{awk}. It does not work. The operating system +treats the rest of the line as a single argument and passes it to @command{awk}. +Doing this leads to confusing behavior---most likely a usage diagnostic +of some sort from @command{awk}. + +@cindex @code{ARGC}/@code{ARGV} variables, portability and +@cindex portability, @code{ARGV} variable +Finally, +the value of @code{ARGV[0]} +(@pxref{Built-in Variables}) +varies depending upon your operating system. +Some systems put @samp{awk} there, some put the full pathname +of @command{awk} (such as @file{/bin/awk}), and some put the name +of your script (@samp{advice}). @value{DARKCORNER} +Don't rely on the value of @code{ARGV[0]} +to provide your script name. + +@node Comments +@subsection Comments in @command{awk} Programs +@cindex @code{#} (number sign), commenting +@cindex number sign (@code{#}), commenting +@cindex commenting +@cindex @command{awk} programs, documenting + +A @dfn{comment} is some text that is included in a program for the sake +of human readers; it is not really an executable part of the program. Comments +can explain what the program does and how it works. Nearly all +programming languages have provisions for comments, as programs are +typically hard to understand without them. + +In the @command{awk} language, a comment starts with the sharp sign +character (@samp{#}) and continues to the end of the line. +The @samp{#} does not have to be the first character on the line. The +@command{awk} language ignores the rest of a line following a sharp sign. +For example, we could have put the following into @file{advice}: + +@example +# This program prints a nice friendly message. It helps +# keep novice users from being afraid of the computer. +BEGIN @{ print "Don't Panic!" @} +@end example + +You can put comment lines into keyboard-composed throwaway @command{awk} +programs, but this usually isn't very useful; the purpose of a +comment is to help you or another person understand the program +when reading it at a later time. + +@cindex quoting +@cindex single quote (@code{'}), vs.@: apostrophe +@cindex @code{'} (single quote), vs.@: apostrophe +@quotation CAUTION +As mentioned in +@ref{One-shot}, +you can enclose small to medium programs in single quotes, in order to keep +your shell scripts self-contained. When doing so, @emph{don't} put +an apostrophe (i.e., a single quote) into a comment (or anywhere else +in your program). The shell interprets the quote as the closing +quote for the entire program. As a result, usually the shell +prints a message about mismatched quotes, and if @command{awk} actually +runs, it will probably print strange messages about syntax errors. +For example, look at the following: + +@example +$ @kbd{awk '@{ print "hello" @} # let's be cute'} +> +@end example + +The shell sees that the first two quotes match, and that +a new quoted object begins at the end of the command line. +It therefore prompts with the secondary prompt, waiting for more input. +With Unix @command{awk}, closing the quoted string produces this result: + +@example +$ @kbd{awk '@{ print "hello" @} # let's be cute'} +> @kbd{'} +@error{} awk: can't open file be +@error{} source line number 1 +@end example + +@cindex @code{\} (backslash) +@cindex backslash (@code{\}) +Putting a backslash before the single quote in @samp{let's} wouldn't help, +since backslashes are not special inside single quotes. +The next @value{SUBSECTION} describes the shell's quoting rules. +@end quotation + +@node Quoting +@subsection Shell-Quoting Issues +@cindex quoting, rules for + +@menu +* DOS Quoting:: Quoting in Windows Batch Files. +@end menu + +For short to medium length @command{awk} programs, it is most convenient +to enter the program on the @command{awk} command line. +This is best done by enclosing the entire program in single quotes. +This is true whether you are entering the program interactively at +the shell prompt, or writing it as part of a larger shell script: + +@example +awk '@var{program text}' @var{input-file1} @var{input-file2} @dots{} +@end example + +@cindex shells, quoting, rules for +@cindex Bourne shell, quoting rules for +Once you are working with the shell, it is helpful to have a basic +knowledge of shell quoting rules. The following rules apply only to +POSIX-compliant, Bourne-style shells (such as Bash, the GNU Bourne-Again +Shell). If you use the C shell, you're on your own. + +@itemize @bullet +@item +Quoted items can be concatenated with nonquoted items as well as with other +quoted items. The shell turns everything into one argument for +the command. + +@item +Preceding any single character with a backslash (@samp{\}) quotes +that character. The shell removes the backslash and passes the quoted +character on to the command. + +@item +@cindex @code{\} (backslash) +@cindex backslash (@code{\}) +@cindex single quote (@code{'}) +@cindex @code{'} (single quote) +Single quotes protect everything between the opening and closing quotes. +The shell does no interpretation of the quoted text, passing it on verbatim +to the command. +It is @emph{impossible} to embed a single quote inside single-quoted text. +Refer back to +@ref{Comments}, +for an example of what happens if you try. + +@item +@cindex double quote (@code{"}) +@cindex @code{"} (double quote) +Double quotes protect most things between the opening and closing quotes. +The shell does at least variable and command substitution on the quoted text. +Different shells may do additional kinds of processing on double-quoted text. + +Since certain characters within double-quoted text are processed by the shell, +they must be @dfn{escaped} within the text. Of note are the characters +@samp{$}, @samp{`}, @samp{\}, and @samp{"}, all of which must be preceded by +a backslash within double-quoted text if they are to be passed on literally +to the program. (The leading backslash is stripped first.) +Thus, the example seen +@ifnotinfo +previously +@end ifnotinfo +in @ref{Read Terminal}, +is applicable: + +@example +$ @kbd{awk "BEGIN @{ print \"Don't Panic!\" @}"} +@print{} Don't Panic! +@end example + +@cindex single quote (@code{'}), with double quotes +@cindex @code{'} (single quote), with double quotes +Note that the single quote is not special within double quotes. + +@item +Null strings are removed when they occur as part of a non-null +command-line argument, while explicit non-null objects are kept. +For example, to specify that the field separator @code{FS} should +be set to the null string, use: + +@example +awk -F "" '@var{program}' @var{files} # correct +@end example + +@noindent +@cindex null strings, quoting and +Don't use this: + +@example +awk -F"" '@var{program}' @var{files} # wrong! +@end example + +@noindent +In the second case, @command{awk} will attempt to use the text of the program +as the value of @code{FS}, and the first @value{FN} as the text of the program! +This results in syntax errors at best, and confusing behavior at worst. +@end itemize + +@cindex quoting, tricks for +Mixing single and double quotes is difficult. You have to resort +to shell quoting tricks, like this: + +@example +$ @kbd{awk 'BEGIN @{ print "Here is a single quote <'"'"'>" @}'} +@print{} Here is a single quote <'> +@end example + +@noindent +This program consists of three concatenated quoted strings. The first and the +third are single-quoted, the second is double-quoted. + +This can be ``simplified'' to: + +@example +$ @kbd{awk 'BEGIN @{ print "Here is a single quote <'\''>" @}'} +@print{} Here is a single quote <'> +@end example + +@noindent +Judge for yourself which of these two is the more readable. + +Another option is to use double quotes, escaping the embedded, @command{awk}-level +double quotes: + +@example +$ @kbd{awk "BEGIN @{ print \"Here is a single quote <'>\" @}"} +@print{} Here is a single quote <'> +@end example + +@noindent +@c ENDOFRANGE sq1x +@c ENDOFRANGE qs2x +This option is also painful, because double quotes, backslashes, and dollar signs +are very common in more advanced @command{awk} programs. + +A third option is to use the octal escape sequence equivalents +(@pxref{Escape Sequences}) +for the +single- and double-quote characters, like so: + +@example +$ @kbd{awk 'BEGIN @{ print "Here is a single quote <\47>" @}'} +@print{} Here is a single quote <'> +$ @kbd{awk 'BEGIN @{ print "Here is a double quote <\42>" @}'} +@print{} Here is a double quote <"> +@end example + +@noindent +This works nicely, except that you should comment clearly what the +escapes mean. + +A fourth option is to use command-line variable assignment, like this: + +@example +$ awk -v sq="'" 'BEGIN @{ print "Here is a single quote <" sq ">" @}' +@print{} Here is a single quote <'> +@end example + +If you really need both single and double quotes in your @command{awk} +program, it is probably best to move it into a separate file, where +the shell won't be part of the picture, and you can say what you mean. + +@node DOS Quoting +@subsubsection Quoting in MS-Windows Batch Files + +@ignore +Date: Wed, 21 May 2008 09:58:43 +0200 (CEST) +From: jeroen.brink@inter.NL.net +Subject: (g)awk "contribution" +To: arnold@skeeve.com +Message-id: <42220.193.172.132.34.1211356723.squirrel@webmail.internl.net> + +Hello Arnold, + +maybe you can help me out. Found your email on the GNU/awk online manual +pages. + +I've searched hard to figure out how, on Windows, to print double quotes. +Couldn't find it in the Quotes area, nor on google or elsewhere. Finally i +figured out how to do this myself. + +How to print all lines in a file surrounded by double quotes (on Windows): + +gawk "{ print \"\042\" $0 \"\042\" }" + +Maybe this is a helpfull tip for other (Windows) gawk users. However, i +don't have a clue as to where to "publish" this tip! Do you? + +Kind regards, + +Jeroen Brink +@end ignore + +Although this @value{DOCUMENT} generally only worries about POSIX systems and the +POSIX shell, the following issue arises often enough for many users that +it is worth addressing. + +The ``shells'' on Microsoft Windows systems use the double-quote +character for quoting, and make it difficult or impossible to include an +escaped double-quote character in a command-line script. +The following example, courtesy of Jeroen Brink, shows +how to print all lines in a file surrounded by double quotes: + +@example +gawk "@{ print \"\042\" $0 \"\042\" @}" @var{file} +@end example + + +@node Sample Data Files +@section @value{DDF}s for the Examples +@c For gawk >= 4.0, update these data files. No-one has such slow modems! + +@cindex input files, examples +@cindex @code{BBS-list} file +Many of the examples in this @value{DOCUMENT} take their input from two sample +@value{DF}s. The first, @file{BBS-list}, represents a list of +computer bulletin board systems together with information about those systems. +The second @value{DF}, called @file{inventory-shipped}, contains +information about monthly shipments. In both files, +each line is considered to be one @dfn{record}. + +In the @value{DF} @file{BBS-list}, each record contains the name of a computer +bulletin board, its phone number, the board's baud rate(s), and a code for +the number of hours it is operational. An @samp{A} in the last column +means the board operates 24 hours a day. A @samp{B} in the last +column means the board only operates on evening and weekend hours. +A @samp{C} means the board operates only on weekends: + +@c 2e: Update the baud rates to reflect today's faster modems +@example +@c system if test ! -d eg ; then mkdir eg ; fi +@c system if test ! -d eg/lib ; then mkdir eg/lib ; fi +@c system if test ! -d eg/data ; then mkdir eg/data ; fi +@c system if test ! -d eg/prog ; then mkdir eg/prog ; fi +@c system if test ! -d eg/misc ; then mkdir eg/misc ; fi +@c file eg/data/BBS-list +aardvark 555-5553 1200/300 B +alpo-net 555-3412 2400/1200/300 A +barfly 555-7685 1200/300 A +bites 555-1675 2400/1200/300 A +camelot 555-0542 300 C +core 555-2912 1200/300 C +fooey 555-1234 2400/1200/300 B +foot 555-6699 1200/300 B +macfoo 555-6480 1200/300 A +sdace 555-3430 2400/1200/300 A +sabafoo 555-2127 1200/300 C +@c endfile +@end example + +@cindex @code{inventory-shipped} file +The @value{DF} @file{inventory-shipped} represents +information about shipments during the year. +Each record contains the month, the number +of green crates shipped, the number of red boxes shipped, the number of +orange bags shipped, and the number of blue packages shipped, +respectively. There are 16 entries, covering the 12 months of last year +and the first four months of the current year. + +@example +@c file eg/data/inventory-shipped +Jan 13 25 15 115 +Feb 15 32 24 226 +Mar 15 24 34 228 +Apr 31 52 63 420 +May 16 34 29 208 +Jun 31 42 75 492 +Jul 24 34 67 436 +Aug 15 34 47 316 +Sep 13 55 37 277 +Oct 29 54 68 525 +Nov 20 87 82 577 +Dec 17 35 61 401 + +Jan 21 36 64 620 +Feb 26 58 80 652 +Mar 24 75 70 495 +Apr 21 70 74 514 +@c endfile +@end example + +@ifinfo +If you are reading this in GNU Emacs using Info, you can copy the regions +of text showing these sample files into your own test files. This way you +can try out the examples shown in the remainder of this document. You do +this by using the command @kbd{M-x write-region} to copy text from the Info +file into a file for use with @command{awk} +(@xref{Misc File Ops, , Miscellaneous File Operations, emacs, GNU Emacs Manual}, +for more information). Using this information, create your own +@file{BBS-list} and @file{inventory-shipped} files and practice what you +learn in this @value{DOCUMENT}. + +@cindex Texinfo +If you are using the stand-alone version of Info, +see @ref{Extract Program}, +for an @command{awk} program that extracts these @value{DF}s from +@file{gawk.texi}, the Texinfo source file for this Info file. +@end ifinfo + +@node Very Simple +@section Some Simple Examples + +The following command runs a simple @command{awk} program that searches the +input file @file{BBS-list} for the character string @samp{foo} (a +grouping of characters is usually called a @dfn{string}; +the term @dfn{string} is based on similar usage in English, such +as ``a string of pearls,'' or ``a string of cars in a train''): + +@example +awk '/foo/ @{ print $0 @}' BBS-list +@end example + +@noindent +When lines containing @samp{foo} are found, they are printed because +@w{@samp{print $0}} means print the current line. (Just @samp{print} by +itself means the same thing, so we could have written that +instead.) + +You will notice that slashes (@samp{/}) surround the string @samp{foo} +in the @command{awk} program. The slashes indicate that @samp{foo} +is the pattern to search for. This type of pattern is called a +@dfn{regular expression}, which is covered in more detail later +(@pxref{Regexp}). +The pattern is allowed to match parts of words. +There are +single quotes around the @command{awk} program so that the shell won't +interpret any of it as special shell characters. + +Here is what this program prints: + +@example +$ @kbd{awk '/foo/ @{ print $0 @}' BBS-list} +@print{} fooey 555-1234 2400/1200/300 B +@print{} foot 555-6699 1200/300 B +@print{} macfoo 555-6480 1200/300 A +@print{} sabafoo 555-2127 1200/300 C +@end example + +@cindex actions, default +@cindex patterns, default +In an @command{awk} rule, either the pattern or the action can be omitted, +but not both. If the pattern is omitted, then the action is performed +for @emph{every} input line. If the action is omitted, the default +action is to print all lines that match the pattern. + +@cindex actions, empty +Thus, we could leave out the action (the @code{print} statement and the curly +braces) in the previous example and the result would be the same: +@command{awk} prints all lines matching the pattern @samp{foo}. By comparison, +omitting the @code{print} statement but retaining the curly braces makes an +empty action that does nothing (i.e., no lines are printed). + +@cindex @command{awk} programs, one-line examples +Many practical @command{awk} programs are just a line or two. Following is a +collection of useful, short programs to get you started. Some of these +programs contain constructs that haven't been covered yet. (The description +of the program will give you a good idea of what is going on, but please +read the rest of the @value{DOCUMENT} to become an @command{awk} expert!) +Most of the examples use a @value{DF} named @file{data}. This is just a +placeholder; if you use these programs yourself, substitute +your own @value{FN}s for @file{data}. +For future reference, note that there is often more than +one way to do things in @command{awk}. At some point, you may want +to look back at these examples and see if +you can come up with different ways to do the same things shown here: + +@itemize @bullet +@item +Print the length of the longest input line: + +@example +awk '@{ if (length($0) > max) max = length($0) @} + END @{ print max @}' data +@end example + +@item +Print every line that is longer than 80 characters: + +@example +awk 'length($0) > 80' data +@end example + +The sole rule has a relational expression as its pattern and it has no +action---so the default action, printing the record, is used. + +@cindex @command{expand} utility +@item +Print the length of the longest line in @file{data}: + +@example +expand data | awk '@{ if (x < length()) x = length() @} + END @{ print "maximum line length is " x @}' +@end example + +The input is processed by the @command{expand} utility to change TABs +into spaces, so the widths compared are actually the right-margin columns. + +@item +Print every line that has at least one field: + +@example +awk 'NF > 0' data +@end example + +This is an easy way to delete blank lines from a file (or rather, to +create a new file similar to the old file but from which the blank lines +have been removed). + +@item +Print seven random numbers from 0 to 100, inclusive: + +@example +awk 'BEGIN @{ for (i = 1; i <= 7; i++) + print int(101 * rand()) @}' +@end example + +@item +Print the total number of bytes used by @var{files}: + +@example +ls -l @var{files} | awk '@{ x += $5 @} + END @{ print "total bytes: " x @}' +@end example + +@item +Print the total number of kilobytes used by @var{files}: + +@c Don't use \ continuation, not discussed yet +@c Remember that awk does floating point division, +@c no need for (x+1023) / 1024 +@example +ls -l @var{files} | awk '@{ x += $5 @} + END @{ print "total K-bytes:", x / 1024 @}' +@end example + +@item +Print a sorted list of the login names of all users: + +@example +awk -F: '@{ print $1 @}' /etc/passwd | sort +@end example + +@item +Count the lines in a file: + +@example +awk 'END @{ print NR @}' data +@end example + +@item +Print the even-numbered lines in the @value{DF}: + +@example +awk 'NR % 2 == 0' data +@end example + +If you use the expression @samp{NR % 2 == 1} instead, +the program would print the odd-numbered lines. +@end itemize + +@node Two Rules +@section An Example with Two Rules +@cindex @command{awk} programs + +The @command{awk} utility reads the input files one line at a +time. For each line, @command{awk} tries the patterns of each of the rules. +If several patterns match, then several actions are run in the order in +which they appear in the @command{awk} program. If no patterns match, then +no actions are run. + +After processing all the rules that match the line (and perhaps there are none), +@command{awk} reads the next line. (However, +@pxref{Next Statement}, +and also @pxref{Nextfile Statement}). +This continues until the program reaches the end of the file. +For example, the following @command{awk} program contains two rules: + +@example +/12/ @{ print $0 @} +/21/ @{ print $0 @} +@end example + +@noindent +The first rule has the string @samp{12} as the +pattern and @samp{print $0} as the action. The second rule has the +string @samp{21} as the pattern and also has @samp{print $0} as the +action. Each rule's action is enclosed in its own pair of braces. + +This program prints every line that contains the string +@samp{12} @emph{or} the string @samp{21}. If a line contains both +strings, it is printed twice, once by each rule. + +This is what happens if we run this program on our two sample @value{DF}s, +@file{BBS-list} and @file{inventory-shipped}: + +@example +$ @kbd{awk '/12/ @{ print $0 @}} +> @kbd{/21/ @{ print $0 @}' BBS-list inventory-shipped} +@print{} aardvark 555-5553 1200/300 B +@print{} alpo-net 555-3412 2400/1200/300 A +@print{} barfly 555-7685 1200/300 A +@print{} bites 555-1675 2400/1200/300 A +@print{} core 555-2912 1200/300 C +@print{} fooey 555-1234 2400/1200/300 B +@print{} foot 555-6699 1200/300 B +@print{} macfoo 555-6480 1200/300 A +@print{} sdace 555-3430 2400/1200/300 A +@print{} sabafoo 555-2127 1200/300 C +@print{} sabafoo 555-2127 1200/300 C +@print{} Jan 21 36 64 620 +@print{} Apr 21 70 74 514 +@end example + +@noindent +Note how the line beginning with @samp{sabafoo} +in @file{BBS-list} was printed twice, once for each rule. + +@node More Complex +@section A More Complex Example + +Now that we've mastered some simple tasks, let's look at +what typical @command{awk} +programs do. This example shows how @command{awk} can be used to +summarize, select, and rearrange the output of another utility. It uses +features that haven't been covered yet, so don't worry if you don't +understand all the details: + +@example +LC_ALL=C ls -l | awk '$6 == "Nov" @{ sum += $5 @} + END @{ print sum @}' +@end example + +@cindex @command{ls} utility +This command prints the total number of bytes in all the files in the +current directory that were last modified in November (of any year). +The @w{@samp{ls -l}} part of this example is a system command that gives +you a listing of the files in a directory, including each file's size and the date +the file was last modified. Its output looks like this: + +@example +-rw-r--r-- 1 arnold user 1933 Nov 7 13:05 Makefile +-rw-r--r-- 1 arnold user 10809 Nov 7 13:03 awk.h +-rw-r--r-- 1 arnold user 983 Apr 13 12:14 awk.tab.h +-rw-r--r-- 1 arnold user 31869 Jun 15 12:20 awkgram.y +-rw-r--r-- 1 arnold user 22414 Nov 7 13:03 awk1.c +-rw-r--r-- 1 arnold user 37455 Nov 7 13:03 awk2.c +-rw-r--r-- 1 arnold user 27511 Dec 9 13:07 awk3.c +-rw-r--r-- 1 arnold user 7989 Nov 7 13:03 awk4.c +@end example + +@noindent +@cindex line continuations, with C shell +The first field contains read-write permissions, the second field contains +the number of links to the file, and the third field identifies the owner of +the file. The fourth field identifies the group of the file. +The fifth field contains the size of the file in bytes. The +sixth, seventh, and eighth fields contain the month, day, and time, +respectively, that the file was last modified. Finally, the ninth field +contains the @value{FN}.@footnote{The @samp{LC_ALL=C} is +needed to produce this traditional-style output from @command{ls}.} + +@c @cindex automatic initialization +@cindex initialization, automatic +The @samp{$6 == "Nov"} in our @command{awk} program is an expression that +tests whether the sixth field of the output from @w{@samp{ls -l}} +matches the string @samp{Nov}. Each time a line has the string +@samp{Nov} for its sixth field, the action @samp{sum += $5} is +performed. This adds the fifth field (the file's size) to the variable +@code{sum}. As a result, when @command{awk} has finished reading all the +input lines, @code{sum} is the total of the sizes of the files whose +lines matched the pattern. (This works because @command{awk} variables +are automatically initialized to zero.) + +After the last line of output from @command{ls} has been processed, the +@code{END} rule executes and prints the value of @code{sum}. +In this example, the value of @code{sum} is 80600. + +These more advanced @command{awk} techniques are covered in later sections +(@pxref{Action Overview}). Before you can move on to more +advanced @command{awk} programming, you have to know how @command{awk} interprets +your input and displays your output. By manipulating fields and using +@code{print} statements, you can produce some very useful and +impressive-looking reports. + +@node Statements/Lines +@section @command{awk} Statements Versus Lines +@cindex line breaks +@cindex newlines + +Most often, each line in an @command{awk} program is a separate statement or +separate rule, like this: + +@example +awk '/12/ @{ print $0 @} + /21/ @{ print $0 @}' BBS-list inventory-shipped +@end example + +@cindex @command{gawk}, newlines in +However, @command{gawk} ignores newlines after any of the following +symbols and keywords: + +@example +, @{ ? : || && do else +@end example + +@noindent +A newline at any other point is considered the end of the +statement.@footnote{The @samp{?} and @samp{:} referred to here is the +three-operand conditional expression described in +@ref{Conditional Exp}. +Splitting lines after @samp{?} and @samp{:} is a minor @command{gawk} +extension; if @option{--posix} is specified +(@pxref{Options}), then this extension is disabled.} + +@cindex @code{\} (backslash), continuing lines and +@cindex backslash (@code{\}), continuing lines and +If you would like to split a single statement into two lines at a point +where a newline would terminate it, you can @dfn{continue} it by ending the +first line with a backslash character (@samp{\}). The backslash must be +the final character on the line in order to be recognized as a continuation +character. A backslash is allowed anywhere in the statement, even +in the middle of a string or regular expression. For example: + +@example +awk '/This regular expression is too long, so continue it\ + on the next line/ @{ print $1 @}' +@end example + +@noindent +@cindex portability, backslash continuation and +We have generally not used backslash continuation in our sample programs. +@command{gawk} places no limit on the +length of a line, so backslash continuation is never strictly necessary; +it just makes programs more readable. For this same reason, as well as +for clarity, we have kept most statements short in the sample programs +presented throughout the @value{DOCUMENT}. Backslash continuation is +most useful when your @command{awk} program is in a separate source file +instead of entered from the command line. You should also note that +many @command{awk} implementations are more particular about where you +may use backslash continuation. For example, they may not allow you to +split a string constant using backslash continuation. Thus, for maximum +portability of your @command{awk} programs, it is best not to split your +lines in the middle of a regular expression or a string. +@c 10/2000: gawk, mawk, and current bell labs awk allow it, +@c solaris 2.7 nawk does not. Solaris /usr/xpg4/bin/awk does though! sigh. + +@cindex @command{csh} utility +@cindex backslash (@code{\}), continuing lines and, in @command{csh} +@cindex @code{\} (backslash), continuing lines and, in @command{csh} +@quotation CAUTION +@emph{Backslash continuation does not work as described +with the C shell.} It works for @command{awk} programs in files and +for one-shot programs, @emph{provided} you are using a POSIX-compliant +shell, such as the Unix Bourne shell or Bash. But the C shell behaves +differently! There, you must use two backslashes in a row, followed by +a newline. Note also that when using the C shell, @emph{every} newline +in your @command{awk} program must be escaped with a backslash. To illustrate: + +@example +% @kbd{awk 'BEGIN @{ \} +? @kbd{ print \\} +? @kbd{ "hello, world" \} +? @kbd{@}'} +@print{} hello, world +@end example + +@noindent +Here, the @samp{%} and @samp{?} are the C shell's primary and secondary +prompts, analogous to the standard shell's @samp{$} and @samp{>}. + +Compare the previous example to how it is done with a POSIX-compliant shell: + +@example +$ @kbd{awk 'BEGIN @{} +> @kbd{print \} +> @kbd{"hello, world"} +> @kbd{@}'} +@print{} hello, world +@end example +@end quotation + +@command{awk} is a line-oriented language. Each rule's action has to +begin on the same line as the pattern. To have the pattern and action +on separate lines, you @emph{must} use backslash continuation; there +is no other option. + +@cindex backslash (@code{\}), continuing lines and, comments and +@cindex @code{\} (backslash), continuing lines and, comments and +@cindex commenting, backslash continuation and +Another thing to keep in mind is that backslash continuation and +comments do not mix. As soon as @command{awk} sees the @samp{#} that +starts a comment, it ignores @emph{everything} on the rest of the +line. For example: + +@example +$ gawk 'BEGIN @{ print "dont panic" # a friendly \ +> BEGIN rule +> @}' +@error{} gawk: cmd. line:2: BEGIN rule +@error{} gawk: cmd. line:2: ^ parse error +@end example + +@noindent +In this case, it looks like the backslash would continue the comment onto the +next line. However, the backslash-newline combination is never even +noticed because it is ``hidden'' inside the comment. Thus, the +@code{BEGIN} is noted as a syntax error. + +@cindex statements, multiple +@cindex @code{;} (semicolon) +@cindex semicolon (@code{;}) +When @command{awk} statements within one rule are short, you might want to put +more than one of them on a line. This is accomplished by separating the statements +with a semicolon (@samp{;}). +This also applies to the rules themselves. +Thus, the program shown at the start of this @value{SECTION} +could also be written this way: + +@example +/12/ @{ print $0 @} ; /21/ @{ print $0 @} +@end example + +@quotation NOTE +The requirement that states that rules on the same line must be +separated with a semicolon was not in the original @command{awk} +language; it was added for consistency with the treatment of statements +within an action. +@end quotation + +@node Other Features +@section Other Features of @command{awk} + +@cindex variables +The @command{awk} language provides a number of predefined, or +@dfn{built-in}, variables that your programs can use to get information +from @command{awk}. There are other variables your program can set +as well to control how @command{awk} processes your data. + +In addition, @command{awk} provides a number of built-in functions for doing +common computational and string-related operations. +@command{gawk} provides built-in functions for working with timestamps, +performing bit manipulation, for runtime string translation (internationalization), +determining the type of a variable, +and array sorting. + +As we develop our presentation of the @command{awk} language, we introduce +most of the variables and many of the functions. They are described +systematically in @ref{Built-in Variables}, and +@ref{Built-in}. + +@node When +@section When to Use @command{awk} + +@cindex @command{awk}, uses for +Now that you've seen some of what @command{awk} can do, +you might wonder how @command{awk} could be useful for you. By using +utility programs, advanced patterns, field separators, arithmetic +statements, and other selection criteria, you can produce much more +complex output. The @command{awk} language is very useful for producing +reports from large amounts of raw data, such as summarizing information +from the output of other utility programs like @command{ls}. +(@xref{More Complex}.) + +Programs written with @command{awk} are usually much smaller than they would +be in other languages. This makes @command{awk} programs easy to compose and +use. Often, @command{awk} programs can be quickly composed at your keyboard, +used once, and thrown away. Because @command{awk} programs are interpreted, you +can avoid the (usually lengthy) compilation part of the typical +edit-compile-test-debug cycle of software development. + +Complex programs have been written in @command{awk}, including a complete +retargetable assembler for eight-bit microprocessors (@pxref{Glossary}, for +more information), and a microcode assembler for a special-purpose Prolog +computer. +While the original @command{awk}'s capabilities were strained by tasks +of such complexity, modern versions are more capable. Even Brian Kernighan's +version of @command{awk} has fewer predefined limits, and those +that it has are much larger than they used to be. + +@cindex @command{awk} programs, complex +If you find yourself writing @command{awk} scripts of more than, say, a few +hundred lines, you might consider using a different programming +language. Emacs Lisp is a good choice if you need sophisticated string +or pattern matching capabilities. The shell is also good at string and +pattern matching; in addition, it allows powerful use of the system +utilities. More conventional languages, such as C, C++, and Java, offer +better facilities for system programming and for managing the complexity +of large programs. Programs in these languages may require more lines +of source code than the equivalent @command{awk} programs, but they are +easier to maintain and usually run more efficiently. + +@node Invoking Gawk +@chapter Running @command{awk} and @command{gawk} + +This @value{CHAPTER} covers how to run awk, both POSIX-standard +and @command{gawk}-specific command-line options, and what +@command{awk} and +@command{gawk} do with non-option arguments. +It then proceeds to cover how @command{gawk} searches for source files, +reading standard input along with other files, @command{gawk}'s +environment variables, @command{gawk}'s exit status, using include files, +and obsolete and undocumented options and/or features. + +Many of the options and features described here are discussed in +more detail later in the @value{DOCUMENT}; feel free to skip over +things in this @value{CHAPTER} that don't interest you right now. + +@menu +* Command Line:: How to run @command{awk}. +* Options:: Command-line options and their meanings. +* Other Arguments:: Input file names and variable assignments. +* Naming Standard Input:: How to specify standard input with other + files. +* Environment Variables:: The environment variables @command{gawk} uses. +* Exit Status:: @command{gawk}'s exit status. +* Include Files:: Including other files into your program. +* Obsolete:: Obsolete Options and/or features. +* Undocumented:: Undocumented Options and Features. +@end menu + +@node Command Line +@section Invoking @command{awk} +@cindex command line, invoking @command{awk} from +@cindex @command{awk}, invoking +@cindex arguments, command-line, invoking @command{awk} +@cindex options, command-line, invoking @command{awk} + +There are two ways to run @command{awk}---with an explicit program or with +one or more program files. Here are templates for both of them; items +enclosed in [@dots{}] in these templates are optional: + +@example +awk @r{[@var{options}]} -f progfile @r{[@code{--}]} @var{file} @dots{} +awk @r{[@var{options}]} @r{[@code{--}]} '@var{program}' @var{file} @dots{} +@end example + +@cindex GNU long options +@cindex long options +@cindex options, long +Besides traditional one-letter POSIX-style options, @command{gawk} also +supports GNU long options. + +@cindex dark corner, invoking @command{awk} +@cindex lint checking, empty programs +It is possible to invoke @command{awk} with an empty program: + +@example +awk '' datafile1 datafile2 +@end example + +@cindex @code{--lint} option +@noindent +Doing so makes little sense, though; @command{awk} exits +silently when given an empty program. +@value{DARKCORNER} +If @option{--lint} has +been specified on the command line, @command{gawk} issues a +warning that the program is empty. + +@node Options +@section Command-Line Options +@c STARTOFRANGE ocl +@cindex options, command-line +@c STARTOFRANGE clo +@cindex command line, options +@c STARTOFRANGE gnulo +@cindex GNU long options +@c STARTOFRANGE longo +@cindex options, long + +Options begin with a dash and consist of a single character. +GNU-style long options consist of two dashes and a keyword. +The keyword can be abbreviated, as long as the abbreviation allows the option +to be uniquely identified. If the option takes an argument, then the +keyword is either immediately followed by an equals sign (@samp{=}) and the +argument's value, or the keyword and the argument's value are separated +by whitespace. +If a particular option with a value is given more than once, it is the +last value that counts. + +@cindex POSIX @command{awk}, GNU long options and +Each long option for @command{gawk} has a corresponding +POSIX-style short option. +The long and short options are +interchangeable in all contexts. +The following list describes options mandated by the POSIX standard: + +@table @code +@item -F @var{fs} +@itemx --field-separator @var{fs} +@cindex @code{-F} option +@cindex @code{--field-separator} option +@cindex @code{FS} variable, @code{--field-separator} option and +Set the @code{FS} variable to @var{fs} +(@pxref{Field Separators}). + +@item -f @var{source-file} +@itemx --file @var{source-file} +@cindex @code{-f} option +@cindex @code{--file} option +@cindex @command{awk} programs, location of +Read @command{awk} program source from @var{source-file} +instead of in the first non-option argument. +This option may be given multiple times; the @command{awk} +program consists of the concatenation the contents of +each specified @var{source-file}. + +@item -v @var{var}=@var{val} +@itemx --assign @var{var}=@var{val} +@cindex @code{-v} option +@cindex @code{--assign} option +@cindex variables, setting +Set the variable @var{var} to the value @var{val} @emph{before} +execution of the program begins. Such variable values are available +inside the @code{BEGIN} rule +(@pxref{Other Arguments}). + +The @option{-v} option can only set one variable, but it can be used +more than once, setting another variable each time, like this: +@samp{awk @w{-v foo=1} @w{-v bar=2} @dots{}}. + +@cindex built-in variables, @code{-v} option@comma{} setting with +@cindex variables, built-in, @code{-v} option@comma{} setting with +@quotation CAUTION +Using @option{-v} to set the values of the built-in +variables may lead to surprising results. @command{awk} will reset the +values of those variables as it needs to, possibly ignoring any +predefined value you may have given. +@end quotation + +@item -W @var{gawk-opt} +@cindex @code{-W} option +Provide an implementation-specific option. +This is the POSIX convention for providing implementation-specific options. +These options +also have corresponding GNU-style long options. +Note that the long options may be abbreviated, as long as +the abbreviations remain unique. +The full list of @command{gawk}-specific options is provided next. + +@item -- +@cindex command line, options, end of +@cindex options, command-line, end of +Signal the end of the command-line options. The following arguments +are not treated as options even if they begin with @samp{-}. This +interpretation of @option{--} follows the POSIX argument parsing +conventions. + +@cindex @code{-} (hyphen), filenames beginning with +@cindex hyphen (@code{-}), filenames beginning with +This is useful if you have @value{FN}s that start with @samp{-}, +or in shell scripts, if you have @value{FN}s that will be specified +by the user that could start with @samp{-}. +It is also useful for passing options on to the @command{awk} +program; see @ref{Getopt Function}. +@end table +@c ENDOFRANGE gnulo +@c ENDOFRANGE longo + +The following list describes @command{gawk}-specific options: + +@table @code +@item -b +@itemx --characters-as-bytes +@cindex @code{-b} option +@cindex @code{--characters-as-bytes} option +Cause @command{gawk} to treat all input data as single-byte characters. +Normally, @command{gawk} follows the POSIX standard and attempts to process +its input data according to the current locale. This can often involve +converting multibyte characters into wide characters (internally), and +can lead to problems or confusion if the input data does not contain valid +multibyte characters. This option is an easy way to tell @command{gawk}: +``hands off my data!''. + +@item -c +@itemx --traditional +@cindex @code{--c} option +@cindex @code{--traditional} option +@cindex compatibility mode (@command{gawk}), specifying +Specify @dfn{compatibility mode}, in which the GNU extensions to +the @command{awk} language are disabled, so that @command{gawk} behaves just +like Brian Kernighan's version @command{awk}. +@xref{POSIX/GNU}, +which summarizes the extensions. Also see +@ref{Compatibility Mode}. + +@item -C +@itemx --copyright +@cindex @code{-C} option +@cindex @code{--copyright} option +@cindex GPL (General Public License), printing +Print the short version of the General Public License and then exit. + +@item -d@r{[}@var{file}@r{]} +@itemx --dump-variables@r{[}=@var{file}@r{]} +@cindex @code{-d} option +@cindex @code{--dump-variables} option +@cindex @code{awkvars.out} file +@cindex files, @code{awkvars.out} +@cindex variables, global, printing list of +Print a sorted list of global variables, their types, and final values +to @var{file}. If no @var{file} is provided, print this +list to the file named @file{awkvars.out} in the current directory. +No space is allowed between the @option{-d} and @var{file}, if +@var{file} is supplied. + +@cindex troubleshooting, typographical errors@comma{} global variables +Having a list of all global variables is a good way to look for +typographical errors in your programs. +You would also use this option if you have a large program with a lot of +functions, and you want to be sure that your functions don't +inadvertently use global variables that you meant to be local. +(This is a particularly easy mistake to make with simple variable +names like @code{i}, @code{j}, etc.) + +@item -e @var{program-text} +@itemx --source @var{program-text} +@cindex @code{-e} option +@cindex @code{--source} option +@cindex source code, mixing +Provide program source code in the @var{program-text}. +This option allows you to mix source code in files with source +code that you enter on the command line. +This is particularly useful +when you have library functions that you want to use from your command-line +programs (@pxref{AWKPATH Variable}). + +@item -E @var{file} +@itemx --exec @var{file} +@cindex @code{-E} option +@cindex @code{--exec} option +@cindex @command{awk} programs, location of +@cindex CGI, @command{awk} scripts for +Similar to @option{-f}, read @command{awk} program text from @var{file}. +There are two differences from @option{-f}: + +@itemize @bullet +@item +This option terminates option processing; anything +else on the command line is passed on directly to the @command{awk} program. + +@item +Command-line variable assignments of the form +@samp{@var{var}=@var{value}} are disallowed. +@end itemize + +This option is particularly necessary for World Wide Web CGI applications +that pass arguments through the URL; using this option prevents a malicious +(or other) user from passing in options, assignments, or @command{awk} source +code (via @option{--source}) to the CGI application. This option should be used +with @samp{#!} scripts (@pxref{Executable Scripts}), like so: + +@example +#! /usr/local/bin/gawk -E + +@var{awk program here @dots{}} +@end example + +@item -g +@itemx --gen-pot +@cindex @code{-g} option +@cindex @code{--gen-pot} option +@cindex portable object files, generating +@cindex files, portable object, generating +Analyze the source program and +generate a GNU @code{gettext} Portable Object Template file on standard +output for all string constants that have been marked for translation. +@xref{Internationalization}, +for information about this option. + +@item -h +@itemx --help +@cindex @code{-h} option +@cindex @code{--help} option +@cindex GNU long options, printing list of +@cindex options, printing list of +@cindex printing, list of options +Print a ``usage'' message summarizing the short and long style options +that @command{gawk} accepts and then exit. + +@item -L @r{[}value@r{]} +@itemx --lint@r{[}=value@r{]} +@cindex @code{-l} option +@cindex @code{--lint} option +@cindex lint checking, issuing warnings +@cindex warnings, issuing +Warn about constructs that are dubious or nonportable to +other @command{awk} implementations. +Some warnings are issued when @command{gawk} first reads your program. Others +are issued at runtime, as your program executes. +With an optional argument of @samp{fatal}, +lint warnings become fatal errors. +This may be drastic, but its use will certainly encourage the +development of cleaner @command{awk} programs. +With an optional argument of @samp{invalid}, only warnings about things +that are actually invalid are issued. (This is not fully implemented yet.) + +Some warnings are only printed once, even if the dubious constructs they +warn about occur multiple times in your @command{awk} program. Thus, +when eliminating problems pointed out by @option{--lint}, you should take +care to search for all occurrences of each inappropriate construct. As +@command{awk} programs are usually short, doing so is not burdensome. + +@item -n +@itemx --non-decimal-data +@cindex @code{-n} option +@cindex @code{--non-decimal-data} option +@cindex hexadecimal values@comma{} enabling interpretation of +@cindex octal values@comma{} enabling interpretation of +@cindex troubleshooting, @code{--non-decimal-data} option +Enable automatic interpretation of octal and hexadecimal +values in input data +(@pxref{Nondecimal Data}). + +@quotation CAUTION +This option can severely break old programs. +Use with care. +@end quotation + +@item -N +@itemx --use-lc-numeric +@cindex @code{-N} option +@cindex @code{--use-lc-numeric} option +Force the use of the locale's decimal point character +when parsing numeric input data (@pxref{Locales}). + +@item -O +@itemx --optimize +@cindex @code{--optimize} option +@cindex @code{-O} option +Enable some optimizations on the internal representation of the program. +At the moment this includes just simple constant folding. The @command{gawk} +maintainer hopes to add more optimizations over time. + +@item -p@r{[}@var{file}@r{]} +@itemx --profile@r{[}=@var{file}@r{]} +@cindex @code{-p} option +@cindex @code{--profile} option +@cindex @command{awk} programs, profiling, enabling +Enable profiling of @command{awk} programs +(@pxref{Profiling}). +By default, profiles are created in a file named @file{awkprof.out}. +The optional @var{file} argument allows you to specify a different +@value{FN} for the profile file. +No space is allowed between the @option{-p} and @var{file}, if +@var{file} is supplied. + +When run with @command{gawk}, the profile is just a ``pretty printed'' version +of the program. When run with @command{pgawk}, the profile contains execution +counts for each statement in the program in the left margin, and function +call counts for each function. + +@item -P +@itemx --posix +@cindex @code{-P} option +@cindex @code{--posix} option +@cindex POSIX mode +@cindex @command{gawk}, extensions@comma{} disabling +Operate in strict POSIX mode. This disables all @command{gawk} +extensions (just like @option{--traditional}) and +disables all extensions not allowed by POSIX. +@xref{Common Extensions}, for a summary of the extensions +in @command{gawk} that are disabled by this option. +Also, +the following additional +restrictions apply: + +@itemize @bullet + +@cindex newlines +@cindex whitespace, newlines as +@item +Newlines do not act as whitespace to separate fields when @code{FS} is +equal to a single space +(@pxref{Fields}). + +@item +Newlines are not allowed after @samp{?} or @samp{:} +(@pxref{Conditional Exp}). + + +@cindex @code{FS} variable, as TAB character +@item +Specifying @samp{-Ft} on the command-line does not set the value +of @code{FS} to be a single TAB character +(@pxref{Field Separators}). + +@cindex locale decimal point character +@cindex decimal point character, locale specific +@item +The locale's decimal point character is used for parsing input +data (@pxref{Locales}). +@end itemize + +@c @cindex automatic warnings +@c @cindex warnings, automatic +@cindex @code{--traditional} option, @code{--posix} option and +@cindex @code{--posix} option, @code{--traditional} option and +If you supply both @option{--traditional} and @option{--posix} on the +command line, @option{--posix} takes precedence. @command{gawk} +also issues a warning if both options are supplied. + +@item -r +@itemx --re-interval +@cindex @code{-r} option +@cindex @code{--re-interval} option +@cindex regular expressions, interval expressions and +Allow interval expressions +(@pxref{Regexp Operators}) +in regexps. +This is now @command{gawk}'s default behavior. +Nevertheless, this option remains both for backward compatibility, +and for use in combination with the @option{--traditional} option. + +@item -R @var{file} +@itemx --command=@var{file} +@cindex @code{-R} option +@cindex @code{--command} option +@command{dgawk} only. +Read @command{dgawk} debugger options and commands from @var{file}. +@xref{Dgawk Info}, for more information. + +@item -S +@itemx --sandbox +@cindex @code{-S} option +@cindex @code{--sandbox} option +@cindex sandbox mode +Disable the @code{system()} function, +input redirections with @code{getline}, +output redirections with @code{print} and @code{printf}, +and dynamic extensions. +This is particularly useful when you want to run @command{awk} scripts +from questionable sources and need to make sure the scripts +can't access your system (other than the specified input data file). + +@item -t +@itemx --lint-old +@cindex @code{--L} option +@cindex @code{--lint-old} option +Warn about constructs that are not available in the original version of +@command{awk} from Version 7 Unix +(@pxref{V7/SVR3.1}). + +@item -V +@itemx --version +@cindex @code{-V} option +@cindex @code{--version} option +@cindex @command{gawk}, versions of, information about@comma{} printing +Print version information for this particular copy of @command{gawk}. +This allows you to determine if your copy of @command{gawk} is up to date +with respect to whatever the Free Software Foundation is currently +distributing. +It is also useful for bug reports +(@pxref{Bugs}). +@end table + +As long as program text has been supplied, +any other options are flagged as invalid with a warning message but +are otherwise ignored. + +@cindex @code{-F} option, @code{-Ft} sets @code{FS} to TAB +In compatibility mode, as a special case, if the value of @var{fs} supplied +to the @option{-F} option is @samp{t}, then @code{FS} is set to the TAB +character (@code{"\t"}). This is true only for @option{--traditional} and not +for @option{--posix} +(@pxref{Field Separators}). + +@cindex @code{-f} option, on command line +The @option{-f} option may be used more than once on the command line. +If it is, @command{awk} reads its program source from all of the named files, as +if they had been concatenated together into one big file. This is +useful for creating libraries of @command{awk} functions. These functions +can be written once and then retrieved from a standard place, instead +of having to be included into each individual program. +(As mentioned in +@ref{Definition Syntax}, +function names must be unique.) + +With standard @command{awk}, library functions can still be used, even +if the program is entered at the terminal, +by specifying @samp{-f /dev/tty}. After typing your program, +type @kbd{@value{CTL}-d} (the end-of-file character) to terminate it. +(You may also use @samp{-f -} to read program source from the standard +input but then you will not be able to also use the standard input as a +source of data.) + +Because it is clumsy using the standard @command{awk} mechanisms to mix source +file and command-line @command{awk} programs, @command{gawk} provides the +@option{--source} option. This does not require you to pre-empt the standard +input for your source code; it allows you to easily mix command-line +and library source code +(@pxref{AWKPATH Variable}). +The @option{--source} option may also be used multiple times on the command line. + +@cindex @code{--source} option +If no @option{-f} or @option{--source} option is specified, then @command{gawk} +uses the first non-option command-line argument as the text of the +program source code. + +@cindex @env{POSIXLY_CORRECT} environment variable +@cindex lint checking, @env{POSIXLY_CORRECT} environment variable +@cindex POSIX mode +If the environment variable @env{POSIXLY_CORRECT} exists, +then @command{gawk} behaves in strict POSIX mode, exactly as if +you had supplied the @option{--posix} command-line option. +Many GNU programs look for this environment variable to suppress +extensions that conflict with POSIX, but @command{gawk} behaves +differently: it suppresses all extensions, even those that do not +conflict with POSIX, and behaves in +strict POSIX mode. If @option{--lint} is supplied on the command line +and @command{gawk} turns on POSIX mode because of @env{POSIXLY_CORRECT}, +then it issues a warning message indicating that POSIX +mode is in effect. +You would typically set this variable in your shell's startup file. +For a Bourne-compatible shell (such as Bash), you would add these +lines to the @file{.profile} file in your home directory: + +@example +POSIXLY_CORRECT=true +export POSIXLY_CORRECT +@end example + +@cindex @command{csh} utility, @env{POSIXLY_CORRECT} environment variable +For a C shell-compatible +shell,@footnote{Not recommended.} +you would add this line to the @file{.login} file in your home directory: + +@example +setenv POSIXLY_CORRECT true +@end example + +@cindex portability, @env{POSIXLY_CORRECT} environment variable +Having @env{POSIXLY_CORRECT} set is not recommended for daily use, +but it is good for testing the portability of your programs to other +environments. +@c ENDOFRANGE ocl +@c ENDOFRANGE clo + +@node Other Arguments +@section Other Command-Line Arguments +@cindex command line, arguments +@cindex arguments, command-line + +Any additional arguments on the command line are normally treated as +input files to be processed in the order specified. However, an +argument that has the form @code{@var{var}=@var{value}}, assigns +the value @var{value} to the variable @var{var}---it does not specify a +file at all. +(See +@ref{Assignment Options}.) + +@cindex @command{gawk}, @code{ARGIND} variable in +@cindex @code{ARGIND} variable, command-line arguments +@cindex @code{ARGC}/@code{ARGV} variables, command-line arguments +All these arguments are made available to your @command{awk} program in the +@code{ARGV} array (@pxref{Built-in Variables}). Command-line options +and the program text (if present) are omitted from @code{ARGV}. +All other arguments, including variable assignments, are +included. As each element of @code{ARGV} is processed, @command{gawk} +sets the variable @code{ARGIND} to the index in @code{ARGV} of the +current element. + +@cindex input files, variable assignments and +The distinction between @value{FN} arguments and variable-assignment +arguments is made when @command{awk} is about to open the next input file. +At that point in execution, it checks the @value{FN} to see whether +it is really a variable assignment; if so, @command{awk} sets the variable +instead of reading a file. + +Therefore, the variables actually receive the given values after all +previously specified files have been read. In particular, the values of +variables assigned in this fashion are @emph{not} available inside a +@code{BEGIN} rule +(@pxref{BEGIN/END}), +because such rules are run before @command{awk} begins scanning the argument list. + +@cindex dark corner, escape sequences +The variable values given on the command line are processed for escape +sequences (@pxref{Escape Sequences}). +@value{DARKCORNER} + +In some earlier implementations of @command{awk}, when a variable assignment +occurred before any @value{FN}s, the assignment would happen @emph{before} +the @code{BEGIN} rule was executed. @command{awk}'s behavior was thus +inconsistent; some command-line assignments were available inside the +@code{BEGIN} rule, while others were not. Unfortunately, +some applications came to depend +upon this ``feature.'' When @command{awk} was changed to be more consistent, +the @option{-v} option was added to accommodate applications that depended +upon the old behavior. + +The variable assignment feature is most useful for assigning to variables +such as @code{RS}, @code{OFS}, and @code{ORS}, which control input and +output formats before scanning the @value{DF}s. It is also useful for +controlling state if multiple passes are needed over a @value{DF}. For +example: + +@cindex files, multiple passes over +@example +awk 'pass == 1 @{ @var{pass 1 stuff} @} + pass == 2 @{ @var{pass 2 stuff} @}' pass=1 mydata pass=2 mydata +@end example + +Given the variable assignment feature, the @option{-F} option for setting +the value of @code{FS} is not +strictly necessary. It remains for historical compatibility. + +@node Naming Standard Input +@section Naming Standard Input + +Often, you may wish to read standard input together with other files. +For example, you may wish to read one file, read standard input coming +from a pipe, and then read another file. + +The way to name the standard input, with all versions of @command{awk}, +is to use a single, standalone minus sign or dash, @samp{-}. For example: + +@example +@var{some_command} | awk -f myprog.awk file1 - file2 +@end example + +@noindent +Here, @command{awk} first reads @file{file1}, then it reads +the output of @var{some_command}, and finally it reads +@file{file2}. + +You may also use @code{"-"} to name standard input when reading +files with @code{getline} (@pxref{Getline/File}). + +In addition, @command{gawk} allows you to specify the special +@value{FN} @file{/dev/stdin}, both on the command line and +with @code{getline}. +Some other versions of @command{awk} also support this, but it +is not standard. +(Some operating systems provide a @file{/dev/stdin} file +in the file system, however, @command{gawk} always processes +this @value{FN} itself.) + +@node Environment Variables +@section The Environment Variables @command{gawk} Uses + +A number of environment variables influence how @command{gawk} +behaves. + +@menu +* AWKPATH Variable:: Searching directories for @command{awk} + programs. +* Other Environment Variables:: The environment variables. +@end menu + +@node AWKPATH Variable +@subsection The @env{AWKPATH} Environment Variable +@cindex @env{AWKPATH} environment variable +@cindex directories, searching +@cindex search paths +@cindex search paths, for source files +@cindex differences in @command{awk} and @command{gawk}, @code{AWKPATH} environment variable +@ifinfo +The previous @value{SECTION} described how @command{awk} program files can be named +on the command-line with the @option{-f} option. +@end ifinfo +In most @command{awk} +implementations, you must supply a precise path name for each program +file, unless the file is in the current directory. +But in @command{gawk}, if the @value{FN} supplied to the @option{-f} option +does not contain a @samp{/}, then @command{gawk} searches a list of +directories (called the @dfn{search path}), one by one, looking for a +file with the specified name. + +The search path is a string consisting of directory names +separated by colons. @command{gawk} gets its search path from the +@env{AWKPATH} environment variable. If that variable does not exist, +@command{gawk} uses a default path, +@samp{.:/usr/local/share/awk}.@footnote{Your version of @command{gawk} +may use a different directory; it +will depend upon how @command{gawk} was built and installed. The actual +directory is the value of @samp{$(datadir)} generated when +@command{gawk} was configured. You probably don't need to worry about this, +though.} + +The search path feature is particularly useful for building libraries +of useful @command{awk} functions. The library files can be placed in a +standard directory in the default path and then specified on +the command line with a short @value{FN}. Otherwise, the full @value{FN} +would have to be typed for each file. + +By using both the @option{--source} and @option{-f} options, your command-line +@command{awk} programs can use facilities in @command{awk} library files +(@pxref{Library Functions}). +Path searching is not done if @command{gawk} is in compatibility mode. +This is true for both @option{--traditional} and @option{--posix}. +@xref{Options}. + +@quotation NOTE +To include +the current directory in the path, either place +@file{.} explicitly in the path or write a null entry in the +path. (A null entry is indicated by starting or ending the path with a +colon or by placing two colons next to each other (@samp{::}).) +This path search mechanism is similar +to the shell's. +@c someday, @cite{The Bourne Again Shell}.... + +However, @command{gawk} always looks in the current directory @emph{before} +searching @env{AWKPATH}, so there is no real reason to include +the current directory in the search path. +@c Prior to 4.0, gawk searched the current directory after the +@c path search, but it's not worth documenting it. +@end quotation + +If @env{AWKPATH} is not defined in the +environment, @command{gawk} places its default search path into +@code{ENVIRON["AWKPATH"]}. This makes it easy to determine +the actual search path that @command{gawk} will use +from within an @command{awk} program. + +While you can change @code{ENVIRON["AWKPATH"]} within your @command{awk} +program, this has no effect on the running program's behavior. This makes +sense: the @env{AWKPATH} environment variable is used to find the program +source files. Once your program is running, all the files have been +found, and @command{gawk} no longer needs to use @env{AWKPATH}. + +@node Other Environment Variables +@subsection Other Environment Variables + +A number of other environment variables affect @command{gawk}'s +behavior, but they are more specialized. Those in the following +list are meant to be used by regular users. + +@table @env +@item POSIXLY_CORRECT +Causes @command{gawk} to switch POSIX compatibility +mode, disabling all traditional and GNU extensions. +@xref{Options}. + +@item GAWK_SOCK_RETRIES +Controls the number of time @command{gawk} will attempt to +retry a two-way TCP/IP (socket) connection before giving up. +@xref{TCP/IP Networking}. + +@item GAWK_MSEC_SLEEP +Specifies the interval between connection retries, +in milliseconds. On systems that do not support +the @code{usleep()} system call, +the value is rounded up to an integral number of seconds. +@end table + +The environment variables in the following list are meant +for use by the @command{gawk} developers for testing and tuning. +They are subject to change. The variables are: + +@table @env +@item AVG_CHAIN_MAX +The average number of items @command{gawk} will maintain on a +hash chain for managing arrays. + +@item AWK_HASH +If this variable exists with a value of @samp{gst}, @command{gawk} +will switch to using the hash function from GNU Smalltalk for +managing arrays. +This function may be marginally faster than the standard function. + +@item AWKREADFUNC +If this variable exists, @command{gawk} switches to reading source +files one line at a time, instead of reading in blocks. This exists +for debugging problems on filesystems on non-POSIX operating systems +where I/O is performed in records, not in blocks. + +@item GAWK_NO_DFA +If this variable exists, @command{gawk} does not use the DFA regexp matcher +for ``does it match'' kinds of tests. This can cause @command{gawk} +to be slower. Its purpose is to help isolate differences between the +two regexp matchers that @command{gawk} uses internally. (There aren't +supposed to be differences, but occasionally theory and practice don't +coordinate with each other.) + +@item GAWK_STACKSIZE +This specifies the amount by which @command{gawk} should grow its +internal evaluation stack, when needed. + +@item TIDYMEM +If this variable exists, @command{gawk} uses the @code{mtrace()} library +calls from GNU LIBC to help track down possible memory leaks. +@end table + +@node Exit Status +@section @command{gawk}'s Exit Status + +@cindex exit status, of @command{gawk} +If the @code{exit} statement is used with a value +(@pxref{Exit Statement}), then @command{gawk} exits with +the numeric value given to it. + +Otherwise, if there were no problems during execution, +@command{gawk} exits with the value of the C constant +@code{EXIT_SUCCESS}. This is usually zero. + +If an error occurs, @command{gawk} exits with the value of +the C constant @code{EXIT_FAILURE}. This is usually one. + +If @command{gawk} exits because of a fatal error, the exit +status is 2. On non-POSIX systems, this value may be mapped +to @code{EXIT_FAILURE}. + +@node Include Files +@section Including Other Files Into Your Program + +@c Panos Papadopoulos contributed the original +@c text for this section. + +This @value{SECTION} describes a feature that is specific to @command{gawk}. + +The @samp{@@include} keyword can be used to read external @command{awk} source +files. This gives you the ability to split large @command{awk} source files +into smaller, more manageable pieces, and also lets you reuse common @command{awk} +code from various @command{awk} scripts. In other words, you can group +together @command{awk} functions, used to carry out specific tasks, +into external files. These files can be used just like function libraries, +using the @samp{@@include} keyword in conjunction with the @code{AWKPATH} +environment variable. + +Let's see an example. +We'll start with two (trivial) @command{awk} scripts, namely +@file{test1} and @file{test2}. Here is the @file{test1} script: + +@example +BEGIN @{ + print "This is script test1." +@} +@end example + +@noindent +and here is @file{test2}: + +@example +@@include "test1" +BEGIN @{ + print "This is script test2." +@} +@end example + +Running @command{gawk} with @file{test2} +produces the following result: + +@example +$ @kbd{gawk -f test2} +@print{} This is file test1. +@print{} This is file test2. +@end example + +@code{gawk} runs the @file{test2} script which includes @file{test1} +using the @samp{@@include} +keyword. So, to include external @command{awk} source files you just +use @samp{@@include} followed by the name of the file to be included, +enclosed in double quotes. + +@quotation NOTE +Keep in mind that this is a language construct and the @value{FN} cannot +be a string variable, but rather just a literal string in double quotes. +@end quotation + +The files to be included may be nested; e.g., given a third +script, namely @file{test3}: + +@example +@@include "test2" +BEGIN @{ + print "This is script test3." +@} +@end example + +@noindent +Running @command{gawk} with the @file{test3} script produces the +following results: + +@example +$ @kbd{gawk -f test3} +@print{} This is file test1. +@print{} This is file test2. +@print{} This is file test3. +@end example + +The @value{FN} can, of course, be a pathname. For example: + +@example +@@include "../io_funcs" +@end example + +@noindent +or: + +@example +@@include "/usr/awklib/network" +@end example + +@noindent +are valid. The @code{AWKPATH} environment variable can be of great +value when using @samp{@@include}. The same rules for the use +of the @code{AWKPATH} variable in command-line file searches +(@pxref{AWKPATH Variable}) apply to +@samp{@@include} also. + +This is very helpful in constructing @command{gawk} function libraries. +If you have a large script with useful, general purpose @command{awk} +functions, you can break it down into library files and put those files +in a special directory. You can then include those ``libraries,'' using +either the full pathnames of the files, or by setting the @code{AWKPATH} +environment variable accordingly and then using @samp{@@include} with +just the file part of the full pathname. Of course you can have more +than one directory to keep library files; the more complex the working +environment is, the more directories you may need to organize the files +to be included. + +Given the ability to specify multiple @option{-f} options, the +@samp{@@include} mechanism is not strictly necessary. +However, the @samp{@@include} keyword +can help you in constructing self-contained @command{gawk} programs, +thus reducing the need for writing complex and tedious command lines. +In particular, @samp{@@include} is very useful for writing CGI scripts +to be run from web pages. + +As mentioned in @ref{AWKPATH Variable}, the current directory is always +searched first for source files, before searching in @env{AWKPATH}, +and this also applies to files named with @samp{@@include}. + +@node Obsolete +@section Obsolete Options and/or Features + +@cindex features, advanced, See advanced features +@cindex options, deprecated +@cindex features, deprecated +@cindex obsolete features +This @value{SECTION} describes features and/or command-line options from +previous releases of @command{gawk} that are either not available in the +current version or that are still supported but deprecated (meaning that +they will @emph{not} be in the next release). + +@c update this section for each release! + +@cindex @code{PROCINFO} array +The process-related special files @file{/dev/pid}, @file{/dev/ppid}, +@file{/dev/pgrpid}, and @file{/dev/user} were deprecated in @command{gawk} +3.1, but still worked. As of @value{PVERSION} 4.0, they are no longer +interpreted specially by @command{gawk}. (Use @code{PROCINFO} instead; +see @ref{Auto-set}.) + +@ignore +This @value{SECTION} +is thus essentially a place holder, +in case some option becomes obsolete in a future version of @command{gawk}. +@end ignore + +@node Undocumented +@section Undocumented Options and Features +@cindex undocumented features +@cindex features, undocumented +@cindex Skywalker, Luke +@cindex Kenobi, Obi-Wan +@cindex Jedi knights +@cindex Knights, jedi +@quotation +@i{Use the Source, Luke!}@* +Obi-Wan +@end quotation + +This @value{SECTION} intentionally left +blank. + +@ignore +@c If these came out in the Info file or TeX document, then they wouldn't +@c be undocumented, would they? + +@command{gawk} has one undocumented option: + +@table @code +@item -W nostalgia +@itemx --nostalgia +Print the message @code{"awk: bailing out near line 1"} and dump core. +This option was inspired by the common behavior of very early versions of +Unix @command{awk} and by a t--shirt. +The message is @emph{not} subject to translation in non-English locales. +@c so there! nyah, nyah. +@end table + +Early versions of @command{awk} used to not require any separator (either +a newline or @samp{;}) between the rules in @command{awk} programs. Thus, +it was common to see one-line programs like: + +@example +awk '@{ sum += $1 @} END @{ print sum @}' +@end example + +@command{gawk} actually supports this but it is purposely undocumented +because it is considered bad style. The correct way to write such a program +is either + +@example +awk '@{ sum += $1 @} ; END @{ print sum @}' +@end example + +@noindent +or + +@example +awk '@{ sum += $1 @} + END @{ print sum @}' data +@end example + +@noindent +@xref{Statements/Lines}, for a fuller +explanation. + +You can insert newlines after the @samp{;} in @code{for} loops. +This seems to have been a long-undocumented feature in Unix @command{awk}. + +Similarly, you may use @code{print} or @code{printf} statements in the +@var{init} and @var{increment} parts of a @code{for} loop. This is another +long-undocumented ``feature'' of Unix @code{awk}. + +@end ignore + +@ignore +@c Try this +@iftex +@page +@headings off +@majorheading II@ @ @ Using @command{awk} and @command{gawk} +Part II shows how to use @command{awk} and @command{gawk} for problem solving. +There is lots of code here for you to read and learn from. +It contains the following chapters: + +@itemize @bullet +@item +@ref{Library Functions}. + +@item +@ref{Sample Programs}. + +@end itemize + +@page +@evenheading @thispage@ @ @ @strong{@value{TITLE}} @| @| +@oddheading @| @| @strong{@thischapter}@ @ @ @thispage +@end iftex +@end ignore + +@node Regexp +@chapter Regular Expressions +@cindex regexp, See regular expressions +@c STARTOFRANGE regexp +@cindex regular expressions + +A @dfn{regular expression}, or @dfn{regexp}, is a way of describing a +set of strings. +Because regular expressions are such a fundamental part of @command{awk} +programming, their format and use deserve a separate @value{CHAPTER}. + +@cindex forward slash (@code{/}) +@cindex @code{/} (forward slash) +A regular expression enclosed in slashes (@samp{/}) +is an @command{awk} pattern that matches every input record whose text +belongs to that set. +The simplest regular expression is a sequence of letters, numbers, or +both. Such a regexp matches any string that contains that sequence. +Thus, the regexp @samp{foo} matches any string containing @samp{foo}. +Therefore, the pattern @code{/foo/} matches any input record containing +the three characters @samp{foo} @emph{anywhere} in the record. Other +kinds of regexps let you specify more complicated classes of strings. + +@ifnotinfo +Initially, the examples in this @value{CHAPTER} are simple. +As we explain more about how +regular expressions work, we present more complicated instances. +@end ifnotinfo + +@menu +* Regexp Usage:: How to Use Regular Expressions. +* Escape Sequences:: How to write nonprinting characters. +* Regexp Operators:: Regular Expression Operators. +* Bracket Expressions:: What can go between @samp{[...]}. +* GNU Regexp Operators:: Operators specific to GNU software. +* Case-sensitivity:: How to do case-insensitive matching. +* Leftmost Longest:: How much text matches. +* Computed Regexps:: Using Dynamic Regexps. +@end menu + +@node Regexp Usage +@section How to Use Regular Expressions + +@cindex regular expressions, as patterns +A regular expression can be used as a pattern by enclosing it in +slashes. Then the regular expression is tested against the +entire text of each record. (Normally, it only needs +to match some part of the text in order to succeed.) For example, the +following prints the second field of each record that contains the string +@samp{foo} anywhere in it: + +@example +$ @kbd{awk '/foo/ @{ print $2 @}' BBS-list} +@print{} 555-1234 +@print{} 555-6699 +@print{} 555-6480 +@print{} 555-2127 +@end example + +@cindex regular expressions, operators +@cindex operators, string-matching +@c @cindex operators, @code{~} +@cindex string-matching operators +@cindex @code{~} (tilde), @code{~} operator +@cindex tilde (@code{~}), @code{~} operator +@cindex @code{!} (exclamation point), @code{!~} operator +@cindex exclamation point (@code{!}), @code{!~} operator +@c @cindex operators, @code{!~} +@cindex @code{if} statement +@cindex @code{while} statement +@cindex @code{do}-@code{while} statement +@c @cindex statements, @code{if} +@c @cindex statements, @code{while} +@c @cindex statements, @code{do} +Regular expressions can also be used in matching expressions. These +expressions allow you to specify the string to match against; it need +not be the entire current input record. The two operators @samp{~} +and @samp{!~} perform regular expression comparisons. Expressions +using these operators can be used as patterns, or in @code{if}, +@code{while}, @code{for}, and @code{do} statements. +(@xref{Statements}.) +For example: + +@example +@var{exp} ~ /@var{regexp}/ +@end example + +@noindent +is true if the expression @var{exp} (taken as a string) +matches @var{regexp}. The following example matches, or selects, +all input records with the uppercase letter @samp{J} somewhere in the +first field: + +@example +$ @kbd{awk '$1 ~ /J/' inventory-shipped} +@print{} Jan 13 25 15 115 +@print{} Jun 31 42 75 492 +@print{} Jul 24 34 67 436 +@print{} Jan 21 36 64 620 +@end example + +So does this: + +@example +awk '@{ if ($1 ~ /J/) print @}' inventory-shipped +@end example + +This next example is true if the expression @var{exp} +(taken as a character string) +does @emph{not} match @var{regexp}: + +@example +@var{exp} !~ /@var{regexp}/ +@end example + +The following example matches, +or selects, all input records whose first field @emph{does not} contain +the uppercase letter @samp{J}: + +@example +$ @kbd{awk '$1 !~ /J/' inventory-shipped} +@print{} Feb 15 32 24 226 +@print{} Mar 15 24 34 228 +@print{} Apr 31 52 63 420 +@print{} May 16 34 29 208 +@dots{} +@end example + +@cindex regexp constants +@cindex regular expressions, constants, See regexp constants +When a regexp is enclosed in slashes, such as @code{/foo/}, we call it +a @dfn{regexp constant}, much like @code{5.27} is a numeric constant and +@code{"foo"} is a string constant. + +@node Escape Sequences +@section Escape Sequences + +@cindex escape sequences +@cindex backslash (@code{\}), in escape sequences +@cindex @code{\} (backslash), in escape sequences +Some characters cannot be included literally in string constants +(@code{"foo"}) or regexp constants (@code{/foo/}). +Instead, they should be represented with @dfn{escape sequences}, +which are character sequences beginning with a backslash (@samp{\}). +One use of an escape sequence is to include a double-quote character in +a string constant. Because a plain double quote ends the string, you +must use @samp{\"} to represent an actual double-quote character as a +part of the string. For example: + +@example +$ @kbd{awk 'BEGIN @{ print "He said \"hi!\" to her." @}'} +@print{} He said "hi!" to her. +@end example + +The backslash character itself is another character that cannot be +included normally; you must write @samp{\\} to put one backslash in the +string or regexp. Thus, the string whose contents are the two characters +@samp{"} and @samp{\} must be written @code{"\"\\"}. + +Other escape sequences represent unprintable characters +such as TAB or newline. While there is nothing to stop you from entering most +unprintable characters directly in a string constant or regexp constant, +they may look ugly. + +The following table lists +all the escape sequences used in @command{awk} and +what they represent. Unless noted otherwise, all these escape +sequences apply to both string constants and regexp constants: + +@table @code +@item \\ +A literal backslash, @samp{\}. + +@c @cindex @command{awk} language, V.4 version +@cindex @code{\} (backslash), @code{\a} escape sequence +@cindex backslash (@code{\}), @code{\a} escape sequence +@item \a +The ``alert'' character, @kbd{@value{CTL}-g}, ASCII code 7 (BEL). +(This usually makes some sort of audible noise.) + +@cindex @code{\} (backslash), @code{\b} escape sequence +@cindex backslash (@code{\}), @code{\b} escape sequence +@item \b +Backspace, @kbd{@value{CTL}-h}, ASCII code 8 (BS). + +@cindex @code{\} (backslash), @code{\f} escape sequence +@cindex backslash (@code{\}), @code{\f} escape sequence +@item \f +Formfeed, @kbd{@value{CTL}-l}, ASCII code 12 (FF). + +@cindex @code{\} (backslash), @code{\n} escape sequence +@cindex backslash (@code{\}), @code{\n} escape sequence +@item \n +Newline, @kbd{@value{CTL}-j}, ASCII code 10 (LF). + +@cindex @code{\} (backslash), @code{\r} escape sequence +@cindex backslash (@code{\}), @code{\r} escape sequence +@item \r +Carriage return, @kbd{@value{CTL}-m}, ASCII code 13 (CR). + +@cindex @code{\} (backslash), @code{\t} escape sequence +@cindex backslash (@code{\}), @code{\t} escape sequence +@item \t +Horizontal TAB, @kbd{@value{CTL}-i}, ASCII code 9 (HT). + +@c @cindex @command{awk} language, V.4 version +@cindex @code{\} (backslash), @code{\v} escape sequence +@cindex backslash (@code{\}), @code{\v} escape sequence +@item \v +Vertical tab, @kbd{@value{CTL}-k}, ASCII code 11 (VT). + +@cindex @code{\} (backslash), @code{\}@var{nnn} escape sequence +@cindex backslash (@code{\}), @code{\}@var{nnn} escape sequence +@item \@var{nnn} +The octal value @var{nnn}, where @var{nnn} stands for 1 to 3 digits +between @samp{0} and @samp{7}. For example, the code for the ASCII ESC +(escape) character is @samp{\033}. + +@c @cindex @command{awk} language, V.4 version +@c @cindex @command{awk} language, POSIX version +@cindex @code{\} (backslash), @code{\x} escape sequence +@cindex backslash (@code{\}), @code{\x} escape sequence +@cindex common extensions, @code{\x} escape sequence +@cindex extensions, common@comma{} @code{\x} escape sequence +@item \x@var{hh}@dots{} +The hexadecimal value @var{hh}, where @var{hh} stands for a sequence +of hexadecimal digits (@samp{0}--@samp{9}, and either @samp{A}--@samp{F} +or @samp{a}--@samp{f}). Like the same construct +in ISO C, the escape sequence continues until the first nonhexadecimal +digit is seen. @value{COMMONEXT} +However, using more than two hexadecimal digits produces +undefined results. (The @samp{\x} escape sequence is not allowed in +POSIX @command{awk}.) + +@cindex @code{\} (backslash), @code{\/} escape sequence +@cindex backslash (@code{\}), @code{\/} escape sequence +@item \/ +A literal slash (necessary for regexp constants only). +This sequence is used when you want to write a regexp +constant that contains a slash. Because the regexp is delimited by +slashes, you need to escape the slash that is part of the pattern, +in order to tell @command{awk} to keep processing the rest of the regexp. + +@cindex @code{\} (backslash), @code{\"} escape sequence +@cindex backslash (@code{\}), @code{\"} escape sequence +@item \" +A literal double quote (necessary for string constants only). +This sequence is used when you want to write a string +constant that contains a double quote. Because the string is delimited by +double quotes, you need to escape the quote that is part of the string, +in order to tell @command{awk} to keep processing the rest of the string. +@end table + +In @command{gawk}, a number of additional two-character sequences that begin +with a backslash have special meaning in regexps. +@xref{GNU Regexp Operators}. + +In a regexp, a backslash before any character that is not in the previous list +and not listed in +@ref{GNU Regexp Operators}, +means that the next character should be taken literally, even if it would +normally be a regexp operator. For example, @code{/a\+b/} matches the three +characters @samp{a+b}. + +@cindex backslash (@code{\}), in escape sequences +@cindex @code{\} (backslash), in escape sequences +@cindex portability +For complete portability, do not use a backslash before any character not +shown in the previous list. + +To summarize: + +@itemize @bullet +@item +The escape sequences in the table above are always processed first, +for both string constants and regexp constants. This happens very early, +as soon as @command{awk} reads your program. + +@item +@command{gawk} processes both regexp constants and dynamic regexps +(@pxref{Computed Regexps}), +for the special operators listed in +@ref{GNU Regexp Operators}. + +@item +A backslash before any other character means to treat that character +literally. +@end itemize + +@c fakenode --- for prepinfo +@subheading Advanced Notes: Backslash Before Regular Characters +@cindex portability, backslash in escape sequences +@cindex POSIX @command{awk}, backslashes in string constants +@cindex backslash (@code{\}), in escape sequences, POSIX and +@cindex @code{\} (backslash), in escape sequences, POSIX and + +@cindex troubleshooting, backslash before nonspecial character +If you place a backslash in a string constant before something that is +not one of the characters previously listed, POSIX @command{awk} purposely +leaves what happens as undefined. There are two choices: + +@c @cindex automatic warnings +@c @cindex warnings, automatic +@table @asis +@item Strip the backslash out +This is what Brian Kernighan's @command{awk} and @command{gawk} both do. +For example, @code{"a\qc"} is the same as @code{"aqc"}. +(Because this is such an easy bug both to introduce and to miss, +@command{gawk} warns you about it.) +Consider @samp{FS = @w{"[ \t]+\|[ \t]+"}} to use vertical bars +surrounded by whitespace as the field separator. There should be +two backslashes in the string: @samp{FS = @w{"[ \t]+\\|[ \t]+"}}.) +@c I did this! This is why I added the warning. + +@cindex @command{gawk}, escape sequences +@cindex Unix @command{awk}, backslashes in escape sequences +@item Leave the backslash alone +Some other @command{awk} implementations do this. +In such implementations, typing @code{"a\qc"} is the same as typing +@code{"a\\qc"}. +@end table + +@c fakenode --- for prepinfo +@subheading Advanced Notes: Escape Sequences for Metacharacters +@cindex metacharacters, escape sequences for + +Suppose you use an octal or hexadecimal +escape to represent a regexp metacharacter. +(See @ref{Regexp Operators}.) +Does @command{awk} treat the character as a literal character or as a regexp +operator? + +@cindex dark corner, escape sequences, for metacharacters +Historically, such characters were taken literally. +@value{DARKCORNER} +However, the POSIX standard indicates that they should be treated +as real metacharacters, which is what @command{gawk} does. +In compatibility mode (@pxref{Options}), +@command{gawk} treats the characters represented by octal and hexadecimal +escape sequences literally when used in regexp constants. Thus, +@code{/a\52b/} is equivalent to @code{/a\*b/}. + +@node Regexp Operators +@section Regular Expression Operators +@c STARTOFRANGE regexpo +@cindex regular expressions, operators + +You can combine regular expressions with special characters, +called @dfn{regular expression operators} or @dfn{metacharacters}, to +increase the power and versatility of regular expressions. + +The escape sequences described +@ifnotinfo +earlier +@end ifnotinfo +in @ref{Escape Sequences}, +are valid inside a regexp. They are introduced by a @samp{\} and +are recognized and converted into corresponding real characters as +the very first step in processing regexps. + +Here is a list of metacharacters. All characters that are not escape +sequences and that are not listed in the table stand for themselves: + +@table @code +@cindex backslash (@code{\}) +@cindex @code{\} (backslash) +@item \ +This is used to suppress the special meaning of a character when +matching. For example, @samp{\$} +matches the character @samp{$}. + +@cindex regular expressions, anchors in +@cindex Texinfo, chapter beginnings in files +@cindex @code{^} (caret) +@cindex caret (@code{^}) +@item ^ +This matches the beginning of a string. For example, @samp{^@@chapter} +matches @samp{@@chapter} at the beginning of a string and can be used +to identify chapter beginnings in Texinfo source files. +The @samp{^} is known as an @dfn{anchor}, because it anchors the pattern to +match only at the beginning of the string. + +It is important to realize that @samp{^} does not match the beginning of +a line embedded in a string. +The condition is not true in the following example: + +@example +if ("line1\nLINE 2" ~ /^L/) @dots{} +@end example + +@cindex @code{$} (dollar sign) +@cindex dollar sign (@code{$}) +@item $ +This is similar to @samp{^}, but it matches only at the end of a string. +For example, @samp{p$} +matches a record that ends with a @samp{p}. The @samp{$} is an anchor +and does not match the end of a line embedded in a string. +The condition in the following example is not true: + +@example +if ("line1\nLINE 2" ~ /1$/) @dots{} +@end example + +@cindex @code{.} (period) +@cindex period (@code{.}) +@item . @r{(period)} +This matches any single character, +@emph{including} the newline character. For example, @samp{.P} +matches any single character followed by a @samp{P} in a string. Using +concatenation, we can make a regular expression such as @samp{U.A}, which +matches any three-character sequence that begins with @samp{U} and ends +with @samp{A}. + +@cindex POSIX @command{awk}, period (@code{.})@comma{} using +In strict POSIX mode (@pxref{Options}), +@samp{.} does not match the @sc{nul} +character, which is a character with all bits equal to zero. +Otherwise, @sc{nul} is just another character. Other versions of @command{awk} +may not be able to match the @sc{nul} character. + +@cindex @code{[]} (square brackets) +@cindex square brackets (@code{[]}) +@cindex bracket expressions +@cindex character sets, See Also bracket expressions +@cindex character lists, See bracket expressions +@item [@dots{}] +This is called a @dfn{bracket expression}.@footnote{In other literature, +you may see a bracket expression referred to as either a +@dfn{character set}, a @dfn{character class}, or a @dfn{character list}.} +It matches any @emph{one} of the characters that are enclosed in +the square brackets. For example, @samp{[MVX]} matches any one of +the characters @samp{M}, @samp{V}, or @samp{X} in a string. A full +discussion of what can be inside the square brackets of a bracket expression +is given in +@ref{Bracket Expressions}. + +@cindex bracket expressions, complemented +@item [^ @dots{}] +This is a @dfn{complemented bracket expression}. The first character after +the @samp{[} @emph{must} be a @samp{^}. It matches any characters +@emph{except} those in the square brackets. For example, @samp{[^awk]} +matches any character that is not an @samp{a}, @samp{w}, +or @samp{k}. + +@cindex @code{|} (vertical bar) +@cindex vertical bar (@code{|}) +@item | +This is the @dfn{alternation operator} and it is used to specify +alternatives. +The @samp{|} has the lowest precedence of all the regular +expression operators. +For example, @samp{^P|[[:digit:]]} +matches any string that matches either @samp{^P} or @samp{[[:digit:]]}. This +means it matches any string that starts with @samp{P} or contains a digit. + +The alternation applies to the largest possible regexps on either side. + +@cindex @code{()} (parentheses) +@cindex parentheses @code{()} +@item (@dots{}) +Parentheses are used for grouping in regular expressions, as in +arithmetic. They can be used to concatenate regular expressions +containing the alternation operator, @samp{|}. For example, +@samp{@@(samp|code)\@{[^@}]+\@}} matches both @samp{@@code@{foo@}} and +@samp{@@samp@{bar@}}. +(These are Texinfo formatting control sequences. The @samp{+} is +explained further on in this list.) + +@cindex @code{*} (asterisk), @code{*} operator, as regexp operator +@cindex asterisk (@code{*}), @code{*} operator, as regexp operator +@item * +This symbol means that the preceding regular expression should be +repeated as many times as necessary to find a match. For example, @samp{ph*} +applies the @samp{*} symbol to the preceding @samp{h} and looks for matches +of one @samp{p} followed by any number of @samp{h}s. This also matches +just @samp{p} if no @samp{h}s are present. + +The @samp{*} repeats the @emph{smallest} possible preceding expression. +(Use parentheses if you want to repeat a larger expression.) It finds +as many repetitions as possible. For example, +@samp{awk '/\(c[ad][ad]*r x\)/ @{ print @}' sample} +prints every record in @file{sample} containing a string of the form +@samp{(car x)}, @samp{(cdr x)}, @samp{(cadr x)}, and so on. +Notice the escaping of the parentheses by preceding them +with backslashes. + +@cindex @code{+} (plus sign) +@cindex plus sign (@code{+}) +@item + +This symbol is similar to @samp{*}, except that the preceding expression must be +matched at least once. This means that @samp{wh+y} +would match @samp{why} and @samp{whhy}, but not @samp{wy}, whereas +@samp{wh*y} would match all three of these strings. +The following is a simpler +way of writing the last @samp{*} example: + +@example +awk '/\(c[ad]+r x\)/ @{ print @}' sample +@end example + +@cindex @code{?} (question mark) regexp operator +@cindex question mark (@code{?}) regexp operator +@item ? +This symbol is similar to @samp{*}, except that the preceding expression can be +matched either once or not at all. For example, @samp{fe?d} +matches @samp{fed} and @samp{fd}, but nothing else. + +@cindex interval expressions +@item @{@var{n}@} +@itemx @{@var{n},@} +@itemx @{@var{n},@var{m}@} +One or two numbers inside braces denote an @dfn{interval expression}. +If there is one number in the braces, the preceding regexp is repeated +@var{n} times. +If there are two numbers separated by a comma, the preceding regexp is +repeated @var{n} to @var{m} times. +If there is one number followed by a comma, then the preceding regexp +is repeated at least @var{n} times: + +@table @code +@item wh@{3@}y +Matches @samp{whhhy}, but not @samp{why} or @samp{whhhhy}. + +@item wh@{3,5@}y +Matches @samp{whhhy}, @samp{whhhhy}, or @samp{whhhhhy}, only. + +@item wh@{2,@}y +Matches @samp{whhy} or @samp{whhhy}, and so on. +@end table + +@cindex POSIX @command{awk}, interval expressions in +Interval expressions were not traditionally available in @command{awk}. +They were added as part of the POSIX standard to make @command{awk} +and @command{egrep} consistent with each other. + +@cindex @command{gawk}, interval expressions and +Initially, because old programs may use @samp{@{} and @samp{@}} in regexp +constants, +@command{gawk} did @emph{not} match interval expressions +in regexps. + +However, beginning with @value{PVERSION} 4.0, +@command{gawk} does match interval expressions by default. +This is because compatibility with POSIX has become more +important to most @command{gawk} users than compatibility with +old programs. + +For programs that use @samp{@{} and @samp{@}} in regexp constants, +it is good practice to always escape them with a backslash. Then the +regexp constants are valid and work the way you want them to, using +any version of @command{awk}.@footnote{Use two backslashes if you're +using a string constant with a regexp operator or function.} + +Finally, when @samp{@{} and @samp{@}} appear in regexp constants +in a way that cannot be interpreted as an interval expression +(such as @code{/q@{a@}/}), then they stand for themselves. +@end table + +@cindex precedence, regexp operators +@cindex regular expressions, operators, precedence of +In regular expressions, the @samp{*}, @samp{+}, and @samp{?} operators, +as well as the braces @samp{@{} and @samp{@}}, +have +the highest precedence, followed by concatenation, and finally by @samp{|}. +As in arithmetic, parentheses can change how operators are grouped. + +@cindex POSIX @command{awk}, regular expressions and +@cindex @command{gawk}, regular expressions, precedence +In POSIX @command{awk} and @command{gawk}, the @samp{*}, @samp{+}, and +@samp{?} operators stand for themselves when there is nothing in the +regexp that precedes them. For example, @code{/+/} matches a literal +plus sign. However, many other versions of @command{awk} treat such a +usage as a syntax error. + +If @command{gawk} is in compatibility mode (@pxref{Options}), interval +expressions are not available in regular expressions. +@c ENDOFRANGE regexpo + +@node Bracket Expressions +@section Using Bracket Expressions +@c STARTOFRANGE charlist +@cindex bracket expressions +@cindex bracket expressions, range expressions +@cindex range expressions (regexps) + +As mentioned earlier, a bracket expression matches any character amongst +those listed between the opening and closing square brackets. + +Within a bracket expression, a @dfn{range expression} consists of two +characters separated by a hyphen. It matches any single character that +sorts between the two characters, based upon the system's native character +set. For example, @samp{[0-9]} is equivalent to @samp{[0123456789]}. +(See @ref{Ranges and Locales}, for an explanation of how the POSIX +standard and @command{gawk} have changed over time. This is mainly +of historical interest.) + +@cindex @code{\} (backslash), in bracket expressions +@cindex backslash (@code{\}), in bracket expressions +@cindex @code{^} (caret), in bracket expressions +@cindex caret (@code{^}), in bracket expressions +@cindex @code{-} (hyphen), in bracket expressions +@cindex hyphen (@code{-}), in bracket expressions +To include one of the characters @samp{\}, @samp{]}, @samp{-}, or @samp{^} in a +bracket expression, put a @samp{\} in front of it. For example: + +@example +[d\]] +@end example + +@noindent +matches either @samp{d} or @samp{]}. + +@cindex POSIX @command{awk}, bracket expressions and +@cindex Extended Regular Expressions (EREs) +@cindex EREs (Extended Regular Expressions) +@cindex @command{egrep} utility +This treatment of @samp{\} in bracket expressions +is compatible with other @command{awk} +implementations and is also mandated by POSIX. +The regular expressions in @command{awk} are a superset +of the POSIX specification for Extended Regular Expressions (EREs). +POSIX EREs are based on the regular expressions accepted by the +traditional @command{egrep} utility. + +@cindex bracket expressions, character classes +@cindex POSIX @command{awk}, bracket expressions and, character classes +@dfn{Character classes} are a feature introduced in the POSIX standard. +A character class is a special notation for describing +lists of characters that have a specific attribute, but the +actual characters can vary from country to country and/or +from character set to character set. For example, the notion of what +is an alphabetic character differs between the United States and France. + +A character class is only valid in a regexp @emph{inside} the +brackets of a bracket expression. Character classes consist of @samp{[:}, +a keyword denoting the class, and @samp{:]}. +@ref{table-char-classes} lists the character classes defined by the +POSIX standard. + +@float Table,table-char-classes +@caption{POSIX Character Classes} +@multitable @columnfractions .15 .85 +@headitem Class @tab Meaning +@item @code{[:alnum:]} @tab Alphanumeric characters. +@item @code{[:alpha:]} @tab Alphabetic characters. +@item @code{[:blank:]} @tab Space and TAB characters. +@item @code{[:cntrl:]} @tab Control characters. +@item @code{[:digit:]} @tab Numeric characters. +@item @code{[:graph:]} @tab Characters that are both printable and visible. +(A space is printable but not visible, whereas an @samp{a} is both.) +@item @code{[:lower:]} @tab Lowercase alphabetic characters. +@item @code{[:print:]} @tab Printable characters (characters that are not control characters). +@item @code{[:punct:]} @tab Punctuation characters (characters that are not letters, digits, +control characters, or space characters). +@item @code{[:space:]} @tab Space characters (such as space, TAB, and formfeed, to name a few). +@item @code{[:upper:]} @tab Uppercase alphabetic characters. +@item @code{[:xdigit:]} @tab Characters that are hexadecimal digits. +@end multitable +@end float + +For example, before the POSIX standard, you had to write @code{/[A-Za-z0-9]/} +to match alphanumeric characters. If your +character set had other alphabetic characters in it, this would not +match them. +With the POSIX character classes, you can write +@code{/[[:alnum:]]/} to match the alphabetic +and numeric characters in your character set. + +@cindex bracket expressions, collating elements +@cindex bracket expressions, non-ASCII +@cindex collating elements +Two additional special sequences can appear in bracket expressions. +These apply to non-ASCII character sets, which can have single symbols +(called @dfn{collating elements}) that are represented with more than one +character. They can also have several characters that are equivalent for +@dfn{collating}, or sorting, purposes. (For example, in French, a plain ``e'' +and a grave-accented ``@`e'' are equivalent.) +These sequences are: + +@table @asis +@cindex bracket expressions, collating symbols +@cindex collating symbols +@item Collating symbols +Multicharacter collating elements enclosed between +@samp{[.} and @samp{.]}. For example, if @samp{ch} is a collating element, +then @code{[[.ch.]]} is a regexp that matches this collating element, whereas +@code{[ch]} is a regexp that matches either @samp{c} or @samp{h}. + +@cindex bracket expressions, equivalence classes +@item Equivalence classes +Locale-specific names for a list of +characters that are equal. The name is enclosed between +@samp{[=} and @samp{=]}. +For example, the name @samp{e} might be used to represent all of +``e,'' ``@`e,'' and ``@'e.'' In this case, @code{[[=e=]]} is a regexp +that matches any of @samp{e}, @samp{@'e}, or @samp{@`e}. +@end table + +These features are very valuable in non-English-speaking locales. + +@cindex internationalization, localization, character classes +@cindex @command{gawk}, character classes and +@cindex POSIX @command{awk}, bracket expressions and, character classes +@quotation CAUTION +The library functions that @command{gawk} uses for regular +expression matching currently recognize only POSIX character classes; +they do not recognize collating symbols or equivalence classes. +@end quotation +@c maybe one day ... +@c ENDOFRANGE charlist + +@node GNU Regexp Operators +@section @command{gawk}-Specific Regexp Operators + +@c This section adapted (long ago) from the regex-0.12 manual + +@c STARTOFRANGE regexpg +@cindex regular expressions, operators, @command{gawk} +@c STARTOFRANGE gregexp +@cindex @command{gawk}, regular expressions, operators +@cindex operators, GNU-specific +@cindex regular expressions, operators, for words +@cindex word, regexp definition of +GNU software that deals with regular expressions provides a number of +additional regexp operators. These operators are described in this +@value{SECTION} and are specific to @command{gawk}; +they are not available in other @command{awk} implementations. +Most of the additional operators deal with word matching. +For our purposes, a @dfn{word} is a sequence of one or more letters, digits, +or underscores (@samp{_}): + +@table @code +@c @cindex operators, @code{\s} (@command{gawk}) +@cindex backslash (@code{\}), @code{\s} operator (@command{gawk}) +@cindex @code{\} (backslash), @code{\s} operator (@command{gawk}) +@item \s +Matches any whitespace character. +Think of it as shorthand for +@w{@code{[[:space:]]}}. + +@c @cindex operators, @code{\S} (@command{gawk}) +@cindex backslash (@code{\}), @code{\S} operator (@command{gawk}) +@cindex @code{\} (backslash), @code{\S} operator (@command{gawk}) +@item \S +Matches any character that is not whitespace. +Think of it as shorthand for +@w{@code{[^[:space:]]}}. + +@c @cindex operators, @code{\w} (@command{gawk}) +@cindex backslash (@code{\}), @code{\w} operator (@command{gawk}) +@cindex @code{\} (backslash), @code{\w} operator (@command{gawk}) +@item \w +Matches any word-constituent character---that is, it matches any +letter, digit, or underscore. Think of it as shorthand for +@w{@code{[[:alnum:]_]}}. + +@c @cindex operators, @code{\W} (@command{gawk}) +@cindex backslash (@code{\}), @code{\W} operator (@command{gawk}) +@cindex @code{\} (backslash), @code{\W} operator (@command{gawk}) +@item \W +Matches any character that is not word-constituent. +Think of it as shorthand for +@w{@code{[^[:alnum:]_]}}. + +@c @cindex operators, @code{\<} (@command{gawk}) +@cindex backslash (@code{\}), @code{\<} operator (@command{gawk}) +@cindex @code{\} (backslash), @code{\<} operator (@command{gawk}) +@item \< +Matches the empty string at the beginning of a word. +For example, @code{/\} (@command{gawk}) +@cindex backslash (@code{\}), @code{\>} operator (@command{gawk}) +@cindex @code{\} (backslash), @code{\>} operator (@command{gawk}) +@item \> +Matches the empty string at the end of a word. +For example, @code{/stow\>/} matches @samp{stow} but not @samp{stowaway}. + +@c @cindex operators, @code{\y} (@command{gawk}) +@cindex backslash (@code{\}), @code{\y} operator (@command{gawk}) +@cindex @code{\} (backslash), @code{\y} operator (@command{gawk}) +@cindex word boundaries@comma{} matching +@item \y +Matches the empty string at either the beginning or the +end of a word (i.e., the word boundar@strong{y}). For example, @samp{\yballs?\y} +matches either @samp{ball} or @samp{balls}, as a separate word. + +@c @cindex operators, @code{\B} (@command{gawk}) +@cindex backslash (@code{\}), @code{\B} operator (@command{gawk}) +@cindex @code{\} (backslash), @code{\B} operator (@command{gawk}) +@item \B +Matches the empty string that occurs between two +word-constituent characters. For example, +@code{/\Brat\B/} matches @samp{crate} but it does not match @samp{dirty rat}. +@samp{\B} is essentially the opposite of @samp{\y}. +@end table + +@cindex buffers, operators for +@cindex regular expressions, operators, for buffers +@cindex operators, string-matching, for buffers +There are two other operators that work on buffers. In Emacs, a +@dfn{buffer} is, naturally, an Emacs buffer. For other programs, +@command{gawk}'s regexp library routines consider the entire +string to match as the buffer. +The operators are: + +@table @code +@item \` +@c @cindex operators, @code{\`} (@command{gawk}) +@cindex backslash (@code{\}), @code{\`} operator (@command{gawk}) +@cindex @code{\} (backslash), @code{\`} operator (@command{gawk}) +Matches the empty string at the +beginning of a buffer (string). + +@c @cindex operators, @code{\'} (@command{gawk}) +@cindex backslash (@code{\}), @code{\'} operator (@command{gawk}) +@cindex @code{\} (backslash), @code{\'} operator (@command{gawk}) +@item \' +Matches the empty string at the +end of a buffer (string). +@end table + +@cindex @code{^} (caret) +@cindex caret (@code{^}) +@cindex @code{?} (question mark) regexp operator +@cindex question mark (@code{?}) regexp operator +Because @samp{^} and @samp{$} always work in terms of the beginning +and end of strings, these operators don't add any new capabilities +for @command{awk}. They are provided for compatibility with other +GNU software. + +@cindex @command{gawk}, word-boundary operator +@cindex word-boundary operator (@command{gawk}) +@cindex operators, word-boundary (@command{gawk}) +In other GNU software, the word-boundary operator is @samp{\b}. However, +that conflicts with the @command{awk} language's definition of @samp{\b} +as backspace, so @command{gawk} uses a different letter. +An alternative method would have been to require two backslashes in the +GNU operators, but this was deemed too confusing. The current +method of using @samp{\y} for the GNU @samp{\b} appears to be the +lesser of two evils. + +@c NOTE!!! Keep this in sync with the same table in the summary appendix! +@c +@c Should really do this with file inclusion. +@cindex regular expressions, @command{gawk}, command-line options +@cindex @command{gawk}, command-line options +The various command-line options +(@pxref{Options}) +control how @command{gawk} interprets characters in regexps: + +@table @asis +@item No options +In the default case, @command{gawk} provides all the facilities of +POSIX regexps and the +@ifnotinfo +previously described +GNU regexp operators. +@end ifnotinfo +@ifnottex +GNU regexp operators described +in @ref{Regexp Operators}. +@end ifnottex + +@item @code{--posix} +Only POSIX regexps are supported; the GNU operators are not special +(e.g., @samp{\w} matches a literal @samp{w}). Interval expressions +are allowed. + +@item @code{--traditional} +Traditional Unix @command{awk} regexps are matched. The GNU operators +are not special, and interval expressions are not available. +The POSIX character classes (@code{[[:alnum:]]}, etc.) are supported, +as Brian Kernighan's @command{awk} does support them. +Characters described by octal and hexadecimal escape sequences are +treated literally, even if they represent regexp metacharacters. + +@item @code{--re-interval} +Allow interval expressions in regexps, if @option{--traditional} +has been provided. +Otherwise, interval expressions are available by default. +@end table +@c ENDOFRANGE gregexp +@c ENDOFRANGE regexpg + +@node Case-sensitivity +@section Case Sensitivity in Matching + +@c STARTOFRANGE regexpcs +@cindex regular expressions, case sensitivity +@c STARTOFRANGE csregexp +@cindex case sensitivity, regexps and +Case is normally significant in regular expressions, both when matching +ordinary characters (i.e., not metacharacters) and inside bracket +expressions. Thus, a @samp{w} in a regular expression matches only a lowercase +@samp{w} and not an uppercase @samp{W}. + +The simplest way to do a case-independent match is to use a bracket +expression---for example, @samp{[Ww]}. However, this can be cumbersome if +you need to use it often, and it can make the regular expressions harder +to read. There are two alternatives that you might prefer. + +One way to perform a case-insensitive match at a particular point in the +program is to convert the data to a single case, using the +@code{tolower()} or @code{toupper()} built-in string functions (which we +haven't discussed yet; +@pxref{String Functions}). +For example: + +@example +tolower($1) ~ /foo/ @{ @dots{} @} +@end example + +@noindent +converts the first field to lowercase before matching against it. +This works in any POSIX-compliant @command{awk}. + +@cindex @command{gawk}, regular expressions, case sensitivity +@cindex case sensitivity, @command{gawk} +@cindex differences in @command{awk} and @command{gawk}, regular expressions +@cindex @code{~} (tilde), @code{~} operator +@cindex tilde (@code{~}), @code{~} operator +@cindex @code{!} (exclamation point), @code{!~} operator +@cindex exclamation point (@code{!}), @code{!~} operator +@cindex @code{IGNORECASE} variable +@cindex @command{gawk}, @code{IGNORECASE} variable in +@c @cindex variables, @code{IGNORECASE} +Another method, specific to @command{gawk}, is to set the variable +@code{IGNORECASE} to a nonzero value (@pxref{Built-in Variables}). +When @code{IGNORECASE} is not zero, @emph{all} regexp and string +operations ignore case. Changing the value of +@code{IGNORECASE} dynamically controls the case-sensitivity of the +program as it runs. Case is significant by default because +@code{IGNORECASE} (like most variables) is initialized to zero: + +@example +x = "aB" +if (x ~ /ab/) @dots{} # this test will fail + +IGNORECASE = 1 +if (x ~ /ab/) @dots{} # now it will succeed +@end example + +In general, you cannot use @code{IGNORECASE} to make certain rules +case-insensitive and other rules case-sensitive, because there is no +straightforward way +to set @code{IGNORECASE} just for the pattern of +a particular rule.@footnote{Experienced C and C++ programmers will note +that it is possible, using something like +@samp{IGNORECASE = 1 && /foObAr/ @{ @dots{} @}} +and +@samp{IGNORECASE = 0 || /foobar/ @{ @dots{} @}}. +However, this is somewhat obscure and we don't recommend it.} +To do this, use either bracket expressions or @code{tolower()}. However, one +thing you can do with @code{IGNORECASE} only is dynamically turn +case-sensitivity on or off for all the rules at once. + +@code{IGNORECASE} can be set on the command line or in a @code{BEGIN} rule +(@pxref{Other Arguments}; also +@pxref{Using BEGIN/END}). +Setting @code{IGNORECASE} from the command line is a way to make +a program case-insensitive without having to edit it. + +Both regexp and string comparison +operations are affected by @code{IGNORECASE}. + +@c @cindex ISO 8859-1 +@c @cindex ISO Latin-1 +In multibyte locales, +the equivalences between upper- +and lowercase characters are tested based on the wide-character values of +the locale's character set. +Otherwise, the characters are tested based +on the ISO-8859-1 (ISO Latin-1) +character set. This character set is a superset of the traditional 128 +ASCII characters, which also provides a number of characters suitable +for use with European languages.@footnote{If you don't understand this, +don't worry about it; it just means that @command{gawk} does +the right thing.} + +The value of @code{IGNORECASE} has no effect if @command{gawk} is in +compatibility mode (@pxref{Options}). +Case is always significant in compatibility mode. +@c ENDOFRANGE csregexp +@c ENDOFRANGE regexpcs + +@node Leftmost Longest +@section How Much Text Matches? + +@cindex regular expressions, leftmost longest match +@c @cindex matching, leftmost longest +Consider the following: + +@example +echo aaaabcd | awk '@{ sub(/a+/, ""); print @}' +@end example + +This example uses the @code{sub()} function (which we haven't discussed yet; +@pxref{String Functions}) +to make a change to the input record. Here, the regexp @code{/a+/} +indicates ``one or more @samp{a} characters,'' and the replacement +text is @samp{}. + +The input contains four @samp{a} characters. +@command{awk} (and POSIX) regular expressions always match +the leftmost, @emph{longest} sequence of input characters that can +match. Thus, all four @samp{a} characters are +replaced with @samp{} in this example: + +@example +$ @kbd{echo aaaabcd | awk '@{ sub(/a+/, ""); print @}'} +@print{} bcd +@end example + +For simple match/no-match tests, this is not so important. But when doing +text matching and substitutions with the @code{match()}, @code{sub()}, @code{gsub()}, +and @code{gensub()} functions, it is very important. +@ifinfo +@xref{String Functions}, +for more information on these functions. +@end ifinfo +Understanding this principle is also important for regexp-based record +and field splitting (@pxref{Records}, +and also @pxref{Field Separators}). + +@node Computed Regexps +@section Using Dynamic Regexps + +@c STARTOFRANGE dregexp +@cindex regular expressions, computed +@c STARTOFRANGE regexpd +@cindex regular expressions, dynamic +@cindex @code{~} (tilde), @code{~} operator +@cindex tilde (@code{~}), @code{~} operator +@cindex @code{!} (exclamation point), @code{!~} operator +@cindex exclamation point (@code{!}), @code{!~} operator +@c @cindex operators, @code{~} +@c @cindex operators, @code{!~} +The righthand side of a @samp{~} or @samp{!~} operator need not be a +regexp constant (i.e., a string of characters between slashes). It may +be any expression. The expression is evaluated and converted to a string +if necessary; the contents of the string are then used as the +regexp. A regexp computed in this way is called a @dfn{dynamic +regexp}: + +@example +BEGIN @{ digits_regexp = "[[:digit:]]+" @} +$0 ~ digits_regexp @{ print @} +@end example + +@noindent +This sets @code{digits_regexp} to a regexp that describes one or more digits, +and tests whether the input record matches this regexp. + +@quotation NOTE +When using the @samp{~} and @samp{!~} +operators, there is a difference between a regexp constant +enclosed in slashes and a string constant enclosed in double quotes. +If you are going to use a string constant, you have to understand that +the string is, in essence, scanned @emph{twice}: the first time when +@command{awk} reads your program, and the second time when it goes to +match the string on the lefthand side of the operator with the pattern +on the right. This is true of any string-valued expression (such as +@code{digits_regexp}, shown previously), not just string constants. +@end quotation + +@cindex regexp constants, slashes vs.@: quotes +@cindex @code{\} (backslash), regexp constants +@cindex backslash (@code{\}), regexp constants +@cindex @code{"} (double quote), regexp constants +@cindex double quote (@code{"}), regexp constants +What difference does it make if the string is +scanned twice? The answer has to do with escape sequences, and particularly +with backslashes. To get a backslash into a regular expression inside a +string, you have to type two backslashes. + +For example, @code{/\*/} is a regexp constant for a literal @samp{*}. +Only one backslash is needed. To do the same thing with a string, +you have to type @code{"\\*"}. The first backslash escapes the +second one so that the string actually contains the +two characters @samp{\} and @samp{*}. + +@cindex troubleshooting, regexp constants vs.@: string constants +@cindex regexp constants, vs.@: string constants +@cindex string constants, vs.@: regexp constants +Given that you can use both regexp and string constants to describe +regular expressions, which should you use? The answer is ``regexp +constants,'' for several reasons: + +@itemize @bullet +@item +String constants are more complicated to write and +more difficult to read. Using regexp constants makes your programs +less error-prone. Not understanding the difference between the two +kinds of constants is a common source of errors. + +@item +It is more efficient to use regexp constants. @command{awk} can note +that you have supplied a regexp and store it internally in a form that +makes pattern matching more efficient. When using a string constant, +@command{awk} must first convert the string into this internal form and +then perform the pattern matching. + +@item +Using regexp constants is better form; it shows clearly that you +intend a regexp match. +@end itemize + +@c fakenode --- for prepinfo +@subheading Advanced Notes: Using @code{\n} in Bracket Expressions of Dynamic Regexps +@cindex regular expressions, dynamic, with embedded newlines +@cindex newlines, in dynamic regexps + +Some commercial versions of @command{awk} do not allow the newline +character to be used inside a bracket expression for a dynamic regexp: + +@example +$ @kbd{awk '$0 ~ "[ \t\n]"'} +@error{} awk: newline in character class [ +@error{} ]... +@error{} source line number 1 +@error{} context is +@error{} >>> <<< +@end example + +@cindex newlines, in regexp constants +But a newline in a regexp constant works with no problem: + +@example +$ @kbd{awk '$0 ~ /[ \t\n]/'} +@kbd{here is a sample line} +@print{} here is a sample line +@kbd{@value{CTL}-d} +@end example + +@command{gawk} does not have this problem, and it isn't likely to +occur often in practice, but it's worth noting for future reference. +@c ENDOFRANGE dregexp +@c ENDOFRANGE regexpd +@c ENDOFRANGE regexp + +@node Reading Files +@chapter Reading Input Files + +@c STARTOFRANGE infir +@cindex input files, reading +@cindex input files +@cindex @code{FILENAME} variable +In the typical @command{awk} program, +@command{awk} reads all input either from the +standard input (by default, this is the keyboard, but often it is a pipe from another +command) or from files whose names you specify on the @command{awk} +command line. If you specify input files, @command{awk} reads them +in order, processing all the data from one before going on to the next. +The name of the current input file can be found in the built-in variable +@code{FILENAME} +(@pxref{Built-in Variables}). + +@cindex records +@cindex fields +The input is read in units called @dfn{records}, and is processed by the +rules of your program one record at a time. +By default, each record is one line. Each +record is automatically split into chunks called @dfn{fields}. +This makes it more convenient for programs to work on the parts of a record. + +@cindex @code{getline} command +On rare occasions, you may need to use the @code{getline} command. +The @code{getline} command is valuable, both because it +can do explicit input from any number of files, and because the files +used with it do not have to be named on the @command{awk} command line +(@pxref{Getline}). + +@menu +* Records:: Controlling how data is split into records. +* Fields:: An introduction to fields. +* Nonconstant Fields:: Nonconstant Field Numbers. +* Changing Fields:: Changing the Contents of a Field. +* Field Separators:: The field separator and how to change it. +* Constant Size:: Reading constant width data. +* Splitting By Content:: Defining Fields By Content +* Multiple Line:: Reading multi-line records. +* Getline:: Reading files under explicit program control + using the @code{getline} function. +* Command line directories:: What happens if you put a directory on the + command line. +@end menu + +@node Records +@section How Input Is Split into Records + +@c STARTOFRANGE inspl +@cindex input, splitting into records +@c STARTOFRANGE recspl +@cindex records, splitting input into +@cindex @code{NR} variable +@cindex @code{FNR} variable +The @command{awk} utility divides the input for your @command{awk} +program into records and fields. +@command{awk} keeps track of the number of records that have +been read +so far +from the current input file. This value is stored in a +built-in variable called @code{FNR}. It is reset to zero when a new +file is started. Another built-in variable, @code{NR}, records the total +number of input records read so far from all @value{DF}s. It starts at zero, +but is never automatically reset to zero. + +@cindex separators, for records +@cindex record separators +Records are separated by a character called the @dfn{record separator}. +By default, the record separator is the newline character. +This is why records are, by default, single lines. +A different character can be used for the record separator by +assigning the character to the built-in variable @code{RS}. + +@cindex newlines, as record separators +@cindex @code{RS} variable +Like any other variable, +the value of @code{RS} can be changed in the @command{awk} program +with the assignment operator, @samp{=} +(@pxref{Assignment Ops}). +The new record-separator character should be enclosed in quotation marks, +which indicate a string constant. Often the right time to do this is +at the beginning of execution, before any input is processed, +so that the very first record is read with the proper separator. +To do this, use the special @code{BEGIN} pattern +(@pxref{BEGIN/END}). +For example: + +@cindex @code{BEGIN} pattern +@example +awk 'BEGIN @{ RS = "/" @} + @{ print $0 @}' BBS-list +@end example + +@noindent +changes the value of @code{RS} to @code{"/"}, before reading any input. +This is a string whose first character is a slash; as a result, records +are separated by slashes. Then the input file is read, and the second +rule in the @command{awk} program (the action with no pattern) prints each +record. Because each @code{print} statement adds a newline at the end of +its output, this @command{awk} program copies the input +with each slash changed to a newline. Here are the results of running +the program on @file{BBS-list}: + +@example +$ @kbd{awk 'BEGIN @{ RS = "/" @}} +> @kbd{@{ print $0 @}' BBS-list} +@print{} aardvark 555-5553 1200 +@print{} 300 B +@print{} alpo-net 555-3412 2400 +@print{} 1200 +@print{} 300 A +@print{} barfly 555-7685 1200 +@print{} 300 A +@print{} bites 555-1675 2400 +@print{} 1200 +@print{} 300 A +@print{} camelot 555-0542 300 C +@print{} core 555-2912 1200 +@print{} 300 C +@print{} fooey 555-1234 2400 +@print{} 1200 +@print{} 300 B +@print{} foot 555-6699 1200 +@print{} 300 B +@print{} macfoo 555-6480 1200 +@print{} 300 A +@print{} sdace 555-3430 2400 +@print{} 1200 +@print{} 300 A +@print{} sabafoo 555-2127 1200 +@print{} 300 C +@print{} +@end example + +@noindent +Note that the entry for the @samp{camelot} BBS is not split. +In the original @value{DF} +(@pxref{Sample Data Files}), +the line looks like this: + +@example +camelot 555-0542 300 C +@end example + +@noindent +It has one baud rate only, so there are no slashes in the record, +unlike the others which have two or more baud rates. +In fact, this record is treated as part of the record +for the @samp{core} BBS; the newline separating them in the output +is the original newline in the @value{DF}, not the one added by +@command{awk} when it printed the record! + +@cindex record separators, changing +@cindex separators, for records +Another way to change the record separator is on the command line, +using the variable-assignment feature +(@pxref{Other Arguments}): + +@example +awk '@{ print $0 @}' RS="/" BBS-list +@end example + +@noindent +This sets @code{RS} to @samp{/} before processing @file{BBS-list}. + +Using an unusual character such as @samp{/} for the record separator +produces correct behavior in the vast majority of cases. However, +the following (extreme) pipeline prints a surprising @samp{1}: + +@example +$ echo | awk 'BEGIN @{ RS = "a" @} ; @{ print NF @}' +@print{} 1 +@end example + +There is one field, consisting of a newline. The value of the built-in +variable @code{NF} is the number of fields in the current record. + +@cindex dark corner, input files +Reaching the end of an input file terminates the current input record, +even if the last character in the file is not the character in @code{RS}. +@value{DARKCORNER} + +@cindex null strings +@cindex strings, empty, See null strings +The empty string @code{""} (a string without any characters) +has a special meaning +as the value of @code{RS}. It means that records are separated +by one or more blank lines and nothing else. +@xref{Multiple Line}, for more details. + +If you change the value of @code{RS} in the middle of an @command{awk} run, +the new value is used to delimit subsequent records, but the record +currently being processed, as well as records already processed, are not +affected. + +@cindex @command{gawk}, @code{RT} variable in +@cindex @code{RT} variable +@cindex records, terminating +@cindex terminating records +@cindex differences in @command{awk} and @command{gawk}, record separators +@cindex regular expressions, as record separators +@cindex record separators, regular expressions as +@cindex separators, for records, regular expressions as +After the end of the record has been determined, @command{gawk} +sets the variable @code{RT} to the text in the input that matched +@code{RS}. + +@cindex common extensions, @code{RS} as a regexp +@cindex extensions, common@comma{} @code{RS} as a regexp +When using @command{gawk}, +the value of @code{RS} is not limited to a one-character +string. It can be any regular expression +(@pxref{Regexp}). @value{COMMONEXT} +In general, each record +ends at the next string that matches the regular expression; the next +record starts at the end of the matching string. This general rule is +actually at work in the usual case, where @code{RS} contains just a +newline: a record ends at the beginning of the next matching string (the +next newline in the input), and the following record starts just after +the end of this string (at the first character of the following line). +The newline, because it matches @code{RS}, is not part of either record. + +When @code{RS} is a single character, @code{RT} +contains the same single character. However, when @code{RS} is a +regular expression, @code{RT} contains +the actual input text that matched the regular expression. + +If the input file ended without any text that matches @code{RS}, +@command{gawk} sets @code{RT} to the null string. + +The following example illustrates both of these features. +It sets @code{RS} equal to a regular expression that +matches either a newline or a series of one or more uppercase letters +with optional leading and/or trailing whitespace: + +@example +$ @kbd{echo record 1 AAAA record 2 BBBB record 3 |} +> @kbd{gawk 'BEGIN @{ RS = "\n|( *[[:upper:]]+ *)" @}} +> @kbd{@{ print "Record =", $0, "and RT =", RT @}'} +@print{} Record = record 1 and RT = AAAA +@print{} Record = record 2 and RT = BBBB +@print{} Record = record 3 and RT = +@print{} +@end example + +@noindent +The final line of output has an extra blank line. This is because the +value of @code{RT} is a newline, and the @code{print} statement +supplies its own terminating newline. +@xref{Simple Sed}, for a more useful example +of @code{RS} as a regexp and @code{RT}. + +If you set @code{RS} to a regular expression that allows optional +trailing text, such as @samp{RS = "abc(XYZ)?"} it is possible, due +to implementation constraints, that @command{gawk} may match the leading +part of the regular expression, but not the trailing part, particularly +if the input text that could match the trailing part is fairly long. +@command{gawk} attempts to avoid this problem, but currently, there's +no guarantee that this will never happen. + +@quotation NOTE +Remember that in @command{awk}, the @samp{^} and @samp{$} anchor +metacharacters match the beginning and end of a @emph{string}, and not +the beginning and end of a @emph{line}. As a result, something like +@samp{RS = "^[[:upper:]]"} can only match at the beginning of a file. +This is because @command{gawk} views the input file as one long string +that happens to contain newline characters in it. +It is thus best to avoid anchor characters in the value of @code{RS}. +@end quotation + +@cindex differences in @command{awk} and @command{gawk}, @code{RS}/@code{RT} variables +The use of @code{RS} as a regular expression and the @code{RT} +variable are @command{gawk} extensions; they are not available in +compatibility mode +(@pxref{Options}). +In compatibility mode, only the first character of the value of +@code{RS} is used to determine the end of the record. + +@c fakenode --- for prepinfo +@subheading Advanced Notes: @code{RS = "\0"} Is Not Portable + +@cindex advanced features, @value{DF}s as single record +@cindex portability, @value{DF}s as single record +There are times when you might want to treat an entire @value{DF} as a +single record. The only way to make this happen is to give @code{RS} +a value that you know doesn't occur in the input file. This is hard +to do in a general way, such that a program always works for arbitrary +input files. +@c can you say `understatement' boys and girls? + +You might think that for text files, the @sc{nul} character, which +consists of a character with all bits equal to zero, is a good +value to use for @code{RS} in this case: + +@example +BEGIN @{ RS = "\0" @} # whole file becomes one record? +@end example + +@cindex differences in @command{awk} and @command{gawk}, strings, storing +@command{gawk} in fact accepts this, and uses the @sc{nul} +character for the record separator. +However, this usage is @emph{not} portable +to other @command{awk} implementations. + +@cindex dark corner, strings, storing +All other @command{awk} implementations@footnote{At least that we know +about.} store strings internally as C-style strings. C strings use the +@sc{nul} character as the string terminator. In effect, this means that +@samp{RS = "\0"} is the same as @samp{RS = ""}. +@value{DARKCORNER} + +@cindex records, treating files as +@cindex files, as single records +The best way to treat a whole file as a single record is to +simply read the file in, one record at a time, concatenating each +record onto the end of the previous ones. +@c ENDOFRANGE inspl +@c ENDOFRANGE recspl + +@node Fields +@section Examining Fields + +@cindex examining fields +@cindex fields +@cindex accessing fields +@c STARTOFRANGE fiex +@cindex fields, examining +@cindex POSIX @command{awk}, field separators and +@cindex field separators, POSIX and +@cindex separators, field, POSIX and +When @command{awk} reads an input record, the record is +automatically @dfn{parsed} or separated by the @command{awk} utility into chunks +called @dfn{fields}. By default, fields are separated by @dfn{whitespace}, +like words in a line. +Whitespace in @command{awk} means any string of one or more spaces, +TABs, or newlines;@footnote{In POSIX @command{awk}, newlines are not +considered whitespace for separating fields.} other characters, such as +formfeed, vertical tab, etc., that are +considered whitespace by other languages, are @emph{not} considered +whitespace by @command{awk}. + +The purpose of fields is to make it more convenient for you to refer to +these pieces of the record. You don't have to use them---you can +operate on the whole record if you want---but fields are what make +simple @command{awk} programs so powerful. + +@cindex field operator @code{$} +@cindex @code{$} (dollar sign), @code{$} field operator +@cindex dollar sign (@code{$}), @code{$} field operator +@cindex field operators@comma{} dollar sign as +A dollar-sign (@samp{$}) is used +to refer to a field in an @command{awk} program, +followed by the number of the field you want. Thus, @code{$1} +refers to the first field, @code{$2} to the second, and so on. +(Unlike the Unix shells, the field numbers are not limited to single digits. +@code{$127} is the one hundred twenty-seventh field in the record.) +For example, suppose the following is a line of input: + +@example +This seems like a pretty nice example. +@end example + +@noindent +Here the first field, or @code{$1}, is @samp{This}, the second field, or +@code{$2}, is @samp{seems}, and so on. Note that the last field, +@code{$7}, is @samp{example.}. Because there is no space between the +@samp{e} and the @samp{.}, the period is considered part of the seventh +field. + +@cindex @code{NF} variable +@cindex fields, number of +@code{NF} is a built-in variable whose value is the number of fields +in the current record. @command{awk} automatically updates the value +of @code{NF} each time it reads a record. No matter how many fields +there are, the last field in a record can be represented by @code{$NF}. +So, @code{$NF} is the same as @code{$7}, which is @samp{example.}. +If you try to reference a field beyond the last +one (such as @code{$8} when the record has only seven fields), you get +the empty string. (If used in a numeric operation, you get zero.) + +The use of @code{$0}, which looks like a reference to the ``zero-th'' field, is +a special case: it represents the whole input record +when you are not interested in specific fields. +Here are some more examples: + +@example +$ @kbd{awk '$1 ~ /foo/ @{ print $0 @}' BBS-list} +@print{} fooey 555-1234 2400/1200/300 B +@print{} foot 555-6699 1200/300 B +@print{} macfoo 555-6480 1200/300 A +@print{} sabafoo 555-2127 1200/300 C +@end example + +@noindent +This example prints each record in the file @file{BBS-list} whose first +field contains the string @samp{foo}. The operator @samp{~} is called a +@dfn{matching operator} +(@pxref{Regexp Usage}); +it tests whether a string (here, the field @code{$1}) matches a given regular +expression. + +By contrast, the following example +looks for @samp{foo} in @emph{the entire record} and prints the first +field and the last field for each matching input record: + +@example +$ @kbd{awk '/foo/ @{ print $1, $NF @}' BBS-list} +@print{} fooey B +@print{} foot B +@print{} macfoo A +@print{} sabafoo C +@end example +@c ENDOFRANGE fiex + +@node Nonconstant Fields +@section Nonconstant Field Numbers +@cindex fields, numbers +@cindex field numbers + +The number of a field does not need to be a constant. Any expression in +the @command{awk} language can be used after a @samp{$} to refer to a +field. The value of the expression specifies the field number. If the +value is a string, rather than a number, it is converted to a number. +Consider this example: + +@example +awk '@{ print $NR @}' +@end example + +@noindent +Recall that @code{NR} is the number of records read so far: one in the +first record, two in the second, etc. So this example prints the first +field of the first record, the second field of the second record, and so +on. For the twentieth record, field number 20 is printed; most likely, +the record has fewer than 20 fields, so this prints a blank line. +Here is another example of using expressions as field numbers: + +@example +awk '@{ print $(2*2) @}' BBS-list +@end example + +@command{awk} evaluates the expression @samp{(2*2)} and uses +its value as the number of the field to print. The @samp{*} sign +represents multiplication, so the expression @samp{2*2} evaluates to four. +The parentheses are used so that the multiplication is done before the +@samp{$} operation; they are necessary whenever there is a binary +operator in the field-number expression. This example, then, prints the +hours of operation (the fourth field) for every line of the file +@file{BBS-list}. (All of the @command{awk} operators are listed, in +order of decreasing precedence, in +@ref{Precedence}.) + +If the field number you compute is zero, you get the entire record. +Thus, @samp{$(2-2)} has the same value as @code{$0}. Negative field +numbers are not allowed; trying to reference one usually terminates +the program. (The POSIX standard does not define +what happens when you reference a negative field number. @command{gawk} +notices this and terminates your program. Other @command{awk} +implementations may behave differently.) + +As mentioned in @ref{Fields}, +@command{awk} stores the current record's number of fields in the built-in +variable @code{NF} (also @pxref{Built-in Variables}). The expression +@code{$NF} is not a special feature---it is the direct consequence of +evaluating @code{NF} and using its value as a field number. + +@node Changing Fields +@section Changing the Contents of a Field + +@c STARTOFRANGE ficon +@cindex fields, changing contents of +The contents of a field, as seen by @command{awk}, can be changed within an +@command{awk} program; this changes what @command{awk} perceives as the +current input record. (The actual input is untouched; @command{awk} @emph{never} +modifies the input file.) +Consider the following example and its output: + +@example +$ @kbd{awk '@{ nboxes = $3 ; $3 = $3 - 10} +> @kbd{print nboxes, $3 @}' inventory-shipped} +@print{} 25 15 +@print{} 32 22 +@print{} 24 14 +@dots{} +@end example + +@noindent +The program first saves the original value of field three in the variable +@code{nboxes}. +The @samp{-} sign represents subtraction, so this program reassigns +field three, @code{$3}, as the original value of field three minus ten: +@samp{$3 - 10}. (@xref{Arithmetic Ops}.) +Then it prints the original and new values for field three. +(Someone in the warehouse made a consistent mistake while inventorying +the red boxes.) + +For this to work, the text in field @code{$3} must make sense +as a number; the string of characters must be converted to a number +for the computer to do arithmetic on it. The number resulting +from the subtraction is converted back to a string of characters that +then becomes field three. +@xref{Conversion}. + +When the value of a field is changed (as perceived by @command{awk}), the +text of the input record is recalculated to contain the new field where +the old one was. In other words, @code{$0} changes to reflect the altered +field. Thus, this program +prints a copy of the input file, with 10 subtracted from the second +field of each line: + +@example +$ @kbd{awk '@{ $2 = $2 - 10; print $0 @}' inventory-shipped} +@print{} Jan 3 25 15 115 +@print{} Feb 5 32 24 226 +@print{} Mar 5 24 34 228 +@dots{} +@end example + +It is also possible to also assign contents to fields that are out +of range. For example: + +@example +$ awk '@{ $6 = ($5 + $4 + $3 + $2) +> print $6 @}' inventory-shipped +@print{} 168 +@print{} 297 +@print{} 301 +@dots{} +@end example + +@cindex adding, fields +@cindex fields, adding +@noindent +We've just created @code{$6}, whose value is the sum of fields +@code{$2}, @code{$3}, @code{$4}, and @code{$5}. The @samp{+} sign +represents addition. For the file @file{inventory-shipped}, @code{$6} +represents the total number of parcels shipped for a particular month. + +Creating a new field changes @command{awk}'s internal copy of the current +input record, which is the value of @code{$0}. Thus, if you do @samp{print $0} +after adding a field, the record printed includes the new field, with +the appropriate number of field separators between it and the previously +existing fields. + +@cindex @code{OFS} variable +@cindex output field separator, See @code{OFS} variable +@cindex field separators, See Also @code{OFS} +This recomputation affects and is affected by +@code{NF} (the number of fields; @pxref{Fields}). +For example, the value of @code{NF} is set to the number of the highest +field you create. +The exact format of @code{$0} is also affected by a feature that has not been discussed yet: +the @dfn{output field separator}, @code{OFS}, +used to separate the fields (@pxref{Output Separators}). + +Note, however, that merely @emph{referencing} an out-of-range field +does @emph{not} change the value of either @code{$0} or @code{NF}. +Referencing an out-of-range field only produces an empty string. For +example: + +@example +if ($(NF+1) != "") + print "can't happen" +else + print "everything is normal" +@end example + +@noindent +should print @samp{everything is normal}, because @code{NF+1} is certain +to be out of range. (@xref{If Statement}, +for more information about @command{awk}'s @code{if-else} statements. +@xref{Typing and Comparison}, +for more information about the @samp{!=} operator.) + +It is important to note that making an assignment to an existing field +changes the +value of @code{$0} but does not change the value of @code{NF}, +even when you assign the empty string to a field. For example: + +@example +$ @kbd{echo a b c d | awk '@{ OFS = ":"; $2 = ""} +> @kbd{print $0; print NF @}'} +@print{} a::c:d +@print{} 4 +@end example + +@noindent +The field is still there; it just has an empty value, denoted by +the two colons between @samp{a} and @samp{c}. +This example shows what happens if you create a new field: + +@example +$ @kbd{echo a b c d | awk '@{ OFS = ":"; $2 = ""; $6 = "new"} +> @kbd{print $0; print NF @}'} +@print{} a::c:d::new +@print{} 6 +@end example + +@noindent +The intervening field, @code{$5}, is created with an empty value +(indicated by the second pair of adjacent colons), +and @code{NF} is updated with the value six. + +@cindex dark corner, @code{NF} variable, decrementing +@cindex @code{NF} variable, decrementing +Decrementing @code{NF} throws away the values of the fields +after the new value of @code{NF} and recomputes @code{$0}. +@value{DARKCORNER} +Here is an example: + +@example +$ echo a b c d e f | awk '@{ print "NF =", NF; +> NF = 3; print $0 @}' +@print{} NF = 6 +@print{} a b c +@end example + +@cindex portability, @code{NF} variable@comma{} decrementing +@quotation CAUTION +Some versions of @command{awk} don't +rebuild @code{$0} when @code{NF} is decremented. Caveat emptor. +@end quotation + +Finally, there are times when it is convenient to force +@command{awk} to rebuild the entire record, using the current +value of the fields and @code{OFS}. To do this, use the +seemingly innocuous assignment: + +@example +$1 = $1 # force record to be reconstituted +print $0 # or whatever else with $0 +@end example + +@noindent +This forces @command{awk} to rebuild the record. It does help +to add a comment, as we've shown here. + +There is a flip side to the relationship between @code{$0} and +the fields. Any assignment to @code{$0} causes the record to be +reparsed into fields using the @emph{current} value of @code{FS}. +This also applies to any built-in function that updates @code{$0}, +such as @code{sub()} and @code{gsub()} +(@pxref{String Functions}). + +@c fakenode --- for prepinfo +@subheading Advanced Notes: Understanding @code{$0} + +It is important to remember that @code{$0} is the @emph{full} +record, exactly as it was read from the input. This includes +any leading or trailing whitespace, and the exact whitespace (or other +characters) that separate the fields. + +It is a not-uncommon error to try to change the field separators +in a record simply by setting @code{FS} and @code{OFS}, and then +expecting a plain @samp{print} or @samp{print $0} to print the +modified record. + +But this does not work, since nothing was done to change the record +itself. Instead, you must force the record to be rebuilt, typically +with a statement such as @samp{$1 = $1}, as described earlier. + +@c ENDOFRANGE ficon + +@node Field Separators +@section Specifying How Fields Are Separated + +@menu +* Default Field Splitting:: How fields are normally separated. +* Regexp Field Splitting:: Using regexps as the field separator. +* Single Character Fields:: Making each character a separate field. +* Command Line Field Separator:: Setting @code{FS} from the command-line. +* Field Splitting Summary:: Some final points and a summary table. +@end menu + +@cindex @code{FS} variable +@cindex fields, separating +@c STARTOFRANGE fisepr +@cindex field separators +@c STARTOFRANGE fisepg +@cindex fields, separating +The @dfn{field separator}, which is either a single character or a regular +expression, controls the way @command{awk} splits an input record into fields. +@command{awk} scans the input record for character sequences that +match the separator; the fields themselves are the text between the matches. + +In the examples that follow, we use the bullet symbol (@bullet{}) to +represent spaces in the output. +If the field separator is @samp{oo}, then the following line: + +@example +moo goo gai pan +@end example + +@noindent +is split into three fields: @samp{m}, @samp{@bullet{}g}, and +@samp{@bullet{}gai@bullet{}pan}. +Note the leading spaces in the values of the second and third fields. + +@cindex troubleshooting, @command{awk} uses @code{FS} not @code{IFS} +The field separator is represented by the built-in variable @code{FS}. +Shell programmers take note: @command{awk} does @emph{not} use the +name @code{IFS} that is used by the POSIX-compliant shells (such as +the Unix Bourne shell, @command{sh}, or Bash). + +@cindex @code{FS} variable, changing value of +The value of @code{FS} can be changed in the @command{awk} program with the +assignment operator, @samp{=} (@pxref{Assignment Ops}). +Often the right time to do this is at the beginning of execution +before any input has been processed, so that the very first record +is read with the proper separator. To do this, use the special +@code{BEGIN} pattern +(@pxref{BEGIN/END}). +For example, here we set the value of @code{FS} to the string +@code{","}: + +@example +awk 'BEGIN @{ FS = "," @} ; @{ print $2 @}' +@end example + +@cindex @code{BEGIN} pattern +@noindent +Given the input line: + +@example +John Q. Smith, 29 Oak St., Walamazoo, MI 42139 +@end example + +@noindent +this @command{awk} program extracts and prints the string +@samp{@bullet{}29@bullet{}Oak@bullet{}St.}. + +@cindex field separators, choice of +@cindex regular expressions as field separators +@cindex field separators, regular expressions as +Sometimes the input data contains separator characters that don't +separate fields the way you thought they would. For instance, the +person's name in the example we just used might have a title or +suffix attached, such as: + +@example +John Q. Smith, LXIX, 29 Oak St., Walamazoo, MI 42139 +@end example + +@noindent +The same program would extract @samp{@bullet{}LXIX}, instead of +@samp{@bullet{}29@bullet{}Oak@bullet{}St.}. +If you were expecting the program to print the +address, you would be surprised. The moral is to choose your data layout and +separator characters carefully to prevent such problems. +(If the data is not in a form that is easy to process, perhaps you +can massage it first with a separate @command{awk} program.) + + +@node Default Field Splitting +@subsection Whitespace Normally Separates Fields + +@cindex newlines, as field separators +@cindex whitespace, as field separators +Fields are normally separated by whitespace sequences +(spaces, TABs, and newlines), not by single spaces. Two spaces in a row do not +delimit an empty field. The default value of the field separator @code{FS} +is a string containing a single space, @w{@code{" "}}. If @command{awk} +interpreted this value in the usual way, each space character would separate +fields, so two spaces in a row would make an empty field between them. +The reason this does not happen is that a single space as the value of +@code{FS} is a special case---it is taken to specify the default manner +of delimiting fields. + +If @code{FS} is any other single character, such as @code{","}, then +each occurrence of that character separates two fields. Two consecutive +occurrences delimit an empty field. If the character occurs at the +beginning or the end of the line, that too delimits an empty field. The +space character is the only single character that does not follow these +rules. + +@node Regexp Field Splitting +@subsection Using Regular Expressions to Separate Fields + +@c STARTOFRANGE regexpfs +@cindex regular expressions, as field separators +@c STARTOFRANGE fsregexp +@cindex field separators, regular expressions as +The previous @value{SUBSECTION} +discussed the use of single characters or simple strings as the +value of @code{FS}. +More generally, the value of @code{FS} may be a string containing any +regular expression. In this case, each match in the record for the regular +expression separates fields. For example, the assignment: + +@example +FS = ", \t" +@end example + +@noindent +makes every area of an input line that consists of a comma followed by a +space and a TAB into a field separator. +@ifinfo +(@samp{\t} +is an @dfn{escape sequence} that stands for a TAB; +@pxref{Escape Sequences}, +for the complete list of similar escape sequences.) +@end ifinfo + +For a less trivial example of a regular expression, try using +single spaces to separate fields the way single commas are used. +@code{FS} can be set to @w{@code{"[@ ]"}} (left bracket, space, right +bracket). This regular expression matches a single space and nothing else +(@pxref{Regexp}). + +There is an important difference between the two cases of @samp{FS = @w{" "}} +(a single space) and @samp{FS = @w{"[ \t\n]+"}} +(a regular expression matching one or more spaces, TABs, or newlines). +For both values of @code{FS}, fields are separated by @dfn{runs} +(multiple adjacent occurrences) of spaces, TABs, +and/or newlines. However, when the value of @code{FS} is @w{@code{" "}}, +@command{awk} first strips leading and trailing whitespace from +the record and then decides where the fields are. +For example, the following pipeline prints @samp{b}: + +@example +$ @kbd{echo ' a b c d ' | awk '@{ print $2 @}'} +@print{} b +@end example + +@noindent +However, this pipeline prints @samp{a} (note the extra spaces around +each letter): + +@example +$ @kbd{echo ' a b c d ' | awk 'BEGIN @{ FS = "[ \t\n]+" @}} +> @kbd{@{ print $2 @}'} +@print{} a +@end example + +@noindent +@cindex null strings +@cindex strings, null +@cindex empty strings, See null strings +In this case, the first field is @dfn{null} or empty. + +The stripping of leading and trailing whitespace also comes into +play whenever @code{$0} is recomputed. For instance, study this pipeline: + +@example +$ @kbd{echo ' a b c d' | awk '@{ print; $2 = $2; print @}'} +@print{} a b c d +@print{} a b c d +@end example + +@noindent +The first @code{print} statement prints the record as it was read, +with leading whitespace intact. The assignment to @code{$2} rebuilds +@code{$0} by concatenating @code{$1} through @code{$NF} together, +separated by the value of @code{OFS}. Because the leading whitespace +was ignored when finding @code{$1}, it is not part of the new @code{$0}. +Finally, the last @code{print} statement prints the new @code{$0}. + +@cindex @code{FS}, containing @code{^} +@cindex @code{^}, in @code{FS} +@cindex dark corner, @code{^}, in @code{FS} +There is an additional subtlety to be aware of when using regular expressions +for field splitting. +It is not well-specified in the POSIX standard, or anywhere else, what @samp{^} +means when splitting fields. Does the @samp{^} match only at the beginning of +the entire record? Or is each field separator a new string? It turns out that +different @command{awk} versions answer this question differently, and you +should not rely on any specific behavior in your programs. +@value{DARKCORNER} + +As a point of information, Brian Kernighan's @command{awk} allows @samp{^} +to match only at the beginning of the record. @command{gawk} +also works this way. For example: + +@example +$ @kbd{echo 'xxAA xxBxx C' |} +> @kbd{gawk -F '(^x+)|( +)' '@{ for (i = 1; i <= NF; i++)} +> @kbd{printf "-->%s<--\n", $i @}'} +@print{} --><-- +@print{} -->AA<-- +@print{} -->xxBxx<-- +@print{} -->C<-- +@end example +@c ENDOFRANGE regexpfs +@c ENDOFRANGE fsregexp + +@node Single Character Fields +@subsection Making Each Character a Separate Field + +@cindex common extensions, single character fields +@cindex extensions, common@comma{} single character fields +@cindex differences in @command{awk} and @command{gawk}, single-character fields +@cindex single-character fields +@cindex fields, single-character +There are times when you may want to examine each character +of a record separately. This can be done in @command{gawk} by +simply assigning the null string (@code{""}) to @code{FS}. @value{COMMONEXT} +In this case, +each individual character in the record becomes a separate field. +For example: + +@example +$ @kbd{echo a b | gawk 'BEGIN @{ FS = "" @}} +> @kbd{@{} +> @kbd{for (i = 1; i <= NF; i = i + 1)} +> @kbd{print "Field", i, "is", $i} +> @kbd{@}'} +@print{} Field 1 is a +@print{} Field 2 is +@print{} Field 3 is b +@end example + +@cindex dark corner, @code{FS} as null string +@cindex FS variable, as null string +Traditionally, the behavior of @code{FS} equal to @code{""} was not defined. +In this case, most versions of Unix @command{awk} simply treat the entire record +as only having one field. +@value{DARKCORNER} +In compatibility mode +(@pxref{Options}), +if @code{FS} is the null string, then @command{gawk} also +behaves this way. + +@node Command Line Field Separator +@subsection Setting @code{FS} from the Command Line +@cindex @code{-F} option +@cindex options, command-line +@cindex command line, options +@cindex field separators, on command line +@cindex command line, @code{FS} on@comma{} setting +@cindex @code{FS} variable, setting from command line + +@code{FS} can be set on the command line. Use the @option{-F} option to +do so. For example: + +@example +awk -F, '@var{program}' @var{input-files} +@end example + +@noindent +sets @code{FS} to the @samp{,} character. Notice that the option uses +an uppercase @samp{F} instead of a lowercase @samp{f}. The latter +option (@option{-f}) specifies a file +containing an @command{awk} program. Case is significant in command-line +options: +the @option{-F} and @option{-f} options have nothing to do with each other. +You can use both options at the same time to set the @code{FS} variable +@emph{and} get an @command{awk} program from a file. + +The value used for the argument to @option{-F} is processed in exactly the +same way as assignments to the built-in variable @code{FS}. +Any special characters in the field separator must be escaped +appropriately. For example, to use a @samp{\} as the field separator +on the command line, you would have to type: + +@example +# same as FS = "\\" +awk -F\\\\ '@dots{}' files @dots{} +@end example + +@noindent +@cindex @code{\} (backslash), as field separators +@cindex backslash (@code{\}), as field separators +Because @samp{\} is used for quoting in the shell, @command{awk} sees +@samp{-F\\}. Then @command{awk} processes the @samp{\\} for escape +characters (@pxref{Escape Sequences}), finally yielding +a single @samp{\} to use for the field separator. + +@c @cindex historical features +As a special case, in compatibility mode +(@pxref{Options}), +if the argument to @option{-F} is @samp{t}, then @code{FS} is set to +the TAB character. If you type @samp{-F\t} at the +shell, without any quotes, the @samp{\} gets deleted, so @command{awk} +figures that you really want your fields to be separated with TABs and +not @samp{t}s. Use @samp{-v FS="t"} or @samp{-F"[t]"} on the command line +if you really do want to separate your fields with @samp{t}s. + +As an example, let's use an @command{awk} program file called @file{baud.awk} +that contains the pattern @code{/300/} and the action @samp{print $1}: + +@example +/300/ @{ print $1 @} +@end example + +Let's also set @code{FS} to be the @samp{-} character and run the +program on the file @file{BBS-list}. The following command prints a +list of the names of the bulletin boards that operate at 300 baud and +the first three digits of their phone numbers: + +@c tweaked to make the tex output look better in @smallbook +@example +$ @kbd{awk -F- -f baud.awk BBS-list} +@print{} aardvark 555 +@print{} alpo +@print{} barfly 555 +@print{} bites 555 +@print{} camelot 555 +@print{} core 555 +@print{} fooey 555 +@print{} foot 555 +@print{} macfoo 555 +@print{} sdace 555 +@print{} sabafoo 555 +@end example + +@noindent +Note the second line of output. The second line +in the original file looked like this: + +@example +alpo-net 555-3412 2400/1200/300 A +@end example + +The @samp{-} as part of the system's name was used as the field +separator, instead of the @samp{-} in the phone number that was +originally intended. This demonstrates why you have to be careful in +choosing your field and record separators. + +@cindex Unix @command{awk}, password files@comma{} field separators and +Perhaps the most common use of a single character as the field +separator occurs when processing the Unix system password file. +On many Unix systems, each user has a separate entry in the system password +file, one line per user. The information in these lines is separated +by colons. The first field is the user's login name and the second is +the user's (encrypted or shadow) password. A password file entry might look +like this: + +@cindex Robbins, Arnold +@example +arnold:xyzzy:2076:10:Arnold Robbins:/home/arnold:/bin/bash +@end example + +The following program searches the system password file and prints +the entries for users who have no password: + +@example +awk -F: '$2 == ""' /etc/passwd +@end example + +@node Field Splitting Summary +@subsection Field-Splitting Summary + +It is important to remember that when you assign a string constant +as the value of @code{FS}, it undergoes normal @command{awk} string +processing. For example, with Unix @command{awk} and @command{gawk}, +the assignment @samp{FS = "\.."} assigns the character string @code{".."} +to @code{FS} (the backslash is stripped). This creates a regexp meaning +``fields are separated by occurrences of any two characters.'' +If instead you want fields to be separated by a literal period followed +by any single character, use @samp{FS = "\\.."}. + +The following table summarizes how fields are split, based on the value +of @code{FS} (@samp{==} means ``is equal to''): + +@table @code +@item FS == " " +Fields are separated by runs of whitespace. Leading and trailing +whitespace are ignored. This is the default. + +@item FS == @var{any other single character} +Fields are separated by each occurrence of the character. Multiple +successive occurrences delimit empty fields, as do leading and +trailing occurrences. +The character can even be a regexp metacharacter; it does not need +to be escaped. + +@item FS == @var{regexp} +Fields are separated by occurrences of characters that match @var{regexp}. +Leading and trailing matches of @var{regexp} delimit empty fields. + +@item FS == "" +Each individual character in the record becomes a separate field. +(This is a @command{gawk} extension; it is not specified by the +POSIX standard.) +@end table + +@c fakenode --- for prepinfo +@subheading Advanced Notes: Changing @code{FS} Does Not Affect the Fields + +@cindex POSIX @command{awk}, field separators and +@cindex field separators, POSIX and +According to the POSIX standard, @command{awk} is supposed to behave +as if each record is split into fields at the time it is read. +In particular, this means that if you change the value of @code{FS} +after a record is read, the value of the fields (i.e., how they were split) +should reflect the old value of @code{FS}, not the new one. + +@cindex dark corner, field separators +@cindex @command{sed} utility +@cindex stream editors +However, many older implementations of @command{awk} do not work this way. Instead, +they defer splitting the fields until a field is actually +referenced. The fields are split +using the @emph{current} value of @code{FS}! +@value{DARKCORNER} +This behavior can be difficult +to diagnose. The following example illustrates the difference +between the two methods. +(The @command{sed}@footnote{The @command{sed} utility is a ``stream editor.'' +Its behavior is also defined by the POSIX standard.} +command prints just the first line of @file{/etc/passwd}.) + +@example +sed 1q /etc/passwd | awk '@{ FS = ":" ; print $1 @}' +@end example + +@noindent +which usually prints: + +@example +root +@end example + +@noindent +on an incorrect implementation of @command{awk}, while @command{gawk} +prints something like: + +@example +root:nSijPlPhZZwgE:0:0:Root:/: +@end example + +@c fakenode --- for prepinfo +@subheading Advanced Notes: @code{FS} and @code{IGNORECASE} + +The @code{IGNORECASE} variable +(@pxref{User-modified}) +affects field splitting @emph{only} when the value of @code{FS} is a regexp. +It has no effect when @code{FS} is a single character, even if +that character is a letter. Thus, in the following code: + +@example +FS = "c" +IGNORECASE = 1 +$0 = "aCa" +print $1 +@end example + +@noindent +The output is @samp{aCa}. If you really want to split fields on an +alphabetic character while ignoring case, use a regexp that will +do it for you. E.g., @samp{FS = "[c]"}. In this case, @code{IGNORECASE} +will take effect. + +@c ENDOFRANGE fisepr +@c ENDOFRANGE fisepg + +@node Constant Size +@section Reading Fixed-Width Data + +@ifnotinfo +@quotation NOTE +This @value{SECTION} discusses an advanced +feature of @command{gawk}. If you are a novice @command{awk} user, +you might want to skip it on the first reading. +@end quotation +@end ifnotinfo + +@ifinfo +(This @value{SECTION} discusses an advanced feature of @command{awk}. +If you are a novice @command{awk} user, you might want to skip it on +the first reading.) +@end ifinfo + +@cindex data, fixed-width +@cindex fixed-width data +@cindex advanced features, fixed-width data +@command{gawk} provides a facility for dealing with +fixed-width fields with no distinctive field separator. For example, +data of this nature arises in the input for old Fortran programs where +numbers are run together, or in the output of programs that did not +anticipate the use of their output as input for other programs. + +An example of the latter is a table where all the columns are lined up by +the use of a variable number of spaces and @emph{empty fields are just +spaces}. Clearly, @command{awk}'s normal field splitting based on @code{FS} +does not work well in this case. Although a portable @command{awk} program +can use a series of @code{substr()} calls on @code{$0} +(@pxref{String Functions}), +this is awkward and inefficient for a large number of fields. + +@cindex troubleshooting, fatal errors, field widths@comma{} specifying +@cindex @command{w} utility +@cindex @code{FIELDWIDTHS} variable +@cindex @command{gawk}, @code{FIELDWIDTHS} variable in +The splitting of an input record into fixed-width fields is specified by +assigning a string containing space-separated numbers to the built-in +variable @code{FIELDWIDTHS}. Each number specifies the width of the field, +@emph{including} columns between fields. If you want to ignore the columns +between fields, you can specify the width as a separate field that is +subsequently ignored. +It is a fatal error to supply a field width that is not a positive number. +The following data is the output of the Unix @command{w} utility. It is useful +to illustrate the use of @code{FIELDWIDTHS}: + +@example +@group + 10:06pm up 21 days, 14:04, 23 users +User tty login@ idle JCPU PCPU what +hzuo ttyV0 8:58pm 9 5 vi p24.tex +hzang ttyV3 6:37pm 50 -csh +eklye ttyV5 9:53pm 7 1 em thes.tex +dportein ttyV6 8:17pm 1:47 -csh +gierd ttyD3 10:00pm 1 elm +dave ttyD4 9:47pm 4 4 w +brent ttyp0 26Jun91 4:46 26:46 4:41 bash +dave ttyq4 26Jun9115days 46 46 wnewmail +@end group +@end example + +The following program takes the above input, converts the idle time to +number of seconds, and prints out the first two fields and the calculated +idle time: + +@quotation NOTE +This program uses a number of @command{awk} features that +haven't been introduced yet. +@end quotation + +@example +BEGIN @{ FIELDWIDTHS = "9 6 10 6 7 7 35" @} +NR > 2 @{ + idle = $4 + sub(/^ */, "", idle) # strip leading spaces + if (idle == "") + idle = 0 + if (idle ~ /:/) @{ + split(idle, t, ":") + idle = t[1] * 60 + t[2] + @} + if (idle ~ /days/) + idle *= 24 * 60 * 60 + + print $1, $2, idle +@} +@end example + +Running the program on the data produces the following results: + +@example +hzuo ttyV0 0 +hzang ttyV3 50 +eklye ttyV5 0 +dportein ttyV6 107 +gierd ttyD3 1 +dave ttyD4 0 +brent ttyp0 286 +dave ttyq4 1296000 +@end example + +Another (possibly more practical) example of fixed-width input data +is the input from a deck of balloting cards. In some parts of +the United States, voters mark their choices by punching holes in computer +cards. These cards are then processed to count the votes for any particular +candidate or on any particular issue. Because a voter may choose not to +vote on some issue, any column on the card may be empty. An @command{awk} +program for processing such data could use the @code{FIELDWIDTHS} feature +to simplify reading the data. (Of course, getting @command{gawk} to run on +a system with card readers is another story!) + +@ignore +Exercise: Write a ballot card reading program +@end ignore + +@cindex @command{gawk}, splitting fields and +Assigning a value to @code{FS} causes @command{gawk} to use +@code{FS} for field splitting again. Use @samp{FS = FS} to make this happen, +without having to know the current value of @code{FS}. +In order to tell which kind of field splitting is in effect, +use @code{PROCINFO["FS"]} +(@pxref{Auto-set}). +The value is @code{"FS"} if regular field splitting is being used, +or it is @code{"FIELDWIDTHS"} if fixed-width field splitting is being used: + +@example +if (PROCINFO["FS"] == "FS") + @var{regular field splitting} @dots{} +else if (PROCINFO["FS"] == "FIELDWIDTHS") + @var{fixed-width field splitting} @dots{} +else + @var{content-based field splitting} @dots{} (see next @value{SECTION}) +@end example + +This information is useful when writing a function +that needs to temporarily change @code{FS} or @code{FIELDWIDTHS}, +read some records, and then restore the original settings +(@pxref{Passwd Functions}, +for an example of such a function). + +@node Splitting By Content +@section Defining Fields By Content + +@ifnotinfo +@quotation NOTE +This @value{SECTION} discusses an advanced +feature of @command{gawk}. If you are a novice @command{awk} user, +you might want to skip it on the first reading. +@end quotation +@end ifnotinfo + +@ifinfo +(This @value{SECTION} discusses an advanced feature of @command{awk}. +If you are a novice @command{awk} user, you might want to skip it on +the first reading.) +@end ifinfo + +@cindex advanced features, specifying field content +Normally, when using @code{FS}, @command{gawk} defines the fields as the +parts of the record that occur in between each field separator. In other +words, @code{FS} defines what a field @emph{is not}, instead of what a field +@emph{is}. +However, there are times when you really want to define the fields by +what they are, and not by what they are not. + +The most notorious such case +is so-called @dfn{comma separated value} (CSV) data. Many spreadsheet programs, +for example, can export their data into text files, where each record is +terminated with a newline, and fields are separated by commas. If only +commas separated the data, there wouldn't be an issue. The problem comes when +one of the fields contains an @emph{embedded} comma. While there is no +formal standard specification for CSV data@footnote{At least, we don't know of one.}, +in such cases, most programs embed the field in double quotes. So we might +have data like this: + +@example +@c file eg/misc/addresses.csv +Robbins,Arnold,"1234 A Pretty Street, NE",MyTown,MyState,12345-6789,USA +@c endfile +@end example + +@cindex @command{gawk}, @code{FPAT} variable in +@cindex @code{FPAT} variable +The @code{FPAT} variable offers a solution for cases like this. +The value of @code{FPAT} should be a string that provides a regular expression. +This regular expression describes the contents of each field. + +In the case of CSV data as presented above, each field is either ``anything that +is not a comma,'' or ``a double quote, anything that is not a double quote, and a +closing double quote.'' If written as a regular expression constant +(@pxref{Regexp}), +we would have @code{/([^,]+)|("[^"]+")/}. +Writing this as a string requires us to escape the double quotes, leading to: + +@example +FPAT = "([^,]+)|(\"[^\"]+\")" +@end example + +Putting this to use, here is a simple program to parse the data: + +@example +@c file eg/misc/simple-csv.awk +BEGIN @{ + FPAT = "([^,]+)|(\"[^\"]+\")" +@} + +@{ + print "NF = ", NF + for (i = 1; i <= NF; i++) @{ + printf("$%d = <%s>\n", i, $i) + @} +@} +@c endfile +@end example + +When run, we get the following: + +@example +$ @kbd{gawk -f simple-csv.awk addresses.csv} +NF = 7 +$1 = +$2 = +$3 = <"1234 A Pretty Street, NE"> +$4 = +$5 = +$6 = <12345-6789> +$7 = +@end example + +Note the embedded comma in the value of @code{$3}. + +A straightforward improvement when processing CSV data of this sort +would be to remove the quotes when they occur, with something like this: + +@example +if (substr($i, 1, 1) == "\"") @{ + len = length($i) + $i = substr($i, 2, len - 2) # Get text within the two quotes +@} +@end example + +As with @code{FS}, the @code{IGNORECASE} variable (@pxref{User-modified}) +affects field splitting with @code{FPAT}. + +Similar to @code{FIELDWIDTHS}, the value of @code{PROCINFO["FS"]} +will be @code{"FPAT"} if content-based field splitting is being used. + +@quotation NOTE +Some programs export CSV data that contains embedded newlines between +the double quotes. @command{gawk} provides no way to deal with this. +Since there is no formal specification for CSV data, there isn't much +more to be done; +the @code{FPAT} mechanism provides an elegant solution for the majority +of cases, and the @command{gawk} maintainer is satisfied with that. +@end quotation + +As written, the regexp used for @code{FPAT} requires that each field +have a least one character. A straightforward modification +(changing changed the first @samp{+} to @samp{*}) allows fields to be empty: + +@example +FPAT = "([^,]*)|(\"[^\"]+\")" +@end example + +Finally, the @code{patsplit()} function makes the same functionality +available for splitting regular strings (@pxref{String Functions}). + +@node Multiple Line +@section Multiple-Line Records + +@c STARTOFRANGE recm +@cindex records, multiline +@c STARTOFRANGE imr +@cindex input, multiline records +@c STARTOFRANGE frm +@cindex files, reading, multiline records +@cindex input, files, See input files +In some databases, a single line cannot conveniently hold all the +information in one entry. In such cases, you can use multiline +records. The first step in doing this is to choose your data format. + +@cindex record separators, with multiline records +One technique is to use an unusual character or string to separate +records. For example, you could use the formfeed character (written +@samp{\f} in @command{awk}, as in C) to separate them, making each record +a page of the file. To do this, just set the variable @code{RS} to +@code{"\f"} (a string containing the formfeed character). Any +other character could equally well be used, as long as it won't be part +of the data in a record. + +@cindex @code{RS} variable, multiline records and +Another technique is to have blank lines separate records. By a special +dispensation, an empty string as the value of @code{RS} indicates that +records are separated by one or more blank lines. When @code{RS} is set +to the empty string, each record always ends at the first blank line +encountered. The next record doesn't start until the first nonblank +line that follows. No matter how many blank lines appear in a row, they +all act as one record separator. +(Blank lines must be completely empty; lines that contain only +whitespace do not count.) + +@cindex leftmost longest match +@cindex matching, leftmost longest +You can achieve the same effect as @samp{RS = ""} by assigning the +string @code{"\n\n+"} to @code{RS}. This regexp matches the newline +at the end of the record and one or more blank lines after the record. +In addition, a regular expression always matches the longest possible +sequence when there is a choice +(@pxref{Leftmost Longest}). +So the next record doesn't start until +the first nonblank line that follows---no matter how many blank lines +appear in a row, they are considered one record separator. + +@cindex dark corner, multiline records +There is an important difference between @samp{RS = ""} and +@samp{RS = "\n\n+"}. In the first case, leading newlines in the input +@value{DF} are ignored, and if a file ends without extra blank lines +after the last record, the final newline is removed from the record. +In the second case, this special processing is not done. +@value{DARKCORNER} + +@cindex field separators, in multiline records +Now that the input is separated into records, the second step is to +separate the fields in the record. One way to do this is to divide each +of the lines into fields in the normal manner. This happens by default +as the result of a special feature. When @code{RS} is set to the empty +string, @emph{and} @code{FS} is set to a single character, +the newline character @emph{always} acts as a field separator. +This is in addition to whatever field separations result from +@code{FS}.@footnote{When @code{FS} is the null string (@code{""}) +or a regexp, this special feature of @code{RS} does not apply. +It does apply to the default field separator of a single space: +@samp{FS = @w{" "}}.} + +The original motivation for this special exception was probably to provide +useful behavior in the default case (i.e., @code{FS} is equal +to @w{@code{" "}}). This feature can be a problem if you really don't +want the newline character to separate fields, because there is no way to +prevent it. However, you can work around this by using the @code{split()} +function to break up the record manually +(@pxref{String Functions}). +If you have a single character field separator, you can work around +the special feature in a different way, by making @code{FS} into a +regexp for that single character. For example, if the field +separator is a percent character, instead of +@samp{FS = "%"}, use @samp{FS = "[%]"}. + +Another way to separate fields is to +put each field on a separate line: to do this, just set the +variable @code{FS} to the string @code{"\n"}. (This single +character separator matches a single newline.) +A practical example of a @value{DF} organized this way might be a mailing +list, where each entry is separated by blank lines. Consider a mailing +list in a file named @file{addresses}, which looks like this: + +@example +Jane Doe +123 Main Street +Anywhere, SE 12345-6789 + +John Smith +456 Tree-lined Avenue +Smallville, MW 98765-4321 +@dots{} +@end example + +@noindent +A simple program to process this file is as follows: + +@example +# addrs.awk --- simple mailing list program + +# Records are separated by blank lines. +# Each line is one field. +BEGIN @{ RS = "" ; FS = "\n" @} + +@{ + print "Name is:", $1 + print "Address is:", $2 + print "City and State are:", $3 + print "" +@} +@end example + +Running the program produces the following output: + +@example +$ awk -f addrs.awk addresses +@print{} Name is: Jane Doe +@print{} Address is: 123 Main Street +@print{} City and State are: Anywhere, SE 12345-6789 +@print{} +@print{} Name is: John Smith +@print{} Address is: 456 Tree-lined Avenue +@print{} City and State are: Smallville, MW 98765-4321 +@print{} +@dots{} +@end example + +@xref{Labels Program}, for a more realistic +program that deals with address lists. +The following +table +summarizes how records are split, based on the +value of +@ifinfo +@code{RS}. +(@samp{==} means ``is equal to.'') +@end ifinfo +@ifnotinfo +@code{RS}: +@end ifnotinfo + +@table @code +@item RS == "\n" +Records are separated by the newline character (@samp{\n}). In effect, +every line in the @value{DF} is a separate record, including blank lines. +This is the default. + +@item RS == @var{any single character} +Records are separated by each occurrence of the character. Multiple +successive occurrences delimit empty records. + +@item RS == "" +Records are separated by runs of blank lines. +When @code{FS} is a single character, then +the newline character +always serves as a field separator, in addition to whatever value +@code{FS} may have. Leading and trailing newlines in a file are ignored. + +@item RS == @var{regexp} +Records are separated by occurrences of characters that match @var{regexp}. +Leading and trailing matches of @var{regexp} delimit empty records. +(This is a @command{gawk} extension; it is not specified by the +POSIX standard.) +@end table + +@cindex @command{gawk}, @code{RT} variable in +@cindex @code{RT} variable +In all cases, @command{gawk} sets @code{RT} to the input text that matched the +value specified by @code{RS}. +But if the input file ended without any text that matches @code{RS}, +then @command{gawk} sets @code{RT} to the null string. +@c ENDOFRANGE recm +@c ENDOFRANGE imr +@c ENDOFRANGE frm + +@node Getline +@section Explicit Input with @code{getline} + +@c STARTOFRANGE getl +@cindex @code{getline} command, explicit input with +@cindex input, explicit +So far we have been getting our input data from @command{awk}'s main +input stream---either the standard input (usually your terminal, sometimes +the output from another program) or from the +files specified on the command line. The @command{awk} language has a +special built-in command called @code{getline} that +can be used to read input under your explicit control. + +The @code{getline} command is used in several different ways and should +@emph{not} be used by beginners. +The examples that follow the explanation of the @code{getline} command +include material that has not been covered yet. Therefore, come back +and study the @code{getline} command @emph{after} you have reviewed the +rest of this @value{DOCUMENT} and have a good knowledge of how @command{awk} works. + +@cindex @command{gawk}, @code{ERRNO} variable in +@cindex @code{ERRNO} variable +@cindex differences in @command{awk} and @command{gawk}, @code{getline} command +@cindex @code{getline} command, return values +@cindex @code{--sandbox} option, input redirection with @command{getline} + +The @code{getline} command returns one if it finds a record and zero if +it encounters the end of the file. If there is some error in getting +a record, such as a file that cannot be opened, then @code{getline} +returns @minus{}1. In this case, @command{gawk} sets the variable +@code{ERRNO} to a string describing the error that occurred. + +In the following examples, @var{command} stands for a string value that +represents a shell command. + +@quotation NOTE +When @option{--sandbox} is specified (@pxref{Options}), +reading lines from files, pipes and coprocesses is disabled. +@end quotation + +@menu +* Plain Getline:: Using @code{getline} with no arguments. +* Getline/Variable:: Using @code{getline} into a variable. +* Getline/File:: Using @code{getline} from a file. +* Getline/Variable/File:: Using @code{getline} into a variable from a + file. +* Getline/Pipe:: Using @code{getline} from a pipe. +* Getline/Variable/Pipe:: Using @code{getline} into a variable from a + pipe. +* Getline/Coprocess:: Using @code{getline} from a coprocess. +* Getline/Variable/Coprocess:: Using @code{getline} into a variable from a + coprocess. +* Getline Notes:: Important things to know about @code{getline}. +* Getline Summary:: Summary of @code{getline} Variants. +@end menu + +@node Plain Getline +@subsection Using @code{getline} with No Arguments + +The @code{getline} command can be used without arguments to read input +from the current input file. All it does in this case is read the next +input record and split it up into fields. This is useful if you've +finished processing the current record, but want to do some special +processing on the next record @emph{right now}. For example: + +@example +@{ + if ((t = index($0, "/*")) != 0) @{ + # value of `tmp' will be "" if t is 1 + tmp = substr($0, 1, t - 1) + u = index(substr($0, t + 2), "*/") + offset = t + 2 + while (u == 0) @{ + if (getline <= 0) @{ + m = "unexpected EOF or error" + m = (m ": " ERRNO) + print m > "/dev/stderr" + exit + @} + u = index($0, "*/") + offset = 0 + @} + # substr() expression will be "" if */ + # occurred at end of line + $0 = tmp substr($0, offset + u + 2) + @} + print $0 +@} +@end example + +This @command{awk} program deletes C-style comments (@samp{/* @dots{} +*/}) from the input. By replacing the @samp{print $0} with other +statements, you could perform more complicated processing on the +decommented input, such as searching for matches of a regular +expression. (This program has a subtle problem---it does not work if one +comment ends and another begins on the same line.) + +@ignore +Exercise, +write a program that does handle multiple comments on the line. +@end ignore + +This form of the @code{getline} command sets @code{NF}, +@code{NR}, @code{FNR}, and the value of @code{$0}. + +@quotation NOTE +The new value of @code{$0} is used to test +the patterns of any subsequent rules. The original value +of @code{$0} that triggered the rule that executed @code{getline} +is lost. +By contrast, the @code{next} statement reads a new record +but immediately begins processing it normally, starting with the first +rule in the program. @xref{Next Statement}. +@end quotation + +@node Getline/Variable +@subsection Using @code{getline} into a Variable +@cindex variables, @code{getline} command into@comma{} using + +You can use @samp{getline @var{var}} to read the next record from +@command{awk}'s input into the variable @var{var}. No other processing is +done. +For example, suppose the next line is a comment or a special string, +and you want to read it without triggering +any rules. This form of @code{getline} allows you to read that line +and store it in a variable so that the main +read-a-line-and-check-each-rule loop of @command{awk} never sees it. +The following example swaps every two lines of input: + +@example +@{ + if ((getline tmp) > 0) @{ + print tmp + print $0 + @} else + print $0 +@} +@end example + +@noindent +It takes the following list: + +@example +wan +tew +free +phore +@end example + +@noindent +and produces these results: + +@example +tew +wan +phore +free +@end example + +The @code{getline} command used in this way sets only the variables +@code{NR} and @code{FNR} (and of course, @var{var}). The record is not +split into fields, so the values of the fields (including @code{$0}) and +the value of @code{NF} do not change. + +@node Getline/File +@subsection Using @code{getline} from a File + +@cindex input redirection +@cindex redirection of input +@cindex @code{<} (left angle bracket), @code{<} operator (I/O) +@cindex left angle bracket (@code{<}), @code{<} operator (I/O) +@cindex operators, input/output +Use @samp{getline < @var{file}} to read the next record from @var{file}. +Here @var{file} is a string-valued expression that +specifies the @value{FN}. @samp{< @var{file}} is called a @dfn{redirection} +because it directs input to come from a different place. +For example, the following +program reads its input record from the file @file{secondary.input} when it +encounters a first field with a value equal to 10 in the current input +file: + +@example +@{ + if ($1 == 10) @{ + getline < "secondary.input" + print + @} else + print +@} +@end example + +Because the main input stream is not used, the values of @code{NR} and +@code{FNR} are not changed. However, the record it reads is split into fields in +the normal manner, so the values of @code{$0} and the other fields are +changed, resulting in a new value of @code{NF}. + +@cindex POSIX @command{awk}, @code{<} operator and +@c Thanks to Paul Eggert for initial wording here +According to POSIX, @samp{getline < @var{expression}} is ambiguous if +@var{expression} contains unparenthesized operators other than +@samp{$}; for example, @samp{getline < dir "/" file} is ambiguous +because the concatenation operator is not parenthesized. You should +write it as @samp{getline < (dir "/" file)} if you want your program +to be portable to all @command{awk} implementations. + +@node Getline/Variable/File +@subsection Using @code{getline} into a Variable from a File +@cindex variables, @code{getline} command into@comma{} using + +Use @samp{getline @var{var} < @var{file}} to read input +from the file +@var{file}, and put it in the variable @var{var}. As above, @var{file} +is a string-valued expression that specifies the file from which to read. + +@cindex @command{gawk}, @code{RT} variable in +@cindex @code{RT} variable +In this version of @code{getline}, none of the built-in variables are +changed and the record is not split into fields. The only variable +changed is @var{var}.@footnote{This is not quite true. @code{RT} could +be changed if @code{RS} is a regular expression.} +For example, the following program copies all the input files to the +output, except for records that say @w{@samp{@@include @var{filename}}}. +Such a record is replaced by the contents of the file +@var{filename}: + +@example +@{ + if (NF == 2 && $1 == "@@include") @{ + while ((getline line < $2) > 0) + print line + close($2) + @} else + print +@} +@end example + +Note here how the name of the extra input file is not built into +the program; it is taken directly from the data, specifically from the second field on +the @samp{@@include} line. + +@cindex @code{close()} function +The @code{close()} function is called to ensure that if two identical +@samp{@@include} lines appear in the input, the entire specified file is +included twice. +@xref{Close Files And Pipes}. + +One deficiency of this program is that it does not process nested +@samp{@@include} statements +(i.e., @samp{@@include} statements in included files) +the way a true macro preprocessor would. +@xref{Igawk Program}, for a program +that does handle nested @samp{@@include} statements. + +@node Getline/Pipe +@subsection Using @code{getline} from a Pipe + +@cindex @code{|} (vertical bar), @code{|} operator (I/O) +@cindex vertical bar (@code{|}), @code{|} operator (I/O) +@cindex input pipeline +@cindex pipes, input +@cindex operators, input/output +The output of a command can also be piped into @code{getline}, using +@samp{@var{command} | getline}. In +this case, the string @var{command} is run as a shell command and its output +is piped into @command{awk} to be used as input. This form of @code{getline} +reads one record at a time from the pipe. +For example, the following program copies its input to its output, except for +lines that begin with @samp{@@execute}, which are replaced by the output +produced by running the rest of the line as a shell command: + +@example +@{ + if ($1 == "@@execute") @{ + tmp = substr($0, 10) # Remove "@@execute" + while ((tmp | getline) > 0) + print + close(tmp) + @} else + print +@} +@end example + +@noindent +@cindex @code{close()} function +The @code{close()} function is called to ensure that if two identical +@samp{@@execute} lines appear in the input, the command is run for +each one. +@ifnottex +@xref{Close Files And Pipes}. +@end ifnottex +@c Exercise!! +@c This example is unrealistic, since you could just use system +Given the input: + +@example +foo +bar +baz +@@execute who +bletch +@end example + +@noindent +the program might produce: + +@cindex Robbins, Bill +@cindex Robbins, Miriam +@cindex Robbins, Arnold +@example +foo +bar +baz +arnold ttyv0 Jul 13 14:22 +miriam ttyp0 Jul 13 14:23 (murphy:0) +bill ttyp1 Jul 13 14:23 (murphy:0) +bletch +@end example + +@noindent +Notice that this program ran the command @command{who} and printed the previous result. +(If you try this program yourself, you will of course get different results, +depending upon who is logged in on your system.) + +This variation of @code{getline} splits the record into fields, sets the +value of @code{NF}, and recomputes the value of @code{$0}. The values of +@code{NR} and @code{FNR} are not changed. + +@cindex POSIX @command{awk}, @code{|} I/O operator and +@c Thanks to Paul Eggert for initial wording here +According to POSIX, @samp{@var{expression} | getline} is ambiguous if +@var{expression} contains unparenthesized operators other than +@samp{$}---for example, @samp{@w{"echo "} "date" | getline} is ambiguous +because the concatenation operator is not parenthesized. You should +write it as @samp{(@w{"echo "} "date") | getline} if you want your program +to be portable to all @command{awk} implementations. + +@quotation NOTE +Unfortunately, @command{gawk} has not been consistent in its treatment +of a construct like @samp{@w{"echo "} "date" | getline}. +Most versions, including the current version, treat it at as +@samp{@w{("echo "} "date") | getline}. +(This how Brian Kernighan's @command{awk} behaves.) +Some versions changed and treated it as +@samp{@w{"echo "} ("date" | getline)}. +(This is how @command{mawk} behaves.) +In short, @emph{always} use explicit parentheses, and then you won't +have to worry. +@end quotation + +@node Getline/Variable/Pipe +@subsection Using @code{getline} into a Variable from a Pipe +@cindex variables, @code{getline} command into@comma{} using + +When you use @samp{@var{command} | getline @var{var}}, the +output of @var{command} is sent through a pipe to +@code{getline} and into the variable @var{var}. For example, the +following program reads the current date and time into the variable +@code{current_time}, using the @command{date} utility, and then +prints it: + +@example +BEGIN @{ + "date" | getline current_time + close("date") + print "Report printed on " current_time +@} +@end example + +In this version of @code{getline}, none of the built-in variables are +changed and the record is not split into fields. + +@ifinfo +@c Thanks to Paul Eggert for initial wording here +According to POSIX, @samp{@var{expression} | getline @var{var}} is ambiguous if +@var{expression} contains unparenthesized operators other than +@samp{$}; for example, @samp{@w{"echo "} "date" | getline @var{var}} is ambiguous +because the concatenation operator is not parenthesized. You should +write it as @samp{(@w{"echo "} "date") | getline @var{var}} if you want your +program to be portable to other @command{awk} implementations. +@end ifinfo + +@node Getline/Coprocess +@subsection Using @code{getline} from a Coprocess +@cindex coprocesses, @code{getline} from +@cindex @code{getline} command, coprocesses@comma{} using from +@cindex @code{|} (vertical bar), @code{|&} operator (I/O) +@cindex vertical bar (@code{|}), @code{|&} operator (I/O) +@cindex operators, input/output +@cindex differences in @command{awk} and @command{gawk}, input/output operators + +Input into @code{getline} from a pipe is a one-way operation. +The command that is started with @samp{@var{command} | getline} only +sends data @emph{to} your @command{awk} program. + +On occasion, you might want to send data to another program +for processing and then read the results back. +@command{gawk} allows you to start a @dfn{coprocess}, with which two-way +communications are possible. This is done with the @samp{|&} +operator. +Typically, you write data to the coprocess first and then +read results back, as shown in the following: + +@example +print "@var{some query}" |& "db_server" +"db_server" |& getline +@end example + +@noindent +which sends a query to @command{db_server} and then reads the results. + +The values of @code{NR} and +@code{FNR} are not changed, +because the main input stream is not used. +However, the record is split into fields in +the normal manner, thus changing the values of @code{$0}, of the other fields, +and of @code{NF}. + +Coprocesses are an advanced feature. They are discussed here only because +this is the @value{SECTION} on @code{getline}. +@xref{Two-way I/O}, +where coprocesses are discussed in more detail. + +@node Getline/Variable/Coprocess +@subsection Using @code{getline} into a Variable from a Coprocess +@cindex variables, @code{getline} command into@comma{} using + +When you use @samp{@var{command} |& getline @var{var}}, the output from +the coprocess @var{command} is sent through a two-way pipe to @code{getline} +and into the variable @var{var}. + +In this version of @code{getline}, none of the built-in variables are +changed and the record is not split into fields. The only variable +changed is @var{var}. + +@ifinfo +Coprocesses are an advanced feature. They are discussed here only because +this is the @value{SECTION} on @code{getline}. +@xref{Two-way I/O}, +where coprocesses are discussed in more detail. +@end ifinfo + +@node Getline Notes +@subsection Points to Remember About @code{getline} +Here are some miscellaneous points about @code{getline} that +you should bear in mind: + +@itemize @bullet +@item +When @code{getline} changes the value of @code{$0} and @code{NF}, +@command{awk} does @emph{not} automatically jump to the start of the +program and start testing the new record against every pattern. +However, the new record is tested against any subsequent rules. + +@cindex differences in @command{awk} and @command{gawk}, implementation limitations +@cindex implementation issues, @command{gawk}, limits +@cindex @command{awk}, implementations, limits +@cindex @command{gawk}, implementation issues, limits +@item +Many @command{awk} implementations limit the number of pipelines that an @command{awk} +program may have open to just one. In @command{gawk}, there is no such limit. +You can open as many pipelines (and coprocesses) as the underlying operating +system permits. + +@cindex side effects, @code{FILENAME} variable +@cindex @code{FILENAME} variable, @code{getline}@comma{} setting with +@cindex dark corner, @code{FILENAME} variable +@cindex @code{getline} command, @code{FILENAME} variable and +@cindex @code{BEGIN} pattern, @code{getline} and +@item +An interesting side effect occurs if you use @code{getline} without a +redirection inside a @code{BEGIN} rule. Because an unredirected @code{getline} +reads from the command-line @value{DF}s, the first @code{getline} command +causes @command{awk} to set the value of @code{FILENAME}. Normally, +@code{FILENAME} does not have a value inside @code{BEGIN} rules, because you +have not yet started to process the command-line @value{DF}s. +@value{DARKCORNER} +(@xref{BEGIN/END}, +also @pxref{Auto-set}.) + +@item +Using @code{FILENAME} with @code{getline} +(@samp{getline < FILENAME}) +is likely to be a source for +confusion. @command{awk} opens a separate input stream from the +current input file. However, by not using a variable, @code{$0} +and @code{NR} are still updated. If you're doing this, it's +probably by accident, and you should reconsider what it is you're +trying to accomplish. + +@item +@ref{Getline Summary}, presents a table summarizing the +@code{getline} variants and which variables they can affect. +It is worth noting that those variants which do not use redirection +can cause @code{FILENAME} to be updated if they cause +@command{awk} to start reading a new input file. +@end itemize + +@node Getline Summary +@subsection Summary of @code{getline} Variants +@cindex @code{getline} command, variants + +@ref{table-getline-variants} +summarizes the eight variants of @code{getline}, +listing which built-in variables are set by each one, +and whether the variant is standard or a @command{gawk} extension. + +@float Table,table-getline-variants +@caption{getline Variants and What They Set} +@multitable @columnfractions .33 .38 .27 +@headitem Variant @tab Effect @tab Standard / Extension +@item @code{getline} @tab Sets @code{$0}, @code{NF}, @code{FNR}, and @code{NR} @tab Standard +@item @code{getline} @var{var} @tab Sets @var{var}, @code{FNR}, and @code{NR} @tab Standard +@item @code{getline <} @var{file} @tab Sets @code{$0} and @code{NF} @tab Standard +@item @code{getline @var{var} < @var{file}} @tab Sets @var{var} @tab Standard +@item @var{command} @code{| getline} @tab Sets @code{$0} and @code{NF} @tab Standard +@item @var{command} @code{| getline} @var{var} @tab Sets @var{var} @tab Standard +@item @var{command} @code{|& getline} @tab Sets @code{$0} and @code{NF} @tab Extension +@item @var{command} @code{|& getline} @var{var} @tab Sets @var{var} @tab Extension +@end multitable +@end float +@c ENDOFRANGE getl +@c ENDOFRANGE inex +@c ENDOFRANGE infir + +@node Command line directories +@section Directories On The Command Line +@cindex directories, command line +@cindex command line, directories on + +According to the POSIX standard, files named on the @command{awk} +command line must be text files. It is a fatal error if they are not. +Most versions of @command{awk} treat a directory on the command line as +a fatal error. + +By default, @command{gawk} produces a warning for a directory on the +command line, but otherwise ignores it. If either of the @option{--posix} +or @option{--traditional} options is given, then @command{gawk} reverts +to treating a directory on the command line as a fatal error. + +@node Printing +@chapter Printing Output + +@c STARTOFRANGE prnt +@cindex printing +@cindex output, printing, See printing +One of the most common programming actions is to @dfn{print}, or output, +some or all of the input. Use the @code{print} statement +for simple output, and the @code{printf} statement +for fancier formatting. +The @code{print} statement is not limited when +computing @emph{which} values to print. However, with two exceptions, +you cannot specify @emph{how} to print them---how many +columns, whether to use exponential notation or not, and so on. +(For the exceptions, @pxref{Output Separators}, and +@ref{OFMT}.) +For printing with specifications, you need the @code{printf} statement +(@pxref{Printf}). + +@c STARTOFRANGE prnts +@cindex @code{print} statement +@cindex @code{printf} statement +Besides basic and formatted printing, this @value{CHAPTER} +also covers I/O redirections to files and pipes, introduces +the special @value{FN}s that @command{gawk} processes internally, +and discusses the @code{close()} built-in function. + +@menu +* Print:: The @code{print} statement. +* Print Examples:: Simple examples of @code{print} statements. +* Output Separators:: The output separators and how to change them. +* OFMT:: Controlling Numeric Output With @code{print}. +* Printf:: The @code{printf} statement. +* Redirection:: How to redirect output to multiple files and + pipes. +* Special Files:: File name interpretation in @command{gawk}. + @command{gawk} allows access to inherited file + descriptors. +* Close Files And Pipes:: Closing Input and Output Files and Pipes. +@end menu + +@node Print +@section The @code{print} Statement + +The @code{print} statement is used for producing output with simple, standardized +formatting. Specify only the strings or numbers to print, in a +list separated by commas. They are output, separated by single spaces, +followed by a newline. The statement looks like this: + +@example +print @var{item1}, @var{item2}, @dots{} +@end example + +@noindent +The entire list of items may be optionally enclosed in parentheses. The +parentheses are necessary if any of the item expressions uses the @samp{>} +relational operator; otherwise it could be confused with an output redirection +(@pxref{Redirection}). + +The items to print can be constant strings or numbers, fields of the +current record (such as @code{$1}), variables, or any @command{awk} +expression. Numeric values are converted to strings and then printed. + +@cindex records, printing +@cindex lines, blank, printing +@cindex text, printing +The simple statement @samp{print} with no items is equivalent to +@samp{print $0}: it prints the entire current record. To print a blank +line, use @samp{print ""}, where @code{""} is the empty string. +To print a fixed piece of text, use a string constant, such as +@w{@code{"Don't Panic"}}, as one item. If you forget to use the +double-quote characters, your text is taken as an @command{awk} +expression, and you will probably get an error. Keep in mind that a +space is printed between any two items. + +@node Print Examples +@section @code{print} Statement Examples + +Each @code{print} statement makes at least one line of output. However, it +isn't limited to only one line. If an item value is a string containing a +newline, the newline is output along with the rest of the string. A +single @code{print} statement can make any number of lines this way. + +@cindex newlines, printing +The following is an example of printing a string that contains embedded newlines +(the @samp{\n} is an escape sequence, used to represent the newline +character; @pxref{Escape Sequences}): + +@example +$ @kbd{awk 'BEGIN @{ print "line one\nline two\nline three" @}'} +@print{} line one +@print{} line two +@print{} line three +@end example + +@cindex fields, printing +The next example, which is run on the @file{inventory-shipped} file, +prints the first two fields of each input record, with a space between +them: + +@example +$ @kbd{awk '@{ print $1, $2 @}' inventory-shipped} +@print{} Jan 13 +@print{} Feb 15 +@print{} Mar 15 +@dots{} +@end example + +@cindex @code{print} statement, commas, omitting +@cindex troubleshooting, @code{print} statement@comma{} omitting commas +A common mistake in using the @code{print} statement is to omit the comma +between two items. This often has the effect of making the items run +together in the output, with no space. The reason for this is that +juxtaposing two string expressions in @command{awk} means to concatenate +them. Here is the same program, without the comma: + +@example +$ @kbd{awk '@{ print $1 $2 @}' inventory-shipped} +@print{} Jan13 +@print{} Feb15 +@print{} Mar15 +@dots{} +@end example + +@cindex @code{BEGIN} pattern, headings@comma{} adding +To someone unfamiliar with the @file{inventory-shipped} file, neither +example's output makes much sense. A heading line at the beginning +would make it clearer. Let's add some headings to our table of months +(@code{$1}) and green crates shipped (@code{$2}). We do this using the +@code{BEGIN} pattern +(@pxref{BEGIN/END}) +so that the headings are only printed once: + +@example +awk 'BEGIN @{ print "Month Crates" + print "----- ------" @} + @{ print $1, $2 @}' inventory-shipped +@end example + +@noindent +When run, the program prints the following: + +@example +Month Crates +----- ------ +Jan 13 +Feb 15 +Mar 15 +@dots{} +@end example + +@noindent +The only problem, however, is that the headings and the table data +don't line up! We can fix this by printing some spaces between the +two fields: + +@example +@group +awk 'BEGIN @{ print "Month Crates" + print "----- ------" @} + @{ print $1, " ", $2 @}' inventory-shipped +@end group +@end example + +@cindex @code{printf} statement, columns@comma{} aligning +@cindex columns, aligning +Lining up columns this way can get pretty +complicated when there are many columns to fix. Counting spaces for two +or three columns is simple, but any more than this can take up +a lot of time. This is why the @code{printf} statement was +created (@pxref{Printf}); +one of its specialties is lining up columns of data. + +@cindex line continuations, in @code{print} statement +@cindex @code{print} statement, line continuations and +@quotation NOTE +You can continue either a @code{print} or +@code{printf} statement simply by putting a newline after any comma +(@pxref{Statements/Lines}). +@end quotation +@c ENDOFRANGE prnts + +@node Output Separators +@section Output Separators + +@cindex @code{OFS} variable +As mentioned previously, a @code{print} statement contains a list +of items separated by commas. In the output, the items are normally +separated by single spaces. However, this doesn't need to be the case; +a single space is simply the default. Any string of +characters may be used as the @dfn{output field separator} by setting the +built-in variable @code{OFS}. The initial value of this variable +is the string @w{@code{" "}}---that is, a single space. + +The output from an entire @code{print} statement is called an +@dfn{output record}. Each @code{print} statement outputs one output +record, and then outputs a string called the @dfn{output record separator} +(or @code{ORS}). The initial +value of @code{ORS} is the string @code{"\n"}; i.e., a newline +character. Thus, each @code{print} statement normally makes a separate line. + +@cindex output, records +@cindex output record separator, See @code{ORS} variable +@cindex @code{ORS} variable +@cindex @code{BEGIN} pattern, @code{OFS}/@code{ORS} variables, assigning values to +In order to change how output fields and records are separated, assign +new values to the variables @code{OFS} and @code{ORS}. The usual +place to do this is in the @code{BEGIN} rule +(@pxref{BEGIN/END}), so +that it happens before any input is processed. It can also be done +with assignments on the command line, before the names of the input +files, or using the @option{-v} command-line option +(@pxref{Options}). +The following example prints the first and second fields of each input +record, separated by a semicolon, with a blank line added after each +newline: + +@ignore +Exercise, +Rewrite the +@example +awk 'BEGIN @{ print "Month Crates" + print "----- ------" @} + @{ print $1, " ", $2 @}' inventory-shipped +@end example +program by using a new value of @code{OFS}. +@end ignore + +@example +$ @kbd{awk 'BEGIN @{ OFS = ";"; ORS = "\n\n" @}} +> @kbd{@{ print $1, $2 @}' BBS-list} +@print{} aardvark;555-5553 +@print{} +@print{} alpo-net;555-3412 +@print{} +@print{} barfly;555-7685 +@dots{} +@end example + +If the value of @code{ORS} does not contain a newline, the program's output +runs together on a single line. + +@node OFMT +@section Controlling Numeric Output with @code{print} +@cindex numeric, output format +@cindex formats@comma{} numeric output +When printing numeric values with the @code{print} statement, +@command{awk} internally converts the number to a string of characters +and prints that string. @command{awk} uses the @code{sprintf()} function +to do this conversion +(@pxref{String Functions}). +For now, it suffices to say that the @code{sprintf()} +function accepts a @dfn{format specification} that tells it how to format +numbers (or strings), and that there are a number of different ways in which +numbers can be formatted. The different format specifications are discussed +more fully in +@ref{Control Letters}. + +@cindex @code{sprintf()} function +@cindex @code{OFMT} variable +@cindex output, format specifier@comma{} @code{OFMT} +The built-in variable @code{OFMT} contains the default format specification +that @code{print} uses with @code{sprintf()} when it wants to convert a +number to a string for printing. +The default value of @code{OFMT} is @code{"%.6g"}. +The way @code{print} prints numbers can be changed +by supplying different format specifications +as the value of @code{OFMT}, as shown in the following example: + +@example +$ @kbd{awk 'BEGIN @{} +> @kbd{OFMT = "%.0f" # print numbers as integers (rounds)} +> @kbd{print 17.23, 17.54 @}'} +@print{} 17 18 +@end example + +@noindent +@cindex dark corner, @code{OFMT} variable +@cindex POSIX @command{awk}, @code{OFMT} variable and +@cindex @code{OFMT} variable, POSIX @command{awk} and +According to the POSIX standard, @command{awk}'s behavior is undefined +if @code{OFMT} contains anything but a floating-point conversion specification. +@value{DARKCORNER} + +@node Printf +@section Using @code{printf} Statements for Fancier Printing + +@c STARTOFRANGE printfs +@cindex @code{printf} statement +@cindex output, formatted +@cindex formatting output +For more precise control over the output format than what is +provided by @code{print}, use @code{printf}. +With @code{printf} you can +specify the width to use for each item, as well as various +formatting choices for numbers (such as what output base to use, whether to +print an exponent, whether to print a sign, and how many digits to print +after the decimal point). You do this by supplying a string, called +the @dfn{format string}, that controls how and where to print the other +arguments. + +@menu +* Basic Printf:: Syntax of the @code{printf} statement. +* Control Letters:: Format-control letters. +* Format Modifiers:: Format-specification modifiers. +* Printf Examples:: Several examples. +@end menu + +@node Basic Printf +@subsection Introduction to the @code{printf} Statement + +@cindex @code{printf} statement, syntax of +A simple @code{printf} statement looks like this: + +@example +printf @var{format}, @var{item1}, @var{item2}, @dots{} +@end example + +@noindent +The entire list of arguments may optionally be enclosed in parentheses. The +parentheses are necessary if any of the item expressions use the @samp{>} +relational operator; otherwise, it can be confused with an output redirection +(@pxref{Redirection}). + +@cindex format strings +The difference between @code{printf} and @code{print} is the @var{format} +argument. This is an expression whose value is taken as a string; it +specifies how to output each of the other arguments. It is called the +@dfn{format string}. + +The format string is very similar to that in the ISO C library function +@code{printf()}. Most of @var{format} is text to output verbatim. +Scattered among this text are @dfn{format specifiers}---one per item. +Each format specifier says to output the next item in the argument list +at that place in the format. + +The @code{printf} statement does not automatically append a newline +to its output. It outputs only what the format string specifies. +So if a newline is needed, you must include one in the format string. +The output separator variables @code{OFS} and @code{ORS} have no effect +on @code{printf} statements. For example: + +@example +$ @kbd{awk 'BEGIN @{} +> @kbd{ORS = "\nOUCH!\n"; OFS = "+"} +> @kbd{msg = "Dont Panic!"} +> @kbd{printf "%s\n", msg} +> @kbd{@}'} +@print{} Dont Panic! +@end example + +@noindent +Here, neither the @samp{+} nor the @samp{OUCH} appear in +the output message. + +@node Control Letters +@subsection Format-Control Letters +@cindex @code{printf} statement, format-control characters +@cindex format specifiers, @code{printf} statement + +A format specifier starts with the character @samp{%} and ends with +a @dfn{format-control letter}---it tells the @code{printf} statement +how to output one item. The format-control letter specifies what @emph{kind} +of value to print. The rest of the format specifier is made up of +optional @dfn{modifiers} that control @emph{how} to print the value, such as +the field width. Here is a list of the format-control letters: + +@table @code +@item %c +Print a number as an ASCII character; thus, @samp{printf "%c", +65} outputs the letter @samp{A}. The output for a string value is +the first character of the string. + +@cindex dark corner, format-control characters +@cindex @command{gawk}, format-control characters +@quotation NOTE +@ignore +The @samp{%c} format does @emph{not} handle values outside the range +0--255. On most systems, values from 0--127 are within the range of +ASCII and will yield an ASCII character. Values in the range 128--255 +may format as characters in some extended character set, or they may not. +System 390 (IBM architecture mainframe) systems use 8-bit characters, +and thus values from 0--255 yield the corresponding EBCDIC character. +Any value above 255 is treated as modulo 255; i.e., the lowest eight bits +of the value are used. The locale and character set are always ignored. +@end ignore +The POSIX standard says the first character of a string is printed. +In locales with multibyte characters, @command{gawk} attempts to +convert the leading bytes of the string into a valid wide character +and then to print the multibyte encoding of that character. +Similarly, when printing a numeric value, @command{gawk} allows the +value to be within the numeric range of values that can be held +in a wide character. + +Other @command{awk} versions generally restrict themselves to printing +the first byte of a string or to numeric values within the range of +a single byte (0--255). +@end quotation + + +@item %d@r{,} %i +Print a decimal integer. +The two control letters are equivalent. +(The @samp{%i} specification is for compatibility with ISO C.) + +@item %e@r{,} %E +Print a number in scientific (exponential) notation; +for example: + +@example +printf "%4.3e\n", 1950 +@end example + +@noindent +prints @samp{1.950e+03}, with a total of four significant figures, three of +which follow the decimal point. +(The @samp{4.3} represents two modifiers, +discussed in the next @value{SUBSECTION}.) +@samp{%E} uses @samp{E} instead of @samp{e} in the output. + +@item %f +Print a number in floating-point notation. +For example: + +@example +printf "%4.3f", 1950 +@end example + +@noindent +prints @samp{1950.000}, with a total of four significant figures, three of +which follow the decimal point. +(The @samp{4.3} represents two modifiers, +discussed in the next @value{SUBSECTION}.) + +On systems supporting IEEE 754 floating point format, values +representing negative +infinity are formatted as +@samp{-inf} or @samp{-infinity}, +and positive infinity as +@samp{inf} and @samp{infinity}. +The special ``not a number'' value formats as @samp{-nan} or @samp{nan}. + +@item %F +Like @samp{%f} but the infinity and ``not a number'' values are spelled +using uppercase letters. + +The @samp{%F} format is a POSIX extension to ISO C; not all systems +support it. On those that don't, @command{gawk} uses @samp{%f} instead. + +@item %g@r{,} %G +Print a number in either scientific notation or in floating-point +notation, whichever uses fewer characters; if the result is printed in +scientific notation, @samp{%G} uses @samp{E} instead of @samp{e}. + +@item %o +Print an unsigned octal integer +(@pxref{Nondecimal-numbers}). + +@item %s +Print a string. + +@item %u +Print an unsigned decimal integer. +(This format is of marginal use, because all numbers in @command{awk} +are floating-point; it is provided primarily for compatibility with C.) + +@item %x@r{,} %X +Print an unsigned hexadecimal integer; +@samp{%X} uses the letters @samp{A} through @samp{F} +instead of @samp{a} through @samp{f} +(@pxref{Nondecimal-numbers}). + +@item %% +Print a single @samp{%}. +This does not consume an +argument and it ignores any modifiers. +@end table + +@cindex dark corner, format-control characters +@cindex @command{gawk}, format-control characters +@quotation NOTE +When using the integer format-control letters for values that are +outside the range of the widest C integer type, @command{gawk} switches to +the @samp{%g} format specifier. If @option{--lint} is provided on the +command line (@pxref{Options}), @command{gawk} +warns about this. Other versions of @command{awk} may print invalid +values or do something else entirely. +@value{DARKCORNER} +@end quotation + +@node Format Modifiers +@subsection Modifiers for @code{printf} Formats + +@c STARTOFRANGE pfm +@cindex @code{printf} statement, modifiers +@cindex modifiers@comma{} in format specifiers +A format specification can also include @dfn{modifiers} that can control +how much of the item's value is printed, as well as how much space it gets. +The modifiers come between the @samp{%} and the format-control letter. +We will use the bullet symbol ``@bullet{}'' in the following examples to +represent +spaces in the output. Here are the possible modifiers, in the order in +which they may appear: + +@table @code +@cindex differences in @command{awk} and @command{gawk}, @code{print}/@code{printf} statements +@cindex @code{printf} statement, positional specifiers +@c the command does NOT start a secondary +@cindex positional specifiers, @code{printf} statement +@item @var{N}$ +An integer constant followed by a @samp{$} is a @dfn{positional specifier}. +Normally, format specifications are applied to arguments in the order +given in the format string. With a positional specifier, the format +specification is applied to a specific argument, instead of what +would be the next argument in the list. Positional specifiers begin +counting with one. Thus: + +@example +printf "%s %s\n", "don't", "panic" +printf "%2$s %1$s\n", "panic", "don't" +@end example + +@noindent +prints the famous friendly message twice. + +At first glance, this feature doesn't seem to be of much use. +It is in fact a @command{gawk} extension, intended for use in translating +messages at runtime. +@xref{Printf Ordering}, +which describes how and why to use positional specifiers. +For now, we will not use them. + +@item - +The minus sign, used before the width modifier (see later on in +this list), +says to left-justify +the argument within its specified width. Normally, the argument +is printed right-justified in the specified width. Thus: + +@example +printf "%-4s", "foo" +@end example + +@noindent +prints @samp{foo@bullet{}}. + +@item @var{space} +For numeric conversions, prefix positive values with a space and +negative values with a minus sign. + +@item + +The plus sign, used before the width modifier (see later on in +this list), +says to always supply a sign for numeric conversions, even if the data +to format is positive. The @samp{+} overrides the space modifier. + +@item # +Use an ``alternate form'' for certain control letters. +For @samp{%o}, supply a leading zero. +For @samp{%x} and @samp{%X}, supply a leading @samp{0x} or @samp{0X} for +a nonzero result. +For @samp{%e}, @samp{%E}, @samp{%f}, and @samp{%F}, the result always +contains a decimal point. +For @samp{%g} and @samp{%G}, trailing zeros are not removed from the result. + +@item 0 +A leading @samp{0} (zero) acts as a flag that indicates that output should be +padded with zeros instead of spaces. +This applies only to the numeric output formats. +This flag only has an effect when the field width is wider than the +value to print. + +@item ' +A single quote or apostrophe character is a POSIX extension to ISO C. +It indicates that the integer part of a floating point value, or the +entire part of an integer decimal value, should have a thousands-separator +character in it. This only works in locales that support such characters. +For example: + +@example +$ @kbd{cat thousands.awk} @ii{Show source program} +@print{} BEGIN @{ printf "%'d\n", 1234567 @} +$ @kbd{LC_ALL=C gawk -f thousands.awk} +@print{} 1234567 @ii{Results in "C" locale} +$ @kbd{LC_ALL=en_US.UTF-8 gawk -f thousands.awk} +@print{} 1,234,567 @ii{Results in US English UTF locale} +@end example + +@noindent +For more information about locales and internationalization issues, +see @ref{Locales}. + +@quotation NOTE +The @samp{'} flag is a nice feature, but its use complicates things: it +becomes difficult to use it in command-line programs. For information +on appropriate quoting tricks, see @ref{Quoting}. +@end quotation + +@item @var{width} +This is a number specifying the desired minimum width of a field. Inserting any +number between the @samp{%} sign and the format-control character forces the +field to expand to this width. The default way to do this is to +pad with spaces on the left. For example: + +@example +printf "%4s", "foo" +@end example + +@noindent +prints @samp{@bullet{}foo}. + +The value of @var{width} is a minimum width, not a maximum. If the item +value requires more than @var{width} characters, it can be as wide as +necessary. Thus, the following: + +@example +printf "%4s", "foobar" +@end example + +@noindent +prints @samp{foobar}. + +Preceding the @var{width} with a minus sign causes the output to be +padded with spaces on the right, instead of on the left. + +@item .@var{prec} +A period followed by an integer constant +specifies the precision to use when printing. +The meaning of the precision varies by control letter: + +@table @asis +@item @code{%d}, @code{%i}, @code{%o}, @code{%u}, @code{%x}, @code{%X} +Minimum number of digits to print. + +@item @code{%e}, @code{%E}, @code{%f}, @code{%F} +Number of digits to the right of the decimal point. + +@item @code{%g}, @code{%G} +Maximum number of significant digits. + +@item @code{%s} +Maximum number of characters from the string that should print. +@end table + +Thus, the following: + +@example +printf "%.4s", "foobar" +@end example + +@noindent +prints @samp{foob}. +@end table + +The C library @code{printf}'s dynamic @var{width} and @var{prec} +capability (for example, @code{"%*.*s"}) is supported. Instead of +supplying explicit @var{width} and/or @var{prec} values in the format +string, they are passed in the argument list. For example: + +@example +w = 5 +p = 3 +s = "abcdefg" +printf "%*.*s\n", w, p, s +@end example + +@noindent +is exactly equivalent to: + +@example +s = "abcdefg" +printf "%5.3s\n", s +@end example + +@noindent +Both programs output @samp{@w{@bullet{}@bullet{}abc}}. +Earlier versions of @command{awk} did not support this capability. +If you must use such a version, you may simulate this feature by using +concatenation to build up the format string, like so: + +@example +w = 5 +p = 3 +s = "abcdefg" +printf "%" w "." p "s\n", s +@end example + +@noindent +This is not particularly easy to read but it does work. + +@c @cindex lint checks +@cindex troubleshooting, fatal errors, @code{printf} format strings +@cindex POSIX @command{awk}, @code{printf} format strings and +C programmers may be used to supplying additional +@samp{l}, @samp{L}, and @samp{h} +modifiers in @code{printf} format strings. These are not valid in @command{awk}. +Most @command{awk} implementations silently ignore them. +If @option{--lint} is provided on the command line +(@pxref{Options}), +@command{gawk} warns about their use. If @option{--posix} is supplied, +their use is a fatal error. +@c ENDOFRANGE pfm + +@node Printf Examples +@subsection Examples Using @code{printf} + +The following simple example shows +how to use @code{printf} to make an aligned table: + +@example +awk '@{ printf "%-10s %s\n", $1, $2 @}' BBS-list +@end example + +@noindent +This command +prints the names of the bulletin boards (@code{$1}) in the file +@file{BBS-list} as a string of 10 characters that are left-justified. It also +prints the phone numbers (@code{$2}) next on the line. This +produces an aligned two-column table of names and phone numbers, +as shown here: + +@example +$ @kbd{awk '@{ printf "%-10s %s\n", $1, $2 @}' BBS-list} +@print{} aardvark 555-5553 +@print{} alpo-net 555-3412 +@print{} barfly 555-7685 +@print{} bites 555-1675 +@print{} camelot 555-0542 +@print{} core 555-2912 +@print{} fooey 555-1234 +@print{} foot 555-6699 +@print{} macfoo 555-6480 +@print{} sdace 555-3430 +@print{} sabafoo 555-2127 +@end example + +In this case, the phone numbers had to be printed as strings because +the numbers are separated by a dash. Printing the phone numbers as +numbers would have produced just the first three digits: @samp{555}. +This would have been pretty confusing. + +It wasn't necessary to specify a width for the phone numbers because +they are last on their lines. They don't need to have spaces +after them. + +The table could be made to look even nicer by adding headings to the +tops of the columns. This is done using the @code{BEGIN} pattern +(@pxref{BEGIN/END}) +so that the headers are only printed once, at the beginning of +the @command{awk} program: + +@example +awk 'BEGIN @{ print "Name Number" + print "---- ------" @} + @{ printf "%-10s %s\n", $1, $2 @}' BBS-list +@end example + +The above example mixes @code{print} and @code{printf} statements in +the same program. Using just @code{printf} statements can produce the +same results: + +@example +awk 'BEGIN @{ printf "%-10s %s\n", "Name", "Number" + printf "%-10s %s\n", "----", "------" @} + @{ printf "%-10s %s\n", $1, $2 @}' BBS-list +@end example + +@noindent +Printing each column heading with the same format specification +used for the column elements ensures that the headings +are aligned just like the columns. + +The fact that the same format specification is used three times can be +emphasized by storing it in a variable, like this: + +@example +awk 'BEGIN @{ format = "%-10s %s\n" + printf format, "Name", "Number" + printf format, "----", "------" @} + @{ printf format, $1, $2 @}' BBS-list +@end example + +@c !!! exercise +At this point, it would be a worthwhile exercise to use the +@code{printf} statement to line up the headings and table data for the +@file{inventory-shipped} example that was covered earlier in the @value{SECTION} +on the @code{print} statement +(@pxref{Print}). +@c ENDOFRANGE printfs + +@node Redirection +@section Redirecting Output of @code{print} and @code{printf} + +@cindex output redirection +@cindex redirection of output +@cindex @code{--sandbox} option, output redirection with @code{print}, @code{printf} +So far, the output from @code{print} and @code{printf} has gone +to the standard +output, usually the screen. Both @code{print} and @code{printf} can +also send their output to other places. +This is called @dfn{redirection}. + +@quotation NOTE +When @option{--sandbox} is specified (@pxref{Options}), +redirecting output to files and pipes is disabled. +@end quotation + +A redirection appears after the @code{print} or @code{printf} statement. +Redirections in @command{awk} are written just like redirections in shell +commands, except that they are written inside the @command{awk} program. + +@c the commas here are part of the see also +@cindex @code{print} statement, See Also redirection, of output +@cindex @code{printf} statement, See Also redirection, of output +There are four forms of output redirection: output to a file, output +appended to a file, output through a pipe to another command, and output +to a coprocess. They are all shown for the @code{print} statement, +but they work identically for @code{printf}: + +@table @code +@cindex @code{>} (right angle bracket), @code{>} operator (I/O) +@cindex right angle bracket (@code{>}), @code{>} operator (I/O) +@cindex operators, input/output +@item print @var{items} > @var{output-file} +This redirection prints the items into the output file named +@var{output-file}. The @value{FN} @var{output-file} can be any +expression. Its value is changed to a string and then used as a +@value{FN} (@pxref{Expressions}). + +When this type of redirection is used, the @var{output-file} is erased +before the first output is written to it. Subsequent writes to the same +@var{output-file} do not erase @var{output-file}, but append to it. +(This is different from how you use redirections in shell scripts.) +If @var{output-file} does not exist, it is created. For example, here +is how an @command{awk} program can write a list of BBS names to one +file named @file{name-list}, and a list of phone numbers to another file +named @file{phone-list}: + +@example +$ @kbd{awk '@{ print $2 > "phone-list"} +> @kbd{print $1 > "name-list" @}' BBS-list} +$ @kbd{cat phone-list} +@print{} 555-5553 +@print{} 555-3412 +@dots{} +$ @kbd{cat name-list} +@print{} aardvark +@print{} alpo-net +@dots{} +@end example + +@noindent +Each output file contains one name or number per line. + +@cindex @code{>} (right angle bracket), @code{>>} operator (I/O) +@cindex right angle bracket (@code{>}), @code{>>} operator (I/O) +@item print @var{items} >> @var{output-file} +This redirection prints the items into the pre-existing output file +named @var{output-file}. The difference between this and the +single-@samp{>} redirection is that the old contents (if any) of +@var{output-file} are not erased. Instead, the @command{awk} output is +appended to the file. +If @var{output-file} does not exist, then it is created. + +@cindex @code{|} (vertical bar), @code{|} operator (I/O) +@cindex pipes, output +@cindex output, pipes +@item print @var{items} | @var{command} +It is possible to send output to another program through a pipe +instead of into a file. This redirection opens a pipe to +@var{command}, and writes the values of @var{items} through this pipe +to another process created to execute @var{command}. + +The redirection argument @var{command} is actually an @command{awk} +expression. Its value is converted to a string whose contents give +the shell command to be run. For example, the following produces two +files, one unsorted list of BBS names, and one list sorted in reverse +alphabetical order: + +@ignore +10/2000: +This isn't the best style, since COMMAND is assigned for each +record. It's done to avoid overfull hboxes in TeX. Leave it +alone for now and let's hope no-one notices. +@end ignore + +@example +awk '@{ print $1 > "names.unsorted" + command = "sort -r > names.sorted" + print $1 | command @}' BBS-list +@end example + +The unsorted list is written with an ordinary redirection, while +the sorted list is written by piping through the @command{sort} utility. + +The next example uses redirection to mail a message to the mailing +list @samp{bug-system}. This might be useful when trouble is encountered +in an @command{awk} script run periodically for system maintenance: + +@example +report = "mail bug-system" +print "Awk script failed:", $0 | report +m = ("at record number " FNR " of " FILENAME) +print m | report +close(report) +@end example + +The message is built using string concatenation and saved in the variable +@code{m}. It's then sent down the pipeline to the @command{mail} program. +(The parentheses group the items to concatenate---see +@ref{Concatenation}.) + +The @code{close()} function is called here because it's a good idea to close +the pipe as soon as all the intended output has been sent to it. +@xref{Close Files And Pipes}, +for more information. + +This example also illustrates the use of a variable to represent +a @var{file} or @var{command}---it is not necessary to always +use a string constant. Using a variable is generally a good idea, +because (if you mean to refer to that same file or command) +@command{awk} requires that the string value be spelled identically +every time. + +@cindex coprocesses +@cindex @code{|} (vertical bar), @code{|&} operator (I/O) +@cindex operators, input/output +@cindex differences in @command{awk} and @command{gawk}, input/output operators +@item print @var{items} |& @var{command} +This redirection prints the items to the input of @var{command}. +The difference between this and the +single-@samp{|} redirection is that the output from @var{command} +can be read with @code{getline}. +Thus @var{command} is a @dfn{coprocess}, which works together with, +but subsidiary to, the @command{awk} program. + +This feature is a @command{gawk} extension, and is not available in +POSIX @command{awk}. +@xref{Getline/Coprocess}, +for a brief discussion. +@xref{Two-way I/O}, +for a more complete discussion. +@end table + +Redirecting output using @samp{>}, @samp{>>}, @samp{|}, or @samp{|&} +asks the system to open a file, pipe, or coprocess only if the particular +@var{file} or @var{command} you specify has not already been written +to by your program or if it has been closed since it was last written to. + +@cindex troubleshooting, printing +It is a common error to use @samp{>} redirection for the first @code{print} +to a file, and then to use @samp{>>} for subsequent output: + +@example +# clear the file +print "Don't panic" > "guide.txt" +@dots{} +# append +print "Avoid improbability generators" >> "guide.txt" +@end example + +@noindent +This is indeed how redirections must be used from the shell. But in +@command{awk}, it isn't necessary. In this kind of case, a program should +use @samp{>} for all the @code{print} statements, since the output file +is only opened once. (It happens that if you mix @samp{>} and @samp{>>} +that output is produced in the expected order. However, mixing the operators +for the same file is definitely poor style, and is confusing to readers +of your program.) + +@cindex differences in @command{awk} and @command{gawk}, implementation limitations +@cindex implementation issues, @command{gawk}, limits +@cindex @command{awk}, implementation issues, pipes +@cindex @command{gawk}, implementation issues, pipes +@ifnotinfo +As mentioned earlier +(@pxref{Getline Notes}), +many +@end ifnotinfo +@ifnottex +Many +@end ifnottex +older +@command{awk} implementations limit the number of pipelines that an @command{awk} +program may have open to just one! In @command{gawk}, there is no such limit. +@command{gawk} allows a program to +open as many pipelines as the underlying operating system permits. + +@c fakenode --- for prepinfo +@subheading Advanced Notes: Piping into @command{sh} +@cindex advanced features, piping into @command{sh} +@cindex shells, piping commands into + +A particularly powerful way to use redirection is to build command lines +and pipe them into the shell, @command{sh}. For example, suppose you +have a list of files brought over from a system where all the @value{FN}s +are stored in uppercase, and you wish to rename them to have names in +all lowercase. The following program is both simple and efficient: + +@c @cindex @command{mv} utility +@example +@{ printf("mv %s %s\n", $0, tolower($0)) | "sh" @} + +END @{ close("sh") @} +@end example + +The @code{tolower()} function returns its argument string with all +uppercase characters converted to lowercase +(@pxref{String Functions}). +The program builds up a list of command lines, +using the @command{mv} utility to rename the files. +It then sends the list to the shell for execution. +@c ENDOFRANGE outre +@c ENDOFRANGE reout + +@node Special Files +@section Special @value{FFN}s in @command{gawk} +@c STARTOFRANGE gfn +@cindex @command{gawk}, @value{FN}s in + +@command{gawk} provides a number of special @value{FN}s that it interprets +internally. These @value{FN}s provide access to standard file descriptors +and TCP/IP networking. + +@menu +* Special FD:: Special files for I/O. +* Special Network:: Special files for network communications. +* Special Caveats:: Things to watch out for. +@end menu + +@node Special FD +@subsection Special Files for Standard Descriptors +@cindex standard input +@cindex input, standard +@cindex standard output +@cindex output, standard +@cindex error output +@cindex standard error +@cindex file descriptors +@cindex files, descriptors, See file descriptors + +Running programs conventionally have three input and output streams +already available to them for reading and writing. These are known as +the @dfn{standard input}, @dfn{standard output}, and @dfn{standard error +output}. These streams are, by default, connected to your keyboard and screen, but +they are often redirected with the shell, via the @samp{<}, @samp{<<}, +@samp{>}, @samp{>>}, @samp{>&}, and @samp{|} operators. Standard error +is typically used for writing error messages; the reason there are two separate +streams, standard output and standard error, is so that they can be +redirected separately. + +@cindex differences in @command{awk} and @command{gawk}, error messages +@cindex error handling +In other implementations of @command{awk}, the only way to write an error +message to standard error in an @command{awk} program is as follows: + +@example +print "Serious error detected!" | "cat 1>&2" +@end example + +@noindent +This works by opening a pipeline to a shell command that can access the +standard error stream that it inherits from the @command{awk} process. +This is far from elegant, and it is also inefficient, because it requires a +separate process. So people writing @command{awk} programs often +don't do this. Instead, they send the error messages to the +screen, like this: + +@example +print "Serious error detected!" > "/dev/tty" +@end example + +@noindent +(@file{/dev/tty} is a special file supplied by the operating system +that is connected to your keyboard and screen. It represents the +``terminal,''@footnote{The ``tty'' in @file{/dev/tty} stands for +``Teletype,'' a serial terminal.} which on modern systems is a keyboard +and screen, not a serial console.) +This usually has the same effect but not always: although the +standard error stream is usually the screen, it can be redirected; when +that happens, writing to the screen is not correct. In fact, if +@command{awk} is run from a background job, it may not have a +terminal at all. +Then opening @file{/dev/tty} fails. + +@command{gawk} provides special @value{FN}s for accessing the three standard +streams. @value{COMMONEXT}. It also provides syntax for accessing +any other inherited open files. If the @value{FN} matches +one of these special names when @command{gawk} redirects input or output, +then it directly uses the stream that the @value{FN} stands for. +These special @value{FN}s work for all operating systems that @command{gawk} +has been ported to, not just those that are POSIX-compliant: + +@cindex common extensions, @code{/dev/stdin} special file +@cindex common extensions, @code{/dev/stdout} special file +@cindex common extensions, @code{/dev/stderr} special file +@cindex extensions, common@comma{} @code{/dev/stdin} special file +@cindex extensions, common@comma{} @code{/dev/stdout} special file +@cindex extensions, common@comma{} @code{/dev/stderr} special file +@cindex @value{FN}s, standard streams in @command{gawk} +@cindex @code{/dev/@dots{}} special files (@command{gawk}) +@cindex files, @code{/dev/@dots{}} special files +@cindex @code{/dev/fd/@var{N}} special files +@table @file +@item /dev/stdin +The standard input (file descriptor 0). + +@item /dev/stdout +The standard output (file descriptor 1). + +@item /dev/stderr +The standard error output (file descriptor 2). + +@item /dev/fd/@var{N} +The file associated with file descriptor @var{N}. Such a file must +be opened by the program initiating the @command{awk} execution (typically +the shell). Unless special pains are taken in the shell from which +@command{gawk} is invoked, only descriptors 0, 1, and 2 are available. +@end table + +The @value{FN}s @file{/dev/stdin}, @file{/dev/stdout}, and @file{/dev/stderr} +are aliases for @file{/dev/fd/0}, @file{/dev/fd/1}, and @file{/dev/fd/2}, +respectively. However, they are more self-explanatory. +The proper way to write an error message in a @command{gawk} program +is to use @file{/dev/stderr}, like this: + +@example +print "Serious error detected!" > "/dev/stderr" +@end example + +@cindex troubleshooting, quotes with @value{FN}s +Note the use of quotes around the @value{FN}. +Like any other redirection, the value must be a string. +It is a common error to omit the quotes, which leads +to confusing results. +@c Exercise: What does it do? :-) + +Finally, using the @code{close()} function on a @value{FN} of the +form @code{"/dev/fd/@var{N}"}, for file descriptor numbers +above two, will actually close the given file descriptor. + +The @file{/dev/stdin}, @file{/dev/stdout}, and @file{/dev/stderr} +special files are also recognized internally by several other +versions of @command{awk}. + +@node Special Network +@subsection Special Files for Network Communications +@cindex networks, support for +@cindex TCP/IP, support for + +@command{gawk} programs +can open a two-way +TCP/IP connection, acting as either a client or a server. +This is done using a special @value{FN} of the form: + +@example +@file{/@var{net-type}/@var{protocol}/@var{local-port}/@var{remote-host}/@var{remote-port}} +@end example + +The @var{net-type} is one of @samp{inet}, @samp{inet4} or @samp{inet6}. +The @var{protocol} is one of @samp{tcp} or @samp{udp}, +and the other fields represent the other essential pieces of information +for making a networking connection. +These @value{FN}s are used with the @samp{|&} operator for communicating +with a coprocess +(@pxref{Two-way I/O}). +This is an advanced feature, mentioned here only for completeness. +Full discussion is delayed until +@ref{TCP/IP Networking}. + +@node Special Caveats +@subsection Special @value{FFN} Caveats + +Here is a list of things to bear in mind when using the +special @value{FN}s that @command{gawk} provides: + +@itemize @bullet +@cindex compatibility mode (@command{gawk}), @value{FN}s +@cindex @value{FN}s, in compatibility mode +@item +Recognition of these special @value{FN}s is disabled if @command{gawk} is in +compatibility mode (@pxref{Options}). + +@item +@command{gawk} @emph{always} +interprets these special @value{FN}s. +For example, using @samp{/dev/fd/4} +for output actually writes on file descriptor 4, and not on a new +file descriptor that is @code{dup()}'ed from file descriptor 4. Most of +the time this does not matter; however, it is important to @emph{not} +close any of the files related to file descriptors 0, 1, and 2. +Doing so results in unpredictable behavior. +@end itemize +@c ENDOFRANGE gfn + +@node Close Files And Pipes +@section Closing Input and Output Redirections +@cindex files, output, See output files +@c STARTOFRANGE ifc +@cindex input files, closing +@c STARTOFRANGE ofc +@cindex output, files@comma{} closing +@c STARTOFRANGE pc +@cindex pipes, closing +@c STARTOFRANGE cc +@cindex coprocesses, closing +@cindex @code{getline} command, coprocesses@comma{} using from + +If the same @value{FN} or the same shell command is used with @code{getline} +more than once during the execution of an @command{awk} program +(@pxref{Getline}), +the file is opened (or the command is executed) the first time only. +At that time, the first record of input is read from that file or command. +The next time the same file or command is used with @code{getline}, +another record is read from it, and so on. + +Similarly, when a file or pipe is opened for output, @command{awk} remembers +the @value{FN} or command associated with it, and subsequent +writes to the same file or command are appended to the previous writes. +The file or pipe stays open until @command{awk} exits. + +@cindex @code{close()} function +This implies that special steps are necessary in order to read the same +file again from the beginning, or to rerun a shell command (rather than +reading more output from the same command). The @code{close()} function +makes these things possible: + +@example +close(@var{filename}) +@end example + +@noindent +or: + +@example +close(@var{command}) +@end example + +The argument @var{filename} or @var{command} can be any expression. Its +value must @emph{exactly} match the string that was used to open the file or +start the command (spaces and other ``irrelevant'' characters +included). For example, if you open a pipe with this: + +@example +"sort -r names" | getline foo +@end example + +@noindent +then you must close it with this: + +@example +close("sort -r names") +@end example + +Once this function call is executed, the next @code{getline} from that +file or command, or the next @code{print} or @code{printf} to that +file or command, reopens the file or reruns the command. +Because the expression that you use to close a file or pipeline must +exactly match the expression used to open the file or run the command, +it is good practice to use a variable to store the @value{FN} or command. +The previous example becomes the following: + +@example +sortcom = "sort -r names" +sortcom | getline foo +@dots{} +close(sortcom) +@end example + +@noindent +This helps avoid hard-to-find typographical errors in your @command{awk} +programs. Here are some of the reasons for closing an output file: + +@itemize @bullet +@item +To write a file and read it back later on in the same @command{awk} +program. Close the file after writing it, then +begin reading it with @code{getline}. + +@item +To write numerous files, successively, in the same @command{awk} +program. If the files aren't closed, eventually @command{awk} may exceed a +system limit on the number of open files in one process. It is best to +close each one when the program has finished writing it. + +@item +To make a command finish. When output is redirected through a pipe, +the command reading the pipe normally continues to try to read input +as long as the pipe is open. Often this means the command cannot +really do its work until the pipe is closed. For example, if +output is redirected to the @command{mail} program, the message is not +actually sent until the pipe is closed. + +@item +To run the same program a second time, with the same arguments. +This is not the same thing as giving more input to the first run! + +For example, suppose a program pipes output to the @command{mail} program. +If it outputs several lines redirected to this pipe without closing +it, they make a single message of several lines. By contrast, if the +program closes the pipe after each line of output, then each line makes +a separate message. +@end itemize + +@cindex differences in @command{awk} and @command{gawk}, @code{close()} function +@cindex portability, @code{close()} function and +If you use more files than the system allows you to have open, +@command{gawk} attempts to multiplex the available open files among +your @value{DF}s. @command{gawk}'s ability to do this depends upon the +facilities of your operating system, so it may not always work. It is +therefore both good practice and good portability advice to always +use @code{close()} on your files when you are done with them. +In fact, if you are using a lot of pipes, it is essential that +you close commands when done. For example, consider something like this: + +@example +@{ + @dots{} + command = ("grep " $1 " /some/file | my_prog -q " $3) + while ((command | getline) > 0) @{ + @var{process output of} command + @} + # need close(command) here +@} +@end example + +This example creates a new pipeline based on data in @emph{each} record. +Without the call to @code{close()} indicated in the comment, @command{awk} +creates child processes to run the commands, until it eventually +runs out of file descriptors for more pipelines. + +Even though each command has finished (as indicated by the end-of-file +return status from @code{getline}), the child process is not +terminated;@footnote{The technical terminology is rather morbid. +The finished child is called a ``zombie,'' and cleaning up after +it is referred to as ``reaping.''} +@c Good old UNIX: give the marketing guys fits, that's the ticket +more importantly, the file descriptor for the pipe +is not closed and released until @code{close()} is called or +@command{awk} exits. + +@code{close()} will silently do nothing if given an argument that +does not represent a file, pipe or coprocess that was opened with +a redirection. + +Note also that @samp{close(FILENAME)} has no +``magic'' effects on the implicit loop that reads through the +files named on the command line. It is, more likely, a close +of a file that was never opened, so @command{awk} silently +does nothing. + +@cindex @code{|} (vertical bar), @code{|&} operator (I/O), pipes@comma{} closing +When using the @samp{|&} operator to communicate with a coprocess, +it is occasionally useful to be able to close one end of the two-way +pipe without closing the other. +This is done by supplying a second argument to @code{close()}. +As in any other call to @code{close()}, +the first argument is the name of the command or special file used +to start the coprocess. +The second argument should be a string, with either of the values +@code{"to"} or @code{"from"}. Case does not matter. +As this is an advanced feature, a more complete discussion is +delayed until +@ref{Two-way I/O}, +which discusses it in more detail and gives an example. + +@c fakenode --- for prepinfo +@subheading Advanced Notes: Using @code{close()}'s Return Value +@cindex advanced features, @code{close()} function +@cindex dark corner, @code{close()} function +@cindex @code{close()} function, return values +@cindex return values@comma{} @code{close()} function +@cindex differences in @command{awk} and @command{gawk}, @code{close()} function +@cindex Unix @command{awk}, @code{close()} function and + +In many versions of Unix @command{awk}, the @code{close()} function +is actually a statement. It is a syntax error to try and use the return +value from @code{close()}: +@value{DARKCORNER} + +@example +command = "@dots{}" +command | getline info +retval = close(command) # syntax error in many Unix awks +@end example + +@cindex @command{gawk}, @code{ERRNO} variable in +@cindex @code{ERRNO} variable +@command{gawk} treats @code{close()} as a function. +The return value is @minus{}1 if the argument names something +that was never opened with a redirection, or if there is +a system problem closing the file or process. +In these cases, @command{gawk} sets the built-in variable +@code{ERRNO} to a string describing the problem. + +In @command{gawk}, +when closing a pipe or coprocess (input or output), +the return value is the exit status of the command.@footnote{ +This is a full 16-bit value as returned by the @code{wait()} +system call. See the system manual pages for information on +how to decode this value.} +Otherwise, it is the return value from the system's @code{close()} or +@code{fclose()} C functions when closing input or output +files, respectively. +This value is zero if the close succeeds, or @minus{}1 if +it fails. + +The POSIX standard is very vague; it says that @code{close()} +returns zero on success and nonzero otherwise. In general, +different implementations vary in what they report when closing +pipes; thus the return value cannot be used portably. +@value{DARKCORNER} +In POSIX mode (@pxref{Options}), @command{gawk} just returns zero +when closing a pipe. + +@c ENDOFRANGE ifc +@c ENDOFRANGE ofc +@c ENDOFRANGE pc +@c ENDOFRANGE cc +@c ENDOFRANGE prnt + +@node Expressions +@chapter Expressions +@c STARTOFRANGE exps +@cindex expressions + +Expressions are the basic building blocks of @command{awk} patterns +and actions. An expression evaluates to a value that you can print, test, +or pass to a function. Additionally, an expression +can assign a new value to a variable or a field by using an assignment operator. + +An expression can serve as a pattern or action statement on its own. +Most other kinds of +statements contain one or more expressions that specify the data on which to +operate. As in other languages, expressions in @command{awk} include +variables, array references, constants, and function calls, as well as +combinations of these with various operators. + +@menu +* Values:: Constants, Variables, and Regular Expressions. +* All Operators:: @command{gawk}'s operators. +* Truth Values and Conditions:: Testing for true and false. +* Function Calls:: A function call is an expression. +* Precedence:: How various operators nest. +* Locales:: How the locale affects things. +@end menu + +@node Values +@section Constants, Variables and Conversions + +Expressions are built up from values and the operations performed +upon them. This @value{SECTION} describes the elementary objects +which provide the values used in expressions. + +@menu +* Constants:: String, numeric and regexp constants. +* Using Constant Regexps:: When and how to use a regexp constant. +* Variables:: Variables give names to values for later use. +* Conversion:: The conversion of strings to numbers and vice + versa. +@end menu + +@node Constants +@subsection Constant Expressions +@cindex constants, types of + +The simplest type of expression is the @dfn{constant}, which always has +the same value. There are three types of constants: numeric, +string, and regular expression. + +Each is used in the appropriate context when you need a data +value that isn't going to change. Numeric constants can +have different forms, but are stored identically internally. + +@menu +* Scalar Constants:: Numeric and string constants. +* Nondecimal-numbers:: What are octal and hex numbers. +* Regexp Constants:: Regular Expression constants. +@end menu + +@node Scalar Constants +@subsubsection Numeric and String Constants + +@cindex numeric, constants +A @dfn{numeric constant} stands for a number. This number can be an +integer, a decimal fraction, or a number in scientific (exponential) +notation.@footnote{The internal representation of all numbers, +including integers, uses double precision +floating-point numbers. +On most modern systems, these are in IEEE 754 standard format.} +Here are some examples of numeric constants that all +have the same value: + +@example +105 +1.05e+2 +1050e-1 +@end example + +@cindex string constants +A string constant consists of a sequence of characters enclosed in +double-quotation marks. For example: + +@example +"parrot" +@end example + +@noindent +@cindex differences in @command{awk} and @command{gawk}, strings +@cindex strings, length of +represents the string whose contents are @samp{parrot}. Strings in +@command{gawk} can be of any length, and they can contain any of the possible +eight-bit ASCII characters including ASCII @sc{nul} (character code zero). +Other @command{awk} +implementations may have difficulty with some character codes. + +@node Nondecimal-numbers +@subsubsection Octal and Hexadecimal Numbers +@cindex octal numbers +@cindex hexadecimal numbers +@cindex numbers, octal +@cindex numbers, hexadecimal + +In @command{awk}, all numbers are in decimal; i.e., base 10. Many other +programming languages allow you to specify numbers in other bases, often +octal (base 8) and hexadecimal (base 16). +In octal, the numbers go 0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, etc. +Just as @samp{11}, in decimal, is 1 times 10 plus 1, so +@samp{11}, in octal, is 1 times 8, plus 1. This equals 9 in decimal. +In hexadecimal, there are 16 digits. Since the everyday decimal +number system only has ten digits (@samp{0}--@samp{9}), the letters +@samp{a} through @samp{f} are used to represent the rest. +(Case in the letters is usually irrelevant; hexadecimal @samp{a} and @samp{A} +have the same value.) +Thus, @samp{11}, in +hexadecimal, is 1 times 16 plus 1, which equals 17 in decimal. + +Just by looking at plain @samp{11}, you can't tell what base it's in. +So, in C, C++, and other languages derived from C, +@c such as PERL, but we won't mention that.... +there is a special notation to signify the base. +Octal numbers start with a leading @samp{0}, +and hexadecimal numbers start with a leading @samp{0x} or @samp{0X}: + +@table @code +@item 11 +Decimal value 11. + +@item 011 +Octal 11, decimal value 9. + +@item 0x11 +Hexadecimal 11, decimal value 17. +@end table + +This example shows the difference: + +@example +$ @kbd{gawk 'BEGIN @{ printf "%d, %d, %d\n", 011, 11, 0x11 @}'} +@print{} 9, 11, 17 +@end example + +Being able to use octal and hexadecimal constants in your programs is most +useful when working with data that cannot be represented conveniently as +characters or as regular numbers, such as binary data of various sorts. + +@cindex @command{gawk}, octal numbers and +@cindex @command{gawk}, hexadecimal numbers and +@command{gawk} allows the use of octal and hexadecimal +constants in your program text. However, such numbers in the input data +are not treated differently; doing so by default would break old +programs. +(If you really need to do this, use the @option{--non-decimal-data} +command-line option; +@pxref{Nondecimal Data}.) +If you have octal or hexadecimal data, +you can use the @code{strtonum()} function +(@pxref{String Functions}) +to convert the data into a number. +Most of the time, you will want to use octal or hexadecimal constants +when working with the built-in bit manipulation functions; +see @ref{Bitwise Functions}, +for more information. + +Unlike some early C implementations, @samp{8} and @samp{9} are not valid +in octal constants; e.g., @command{gawk} treats @samp{018} as decimal 18: + +@example +$ @kbd{gawk 'BEGIN @{ print "021 is", 021 ; print 018 @}'} +@print{} 021 is 17 +@print{} 18 +@end example + +@cindex compatibility mode (@command{gawk}), octal numbers +@cindex compatibility mode (@command{gawk}), hexadecimal numbers +Octal and hexadecimal source code constants are a @command{gawk} extension. +If @command{gawk} is in compatibility mode +(@pxref{Options}), +they are not available. + +@c fakenode --- for prepinfo +@subheading Advanced Notes: A Constant's Base Does Not Affect Its Value +@cindex advanced features, constants@comma{} values of + +Once a numeric constant has +been converted internally into a number, +@command{gawk} no longer remembers +what the original form of the constant was; the internal value is +always used. This has particular consequences for conversion of +numbers to strings: + +@example +$ @kbd{gawk 'BEGIN @{ printf "0x11 is <%s>\n", 0x11 @}'} +@print{} 0x11 is <17> +@end example + +@node Regexp Constants +@subsubsection Regular Expression Constants + +@c STARTOFRANGE rec +@cindex regexp constants +@cindex @code{~} (tilde), @code{~} operator +@cindex tilde (@code{~}), @code{~} operator +@cindex @code{!} (exclamation point), @code{!~} operator +@cindex exclamation point (@code{!}), @code{!~} operator +A regexp constant is a regular expression description enclosed in +slashes, such as @code{@w{/^beginning and end$/}}. Most regexps used in +@command{awk} programs are constant, but the @samp{~} and @samp{!~} +matching operators can also match computed or dynamic regexps +(which are just ordinary strings or variables that contain a regexp). +@c ENDOFRANGE cnst + +@node Using Constant Regexps +@subsection Using Regular Expression Constants + +@cindex dark corner, regexp constants +When used on the righthand side of the @samp{~} or @samp{!~} +operators, a regexp constant merely stands for the regexp that is to be +matched. +However, regexp constants (such as @code{/foo/}) may be used like simple expressions. +When a +regexp constant appears by itself, it has the same meaning as if it appeared +in a pattern, i.e., @samp{($0 ~ /foo/)} +@value{DARKCORNER} +@xref{Expression Patterns}. +This means that the following two code segments: + +@example +if ($0 ~ /barfly/ || $0 ~ /camelot/) + print "found" +@end example + +@noindent +and: + +@example +if (/barfly/ || /camelot/) + print "found" +@end example + +@noindent +are exactly equivalent. +One rather bizarre consequence of this rule is that the following +Boolean expression is valid, but does not do what the user probably +intended: + +@example +# Note that /foo/ is on the left of the ~ +if (/foo/ ~ $1) print "found foo" +@end example + +@c @cindex automatic warnings +@c @cindex warnings, automatic +@cindex @command{gawk}, regexp constants and +@cindex regexp constants, in @command{gawk} +@noindent +This code is ``obviously'' testing @code{$1} for a match against the regexp +@code{/foo/}. But in fact, the expression @samp{/foo/ ~ $1} really means +@samp{($0 ~ /foo/) ~ $1}. In other words, first match the input record +against the regexp @code{/foo/}. The result is either zero or one, +depending upon the success or failure of the match. That result +is then matched against the first field in the record. +Because it is unlikely that you would ever really want to make this kind of +test, @command{gawk} issues a warning when it sees this construct in +a program. +Another consequence of this rule is that the assignment statement: + +@example +matches = /foo/ +@end example + +@noindent +assigns either zero or one to the variable @code{matches}, depending +upon the contents of the current input record. + +@cindex differences in @command{awk} and @command{gawk}, regexp constants +@cindex dark corner, regexp constants, as arguments to user-defined functions +@cindex @code{gensub()} function (@command{gawk}) +@cindex @code{sub()} function +@cindex @code{gsub()} function +Constant regular expressions are also used as the first argument for +the @code{gensub()}, @code{sub()}, and @code{gsub()} functions, as the +second argument of the @code{match()} function, +and as the third argument of the @code{patsplit()} function +(@pxref{String Functions}). +Modern implementations of @command{awk}, including @command{gawk}, allow +the third argument of @code{split()} to be a regexp constant, but some +older implementations do not. +@value{DARKCORNER} +This can lead to confusion when attempting to use regexp constants +as arguments to user-defined functions +(@pxref{User-defined}). +For example: + +@example +function mysub(pat, repl, str, global) +@{ + if (global) + gsub(pat, repl, str) + else + sub(pat, repl, str) + return str +@} + +@{ + @dots{} + text = "hi! hi yourself!" + mysub(/hi/, "howdy", text, 1) + @dots{} +@} +@end example + +@c @cindex automatic warnings +@c @cindex warnings, automatic +In this example, the programmer wants to pass a regexp constant to the +user-defined function @code{mysub}, which in turn passes it on to +either @code{sub()} or @code{gsub()}. However, what really happens is that +the @code{pat} parameter is either one or zero, depending upon whether +or not @code{$0} matches @code{/hi/}. +@command{gawk} issues a warning when it sees a regexp constant used as +a parameter to a user-defined function, since passing a truth value in +this way is probably not what was intended. +@c ENDOFRANGE rec + +@node Variables +@subsection Variables + +@cindex variables, user-defined +@cindex user-defined, variables +Variables are ways of storing values at one point in your program for +use later in another part of your program. They can be manipulated +entirely within the program text, and they can also be assigned values +on the @command{awk} command line. + +@menu +* Using Variables:: Using variables in your programs. +* Assignment Options:: Setting variables on the command-line and a + summary of command-line syntax. This is an + advanced method of input. +@end menu + +@node Using Variables +@subsubsection Using Variables in a Program + +Variables let you give names to values and refer to them later. Variables +have already been used in many of the examples. The name of a variable +must be a sequence of letters, digits, or underscores, and it may not begin +with a digit. Case is significant in variable names; @code{a} and @code{A} +are distinct variables. + +A variable name is a valid expression by itself; it represents the +variable's current value. Variables are given new values with +@dfn{assignment operators}, @dfn{increment operators}, and +@dfn{decrement operators}. +@xref{Assignment Ops}. +In addition, the @code{sub()} and @code{gsub()} functions can +change a variable's value, and the @code{match()}, @code{patsplit()} +and @code{split()} functions can change the contents of their +array parameters. @xref{String Functions}. + +@cindex variables, built-in +@cindex variables, initializing +A few variables have special built-in meanings, such as @code{FS} (the +field separator), and @code{NF} (the number of fields in the current input +record). @xref{Built-in Variables}, for a list of the built-in variables. +These built-in variables can be used and assigned just like all other +variables, but their values are also used or changed automatically by +@command{awk}. All built-in variables' names are entirely uppercase. + +Variables in @command{awk} can be assigned either numeric or string values. +The kind of value a variable holds can change over the life of a program. +By default, variables are initialized to the empty string, which +is zero if converted to a number. There is no need to explicitly +``initialize'' a variable in @command{awk}, +which is what you would do in C and in most other traditional languages. + +@node Assignment Options +@subsubsection Assigning Variables on the Command Line +@cindex variables, assigning on command line +@cindex command line, variables@comma{} assigning on + +Any @command{awk} variable can be set by including a @dfn{variable assignment} +among the arguments on the command line when @command{awk} is invoked +(@pxref{Other Arguments}). +Such an assignment has the following form: + +@example +@var{variable}=@var{text} +@end example + +@cindex @code{-v} option, variables@comma{} assigning +@noindent +With it, a variable is set either at the beginning of the +@command{awk} run or in between input files. +When the assignment is preceded with the @option{-v} option, +as in the following: + +@example +-v @var{variable}=@var{text} +@end example + +@noindent +the variable is set at the very beginning, even before the +@code{BEGIN} rules execute. The @option{-v} option and its assignment +must precede all the @value{FN} arguments, as well as the program text. +(@xref{Options}, for more information about +the @option{-v} option.) +Otherwise, the variable assignment is performed at a time determined by +its position among the input file arguments---after the processing of the +preceding input file argument. For example: + +@example +awk '@{ print $n @}' n=4 inventory-shipped n=2 BBS-list +@end example + +@noindent +prints the value of field number @code{n} for all input records. Before +the first file is read, the command line sets the variable @code{n} +equal to four. This causes the fourth field to be printed in lines from +@file{inventory-shipped}. After the first file has finished, +but before the second file is started, @code{n} is set to two, so that the +second field is printed in lines from @file{BBS-list}: + +@example +$ @kbd{awk '@{ print $n @}' n=4 inventory-shipped n=2 BBS-list} +@print{} 15 +@print{} 24 +@dots{} +@print{} 555-5553 +@print{} 555-3412 +@dots{} +@end example + +@cindex dark corner, command-line arguments +Command-line arguments are made available for explicit examination by +the @command{awk} program in the @code{ARGV} array +(@pxref{ARGC and ARGV}). +@command{awk} processes the values of command-line assignments for escape +sequences +(@pxref{Escape Sequences}). +@value{DARKCORNER} + +@node Conversion +@subsection Conversion of Strings and Numbers + +@cindex converting, strings to numbers +@cindex strings, converting +@cindex numbers, converting +@cindex converting, numbers to strings +Strings are converted to numbers and numbers are converted to strings, if the context +of the @command{awk} program demands it. For example, if the value of +either @code{foo} or @code{bar} in the expression @samp{foo + bar} +happens to be a string, it is converted to a number before the addition +is performed. If numeric values appear in string concatenation, they +are converted to strings. Consider the following: + +@example +two = 2; three = 3 +print (two three) + 4 +@end example + +@noindent +This prints the (numeric) value 27. The numeric values of +the variables @code{two} and @code{three} are converted to strings and +concatenated together. The resulting string is converted back to the +number 23, to which 4 is then added. + +@cindex null strings, converting numbers to strings +@cindex type conversion +If, for some reason, you need to force a number to be converted to a +string, concatenate that number with the empty string, @code{""}. +To force a string to be converted to a number, add zero to that string. +A string is converted to a number by interpreting any numeric prefix +of the string as numerals: +@code{"2.5"} converts to 2.5, @code{"1e3"} converts to 1000, and @code{"25fix"} +has a numeric value of 25. +Strings that can't be interpreted as valid numbers convert to zero. + +@cindex @code{CONVFMT} variable +The exact manner in which numbers are converted into strings is controlled +by the @command{awk} built-in variable @code{CONVFMT} (@pxref{Built-in Variables}). +Numbers are converted using the @code{sprintf()} function +with @code{CONVFMT} as the format +specifier +(@pxref{String Functions}). + +@code{CONVFMT}'s default value is @code{"%.6g"}, which prints a value with +at most six significant digits. For some applications, you might want to +change it to specify more precision. +On most modern machines, +17 digits is usually enough to capture a floating-point number's +value exactly.@footnote{Pathological cases can require up to +752 digits (!), but we doubt that you need to worry about this.} + +@cindex dark corner, @code{CONVFMT} variable +Strange results can occur if you set @code{CONVFMT} to a string that doesn't +tell @code{sprintf()} how to format floating-point numbers in a useful way. +For example, if you forget the @samp{%} in the format, @command{awk} converts +all numbers to the same constant string. + +As a special case, if a number is an integer, then the result of converting +it to a string is @emph{always} an integer, no matter what the value of +@code{CONVFMT} may be. Given the following code fragment: + +@example +CONVFMT = "%2.2f" +a = 12 +b = a "" +@end example + +@noindent +@code{b} has the value @code{"12"}, not @code{"12.00"}. +@value{DARKCORNER} + +@cindex POSIX @command{awk}, @code{OFMT} variable and +@cindex @code{OFMT} variable +@cindex portability, new @command{awk} vs.@: old @command{awk} +@cindex @command{awk}, new vs.@: old, @code{OFMT} variable +Prior to the POSIX standard, @command{awk} used the value +of @code{OFMT} for converting numbers to strings. @code{OFMT} +specifies the output format to use when printing numbers with @code{print}. +@code{CONVFMT} was introduced in order to separate the semantics of +conversion from the semantics of printing. Both @code{CONVFMT} and +@code{OFMT} have the same default value: @code{"%.6g"}. In the vast majority +of cases, old @command{awk} programs do not change their behavior. +However, these semantics for @code{OFMT} are something to keep in mind if you must +port your new-style program to older implementations of @command{awk}. +We recommend +that instead of changing your programs, just port @command{gawk} itself. +@xref{Print}, +for more information on the @code{print} statement. + +And, once again, where you are can matter when it comes to converting +between numbers and strings. In @ref{Locales}, we mentioned that +the local character set and language (the locale) can affect how +@command{gawk} matches characters. The locale also affects numeric +formats. In particular, for @command{awk} programs, it affects the +decimal point character. The @code{"C"} locale, and most English-language +locales, use the period character (@samp{.}) as the decimal point. +However, many (if not most) European and non-English locales use the comma +(@samp{,}) as the decimal point character. + +The POSIX standard says that @command{awk} always uses the period as the decimal +point when reading the @command{awk} program source code, and for command-line +variable assignments (@pxref{Other Arguments}). +However, when interpreting input data, for @code{print} and @code{printf} output, +and for number to string conversion, the local decimal point character is used. +Here are some examples indicating the difference in behavior, +on a GNU/Linux system: + +@example +$ @kbd{gawk 'BEGIN @{ printf "%g\n", 3.1415927 @}'} +@print{} 3.14159 +$ @kbd{LC_ALL=en_DK gawk 'BEGIN @{ printf "%g\n", 3.1415927 @}'} +@print{} 3,14159 +$ @kbd{echo 4,321 | gawk '@{ print $1 + 1 @}'} +@print{} 5 +$ @kbd{echo 4,321 | LC_ALL=en_DK gawk '@{ print $1 + 1 @}'} +@print{} 5,321 +@end example + +@noindent +The @samp{en_DK} locale is for English in Denmark, where the comma acts as +the decimal point separator. In the normal @code{"C"} locale, @command{gawk} +treats @samp{4,321} as @samp{4}, while in the Danish locale, it's treated +as the full number, 4.321. + +Some earlier versions of @command{gawk} fully complied with this aspect +of the standard. However, many users in non-English locales complained +about this behavior, since their data used a period as the decimal +point, so the default behavior was restored to use a period as the +decimal point character. You can use the @option{--use-lc-numeric} +option (@pxref{Options}) to force @command{gawk} to use the locale's +decimal point character. (@command{gawk} also uses the locale's decimal +point character when in POSIX mode, either via @option{--posix}, or the +@env{POSIXLY_CORRECT} environment variable.) + +@ref{table-locale-affects} describes the cases in which the locale's decimal +point character is used and when a period is used. Some of these +features have not been described yet. + +@float Table,table-locale-affects +@caption{Locale Decimal Point versus A Period} +@multitable @columnfractions .15 .20 .45 +@headitem Feature @tab Default @tab @option{--posix} or @option{--use-lc-numeric} +@item @code{%'g} @tab Use locale @tab Use locale +@item @code{%g} @tab Use period @tab Use locale +@item Input @tab Use period @tab Use locale +@item @code{strtonum()} @tab Use period @tab Use locale +@end multitable +@end float + +Finally, modern day formal standards and IEEE standard floating point +representation can have an unusual but important effect on the way +@command{gawk} converts some special string values to numbers. The details +are presented in @ref{POSIX Floating Point Problems}. + +@node All Operators +@section Operators: Doing Something With Values + +This @value{SECTION} introduces the @dfn{operators} which make use +of the values provided by constants and variables. + +@menu +* Arithmetic Ops:: Arithmetic operations (@samp{+}, @samp{-}, + etc.) +* Concatenation:: Concatenating strings. +* Assignment Ops:: Changing the value of a variable or a field. +* Increment Ops:: Incrementing the numeric value of a variable. +@end menu + +@node Arithmetic Ops +@subsection Arithmetic Operators +@cindex arithmetic operators +@cindex operators, arithmetic +@c @cindex addition +@c @cindex subtraction +@c @cindex multiplication +@c @cindex division +@c @cindex remainder +@c @cindex quotient +@c @cindex exponentiation + +The @command{awk} language uses the common arithmetic operators when +evaluating expressions. All of these arithmetic operators follow normal +precedence rules and work as you would expect them to. + +The following example uses a file named @file{grades}, which contains +a list of student names as well as three test scores per student (it's +a small class): + +@example +Pat 100 97 58 +Sandy 84 72 93 +Chris 72 92 89 +@end example + +@noindent +This program takes the file @file{grades} and prints the average +of the scores: + +@example +$ @kbd{awk '@{ sum = $2 + $3 + $4 ; avg = sum / 3} +> @kbd{print $1, avg @}' grades} +@print{} Pat 85 +@print{} Sandy 83 +@print{} Chris 84.3333 +@end example + +The following list provides the arithmetic operators in @command{awk}, in order from +the highest precedence to the lowest: + +@table @code +@item - @var{x} +Negation. + +@item + @var{x} +Unary plus; the expression is converted to a number. + +@cindex common extensions, @code{**} operator +@cindex extensions, common@comma{} @code{**} operator +@cindex POSIX @command{awk}, arithmetic operators and +@item @var{x} ^ @var{y} +@itemx @var{x} ** @var{y} +Exponentiation; @var{x} raised to the @var{y} power. @samp{2 ^ 3} has +the value eight; the character sequence @samp{**} is equivalent to +@samp{^}. @value{COMMONEXT} + +@item @var{x} * @var{y} +Multiplication. + +@cindex troubleshooting, division +@cindex division +@item @var{x} / @var{y} +Division; because all numbers in @command{awk} are floating-point +numbers, the result is @emph{not} rounded to an integer---@samp{3 / 4} has +the value 0.75. (It is a common mistake, especially for C programmers, +to forget that @emph{all} numbers in @command{awk} are floating-point, +and that division of integer-looking constants produces a real number, +not an integer.) + +@item @var{x} % @var{y} +Remainder; further discussion is provided in the text, just +after this list. + +@item @var{x} + @var{y} +Addition. + +@item @var{x} - @var{y} +Subtraction. +@end table + +Unary plus and minus have the same precedence, +the multiplication operators all have the same precedence, and +addition and subtraction have the same precedence. + +@cindex differences in @command{awk} and @command{gawk}, trunc-mod operation +@cindex trunc-mod operation +When computing the remainder of @samp{@var{x} % @var{y}}, +the quotient is rounded toward zero to an integer and +multiplied by @var{y}. This result is subtracted from @var{x}; +this operation is sometimes known as ``trunc-mod.'' The following +relation always holds: + +@example +b * int(a / b) + (a % b) == a +@end example + +One possibly undesirable effect of this definition of remainder is that +@code{@var{x} % @var{y}} is negative if @var{x} is negative. Thus: + +@example +-17 % 8 = -1 +@end example + +In other @command{awk} implementations, the signedness of the remainder +may be machine-dependent. +@c !!! what does posix say? + +@cindex portability, @code{**} operator and +@cindex @code{*} (asterisk), @code{**} operator +@cindex asterisk (@code{*}), @code{**} operator +@quotation NOTE +The POSIX standard only specifies the use of @samp{^} +for exponentiation. +For maximum portability, do not use the @samp{**} operator. +@end quotation + +@node Concatenation +@subsection String Concatenation +@cindex Kernighan, Brian +@quotation +@i{It seemed like a good idea at the time.}@* +Brian Kernighan +@end quotation + +@cindex string operators +@cindex operators, string +@cindex concatenating +There is only one string operation: concatenation. It does not have a +specific operator to represent it. Instead, concatenation is performed by +writing expressions next to one another, with no operator. For example: + +@example +$ @kbd{awk '@{ print "Field number one: " $1 @}' BBS-list} +@print{} Field number one: aardvark +@print{} Field number one: alpo-net +@dots{} +@end example + +Without the space in the string constant after the @samp{:}, the line +runs together. For example: + +@example +$ @kbd{awk '@{ print "Field number one:" $1 @}' BBS-list} +@print{} Field number one:aardvark +@print{} Field number one:alpo-net +@dots{} +@end example + +@cindex troubleshooting, string concatenation +Because string concatenation does not have an explicit operator, it is +often necessary to insure that it happens at the right time by using +parentheses to enclose the items to concatenate. For example, +you might expect that the +following code fragment concatenates @code{file} and @code{name}: + +@example +file = "file" +name = "name" +print "something meaningful" > file name +@end example + +@noindent +This produces a syntax error with some versions of Unix +@command{awk}.@footnote{It happens that Brian Kernighan's +@command{awk}, @command{gawk} and @command{mawk} all ``get it right,'' +but you should not rely on this.} +It is necessary to use the following: + +@example +print "something meaningful" > (file name) +@end example + +@cindex order of evaluation, concatenation +@cindex evaluation order, concatenation +@cindex side effects +Parentheses should be used around concatenation in all but the +most common contexts, such as on the righthand side of @samp{=}. +Be careful about the kinds of expressions used in string concatenation. +In particular, the order of evaluation of expressions used for concatenation +is undefined in the @command{awk} language. Consider this example: + +@example +BEGIN @{ + a = "don't" + print (a " " (a = "panic")) +@} +@end example + +@noindent +It is not defined whether the assignment to @code{a} happens +before or after the value of @code{a} is retrieved for producing the +concatenated value. The result could be either @samp{don't panic}, +or @samp{panic panic}. +@c see test/nasty.awk for a worse example + +The precedence of concatenation, when mixed with other operators, is often +counter-intuitive. Consider this example: + +@ignore +> To: bug-gnu-utils@@gnu.org +> CC: arnold@@gnu.org +> Subject: gawk 3.0.4 bug with {print -12 " " -24} +> From: Russell Schulz +> Date: Tue, 8 Feb 2000 19:56:08 -0700 +> +> gawk 3.0.4 on NT gives me: +> +> prompt> cat bad.awk +> BEGIN { print -12 " " -24; } +> +> prompt> gawk -f bad.awk +> -12-24 +> +> when I would expect +> +> -12 -24 +> +> I have not investigated the source, or other implementations. The +> bug is there on my NT and DOS versions 2.15.6 . +@end ignore + +@example +$ @kbd{awk 'BEGIN @{ print -12 " " -24 @}'} +@print{} -12-24 +@end example + +This ``obviously'' is concatenating @minus{}12, a space, and @minus{}24. +But where did the space disappear to? +The answer lies in the combination of operator precedences and +@command{awk}'s automatic conversion rules. To get the desired result, +write the program this way: + +@example +$ @kbd{awk 'BEGIN @{ print -12 " " (-24) @}'} +@print{} -12 -24 +@end example + +This forces @command{awk} to treat the @samp{-} on the @samp{-24} as unary. +Otherwise, it's parsed as follows: + +@display + @minus{}12 (@code{"@ "} @minus{} 24) +@result{} @minus{}12 (0 @minus{} 24) +@result{} @minus{}12 (@minus{}24) +@result{} @minus{}12@minus{}24 +@end display + +As mentioned earlier, +when doing concatenation, @emph{parenthesize}. Otherwise, +you're never quite sure what you'll get. + +@node Assignment Ops +@subsection Assignment Expressions +@c STARTOFRANGE asop +@cindex assignment operators +@c STARTOFRANGE opas +@cindex operators, assignment +@c STARTOFRANGE exas +@cindex expressions, assignment +@cindex @code{=} (equals sign), @code{=} operator +@cindex equals sign (@code{=}), @code{=} operator +An @dfn{assignment} is an expression that stores a (usually different) +value into a variable. For example, let's assign the value one to the variable +@code{z}: + +@example +z = 1 +@end example + +After this expression is executed, the variable @code{z} has the value one. +Whatever old value @code{z} had before the assignment is forgotten. + +Assignments can also store string values. For example, the +following stores +the value @code{"this food is good"} in the variable @code{message}: + +@example +thing = "food" +predicate = "good" +message = "this " thing " is " predicate +@end example + +@noindent +@cindex side effects, assignment expressions +This also illustrates string concatenation. +The @samp{=} sign is called an @dfn{assignment operator}. It is the +simplest assignment operator because the value of the righthand +operand is stored unchanged. +Most operators (addition, concatenation, and so on) have no effect +except to compute a value. If the value isn't used, there's no reason to +use the operator. An assignment operator is different; it does +produce a value, but even if you ignore it, the assignment still +makes itself felt through the alteration of the variable. We call this +a @dfn{side effect}. + +@cindex lvalues/rvalues +@cindex rvalues/lvalues +@cindex assignment operators, lvalues/rvalues +@cindex operators, assignment +The lefthand operand of an assignment need not be a variable +(@pxref{Variables}); it can also be a field +(@pxref{Changing Fields}) or +an array element (@pxref{Arrays}). +These are all called @dfn{lvalues}, +which means they can appear on the lefthand side of an assignment operator. +The righthand operand may be any expression; it produces the new value +that the assignment stores in the specified variable, field, or array +element. (Such values are called @dfn{rvalues}.) + +@cindex variables, types of +It is important to note that variables do @emph{not} have permanent types. +A variable's type is simply the type of whatever value it happens +to hold at the moment. In the following program fragment, the variable +@code{foo} has a numeric value at first, and a string value later on: + +@example +foo = 1 +print foo +foo = "bar" +print foo +@end example + +@noindent +When the second assignment gives @code{foo} a string value, the fact that +it previously had a numeric value is forgotten. + +String values that do not begin with a digit have a numeric value of +zero. After executing the following code, the value of @code{foo} is five: + +@example +foo = "a string" +foo = foo + 5 +@end example + +@quotation NOTE +Using a variable as a number and then later as a string +can be confusing and is poor programming style. The previous two examples +illustrate how @command{awk} works, @emph{not} how you should write your +programs! +@end quotation + +An assignment is an expression, so it has a value---the same value that +is assigned. Thus, @samp{z = 1} is an expression with the value one. +One consequence of this is that you can write multiple assignments together, +such as: + +@example +x = y = z = 5 +@end example + +@noindent +This example stores the value five in all three variables +(@code{x}, @code{y}, and @code{z}). +It does so because the +value of @samp{z = 5}, which is five, is stored into @code{y} and then +the value of @samp{y = z = 5}, which is five, is stored into @code{x}. + +Assignments may be used anywhere an expression is called for. For +example, it is valid to write @samp{x != (y = 1)} to set @code{y} to one, +and then test whether @code{x} equals one. But this style tends to make +programs hard to read; such nesting of assignments should be avoided, +except perhaps in a one-shot program. + +@cindex @code{+} (plus sign), @code{+=} operator +@cindex plus sign (@code{+}), @code{+=} operator +Aside from @samp{=}, there are several other assignment operators that +do arithmetic with the old value of the variable. For example, the +operator @samp{+=} computes a new value by adding the righthand value +to the old value of the variable. Thus, the following assignment adds +five to the value of @code{foo}: + +@example +foo += 5 +@end example + +@noindent +This is equivalent to the following: + +@example +foo = foo + 5 +@end example + +@noindent +Use whichever makes the meaning of your program clearer. + +There are situations where using @samp{+=} (or any assignment operator) +is @emph{not} the same as simply repeating the lefthand operand in the +righthand expression. For example: + +@cindex Rankin, Pat +@example +# Thanks to Pat Rankin for this example +BEGIN @{ + foo[rand()] += 5 + for (x in foo) + print x, foo[x] + + bar[rand()] = bar[rand()] + 5 + for (x in bar) + print x, bar[x] +@} +@end example + +@cindex operators, assignment, evaluation order +@cindex assignment operators, evaluation order +@noindent +The indices of @code{bar} are practically guaranteed to be different, because +@code{rand()} returns different values each time it is called. +(Arrays and the @code{rand()} function haven't been covered yet. +@xref{Arrays}, +and see @ref{Numeric Functions}, for more information). +This example illustrates an important fact about assignment +operators: the lefthand expression is only evaluated @emph{once}. +It is up to the implementation as to which expression is evaluated +first, the lefthand or the righthand. +Consider this example: + +@example +i = 1 +a[i += 2] = i + 1 +@end example + +@noindent +The value of @code{a[3]} could be either two or four. + +@ref{table-assign-ops} lists the arithmetic assignment operators. In each +case, the righthand operand is an expression whose value is converted +to a number. + +@cindex @code{-} (hyphen), @code{-=} operator +@cindex hyphen (@code{-}), @code{-=} operator +@cindex @code{*} (asterisk), @code{*=} operator +@cindex asterisk (@code{*}), @code{*=} operator +@cindex @code{/} (forward slash), @code{/=} operator +@cindex forward slash (@code{/}), @code{/=} operator +@cindex @code{%} (percent sign), @code{%=} operator +@cindex percent sign (@code{%}), @code{%=} operator +@cindex @code{^} (caret), @code{^=} operator +@cindex caret (@code{^}), @code{^=} operator +@cindex @code{*} (asterisk), @code{**=} operator +@cindex asterisk (@code{*}), @code{**=} operator +@float Table,table-assign-ops +@caption{Arithmetic Assignment Operators} +@multitable @columnfractions .30 .70 +@headitem Operator @tab Effect +@item @var{lvalue} @code{+=} @var{increment} @tab Adds @var{increment} to the value of @var{lvalue}. +@item @var{lvalue} @code{-=} @var{decrement} @tab Subtracts @var{decrement} from the value of @var{lvalue}. +@item @var{lvalue} @code{*=} @var{coefficient} @tab Multiplies the value of @var{lvalue} by @var{coefficient}. +@item @var{lvalue} @code{/=} @var{divisor} @tab Divides the value of @var{lvalue} by @var{divisor}. +@item @var{lvalue} @code{%=} @var{modulus} @tab Sets @var{lvalue} to its remainder by @var{modulus}. +@cindex common extensions, @code{**=} operator +@cindex extensions, common@comma{} @code{**=} operator +@cindex @command{awk} language, POSIX version +@cindex POSIX @command{awk} +@item @var{lvalue} @code{^=} @var{power} @tab +@item @var{lvalue} @code{**=} @var{power} @tab Raises @var{lvalue} to the power @var{power}. @value{COMMONEXT} +@end multitable +@end float + +@cindex POSIX @command{awk}, @code{**=} operator and +@cindex portability, @code{**=} operator and +@quotation NOTE +Only the @samp{^=} operator is specified by POSIX. +For maximum portability, do not use the @samp{**=} operator. +@end quotation + +@c fakenode --- for prepinfo +@subheading Advanced Notes: Syntactic Ambiguities Between @samp{/=} and Regular Expressions +@cindex advanced features, regexp constants +@cindex dark corner, regexp constants, @code{/=} operator and +@cindex @code{/} (forward slash), @code{/=} operator, vs. @code{/=@dots{}/} regexp constant +@cindex forward slash (@code{/}), @code{/=} operator, vs. @code{/=@dots{}/} regexp constant +@cindex regexp constants, @code{/=@dots{}/}, @code{/=} operator and + +@c derived from email from "Nelson H. F. Beebe" +@c Date: Mon, 1 Sep 1997 13:38:35 -0600 (MDT) + +@cindex dark corner +@cindex ambiguity, syntactic: @code{/=} operator vs. @code{/=@dots{}/} regexp constant +@cindex syntactic ambiguity: @code{/=} operator vs. @code{/=@dots{}/} regexp constant +@cindex @code{/=} operator vs. @code{/=@dots{}/} regexp constant +There is a syntactic ambiguity between the @code{/=} assignment +operator and regexp constants whose first character is an @samp{=}. +@value{DARKCORNER} +This is most notable in commercial @command{awk} versions. +For example: + +@example +$ awk /==/ /dev/null +@error{} awk: syntax error at source line 1 +@error{} context is +@error{} >>> /= <<< +@error{} awk: bailing out at source line 1 +@end example + +@noindent +A workaround is: + +@example +awk '/[=]=/' /dev/null +@end example + +@command{gawk} does not have this problem, +nor do the other +freely available versions described in +@ref{Other Versions}. +@c ENDOFRANGE exas +@c ENDOFRANGE opas +@c ENDOFRANGE asop + +@node Increment Ops +@subsection Increment and Decrement Operators + +@c STARTOFRANGE inop +@cindex increment operators +@c STARTOFRANGE opde +@cindex operators, decrement/increment +@dfn{Increment} and @dfn{decrement operators} increase or decrease the value of +a variable by one. An assignment operator can do the same thing, so +the increment operators add no power to the @command{awk} language; however, they +are convenient abbreviations for very common operations. + +@cindex side effects +@cindex @code{+} (plus sign), @code{++} (decrement/increment operators) +@cindex plus sign (@code{+}), @code{++} (decrement/increment operators) +@cindex side effects, decrement/increment operators +The operator used for adding one is written @samp{++}. It can be used to increment +a variable either before or after taking its value. +To pre-increment a variable @code{v}, write @samp{++v}. This adds +one to the value of @code{v}---that new value is also the value of the +expression. (The assignment expression @samp{v += 1} is completely +equivalent.) +Writing the @samp{++} after the variable specifies post-increment. This +increments the variable value just the same; the difference is that the +value of the increment expression itself is the variable's @emph{old} +value. Thus, if @code{foo} has the value four, then the expression @samp{foo++} +has the value four, but it changes the value of @code{foo} to five. +In other words, the operator returns the old value of the variable, +but with the side effect of incrementing it. + +The post-increment @samp{foo++} is nearly the same as writing @samp{(foo ++= 1) - 1}. It is not perfectly equivalent because all numbers in +@command{awk} are floating-point---in floating-point, @samp{foo + 1 - 1} does +not necessarily equal @code{foo}. But the difference is minute as +long as you stick to numbers that are fairly small (less than 10e12). + +@cindex @code{$} (dollar sign), incrementing fields and arrays +@cindex dollar sign (@code{$}), incrementing fields and arrays +Fields and array elements are incremented +just like variables. (Use @samp{$(i++)} when you want to do a field reference +and a variable increment at the same time. The parentheses are necessary +because of the precedence of the field reference operator @samp{$}.) + +@cindex decrement operators +The decrement operator @samp{--} works just like @samp{++}, except that +it subtracts one instead of adding it. As with @samp{++}, it can be used before +the lvalue to pre-decrement or after it to post-decrement. +Following is a summary of increment and decrement expressions: + +@table @code +@cindex @code{+} (plus sign), @code{++} operator +@cindex plus sign (@code{+}), @code{++} operator +@item ++@var{lvalue} +Increment @var{lvalue}, returning the new value as the +value of the expression. + +@item @var{lvalue}++ +Increment @var{lvalue}, returning the @emph{old} value of @var{lvalue} +as the value of the expression. + +@cindex @code{-} (hyphen), @code{--} operator +@cindex hyphen (@code{-}), @code{--} operator +@item --@var{lvalue} +Decrement @var{lvalue}, returning the new value as the +value of the expression. +(This expression is +like @samp{++@var{lvalue}}, but instead of adding, it subtracts.) + +@item @var{lvalue}-- +Decrement @var{lvalue}, returning the @emph{old} value of @var{lvalue} +as the value of the expression. +(This expression is +like @samp{@var{lvalue}++}, but instead of adding, it subtracts.) +@end table + +@c fakenode --- for prepinfo +@subheading Advanced Notes: Operator Evaluation Order +@cindex advanced features, operators@comma{} precedence +@cindex precedence +@cindex operators, precedence +@cindex portability, operators +@cindex evaluation order +@cindex Marx, Groucho +@quotation +@i{Doctor, doctor! It hurts when I do this!@* +So don't do that!}@* +Groucho Marx +@end quotation + +@noindent +What happens for something like the following? + +@example +b = 6 +print b += b++ +@end example + +@noindent +Or something even stranger? + +@example +b = 6 +b += ++b + b++ +print b +@end example + +@cindex side effects +In other words, when do the various side effects prescribed by the +postfix operators (@samp{b++}) take effect? +When side effects happen is @dfn{implementation defined}. +In other words, it is up to the particular version of @command{awk}. +The result for the first example may be 12 or 13, and for the second, it +may be 22 or 23. + +In short, doing things like this is not recommended and definitely +not anything that you can rely upon for portability. +You should avoid such things in your own programs. +@c You'll sleep better at night and be able to look at yourself +@c in the mirror in the morning. +@c ENDOFRANGE inop +@c ENDOFRANGE opde +@c ENDOFRANGE deop + +@node Truth Values and Conditions +@section Truth Values and Conditions + +In certain contexts, expression values also serve as ``truth values;'' i.e., +they determine what should happen next as the program runs. This +@value{SECTION} describes how @command{awk} defines ``true'' and ``false'' +and how values are compared. + +@menu +* Truth Values:: What is ``true'' and what is ``false''. +* Typing and Comparison:: How variables acquire types and how this + affects comparison of numbers and strings with + @samp{<}, etc. +* Boolean Ops:: Combining comparison expressions using boolean + operators @samp{||} (``or''), @samp{&&} + (``and'') and @samp{!} (``not''). +* Conditional Exp:: Conditional expressions select between two + subexpressions under control of a third + subexpression. +@end menu + +@node Truth Values +@subsection True and False in @command{awk} +@cindex truth values +@cindex logical false/true +@cindex false, logical +@cindex true, logical + +@cindex null strings +Many programming languages have a special representation for the concepts +of ``true'' and ``false.'' Such languages usually use the special +constants @code{true} and @code{false}, or perhaps their uppercase +equivalents. +However, @command{awk} is different. +It borrows a very simple concept of true and +false from C. In @command{awk}, any nonzero numeric value @emph{or} any +nonempty string value is true. Any other value (zero or the null +string, @code{""}) is false. The following program prints @samp{A strange +truth value} three times: + +@example +BEGIN @{ + if (3.1415927) + print "A strange truth value" + if ("Four Score And Seven Years Ago") + print "A strange truth value" + if (j = 57) + print "A strange truth value" +@} +@end example + +@cindex dark corner +There is a surprising consequence of the ``nonzero or non-null'' rule: +the string constant @code{"0"} is actually true, because it is non-null. +@value{DARKCORNER} + +@node Typing and Comparison +@subsection Variable Typing and Comparison Expressions +@quotation +@i{The Guide is definitive. Reality is frequently inaccurate.}@* +The Hitchhiker's Guide to the Galaxy +@end quotation + +@c STARTOFRANGE comex +@cindex comparison expressions +@c STARTOFRANGE excom +@cindex expressions, comparison +@cindex expressions, matching, See comparison expressions +@cindex matching, expressions, See comparison expressions +@cindex relational operators, See comparison operators +@cindex operators, relational, See operators@comma{} comparison +@c STARTOFRANGE varting +@cindex variable typing +@c STARTOFRANGE vartypc +@cindex variables, types of, comparison expressions and +Unlike other programming languages, @command{awk} variables do not have a +fixed type. Instead, they can be either a number or a string, depending +upon the value that is assigned to them. +We look now at how variables are typed, and how @command{awk} +compares variables. + +@menu +* Variable Typing:: String type versus numeric type. +* Comparison Operators:: The comparison operators. +* POSIX String Comparison:: String comparison with POSIX rules. +@end menu + +@node Variable Typing +@subsubsection String Type Versus Numeric Type + +@cindex numeric, strings +@cindex strings, numeric +@cindex POSIX @command{awk}, numeric strings and +The 1992 POSIX standard introduced +the concept of a @dfn{numeric string}, which is simply a string that looks +like a number---for example, @code{@w{" +2"}}. This concept is used +for determining the type of a variable. +The type of the variable is important because the types of two variables +determine how they are compared. +The various versions of the POSIX standard did not get the rules +quite right for several editions. Fortunately, as of at least the +2008 standard (and possibly earlier), the standard has been fixed, +and variable typing follows these rules:@footnote{@command{gawk} has +followed these rules for many years, +and it is gratifying that the POSIX standard is also now correct.} + +@itemize @bullet +@item +A numeric constant or the result of a numeric operation has the @var{numeric} +attribute. + +@item +A string constant or the result of a string operation has the @var{string} +attribute. + +@item +Fields, @code{getline} input, @code{FILENAME}, @code{ARGV} elements, +@code{ENVIRON} elements, and the elements of an array created by +@code{patsplit()}, @code{split()} and @code{match()} that are numeric +strings have the @var{strnum} attribute. Otherwise, they have +the @var{string} attribute. Uninitialized variables also have the +@var{strnum} attribute. + +@item +Attributes propagate across assignments but are not changed by +any use. +@c (Although a use may cause the entity to acquire an additional +@c value such that it has both a numeric and string value, this leaves the +@c attribute unchanged.) +@c This is important but not relevant +@end itemize + +The last rule is particularly important. In the following program, +@code{a} has numeric type, even though it is later used in a string +operation: + +@example +BEGIN @{ + a = 12.345 + b = a " is a cute number" + print b +@} +@end example + +When two operands are compared, either string comparison or numeric comparison +may be used. This depends upon the attributes of the operands, according to the +following symmetric matrix: + +@c thanks to Karl Berry, kb@cs.umb.edu, for major help with TeX tables +@tex +\centerline{ +\vbox{\bigskip % space above the table (about 1 linespace) +% Because we have vertical rules, we can't let TeX insert interline space +% in its usual way. +\offinterlineskip +% +% Define the table template. & separates columns, and \cr ends the +% template (and each row). # is replaced by the text of that entry on +% each row. The template for the first column breaks down like this: +% \strut -- a way to make each line have the height and depth +% of a normal line of type, since we turned off interline spacing. +% \hfil -- infinite glue; has the effect of right-justifying in this case. +% # -- replaced by the text (for instance, `STRNUM', in the last row). +% \quad -- about the width of an `M'. Just separates the columns. +% +% The second column (\vrule#) is what generates the vertical rule that +% spans table rows. +% +% The doubled && before the next entry means `repeat the following +% template as many times as necessary on each line' -- in our case, twice. +% +% The template itself, \quad#\hfil, left-justifies with a little space before. +% +\halign{\strut\hfil#\quad&\vrule#&&\quad#\hfil\cr + &&STRING &NUMERIC &STRNUM\cr +% The \omit tells TeX to skip inserting the template for this column on +% this particular row. In this case, we only want a little extra space +% to separate the heading row from the rule below it. the depth 2pt -- +% `\vrule depth 2pt' is that little space. +\omit &depth 2pt\cr +% This is the horizontal rule below the heading. Since it has nothing to +% do with the columns of the table, we use \noalign to get it in there. +\noalign{\hrule} +% Like above, this time a little more space. +\omit &depth 4pt\cr +% The remaining rows have nothing special about them. +STRING &&string &string &string\cr +NUMERIC &&string &numeric &numeric\cr +STRNUM &&string &numeric &numeric\cr +}}} +@end tex +@ifnottex +@display + +---------------------------------------------- + | STRING NUMERIC STRNUM +--------+---------------------------------------------- + | +STRING | string string string + | +NUMERIC | string numeric numeric + | +STRNUM | string numeric numeric +--------+---------------------------------------------- +@end display +@end ifnottex + +The basic idea is that user input that looks numeric---and @emph{only} +user input---should be treated as numeric, even though it is actually +made of characters and is therefore also a string. +Thus, for example, the string constant @w{@code{" +3.14"}}, +when it appears in program source code, +is a string---even though it looks numeric---and +is @emph{never} treated as number for comparison +purposes. + +In short, when one operand is a ``pure'' string, such as a string +constant, then a string comparison is performed. Otherwise, a +numeric comparison is performed. + +This point bears additional emphasis: All user input is made of characters, +and so is first and foremost of @var{string} type; input strings +that look numeric are additionally given the @var{strnum} attribute. +Thus, the six-character input string @w{@samp{ +3.14}} receives the +@var{strnum} attribute. In contrast, the eight-character literal +@w{@code{" +3.14"}} appearing in program text is a string constant. +The following examples print @samp{1} when the comparison between +the two different constants is true, @samp{0} otherwise: + +@example +$ @kbd{echo ' +3.14' | gawk '@{ print $0 == " +3.14" @}'} @ii{True} +@print{} 1 +$ @kbd{echo ' +3.14' | gawk '@{ print $0 == "+3.14" @}'} @ii{False} +@print{} 0 +$ @kbd{echo ' +3.14' | gawk '@{ print $0 == "3.14" @}'} @ii{False} +@print{} 0 +$ @kbd{echo ' +3.14' | gawk '@{ print $0 == 3.14 @}'} @ii{True} +@print{} 1 +$ @kbd{echo ' +3.14' | gawk '@{ print $1 == " +3.14" @}'} @ii{False} +@print{} 0 +$ @kbd{echo ' +3.14' | gawk '@{ print $1 == "+3.14" @}'} @ii{True} +@print{} 1 +$ @kbd{echo ' +3.14' | gawk '@{ print $1 == "3.14" @}'} @ii{False} +@print{} 0 +$ @kbd{echo ' +3.14' | gawk '@{ print $1 == 3.14 @}'} @ii{True} +@print{} 1 +@end example + +@node Comparison Operators +@subsubsection Comparison Operators + +@dfn{Comparison expressions} compare strings or numbers for +relationships such as equality. They are written using @dfn{relational +operators}, which are a superset of those in C. +@ref{table-relational-ops} describes them. + +@cindex @code{<} (left angle bracket), @code{<} operator +@cindex left angle bracket (@code{<}), @code{<} operator +@cindex @code{<} (left angle bracket), @code{<=} operator +@cindex left angle bracket (@code{<}), @code{<=} operator +@cindex @code{>} (right angle bracket), @code{>=} operator +@cindex right angle bracket (@code{>}), @code{>=} operator +@cindex @code{>} (right angle bracket), @code{>} operator +@cindex right angle bracket (@code{>}), @code{>} operator +@cindex @code{=} (equals sign), @code{==} operator +@cindex equals sign (@code{=}), @code{==} operator +@cindex @code{!} (exclamation point), @code{!=} operator +@cindex exclamation point (@code{!}), @code{!=} operator +@cindex @code{~} (tilde), @code{~} operator +@cindex tilde (@code{~}), @code{~} operator +@cindex @code{!} (exclamation point), @code{!~} operator +@cindex exclamation point (@code{!}), @code{!~} operator +@cindex @code{in} operator +@float Table,table-relational-ops +@caption{Relational Operators} +@multitable @columnfractions .25 .75 +@headitem Expression @tab Result +@item @var{x} @code{<} @var{y} @tab True if @var{x} is less than @var{y}. +@item @var{x} @code{<=} @var{y} @tab True if @var{x} is less than or equal to @var{y}. +@item @var{x} @code{>} @var{y} @tab True if @var{x} is greater than @var{y}. +@item @var{x} @code{>=} @var{y} @tab True if @var{x} is greater than or equal to @var{y}. +@item @var{x} @code{==} @var{y} @tab True if @var{x} is equal to @var{y}. +@item @var{x} @code{!=} @var{y} @tab True if @var{x} is not equal to @var{y}. +@item @var{x} @code{~} @var{y} @tab True if the string @var{x} matches the regexp denoted by @var{y}. +@item @var{x} @code{!~} @var{y} @tab True if the string @var{x} does not match the regexp denoted by @var{y}. +@item @var{subscript} @code{in} @var{array} @tab True if the array @var{array} has an element with the subscript @var{subscript}. +@end multitable +@end float + +Comparison expressions have the value one if true and zero if false. +When comparing operands of mixed types, numeric operands are converted +to strings using the value of @code{CONVFMT} +(@pxref{Conversion}). + +Strings are compared +by comparing the first character of each, then the second character of each, +and so on. Thus, @code{"10"} is less than @code{"9"}. If there are two +strings where one is a prefix of the other, the shorter string is less than +the longer one. Thus, @code{"abc"} is less than @code{"abcd"}. + +@cindex troubleshooting, @code{==} operator +It is very easy to accidentally mistype the @samp{==} operator and +leave off one of the @samp{=} characters. The result is still valid +@command{awk} code, but the program does not do what is intended: + +@example +if (a = b) # oops! should be a == b + @dots{} +else + @dots{} +@end example + +@noindent +Unless @code{b} happens to be zero or the null string, the @code{if} +part of the test always succeeds. Because the operators are +so similar, this kind of error is very difficult to spot when +scanning the source code. + +@cindex @command{gawk}, comparison operators and +The following table of expressions illustrates the kind of comparison +@command{gawk} performs, as well as what the result of the comparison is: + +@table @code +@item 1.5 <= 2.0 +numeric comparison (true) + +@item "abc" >= "xyz" +string comparison (false) + +@item 1.5 != " +2" +string comparison (true) + +@item "1e2" < "3" +string comparison (true) + +@item a = 2; b = "2" +@itemx a == b +string comparison (true) + +@item a = 2; b = " +2" +@item a == b +string comparison (false) +@end table + +In this example: + +@example +$ @kbd{echo 1e2 3 | awk '@{ print ($1 < $2) ? "true" : "false" @}'} +@print{} false +@end example + +@cindex comparison expressions, string vs.@: regexp +@c @cindex string comparison vs.@: regexp comparison +@c @cindex regexp comparison vs.@: string comparison +@noindent +the result is @samp{false} because both @code{$1} and @code{$2} +are user input. They are numeric strings---therefore both have +the @var{strnum} attribute, dictating a numeric comparison. +The purpose of the comparison rules and the use of numeric strings is +to attempt to produce the behavior that is ``least surprising,'' while +still ``doing the right thing.'' + +String comparisons and regular expression comparisons are very different. +For example: + +@example +x == "foo" +@end example + +@noindent +has the value one, or is true if the variable @code{x} +is precisely @samp{foo}. By contrast: + +@example +x ~ /foo/ +@end example + +@noindent +has the value one if @code{x} contains @samp{foo}, such as +@code{"Oh, what a fool am I!"}. + +@cindex @code{~} (tilde), @code{~} operator +@cindex tilde (@code{~}), @code{~} operator +@cindex @code{!} (exclamation point), @code{!~} operator +@cindex exclamation point (@code{!}), @code{!~} operator +The righthand operand of the @samp{~} and @samp{!~} operators may be +either a regexp constant (@code{/@dots{}/}) or an ordinary +expression. In the latter case, the value of the expression as a string is used as a +dynamic regexp (@pxref{Regexp Usage}; also +@pxref{Computed Regexps}). + +@cindex @command{awk}, regexp constants and +@cindex regexp constants +In modern implementations of @command{awk}, a constant regular +expression in slashes by itself is also an expression. The regexp +@code{/@var{regexp}/} is an abbreviation for the following comparison expression: + +@example +$0 ~ /@var{regexp}/ +@end example + +One special place where @code{/foo/} is @emph{not} an abbreviation for +@samp{$0 ~ /foo/} is when it is the righthand operand of @samp{~} or +@samp{!~}. +@xref{Using Constant Regexps}, +where this is discussed in more detail. + +@node POSIX String Comparison +@subsubsection String Comparison With POSIX Rules + +The POSIX standard says that string comparison is performed based +on the locale's collating order. This is usually very different +from the results obtained when doing straight character-by-character +comparison.@footnote{Technically, string comparison is supposed +to behave the same way as if the strings are compared with the C +@code{strcoll()} function.} + +Because this behavior differs considerably from existing practice, +@command{gawk} only implements it when in POSIX mode (@pxref{Options}). +Here is an example to illustrate the difference, in an @samp{en_US.UTF-8} +locale: + +@example +$ @kbd{gawk 'BEGIN @{ printf("ABC < abc = %s\n",} +> @kbd{("ABC" < "abc" ? "TRUE" : "FALSE")) @}'} +@print{} ABC < abc = TRUE +$ @kbd{gawk --posix 'BEGIN @{ printf("ABC < abc = %s\n",} +> @kbd{("ABC" < "abc" ? "TRUE" : "FALSE")) @}'} +@print{} ABC < abc = FALSE +@end example + +@c ENDOFRANGE comex +@c ENDOFRANGE excom +@c ENDOFRANGE vartypc +@c ENDOFRANGE varting + +@node Boolean Ops +@subsection Boolean Expressions +@cindex and Boolean-logic operator +@cindex or Boolean-logic operator +@cindex not Boolean-logic operator +@c STARTOFRANGE exbo +@cindex expressions, Boolean +@c STARTOFRANGE boex +@cindex Boolean expressions +@cindex operators, Boolean, See Boolean expressions +@cindex Boolean operators, See Boolean expressions +@cindex logical operators, See Boolean expressions +@cindex operators, logical, See Boolean expressions + +A @dfn{Boolean expression} is a combination of comparison expressions or +matching expressions, using the Boolean operators ``or'' +(@samp{||}), ``and'' (@samp{&&}), and ``not'' (@samp{!}), along with +parentheses to control nesting. The truth value of the Boolean expression is +computed by combining the truth values of the component expressions. +Boolean expressions are also referred to as @dfn{logical expressions}. +The terms are equivalent. + +Boolean expressions can be used wherever comparison and matching +expressions can be used. They can be used in @code{if}, @code{while}, +@code{do}, and @code{for} statements +(@pxref{Statements}). +They have numeric values (one if true, zero if false) that come into play +if the result of the Boolean expression is stored in a variable or +used in arithmetic. + +In addition, every Boolean expression is also a valid pattern, so +you can use one as a pattern to control the execution of rules. +The Boolean operators are: + +@table @code +@item @var{boolean1} && @var{boolean2} +True if both @var{boolean1} and @var{boolean2} are true. For example, +the following statement prints the current input record if it contains +both @samp{2400} and @samp{foo}: + +@example +if ($0 ~ /2400/ && $0 ~ /foo/) print +@end example + +@cindex side effects, Boolean operators +The subexpression @var{boolean2} is evaluated only if @var{boolean1} +is true. This can make a difference when @var{boolean2} contains +expressions that have side effects. In the case of @samp{$0 ~ /foo/ && +($2 == bar++)}, the variable @code{bar} is not incremented if there is +no substring @samp{foo} in the record. + +@item @var{boolean1} || @var{boolean2} +True if at least one of @var{boolean1} or @var{boolean2} is true. +For example, the following statement prints all records in the input +that contain @emph{either} @samp{2400} or +@samp{foo} or both: + +@example +if ($0 ~ /2400/ || $0 ~ /foo/) print +@end example + +The subexpression @var{boolean2} is evaluated only if @var{boolean1} +is false. This can make a difference when @var{boolean2} contains +expressions that have side effects. + +@item ! @var{boolean} +True if @var{boolean} is false. For example, +the following program prints @samp{no home!} in +the unusual event that the @env{HOME} environment +variable is not defined: + +@example +BEGIN @{ if (! ("HOME" in ENVIRON)) + print "no home!" @} +@end example + +(The @code{in} operator is described in +@ref{Reference to Elements}.) +@end table + +@cindex short-circuit operators +@cindex operators, short-circuit +@cindex @code{&} (ampersand), @code{&&} operator +@cindex ampersand (@code{&}), @code{&&} operator +@cindex @code{|} (vertical bar), @code{||} operator +@cindex vertical bar (@code{|}), @code{||} operator +The @samp{&&} and @samp{||} operators are called @dfn{short-circuit} +operators because of the way they work. Evaluation of the full expression +is ``short-circuited'' if the result can be determined part way through +its evaluation. + +@cindex line continuations +Statements that use @samp{&&} or @samp{||} can be continued simply +by putting a newline after them. But you cannot put a newline in front +of either of these operators without using backslash continuation +(@pxref{Statements/Lines}). + +@cindex @code{!} (exclamation point), @code{!} operator +@cindex exclamation point (@code{!}), @code{!} operator +@cindex newlines +@cindex variables, flag +@cindex flag variables +The actual value of an expression using the @samp{!} operator is +either one or zero, depending upon the truth value of the expression it +is applied to. +The @samp{!} operator is often useful for changing the sense of a flag +variable from false to true and back again. For example, the following +program is one way to print lines in between special bracketing lines: + +@example +$1 == "START" @{ interested = ! interested; next @} +interested == 1 @{ print @} +$1 == "END" @{ interested = ! interested; next @} +@end example + +@noindent +The variable @code{interested}, as with all @command{awk} variables, starts +out initialized to zero, which is also false. When a line is seen whose +first field is @samp{START}, the value of @code{interested} is toggled +to true, using @samp{!}. The next rule prints lines as long as +@code{interested} is true. When a line is seen whose first field is +@samp{END}, @code{interested} is toggled back to false.@footnote{This +program has a bug; it prints lines starting with @samp{END}. How +would you fix it?} + +@ignore +Scott Deifik points out that this program isn't robust against +bogus input data, but the point is to illustrate the use of `!', +so we'll leave well enough alone. +@end ignore + +@cindex @code{next} statement +@quotation NOTE +The @code{next} statement is discussed in +@ref{Next Statement}. +@code{next} tells @command{awk} to skip the rest of the rules, get the +next record, and start processing the rules over again at the top. +The reason it's there is to avoid printing the bracketing +@samp{START} and @samp{END} lines. +@end quotation +@c ENDOFRANGE exbo +@c ENDOFRANGE boex + +@node Conditional Exp +@subsection Conditional Expressions +@cindex conditional expressions +@cindex expressions, conditional +@cindex expressions, selecting + +A @dfn{conditional expression} is a special kind of expression that has +three operands. It allows you to use one expression's value to select +one of two other expressions. +The conditional expression is the same as in the C language, +as shown here: + +@example +@var{selector} ? @var{if-true-exp} : @var{if-false-exp} +@end example + +@noindent +There are three subexpressions. The first, @var{selector}, is always +computed first. If it is ``true'' (not zero or not null), then +@var{if-true-exp} is computed next and its value becomes the value of +the whole expression. Otherwise, @var{if-false-exp} is computed next +and its value becomes the value of the whole expression. +For example, the following expression produces the absolute value of @code{x}: + +@example +x >= 0 ? x : -x +@end example + +@cindex side effects, conditional expressions +Each time the conditional expression is computed, only one of +@var{if-true-exp} and @var{if-false-exp} is used; the other is ignored. +This is important when the expressions have side effects. For example, +this conditional expression examines element @code{i} of either array +@code{a} or array @code{b}, and increments @code{i}: + +@example +x == y ? a[i++] : b[i++] +@end example + +@noindent +This is guaranteed to increment @code{i} exactly once, because each time +only one of the two increment expressions is executed +and the other is not. +@xref{Arrays}, +for more information about arrays. + +@cindex differences in @command{awk} and @command{gawk}, line continuations +@cindex line continuations, @command{gawk} +@cindex @command{gawk}, line continuation in +As a minor @command{gawk} extension, +a statement that uses @samp{?:} can be continued simply +by putting a newline after either character. +However, putting a newline in front +of either character does not work without using backslash continuation +(@pxref{Statements/Lines}). +If @option{--posix} is specified +(@pxref{Options}), then this extension is disabled. + +@node Function Calls +@section Function Calls +@cindex function calls + +A @dfn{function} is a name for a particular calculation. +This enables you to +ask for it by name at any point in the program. For +example, the function @code{sqrt()} computes the square root of a number. + +@cindex functions, built-in +A fixed set of functions are @dfn{built-in}, which means they are +available in every @command{awk} program. The @code{sqrt()} function is one +of these. @xref{Built-in}, for a list of built-in +functions and their descriptions. In addition, you can define +functions for use in your program. +@xref{User-defined}, +for instructions on how to do this. + +@cindex arguments, in function calls +The way to use a function is with a @dfn{function call} expression, +which consists of the function name followed immediately by a list of +@dfn{arguments} in parentheses. The arguments are expressions that +provide the raw materials for the function's calculations. +When there is more than one argument, they are separated by commas. If +there are no arguments, just write @samp{()} after the function name. +The following examples show function calls with and without arguments: + +@example +sqrt(x^2 + y^2) @ii{one argument} +atan2(y, x) @ii{two arguments} +rand() @ii{no arguments} +@end example + +@cindex troubleshooting, function call syntax +@quotation CAUTION +Do not put any space between the function name and the open-parenthesis! +A user-defined function name looks just like the name of a +variable---a space would make the expression look like concatenation of +a variable with an expression inside parentheses. +With built-in functions, space before the parenthesis is harmless, but +it is best not to get into the habit of using space to avoid mistakes +with user-defined functions. +@end quotation + +Each function expects a particular number +of arguments. For example, the @code{sqrt()} function must be called with +a single argument, the number of which to take the square root: + +@example +sqrt(@var{argument}) +@end example + +Some of the built-in functions have one or +more optional arguments. +If those arguments are not supplied, the functions +use a reasonable default value. +@xref{Built-in}, for full details. If arguments +are omitted in calls to user-defined functions, then those arguments are +treated as local variables and initialized to the empty string +(@pxref{User-defined}). + +As an advanced feature, @command{gawk} provides indirect function calls, +which is a way to choose the function to call at runtime, instead of +when you write the source code to your program. We defer discussion of +this feature until later; see @ref{Indirect Calls}. + +@cindex side effects, function calls +Like every other expression, the function call has a value, which is +computed by the function based on the arguments you give it. In this +example, the value of @samp{sqrt(@var{argument})} is the square root of +@var{argument}. +The following program reads numbers, one number per line, and prints the +square root of each one: + +@example +$ @kbd{awk '@{ print "The square root of", $1, "is", sqrt($1) @}'} +@kbd{1} +@print{} The square root of 1 is 1 +@kbd{3} +@print{} The square root of 3 is 1.73205 +@kbd{5} +@print{} The square root of 5 is 2.23607 +@kbd{@value{CTL}-d} +@end example + +A function can also have side effects, such as assigning +values to certain variables or doing I/O. +This program shows how the @code{match()} function +(@pxref{String Functions}) +changes the variables @code{RSTART} and @code{RLENGTH}: + +@example +@{ + if (match($1, $2)) + print RSTART, RLENGTH + else + print "no match" +@} +@end example + +@noindent +Here is a sample run: + +@example +$ @kbd{awk -f matchit.awk} +@kbd{aaccdd c+} +@print{} 3 2 +@kbd{foo bar} +@print{} no match +@kbd{abcdefg e} +@print{} 5 1 +@end example + +@node Precedence +@section Operator Precedence (How Operators Nest) +@c STARTOFRANGE prec +@cindex precedence +@c STARTOFRANGE oppr +@cindex operators, precedence + +@dfn{Operator precedence} determines how operators are grouped when +different operators appear close by in one expression. For example, +@samp{*} has higher precedence than @samp{+}; thus, @samp{a + b * c} +means to multiply @code{b} and @code{c}, and then add @code{a} to the +product (i.e., @samp{a + (b * c)}). + +The normal precedence of the operators can be overruled by using parentheses. +Think of the precedence rules as saying where the +parentheses are assumed to be. In +fact, it is wise to always use parentheses whenever there is an unusual +combination of operators, because other people who read the program may +not remember what the precedence is in this case. +Even experienced programmers occasionally forget the exact rules, +which leads to mistakes. +Explicit parentheses help prevent +any such mistakes. + +When operators of equal precedence are used together, the leftmost +operator groups first, except for the assignment, conditional, and +exponentiation operators, which group in the opposite order. +Thus, @samp{a - b + c} groups as @samp{(a - b) + c} and +@samp{a = b = c} groups as @samp{a = (b = c)}. + +Normally the precedence of prefix unary operators does not matter, +because there is only one way to interpret +them: innermost first. Thus, @samp{$++i} means @samp{$(++i)} and +@samp{++$x} means @samp{++($x)}. However, when another operator follows +the operand, then the precedence of the unary operators can matter. +@samp{$x^2} means @samp{($x)^2}, but @samp{-x^2} means +@samp{-(x^2)}, because @samp{-} has lower precedence than @samp{^}, +whereas @samp{$} has higher precedence. +Also, operators cannot be combined in a way that violates the +precedence rules; for example, @samp{$$0++--} is not a valid +expression because the first @samp{$} has higher precedence than the +@samp{++}; to avoid the problem the expression can be rewritten as +@samp{$($0++)--}. + +This table presents @command{awk}'s operators, in order of highest +to lowest precedence: + +@c use @code in the items, looks better in TeX w/o all the quotes +@table @code +@item (@dots{}) +Grouping. + +@cindex @code{$} (dollar sign), @code{$} field operator +@cindex dollar sign (@code{$}), @code{$} field operator +@item $ +Field reference. + +@cindex @code{+} (plus sign), @code{++} operator +@cindex plus sign (@code{+}), @code{++} operator +@cindex @code{-} (hyphen), @code{--} (decrement/increment) operator +@cindex hyphen (@code{-}), @code{--} (decrement/increment) operators +@item ++ -- +Increment, decrement. + +@cindex @code{^} (caret), @code{^} operator +@cindex caret (@code{^}), @code{^} operator +@cindex @code{*} (asterisk), @code{**} operator +@cindex asterisk (@code{*}), @code{**} operator +@item ^ ** +Exponentiation. These operators group right-to-left. + +@cindex @code{+} (plus sign), @code{+} operator +@cindex plus sign (@code{+}), @code{+} operator +@cindex @code{-} (hyphen), @code{-} operator +@cindex hyphen (@code{-}), @code{-} operator +@cindex @code{!} (exclamation point), @code{!} operator +@cindex exclamation point (@code{!}), @code{!} operator +@item + - ! +Unary plus, minus, logical ``not.'' + +@cindex @code{*} (asterisk), @code{*} operator, as multiplication operator +@cindex asterisk (@code{*}), @code{*} operator, as multiplication operator +@cindex @code{/} (forward slash), @code{/} operator +@cindex forward slash (@code{/}), @code{/} operator +@cindex @code{%} (percent sign), @code{%} operator +@cindex percent sign (@code{%}), @code{%} operator +@item * / % +Multiplication, division, remainder. + +@cindex @code{+} (plus sign), @code{+} operator +@cindex plus sign (@code{+}), @code{+} operator +@cindex @code{-} (hyphen), @code{-} operator +@cindex hyphen (@code{-}), @code{-} operator +@item + - +Addition, subtraction. + +@item @r{String Concatenation} +There is no special symbol for concatenation. +The operands are simply written side by side +(@pxref{Concatenation}). + +@cindex @code{<} (left angle bracket), @code{<} operator +@cindex left angle bracket (@code{<}), @code{<} operator +@cindex @code{<} (left angle bracket), @code{<=} operator +@cindex left angle bracket (@code{<}), @code{<=} operator +@cindex @code{>} (right angle bracket), @code{>=} operator +@cindex right angle bracket (@code{>}), @code{>=} operator +@cindex @code{>} (right angle bracket), @code{>} operator +@cindex right angle bracket (@code{>}), @code{>} operator +@cindex @code{=} (equals sign), @code{==} operator +@cindex equals sign (@code{=}), @code{==} operator +@cindex @code{!} (exclamation point), @code{!=} operator +@cindex exclamation point (@code{!}), @code{!=} operator +@cindex @code{>} (right angle bracket), @code{>>} operator (I/O) +@cindex right angle bracket (@code{>}), @code{>>} operator (I/O) +@cindex operators, input/output +@cindex @code{|} (vertical bar), @code{|} operator (I/O) +@cindex vertical bar (@code{|}), @code{|} operator (I/O) +@cindex operators, input/output +@cindex @code{|} (vertical bar), @code{|&} operator (I/O) +@cindex vertical bar (@code{|}), @code{|&} operator (I/O) +@cindex operators, input/output +@item < <= == != > >= >> | |& +Relational and redirection. +The relational operators and the redirections have the same precedence +level. Characters such as @samp{>} serve both as relationals and as +redirections; the context distinguishes between the two meanings. + +@cindex @code{print} statement, I/O operators in +@cindex @code{printf} statement, I/O operators in +Note that the I/O redirection operators in @code{print} and @code{printf} +statements belong to the statement level, not to expressions. The +redirection does not produce an expression that could be the operand of +another operator. As a result, it does not make sense to use a +redirection operator near another operator of lower precedence without +parentheses. Such combinations (for example, @samp{print foo > a ? b : c}), +result in syntax errors. +The correct way to write this statement is @samp{print foo > (a ? b : c)}. + +@cindex @code{~} (tilde), @code{~} operator +@cindex tilde (@code{~}), @code{~} operator +@cindex @code{!} (exclamation point), @code{!~} operator +@cindex exclamation point (@code{!}), @code{!~} operator +@item ~ !~ +Matching, nonmatching. + +@cindex @code{in} operator +@item in +Array membership. + +@cindex @code{&} (ampersand), @code{&&} operator +@cindex ampersand (@code{&}), @code{&&} operator +@item && +Logical ``and''. + +@cindex @code{|} (vertical bar), @code{||} operator +@cindex vertical bar (@code{|}), @code{||} operator +@item || +Logical ``or''. + +@cindex @code{?} (question mark), @code{?:} operator +@cindex question mark (@code{?}), @code{?:} operator +@item ?: +Conditional. This operator groups right-to-left. + +@cindex @code{+} (plus sign), @code{+=} operator +@cindex plus sign (@code{+}), @code{+=} operator +@cindex @code{-} (hyphen), @code{-=} operator +@cindex hyphen (@code{-}), @code{-=} operator +@cindex @code{*} (asterisk), @code{*=} operator +@cindex asterisk (@code{*}), @code{*=} operator +@cindex @code{*} (asterisk), @code{**=} operator +@cindex asterisk (@code{*}), @code{**=} operator +@cindex @code{/} (forward slash), @code{/=} operator +@cindex forward slash (@code{/}), @code{/=} operator +@cindex @code{%} (percent sign), @code{%=} operator +@cindex percent sign (@code{%}), @code{%=} operator +@cindex @code{^} (caret), @code{^=} operator +@cindex caret (@code{^}), @code{^=} operator +@item = += -= *= /= %= ^= **= +Assignment. These operators group right-to-left. +@end table + +@cindex POSIX @command{awk}, @code{**} operator and +@cindex portability, operators, not in POSIX @command{awk} +@quotation NOTE +The @samp{|&}, @samp{**}, and @samp{**=} operators are not specified by POSIX. +For maximum portability, do not use them. +@end quotation +@c ENDOFRANGE prec +@c ENDOFRANGE oppr + +@node Locales +@section Where You Are Makes A Difference +@cindex locale, definition of + +Modern systems support the notion of @dfn{locales}: a way to tell +the system about the local character set and language. + +Once upon a time, the locale setting used to affect regexp matching +(@pxref{Ranges and Locales}), but this is no longer true. + +Locales can affect record splitting. +For the normal case of @samp{RS = "\n"}, the locale is largely irrelevant. +For other single-character record separators, setting @samp{LC_ALL=C} +in the environment +will give you much better performance when reading records. Otherwise, +@command{gawk} has to make several function calls, @emph{per input +character}, to find the record terminator. + +According to POSIX, string comparison is also affected by locales +(similar to regular expressions). The details are presented in +@ref{POSIX String Comparison}. + +Finally, the locale affects the value of the decimal point character +used when @command{gawk} parses input data. This is discussed in +detail in @ref{Conversion}. + +@c ENDOFRANGE exps + +@node Patterns and Actions +@chapter Patterns, Actions, and Variables +@c STARTOFRANGE pat +@cindex patterns + +As you have already seen, each @command{awk} statement consists of +a pattern with an associated action. This @value{CHAPTER} describes how +you build patterns and actions, what kinds of things you can do within +actions, and @command{awk}'s built-in variables. + +The pattern-action rules and the statements available for use +within actions form the core of @command{awk} programming. +In a sense, everything covered +up to here has been the foundation +that programs are built on top of. Now it's time to start +building something useful. + +@menu +* Pattern Overview:: What goes into a pattern. +* Using Shell Variables:: How to use shell variables with @command{awk}. +* Action Overview:: What goes into an action. +* Statements:: Describes the various control statements in + detail. +* Built-in Variables:: Summarizes the built-in variables. +@end menu + +@node Pattern Overview +@section Pattern Elements + +@menu +* Regexp Patterns:: Using regexps as patterns. +* Expression Patterns:: Any expression can be used as a pattern. +* Ranges:: Pairs of patterns specify record ranges. +* BEGIN/END:: Specifying initialization and cleanup rules. +* BEGINFILE/ENDFILE:: Two special patterns for advanced control. +* Empty:: The empty pattern, which matches every record. +@end menu + +@cindex patterns, types of +Patterns in @command{awk} control the execution of rules---a rule is +executed when its pattern matches the current input record. +The following is a summary of the types of @command{awk} patterns: + +@table @code +@item /@var{regular expression}/ +A regular expression. It matches when the text of the +input record fits the regular expression. +(@xref{Regexp}.) + +@item @var{expression} +A single expression. It matches when its value +is nonzero (if a number) or non-null (if a string). +(@xref{Expression Patterns}.) + +@item @var{pat1}, @var{pat2} +A pair of patterns separated by a comma, specifying a range of records. +The range includes both the initial record that matches @var{pat1} and +the final record that matches @var{pat2}. +(@xref{Ranges}.) + +@item BEGIN +@itemx END +Special patterns for you to supply startup or cleanup actions for your +@command{awk} program. +(@xref{BEGIN/END}.) + +@item BEGINFILE +@itemx ENDFILE +Special patterns for you to supply startup or cleanup actions to be +done on a per file basis. +(@xref{BEGINFILE/ENDFILE}.) + +@item @var{empty} +The empty pattern matches every input record. +(@xref{Empty}.) +@end table + +@node Regexp Patterns +@subsection Regular Expressions as Patterns +@cindex patterns, expressions as +@cindex regular expressions, as patterns + +Regular expressions are one of the first kinds of patterns presented +in this book. +This kind of pattern is simply a regexp constant in the pattern part of +a rule. Its meaning is @samp{$0 ~ /@var{pattern}/}. +The pattern matches when the input record matches the regexp. +For example: + +@example +/foo|bar|baz/ @{ buzzwords++ @} +END @{ print buzzwords, "buzzwords seen" @} +@end example + +@node Expression Patterns +@subsection Expressions as Patterns +@cindex expressions, as patterns + +Any @command{awk} expression is valid as an @command{awk} pattern. +The pattern matches if the expression's value is nonzero (if a +number) or non-null (if a string). +The expression is reevaluated each time the rule is tested against a new +input record. If the expression uses fields such as @code{$1}, the +value depends directly on the new input record's text; otherwise, it +depends on only what has happened so far in the execution of the +@command{awk} program. + +@cindex comparison expressions, as patterns +@cindex patterns, comparison expressions as +Comparison expressions, using the comparison operators described in +@ref{Typing and Comparison}, +are a very common kind of pattern. +Regexp matching and nonmatching are also very common expressions. +The left operand of the @samp{~} and @samp{!~} operators is a string. +The right operand is either a constant regular expression enclosed in +slashes (@code{/@var{regexp}/}), or any expression whose string value +is used as a dynamic regular expression +(@pxref{Computed Regexps}). +The following example prints the second field of each input record +whose first field is precisely @samp{foo}: + +@cindex @code{/} (forward slash), patterns and +@cindex forward slash (@code{/}), patterns and +@cindex @code{~} (tilde), @code{~} operator +@cindex tilde (@code{~}), @code{~} operator +@cindex @code{!} (exclamation point), @code{!~} operator +@cindex exclamation point (@code{!}), @code{!~} operator +@example +$ @kbd{awk '$1 == "foo" @{ print $2 @}' BBS-list} +@end example + +@noindent +(There is no output, because there is no BBS site with the exact name @samp{foo}.) +Contrast this with the following regular expression match, which +accepts any record with a first field that contains @samp{foo}: + +@example +$ @kbd{awk '$1 ~ /foo/ @{ print $2 @}' BBS-list} +@print{} 555-1234 +@print{} 555-6699 +@print{} 555-6480 +@print{} 555-2127 +@end example + +@cindex regexp constants, as patterns +@cindex patterns, regexp constants as +A regexp constant as a pattern is also a special case of an expression +pattern. The expression @code{/foo/} has the value one if @samp{foo} +appears in the current input record. Thus, as a pattern, @code{/foo/} +matches any record containing @samp{foo}. + +@cindex Boolean expressions, as patterns +Boolean expressions are also commonly used as patterns. +Whether the pattern +matches an input record depends on whether its subexpressions match. +For example, the following command prints all the records in +@file{BBS-list} that contain both @samp{2400} and @samp{foo}: + +@example +$ @kbd{awk '/2400/ && /foo/' BBS-list} +@print{} fooey 555-1234 2400/1200/300 B +@end example + +The following command prints all records in +@file{BBS-list} that contain @emph{either} @samp{2400} or @samp{foo} +(or both, of course): + +@example +$ @kbd{awk '/2400/ || /foo/' BBS-list} +@print{} alpo-net 555-3412 2400/1200/300 A +@print{} bites 555-1675 2400/1200/300 A +@print{} fooey 555-1234 2400/1200/300 B +@print{} foot 555-6699 1200/300 B +@print{} macfoo 555-6480 1200/300 A +@print{} sdace 555-3430 2400/1200/300 A +@print{} sabafoo 555-2127 1200/300 C +@end example + +The following command prints all records in +@file{BBS-list} that do @emph{not} contain the string @samp{foo}: + +@example +$ @kbd{awk '! /foo/' BBS-list} +@print{} aardvark 555-5553 1200/300 B +@print{} alpo-net 555-3412 2400/1200/300 A +@print{} barfly 555-7685 1200/300 A +@print{} bites 555-1675 2400/1200/300 A +@print{} camelot 555-0542 300 C +@print{} core 555-2912 1200/300 C +@print{} sdace 555-3430 2400/1200/300 A +@end example + +@cindex @code{BEGIN} pattern, Boolean patterns and +@cindex @code{END} pattern, Boolean patterns and +@cindex @code{BEGINFILE} pattern, Boolean patterns and +@cindex @code{ENDFILE} pattern, Boolean patterns and +The subexpressions of a Boolean operator in a pattern can be constant regular +expressions, comparisons, or any other @command{awk} expressions. Range +patterns are not expressions, so they cannot appear inside Boolean +patterns. Likewise, the special patterns @code{BEGIN}, @code{END}, +@code{BEGINFILE} and @code{ENDFILE}, +which never match any input record, are not expressions and cannot +appear inside Boolean patterns. + +The precedence of the different operators which can appear in +patterns is described in @ref{Precedence}. + +@node Ranges +@subsection Specifying Record Ranges with Patterns + +@cindex range patterns +@cindex patterns, ranges in +@cindex lines, matching ranges of +@cindex @code{,} (comma), in range patterns +@cindex comma (@code{,}), in range patterns +A @dfn{range pattern} is made of two patterns separated by a comma, in +the form @samp{@var{begpat}, @var{endpat}}. It is used to match ranges of +consecutive input records. The first pattern, @var{begpat}, controls +where the range begins, while @var{endpat} controls where +the pattern ends. For example, the following: + +@example +awk '$1 == "on", $1 == "off"' myfile +@end example + +@noindent +prints every record in @file{myfile} between @samp{on}/@samp{off} pairs, inclusive. + +A range pattern starts out by matching @var{begpat} against every +input record. When a record matches @var{begpat}, the range pattern is +@dfn{turned on} and the range pattern matches this record as well. As long as +the range pattern stays turned on, it automatically matches every input +record read. The range pattern also matches @var{endpat} against every +input record; when this succeeds, the range pattern is turned off again +for the following record. Then the range pattern goes back to checking +@var{begpat} against each record. + +@cindex @code{if} statement, actions@comma{} changing +The record that turns on the range pattern and the one that turns it +off both match the range pattern. If you don't want to operate on +these records, you can write @code{if} statements in the rule's action +to distinguish them from the records you are interested in. + +It is possible for a pattern to be turned on and off by the same +record. If the record satisfies both conditions, then the action is +executed for just that record. +For example, suppose there is text between two identical markers (e.g., +the @samp{%} symbol), each on its own line, that should be ignored. +A first attempt would be to +combine a range pattern that describes the delimited text with the +@code{next} statement +(not discussed yet, @pxref{Next Statement}). +This causes @command{awk} to skip any further processing of the current +record and start over again with the next input record. Such a program +looks like this: + +@example +/^%$/,/^%$/ @{ next @} + @{ print @} +@end example + +@noindent +@cindex lines, skipping between markers +@c @cindex flag variables +This program fails because the range pattern is both turned on and turned off +by the first line, which just has a @samp{%} on it. To accomplish this task, +write the program in the following manner, using a flag: + +@cindex @code{!} (exclamation point), @code{!} operator +@example +/^%$/ @{ skip = ! skip; next @} +skip == 1 @{ next @} # skip lines with `skip' set +@end example + +In a range pattern, the comma (@samp{,}) has the lowest precedence of +all the operators (i.e., it is evaluated last). Thus, the following +program attempts to combine a range pattern with another, simpler test: + +@example +echo Yes | awk '/1/,/2/ || /Yes/' +@end example + +The intent of this program is @samp{(/1/,/2/) || /Yes/}. +However, @command{awk} interprets this as @samp{/1/, (/2/ || /Yes/)}. +This cannot be changed or worked around; range patterns do not combine +with other patterns: + +@example +$ @kbd{echo Yes | gawk '(/1/,/2/) || /Yes/'} +@error{} gawk: cmd. line:1: (/1/,/2/) || /Yes/ +@error{} gawk: cmd. line:1: ^ syntax error +@end example + +@node BEGIN/END +@subsection The @code{BEGIN} and @code{END} Special Patterns + +@c STARTOFRANGE beg +@cindex @code{BEGIN} pattern +@c STARTOFRANGE end +@cindex @code{END} pattern +All the patterns described so far are for matching input records. +The @code{BEGIN} and @code{END} special patterns are different. +They supply startup and cleanup actions for @command{awk} programs. +@code{BEGIN} and @code{END} rules must have actions; there is no default +action for these rules because there is no current record when they run. +@code{BEGIN} and @code{END} rules are often referred to as +``@code{BEGIN} and @code{END} blocks'' by long-time @command{awk} +programmers. + +@menu +* Using BEGIN/END:: How and why to use BEGIN/END rules. +* I/O And BEGIN/END:: I/O issues in BEGIN/END rules. +@end menu + +@node Using BEGIN/END +@subsubsection Startup and Cleanup Actions + +A @code{BEGIN} rule is executed once only, before the first input record +is read. Likewise, an @code{END} rule is executed once only, after all the +input is read. For example: + +@example +$ @kbd{awk '} +> @kbd{BEGIN @{ print "Analysis of \"foo\"" @}} +> @kbd{/foo/ @{ ++n @}} +> @kbd{END @{ print "\"foo\" appears", n, "times." @}' BBS-list} +@print{} Analysis of "foo" +@print{} "foo" appears 4 times. +@end example + +@cindex @code{BEGIN} pattern, operators and +@cindex @code{END} pattern, operators and +This program finds the number of records in the input file @file{BBS-list} +that contain the string @samp{foo}. The @code{BEGIN} rule prints a title +for the report. There is no need to use the @code{BEGIN} rule to +initialize the counter @code{n} to zero, since @command{awk} does this +automatically (@pxref{Variables}). +The second rule increments the variable @code{n} every time a +record containing the pattern @samp{foo} is read. The @code{END} rule +prints the value of @code{n} at the end of the run. + +The special patterns @code{BEGIN} and @code{END} cannot be used in ranges +or with Boolean operators (indeed, they cannot be used with any operators). +An @command{awk} program may have multiple @code{BEGIN} and/or @code{END} +rules. They are executed in the order in which they appear: all the @code{BEGIN} +rules at startup and all the @code{END} rules at termination. +@code{BEGIN} and @code{END} rules may be intermixed with other rules. +This feature was added in the 1987 version of @command{awk} and is included +in the POSIX standard. +The original (1978) version of @command{awk} +required the @code{BEGIN} rule to be placed at the beginning of the +program, the @code{END} rule to be placed at the end, and only allowed one of +each. +This is no longer required, but it is a good idea to follow this template +in terms of program organization and readability. + +Multiple @code{BEGIN} and @code{END} rules are useful for writing +library functions, because each library file can have its own @code{BEGIN} and/or +@code{END} rule to do its own initialization and/or cleanup. +The order in which library functions are named on the command line +controls the order in which their @code{BEGIN} and @code{END} rules are +executed. Therefore, you have to be careful when writing such rules in +library files so that the order in which they are executed doesn't matter. +@xref{Options}, for more information on +using library functions. +@xref{Library Functions}, +for a number of useful library functions. + +If an @command{awk} program has only @code{BEGIN} rules and no +other rules, then the program exits after the @code{BEGIN} rule is +run.@footnote{The original version of @command{awk} kept +reading and ignoring input until the end of the file was seen.} However, if an +@code{END} rule exists, then the input is read, even if there are +no other rules in the program. This is necessary in case the @code{END} +rule checks the @code{FNR} and @code{NR} variables. + +@node I/O And BEGIN/END +@subsubsection Input/Output from @code{BEGIN} and @code{END} Rules + +@cindex input/output, from @code{BEGIN} and @code{END} +There are several (sometimes subtle) points to remember when doing I/O +from a @code{BEGIN} or @code{END} rule. +The first has to do with the value of @code{$0} in a @code{BEGIN} +rule. Because @code{BEGIN} rules are executed before any input is read, +there simply is no input record, and therefore no fields, when +executing @code{BEGIN} rules. References to @code{$0} and the fields +yield a null string or zero, depending upon the context. One way +to give @code{$0} a real value is to execute a @code{getline} command +without a variable (@pxref{Getline}). +Another way is simply to assign a value to @code{$0}. + +@cindex differences in @command{awk} and @command{gawk}, @code{BEGIN}/@code{END} patterns +@cindex POSIX @command{awk}, @code{BEGIN}/@code{END} patterns +@cindex @code{print} statement, @code{BEGIN}/@code{END} patterns and +@cindex @code{BEGIN} pattern, @code{print} statement and +@cindex @code{END} pattern, @code{print} statement and +The second point is similar to the first but from the other direction. +Traditionally, due largely to implementation issues, @code{$0} and +@code{NF} were @emph{undefined} inside an @code{END} rule. +The POSIX standard specifies that @code{NF} is available in an @code{END} +rule. It contains the number of fields from the last input record. +Most probably due to an oversight, the standard does not say that @code{$0} +is also preserved, although logically one would think that it should be. +In fact, @command{gawk} does preserve the value of @code{$0} for use in +@code{END} rules. Be aware, however, that Brian Kernighan's @command{awk}, and possibly +other implementations, do not. + +The third point follows from the first two. The meaning of @samp{print} +inside a @code{BEGIN} or @code{END} rule is the same as always: +@samp{print $0}. If @code{$0} is the null string, then this prints an +empty record. Many long time @command{awk} programmers use an unadorned +@samp{print} in @code{BEGIN} and @code{END} rules, to mean @samp{@w{print ""}}, +relying on @code{$0} being null. Although one might generally get away with +this in @code{BEGIN} rules, it is a very bad idea in @code{END} rules, +at least in @command{gawk}. It is also poor style, since if an empty +line is needed in the output, the program should print one explicitly. + +@cindex @code{next} statement, @code{BEGIN}/@code{END} patterns and +@cindex @code{nextfile} statement, @code{BEGIN}/@code{END} patterns and +@cindex @code{BEGIN} pattern, @code{next}/@code{nextfile} statements and +@cindex @code{END} pattern, @code{next}/@code{nextfile} statements and +Finally, the @code{next} and @code{nextfile} statements are not allowed +in a @code{BEGIN} rule, because the implicit +read-a-record-and-match-against-the-rules loop has not started yet. Similarly, those statements +are not valid in an @code{END} rule, since all the input has been read. +(@xref{Next Statement}, and see +@ref{Nextfile Statement}.) +@c ENDOFRANGE beg +@c ENDOFRANGE end + +@node BEGINFILE/ENDFILE +@subsection The @code{BEGINFILE} and @code{ENDFILE} Special Patterns +@cindex @code{BEGINFILE} pattern +@cindex @code{ENDFILE} pattern + +This @value{SECTION} describes a @command{gawk}-specific feature. + +Two special kinds of rule, @code{BEGINFILE} and @code{ENDFILE}, give +you ``hooks'' into @command{gawk}'s command-line file processing loop. +As with the @code{BEGIN} and @code{END} rules (@pxref{BEGIN/END}), all +@code{BEGINFILE} rules in a program are merged, in the order they are +read by @command{gawk}, and all @code{ENDFILE} rules are merged as well. + +The body of the @code{BEGINFILE} rules is executed just before +@command{gawk} reads the first record from a file. @code{FILENAME} +is set to the name of the current file, and @code{FNR} is set to zero. + +The @code{BEGINFILE} rule provides you the opportunity for two tasks +that would otherwise be difficult or impossible to perform: + +@itemize @bullet +@item +You can test if the file is readable. Normally, it is a fatal error if a +file named on the command line cannot be opened for reading. However, +you can bypass the fatal error and move on to the next file on the +command line. + +@cindex @command{gawk}, @code{ERRNO} variable in +@cindex @code{ERRNO} variable +@cindex @code{nextfile} statement, @code{BEGINFILE}/@code{ENDFILE} patterns and +You do this by checking if the @code{ERRNO} variable is not the empty +string; if so, then @command{gawk} was not able to open the file. In +this case, your program can execute the @code{nextfile} statement +(@pxref{Nextfile Statement}). This causes @command{gawk} to skip +the file entirely. Otherwise, @command{gawk} exits with the usual +fatal error. + +@item +If you have written extensions that modify the record handling (by inserting +an ``open hook''), you can invoke them at this point, before @command{gawk} +has started processing the file. (This is a @emph{very} advanced feature, +currently used only by the @uref{http://xmlgawk.sourceforge.net, XMLgawk project}.) +@end itemize + +The @code{ENDFILE} rule is called when @command{gawk} has finished processing +the last record in an input file. For the last input file, +it will be called before any @code{END} rules. +The @code{ENDFILE} rule is executed even for empty input files. + +Normally, when an error occurs when reading input in the normal input +processing loop, the error is fatal. However, if an @code{ENDFILE} +rule is present, the error becomes non-fatal, and instead @code{ERRNO} +is set. This makes it possible to catch and process I/O errors at the +level of the @command{awk} program. + +@cindex @code{next} statement, @code{BEGINFILE}/@code{ENDFILE} patterns and +The @code{next} statement (@pxref{Next Statement}) is not allowed inside +either a @code{BEGINFILE} or and @code{ENDFILE} rule. The @code{nextfile} +statement (@pxref{Nextfile Statement}) is allowed only inside a +@code{BEGINFILE} rule, but not inside an @code{ENDFILE} rule. + +@cindex @code{getline} statement, @code{BEGINFILE}/@code{ENDFILE} patterns and +The @code{getline} statement (@pxref{Getline}) is restricted inside +both @code{BEGINFILE} and @code{ENDFILE}. Only the @samp{getline +@var{variable} < @var{file}} form is allowed. + +@code{BEGINFILE} and @code{ENDFILE} are @command{gawk} extensions. +In most other @command{awk} implementations, or if @command{gawk} is in +compatibility mode (@pxref{Options}), they are not special. + +@c FIXME: For 4.1 maybe deal with this? +@ignore +Date: Tue, 17 May 2011 02:06:10 PDT +From: rankin@pactechdata.com (Pat Rankin) +Message-Id: <110517015127.20240f4a@pactechdata.com> +Subject: BEGINFILE +To: arnold@skeeve.com + + The documentation for BEGINFILE states that FNR is 0, which seems +pretty obvious. It doesn't mention what the value of $0 is, and that's +not obvious. I think setting it to null before starting the BEGINFILE +action would be preferable to leaving whatever was there in the last +record of the previous file. + + ENDFILE can retain the last record in $0. I guess it has to if +the END rule's actions see that value too. But the beginning of a new +file doesn't just mean that the old one has been closed; the old file +is being superseded, so leaving the old data around feels wrong to me. +[If the user wants to keep it on hand, he or she can use an ENDFILE +rule to grab it before moving on to the next file.] +@end ignore + +@node Empty +@subsection The Empty Pattern + +@cindex empty pattern +@cindex patterns, empty +An empty (i.e., nonexistent) pattern is considered to match @emph{every} +input record. For example, the program: + +@example +awk '@{ print $1 @}' BBS-list +@end example + +@noindent +prints the first field of every record. +@c ENDOFRANGE pat + +@node Using Shell Variables +@section Using Shell Variables in Programs +@cindex shells, variables +@cindex @command{awk} programs, shell variables in +@c @cindex shell and @command{awk} interaction + +@command{awk} programs are often used as components in larger +programs written in shell. +For example, it is very common to use a shell variable to +hold a pattern that the @command{awk} program searches for. +There are two ways to get the value of the shell variable +into the body of the @command{awk} program. + +@cindex shells, quoting +The most common method is to use shell quoting to substitute +the variable's value into the program inside the script. +For example, in the following program: + +@example +printf "Enter search pattern: " +read pattern +awk "/$pattern/ "'@{ nmatches++ @} + END @{ print nmatches, "found" @}' /path/to/data +@end example + +@noindent +the @command{awk} program consists of two pieces of quoted text +that are concatenated together to form the program. +The first part is double-quoted, which allows substitution of +the @code{pattern} shell variable inside the quotes. +The second part is single-quoted. + +Variable substitution via quoting works, but can be potentially +messy. It requires a good understanding of the shell's quoting rules +(@pxref{Quoting}), +and it's often difficult to correctly +match up the quotes when reading the program. + +A better method is to use @command{awk}'s variable assignment feature +(@pxref{Assignment Options}) +to assign the shell variable's value to an @command{awk} variable's +value. Then use dynamic regexps to match the pattern +(@pxref{Computed Regexps}). +The following shows how to redo the +previous example using this technique: + +@example +printf "Enter search pattern: " +read pattern +awk -v pat="$pattern" '$0 ~ pat @{ nmatches++ @} + END @{ print nmatches, "found" @}' /path/to/data +@end example + +@noindent +Now, the @command{awk} program is just one single-quoted string. +The assignment @samp{-v pat="$pattern"} still requires double quotes, +in case there is whitespace in the value of @code{$pattern}. +The @command{awk} variable @code{pat} could be named @code{pattern} +too, but that would be more confusing. Using a variable also +provides more flexibility, since the variable can be used anywhere inside +the program---for printing, as an array subscript, or for any other +use---without requiring the quoting tricks at every point in the program. + +@node Action Overview +@section Actions +@c @cindex action, definition of +@c @cindex curly braces +@c @cindex action, curly braces +@c @cindex action, separating statements +@cindex actions + +An @command{awk} program or script consists of a series of +rules and function definitions interspersed. (Functions are +described later. @xref{User-defined}.) +A rule contains a pattern and an action, either of which (but not +both) may be omitted. The purpose of the @dfn{action} is to tell +@command{awk} what to do once a match for the pattern is found. Thus, +in outline, an @command{awk} program generally looks like this: + +@example +@r{[}@var{pattern}@r{]} @{ @var{action} @} + @var{pattern} @r{[}@{ @var{action} @}@r{]} +@dots{} +function @var{name}(@var{args}) @{ @dots{} @} +@dots{} +@end example + +@cindex @code{@{@}} (braces), actions and +@cindex braces (@code{@{@}}), actions and +@cindex separators, for statements in actions +@cindex newlines, separating statements in actions +@cindex @code{;} (semicolon), separating statements in actions +@cindex semicolon (@code{;}), separating statements in actions +An action consists of one or more @command{awk} @dfn{statements}, enclosed +in curly braces (@samp{@{@dots{}@}}). Each statement specifies one +thing to do. The statements are separated by newlines or semicolons. +The curly braces around an action must be used even if the action +contains only one statement, or if it contains no statements at +all. However, if you omit the action entirely, omit the curly braces as +well. An omitted action is equivalent to @samp{@{ print $0 @}}: + +@example +/foo/ @{ @} @ii{match @code{foo}, do nothing --- empty action} +/foo/ @ii{match @code{foo}, print the record --- omitted action} +@end example + +The following types of statements are supported in @command{awk}: + +@table @asis +@cindex side effects, statements +@item Expressions +Call functions or assign values to variables +(@pxref{Expressions}). Executing +this kind of statement simply computes the value of the expression. +This is useful when the expression has side effects +(@pxref{Assignment Ops}). + +@item Control statements +Specify the control flow of @command{awk} +programs. The @command{awk} language gives you C-like constructs +(@code{if}, @code{for}, @code{while}, and @code{do}) as well as a few +special ones (@pxref{Statements}). + +@item Compound statements +Consist of one or more statements enclosed in +curly braces. A compound statement is used in order to put several +statements together in the body of an @code{if}, @code{while}, @code{do}, +or @code{for} statement. + +@item Input statements +Use the @code{getline} command +(@pxref{Getline}). +Also supplied in @command{awk} are the @code{next} +statement (@pxref{Next Statement}), +and the @code{nextfile} statement +(@pxref{Nextfile Statement}). + +@item Output statements +Such as @code{print} and @code{printf}. +@xref{Printing}. + +@item Deletion statements +For deleting array elements. +@xref{Delete}. +@end table + +@node Statements +@section Control Statements in Actions +@c STARTOFRANGE csta +@cindex control statements +@c STARTOFRANGE acs +@cindex statements, control, in actions +@c STARTOFRANGE accs +@cindex actions, control statements in + +@dfn{Control statements}, such as @code{if}, @code{while}, and so on, +control the flow of execution in @command{awk} programs. Most of @command{awk}'s +control statements are patterned after similar statements in C. + +@cindex compound statements@comma{} control statements and +@cindex statements, compound@comma{} control statements and +@cindex body, in actions +@cindex @code{@{@}} (braces), statements, grouping +@cindex braces (@code{@{@}}), statements, grouping +@cindex newlines, separating statements in actions +@cindex @code{;} (semicolon), separating statements in actions +@cindex semicolon (@code{;}), separating statements in actions +All the control statements start with special keywords, such as @code{if} +and @code{while}, to distinguish them from simple expressions. +Many control statements contain other statements. For example, the +@code{if} statement contains another statement that may or may not be +executed. The contained statement is called the @dfn{body}. +To include more than one statement in the body, group them into a +single @dfn{compound statement} with curly braces, separating them with +newlines or semicolons. + +@menu +* If Statement:: Conditionally execute some @command{awk} + statements. +* While Statement:: Loop until some condition is satisfied. +* Do Statement:: Do specified action while looping until some + condition is satisfied. +* For Statement:: Another looping statement, that provides + initialization and increment clauses. +* Switch Statement:: Switch/case evaluation for conditional + execution of statements based on a value. +* Break Statement:: Immediately exit the innermost enclosing loop. +* Continue Statement:: Skip to the end of the innermost enclosing + loop. +* Next Statement:: Stop processing the current input record. +* Nextfile Statement:: Stop processing the current file. +* Exit Statement:: Stop execution of @command{awk}. +@end menu + +@node If Statement +@subsection The @code{if}-@code{else} Statement + +@cindex @code{if} statement +The @code{if}-@code{else} statement is @command{awk}'s decision-making +statement. It looks like this: + +@example +if (@var{condition}) @var{then-body} @r{[}else @var{else-body}@r{]} +@end example + +@noindent +The @var{condition} is an expression that controls what the rest of the +statement does. If the @var{condition} is true, @var{then-body} is +executed; otherwise, @var{else-body} is executed. +The @code{else} part of the statement is +optional. The condition is considered false if its value is zero or +the null string; otherwise, the condition is true. +Refer to the following: + +@example +if (x % 2 == 0) + print "x is even" +else + print "x is odd" +@end example + +In this example, if the expression @samp{x % 2 == 0} is true (that is, +if the value of @code{x} is evenly divisible by two), then the first +@code{print} statement is executed; otherwise, the second @code{print} +statement is executed. +If the @code{else} keyword appears on the same line as @var{then-body} and +@var{then-body} is not a compound statement (i.e., not surrounded by +curly braces), then a semicolon must separate @var{then-body} from +the @code{else}. +To illustrate this, the previous example can be rewritten as: + +@example +if (x % 2 == 0) print "x is even"; else + print "x is odd" +@end example + +@noindent +If the @samp{;} is left out, @command{awk} can't interpret the statement and +it produces a syntax error. Don't actually write programs this way, +because a human reader might fail to see the @code{else} if it is not +the first thing on its line. + +@node While Statement +@subsection The @code{while} Statement +@cindex @code{while} statement +@cindex loops +@cindex loops, See Also @code{while} statement + +In programming, a @dfn{loop} is a part of a program that can +be executed two or more times in succession. +The @code{while} statement is the simplest looping statement in +@command{awk}. It repeatedly executes a statement as long as a condition is +true. For example: + +@example +while (@var{condition}) + @var{body} +@end example + +@cindex body, in loops +@noindent +@var{body} is a statement called the @dfn{body} of the loop, +and @var{condition} is an expression that controls how long the loop +keeps running. +The first thing the @code{while} statement does is test the @var{condition}. +If the @var{condition} is true, it executes the statement @var{body}. +@ifinfo +(The @var{condition} is true when the value +is not zero and not a null string.) +@end ifinfo +After @var{body} has been executed, +@var{condition} is tested again, and if it is still true, @var{body} is +executed again. This process repeats until the @var{condition} is no longer +true. If the @var{condition} is initially false, the body of the loop is +never executed and @command{awk} continues with the statement following +the loop. +This example prints the first three fields of each record, one per line: + +@example +awk '@{ + i = 1 + while (i <= 3) @{ + print $i + i++ + @} +@}' inventory-shipped +@end example + +@noindent +The body of this loop is a compound statement enclosed in braces, +containing two statements. +The loop works in the following manner: first, the value of @code{i} is set to one. +Then, the @code{while} statement tests whether @code{i} is less than or equal to +three. This is true when @code{i} equals one, so the @code{i}-th +field is printed. Then the @samp{i++} increments the value of @code{i} +and the loop repeats. The loop terminates when @code{i} reaches four. + +A newline is not required between the condition and the +body; however using one makes the program clearer unless the body is a +compound statement or else is very simple. The newline after the open-brace +that begins the compound statement is not required either, but the +program is harder to read without it. + +@node Do Statement +@subsection The @code{do}-@code{while} Statement +@cindex @code{do}-@code{while} statement + +The @code{do} loop is a variation of the @code{while} looping statement. +The @code{do} loop executes the @var{body} once and then repeats the +@var{body} as long as the @var{condition} is true. It looks like this: + +@example +do + @var{body} +while (@var{condition}) +@end example + +Even if the @var{condition} is false at the start, the @var{body} is +executed at least once (and only once, unless executing @var{body} +makes @var{condition} true). Contrast this with the corresponding +@code{while} statement: + +@example +while (@var{condition}) + @var{body} +@end example + +@noindent +This statement does not execute @var{body} even once if the @var{condition} +is false to begin with. +The following is an example of a @code{do} statement: + +@example +@{ + i = 1 + do @{ + print $0 + i++ + @} while (i <= 10) +@} +@end example + +@noindent +This program prints each input record 10 times. However, it isn't a very +realistic example, since in this case an ordinary @code{while} would do +just as well. This situation reflects actual experience; only +occasionally is there a real use for a @code{do} statement. + +@node For Statement +@subsection The @code{for} Statement +@cindex @code{for} statement + +The @code{for} statement makes it more convenient to count iterations of a +loop. The general form of the @code{for} statement looks like this: + +@example +for (@var{initialization}; @var{condition}; @var{increment}) + @var{body} +@end example + +@noindent +The @var{initialization}, @var{condition}, and @var{increment} parts are +arbitrary @command{awk} expressions, and @var{body} stands for any +@command{awk} statement. + +The @code{for} statement starts by executing @var{initialization}. +Then, as long +as the @var{condition} is true, it repeatedly executes @var{body} and then +@var{increment}. Typically, @var{initialization} sets a variable to +either zero or one, @var{increment} adds one to it, and @var{condition} +compares it against the desired number of iterations. +For example: + +@example +awk '@{ + for (i = 1; i <= 3; i++) + print $i +@}' inventory-shipped +@end example + +@noindent +This prints the first three fields of each input record, with one field per +line. + +It isn't possible to +set more than one variable in the +@var{initialization} part without using a multiple assignment statement +such as @samp{x = y = 0}. This makes sense only if all the initial values +are equal. (But it is possible to initialize additional variables by writing +their assignments as separate statements preceding the @code{for} loop.) + +@c @cindex comma operator, not supported +The same is true of the @var{increment} part. Incrementing additional +variables requires separate statements at the end of the loop. +The C compound expression, using C's comma operator, is useful in +this context but it is not supported in @command{awk}. + +Most often, @var{increment} is an increment expression, as in the previous +example. But this is not required; it can be any expression +whatsoever. For example, the following statement prints all the powers of two +between 1 and 100: + +@example +for (i = 1; i <= 100; i *= 2) + print i +@end example + +If there is nothing to be done, any of the three expressions in the +parentheses following the @code{for} keyword may be omitted. Thus, +@w{@samp{for (; x > 0;)}} is equivalent to @w{@samp{while (x > 0)}}. If the +@var{condition} is omitted, it is treated as true, effectively +yielding an @dfn{infinite loop} (i.e., a loop that never terminates). + +In most cases, a @code{for} loop is an abbreviation for a @code{while} +loop, as shown here: + +@example +@var{initialization} +while (@var{condition}) @{ + @var{body} + @var{increment} +@} +@end example + +@cindex loops, @code{continue} statements and +@noindent +The only exception is when the @code{continue} statement +(@pxref{Continue Statement}) is used +inside the loop. Changing a @code{for} statement to a @code{while} +statement in this way can change the effect of the @code{continue} +statement inside the loop. + +The @command{awk} language has a @code{for} statement in addition to a +@code{while} statement because a @code{for} loop is often both less work to +type and more natural to think of. Counting the number of iterations is +very common in loops. It can be easier to think of this counting as part +of looping rather than as something to do inside the loop. + +@cindex @code{in} operator +There is an alternate version of the @code{for} loop, for iterating over +all the indices of an array: + +@example +for (i in array) + @var{do something with} array[i] +@end example + +@noindent +@xref{Scanning an Array}, +for more information on this version of the @code{for} loop. + +@node Switch Statement +@subsection The @code{switch} Statement +@cindex @code{switch} statement +@cindex @code{case} keyword +@cindex @code{default} keyword + +The @code{switch} statement allows the evaluation of an expression and +the execution of statements based on a @code{case} match. Case statements +are checked for a match in the order they are defined. If no suitable +@code{case} is found, the @code{default} section is executed, if supplied. + +Each @code{case} contains a single constant, be it numeric, string, or +regexp. The @code{switch} expression is evaluated, and then each +@code{case}'s constant is compared against the result in turn. The type of constant +determines the comparison: numeric or string do the usual comparisons. +A regexp constant does a regular expression match against the string +value of the original expression. The general form of the @code{switch} +statement looks like this: + +@example +switch (@var{expression}) @{ +case @var{value or regular expression}: + @var{case-body} +default: + @var{default-body} +@} +@end example + +Control flow in +the @code{switch} statement works as it does in C. Once a match to a given +case is made, the case statement bodies execute until a @code{break}, +@code{continue}, @code{next}, @code{nextfile} or @code{exit} is encountered, +or the end of the @code{switch} statement itself. For example: + +@example +switch (NR * 2 + 1) @{ +case 3: +case "11": + print NR - 1 + break + +case /2[[:digit:]]+/: + print NR + +default: + print NR + 1 + +case -1: + print NR * -1 +@} +@end example + +Note that if none of the statements specified above halt execution +of a matched @code{case} statement, execution falls through to the +next @code{case} until execution halts. In the above example, for +any case value starting with @samp{2} followed by one or more digits, +the @code{print} statement is executed and then falls through into the +@code{default} section, executing its @code{print} statement. In turn, +the @minus{}1 case will also be executed since the @code{default} does +not halt execution. + +This @code{switch} statement is a @command{gawk} extension. +If @command{gawk} is in compatibility mode +(@pxref{Options}), +it is not available. + +@node Break Statement +@subsection The @code{break} Statement +@cindex @code{break} statement +@cindex loops, exiting + +The @code{break} statement jumps out of the innermost @code{for}, +@code{while}, or @code{do} loop that encloses it. The following example +finds the smallest divisor of any integer, and also identifies prime +numbers: + +@example +# find smallest divisor of num +@{ + num = $1 + for (div = 2; div * div <= num; div++) @{ + if (num % div == 0) + break + @} + if (num % div == 0) + printf "Smallest divisor of %d is %d\n", num, div + else + printf "%d is prime\n", num +@} +@end example + +When the remainder is zero in the first @code{if} statement, @command{awk} +immediately @dfn{breaks out} of the containing @code{for} loop. This means +that @command{awk} proceeds immediately to the statement following the loop +and continues processing. (This is very different from the @code{exit} +statement, which stops the entire @command{awk} program. +@xref{Exit Statement}.) + +The following program illustrates how the @var{condition} of a @code{for} +or @code{while} statement could be replaced with a @code{break} inside +an @code{if}: + +@example +# find smallest divisor of num +@{ + num = $1 + for (div = 2; ; div++) @{ + if (num % div == 0) @{ + printf "Smallest divisor of %d is %d\n", num, div + break + @} + if (div * div > num) @{ + printf "%d is prime\n", num + break + @} + @} +@} +@end example + +The @code{break} statement is also used to break out of the +@code{switch} statement. +This is discussed in @ref{Switch Statement}. + +@c @cindex @code{break}, outside of loops +@c @cindex historical features +@c @cindex @command{awk} language, POSIX version +@cindex POSIX @command{awk}, @code{break} statement and +@cindex dark corner, @code{break} statement +@cindex @command{gawk}, @code{break} statement in +The @code{break} statement has no meaning when +used outside the body of a loop or @code{switch}. +However, although it was never documented, +historical implementations of @command{awk} treated the @code{break} +statement outside of a loop as if it were a @code{next} statement +(@pxref{Next Statement}). +@value{DARKCORNER} +Recent versions of Brian Kernighan's @command{awk} no longer allow this usage, +nor does @command{gawk}. + +@node Continue Statement +@subsection The @code{continue} Statement + +@cindex @code{continue} statement +Similar to @code{break}, the @code{continue} statement is used only inside +@code{for}, @code{while}, and @code{do} loops. It skips +over the rest of the loop body, causing the next cycle around the loop +to begin immediately. Contrast this with @code{break}, which jumps out +of the loop altogether. + +The @code{continue} statement in a @code{for} loop directs @command{awk} to +skip the rest of the body of the loop and resume execution with the +increment-expression of the @code{for} statement. The following program +illustrates this fact: + +@example +BEGIN @{ + for (x = 0; x <= 20; x++) @{ + if (x == 5) + continue + printf "%d ", x + @} + print "" +@} +@end example + +@noindent +This program prints all the numbers from 0 to 20---except for 5, for +which the @code{printf} is skipped. Because the increment @samp{x++} +is not skipped, @code{x} does not remain stuck at 5. Contrast the +@code{for} loop from the previous example with the following @code{while} loop: + +@example +BEGIN @{ + x = 0 + while (x <= 20) @{ + if (x == 5) + continue + printf "%d ", x + x++ + @} + print "" +@} +@end example + +@noindent +This program loops forever once @code{x} reaches 5. + +@c @cindex @code{continue}, outside of loops +@c @cindex historical features +@c @cindex @command{awk} language, POSIX version +@cindex POSIX @command{awk}, @code{continue} statement and +@cindex dark corner, @code{continue} statement +@cindex @command{gawk}, @code{continue} statement in +The @code{continue} statement has no special meaning with respect to the +@code{switch} statement, nor does it have any meaning when used outside the +body of a loop. Historical versions of @command{awk} treated a @code{continue} +statement outside a loop the same way they treated a @code{break} +statement outside a loop: as if it were a @code{next} +statement +(@pxref{Next Statement}). +@value{DARKCORNER} +Recent versions of Brian Kernighan's @command{awk} no longer work this way, nor +does @command{gawk}. + +@node Next Statement +@subsection The @code{next} Statement +@cindex @code{next} statement + +The @code{next} statement forces @command{awk} to immediately stop processing +the current record and go on to the next record. This means that no +further rules are executed for the current record, and the rest of the +current rule's action isn't executed. + +Contrast this with the effect of the @code{getline} function +(@pxref{Getline}). That also causes +@command{awk} to read the next record immediately, but it does not alter the +flow of control in any way (i.e., the rest of the current action executes +with a new input record). + +@cindex @command{awk} programs, execution of +At the highest level, @command{awk} program execution is a loop that reads +an input record and then tests each rule's pattern against it. If you +think of this loop as a @code{for} statement whose body contains the +rules, then the @code{next} statement is analogous to a @code{continue} +statement. It skips to the end of the body of this implicit loop and +executes the increment (which reads another record). + +For example, suppose an @command{awk} program works only on records +with four fields, and it shouldn't fail when given bad input. To avoid +complicating the rest of the program, write a ``weed out'' rule near +the beginning, in the following manner: + +@example +NF != 4 @{ + err = sprintf("%s:%d: skipped: NF != 4\n", FILENAME, FNR) + print err > "/dev/stderr" + next +@} +@end example + +@noindent +Because of the @code{next} statement, +the program's subsequent rules won't see the bad record. The error +message is redirected to the standard error output stream, as error +messages should be. +For more detail see +@ref{Special Files}. + +If the @code{next} statement causes the end of the input to be reached, +then the code in any @code{END} rules is executed. +@xref{BEGIN/END}. + +The @code{next} statement is not allowed inside @code{BEGINFILE} and +@code{ENDFILE} rules. @xref{BEGINFILE/ENDFILE}. + +@c @cindex @command{awk} language, POSIX version +@c @cindex @code{next}, inside a user-defined function +@cindex @code{BEGIN} pattern, @code{next}/@code{nextfile} statements and +@cindex @code{END} pattern, @code{next}/@code{nextfile} statements and +@cindex POSIX @command{awk}, @code{next}/@code{nextfile} statements and +@cindex @code{next} statement, user-defined functions and +@cindex functions, user-defined, @code{next}/@code{nextfile} statements and +According to the POSIX standard, the behavior is undefined if +the @code{next} statement is used in a @code{BEGIN} or @code{END} rule. +@command{gawk} treats it as a syntax error. +Although POSIX permits it, +some other @command{awk} implementations don't allow the @code{next} +statement inside function bodies +(@pxref{User-defined}). +Just as with any other @code{next} statement, a @code{next} statement inside a +function body reads the next record and starts processing it with the +first rule in the program. + +@node Nextfile Statement +@subsection Using @command{gawk}'s @code{nextfile} Statement +@cindex @code{nextfile} statement +@cindex differences in @command{awk} and @command{gawk}, @code{next}/@code{nextfile} statements + +@cindex common extensions, @code{nextfile} statement +@cindex extensions, common@comma{} @code{nextfile} statement +@command{gawk} provides the @code{nextfile} statement, +which is similar to the @code{next} statement. @value{COMMONEXT} +However, instead of abandoning processing of the current record, the +@code{nextfile} statement instructs @command{gawk} to stop processing the +current @value{DF}. + +The @code{nextfile} statement is a @command{gawk} extension. +In most other @command{awk} implementations, +or if @command{gawk} is in compatibility mode +(@pxref{Options}), +@code{nextfile} is not special. + +Upon execution of the @code{nextfile} statement, +any @code{ENDFILE} rules are executed except in the case as +mentioned below, @code{FILENAME} is +updated to the name of the next @value{DF} listed on the command line, +@code{FNR} is reset to one, @code{ARGIND} is incremented, +any @code{BEGINFILE} rules are executed, and processing +starts over with the first rule in the program. +(@code{ARGIND} hasn't been introduced yet. @xref{Built-in Variables}.) +If the @code{nextfile} statement causes the end of the input to be reached, +then the code in any @code{END} rules is executed. An exception to this is +when the @code{nextfile} is invoked during execution of any statement in an +@code{END} rule; In this case, it causes the program to stop immediately. @xref{BEGIN/END}. + +The @code{nextfile} statement is useful when there are many @value{DF}s +to process but it isn't necessary to process every record in every file. +Normally, in order to move on to the next @value{DF}, a program +has to continue scanning the unwanted records. The @code{nextfile} +statement accomplishes this much more efficiently. + +In addition, @code{nextfile} is useful inside a @code{BEGINFILE} +rule to skip over a file that would otherwise cause @command{gawk} +to exit with a fatal error. In this case, @code{ENDFILE} rules are not +executed. @xref{BEGINFILE/ENDFILE}. + +While one might think that @samp{close(FILENAME)} would accomplish +the same as @code{nextfile}, this isn't true. @code{close()} is +reserved for closing files, pipes, and coprocesses that are +opened with redirections. It is not related to the main processing that +@command{awk} does with the files listed in @code{ARGV}. + +@cindex functions, user-defined, @code{next}/@code{nextfile} statements and +@cindex @code{nextfile} statement, user-defined functions and +The current version of the Brian Kernighan's @command{awk} (@pxref{Other +Versions}) also supports @code{nextfile}. However, it doesn't allow the +@code{nextfile} statement inside function bodies (@pxref{User-defined}). +@command{gawk} does; a @code{nextfile} inside a function body reads the +next record and starts processing it with the first rule in the program, +just as any other @code{nextfile} statement. + +@node Exit Statement +@subsection The @code{exit} Statement + +@cindex @code{exit} statement +The @code{exit} statement causes @command{awk} to immediately stop +executing the current rule and to stop processing input; any remaining input +is ignored. The @code{exit} statement is written as follows: + +@example +exit @r{[}@var{return code}@r{]} +@end example + +@cindex @code{BEGIN} pattern, @code{exit} statement and +@cindex @code{END} pattern, @code{exit} statement and +When an @code{exit} statement is executed from a @code{BEGIN} rule, the +program stops processing everything immediately. No input records are +read. However, if an @code{END} rule is present, +as part of executing the @code{exit} statement, +the @code{END} rule is executed +(@pxref{BEGIN/END}). +If @code{exit} is used in the body of an @code{END} rule, it causes +the program to stop immediately. + +An @code{exit} statement that is not part of a @code{BEGIN} or @code{END} +rule stops the execution of any further automatic rules for the current +record, skips reading any remaining input records, and executes the +@code{END} rule if there is one. +Any @code{ENDFILE} rules are also skipped; they are not executed. + +In such a case, +if you don't want the @code{END} rule to do its job, set a variable +to nonzero before the @code{exit} statement and check that variable in +the @code{END} rule. +@xref{Assert Function}, +for an example that does this. + +@cindex dark corner, @code{exit} statement +If an argument is supplied to @code{exit}, its value is used as the exit +status code for the @command{awk} process. If no argument is supplied, +@code{exit} causes @command{awk} to return a ``success'' status. +In the case where an argument +is supplied to a first @code{exit} statement, and then @code{exit} is +called a second time from an @code{END} rule with no argument, +@command{awk} uses the previously supplied exit value. +@value{DARKCORNER} +@xref{Exit Status}, for more information. + +@cindex programming conventions, @code{exit} statement +For example, suppose an error condition occurs that is difficult or +impossible to handle. Conventionally, programs report this by +exiting with a nonzero status. An @command{awk} program can do this +using an @code{exit} statement with a nonzero argument, as shown +in the following example: + +@example +BEGIN @{ + if (("date" | getline date_now) <= 0) @{ + print "Can't get system date" > "/dev/stderr" + exit 1 + @} + print "current date is", date_now + close("date") +@} +@end example + +@quotation NOTE +For full portability, exit values should be between zero and 126, inclusive. +Negative values, and values of 127 or greater, may not produce consistent +results across different operating systems. +@end quotation + +@c ENDOFRANGE csta +@c ENDOFRANGE acs +@c ENDOFRANGE accs + +@node Built-in Variables +@section Built-in Variables +@c STARTOFRANGE bvar +@cindex built-in variables +@c STARTOFRANGE varb +@cindex variables, built-in + +Most @command{awk} variables are available to use for your own +purposes; they never change unless your program assigns values to +them, and they never affect anything unless your program examines them. +However, a few variables in @command{awk} have special built-in meanings. +@command{awk} examines some of these automatically, so that they enable you +to tell @command{awk} how to do certain things. Others are set +automatically by @command{awk}, so that they carry information from the +internal workings of @command{awk} to your program. + +@cindex @command{gawk}, built-in variables and +This @value{SECTION} documents all the built-in variables of +@command{gawk}, most of which are also documented in the chapters +describing their areas of activity. + +@menu +* User-modified:: Built-in variables that you change to control + @command{awk}. +* Auto-set:: Built-in variables where @command{awk} gives + you information. +* ARGC and ARGV:: Ways to use @code{ARGC} and @code{ARGV}. +@end menu + +@node User-modified +@subsection Built-in Variables That Control @command{awk} +@c STARTOFRANGE bvaru +@cindex built-in variables, user-modifiable +@c STARTOFRANGE nmbv +@cindex user-modifiable variables + +The following is an alphabetical list of variables that you can change to +control how @command{awk} does certain things. The variables that are +specific to @command{gawk} are marked with a pound sign@w{ (@samp{#}).} + +@table @code +@cindex @code{BINMODE} variable +@cindex binary input/output +@cindex input/output, binary +@item BINMODE # +On non-POSIX systems, this variable specifies use of binary mode for all I/O. +Numeric values of one, two, or three specify that input files, output files, or +all files, respectively, should use binary I/O. +A numeric value less than zero is treated as zero, and a numeric value greater than +three is treated as three. +Alternatively, +string values of @code{"r"} or @code{"w"} specify that input files and +output files, respectively, should use binary I/O. +A string value of @code{"rw"} or @code{"wr"} indicates that all +files should use binary I/O. +Any other string value is treated the same as @code{"rw"}, +but causes @command{gawk} +to generate a warning message. +@code{BINMODE} is described in more detail in +@ref{PC Using}. + +@cindex differences in @command{awk} and @command{gawk}, @code{BINMODE} variable +This variable is a @command{gawk} extension. +In other @command{awk} implementations +(except @command{mawk}, +@pxref{Other Versions}), +or if @command{gawk} is in compatibility mode +(@pxref{Options}), +it is not special. + +@cindex @code{CONVFMT} variable +@cindex POSIX @command{awk}, @code{CONVFMT} variable and +@cindex numbers, converting, to strings +@cindex strings, converting, numbers to +@item CONVFMT +This string controls conversion of numbers to +strings (@pxref{Conversion}). +It works by being passed, in effect, as the first argument to the +@code{sprintf()} function +(@pxref{String Functions}). +Its default value is @code{"%.6g"}. +@code{CONVFMT} was introduced by the POSIX standard. + +@cindex @command{gawk}, @code{FIELDWIDTHS} variable in +@cindex @code{FIELDWIDTHS} variable +@cindex differences in @command{awk} and @command{gawk}, @code{FIELDWIDTHS} variable +@cindex field separators, @code{FIELDWIDTHS} variable and +@cindex separators, field, @code{FIELDWIDTHS} variable and +@item FIELDWIDTHS # +This is a space-separated list of columns that tells @command{gawk} +how to split input with fixed columnar boundaries. +Assigning a value to @code{FIELDWIDTHS} +overrides the use of @code{FS} and @code{FPAT} for field splitting. +@xref{Constant Size}, for more information. + +If @command{gawk} is in compatibility mode +(@pxref{Options}), then @code{FIELDWIDTHS} +has no special meaning, and field-splitting operations occur based +exclusively on the value of @code{FS}. + +@cindex @command{gawk}, @code{FPAT} variable in +@cindex @code{FPAT} variable +@cindex differences in @command{awk} and @command{gawk}, @code{FPAT} variable +@cindex field separators, @code{FPAT} variable and +@cindex separators, field, @code{FPAT} variable and +@item FPAT # +This is a regular expression (as a string) that tells @command{gawk} +to create the fields based on text that matches the regular expression. +Assigning a value to @code{FPAT} +overrides the use of @code{FS} and @code{FIELDWIDTHS} for field splitting. +@xref{Splitting By Content}, for more information. + +If @command{gawk} is in compatibility mode +(@pxref{Options}), then @code{FPAT} +has no special meaning, and field-splitting operations occur based +exclusively on the value of @code{FS}. + +@cindex @code{FS} variable +@cindex separators, field +@cindex field separators +@item FS +This is the input field separator +(@pxref{Field Separators}). +The value is a single-character string or a multi-character regular +expression that matches the separations between fields in an input +record. If the value is the null string (@code{""}), then each +character in the record becomes a separate field. +(This behavior is a @command{gawk} extension. POSIX @command{awk} does not +specify the behavior when @code{FS} is the null string. +Nonetheless, some other versions of @command{awk} also treat +@code{""} specially.) + +@cindex POSIX @command{awk}, @code{FS} variable and +The default value is @w{@code{" "}}, a string consisting of a single +space. As a special exception, this value means that any +sequence of spaces, TABs, and/or newlines is a single separator.@footnote{In +POSIX @command{awk}, newline does not count as whitespace.} It also causes +spaces, TABs, and newlines at the beginning and end of a record to be ignored. + +You can set the value of @code{FS} on the command line using the +@option{-F} option: + +@example +awk -F, '@var{program}' @var{input-files} +@end example + +@cindex @command{gawk}, field separators and +If @command{gawk} is using @code{FIELDWIDTHS} or @code{FPAT} +for field splitting, +assigning a value to @code{FS} causes @command{gawk} to return to +the normal, @code{FS}-based field splitting. An easy way to do this +is to simply say @samp{FS = FS}, perhaps with an explanatory comment. + +@cindex @command{gawk}, @code{IGNORECASE} variable in +@cindex @code{IGNORECASE} variable +@cindex differences in @command{awk} and @command{gawk}, @code{IGNORECASE} variable +@cindex case sensitivity, string comparisons and +@cindex case sensitivity, regexps and +@cindex regular expressions, case sensitivity +@item IGNORECASE # +If @code{IGNORECASE} is nonzero or non-null, then all string comparisons +and all regular expression matching are case independent. Thus, regexp +matching with @samp{~} and @samp{!~}, as well as the @code{gensub()}, +@code{gsub()}, @code{index()}, @code{match()}, @code{patsplit()}, +@code{split()}, and @code{sub()} +functions, record termination with @code{RS}, and field splitting with +@code{FS} and @code{FPAT}, all ignore case when doing their particular regexp operations. +However, the value of @code{IGNORECASE} does @emph{not} affect array subscripting +and it does not affect field splitting when using a single-character +field separator. +@xref{Case-sensitivity}. + +If @command{gawk} is in compatibility mode +(@pxref{Options}), +then @code{IGNORECASE} has no special meaning. Thus, string +and regexp operations are always case-sensitive. + +@cindex @command{gawk}, @code{LINT} variable in +@cindex @code{LINT} variable +@cindex differences in @command{awk} and @command{gawk}, @code{LINT} variable +@cindex lint checking +@item LINT # +When this variable is true (nonzero or non-null), @command{gawk} +behaves as if the @option{--lint} command-line option is in effect. +(@pxref{Options}). +With a value of @code{"fatal"}, lint warnings become fatal errors. +With a value of @code{"invalid"}, only warnings about things that are +actually invalid are issued. (This is not fully implemented yet.) +Any other true value prints nonfatal warnings. +Assigning a false value to @code{LINT} turns off the lint warnings. + +This variable is a @command{gawk} extension. It is not special +in other @command{awk} implementations. Unlike the other special variables, +changing @code{LINT} does affect the production of lint warnings, +even if @command{gawk} is in compatibility mode. Much as +the @option{--lint} and @option{--traditional} options independently +control different aspects of @command{gawk}'s behavior, the control +of lint warnings during program execution is independent of the flavor +of @command{awk} being executed. + +@cindex @code{OFMT} variable +@cindex numbers, converting, to strings +@cindex strings, converting, numbers to +@item OFMT +This string controls conversion of numbers to +strings (@pxref{Conversion}) for +printing with the @code{print} statement. It works by being passed +as the first argument to the @code{sprintf()} function +(@pxref{String Functions}). +Its default value is @code{"%.6g"}. Earlier versions of @command{awk} +also used @code{OFMT} to specify the format for converting numbers to +strings in general expressions; this is now done by @code{CONVFMT}. + +@cindex @code{sprintf()} function, @code{OFMT} variable and +@cindex @code{print} statement, @code{OFMT} variable and +@cindex @code{OFS} variable +@cindex separators, field +@cindex field separators +@item OFS +This is the output field separator (@pxref{Output Separators}). It is +output between the fields printed by a @code{print} statement. Its +default value is @w{@code{" "}}, a string consisting of a single space. + +@cindex @code{ORS} variable +@item ORS +This is the output record separator. It is output at the end of every +@code{print} statement. Its default value is @code{"\n"}, the newline +character. (@xref{Output Separators}.) + +@cindex @code{RS} variable +@cindex separators, for records +@cindex record separators +@item RS +This is @command{awk}'s input record separator. Its default value is a string +containing a single newline character, which means that an input record +consists of a single line of text. +It can also be the null string, in which case records are separated by +runs of blank lines. +If it is a regexp, records are separated by +matches of the regexp in the input text. +(@xref{Records}.) + +The ability for @code{RS} to be a regular expression +is a @command{gawk} extension. +In most other @command{awk} implementations, +or if @command{gawk} is in compatibility mode +(@pxref{Options}), +just the first character of @code{RS}'s value is used. + +@cindex @code{SUBSEP} variable +@cindex separators, subscript +@cindex subscript separators +@item SUBSEP +This is the subscript separator. It has the default value of +@code{"\034"} and is used to separate the parts of the indices of a +multidimensional array. Thus, the expression @code{@w{foo["A", "B"]}} +really accesses @code{foo["A\034B"]} +(@pxref{Multi-dimensional}). + +@cindex @command{gawk}, @code{TEXTDOMAIN} variable in +@cindex @code{TEXTDOMAIN} variable +@cindex differences in @command{awk} and @command{gawk}, @code{TEXTDOMAIN} variable +@cindex internationalization, localization +@item TEXTDOMAIN # +This variable is used for internationalization of programs at the +@command{awk} level. It sets the default text domain for specially +marked string constants in the source text, as well as for the +@code{dcgettext()}, @code{dcngettext()} and @code{bindtextdomain()} functions +(@pxref{Internationalization}). +The default value of @code{TEXTDOMAIN} is @code{"messages"}. + +This variable is a @command{gawk} extension. +In other @command{awk} implementations, +or if @command{gawk} is in compatibility mode +(@pxref{Options}), +it is not special. +@end table +@c ENDOFRANGE bvar +@c ENDOFRANGE varb +@c ENDOFRANGE bvaru +@c ENDOFRANGE nmbv + +@node Auto-set +@subsection Built-in Variables That Convey Information + +@c STARTOFRANGE bvconi +@cindex built-in variables, conveying information +@c STARTOFRANGE vbconi +@cindex variables, built-in, conveying information +The following is an alphabetical list of variables that @command{awk} +sets automatically on certain occasions in order to provide +information to your program. The variables that are specific to +@command{gawk} are marked with a pound sign@w{ (@samp{#}).} + +@table @code +@cindex @code{ARGC}/@code{ARGV} variables +@cindex arguments, command-line +@cindex command line, arguments +@item ARGC@r{,} ARGV +The command-line arguments available to @command{awk} programs are stored in +an array called @code{ARGV}. @code{ARGC} is the number of command-line +arguments present. @xref{Other Arguments}. +Unlike most @command{awk} arrays, +@code{ARGV} is indexed from 0 to @code{ARGC} @minus{} 1. +In the following example: + +@example +$ @kbd{awk 'BEGIN @{} +> @kbd{for (i = 0; i < ARGC; i++)} +> @kbd{print ARGV[i]} +> @kbd{@}' inventory-shipped BBS-list} +@print{} awk +@print{} inventory-shipped +@print{} BBS-list +@end example + +@noindent +@code{ARGV[0]} contains @samp{awk}, @code{ARGV[1]} +contains @samp{inventory-shipped}, and @code{ARGV[2]} contains +@samp{BBS-list}. The value of @code{ARGC} is three, one more than the +index of the last element in @code{ARGV}, because the elements are numbered +from zero. + +@cindex programming conventions, @code{ARGC}/@code{ARGV} variables +The names @code{ARGC} and @code{ARGV}, as well as the convention of indexing +the array from 0 to @code{ARGC} @minus{} 1, are derived from the C language's +method of accessing command-line arguments. + +@cindex dark corner, value of @code{ARGV[0]} +The value of @code{ARGV[0]} can vary from system to system. +Also, you should note that the program text is @emph{not} included in +@code{ARGV}, nor are any of @command{awk}'s command-line options. +@xref{ARGC and ARGV}, for information +about how @command{awk} uses these variables. +@value{DARKCORNER} + +@cindex @code{ARGIND} variable +@cindex differences in @command{awk} and @command{gawk}, @code{ARGIND} variable +@item ARGIND # +The index in @code{ARGV} of the current file being processed. +Every time @command{gawk} opens a new @value{DF} for processing, it sets +@code{ARGIND} to the index in @code{ARGV} of the @value{FN}. +When @command{gawk} is processing the input files, +@samp{FILENAME == ARGV[ARGIND]} is always true. + +@cindex files, processing@comma{} @code{ARGIND} variable and +This variable is useful in file processing; it allows you to tell how far +along you are in the list of @value{DF}s as well as to distinguish between +successive instances of the same @value{FN} on the command line. + +@cindex @value{FN}s, distinguishing +While you can change the value of @code{ARGIND} within your @command{awk} +program, @command{gawk} automatically sets it to a new value when the +next file is opened. + +This variable is a @command{gawk} extension. +In other @command{awk} implementations, +or if @command{gawk} is in compatibility mode +(@pxref{Options}), +it is not special. + +@cindex @code{ENVIRON} array +@cindex environment variables +@item ENVIRON +An associative array containing the values of the environment. The array +indices are the environment variable names; the elements are the values of +the particular environment variables. For example, +@code{ENVIRON["HOME"]} might be @file{/home/arnold}. Changing this array +does not affect the environment passed on to any programs that +@command{awk} may spawn via redirection or the @code{system()} function. +@c (In a future version of @command{gawk}, it may do so.) + +Some operating systems may not have environment variables. +On such systems, the @code{ENVIRON} array is empty (except for +@w{@code{ENVIRON["AWKPATH"]}}, +@pxref{AWKPATH Variable}). + +@cindex @command{gawk}, @code{ERRNO} variable in +@cindex @code{ERRNO} variable +@cindex differences in @command{awk} and @command{gawk}, @code{ERRNO} variable +@cindex error handling, @code{ERRNO} variable and +@item ERRNO # +If a system error occurs during a redirection for @code{getline}, +during a read for @code{getline}, or during a @code{close()} operation, +then @code{ERRNO} contains a string describing the error. + +In addition, @command{gawk} clears @code{ERRNO} +before opening each command-line input file. This enables checking if +the file is readable inside a @code{BEGINFILE} pattern (@pxref{BEGINFILE/ENDFILE}). + +Otherwise, +@code{ERRNO} works similarly to the C variable @code{errno}. +Except for the case just mentioned, +@command{gawk} @emph{never} clears it (sets it +to zero or @code{""}). Thus, you should only expect its value +to be meaningful when an I/O operation returns a failure +value, such as @code{getline} returning @minus{}1. +You are, of course, free to clear it yourself before doing an +I/O operation. + +This variable is a @command{gawk} extension. +In other @command{awk} implementations, +or if @command{gawk} is in compatibility mode +(@pxref{Options}), +it is not special. + +@cindex @code{FILENAME} variable +@cindex dark corner, @code{FILENAME} variable +@item FILENAME +The name of the file that @command{awk} is currently reading. +When no @value{DF}s are listed on the command line, @command{awk} reads +from the standard input and @code{FILENAME} is set to @code{"-"}. +@code{FILENAME} is changed each time a new file is read +(@pxref{Reading Files}). +Inside a @code{BEGIN} rule, the value of @code{FILENAME} is +@code{""}, since there are no input files being processed +yet.@footnote{Some early implementations of Unix @command{awk} initialized +@code{FILENAME} to @code{"-"}, even if there were @value{DF}s to be +processed. This behavior was incorrect and should not be relied +upon in your programs.} +@value{DARKCORNER} +Note, though, that using @code{getline} +(@pxref{Getline}) +inside a @code{BEGIN} rule can give +@code{FILENAME} a value. + +@cindex @code{FNR} variable +@item FNR +The current record number in the current file. @code{FNR} is +incremented each time a new record is read +(@pxref{Records}). It is reinitialized +to zero each time a new input file is started. + +@cindex @code{NF} variable +@item NF +The number of fields in the current input record. +@code{NF} is set each time a new record is read, when a new field is +created or when @code{$0} changes (@pxref{Fields}). + +Unlike most of the variables described in this +@ifnotinfo +section, +@end ifnotinfo +@ifinfo +node, +@end ifinfo +assigning a value to @code{NF} has the potential to affect +@command{awk}'s internal workings. In particular, assignments +to @code{NF} can be used to create or remove fields from the +current record. @xref{Changing Fields}. + +@cindex @code{NR} variable +@item NR +The number of input records @command{awk} has processed since +the beginning of the program's execution +(@pxref{Records}). +@code{NR} is incremented each time a new record is read. + +@cindex @command{gawk}, @code{PROCINFO} array in +@cindex @code{PROCINFO} array +@cindex differences in @command{awk} and @command{gawk}, @code{PROCINFO} array +@item PROCINFO # +The elements of this array provide access to information about the +running @command{awk} program. +The following elements (listed alphabetically) +are guaranteed to be available: + +@table @code +@item PROCINFO["egid"] +The value of the @code{getegid()} system call. + +@item PROCINFO["euid"] +The value of the @code{geteuid()} system call. + +@item PROCINFO["FS"] +This is +@code{"FS"} if field splitting with @code{FS} is in effect, +@code{"FIELDWIDTHS"} if field splitting with @code{FIELDWIDTHS} is in effect, +or @code{"FPAT"} if field matching with @code{FPAT} is in effect. + +@item PROCINFO["gid"] +The value of the @code{getgid()} system call. + +@item PROCINFO["pgrpid"] +The process group ID of the current process. + +@item PROCINFO["pid"] +The process ID of the current process. + +@item PROCINFO["ppid"] +The parent process ID of the current process. + +@item PROCINFO["sorted_in"] +If this element exists in @code{PROCINFO}, its value controls the +order in which array indices will be processed by +@samp{for (index in array) @dots{}} loops. +Since this is an advanced feature, we defer the +full description until later; see +@ref{Scanning an Array}. + +@item PROCINFO["strftime"] +The default time format string for @code{strftime()}. +Assigning a new value to this element changes the default. +@xref{Time Functions}. + +@item PROCINFO["uid"] +The value of the @code{getuid()} system call. + +@item PROCINFO["version"] +The version of @command{gawk}. +@end table + +On some systems, there may be elements in the array, @code{"group1"} +through @code{"group@var{N}"} for some @var{N}. @var{N} is the number of +supplementary groups that the process has. Use the @code{in} operator +to test for these elements +(@pxref{Reference to Elements}). + +@cindex @command{gawk}, @code{PROCINFO} array in +@cindex @code{PROCINFO} array +The @code{PROCINFO} array is also used to cause coprocesses +to communicate over pseudo-ttys instead of through two-way pipes; +this is discussed further in @ref{Two-way I/O}. + +This array is a @command{gawk} extension. +In other @command{awk} implementations, +or if @command{gawk} is in compatibility mode +(@pxref{Options}), +it is not special. + +@cindex @code{RLENGTH} variable +@item RLENGTH +The length of the substring matched by the +@code{match()} function +(@pxref{String Functions}). +@code{RLENGTH} is set by invoking the @code{match()} function. Its value +is the length of the matched string, or @minus{}1 if no match is found. + +@cindex @code{RSTART} variable +@item RSTART +The start-index in characters of the substring that is matched by the +@code{match()} function +(@pxref{String Functions}). +@code{RSTART} is set by invoking the @code{match()} function. Its value +is the position of the string where the matched substring starts, or zero +if no match was found. + +@cindex @command{gawk}, @code{RT} variable in +@cindex @code{RT} variable +@cindex differences in @command{awk} and @command{gawk}, @code{RT} variable +@item RT # +This is set each time a record is read. It contains the input text +that matched the text denoted by @code{RS}, the record separator. + +This variable is a @command{gawk} extension. +In other @command{awk} implementations, +or if @command{gawk} is in compatibility mode +(@pxref{Options}), +it is not special. +@end table +@c ENDOFRANGE bvconi +@c ENDOFRANGE vbconi + +@c fakenode --- for prepinfo +@subheading Advanced Notes: Changing @code{NR} and @code{FNR} +@cindex @code{NR} variable, changing +@cindex @code{FNR} variable, changing +@cindex advanced features, @code{FNR}/@code{NR} variables +@cindex dark corner, @code{FNR}/@code{NR} variables +@command{awk} increments @code{NR} and @code{FNR} +each time it reads a record, instead of setting them to the absolute +value of the number of records read. This means that a program can +change these variables and their new values are incremented for +each record. +@value{DARKCORNER} +The following example shows this: + +@example +$ @kbd{echo '1} +> @kbd{2} +> @kbd{3} +> @kbd{4' | awk 'NR == 2 @{ NR = 17 @}} +> @kbd{@{ print NR @}'} +@print{} 1 +@print{} 17 +@print{} 18 +@print{} 19 +@end example + +@noindent +Before @code{FNR} was added to the @command{awk} language +(@pxref{V7/SVR3.1}), +many @command{awk} programs used this feature to track the number of +records in a file by resetting @code{NR} to zero when @code{FILENAME} +changed. + +@node ARGC and ARGV +@subsection Using @code{ARGC} and @code{ARGV} +@cindex @code{ARGC}/@code{ARGV} variables +@cindex arguments, command-line +@cindex command line, arguments + +@ref{Auto-set}, +presented the following program describing the information contained in @code{ARGC} +and @code{ARGV}: + +@example +$ @kbd{awk 'BEGIN @{} +> @kbd{for (i = 0; i < ARGC; i++)} +> @kbd{print ARGV[i]} +> @kbd{@}' inventory-shipped BBS-list} +@print{} awk +@print{} inventory-shipped +@print{} BBS-list +@end example + +@noindent +In this example, @code{ARGV[0]} contains @samp{awk}, @code{ARGV[1]} +contains @samp{inventory-shipped}, and @code{ARGV[2]} contains +@samp{BBS-list}. +Notice that the @command{awk} program is not entered in @code{ARGV}. The +other command-line options, with their arguments, are also not +entered. This includes variable assignments done with the @option{-v} +option (@pxref{Options}). +Normal variable assignments on the command line @emph{are} +treated as arguments and do show up in the @code{ARGV} array. +Given the following program in a file named @file{showargs.awk}: + +@example +BEGIN @{ + printf "A=%d, B=%d\n", A, B + for (i = 0; i < ARGC; i++) + printf "\tARGV[%d] = %s\n", i, ARGV[i] +@} +END @{ printf "A=%d, B=%d\n", A, B @} +@end example + +@noindent +Running it produces the following: + +@example +$ @kbd{awk -v A=1 -f showargs.awk B=2 /dev/null} +@print{} A=1, B=0 +@print{} ARGV[0] = awk +@print{} ARGV[1] = B=2 +@print{} ARGV[2] = /dev/null +@print{} A=1, B=2 +@end example + +A program can alter @code{ARGC} and the elements of @code{ARGV}. +Each time @command{awk} reaches the end of an input file, it uses the next +element of @code{ARGV} as the name of the next input file. By storing a +different string there, a program can change which files are read. +Use @code{"-"} to represent the standard input. Storing +additional elements and incrementing @code{ARGC} causes +additional files to be read. + +If the value of @code{ARGC} is decreased, that eliminates input files +from the end of the list. By recording the old value of @code{ARGC} +elsewhere, a program can treat the eliminated arguments as +something other than @value{FN}s. + +To eliminate a file from the middle of the list, store the null string +(@code{""}) into @code{ARGV} in place of the file's name. As a +special feature, @command{awk} ignores @value{FN}s that have been +replaced with the null string. +Another option is to +use the @code{delete} statement to remove elements from +@code{ARGV} (@pxref{Delete}). + +All of these actions are typically done in the @code{BEGIN} rule, +before actual processing of the input begins. +@xref{Split Program}, and see +@ref{Tee Program}, for examples +of each way of removing elements from @code{ARGV}. +The following fragment processes @code{ARGV} in order to examine, and +then remove, command-line options: + +@example +BEGIN @{ + for (i = 1; i < ARGC; i++) @{ + if (ARGV[i] == "-v") + verbose = 1 + else if (ARGV[i] == "-q") + debug = 1 + else if (ARGV[i] ~ /^-./) @{ + e = sprintf("%s: unrecognized option -- %c", + ARGV[0], substr(ARGV[i], 2, 1)) + print e > "/dev/stderr" + @} else + break + delete ARGV[i] + @} +@} +@end example + +To actually get the options into the @command{awk} program, +end the @command{awk} options with @option{--} and then supply +the @command{awk} program's options, in the following manner: + +@example +awk -f myprog -- -v -q file1 file2 @dots{} +@end example + +@cindex differences in @command{awk} and @command{gawk}, @code{ARGC}/@code{ARGV} variables +This is not necessary in @command{gawk}. Unless @option{--posix} has +been specified, @command{gawk} silently puts any unrecognized options +into @code{ARGV} for the @command{awk} program to deal with. As soon +as it sees an unknown option, @command{gawk} stops looking for other +options that it might otherwise recognize. The previous example with +@command{gawk} would be: + +@example +gawk -f myprog -q -v file1 file2 @dots{} +@end example + +@noindent +Because @option{-q} is not a valid @command{gawk} option, +it and the following @option{-v} +are passed on to the @command{awk} program. +(@xref{Getopt Function}, for an @command{awk} library function +that parses command-line options.) + +@node Arrays +@chapter Arrays in @command{awk} +@c STARTOFRANGE arrs +@cindex arrays + +An @dfn{array} is a table of values called @dfn{elements}. The +elements of an array are distinguished by their @dfn{indices}. Indices +may be either numbers or strings. + +This @value{CHAPTER} describes how arrays work in @command{awk}, +how to use array elements, how to scan through every element in an array, +and how to remove array elements. +It also describes how @command{awk} simulates multidimensional +arrays, as well as some of the less obvious points about array usage. +The @value{CHAPTER} moves on to discuss @command{gawk}'s facility +for sorting arrays, and ends with a brief description of @command{gawk}'s +ability to support true multidimensional arrays. + +@cindex variables, names of +@cindex functions, names of +@cindex arrays, names of +@cindex names, arrays/variables +@cindex namespace issues +@command{awk} maintains a single set +of names that may be used for naming variables, arrays, and functions +(@pxref{User-defined}). +Thus, you cannot have a variable and an array with the same name in the +same @command{awk} program. + +@menu +* Array Basics:: The basics of arrays. +* Delete:: The @code{delete} statement removes an element + from an array. +* Numeric Array Subscripts:: How to use numbers as subscripts in + @command{awk}. +* Uninitialized Subscripts:: Using Uninitialized variables as subscripts. +* Multi-dimensional:: Emulating multidimensional arrays in + @command{awk}. +* Arrays of Arrays:: True multidimensional arrays. +@end menu + +@node Array Basics +@section The Basics of Arrays + +This @value{SECTION} presents the basics: working with elements +in arrays one at a time, and traversing all of the elements in +an array. + +@menu +* Array Intro:: Introduction to Arrays +* Reference to Elements:: How to examine one element of an array. +* Assigning Elements:: How to change an element of an array. +* Array Example:: Basic Example of an Array +* Scanning an Array:: A variation of the @code{for} statement. It + loops through the indices of an array's + existing elements. +* Controlling Scanning:: Controlling the order in which arrays are + scanned. +@end menu + +@node Array Intro +@subsection Introduction to Arrays + +@cindex Wall, Larry +@quotation +@i{Doing linear scans over an associative array is like trying to club someone +to death with a loaded Uzi.}@* +Larry Wall +@end quotation + +The @command{awk} language provides one-dimensional arrays +for storing groups of related strings or numbers. +Every @command{awk} array must have a name. Array names have the same +syntax as variable names; any valid variable name would also be a valid +array name. But one name cannot be used in both ways (as an array and +as a variable) in the same @command{awk} program. + +Arrays in @command{awk} superficially resemble arrays in other programming +languages, but there are fundamental differences. In @command{awk}, it +isn't necessary to specify the size of an array before starting to use it. +Additionally, any number or string in @command{awk}, not just consecutive integers, +may be used as an array index. + +In most other languages, arrays must be @dfn{declared} before use, +including a specification of +how many elements or components they contain. In such languages, the +declaration causes a contiguous block of memory to be allocated for that +many elements. Usually, an index in the array must be a positive integer. +For example, the index zero specifies the first element in the array, which is +actually stored at the beginning of the block of memory. Index one +specifies the second element, which is stored in memory right after the +first element, and so on. It is impossible to add more elements to the +array, because it has room only for as many elements as given in +the declaration. +(Some languages allow arbitrary starting and ending +indices---e.g., @samp{15 .. 27}---but the size of the array is still fixed when +the array is declared.) + +A contiguous array of four elements might look like the following example, +conceptually, if the element values are 8, @code{"foo"}, +@code{""}, and 30: + +@c @strong{FIXME: NEXT ED:} Use real images here +@iftex +@c from Karl Berry, much thanks for the help. +@tex +\bigskip % space above the table (about 1 linespace) +\offinterlineskip +\newdimen\width \width = 1.5cm +\newdimen\hwidth \hwidth = 4\width \advance\hwidth by 2pt % 5 * 0.4pt +\centerline{\vbox{ +\halign{\strut\hfil\ignorespaces#&&\vrule#&\hbox to\width{\hfil#\unskip\hfil}\cr +\noalign{\hrule width\hwidth} + &&{\tt 8} &&{\tt "foo"} &&{\tt ""} &&{\tt 30} &&\quad Value\cr +\noalign{\hrule width\hwidth} +\noalign{\smallskip} + &\omit&0&\omit &1 &\omit&2 &\omit&3 &\omit&\quad Index\cr +} +}} +@end tex +@end iftex +@ifnottex +@example ++---------+---------+--------+---------+ +| 8 | "foo" | "" | 30 | @r{Value} ++---------+---------+--------+---------+ + 0 1 2 3 @r{Index} +@end example +@end ifnottex + +@noindent +Only the values are stored; the indices are implicit from the order of +the values. Here, 8 is the value at index zero, because 8 appears in the +position with zero elements before it. + +@c STARTOFRANGE arrin +@cindex arrays, indexing +@c STARTOFRANGE inarr +@cindex indexing arrays +@cindex associative arrays +@cindex arrays, associative +Arrays in @command{awk} are different---they are @dfn{associative}. This means +that each array is a collection of pairs: an index and its corresponding +array element value: + +@example +@r{Index} 3 @r{Value} 30 +@r{Index} 1 @r{Value} "foo" +@r{Index} 0 @r{Value} 8 +@r{Index} 2 @r{Value} "" +@end example + +@noindent +The pairs are shown in jumbled order because their order is irrelevant. + +One advantage of associative arrays is that new pairs can be added +at any time. For example, suppose a tenth element is added to the array +whose value is @w{@code{"number ten"}}. The result is: + +@example +@r{Index} 10 @r{Value} "number ten" +@r{Index} 3 @r{Value} 30 +@r{Index} 1 @r{Value} "foo" +@r{Index} 0 @r{Value} 8 +@r{Index} 2 @r{Value} "" +@end example + +@noindent +@cindex sparse arrays +@cindex arrays, sparse +Now the array is @dfn{sparse}, which just means some indices are missing. +It has elements 0--3 and 10, but doesn't have elements 4, 5, 6, 7, 8, or 9. + +Another consequence of associative arrays is that the indices don't +have to be positive integers. Any number, or even a string, can be +an index. For example, the following is an array that translates words from +English to French: + +@example +@r{Index} "dog" @r{Value} "chien" +@r{Index} "cat" @r{Value} "chat" +@r{Index} "one" @r{Value} "un" +@r{Index} 1 @r{Value} "un" +@end example + +@noindent +Here we decided to translate the number one in both spelled-out and +numeric form---thus illustrating that a single array can have both +numbers and strings as indices. +In fact, array subscripts are always strings; this is discussed +in more detail in +@ref{Numeric Array Subscripts}. +Here, the number @code{1} isn't double-quoted, since @command{awk} +automatically converts it to a string. + +@cindex @command{gawk}, @code{IGNORECASE} variable in +@cindex @code{IGNORECASE} variable +@cindex case sensitivity, array indices and +@cindex arrays, @code{IGNORECASE} variable and +@cindex @code{IGNORECASE} variable, array subscripts and +The value of @code{IGNORECASE} has no effect upon array subscripting. +The identical string value used to store an array element must be used +to retrieve it. +When @command{awk} creates an array (e.g., with the @code{split()} +built-in function), +that array's indices are consecutive integers starting at one. +(@xref{String Functions}.) + +@command{awk}'s arrays are efficient---the time to access an element +is independent of the number of elements in the array. +@c ENDOFRANGE arrin +@c ENDOFRANGE inarr + +@node Reference to Elements +@subsection Referring to an Array Element +@cindex arrays, elements, referencing +@cindex elements in arrays + +The principal way to use an array is to refer to one of its elements. +An array reference is an expression as follows: + +@example +@var{array}[@var{index-expression}] +@end example + +@noindent +Here, @var{array} is the name of an array. The expression @var{index-expression} is +the index of the desired element of the array. + +The value of the array reference is the current value of that array +element. For example, @code{foo[4.3]} is an expression for the element +of array @code{foo} at index @samp{4.3}. + +A reference to an array element that has no recorded value yields a value of +@code{""}, the null string. This includes elements +that have not been assigned any value as well as elements that have been +deleted (@pxref{Delete}). + +@quotation NOTE +A reference to an element that does not exist @emph{automatically} creates +that array element, with the null string as its value. (In some cases, +this is unfortunate, because it might waste memory inside @command{awk}.) + +Novice @command{awk} programmers often make the mistake of checking if +an element exists by checking if the value is empty: + +@example +# Check if "foo" exists in a: @ii{Incorrect!} +if (a["foo"] != "") @dots{} +@end example + +@noindent +This is incorrect, since this will @emph{create} @code{a["foo"]} +if it didn't exist before! +@end quotation + +@c @cindex arrays, @code{in} operator and +@cindex @code{in} operator, arrays and +To determine whether an element exists in an array at a certain index, use +the following expression: + +@example +@var{ind} in @var{array} +@end example + +@cindex side effects, array indexing +@noindent +This expression tests whether the particular index @var{ind} exists, +without the side effect of creating that element if it is not present. +The expression has the value one (true) if @code{@var{array}[@var{ind}]} +exists and zero (false) if it does not exist. +For example, this statement tests whether the array @code{frequencies} +contains the index @samp{2}: + +@example +if (2 in frequencies) + print "Subscript 2 is present." +@end example + +Note that this is @emph{not} a test of whether the array +@code{frequencies} contains an element whose @emph{value} is two. +There is no way to do that except to scan all the elements. Also, this +@emph{does not} create @code{frequencies[2]}, while the following +(incorrect) alternative does: + +@example +if (frequencies[2] != "") + print "Subscript 2 is present." +@end example + +@node Assigning Elements +@subsection Assigning Array Elements +@cindex arrays, elements, assigning +@cindex elements in arrays, assigning + +Array elements can be assigned values just like +@command{awk} variables: + +@example +@var{array}[@var{index-expression}] = @var{value} +@end example + +@noindent +@var{array} is the name of an array. The expression +@var{index-expression} is the index of the element of the array that is +assigned a value. The expression @var{value} is the value to +assign to that element of the array. + +@node Array Example +@subsection Basic Array Example + +The following program takes a list of lines, each beginning with a line +number, and prints them out in order of line number. The line numbers +are not in order when they are first read---instead they +are scrambled. This program sorts the lines by making an array using +the line numbers as subscripts. The program then prints out the lines +in sorted order of their numbers. It is a very simple program and gets +confused upon encountering repeated numbers, gaps, or lines that don't +begin with a number: + +@example +@c file eg/misc/arraymax.awk +@{ + if ($1 > max) + max = $1 + arr[$1] = $0 +@} + +END @{ + for (x = 1; x <= max; x++) + print arr[x] +@} +@c endfile +@end example + +The first rule keeps track of the largest line number seen so far; +it also stores each line into the array @code{arr}, at an index that +is the line's number. +The second rule runs after all the input has been read, to print out +all the lines. +When this program is run with the following input: + +@example +@c file eg/misc/arraymax.data +5 I am the Five man +2 Who are you? The new number two! +4 . . . And four on the floor +1 Who is number one? +3 I three you. +@c endfile +@end example + +@noindent +Its output is: + +@example +1 Who is number one? +2 Who are you? The new number two! +3 I three you. +4 . . . And four on the floor +5 I am the Five man +@end example + +If a line number is repeated, the last line with a given number overrides +the others. +Gaps in the line numbers can be handled with an easy improvement to the +program's @code{END} rule, as follows: + +@example +END @{ + for (x = 1; x <= max; x++) + if (x in arr) + print arr[x] +@} +@end example + +@node Scanning an Array +@subsection Scanning All Elements of an Array +@cindex elements in arrays, scanning +@cindex arrays, scanning + +In programs that use arrays, it is often necessary to use a loop that +executes once for each element of an array. In other languages, where +arrays are contiguous and indices are limited to positive integers, +this is easy: all the valid indices can be found by counting from +the lowest index up to the highest. This technique won't do the job +in @command{awk}, because any number or string can be an array index. +So @command{awk} has a special kind of @code{for} statement for scanning +an array: + +@example +for (@var{var} in @var{array}) + @var{body} +@end example + +@noindent +@cindex @code{in} operator, arrays and +This loop executes @var{body} once for each index in @var{array} that the +program has previously used, with the variable @var{var} set to that index. + +@cindex arrays, @code{for} statement and +@cindex @code{for} statement, in arrays +The following program uses this form of the @code{for} statement. The +first rule scans the input records and notes which words appear (at +least once) in the input, by storing a one into the array @code{used} with +the word as index. The second rule scans the elements of @code{used} to +find all the distinct words that appear in the input. It prints each +word that is more than 10 characters long and also prints the number of +such words. +@xref{String Functions}, +for more information on the built-in function @code{length()}. + +@example +# Record a 1 for each word that is used at least once +@{ + for (i = 1; i <= NF; i++) + used[$i] = 1 +@} + +# Find number of distinct words more than 10 characters long +END @{ + for (x in used) @{ + if (length(x) > 10) @{ + ++num_long_words + print x + @} + @} + print num_long_words, "words longer than 10 characters" +@} +@end example + +@noindent +@xref{Word Sorting}, +for a more detailed example of this type. + +@cindex arrays, elements, order of +@cindex elements in arrays, order of +The order in which elements of the array are accessed by this statement +is determined by the internal arrangement of the array elements within +@command{awk} and normally cannot be controlled or changed. This can lead to +problems if new elements are added to @var{array} by statements in +the loop body; it is not predictable whether the @code{for} loop will +reach them. Similarly, changing @var{var} inside the loop may produce +strange results. It is best to avoid such things. + +@node Controlling Scanning +@subsection Using Predefined Array Scanning Orders + +By default, when a @code{for} loop traverses an array, the order +is undefined, meaning that the @command{awk} implementation +determines the order in which the array is traversed. +This order is usually based on the internal implementation of arrays +and will vary from one version of @command{awk} to the next. + +Often, though, you may wish to do something simple, such as +``traverse the array by comparing the indices in ascending order,'' +or ``traverse the array by on comparing the values in descending order.'' +@command{gawk} provides two mechanisms which give you this control. + +@itemize @bullet +@item +Set @code{PROCINFO["sorted_in"]} to one of a set of predefined values. +We describe this now. + +@item +Set @code{PROCINFO["sorted_in"]} to the name of a user-defined function +to be used for comparison of array elements. This advanced feature +is described later, in @ref{Array Sorting}. +@end itemize + +The following special values for @code{PROCINFO["sorted_in"]} are available: + +@table @code +@item "@@unsorted" +Array elements are processed in arbitrary order, which is the default +@command{awk} behavior. + +@item "@@ind_str_asc" +Order by indices compared as strings; this is the most basic sort. +(Internally, array indices are always strings, so with @samp{a[2*5] = 1} +the index is @code{"10"} rather than numeric 10.) + +@item "@@ind_num_asc" +Order by indices but force them to be treated as numbers in the process. +Any index with a non-numeric value will end up positioned as if it were zero. + +@item "@@val_type_asc" +Order by element values rather than indices. +Ordering is by the type assigned to the element +(@pxref{Typing and Comparison}). +All numeric values come before all string values, +which in turn come before all subarrays. +(Subarrays have not been described yet; +@pxref{Arrays of Arrays}). + +@item "@@val_str_asc" +Order by element values rather than by indices. Scalar values are +compared as strings. Subarrays, if present, come out last. + +@item "@@val_num_asc" +Order by element values rather than by indices. Scalar values are +compared as numbers. Subarrays, if present, come out last. +When numeric values are equal, the string values are used to provide +an ordering: this guarantees consistent results across different +versions of the C @code{qsort()} function,@footnote{When two elements +compare as equal, the C @code{qsort()} function does not guarantee +that they will maintain their original relative order after sorting. +Using the string value to provide a unique ordering when the numeric +values are equal ensures that @command{gawk} behaves consistently +across different environments.} which @command{gawk} uses internally +to perform the sorting. + +@item "@@ind_str_desc" +Reverse order from the most basic sort. + +@item "@@ind_num_desc" +Numeric indices ordered from high to low. + +@item "@@val_type_desc" +Element values, based on type, in descending order. + +@item "@@val_str_desc" +Element values, treated as strings, ordered from high to low. +Subarrays, if present, come out first. + +@item "@@val_num_desc" +Element values, treated as numbers, ordered from high to low. +Subarrays, if present, come out first. +@end table + +The array traversal order is determined before the @code{for} loop +starts to run. Changing @code{PROCINFO["sorted_in"]} in the loop body +will not affect the loop. + +For example: + +@example +$ @kbd{gawk 'BEGIN @{} +> @kbd{ a[4] = 4} +> @kbd{ a[3] = 3} +> @kbd{ for (i in a)} +> @kbd{ print i, a[i]} +> @kbd{@}'} +@print{} 4 4 +@print{} 3 3 +$ @kbd{gawk 'BEGIN @{} +> @kbd{ PROCINFO["sorted_in"] = "@@ind_str_asc"} +> @kbd{ a[4] = 4} +> @kbd{ a[3] = 3} +> @kbd{ for (i in a)} +> @kbd{ print i, a[i]} +> @kbd{@}'} +@print{} 3 3 +@print{} 4 4 +@end example + +When sorting an array by element values, if a value happens to be +a subarray then it is considered to be greater than any string or +numeric value, regardless of what the subarray itself contains, +and all subarrays are treated as being equal to each other. Their +order relative to each other is determined by their index strings. + +Here are some additional things to bear in mind about sorted +array traversal. + +@itemize @bullet +@item +The value of @code{PROCINFO["sorted_in"]} is global. That is, it affects +all array traversal @code{for} loops. If you need to change it within your +own code, you should see if it's defined and save and restore the value: + +@example +@dots{} +if ("sorted_in" in PROCINFO) @{ + save_sorted = PROCINFO["sorted_in"] + PROCINFO["sorted_in"] = "@@val_str_desc" # or whatever +@} +@dots{} +if (save_sorted) + PROCINFO["sorted_in"] = save_sorted +@end example + +@item +As mentioned, the default array traversal order is represented by +@code{"@@unsorted"}. You can also get the default behavior by assigning +the null string to @code{PROCINFO["sorted_in"]} or by just deleting the +@code{"sorted_in"} element from the @code{PROCINFO} array with +the @code{delete} statement. +(The @code{delete} statement hasn't been described yet; @pxref{Delete}.) +@end itemize + +In addition, @command{gawk} provides built-in functions for +sorting arrays; see @ref{Array Sorting Functions}. + +@node Delete +@section The @code{delete} Statement +@cindex @code{delete} statement +@cindex deleting elements in arrays +@cindex arrays, elements, deleting +@cindex elements in arrays, deleting + +To remove an individual element of an array, use the @code{delete} +statement: + +@example +delete @var{array}[@var{index-expression}] +@end example + +Once an array element has been deleted, any value the element once +had is no longer available. It is as if the element had never +been referred to or been given a value. +The following is an example of deleting elements in an array: + +@example +for (i in frequencies) + delete frequencies[i] +@end example + +@noindent +This example removes all the elements from the array @code{frequencies}. +Once an element is deleted, a subsequent @code{for} statement to scan the array +does not report that element and the @code{in} operator to check for +the presence of that element returns zero (i.e., false): + +@example +delete foo[4] +if (4 in foo) + print "This will never be printed" +@end example + +@cindex null strings, array elements and +It is important to note that deleting an element is @emph{not} the +same as assigning it a null value (the empty string, @code{""}). +For example: + +@example +foo[4] = "" +if (4 in foo) + print "This is printed, even though foo[4] is empty" +@end example + +@cindex lint checking, array elements +It is not an error to delete an element that does not exist. +However, if @option{--lint} is provided on the command line +(@pxref{Options}), +@command{gawk} issues a warning message when an element that +is not in the array is deleted. + +@cindex common extensions, @code{delete} to delete entire arrays +@cindex extensions, common@comma{} @code{delete} to delete entire arrays +@cindex arrays, deleting entire contents +@cindex deleting entire arrays +@cindex differences in @command{awk} and @command{gawk}, array elements, deleting +All the elements of an array may be deleted with a single statement +@value{COMMONEXT} +by leaving off the subscript in the @code{delete} statement, +as follows: + +@example +delete @var{array} +@end example + +This ability is a @command{gawk} extension; it is not available in +compatibility mode (@pxref{Options}). + +Using this version of the @code{delete} statement is about three times +more efficient than the equivalent loop that deletes each element one +at a time. + +@cindex portability, deleting array elements +@cindex Brennan, Michael +The following statement provides a portable but nonobvious way to clear +out an array:@footnote{Thanks to Michael Brennan for pointing this out.} + +@example +split("", array) +@end example + +@cindex @code{split()} function, array elements@comma{} deleting +The @code{split()} function +(@pxref{String Functions}) +clears out the target array first. This call asks it to split +apart the null string. Because there is no data to split out, the +function simply clears the array and then returns. + +@quotation CAUTION +Deleting an array does not change its type; you cannot +delete an array and then use the array's name as a scalar +(i.e., a regular variable). For example, the following does not work: + +@example +a[1] = 3 +delete a +a = 3 +@end example +@end quotation + +@node Numeric Array Subscripts +@section Using Numbers to Subscript Arrays + +@cindex numbers, as array subscripts +@cindex arrays, subscripts +@cindex subscripts in arrays, numbers as +@cindex @code{CONVFMT} variable, array subscripts and +An important aspect to remember about arrays is that @emph{array subscripts +are always strings}. When a numeric value is used as a subscript, +it is converted to a string value before being used for subscripting +(@pxref{Conversion}). +This means that the value of the built-in variable @code{CONVFMT} can +affect how your program accesses elements of an array. For example: + +@example +xyz = 12.153 +data[xyz] = 1 +CONVFMT = "%2.2f" +if (xyz in data) + printf "%s is in data\n", xyz +else + printf "%s is not in data\n", xyz +@end example + +@noindent +This prints @samp{12.15 is not in data}. The first statement gives +@code{xyz} a numeric value. Assigning to +@code{data[xyz]} subscripts @code{data} with the string value @code{"12.153"} +(using the default conversion value of @code{CONVFMT}, @code{"%.6g"}). +Thus, the array element @code{data["12.153"]} is assigned the value one. +The program then changes +the value of @code{CONVFMT}. The test @samp{(xyz in data)} generates a new +string value from @code{xyz}---this time @code{"12.15"}---because the value of +@code{CONVFMT} only allows two significant digits. This test fails, +since @code{"12.15"} is different from @code{"12.153"}. + +@cindex converting, during subscripting +According to the rules for conversions +(@pxref{Conversion}), integer +values are always converted to strings as integers, no matter what the +value of @code{CONVFMT} may happen to be. So the usual case of +the following works: + +@example +for (i = 1; i <= maxsub; i++) + @ii{do something with} array[i] +@end example + +The ``integer values always convert to strings as integers'' rule +has an additional consequence for array indexing. +Octal and hexadecimal constants +(@pxref{Nondecimal-numbers}) +are converted internally into numbers, and their original form +is forgotten. +This means, for example, that +@code{array[17]}, +@code{array[021]}, +and +@code{array[0x11]} +all refer to the same element! + +As with many things in @command{awk}, the majority of the time +things work as one would expect them to. But it is useful to have a precise +knowledge of the actual rules since they can sometimes have a subtle +effect on your programs. + +@node Uninitialized Subscripts +@section Using Uninitialized Variables as Subscripts + +@cindex variables, uninitialized@comma{} as array subscripts +@cindex uninitialized variables, as array subscripts +@cindex subscripts in arrays, uninitialized variables as +@cindex arrays, subscripts, uninitialized variables as +Suppose it's necessary to write a program +to print the input data in reverse order. +A reasonable attempt to do so (with some test +data) might look like this: + +@example +$ @kbd{echo 'line 1} +> @kbd{line 2} +> @kbd{line 3' | awk '@{ l[lines] = $0; ++lines @}} +> @kbd{END @{} +> @kbd{for (i = lines-1; i >= 0; --i)} +> @kbd{print l[i]} +> @kbd{@}'} +@print{} line 3 +@print{} line 2 +@end example + +Unfortunately, the very first line of input data did not come out in the +output! + +Upon first glance, we would think that this program should have worked. +The variable @code{lines} +is uninitialized, and uninitialized variables have the numeric value zero. +So, @command{awk} should have printed the value of @code{l[0]}. + +The issue here is that subscripts for @command{awk} arrays are @emph{always} +strings. Uninitialized variables, when used as strings, have the +value @code{""}, not zero. Thus, @samp{line 1} ends up stored in +@code{l[""]}. +The following version of the program works correctly: + +@example +@{ l[lines++] = $0 @} +END @{ + for (i = lines - 1; i >= 0; --i) + print l[i] +@} +@end example + +Here, the @samp{++} forces @code{lines} to be numeric, thus making +the ``old value'' numeric zero. This is then converted to @code{"0"} +as the array subscript. + +@cindex null strings, as array subscripts +@cindex dark corner, array subscripts +@cindex lint checking, array subscripts +Even though it is somewhat unusual, the null string +(@code{""}) is a valid array subscript. +@value{DARKCORNER} +@command{gawk} warns about the use of the null string as a subscript +if @option{--lint} is provided +on the command line (@pxref{Options}). + +@node Multi-dimensional +@section Multidimensional Arrays + +@menu +* Multi-scanning:: Scanning multidimensional arrays. +@end menu + +@cindex subscripts in arrays, multidimensional +@cindex arrays, multidimensional +A multidimensional array is an array in which an element is identified +by a sequence of indices instead of a single index. For example, a +two-dimensional array requires two indices. The usual way (in most +languages, including @command{awk}) to refer to an element of a +two-dimensional array named @code{grid} is with +@code{grid[@var{x},@var{y}]}. + +@cindex @code{SUBSEP} variable, multidimensional arrays +Multidimensional arrays are supported in @command{awk} through +concatenation of indices into one string. +@command{awk} converts the indices into strings +(@pxref{Conversion}) and +concatenates them together, with a separator between them. This creates +a single string that describes the values of the separate indices. The +combined string is used as a single index into an ordinary, +one-dimensional array. The separator used is the value of the built-in +variable @code{SUBSEP}. + +For example, suppose we evaluate the expression @samp{foo[5,12] = "value"} +when the value of @code{SUBSEP} is @code{"@@"}. The numbers 5 and 12 are +converted to strings and +concatenated with an @samp{@@} between them, yielding @code{"5@@12"}; thus, +the array element @code{foo["5@@12"]} is set to @code{"value"}. + +Once the element's value is stored, @command{awk} has no record of whether +it was stored with a single index or a sequence of indices. The two +expressions @samp{foo[5,12]} and @w{@samp{foo[5 SUBSEP 12]}} are always +equivalent. + +The default value of @code{SUBSEP} is the string @code{"\034"}, +which contains a nonprinting character that is unlikely to appear in an +@command{awk} program or in most input data. +The usefulness of choosing an unlikely character comes from the fact +that index values that contain a string matching @code{SUBSEP} can lead to +combined strings that are ambiguous. Suppose that @code{SUBSEP} is +@code{"@@"}; then @w{@samp{foo["a@@b", "c"]}} and @w{@samp{foo["a", +"b@@c"]}} are indistinguishable because both are actually +stored as @samp{foo["a@@b@@c"]}. + +To test whether a particular index sequence exists in a +multidimensional array, use the same operator (@code{in}) that is +used for single dimensional arrays. Write the whole sequence of indices +in parentheses, separated by commas, as the left operand: + +@example +(@var{subscript1}, @var{subscript2}, @dots{}) in @var{array} +@end example + +The following example treats its input as a two-dimensional array of +fields; it rotates this array 90 degrees clockwise and prints the +result. It assumes that all lines have the same number of +elements: + +@example +@{ + if (max_nf < NF) + max_nf = NF + max_nr = NR + for (x = 1; x <= NF; x++) + vector[x, NR] = $x +@} + +END @{ + for (x = 1; x <= max_nf; x++) @{ + for (y = max_nr; y >= 1; --y) + printf("%s ", vector[x, y]) + printf("\n") + @} +@} +@end example + +@noindent +When given the input: + +@example +1 2 3 4 5 6 +2 3 4 5 6 1 +3 4 5 6 1 2 +4 5 6 1 2 3 +@end example + +@noindent +the program produces the following output: + +@example +4 3 2 1 +5 4 3 2 +6 5 4 3 +1 6 5 4 +2 1 6 5 +3 2 1 6 +@end example + +@node Multi-scanning +@subsection Scanning Multidimensional Arrays + +There is no special @code{for} statement for scanning a +``multidimensional'' array. There cannot be one, because, in truth, +@command{awk} does not have +multidimensional arrays or elements---there is only a +multidimensional @emph{way of accessing} an array. + +@cindex subscripts in arrays, multidimensional, scanning +@cindex arrays, multidimensional, scanning +However, if your program has an array that is always accessed as +multidimensional, you can get the effect of scanning it by combining +the scanning @code{for} statement +(@pxref{Scanning an Array}) with the +built-in @code{split()} function +(@pxref{String Functions}). +It works in the following manner: + +@example +for (combined in array) @{ + split(combined, separate, SUBSEP) + @dots{} +@} +@end example + +@noindent +This sets the variable @code{combined} to +each concatenated combined index in the array, and splits it +into the individual indices by breaking it apart where the value of +@code{SUBSEP} appears. The individual indices then become the elements of +the array @code{separate}. + +Thus, if a value is previously stored in @code{array[1, "foo"]}, then +an element with index @code{"1\034foo"} exists in @code{array}. (Recall +that the default value of @code{SUBSEP} is the character with code 034.) +Sooner or later, the @code{for} statement finds that index and does an +iteration with the variable @code{combined} set to @code{"1\034foo"}. +Then the @code{split()} function is called as follows: + +@example +split("1\034foo", separate, "\034") +@end example + +@noindent +The result is to set @code{separate[1]} to @code{"1"} and +@code{separate[2]} to @code{"foo"}. Presto! The original sequence of +separate indices is recovered. + + +@node Arrays of Arrays +@section Arrays of Arrays + +@command{gawk} goes beyond standard @command{awk}'s multidimensional +array access and provides true arrays of +arrays. Elements of a subarray are referred to by their own indices +enclosed in square brackets, just like the elements of the main array. +For example, the following creates a two-element subarray at index @samp{1} +of the main array @code{a}: + +@example +a[1][1] = 1 +a[1][2] = 2 +@end example + +This simulates a true two-dimensional array. Each subarray element can +contain another subarray as a value, which in turn can hold other arrays +as well. In this way, you can create arrays of three or more dimensions. +The indices can be any @command{awk} expression, including scalars +separated by commas (that is, a regular @command{awk} simulated +multidimensional subscript). So the following is valid in +@command{gawk}: + +@example +a[1][3][1, "name"] = "barney" +@end example + +Each subarray and the main array can be of different length. In fact, the +elements of an array or its subarray do not all have to have the same +type. This means that the main array and any of its subarrays can be +non-rectangular, or jagged in structure. One can assign a scalar value to +the index @samp{4} of the main array @code{a}: + +@example +a[4] = "An element in a jagged array" +@end example + +The terms @dfn{dimension}, @dfn{row} and @dfn{column} are +meaningless when applied +to such an array, but we will use ``dimension'' henceforth to imply the +maximum number of indices needed to refer to an existing element. The +type of any element that has already been assigned cannot be changed +by assigning a value of a different type. You have to first delete the +current element, which effectively makes @command{gawk} forget about +the element at that index: + +@example +delete a[4] +a[4][5][6][7] = "An element in a four-dimensional array" +@end example + +@noindent +This removes the scalar value from index @samp{4} and then inserts a +subarray of subarray of subarray containing a scalar. You can also +delete an entire subarray or subarray of subarrays: + +@example +delete a[4][5] +a[4][5] = "An element in subarray a[4]" +@end example + +But recall that you can not delete the main array @code{a} and then use it +as a scalar. + +The built-in functions which take array arguments can also be used +with subarrays. For example, the following code fragment uses @code{length()} +(@pxref{String Functions}) +to determine the number of elements in the main array @code{a} and +its subarrays: + +@example +print length(a), length(a[1]), length(a[1][3]) +@end example + +@noindent +This results in the following output for our main array @code{a}: + +@example +2, 3, 1 +@end example + +@noindent +The @samp{@var{subscript} in @var{array}} expression +(@pxref{Reference to Elements}) works similarly for both +regular @command{awk}-style +arrays and arrays of arrays. For example, the tests @samp{1 in a}, +@samp{3 in a[1]}, and @samp{(1, "name") in a[1][3]} all evaluate to +one (true) for our array @code{a}. + +The @samp{for (item in array)} statement (@pxref{Scanning an Array}) +can be nested to scan all the +elements of an array of arrays if it is rectangular in structure. In order +to print the contents (scalar values) of a two-dimensional array of arrays +(i.e., in which each first-level element is itself an +array, not necessarily of the same length) +you could use the following code: + +@example +for (i in array) + for (j in array[i]) + print array[i][j] +@end example + +The @code{isarray()} function (@pxref{Type Functions}) +lets you test if an array element is itself an array: + +@example +for (i in array) @{ + if (isarray(array[i]) @{ + for (j in array[i]) @{ + print array[i][j] + @} + @} +@} +@end example + +If the structure of a jagged array of arrays is known in advance, +you can often devise workarounds using control statements. For example, +the following code prints the elements of our main array @code{a}: + +@example +for (i in a) @{ + for (j in a[i]) @{ + if (j == 3) @{ + for (k in a[i][j]) + print a[i][j][k] + @} else + print a[i][j] + @} +@} +@end example + +@noindent +@xref{Walking Arrays}, for a user-defined function that will ``walk'' an +arbitrarily-dimensioned array of arrays. + +Recall that a reference to an uninitialized array element yields a value +of @code{""}, the null string. This has one important implication when you +intend to use a subarray as an argument to a function, as illustrated by +the following example: + +@example +$ @kbd{gawk 'BEGIN @{ split("a b c d", b[1]); print b[1][1] @}'} +@error{} gawk: cmd. line:1: fatal: split: second argument is not an array +@end example + +The way to work around this is to first force @code{b[1]} to be an array by +creating an arbitrary index: + +@example +$ @kbd{gawk 'BEGIN @{ b[1][1] = ""; split("a b c d", b[1]); print b[1][1] @}'} +@print{} a +@end example +@c ENDOFRANGE arrs + +@node Functions +@chapter Functions + +@c STARTOFRANGE funcbi +@cindex functions, built-in +@c STARTOFRANGE bifunc +@cindex built-in functions +This @value{CHAPTER} describes @command{awk}'s built-in functions, +which fall into three categories: numeric, string, and I/O. +@command{gawk} provides additional groups of functions +to work with values that represent time, do +bit manipulation, sort arrays, and internationalize and localize programs. + +Besides the built-in functions, @command{awk} has provisions for +writing new functions that the rest of a program can use. +The second half of this @value{CHAPTER} describes these +@dfn{user-defined} functions. + +@menu +* Built-in:: Summarizes the built-in functions. +* User-defined:: Describes User-defined functions in detail. +* Indirect Calls:: Choosing the function to call at runtime. +@end menu + +@node Built-in +@section Built-in Functions + +@dfn{Built-in} functions are always available for +your @command{awk} program to call. This @value{SECTION} defines all +the built-in +functions in @command{awk}; some of these are mentioned in other sections +but are summarized here for your convenience. + +@menu +* Calling Built-in:: How to call built-in functions. +* Numeric Functions:: Functions that work with numbers, including + @code{int()}, @code{sin()} and @code{rand()}. +* String Functions:: Functions for string manipulation, such as + @code{split()}, @code{match()} and + @code{sprintf()}. +* I/O Functions:: Functions for files and shell commands. +* Time Functions:: Functions for dealing with timestamps. +* Bitwise Functions:: Functions for bitwise operations. +* Type Functions:: Functions for type information. +* I18N Functions:: Functions for string translation. +@end menu + +@node Calling Built-in +@subsection Calling Built-in Functions + +To call one of @command{awk}'s built-in functions, write the name of +the function followed +by arguments in parentheses. For example, @samp{atan2(y + z, 1)} +is a call to the function @code{atan2()} and has two arguments. + +@cindex programming conventions, functions, calling +@cindex whitespace, functions@comma{} calling +Whitespace is ignored between the built-in function name and the +open parenthesis, but nonetheless it is good practice to avoid using whitespace +there. User-defined functions do not permit whitespace in this way, and +it is easier to avoid mistakes by following a simple +convention that always works---no whitespace after a function name. + +@cindex troubleshooting, @command{gawk}, fatal errors@comma{} function arguments +@cindex @command{gawk}, function arguments and +@cindex differences in @command{awk} and @command{gawk}, function arguments (@command{gawk}) +Each built-in function accepts a certain number of arguments. +In some cases, arguments can be omitted. The defaults for omitted +arguments vary from function to function and are described under the +individual functions. In some @command{awk} implementations, extra +arguments given to built-in functions are ignored. However, in @command{gawk}, +it is a fatal error to give extra arguments to a built-in function. + +When a function is called, expressions that create the function's actual +parameters are evaluated completely before the call is performed. +For example, in the following code fragment: + +@example +i = 4 +j = sqrt(i++) +@end example + +@cindex evaluation order, functions +@cindex functions, built-in, evaluation order +@cindex built-in functions, evaluation order +@noindent +the variable @code{i} is incremented to the value five before @code{sqrt()} +is called with a value of four for its actual parameter. +The order of evaluation of the expressions used for the function's +parameters is undefined. Thus, avoid writing programs that +assume that parameters are evaluated from left to right or from +right to left. For example: + +@example +i = 5 +j = atan2(i++, i *= 2) +@end example + +If the order of evaluation is left to right, then @code{i} first becomes +6, and then 12, and @code{atan2()} is called with the two arguments 6 +and 12. But if the order of evaluation is right to left, @code{i} +first becomes 10, then 11, and @code{atan2()} is called with the +two arguments 11 and 10. + +@node Numeric Functions +@subsection Numeric Functions + +The following list describes all of +the built-in functions that work with numbers. +Optional parameters are enclosed in square brackets@w{ ([ ]):} + +@table @code +@item atan2(@var{y}, @var{x}) +@cindex @code{atan2()} function +Return the arctangent of @code{@var{y} / @var{x}} in radians. +You can use @samp{pi = atan2(0, -1)} to retrieve the value of +@tex +$\pi$. +@end tex +@ifnottex +pi. +@end ifnottex + +@item cos(@var{x}) +@cindex @code{cos()} function +Return the cosine of @var{x}, with @var{x} in radians. + +@item exp(@var{x}) +@cindex @code{exp()} function +Return the exponential of @var{x} (@code{e ^ @var{x}}) or report +an error if @var{x} is out of range. The range of values @var{x} can have +depends on your machine's floating-point representation. + +@item int(@var{x}) +@cindex @code{int()} function +Return the nearest integer to @var{x}, located between @var{x} and zero and +truncated toward zero. + +For example, @code{int(3)} is 3, @code{int(3.9)} is 3, @code{int(-3.9)} +is @minus{}3, and @code{int(-3)} is @minus{}3 as well. + +@item log(@var{x}) +@cindex @code{log()} function +Return the natural logarithm of @var{x}, if @var{x} is positive; +otherwise, report an error. + +@item rand() +@cindex @code{rand()} function +@cindex random numbers, @code{rand()}/@code{srand()} functions +Return a random number. The values of @code{rand()} are +uniformly distributed between zero and one. +The value could be zero but is never one.@footnote{The C version of @code{rand()} +on many Unix systems +is known to produce fairly poor sequences of random numbers. +However, nothing requires that an @command{awk} implementation use the C +@code{rand()} to implement the @command{awk} version of @code{rand()}. +In fact, @command{gawk} uses the BSD @code{random()} function, which is +considerably better than @code{rand()}, to produce random numbers.} + +Often random integers are needed instead. Following is a user-defined function +that can be used to obtain a random non-negative integer less than @var{n}: + +@example +function randint(n) @{ + return int(n * rand()) +@} +@end example + +@noindent +The multiplication produces a random number greater than zero and less +than @code{n}. Using @code{int()}, this result is made into +an integer between zero and @code{n} @minus{} 1, inclusive. + +The following example uses a similar function to produce random integers +between one and @var{n}. This program prints a new random number for +each input record: + +@example +# Function to roll a simulated die. +function roll(n) @{ return 1 + int(rand() * n) @} + +# Roll 3 six-sided dice and +# print total number of points. +@{ + printf("%d points\n", + roll(6)+roll(6)+roll(6)) +@} +@end example + +@cindex numbers, random +@cindex random numbers, seed of +@quotation CAUTION +In most @command{awk} implementations, including @command{gawk}, +@code{rand()} starts generating numbers from the same +starting number, or @dfn{seed}, each time you run @command{awk}.@footnote{@command{mawk} +uses a different seed each time.} Thus, +a program generates the same results each time you run it. +The numbers are random within one @command{awk} run but predictable +from run to run. This is convenient for debugging, but if you want +a program to do different things each time it is used, you must change +the seed to a value that is different in each run. To do this, +use @code{srand()}. +@end quotation + +@item sin(@var{x}) +@cindex @code{sin()} function +Return the sine of @var{x}, with @var{x} in radians. + +@item sqrt(@var{x}) +@cindex @code{sqrt()} function +Return the positive square root of @var{x}. +@command{gawk} prints a warning message +if @var{x} is negative. Thus, @code{sqrt(4)} is 2. + +@item srand(@r{[}@var{x}@r{]}) +@cindex @code{srand()} function +Set the starting point, or seed, +for generating random numbers to the value @var{x}. + +Each seed value leads to a particular sequence of random +numbers.@footnote{Computer-generated random numbers really are not truly +random. They are technically known as ``pseudorandom.'' This means +that while the numbers in a sequence appear to be random, you can in +fact generate the same sequence of random numbers over and over again.} +Thus, if the seed is set to the same value a second time, +the same sequence of random numbers is produced again. + +@quotation CAUTION +Different @command{awk} implementations use different random-number +generators internally. Don't expect the same @command{awk} program +to produce the same series of random numbers when executed by +different versions of @command{awk}. +@end quotation + +If the argument @var{x} is omitted, as in @samp{srand()}, then the current +date and time of day are used for a seed. This is the way to get random +numbers that are truly unpredictable. + +The return value of @code{srand()} is the previous seed. This makes it +easy to keep track of the seeds in case you need to consistently reproduce +sequences of random numbers. +@end table + +@node String Functions +@subsection String-Manipulation Functions + +The functions in this @value{SECTION} look at or change the text of one or more +strings. +@code{gawk} understands locales (@pxref{Locales}), and does all string processing in terms of +@emph{characters}, not @emph{bytes}. This distinction is particularly important +to understand for locales where one character +may be represented by multiple bytes. Thus, for example, @code{length()} +returns the number of characters in a string, and not the number of bytes +used to represent those characters, Similarly, @code{index()} works with +character indices, and not byte indices. + +In the following list, optional parameters are enclosed in square brackets@w{ ([ ]).} +Several functions perform string substitution; the full discussion is +provided in the description of the @code{sub()} function, which comes +towards the end since the list is presented in alphabetic order. +Those functions that are specific to @command{gawk} are marked with a +pound sign@w{ (@samp{#}):} + +@menu +* Gory Details:: More than you want to know about @samp{\} and + @samp{&} with @code{sub()}, @code{gsub()}, and + @code{gensub()}. +@end menu + +@table @code +@item asort(@var{source} @r{[}, @var{dest} @r{[}, @var{how} @r{]} @r{]}) # +@cindex arrays, elements, retrieving number of +@cindex @code{asort()} function (@command{gawk}) +@cindex @command{gawk}, @code{IGNORECASE} variable in +@cindex @code{IGNORECASE} variable +Return the number of elements in the array @var{source}. +@command{gawk} sorts the contents of @var{source} +and replaces the indices +of the sorted values of @var{source} with sequential +integers starting with one. If the optional array @var{dest} is specified, +then @var{source} is duplicated into @var{dest}. @var{dest} is then +sorted, leaving the indices of @var{source} unchanged. The optional third +argument @var{how} is a string which controls the rule for comparing values, +and the sort direction. A single space is required between the +comparison mode, @samp{string} or @samp{number}, and the direction specification, +@samp{ascending} or @samp{descending}. You can omit direction and/or mode +in which case it will default to @samp{ascending} and @samp{string}, respectively. +An empty string "" is the same as the default @code{"ascending string"} +for the value of @var{how}. If the @samp{source} array contains subarrays as values, +they will come out last(first) in the @samp{dest} array for @samp{ascending}(@samp{descending}) +order specification. The value of @code{IGNORECASE} affects the sorting. +The third argument can also be a user-defined function name in which case +the value returned by the function is used to order the array elements +before constructing the result array. +@xref{Array Sorting Functions}, for more information. + +For example, if the contents of @code{a} are as follows: + +@example +a["last"] = "de" +a["first"] = "sac" +a["middle"] = "cul" +@end example + +@noindent +A call to @code{asort()}: + +@example +asort(a) +@end example + +@noindent +results in the following contents of @code{a}: + +@example +a[1] = "cul" +a[2] = "de" +a[3] = "sac" +@end example + +In order to reverse the direction of the sorted results in the above example, +@code{asort()} can be called with three arguments as follows: + +@example +asort(a, a, "descending") +@end example + +The @code{asort()} function is described in more detail in +@ref{Array Sorting Functions}. +@code{asort()} is a @command{gawk} extension; it is not available +in compatibility mode (@pxref{Options}). + +@item asorti(@var{source} @r{[}, @var{dest} @r{[}, @var{how} @r{]} @r{]}) # +@cindex @code{asorti()} function (@command{gawk}) +Return the number of elements in the array @var{source}. +It works similarly to @code{asort()}, however, the @emph{indices} +are sorted, instead of the values. (Here too, +@code{IGNORECASE} affects the sorting.) + +The @code{asorti()} function is described in more detail in +@ref{Array Sorting Functions}. +@code{asorti()} is a @command{gawk} extension; it is not available +in compatibility mode (@pxref{Options}). + +@item gensub(@var{regexp}, @var{replacement}, @var{how} @r{[}, @var{target}@r{]}) # +@cindex @code{gensub()} function (@command{gawk}) +Search the target string @var{target} for matches of the regular +expression @var{regexp}. If @var{how} is a string beginning with +@samp{g} or @samp{G} (short for ``global''), then replace all matches of @var{regexp} with +@var{replacement}. Otherwise, @var{how} is treated as a number indicating +which match of @var{regexp} to replace. If no @var{target} is supplied, +use @code{$0}. It returns the modified string as the result +of the function and the original target string is @emph{not} changed. + +@code{gensub()} is a general substitution function. It's purpose is +to provide more features than the standard @code{sub()} and @code{gsub()} +functions. + +@code{gensub()} provides an additional feature that is not available +in @code{sub()} or @code{gsub()}: the ability to specify components of a +regexp in the replacement text. This is done by using parentheses in +the regexp to mark the components and then specifying @samp{\@var{N}} +in the replacement text, where @var{N} is a digit from 1 to 9. +For example: + +@example +$ @kbd{gawk '} +> @kbd{BEGIN @{} +> @kbd{a = "abc def"} +> @kbd{b = gensub(/(.+) (.+)/, "\\2 \\1", "g", a)} +> @kbd{print b} +> @kbd{@}'} +@print{} def abc +@end example + +@noindent +As with @code{sub()}, you must type two backslashes in order +to get one into the string. +In the replacement text, the sequence @samp{\0} represents the entire +matched text, as does the character @samp{&}. + +The following example shows how you can use the third argument to control +which match of the regexp should be changed: + +@example +$ @kbd{echo a b c a b c |} +> @kbd{gawk '@{ print gensub(/a/, "AA", 2) @}'} +@print{} a b c AA b c +@end example + +In this case, @code{$0} is the default target string. +@code{gensub()} returns the new string as its result, which is +passed directly to @code{print} for printing. + +@c @cindex automatic warnings +@c @cindex warnings, automatic +If the @var{how} argument is a string that does not begin with @samp{g} or +@samp{G}, or if it is a number that is less than or equal to zero, only one +substitution is performed. If @var{how} is zero, @command{gawk} issues +a warning message. + +If @var{regexp} does not match @var{target}, @code{gensub()}'s return value +is the original unchanged value of @var{target}. + +@code{gensub()} is a @command{gawk} extension; it is not available +in compatibility mode (@pxref{Options}). + +@item gsub(@var{regexp}, @var{replacement} @r{[}, @var{target}@r{]}) +@cindex @code{gsub()} function +Search @var{target} for +@emph{all} of the longest, leftmost, @emph{nonoverlapping} matching +substrings it can find and replace them with @var{replacement}. +The @samp{g} in @code{gsub()} stands for +``global,'' which means replace everywhere. For example: + +@example +@{ gsub(/Britain/, "United Kingdom"); print @} +@end example + +@noindent +replaces all occurrences of the string @samp{Britain} with @samp{United +Kingdom} for all input records. + +The @code{gsub()} function returns the number of substitutions made. If +the variable to search and alter (@var{target}) is +omitted, then the entire input record (@code{$0}) is used. +As in @code{sub()}, the characters @samp{&} and @samp{\} are special, +and the third argument must be assignable. + +@item index(@var{in}, @var{find}) +@cindex @code{index()} function +@cindex searching +Search the string @var{in} for the first occurrence of the string +@var{find}, and return the position in characters where that occurrence +begins in the string @var{in}. Consider the following example: + +@example +$ @kbd{awk 'BEGIN @{ print index("peanut", "an") @}'} +@print{} 3 +@end example + +@noindent +If @var{find} is not found, @code{index()} returns zero. +(Remember that string indices in @command{awk} start at one.) + +@item length(@r{[}@var{string}@r{]}) +@cindex @code{length()} function +Return the number of characters in @var{string}. If +@var{string} is a number, the length of the digit string representing +that number is returned. For example, @code{length("abcde")} is five. By +contrast, @code{length(15 * 35)} works out to three. In this example, 15 * 35 = +525, and 525 is then converted to the string @code{"525"}, which has +three characters. + +If no argument is supplied, @code{length()} returns the length of @code{$0}. + +@c @cindex historical features +@cindex portability, @code{length()} function +@cindex POSIX @command{awk}, functions and, @code{length()} +@quotation NOTE +In older versions of @command{awk}, the @code{length()} function could +be called +without any parentheses. Doing so is considered poor practice, +although the 2008 POSIX standard explicitly allows it, to +support historical practice. For programs to be maximally portable, +always supply the parentheses. +@end quotation + +@cindex dark corner, @code{length()} function +If @code{length()} is called with a variable that has not been used, +@command{gawk} forces the variable to be a scalar. Other +implementations of @command{awk} leave the variable without a type. +@value{DARKCORNER} +Consider: + +@example +$ @kbd{gawk 'BEGIN @{ print length(x) ; x[1] = 1 @}'} +@print{} 0 +@error{} gawk: fatal: attempt to use scalar `x' as array + +$ @kbd{nawk 'BEGIN @{ print length(x) ; x[1] = 1 @}'} +@print{} 0 +@end example + +@noindent +If @option{--lint} has +been specified on the command line, @command{gawk} issues a +warning about this. + +@cindex common extensions, @code{length()} applied to an array +@cindex extensions, common@comma{} @code{length()} applied to an array +@cindex differences between @command{gawk} and @command{awk} +With @command{gawk} and several other @command{awk} implementations, when given an +array argument, the @code{length()} function returns the number of elements +in the array. @value{COMMONEXT} +This is less useful than it might seem at first, as the +array is not guaranteed to be indexed from one to the number of elements +in it. +If @option{--lint} is provided on the command line +(@pxref{Options}), +@command{gawk} warns that passing an array argument is not portable. +If @option{--posix} is supplied, using an array argument is a fatal error +(@pxref{Arrays}). + +@item match(@var{string}, @var{regexp} @r{[}, @var{array}@r{]}) +@cindex @code{match()} function +Search @var{string} for the +longest, leftmost substring matched by the regular expression, +@var{regexp} and return the character position, or @dfn{index}, +at which that substring begins (one, if it starts at the beginning of +@var{string}). If no match is found, return zero. + +The @var{regexp} argument may be either a regexp constant +(@code{/@dots{}/}) or a string constant (@code{"@dots{}"}). +In the latter case, the string is treated as a regexp to be matched. +@xref{Computed Regexps}, for a +discussion of the difference between the two forms, and the +implications for writing your program correctly. + +The order of the first two arguments is backwards from most other string +functions that work with regular expressions, such as +@code{sub()} and @code{gsub()}. It might help to remember that +for @code{match()}, the order is the same as for the @samp{~} operator: +@samp{@var{string} ~ @var{regexp}}. + +@cindex @code{RSTART} variable, @code{match()} function and +@cindex @code{RLENGTH} variable, @code{match()} function and +@cindex @code{match()} function, @code{RSTART}/@code{RLENGTH} variables +The @code{match()} function sets the built-in variable @code{RSTART} to +the index. It also sets the built-in variable @code{RLENGTH} to the +length in characters of the matched substring. If no match is found, +@code{RSTART} is set to zero, and @code{RLENGTH} to @minus{}1. + +For example: + +@example +@c file eg/misc/findpat.awk +@{ + if ($1 == "FIND") + regex = $2 + else @{ + where = match($0, regex) + if (where != 0) + print "Match of", regex, "found at", + where, "in", $0 + @} +@} +@c endfile +@end example + +@noindent +This program looks for lines that match the regular expression stored in +the variable @code{regex}. This regular expression can be changed. If the +first word on a line is @samp{FIND}, @code{regex} is changed to be the +second word on that line. Therefore, if given: + +@example +@c file eg/misc/findpat.data +FIND ru+n +My program runs +but not very quickly +FIND Melvin +JF+KM +This line is property of Reality Engineering Co. +Melvin was here. +@c endfile +@end example + +@noindent +@command{awk} prints: + +@example +Match of ru+n found at 12 in My program runs +Match of Melvin found at 1 in Melvin was here. +@end example + +@cindex differences in @command{awk} and @command{gawk}, @code{match()} function +If @var{array} is present, it is cleared, and then the zeroth element +of @var{array} is set to the entire portion of @var{string} +matched by @var{regexp}. If @var{regexp} contains parentheses, +the integer-indexed elements of @var{array} are set to contain the +portion of @var{string} matching the corresponding parenthesized +subexpression. +For example: + +@example +$ @kbd{echo foooobazbarrrrr |} +> @kbd{gawk '@{ match($0, /(fo+).+(bar*)/, arr)} +> @kbd{print arr[1], arr[2] @}'} +@print{} foooo barrrrr +@end example + +In addition, +multidimensional subscripts are available providing +the start index and length of each matched subexpression: + +@example +$ @kbd{echo foooobazbarrrrr |} +> @kbd{gawk '@{ match($0, /(fo+).+(bar*)/, arr)} +> @kbd{print arr[1], arr[2]} +> @kbd{print arr[1, "start"], arr[1, "length"]} +> @kbd{print arr[2, "start"], arr[2, "length"]} +> @kbd{@}'} +@print{} foooo barrrrr +@print{} 1 5 +@print{} 9 7 +@end example + +There may not be subscripts for the start and index for every parenthesized +subexpression, since they may not all have matched text; thus they +should be tested for with the @code{in} operator +(@pxref{Reference to Elements}). + +@cindex troubleshooting, @code{match()} function +The @var{array} argument to @code{match()} is a +@command{gawk} extension. In compatibility mode +(@pxref{Options}), +using a third argument is a fatal error. + +@item patsplit(@var{string}, @var{array} @r{[}, @var{fieldpat} @r{[}, @var{seps} @r{]} @r{]}) # +@cindex @code{patsplit()} function +Divide +@var{string} into pieces defined by @var{fieldpat} +and store the pieces in @var{array} and the separator strings in the +@var{seps} array. The first piece is stored in +@code{@var{array}[1]}, the second piece in @code{@var{array}[2]}, and so +forth. The third argument, @var{fieldpat}, is +a regexp describing the fields in @var{string} (just as @code{FPAT} is +a regexp describing the fields in input records). +It may be either a regexp constant or a string. +If @var{fieldpat} is omitted, the value of @code{FPAT} is used. +@code{patsplit()} returns the number of elements created. +@code{@var{seps}[@var{i}]} is +the separator string +between @code{@var{array}[@var{i}]} and @code{@var{array}[@var{i}+1]}. +Any leading separator will be in @code{@var{seps}[0]}. + +The @code{patsplit()} function splits strings into pieces in a +manner similar to the way input lines are split into fields using @code{FPAT} +(@pxref{Splitting By Content}. + +Before splitting the string, @code{patsplit()} deletes any previously existing +elements in the arrays @var{array} and @var{seps}. + +@cindex troubleshooting, @code{patsplit()} function +The @code{patsplit()} function is a +@command{gawk} extension. In compatibility mode +(@pxref{Options}), +it is not available. + +@item split(@var{string}, @var{array} @r{[}, @var{fieldsep} @r{[}, @var{seps} @r{]} @r{]}) +@cindex @code{split()} function +Divide @var{string} into pieces separated by @var{fieldsep} +and store the pieces in @var{array} and the separator strings in the +@var{seps} array. The first piece is stored in +@code{@var{array}[1]}, the second piece in @code{@var{array}[2]}, and so +forth. The string value of the third argument, @var{fieldsep}, is +a regexp describing where to split @var{string} (much as @code{FS} can +be a regexp describing where to split input records; +@pxref{Regexp Field Splitting}). +If @var{fieldsep} is omitted, the value of @code{FS} is used. +@code{split()} returns the number of elements created. +@var{seps} is a @command{gawk} extension with @code{@var{seps}[@var{i}]} +being the separator string +between @code{@var{array}[@var{i}]} and @code{@var{array}[@var{i}+1]}. +If @var{fieldsep} is a single +space then any leading whitespace goes into @code{@var{seps}[0]} and +any trailing +whitespace goes into @code{@var{seps}[@var{n}]} where @var{n} is the +return value of +@code{split()} (that is, the number of elements in @var{array}). + +The @code{split()} function splits strings into pieces in a +manner similar to the way input lines are split into fields. For example: + +@example +split("cul-de-sac", a, "-", seps) +@end example + +@noindent +@cindex strings, splitting +splits the string @samp{cul-de-sac} into three fields using @samp{-} as the +separator. It sets the contents of the array @code{a} as follows: + +@example +a[1] = "cul" +a[2] = "de" +a[3] = "sac" +@end example + +and sets the contents of the array @code{seps} as follows: + +@example +seps[1] = "-" +seps[2] = "-" +@end example + +@noindent +The value returned by this call to @code{split()} is three. + +@cindex differences in @command{awk} and @command{gawk}, @code{split()} function +As with input field-splitting, when the value of @var{fieldsep} is +@w{@code{" "}}, leading and trailing whitespace is ignored in values assigned to +the elements of +@var{array} but not in @var{seps}, and the elements +are separated by runs of whitespace. +Also as with input field-splitting, if @var{fieldsep} is the null string, each +individual character in the string is split into its own array element. +@value{COMMONEXT} + +Note, however, that @code{RS} has no effect on the way @code{split()} +works. Even though @samp{RS = ""} causes newline to also be an input +field separator, this does not affect how @code{split()} splits strings. + +@cindex dark corner, @code{split()} function +Modern implementations of @command{awk}, including @command{gawk}, allow +the third argument to be a regexp constant (@code{/abc/}) as well as a +string. +@value{DARKCORNER} +The POSIX standard allows this as well. +@xref{Computed Regexps}, for a +discussion of the difference between using a string constant or a regexp constant, +and the implications for writing your program correctly. + +Before splitting the string, @code{split()} deletes any previously existing +elements in the arrays @var{array} and @var{seps}. + +If @var{string} is null, the array has no elements. (So this is a portable +way to delete an entire array with one statement. +@xref{Delete}.) + +If @var{string} does not match @var{fieldsep} at all (but is not null), +@var{array} has one element only. The value of that element is the original +@var{string}. + +@item sprintf(@var{format}, @var{expression1}, @dots{}) +@cindex @code{sprintf()} function +Return (without printing) the string that @code{printf} would +have printed out with the same arguments +(@pxref{Printf}). +For example: + +@example +pival = sprintf("pi = %.2f (approx.)", 22/7) +@end example + +@noindent +assigns the string @w{@samp{pi = 3.14 (approx.)}} to the variable @code{pival}. + +@cindex @code{strtonum()} function (@command{gawk}) +@item strtonum(@var{str}) # +Examine @var{str} and return its numeric value. If @var{str} +begins with a leading @samp{0}, @code{strtonum()} assumes that @var{str} +is an octal number. If @var{str} begins with a leading @samp{0x} or +@samp{0X}, @code{strtonum()} assumes that @var{str} is a hexadecimal number. +For example: + +@example +$ @kbd{echo 0x11 |} +> @kbd{gawk '@{ printf "%d\n", strtonum($1) @}'} +@print{} 17 +@end example + +Using the @code{strtonum()} function is @emph{not} the same as adding zero +to a string value; the automatic coercion of strings to numbers +works only for decimal data, not for octal or hexadecimal.@footnote{Unless +you use the @option{--non-decimal-data} option, which isn't recommended. +@xref{Nondecimal Data}, for more information.} + +Note also that @code{strtonum()} uses the current locale's decimal point +for recognizing numbers (@pxref{Locales}). + +@cindex differences in @command{awk} and @command{gawk}, @code{strtonum()} function (@command{gawk}) +@code{strtonum()} is a @command{gawk} extension; it is not available +in compatibility mode (@pxref{Options}). + +@item sub(@var{regexp}, @var{replacement} @r{[}, @var{target}@r{]}) +@cindex @code{sub()} function +Search @var{target}, which is treated as a string, for the +leftmost, longest substring matched by the regular expression @var{regexp}. +Modify the entire string +by replacing the matched text with @var{replacement}. +The modified string becomes the new value of @var{target}. +Return the number of substitutions made (zero or one). + +The @var{regexp} argument may be either a regexp constant +(@code{/@dots{}/}) or a string constant (@code{"@dots{}"}). +In the latter case, the string is treated as a regexp to be matched. +@xref{Computed Regexps}, for a +discussion of the difference between the two forms, and the +implications for writing your program correctly. + +This function is peculiar because @var{target} is not simply +used to compute a value, and not just any expression will do---it +must be a variable, field, or array element so that @code{sub()} can +store a modified value there. If this argument is omitted, then the +default is to use and alter @code{$0}.@footnote{Note that this means +that the record will first be regenerated using the value of @code{OFS} if +any fields have been changed, and that the fields will be updated +after the substitution, even if the operation is a ``no-op'' such +as @samp{sub(/^/, "")}.} +For example: + +@example +str = "water, water, everywhere" +sub(/at/, "ith", str) +@end example + +@noindent +sets @code{str} to @w{@samp{wither, water, everywhere}}, by replacing the +leftmost longest occurrence of @samp{at} with @samp{ith}. + +If the special character @samp{&} appears in @var{replacement}, it +stands for the precise substring that was matched by @var{regexp}. (If +the regexp can match more than one string, then this precise substring +may vary.) For example: + +@example +@{ sub(/candidate/, "& and his wife"); print @} +@end example + +@noindent +changes the first occurrence of @samp{candidate} to @samp{candidate +and his wife} on each input line. +Here is another example: + +@example +$ @kbd{awk 'BEGIN @{} +> @kbd{str = "daabaaa"} +> @kbd{sub(/a+/, "C&C", str)} +> @kbd{print str} +> @kbd{@}'} +@print{} dCaaCbaaa +@end example + +@noindent +This shows how @samp{&} can represent a nonconstant string and also +illustrates the ``leftmost, longest'' rule in regexp matching +(@pxref{Leftmost Longest}). + +The effect of this special character (@samp{&}) can be turned off by putting a +backslash before it in the string. As usual, to insert one backslash in +the string, you must write two backslashes. Therefore, write @samp{\\&} +in a string constant to include a literal @samp{&} in the replacement. +For example, the following shows how to replace the first @samp{|} on each line with +an @samp{&}: + +@example +@{ sub(/\|/, "\\&"); print @} +@end example + +@cindex @code{sub()} function, arguments of +@cindex @code{gsub()} function, arguments of +As mentioned, the third argument to @code{sub()} must +be a variable, field or array element. +Some versions of @command{awk} allow the third argument to +be an expression that is not an lvalue. In such a case, @code{sub()} +still searches for the pattern and returns zero or one, but the result of +the substitution (if any) is thrown away because there is no place +to put it. Such versions of @command{awk} accept expressions +like the following: + +@example +sub(/USA/, "United States", "the USA and Canada") +@end example + +@noindent +@cindex troubleshooting, @code{gsub()}/@code{sub()} functions +For historical compatibility, @command{gawk} accepts such erroneous code. +However, using any other nonchangeable +object as the third parameter causes a fatal error and your program +will not run. + +Finally, if the @var{regexp} is not a regexp constant, it is converted into a +string, and then the value of that string is treated as the regexp to match. + +@item substr(@var{string}, @var{start} @r{[}, @var{length}@r{]}) +@cindex @code{substr()} function +Return a @var{length}-character-long substring of @var{string}, +starting at character number @var{start}. The first character of a +string is character number one.@footnote{This is different from +C and C++, in which the first character is number zero.} +For example, @code{substr("washington", 5, 3)} returns @code{"ing"}. + +If @var{length} is not present, @code{substr()} returns the whole suffix of +@var{string} that begins at character number @var{start}. For example, +@code{substr("washington", 5)} returns @code{"ington"}. The whole +suffix is also returned +if @var{length} is greater than the number of characters remaining +in the string, counting from character @var{start}. + +If @var{start} is less than one, @code{substr()} treats it as +if it was one. (POSIX doesn't specify what to do in this case: +Brian Kernighan's @command{awk} acts this way, and therefore @command{gawk} +does too.) +If @var{start} is greater than the number of characters +in the string, @code{substr()} returns the null string. +Similarly, if @var{length} is present but less than or equal to zero, +the null string is returned. + +@cindex troubleshooting, @code{substr()} function +The string returned by @code{substr()} @emph{cannot} be +assigned. Thus, it is a mistake to attempt to change a portion of +a string, as shown in the following example: + +@example +string = "abcdef" +# try to get "abCDEf", won't work +substr(string, 3, 3) = "CDE" +@end example + +@noindent +It is also a mistake to use @code{substr()} as the third argument +of @code{sub()} or @code{gsub()}: + +@example +gsub(/xyz/, "pdq", substr($0, 5, 20)) # WRONG +@end example + +@cindex portability, @code{substr()} function +(Some commercial versions of @command{awk} treat +@code{substr()} as assignable, but doing so is not portable.) + +If you need to replace bits and pieces of a string, combine @code{substr()} +with string concatenation, in the following manner: + +@example +string = "abcdef" +@dots{} +string = substr(string, 1, 2) "CDE" substr(string, 6) +@end example + +@cindex case sensitivity, converting case +@cindex converting, case +@item tolower(@var{string}) +@cindex @code{tolower()} function +Return a copy of @var{string}, with each uppercase character +in the string replaced with its corresponding lowercase character. +Nonalphabetic characters are left unchanged. For example, +@code{tolower("MiXeD cAsE 123")} returns @code{"mixed case 123"}. + +@item toupper(@var{string}) +@cindex @code{toupper()} function +Return a copy of @var{string}, with each lowercase character +in the string replaced with its corresponding uppercase character. +Nonalphabetic characters are left unchanged. For example, +@code{toupper("MiXeD cAsE 123")} returns @code{"MIXED CASE 123"}. +@end table + +@node Gory Details +@subsubsection More About @samp{\} and @samp{&} with @code{sub()}, @code{gsub()}, and @code{gensub()} + +@cindex escape processing, @code{gsub()}/@code{gensub()}/@code{sub()} functions +@cindex @code{sub()} function, escape processing +@cindex @code{gsub()} function, escape processing +@cindex @code{gensub()} function (@command{gawk}), escape processing +@cindex @code{\} (backslash), @code{gsub()}/@code{gensub()}/@code{sub()} functions and +@cindex backslash (@code{\}), @code{gsub()}/@code{gensub()}/@code{sub()} functions and +@cindex @code{&} (ampersand), @code{gsub()}/@code{gensub()}/@code{sub()} functions and +@cindex ampersand (@code{&}), @code{gsub()}/@code{gensub()}/@code{sub()} functions and +When using @code{sub()}, @code{gsub()}, or @code{gensub()}, and trying to get literal +backslashes and ampersands into the replacement text, you need to remember +that there are several levels of @dfn{escape processing} going on. + +First, there is the @dfn{lexical} level, which is when @command{awk} reads +your program +and builds an internal copy of it that can be executed. +Then there is the runtime level, which is when @command{awk} actually scans the +replacement string to determine what to generate. + +At both levels, @command{awk} looks for a defined set of characters that +can come after a backslash. At the lexical level, it looks for the +escape sequences listed in @ref{Escape Sequences}. +Thus, for every @samp{\} that @command{awk} processes at the runtime +level, you must type two backslashes at the lexical level. +When a character that is not valid for an escape sequence follows the +@samp{\}, Brian Kernighan's @command{awk} and @command{gawk} both simply remove the initial +@samp{\} and put the next character into the string. Thus, for +example, @code{"a\qb"} is treated as @code{"aqb"}. + +At the runtime level, the various functions handle sequences of +@samp{\} and @samp{&} differently. The situation is (sadly) somewhat complex. +Historically, the @code{sub()} and @code{gsub()} functions treated the two +character sequence @samp{\&} specially; this sequence was replaced in +the generated text with a single @samp{&}. Any other @samp{\} within +the @var{replacement} string that did not precede an @samp{&} was passed +through unchanged. This is illustrated in @ref{table-sub-escapes}. + +@c Thank to Karl Berry for help with the TeX stuff. +@float Table,table-sub-escapes +@caption{Historical Escape Sequence Processing for @code{sub()} and @code{gsub()}} +@tex +\vbox{\bigskip +% This table has lots of &'s and \'s, so unspecialize them. +\catcode`\& = \other \catcode`\\ = \other +% But then we need character for escape and tab. +@catcode`! = 4 +@halign{@hfil#!@qquad@hfil#!@qquad#@hfil@cr + You type!@code{sub()} sees!@code{sub()} generates@cr +@hrulefill!@hrulefill!@hrulefill@cr + @code{\&}! @code{&}!the matched text@cr + @code{\\&}! @code{\&}!a literal @samp{&}@cr + @code{\\\&}! @code{\&}!a literal @samp{&}@cr +@code{\\\\&}! @code{\\&}!a literal @samp{\&}@cr +@code{\\\\\&}! @code{\\&}!a literal @samp{\&}@cr +@code{\\\\\\&}! @code{\\\&}!a literal @samp{\\&}@cr + @code{\\q}! @code{\q}!a literal @samp{\q}@cr +} +@bigskip} +@end tex +@ifdocbook +@multitable @columnfractions .20 .20 .60 +@headitem You type @tab @code{sub()} sees @tab @code{sub()} generates +@item @code{\&} @tab @code{&} @tab the matched text +@item @code{\\&} @tab @code{\&} @tab a literal @samp{&} +@item @code{\\\&} @tab @code{\&} @tab a literal @samp{&} +@item @code{\\\\&} @tab @code{\\&} @tab a literal @samp{\&} +@item @code{\\\\\&} @tab @code{\\&} @tab a literal @samp{\&} +@item @code{\\\\\\&} @tab @code{\\\&} @tab a literal @samp{\\&} +@item @code{\\q} @tab @code{\q} @tab a literal @samp{\q} +@end multitable +@end ifdocbook +@ifnottex +@ifnotdocbook +@display + You type @code{sub()} sees @code{sub()} generates + -------- ---------- --------------- + @code{\&} @code{&} the matched text + @code{\\&} @code{\&} a literal @samp{&} + @code{\\\&} @code{\&} a literal @samp{&} + @code{\\\\&} @code{\\&} a literal @samp{\&} + @code{\\\\\&} @code{\\&} a literal @samp{\&} +@code{\\\\\\&} @code{\\\&} a literal @samp{\\&} + @code{\\q} @code{\q} a literal @samp{\q} +@end display +@end ifnotdocbook +@end ifnottex +@end float + +@noindent +This table shows both the lexical-level processing, where +an odd number of backslashes becomes an even number at the runtime level, +as well as the runtime processing done by @code{sub()}. +(For the sake of simplicity, the rest of the following tables only show the +case of even numbers of backslashes entered at the lexical level.) + +The problem with the historical approach is that there is no way to get +a literal @samp{\} followed by the matched text. + +@c @cindex @command{awk} language, POSIX version +@cindex POSIX @command{awk}, functions and, @code{gsub()}/@code{sub()} +The 1992 POSIX standard attempted to fix this problem. That standard +says that @code{sub()} and @code{gsub()} look for either a @samp{\} or an @samp{&} +after the @samp{\}. If either one follows a @samp{\}, that character is +output literally. The interpretation of @samp{\} and @samp{&} then becomes +as shown in @ref{table-sub-posix-92}. + +@float Table,table-sub-posix-92 +@caption{1992 POSIX Rules for sub and gsub Escape Sequence Processing} +@c thanks to Karl Berry for formatting this table +@tex +\vbox{\bigskip +% This table has lots of &'s and \'s, so unspecialize them. +\catcode`\& = \other \catcode`\\ = \other +% But then we need character for escape and tab. +@catcode`! = 4 +@halign{@hfil#!@qquad@hfil#!@qquad#@hfil@cr + You type!@code{sub()} sees!@code{sub()} generates@cr +@hrulefill!@hrulefill!@hrulefill@cr + @code{&}! @code{&}!the matched text@cr + @code{\\&}! @code{\&}!a literal @samp{&}@cr +@code{\\\\&}! @code{\\&}!a literal @samp{\}, then the matched text@cr +@code{\\\\\\&}! @code{\\\&}!a literal @samp{\&}@cr +} +@bigskip} +@end tex +@ifdocbook +@multitable @columnfractions .20 .20 .60 +@headitem You type @tab @code{sub()} sees @tab @code{sub()} generates +@item @code{&} @tab @code{&} @tab the matched text +@item @code{\\&} @tab @code{\&} @tab a literal @samp{&} +@item @code{\\\\&} @tab @code{\\&} @tab a literal @samp{\}, then the matched text +@item @code{\\\\\\&} @tab @code{\\\&} @tab a literal @samp{\&} +@end multitable +@end ifdocbook +@ifnottex +@ifnotdocbook +@display + You type @code{sub()} sees @code{sub()} generates + -------- ---------- --------------- + @code{&} @code{&} the matched text + @code{\\&} @code{\&} a literal @samp{&} + @code{\\\\&} @code{\\&} a literal @samp{\}, then the matched text +@code{\\\\\\&} @code{\\\&} a literal @samp{\&} +@end display +@end ifnotdocbook +@end ifnottex +@end float + +@noindent +This appears to solve the problem. +Unfortunately, the phrasing of the standard is unusual. It +says, in effect, that @samp{\} turns off the special meaning of any +following character, but for anything other than @samp{\} and @samp{&}, +such special meaning is undefined. This wording leads to two problems: + +@itemize @bullet +@item +Backslashes must now be doubled in the @var{replacement} string, breaking +historical @command{awk} programs. + +@item +To make sure that an @command{awk} program is portable, @emph{every} character +in the @var{replacement} string must be preceded with a +backslash.@footnote{This consequence was certainly unintended.} +@c I can say that, 'cause I was involved in making this change +@end itemize + +Because of the problems just listed, +in 1996, the @command{gawk} maintainer submitted +proposed text for a revised standard that +reverts to rules that correspond more closely to the original existing +practice. The proposed rules have special cases that make it possible +to produce a @samp{\} preceding the matched text. This is shown in +@ref{table-sub-proposed}. + +@float Table,table-sub-proposed +@caption{Proposed rules for sub and backslash} +@tex +\vbox{\bigskip +% This table has lots of &'s and \'s, so unspecialize them. +\catcode`\& = \other \catcode`\\ = \other +% But then we need character for escape and tab. +@catcode`! = 4 +@halign{@hfil#!@qquad@hfil#!@qquad#@hfil@cr + You type!@code{sub()} sees!@code{sub()} generates@cr +@hrulefill!@hrulefill!@hrulefill@cr +@code{\\\\\\&}! @code{\\\&}!a literal @samp{\&}@cr +@code{\\\\&}! @code{\\&}!a literal @samp{\}, followed by the matched text@cr + @code{\\&}! @code{\&}!a literal @samp{&}@cr + @code{\\q}! @code{\q}!a literal @samp{\q}@cr + @code{\\\\}! @code{\\}!@code{\\}@cr +} +@bigskip} +@end tex +@ifdocbook +@multitable @columnfractions .20 .20 .60 +@headitem You type @tab @code{sub()} sees @tab @code{sub()} generates +@item @code{\\\\\\&} @tab @code{\\\&} @tab a literal @samp{\&} +@item @code{\\\\&} @tab @code{\\&} @tab a literal @samp{\}, followed by the matched text +@item @code{\\&} @tab @code{\&} @tab a literal @samp{&} +@item @code{\\q} @tab @code{\q} @tab a literal @samp{\q} +@item @code{\\\\} @tab @code{\\} @tab @code{\\} +@end multitable +@end ifdocbook +@ifnottex +@ifnotdocbook +@display + You type @code{sub()} sees @code{sub()} generates + -------- ---------- --------------- +@code{\\\\\\&} @code{\\\&} a literal @samp{\&} + @code{\\\\&} @code{\\&} a literal @samp{\}, followed by the matched text + @code{\\&} @code{\&} a literal @samp{&} + @code{\\q} @code{\q} a literal @samp{\q} + @code{\\\\} @code{\\} @code{\\} +@end display +@end ifnotdocbook +@end ifnottex +@end float + +In a nutshell, at the runtime level, there are now three special sequences +of characters (@samp{\\\&}, @samp{\\&} and @samp{\&}) whereas historically +there was only one. However, as in the historical case, any @samp{\} that +is not part of one of these three sequences is not special and appears +in the output literally. + +@command{gawk} 3.0 and 3.1 follow these proposed POSIX rules for @code{sub()} and +@code{gsub()}. +@c As much as we think it's a lousy idea. You win some, you lose some. Sigh. +The POSIX standard took much longer to be revised than was expected in 1996. +The 2001 standard does not follow the above rules. Instead, the rules +there are somewhat simpler. The results are similar except for one case. + +The POSIX rules state that @samp{\&} in the replacement string produces +a literal @samp{&}, @samp{\\} produces a literal @samp{\}, and @samp{\} followed +by anything else is not special; the @samp{\} is placed straight into the output. +These rules are presented in @ref{table-posix-sub}. + +@float Table,table-posix-sub +@caption{POSIX rules for @code{sub()} and @code{gsub()}} +@tex +\vbox{\bigskip +% This table has lots of &'s and \'s, so unspecialize them. +\catcode`\& = \other \catcode`\\ = \other +% But then we need character for escape and tab. +@catcode`! = 4 +@halign{@hfil#!@qquad@hfil#!@qquad#@hfil@cr + You type!@code{sub()} sees!@code{sub()} generates@cr +@hrulefill!@hrulefill!@hrulefill@cr +@code{\\\\\\&}! @code{\\\&}!a literal @samp{\&}@cr +@code{\\\\&}! @code{\\&}!a literal @samp{\}, followed by the matched text@cr + @code{\\&}! @code{\&}!a literal @samp{&}@cr + @code{\\q}! @code{\q}!a literal @samp{\q}@cr + @code{\\\\}! @code{\\}!@code{\}@cr +} +@bigskip} +@end tex +@ifdocbook +@multitable @columnfractions .20 .20 .60 +@headitem You type @tab @code{sub()} sees @tab @code{sub()} generates +@item @code{\\\\\\&} @tab @code{\\\&} @tab a literal @samp{\&} +@item @code{\\\\&} @tab @code{\\&} @tab a literal @samp{\}, followed by the matched text +@item @code{\\&} @tab @code{\&} @tab a literal @samp{&} +@item @code{\\q} @tab @code{\q} @tab a literal @samp{\q} +@item @code{\\\\} @tab @code{\\} @tab @code{\} +@end multitable +@end ifdocbook +@ifnottex +@ifnotdocbook +@display + You type @code{sub()} sees @code{sub()} generates + -------- ---------- --------------- +@code{\\\\\\&} @code{\\\&} a literal @samp{\&} + @code{\\\\&} @code{\\&} a literal @samp{\}, followed by the matched text + @code{\\&} @code{\&} a literal @samp{&} + @code{\\q} @code{\q} a literal @samp{\q} + @code{\\\\} @code{\\} @code{\} +@end display +@end ifnotdocbook +@end ifnottex +@end float + +The only case where the difference is noticeable is the last one: @samp{\\\\} +is seen as @samp{\\} and produces @samp{\} instead of @samp{\\}. + +Starting with @value{PVERSION} 3.1.4, @command{gawk} followed the POSIX rules +when @option{--posix} is specified (@pxref{Options}). Otherwise, +it continued to follow the 1996 proposed rules, since +that had been its behavior for many years. + +When @value{PVERSION} 4.0.0, was released, the @command{gawk} maintainer +made the POSIX rules the default, breaking well over a decade's worth +of backwards compatibility.@footnote{This was rather naive of him, despite +there being a note in this section indicating that the next major version +would move to the POSIX rules.} Needless to say, this was a bad idea, +and as of @value{PVERSION} 4.0.1, @command{gawk} resumed its historical +behavior, and only follows the POSIX rules when @option{--posix} is given. + +The rules for @code{gensub()} are considerably simpler. At the runtime +level, whenever @command{gawk} sees a @samp{\}, if the following character +is a digit, then the text that matched the corresponding parenthesized +subexpression is placed in the generated output. Otherwise, +no matter what character follows the @samp{\}, it +appears in the generated text and the @samp{\} does not, +as shown in @ref{table-gensub-escapes}. + +@float Table,table-gensub-escapes +@caption{Escape Sequence Processing for @code{gensub()}} +@tex +\vbox{\bigskip +% This table has lots of &'s and \'s, so unspecialize them. +\catcode`\& = \other \catcode`\\ = \other +% But then we need character for escape and tab. +@catcode`! = 4 +@halign{@hfil#!@qquad@hfil#!@qquad#@hfil@cr + You type!@code{gensub()} sees!@code{gensub()} generates@cr +@hrulefill!@hrulefill!@hrulefill@cr + @code{&}! @code{&}!the matched text@cr + @code{\\&}! @code{\&}!a literal @samp{&}@cr + @code{\\\\}! @code{\\}!a literal @samp{\}@cr + @code{\\\\&}! @code{\\&}!a literal @samp{\}, then the matched text@cr +@code{\\\\\\&}! @code{\\\&}!a literal @samp{\&}@cr + @code{\\q}! @code{\q}!a literal @samp{q}@cr +} +@bigskip} +@end tex +@ifdocbook +@multitable @columnfractions .20 .20 .60 +@headitem You type @tab @code{gensub()} sees @tab @code{gensub()} generates +@item @code{&} @tab @code{&} @tab the matched text +@item @code{\\&} @tab @code{\&} @tab a literal @samp{&} +@item @code{\\\\} @tab @code{\\} @tab a literal @samp{\} +@item @code{\\\\&} @tab @code{\\&} @tab a literal @samp{\}, then the matched text +@item @code{\\\\\\&} @tab @code{\\\&} @tab a literal @samp{\&} +@item @code{\\q} @tab @code{\q} @tab a literal @samp{q} +@end multitable +@end ifdocbook +@ifnottex +@ifnotdocbook +@display + You type @code{gensub()} sees @code{gensub()} generates + -------- ------------- ------------------ + @code{&} @code{&} the matched text + @code{\\&} @code{\&} a literal @samp{&} + @code{\\\\} @code{\\} a literal @samp{\} + @code{\\\\&} @code{\\&} a literal @samp{\}, then the matched text +@code{\\\\\\&} @code{\\\&} a literal @samp{\&} + @code{\\q} @code{\q} a literal @samp{q} +@end display +@end ifnotdocbook +@end ifnottex +@end float + +Because of the complexity of the lexical and runtime level processing +and the special cases for @code{sub()} and @code{gsub()}, +we recommend the use of @command{gawk} and @code{gensub()} when you have +to do substitutions. + +@c fakenode --- for prepinfo +@subheading Advanced Notes: Matching the Null String +@cindex advanced features, null strings@comma{} matching +@cindex matching, null strings +@cindex null strings, matching +@cindex @code{*} (asterisk), @code{*} operator, null strings@comma{} matching +@cindex asterisk (@code{*}), @code{*} operator, null strings@comma{} matching + +In @command{awk}, the @samp{*} operator can match the null string. +This is particularly important for the @code{sub()}, @code{gsub()}, +and @code{gensub()} functions. For example: + +@example +$ @kbd{echo abc | awk '@{ gsub(/m*/, "X"); print @}'} +@print{} XaXbXcX +@end example + +@noindent +Although this makes a certain amount of sense, it can be surprising. + +@node I/O Functions +@subsection Input/Output Functions + +The following functions relate to input/output (I/O). +Optional parameters are enclosed in square brackets ([ ]): + +@table @code +@item close(@var{filename} @r{[}, @var{how}@r{]}) +@cindex @code{close()} function +@cindex files, closing +Close the file @var{filename} for input or output. Alternatively, the +argument may be a shell command that was used for creating a coprocess, or +for redirecting to or from a pipe; then the coprocess or pipe is closed. +@xref{Close Files And Pipes}, +for more information. + +When closing a coprocess, it is occasionally useful to first close +one end of the two-way pipe and then to close the other. This is done +by providing a second argument to @code{close()}. This second argument +should be one of the two string values @code{"to"} or @code{"from"}, +indicating which end of the pipe to close. Case in the string does +not matter. +@xref{Two-way I/O}, +which discusses this feature in more detail and gives an example. + +@item fflush(@r{[}@var{filename}@r{]}) +@cindex @code{fflush()} function +@cindex common extensions, @code{fflush()} function +@cindex extensions, common@comma{} @code{fflush()} function +Flush any buffered output associated with @var{filename}, which is either a +file opened for writing or a shell command for redirecting output to +a pipe or coprocess. @value{COMMONEXT}. + +@cindex portability, @code{fflush()} function and +@cindex buffers, flushing +@cindex output, buffering +Many utility programs @dfn{buffer} their output; i.e., they save information +to write to a disk file or the screen in memory until there is enough +for it to be worthwhile to send the data to the output device. +This is often more efficient than writing +every little bit of information as soon as it is ready. However, sometimes +it is necessary to force a program to @dfn{flush} its buffers; that is, +write the information to its destination, even if a buffer is not full. +This is the purpose of the @code{fflush()} function---@command{gawk} also +buffers its output and the @code{fflush()} function forces +@command{gawk} to flush its buffers. + +@code{fflush()} was added to Brian Kernighan's +version of @command{awk} in 1994; it is not part of the POSIX standard and is +not available if @option{--posix} has been specified on the +command line (@pxref{Options}). + +@cindex @command{gawk}, @code{fflush()} function in +@command{gawk} extends the @code{fflush()} function in two ways. The first +is to allow no argument at all. In this case, the buffer for the +standard output is flushed. The second is to allow the null string +(@w{@code{""}}) as the argument. In this case, the buffers for +@emph{all} open output files and pipes are flushed. +Brian Kernighan's @command{awk} also supports these extensions. + +@c @cindex automatic warnings +@c @cindex warnings, automatic +@cindex troubleshooting, @code{fflush()} function +@code{fflush()} returns zero if the buffer is successfully flushed; +otherwise, it returns @minus{}1. +In the case where all buffers are flushed, the return value is zero +only if all buffers were flushed successfully. Otherwise, it is +@minus{}1, and @command{gawk} warns about the problem @var{filename}. + +@command{gawk} also issues a warning message if you attempt to flush +a file or pipe that was opened for reading (such as with @code{getline}), +or if @var{filename} is not an open file, pipe, or coprocess. +In such a case, @code{fflush()} returns @minus{}1, as well. + +@item system(@var{command}) +@cindex @code{system()} function +@cindex interacting with other programs +Execute the operating-system +command @var{command} and then return to the @command{awk} program. +Return @var{command}'s exit status. + +For example, if the following fragment of code is put in your @command{awk} +program: + +@example +END @{ + system("date | mail -s 'awk run done' root") +@} +@end example + +@noindent +the system administrator is sent mail when the @command{awk} program +finishes processing input and begins its end-of-input processing. + +Note that redirecting @code{print} or @code{printf} into a pipe is often +enough to accomplish your task. If you need to run many commands, it +is more efficient to simply print them down a pipeline to the shell: + +@example +while (@var{more stuff to do}) + print @var{command} | "/bin/sh" +close("/bin/sh") +@end example + +@noindent +@cindex troubleshooting, @code{system()} function +@cindex @code{--sandbox} option, disabling @code{system()} function +However, if your @command{awk} +program is interactive, @code{system()} is useful for running large +self-contained programs, such as a shell or an editor. +Some operating systems cannot implement the @code{system()} function. +@code{system()} causes a fatal error if it is not supported. + +@quotation NOTE +When @option{--sandbox} is specified, the @code{system()} function is disabled +(@pxref{Options}). +@end quotation + +@end table + +@c fakenode --- for prepinfo +@subheading Advanced Notes: Interactive Versus Noninteractive Buffering +@cindex advanced features, buffering +@cindex buffering, interactive vs.@: noninteractive + +As a side point, buffering issues can be even more confusing, depending +upon whether your program is @dfn{interactive}, i.e., communicating +with a user sitting at a keyboard.@footnote{A program is interactive +if the standard output is connected to a terminal device. On modern +systems, this means your keyboard and screen.} + +@c Thanks to Walter.Mecky@dresdnerbank.de for this example, and for +@c motivating me to write this section. +Interactive programs generally @dfn{line buffer} their output; i.e., they +write out every line. Noninteractive programs wait until they have +a full buffer, which may be many lines of output. +Here is an example of the difference: + +@example +$ @kbd{awk '@{ print $1 + $2 @}'} +@kbd{1 1} +@print{} 2 +@kbd{2 3} +@print{} 5 +@kbd{@value{CTL}-d} +@end example + +@noindent +Each line of output is printed immediately. Compare that behavior +with this example: + +@example +$ @kbd{awk '@{ print $1 + $2 @}' | cat} +@kbd{1 1} +@kbd{2 3} +@kbd{@value{CTL}-d} +@print{} 2 +@print{} 5 +@end example + +@noindent +Here, no output is printed until after the @kbd{@value{CTL}-d} is typed, because +it is all buffered and sent down the pipe to @command{cat} in one shot. + +@c fakenode --- for prepinfo +@subheading Advanced Notes: Controlling Output Buffering with @code{system()} +@cindex advanced features, buffering +@cindex buffers, flushing +@cindex buffering, input/output +@cindex output, buffering + +The @code{fflush()} function provides explicit control over output buffering for +individual files and pipes. However, its use is not portable to many other +@command{awk} implementations. An alternative method to flush output +buffers is to call @code{system()} with a null string as its argument: + +@example +system("") # flush output +@end example + +@noindent +@command{gawk} treats this use of the @code{system()} function as a special +case and is smart enough not to run a shell (or other command +interpreter) with the empty command. Therefore, with @command{gawk}, this +idiom is not only useful, it is also efficient. While this method should work +with other @command{awk} implementations, it does not necessarily avoid +starting an unnecessary shell. (Other implementations may only +flush the buffer associated with the standard output and not necessarily +all buffered output.) + +If you think about what a programmer expects, it makes sense that +@code{system()} should flush any pending output. The following program: + +@example +BEGIN @{ + print "first print" + system("echo system echo") + print "second print" +@} +@end example + +@noindent +must print: + +@example +first print +system echo +second print +@end example + +@noindent +and not: + +@example +system echo +first print +second print +@end example + +If @command{awk} did not flush its buffers before calling @code{system()}, +you would see the latter (undesirable) output. + +@node Time Functions +@subsection Time Functions + +@c STARTOFRANGE tst +@cindex timestamps +@c STARTOFRANGE logftst +@cindex log files, timestamps in +@c STARTOFRANGE filogtst +@cindex files, log@comma{} timestamps in +@c STARTOFRANGE gawtst +@cindex @command{gawk}, timestamps +@cindex POSIX @command{awk}, timestamps and +@code{awk} programs are commonly used to process log files +containing timestamp information, indicating when a +particular log record was written. Many programs log their timestamp +in the form returned by the @code{time()} system call, which is the +number of seconds since a particular epoch. On POSIX-compliant systems, +it is the number of seconds since +1970-01-01 00:00:00 UTC, not counting leap seconds.@footnote{@xref{Glossary}, +especially the entries ``Epoch'' and ``UTC.''} +All known POSIX-compliant systems support timestamps from 0 through +@math{2^{31} - 1}, which is sufficient to represent times through +2038-01-19 03:14:07 UTC. Many systems support a wider range of timestamps, +including negative timestamps that represent times before the +epoch. + +@cindex @command{date} utility, GNU +@cindex time, retrieving +In order to make it easier to process such log files and to produce +useful reports, @command{gawk} provides the following functions for +working with timestamps. They are @command{gawk} extensions; they are +not specified in the POSIX standard, nor are they in any other known +version of @command{awk}.@footnote{The GNU @command{date} utility can +also do many of the things described here. Its use may be preferable +for simple time-related operations in shell scripts.} +Optional parameters are enclosed in square brackets ([ ]): + +@table @code +@item mktime(@var{datespec}) +@cindex @code{mktime()} function (@command{gawk}) +Turn @var{datespec} into a timestamp in the same form +as is returned by @code{systime()}. It is similar to the function of the +same name in ISO C. The argument, @var{datespec}, is a string of the form +@w{@code{"@var{YYYY} @var{MM} @var{DD} @var{HH} @var{MM} @var{SS} [@var{DST}]"}}. +The string consists of six or seven numbers representing, respectively, +the full year including century, the month from 1 to 12, the day of the month +from 1 to 31, the hour of the day from 0 to 23, the minute from 0 to +59, the second from 0 to 60,@footnote{Occasionally there are +minutes in a year with a leap second, which is why the +seconds can go up to 60.} +and an optional daylight-savings flag. + +The values of these numbers need not be within the ranges specified; +for example, an hour of @minus{}1 means 1 hour before midnight. +The origin-zero Gregorian calendar is assumed, with year 0 preceding +year 1 and year @minus{}1 preceding year 0. +The time is assumed to be in the local timezone. +If the daylight-savings flag is positive, the time is assumed to be +daylight savings time; if zero, the time is assumed to be standard +time; and if negative (the default), @code{mktime()} attempts to determine +whether daylight savings time is in effect for the specified time. + +If @var{datespec} does not contain enough elements or if the resulting time +is out of range, @code{mktime()} returns @minus{}1. + +@cindex @command{gawk}, @code{PROCINFO} array in +@cindex @code{PROCINFO} array +@item strftime(@r{[}@var{format} @r{[}, @var{timestamp} @r{[}, @var{utc-flag}@r{]]]}) +@c STARTOFRANGE strf +@cindex @code{strftime()} function (@command{gawk}) +Format the time specified by @var{timestamp} +based on the contents of the @var{format} string and return the result. +It is similar to the function of the same name in ISO C. +If @var{utc-flag} is present and is either nonzero or non-null, the value +is formatted as UTC (Coordinated Universal Time, formerly GMT or Greenwich +Mean Time). Otherwise, the value is formatted for the local time zone. +The @var{timestamp} is in the same format as the value returned by the +@code{systime()} function. If no @var{timestamp} argument is supplied, +@command{gawk} uses the current time of day as the timestamp. +If no @var{format} argument is supplied, @code{strftime()} uses +the value of @code{PROCINFO["strftime"]} as the format string +(@pxref{Built-in Variables}). +The default string value is +@code{@w{"%a %b %e %H:%M:%S %Z %Y"}}. This format string produces +output that is equivalent to that of the @command{date} utility. +You can assign a new value to @code{PROCINFO["strftime"]} to +change the default format. + +@item systime() +@cindex @code{systime()} function (@command{gawk}) +@cindex timestamps +Return the current time as the number of seconds since +the system epoch. On POSIX systems, this is the number of seconds +since 1970-01-01 00:00:00 UTC, not counting leap seconds. +It may be a different number on other systems. +@end table + +The @code{systime()} function allows you to compare a timestamp from a +log file with the current time of day. In particular, it is easy to +determine how long ago a particular record was logged. It also allows +you to produce log records using the ``seconds since the epoch'' format. + +@cindex converting, dates to timestamps +@cindex dates, converting to timestamps +@cindex timestamps, converting dates to +The @code{mktime()} function allows you to convert a textual representation +of a date and time into a timestamp. This makes it easy to do before/after +comparisons of dates and times, particularly when dealing with date and +time data coming from an external source, such as a log file. + +The @code{strftime()} function allows you to easily turn a timestamp +into human-readable information. It is similar in nature to the @code{sprintf()} +function +(@pxref{String Functions}), +in that it copies nonformat specification characters verbatim to the +returned string, while substituting date and time values for format +specifications in the @var{format} string. + +@cindex format specifiers, @code{strftime()} function (@command{gawk}) +@code{strftime()} is guaranteed by the 1999 ISO C +standard@footnote{Unfortunately, +not every system's @code{strftime()} necessarily +supports all of the conversions listed here.} +to support the following date format specifications: + +@table @code +@item %a +The locale's abbreviated weekday name. + +@item %A +The locale's full weekday name. + +@item %b +The locale's abbreviated month name. + +@item %B +The locale's full month name. + +@item %c +The locale's ``appropriate'' date and time representation. +(This is @samp{%A %B %d %T %Y} in the @code{"C"} locale.) + +@item %C +The century part of the current year. +This is the year divided by 100 and truncated to the next +lower integer. + +@item %d +The day of the month as a decimal number (01--31). + +@item %D +Equivalent to specifying @samp{%m/%d/%y}. + +@item %e +The day of the month, padded with a space if it is only one digit. + +@item %F +Equivalent to specifying @samp{%Y-%m-%d}. +This is the ISO 8601 date format. + +@item %g +The year modulo 100 of the ISO 8601 week number, as a decimal number (00--99). +For example, January 1, 1993 is in week 53 of 1992. Thus, the year +of its ISO 8601 week number is 1992, even though its year is 1993. +Similarly, December 31, 1973 is in week 1 of 1974. Thus, the year +of its ISO week number is 1974, even though its year is 1973. + +@item %G +The full year of the ISO week number, as a decimal number. + +@item %h +Equivalent to @samp{%b}. + +@item %H +The hour (24-hour clock) as a decimal number (00--23). + +@item %I +The hour (12-hour clock) as a decimal number (01--12). + +@item %j +The day of the year as a decimal number (001--366). + +@item %m +The month as a decimal number (01--12). + +@item %M +The minute as a decimal number (00--59). + +@item %n +A newline character (ASCII LF). + +@item %p +The locale's equivalent of the AM/PM designations associated +with a 12-hour clock. + +@item %r +The locale's 12-hour clock time. +(This is @samp{%I:%M:%S %p} in the @code{"C"} locale.) + +@item %R +Equivalent to specifying @samp{%H:%M}. + +@item %S +The second as a decimal number (00--60). + +@item %t +A TAB character. + +@item %T +Equivalent to specifying @samp{%H:%M:%S}. + +@item %u +The weekday as a decimal number (1--7). Monday is day one. + +@item %U +The week number of the year (the first Sunday as the first day of week one) +as a decimal number (00--53). + +@c @cindex ISO 8601 +@item %V +The week number of the year (the first Monday as the first +day of week one) as a decimal number (01--53). +The method for determining the week number is as specified by ISO 8601. +(To wit: if the week containing January 1 has four or more days in the +new year, then it is week one; otherwise it is week 53 of the previous year +and the next week is week one.) + +@item %w +The weekday as a decimal number (0--6). Sunday is day zero. + +@item %W +The week number of the year (the first Monday as the first day of week one) +as a decimal number (00--53). + +@item %x +The locale's ``appropriate'' date representation. +(This is @samp{%A %B %d %Y} in the @code{"C"} locale.) + +@item %X +The locale's ``appropriate'' time representation. +(This is @samp{%T} in the @code{"C"} locale.) + +@item %y +The year modulo 100 as a decimal number (00--99). + +@item %Y +The full year as a decimal number (e.g., 2011). + +@c @cindex RFC 822 +@c @cindex RFC 1036 +@item %z +The timezone offset in a +HHMM format (e.g., the format necessary to +produce RFC 822/RFC 1036 date headers). + +@item %Z +The time zone name or abbreviation; no characters if +no time zone is determinable. + +@item %Ec %EC %Ex %EX %Ey %EY %Od %Oe %OH +@itemx %OI %Om %OM %OS %Ou %OU %OV %Ow %OW %Oy +``Alternate representations'' for the specifications +that use only the second letter (@samp{%c}, @samp{%C}, +and so on).@footnote{If you don't understand any of this, don't worry about +it; these facilities are meant to make it easier to ``internationalize'' +programs. +Other internationalization features are described in +@ref{Internationalization}.} +(These facilitate compliance with the POSIX @command{date} utility.) + +@item %% +A literal @samp{%}. +@end table + +If a conversion specifier is not one of the above, the behavior is +undefined.@footnote{This is because ISO C leaves the +behavior of the C version of @code{strftime()} undefined and @command{gawk} +uses the system's version of @code{strftime()} if it's there. +Typically, the conversion specifier either does not appear in the +returned string or appears literally.} + +@c @cindex locale, definition of +Informally, a @dfn{locale} is the geographic place in which a program +is meant to run. For example, a common way to abbreviate the date +September 4, 2012 in the United States is ``9/4/12.'' +In many countries in Europe, however, it is abbreviated ``4.9.12.'' +Thus, the @samp{%x} specification in a @code{"US"} locale might produce +@samp{9/4/12}, while in a @code{"EUROPE"} locale, it might produce +@samp{4.9.12}. The ISO C standard defines a default @code{"C"} +locale, which is an environment that is typical of what many C programmers +are used to. + +For systems that are not yet fully standards-compliant, +@command{gawk} supplies a copy of +@code{strftime()} from the GNU C Library. +It supports all of the just-listed format specifications. +If that version is +used to compile @command{gawk} (@pxref{Installation}), +then the following additional format specifications are available: + +@table @code +@item %k +The hour (24-hour clock) as a decimal number (0--23). +Single-digit numbers are padded with a space. + +@item %l +The hour (12-hour clock) as a decimal number (1--12). +Single-digit numbers are padded with a space. + +@ignore +@item %N +The ``Emperor/Era'' name. +Equivalent to @code{%C}. + +@item %o +The ``Emperor/Era'' year. +Equivalent to @code{%y}. +@end ignore + +@item %s +The time as a decimal timestamp in seconds since the epoch. + +@ignore +@item %v +The date in VMS format (e.g., @samp{20-JUN-1991}). +@end ignore +@end table +@c ENDOFRANGE strf + +Additionally, the alternate representations are recognized but their +normal representations are used. + +@cindex @code{date} utility, POSIX +@cindex POSIX @command{awk}, @code{date} utility and +The following example is an @command{awk} implementation of the POSIX +@command{date} utility. Normally, the @command{date} utility prints the +current date and time of day in a well-known format. However, if you +provide an argument to it that begins with a @samp{+}, @command{date} +copies nonformat specifier characters to the standard output and +interprets the current time according to the format specifiers in +the string. For example: + +@example +$ date '+Today is %A, %B %d, %Y.' +@print{} Today is Wednesday, March 30, 2011. +@end example + +Here is the @command{gawk} version of the @command{date} utility. +It has a shell ``wrapper'' to handle the @option{-u} option, +which requires that @command{date} run as if the time zone +is set to UTC: + +@example +#! /bin/sh +# +# date --- approximate the POSIX 'date' command + +case $1 in +-u) TZ=UTC0 # use UTC + export TZ + shift ;; +esac + +gawk 'BEGIN @{ + format = "%a %b %e %H:%M:%S %Z %Y" + exitval = 0 + + if (ARGC > 2) + exitval = 1 + else if (ARGC == 2) @{ + format = ARGV[1] + if (format ~ /^\+/) + format = substr(format, 2) # remove leading + + @} + print strftime(format) + exit exitval +@}' "$@@" +@end example +@c ENDOFRANGE tst +@c ENDOFRANGE logftst +@c ENDOFRANGE filogtst +@c ENDOFRANGE gawtst + +@node Bitwise Functions +@subsection Bit-Manipulation Functions +@c STARTOFRANGE bit +@cindex bitwise, operations +@c STARTOFRANGE and +@cindex AND bitwise operation +@c STARTOFRANGE oro +@cindex OR bitwise operation +@c STARTOFRANGE xor +@cindex XOR bitwise operation +@c STARTOFRANGE opbit +@cindex operations, bitwise +@quotation +@i{I can explain it for you, but I can't understand it for you.}@* +Anonymous +@end quotation + +Many languages provide the ability to perform @dfn{bitwise} operations +on two integer numbers. In other words, the operation is performed on +each successive pair of bits in the operands. +Three common operations are bitwise AND, OR, and XOR. +The operations are described in @ref{table-bitwise-ops}. + +@float Table,table-bitwise-ops +@caption{Bitwise Operations} +@ifnottex +@ifnotdocbook +@display + Bit Operator + | AND | OR | XOR + |---+---+---+---+---+--- +Operands | 0 | 1 | 0 | 1 | 0 | 1 +----------+---+---+---+---+---+--- + 0 | 0 0 | 0 1 | 0 1 + 1 | 0 1 | 1 1 | 1 0 +@end display +@end ifnotdocbook +@end ifnottex +@tex +\centerline{ +\vbox{\bigskip % space above the table (about 1 linespace) +% Because we have vertical rules, we can't let TeX insert interline space +% in its usual way. +\offinterlineskip +\halign{\strut\hfil#\quad\hfil % operands + &\vrule#&\quad#\quad % rule, 0 (of and) + &\vrule#&\quad#\quad % rule, 1 (of and) + &\vrule# % rule between and and or + &\quad#\quad % 0 (of or) + &\vrule#&\quad#\quad % rule, 1 (of of) + &\vrule# % rule between or and xor + &\quad#\quad % 0 of xor + &\vrule#&\quad#\quad % rule, 1 of xor + \cr +&\omit&\multispan{11}\hfil\bf Bit operator\hfil\cr +\noalign{\smallskip} +& &\multispan3\hfil AND\hfil&&\multispan3\hfil OR\hfil + &&\multispan3\hfil XOR\hfil\cr +\bf Operands&&0&&1&&0&&1&&0&&1\cr +\noalign{\hrule} +\omit&height 2pt&&\omit&&&&\omit&&&&\omit\cr +\noalign{\hrule height0pt}% without this the rule does not extend; why? +0&&0&\omit&0&&0&\omit&1&&0&\omit&1\cr +1&&0&\omit&1&&1&\omit&1&&1&\omit&0\cr +}}} +@end tex + +@docbook + + +Bitwise Operations + + + + + + + + + + + + + + + + + +Bit Operator + + + + +AND +OR +XOR + + + +Operands +0 +1 +0 +1 +0 +1 + + + +0 +0 +0 +0 +1 +0 +1 + + + +1 +0 +1 +1 +1 +1 +0 + + + + +
+@end docbook +@end float + +@cindex bitwise, complement +@cindex complement, bitwise +As you can see, the result of an AND operation is 1 only when @emph{both} +bits are 1. +The result of an OR operation is 1 if @emph{either} bit is 1. +The result of an XOR operation is 1 if either bit is 1, +but not both. +The next operation is the @dfn{complement}; the complement of 1 is 0 and +the complement of 0 is 1. Thus, this operation ``flips'' all the bits +of a given value. + +@cindex bitwise, shift +@cindex left shift, bitwise +@cindex right shift, bitwise +@cindex shift, bitwise +Finally, two other common operations are to shift the bits left or right. +For example, if you have a bit string @samp{10111001} and you shift it +right by three bits, you end up with @samp{00010111}.@footnote{This example +shows that 0's come in on the left side. For @command{gawk}, this is +always true, but in some languages, it's possible to have the left side +fill with 1's. Caveat emptor.} +@c Purposely decided to use 0's and 1's here. 2/2001. +If you start over +again with @samp{10111001} and shift it left by three bits, you end up +with @samp{11001000}. +@command{gawk} provides built-in functions that implement the +bitwise operations just described. They are: + +@cindex @command{gawk}, bitwise operations in +@table @code +@cindex @code{and()} function (@command{gawk}) +@item and(@var{v1}, @var{v2}) +Return the bitwise AND of the values provided by @var{v1} and @var{v2}. + +@cindex @code{compl()} function (@command{gawk}) +@item compl(@var{val}) +Return the bitwise complement of @var{val}. + +@cindex @code{lshift()} function (@command{gawk}) +@item lshift(@var{val}, @var{count}) +Return the value of @var{val}, shifted left by @var{count} bits. + +@cindex @code{or()} function (@command{gawk}) +@item or(@var{v1}, @var{v2}) +Return the bitwise OR of the values provided by @var{v1} and @var{v2}. + +@cindex @code{rshift()} function (@command{gawk}) +@item rshift(@var{val}, @var{count}) +Return the value of @var{val}, shifted right by @var{count} bits. + +@cindex @code{xor()} function (@command{gawk}) +@item xor(@var{v1}, @var{v2}) +Return the bitwise XOR of the values provided by @var{v1} and @var{v2}. +@end table + +For all of these functions, first the double precision floating-point value is +converted to the widest C unsigned integer type, then the bitwise operation is +performed. If the result cannot be represented exactly as a C @code{double}, +leading nonzero bits are removed one by one until it can be represented +exactly. The result is then converted back into a C @code{double}. (If +you don't understand this paragraph, don't worry about it.) + +Here is a user-defined function (@pxref{User-defined}) +that illustrates the use of these functions: + +@cindex @code{bits2str()} user-defined function +@cindex @code{testbits.awk} program +@example +@group +@c file eg/lib/bits2str.awk +# bits2str --- turn a byte into readable 1's and 0's + +function bits2str(bits, data, mask) +@{ + if (bits == 0) + return "0" + + mask = 1 + for (; bits != 0; bits = rshift(bits, 1)) + data = (and(bits, mask) ? "1" : "0") data + + while ((length(data) % 8) != 0) + data = "0" data + + return data +@} +@c endfile +@end group + +@c this is a hack to make testbits.awk self-contained +@ignore +@c file eg/prog/testbits.awk +# bits2str --- turn a byte into readable 1's and 0's + +function bits2str(bits, data, mask) +@{ + if (bits == 0) + return "0" + + mask = 1 + for (; bits != 0; bits = rshift(bits, 1)) + data = (and(bits, mask) ? "1" : "0") data + + while ((length(data) % 8) != 0) + data = "0" data + + return data +@} +@c endfile +@end ignore +@c file eg/prog/testbits.awk +BEGIN @{ + printf "123 = %s\n", bits2str(123) + printf "0123 = %s\n", bits2str(0123) + printf "0x99 = %s\n", bits2str(0x99) + comp = compl(0x99) + printf "compl(0x99) = %#x = %s\n", comp, bits2str(comp) + shift = lshift(0x99, 2) + printf "lshift(0x99, 2) = %#x = %s\n", shift, bits2str(shift) + shift = rshift(0x99, 2) + printf "rshift(0x99, 2) = %#x = %s\n", shift, bits2str(shift) +@} +@c endfile +@end example + +@noindent +This program produces the following output when run: + +@example +$ @kbd{gawk -f testbits.awk} +@print{} 123 = 01111011 +@print{} 0123 = 01010011 +@print{} 0x99 = 10011001 +@print{} compl(0x99) = 0xffffff66 = 11111111111111111111111101100110 +@print{} lshift(0x99, 2) = 0x264 = 0000001001100100 +@print{} rshift(0x99, 2) = 0x26 = 00100110 +@end example + +@cindex converting, strings to numbers +@cindex strings, converting +@cindex numbers, converting +@cindex converting, numbers to strings +The @code{bits2str()} function turns a binary number into a string. +The number @code{1} represents a binary value where the rightmost bit +is set to 1. Using this mask, +the function repeatedly checks the rightmost bit. +ANDing the mask with the value indicates whether the +rightmost bit is 1 or not. If so, a @code{"1"} is concatenated onto the front +of the string. +Otherwise, a @code{"0"} is added. +The value is then shifted right by one bit and the loop continues +until there are no more 1 bits. + +If the initial value is zero it returns a simple @code{"0"}. +Otherwise, at the end, it pads the value with zeros to represent multiples +of 8-bit quantities. This is typical in modern computers. + +The main code in the @code{BEGIN} rule shows the difference between the +decimal and octal values for the same numbers +(@pxref{Nondecimal-numbers}), +and then demonstrates the +results of the @code{compl()}, @code{lshift()}, and @code{rshift()} functions. +@c ENDOFRANGE bit +@c ENDOFRANGE and +@c ENDOFRANGE oro +@c ENDOFRANGE xor +@c ENDOFRANGE opbit + +@node Type Functions +@subsection Getting Type Information + +@command{gawk} provides a single function that lets you distinguish +an array from a scalar variable. This is necessary for writing code +that traverses every element of a true multidimensional array +(@pxref{Arrays of Arrays}). + +@table @code +@cindex @code{isarray()} function (@command{gawk}) +@item isarray(@var{x}) +Return a true value if @var{x} is an array. Otherwise return false. +@end table + +@node I18N Functions +@subsection String-Translation Functions +@cindex @command{gawk}, string-translation functions +@cindex functions, string-translation +@cindex internationalization +@cindex @command{awk} programs, internationalizing + +@command{gawk} provides facilities for internationalizing @command{awk} programs. +These include the functions described in the following list. +The descriptions here are purposely brief. +@xref{Internationalization}, +for the full story. +Optional parameters are enclosed in square brackets ([ ]): + +@table @code +@cindex @code{bindtextdomain()} function (@command{gawk}) +@item bindtextdomain(@var{directory} @r{[}, @var{domain}@r{]}) +Set the directory in which +@command{gawk} will look for message translation files, in case they +will not or cannot be placed in the ``standard'' locations +(e.g., during testing). +It returns the directory in which @var{domain} is ``bound.'' + +The default @var{domain} is the value of @code{TEXTDOMAIN}. +If @var{directory} is the null string (@code{""}), then +@code{bindtextdomain()} returns the current binding for the +given @var{domain}. + +@cindex @code{dcgettext()} function (@command{gawk}) +@item dcgettext(@var{string} @r{[}, @var{domain} @r{[}, @var{category}@r{]]}) +Return the translation of @var{string} in +text domain @var{domain} for locale category @var{category}. +The default value for @var{domain} is the current value of @code{TEXTDOMAIN}. +The default value for @var{category} is @code{"LC_MESSAGES"}. + +@cindex @code{dcngettext()} function (@command{gawk}) +@item dcngettext(@var{string1}, @var{string2}, @var{number} @r{[}, @var{domain} @r{[}, @var{category}@r{]]}) +Return the plural form used for @var{number} of the +translation of @var{string1} and @var{string2} in text domain +@var{domain} for locale category @var{category}. @var{string1} is the +English singular variant of a message, and @var{string2} the English plural +variant of the same message. +The default value for @var{domain} is the current value of @code{TEXTDOMAIN}. +The default value for @var{category} is @code{"LC_MESSAGES"}. +@end table +@c ENDOFRANGE funcbi +@c ENDOFRANGE bifunc + +@node User-defined +@section User-Defined Functions + +@c STARTOFRANGE udfunc +@cindex user-defined, functions +@c STARTOFRANGE funcud +@cindex functions, user-defined +Complicated @command{awk} programs can often be simplified by defining +your own functions. User-defined functions can be called just like +built-in ones (@pxref{Function Calls}), but it is up to you to define +them, i.e., to tell @command{awk} what they should do. + +@menu +* Definition Syntax:: How to write definitions and what they mean. +* Function Example:: An example function definition and what it + does. +* Function Caveats:: Things to watch out for. +* Return Statement:: Specifying the value a function returns. +* Dynamic Typing:: How variable types can change at runtime. +@end menu + +@node Definition Syntax +@subsection Function Definition Syntax + +@c STARTOFRANGE fdef +@cindex functions, defining +Definitions of functions can appear anywhere between the rules of an +@command{awk} program. Thus, the general form of an @command{awk} program is +extended to include sequences of rules @emph{and} user-defined function +definitions. +There is no need to put the definition of a function +before all uses of the function. This is because @command{awk} reads the +entire program before starting to execute any of it. + +The definition of a function named @var{name} looks like this: + +@example +function @var{name}(@r{[}@var{parameter-list}@r{]}) +@{ + @var{body-of-function} +@} +@end example + +@cindex names, functions +@cindex functions, names of +@cindex namespace issues, functions +@noindent +Here, @var{name} is the name of the function to define. A valid function +name is like a valid variable name: a sequence of letters, digits, and +underscores that doesn't start with a digit. +Within a single @command{awk} program, any particular name can only be +used as a variable, array, or function. + +@var{parameter-list} is an optional list of the function's arguments and local +variable names, separated by commas. When the function is called, +the argument names are used to hold the argument values given in +the call. The local variables are initialized to the empty string. +A function cannot have two parameters with the same name, nor may it +have a parameter with the same name as the function itself. + +In addition, according to the POSIX standard, function parameters cannot have the same +name as one of the special built-in variables +(@pxref{Built-in Variables}. Not all versions of @command{awk} +enforce this restriction. + +The @var{body-of-function} consists of @command{awk} statements. It is the +most important part of the definition, because it says what the function +should actually @emph{do}. The argument names exist to give the body a +way to talk about the arguments; local variables exist to give the body +places to keep temporary values. + +Argument names are not distinguished syntactically from local variable +names. Instead, the number of arguments supplied when the function is +called determines how many argument variables there are. Thus, if three +argument values are given, the first three names in @var{parameter-list} +are arguments and the rest are local variables. + +It follows that if the number of arguments is not the same in all calls +to the function, some of the names in @var{parameter-list} may be +arguments on some occasions and local variables on others. Another +way to think of this is that omitted arguments default to the +null string. + +@cindex programming conventions, functions, writing +Usually when you write a function, you know how many names you intend to +use for arguments and how many you intend to use as local variables. It is +conventional to place some extra space between the arguments and +the local variables, in order to document how your function is supposed to be used. + +@cindex variables, shadowing +During execution of the function body, the arguments and local variable +values hide, or @dfn{shadow}, any variables of the same names used in the +rest of the program. The shadowed variables are not accessible in the +function definition, because there is no way to name them while their +names have been taken away for the local variables. All other variables +used in the @command{awk} program can be referenced or set normally in the +function's body. + +The arguments and local variables last only as long as the function body +is executing. Once the body finishes, you can once again access the +variables that were shadowed while the function was running. + +@cindex recursive functions +@cindex functions, recursive +The function body can contain expressions that call functions. They +can even call this function, either directly or by way of another +function. When this happens, we say the function is @dfn{recursive}. +The act of a function calling itself is called @dfn{recursion}. + +All the built-in functions return a value to their caller. +User-defined functions can do also, using the @code{return} statement, +which is described in detail in @ref{Return Statement}. +Many of the subsequent examples in this @value{SECTION} use +the @code{return} statement. + +@cindex common extensions, @code{func} keyword +@cindex extensions, common@comma{} @code{func} keyword +@c @cindex @command{awk} language, POSIX version +@c @cindex POSIX @command{awk} +@cindex POSIX @command{awk}, @code{function} keyword in +In many @command{awk} implementations, including @command{gawk}, +the keyword @code{function} may be +abbreviated @code{func}. @value{COMMONEXT} +However, POSIX only specifies the use of +the keyword @code{function}. This actually has some practical implications. +If @command{gawk} is in POSIX-compatibility mode +(@pxref{Options}), then the following +statement does @emph{not} define a function: + +@example +func foo() @{ a = sqrt($1) ; print a @} +@end example + +@noindent +Instead it defines a rule that, for each record, concatenates the value +of the variable @samp{func} with the return value of the function @samp{foo}. +If the resulting string is non-null, the action is executed. +This is probably not what is desired. (@command{awk} accepts this input as +syntactically valid, because functions may be used before they are defined +in @command{awk} programs.@footnote{This program won't actually run, +since @code{foo()} is undefined.}) + +@cindex portability, functions@comma{} defining +To ensure that your @command{awk} programs are portable, always use the +keyword @code{function} when defining a function. + +@node Function Example +@subsection Function Definition Examples + +Here is an example of a user-defined function, called @code{myprint()}, that +takes a number and prints it in a specific format: + +@example +function myprint(num) +@{ + printf "%6.3g\n", num +@} +@end example + +@noindent +To illustrate, here is an @command{awk} rule that uses our @code{myprint} +function: + +@example +$3 > 0 @{ myprint($3) @} +@end example + +@noindent +This program prints, in our special format, all the third fields that +contain a positive number in our input. Therefore, when given the following input: + +@example + 1.2 3.4 5.6 7.8 + 9.10 11.12 -13.14 15.16 +17.18 19.20 21.22 23.24 +@end example + +@noindent +this program, using our function to format the results, prints: + +@example + 5.6 + 21.2 +@end example + +This function deletes all the elements in an array: + +@example +function delarray(a, i) +@{ + for (i in a) + delete a[i] +@} +@end example + +When working with arrays, it is often necessary to delete all the elements +in an array and start over with a new list of elements +(@pxref{Delete}). +Instead of having +to repeat this loop everywhere that you need to clear out +an array, your program can just call @code{delarray}. +(This guarantees portability. The use of @samp{delete @var{array}} to delete +the contents of an entire array is a nonstandard extension.) + +The following is an example of a recursive function. It takes a string +as an input parameter and returns the string in backwards order. +Recursive functions must always have a test that stops the recursion. +In this case, the recursion terminates when the starting position +is zero, i.e., when there are no more characters left in the string. + +@cindex @code{rev()} user-defined function +@example +function rev(str, start) +@{ + if (start == 0) + return "" + + return (substr(str, start, 1) rev(str, start - 1)) +@} +@end example + +If this function is in a file named @file{rev.awk}, it can be tested +this way: + +@example +$ @kbd{echo "Don't Panic!" |} +> @kbd{gawk --source '@{ print rev($0, length($0)) @}' -f rev.awk} +@print{} !cinaP t'noD +@end example + +The C @code{ctime()} function takes a timestamp and returns it in a string, +formatted in a well-known fashion. +The following example uses the built-in @code{strftime()} function +(@pxref{Time Functions}) +to create an @command{awk} version of @code{ctime()}: + +@cindex @code{ctime()} user-defined function +@example +@c file eg/lib/ctime.awk +# ctime.awk +# +# awk version of C ctime(3) function + +function ctime(ts, format) +@{ + format = "%a %b %e %H:%M:%S %Z %Y" + if (ts == 0) + ts = systime() # use current time as default + return strftime(format, ts) +@} +@c endfile +@end example +@c ENDOFRANGE fdef + +@node Function Caveats +@subsection Calling User-Defined Functions + +@c STARTOFRANGE fudc +This section describes how to call a user-defined function. + +@menu +* Calling A Function:: Don't use spaces. +* Variable Scope:: Controlling variable scope. +* Pass By Value/Reference:: Passing parameters. +@end menu + +@node Calling A Function +@subsubsection Writing A Function Call + +@cindex functions, user-defined, calling +@dfn{Calling a function} means causing the function to run and do its job. +A function call is an expression and its value is the value returned by +the function. + +A function call consists of the function name followed by the arguments +in parentheses. @command{awk} expressions are what you write in the +call for the arguments. Each time the call is executed, these +expressions are evaluated, and the values become the actual arguments. For +example, here is a call to @code{foo()} with three arguments (the first +being a string concatenation): + +@example +foo(x y, "lose", 4 * z) +@end example + +@quotation CAUTION +Whitespace characters (spaces and TABs) are not allowed +between the function name and the open-parenthesis of the argument list. +If you write whitespace by mistake, @command{awk} might think that you mean +to concatenate a variable with an expression in parentheses. However, it +notices that you used a function name and not a variable name, and reports +an error. +@end quotation + +@node Variable Scope +@subsubsection Controlling Variable Scope + +@cindex local variables +@cindex variables, local +There is no way to make a variable local to a @code{@{ @dots{} @}} block in +@command{awk}, but you can make a variable local to a function. It is +good practice to do so whenever a variable is needed only in that +function. + +To make a variable local to a function, simply declare the variable as +an argument after the actual function arguments +(@pxref{Definition Syntax}). +Look at the following example where variable +@code{i} is a global variable used by both functions @code{foo()} and +@code{bar()}: + +@example +function bar() +@{ + for (i = 0; i < 3; i++) + print "bar's i=" i +@} + +function foo(j) +@{ + i = j + 1 + print "foo's i=" i + bar() + print "foo's i=" i +@} + +BEGIN @{ + i = 10 + print "top's i=" i + foo(0) + print "top's i=" i +@} +@end example + +Running this script produces the following, because the @code{i} in +functions @code{foo()} and @code{bar()} and at the top level refer to the same +variable instance: + +@example +top's i=10 +foo's i=1 +bar's i=0 +bar's i=1 +bar's i=2 +foo's i=3 +top's i=3 +@end example + +If you want @code{i} to be local to both @code{foo()} and @code{bar()} do as +follows (the extra-space before @code{i} is a coding convention to +indicate that @code{i} is a local variable, not an argument): + +@example +function bar( i) +@{ + for (i = 0; i < 3; i++) + print "bar's i=" i +@} + +function foo(j, i) +@{ + i = j + 1 + print "foo's i=" i + bar() + print "foo's i=" i +@} + +BEGIN @{ + i = 10 + print "top's i=" i + foo(0) + print "top's i=" i +@} +@end example + +Running the corrected script produces the following: + +@example +top's i=10 +foo's i=1 +bar's i=0 +bar's i=1 +bar's i=2 +foo's i=1 +top's i=10 +@end example + +@node Pass By Value/Reference +@subsubsection Passing Function Arguments By Value Or By Reference + +In @command{awk}, when you declare a function, there is no way to +declare explicitly whether the arguments are passed @dfn{by value} or +@dfn{by reference}. + +Instead the passing convention is determined at runtime when +the function is called according to the following rule: + +@itemize +@item +If the argument is an array variable, then it is passed by reference, +@item +Otherwise the argument is passed by value. +@end itemize + +@cindex call by value +Passing an argument by value means that when a function is called, it +is given a @emph{copy} of the value of this argument. +The caller may use a variable as the expression for the argument, but +the called function does not know this---it only knows what value the +argument had. For example, if you write the following code: + +@example +foo = "bar" +z = myfunc(foo) +@end example + +@noindent +then you should not think of the argument to @code{myfunc()} as being +``the variable @code{foo}.'' Instead, think of the argument as the +string value @code{"bar"}. +If the function @code{myfunc()} alters the values of its local variables, +this has no effect on any other variables. Thus, if @code{myfunc()} +does this: + +@example +function myfunc(str) +@{ + print str + str = "zzz" + print str +@} +@end example + +@noindent +to change its first argument variable @code{str}, it does @emph{not} +change the value of @code{foo} in the caller. The role of @code{foo} in +calling @code{myfunc()} ended when its value (@code{"bar"}) was computed. +If @code{str} also exists outside of @code{myfunc()}, the function body +cannot alter this outer value, because it is shadowed during the +execution of @code{myfunc()} and cannot be seen or changed from there. + +@cindex call by reference +@cindex arrays, as parameters to functions +@cindex functions, arrays as parameters to +However, when arrays are the parameters to functions, they are @emph{not} +copied. Instead, the array itself is made available for direct manipulation +by the function. This is usually termed @dfn{call by reference}. +Changes made to an array parameter inside the body of a function @emph{are} +visible outside that function. + +@quotation NOTE +Changing an array parameter inside a function +can be very dangerous if you do not watch what you are doing. +For example: + +@example +function changeit(array, ind, nvalue) +@{ + array[ind] = nvalue +@} + +BEGIN @{ + a[1] = 1; a[2] = 2; a[3] = 3 + changeit(a, 2, "two") + printf "a[1] = %s, a[2] = %s, a[3] = %s\n", + a[1], a[2], a[3] +@} +@end example + +@noindent +prints @samp{a[1] = 1, a[2] = two, a[3] = 3}, because +@code{changeit} stores @code{"two"} in the second element of @code{a}. +@end quotation + +@cindex undefined functions +@cindex functions, undefined +Some @command{awk} implementations allow you to call a function that +has not been defined. They only report a problem at runtime when the +program actually tries to call the function. For example: + +@example +BEGIN @{ + if (0) + foo() + else + bar() +@} +function bar() @{ @dots{} @} +# note that `foo' is not defined +@end example + +@noindent +Because the @samp{if} statement will never be true, it is not really a +problem that @code{foo()} has not been defined. Usually, though, it is a +problem if a program calls an undefined function. + +@cindex lint checking, undefined functions +If @option{--lint} is specified +(@pxref{Options}), +@command{gawk} reports calls to undefined functions. + +@cindex portability, @code{next} statement in user-defined functions +Some @command{awk} implementations generate a runtime +error if you use the @code{next} statement +(@pxref{Next Statement}) +inside a user-defined function. +@command{gawk} does not have this limitation. +@c ENDOFRANGE fudc + +@node Return Statement +@subsection The @code{return} Statement +@cindex @code{return} statement@comma{} user-defined functions + +As seen in several earlier examples, +the body of a user-defined function can contain a @code{return} statement. +This statement returns control to the calling part of the @command{awk} program. It +can also be used to return a value for use in the rest of the @command{awk} +program. It looks like this: + +@example +return @r{[}@var{expression}@r{]} +@end example + +The @var{expression} part is optional. +Due most likely to an oversight, POSIX does not define what the return +value is if you omit the @var{expression}. Technically speaking, this +make the returned value undefined, and therefore, unpredictable. +In practice, though, all versions of @command{awk} simply return the +null string, which acts like zero if used in a numeric context. + +A @code{return} statement with no value expression is assumed at the end of +every function definition. So if control reaches the end of the function +body, then technically, the function returns an unpredictable value. +In practice, it returns the empty string. @command{awk} +does @emph{not} warn you if you use the return value of such a function. + +Sometimes, you want to write a function for what it does, not for +what it returns. Such a function corresponds to a @code{void} function +in C, C++ or Java, or to a @code{procedure} in Ada. Thus, it may be appropriate to not +return any value; simply bear in mind that you should not be using the +return value of such a function. + +The following is an example of a user-defined function that returns a value +for the largest number among the elements of an array: + +@example +function maxelt(vec, i, ret) +@{ + for (i in vec) @{ + if (ret == "" || vec[i] > ret) + ret = vec[i] + @} + return ret +@} +@end example + +@cindex programming conventions, function parameters +@noindent +You call @code{maxelt()} with one argument, which is an array name. The local +variables @code{i} and @code{ret} are not intended to be arguments; +while there is nothing to stop you from passing more than one argument +to @code{maxelt()}, the results would be strange. The extra space before +@code{i} in the function parameter list indicates that @code{i} and +@code{ret} are local variables. +You should follow this convention when defining functions. + +The following program uses the @code{maxelt()} function. It loads an +array, calls @code{maxelt()}, and then reports the maximum number in that +array: + +@example +function maxelt(vec, i, ret) +@{ + for (i in vec) @{ + if (ret == "" || vec[i] > ret) + ret = vec[i] + @} + return ret +@} + +# Load all fields of each record into nums. +@{ + for(i = 1; i <= NF; i++) + nums[NR, i] = $i +@} + +END @{ + print maxelt(nums) +@} +@end example + +Given the following input: + +@example + 1 5 23 8 16 +44 3 5 2 8 26 +256 291 1396 2962 100 +-6 467 998 1101 +99385 11 0 225 +@end example + +@noindent +the program reports (predictably) that 99,385 is the largest value +in the array. + +@node Dynamic Typing +@subsection Functions and Their Effects on Variable Typing + +@command{awk} is a very fluid language. +It is possible that @command{awk} can't tell if an identifier +represents a scalar variable or an array until runtime. +Here is an annotated sample program: + +@example +function foo(a) +@{ + a[1] = 1 # parameter is an array +@} + +BEGIN @{ + b = 1 + foo(b) # invalid: fatal type mismatch + + foo(x) # x uninitialized, becomes an array dynamically + x = 1 # now not allowed, runtime error +@} +@end example + +Usually, such things aren't a big issue, but it's worth +being aware of them. +@c ENDOFRANGE udfunc + +@node Indirect Calls +@section Indirect Function Calls + +@cindex indirect function calls +@cindex function calls, indirect +@cindex function pointers +@cindex pointers to functions +@cindex differences in @command{awk} and @command{gawk}, indirect function calls + +This section describes a @command{gawk}-specific extension. + +Often, you may wish to defer the choice of function to call until runtime. +For example, you may have different kinds of records, each of which +should be processed differently. + +Normally, you would have to use a series of @code{if}-@code{else} +statements to decide which function to call. By using @dfn{indirect} +function calls, you can specify the name of the function to call as a +string variable, and then call the function. Let's look at an example. + +Suppose you have a file with your test scores for the classes you +are taking. The first field is the class name. The following fields +are the functions to call to process the data, up to a ``marker'' +field @samp{data:}. Following the marker, to the end of the record, +are the various numeric test scores. + +Here is the initial file; you wish to get the sum and the average of +your test scores: + +@example +@c file eg/data/class_data1 +Biology_101 sum average data: 87.0 92.4 78.5 94.9 +Chemistry_305 sum average data: 75.2 98.3 94.7 88.2 +English_401 sum average data: 100.0 95.6 87.1 93.4 +@c endfile +@end example + +To process the data, you might write initially: + +@example +@{ + class = $1 + for (i = 2; $i != "data:"; i++) @{ + if ($i == "sum") + sum() # processes the whole record + else if ($i == "average") + average() + @dots{} # and so on + @} +@} +@end example + +@noindent +This style of programming works, but can be awkward. With @dfn{indirect} +function calls, you tell @command{gawk} to use the @emph{value} of a +variable as the name of the function to call. + +The syntax is similar to that of a regular function call: an identifier +immediately followed by a left parenthesis, any arguments, and then +a closing right parenthesis, with the addition of a leading @samp{@@} +character: + +@example +the_func = "sum" +result = @@the_func() # calls the `sum' function +@end example + +Here is a full program that processes the previously shown data, +using indirect function calls. + +@example +@c file eg/prog/indirectcall.awk +# indirectcall.awk --- Demonstrate indirect function calls +@c endfile +@ignore +@c file eg/prog/indirectcall.awk +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# January 2009 +@c endfile +@end ignore + +@c file eg/prog/indirectcall.awk +# average --- return the average of the values in fields $first - $last + +function average(first, last, sum, i) +@{ + sum = 0; + for (i = first; i <= last; i++) + sum += $i + + return sum / (last - first + 1) +@} + +# sum --- return the sum of the values in fields $first - $last + +function sum(first, last, ret, i) +@{ + ret = 0; + for (i = first; i <= last; i++) + ret += $i + + return ret +@} +@c endfile +@end example + +These two functions expect to work on fields; thus the parameters +@code{first} and @code{last} indicate where in the fields to start and end. +Otherwise they perform the expected computations and are not unusual. + +@example +@c file eg/prog/indirectcall.awk +# For each record, print the class name and the requested statistics + +@{ + class_name = $1 + gsub(/_/, " ", class_name) # Replace _ with spaces + + # find start + for (i = 1; i <= NF; i++) @{ + if ($i == "data:") @{ + start = i + 1 + break + @} + @} + + printf("%s:\n", class_name) + for (i = 2; $i != "data:"; i++) @{ + the_function = $i + printf("\t%s: <%s>\n", $i, @@the_function(start, NF) "") + @} + print "" +@} +@c endfile +@end example + +This is the main processing for each record. It prints the class name (with +underscores replaced with spaces). It then finds the start of the actual data, +saving it in @code{start}. +The last part of the code loops through each function name (from @code{$2} up to +the marker, @samp{data:}), calling the function named by the field. The indirect +function call itself occurs as a parameter in the call to @code{printf}. +(The @code{printf} format string uses @samp{%s} as the format specifier so that we +can use functions that return strings, as well as numbers. Note that the result +from the indirect call is concatenated with the empty string, in order to force +it to be a string value.) + +Here is the result of running the program: + +@example +$ @kbd{gawk -f indirectcall.awk class_data1} +@print{} Biology 101: +@print{} sum: <352.8> +@print{} average: <88.2> +@print{} +@print{} Chemistry 305: +@print{} sum: <356.4> +@print{} average: <89.1> +@print{} +@print{} English 401: +@print{} sum: <376.1> +@print{} average: <94.025> +@end example + +The ability to use indirect function calls is more powerful than you may +think at first. The C and C++ languages provide ``function pointers,'' which +are a mechanism for calling a function chosen at runtime. One of the most +well-known uses of this ability is the C @code{qsort()} function, which sorts +an array using the famous ``quick sort'' algorithm +(see @uref{http://en.wikipedia.org/wiki/Quick_sort, the Wikipedia article} +for more information). To use this function, you supply a pointer to a comparison +function. This mechanism allows you to sort arbitrary data in an arbitrary +fashion. + +We can do something similar using @command{gawk}, like this: + +@example +@c file eg/lib/quicksort.awk +# quicksort.awk --- Quicksort algorithm, with user-supplied +# comparison function +@c endfile +@ignore +@c file eg/lib/quicksort.awk +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# January 2009 +@c endfile + +@end ignore +@c file eg/lib/quicksort.awk +# quicksort --- C.A.R. Hoare's quick sort algorithm. See Wikipedia +# or almost any algorithms or computer science text +@c endfile +@ignore +@c file eg/lib/quicksort.awk +# +# Adapted from K&R-II, page 110 +@c endfile +@end ignore +@c file eg/lib/quicksort.awk + +function quicksort(data, left, right, less_than, i, last) +@{ + if (left >= right) # do nothing if array contains fewer + return # than two elements + + quicksort_swap(data, left, int((left + right) / 2)) + last = left + for (i = left + 1; i <= right; i++) + if (@@less_than(data[i], data[left])) + quicksort_swap(data, ++last, i) + quicksort_swap(data, left, last) + quicksort(data, left, last - 1, less_than) + quicksort(data, last + 1, right, less_than) +@} + +# quicksort_swap --- helper function for quicksort, should really be inline + +function quicksort_swap(data, i, j, temp) +@{ + temp = data[i] + data[i] = data[j] + data[j] = temp +@} +@c endfile +@end example + +The @code{quicksort()} function receives the @code{data} array, the starting and ending +indices to sort (@code{left} and @code{right}), and the name of a function that +performs a ``less than'' comparison. It then implements the quick sort algorithm. + +To make use of the sorting function, we return to our previous example. The +first thing to do is write some comparison functions: + +@example +@c file eg/prog/indirectcall.awk +# num_lt --- do a numeric less than comparison + +function num_lt(left, right) +@{ + return ((left + 0) < (right + 0)) +@} + +# num_ge --- do a numeric greater than or equal to comparison + +function num_ge(left, right) +@{ + return ((left + 0) >= (right + 0)) +@} +@c endfile +@end example + +The @code{num_ge()} function is needed to perform a descending sort; when used +to perform a ``less than'' test, it actually does the opposite (greater than +or equal to), which yields data sorted in descending order. + +Next comes a sorting function. It is parameterized with the starting and +ending field numbers and the comparison function. It builds an array with +the data and calls @code{quicksort} appropriately, and then formats the +results as a single string: + +@example +@c file eg/prog/indirectcall.awk +# do_sort --- sort the data according to `compare' +# and return it as a string + +function do_sort(first, last, compare, data, i, retval) +@{ + delete data + for (i = 1; first <= last; first++) @{ + data[i] = $first + i++ + @} + + quicksort(data, 1, i-1, compare) + + retval = data[1] + for (i = 2; i in data; i++) + retval = retval " " data[i] + + return retval +@} +@c endfile +@end example + +Finally, the two sorting functions call @code{do_sort()}, passing in the +names of the two comparison functions: + +@example +@c file eg/prog/indirectcall.awk +# sort --- sort the data in ascending order and return it as a string + +function sort(first, last) +@{ + return do_sort(first, last, "num_lt") +@} + +# rsort --- sort the data in descending order and return it as a string + +function rsort(first, last) +@{ + return do_sort(first, last, "num_ge") +@} +@c endfile +@end example + +Here is an extended version of the data file: + +@example +@c file eg/data/class_data2 +Biology_101 sum average sort rsort data: 87.0 92.4 78.5 94.9 +Chemistry_305 sum average sort rsort data: 75.2 98.3 94.7 88.2 +English_401 sum average sort rsort data: 100.0 95.6 87.1 93.4 +@c endfile +@end example + +Finally, here are the results when the enhanced program is run: + +@example +$ @kbd{gawk -f quicksort.awk -f indirectcall.awk class_data2} +@print{} Biology 101: +@print{} sum: <352.8> +@print{} average: <88.2> +@print{} sort: <78.5 87.0 92.4 94.9> +@print{} rsort: <94.9 92.4 87.0 78.5> +@print{} +@print{} Chemistry 305: +@print{} sum: <356.4> +@print{} average: <89.1> +@print{} sort: <75.2 88.2 94.7 98.3> +@print{} rsort: <98.3 94.7 88.2 75.2> +@print{} +@print{} English 401: +@print{} sum: <376.1> +@print{} average: <94.025> +@print{} sort: <87.1 93.4 95.6 100.0> +@print{} rsort: <100.0 95.6 93.4 87.1> +@end example + +Remember that you must supply a leading @samp{@@} in front of an indirect function call. + +Unfortunately, indirect function calls cannot be used with the built-in functions. However, +you can generally write ``wrapper'' functions which call the built-in ones, and those can +be called indirectly. (Other than, perhaps, the mathematical functions, there is not a lot +of reason to try to call the built-in functions indirectly.) + +@command{gawk} does its best to make indirect function calls efficient. +For example, in the following case: + +@example +for (i = 1; i <= n; i++) + @@the_func() +@end example + +@noindent +@code{gawk} will look up the actual function to call only once. + +@c ENDOFRANGE funcud + +@node Internationalization +@chapter Internationalization with @command{gawk} + +Once upon a time, computer makers +wrote software that worked only in English. +Eventually, hardware and software vendors noticed that if their +systems worked in the native languages of non-English-speaking +countries, they were able to sell more systems. +As a result, internationalization and localization +of programs and software systems became a common practice. + +@c STARTOFRANGE inloc +@cindex internationalization, localization +@cindex @command{gawk}, internationalization and, See internationalization +@cindex internationalization, localization, @command{gawk} and +For many years, the ability to provide internationalization +was largely restricted to programs written in C and C++. +This @value{CHAPTER} describes the underlying library @command{gawk} +uses for internationalization, as well as how +@command{gawk} makes internationalization +features available at the @command{awk} program level. +Having internationalization available at the @command{awk} level +gives software developers additional flexibility---they are no +longer forced to write in C or C++ when internationalization is +a requirement. + +@menu +* I18N and L10N:: Internationalization and Localization. +* Explaining gettext:: How GNU @code{gettext} works. +* Programmer i18n:: Features for the programmer. +* Translator i18n:: Features for the translator. +* I18N Example:: A simple i18n example. +* Gawk I18N:: @command{gawk} is also internationalized. +@end menu + +@node I18N and L10N +@section Internationalization and Localization + +@cindex internationalization +@cindex localization, See internationalization@comma{} localization +@cindex localization +@dfn{Internationalization} means writing (or modifying) a program once, +in such a way that it can use multiple languages without requiring +further source-code changes. +@dfn{Localization} means providing the data necessary for an +internationalized program to work in a particular language. +Most typically, these terms refer to features such as the language +used for printing error messages, the language used to read +responses, and information related to how numerical and +monetary values are printed and read. + +@node Explaining gettext +@section GNU @code{gettext} + +@cindex internationalizing a program +@c STARTOFRANGE gettex +@cindex @code{gettext} library +The facilities in GNU @code{gettext} focus on messages; strings printed +by a program, either directly or via formatting with @code{printf} or +@code{sprintf()}.@footnote{For some operating systems, the @command{gawk} +port doesn't support GNU @code{gettext}. +Therefore, these features are not available +if you are using one of those operating systems. Sorry.} + +@cindex portability, @code{gettext} library and +When using GNU @code{gettext}, each application has its own +@dfn{text domain}. This is a unique name, such as @samp{kpilot} or @samp{gawk}, +that identifies the application. +A complete application may have multiple components---programs written +in C or C++, as well as scripts written in @command{sh} or @command{awk}. +All of the components use the same text domain. + +To make the discussion concrete, assume we're writing an application +named @command{guide}. Internationalization consists of the +following steps, in this order: + +@enumerate +@item +The programmer goes +through the source for all of @command{guide}'s components +and marks each string that is a candidate for translation. +For example, @code{"`-F': option required"} is a good candidate for translation. +A table with strings of option names is not (e.g., @command{gawk}'s +@option{--profile} option should remain the same, no matter what the local +language). + +@cindex @code{textdomain()} function (C library) +@item +The programmer indicates the application's text domain +(@code{"guide"}) to the @code{gettext} library, +by calling the @code{textdomain()} function. + +@cindex @code{.pot} files +@cindex files, @code{.pot} +@cindex portable object template files +@cindex files, portable object template +@item +Messages from the application are extracted from the source code and +collected into a portable object template file (@file{guide.pot}), +which lists the strings and their translations. +The translations are initially empty. +The original (usually English) messages serve as the key for +lookup of the translations. + +@cindex @code{.po} files +@cindex files, @code{.po} +@cindex portable object files +@cindex files, portable object +@item +For each language with a translator, @file{guide.pot} +is copied to a portable object file (@code{.po}) +and translations are created and shipped with the application. +For example, there might be a @file{fr.po} for a French translation. + +@cindex @code{.mo} files +@cindex files, @code{.mo} +@cindex message object files +@cindex files, message object +@item +Each language's @file{.po} file is converted into a binary +message object (@file{.mo}) file. +A message object file contains the original messages and their +translations in a binary format that allows fast lookup of translations +at runtime. + +@item +When @command{guide} is built and installed, the binary translation files +are installed in a standard place. + +@cindex @code{bindtextdomain()} function (C library) +@item +For testing and development, it is possible to tell @code{gettext} +to use @file{.mo} files in a different directory than the standard +one by using the @code{bindtextdomain()} function. + +@cindex @code{.mo} files, specifying directory of +@cindex files, @code{.mo}, specifying directory of +@cindex message object files, specifying directory of +@cindex files, message object, specifying directory of +@item +At runtime, @command{guide} looks up each string via a call +to @code{gettext()}. The returned string is the translated string +if available, or the original string if not. + +@item +If necessary, it is possible to access messages from a different +text domain than the one belonging to the application, without +having to switch the application's default text domain back +and forth. +@end enumerate + +@cindex @code{gettext()} function (C library) +In C (or C++), the string marking and dynamic translation lookup +are accomplished by wrapping each string in a call to @code{gettext()}: + +@example +printf("%s", gettext("Don't Panic!\n")); +@end example + +The tools that extract messages from source code pull out all +strings enclosed in calls to @code{gettext()}. + +@cindex @code{_} (underscore), @code{_} C macro +@cindex underscore (@code{_}), @code{_} C macro +The GNU @code{gettext} developers, recognizing that typing +@samp{gettext(@dots{})} over and over again is both painful and ugly to look +at, use the macro @samp{_} (an underscore) to make things easier: + +@example +/* In the standard header file: */ +#define _(str) gettext(str) + +/* In the program text: */ +printf("%s", _("Don't Panic!\n")); +@end example + +@cindex internationalization, localization, locale categories +@cindex @code{gettext} library, locale categories +@cindex locale categories +@noindent +This reduces the typing overhead to just three extra characters per string +and is considerably easier to read as well. + +There are locale @dfn{categories} +for different types of locale-related information. +The defined locale categories that @code{gettext} knows about are: + +@table @code +@cindex @code{LC_MESSAGES} locale category +@item LC_MESSAGES +Text messages. This is the default category for @code{gettext} +operations, but it is possible to supply a different one explicitly, +if necessary. (It is almost never necessary to supply a different category.) + +@cindex sorting characters in different languages +@cindex @code{LC_COLLATE} locale category +@item LC_COLLATE +Text-collation information; i.e., how different characters +and/or groups of characters sort in a given language. + +@cindex @code{LC_CTYPE} locale category +@item LC_CTYPE +Character-type information (alphabetic, digit, upper- or lowercase, and +so on). +This information is accessed via the +POSIX character classes in regular expressions, +such as @code{/[[:alnum:]]/} +(@pxref{Regexp Operators}). + +@cindex monetary information, localization +@cindex currency symbols, localization +@cindex @code{LC_MONETARY} locale category +@item LC_MONETARY +Monetary information, such as the currency symbol, and whether the +symbol goes before or after a number. + +@cindex @code{LC_NUMERIC} locale category +@item LC_NUMERIC +Numeric information, such as which characters to use for the decimal +point and the thousands separator.@footnote{Americans +use a comma every three decimal places and a period for the decimal +point, while many Europeans do exactly the opposite: +1,234.56 versus 1.234,56.} + +@cindex @code{LC_RESPONSE} locale category +@item LC_RESPONSE +Response information, such as how ``yes'' and ``no'' appear in the +local language, and possibly other information as well. + +@cindex time, localization and +@cindex dates, information related to@comma{} localization +@cindex @code{LC_TIME} locale category +@item LC_TIME +Time- and date-related information, such as 12- or 24-hour clock, month printed +before or after the day in a date, local month abbreviations, and so on. + +@cindex @code{LC_ALL} locale category +@item LC_ALL +All of the above. (Not too useful in the context of @code{gettext}.) +@end table +@c ENDOFRANGE gettex + +@node Programmer i18n +@section Internationalizing @command{awk} Programs +@c STARTOFRANGE inap +@cindex @command{awk} programs, internationalizing + +@command{gawk} provides the following variables and functions for +internationalization: + +@table @code +@cindex @code{TEXTDOMAIN} variable +@item TEXTDOMAIN +This variable indicates the application's text domain. +For compatibility with GNU @code{gettext}, the default +value is @code{"messages"}. + +@cindex internationalization, localization, marked strings +@cindex strings, for localization +@item _"your message here" +String constants marked with a leading underscore +are candidates for translation at runtime. +String constants without a leading underscore are not translated. + +@cindex @code{dcgettext()} function (@command{gawk}) +@item dcgettext(@var{string} @r{[}, @var{domain} @r{[}, @var{category}@r{]]}) +Return the translation of @var{string} in +text domain @var{domain} for locale category @var{category}. +The default value for @var{domain} is the current value of @code{TEXTDOMAIN}. +The default value for @var{category} is @code{"LC_MESSAGES"}. + +If you supply a value for @var{category}, it must be a string equal to +one of the known locale categories described in +@ifnotinfo +the previous @value{SECTION}. +@end ifnotinfo +@ifinfo +@ref{Explaining gettext}. +@end ifinfo +You must also supply a text domain. Use @code{TEXTDOMAIN} if +you want to use the current domain. + +@quotation CAUTION +The order of arguments to the @command{awk} version +of the @code{dcgettext()} function is purposely different from the order for +the C version. The @command{awk} version's order was +chosen to be simple and to allow for reasonable @command{awk}-style +default arguments. +@end quotation + +@cindex @code{dcngettext()} function (@command{gawk}) +@item dcngettext(@var{string1}, @var{string2}, @var{number} @r{[}, @var{domain} @r{[}, @var{category}@r{]]}) +Return the plural form used for @var{number} of the +translation of @var{string1} and @var{string2} in text domain +@var{domain} for locale category @var{category}. @var{string1} is the +English singular variant of a message, and @var{string2} the English plural +variant of the same message. +The default value for @var{domain} is the current value of @code{TEXTDOMAIN}. +The default value for @var{category} is @code{"LC_MESSAGES"}. + +The same remarks about argument order as for the @code{dcgettext()} function apply. + +@cindex @code{.mo} files, specifying directory of +@cindex files, @code{.mo}, specifying directory of +@cindex message object files, specifying directory of +@cindex files, message object, specifying directory of +@cindex @code{bindtextdomain()} function (@command{gawk}) +@item bindtextdomain(@var{directory} @r{[}, @var{domain}@r{]}) +Change the directory in which +@code{gettext} looks for @file{.mo} files, in case they +will not or cannot be placed in the standard locations +(e.g., during testing). +Return the directory in which @var{domain} is ``bound.'' + +The default @var{domain} is the value of @code{TEXTDOMAIN}. +If @var{directory} is the null string (@code{""}), then +@code{bindtextdomain()} returns the current binding for the +given @var{domain}. +@end table + +To use these facilities in your @command{awk} program, follow the steps +outlined in +@ifnotinfo +the previous @value{SECTION}, +@end ifnotinfo +@ifinfo +@ref{Explaining gettext}, +@end ifinfo +like so: + +@enumerate +@cindex @code{BEGIN} pattern, @code{TEXTDOMAIN} variable and +@cindex @code{TEXTDOMAIN} variable, @code{BEGIN} pattern and +@item +Set the variable @code{TEXTDOMAIN} to the text domain of +your program. This is best done in a @code{BEGIN} rule +(@pxref{BEGIN/END}), +or it can also be done via the @option{-v} command-line +option (@pxref{Options}): + +@example +BEGIN @{ + TEXTDOMAIN = "guide" + @dots{} +@} +@end example + +@cindex @code{_} (underscore), translatable string +@cindex underscore (@code{_}), translatable string +@item +Mark all translatable strings with a leading underscore (@samp{_}) +character. It @emph{must} be adjacent to the opening +quote of the string. For example: + +@example +print _"hello, world" +x = _"you goofed" +printf(_"Number of users is %d\n", nusers) +@end example + +@item +If you are creating strings dynamically, you can +still translate them, using the @code{dcgettext()} +built-in function: + +@example +message = nusers " users logged in" +message = dcgettext(message, "adminprog") +print message +@end example + +Here, the call to @code{dcgettext()} supplies a different +text domain (@code{"adminprog"}) in which to find the +message, but it uses the default @code{"LC_MESSAGES"} category. + +@cindex @code{LC_MESSAGES} locale category, @code{bindtextdomain()} function (@command{gawk}) +@item +During development, you might want to put the @file{.mo} +file in a private directory for testing. This is done +with the @code{bindtextdomain()} built-in function: + +@example +BEGIN @{ + TEXTDOMAIN = "guide" # our text domain + if (Testing) @{ + # where to find our files + bindtextdomain("testdir") + # joe is in charge of adminprog + bindtextdomain("../joe/testdir", "adminprog") + @} + @dots{} +@} +@end example + +@end enumerate + +@xref{I18N Example}, +for an example program showing the steps to create +and use translations from @command{awk}. + +@node Translator i18n +@section Translating @command{awk} Programs + +@cindex @code{.po} files +@cindex files, @code{.po} +@cindex portable object files +@cindex files, portable object +Once a program's translatable strings have been marked, they must +be extracted to create the initial @file{.po} file. +As part of translation, it is often helpful to rearrange the order +in which arguments to @code{printf} are output. + +@command{gawk}'s @option{--gen-pot} command-line option extracts +the messages and is discussed next. +After that, @code{printf}'s ability to +rearrange the order for @code{printf} arguments at runtime +is covered. + +@menu +* String Extraction:: Extracting marked strings. +* Printf Ordering:: Rearranging @code{printf} arguments. +* I18N Portability:: @command{awk}-level portability issues. +@end menu + +@node String Extraction +@subsection Extracting Marked Strings +@cindex strings, extracting +@cindex marked strings@comma{} extracting +@cindex @code{--gen-pot} option +@cindex command-line options, string extraction +@cindex string extraction (internationalization) +@cindex marked string extraction (internationalization) +@cindex extraction, of marked strings (internationalization) + +@cindex @code{--gen-pot} option +Once your @command{awk} program is working, and all the strings have +been marked and you've set (and perhaps bound) the text domain, +it is time to produce translations. +First, use the @option{--gen-pot} command-line option to create +the initial @file{.pot} file: + +@example +$ @kbd{gawk --gen-pot -f guide.awk > guide.pot} +@end example + +@cindex @code{xgettext} utility +When run with @option{--gen-pot}, @command{gawk} does not execute your +program. Instead, it parses it as usual and prints all marked strings +to standard output in the format of a GNU @code{gettext} Portable Object +file. Also included in the output are any constant strings that +appear as the first argument to @code{dcgettext()} or as the first and +second argument to @code{dcngettext()}.@footnote{The +@command{xgettext} utility that comes with GNU +@code{gettext} can handle @file{.awk} files.} +@xref{I18N Example}, +for the full list of steps to go through to create and test +translations for @command{guide}. + +@node Printf Ordering +@subsection Rearranging @code{printf} Arguments + +@cindex @code{printf} statement, positional specifiers +@cindex positional specifiers, @code{printf} statement +Format strings for @code{printf} and @code{sprintf()} +(@pxref{Printf}) +present a special problem for translation. +Consider the following:@footnote{This example is borrowed +from the GNU @code{gettext} manual.} + +@c line broken here only for smallbook format +@example +printf(_"String `%s' has %d characters\n", + string, length(string))) +@end example + +A possible German translation for this might be: + +@example +"%d Zeichen lang ist die Zeichenkette `%s'\n" +@end example + +The problem should be obvious: the order of the format +specifications is different from the original! +Even though @code{gettext()} can return the translated string +at runtime, +it cannot change the argument order in the call to @code{printf}. + +To solve this problem, @code{printf} format specifiers may have +an additional optional element, which we call a @dfn{positional specifier}. +For example: + +@example +"%2$d Zeichen lang ist die Zeichenkette `%1$s'\n" +@end example + +Here, the positional specifier consists of an integer count, which indicates which +argument to use, and a @samp{$}. Counts are one-based, and the +format string itself is @emph{not} included. Thus, in the following +example, @samp{string} is the first argument and @samp{length(string)} is the second: + +@example +$ @kbd{gawk 'BEGIN @{} +> @kbd{string = "Dont Panic"} +> @kbd{printf _"%2$d characters live in \"%1$s\"\n",} +> @kbd{string, length(string)} +> @kbd{@}'} +@print{} 10 characters live in "Dont Panic" +@end example + +If present, positional specifiers come first in the format specification, +before the flags, the field width, and/or the precision. + +Positional specifiers can be used with the dynamic field width and +precision capability: + +@example +$ @kbd{gawk 'BEGIN @{} +> @kbd{printf("%*.*s\n", 10, 20, "hello")} +> @kbd{printf("%3$*2$.*1$s\n", 20, 10, "hello")} +> @kbd{@}'} +@print{} hello +@print{} hello +@end example + +@quotation NOTE +When using @samp{*} with a positional specifier, the @samp{*} +comes first, then the integer position, and then the @samp{$}. +This is somewhat counterintuitive. +@end quotation + +@cindex @code{printf} statement, positional specifiers, mixing with regular formats +@cindex positional specifiers, @code{printf} statement, mixing with regular formats +@cindex format specifiers, mixing regular with positional specifiers +@command{gawk} does not allow you to mix regular format specifiers +and those with positional specifiers in the same string: + +@example +$ @kbd{gawk 'BEGIN @{ printf _"%d %3$s\n", 1, 2, "hi" @}'} +@error{} gawk: cmd. line:1: fatal: must use `count$' on all formats or none +@end example + +@quotation NOTE +There are some pathological cases that @command{gawk} may fail to +diagnose. In such cases, the output may not be what you expect. +It's still a bad idea to try mixing them, even if @command{gawk} +doesn't detect it. +@end quotation + +Although positional specifiers can be used directly in @command{awk} programs, +their primary purpose is to help in producing correct translations of +format strings into languages different from the one in which the program +is first written. + +@node I18N Portability +@subsection @command{awk} Portability Issues + +@cindex portability, internationalization and +@cindex internationalization, localization, portability and +@command{gawk}'s internationalization features were purposely chosen to +have as little impact as possible on the portability of @command{awk} +programs that use them to other versions of @command{awk}. +Consider this program: + +@example +BEGIN @{ + TEXTDOMAIN = "guide" + if (Test_Guide) # set with -v + bindtextdomain("/test/guide/messages") + print _"don't panic!" +@} +@end example + +@noindent +As written, it won't work on other versions of @command{awk}. +However, it is actually almost portable, requiring very little +change: + +@itemize @bullet +@cindex @code{TEXTDOMAIN} variable, portability and +@item +Assignments to @code{TEXTDOMAIN} won't have any effect, +since @code{TEXTDOMAIN} is not special in other @command{awk} implementations. + +@item +Non-GNU versions of @command{awk} treat marked strings +as the concatenation of a variable named @code{_} with the string +following it.@footnote{This is good fodder for an ``Obfuscated +@command{awk}'' contest.} Typically, the variable @code{_} has +the null string (@code{""}) as its value, leaving the original string constant as +the result. + +@item +By defining ``dummy'' functions to replace @code{dcgettext()}, @code{dcngettext()} +and @code{bindtextdomain()}, the @command{awk} program can be made to run, but +all the messages are output in the original language. +For example: + +@cindex @code{bindtextdomain()} function (@command{gawk}), portability and +@cindex @code{dcgettext()} function (@command{gawk}), portability and +@cindex @code{dcngettext()} function (@command{gawk}), portability and +@example +@c file eg/lib/libintl.awk +function bindtextdomain(dir, domain) +@{ + return dir +@} + +function dcgettext(string, domain, category) +@{ + return string +@} + +function dcngettext(string1, string2, number, domain, category) +@{ + return (number == 1 ? string1 : string2) +@} +@c endfile +@end example + +@item +The use of positional specifications in @code{printf} or +@code{sprintf()} is @emph{not} portable. +To support @code{gettext()} at the C level, many systems' C versions of +@code{sprintf()} do support positional specifiers. But it works only if +enough arguments are supplied in the function call. Many versions of +@command{awk} pass @code{printf} formats and arguments unchanged to the +underlying C library version of @code{sprintf()}, but only one format and +argument at a time. What happens if a positional specification is +used is anybody's guess. +However, since the positional specifications are primarily for use in +@emph{translated} format strings, and since non-GNU @command{awk}s never +retrieve the translated string, this should not be a problem in practice. +@end itemize +@c ENDOFRANGE inap + +@node I18N Example +@section A Simple Internationalization Example + +Now let's look at a step-by-step example of how to internationalize and +localize a simple @command{awk} program, using @file{guide.awk} as our +original source: + +@example +@c file eg/prog/guide.awk +BEGIN @{ + TEXTDOMAIN = "guide" + bindtextdomain(".") # for testing + print _"Don't Panic" + print _"The Answer Is", 42 + print "Pardon me, Zaphod who?" +@} +@c endfile +@end example + +@noindent +Run @samp{gawk --gen-pot} to create the @file{.pot} file: + +@example +$ @kbd{gawk --gen-pot -f guide.awk > guide.pot} +@end example + +@noindent +This produces: + +@example +@c file eg/data/guide.po +#: guide.awk:4 +msgid "Don't Panic" +msgstr "" + +#: guide.awk:5 +msgid "The Answer Is" +msgstr "" + +@c endfile +@end example + +This original portable object template file is saved and reused for each language +into which the application is translated. The @code{msgid} +is the original string and the @code{msgstr} is the translation. + +@quotation NOTE +Strings not marked with a leading underscore do not +appear in the @file{guide.pot} file. +@end quotation + +Next, the messages must be translated. +Here is a translation to a hypothetical dialect of English, +called ``Mellow'':@footnote{Perhaps it would be better if it were +called ``Hippy.'' Ah, well.} + +@example +@group +$ cp guide.pot guide-mellow.po +@var{Add translations to} guide-mellow.po @dots{} +@end group +@end example + +@noindent +Following are the translations: + +@example +@c file eg/data/guide-mellow.po +#: guide.awk:4 +msgid "Don't Panic" +msgstr "Hey man, relax!" + +#: guide.awk:5 +msgid "The Answer Is" +msgstr "Like, the scoop is" + +@c endfile +@end example + +@cindex Linux +@cindex GNU/Linux +The next step is to make the directory to hold the binary message object +file and then to create the @file{guide.mo} file. +The directory layout shown here is standard for GNU @code{gettext} on +GNU/Linux systems. Other versions of @code{gettext} may use a different +layout: + +@example +$ @kbd{mkdir en_US en_US/LC_MESSAGES} +@end example + +@cindex @code{.po} files, converting to @code{.mo} +@cindex files, @code{.po}, converting to @code{.mo} +@cindex @code{.mo} files, converting from @code{.po} +@cindex files, @code{.mo}, converting from @code{.po} +@cindex portable object files, converting to message object files +@cindex files, portable object, converting to message object files +@cindex message object files, converting from portable object files +@cindex files, message object, converting from portable object files +@cindex @command{msgfmt} utility +The @command{msgfmt} utility does the conversion from human-readable +@file{.po} file to machine-readable @file{.mo} file. +By default, @command{msgfmt} creates a file named @file{messages}. +This file must be renamed and placed in the proper directory so that +@command{gawk} can find it: + +@example +$ @kbd{msgfmt guide-mellow.po} +$ @kbd{mv messages en_US/LC_MESSAGES/guide.mo} +@end example + +Finally, we run the program to test it: + +@example +$ @kbd{gawk -f guide.awk} +@print{} Hey man, relax! +@print{} Like, the scoop is 42 +@print{} Pardon me, Zaphod who? +@end example + +If the three replacement functions for @code{dcgettext()}, @code{dcngettext()} +and @code{bindtextdomain()} +(@pxref{I18N Portability}) +are in a file named @file{libintl.awk}, +then we can run @file{guide.awk} unchanged as follows: + +@example +$ @kbd{gawk --posix -f guide.awk -f libintl.awk} +@print{} Don't Panic +@print{} The Answer Is 42 +@print{} Pardon me, Zaphod who? +@end example + +@node Gawk I18N +@section @command{gawk} Can Speak Your Language + +@command{gawk} itself has been internationalized +using the GNU @code{gettext} package. +(GNU @code{gettext} is described in +complete detail in +@ifinfo +@inforef{Top, , GNU @code{gettext} utilities, gettext, GNU gettext tools}.) +@end ifinfo +@ifnotinfo +@cite{GNU gettext tools}.) +@end ifnotinfo +As of this writing, the latest version of GNU @code{gettext} is +@uref{ftp://ftp.gnu.org/gnu/gettext/gettext-0.18.1.tar.gz, @value{PVERSION} 0.18.1}. + +If a translation of @command{gawk}'s messages exists, +then @command{gawk} produces usage messages, warnings, +and fatal errors in the local language. +@c ENDOFRANGE inloc + +@node Advanced Features +@chapter Advanced Features of @command{gawk} +@cindex advanced features, network connections, See Also networks, connections +@c STARTOFRANGE gawadv +@cindex @command{gawk}, features, advanced +@c STARTOFRANGE advgaw +@cindex advanced features, @command{gawk} +@ignore +Contributed by: Peter Langston + + Found in Steve English's "signature" line: + +"Write documentation as if whoever reads it is a violent psychopath +who knows where you live." +@end ignore +@quotation +@i{Write documentation as if whoever reads it is +a violent psychopath who knows where you live.}@* +Steve English, as quoted by Peter Langston +@end quotation + +This @value{CHAPTER} discusses advanced features in @command{gawk}. +It's a bit of a ``grab bag'' of items that are otherwise unrelated +to each other. +First, a command-line option allows @command{gawk} to recognize +nondecimal numbers in input data, not just in @command{awk} +programs. +Then, @command{gawk}'s special features for sorting arrays are presented. +Next, two-way I/O, discussed briefly in earlier parts of this +@value{DOCUMENT}, is described in full detail, along with the basics +of TCP/IP networking. Finally, @command{gawk} +can @dfn{profile} an @command{awk} program, making it possible to tune +it for performance. + +@ref{Dynamic Extensions}, +discusses the ability to dynamically add new built-in functions to +@command{gawk}. As this feature is still immature and likely to change, +its description is relegated to an appendix. + +@menu +* Nondecimal Data:: Allowing nondecimal input data. +* Array Sorting:: Facilities for controlling array traversal and + sorting arrays. +* Two-way I/O:: Two-way communications with another process. +* TCP/IP Networking:: Using @command{gawk} for network programming. +* Profiling:: Profiling your @command{awk} programs. +@end menu + +@node Nondecimal Data +@section Allowing Nondecimal Input Data +@cindex @code{--non-decimal-data} option +@cindex advanced features, @command{gawk}, nondecimal input data +@cindex input, data@comma{} nondecimal +@cindex constants, nondecimal + +If you run @command{gawk} with the @option{--non-decimal-data} option, +you can have nondecimal constants in your input data: + +@c line break here for small book format +@example +$ @kbd{echo 0123 123 0x123 |} +> @kbd{gawk --non-decimal-data '@{ printf "%d, %d, %d\n",} +> @kbd{$1, $2, $3 @}'} +@print{} 83, 123, 291 +@end example + +For this feature to work, write your program so that +@command{gawk} treats your data as numeric: + +@example +$ @kbd{echo 0123 123 0x123 | gawk '@{ print $1, $2, $3 @}'} +@print{} 0123 123 0x123 +@end example + +@noindent +The @code{print} statement treats its expressions as strings. +Although the fields can act as numbers when necessary, +they are still strings, so @code{print} does not try to treat them +numerically. You may need to add zero to a field to force it to +be treated as a number. For example: + +@example +$ @kbd{echo 0123 123 0x123 | gawk --non-decimal-data '} +> @kbd{@{ print $1, $2, $3} +> @kbd{print $1 + 0, $2 + 0, $3 + 0 @}'} +@print{} 0123 123 0x123 +@print{} 83 123 291 +@end example + +Because it is common to have decimal data with leading zeros, and because +using this facility could lead to surprising results, the default is to leave it +disabled. If you want it, you must explicitly request it. + +@cindex programming conventions, @code{--non-decimal-data} option +@cindex @code{--non-decimal-data} option, @code{strtonum()} function and +@cindex @code{strtonum()} function (@command{gawk}), @code{--non-decimal-data} option and +@quotation CAUTION +@emph{Use of this option is not recommended.} +It can break old programs very badly. +Instead, use the @code{strtonum()} function to convert your data +(@pxref{Nondecimal-numbers}). +This makes your programs easier to write and easier to read, and +leads to less surprising results. +@end quotation + +@node Array Sorting +@section Controlling Array Traversal and Array Sorting + +@command{gawk} lets you control the order in which a @samp{for (i in array)} +loop traverses an array. + +In addition, two built-in functions, @code{asort()} and @code{asorti()}, +let you sort arrays based on the array values and indices, respectively. +These two functions also provide control over the sorting criteria used +to order the elements during sorting. + +@menu +* Controlling Array Traversal:: How to use PROCINFO["sorted_in"]. +* Array Sorting Functions:: How to use @code{asort()} and @code{asorti()}. +@end menu + +@node Controlling Array Traversal +@subsection Controlling Array Traversal + +By default, the order in which a @samp{for (i in array)} loop +scans an array is not defined; it is generally based upon +the internal implementation of arrays inside @command{awk}. + +Often, though, it is desirable to be able to loop over the elements +in a particular order that you, the programmer, choose. @command{gawk} +lets you do this. + +@ref{Controlling Scanning}, describes how you can assign special, +pre-defined values to @code{PROCINFO["sorted_in"]} in order to +control the order in which @command{gawk} will traverse an array +during a @code{for} loop. + +In addition, the value of @code{PROCINFO["sorted_in"]} can be a function name. +This lets you traverse an array based on any custom criterion. +The array elements are ordered according to the return value of this +function. The comparison function should be defined with at least +four arguments: + +@example +function comp_func(i1, v1, i2, v2) +@{ + @var{compare elements 1 and 2 in some fashion} + @var{return < 0; 0; or > 0} +@} +@end example + +Here, @var{i1} and @var{i2} are the indices, and @var{v1} and @var{v2} +are the corresponding values of the two elements being compared. +Either @var{v1} or @var{v2}, or both, can be arrays if the array being +traversed contains subarrays as values. +(@xref{Arrays of Arrays}, for more information about subarrays.) +The three possible return values are interpreted as follows: + +@table @code +@item comp_func(i1, v1, i2, v2) < 0 +Index @var{i1} comes before index @var{i2} during loop traversal. + +@item comp_func(i1, v1, i2, v2) == 0 +Indices @var{i1} and @var{i2} +come together but the relative order with respect to each other is undefined. + +@item comp_func(i1, v1, i2, v2) > 0 +Index @var{i1} comes after index @var{i2} during loop traversal. +@end table + +Our first comparison function can be used to scan an array in +numerical order of the indices: + +@example +function cmp_num_idx(i1, v1, i2, v2) +@{ + # numerical index comparison, ascending order + return (i1 - i2) +@} +@end example + +Our second function traverses an array based on the string order of +the element values rather than by indices: + +@example +function cmp_str_val(i1, v1, i2, v2) +@{ + # string value comparison, ascending order + v1 = v1 "" + v2 = v2 "" + if (v1 < v2) + return -1 + return (v1 != v2) +@} +@end example + +The third +comparison function makes all numbers, and numeric strings without +any leading or trailing spaces, come out first during loop traversal: + +@example +function cmp_num_str_val(i1, v1, i2, v2, n1, n2) +@{ + # numbers before string value comparison, ascending order + n1 = v1 + 0 + n2 = v2 + 0 + if (n1 == v1) + return (n2 == v2) ? (n1 - n2) : -1 + else if (n2 == v2) + return 1 + return (v1 < v2) ? -1 : (v1 != v2) +@} +@end example + +Here is a main program to demonstrate how @command{gawk} +behaves using each of the previous functions: + +@example +BEGIN @{ + data["one"] = 10 + data["two"] = 20 + data[10] = "one" + data[100] = 100 + data[20] = "two" + + f[1] = "cmp_num_idx" + f[2] = "cmp_str_val" + f[3] = "cmp_num_str_val" + for (i = 1; i <= 3; i++) @{ + printf("Sort function: %s\n", f[i]) + PROCINFO["sorted_in"] = f[i] + for (j in data) + printf("\tdata[%s] = %s\n", j, data[j]) + print "" + @} +@} +@end example + +Here are the results when the program is run: +@page + +@example +$ @kbd{gawk -f compdemo.awk} +@print{} Sort function: cmp_num_idx @ii{Sort by numeric index} +@print{} data[two] = 20 +@print{} data[one] = 10 @ii{Both strings are numerically zero} +@print{} data[10] = one +@print{} data[20] = two +@print{} data[100] = 100 +@print{} +@print{} Sort function: cmp_str_val @ii{Sort by element values as strings} +@print{} data[one] = 10 +@print{} data[100] = 100 @ii{String 100 is less than string 20} +@print{} data[two] = 20 +@print{} data[10] = one +@print{} data[20] = two +@print{} +@print{} Sort function: cmp_num_str_val @ii{Sort all numeric values before all strings} +@print{} data[one] = 10 +@print{} data[two] = 20 +@print{} data[100] = 100 +@print{} data[10] = one +@print{} data[20] = two +@end example + +Consider sorting the entries of a GNU/Linux system password file +according to login name. The following program sorts records +by a specific field position and can be used for this purpose: + +@example +# sort.awk --- simple program to sort by field position +# field position is specified by the global variable POS + +function cmp_field(i1, v1, i2, v2) +@{ + # comparison by value, as string, and ascending order + return v1[POS] < v2[POS] ? -1 : (v1[POS] != v2[POS]) +@} + +@{ + for (i = 1; i <= NF; i++) + a[NR][i] = $i +@} + +END @{ + PROCINFO["sorted_in"] = "cmp_field" + if (POS < 1 || POS > NF) + POS = 1 + for (i in a) @{ + for (j = 1; j <= NF; j++) + printf("%s%c", a[i][j], j < NF ? ":" : "") + print "" + @} +@} +@end example + +The first field in each entry of the password file is the user's login name, +and the fields are separated by colons. +Each record defines a subarray, +with each field as an element in the subarray. +Running the program produces the +following output: + +@example +$ @kbd{gawk -vPOS=1 -F: -f sort.awk /etc/passwd} +@print{} adm:x:3:4:adm:/var/adm:/sbin/nologin +@print{} apache:x:48:48:Apache:/var/www:/sbin/nologin +@print{} avahi:x:70:70:Avahi daemon:/:/sbin/nologin +@dots{} +@end example + +The comparison should normally always return the same value when given a +specific pair of array elements as its arguments. If inconsistent +results are returned then the order is undefined. This behavior can be +exploited to introduce random order into otherwise seemingly +ordered data: + +@example +function cmp_randomize(i1, v1, i2, v2) +@{ + # random order + return (2 - 4 * rand()) +@} +@end example + +As mentioned above, the order of the indices is arbitrary if two +elements compare equal. This is usually not a problem, but letting +the tied elements come out in arbitrary order can be an issue, especially +when comparing item values. The partial ordering of the equal elements +may change during the next loop traversal, if other elements are added or +removed from the array. One way to resolve ties when comparing elements +with otherwise equal values is to include the indices in the comparison +rules. Note that doing this may make the loop traversal less efficient, +so consider it only if necessary. The following comparison functions +force a deterministic order, and are based on the fact that the +indices of two elements are never equal: + +@example +function cmp_numeric(i1, v1, i2, v2) +@{ + # numerical value (and index) comparison, descending order + return (v1 != v2) ? (v2 - v1) : (i2 - i1) +@} + +function cmp_string(i1, v1, i2, v2) +@{ + # string value (and index) comparison, descending order + v1 = v1 i1 + v2 = v2 i2 + return (v1 > v2) ? -1 : (v1 != v2) +@} +@end example + +@c Avoid using the term ``stable'' when describing the unpredictable behavior +@c if two items compare equal. Usually, the goal of a "stable algorithm" +@c is to maintain the original order of the items, which is a meaningless +@c concept for a list constructed from a hash. + +A custom comparison function can often simplify ordered loop +traversal, and the sky is really the limit when it comes to +designing such a function. + +When string comparisons are made during a sort, either for element +values where one or both aren't numbers, or for element indices +handled as strings, the value of @code{IGNORECASE} +(@pxref{Built-in Variables}) controls whether +the comparisons treat corresponding uppercase and lowercase letters as +equivalent or distinct. + +Another point to keep in mind is that in the case of subarrays +the element values can themselves be arrays; a production comparison +function should use the @code{isarray()} function +(@pxref{Type Functions}), +to check for this, and choose a defined sorting order for subarrays. + +All sorting based on @code{PROCINFO["sorted_in"]} +is disabled in POSIX mode, +since the @code{PROCINFO} array is not special in that case. + +As a side note, sorting the array indices before traversing +the array has been reported to add 15% to 20% overhead to the +execution time of @command{awk} programs. For this reason, +sorted array traversal is not the default. + +@c The @command{gawk} +@c maintainers believe that only the people who wish to use a +@c feature should have to pay for it. + +@node Array Sorting Functions +@subsection Sorting Array Values and Indices with @command{gawk} + +@cindex arrays, sorting +@cindex @code{asort()} function (@command{gawk}) +@cindex @code{asort()} function (@command{gawk}), arrays@comma{} sorting +@cindex sort function, arrays, sorting +In most @command{awk} implementations, sorting an array requires +writing a @code{sort()} function. +While this can be educational for exploring different sorting algorithms, +usually that's not the point of the program. +@command{gawk} provides the built-in @code{asort()} +and @code{asorti()} functions +(@pxref{String Functions}) +for sorting arrays. For example: + +@example +@var{populate the array} data +n = asort(data) +for (i = 1; i <= n; i++) + @var{do something with} data[i] +@end example + +After the call to @code{asort()}, the array @code{data} is indexed from 1 +to some number @var{n}, the total number of elements in @code{data}. +(This count is @code{asort()}'s return value.) +@code{data[1]} @value{LEQ} @code{data[2]} @value{LEQ} @code{data[3]}, and so on. +The comparison is based on the type of the elements +(@pxref{Typing and Comparison}). +All numeric values come before all string values, +which in turn come before all subarrays. + +@cindex side effects, @code{asort()} function +An important side effect of calling @code{asort()} is that +@emph{the array's original indices are irrevocably lost}. +As this isn't always desirable, @code{asort()} accepts a +second argument: + +@example +@var{populate the array} source +n = asort(source, dest) +for (i = 1; i <= n; i++) + @var{do something with} dest[i] +@end example + +In this case, @command{gawk} copies the @code{source} array into the +@code{dest} array and then sorts @code{dest}, destroying its indices. +However, the @code{source} array is not affected. + +@code{asort()} accepts a third string argument to control comparison of +array elements. As with @code{PROCINFO["sorted_in"]}, this argument +may be one of the predefined names that @command{gawk} provides +(@pxref{Controlling Scanning}), or the name of a user-defined function +(@pxref{Controlling Array Traversal}). + +@quotation NOTE +In all cases, the sorted element values consist of the original +array's element values. The ability to control comparison merely +affects the way in which they are sorted. +@end quotation + +Often, what's needed is to sort on the values of the @emph{indices} +instead of the values of the elements. +To do that, use the +@code{asorti()} function. The interface is identical to that of +@code{asort()}, except that the index values are used for sorting, and +become the values of the result array: + +@example +@{ source[$0] = some_func($0) @} + +END @{ + n = asorti(source, dest) + for (i = 1; i <= n; i++) @{ + @ii{Work with sorted indices directly:} + @var{do something with} dest[i] + @dots{} + @ii{Access original array via sorted indices:} + @var{do something with} source[dest[i]] + @} +@} +@end example + +Similar to @code{asort()}, +in all cases, the sorted element values consist of the original +array's indices. The ability to control comparison merely +affects the way in which they are sorted. + +Sorting the array by replacing the indices provides maximal flexibility. +To traverse the elements in decreasing order, use a loop that goes from +@var{n} down to 1, either over the elements or over the indices.@footnote{You +may also use one of the predefined sorting names that sorts in +decreasing order.} + +@cindex reference counting, sorting arrays +Copying array indices and elements isn't expensive in terms of memory. +Internally, @command{gawk} maintains @dfn{reference counts} to data. +For example, when @code{asort()} copies the first array to the second one, +there is only one copy of the original array elements' data, even though +both arrays use the values. + +@c Document It And Call It A Feature. Sigh. +@cindex @command{gawk}, @code{IGNORECASE} variable in +@cindex @code{IGNORECASE} variable +@cindex arrays, sorting, @code{IGNORECASE} variable and +@cindex @code{IGNORECASE} variable, array sorting and +Because @code{IGNORECASE} affects string comparisons, the value +of @code{IGNORECASE} also affects sorting for both @code{asort()} and @code{asorti()}. +Note also that the locale's sorting order does @emph{not} +come into play; comparisons are based on character values only.@footnote{This +is true because locale-based comparison occurs only when in POSIX +compatibility mode, and since @code{asort()} and @code{asorti()} are +@command{gawk} extensions, they are not available in that case.} +Caveat Emptor. + +@node Two-way I/O +@section Two-Way Communications with Another Process +@cindex Brennan, Michael +@cindex programmers, attractiveness of +@smallexample +@c Path: cssun.mathcs.emory.edu!gatech!newsxfer3.itd.umich.edu!news-peer.sprintlink.net!news-sea-19.sprintlink.net!news-in-west.sprintlink.net!news.sprintlink.net!Sprint!204.94.52.5!news.whidbey.com!brennan +From: brennan@@whidbey.com (Mike Brennan) +Newsgroups: comp.lang.awk +Subject: Re: Learn the SECRET to Attract Women Easily +Date: 4 Aug 1997 17:34:46 GMT +@c Organization: WhidbeyNet +@c Lines: 12 +Message-ID: <5s53rm$eca@@news.whidbey.com> +@c References: <5s20dn$2e1@chronicle.concentric.net> +@c Reply-To: brennan@whidbey.com +@c NNTP-Posting-Host: asn202.whidbey.com +@c X-Newsreader: slrn (0.9.4.1 UNIX) +@c Xref: cssun.mathcs.emory.edu comp.lang.awk:5403 + +On 3 Aug 1997 13:17:43 GMT, Want More Dates??? + wrote: +>Learn the SECRET to Attract Women Easily +> +>The SCENT(tm) Pheromone Sex Attractant For Men to Attract Women + +The scent of awk programmers is a lot more attractive to women than +the scent of perl programmers. +-- +Mike Brennan +@c brennan@@whidbey.com +@end smallexample + +@cindex advanced features, @command{gawk}, processes@comma{} communicating with +@cindex processes, two-way communications with +It is often useful to be able to +send data to a separate program for +processing and then read the result. This can always be +done with temporary files: + +@example +# Write the data for processing +tempfile = ("mydata." PROCINFO["pid"]) +while (@var{not done with data}) + print @var{data} | ("subprogram > " tempfile) +close("subprogram > " tempfile) + +# Read the results, remove tempfile when done +while ((getline newdata < tempfile) > 0) + @var{process} newdata @var{appropriately} +close(tempfile) +system("rm " tempfile) +@end example + +@noindent +This works, but not elegantly. Among other things, it requires that +the program be run in a directory that cannot be shared among users; +for example, @file{/tmp} will not do, as another user might happen +to be using a temporary file with the same name. + +@cindex coprocesses +@cindex input/output, two-way +@cindex @code{|} (vertical bar), @code{|&} operator (I/O) +@cindex vertical bar (@code{|}), @code{|&} operator (I/O) +@cindex @command{csh} utility, @code{|&} operator, comparison with +However, with @command{gawk}, it is possible to +open a @emph{two-way} pipe to another process. The second process is +termed a @dfn{coprocess}, since it runs in parallel with @command{gawk}. +The two-way connection is created using the @samp{|&} operator +(borrowed from the Korn shell, @command{ksh}):@footnote{This is very +different from the same operator in the C shell.} + +@example +do @{ + print @var{data} |& "subprogram" + "subprogram" |& getline results +@} while (@var{data left to process}) +close("subprogram") +@end example + +The first time an I/O operation is executed using the @samp{|&} +operator, @command{gawk} creates a two-way pipeline to a child process +that runs the other program. Output created with @code{print} +or @code{printf} is written to the program's standard input, and +output from the program's standard output can be read by the @command{gawk} +program using @code{getline}. +As is the case with processes started by @samp{|}, the subprogram +can be any program, or pipeline of programs, that can be started by +the shell. + +There are some cautionary items to be aware of: + +@itemize @bullet +@item +As the code inside @command{gawk} currently stands, the coprocess's +standard error goes to the same place that the parent @command{gawk}'s +standard error goes. It is not possible to read the child's +standard error separately. + +@cindex deadlocks +@cindex buffering, input/output +@cindex @code{getline} command, deadlock and +@item +I/O buffering may be a problem. @command{gawk} automatically +flushes all output down the pipe to the coprocess. +However, if the coprocess does not flush its output, +@command{gawk} may hang when doing a @code{getline} in order to read +the coprocess's results. This could lead to a situation +known as @dfn{deadlock}, where each process is waiting for the +other one to do something. +@end itemize + +@cindex @code{close()} function, two-way pipes and +It is possible to close just one end of the two-way pipe to +a coprocess, by supplying a second argument to the @code{close()} +function of either @code{"to"} or @code{"from"} +(@pxref{Close Files And Pipes}). +These strings tell @command{gawk} to close the end of the pipe +that sends data to the coprocess or the end that reads from it, +respectively. + +@cindex @command{sort} utility, coprocesses and +This is particularly necessary in order to use +the system @command{sort} utility as part of a coprocess; +@command{sort} must read @emph{all} of its input +data before it can produce any output. +The @command{sort} program does not receive an end-of-file indication +until @command{gawk} closes the write end of the pipe. + +When you have finished writing data to the @command{sort} +utility, you can close the @code{"to"} end of the pipe, and +then start reading sorted data via @code{getline}. +For example: + +@example +BEGIN @{ + command = "LC_ALL=C sort" + n = split("abcdefghijklmnopqrstuvwxyz", a, "") + + for (i = n; i > 0; i--) + print a[i] |& command + close(command, "to") + + while ((command |& getline line) > 0) + print "got", line + close(command) +@} +@end example + +This program writes the letters of the alphabet in reverse order, one +per line, down the two-way pipe to @command{sort}. It then closes the +write end of the pipe, so that @command{sort} receives an end-of-file +indication. This causes @command{sort} to sort the data and write the +sorted data back to the @command{gawk} program. Once all of the data +has been read, @command{gawk} terminates the coprocess and exits. + +As a side note, the assignment @samp{LC_ALL=C} in the @command{sort} +command ensures traditional Unix (ASCII) sorting from @command{sort}. + +@cindex @command{gawk}, @code{PROCINFO} array in +@cindex @code{PROCINFO} array +You may also use pseudo-ttys (ptys) for +two-way communication instead of pipes, if your system supports them. +This is done on a per-command basis, by setting a special element +in the @code{PROCINFO} array +(@pxref{Auto-set}), +like so: + +@example +command = "sort -nr" # command, save in convenience variable +PROCINFO[command, "pty"] = 1 # update PROCINFO +print @dots{} |& command # start two-way pipe +@dots{} +@end example + +@noindent +Using ptys avoids the buffer deadlock issues described earlier, at some +loss in performance. If your system does not have ptys, or if all the +system's ptys are in use, @command{gawk} automatically falls back to +using regular pipes. + +@node TCP/IP Networking +@section Using @command{gawk} for Network Programming +@cindex advanced features, @command{gawk}, network programming +@cindex networks, programming +@c STARTOFRANGE tcpip +@cindex TCP/IP +@cindex @code{/inet/@dots{}} special files (@command{gawk}) +@cindex files, @code{/inet/@dots{}} (@command{gawk}) +@cindex @code{/inet4/@dots{}} special files (@command{gawk}) +@cindex files, @code{/inet4/@dots{}} (@command{gawk}) +@cindex @code{/inet6/@dots{}} special files (@command{gawk}) +@cindex files, @code{/inet6/@dots{}} (@command{gawk}) +@cindex @code{EMISTERED} +@quotation +@code{EMISTERED}:@* +@ @ @ @ @i{A host is a host from coast to coast,@* +@ @ @ @ and no-one can talk to host that's close,@* +@ @ @ @ unless the host that isn't close@* +@ @ @ @ is busy hung or dead.} +@end quotation + +In addition to being able to open a two-way pipeline to a coprocess +on the same system +(@pxref{Two-way I/O}), +it is possible to make a two-way connection to +another process on another system across an IP network connection. + +You can think of this as just a @emph{very long} two-way pipeline to +a coprocess. +The way @command{gawk} decides that you want to use TCP/IP networking is +by recognizing special @value{FN}s that begin with one of @samp{/inet/}, +@samp{/inet4/} or @samp{/inet6}. + +The full syntax of the special @value{FN} is +@file{/@var{net-type}/@var{protocol}/@var{local-port}/@var{remote-host}/@var{remote-port}}. +The components are: + +@table @var +@item net-type +Specifies the kind of Internet connection to make. +Use @samp{/inet4/} to force IPv4, and +@samp{/inet6/} to force IPv6. +Plain @samp{/inet/} (which used to be the only option) uses +the system default, most likely IPv4. + +@item protocol +The protocol to use over IP. This must be either @samp{tcp}, or +@samp{udp}, for a TCP or UDP IP connection, +respectively. The use of TCP is recommended for most applications. + +@item local-port +@cindex @code{getaddrinfo()} function (C library) +The local TCP or UDP port number to use. Use a port number of @samp{0} +when you want the system to pick a port. This is what you should do +when writing a TCP or UDP client. +You may also use a well-known service name, such as @samp{smtp} +or @samp{http}, in which case @command{gawk} attempts to determine +the predefined port number using the C @code{getaddrinfo()} function. + +@item remote-host +The IP address or fully-qualified domain name of the Internet +host to which you want to connect. + +@item remote-port +The TCP or UDP port number to use on the given @var{remote-host}. +Again, use @samp{0} if you don't care, or else a well-known +service name. +@end table + +@cindex @command{gawk}, @code{ERRNO} variable in +@cindex @code{ERRNO} variable +@quotation NOTE +Failure in opening a two-way socket will result in a non-fatal error +being returned to the calling code. The value of @code{ERRNO} indicates +the error (@pxref{Auto-set}). +@end quotation + +Consider the following very simple example: + +@example +BEGIN @{ + Service = "/inet/tcp/0/localhost/daytime" + Service |& getline + print $0 + close(Service) +@} +@end example + +This program reads the current date and time from the local system's +TCP @samp{daytime} server. +It then prints the results and closes the connection. + +Because this topic is extensive, the use of @command{gawk} for +TCP/IP programming is documented separately. +@ifinfo +See +@inforef{Top, , General Introduction, gawkinet, TCP/IP Internetworking with @command{gawk}}, +@end ifinfo +@ifnotinfo +See @cite{TCP/IP Internetworking with @command{gawk}}, +which comes as part of the @command{gawk} distribution, +@end ifnotinfo +for a much more complete introduction and discussion, as well as +extensive examples. + +@c ENDOFRANGE tcpip + +@node Profiling +@section Profiling Your @command{awk} Programs +@c STARTOFRANGE awkp +@cindex @command{awk} programs, profiling +@c STARTOFRANGE proawk +@cindex profiling @command{awk} programs +@c STARTOFRANGE pgawk +@cindex @command{pgawk} program +@cindex profiling @command{gawk}, See @command{pgawk} program + +You may produce execution +traces of your @command{awk} programs. +This is done with a specially compiled version of @command{gawk}, +called @command{pgawk} (``profiling @command{gawk}''). + +@cindex @code{awkprof.out} file +@cindex files, @code{awkprof.out} +@cindex @command{pgawk} program, @code{awkprof.out} file +@command{pgawk} is identical in every way to @command{gawk}, except that when +it has finished running, it creates a profile of your program in a file +named @file{awkprof.out}. +Because it is profiling, it also executes up to 45% slower than +@command{gawk} normally does. + +@cindex @code{--profile} option +As shown in the following example, +the @option{--profile} option can be used to change the name of the file +where @command{pgawk} will write the profile: + +@example +pgawk --profile=myprog.prof -f myprog.awk data1 data2 +@end example + +@noindent +In the above example, @command{pgawk} places the profile in +@file{myprog.prof} instead of in @file{awkprof.out}. + +Here is a sample +session showing a simple @command{awk} program, its input data, and the +results from running @command{pgawk}. First, the @command{awk} program: + +@example +BEGIN @{ print "First BEGIN rule" @} + +END @{ print "First END rule" @} + +/foo/ @{ + print "matched /foo/, gosh" + for (i = 1; i <= 3; i++) + sing() +@} + +@{ + if (/foo/) + print "if is true" + else + print "else is true" +@} + +BEGIN @{ print "Second BEGIN rule" @} + +END @{ print "Second END rule" @} + +function sing( dummy) +@{ + print "I gotta be me!" +@} +@end example + +Following is the input data: + +@example +foo +bar +baz +foo +junk +@end example + +Here is the @file{awkprof.out} that results from running @command{pgawk} +on this program and data (this example also illustrates that @command{awk} +programmers sometimes have to work late): + +@cindex @code{BEGIN} pattern, @command{pgawk} program +@cindex @code{END} pattern, @command{pgawk} program +@example + # gawk profile, created Sun Aug 13 00:00:15 2000 + + # BEGIN block(s) + + BEGIN @{ + 1 print "First BEGIN rule" + 1 print "Second BEGIN rule" + @} + + # Rule(s) + + 5 /foo/ @{ # 2 + 2 print "matched /foo/, gosh" + 6 for (i = 1; i <= 3; i++) @{ + 6 sing() + @} + @} + + 5 @{ + 5 if (/foo/) @{ # 2 + 2 print "if is true" + 3 @} else @{ + 3 print "else is true" + @} + @} + + # END block(s) + + END @{ + 1 print "First END rule" + 1 print "Second END rule" + @} + + # Functions, listed alphabetically + + 6 function sing(dummy) + @{ + 6 print "I gotta be me!" + @} +@end example + +This example illustrates many of the basic features of profiling output. +They are as follows: + +@itemize @bullet +@item +The program is printed in the order @code{BEGIN} rule, +@code{BEGINFILE} rule, +pattern/action rules, +@code{ENDFILE} rule, @code{END} rule and functions, listed +alphabetically. +Multiple @code{BEGIN} and @code{END} rules are merged together, +as are multiple @code{BEGINFILE} and @code{ENDFILE} rules. + +@cindex patterns, counts +@item +Pattern-action rules have two counts. +The first count, to the left of the rule, shows how many times +the rule's pattern was @emph{tested}. +The second count, to the right of the rule's opening left brace +in a comment, +shows how many times the rule's action was @emph{executed}. +The difference between the two indicates how many times the rule's +pattern evaluated to false. + +@item +Similarly, +the count for an @code{if}-@code{else} statement shows how many times +the condition was tested. +To the right of the opening left brace for the @code{if}'s body +is a count showing how many times the condition was true. +The count for the @code{else} +indicates how many times the test failed. + +@cindex loops, count for header +@item +The count for a loop header (such as @code{for} +or @code{while}) shows how many times the loop test was executed. +(Because of this, you can't just look at the count on the first +statement in a rule to determine how many times the rule was executed. +If the first statement is a loop, the count is misleading.) + +@cindex functions, user-defined, counts +@cindex user-defined, functions, counts +@item +For user-defined functions, the count next to the @code{function} +keyword indicates how many times the function was called. +The counts next to the statements in the body show how many times +those statements were executed. + +@cindex @code{@{@}} (braces), @command{pgawk} program +@cindex braces (@code{@{@}}), @command{pgawk} program +@item +The layout uses ``K&R'' style with TABs. +Braces are used everywhere, even when +the body of an @code{if}, @code{else}, or loop is only a single statement. + +@cindex @code{()} (parentheses), @command{pgawk} program +@cindex parentheses @code{()}, @command{pgawk} program +@item +Parentheses are used only where needed, as indicated by the structure +of the program and the precedence rules. +@c extra verbiage here satisfies the copyeditor. ugh. +For example, @samp{(3 + 5) * 4} means add three plus five, then multiply +the total by four. However, @samp{3 + 5 * 4} has no parentheses, and +means @samp{3 + (5 * 4)}. + +@ignore +@item +All string concatenations are parenthesized too. +(This could be made a bit smarter.) +@end ignore + +@item +Parentheses are used around the arguments to @code{print} +and @code{printf} only when +the @code{print} or @code{printf} statement is followed by a redirection. +Similarly, if +the target of a redirection isn't a scalar, it gets parenthesized. + +@item +@command{pgawk} supplies leading comments in +front of the @code{BEGIN} and @code{END} rules, +the pattern/action rules, and the functions. + +@end itemize + +The profiled version of your program may not look exactly like what you +typed when you wrote it. This is because @command{pgawk} creates the +profiled version by ``pretty printing'' its internal representation of +the program. The advantage to this is that @command{pgawk} can produce +a standard representation. The disadvantage is that all source-code +comments are lost, as are the distinctions among multiple @code{BEGIN}, +@code{END}, @code{BEGINFILE}, and @code{ENDFILE} rules. Also, things such as: + +@example +/foo/ +@end example + +@noindent +come out as: + +@example +/foo/ @{ + print $0 +@} +@end example + +@noindent +which is correct, but possibly surprising. + +@cindex profiling @command{awk} programs, dynamically +@cindex @command{pgawk} program, dynamic profiling +Besides creating profiles when a program has completed, +@command{pgawk} can produce a profile while it is running. +This is useful if your @command{awk} program goes into an +infinite loop and you want to see what has been executed. +To use this feature, run @command{pgawk} in the background: + +@example +$ @kbd{pgawk -f myprog &} +[1] 13992 +@end example + +@cindex @command{kill} command@comma{} dynamic profiling +@cindex @code{USR1} signal +@cindex @code{SIGUSR1} signal +@cindex signals, @code{USR1}/@code{SIGUSR1} +@noindent +The shell prints a job number and process ID number; in this case, 13992. +Use the @command{kill} command to send the @code{USR1} signal +to @command{pgawk}: + +@example +$ @kbd{kill -USR1 13992} +@end example + +@noindent +As usual, the profiled version of the program is written to +@file{awkprof.out}, or to a different file if you use the @option{--profile} +option. + +Along with the regular profile, as shown earlier, the profile +includes a trace of any active functions: + +@example +# Function Call Stack: + +# 3. baz +# 2. bar +# 1. foo +# -- main -- +@end example + +You may send @command{pgawk} the @code{USR1} signal as many times as you like. +Each time, the profile and function call trace are appended to the output +profile file. + +@cindex @code{HUP} signal +@cindex @code{SIGHUP} signal +@cindex signals, @code{HUP}/@code{SIGHUP} +If you use the @code{HUP} signal instead of the @code{USR1} signal, +@command{pgawk} produces the profile and the function call trace and then exits. + +@cindex @code{INT} signal (MS-Windows) +@cindex @code{SIGINT} signal (MS-Windows) +@cindex signals, @code{INT}/@code{SIGINT} (MS-Windows) +@cindex @code{QUIT} signal (MS-Windows) +@cindex @code{SIGQUIT} signal (MS-Windows) +@cindex signals, @code{QUIT}/@code{SIGQUIT} (MS-Windows) +When @command{pgawk} runs on MS-Windows systems, it uses the +@code{INT} and @code{QUIT} signals for producing the profile and, in +the case of the @code{INT} signal, @command{pgawk} exits. This is +because these systems don't support the @command{kill} command, so the +only signals you can deliver to a program are those generated by the +keyboard. The @code{INT} signal is generated by the +@kbd{@value{CTL}-@key{C}} or @kbd{@value{CTL}-@key{BREAK}} key, while the +@code{QUIT} signal is generated by the @kbd{@value{CTL}-@key{\}} key. + +Finally, regular @command{gawk} also accepts the @option{--profile} option. +When called this way, @command{gawk} ``pretty prints'' the program into +@file{awkprof.out}, without any execution counts. +@c ENDOFRANGE advgaw +@c ENDOFRANGE gawadv +@c ENDOFRANGE pgawk +@c ENDOFRANGE awkp +@c ENDOFRANGE proawk + +@node Library Functions +@chapter A Library of @command{awk} Functions +@c STARTOFRANGE libf +@cindex libraries of @command{awk} functions +@c STARTOFRANGE flib +@cindex functions, library +@c STARTOFRANGE fudlib +@cindex functions, user-defined, library of + +@ref{User-defined}, describes how to write +your own @command{awk} functions. Writing functions is important, because +it allows you to encapsulate algorithms and program tasks in a single +place. It simplifies programming, making program development more +manageable, and making programs more readable. + +One valuable way to learn a new programming language is to @emph{read} +programs in that language. To that end, this @value{CHAPTER} +and @ref{Sample Programs}, +provide a good-sized body of code for you to read, +and hopefully, to learn from. + +@c 2e: USE TEXINFO-2 FUNCTION DEFINITION STUFF!!!!!!!!!!!!! +This @value{CHAPTER} presents a library of useful @command{awk} functions. +Many of the sample programs presented later in this @value{DOCUMENT} +use these functions. +The functions are presented here in a progression from simple to complex. + +@cindex Texinfo +@ref{Extract Program}, +presents a program that you can use to extract the source code for +these example library functions and programs from the Texinfo source +for this @value{DOCUMENT}. +(This has already been done as part of the @command{gawk} distribution.) + +If you have written one or more useful, general-purpose @command{awk} functions +and would like to contribute them to the @command{awk} user community, see +@ref{How To Contribute}, for more information. + +@cindex portability, example programs +The programs in this @value{CHAPTER} and in +@ref{Sample Programs}, +freely use features that are @command{gawk}-specific. +Rewriting these programs for different implementations of @command{awk} +is pretty straightforward. + +@itemize @bullet +@item +Diagnostic error messages are sent to @file{/dev/stderr}. +Use @samp{| "cat 1>&2"} instead of @samp{> "/dev/stderr"} if your system +does not have a @file{/dev/stderr}, or if you cannot use @command{gawk}. + +@item +A number of programs use @code{nextfile} +(@pxref{Nextfile Statement}) +to skip any remaining input in the input file. + +@item +@c 12/2000: Thanks to Nelson Beebe for pointing out the output issue. +@cindex case sensitivity, example programs +@cindex @code{IGNORECASE} variable, in example programs +Finally, some of the programs choose to ignore upper- and lowercase +distinctions in their input. They do so by assigning one to @code{IGNORECASE}. +You can achieve almost the same effect@footnote{The effects are +not identical. Output of the transformed +record will be in all lowercase, while @code{IGNORECASE} preserves the original +contents of the input record.} by adding the following rule to the +beginning of the program: + +@example +# ignore case +@{ $0 = tolower($0) @} +@end example + +@noindent +Also, verify that all regexp and string constants used in +comparisons use only lowercase letters. +@end itemize + +@menu +* Library Names:: How to best name private global variables in + library functions. +* General Functions:: Functions that are of general use. +* Data File Management:: Functions for managing command-line data + files. +* Getopt Function:: A function for processing command-line + arguments. +* Passwd Functions:: Functions for getting user information. +* Group Functions:: Functions for getting group information. +* Walking Arrays:: A function to walk arrays of arrays. +@end menu + +@node Library Names +@section Naming Library Function Global Variables + +@cindex names, arrays/variables +@cindex names, functions +@cindex namespace issues +@cindex @command{awk} programs, documenting +@cindex documentation, of @command{awk} programs +Due to the way the @command{awk} language evolved, variables are either +@dfn{global} (usable by the entire program) or @dfn{local} (usable just by +a specific function). There is no intermediate state analogous to +@code{static} variables in C. + +@cindex variables, global, for library functions +@cindex private variables +@cindex variables, private +Library functions often need to have global variables that they can use to +preserve state information between calls to the function---for example, +@code{getopt()}'s variable @code{_opti} +(@pxref{Getopt Function}). +Such variables are called @dfn{private}, since the only functions that need to +use them are the ones in the library. + +When writing a library function, you should try to choose names for your +private variables that will not conflict with any variables used by +either another library function or a user's main program. For example, a +name like @code{i} or @code{j} is not a good choice, because user programs +often use variable names like these for their own purposes. + +@cindex programming conventions, private variable names +The example programs shown in this @value{CHAPTER} all start the names of their +private variables with an underscore (@samp{_}). Users generally don't use +leading underscores in their variable names, so this convention immediately +decreases the chances that the variable name will be accidentally shared +with the user's program. + +@cindex @code{_} (underscore), in names of private variables +@cindex underscore (@code{_}), in names of private variables +In addition, several of the library functions use a prefix that helps +indicate what function or set of functions use the variables---for example, +@code{_pw_byname} in the user database routines +(@pxref{Passwd Functions}). +This convention is recommended, since it even further decreases the +chance of inadvertent conflict among variable names. Note that this +convention is used equally well for variable names and for private +function names.@footnote{While all the library routines could have +been rewritten to use this convention, this was not done, in order to +show how our own @command{awk} programming style has evolved and to +provide some basis for this discussion.} + +As a final note on variable naming, if a function makes global variables +available for use by a main program, it is a good convention to start that +variable's name with a capital letter---for +example, @code{getopt()}'s @code{Opterr} and @code{Optind} variables +(@pxref{Getopt Function}). +The leading capital letter indicates that it is global, while the fact that +the variable name is not all capital letters indicates that the variable is +not one of @command{awk}'s built-in variables, such as @code{FS}. + +@cindex @code{--dump-variables} option +It is also important that @emph{all} variables in library +functions that do not need to save state are, in fact, declared +local.@footnote{@command{gawk}'s @option{--dump-variables} command-line +option is useful for verifying this.} If this is not done, the variable +could accidentally be used in the user's program, leading to bugs that +are very difficult to track down: + +@example +function lib_func(x, y, l1, l2) +@{ + @dots{} + @var{use variable} some_var # some_var should be local + @dots{} # but is not by oversight +@} +@end example + +@cindex arrays, associative, library functions and +@cindex libraries of @command{awk} functions, associative arrays and +@cindex functions, library, associative arrays and +@cindex Tcl +A different convention, common in the Tcl community, is to use a single +associative array to hold the values needed by the library function(s), or +``package.'' This significantly decreases the number of actual global names +in use. For example, the functions described in +@ref{Passwd Functions}, +might have used array elements @code{@w{PW_data["inited"]}}, @code{@w{PW_data["total"]}}, +@code{@w{PW_data["count"]}}, and @code{@w{PW_data["awklib"]}}, instead of +@code{@w{_pw_inited}}, @code{@w{_pw_awklib}}, @code{@w{_pw_total}}, +and @code{@w{_pw_count}}. + +The conventions presented in this @value{SECTION} are exactly +that: conventions. You are not required to write your programs this +way---we merely recommend that you do so. + +@node General Functions +@section General Programming + +This @value{SECTION} presents a number of functions that are of general +programming use. + +@menu +* Strtonum Function:: A replacement for the built-in + @code{strtonum()} function. +* Assert Function:: A function for assertions in @command{awk} + programs. +* Round Function:: A function for rounding if @code{sprintf()} + does not do it correctly. +* Cliff Random Function:: The Cliff Random Number Generator. +* Ordinal Functions:: Functions for using characters as numbers and + vice versa. +* Join Function:: A function to join an array into a string. +* Gettimeofday Function:: A function to get formatted times. +@end menu + +@node Strtonum Function +@subsection Converting Strings To Numbers + +The @code{strtonum()} function (@pxref{String Functions}) +is a @command{gawk} extension. The following function +provides an implementation for other versions of @command{awk}: + +@example +@c file eg/lib/strtonum.awk +# mystrtonum --- convert string to number + +@c endfile +@ignore +@c file eg/lib/strtonum.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# February, 2004 + +@c endfile +@end ignore +@c file eg/lib/strtonum.awk +function mystrtonum(str, ret, chars, n, i, k, c) +@{ + if (str ~ /^0[0-7]*$/) @{ + # octal + n = length(str) + ret = 0 + for (i = 1; i <= n; i++) @{ + c = substr(str, i, 1) + if ((k = index("01234567", c)) > 0) + k-- # adjust for 1-basing in awk + + ret = ret * 8 + k + @} + @} else if (str ~ /^0[xX][[:xdigit:]]+/) @{ + # hexadecimal + str = substr(str, 3) # lop off leading 0x + n = length(str) + ret = 0 + for (i = 1; i <= n; i++) @{ + c = substr(str, i, 1) + c = tolower(c) + if ((k = index("0123456789", c)) > 0) + k-- # adjust for 1-basing in awk + else if ((k = index("abcdef", c)) > 0) + k += 9 + + ret = ret * 16 + k + @} + @} else if (str ~ \ + /^[-+]?([0-9]+([.][0-9]*([Ee][0-9]+)?)?|([.][0-9]+([Ee][-+]?[0-9]+)?))$/) @{ + # decimal number, possibly floating point + ret = str + 0 + @} else + ret = "NOT-A-NUMBER" + + return ret +@} + +# BEGIN @{ # gawk test harness +# a[1] = "25" +# a[2] = ".31" +# a[3] = "0123" +# a[4] = "0xdeadBEEF" +# a[5] = "123.45" +# a[6] = "1.e3" +# a[7] = "1.32" +# a[7] = "1.32E2" +# +# for (i = 1; i in a; i++) +# print a[i], strtonum(a[i]), mystrtonum(a[i]) +# @} +@c endfile +@end example + +The function first looks for C-style octal numbers (base 8). +If the input string matches a regular expression describing octal +numbers, then @code{mystrtonum()} loops through each character in the +string. It sets @code{k} to the index in @code{"01234567"} of the current +octal digit. Since the return value is one-based, the @samp{k--} +adjusts @code{k} so it can be used in computing the return value. + +Similar logic applies to the code that checks for and converts a +hexadecimal value, which starts with @samp{0x} or @samp{0X}. +The use of @code{tolower()} simplifies the computation for finding +the correct numeric value for each hexadecimal digit. + +Finally, if the string matches the (rather complicated) regexp for a +regular decimal integer or floating-point number, the computation +@samp{ret = str + 0} lets @command{awk} convert the value to a +number. + +A commented-out test program is included, so that the function can +be tested with @command{gawk} and the results compared to the built-in +@code{strtonum()} function. + +@node Assert Function +@subsection Assertions + +@c STARTOFRANGE asse +@cindex assertions +@c STARTOFRANGE assef +@cindex @code{assert()} function (C library) +@c STARTOFRANGE libfass +@cindex libraries of @command{awk} functions, assertions +@c STARTOFRANGE flibass +@cindex functions, library, assertions +@cindex @command{awk} programs, lengthy, assertions +When writing large programs, it is often useful to know +that a condition or set of conditions is true. Before proceeding with a +particular computation, you make a statement about what you believe to be +the case. Such a statement is known as an +@dfn{assertion}. The C language provides an @code{} header file +and corresponding @code{assert()} macro that the programmer can use to make +assertions. If an assertion fails, the @code{assert()} macro arranges to +print a diagnostic message describing the condition that should have +been true but was not, and then it kills the program. In C, using +@code{assert()} looks this: + +@example +#include + +int myfunc(int a, double b) +@{ + assert(a <= 5 && b >= 17.1); + @dots{} +@} +@end example + +If the assertion fails, the program prints a message similar to this: + +@example +prog.c:5: assertion failed: a <= 5 && b >= 17.1 +@end example + +@cindex @code{assert()} user-defined function +The C language makes it possible to turn the condition into a string for use +in printing the diagnostic message. This is not possible in @command{awk}, so +this @code{assert()} function also requires a string version of the condition +that is being tested. +Following is the function: + +@example +@c file eg/lib/assert.awk +# assert --- assert that a condition is true. Otherwise exit. + +@c endfile +@ignore +@c file eg/lib/assert.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# May, 1993 + +@c endfile +@end ignore +@c file eg/lib/assert.awk +function assert(condition, string) +@{ + if (! condition) @{ + printf("%s:%d: assertion failed: %s\n", + FILENAME, FNR, string) > "/dev/stderr" + _assert_exit = 1 + exit 1 + @} +@} + +@group +END @{ + if (_assert_exit) + exit 1 +@} +@end group +@c endfile +@end example + +The @code{assert()} function tests the @code{condition} parameter. If it +is false, it prints a message to standard error, using the @code{string} +parameter to describe the failed condition. It then sets the variable +@code{_assert_exit} to one and executes the @code{exit} statement. +The @code{exit} statement jumps to the @code{END} rule. If the @code{END} +rules finds @code{_assert_exit} to be true, it exits immediately. + +The purpose of the test in the @code{END} rule is to +keep any other @code{END} rules from running. When an assertion fails, the +program should exit immediately. +If no assertions fail, then @code{_assert_exit} is still +false when the @code{END} rule is run normally, and the rest of the +program's @code{END} rules execute. +For all of this to work correctly, @file{assert.awk} must be the +first source file read by @command{awk}. +The function can be used in a program in the following way: + +@example +function myfunc(a, b) +@{ + assert(a <= 5 && b >= 17.1, "a <= 5 && b >= 17.1") + @dots{} +@} +@end example + +@noindent +If the assertion fails, you see a message similar to the following: + +@example +mydata:1357: assertion failed: a <= 5 && b >= 17.1 +@end example + +@cindex @code{END} pattern, @code{assert()} user-defined function and +There is a small problem with this version of @code{assert()}. +An @code{END} rule is automatically added +to the program calling @code{assert()}. Normally, if a program consists +of just a @code{BEGIN} rule, the input files and/or standard input are +not read. However, now that the program has an @code{END} rule, @command{awk} +attempts to read the input @value{DF}s or standard input +(@pxref{Using BEGIN/END}), +most likely causing the program to hang as it waits for input. + +@cindex @code{BEGIN} pattern, @code{assert()} user-defined function and +There is a simple workaround to this: +make sure that such a @code{BEGIN} rule always ends +with an @code{exit} statement. +@c ENDOFRANGE asse +@c ENDOFRANGE assef +@c ENDOFRANGE flibass +@c ENDOFRANGE libfass + +@node Round Function +@subsection Rounding Numbers + +@cindex rounding numbers +@cindex numbers, rounding +@cindex libraries of @command{awk} functions, rounding numbers +@cindex functions, library, rounding numbers +@cindex @code{print} statement, @code{sprintf()} function and +@cindex @code{printf} statement, @code{sprintf()} function and +@cindex @code{sprintf()} function, @code{print}/@code{printf} statements and +The way @code{printf} and @code{sprintf()} +(@pxref{Printf}) +perform rounding often depends upon the system's C @code{sprintf()} +subroutine. On many machines, @code{sprintf()} rounding is ``unbiased,'' +which means it doesn't always round a trailing @samp{.5} up, contrary +to naive expectations. In unbiased rounding, @samp{.5} rounds to even, +rather than always up, so 1.5 rounds to 2 but 4.5 rounds to 4. This means +that if you are using a format that does rounding (e.g., @code{"%.0f"}), +you should check what your system does. The following function does +traditional rounding; it might be useful if your @command{awk}'s @code{printf} +does unbiased rounding: + +@cindex @code{round()} user-defined function +@example +@c file eg/lib/round.awk +# round.awk --- do normal rounding +@c endfile +@ignore +@c file eg/lib/round.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# August, 1996 +@c endfile +@end ignore +@c file eg/lib/round.awk + +function round(x, ival, aval, fraction) +@{ + ival = int(x) # integer part, int() truncates + + # see if fractional part + if (ival == x) # no fraction + return ival # ensure no decimals + + if (x < 0) @{ + aval = -x # absolute value + ival = int(aval) + fraction = aval - ival + if (fraction >= .5) + return int(x) - 1 # -2.5 --> -3 + else + return int(x) # -2.3 --> -2 + @} else @{ + fraction = x - ival + if (fraction >= .5) + return ival + 1 + else + return ival + @} +@} +@c endfile +@c don't include test harness in the file that gets installed + +# test harness +@{ print $0, round($0) @} +@end example + +@node Cliff Random Function +@subsection The Cliff Random Number Generator +@cindex random numbers, Cliff +@cindex Cliff random numbers +@cindex numbers, Cliff random +@cindex functions, library, Cliff random numbers + +The +@uref{http://mathworld.wolfram.com/CliffRandomNumberGenerator.html, Cliff random number generator} +is a very simple random number generator that ``passes the noise sphere test +for randomness by showing no structure.'' +It is easily programmed, in less than 10 lines of @command{awk} code: + +@cindex @code{cliff_rand()} user-defined function +@example +@c file eg/lib/cliff_rand.awk +# cliff_rand.awk --- generate Cliff random numbers +@c endfile +@ignore +@c file eg/lib/cliff_rand.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# December 2000 +@c endfile +@end ignore +@c file eg/lib/cliff_rand.awk + +BEGIN @{ _cliff_seed = 0.1 @} + +function cliff_rand() +@{ + _cliff_seed = (100 * log(_cliff_seed)) % 1 + if (_cliff_seed < 0) + _cliff_seed = - _cliff_seed + return _cliff_seed +@} +@c endfile +@end example + +This algorithm requires an initial ``seed'' of 0.1. Each new value +uses the current seed as input for the calculation. +If the built-in @code{rand()} function +(@pxref{Numeric Functions}) +isn't random enough, you might try using this function instead. + +@node Ordinal Functions +@subsection Translating Between Characters and Numbers + +@cindex libraries of @command{awk} functions, character values as numbers +@cindex functions, library, character values as numbers +@cindex characters, values of as numbers +@cindex numbers, as values of characters +One commercial implementation of @command{awk} supplies a built-in function, +@code{ord()}, which takes a character and returns the numeric value for that +character in the machine's character set. If the string passed to +@code{ord()} has more than one character, only the first one is used. + +The inverse of this function is @code{chr()} (from the function of the same +name in Pascal), which takes a number and returns the corresponding character. +Both functions are written very nicely in @command{awk}; there is no real +reason to build them into the @command{awk} interpreter: + +@cindex @code{ord()} user-defined function +@cindex @code{chr()} user-defined function +@example +@c file eg/lib/ord.awk +# ord.awk --- do ord and chr + +# Global identifiers: +# _ord_: numerical values indexed by characters +# _ord_init: function to initialize _ord_ +@c endfile +@ignore +@c file eg/lib/ord.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# 16 January, 1992 +# 20 July, 1992, revised +@c endfile +@end ignore +@c file eg/lib/ord.awk + +BEGIN @{ _ord_init() @} + +function _ord_init( low, high, i, t) +@{ + low = sprintf("%c", 7) # BEL is ascii 7 + if (low == "\a") @{ # regular ascii + low = 0 + high = 127 + @} else if (sprintf("%c", 128 + 7) == "\a") @{ + # ascii, mark parity + low = 128 + high = 255 + @} else @{ # ebcdic(!) + low = 0 + high = 255 + @} + + for (i = low; i <= high; i++) @{ + t = sprintf("%c", i) + _ord_[t] = i + @} +@} +@c endfile +@end example + +@cindex character sets (machine character encodings) +@cindex ASCII +@cindex EBCDIC +@cindex mark parity +Some explanation of the numbers used by @code{chr} is worthwhile. +The most prominent character set in use today is ASCII.@footnote{This +is changing; many systems use Unicode, a very large character set +that includes ASCII as a subset. On systems with full Unicode support, +a character can occupy up to 32 bits, making simple tests such as +used here prohibitively expensive.} +Although an +8-bit byte can hold 256 distinct values (from 0 to 255), ASCII only +defines characters that use the values from 0 to 127.@footnote{ASCII +has been extended in many countries to use the values from 128 to 255 +for country-specific characters. If your system uses these extensions, +you can simplify @code{_ord_init} to loop from 0 to 255.} +In the now distant past, +at least one minicomputer manufacturer +@c Pr1me, blech +used ASCII, but with mark parity, meaning that the leftmost bit in the byte +is always 1. This means that on those systems, characters +have numeric values from 128 to 255. +Finally, large mainframe systems use the EBCDIC character set, which +uses all 256 values. +While there are other character sets in use on some older systems, +they are not really worth worrying about: + +@example +@c file eg/lib/ord.awk +function ord(str, c) +@{ + # only first character is of interest + c = substr(str, 1, 1) + return _ord_[c] +@} + +function chr(c) +@{ + # force c to be numeric by adding 0 + return sprintf("%c", c + 0) +@} +@c endfile + +#### test code #### +# BEGIN \ +# @{ +# for (;;) @{ +# printf("enter a character: ") +# if (getline var <= 0) +# break +# printf("ord(%s) = %d\n", var, ord(var)) +# @} +# @} +@c endfile +@end example + +An obvious improvement to these functions is to move the code for the +@code{@w{_ord_init}} function into the body of the @code{BEGIN} rule. It was +written this way initially for ease of development. +There is a ``test program'' in a @code{BEGIN} rule, to test the +function. It is commented out for production use. + +@node Join Function +@subsection Merging an Array into a String + +@cindex libraries of @command{awk} functions, merging arrays into strings +@cindex functions, library, merging arrays into strings +@cindex strings, merging arrays into +@cindex arrays, merging into strings +When doing string processing, it is often useful to be able to join +all the strings in an array into one long string. The following function, +@code{join()}, accomplishes this task. It is used later in several of +the application programs +(@pxref{Sample Programs}). + +Good function design is important; this function needs to be general but it +should also have a reasonable default behavior. It is called with an array +as well as the beginning and ending indices of the elements in the array to be +merged. This assumes that the array indices are numeric---a reasonable +assumption since the array was likely created with @code{split()} +(@pxref{String Functions}): + +@cindex @code{join()} user-defined function +@example +@c file eg/lib/join.awk +# join.awk --- join an array into a string +@c endfile +@ignore +@c file eg/lib/join.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# May 1993 +@c endfile +@end ignore +@c file eg/lib/join.awk + +function join(array, start, end, sep, result, i) +@{ + if (sep == "") + sep = " " + else if (sep == SUBSEP) # magic value + sep = "" + result = array[start] + for (i = start + 1; i <= end; i++) + result = result sep array[i] + return result +@} +@c endfile +@end example + +An optional additional argument is the separator to use when joining the +strings back together. If the caller supplies a nonempty value, +@code{join()} uses it; if it is not supplied, it has a null +value. In this case, @code{join()} uses a single space as a default +separator for the strings. If the value is equal to @code{SUBSEP}, +then @code{join()} joins the strings with no separator between them. +@code{SUBSEP} serves as a ``magic'' value to indicate that there should +be no separation between the component strings.@footnote{It would +be nice if @command{awk} had an assignment operator for concatenation. +The lack of an explicit operator for concatenation makes string operations +more difficult than they really need to be.} + +@node Gettimeofday Function +@subsection Managing the Time of Day + +@cindex libraries of @command{awk} functions, managing, time +@cindex functions, library, managing time +@cindex timestamps, formatted +@cindex time, managing +The @code{systime()} and @code{strftime()} functions described in +@ref{Time Functions}, +provide the minimum functionality necessary for dealing with the time of day +in human readable form. While @code{strftime()} is extensive, the control +formats are not necessarily easy to remember or intuitively obvious when +reading a program. + +The following function, @code{gettimeofday()}, populates a user-supplied array +with preformatted time information. It returns a string with the current +time formatted in the same way as the @command{date} utility: + +@cindex @code{gettimeofday()} user-defined function +@example +@c file eg/lib/gettime.awk +# gettimeofday.awk --- get the time of day in a usable format +@c endfile +@ignore +@c file eg/lib/gettime.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain, May 1993 +# +@c endfile +@end ignore +@c file eg/lib/gettime.awk + +# Returns a string in the format of output of date(1) +# Populates the array argument time with individual values: +# time["second"] -- seconds (0 - 59) +# time["minute"] -- minutes (0 - 59) +# time["hour"] -- hours (0 - 23) +# time["althour"] -- hours (0 - 12) +# time["monthday"] -- day of month (1 - 31) +# time["month"] -- month of year (1 - 12) +# time["monthname"] -- name of the month +# time["shortmonth"] -- short name of the month +# time["year"] -- year modulo 100 (0 - 99) +# time["fullyear"] -- full year +# time["weekday"] -- day of week (Sunday = 0) +# time["altweekday"] -- day of week (Monday = 0) +# time["dayname"] -- name of weekday +# time["shortdayname"] -- short name of weekday +# time["yearday"] -- day of year (0 - 365) +# time["timezone"] -- abbreviation of timezone name +# time["ampm"] -- AM or PM designation +# time["weeknum"] -- week number, Sunday first day +# time["altweeknum"] -- week number, Monday first day + +function gettimeofday(time, ret, now, i) +@{ + # get time once, avoids unnecessary system calls + now = systime() + + # return date(1)-style output + ret = strftime("%a %b %e %H:%M:%S %Z %Y", now) + + # clear out target array + delete time + + # fill in values, force numeric values to be + # numeric by adding 0 + time["second"] = strftime("%S", now) + 0 + time["minute"] = strftime("%M", now) + 0 + time["hour"] = strftime("%H", now) + 0 + time["althour"] = strftime("%I", now) + 0 + time["monthday"] = strftime("%d", now) + 0 + time["month"] = strftime("%m", now) + 0 + time["monthname"] = strftime("%B", now) + time["shortmonth"] = strftime("%b", now) + time["year"] = strftime("%y", now) + 0 + time["fullyear"] = strftime("%Y", now) + 0 + time["weekday"] = strftime("%w", now) + 0 + time["altweekday"] = strftime("%u", now) + 0 + time["dayname"] = strftime("%A", now) + time["shortdayname"] = strftime("%a", now) + time["yearday"] = strftime("%j", now) + 0 + time["timezone"] = strftime("%Z", now) + time["ampm"] = strftime("%p", now) + time["weeknum"] = strftime("%U", now) + 0 + time["altweeknum"] = strftime("%W", now) + 0 + + return ret +@} +@c endfile +@end example + +The string indices are easier to use and read than the various formats +required by @code{strftime()}. The @code{alarm} program presented in +@ref{Alarm Program}, +uses this function. +A more general design for the @code{gettimeofday()} function would have +allowed the user to supply an optional timestamp value to use instead +of the current time. + +@node Data File Management +@section @value{DDF} Management + +@c STARTOFRANGE dataf +@cindex files, managing +@c STARTOFRANGE libfdataf +@cindex libraries of @command{awk} functions, managing, @value{DF}s +@c STARTOFRANGE flibdataf +@cindex functions, library, managing @value{DF}s +This @value{SECTION} presents functions that are useful for managing +command-line @value{DF}s. + +@menu +* Filetrans Function:: A function for handling data file transitions. +* Rewind Function:: A function for rereading the current file. +* File Checking:: Checking that data files are readable. +* Empty Files:: Checking for zero-length files. +* Ignoring Assigns:: Treating assignments as file names. +@end menu + +@node Filetrans Function +@subsection Noting @value{DDF} Boundaries + +@cindex files, managing, @value{DF} boundaries +@cindex files, initialization and cleanup +The @code{BEGIN} and @code{END} rules are each executed exactly once at +the beginning and end of your @command{awk} program, respectively +(@pxref{BEGIN/END}). +We (the @command{gawk} authors) once had a user who mistakenly thought that the +@code{BEGIN} rule is executed at the beginning of each @value{DF} and the +@code{END} rule is executed at the end of each @value{DF}. + +When informed +that this was not the case, the user requested that we add new special +patterns to @command{gawk}, named @code{BEGIN_FILE} and @code{END_FILE}, that +would have the desired behavior. He even supplied us the code to do so. + +Adding these special patterns to @command{gawk} wasn't necessary; +the job can be done cleanly in @command{awk} itself, as illustrated +by the following library program. +It arranges to call two user-supplied functions, @code{beginfile()} and +@code{endfile()}, at the beginning and end of each @value{DF}. +Besides solving the problem in only nine(!) lines of code, it does so +@emph{portably}; this works with any implementation of @command{awk}: + +@example +# transfile.awk +# +# Give the user a hook for filename transitions +# +# The user must supply functions beginfile() and endfile() +# that each take the name of the file being started or +# finished, respectively. +@c # +@c # Arnold Robbins, arnold@@skeeve.com, Public Domain +@c # January 1992 + +FILENAME != _oldfilename \ +@{ + if (_oldfilename != "") + endfile(_oldfilename) + _oldfilename = FILENAME + beginfile(FILENAME) +@} + +END @{ endfile(FILENAME) @} +@end example + +This file must be loaded before the user's ``main'' program, so that the +rule it supplies is executed first. + +This rule relies on @command{awk}'s @code{FILENAME} variable that +automatically changes for each new @value{DF}. The current @value{FN} is +saved in a private variable, @code{_oldfilename}. If @code{FILENAME} does +not equal @code{_oldfilename}, then a new @value{DF} is being processed and +it is necessary to call @code{endfile()} for the old file. Because +@code{endfile()} should only be called if a file has been processed, the +program first checks to make sure that @code{_oldfilename} is not the null +string. The program then assigns the current @value{FN} to +@code{_oldfilename} and calls @code{beginfile()} for the file. +Because, like all @command{awk} variables, @code{_oldfilename} is +initialized to the null string, this rule executes correctly even for the +first @value{DF}. + +The program also supplies an @code{END} rule to do the final processing for +the last file. Because this @code{END} rule comes before any @code{END} rules +supplied in the ``main'' program, @code{endfile()} is called first. Once +again the value of multiple @code{BEGIN} and @code{END} rules should be clear. + +@cindex @code{beginfile()} user-defined function +@cindex @code{endfile()} user-defined function +If the same @value{DF} occurs twice in a row on the command line, then +@code{endfile()} and @code{beginfile()} are not executed at the end of the +first pass and at the beginning of the second pass. +The following version solves the problem: + +@example +@c file eg/lib/ftrans.awk +# ftrans.awk --- handle data file transitions +# +# user supplies beginfile() and endfile() functions +@c endfile +@ignore +@c file eg/lib/ftrans.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# November 1992 +@c endfile +@end ignore +@c file eg/lib/ftrans.awk + +FNR == 1 @{ + if (_filename_ != "") + endfile(_filename_) + _filename_ = FILENAME + beginfile(FILENAME) +@} + +END @{ endfile(_filename_) @} +@c endfile +@end example + +@ref{Wc Program}, +shows how this library function can be used and +how it simplifies writing the main program. + +@c fakenode --- for prepinfo +@subheading Advanced Notes: So Why Does @command{gawk} have @code{BEGINFILE} and @code{ENDFILE}? + +You are probably wondering, if @code{beginfile()} and @code{endfile()} +functions can do the job, why does @command{gawk} have +@code{BEGINFILE} and @code{ENDFILE} patterns (@pxref{BEGINFILE/ENDFILE})? + +Good question. Normally, if @command{awk} cannot open a file, this +causes an immediate fatal error. In this case, there is no way for a +user-defined function to deal with the problem, since the mechanism for +calling it relies on the file being open and at the first record. Thus, +the main reason for @code{BEGINFILE} is to give you a ``hook'' to catch +files that cannot be processed. @code{ENDFILE} exists for symmetry, +and because it provides an easy way to do per-file cleanup processing. + +@node Rewind Function +@subsection Rereading the Current File + +@cindex files, reading +Another request for a new built-in function was for a @code{rewind()} +function that would make it possible to reread the current file. +The requesting user didn't want to have to use @code{getline} +(@pxref{Getline}) +inside a loop. + +However, as long as you are not in the @code{END} rule, it is +quite easy to arrange to immediately close the current input file +and then start over with it from the top. +For lack of a better name, we'll call it @code{rewind()}: + +@cindex @code{rewind()} user-defined function +@example +@c file eg/lib/rewind.awk +# rewind.awk --- rewind the current file and start over +@c endfile +@ignore +@c file eg/lib/rewind.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# September 2000 +@c endfile +@end ignore +@c file eg/lib/rewind.awk + +function rewind( i) +@{ + # shift remaining arguments up + for (i = ARGC; i > ARGIND; i--) + ARGV[i] = ARGV[i-1] + + # make sure gawk knows to keep going + ARGC++ + + # make current file next to get done + ARGV[ARGIND+1] = FILENAME + + # do it + nextfile +@} +@c endfile +@end example + +This code relies on the @code{ARGIND} variable +(@pxref{Auto-set}), +which is specific to @command{gawk}. +If you are not using +@command{gawk}, you can use ideas presented in +@ifnotinfo +the previous @value{SECTION} +@end ifnotinfo +@ifinfo +@ref{Filetrans Function}, +@end ifinfo +to either update @code{ARGIND} on your own +or modify this code as appropriate. + +The @code{rewind()} function also relies on the @code{nextfile} keyword +(@pxref{Nextfile Statement}). + +@node File Checking +@subsection Checking for Readable @value{DDF}s + +@cindex troubleshooting, readable @value{DF}s +@cindex readable @value{DF}s@comma{} checking +@cindex files, skipping +Normally, if you give @command{awk} a @value{DF} that isn't readable, +it stops with a fatal error. There are times when you +might want to just ignore such files and keep going. You can +do this by prepending the following program to your @command{awk} +program: + +@cindex @code{readable.awk} program +@example +@c file eg/lib/readable.awk +# readable.awk --- library file to skip over unreadable files +@c endfile +@ignore +@c file eg/lib/readable.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# October 2000 +# December 2010 +@c endfile +@end ignore +@c file eg/lib/readable.awk + +BEGIN @{ + for (i = 1; i < ARGC; i++) @{ + if (ARGV[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/ \ + || ARGV[i] == "-" || ARGV[i] == "/dev/stdin") + continue # assignment or standard input + else if ((getline junk < ARGV[i]) < 0) # unreadable + delete ARGV[i] + else + close(ARGV[i]) + @} +@} +@c endfile +@end example + +@cindex troubleshooting, @code{getline} function +This works, because the @code{getline} won't be fatal. +Removing the element from @code{ARGV} with @code{delete} +skips the file (since it's no longer in the list). +See also @ref{ARGC and ARGV}. + +@node Empty Files +@subsection Checking For Zero-length Files + +All known @command{awk} implementations silently skip over zero-length files. +This is a by-product of @command{awk}'s implicit +read-a-record-and-match-against-the-rules loop: when @command{awk} +tries to read a record from an empty file, it immediately receives an +end of file indication, closes the file, and proceeds on to the next +command-line @value{DF}, @emph{without} executing any user-level +@command{awk} program code. + +Using @command{gawk}'s @code{ARGIND} variable +(@pxref{Built-in Variables}), it is possible to detect when an empty +@value{DF} has been skipped. Similar to the library file presented +in @ref{Filetrans Function}, the following library file calls a function named +@code{zerofile()} that the user must provide. The arguments passed are +the @value{FN} and the position in @code{ARGV} where it was found: + +@cindex @code{zerofile.awk} program +@example +@c file eg/lib/zerofile.awk +# zerofile.awk --- library file to process empty input files +@c endfile +@ignore +@c file eg/lib/zerofile.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# June 2003 +@c endfile +@end ignore +@c file eg/lib/zerofile.awk + +BEGIN @{ Argind = 0 @} + +ARGIND > Argind + 1 @{ + for (Argind++; Argind < ARGIND; Argind++) + zerofile(ARGV[Argind], Argind) +@} + +ARGIND != Argind @{ Argind = ARGIND @} + +END @{ + if (ARGIND > Argind) + for (Argind++; Argind <= ARGIND; Argind++) + zerofile(ARGV[Argind], Argind) +@} +@c endfile +@end example + +The user-level variable @code{Argind} allows the @command{awk} program +to track its progress through @code{ARGV}. Whenever the program detects +that @code{ARGIND} is greater than @samp{Argind + 1}, it means that one or +more empty files were skipped. The action then calls @code{zerofile()} for +each such file, incrementing @code{Argind} along the way. + +The @samp{Argind != ARGIND} rule simply keeps @code{Argind} up to date +in the normal case. + +Finally, the @code{END} rule catches the case of any empty files at +the end of the command-line arguments. Note that the test in the +condition of the @code{for} loop uses the @samp{<=} operator, +not @samp{<}. + +As an exercise, you might consider whether this same problem can +be solved without relying on @command{gawk}'s @code{ARGIND} variable. + +As a second exercise, revise this code to handle the case where +an intervening value in @code{ARGV} is a variable assignment. + +@ignore +# zerofile2.awk --- same thing, portably + +BEGIN @{ + ARGIND = Argind = 0 + for (i = 1; i < ARGC; i++) + Fnames[ARGV[i]]++ + +@} +FNR == 1 @{ + while (ARGV[ARGIND] != FILENAME) + ARGIND++ + Seen[FILENAME]++ + if (Seen[FILENAME] == Fnames[FILENAME]) + do + ARGIND++ + while (ARGV[ARGIND] != FILENAME) +@} +ARGIND > Argind + 1 @{ + for (Argind++; Argind < ARGIND; Argind++) + zerofile(ARGV[Argind], Argind) +@} +ARGIND != Argind @{ + Argind = ARGIND +@} +END @{ + if (ARGIND < ARGC - 1) + ARGIND = ARGC - 1 + if (ARGIND > Argind) + for (Argind++; Argind <= ARGIND; Argind++) + zerofile(ARGV[Argind], Argind) +@} +@end ignore + +@node Ignoring Assigns +@subsection Treating Assignments as @value{FFN}s + +@cindex assignments as filenames +@cindex filenames, assignments as +Occasionally, you might not want @command{awk} to process command-line +variable assignments +(@pxref{Assignment Options}). +In particular, if you have a @value{FN} that contain an @samp{=} character, +@command{awk} treats the @value{FN} as an assignment, and does not process it. + +Some users have suggested an additional command-line option for @command{gawk} +to disable command-line assignments. However, some simple programming with +a library file does the trick: + +@cindex @code{noassign.awk} program +@example +@c file eg/lib/noassign.awk +# noassign.awk --- library file to avoid the need for a +# special option that disables command-line assignments +@c endfile +@ignore +@c file eg/lib/noassign.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# October 1999 +@c endfile +@end ignore +@c file eg/lib/noassign.awk + +function disable_assigns(argc, argv, i) +@{ + for (i = 1; i < argc; i++) + if (argv[i] ~ /^[[:alpha:]_][[:alnum:]_]*=.*/) + argv[i] = ("./" argv[i]) +@} + +BEGIN @{ + if (No_command_assign) + disable_assigns(ARGC, ARGV) +@} +@c endfile +@end example + +You then run your program this way: + +@example +awk -v No_command_assign=1 -f noassign.awk -f yourprog.awk * +@end example + +The function works by looping through the arguments. +It prepends @samp{./} to +any argument that matches the form +of a variable assignment, turning that argument into a @value{FN}. + +The use of @code{No_command_assign} allows you to disable command-line +assignments at invocation time, by giving the variable a true value. +When not set, it is initially zero (i.e., false), so the command-line arguments +are left alone. +@c ENDOFRANGE dataf +@c ENDOFRANGE flibdataf +@c ENDOFRANGE libfdataf + +@node Getopt Function +@section Processing Command-Line Options + +@c STARTOFRANGE libfclo +@cindex libraries of @command{awk} functions, command-line options +@c STARTOFRANGE flibclo +@cindex functions, library, command-line options +@c STARTOFRANGE clop +@cindex command-line options, processing +@c STARTOFRANGE oclp +@cindex options, command-line, processing +@c STARTOFRANGE clibf +@cindex functions, library, C library +@cindex arguments, processing +Most utilities on POSIX compatible systems take options on +the command line that can be used to change the way a program behaves. +@command{awk} is an example of such a program +(@pxref{Options}). +Often, options take @dfn{arguments}; i.e., data that the program needs to +correctly obey the command-line option. For example, @command{awk}'s +@option{-F} option requires a string to use as the field separator. +The first occurrence on the command line of either @option{--} or a +string that does not begin with @samp{-} ends the options. + +@cindex @code{getopt()} function (C library) +Modern Unix systems provide a C function named @code{getopt()} for processing +command-line arguments. The programmer provides a string describing the +one-letter options. If an option requires an argument, it is followed in the +string with a colon. @code{getopt()} is also passed the +count and values of the command-line arguments and is called in a loop. +@code{getopt()} processes the command-line arguments for option letters. +Each time around the loop, it returns a single character representing the +next option letter that it finds, or @samp{?} if it finds an invalid option. +When it returns @minus{}1, there are no options left on the command line. + +When using @code{getopt()}, options that do not take arguments can be +grouped together. Furthermore, options that take arguments require that the +argument be present. The argument can immediately follow the option letter, +or it can be a separate command-line argument. + +Given a hypothetical program that takes +three command-line options, @option{-a}, @option{-b}, and @option{-c}, where +@option{-b} requires an argument, all of the following are valid ways of +invoking the program: + +@example +prog -a -b foo -c data1 data2 data3 +prog -ac -bfoo -- data1 data2 data3 +prog -acbfoo data1 data2 data3 +@end example + +Notice that when the argument is grouped with its option, the rest of +the argument is considered to be the option's argument. +In this example, @option{-acbfoo} indicates that all of the +@option{-a}, @option{-b}, and @option{-c} options were supplied, +and that @samp{foo} is the argument to the @option{-b} option. + +@code{getopt()} provides four external variables that the programmer can use: + +@table @code +@item optind +The index in the argument value array (@code{argv}) where the first +nonoption command-line argument can be found. + +@item optarg +The string value of the argument to an option. + +@item opterr +Usually @code{getopt()} prints an error message when it finds an invalid +option. Setting @code{opterr} to zero disables this feature. (An +application might want to print its own error message.) + +@item optopt +The letter representing the command-line option. +@c While not usually documented, most versions supply this variable. +@end table + +The following C fragment shows how @code{getopt()} might process command-line +arguments for @command{awk}: + +@example +int +main(int argc, char *argv[]) +@{ + @dots{} + /* print our own message */ + opterr = 0; + while ((c = getopt(argc, argv, "v:f:F:W:")) != -1) @{ + switch (c) @{ + case 'f': /* file */ + @dots{} + break; + case 'F': /* field separator */ + @dots{} + break; + case 'v': /* variable assignment */ + @dots{} + break; + case 'W': /* extension */ + @dots{} + break; + case '?': + default: + usage(); + break; + @} + @} + @dots{} +@} +@end example + +As a side point, @command{gawk} actually uses the GNU @code{getopt_long()} +function to process both normal and GNU-style long options +(@pxref{Options}). + +The abstraction provided by @code{getopt()} is very useful and is quite +handy in @command{awk} programs as well. Following is an @command{awk} +version of @code{getopt()}. This function highlights one of the +greatest weaknesses in @command{awk}, which is that it is very poor at +manipulating single characters. Repeated calls to @code{substr()} are +necessary for accessing individual characters +(@pxref{String Functions}).@footnote{This +function was written before @command{gawk} acquired the ability to +split strings into single characters using @code{""} as the separator. +We have left it alone, since using @code{substr()} is more portable.} +@c FIXME: could use split(str, a, "") to do it more easily. + +The discussion that follows walks through the code a bit at a time: + +@cindex @code{getopt()} user-defined function +@example +@c file eg/lib/getopt.awk +# getopt.awk --- Do C library getopt(3) function in awk +@c endfile +@ignore +@c file eg/lib/getopt.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# +# Initial version: March, 1991 +# Revised: May, 1993 +@c endfile +@end ignore +@c file eg/lib/getopt.awk + +# External variables: +# Optind -- index in ARGV of first nonoption argument +# Optarg -- string value of argument to current option +# Opterr -- if nonzero, print our own diagnostic +# Optopt -- current option letter + +# Returns: +# -1 at end of options +# "?" for unrecognized option +# a character representing the current option + +# Private Data: +# _opti -- index in multi-flag option, e.g., -abc +@c endfile +@end example + +The function starts out with comments presenting +a list of the global variables it uses, +what the return values are, what they mean, and any global variables that +are ``private'' to this library function. Such documentation is essential +for any program, and particularly for library functions. + +The @code{getopt()} function first checks that it was indeed called with +a string of options (the @code{options} parameter). If @code{options} +has a zero length, @code{getopt()} immediately returns @minus{}1: + +@cindex @code{getopt()} user-defined function +@example +@c file eg/lib/getopt.awk +function getopt(argc, argv, options, thisopt, i) +@{ + if (length(options) == 0) # no options given + return -1 + +@group + if (argv[Optind] == "--") @{ # all done + Optind++ + _opti = 0 + return -1 +@end group + @} else if (argv[Optind] !~ /^-[^:[:space:]]/) @{ + _opti = 0 + return -1 + @} +@c endfile +@end example + +The next thing to check for is the end of the options. A @option{--} +ends the command-line options, as does any command-line argument that +does not begin with a @samp{-}. @code{Optind} is used to step through +the array of command-line arguments; it retains its value across calls +to @code{getopt()}, because it is a global variable. + +The regular expression that is used, @code{@w{/^-[^:[:space:]/}}, +checks for a @samp{-} followed by anything +that is not whitespace and not a colon. +If the current command-line argument does not match this pattern, +it is not an option, and it ends option processing. Continuing on: + +@example +@c file eg/lib/getopt.awk + if (_opti == 0) + _opti = 2 + thisopt = substr(argv[Optind], _opti, 1) + Optopt = thisopt + i = index(options, thisopt) + if (i == 0) @{ + if (Opterr) + printf("%c -- invalid option\n", + thisopt) > "/dev/stderr" + if (_opti >= length(argv[Optind])) @{ + Optind++ + _opti = 0 + @} else + _opti++ + return "?" + @} +@c endfile +@end example + +The @code{_opti} variable tracks the position in the current command-line +argument (@code{argv[Optind]}). If multiple options are +grouped together with one @samp{-} (e.g., @option{-abx}), it is necessary +to return them to the user one at a time. + +If @code{_opti} is equal to zero, it is set to two, which is the index in +the string of the next character to look at (we skip the @samp{-}, which +is at position one). The variable @code{thisopt} holds the character, +obtained with @code{substr()}. It is saved in @code{Optopt} for the main +program to use. + +If @code{thisopt} is not in the @code{options} string, then it is an +invalid option. If @code{Opterr} is nonzero, @code{getopt()} prints an error +message on the standard error that is similar to the message from the C +version of @code{getopt()}. + +Because the option is invalid, it is necessary to skip it and move on to the +next option character. If @code{_opti} is greater than or equal to the +length of the current command-line argument, it is necessary to move on +to the next argument, so @code{Optind} is incremented and @code{_opti} is reset +to zero. Otherwise, @code{Optind} is left alone and @code{_opti} is merely +incremented. + +In any case, because the option is invalid, @code{getopt()} returns @code{"?"}. +The main program can examine @code{Optopt} if it needs to know what the +invalid option letter actually is. Continuing on: + +@example +@c file eg/lib/getopt.awk + if (substr(options, i + 1, 1) == ":") @{ + # get option argument + if (length(substr(argv[Optind], _opti + 1)) > 0) + Optarg = substr(argv[Optind], _opti + 1) + else + Optarg = argv[++Optind] + _opti = 0 + @} else + Optarg = "" +@c endfile +@end example + +If the option requires an argument, the option letter is followed by a colon +in the @code{options} string. If there are remaining characters in the +current command-line argument (@code{argv[Optind]}), then the rest of that +string is assigned to @code{Optarg}. Otherwise, the next command-line +argument is used (@samp{-xFOO} versus @samp{@w{-x FOO}}). In either case, +@code{_opti} is reset to zero, because there are no more characters left to +examine in the current command-line argument. Continuing: + +@example +@c file eg/lib/getopt.awk + if (_opti == 0 || _opti >= length(argv[Optind])) @{ + Optind++ + _opti = 0 + @} else + _opti++ + return thisopt +@} +@c endfile +@end example + +Finally, if @code{_opti} is either zero or greater than the length of the +current command-line argument, it means this element in @code{argv} is +through being processed, so @code{Optind} is incremented to point to the +next element in @code{argv}. If neither condition is true, then only +@code{_opti} is incremented, so that the next option letter can be processed +on the next call to @code{getopt()}. + +The @code{BEGIN} rule initializes both @code{Opterr} and @code{Optind} to one. +@code{Opterr} is set to one, since the default behavior is for @code{getopt()} +to print a diagnostic message upon seeing an invalid option. @code{Optind} +is set to one, since there's no reason to look at the program name, which is +in @code{ARGV[0]}: + +@example +@c file eg/lib/getopt.awk +BEGIN @{ + Opterr = 1 # default is to diagnose + Optind = 1 # skip ARGV[0] + + # test program + if (_getopt_test) @{ + while ((_go_c = getopt(ARGC, ARGV, "ab:cd")) != -1) + printf("c = <%c>, optarg = <%s>\n", + _go_c, Optarg) + printf("non-option arguments:\n") + for (; Optind < ARGC; Optind++) + printf("\tARGV[%d] = <%s>\n", + Optind, ARGV[Optind]) + @} +@} +@c endfile +@end example + +The rest of the @code{BEGIN} rule is a simple test program. Here is the +result of two sample runs of the test program: + +@example +$ @kbd{awk -f getopt.awk -v _getopt_test=1 -- -a -cbARG bax -x} +@print{} c =
, optarg = <> +@print{} c = , optarg = <> +@print{} c = , optarg = +@print{} non-option arguments: +@print{} ARGV[3] = +@print{} ARGV[4] = <-x> + +$ @kbd{awk -f getopt.awk -v _getopt_test=1 -- -a -x -- xyz abc} +@print{} c = , optarg = <> +@error{} x -- invalid option +@print{} c = , optarg = <> +@print{} non-option arguments: +@print{} ARGV[4] = +@print{} ARGV[5] = +@end example + +In both runs, +the first @option{--} terminates the arguments to @command{awk}, so that it does +not try to interpret the @option{-a}, etc., as its own options. + +@quotation NOTE +After @code{getopt()} is through, it is the responsibility of the user level +code to +clear out all the elements of @code{ARGV} from 1 to @code{Optind}, +so that @command{awk} does not try to process the command-line options +as @value{FN}s. +@end quotation + +Several of the sample programs presented in +@ref{Sample Programs}, +use @code{getopt()} to process their arguments. +@c ENDOFRANGE libfclo +@c ENDOFRANGE flibclo +@c ENDOFRANGE clop +@c ENDOFRANGE oclp + +@node Passwd Functions +@section Reading the User Database + +@c STARTOFRANGE libfudata +@cindex libraries of @command{awk} functions, user database, reading +@c STARTOFRANGE flibudata +@cindex functions, library, user database, reading +@c STARTOFRANGE udatar +@cindex user database@comma{} reading +@c STARTOFRANGE dataur +@cindex database, users@comma{} reading +@cindex @code{PROCINFO} array +The @code{PROCINFO} array +(@pxref{Built-in Variables}) +provides access to the current user's real and effective user and group ID +numbers, and if available, the user's supplementary group set. +However, because these are numbers, they do not provide very useful +information to the average user. There needs to be some way to find the +user information associated with the user and group ID numbers. This +@value{SECTION} presents a suite of functions for retrieving information from the +user database. @xref{Group Functions}, +for a similar suite that retrieves information from the group database. + +@cindex @code{getpwent()} function (C library) +@cindex @code{getpwent()} user-defined function +@cindex users, information about, retrieving +@cindex login information +@cindex account information +@cindex password file +@cindex files, password +The POSIX standard does not define the file where user information is +kept. Instead, it provides the @code{} header file +and several C language subroutines for obtaining user information. +The primary function is @code{getpwent()}, for ``get password entry.'' +The ``password'' comes from the original user database file, +@file{/etc/passwd}, which stores user information, along with the +encrypted passwords (hence the name). + +@cindex @command{pwcat} program +While an @command{awk} program could simply read @file{/etc/passwd} +directly, this file may not contain complete information about the +system's set of users.@footnote{It is often the case that password +information is stored in a network database.} To be sure you are able to +produce a readable and complete version of the user database, it is necessary +to write a small C program that calls @code{getpwent()}. @code{getpwent()} +is defined as returning a pointer to a @code{struct passwd}. Each time it +is called, it returns the next entry in the database. When there are +no more entries, it returns @code{NULL}, the null pointer. When this +happens, the C program should call @code{endpwent()} to close the database. +Following is @command{pwcat}, a C program that ``cats'' the password database: + +@c Use old style function header for portability to old systems (SunOS, HP/UX). + +@example +@c file eg/lib/pwcat.c +/* + * pwcat.c + * + * Generate a printable version of the password database + */ +@c endfile +@ignore +@c file eg/lib/pwcat.c +/* + * Arnold Robbins, arnold@@skeeve.com, May 1993 + * Public Domain + * December 2010, move to ANSI C definition for main(). + */ + +#if HAVE_CONFIG_H +#include +#endif + +@c endfile +@end ignore +@c file eg/lib/pwcat.c +#include +#include + +@c endfile +@ignore +@c file eg/lib/pwcat.c +#if defined (STDC_HEADERS) +#include +#endif + +@c endfile +@end ignore +@c file eg/lib/pwcat.c +int +main(int argc, char **argv) +@{ + struct passwd *p; + + while ((p = getpwent()) != NULL) +@c endfile +@ignore +@c file eg/lib/pwcat.c +#ifdef ZOS_USS + printf("%s:%ld:%ld:%s:%s\n", + p->pw_name, (long) p->pw_uid, + (long) p->pw_gid, p->pw_dir, p->pw_shell); +#else +@c endfile +@end ignore +@c file eg/lib/pwcat.c + printf("%s:%s:%ld:%ld:%s:%s:%s\n", + p->pw_name, p->pw_passwd, (long) p->pw_uid, + (long) p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell); +@c endfile +@ignore +@c file eg/lib/pwcat.c +#endif +@c endfile +@end ignore +@c file eg/lib/pwcat.c + + endpwent(); + return 0; +@} +@c endfile +@end example + +If you don't understand C, don't worry about it. +The output from @command{pwcat} is the user database, in the traditional +@file{/etc/passwd} format of colon-separated fields. The fields are: + +@table @asis +@item Login name +The user's login name. + +@item Encrypted password +The user's encrypted password. This may not be available on some systems. + +@item User-ID +The user's numeric user ID number. +(On some systems it's a C @code{long}, and not an @code{int}. Thus +we cast it to @code{long} for all cases.) + +@item Group-ID +The user's numeric group ID number. +(Similar comments about @code{long} vs.@: @code{int} apply here.) + +@item Full name +The user's full name, and perhaps other information associated with the +user. + +@item Home directory +The user's login (or ``home'') directory (familiar to shell programmers as +@code{$HOME}). + +@item Login shell +The program that is run when the user logs in. This is usually a +shell, such as Bash. +@end table + +A few lines representative of @command{pwcat}'s output are as follows: + +@cindex Jacobs, Andrew +@cindex Robbins, Arnold +@cindex Robbins, Miriam +@example +$ @kbd{pwcat} +@print{} root:3Ov02d5VaUPB6:0:1:Operator:/:/bin/sh +@print{} nobody:*:65534:65534::/: +@print{} daemon:*:1:1::/: +@print{} sys:*:2:2::/:/bin/csh +@print{} bin:*:3:3::/bin: +@print{} arnold:xyzzy:2076:10:Arnold Robbins:/home/arnold:/bin/sh +@print{} miriam:yxaay:112:10:Miriam Robbins:/home/miriam:/bin/sh +@print{} andy:abcca2:113:10:Andy Jacobs:/home/andy:/bin/sh +@dots{} +@end example + +With that introduction, following is a group of functions for getting user +information. There are several functions here, corresponding to the C +functions of the same names: + +@cindex @code{_pw_init()} user-defined function +@example +@c file eg/lib/passwdawk.in +# passwd.awk --- access password file information +@c endfile +@ignore +@c file eg/lib/passwdawk.in +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# May 1993 +# Revised October 2000 +# Revised December 2010 +@c endfile +@end ignore +@c file eg/lib/passwdawk.in + +BEGIN @{ + # tailor this to suit your system + _pw_awklib = "/usr/local/libexec/awk/" +@} + +function _pw_init( oldfs, oldrs, olddol0, pwcat, using_fw, using_fpat) +@{ + if (_pw_inited) + return + + oldfs = FS + oldrs = RS + olddol0 = $0 + using_fw = (PROCINFO["FS"] == "FIELDWIDTHS") + using_fpat = (PROCINFO["FS"] == "FPAT") + FS = ":" + RS = "\n" + + pwcat = _pw_awklib "pwcat" + while ((pwcat | getline) > 0) @{ + _pw_byname[$1] = $0 + _pw_byuid[$3] = $0 + _pw_bycount[++_pw_total] = $0 + @} + close(pwcat) + _pw_count = 0 + _pw_inited = 1 + FS = oldfs + if (using_fw) + FIELDWIDTHS = FIELDWIDTHS + else if (using_fpat) + FPAT = FPAT + RS = oldrs + $0 = olddol0 +@} +@c endfile +@end example + +@cindex @code{BEGIN} pattern, @code{pwcat} program +The @code{BEGIN} rule sets a private variable to the directory where +@command{pwcat} is stored. Because it is used to help out an @command{awk} library +routine, we have chosen to put it in @file{/usr/local/libexec/awk}; +however, you might want it to be in a different directory on your system. + +The function @code{_pw_init()} keeps three copies of the user information +in three associative arrays. The arrays are indexed by username +(@code{_pw_byname}), by user ID number (@code{_pw_byuid}), and by order of +occurrence (@code{_pw_bycount}). +The variable @code{_pw_inited} is used for efficiency, since @code{_pw_init()} +needs to be called only once. + +@cindex @code{getline} command, @code{_pw_init()} function +Because this function uses @code{getline} to read information from +@command{pwcat}, it first saves the values of @code{FS}, @code{RS}, and @code{$0}. +It notes in the variable @code{using_fw} whether field splitting +with @code{FIELDWIDTHS} is in effect or not. +Doing so is necessary, since these functions could be called +from anywhere within a user's program, and the user may have his +or her +own way of splitting records and fields. + +@cindex @code{PROCINFO} array +The @code{using_fw} variable checks @code{PROCINFO["FS"]}, which +is @code{"FIELDWIDTHS"} if field splitting is being done with +@code{FIELDWIDTHS}. This makes it possible to restore the correct +field-splitting mechanism later. The test can only be true for +@command{gawk}. It is false if using @code{FS} or @code{FPAT}, +or on some other @command{awk} implementation. + +The code that checks for using @code{FPAT}, using @code{using_fpat} +and @code{PROCINFO["FS"]} is similar. + +The main part of the function uses a loop to read database lines, split +the line into fields, and then store the line into each array as necessary. +When the loop is done, @code{@w{_pw_init()}} cleans up by closing the pipeline, +setting @code{@w{_pw_inited}} to one, and restoring @code{FS} +(and @code{FIELDWIDTHS} or @code{FPAT} +if necessary), @code{RS}, and @code{$0}. +The use of @code{@w{_pw_count}} is explained shortly. + +@cindex @code{getpwnam()} function (C library) +The @code{getpwnam()} function takes a username as a string argument. If that +user is in the database, it returns the appropriate line. Otherwise, it +relies on the array reference to a nonexistent +element to create the element with the null string as its value: + +@cindex @code{getpwnam()} user-defined function +@example +@group +@c file eg/lib/passwdawk.in +function getpwnam(name) +@{ + _pw_init() + return _pw_byname[name] +@} +@c endfile +@end group +@end example + +@cindex @code{getpwuid()} function (C library) +Similarly, +the @code{getpwuid} function takes a user ID number argument. If that +user number is in the database, it returns the appropriate line. Otherwise, it +returns the null string: + +@cindex @code{getpwuid()} user-defined function +@example +@c file eg/lib/passwdawk.in +function getpwuid(uid) +@{ + _pw_init() + return _pw_byuid[uid] +@} +@c endfile +@end example + +@cindex @code{getpwent()} function (C library) +The @code{getpwent()} function simply steps through the database, one entry at +a time. It uses @code{_pw_count} to track its current position in the +@code{_pw_bycount} array: + +@cindex @code{getpwent()} user-defined function +@example +@c file eg/lib/passwdawk.in +function getpwent() +@{ + _pw_init() + if (_pw_count < _pw_total) + return _pw_bycount[++_pw_count] + return "" +@} +@c endfile +@end example + +@cindex @code{endpwent()} function (C library) +The @code{@w{endpwent()}} function resets @code{@w{_pw_count}} to zero, so that +subsequent calls to @code{getpwent()} start over again: + +@cindex @code{endpwent()} user-defined function +@example +@c file eg/lib/passwdawk.in +function endpwent() +@{ + _pw_count = 0 +@} +@c endfile +@end example + +A conscious design decision in this suite is that each subroutine calls +@code{@w{_pw_init()}} to initialize the database arrays. +The overhead of running +a separate process to generate the user database, and the I/O to scan it, +are only incurred if the user's main program actually calls one of these +functions. If this library file is loaded along with a user's program, but +none of the routines are ever called, then there is no extra runtime overhead. +(The alternative is move the body of @code{@w{_pw_init()}} into a +@code{BEGIN} rule, which always runs @command{pwcat}. This simplifies the +code but runs an extra process that may never be needed.) + +In turn, calling @code{_pw_init()} is not too expensive, because the +@code{_pw_inited} variable keeps the program from reading the data more than +once. If you are worried about squeezing every last cycle out of your +@command{awk} program, the check of @code{_pw_inited} could be moved out of +@code{_pw_init()} and duplicated in all the other functions. In practice, +this is not necessary, since most @command{awk} programs are I/O-bound, +and such a change would clutter up the code. + +The @command{id} program in @ref{Id Program}, +uses these functions. +@c ENDOFRANGE libfudata +@c ENDOFRANGE flibudata +@c ENDOFRANGE udatar +@c ENDOFRANGE dataur + +@node Group Functions +@section Reading the Group Database + +@c STARTOFRANGE libfgdata +@cindex libraries of @command{awk} functions, group database, reading +@c STARTOFRANGE flibgdata +@cindex functions, library, group database, reading +@c STARTOFRANGE gdatar +@cindex group database, reading +@c STARTOFRANGE datagr +@cindex database, group, reading +@cindex @code{PROCINFO} array +@cindex @code{getgrent()} function (C library) +@cindex @code{getgrent()} user-defined function +@cindex groups@comma{} information about +@cindex account information +@cindex group file +@cindex files, group +Much of the discussion presented in +@ref{Passwd Functions}, +applies to the group database as well. Although there has traditionally +been a well-known file (@file{/etc/group}) in a well-known format, the POSIX +standard only provides a set of C library routines +(@code{} and @code{getgrent()}) +for accessing the information. +Even though this file may exist, it may not have +complete information. Therefore, as with the user database, it is necessary +to have a small C program that generates the group database as its output. +@command{grcat}, a C program that ``cats'' the group database, +is as follows: + +@cindex @command{grcat} program +@example +@c file eg/lib/grcat.c +/* + * grcat.c + * + * Generate a printable version of the group database + */ +@c endfile +@ignore +@c file eg/lib/grcat.c +/* + * Arnold Robbins, arnold@@skeeve.com, May 1993 + * Public Domain + * December 2010, move to ANSI C definition for main(). + */ + +/* For OS/2, do nothing. */ +#if HAVE_CONFIG_H +#include +#endif + +#if defined (STDC_HEADERS) +#include +#endif + +#ifndef HAVE_GETGRENT +int main() { return 0; } +#else +@c endfile +@end ignore +@c file eg/lib/grcat.c +#include +#include + +int +main(int argc, char **argv) +@{ + struct group *g; + int i; + + while ((g = getgrent()) != NULL) @{ +@c endfile +@ignore +@c file eg/lib/grcat.c +#ifdef ZOS_USS + printf("%s:%ld:", g->gr_name, (long) g->gr_gid); +#else +@c endfile +@end ignore +@c file eg/lib/grcat.c + printf("%s:%s:%ld:", g->gr_name, g->gr_passwd, + (long) g->gr_gid); +@c endfile +@ignore +@c file eg/lib/grcat.c +#endif +@c endfile +@end ignore +@c file eg/lib/grcat.c + for (i = 0; g->gr_mem[i] != NULL; i++) @{ + printf("%s", g->gr_mem[i]); +@group + if (g->gr_mem[i+1] != NULL) + putchar(','); + @} +@end group + putchar('\n'); + @} + endgrent(); + return 0; +@} +@c endfile +@ignore +@c file eg/lib/grcat.c +#endif /* HAVE_GETGRENT */ +@c endfile +@end ignore +@end example + +Each line in the group database represents one group. The fields are +separated with colons and represent the following information: + +@table @asis +@item Group Name +The group's name. + +@item Group Password +The group's encrypted password. In practice, this field is never used; +it is usually empty or set to @samp{*}. + +@item Group ID Number +The group's numeric group ID number; +this number must be unique within the file. +(On some systems it's a C @code{long}, and not an @code{int}. Thus +we cast it to @code{long} for all cases.) + +@item Group Member List +A comma-separated list of user names. These users are members of the group. +Modern Unix systems allow users to be members of several groups +simultaneously. If your system does, then there are elements +@code{"group1"} through @code{"group@var{N}"} in @code{PROCINFO} +for those group ID numbers. +(Note that @code{PROCINFO} is a @command{gawk} extension; +@pxref{Built-in Variables}.) +@end table + +Here is what running @command{grcat} might produce: + +@example +$ @kbd{grcat} +@print{} wheel:*:0:arnold +@print{} nogroup:*:65534: +@print{} daemon:*:1: +@print{} kmem:*:2: +@print{} staff:*:10:arnold,miriam,andy +@print{} other:*:20: +@dots{} +@end example + +Here are the functions for obtaining information from the group database. +There are several, modeled after the C library functions of the same names: + +@cindex @code{getline} command, @code{_gr_init()} user-defined function +@cindex @code{_gr_init()} user-defined function +@example +@c file eg/lib/groupawk.in +# group.awk --- functions for dealing with the group file +@c endfile +@ignore +@c file eg/lib/groupawk.in +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# May 1993 +# Revised October 2000 +# Revised December 2010 +@c endfile +@end ignore +@c line break on _gr_init for smallbook +@c file eg/lib/groupawk.in + +BEGIN \ +@{ + # Change to suit your system + _gr_awklib = "/usr/local/libexec/awk/" +@} + +function _gr_init( oldfs, oldrs, olddol0, grcat, + using_fw, using_fpat, n, a, i) +@{ + if (_gr_inited) + return + + oldfs = FS + oldrs = RS + olddol0 = $0 + using_fw = (PROCINFO["FS"] == "FIELDWIDTHS") + using_fpat = (PROCINFO["FS"] == "FPAT") + FS = ":" + RS = "\n" + + grcat = _gr_awklib "grcat" + while ((grcat | getline) > 0) @{ + if ($1 in _gr_byname) + _gr_byname[$1] = _gr_byname[$1] "," $4 + else + _gr_byname[$1] = $0 + if ($3 in _gr_bygid) + _gr_bygid[$3] = _gr_bygid[$3] "," $4 + else + _gr_bygid[$3] = $0 + + n = split($4, a, "[ \t]*,[ \t]*") + for (i = 1; i <= n; i++) + if (a[i] in _gr_groupsbyuser) + _gr_groupsbyuser[a[i]] = \ + _gr_groupsbyuser[a[i]] " " $1 + else + _gr_groupsbyuser[a[i]] = $1 + + _gr_bycount[++_gr_count] = $0 + @} + close(grcat) + _gr_count = 0 + _gr_inited++ + FS = oldfs + if (using_fw) + FIELDWIDTHS = FIELDWIDTHS + else if (using_fpat) + FPAT = FPAT + RS = oldrs + $0 = olddol0 +@} +@c endfile +@end example + +The @code{BEGIN} rule sets a private variable to the directory where +@command{grcat} is stored. Because it is used to help out an @command{awk} library +routine, we have chosen to put it in @file{/usr/local/libexec/awk}. You might +want it to be in a different directory on your system. + +These routines follow the same general outline as the user database routines +(@pxref{Passwd Functions}). +The @code{@w{_gr_inited}} variable is used to +ensure that the database is scanned no more than once. +The @code{@w{_gr_init()}} function first saves @code{FS}, +@code{RS}, and +@code{$0}, and then sets @code{FS} and @code{RS} to the correct values for +scanning the group information. +It also takes care to note whether @code{FIELDWIDTHS} or @code{FPAT} +is being used, and to restore the appropriate field splitting mechanism. + +The group information is stored is several associative arrays. +The arrays are indexed by group name (@code{@w{_gr_byname}}), by group ID number +(@code{@w{_gr_bygid}}), and by position in the database (@code{@w{_gr_bycount}}). +There is an additional array indexed by user name (@code{@w{_gr_groupsbyuser}}), +which is a space-separated list of groups to which each user belongs. + +Unlike the user database, it is possible to have multiple records in the +database for the same group. This is common when a group has a large number +of members. A pair of such entries might look like the following: + +@example +tvpeople:*:101:johnny,jay,arsenio +tvpeople:*:101:david,conan,tom,joan +@end example + +For this reason, @code{_gr_init()} looks to see if a group name or +group ID number is already seen. If it is, then the user names are +simply concatenated onto the previous list of users. (There is actually a +subtle problem with the code just presented. Suppose that +the first time there were no names. This code adds the names with +a leading comma. It also doesn't check that there is a @code{$4}.) + +Finally, @code{_gr_init()} closes the pipeline to @command{grcat}, restores +@code{FS} (and @code{FIELDWIDTHS} or @code{FPAT} if necessary), @code{RS}, and @code{$0}, +initializes @code{_gr_count} to zero +(it is used later), and makes @code{_gr_inited} nonzero. + +@cindex @code{getgrnam()} function (C library) +The @code{getgrnam()} function takes a group name as its argument, and if that +group exists, it is returned. +Otherwise, it +relies on the array reference to a nonexistent +element to create the element with the null string as its value: + +@cindex @code{getgrnam()} user-defined function +@example +@c file eg/lib/groupawk.in +function getgrnam(group) +@{ + _gr_init() + return _gr_byname[group] +@} +@c endfile +@end example + +@cindex @code{getgrgid()} function (C library) +The @code{getgrgid()} function is similar; it takes a numeric group ID and +looks up the information associated with that group ID: + +@cindex @code{getgrgid()} user-defined function +@example +@c file eg/lib/groupawk.in +function getgrgid(gid) +@{ + _gr_init() + return _gr_bygid[gid] +@} +@c endfile +@end example + +@cindex @code{getgruser()} function (C library) +The @code{getgruser()} function does not have a C counterpart. It takes a +user name and returns the list of groups that have the user as a member: + +@cindex @code{getgruser()} function, user-defined +@example +@c file eg/lib/groupawk.in +function getgruser(user) +@{ + _gr_init() + return _gr_groupsbyuser[user] +@} +@c endfile +@end example + +@cindex @code{getgrent()} function (C library) +The @code{getgrent()} function steps through the database one entry at a time. +It uses @code{_gr_count} to track its position in the list: + +@cindex @code{getgrent()} user-defined function +@example +@c file eg/lib/groupawk.in +function getgrent() +@{ + _gr_init() + if (++_gr_count in _gr_bycount) + return _gr_bycount[_gr_count] + return "" +@} +@c endfile +@end example +@c ENDOFRANGE clibf + +@cindex @code{endgrent()} function (C library) +The @code{endgrent()} function resets @code{_gr_count} to zero so that @code{getgrent()} can +start over again: + +@cindex @code{endgrent()} user-defined function +@example +@c file eg/lib/groupawk.in +function endgrent() +@{ + _gr_count = 0 +@} +@c endfile +@end example + +As with the user database routines, each function calls @code{_gr_init()} to +initialize the arrays. Doing so only incurs the extra overhead of running +@command{grcat} if these functions are used (as opposed to moving the body of +@code{_gr_init()} into a @code{BEGIN} rule). + +Most of the work is in scanning the database and building the various +associative arrays. The functions that the user calls are themselves very +simple, relying on @command{awk}'s associative arrays to do work. + +The @command{id} program in @ref{Id Program}, +uses these functions. + +@node Walking Arrays +@section Traversing Arrays of Arrays + +@ref{Arrays of Arrays}, described how @command{gawk} +provides arrays of arrays. In particular, any element of +an array may be either a scalar, or another array. The +@code{isarray()} function (@pxref{Type Functions}) +lets you distinguish an array +from a scalar. +The following function, @code{walk_array()}, recursively traverses +an array, printing each element's indices and value. +You call it with the array and a string representing the name +of the array: + +@cindex @code{walk_array()} user-defined function +@example +@c file eg/lib/walkarray.awk +function walk_array(arr, name, i) +@{ + for (i in arr) @{ + if (isarray(arr[i])) + walk_array(arr[i], (name "[" i "]")) + else + printf("%s[%s] = %s\n", name, i, arr[i]) + @} +@} +@c endfile +@end example + +@noindent +It works by looping over each element of the array. If any given +element is itself an array, the function calls itself recursively, +passing the subarray and a new string representing the current index. +Otherwise, the function simply prints the element's name, index, and value. +Here is a main program to demonstrate: + +@example +BEGIN @{ + a[1] = 1 + a[2][1] = 21 + a[2][2] = 22 + a[3] = 3 + a[4][1][1] = 411 + a[4][2] = 42 + + walk_array(a, "a") +@} +@end example + +When run, the program produces the following output: + +@example +$ @kbd{gawk -f walk_array.awk} +@print{} a[4][1][1] = 411 +@print{} a[4][2] = 42 +@print{} a[1] = 1 +@print{} a[2][1] = 21 +@print{} a[2][2] = 22 +@print{} a[3] = 3 +@end example + +@c ENDOFRANGE libfgdata +@c ENDOFRANGE flibgdata +@c ENDOFRANGE gdatar +@c ENDOFRANGE libf +@c ENDOFRANGE flib +@c ENDOFRANGE fudlib +@c ENDOFRANGE datagr + +@node Sample Programs +@chapter Practical @command{awk} Programs +@c STARTOFRANGE awkpex +@cindex @command{awk} programs, examples of + +@ref{Library Functions}, +presents the idea that reading programs in a language contributes to +learning that language. This @value{CHAPTER} continues that theme, +presenting a potpourri of @command{awk} programs for your reading +enjoyment. +@ifnotinfo +There are three sections. +The first describes how to run the programs presented +in this @value{CHAPTER}. + +The second presents @command{awk} +versions of several common POSIX utilities. +These are programs that you are hopefully already familiar with, +and therefore, whose problems are understood. +By reimplementing these programs in @command{awk}, +you can focus on the @command{awk}-related aspects of solving +the programming problem. + +The third is a grab bag of interesting programs. +These solve a number of different data-manipulation and management +problems. Many of the programs are short, which emphasizes @command{awk}'s +ability to do a lot in just a few lines of code. +@end ifnotinfo + +Many of these programs use library functions presented in +@ref{Library Functions}. + +@menu +* Running Examples:: How to run these examples. +* Clones:: Clones of common utilities. +* Miscellaneous Programs:: Some interesting @command{awk} programs. +@end menu + +@node Running Examples +@section Running the Example Programs + +To run a given program, you would typically do something like this: + +@example +awk -f @var{program} -- @var{options} @var{files} +@end example + +@noindent +Here, @var{program} is the name of the @command{awk} program (such as +@file{cut.awk}), @var{options} are any command-line options for the +program that start with a @samp{-}, and @var{files} are the actual @value{DF}s. + +If your system supports the @samp{#!} executable interpreter mechanism +(@pxref{Executable Scripts}), +you can instead run your program directly: + +@example +cut.awk -c1-8 myfiles > results +@end example + +If your @command{awk} is not @command{gawk}, you may instead need to use this: + +@example +cut.awk -- -c1-8 myfiles > results +@end example + +@node Clones +@section Reinventing Wheels for Fun and Profit +@c STARTOFRANGE posimawk +@cindex POSIX, programs@comma{} implementing in @command{awk} + +This @value{SECTION} presents a number of POSIX utilities implemented in +@command{awk}. Reinventing these programs in @command{awk} is often enjoyable, +because the algorithms can be very clearly expressed, and the code is usually +very concise and simple. This is true because @command{awk} does so much for you. + +It should be noted that these programs are not necessarily intended to +replace the installed versions on your system. +Nor may all of these programs be fully compliant with the most recent +POSIX standard. This is not a problem; their +purpose is to illustrate @command{awk} language programming for ``real world'' +tasks. + +The programs are presented in alphabetical order. + +@menu +* Cut Program:: The @command{cut} utility. +* Egrep Program:: The @command{egrep} utility. +* Id Program:: The @command{id} utility. +* Split Program:: The @command{split} utility. +* Tee Program:: The @command{tee} utility. +* Uniq Program:: The @command{uniq} utility. +* Wc Program:: The @command{wc} utility. +@end menu + +@node Cut Program +@subsection Cutting out Fields and Columns + +@cindex @command{cut} utility +@c STARTOFRANGE cut +@cindex @command{cut} utility +@c STARTOFRANGE ficut +@cindex fields, cutting +@c STARTOFRANGE colcut +@cindex columns, cutting +The @command{cut} utility selects, or ``cuts,'' characters or fields +from its standard input and sends them to its standard output. +Fields are separated by TABs by default, +but you may supply a command-line option to change the field +@dfn{delimiter} (i.e., the field-separator character). @command{cut}'s +definition of fields is less general than @command{awk}'s. + +A common use of @command{cut} might be to pull out just the login name of +logged-on users from the output of @command{who}. For example, the following +pipeline generates a sorted, unique list of the logged-on users: + +@example +who | cut -c1-8 | sort | uniq +@end example + +The options for @command{cut} are: + +@table @code +@item -c @var{list} +Use @var{list} as the list of characters to cut out. Items within the list +may be separated by commas, and ranges of characters can be separated with +dashes. The list @samp{1-8,15,22-35} specifies characters 1 through +8, 15, and 22 through 35. + +@item -f @var{list} +Use @var{list} as the list of fields to cut out. + +@item -d @var{delim} +Use @var{delim} as the field-separator character instead of the TAB +character. + +@item -s +Suppress printing of lines that do not contain the field delimiter. +@end table + +The @command{awk} implementation of @command{cut} uses the @code{getopt()} library +function (@pxref{Getopt Function}) +and the @code{join()} library function +(@pxref{Join Function}). + +The program begins with a comment describing the options, the library +functions needed, and a @code{usage()} function that prints out a usage +message and exits. @code{usage()} is called if invalid arguments are +supplied: + +@cindex @code{cut.awk} program +@example +@c file eg/prog/cut.awk +# cut.awk --- implement cut in awk +@c endfile +@ignore +@c file eg/prog/cut.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# May 1993 +@c endfile +@end ignore +@c file eg/prog/cut.awk + +# Options: +# -f list Cut fields +# -d c Field delimiter character +# -c list Cut characters +# +# -s Suppress lines without the delimiter +# +# Requires getopt() and join() library functions + +@group +function usage( e1, e2) +@{ + e1 = "usage: cut [-f list] [-d c] [-s] [files...]" + e2 = "usage: cut [-c list] [files...]" + print e1 > "/dev/stderr" + print e2 > "/dev/stderr" + exit 1 +@} +@end group +@c endfile +@end example + +@noindent +The variables @code{e1} and @code{e2} are used so that the function +fits nicely on the +@ifnotinfo +page. +@end ifnotinfo +@ifnottex +screen. +@end ifnottex + +@cindex @code{BEGIN} pattern, running @command{awk} programs and +@cindex @code{FS} variable, running @command{awk} programs and +Next comes a @code{BEGIN} rule that parses the command-line options. +It sets @code{FS} to a single TAB character, because that is @command{cut}'s +default field separator. The rule then sets the output field separator to be the +same as the input field separator. A loop using @code{getopt()} steps +through the command-line options. Exactly one of the variables +@code{by_fields} or @code{by_chars} is set to true, to indicate that +processing should be done by fields or by characters, respectively. +When cutting by characters, the output field separator is set to the null +string: + +@example +@c file eg/prog/cut.awk +BEGIN \ +@{ + FS = "\t" # default + OFS = FS + while ((c = getopt(ARGC, ARGV, "sf:c:d:")) != -1) @{ + if (c == "f") @{ + by_fields = 1 + fieldlist = Optarg + @} else if (c == "c") @{ + by_chars = 1 + fieldlist = Optarg + OFS = "" + @} else if (c == "d") @{ + if (length(Optarg) > 1) @{ + printf("Using first character of %s" \ + " for delimiter\n", Optarg) > "/dev/stderr" + Optarg = substr(Optarg, 1, 1) + @} + FS = Optarg + OFS = FS + if (FS == " ") # defeat awk semantics + FS = "[ ]" + @} else if (c == "s") + suppress++ + else + usage() + @} + + # Clear out options + for (i = 1; i < Optind; i++) + ARGV[i] = "" +@c endfile +@end example + +@cindex field separators, spaces as +The code must take +special care when the field delimiter is a space. Using +a single space (@code{@w{" "}}) for the value of @code{FS} is +incorrect---@command{awk} would separate fields with runs of spaces, +TABs, and/or newlines, and we want them to be separated with individual +spaces. Also remember that after @code{getopt()} is through +(as described in @ref{Getopt Function}), +we have to +clear out all the elements of @code{ARGV} from 1 to @code{Optind}, +so that @command{awk} does not try to process the command-line options +as @value{FN}s. + +After dealing with the command-line options, the program verifies that the +options make sense. Only one or the other of @option{-c} and @option{-f} +should be used, and both require a field list. Then the program calls +either @code{set_fieldlist()} or @code{set_charlist()} to pull apart the +list of fields or characters: + +@example +@c file eg/prog/cut.awk + if (by_fields && by_chars) + usage() + + if (by_fields == 0 && by_chars == 0) + by_fields = 1 # default + + if (fieldlist == "") @{ + print "cut: needs list for -c or -f" > "/dev/stderr" + exit 1 + @} + + if (by_fields) + set_fieldlist() + else + set_charlist() +@} +@c endfile +@end example + +@code{set_fieldlist()} splits the field list apart at the commas +into an array. Then, for each element of the array, it looks to +see if the element is actually a range, and if so, splits it apart. +The function checks the range +to make sure that the first number is smaller than the second. +Each number in the list is added to the @code{flist} array, which +simply lists the fields that will be printed. Normal field splitting +is used. The program lets @command{awk} handle the job of doing the +field splitting: + +@example +@c file eg/prog/cut.awk +function set_fieldlist( n, m, i, j, k, f, g) +@{ + n = split(fieldlist, f, ",") + j = 1 # index in flist + for (i = 1; i <= n; i++) @{ + if (index(f[i], "-") != 0) @{ # a range + m = split(f[i], g, "-") +@group + if (m != 2 || g[1] >= g[2]) @{ + printf("bad field list: %s\n", + f[i]) > "/dev/stderr" + exit 1 + @} +@end group + for (k = g[1]; k <= g[2]; k++) + flist[j++] = k + @} else + flist[j++] = f[i] + @} + nfields = j - 1 +@} +@c endfile +@end example + +The @code{set_charlist()} function is more complicated than +@code{set_fieldlist()}. +The idea here is to use @command{gawk}'s @code{FIELDWIDTHS} variable +(@pxref{Constant Size}), +which describes constant-width input. When using a character list, that is +exactly what we have. + +Setting up @code{FIELDWIDTHS} is more complicated than simply listing the +fields that need to be printed. We have to keep track of the fields to +print and also the intervening characters that have to be skipped. +For example, suppose you wanted characters 1 through 8, 15, and +22 through 35. You would use @samp{-c 1-8,15,22-35}. The necessary value +for @code{FIELDWIDTHS} is @code{@w{"8 6 1 6 14"}}. This yields five +fields, and the fields to print +are @code{$1}, @code{$3}, and @code{$5}. +The intermediate fields are @dfn{filler}, +which is stuff in between the desired data. +@code{flist} lists the fields to print, and @code{t} tracks the +complete field list, including filler fields: + +@example +@c file eg/prog/cut.awk +function set_charlist( field, i, j, f, g, t, + filler, last, len) +@{ + field = 1 # count total fields + n = split(fieldlist, f, ",") + j = 1 # index in flist + for (i = 1; i <= n; i++) @{ + if (index(f[i], "-") != 0) @{ # range + m = split(f[i], g, "-") + if (m != 2 || g[1] >= g[2]) @{ + printf("bad character list: %s\n", + f[i]) > "/dev/stderr" + exit 1 + @} + len = g[2] - g[1] + 1 + if (g[1] > 1) # compute length of filler + filler = g[1] - last - 1 + else + filler = 0 +@group + if (filler) + t[field++] = filler +@end group + t[field++] = len # length of field + last = g[2] + flist[j++] = field - 1 + @} else @{ + if (f[i] > 1) + filler = f[i] - last - 1 + else + filler = 0 + if (filler) + t[field++] = filler + t[field++] = 1 + last = f[i] + flist[j++] = field - 1 + @} + @} + FIELDWIDTHS = join(t, 1, field - 1) + nfields = j - 1 +@} +@c endfile +@end example + +Next is the rule that actually processes the data. If the @option{-s} option +is given, then @code{suppress} is true. The first @code{if} statement +makes sure that the input record does have the field separator. If +@command{cut} is processing fields, @code{suppress} is true, and the field +separator character is not in the record, then the record is skipped. + +If the record is valid, then @command{gawk} has split the data +into fields, either using the character in @code{FS} or using fixed-length +fields and @code{FIELDWIDTHS}. The loop goes through the list of fields +that should be printed. The corresponding field is printed if it contains data. +If the next field also has data, then the separator character is +written out between the fields: + +@example +@c file eg/prog/cut.awk +@{ + if (by_fields && suppress && index($0, FS) != 0) + next + + for (i = 1; i <= nfields; i++) @{ + if ($flist[i] != "") @{ + printf "%s", $flist[i] + if (i < nfields && $flist[i+1] != "") + printf "%s", OFS + @} + @} + print "" +@} +@c endfile +@end example + +This version of @command{cut} relies on @command{gawk}'s @code{FIELDWIDTHS} +variable to do the character-based cutting. While it is possible in +other @command{awk} implementations to use @code{substr()} +(@pxref{String Functions}), +it is also extremely painful. +The @code{FIELDWIDTHS} variable supplies an elegant solution to the problem +of picking the input line apart by characters. +@c ENDOFRANGE cut +@c ENDOFRANGE ficut +@c ENDOFRANGE colcut + +@c Exercise: Rewrite using split with "". + +@node Egrep Program +@subsection Searching for Regular Expressions in Files + +@c STARTOFRANGE regexps +@cindex regular expressions, searching for +@c STARTOFRANGE sfregexp +@cindex searching, files for regular expressions +@c STARTOFRANGE fsregexp +@cindex files, searching for regular expressions +@cindex @command{egrep} utility +The @command{egrep} utility searches files for patterns. It uses regular +expressions that are almost identical to those available in @command{awk} +(@pxref{Regexp}). +You invoke it as follows: + +@example +egrep @r{[} @var{options} @r{]} '@var{pattern}' @var{files} @dots{} +@end example + +The @var{pattern} is a regular expression. In typical usage, the regular +expression is quoted to prevent the shell from expanding any of the +special characters as @value{FN} wildcards. Normally, @command{egrep} +prints the lines that matched. If multiple @value{FN}s are provided on +the command line, each output line is preceded by the name of the file +and a colon. + +The options to @command{egrep} are as follows: + +@table @code +@item -c +Print out a count of the lines that matched the pattern, instead of the +lines themselves. + +@item -s +Be silent. No output is produced and the exit value indicates whether +the pattern was matched. + +@item -v +Invert the sense of the test. @command{egrep} prints the lines that do +@emph{not} match the pattern and exits successfully if the pattern is not +matched. + +@item -i +Ignore case distinctions in both the pattern and the input data. + +@item -l +Only print (list) the names of the files that matched, not the lines that matched. + +@item -e @var{pattern} +Use @var{pattern} as the regexp to match. The purpose of the @option{-e} +option is to allow patterns that start with a @samp{-}. +@end table + +This version uses the @code{getopt()} library function +(@pxref{Getopt Function}) +and the file transition library program +(@pxref{Filetrans Function}). + +The program begins with a descriptive comment and then a @code{BEGIN} rule +that processes the command-line arguments with @code{getopt()}. The @option{-i} +(ignore case) option is particularly easy with @command{gawk}; we just use the +@code{IGNORECASE} built-in variable +(@pxref{Built-in Variables}): + +@cindex @code{egrep.awk} program +@example +@c file eg/prog/egrep.awk +# egrep.awk --- simulate egrep in awk +# +@c endfile +@ignore +@c file eg/prog/egrep.awk +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# May 1993 + +@c endfile +@end ignore +@c file eg/prog/egrep.awk +# Options: +# -c count of lines +# -s silent - use exit value +# -v invert test, success if no match +# -i ignore case +# -l print filenames only +# -e argument is pattern +# +# Requires getopt and file transition library functions + +BEGIN @{ + while ((c = getopt(ARGC, ARGV, "ce:svil")) != -1) @{ + if (c == "c") + count_only++ + else if (c == "s") + no_print++ + else if (c == "v") + invert++ + else if (c == "i") + IGNORECASE = 1 + else if (c == "l") + filenames_only++ + else if (c == "e") + pattern = Optarg + else + usage() + @} +@c endfile +@end example + +Next comes the code that handles the @command{egrep}-specific behavior. If no +pattern is supplied with @option{-e}, the first nonoption on the +command line is used. The @command{awk} command-line arguments up to @code{ARGV[Optind]} +are cleared, so that @command{awk} won't try to process them as files. If no +files are specified, the standard input is used, and if multiple files are +specified, we make sure to note this so that the @value{FN}s can precede the +matched lines in the output: + +@example +@c file eg/prog/egrep.awk + if (pattern == "") + pattern = ARGV[Optind++] + + for (i = 1; i < Optind; i++) + ARGV[i] = "" + if (Optind >= ARGC) @{ + ARGV[1] = "-" + ARGC = 2 + @} else if (ARGC - Optind > 1) + do_filenames++ + +# if (IGNORECASE) +# pattern = tolower(pattern) +@} +@c endfile +@end example + +The last two lines are commented out, since they are not needed in +@command{gawk}. They should be uncommented if you have to use another version +of @command{awk}. + +The next set of lines should be uncommented if you are not using +@command{gawk}. This rule translates all the characters in the input line +into lowercase if the @option{-i} option is specified.@footnote{It +also introduces a subtle bug; +if a match happens, we output the translated line, not the original.} +The rule is +commented out since it is not necessary with @command{gawk}: + +@c Exercise: Fix this, w/array and new line as key to original line + +@example +@c file eg/prog/egrep.awk +#@{ +# if (IGNORECASE) +# $0 = tolower($0) +#@} +@c endfile +@end example + +The @code{beginfile()} function is called by the rule in @file{ftrans.awk} +when each new file is processed. In this case, it is very simple; all it +does is initialize a variable @code{fcount} to zero. @code{fcount} tracks +how many lines in the current file matched the pattern. +Naming the parameter @code{junk} shows we know that @code{beginfile()} +is called with a parameter, but that we're not interested in its value: + +@example +@c file eg/prog/egrep.awk +function beginfile(junk) +@{ + fcount = 0 +@} +@c endfile +@end example + +The @code{endfile()} function is called after each file has been processed. +It affects the output only when the user wants a count of the number of lines that +matched. @code{no_print} is true only if the exit status is desired. +@code{count_only} is true if line counts are desired. @command{egrep} +therefore only prints line counts if printing and counting are enabled. +The output format must be adjusted depending upon the number of files to +process. Finally, @code{fcount} is added to @code{total}, so that we +know the total number of lines that matched the pattern: + +@example +@c file eg/prog/egrep.awk +function endfile(file) +@{ + if (! no_print && count_only) @{ + if (do_filenames) + print file ":" fcount + else + print fcount + @} + + total += fcount +@} +@c endfile +@end example + +The following rule does most of the work of matching lines. The variable +@code{matches} is true if the line matched the pattern. If the user +wants lines that did not match, the sense of @code{matches} is inverted +using the @samp{!} operator. @code{fcount} is incremented with the value of +@code{matches}, which is either one or zero, depending upon a +successful or unsuccessful match. If the line does not match, the +@code{next} statement just moves on to the next record. + +A number of additional tests are made, but they are only done if we +are not counting lines. First, if the user only wants exit status +(@code{no_print} is true), then it is enough to know that @emph{one} +line in this file matched, and we can skip on to the next file with +@code{nextfile}. Similarly, if we are only printing @value{FN}s, we can +print the @value{FN}, and then skip to the next file with @code{nextfile}. +Finally, each line is printed, with a leading @value{FN} and colon +if necessary: + +@cindex @code{!} (exclamation point), @code{!} operator +@cindex exclamation point (@code{!}), @code{!} operator +@example +@c file eg/prog/egrep.awk +@{ + matches = ($0 ~ pattern) + if (invert) + matches = ! matches + + fcount += matches # 1 or 0 + + if (! matches) + next + + if (! count_only) @{ + if (no_print) + nextfile + + if (filenames_only) @{ + print FILENAME + nextfile + @} + + if (do_filenames) + print FILENAME ":" $0 + else + print + @} +@} +@c endfile +@end example + +The @code{END} rule takes care of producing the correct exit status. If +there are no matches, the exit status is one; otherwise it is zero: + +@example +@c file eg/prog/egrep.awk +END \ +@{ + if (total == 0) + exit 1 + exit 0 +@} +@c endfile +@end example + +The @code{usage()} function prints a usage message in case of invalid options, +and then exits: + +@example +@c file eg/prog/egrep.awk +function usage( e) +@{ + e = "Usage: egrep [-csvil] [-e pat] [files ...]" + e = e "\n\tegrep [-csvil] pat [files ...]" + print e > "/dev/stderr" + exit 1 +@} +@c endfile +@end example + +The variable @code{e} is used so that the function fits nicely +on the printed page. + +@cindex @code{END} pattern, backslash continuation and +@cindex @code{\} (backslash), continuing lines and +@cindex backslash (@code{\}), continuing lines and +Just a note on programming style: you may have noticed that the @code{END} +rule uses backslash continuation, with the open brace on a line by +itself. This is so that it more closely resembles the way functions +are written. Many of the examples +in this @value{CHAPTER} +use this style. You can decide for yourself if you like writing +your @code{BEGIN} and @code{END} rules this way +or not. +@c ENDOFRANGE regexps +@c ENDOFRANGE sfregexp +@c ENDOFRANGE fsregexp + +@node Id Program +@subsection Printing out User Information + +@cindex printing, user information +@cindex users, information about, printing +@cindex @command{id} utility +The @command{id} utility lists a user's real and effective user ID numbers, +real and effective group ID numbers, and the user's group set, if any. +@command{id} only prints the effective user ID and group ID if they are +different from the real ones. If possible, @command{id} also supplies the +corresponding user and group names. The output might look like this: + +@example +$ @kbd{id} +@print{} uid=500(arnold) gid=500(arnold) groups=6(disk),7(lp),19(floppy) +@end example + +@cindex @code{PROCINFO} array +This information is part of what is provided by @command{gawk}'s +@code{PROCINFO} array (@pxref{Built-in Variables}). +However, the @command{id} utility provides a more palatable output than just +individual numbers. + +Here is a simple version of @command{id} written in @command{awk}. +It uses the user database library functions +(@pxref{Passwd Functions}) +and the group database library functions +(@pxref{Group Functions}): + +The program is fairly straightforward. All the work is done in the +@code{BEGIN} rule. The user and group ID numbers are obtained from +@code{PROCINFO}. +The code is repetitive. The entry in the user database for the real user ID +number is split into parts at the @samp{:}. The name is the first field. +Similar code is used for the effective user ID number and the group +numbers: + +@cindex @code{id.awk} program +@example +@c file eg/prog/id.awk +# id.awk --- implement id in awk +# +# Requires user and group library functions +@c endfile +@ignore +@c file eg/prog/id.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# May 1993 +# Revised February 1996 + +@c endfile +@end ignore +@c file eg/prog/id.awk +# output is: +# uid=12(foo) euid=34(bar) gid=3(baz) \ +# egid=5(blat) groups=9(nine),2(two),1(one) + +@group +BEGIN \ +@{ + uid = PROCINFO["uid"] + euid = PROCINFO["euid"] + gid = PROCINFO["gid"] + egid = PROCINFO["egid"] +@end group + + printf("uid=%d", uid) + pw = getpwuid(uid) + if (pw != "") @{ + split(pw, a, ":") + printf("(%s)", a[1]) + @} + + if (euid != uid) @{ + printf(" euid=%d", euid) + pw = getpwuid(euid) + if (pw != "") @{ + split(pw, a, ":") + printf("(%s)", a[1]) + @} + @} + + printf(" gid=%d", gid) + pw = getgrgid(gid) + if (pw != "") @{ + split(pw, a, ":") + printf("(%s)", a[1]) + @} + + if (egid != gid) @{ + printf(" egid=%d", egid) + pw = getgrgid(egid) + if (pw != "") @{ + split(pw, a, ":") + printf("(%s)", a[1]) + @} + @} + + for (i = 1; ("group" i) in PROCINFO; i++) @{ + if (i == 1) + printf(" groups=") + group = PROCINFO["group" i] + printf("%d", group) + pw = getgrgid(group) + if (pw != "") @{ + split(pw, a, ":") + printf("(%s)", a[1]) + @} + if (("group" (i+1)) in PROCINFO) + printf(",") + @} + + print "" +@} +@c endfile +@end example + +@cindex @code{in} operator +The test in the @code{for} loop is worth noting. +Any supplementary groups in the @code{PROCINFO} array have the +indices @code{"group1"} through @code{"group@var{N}"} for some +@var{N}, i.e., the total number of supplementary groups. +However, we don't know in advance how many of these groups +there are. + +This loop works by starting at one, concatenating the value with +@code{"group"}, and then using @code{in} to see if that value is +in the array. Eventually, @code{i} is incremented past +the last group in the array and the loop exits. + +The loop is also correct if there are @emph{no} supplementary +groups; then the condition is false the first time it's +tested, and the loop body never executes. + +@c exercise!!! +@ignore +The POSIX version of @command{id} takes arguments that control which +information is printed. Modify this version to accept the same +arguments and perform in the same way. +@end ignore + +@node Split Program +@subsection Splitting a Large File into Pieces + +@c FIXME: One day, update to current POSIX version of split + +@c STARTOFRANGE filspl +@cindex files, splitting +@cindex @code{split} utility +The @command{split} program splits large text files into smaller pieces. +Usage is as follows:@footnote{This is the traditional usage. The +POSIX usage is different, but not relevant for what the program +aims to demonstrate.} + +@example +split @r{[}-@var{count}@r{]} file @r{[} @var{prefix} @r{]} +@end example + +By default, +the output files are named @file{xaa}, @file{xab}, and so on. Each file has +1000 lines in it, with the likely exception of the last file. To change the +number of lines in each file, supply a number on the command line +preceded with a minus; e.g., @samp{-500} for files with 500 lines in them +instead of 1000. To change the name of the output files to something like +@file{myfileaa}, @file{myfileab}, and so on, supply an additional +argument that specifies the @value{FN} prefix. + +Here is a version of @command{split} in @command{awk}. It uses the +@code{ord()} and @code{chr()} functions presented in +@ref{Ordinal Functions}. + +The program first sets its defaults, and then tests to make sure there are +not too many arguments. It then looks at each argument in turn. The +first argument could be a minus sign followed by a number. If it is, this happens +to look like a negative number, so it is made positive, and that is the +count of lines. The data @value{FN} is skipped over and the final argument +is used as the prefix for the output @value{FN}s: + +@cindex @code{split.awk} program +@example +@c file eg/prog/split.awk +# split.awk --- do split in awk +# +# Requires ord() and chr() library functions +@c endfile +@ignore +@c file eg/prog/split.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# May 1993 + +@c endfile +@end ignore +@c file eg/prog/split.awk +# usage: split [-num] [file] [outname] + +BEGIN @{ + outfile = "x" # default + count = 1000 + if (ARGC > 4) + usage() + + i = 1 + if (ARGV[i] ~ /^-[[:digit:]]+$/) @{ + count = -ARGV[i] + ARGV[i] = "" + i++ + @} + # test argv in case reading from stdin instead of file + if (i in ARGV) + i++ # skip data file name + if (i in ARGV) @{ + outfile = ARGV[i] + ARGV[i] = "" + @} + + s1 = s2 = "a" + out = (outfile s1 s2) +@} +@c endfile +@end example + +The next rule does most of the work. @code{tcount} (temporary count) tracks +how many lines have been printed to the output file so far. If it is greater +than @code{count}, it is time to close the current file and start a new one. +@code{s1} and @code{s2} track the current suffixes for the @value{FN}. If +they are both @samp{z}, the file is just too big. Otherwise, @code{s1} +moves to the next letter in the alphabet and @code{s2} starts over again at +@samp{a}: + +@c else on separate line here for page breaking +@example +@c file eg/prog/split.awk +@{ + if (++tcount > count) @{ + close(out) + if (s2 == "z") @{ + if (s1 == "z") @{ + printf("split: %s is too large to split\n", + FILENAME) > "/dev/stderr" + exit 1 + @} + s1 = chr(ord(s1) + 1) + s2 = "a" + @} +@group + else + s2 = chr(ord(s2) + 1) +@end group + out = (outfile s1 s2) + tcount = 1 + @} + print > out +@} +@c endfile +@end example + +@c Exercise: do this with just awk builtin functions, index("abc..."), substr, etc. + +@noindent +The @code{usage()} function simply prints an error message and exits: + +@example +@c file eg/prog/split.awk +function usage( e) +@{ + e = "usage: split [-num] [file] [outname]" + print e > "/dev/stderr" + exit 1 +@} +@c endfile +@end example + +@noindent +The variable @code{e} is used so that the function +fits nicely on the +@ifinfo +screen. +@end ifinfo +@ifnotinfo +page. +@end ifnotinfo + +This program is a bit sloppy; it relies on @command{awk} to automatically close the last file +instead of doing it in an @code{END} rule. +It also assumes that letters are contiguous in the character set, +which isn't true for EBCDIC systems. + +@c Exercise: Fix these problems. +@c BFD... +@c ENDOFRANGE filspl + +@node Tee Program +@subsection Duplicating Output into Multiple Files + +@cindex files, multiple@comma{} duplicating output into +@cindex output, duplicating into files +@cindex @code{tee} utility +The @code{tee} program is known as a ``pipe fitting.'' @code{tee} copies +its standard input to its standard output and also duplicates it to the +files named on the command line. Its usage is as follows: + +@example +tee @r{[}-a@r{]} file @dots{} +@end example + +The @option{-a} option tells @code{tee} to append to the named files, instead of +truncating them and starting over. + +The @code{BEGIN} rule first makes a copy of all the command-line arguments +into an array named @code{copy}. +@code{ARGV[0]} is not copied, since it is not needed. +@code{tee} cannot use @code{ARGV} directly, since @command{awk} attempts to +process each @value{FN} in @code{ARGV} as input data. + +@cindex flag variables +If the first argument is @option{-a}, then the flag variable +@code{append} is set to true, and both @code{ARGV[1]} and +@code{copy[1]} are deleted. If @code{ARGC} is less than two, then no +@value{FN}s were supplied and @code{tee} prints a usage message and exits. +Finally, @command{awk} is forced to read the standard input by setting +@code{ARGV[1]} to @code{"-"} and @code{ARGC} to two: + +@cindex @code{tee.awk} program +@example +@c file eg/prog/tee.awk +# tee.awk --- tee in awk +# +# Copy standard input to all named output files. +# Append content if -a option is supplied. +# +@c endfile +@ignore +@c file eg/prog/tee.awk +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# May 1993 +# Revised December 1995 + +@c endfile +@end ignore +@c file eg/prog/tee.awk +BEGIN \ +@{ + for (i = 1; i < ARGC; i++) + copy[i] = ARGV[i] + + if (ARGV[1] == "-a") @{ + append = 1 + delete ARGV[1] + delete copy[1] + ARGC-- + @} + if (ARGC < 2) @{ + print "usage: tee [-a] file ..." > "/dev/stderr" + exit 1 + @} + ARGV[1] = "-" + ARGC = 2 +@} +@c endfile +@end example + +The following single rule does all the work. Since there is no pattern, it is +executed for each line of input. The body of the rule simply prints the +line into each file on the command line, and then to the standard output: + +@example +@c file eg/prog/tee.awk +@{ + # moving the if outside the loop makes it run faster + if (append) + for (i in copy) + print >> copy[i] + else + for (i in copy) + print > copy[i] + print +@} +@c endfile +@end example + +@noindent +It is also possible to write the loop this way: + +@example +for (i in copy) + if (append) + print >> copy[i] + else + print > copy[i] +@end example + +@noindent +This is more concise but it is also less efficient. The @samp{if} is +tested for each record and for each output file. By duplicating the loop +body, the @samp{if} is only tested once for each input record. If there are +@var{N} input records and @var{M} output files, the first method only +executes @var{N} @samp{if} statements, while the second executes +@var{N}@code{*}@var{M} @samp{if} statements. + +Finally, the @code{END} rule cleans up by closing all the output files: + +@example +@c file eg/prog/tee.awk +END \ +@{ + for (i in copy) + close(copy[i]) +@} +@c endfile +@end example + +@node Uniq Program +@subsection Printing Nonduplicated Lines of Text + +@c FIXME: One day, update to current POSIX version of uniq + +@c STARTOFRANGE prunt +@cindex printing, unduplicated lines of text +@c STARTOFRANGE tpul +@cindex text@comma{} printing, unduplicated lines of +@cindex @command{uniq} utility +The @command{uniq} utility reads sorted lines of data on its standard +input, and by default removes duplicate lines. In other words, it only +prints unique lines---hence the name. @command{uniq} has a number of +options. The usage is as follows: + +@example +uniq @r{[}-udc @r{[}-@var{n}@r{]]} @r{[}+@var{n}@r{]} @r{[} @var{input file} @r{[} @var{output file} @r{]]} +@end example + +The options for @command{uniq} are: + +@table @code +@item -d +Print only repeated lines. + +@item -u +Print only nonrepeated lines. + +@item -c +Count lines. This option overrides @option{-d} and @option{-u}. Both repeated +and nonrepeated lines are counted. + +@item -@var{n} +Skip @var{n} fields before comparing lines. The definition of fields +is similar to @command{awk}'s default: nonwhitespace characters separated +by runs of spaces and/or TABs. + +@item +@var{n} +Skip @var{n} characters before comparing lines. Any fields specified with +@samp{-@var{n}} are skipped first. + +@item @var{input file} +Data is read from the input file named on the command line, instead of from +the standard input. + +@item @var{output file} +The generated output is sent to the named output file, instead of to the +standard output. +@end table + +Normally @command{uniq} behaves as if both the @option{-d} and +@option{-u} options are provided. + +@command{uniq} uses the +@code{getopt()} library function +(@pxref{Getopt Function}) +and the @code{join()} library function +(@pxref{Join Function}). + +The program begins with a @code{usage()} function and then a brief outline of +the options and their meanings in comments. +The @code{BEGIN} rule deals with the command-line arguments and options. It +uses a trick to get @code{getopt()} to handle options of the form @samp{-25}, +treating such an option as the option letter @samp{2} with an argument of +@samp{5}. If indeed two or more digits are supplied (@code{Optarg} looks +like a number), @code{Optarg} is +concatenated with the option digit and then the result is added to zero to make +it into a number. If there is only one digit in the option, then +@code{Optarg} is not needed. In this case, @code{Optind} must be decremented so that +@code{getopt()} processes it next time. This code is admittedly a bit +tricky. + +If no options are supplied, then the default is taken, to print both +repeated and nonrepeated lines. The output file, if provided, is assigned +to @code{outputfile}. Early on, @code{outputfile} is initialized to the +standard output, @file{/dev/stdout}: + +@cindex @code{uniq.awk} program +@example +@c file eg/prog/uniq.awk +@group +# uniq.awk --- do uniq in awk +# +# Requires getopt() and join() library functions +@end group +@c endfile +@ignore +@c file eg/prog/uniq.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# May 1993 +@c endfile +@end ignore +@c file eg/prog/uniq.awk + +function usage( e) +@{ + e = "Usage: uniq [-udc [-n]] [+n] [ in [ out ]]" + print e > "/dev/stderr" + exit 1 +@} + +# -c count lines. overrides -d and -u +# -d only repeated lines +# -u only nonrepeated lines +# -n skip n fields +# +n skip n characters, skip fields first + +BEGIN \ +@{ + count = 1 + outputfile = "/dev/stdout" + opts = "udc0:1:2:3:4:5:6:7:8:9:" + while ((c = getopt(ARGC, ARGV, opts)) != -1) @{ + if (c == "u") + non_repeated_only++ + else if (c == "d") + repeated_only++ + else if (c == "c") + do_count++ + else if (index("0123456789", c) != 0) @{ + # getopt requires args to options + # this messes us up for things like -5 + if (Optarg ~ /^[[:digit:]]+$/) + fcount = (c Optarg) + 0 + else @{ + fcount = c + 0 + Optind-- + @} + @} else + usage() + @} + + if (ARGV[Optind] ~ /^\+[[:digit:]]+$/) @{ + charcount = substr(ARGV[Optind], 2) + 0 + Optind++ + @} + + for (i = 1; i < Optind; i++) + ARGV[i] = "" + + if (repeated_only == 0 && non_repeated_only == 0) + repeated_only = non_repeated_only = 1 + + if (ARGC - Optind == 2) @{ + outputfile = ARGV[ARGC - 1] + ARGV[ARGC - 1] = "" + @} +@} +@c endfile +@end example + +The following function, @code{are_equal()}, compares the current line, +@code{$0}, to the +previous line, @code{last}. It handles skipping fields and characters. +If no field count and no character count are specified, @code{are_equal()} +simply returns one or zero depending upon the result of a simple string +comparison of @code{last} and @code{$0}. Otherwise, things get more +complicated. +If fields have to be skipped, each line is broken into an array using +@code{split()} +(@pxref{String Functions}); +the desired fields are then joined back into a line using @code{join()}. +The joined lines are stored in @code{clast} and @code{cline}. +If no fields are skipped, @code{clast} and @code{cline} are set to +@code{last} and @code{$0}, respectively. +Finally, if characters are skipped, @code{substr()} is used to strip off the +leading @code{charcount} characters in @code{clast} and @code{cline}. The +two strings are then compared and @code{are_equal()} returns the result: + +@example +@c file eg/prog/uniq.awk +function are_equal( n, m, clast, cline, alast, aline) +@{ + if (fcount == 0 && charcount == 0) + return (last == $0) + + if (fcount > 0) @{ + n = split(last, alast) + m = split($0, aline) + clast = join(alast, fcount+1, n) + cline = join(aline, fcount+1, m) + @} else @{ + clast = last + cline = $0 + @} + if (charcount) @{ + clast = substr(clast, charcount + 1) + cline = substr(cline, charcount + 1) + @} + + return (clast == cline) +@} +@c endfile +@end example + +The following two rules are the body of the program. The first one is +executed only for the very first line of data. It sets @code{last} equal to +@code{$0}, so that subsequent lines of text have something to be compared to. + +The second rule does the work. The variable @code{equal} is one or zero, +depending upon the results of @code{are_equal()}'s comparison. If @command{uniq} +is counting repeated lines, and the lines are equal, then it increments the @code{count} variable. +Otherwise, it prints the line and resets @code{count}, +since the two lines are not equal. + +If @command{uniq} is not counting, and if the lines are equal, @code{count} is incremented. +Nothing is printed, since the point is to remove duplicates. +Otherwise, if @command{uniq} is counting repeated lines and more than +one line is seen, or if @command{uniq} is counting nonrepeated lines +and only one line is seen, then the line is printed, and @code{count} +is reset. + +Finally, similar logic is used in the @code{END} rule to print the final +line of input data: + +@example +@c file eg/prog/uniq.awk +NR == 1 @{ + last = $0 + next +@} + +@{ + equal = are_equal() + + if (do_count) @{ # overrides -d and -u + if (equal) + count++ + else @{ + printf("%4d %s\n", count, last) > outputfile + last = $0 + count = 1 # reset + @} + next + @} + + if (equal) + count++ + else @{ + if ((repeated_only && count > 1) || + (non_repeated_only && count == 1)) + print last > outputfile + last = $0 + count = 1 + @} +@} + +END @{ + if (do_count) + printf("%4d %s\n", count, last) > outputfile + else if ((repeated_only && count > 1) || + (non_repeated_only && count == 1)) + print last > outputfile + close(outputfile) +@} +@c endfile +@end example +@c ENDOFRANGE prunt +@c ENDOFRANGE tpul + +@node Wc Program +@subsection Counting Things + +@c FIXME: One day, update to current POSIX version of wc + +@c STARTOFRANGE count +@cindex counting +@c STARTOFRANGE infco +@cindex input files, counting elements in +@c STARTOFRANGE woco +@cindex words, counting +@c STARTOFRANGE chco +@cindex characters, counting +@c STARTOFRANGE lico +@cindex lines, counting +@cindex @command{wc} utility +The @command{wc} (word count) utility counts lines, words, and characters in +one or more input files. Its usage is as follows: + +@example +wc @r{[}-lwc@r{]} @r{[} @var{files} @dots{} @r{]} +@end example + +If no files are specified on the command line, @command{wc} reads its standard +input. If there are multiple files, it also prints total counts for all +the files. The options and their meanings are shown in the following list: + +@table @code +@item -l +Count only lines. + +@item -w +Count only words. +A ``word'' is a contiguous sequence of nonwhitespace characters, separated +by spaces and/or TABs. Luckily, this is the normal way @command{awk} separates +fields in its input data. + +@item -c +Count only characters. +@end table + +Implementing @command{wc} in @command{awk} is particularly elegant, +since @command{awk} does a lot of the work for us; it splits lines into +words (i.e., fields) and counts them, it counts lines (i.e., records), +and it can easily tell us how long a line is. + +This program uses the @code{getopt()} library function +(@pxref{Getopt Function}) +and the file-transition functions +(@pxref{Filetrans Function}). + +This version has one notable difference from traditional versions of +@command{wc}: it always prints the counts in the order lines, words, +and characters. Traditional versions note the order of the @option{-l}, +@option{-w}, and @option{-c} options on the command line, and print the +counts in that order. + +The @code{BEGIN} rule does the argument processing. The variable +@code{print_total} is true if more than one file is named on the +command line: + +@cindex @code{wc.awk} program +@example +@c file eg/prog/wc.awk +# wc.awk --- count lines, words, characters +@c endfile +@ignore +@c file eg/prog/wc.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# May 1993 +@c endfile +@end ignore +@c file eg/prog/wc.awk + +# Options: +# -l only count lines +# -w only count words +# -c only count characters +# +# Default is to count lines, words, characters +# +# Requires getopt() and file transition library functions + +BEGIN @{ + # let getopt() print a message about + # invalid options. we ignore them + while ((c = getopt(ARGC, ARGV, "lwc")) != -1) @{ + if (c == "l") + do_lines = 1 + else if (c == "w") + do_words = 1 + else if (c == "c") + do_chars = 1 + @} + for (i = 1; i < Optind; i++) + ARGV[i] = "" + + # if no options, do all + if (! do_lines && ! do_words && ! do_chars) + do_lines = do_words = do_chars = 1 + + print_total = (ARGC - i > 2) +@} +@c endfile +@end example + +The @code{beginfile()} function is simple; it just resets the counts of lines, +words, and characters to zero, and saves the current @value{FN} in +@code{fname}: + +@example +@c file eg/prog/wc.awk +function beginfile(file) +@{ + lines = words = chars = 0 + fname = FILENAME +@} +@c endfile +@end example + +The @code{endfile()} function adds the current file's numbers to the running +totals of lines, words, and characters.@footnote{@command{wc} can't just use the value of +@code{FNR} in @code{endfile()}. If you examine +the code in +@ref{Filetrans Function}, +you will see that +@code{FNR} has already been reset by the time +@code{endfile()} is called.} It then prints out those numbers +for the file that was just read. It relies on @code{beginfile()} to reset the +numbers for the following @value{DF}: +@c FIXME: ONE DAY: make the above footnote an exercise, +@c instead of giving away the answer. + +@example +@c file eg/prog/wc.awk +function endfile(file) +@{ + tlines += lines + twords += words + tchars += chars + if (do_lines) + printf "\t%d", lines +@group + if (do_words) + printf "\t%d", words +@end group + if (do_chars) + printf "\t%d", chars + printf "\t%s\n", fname +@} +@c endfile +@end example + +There is one rule that is executed for each line. It adds the length of +the record, plus one, to @code{chars}.@footnote{Since @command{gawk} +understands multibyte locales, this code counts characters, not bytes.} +Adding one plus the record length +is needed because the newline character separating records (the value +of @code{RS}) is not part of the record itself, and thus not included +in its length. Next, @code{lines} is incremented for each line read, +and @code{words} is incremented by the value of @code{NF}, which is the +number of ``words'' on this line: + +@example +@c file eg/prog/wc.awk +# do per line +@{ + chars += length($0) + 1 # get newline + lines++ + words += NF +@} +@c endfile +@end example + +Finally, the @code{END} rule simply prints the totals for all the files: + +@example +@c file eg/prog/wc.awk +END @{ + if (print_total) @{ + if (do_lines) + printf "\t%d", tlines + if (do_words) + printf "\t%d", twords + if (do_chars) + printf "\t%d", tchars + print "\ttotal" + @} +@} +@c endfile +@end example +@c ENDOFRANGE count +@c ENDOFRANGE infco +@c ENDOFRANGE lico +@c ENDOFRANGE woco +@c ENDOFRANGE chco +@c ENDOFRANGE posimawk + +@node Miscellaneous Programs +@section A Grab Bag of @command{awk} Programs + +This @value{SECTION} is a large ``grab bag'' of miscellaneous programs. +We hope you find them both interesting and enjoyable. + +@menu +* Dupword Program:: Finding duplicated words in a document. +* Alarm Program:: An alarm clock. +* Translate Program:: A program similar to the @command{tr} utility. +* Labels Program:: Printing mailing labels. +* Word Sorting:: A program to produce a word usage count. +* History Sorting:: Eliminating duplicate entries from a history + file. +* Extract Program:: Pulling out programs from Texinfo source + files. +* Simple Sed:: A Simple Stream Editor. +* Igawk Program:: A wrapper for @command{awk} that includes + files. +* Anagram Program:: Finding anagrams from a dictionary. +* Signature Program:: People do amazing things with too much time on + their hands. +@end menu + +@node Dupword Program +@subsection Finding Duplicated Words in a Document + +@cindex words, duplicate@comma{} searching for +@cindex searching, for words +@cindex documents@comma{} searching +A common error when writing large amounts of prose is to accidentally +duplicate words. Typically you will see this in text as something like ``the +the program does the following@dots{}'' When the text is online, often +the duplicated words occur at the end of one line and the +@iftex +the +@end iftex +beginning of +another, making them very difficult to spot. +@c as here! + +This program, @file{dupword.awk}, scans through a file one line at a time +and looks for adjacent occurrences of the same word. It also saves the last +word on a line (in the variable @code{prev}) for comparison with the first +word on the next line. + +@cindex Texinfo +The first two statements make sure that the line is all lowercase, +so that, for example, ``The'' and ``the'' compare equal to each other. +The next statement replaces nonalphanumeric and nonwhitespace characters +with spaces, so that punctuation does not affect the comparison either. +The characters are replaced with spaces so that formatting controls +don't create nonsense words (e.g., the Texinfo @samp{@@code@{NF@}} +becomes @samp{codeNF} if punctuation is simply deleted). The record is +then resplit into fields, yielding just the actual words on the line, +and ensuring that there are no empty fields. + +If there are no fields left after removing all the punctuation, the +current record is skipped. Otherwise, the program loops through each +word, comparing it to the previous one: + +@cindex @code{dupword.awk} program +@example +@c file eg/prog/dupword.awk +# dupword.awk --- find duplicate words in text +@c endfile +@ignore +@c file eg/prog/dupword.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# December 1991 +# Revised October 2000 + +@c endfile +@end ignore +@c file eg/prog/dupword.awk +@{ + $0 = tolower($0) + gsub(/[^[:alnum:][:blank:]]/, " "); + $0 = $0 # re-split + if (NF == 0) + next + if ($1 == prev) + printf("%s:%d: duplicate %s\n", + FILENAME, FNR, $1) + for (i = 2; i <= NF; i++) + if ($i == $(i-1)) + printf("%s:%d: duplicate %s\n", + FILENAME, FNR, $i) + prev = $NF +@} +@c endfile +@end example + +@node Alarm Program +@subsection An Alarm Clock Program +@cindex insomnia, cure for +@cindex Robbins, Arnold +@quotation +@i{Nothing cures insomnia like a ringing alarm clock.}@* +Arnold Robbins +@end quotation + +@c STARTOFRANGE tialarm +@cindex time, alarm clock example program +@c STARTOFRANGE alaex +@cindex alarm clock example program +The following program is a simple ``alarm clock'' program. +You give it a time of day and an optional message. At the specified time, +it prints the message on the standard output. In addition, you can give it +the number of times to repeat the message as well as a delay between +repetitions. + +This program uses the @code{gettimeofday()} function from +@ref{Gettimeofday Function}. + +All the work is done in the @code{BEGIN} rule. The first part is argument +checking and setting of defaults: the delay, the count, and the message to +print. If the user supplied a message without the ASCII BEL +character (known as the ``alert'' character, @code{"\a"}), then it is added to +the message. (On many systems, printing the ASCII BEL generates an +audible alert. Thus when the alarm goes off, the system calls attention +to itself in case the user is not looking at the computer.) +Just for a change, this program uses a @code{switch} statement +(@pxref{Switch Statement}), but the processing could be done with a series of +@code{if}-@code{else} statements instead. +Here is the program: + +@cindex @code{alarm.awk} program +@example +@c file eg/prog/alarm.awk +# alarm.awk --- set an alarm +# +# Requires gettimeofday() library function +@c endfile +@ignore +@c file eg/prog/alarm.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# May 1993 +# Revised December 2010 + +@c endfile +@end ignore +@c file eg/prog/alarm.awk +# usage: alarm time [ "message" [ count [ delay ] ] ] + +BEGIN \ +@{ + # Initial argument sanity checking + usage1 = "usage: alarm time ['message' [count [delay]]]" + usage2 = sprintf("\t(%s) time ::= hh:mm", ARGV[1]) + + if (ARGC < 2) @{ + print usage1 > "/dev/stderr" + print usage2 > "/dev/stderr" + exit 1 + @} + switch (ARGC) @{ + case 5: + delay = ARGV[4] + 0 + # fall through + case 4: + count = ARGV[3] + 0 + # fall through + case 3: + message = ARGV[2] + break + default: + if (ARGV[1] !~ /[[:digit:]]?[[:digit:]]:[[:digit:]]@{2@}/) @{ + print usage1 > "/dev/stderr" + print usage2 > "/dev/stderr" + exit 1 + @} + break + @} + + # set defaults for once we reach the desired time + if (delay == 0) + delay = 180 # 3 minutes +@group + if (count == 0) + count = 5 +@end group + if (message == "") + message = sprintf("\aIt is now %s!\a", ARGV[1]) + else if (index(message, "\a") == 0) + message = "\a" message "\a" +@c endfile +@end example + +The next @value{SECTION} of code turns the alarm time into hours and minutes, +converts it (if necessary) to a 24-hour clock, and then turns that +time into a count of the seconds since midnight. Next it turns the current +time into a count of seconds since midnight. The difference between the two +is how long to wait before setting off the alarm: + +@example +@c file eg/prog/alarm.awk + # split up alarm time + split(ARGV[1], atime, ":") + hour = atime[1] + 0 # force numeric + minute = atime[2] + 0 # force numeric + + # get current broken down time + gettimeofday(now) + + # if time given is 12-hour hours and it's after that + # hour, e.g., `alarm 5:30' at 9 a.m. means 5:30 p.m., + # then add 12 to real hour + if (hour < 12 && now["hour"] > hour) + hour += 12 + + # set target time in seconds since midnight + target = (hour * 60 * 60) + (minute * 60) + + # get current time in seconds since midnight + current = (now["hour"] * 60 * 60) + \ + (now["minute"] * 60) + now["second"] + + # how long to sleep for + naptime = target - current + if (naptime <= 0) @{ + print "time is in the past!" > "/dev/stderr" + exit 1 + @} +@c endfile +@end example + +@cindex @command{sleep} utility +Finally, the program uses the @code{system()} function +(@pxref{I/O Functions}) +to call the @command{sleep} utility. The @command{sleep} utility simply pauses +for the given number of seconds. If the exit status is not zero, +the program assumes that @command{sleep} was interrupted and exits. If +@command{sleep} exited with an OK status (zero), then the program prints the +message in a loop, again using @command{sleep} to delay for however many +seconds are necessary: + +@example +@c file eg/prog/alarm.awk + # zzzzzz..... go away if interrupted + if (system(sprintf("sleep %d", naptime)) != 0) + exit 1 + + # time to notify! + command = sprintf("sleep %d", delay) + for (i = 1; i <= count; i++) @{ + print message + # if sleep command interrupted, go away + if (system(command) != 0) + break + @} + + exit 0 +@} +@c endfile +@end example +@c ENDOFRANGE tialarm +@c ENDOFRANGE alaex + +@node Translate Program +@subsection Transliterating Characters + +@c STARTOFRANGE chtra +@cindex characters, transliterating +@cindex @command{tr} utility +The system @command{tr} utility transliterates characters. For example, it is +often used to map uppercase letters into lowercase for further processing: + +@example +@var{generate data} | tr 'A-Z' 'a-z' | @var{process data} @dots{} +@end example + +@command{tr} requires two lists of characters.@footnote{On some older +systems, +@ifset ORA +including Solaris, +@end ifset +@command{tr} may require that the lists be written as +range expressions enclosed in square brackets (@samp{[a-z]}) and quoted, +to prevent the shell from attempting a @value{FN} expansion. This is +not a feature.} When processing the input, the first character in the +first list is replaced with the first character in the second list, +the second character in the first list is replaced with the second +character in the second list, and so on. If there are more characters +in the ``from'' list than in the ``to'' list, the last character of the +``to'' list is used for the remaining characters in the ``from'' list. + +Some time ago, +@c early or mid-1989! +a user proposed that a transliteration function should +be added to @command{gawk}. +@c Wishing to avoid gratuitous new features, +@c at least theoretically +The following program was written to +prove that character transliteration could be done with a user-level +function. This program is not as complete as the system @command{tr} utility +but it does most of the job. + +The @command{translate} program demonstrates one of the few weaknesses +of standard @command{awk}: dealing with individual characters is very +painful, requiring repeated use of the @code{substr()}, @code{index()}, +and @code{gsub()} built-in functions +(@pxref{String Functions}).@footnote{This +program was written before @command{gawk} acquired the ability to +split each character in a string into separate array elements.} +@c Exercise: How might you use this new feature to simplify the program? +There are two functions. The first, @code{stranslate()}, takes three +arguments: + +@table @code +@item from +A list of characters from which to translate. + +@item to +A list of characters to which to translate. + +@item target +The string on which to do the translation. +@end table + +Associative arrays make the translation part fairly easy. @code{t_ar} holds +the ``to'' characters, indexed by the ``from'' characters. Then a simple +loop goes through @code{from}, one character at a time. For each character +in @code{from}, if the character appears in @code{target}, +it is replaced with the corresponding @code{to} character. + +The @code{translate()} function simply calls @code{stranslate()} using @code{$0} +as the target. The main program sets two global variables, @code{FROM} and +@code{TO}, from the command line, and then changes @code{ARGV} so that +@command{awk} reads from the standard input. + +Finally, the processing rule simply calls @code{translate()} for each record: + +@cindex @code{translate.awk} program +@example +@c file eg/prog/translate.awk +# translate.awk --- do tr-like stuff +@c endfile +@ignore +@c file eg/prog/translate.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# August 1989 +# February 2009 - bug fix + +@c endfile +@end ignore +@c file eg/prog/translate.awk +# Bugs: does not handle things like: tr A-Z a-z, it has +# to be spelled out. However, if `to' is shorter than `from', +# the last character in `to' is used for the rest of `from'. + +function stranslate(from, to, target, lf, lt, ltarget, t_ar, i, c, + result) +@{ + lf = length(from) + lt = length(to) + ltarget = length(target) + for (i = 1; i <= lt; i++) + t_ar[substr(from, i, 1)] = substr(to, i, 1) + if (lt < lf) + for (; i <= lf; i++) + t_ar[substr(from, i, 1)] = substr(to, lt, 1) + for (i = 1; i <= ltarget; i++) @{ + c = substr(target, i, 1) + if (c in t_ar) + c = t_ar[c] + result = result c + @} + return result +@} + +function translate(from, to) +@{ + return $0 = stranslate(from, to, $0) +@} + +# main program +BEGIN @{ +@group + if (ARGC < 3) @{ + print "usage: translate from to" > "/dev/stderr" + exit + @} +@end group + FROM = ARGV[1] + TO = ARGV[2] + ARGC = 2 + ARGV[1] = "-" +@} + +@{ + translate(FROM, TO) + print +@} +@c endfile +@end example + +While it is possible to do character transliteration in a user-level +function, it is not necessarily efficient, and we (the @command{gawk} +authors) started to consider adding a built-in function. However, +shortly after writing this program, we learned that the System V Release 4 +@command{awk} had added the @code{toupper()} and @code{tolower()} functions +(@pxref{String Functions}). +These functions handle the vast majority of the +cases where character transliteration is necessary, and so we chose to +simply add those functions to @command{gawk} as well and then leave well +enough alone. + +An obvious improvement to this program would be to set up the +@code{t_ar} array only once, in a @code{BEGIN} rule. However, this +assumes that the ``from'' and ``to'' lists +will never change throughout the lifetime of the program. +@c ENDOFRANGE chtra + +@node Labels Program +@subsection Printing Mailing Labels + +@c STARTOFRANGE prml +@cindex printing, mailing labels +@c STARTOFRANGE mlprint +@cindex mailing labels@comma{} printing +Here is a ``real world''@footnote{``Real world'' is defined as +``a program actually used to get something done.''} +program. This +script reads lists of names and +addresses and generates mailing labels. Each page of labels has 20 labels +on it, two across and 10 down. The addresses are guaranteed to be no more +than five lines of data. Each address is separated from the next by a blank +line. + +The basic idea is to read 20 labels worth of data. Each line of each label +is stored in the @code{line} array. The single rule takes care of filling +the @code{line} array and printing the page when 20 labels have been read. + +The @code{BEGIN} rule simply sets @code{RS} to the empty string, so that +@command{awk} splits records at blank lines +(@pxref{Records}). +It sets @code{MAXLINES} to 100, since 100 is the maximum number +of lines on the page (20 * 5 = 100). + +Most of the work is done in the @code{printpage()} function. +The label lines are stored sequentially in the @code{line} array. But they +have to print horizontally; @code{line[1]} next to @code{line[6]}, +@code{line[2]} next to @code{line[7]}, and so on. Two loops are used to +accomplish this. The outer loop, controlled by @code{i}, steps through +every 10 lines of data; this is each row of labels. The inner loop, +controlled by @code{j}, goes through the lines within the row. +As @code{j} goes from 0 to 4, @samp{i+j} is the @code{j}-th line in +the row, and @samp{i+j+5} is the entry next to it. The output ends up +looking something like this: + +@example +line 1 line 6 +line 2 line 7 +line 3 line 8 +line 4 line 9 +line 5 line 10 +@dots{} +@end example + +@noindent +The @code{printf} format string @samp{%-41s} left-aligns +the data and prints it within a fixed-width field. + +As a final note, an extra blank line is printed at lines 21 and 61, to keep +the output lined up on the labels. This is dependent on the particular +brand of labels in use when the program was written. You will also note +that there are two blank lines at the top and two blank lines at the bottom. + +The @code{END} rule arranges to flush the final page of labels; there may +not have been an even multiple of 20 labels in the data: + +@cindex @code{labels.awk} program +@example +@c file eg/prog/labels.awk +# labels.awk --- print mailing labels +@c endfile +@ignore +@c file eg/prog/labels.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# June 1992 +# December 2010, minor edits +@c endfile +@end ignore +@c file eg/prog/labels.awk + +# Each label is 5 lines of data that may have blank lines. +# The label sheets have 2 blank lines at the top and 2 at +# the bottom. + +BEGIN @{ RS = "" ; MAXLINES = 100 @} + +function printpage( i, j) +@{ + if (Nlines <= 0) + return + + printf "\n\n" # header + + for (i = 1; i <= Nlines; i += 10) @{ + if (i == 21 || i == 61) + print "" + for (j = 0; j < 5; j++) @{ + if (i + j > MAXLINES) + break + printf " %-41s %s\n", line[i+j], line[i+j+5] + @} + print "" + @} + + printf "\n\n" # footer + + delete line +@} + +# main rule +@{ + if (Count >= 20) @{ + printpage() + Count = 0 + Nlines = 0 + @} + n = split($0, a, "\n") + for (i = 1; i <= n; i++) + line[++Nlines] = a[i] + for (; i <= 5; i++) + line[++Nlines] = "" + Count++ +@} + +END \ +@{ + printpage() +@} +@c endfile +@end example +@c ENDOFRANGE prml +@c ENDOFRANGE mlprint + +@node Word Sorting +@subsection Generating Word-Usage Counts + +@c STARTOFRANGE worus +@cindex words, usage counts@comma{} generating + +When working with large amounts of text, it can be interesting to know +how often different words appear. For example, an author may overuse +certain words, in which case she might wish to find synonyms to substitute +for words that appear too often. This @value{SUBSECTION} develops a +program for counting words and presenting the frequency information +in a useful format. + +At first glance, a program like this would seem to do the job: + +@example +# Print list of word frequencies + +@{ + for (i = 1; i <= NF; i++) + freq[$i]++ +@} + +END @{ + for (word in freq) + printf "%s\t%d\n", word, freq[word] +@} +@end example + +The program relies on @command{awk}'s default field splitting +mechanism to break each line up into ``words,'' and uses an +associative array named @code{freq}, indexed by each word, to count +the number of times the word occurs. In the @code{END} rule, +it prints the counts. + +This program has several problems that prevent it from being +useful on real text files: + +@itemize @bullet +@item +The @command{awk} language considers upper- and lowercase characters to be +distinct. Therefore, ``bartender'' and ``Bartender'' are not treated +as the same word. This is undesirable, since in normal text, words +are capitalized if they begin sentences, and a frequency analyzer should not +be sensitive to capitalization. + +@item +Words are detected using the @command{awk} convention that fields are +separated just by whitespace. Other characters in the input (except +newlines) don't have any special meaning to @command{awk}. This means that +punctuation characters count as part of words. + +@item +The output does not come out in any useful order. You're more likely to be +interested in which words occur most frequently or in having an alphabetized +table of how frequently each word occurs. +@end itemize + +@cindex @command{sort} utility +The first problem can be solved by using @code{tolower()} to remove case +distinctions. The second problem can be solved by using @code{gsub()} +to remove punctuation characters. Finally, we solve the third problem +by using the system @command{sort} utility to process the output of the +@command{awk} script. Here is the new version of the program: + +@cindex @code{wordfreq.awk} program +@example +@c file eg/prog/wordfreq.awk +# wordfreq.awk --- print list of word frequencies + +@{ + $0 = tolower($0) # remove case distinctions + # remove punctuation + gsub(/[^[:alnum:]_[:blank:]]/, "", $0) + for (i = 1; i <= NF; i++) + freq[$i]++ +@} + +@c endfile +END @{ + for (word in freq) + printf "%s\t%d\n", word, freq[word] +@} +@end example + +Assuming we have saved this program in a file named @file{wordfreq.awk}, +and that the data is in @file{file1}, the following pipeline: + +@example +awk -f wordfreq.awk file1 | sort -k 2nr +@end example + +@noindent +produces a table of the words appearing in @file{file1} in order of +decreasing frequency. + +The @command{awk} program suitably massages the +data and produces a word frequency table, which is not ordered. +The @command{awk} script's output is then sorted by the @command{sort} +utility and printed on the screen. + +The options given to @command{sort} +specify a sort that uses the second field of each input line (skipping +one field), that the sort keys should be treated as numeric quantities +(otherwise @samp{15} would come before @samp{5}), and that the sorting +should be done in descending (reverse) order. + +The @command{sort} could even be done from within the program, by changing +the @code{END} action to: + +@example +@c file eg/prog/wordfreq.awk +END @{ + sort = "sort -k 2nr" + for (word in freq) + printf "%s\t%d\n", word, freq[word] | sort + close(sort) +@} +@c endfile +@end example + +This way of sorting must be used on systems that do not +have true pipes at the command-line (or batch-file) level. +See the general operating system documentation for more information on how +to use the @command{sort} program. +@c ENDOFRANGE worus + +@node History Sorting +@subsection Removing Duplicates from Unsorted Text + +@c STARTOFRANGE lidu +@cindex lines, duplicate@comma{} removing +The @command{uniq} program +(@pxref{Uniq Program}), +removes duplicate lines from @emph{sorted} data. + +Suppose, however, you need to remove duplicate lines from a @value{DF} but +that you want to preserve the order the lines are in. A good example of +this might be a shell history file. The history file keeps a copy of all +the commands you have entered, and it is not unusual to repeat a command +several times in a row. Occasionally you might want to compact the history +by removing duplicate entries. Yet it is desirable to maintain the order +of the original commands. + +This simple program does the job. It uses two arrays. The @code{data} +array is indexed by the text of each line. +For each line, @code{data[$0]} is incremented. +If a particular line has not +been seen before, then @code{data[$0]} is zero. +In this case, the text of the line is stored in @code{lines[count]}. +Each element of @code{lines} is a unique command, and the indices of +@code{lines} indicate the order in which those lines are encountered. +The @code{END} rule simply prints out the lines, in order: + +@cindex Rakitzis, Byron +@cindex @code{histsort.awk} program +@example +@c file eg/prog/histsort.awk +# histsort.awk --- compact a shell history file +# Thanks to Byron Rakitzis for the general idea +@c endfile +@ignore +@c file eg/prog/histsort.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# May 1993 +@c endfile +@end ignore +@c file eg/prog/histsort.awk + +@group +@{ + if (data[$0]++ == 0) + lines[++count] = $0 +@} +@end group + +@group +END @{ + for (i = 1; i <= count; i++) + print lines[i] +@} +@end group +@c endfile +@end example + +This program also provides a foundation for generating other useful +information. For example, using the following @code{print} statement in the +@code{END} rule indicates how often a particular command is used: + +@example +print data[lines[i]], lines[i] +@end example + +This works because @code{data[$0]} is incremented each time a line is +seen. +@c ENDOFRANGE lidu + +@node Extract Program +@subsection Extracting Programs from Texinfo Source Files + +@c STARTOFRANGE texse +@cindex Texinfo, extracting programs from source files +@c STARTOFRANGE fitex +@cindex files, Texinfo@comma{} extracting programs from +@ifnotinfo +Both this chapter and the previous chapter +(@ref{Library Functions}) +present a large number of @command{awk} programs. +@end ifnotinfo +@ifinfo +The nodes +@ref{Library Functions}, +and @ref{Sample Programs}, +are the top level nodes for a large number of @command{awk} programs. +@end ifinfo +If you want to experiment with these programs, it is tedious to have to type +them in by hand. Here we present a program that can extract parts of a +Texinfo input file into separate files. + +@cindex Texinfo +This @value{DOCUMENT} is written in @uref{http://texinfo.org, Texinfo}, +the GNU project's document formatting language. +A single Texinfo source file can be used to produce both +printed and online documentation. +@ifnotinfo +Texinfo is fully documented in the book +@cite{Texinfo---The GNU Documentation Format}, +available from the Free Software Foundation. +@end ifnotinfo +@ifinfo +The Texinfo language is described fully, starting with +@inforef{Top, , Texinfo, texinfo,Texinfo---The GNU Documentation Format}. +@end ifinfo + +For our purposes, it is enough to know three things about Texinfo input +files: + +@itemize @bullet +@item +The ``at'' symbol (@samp{@@}) is special in Texinfo, much as +the backslash (@samp{\}) is in C +or @command{awk}. Literal @samp{@@} symbols are represented in Texinfo source +files as @samp{@@@@}. + +@item +Comments start with either @samp{@@c} or @samp{@@comment}. +The file-extraction program works by using special comments that start +at the beginning of a line. + +@item +Lines containing @samp{@@group} and @samp{@@end group} commands bracket +example text that should not be split across a page boundary. +(Unfortunately, @TeX{} isn't always smart enough to do things exactly right, +so we have to give it some help.) +@end itemize + +The following program, @file{extract.awk}, reads through a Texinfo source +file and does two things, based on the special comments. +Upon seeing @samp{@w{@@c system @dots{}}}, +it runs a command, by extracting the command text from the +control line and passing it on to the @code{system()} function +(@pxref{I/O Functions}). +Upon seeing @samp{@@c file @var{filename}}, each subsequent line is sent to +the file @var{filename}, until @samp{@@c endfile} is encountered. +The rules in @file{extract.awk} match either @samp{@@c} or +@samp{@@comment} by letting the @samp{omment} part be optional. +Lines containing @samp{@@group} and @samp{@@end group} are simply removed. +@file{extract.awk} uses the @code{join()} library function +(@pxref{Join Function}). + +The example programs in the online Texinfo source for @cite{@value{TITLE}} +(@file{gawk.texi}) have all been bracketed inside @samp{file} and +@samp{endfile} lines. The @command{gawk} distribution uses a copy of +@file{extract.awk} to extract the sample programs and install many +of them in a standard directory where @command{gawk} can find them. +The Texinfo file looks something like this: + +@example +@dots{} +This program has a @@code@{BEGIN@} rule, +that prints a nice message: + +@@example +@@c file examples/messages.awk +BEGIN @@@{ print "Don't panic!" @@@} +@@c end file +@@end example + +It also prints some final advice: + +@@example +@@c file examples/messages.awk +END @@@{ print "Always avoid bored archeologists!" @@@} +@@c end file +@@end example +@dots{} +@end example + +@file{extract.awk} begins by setting @code{IGNORECASE} to one, so that +mixed upper- and lowercase letters in the directives won't matter. + +The first rule handles calling @code{system()}, checking that a command is +given (@code{NF} is at least three) and also checking that the command +exits with a zero exit status, signifying OK: + +@cindex @code{extract.awk} program +@example +@c file eg/prog/extract.awk +# extract.awk --- extract files and run programs +# from texinfo files +@c endfile +@ignore +@c file eg/prog/extract.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# May 1993 +# Revised September 2000 +@c endfile +@end ignore +@c file eg/prog/extract.awk + +BEGIN @{ IGNORECASE = 1 @} + +/^@@c(omment)?[ \t]+system/ \ +@{ + if (NF < 3) @{ + e = (FILENAME ":" FNR) + e = (e ": badly formed `system' line") + print e > "/dev/stderr" + next + @} + $1 = "" + $2 = "" + stat = system($0) + if (stat != 0) @{ + e = (FILENAME ":" FNR) + e = (e ": warning: system returned " stat) + print e > "/dev/stderr" + @} +@} +@c endfile +@end example + +@noindent +The variable @code{e} is used so that the rule +fits nicely on the +@ifnotinfo +page. +@end ifnotinfo +@ifnottex +screen. +@end ifnottex + +The second rule handles moving data into files. It verifies that a +@value{FN} is given in the directive. If the file named is not the +current file, then the current file is closed. Keeping the current file +open until a new file is encountered allows the use of the @samp{>} +redirection for printing the contents, keeping open file management +simple. + +The @code{for} loop does the work. It reads lines using @code{getline} +(@pxref{Getline}). +For an unexpected end of file, it calls the @code{@w{unexpected_eof()}} +function. If the line is an ``endfile'' line, then it breaks out of +the loop. +If the line is an @samp{@@group} or @samp{@@end group} line, then it +ignores it and goes on to the next line. +Similarly, comments within examples are also ignored. + +Most of the work is in the following few lines. If the line has no @samp{@@} +symbols, the program can print it directly. +Otherwise, each leading @samp{@@} must be stripped off. +To remove the @samp{@@} symbols, the line is split into separate elements of +the array @code{a}, using the @code{split()} function +(@pxref{String Functions}). +The @samp{@@} symbol is used as the separator character. +Each element of @code{a} that is empty indicates two successive @samp{@@} +symbols in the original line. For each two empty elements (@samp{@@@@} in +the original file), we have to add a single @samp{@@} symbol back +in.@footnote{This program was written before @command{gawk} had the +@code{gensub()} function. Consider how you might use it to simplify the code.} + +When the processing of the array is finished, @code{join()} is called with the +value of @code{SUBSEP}, to rejoin the pieces back into a single +line. That line is then printed to the output file: + +@example +@c file eg/prog/extract.awk +/^@@c(omment)?[ \t]+file/ \ +@{ + if (NF != 3) @{ + e = (FILENAME ":" FNR ": badly formed `file' line") + print e > "/dev/stderr" + next + @} + if ($3 != curfile) @{ + if (curfile != "") + close(curfile) + curfile = $3 + @} + + for (;;) @{ + if ((getline line) <= 0) + unexpected_eof() + if (line ~ /^@@c(omment)?[ \t]+endfile/) + break + else if (line ~ /^@@(end[ \t]+)?group/) + continue + else if (line ~ /^@@c(omment+)?[ \t]+/) + continue + if (index(line, "@@") == 0) @{ + print line > curfile + continue + @} + n = split(line, a, "@@") + # if a[1] == "", means leading @@, + # don't add one back in. + for (i = 2; i <= n; i++) @{ + if (a[i] == "") @{ # was an @@@@ + a[i] = "@@" + if (a[i+1] == "") + i++ + @} + @} + print join(a, 1, n, SUBSEP) > curfile + @} +@} +@c endfile +@end example + +An important thing to note is the use of the @samp{>} redirection. +Output done with @samp{>} only opens the file once; it stays open and +subsequent output is appended to the file +(@pxref{Redirection}). +This makes it easy to mix program text and explanatory prose for the same +sample source file (as has been done here!) without any hassle. The file is +only closed when a new data @value{FN} is encountered or at the end of the +input file. + +Finally, the function @code{@w{unexpected_eof()}} prints an appropriate +error message and then exits. +The @code{END} rule handles the final cleanup, closing the open file: + +@c function lb put on same line for page breaking. sigh +@example +@c file eg/prog/extract.awk +@group +function unexpected_eof() +@{ + printf("%s:%d: unexpected EOF or error\n", + FILENAME, FNR) > "/dev/stderr" + exit 1 +@} +@end group + +END @{ + if (curfile) + close(curfile) +@} +@c endfile +@end example +@c ENDOFRANGE texse +@c ENDOFRANGE fitex + +@node Simple Sed +@subsection A Simple Stream Editor + +@cindex @command{sed} utility +@cindex stream editors +The @command{sed} utility is a stream editor, a program that reads a +stream of data, makes changes to it, and passes it on. +It is often used to make global changes to a large file or to a stream +of data generated by a pipeline of commands. +While @command{sed} is a complicated program in its own right, its most common +use is to perform global substitutions in the middle of a pipeline: + +@example +command1 < orig.data | sed 's/old/new/g' | command2 > result +@end example + +Here, @samp{s/old/new/g} tells @command{sed} to look for the regexp +@samp{old} on each input line and globally replace it with the text +@samp{new}, i.e., all the occurrences on a line. This is similar to +@command{awk}'s @code{gsub()} function +(@pxref{String Functions}). + +The following program, @file{awksed.awk}, accepts at least two command-line +arguments: the pattern to look for and the text to replace it with. Any +additional arguments are treated as data @value{FN}s to process. If none +are provided, the standard input is used: + +@cindex Brennan, Michael +@cindex @command{awksed.awk} program +@c @cindex simple stream editor +@c @cindex stream editor, simple +@example +@c file eg/prog/awksed.awk +# awksed.awk --- do s/foo/bar/g using just print +# Thanks to Michael Brennan for the idea +@c endfile +@ignore +@c file eg/prog/awksed.awk +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# August 1995 +@c endfile +@end ignore +@c file eg/prog/awksed.awk + +function usage() +@{ + print "usage: awksed pat repl [files...]" > "/dev/stderr" + exit 1 +@} + +BEGIN @{ + # validate arguments + if (ARGC < 3) + usage() + + RS = ARGV[1] + ORS = ARGV[2] + + # don't use arguments as files + ARGV[1] = ARGV[2] = "" +@} + +@group +# look ma, no hands! +@{ + if (RT == "") + printf "%s", $0 + else + print +@} +@end group +@c endfile +@end example + +The program relies on @command{gawk}'s ability to have @code{RS} be a regexp, +as well as on the setting of @code{RT} to the actual text that terminates the +record (@pxref{Records}). + +The idea is to have @code{RS} be the pattern to look for. @command{gawk} +automatically sets @code{$0} to the text between matches of the pattern. +This is text that we want to keep, unmodified. Then, by setting @code{ORS} +to the replacement text, a simple @code{print} statement outputs the +text we want to keep, followed by the replacement text. + +There is one wrinkle to this scheme, which is what to do if the last record +doesn't end with text that matches @code{RS}. Using a @code{print} +statement unconditionally prints the replacement text, which is not correct. +However, if the file did not end in text that matches @code{RS}, @code{RT} +is set to the null string. In this case, we can print @code{$0} using +@code{printf} +(@pxref{Printf}). + +The @code{BEGIN} rule handles the setup, checking for the right number +of arguments and calling @code{usage()} if there is a problem. Then it sets +@code{RS} and @code{ORS} from the command-line arguments and sets +@code{ARGV[1]} and @code{ARGV[2]} to the null string, so that they are +not treated as @value{FN}s +(@pxref{ARGC and ARGV}). + +The @code{usage()} function prints an error message and exits. +Finally, the single rule handles the printing scheme outlined above, +using @code{print} or @code{printf} as appropriate, depending upon the +value of @code{RT}. + +@ignore +Exercise, compare the performance of this version with the more +straightforward: + +BEGIN { + pat = ARGV[1] + repl = ARGV[2] + ARGV[1] = ARGV[2] = "" +} + +{ gsub(pat, repl); print } + +Exercise: what are the advantages and disadvantages of this version versus sed? + Advantage: egrep regexps + speed (?) + Disadvantage: no & in replacement text + +Others? +@end ignore + +@node Igawk Program +@subsection An Easy Way to Use Library Functions + +@c STARTOFRANGE libfex +@cindex libraries of @command{awk} functions, example program for using +@c STARTOFRANGE flibex +@cindex functions, library, example program for using +In @ref{Include Files}, we saw how @command{gawk} provides a built-in +file-inclusion capability. However, this is a @command{gawk} extension. +This @value{SECTION} provides the motivation for making file inclusion +available for standard @command{awk}, and shows how to do it using a +combination of shell and @command{awk} programming. + +Using library functions in @command{awk} can be very beneficial. It +encourages code reuse and the writing of general functions. Programs are +smaller and therefore clearer. +However, using library functions is only easy when writing @command{awk} +programs; it is painful when running them, requiring multiple @option{-f} +options. If @command{gawk} is unavailable, then so too is the @env{AWKPATH} +environment variable and the ability to put @command{awk} functions into a +library directory (@pxref{Options}). +It would be nice to be able to write programs in the following manner: + +@example +# library functions +@@include getopt.awk +@@include join.awk +@dots{} + +# main program +BEGIN @{ + while ((c = getopt(ARGC, ARGV, "a:b:cde")) != -1) + @dots{} + @dots{} +@} +@end example + +The following program, @file{igawk.sh}, provides this service. +It simulates @command{gawk}'s searching of the @env{AWKPATH} variable +and also allows @dfn{nested} includes; i.e., a file that is included +with @samp{@@include} can contain further @samp{@@include} statements. +@command{igawk} makes an effort to only include files once, so that nested +includes don't accidentally include a library function twice. + +@command{igawk} should behave just like @command{gawk} externally. This +means it should accept all of @command{gawk}'s command-line arguments, +including the ability to have multiple source files specified via +@option{-f}, and the ability to mix command-line and library source files. + +The program is written using the POSIX Shell (@command{sh}) command +language.@footnote{Fully explaining the @command{sh} language is beyond +the scope of this book. We provide some minimal explanations, but see +a good shell programming book if you wish to understand things in more +depth.} It works as follows: + +@enumerate +@item +Loop through the arguments, saving anything that doesn't represent +@command{awk} source code for later, when the expanded program is run. + +@item +For any arguments that do represent @command{awk} text, put the arguments into +a shell variable that will be expanded. There are two cases: + +@enumerate a +@item +Literal text, provided with @option{--source} or @option{--source=}. This +text is just appended directly. + +@item +Source @value{FN}s, provided with @option{-f}. We use a neat trick and append +@samp{@@include @var{filename}} to the shell variable's contents. Since the file-inclusion +program works the way @command{gawk} does, this gets the text +of the file included into the program at the correct point. +@end enumerate + +@item +Run an @command{awk} program (naturally) over the shell variable's contents to expand +@samp{@@include} statements. The expanded program is placed in a second +shell variable. + +@item +Run the expanded program with @command{gawk} and any other original command-line +arguments that the user supplied (such as the data @value{FN}s). +@end enumerate + +This program uses shell variables extensively: for storing command-line arguments, +the text of the @command{awk} program that will expand the user's program, for the +user's original program, and for the expanded program. Doing so removes some +potential problems that might arise were we to use temporary files instead, +at the cost of making the script somewhat more complicated. + +The initial part of the program turns on shell tracing if the first +argument is @samp{debug}. + +The next part loops through all the command-line arguments. +There are several cases of interest: + +@table @code +@item -- +This ends the arguments to @command{igawk}. Anything else should be passed on +to the user's @command{awk} program without being evaluated. + +@item -W +This indicates that the next option is specific to @command{gawk}. To make +argument processing easier, the @option{-W} is appended to the front of the +remaining arguments and the loop continues. (This is an @command{sh} +programming trick. Don't worry about it if you are not familiar with +@command{sh}.) + +@item -v@r{,} -F +These are saved and passed on to @command{gawk}. + +@item -f@r{,} --file@r{,} --file=@r{,} -Wfile= +The @value{FN} is appended to the shell variable @code{program} with an +@samp{@@include} statement. +The @command{expr} utility is used to remove the leading option part of the +argument (e.g., @samp{--file=}). +(Typical @command{sh} usage would be to use the @command{echo} and @command{sed} +utilities to do this work. Unfortunately, some versions of @command{echo} evaluate +escape sequences in their arguments, possibly mangling the program text. +Using @command{expr} avoids this problem.) + +@item --source@r{,} --source=@r{,} -Wsource= +The source text is appended to @code{program}. + +@item --version@r{,} -Wversion +@command{igawk} prints its version number, runs @samp{gawk --version} +to get the @command{gawk} version information, and then exits. +@end table + +If none of the @option{-f}, @option{--file}, @option{-Wfile}, @option{--source}, +or @option{-Wsource} arguments are supplied, then the first nonoption argument +should be the @command{awk} program. If there are no command-line +arguments left, @command{igawk} prints an error message and exits. +Otherwise, the first argument is appended to @code{program}. +In any case, after the arguments have been processed, +@code{program} contains the complete text of the original @command{awk} +program. + +The program is as follows: + +@cindex @code{igawk.sh} program +@example +@c file eg/prog/igawk.sh +#! /bin/sh +# igawk --- like gawk but do @@include processing +@c endfile +@ignore +@c file eg/prog/igawk.sh +# +# Arnold Robbins, arnold@@skeeve.com, Public Domain +# July 1993 +# December 2010, minor edits +@c endfile +@end ignore +@c file eg/prog/igawk.sh + +if [ "$1" = debug ] +then + set -x + shift +fi + +# A literal newline, so that program text is formatted correctly +n=' +' + +# Initialize variables to empty +program= +opts= + +while [ $# -ne 0 ] # loop over arguments +do + case $1 in + --) shift + break ;; + + -W) shift + # The $@{x?'message here'@} construct prints a + # diagnostic if $x is the null string + set -- -W"$@{@@?'missing operand'@}" + continue ;; + + -[vF]) opts="$opts $1 '$@{2?'missing operand'@}'" + shift ;; + + -[vF]*) opts="$opts '$1'" ;; + + -f) program="$program$n@@include $@{2?'missing operand'@}" + shift ;; + + -f*) f=$(expr "$1" : '-f\(.*\)') + program="$program$n@@include $f" ;; + + -[W-]file=*) + f=$(expr "$1" : '-.file=\(.*\)') + program="$program$n@@include $f" ;; + + -[W-]file) + program="$program$n@@include $@{2?'missing operand'@}" + shift ;; + + -[W-]source=*) + t=$(expr "$1" : '-.source=\(.*\)') + program="$program$n$t" ;; + + -[W-]source) + program="$program$n$@{2?'missing operand'@}" + shift ;; + + -[W-]version) + echo igawk: version 3.0 1>&2 + gawk --version + exit 0 ;; + + -[W-]*) opts="$opts '$1'" ;; + + *) break ;; + esac + shift +done + +if [ -z "$program" ] +then + program=$@{1?'missing program'@} + shift +fi + +# At this point, `program' has the program. +@c endfile +@end example + +The @command{awk} program to process @samp{@@include} directives +is stored in the shell variable @code{expand_prog}. Doing this keeps +the shell script readable. The @command{awk} program +reads through the user's program, one line at a time, using @code{getline} +(@pxref{Getline}). The input +@value{FN}s and @samp{@@include} statements are managed using a stack. +As each @samp{@@include} is encountered, the current @value{FN} is +``pushed'' onto the stack and the file named in the @samp{@@include} +directive becomes the current @value{FN}. As each file is finished, +the stack is ``popped,'' and the previous input file becomes the current +input file again. The process is started by making the original file +the first one on the stack. + +The @code{pathto()} function does the work of finding the full path to +a file. It simulates @command{gawk}'s behavior when searching the +@env{AWKPATH} environment variable +(@pxref{AWKPATH Variable}). +If a @value{FN} has a @samp{/} in it, no path search is done. +Similarly, if the @value{FN} is @code{"-"}, then that string is +used as-is. Otherwise, +the @value{FN} is concatenated with the name of each directory in +the path, and an attempt is made to open the generated @value{FN}. +The only way to test if a file can be read in @command{awk} is to go +ahead and try to read it with @code{getline}; this is what @code{pathto()} +does.@footnote{On some very old versions of @command{awk}, the test +@samp{getline junk < t} can loop forever if the file exists but is empty. +Caveat emptor.} If the file can be read, it is closed and the @value{FN} +is returned: + +@ignore +An alternative way to test for the file's existence would be to call +@samp{system("test -r " t)}, which uses the @command{test} utility to +see if the file exists and is readable. The disadvantage to this method +is that it requires creating an extra process and can thus be slightly +slower. +@end ignore + +@example +@c file eg/prog/igawk.sh +expand_prog=' + +function pathto(file, i, t, junk) +@{ + if (index(file, "/") != 0) + return file + + if (file == "-") + return file + + for (i = 1; i <= ndirs; i++) @{ + t = (pathlist[i] "/" file) +@group + if ((getline junk < t) > 0) @{ + # found it + close(t) + return t + @} +@end group + @} + return "" +@} +@c endfile +@end example + +The main program is contained inside one @code{BEGIN} rule. The first thing it +does is set up the @code{pathlist} array that @code{pathto()} uses. After +splitting the path on @samp{:}, null elements are replaced with @code{"."}, +which represents the current directory: + +@example +@c file eg/prog/igawk.sh +BEGIN @{ + path = ENVIRON["AWKPATH"] + ndirs = split(path, pathlist, ":") + for (i = 1; i <= ndirs; i++) @{ + if (pathlist[i] == "") + pathlist[i] = "." + @} +@c endfile +@end example + +The stack is initialized with @code{ARGV[1]}, which will be @file{/dev/stdin}. +The main loop comes next. Input lines are read in succession. Lines that +do not start with @samp{@@include} are printed verbatim. +If the line does start with @samp{@@include}, the @value{FN} is in @code{$2}. +@code{pathto()} is called to generate the full path. If it cannot, then the program +prints an error message and continues. + +The next thing to check is if the file is included already. The +@code{processed} array is indexed by the full @value{FN} of each included +file and it tracks this information for us. If the file is +seen again, a warning message is printed. Otherwise, the new @value{FN} is +pushed onto the stack and processing continues. + +Finally, when @code{getline} encounters the end of the input file, the file +is closed and the stack is popped. When @code{stackptr} is less than zero, +the program is done: + +@example +@c file eg/prog/igawk.sh + stackptr = 0 + input[stackptr] = ARGV[1] # ARGV[1] is first file + + for (; stackptr >= 0; stackptr--) @{ + while ((getline < input[stackptr]) > 0) @{ + if (tolower($1) != "@@include") @{ + print + continue + @} + fpath = pathto($2) +@group + if (fpath == "") @{ + printf("igawk:%s:%d: cannot find %s\n", + input[stackptr], FNR, $2) > "/dev/stderr" + continue + @} +@end group + if (! (fpath in processed)) @{ + processed[fpath] = input[stackptr] + input[++stackptr] = fpath # push onto stack + @} else + print $2, "included in", input[stackptr], + "already included in", + processed[fpath] > "/dev/stderr" + @} + close(input[stackptr]) + @} +@}' # close quote ends `expand_prog' variable + +processed_program=$(gawk -- "$expand_prog" /dev/stdin << EOF +$program +EOF +) +@c endfile +@end example + +The shell construct @samp{@var{command} << @var{marker}} is called a @dfn{here document}. +Everything in the shell script up to the @var{marker} is fed to @var{command} as input. +The shell processes the contents of the here document for variable and command substitution +(and possibly other things as well, depending upon the shell). + +The shell construct @samp{$(@dots{})} is called @dfn{command substitution}. +The output of the command inside the parentheses is substituted +into the command line. +Because the result is used in a variable assignment, +it is saved as a single string, even if the results contain whitespace. + +The expanded program is saved in the variable @code{processed_program}. +It's done in these steps: + +@enumerate +@item +Run @command{gawk} with the @samp{@@include}-processing program (the +value of the @code{expand_prog} shell variable) on standard input. + +@item +Standard input is the contents of the user's program, from the shell variable @code{program}. +Its contents are fed to @command{gawk} via a here document. + +@item +The results of this processing are saved in the shell variable @code{processed_program} by using command substitution. +@end enumerate + +The last step is to call @command{gawk} with the expanded program, +along with the original +options and command-line arguments that the user supplied. + +@c this causes more problems than it solves, so leave it out. +@ignore +The special file @file{/dev/null} is passed as a @value{DF} to @command{gawk} +to handle an interesting case. Suppose that the user's program only has +a @code{BEGIN} rule and there are no @value{DF}s to read. +The program should exit without reading any @value{DF}s. +However, suppose that an included library file defines an @code{END} +rule of its own. In this case, @command{gawk} will hang, reading standard +input. In order to avoid this, @file{/dev/null} is explicitly added to the +command-line. Reading from @file{/dev/null} always returns an immediate +end of file indication. + +@c Hmm. Add /dev/null if $# is 0? Still messes up ARGV. Sigh. +@end ignore + +@example +@c file eg/prog/igawk.sh +eval gawk $opts -- '"$processed_program"' '"$@@"' +@c endfile +@end example + +The @command{eval} command is a shell construct that reruns the shell's parsing +process. This keeps things properly quoted. + +This version of @command{igawk} represents my fifth version of this program. +There are four key simplifications that make the program work better: + +@itemize @bullet +@item +Using @samp{@@include} even for the files named with @option{-f} makes building +the initial collected @command{awk} program much simpler; all the +@samp{@@include} processing can be done once. + +@item +Not trying to save the line read with @code{getline} +in the @code{pathto()} function when testing for the +file's accessibility for use with the main program simplifies things +considerably. +@c what problem does this engender though - exercise +@c answer, reading from "-" or /dev/stdin + +@item +Using a @code{getline} loop in the @code{BEGIN} rule does it all in one +place. It is not necessary to call out to a separate loop for processing +nested @samp{@@include} statements. + +@item +Instead of saving the expanded program in a temporary file, putting it in a shell variable +avoids some potential security problems. +This has the disadvantage that the script relies upon more features +of the @command{sh} language, making it harder to follow for those who +aren't familiar with @command{sh}. +@end itemize + +Also, this program illustrates that it is often worthwhile to combine +@command{sh} and @command{awk} programming together. You can usually +accomplish quite a lot, without having to resort to low-level programming +in C or C++, and it is frequently easier to do certain kinds of string +and argument manipulation using the shell than it is in @command{awk}. + +Finally, @command{igawk} shows that it is not always necessary to add new +features to a program; they can often be layered on top. +@ignore +With @command{igawk}, +there is no real reason to build @samp{@@include} processing into +@command{gawk} itself. +@end ignore + +@cindex search paths +@cindex search paths, for source files +@cindex source files@comma{} search path for +@cindex files, source@comma{} search path for +@cindex directories, searching +As an additional example of this, consider the idea of having two +files in a directory in the search path: + +@table @file +@item default.awk +This file contains a set of default library functions, such +as @code{getopt()} and @code{assert()}. + +@item site.awk +This file contains library functions that are specific to a site or +installation; i.e., locally developed functions. +Having a separate file allows @file{default.awk} to change with +new @command{gawk} releases, without requiring the system administrator to +update it each time by adding the local functions. +@end table + +One user +@c Karl Berry, karl@ileaf.com, 10/95 +suggested that @command{gawk} be modified to automatically read these files +upon startup. Instead, it would be very simple to modify @command{igawk} +to do this. Since @command{igawk} can process nested @samp{@@include} +directives, @file{default.awk} could simply contain @samp{@@include} +statements for the desired library functions. + +@c Exercise: make this change +@c ENDOFRANGE libfex +@c ENDOFRANGE flibex +@c ENDOFRANGE awkpex + +@node Anagram Program +@subsection Finding Anagrams From A Dictionary + +An interesting programming challenge is to +search for @dfn{anagrams} in a +word list (such as +@file{/usr/share/dict/words} on many GNU/Linux systems). +One word is an anagram of another if both words contain +the same letters +(for example, ``babbling'' and ``blabbing''). + +An elegant algorithm is presented in Column 2, Problem C of +Jon Bentley's @cite{Programming Pearls}, second edition. +The idea is to give words that are anagrams a common signature, +sort all the words together by their signature, and then print them. +Dr.@: Bentley observes that taking the letters in each word and +sorting them produces that common signature. + +The following program uses arrays of arrays to bring together +words with the same signature and array sorting to print the words +in sorted order. + +@cindex @code{anagram.awk} program +@example +@c file eg/prog/anagram.awk +# anagram.awk --- An implementation of the anagram finding algorithm +# from Jon Bentley's "Programming Pearls", 2nd edition. +# Addison Wesley, 2000, ISBN 0-201-65788-0. +# Column 2, Problem C, section 2.8, pp 18-20. +@c endfile +@ignore +@c file eg/prog/anagram.awk +# +# This program requires gawk 4.0 or newer. +# Required gawk-specific features: +# - True multidimensional arrays +# - split() with "" as separator splits out individual characters +# - asort() and asorti() functions +# +# See http://savannah.gnu.org/projects/gawk. +# +# Arnold Robbins +# arnold@@skeeve.com +# Public Domain +# January, 2011 +@c endfile +@end ignore +@c file eg/prog/anagram.awk + +/'s$/ @{ next @} # Skip possessives +@c endfile +@end example + +The program starts with a header, and then a rule to skip +possessives in the dictionary file. The next rule builds +up the data structure. The first dimension of the array +is indexed by the signature; the second dimension is the word +itself: + +@example +@c file eg/prog/anagram.awk +@{ + key = word2key($1) # Build signature + data[key][$1] = $1 # Store word with signature +@} +@c endfile +@end example + +The @code{word2key()} function creates the signature. +It splits the word apart into individual letters, +sorts the letters, and then joins them back together: + +@example +@c file eg/prog/anagram.awk +# word2key --- split word apart into letters, sort, joining back together + +function word2key(word, a, i, n, result) +@{ + n = split(word, a, "") + asort(a) + + for (i = 1; i <= n; i++) + result = result a[i] + + return result +@} +@c endfile +@end example + +Finally, the @code{END} rule traverses the array +and prints out the anagram lists. It sends the output +to the system @command{sort} command, since otherwise +the anagrams would appear in arbitrary order: + +@example +@c file eg/prog/anagram.awk +END @{ + sort = "sort" + for (key in data) @{ + # Sort words with same key + nwords = asorti(data[key], words) + if (nwords == 1) + continue + + # And print. Minor glitch: trailing space at end of each line + for (j = 1; j <= nwords; j++) + printf("%s ", words[j]) | sort + print "" | sort + @} + close(sort) +@} +@c endfile +@end example + +Here is some partial output when the program is run: + +@example +$ @kbd{gawk -f anagram.awk /usr/share/dict/words | grep '^b'} +@dots{} +babbled blabbed +babbler blabber brabble +babblers blabbers brabbles +babbling blabbing +babbly blabby +babel bable +babels beslab +babery yabber +@dots{} +@end example + +@node Signature Program +@subsection And Now For Something Completely Different + +The following program was written by Davide Brini +@c (@email{dave_br@@gmx.com}) +and is published on @uref{http://backreference.org/2011/02/03/obfuscated-awk/, +his website}. +It serves as his signature in the Usenet group @code{comp.lang.awk}. +He supplies the following copyright terms: + +@quotation +Copyright @copyright{} 2008 Davide Brini + +Copying and distribution of the code published in this page, with or without +modification, are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. +@end quotation + +Here is the program: + +@example +awk 'BEGIN@{O="~"~"~";o="=="=="==";o+=+o;x=O""O;while(X++<=x+o+o)c=c"%c"; +printf c,(x-O)*(x-O),x*(x-o)-o,x*(x-O)+x-O-o,+x*(x-O)-x+o,X*(o*o+O)+x-O, +X*(X-x)-o*o,(x+X)*o*o+o,x*(X-x)-O-O,x-O+(O+o+X+x)*(o+O),X*X-X*(x-O)-x+O, +O+X*(o*(o+O)+O),+x+O+X*o,x*(x-o),(o+X+x)*o*o-(x-O-O),O+(X-x)*(X+O),x-O@}' +@end example + +We leave it to you to determine what the program does. + +@ignore +To: "Arnold Robbins" +Date: Sat, 20 Aug 2011 13:50:46 -0400 +Subject: The GNU Awk User's Guide, Section 13.3.11 +From: "Chris Johansen" +Message-ID: + +Arnold, you don't know me, but we have a tenuous connection. My wife is +Barbara A. Field, FAIA, GIT '65 (B. Arch.). + +I have had a couple of paper copies of "Effective Awk Programming" for +years, and now I'm going through a Kindle version of "The GNU Awk User's +Guide" again. When I got to section 13.3.11, I reformatted and lightly +commented Davide Brin's signature script to understand its workings. + +It occurs to me that this might have pedagogical value as an example +(although imperfect) of the value of whitespace and comments, and a +starting point for that discussion. It certainly helped _me_ understand +what's going on. You are welcome to it, as-is or modified (subject to +Davide's constraints, of course, which I think I have met). + +If I were to include it in a future edition, I would put it at some +distance from section 13.3.11, say, as a note or an appendix, so as not to +be a "spoiler" to the puzzle. + +Best regards, +-- +Chris Johansen {johansen at main dot nc dot us} + . . . collapsing the probability wave function, sending ripples of +certainty through the space-time continuum. + + +#! /usr/bin/gawk -f + +# From "13.3.11 And Now For Something Completely Different" +# http://www.gnu.org/software/gawk/manual/html_node/Signature-Program.html#Signature-Program + +# Copyright © 2008 Davide Brini + +# Copying and distribution of the code published in this page, with +# or without modification, are permitted in any medium without +# royalty provided the copyright notice and this notice are preserved. + +BEGIN { + O = "~" ~ "~"; # 1 + o = "==" == "=="; # 1 + o += +o; # 2 + x = O "" O; # 11 + + + while ( X++ <= x + o + o ) c = c "%c"; + + # O is 1 + # o is 2 + # x is 11 + # X is 17 + # c is "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c" + + printf c, + ( x - O )*( x - O), # 100 d + x*( x - o ) - o, # 97 a + x*( x - O ) + x - O - o, # 118 v + +x*( x - O ) - x + o, # 101 e + X*( o*o + O ) + x - O, # 95 _ + X*( X - x ) - o*o, # 98 b + ( x + X )*o*o + o, # 114 r + x*( X - x ) - O - O, # 64 @ + x - O + ( O + o + X + x )*( o + O ), # 103 g + X*X - X*( x - O ) - x + O, # 109 m + O + X*( o*( o + O ) + O ), # 120 x + +x + O + X*o, # 46 . + x*( x - o), # 99 c + ( o + X + x )*o*o - ( x - O - O ), # 111 0 + O + ( X - x )*( X + O ), # 109 m + x - O # 10 \n +} +@end ignore + +@c The original text for this chapter was contributed by Efraim Yawitz. +@c FIXME: Add more indexing. + +@node Debugger +@chapter @command{dgawk}: The @command{awk} Debugger +@cindex @command{dgawk} + +It would be nice if computer programs worked perfectly the first time they +were run, but in real life, this rarely happens for programs of +any complexity. Thus, most programming languages have facilities available +for ``debugging'' programs, and now @command{awk} is no exception. + +The @command{dgawk} debugger is purposely modeled after +@uref{http://www.gnu.org/software/gdb/, the GNU Debugger (GDB)} +command-line debugger. If you are familiar with GDB, learning +@command{dgawk} is easy. + +@menu +* Debugging:: Introduction to @command{dgawk}. +* Sample dgawk session:: Sample @command{dgawk} session. +* List of Debugger Commands:: Main @command{dgawk} Commands. +* Readline Support:: Readline Support. +* Dgawk Limitations:: Limitations and future plans. +@end menu + +@node Debugging +@section Introduction to @command{dgawk} + +This @value{SECTION} introduces debugging in general and begins +the discussion of debugging in @command{gawk}. + +@menu +* Debugging Concepts:: Debugging In General. +* Debugging Terms:: Additional Debugging Concepts. +* Awk Debugging:: Awk Debugging. +@end menu + +@node Debugging Concepts +@subsection Debugging In General + +(If you have used debuggers in other languages, you may want to skip +ahead to the next section on the specific features of the @command{awk} +debugger.) + +Of course, a debugging program cannot remove bugs for you, since it has +no way of knowing what you or your users consider a ``bug'' and what is a +``feature.'' (Sometimes, we humans have a hard time with this ourselves.) +In that case, what can you expect from such a tool? The answer to that +depends on the language being debugged, but in general, you can expect at +least the following: + +@itemize @bullet +@item +The ability to watch a program execute its instructions one by one, +giving you, the programmer, the opportunity to think about what is happening +on a time scale of seconds, minutes, or hours, rather than the nanosecond +time scale at which the code usually runs. + +@item +The opportunity to not only passively observe the operation of your +program, but to control it and try different paths of execution, without +having to change your source files. + +@item +The chance to see the values of data in the program at any point in +execution, and also to change that data on the fly, to see how that +affects what happens afterwards. (This often includes the ability +to look at internal data structures besides the variables you actually +defined in your code.) + +@item +The ability to obtain additional information about your program's state +or even its internal structure. +@end itemize + +All of these tools provide a great amount of help in using your own +skills and understanding of the goals of your program to find where it +is going wrong (or, for that matter, to better comprehend a perfectly +functional program that you or someone else wrote). + +@node Debugging Terms +@subsection Additional Debugging Concepts + +Before diving in to the details, we need to introduce several +important concepts that apply to just about all debuggers, including +@command{dgawk}. +The following list defines terms used throughout the rest of +this @value{CHAPTER}. + +@table @dfn +@item Stack Frame +Programs generally call functions during the course of their execution. +One function can call another, or a function can call itself (recursion). +You can view the chain of called functions (main program calls A, which +calls B, which calls C), as a stack of executing functions: the currently +running function is the topmost one on the stack, and when it finishes +(returns), the next one down then becomes the active function. +Such a stack is termed a @dfn{call stack}. + +For each function on the call stack, the system maintains a data area +that contains the function's parameters, local variables, and return value, +as well as any other ``bookkeeping'' information needed to manage the +call stack. This data area is termed a @dfn{stack frame}. + +@command{gawk} also follows this model, and @command{dgawk} gives you +access to the call stack and to each stack frame. You can see the +call stack, as well as from where each function on the stack was +invoked. Commands that print the call stack print information about +each stack frame (as detailed later on). + +@item Breakpoint +During debugging, you often wish to let the program run until it +reaches a certain point, and then continue execution from there one +statement (or instruction) at a time. The way to do this is to set +a @dfn{breakpoint} within the program. A breakpoint is where the +execution of the program should break off (stop), so that you can +take over control of the program's execution. You can add and remove +as many breakpoints as you like. + +@item Watchpoint +A watchpoint is similar to a breakpoint. The difference is that +breakpoints are oriented around the code: stop when a certain point in the +code is reached. A watchpoint, however, specifies that program execution +should stop when a @emph{data value} is changed. This is useful, since +sometimes it happens that a variable receives an erroneous value, and it's +hard to track down where this happens just by looking at the code. +By using a watchpoint, you can stop whenever a variable is assigned to, +and usually find the errant code quite quickly. +@end table + +@node Awk Debugging +@subsection Awk Debugging + +Debugging an @command{awk} program has some specific aspects that are +not shared with other programming languages. + +First of all, the fact that @command{awk} programs usually take input +line-by-line from a file or files and operate on those lines using specific +rules makes it especially useful to organize viewing the execution of +the program in terms of these rules. As we will see, each @command{awk} +rule is treated almost like a function call, with its own specific block +of instructions. + +In addition, since @command{awk} is by design a very concise language, +it is easy to lose sight of everything that is going on ``inside'' +each line of @command{awk} code. The debugger provides the opportunity +to look at the individual primitive instructions carried out +by the higher-level @command{awk} commands. + +@node Sample dgawk session +@section Sample @command{dgawk} session + +In order to illustrate the use of @command{dgawk}, let's look at a sample +debugging session. We will use the @command{awk} implementation of the +POSIX @command{uniq} command described earlier (@pxref{Uniq Program}) +as our example. + +@menu +* dgawk invocation:: @command{dgawk} Invocation. +* Finding The Bug:: Finding The Bug. +@end menu + +@node dgawk invocation +@subsection @command{dgawk} Invocation + +Starting @command{dgawk} is exactly like running @command{awk}. The +file(s) containing the program and any supporting code are given on the +command line as arguments to one or more @option{-f} options. +(@command{dgawk} is not designed to debug command-line +programs, only programs contained in files.) In our case, +we call @command{dgawk} like this: + +@example +$ @kbd{dgawk -f getopt.awk -f join.awk -f uniq.awk inputfile} +@end example + +@noindent +where both @file{getopt.awk} and @file{uniq.awk} are in @env{$AWKPATH}. +(Experienced users of GDB or similar debuggers should note that +this syntax is slightly different from what they are used to. +With @command{dgawk}, the arguments for running the program are given +in the command line to the debugger rather than as part of the @code{run} +command at the debugger prompt.) + +Instead of immediately running the program on @file{inputfile}, as +@command{gawk} would ordinarily do, @command{dgawk} merely loads all +the program source files, compiles them internally, and then gives +us a prompt: + +@example +dgawk> +@end example + +@noindent +from which we can issue commands to the debugger. At this point, no +code has been executed. + +@node Finding The Bug +@subsection Finding The Bug + +Let's say that we are having a problem using (a faulty version of) +@file{uniq.awk} in the ``field-skipping'' mode, and it doesn't seem to be +catching lines which should be identical when skipping the first field, +such as: + +@example +awk is a wonderful program! +gawk is a wonderful program! +@end example + +This could happen if we were thinking (C-like) of the fields in a record +as being numbered in a zero-based fashion, so instead of the lines: + +@example +clast = join(alast, fcount+1, n) +cline = join(aline, fcount+1, m) +@end example + +@noindent +we wrote: + +@example +clast = join(alast, fcount, n) +cline = join(aline, fcount, m) +@end example + +The first thing we usually want to do when trying to investigate a +problem like this is to put a breakpoint in the program so that we can +watch it at work and catch what it is doing wrong. A reasonable spot for +a breakpoint in @file{uniq.awk} is at the beginning of the function +@code{are_equal()}, which compares the current line with the previous one. To set +the breakpoint, use the @code{b} (breakpoint) command: + +@example +dgawk> @kbd{b are_equal} +@print{} Breakpoint 1 set at file `awklib/eg/prog/uniq.awk', line 64 +@end example + +The debugger tells us the file and line number where the breakpoint is. +Now type @samp{r} or @samp{run} and the program runs until it hits +the breakpoint for the first time: + +@example +dgawk> @kbd{r} +@print{} Starting program: +@print{} Stopping in Rule ... +@print{} Breakpoint 1, are_equal(n, m, clast, cline, alast, aline) + at `awklib/eg/prog/uniq.awk':64 +@print{} 64 if (fcount == 0 && charcount == 0) +dgawk> +@end example + +Now we can look at what's going on inside our program. First of all, +let's see how we got to where we are. At the prompt, we type @samp{bt} +(short for ``backtrace''), and @command{dgawk} responds with a +listing of the current stack frames: + +@example +dgawk> @kbd{bt} +@print{} #0 are_equal(n, m, clast, cline, alast, aline) + at `awklib/eg/prog/uniq.awk':69 +@print{} #1 in main() at `awklib/eg/prog/uniq.awk':89 +@end example + +This tells us that @code{are_equal()} was called by the main program at +line 89 of @file{uniq.awk}. (This is not a big surprise, since this +is the only call to @code{are_equal()} in the program, but in more complex +programs, knowing who called a function and with what parameters can be +the key to finding the source of the problem.) + +Now that we're in @code{are_equal()}, we can start looking at the values +of some variables. Let's say we type @samp{p n} +(@code{p} is short for ``print''). We would expect to see the value of +@code{n}, a parameter to @code{are_equal()}. Actually, @command{dgawk} +gives us: + +@example +dgawk> @kbd{p n} +@print{} n = untyped variable +@end example + +@noindent +In this case, @code{n} is an uninitialized local variable, since the +function was called without arguments (@pxref{Function Calls}). + +A more useful variable to display might be the current record: + +@example +dgawk> @kbd{p $0} +@print{} $0 = string ("gawk is a wonderful program!") +@end example + +@noindent +This might be a bit puzzling at first since this is the second line of +our test input above. Let's look at @code{NR}: + +@example +dgawk> @kbd{p NR} +@print{} NR = number (2) +@end example + +@noindent +So we can see that @code{are_equal()} was only called for the second record +of the file. Of course, this is because our program contained a rule for +@samp{NR == 1}: + +@example +NR == 1 @{ + last = $0 + next +@} +@end example + +OK, let's just check that that rule worked correctly: + +@example +dgawk> @kbd{p last} +@print{} last = string ("awk is a wonderful program!") +@end example + +Everything we have done so far has verified that the program has worked as +planned, up to and including the call to @code{are_equal()}, so the problem must +be inside this function. To investigate further, we must begin +``stepping through'' the lines of @code{are_equal()}. We start by typing +@samp{n} (for ``next''): + +@example +dgawk> @kbd{n} +@print{} 67 if (fcount > 0) @{ +@end example + +This tells us that @command{gawk} is now ready to execute line 67, which +decides whether to give the lines the special ``field skipping'' treatment +indicated by the @option{-f} command-line option. (Notice that we skipped +from where we were before at line 64 to here, since the condition in line 64 + +@example +if (fcount == 0 && charcount == 0) +@end example + +@noindent +was false.) + +Continuing to step, we now get to the splitting of the current and +last records: + +@example +dgawk> @kbd{n} +@print{} 68 n = split(last, alast) +dgawk> @kbd{n} +@print{} 69 m = split($0, aline) +@end example + +At this point, we should be curious to see what our records were split +into, so we try to look: + +@example +dgawk> @kbd{p n m alast aline} +@print{} n = number (5) +@print{} m = number (5) +@print{} alast = array, 5 elements +@print{} aline = array, 5 elements +@end example + +@noindent +(The @code{p} command can take more than one argument, similar to +@command{awk}'s @code{print} statement.) + +This is kind of disappointing, though. All we found out is that there +are five elements in each of our arrays. Useful enough (we now know that +none of the words were accidentally left out), but what if we want to see +inside the array? + +The first choice would be to use subscripts: + +@example +dgawk> @kbd{p alast[0]} +@print{} "0" not in array `alast' +@end example + +@noindent +Oops! + +@example +dgawk> @kbd{p alast[1]} +@print{} alast["1"] = string ("awk") +@end example + +This would be kind of slow for a 100-member array, though, so +@command{dgawk} provides a shortcut (reminiscent of another language +not to be mentioned): + +@example +dgawk> @kbd{p @@alast} +@print{} alast["1"] = string ("awk") +@print{} alast["2"] = string ("is") +@print{} alast["3"] = string ("a") +@print{} alast["4"] = string ("wonderful") +@print{} alast["5"] = string ("program!") +@end example + +It looks like we got this far OK. Let's take another step +or two: + +@example +dgawk> @kbd{n} +@print{} 70 clast = join(alast, fcount, n) +dgawk> @kbd{n} +@print{} 71 cline = join(aline, fcount, m) +@end example + +Well, here we are at our error (sorry to spoil the suspense). What we +had in mind was to join the fields starting from the second one to make +the virtual record to compare, and if the first field was numbered zero, +this would work. Let's look at what we've got: + +@example +dgawk> @kbd{p cline clast} +@print{} cline = string ("gawk is a wonderful program!") +@print{} clast = string ("awk is a wonderful program!") +@end example + +Hey, those look pretty familiar! They're just our original, unaltered, +input records. A little thinking (the human brain is still the best +debugging tool), and we realize that we were off by one! + +We get out of @command{dgawk}: + +@example +dgawk> @kbd{q} +@print{} The program is running. Exit anyway (y/n)? @kbd{y} +@end example + +@noindent +Then we get into an editor: + +@example +clast = join(alast, fcount+1, n) +cline = join(aline, fcount+1, m) +@end example + +@noindent +and problem solved! + +@node List of Debugger Commands +@section Main @command{dgawk} Commands + +The @command{dgawk} command set can be divided into the +following categories: + +@itemize @bullet{} + +@item +Breakpoint control + +@item +Execution control + +@item +Viewing and changing data + +@item +Working with the stack + +@item +Getting information + +@item +Miscellaneous +@end itemize + +Each of these are discussed in the following subsections. +In the following descriptions, commands which may be abbreviated +show the abbreviation on a second description line. +A @command{dgawk} command name may also be truncated if that partial +name is unambiguous. @command{dgawk} has the built-in capability to +automatically repeat the previous command when just hitting @key{Enter}. +This works for the commands @code{list}, @code{next}, @code{nexti}, @code{step}, @code{stepi} +and @code{continue} executed without any argument. + +@menu +* Breakpoint Control:: Control of breakpoints. +* Dgawk Execution Control:: Control of execution. +* Viewing And Changing Data:: Viewing and changing data. +* Dgawk Stack:: Dealing with the stack. +* Dgawk Info:: Obtaining information about the program and + the debugger state. +* Miscellaneous Dgawk Commands:: Miscellaneous Commands. +@end menu + +@node Breakpoint Control +@subsection Control Of Breakpoints + +As we saw above, the first thing you probably want to do in a debugging +session is to get your breakpoints set up, since otherwise your program +will just run as if it was not under the debugger. The commands for +controlling breakpoints are: + +@table @asis +@cindex debugger commands, @code{b} (@code{break}) +@cindex debugger commands, @code{break} +@cindex @code{break} debugger command +@cindex @code{b} debugger command (alias for @code{break}) +@item @code{break} [[@var{filename}@code{:}]@var{n} | @var{function}] [@code{"@var{expression}"}] +@itemx @code{b} [[@var{filename}@code{:}]@var{n} | @var{function}] [@code{"@var{expression}"}] +Without any argument, set a breakpoint at the next instruction +to be executed in the selected stack frame. +Arguments can be one of the following: + +@c nested table +@table @var +@item n +Set a breakpoint at line number @var{n} in the current source file. + +@item filename@code{:}n +Set a breakpoint at line number @var{n} in source file @var{filename}. + +@item function +Set a breakpoint at entry to (the first instruction of) +function @var{function}. +@end table + +Each breakpoint is assigned a number which can be used to delete it from +the breakpoint list using the @code{delete} command. + +With a breakpoint, you may also supply a condition. This is an +@command{awk} expression (enclosed in double quotes) that @command{dgawk} +evaluates whenever the breakpoint is reached. If the condition is true, +then @command{dgawk} stops execution and prompts for a command. Otherwise, +@command{dgawk} continues executing the program. + +@cindex debugger commands, @code{clear} +@cindex @code{clear} debugger command +@item @code{clear} [[@var{filename}@code{:}]@var{n} | @var{function}] +Without any argument, delete any breakpoint at the next instruction +to be executed in the selected stack frame. If the program stops at +a breakpoint, this deletes that breakpoint so that the program +does not stop at that location again. Arguments can be one of the following: + +@c nested table +@table @var +@item n +Delete breakpoint(s) set at line number @var{n} in the current source file. + +@item filename@code{:}n +Delete breakpoint(s) set at line number @var{n} in source file @var{filename}. + +@item function +Delete breakpoint(s) set at entry to function @var{function}. +@end table + +@cindex debugger commands, @code{condition} +@cindex @code{condition} debugger command +@item @code{condition} @var{n} @code{"@var{expression}"} +Add a condition to existing breakpoint or watchpoint @var{n}. The +condition is an @command{awk} expression that @command{dgawk} evaluates +whenever the breakpoint or watchpoint is reached. If the condition is true, then +@command{dgawk} stops execution and prompts for a command. Otherwise, +@command{dgawk} continues executing the program. If the condition expression is +not specified, any existing condition is removed; i.e., the breakpoint or +watchpoint is made unconditional. + +@cindex debugger commands, @code{d} (@code{delete}) +@cindex debugger commands, @code{delete} +@cindex @code{delete} debugger command +@cindex @code{d} debugger command (alias for @code{delete}) +@item @code{delete} [@var{n1 n2} @dots{}] [@var{n}--@var{m}] +@itemx @code{d} [@var{n1 n2} @dots{}] [@var{n}--@var{m}] +Delete specified breakpoints or a range of breakpoints. Deletes +all defined breakpoints if no argument is supplied. + +@cindex debugger commands, @code{disable} +@cindex @code{disable} debugger command +@item @code{disable} [@var{n1 n2} @dots{} | @var{n}--@var{m}] +Disable specified breakpoints or a range of breakpoints. Without +any argument, disables all breakpoints. + +@cindex debugger commands, @code{e} (@code{enable}) +@cindex debugger commands, @code{enable} +@cindex @code{enable} debugger command +@cindex @code{e} debugger command (alias for @code{enable}) +@item @code{enable} [@code{del} | @code{once}] [@var{n1 n2} @dots{}] [@var{n}--@var{m}] +@itemx @code{e} [@code{del} | @code{once}] [@var{n1 n2} @dots{}] [@var{n}--@var{m}] +Enable specified breakpoints or a range of breakpoints. Without +any argument, enables all breakpoints. +Optionally, you can specify how to enable the breakpoint: + +@c nested table +@table @code +@item del +Enable the breakpoint(s) temporarily, then delete it when +the program stops at the breakpoint. + +@item once +Enable the breakpoint(s) temporarily, then disable it when +the program stops at the breakpoint. +@end table + +@cindex debugger commands, @code{ignore} +@cindex @code{ignore} debugger command +@item @code{ignore} @var{n} @var{count} +Ignore breakpoint number @var{n} the next @var{count} times it is +hit. + +@cindex debugger commands, @code{t} (@code{tbreak}) +@cindex debugger commands, @code{tbreak} +@cindex @code{tbreak} debugger command +@cindex @code{t} debugger command (alias for @code{tbreak}) +@item @code{tbreak} [[@var{filename}@code{:}]@var{n} | @var{function}] +@itemx @code{t} [[@var{filename}@code{:}]@var{n} | @var{function}] +Set a temporary breakpoint (enabled for only one stop). +The arguments are the same as for @code{break}. +@end table + +@node Dgawk Execution Control +@subsection Control of Execution + +Now that your breakpoints are ready, you can start running the program +and observing its behavior. There are more commands for controlling +execution of the program than we saw in our earlier example: + +@table @asis +@cindex debugger commands, @code{commands} +@cindex @code{commands} debugger command +@cindex debugger commands, @code{silent} +@cindex @code{silent} debugger command +@cindex debugger commands, @code{end} +@cindex @code{end} debugger command +@item @code{commands} [@var{n}] +@itemx @code{silent} +@itemx @dots{} +@itemx @code{end} +Set a list of commands to be executed upon stopping at +a breakpoint or watchpoint. @var{n} is the breakpoint or watchpoint number. +Without a number, the last one set is used. The actual commands follow, +starting on the next line, and terminated by the @code{end} command. +If the command @code{silent} is in the list, the usual messages about +stopping at a breakpoint and the source line are not printed. Any command +in the list that resumes execution (e.g., @code{continue}) terminates the list +(an implicit @code{end}), and subsequent commands are ignored. +For example: + +@example +dgawk> @kbd{commands} +> @kbd{silent} +> @kbd{printf "A silent breakpoint; i = %d\n", i} +> @kbd{info locals} +> @kbd{set i = 10} +> @kbd{continue} +> @kbd{end} +dgawk> +@end example + +@cindex debugger commands, @code{c} (@code{continue}) +@cindex debugger commands, @code{continue} +@item @code{continue} [@var{count}] +@itemx @code{c} [@var{count}] +Resume program execution. If continued from a breakpoint and @var{count} is +specified, ignores the breakpoint at that location the next @var{count} times +before stopping. + +@cindex debugger commands, @code{finish} +@cindex @code{finish} debugger command +@item @code{finish} +Execute until the selected stack frame returns. +Print the returned value. + +@cindex debugger commands, @code{n} (@code{next}) +@cindex debugger commands, @code{next} +@cindex @code{next} debugger command +@cindex @code{n} debugger command (alias for @code{next}) +@item @code{next} [@var{count}] +@itemx @code{n} [@var{count}] +Continue execution to the next source line, stepping over function calls. +The argument @var{count} controls how many times to repeat the action, as +in @code{step}. + +@cindex debugger commands, @code{ni} (@code{nexti}) +@cindex debugger commands, @code{nexti} +@cindex @code{nexti} debugger command +@cindex @code{ni} debugger command (alias for @code{nexti}) +@item @code{nexti} [@var{count}] +@itemx @code{ni} [@var{count}] +Execute one (or @var{count}) instruction(s), stepping over function calls. + +@cindex debugger commands, @code{return} +@cindex @code{return} debugger command +@item @code{return} [@var{value}] +Cancel execution of a function call. If @var{value} (either a string or a +number) is specified, it is used as the function's return value. If used in a +frame other than the innermost one (the currently executing function, i.e., +frame number 0), discard all inner frames in addition to the selected one, +and the caller of that frame becomes the innermost frame. + +@cindex debugger commands, @code{r} (@code{run}) +@cindex debugger commands, @code{run} +@cindex @code{run} debugger command +@cindex @code{r} debugger command (alias for @code{run}) +@item @code{run} +@itemx @code{r} +Start/restart execution of the program. When restarting, @command{dgawk} +retains the current breakpoints, watchpoints, command history, +automatic display variables, and debugger options. + +@cindex debugger commands, @code{s} (@code{step}) +@cindex debugger commands, @code{step} +@cindex @code{step} debugger command +@cindex @code{s} debugger command (alias for @code{step}) +@item @code{step} [@var{count}] +@itemx @code{s} [@var{count}] +Continue execution until control reaches a different source line in the +current stack frame. @code{step} steps inside any function called within +the line. If the argument @var{count} is supplied, steps that many times before +stopping, unless it encounters a breakpoint or watchpoint. + +@cindex debugger commands, @code{si} (@code{stepi}) +@cindex debugger commands, @code{stepi} +@cindex @code{stepi} debugger command +@cindex @code{si} debugger command (alias for @code{stepi}) +@item @code{stepi} [@var{count}] +@itemx @code{si} [@var{count}] +Execute one (or @var{count}) instruction(s), stepping inside function calls. +(For illustration of what is meant by an ``instruction'' in @command{gawk}, +see the output shown under @code{dump} in @ref{Miscellaneous Dgawk Commands}.) + +@cindex debugger commands, @code{u} (@code{until}) +@cindex debugger commands, @code{until} +@cindex @code{until} debugger command +@cindex @code{u} debugger command (alias for @code{until}) +@item @code{until} [[@var{filename}@code{:}]@var{n} | @var{function}] +@itemx @code{u} [[@var{filename}@code{:}]@var{n} | @var{function}] +Without any argument, continue execution until a line past the current +line in current stack frame is reached. With an argument, +continue execution until the specified location is reached, or the current +stack frame returns. +@end table + +@node Viewing And Changing Data +@subsection Viewing and Changing Data + +The commands for viewing and changing variables inside of @command{gawk} are: + +@table @asis +@cindex debugger commands, @code{display} +@cindex @code{display} debugger command +@item @code{display} [@var{var} | @code{$}@var{n}] +Add variable @var{var} (or field @code{$@var{n}}) to the display list. +The value of the variable or field is displayed each time the program stops. +Each variable added to the list is identified by a unique number: + +@example +dgawk> @kbd{display x} +@print{} 10: x = 1 +@end example + +@noindent +displays the assigned item number, the variable name and its current value. +If the display variable refers to a function parameter, it is silently +deleted from the list as soon as the execution reaches a context where +no such variable of the given name exists. +Without argument, @code{display} displays the current values of +items on the list. + +@cindex debugger commands, @code{eval} +@cindex @code{eval} debugger command +@item @code{eval "@var{awk statements}"} +Evaluate @var{awk statements} in the context of the running program. +You can do anything that an @command{awk} program would do: assign +values to variables, call functions, and so on. + +@item @code{eval} @var{param}, @dots{} +@itemx @var{awk statements} +@itemx @code{end} +This form of @code{eval} is similar, but it allows you to define +``local variables'' that exist in the context of the +@var{awk statements}, instead of using variables or function +parameters defined by the program. + +@cindex debugger commands, @code{p} (@code{print}) +@cindex debugger commands, @code{print} +@cindex @code{print} debugger command +@cindex @code{p} debugger command (alias for @code{print}) +@item @code{print} @var{var1}[@code{,} @var{var2} @dots{}] +@itemx @code{p} @var{var1}[@code{,} @var{var2} @dots{}] +Print the value of a @command{gawk} variable or field. +Fields must be referenced by constants: + +@example +dgawk> @kbd{print $3} +@end example + +@noindent +This prints the third field in the input record (if the specified field does not +exist, it prints @samp{Null field}). A variable can be an array element, with +the subscripts being constant values. To print the contents of an array, +prefix the name of the array with the @samp{@@} symbol: + +@example +gawk> @kbd{print @@a} +@end example + +@noindent +This prints the indices and the corresponding values for all elements in +the array @code{a}. + +@cindex debugger commands, @code{printf} +@cindex @code{printf} debugger command +@item @code{printf} @var{format} [@code{,} @var{arg} @dots{}] +Print formatted text. The @var{format} may include escape sequences, +such as @samp{\n} +(@pxref{Escape Sequences}). +No newline is printed unless one is specified. + +@cindex debugger commands, @code{set} +@cindex @code{set} debugger command +@item @code{set} @var{var}@code{=}@var{value} +Assign a constant (number or string) value to an @command{awk} variable +or field. +String values must be enclosed between double quotes (@code{"@dots{}"}). + +You can also set special @command{awk} variables, such as @code{FS}, +@code{NF}, @code{NR}, etc. + +@cindex debugger commands, @code{w} (@code{watch}) +@cindex debugger commands, @code{watch} +@cindex @code{watch} debugger command +@cindex @code{w} debugger command (alias for @code{watch}) +@item @code{watch} @var{var} | @code{$}@var{n} [@code{"@var{expression}"}] +@itemx @code{w} @var{var} | @code{$}@var{n} [@code{"@var{expression}"}] +Add variable @var{var} (or field @code{$@var{n}}) to the watch list. +@command{dgawk} then stops whenever +the value of the variable or field changes. Each watched item is assigned a +number which can be used to delete it from the watch list using the +@code{unwatch} command. + +With a watchpoint, you may also supply a condition. This is an +@command{awk} expression (enclosed in double quotes) that @command{dgawk} +evaluates whenever the watchpoint is reached. If the condition is true, +then @command{dgawk} stops execution and prompts for a command. Otherwise, +@command{dgawk} continues executing the program. + +@cindex debugger commands, @code{undisplay} +@cindex @code{undisplay} debugger command +@item @code{undisplay} [@var{n}] +Remove item number @var{n} (or all items, if no argument) from the +automatic display list. + +@cindex debugger commands, @code{unwatch} +@cindex @code{unwatch} debugger command +@item @code{unwatch} [@var{n}] +Remove item number @var{n} (or all items, if no argument) from the +watch list. + +@end table + +@node Dgawk Stack +@subsection Dealing With The Stack + +Whenever you run a program which contains any function calls, +@command{gawk} maintains a stack of all of the function calls leading up +to where the program is right now. You can see how you got to where you are, +and also move around in the stack to see what the state of things was in the +functions which called the one you are in. The commands for doing this are: + +@table @asis +@cindex debugger commands, @code{bt} (@code{backtrace}) +@cindex debugger commands, @code{backtrace} +@cindex @code{backtrace} debugger command +@cindex @code{bt} debugger command (alias for @code{backtrace}) +@item @code{backtrace} [@var{count}] +@itemx @code{bt} [@var{count}] +Print a backtrace of all function calls (stack frames), or innermost @var{count} +frames if @var{count} > 0. Print the outermost @var{count} frames if +@var{count} < 0. The backtrace displays the name and arguments to each +function, the source @value{FN}, and the line number. + +@cindex debugger commands, @code{down} +@cindex @code{down} debugger command +@item @code{down} [@var{count}] +Move @var{count} (default 1) frames down the stack toward the innermost frame. +Then select and print the frame. + +@cindex debugger commands, @code{f} (@code{frame}) +@cindex debugger commands, @code{frame} +@cindex @code{frame} debugger command +@cindex @code{f} debugger command (alias for @code{frame}) +@item @code{frame} [@var{n}] +@itemx @code{f} [@var{n}] +Select and print (frame number, function and argument names, source file, +and the source line) stack frame @var{n}. Frame 0 is the currently executing, +or @dfn{innermost}, frame (function call), frame 1 is the frame that called the +innermost one. The highest numbered frame is the one for the main program. + +@cindex debugger commands, @code{up} +@cindex @code{up} debugger command +@item @code{up} [@var{count}] +Move @var{count} (default 1) frames up the stack toward the outermost frame. +Then select and print the frame. +@end table + +@node Dgawk Info +@subsection Obtaining Information About The Program and The Debugger State + +Besides looking at the values of variables, there is often a need to get +other sorts of information about the state of your program and of the +debugging environment itself. @command{dgawk} has one command which +provides this information, appropriately called @code{info}. @code{info} +is used with one of a number of arguments that tell it exactly what +you want to know: + +@table @asis +@cindex debugger commands, @code{i} (@code{info}) +@cindex debugger commands, @code{info} +@cindex @code{info} debugger command +@cindex @code{i} debugger command (alias for @code{info}) +@item @code{info} @var{what} +@itemx @code{i} @var{what} +The value for @var{what} should be one of the following: + +@c nested table +@table @code +@item args +Arguments of the selected frame. + +@item break +List all currently set breakpoints. + +@item display +List all items in the automatic display list. + +@item frame +Description of the selected stack frame. + +@item functions +List all function definitions including source file names and +line numbers. + +@item locals +Local variables of the selected frame. + +@item source +The name of the current source file. Each time the program stops, the +current source file is the file containing the current instruction. +When @command{dgawk} first starts, the current source file is the first file +included via the @option{-f} option. The +@samp{list @var{filename}:@var{lineno}} command can +be used at any time to change the current source. + +@item sources +List all program sources. + +@item variables +List all global variables. + +@item watch +List all items in the watch list. +@end table +@end table + +Additional commands give you control over the debugger, the ability to +save the debugger's state, and the ability to run debugger commands +from a file. The commands are: + +@table @asis +@cindex debugger commands, @code{o} (@code{option}) +@cindex debugger commands, @code{option} +@cindex @code{option} debugger command +@cindex @code{o} debugger command (alias for @code{option}) +@item @code{option} [@var{name}[@code{=}@var{value}]] +@itemx @code{o} [@var{name}[@code{=}@var{value}]] +Without an argument, display the available debugger options +and their current values. @samp{option @var{name}} shows the current +value of the named option. @samp{option @var{name}=@var{value}} assigns +a new value to the named option. +The available options are: + +@c nested table +@table @code +@item history_size +The maximum number of lines to keep in the history file @file{./.dgawk_history}. +The default is 100. + +@item listsize +The number of lines that @code{list} prints. The default is 15. + +@item outfile +Send @command{gawk} output to a file; debugger output still goes +to standard output. An empty string (@code{""}) resets output to +standard output. + +@item prompt +The debugger prompt. The default is @samp{@w{dgawk> }}. + +@item save_history @r{[}on @r{|} off@r{]} +Save command history to file @file{./.dgawk_history}. +The default is @code{on}. + +@item save_options @r{[}on @r{|} off@r{]} +Save current options to file @file{./.dgawkrc} upon exit. +The default is @code{on}. +Options are read back in to the next session upon startup. + +@item trace @r{[}on @r{|} off@r{]} +Turn instruction tracing on or off. The default is @code{off}. +@end table + +@item @code{save} @var{filename} +Save the commands from the current session to the given @value{FN}, +so that they can be replayed using the @command{source} command. + +@item @code{source} @var{filename} +Run command(s) from a file; an error in any command does not +terminate execution of subsequent commands. Comments (lines starting +with @samp{#}) are allowed in a command file. +Empty lines are ignored; they do @emph{not} +repeat the last command. +You can't restart the program by having more than one @code{run} +command in the file. Also, the list of commands may include additional +@code{source} commands; however, @command{dgawk} will not source the +same file more than once in order to avoid infinite recursion. + +In addition to, or instead of the @code{source} command, you can use +the @option{-R @var{file}} or @option{--command=@var{file}} command-line +options to execute commands from a file non-interactively +(@pxref{Options}. +@end table + +@node Miscellaneous Dgawk Commands +@subsection Miscellaneous Commands + +There are a few more commands which do not fit into the +previous categories, as follows: + +@table @asis +@cindex debugger commands, @code{dump} +@cindex @code{dump} debugger command +@item @code{dump} [@var{filename}] +Dump bytecode of the program to standard output or to the file +named in @var{filename}. This prints a representation of the internal +instructions which @command{gawk} executes to implement the @command{awk} +commands in a program. This can be very enlightening, as the following +partial dump of Davide Brini's obfuscated code +(@pxref{Signature Program}) demonstrates: + +@smallexample +dgawk> @kbd{dump} +@print{} # BEGIN +@print{} +@print{} [ 2:0x89faef4] Op_rule : [in_rule = BEGIN] [source_file = brini.awk] +@print{} [ 3:0x89fa428] Op_push_i : "~" [PERM|STRING|STRCUR] +@print{} [ 3:0x89fa464] Op_push_i : "~" [PERM|STRING|STRCUR] +@print{} [ 3:0x89fa450] Op_match : +@print{} [ 3:0x89fa3ec] Op_store_var : O [do_reference = FALSE] +@print{} [ 4:0x89fa48c] Op_push_i : "==" [PERM|STRING|STRCUR] +@print{} [ 4:0x89fa4c8] Op_push_i : "==" [PERM|STRING|STRCUR] +@print{} [ 4:0x89fa4b4] Op_equal : +@print{} [ 4:0x89fa400] Op_store_var : o [do_reference = FALSE] +@print{} [ 5:0x89fa4f0] Op_push : o +@print{} [ 5:0x89fa4dc] Op_plus_i : 0 [PERM|NUMCUR|NUMBER] +@print{} [ 5:0x89fa414] Op_push_lhs : o [do_reference = TRUE] +@print{} [ 5:0x89fa4a0] Op_assign_plus : +@print{} [ :0x89fa478] Op_pop : +@print{} [ 6:0x89fa540] Op_push : O +@print{} [ 6:0x89fa554] Op_push_i : "" [PERM|STRING|STRCUR] +@print{} [ :0x89fa5a4] Op_no_op : +@print{} [ 6:0x89fa590] Op_push : O +@print{} [ :0x89fa5b8] Op_concat : [expr_count = 3] [concat_flag = 0] +@print{} [ 6:0x89fa518] Op_store_var : x [do_reference = FALSE] +@print{} [ 7:0x89fa504] Op_push_loop : [target_continue = 0x89fa568] [target_break = 0x89fa680] +@print{} [ 7:0x89fa568] Op_push_lhs : X [do_reference = TRUE] +@print{} [ 7:0x89fa52c] Op_postincrement : +@print{} [ 7:0x89fa5e0] Op_push : x +@print{} [ 7:0x89fa61c] Op_push : o +@print{} [ 7:0x89fa5f4] Op_plus : +@print{} [ 7:0x89fa644] Op_push : o +@print{} [ 7:0x89fa630] Op_plus : +@print{} [ 7:0x89fa5cc] Op_leq : +@print{} [ :0x89fa57c] Op_jmp_false : [target_jmp = 0x89fa680] +@print{} [ 7:0x89fa694] Op_push_i : "%c" [PERM|STRING|STRCUR] +@print{} [ :0x89fa6d0] Op_no_op : +@print{} [ 7:0x89fa608] Op_assign_concat : c +@print{} [ :0x89fa6a8] Op_jmp : [target_jmp = 0x89fa568] +@print{} [ :0x89fa680] Op_pop_loop : +@print{} +@dots{} +@print{} +@print{} [ 8:0x89fa658] Op_K_printf : [expr_count = 17] [redir_type = ""] +@print{} [ :0x89fa374] Op_no_op : +@print{} [ :0x89fa3d8] Op_atexit : +@print{} [ :0x89fa6bc] Op_stop : +@print{} [ :0x89fa39c] Op_no_op : +@print{} [ :0x89fa3b0] Op_after_beginfile : +@print{} [ :0x89fa388] Op_no_op : +@print{} [ :0x89fa3c4] Op_after_endfile : +dgawk> +@end smallexample + +@cindex debugger commands, @code{h} (@code{help}) +@cindex debugger commands, @code{help} +@cindex @code{help} debugger command +@cindex @code{h} debugger command (alias for @code{help}) +@item @code{help} +@itemx @code{h} +Print a list of all of the @command{dgawk} commands with a short +summary of their usage. @samp{help @var{command}} prints the information +about the command @var{command}. + +@cindex debugger commands, @code{l} (@code{list}) +@cindex debugger commands, @code{list} +@cindex @code{list} debugger command +@cindex @code{l} debugger command (alias for @code{list}) +@item @code{list} [@code{-} | @code{+} | @var{n} | @var{filename@code{:}n} | @var{n}--@var{m} | @var{function}] +@itemx @code{l} [@code{-} | @code{+} | @var{n} | @var{filename@code{:}n} | @var{n}--@var{m} | @var{function}] +Print the specified lines (default 15) from the current source file +or the file named @var{filename}. The possible arguments to @code{list} +are as follows: + +@c nested table +@table @asis +@item @code{-} +Print lines before the lines last printed. + +@item @code{+} +Print lines after the lines last printed. +@code{list} without any argument does the same thing. + +@item @var{n} +Print lines centered around line number @var{n}. + +@item @var{n}--@var{m} +Print lines from @var{n} to @var{m}. + +@item @var{filename@code{:}n} +Print lines centered around line number @var{n} in +source file @var{filename}. This command may change the current source file. + +@item @var{function} +Print lines centered around beginning of the +function @var{function}. This command may change the current source file. +@end table + +@cindex debugger commands, @code{q} (@code{quit}) +@cindex debugger commands, @code{quit} +@cindex @code{quit} debugger command +@cindex @code{q} debugger command (alias for @code{quit}) +@item @code{quit} +@itemx @code{q} +Exit the debugger. Debugging is great fun, but sometimes we all have +to tend to other obligations in life, and sometimes we find the bug, +and are free to go on to the next one! As we saw above, if you are +running a program, @command{dgawk} warns you if you accidentally type +@samp{q} or @samp{quit}, to make sure you really want to quit. + +@cindex debugger commands, @code{trace} +@cindex @code{trace} debugger command +@item @code{trace} @code{on} @r{|} @code{off} +Turn on or off a continuous printing of instructions which are about to +be executed, along with printing the @command{awk} line which they +implement. The default is @code{off}. + +It is to be hoped that most of the ``opcodes'' in these instructions are +fairly self-explanatory, and using @code{stepi} and @code{nexti} while +@code{trace} is on will make them into familiar friends. + +@end table + +@node Readline Support +@section Readline Support + +If @command{dgawk} is compiled with the @code{readline} library, you +can take advantage of that library's command completion and history expansion +features. The following types of completion are available: + +@table @asis +@item Command completion +Command names. + +@item Source @value{FN} completion +Source @value{FN}s. Relevant commands are +@code{break}, +@code{clear}, +@code{list}, +@code{tbreak}, +and +@code{until}. + +@item Argument completion +Non-numeric arguments to a command. +Relevant commands are @code{enable} and @code{info}. + +@item Variable name completion +Global variable names, and function arguments in the current context +if the program is running. Relevant commands are +@code{display}, +@code{print}, +@code{set}, +and +@code{watch}. + +@end table + +@node Dgawk Limitations +@section Limitations and Future Plans + +We hope you find @command{dgawk} useful and enjoyable to work with, +but as with any program, especially in its early releases, it still has +some limitations. A few which are worth being aware of are: + +@itemize @bullet{} +@item +At this point, @command{dgawk} does not give a detailed explanation of +what you did wrong when you type in something it doesn't like. Rather, it just +responds @samp{syntax error}. When you do figure out what your mistake was, +though, you'll feel like a real guru. + +@item +If you perused the dump of opcodes in @ref{Miscellaneous Dgawk Commands}, +(or if you are already familiar with @command{gawk} internals), +you will realize that much of the internal manipulation of data +in @command{gawk}, as in many interpreters, is done on a stack. +@code{Op_push}, @code{Op_pop}, etc., are the ``bread and butter'' of +most @command{gawk} code. Unfortunately, as of now, @command{dgawk} +does not allow you to examine the stack's contents. + +That is, the intermediate results of expression evaluation are on the +stack, but cannot be printed. Rather, only variables which are defined +in the program can be printed. Of course, a workaround for +this is to use more explicit variables at the debugging stage and then +change back to obscure, perhaps more optimal code later. + +@item +There is no way to look ``inside'' the process of compiling +regular expressions to see if you got it right. As an @command{awk} +programmer, you are expected to know what @code{/[^[:alnum:][:blank:]]/} +means. + +@item +@command{dgawk} is designed to be used by running a program (with all its +parameters) on the command line, as described in @ref{dgawk invocation}. +There is no way (as of now) to attach or ``break in'' to a running program. +This seems reasonable for a language which is used mainly for quickly +executing, short programs. + +@item +@command{dgawk} only accepts source supplied with the @option{-f} option. +@end itemize + +Look forward to a future release when these and other missing features may +be added, and of course feel free to try to add them yourself! + +@ignore +@c Try this +@iftex +@page +@headings off +@majorheading III@ @ @ Appendixes +Part III provides the appendixes, the Glossary, and two licenses that cover +the @command{gawk} source code and this @value{DOCUMENT}, respectively. +It contains the following appendixes: + +@itemize @bullet +@item +@ref{Language History}. + +@item +@ref{Installation}. + +@item +@ref{Notes}. + +@item +@ref{Basic Concepts}. + +@item +@ref{Glossary}. + +@item +@ref{Copying}. + +@item +@ref{GNU Free Documentation License}. +@end itemize + +@page +@evenheading @thispage@ @ @ @strong{@value{TITLE}} @| @| +@oddheading @| @| @strong{@thischapter}@ @ @ @thispage +@end iftex +@end ignore + +@node Language History +@appendix The Evolution of the @command{awk} Language + +This @value{DOCUMENT} describes the GNU implementation of @command{awk}, which follows +the POSIX specification. +Many long-time @command{awk} users learned @command{awk} programming +with the original @command{awk} implementation in Version 7 Unix. +(This implementation was the basis for @command{awk} in Berkeley Unix, +through 4.3-Reno. Subsequent versions of Berkeley Unix, and some systems +derived from 4.4BSD-Lite, use various versions of @command{gawk} +for their @command{awk}.) +This @value{CHAPTER} briefly describes the +evolution of the @command{awk} language, with cross-references to other parts +of the @value{DOCUMENT} where you can find more information. + +@c FIXME: Try to determine whether it was 3.1 or 3.2 that had new awk. + +@menu +* V7/SVR3.1:: The major changes between V7 and System V + Release 3.1. +* SVR4:: Minor changes between System V Releases 3.1 + and 4. +* POSIX:: New features from the POSIX standard. +* BTL:: New features from Brian Kernighan's version of + @command{awk}. +* POSIX/GNU:: The extensions in @command{gawk} not in POSIX + @command{awk}. +* Common Extensions:: Common Extensions Summary. +* Ranges and Locales:: How locales used to affect regexp ranges. +* Contributors:: The major contributors to @command{gawk}. +@end menu + +@node V7/SVR3.1 +@appendixsec Major Changes Between V7 and SVR3.1 +@c STARTOFRANGE gawkv +@cindex @command{awk}, versions of +@c STARTOFRANGE gawkv1 +@cindex @command{awk}, versions of, changes between V7 and SVR3.1 + +The @command{awk} language evolved considerably between the release of +Version 7 Unix (1978) and the new version that was first made generally available in +System V Release 3.1 (1987). This @value{SECTION} summarizes the changes, with +cross-references to further details: + +@itemize @bullet +@item +The requirement for @samp{;} to separate rules on a line +(@pxref{Statements/Lines}). + +@item +User-defined functions and the @code{return} statement +(@pxref{User-defined}). + +@item +The @code{delete} statement (@pxref{Delete}). + +@item +The @code{do}-@code{while} statement +(@pxref{Do Statement}). + +@item +The built-in functions @code{atan2()}, @code{cos()}, @code{sin()}, @code{rand()}, and +@code{srand()} (@pxref{Numeric Functions}). + +@item +The built-in functions @code{gsub()}, @code{sub()}, and @code{match()} +(@pxref{String Functions}). + +@item +The built-in functions @code{close()} and @code{system()} +(@pxref{I/O Functions}). + +@item +The @code{ARGC}, @code{ARGV}, @code{FNR}, @code{RLENGTH}, @code{RSTART}, +and @code{SUBSEP} built-in variables (@pxref{Built-in Variables}). + +@item +Assignable @code{$0} (@pxref{Changing Fields}). + +@item +The conditional expression using the ternary operator @samp{?:} +(@pxref{Conditional Exp}). + +@item +The expression @samp{@var{index-variable} in @var{array}} outside of @code{for} +statements (@pxref{Reference to Elements}). + +@item +The exponentiation operator @samp{^} +(@pxref{Arithmetic Ops}) and its assignment operator +form @samp{^=} (@pxref{Assignment Ops}). + +@item +C-compatible operator precedence, which breaks some old @command{awk} +programs (@pxref{Precedence}). + +@item +Regexps as the value of @code{FS} +(@pxref{Field Separators}) and as the +third argument to the @code{split()} function +(@pxref{String Functions}), rather than using only the first character +of @code{FS}. + +@item +Dynamic regexps as operands of the @samp{~} and @samp{!~} operators +(@pxref{Regexp Usage}). + +@item +The escape sequences @samp{\b}, @samp{\f}, and @samp{\r} +(@pxref{Escape Sequences}). +(Some vendors have updated their old versions of @command{awk} to +recognize @samp{\b}, @samp{\f}, and @samp{\r}, but this is not +something you can rely on.) + +@item +Redirection of input for the @code{getline} function +(@pxref{Getline}). + +@item +Multiple @code{BEGIN} and @code{END} rules +(@pxref{BEGIN/END}). + +@item +Multidimensional arrays +(@pxref{Multi-dimensional}). +@end itemize +@c ENDOFRANGE gawkv1 + +@node SVR4 +@appendixsec Changes Between SVR3.1 and SVR4 + +@cindex @command{awk}, versions of, changes between SVR3.1 and SVR4 +The System V Release 4 (1989) version of Unix @command{awk} added these features +(some of which originated in @command{gawk}): + +@itemize @bullet +@item +The @code{ENVIRON} array (@pxref{Built-in Variables}). +@c gawk and MKS awk + +@item +Multiple @option{-f} options on the command line +(@pxref{Options}). +@c MKS awk + +@item +The @option{-v} option for assigning variables before program execution begins +(@pxref{Options}). +@c GNU, Bell Laboratories & MKS together + +@item +The @option{--} option for terminating command-line options. + +@item +The @samp{\a}, @samp{\v}, and @samp{\x} escape sequences +(@pxref{Escape Sequences}). +@c GNU, for ANSI C compat + +@item +A defined return value for the @code{srand()} built-in function +(@pxref{Numeric Functions}). + +@item +The @code{toupper()} and @code{tolower()} built-in string functions +for case translation +(@pxref{String Functions}). + +@item +A cleaner specification for the @samp{%c} format-control letter in the +@code{printf} function +(@pxref{Control Letters}). + +@item +The ability to dynamically pass the field width and precision (@code{"%*.*d"}) +in the argument list of the @code{printf} function +(@pxref{Control Letters}). + +@item +The use of regexp constants, such as @code{/foo/}, as expressions, where +they are equivalent to using the matching operator, as in @samp{$0 ~ /foo/} +(@pxref{Using Constant Regexps}). + +@item +Processing of escape sequences inside command-line variable assignments +(@pxref{Assignment Options}). +@end itemize + +@node POSIX +@appendixsec Changes Between SVR4 and POSIX @command{awk} +@cindex @command{awk}, versions of, changes between SVR4 and POSIX @command{awk} +@cindex POSIX @command{awk}, changes in @command{awk} versions + +The POSIX Command Language and Utilities standard for @command{awk} (1992) +introduced the following changes into the language: + +@itemize @bullet +@item +The use of @option{-W} for implementation-specific options +(@pxref{Options}). + +@item +The use of @code{CONVFMT} for controlling the conversion of numbers +to strings (@pxref{Conversion}). + +@item +The concept of a numeric string and tighter comparison rules to go +with it (@pxref{Typing and Comparison}). + +@item +The use of built-in variables as function parameter names is forbidden +(@pxref{Definition Syntax}. + +@item +More complete documentation of many of the previously undocumented +features of the language. +@end itemize + +@xref{Common Extensions}, for a list of common extensions +not permitted by the POSIX standard. + +The 2008 POSIX standard can be found online at +@url{http://www.opengroup.org/onlinepubs/9699919799/}. + +@c ENDOFRANGE gawkv + +@node BTL +@appendixsec Extensions in Brian Kernighan's @command{awk} + +@cindex @command{awk}, versions of, See Also Brian Kernighan's @command{awk} +@cindex extensions, Brian Kernighan's @command{awk} +@cindex Brian Kernighan's @command{awk}, extensions +@cindex Kernighan, Brian +Brian Kernighan +has made his version available via his home page +(@pxref{Other Versions}). + +This @value{SECTION} describes common extensions that +originally appeared in his version of @command{awk}. + +@itemize @bullet +@item +The @samp{**} and @samp{**=} operators +(@pxref{Arithmetic Ops} +and +@ref{Assignment Ops}). + +@item +The use of @code{func} as an abbreviation for @code{function} +(@pxref{Definition Syntax}). + +@item +The @code{fflush()} built-in function for flushing buffered output +(@pxref{I/O Functions}). + +@ignore +@item +The @code{SYMTAB} array, that allows access to @command{awk}'s internal symbol +table. This feature is not documented, largely because +it is somewhat shakily implemented. For instance, you cannot access arrays +or array elements through it. +@end ignore +@end itemize + +@xref{Common Extensions}, for a full list of the extensions +available in his @command{awk}. + +@node POSIX/GNU +@appendixsec Extensions in @command{gawk} Not in POSIX @command{awk} + +@c STARTOFRANGE fripls +@cindex compatibility mode (@command{gawk}), extensions +@c STARTOFRANGE exgnot +@cindex extensions, in @command{gawk}, not in POSIX @command{awk} +@c STARTOFRANGE posnot +@cindex POSIX, @command{gawk} extensions not included in +The GNU implementation, @command{gawk}, adds a large number of features. +They can all be disabled with either the @option{--traditional} or +@option{--posix} options +(@pxref{Options}). + +A number of features have come and gone over the years. This @value{SECTION} +summarizes the additional features over POSIX @command{awk} that are +in the current version of @command{gawk}. + +@itemize @bullet + +@item +Additional built-in variables: + +@itemize @minus +@item +The +@code{ARGIND} +@code{BINMODE}, +@code{ERRNO}, +@code{FIELDWIDTHS}, +@code{FPAT}, +@code{IGNORECASE}, +@code{LINT}, +@code{PROCINFO}, +@code{RT}, +and +@code{TEXTDOMAIN} +variables +(@pxref{Built-in Variables}). +@end itemize + +@item +Special files in I/O redirections: + +@itemize @minus{} +@item +The @file{/dev/stdin}, @file{/dev/stdout}, @file{/dev/stderr} and +@file{/dev/fd/@var{N}} special @value{FN}s +(@pxref{Special Files}). + +@item +The @file{/inet}, @file{/inet4}, and @samp{/inet6} special files for +TCP/IP networking using @samp{|&} to specify which version of the +IP protocol to use. +(@pxref{TCP/IP Networking}). +@end itemize + +@item +Changes and/or additions to the language: + +@itemize @minus{} +@item +The @samp{\x} escape sequence +(@pxref{Escape Sequences}). + +@item +Full support for both POSIX and GNU regexps +(@pxref{Regexp}). + +@item +The ability for @code{FS} and for the third +argument to @code{split()} to be null strings +(@pxref{Single Character Fields}). + +@item +The ability for @code{RS} to be a regexp +(@pxref{Records}). + +@item +The ability to use octal and hexadecimal constants in @command{awk} +program source code +(@pxref{Nondecimal-numbers}). + +@item +The @samp{|&} operator for two-way I/O to a coprocess +(@pxref{Two-way I/O}). + +@item +Indirect function calls +(@pxref{Indirect Calls}). + +@item +Directories on the command line produce a warning and are skipped +(@pxref{Command line directories}). +@end itemize + +@item +New keywords: + +@itemize @minus{} +@item +The @code{BEGINFILE} and @code{ENDFILE} special patterns. +(@pxref{BEGINFILE/ENDFILE}). + +@item +The ability to delete all of an array at once with @samp{delete @var{array}} +(@pxref{Delete}). + +@item +The @code{nextfile} statement +(@pxref{Nextfile Statement}). + +@item +The @code{switch} statement +(@pxref{Switch Statement}). +@end itemize + +@item +Changes to standard @command{awk} functions: + +@itemize @minus +@item +The optional second argument to @code{close()} that allows closing one end +of a two-way pipe to a coprocess +(@pxref{Two-way I/O}). + +@item +POSIX compliance for @code{gsub()} and @code{sub()}. + +@item +The @code{length()} function accepts an array argument +and returns the number of elements in the array +(@pxref{String Functions}). + +@item +The optional third argument to the @code{match()} function +for capturing text-matching subexpressions within a regexp +(@pxref{String Functions}). + +@item +Positional specifiers in @code{printf} formats for +making translations easier +(@pxref{Printf Ordering}). + +@item +The @code{split()} function's additional optional fourth +argument which is an array to hold the text of the field separators. +(@pxref{String Functions}). +@end itemize + +@item +Additional functions only in @command{gawk}: + +@itemize @minus +@item +The +@code{and()}, +@code{compl()}, +@code{lshift()}, +@code{or()}, +@code{rshift()}, +and +@code{xor()} +functions for bit manipulation +(@pxref{Bitwise Functions}). + +@item +The @code{asort()} and @code{asorti()} functions for sorting arrays +(@pxref{Array Sorting}). + +@item +The @code{bindtextdomain()}, @code{dcgettext()} and @code{dcngettext()} +functions for internationalization +(@pxref{Programmer i18n}). + +@item +The @code{extension()} built-in function and the ability to add +new functions dynamically +(@pxref{Dynamic Extensions}). + +@item +The @code{fflush()} function from Brian Kernighan's +version of @command{awk} +(@pxref{I/O Functions}). + +@item +The @code{gensub()}, @code{patsplit()}, and @code{strtonum()} functions +for more powerful text manipulation +(@pxref{String Functions}). + +@item +The @code{mktime()}, @code{systime()}, and @code{strftime()} +functions for working with timestamps +(@pxref{Time Functions}). +@end itemize + + +@item +Changes and/or additions in the command-line options: + +@itemize @minus +@item +The @env{AWKPATH} environment variable for specifying a path search for +the @option{-f} command-line option +(@pxref{Options}). + +@item +The ability to use GNU-style long-named options that start with @option{--} +and the +@option{--characters-as-bytes}, +@option{--compat}, +@option{--dump-variables}, +@option{--exec}, +@option{--gen-pot}, +@option{--lint}, +@option{--lint-old}, +@option{--non-decimal-data}, +@option{--posix}, +@option{--profile}, +@option{--re-interval}, +@option{--sandbox}, +@option{--source}, +@option{--traditional}, +and +@option{--use-lc-numeric} +options +(@pxref{Options}). +@end itemize + + +@c new ports + +@item +Support for the following obsolete systems was removed from the code +and the documentation for @command{gawk} @value{PVERSION} 4.0: + +@c nested table +@itemize @minus +@item +Amiga + +@item +Atari + +@item +BeOS + +@item +Cray + +@item +MIPS RiscOS + +@item +MS-DOS with the Microsoft Compiler + +@item +MS-Windows with the Microsoft Compiler + +@item +NeXT + +@item +SunOS 3.x, Sun 386 (Road Runner) + +@item +Tandem (non-POSIX) + +@item +Prestandard VAX C compiler for VAX/VMS + +@end itemize + +@end itemize + +@c XXX ADD MORE STUFF HERE + +@c ENDOFRANGE fripls +@c ENDOFRANGE exgnot +@c ENDOFRANGE posnot + +@node Common Extensions +@appendixsec Common Extensions Summary + +This @value{SECTION} summarizes the common extensions supported +by @command{gawk}, Brian Kernighan's @command{awk}, and @command{mawk}, +the three most widely-used freely available versions of @command{awk} +(@pxref{Other Versions}). + +@multitable {@file{/dev/stderr} special file} {BWK Awk} {Mawk} {GNU Awk} +@headitem Feature @tab BWK Awk @tab Mawk @tab GNU Awk +@item @samp{\x} Escape sequence @tab X @tab X @tab X +@item @code{RS} as regexp @tab @tab X @tab X +@item @code{FS} as null string @tab X @tab X @tab X +@item @file{/dev/stdin} special file @tab X @tab @tab X +@item @file{/dev/stdout} special file @tab X @tab X @tab X +@item @file{/dev/stderr} special file @tab X @tab X @tab X +@item @code{**} and @code{**=} operators @tab X @tab @tab X +@item @code{func} keyword @tab X @tab @tab X +@item @code{nextfile} statement @tab X @tab X @tab X +@item @code{delete} without subscript @tab X @tab X @tab X +@item @code{length()} of an array @tab X @tab @tab X +@item @code{fflush()} function @tab X @tab X @tab X +@item @code{BINMODE} variable @tab @tab X @tab X +@end multitable + +@node Ranges and Locales +@appendixsec Regexp Ranges and Locales: A Long Sad Story + +This @value{SECTION} describes the confusing history of ranges within +regular expressions and their interactions with locales, and how this +affected different versions of @command{gawk}. + +The original Unix tools that worked with regular expressions defined +character ranges (such as @samp{[a-z]}) to match any character between +the first character in the range and the last character in the range, +inclusive. Ordering was based on the numeric value of each character +in the machine's native character set. Thus, on ASCII-based systems, +@code{[a-z]} matched all the lowercase letters, and only the lowercase +letters, since the numeric values for the letters from @samp{a} through +@samp{z} were contiguous. (On an EBCDIC system, the range @samp{[a-z]} +includes additional, non-alphabetic characters as well.) + +Almost all introductory Unix literature explained range expressions +as working in this fashion, and in particular, would teach that the +``correct'' way to match lowercase letters was with @samp{[a-z]}, and +that @samp{[A-Z]} was the ``correct'' way to match uppercase letters. +And indeed, this was true. + +The 1993 POSIX standard introduced the idea of locales (@pxref{Locales}). +Since many locales include other letters besides the plain twenty-six +letters of the American English alphabet, the POSIX standard added +character classes (@pxref{Bracket Expressions}) as a way to match +different kinds of characters besides the traditional ones in the ASCII +character set. + +However, the standard @emph{changed} the interpretation of range expressions. +In the @code{"C"} and @code{"POSIX"} locales, a range expression like +@samp{[a-dx-z]} is still equivalent to @samp{[abcdxyz]}, as in ASCII. +But outside those locales, the ordering was defined to be based on +@dfn{collation order}. + +In many locales, @samp{A} and @samp{a} are both less than @samp{B}. +In other words, these locales sort characters in dictionary order, +and @samp{[a-dx-z]} is typically not equivalent to @samp{[abcdxyz]}; +instead it might be equivalent to @samp{[aBbCcdXxYyz]}, for example. + +This point needs to be emphasized: Much literature teaches that you should +use @samp{[a-z]} to match a lowercase character. But on systems with +non-ASCII locales, this also matched all of the uppercase characters +except @samp{Z}! This was a continuous cause of confusion, even well +into the twenty-first century. + +To demonstrate these issues, the following example uses the @code{sub()} +function, which does text replacement (@pxref{String Functions}). Here, +the intent is to remove trailing uppercase characters: + +@example +$ @kbd{echo something1234abc | gawk-3.1.8 '@{ sub("[A-Z]*$", ""); print @}'} +@print{} something1234a +@end example + +@noindent +This output is unexpected, since the @samp{bc} at the end of +@samp{something1234abc} should not normally match @samp{[A-Z]*}. +This result is due to the locale setting (and thus you may not see +it on your system). + +Similar considerations apply to other ranges. For example, @samp{["-/]} +is perfectly valid in ASCII, but is not valid in many Unicode locales, +such as @samp{en_US.UTF-8}. + +Early versions of @command{gawk} used regexp matching code that was not +locale aware, so ranges had their traditional interpretation. + +When @command{gawk} switched to using locale-aware regexp matchers, +the problems began; especially as both GNU/Linux and commercial Unix +vendors started implementing non-ASCII locales, @emph{and making them +the default}. Perhaps the most frequently asked question became something +like ``why does @code{[A-Z]} match lowercase letters?!?'' + +This situation existed for close to 10 years, if not more, and +the @command{gawk} maintainer grew weary of trying to explain that +@command{gawk} was being nicely standards-compliant, and that the issue +was in the user's locale. During the development of version 4.0, +he modified @command{gawk} to always treat ranges in the original, +pre-POSIX fashion, unless @option{--posix} was used (@pxref{Options}). + +Fortunately, shortly before the final release of @command{gawk} 4.0, +the maintainer learned that the 2008 standard had changed the +definition of ranges, such that outside the @code{"C"} and @code{"POSIX"} +locales, the meaning of range expressions was +@emph{undefined}.@footnote{See +@uref{http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03_05, the standard} +and +@uref{http://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap09.html#tag_21_09_03_05, its rationale}.} + +By using this lovely technical term, the standard gives license +to implementors to implement ranges in whatever way they choose. +The @command{gawk} maintainer chose to apply the pre-POSIX meaning in all +cases: the default regexp matching; with @option{--traditional}, and with +@option{--posix}; in all cases, @command{gawk} remains POSIX compliant. + +@node Contributors +@appendixsec Major Contributors to @command{gawk} +@cindex @command{gawk}, list of contributors to +@quotation +@i{Always give credit where credit is due.}@* +Anonymous +@end quotation + +This @value{SECTION} names the major contributors to @command{gawk} +and/or this @value{DOCUMENT}, in approximate chronological order: + +@itemize @bullet +@item +@cindex Aho, Alfred +@cindex Weinberger, Peter +@cindex Kernighan, Brian +Dr.@: Alfred V.@: Aho, +Dr.@: Peter J.@: Weinberger, and +Dr.@: Brian W.@: Kernighan, all of Bell Laboratories, +designed and implemented Unix @command{awk}, +from which @command{gawk} gets the majority of its feature set. + +@item +@cindex Rubin, Paul +Paul Rubin +did the initial design and implementation in 1986, and wrote +the first draft (around 40 pages) of this @value{DOCUMENT}. + +@item +@cindex Fenlason, Jay +Jay Fenlason +finished the initial implementation. + +@item +@cindex Close, Diane +Diane Close +revised the first draft of this @value{DOCUMENT}, bringing it +to around 90 pages. + +@item +@cindex Stallman, Richard +Richard Stallman +helped finish the implementation and the initial draft of this +@value{DOCUMENT}. +He is also the founder of the FSF and the GNU project. + +@item +@cindex Woods, John +John Woods +contributed parts of the code (mostly fixes) in +the initial version of @command{gawk}. + +@item +@cindex Trueman, David +In 1988, +David Trueman +took over primary maintenance of @command{gawk}, +making it compatible with ``new'' @command{awk}, and +greatly improving its performance. + +@item +@cindex Kwok, Conrad +@cindex Garfinkle, Scott +@cindex Williams, Kent +Conrad Kwok, +Scott Garfinkle, +and +Kent Williams +did the initial ports to MS-DOS with various versions of MSC. + +@item +@cindex Rankin, Pat +Pat Rankin +provided the VMS port and its documentation. + +@item +@cindex Peterson, Hal +Hal Peterson +provided help in porting @command{gawk} to Cray systems. +(This is no longer supported.) + +@item +@cindex Rommel, Kai Uwe +Kai Uwe Rommel +provided the initial port to OS/2 and its documentation. + +@item +@cindex Jaegermann, Michal +Michal Jaegermann +provided the port to Atari systems and its documentation. +(This port is no longer supported.) +He continues to provide portability checking with DEC Alpha +systems, and has done a lot of work to make sure @command{gawk} +works on non-32-bit systems. + +@item +@cindex Fish, Fred +Fred Fish +provided the port to Amiga systems and its documentation. +(With Fred's sad passing, this is no longer supported.) + +@item +@cindex Deifik, Scott +Scott Deifik +currently maintains the MS-DOS port using DJGPP. + +@item +@cindex Zaretskii, Eli +Eli Zaretskii +currently maintains the MS-Windows port using MinGW. + + +@item +@cindex Grigera, Juan +Juan Grigera +provided a port to Windows32 systems. +(This is no longer supported.) + +@item +@cindex Hankerson, Darrel +For many years, +Dr.@: Darrel Hankerson +acted as coordinator for the various ports to different PC platforms +and created binary distributions for various PC operating systems. +He was also instrumental in keeping the documentation up to date for +the various PC platforms. + +@item +@cindex Zoulas, Christos +Christos Zoulas +provided the @code{extension()} +built-in function for dynamically adding new modules. + +@item +@cindex Kahrs, J@"urgen +J@"urgen Kahrs +contributed the initial version of the TCP/IP networking +code and documentation, and motivated the inclusion of the @samp{|&} operator. + +@item +@cindex Davies, Stephen +Stephen Davies +provided the initial port to Tandem systems and its documentation. +(However, this is no longer supported.) +He was also instrumental in the initial work to integrate the +byte-code internals into the @command{gawk} code base. + +@item +@cindex Woehlke, Matthew +Matthew Woehlke +provided improvements for Tandem's POSIX-compliant systems. + +@item +@cindex Brown, Martin +Martin Brown +provided the port to BeOS and its documentation. +(This is no longer supported.) + +@item +@cindex Peters, Arno +Arno Peters +did the initial work to convert @command{gawk} to use +GNU Automake and GNU @code{gettext}. + +@item +@cindex Broder, Alan J.@: +Alan J.@: Broder +provided the initial version of the @code{asort()} function +as well as the code for the optional third argument to the +@code{match()} function. + +@item +@cindex Buening, Andreas +Andreas Buening +updated the @command{gawk} port for OS/2. + +@item +@cindex Hasegawa, Isamu +Isamu Hasegawa, +of IBM in Japan, contributed support for multibyte characters. + +@item +@cindex Benzinger, Michael +Michael Benzinger contributed the initial code for @code{switch} statements. + +@item +@cindex McPhee, Patrick +Patrick T.J.@: McPhee contributed the code for dynamic loading in Windows32 +environments. +(This is no longer supported) + +@item +@cindex Haque, John +John Haque +reworked the @command{gawk} internals to use a byte-code engine, +providing the @command{dgawk} debugger for @command{awk} programs. + +@item +@cindex Yawitz, Efraim +Efraim Yawitz contributed the original text for @ref{Debugger}. + +@item +@cindex Robbins, Arnold +Arnold Robbins +has been working on @command{gawk} since 1988, at first +helping David Trueman, and as the primary maintainer since around 1994. +@end itemize + +@node Installation +@appendix Installing @command{gawk} + +@c last two commas are part of see also +@cindex operating systems, See Also GNU/Linux, PC operating systems, Unix +@c STARTOFRANGE gligawk +@cindex @command{gawk}, installing +@c STARTOFRANGE ingawk +@cindex installing @command{gawk} +This appendix provides instructions for installing @command{gawk} on the +various platforms that are supported by the developers. The primary +developer supports GNU/Linux (and Unix), whereas the other ports are +contributed. +@xref{Bugs}, +for the electronic mail addresses of the people who did +the respective ports. + +@menu +* Gawk Distribution:: What is in the @command{gawk} distribution. +* Unix Installation:: Installing @command{gawk} under various + versions of Unix. +* Non-Unix Installation:: Installation on Other Operating Systems. +* Bugs:: Reporting Problems and Bugs. +* Other Versions:: Other freely available @command{awk} + implementations. +@end menu + +@node Gawk Distribution +@appendixsec The @command{gawk} Distribution +@cindex source code, @command{gawk} + +This @value{SECTION} describes how to get the @command{gawk} +distribution, how to extract it, and then what is in the various files and +subdirectories. + +@menu +* Getting:: How to get the distribution. +* Extracting:: How to extract the distribution. +* Distribution contents:: What is in the distribution. +@end menu + +@node Getting +@appendixsubsec Getting the @command{gawk} Distribution +@cindex @command{gawk}, source code@comma{} obtaining +There are three ways to get GNU software: + +@itemize @bullet +@item +Copy it from someone else who already has it. + +@cindex FSF (Free Software Foundation) +@cindex Free Software Foundation (FSF) +@item +Retrieve @command{gawk} +from the Internet host +@code{ftp.gnu.org}, in the directory @file{/gnu/gawk}. +Both anonymous @command{ftp} and @code{http} access are supported. +If you have the @command{wget} program, you can use a command like +the following: + +@example +wget http://ftp.gnu.org/gnu/gawk/gawk-@value{VERSION}.@value{PATCHLEVEL}.tar.gz +@end example +@end itemize + +The GNU software archive is mirrored around the world. +The up-to-date list of mirror sites is available from +@uref{http://www.gnu.org/order/ftp.html, the main FSF web site}. +Try to use one of the mirrors; they +will be less busy, and you can usually find one closer to your site. + +@node Extracting +@appendixsubsec Extracting the Distribution +@command{gawk} is distributed as several @code{tar} files compressed with +different compression programs: @command{gzip}, @command{bzip2}, +and @command{xz}. For simplicity, the rest of these instructions assume +you are using the one compressed with the GNU Zip program, @code{gzip}. + +Once you have the distribution (for example, +@file{gawk-@value{VERSION}.@value{PATCHLEVEL}.tar.gz}), +use @code{gzip} to expand the +file and then use @code{tar} to extract it. You can use the following +pipeline to produce the @command{gawk} distribution: + +@example +# Under System V, add 'o' to the tar options +gzip -d -c gawk-@value{VERSION}.@value{PATCHLEVEL}.tar.gz | tar -xvpf - +@end example + +On a system with GNU @command{tar}, you can let @command{tar} +do the decompression for you: + +@example +tar -xvpzf gawk-@value{VERSION}.@value{PATCHLEVEL}.tar.gz +@end example + +@noindent +Extracting the archive +creates a directory named @file{gawk-@value{VERSION}.@value{PATCHLEVEL}} +in the current directory. + +The distribution @value{FN} is of the form +@file{gawk-@var{V}.@var{R}.@var{P}.tar.gz}. +The @var{V} represents the major version of @command{gawk}, +the @var{R} represents the current release of version @var{V}, and +the @var{P} represents a @dfn{patch level}, meaning that minor bugs have +been fixed in the release. The current patch level is @value{PATCHLEVEL}, +but when retrieving distributions, you should get the version with the highest +version, release, and patch level. (Note, however, that patch levels greater than +or equal to 70 denote ``beta'' or nonproduction software; you might not want +to retrieve such a version unless you don't mind experimenting.) +If you are not on a Unix or GNU/Linux system, you need to make other arrangements +for getting and extracting the @command{gawk} distribution. You should consult +a local expert. + +@node Distribution contents +@appendixsubsec Contents of the @command{gawk} Distribution +@c STARTOFRANGE gawdis +@cindex @command{gawk}, distribution + +The @command{gawk} distribution has a number of C source files, +documentation files, +subdirectories, and files related to the configuration process +(@pxref{Unix Installation}), +as well as several subdirectories related to different non-Unix +operating systems: + +@table @asis +@item Various @samp{.c}, @samp{.y}, and @samp{.h} files +The actual @command{gawk} source code. +@end table + +@table @file +@item README +@itemx README_d/README.* +Descriptive files: @file{README} for @command{gawk} under Unix and the +rest for the various hardware and software combinations. + +@item INSTALL +A file providing an overview of the configuration and installation process. + +@item ChangeLog +A detailed list of source code changes as bugs are fixed or improvements made. + +@item ChangeLog.0 +An older list of source code changes. + +@item NEWS +A list of changes to @command{gawk} since the last release or patch. + +@item NEWS.0 +An older list of changes to @command{gawk}. + +@item COPYING +The GNU General Public License. + +@item FUTURES +A brief list of features and changes being contemplated for future +releases, with some indication of the time frame for the feature, based +on its difficulty. + +@item LIMITATIONS +A list of those factors that limit @command{gawk}'s performance. +Most of these depend on the hardware or operating system software and +are not limits in @command{gawk} itself. + +@item POSIX.STD +A description of behaviors in the POSIX standard for @command{awk} which +are left undefined, or where @command{gawk} may not comply fully, as well +as a list of things that the POSIX standard should describe but does not. + +@cindex artificial intelligence@comma{} @command{gawk} and +@item doc/awkforai.txt +A short article describing why @command{gawk} is a good language for +Artificial Intelligence (AI) programming. + +@item doc/bc_notes +A brief description of @command{gawk}'s ``byte code'' internals. + +@item doc/README.card +@itemx doc/ad.block +@itemx doc/awkcard.in +@itemx doc/cardfonts +@itemx doc/colors +@itemx doc/macros +@itemx doc/no.colors +@itemx doc/setter.outline +The @command{troff} source for a five-color @command{awk} reference card. +A modern version of @command{troff} such as GNU @command{troff} (@command{groff}) is +needed to produce the color version. See the file @file{README.card} +for instructions if you have an older @command{troff}. + +@item doc/gawk.1 +The @command{troff} source for a manual page describing @command{gawk}. +This is distributed for the convenience of Unix users. + +@cindex Texinfo +@item doc/gawk.texi +The Texinfo source file for this @value{DOCUMENT}. +It should be processed with @TeX{} +(via @command{texi2dvi} or @command{texi2pdf}) +to produce a printed document, and +with @command{makeinfo} to produce an Info or HTML file. + +@item doc/gawk.info +The generated Info file for this @value{DOCUMENT}. + +@item doc/gawkinet.texi +The Texinfo source file for +@ifinfo +@inforef{Top, , General Introduction, gawkinet, TCP/IP Internetworking with @command{gawk}}. +@end ifinfo +@ifnotinfo +@cite{TCP/IP Internetworking with @command{gawk}}. +@end ifnotinfo +It should be processed with @TeX{} +(via @command{texi2dvi} or @command{texi2pdf}) +to produce a printed document and +with @command{makeinfo} to produce an Info or HTML file. + +@item doc/gawkinet.info +The generated Info file for +@cite{TCP/IP Internetworking with @command{gawk}}. + +@item doc/igawk.1 +The @command{troff} source for a manual page describing the @command{igawk} +program presented in +@ref{Igawk Program}. + +@item doc/Makefile.in +The input file used during the configuration process to generate the +actual @file{Makefile} for creating the documentation. + +@item Makefile.am +@itemx */Makefile.am +Files used by the GNU @command{automake} software for generating +the @file{Makefile.in} files used by @command{autoconf} and +@command{configure}. + +@item Makefile.in +@itemx aclocal.m4 +@itemx configh.in +@itemx configure.ac +@itemx configure +@itemx custom.h +@itemx missing_d/* +@itemx m4/* +These files and subdirectories are used when configuring @command{gawk} +for various Unix systems. They are explained in +@ref{Unix Installation}. + +@item po/* +The @file{po} library contains message translations. + +@item awklib/extract.awk +@itemx awklib/Makefile.am +@itemx awklib/Makefile.in +@itemx awklib/eg/* +The @file{awklib} directory contains a copy of @file{extract.awk} +(@pxref{Extract Program}), +which can be used to extract the sample programs from the Texinfo +source file for this @value{DOCUMENT}. It also contains a @file{Makefile.in} file, which +@command{configure} uses to generate a @file{Makefile}. +@file{Makefile.am} is used by GNU Automake to create @file{Makefile.in}. +The library functions from +@ref{Library Functions}, +and the @command{igawk} program from +@ref{Igawk Program}, +are included as ready-to-use files in the @command{gawk} distribution. +They are installed as part of the installation process. +The rest of the programs in this @value{DOCUMENT} are available in appropriate +subdirectories of @file{awklib/eg}. + +@item posix/* +Files needed for building @command{gawk} on POSIX-compliant systems. + +@item pc/* +Files needed for building @command{gawk} under MS-Windows and OS/2 +(@pxref{PC Installation}, for details). + +@item vms/* +Files needed for building @command{gawk} under VMS +(@pxref{VMS Installation}, for details). + +@item test/* +A test suite for +@command{gawk}. You can use @samp{make check} from the top-level @command{gawk} +directory to run your version of @command{gawk} against the test suite. +If @command{gawk} successfully passes @samp{make check}, then you can +be confident of a successful port. +@end table +@c ENDOFRANGE gawdis + +@node Unix Installation +@appendixsec Compiling and Installing @command{gawk} on Unix-like Systems + +Usually, you can compile and install @command{gawk} by typing only two +commands. However, if you use an unusual system, you may need +to configure @command{gawk} for your system yourself. + +@menu +* Quick Installation:: Compiling @command{gawk} under Unix. +* Additional Configuration Options:: Other compile-time options. +* Configuration Philosophy:: How it's all supposed to work. +@end menu + +@node Quick Installation +@appendixsubsec Compiling @command{gawk} for Unix-like Systems + +The normal installation steps should work on all modern commercial +Unix-derived systems, GNU/Linux, BSD-based systems, and the Cygwin +environment for MS-Windows. + +After you have extracted the @command{gawk} distribution, @command{cd} +to @file{gawk-@value{VERSION}.@value{PATCHLEVEL}}. Like most GNU software, +@command{gawk} is configured +automatically for your system by running the @command{configure} program. +This program is a Bourne shell script that is generated automatically using +GNU @command{autoconf}. +@ifnotinfo +(The @command{autoconf} software is +described fully in +@cite{Autoconf---Generating Automatic Configuration Scripts}, +which can be found online at +@uref{http://www.gnu.org/software/autoconf/manual/index.html, +the Free Software Foundation's web site}.) +@end ifnotinfo +@ifinfo +(The @command{autoconf} software is described fully starting with +@inforef{Top, , Autoconf, autoconf,Autoconf---Generating Automatic Configuration Scripts}.) +@end ifinfo + +To configure @command{gawk}, simply run @command{configure}: + +@example +sh ./configure +@end example + +This produces a @file{Makefile} and @file{config.h} tailored to your system. +The @file{config.h} file describes various facts about your system. +You might want to edit the @file{Makefile} to +change the @code{CFLAGS} variable, which controls +the command-line options that are passed to the C compiler (such as +optimization levels or compiling for debugging). + +Alternatively, you can add your own values for most @command{make} +variables on the command line, such as @code{CC} and @code{CFLAGS}, when +running @command{configure}: + +@example +CC=cc CFLAGS=-g sh ./configure +@end example + +@noindent +See the file @file{INSTALL} in the @command{gawk} distribution for +all the details. + +After you have run @command{configure} and possibly edited the @file{Makefile}, +type: + +@example +make +@end example + +@noindent +Shortly thereafter, you should have an executable version of @command{gawk}. +That's all there is to it! +To verify that @command{gawk} is working properly, +run @samp{make check}. All of the tests should succeed. +If these steps do not work, or if any of the tests fail, +check the files in the @file{README_d} directory to see if you've +found a known problem. If the failure is not described there, +please send in a bug report (@pxref{Bugs}). + +@node Additional Configuration Options +@appendixsubsec Additional Configuration Options +@cindex @command{gawk}, configuring, options +@cindex configuration options@comma{} @command{gawk} + +There are several additional options you may use on the @command{configure} +command line when compiling @command{gawk} from scratch, including: + +@table @code + +@cindex @code{--disable-lint} configuration option +@cindex configuration option, @code{--disable-lint} +@item --disable-lint +Disable all lint checking within @code{gawk}. The +@option{--lint} and @option{--lint-old} options +(@pxref{Options}) +are accepted, but silently do nothing. +Similarly, setting the @code{LINT} variable +(@pxref{User-modified}) +has no effect on the running @command{awk} program. + +When used with GCC's automatic dead-code-elimination, this option +cuts almost 200K bytes off the size of the @command{gawk} +executable on GNU/Linux x86 systems. Results on other systems and +with other compilers are likely to vary. +Using this option may bring you some slight performance improvement. + +Using this option will cause some of the tests in the test suite +to fail. This option may be removed at a later date. + +@cindex @code{--disable-nls} configuration option +@cindex configuration option, @code{--disable-nls} +@item --disable-nls +Disable all message-translation facilities. +This is usually not desirable, but it may bring you some slight performance +improvement. + +@cindex @code{--with-whiny-user-strftime} configuration option +@cindex configuration option, @code{--with-whiny-user-strftime} +@item --with-whiny-user-strftime +Force use of the included version of the @code{strftime()} +function for deficient systems. +@end table + +Use the command @samp{./configure --help} to see the full list of +options that @command{configure} supplies. + +@node Configuration Philosophy +@appendixsubsec The Configuration Process + +@cindex @command{gawk}, configuring +This @value{SECTION} is of interest only if you know something about using the +C language and Unix-like operating systems. + +The source code for @command{gawk} generally attempts to adhere to formal +standards wherever possible. This means that @command{gawk} uses library +routines that are specified by the ISO C standard and by the POSIX +operating system interface standard. +The @command{gawk} source code requires using an ISO C compiler (the 1990 +standard). + +Many Unix systems do not support all of either the ISO or the +POSIX standards. The @file{missing_d} subdirectory in the @command{gawk} +distribution contains replacement versions of those functions that are +most likely to be missing. + +The @file{config.h} file that @command{configure} creates contains +definitions that describe features of the particular operating system +where you are attempting to compile @command{gawk}. The three things +described by this file are: what header files are available, so that +they can be correctly included, what (supposedly) standard functions +are actually available in your C libraries, and various miscellaneous +facts about your operating system. For example, there may not be an +@code{st_blksize} element in the @code{stat} structure. In this case, +@samp{HAVE_ST_BLKSIZE} is undefined. + +@cindex @code{custom.h} file +It is possible for your C compiler to lie to @command{configure}. It may +do so by not exiting with an error when a library function is not +available. To get around this, edit the file @file{custom.h}. +Use an @samp{#ifdef} that is appropriate for your system, and either +@code{#define} any constants that @command{configure} should have defined but +didn't, or @code{#undef} any constants that @command{configure} defined and +should not have. @file{custom.h} is automatically included by +@file{config.h}. + +It is also possible that the @command{configure} program generated by +@command{autoconf} will not work on your system in some other fashion. +If you do have a problem, the file @file{configure.ac} is the input for +@command{autoconf}. You may be able to change this file and generate a +new version of @command{configure} that works on your system +(@pxref{Bugs}, +for information on how to report problems in configuring @command{gawk}). +The same mechanism may be used to send in updates to @file{configure.ac} +and/or @file{custom.h}. + +@node Non-Unix Installation +@appendixsec Installation on Other Operating Systems + +This @value{SECTION} describes how to install @command{gawk} on +various non-Unix systems. + +@menu +* PC Installation:: Installing and Compiling @command{gawk} on + MS-DOS and OS/2. +* VMS Installation:: Installing @command{gawk} on VMS. +@end menu + +@c Rewritten by Scott Deifik +@c and Darrel Hankerson + +@node PC Installation +@appendixsubsec Installation on PC Operating Systems + +@cindex PC operating systems@comma{} @command{gawk} on, installing +@cindex operating systems, PC@comma{} @command{gawk} on, installing +This @value{SECTION} covers installation and usage of @command{gawk} on x86 machines +running MS-DOS, any version of MS-Windows, or OS/2. +In this @value{SECTION}, the term ``Windows32'' +refers to any of Microsoft Windows-95/98/ME/NT/2000/XP/Vista/7. + +The limitations of MS-DOS (and MS-DOS shells under Windows32 or OS/2) has meant +that various ``DOS extenders'' are often used with programs such as +@command{gawk}. The varying capabilities of Microsoft Windows 3.1 +and Windows32 can add to the confusion. For an overview of the +considerations, please refer to @file{README_d/README.pc} in the +distribution. + +@menu +* PC Binary Installation:: Installing a prepared distribution. +* PC Compiling:: Compiling @command{gawk} for MS-DOS, + Windows32, and OS/2. +* PC Testing:: Testing @command{gawk} on PC systems. +* PC Using:: Running @command{gawk} on MS-DOS, Windows32 + and OS/2. +* Cygwin:: Building and running @command{gawk} for + Cygwin. +* MSYS:: Using @command{gawk} In The MSYS Environment. +@end menu + +@node PC Binary Installation +@appendixsubsubsec Installing a Prepared Distribution for PC Systems + +If you have received a binary distribution prepared by the MS-DOS +maintainers, then @command{gawk} and the necessary support files appear +under the @file{gnu} directory, with executables in @file{gnu/bin}, +libraries in @file{gnu/lib/awk}, and manual pages under @file{gnu/man}. +This is designed for easy installation to a @file{/gnu} directory on your +drive---however, the files can be installed anywhere provided @env{AWKPATH} is +set properly. Regardless of the installation directory, the first line of +@file{igawk.cmd} and @file{igawk.bat} (in @file{gnu/bin}) may need to be +edited. + +The binary distribution contains a separate file describing the +contents. In particular, it may include more than one version of the +@command{gawk} executable. + +OS/2 (32 bit, EMX) binary distributions are prepared for the @file{/usr} +directory of your preferred drive. Set @env{UNIXROOT} to your installation +drive (e.g., @samp{e:}) if you want to install @command{gawk} onto another drive +than the hardcoded default @samp{c:}. Executables appear in @file{/usr/bin}, +libraries under @file{/usr/share/awk}, manual pages under @file{/usr/man}, +Texinfo documentation under @file{/usr/info}, and NLS files +under @file{/usr/share/locale}. +Note that the files can be installed anywhere provided @env{AWKPATH} is +set properly. + +If you already have a file @file{/usr/info/dir} from another package +@emph{do not overwrite it!} Instead enter the following commands at your prompt +(replace @samp{x:} by your installation drive): + +@example +install-info --info-dir=x:/usr/info x:/usr/info/gawk.info +install-info --info-dir=x:/usr/info x:/usr/info/gawkinet.info +@end example + +The binary distribution may contain a separate file containing additional +or more detailed installation instructions. + +@node PC Compiling +@appendixsubsubsec Compiling @command{gawk} for PC Operating Systems + +@command{gawk} can be compiled for MS-DOS, Windows32, and OS/2 using the GNU +development tools from DJ Delorie (DJGPP: MS-DOS only) or Eberhard +Mattes (EMX: MS-DOS, Windows32 and OS/2). The file +@file{README_d/README.pc} in the @command{gawk} distribution contains +additional notes, and @file{pc/Makefile} contains important information on +compilation options. + +@cindex compiling @command{gawk} for MS-DOS and MS-Windows +To build @command{gawk} for MS-DOS and Windows32, copy the files in +the @file{pc} directory (@emph{except} for @file{ChangeLog}) to the +directory with the rest of the @command{gawk} sources, then invoke +@command{make} with the appropriate target name as an argument to +build @command{gawk}. The @file{Makefile} copied from the @file{pc} +directory contains a configuration section with comments and may need +to be edited in order to work with your @command{make} utility. + +The @file{Makefile} supports a number of targets for building various +MS-DOS and Windows32 versions. A list of targets is printed if the +@command{make} command is given without a target. As an example, to +build @command{gawk} using the DJGPP tools, enter @samp{make djgpp}. +(The DJGPP tools needed for the build may be found at +@uref{ftp://ftp.delorie.com/pub/djgpp/current/v2gnu/}.) To build a +native MS-Windows binary of @command{gawk}, type @samp{make mingw32}. + +@cindex compiling @command{gawk} with EMX for OS/2 +The 32 bit EMX version of @command{gawk} works ``out of the box'' under OS/2. +However, it is highly recommended to use GCC 2.95.3 for the compilation. +In principle, it is possible to compile @command{gawk} the following way: + +@example +$ @kbd{./configure} +$ @kbd{make} +@end example + +This is not recommended, though. To get an OMF executable you should +use the following commands at your @command{sh} prompt: + +@example +$ @kbd{CFLAGS="-O2 -Zomf -Zmt"} +$ @kbd{export CFLAGS} +$ @kbd{LDFLAGS="-s -Zcrtdll -Zlinker /exepack:2 -Zlinker /pm:vio -Zstack 0x6000"} +$ @kbd{export LDFLAGS} +$ @kbd{RANLIB="echo"} +$ @kbd{export RANLIB} +$ @kbd{./configure --prefix=c:/usr} +$ @kbd{make AR=emxomfar} +@end example + +These are just suggestions for use with GCC 2.x. You may use any other set of +(self-consistent) environment variables and compiler flags. + +@ignore +To get an FHS-compliant file hierarchy it is recommended to use the additional +@command{configure} options @option{--infodir=c:/usr/share/info}, @option{--mandir=c:/usr/share/man} +and @option{--libexecdir=c:/usr/lib}. +@end ignore + +@ignore +The internal @code{gettext} library tends to be problematic. It is therefore recommended +to use either an external one (@option{--without-included-gettext}) or to disable +NLS entirely (@option{--disable-nls}). +@end ignore + +If you use GCC 2.95 it is recommended to use also: + +@example +$ @kbd{LIBS="-lgcc"} +$ @kbd{export LIBS} +@end example + +You can also get an @code{a.out} executable if you prefer: + +@example +$ @kbd{CFLAGS="-O2 -Zmt"} +$ @kbd{export CFLAGS} +$ @kbd{LDFLAGS="-s -Zstack 0x6000"} +$ @kbd{LIBS="-lgcc"} +$ @kbd{unset RANLIB} +@c $ ./configure --prefix=c:/usr --without-included-gettext +$ @kbd{./configure --prefix=c:/usr} +$ @kbd{make} +@end example + +@quotation NOTE +Compilation of @code{a.out} executables also works with GCC 3.2. +Versions later than GCC 3.2 have not been tested successfully. +@end quotation + +@samp{make install} works as expected with the EMX build. + +@quotation NOTE +Ancient OS/2 ports of GNU @command{make} are not able to handle +the Makefiles of this package. If you encounter any problems with +@command{make}, try GNU Make 3.79.1 or later versions. You should +find the latest version on +@uref{ftp://hobbes.nmsu.edu/pub/os2/}. +@end quotation + +@node PC Testing +@appendixsubsubsec Testing @command{gawk} on PC Operating Systems + +Using @command{make} to run the standard tests and to install @command{gawk} +requires additional Unix-like tools, including @command{sh}, @command{sed}, and +@command{cp}. In order to run the tests, the @file{test/*.ok} files may need to +be converted so that they have the usual MS-DOS-style end-of-line markers. +Alternatively, run @command{make check CMP="diff -a"} to use GNU @command{diff} +in text mode instead of @command{cmp} to compare the resulting files. + +Most +of the tests work properly with Stewartson's shell along with the +companion utilities or appropriate GNU utilities. However, some editing of +@file{test/Makefile} is required. It is recommended that you copy the file +@file{pc/Makefile.tst} over the file @file{test/Makefile} as a +replacement. Details can be found in @file{README_d/README.pc} +and in the file @file{pc/Makefile.tst}. + +On OS/2 the @code{pid} test fails because @code{spawnl()} is used instead of +@code{fork()}/@code{execl()} to start child processes. +Also the @code{mbfw1} and @code{mbprintf1} tests fail because the needed +multibyte functionality is not available. + + +@node PC Using +@appendixsubsubsec Using @command{gawk} on PC Operating Systems +@c STARTOFRANGE opgawx +@cindex operating systems, PC, @command{gawk} on +@c STARTOFRANGE pcgawon +@cindex PC operating systems, @command{gawk} on + +With the exception of the Cygwin environment, +the @samp{|&} operator and TCP/IP networking +(@pxref{TCP/IP Networking}) +are not supported for MS-DOS or MS-Windows. EMX (OS/2 only) does support +at least the @samp{|&} operator. + +@cindex search paths +@cindex search paths, for source files +@cindex @command{gawk}, OS/2 version of +@cindex @command{gawk}, MS-DOS version of +@cindex @command{gawk}, MS-Windows version of +@cindex @code{;} (semicolon), @code{AWKPATH} variable and +@cindex semicolon (@code{;}), @code{AWKPATH} variable and +@cindex @code{AWKPATH} environment variable +The MS-DOS and MS-Windows versions of @command{gawk} search for +program files as described in @ref{AWKPATH Variable}. However, +semicolons (rather than colons) separate elements in the @env{AWKPATH} +variable. If @env{AWKPATH} is not set or is empty, then the default +search path for MS-Windows and MS-DOS versions is +@code{@w{".;c:/lib/awk;c:/gnu/lib/awk"}}. + +@cindex @code{UNIXROOT} variable, on OS/2 systems +The search path for OS/2 (32 bit, EMX) is determined by the prefix directory +(most likely @file{/usr} or @file{c:/usr}) that has been specified as an option of +the @command{configure} script like it is the case for the Unix versions. +If @file{c:/usr} is the prefix directory then the default search path contains @file{.} +and @file{c:/usr/share/awk}. +Additionally, to support binary distributions of @command{gawk} for OS/2 +systems whose drive @samp{c:} might not support long file names or might not exist +at all, there is a special environment variable. If @env{UNIXROOT} specifies +a drive then this specific drive is also searched for program files. +E.g., if @env{UNIXROOT} is set to @file{e:} the complete default search path is +@code{@w{".;c:/usr/share/awk;e:/usr/share/awk"}}. + +An @command{sh}-like shell (as opposed to @command{command.com} under MS-DOS +or @command{cmd.exe} under MS-Windows or OS/2) may be useful for @command{awk} programming. +The DJGPP collection of tools includes an MS-DOS port of Bash, +and several shells are available for OS/2, including @command{ksh}. + +@cindex common extensions, @code{BINMODE} variable +@cindex extensions, common@comma{} @code{BINMODE} variable +@cindex differences in @command{awk} and @command{gawk}, @code{BINMODE} variable +@cindex @code{BINMODE} variable +Under MS-Windows, OS/2 and MS-DOS, @command{gawk} (and many other text programs) silently +translate end-of-line @code{"\r\n"} to @code{"\n"} on input and @code{"\n"} +to @code{"\r\n"} on output. A special @code{BINMODE} variable @value{COMMONEXT} +allows control over these translations and is interpreted as follows: + +@itemize @bullet +@item +If @code{BINMODE} is @code{"r"}, or one, +then +binary mode is set on read (i.e., no translations on reads). + +@item +If @code{BINMODE} is @code{"w"}, or two, +then +binary mode is set on write (i.e., no translations on writes). + +@item +If @code{BINMODE} is @code{"rw"} or @code{"wr"} or three, +binary mode is set for both read and write. + +@item +@code{BINMODE=@var{non-null-string}} is +the same as @samp{BINMODE=3} (i.e., no translations on +reads or writes). However, @command{gawk} issues a warning +message if the string is not one of @code{"rw"} or @code{"wr"}. +@end itemize + +@noindent +The modes for standard input and standard output are set one time +only (after the +command line is read, but before processing any of the @command{awk} program). +Setting @code{BINMODE} for standard input or +standard output is accomplished by using an +appropriate @samp{-v BINMODE=@var{N}} option on the command line. +@code{BINMODE} is set at the time a file or pipe is opened and cannot be +changed mid-stream. + +The name @code{BINMODE} was chosen to match @command{mawk} +(@pxref{Other Versions}). +@command{mawk} and @command{gawk} handle @code{BINMODE} similarly; however, +@command{mawk} adds a @samp{-W BINMODE=@var{N}} option and an environment +variable that can set @code{BINMODE}, @code{RS}, and @code{ORS}. The +files @file{binmode[1-3].awk} (under @file{gnu/lib/awk} in some of the +prepared distributions) have been chosen to match @command{mawk}'s @samp{-W +BINMODE=@var{N}} option. These can be changed or discarded; in particular, +the setting of @code{RS} giving the fewest ``surprises'' is open to debate. +@command{mawk} uses @samp{RS = "\r\n"} if binary mode is set on read, which is +appropriate for files with the MS-DOS-style end-of-line. + +To illustrate, the following examples set binary mode on writes for standard +output and other files, and set @code{ORS} as the ``usual'' MS-DOS-style +end-of-line: + +@example +gawk -v BINMODE=2 -v ORS="\r\n" @dots{} +@end example + +@noindent +or: + +@example +gawk -v BINMODE=w -f binmode2.awk @dots{} +@end example + +@noindent +These give the same result as the @samp{-W BINMODE=2} option in +@command{mawk}. +The following changes the record separator to @code{"\r\n"} and sets binary +mode on reads, but does not affect the mode on standard input: + +@example +gawk -v RS="\r\n" --source "BEGIN @{ BINMODE = 1 @}" @dots{} +@end example + +@noindent +or: + +@example +gawk -f binmode1.awk @dots{} +@end example + +@noindent +With proper quoting, in the first example the setting of @code{RS} can be +moved into the @code{BEGIN} rule. + +@node Cygwin +@appendixsubsubsec Using @command{gawk} In The Cygwin Environment +@cindex compiling @command{gawk} for Cygwin + +@command{gawk} can be built and used ``out of the box'' under MS-Windows +if you are using the @uref{http://www.cygwin.com, Cygwin environment}. +This environment provides an excellent simulation of Unix, using the +GNU tools, such as Bash, the GNU Compiler Collection (GCC), GNU Make, +and other GNU programs. Compilation and installation for Cygwin is the +same as for a Unix system: + +@example +tar -xvpzf gawk-@value{VERSION}.@value{PATCHLEVEL}.tar.gz +cd gawk-@value{VERSION}.@value{PATCHLEVEL} +./configure +make +@end example + +When compared to GNU/Linux on the same system, the @samp{configure} +step on Cygwin takes considerably longer. However, it does finish, +and then the @samp{make} proceeds as usual. + +@quotation NOTE +The @samp{|&} operator and TCP/IP networking +(@pxref{TCP/IP Networking}) +are fully supported in the Cygwin environment. This is not true +for any other environment on MS-Windows. +@end quotation + +@node MSYS +@appendixsubsubsec Using @command{gawk} In The MSYS Environment + +In the MSYS environment under MS-Windows, @command{gawk} automatically +uses binary mode for reading and writing files. Thus there is no +need to use the @code{BINMODE} variable. + +This can cause problems with other Unix-like components that have +been ported to MS-Windows that expect @command{gawk} to do automatic +translation of @code{"\r\n"}, since it won't. Caveat Emptor! + +@node VMS Installation +@appendixsubsec How to Compile and Install @command{gawk} on VMS + +@c based on material from Pat Rankin +@c now rankin@pactechdata.com +@c now r.pat.rankin@gmail.com + +@cindex @command{gawk}, VMS version of +@cindex installation, VMS +This @value{SUBSECTION} describes how to compile and install @command{gawk} under VMS. +The older designation ``VMS'' is used throughout to refer to OpenVMS. + +@menu +* VMS Compilation:: How to compile @command{gawk} under VMS. +* VMS Installation Details:: How to install @command{gawk} under VMS. +* VMS Running:: How to run @command{gawk} under VMS. +* VMS Old Gawk:: An old version comes with some VMS systems. +@end menu + +@node VMS Compilation +@appendixsubsubsec Compiling @command{gawk} on VMS +@cindex compiling @command{gawk} for VMS + +To compile @command{gawk} under VMS, there is a @code{DCL} command procedure that +issues all the necessary @code{CC} and @code{LINK} commands. There is +also a @file{Makefile} for use with the @code{MMS} utility. From the source +directory, use either: + +@example +$ @kbd{@@[.VMS]VMSBUILD.COM} +@end example + +@noindent +or: + +@example +$ @kbd{MMS/DESCRIPTION=[.VMS]DESCRIP.MMS GAWK} +@end example + +Older versions of @command{gawk} could be built with VAX C or +GNU C on VAX/VMS, as well as with DEC C, but that is no longer +supported. DEC C (also briefly known as ``Compaq C'' and now known +as ``HP C,'' but referred to here as ``DEC C'') is required. Both +@code{VMSBUILD.COM} and @code{DESCRIP.MMS} contain some obsolete support +for the older compilers but are set up to use DEC C by default. + +@command{gawk} has been tested under Alpha/VMS 7.3-1 using Compaq C V6.4, +and on Alpha/VMS 7.3, Alpha/VMS 7.3-2, and IA64/VMS 8.3.@footnote{The IA64 +architecture is also known as ``Itanium.''} + +@node VMS Installation Details +@appendixsubsubsec Installing @command{gawk} on VMS + +To install @command{gawk}, all you need is a ``foreign'' command, which is +a @code{DCL} symbol whose value begins with a dollar sign. For example: + +@example +$ @kbd{GAWK :== $disk1:[gnubin]GAWK} +@end example + +@noindent +Substitute the actual location of @command{gawk.exe} for +@samp{$disk1:[gnubin]}. The symbol should be placed in the +@file{login.com} of any user who wants to run @command{gawk}, +so that it is defined every time the user logs on. +Alternatively, the symbol may be placed in the system-wide +@file{sylogin.com} procedure, which allows all users +to run @command{gawk}. + +Optionally, the help entry can be loaded into a VMS help library: + +@example +$ @kbd{LIBRARY/HELP SYS$HELP:HELPLIB [.VMS]GAWK.HLP} +@end example + +@noindent +(You may want to substitute a site-specific help library rather than +the standard VMS library @samp{HELPLIB}.) After loading the help text, +the command: + +@example +$ @kbd{HELP GAWK} +@end example + +@noindent +provides information about both the @command{gawk} implementation and the +@command{awk} programming language. + +The logical name @samp{AWK_LIBRARY} can designate a default location +for @command{awk} program files. For the @option{-f} option, if the specified +@value{FN} has no device or directory path information in it, @command{gawk} +looks in the current directory first, then in the directory specified +by the translation of @samp{AWK_LIBRARY} if the file is not found. +If, after searching in both directories, the file still is not found, +@command{gawk} appends the suffix @samp{.awk} to the filename and retries +the file search. If @samp{AWK_LIBRARY} has no definition, a default value +of @samp{SYS$LIBRARY:} is used for it. + +@node VMS Running +@appendixsubsubsec Running @command{gawk} on VMS + +Command-line parsing and quoting conventions are significantly different +on VMS, so examples in this @value{DOCUMENT} or from other sources often need minor +changes. They @emph{are} minor though, and all @command{awk} programs +should run correctly. + +Here are a couple of trivial tests: + +@example +$ @kbd{gawk -- "BEGIN @{print ""Hello, World!""@}"} +$ @kbd{gawk -"W" version} +! could also be -"W version" or "-W version" +@end example + +@noindent +Note that uppercase and mixed-case text must be quoted. + +The VMS port of @command{gawk} includes a @code{DCL}-style interface in addition +to the original shell-style interface (see the help entry for details). +One side effect of dual command-line parsing is that if there is only a +single parameter (as in the quoted string program above), the command +becomes ambiguous. To work around this, the normally optional @option{--} +flag is required to force Unix-style parsing rather than @code{DCL} parsing. If any +other dash-type options (or multiple parameters such as @value{DF}s to +process) are present, there is no ambiguity and @option{--} can be omitted. + +@c @cindex directory search +@c @cindex path, search +@cindex search paths +@cindex search paths, for source files +The default search path, when looking for @command{awk} program files specified +by the @option{-f} option, is @code{"SYS$DISK:[],AWK_LIBRARY:"}. The logical +name @env{AWKPATH} can be used to override this default. The format +of @env{AWKPATH} is a comma-separated list of directory specifications. +When defining it, the value should be quoted so that it retains a single +translation and not a multitranslation @code{RMS} searchlist. + +@ignore +@c The VMS POSIX product, also known as POSIX for OpenVMS, is long defunct +@c and building gawk for it has not been tested in many years, but these +@c old instructions might still work if anyone is still using it. + +@node VMS POSIX +@appendixsubsubsec Building and Using @command{gawk} on VMS POSIX + +Ignore the instructions above, although @file{vms/gawk.hlp} should still +be made available in a help library. The source tree should be unpacked +into a container file subsystem rather than into the ordinary VMS filesystem. +Make sure that the two scripts, @file{configure} and +@file{vms/posix-cc.sh}, are executable; use @samp{chmod +x} on them if +necessary. Then execute the following two commands: + +@example +psx> @kbd{CC=vms/posix-cc.sh configure} +psx> @kbd{make CC=c89 gawk} +@end example + +@noindent +The first command constructs files @file{config.h} and @file{Makefile} out +of templates, using a script to make the C compiler fit @command{configure}'s +expectations. The second command compiles and links @command{gawk} using +the C compiler directly; ignore any warnings from @command{make} about being +unable to redefine @code{CC}. @command{configure} takes a very long +time to execute, but at least it provides incremental feedback as it runs. + +This has been tested with VAX/VMS V6.2, VMS POSIX V2.0, and DEC C V5.2. + +Once built, @command{gawk} works like any other shell utility. Unlike +the normal VMS port of @command{gawk}, no special command-line manipulation is +needed in the VMS POSIX environment. +@end ignore + +@node VMS Old Gawk +@appendixsubsubsec Some VMS Systems Have An Old Version of @command{gawk} + +@c Thanks to "gerard labadie" + +Some versions of VMS have an old version of @command{gawk}. To access it, +define a symbol, as follows: + +@example +$ @kbd{gawk :== $sys$common:[syshlp.examples.tcpip.snmp]gawk.exe} +@end example + +This is apparently @value{PVERSION} 2.15.6, which is extremely old. We +recommend compiling and using the current version. + +@c ENDOFRANGE opgawx +@c ENDOFRANGE pcgawon + +@node Bugs +@appendixsec Reporting Problems and Bugs +@cindex archeologists +@quotation +@i{There is nothing more dangerous than a bored archeologist.}@* +The Hitchhiker's Guide to the Galaxy +@end quotation +@c the radio show, not the book. :-) + +@c STARTOFRANGE dbugg +@cindex debugging @command{gawk}, bug reports +@c STARTOFRANGE tblgawb +@cindex troubleshooting, @command{gawk}, bug reports +If you have problems with @command{gawk} or think that you have found a bug, +please report it to the developers; we cannot promise to do anything +but we might well want to fix it. + +Before reporting a bug, make sure you have actually found a real bug. +Carefully reread the documentation and see if it really says you can do +what you're trying to do. If it's not clear whether you should be able +to do something or not, report that too; it's a bug in the documentation! + +Before reporting a bug or trying to fix it yourself, try to isolate it +to the smallest possible @command{awk} program and input @value{DF} that +reproduces the problem. Then send us the program and @value{DF}, +some idea of what kind of Unix system you're using, +the compiler you used to compile @command{gawk}, and the exact results +@command{gawk} gave you. Also say what you expected to occur; this helps +us decide whether the problem is really in the documentation. + +Please include the version number of @command{gawk} you are using. +You can get this information with the command @samp{gawk --version}. + +@cindex @code{bug-gawk@@gnu.org} bug reporting address +@cindex email address for bug reports, @code{bug-gawk@@gnu.org} +@cindex bug reports, email address, @code{bug-gawk@@gnu.org} +Once you have a precise problem, send email to +@EMAIL{bug-gawk@@gnu.org,bug-gawk at gnu dot org}. + +@cindex Robbins, Arnold +Using this address automatically sends a copy of your +mail to me. If necessary, I can be reached directly at +@EMAIL{arnold@@skeeve.com,arnold at skeeve dot com}. +The bug reporting address is preferred since the +email list is archived at the GNU Project. +@emph{All email should be in English, since that is my native language.} + +@cindex @code{comp.lang.awk} newsgroup +@quotation CAUTION +Do @emph{not} try to report bugs in @command{gawk} by +posting to the Usenet/Internet newsgroup @code{comp.lang.awk}. +While the @command{gawk} developers do occasionally read this newsgroup, +there is no guarantee that we will see your posting. The steps described +above are the official recognized ways for reporting bugs. +Really. +@end quotation + +@quotation NOTE +Many distributions of GNU/Linux and the various BSD-based operating systems +have their own bug reporting systems. If you report a bug using your distribution's +bug reporting system, @emph{please} also send a copy to +@EMAIL{bug-gawk@@gnu.org,bug-gawk at gnu dot org}. + +This is for two reasons. First, while some distributions forward +bug reports ``upstream'' to the GNU mailing list, many don't, so there is a good +chance that the @command{gawk} maintainer won't even see the bug report! Second, +mail to the GNU list is archived, and having everything at the GNU project +keeps things self-contained and not dependant on other web sites. +@end quotation + +Non-bug suggestions are always welcome as well. If you have questions +about things that are unclear in the documentation or are just obscure +features, ask me; I will try to help you out, although I +may not have the time to fix the problem. You can send me electronic +mail at the Internet address noted previously. + +If you find bugs in one of the non-Unix ports of @command{gawk}, please send +an electronic mail message to the person who maintains that port. They +are named in the following list, as well as in the @file{README} file in the @command{gawk} +distribution. Information in the @file{README} file should be considered +authoritative if it conflicts with this @value{DOCUMENT}. + +The people maintaining the non-Unix ports of @command{gawk} are +as follows: + +@multitable {MS-Windows with MINGW} {123456789012345678901234567890123456789001234567890} +@cindex Deifik, Scott +@item MS-DOS with DJGPP @tab Scott Deifik, @EMAIL{scottd.mail@@sbcglobal.net,scottd dot mail at sbcglobal dot net}. + +@cindex Zaretskii, Eli +@item MS-Windows with MINGW @tab Eli Zaretskii, @EMAIL{eliz@@gnu.org,eliz at gnu dot org}. + +@cindex Buening, Andreas +@item OS/2 @tab Andreas Buening, @EMAIL{andreas.buening@@nexgo.de,andreas dot buening at nexgo dot de}. + +@cindex Rankin, Pat +@item VMS @tab Pat Rankin, @EMAIL{r.pat.rankin@@gmail.com,r.pat.rankin at gmail.com} + +@cindex Pitts, Dave +@item z/OS (OS/390) @tab Dave Pitts, @EMAIL{dpitts@@cozx.com,dpitts at cozx dot com}. +@end multitable + +If your bug is also reproducible under Unix, please send a copy of your +report to the @EMAIL{bug-gawk@@gnu.org,bug-gawk at gnu dot org} email list as well. +@c ENDOFRANGE dbugg +@c ENDOFRANGE tblgawb + +@node Other Versions +@appendixsec Other Freely Available @command{awk} Implementations +@c STARTOFRANGE awkim +@cindex @command{awk}, implementations +@ignore +From: emory!amc.com!brennan (Michael Brennan) +Subject: C++ comments in awk programs +To: arnold@gnu.ai.mit.edu (Arnold Robbins) +Date: Wed, 4 Sep 1996 08:11:48 -0700 (PDT) + +@end ignore +@cindex Brennan, Michael +@quotation +@i{It's kind of fun to put comments like this in your awk code.}@* +@ @ @ @ @ @ @code{// Do C++ comments work? answer: yes! of course}@* +Michael Brennan +@end quotation + +There are a number of other freely available @command{awk} implementations. +This @value{SECTION} briefly describes where to get them: + +@table @asis +@cindex Kernighan, Brian +@cindex source code, Brian Kernighan's @command{awk} +@cindex @command{awk}, versions of, See Also Brian Kernighan's @command{awk} +@cindex extensions, Brian Kernighan's @command{awk} +@cindex Brian Kernighan's @command{awk}, extensions +@item Unix @command{awk} +Brian Kernighan, one of the original designers of Unix @command{awk}, +has made his implementation of +@command{awk} freely available. +You can retrieve this version via the World Wide Web from +@uref{http://www.cs.princeton.edu/~bwk, his home page}. +It is available in several archive formats: + +@table @asis +@item Shell archive +@uref{http://www.cs.princeton.edu/~bwk/btl.mirror/awk.shar} + +@item Compressed @command{tar} file +@uref{http://www.cs.princeton.edu/~bwk/btl.mirror/awk.tar.gz} + +@item Zip file +@uref{http://www.cs.princeton.edu/~bwk/btl.mirror/awk.zip} +@end table + +This version requires an ISO C (1990 standard) compiler; +the C compiler from +GCC (the GNU Compiler Collection) +works quite nicely. + +@xref{Common Extensions}, +for a list of extensions in this @command{awk} that are not in POSIX @command{awk}. + +@cindex Brennan, Michael +@cindex @command{mawk} program +@cindex source code, @command{mawk} +@item @command{mawk} +Michael Brennan wrote an independent implementation of @command{awk}, +called @command{mawk}. It is available under the GPL +(@pxref{Copying}), +just as @command{gawk} is. + +The original distribution site for the @command{mawk} source code +no longer has it. A copy is available at +@uref{http://www.skeeve.com/gawk/mawk1.3.3.tar.gz}. + +In 2009, Thomas Dickey took on @command{mawk} maintenance. +Basic information is available on +@uref{http://www.invisible-island.net/mawk/mawk.html, the project's web page}. +The download URL is +@url{http://invisible-island.net/datafiles/release/mawk.tar.gz}. + +Once you have it, +@command{gunzip} may be used to decompress this file. Installation +is similar to @command{gawk}'s +(@pxref{Unix Installation}). + +@xref{Common Extensions}, +for a list of extensions in @command{mawk} that are not in POSIX @command{awk}. + +@cindex Sumner, Andrew +@cindex @command{awka} compiler for @command{awk} +@cindex source code, @command{awka} +@item @command{awka} +Written by Andrew Sumner, +@command{awka} translates @command{awk} programs into C, compiles them, +and links them with a library of functions that provides the core +@command{awk} functionality. +It also has a number of extensions. + +The @command{awk} translator is released under the GPL, and the library +is under the LGPL. + +To get @command{awka}, go to @url{http://sourceforge.net/projects/awka}. +@c You can reach Andrew Sumner at @email{andrew@@zbcom.net}. +@c andrewsumner@@yahoo.net + +The project seems to be frozen; no new code changes have been made +since approximately 2003. + +@cindex Beebe, Nelson +@cindex @command{pawk} (profiling version of Brian Kernighan's @command{awk}) +@cindex source code, @command{pawk} +@item @command{pawk} +Nelson H.F.@: Beebe at the University of Utah has modified +Brian Kernighan's @command{awk} to provide timing and profiling information. +It is different from @command{pgawk} +(@pxref{Profiling}), +in that it uses CPU-based profiling, not line-count +profiling. You may find it at either +@uref{ftp://ftp.math.utah.edu/pub/pawk/pawk-20030606.tar.gz} +or +@uref{http://www.math.utah.edu/pub/pawk/pawk-20030606.tar.gz}. + +@item Busybox Awk +@cindex Busybox Awk +@cindex source code, Busybox Awk +Busybox is a GPL-licensed program providing small versions of many +applications within a single executable. It is aimed at embedded systems. +It includes a full implementation of POSIX @command{awk}. When building +it, be careful not to do @samp{make install} as it will overwrite +copies of other applications in your @file{/usr/local/bin}. For more +information, see the @uref{http://busybox.net, project's home page}. + +@cindex OpenSolaris +@cindex Solaris, POSIX-compliant @command{awk} +@cindex source code, Solaris @command{awk} +@item The OpenSolaris POSIX @command{awk} +The version of @command{awk} in @file{/usr/xpg4/bin} on Solaris is +more-or-less +POSIX-compliant. It is based on the @command{awk} from Mortice Kern +Systems for PCs. The source code can be downloaded from +the @uref{http://www.opensolaris.org, OpenSolaris web site}. +This author was able to make it compile and work under GNU/Linux +with 1--2 hours of work. Making it more generally portable (using +GNU Autoconf and/or Automake) would take more work, and this +has not been done, at least to our knowledge. + +@cindex @command{jawk} +@cindex Java implementation of @command{awk} +@cindex source code, @command{jawk} +@item @command{jawk} +This is an interpreter for @command{awk} written in Java. It claims +to be a full interpreter, although because it uses Java facilities +for I/O and for regexp matching, the language it supports is different +from POSIX @command{awk}. More information is available on the +@uref{http://jawk.sourceforge.net, project's home page}. + +@item Libmawk +@cindex libmawk +@cindex source code, libmawk +This is an embeddable @command{awk} interpreter derived from +@command{mawk}. For more information see +@uref{http://repo.hu/projects/libmawk/}. + +@item @w{QSE Awk} +@cindex QSE Awk +@cindex source code, QSE Awk +This is an embeddable @command{awk} interpreter. For more information +see @uref{http://code.google.com/p/qse/} and @uref{http://awk.info/?tools/qse}. + +@item @command{QTawk} +@cindex QuikTrim Awk +@cindex source code, QuikTrim Awk +This is an independent implementation of @command{awk} distributed +under the GPL. It has a large number of extensions over standard +@command{awk} and may not be 100% syntactically compatible with it. +See @uref{http://www.quiktrim.org/QTawk.html} for more information, +including the manual and a download link. + +@item @command{xgawk} +@cindex @command{xgawk} +@cindex source code, @command{xgawk} +XML @command{gawk}. +This is a fork of the @command{gawk} 3.1.6 source base +to support processing XML files. It has a number of +interesting extensions which should one day be integrated +into the main @command{gawk} code base. +For more information, see +@uref{http://xmlgawk.sourceforge.net, the XMLgawk project web site}. + +@end table +@c ENDOFRANGE gligawk +@c ENDOFRANGE ingawk +@c ENDOFRANGE awkim + +@node Notes +@appendix Implementation Notes +@c STARTOFRANGE gawii +@cindex @command{gawk}, implementation issues +@c STARTOFRANGE impis +@cindex implementation issues, @command{gawk} + +This appendix contains information mainly of interest to implementers and +maintainers of @command{gawk}. Everything in it applies specifically to +@command{gawk} and not to other implementations. + +@menu +* Compatibility Mode:: How to disable certain @command{gawk} + extensions. +* Additions:: Making Additions To @command{gawk}. +* Dynamic Extensions:: Adding new built-in functions to + @command{gawk}. +* Future Extensions:: New features that may be implemented one day. +@end menu + +@node Compatibility Mode +@appendixsec Downward Compatibility and Debugging +@cindex @command{gawk}, implementation issues, downward compatibility +@cindex @command{gawk}, implementation issues, debugging +@cindex troubleshooting, @command{gawk} +@cindex implementation issues@comma{} @command{gawk}, debugging + +@xref{POSIX/GNU}, +for a summary of the GNU extensions to the @command{awk} language and program. +All of these features can be turned off by invoking @command{gawk} with the +@option{--traditional} option or with the @option{--posix} option. + +If @command{gawk} is compiled for debugging with @samp{-DDEBUG}, then there +is one more option available on the command line: + +@table @code +@item -Y +@itemx --parsedebug +Prints out the parse stack information as the program is being parsed. +@end table + +This option is intended only for serious @command{gawk} developers +and not for the casual user. It probably has not even been compiled into +your version of @command{gawk}, since it slows down execution. + +@node Additions +@appendixsec Making Additions to @command{gawk} + +If you find that you want to enhance @command{gawk} in a significant +fashion, you are perfectly free to do so. That is the point of having +free software; the source code is available and you are free to change +it as you want (@pxref{Copying}). + +This @value{SECTION} discusses the ways you might want to change @command{gawk} +as well as any considerations you should bear in mind. + +@menu +* Accessing The Source:: Accessing the Git repository. +* Adding Code:: Adding code to the main body of + @command{gawk}. +* New Ports:: Porting @command{gawk} to a new operating + system. +@end menu + +@node Accessing The Source +@appendixsubsec Accessing The @command{gawk} Git Repository + +As @command{gawk} is Free Software, the source code is always available. +@ref{Gawk Distribution}, describes how to get and build the formal, +released versions of @command{gawk}. + +However, if you want to modify @command{gawk} and contribute back your +changes, you will probably wish to work with the development version. +To do so, you will need to access the @command{gawk} source code +repository. The code is maintained using the +@uref{http://git-scm.com/, Git distributed version control system}. +You will need to install it if your system doesn't have it. +Once you have done so, use the command: + +@example +git clone git://git.savannah.gnu.org/gawk.git +@end example + +@noindent +This will clone the @command{gawk} repository. If you are behind a +firewall that will not allow you to use the Git native protocol, you +can still access the repository using: + +@example +git clone http://git.savannah.gnu.org/r/gawk.git +@end example + +Once you have made changes, you can use @samp{git diff} to produce a +patch, and send that to the @command{gawk} maintainer; see @ref{Bugs} +for how to do that. + +Finally, if you cannot install Git (e.g., if it hasn't been ported +yet to your operating system), you can use the Git--CVS gateway +to check out a copy using CVS, as follows: + +@example +cvs -d:pserver:anonymous@@pserver.git.sv.gnu.org:/gawk.git co -d gawk master +@end example + +@node Adding Code +@appendixsubsec Adding New Features + +@c STARTOFRANGE adfgaw +@cindex adding, features to @command{gawk} +@c STARTOFRANGE fadgaw +@cindex features, adding to @command{gawk} +@c STARTOFRANGE gawadf +@cindex @command{gawk}, features, adding +You are free to add any new features you like to @command{gawk}. +However, if you want your changes to be incorporated into the @command{gawk} +distribution, there are several steps that you need to take in order to +make it possible to include your changes: + +@enumerate 1 +@item +Before building the new feature into @command{gawk} itself, +consider writing it as an extension module +(@pxref{Dynamic Extensions}). +If that's not possible, continue with the rest of the steps in this list. + +@item +Be prepared to sign the appropriate paperwork. +In order for the FSF to distribute your changes, you must either place +those changes in the public domain and submit a signed statement to that +effect, or assign the copyright in your changes to the FSF. +Both of these actions are easy to do and @emph{many} people have done so +already. If you have questions, please contact me +(@pxref{Bugs}), +or @EMAIL{assign@@gnu.org,assign at gnu dot org}. + +@item +Get the latest version. +It is much easier for me to integrate changes if they are relative to +the most recent distributed version of @command{gawk}. If your version of +@command{gawk} is very old, I may not be able to integrate them at all. +(@xref{Getting}, +for information on getting the latest version of @command{gawk}.) + +@item +@ifnotinfo +Follow the @cite{GNU Coding Standards}. +@end ifnotinfo +@ifinfo +See @inforef{Top, , Version, standards, GNU Coding Standards}. +@end ifinfo +This document describes how GNU software should be written. If you haven't +read it, please do so, preferably @emph{before} starting to modify @command{gawk}. +(The @cite{GNU Coding Standards} are available from +the GNU Project's +@uref{http://www.gnu.org/prep/standards_toc.html, web site}. +Texinfo, Info, and DVI versions are also available.) + +@cindex @command{gawk}, coding style in +@item +Use the @command{gawk} coding style. +The C code for @command{gawk} follows the instructions in the +@cite{GNU Coding Standards}, with minor exceptions. The code is formatted +using the traditional ``K&R'' style, particularly as regards to the placement +of braces and the use of TABs. In brief, the coding rules for @command{gawk} +are as follows: + +@itemize @bullet +@item +Use ANSI/ISO style (prototype) function headers when defining functions. + +@item +Put the name of the function at the beginning of its own line. + +@item +Put the return type of the function, even if it is @code{int}, on the +line above the line with the name and arguments of the function. + +@item +Put spaces around parentheses used in control structures +(@code{if}, @code{while}, @code{for}, @code{do}, @code{switch}, +and @code{return}). + +@item +Do not put spaces in front of parentheses used in function calls. + +@item +Put spaces around all C operators and after commas in function calls. + +@item +Do not use the comma operator to produce multiple side effects, except +in @code{for} loop initialization and increment parts, and in macro bodies. + +@item +Use real TABs for indenting, not spaces. + +@item +Use the ``K&R'' brace layout style. + +@item +Use comparisons against @code{NULL} and @code{'\0'} in the conditions of +@code{if}, @code{while}, and @code{for} statements, as well as in the @code{case}s +of @code{switch} statements, instead of just the +plain pointer or character value. + +@item +Use the @code{TRUE}, @code{FALSE} and @code{NULL} symbolic constants +and the character constant @code{'\0'} where appropriate, instead of @code{1} +and @code{0}. + +@item +Provide one-line descriptive comments for each function. + +@item +Do not use the @code{alloca()} function for allocating memory off the +stack. Its use causes more portability trouble than is worth the minor +benefit of not having to free the storage. Instead, use @code{malloc()} +and @code{free()}. + +@item +Do not use comparisons of the form @samp{! strcmp(a, b)} or similar. +As Henry Spencer once said, ``@code{strcmp()} is not a boolean!'' +Instead, use @samp{strcmp(a, b) == 0}. + +@item +If adding new bit flag values, use explicit hexadecimal constants +(@code{0x001}, @code{0x002}, @code{0x004}, and son on) instead of +shifting one left by successive amounts (@samp{(1<<0)}, @samp{(1<<1)}, +and so on). +@end itemize + +@quotation NOTE +If I have to reformat your code to follow the coding style used in +@command{gawk}, I may not bother to integrate your changes at all. +@end quotation + +@cindex Texinfo +@item +Update the documentation. +Along with your new code, please supply new sections and/or chapters +for this @value{DOCUMENT}. If at all possible, please use real +Texinfo, instead of just supplying unformatted ASCII text (although +even that is better than no documentation at all). +Conventions to be followed in @cite{@value{TITLE}} are provided +after the @samp{@@bye} at the end of the Texinfo source file. +If possible, please update the @command{man} page as well. + +You will also have to sign paperwork for your documentation changes. + +@item +Submit changes as unified diffs. +Use @samp{diff -u -r -N} to compare +the original @command{gawk} source tree with your version. +I recommend using the GNU version of @command{diff}. +Send the output produced by either run of @command{diff} to me when you +submit your changes. +(@xref{Bugs}, for the electronic mail +information.) + +Using this format makes it easy for me to apply your changes to the +master version of the @command{gawk} source code (using @code{patch}). +If I have to apply the changes manually, using a text editor, I may +not do so, particularly if there are lots of changes. + +@item +Include an entry for the @file{ChangeLog} file with your submission. +This helps further minimize the amount of work I have to do, +making it easier for me to accept patches. +@end enumerate + +Although this sounds like a lot of work, please remember that while you +may write the new code, I have to maintain it and support it. If it +isn't possible for me to do that with a minimum of extra work, then I +probably will not. +@c ENDOFRANGE adfgaw +@c ENDOFRANGE gawadf +@c ENDOFRANGE fadgaw + +@node New Ports +@appendixsubsec Porting @command{gawk} to a New Operating System +@cindex portability, @command{gawk} +@cindex operating systems, porting @command{gawk} to + +@cindex porting @command{gawk} +If you want to port @command{gawk} to a new operating system, there are +several steps: + +@enumerate 1 +@item +Follow the guidelines in +@ifinfo +@ref{Adding Code}, +@end ifinfo +@ifnotinfo +the previous @value{SECTION} +@end ifnotinfo +concerning coding style, submission of diffs, and so on. + +@item +Be prepared to sign the appropriate paperwork. +In order for the FSF to distribute your code, you must either place +your code in the public domain and submit a signed statement to that +effect, or assign the copyright in your code to the FSF. +@ifinfo +Both of these actions are easy to do and @emph{many} people have done so +already. If you have questions, please contact me, or +@email{gnu@@gnu.org}. +@end ifinfo + +@item +When doing a port, bear in mind that your code must coexist peacefully +with the rest of @command{gawk} and the other ports. Avoid gratuitous +changes to the system-independent parts of the code. If at all possible, +avoid sprinkling @samp{#ifdef}s just for your port throughout the +code. + +If the changes needed for a particular system affect too much of the +code, I probably will not accept them. In such a case, you can, of course, +distribute your changes on your own, as long as you comply +with the GPL +(@pxref{Copying}). + +@item +A number of the files that come with @command{gawk} are maintained by other +people. Thus, you should not change them +unless it is for a very good reason; i.e., changes are not out of the +question, but changes to these files are scrutinized extra carefully. +The files are @file{dfa.c}, @file{dfa.h}, @file{getopt1.c}, @file{getopt.c}, +@file{getopt.h}, @file{install-sh}, @file{mkinstalldirs}, @file{regcomp.c}, +@file{regex.c}, @file{regexec.c}, @file{regexex.c}, @file{regex.h}, +@file{regex_internal.c}, and @file{regex_internal.h}. + +@item +Be willing to continue to maintain the port. +Non-Unix operating systems are supported by volunteers who maintain +the code needed to compile and run @command{gawk} on their systems. If noone +volunteers to maintain a port, it becomes unsupported and it may +be necessary to remove it from the distribution. + +@item +Supply an appropriate @file{gawkmisc.???} file. +Each port has its own @file{gawkmisc.???} that implements certain +operating system specific functions. This is cleaner than a plethora of +@samp{#ifdef}s scattered throughout the code. The @file{gawkmisc.c} in +the main source directory includes the appropriate +@file{gawkmisc.???} file from each subdirectory. +Be sure to update it as well. + +Each port's @file{gawkmisc.???} file has a suffix reminiscent of the machine +or operating system for the port---for example, @file{pc/gawkmisc.pc} and +@file{vms/gawkmisc.vms}. The use of separate suffixes, instead of plain +@file{gawkmisc.c}, makes it possible to move files from a port's subdirectory +into the main subdirectory, without accidentally destroying the real +@file{gawkmisc.c} file. (Currently, this is only an issue for the +PC operating system ports.) + +@item +Supply a @file{Makefile} as well as any other C source and header files that are +necessary for your operating system. All your code should be in a +separate subdirectory, with a name that is the same as, or reminiscent +of, either your operating system or the computer system. If possible, +try to structure things so that it is not necessary to move files out +of the subdirectory into the main source directory. If that is not +possible, then be sure to avoid using names for your files that +duplicate the names of files in the main source directory. + +@item +Update the documentation. +Please write a section (or sections) for this @value{DOCUMENT} describing the +installation and compilation steps needed to compile and/or install +@command{gawk} for your system. +@end enumerate + +Following these steps makes it much easier to integrate your changes +into @command{gawk} and have them coexist happily with other +operating systems' code that is already there. + +In the code that you supply and maintain, feel free to use a +coding style and brace layout that suits your taste. + +@node Dynamic Extensions +@appendixsec Adding New Built-in Functions to @command{gawk} +@cindex Robinson, Will +@cindex robot, the +@cindex Lost In Space +@quotation +@i{Danger Will Robinson! Danger!!@* +Warning! Warning!}@* +The Robot +@end quotation + +@c STARTOFRANGE gladfgaw +@cindex @command{gawk}, functions, adding +@c STARTOFRANGE adfugaw +@cindex adding, functions to @command{gawk} +@c STARTOFRANGE fubadgaw +@cindex functions, built-in, adding to @command{gawk} +It is possible to add new built-in +functions to @command{gawk} using dynamically loaded libraries. This +facility is available on systems (such as GNU/Linux) that support +the C @code{dlopen()} and @code{dlsym()} functions. +This @value{SECTION} describes how to write and use dynamically +loaded extensions for @command{gawk}. +Experience with programming in +C or C++ is necessary when reading this @value{SECTION}. + +@quotation CAUTION +The facilities described in this @value{SECTION} +are very much subject to change in a future @command{gawk} release. +Be aware that you may have to re-do everything, +at some future time. + +If you have written your own dynamic extensions, +be sure to recompile them for each new @command{gawk} release. +There is no guarantee of binary compatibility between different +releases, nor will there ever be such a guarantee. +@end quotation + +@quotation NOTE +When @option{--sandbox} is specified, extensions are disabled +(@pxref{Options}. +@end quotation + +@menu +* Internals:: A brief look at some @command{gawk} internals. +* Plugin License:: A note about licensing. +* Sample Library:: A example of new functions. +@end menu + +@node Internals +@appendixsubsec A Minimal Introduction to @command{gawk} Internals +@c STARTOFRANGE gawint +@cindex @command{gawk}, internals + +The truth is that @command{gawk} was not designed for simple extensibility. +The facilities for adding functions using shared libraries work, but +are something of a ``bag on the side.'' Thus, this tour is +brief and simplistic; would-be @command{gawk} hackers are encouraged to +spend some time reading the source code before trying to write +extensions based on the material presented here. Of particular note +are the files @file{awk.h}, @file{builtin.c}, and @file{eval.c}. +Reading @file{awkgram.y} in order to see how the parse tree is built +would also be of use. + +@cindex @code{awk.h} file (internal) +With the disclaimers out of the way, the following types, structure +members, functions, and macros are declared in @file{awk.h} and are of +use when writing extensions. The next @value{SECTION} +shows how they are used: + +@table @code +@cindex floating-point, numbers, @code{AWKNUM} internal type +@cindex numbers, floating-point, @code{AWKNUM} internal type +@cindex @code{AWKNUM} internal type +@cindex internal type, @code{AWKNUM} +@item AWKNUM +An @code{AWKNUM} is the internal type of @command{awk} +floating-point numbers. Typically, it is a C @code{double}. + +@cindex @code{NODE} internal type +@cindex internal type, @code{NODE} +@cindex strings, @code{NODE} internal type +@cindex numbers, @code{NODE} internal type +@item NODE +Just about everything is done using objects of type @code{NODE}. +These contain both strings and numbers, as well as variables and arrays. + +@cindex @code{force_number()} internal function +@cindex internal function, @code{force_number()} +@cindex numeric, values +@item AWKNUM force_number(NODE *n) +This macro forces a value to be numeric. It returns the actual +numeric value contained in the node. +It may end up calling an internal @command{gawk} function. + +@cindex @code{force_string()} internal function +@cindex internal function, @code{force_string()} +@item void force_string(NODE *n) +This macro guarantees that a @code{NODE}'s string value is current. +It may end up calling an internal @command{gawk} function. +It also guarantees that the string is zero-terminated. + +@cindex @code{force_wstring()} internal function +@cindex internal function, @code{force_wstring()} +@item void force_wstring(NODE *n) +Similarly, this +macro guarantees that a @code{NODE}'s wide-string value is current. +It may end up calling an internal @command{gawk} function. +It also guarantees that the wide string is zero-terminated. + +@cindex @code{get_curfunc_arg_count()} internal function +@cindex internal function, @code{get_curfunc_arg_count()} +@item size_t get_curfunc_arg_count(void) +This function returns the actual number of parameters passed +to the current function. Inside the code of an extension +this can be used to determine the maximum index which is +safe to use with @code{get_actual_argument}. If this value is +greater than @code{nargs}, the function was +called incorrectly from the @command{awk} program. + +@cindex parameters@comma{} number of +@cindex @code{nargs} internal variable +@cindex internal variable, @code{nargs} +@item nargs +Inside an extension function, this is the maximum number of +expected parameters, as set by the @code{make_builtin()} function. + +@cindex @code{stptr} internal variable +@cindex internal variable, @code{stptr} +@cindex @code{stlen} internal variable +@cindex internal variable, @code{stlen} +@item n->stptr +@itemx n->stlen +The data and length of a @code{NODE}'s string value, respectively. +The string is @emph{not} guaranteed to be zero-terminated. +If you need to pass the string value to a C library function, save +the value in @code{n->stptr[n->stlen]}, assign @code{'\0'} to it, +call the routine, and then restore the value. + +@cindex @code{wstptr} internal variable +@cindex internal variable, @code{wstptr} +@cindex @code{wstlen} internal variable +@cindex internal variable, @code{wstlen} +@item n->wstptr +@itemx n->wstlen +The data and length of a @code{NODE}'s wide-string value, respectively. +Use @code{force_wstring()} to make sure these values are current. + +@cindex @code{type} internal variable +@cindex internal variable, @code{type} +@item n->type +The type of the @code{NODE}. This is a C @code{enum}. Values should +be one of @code{Node_var}, @code{Node_var_new}, or @code{Node_var_array} +for function parameters. + +@cindex @code{vname} internal variable +@cindex internal variable, @code{vname} +@item n->vname +The ``variable name'' of a node. This is not of much use inside +externally written extensions. + +@cindex arrays, associative, clearing +@cindex @code{assoc_clear()} internal function +@cindex internal function, @code{assoc_clear()} +@item void assoc_clear(NODE *n) +Clears the associative array pointed to by @code{n}. +Make sure that @samp{n->type == Node_var_array} first. + +@cindex arrays, elements, installing +@cindex @code{assoc_lookup()} internal function +@cindex internal function, @code{assoc_lookup()} +@item NODE **assoc_lookup(NODE *symbol, NODE *subs, int reference) +Finds, and installs if necessary, array elements. +@code{symbol} is the array, @code{subs} is the subscript. +This is usually a value created with @code{make_string()} (see below). +@code{reference} should be @code{TRUE} if it is an error to use the +value before it is created. Typically, @code{FALSE} is the +correct value to use from extension functions. + +@cindex strings +@cindex @code{make_string()} internal function +@cindex internal function, @code{make_string()} +@item NODE *make_string(char *s, size_t len) +Take a C string and turn it into a pointer to a @code{NODE} that +can be stored appropriately. This is permanent storage; understanding +of @command{gawk} memory management is helpful. + +@cindex numbers +@cindex @code{make_number()} internal function +@cindex internal function, @code{make_number()} +@item NODE *make_number(AWKNUM val) +Take an @code{AWKNUM} and turn it into a pointer to a @code{NODE} that +can be stored appropriately. This is permanent storage; understanding +of @command{gawk} memory management is helpful. + + +@cindex nodes@comma{} duplicating +@cindex @code{dupnode()} internal function +@cindex internal function, @code{dupnode()} +@item NODE *dupnode(NODE *n) +Duplicate a node. In most cases, this increments an internal +reference count instead of actually duplicating the entire @code{NODE}; +understanding of @command{gawk} memory management is helpful. + +@cindex memory, releasing +@cindex @code{unref()} internal function +@cindex internal function, @code{unref()} +@item void unref(NODE *n) +This macro releases the memory associated with a @code{NODE} +allocated with @code{make_string()} or @code{make_number()}. +Understanding of @command{gawk} memory management is helpful. + +@cindex @code{make_builtin()} internal function +@cindex internal function, @code{make_builtin()} +@item void make_builtin(const char *name, NODE *(*func)(NODE *), int count) +Register a C function pointed to by @code{func} as new built-in +function @code{name}. @code{name} is a regular C string. @code{count} +is the maximum number of arguments that the function takes. +The function should be written in the following manner: + +@example +/* do_xxx --- do xxx function for gawk */ + +NODE * +do_xxx(int nargs) +@{ + @dots{} +@} +@end example + +@cindex arguments, retrieving +@cindex @code{get_argument()} internal function +@cindex internal function, @code{get_argument()} +@item NODE *get_argument(int i) +This function is called from within a C extension function to get +the @code{i}-th argument from the function call. +The first argument is argument zero. + +@cindex @code{get_actual_argument()} internal function +@cindex internal function, @code{get_actual_argument()} +@item NODE *get_actual_argument(int i, +@itemx @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ int@ optional,@ int@ wantarray); +This function retrieves a particular argument @code{i}. @code{wantarray} is @code{TRUE} +if the argument should be an array, @code{FALSE} otherwise. If @code{optional} is +@code{TRUE}, the argument need not have been supplied. If it wasn't, the return +value is @code{NULL}. It is a fatal error if @code{optional} is @code{TRUE} but +the argument was not provided. + +@cindex @code{get_scalar_argument()} internal macro +@cindex internal macro, @code{get_scalar_argument()} +@item get_scalar_argument(i, opt) +This is a convenience macro that calls @code{get_actual_argument()}. + +@cindex @code{get_array_argument()} internal macro +@cindex internal macro, @code{get_array_argument()} +@item get_array_argument(i, opt) +This is a convenience macro that calls @code{get_actual_argument()}. + +@cindex functions, return values@comma{} setting + +@cindex @code{ERRNO} variable +@cindex @code{update_ERRNO()} internal function +@cindex internal function, @code{update_ERRNO()} +@item void update_ERRNO(void) +This function is called from within a C extension function to set +the value of @command{gawk}'s @code{ERRNO} variable, based on the current +value of the C @code{errno} global variable. +It is provided as a convenience. + +@cindex @code{ERRNO} variable +@cindex @code{update_ERRNO_saved()} internal function +@cindex internal function, @code{update_ERRNO_saved()} +@item void update_ERRNO_saved(int errno_saved) +This function is called from within a C extension function to set +the value of @command{gawk}'s @code{ERRNO} variable, based on the error +value provided as the argument. +It is provided as a convenience. + +@cindex @code{ENVIRON} array +@cindex @code{PROCINFO} array +@cindex @code{register_deferred_variable()} internal function +@cindex internal function, @code{register_deferred_variable()} +@item void register_deferred_variable(const char *name, NODE *(*load_func)(void)) +This function is called to register a function to be called when a +reference to an undefined variable with the given name is encountered. +The callback function will never be called if the variable exists already, +so, unless the calling code is running at program startup, it should first +check whether a variable of the given name already exists. +The argument function must return a pointer to a @code{NODE} containing the +newly created variable. This function is used to implement the builtin +@code{ENVIRON} and @code{PROCINFO} arrays, so you can refer to them +for examples. + +@cindex @code{IOBUF} internal structure +@cindex internal structure, @code{IOBUF} +@cindex @code{iop_alloc()} internal function +@cindex internal function, @code{iop_alloc()} +@cindex @code{get_record()} input method +@cindex @code{close_func}() input method +@cindex @code{INVALID_HANDLE} internal constant +@cindex internal constant, @code{INVALID_HANDLE} +@cindex XML (eXtensible Markup Language) +@cindex eXtensible Markup Language (XML) +@cindex @code{register_open_hook()} internal function +@cindex internal function, @code{register_open_hook()} +@item void register_open_hook(void *(*open_func)(IOBUF *)) +This function is called to register a function to be called whenever +a new data file is opened, leading to the creation of an @code{IOBUF} +structure in @code{iop_alloc()}. After creating the new @code{IOBUF}, +@code{iop_alloc()} will call (in reverse order of registration, so the last +function registered is called first) each open hook until one returns +non-@code{NULL}. If any hook returns a non-@code{NULL} value, that value is assigned +to the @code{IOBUF}'s @code{opaque} field (which will presumably point +to a structure containing additional state associated with the input +processing), and no further open hooks are called. + +The function called will most likely want to set the @code{IOBUF}'s +@code{get_record} method to indicate that future input records should +be retrieved by calling that method instead of using the standard +@command{gawk} input processing. + +And the function will also probably want to set the @code{IOBUF}'s +@code{close_func} method to be called when the file is closed to clean +up any state associated with the input. + +Finally, hook functions should be prepared to receive an @code{IOBUF} +structure where the @code{fd} field is set to @code{INVALID_HANDLE}, +meaning that @command{gawk} was not able to open the file itself. In +this case, the hook function must be able to successfully open the file +and place a valid file descriptor there. + +Currently, for example, the hook function facility is used to implement +the XML parser shared library extension. For more info, please look in +@file{awk.h} and in @file{io.c}. +@end table + +An argument that is supposed to be an array needs to be handled with +some extra code, in case the array being passed in is actually +from a function parameter. + +The following boilerplate code shows how to do this: + +@example +NODE *the_arg; + +/* assume need 3rd arg, 0-based */ +the_arg = get_array_argument(2, FALSE); +@end example + +Again, you should spend time studying the @command{gawk} internals; +don't just blindly copy this code. +@c ENDOFRANGE gawint + +@node Plugin License +@appendixsubsec Extension Licensing + +Every dynamic extension should define the global symbol +@code{plugin_is_GPL_compatible} to assert that it has been licensed under +a GPL-compatible license. If this symbol does not exist, @command{gawk} +will emit a fatal error and exit. + +The declared type of the symbol should be @code{int}. It does not need +to be in any allocated section, though. The code merely asserts that +the symbol exists in the global scope. Something like this is enough: + +@example +int plugin_is_GPL_compatible; +@end example + +@node Sample Library +@appendixsubsec Example: Directory and File Operation Built-ins +@c STARTOFRANGE chdirg +@cindex @code{chdir()} function@comma{} implementing in @command{gawk} +@c STARTOFRANGE statg +@cindex @code{stat()} function@comma{} implementing in @command{gawk} +@c STARTOFRANGE filre +@cindex files, information about@comma{} retrieving +@c STARTOFRANGE dirch +@cindex directories, changing + +Two useful functions that are not in @command{awk} are @code{chdir()} +(so that an @command{awk} program can change its directory) and +@code{stat()} (so that an @command{awk} program can gather information about +a file). +This @value{SECTION} implements these functions for @command{gawk} in an +external extension library. + +@menu +* Internal File Description:: What the new functions will do. +* Internal File Ops:: The code for internal file operations. +* Using Internal File Ops:: How to use an external extension. +@end menu + +@node Internal File Description +@appendixsubsubsec Using @code{chdir()} and @code{stat()} + +This @value{SECTION} shows how to use the new functions at the @command{awk} +level once they've been integrated into the running @command{gawk} +interpreter. +Using @code{chdir()} is very straightforward. It takes one argument, +the new directory to change to: + +@example +@dots{} +newdir = "/home/arnold/funstuff" +ret = chdir(newdir) +if (ret < 0) @{ + printf("could not change to %s: %s\n", + newdir, ERRNO) > "/dev/stderr" + exit 1 +@} +@dots{} +@end example + +The return value is negative if the @code{chdir} failed, +and @code{ERRNO} +(@pxref{Built-in Variables}) +is set to a string indicating the error. + +Using @code{stat()} is a bit more complicated. +The C @code{stat()} function fills in a structure that has a fair +amount of information. +The right way to model this in @command{awk} is to fill in an associative +array with the appropriate information: + +@c broke printf for page breaking +@example +file = "/home/arnold/.profile" +fdata[1] = "x" # force `fdata' to be an array +ret = stat(file, fdata) +if (ret < 0) @{ + printf("could not stat %s: %s\n", + file, ERRNO) > "/dev/stderr" + exit 1 +@} +printf("size of %s is %d bytes\n", file, fdata["size"]) +@end example + +The @code{stat()} function always clears the data array, even if +the @code{stat()} fails. It fills in the following elements: + +@table @code +@item "name" +The name of the file that was @code{stat()}'ed. + +@item "dev" +@itemx "ino" +The file's device and inode numbers, respectively. + +@item "mode" +The file's mode, as a numeric value. This includes both the file's +type and its permissions. + +@item "nlink" +The number of hard links (directory entries) the file has. + +@item "uid" +@itemx "gid" +The numeric user and group ID numbers of the file's owner. + +@item "size" +The size in bytes of the file. + +@item "blocks" +The number of disk blocks the file actually occupies. This may not +be a function of the file's size if the file has holes. + +@item "atime" +@itemx "mtime" +@itemx "ctime" +The file's last access, modification, and inode update times, +respectively. These are numeric timestamps, suitable for formatting +with @code{strftime()} +(@pxref{Built-in}). + +@item "pmode" +The file's ``printable mode.'' This is a string representation of +the file's type and permissions, such as what is produced by +@samp{ls -l}---for example, @code{"drwxr-xr-x"}. + +@item "type" +A printable string representation of the file's type. The value +is one of the following: + +@table @code +@item "blockdev" +@itemx "chardev" +The file is a block or character device (``special file''). + +@ignore +@item "door" +The file is a Solaris ``door'' (special file used for +interprocess communications). +@end ignore + +@item "directory" +The file is a directory. + +@item "fifo" +The file is a named-pipe (also known as a FIFO). + +@item "file" +The file is just a regular file. + +@item "socket" +The file is an @code{AF_UNIX} (``Unix domain'') socket in the +filesystem. + +@item "symlink" +The file is a symbolic link. +@end table +@end table + +Several additional elements may be present depending upon the operating +system and the type of the file. You can test for them in your @command{awk} +program by using the @code{in} operator +(@pxref{Reference to Elements}): + +@table @code +@item "blksize" +The preferred block size for I/O to the file. This field is not +present on all POSIX-like systems in the C @code{stat} structure. + +@item "linkval" +If the file is a symbolic link, this element is the name of the +file the link points to (i.e., the value of the link). + +@item "rdev" +@itemx "major" +@itemx "minor" +If the file is a block or character device file, then these values +represent the numeric device number and the major and minor components +of that number, respectively. +@end table + +@node Internal File Ops +@appendixsubsubsec C Code for @code{chdir()} and @code{stat()} + +Here is the C code for these extensions. They were written for +GNU/Linux. The code needs some more work for complete portability +to other POSIX-compliant systems:@footnote{This version is edited +slightly for presentation. See +@file{extension/filefuncs.c} in the @command{gawk} distribution +for the complete version.} + +@c break line for page breaking +@example +#include "awk.h" + +#include + +int plugin_is_GPL_compatible; + +/* do_chdir --- provide dynamically loaded chdir() builtin for gawk */ + +static NODE * +do_chdir(int nargs) +@{ + NODE *newdir; + int ret = -1; + + if (do_lint && get_curfunc_arg_count() != 1) + lintwarn("chdir: called with incorrect number of arguments"); + + newdir = get_scalar_argument(0, FALSE); +@end example + +The file includes the @code{"awk.h"} header file for definitions +for the @command{gawk} internals. It includes @code{} +for access to the @code{major()} and @code{minor}() macros. + +@cindex programming conventions, @command{gawk} internals +By convention, for an @command{awk} function @code{foo}, the function that +implements it is called @samp{do_foo}. The function should take +a @samp{int} argument, usually called @code{nargs}, that +represents the number of defined arguments for the function. The @code{newdir} +variable represents the new directory to change to, retrieved +with @code{get_scalar_argument()}. Note that the first argument is +numbered zero. + +This code actually accomplishes the @code{chdir()}. It first forces +the argument to be a string and passes the string value to the +@code{chdir()} system call. If the @code{chdir()} fails, @code{ERRNO} +is updated. + +@example + (void) force_string(newdir); + ret = chdir(newdir->stptr); + if (ret < 0) + update_ERRNO(); +@end example + +Finally, the function returns the return value to the @command{awk} level: + +@example + return make_number((AWKNUM) ret); +@} +@end example + +The @code{stat()} built-in is more involved. First comes a function +that turns a numeric mode into a printable representation +(e.g., 644 becomes @samp{-rw-r--r--}). This is omitted here for brevity: + +@c break line for page breaking +@example +/* format_mode --- turn a stat mode field into something readable */ + +static char * +format_mode(unsigned long fmode) +@{ + @dots{} +@} +@end example + +Next comes the @code{do_stat()} function. It starts with +variable declarations and argument checking: + +@ignore +Changed message for page breaking. Used to be: + "stat: called with incorrect number of arguments (%d), should be 2", +@end ignore +@example +/* do_stat --- provide a stat() function for gawk */ + +static NODE * +do_stat(int nargs) +@{ + NODE *file, *array, *tmp; + struct stat sbuf; + int ret; + NODE **aptr; + char *pmode; /* printable mode */ + char *type = "unknown"; + + if (do_lint && get_curfunc_arg_count() > 2) + lintwarn("stat: called with too many arguments"); +@end example + +Then comes the actual work. First, the function gets the arguments. +Then, it always clears the array. +The code use @code{lstat()} (instead of @code{stat()}) +to get the file information, +in case the file is a symbolic link. +If there's an error, it sets @code{ERRNO} and returns: + +@c comment made multiline for page breaking +@example + /* file is first arg, array to hold results is second */ + file = get_scalar_argument(0, FALSE); + array = get_array_argument(1, FALSE); + + /* empty out the array */ + assoc_clear(array); + + /* lstat the file, if error, set ERRNO and return */ + (void) force_string(file); + ret = lstat(file->stptr, & sbuf); + if (ret < 0) @{ + update_ERRNO(); + return make_number((AWKNUM) ret); + @} +@end example + +Now comes the tedious part: filling in the array. Only a few of the +calls are shown here, since they all follow the same pattern: + +@example + /* fill in the array */ + aptr = assoc_lookup(array, tmp = make_string("name", 4), FALSE); + *aptr = dupnode(file); + unref(tmp); + + aptr = assoc_lookup(array, tmp = make_string("mode", 4), FALSE); + *aptr = make_number((AWKNUM) sbuf.st_mode); + unref(tmp); + + aptr = assoc_lookup(array, tmp = make_string("pmode", 5), FALSE); + pmode = format_mode(sbuf.st_mode); + *aptr = make_string(pmode, strlen(pmode)); + unref(tmp); +@end example + +When done, return the @code{lstat()} return value: + +@example + + return make_number((AWKNUM) ret); +@} +@end example + +@cindex programming conventions, @command{gawk} internals +Finally, it's necessary to provide the ``glue'' that loads the +new function(s) into @command{gawk}. By convention, each library has +a routine named @code{dlload()} that does the job: + +@example +/* dlload --- load new builtins in this library */ + +NODE * +dlload(NODE *tree, void *dl) +@{ + make_builtin("chdir", do_chdir, 1); + make_builtin("stat", do_stat, 2); + return make_number((AWKNUM) 0); +@} +@end example + +And that's it! As an exercise, consider adding functions to +implement system calls such as @code{chown()}, @code{chmod()}, +and @code{umask()}. + +@node Using Internal File Ops +@appendixsubsubsec Integrating the Extensions + +@cindex @command{gawk}, interpreter@comma{} adding code to +Now that the code is written, it must be possible to add it at +runtime to the running @command{gawk} interpreter. First, the +code must be compiled. Assuming that the functions are in +a file named @file{filefuncs.c}, and @var{idir} is the location +of the @command{gawk} include files, +the following steps create +a GNU/Linux shared library: + +@example +$ @kbd{gcc -fPIC -shared -DHAVE_CONFIG_H -c -O -g -I@var{idir} filefuncs.c} +$ @kbd{ld -o filefuncs.so -shared filefuncs.o} +@end example + +@cindex @code{extension()} function (@command{gawk}) +Once the library exists, it is loaded by calling the @code{extension()} +built-in function. +This function takes two arguments: the name of the +library to load and the name of a function to call when the library +is first loaded. This function adds the new functions to @command{gawk}. +It returns the value returned by the initialization function +within the shared library: + +@example +# file testff.awk +BEGIN @{ + extension("./filefuncs.so", "dlload") + + chdir(".") # no-op + + data[1] = 1 # force `data' to be an array + print "Info for testff.awk" + ret = stat("testff.awk", data) + print "ret =", ret + for (i in data) + printf "data[\"%s\"] = %s\n", i, data[i] + print "testff.awk modified:", + strftime("%m %d %y %H:%M:%S", data["mtime"]) + + print "\nInfo for JUNK" + ret = stat("JUNK", data) + print "ret =", ret + for (i in data) + printf "data[\"%s\"] = %s\n", i, data[i] + print "JUNK modified:", strftime("%m %d %y %H:%M:%S", data["mtime"]) +@} +@end example + +Here are the results of running the program: + +@example +$ @kbd{gawk -f testff.awk} +@print{} Info for testff.awk +@print{} ret = 0 +@print{} data["size"] = 607 +@print{} data["ino"] = 14945891 +@print{} data["name"] = testff.awk +@print{} data["pmode"] = -rw-rw-r-- +@print{} data["nlink"] = 1 +@print{} data["atime"] = 1293993369 +@print{} data["mtime"] = 1288520752 +@print{} data["mode"] = 33204 +@print{} data["blksize"] = 4096 +@print{} data["dev"] = 2054 +@print{} data["type"] = file +@print{} data["gid"] = 500 +@print{} data["uid"] = 500 +@print{} data["blocks"] = 8 +@print{} data["ctime"] = 1290113572 +@print{} testff.awk modified: 10 31 10 12:25:52 +@print{} +@print{} Info for JUNK +@print{} ret = -1 +@print{} JUNK modified: 01 01 70 02:00:00 +@end example +@c ENDOFRANGE filre +@c ENDOFRANGE dirch +@c ENDOFRANGE statg +@c ENDOFRANGE chdirg +@c ENDOFRANGE gladfgaw +@c ENDOFRANGE adfugaw +@c ENDOFRANGE fubadgaw + +@node Future Extensions +@appendixsec Probable Future Extensions +@ignore +From emory!scalpel.netlabs.com!lwall Tue Oct 31 12:43:17 1995 +Return-Path: +Message-Id: <9510311732.AA28472@scalpel.netlabs.com> +To: arnold@skeeve.atl.ga.us (Arnold D. Robbins) +Subject: Re: May I quote you? +In-Reply-To: Your message of "Tue, 31 Oct 95 09:11:00 EST." + +Date: Tue, 31 Oct 95 09:32:46 -0800 +From: Larry Wall + +: Greetings. I am working on the release of gawk 3.0. Part of it will be a +: thoroughly updated manual. One of the sections deals with planned future +: extensions and enhancements. I have the following at the beginning +: of it: +: +: @cindex PERL +: @cindex Wall, Larry +: @display +: @i{AWK is a language similar to PERL, only considerably more elegant.} @* +: Arnold Robbins +: @sp 1 +: @i{Hey!} @* +: Larry Wall +: @end display +: +: Before I actually release this for publication, I wanted to get your +: permission to quote you. (Hopefully, in the spirit of much of GNU, the +: implied humor is visible... :-) + +I think that would be fine. + +Larry +@end ignore +@cindex Perl +@cindex Wall, Larry +@cindex Robbins, Arnold +@quotation +@i{AWK is a language similar to PERL, only considerably more elegant.}@* +Arnold Robbins + +@i{Hey!}@* +Larry Wall +@end quotation + +This @value{SECTION} briefly lists extensions and possible improvements +that indicate the directions we are +currently considering for @command{gawk}. The file @file{FUTURES} in the +@command{gawk} distribution lists these extensions as well. + +Following is a list of probable future changes visible at the +@command{awk} language level: + +@c these are ordered by likelihood +@table @asis +@item Loadable module interface +It is not clear that the @command{awk}-level interface to the +modules facility is as good as it should be. The interface needs to be +redesigned, particularly taking namespace issues into account, as +well as possibly including issues such as library search path order +and versioning. + +@item @code{RECLEN} variable for fixed-length records +Along with @code{FIELDWIDTHS}, this would speed up the processing of +fixed-length records. +@code{PROCINFO["RS"]} would be @code{"RS"} or @code{"RECLEN"}, +depending upon which kind of record processing is in effect. + +@item Databases +It may be possible to map a GDBM/NDBM/SDBM file into an @command{awk} array. + +@item More @code{lint} warnings +There are more things that could be checked for portability. +@end table + +Following is a list of probable improvements that will make @command{gawk}'s +source code easier to work with: + +@table @asis +@item Loadable module mechanics +The current extension mechanism works +(@pxref{Dynamic Extensions}), +but is rather primitive. It requires a fair amount of manual work +to create and integrate a loadable module. +Nor is the current mechanism as portable as might be desired. +The GNU @command{libtool} package provides a number of features that +would make using loadable modules much easier. +@command{gawk} should be changed to use @command{libtool}. + +@item Loadable module internals +The API to its internals that @command{gawk} ``exports'' should be revised. +Too many things are needlessly exposed. A new API should be designed +and implemented to make module writing easier. + +@item Better array subscript management +@command{gawk}'s management of array subscript storage could use revamping, +so that using the same value to index multiple arrays only +stores one copy of the index value. +@end table + +Finally, +the programs in the test suite could use documenting in this @value{DOCUMENT}. + +@xref{Additions}, +if you are interested in tackling any of these projects. +@c ENDOFRANGE impis +@c ENDOFRANGE gawii + +@node Basic Concepts +@appendix Basic Programming Concepts +@cindex programming, concepts +@c STARTOFRANGE procon +@cindex programming, concepts + +This @value{APPENDIX} attempts to define some of the basic concepts +and terms that are used throughout the rest of this @value{DOCUMENT}. +As this @value{DOCUMENT} is specifically about @command{awk}, +and not about computer programming in general, the coverage here +is by necessity fairly cursory and simplistic. +(If you need more background, there are many +other introductory texts that you should refer to instead.) + +@menu +* Basic High Level:: The high level view. +* Basic Data Typing:: A very quick intro to data types. +* Floating Point Issues:: Stuff to know about floating-point numbers. +@end menu + +@node Basic High Level +@appendixsec What a Program Does + +@cindex processing data +At the most basic level, the job of a program is to process +some input data and produce results. + +@iftex +@image{general-program} +@end iftex +@ifnottex +@example + _______ ++------+ / \ +---------+ +| Data | -----> < Program > -----> | Results | ++------+ \_______/ +---------+ +@end example +@end ifnottex + +@cindex compiled programs +@cindex interpreted programs +The ``program'' in the figure can be either a compiled +program@footnote{Compiled programs are typically written +in lower-level languages such as C, C++, or Ada, +and then translated, or @dfn{compiled}, into a form that +the computer can execute directly.} +(such as @command{ls}), +or it may be @dfn{interpreted}. In the latter case, a machine-executable +program such as @command{awk} reads your program, and then uses the +instructions in your program to process the data. + +@cindex programming, basic steps +When you write a program, it usually consists +of the following, very basic set of steps: + +@iftex +@image{process-flow} +@end iftex +@ifnottex +@example + ______ ++----------------+ / More \ No +----------+ +| Initialization | -------> < Data > -------> | Clean Up | ++----------------+ ^ \ ? / +----------+ + | +--+-+ + | | Yes + | | + | V + | +---------+ + +-----+ Process | + +---------+ +@end example +@end ifnottex + +@table @asis +@item Initialization +These are the things you do before actually starting to process +data, such as checking arguments, initializing any data you need +to work with, and so on. +This step corresponds to @command{awk}'s @code{BEGIN} rule +(@pxref{BEGIN/END}). + +If you were baking a cake, this might consist of laying out all the +mixing bowls and the baking pan, and making sure you have all the +ingredients that you need. + +@item Processing +This is where the actual work is done. Your program reads data, +one logical chunk at a time, and processes it as appropriate. + +In most programming languages, you have to manually manage the reading +of data, checking to see if there is more each time you read a chunk. +@command{awk}'s pattern-action paradigm +(@pxref{Getting Started}) +handles the mechanics of this for you. + +In baking a cake, the processing corresponds to the actual labor: +breaking eggs, mixing the flour, water, and other ingredients, and then putting the cake +into the oven. + +@item Clean Up +Once you've processed all the data, you may have things you need to +do before exiting. +This step corresponds to @command{awk}'s @code{END} rule +(@pxref{BEGIN/END}). + +After the cake comes out of the oven, you still have to wrap it in +plastic wrap to keep anyone from tasting it, as well as wash +the mixing bowls and utensils. +@end table + +@cindex algorithms +An @dfn{algorithm} is a detailed set of instructions necessary to accomplish +a task, or process data. It is much the same as a recipe for baking +a cake. Programs implement algorithms. Often, it is up to you to design +the algorithm and implement it, simultaneously. + +@cindex records +@cindex fields +The ``logical chunks'' we talked about previously are called @dfn{records}, +similar to the records a company keeps on employees, a school keeps for +students, or a doctor keeps for patients. +Each record has many component parts, such as first and last names, +date of birth, address, and so on. The component parts are referred +to as the @dfn{fields} of the record. + +The act of reading data is termed @dfn{input}, and that of +generating results, not too surprisingly, is termed @dfn{output}. +They are often referred to together as ``input/output,'' +and even more often, as ``I/O'' for short. +(You will also see ``input'' and ``output'' used as verbs.) + +@cindex data-driven languages +@cindex languages@comma{} data-driven +@command{awk} manages the reading of data for you, as well as the +breaking it up into records and fields. Your program's job is to +tell @command{awk} what to do with the data. You do this by describing +@dfn{patterns} in the data to look for, and @dfn{actions} to execute +when those patterns are seen. This @dfn{data-driven} nature of +@command{awk} programs usually makes them both easier to write +and easier to read. + +@node Basic Data Typing +@appendixsec Data Values in a Computer + +@cindex variables +In a program, +you keep track of information and values in things called @dfn{variables}. +A variable is just a name for a given value, such as @code{first_name}, +@code{last_name}, @code{address}, and so on. +@command{awk} has several predefined variables, and it has +special names to refer to the current input record +and the fields of the record. +You may also group multiple +associated values under one name, as an array. + +@cindex values, numeric +@cindex values, string +@cindex scalar values +Data, particularly in @command{awk}, consists of either numeric +values, such as 42 or 3.1415927, or string values. +String values are essentially anything that's not a number, such as a name. +Strings are sometimes referred to as @dfn{character data}, since they +store the individual characters that comprise them. +Individual variables, as well as numeric and string variables, are +referred to as @dfn{scalar} values. +Groups of values, such as arrays, are not scalars. + +@cindex integers +@cindex floating-point, numbers +@cindex numbers, floating-point +Within computers, there are two kinds of numeric values: @dfn{integers} +and @dfn{floating-point}. +In school, integer values were referred to as ``whole'' numbers---that is, +numbers without any fractional part, such as 1, 42, or @minus{}17. +The advantage to integer numbers is that they represent values exactly. +The disadvantage is that their range is limited. On most systems, +this range is @minus{}2,147,483,648 to 2,147,483,647. +However, many systems now support a range from +@minus{}9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. + +@cindex unsigned integers +@cindex integers, unsigned +Integer values come in two flavors: @dfn{signed} and @dfn{unsigned}. +Signed values may be negative or positive, with the range of values just +described. +Unsigned values are always positive. On most systems, +the range is from 0 to 4,294,967,295. +However, many systems now support a range from +0 to 18,446,744,073,709,551,615. + +@cindex double precision floating-point +@cindex single precision floating-point +Floating-point numbers represent what are called ``real'' numbers; i.e., +those that do have a fractional part, such as 3.1415927. +The advantage to floating-point numbers is that they +can represent a much larger range of values. +The disadvantage is that there are numbers that they cannot represent +exactly. +@command{awk} uses @dfn{double precision} floating-point numbers, which +can hold more digits than @dfn{single precision} +floating-point numbers. +Floating-point issues are discussed more fully in +@ref{Floating Point Issues}. + +At the very lowest level, computers store values as groups of binary digits, +or @dfn{bits}. Modern computers group bits into groups of eight, called @dfn{bytes}. +Advanced applications sometimes have to manipulate bits directly, +and @command{gawk} provides functions for doing so. + +@cindex null strings +While you are probably used to the idea of a number without a value (i.e., zero), +it takes a bit more getting used to the idea of zero-length character data. +Nevertheless, such a thing exists. +It is called the @dfn{null string}. +The null string is character data that has no value. +In other words, it is empty. It is written in @command{awk} programs +like this: @code{""}. + +Humans are used to working in decimal; i.e., base 10. In base 10, +numbers go from 0 to 9, and then ``roll over'' into the next +column. (Remember grade school? 42 is 4 times 10 plus 2.) + +There are other number bases though. Computers commonly use base 2 +or @dfn{binary}, base 8 or @dfn{octal}, and base 16 or @dfn{hexadecimal}. +In binary, each column represents two times the value in the column to +its right. Each column may contain either a 0 or a 1. +Thus, binary 1010 represents 1 times 8, plus 0 times 4, plus 1 times 2, +plus 0 times 1, or decimal 10. +Octal and hexadecimal are discussed more in +@ref{Nondecimal-numbers}. + +Programs are written in programming languages. +Hundreds, if not thousands, of programming languages exist. +One of the most popular is the C programming language. +The C language had a very strong influence on the design of +the @command{awk} language. + +@cindex Kernighan, Brian +@cindex Ritchie, Dennis +There have been several versions of C. The first is often referred to +as ``K&R'' C, after the initials of Brian Kernighan and Dennis Ritchie, +the authors of the first book on C. (Dennis Ritchie created the language, +and Brian Kernighan was one of the creators of @command{awk}.) + +In the mid-1980s, an effort began to produce an international standard +for C. This work culminated in 1989, with the production of the ANSI +standard for C. This standard became an ISO standard in 1990. +In 1999, a revised ISO C standard was approved and released. +Where it makes sense, POSIX @command{awk} is compatible with 1999 ISO C. + +@node Floating Point Issues +@appendixsec Floating-Point Number Caveats + +As mentioned earlier, floating-point numbers represent what are called +``real'' numbers, i.e., those that have a fractional part. @command{awk} +uses double precision floating-point numbers to represent all +numeric values. This @value{SECTION} describes some of the issues +involved in using floating-point numbers. + +There is a very nice +@uref{http://www.validlab.com/goldberg/paper.pdf, paper on floating-point arithmetic} +by David Goldberg, +``What Every Computer Scientist Should Know About Floating-point Arithmetic,'' +@cite{ACM Computing Surveys} @strong{23}, 1 (1991-03), 5-48. +This is worth reading if you are interested in the details, +but it does require a background in computer science. + +@menu +* String Conversion Precision:: The String Value Can Lie. +* Unexpected Results:: Floating Point Numbers Are Not Abstract + Numbers. +* POSIX Floating Point Problems:: Standards Versus Existing Practice. +@end menu + +@node String Conversion Precision +@appendixsubsec The String Value Can Lie + +Internally, @command{awk} keeps both the numeric value +(double precision floating-point) and the string value for a variable. +Separately, @command{awk} keeps +track of what type the variable has +(@pxref{Typing and Comparison}), +which plays a role in how variables are used in comparisons. + +It is important to note that the string value for a number may not +reflect the full value (all the digits) that the numeric value +actually contains. +The following program (@file{values.awk}) illustrates this: + +@example +@{ + sum = $1 + $2 + # see it for what it is + printf("sum = %.12g\n", sum) + # use CONVFMT + a = "<" sum ">" + print "a =", a + # use OFMT + print "sum =", sum +@} +@end example + +@noindent +This program shows the full value of the sum of @code{$1} and @code{$2} +using @code{printf}, and then prints the string values obtained +from both automatic conversion (via @code{CONVFMT}) and +from printing (via @code{OFMT}). + +Here is what happens when the program is run: + +@example +$ @kbd{echo 3.654321 1.2345678 | awk -f values.awk} +@print{} sum = 4.8888888 +@print{} a = <4.88889> +@print{} sum = 4.88889 +@end example + +This makes it clear that the full numeric value is different from +what the default string representations show. + +@code{CONVFMT}'s default value is @code{"%.6g"}, which yields a value with +at least six significant digits. For some applications, you might want to +change it to specify more precision. +On most modern machines, most of the time, +17 digits is enough to capture a floating-point number's +value exactly.@footnote{Pathological cases can require up to +752 digits (!), but we doubt that you need to worry about this.} + +@node Unexpected Results +@appendixsubsec Floating Point Numbers Are Not Abstract Numbers + +@cindex floating-point, numbers +Unlike numbers in the abstract sense (such as what you studied in high school +or college math), numbers stored in computers are limited in certain ways. +They cannot represent an infinite number of digits, nor can they always +represent things exactly. +In particular, +floating-point numbers cannot +always represent values exactly. Here is an example: + +@example +$ @kbd{awk '@{ printf("%010d\n", $1 * 100) @}'} +515.79 +@print{} 0000051579 +515.80 +@print{} 0000051579 +515.81 +@print{} 0000051580 +515.82 +@print{} 0000051582 +@kbd{@value{CTL}-d} +@end example + +@noindent +This shows that some values can be represented exactly, +whereas others are only approximated. This is not a ``bug'' +in @command{awk}, but simply an artifact of how computers +represent numbers. + +@cindex negative zero +@cindex positive zero +@cindex zero@comma{} negative vs.@: positive +Another peculiarity of floating-point numbers on modern systems +is that they often have more than one representation for the number zero! +In particular, it is possible to represent ``minus zero'' as well as +regular, or ``positive'' zero. + +This example shows that negative and positive zero are distinct values +when stored internally, but that they are in fact equal to each other, +as well as to ``regular'' zero: + +@example +$ @kbd{gawk 'BEGIN @{ mz = -0 ; pz = 0} +> @kbd{printf "-0 = %g, +0 = %g, (-0 == +0) -> %d\n", mz, pz, mz == pz} +> @kbd{printf "mz == 0 -> %d, pz == 0 -> %d\n", mz == 0, pz == 0} +> @kbd{@}'} +@print{} -0 = -0, +0 = 0, (-0 == +0) -> 1 +@print{} mz == 0 -> 1, pz == 0 -> 1 +@end example + +It helps to keep this in mind should you process numeric data +that contains negative zero values; the fact that the zero is negative +is noted and can affect comparisons. + +@node POSIX Floating Point Problems +@appendixsubsec Standards Versus Existing Practice + +Historically, @command{awk} has converted any non-numeric looking string +to the numeric value zero, when required. Furthermore, the original +definition of the language and the original POSIX standards specified that +@command{awk} only understands decimal numbers (base 10), and not octal +(base 8) or hexadecimal numbers (base 16). + +Changes in the language of the +2001 and 2004 POSIX standard can be interpreted to imply that @command{awk} +should support additional features. These features are: + +@itemize @bullet +@item +Interpretation of floating point data values specified in hexadecimal +notation (@samp{0xDEADBEEF}). (Note: data values, @emph{not} +source code constants.) + +@item +Support for the special IEEE 754 floating point values ``Not A Number'' +(NaN), positive Infinity (``inf'') and negative Infinity (``@minus{}inf''). +In particular, the format for these values is as specified by the ISO 1999 +C standard, which ignores case and can allow machine-dependent additional +characters after the @samp{nan} and allow either @samp{inf} or @samp{infinity}. +@end itemize + +The first problem is that both of these are clear changes to historical +practice: + +@itemize @bullet +@item +The @command{gawk} maintainer feels that supporting hexadecimal floating +point values, in particular, is ugly, and was never intended by the +original designers to be part of the language. + +@item +Allowing completely alphabetic strings to have valid numeric +values is also a very severe departure from historical practice. +@end itemize + +The second problem is that the @code{gawk} maintainer feels that this +interpretation of the standard, which requires a certain amount of +``language lawyering'' to arrive at in the first place, was not even +intended by the standard developers. In other words, ``we see how you +got where you are, but we don't think that that's where you want to be.'' + +The 2008 POSIX standard added explicit wording to allow, but not require, +that @command{awk} support hexadecimal floating point values and +special values for ``Not A Number'' and infinity. + +Although the @command{gawk} maintainer continues to feel that +providing those features is inadvisable, +nevertheless, on systems that support IEEE floating point, it seems +reasonable to provide @emph{some} way to support NaN and Infinity values. +The solution implemented in @command{gawk} is as follows: + +@itemize @bullet +@item +With the @option{--posix} command-line option, @command{gawk} becomes +``hands off.'' String values are passed directly to the system library's +@code{strtod()} function, and if it successfully returns a numeric value, +that is what's used.@footnote{You asked for it, you got it.} +By definition, the results are not portable across +different systems. They are also a little surprising: + +@example +$ @kbd{echo nanny | gawk --posix '@{ print $1 + 0 @}'} +@print{} nan +$ @kbd{echo 0xDeadBeef | gawk --posix '@{ print $1 + 0 @}'} +@print{} 3735928559 +@end example + +@item +Without @option{--posix}, @command{gawk} interprets the four strings +@samp{+inf}, +@samp{-inf}, +@samp{+nan}, +and +@samp{-nan} +specially, producing the corresponding special numeric values. +The leading sign acts a signal to @command{gawk} (and the user) +that the value is really numeric. Hexadecimal floating point is +not supported (unless you also use @option{--non-decimal-data}, +which is @emph{not} recommended). For example: + +@example +$ @kbd{echo nanny | gawk '@{ print $1 + 0 @}'} +@print{} 0 +$ @kbd{echo +nan | gawk '@{ print $1 + 0 @}'} +@print{} nan +$ @kbd{echo 0xDeadBeef | gawk '@{ print $1 + 0 @}'} +@print{} 0 +@end example + +@command{gawk} does ignore case in the four special values. +Thus @samp{+nan} and @samp{+NaN} are the same. +@end itemize + +@c ENDOFRANGE procon + +@node Glossary +@unnumbered Glossary + +@table @asis +@item Action +A series of @command{awk} statements attached to a rule. If the rule's +pattern matches an input record, @command{awk} executes the +rule's action. Actions are always enclosed in curly braces. +(@xref{Action Overview}.) + +@cindex Spencer, Henry +@cindex @command{sed} utility +@cindex amazing @command{awk} assembler (@command{aaa}) +@item Amazing @command{awk} Assembler +Henry Spencer at the University of Toronto wrote a retargetable assembler +completely as @command{sed} and @command{awk} scripts. It is thousands +of lines long, including machine descriptions for several eight-bit +microcomputers. It is a good example of a program that would have been +better written in another language. +You can get it from @uref{http://awk.info/?awk100/aaa}. + +@cindex Ada programming language +@cindex Programming languages, Ada +@item Ada +A programming language originally defined by the U.S.@: Department of +Defense for embedded programming. It was designed to enforce good +Software Engineering practices. + +@cindex amazingly workable formatter (@command{awf}) +@cindex @command{awf} (amazingly workable formatter) program +@item Amazingly Workable Formatter (@command{awf}) +Henry Spencer at the University of Toronto wrote a formatter that accepts +a large subset of the @samp{nroff -ms} and @samp{nroff -man} formatting +commands, using @command{awk} and @command{sh}. +It is available +from @uref{http://awk.info/?tools/awf}. + +@item Anchor +The regexp metacharacters @samp{^} and @samp{$}, which force the match +to the beginning or end of the string, respectively. + +@cindex ANSI +@item ANSI +The American National Standards Institute. This organization produces +many standards, among them the standards for the C and C++ programming +languages. +These standards often become international standards as well. See also +``ISO.'' + +@item Array +A grouping of multiple values under the same name. +Most languages just provide sequential arrays. +@command{awk} provides associative arrays. + +@item Assertion +A statement in a program that a condition is true at this point in the program. +Useful for reasoning about how a program is supposed to behave. + +@item Assignment +An @command{awk} expression that changes the value of some @command{awk} +variable or data object. An object that you can assign to is called an +@dfn{lvalue}. The assigned values are called @dfn{rvalues}. +@xref{Assignment Ops}. + +@item Associative Array +Arrays in which the indices may be numbers or strings, not just +sequential integers in a fixed range. + +@item @command{awk} Language +The language in which @command{awk} programs are written. + +@item @command{awk} Program +An @command{awk} program consists of a series of @dfn{patterns} and +@dfn{actions}, collectively known as @dfn{rules}. For each input record +given to the program, the program's rules are all processed in turn. +@command{awk} programs may also contain function definitions. + +@item @command{awk} Script +Another name for an @command{awk} program. + +@item Bash +The GNU version of the standard shell +@ifnotinfo +(the @b{B}ourne-@b{A}gain @b{SH}ell). +@end ifnotinfo +@ifinfo +(the Bourne-Again SHell). +@end ifinfo +See also ``Bourne Shell.'' + +@item BBS +See ``Bulletin Board System.'' + +@item Bit +Short for ``Binary Digit.'' +All values in computer memory ultimately reduce to binary digits: values +that are either zero or one. +Groups of bits may be interpreted differently---as integers, +floating-point numbers, character data, addresses of other +memory objects, or other data. +@command{awk} lets you work with floating-point numbers and strings. +@command{gawk} lets you manipulate bit values with the built-in +functions described in +@ref{Bitwise Functions}. + +Computers are often defined by how many bits they use to represent integer +values. Typical systems are 32-bit systems, but 64-bit systems are +becoming increasingly popular, and 16-bit systems have essentially +disappeared. + +@item Boolean Expression +Named after the English mathematician Boole. See also ``Logical Expression.'' + +@item Bourne Shell +The standard shell (@file{/bin/sh}) on Unix and Unix-like systems, +originally written by Steven R.@: Bourne. +Many shells (Bash, @command{ksh}, @command{pdksh}, @command{zsh}) are +generally upwardly compatible with the Bourne shell. + +@item Built-in Function +The @command{awk} language provides built-in functions that perform various +numerical, I/O-related, and string computations. Examples are +@code{sqrt()} (for the square root of a number) and @code{substr()} (for a +substring of a string). +@command{gawk} provides functions for timestamp management, bit manipulation, +array sorting, type checking, +and runtime string translation. +(@xref{Built-in}.) + +@item Built-in Variable +@code{ARGC}, +@code{ARGV}, +@code{CONVFMT}, +@code{ENVIRON}, +@code{FILENAME}, +@code{FNR}, +@code{FS}, +@code{NF}, +@code{NR}, +@code{OFMT}, +@code{OFS}, +@code{ORS}, +@code{RLENGTH}, +@code{RSTART}, +@code{RS}, +and +@code{SUBSEP} +are the variables that have special meaning to @command{awk}. +In addition, +@code{ARGIND}, +@code{BINMODE}, +@code{ERRNO}, +@code{FIELDWIDTHS}, +@code{FPAT}, +@code{IGNORECASE}, +@code{LINT}, +@code{PROCINFO}, +@code{RT}, +and +@code{TEXTDOMAIN} +are the variables that have special meaning to @command{gawk}. +Changing some of them affects @command{awk}'s running environment. +(@xref{Built-in Variables}.) + +@item Braces +See ``Curly Braces.'' + +@item Bulletin Board System +A computer system allowing users to log in and read and/or leave messages +for other users of the system, much like leaving paper notes on a bulletin +board. + +@item C +The system programming language that most GNU software is written in. The +@command{awk} programming language has C-like syntax, and this @value{DOCUMENT} +points out similarities between @command{awk} and C when appropriate. + +In general, @command{gawk} attempts to be as similar to the 1990 version +of ISO C as makes sense. + +@item C++ +A popular object-oriented programming language derived from C. + +@cindex ASCII +@cindex ISO 8859-1 +@cindex ISO Latin-1 +@cindex character sets (machine character encodings) +@cindex Unicode +@item Character Set +The set of numeric codes used by a computer system to represent the +characters (letters, numbers, punctuation, etc.) of a particular country +or place. The most common character set in use today is ASCII (American +Standard Code for Information Interchange). Many European +countries use an extension of ASCII known as ISO-8859-1 (ISO Latin-1). +The @uref{http://www.unicode.org, Unicode character set} is +becoming increasingly popular and standard, and is particularly +widely used on GNU/Linux systems. + +@cindex @command{chem} utility +@item CHEM +A preprocessor for @command{pic} that reads descriptions of molecules +and produces @command{pic} input for drawing them. +It was written in @command{awk} +by Brian Kernighan and Jon Bentley, and is available from +@uref{http://netlib.sandia.gov/netlib/typesetting/chem.gz}. + +@item Coprocess +A subordinate program with which two-way communications is possible. + +@cindex compiled programs +@item Compiler +A program that translates human-readable source code into +machine-executable object code. The object code is then executed +directly by the computer. +See also ``Interpreter.'' + +@item Compound Statement +A series of @command{awk} statements, enclosed in curly braces. Compound +statements may be nested. +(@xref{Statements}.) + +@item Concatenation +Concatenating two strings means sticking them together, one after another, +producing a new string. For example, the string @samp{foo} concatenated with +the string @samp{bar} gives the string @samp{foobar}. +(@xref{Concatenation}.) + +@item Conditional Expression +An expression using the @samp{?:} ternary operator, such as +@samp{@var{expr1} ? @var{expr2} : @var{expr3}}. The expression +@var{expr1} is evaluated; if the result is true, the value of the whole +expression is the value of @var{expr2}; otherwise the value is +@var{expr3}. In either case, only one of @var{expr2} and @var{expr3} +is evaluated. (@xref{Conditional Exp}.) + +@item Comparison Expression +A relation that is either true or false, such as @samp{a < b}. +Comparison expressions are used in @code{if}, @code{while}, @code{do}, +and @code{for} +statements, and in patterns to select which input records to process. +(@xref{Typing and Comparison}.) + +@item Curly Braces +The characters @samp{@{} and @samp{@}}. Curly braces are used in +@command{awk} for delimiting actions, compound statements, and function +bodies. + +@cindex dark corner +@item Dark Corner +An area in the language where specifications often were (or still +are) not clear, leading to unexpected or undesirable behavior. +Such areas are marked in this @value{DOCUMENT} with +@iftex +the picture of a flashlight in the margin +@end iftex +@ifnottex +``(d.c.)'' in the text +@end ifnottex +and are indexed under the heading ``dark corner.'' + +@item Data Driven +A description of @command{awk} programs, where you specify the data you +are interested in processing, and what to do when that data is seen. + +@item Data Objects +These are numbers and strings of characters. Numbers are converted into +strings and vice versa, as needed. +(@xref{Conversion}.) + +@item Deadlock +The situation in which two communicating processes are each waiting +for the other to perform an action. + +@item Debugger +A program used to help developers remove ``bugs'' from (de-bug) +their programs. + +@item Double Precision +An internal representation of numbers that can have fractional parts. +Double precision numbers keep track of more digits than do single precision +numbers, but operations on them are sometimes more expensive. This is the way +@command{awk} stores numeric values. It is the C type @code{double}. + +@item Dynamic Regular Expression +A dynamic regular expression is a regular expression written as an +ordinary expression. It could be a string constant, such as +@code{"foo"}, but it may also be an expression whose value can vary. +(@xref{Computed Regexps}.) + +@item Environment +A collection of strings, of the form @var{name@code{=}val}, that each +program has available to it. Users generally place values into the +environment in order to provide information to various programs. Typical +examples are the environment variables @env{HOME} and @env{PATH}. + +@item Empty String +See ``Null String.'' + +@cindex epoch, definition of +@item Epoch +The date used as the ``beginning of time'' for timestamps. +Time values in most systems are represented as seconds since the epoch, +with library functions available for converting these values into +standard date and time formats. + +The epoch on Unix and POSIX systems is 1970-01-01 00:00:00 UTC. +See also ``GMT'' and ``UTC.'' + +@item Escape Sequences +A special sequence of characters used for describing nonprinting +characters, such as @samp{\n} for newline or @samp{\033} for the ASCII +ESC (Escape) character. (@xref{Escape Sequences}.) + +@item Extension +An additional feature or change to a programming language or +utility not defined by that language's or utility's standard. +@command{gawk} has (too) many extensions over POSIX @command{awk}. + +@item FDL +See ``Free Documentation License.'' + +@item Field +When @command{awk} reads an input record, it splits the record into pieces +separated by whitespace (or by a separator regexp that you can +change by setting the built-in variable @code{FS}). Such pieces are +called fields. If the pieces are of fixed length, you can use the built-in +variable @code{FIELDWIDTHS} to describe their lengths. +If you wish to specify the contents of fields instead of the field +separator, you can use the built-in variable @code{FPAT} to do so. +(@xref{Field Separators}, +@ref{Constant Size}, +and +@ref{Splitting By Content}.) + +@item Flag +A variable whose truth value indicates the existence or nonexistence +of some condition. + +@item Floating-Point Number +Often referred to in mathematical terms as a ``rational'' or real number, +this is just a number that can have a fractional part. +See also ``Double Precision'' and ``Single Precision.'' + +@item Format +Format strings are used to control the appearance of output in the +@code{strftime()} and @code{sprintf()} functions, and are used in the +@code{printf} statement as well. Also, data conversions from numbers to strings +are controlled by the format strings contained in the built-in variables +@code{CONVFMT} and @code{OFMT}. (@xref{Control Letters}.) + +@item Free Documentation License +This document describes the terms under which this @value{DOCUMENT} +is published and may be copied. (@xref{GNU Free Documentation License}.) + +@item Function +A specialized group of statements used to encapsulate general +or program-specific tasks. @command{awk} has a number of built-in +functions, and also allows you to define your own. +(@xref{Functions}.) + +@item FSF +See ``Free Software Foundation.'' + +@cindex FSF (Free Software Foundation) +@cindex Free Software Foundation (FSF) +@cindex Stallman, Richard +@item Free Software Foundation +A nonprofit organization dedicated +to the production and distribution of freely distributable software. +It was founded by Richard M.@: Stallman, the author of the original +Emacs editor. GNU Emacs is the most widely used version of Emacs today. + +@item @command{gawk} +The GNU implementation of @command{awk}. + +@cindex GPL (General Public License) +@cindex General Public License (GPL) +@cindex GNU General Public License +@item General Public License +This document describes the terms under which @command{gawk} and its source +code may be distributed. (@xref{Copying}.) + +@item GMT +``Greenwich Mean Time.'' +This is the old term for UTC. +It is the time of day used internally for Unix and POSIX systems. +See also ``Epoch'' and ``UTC.'' + +@cindex FSF (Free Software Foundation) +@cindex Free Software Foundation (FSF) +@cindex GNU Project +@item GNU +``GNU's not Unix''. An on-going project of the Free Software Foundation +to create a complete, freely distributable, POSIX-compliant computing +environment. + +@item GNU/Linux +A variant of the GNU system using the Linux kernel, instead of the +Free Software Foundation's Hurd kernel. +The Linux kernel is a stable, efficient, full-featured clone of Unix that has +been ported to a variety of architectures. +It is most popular on PC-class systems, but runs well on a variety of +other systems too. +The Linux kernel source code is available under the terms of the GNU General +Public License, which is perhaps its most important aspect. + +@item GPL +See ``General Public License.'' + +@item Hexadecimal +Base 16 notation, where the digits are @code{0}--@code{9} and +@code{A}--@code{F}, with @samp{A} +representing 10, @samp{B} representing 11, and so on, up to @samp{F} for 15. +Hexadecimal numbers are written in C using a leading @samp{0x}, +to indicate their base. Thus, @code{0x12} is 18 (1 times 16 plus 2). +@xref{Nondecimal-numbers}. + +@item I/O +Abbreviation for ``Input/Output,'' the act of moving data into and/or +out of a running program. + +@item Input Record +A single chunk of data that is read in by @command{awk}. Usually, an @command{awk} input +record consists of one line of text. +(@xref{Records}.) + +@item Integer +A whole number, i.e., a number that does not have a fractional part. + +@item Internationalization +The process of writing or modifying a program so +that it can use multiple languages without requiring +further source code changes. + +@cindex interpreted programs +@item Interpreter +A program that reads human-readable source code directly, and uses +the instructions in it to process data and produce results. +@command{awk} is typically (but not always) implemented as an interpreter. +See also ``Compiler.'' + +@item Interval Expression +A component of a regular expression that lets you specify repeated matches of +some part of the regexp. Interval expressions were not originally available +in @command{awk} programs. + +@cindex ISO +@item ISO +The International Standards Organization. +This organization produces international standards for many things, including +programming languages, such as C and C++. +In the computer arena, important standards like those for C, C++, and POSIX +become both American national and ISO international standards simultaneously. +This @value{DOCUMENT} refers to Standard C as ``ISO C'' throughout. + +@cindex Java programming language +@cindex Programming languages, Java +@item Java +A modern programming language originally developed by Sun Microsystems +(now Oracle) supporting Object-Oriented programming. Although usually +implemented by compiling to the instructions for a standard virtual +machine (the JVM), the language can be compiled to native code. + +@item Keyword +In the @command{awk} language, a keyword is a word that has special +meaning. Keywords are reserved and may not be used as variable names. + +@command{gawk}'s keywords are: +@code{BEGIN}, +@code{BEGINFILE}, +@code{END}, +@code{ENDFILE}, +@code{break}, +@code{case}, +@code{continue}, +@code{default} +@code{delete}, +@code{do@dots{}while}, +@code{else}, +@code{exit}, +@code{for@dots{}in}, +@code{for}, +@code{function}, +@code{func}, +@code{if}, +@code{nextfile}, +@code{next}, +@code{switch}, +and +@code{while}. + +@cindex LGPL (Lesser General Public License) +@cindex Lesser General Public License (LGPL) +@cindex GNU Lesser General Public License +@item Lesser General Public License +This document describes the terms under which binary library archives +or shared objects, +and their source code may be distributed. + +@item Linux +See ``GNU/Linux.'' + +@item LGPL +See ``Lesser General Public License.'' + +@item Localization +The process of providing the data necessary for an +internationalized program to work in a particular language. + +@item Logical Expression +An expression using the operators for logic, AND, OR, and NOT, written +@samp{&&}, @samp{||}, and @samp{!} in @command{awk}. Often called Boolean +expressions, after the mathematician who pioneered this kind of +mathematical logic. + +@item Lvalue +An expression that can appear on the left side of an assignment +operator. In most languages, lvalues can be variables or array +elements. In @command{awk}, a field designator can also be used as an +lvalue. + +@item Matching +The act of testing a string against a regular expression. If the +regexp describes the contents of the string, it is said to @dfn{match} it. + +@item Metacharacters +Characters used within a regexp that do not stand for themselves. +Instead, they denote regular expression operations, such as repetition, +grouping, or alternation. + +@item No-op +An operation that does nothing. + +@item Null String +A string with no characters in it. It is represented explicitly in +@command{awk} programs by placing two double quote characters next to +each other (@code{""}). It can appear in input data by having two successive +occurrences of the field separator appear next to each other. + +@item Number +A numeric-valued data object. Modern @command{awk} implementations use +double precision floating-point to represent numbers. +Ancient @command{awk} implementations used single precision floating-point. + +@item Octal +Base-eight notation, where the digits are @code{0}--@code{7}. +Octal numbers are written in C using a leading @samp{0}, +to indicate their base. Thus, @code{013} is 11 (one times 8 plus 3). +@xref{Nondecimal-numbers}. + +@cindex P1003.1 POSIX standard +@cindex P1003.2 POSIX standard +@item P1003.1, P1003.2 +See ``POSIX.'' + +@item Pattern +Patterns tell @command{awk} which input records are interesting to which +rules. + +A pattern is an arbitrary conditional expression against which input is +tested. If the condition is satisfied, the pattern is said to @dfn{match} +the input record. A typical pattern might compare the input record against +a regular expression. (@xref{Pattern Overview}.) + +@item POSIX +The name for a series of standards +@c being developed by the IEEE +that specify a Portable Operating System interface. The ``IX'' denotes +the Unix heritage of these standards. The main standard of interest for +@command{awk} users is +@cite{IEEE Standard for Information Technology, Standard 1003.1-2008}. +The 2008 POSIX standard can be found online at +@url{http://www.opengroup.org/onlinepubs/9699919799/}. + +@item Precedence +The order in which operations are performed when operators are used +without explicit parentheses. + +@item Private +Variables and/or functions that are meant for use exclusively by library +functions and not for the main @command{awk} program. Special care must be +taken when naming such variables and functions. +(@xref{Library Names}.) + +@item Range (of input lines) +A sequence of consecutive lines from the input file(s). A pattern +can specify ranges of input lines for @command{awk} to process or it can +specify single lines. (@xref{Pattern Overview}.) + +@item Recursion +When a function calls itself, either directly or indirectly. +As long as this is not clear, refer to the entry for ``recursion.'' +If this is clear, stop, and proceed to the next entry. + +@item Redirection +Redirection means performing input from something other than the standard input +stream, or performing output to something other than the standard output stream. + +You can redirect input to the @code{getline} statement using +the @samp{<}, @samp{|}, and @samp{|&} operators. +You can redirect the output of the @code{print} and @code{printf} statements +to a file or a system command, using the @samp{>}, @samp{>>}, @samp{|}, and @samp{|&} +operators. +(@xref{Getline}, +and @ref{Redirection}.) + +@item Regexp +See ``Regular Expression.'' + +@item Regular Expression +A regular expression (``regexp'' for short) is a pattern that denotes a +set of strings, possibly an infinite set. For example, the regular expression +@samp{R.*xp} matches any string starting with the letter @samp{R} +and ending with the letters @samp{xp}. In @command{awk}, regular expressions are +used in patterns and in conditional expressions. Regular expressions may contain +escape sequences. (@xref{Regexp}.) + +@item Regular Expression Constant +A regular expression constant is a regular expression written within +slashes, such as @code{/foo/}. This regular expression is chosen +when you write the @command{awk} program and cannot be changed during +its execution. (@xref{Regexp Usage}.) + +@item Rule +A segment of an @command{awk} program that specifies how to process single +input records. A rule consists of a @dfn{pattern} and an @dfn{action}. +@command{awk} reads an input record; then, for each rule, if the input record +satisfies the rule's pattern, @command{awk} executes the rule's action. +Otherwise, the rule does nothing for that input record. + +@item Rvalue +A value that can appear on the right side of an assignment operator. +In @command{awk}, essentially every expression has a value. These values +are rvalues. + +@item Scalar +A single value, be it a number or a string. +Regular variables are scalars; arrays and functions are not. + +@item Search Path +In @command{gawk}, a list of directories to search for @command{awk} program source files. +In the shell, a list of directories to search for executable programs. + +@item Seed +The initial value, or starting point, for a sequence of random numbers. + +@item @command{sed} +See ``Stream Editor.'' + +@item Shell +The command interpreter for Unix and POSIX-compliant systems. +The shell works both interactively, and as a programming language +for batch files, or shell scripts. + +@item Short-Circuit +The nature of the @command{awk} logical operators @samp{&&} and @samp{||}. +If the value of the entire expression is determinable from evaluating just +the lefthand side of these operators, the righthand side is not +evaluated. +(@xref{Boolean Ops}.) + +@item Side Effect +A side effect occurs when an expression has an effect aside from merely +producing a value. Assignment expressions, increment and decrement +expressions, and function calls have side effects. +(@xref{Assignment Ops}.) + +@item Single Precision +An internal representation of numbers that can have fractional parts. +Single precision numbers keep track of fewer digits than do double precision +numbers, but operations on them are sometimes less expensive in terms of CPU time. +This is the type used by some very old versions of @command{awk} to store +numeric values. It is the C type @code{float}. + +@item Space +The character generated by hitting the space bar on the keyboard. + +@item Special File +A @value{FN} interpreted internally by @command{gawk}, instead of being handed +directly to the underlying operating system---for example, @file{/dev/stderr}. +(@xref{Special Files}.) + +@item Stream Editor +A program that reads records from an input stream and processes them one +or more at a time. This is in contrast with batch programs, which may +expect to read their input files in entirety before starting to do +anything, as well as with interactive programs which require input from the +user. + +@item String +A datum consisting of a sequence of characters, such as @samp{I am a +string}. Constant strings are written with double quotes in the +@command{awk} language and may contain escape sequences. +(@xref{Escape Sequences}.) + +@item Tab +The character generated by hitting the @kbd{TAB} key on the keyboard. +It usually expands to up to eight spaces upon output. + +@item Text Domain +A unique name that identifies an application. +Used for grouping messages that are translated at runtime +into the local language. + +@item Timestamp +A value in the ``seconds since the epoch'' format used by Unix +and POSIX systems. Used for the @command{gawk} functions +@code{mktime()}, @code{strftime()}, and @code{systime()}. +See also ``Epoch'' and ``UTC.'' + +@cindex Linux +@cindex GNU/Linux +@cindex Unix +@cindex BSD-based operating systems +@cindex NetBSD +@cindex FreeBSD +@cindex OpenBSD +@item Unix +A computer operating system originally developed in the early 1970's at +AT&T Bell Laboratories. It initially became popular in universities around +the world and later moved into commercial environments as a software +development system and network server system. There are many commercial +versions of Unix, as well as several work-alike systems whose source code +is freely available (such as GNU/Linux, @uref{http://www.netbsd.org, NetBSD}, +@uref{http://www.freebsd.org, FreeBSD}, and @uref{http://www.openbsd.org, OpenBSD}). + +@item UTC +The accepted abbreviation for ``Universal Coordinated Time.'' +This is standard time in Greenwich, England, which is used as a +reference time for day and date calculations. +See also ``Epoch'' and ``GMT.'' + +@item Whitespace +A sequence of space, TAB, or newline characters occurring inside an input +record or a string. +@end table + +@c The GNU General Public License. +@node Copying +@unnumbered GNU General Public License +@center Version 3, 29 June 2007 + +@c This file is intended to be included within another document, +@c hence no sectioning command or @node. + +@display +Copyright @copyright{} 2007 Free Software Foundation, Inc. @url{http://fsf.org/} + +Everyone is permitted to copy and distribute verbatim copies of this +license document, but changing it is not allowed. +@end display + +@c fakenode --- for prepinfo +@heading Preamble + +The GNU General Public License is a free, copyleft license for +software and other kinds of works. + +The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom +to share and change all versions of a program---to make sure it remains +free software for all its users. We, the Free Software Foundation, +use the GNU General Public License for most of our software; it +applies also to any other work released this way by its authors. You +can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you +have certain responsibilities if you distribute copies of the +software, or if you modify it: responsibilities to respect the freedom +of others. + +For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, +receive or can get the source code. And you must show them these +terms so they know their rights. + +Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + +Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the +manufacturer can do so. This is fundamentally incompatible with the +aim of protecting users' freedom to change the software. The +systematic pattern of such abuse occurs in the area of products for +individuals to use, which is precisely where it is most unacceptable. +Therefore, we have designed this version of the GPL to prohibit the +practice for those products. If such problems arise substantially in +other domains, we stand ready to extend this provision to those +domains in future versions of the GPL, as needed to protect the +freedom of users. + +Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish +to avoid the special danger that patents applied to a free program +could make it effectively proprietary. To prevent this, the GPL +assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and +modification follow. + +@c fakenode --- for prepinfo +@heading TERMS AND CONDITIONS + +@enumerate 0 +@item Definitions. + +``This License'' refers to version 3 of the GNU General Public License. + +``Copyright'' also means copyright-like laws that apply to other kinds +of works, such as semiconductor masks. + +``The Program'' refers to any copyrightable work licensed under this +License. Each licensee is addressed as ``you''. ``Licensees'' and +``recipients'' may be individuals or organizations. + +To ``modify'' a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of +an exact copy. The resulting work is called a ``modified version'' of +the earlier work or a work ``based on'' the earlier work. + +A ``covered work'' means either the unmodified Program or a work based +on the Program. + +To ``propagate'' a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + +To ``convey'' a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user +through a computer network, with no transfer of a copy, is not +conveying. + +An interactive user interface displays ``Appropriate Legal Notices'' to +the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + +@item Source Code. + +The ``source code'' for a work means the preferred form of the work for +making modifications to it. ``Object code'' means any non-source form +of a work. + +A ``Standard Interface'' means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + +The ``System Libraries'' of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +``Major Component'', in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + +The ``Corresponding Source'' for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can +regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same +work. + +@item Basic Permissions. + +All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, +without conditions so long as your license otherwise remains in force. +You may convey covered works to others for the sole purpose of having +them make modifications exclusively for you, or provide you with +facilities for running those works, provided that you comply with the +terms of this License in conveying all material for which you do not +control copyright. Those thus making or running the covered works for +you must do so exclusively on your behalf, under your direction and +control, on terms that prohibit them from making any copies of your +copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the +conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + +@item Protecting Users' Legal Rights From Anti-Circumvention Law. + +No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + +When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such +circumvention is effected by exercising rights under this License with +respect to the covered work, and you disclaim any intention to limit +operation or modification of the work as a means of enforcing, against +the work's users, your or third parties' legal rights to forbid +circumvention of technological measures. + +@item Conveying Verbatim Copies. + +You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + +@item Conveying Modified Source Versions. + +You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these +conditions: + +@enumerate a +@item +The work must carry prominent notices stating that you modified it, +and giving a relevant date. + +@item +The work must carry prominent notices stating that it is released +under this License and any conditions added under section 7. This +requirement modifies the requirement in section 4 to ``keep intact all +notices''. + +@item +You must license the entire work, as a whole, under this License to +anyone who comes into possession of a copy. This License will +therefore apply, along with any applicable section 7 additional terms, +to the whole of the work, and all its parts, regardless of how they +are packaged. This License gives no permission to license the work in +any other way, but it does not invalidate such permission if you have +separately received it. + +@item +If the work has interactive user interfaces, each must display +Appropriate Legal Notices; however, if the Program has interactive +interfaces that do not display Appropriate Legal Notices, your work +need not make them do so. +@end enumerate + +A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +``aggregate'' if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + +@item Conveying Non-Source Forms. + +You may convey a covered work in object code form under the terms of +sections 4 and 5, provided that you also convey the machine-readable +Corresponding Source under the terms of this License, in one of these +ways: + +@enumerate a +@item +Convey the object code in, or embodied in, a physical product +(including a physical distribution medium), accompanied by the +Corresponding Source fixed on a durable physical medium customarily +used for software interchange. + +@item +Convey the object code in, or embodied in, a physical product +(including a physical distribution medium), accompanied by a written +offer, valid for at least three years and valid for as long as you +offer spare parts or customer support for that product model, to give +anyone who possesses the object code either (1) a copy of the +Corresponding Source for all the software in the product that is +covered by this License, on a durable physical medium customarily used +for software interchange, for a price no more than your reasonable +cost of physically performing this conveying of source, or (2) access +to copy the Corresponding Source from a network server at no charge. + +@item +Convey individual copies of the object code with a copy of the written +offer to provide the Corresponding Source. This alternative is +allowed only occasionally and noncommercially, and only if you +received the object code with such an offer, in accord with subsection +6b. + +@item +Convey the object code by offering access from a designated place +(gratis or for a charge), and offer equivalent access to the +Corresponding Source in the same way through the same place at no +further charge. You need not require recipients to copy the +Corresponding Source along with the object code. If the place to copy +the object code is a network server, the Corresponding Source may be +on a different server (operated by you or a third party) that supports +equivalent copying facilities, provided you maintain clear directions +next to the object code saying where to find the Corresponding Source. +Regardless of what server hosts the Corresponding Source, you remain +obligated to ensure that it is available for as long as needed to +satisfy these requirements. + +@item +Convey the object code using peer-to-peer transmission, provided you +inform other peers where the object code and Corresponding Source of +the work are being offered to the general public at no charge under +subsection 6d. + +@end enumerate + +A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + +A ``User Product'' is either (1) a ``consumer product'', which means any +tangible personal property which is normally used for personal, +family, or household purposes, or (2) anything designed or sold for +incorporation into a dwelling. In determining whether a product is a +consumer product, doubtful cases shall be resolved in favor of +coverage. For a particular product received by a particular user, +``normally used'' refers to a typical or common use of that class of +product, regardless of the status of the particular user or of the way +in which the particular user actually uses, or expects or is expected +to use, the product. A product is a consumer product regardless of +whether the product has substantial commercial, industrial or +non-consumer uses, unless such uses represent the only significant +mode of use of the product. + +``Installation Information'' for a User Product means any methods, +procedures, authorization keys, or other information required to +install and execute modified versions of a covered work in that User +Product from a modified version of its Corresponding Source. The +information must suffice to ensure that the continued functioning of +the modified object code is in no case prevented or interfered with +solely because modification has been made. + +If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + +The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or +updates for a work that has been modified or installed by the +recipient, or for the User Product in which it has been modified or +installed. Access to a network may be denied when the modification +itself materially and adversely affects the operation of the network +or violates the rules and protocols for communication across the +network. + +Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + +@item Additional Terms. + +``Additional permissions'' are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders +of that material) supplement the terms of this License with terms: + +@enumerate a +@item +Disclaiming warranty or limiting liability differently from the terms +of sections 15 and 16 of this License; or + +@item +Requiring preservation of specified reasonable legal notices or author +attributions in that material or in the Appropriate Legal Notices +displayed by works containing it; or + +@item +Prohibiting misrepresentation of the origin of that material, or +requiring that modified versions of such material be marked in +reasonable ways as different from the original version; or + +@item +Limiting the use for publicity purposes of names of licensors or +authors of the material; or + +@item +Declining to grant rights under trademark law for use of some trade +names, trademarks, or service marks; or + +@item +Requiring indemnification of licensors and authors of that material by +anyone who conveys the material (or modified versions of it) with +contractual assumptions of liability to the recipient, for any +liability that these contractual assumptions directly impose on those +licensors and authors. +@end enumerate + +All other non-permissive additional terms are considered ``further +restrictions'' within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; the +above requirements apply either way. + +@item Termination. + +You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + +However, if you cease all violation of this License, then your license +from a particular copyright holder is reinstated (a) provisionally, +unless and until the copyright holder explicitly and finally +terminates your license, and (b) permanently, if the copyright holder +fails to notify you of the violation by some reasonable means prior to +60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + +@item Acceptance Not Required for Having Copies. + +You are not required to accept this License in order to receive or run +a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + +@item Automatic Licensing of Downstream Recipients. + +Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + +An ``entity transaction'' is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + +@item Patents. + +A ``contributor'' is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's ``contributor version''. + +A contributor's ``essential patent claims'' are all patent claims owned +or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, ``control'' includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + +In the following three paragraphs, a ``patent license'' is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To ``grant'' such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + +If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. ``Knowingly relying'' means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + +A patent license is ``discriminatory'' if it does not include within the +scope of its coverage, prohibits the exercise of, or is conditioned on +the non-exercise of one or more of the rights that are specifically +granted under this License. You may not convey a covered work if you +are a party to an arrangement with a third party that is in the +business of distributing software, under which you make payment to the +third party based on the extent of your activity of conveying the +work, and under which the third party grants, to any of the parties +who would receive the covered work from you, a discriminatory patent +license (a) in connection with copies of the covered work conveyed by +you (or copies made from those copies), or (b) primarily for and in +connection with specific products or compilations that contain the +covered work, unless you entered into that arrangement, or that patent +license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + +@item No Surrender of Others' Freedom. + +If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey +a covered work so as to satisfy simultaneously your obligations under +this License and any other pertinent obligations, then as a +consequence you may not convey it at all. For example, if you agree +to terms that obligate you to collect a royalty for further conveying +from those to whom you convey the Program, the only way you could +satisfy both those terms and this License would be to refrain entirely +from conveying the Program. + +@item Use with the GNU Affero General Public License. + +Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + +@item Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions +of the GNU General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies that a certain numbered version of the GNU General Public +License ``or any later version'' applies to it, you have the option of +following the terms and conditions either of that numbered version or +of any later version published by the Free Software Foundation. If +the Program does not specify a version number of the GNU General +Public License, you may choose any version ever published by the Free +Software Foundation. + +If the Program specifies that a proxy can decide which future versions +of the GNU General Public License can be used, that proxy's public +statement of acceptance of a version permanently authorizes you to +choose that version for the Program. + +Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + +@item Disclaimer of Warranty. + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM ``AS IS'' WITHOUT +WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND +PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE +DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR +CORRECTION. + +@item Limitation of Liability. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR +CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES +ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT +NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR +LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM +TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER +PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +@item Interpretation of Sections 15 and 16. + +If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + +@end enumerate + +@c fakenode --- for prepinfo +@heading END OF TERMS AND CONDITIONS + +@c fakenode --- for prepinfo +@heading How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these +terms. + +To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the ``copyright'' line and a pointer to where the full notice is found. + +@smallexample +@var{one line to give the program's name and a brief idea of what it does.} +Copyright (C) @var{year} @var{name of author} + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or (at +your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see @url{http://www.gnu.org/licenses/}. +@end smallexample + +Also add information on how to contact you by electronic and paper mail. + +If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + +@smallexample +@var{program} Copyright (C) @var{year} @var{name of author} +This program comes with ABSOLUTELY NO WARRANTY; for details type @samp{show w}. +This is free software, and you are welcome to redistribute it +under certain conditions; type @samp{show c} for details. +@end smallexample + +The hypothetical commands @samp{show w} and @samp{show c} should show +the appropriate parts of the General Public License. Of course, your +program's commands might be different; for a GUI interface, you would +use an ``about box''. + +You should also get your employer (if you work as a programmer) or school, +if any, to sign a ``copyright disclaimer'' for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +@url{http://www.gnu.org/licenses/}. + +The GNU General Public License does not permit incorporating your +program into proprietary programs. If your program is a subroutine +library, you may consider it more useful to permit linking proprietary +applications with the library. If this is what you want to do, use +the GNU Lesser General Public License instead of this License. But +first, please read @url{http://www.gnu.org/philosophy/why-not-lgpl.html}. + + +@c The GNU Free Documentation License. +@node GNU Free Documentation License +@unnumbered GNU Free Documentation License +@cindex FDL (Free Documentation License) +@cindex Free Documentation License (FDL) +@cindex GNU Free Documentation License +@center Version 1.3, 3 November 2008 + +@c This file is intended to be included within another document, +@c hence no sectioning command or @node. + +@display +Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. +@uref{http://fsf.org/} + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. +@end display + +@enumerate 0 +@item +PREAMBLE + +The purpose of this License is to make a manual, textbook, or other +functional and useful document @dfn{free} in the sense of freedom: to +assure everyone the effective freedom to copy and redistribute it, +with or without modifying it, either commercially or noncommercially. +Secondarily, this License preserves for the author and publisher a way +to get credit for their work, while not being considered responsible +for modifications made by others. + +This License is a kind of ``copyleft'', which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + +@item +APPLICABILITY AND DEFINITIONS + +This License applies to any manual or other work, in any medium, that +contains a notice placed by the copyright holder saying it can be +distributed under the terms of this License. Such a notice grants a +world-wide, royalty-free license, unlimited in duration, to use that +work under the conditions stated herein. The ``Document'', below, +refers to any such manual or work. Any member of the public is a +licensee, and is addressed as ``you''. You accept the license if you +copy, modify or distribute the work in a way requiring permission +under copyright law. + +A ``Modified Version'' of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A ``Secondary Section'' is a named appendix or a front-matter section +of the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall +subject (or to related matters) and contains nothing that could fall +directly within that overall subject. (Thus, if the Document is in +part a textbook of mathematics, a Secondary Section may not explain +any mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The ``Invariant Sections'' are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. If a +section does not fit the above definition of Secondary then it is not +allowed to be designated as Invariant. The Document may contain zero +Invariant Sections. If the Document does not identify any Invariant +Sections then there are none. + +The ``Cover Texts'' are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. A Front-Cover Text may +be at most 5 words, and a Back-Cover Text may be at most 25 words. + +A ``Transparent'' copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, that is suitable for revising the document +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup, or absence of markup, has been arranged to thwart +or discourage subsequent modification by readers is not Transparent. +An image format is not Transparent if used for any substantial amount +of text. A copy that is not ``Transparent'' is called ``Opaque''. + +Examples of suitable formats for Transparent copies include plain +@sc{ascii} without markup, Texinfo input format, La@TeX{} input +format, @acronym{SGML} or @acronym{XML} using a publicly available +@acronym{DTD}, and standard-conforming simple @acronym{HTML}, +PostScript or @acronym{PDF} designed for human modification. Examples +of transparent image formats include @acronym{PNG}, @acronym{XCF} and +@acronym{JPG}. Opaque formats include proprietary formats that can be +read and edited only by proprietary word processors, @acronym{SGML} or +@acronym{XML} for which the @acronym{DTD} and/or processing tools are +not generally available, and the machine-generated @acronym{HTML}, +PostScript or @acronym{PDF} produced by some word processors for +output purposes only. + +The ``Title Page'' means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, ``Title Page'' means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + +The ``publisher'' means any person or entity that distributes copies +of the Document to the public. + +A section ``Entitled XYZ'' means a named subunit of the Document whose +title either is precisely XYZ or contains XYZ in parentheses following +text that translates XYZ in another language. (Here XYZ stands for a +specific section name mentioned below, such as ``Acknowledgements'', +``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title'' +of such a section when you modify the Document means that it remains a +section ``Entitled XYZ'' according to this definition. + +The Document may include Warranty Disclaimers next to the notice which +states that this License applies to the Document. These Warranty +Disclaimers are considered to be included by reference in this +License, but only as regards disclaiming warranties: any other +implication that these Warranty Disclaimers may have is void and has +no effect on the meaning of this License. + +@item +VERBATIM COPYING + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no other +conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + +@item +COPYING IN QUANTITY + +If you publish printed copies (or copies in media that commonly have +printed covers) of the Document, numbering more than 100, and the +Document's license notice requires Cover Texts, you must enclose the +copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. +Copying with changes limited to the covers, as long as they preserve +the title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a computer-network location from which the general network-using +public has access to download using public-standard network protocols +a complete Transparent copy of the Document, free of added material. +If you use the latter option, you must take reasonably prudent steps, +when you begin distribution of Opaque copies in quantity, to ensure +that this Transparent copy will remain thus accessible at the stated +location until at least one year after the last time you distribute an +Opaque copy (directly or through your agents or retailers) of that +edition to the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to give +them a chance to provide you with an updated version of the Document. + +@item +MODIFICATIONS + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +@enumerate A +@item +Use in the Title Page (and on the covers, if any) a title distinct +from that of the Document, and from those of previous versions +(which should, if there were any, be listed in the History section +of the Document). You may use the same title as a previous version +if the original publisher of that version gives permission. + +@item +List on the Title Page, as authors, one or more persons or entities +responsible for authorship of the modifications in the Modified +Version, together with at least five of the principal authors of the +Document (all of its principal authors, if it has fewer than five), +unless they release you from this requirement. + +@item +State on the Title page the name of the publisher of the +Modified Version, as the publisher. + +@item +Preserve all the copyright notices of the Document. + +@item +Add an appropriate copyright notice for your modifications +adjacent to the other copyright notices. + +@item +Include, immediately after the copyright notices, a license notice +giving the public permission to use the Modified Version under the +terms of this License, in the form shown in the Addendum below. + +@item +Preserve in that license notice the full lists of Invariant Sections +and required Cover Texts given in the Document's license notice. + +@item +Include an unaltered copy of this License. + +@item +Preserve the section Entitled ``History'', Preserve its Title, and add +to it an item stating at least the title, year, new authors, and +publisher of the Modified Version as given on the Title Page. If +there is no section Entitled ``History'' in the Document, create one +stating the title, year, authors, and publisher of the Document as +given on its Title Page, then add an item describing the Modified +Version as stated in the previous sentence. + +@item +Preserve the network location, if any, given in the Document for +public access to a Transparent copy of the Document, and likewise +the network locations given in the Document for previous versions +it was based on. These may be placed in the ``History'' section. +You may omit a network location for a work that was published at +least four years before the Document itself, or if the original +publisher of the version it refers to gives permission. + +@item +For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve +the Title of the section, and preserve in the section all the +substance and tone of each of the contributor acknowledgements and/or +dedications given therein. + +@item +Preserve all the Invariant Sections of the Document, +unaltered in their text and in their titles. Section numbers +or the equivalent are not considered part of the section titles. + +@item +Delete any section Entitled ``Endorsements''. Such a section +may not be included in the Modified Version. + +@item +Do not retitle any existing section to be Entitled ``Endorsements'' or +to conflict in title with any Invariant Section. + +@item +Preserve any Warranty Disclaimers. +@end enumerate + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section Entitled ``Endorsements'', provided it contains +nothing but endorsements of your Modified Version by various +parties---for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + +@item +COMBINING DOCUMENTS + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice, and that you preserve all their Warranty Disclaimers. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections Entitled ``History'' +in the various original documents, forming one section Entitled +``History''; likewise combine any sections Entitled ``Acknowledgements'', +and any sections Entitled ``Dedications''. You must delete all +sections Entitled ``Endorsements.'' + +@item +COLLECTIONS OF DOCUMENTS + +You may make a collection consisting of the Document and other documents +released under this License, and replace the individual copies of this +License in the various documents with a single copy that is included in +the collection, provided that you follow the rules of this License for +verbatim copying of each of the documents in all other respects. + +You may extract a single document from such a collection, and distribute +it individually under this License, provided you insert a copy of this +License into the extracted document, and follow this License in all +other respects regarding verbatim copying of that document. + +@item +AGGREGATION WITH INDEPENDENT WORKS + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, is called an ``aggregate'' if the copyright +resulting from the compilation is not used to limit the legal rights +of the compilation's users beyond what the individual works permit. +When the Document is included in an aggregate, this License does not +apply to the other works in the aggregate which are not themselves +derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one half of +the entire aggregate, the Document's Cover Texts may be placed on +covers that bracket the Document within the aggregate, or the +electronic equivalent of covers if the Document is in electronic form. +Otherwise they must appear on printed covers that bracket the whole +aggregate. + +@item +TRANSLATION + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section 4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License, and all the license notices in the +Document, and any Warranty Disclaimers, provided that you also include +the original English version of this License and the original versions +of those notices and disclaimers. In case of a disagreement between +the translation and the original version of this License or a notice +or disclaimer, the original version will prevail. + +If a section in the Document is Entitled ``Acknowledgements'', +``Dedications'', or ``History'', the requirement (section 4) to Preserve +its Title (section 1) will typically require changing the actual +title. + +@item +TERMINATION + +You may not copy, modify, sublicense, or distribute the Document +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense, or distribute it is void, and +will automatically terminate your rights under this License. + +However, if you cease all violation of this License, then your license +from a particular copyright holder is reinstated (a) provisionally, +unless and until the copyright holder explicitly and finally +terminates your license, and (b) permanently, if the copyright holder +fails to notify you of the violation by some reasonable means prior to +60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, receipt of a copy of some or all of the same material does +not give you any rights to use it. + +@item +FUTURE REVISIONS OF THIS LICENSE + +The Free Software Foundation may publish new, revised versions +of the GNU Free Documentation License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. See +@uref{http://www.gnu.org/copyleft/}. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License ``or any later version'' applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. If the Document +specifies that a proxy can decide which future versions of this +License can be used, that proxy's public statement of acceptance of a +version permanently authorizes you to choose that version for the +Document. + +@item +RELICENSING + +``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any +World Wide Web server that publishes copyrightable works and also +provides prominent facilities for anybody to edit those works. A +public wiki that anybody can edit is an example of such a server. A +``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the +site means any set of copyrightable works thus published on the MMC +site. + +``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0 +license published by Creative Commons Corporation, a not-for-profit +corporation with a principal place of business in San Francisco, +California, as well as future copyleft versions of that license +published by that same organization. + +``Incorporate'' means to publish or republish a Document, in whole or +in part, as part of another Document. + +An MMC is ``eligible for relicensing'' if it is licensed under this +License, and if all works that were first published under this License +somewhere other than this MMC, and subsequently incorporated in whole +or in part into the MMC, (1) had no cover texts or invariant sections, +and (2) were thus incorporated prior to November 1, 2008. + +The operator of an MMC Site may republish an MMC contained in the site +under CC-BY-SA on the same site at any time before August 1, 2009, +provided the MMC is eligible for relicensing. + +@end enumerate + +@c fakenode --- for prepinfo +@unnumberedsec ADDENDUM: How to use this License for your documents + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and +license notices just after the title page: + +@smallexample +@group + Copyright (C) @var{year} @var{your name}. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover + Texts. A copy of the license is included in the section entitled ``GNU + Free Documentation License''. +@end group +@end smallexample + +If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, +replace the ``with@dots{}Texts.'' line with this: + +@smallexample +@group + with the Invariant Sections being @var{list their titles}, with + the Front-Cover Texts being @var{list}, and with the Back-Cover Texts + being @var{list}. +@end group +@end smallexample + +If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, +to permit their use in free software. + +@c Local Variables: +@c ispell-local-pdict: "ispell-dict" +@c End: + +@node Index +@unnumbered Index +@printindex cp + +@bye + +Unresolved Issues: +------------------ +1. From ADR. + + Robert J. Chassell points out that awk programs should have some indication + of how to use them. It would be useful to perhaps have a "programming + style" section of the manual that would include this and other tips. + +2. The default AWKPATH search path should be configurable via `configure' + The default and how this changes needs to be documented. + +Consistency issues: + /.../ regexps are in @code, not @samp + ".." strings are in @code, not @samp + no @print before @dots + values of expressions in the text (@code{x} has the value 15), + should be in roman, not @code + Use TAB and not tab + Use ESC and not ESCAPE + Use space and not blank to describe the space bar's character + The term "blank" is thus basically reserved for "blank lines" etc. + To make dark corners work, the @value{DARKCORNER} has to be outside + closing `.' of a sentence and after (pxref{...}). + " " should have an @w{} around it + Use "non-" only with language names or acronyms, or the words bug and option and null + Use @command{ftp} when talking about anonymous ftp + Use uppercase and lowercase, not "upper-case" and "lower-case" + or "upper case" and "lower case" + Use "single precision" and "double precision", not "single-precision" or "double-precision" + Use alphanumeric, not alpha-numeric + Use POSIX-compliant, not POSIX compliant + Use --foo, not -Wfoo when describing long options + Use "Bell Laboratories", but not "Bell Labs". + Use "behavior" instead of "behaviour". + Use "zeros" instead of "zeroes". + Use "nonzero" not "non-zero". + Use "runtime" not "run time" or "run-time". + Use "command-line" not "command line". + Use "online" not "on-line". + Use "whitespace" not "white space". + Use "Input/Output", not "input/output". Also "I/O", not "i/o". + Use "lefthand"/"righthand", not "left-hand"/"right-hand". + Use "workaround", not "work-around". + Use "startup"/"cleanup", not "start-up"/"clean-up" + Use @code{do}, and not @code{do}-@code{while}, except where + actually discussing the do-while. + Use "versus" in text and "vs." in index entries + Use @code{"C"} for the C locale, not ``C'' or @samp{C}. + The words "a", "and", "as", "between", "for", "from", "in", "of", + "on", "that", "the", "to", "with", and "without", + should not be capitalized in @chapter, @section etc. + "Into" and "How" should. + Search for @dfn; make sure important items are also indexed. + "e.g." should always be followed by a comma. + "i.e." should always be followed by a comma. + The numbers zero through ten should be spelled out, except when + talking about file descriptor numbers. > 10 and < 0, it's + ok to use numbers. + In tables, put command-line options in @code, while in the text, + put them in @option. + For most cases, do NOT put a comma before "and", "or" or "but". + But exercise taste with this rule. + Don't show the awk command with a program in quotes when it's + just the program. I.e. + + { + .... + } + + not + awk '{ + ... + }' + + Do show it when showing command-line arguments, data files, etc, even + if there is no output shown. + + Use numbered lists only to show a sequential series of steps. + + Use @code{xxx} for the xxx operator in indexing statements, not @samp. + Use MS-Windows not MS Windows + Use MS-DOS not MS-DOS + Use an empty set of parentheses after built-in and awk function names. + +Date: Wed, 13 Apr 94 15:20:52 -0400 +From: rms@gnu.org (Richard Stallman) +To: gnu-prog@gnu.org +Subject: A reminder: no pathnames in GNU + +It's a GNU convention to use the term "file name" for the name of a +file, never "pathname". We use the term "path" for search paths, +which are lists of file names. Using it for a single file name as +well is potentially confusing to users. + +So please check any documentation you maintain, if you think you might +have used "pathname". + +Note that "file name" should be two words when it appears as ordinary +text. It's ok as one word when it's a metasyntactic variable, though. + +------------------------ +ORA uses filename, thus the macro. + +Suggestions: +------------ +Enhance FIELDWIDTHS with some way to indicate "the rest of the record". +E.g., a length of 0 or -1 or something. May be "n"? + +Make FIELDWIDTHS be an array? + +% Next edition: +% 1. Talk about common extensions, those in nawk, gawk, mawk +% 2. Use @code{foo} for variables and @code{foo()} for functions +% 3. Standardize the error messages from the functions and programs +% in Chapters 12 and 13. +% 4. Nuke the BBS stuff and use something that won't be obsolete diff --git a/doc/gawkinet.info b/doc/gawkinet.info new file mode 100644 index 0000000..0a0d69d --- /dev/null +++ b/doc/gawkinet.info @@ -0,0 +1,4397 @@ +This is gawkinet.info, produced by makeinfo version 4.13 from +gawkinet.texi. + +INFO-DIR-SECTION Network applications +START-INFO-DIR-ENTRY +* Gawkinet: (gawkinet). TCP/IP Internetworking With `gawk'. +END-INFO-DIR-ENTRY + + This is Edition 1.3 of `TCP/IP Internetworking With `gawk'', for the +4.0.0 (or later) version of the GNU implementation of AWK. + + + Copyright (C) 2000, 2001, 2002, 2004, 2009, 2010 Free Software +Foundation, Inc. + + + Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with the +Invariant Sections being "GNU General Public License", the Front-Cover +texts being (a) (see below), and with the Back-Cover Texts being (b) +(see below). A copy of the license is included in the section entitled +"GNU Free Documentation License". + + a. "A GNU Manual" + + b. "You have the freedom to copy and modify this GNU manual. Buying + copies from the FSF supports it in developing GNU and promoting + software freedom." + + This file documents the networking features in GNU `awk'. + + This is Edition 1.3 of `TCP/IP Internetworking With `gawk'', for the +4.0.0 (or later) version of the GNU implementation of AWK. + + + Copyright (C) 2000, 2001, 2002, 2004, 2009, 2010 Free Software +Foundation, Inc. + + + Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with the +Invariant Sections being "GNU General Public License", the Front-Cover +texts being (a) (see below), and with the Back-Cover Texts being (b) +(see below). A copy of the license is included in the section entitled +"GNU Free Documentation License". + + a. "A GNU Manual" + + b. "You have the freedom to copy and modify this GNU manual. Buying + copies from the FSF supports it in developing GNU and promoting + software freedom." + + +File: gawkinet.info, Node: Top, Next: Preface, Prev: (dir), Up: (dir) + +General Introduction +******************** + +This file documents the networking features in GNU Awk (`gawk') version +4.0 and later. + + This is Edition 1.3 of `TCP/IP Internetworking With `gawk'', for the +4.0.0 (or later) version of the GNU implementation of AWK. + + + Copyright (C) 2000, 2001, 2002, 2004, 2009, 2010 Free Software +Foundation, Inc. + + + Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with the +Invariant Sections being "GNU General Public License", the Front-Cover +texts being (a) (see below), and with the Back-Cover Texts being (b) +(see below). A copy of the license is included in the section entitled +"GNU Free Documentation License". + + a. "A GNU Manual" + + b. "You have the freedom to copy and modify this GNU manual. Buying + copies from the FSF supports it in developing GNU and promoting + software freedom." + +* Menu: + +* Preface:: About this document. +* Introduction:: About networking. +* Using Networking:: Some examples. +* Some Applications and Techniques:: More extended examples. +* Links:: Where to find the stuff mentioned in this + document. +* GNU Free Documentation License:: The license for this document. +* Index:: The index. + +* Stream Communications:: Sending data streams. +* Datagram Communications:: Sending self-contained messages. +* The TCP/IP Protocols:: How these models work in the Internet. +* Basic Protocols:: The basic protocols. +* Ports:: The idea behind ports. +* Making Connections:: Making TCP/IP connections. +* Gawk Special Files:: How to do `gawk' networking. +* Special File Fields:: The fields in the special file name. +* Comparing Protocols:: Differences between the protocols. +* File /inet/tcp:: The TCP special file. +* File /inet/udp:: The UDP special file. +* TCP Connecting:: Making a TCP connection. +* Troubleshooting:: Troubleshooting TCP/IP connections. +* Interacting:: Interacting with a service. +* Setting Up:: Setting up a service. +* Email:: Reading email. +* Web page:: Reading a Web page. +* Primitive Service:: A primitive Web service. +* Interacting Service:: A Web service with interaction. +* CGI Lib:: A simple CGI library. +* Simple Server:: A simple Web server. +* Caveats:: Network programming caveats. +* Challenges:: Where to go from here. +* PANIC:: An Emergency Web Server. +* GETURL:: Retrieving Web Pages. +* REMCONF:: Remote Configuration Of Embedded Systems. +* URLCHK:: Look For Changed Web Pages. +* WEBGRAB:: Extract Links From A Page. +* STATIST:: Graphing A Statistical Distribution. +* MAZE:: Walking Through A Maze In Virtual Reality. +* MOBAGWHO:: A Simple Mobile Agent. +* STOXPRED:: Stock Market Prediction As A Service. +* PROTBASE:: Searching Through A Protein Database. + + +File: gawkinet.info, Node: Preface, Next: Introduction, Prev: Top, Up: Top + +Preface +******* + +In May of 1997, Ju"rgen Kahrs felt the need for network access from +`awk', and, with a little help from me, set about adding features to do +this for `gawk'. At that time, he wrote the bulk of this Info file. + + The code and documentation were added to the `gawk' 3.1 development +tree, and languished somewhat until I could finally get down to some +serious work on that version of `gawk'. This finally happened in the +middle of 2000. + + Meantime, Ju"rgen wrote an article about the Internet special files +and `|&' operator for `Linux Journal', and made a networking patch for +the production versions of `gawk' available from his home page. In +August of 2000 (for `gawk' 3.0.6), this patch also made it to the main +GNU `ftp' distribution site. + + For release with `gawk', I edited Ju"rgen's prose for English +grammar and style, as he is not a native English speaker. I also +rearranged the material somewhat for what I felt was a better order of +presentation, and (re)wrote some of the introductory material. + + The majority of this document and the code are his work, and the +high quality and interesting ideas speak for themselves. It is my hope +that these features will be of significant value to the `awk' community. + + +Arnold Robbins +Nof Ayalon, ISRAEL +March, 2001 + + +File: gawkinet.info, Node: Introduction, Next: Using Networking, Prev: Preface, Up: Top + +1 Networking Concepts +********************* + +This major node provides a (necessarily) brief introduction to computer +networking concepts. For many applications of `gawk' to TCP/IP +networking, we hope that this is enough. For more advanced tasks, you +will need deeper background, and it may be necessary to switch to +lower-level programming in C or C++. + + There are two real-life models for the way computers send messages +to each other over a network. While the analogies are not perfect, +they are close enough to convey the major concepts. These two models +are the phone system (reliable byte-stream communications), and the +postal system (best-effort datagrams). + +* Menu: + +* Stream Communications:: Sending data streams. +* Datagram Communications:: Sending self-contained messages. +* The TCP/IP Protocols:: How these models work in the Internet. +* Making Connections:: Making TCP/IP connections. + + +File: gawkinet.info, Node: Stream Communications, Next: Datagram Communications, Prev: Introduction, Up: Introduction + +1.1 Reliable Byte-streams (Phone Calls) +======================================= + +When you make a phone call, the following steps occur: + + 1. You dial a number. + + 2. The phone system connects to the called party, telling them there + is an incoming call. (Their phone rings.) + + 3. The other party answers the call, or, in the case of a computer + network, refuses to answer the call. + + 4. Assuming the other party answers, the connection between you is + now a "duplex" (two-way), "reliable" (no data lost), sequenced + (data comes out in the order sent) data stream. + + 5. You and your friend may now talk freely, with the phone system + moving the data (your voices) from one end to the other. From + your point of view, you have a direct end-to-end connection with + the person on the other end. + + The same steps occur in a duplex reliable computer networking +connection. There is considerably more overhead in setting up the +communications, but once it's done, data moves in both directions, +reliably, in sequence. + + +File: gawkinet.info, Node: Datagram Communications, Next: The TCP/IP Protocols, Prev: Stream Communications, Up: Introduction + +1.2 Best-effort Datagrams (Mailed Letters) +========================================== + +Suppose you mail three different documents to your office on the other +side of the country on two different days. Doing so entails the +following. + + 1. Each document travels in its own envelope. + + 2. Each envelope contains both the sender and the recipient address. + + 3. Each envelope may travel a different route to its destination. + + 4. The envelopes may arrive in a different order from the one in + which they were sent. + + 5. One or more may get lost in the mail. (Although, fortunately, + this does not occur very often.) + + 6. In a computer network, one or more "packets" may also arrive + multiple times. (This doesn't happen with the postal system!) + + + The important characteristics of datagram communications, like those +of the postal system are thus: + + * Delivery is "best effort;" the data may never get there. + + * Each message is self-contained, including the source and + destination addresses. + + * Delivery is _not_ sequenced; packets may arrive out of order, + and/or multiple times. + + * Unlike the phone system, overhead is considerably lower. It is + not necessary to set up the call first. + + The price the user pays for the lower overhead of datagram +communications is exactly the lower reliability; it is often necessary +for user-level protocols that use datagram communications to add their +own reliability features on top of the basic communications. + + +File: gawkinet.info, Node: The TCP/IP Protocols, Next: Making Connections, Prev: Datagram Communications, Up: Introduction + +1.3 The Internet Protocols +========================== + +The Internet Protocol Suite (usually referred to as just TCP/IP)(1) +consists of a number of different protocols at different levels or +"layers." For our purposes, three protocols provide the fundamental +communications mechanisms. All other defined protocols are referred to +as user-level protocols (e.g., HTTP, used later in this Info file). + +* Menu: + +* Basic Protocols:: The basic protocols. +* Ports:: The idea behind ports. + + ---------- Footnotes ---------- + + (1) It should be noted that although the Internet seems to have +conquered the world, there are other networking protocol suites in +existence and in use. + + +File: gawkinet.info, Node: Basic Protocols, Next: Ports, Prev: The TCP/IP Protocols, Up: The TCP/IP Protocols + +1.3.1 The Basic Internet Protocols +---------------------------------- + +IP + The Internet Protocol. This protocol is almost never used + directly by applications. It provides the basic packet delivery + and routing infrastructure of the Internet. Much like the phone + company's switching centers or the Post Office's trucks, it is not + of much day-to-day interest to the regular user (or programmer). + It happens to be a best effort datagram protocol. In the early + twenty-first century, there are two versions of this protocol in + use: + + IPv4 + The original version of the Internet Protocol, with 32-bit + addresses, on which most of the current Internet is based. + + IPv6 + The "next generation" of the Internet Protocol, with 128-bit + addresses. This protocol is in wide use in certain parts of + the world, but has not yet replaced IPv4.(1) + + Versions of the other protocols that sit "atop" IP exist for both + IPv4 and IPv6. However, as the IPv6 versions are fundamentally the + same as the original IPv4 versions, we will not distinguish + further between them. + +UDP + The User Datagram Protocol. This is a best effort datagram + protocol. It provides a small amount of extra reliability over + IP, and adds the notion of "ports", described in *note TCP and UDP + Ports: Ports. + +TCP + The Transmission Control Protocol. This is a duplex, reliable, + sequenced byte-stream protocol, again layered on top of IP, and + also providing the notion of ports. This is the protocol that you + will most likely use when using `gawk' for network programming. + + All other user-level protocols use either TCP or UDP to do their +basic communications. Examples are SMTP (Simple Mail Transfer +Protocol), FTP (File Transfer Protocol), and HTTP (HyperText Transfer +Protocol). + + ---------- Footnotes ---------- + + (1) There isn't an IPv5. + + +File: gawkinet.info, Node: Ports, Prev: Basic Protocols, Up: The TCP/IP Protocols + +1.3.2 TCP and UDP Ports +----------------------- + +In the postal system, the address on an envelope indicates a physical +location, such as a residence or office building. But there may be +more than one person at the location; thus you have to further quantify +the recipient by putting a person or company name on the envelope. + + In the phone system, one phone number may represent an entire +company, in which case you need a person's extension number in order to +reach that individual directly. Or, when you call a home, you have to +say, "May I please speak to ..." before talking to the person directly. + + IP networking provides the concept of addressing. An IP address +represents a particular computer, but no more. In order to reach the +mail service on a system, or the FTP or WWW service on a system, you +must have some way to further specify which service you want. In the +Internet Protocol suite, this is done with "port numbers", which +represent the services, much like an extension number used with a phone +number. + + Port numbers are 16-bit integers. Unix and Unix-like systems +reserve ports below 1024 for "well known" services, such as SMTP, FTP, +and HTTP. Numbers 1024 and above may be used by any application, +although there is no promise made that a particular port number is +always available. + + +File: gawkinet.info, Node: Making Connections, Prev: The TCP/IP Protocols, Up: Introduction + +1.4 Making TCP/IP Connections (And Some Terminology) +==================================================== + +Two terms come up repeatedly when discussing networking: "client" and +"server". For now, we'll discuss these terms at the "connection +level", when first establishing connections between two processes on +different systems over a network. (Once the connection is established, +the higher level, or "application level" protocols, such as HTTP or +FTP, determine who is the client and who is the server. Often, it +turns out that the client and server are the same in both roles.) + + The "server" is the system providing the service, such as the web +server or email server. It is the "host" (system) which is _connected +to_ in a transaction. For this to work though, the server must be +expecting connections. Much as there has to be someone at the office +building to answer the phone(1), the server process (usually) has to be +started first and be waiting for a connection. + + The "client" is the system requesting the service. It is the system +_initiating the connection_ in a transaction. (Just as when you pick +up the phone to call an office or store.) + + In the TCP/IP framework, each end of a connection is represented by +a pair of (ADDRESS, PORT) pairs. For the duration of the connection, +the ports in use at each end are unique, and cannot be used +simultaneously by other processes on the same system. (Only after +closing a connection can a new one be built up on the same port. This +is contrary to the usual behavior of fully developed web servers which +have to avoid situations in which they are not reachable. We have to +pay this price in order to enjoy the benefits of a simple communication +paradigm in `gawk'.) + + Furthermore, once the connection is established, communications are +"synchronous".(2) I.e., each end waits on the other to finish +transmitting, before replying. This is much like two people in a phone +conversation. While both could talk simultaneously, doing so usually +doesn't work too well. + + In the case of TCP, the synchronicity is enforced by the protocol +when sending data. Data writes "block" until the data have been +received on the other end. For both TCP and UDP, data reads block +until there is incoming data waiting to be read. This is summarized in +the following table, where an "X" indicates that the given action +blocks. + +TCP X X +UDP X + + ---------- Footnotes ---------- + + (1) In the days before voice mail systems! + + (2) For the technically savvy, data reads block--if there's no +incoming data, the program is made to wait until there is, instead of +receiving a "there's no data" error return. + + +File: gawkinet.info, Node: Using Networking, Next: Some Applications and Techniques, Prev: Introduction, Up: Top + +2 Networking With `gawk' +************************ + +The `awk' programming language was originally developed as a +pattern-matching language for writing short programs to perform data +manipulation tasks. `awk''s strength is the manipulation of textual +data that is stored in files. It was never meant to be used for +networking purposes. To exploit its features in a networking context, +it's necessary to use an access mode for network connections that +resembles the access of files as closely as possible. + + `awk' is also meant to be a prototyping language. It is used to +demonstrate feasibility and to play with features and user interfaces. +This can be done with file-like handling of network connections. +`gawk' trades the lack of many of the advanced features of the TCP/IP +family of protocols for the convenience of simple connection handling. +The advanced features are available when programming in C or Perl. In +fact, the network programming in this major node is very similar to +what is described in books such as `Internet Programming with Python', +`Advanced Perl Programming', or `Web Client Programming with Perl'. + + However, you can do the programming here without first having to +learn object-oriented ideology; underlying languages such as Tcl/Tk, +Perl, Python; or all of the libraries necessary to extend these +languages before they are ready for the Internet. + + This major node demonstrates how to use the TCP protocol. The UDP +protocol is much less important for most users. + +* Menu: + +* Gawk Special Files:: How to do `gawk' networking. +* TCP Connecting:: Making a TCP connection. +* Troubleshooting:: Troubleshooting TCP/IP connections. +* Interacting:: Interacting with a service. +* Setting Up:: Setting up a service. +* Email:: Reading email. +* Web page:: Reading a Web page. +* Primitive Service:: A primitive Web service. +* Interacting Service:: A Web service with interaction. +* Simple Server:: A simple Web server. +* Caveats:: Network programming caveats. +* Challenges:: Where to go from here. + + +File: gawkinet.info, Node: Gawk Special Files, Next: TCP Connecting, Prev: Using Networking, Up: Using Networking + +2.1 `gawk''s Networking Mechanisms +================================== + +The `|&' operator for use in communicating with a "coprocess" is +described in *note Two-way Communications With Another Process: +(gawk)Two-way I/O. It shows how to do two-way I/O to a separate +process, sending it data with `print' or `printf' and reading data with +`getline'. If you haven't read it already, you should detour there to +do so. + + `gawk' transparently extends the two-way I/O mechanism to simple +networking through the use of special file names. When a "coprocess" +that matches the special files we are about to describe is started, +`gawk' creates the appropriate network connection, and then two-way I/O +proceeds as usual. + + At the C, C++, and Perl level, networking is accomplished via +"sockets", an Application Programming Interface (API) originally +developed at the University of California at Berkeley that is now used +almost universally for TCP/IP networking. Socket level programming, +while fairly straightforward, requires paying attention to a number of +details, as well as using binary data. It is not well-suited for use +from a high-level language like `awk'. The special files provided in +`gawk' hide the details from the programmer, making things much simpler +and easier to use. + + The special file name for network access is made up of several +fields, all of which are mandatory: + + /NET-TYPE/PROTOCOL/LOCALPORT/HOSTNAME/REMOTEPORT + + The NET-TYPE field lets you specify IPv4 versus IPv6, or lets you +allow the system to choose. + +* Menu: + +* Special File Fields:: The fields in the special file name. +* Comparing Protocols:: Differences between the protocols. + + +File: gawkinet.info, Node: Special File Fields, Next: Comparing Protocols, Prev: Gawk Special Files, Up: Gawk Special Files + +2.1.1 The Fields of the Special File Name +----------------------------------------- + +This node explains the meaning of all the other fields, as well as the +range of values and the defaults. All of the fields are mandatory. To +let the system pick a value, or if the field doesn't apply to the +protocol, specify it as `0': + +NET-TYPE + This is one of `inet4' for IPv4, `inet6' for IPv6, or `inet' to + use the system default (which is likely to be IPv4). For the rest + of this document, we will use the generic `/inet' in our + descriptions of how `gawk''s networking works. + +PROTOCOL + Determines which member of the TCP/IP family of protocols is + selected to transport the data across the network. There are two + possible values (always written in lowercase): `tcp' and `udp'. + The exact meaning of each is explained later in this node. + +LOCALPORT + Determines which port on the local machine is used to communicate + across the network. Application-level clients usually use `0' to + indicate they do not care which local port is used--instead they + specify a remote port to connect to. It is vital for + application-level servers to use a number different from `0' here + because their service has to be available at a specific publicly + known port number. It is possible to use a name from + `/etc/services' here. + +HOSTNAME + Determines which remote host is to be at the other end of the + connection. Application-level servers must fill this field with a + `0' to indicate their being open for all other hosts to connect to + them and enforce connection level server behavior this way. It is + not possible for an application-level server to restrict its + availability to one remote host by entering a host name here. + Application-level clients must enter a name different from `0'. + The name can be either symbolic (e.g., `jpl-devvax.jpl.nasa.gov') + or numeric (e.g., `128.149.1.143'). + +REMOTEPORT + Determines which port on the remote machine is used to communicate + across the network. For `/inet/tcp' and `/inet/udp', + application-level clients _must_ use a number other than `0' to + indicate to which port on the remote machine they want to connect. + Application-level servers must not fill this field with a `0'. + Instead they specify a local port to which clients connect. It is + possible to use a name from `/etc/services' here. + + Experts in network programming will notice that the usual +client/server asymmetry found at the level of the socket API is not +visible here. This is for the sake of simplicity of the high-level +concept. If this asymmetry is necessary for your application, use +another language. For `gawk', it is more important to enable users to +write a client program with a minimum of code. What happens when first +accessing a network connection is seen in the following pseudocode: + + if ((name of remote host given) && (other side accepts connection)) { + rendez-vous successful; transmit with getline or print + } else { + if ((other side did not accept) && (localport == 0)) + exit unsuccessful + if (TCP) { + set up a server accepting connections + this means waiting for the client on the other side to connect + } else + ready + } + + The exact behavior of this algorithm depends on the values of the +fields of the special file name. When in doubt, *note +table-inet-components:: gives you the combinations of values and their +meaning. If this table is too complicated, focus on the three lines +printed in *bold*. All the examples in *note Networking With `gawk': +Using Networking, use only the patterns printed in bold letters. + +PROTOCOL LOCAL PORT HOST NAME REMOTE RESULTING CONNECTION-LEVEL + PORT BEHAVIOR +------------------------------------------------------------------------------ +*tcp* *0* *x* *x* *Dedicated client, fails if + immediately connecting to a + server on the + other side fails* +udp 0 x x Dedicated client +*tcp, udp* *x* *x* *x* *Client, switches to + dedicated server if + necessary* +*tcp, udp* *x* *0* *0* *Dedicated server* +tcp, udp x x 0 Invalid +tcp, udp 0 0 x Invalid +tcp, udp x 0 x Invalid +tcp, udp 0 0 0 Invalid +tcp, udp 0 x 0 Invalid + +Table 2.1: /inet Special File Components + + In general, TCP is the preferred mechanism to use. It is the +simplest protocol to understand and to use. Use UDP only if +circumstances demand low-overhead. + + +File: gawkinet.info, Node: Comparing Protocols, Prev: Special File Fields, Up: Gawk Special Files + +2.1.2 Comparing Protocols +------------------------- + +This node develops a pair of programs (sender and receiver) that do +nothing but send a timestamp from one machine to another. The sender +and the receiver are implemented with each of the two protocols +available and demonstrate the differences between them. + +* Menu: + +* File /inet/tcp:: The TCP special file. +* File /inet/udp:: The UDP special file. + + +File: gawkinet.info, Node: File /inet/tcp, Next: File /inet/udp, Prev: Comparing Protocols, Up: Comparing Protocols + +2.1.2.1 `/inet/tcp' +................... + +Once again, always use TCP. (Use UDP when low overhead is a necessity, +and use RAW for network experimentation.) The first example is the +sender program: + + # Server + BEGIN { + print strftime() |& "/inet/tcp/8888/0/0" + close("/inet/tcp/8888/0/0") + } + + The receiver is very simple: + + # Client + BEGIN { + "/inet/tcp/0/localhost/8888" |& getline + print $0 + close("/inet/tcp/0/localhost/8888") + } + + TCP guarantees that the bytes arrive at the receiving end in exactly +the same order that they were sent. No byte is lost (except for broken +connections), doubled, or out of order. Some overhead is necessary to +accomplish this, but this is the price to pay for a reliable service. +It does matter which side starts first. The sender/server has to be +started first, and it waits for the receiver to read a line. + + +File: gawkinet.info, Node: File /inet/udp, Prev: File /inet/tcp, Up: Comparing Protocols + +2.1.2.2 `/inet/udp' +................... + +The server and client programs that use UDP are almost identical to +their TCP counterparts; only the PROTOCOL has changed. As before, it +does matter which side starts first. The receiving side blocks and +waits for the sender. In this case, the receiver/client has to be +started first: + + # Server + BEGIN { + print strftime() |& "/inet/udp/8888/0/0" + close("/inet/udp/8888/0/0") + } + + The receiver is almost identical to the TCP receiver: + + # Client + BEGIN { + "/inet/udp/0/localhost/8888" |& getline + print $0 + close("/inet/udp/0/localhost/8888") + } + + UDP cannot guarantee that the datagrams at the receiving end will +arrive in exactly the same order they were sent. Some datagrams could be +lost, some doubled, and some out of order. But no overhead is necessary +to accomplish this. This unreliable behavior is good enough for tasks +such as data acquisition, logging, and even stateless services like NFS. + + +File: gawkinet.info, Node: TCP Connecting, Next: Troubleshooting, Prev: Gawk Special Files, Up: Using Networking + +2.2 Establishing a TCP Connection +================================= + +Let's observe a network connection at work. Type in the following +program and watch the output. Within a second, it connects via TCP +(`/inet/tcp') to the machine it is running on (`localhost') and asks +the service `daytime' on the machine what time it is: + + BEGIN { + "/inet/tcp/0/localhost/daytime" |& getline + print $0 + close("/inet/tcp/0/localhost/daytime") + } + + Even experienced `awk' users will find the second line strange in two +respects: + + * A special file is used as a shell command that pipes its output + into `getline'. One would rather expect to see the special file + being read like any other file (`getline < + "/inet/tcp/0/localhost/daytime")'. + + * The operator `|&' has not been part of any `awk' implementation + (until now). It is actually the only extension of the `awk' + language needed (apart from the special files) to introduce + network access. + + The `|&' operator was introduced in `gawk' 3.1 in order to overcome +the crucial restriction that access to files and pipes in `awk' is +always unidirectional. It was formerly impossible to use both access +modes on the same file or pipe. Instead of changing the whole concept +of file access, the `|&' operator behaves exactly like the usual pipe +operator except for two additions: + + * Normal shell commands connected to their `gawk' program with a `|&' + pipe can be accessed bidirectionally. The `|&' turns out to be a + quite general, useful, and natural extension of `awk'. + + * Pipes that consist of a special file name for network connections + are not executed as shell commands. Instead, they can be read and + written to, just like a full-duplex network connection. + + In the earlier example, the `|&' operator tells `getline' to read a +line from the special file `/inet/tcp/0/localhost/daytime'. We could +also have printed a line into the special file. But instead we just +read a line with the time, printed it, and closed the connection. +(While we could just let `gawk' close the connection by finishing the +program, in this Info file we are pedantic and always explicitly close +the connections.) + + +File: gawkinet.info, Node: Troubleshooting, Next: Interacting, Prev: TCP Connecting, Up: Using Networking + +2.3 Troubleshooting Connection Problems +======================================= + +It may well be that for some reason the program shown in the previous +example does not run on your machine. When looking at possible reasons +for this, you will learn much about typical problems that arise in +network programming. First of all, your implementation of `gawk' may +not support network access because it is a pre-3.1 version or you do +not have a network interface in your machine. Perhaps your machine +uses some other protocol, such as DECnet or Novell's IPX. For the rest +of this major node, we will assume you work on a Unix machine that +supports TCP/IP. If the previous example program does not run on your +machine, it may help to replace the name `localhost' with the name of +your machine or its IP address. If it does, you could replace +`localhost' with the name of another machine in your vicinity--this +way, the program connects to another machine. Now you should see the +date and time being printed by the program, otherwise your machine may +not support the `daytime' service. Try changing the service to +`chargen' or `ftp'. This way, the program connects to other services +that should give you some response. If you are curious, you should have +a look at your `/etc/services' file. It could look like this: + + # /etc/services: + # + # Network services, Internet style + # + # Name Number/Protocol Alternate name # Comments + + echo 7/tcp + echo 7/udp + discard 9/tcp sink null + discard 9/udp sink null + daytime 13/tcp + daytime 13/udp + chargen 19/tcp ttytst source + chargen 19/udp ttytst source + ftp 21/tcp + telnet 23/tcp + smtp 25/tcp mail + finger 79/tcp + www 80/tcp http # WorldWideWeb HTTP + www 80/udp # HyperText Transfer Protocol + pop-2 109/tcp postoffice # POP version 2 + pop-2 109/udp + pop-3 110/tcp # POP version 3 + pop-3 110/udp + nntp 119/tcp readnews untp # USENET News + irc 194/tcp # Internet Relay Chat + irc 194/udp + ... + + Here, you find a list of services that traditional Unix machines +usually support. If your GNU/Linux machine does not do so, it may be +that these services are switched off in some startup script. Systems +running some flavor of Microsoft Windows usually do _not_ support these +services. Nevertheless, it _is_ possible to do networking with `gawk' +on Microsoft Windows.(1) The first column of the file gives the name of +the service, and the second column gives a unique number and the +protocol that one can use to connect to this service. The rest of the +line is treated as a comment. You see that some services (`echo') +support TCP as well as UDP. + + ---------- Footnotes ---------- + + (1) Microsoft preferred to ignore the TCP/IP family of protocols +until 1995. Then came the rise of the Netscape browser as a landmark +"killer application." Microsoft added TCP/IP support and their own +browser to Microsoft Windows 95 at the last minute. They even +back-ported their TCP/IP implementation to Microsoft Windows for +Workgroups 3.11, but it was a rather rudimentary and half-hearted +implementation. Nevertheless, the equivalent of `/etc/services' resides +under `C:\WINNT\system32\drivers\etc\services' on Microsoft Windows 2000 +and Microsoft Windows XP. + + +File: gawkinet.info, Node: Interacting, Next: Setting Up, Prev: Troubleshooting, Up: Using Networking + +2.4 Interacting with a Network Service +====================================== + +The next program makes use of the possibility to really interact with a +network service by printing something into the special file. It asks the +so-called `finger' service if a user of the machine is logged in. When +testing this program, try to change `localhost' to some other machine +name in your local network: + + BEGIN { + NetService = "/inet/tcp/0/localhost/finger" + print "NAME" |& NetService + while ((NetService |& getline) > 0) + print $0 + close(NetService) + } + + After telling the service on the machine which user to look for, the +program repeatedly reads lines that come as a reply. When no more lines +are coming (because the service has closed the connection), the program +also closes the connection. Try replacing `"NAME"' with your login name +(or the name of someone else logged in). For a list of all users +currently logged in, replace NAME with an empty string (`""'). + + The final `close' command could be safely deleted from the above +script, because the operating system closes any open connection by +default when a script reaches the end of execution. In order to avoid +portability problems, it is best to always close connections explicitly. +With the Linux kernel, for example, proper closing results in flushing +of buffers. Letting the close happen by default may result in +discarding buffers. + + When looking at `/etc/services' you may have noticed that the +`daytime' service is also available with `udp'. In the earlier example, +change `tcp' to `udp', and change `finger' to `daytime'. After +starting the modified program, you see the expected day and time +message. The program then hangs, because it waits for more lines +coming from the service. However, they never come. This behavior is a +consequence of the differences between TCP and UDP. When using UDP, +neither party is automatically informed about the other closing the +connection. Continuing to experiment this way reveals many other subtle +differences between TCP and UDP. To avoid such trouble, one should +always remember the advice Douglas E. Comer and David Stevens give in +Volume III of their series `Internetworking With TCP' (page 14): + + When designing client-server applications, beginners are strongly + advised to use TCP because it provides reliable, + connection-oriented communication. Programs only use UDP if the + application protocol handles reliability, the application requires + hardware broadcast or multicast, or the application cannot + tolerate virtual circuit overhead. + + +File: gawkinet.info, Node: Setting Up, Next: Email, Prev: Interacting, Up: Using Networking + +2.5 Setting Up a Service +======================== + +The preceding programs behaved as clients that connect to a server +somewhere on the Internet and request a particular service. Now we set +up such a service to mimic the behavior of the `daytime' service. Such +a server does not know in advance who is going to connect to it over +the network. Therefore, we cannot insert a name for the host to connect +to in our special file name. + + Start the following program in one window. Notice that the service +does not have the name `daytime', but the number `8888'. From looking +at `/etc/services', you know that names like `daytime' are just +mnemonics for predetermined 16-bit integers. Only the system +administrator (`root') could enter our new service into `/etc/services' +with an appropriate name. Also notice that the service name has to be +entered into a different field of the special file name because we are +setting up a server, not a client: + + BEGIN { + print strftime() |& "/inet/tcp/8888/0/0" + close("/inet/tcp/8888/0/0") + } + + Now open another window on the same machine. Copy the client +program given as the first example (*note Establishing a TCP +Connection: TCP Connecting.) to a new file and edit it, changing the +name `daytime' to `8888'. Then start the modified client. You should +get a reply like this: + + Sat Sep 27 19:08:16 CEST 1997 + +Both programs explicitly close the connection. + + Now we will intentionally make a mistake to see what happens when +the name `8888' (the so-called port) is already used by another service. +Start the server program in both windows. The first one works, but the +second one complains that it could not open the connection. Each port +on a single machine can only be used by one server program at a time. +Now terminate the server program and change the name `8888' to `echo'. +After restarting it, the server program does not run any more, and you +know why: there is already an `echo' service running on your machine. +But even if this isn't true, you would not get your own `echo' server +running on a Unix machine, because the ports with numbers smaller than +1024 (`echo' is at port 7) are reserved for `root'. On machines +running some flavor of Microsoft Windows, there is no restriction that +reserves ports 1 to 1024 for a privileged user; hence, you can start an +`echo' server there. + + Turning this short server program into something really useful is +simple. Imagine a server that first reads a file name from the client +through the network connection, then does something with the file and +sends a result back to the client. The server-side processing could be: + + BEGIN { + NetService = "/inet/tcp/8888/0/0" + NetService |& getline + CatPipe = ("cat " $1) # sets $0 and the fields + while ((CatPipe | getline) > 0) + print $0 |& NetService + close(NetService) + } + +and we would have a remote copying facility. Such a server reads the +name of a file from any client that connects to it and transmits the +contents of the named file across the net. The server-side processing +could also be the execution of a command that is transmitted across the +network. From this example, you can see how simple it is to open up a +security hole on your machine. If you allow clients to connect to your +machine and execute arbitrary commands, anyone would be free to do `rm +-rf *'. + + +File: gawkinet.info, Node: Email, Next: Web page, Prev: Setting Up, Up: Using Networking + +2.6 Reading Email +================= + +The distribution of email is usually done by dedicated email servers +that communicate with your machine using special protocols. To receive +email, we will use the Post Office Protocol (POP). Sending can be done +with the much older Simple Mail Transfer Protocol (SMTP). + + When you type in the following program, replace the EMAILHOST by the +name of your local email server. Ask your administrator if the server +has a POP service, and then use its name or number in the program below. +Now the program is ready to connect to your email server, but it will +not succeed in retrieving your mail because it does not yet know your +login name or password. Replace them in the program and it shows you +the first email the server has in store: + + BEGIN { + POPService = "/inet/tcp/0/EMAILHOST/pop3" + RS = ORS = "\r\n" + print "user NAME" |& POPService + POPService |& getline + print "pass PASSWORD" |& POPService + POPService |& getline + print "retr 1" |& POPService + POPService |& getline + if ($1 != "+OK") exit + print "quit" |& POPService + RS = "\r\n\\.\r\n" + POPService |& getline + print $0 + close(POPService) + } + + The record separators `RS' and `ORS' are redefined because the +protocol (POP) requires CR-LF to separate lines. After identifying +yourself to the email service, the command `retr 1' instructs the +service to send the first of all your email messages in line. If the +service replies with something other than `+OK', the program exits; +maybe there is no email. Otherwise, the program first announces that it +intends to finish reading email, and then redefines `RS' in order to +read the entire email as multiline input in one record. From the POP +RFC, we know that the body of the email always ends with a single line +containing a single dot. The program looks for this using `RS = +"\r\n\\.\r\n"'. When it finds this sequence in the mail message, it +quits. You can invoke this program as often as you like; it does not +delete the message it reads, but instead leaves it on the server. + + +File: gawkinet.info, Node: Web page, Next: Primitive Service, Prev: Email, Up: Using Networking + +2.7 Reading a Web Page +====================== + +Retrieving a web page from a web server is as simple as retrieving +email from an email server. We only have to use a similar, but not +identical, protocol and a different port. The name of the protocol is +HyperText Transfer Protocol (HTTP) and the port number is usually 80. +As in the preceding node, ask your administrator about the name of your +local web server or proxy web server and its port number for HTTP +requests. + + The following program employs a rather crude approach toward +retrieving a web page. It uses the prehistoric syntax of HTTP 0.9, +which almost all web servers still support. The most noticeable thing +about it is that the program directs the request to the local proxy +server whose name you insert in the special file name (which in turn +calls `www.yahoo.com'): + + BEGIN { + RS = ORS = "\r\n" + HttpService = "/inet/tcp/0/PROXY/80" + print "GET http://www.yahoo.com" |& HttpService + while ((HttpService |& getline) > 0) + print $0 + close(HttpService) + } + + Again, lines are separated by a redefined `RS' and `ORS'. The `GET' +request that we send to the server is the only kind of HTTP request +that existed when the web was created in the early 1990s. HTTP calls +this `GET' request a "method," which tells the service to transmit a +web page (here the home page of the Yahoo! search engine). Version 1.0 +added the request methods `HEAD' and `POST'. The current version of +HTTP is 1.1,(1) and knows the additional request methods `OPTIONS', +`PUT', `DELETE', and `TRACE'. You can fill in any valid web address, +and the program prints the HTML code of that page to your screen. + + Notice the similarity between the responses of the POP and HTTP +services. First, you get a header that is terminated by an empty line, +and then you get the body of the page in HTML. The lines of the +headers also have the same form as in POP. There is the name of a +parameter, then a colon, and finally the value of that parameter. + + Images (`.png' or `.gif' files) can also be retrieved this way, but +then you get binary data that should be redirected into a file. Another +application is calling a CGI (Common Gateway Interface) script on some +server. CGI scripts are used when the contents of a web page are not +constant, but generated instantly at the moment you send a request for +the page. For example, to get a detailed report about the current +quotes of Motorola stock shares, call a CGI script at Yahoo! with the +following: + + get = "GET http://quote.yahoo.com/q?s=MOT&d=t" + print get |& HttpService + + You can also request weather reports this way. + + ---------- Footnotes ---------- + + (1) Version 1.0 of HTTP was defined in RFC 1945. HTTP 1.1 was +initially specified in RFC 2068. In June 1999, RFC 2068 was made +obsolete by RFC 2616, an update without any substantial changes. + + +File: gawkinet.info, Node: Primitive Service, Next: Interacting Service, Prev: Web page, Up: Using Networking + +2.8 A Primitive Web Service +=========================== + +Now we know enough about HTTP to set up a primitive web service that +just says `"Hello, world"' when someone connects to it with a browser. +Compared to the situation in the preceding node, our program changes +the role. It tries to behave just like the server we have observed. +Since we are setting up a server here, we have to insert the port +number in the `localport' field of the special file name. The other two +fields (HOSTNAME and REMOTEPORT) have to contain a `0' because we do +not know in advance which host will connect to our service. + + In the early 1990s, all a server had to do was send an HTML document +and close the connection. Here, we adhere to the modern syntax of HTTP. +The steps are as follows: + + 1. Send a status line telling the web browser that everything is okay. + + 2. Send a line to tell the browser how many bytes follow in the body + of the message. This was not necessary earlier because both + parties knew that the document ended when the connection closed. + Nowadays it is possible to stay connected after the transmission + of one web page. This is to avoid the network traffic necessary + for repeatedly establishing TCP connections for requesting several + images. Thus, there is the need to tell the receiving party how + many bytes will be sent. The header is terminated as usual with an + empty line. + + 3. Send the `"Hello, world"' body in HTML. The useless `while' loop + swallows the request of the browser. We could actually omit the + loop, and on most machines the program would still work. First, + start the following program: + + BEGIN { + RS = ORS = "\r\n" + HttpService = "/inet/tcp/8080/0/0" + Hello = "" \ + "A Famous Greeting" \ + "

Hello, world

" + Len = length(Hello) + length(ORS) + print "HTTP/1.0 200 OK" |& HttpService + print "Content-Length: " Len ORS |& HttpService + print Hello |& HttpService + while ((HttpService |& getline) > 0) + continue; + close(HttpService) + } + + Now, on the same machine, start your favorite browser and let it +point to `http://localhost:8080' (the browser needs to know on which +port our server is listening for requests). If this does not work, the +browser probably tries to connect to a proxy server that does not know +your machine. If so, change the browser's configuration so that the +browser does not try to use a proxy to connect to your machine. + + +File: gawkinet.info, Node: Interacting Service, Next: Simple Server, Prev: Primitive Service, Up: Using Networking + +2.9 A Web Service with Interaction +================================== + +This node shows how to set up a simple web server. The subnode is a +library file that we will use with all the examples in *note Some +Applications and Techniques::. + +* Menu: + +* CGI Lib:: A simple CGI library. + + Setting up a web service that allows user interaction is more +difficult and shows us the limits of network access in `gawk'. In this +node, we develop a main program (a `BEGIN' pattern and its action) +that will become the core of event-driven execution controlled by a +graphical user interface (GUI). Each HTTP event that the user triggers +by some action within the browser is received in this central +procedure. Parameters and menu choices are extracted from this request, +and an appropriate measure is taken according to the user's choice. +For example: + + BEGIN { + if (MyHost == "") { + "uname -n" | getline MyHost + close("uname -n") + } + if (MyPort == 0) MyPort = 8080 + HttpService = "/inet/tcp/" MyPort "/0/0" + MyPrefix = "http://" MyHost ":" MyPort + SetUpServer() + while ("awk" != "complex") { + # header lines are terminated this way + RS = ORS = "\r\n" + Status = 200 # this means OK + Reason = "OK" + Header = TopHeader + Document = TopDoc + Footer = TopFooter + if (GETARG["Method"] == "GET") { + HandleGET() + } else if (GETARG["Method"] == "HEAD") { + # not yet implemented + } else if (GETARG["Method"] != "") { + print "bad method", GETARG["Method"] + } + Prompt = Header Document Footer + print "HTTP/1.0", Status, Reason |& HttpService + print "Connection: Close" |& HttpService + print "Pragma: no-cache" |& HttpService + len = length(Prompt) + length(ORS) + print "Content-length:", len |& HttpService + print ORS Prompt |& HttpService + # ignore all the header lines + while ((HttpService |& getline) > 0) + ; + # stop talking to this client + close(HttpService) + # wait for new client request + HttpService |& getline + # do some logging + print systime(), strftime(), $0 + # read request parameters + CGI_setup($1, $2, $3) + } + } + + This web server presents menu choices in the form of HTML links. +Therefore, it has to tell the browser the name of the host it is +residing on. When starting the server, the user may supply the name of +the host from the command line with `gawk -v MyHost="Rumpelstilzchen"'. +If the user does not do this, the server looks up the name of the host +it is running on for later use as a web address in HTML documents. The +same applies to the port number. These values are inserted later into +the HTML content of the web pages to refer to the home system. + + Each server that is built around this core has to initialize some +application-dependent variables (such as the default home page) in a +procedure `SetUpServer', which is called immediately before entering the +infinite loop of the server. For now, we will write an instance that +initiates a trivial interaction. With this home page, the client user +can click on two possible choices, and receive the current date either +in human-readable format or in seconds since 1970: + + function SetUpServer() { + TopHeader = "" + TopHeader = TopHeader \ + "My name is GAWK, GNU AWK" + TopDoc = "

\ + Do you prefer your date human or \ + POSIXed?

" ORS ORS + TopFooter = "" + } + + On the first run through the main loop, the default line terminators +are set and the default home page is copied to the actual home page. +Since this is the first run, `GETARG["Method"]' is not initialized yet, +hence the case selection over the method does nothing. Now that the +home page is initialized, the server can start communicating to a +client browser. + + It does so by printing the HTTP header into the network connection +(`print ... |& HttpService'). This command blocks execution of the +server script until a client connects. If this server script is +compared with the primitive one we wrote before, you will notice two +additional lines in the header. The first instructs the browser to +close the connection after each request. The second tells the browser +that it should never try to _remember_ earlier requests that had +identical web addresses (no caching). Otherwise, it could happen that +the browser retrieves the time of day in the previous example just once, +and later it takes the web page from the cache, always displaying the +same time of day although time advances each second. + + Having supplied the initial home page to the browser with a valid +document stored in the parameter `Prompt', it closes the connection and +waits for the next request. When the request comes, a log line is +printed that allows us to see which request the server receives. The +final step in the loop is to call the function `CGI_setup', which reads +all the lines of the request (coming from the browser), processes them, +and stores the transmitted parameters in the array `PARAM'. The complete +text of these application-independent functions can be found in *note A +Simple CGI Library: CGI Lib. For now, we use a simplified version of +`CGI_setup': + + function CGI_setup( method, uri, version, i) { + delete GETARG; delete MENU; delete PARAM + GETARG["Method"] = $1 + GETARG["URI"] = $2 + GETARG["Version"] = $3 + i = index($2, "?") + # is there a "?" indicating a CGI request? + if (i > 0) { + split(substr($2, 1, i-1), MENU, "[/:]") + split(substr($2, i+1), PARAM, "&") + for (i in PARAM) { + j = index(PARAM[i], "=") + GETARG[substr(PARAM[i], 1, j-1)] = \ + substr(PARAM[i], j+1) + } + } else { # there is no "?", no need for splitting PARAMs + split($2, MENU, "[/:]") + } + } + + At first, the function clears all variables used for global storage +of request parameters. The rest of the function serves the purpose of +filling the global parameters with the extracted new values. To +accomplish this, the name of the requested resource is split into parts +and stored for later evaluation. If the request contains a `?', then +the request has CGI variables seamlessly appended to the web address. +Everything in front of the `?' is split up into menu items, and +everything behind the `?' is a list of `VARIABLE=VALUE' pairs +(separated by `&') that also need splitting. This way, CGI variables are +isolated and stored. This procedure lacks recognition of special +characters that are transmitted in coded form(1). Here, any optional +request header and body parts are ignored. We do not need header +parameters and the request body. However, when refining our approach or +working with the `POST' and `PUT' methods, reading the header and body +becomes inevitable. Header parameters should then be stored in a global +array as well as the body. + + On each subsequent run through the main loop, one request from a +browser is received, evaluated, and answered according to the user's +choice. This can be done by letting the value of the HTTP method guide +the main loop into execution of the procedure `HandleGET', which +evaluates the user's choice. In this case, we have only one +hierarchical level of menus, but in the general case, menus are nested. +The menu choices at each level are separated by `/', just as in file +names. Notice how simple it is to construct menus of arbitrary depth: + + function HandleGET() { + if ( MENU[2] == "human") { + Footer = strftime() TopFooter + } else if (MENU[2] == "POSIX") { + Footer = systime() TopFooter + } + } + + The disadvantage of this approach is that our server is slow and can +handle only one request at a time. Its main advantage, however, is that +the server consists of just one `gawk' program. No need for installing +an `httpd', and no need for static separate HTML files, CGI scripts, or +`root' privileges. This is rapid prototyping. This program can be +started on the same host that runs your browser. Then let your browser +point to `http://localhost:8080'. + + It is also possible to include images into the HTML pages. Most +browsers support the not very well-known `.xbm' format, which may +contain only monochrome pictures but is an ASCII format. Binary images +are possible but not so easy to handle. Another way of including images +is to generate them with a tool such as GNUPlot, by calling the tool +with the `system' function or through a pipe. + + ---------- Footnotes ---------- + + (1) As defined in RFC 2068. + + +File: gawkinet.info, Node: CGI Lib, Prev: Interacting Service, Up: Interacting Service + +2.9.1 A Simple CGI Library +-------------------------- + + HTTP is like being married: you have to be able to handle whatever + you're given, while being very careful what you send back. + Phil Smith III, + `http://www.netfunny.com/rhf/jokes/99/Mar/http.html' + + In *note A Web Service with Interaction: Interacting Service, we saw +the function `CGI_setup' as part of the web server "core logic" +framework. The code presented there handles almost everything necessary +for CGI requests. One thing it doesn't do is handle encoded characters +in the requests. For example, an `&' is encoded as a percent sign +followed by the hexadecimal value: `%26'. These encoded values should +be decoded. Following is a simple library to perform these tasks. +This code is used for all web server examples used throughout the rest +of this Info file. If you want to use it for your own web server, +store the source code into a file named `inetlib.awk'. Then you can +include these functions into your code by placing the following +statement into your program (on the first line of your script): + + @include inetlib.awk + +But beware, this mechanism is only possible if you invoke your web +server script with `igawk' instead of the usual `awk' or `gawk'. Here +is the code: + + # CGI Library and core of a web server + # Global arrays + # GETARG --- arguments to CGI GET command + # MENU --- menu items (path names) + # PARAM --- parameters of form x=y + + # Optional variable MyHost contains host address + # Optional variable MyPort contains port number + # Needs TopHeader, TopDoc, TopFooter + # Sets MyPrefix, HttpService, Status, Reason + + BEGIN { + if (MyHost == "") { + "uname -n" | getline MyHost + close("uname -n") + } + if (MyPort == 0) MyPort = 8080 + HttpService = "/inet/tcp/" MyPort "/0/0" + MyPrefix = "http://" MyHost ":" MyPort + SetUpServer() + while ("awk" != "complex") { + # header lines are terminated this way + RS = ORS = "\r\n" + Status = 200 # this means OK + Reason = "OK" + Header = TopHeader + Document = TopDoc + Footer = TopFooter + if (GETARG["Method"] == "GET") { + HandleGET() + } else if (GETARG["Method"] == "HEAD") { + # not yet implemented + } else if (GETARG["Method"] != "") { + print "bad method", GETARG["Method"] + } + Prompt = Header Document Footer + print "HTTP/1.0", Status, Reason |& HttpService + print "Connection: Close" |& HttpService + print "Pragma: no-cache" |& HttpService + len = length(Prompt) + length(ORS) + print "Content-length:", len |& HttpService + print ORS Prompt |& HttpService + # ignore all the header lines + while ((HttpService |& getline) > 0) + continue + # stop talking to this client + close(HttpService) + # wait for new client request + HttpService |& getline + # do some logging + print systime(), strftime(), $0 + CGI_setup($1, $2, $3) + } + } + + function CGI_setup( method, uri, version, i) + { + delete GETARG + delete MENU + delete PARAM + GETARG["Method"] = method + GETARG["URI"] = uri + GETARG["Version"] = version + + i = index(uri, "?") + if (i > 0) { # is there a "?" indicating a CGI request? + split(substr(uri, 1, i-1), MENU, "[/:]") + split(substr(uri, i+1), PARAM, "&") + for (i in PARAM) { + PARAM[i] = _CGI_decode(PARAM[i]) + j = index(PARAM[i], "=") + GETARG[substr(PARAM[i], 1, j-1)] = \ + substr(PARAM[i], j+1) + } + } else { # there is no "?", no need for splitting PARAMs + split(uri, MENU, "[/:]") + } + for (i in MENU) # decode characters in path + if (i > 4) # but not those in host name + MENU[i] = _CGI_decode(MENU[i]) + } + + This isolates details in a single function, `CGI_setup'. Decoding +of encoded characters is pushed off to a helper function, +`_CGI_decode'. The use of the leading underscore (`_') in the function +name is intended to indicate that it is an "internal" function, +although there is nothing to enforce this: + + function _CGI_decode(str, hexdigs, i, pre, code1, code2, + val, result) + { + hexdigs = "123456789abcdef" + + i = index(str, "%") + if (i == 0) # no work to do + return str + + do { + pre = substr(str, 1, i-1) # part before %xx + code1 = substr(str, i+1, 1) # first hex digit + code2 = substr(str, i+2, 1) # second hex digit + str = substr(str, i+3) # rest of string + + code1 = tolower(code1) + code2 = tolower(code2) + val = index(hexdigs, code1) * 16 \ + + index(hexdigs, code2) + + result = result pre sprintf("%c", val) + i = index(str, "%") + } while (i != 0) + if (length(str) > 0) + result = result str + return result + } + + This works by splitting the string apart around an encoded character. +The two digits are converted to lowercase characters and looked up in a +string of hex digits. Note that `0' is not in the string on purpose; +`index' returns zero when it's not found, automatically giving the +correct value! Once the hexadecimal value is converted from characters +in a string into a numerical value, `sprintf' converts the value back +into a real character. The following is a simple test harness for the +above functions: + + BEGIN { + CGI_setup("GET", + "http://www.gnu.org/cgi-bin/foo?p1=stuff&p2=stuff%26junk" \ + "&percent=a %25 sign", + "1.0") + for (i in MENU) + printf "MENU[\"%s\"] = %s\n", i, MENU[i] + for (i in PARAM) + printf "PARAM[\"%s\"] = %s\n", i, PARAM[i] + for (i in GETARG) + printf "GETARG[\"%s\"] = %s\n", i, GETARG[i] + } + + And this is the result when we run it: + + $ gawk -f testserv.awk + -| MENU["4"] = www.gnu.org + -| MENU["5"] = cgi-bin + -| MENU["6"] = foo + -| MENU["1"] = http + -| MENU["2"] = + -| MENU["3"] = + -| PARAM["1"] = p1=stuff + -| PARAM["2"] = p2=stuff&junk + -| PARAM["3"] = percent=a % sign + -| GETARG["p1"] = stuff + -| GETARG["percent"] = a % sign + -| GETARG["p2"] = stuff&junk + -| GETARG["Method"] = GET + -| GETARG["Version"] = 1.0 + -| GETARG["URI"] = http://www.gnu.org/cgi-bin/foo?p1=stuff& + p2=stuff%26junk&percent=a %25 sign + + +File: gawkinet.info, Node: Simple Server, Next: Caveats, Prev: Interacting Service, Up: Using Networking + +2.10 A Simple Web Server +======================== + +In the preceding node, we built the core logic for event-driven GUIs. +In this node, we finally extend the core to a real application. No one +would actually write a commercial web server in `gawk', but it is +instructive to see that it is feasible in principle. + + The application is ELIZA, the famous program by Joseph Weizenbaum +that mimics the behavior of a professional psychotherapist when talking +to you. Weizenbaum would certainly object to this description, but +this is part of the legend around ELIZA. Take the site-independent +core logic and append the following code: + + function SetUpServer() { + SetUpEliza() + TopHeader = \ + "An HTTP-based System with GAWK\ + \ + " + TopDoc = "\ +

Please choose one of the following actions:

\ +
" + TopFooter = "" + } + + `SetUpServer' is similar to the previous example, except for calling +another function, `SetUpEliza'. This approach can be used to implement +other kinds of servers. The only changes needed to do so are hidden in +the functions `SetUpServer' and `HandleGET'. Perhaps it might be +necessary to implement other HTTP methods. The `igawk' program that +comes with `gawk' may be useful for this process. + + When extending this example to a complete application, the first +thing to do is to implement the function `SetUpServer' to initialize +the HTML pages and some variables. These initializations determine the +way your HTML pages look (colors, titles, menu items, etc.). + + The function `HandleGET' is a nested case selection that decides +which page the user wants to see next. Each nesting level refers to a +menu level of the GUI. Each case implements a certain action of the +menu. On the deepest level of case selection, the handler essentially +knows what the user wants and stores the answer into the variable that +holds the HTML page contents: + + function HandleGET() { + # A real HTTP server would treat some parts of the URI as a file name. + # We take parts of the URI as menu choices and go on accordingly. + if(MENU[2] == "AboutServer") { + Document = "This is not a CGI script.\ + This is an httpd, an HTML file, and a CGI script all \ + in one GAWK script. It needs no separate www-server, \ + no installation, and no root privileges.\ +

To run it, do this:

    \ +
  • start this script with \"gawk -f httpserver.awk\",
  • \ +
  • and on the same host let your www browser open location\ + \"http://localhost:8080\"
  • \ +
\

\ Details of HTTP come from:

    \ +
  • Hethmon: Illustrated Guide to HTTP

    \ +
  • RFC 2068

JK 14.9.1997

" + } else if (MENU[2] == "AboutELIZA") { + Document = "This is an implementation of the famous ELIZA\ + program by Joseph Weizenbaum. It is written in GAWK and\ + uses an HTML GUI." + } else if (MENU[2] == "StartELIZA") { + gsub(/\+/, " ", GETARG["YouSay"]) + # Here we also have to substitute coded special characters + Document = "
" \ + "

" ElizaSays(GETARG["YouSay"]) "

\ +

\ +

" + } + } + + Now we are down to the heart of ELIZA, so you can see how it works. +Initially the user does not say anything; then ELIZA resets its money +counter and asks the user to tell what comes to mind open heartedly. +The subsequent answers are converted to uppercase characters and stored +for later comparison. ELIZA presents the bill when being confronted with +a sentence that contains the phrase "shut up." Otherwise, it looks for +keywords in the sentence, conjugates the rest of the sentence, remembers +the keyword for later use, and finally selects an answer from the set of +possible answers: + + function ElizaSays(YouSay) { + if (YouSay == "") { + cost = 0 + answer = "HI, IM ELIZA, TELL ME YOUR PROBLEM" + } else { + q = toupper(YouSay) + gsub("'", "", q) + if(q == qold) { + answer = "PLEASE DONT REPEAT YOURSELF !" + } else { + if (index(q, "SHUT UP") > 0) { + answer = "WELL, PLEASE PAY YOUR BILL. ITS EXACTLY ... $"\ + int(100*rand()+30+cost/100) + } else { + qold = q + w = "-" # no keyword recognized yet + for (i in k) { # search for keywords + if (index(q, i) > 0) { + w = i + break + } + } + if (w == "-") { # no keyword, take old subject + w = wold + subj = subjold + } else { # find subject + subj = substr(q, index(q, w) + length(w)+1) + wold = w + subjold = subj # remember keyword and subject + } + for (i in conj) + gsub(i, conj[i], q) # conjugation + # from all answers to this keyword, select one randomly + answer = r[indices[int(split(k[w], indices) * rand()) + 1]] + # insert subject into answer + gsub("_", subj, answer) + } + } + } + cost += length(answer) # for later payment : 1 cent per character + return answer + } + + In the long but simple function `SetUpEliza', you can see tables for +conjugation, keywords, and answers.(1) The associative array `k' +contains indices into the array of answers `r'. To choose an answer, +ELIZA just picks an index randomly: + + function SetUpEliza() { + srand() + wold = "-" + subjold = " " + + # table for conjugation + conj[" ARE " ] = " AM " + conj["WERE " ] = "WAS " + conj[" YOU " ] = " I " + conj["YOUR " ] = "MY " + conj[" IVE " ] =\ + conj[" I HAVE " ] = " YOU HAVE " + conj[" YOUVE " ] =\ + conj[" YOU HAVE "] = " I HAVE " + conj[" IM " ] =\ + conj[" I AM " ] = " YOU ARE " + conj[" YOURE " ] =\ + conj[" YOU ARE " ] = " I AM " + + # table of all answers + r[1] = "DONT YOU BELIEVE THAT I CAN _" + r[2] = "PERHAPS YOU WOULD LIKE TO BE ABLE TO _ ?" + ... + + # table for looking up answers that + # fit to a certain keyword + k["CAN YOU"] = "1 2 3" + k["CAN I"] = "4 5" + k["YOU ARE"] =\ + k["YOURE"] = "6 7 8 9" + ... + + } + + Some interesting remarks and details (including the original source +code of ELIZA) are found on Mark Humphrys' home page. Yahoo! also has +a page with a collection of ELIZA-like programs. Many of them are +written in Java, some of them disclosing the Java source code, and a +few even explain how to modify the Java source code. + + ---------- Footnotes ---------- + + (1) The version shown here is abbreviated. The full version comes +with the `gawk' distribution. + + +File: gawkinet.info, Node: Caveats, Next: Challenges, Prev: Simple Server, Up: Using Networking + +2.11 Network Programming Caveats +================================ + +By now it should be clear that debugging a networked application is more +complicated than debugging a single-process single-hosted application. +The behavior of a networked application sometimes looks noncausal +because it is not reproducible in a strong sense. Whether a network +application works or not sometimes depends on the following: + + * How crowded the underlying network is + + * If the party at the other end is running or not + + * The state of the party at the other end + + The most difficult problems for a beginner arise from the hidden +states of the underlying network. After closing a TCP connection, it's +often necessary to wait a short while before reopening the connection. +Even more difficult is the establishment of a connection that +previously ended with a "broken pipe." Those connections have to "time +out" for a minute or so before they can reopen. Check this with the +command `netstat -a', which provides a list of still "active" +connections. + + +File: gawkinet.info, Node: Challenges, Prev: Caveats, Up: Using Networking + +2.12 Where To Go From Here +========================== + +Now, you have learned enough to build your own application. You could, +for example, take part in the Loebner Contest to win $100,000. The +Loebner Prize is the first formal instantiation of a Turing Test. Hugh +Loebner agreed with The Cambridge Center for Behavioral Studies to +underwrite a contest designed to implement the Turing Test. Dr. +Loebner pledged a Grand Prize of $100,000 for the first computer whose +responses were indistinguishable from a human's. Each year an annual +prize of $2000 and a bronze medal is awarded to the _most_ human +computer. The winner of the annual contest is the best entry relative +to other entries that year, irrespective of how good it is in an +absolute sense. Here is an example of a conversation with the winning +program of 1997: + + (c)1997 Cambridge Center For Behavioral Studies all rights reserved [CONVERSE] + [Intelligent Research Ltd.] Start at: [1997/04/29 08:59:40] + PROGRAM[10:39:20]Hi, my name is Catherine, what's yours? + JUDGE02[10:39:36]My name is Nathan. + PROGRAM[10:39:37]Well, it's nice to meet you, Nathan. + PROGRAM[10:39:45]Did you see that story on CNN last night about the lesbian + PROGRAM[10:40:03]couple who came out at a White House party on Sunday? + JUDGE02[10:40:45]No. I'm sorry I missed that. How did the Prez take it? + PROGRAM[10:40:47]Ellen Degeneres was one of them - she was kissing her lover + PROGRAM[10:41:08]in front of Bill Clinton. Do you think he was very + PROGRAM[10:41:21]embarrassed? + JUDGE02[10:41:37]You tell me. I didn't see it. + PROGRAM[10:41:38]Are you still a Friend of Bill Clinton? + JUDGE02[10:42:22]Yes. I would like to talk about something else. Do you know anything about sculpture. + PROGRAM[10:42:24]Well, I suppose he's doing his best like most of us, but he + PROGRAM[10:42:35]does seem to attract an UNUSUAL amount of bad publicity, + PROGRAM[10:42:51]wouldnt you say--can it all be bad luck? + JUDGE02[10:43:20]I asked you if you knew anything about sculpture. + PROGRAM[10:43:21]OK, but what happens now--does it all drift on, with + PROGRAM[10:43:36]everyone waiting to see how much his friends have said about + PROGRAM[10:43:47]him under threat of lots and lots of jail-or will something + PROGRAM[10:44:01]dramatic actually happen? + JUDGE02[10:44:19]Do you know what sculpture is? + PROGRAM[10:44:20]Well, youre more a fan of his than I am I guess---though I + PROGRAM[10:44:34]cant SWEAR what Id have done in that locked hotel room, I + PROGRAM[10:44:51]must say. + JUDGE02[10:45:26]Have you ever been to the Salmagundi Club? + PROGRAM[10:45:29]Never. to go back to the original discussion Time to get + PROGRAM[10:45:43]off this one I think and onto something more down to earth! + JUDGE02[10:46:20]What is more down to earth than art? + PROGRAM[10:46:21]I don't know what -- to be honest. - + PROGRAM[10:46:30]I suppose it depends on where you're coming from, but as the + PROGRAM[10:46:46]song goes in My Fair Lady, "Why can't a woman be more like a + PROGRAM[10:47:03]man? " + JUDGE02[10:47:52]I liked that song but I prefer "Why can't children be more like we are" + JUDGE02[10:48:10]from another play the name of which I cannot remember. + PROGRAM[10:48:12]What, if anything, do you enjoy about being a man? + JUDGE02[10:49:01]I would enjoy all aspects of life no matter what my gender. + PROGRAM[10:49:02]Do you think of yourself as being attractive? + + This program insists on always speaking about the same story around +Bill Clinton. You see, even a program with a rather narrow mind can +behave so much like a human being that it can win this prize. It is +quite common to let these programs talk to each other via network +connections. But during the competition itself, the program and its +computer have to be present at the place the competition is held. We +all would love to see a `gawk' program win in such an event. Maybe it +is up to you to accomplish this? + + Some other ideas for useful networked applications: + * Read the file `doc/awkforai.txt' in the `gawk' distribution. It + was written by Ronald P. Loui (at the time, Associate Professor of + Computer Science, at Washington University in St. Louis, + ) and summarizes why he taught `gawk' to + students of Artificial Intelligence. Here are some passages from + the text: + + The GAWK manual can be consumed in a single lab session and + the language can be mastered by the next morning by the + average student. GAWK's automatic initialization, implicit + coercion, I/O support and lack of pointers forgive many of + the mistakes that young programmers are likely to make. + Those who have seen C but not mastered it are happy to see + that GAWK retains some of the same sensibilities while adding + what must be regarded as spoonsful of syntactic sugar. + ... + There are further simple answers. Probably the best is the + fact that increasingly, undergraduate AI programming is + involving the Web. Oren Etzioni (University of Washington, + Seattle) has for a while been arguing that the "softbot" is + replacing the mechanical engineers' robot as the most + glamorous AI testbed. If the artifact whose behavior needs + to be controlled in an intelligent way is the software agent, + then a language that is well-suited to controlling the + software environment is the appropriate language. That would + imply a scripting language. If the robot is KAREL, then the + right language is "turn left; turn right." If the robot is + Netscape, then the right language is something that can + generate `netscape -remote + 'openURL(http://cs.wustl.edu/~loui)'' with elan. + ... + AI programming requires high-level thinking. There have + always been a few gifted programmers who can write high-level + programs in assembly language. Most however need the ambient + abstraction to have a higher floor. + ... + Second, inference is merely the expansion of notation. No + matter whether the logic that underlies an AI program is + fuzzy, probabilistic, deontic, defeasible, or deductive, the + logic merely defines how strings can be transformed into + other strings. A language that provides the best support for + string processing in the end provides the best support for + logic, for the exploration of various logics, and for most + forms of symbolic processing that AI might choose to call + "reasoning" instead of "logic." The implication is that + PROLOG, which saves the AI programmer from having to write a + unifier, saves perhaps two dozen lines of GAWK code at the + expense of strongly biasing the logic and representational + expressiveness of any approach. + + Now that `gawk' itself can connect to the Internet, it should be + obvious that it is suitable for writing intelligent web agents. + + * `awk' is strong at pattern recognition and string processing. So, + it is well suited to the classic problem of language translation. + A first try could be a program that knows the 100 most frequent + English words and their counterparts in German or French. The + service could be implemented by regularly reading email with the + program above, replacing each word by its translation and sending + the translation back via SMTP. Users would send English email to + their translation service and get back a translated email message + in return. As soon as this works, more effort can be spent on a + real translation program. + + * Another dialogue-oriented application (on the verge of ridicule) + is the email "support service." Troubled customers write an email + to an automatic `gawk' service that reads the email. It looks for + keywords in the mail and assembles a reply email accordingly. By + carefully investigating the email header, and repeating these + keywords through the reply email, it is rather simple to give the + customer a feeling that someone cares. Ideally, such a service + would search a database of previous cases for solutions. If none + exists, the database could, for example, consist of all the + newsgroups, mailing lists and FAQs on the Internet. + + +File: gawkinet.info, Node: Some Applications and Techniques, Next: Links, Prev: Using Networking, Up: Top + +3 Some Applications and Techniques +********************************** + +In this major node, we look at a number of self-contained scripts, with +an emphasis on concise networking. Along the way, we work towards +creating building blocks that encapsulate often needed functions of the +networking world, show new techniques that broaden the scope of +problems that can be solved with `gawk', and explore leading edge +technology that may shape the future of networking. + + We often refer to the site-independent core of the server that we +built in *note A Simple Web Server: Simple Server. When building new +and nontrivial servers, we always copy this building block and append +new instances of the two functions `SetUpServer' and `HandleGET'. + + This makes a lot of sense, since this scheme of event-driven +execution provides `gawk' with an interface to the most widely accepted +standard for GUIs: the web browser. Now, `gawk' can rival even Tcl/Tk. + + Tcl and `gawk' have much in common. Both are simple scripting +languages that allow us to quickly solve problems with short programs. +But Tcl has Tk on top of it, and `gawk' had nothing comparable up to +now. While Tcl needs a large and ever-changing library (Tk, which was +bound to the X Window System until recently), `gawk' needs just the +networking interface and some kind of browser on the client's side. +Besides better portability, the most important advantage of this +approach (embracing well-established standards such HTTP and HTML) is +that _we do not need to change the language_. We let others do the work +of fighting over protocols and standards. We can use HTML, JavaScript, +VRML, or whatever else comes along to do our work. + +* Menu: + +* PANIC:: An Emergency Web Server. +* GETURL:: Retrieving Web Pages. +* REMCONF:: Remote Configuration Of Embedded Systems. +* URLCHK:: Look For Changed Web Pages. +* WEBGRAB:: Extract Links From A Page. +* STATIST:: Graphing A Statistical Distribution. +* MAZE:: Walking Through A Maze In Virtual Reality. +* MOBAGWHO:: A Simple Mobile Agent. +* STOXPRED:: Stock Market Prediction As A Service. +* PROTBASE:: Searching Through A Protein Database. + + +File: gawkinet.info, Node: PANIC, Next: GETURL, Prev: Some Applications and Techniques, Up: Some Applications and Techniques + +3.1 PANIC: An Emergency Web Server +================================== + +At first glance, the `"Hello, world"' example in *note A Primitive Web +Service: Primitive Service, seems useless. By adding just a few lines, +we can turn it into something useful. + + The PANIC program tells everyone who connects that the local site is +not working. When a web server breaks down, it makes a difference if +customers get a strange "network unreachable" message, or a short +message telling them that the server has a problem. In such an +emergency, the hard disk and everything on it (including the regular +web service) may be unavailable. Rebooting the web server off a +diskette makes sense in this setting. + + To use the PANIC program as an emergency web server, all you need +are the `gawk' executable and the program below on a diskette. By +default, it connects to port 8080. A different value may be supplied on +the command line: + + BEGIN { + RS = ORS = "\r\n" + if (MyPort == 0) MyPort = 8080 + HttpService = "/inet/tcp/" MyPort "/0/0" + Hello = "Out Of Service" \ + "

" \ + "This site is temporarily out of service." \ + "

" + Len = length(Hello) + length(ORS) + while ("awk" != "complex") { + print "HTTP/1.0 200 OK" |& HttpService + print "Content-Length: " Len ORS |& HttpService + print Hello |& HttpService + while ((HttpService |& getline) > 0) + continue; + close(HttpService) + } + } + + +File: gawkinet.info, Node: GETURL, Next: REMCONF, Prev: PANIC, Up: Some Applications and Techniques + +3.2 GETURL: Retrieving Web Pages +================================ + +GETURL is a versatile building block for shell scripts that need to +retrieve files from the Internet. It takes a web address as a +command-line parameter and tries to retrieve the contents of this +address. The contents are printed to standard output, while the header +is printed to `/dev/stderr'. A surrounding shell script could analyze +the contents and extract the text or the links. An ASCII browser could +be written around GETURL. But more interestingly, web robots are +straightforward to write on top of GETURL. On the Internet, you can find +several programs of the same name that do the same job. They are usually +much more complex internally and at least 10 times longer. + + At first, GETURL checks if it was called with exactly one web +address. Then, it checks if the user chose to use a special proxy +server whose name is handed over in a variable. By default, it is +assumed that the local machine serves as proxy. GETURL uses the `GET' +method by default to access the web page. By handing over the name of a +different method (such as `HEAD'), it is possible to choose a different +behavior. With the `HEAD' method, the user does not receive the body of +the page content, but does receive the header: + + BEGIN { + if (ARGC != 2) { + print "GETURL - retrieve Web page via HTTP 1.0" + print "IN:\n the URL as a command-line parameter" + print "PARAM(S):\n -v Proxy=MyProxy" + print "OUT:\n the page content on stdout" + print " the page header on stderr" + print "JK 16.05.1997" + print "ADR 13.08.2000" + exit + } + URL = ARGV[1]; ARGV[1] = "" + if (Proxy == "") Proxy = "127.0.0.1" + if (ProxyPort == 0) ProxyPort = 80 + if (Method == "") Method = "GET" + HttpService = "/inet/tcp/0/" Proxy "/" ProxyPort + ORS = RS = "\r\n\r\n" + print Method " " URL " HTTP/1.0" |& HttpService + HttpService |& getline Header + print Header > "/dev/stderr" + while ((HttpService |& getline) > 0) + printf "%s", $0 + close(HttpService) + } + + This program can be changed as needed, but be careful with the last +lines. Make sure transmission of binary data is not corrupted by +additional line breaks. Even as it is now, the byte sequence +`"\r\n\r\n"' would disappear if it were contained in binary data. Don't +get caught in a trap when trying a quick fix on this one. + + +File: gawkinet.info, Node: REMCONF, Next: URLCHK, Prev: GETURL, Up: Some Applications and Techniques + +3.3 REMCONF: Remote Configuration of Embedded Systems +===================================================== + +Today, you often find powerful processors in embedded systems. +Dedicated network routers and controllers for all kinds of machinery +are examples of embedded systems. Processors like the Intel 80x86 or +the AMD Elan are able to run multitasking operating systems, such as +XINU or GNU/Linux in embedded PCs. These systems are small and usually +do not have a keyboard or a display. Therefore it is difficult to set +up their configuration. There are several widespread ways to set them +up: + + * DIP switches + + * Read Only Memories such as EPROMs + + * Serial lines or some kind of keyboard + + * Network connections via `telnet' or SNMP + + * HTTP connections with HTML GUIs + + In this node, we look at a solution that uses HTTP connections to +control variables of an embedded system that are stored in a file. +Since embedded systems have tight limits on resources like memory, it +is difficult to employ advanced techniques such as SNMP and HTTP +servers. `gawk' fits in quite nicely with its single executable which +needs just a short script to start working. The following program +stores the variables in a file, and a concurrent process in the +embedded system may read the file. The program uses the +site-independent part of the simple web server that we developed in +*note A Web Service with Interaction: Interacting Service. As +mentioned there, all we have to do is to write two new procedures +`SetUpServer' and `HandleGET': + + function SetUpServer() { + TopHeader = "Remote Configuration" + TopDoc = "\ +

Please choose one of the following actions:

\ + " + TopFooter = "" + if (ConfigFile == "") ConfigFile = "config.asc" + } + + The function `SetUpServer' initializes the top level HTML texts as +usual. It also initializes the name of the file that contains the +configuration parameters and their values. In case the user supplies a +name from the command line, that name is used. The file is expected to +contain one parameter per line, with the name of the parameter in +column one and the value in column two. + + The function `HandleGET' reflects the structure of the menu tree as +usual. The first menu choice tells the user what this is all about. The +second choice reads the configuration file line by line and stores the +parameters and their values. Notice that the record separator for this +file is `"\n"', in contrast to the record separator for HTTP. The third +menu choice builds an HTML table to show the contents of the +configuration file just read. The fourth choice does the real work of +changing parameters, and the last one just saves the configuration into +a file: + + function HandleGET() { + if(MENU[2] == "AboutServer") { + Document = "This is a GUI for remote configuration of an\ + embedded system. It is is implemented as one GAWK script." + } else if (MENU[2] == "ReadConfig") { + RS = "\n" + while ((getline < ConfigFile) > 0) + config[$1] = $2; + close(ConfigFile) + RS = "\r\n" + Document = "Configuration has been read." + } else if (MENU[2] == "CheckConfig") { + Document = "" + for (i in config) + Document = Document "" \ + "" + Document = Document "
" i "" config[i] "
" + } else if (MENU[2] == "ChangeConfig") { + if ("Param" in GETARG) { # any parameter to set? + if (GETARG["Param"] in config) { # is parameter valid? + config[GETARG["Param"]] = GETARG["Value"] + Document = (GETARG["Param"] " = " GETARG["Value"] ".") + } else { + Document = "Parameter " GETARG["Param"] " is invalid." + } + } else { + Document = "

Change one parameter

\ + \ + \ + \ + \ +
ParameterValue
" + } + } else if (MENU[2] == "SaveConfig") { + for (i in config) + printf("%s %s\n", i, config[i]) > ConfigFile + close(ConfigFile) + Document = "Configuration has been saved." + } + } + + We could also view the configuration file as a database. From this +point of view, the previous program acts like a primitive database +server. Real SQL database systems also make a service available by +providing a TCP port that clients can connect to. But the application +level protocols they use are usually proprietary and also change from +time to time. This is also true for the protocol that MiniSQL uses. + + +File: gawkinet.info, Node: URLCHK, Next: WEBGRAB, Prev: REMCONF, Up: Some Applications and Techniques + +3.4 URLCHK: Look for Changed Web Pages +====================================== + +Most people who make heavy use of Internet resources have a large +bookmark file with pointers to interesting web sites. It is impossible +to regularly check by hand if any of these sites have changed. A program +is needed to automatically look at the headers of web pages and tell +which ones have changed. URLCHK does the comparison after using GETURL +with the `HEAD' method to retrieve the header. + + Like GETURL, this program first checks that it is called with exactly +one command-line parameter. URLCHK also takes the same command-line +variables `Proxy' and `ProxyPort' as GETURL, because these variables +are handed over to GETURL for each URL that gets checked. The one and +only parameter is the name of a file that contains one line for each +URL. In the first column, we find the URL, and the second and third +columns hold the length of the URL's body when checked for the two last +times. Now, we follow this plan: + + 1. Read the URLs from the file and remember their most recent lengths + + 2. Delete the contents of the file + + 3. For each URL, check its new length and write it into the file + + 4. If the most recent and the new length differ, tell the user + + It may seem a bit peculiar to read the URLs from a file together +with their two most recent lengths, but this approach has several +advantages. You can call the program again and again with the same +file. After running the program, you can regenerate the changed URLs by +extracting those lines that differ in their second and third columns: + + BEGIN { + if (ARGC != 2) { + print "URLCHK - check if URLs have changed" + print "IN:\n the file with URLs as a command-line parameter" + print " file contains URL, old length, new length" + print "PARAMS:\n -v Proxy=MyProxy -v ProxyPort=8080" + print "OUT:\n same as file with URLs" + print "JK 02.03.1998" + exit + } + URLfile = ARGV[1]; ARGV[1] = "" + if (Proxy != "") Proxy = " -v Proxy=" Proxy + if (ProxyPort != "") ProxyPort = " -v ProxyPort=" ProxyPort + while ((getline < URLfile) > 0) + Length[$1] = $3 + 0 + close(URLfile) # now, URLfile is read in and can be updated + GetHeader = "gawk " Proxy ProxyPort " -v Method=\"HEAD\" -f geturl.awk " + for (i in Length) { + GetThisHeader = GetHeader i " 2>&1" + while ((GetThisHeader | getline) > 0) + if (toupper($0) ~ /CONTENT-LENGTH/) NewLength = $2 + 0 + close(GetThisHeader) + print i, Length[i], NewLength > URLfile + if (Length[i] != NewLength) # report only changed URLs + print i, Length[i], NewLength + } + close(URLfile) + } + + Another thing that may look strange is the way GETURL is called. +Before calling GETURL, we have to check if the proxy variables need to +be passed on. If so, we prepare strings that will become part of the +command line later. In `GetHeader', we store these strings together +with the longest part of the command line. Later, in the loop over the +URLs, `GetHeader' is appended with the URL and a redirection operator +to form the command that reads the URL's header over the Internet. +GETURL always produces the headers over `/dev/stderr'. That is the +reason why we need the redirection operator to have the header piped in. + + This program is not perfect because it assumes that changing URLs +results in changed lengths, which is not necessarily true. A more +advanced approach is to look at some other header line that holds time +information. But, as always when things get a bit more complicated, +this is left as an exercise to the reader. + + +File: gawkinet.info, Node: WEBGRAB, Next: STATIST, Prev: URLCHK, Up: Some Applications and Techniques + +3.5 WEBGRAB: Extract Links from a Page +====================================== + +Sometimes it is necessary to extract links from web pages. Browsers do +it, web robots do it, and sometimes even humans do it. Since we have a +tool like GETURL at hand, we can solve this problem with some help from +the Bourne shell: + + BEGIN { RS = "http://[#%&\\+\\-\\./0-9\\:;\\?A-Z_a-z\\~]*" } + RT != "" { + command = ("gawk -v Proxy=MyProxy -f geturl.awk " RT \ + " > doc" NR ".html") + print command + } + + Notice that the regular expression for URLs is rather crude. A +precise regular expression is much more complex. But this one works +rather well. One problem is that it is unable to find internal links of +an HTML document. Another problem is that `ftp', `telnet', `news', +`mailto', and other kinds of links are missing in the regular +expression. However, it is straightforward to add them, if doing so is +necessary for other tasks. + + This program reads an HTML file and prints all the HTTP links that +it finds. It relies on `gawk''s ability to use regular expressions as +record separators. With `RS' set to a regular expression that matches +links, the second action is executed each time a non-empty link is +found. We can find the matching link itself in `RT'. + + The action could use the `system' function to let another GETURL +retrieve the page, but here we use a different approach. This simple +program prints shell commands that can be piped into `sh' for +execution. This way it is possible to first extract the links, wrap +shell commands around them, and pipe all the shell commands into a +file. After editing the file, execution of the file retrieves exactly +those files that we really need. In case we do not want to edit, we can +retrieve all the pages like this: + + gawk -f geturl.awk http://www.suse.de | gawk -f webgrab.awk | sh + + After this, you will find the contents of all referenced documents in +files named `doc*.html' even if they do not contain HTML code. The +most annoying thing is that we always have to pass the proxy to GETURL. +If you do not like to see the headers of the web pages appear on the +screen, you can redirect them to `/dev/null'. Watching the headers +appear can be quite interesting, because it reveals interesting details +such as which web server the companies use. Now, it is clear how the +clever marketing people use web robots to determine the market shares +of Microsoft and Netscape in the web server market. + + Port 80 of any web server is like a small hole in a repellent +firewall. After attaching a browser to port 80, we usually catch a +glimpse of the bright side of the server (its home page). With a tool +like GETURL at hand, we are able to discover some of the more concealed +or even "indecent" services (i.e., lacking conformity to standards of +quality). It can be exciting to see the fancy CGI scripts that lie +there, revealing the inner workings of the server, ready to be called: + + * With a command such as: + + gawk -f geturl.awk http://any.host.on.the.net/cgi-bin/ + + some servers give you a directory listing of the CGI files. + Knowing the names, you can try to call some of them and watch for + useful results. Sometimes there are executables in such directories + (such as Perl interpreters) that you may call remotely. If there + are subdirectories with configuration data of the web server, this + can also be quite interesting to read. + + * The well-known Apache web server usually has its CGI files in the + directory `/cgi-bin'. There you can often find the scripts + `test-cgi' and `printenv'. Both tell you some things about the + current connection and the installation of the web server. Just + call: + + gawk -f geturl.awk http://any.host.on.the.net/cgi-bin/test-cgi + gawk -f geturl.awk http://any.host.on.the.net/cgi-bin/printenv + + * Sometimes it is even possible to retrieve system files like the web + server's log file--possibly containing customer data--or even the + file `/etc/passwd'. (We don't recommend this!) + + *Caution:* Although this may sound funny or simply irrelevant, we +are talking about severe security holes. Try to explore your own system +this way and make sure that none of the above reveals too much +information about your system. + + +File: gawkinet.info, Node: STATIST, Next: MAZE, Prev: WEBGRAB, Up: Some Applications and Techniques + +3.6 STATIST: Graphing a Statistical Distribution +================================================ + +In the HTTP server examples we've shown thus far, we never present an +image to the browser and its user. Presenting images is one task. +Generating images that reflect some user input and presenting these +dynamically generated images is another. In this node, we use GNUPlot +for generating `.png', `.ps', or `.gif' files.(1) + + The program we develop takes the statistical parameters of two +samples and computes the t-test statistics. As a result, we get the +probabilities that the means and the variances of both samples are the +same. In order to let the user check plausibility, the program presents +an image of the distributions. The statistical computation follows +`Numerical Recipes in C: The Art of Scientific Computing' by William H. +Press, Saul A. Teukolsky, William T. Vetterling, and Brian P. Flannery. +Since `gawk' does not have a built-in function for the computation of +the beta function, we use the `ibeta' function of GNUPlot. As a side +effect, we learn how to use GNUPlot as a sophisticated calculator. The +comparison of means is done as in `tutest', paragraph 14.2, page 613, +and the comparison of variances is done as in `ftest', page 611 in +`Numerical Recipes'. + + As usual, we take the site-independent code for servers and append +our own functions `SetUpServer' and `HandleGET': + + function SetUpServer() { + TopHeader = "Statistics with GAWK" + TopDoc = "\ +

Please choose one of the following actions:

\ + " + TopFooter = "" + GnuPlot = "gnuplot 2>&1" + m1=m2=0; v1=v2=1; n1=n2=10 + } + + Here, you see the menu structure that the user sees. Later, we will +see how the program structure of the `HandleGET' function reflects the +menu structure. What is missing here is the link for the image we +generate. In an event-driven environment, request, generation, and +delivery of images are separated. + + Notice the way we initialize the `GnuPlot' command string for the +pipe. By default, GNUPlot outputs the generated image via standard +output, as well as the results of `print'(ed) calculations via standard +error. The redirection causes standard error to be mixed into standard +output, enabling us to read results of calculations with `getline'. By +initializing the statistical parameters with some meaningful defaults, +we make sure the user gets an image the first time he uses the program. + + Following is the rather long function `HandleGET', which implements +the contents of this service by reacting to the different kinds of +requests from the browser. Before you start playing with this script, +make sure that your browser supports JavaScript and that it also has +this option switched on. The script uses a short snippet of JavaScript +code for delayed opening of a window with an image. A more detailed +explanation follows: + + function HandleGET() { + if(MENU[2] == "AboutServer") { + Document = "This is a GUI for a statistical computation.\ + It compares means and variances of two distributions.\ + It is implemented as one GAWK script and uses GNUPLOT." + } else if (MENU[2] == "EnterParameters") { + Document = "" + if ("m1" in GETARG) { # are there parameters to compare? + Document = Document "" + m1 = GETARG["m1"]; v1 = GETARG["v1"]; n1 = GETARG["n1"] + m2 = GETARG["m2"]; v2 = GETARG["v2"]; n2 = GETARG["n2"] + t = (m1-m2)/sqrt(v1/n1+v2/n2) + df = (v1/n1+v2/n2)*(v1/n1+v2/n2)/((v1/n1)*(v1/n1)/(n1-1) \ + + (v2/n2)*(v2/n2) /(n2-1)) + if (v1>v2) { + f = v1/v2 + df1 = n1 - 1 + df2 = n2 - 1 + } else { + f = v2/v1 + df1 = n2 - 1 + df2 = n1 - 1 + } + print "pt=ibeta(" df/2 ",0.5," df/(df+t*t) ")" |& GnuPlot + print "pF=2.0*ibeta(" df2/2 "," df1/2 "," \ + df2/(df2+df1*f) ")" |& GnuPlot + print "print pt, pF" |& GnuPlot + RS="\n"; GnuPlot |& getline; RS="\r\n" # $1 is pt, $2 is pF + print "invsqrt2pi=1.0/sqrt(2.0*pi)" |& GnuPlot + print "nd(x)=invsqrt2pi/sd*exp(-0.5*((x-mu)/sd)**2)" |& GnuPlot + print "set term png small color" |& GnuPlot + #print "set term postscript color" |& GnuPlot + #print "set term gif medium size 320,240" |& GnuPlot + print "set yrange[-0.3:]" |& GnuPlot + print "set label 'p(m1=m2) =" $1 "' at 0,-0.1 left" |& GnuPlot + print "set label 'p(v1=v2) =" $2 "' at 0,-0.2 left" |& GnuPlot + print "plot mu=" m1 ",sd=" sqrt(v1) ", nd(x) title 'sample 1',\ + mu=" m2 ",sd=" sqrt(v2) ", nd(x) title 'sample 2'" |& GnuPlot + print "quit" |& GnuPlot + GnuPlot |& getline Image + while ((GnuPlot |& getline) > 0) + Image = Image RS $0 + close(GnuPlot) + } + Document = Document "\ +

Do these samples have the same Gaussian distribution?

\ +
\ + \ + + \ + + \ + + \ + \ + + \ + + \ + + \ + \ +
1. Mean 1. Variance1. Count
2. Mean 2. Variance2. Count

" + } else if (MENU[2] ~ "Image") { + Reason = "OK" ORS "Content-type: image/png" + #Reason = "OK" ORS "Content-type: application/x-postscript" + #Reason = "OK" ORS "Content-type: image/gif" + Header = Footer = "" + Document = Image + } + } + + As usual, we give a short description of the service in the first +menu choice. The third menu choice shows us that generation and +presentation of an image are two separate actions. While the latter +takes place quite instantly in the third menu choice, the former takes +place in the much longer second choice. Image data passes from the +generating action to the presenting action via the variable `Image' +that contains a complete `.png' image, which is otherwise stored in a +file. If you prefer `.ps' or `.gif' images over the default `.png' +images, you may select these options by uncommenting the appropriate +lines. But remember to do so in two places: when telling GNUPlot which +kind of images to generate, and when transmitting the image at the end +of the program. + + Looking at the end of the program, the way we pass the +`Content-type' to the browser is a bit unusual. It is appended to the +`OK' of the first header line to make sure the type information becomes +part of the header. The other variables that get transmitted across +the network are made empty, because in this case we do not have an HTML +document to transmit, but rather raw image data to contain in the body. + + Most of the work is done in the second menu choice. It starts with a +strange JavaScript code snippet. When first implementing this server, +we used a short `""' here. But then +browsers got smarter and tried to improve on speed by requesting the +image and the HTML code at the same time. When doing this, the browser +tries to build up a connection for the image request while the request +for the HTML text is not yet completed. The browser tries to connect to +the `gawk' server on port 8080 while port 8080 is still in use for +transmission of the HTML text. The connection for the image cannot be +built up, so the image appears as "broken" in the browser window. We +solved this problem by telling the browser to open a separate window +for the image, but only after a delay of 1000 milliseconds. By this +time, the server should be ready for serving the next request. + + But there is one more subtlety in the JavaScript code. Each time +the JavaScript code opens a window for the image, the name of the image +is appended with a timestamp (`systime'). Why this constant change of +name for the image? Initially, we always named the image `Image', but +then the Netscape browser noticed the name had _not_ changed since the +previous request and displayed the previous image (caching behavior). +The server core is implemented so that browsers are told _not_ to cache +anything. Obviously HTTP requests do not always work as expected. One +way to circumvent the cache of such overly smart browsers is to change +the name of the image with each request. These three lines of JavaScript +caused us a lot of trouble. + + The rest can be broken down into two phases. At first, we check if +there are statistical parameters. When the program is first started, +there usually are no parameters because it enters the page coming from +the top menu. Then, we only have to present the user a form that he +can use to change statistical parameters and submit them. Subsequently, +the submission of the form causes the execution of the first phase +because _now_ there _are_ parameters to handle. + + Now that we have parameters, we know there will be an image +available. Therefore we insert the JavaScript code here to initiate +the opening of the image in a separate window. Then, we prepare some +variables that will be passed to GNUPlot for calculation of the +probabilities. Prior to reading the results, we must temporarily change +`RS' because GNUPlot separates lines with newlines. After instructing +GNUPlot to generate a `.png' (or `.ps' or `.gif') image, we initiate +the insertion of some text, explaining the resulting probabilities. The +final `plot' command actually generates the image data. This raw binary +has to be read in carefully without adding, changing, or deleting a +single byte. Hence the unusual initialization of `Image' and completion +with a `while' loop. + + When using this server, it soon becomes clear that it is far from +being perfect. It mixes source code of six scripting languages or +protocols: + + * GNU `awk' implements a server for the protocol: + + * HTTP which transmits: + + * HTML text which contains a short piece of: + + * JavaScript code opening a separate window. + + * A Bourne shell script is used for piping commands into: + + * GNUPlot to generate the image to be opened. + + After all this work, the GNUPlot image opens in the JavaScript window +where it can be viewed by the user. + + It is probably better not to mix up so many different languages. +The result is not very readable. Furthermore, the statistical part of +the server does not take care of invalid input. Among others, using +negative variances will cause invalid results. + + ---------- Footnotes ---------- + + (1) Due to licensing problems, the default installation of GNUPlot +disables the generation of `.gif' files. If your installed version +does not accept `set term gif', just download and install the most +recent version of GNUPlot and the GD library +(http://www.boutell.com/gd/) by Thomas Boutell. Otherwise you still +have the chance to generate some ASCII-art style images with GNUPlot by +using `set term dumb'. (We tried it and it worked.) + + +File: gawkinet.info, Node: MAZE, Next: MOBAGWHO, Prev: STATIST, Up: Some Applications and Techniques + +3.7 MAZE: Walking Through a Maze In Virtual Reality +=================================================== + + In the long run, every program becomes rococo, and then rubble. + Alan Perlis + + By now, we know how to present arbitrary `Content-type's to a +browser. In this node, our server will present a 3D world to our +browser. The 3D world is described in a scene description language +(VRML, Virtual Reality Modeling Language) that allows us to travel +through a perspective view of a 2D maze with our browser. Browsers with +a VRML plugin enable exploration of this technology. We could do one of +those boring `Hello world' examples here, that are usually presented +when introducing novices to VRML. If you have never written any VRML +code, have a look at the VRML FAQ. Presenting a static VRML scene is a +bit trivial; in order to expose `gawk''s new capabilities, we will +present a dynamically generated VRML scene. The function `SetUpServer' +is very simple because it only sets the default HTML page and +initializes the random number generator. As usual, the surrounding +server lets you browse the maze. + + function SetUpServer() { + TopHeader = "Walk through a maze" + TopDoc = "\ +

Please choose one of the following actions:

\ + " + TopFooter = "" + srand() + } + + The function `HandleGET' is a bit longer because it first computes +the maze and afterwards generates the VRML code that is sent across the +network. As shown in the STATIST example (*note STATIST::), we set the +type of the content to VRML and then store the VRML representation of +the maze as the page content. We assume that the maze is stored in a 2D +array. Initially, the maze consists of walls only. Then, we add an +entry and an exit to the maze and let the rest of the work be done by +the function `MakeMaze'. Now, only the wall fields are left in the +maze. By iterating over the these fields, we generate one line of VRML +code for each wall field. + + function HandleGET() { + if (MENU[2] == "AboutServer") { + Document = "If your browser has a VRML 2 plugin,\ + this server shows you a simple VRML scene." + } else if (MENU[2] == "VRMLtest") { + XSIZE = YSIZE = 11 # initially, everything is wall + for (y = 0; y < YSIZE; y++) + for (x = 0; x < XSIZE; x++) + Maze[x, y] = "#" + delete Maze[0, 1] # entry is not wall + delete Maze[XSIZE-1, YSIZE-2] # exit is not wall + MakeMaze(1, 1) + Document = "\ + #VRML V2.0 utf8\n\ + Group {\n\ + children [\n\ + PointLight {\n\ + ambientIntensity 0.2\n\ + color 0.7 0.7 0.7\n\ + location 0.0 8.0 10.0\n\ + }\n\ + DEF B1 Background {\n\ + skyColor [0 0 0, 1.0 1.0 1.0 ]\n\ + skyAngle 1.6\n\ + groundColor [1 1 1, 0.8 0.8 0.8, 0.2 0.2 0.2 ]\n\ + groundAngle [ 1.2 1.57 ]\n\ + }\n\ + DEF Wall Shape {\n\ + geometry Box {size 1 1 1}\n\ + appearance Appearance { material Material { diffuseColor 0 0 1 } }\n\ + }\n\ + DEF Entry Viewpoint {\n\ + position 0.5 1.0 5.0\n\ + orientation 0.0 0.0 -1.0 0.52\n\ + }\n" + for (i in Maze) { + split(i, t, SUBSEP) + Document = Document " Transform { translation " + Document = Document t[1] " 0 -" t[2] " children USE Wall }\n" + } + Document = Document " ] # end of group for world\n}" + Reason = "OK" ORS "Content-type: model/vrml" + Header = Footer = "" + } + } + + Finally, we have a look at `MakeMaze', the function that generates +the `Maze' array. When entered, this function assumes that the array +has been initialized so that each element represents a wall element and +the maze is initially full of wall elements. Only the entrance and the +exit of the maze should have been left free. The parameters of the +function tell us which element must be marked as not being a wall. +After this, we take a look at the four neighboring elements and +remember which we have already treated. Of all the neighboring +elements, we take one at random and walk in that direction. Therefore, +the wall element in that direction has to be removed and then, we call +the function recursively for that element. The maze is only completed +if we iterate the above procedure for _all_ neighboring elements (in +random order) and for our present element by recursively calling the +function for the present element. This last iteration could have been +done in a loop, but it is done much simpler recursively. + + Notice that elements with coordinates that are both odd are assumed +to be on our way through the maze and the generating process cannot +terminate as long as there is such an element not being `delete'd. All +other elements are potentially part of the wall. + + function MakeMaze(x, y) { + delete Maze[x, y] # here we are, we have no wall here + p = 0 # count unvisited fields in all directions + if (x-2 SUBSEP y in Maze) d[p++] = "-x" + if (x SUBSEP y-2 in Maze) d[p++] = "-y" + if (x+2 SUBSEP y in Maze) d[p++] = "+x" + if (x SUBSEP y+2 in Maze) d[p++] = "+y" + if (p>0) { # if there are unvisited fields, go there + p = int(p*rand()) # choose one unvisited field at random + if (d[p] == "-x") { delete Maze[x - 1, y]; MakeMaze(x - 2, y) + } else if (d[p] == "-y") { delete Maze[x, y - 1]; MakeMaze(x, y - 2) + } else if (d[p] == "+x") { delete Maze[x + 1, y]; MakeMaze(x + 2, y) + } else if (d[p] == "+y") { delete Maze[x, y + 1]; MakeMaze(x, y + 2) + } # we are back from recursion + MakeMaze(x, y); # try again while there are unvisited fields + } + } + + +File: gawkinet.info, Node: MOBAGWHO, Next: STOXPRED, Prev: MAZE, Up: Some Applications and Techniques + +3.8 MOBAGWHO: a Simple Mobile Agent +=================================== + + There are two ways of constructing a software design: One way is to + make it so simple that there are obviously no deficiencies, and the + other way is to make it so complicated that there are no obvious + deficiencies. + C. A. R. Hoare + + A "mobile agent" is a program that can be dispatched from a computer +and transported to a remote server for execution. This is called +"migration", which means that a process on another system is started +that is independent from its originator. Ideally, it wanders through a +network while working for its creator or owner. In places like the UMBC +Agent Web, people are quite confident that (mobile) agents are a +software engineering paradigm that enables us to significantly increase +the efficiency of our work. Mobile agents could become the mediators +between users and the networking world. For an unbiased view at this +technology, see the remarkable paper `Mobile Agents: Are they a good +idea?'.(1) + + When trying to migrate a process from one system to another, a +server process is needed on the receiving side. Depending on the kind +of server process, several ways of implementation come to mind. How +the process is implemented depends upon the kind of server process: + + * HTTP can be used as the protocol for delivery of the migrating + process. In this case, we use a common web server as the receiving + server process. A universal CGI script mediates between migrating + process and web server. Each server willing to accept migrating + agents makes this universal service available. HTTP supplies the + `POST' method to transfer some data to a file on the web server. + When a CGI script is called remotely with the `POST' method + instead of the usual `GET' method, data is transmitted from the + client process to the standard input of the server's CGI script. + So, to implement a mobile agent, we must not only write the agent + program to start on the client side, but also the CGI script to + receive the agent on the server side. + + * The `PUT' method can also be used for migration. HTTP does not + require a CGI script for migration via `PUT'. However, with common + web servers there is no advantage to this solution, because web + servers such as Apache require explicit activation of a special + `PUT' script. + + * `Agent Tcl' pursues a different course; it relies on a dedicated + server process with a dedicated protocol specialized for receiving + mobile agents. + + Our agent example abuses a common web server as a migration tool. +So, it needs a universal CGI script on the receiving side (the web +server). The receiving script is activated with a `POST' request when +placed into a location like `/httpd/cgi-bin/PostAgent.sh'. Make sure +that the server system uses a version of `gawk' that supports network +access (Version 3.1 or later; verify with `gawk --version'). + + #!/bin/sh + MobAg=/tmp/MobileAgent.$$ + # direct script to mobile agent file + cat > $MobAg + # execute agent concurrently + gawk -f $MobAg $MobAg > /dev/null & + # HTTP header, terminator and body + gawk 'BEGIN { print "\r\nAgent started" }' + rm $MobAg # delete script file of agent + + By making its process id (`$$') part of the unique file name, the +script avoids conflicts between concurrent instances of the script. +First, all lines from standard input (the mobile agent's source code) +are copied into this unique file. Then, the agent is started as a +concurrent process and a short message reporting this fact is sent to +the submitting client. Finally, the script file of the mobile agent is +removed because it is no longer needed. Although it is a short script, +there are several noteworthy points: + +Security + _There is none_. In fact, the CGI script should never be made + available on a server that is part of the Internet because everyone + would be allowed to execute arbitrary commands with it. This + behavior is acceptable only when performing rapid prototyping. + +Self-Reference + Each migrating instance of an agent is started in a way that + enables it to read its own source code from standard input and use + the code for subsequent migrations. This is necessary because it + needs to treat the agent's code as data to transmit. `gawk' is not + the ideal language for such a job. Lisp and Tcl are more suitable + because they do not make a distinction between program code and + data. + +Independence + After migration, the agent is not linked to its former home in any + way. By reporting `Agent started', it waves "Goodbye" to its + origin. The originator may choose to terminate or not. + + The originating agent itself is started just like any other +command-line script, and reports the results on standard output. By +letting the name of the original host migrate with the agent, the agent +that migrates to a host far away from its origin can report the result +back home. Having arrived at the end of the journey, the agent +establishes a connection and reports the results. This is the reason +for determining the name of the host with `uname -n' and storing it in +`MyOrigin' for later use. We may also set variables with the `-v' +option from the command line. This interactivity is only of importance +in the context of starting a mobile agent; therefore this `BEGIN' +pattern and its action do not take part in migration: + + BEGIN { + if (ARGC != 2) { + print "MOBAG - a simple mobile agent" + print "CALL:\n gawk -f mobag.awk mobag.awk" + print "IN:\n the name of this script as a command-line parameter" + print "PARAM:\n -v MyOrigin=myhost.com" + print "OUT:\n the result on stdout" + print "JK 29.03.1998 01.04.1998" + exit + } + if (MyOrigin == "") { + "uname -n" | getline MyOrigin + close("uname -n") + } + } + + Since `gawk' cannot manipulate and transmit parts of the program +directly, the source code is read and stored in strings. Therefore, +the program scans itself for the beginning and the ending of functions. +Each line in between is appended to the code string until the end of +the function has been reached. A special case is this part of the +program itself. It is not a function. Placing a similar framework +around it causes it to be treated like a function. Notice that this +mechanism works for all the functions of the source code, but it cannot +guarantee that the order of the functions is preserved during migration: + + #ReadMySelf + /^function / { FUNC = $2 } + /^END/ || /^#ReadMySelf/ { FUNC = $1 } + FUNC != "" { MOBFUN[FUNC] = MOBFUN[FUNC] RS $0 } + (FUNC != "") && (/^}/ || /^#EndOfMySelf/) \ + { FUNC = "" } + #EndOfMySelf + + The web server code in *note A Web Service with Interaction: +Interacting Service, was first developed as a site-independent core. +Likewise, the `gawk'-based mobile agent starts with an +agent-independent core, to which can be appended application-dependent +functions. What follows is the only application-independent function +needed for the mobile agent: + + function migrate(Destination, MobCode, Label) { + MOBVAR["Label"] = Label + MOBVAR["Destination"] = Destination + RS = ORS = "\r\n" + HttpService = "/inet/tcp/0/" Destination + for (i in MOBFUN) + MobCode = (MobCode "\n" MOBFUN[i]) + MobCode = MobCode "\n\nBEGIN {" + for (i in MOBVAR) + MobCode = (MobCode "\n MOBVAR[\"" i "\"] = \"" MOBVAR[i] "\"") + MobCode = MobCode "\n}\n" + print "POST /cgi-bin/PostAgent.sh HTTP/1.0" |& HttpService + print "Content-length:", length(MobCode) ORS |& HttpService + printf "%s", MobCode |& HttpService + while ((HttpService |& getline) > 0) + print $0 + close(HttpService) + } + + The `migrate' function prepares the aforementioned strings +containing the program code and transmits them to a server. A +consequence of this modular approach is that the `migrate' function +takes some parameters that aren't needed in this application, but that +will be in future ones. Its mandatory parameter `Destination' holds the +name (or IP address) of the server that the agent wants as a host for +its code. The optional parameter `MobCode' may contain some `gawk' code +that is inserted during migration in front of all other code. The +optional parameter `Label' may contain a string that tells the agent +what to do in program execution after arrival at its new home site. One +of the serious obstacles in implementing a framework for mobile agents +is that it does not suffice to migrate the code. It is also necessary +to migrate the state of execution of the agent. In contrast to `Agent +Tcl', this program does not try to migrate the complete set of +variables. The following conventions are used: + + * Each variable in an agent program is local to the current host and + does _not_ migrate. + + * The array `MOBFUN' shown above is an exception. It is handled by + the function `migrate' and does migrate with the application. + + * The other exception is the array `MOBVAR'. Each variable that + takes part in migration has to be an element of this array. + `migrate' also takes care of this. + + Now it's clear what happens to the `Label' parameter of the function +`migrate'. It is copied into `MOBVAR["Label"]' and travels alongside +the other data. Since travelling takes place via HTTP, records must be +separated with `"\r\n"' in `RS' and `ORS' as usual. The code assembly +for migration takes place in three steps: + + * Iterate over `MOBFUN' to collect all functions verbatim. + + * Prepare a `BEGIN' pattern and put assignments to mobile variables + into the action part. + + * Transmission itself resembles GETURL: the header with the request + and the `Content-length' is followed by the body. In case there is + any reply over the network, it is read completely and echoed to + standard output to avoid irritating the server. + + The application-independent framework is now almost complete. What +follows is the `END' pattern that is executed when the mobile agent has +finished reading its own code. First, it checks whether it is already +running on a remote host or not. In case initialization has not yet +taken place, it starts `MyInit'. Otherwise (later, on a remote host), it +starts `MyJob': + + END { + if (ARGC != 2) exit # stop when called with wrong parameters + if (MyOrigin != "") # is this the originating host? + MyInit() # if so, initialize the application + else # we are on a host with migrated data + MyJob() # so we do our job + } + + All that's left to extend the framework into a complete application +is to write two application-specific functions: `MyInit' and `MyJob'. +Keep in mind that the former is executed once on the originating host, +while the latter is executed after each migration: + + function MyInit() { + MOBVAR["MyOrigin"] = MyOrigin + MOBVAR["Machines"] = "localhost/80 max/80 moritz/80 castor/80" + split(MOBVAR["Machines"], Machines) # which host is the first? + migrate(Machines[1], "", "") # go to the first host + while (("/inet/tcp/8080/0/0" |& getline) > 0) # wait for result + print $0 # print result + close("/inet/tcp/8080/0/0") + } + + As mentioned earlier, this agent takes the name of its origin +(`MyOrigin') with it. Then, it takes the name of its first destination +and goes there for further work. Notice that this name has the port +number of the web server appended to the name of the server, because +the function `migrate' needs it this way to create the `HttpService' +variable. Finally, it waits for the result to arrive. The `MyJob' +function runs on the remote host: + + function MyJob() { + # forget this host + sub(MOBVAR["Destination"], "", MOBVAR["Machines"]) + MOBVAR["Result"]=MOBVAR["Result"] SUBSEP SUBSEP MOBVAR["Destination"] ":" + while (("who" | getline) > 0) # who is logged in? + MOBVAR["Result"] = MOBVAR["Result"] SUBSEP $0 + close("who") + if (index(MOBVAR["Machines"], "/") > 0) { # any more machines to visit? + split(MOBVAR["Machines"], Machines) # which host is next? + migrate(Machines[1], "", "") # go there + } else { # no more machines + gsub(SUBSEP, "\n", MOBVAR["Result"]) # send result to origin + print MOBVAR["Result"] |& "/inet/tcp/0/" MOBVAR["MyOrigin"] "/8080" + close("/inet/tcp/0/" MOBVAR["MyOrigin"] "/8080") + } + } + + After migrating, the first thing to do in `MyJob' is to delete the +name of the current host from the list of hosts to visit. Now, it is +time to start the real work by appending the host's name to the result +string, and reading line by line who is logged in on this host. A very +annoying circumstance is the fact that the elements of `MOBVAR' cannot +hold the newline character (`"\n"'). If they did, migration of this +string did not work because the string didn't obey the syntax rule for +a string in `gawk'. `SUBSEP' is used as a temporary replacement. If +the list of hosts to visit holds at least one more entry, the agent +migrates to that place to go on working there. Otherwise, we replace +the `SUBSEP's with a newline character in the resulting string, and +report it to the originating host, whose name is stored in +`MOBVAR["MyOrigin"]'. + + ---------- Footnotes ---------- + + (1) `http://www.research.ibm.com/massive/mobag.ps' + + +File: gawkinet.info, Node: STOXPRED, Next: PROTBASE, Prev: MOBAGWHO, Up: Some Applications and Techniques + +3.9 STOXPRED: Stock Market Prediction As A Service +================================================== + + Far out in the uncharted backwaters of the unfashionable end of + the Western Spiral arm of the Galaxy lies a small unregarded + yellow sun. + + Orbiting this at a distance of roughly ninety-two million miles is + an utterly insignificant little blue-green planet whose + ape-descendent life forms are so amazingly primitive that they + still think digital watches are a pretty neat idea. + + This planet has -- or rather had -- a problem, which was this: + most of the people living on it were unhappy for pretty much of + the time. Many solutions were suggested for this problem, but + most of these were largely concerned with the movements of small + green pieces of paper, which is odd because it wasn't the small + green pieces of paper that were unhappy. + Douglas Adams, `The Hitch Hiker's Guide to the Galaxy' + + Valuable services on the Internet are usually _not_ implemented as +mobile agents. There are much simpler ways of implementing services. +All Unix systems provide, for example, the `cron' service. Unix system +users can write a list of tasks to be done each day, each week, twice a +day, or just once. The list is entered into a file named `crontab'. +For example, to distribute a newsletter on a daily basis this way, use +`cron' for calling a script each day early in the morning. + + # run at 8 am on weekdays, distribute the newsletter + 0 8 * * 1-5 $HOME/bin/daily.job >> $HOME/log/newsletter 2>&1 + + The script first looks for interesting information on the Internet, +assembles it in a nice form and sends the results via email to the +customers. + + The following is an example of a primitive newsletter on stock +market prediction. It is a report which first tries to predict the +change of each share in the Dow Jones Industrial Index for the +particular day. Then it mentions some especially promising shares as +well as some shares which look remarkably bad on that day. The report +ends with the usual disclaimer which tells every child _not_ to try +this at home and hurt anybody. + + Good morning Uncle Scrooge, + + This is your daily stock market report for Monday, October 16, 2000. + Here are the predictions for today: + + AA neutral + GE up + JNJ down + MSFT neutral + ... + UTX up + DD down + IBM up + MO down + WMT up + DIS up + INTC up + MRK down + XOM down + EK down + IP down + + The most promising shares for today are these: + + INTC http://biz.yahoo.com/n/i/intc.html + + The stock shares to avoid today are these: + + EK http://biz.yahoo.com/n/e/ek.html + IP http://biz.yahoo.com/n/i/ip.html + DD http://biz.yahoo.com/n/d/dd.html + ... + + The script as a whole is rather long. In order to ease the pain of +studying other people's source code, we have broken the script up into +meaningful parts which are invoked one after the other. The basic +structure of the script is as follows: + + BEGIN { + Init() + ReadQuotes() + CleanUp() + Prediction() + Report() + SendMail() + } + + The earlier parts store data into variables and arrays which are +subsequently used by later parts of the script. The `Init' function +first checks if the script is invoked correctly (without any +parameters). If not, it informs the user of the correct usage. What +follows are preparations for the retrieval of the historical quote +data. The names of the 30 stock shares are stored in an array `name' +along with the current date in `day', `month', and `year'. + + All users who are separated from the Internet by a firewall and have +to direct their Internet accesses to a proxy must supply the name of +the proxy to this script with the `-v Proxy=NAME' option. For most +users, the default proxy and port number should suffice. + + function Init() { + if (ARGC != 1) { + print "STOXPRED - daily stock share prediction" + print "IN:\n no parameters, nothing on stdin" + print "PARAM:\n -v Proxy=MyProxy -v ProxyPort=80" + print "OUT:\n commented predictions as email" + print "JK 09.10.2000" + exit + } + # Remember ticker symbols from Dow Jones Industrial Index + StockCount = split("AA GE JNJ MSFT AXP GM JPM PG BA HD KO \ + SBC C HON MCD T CAT HWP MMM UTX DD IBM MO WMT DIS INTC \ + MRK XOM EK IP", name); + # Remember the current date as the end of the time series + day = strftime("%d") + month = strftime("%m") + year = strftime("%Y") + if (Proxy == "") Proxy = "chart.yahoo.com" + if (ProxyPort == 0) ProxyPort = 80 + YahooData = "/inet/tcp/0/" Proxy "/" ProxyPort + } + + There are two really interesting parts in the script. One is the +function which reads the historical stock quotes from an Internet +server. The other is the one that does the actual prediction. In the +following function we see how the quotes are read from the Yahoo +server. The data which comes from the server is in CSV format +(comma-separated values): + + Date,Open,High,Low,Close,Volume + 9-Oct-00,22.75,22.75,21.375,22.375,7888500 + 6-Oct-00,23.8125,24.9375,21.5625,22,10701100 + 5-Oct-00,24.4375,24.625,23.125,23.50,5810300 + + Lines contain values of the same time instant, whereas columns are +separated by commas and contain the kind of data that is described in +the header (first) line. At first, `gawk' is instructed to separate +columns by commas (`FS = ","'). In the loop that follows, a connection +to the Yahoo server is first opened, then a download takes place, and +finally the connection is closed. All this happens once for each ticker +symbol. In the body of this loop, an Internet address is built up as a +string according to the rules of the Yahoo server. The starting and +ending date are chosen to be exactly the same, but one year apart in +the past. All the action is initiated within the `printf' command which +transmits the request for data to the Yahoo server. + + In the inner loop, the server's data is first read and then scanned +line by line. Only lines which have six columns and the name of a month +in the first column contain relevant data. This data is stored in the +two-dimensional array `quote'; one dimension being time, the other +being the ticker symbol. During retrieval of the first stock's data, +the calendar names of the time instances are stored in the array `day' +because we need them later. + + function ReadQuotes() { + # Retrieve historical data for each ticker symbol + FS = "," + for (stock = 1; stock <= StockCount; stock++) { + URL = "http://chart.yahoo.com/table.csv?s=" name[stock] \ + "&a=" month "&b=" day "&c=" year-1 \ + "&d=" month "&e=" day "&f=" year \ + "g=d&q=q&y=0&z=" name[stock] "&x=.csv" + printf("GET " URL " HTTP/1.0\r\n\r\n") |& YahooData + while ((YahooData |& getline) > 0) { + if (NF == 6 && $1 ~ /Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec/) { + if (stock == 1) + days[++daycount] = $1; + quote[$1, stock] = $5 + } + } + close(YahooData) + } + FS = " " + } + + Now that we _have_ the data, it can be checked once again to make +sure that no individual stock is missing or invalid, and that all the +stock quotes are aligned correctly. Furthermore, we renumber the time +instances. The most recent day gets day number 1 and all other days get +consecutive numbers. All quotes are rounded toward the nearest whole +number in US Dollars. + + function CleanUp() { + # clean up time series; eliminate incomplete data sets + for (d = 1; d <= daycount; d++) { + for (stock = 1; stock <= StockCount; stock++) + if (! ((days[d], stock) in quote)) + stock = StockCount + 10 + if (stock > StockCount + 1) + continue + datacount++ + for (stock = 1; stock <= StockCount; stock++) + data[datacount, stock] = int(0.5 + quote[days[d], stock]) + } + delete quote + delete days + } + + Now we have arrived at the second really interesting part of the +whole affair. What we present here is a very primitive prediction +algorithm: _If a stock fell yesterday, assume it will also fall today; +if it rose yesterday, assume it will rise today_. (Feel free to +replace this algorithm with a smarter one.) If a stock changed in the +same direction on two consecutive days, this is an indication which +should be highlighted. Two-day advances are stored in `hot' and +two-day declines in `avoid'. + + The rest of the function is a sanity check. It counts the number of +correct predictions in relation to the total number of predictions one +could have made in the year before. + + function Prediction() { + # Predict each ticker symbol by prolonging yesterday's trend + for (stock = 1; stock <= StockCount; stock++) { + if (data[1, stock] > data[2, stock]) { + predict[stock] = "up" + } else if (data[1, stock] < data[2, stock]) { + predict[stock] = "down" + } else { + predict[stock] = "neutral" + } + if ((data[1, stock] > data[2, stock]) && (data[2, stock] > data[3, stock])) + hot[stock] = 1 + if ((data[1, stock] < data[2, stock]) && (data[2, stock] < data[3, stock])) + avoid[stock] = 1 + } + # Do a plausibility check: how many predictions proved correct? + for (s = 1; s <= StockCount; s++) { + for (d = 1; d <= datacount-2; d++) { + if (data[d+1, s] > data[d+2, s]) { + UpCount++ + } else if (data[d+1, s] < data[d+2, s]) { + DownCount++ + } else { + NeutralCount++ + } + if (((data[d, s] > data[d+1, s]) && (data[d+1, s] > data[d+2, s])) || + ((data[d, s] < data[d+1, s]) && (data[d+1, s] < data[d+2, s])) || + ((data[d, s] == data[d+1, s]) && (data[d+1, s] == data[d+2, s]))) + CorrectCount++ + } + } + } + + At this point the hard work has been done: the array `predict' +contains the predictions for all the ticker symbols. It is up to the +function `Report' to find some nice words to introduce the desired +information. + + function Report() { + # Generate report + report = "\nThis is your daily " + report = report "stock market report for "strftime("%A, %B %d, %Y")".\n" + report = report "Here are the predictions for today:\n\n" + for (stock = 1; stock <= StockCount; stock++) + report = report "\t" name[stock] "\t" predict[stock] "\n" + for (stock in hot) { + if (HotCount++ == 0) + report = report "\nThe most promising shares for today are these:\n\n" + report = report "\t" name[stock] "\t\thttp://biz.yahoo.com/n/" \ + tolower(substr(name[stock], 1, 1)) "/" tolower(name[stock]) ".html\n" + } + for (stock in avoid) { + if (AvoidCount++ == 0) + report = report "\nThe stock shares to avoid today are these:\n\n" + report = report "\t" name[stock] "\t\thttp://biz.yahoo.com/n/" \ + tolower(substr(name[stock], 1, 1)) "/" tolower(name[stock]) ".html\n" + } + report = report "\nThis sums up to " HotCount+0 " winners and " AvoidCount+0 + report = report " losers. When using this kind\nof prediction scheme for" + report = report " the 12 months which lie behind us,\nwe get " UpCount + report = report " 'ups' and " DownCount " 'downs' and " NeutralCount + report = report " 'neutrals'. Of all\nthese " UpCount+DownCount+NeutralCount + report = report " predictions " CorrectCount " proved correct next day.\n" + report = report "A success rate of "\ + int(100*CorrectCount/(UpCount+DownCount+NeutralCount)) "%.\n" + report = report "Random choice would have produced a 33% success rate.\n" + report = report "Disclaimer: Like every other prediction of the stock\n" + report = report "market, this report is, of course, complete nonsense.\n" + report = report "If you are stupid enough to believe these predictions\n" + report = report "you should visit a doctor who can treat your ailment." + } + + The function `SendMail' goes through the list of customers and opens +a pipe to the `mail' command for each of them. Each one receives an +email message with a proper subject heading and is addressed with his +full name. + + function SendMail() { + # send report to customers + customer["uncle.scrooge@ducktown.gov"] = "Uncle Scrooge" + customer["more@utopia.org" ] = "Sir Thomas More" + customer["spinoza@denhaag.nl" ] = "Baruch de Spinoza" + customer["marx@highgate.uk" ] = "Karl Marx" + customer["keynes@the.long.run" ] = "John Maynard Keynes" + customer["bierce@devil.hell.org" ] = "Ambrose Bierce" + customer["laplace@paris.fr" ] = "Pierre Simon de Laplace" + for (c in customer) { + MailPipe = "mail -s 'Daily Stock Prediction Newsletter'" c + print "Good morning " customer[c] "," | MailPipe + print report "\n.\n" | MailPipe + close(MailPipe) + } + } + + Be patient when running the script by hand. Retrieving the data for +all the ticker symbols and sending the emails may take several minutes +to complete, depending upon network traffic and the speed of the +available Internet link. The quality of the prediction algorithm is +likely to be disappointing. Try to find a better one. Should you find +one with a success rate of more than 50%, please tell us about it! It +is only for the sake of curiosity, of course. `:-)' + + +File: gawkinet.info, Node: PROTBASE, Prev: STOXPRED, Up: Some Applications and Techniques + +3.10 PROTBASE: Searching Through A Protein Database +=================================================== + + Hoare's Law of Large Problems: Inside every large problem is a + small problem struggling to get out. + + Yahoo's database of stock market data is just one among the many +large databases on the Internet. Another one is located at NCBI +(National Center for Biotechnology Information). Established in 1988 as +a national resource for molecular biology information, NCBI creates +public databases, conducts research in computational biology, develops +software tools for analyzing genome data, and disseminates biomedical +information. In this section, we look at one of NCBI's public services, +which is called BLAST (Basic Local Alignment Search Tool). + + You probably know that the information necessary for reproducing +living cells is encoded in the genetic material of the cells. The +genetic material is a very long chain of four base nucleotides. It is +the order of appearance (the sequence) of nucleotides which contains +the information about the substance to be produced. Scientists in +biotechnology often find a specific fragment, determine the nucleotide +sequence, and need to know where the sequence at hand comes from. This +is where the large databases enter the game. At NCBI, databases store +the knowledge about which sequences have ever been found and where they +have been found. When the scientist sends his sequence to the BLAST +service, the server looks for regions of genetic material in its +database which look the most similar to the delivered nucleotide +sequence. After a search time of some seconds or minutes the server +sends an answer to the scientist. In order to make access simple, NCBI +chose to offer their database service through popular Internet +protocols. There are four basic ways to use the so-called BLAST +services: + + * The easiest way to use BLAST is through the web. Users may simply + point their browsers at the NCBI home page and link to the BLAST + pages. NCBI provides a stable URL that may be used to perform + BLAST searches without interactive use of a web browser. This is + what we will do later in this section. A demonstration client and + a `README' file demonstrate how to access this URL. + + * Currently, `blastcl3' is the standard network BLAST client. You + can download `blastcl3' from the anonymous FTP location. + + * BLAST 2.0 can be run locally as a full executable and can be used + to run BLAST searches against private local databases, or + downloaded copies of the NCBI databases. BLAST 2.0 executables may + be found on the NCBI anonymous FTP server. + + * The NCBI BLAST Email server is the best option for people without + convenient access to the web. A similarity search can be performed + by sending a properly formatted mail message containing the + nucleotide or protein query sequence to . + The query sequence is compared against the specified database + using the BLAST algorithm and the results are returned in an email + message. For more information on formulating email BLAST searches, + you can send a message consisting of the word "HELP" to the same + address, . + + Our starting point is the demonstration client mentioned in the +first option. The `README' file that comes along with the client +explains the whole process in a nutshell. In the rest of this section, +we first show what such requests look like. Then we show how to use +`gawk' to implement a client in about 10 lines of code. Finally, we +show how to interpret the result returned from the service. + + Sequences are expected to be represented in the standard IUB/IUPAC +amino acid and nucleic acid codes, with these exceptions: lower-case +letters are accepted and are mapped into upper-case; a single hyphen or +dash can be used to represent a gap of indeterminate length; and in +amino acid sequences, `U' and `*' are acceptable letters (see below). +Before submitting a request, any numerical digits in the query sequence +should either be removed or replaced by appropriate letter codes (e.g., +`N' for unknown nucleic acid residue or `X' for unknown amino acid +residue). The nucleic acid codes supported are: + + A --> adenosine M --> A C (amino) + C --> cytidine S --> G C (strong) + G --> guanine W --> A T (weak) + T --> thymidine B --> G T C + U --> uridine D --> G A T + R --> G A (purine) H --> A C T + Y --> T C (pyrimidine) V --> G C A + K --> G T (keto) N --> A G C T (any) + - gap of indeterminate length + + Now you know the alphabet of nucleotide sequences. The last two lines +of the following example query show you such a sequence, which is +obviously made up only of elements of the alphabet just described. +Store this example query into a file named `protbase.request'. You are +now ready to send it to the server with the demonstration client. + + PROGRAM blastn + DATALIB month + EXPECT 0.75 + BEGIN + >GAWK310 the gawking gene GNU AWK + tgcttggctgaggagccataggacgagagcttcctggtgaagtgtgtttcttgaaatcat + caccaccatggacagcaaa + + The actual search request begins with the mandatory parameter +`PROGRAM' in the first column followed by the value `blastn' (the name +of the program) for searching nucleic acids. The next line contains +the mandatory search parameter `DATALIB' with the value `month' for the +newest nucleic acid sequences. The third line contains an optional +`EXPECT' parameter and the value desired for it. The fourth line +contains the mandatory `BEGIN' directive, followed by the query +sequence in FASTA/Pearson format. Each line of information must be +less than 80 characters in length. + + The "month" database contains all new or revised sequences released +in the last 30 days and is useful for searching against new sequences. +There are five different blast programs, `blastn' being the one that +compares a nucleotide query sequence against a nucleotide sequence +database. + + The last server directive that must appear in every request is the +`BEGIN' directive. The query sequence should immediately follow the +`BEGIN' directive and must appear in FASTA/Pearson format. A sequence +in FASTA/Pearson format begins with a single-line description. The +description line, which is required, is distinguished from the lines of +sequence data that follow it by having a greater-than (`>') symbol in +the first column. For the purposes of the BLAST server, the text of +the description is arbitrary. + + If you prefer to use a client written in `gawk', just store the +following 10 lines of code into a file named `protbase.awk' and use +this client instead. Invoke it with `gawk -f protbase.awk +protbase.request'. Then wait a minute and watch the result coming in. +In order to replicate the demonstration client's behavior as closely as +possible, this client does not use a proxy server. We could also have +extended the client program in *note Retrieving Web Pages: GETURL, to +implement the client request from `protbase.awk' as a special case. + + { request = request "\n" $0 } + + END { + BLASTService = "/inet/tcp/0/www.ncbi.nlm.nih.gov/80" + printf "POST /cgi-bin/BLAST/nph-blast_report HTTP/1.0\n" |& BLASTService + printf "Content-Length: " length(request) "\n\n" |& BLASTService + printf request |& BLASTService + while ((BLASTService |& getline) > 0) + print $0 + close(BLASTService) + } + + The demonstration client from NCBI is 214 lines long (written in C) +and it is not immediately obvious what it does. Our client is so short +that it _is_ obvious what it does. First it loops over all lines of the +query and stores the whole query into a variable. Then the script +establishes an Internet connection to the NCBI server and transmits the +query by framing it with a proper HTTP request. Finally it receives and +prints the complete result coming from the server. + + Now, let us look at the result. It begins with an HTTP header, which +you can ignore. Then there are some comments about the query having been +filtered to avoid spuriously high scores. After this, there is a +reference to the paper that describes the software being used for +searching the data base. After a repetition of the original query's +description we find the list of significant alignments: + + Sequences producing significant alignments: (bits) Value + + gb|AC021182.14|AC021182 Homo sapiens chromosome 7 clone RP11-733... 38 0.20 + gb|AC021056.12|AC021056 Homo sapiens chromosome 3 clone RP11-115... 38 0.20 + emb|AL160278.10|AL160278 Homo sapiens chromosome 9 clone RP11-57... 38 0.20 + emb|AL391139.11|AL391139 Homo sapiens chromosome X clone RP11-35... 38 0.20 + emb|AL365192.6|AL365192 Homo sapiens chromosome 6 clone RP3-421H... 38 0.20 + emb|AL138812.9|AL138812 Homo sapiens chromosome 11 clone RP1-276... 38 0.20 + gb|AC073881.3|AC073881 Homo sapiens chromosome 15 clone CTD-2169... 38 0.20 + + This means that the query sequence was found in seven human +chromosomes. But the value 0.20 (20%) means that the probability of an +accidental match is rather high (20%) in all cases and should be taken +into account. You may wonder what the first column means. It is a key +to the specific database in which this occurrence was found. The +unique sequence identifiers reported in the search results can be used +as sequence retrieval keys via the NCBI server. The syntax of sequence +header lines used by the NCBI BLAST server depends on the database from +which each sequence was obtained. The table below lists the +identifiers for the databases from which the sequences were derived. + + Database Name Identifier Syntax + ============================ ======================== + GenBank gb|accession|locus + EMBL Data Library emb|accession|locus + DDBJ, DNA Database of Japan dbj|accession|locus + NBRF PIR pir||entry + Protein Research Foundation prf||name + SWISS-PROT sp|accession|entry name + Brookhaven Protein Data Bank pdb|entry|chain + Kabat's Sequences of Immuno... gnl|kabat|identifier + Patents pat|country|number + GenInfo Backbone Id bbs|number + + For example, an identifier might be `gb|AC021182.14|AC021182', where +the `gb' tag indicates that the identifier refers to a GenBank sequence, +`AC021182.14' is its GenBank ACCESSION, and `AC021182' is the GenBank +LOCUS. The identifier contains no spaces, so that a space indicates +the end of the identifier. + + Let us continue in the result listing. Each of the seven alignments +mentioned above is subsequently described in detail. We will have a +closer look at the first of them. + + >gb|AC021182.14|AC021182 Homo sapiens chromosome 7 clone RP11-733N23, WORKING DRAFT SEQUENCE, 4 + unordered pieces + Length = 176383 + + Score = 38.2 bits (19), Expect = 0.20 + Identities = 19/19 (100%) + Strand = Plus / Plus + + Query: 35 tggtgaagtgtgtttcttg 53 + ||||||||||||||||||| + Sbjct: 69786 tggtgaagtgtgtttcttg 69804 + + This alignment was located on the human chromosome 7. The fragment +on which part of the query was found had a total length of 176383. Only +19 of the nucleotides matched and the matching sequence ran from +character 35 to 53 in the query sequence and from 69786 to 69804 in the +fragment on chromosome 7. If you are still reading at this point, you +are probably interested in finding out more about Computational Biology +and you might appreciate the following hints. + + 1. There is a book called `Introduction to Computational Biology' by + Michael S. Waterman, which is worth reading if you are seriously + interested. You can find a good book review on the Internet. + + 2. While Waterman's book can explain to you the algorithms employed + internally in the database search engines, most practitioners + prefer to approach the subject differently. The applied side of + Computational Biology is called Bioinformatics, and emphasizes the + tools available for day-to-day work as well as how to actually + _use_ them. One of the very few affordable books on Bioinformatics + is `Developing Bioinformatics Computer Skills'. + + 3. The sequences _gawk_ and _gnuawk_ are in widespread use in the + genetic material of virtually every earthly living being. Let us + take this as a clear indication that the divine creator has + intended `gawk' to prevail over other scripting languages such as + `perl', `tcl', or `python' which are not even proper sequences. + (:-) + + +File: gawkinet.info, Node: Links, Next: GNU Free Documentation License, Prev: Some Applications and Techniques, Up: Top + +4 Related Links +*************** + +This section lists the URLs for various items discussed in this major +node. They are presented in the order in which they appear. + +`Internet Programming with Python' + `http://www.fsbassociates.com/books/python.htm' + +`Advanced Perl Programming' + `http://www.oreilly.com/catalog/advperl' + +`Web Client Programming with Perl' + `http://www.oreilly.com/catalog/webclient' + +Richard Stevens's home page and book + `http://www.kohala.com/~rstevens' + +The SPAK home page + `http://www.userfriendly.net/linux/RPM/contrib/libc6/i386/spak-0.6b-1.i386.html' + +Volume III of `Internetworking with TCP/IP', by Comer and Stevens + `http://www.cs.purdue.edu/homes/dec/tcpip3s.cont.html' + +XBM Graphics File Format + `http://www.wotsit.org/download.asp?f=xbm' + +GNUPlot + `http://www.cs.dartmouth.edu/gnuplot_info.html' + +Mark Humphrys' Eliza page + `http://www.compapp.dcu.ie/~humphrys/eliza.html' + +Yahoo! Eliza Information + `http://dir.yahoo.com/Recreation/Games/Computer_Games/Internet_Games/Web_Games/Artificial_Intelligence' + +Java versions of Eliza + `http://www.tjhsst.edu/Psych/ch1/eliza.html' + +Java versions of Eliza with source code + `http://home.adelphia.net/~lifeisgood/eliza/eliza.htm' + +Eliza Programs with Explanations + `http://chayden.net/chayden/eliza/Eliza.shtml' + +Loebner Contest + `http://acm.org/~loebner/loebner-prize.htmlx' + +Tck/Tk Information + `http://www.scriptics.com/' + +Intel 80x86 Processors + `http://developer.intel.com/design/platform/embedpc/what_is.htm' + +AMD Elan Processors + `http://www.amd.com/products/epd/processors/4.32bitcont/32bitcont/index.html' + +XINU + `http://willow.canberra.edu.au/~chrisc/xinu.html' + +GNU/Linux + `http://uclinux.lineo.com/' + +Embedded PCs + `http://dir.yahoo.com/Business_and_Economy/Business_to_Business/Computers/Hardware/Embedded_Control/' + +MiniSQL + `http://www.hughes.com.au/library/' + +Market Share Surveys + `http://www.netcraft.com/survey' + +`Numerical Recipes in C: The Art of Scientific Computing' + `http://www.nr.com' + +VRML + `http://www.vrml.org' + +The VRML FAQ + `http://www.vrml.org/technicalinfo/specifications/specifications.htm#FAQ' + +The UMBC Agent Web + `http://www.cs.umbc.edu/agents' + +Apache Web Server + `http://www.apache.org' + +National Center for Biotechnology Information (NCBI) + `http://www.ncbi.nlm.nih.gov' + +Basic Local Alignment Search Tool (BLAST) + `http://www.ncbi.nlm.nih.gov/BLAST/blast_overview.html' + +NCBI Home Page + `http://www.ncbi.nlm.nih.gov' + +BLAST Pages + `http://www.ncbi.nlm.nih.gov/BLAST' + +BLAST Demonstration Client + `ftp://ncbi.nlm.nih.gov/blast/blasturl/' + +BLAST anonymous FTP location + `ftp://ncbi.nlm.nih.gov/blast/network/netblast/' + +BLAST 2.0 Executables + `ftp://ncbi.nlm.nih.gov/blast/executables/' + +IUB/IUPAC Amino Acid and Nucleic Acid Codes + `http://www.uthscsa.edu/geninfo/blastmail.html#item6' + +FASTA/Pearson Format + `http://www.ncbi.nlm.nih.gov/BLAST/fasta.html' + +Fasta/Pearson Sequence in Java + `http://www.kazusa.or.jp/java/codon_table_java/' + +Book Review of `Introduction to Computational Biology' + `http://www.acm.org/crossroads/xrds5-1/introcb.html' + +`Developing Bioinformatics Computer Skills' + `http://www.oreilly.com/catalog/bioskills/' + + + +File: gawkinet.info, Node: GNU Free Documentation License, Next: Index, Prev: Links, Up: Top + +GNU Free Documentation License +****************************** + + Version 1.3, 3 November 2008 + + Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. + `http://fsf.org/' + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + 0. PREAMBLE + + The purpose of this License is to make a manual, textbook, or other + functional and useful document "free" in the sense of freedom: to + assure everyone the effective freedom to copy and redistribute it, + with or without modifying it, either commercially or + noncommercially. Secondarily, this License preserves for the + author and publisher a way to get credit for their work, while not + being considered responsible for modifications made by others. + + This License is a kind of "copyleft", which means that derivative + works of the document must themselves be free in the same sense. + It complements the GNU General Public License, which is a copyleft + license designed for free software. + + We have designed this License in order to use it for manuals for + free software, because free software needs free documentation: a + free program should come with manuals providing the same freedoms + that the software does. But this License is not limited to + software manuals; it can be used for any textual work, regardless + of subject matter or whether it is published as a printed book. + We recommend this License principally for works whose purpose is + instruction or reference. + + 1. APPLICABILITY AND DEFINITIONS + + This License applies to any manual or other work, in any medium, + that contains a notice placed by the copyright holder saying it + can be distributed under the terms of this License. Such a notice + grants a world-wide, royalty-free license, unlimited in duration, + to use that work under the conditions stated herein. The + "Document", below, refers to any such manual or work. Any member + of the public is a licensee, and is addressed as "you". You + accept the license if you copy, modify or distribute the work in a + way requiring permission under copyright law. + + A "Modified Version" of the Document means any work containing the + Document or a portion of it, either copied verbatim, or with + modifications and/or translated into another language. + + A "Secondary Section" is a named appendix or a front-matter section + of the Document that deals exclusively with the relationship of the + publishers or authors of the Document to the Document's overall + subject (or to related matters) and contains nothing that could + fall directly within that overall subject. (Thus, if the Document + is in part a textbook of mathematics, a Secondary Section may not + explain any mathematics.) The relationship could be a matter of + historical connection with the subject or with related matters, or + of legal, commercial, philosophical, ethical or political position + regarding them. + + The "Invariant Sections" are certain Secondary Sections whose + titles are designated, as being those of Invariant Sections, in + the notice that says that the Document is released under this + License. If a section does not fit the above definition of + Secondary then it is not allowed to be designated as Invariant. + The Document may contain zero Invariant Sections. If the Document + does not identify any Invariant Sections then there are none. + + The "Cover Texts" are certain short passages of text that are + listed, as Front-Cover Texts or Back-Cover Texts, in the notice + that says that the Document is released under this License. A + Front-Cover Text may be at most 5 words, and a Back-Cover Text may + be at most 25 words. + + A "Transparent" copy of the Document means a machine-readable copy, + represented in a format whose specification is available to the + general public, that is suitable for revising the document + straightforwardly with generic text editors or (for images + composed of pixels) generic paint programs or (for drawings) some + widely available drawing editor, and that is suitable for input to + text formatters or for automatic translation to a variety of + formats suitable for input to text formatters. A copy made in an + otherwise Transparent file format whose markup, or absence of + markup, has been arranged to thwart or discourage subsequent + modification by readers is not Transparent. An image format is + not Transparent if used for any substantial amount of text. A + copy that is not "Transparent" is called "Opaque". + + Examples of suitable formats for Transparent copies include plain + ASCII without markup, Texinfo input format, LaTeX input format, + SGML or XML using a publicly available DTD, and + standard-conforming simple HTML, PostScript or PDF designed for + human modification. Examples of transparent image formats include + PNG, XCF and JPG. Opaque formats include proprietary formats that + can be read and edited only by proprietary word processors, SGML or + XML for which the DTD and/or processing tools are not generally + available, and the machine-generated HTML, PostScript or PDF + produced by some word processors for output purposes only. + + The "Title Page" means, for a printed book, the title page itself, + plus such following pages as are needed to hold, legibly, the + material this License requires to appear in the title page. For + works in formats which do not have any title page as such, "Title + Page" means the text near the most prominent appearance of the + work's title, preceding the beginning of the body of the text. + + The "publisher" means any person or entity that distributes copies + of the Document to the public. + + A section "Entitled XYZ" means a named subunit of the Document + whose title either is precisely XYZ or contains XYZ in parentheses + following text that translates XYZ in another language. (Here XYZ + stands for a specific section name mentioned below, such as + "Acknowledgements", "Dedications", "Endorsements", or "History".) + To "Preserve the Title" of such a section when you modify the + Document means that it remains a section "Entitled XYZ" according + to this definition. + + The Document may include Warranty Disclaimers next to the notice + which states that this License applies to the Document. These + Warranty Disclaimers are considered to be included by reference in + this License, but only as regards disclaiming warranties: any other + implication that these Warranty Disclaimers may have is void and + has no effect on the meaning of this License. + + 2. VERBATIM COPYING + + You may copy and distribute the Document in any medium, either + commercially or noncommercially, provided that this License, the + copyright notices, and the license notice saying this License + applies to the Document are reproduced in all copies, and that you + add no other conditions whatsoever to those of this License. You + may not use technical measures to obstruct or control the reading + or further copying of the copies you make or distribute. However, + you may accept compensation in exchange for copies. If you + distribute a large enough number of copies you must also follow + the conditions in section 3. + + You may also lend copies, under the same conditions stated above, + and you may publicly display copies. + + 3. COPYING IN QUANTITY + + If you publish printed copies (or copies in media that commonly + have printed covers) of the Document, numbering more than 100, and + the Document's license notice requires Cover Texts, you must + enclose the copies in covers that carry, clearly and legibly, all + these Cover Texts: Front-Cover Texts on the front cover, and + Back-Cover Texts on the back cover. Both covers must also clearly + and legibly identify you as the publisher of these copies. The + front cover must present the full title with all words of the + title equally prominent and visible. You may add other material + on the covers in addition. Copying with changes limited to the + covers, as long as they preserve the title of the Document and + satisfy these conditions, can be treated as verbatim copying in + other respects. + + If the required texts for either cover are too voluminous to fit + legibly, you should put the first ones listed (as many as fit + reasonably) on the actual cover, and continue the rest onto + adjacent pages. + + If you publish or distribute Opaque copies of the Document + numbering more than 100, you must either include a + machine-readable Transparent copy along with each Opaque copy, or + state in or with each Opaque copy a computer-network location from + which the general network-using public has access to download + using public-standard network protocols a complete Transparent + copy of the Document, free of added material. If you use the + latter option, you must take reasonably prudent steps, when you + begin distribution of Opaque copies in quantity, to ensure that + this Transparent copy will remain thus accessible at the stated + location until at least one year after the last time you + distribute an Opaque copy (directly or through your agents or + retailers) of that edition to the public. + + It is requested, but not required, that you contact the authors of + the Document well before redistributing any large number of + copies, to give them a chance to provide you with an updated + version of the Document. + + 4. MODIFICATIONS + + You may copy and distribute a Modified Version of the Document + under the conditions of sections 2 and 3 above, provided that you + release the Modified Version under precisely this License, with + the Modified Version filling the role of the Document, thus + licensing distribution and modification of the Modified Version to + whoever possesses a copy of it. In addition, you must do these + things in the Modified Version: + + A. Use in the Title Page (and on the covers, if any) a title + distinct from that of the Document, and from those of + previous versions (which should, if there were any, be listed + in the History section of the Document). You may use the + same title as a previous version if the original publisher of + that version gives permission. + + B. List on the Title Page, as authors, one or more persons or + entities responsible for authorship of the modifications in + the Modified Version, together with at least five of the + principal authors of the Document (all of its principal + authors, if it has fewer than five), unless they release you + from this requirement. + + C. State on the Title page the name of the publisher of the + Modified Version, as the publisher. + + D. Preserve all the copyright notices of the Document. + + E. Add an appropriate copyright notice for your modifications + adjacent to the other copyright notices. + + F. Include, immediately after the copyright notices, a license + notice giving the public permission to use the Modified + Version under the terms of this License, in the form shown in + the Addendum below. + + G. Preserve in that license notice the full lists of Invariant + Sections and required Cover Texts given in the Document's + license notice. + + H. Include an unaltered copy of this License. + + I. Preserve the section Entitled "History", Preserve its Title, + and add to it an item stating at least the title, year, new + authors, and publisher of the Modified Version as given on + the Title Page. If there is no section Entitled "History" in + the Document, create one stating the title, year, authors, + and publisher of the Document as given on its Title Page, + then add an item describing the Modified Version as stated in + the previous sentence. + + J. Preserve the network location, if any, given in the Document + for public access to a Transparent copy of the Document, and + likewise the network locations given in the Document for + previous versions it was based on. These may be placed in + the "History" section. You may omit a network location for a + work that was published at least four years before the + Document itself, or if the original publisher of the version + it refers to gives permission. + + K. For any section Entitled "Acknowledgements" or "Dedications", + Preserve the Title of the section, and preserve in the + section all the substance and tone of each of the contributor + acknowledgements and/or dedications given therein. + + L. Preserve all the Invariant Sections of the Document, + unaltered in their text and in their titles. Section numbers + or the equivalent are not considered part of the section + titles. + + M. Delete any section Entitled "Endorsements". Such a section + may not be included in the Modified Version. + + N. Do not retitle any existing section to be Entitled + "Endorsements" or to conflict in title with any Invariant + Section. + + O. Preserve any Warranty Disclaimers. + + If the Modified Version includes new front-matter sections or + appendices that qualify as Secondary Sections and contain no + material copied from the Document, you may at your option + designate some or all of these sections as invariant. To do this, + add their titles to the list of Invariant Sections in the Modified + Version's license notice. These titles must be distinct from any + other section titles. + + You may add a section Entitled "Endorsements", provided it contains + nothing but endorsements of your Modified Version by various + parties--for example, statements of peer review or that the text + has been approved by an organization as the authoritative + definition of a standard. + + You may add a passage of up to five words as a Front-Cover Text, + and a passage of up to 25 words as a Back-Cover Text, to the end + of the list of Cover Texts in the Modified Version. Only one + passage of Front-Cover Text and one of Back-Cover Text may be + added by (or through arrangements made by) any one entity. If the + Document already includes a cover text for the same cover, + previously added by you or by arrangement made by the same entity + you are acting on behalf of, you may not add another; but you may + replace the old one, on explicit permission from the previous + publisher that added the old one. + + The author(s) and publisher(s) of the Document do not by this + License give permission to use their names for publicity for or to + assert or imply endorsement of any Modified Version. + + 5. COMBINING DOCUMENTS + + You may combine the Document with other documents released under + this License, under the terms defined in section 4 above for + modified versions, provided that you include in the combination + all of the Invariant Sections of all of the original documents, + unmodified, and list them all as Invariant Sections of your + combined work in its license notice, and that you preserve all + their Warranty Disclaimers. + + The combined work need only contain one copy of this License, and + multiple identical Invariant Sections may be replaced with a single + copy. If there are multiple Invariant Sections with the same name + but different contents, make the title of each such section unique + by adding at the end of it, in parentheses, the name of the + original author or publisher of that section if known, or else a + unique number. Make the same adjustment to the section titles in + the list of Invariant Sections in the license notice of the + combined work. + + In the combination, you must combine any sections Entitled + "History" in the various original documents, forming one section + Entitled "History"; likewise combine any sections Entitled + "Acknowledgements", and any sections Entitled "Dedications". You + must delete all sections Entitled "Endorsements." + + 6. COLLECTIONS OF DOCUMENTS + + You may make a collection consisting of the Document and other + documents released under this License, and replace the individual + copies of this License in the various documents with a single copy + that is included in the collection, provided that you follow the + rules of this License for verbatim copying of each of the + documents in all other respects. + + You may extract a single document from such a collection, and + distribute it individually under this License, provided you insert + a copy of this License into the extracted document, and follow + this License in all other respects regarding verbatim copying of + that document. + + 7. AGGREGATION WITH INDEPENDENT WORKS + + A compilation of the Document or its derivatives with other + separate and independent documents or works, in or on a volume of + a storage or distribution medium, is called an "aggregate" if the + copyright resulting from the compilation is not used to limit the + legal rights of the compilation's users beyond what the individual + works permit. When the Document is included in an aggregate, this + License does not apply to the other works in the aggregate which + are not themselves derivative works of the Document. + + If the Cover Text requirement of section 3 is applicable to these + copies of the Document, then if the Document is less than one half + of the entire aggregate, the Document's Cover Texts may be placed + on covers that bracket the Document within the aggregate, or the + electronic equivalent of covers if the Document is in electronic + form. Otherwise they must appear on printed covers that bracket + the whole aggregate. + + 8. TRANSLATION + + Translation is considered a kind of modification, so you may + distribute translations of the Document under the terms of section + 4. Replacing Invariant Sections with translations requires special + permission from their copyright holders, but you may include + translations of some or all Invariant Sections in addition to the + original versions of these Invariant Sections. You may include a + translation of this License, and all the license notices in the + Document, and any Warranty Disclaimers, provided that you also + include the original English version of this License and the + original versions of those notices and disclaimers. In case of a + disagreement between the translation and the original version of + this License or a notice or disclaimer, the original version will + prevail. + + If a section in the Document is Entitled "Acknowledgements", + "Dedications", or "History", the requirement (section 4) to + Preserve its Title (section 1) will typically require changing the + actual title. + + 9. TERMINATION + + You may not copy, modify, sublicense, or distribute the Document + except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense, or distribute it is void, + and will automatically terminate your rights under this License. + + However, if you cease all violation of this License, then your + license from a particular copyright holder is reinstated (a) + provisionally, unless and until the copyright holder explicitly + and finally terminates your license, and (b) permanently, if the + copyright holder fails to notify you of the violation by some + reasonable means prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is + reinstated permanently if the copyright holder notifies you of the + violation by some reasonable means, this is the first time you have + received notice of violation of this License (for any work) from + that copyright holder, and you cure the violation prior to 30 days + after your receipt of the notice. + + Termination of your rights under this section does not terminate + the licenses of parties who have received copies or rights from + you under this License. If your rights have been terminated and + not permanently reinstated, receipt of a copy of some or all of + the same material does not give you any rights to use it. + + 10. FUTURE REVISIONS OF THIS LICENSE + + The Free Software Foundation may publish new, revised versions of + the GNU Free Documentation License from time to time. Such new + versions will be similar in spirit to the present version, but may + differ in detail to address new problems or concerns. See + `http://www.gnu.org/copyleft/'. + + Each version of the License is given a distinguishing version + number. If the Document specifies that a particular numbered + version of this License "or any later version" applies to it, you + have the option of following the terms and conditions either of + that specified version or of any later version that has been + published (not as a draft) by the Free Software Foundation. If + the Document does not specify a version number of this License, + you may choose any version ever published (not as a draft) by the + Free Software Foundation. If the Document specifies that a proxy + can decide which future versions of this License can be used, that + proxy's public statement of acceptance of a version permanently + authorizes you to choose that version for the Document. + + 11. RELICENSING + + "Massive Multiauthor Collaboration Site" (or "MMC Site") means any + World Wide Web server that publishes copyrightable works and also + provides prominent facilities for anybody to edit those works. A + public wiki that anybody can edit is an example of such a server. + A "Massive Multiauthor Collaboration" (or "MMC") contained in the + site means any set of copyrightable works thus published on the MMC + site. + + "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 + license published by Creative Commons Corporation, a not-for-profit + corporation with a principal place of business in San Francisco, + California, as well as future copyleft versions of that license + published by that same organization. + + "Incorporate" means to publish or republish a Document, in whole or + in part, as part of another Document. + + An MMC is "eligible for relicensing" if it is licensed under this + License, and if all works that were first published under this + License somewhere other than this MMC, and subsequently + incorporated in whole or in part into the MMC, (1) had no cover + texts or invariant sections, and (2) were thus incorporated prior + to November 1, 2008. + + The operator of an MMC Site may republish an MMC contained in the + site under CC-BY-SA on the same site at any time before August 1, + 2009, provided the MMC is eligible for relicensing. + + +ADDENDUM: How to use this License for your documents +==================================================== + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and license +notices just after the title page: + + Copyright (C) YEAR YOUR NAME. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover + Texts. A copy of the license is included in the section entitled ``GNU + Free Documentation License''. + + If you have Invariant Sections, Front-Cover Texts and Back-Cover +Texts, replace the "with...Texts." line with this: + + with the Invariant Sections being LIST THEIR TITLES, with + the Front-Cover Texts being LIST, and with the Back-Cover Texts + being LIST. + + If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + + If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, to +permit their use in free software. + + +File: gawkinet.info, Node: Index, Prev: GNU Free Documentation License, Up: Top + +Index +***** + +[index] +* Menu: + +* /inet/ files (gawk): Gawk Special Files. (line 34) +* /inet/tcp special files (gawk): File /inet/tcp. (line 6) +* /inet/udp special files (gawk): File /inet/udp. (line 6) +* advanced features, network connections: Troubleshooting. (line 6) +* agent <1>: MOBAGWHO. (line 6) +* agent: Challenges. (line 76) +* AI: Challenges. (line 76) +* apache <1>: MOBAGWHO. (line 42) +* apache: WEBGRAB. (line 72) +* Bioinformatics: PROTBASE. (line 227) +* BLAST, Basic Local Alignment Search Tool: PROTBASE. (line 6) +* blocking: Making Connections. (line 35) +* Boutell, Thomas: STATIST. (line 6) +* CGI (Common Gateway Interface): MOBAGWHO. (line 42) +* CGI (Common Gateway Interface), dynamic web pages and: Web page. + (line 46) +* CGI (Common Gateway Interface), library: CGI Lib. (line 11) +* clients: Making Connections. (line 21) +* Clinton, Bill: Challenges. (line 59) +* Common Gateway Interface, See CGI: Web page. (line 46) +* Computational Biology: PROTBASE. (line 227) +* contest: Challenges. (line 6) +* cron utility: STOXPRED. (line 23) +* CSV format: STOXPRED. (line 128) +* Dow Jones Industrial Index: STOXPRED. (line 44) +* ELIZA program: Simple Server. (line 11) +* email: Email. (line 11) +* FASTA/Pearson format: PROTBASE. (line 102) +* FDL (Free Documentation License): GNU Free Documentation License. + (line 6) +* filenames, for network access: Gawk Special Files. (line 29) +* files, /inet/ (gawk): Gawk Special Files. (line 34) +* files, /inet/tcp (gawk): File /inet/tcp. (line 6) +* files, /inet/udp (gawk): File /inet/udp. (line 6) +* finger utility: Setting Up. (line 22) +* Free Documentation License (FDL): GNU Free Documentation License. + (line 6) +* FTP (File Transfer Protocol): Basic Protocols. (line 45) +* gawk, networking: Using Networking. (line 6) +* gawk, networking, connections <1>: TCP Connecting. (line 6) +* gawk, networking, connections: Special File Fields. (line 53) +* gawk, networking, filenames: Gawk Special Files. (line 29) +* gawk, networking, See Also email: Email. (line 6) +* gawk, networking, service, establishing: Setting Up. (line 6) +* gawk, networking, troubleshooting: Caveats. (line 6) +* gawk, web and, See web service: Interacting Service. (line 6) +* getline command: TCP Connecting. (line 11) +* GETURL program: GETURL. (line 6) +* GIF image format <1>: STATIST. (line 6) +* GIF image format: Web page. (line 46) +* GNU Free Documentation License: GNU Free Documentation License. + (line 6) +* GNU/Linux <1>: REMCONF. (line 6) +* GNU/Linux <2>: Interacting. (line 27) +* GNU/Linux: Troubleshooting. (line 54) +* GNUPlot utility <1>: STATIST. (line 6) +* GNUPlot utility: Interacting Service. (line 189) +* Hoare, C.A.R. <1>: PROTBASE. (line 6) +* Hoare, C.A.R.: MOBAGWHO. (line 6) +* hostname field: Special File Fields. (line 34) +* HTML (Hypertext Markup Language): Web page. (line 30) +* HTTP (Hypertext Transfer Protocol) <1>: Web page. (line 6) +* HTTP (Hypertext Transfer Protocol): Basic Protocols. (line 45) +* HTTP (Hypertext Transfer Protocol), record separators and: Web page. + (line 30) +* HTTP server, core logic: Interacting Service. (line 6) +* Humphrys, Mark: Simple Server. (line 179) +* Hypertext Markup Language (HTML): Web page. (line 30) +* Hypertext Transfer Protocol, See HTTP: Web page. (line 6) +* image format: STATIST. (line 6) +* images, in web pages: Interacting Service. (line 189) +* images, retrieving over networks: Web page. (line 46) +* input/output, two-way, See Also gawk, networking: Gawk Special Files. + (line 19) +* Internet, See networks: Interacting. (line 48) +* JavaScript: STATIST. (line 56) +* Linux <1>: REMCONF. (line 6) +* Linux <2>: Interacting. (line 27) +* Linux: Troubleshooting. (line 54) +* Lisp: MOBAGWHO. (line 98) +* localport field: Gawk Special Files. (line 34) +* Loebner, Hugh: Challenges. (line 6) +* Loui, Ronald: Challenges. (line 76) +* MAZE: MAZE. (line 6) +* Microsoft Windows: WEBGRAB. (line 43) +* Microsoft Windows, networking: Troubleshooting. (line 54) +* Microsoft Windows, networking, ports: Setting Up. (line 37) +* MiniSQL: REMCONF. (line 111) +* MOBAGWHO program: MOBAGWHO. (line 6) +* NCBI, National Center for Biotechnology Information: PROTBASE. + (line 6) +* network type field: Special File Fields. (line 11) +* networks, gawk and: Using Networking. (line 6) +* networks, gawk and, connections <1>: TCP Connecting. (line 6) +* networks, gawk and, connections: Special File Fields. (line 53) +* networks, gawk and, filenames: Gawk Special Files. (line 29) +* networks, gawk and, See Also email: Email. (line 6) +* networks, gawk and, service, establishing: Setting Up. (line 6) +* networks, gawk and, troubleshooting: Caveats. (line 6) +* networks, ports, reserved: Setting Up. (line 37) +* networks, ports, specifying: Special File Fields. (line 24) +* networks, See Also web pages: PANIC. (line 6) +* Numerical Recipes: STATIST. (line 24) +* ORS variable, HTTP and: Web page. (line 30) +* ORS variable, POP and: Email. (line 36) +* PANIC program: PANIC. (line 6) +* Perl: Using Networking. (line 14) +* Perl, gawk networking and: Using Networking. (line 24) +* Perlis, Alan: MAZE. (line 6) +* pipes, networking and: TCP Connecting. (line 30) +* PNG image format <1>: STATIST. (line 6) +* PNG image format: Web page. (line 46) +* POP (Post Office Protocol): Email. (line 6) +* Post Office Protocol (POP): Email. (line 6) +* PostScript: STATIST. (line 138) +* PROLOG: Challenges. (line 76) +* PROTBASE: PROTBASE. (line 6) +* protocol field: Special File Fields. (line 17) +* PS image format: STATIST. (line 6) +* Python: Using Networking. (line 14) +* Python, gawk networking and: Using Networking. (line 24) +* record separators, HTTP and: Web page. (line 30) +* record separators, POP and: Email. (line 36) +* REMCONF program: REMCONF. (line 6) +* remoteport field: Gawk Special Files. (line 34) +* robot <1>: WEBGRAB. (line 6) +* robot: Challenges. (line 85) +* RS variable, HTTP and: Web page. (line 30) +* RS variable, POP and: Email. (line 36) +* servers <1>: Setting Up. (line 22) +* servers: Making Connections. (line 14) +* servers, as hosts: Special File Fields. (line 34) +* servers, HTTP: Interacting Service. (line 6) +* servers, web: Simple Server. (line 6) +* Simple Mail Transfer Protocol (SMTP): Email. (line 6) +* SMTP (Simple Mail Transfer Protocol) <1>: Email. (line 6) +* SMTP (Simple Mail Transfer Protocol): Basic Protocols. (line 45) +* STATIST program: STATIST. (line 6) +* STOXPRED program: STOXPRED. (line 6) +* synchronous communications: Making Connections. (line 35) +* Tcl/Tk: Using Networking. (line 14) +* Tcl/Tk, gawk and <1>: Some Applications and Techniques. + (line 22) +* Tcl/Tk, gawk and: Using Networking. (line 24) +* TCP (Transmission Control Protocol) <1>: File /inet/tcp. (line 6) +* TCP (Transmission Control Protocol): Using Networking. (line 29) +* TCP (Transmission Control Protocol), connection, establishing: TCP Connecting. + (line 6) +* TCP (Transmission Control Protocol), UDP and: Interacting. (line 48) +* TCP/IP, network type, selecting: Special File Fields. (line 11) +* TCP/IP, protocols, selecting: Special File Fields. (line 17) +* TCP/IP, sockets and: Gawk Special Files. (line 19) +* Transmission Control Protocol, See TCP: Using Networking. (line 29) +* troubleshooting, gawk, networks: Caveats. (line 6) +* troubleshooting, networks, connections: Troubleshooting. (line 6) +* troubleshooting, networks, timeouts: Caveats. (line 18) +* UDP (User Datagram Protocol): File /inet/udp. (line 6) +* UDP (User Datagram Protocol), TCP and: Interacting. (line 48) +* Unix, network ports and: Setting Up. (line 37) +* URLCHK program: URLCHK. (line 6) +* User Datagram Protocol, See UDP: File /inet/udp. (line 6) +* vertical bar (|), |& operator (I/O): TCP Connecting. (line 25) +* VRML: MAZE. (line 6) +* web browsers, See web service: Interacting Service. (line 6) +* web pages: Web page. (line 6) +* web pages, images in: Interacting Service. (line 189) +* web pages, retrieving: GETURL. (line 6) +* web servers: Simple Server. (line 6) +* web service <1>: PANIC. (line 6) +* web service: Primitive Service. (line 6) +* WEBGRAB program: WEBGRAB. (line 6) +* Weizenbaum, Joseph: Simple Server. (line 11) +* XBM image format: Interacting Service. (line 189) +* Yahoo! <1>: STOXPRED. (line 6) +* Yahoo!: REMCONF. (line 6) +* | (vertical bar), |& operator (I/O): TCP Connecting. (line 25) + + + +Tag Table: +Node: Top2015 +Node: Preface5652 +Node: Introduction7027 +Node: Stream Communications8053 +Node: Datagram Communications9226 +Node: The TCP/IP Protocols10857 +Ref: The TCP/IP Protocols-Footnote-111541 +Node: Basic Protocols11698 +Ref: Basic Protocols-Footnote-113741 +Node: Ports13770 +Node: Making Connections15177 +Ref: Making Connections-Footnote-117738 +Ref: Making Connections-Footnote-217785 +Node: Using Networking17966 +Node: Gawk Special Files20284 +Node: Special File Fields22094 +Ref: table-inet-components25967 +Node: Comparing Protocols27287 +Node: File /inet/tcp27820 +Node: File /inet/udp28846 +Node: TCP Connecting29944 +Node: Troubleshooting32282 +Ref: Troubleshooting-Footnote-135334 +Node: Interacting35903 +Node: Setting Up38633 +Node: Email42127 +Node: Web page44453 +Ref: Web page-Footnote-147258 +Node: Primitive Service47455 +Node: Interacting Service50189 +Ref: Interacting Service-Footnote-159318 +Node: CGI Lib59350 +Node: Simple Server66311 +Ref: Simple Server-Footnote-174034 +Node: Caveats74135 +Node: Challenges75278 +Node: Some Applications and Techniques83957 +Node: PANIC86414 +Node: GETURL88132 +Node: REMCONF90755 +Node: URLCHK96231 +Node: WEBGRAB100066 +Node: STATIST104516 +Ref: STATIST-Footnote-1116224 +Node: MAZE116669 +Node: MOBAGWHO122853 +Ref: MOBAGWHO-Footnote-1136797 +Node: STOXPRED136852 +Node: PROTBASE151107 +Node: Links164188 +Node: GNU Free Documentation License167622 +Node: Index192761 + +End Tag Table diff --git a/doc/gawkinet.texi b/doc/gawkinet.texi new file mode 100644 index 0000000..eb0f2d8 --- /dev/null +++ b/doc/gawkinet.texi @@ -0,0 +1,5187 @@ +\input texinfo @c -*-texinfo-*- +@c %**start of header (This is for running Texinfo on a region.) +@setfilename gawkinet.info +@settitle TCP/IP Internetworking With @command{gawk} +@c %**end of header (This is for running Texinfo on a region.) +@c FIXME: web vs. Web + +@dircategory Network applications +@direntry +* Gawkinet: (gawkinet). TCP/IP Internetworking With `gawk'. +@end direntry + +@iftex +@set DOCUMENT book +@set CHAPTER chapter +@set SECTION section +@set DARKCORNER @inmargin{@image{lflashlight,1cm}, @image{rflashlight,1cm}} +@end iftex +@ifinfo +@set DOCUMENT Info file +@set CHAPTER major node +@set SECTION node +@set DARKCORNER (d.c.) +@end ifinfo +@ifhtml +@set DOCUMENT web page +@set CHAPTER chapter +@set SECTION section +@set DARKCORNER (d.c.) +@end ifhtml + +@set FSF + +@set FN file name +@set FFN File Name + +@c merge the function and variable indexes into the concept index +@ifinfo +@synindex fn cp +@synindex vr cp +@end ifinfo +@iftex +@syncodeindex fn cp +@syncodeindex vr cp +@end iftex + +@c If "finalout" is commented out, the printed output will show +@c black boxes that mark lines that are too long. Thus, it is +@c unwise to comment it out when running a master in case there are +@c overfulls which are deemed okay. + +@iftex +@finalout +@end iftex + +@smallbook + +@c Special files are described in chapter 6 Printing Output under +@c 6.7 Special File Names in gawk. I think the networking does not +@c fit into that chapter, thus this separate document. At over 50 +@c pages, I think this is the right decision. ADR. + +@set TITLE TCP/IP Internetworking With @command{gawk} +@set EDITION 1.3 +@set UPDATE-MONTH December, 2010 +@c gawk versions: +@set VERSION 4.0 +@set PATCHLEVEL 0 + +@copying +This is Edition @value{EDITION} of @cite{@value{TITLE}}, +for the @value{VERSION}.@value{PATCHLEVEL} (or later) version of the GNU +implementation of AWK. +@sp 2 +Copyright (C) 2000, 2001, 2002, 2004, 2009, 2010 Free Software Foundation, Inc. +@sp 2 +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with the +Invariant Sections being ``GNU General Public License'', the Front-Cover +texts being (a) (see below), and with the Back-Cover Texts being (b) +(see below). A copy of the license is included in the section entitled +``GNU Free Documentation License''. + +@enumerate a +@item +``A GNU Manual'' + +@item +``You have the freedom to +copy and modify this GNU manual. Buying copies from the FSF +supports it in developing GNU and promoting software freedom.'' +@end enumerate +@end copying + +@ifinfo +This file documents the networking features in GNU @command{awk}. + +@insertcopying +@end ifinfo + +@setchapternewpage odd + +@titlepage +@title @value{TITLE} +@subtitle Edition @value{EDITION} +@subtitle @value{UPDATE-MONTH} +@author J@"urgen Kahrs +@author with Arnold D. Robbins + +@c Include the Distribution inside the titlepage environment so +@c that headings are turned off. Headings on and off do not work. + +@page +@vskip 0pt plus 1filll +@sp 2 +Published by: +@sp 1 + +Free Software Foundation @* +51 Franklin Street, Fifth Floor @* +Boston, MA 02110-1301 USA @* +Phone: +1-617-542-5942 @* +Fax: +1-617-542-2652 @* +Email: @email{gnu@@gnu.org} @* +URL: @uref{http://www.gnu.org/} @* + +ISBN 1-882114-93-0 @* + +@insertcopying + +@c @sp 2 +@c Cover art by ?????. +@end titlepage + +@iftex +@headings off +@evenheading @thispage@ @ @ @strong{@value{TITLE}} @| @| +@oddheading @| @| @strong{@thischapter}@ @ @ @thispage +@end iftex + +@ifnottex +@node Top, Preface, (dir), (dir) +@top General Introduction +@comment node-name, next, previous, up + +This file documents the networking features in GNU Awk (@command{gawk}) +version 4.0 and later. + +@insertcopying +@end ifnottex + +@menu +* Preface:: About this document. +* Introduction:: About networking. +* Using Networking:: Some examples. +* Some Applications and Techniques:: More extended examples. +* Links:: Where to find the stuff mentioned in this + document. +* GNU Free Documentation License:: The license for this document. +* Index:: The index. + +@detailmenu +* Stream Communications:: Sending data streams. +* Datagram Communications:: Sending self-contained messages. +* The TCP/IP Protocols:: How these models work in the Internet. +* Basic Protocols:: The basic protocols. +* Ports:: The idea behind ports. +* Making Connections:: Making TCP/IP connections. +* Gawk Special Files:: How to do @command{gawk} networking. +* Special File Fields:: The fields in the special file name. +* Comparing Protocols:: Differences between the protocols. +* File /inet/tcp:: The TCP special file. +* File /inet/udp:: The UDP special file. +* TCP Connecting:: Making a TCP connection. +* Troubleshooting:: Troubleshooting TCP/IP connections. +* Interacting:: Interacting with a service. +* Setting Up:: Setting up a service. +* Email:: Reading email. +* Web page:: Reading a Web page. +* Primitive Service:: A primitive Web service. +* Interacting Service:: A Web service with interaction. +* CGI Lib:: A simple CGI library. +* Simple Server:: A simple Web server. +* Caveats:: Network programming caveats. +* Challenges:: Where to go from here. +* PANIC:: An Emergency Web Server. +* GETURL:: Retrieving Web Pages. +* REMCONF:: Remote Configuration Of Embedded Systems. +* URLCHK:: Look For Changed Web Pages. +* WEBGRAB:: Extract Links From A Page. +* STATIST:: Graphing A Statistical Distribution. +* MAZE:: Walking Through A Maze In Virtual Reality. +* MOBAGWHO:: A Simple Mobile Agent. +* STOXPRED:: Stock Market Prediction As A Service. +* PROTBASE:: Searching Through A Protein Database. +@end detailmenu +@end menu + +@contents + +@node Preface, Introduction, Top, Top +@unnumbered Preface + +In May of 1997, J@"urgen Kahrs felt the need for network access +from @command{awk}, and, with a little help from me, set about adding +features to do this for @command{gawk}. At that time, he +wrote the bulk of this @value{DOCUMENT}. + +The code and documentation were added to the @command{gawk} 3.1 development +tree, and languished somewhat until I could finally get +down to some serious work on that version of @command{gawk}. +This finally happened in the middle of 2000. + +Meantime, J@"urgen wrote an article about the Internet special +files and @samp{|&} operator for @cite{Linux Journal}, and made a +networking patch for the production versions of @command{gawk} +available from his home page. +In August of 2000 (for @command{gawk} 3.0.6), this patch +also made it to the main GNU @command{ftp} distribution site. + +For release with @command{gawk}, I edited J@"urgen's prose +for English grammar and style, as he is not a native English +speaker. I also +rearranged the material somewhat for what I felt was a better order of +presentation, and (re)wrote some of the introductory material. + +The majority of this document and the code are his work, and the +high quality and interesting ideas speak for themselves. It is my +hope that these features will be of significant value to the @command{awk} +community. + +@sp 1 +@noindent +Arnold Robbins @* +Nof Ayalon, ISRAEL @* +March, 2001 + +@node Introduction, Using Networking, Preface, Top +@chapter Networking Concepts + +This @value{CHAPTER} provides a (necessarily) brief introduction to +computer networking concepts. For many applications of @command{gawk} +to TCP/IP networking, we hope that this is enough. For more +advanced tasks, you will need deeper background, and it may be necessary +to switch to lower-level programming in C or C++. + +There are two real-life models for the way computers send messages +to each other over a network. While the analogies are not perfect, +they are close enough to convey the major concepts. +These two models are the phone system (reliable byte-stream communications), +and the postal system (best-effort datagrams). + +@menu +* Stream Communications:: Sending data streams. +* Datagram Communications:: Sending self-contained messages. +* The TCP/IP Protocols:: How these models work in the Internet. +* Making Connections:: Making TCP/IP connections. +@end menu + +@node Stream Communications, Datagram Communications, Introduction, Introduction +@section Reliable Byte-streams (Phone Calls) + +When you make a phone call, the following steps occur: + +@enumerate +@item +You dial a number. + +@item +The phone system connects to the called party, telling +them there is an incoming call. (Their phone rings.) + +@item +The other party answers the call, or, in the case of a +computer network, refuses to answer the call. + +@item +Assuming the other party answers, the connection between +you is now a @dfn{duplex} (two-way), @dfn{reliable} (no data lost), +sequenced (data comes out in the order sent) data stream. + +@item +You and your friend may now talk freely, with the phone system +moving the data (your voices) from one end to the other. +From your point of view, you have a direct end-to-end +connection with the person on the other end. +@end enumerate + +The same steps occur in a duplex reliable computer networking connection. +There is considerably more overhead in setting up the communications, +but once it's done, data moves in both directions, reliably, in sequence. + +@node Datagram Communications, The TCP/IP Protocols, Stream Communications, Introduction +@section Best-effort Datagrams (Mailed Letters) + +Suppose you mail three different documents to your office on the +other side of the country on two different days. Doing so +entails the following. + +@enumerate +@item +Each document travels in its own envelope. + +@item +Each envelope contains both the sender and the +recipient address. + +@item +Each envelope may travel a different route to its destination. + +@item +The envelopes may arrive in a different order from the one +in which they were sent. + +@item +One or more may get lost in the mail. +(Although, fortunately, this does not occur very often.) + +@item +In a computer network, one or more @dfn{packets} +may also arrive multiple times. (This doesn't happen +with the postal system!) + +@end enumerate + +The important characteristics of datagram communications, like +those of the postal system are thus: + +@itemize @bullet +@item +Delivery is ``best effort;'' the data may never get there. + +@item +Each message is self-contained, including the source and +destination addresses. + +@item +Delivery is @emph{not} sequenced; packets may arrive out +of order, and/or multiple times. + +@item +Unlike the phone system, overhead is considerably lower. +It is not necessary to set up the call first. +@end itemize + +The price the user pays for the lower overhead of datagram communications +is exactly the lower reliability; it is often necessary for user-level +protocols that use datagram communications to add their own reliability +features on top of the basic communications. + +@node The TCP/IP Protocols, Making Connections, Datagram Communications, Introduction +@section The Internet Protocols + +The Internet Protocol Suite (usually referred to as just TCP/IP)@footnote{ +It should be noted that although the Internet seems to have conquered the +world, there are other networking protocol suites in existence and in use.} +consists of a number of different protocols at different levels or ``layers.'' +For our purposes, three protocols provide the fundamental communications +mechanisms. All other defined protocols are referred to as user-level +protocols (e.g., HTTP, used later in this @value{DOCUMENT}). + +@menu +* Basic Protocols:: The basic protocols. +* Ports:: The idea behind ports. +@end menu + +@node Basic Protocols, Ports, The TCP/IP Protocols, The TCP/IP Protocols +@subsection The Basic Internet Protocols + +@table @asis +@item IP +The Internet Protocol. This protocol is almost never used directly by +applications. It provides the basic packet delivery and routing infrastructure +of the Internet. Much like the phone company's switching centers or the Post +Office's trucks, it is not of much day-to-day interest to the regular user +(or programmer). +It happens to be a best effort datagram protocol. +In the early twenty-first century, there are two versions of this protocol +in use: + +@table @asis +@item IPv4 +The original version of the Internet Protocol, with 32-bit addresses, on which +most of the current Internet is based. + +@item IPv6 +The ``next generation'' of the Internet Protocol, with 128-bit addresses. +This protocol is in wide use in certain parts of the world, but has not +yet replaced IPv4.@footnote{There isn't an IPv5.} +@end table + +Versions of the other protocols that sit ``atop'' IP exist for both +IPv4 and IPv6. However, as the IPv6 versions are fundamentally the same +as the original IPv4 versions, we will not distinguish further between them. + +@item UDP +The User Datagram Protocol. This is a best effort datagram protocol. +It provides a small amount of extra reliability over IP, and adds +the notion of @dfn{ports}, described in @ref{Ports, ,TCP and UDP Ports}. + +@item TCP +The Transmission Control Protocol. This is a duplex, reliable, sequenced +byte-stream protocol, again layered on top of IP, and also providing the +notion of ports. This is the protocol that you will most likely use +when using @command{gawk} for network programming. +@end table + +All other user-level protocols use either TCP or UDP to do their basic +communications. Examples are SMTP (Simple Mail Transfer Protocol), +FTP (File Transfer Protocol), and HTTP (HyperText Transfer Protocol). +@cindex SMTP (Simple Mail Transfer Protocol) +@cindex FTP (File Transfer Protocol) +@cindex HTTP (Hypertext Transfer Protocol) + +@node Ports, , Basic Protocols, The TCP/IP Protocols +@subsection TCP and UDP Ports + +In the postal system, the address on an envelope indicates a physical +location, such as a residence or office building. But there may be +more than one person at the location; thus you have to further quantify +the recipient by putting a person or company name on the envelope. + +In the phone system, one phone number may represent an entire company, +in which case you need a person's extension number in order to +reach that individual directly. Or, when you call a home, you have to +say, ``May I please speak to ...'' before talking to the person directly. + +IP networking provides the concept of addressing. An IP address represents +a particular computer, but no more. In order to reach the mail service +on a system, or the FTP or WWW service on a system, you must have some +way to further specify which service you want. In the Internet Protocol suite, +this is done with @dfn{port numbers}, which represent the services, much +like an extension number used with a phone number. + +Port numbers are 16-bit integers. Unix and Unix-like systems reserve ports +below 1024 for ``well known'' services, such as SMTP, FTP, and HTTP. +Numbers 1024 and above may be used by any application, although there is no +promise made that a particular port number is always available. + +@node Making Connections, , The TCP/IP Protocols, Introduction +@section Making TCP/IP Connections (And Some Terminology) + +Two terms come up repeatedly when discussing networking: +@dfn{client} and @dfn{server}. For now, we'll discuss these terms +at the @dfn{connection level}, when first establishing connections +between two processes on different systems over a network. +(Once the connection is established, the higher level, or +@dfn{application level} protocols, +such as HTTP or FTP, determine who is the client and who is the +server. Often, it turns out that the client and server are the +same in both roles.) + +@cindex servers +The @dfn{server} is the system providing the service, such as the +web server or email server. It is the @dfn{host} (system) which +is @emph{connected to} in a transaction. +For this to work though, the server must be expecting connections. +Much as there has to be someone at the office building to answer +the phone@footnote{In the days before voice mail systems!}, the +server process (usually) has to be started first and be waiting +for a connection. + +@cindex clients +The @dfn{client} is the system requesting the service. +It is the system @emph{initiating the connection} in a transaction. +(Just as when you pick up the phone to call an office or store.) + +In the TCP/IP framework, each end of a connection is represented by a pair +of (@var{address}, @var{port}) pairs. For the duration of the connection, +the ports in use at each end are unique, and cannot be used simultaneously +by other processes on the same system. (Only after closing a connection +can a new one be built up on the same port. This is contrary to the usual +behavior of fully developed web servers which have to avoid situations +in which they are not reachable. We have to pay this price in order to +enjoy the benefits of a simple communication paradigm in @command{gawk}.) + +@cindex blocking +@cindex synchronous communications +Furthermore, once the connection is established, communications are +@dfn{synchronous}.@footnote{For the technically savvy, data reads +block---if there's no incoming data, the program is made to wait until +there is, instead of receiving a ``there's no data'' error return.} I.e., +each end waits on the other to finish transmitting, before replying. This +is much like two people in a phone conversation. While both could talk +simultaneously, doing so usually doesn't work too well. + +In the case of TCP, the synchronicity is enforced by the protocol when +sending data. Data writes @dfn{block} until the data have been received on the +other end. For both TCP and UDP, data reads block until there is incoming +data waiting to be read. This is summarized in the following table, +where an ``X'' indicates that the given action blocks. + +@ifnottex +@multitable {Protocol} {Reads} {Writes} +@item TCP @tab X @tab X +@item UDP @tab X @tab +@end multitable +@end ifnottex +@tex +\centerline{ +\vbox{\bigskip % space above the table (about 1 linespace) +% Because we have vertical rules, we can't let TeX insert interline space +% in its usual way. +\offinterlineskip +\halign{\hfil\strut# &\vrule #& \hfil#\hfil& \hfil#\hfil\cr +Protocol&&\quad Reads\quad &Writes\cr +\noalign{\hrule} +\omit&height 2pt\cr +\noalign{\hrule height0pt}% without this the rule does not extend; why? +TCP&&X&X\cr +UDP&&X&\cr +}}} +@end tex + +@node Using Networking, Some Applications and Techniques, Introduction, Top +@comment node-name, next, previous, up +@chapter Networking With @command{gawk} + +@c STARTOFRANGE netgawk +@cindex networks, @command{gawk} and +@c STARTOFRANGE gawknet +@cindex @command{gawk}, networking +The @command{awk} programming language was originally developed as a +pattern-matching language for writing short programs to perform +data manipulation tasks. +@command{awk}'s strength is the manipulation of textual data +that is stored in files. +It was never meant to be used for networking purposes. +To exploit its features in a +networking context, it's necessary to use an access mode for network connections +that resembles the access of files as closely as possible. + +@cindex Perl +@cindex Python +@cindex Tcl/Tk +@command{awk} is also meant to be a prototyping language. It is used +to demonstrate feasibility and to play with features and user interfaces. +This can be done with file-like handling of network +connections. +@command{gawk} trades the lack +of many of the advanced features of the TCP/IP family of protocols +for the convenience of simple connection handling. +The advanced +features are available when programming in C or Perl. In fact, the +network programming +in this @value{CHAPTER} +is very similar to what is described in books such as +@cite{Internet Programming with Python}, +@cite{Advanced Perl Programming}, +or +@cite{Web Client Programming with Perl}. + +@cindex Perl, @command{gawk} networking and +@cindex Python, @command{gawk} networking and +@cindex Tcl/Tk, @command{gawk} and +However, you can do the programming here without first having to learn object-oriented +ideology; underlying languages such as Tcl/Tk, Perl, Python; or all of +the libraries necessary to extend these languages before they are ready for the Internet. + +@cindex Transmission Control Protocol, See TCP +@cindex TCP (Transmission Control Protocol) +This @value{CHAPTER} demonstrates how to use the TCP protocol. The +UDP protocol is much less important for most users. + +@menu +* Gawk Special Files:: How to do @command{gawk} networking. +* TCP Connecting:: Making a TCP connection. +* Troubleshooting:: Troubleshooting TCP/IP connections. +* Interacting:: Interacting with a service. +* Setting Up:: Setting up a service. +* Email:: Reading email. +* Web page:: Reading a Web page. +* Primitive Service:: A primitive Web service. +* Interacting Service:: A Web service with interaction. +* Simple Server:: A simple Web server. +* Caveats:: Network programming caveats. +* Challenges:: Where to go from here. +@end menu + +@node Gawk Special Files, TCP Connecting, Using Networking, Using Networking +@comment node-name, next, previous, up +@section @command{gawk}'s Networking Mechanisms + +The @samp{|&} operator for use in +communicating with a @dfn{coprocess} is described in +@ref{Two-way I/O, ,Two-way Communications With Another Process, gawk, GAWK: Effective AWK Programming}. +It shows how to do two-way I/O to a +separate process, sending it data with @code{print} or @code{printf} and +reading data with @code{getline}. If you haven't read it already, you should +detour there to do so. + +@command{gawk} transparently extends the two-way I/O mechanism to simple networking through +the use of special @value{FN}s. When a ``coprocess'' that matches +the special files we are about to describe +is started, @command{gawk} creates the appropriate network +connection, and then two-way I/O proceeds as usual. + +@c last comma is part of see-also +@cindex input/output, two-way, See Also @command{gawk}, networking +@cindex TCP/IP, sockets and +At the C, C++, and Perl level, networking is accomplished +via @dfn{sockets}, an Application Programming Interface (API) originally +developed at the University of California at Berkeley that is now used +almost universally for TCP/IP networking. +Socket level programming, while fairly straightforward, requires paying +attention to a number of details, as well as using binary data. It is not +well-suited for use from a high-level language like @command{awk}. +The special files provided in @command{gawk} hide the details from +the programmer, making things much simpler and easier to use. +@c Who sez we can't toot our own horn occasionally? + +@c STARTOFRANGE filenet +@cindex filenames, for network access +@c STARTOFRANGE gawnetf +@cindex @command{gawk}, networking, filenames +@c STARTOFRANGE netgawf +@cindex networks, @command{gawk} and, filenames +The special @value{FN} for network access is made up of several fields, all +of which are mandatory: + +@example +/@var{net-type}/@var{protocol}/@var{localport}/@var{hostname}/@var{remoteport} +@end example + +@cindex @code{/inet/} files (@command{gawk}) +@cindex files, @code{/inet/} (@command{gawk}) +@cindex localport field +@cindex remoteport field +The @var{net-type} field lets you specify IPv4 versus IPv6, or lets +you allow the system to choose. + +@menu +* Special File Fields:: The fields in the special file name. +* Comparing Protocols:: Differences between the protocols. +@end menu + +@node Special File Fields, Comparing Protocols, Gawk Special Files, Gawk Special Files +@subsection The Fields of the Special @value{FFN} +This @value{SECTION} explains the meaning of all the other fields, +as well as the range of values and the defaults. +All of the fields are mandatory. To let the system pick a value, +or if the field doesn't apply to the protocol, specify it as @samp{0}: + +@table @var +@cindex network type field +@c last comma is part of secondary +@cindex TCP/IP, network type, selecting +@item net-type +This is one of @samp{inet4} for IPv4, @samp{inet6} for IPv6, +or @samp{inet} to use the system default (which is likely to be IPv4). +For the rest of this document, we will use the generic @samp{/inet} +in our descriptions of how @command{gawk}'s networking works. + +@cindex protocol field +@c last comma is part of secondary +@cindex TCP/IP, protocols, selecting +@item protocol +Determines which member of the TCP/IP +family of protocols is selected to transport the data across the +network. There are two possible values (always written in lowercase): +@samp{tcp} and @samp{udp}. The exact meaning of each is +explained later in this @value{SECTION}. + +@item localport +@cindex networks, ports, specifying +Determines which port on the local +machine is used to communicate across the network. Application-level clients +usually use @samp{0} to indicate they do not care which local port is +used---instead they specify a remote port to connect to. It is vital for +application-level servers to use a number different from @samp{0} here +because their service has to be available at a specific publicly known +port number. It is possible to use a name from @file{/etc/services} here. + +@item hostname +@cindex hostname field +@cindex servers, as hosts +Determines which remote host is to +be at the other end of the connection. Application-level servers must fill +this field with a @samp{0} to indicate their being open for all other hosts +to connect to them and enforce connection level server behavior this way. +It is not possible for an application-level server to restrict its +availability to one remote host by entering a host name here. +Application-level clients must enter a name different from @samp{0}. +The name can be either symbolic +(e.g., @samp{jpl-devvax.jpl.nasa.gov}) or numeric (e.g., @samp{128.149.1.143}). + +@item remoteport +Determines which port on the remote +machine is used to communicate across the network. +For @file{/inet/tcp} and @file{/inet/udp}, +application-level clients @emph{must} use a number +other than @samp{0} to indicate to which port on the remote machine +they want to connect. Application-level servers must not fill this field with +a @samp{0}. Instead they specify a local port to which clients connect. +It is possible to use a name from @file{/etc/services} here. +@end table + +@cindex networks, @command{gawk} and, connections +@cindex @command{gawk}, networking, connections +Experts in network programming will notice that the usual +client/server asymmetry found at the level of the socket API is not visible +here. This is for the sake of simplicity of the high-level concept. If this +asymmetry is necessary for your application, +use another language. +For @command{gawk}, it is +more important to enable users to write a client program with a minimum +of code. What happens when first accessing a network connection is seen +in the following pseudocode: + +@smallexample +if ((name of remote host given) && (other side accepts connection)) @{ + rendez-vous successful; transmit with getline or print +@} else @{ + if ((other side did not accept) && (localport == 0)) + exit unsuccessful + if (TCP) @{ + set up a server accepting connections + this means waiting for the client on the other side to connect + @} else + ready +@} +@end smallexample + +The exact behavior of this algorithm depends on the values of the +fields of the special @value{FN}. When in doubt, @ref{table-inet-components} +gives you the combinations of values and their meaning. If this +table is too complicated, focus on the three lines printed in +@strong{bold}. All the examples in +@ref{Using Networking, ,Networking With @command{gawk}}, +use only the +patterns printed in bold letters. + +@float Table,table-inet-components +@caption{/inet Special File Components} +@multitable @columnfractions .15 .15 .15 .15 .40 +@headitem @sc{protocol} @tab @sc{local port} @tab @sc{host name} +@tab @sc{remote port} @tab @sc{Resulting connection-level behavior} +@item @strong{tcp} @tab @strong{0} @tab @strong{x} @tab @strong{x} @tab + @strong{Dedicated client, fails if immediately connecting to a + server on the other side fails} +@item udp @tab 0 @tab x @tab x @tab Dedicated client +@item @strong{tcp, udp} @tab @strong{x} @tab @strong{x} @tab @strong{x} @tab + @strong{Client, switches to dedicated server if necessary} +@item @strong{tcp, udp} @tab @strong{x} @tab @strong{0} @tab @strong{0} @tab + @strong{Dedicated server} +@item tcp, udp @tab x @tab x @tab 0 @tab Invalid +@item tcp, udp @tab 0 @tab 0 @tab x @tab Invalid +@item tcp, udp @tab x @tab 0 @tab x @tab Invalid +@item tcp, udp @tab 0 @tab 0 @tab 0 @tab Invalid +@item tcp, udp @tab 0 @tab x @tab 0 @tab Invalid +@end multitable +@end float + +In general, TCP is the preferred mechanism to use. It is the simplest +protocol to understand and to use. Use UDP only if circumstances +demand low-overhead. + +@node Comparing Protocols, , Special File Fields, Gawk Special Files +@subsection Comparing Protocols + +This @value{SECTION} develops a pair of programs (sender and receiver) +that do nothing but send a timestamp from one machine to another. The +sender and the receiver are implemented with each of the two protocols +available and demonstrate the differences between them. + +@menu +* File /inet/tcp:: The TCP special file. +* File /inet/udp:: The UDP special file. +@end menu + +@node File /inet/tcp, File /inet/udp, Comparing Protocols, Comparing Protocols +@subsubsection @file{/inet/tcp} +@cindex @code{/inet/tcp} special files (@command{gawk}) +@cindex files, @code{/inet/tcp} (@command{gawk}) +@cindex TCP (Transmission Control Protocol) +Once again, always use TCP. +(Use UDP when low overhead is a necessity, and use RAW for +network experimentation.) +The first example is the sender +program: + +@example +# Server +BEGIN @{ + print strftime() |& "/inet/tcp/8888/0/0" + close("/inet/tcp/8888/0/0") +@} +@end example + +The receiver is very simple: + +@example +# Client +BEGIN @{ + "/inet/tcp/0/localhost/8888" |& getline + print $0 + close("/inet/tcp/0/localhost/8888") +@} +@end example + +TCP guarantees that the bytes arrive at the receiving end in exactly +the same order that they were sent. No byte is lost +(except for broken connections), doubled, or out of order. Some +overhead is necessary to accomplish this, but this is the price to pay for +a reliable service. +It does matter which side starts first. The sender/server has to be started +first, and it waits for the receiver to read a line. + +@node File /inet/udp, , File /inet/tcp, Comparing Protocols +@subsubsection @file{/inet/udp} +@cindex @code{/inet/udp} special files (@command{gawk}) +@cindex files, @code{/inet/udp} (@command{gawk}) +@cindex UDP (User Datagram Protocol) +@cindex User Datagram Protocol, See UDP +The server and client programs that use UDP are almost identical to their TCP counterparts; +only the @var{protocol} has changed. As before, it does matter which side +starts first. The receiving side blocks and waits for the sender. +In this case, the receiver/client has to be started first: + +@example +# Server +BEGIN @{ + print strftime() |& "/inet/udp/8888/0/0" + close("/inet/udp/8888/0/0") +@} +@end example + +The receiver is almost identical to the TCP receiver: + +@example +# Client +BEGIN @{ + "/inet/udp/0/localhost/8888" |& getline + print $0 + close("/inet/udp/0/localhost/8888") +@} +@end example + +UDP cannot guarantee that the datagrams at the receiving end will arrive in exactly +the same order they were sent. Some datagrams could be +lost, some doubled, and some out of order. But no overhead is necessary to +accomplish this. This unreliable behavior is good enough for tasks +such as data acquisition, logging, and even stateless services like NFS. + +@node TCP Connecting, Troubleshooting, Gawk Special Files, Using Networking +@section Establishing a TCP Connection + +@c STARTOFRANGE tcpcon +@cindex TCP (Transmission Control Protocol), connection, establishing +@c STARTOFRANGE netcon +@cindex networks, @command{gawk} and, connections +@c STARTOFRANGE gawcon +@cindex @command{gawk}, networking, connections +Let's observe a network connection at work. Type in the following program +and watch the output. Within a second, it connects via TCP (@file{/inet/tcp}) +to the machine it is running on (@samp{localhost}) and asks the service +@samp{daytime} on the machine what time it is: + +@cindex @code{getline} command +@example +BEGIN @{ + "/inet/tcp/0/localhost/daytime" |& getline + print $0 + close("/inet/tcp/0/localhost/daytime") +@} +@end example + +Even experienced @command{awk} users will find the second line strange in two +respects: + +@itemize @bullet +@item +A special file is used as a shell command that pipes its output +into @code{getline}. One would rather expect to see the special file +being read like any other file (@samp{getline < +"/inet/tcp/0/localhost/daytime")}. + +@item +@cindex @code{|} (vertical bar), @code{|&} operator (I/O) +@cindex vertical bar (@code{|}), @code{|&} operator (I/O) +The operator @samp{|&} has not been part of any @command{awk} +implementation (until now). +It is actually the only extension of the @command{awk} +language needed (apart from the special files) to introduce network access. +@end itemize + +@cindex pipes, networking and +The @samp{|&} operator was introduced in @command{gawk} 3.1 in order to +overcome the crucial restriction that access to files and pipes in +@command{awk} is always unidirectional. It was formerly impossible to use +both access modes on the same file or pipe. Instead of changing the whole +concept of file access, the @samp{|&} operator +behaves exactly like the usual pipe operator except for two additions: + +@itemize @bullet +@item +Normal shell commands connected to their @command{gawk} program with a @samp{|&} +pipe can be accessed bidirectionally. The @samp{|&} turns out to be a quite +general, useful, and natural extension of @command{awk}. + +@item +Pipes that consist of a special @value{FN} for network connections are not +executed as shell commands. Instead, they can be read and written to, just +like a full-duplex network connection. +@end itemize + +In the earlier example, the @samp{|&} operator tells @code{getline} +to read a line from the special file @file{/inet/tcp/0/localhost/daytime}. +We could also have printed a line into the special file. But instead we just +read a line with the time, printed it, and closed the connection. +(While we could just let @command{gawk} close the connection by finishing +the program, in this @value{DOCUMENT} +we are pedantic and always explicitly close the connections.) + +@node Troubleshooting, Interacting, TCP Connecting, Using Networking +@section Troubleshooting Connection Problems +@cindex advanced features, network connections +@c last comma is part of secondary +@cindex troubleshooting, networks, connections +It may well be that for some reason the program shown in the previous example does not run on your +machine. When looking at possible reasons for this, you will learn much +about typical problems that arise in network programming. First of all, +your implementation of @command{gawk} may not support network access +because it is +a pre-3.1 version or you do not have a network interface in your machine. +Perhaps your machine uses some other protocol, such as +DECnet or Novell's IPX. For the rest of this @value{CHAPTER}, +we will assume +you work on a Unix machine that supports TCP/IP. If the previous example program does +not run on your machine, it may help to replace the name +@samp{localhost} with the name of your machine or its IP address. If it +does, you could replace @samp{localhost} with the name of another machine +in your vicinity---this way, the program connects to another machine. +Now you should see the date and time being printed by the program, +otherwise your machine may not support the @samp{daytime} service. +Try changing the service to @samp{chargen} or @samp{ftp}. This way, the program +connects to other services that should give you some response. If you are +curious, you should have a look at your @file{/etc/services} file. It could +look like this: + +@ignore +@multitable {1234567890123} {1234567890123} {123456789012345678901234567890123456789012} +@item Service @strong{name} @tab Service @strong{number} +@item echo @tab 7/tcp @tab echo sends back each line it receives +@item echo @tab 7/udp @tab echo is good for testing purposes +@item discard @tab 9/tcp @tab discard behaves like @file{/dev/null} +@item discard @tab 9/udp @tab discard just throws away each line +@item daytime @tab 13/tcp @tab daytime sends date & time once per connection +@item daytime @tab 13/udp +@item chargen @tab 19/tcp @tab chargen infinitely produces character sets +@item chargen @tab 19/udp @tab chargen is good for testing purposes +@item ftp @tab 21/tcp @tab ftp is the usual file transfer protocol +@item telnet @tab 23/tcp @tab telnet is the usual login facility +@item smtp @tab 25/tcp @tab smtp is the Simple Mail Transfer Protocol +@item finger @tab 79/tcp @tab finger tells you who is logged in +@item www @tab 80/tcp @tab www is the HyperText Transfer Protocol +@item pop2 @tab 109/tcp @tab pop2 is an older version of pop3 +@item pop2 @tab 109/udp +@item pop3 @tab 110/tcp @tab pop3 is the Post Office Protocol +@item pop3 @tab 110/udp @tab pop3 is used for receiving email +@item nntp @tab 119/tcp @tab nntp is the USENET News Transfer Protocol +@item irc @tab 194/tcp @tab irc is the Internet Relay Chat +@item irc @tab 194/udp +@end multitable +@end ignore + +@smallexample +# /etc/services: +# +# Network services, Internet style +# +# Name Number/Protocol Alternate name # Comments + +echo 7/tcp +echo 7/udp +discard 9/tcp sink null +discard 9/udp sink null +daytime 13/tcp +daytime 13/udp +chargen 19/tcp ttytst source +chargen 19/udp ttytst source +ftp 21/tcp +telnet 23/tcp +smtp 25/tcp mail +finger 79/tcp +www 80/tcp http # WorldWideWeb HTTP +www 80/udp # HyperText Transfer Protocol +pop-2 109/tcp postoffice # POP version 2 +pop-2 109/udp +pop-3 110/tcp # POP version 3 +pop-3 110/udp +nntp 119/tcp readnews untp # USENET News +irc 194/tcp # Internet Relay Chat +irc 194/udp +@dots{} +@end smallexample + +@cindex Linux +@cindex GNU/Linux +@cindex Microsoft Windows, networking +Here, you find a list of services that traditional Unix machines usually +support. If your GNU/Linux machine does not do so, it may be that these +services are switched off in some startup script. Systems running some +flavor of Microsoft Windows usually do @emph{not} support these services. +Nevertheless, it @emph{is} possible to do networking with @command{gawk} on +Microsoft +Windows.@footnote{Microsoft preferred to ignore the TCP/IP +family of protocols until 1995. Then came the rise of the Netscape browser +as a landmark ``killer application.'' Microsoft added TCP/IP support and +their own browser to Microsoft Windows 95 at the last minute. They even back-ported +their TCP/IP implementation to Microsoft Windows for Workgroups 3.11, but it was +a rather rudimentary and half-hearted implementation. Nevertheless, +the equivalent of @file{/etc/services} resides under +@file{C:\WINNT\system32\drivers\etc\services} on Microsoft Windows 2000 +and Microsoft Windows XP.} +The first column of the file gives the name of the service, and +the second column gives a unique number and the protocol that one can use to connect to +this service. +The rest of the line is treated as a comment. +You see that some services (@samp{echo}) support TCP as +well as UDP. + +@node Interacting, Setting Up, Troubleshooting, Using Networking +@section Interacting with a Network Service + +The next program makes use of the possibility to really interact with a +network service by printing something into the special file. It asks the +so-called @command{finger} service if a user of the machine is logged in. When +testing this program, try to change @samp{localhost} to +some other machine name in your local network: + +@c system if test ! -d eg ; then mkdir eg ; fi +@c system if test ! -d eg/network ; then mkdir eg/network ; fi +@example +@c file eg/network/fingerclient.awk +BEGIN @{ + NetService = "/inet/tcp/0/localhost/finger" + print "@var{name}" |& NetService + while ((NetService |& getline) > 0) + print $0 + close(NetService) +@} +@c endfile +@end example + +After telling the service on the machine which user to look for, +the program repeatedly reads lines that come as a reply. When no more +lines are coming (because the service has closed the connection), the +program also closes the connection. Try replacing @code{"@var{name}"} with your +login name (or the name of someone else logged in). For a list +of all users currently logged in, replace @var{name} with an empty string +(@code{""}). + +@cindex Linux +@cindex GNU/Linux +The final @code{close} command could be safely deleted from +the above script, because the operating system closes any open connection +by default when a script reaches the end of execution. In order to avoid +portability problems, it is best to always close connections explicitly. +With the Linux kernel, +for example, proper closing results in flushing of buffers. Letting +the close happen by default may result in discarding buffers. + +@ignore +@c Chuck comments that this seems out of place. He's right. I dunno +@c where to put it though. +@cindex @command{finger} utility +@cindex RFC 1288 +In the early days of the Internet (up until about 1992), you could use +such a program to check if some user in another country was logged in on +a specific machine. +RFC 1288@footnote{@uref{http://www.cis.ohio-state.edu/htbin/rfc/rfc1288.html}} +provides the exact definition of the @command{finger} protocol. +Every contemporary Unix system also has a command named @command{finger}, +which functions as a client for the protocol of the same name. +Still today, some people maintain simple information systems +with this ancient protocol. For example, by typing +@samp{finger quake@@seismo.unr.edu} +you get the latest @dfn{Earthquake Bulletin} for the state of Nevada. + +@cindex Earthquake Bulletin +@smallexample +$ finger quake@@seismo.unr.edu + +[@dots{}] + +DATE-(UTC)-TIME LAT LON DEP MAG COMMENTS +yy/mm/dd hh:mm:ss deg. deg. km + +98/12/14 21:09:22 37.47N 116.30W 0.0 2.3Md 76.4 km S of WARM SPRINGS, NEVA +98/12/14 22:05:09 39.69N 120.41W 11.9 2.1Md 53.8 km WNW of RENO, NEVADA +98/12/15 14:14:19 38.04N 118.60W 2.0 2.3Md 51.0 km S of HAWTHORNE, NEVADA +98/12/17 01:49:02 36.06N 117.58W 13.9 3.0Md 74.9 km SE of LONE PINE, CALIFOR +98/12/17 05:39:26 39.95N 120.87W 6.2 2.6Md 101.6 km WNW of RENO, NEVADA +98/12/22 06:07:42 38.68N 119.82W 5.2 2.3Md 50.7 km S of CARSON CITY, NEVAD +@end smallexample + +@noindent +This output from @command{finger} contains the time, location, depth, +magnitude, and a short comment about +the earthquakes registered in that region during the last 10 days. +In many places today the use of such services is restricted +because most networks have firewalls and proxy servers between them +and the Internet. Most firewalls are programmed to not let +@command{finger} requests go beyond the local network. + +@cindex Coke machine +Another (ab)use of the @command{finger} protocol are several Coke machines +that are connected to the Internet. There is a short list of such +Coke machines.@footnote{@uref{http://ca.yahoo.com/Computers_and_Internet/Internet/Devices_Connected_to_the_Internet/Soda_Machines/}} +You can access them either from the command-line or with a simple +@command{gawk} script. They usually tell you about the different +flavors of Coke and beer available there. If you have an account there, +you can even order some drink this way. +@end ignore + +When looking at @file{/etc/services} you may have noticed that the +@samp{daytime} service is also available with @samp{udp}. In the earlier +example, change @samp{tcp} to @samp{udp}, +and change @samp{finger} to @samp{daytime}. +After starting the modified program, you see the expected day and time message. +The program then hangs, because it waits for more lines coming from the +service. However, they never come. This behavior is a consequence of the +differences between TCP and UDP. When using UDP, neither party is +automatically informed about the other closing the connection. +Continuing to experiment this way reveals many other subtle +differences between TCP and UDP. To avoid such trouble, one should always +remember the advice Douglas E.@: Comer and David Stevens give in +Volume III of their series @cite{Internetworking With TCP} +(page 14): + +@cindex TCP (Transmission Control Protocol), UDP and +@cindex UDP (User Datagram Protocol), TCP and +@cindex Internet, See networks +@quotation +When designing client-server applications, beginners are strongly +advised to use TCP because it provides reliable, connection-oriented +communication. Programs only use UDP if the application protocol handles +reliability, the application requires hardware broadcast or multicast, +or the application cannot tolerate virtual circuit overhead. +@end quotation + +@node Setting Up, Email, Interacting, Using Networking +@section Setting Up a Service +@c last comma is part of tertiary +@cindex networks, @command{gawk} and, service, establishing +@c last comma is part of tertiary +@cindex @command{gawk}, networking, service, establishing +The preceding programs behaved as clients that connect to a server somewhere +on the Internet and request a particular service. Now we set up such a +service to mimic the behavior of the @samp{daytime} service. +Such a server does not know in advance who is going to connect to it over +the network. Therefore, we cannot insert a name for the host to connect to +in our special @value{FN}. + +Start the following program in one window. Notice that the service does +not have the name @samp{daytime}, but the number @samp{8888}. +From looking at @file{/etc/services}, you know that names like @samp{daytime} +are just mnemonics for predetermined 16-bit integers. +Only the system administrator (@code{root}) could enter +our new service into @file{/etc/services} with an appropriate name. +Also notice that the service name has to be entered into a different field +of the special @value{FN} because we are setting up a server, not a client: + +@cindex @command{finger} utility +@cindex servers +@example +BEGIN @{ + print strftime() |& "/inet/tcp/8888/0/0" + close("/inet/tcp/8888/0/0") +@} +@end example + +Now open another window on the same machine. +Copy the client program given as the first example +(@pxref{TCP Connecting, ,Establishing a TCP Connection}) +to a new file and edit it, changing the name @samp{daytime} to +@samp{8888}. Then start the modified client. You should get a reply +like this: + +@example +Sat Sep 27 19:08:16 CEST 1997 +@end example + +@noindent +Both programs explicitly close the connection. + +@c first comma is part of primary +@cindex Microsoft Windows, networking, ports +@cindex networks, ports, reserved +@cindex Unix, network ports and +Now we will intentionally make a mistake to see what happens when the name +@samp{8888} (the so-called port) is already used by another service. +Start the server +program in both windows. The first one works, but the second one +complains that it could not open the connection. Each port on a single +machine can only be used by one server program at a time. Now terminate the +server program and change the name @samp{8888} to @samp{echo}. After restarting it, +the server program does not run any more, and you know why: there is already +an @samp{echo} service running on your machine. But even if this isn't true, +you would not get +your own @samp{echo} server running on a Unix machine, +because the ports with numbers smaller +than 1024 (@samp{echo} is at port 7) are reserved for @code{root}. +On machines running some flavor of Microsoft Windows, there is no restriction +that reserves ports 1 to 1024 for a privileged user; hence, you can start +an @samp{echo} server there. + +Turning this short server program into something really useful is simple. +Imagine a server that first reads a @value{FN} from the client through the +network connection, then does something with the file and +sends a result back to the client. The server-side processing +could be: + +@example +BEGIN @{ + NetService = "/inet/tcp/8888/0/0" + NetService |& getline + CatPipe = ("cat " $1) # sets $0 and the fields + while ((CatPipe | getline) > 0) + print $0 |& NetService + close(NetService) +@} +@end example + +@noindent +and we would +have a remote copying facility. Such a server reads the name of a file +from any client that connects to it and transmits the contents of the +named file across the net. The server-side processing could also be +the execution of a command that is transmitted across the network. From this +example, you can see how simple it is to open up a security hole on your +machine. If you allow clients to connect to your machine and +execute arbitrary commands, anyone would be free to do @samp{rm -rf *}. + +@node Email, Web page, Setting Up, Using Networking +@section Reading Email +@c @cindex RFC 1939 +@c @cindex RFC 821 +@cindex @command{gawk}, networking, See Also email +@cindex networks, @command{gawk} and, See Also email +@cindex POP (Post Office Protocol) +@cindex SMTP (Simple Mail Transfer Protocol) +@cindex Post Office Protocol (POP) +@cindex Simple Mail Transfer Protocol (SMTP) +The distribution of email is usually done by dedicated email servers that +communicate with your machine using special protocols. To receive email, we +will use the Post Office Protocol (POP). Sending can be done with the much +older Simple Mail Transfer Protocol (SMTP). +@ignore +@footnote{RFC 1939 defines POP. +RFC 821 defines SMTP. See +@uref{http://rfc.fh-koeln.de/doc/rfc/html/rfc.html, RFCs in HTML}.} +@end ignore + +@cindex email +When you type in the following program, replace the @var{emailhost} by the +name of your local email server. Ask your administrator if the server has a +POP service, and then use its name or number in the program below. +Now the program is ready to connect to your email server, but it will not +succeed in retrieving your mail because it does not yet know your login +name or password. Replace them in the program and it +shows you the first email the server has in store: + +@example +BEGIN @{ + POPService = "/inet/tcp/0/@var{emailhost}/pop3" + RS = ORS = "\r\n" + print "user @var{name}" |& POPService + POPService |& getline + print "pass @var{password}" |& POPService + POPService |& getline + print "retr 1" |& POPService + POPService |& getline + if ($1 != "+OK") exit + print "quit" |& POPService + RS = "\r\n\\.\r\n" + POPService |& getline + print $0 + close(POPService) +@} +@end example + +@c @cindex RFC 1939 +@cindex record separators, POP and +@cindex @code{RS} variable, POP and +@cindex @code{ORS} variable, POP and +@cindex POP (Post Office Protocol) +The record separators @code{RS} and @code{ORS} are redefined because the +protocol (POP) requires CR-LF to separate lines. After identifying +yourself to the email service, the command @samp{retr 1} instructs the +service to send the first of all your email messages in line. If the service +replies with something other than @samp{+OK}, the program exits; maybe there +is no email. Otherwise, the program first announces that it intends to finish +reading email, and then redefines @code{RS} in order to read the entire +email as multiline input in one record. From the POP RFC, we know that the body +of the email always ends with a single line containing a single dot. +The program looks for this using @samp{RS = "\r\n\\.\r\n"}. +When it finds this sequence in the mail message, it quits. +You can invoke this program as often as you like; it does not delete the +message it reads, but instead leaves it on the server. + +@node Web page, Primitive Service, Email, Using Networking +@section Reading a Web Page +@cindex web pages +@cindex HTTP (Hypertext Transfer Protocol) +@cindex Hypertext Transfer Protocol, See HTTP +@c @cindex RFC 2068 +@c @cindex RFC 2616 + +Retrieving a web page from a web server is as simple as +retrieving email from an email server. We only have to use a +similar, but not identical, protocol and a different port. The name of the +protocol is HyperText Transfer Protocol (HTTP) and the port number is usually +80. As in the preceding @value{SECTION}, ask your administrator about the +name of your local web server or proxy web server and its port number +for HTTP requests. + +@ignore +@c Chuck says this stuff isn't necessary +More detailed information about HTTP can be found at +the home of the web protocols,@footnote{@uref{http://www.w3.org/pub/WWW/Protocols}} +including the specification of HTTP in RFC 2068. The protocol specification +in RFC 2068 is concise and you can get it for free. If you need more +explanation and you are willing to pay for a book, you might be +interested in one of these books: + +@enumerate + +@item +When we started writing web clients and servers with @command{gawk}, +the only book available with details about HTTP was the one by Paul Hethmon +called +@cite{Illustrated Guide to HTTP}.@footnote{@uref{http://www.browsebooks.com/Hethmon/?882}} +Hethmon not only describes HTTP, +he also implements a simple web server in C++. + +@item +Since July 2000, O'Reilly offers the book by Clinton Wong called +@cite{HTTP Pocket Reference}.@footnote{@uref{http://www.oreilly.com/catalog/httppr}} +It only has 75 pages but its +focus definitely is HTTP. This pocket reference is not a replacement +for the RFC, but I wish I had had it back in 1997 when I started writing +scripts to handle HTTP. + +@item +Another small booklet about HTTP is the one by Toexcell Incorporated Staff, +ISBN 1-58348-270-9, called +@cite{Hypertext Transfer Protocol Http 1.0 Specifications} + +@end enumerate +@end ignore + +The following program employs a rather crude approach toward retrieving a +web page. It uses the prehistoric syntax of HTTP 0.9, which almost all +web servers still support. The most noticeable thing about it is that the +program directs the request to the local proxy server whose name you insert +in the special @value{FN} (which in turn calls @samp{www.yahoo.com}): + +@example +BEGIN @{ + RS = ORS = "\r\n" + HttpService = "/inet/tcp/0/@var{proxy}/80" + print "GET http://www.yahoo.com" |& HttpService + while ((HttpService |& getline) > 0) + print $0 + close(HttpService) +@} +@end example + +@c @cindex RFC 1945 +@cindex record separators, HTTP and +@cindex @code{RS} variable, HTTP and +@cindex @code{ORS} variable, HTTP and +@cindex HTTP (Hypertext Transfer Protocol), record separators and +@cindex HTML (Hypertext Markup Language) +@cindex Hypertext Markup Language (HTML) +Again, lines are separated by a redefined @code{RS} and @code{ORS}. +The @code{GET} request that we send to the server is the only kind of +HTTP request that existed when the web was created in the early 1990s. +HTTP calls this @code{GET} request a ``method,'' which tells the +service to transmit a web page (here the home page of the Yahoo! search +engine). Version 1.0 added the request methods @code{HEAD} and +@code{POST}. The current version of HTTP is 1.1,@footnote{Version 1.0 of +HTTP was defined in RFC 1945. HTTP 1.1 was initially specified in RFC +2068. In June 1999, RFC 2068 was made obsolete by RFC 2616, an update +without any substantial changes.} and knows the additional request +methods @code{OPTIONS}, @code{PUT}, @code{DELETE}, and @code{TRACE}. +You can fill in any valid web address, and the program prints the +HTML code of that page to your screen. + +Notice the similarity between the responses of the POP and HTTP +services. First, you get a header that is terminated by an empty line, and +then you get the body of the page in HTML. The lines of the headers also +have the same form as in POP. There is the name of a parameter, +then a colon, and finally the value of that parameter. + +@cindex CGI (Common Gateway Interface), dynamic web pages and +@cindex Common Gateway Interface, See CGI +@cindex GIF image format +@cindex PNG image format +@cindex images, retrieving over networks +Images (@file{.png} or @file{.gif} files) can also be retrieved this way, +but then you +get binary data that should be redirected into a file. Another +application is calling a CGI (Common Gateway Interface) script on some +server. CGI scripts are used when the contents of a web page are not +constant, but generated instantly at the moment you send a request +for the page. For example, to get a detailed report about the current +quotes of Motorola stock shares, call a CGI script at Yahoo! with +the following: + +@example +get = "GET http://quote.yahoo.com/q?s=MOT&d=t" +print get |& HttpService +@end example + +You can also request weather reports this way. +@ignore +@cindex Boutell, Thomas +A good book to go on with is +the +@cite{HTML Source Book}.@footnote{@uref{http://www.utoronto.ca/webdocs/HTMLdocs/NewHTML/book.html}} +There are also some books on CGI programming +like @cite{CGI Programming in C & Perl}, +by Thomas Boutell@footnote{@uref{http://cseng.aw.com/bookdetail.qry?ISBN=0-201-42219-0&ptype=0}}, +and @cite{The CGI Book}.@footnote{@uref{http://www.cgibook.com}} +Another good source is @cite{The CGI Resource Index}}.@footnote{@uref{http://www.cgi-resources.com}} +@end ignore + +@node Primitive Service, Interacting Service, Web page, Using Networking +@section A Primitive Web Service +@c STARTOFRANGE webser +@cindex web service +Now we know enough about HTTP to set up a primitive web service that just +says @code{"Hello, world"} when someone connects to it with a browser. +Compared +to the situation in the preceding @value{SECTION}, our program changes the role. It +tries to behave just like the server we have observed. Since we are setting +up a server here, we have to insert the port number in the @samp{localport} +field of the special @value{FN}. The other two fields (@var{hostname} and +@var{remoteport}) have to contain a @samp{0} because we do not know in +advance which host will connect to our service. + +In the early 1990s, all a server had to do was send an HTML document and +close the connection. Here, we adhere to the modern syntax of HTTP. +The steps are as follows: + +@enumerate 1 +@item +Send a status line telling the web browser that everything +is okay. + +@item +Send a line to tell the browser how many bytes follow in the +body of the message. This was not necessary earlier because both +parties knew that the document ended when the connection closed. Nowadays +it is possible to stay connected after the transmission of one web page. +This is to avoid the network traffic necessary for repeatedly establishing +TCP connections for requesting several images. Thus, there is the need to tell +the receiving party how many bytes will be sent. The header is terminated +as usual with an empty line. + +@item +Send the @code{"Hello, world"} body +in HTML. +The useless @code{while} loop swallows the request of the browser. +We could actually omit the loop, and on most machines the program would still +work. +First, start the following program: +@end enumerate + +@example +@c file eg/network/hello-serv.awk +BEGIN @{ + RS = ORS = "\r\n" + HttpService = "/inet/tcp/8080/0/0" + Hello = "" \ + "A Famous Greeting" \ + "

Hello, world

" + Len = length(Hello) + length(ORS) + print "HTTP/1.0 200 OK" |& HttpService + print "Content-Length: " Len ORS |& HttpService + print Hello |& HttpService + while ((HttpService |& getline) > 0) + continue; + close(HttpService) +@} +@c endfile +@end example + +Now, on the same machine, start your favorite browser and let it point to +@uref{http://localhost:8080} (the browser needs to know on which port +our server is listening for requests). If this does not work, the browser +probably tries to connect to a proxy server that does not know your machine. +If so, change the browser's configuration so that the browser does not try to +use a proxy to connect to your machine. + +@node Interacting Service, Simple Server, Primitive Service, Using Networking +@section A Web Service with Interaction +@cindex @command{gawk}, web and, See web service +@cindex web browsers, See web service +@c comma is part of primary +@cindex HTTP server, core logic +@cindex servers, HTTP +@ifinfo +This node shows how to set up a simple web server. +The subnode is a library file that we will use with all the examples in +@ref{Some Applications and Techniques}. +@end ifinfo + +@menu +* CGI Lib:: A simple CGI library. +@end menu + +Setting up a web service that allows user interaction is more difficult and +shows us the limits of network access in @command{gawk}. In this @value{SECTION}, +we develop a main program (a @code{BEGIN} pattern and its action) +that will become the core of event-driven execution controlled by a +graphical user interface (GUI). +Each HTTP event that the user triggers by some action within the browser +is received in this central procedure. Parameters and menu choices are +extracted from this request, and an appropriate measure is taken according to +the user's choice. +For example: + +@cindex HTTP server, core logic +@example +BEGIN @{ + if (MyHost == "") @{ + "uname -n" | getline MyHost + close("uname -n") + @} + if (MyPort == 0) MyPort = 8080 + HttpService = "/inet/tcp/" MyPort "/0/0" + MyPrefix = "http://" MyHost ":" MyPort + SetUpServer() + while ("awk" != "complex") @{ + # header lines are terminated this way + RS = ORS = "\r\n" + Status = 200 # this means OK + Reason = "OK" + Header = TopHeader + Document = TopDoc + Footer = TopFooter + if (GETARG["Method"] == "GET") @{ + HandleGET() + @} else if (GETARG["Method"] == "HEAD") @{ + # not yet implemented + @} else if (GETARG["Method"] != "") @{ + print "bad method", GETARG["Method"] + @} + Prompt = Header Document Footer + print "HTTP/1.0", Status, Reason |& HttpService + print "Connection: Close" |& HttpService + print "Pragma: no-cache" |& HttpService + len = length(Prompt) + length(ORS) + print "Content-length:", len |& HttpService + print ORS Prompt |& HttpService + # ignore all the header lines + while ((HttpService |& getline) > 0) + ; + # stop talking to this client + close(HttpService) + # wait for new client request + HttpService |& getline + # do some logging + print systime(), strftime(), $0 + # read request parameters + CGI_setup($1, $2, $3) + @} +@} +@end example + +This web server presents menu choices in the form of HTML links. +Therefore, it has to tell the browser the name of the host it is +residing on. When starting the server, the user may supply the name +of the host from the command line with @samp{gawk -v MyHost="Rumpelstilzchen"}. +If the user does not do this, the server looks up the name of the host it is +running on for later use as a web address in HTML documents. The same +applies to the port number. These values are inserted later into the +HTML content of the web pages to refer to the home system. + +Each server that is built around this core has to initialize some +application-dependent variables (such as the default home page) in a procedure +@code{SetUpServer}, which is called immediately before entering the +infinite loop of the server. For now, we will write an instance that +initiates a trivial interaction. With this home page, the client user +can click on two possible choices, and receive the current date either +in human-readable format or in seconds since 1970: + +@example +function SetUpServer() @{ + TopHeader = "" + TopHeader = TopHeader \ + "My name is GAWK, GNU AWK" + TopDoc = "

\ + Do you prefer your date human or \ + POSIXed?

" ORS ORS + TopFooter = "" +@} +@end example + +On the first run through the main loop, the default line terminators are +set and the default home page is copied to the actual home page. Since this +is the first run, @code{GETARG["Method"]} is not initialized yet, hence the +case selection over the method does nothing. Now that the home page is +initialized, the server can start communicating to a client browser. + +@c @cindex RFC 2068 +It does so by printing the HTTP header into the network connection +(@samp{print @dots{} |& HttpService}). This command blocks execution of +the server script until a client connects. If this server +script is compared with the primitive one we wrote before, you will notice +two additional lines in the header. The first instructs the browser +to close the connection after each request. The second tells the +browser that it should never try to @emph{remember} earlier requests +that had identical web addresses (no caching). Otherwise, it could happen +that the browser retrieves the time of day in the previous example just once, +and later it takes the web page from the cache, always displaying the same +time of day although time advances each second. + +Having supplied the initial home page to the browser with a valid document +stored in the parameter @code{Prompt}, it closes the connection and waits +for the next request. When the request comes, a log line is printed that +allows us to see which request the server receives. The final step in the +loop is to call the function @code{CGI_setup}, which reads all the lines +of the request (coming from the browser), processes them, and stores the +transmitted parameters in the array @code{PARAM}. The complete +text of these application-independent functions can be found in +@ref{CGI Lib, ,A Simple CGI Library}. +For now, we use a simplified version of @code{CGI_setup}: + +@example +function CGI_setup( method, uri, version, i) @{ + delete GETARG; delete MENU; delete PARAM + GETARG["Method"] = $1 + GETARG["URI"] = $2 + GETARG["Version"] = $3 + i = index($2, "?") + # is there a "?" indicating a CGI request? +@group + if (i > 0) @{ + split(substr($2, 1, i-1), MENU, "[/:]") + split(substr($2, i+1), PARAM, "&") + for (i in PARAM) @{ + j = index(PARAM[i], "=") + GETARG[substr(PARAM[i], 1, j-1)] = \ + substr(PARAM[i], j+1) + @} + @} else @{ # there is no "?", no need for splitting PARAMs + split($2, MENU, "[/:]") + @} +@end group +@} +@end example + +At first, the function clears all variables used for +global storage of request parameters. The rest of the function serves +the purpose of filling the global parameters with the extracted new values. +To accomplish this, the name of the requested resource is split into +parts and stored for later evaluation. If the request contains a @samp{?}, +then the request has CGI variables seamlessly appended to the web address. +Everything in front of the @samp{?} is split up into menu items, and +everything behind the @samp{?} is a list of @samp{@var{variable}=@var{value}} pairs +(separated by @samp{&}) that also need splitting. This way, CGI variables are +isolated and stored. This procedure lacks recognition of special characters +that are transmitted in coded form@footnote{As defined in RFC 2068.}. Here, any +optional request header and body parts are ignored. We do not need +header parameters and the request body. However, when refining our approach or +working with the @code{POST} and @code{PUT} methods, reading the header +and body +becomes inevitable. Header parameters should then be stored in a global +array as well as the body. + +On each subsequent run through the main loop, one request from a browser is +received, evaluated, and answered according to the user's choice. This can be +done by letting the value of the HTTP method guide the main loop into +execution of the procedure @code{HandleGET}, which evaluates the user's +choice. In this case, we have only one hierarchical level of menus, +but in the general case, +menus are nested. +The menu choices at each level are +separated by @samp{/}, just as in @value{FN}s. Notice how simple it is to +construct menus of arbitrary depth: + +@example +function HandleGET() @{ + if ( MENU[2] == "human") @{ + Footer = strftime() TopFooter + @} else if (MENU[2] == "POSIX") @{ + Footer = systime() TopFooter + @} +@} +@end example + +The disadvantage of this approach is that our server is slow and can +handle only one request at a time. Its main advantage, however, is that +the server +consists of just one @command{gawk} program. No need for installing an +@command{httpd}, and no need for static separate HTML files, CGI scripts, or +@code{root} privileges. This is rapid prototyping. +This program can be started on the same host that runs your browser. +Then let your browser point to @uref{http://localhost:8080}. + +@cindex XBM image format +@cindex images, in web pages +@cindex web pages, images in +@cindex GNUPlot utility +It is also possible to include images into the HTML pages. +Most browsers support the not very well-known +@file{.xbm} format, +which may contain only +monochrome pictures but is an ASCII format. Binary images are possible but +not so easy to handle. Another way of including images is to generate them +with a tool such as GNUPlot, +by calling the tool with the @code{system} function or through a pipe. + +@node CGI Lib, , Interacting Service, Interacting Service +@subsection A Simple CGI Library +@quotation +@i{HTTP is like being married: you have to be able to handle whatever +you're given, while being very careful what you send back.}@* +Phil Smith III,@* +@uref{http://www.netfunny.com/rhf/jokes/99/Mar/http.html} +@end quotation + +@c STARTOFRANGE cgilib +@cindex CGI (Common Gateway Interface), library +In @ref{Interacting Service, ,A Web Service with Interaction}, +we saw the function @code{CGI_setup} as part of the web server +``core logic'' framework. The code presented there handles almost +everything necessary for CGI requests. +One thing it doesn't do is handle encoded characters in the requests. +For example, an @samp{&} is encoded as a percent sign followed by +the hexadecimal value: @samp{%26}. These encoded values should be +decoded. +Following is a simple library to perform these tasks. +This code is used for all web server examples +used throughout the rest of this @value{DOCUMENT}. +If you want to use it for your own web server, store the source code +into a file named @file{inetlib.awk}. Then you can include +these functions into your code by placing the following statement +into your program +(on the first line of your script): + +@example +@@include inetlib.awk +@end example + +@noindent +But beware, this mechanism is +only possible if you invoke your web server script with @command{igawk} +instead of the usual @command{awk} or @command{gawk}. +Here is the code: + +@example +@c file eg/network/coreserv.awk +# CGI Library and core of a web server +@c endfile +@ignore +@c file eg/network/coreserv.awk +# +# Juergen Kahrs, Juergen.Kahrs@@vr-web.de +# with Arnold Robbins, arnold@@gnu.org +# September 2000 + +@c endfile +@end ignore +@c file eg/network/coreserv.awk +# Global arrays +# GETARG --- arguments to CGI GET command +# MENU --- menu items (path names) +# PARAM --- parameters of form x=y + +# Optional variable MyHost contains host address +# Optional variable MyPort contains port number +# Needs TopHeader, TopDoc, TopFooter +# Sets MyPrefix, HttpService, Status, Reason + +BEGIN @{ + if (MyHost == "") @{ + "uname -n" | getline MyHost + close("uname -n") + @} + if (MyPort == 0) MyPort = 8080 + HttpService = "/inet/tcp/" MyPort "/0/0" + MyPrefix = "http://" MyHost ":" MyPort + SetUpServer() + while ("awk" != "complex") @{ + # header lines are terminated this way + RS = ORS = "\r\n" + Status = 200 # this means OK + Reason = "OK" + Header = TopHeader + Document = TopDoc + Footer = TopFooter + if (GETARG["Method"] == "GET") @{ + HandleGET() + @} else if (GETARG["Method"] == "HEAD") @{ + # not yet implemented + @} else if (GETARG["Method"] != "") @{ + print "bad method", GETARG["Method"] + @} + Prompt = Header Document Footer + print "HTTP/1.0", Status, Reason |& HttpService + print "Connection: Close" |& HttpService + print "Pragma: no-cache" |& HttpService + len = length(Prompt) + length(ORS) + print "Content-length:", len |& HttpService + print ORS Prompt |& HttpService + # ignore all the header lines + while ((HttpService |& getline) > 0) + continue + # stop talking to this client + close(HttpService) + # wait for new client request + HttpService |& getline + # do some logging + print systime(), strftime(), $0 + CGI_setup($1, $2, $3) + @} +@} + +function CGI_setup( method, uri, version, i) +@{ + delete GETARG + delete MENU + delete PARAM + GETARG["Method"] = method + GETARG["URI"] = uri + GETARG["Version"] = version + + i = index(uri, "?") + if (i > 0) @{ # is there a "?" indicating a CGI request? + split(substr(uri, 1, i-1), MENU, "[/:]") + split(substr(uri, i+1), PARAM, "&") + for (i in PARAM) @{ + PARAM[i] = _CGI_decode(PARAM[i]) + j = index(PARAM[i], "=") + GETARG[substr(PARAM[i], 1, j-1)] = \ + substr(PARAM[i], j+1) + @} + @} else @{ # there is no "?", no need for splitting PARAMs + split(uri, MENU, "[/:]") + @} + for (i in MENU) # decode characters in path + if (i > 4) # but not those in host name + MENU[i] = _CGI_decode(MENU[i]) +@} +@c endfile +@end example + +This isolates details in a single function, @code{CGI_setup}. +Decoding of encoded characters is pushed off to a helper function, +@code{_CGI_decode}. The use of the leading underscore (@samp{_}) in +the function name is intended to indicate that it is an ``internal'' +function, although there is nothing to enforce this: + +@example +@c file eg/network/coreserv.awk +function _CGI_decode(str, hexdigs, i, pre, code1, code2, + val, result) +@{ + hexdigs = "123456789abcdef" + + i = index(str, "%") + if (i == 0) # no work to do + return str + + do @{ + pre = substr(str, 1, i-1) # part before %xx + code1 = substr(str, i+1, 1) # first hex digit + code2 = substr(str, i+2, 1) # second hex digit + str = substr(str, i+3) # rest of string + + code1 = tolower(code1) + code2 = tolower(code2) + val = index(hexdigs, code1) * 16 \ + + index(hexdigs, code2) + + result = result pre sprintf("%c", val) + i = index(str, "%") + @} while (i != 0) + if (length(str) > 0) + result = result str + return result +@} +@c endfile +@end example + +This works by splitting the string apart around an encoded character. +The two digits are converted to lowercase characters and looked up in a string +of hex digits. Note that @code{0} is not in the string on purpose; +@code{index} returns zero when it's not found, automatically giving +the correct value! Once the hexadecimal value is converted from +characters in a string into a numerical value, @code{sprintf} +converts the value back into a real character. +The following is a simple test harness for the above functions: + +@example +@c file eg/network/testserv.awk +BEGIN @{ + CGI_setup("GET", + "http://www.gnu.org/cgi-bin/foo?p1=stuff&p2=stuff%26junk" \ + "&percent=a %25 sign", + "1.0") + for (i in MENU) + printf "MENU[\"%s\"] = %s\n", i, MENU[i] + for (i in PARAM) + printf "PARAM[\"%s\"] = %s\n", i, PARAM[i] + for (i in GETARG) + printf "GETARG[\"%s\"] = %s\n", i, GETARG[i] +@} +@c endfile +@end example + +And this is the result when we run it: + +@c artificial line wrap in last output line +@example +$ gawk -f testserv.awk +@print{} MENU["4"] = www.gnu.org +@print{} MENU["5"] = cgi-bin +@print{} MENU["6"] = foo +@print{} MENU["1"] = http +@print{} MENU["2"] = +@print{} MENU["3"] = +@print{} PARAM["1"] = p1=stuff +@print{} PARAM["2"] = p2=stuff&junk +@print{} PARAM["3"] = percent=a % sign +@print{} GETARG["p1"] = stuff +@print{} GETARG["percent"] = a % sign +@print{} GETARG["p2"] = stuff&junk +@print{} GETARG["Method"] = GET +@print{} GETARG["Version"] = 1.0 +@print{} GETARG["URI"] = http://www.gnu.org/cgi-bin/foo?p1=stuff& +p2=stuff%26junk&percent=a %25 sign +@end example + +@node Simple Server, Caveats, Interacting Service, Using Networking +@section A Simple Web Server +@c STARTOFRANGE webserx +@cindex web servers +@c STARTOFRANGE serweb +@cindex servers, web +In the preceding @value{SECTION}, we built the core logic for event-driven GUIs. +In this @value{SECTION}, we finally extend the core to a real application. +No one would actually write a commercial web server in @command{gawk}, but +it is instructive to see that it is feasible in principle. + +@cindex ELIZA program +@cindex Weizenbaum, Joseph +The application is ELIZA, the famous program by Joseph Weizenbaum that +mimics the behavior of a professional psychotherapist when talking to you. +Weizenbaum would certainly object to this description, but this is part of +the legend around ELIZA. +Take the site-independent core logic and append the following code: + +@example +@c file eg/network/eliza.awk +function SetUpServer() @{ + SetUpEliza() + TopHeader = \ + "An HTTP-based System with GAWK\ + \ + " + TopDoc = "\ +

Please choose one of the following actions:

\ +
" + TopFooter = "" +@} +@c endfile +@end example + +@code{SetUpServer} is similar to the previous example, +except for calling another function, @code{SetUpEliza}. +This approach can be used to implement other kinds of servers. +The only changes needed to do so are hidden in the functions +@code{SetUpServer} and @code{HandleGET}. Perhaps it might be necessary to +implement other HTTP methods. +The @command{igawk} program that comes with @command{gawk} +may be useful for this process. + +When extending this example to a complete application, the first +thing to do is to implement the function @code{SetUpServer} to +initialize the HTML pages and some variables. These initializations +determine the way your HTML pages look (colors, titles, menu +items, etc.). + +The function @code{HandleGET} is a nested case selection that decides +which page the user wants to see next. Each nesting level refers to a menu +level of the GUI. Each case implements a certain action of the menu. On the +deepest level of case selection, the handler essentially knows what the +user wants and stores the answer into the variable that holds the HTML +page contents: + +@smallexample +@c file eg/network/eliza.awk +function HandleGET() @{ + # A real HTTP server would treat some parts of the URI as a file name. + # We take parts of the URI as menu choices and go on accordingly. + if(MENU[2] == "AboutServer") @{ + Document = "This is not a CGI script.\ + This is an httpd, an HTML file, and a CGI script all \ + in one GAWK script. It needs no separate www-server, \ + no installation, and no root privileges.\ +

To run it, do this:

    \ +
  • start this script with \"gawk -f httpserver.awk\",
  • \ +
  • and on the same host let your www browser open location\ + \"http://localhost:8080\"
  • \ +
\

\ Details of HTTP come from:

    \ +
  • Hethmon: Illustrated Guide to HTTP

    \ +
  • RFC 2068

JK 14.9.1997

" + @} else if (MENU[2] == "AboutELIZA") @{ + Document = "This is an implementation of the famous ELIZA\ + program by Joseph Weizenbaum. It is written in GAWK and\ + uses an HTML GUI." + @} else if (MENU[2] == "StartELIZA") @{ + gsub(/\+/, " ", GETARG["YouSay"]) + # Here we also have to substitute coded special characters + Document = "
" \ + "

" ElizaSays(GETARG["YouSay"]) "

\ +

\ +

" + @} +@} +@c endfile +@end smallexample + +Now we are down to the heart of ELIZA, so you can see how it works. +Initially the user does not say anything; then ELIZA resets its money +counter and asks the user to tell what comes to mind open heartedly. +The subsequent answers are converted to uppercase characters and stored for +later comparison. ELIZA presents the bill when being confronted with +a sentence that contains the phrase ``shut up.'' Otherwise, it looks for +keywords in the sentence, conjugates the rest of the sentence, remembers +the keyword for later use, and finally selects an answer from the set of +possible answers: + +@smallexample +@c file eg/network/eliza.awk +function ElizaSays(YouSay) @{ + if (YouSay == "") @{ + cost = 0 + answer = "HI, IM ELIZA, TELL ME YOUR PROBLEM" + @} else @{ + q = toupper(YouSay) + gsub("'", "", q) + if(q == qold) @{ + answer = "PLEASE DONT REPEAT YOURSELF !" + @} else @{ + if (index(q, "SHUT UP") > 0) @{ + answer = "WELL, PLEASE PAY YOUR BILL. ITS EXACTLY ... $"\ + int(100*rand()+30+cost/100) + @} else @{ + qold = q + w = "-" # no keyword recognized yet + for (i in k) @{ # search for keywords + if (index(q, i) > 0) @{ + w = i + break + @} + @} + if (w == "-") @{ # no keyword, take old subject + w = wold + subj = subjold + @} else @{ # find subject + subj = substr(q, index(q, w) + length(w)+1) + wold = w + subjold = subj # remember keyword and subject + @} + for (i in conj) + gsub(i, conj[i], q) # conjugation + # from all answers to this keyword, select one randomly + answer = r[indices[int(split(k[w], indices) * rand()) + 1]] + # insert subject into answer + gsub("_", subj, answer) + @} + @} + @} + cost += length(answer) # for later payment : 1 cent per character + return answer +@} +@c endfile +@end smallexample + +In the long but simple function @code{SetUpEliza}, you can see tables +for conjugation, keywords, and answers.@footnote{The version shown +here is abbreviated. The full version comes with the @command{gawk} +distribution.} The associative array @code{k} +contains indices into the array of answers @code{r}. To choose an +answer, ELIZA just picks an index randomly: + +@example +@c file eg/network/eliza.awk +function SetUpEliza() @{ + srand() + wold = "-" + subjold = " " + + # table for conjugation + conj[" ARE " ] = " AM " + conj["WERE " ] = "WAS " + conj[" YOU " ] = " I " + conj["YOUR " ] = "MY " + conj[" IVE " ] =\ + conj[" I HAVE " ] = " YOU HAVE " + conj[" YOUVE " ] =\ + conj[" YOU HAVE "] = " I HAVE " + conj[" IM " ] =\ + conj[" I AM " ] = " YOU ARE " + conj[" YOURE " ] =\ + conj[" YOU ARE " ] = " I AM " + + # table of all answers + r[1] = "DONT YOU BELIEVE THAT I CAN _" + r[2] = "PERHAPS YOU WOULD LIKE TO BE ABLE TO _ ?" +@c endfile + @dots{} +@end example +@ignore +@c file eg/network/eliza.awk + r[3] = "YOU WANT ME TO BE ABLE TO _ ?" + r[4] = "PERHAPS YOU DONT WANT TO _ " + r[5] = "DO YOU WANT TO BE ABLE TO _ ?" + r[6] = "WHAT MAKES YOU THINK I AM _ ?" + r[7] = "DOES IT PLEASE YOU TO BELIEVE I AM _ ?" + r[8] = "PERHAPS YOU WOULD LIKE TO BE _ ?" + r[9] = "DO YOU SOMETIMES WISH YOU WERE _ ?" + r[10] = "DONT YOU REALLY _ ?" + r[11] = "WHY DONT YOU _ ?" + r[12] = "DO YOU WISH TO BE ABLE TO _ ?" + r[13] = "DOES THAT TROUBLE YOU ?" + r[14] = "TELL ME MORE ABOUT SUCH FEELINGS" + r[15] = "DO YOU OFTEN FEEL _ ?" + r[16] = "DO YOU ENJOY FEELING _ ?" + r[17] = "DO YOU REALLY BELIEVE I DONT _ ?" + r[18] = "PERHAPS IN GOOD TIME I WILL _ " + r[19] = "DO YOU WANT ME TO _ ?" + r[20] = "DO YOU THINK YOU SHOULD BE ABLE TO _ ?" + r[21] = "WHY CANT YOU _ ?" + r[22] = "WHY ARE YOU INTERESTED IN WHETHER OR NOT I AM _ ?" + r[23] = "WOULD YOU PREFER IF I WERE NOT _ ?" + r[24] = "PERHAPS IN YOUR FANTASIES I AM _ " + r[25] = "HOW DO YOU KNOW YOU CANT _ ?" + r[26] = "HAVE YOU TRIED ?" + r[27] = "PERHAPS YOU CAN NOW _ " + r[28] = "DID YOU COME TO ME BECAUSE YOU ARE _ ?" + r[29] = "HOW LONG HAVE YOU BEEN _ ?" + r[30] = "DO YOU BELIEVE ITS NORMAL TO BE _ ?" + r[31] = "DO YOU ENJOY BEING _ ?" + r[32] = "WE WERE DISCUSSING YOU -- NOT ME" + r[33] = "Oh, I _" + r[34] = "YOU'RE NOT REALLY TALKING ABOUT ME, ARE YOU ?" + r[35] = "WHAT WOULD IT MEAN TO YOU, IF YOU GOT _ ?" + r[36] = "WHY DO YOU WANT _ ?" + r[37] = "SUPPOSE YOU SOON GOT _" + r[38] = "WHAT IF YOU NEVER GOT _ ?" + r[39] = "I SOMETIMES ALSO WANT _" + r[40] = "WHY DO YOU ASK ?" + r[41] = "DOES THAT QUESTION INTEREST YOU ?" + r[42] = "WHAT ANSWER WOULD PLEASE YOU THE MOST ?" + r[43] = "WHAT DO YOU THINK ?" + r[44] = "ARE SUCH QUESTIONS IN YOUR MIND OFTEN ?" + r[45] = "WHAT IS IT THAT YOU REALLY WANT TO KNOW ?" + r[46] = "HAVE YOU ASKED ANYONE ELSE ?" + r[47] = "HAVE YOU ASKED SUCH QUESTIONS BEFORE ?" + r[48] = "WHAT ELSE COMES TO MIND WHEN YOU ASK THAT ?" + r[49] = "NAMES DON'T INTEREST ME" + r[50] = "I DONT CARE ABOUT NAMES -- PLEASE GO ON" + r[51] = "IS THAT THE REAL REASON ?" + r[52] = "DONT ANY OTHER REASONS COME TO MIND ?" + r[53] = "DOES THAT REASON EXPLAIN ANYTHING ELSE ?" + r[54] = "WHAT OTHER REASONS MIGHT THERE BE ?" + r[55] = "PLEASE DON'T APOLOGIZE !" + r[56] = "APOLOGIES ARE NOT NECESSARY" + r[57] = "WHAT FEELINGS DO YOU HAVE WHEN YOU APOLOGIZE ?" + r[58] = "DON'T BE SO DEFENSIVE" + r[59] = "WHAT DOES THAT DREAM SUGGEST TO YOU ?" + r[60] = "DO YOU DREAM OFTEN ?" + r[61] = "WHAT PERSONS APPEAR IN YOUR DREAMS ?" + r[62] = "ARE YOU DISTURBED BY YOUR DREAMS ?" + r[63] = "HOW DO YOU DO ... PLEASE STATE YOUR PROBLEM" + r[64] = "YOU DON'T SEEM QUITE CERTAIN" + r[65] = "WHY THE UNCERTAIN TONE ?" + r[66] = "CAN'T YOU BE MORE POSITIVE ?" + r[67] = "YOU AREN'T SURE ?" + r[68] = "DON'T YOU KNOW ?" + r[69] = "WHY NO _ ?" + r[70] = "DON'T SAY NO, IT'S ALWAYS SO NEGATIVE" + r[71] = "WHY NOT ?" + r[72] = "ARE YOU SURE ?" + r[73] = "WHY NO ?" + r[74] = "WHY ARE YOU CONCERNED ABOUT MY _ ?" + r[75] = "WHAT ABOUT YOUR OWN _ ?" + r[76] = "CAN'T YOU THINK ABOUT A SPECIFIC EXAMPLE ?" + r[77] = "WHEN ?" + r[78] = "WHAT ARE YOU THINKING OF ?" + r[79] = "REALLY, ALWAYS ?" + r[80] = "DO YOU REALLY THINK SO ?" + r[81] = "BUT YOU ARE NOT SURE YOU _ " + r[82] = "DO YOU DOUBT YOU _ ?" + r[83] = "IN WHAT WAY ?" + r[84] = "WHAT RESEMBLANCE DO YOU SEE ?" + r[85] = "WHAT DOES THE SIMILARITY SUGGEST TO YOU ?" + r[86] = "WHAT OTHER CONNECTION DO YOU SEE ?" + r[87] = "COULD THERE REALLY BE SOME CONNECTIONS ?" + r[88] = "HOW ?" + r[89] = "YOU SEEM QUITE POSITIVE" + r[90] = "ARE YOU SURE ?" + r[91] = "I SEE" + r[92] = "I UNDERSTAND" + r[93] = "WHY DO YOU BRING UP THE TOPIC OF FRIENDS ?" + r[94] = "DO YOUR FRIENDS WORRY YOU ?" + r[95] = "DO YOUR FRIENDS PICK ON YOU ?" + r[96] = "ARE YOU SURE YOU HAVE ANY FRIENDS ?" + r[97] = "DO YOU IMPOSE ON YOUR FRIENDS ?" + r[98] = "PERHAPS YOUR LOVE FOR FRIENDS WORRIES YOU" + r[99] = "DO COMPUTERS WORRY YOU ?" + r[100] = "ARE YOU TALKING ABOUT ME IN PARTICULAR ?" + r[101] = "ARE YOU FRIGHTENED BY MACHINES ?" + r[102] = "WHY DO YOU MENTION COMPUTERS ?" + r[103] = "WHAT DO YOU THINK MACHINES HAVE TO DO WITH YOUR PROBLEMS ?" + r[104] = "DON'T YOU THINK COMPUTERS CAN HELP PEOPLE ?" + r[105] = "WHAT IS IT ABOUT MACHINES THAT WORRIES YOU ?" + r[106] = "SAY, DO YOU HAVE ANY PSYCHOLOGICAL PROBLEMS ?" + r[107] = "WHAT DOES THAT SUGGEST TO YOU ?" + r[108] = "I SEE" + r[109] = "IM NOT SURE I UNDERSTAND YOU FULLY" + r[110] = "COME COME ELUCIDATE YOUR THOUGHTS" + r[111] = "CAN YOU ELABORATE ON THAT ?" + r[112] = "THAT IS QUITE INTERESTING" + r[113] = "WHY DO YOU HAVE PROBLEMS WITH MONEY ?" + r[114] = "DO YOU THINK MONEY IS EVERYTHING ?" + r[115] = "ARE YOU SURE THAT MONEY IS THE PROBLEM ?" + r[116] = "I THINK WE WANT TO TALK ABOUT YOU, NOT ABOUT ME" + r[117] = "WHAT'S ABOUT ME ?" + r[118] = "WHY DO YOU ALWAYS BRING UP MY NAME ?" +@c endfile +@end ignore + +@example +@c file eg/network/eliza.awk + # table for looking up answers that + # fit to a certain keyword + k["CAN YOU"] = "1 2 3" + k["CAN I"] = "4 5" + k["YOU ARE"] =\ + k["YOURE"] = "6 7 8 9" +@c endfile + @dots{} +@end example +@ignore +@c file eg/network/eliza.awk + k["I DONT"] = "10 11 12 13" + k["I FEEL"] = "14 15 16" + k["WHY DONT YOU"] = "17 18 19" + k["WHY CANT I"] = "20 21" + k["ARE YOU"] = "22 23 24" + k["I CANT"] = "25 26 27" + k["I AM"] =\ + k["IM "] = "28 29 30 31" + k["YOU "] = "32 33 34" + k["I WANT"] = "35 36 37 38 39" + k["WHAT"] =\ + k["HOW"] =\ + k["WHO"] =\ + k["WHERE"] =\ + k["WHEN"] =\ + k["WHY"] = "40 41 42 43 44 45 46 47 48" + k["NAME"] = "49 50" + k["CAUSE"] = "51 52 53 54" + k["SORRY"] = "55 56 57 58" + k["DREAM"] = "59 60 61 62" + k["HELLO"] =\ + k["HI "] = "63" + k["MAYBE"] = "64 65 66 67 68" + k[" NO "] = "69 70 71 72 73" + k["YOUR"] = "74 75" + k["ALWAYS"] = "76 77 78 79" + k["THINK"] = "80 81 82" + k["LIKE"] = "83 84 85 86 87 88 89" + k["YES"] = "90 91 92" + k["FRIEND"] = "93 94 95 96 97 98" + k["COMPUTER"] = "99 100 101 102 103 104 105" + k["-"] = "106 107 108 109 110 111 112" + k["MONEY"] = "113 114 115" + k["ELIZA"] = "116 117 118" +@c endfile +@end ignore +@example +@c file eg/network/eliza.awk +@} +@c endfile +@end example + +@cindex Humphrys, Mark +@cindex ELIZA program +Some interesting remarks and details (including the original source code +of ELIZA) are found on Mark Humphrys' home page. Yahoo! also has a +page with a collection of ELIZA-like programs. Many of them are written +in Java, some of them disclosing the Java source code, and a few even +explain how to modify the Java source code. + +@node Caveats, Challenges, Simple Server, Using Networking +@section Network Programming Caveats + +@cindex networks, @command{gawk} and, troubleshooting +@cindex @command{gawk}, networking, troubleshooting +@cindex troubleshooting, @command{gawk}, networks +By now it should be clear +that debugging a networked application is more +complicated than debugging a single-process single-hosted application. +The behavior of a networked application sometimes looks noncausal because +it is not reproducible in a strong sense. Whether a network application +works or not sometimes depends on the following: + +@itemize @bullet +@item +How crowded the underlying network is + +@item +If the party at the other end is running or not + +@item +The state of the party at the other end +@end itemize + +@cindex troubleshooting, networks, timeouts +The most difficult problems for a beginner arise from the hidden states of the +underlying network. After closing a TCP connection, it's often necessary to wait +a short while before reopening the connection. Even more difficult is the +establishment of a connection that previously ended with a ``broken pipe.'' +Those connections have to ``time out'' for a minute or so +before they can reopen. +Check this with the command @samp{netstat -a}, which +provides a list of still ``active'' connections. + +@node Challenges, , Caveats, Using Networking +@section Where To Go From Here + +@cindex Loebner, Hugh +@cindex contest +Now, you have learned enough to build your own application. You could, +for example, take part in the +Loebner Contest +to win $100,000. The Loebner Prize is the first formal instantiation of +a Turing Test. Hugh Loebner agreed with The Cambridge Center for Behavioral +Studies to underwrite a contest designed to implement the Turing Test. +Dr.@: Loebner pledged a Grand Prize of $100,000 for the first computer whose +responses were indistinguishable from a human's. Each year an annual prize +of $2000 and a bronze medal is awarded to the @emph{most} human computer. +The winner of the annual contest is the best entry relative to other entries +that year, irrespective of how good it is in an absolute sense. Here is +an example of a conversation with the winning program of 1997: + +@smallexample +(c)1997 Cambridge Center For Behavioral Studies all rights reserved [CONVERSE] +[Intelligent Research Ltd.] Start at: [1997/04/29 08:59:40] +PROGRAM[10:39:20]Hi, my name is Catherine, what's yours? +JUDGE02[10:39:36]My name is Nathan. +PROGRAM[10:39:37]Well, it's nice to meet you, Nathan. +PROGRAM[10:39:45]Did you see that story on CNN last night about the lesbian +PROGRAM[10:40:03]couple who came out at a White House party on Sunday? +JUDGE02[10:40:45]No. I'm sorry I missed that. How did the Prez take it? +PROGRAM[10:40:47]Ellen Degeneres was one of them - she was kissing her lover +PROGRAM[10:41:08]in front of Bill Clinton. Do you think he was very +PROGRAM[10:41:21]embarrassed? +JUDGE02[10:41:37]You tell me. I didn't see it. +PROGRAM[10:41:38]Are you still a Friend of Bill Clinton? +JUDGE02[10:42:22]Yes. I would like to talk about something else. Do you know anything about sculpture. +PROGRAM[10:42:24]Well, I suppose he's doing his best like most of us, but he +PROGRAM[10:42:35]does seem to attract an UNUSUAL amount of bad publicity, +PROGRAM[10:42:51]wouldnt you say--can it all be bad luck? +JUDGE02[10:43:20]I asked you if you knew anything about sculpture. +PROGRAM[10:43:21]OK, but what happens now--does it all drift on, with +PROGRAM[10:43:36]everyone waiting to see how much his friends have said about +PROGRAM[10:43:47]him under threat of lots and lots of jail-or will something +PROGRAM[10:44:01]dramatic actually happen? +JUDGE02[10:44:19]Do you know what sculpture is? +PROGRAM[10:44:20]Well, youre more a fan of his than I am I guess---though I +PROGRAM[10:44:34]cant SWEAR what Id have done in that locked hotel room, I +PROGRAM[10:44:51]must say. +JUDGE02[10:45:26]Have you ever been to the Salmagundi Club? +PROGRAM[10:45:29]Never. to go back to the original discussion Time to get +PROGRAM[10:45:43]off this one I think and onto something more down to earth! +JUDGE02[10:46:20]What is more down to earth than art? +PROGRAM[10:46:21]I don't know what -- to be honest. - +PROGRAM[10:46:30]I suppose it depends on where you're coming from, but as the +PROGRAM[10:46:46]song goes in My Fair Lady, "Why can't a woman be more like a +PROGRAM[10:47:03]man? " +JUDGE02[10:47:52]I liked that song but I prefer "Why can't children be more like we are" +JUDGE02[10:48:10]from another play the name of which I cannot remember. +PROGRAM[10:48:12]What, if anything, do you enjoy about being a man? +JUDGE02[10:49:01]I would enjoy all aspects of life no matter what my gender. +PROGRAM[10:49:02]Do you think of yourself as being attractive? +@end smallexample + +@cindex Clinton, Bill +This program insists on always speaking about the same story around Bill +Clinton. You see, even a program with a rather narrow mind can behave so +much like a human being that it can win this prize. It is quite common to +let these programs talk to each other via network connections. But during the +competition itself, the program and its computer have to be present at the +place the competition is held. We all would love to see a @command{gawk} +program win in such an event. Maybe it is up to you to accomplish this? + +Some other ideas for useful networked applications: +@itemize @bullet +@item +Read the file @file{doc/awkforai.txt} in the @command{gawk} distribution. +It was written by Ronald P.@: Loui (at the time, Associate Professor of +Computer Science, at Washington University in St. Louis, +@email{loui@@ai.wustl.edu}) and summarizes why +he taught @command{gawk} to students of Artificial Intelligence. Here are +some passages from the text: + +@cindex AI +@cindex PROLOG +@cindex Loui, Ronald +@cindex agent +@quotation +The GAWK manual can +be consumed in a single lab session and the language can be mastered by +the next morning by the average student. GAWK's automatic +initialization, implicit coercion, I/O support and lack of pointers +forgive many of the mistakes that young programmers are likely to make. +Those who have seen C but not mastered it are happy to see that GAWK +retains some of the same sensibilities while adding what must be +regarded as spoonsful of syntactic sugar.@* +@dots{}@* +@cindex robot +There are further simple answers. Probably the best is the fact that +increasingly, undergraduate AI programming is involving the Web. Oren +Etzioni (University of Washington, Seattle) has for a while been arguing +that the ``softbot'' is replacing the mechanical engineers' robot as the +most glamorous AI testbed. If the artifact whose behavior needs to be +controlled in an intelligent way is the software agent, then a language +that is well-suited to controlling the software environment is the +appropriate language. That would imply a scripting language. If the +robot is KAREL, then the right language is ``turn left; turn right.'' If +the robot is Netscape, then the right language is something that can +generate @samp{netscape -remote 'openURL(http://cs.wustl.edu/~loui)'} with +elan.@* +@dots{}@* +AI programming requires high-level thinking. There have always been a few +gifted programmers who can write high-level programs in assembly language. +Most however need the ambient abstraction to have a higher floor.@* +@dots{}@* +Second, inference is merely the expansion of notation. No matter whether +the logic that underlies an AI program is fuzzy, probabilistic, deontic, +defeasible, or deductive, the logic merely defines how strings can be +transformed into other strings. A language that provides the best +support for string processing in the end provides the best support for +logic, for the exploration of various logics, and for most forms of +symbolic processing that AI might choose to call ``reasoning'' instead of +``logic.'' The implication is that PROLOG, which saves the AI programmer +from having to write a unifier, saves perhaps two dozen lines of GAWK +code at the expense of strongly biasing the logic and representational +expressiveness of any approach. +@end quotation + +Now that @command{gawk} itself can connect to the Internet, it should be obvious +that it is suitable for writing intelligent web agents. + +@item +@command{awk} is strong at pattern recognition and string processing. +So, it is well suited to the classic problem of language translation. +A first try could be a program that knows the 100 most frequent English +words and their counterparts in German or French. The service could be +implemented by regularly reading email with the program above, replacing +each word by its translation and sending the translation back via SMTP. +Users would send English email to their translation service and get +back a translated email message in return. As soon as this works, +more effort can be spent on a real translation program. + +@item +Another dialogue-oriented application (on the verge +of ridicule) is the email ``support service.'' Troubled customers write an +email to an automatic @command{gawk} service that reads the email. It looks +for keywords in the mail and assembles a reply email accordingly. By carefully +investigating the email header, and repeating these keywords through the +reply email, it is rather simple to give the customer a feeling that +someone cares. Ideally, such a service would search a database of previous +cases for solutions. If none exists, the database could, for example, consist +of all the newsgroups, mailing lists and FAQs on the Internet. +@end itemize + +@node Some Applications and Techniques, Links, Using Networking, Top +@comment node-name, next, previous, up + +@chapter Some Applications and Techniques +In this @value{CHAPTER}, we look at a number of self-contained +scripts, with an emphasis on concise networking. Along the way, we +work towards creating building blocks that encapsulate often needed +functions of the networking world, show new techniques that +broaden the scope of problems that can be solved with @command{gawk}, and +explore leading edge technology that may shape the future of networking. + +We often refer to the site-independent core of the server that +we built in +@ref{Simple Server, ,A Simple Web Server}. +When building new and nontrivial servers, we +always copy this building block and append new instances of the two +functions @code{SetUpServer} and @code{HandleGET}. + +This makes a lot of sense, since +this scheme of event-driven +execution provides @command{gawk} with an interface to the most widely +accepted standard for GUIs: the web browser. Now, @command{gawk} can rival even +Tcl/Tk. + +@cindex Tcl/Tk, @command{gawk} and +Tcl and @command{gawk} have much in common. Both are simple scripting languages +that allow us to quickly solve problems with short programs. But Tcl has Tk +on top of it, and @command{gawk} had nothing comparable up to now. While Tcl +needs a large and ever-changing library (Tk, which was bound to the X Window +System until recently), @command{gawk} needs just the networking interface +and some kind of browser on the client's side. Besides better portability, +the most important advantage of this approach (embracing well-established +standards such HTTP and HTML) is that @emph{we do not need to change the +language}. We let others do the work of fighting over protocols and standards. +We can use HTML, JavaScript, VRML, or whatever else comes along to do our work. + +@menu +* PANIC:: An Emergency Web Server. +* GETURL:: Retrieving Web Pages. +* REMCONF:: Remote Configuration Of Embedded Systems. +* URLCHK:: Look For Changed Web Pages. +* WEBGRAB:: Extract Links From A Page. +* STATIST:: Graphing A Statistical Distribution. +* MAZE:: Walking Through A Maze In Virtual Reality. +* MOBAGWHO:: A Simple Mobile Agent. +* STOXPRED:: Stock Market Prediction As A Service. +* PROTBASE:: Searching Through A Protein Database. +@end menu + +@node PANIC, GETURL, Some Applications and Techniques, Some Applications and Techniques +@section PANIC: An Emergency Web Server +@cindex PANIC program +@cindex networks, See Also web pages +@cindex web service +At first glance, the @code{"Hello, world"} example in +@ref{Primitive Service, ,A Primitive Web Service}, +seems useless. By adding just a few lines, we can turn it into something useful. + +The PANIC program tells everyone who connects that the local +site is not working. When a web server breaks down, it makes a difference +if customers get a strange ``network unreachable'' message, or a short message +telling them that the server has a problem. In such an emergency, +the hard disk and everything on it (including the regular web service) may +be unavailable. Rebooting the web server off a diskette makes sense in this +setting. + +To use the PANIC program as an emergency web server, all you need are the +@command{gawk} executable and the program below on a diskette. By default, +it connects to port 8080. A different value may be supplied on the +command line: + +@example +@c file eg/network/panic.awk +BEGIN @{ + RS = ORS = "\r\n" + if (MyPort == 0) MyPort = 8080 + HttpService = "/inet/tcp/" MyPort "/0/0" + Hello = "Out Of Service" \ + "

" \ + "This site is temporarily out of service." \ + "

" + Len = length(Hello) + length(ORS) + while ("awk" != "complex") @{ + print "HTTP/1.0 200 OK" |& HttpService + print "Content-Length: " Len ORS |& HttpService + print Hello |& HttpService + while ((HttpService |& getline) > 0) + continue; + close(HttpService) + @} +@} +@c endfile +@end example + +@node GETURL, REMCONF, PANIC, Some Applications and Techniques +@section GETURL: Retrieving Web Pages +@cindex GETURL program +@cindex web pages, retrieving +GETURL is a versatile building block for shell scripts that need to retrieve +files from the Internet. It takes a web address as a command-line parameter and +tries to retrieve the contents of this address. The contents are printed +to standard output, while the header is printed to @file{/dev/stderr}. +A surrounding shell script +could analyze the contents and extract the text or the links. An ASCII +browser could be written around GETURL. But more interestingly, web robots are +straightforward to write on top of GETURL. On the Internet, you can find +several programs of the same name that do the same job. They are usually +much more complex internally and at least 10 times longer. + +At first, GETURL checks if it was called with exactly one web address. +Then, it checks if the user chose to use a special proxy server whose name +is handed over in a variable. By default, it is assumed that the local +machine serves as proxy. GETURL uses the @code{GET} method by default +to access the web page. By handing over the name of a different method +(such as @code{HEAD}), it is possible to choose a different behavior. With +the @code{HEAD} method, the user does not receive the body of the page +content, but does receive the header: + +@example +@c file eg/network/geturl.awk +BEGIN @{ + if (ARGC != 2) @{ + print "GETURL - retrieve Web page via HTTP 1.0" + print "IN:\n the URL as a command-line parameter" + print "PARAM(S):\n -v Proxy=MyProxy" + print "OUT:\n the page content on stdout" + print " the page header on stderr" + print "JK 16.05.1997" + print "ADR 13.08.2000" + exit + @} + URL = ARGV[1]; ARGV[1] = "" + if (Proxy == "") Proxy = "127.0.0.1" + if (ProxyPort == 0) ProxyPort = 80 + if (Method == "") Method = "GET" + HttpService = "/inet/tcp/0/" Proxy "/" ProxyPort + ORS = RS = "\r\n\r\n" + print Method " " URL " HTTP/1.0" |& HttpService + HttpService |& getline Header + print Header > "/dev/stderr" + while ((HttpService |& getline) > 0) + printf "%s", $0 + close(HttpService) +@} +@c endfile +@end example + +This program can be changed as needed, but be careful with the last lines. +Make sure transmission of binary data is not corrupted by additional line +breaks. Even as it is now, the byte sequence @code{"\r\n\r\n"} would +disappear if it were contained in binary data. Don't get caught in a +trap when trying a quick fix on this one. + +@node REMCONF, URLCHK, GETURL, Some Applications and Techniques +@section REMCONF: Remote Configuration of Embedded Systems +@cindex REMCONF program +@cindex Linux +@cindex GNU/Linux +@cindex Yahoo! +Today, you often find powerful processors in embedded systems. Dedicated +network routers and controllers for all kinds of machinery are examples +of embedded systems. Processors like the Intel 80x86 or the AMD Elan are +able to run multitasking operating systems, such as XINU or GNU/Linux +in embedded PCs. These systems are small and usually do not have +a keyboard or a display. Therefore it is difficult to set up their +configuration. There are several widespread ways to set them up: + +@itemize @bullet +@item +DIP switches + +@item +Read Only Memories such as EPROMs + +@item +Serial lines or some kind of keyboard + +@item +Network connections via @command{telnet} or SNMP + +@item +HTTP connections with HTML GUIs +@end itemize + +In this @value{SECTION}, we look at a solution that uses HTTP connections +to control variables of an embedded system that are stored in a file. +Since embedded systems have tight limits on resources like memory, +it is difficult to employ advanced techniques such as SNMP and HTTP +servers. @command{gawk} fits in quite nicely with its single executable +which needs just a short script to start working. +The following program stores the variables in a file, and a concurrent +process in the embedded system may read the file. The program uses the +site-independent part of the simple web server that we developed in +@ref{Interacting Service, ,A Web Service with Interaction}. +As mentioned there, all we have to do is to write two new procedures +@code{SetUpServer} and @code{HandleGET}: + +@smallexample +@c file eg/network/remconf.awk +function SetUpServer() @{ + TopHeader = "Remote Configuration" + TopDoc = "\ +

Please choose one of the following actions:

\ + " + TopFooter = "" + if (ConfigFile == "") ConfigFile = "config.asc" +@} +@c endfile +@end smallexample + +The function @code{SetUpServer} initializes the top level HTML texts +as usual. It also initializes the name of the file that contains the +configuration parameters and their values. In case the user supplies +a name from the command line, that name is used. The file is expected to +contain one parameter per line, with the name of the parameter in +column one and the value in column two. + +The function @code{HandleGET} reflects the structure of the menu +tree as usual. The first menu choice tells the user what this is all +about. The second choice reads the configuration file line by line +and stores the parameters and their values. Notice that the record +separator for this file is @code{"\n"}, in contrast to the record separator +for HTTP. The third menu choice builds an HTML table to show +the contents of the configuration file just read. The fourth choice +does the real work of changing parameters, and the last one just saves +the configuration into a file: + +@smallexample +@c file eg/network/remconf.awk +function HandleGET() @{ + if(MENU[2] == "AboutServer") @{ + Document = "This is a GUI for remote configuration of an\ + embedded system. It is is implemented as one GAWK script." + @} else if (MENU[2] == "ReadConfig") @{ + RS = "\n" + while ((getline < ConfigFile) > 0) + config[$1] = $2; + close(ConfigFile) + RS = "\r\n" + Document = "Configuration has been read." + @} else if (MENU[2] == "CheckConfig") @{ + Document = "" + for (i in config) + Document = Document "" \ + "" + Document = Document "
" i "" config[i] "
" + @} else if (MENU[2] == "ChangeConfig") @{ + if ("Param" in GETARG) @{ # any parameter to set? + if (GETARG["Param"] in config) @{ # is parameter valid? + config[GETARG["Param"]] = GETARG["Value"] + Document = (GETARG["Param"] " = " GETARG["Value"] ".") + @} else @{ + Document = "Parameter " GETARG["Param"] " is invalid." + @} + @} else @{ + Document = "

Change one parameter

\ + \ + \ + \ + \ +
ParameterValue
" + @} + @} else if (MENU[2] == "SaveConfig") @{ + for (i in config) + printf("%s %s\n", i, config[i]) > ConfigFile + close(ConfigFile) + Document = "Configuration has been saved." + @} +@} +@c endfile +@end smallexample + +@cindex MiniSQL +We could also view the configuration file as a database. From this +point of view, the previous program acts like a primitive database server. +Real SQL database systems also make a service available by providing +a TCP port that clients can connect to. But the application level protocols +they use are usually proprietary and also change from time to time. +This is also true for the protocol that +MiniSQL uses. + +@node URLCHK, WEBGRAB, REMCONF, Some Applications and Techniques +@section URLCHK: Look for Changed Web Pages +@cindex URLCHK program +Most people who make heavy use of Internet resources have a large +bookmark file with pointers to interesting web sites. It is impossible +to regularly check by hand if any of these sites have changed. A program +is needed to automatically look at the headers of web pages and tell +which ones have changed. URLCHK does the comparison after using GETURL +with the @code{HEAD} method to retrieve the header. + +Like GETURL, this program first checks that it is called with exactly +one command-line parameter. URLCHK also takes the same command-line variables +@code{Proxy} and @code{ProxyPort} as GETURL, +because these variables are handed over to GETURL for each URL +that gets checked. The one and only parameter is the name of a file that +contains one line for each URL. In the first column, we find the URL, and +the second and third columns hold the length of the URL's body when checked +for the two last times. Now, we follow this plan: + +@enumerate +@item +Read the URLs from the file and remember their most recent lengths + +@item +Delete the contents of the file + +@item +For each URL, check its new length and write it into the file + +@item +If the most recent and the new length differ, tell the user +@end enumerate + +It may seem a bit peculiar to read the URLs from a file together +with their two most recent lengths, but this approach has several +advantages. You can call the program again and again with the same +file. After running the program, you can regenerate the changed URLs +by extracting those lines that differ in their second and third columns: + +@c inspired by URLCHK in iX 5/97 166. +@smallexample +@c file eg/network/urlchk.awk +BEGIN @{ + if (ARGC != 2) @{ + print "URLCHK - check if URLs have changed" + print "IN:\n the file with URLs as a command-line parameter" + print " file contains URL, old length, new length" + print "PARAMS:\n -v Proxy=MyProxy -v ProxyPort=8080" + print "OUT:\n same as file with URLs" + print "JK 02.03.1998" + exit + @} + URLfile = ARGV[1]; ARGV[1] = "" + if (Proxy != "") Proxy = " -v Proxy=" Proxy + if (ProxyPort != "") ProxyPort = " -v ProxyPort=" ProxyPort + while ((getline < URLfile) > 0) + Length[$1] = $3 + 0 + close(URLfile) # now, URLfile is read in and can be updated + GetHeader = "gawk " Proxy ProxyPort " -v Method=\"HEAD\" -f geturl.awk " + for (i in Length) @{ + GetThisHeader = GetHeader i " 2>&1" + while ((GetThisHeader | getline) > 0) + if (toupper($0) ~ /CONTENT-LENGTH/) NewLength = $2 + 0 + close(GetThisHeader) + print i, Length[i], NewLength > URLfile + if (Length[i] != NewLength) # report only changed URLs + print i, Length[i], NewLength + @} + close(URLfile) +@} +@c endfile +@end smallexample + +Another thing that may look strange is the way GETURL is called. +Before calling GETURL, we have to check if the proxy variables need +to be passed on. If so, we prepare strings that will become part +of the command line later. In @code{GetHeader}, we store these strings +together with the longest part of the command line. Later, in the loop +over the URLs, @code{GetHeader} is appended with the URL and a redirection +operator to form the command that reads the URL's header over the Internet. +GETURL always produces the headers over @file{/dev/stderr}. That is +the reason why we need the redirection operator to have the header +piped in. + +This program is not perfect because it assumes that changing URLs +results in changed lengths, which is not necessarily true. A more +advanced approach is to look at some other header line that +holds time information. But, as always when things get a bit more +complicated, this is left as an exercise to the reader. + +@node WEBGRAB, STATIST, URLCHK, Some Applications and Techniques +@section WEBGRAB: Extract Links from a Page +@cindex WEBGRAB program +@c Inspired by iX 1/98 157. +@cindex robot +Sometimes it is necessary to extract links from web pages. +Browsers do it, web robots do it, and sometimes even humans do it. +Since we have a tool like GETURL at hand, we can solve this problem with +some help from the Bourne shell: + +@example +@c file eg/network/webgrab.awk +BEGIN @{ RS = "http://[#%&\\+\\-\\./0-9\\:;\\?A-Z_a-z\\~]*" @} +RT != "" @{ + command = ("gawk -v Proxy=MyProxy -f geturl.awk " RT \ + " > doc" NR ".html") + print command +@} +@c endfile +@end example + +Notice that the regular expression for URLs is rather crude. A precise +regular expression is much more complex. But this one works +rather well. One problem is that it is unable to find internal links of +an HTML document. Another problem is that +@samp{ftp}, @samp{telnet}, @samp{news}, @samp{mailto}, and other kinds +of links are missing in the regular expression. +However, it is straightforward to add them, if doing so is necessary for other tasks. + +This program reads an HTML file and prints all the HTTP links that it finds. +It relies on @command{gawk}'s ability to use regular expressions as record +separators. With @code{RS} set to a regular expression that matches links, +the second action is executed each time a non-empty link is found. +We can find the matching link itself in @code{RT}. + +The action could use the @code{system} function to let another GETURL +retrieve the page, but here we use a different approach. +This simple program prints shell commands that can be piped into @command{sh} +for execution. This way it is possible to first extract +the links, wrap shell commands around them, and pipe all the shell commands +into a file. After editing the file, execution of the file retrieves +exactly those files that we really need. In case we do not want to edit, +we can retrieve all the pages like this: + +@smallexample +gawk -f geturl.awk http://www.suse.de | gawk -f webgrab.awk | sh +@end smallexample + +@cindex Microsoft Windows +After this, you will find the contents of all referenced documents in +files named @file{doc*.html} even if they do not contain HTML code. +The most annoying thing is that we always have to pass the proxy to +GETURL. If you do not like to see the headers of the web pages +appear on the screen, you can redirect them to @file{/dev/null}. +Watching the headers appear can be quite interesting, because +it reveals +interesting details such as which web server the companies use. +Now, it is clear how the clever marketing people +use web robots to determine the +market shares +of Microsoft and Netscape in the web server market. + +Port 80 of any web server is like a small hole in a repellent firewall. +After attaching a browser to port 80, we usually catch a glimpse +of the bright side of the server (its home page). With a tool like GETURL +at hand, we are able to discover some of the more concealed +or even ``indecent'' services (i.e., lacking conformity to standards of quality). +It can be exciting to see the fancy CGI scripts that lie +there, revealing the inner workings of the server, ready to be called: + +@itemize @bullet +@item +With a command such as: + +@example +gawk -f geturl.awk http://any.host.on.the.net/cgi-bin/ +@end example + +some servers give you a directory listing of the CGI files. +Knowing the names, you can try to call some of them and watch +for useful results. Sometimes there are executables in such directories +(such as Perl interpreters) that you may call remotely. If there are +subdirectories with configuration data of the web server, this can also +be quite interesting to read. + +@item +@cindex apache +The well-known Apache web server usually has its CGI files in the +directory @file{/cgi-bin}. There you can often find the scripts +@file{test-cgi} and @file{printenv}. Both tell you some things +about the current connection and the installation of the web server. +Just call: + +@smallexample +gawk -f geturl.awk http://any.host.on.the.net/cgi-bin/test-cgi +gawk -f geturl.awk http://any.host.on.the.net/cgi-bin/printenv +@end smallexample + +@item +Sometimes it is even possible to retrieve system files like the web +server's log file---possibly containing customer data---or even the file +@file{/etc/passwd}. +(We don't recommend this!) +@end itemize + +@strong{Caution:} +Although this may sound funny or simply irrelevant, we are talking about +severe security holes. Try to explore your own system this way and make +sure that none of the above reveals too much information about your system. + +@node STATIST, MAZE, WEBGRAB, Some Applications and Techniques +@section STATIST: Graphing a Statistical Distribution +@cindex STATIST program + +@cindex GNUPlot utility +@cindex image format +@cindex GIF image format +@cindex PNG image format +@cindex PS image format +@cindex Boutell, Thomas +@iftex +@image{statist,3in} +@end iftex +In the HTTP server examples we've shown thus far, we never present an image +to the browser and its user. Presenting images is one task. Generating +images that reflect some user input and presenting these dynamically +generated images is another. In this @value{SECTION}, we use GNUPlot +for generating @file{.png}, @file{.ps}, or @file{.gif} +files.@footnote{Due to licensing problems, the default +installation of GNUPlot disables the generation of @file{.gif} files. +If your installed version does not accept @samp{set term gif}, +just download and install the most recent version of GNUPlot and the +@uref{http://www.boutell.com/gd/, GD library} +by Thomas Boutell. +Otherwise you still have the chance to generate some +ASCII-art style images with GNUPlot by using @samp{set term dumb}. +(We tried it and it worked.)} + +The program we develop takes the statistical parameters of two samples +and computes the t-test statistics. As a result, we get the probabilities +that the means and the variances of both samples are the same. In order to +let the user check plausibility, the program presents an image of the +distributions. The statistical computation follows +@cite{Numerical Recipes in C: The Art of Scientific Computing} +by William H.@: Press, Saul A.@: Teukolsky, William T.@: Vetterling, and Brian P. Flannery. +Since @command{gawk} does not have a built-in function +for the computation of the beta function, we use the @code{ibeta} function +of GNUPlot. As a side effect, we learn how to use GNUPlot as a +sophisticated calculator. The comparison of means is done as in @code{tutest}, +paragraph 14.2, page 613, and the comparison of variances is done as in @code{ftest}, +page 611 in @cite{Numerical Recipes}. +@cindex Numerical Recipes + +As usual, we take the site-independent code for servers and append +our own functions @code{SetUpServer} and @code{HandleGET}: + +@smallexample +@c file eg/network/statist.awk +function SetUpServer() @{ + TopHeader = "Statistics with GAWK" + TopDoc = "\ +

Please choose one of the following actions:

\ + " + TopFooter = "" + GnuPlot = "gnuplot 2>&1" + m1=m2=0; v1=v2=1; n1=n2=10 +@} +@c endfile +@end smallexample + +Here, you see the menu structure that the user sees. Later, we +will see how the program structure of the @code{HandleGET} function +reflects the menu structure. What is missing here is the link for the +image we generate. In an event-driven environment, request, +generation, and delivery of images are separated. + +Notice the way we initialize the @code{GnuPlot} command string for +the pipe. By default, +GNUPlot outputs the generated image via standard output, as well as +the results of @code{print}(ed) calculations via standard error. +The redirection causes standard error to be mixed into standard +output, enabling us to read results of calculations with @code{getline}. +By initializing the statistical parameters with some meaningful +defaults, we make sure the user gets an image the first time +he uses the program. + +@cindex JavaScript +Following is the rather long function @code{HandleGET}, which +implements the contents of this service by reacting to the different +kinds of requests from the browser. Before you start playing with +this script, make sure that your browser supports JavaScript and that it also +has this option switched on. The script uses a short snippet of +JavaScript code for delayed opening of a window with an image. +A more detailed explanation follows: + +@smallexample +@c file eg/network/statist.awk +function HandleGET() @{ + if(MENU[2] == "AboutServer") @{ + Document = "This is a GUI for a statistical computation.\ + It compares means and variances of two distributions.\ + It is implemented as one GAWK script and uses GNUPLOT." + @} else if (MENU[2] == "EnterParameters") @{ + Document = "" + if ("m1" in GETARG) @{ # are there parameters to compare? + Document = Document "" + m1 = GETARG["m1"]; v1 = GETARG["v1"]; n1 = GETARG["n1"] + m2 = GETARG["m2"]; v2 = GETARG["v2"]; n2 = GETARG["n2"] + t = (m1-m2)/sqrt(v1/n1+v2/n2) + df = (v1/n1+v2/n2)*(v1/n1+v2/n2)/((v1/n1)*(v1/n1)/(n1-1) \ + + (v2/n2)*(v2/n2) /(n2-1)) + if (v1>v2) @{ + f = v1/v2 + df1 = n1 - 1 + df2 = n2 - 1 + @} else @{ + f = v2/v1 + df1 = n2 - 1 + df2 = n1 - 1 + @} + print "pt=ibeta(" df/2 ",0.5," df/(df+t*t) ")" |& GnuPlot + print "pF=2.0*ibeta(" df2/2 "," df1/2 "," \ + df2/(df2+df1*f) ")" |& GnuPlot + print "print pt, pF" |& GnuPlot + RS="\n"; GnuPlot |& getline; RS="\r\n" # $1 is pt, $2 is pF + print "invsqrt2pi=1.0/sqrt(2.0*pi)" |& GnuPlot + print "nd(x)=invsqrt2pi/sd*exp(-0.5*((x-mu)/sd)**2)" |& GnuPlot + print "set term png small color" |& GnuPlot + #print "set term postscript color" |& GnuPlot + #print "set term gif medium size 320,240" |& GnuPlot + print "set yrange[-0.3:]" |& GnuPlot + print "set label 'p(m1=m2) =" $1 "' at 0,-0.1 left" |& GnuPlot + print "set label 'p(v1=v2) =" $2 "' at 0,-0.2 left" |& GnuPlot + print "plot mu=" m1 ",sd=" sqrt(v1) ", nd(x) title 'sample 1',\ + mu=" m2 ",sd=" sqrt(v2) ", nd(x) title 'sample 2'" |& GnuPlot + print "quit" |& GnuPlot + GnuPlot |& getline Image + while ((GnuPlot |& getline) > 0) + Image = Image RS $0 + close(GnuPlot) + @} + Document = Document "\ +

Do these samples have the same Gaussian distribution?

\ +
\ + \ + + \ + + \ + + \ + \ + + \ + + \ + + \ + \ +
1. Mean 1. Variance1. Count
2. Mean 2. Variance2. Count

" + @} else if (MENU[2] ~ "Image") @{ + Reason = "OK" ORS "Content-type: image/png" + #Reason = "OK" ORS "Content-type: application/x-postscript" + #Reason = "OK" ORS "Content-type: image/gif" + Header = Footer = "" + Document = Image + @} +@} +@c endfile +@end smallexample + +@cindex PostScript +As usual, we give a short description of the service in the first +menu choice. The third menu choice shows us that generation and +presentation of an image are two separate actions. While the latter +takes place quite instantly in the third menu choice, the former +takes place in the much longer second choice. Image data passes from the +generating action to the presenting action via the variable @code{Image} +that contains a complete @file{.png} image, which is otherwise stored +in a file. If you prefer @file{.ps} or @file{.gif} images over the +default @file{.png} images, you may select these options by uncommenting +the appropriate lines. But remember to do so in two places: when +telling GNUPlot which kind of images to generate, and when transmitting the +image at the end of the program. + +Looking at the end of the program, +the way we pass the @samp{Content-type} to the browser is a bit unusual. +It is appended to the @samp{OK} of the first header line +to make sure the type information becomes part of the header. +The other variables that get transmitted across the network are +made empty, because in this case we do not have an HTML document to +transmit, but rather raw image data to contain in the body. + +Most of the work is done in the second menu choice. It starts with a +strange JavaScript code snippet. When first implementing this server, +we used a short @code{@w{""} here. But then +browsers got smarter and tried to improve on speed by requesting the +image and the HTML code at the same time. When doing this, the browser +tries to build up a connection for the image request while the request for +the HTML text is not yet completed. The browser tries to connect +to the @command{gawk} server on port 8080 while port 8080 is still in use for +transmission of the HTML text. The connection for the image cannot be +built up, so the image appears as ``broken'' in the browser window. +We solved this problem by telling the browser to open a separate window +for the image, but only after a delay of 1000 milliseconds. +By this time, the server should be ready for serving the next request. + +But there is one more subtlety in the JavaScript code. +Each time the JavaScript code opens a window for the image, the +name of the image is appended with a timestamp (@code{systime}). +Why this constant change of name for the image? Initially, we always named +the image @code{Image}, but then the Netscape browser noticed the name +had @emph{not} changed since the previous request and displayed the +previous image (caching behavior). The server core +is implemented so that browsers are told @emph{not} to cache anything. +Obviously HTTP requests do not always work as expected. One way to +circumvent the cache of such overly smart browsers is to change the +name of the image with each request. These three lines of JavaScript +caused us a lot of trouble. + +The rest can be broken +down into two phases. At first, we check if there are statistical +parameters. When the program is first started, there usually are no +parameters because it enters the page coming from the top menu. +Then, we only have to present the user a form that he can use to change +statistical parameters and submit them. Subsequently, the submission of +the form causes the execution of the first phase because @emph{now} +there @emph{are} parameters to handle. + +Now that we have parameters, we know there will be an image available. +Therefore we insert the JavaScript code here to initiate the opening +of the image in a separate window. Then, +we prepare some variables that will be passed to GNUPlot for calculation +of the probabilities. Prior to reading the results, we must temporarily +change @code{RS} because GNUPlot separates lines with newlines. +After instructing GNUPlot to generate a @file{.png} (or @file{.ps} or +@file{.gif}) image, we initiate the insertion of some text, +explaining the resulting probabilities. The final @samp{plot} command +actually generates the image data. This raw binary has to be read in carefully +without adding, changing, or deleting a single byte. Hence the unusual +initialization of @code{Image} and completion with a @code{while} loop. + +When using this server, it soon becomes clear that it is far from being +perfect. It mixes source code of six scripting languages or protocols: + +@itemize @bullet +@item GNU @command{awk} implements a server for the protocol: +@item HTTP which transmits: +@item HTML text which contains a short piece of: +@item JavaScript code opening a separate window. +@item A Bourne shell script is used for piping commands into: +@item GNUPlot to generate the image to be opened. +@end itemize + +After all this work, the GNUPlot image opens in the JavaScript window +where it can be viewed by the user. + +It is probably better not to mix up so many different languages. +The result is not very readable. Furthermore, the +statistical part of the server does not take care of invalid input. +Among others, using negative variances will cause invalid results. + +@node MAZE, MOBAGWHO, STATIST, Some Applications and Techniques +@section MAZE: Walking Through a Maze In Virtual Reality +@cindex MAZE +@cindex VRML +@c VRML in iX 11/96 134. +@quotation +@cindex Perlis, Alan +@i{In the long run, every program becomes rococo, and then rubble.}@* +Alan Perlis +@end quotation + +By now, we know how to present arbitrary @samp{Content-type}s to a browser. +In this @value{SECTION}, our server will present a 3D world to our browser. +The 3D world is described in a scene description language (VRML, +Virtual Reality Modeling Language) that allows us to travel through a +perspective view of a 2D maze with our browser. Browsers with a +VRML plugin enable exploration of this technology. We could do +one of those boring @samp{Hello world} examples here, that are usually +presented when introducing novices to +VRML. If you have never written +any VRML code, have a look at +the VRML FAQ. +Presenting a static VRML scene is a bit trivial; in order to expose +@command{gawk}'s new capabilities, we will present a dynamically generated +VRML scene. The function @code{SetUpServer} is very simple because it +only sets the default HTML page and initializes the random number +generator. As usual, the surrounding server lets you browse the maze. + +@smallexample +@c file eg/network/maze.awk +function SetUpServer() @{ + TopHeader = "Walk through a maze" + TopDoc = "\ +

Please choose one of the following actions:

\ + " + TopFooter = "" + srand() +@} +@c endfile +@end smallexample + +The function @code{HandleGET} is a bit longer because it first computes +the maze and afterwards generates the VRML code that is sent across +the network. As shown in the STATIST example +(@pxref{STATIST}), +we set the type of the +content to VRML and then store the VRML representation of the maze as the +page content. We assume that the maze is stored in a 2D array. Initially, +the maze consists of walls only. Then, we add an entry and an exit to the +maze and let the rest of the work be done by the function @code{MakeMaze}. +Now, only the wall fields are left in the maze. By iterating over the these +fields, we generate one line of VRML code for each wall field. + +@smallexample +@c file eg/network/maze.awk +function HandleGET() @{ + if (MENU[2] == "AboutServer") @{ + Document = "If your browser has a VRML 2 plugin,\ + this server shows you a simple VRML scene." + @} else if (MENU[2] == "VRMLtest") @{ + XSIZE = YSIZE = 11 # initially, everything is wall + for (y = 0; y < YSIZE; y++) + for (x = 0; x < XSIZE; x++) + Maze[x, y] = "#" + delete Maze[0, 1] # entry is not wall + delete Maze[XSIZE-1, YSIZE-2] # exit is not wall + MakeMaze(1, 1) + Document = "\ +#VRML V2.0 utf8\n\ +Group @{\n\ + children [\n\ + PointLight @{\n\ + ambientIntensity 0.2\n\ + color 0.7 0.7 0.7\n\ + location 0.0 8.0 10.0\n\ + @}\n\ + DEF B1 Background @{\n\ + skyColor [0 0 0, 1.0 1.0 1.0 ]\n\ + skyAngle 1.6\n\ + groundColor [1 1 1, 0.8 0.8 0.8, 0.2 0.2 0.2 ]\n\ + groundAngle [ 1.2 1.57 ]\n\ + @}\n\ + DEF Wall Shape @{\n\ + geometry Box @{size 1 1 1@}\n\ + appearance Appearance @{ material Material @{ diffuseColor 0 0 1 @} @}\n\ + @}\n\ + DEF Entry Viewpoint @{\n\ + position 0.5 1.0 5.0\n\ + orientation 0.0 0.0 -1.0 0.52\n\ + @}\n" + for (i in Maze) @{ + split(i, t, SUBSEP) + Document = Document " Transform @{ translation " + Document = Document t[1] " 0 -" t[2] " children USE Wall @}\n" + @} + Document = Document " ] # end of group for world\n@}" + Reason = "OK" ORS "Content-type: model/vrml" + Header = Footer = "" + @} +@} +@c endfile +@end smallexample + +Finally, we have a look at @code{MakeMaze}, the function that generates +the @code{Maze} array. When entered, this function assumes that the array +has been initialized so that each element represents a wall element and +the maze is initially full of wall elements. Only the entrance and the exit +of the maze should have been left free. The parameters of the function tell +us which element must be marked as not being a wall. After this, we take +a look at the four neighboring elements and remember which we have already +treated. Of all the neighboring elements, we take one at random and +walk in that direction. Therefore, the wall element in that direction has +to be removed and then, we call the function recursively for that element. +The maze is only completed if we iterate the above procedure for +@emph{all} neighboring elements (in random order) and for our present +element by recursively calling the function for the present element. This +last iteration could have been done in a loop, +but it is done much simpler recursively. + +Notice that elements with coordinates that are both odd are assumed to be +on our way through the maze and the generating process cannot terminate +as long as there is such an element not being @code{delete}d. All other +elements are potentially part of the wall. + +@smallexample +@c file eg/network/maze.awk +function MakeMaze(x, y) @{ + delete Maze[x, y] # here we are, we have no wall here + p = 0 # count unvisited fields in all directions + if (x-2 SUBSEP y in Maze) d[p++] = "-x" + if (x SUBSEP y-2 in Maze) d[p++] = "-y" + if (x+2 SUBSEP y in Maze) d[p++] = "+x" + if (x SUBSEP y+2 in Maze) d[p++] = "+y" + if (p>0) @{ # if there are unvisited fields, go there + p = int(p*rand()) # choose one unvisited field at random + if (d[p] == "-x") @{ delete Maze[x - 1, y]; MakeMaze(x - 2, y) + @} else if (d[p] == "-y") @{ delete Maze[x, y - 1]; MakeMaze(x, y - 2) + @} else if (d[p] == "+x") @{ delete Maze[x + 1, y]; MakeMaze(x + 2, y) + @} else if (d[p] == "+y") @{ delete Maze[x, y + 1]; MakeMaze(x, y + 2) + @} # we are back from recursion + MakeMaze(x, y); # try again while there are unvisited fields + @} +@} +@c endfile +@end smallexample + +@node MOBAGWHO, STOXPRED, MAZE, Some Applications and Techniques +@section MOBAGWHO: a Simple Mobile Agent +@cindex MOBAGWHO program +@cindex agent +@quotation +@cindex Hoare, C.A.R. +@i{There are two ways of constructing a software design: One way is to +make it so simple that there are obviously no deficiencies, and the +other way is to make it so complicated that there are no obvious +deficiencies.} @* +C. A. R. Hoare +@end quotation + +A @dfn{mobile agent} is a program that can be dispatched from a computer and +transported to a remote server for execution. This is called @dfn{migration}, +which means that a process on another system is started that is independent +from its originator. Ideally, it wanders through +a network while working for its creator or owner. In places like +the UMBC Agent Web, +people are quite confident that (mobile) agents are a software engineering +paradigm that enables us to significantly increase the efficiency +of our work. Mobile agents could become the mediators between users and +the networking world. For an unbiased view at this technology, +see the remarkable paper @cite{Mobile Agents: Are they a good +idea?}.@footnote{@uref{http://www.research.ibm.com/massive/mobag.ps}} + +@ignore +@c Chuck says to take all of this out. +@cindex Tcl/Tk +A good instance of this paradigm is +@cite{Agent Tcl},@footnote{@uref{http://agent.cs.dartmouth.edu/software/agent2.0/}} +an extension of the Tcl language. After introducing a typical +development environment, the aforementioned paper shows a nice little +example application that we will try to rebuild in @command{gawk}. The +@command{who} agent takes a list of servers and wanders from one server +to the next one, always looking to see who is logged in. +Having reached the last +one, it sends back a message with a list of all users it found on each +machine. + +But before implementing something that might or might not be a mobile +agent, let us clarify the concept and some important terms. The agent +paradigm in general is such a young scientific discipline that it has +not yet developed a widely-accepted terminology. Some authors try to +give precise definitions, but their scope is often not wide enough +to be generally accepted. Franklin and Graesser ask +@cite{Is it an Agent or just a Program: A Taxonomy for Autonomous +Agents}@footnote{@uref{http://www.msci.memphis.edu/~franklin/AgentProg.html}} +and give even better answers than Caglayan and Harrison in their +@cite{Agent Sourcebook}.@footnote{@uref{http://www.aminda.com/mazzu/sourcebook/}} + +@itemize @minus +@item +@i{An autonomous agent is a system situated within and a part of +an environment that senses that environment and acts on it, over time, in +pursuit of its own agenda and so as to effect what it senses in the future.} +(Quoted from Franklin and Graesser.) +@item +A mobile agent is able to transport itself from one machine to another. +@item +The term @dfn{migration} often denotes this process of moving. +But neither of the two sources above even mentions this term, while others +use it regularly. +@end itemize + +Before delving into the (rather demanding) details of +implementation, let us give just one more quotation as a final +motivation. Steven Farley published an excellent paper called +@cite{Mobile Agent System Architecture},@footnote{This often +cited text originally appeared as a conference paper here: +@uref{http://www.sigs.com/publications/docs/java/9705/farley.html} +Many bibliographies on the Internet point to this dead link. Meanwhile, +the paper appeared as a contribution to a book called More Java Gems here: +@uref{http://uk.cambridge.org/computerscience/object/catalogue/0521774772/default.htm}} +in which he asks ``Why use an agent architecture?'' + +@quotation +If client-server systems are the currently established norm and distributed +object systems such as CORBA are defining the future standards, why bother +with agents? Agent architectures have certain advantages over these other +types. Three of the most important advantages are: +@cindex CORBA + +@enumerate +@item +An agent performs much processing at the server where local bandwidth +is high, thus reducing the amount of network bandwidth consumed and increasing +overall performance. In contrast, a CORBA client object with the equivalent +functionality of a given agent must make repeated remote method calls to +the server object because CORBA objects cannot move across the network +at runtime. + +@item +An agent operates independently of the application from which the +agent was invoked. The agent operates asynchronously, meaning that the +client application does not need to wait for the results. This is especially +important for mobile users who are not always connected to the network. + +@item +The use of agents allows for the injection of new functionality into +a system at run time. An agent system essentially contains its own automatic +software distribution mechanism. Since CORBA has no built-in support for +mobile code, new functionality generally has to be installed manually. + +@end enumerate + +Of course a non-agent system can exhibit these same features with some +work. But the mobile code paradigm supports the transfer of executable +code to a remote location for asynchronous execution from the start. An +agent architecture should be considered for systems where the above features +are primary requirements. +@end quotation +@end ignore + +When trying to migrate a process from one system to another, +a server process is needed on the receiving side. Depending on the kind +of server process, several ways of implementation come to mind. +How the process is implemented depends upon the kind of server process: + +@itemize @bullet +@item +HTTP can be used as the protocol for delivery of the migrating +process. In this case, we use a common web +server as the receiving server process. A universal CGI script +mediates between migrating process and web server. +Each server willing to accept migrating agents makes this universal +service available. HTTP supplies the @code{POST} method to transfer +some data to a file on the web server. When a CGI script is called +remotely with the @code{POST} method instead of the usual @code{GET} method, +data is transmitted from the client process to the standard input +of the server's CGI script. So, to implement a mobile agent, +we must not only write the agent program to start on the client +side, but also the CGI script to receive the agent on the server side. + +@cindex CGI (Common Gateway Interface) +@cindex apache +@item +The @code{PUT} method can also be used for migration. HTTP does not +require a CGI script for migration via @code{PUT}. However, with common web +servers there is no advantage to this solution, because web servers such as +Apache +require explicit activation of a special @code{PUT} script. + +@item +@cite{Agent Tcl} pursues a different course; it relies on a dedicated server +process with a dedicated protocol specialized for receiving mobile agents. +@end itemize + +Our agent example abuses a common web server as a migration tool. So, it needs a +universal CGI script on the receiving side (the web server). The receiving script is +activated with a @code{POST} request when placed into a location like +@file{/httpd/cgi-bin/PostAgent.sh}. Make sure that the server system uses a +version of @command{gawk} that supports network access (Version 3.1 or later; +verify with @samp{gawk --version}). + +@example +@c file eg/network/PostAgent.sh +#!/bin/sh +MobAg=/tmp/MobileAgent.$$ +# direct script to mobile agent file +cat > $MobAg +# execute agent concurrently +gawk -f $MobAg $MobAg > /dev/null & +# HTTP header, terminator and body +gawk 'BEGIN @{ print "\r\nAgent started" @}' +rm $MobAg # delete script file of agent +@c endfile +@end example + +By making its process id (@code{$$}) part of the unique @value{FN}, the +script avoids conflicts between concurrent instances of the script. +First, all lines +from standard input (the mobile agent's source code) are copied into +this unique file. Then, the agent is started as a concurrent process +and a short message reporting this fact is sent to the submitting client. +Finally, the script file of the mobile agent is removed because it is +no longer needed. Although it is a short script, there are several noteworthy +points: + +@table @asis +@item Security +@emph{There is none}. In fact, the CGI script should never +be made available on a server that is part of the Internet because everyone +would be allowed to execute arbitrary commands with it. This behavior is +acceptable only when performing rapid prototyping. + +@item Self-Reference +Each migrating instance of an agent is started +in a way that enables it to read its own source code from standard input +and use the code for subsequent +migrations. This is necessary because it needs to treat the agent's code +as data to transmit. @command{gawk} is not the ideal language for such +a job. Lisp and Tcl are more suitable because they do not make a distinction +between program code and data. + +@item Independence +After migration, the agent is not linked to its +former home in any way. By reporting @samp{Agent started}, it waves +``Goodbye'' to its origin. The originator may choose to terminate or not. +@end table + +@cindex Lisp +The originating agent itself is started just like any other command-line +script, and reports the results on standard output. By letting the name +of the original host migrate with the agent, the agent that migrates +to a host far away from its origin can report the result back home. +Having arrived at the end of the journey, the agent establishes +a connection and reports the results. This is the reason for +determining the name of the host with @samp{uname -n} and storing it +in @code{MyOrigin} for later use. We may also set variables with the +@option{-v} option from the command line. This interactivity is only +of importance in the context of starting a mobile agent; therefore this +@code{BEGIN} pattern and its action do not take part in migration: + +@smallexample +@c file eg/network/mobag.awk +BEGIN @{ + if (ARGC != 2) @{ + print "MOBAG - a simple mobile agent" + print "CALL:\n gawk -f mobag.awk mobag.awk" + print "IN:\n the name of this script as a command-line parameter" + print "PARAM:\n -v MyOrigin=myhost.com" + print "OUT:\n the result on stdout" + print "JK 29.03.1998 01.04.1998" + exit + @} + if (MyOrigin == "") @{ + "uname -n" | getline MyOrigin + close("uname -n") + @} +@} +@c endfile +@end smallexample + +Since @command{gawk} cannot manipulate and transmit parts of the program +directly, the source code is read and stored in strings. +Therefore, the program scans itself for +the beginning and the ending of functions. +Each line in between is appended to the code string until the end of +the function has been reached. A special case is this part of the program +itself. It is not a function. +Placing a similar framework around it causes it to be treated +like a function. Notice that this mechanism works for all the +functions of the source code, but it cannot guarantee that the order +of the functions is preserved during migration: + +@smallexample +@c file eg/network/mobag.awk +#ReadMySelf +/^function / @{ FUNC = $2 @} +/^END/ || /^#ReadMySelf/ @{ FUNC = $1 @} +FUNC != "" @{ MOBFUN[FUNC] = MOBFUN[FUNC] RS $0 @} +(FUNC != "") && (/^@}/ || /^#EndOfMySelf/) \ + @{ FUNC = "" @} +#EndOfMySelf +@c endfile +@end smallexample + +The web server code in +@ref{Interacting Service, ,A Web Service with Interaction}, +was first developed as a site-independent core. Likewise, the +@command{gawk}-based mobile agent +starts with an agent-independent core, to which can be appended +application-dependent functions. What follows is the only +application-independent function needed for the mobile agent: + +@smallexample +@c file eg/network/mobag.awk +function migrate(Destination, MobCode, Label) @{ + MOBVAR["Label"] = Label + MOBVAR["Destination"] = Destination + RS = ORS = "\r\n" + HttpService = "/inet/tcp/0/" Destination + for (i in MOBFUN) + MobCode = (MobCode "\n" MOBFUN[i]) + MobCode = MobCode "\n\nBEGIN @{" + for (i in MOBVAR) + MobCode = (MobCode "\n MOBVAR[\"" i "\"] = \"" MOBVAR[i] "\"") + MobCode = MobCode "\n@}\n" + print "POST /cgi-bin/PostAgent.sh HTTP/1.0" |& HttpService + print "Content-length:", length(MobCode) ORS |& HttpService + printf "%s", MobCode |& HttpService + while ((HttpService |& getline) > 0) + print $0 + close(HttpService) +@} +@c endfile +@end smallexample + +The @code{migrate} function prepares the +aforementioned strings containing the program code and transmits them to a +server. A consequence of this modular approach is that the @code{migrate} +function takes some parameters that aren't needed in this application, +but that will be in future ones. Its mandatory parameter @code{Destination} holds the +name (or IP address) of the server that the agent wants as a host for its +code. The optional parameter @code{MobCode} may contain some @command{gawk} +code that is inserted during migration in front of all other code. +The optional parameter @code{Label} may contain +a string that tells the agent what to do in program execution after +arrival at its new home site. One of the serious obstacles in implementing +a framework for mobile agents is that it does not suffice to migrate the +code. It is also necessary to migrate the state of execution of the agent. In +contrast to @cite{Agent Tcl}, this program does not try to migrate the complete set +of variables. The following conventions are used: + +@itemize @bullet +@item +Each variable in an agent program is local to the current host and does +@emph{not} migrate. + +@item +The array @code{MOBFUN} shown above is an exception. It is handled +by the function @code{migrate} and does migrate with the application. + +@item +The other exception is the array @code{MOBVAR}. Each variable that +takes part in migration has to be an element of this array. +@code{migrate} also takes care of this. +@end itemize + +Now it's clear what happens to the @code{Label} parameter of the +function @code{migrate}. It is copied into @code{MOBVAR["Label"]} and +travels alongside the other data. Since travelling takes place via HTTP, +records must be separated with @code{"\r\n"} in @code{RS} and +@code{ORS} as usual. The code assembly for migration takes place in +three steps: + +@itemize @bullet +@item +Iterate over @code{MOBFUN} to collect all functions verbatim. + +@item +Prepare a @code{BEGIN} pattern and put assignments to mobile +variables into the action part. + +@item +Transmission itself resembles GETURL: the header with the request +and the @code{Content-length} is followed by the body. In case there is +any reply over the network, it is read completely and echoed to +standard output to avoid irritating the server. +@end itemize + +The application-independent framework is now almost complete. What follows +is the @code{END} pattern that is executed when the mobile agent has +finished reading its own code. First, it checks whether it is already +running on a remote host or not. In case initialization has not yet taken +place, it starts @code{MyInit}. Otherwise (later, on a remote host), it +starts @code{MyJob}: + +@smallexample +@c file eg/network/mobag.awk +END @{ + if (ARGC != 2) exit # stop when called with wrong parameters + if (MyOrigin != "") # is this the originating host? + MyInit() # if so, initialize the application + else # we are on a host with migrated data + MyJob() # so we do our job +@} +@c endfile +@end smallexample + +All that's left to extend the framework into a complete application +is to write two application-specific functions: @code{MyInit} and +@code{MyJob}. Keep in mind that the former is executed once on the +originating host, while the latter is executed after each migration: + +@smallexample +@c file eg/network/mobag.awk +function MyInit() @{ + MOBVAR["MyOrigin"] = MyOrigin + MOBVAR["Machines"] = "localhost/80 max/80 moritz/80 castor/80" + split(MOBVAR["Machines"], Machines) # which host is the first? + migrate(Machines[1], "", "") # go to the first host + while (("/inet/tcp/8080/0/0" |& getline) > 0) # wait for result + print $0 # print result + close("/inet/tcp/8080/0/0") +@} +@c endfile +@end smallexample + +As mentioned earlier, this agent takes the name of its origin +(@code{MyOrigin}) with it. Then, it takes the name of its first +destination and goes there for further work. Notice that this name has +the port number of the web server appended to the name of the server, +because the function @code{migrate} needs it this way to create +the @code{HttpService} variable. Finally, it waits for the result to arrive. +The @code{MyJob} function runs on the remote host: + +@smallexample +@c file eg/network/mobag.awk +function MyJob() @{ + # forget this host + sub(MOBVAR["Destination"], "", MOBVAR["Machines"]) + MOBVAR["Result"]=MOBVAR["Result"] SUBSEP SUBSEP MOBVAR["Destination"] ":" + while (("who" | getline) > 0) # who is logged in? + MOBVAR["Result"] = MOBVAR["Result"] SUBSEP $0 + close("who") + if (index(MOBVAR["Machines"], "/") > 0) @{ # any more machines to visit? + split(MOBVAR["Machines"], Machines) # which host is next? + migrate(Machines[1], "", "") # go there + @} else @{ # no more machines + gsub(SUBSEP, "\n", MOBVAR["Result"]) # send result to origin + print MOBVAR["Result"] |& "/inet/tcp/0/" MOBVAR["MyOrigin"] "/8080" + close("/inet/tcp/0/" MOBVAR["MyOrigin"] "/8080") + @} +@} +@c endfile +@end smallexample + +After migrating, the first thing to do in @code{MyJob} is to delete +the name of the current host from the list of hosts to visit. Now, it +is time to start the real work by appending the host's name to the +result string, and reading line by line who is logged in on this host. +A very annoying circumstance is the fact that the elements of +@code{MOBVAR} cannot hold the newline character (@code{"\n"}). If they +did, migration of this string did not work because the string didn't +obey the syntax rule for a string in @command{gawk}. +@code{SUBSEP} is used as a temporary replacement. +If the list of hosts to visit holds +at least one more entry, the agent migrates to that place to go on +working there. Otherwise, we replace the @code{SUBSEP}s +with a newline character in the resulting string, and report it to +the originating host, whose name is stored in @code{MOBVAR["MyOrigin"]}. + +@node STOXPRED, PROTBASE, MOBAGWHO, Some Applications and Techniques +@section STOXPRED: Stock Market Prediction As A Service +@cindex STOXPRED program +@cindex Yahoo! +@quotation +@i{Far out in the uncharted backwaters of the unfashionable end of +the Western Spiral arm of the Galaxy lies a small unregarded yellow sun.} + +@i{Orbiting this at a distance of roughly ninety-two million miles is an +utterly insignificant little blue-green planet whose ape-descendent life +forms are so amazingly primitive that they still think digital watches are +a pretty neat idea.} + +@i{This planet has --- or rather had --- a problem, which was this: +most of the people living on it were unhappy for pretty much of the time. +Many solutions were suggested for this problem, but most of these were +largely concerned with the movements of small green pieces of paper, +which is odd because it wasn't the small green pieces of paper that +were unhappy.} @* +Douglas Adams, @cite{The Hitch Hiker's Guide to the Galaxy} +@end quotation + +@cindex @command{cron} utility +Valuable services on the Internet are usually @emph{not} implemented +as mobile agents. There are much simpler ways of implementing services. +All Unix systems provide, for example, the @command{cron} service. +Unix system users can write a list of tasks to be done each day, each +week, twice a day, or just once. The list is entered into a file named +@file{crontab}. For example, to distribute a newsletter on a daily +basis this way, use @command{cron} for calling a script each day early +in the morning. + +@example +# run at 8 am on weekdays, distribute the newsletter +0 8 * * 1-5 $HOME/bin/daily.job >> $HOME/log/newsletter 2>&1 +@end example + +The script first looks for interesting information on the Internet, +assembles it in a nice form and sends the results via email to +the customers. + +The following is an example of a primitive +newsletter on stock market prediction. It is a report which first +tries to predict the change of each share in the Dow Jones Industrial +Index for the particular day. Then it mentions some especially +promising shares as well as some shares which look remarkably bad +on that day. The report ends with the usual disclaimer which tells +every child @emph{not} to try this at home and hurt anybody. +@cindex Dow Jones Industrial Index + +@smallexample +Good morning Uncle Scrooge, + +This is your daily stock market report for Monday, October 16, 2000. +Here are the predictions for today: + + AA neutral + GE up + JNJ down + MSFT neutral + @dots{} + UTX up + DD down + IBM up + MO down + WMT up + DIS up + INTC up + MRK down + XOM down + EK down + IP down + +The most promising shares for today are these: + + INTC http://biz.yahoo.com/n/i/intc.html + +The stock shares to avoid today are these: + + EK http://biz.yahoo.com/n/e/ek.html + IP http://biz.yahoo.com/n/i/ip.html + DD http://biz.yahoo.com/n/d/dd.html + @dots{} +@end smallexample + +@ignore +@c Chuck suggests removing this paragraph +If you are not into stock market prediction but want to earn money +with a more humane service, you might prefer to send out horoscopes +to your customers. Or, once every refrigerator in every household on this side +of the Chinese Wall is connected to the Internet, such a service could +inspect the contents of your customer's refrigerators each day and +advise them on nutrition. Big Brother is watching them. +@end ignore + +The script as a whole is rather long. In order to ease the pain of +studying other people's source code, we have broken the script +up into meaningful parts which are invoked one after the other. +The basic structure of the script is as follows: + +@example +@c file eg/network/stoxpred.awk +BEGIN @{ + Init() + ReadQuotes() + CleanUp() + Prediction() + Report() + SendMail() +@} +@c endfile +@end example + +The earlier parts store data into variables and arrays which are +subsequently used by later parts of the script. The @code{Init} function +first checks if the script is invoked correctly (without any parameters). +If not, it informs the user of the correct usage. What follows are preparations +for the retrieval of the historical quote data. The names of the 30 stock +shares are stored in an array @code{name} along with the current date +in @code{day}, @code{month}, and @code{year}. + +All users who are separated +from the Internet by a firewall and have to direct their Internet accesses +to a proxy must supply the name of the proxy to this script with the +@samp{-v Proxy=@var{name}} option. For most users, the default proxy and +port number should suffice. + +@example +@c file eg/network/stoxpred.awk +function Init() @{ + if (ARGC != 1) @{ + print "STOXPRED - daily stock share prediction" + print "IN:\n no parameters, nothing on stdin" + print "PARAM:\n -v Proxy=MyProxy -v ProxyPort=80" + print "OUT:\n commented predictions as email" + print "JK 09.10.2000" + exit + @} + # Remember ticker symbols from Dow Jones Industrial Index + StockCount = split("AA GE JNJ MSFT AXP GM JPM PG BA HD KO \ + SBC C HON MCD T CAT HWP MMM UTX DD IBM MO WMT DIS INTC \ + MRK XOM EK IP", name); + # Remember the current date as the end of the time series + day = strftime("%d") + month = strftime("%m") + year = strftime("%Y") + if (Proxy == "") Proxy = "chart.yahoo.com" + if (ProxyPort == 0) ProxyPort = 80 + YahooData = "/inet/tcp/0/" Proxy "/" ProxyPort +@} +@c endfile +@end example + +@cindex CSV format +There are two really interesting parts in the script. One is the +function which reads the historical stock quotes from an Internet +server. The other is the one that does the actual prediction. In +the following function we see how the quotes are read from the +Yahoo server. The data which comes from the server is in +CSV format (comma-separated values): + +@example +@c file eg/network/stoxdata.txt +Date,Open,High,Low,Close,Volume +9-Oct-00,22.75,22.75,21.375,22.375,7888500 +6-Oct-00,23.8125,24.9375,21.5625,22,10701100 +5-Oct-00,24.4375,24.625,23.125,23.50,5810300 +@c endfile +@end example + +Lines contain values of the same time instant, whereas columns are +separated by commas and contain the kind of data that is described +in the header (first) line. At first, @command{gawk} is instructed to +separate columns by commas (@samp{FS = ","}). In the loop that follows, +a connection to the Yahoo server is first opened, then a download takes +place, and finally the connection is closed. All this happens once for +each ticker symbol. In the body of this loop, an Internet address is +built up as a string according to the rules of the Yahoo server. The +starting and ending date are chosen to be exactly the same, but one year +apart in the past. All the action is initiated within the @code{printf} +command which transmits the request for data to the Yahoo server. + +In the inner loop, the server's data is first read and then scanned +line by line. Only lines which have six columns and the name of a month +in the first column contain relevant data. This data is stored +in the two-dimensional array @code{quote}; one dimension +being time, the other being the ticker symbol. During retrieval of the +first stock's data, the calendar names of the time instances are stored +in the array @code{day} because we need them later. + +@smallexample +@c file eg/network/stoxpred.awk +function ReadQuotes() @{ + # Retrieve historical data for each ticker symbol + FS = "," + for (stock = 1; stock <= StockCount; stock++) @{ + URL = "http://chart.yahoo.com/table.csv?s=" name[stock] \ + "&a=" month "&b=" day "&c=" year-1 \ + "&d=" month "&e=" day "&f=" year \ + "g=d&q=q&y=0&z=" name[stock] "&x=.csv" + printf("GET " URL " HTTP/1.0\r\n\r\n") |& YahooData + while ((YahooData |& getline) > 0) @{ + if (NF == 6 && $1 ~ /Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec/) @{ + if (stock == 1) + days[++daycount] = $1; + quote[$1, stock] = $5 + @} + @} + close(YahooData) + @} + FS = " " +@} +@c endfile +@end smallexample + +Now that we @emph{have} the data, it can be checked once again to make sure +that no individual stock is missing or invalid, and that all the stock quotes are +aligned correctly. Furthermore, we renumber the time instances. The +most recent day gets day number 1 and all other days get consecutive +numbers. All quotes are rounded toward the nearest whole number in US Dollars. + +@smallexample +@c file eg/network/stoxpred.awk +function CleanUp() @{ + # clean up time series; eliminate incomplete data sets + for (d = 1; d <= daycount; d++) @{ + for (stock = 1; stock <= StockCount; stock++) + if (! ((days[d], stock) in quote)) + stock = StockCount + 10 + if (stock > StockCount + 1) + continue + datacount++ + for (stock = 1; stock <= StockCount; stock++) + data[datacount, stock] = int(0.5 + quote[days[d], stock]) + @} + delete quote + delete days +@} +@c endfile +@end smallexample + +Now we have arrived at the second really interesting part of the whole affair. +What we present here is a very primitive prediction algorithm: +@emph{If a stock fell yesterday, assume it will also fall today; if +it rose yesterday, assume it will rise today}. (Feel free to replace this +algorithm with a smarter one.) If a stock changed in the same direction +on two consecutive days, this is an indication which should be highlighted. +Two-day advances are stored in @code{hot} and two-day declines in +@code{avoid}. + +The rest of the function is a sanity check. It counts the number of +correct predictions in relation to the total number of predictions +one could have made in the year before. + +@smallexample +@c file eg/network/stoxpred.awk +function Prediction() @{ + # Predict each ticker symbol by prolonging yesterday's trend + for (stock = 1; stock <= StockCount; stock++) @{ + if (data[1, stock] > data[2, stock]) @{ + predict[stock] = "up" + @} else if (data[1, stock] < data[2, stock]) @{ + predict[stock] = "down" + @} else @{ + predict[stock] = "neutral" + @} + if ((data[1, stock] > data[2, stock]) && (data[2, stock] > data[3, stock])) + hot[stock] = 1 + if ((data[1, stock] < data[2, stock]) && (data[2, stock] < data[3, stock])) + avoid[stock] = 1 + @} + # Do a plausibility check: how many predictions proved correct? + for (s = 1; s <= StockCount; s++) @{ + for (d = 1; d <= datacount-2; d++) @{ + if (data[d+1, s] > data[d+2, s]) @{ + UpCount++ + @} else if (data[d+1, s] < data[d+2, s]) @{ + DownCount++ + @} else @{ + NeutralCount++ + @} + if (((data[d, s] > data[d+1, s]) && (data[d+1, s] > data[d+2, s])) || + ((data[d, s] < data[d+1, s]) && (data[d+1, s] < data[d+2, s])) || + ((data[d, s] == data[d+1, s]) && (data[d+1, s] == data[d+2, s]))) + CorrectCount++ + @} + @} +@} +@c endfile +@end smallexample + +At this point the hard work has been done: the array @code{predict} +contains the predictions for all the ticker symbols. It is up to the +function @code{Report} to find some nice words to introduce the +desired information. + +@smallexample +@c file eg/network/stoxpred.awk +function Report() @{ + # Generate report + report = "\nThis is your daily " + report = report "stock market report for "strftime("%A, %B %d, %Y")".\n" + report = report "Here are the predictions for today:\n\n" + for (stock = 1; stock <= StockCount; stock++) + report = report "\t" name[stock] "\t" predict[stock] "\n" + for (stock in hot) @{ + if (HotCount++ == 0) + report = report "\nThe most promising shares for today are these:\n\n" + report = report "\t" name[stock] "\t\thttp://biz.yahoo.com/n/" \ + tolower(substr(name[stock], 1, 1)) "/" tolower(name[stock]) ".html\n" + @} + for (stock in avoid) @{ + if (AvoidCount++ == 0) + report = report "\nThe stock shares to avoid today are these:\n\n" + report = report "\t" name[stock] "\t\thttp://biz.yahoo.com/n/" \ + tolower(substr(name[stock], 1, 1)) "/" tolower(name[stock]) ".html\n" + @} + report = report "\nThis sums up to " HotCount+0 " winners and " AvoidCount+0 + report = report " losers. When using this kind\nof prediction scheme for" + report = report " the 12 months which lie behind us,\nwe get " UpCount + report = report " 'ups' and " DownCount " 'downs' and " NeutralCount + report = report " 'neutrals'. Of all\nthese " UpCount+DownCount+NeutralCount + report = report " predictions " CorrectCount " proved correct next day.\n" + report = report "A success rate of "\ + int(100*CorrectCount/(UpCount+DownCount+NeutralCount)) "%.\n" + report = report "Random choice would have produced a 33% success rate.\n" + report = report "Disclaimer: Like every other prediction of the stock\n" + report = report "market, this report is, of course, complete nonsense.\n" + report = report "If you are stupid enough to believe these predictions\n" + report = report "you should visit a doctor who can treat your ailment." +@} +@c endfile +@end smallexample + +The function @code{SendMail} goes through the list of customers and opens +a pipe to the @code{mail} command for each of them. Each one receives an +email message with a proper subject heading and is addressed with his full name. + +@smallexample +@c file eg/network/stoxpred.awk +function SendMail() @{ + # send report to customers + customer["uncle.scrooge@@ducktown.gov"] = "Uncle Scrooge" + customer["more@@utopia.org" ] = "Sir Thomas More" + customer["spinoza@@denhaag.nl" ] = "Baruch de Spinoza" + customer["marx@@highgate.uk" ] = "Karl Marx" + customer["keynes@@the.long.run" ] = "John Maynard Keynes" + customer["bierce@@devil.hell.org" ] = "Ambrose Bierce" + customer["laplace@@paris.fr" ] = "Pierre Simon de Laplace" + for (c in customer) @{ + MailPipe = "mail -s 'Daily Stock Prediction Newsletter'" c + print "Good morning " customer[c] "," | MailPipe + print report "\n.\n" | MailPipe + close(MailPipe) + @} +@} +@c endfile +@end smallexample + +Be patient when running the script by hand. +Retrieving the data for all the ticker symbols and sending the emails +may take several minutes to complete, depending upon network traffic +and the speed of the available Internet link. +The quality of the prediction algorithm is likely to be disappointing. +Try to find a better one. +Should you find one with a success rate of more than 50%, please tell +us about it! It is only for the sake of curiosity, of course. @code{:-)} + +@ignore +@c chuck says to remove this +Let us give you one final indication as to what one can expect from +a prediction of stock data, which is sometimes said to contain much +randomness. One theory says that all relevant information to be taken +into account when estimating the price of a stock is contained in the +stock quotes. Every bit of useful information has influenced the +fair price. Therefore (the theory says) temporary changes (i.e., fluctuations +within a minute) have to be purely random. But what is the cause of +short-term changes in stock prices? + +Stock prices are fixed when supply and demand meet each other. +What people are willing to pay reflects human expectations. +Human expectations are not necessarily random. On the Internet, +you can find an elucidating paper about predictability and human +expectations: +@uref{http://it.ucsd.edu/IT/Newsletter/archives/meir/05meir.html, +@cite{Reflections on ``Universal Prediction of Individual Sequences''}} +The authors (Feder, Merhav, Gutman) introduce the reader to the subject +by telling a thrilling anecdote. +@cindex Shannon, Claude +@quotation +In the early 50's, at Bell Laboratories, David Hagelbarger built a +simple ``mind reading'' machine, whose purpose was to play the ``penny +matching'' game. In this game, a player chooses head or tail, while a +``mind reading'' machine tries to predict and match his choice. +Surprisingly, as Robert Lucky tells in his book ``Silicon Dreams'', +Hagelbarger's simple, 8-state machine, was able to match the ``pennies'' +of its human opponent 5,218 times over the course of 9,795 plays. +Random guessing would lead to such a high success rate with a probability +less than one out of 10 billion! Shannon, who was interested in prediction, +information, and thinking machines, closely followed Hagelbarger's +machine, and eventually built his own stripped-down version of the machine, +having the same states, but one that used a simpler strategy at each state. +As the legend goes, in a duel between the two machines, Shannon's machine +won by a slight margin! No one knows if this was due to a superior algorithm +or just a chance happening associated with the specific sequence at that game. +In any event, the success of both these machines against ``untrained'' human +opponents was explained by the fact that the human opponents cannot draw +completely random +bits. +@end quotation +@end ignore + +@node PROTBASE, , STOXPRED, Some Applications and Techniques +@section PROTBASE: Searching Through A Protein Database +@cindex PROTBASE +@cindex NCBI, National Center for Biotechnology Information +@cindex BLAST, Basic Local Alignment Search Tool +@cindex Hoare, C.A.R. +@quotation +@i{Hoare's Law of Large Problems: Inside every large problem is a small + problem struggling to get out.} +@end quotation + +Yahoo's database of stock market data is just one among the many large +databases on the Internet. Another one is located at NCBI +(National Center for Biotechnology +Information). Established in 1988 as a national resource for molecular +biology information, NCBI creates public databases, conducts research +in computational biology, develops software tools for analyzing genome +data, and disseminates biomedical information. In this section, we +look at one of NCBI's public services, which is called BLAST +(Basic Local Alignment Search Tool). + +You probably know that the information necessary for reproducing living +cells is encoded in the genetic material of the cells. The genetic material +is a very long chain of four base nucleotides. It is the order of +appearance (the sequence) of nucleotides which contains the information +about the substance to be produced. Scientists in biotechnology often +find a specific fragment, determine the nucleotide sequence, and need +to know where the sequence at hand comes from. This is where the large +databases enter the game. At NCBI, databases store the knowledge +about which sequences have ever been found and where they have been found. +When the scientist sends his sequence to the BLAST service, the server +looks for regions of genetic material in its database which +look the most similar to the delivered nucleotide sequence. After a +search time of some seconds or minutes the server sends an answer to +the scientist. In order to make access simple, NCBI chose to offer +their database service through popular Internet protocols. There are +four basic ways to use the so-called BLAST services: + +@itemize @bullet +@item +The easiest way to use BLAST is through the web. Users may simply point +their browsers at the NCBI home page +and link to the BLAST pages. +NCBI provides a stable URL that may be used to perform BLAST searches +without interactive use of a web browser. This is what we will do later +in this section. +A demonstration client +and a @file{README} file demonstrate how to access this URL. + +@item +Currently, +@command{blastcl3} is the standard network BLAST client. +You can download @command{blastcl3} from the +anonymous FTP location. + +@item +BLAST 2.0 can be run locally as a full executable and can be used to run +BLAST searches against private local databases, or downloaded copies of the +NCBI databases. BLAST 2.0 executables may be found on the NCBI +anonymous FTP server. + +@item +The NCBI BLAST Email server is the best option for people without convenient +access to the web. A similarity search can be performed by sending a properly +formatted mail message containing the nucleotide or protein query sequence to +@email{blast@@ncbi.nlm.nih.gov}. The query sequence is compared against the +specified database using the BLAST algorithm and the results are returned in +an email message. For more information on formulating email BLAST searches, +you can send a message consisting of the word ``HELP'' to the same address, +@email{blast@@ncbi.nlm.nih.gov}. +@end itemize + +Our starting point is the demonstration client mentioned in the first option. +The @file{README} file that comes along with the client explains the whole +process in a nutshell. In the rest of this section, we first show +what such requests look like. Then we show how to use @command{gawk} to +implement a client in about 10 lines of code. Finally, we show how to +interpret the result returned from the service. + +Sequences are expected to be represented in the standard +IUB/IUPAC amino acid and nucleic acid codes, +with these exceptions: lower-case letters are accepted and are mapped +into upper-case; a single hyphen or dash can be used to represent a gap +of indeterminate length; and in amino acid sequences, @samp{U} and @samp{*} +are acceptable letters (see below). Before submitting a request, any numerical +digits in the query sequence should either be removed or replaced by +appropriate letter codes (e.g., @samp{N} for unknown nucleic acid residue +or @samp{X} for unknown amino acid residue). +The nucleic acid codes supported are: + +@example +A --> adenosine M --> A C (amino) +C --> cytidine S --> G C (strong) +G --> guanine W --> A T (weak) +T --> thymidine B --> G T C +U --> uridine D --> G A T +R --> G A (purine) H --> A C T +Y --> T C (pyrimidine) V --> G C A +K --> G T (keto) N --> A G C T (any) + - gap of indeterminate length +@end example + +Now you know the alphabet of nucleotide sequences. The last two lines +of the following example query show you such a sequence, which is obviously +made up only of elements of the alphabet just described. Store this example +query into a file named @file{protbase.request}. You are now ready to send +it to the server with the demonstration client. + +@example +@c file eg/network/protbase.request +PROGRAM blastn +DATALIB month +EXPECT 0.75 +BEGIN +>GAWK310 the gawking gene GNU AWK +tgcttggctgaggagccataggacgagagcttcctggtgaagtgtgtttcttgaaatcat +caccaccatggacagcaaa +@c endfile +@end example + +@cindex FASTA/Pearson format +The actual search request begins with the mandatory parameter @samp{PROGRAM} +in the first column followed by the value @samp{blastn} (the name of the +program) for searching nucleic acids. The next line contains the mandatory +search parameter @samp{DATALIB} with the value @samp{month} for the newest +nucleic acid sequences. The third line contains an optional @samp{EXPECT} +parameter and the value desired for it. The fourth line contains the +mandatory @samp{BEGIN} directive, followed by the query sequence in +FASTA/Pearson format. +Each line of information must be less than 80 characters in length. + +The ``month'' database contains all new or revised sequences released in the +last 30 days and is useful for searching against new sequences. +There are five different blast programs, @command{blastn} being the one that +compares a nucleotide query sequence against a nucleotide sequence database. + +The last server directive that must appear in every request is the +@samp{BEGIN} directive. The query sequence should immediately follow the +@samp{BEGIN} directive and must appear in FASTA/Pearson format. +A sequence in +FASTA/Pearson format begins with a single-line description. +The description line, which is required, is distinguished from the lines of +sequence data that follow it by having a greater-than (@samp{>}) symbol +in the first column. For the purposes of the BLAST server, the text of +the description is arbitrary. + +If you prefer to use a client written in @command{gawk}, just store the following +10 lines of code into a file named @file{protbase.awk} and use this client +instead. Invoke it with @samp{gawk -f protbase.awk protbase.request}. +Then wait a minute and watch the result coming in. In order to replicate +the demonstration client's behavior as closely as possible, this client +does not use a proxy server. We could also have extended the client program +in @ref{GETURL, ,Retrieving Web Pages}, to implement the client request from +@file{protbase.awk} as a special case. + +@smallexample +@c file eg/network/protbase.awk +@{ request = request "\n" $0 @} + +END @{ + BLASTService = "/inet/tcp/0/www.ncbi.nlm.nih.gov/80" + printf "POST /cgi-bin/BLAST/nph-blast_report HTTP/1.0\n" |& BLASTService + printf "Content-Length: " length(request) "\n\n" |& BLASTService + printf request |& BLASTService + while ((BLASTService |& getline) > 0) + print $0 + close(BLASTService) +@} +@c endfile +@end smallexample + +The demonstration client from NCBI is 214 lines long (written in C) and +it is not immediately obvious what it does. Our client is so short that +it @emph{is} obvious what it does. First it loops over all lines of the +query and stores the whole query into a variable. Then the script +establishes an Internet connection to the NCBI server and transmits the +query by framing it with a proper HTTP request. Finally it receives +and prints the complete result coming from the server. + +Now, let us look at the result. It begins with an HTTP header, which you +can ignore. Then there are some comments about the query having been +filtered to avoid spuriously high scores. After this, there is a reference +to the paper that describes the software being used for searching the data +base. After a repetition of the original query's description we find the +list of significant alignments: + +@smallexample +@c file eg/network/protbase.result +Sequences producing significant alignments: (bits) Value + +gb|AC021182.14|AC021182 Homo sapiens chromosome 7 clone RP11-733... 38 0.20 +gb|AC021056.12|AC021056 Homo sapiens chromosome 3 clone RP11-115... 38 0.20 +emb|AL160278.10|AL160278 Homo sapiens chromosome 9 clone RP11-57... 38 0.20 +emb|AL391139.11|AL391139 Homo sapiens chromosome X clone RP11-35... 38 0.20 +emb|AL365192.6|AL365192 Homo sapiens chromosome 6 clone RP3-421H... 38 0.20 +emb|AL138812.9|AL138812 Homo sapiens chromosome 11 clone RP1-276... 38 0.20 +gb|AC073881.3|AC073881 Homo sapiens chromosome 15 clone CTD-2169... 38 0.20 +@c endfile +@end smallexample + +This means that the query sequence was found in seven human chromosomes. +But the value 0.20 (20%) means that the probability of an accidental match +is rather high (20%) in all cases and should be taken into account. +You may wonder what the first column means. It is a key to the specific +database in which this occurrence was found. The unique sequence identifiers +reported in the search results can be used as sequence retrieval keys +via the NCBI server. The syntax of sequence header lines used by the NCBI +BLAST server depends on the database from which each sequence was obtained. +The table below lists the identifiers for the databases from which the +sequences were derived. + +@ifinfo +@example +Database Name Identifier Syntax +============================ ======================== +GenBank gb|accession|locus +EMBL Data Library emb|accession|locus +DDBJ, DNA Database of Japan dbj|accession|locus +NBRF PIR pir||entry +Protein Research Foundation prf||name +SWISS-PROT sp|accession|entry name +Brookhaven Protein Data Bank pdb|entry|chain +Kabat's Sequences of Immuno@dots{} gnl|kabat|identifier +Patents pat|country|number +GenInfo Backbone Id bbs|number +@end example +@end ifinfo + +@ifnotinfo +@multitable {Kabat's Sequences of Immuno@dots{}} {@code{@w{sp|accession|entry name}}} +@item GenBank @tab @code{gb|accession|locus} +@item EMBL Data Library @tab @code{emb|accession|locus} +@item DDBJ, DNA Database of Japan @tab @code{dbj|accession|locus} +@item NBRF PIR @tab @code{pir||entry} +@item Protein Research Foundation @tab @code{prf||name} +@item SWISS-PROT @tab @code{@w{sp|accession|entry name}} +@item Brookhaven Protein Data Bank @tab @code{pdb|entry|chain} +@item Kabat's Sequences of Immuno@dots{} @tab @code{gnl|kabat|identifier} +@item Patents @tab @code{pat|country|number} +@item GenInfo Backbone Id @tab @code{bbs|number} +@end multitable +@end ifnotinfo + + +For example, an identifier might be @samp{gb|AC021182.14|AC021182}, where the +@samp{gb} tag indicates that the identifier refers to a GenBank sequence, +@samp{AC021182.14} is its GenBank ACCESSION, and @samp{AC021182} is the GenBank LOCUS. +The identifier contains no spaces, so that a space indicates the end of the +identifier. + +Let us continue in the result listing. Each of the seven alignments mentioned +above is subsequently described in detail. We will have a closer look at +the first of them. + +@smallexample +>gb|AC021182.14|AC021182 Homo sapiens chromosome 7 clone RP11-733N23, WORKING DRAFT SEQUENCE, 4 + unordered pieces + Length = 176383 + + Score = 38.2 bits (19), Expect = 0.20 + Identities = 19/19 (100%) + Strand = Plus / Plus + +Query: 35 tggtgaagtgtgtttcttg 53 + ||||||||||||||||||| +Sbjct: 69786 tggtgaagtgtgtttcttg 69804 +@end smallexample + +This alignment was located on the human chromosome 7. The fragment on which +part of the query was found had a total length of 176383. Only 19 of the +nucleotides matched and the matching sequence ran from character 35 to 53 +in the query sequence and from 69786 to 69804 in the fragment on chromosome 7. +If you are still reading at this point, you are probably interested in finding +out more about Computational Biology and you might appreciate the following +hints. + +@cindex Computational Biology +@cindex Bioinformatics +@enumerate +@item +There is a book called @cite{Introduction to Computational Biology} +by Michael S. Waterman, which is worth reading if you are seriously +interested. You can find a good +book review +on the Internet. + +@item +While Waterman's book can explain to you the algorithms employed internally +in the database search engines, most practitioners prefer to approach +the subject differently. The applied side of Computational Biology is +called Bioinformatics, and emphasizes the tools available for day-to-day +work as well as how to actually @emph{use} them. One of the very few affordable +books on Bioinformatics is +@cite{Developing Bioinformatics Computer Skills}. + +@item +The sequences @emph{gawk} and @emph{gnuawk} are in widespread use in +the genetic material of virtually every earthly living being. Let us +take this as a clear indication that the divine creator has intended +@code{gawk} to prevail over other scripting languages such as @code{perl}, +@code{tcl}, or @code{python} which are not even proper sequences. (:-) +@end enumerate + +@node Links, GNU Free Documentation License, Some Applications and Techniques, Top +@chapter Related Links + +This section lists the URLs for various items discussed in this @value{CHAPTER}. +They are presented in the order in which they appear. + +@table @asis + +@item @cite{Internet Programming with Python} +@uref{http://www.fsbassociates.com/books/python.htm} + +@item @cite{Advanced Perl Programming} +@uref{http://www.oreilly.com/catalog/advperl} + +@item @cite{Web Client Programming with Perl} +@uref{http://www.oreilly.com/catalog/webclient} + +@item Richard Stevens's home page and book +@uref{http://www.kohala.com/~rstevens} + +@item The SPAK home page +@uref{http://www.userfriendly.net/linux/RPM/contrib/libc6/i386/spak-0.6b-1.i386.html} + +@item Volume III of @cite{Internetworking with TCP/IP}, by Comer and Stevens +@uref{http://www.cs.purdue.edu/homes/dec/tcpip3s.cont.html} + +@item XBM Graphics File Format +@uref{http://www.wotsit.org/download.asp?f=xbm} + +@item GNUPlot +@uref{http://www.cs.dartmouth.edu/gnuplot_info.html} + +@item Mark Humphrys' Eliza page +@uref{http://www.compapp.dcu.ie/~humphrys/eliza.html} + +@item Yahoo! Eliza Information +@uref{http://dir.yahoo.com/Recreation/Games/Computer_Games/Internet_Games/Web_Games/Artificial_Intelligence} + +@item Java versions of Eliza +@uref{http://www.tjhsst.edu/Psych/ch1/eliza.html} + +@item Java versions of Eliza with source code +@uref{http://home.adelphia.net/~lifeisgood/eliza/eliza.htm} + +@item Eliza Programs with Explanations +@uref{http://chayden.net/chayden/eliza/Eliza.shtml} + +@item Loebner Contest +@uref{http://acm.org/~loebner/loebner-prize.htmlx} + +@item Tck/Tk Information +@uref{http://www.scriptics.com/} + +@item Intel 80x86 Processors +@uref{http://developer.intel.com/design/platform/embedpc/what_is.htm} + +@item AMD Elan Processors +@uref{http://www.amd.com/products/epd/processors/4.32bitcont/32bitcont/index.html} + +@item XINU +@uref{http://willow.canberra.edu.au/~chrisc/xinu.html } + +@item GNU/Linux +@uref{http://uclinux.lineo.com/} + +@item Embedded PCs +@uref{http://dir.yahoo.com/Business_and_Economy/Business_to_Business/Computers/Hardware/Embedded_Control/} + +@item MiniSQL +@uref{http://www.hughes.com.au/library/} + +@item Market Share Surveys +@uref{http://www.netcraft.com/survey} + +@item @cite{Numerical Recipes in C: The Art of Scientific Computing} +@uref{http://www.nr.com} + +@item VRML +@uref{http://www.vrml.org} + +@item The VRML FAQ +@uref{http://www.vrml.org/technicalinfo/specifications/specifications.htm#FAQ} + +@item The UMBC Agent Web +@uref{http://www.cs.umbc.edu/agents } + +@item Apache Web Server +@uref{http://www.apache.org} + +@item National Center for Biotechnology Information (NCBI) +@uref{http://www.ncbi.nlm.nih.gov} + +@item Basic Local Alignment Search Tool (BLAST) +@uref{http://www.ncbi.nlm.nih.gov/BLAST/blast_overview.html} + +@item NCBI Home Page +@uref{http://www.ncbi.nlm.nih.gov} + +@item BLAST Pages +@uref{http://www.ncbi.nlm.nih.gov/BLAST} + +@item BLAST Demonstration Client +@uref{ftp://ncbi.nlm.nih.gov/blast/blasturl/} + +@item BLAST anonymous FTP location +@uref{ftp://ncbi.nlm.nih.gov/blast/network/netblast/} + +@item BLAST 2.0 Executables +@uref{ftp://ncbi.nlm.nih.gov/blast/executables/} + +@item IUB/IUPAC Amino Acid and Nucleic Acid Codes +@uref{http://www.uthscsa.edu/geninfo/blastmail.html#item6} + +@item FASTA/Pearson Format +@uref{http://www.ncbi.nlm.nih.gov/BLAST/fasta.html} + +@item Fasta/Pearson Sequence in Java +@uref{http://www.kazusa.or.jp/java/codon_table_java/} + +@item Book Review of @cite{Introduction to Computational Biology} +@uref{http://www.acm.org/crossroads/xrds5-1/introcb.html} + +@item @cite{Developing Bioinformatics Computer Skills} +@uref{http://www.oreilly.com/catalog/bioskills/} + +@end table + +@c The GNU Free Documentation License. +@node GNU Free Documentation License, Index, Links, Top +@unnumbered GNU Free Documentation License +@cindex FDL (Free Documentation License) +@cindex Free Documentation License (FDL) +@cindex GNU Free Documentation License +@center Version 1.3, 3 November 2008 + +@c This file is intended to be included within another document, +@c hence no sectioning command or @node. + +@display +Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. +@uref{http://fsf.org/} + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. +@end display + +@enumerate 0 +@item +PREAMBLE + +The purpose of this License is to make a manual, textbook, or other +functional and useful document @dfn{free} in the sense of freedom: to +assure everyone the effective freedom to copy and redistribute it, +with or without modifying it, either commercially or noncommercially. +Secondarily, this License preserves for the author and publisher a way +to get credit for their work, while not being considered responsible +for modifications made by others. + +This License is a kind of ``copyleft'', which means that derivative +works of the document must themselves be free in the same sense. It +complements the GNU General Public License, which is a copyleft +license designed for free software. + +We have designed this License in order to use it for manuals for free +software, because free software needs free documentation: a free +program should come with manuals providing the same freedoms that the +software does. But this License is not limited to software manuals; +it can be used for any textual work, regardless of subject matter or +whether it is published as a printed book. We recommend this License +principally for works whose purpose is instruction or reference. + +@item +APPLICABILITY AND DEFINITIONS + +This License applies to any manual or other work, in any medium, that +contains a notice placed by the copyright holder saying it can be +distributed under the terms of this License. Such a notice grants a +world-wide, royalty-free license, unlimited in duration, to use that +work under the conditions stated herein. The ``Document'', below, +refers to any such manual or work. Any member of the public is a +licensee, and is addressed as ``you''. You accept the license if you +copy, modify or distribute the work in a way requiring permission +under copyright law. + +A ``Modified Version'' of the Document means any work containing the +Document or a portion of it, either copied verbatim, or with +modifications and/or translated into another language. + +A ``Secondary Section'' is a named appendix or a front-matter section +of the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall +subject (or to related matters) and contains nothing that could fall +directly within that overall subject. (Thus, if the Document is in +part a textbook of mathematics, a Secondary Section may not explain +any mathematics.) The relationship could be a matter of historical +connection with the subject or with related matters, or of legal, +commercial, philosophical, ethical or political position regarding +them. + +The ``Invariant Sections'' are certain Secondary Sections whose titles +are designated, as being those of Invariant Sections, in the notice +that says that the Document is released under this License. If a +section does not fit the above definition of Secondary then it is not +allowed to be designated as Invariant. The Document may contain zero +Invariant Sections. If the Document does not identify any Invariant +Sections then there are none. + +The ``Cover Texts'' are certain short passages of text that are listed, +as Front-Cover Texts or Back-Cover Texts, in the notice that says that +the Document is released under this License. A Front-Cover Text may +be at most 5 words, and a Back-Cover Text may be at most 25 words. + +A ``Transparent'' copy of the Document means a machine-readable copy, +represented in a format whose specification is available to the +general public, that is suitable for revising the document +straightforwardly with generic text editors or (for images composed of +pixels) generic paint programs or (for drawings) some widely available +drawing editor, and that is suitable for input to text formatters or +for automatic translation to a variety of formats suitable for input +to text formatters. A copy made in an otherwise Transparent file +format whose markup, or absence of markup, has been arranged to thwart +or discourage subsequent modification by readers is not Transparent. +An image format is not Transparent if used for any substantial amount +of text. A copy that is not ``Transparent'' is called ``Opaque''. + +Examples of suitable formats for Transparent copies include plain +@sc{ascii} without markup, Texinfo input format, La@TeX{} input +format, @acronym{SGML} or @acronym{XML} using a publicly available +@acronym{DTD}, and standard-conforming simple @acronym{HTML}, +PostScript or @acronym{PDF} designed for human modification. Examples +of transparent image formats include @acronym{PNG}, @acronym{XCF} and +@acronym{JPG}. Opaque formats include proprietary formats that can be +read and edited only by proprietary word processors, @acronym{SGML} or +@acronym{XML} for which the @acronym{DTD} and/or processing tools are +not generally available, and the machine-generated @acronym{HTML}, +PostScript or @acronym{PDF} produced by some word processors for +output purposes only. + +The ``Title Page'' means, for a printed book, the title page itself, +plus such following pages as are needed to hold, legibly, the material +this License requires to appear in the title page. For works in +formats which do not have any title page as such, ``Title Page'' means +the text near the most prominent appearance of the work's title, +preceding the beginning of the body of the text. + +The ``publisher'' means any person or entity that distributes copies +of the Document to the public. + +A section ``Entitled XYZ'' means a named subunit of the Document whose +title either is precisely XYZ or contains XYZ in parentheses following +text that translates XYZ in another language. (Here XYZ stands for a +specific section name mentioned below, such as ``Acknowledgements'', +``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title'' +of such a section when you modify the Document means that it remains a +section ``Entitled XYZ'' according to this definition. + +The Document may include Warranty Disclaimers next to the notice which +states that this License applies to the Document. These Warranty +Disclaimers are considered to be included by reference in this +License, but only as regards disclaiming warranties: any other +implication that these Warranty Disclaimers may have is void and has +no effect on the meaning of this License. + +@item +VERBATIM COPYING + +You may copy and distribute the Document in any medium, either +commercially or noncommercially, provided that this License, the +copyright notices, and the license notice saying this License applies +to the Document are reproduced in all copies, and that you add no other +conditions whatsoever to those of this License. You may not use +technical measures to obstruct or control the reading or further +copying of the copies you make or distribute. However, you may accept +compensation in exchange for copies. If you distribute a large enough +number of copies you must also follow the conditions in section 3. + +You may also lend copies, under the same conditions stated above, and +you may publicly display copies. + +@item +COPYING IN QUANTITY + +If you publish printed copies (or copies in media that commonly have +printed covers) of the Document, numbering more than 100, and the +Document's license notice requires Cover Texts, you must enclose the +copies in covers that carry, clearly and legibly, all these Cover +Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on +the back cover. Both covers must also clearly and legibly identify +you as the publisher of these copies. The front cover must present +the full title with all words of the title equally prominent and +visible. You may add other material on the covers in addition. +Copying with changes limited to the covers, as long as they preserve +the title of the Document and satisfy these conditions, can be treated +as verbatim copying in other respects. + +If the required texts for either cover are too voluminous to fit +legibly, you should put the first ones listed (as many as fit +reasonably) on the actual cover, and continue the rest onto adjacent +pages. + +If you publish or distribute Opaque copies of the Document numbering +more than 100, you must either include a machine-readable Transparent +copy along with each Opaque copy, or state in or with each Opaque copy +a computer-network location from which the general network-using +public has access to download using public-standard network protocols +a complete Transparent copy of the Document, free of added material. +If you use the latter option, you must take reasonably prudent steps, +when you begin distribution of Opaque copies in quantity, to ensure +that this Transparent copy will remain thus accessible at the stated +location until at least one year after the last time you distribute an +Opaque copy (directly or through your agents or retailers) of that +edition to the public. + +It is requested, but not required, that you contact the authors of the +Document well before redistributing any large number of copies, to give +them a chance to provide you with an updated version of the Document. + +@item +MODIFICATIONS + +You may copy and distribute a Modified Version of the Document under +the conditions of sections 2 and 3 above, provided that you release +the Modified Version under precisely this License, with the Modified +Version filling the role of the Document, thus licensing distribution +and modification of the Modified Version to whoever possesses a copy +of it. In addition, you must do these things in the Modified Version: + +@enumerate A +@item +Use in the Title Page (and on the covers, if any) a title distinct +from that of the Document, and from those of previous versions +(which should, if there were any, be listed in the History section +of the Document). You may use the same title as a previous version +if the original publisher of that version gives permission. + +@item +List on the Title Page, as authors, one or more persons or entities +responsible for authorship of the modifications in the Modified +Version, together with at least five of the principal authors of the +Document (all of its principal authors, if it has fewer than five), +unless they release you from this requirement. + +@item +State on the Title page the name of the publisher of the +Modified Version, as the publisher. + +@item +Preserve all the copyright notices of the Document. + +@item +Add an appropriate copyright notice for your modifications +adjacent to the other copyright notices. + +@item +Include, immediately after the copyright notices, a license notice +giving the public permission to use the Modified Version under the +terms of this License, in the form shown in the Addendum below. + +@item +Preserve in that license notice the full lists of Invariant Sections +and required Cover Texts given in the Document's license notice. + +@item +Include an unaltered copy of this License. + +@item +Preserve the section Entitled ``History'', Preserve its Title, and add +to it an item stating at least the title, year, new authors, and +publisher of the Modified Version as given on the Title Page. If +there is no section Entitled ``History'' in the Document, create one +stating the title, year, authors, and publisher of the Document as +given on its Title Page, then add an item describing the Modified +Version as stated in the previous sentence. + +@item +Preserve the network location, if any, given in the Document for +public access to a Transparent copy of the Document, and likewise +the network locations given in the Document for previous versions +it was based on. These may be placed in the ``History'' section. +You may omit a network location for a work that was published at +least four years before the Document itself, or if the original +publisher of the version it refers to gives permission. + +@item +For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve +the Title of the section, and preserve in the section all the +substance and tone of each of the contributor acknowledgements and/or +dedications given therein. + +@item +Preserve all the Invariant Sections of the Document, +unaltered in their text and in their titles. Section numbers +or the equivalent are not considered part of the section titles. + +@item +Delete any section Entitled ``Endorsements''. Such a section +may not be included in the Modified Version. + +@item +Do not retitle any existing section to be Entitled ``Endorsements'' or +to conflict in title with any Invariant Section. + +@item +Preserve any Warranty Disclaimers. +@end enumerate + +If the Modified Version includes new front-matter sections or +appendices that qualify as Secondary Sections and contain no material +copied from the Document, you may at your option designate some or all +of these sections as invariant. To do this, add their titles to the +list of Invariant Sections in the Modified Version's license notice. +These titles must be distinct from any other section titles. + +You may add a section Entitled ``Endorsements'', provided it contains +nothing but endorsements of your Modified Version by various +parties---for example, statements of peer review or that the text has +been approved by an organization as the authoritative definition of a +standard. + +You may add a passage of up to five words as a Front-Cover Text, and a +passage of up to 25 words as a Back-Cover Text, to the end of the list +of Cover Texts in the Modified Version. Only one passage of +Front-Cover Text and one of Back-Cover Text may be added by (or +through arrangements made by) any one entity. If the Document already +includes a cover text for the same cover, previously added by you or +by arrangement made by the same entity you are acting on behalf of, +you may not add another; but you may replace the old one, on explicit +permission from the previous publisher that added the old one. + +The author(s) and publisher(s) of the Document do not by this License +give permission to use their names for publicity for or to assert or +imply endorsement of any Modified Version. + +@item +COMBINING DOCUMENTS + +You may combine the Document with other documents released under this +License, under the terms defined in section 4 above for modified +versions, provided that you include in the combination all of the +Invariant Sections of all of the original documents, unmodified, and +list them all as Invariant Sections of your combined work in its +license notice, and that you preserve all their Warranty Disclaimers. + +The combined work need only contain one copy of this License, and +multiple identical Invariant Sections may be replaced with a single +copy. If there are multiple Invariant Sections with the same name but +different contents, make the title of each such section unique by +adding at the end of it, in parentheses, the name of the original +author or publisher of that section if known, or else a unique number. +Make the same adjustment to the section titles in the list of +Invariant Sections in the license notice of the combined work. + +In the combination, you must combine any sections Entitled ``History'' +in the various original documents, forming one section Entitled +``History''; likewise combine any sections Entitled ``Acknowledgements'', +and any sections Entitled ``Dedications''. You must delete all +sections Entitled ``Endorsements.'' + +@item +COLLECTIONS OF DOCUMENTS + +You may make a collection consisting of the Document and other documents +released under this License, and replace the individual copies of this +License in the various documents with a single copy that is included in +the collection, provided that you follow the rules of this License for +verbatim copying of each of the documents in all other respects. + +You may extract a single document from such a collection, and distribute +it individually under this License, provided you insert a copy of this +License into the extracted document, and follow this License in all +other respects regarding verbatim copying of that document. + +@item +AGGREGATION WITH INDEPENDENT WORKS + +A compilation of the Document or its derivatives with other separate +and independent documents or works, in or on a volume of a storage or +distribution medium, is called an ``aggregate'' if the copyright +resulting from the compilation is not used to limit the legal rights +of the compilation's users beyond what the individual works permit. +When the Document is included in an aggregate, this License does not +apply to the other works in the aggregate which are not themselves +derivative works of the Document. + +If the Cover Text requirement of section 3 is applicable to these +copies of the Document, then if the Document is less than one half of +the entire aggregate, the Document's Cover Texts may be placed on +covers that bracket the Document within the aggregate, or the +electronic equivalent of covers if the Document is in electronic form. +Otherwise they must appear on printed covers that bracket the whole +aggregate. + +@item +TRANSLATION + +Translation is considered a kind of modification, so you may +distribute translations of the Document under the terms of section 4. +Replacing Invariant Sections with translations requires special +permission from their copyright holders, but you may include +translations of some or all Invariant Sections in addition to the +original versions of these Invariant Sections. You may include a +translation of this License, and all the license notices in the +Document, and any Warranty Disclaimers, provided that you also include +the original English version of this License and the original versions +of those notices and disclaimers. In case of a disagreement between +the translation and the original version of this License or a notice +or disclaimer, the original version will prevail. + +If a section in the Document is Entitled ``Acknowledgements'', +``Dedications'', or ``History'', the requirement (section 4) to Preserve +its Title (section 1) will typically require changing the actual +title. + +@item +TERMINATION + +You may not copy, modify, sublicense, or distribute the Document +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense, or distribute it is void, and +will automatically terminate your rights under this License. + +However, if you cease all violation of this License, then your license +from a particular copyright holder is reinstated (a) provisionally, +unless and until the copyright holder explicitly and finally +terminates your license, and (b) permanently, if the copyright holder +fails to notify you of the violation by some reasonable means prior to +60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, receipt of a copy of some or all of the same material does +not give you any rights to use it. + +@item +FUTURE REVISIONS OF THIS LICENSE + +The Free Software Foundation may publish new, revised versions +of the GNU Free Documentation License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. See +@uref{http://www.gnu.org/copyleft/}. + +Each version of the License is given a distinguishing version number. +If the Document specifies that a particular numbered version of this +License ``or any later version'' applies to it, you have the option of +following the terms and conditions either of that specified version or +of any later version that has been published (not as a draft) by the +Free Software Foundation. If the Document does not specify a version +number of this License, you may choose any version ever published (not +as a draft) by the Free Software Foundation. If the Document +specifies that a proxy can decide which future versions of this +License can be used, that proxy's public statement of acceptance of a +version permanently authorizes you to choose that version for the +Document. + +@item +RELICENSING + +``Massive Multiauthor Collaboration Site'' (or ``MMC Site'') means any +World Wide Web server that publishes copyrightable works and also +provides prominent facilities for anybody to edit those works. A +public wiki that anybody can edit is an example of such a server. A +``Massive Multiauthor Collaboration'' (or ``MMC'') contained in the +site means any set of copyrightable works thus published on the MMC +site. + +``CC-BY-SA'' means the Creative Commons Attribution-Share Alike 3.0 +license published by Creative Commons Corporation, a not-for-profit +corporation with a principal place of business in San Francisco, +California, as well as future copyleft versions of that license +published by that same organization. + +``Incorporate'' means to publish or republish a Document, in whole or +in part, as part of another Document. + +An MMC is ``eligible for relicensing'' if it is licensed under this +License, and if all works that were first published under this License +somewhere other than this MMC, and subsequently incorporated in whole +or in part into the MMC, (1) had no cover texts or invariant sections, +and (2) were thus incorporated prior to November 1, 2008. + +The operator of an MMC Site may republish an MMC contained in the site +under CC-BY-SA on the same site at any time before August 1, 2009, +provided the MMC is eligible for relicensing. + +@end enumerate + +@c fakenode --- for prepinfo +@unnumberedsec ADDENDUM: How to use this License for your documents + +To use this License in a document you have written, include a copy of +the License in the document and put the following copyright and +license notices just after the title page: + +@smallexample +@group + Copyright (C) @var{year} @var{your name}. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.3 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover + Texts. A copy of the license is included in the section entitled ``GNU + Free Documentation License''. +@end group +@end smallexample + +If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, +replace the ``with@dots{}Texts.'' line with this: + +@smallexample +@group + with the Invariant Sections being @var{list their titles}, with + the Front-Cover Texts being @var{list}, and with the Back-Cover Texts + being @var{list}. +@end group +@end smallexample + +If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. + +If your document contains nontrivial examples of program code, we +recommend releasing these examples in parallel under your choice of +free software license, such as the GNU General Public License, +to permit their use in free software. + +@c Local Variables: +@c ispell-local-pdict: "ispell-dict" +@c End: + + +@node Index, , GNU Free Documentation License, Top +@comment node-name, next, previous, up + +@unnumbered Index +@printindex cp +@bye + +Conventions: +1. Functions, built-in or otherwise, do NOT have () after them. +2. Gawk built-in vars and functions are in @code. Also program vars and + functions. +3. HTTP method names are in @code. +4. Protocols such as echo, ftp, etc are in @samp. +5. URLs are in @url. +6. All RFCs in the index. Put a space between `RFC' and the number. diff --git a/doc/general-program.eps b/doc/general-program.eps new file mode 100644 index 0000000..1249716 --- /dev/null +++ b/doc/general-program.eps @@ -0,0 +1,153 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: general-program.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5c +%%CreationDate: Thu Jan 6 17:36:07 2011 +%%BoundingBox: 0 0 269 58 +%Magnification: 1.0000 +%%EndComments +%%BeginProlog +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +/pageheader { +save +newpath 0 58 moveto 0 0 lineto 269 0 lineto 269 58 lineto closepath clip newpath +-194.8 247.1 translate +1 -1 scale +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06299 0.06299 sc +} bind def +/pagefooter { +$F2psEnd +restore +} bind def +%%EndProlog +pageheader +% +% Fig objects follow +% +% +% here starts figure with depth 50 +% Polyline +0 slj +0 slc +7.500 slw +n 4961 3021 m 4706 3467 l 4965 3911 l 5478 3908 l 5733 3462 l 5474 3018 l + + cp gs col0 s gr +% Polyline +gs clippath +4544 3495 m 4695 3495 l 4695 3435 l 4544 3435 l 4544 3435 l 4664 3465 l 4544 3495 l cp +eoclip +n 4095 3465 m + 4680 3465 l gs col0 s gr gr + +% arrowhead +n 4544 3495 m 4664 3465 l 4544 3435 l 4544 3495 l cp gs 0.00 setgray ef gr col0 s +% Polyline +gs clippath +6164 3495 m 6315 3495 l 6315 3435 l 6164 3435 l 6164 3435 l 6284 3465 l 6164 3495 l cp +eoclip +n 5805 3465 m + 6300 3465 l gs col0 s gr gr + +% arrowhead +n 6164 3495 m 6284 3465 l 6164 3435 l 6164 3495 l cp gs 0.00 setgray ef gr col0 s +% Polyline +n 6405 3150 m 6330 3150 6330 3704 75 arcto 4 {pop} repeat + 6330 3779 7274 3779 75 arcto 4 {pop} repeat + 7349 3779 7349 3225 75 arcto 4 {pop} repeat + 7349 3150 6405 3150 75 arcto 4 {pop} repeat + cp gs col0 s gr +% Polyline +n 3165 3195 m 3105 3195 3105 3719 60 arcto 4 {pop} repeat + 3105 3779 3992 3779 60 arcto 4 {pop} repeat + 4052 3779 4052 3255 60 arcto 4 {pop} repeat + 4052 3195 3165 3195 60 arcto 4 {pop} repeat + cp gs col0 s gr +/Times-Roman ff 180.00 scf sf +6525 3510 m +gs 1 -1 sc (Results) col0 sh gr +/Times-Roman ff 180.00 scf sf +3375 3510 m +gs 1 -1 sc (Data) col0 sh gr +/Times-Roman ff 180.00 scf sf +4860 3510 m +gs 1 -1 sc (Program) col0 sh gr +% here ends figure; +pagefooter +showpage +%%Trailer +%EOF diff --git a/doc/general-program.fig b/doc/general-program.fig new file mode 100644 index 0000000..8ab42f3 --- /dev/null +++ b/doc/general-program.fig @@ -0,0 +1,25 @@ +#FIG 3.2 Produced by xfig version 3.2.5b +Landscape +Center +Metric +A4 +100.00 +Single +-2 +1200 2 +2 3 0 1 0 7 50 -1 -1 0.000 0 0 0 0 0 7 + 4961 3021 4706 3467 4965 3911 5478 3908 5733 3462 5474 3018 + 4961 3021 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 + 1 1 1.00 60.00 120.00 + 4095 3465 4680 3465 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 + 1 1 1.00 60.00 120.00 + 5805 3465 6300 3465 +2 4 0 1 0 7 50 -1 -1 0.000 0 0 5 0 0 5 + 7349 3779 7349 3150 6330 3150 6330 3779 7349 3779 +2 4 0 1 0 7 50 -1 -1 0.000 0 0 4 0 0 5 + 4052 3779 4052 3195 3105 3195 3105 3779 4052 3779 +4 0 0 50 -1 0 12 0.0000 4 150 630 6525 3510 Results\001 +4 0 0 50 -1 0 12 0.0000 4 150 420 3375 3510 Data\001 +4 0 0 50 -1 0 12 0.0000 4 195 750 4860 3510 Program\001 diff --git a/doc/general-program.pdf b/doc/general-program.pdf new file mode 100644 index 0000000000000000000000000000000000000000..c79b9efa3c3f767988441b307ae5ba81ab887061 GIT binary patch literal 5588 zcmb_Ad0fot|Lcmz5iN>JAKFaR%x6AxH8a&vGb(f+=)xSIrl~n<=2K1ONJ1pF_@WDi z6roy4s2n*XD$8!mX46K|=BzC8eLho>jxqs;@==jejB>dIHKsxZa)Ku7 zh|f92L}X0GBTLoOMTa(K|1$sRsKn}x3a93HR^jARlQM=xmL)Y^{?(P*aMa&-=#A+Q zt!v}DYO1^M4DnyQ`;>zCGT5Z!ujNDegzBzT_NuZcdO8R}tn|}A8A4n;ZiKD>f(f^r zY<6rPvqqi>kvAk1nLUuvG>$tGk~C1sb`y_g?=6;_t)`Uhoe|x7>E2-~@gQg3YWfc` z&%G+QpV>Ubxq9}f6@^y|d=5STMbtSXZStHh6L`ifp72hseoxk9c1m~cipt}2QZ$L< zi->MBCGztdF5WRxA0a)hU9fU#%bDXdu`qzGZgm`5bj9kNU zsFmyuSxZSuWZzjQDhg;AUm=LC#ai-5&EVHv$j^$+*;012;KUMkb)0j#*`H~C9~$VL zKPJWtT4fQwBxB-!UuLcI;R;pP?}tK@%ba#5%#5qIa^sknoO(6UGq`jSC5j(*OXP7N z{_OPH;$A)d(P~~Aw!xAd$xq!}v;9!kk%xJl)77~rbV-52Y?(c*=2ef#7TsgV1^Sld zO+Qi+;TYPH^3&@(J^?FKZS=@)n~FS5?6I1t66MJ3`uVAZGj~s0-^*xtb!S>6w2eHp zwoQ-X(kgua{#o1#R^fWnR>DsUme=3@BlC^wx#DG!U(iN_L}QrSvAUxxQ~ElxC**g% z$l##NsxxNRA5ew3KZw8x4?H~F@c$Xs2%#TD{}huxG2tleA&{W3D=L->9F!U;fC84O zOg6+|1rflS3RPeb4G&rZ?1ie8ktz|Y2I1_XQi{A$EC2=p55YdD1_S8xG?)=Za^(atCt#r7fQuyD1d-#?L`QJ z0EbANsY;FULIf&^$%0)3{bK~Nh8Ii4Scp0RvZhi2(Kmhs1_KWV zCKK2D|M(Fo5S@ZdsUsympbrZ-zoPOI_4j^hl(2}SKt{MZFg%*UL zs}eOtqY_|ywFr-300qG(2zN%Mk`ORuf+gI{_!>@1faimlk&5gU5*Z3n2(UMX$`^si zWfEXlsag&8qqVPg-|&)tHgqPy#GL^$!2;&P93ZrM145Nm{8&asFM$fnM|Bf{32SG&Ice=XM6U9v3wCk1C#ky{r zb$^HowJ8XzcRNdq$ZYI5u4pVzjp?m(3g*18OSg&stKyMOlikbvZ%uS27wd{BhMv-9 zs^_2FoWjDnr;3{vUZP#;$h>0WvUmTJpeIDL=;aBD*2zgi2cPPnJ5JJcQqCk8H#uE0 zUGAd8lXtpry?WTP`l7k-yP&r7*YC%5J$>JFHK)3oze@0Wwb?td=Yf+;t~Jevx6jz< zvUKLwMejH5;qNooe?D(j@qYiMURPm@+4_^@`_YNc{GD$OUeqrRBzwPzHt%RPL2K+yWQn=eMk0%>IyN^&|XX^t_9N`Suq-I8ny@He=z@{6epZNnV@QZKaM`cy87D z?925C%$~wl$0#gv)#AqO2bvw;pDh{ z6Q7pTlBMve+tvjwS6jnO&+?joeOsefUiW0@*@M%}?q0fGxl6e$&8j*HwO*ZUXzX17 z#4SVj1V80cIR9+b`I@p$@|KljSFbyWT1ri`%iR&j0+YEO6;@qQjNSvq71P}6dJF`$ zMK#Fl7R8YsooMrw?S>wP9+{(4t1>dpU4J$m(VSapSDozWewNqUc(dpI>;^Z*L#(ke z(s>$eKMBVC`H+(JC+*zjCNwGp4E8gH5-CkhsryG*CzjVATs^l+*dJY&K1?e zL;n}=)N!QX>0k5VUoFGpv6!}@b zzLb~em_%E1&j0R$qKa|rau3+{CQ>ZhRy=O@AJ^&DmUJyZck9W~J5fL3#?wwWe7o*; zw@*&;Z{M4VMxR*H7W->L)Z^o?GD3!WQ*QlY@}Z}}Mz3}D1!d|Bi>KaxJM&D3Mr^xq z?#XCg^M#6gA#~X;;ywpNAFHO7XOTjRufK5$GR5k> z4jN8QjJ|SYB~n)9aJtv9W>uuxEJa&6=DEfKdqWaPa9kQ^Na{Zj_nkE z-A!-bAc=G0jwcmK$)yQhszA%Tmv$`I{agIkKKgsovz*=Y>1BW9R#nX{H6m}_8(n85 zIom9s8b7J$7Q3N4A_UX@>)i3EK&~dDDsI#YX6AigxtBC=w%O3AxbH5)k9uDj%=&fW(RyaU;ghcxde@J@s#Aq;J=^$UX%kk& zhnkK|a4Fe-?^?QM?BX?-@=7d?1O9Z231g3c>uzo`aX7zwK}>sl`_ygaK8L*55Vo8A zJcV;4a!W2t`-FE&{cI|$&MK6v=8CO%@a8Ne!pge4SX|Bnsv!>H@S&f-bU764P z?zze-I@@;tF_-mt${MyIy*rdQ99>bK@;$Tn9QJ+EoOO{G3y8`2SIi35{!|gw{mS^* zq?H%^#%u{Rot8iANpsXrti^sp#8UsQ-BIW6Kf>HO-*I2;G4ij}tig=@xl2Ekr<#=% zWYvfHOb`9-@ASBQGviTXd-DERxvMVaKYE+;^mUl8jK#%G-Val!W<{pG%igW4^Zv<9 z|C`fId;JgBj@|RUg;AA!-s{_5KX5JyB^B4F?+H&JU;ZKXPq*Gm8ERjgk-2!Ouu(KU zq%2{>^D^H&W%gC6s64|a!(?t^R%77rH7eu!QqG!mg=gfnz+1V|=beVXF*s9~;b%t8 zI=V4=X?NXN#bw)vS7+IJ$#eVMu zy&bQ@v8?&aLNaj-ZQztX-;e9E|1Uzk5n=7rwZSDPAYA(#9Fg&2t?;J~ezFVSRnqcc8U%(inh;Q~<@ia|nDB30NCJ5N^;A*tAoxR~KeaSi98AyVg973v-9<|B#? z6S2j_Ib4G6904fZQIbXwP72ociE0Q`Dt0q?UM`L^a0CrUBM+B@au(9aWePP%V@K4I zaKIP`!$e4nf`!=;m$-UBm{KVVlVT8+%qAlwgk}W=t3X8+tyG0U2$@L)ELGxQju)up z`xt_m9WeyM!Z|P;9UV=MrjeB@35>AWY?wlYsZGTAITJI zvQ{UuNGXSQ))VETl0>T9ggvvmbA&CM$5*y6v zLLrq&Lumt&!Ut*inJBOTWYK^Lz=#976mg^oRoM}pJX|2B5TzRHE3F|G*%~3j{X72` z6apUk_TGUT`!{b3a5%1@HV%&AgC2=Xr63520{$_55Ni&N$)V6JDO3)HVhewP30w|H zdEj*bycYZqq=PUAkt$U_AP~60QVCUzMnQ{El^XW|jZB3+1ehp9hDM<>h#~3|ujSEC zVhiJL8f2w^(QblpSJ(gFa&kEy&^R84uM|bfLCrp&|38MyzvyAH=%bq9kt&%sBg7&Y zm7%ysYT#r9=qVO)f|V+{0K~H(JREcs0t^@#2Ej<=+JZ$)ipfx}Hs9=JSl>V<#q)T01}=j? z9voZ(^e=t?9-~jEB{+lah|&02_|<7Vs9PGyZHsTE_AJns;pqZwk0*=;pMz%`1)(qz zYZ_CVXhaHy2+%-6{sV>&?lOySIAcJFQf2XvNj2-^BZ5YS27}fap%d`at?z@F3 z1w#Wc77H}t_y;KlV01PUG~A!VC@d;?NcjTB1YPi#FbeWDjEO%7d_l{mgLeFL7(!uu zB^Lq5^p|)PHv4Nl3iWFkgY}gzGzJYkDh$ZQR07Z|tH7%%1ba(k!D|v7g1wYV@a%&( z&k#Ic5v+u?jWp=n`A~qZgS|D?n$5I#ut!)9OnWBXp2FlgIL>pRP^e5M!sq@oMiBm@ Wq{aj)OzR*9!e9{0&F8s068;NKyef+T literal 0 HcmV?d00001 diff --git a/doc/igawk.1 b/doc/igawk.1 new file mode 100644 index 0000000..08173ec --- /dev/null +++ b/doc/igawk.1 @@ -0,0 +1,73 @@ +.TH IGAWK 1 "Nov 3 1999" "Free Software Foundation" "Utility Commands" +.SH NAME +igawk \- gawk with include files +.SH SYNOPSIS +.B igawk +[ all +.I gawk +options ] +.B \-f +.I program-file +[ +.B \-\^\- +] file .\^.\^. +.br +.B igawk +[ all +.I gawk +options ] +[ +.B \-\^\- +] +.I program-text +file .\^.\^. +.SH DESCRIPTION +.I Igawk +is a simple shell script that adds the ability to have ``include files'' to +.IR gawk (1). +.PP +AWK programs for +.I igawk +are the same as for +.IR gawk , +except that, in addition, you may have lines like +.RS +.sp +.ft B +@include getopt.awk +.ft R +.sp +.RE +in your program to include the file +.B getopt.awk +from either the current directory or one of the other directories +in the search path. +.SH OPTIONS +See +.IR gawk (1) +for a full description of the AWK language and the options that +.I gawk +supports. +.SH EXAMPLES +.nf +.ft B +cat << EOF > test.awk +@include getopt.awk +.sp +BEGIN { + while (getopt(ARGC, ARGV, "am:q") != \-1) + \&.\^.\^. +} +EOF +.sp +igawk \-f test.awk +.ft R +.fi +.SH SEE ALSO +.IR gawk (1) +.PP +.IR "Effective AWK Programming" , +Edition 1.0, published by the Free Software Foundation, 1995. +.SH AUTHOR +Arnold Robbins +.RB ( arnold@skeeve.com ). diff --git a/doc/lflashlight-small.xpic b/doc/lflashlight-small.xpic new file mode 100644 index 0000000..94ae774 --- /dev/null +++ b/doc/lflashlight-small.xpic @@ -0,0 +1,20 @@ +#! /usr/X11R6/bin/xpic +80 48 160 80 8 +1 75 144 48 160 56 0 0 +2 + 160 48 144 56 +1 76 112 48 136 56 0 0 +2 + 112 56 136 48 +1 77 112 72 136 80 0 0 +2 + 112 72 136 80 +5 78 128 48 144 80 0 0 +136 64 8 16 +3 79 80 56 112 72 0 0 +1 80 144 64 160 64 0 0 +2 + 144 64 160 64 +1 81 144 72 160 80 0 0 +2 + 144 72 160 80 diff --git a/doc/lflashlight.eps b/doc/lflashlight.eps new file mode 100644 index 0000000..fdb8cf3 --- /dev/null +++ b/doc/lflashlight.eps @@ -0,0 +1,135 @@ +%! +%%Creator: arnold@skeeve (Aharon Robbins) +%%Title: rflashlight.small.xpic (xpic) +%%CreationDate: Tue Dec 12 09:51:27 2000 +%%Pages: 1 +%%BoundingBox: 0 0 72 28.8 +% (in inches) at 0 0, width 1, height 0.4 +%%EndComments +% Prolog for xpic to PostScript converter +% Author: Mark Moraes +% $Header: x2ps.pro,v 1.2 88/03/19 16:50:09 moraes Exp +% %d D - change style SOLID, DOTTED, SHORT-DASH, LONG-DASH, DOT-DASH +% %s F - change font to fontname +% %d S - change size (font size in points) +% (%s) rj %d t - text right just. (%d is TOPLINE, MIDLINE, BOTLINE) +% (%s) lj %d t - text left just. (%d is TOPLINE, MIDLINE, BOTLINE) +% (%s) ce %d t - text centered (%d is TOPLINE, MIDLINE, BOTLINE) +% %d %d l - lineto +% %d %d m - moveto +% %d %d s - spline segment +% x - flush line, spline +% b - box +% e - ellipse +% %d ss - setscale +% %d W - change linewidth +% getpagesize - gets the values of PAGEHEIGHT and PAGEWIDTH +% %d %d flip - translate by %d, PAGEHEIGHT - %d (this +% transforms to X windows coordinates) +save 50 dict begin /xpic exch def +/StartXpic {newpath 0 0 moveto [] 0 setdash 0 setgray 1 setlinecap} def +% Set defaults +/fontname /Times-Roman def +/ptsize 12 def +% halign has the values for MIDLINE, TOPLINE, BOTLINE +/halign 3 array def +/s {rcurveto} def +/x {stroke} def +/l {lineto} def +/m {moveto} def +/b { + /ury exch def /urx exch def /lly exch def /llx exch def + llx lly moveto urx lly lineto urx ury lineto + llx ury lineto llx lly lineto stroke +} def +/mtrx matrix def +/e { + /yc exch def /xc exch def /yrad exch def /xrad exch def + xc xrad add yc moveto + /savematrix mtrx currentmatrix def + xc yc translate + xrad yrad scale + 0 0 1 0 360 arc + savematrix setmatrix stroke +} def +% The next three take the text string, and moveto the right horiz. position +% leaving the string on the stack. +/lj {} def +/rj {dup stringwidth pop neg 0 rmoveto} def +/ce {dup stringwidth pop 2 div neg 0 rmoveto} def +% And this is invoked after one of the three above, and +% computes the vert. pos, and then displays the string. +/t {halign exch get 0 exch rmoveto show newpath} def +% Store an array of patterns in /styles - a pattern is an array consisting +% of an array and an offset. Corresp to xpic patterns +% solid, dotted, short-dashed, long-dashed, dot-dashed +/styles [ [] 0 ] [ [1 3] 0 ] [ [4 4] 0 ] [ [8 4] 0 ] [ [1 4 4 4] 0 ] + 5 array astore def +% change style to arg. +/D {stroke styles exch get aload pop setdash newpath} def +/W {stroke 0.5 mul setlinewidth newpath} def +% fontbox takes a fontname off the stack, and returns an array +% containing the values of the bottom line of the bounding box, the +% mid line of the bounding box, and the top line of the bounding box +% of that font, taken from the baseline, scaled to a font of size 1 +/fontbox { + findfont dup /FontMatrix get /fm exch def /FontBBox get aload pop + /ytop exch def pop /ybot exch def pop + /ymid ytop ybot sub 2 div def + 0 ybot fm dtransform exch pop % botline + dup neg exch % midline - this works better than (ytop-ybot)/2! + 0 ytop fm dtransform exch pop exch %topline + % now in the order midline, topline, botline. + 3 array astore +} def +% select font +/F { + dup /fontname exch def fontbox + /thisfontbox exch def SF +} def +% set point size +/S {/ptsize exch def SF} def +% actually set font +/SF { + fontname findfont ptsize curscale div scalefont setfont + thisfontbox aload pop + 1 1 3 { + pop ptsize mul curscale div neg 3 1 roll + } for + halign astore pop +} def +% sets the scale to 72 / n, where n is on the stack, and stores the value +% in curscale for font scaling +/curscale 1 def +/getpagesize{newpath clippath pathbbox /pageheight exch def + /pagewidth exch def pop pop newpath} def +/flip{pageheight exch sub translate} def +/ss {/curscale exch 72 exch div dup dup scale def} def +/land {90 rotate} def +StartXpic +%%EndProlog +80 ss +0.5 W +0 D +80 32 m +64 24 l +x +32 24 m +56 32 l +x +32 8 m +56 0 l +x +8 16 56 16 e +0 24 32 8 b +64 16 m +80 16 l +x +64 8 m +80 0 l +x +%%Trailer +showpage +% Trailer for xpic to PostScript converter +% $Header: x2ps.tra,v 1.2 89/07/02 15:59:53 moraes Exp $ +xpic end restore diff --git a/doc/lflashlight.pdf b/doc/lflashlight.pdf new file mode 100644 index 0000000..4432fdd --- /dev/null +++ b/doc/lflashlight.pdf @@ -0,0 +1,56 @@ +%PDF-1.3 +%Ç쏢 +6 0 obj +<> +stream +xœUA! E÷=EO€¥¯ànôÄ“™ÅèÂëÛ51„P¿Ÿß)D$[ól;pº +>ÞÀ3~ âE÷*ò²à¹äXpƒ±Z)IwZyBêȚ¢Èl·jFœBæ3fI¡–aáV ¤HàTúMÿÔV›‡*´R‘ÔÈèjÂñowU¢¹Î4ÍEÔì ¼îImä‘tÐ>’Á1Òªë ŸO>endstream +endobj +7 0 obj +168 +endobj +5 0 obj +<> +/Contents 6 0 R +>> +endobj +3 0 obj +<< /Type /Pages /Kids [ +5 0 R +] /Count 1 +>> +endobj +1 0 obj +<> +endobj +4 0 obj +<> +endobj +8 0 obj +<> +endobj +2 0 obj +<>endobj +xref +0 9 +0000000000 65535 f +0000000471 00000 n +0000000617 00000 n +0000000412 00000 n +0000000519 00000 n +0000000272 00000 n +0000000015 00000 n +0000000253 00000 n +0000000588 00000 n +trailer +<< /Size 9 /Root 1 0 R /Info 2 0 R +>> +startxref +667 +%%EOF diff --git a/doc/macros b/doc/macros new file mode 100644 index 0000000..112e3c8 --- /dev/null +++ b/doc/macros @@ -0,0 +1,211 @@ +.\" SSC Reference card macros +.\" +.\" Copyright (C) 1996, Specialized System Consultants Inc. (SSC) +.\" +.\" These macros are free software; you can redistribute them and/or modify +.\" them under the terms of the GNU General Public License as published by +.\" the Free Software Foundation; either version 2 of the License, or +.\" (at your option) any later version. +.\" +.\" These macros are distributed in the hope that it will be useful, +.\" but WITHOUT ANY WARRANTY; without even the implied warranty of +.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +.\" GNU General Public License for more details. +.\" +.\" You should have received a copy of the GNU General Public License +.\" along with this program; if not, write to the Free Software +.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +.\" +.\" Generic SSC "card" macros +.\" based on lots of other macros +.\" Last update: 4-25-91 ph +.\" attempting to get margins in the boxes Aug 3 09:43:48 PDT 1994 +.ll 3i \" length of text line +.lt 3.2i \" length of title line +.de BT \" bottom of page trap +.sp |8.2i \" go to where we put footer +.ie \\n(CL=1 \{\ +. nr CL 2 +.tl ''\\*(CD\\n+(PN'' \" footer is just page number +. po 4i \" go to second column +.TP \" print header if any +\} +.el \{\ +. nr CL 1 +.tl ''\\*(CD\\n+(PN'' \" footer is just page number +. po .5i \" go to first column +. bp \" force a new page (which will force header) +. TP +\} +.. +.de TP \" top of page +.\" .sp |.2i +.sp |0 +.\" put page header stuff here +.\" for example: .tl ''WOW!'' +.\".sp +.. +.\" .wh 8.1i BT \" set bottom of column trap +.nf \" don't fill lines +.nh \" no hyphenation +.nr CL 1 \" start with column = 1 +.po .5i \" offset for first column +.vs 9 \" line spacing +.ps 8 \" point size +.de ST \" set tabs to normal places +.ta .2i .78i 1.2i 1.7i \" set tabs +.. +.ig + From: bryang@chinet.chi.il.us (Bryan Glennon) + Box macro. Do a .mk z where the box is to start, and a .eb + where it is to end. Optional argument is a title to be centered + within the top box line. + + Usage: + + .mk z + Text, etc to be boxed... + .eb "Optional title goes here" + + ~or~ + + .mk z + Text, etc to be boxed... + .eb + + + Some explanation: + The macro name is eb <.de eb>. First thing we do is to go up on line + <.sp -1> and turn off fill mode <.nf>. Now it gets interesting: the + .ie is the if/else construct. We check the number of arguments provided + to the macro <\\n(.$> and if it is greater than 0 (meaning we have a title), + we do the rest of the .ie line, as follows: + + \h'-.5n' - move left one-half of an n + \L'|\\nzu-1' - draw a vertical line <\L> to the + absolute position (|) given by \\nzu-1, + which is the position set with the .mk + command into register z <\\nz> in base + units minus 1. + \l'(\\n(.lu+1n-\w'\\$1'u/2u)\(ul' - Draw a horizontal line <\l> with length + equal to the current line length + <\\n(.l> in base units plus the + space required for an 'n' <1n>, minus + the width <\w> of the title string + <\\$1> in base units divided by 2 + >. Draw the line + using the underline character, <\(ul>. + \v'.3m'\|\\$1\|\v'-.3m' - Move down the page 3/10 of an m, + <\v'.3m'>, output a 1/6 of an m space + <\|>, output the title <\\$1>, another + 1/6 of an m space <\|>, and then move + up the page 3/10 of an m <\v'-.3m'>. + \l'...\(ul' - Draw the second part of the line, just + like the corresponding left half done + before. + \L'-|\\nzu+1' - Draw a verticle line <\L> going down + the absolute distance <-|> from where + the macro was given to where the start + point was marked <\\nz> in base units + plus one line <+1> + \l'|0u-.5n\(ul' - Draw a horizontal line to the absolute + position (|0) when the macro was + invoked, minus half an n <-.5n> using + the underline character <\(ul>. + + The .el beings the else part, which is identical to the above, except + the string dosen't get printed. This makes the printing of the top + line much easier: just draw a line <\l> with width equal to the + current line plus the witdh of an n <\\n(.l+1n> using the underline + character <.\(ul>. +.. +.de ES \" start "text in a box" +.mk z +.in +.5n +.ll -.5n +.sp 1.3 +.. +.de EB \" end "text in a box" -- optional box title as argument +.sp -.6 +.nf +.in -.5n +.ll +.5n +.ie \\n(.$\ +\L'|\\nzu'\ +\l'(\\n(.lu-\w'\\$1'u)/2u-.33m\(ul'\ +\v'.3m'\|\\$1\|\v'-.3m'\ +\l'(\\n(.lu-\w'\\$1'u)/2u\(ul'\ +\L'-|\\nzu'\ +\l'|0u\(ul' +.el \h'-.5n'\L'|\\nzu-1'\l'\\n(.lu+1n\(ul'\L'-|\\nzu+1'\l'|0u-.5n\(ul' +.in 0 +.. +.de SL \" draw single line (works in non-fill mode only) +.sp -.8 +.ti 0 +\l'\\n(.lu\(ul' +.. +.de Hl \" draw horizontal line +.br +.ti 0 +\l'\\n(.lu-\\n(.iu' +.br +.. +.de DL \" draw double line (works in non-fill mode only) +.sp -.8 +.ti 0 +\l'\\n(.lu\(ul' +.sp -.8 +.ti 0 +\l'\\n(.lu\(ul' +.. +.ST +.nr PN 0 1 \" sets starting page number and auto-increment +.\" must define page header (if any) before here +.TP +.ds 3) \|\v'3p'\s+5\z\(sq\s0\v'-3p'\h'1.25p'\v'-.5p'3\v'.5p'\h'2p' +.\" old one .ds 2) \h'-1.5p'\v'1p'\s+4\z\(ci\s0\v'-1p'\h'3.25p'2 +.ds 2) \|\v'-2.4p'\D'c.095id'\h'-5.15p'\v'2.4p'2\h'1.9p' +.ds dC \v'1p'\s+5\(bu\s0\v'-1p'\" for development commands +.ds tC \s+2\(dm\s0\" (for DWB) should be a triangle +.ds tP \s+2\(dm\s0\" (for other text processing) should be a triangle +.\" various trademark symbols +.ds Tm \v'-0.5m'\s8TM\s0\v'0.5m' +.ds Ts \v'-0.5m'\s4TM\s0\v'0.5m' +.ig ++ +.\" mount Serifa fonts +.fp 5 SR +.fp 6 SB +.fp 4 Si +.++ +.\" other assorted junk +.lg 0 +.\" Fl requires extended version of troff +.de Fl \" draw fat horizontal line +.br +.ti 0 +.ruw 1.5p +\l'\\n(.lu-\\n(.iu' +.br +.ruw +.. +.de Bx \" box for keys in text +\\$3\&\|\&\c +\s-3\(br\|\fH\v'.18n'\\$1\v'-.18n\fP\|\(br\l'|0\(rn'\l'|0\(ul'\&\s0\|\\$2 +.. +.de Fn \" function name - left justified, gray background +.\" bold with gray for function name +.ns +.br +\ +.ns +.br +\!! gsave ( ) stringwidth neg 0 rmoveto +\!! /Serifa-Bold findfont 8 scalefont setfont +\!! (\\$1) dup stringwidth pop 6 gsave dup 0 exch rlineto neg exch 0 rlineto +\!! 0 exch rlineto closepath .9 setgray fill grestore show +\!! grestore +.nf +.rs +.. +.rs diff --git a/doc/no.colors b/doc/no.colors new file mode 100644 index 0000000..b4fa397 --- /dev/null +++ b/doc/no.colors @@ -0,0 +1,31 @@ +.\" AWK Reference Card --- Arnold Robbins, arnold@skeeve.com +.\" This file is for troff which does not know what to do +.\" with literal Poscript and cannot use the macros from 'colors'. +.\" +.\" Copyright (C) 1996 Free Software Foundation, Inc. +.\" +.\" Permission is granted to make and distribute verbatim copies of +.\" this reference card provided the copyright notice and this permission +.\" notice are preserved on all copies. +.\" +.\" Permission is granted to process this file through troff and print the +.\" results, provided the printed document carries copying permission +.\" notice identical to this one except for the removal of this paragraph +.\" (this paragraph not being relevant to the printed reference card). +.\" +.\" Permission is granted to copy and distribute modified versions of this +.\" reference card under the conditions for verbatim copying, provided that +.\" the entire resulting derived work is distributed under the terms of a +.\" permission notice identical to this one. +.\" +.\" Permission is granted to copy and distribute translations of this +.\" reference card into another language, under the above conditions for +.\" modified versions, except that this permission notice may be stated in +.\" a translation approved by the Foundation. +.\" +.ds CR +.ds CG +.ds CL +.ds CB +.ds CD +.ds CX diff --git a/doc/process-flow.eps b/doc/process-flow.eps new file mode 100644 index 0000000..81b937b --- /dev/null +++ b/doc/process-flow.eps @@ -0,0 +1,191 @@ +%!PS-Adobe-2.0 EPSF-2.0 +%%Title: process-flow.fig +%%Creator: fig2dev Version 3.2 Patchlevel 5c +%%CreationDate: Thu Jan 6 17:25:09 2011 +%%BoundingBox: 0 0 367 174 +%Magnification: 1.0000 +%%EndComments +%%BeginProlog +/$F2psDict 200 dict def +$F2psDict begin +$F2psDict /mtrx matrix put +/col-1 {0 setgray} bind def +/col0 {0.000 0.000 0.000 srgb} bind def +/col1 {0.000 0.000 1.000 srgb} bind def +/col2 {0.000 1.000 0.000 srgb} bind def +/col3 {0.000 1.000 1.000 srgb} bind def +/col4 {1.000 0.000 0.000 srgb} bind def +/col5 {1.000 0.000 1.000 srgb} bind def +/col6 {1.000 1.000 0.000 srgb} bind def +/col7 {1.000 1.000 1.000 srgb} bind def +/col8 {0.000 0.000 0.560 srgb} bind def +/col9 {0.000 0.000 0.690 srgb} bind def +/col10 {0.000 0.000 0.820 srgb} bind def +/col11 {0.530 0.810 1.000 srgb} bind def +/col12 {0.000 0.560 0.000 srgb} bind def +/col13 {0.000 0.690 0.000 srgb} bind def +/col14 {0.000 0.820 0.000 srgb} bind def +/col15 {0.000 0.560 0.560 srgb} bind def +/col16 {0.000 0.690 0.690 srgb} bind def +/col17 {0.000 0.820 0.820 srgb} bind def +/col18 {0.560 0.000 0.000 srgb} bind def +/col19 {0.690 0.000 0.000 srgb} bind def +/col20 {0.820 0.000 0.000 srgb} bind def +/col21 {0.560 0.000 0.560 srgb} bind def +/col22 {0.690 0.000 0.690 srgb} bind def +/col23 {0.820 0.000 0.820 srgb} bind def +/col24 {0.500 0.190 0.000 srgb} bind def +/col25 {0.630 0.250 0.000 srgb} bind def +/col26 {0.750 0.380 0.000 srgb} bind def +/col27 {1.000 0.500 0.500 srgb} bind def +/col28 {1.000 0.630 0.630 srgb} bind def +/col29 {1.000 0.750 0.750 srgb} bind def +/col30 {1.000 0.880 0.880 srgb} bind def +/col31 {1.000 0.840 0.000 srgb} bind def + +end + +/cp {closepath} bind def +/ef {eofill} bind def +/gr {grestore} bind def +/gs {gsave} bind def +/sa {save} bind def +/rs {restore} bind def +/l {lineto} bind def +/m {moveto} bind def +/rm {rmoveto} bind def +/n {newpath} bind def +/s {stroke} bind def +/sh {show} bind def +/slc {setlinecap} bind def +/slj {setlinejoin} bind def +/slw {setlinewidth} bind def +/srgb {setrgbcolor} bind def +/rot {rotate} bind def +/sc {scale} bind def +/sd {setdash} bind def +/ff {findfont} bind def +/sf {setfont} bind def +/scf {scalefont} bind def +/sw {stringwidth} bind def +/tr {translate} bind def +/tnt {dup dup currentrgbcolor + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add + 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb} + bind def +/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul + 4 -2 roll mul srgb} bind def +/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def +/$F2psEnd {$F2psEnteredState restore end} def + +/pageheader { +save +newpath 0 174 moveto 0 0 lineto 367 0 lineto 367 174 lineto closepath clip newpath +-161.1 355.1 translate +1 -1 scale +$F2psBegin +10 setmiterlimit +0 slj 0 slc + 0.06299 0.06299 sc +} bind def +/pagefooter { +$F2psEnd +restore +} bind def +%%EndProlog +pageheader +% +% Fig objects follow +% +% +% here starts figure with depth 50 +% Polyline +0 slj +0 slc +7.500 slw +n 4819 3540 m 5460 4181 l 6101 3540 l 5460 2899 l 4819 3540 l + cp gs col0 s gr +% Polyline +gs clippath +4634 3585 m 4785 3585 l 4785 3525 l 4634 3525 l 4634 3525 l 4754 3555 l 4634 3585 l cp +eoclip +n 3960 3555 m + 4770 3555 l gs col0 s gr gr + +% arrowhead +n 4634 3585 m 4754 3555 l 4634 3525 l 4634 3585 l cp gs 0.00 setgray ef gr col0 s +% Polyline +gs clippath +6839 3585 m 6990 3585 l 6990 3525 l 6839 3525 l 6839 3525 l 6959 3555 l 6839 3585 l cp +eoclip +n 6165 3555 m + 6975 3555 l gs col0 s gr gr + +% arrowhead +n 6839 3585 m 6959 3555 l 6839 3525 l 6839 3585 l cp gs 0.00 setgray ef gr col0 s +% Polyline +n 2644 3240 m 2569 3240 2569 3802 75 arcto 4 {pop} repeat + 2569 3877 3835 3877 75 arcto 4 {pop} repeat + 3910 3877 3910 3315 75 arcto 4 {pop} repeat + 3910 3240 2644 3240 75 arcto 4 {pop} repeat + cp gs col0 s gr +% Polyline +n 7095 3240 m 7020 3240 7020 3806 75 arcto 4 {pop} repeat + 7020 3881 8294 3881 75 arcto 4 {pop} repeat + 8369 3881 8369 3315 75 arcto 4 {pop} repeat + 8369 3240 7095 3240 75 arcto 4 {pop} repeat + cp gs col0 s gr +% Polyline +gs clippath +5460 4904 m 5460 5055 l 5520 5055 l 5520 4904 l 5520 4904 l 5490 5024 l 5460 4904 l cp +eoclip +n 5490 4230 m + 5490 5040 l gs col0 s gr gr + +% arrowhead +n 5460 4904 m 5490 5024 l 5520 4904 l 5460 4904 l cp gs 0.00 setgray ef gr col0 s +% Polyline +n 5028 5067 m 4953 5067 4953 5550 75 arcto 4 {pop} repeat + 4953 5625 5905 5625 75 arcto 4 {pop} repeat + 5980 5625 5980 5142 75 arcto 4 {pop} repeat + 5980 5067 5028 5067 75 arcto 4 {pop} repeat + cp gs col0 s gr +% Polyline +gs clippath +4305 3736 m 4305 3585 l 4245 3585 l 4245 3736 l 4245 3736 l 4275 3616 l 4305 3736 l cp +eoclip +n 4905 5355 m 4275 5355 l + 4275 3600 l gs col0 s gr gr + +% arrowhead +n 4305 3736 m 4275 3616 l 4245 3736 l 4305 3736 l cp gs 0.00 setgray ef gr col0 s +/Times-Roman ff 180.00 scf sf +5265 3375 m +gs 1 -1 sc (More) col0 sh gr +/Times-Roman ff 180.00 scf sf +5265 3630 m +gs 1 -1 sc (Data) col0 sh gr +/Times-Roman ff 180.00 scf sf +5265 3885 m +gs 1 -1 sc ( ?) col0 sh gr +/Times-Roman ff 180.00 scf sf +6210 3465 m +gs 1 -1 sc (No) col0 sh gr +/Times-Roman ff 180.00 scf sf +5535 4455 m +gs 1 -1 sc (Yes) col0 sh gr +/Times-Roman ff 180.00 scf sf +2745 3645 m +gs 1 -1 sc (Initialization) col0 sh gr +/Times-Roman ff 180.00 scf sf +7290 3600 m +gs 1 -1 sc (Clean Up) col0 sh gr +/Times-Roman ff 180.00 scf sf +5130 5400 m +gs 1 -1 sc (Process) col0 sh gr +% here ends figure; +pagefooter +showpage +%%Trailer +%EOF diff --git a/doc/process-flow.fig b/doc/process-flow.fig new file mode 100644 index 0000000..b661313 --- /dev/null +++ b/doc/process-flow.fig @@ -0,0 +1,37 @@ +#FIG 3.2 Produced by xfig version 3.2.5b +Landscape +Center +Metric +A4 +100.00 +Single +-2 +1200 2 +2 3 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 6 + 4819 3540 5460 4181 6101 3540 5460 2899 4819 3540 4819 3540 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 + 1 1 1.00 60.00 120.00 + 3960 3555 4770 3555 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 + 1 1 1.00 60.00 120.00 + 6165 3555 6975 3555 +2 4 0 1 0 7 50 -1 -1 0.000 0 0 5 0 0 5 + 2569 3240 2569 3877 3910 3877 3910 3240 2569 3240 +2 4 0 1 0 7 50 -1 -1 0.000 0 0 5 0 0 5 + 7020 3240 7020 3881 8369 3881 8369 3240 7020 3240 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 2 + 1 1 1.00 60.00 120.00 + 5490 4230 5490 5040 +2 4 0 1 0 7 50 -1 -1 0.000 0 0 5 0 0 5 + 4953 5067 4953 5625 5980 5625 5980 5067 4953 5067 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 1 0 3 + 1 1 1.00 60.00 120.00 + 4905 5355 4275 5355 4275 3600 +4 0 0 50 -1 0 12 0.0000 4 150 480 5265 3375 More\001 +4 0 0 50 -1 0 12 0.0000 4 150 420 5265 3630 Data\001 +4 0 0 50 -1 0 12 0.0000 4 150 270 5265 3885 ?\001 +4 0 0 50 -1 0 12 0.0000 4 150 270 6210 3465 No\001 +4 0 0 50 -1 0 12 0.0000 4 150 330 5535 4455 Yes\001 +4 0 0 50 -1 0 12 0.0000 4 150 1035 2745 3645 Initialization\001 +4 0 0 50 -1 0 12 0.0000 4 195 810 7290 3600 Clean Up\001 +4 0 0 50 -1 0 12 0.0000 4 150 690 5130 5400 Process\001 diff --git a/doc/process-flow.pdf b/doc/process-flow.pdf new file mode 100644 index 0000000000000000000000000000000000000000..23d567d2fab72a15e507217d664ad6f8257d8819 GIT binary patch literal 6558 zcmb_Bc_38V|1D3viISAiautR&?(8!>re|NWWtXL9xif}Y%pyZ+(L$CItw>6xT|Grb zNt?8(P_h=KRFYRzQhw)7w7lN$z3(6I4(6WoS=}`q?yS9N!ZpdsDQt42YNM9-viLCf)X9C5C&_4CoIMYMC_Qn$4UEoRqpG;%OT?b5rM zti^&k<9G7kYrc15+Kf{e_XeHyS!iHi6?{9nWlxCPp_C6>6d6TToA$38o9&jdrsP&V zIh}8lQ)G;}y=vJA4lhCVcaGMP&@o-S-bV+{`RnE`TXyAnvU-Tb_|Mtzcf_r#JY}`H z>!PhwmBtfK&lxG5JlC7Y?K7{tW=!;mGC0K5(SJ35wCVAl*v&n=E}0NXAv=O6ZTI0$ zykN7@^U3?XtMgeeM$OgA)TZZ^k8Xf9$D~xqM?mKKwOOhe>Y3H_c{__t`H0hN?pdGF zyEM%z6Cm9eZyy?F8|_P>$_oDIHNIk%?t<9wI|f;#o06v_1{qb{Ua_U_#0W}P#r^4# zCe$Ugt%8_5O!8&{qfgkJUY6 zoOouLgzsr!{hZvEd6>Jk=kbFh_ujYFj5%4#JvC;rObbUhs9#InUyxxv*}~(om%sm` zS@T_vm^zD>blDP8CpOG5NKz+`V?x@T1<8v&;!NgHT{fuXu$*j1JT!B1NVi)jQ}w;I z`iOzJ(zwCxZIK%%Y1;30nHT4zjc{CDwd&~hP|r4AUIAGn?@3cGcRv%3GW#j5Fz=@k8z>^G~c z<6}4VAAdGKEHTL0hcRYDZP_w$bJ*_pzJ-m|qQd2k4?nt5wZhW!T9$hEmTKtJgO-k6 zajo5mpVIQO?!gRNiH;|Ap*B-%W@by7KMyW`*N83OPf9CaC|TJ)E;a4u1UO~IsSVFx zR_m{`)G=1y!f?80-nPo=)u(s~t#yyKTf+3da^#?-@Mz(y!s42`^2U#cvLhwz8?*8| z-50k!dC>Vme*Emc?!g0dJl39gCd;ticIeW=5?X0WX;8lb5y>GE zn%o%J8Ix+5bTR6^hs0U!~u;+ z{K|_&LM?}W=yZ!O5DbNa#@Lt7H{5S;N(kTwxB{&2|Dq5g4K>T~HwBM}z%K^<22lv4 zk${|G93>}|0~%-|aJ2A6Jg{hyjY!7-I`)ZX$W20FDWrwhpX#+TLhz*$vFj0qtY%_uFV0+jF zc85J+FW3(bf|)QIMqoZHfJLwvj)Eo8h)m8Gi(n}%gJn@nHUi7xI8)^c!QqUMfH+`_ z@1qtS5839+@%{bj4V3)eqISc_J&{bXU@*QO>_WdKfj&>CF$jjO+a2z0+)Li=a_{6l zv)ykTpLVF+KCs9%K^kd8u#JE=%~LZ7aK7-Q(!pTmFSfQxqX^-7dA<((x|zkrVU4bl zW8?jKjY8pp&~m%+OLBMAcRiTVIQOZ=)1|HNmUef?x3+#{Pq2}xO-`AVV|X)D`-t zV2OlW6l|QyO_6aBmD3JwpH#=YjvKSSs~OImI$4}~ZI6nIbd5stR;%av)vJDH+bSEH z@0N`=a%ii(db#w;{5HB|w_$;Oarx`z0cr_~*$Z>^LN$E?eaqO(7nenp7}{jbnJAu_ zq_ggqHkG!ZHlsER*7%L~h7;$lJ7TXs!Di1yvvtBtvsu{V>yxm7tGB7K>9Z2lR3z(8 zuCJqESst+d@f|jY^U`c~O72Ola>}DJPuqoC9CVnw@kN!+)f(SuH9rku?ZCXlp2m_J zhNU~=)-FF$vEcqF&IX4a#=Bo=8a}6(`t8wsTD)tMW3<_Om!(=emS1dcP<@=_RBUHI zPxBJr@4!lT)kd#|387}G>8I4=H^;_azfP<>+I3;W#^a15ZU;SQ>)>g6ar^7654Wh+ ze_oNMzkd$nlka2V0_Vi#r_~bMZkK-^JyueGt*~=p$_eS`$MwWGgPXC)$BtErR;w@@ zm!24y++EXyn6G==Lk1*ACQVRd0yY#bZ3E+k@m`p!-u?T%J)w4tVxmV zI@kPo#pIFldfd5w$78nhrgiT5xarx_w9q%WPx@0GvDWTlhhtY3B^{o*S#e{X|NY1X zk7j9gJ17YLse>O*ePrcB9PVE3w*F=5b*o(Z)NQ(+1T0cT zJJgdBH2!$Mr(WUm%WWBSp|p?HR<~okQR|3~^E6&%cP26|n6>z^aD>g&ml8z7FzxE} z5!_5g<<|E)?@ycMC%?4W)g6`HbUKq0nEz(#!S%!(-s|}W0d{k9E*b4i?71;H!l2dr z{x6duPpU4_zUZ`CUuW;H#u+8fYi=gJb5(5!DG;uVaW2E`h^u4MH4JkELECan&m_9_RwaiBGhA0}6?H6uKUOcp|FO=Pzqp~}S*m^cJKoXFpK5)}@9Or4 zXSK2Xrxd=L!0j!bBud~DgzqRAG;fdHZ05Je&}5D``yrx zmQhCi_2CCr;BI{GWPDz?rDIoh;nsQ8W3d^D_eQyouzq*GUx(=Z=fb;3MiPU0J?m^= zKTUNSe8`F?SBZ9ayy?=|a>gIp5Oj^?ARnFJn=jeAz9;v%hEVKvvSO0fR;YFR*k&gj z*DmE)XbtO+k)3?m+qb46cRzi&OyKWMyc$woV(65e$5A)MpNcl0ePM5OVp!SQe9@Yo zE$#a6k8IM z?hkvL65bXXTiQQGK6Z@f+nlp)n~%QITKjO~+WE8Vbs{cuEte5fX=}1|i+V)n7Yy$& zXk4VFXXZA^ah0K|+1aw>$L^hJ#`&=f-}`ms+Vrw)@m;ax{*t0Aj$^Fy<86g0yS)&T zkrf8f?|z#(VAANVXTTRUA^_wOERc}O^z@rxfq(^`g_!UQMQ27 z@FYRYeS2_ks=~lG;gM@wV{J|D?dv-qU4C~_A@(Y5Z9hb|EYiEm%8w6R{mx(t<=sJR zqtA1AqteZa_gtP->RM{G!#sxFwXwl?e%jt*-K?vkolBzj{5Ch}l>VIwJqNGNadA1| zh$+k{+jQ#Djh;ulZrza>R2O$UC$dZi4CTeSdW*I^+q|>KhI`cOSu*)gj7s|HKQnpu zX=+#24k%h)vscHMc)%~}t*O20>mL_Xc4!-o(mnlRV(Pha`Nwmu`{r^cO~diG#B7RA zczCMuL9|6*Q~!xgcXLMXu66scxZe4$XZ+Na55(%lJ7142wZ0|lo}&9_P1*9yD|-7Z zx77zZHMdpon^~V%BO;S(doAwVo2B<#=KPV*MU8?PQ<44ioZdzj^~x>$s(00FYVy2E zohC5iZJnv`&u?19y49KUY(v^X^Y`obJbFaLbXLEA_dzvioCfr{ zIqLV>uGIx+G(%4I{U%&|=&S_FJL<7+%)u@{;Ux1kBh@yS{*hTvd|bz!b*Zu*-FK}* zT}qwa=o77%J}^=T=0sSuocCP}(+lrFIJgb2C&l1IWkH|5YxT3`SZx1i3 zmqx{oGwRQ~8?ho>N}XKM?|RX=y*gPa@KU{TD|3Ew-m884L{pdH+8^xw^#FNxU2UC? z>Y0sIdDsSz)33`qZ?Ef&cC-7uB7byIB%G* zKsTt?mCTHQS3cc7V1KOH#I)MXxz(sqosiyPN)PBD^{HO?WS;OF4!4s`zz(=w$y)F> zwfxzOq!#I1%;1C~hE;TX^sc8Tp3G^QH6!3+|3|}Y-Q0ovrY&dgo#8_9{u-pYVRq?< z?_Alg`>da;eSd$^1*439j9*>1kBfSvZ-Qpi`J|8!vp%=1VV^y$uTwavXfx0cAT1~< z>z?v*ZcHC>#n~Df>&-3Ra-aW6yFEqOxZ7_1 zx8j_R=C*z;*m}~%!NvB2Ig({?gzB@XxvJXC+%l)zyr=(6Q<(S>VeLV0os;+1WQK%v zHyyy1-K?nanO5;et!*KrwIUw9*#21RDXW_A@3_PD&bKREpu5}f{f$5(6TjZytmZ1f zO)(OYLo9^H7g=MwOUtnkpJR;;pt$4RqwJ7yzH^)u@rm>BWyeLbEjZY@42;!WCa5tH zoPrsJ<0|_;G6>vut!LVKyE)E85fqjRVU!S*U64X35XmeR)>tKpC3r`tVJxIXkw;o% z1KqtKxmYZS7Lcb@gdg~oOe8Z`>SWFq3t@gB zOfbj8!-9tEFmRuSP{B-=I9d+YfY7)s0+EHI5ZDwPfq<}Zc<|sTbRwS30aXBj%^8*y z^__-4hynm0iv&yn-Yh{i&533sQfsV}mmB01E|$r^lzTY9s?r zCICG-Y)h_KDrBPZ92EtsQl_$O1i^@9SOK7%FBc#TWxm-6I{d^CS71xyjo8mqu@ z5H2%XAjdMIKraZ9$#7hOIK~{f?TZ@(e8!g-B|ZF&=ifL_zV8JYcMd-fAsu! zjJ|D^U<0jpoBUl~n}Wg~%@q*cXttQxTcW9kC*Y|B8tCGnS%$^q zu>cKZdj33))Y#csv2L1pkUh`H7Z5B>#j54l~e%`jHk`5VYt1 zGDoEUj7K8;GzYx!lYV3h0W`3N`N^eB&`gnn|9?QR4?hm{JIN62Ef#~uB-&kpU>6Zr z3@JM;pzC7~1zXW*78DwtWNS;bw<9>xEgZ;H2OE1w8pVM~COXimjDN=nMSGqyIa4ZE RI*3XjQZPnF4xWyf{{yPJ{vQAU literal 0 HcmV?d00001 diff --git a/doc/rflashlight-small.xpic b/doc/rflashlight-small.xpic new file mode 100644 index 0000000..9e78a3f --- /dev/null +++ b/doc/rflashlight-small.xpic @@ -0,0 +1,26 @@ +#! /usr/X11R6/bin/xpic +80 48 160 80 8 +5 36 96 48 112 80 0 0 +104 64 8 16 +1 37 104 48 128 56 0 0 +2 + 104 48 128 56 +1 38 104 72 128 80 0 0 +2 + 104 80 128 72 +2 39 128 56 128 72 0 0 +2 + 128 56 128 72 +3 40 128 56 160 72 0 0 +1 41 80 72 80 72 0 0 +2 + 80 72 80 72 +1 42 80 72 96 80 0 0 +2 + 80 80 96 72 +1 43 80 64 96 64 0 0 +2 + 80 64 96 64 +1 45 80 48 96 56 0 0 +2 + 96 56 80 48 diff --git a/doc/rflashlight.eps b/doc/rflashlight.eps new file mode 100644 index 0000000..28cb7e2 --- /dev/null +++ b/doc/rflashlight.eps @@ -0,0 +1,141 @@ +%! +%%Creator: arnold@skeeve (Aharon Robbins) +%%Title: flashlight.small.xpic (xpic) +%%CreationDate: Tue Oct 24 14:41:28 2000 +%%Pages: 1 +%%BoundingBox: 0 0 72 28.8 +% (in inches) at 0 0, width 1, height 0.4 +%%EndComments +% Prolog for xpic to PostScript converter +% Author: Mark Moraes +% $Header: x2ps.pro,v 1.2 88/03/19 16:50:09 moraes Exp +% %d D - change style SOLID, DOTTED, SHORT-DASH, LONG-DASH, DOT-DASH +% %s F - change font to fontname +% %d S - change size (font size in points) +% (%s) rj %d t - text right just. (%d is TOPLINE, MIDLINE, BOTLINE) +% (%s) lj %d t - text left just. (%d is TOPLINE, MIDLINE, BOTLINE) +% (%s) ce %d t - text centered (%d is TOPLINE, MIDLINE, BOTLINE) +% %d %d l - lineto +% %d %d m - moveto +% %d %d s - spline segment +% x - flush line, spline +% b - box +% e - ellipse +% %d ss - setscale +% %d W - change linewidth +% getpagesize - gets the values of PAGEHEIGHT and PAGEWIDTH +% %d %d flip - translate by %d, PAGEHEIGHT - %d (this +% transforms to X windows coordinates) +save 50 dict begin /xpic exch def +/StartXpic {newpath 0 0 moveto [] 0 setdash 0 setgray 1 setlinecap} def +% Set defaults +/fontname /Times-Roman def +/ptsize 12 def +% halign has the values for MIDLINE, TOPLINE, BOTLINE +/halign 3 array def +/s {rcurveto} def +/x {stroke} def +/l {lineto} def +/m {moveto} def +/b { + /ury exch def /urx exch def /lly exch def /llx exch def + llx lly moveto urx lly lineto urx ury lineto + llx ury lineto llx lly lineto stroke +} def +/mtrx matrix def +/e { + /yc exch def /xc exch def /yrad exch def /xrad exch def + xc xrad add yc moveto + /savematrix mtrx currentmatrix def + xc yc translate + xrad yrad scale + 0 0 1 0 360 arc + savematrix setmatrix stroke +} def +% The next three take the text string, and moveto the right horiz. position +% leaving the string on the stack. +/lj {} def +/rj {dup stringwidth pop neg 0 rmoveto} def +/ce {dup stringwidth pop 2 div neg 0 rmoveto} def +% And this is invoked after one of the three above, and +% computes the vert. pos, and then displays the string. +/t {halign exch get 0 exch rmoveto show newpath} def +% Store an array of patterns in /styles - a pattern is an array consisting +% of an array and an offset. Corresp to xpic patterns +% solid, dotted, short-dashed, long-dashed, dot-dashed +/styles [ [] 0 ] [ [1 3] 0 ] [ [4 4] 0 ] [ [8 4] 0 ] [ [1 4 4 4] 0 ] + 5 array astore def +% change style to arg. +/D {stroke styles exch get aload pop setdash newpath} def +/W {stroke 0.5 mul setlinewidth newpath} def +% fontbox takes a fontname off the stack, and returns an array +% containing the values of the bottom line of the bounding box, the +% mid line of the bounding box, and the top line of the bounding box +% of that font, taken from the baseline, scaled to a font of size 1 +/fontbox { + findfont dup /FontMatrix get /fm exch def /FontBBox get aload pop + /ytop exch def pop /ybot exch def pop + /ymid ytop ybot sub 2 div def + 0 ybot fm dtransform exch pop % botline + dup neg exch % midline - this works better than (ytop-ybot)/2! + 0 ytop fm dtransform exch pop exch %topline + % now in the order midline, topline, botline. + 3 array astore +} def +% select font +/F { + dup /fontname exch def fontbox + /thisfontbox exch def SF +} def +% set point size +/S {/ptsize exch def SF} def +% actually set font +/SF { + fontname findfont ptsize curscale div scalefont setfont + thisfontbox aload pop + 1 1 3 { + pop ptsize mul curscale div neg 3 1 roll + } for + halign astore pop +} def +% sets the scale to 72 / n, where n is on the stack, and stores the value +% in curscale for font scaling +/curscale 1 def +/getpagesize{newpath clippath pathbbox /pageheight exch def + /pagewidth exch def pop pop newpath} def +/flip{pageheight exch sub translate} def +/ss {/curscale exch 72 exch div dup dup scale def} def +/land {90 rotate} def +StartXpic +%%EndProlog +80 ss +0.5 W +0 D +8 16 24 16 e +24 32 m +48 24 l +x +24 0 m +48 8 l +x +48 24 m +0 0 0 -5.33333 0 -16 s +x +48 24 80 8 b +0 8 m +0 8 l +x +0 0 m +16 8 l +x +0 16 m +16 16 l +x +16 24 m +0 32 l +x +%%Trailer +showpage +% Trailer for xpic to PostScript converter +% $Header: x2ps.tra,v 1.2 89/07/02 15:59:53 moraes Exp $ +xpic end restore diff --git a/doc/rflashlight.pdf b/doc/rflashlight.pdf new file mode 100644 index 0000000..72c8561 --- /dev/null +++ b/doc/rflashlight.pdf @@ -0,0 +1,57 @@ +%PDF-1.3 +%Ç쏢 +6 0 obj +<> +stream +xœEQà †ß9'pBQ»+ì­ÛšeYRº%Ûõ'(] ‚ð£îaÔ5üZa‡ÓUðñœð „—fOàyFÁzD›EÌSH|FN)”,hŒ²ù¨äÀS?iWk¬Ö*ڞ%H!F¯Ž¦Ð®®MÁë\m…ø¬ +2±õmƒÆÁ +òt‡”gÉÏH–¿ðëÞXTR»Û쬊š>@ÿŒ2{¤MéWV¶´õó'E€endstream +endobj +7 0 obj +175 +endobj +5 0 obj +<> +/Contents 6 0 R +>> +endobj +3 0 obj +<< /Type /Pages /Kids [ +5 0 R +] /Count 1 +>> +endobj +1 0 obj +<> +endobj +4 0 obj +<> +endobj +8 0 obj +<> +endobj +2 0 obj +<>endobj +xref +0 9 +0000000000 65535 f +0000000478 00000 n +0000000624 00000 n +0000000419 00000 n +0000000526 00000 n +0000000279 00000 n +0000000015 00000 n +0000000260 00000 n +0000000595 00000 n +trailer +<< /Size 9 /Root 1 0 R /Info 2 0 R +>> +startxref +674 +%%EOF diff --git a/doc/setter.outline b/doc/setter.outline new file mode 100644 index 0000000..37e5cbf --- /dev/null +++ b/doc/setter.outline @@ -0,0 +1,77 @@ +%!PS-Adobe-3.0 +% SSC Reference card typesetter outline / cut marks +% +% Copyright (C) 1996, Specialized System Consultants Inc. (SSC) +% +% This file is free software; you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation; either version 2 of the License, or +% (at your option) any later version. +% +% This file is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +% +%! page cut marks and stuff for Pocket References - 10-26-88 - ph +%! modified to move the cut marks onto the page +%! center a string +/inch {72 mul} def +/cshow % stk: string + % center string in space (space us variable) + { + dup stringwidth pop % get length of string + space exch sub 2 div % compute initial space needed + 0 rmoveto % move over + show + } def + +/flashme +{ /space 612 def + 0 0 0 setrgbcolor % always print this stuff + + /Helvetica findfont 12 scalefont setfont + gsave +% for groff (I hope) + -6 -6 translate + 0.2 setlinewidth + + 0.25 inch 10.5 inch moveto + 0.5 inch 10.5 inch lineto + .75 inch 10.75 inch moveto + .75 inch 11 inch lineto + stroke + + 0.25 inch 2 inch moveto + 0.5 inch 2 inch lineto + .75 inch 1.75 inch moveto + .75 inch 1.50 inch lineto + stroke + 4.25 inch 11 inch moveto + 4.25 inch 10.75 inch lineto + stroke + + 4.25 inch 1.75 inch moveto + 4.25 inch 1.5 inch lineto + stroke + + 7.75 inch 1.5 inch moveto + 7.75 inch 1.75 inch lineto + 8 inch 2 inch moveto + 8.25 inch 2 inch lineto + stroke + + 7.75 inch 11 inch moveto + 7.75 inch 10.75 inch lineto + 8 inch 10.5 inch moveto + 8.25 inch 10.5 inch lineto + stroke + grestore + } def + +% actually do something + diff --git a/doc/statist.eps b/doc/statist.eps new file mode 100644 index 0000000..1e1f09f --- /dev/null +++ b/doc/statist.eps @@ -0,0 +1,557 @@ +%!PS-Adobe-2.0 +%%Creator: gnuplot 3.7 patchlevel 0.1 +%%CreationDate: Sun Jan 7 14:23:12 2001 +%%DocumentFonts: (atend) +%%BoundingBox: 50 50 554 770 +%%Orientation: Portrait +%%Pages: (atend) +%%EndComments +/gnudict 256 dict def +gnudict begin +/Color true def +/Solid false def +/gnulinewidth 5.000 def +/userlinewidth gnulinewidth def +/vshift -46 def +/dl {10 mul} def +/hpt_ 31.5 def +/vpt_ 31.5 def +/hpt hpt_ def +/vpt vpt_ def +/M {moveto} bind def +/L {lineto} bind def +/R {rmoveto} bind def +/V {rlineto} bind def +/vpt2 vpt 2 mul def +/hpt2 hpt 2 mul def +/Lshow { currentpoint stroke M + 0 vshift R show } def +/Rshow { currentpoint stroke M + dup stringwidth pop neg vshift R show } def +/Cshow { currentpoint stroke M + dup stringwidth pop -2 div vshift R show } def +/UP { dup vpt_ mul /vpt exch def hpt_ mul /hpt exch def + /hpt2 hpt 2 mul def /vpt2 vpt 2 mul def } def +/DL { Color {setrgbcolor Solid {pop []} if 0 setdash } + {pop pop pop Solid {pop []} if 0 setdash} ifelse } def +/BL { stroke gnulinewidth 2 mul setlinewidth } def +/AL { stroke gnulinewidth 2 div setlinewidth } def +/UL { gnulinewidth mul /userlinewidth exch def } def +/PL { stroke userlinewidth setlinewidth } def +/LTb { BL [] 0 0 0 DL } def +/LTa { AL [1 dl 2 dl] 0 setdash 0 0 0 setrgbcolor } def +/LT0 { PL [] 1 0 0 DL } def +/LT1 { PL [4 dl 2 dl] 0 1 0 DL } def +/LT2 { PL [2 dl 3 dl] 0 0 1 DL } def +/LT3 { PL [1 dl 1.5 dl] 1 0 1 DL } def +/LT4 { PL [5 dl 2 dl 1 dl 2 dl] 0 1 1 DL } def +/LT5 { PL [4 dl 3 dl 1 dl 3 dl] 1 1 0 DL } def +/LT6 { PL [2 dl 2 dl 2 dl 4 dl] 0 0 0 DL } def +/LT7 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 1 0.3 0 DL } def +/LT8 { PL [2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 2 dl 4 dl] 0.5 0.5 0.5 DL } def +/Pnt { stroke [] 0 setdash + gsave 1 setlinecap M 0 0 V stroke grestore } def +/Dia { stroke [] 0 setdash 2 copy vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V closepath stroke + Pnt } def +/Pls { stroke [] 0 setdash vpt sub M 0 vpt2 V + currentpoint stroke M + hpt neg vpt neg R hpt2 0 V stroke + } def +/Box { stroke [] 0 setdash 2 copy exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V closepath stroke + Pnt } def +/Crs { stroke [] 0 setdash exch hpt sub exch vpt add M + hpt2 vpt2 neg V currentpoint stroke M + hpt2 neg 0 R hpt2 vpt2 V stroke } def +/TriU { stroke [] 0 setdash 2 copy vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V closepath stroke + Pnt } def +/Star { 2 copy Pls Crs } def +/BoxF { stroke [] 0 setdash exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V closepath fill } def +/TriUF { stroke [] 0 setdash vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V closepath fill } def +/TriD { stroke [] 0 setdash 2 copy vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V closepath stroke + Pnt } def +/TriDF { stroke [] 0 setdash vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V closepath fill} def +/DiaF { stroke [] 0 setdash vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V closepath fill } def +/Pent { stroke [] 0 setdash 2 copy gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + closepath stroke grestore Pnt } def +/PentF { stroke [] 0 setdash gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + closepath fill grestore } def +/Circle { stroke [] 0 setdash 2 copy + hpt 0 360 arc stroke Pnt } def +/CircleF { stroke [] 0 setdash hpt 0 360 arc fill } def +/C0 { BL [] 0 setdash 2 copy moveto vpt 90 450 arc } bind def +/C1 { BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 90 arc closepath fill + vpt 0 360 arc closepath } bind def +/C2 { BL [] 0 setdash 2 copy moveto + 2 copy vpt 90 180 arc closepath fill + vpt 0 360 arc closepath } bind def +/C3 { BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 180 arc closepath fill + vpt 0 360 arc closepath } bind def +/C4 { BL [] 0 setdash 2 copy moveto + 2 copy vpt 180 270 arc closepath fill + vpt 0 360 arc closepath } bind def +/C5 { BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 90 arc + 2 copy moveto + 2 copy vpt 180 270 arc closepath fill + vpt 0 360 arc } bind def +/C6 { BL [] 0 setdash 2 copy moveto + 2 copy vpt 90 270 arc closepath fill + vpt 0 360 arc closepath } bind def +/C7 { BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 270 arc closepath fill + vpt 0 360 arc closepath } bind def +/C8 { BL [] 0 setdash 2 copy moveto + 2 copy vpt 270 360 arc closepath fill + vpt 0 360 arc closepath } bind def +/C9 { BL [] 0 setdash 2 copy moveto + 2 copy vpt 270 450 arc closepath fill + vpt 0 360 arc closepath } bind def +/C10 { BL [] 0 setdash 2 copy 2 copy moveto vpt 270 360 arc closepath fill + 2 copy moveto + 2 copy vpt 90 180 arc closepath fill + vpt 0 360 arc closepath } bind def +/C11 { BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 180 arc closepath fill + 2 copy moveto + 2 copy vpt 270 360 arc closepath fill + vpt 0 360 arc closepath } bind def +/C12 { BL [] 0 setdash 2 copy moveto + 2 copy vpt 180 360 arc closepath fill + vpt 0 360 arc closepath } bind def +/C13 { BL [] 0 setdash 2 copy moveto + 2 copy vpt 0 90 arc closepath fill + 2 copy moveto + 2 copy vpt 180 360 arc closepath fill + vpt 0 360 arc closepath } bind def +/C14 { BL [] 0 setdash 2 copy moveto + 2 copy vpt 90 360 arc closepath fill + vpt 0 360 arc } bind def +/C15 { BL [] 0 setdash 2 copy vpt 0 360 arc closepath fill + vpt 0 360 arc closepath } bind def +/Rec { newpath 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto + neg 0 rlineto closepath } bind def +/Square { dup Rec } bind def +/Bsquare { vpt sub exch vpt sub exch vpt2 Square } bind def +/S0 { BL [] 0 setdash 2 copy moveto 0 vpt rlineto BL Bsquare } bind def +/S1 { BL [] 0 setdash 2 copy vpt Square fill Bsquare } bind def +/S2 { BL [] 0 setdash 2 copy exch vpt sub exch vpt Square fill Bsquare } bind def +/S3 { BL [] 0 setdash 2 copy exch vpt sub exch vpt2 vpt Rec fill Bsquare } bind def +/S4 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def +/S5 { BL [] 0 setdash 2 copy 2 copy vpt Square fill + exch vpt sub exch vpt sub vpt Square fill Bsquare } bind def +/S6 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill Bsquare } bind def +/S7 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt vpt2 Rec fill + 2 copy vpt Square fill + Bsquare } bind def +/S8 { BL [] 0 setdash 2 copy vpt sub vpt Square fill Bsquare } bind def +/S9 { BL [] 0 setdash 2 copy vpt sub vpt vpt2 Rec fill Bsquare } bind def +/S10 { BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt Square fill + Bsquare } bind def +/S11 { BL [] 0 setdash 2 copy vpt sub vpt Square fill 2 copy exch vpt sub exch vpt2 vpt Rec fill + Bsquare } bind def +/S12 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill Bsquare } bind def +/S13 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill + 2 copy vpt Square fill Bsquare } bind def +/S14 { BL [] 0 setdash 2 copy exch vpt sub exch vpt sub vpt2 vpt Rec fill + 2 copy exch vpt sub exch vpt Square fill Bsquare } bind def +/S15 { BL [] 0 setdash 2 copy Bsquare fill Bsquare } bind def +/D0 { gsave translate 45 rotate 0 0 S0 stroke grestore } bind def +/D1 { gsave translate 45 rotate 0 0 S1 stroke grestore } bind def +/D2 { gsave translate 45 rotate 0 0 S2 stroke grestore } bind def +/D3 { gsave translate 45 rotate 0 0 S3 stroke grestore } bind def +/D4 { gsave translate 45 rotate 0 0 S4 stroke grestore } bind def +/D5 { gsave translate 45 rotate 0 0 S5 stroke grestore } bind def +/D6 { gsave translate 45 rotate 0 0 S6 stroke grestore } bind def +/D7 { gsave translate 45 rotate 0 0 S7 stroke grestore } bind def +/D8 { gsave translate 45 rotate 0 0 S8 stroke grestore } bind def +/D9 { gsave translate 45 rotate 0 0 S9 stroke grestore } bind def +/D10 { gsave translate 45 rotate 0 0 S10 stroke grestore } bind def +/D11 { gsave translate 45 rotate 0 0 S11 stroke grestore } bind def +/D12 { gsave translate 45 rotate 0 0 S12 stroke grestore } bind def +/D13 { gsave translate 45 rotate 0 0 S13 stroke grestore } bind def +/D14 { gsave translate 45 rotate 0 0 S14 stroke grestore } bind def +/D15 { gsave translate 45 rotate 0 0 S15 stroke grestore } bind def +/DiaE { stroke [] 0 setdash vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V closepath stroke } def +/BoxE { stroke [] 0 setdash exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V closepath stroke } def +/TriUE { stroke [] 0 setdash vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V closepath stroke } def +/TriDE { stroke [] 0 setdash vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V closepath stroke } def +/PentE { stroke [] 0 setdash gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + closepath stroke grestore } def +/CircE { stroke [] 0 setdash + hpt 0 360 arc stroke } def +/Opaque { gsave closepath 1 setgray fill grestore 0 setgray closepath } def +/DiaW { stroke [] 0 setdash vpt add M + hpt neg vpt neg V hpt vpt neg V + hpt vpt V hpt neg vpt V Opaque stroke } def +/BoxW { stroke [] 0 setdash exch hpt sub exch vpt add M + 0 vpt2 neg V hpt2 0 V 0 vpt2 V + hpt2 neg 0 V Opaque stroke } def +/TriUW { stroke [] 0 setdash vpt 1.12 mul add M + hpt neg vpt -1.62 mul V + hpt 2 mul 0 V + hpt neg vpt 1.62 mul V Opaque stroke } def +/TriDW { stroke [] 0 setdash vpt 1.12 mul sub M + hpt neg vpt 1.62 mul V + hpt 2 mul 0 V + hpt neg vpt -1.62 mul V Opaque stroke } def +/PentW { stroke [] 0 setdash gsave + translate 0 hpt M 4 {72 rotate 0 hpt L} repeat + Opaque stroke grestore } def +/CircW { stroke [] 0 setdash + hpt 0 360 arc Opaque stroke } def +/BoxFill { gsave Rec 1 setgray fill grestore } def +end +%%EndProlog +%%Page: 1 1 +gnudict begin +gsave +50 50 translate +0.100 0.100 scale +0 setgray +newpath +(Helvetica) findfont 140 scalefont setfont +1.000 UL +LTb +574 280 M +63 0 V +4165 0 R +-63 0 V +490 280 M +(-0.3) Rshow +574 1245 M +63 0 V +4165 0 R +-63 0 V +-4249 0 R +(-0.2) Rshow +574 2209 M +63 0 V +4165 0 R +-63 0 V +-4249 0 R +(-0.1) Rshow +574 3174 M +63 0 V +4165 0 R +-63 0 V +-4249 0 R +(0) Rshow +574 4138 M +63 0 V +4165 0 R +-63 0 V +-4249 0 R +(0.1) Rshow +574 5103 M +63 0 V +4165 0 R +-63 0 V +-4249 0 R +(0.2) Rshow +574 6067 M +63 0 V +4165 0 R +-63 0 V +-4249 0 R +(0.3) Rshow +574 7032 M +63 0 V +4165 0 R +-63 0 V +-4249 0 R +(0.4) Rshow +574 280 M +0 63 V +0 6689 R +0 -63 V +574 140 M +(-10) Cshow +1631 280 M +0 63 V +0 6689 R +0 -63 V +0 -6829 R +(-5) Cshow +2688 280 M +0 63 V +0 6689 R +0 -63 V +0 -6829 R +(0) Cshow +3745 280 M +0 63 V +0 6689 R +0 -63 V +0 -6829 R +(5) Cshow +4802 280 M +0 63 V +0 6689 R +0 -63 V +0 -6829 R +(10) Cshow +1.000 UL +LTb +574 280 M +4228 0 V +0 6752 V +-4228 0 V +574 280 L +2688 2209 M +(p\(m1=m2\) =0.0863798346775753) Lshow +2688 1245 M +(p\(v1=v2\) =0.31647637745891) Lshow +1.000 UL +LT0 +4151 6899 M +(sample 1) Rshow +4235 6899 M +399 0 V +574 3174 M +43 0 V +42 0 V +43 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +43 0 V +42 1 V +43 2 V +43 4 V +42 8 V +43 13 V +43 24 V +42 41 V +43 65 V +43 101 V +43 146 V +42 205 V +43 271 V +43 340 V +42 404 V +43 450 V +43 470 V +43 452 V +42 390 V +43 288 V +43 153 V +42 0 V +43 -153 V +43 -288 V +42 -390 V +43 -452 V +43 -470 V +43 -450 V +42 -404 V +43 -340 V +43 -271 V +42 -205 V +43 -146 V +43 -101 V +43 -65 V +42 -41 V +43 -24 V +43 -13 V +42 -8 V +43 -4 V +43 -2 V +42 -1 V +43 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +43 0 V +42 0 V +43 0 V +1.000 UL +LT1 +4151 6759 M +(sample 2) Rshow +4235 6759 M +399 0 V +574 3174 M +43 0 V +42 0 V +43 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +42 0 V +43 1 V +43 1 V +43 1 V +42 3 V +43 4 V +43 6 V +42 9 V +43 13 V +43 19 V +42 27 V +43 37 V +43 51 V +43 66 V +42 85 V +43 106 V +43 130 V +42 155 V +43 179 V +43 201 V +43 219 V +42 231 V +43 236 V +43 229 V +42 214 V +43 187 V +43 149 V +42 104 V +43 52 V +43 -3 V +43 -57 V +42 -109 V +43 -154 V +43 -189 V +42 -216 V +43 -231 V +43 -235 V +43 -231 V +42 -217 V +43 -199 V +43 -177 V +42 -152 V +43 -127 V +43 -104 V +42 -83 V +43 -65 V +43 -49 V +43 -36 V +42 -26 V +43 -19 V +43 -12 V +42 -9 V +43 -6 V +43 -3 V +43 -3 V +42 -1 V +43 -1 V +43 -1 V +42 0 V +43 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +42 0 V +43 0 V +43 0 V +43 0 V +42 0 V +43 0 V +stroke +grestore +end +showpage +%%Trailer +%%DocumentFonts: Helvetica +%%Pages: 1 diff --git a/doc/statist.jpg b/doc/statist.jpg new file mode 100644 index 0000000000000000000000000000000000000000..92428f257344dc6de71f04bf67676ce45189c2d6 GIT binary patch literal 20400 zcmeIa2Ut{Dwl;i_oFz%lAQ>d*C>hC;L69QnjKo3|6eI`;NRXU!jshY`&N+jUGm-_W z>Mwhy@9nnlbkFoWckcb>zs0kus&n?)b#_>5z3W};Y}gEJ1-Pv&uOts3AOHXY{11RZ zfi7)lD-Z9-Zk8e<`noi_mTvC0&Q3JEoZR;w)6i&HdWq0*^KkJ9a|!d&Fl(qO(6~JI z0NK!RbMmlY{O6U{PM$6f&K@)mY@Ixx(0KhvBZ7aa?qKO<=|FRjlN$r$zLuQyLv<|? znt$-eXlOJ&A3NB3_|S;c2=cSjXgfMPd)U}IS;N2I!+^~L_W?8%6jT&sG*nbnbaXTf zEJAE7OiV0Nd;(lTN-}CHN-_!x8U{`#8aj4*3JPXH7WRAGe0+S=Ov2(qJYt-@d_3P9 zK|n`G$HK%S!Nw-xp{1bZ`G;Sy4*(t-!pf~6LE->z$M@OukkA(|!@^_Z-oz&)zD-Kb%FfBn%P%M_s;aK3t*dWnZ2H*I z`KhbBr?+oxd}4BHdS-U+^Ox1N^^MJ~?VYd3C#PrU7nk3zzV{0OK>SO$;Q#;9u^;+{ z2k+M{BqT&6)bIU5xaAEmhe=7dvEV<|v;XMWfA(t*z(PcTPaYy3APHPtF=qu~u*H3SlwFutox62q zG40at|)lz^K=it_#7uAonFHjWyzg267);It+OJ;vo#kOfRE*%p|- z;aMUKV9Ye|g+T@9Xag;!Ukn{=r&?5!? z5m(p6B!xPkFF_*V|Bv+Kf8&flEEjXT@;_?#{v2sedRIu!cCUqG4F=@+XRp&UAqtW9 z0(tultHew;#qS)6hVsKaNkInmM}c))A9$*U&81N@QTGWCe^`*69)x<5zgcn7Kh#1P z(S(b_4?-aM>vgMvDlO*@1AdT#--wbFB{I=44EU8CWd9&a!2gDuD!QQJYOYBeBfX(7 zV@Py+Yer?6wDg%wMyO$RU0&?U_x~32Kc&93^q+*Qlv;^%9?DMCY_HeHe!1IZLuvxD znG8D4b;Ge#%ka*??)z>i;Du$!P%WiozO=P4f6i2@j1troVyQ7hPjio6h{1YcB2M36 z;gQiJRa>M)-R9O|-Y(2f4Ug+8*WHAKc6FIE(AI)U(})w87e5Dl2)$oEzW~ z#TT8Tj)JT6v?qzsc0JQ8mg0;ua5wl^T}%ZAm=%{p2q)kRUycy?y`m$ouKGf!R>fyd zPPQR5*jnr}exY183nwn*-sLmnJ3 zZF!dJzuQB)hr1{)#Nb`Hk}R6?WHYQ@f$oKT7Y|ww9|vV{;ORrSmD?S@>1ECe&!+iX zJu32UauA$0^z1C9@xy%PdRyzB{wD@~ClSY(Xp%MD%tkqYP!nFJJ;DWI6&}hVC%s(( zL}G0xrnSCS6<6V-VKww!N2~>UU^^Eg2_6kol!dt^#bAo_E>3PK&y@n#0^IQl|DSoU(l*f z-F`!*a?J-_BdlK*B!rQH`(`uWaOh;uqu_JdA(Q$1&Xi^eLtp0rN!KfKUV$-0>##cKVR@rbpn~ZcAi>b^1i5g4n~iHYWd2zLzDrINE;yGsQIlVq;cyxJu1&^zf+M@} z&fb0-trFTNooG3Z$c)s8Tkbt)L{`=5a@7GEcF2VNuRHl{X3g&5C?}A7*pgb^eMeRs zn5RR;mq@=|UT8SBx6tnudM9FjaNWO?a+$U6K*ZV`1{7xme41=YHCIV_nIYp98vijk zfX5D#**tvX>uR&@oPl7^^TOkKa+iAu6wDNx2N1h`=H^VL_P(!^K7o>9_pjZRU_eH0 zA{2?~aum{-0|Q31;IQTv!Hpe+(C^cuMC%I}@PQfZWGi_}2**Spp2Gk#H+wRRDt6Z$ zU8g;nqLLjYrVK=WuW){%?Q<~r1}F`Tb5Y!Gc5H<>@2+Rdotna!n4h0vq|;KX_N~F?Z6di%V{Sh8UFx0D1QslN zvVa9AN4;Dz1Fdb!4+ zY=Ut&iUO)Nu@_XY_H4z+S<@=t1cJS9FcY_aPsV;8p}gL7mh*$fXORuVpVN5H@-^=h zObpkDuX9*qMYn_!`$wjCY&w9K?@KJ&QL||Xq$s>)Fd&WFZ13ubxap<`o2#!IPUup7 z6j0vVd}1@p)`Hb|XGH}`b(7~QrzYdvK;|1R;kA{hm9xzP0ZLBE5%0|S(Q39r0I{M_ zY_)M;k2$X(ce?(w^D&Et@>OekNLx?F(PCW=i6~kXMobT8lr;GZhRsWL&EecD=HduK zXQ#Z^d6`~KZyaJZ`o=q0MY?OOtva{kHS&d4JWq?=vK2Gf%khTXf~?O_(&g}iBYfmA z?6}t(jrPW1!0=f&u6D#lbc5vsJ>#C`7GD*AL|S-o*XDk5K<(6Enup5Wg-udmRWedtRWydVq3$i*@S*)#`C?0d4|juJWP@i| zVE_z}pVN~zhHT!v5hsTmTNrR9Fb4N){%YSb*j{|yKbhYV(W$vee?0C)*MRHEcw*2& zxbkVex+f}PnKlKF&40~3D0f_2?kh$|-lbuONt$BqzG1KNeFm(O;~eD^3*?V@aqZn1 zrx`f0aLF<$?s4wVi6~O0@YAN^n#~O+QS(Rw`SOuN90ct4Mh8P4_LjnB{|% zbz$zCHGB|SGnFX(o_)TUUL%`;xAMLNoc?j^>D&g(NxnsaIqc`fb33@AcY0QeWrDD* zQ_m^fyK?_x)Bd_tez|P^p3g-0A3!$eIYoS?)sL?nI!((H)4M6FbvKhm?R}Wy>$=Gj zy}De0UVfBBtb{9_5^c`e=PDZ~vBnXVOpQzoX&bo*_LMC3OZ{iyOs8<>BA)L9%50n7 zd~MlgdUqS@Y;u`+dcu8a-3nJc(HDk$JApcBNFIpUJh2oImr<;=Y^qe#!l)_!(vtF} z;TsrmJ1d+uA~>8mjC}EWc|te{%c<`$hwE~`772IdFEe>#JeHJ91y#ncd6ehpTuli+L`kg7w}0WJ)3Lh zh5<3|>E{8LZCdqK)nj;%%1>+= zS6Rz(7AaR)h9`Vnr){`C$tt|8oPizR3#-JX3L(l5TPFhxY}-Vajd2_K#~o1%X72E&f5QD7-lk0%Y45MQm$(MMQO(ynaJogQ!Q3a5 z?pD;mYT*T9ka+tk;cg)*9Xe@e73IqS-0~F!iOWwa6!wHlWLR`SkvLEgcv24%JXBsJ zK7;r_9c7Hnjv*R-s;f(iM3oUz>3)Fm9{ezQ!0-wy9n+ zki5_vZ{$$Itb1kk>!4ucIHhgvMw{s+@+`f9Ms@_8(2;yvkP%bgi}iww3eEYDWh<}| zDUfuPUtF(A7o$3Z@r!5$DtlXJ>x~ChhE_t_v2cF=`=&tC>9a!fa5+m)tQ?-0*U~+7 z2_++cMkD`2+W220Z>$Lwhg6Ziqs{Djcl7&G1&;4!_{B<5UFIyt_dWN?$zE`Jbz*Zq zmfj))$$VipM!AOTP}yB;nwQ0(S>l?N#f(vu4IqplsAaOT;p8;ttuHWVWi`cT)_F@| zuAMe{v2cN2ZNTwt2rnTxeE`fIeTmy*kar)y9m$o2QBx+^cLhs( zTiU?B@t!J&H%6x8b&ENa_QJ%xf#GbS{dII6ooQ$KM~Ft^h3|fGz+^1CX0+5E1`+DS z(~aBWf_|f%5nH+Ce17HqrXy`~ggT@|rIOwo^Kjh4Bnn;>i@=qRZ95{X*2#xV4rs%v z7RWf1!BOJoD;!NroLOa&`L#rBZy%iBG=UR);8R;ImG%1$<8K_wAK}Yyfb}ncav61Z z{jhVvw(j^+zzfxe@D=fi#6fE;?PtUZ!*n9N{-F-Cr6(~%w-QxVi96YFQa;;bd->2! z*V;3>V!h_6?u%g?d`*lduZ~Lf3~s-bf7Hsx5NNrxWG6~hv~h6X&fEc-@}k{_AWexA zD0~1rwzzozgyIluKl;puE#vF*P24a(447fvg#mK>a0R3LC`F=$ql2?BZ@X^9f$`C_ zhR;l$0&9Kw$9$Tkr?QU@e3hl2O2;KHZm^j2H z>He~MG-z66*d)45{78%UK}-@I29N)zZ*hoi1E`eSDj;RaPNlQ)!;xk=eoDqji^$2* zAWKVOB&z3Rp1j;~veoSj4;1yZa-tgO3FmDM^#fgyioAMItti2W6MlGFlaH@czDNeU zHbYVFN%Dw-s{(cyvmXpS+I!P#x_$|@OlHpd$Cbx#6o>BGhGl(x>1veHM*=d%b)poC zTOaUI{8m;+rkR`tD!DqvxvmYnx~9o=E)vgGx*Ha+=O1i(C`B#url!4JL#+7awEQ=_ zc&s7$hn|iyPAOu|{=WMr-(WybL-)1BjcE~?!mzpZ?s=F+lJS{`6(c$f2y&!21#l+0 zJnXS)nYP+~7UlB5Cvt5!H`HtrLBU2}KL}lXGAJ5_o*ygu=79R{A5K>8NNimd7W3mx zHj;Meu0w1g_uvp}@D?0WV2}y+=d|PATp!dAU%anlNq5*E619SZ3F<{tyW7->7sWg@ zTX=7(5*g`hQCHC}UR_YUc4A(}4zqH$b^!X1x zqaPfdA0QYUHT(d)zmvj*8VG-~AUn!`-sjs5Tg4d5vFIut+Jq8y`=?@g4@yievhS_b zMN}$+^e5`IfDePZ6HxEUdPz6?+yw>A3chF5;kX_Afw@lh94xuZrlWzGnhPpxM!lSi zpX6mW52-qK)QK2%6ECJ+WhM5&Env0J3Y&5J_1m)ZDyl=ikpY@Z-;Hnv3}~DNIlXd6kY~zU6V?##@xc)%o|(MLEb%hZvo3k?B793j3Ic@_`c8z!Mf6^xFqEa;<#%u zUvHK{rp?T25>HC$J%xr{)w=k+It3TRRUA~Qj!^2i{FqAo3xl=-&AU)=CI_LWuFW6K z=`YX!Z<}A-Gr0SlKf4b;Eaz@};A0wfFtY*C7?<=p?~h9J9KUHz;U?Z)-~8I`FnRTM z-`%iDC9y7j^KyZ;HvJH<4EHXmf%;tX1=Y+ZRnDm2$wv+tu(|Th;1mgeISQe>m35F~ zeH#LPlrQ*6QhgXoegbzW{!;-4U(Lh)-oY|RnujXYo;4|wHFe}2K}m=4{jxfTlPm*) zO`#rC(i=P9%)G$E{RD`AO8&PN?=Pm~1Kpp~E(>?;YV)QY!3tNzTi@xLqTcJ`ZGwWg zKG`!7EH~Ws)R6{7(`^iNtI&YqlxPhE?8}u@zb{$7Z0Ed%SsVN1-=N6{r12JEssnO zCa7PYPMEic2?O^Cqw+U=T}g`owl7<#qqf$#li7?+ZduyVJ%=b2z9F=(C*7{Y6gz)T zS7?|TL!#9in`Ya3!*b?Rt$|eQqr#og{OjS$`O}lKxQ)}v{~zW*6MQo z^H-+REbWoFarD9@3997x^5hs|7#WChJh_Gv#W7BKMyeIxib{qaNik#+`gq*x-c$ z2p5HUzn*)6rMr>(jVMYa%`xNRzzu-7Oq$DK$}%YFa}0q2)9LGOhQCxP-)#abd9la) z>a;nT_PdeU<}Fh6s6_mP*aGiHjno?aT11w7Zk3di@UVWZg#lr%^QiQcmAZBzFAkgz zOMQ{wsFJ}w@KuJ*C21x&gHIIr#*4E^*=gSSVh66pdAY0Pt2)0n^a-(cOpt|7$v+8K zbZ55)rEBkA2IJPbYERm>xw})qW2=|p>ci`jN!>S?b6JKG&bwDIAlO>cvoHXD&xz}9 zga3%x_+Ml)kX4m!X{$V+R=RT?WUNYxy5NXDy@-B6}X4| z@D+qt+o!3+{_X0iE$*`O{ih+Q1rlcb<~}4bSWFkC!Ri;pV(I0^e%FYaes(4XZqf>y zP?f8LE*Q}LX}E+t@Bthw&bprVo*7oFM)8N;qWKtoa+&NYRP5aNhTief=l=>>X*9rT z&PlVzZHnD5su{z_I09+UcY*#J)tc-q@~z{-{sc0rQi|}eFB_>d+?Nul!T*UiBM%+ zpe}e6ysB^Nc~!j*f}5?XkAFftc>J&;z9+i;!eRYyg7mDlXC3Wm`ZBcxo!z(U7rBCc z&H?;@r(J5uDtx2!AIJLUHT*1Mp8yEG3`f9Pa!$zLNJBD@Q#esL!WaVsLE{TjMro$} z{*WPb+czb~KIV;^^&8jV^lvkj_zL;6-57@f*)~I%J&Q^bC2C5NT6T(b7AD8Hty}~v zw$r8eM8RQvas((mebR3tTt^i$p!scUNHwvoCH)5dX>f$A^X8W*>*vozGR~(QQpTsj zs}63fHAxte(f<2PaUZ>qCaYHFao{6|Ibn z@)kBB4`)8S!Ey0JMJ(7-pl>kpU~*OFWQQvmixAy72$}Xh7@$K7IRL+iaJq6qxVdZ} zOlGwxdywstRs6VANY?tmS}m!ng=Nb`f3cL)Yqmas)&4=k=y{P&!i@^2O@CR zlKH#V`n~cG!H)lmIxeWUl>46(jD|()=J??Xp(!2W^kn`OBDjm%Jm8a8*m!cse1&cRX(*rE}fyAk%?_5 zU!7qi>g8{fFyqk%~Z5=oLd^(Q5Je_TMcynU}1C~Q!z?ZGR*2VDwv)xDz zRLkkk`oZbBJ22qlbK7N;z%PCy%KE1K2nO8yzgGXu2v{%7+r{o5^E1eW6LM2vC=^u-d|S#V8_pla_fQT&=b;%O0x&-sJ+!=p0k4%LqOYLu zBW4`A@{^pn81)z2Vlr{)hA-T>Q(cr6Q&SyLiLwc~Kjwm@GE&pE0+bE{wokPq@Ta{5 z$_~!J(~A&exCB*({7w)MZxGA-c8ylqn#3hdlr)kXnpm(fN|DcnfUybNLdV<_^M2-2 z4~n?)c#^fF4EMlrRbtXvgPoU-2c?JfJVwTHB8W9LY9xr;G1@xzkrHD&((D!GsVI|4 zN(O|!s3eakPQ`~y??X~pZz^`YE9FJ*YCQmdcxMp(MU}0p(YEDX3wRJ56BwQeNr&fX zNxxdY{z45ERG8&QYn#}4WaSGfLiP_3aOhr5TNF(UcsASpEpZhpcNMJS-x$k6#)7LQ zta}ypqF#(jWD?A#3lGB1bKM|8M80A9cVB83_L;VbM< zaMI^K3<%GjQ~7548TuGx9$pY*T4Go3iC6*LxfUjsXbXH-bpZ{8yOoC>;IE#>hu`a2 z{pHOvnYFHe`P*eZJVg{627DU*MNJQP$#w9HZ!g5!;-SZ?JX& zO}JN*6G#5u6X6xDfHtlZvJ~gf@IJr8hJ#D}pW{qFW^8P+rT>=p{Y6~qXUq9N_5K62 z`E6#vzn1^{v%J~gyzYkpJUo%%P;xDEYxx`lF2AF7Z+@Nb_HR3TI^xQGe!HIG%i7K3 z3ql}{qRs(%+&=$K*C_XKF&y7DV4~JhP`=(MQd^^@@@XnvuP0AuZiO0xIf@H zr`;ybN}_`pPiKkT!fxc2!O~SJv#0~v_%E)t)%Y}!sj>bOKz_90&;(OW`YBFVrO)=}w4qngUFMba^z4tLhqBu^)T45Y>D zaSc0u5ElhcOUWB{M?uY3N--H^mY+&4cFci0v4WB0>=aMe+vI3SQH#yhf0g_2or1O8 zZqiwg>`-z2f~}$<6C$gpIbZZF<^-3ML3owYwRbh|p9rn|C-~pE@#HvtbjNwGKaAs$ z>b#FRM@g&-b5XWou{H<^A4ew?y{}>=$RnPDpu^Ld=+pbkL8JmIVS2N^9eHUa7io%( zMj;Oqt?Q2$=UVJX3LFb=a|Szt5*}$XZ)aE1q{b{QEZ-0`Jz&T%ds;!oSTXHs1iAC2 zovSnh56>Ip5n8xU+&n6F<>^xXeB{H|rBCePPx%{~c7A`YA z_0OU?CsZgxrvo-=W!4@$C2+cc*As--1ciYe)^};8c{{|!y61)=xdZ3XRU1N9dNxK3 zk3R@&$J3*ZTUYz`H6T_5KXEGk(omluoDq-M z&EP<4qS!+dg+`w`5g+~en*5c1d45Cm9vl@l+vikcq19p)VXXN#C&lMDzITpkbZ+eq z<9k(VuNE~o1OxW8*t726-R_b?0$uRRE_UnEM0-ga!3uMomR(CclOy+fjpd#f{3J|3#;Gk4&Te0(c+imAg zSiysoFEzGrly`?&lX|Jy+)zQ=vc7dG0)+yJcQS3Rp0l(X$t67~c<9)e^g(L9NS04TS2S{g${i=-WVcpU}&nHKYytu^@yW` ztxdVx~hxt!F($eg>zvg!!~4UcQ}5TxdU9@mGSwa|4d zKe1?SY<{($x3Q{f?_3kwkYvRwc2rU0gT#xh%cxOQlxPU-bMZS0syEcuw@h$wCL+_`kAfd{hDp3-<_nw8lGJD{fPS*^xZfwR>yHkjTjd`S9c4|g0V=Bn-bo*k5Is!Ys1$KGYhP~8#vU?p}g z_WX4~vaF}>i4^V3$@9eonNJD#Y7nLZT8FO{u0{7<0-F0ypo1H@y!}Iq*S`D1q}$2E zwO_4658>%(m6y+y8;+uN;-P5Ar^35mq@#Kb&m zj)Tpz>k%?^*~2^q$J!U^G!I>b@TPK0TeI)HlW6t?oxcm%C(Wun(b2^b#Iy)}Xc-(D zcR6#*r6@e;4lVrm4%iQzX}_YxGnSSu*E~q9eDlin z>D+)9gU1r%=QB5LyySIGLxP}G&rjN|N5`#U-sc4jljR3gEKX#?bCYY_4W9aM1wd%h z%*{c=OAghI<$3eFN86>2Sl(WhCXeDn$~o_RSyit)erjc91ztt#7Bl7q`bXJc8t)=aZWdXf>-mOy(DHDmb4;-{7gfb65Z7!(MYzQoj@Mxt^Qw ztcB}Q)6uD+L!GJpMA_-(e!27hBcdpuTO#kh5k5B5bI>|;oUF8tydVz}4gXFT{8)aC zN#YyD9Qof@GK@(bgy`yjOpsAnB7aIs>4W6^%=lgFJI}{oaaFF>ssjq0$I9yiy z_s?FDZ~U8!sa>MheDC}Qmo6inu(uJ^Z@#@;rP$1SLUGoEP-r*j6zNn?mX~P@LKKpV z-LVW)F-yJGiM2uy4bo$KHSJ+y&bCOmvlO7B9fj$aV$>DXPPq`q*12kL#UOoMnwz)* zL}t4#HIcECwLZQRXG2#Vl+==^-!W#KiYpXIaCY2?-jg5X*kG>Y z85Fi6NK_)ebiwF+hTY@%{{vWRXBug|V0%>>SrY}1pXH5PHQ;^D;g0vRWY6i+couO} zwytuU=z{=58p$KV1pU#CfEc!W$n&-iT!nKbE~2;m9>#Ys*-Y2fOQ2C(r0X?|<<5E* z5|DV_cQ~r9yI4FCrGMSr`gurE!{N~-NVD;)%ueMll}SN@Fm~DXkW5I=$3=GI6&TRZ z?%w0%hA^QcDsH4Y!O2;=SBt5Vv`=k0;4)A)Qm5Dvw>iwPkkjha@AghAqJJUgW!8Lbr(F8VE{B{GNB$JwJLRbZOs>1!wADr`8lNyb zZhiQ4Zb{($mLw#?4P7)y6pbl#XNm2V4=5R3L(EOSJ$@o07;Pn3cu+|nN?qAd8-C^Y z5;}aoTi2v=@53vNzKk-3{>CIj`T4GIwHH&16PW-AeV_hgNuNWu#@e|sGkYAF1V4~_O(?czI;%8VX!Vsh6 zUBFn|GFke$@^xuv7<-JOfOzLx2HY=O0^LJh!+bruXH#K!g_82w5zV%8v7IP(etD_e zjmR;X`3(zNhsVuJ0s;?2}C zjm4Y#N#Eg_tYQhWR?;d_N-^pqF58}#nHpA1aCxTq`8o2))(KXa42p=+Ev>EI{WW=@S5G)5*G)BjhH;S7 zeXzBwkGnPY0=|ji{oIw)HcQ@>xE3PdFa!xU!(%^GX z=t+LT#a`r$Gf%ci9P7o&sIM=_lyY*Kk?$kF=;*V;UB8EQt02MwLlcPgoYs@APO!&p ztfh;Ubt*BOcqA1v`5KSwK*>T5-%)4@Ws)9QN`RjWe@le_el~huZwn%5;?1!P-O!=oMl1xXg8iJRYSZ&B6Q!q|$d*;6PUp8L zF>Ac)mDrGbNNJUXdJ!eQG+wJ?+v~RBWle3ouW71{T{;kE6v(xdwWYJkSloyS!En(5 zz8S|f$xNyZcX+R=wT(HP7VbHaE2s7D^K+=F6x-&~>T)rMk;#Tgy`eyR`$9dDeht{; z@LZ(2R!i5co^)_xH(T5^?r@2w@RQ$I_^@JjTg?|EmeNSIacrm%CDWEO4KH;ur*9P5 z_&~J13k65*Nqd=Ew`|+{XZnqkj%Rv4boJMwCgKGxJW_|Oj(F7ccFioR3kjUmEHyfQ z%UE_={$gKMYX=B+ni6VT_4f}XhBxTnW`}d^3CK12*SP5&#Ds7@-roJj4 z^&&Q**yOMppi_J7Ggx@6#B8Z5{nt;?{P3jMLYhGGl76f$jkioO`(qVa`a|pw5mE1h z#ih&CmeranE??wA@(o%i>bLdg1E*edC5AcjMziwmrhVJuj&eho`I(>m{{C;va{cvz zr2pm|y}!vd{>hv_g#Y6xe~KdMh^st!rcb0Cly-iuch2 zwM}84lLYY^Np5%0$Glco1}cBrY#?+Sd~#L>UOB&j0nwT;0L>{89z-5qMx@d_|?IGr;Gs8+v<@3mRBEd_%PakEZVYWs{m;ACvrXu7BRc z;orQi>N869J>ogl`nV0SjY)0Y{><@Ltg3@9VR#BngzH81JgVdmqZg%)Xj3i5#opBa zo~!k)qtodd$6U9zmX&=gQpzyOEySFkcK7+e1@8Oz3h|E-W`!HtCes^;efp(1JUYHQ z2~t1mO3AaMgCYhnj&+U{FTx`#qMG3efbt%SGMBov6!|Zs!g{TKJ$q~RXf$bCAPe^a zbNMxEcA}T7k{<(vc8%L!m7l3Nhqlr-PuzVb_da|~8*56i)e2|%HR_XbtifY5tYd-K zouG=WAR$SzouX+nPJZV7Q@?qi8B-Ww!(ZB@@-{+ktZQpXfHb_T^dwy>cf86u1sA8`}DLgn*Z1phLW@n$hI^V&bivTbbc`igxJSv0>qKWA&p_@ z;j6GQihd`v5-EeDa1VgvCZf!Y`09wE5|XVIjIAqfj-+U8CvXurj9_koLc^GBR+g!g zVviN3&3X@g|3}*N$L}YSFGccl?MoJ=9laS#w(}USRQTs*s}@lbJ#6u-QVR87dE!-A zn#|H~pflzD9S^VjEJtNXYjM~)_KNHEgz++ zvfcO*og`Nm+j$m($?h@fcia=Lj_zUxI;0LkHHx8;`_sMIru{{3xF#h8*hnP Z?yEbx5wutauWq4RF)_hY6am=m{|9KIMKS;Y literal 0 HcmV?d00001 diff --git a/doc/statist.pdf b/doc/statist.pdf new file mode 100644 index 0000000000000000000000000000000000000000..2122a33ab46087dc73aa5aced984375de1831ada GIT binary patch literal 5313 zcmb_g30O?++b2bhv=H8iPH59|W^aZTTBSvAo6~oTQx`imJU#}PRRbyt8_bHs(hd2yp8>=A0@r`m?fyEaeS;aCSl9|^#h`V zk|FfO?2R)GlV7`U&5hbml-%3bUuRd(4lQoX${0U$`2kp8pZYl5OK@KPo@#D>huH4p zr4{_sycL0eD+KeZ?OYX9HKw25dCkc6vt^J(5f@HbPw2~^Cq)Ach11+G%2peoc*hAQ z3{hFl7L$jinL^zgWQE*5(l);~P&vtTI25#HT(M5ImX>CX zjL=44#S^9-!UU&|5CPvuDqB7fVT6yelt6S4gz@1CU0Ja(Q# z<(}NkHwAa-&7R>F3iey7Ums3&+~~Fom@>_I4xzi&84aezJ{UG>Y7yE-HqCY0ncV8} zGQOZfN{;JPHvJIQx~%b4WuAQ3rGL12RyHTl-hV7_DjX}TD#pw@H5gB&mkqhzm;ZWX z+si#eIjc>4$9#L9Th+H0#Hmo_`O7xTUtvb`wlIgy-=z==N1Jlv#bKm;BLMd z%bn;$e6}L7&MT z)9Xc_uBx)_@5-K5DQ>Ft@jV`Jmv67jt|Jc48oWW=Cxc+?_|@FT~V`Y<5Sh(d)x1IW>ZqE7b)tkCc>0gVTguxJ|; zXiR6r83#baC?-T>12`ld!DNU<_h33eEI3gaG3gE_5ZelbQyBo7Lf&kcPs^LFW5Qv@ zU=~=k=`cG6%lUwF7pMV$!xC8llJksFFlo^~M8!f5gr&g-0vroj0I28U$O5cTi2cSW z8vvHzfr$Kx6;ZXAJ{LGOC~S%wow_7q!TKMn@W0}JSPdFd+#%2y51JZ-x{k1!E^Ht0 zkdXm^0Zj}5v?3b&LkMSsi&~BGC`6|5Ppim|msT-o_#}Q^C;wRHoCe}1O^D^dbYZaR zOc43x*kWj8p{r*gcK~wpgxD?)6wZn|d}3A#7$rQQfF%(C3>r%U$ON1Xa!*iM01k@+ z_p=<3bAzd{%PEWlkPFqB4JhF;C=gMDtRcK8P#5-;i^F~z)eSyw6llVR+|6N$cob;h z!eY75sE1t~;rj@yL_&cUi(&{kGAz}Z!i3LX24pcP4iLyd0>uq-VlT{?h(6HShv5v- zKnBEgp*w=U5R(qlX%NWvqJwN_CIo>_a5#ZZE}js`a`6UPkSC1hm92dYhBZLD;zd9B9T=cn#$5A#C<%n}J8jBa{&-dukMT_AChpOuG zrD|rn)^r1PQ;LM+A9jVz9SRHM!Cc}!;C*06NdC)XO|^m^ z{pOIR^^V*dO+%<$bvZy#4ltA57{5YY_pI4z*TZjE5p(QkhPf(!>Tjcdb2Guk^8J(?{r9=GLAetD_r~l~pR|s9*T_`Qzx|%-ER| z7tB**6BO*^-A0ScliTIpODM%Bu8!O>Of1w$$&!0w&|KfN<(#<#>&)T)+exD_{5IM& znqgJD|J8{0=C(F!PQiC=Cr9_UR}=rqDH>yDDw|&}(aCO@R@=E>sL?u4)h@eXlr=HI zYawAb+0a-Gb*iH5LLw#9BcEz=rSBjL#oo6*x}|3Q%Tqp~aR8t6QB?_v`k&*Y{!(-1rd`Z@lI>2qye;^vXTcQ%+JfZ;p%UDiJ3Lw0i8Ee<#BbCqR8kjNw+UIo?Ce*2wC3JF55M7X?5r0 zcltbc1k69|9Gtm!&1P%KvHFG&^#bwY3ToyW(|<~jZ?sp?*!!xtY*8Km%?q7OQ!0&~81m9|lG&Po<(c^)l`xt6Y2-NjiKJiPq>n(kSV|bt z!84B;EoGDS%pbfV6TCg$Fu>C9Md+u9X6E`b6#*HQ`F-Dom1p;Le|e%2>r?J1auCO3 z>vc8YZrhQj*Amk*b9bxOnWf!oymv)}5oWaMgIH@K_2F~(x2d6@cn33Ik6&7Q=rO52 zsYqHe?#1~>Yt*$c{=_#rK=b&4q%7OchlZj$U4^S~-~Ot+(L1hon}VGwdTPJd)8<8J zThxqtM6cBm<&dVy7rNLE0}l@wl(uZeo!u^3pM&dMwe~k@ke&})(1Nk9k!Fua3byJG zxLnWDd@_UXOfIkWV$Cq0_56KUha4Q%VzO5bn;$x!6}?tpK7h8G>gxOT^ck_bw<_~4 zUz-~M%ccmMg8m~s<1_o5(hv3>GEG%IY}sto5#{`HEY9OpnB}F}t?D4XlT2tFj1w=Fs@cLl$2)UrA0=4pHiPcS9lg?4cBK8N za1Fp+NP5V%UyWb>-5o7bSA7H%r}JO$iL0Jzr2Oc+XIBpChq`iF>ryQtQN!M2ncwCzvzly1>^{@z~CfoQKSZ?*RqTVW= z{I1tk{is*eDMYDP%DHU4Mc~(p;TP_v`I9Cx3T*Ec(*~}$6X~Y+ukSN^W}-(;OuBG4 zMIz*)EpM@DOW(usUQv|X$P1x??a_jb&vN#(OmnZV7RPqR1x&8|WDxam3nlC*B^I0S zy*Xe@{n-hEsa;tw|Bk>7p7&WZA{HXHS3Co6ob@R_ShVv<_u1ack(K0!b{4_gT3!fS zNY~+$H;IW8v%*8AGjH0ZzGCEO=X9@(xICD2IH94`%Ut`xB)6tNM!DU`7g= z4@LRARQ`CKnCC6UlVuZ^uD7Z6p8hgLdiLNzSV_~ifpm)Ey)*tN_OilE?(Gx&t>8x-8Uxgr1S#22Xx3O?t|xHoh2*8OQZ-f&GMzGf}ou?ISj1^*r2sS@rlFbExxXREeahk-OTd7fqK9RLg3BJH^Z{@L0ze=TIWLJs28cu@ z0E@){I2>-_g=qv5egO;97Wq(1Jpa?Uqz93){1S+8*@z)D684>-9xMc?*jzVl)=7Z;mjR+a z7x#*R{kG(Tr4d732n6JNDIga2#L>TmL&l{&5O7LxP%ZdtnFn6Spkaq_{vb&BR5%ir z5dYnXV3*c@p2IXagcjYtr22n3atv4&f>T;J!=Hs9`$A%o1Husr%bQ#TaU>wWnxC0| znZtpA1Ry6MF&LYlTDzaxD7fKt^l*TfGCGE4fQ~br#a?Ka03}7VlB}xgVjtY z5Ai5?VvS3n+swnW2|(Qu3TD-DAs!. +% +% As a special exception, when this file is read by TeX when processing +% a Texinfo source document, you may use the result without +% restriction. (This has been our intent since Texinfo was invented.) +% +% Please try the latest version of texinfo.tex before submitting bug +% reports; you can get the latest version from: +% http://www.gnu.org/software/texinfo/ (the Texinfo home page), or +% ftp://tug.org/tex/texinfo.tex +% (and all CTAN mirrors, see http://www.ctan.org). +% The texinfo.tex in any given distribution could well be out +% of date, so if that's what you're using, please check. +% +% Send bug reports to bug-texinfo@gnu.org. Please include including a +% complete document in each bug report with which we can reproduce the +% problem. Patches are, of course, greatly appreciated. +% +% To process a Texinfo manual with TeX, it's most reliable to use the +% texi2dvi shell script that comes with the distribution. For a simple +% manual foo.texi, however, you can get away with this: +% tex foo.texi +% texindex foo.?? +% tex foo.texi +% tex foo.texi +% dvips foo.dvi -o # or whatever; this makes foo.ps. +% The extra TeX runs get the cross-reference information correct. +% Sometimes one run after texindex suffices, and sometimes you need more +% than two; texi2dvi does it as many times as necessary. +% +% It is possible to adapt texinfo.tex for other languages, to some +% extent. You can get the existing language-specific files from the +% full Texinfo distribution. +% +% The GNU Texinfo home page is http://www.gnu.org/software/texinfo. + + +\message{Loading texinfo [version \texinfoversion]:} + +% If in a .fmt file, print the version number +% and turn on active characters that we couldn't do earlier because +% they might have appeared in the input file name. +\everyjob{\message{[Texinfo version \texinfoversion]}% + \catcode`+=\active \catcode`\_=\active} + +\chardef\other=12 + +% We never want plain's \outer definition of \+ in Texinfo. +% For @tex, we can use \tabalign. +\let\+ = \relax + +% Save some plain tex macros whose names we will redefine. +\let\ptexb=\b +\let\ptexbullet=\bullet +\let\ptexc=\c +\let\ptexcomma=\, +\let\ptexdot=\. +\let\ptexdots=\dots +\let\ptexend=\end +\let\ptexequiv=\equiv +\let\ptexexclam=\! +\let\ptexfootnote=\footnote +\let\ptexgtr=> +\let\ptexhat=^ +\let\ptexi=\i +\let\ptexindent=\indent +\let\ptexinsert=\insert +\let\ptexlbrace=\{ +\let\ptexless=< +\let\ptexnewwrite\newwrite +\let\ptexnoindent=\noindent +\let\ptexplus=+ +\let\ptexraggedright=\raggedright +\let\ptexrbrace=\} +\let\ptexslash=\/ +\let\ptexstar=\* +\let\ptext=\t +\let\ptextop=\top +{\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode + +% If this character appears in an error message or help string, it +% starts a new line in the output. +\newlinechar = `^^J + +% Use TeX 3.0's \inputlineno to get the line number, for better error +% messages, but if we're using an old version of TeX, don't do anything. +% +\ifx\inputlineno\thisisundefined + \let\linenumber = \empty % Pre-3.0. +\else + \def\linenumber{l.\the\inputlineno:\space} +\fi + +% Set up fixed words for English if not already set. +\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi +\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi +\ifx\putworderror\undefined \gdef\putworderror{error}\fi +\ifx\putwordfile\undefined \gdef\putwordfile{file}\fi +\ifx\putwordin\undefined \gdef\putwordin{in}\fi +\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi +\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi +\ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi +\ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi +\ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi +\ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi +\ifx\putwordof\undefined \gdef\putwordof{of}\fi +\ifx\putwordon\undefined \gdef\putwordon{on}\fi +\ifx\putwordpage\undefined \gdef\putwordpage{page}\fi +\ifx\putwordsection\undefined \gdef\putwordsection{section}\fi +\ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi +\ifx\putwordsee\undefined \gdef\putwordsee{see}\fi +\ifx\putwordSee\undefined \gdef\putwordSee{See}\fi +\ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi +\ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi +% +\ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi +\ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi +\ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi +\ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi +\ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi +\ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi +\ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi +\ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi +\ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi +\ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi +\ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi +\ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi +% +\ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi +\ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi +\ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi +\ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi +\ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi + +% Since the category of space is not known, we have to be careful. +\chardef\spacecat = 10 +\def\spaceisspace{\catcode`\ =\spacecat} + +% sometimes characters are active, so we need control sequences. +\chardef\ampChar = `\& +\chardef\colonChar = `\: +\chardef\commaChar = `\, +\chardef\dashChar = `\- +\chardef\dotChar = `\. +\chardef\exclamChar= `\! +\chardef\hashChar = `\# +\chardef\lquoteChar= `\` +\chardef\questChar = `\? +\chardef\rquoteChar= `\' +\chardef\semiChar = `\; +\chardef\slashChar = `\/ +\chardef\underChar = `\_ + +% Ignore a token. +% +\def\gobble#1{} + +% The following is used inside several \edef's. +\def\makecsname#1{\expandafter\noexpand\csname#1\endcsname} + +% Hyphenation fixes. +\hyphenation{ + Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script + ap-pen-dix bit-map bit-maps + data-base data-bases eshell fall-ing half-way long-est man-u-script + man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm + par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces + spell-ing spell-ings + stand-alone strong-est time-stamp time-stamps which-ever white-space + wide-spread wrap-around +} + +% Margin to add to right of even pages, to left of odd pages. +\newdimen\bindingoffset +\newdimen\normaloffset +\newdimen\pagewidth \newdimen\pageheight + +% For a final copy, take out the rectangles +% that mark overfull boxes (in case you have decided +% that the text looks ok even though it passes the margin). +% +\def\finalout{\overfullrule=0pt } + +% Sometimes it is convenient to have everything in the transcript file +% and nothing on the terminal. We don't just call \tracingall here, +% since that produces some useless output on the terminal. We also make +% some effort to order the tracing commands to reduce output in the log +% file; cf. trace.sty in LaTeX. +% +\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% +\def\loggingall{% + \tracingstats2 + \tracingpages1 + \tracinglostchars2 % 2 gives us more in etex + \tracingparagraphs1 + \tracingoutput1 + \tracingmacros2 + \tracingrestores1 + \showboxbreadth\maxdimen \showboxdepth\maxdimen + \ifx\eTeXversion\thisisundefined\else % etex gives us more logging + \tracingscantokens1 + \tracingifs1 + \tracinggroups1 + \tracingnesting2 + \tracingassigns1 + \fi + \tracingcommands3 % 3 gives us more in etex + \errorcontextlines16 +}% + +% @errormsg{MSG}. Do the index-like expansions on MSG, but if things +% aren't perfect, it's not the end of the world, being an error message, +% after all. +% +\def\errormsg{\begingroup \indexnofonts \doerrormsg} +\def\doerrormsg#1{\errmessage{#1}} + +% add check for \lastpenalty to plain's definitions. If the last thing +% we did was a \nobreak, we don't want to insert more space. +% +\def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount + \removelastskip\penalty-50\smallskip\fi\fi} +\def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount + \removelastskip\penalty-100\medskip\fi\fi} +\def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount + \removelastskip\penalty-200\bigskip\fi\fi} + +% Do @cropmarks to get crop marks. +% +\newif\ifcropmarks +\let\cropmarks = \cropmarkstrue +% +% Dimensions to add cropmarks at corners. +% Added by P. A. MacKay, 12 Nov. 1986 +% +\newdimen\outerhsize \newdimen\outervsize % set by the paper size routines +\newdimen\cornerlong \cornerlong=1pc +\newdimen\cornerthick \cornerthick=.3pt +\newdimen\topandbottommargin \topandbottommargin=.75in + +% Output a mark which sets \thischapter, \thissection and \thiscolor. +% We dump everything together because we only have one kind of mark. +% This works because we only use \botmark / \topmark, not \firstmark. +% +% A mark contains a subexpression of the \ifcase ... \fi construct. +% \get*marks macros below extract the needed part using \ifcase. +% +% Another complication is to let the user choose whether \thischapter +% (\thissection) refers to the chapter (section) in effect at the top +% of a page, or that at the bottom of a page. The solution is +% described on page 260 of The TeXbook. It involves outputting two +% marks for the sectioning macros, one before the section break, and +% one after. I won't pretend I can describe this better than DEK... +\def\domark{% + \toks0=\expandafter{\lastchapterdefs}% + \toks2=\expandafter{\lastsectiondefs}% + \toks4=\expandafter{\prevchapterdefs}% + \toks6=\expandafter{\prevsectiondefs}% + \toks8=\expandafter{\lastcolordefs}% + \mark{% + \the\toks0 \the\toks2 + \noexpand\or \the\toks4 \the\toks6 + \noexpand\else \the\toks8 + }% +} +% \topmark doesn't work for the very first chapter (after the title +% page or the contents), so we use \firstmark there -- this gets us +% the mark with the chapter defs, unless the user sneaks in, e.g., +% @setcolor (or @url, or @link, etc.) between @contents and the very +% first @chapter. +\def\gettopheadingmarks{% + \ifcase0\topmark\fi + \ifx\thischapter\empty \ifcase0\firstmark\fi \fi +} +\def\getbottomheadingmarks{\ifcase1\botmark\fi} +\def\getcolormarks{\ifcase2\topmark\fi} + +% Avoid "undefined control sequence" errors. +\def\lastchapterdefs{} +\def\lastsectiondefs{} +\def\prevchapterdefs{} +\def\prevsectiondefs{} +\def\lastcolordefs{} + +% Main output routine. +\chardef\PAGE = 255 +\output = {\onepageout{\pagecontents\PAGE}} + +\newbox\headlinebox +\newbox\footlinebox + +% \onepageout takes a vbox as an argument. Note that \pagecontents +% does insertions, but you have to call it yourself. +\def\onepageout#1{% + \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi + % + \ifodd\pageno \advance\hoffset by \bindingoffset + \else \advance\hoffset by -\bindingoffset\fi + % + % Do this outside of the \shipout so @code etc. will be expanded in + % the headline as they should be, not taken literally (outputting ''code). + \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi + \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% + \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi + \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% + % + {% + % Have to do this stuff outside the \shipout because we want it to + % take effect in \write's, yet the group defined by the \vbox ends + % before the \shipout runs. + % + \indexdummies % don't expand commands in the output. + \normalturnoffactive % \ in index entries must not stay \, e.g., if + % the page break happens to be in the middle of an example. + % We don't want .vr (or whatever) entries like this: + % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}} + % "\acronym" won't work when it's read back in; + % it needs to be + % {\code {{\tt \backslashcurfont }acronym} + \shipout\vbox{% + % Do this early so pdf references go to the beginning of the page. + \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi + % + \ifcropmarks \vbox to \outervsize\bgroup + \hsize = \outerhsize + \vskip-\topandbottommargin + \vtop to0pt{% + \line{\ewtop\hfil\ewtop}% + \nointerlineskip + \line{% + \vbox{\moveleft\cornerthick\nstop}% + \hfill + \vbox{\moveright\cornerthick\nstop}% + }% + \vss}% + \vskip\topandbottommargin + \line\bgroup + \hfil % center the page within the outer (page) hsize. + \ifodd\pageno\hskip\bindingoffset\fi + \vbox\bgroup + \fi + % + \unvbox\headlinebox + \pagebody{#1}% + \ifdim\ht\footlinebox > 0pt + % Only leave this space if the footline is nonempty. + % (We lessened \vsize for it in \oddfootingyyy.) + % The \baselineskip=24pt in plain's \makefootline has no effect. + \vskip 24pt + \unvbox\footlinebox + \fi + % + \ifcropmarks + \egroup % end of \vbox\bgroup + \hfil\egroup % end of (centering) \line\bgroup + \vskip\topandbottommargin plus1fill minus1fill + \boxmaxdepth = \cornerthick + \vbox to0pt{\vss + \line{% + \vbox{\moveleft\cornerthick\nsbot}% + \hfill + \vbox{\moveright\cornerthick\nsbot}% + }% + \nointerlineskip + \line{\ewbot\hfil\ewbot}% + }% + \egroup % \vbox from first cropmarks clause + \fi + }% end of \shipout\vbox + }% end of group with \indexdummies + \advancepageno + \ifnum\outputpenalty>-20000 \else\dosupereject\fi +} + +\newinsert\margin \dimen\margin=\maxdimen + +\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} +{\catcode`\@ =11 +\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi +% marginal hacks, juha@viisa.uucp (Juha Takala) +\ifvoid\margin\else % marginal info is present + \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi +\dimen@=\dp#1\relax \unvbox#1\relax +\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi +\ifr@ggedbottom \kern-\dimen@ \vfil \fi} +} + +% Here are the rules for the cropmarks. Note that they are +% offset so that the space between them is truly \outerhsize or \outervsize +% (P. A. MacKay, 12 November, 1986) +% +\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} +\def\nstop{\vbox + {\hrule height\cornerthick depth\cornerlong width\cornerthick}} +\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} +\def\nsbot{\vbox + {\hrule height\cornerlong depth\cornerthick width\cornerthick}} + +% Parse an argument, then pass it to #1. The argument is the rest of +% the input line (except we remove a trailing comment). #1 should be a +% macro which expects an ordinary undelimited TeX argument. +% +\def\parsearg{\parseargusing{}} +\def\parseargusing#1#2{% + \def\argtorun{#2}% + \begingroup + \obeylines + \spaceisspace + #1% + \parseargline\empty% Insert the \empty token, see \finishparsearg below. +} + +{\obeylines % + \gdef\parseargline#1^^M{% + \endgroup % End of the group started in \parsearg. + \argremovecomment #1\comment\ArgTerm% + }% +} + +% First remove any @comment, then any @c comment. +\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm} +\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} + +% Each occurrence of `\^^M' or `\^^M' is replaced by a single space. +% +% \argremovec might leave us with trailing space, e.g., +% @end itemize @c foo +% This space token undergoes the same procedure and is eventually removed +% by \finishparsearg. +% +\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M} +\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M} +\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{% + \def\temp{#3}% + \ifx\temp\empty + % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp: + \let\temp\finishparsearg + \else + \let\temp\argcheckspaces + \fi + % Put the space token in: + \temp#1 #3\ArgTerm +} + +% If a _delimited_ argument is enclosed in braces, they get stripped; so +% to get _exactly_ the rest of the line, we had to prevent such situation. +% We prepended an \empty token at the very beginning and we expand it now, +% just before passing the control to \argtorun. +% (Similarly, we have to think about #3 of \argcheckspacesY above: it is +% either the null string, or it ends with \^^M---thus there is no danger +% that a pair of braces would be stripped. +% +% But first, we have to remove the trailing space token. +% +\def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}} + +% \parseargdef\foo{...} +% is roughly equivalent to +% \def\foo{\parsearg\Xfoo} +% \def\Xfoo#1{...} +% +% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my +% favourite TeX trick. --kasal, 16nov03 + +\def\parseargdef#1{% + \expandafter \doparseargdef \csname\string#1\endcsname #1% +} +\def\doparseargdef#1#2{% + \def#2{\parsearg#1}% + \def#1##1% +} + +% Several utility definitions with active space: +{ + \obeyspaces + \gdef\obeyedspace{ } + + % Make each space character in the input produce a normal interword + % space in the output. Don't allow a line break at this space, as this + % is used only in environments like @example, where each line of input + % should produce a line of output anyway. + % + \gdef\sepspaces{\obeyspaces\let =\tie} + + % If an index command is used in an @example environment, any spaces + % therein should become regular spaces in the raw index file, not the + % expansion of \tie (\leavevmode \penalty \@M \ ). + \gdef\unsepspaces{\let =\space} +} + + +\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} + +% Define the framework for environments in texinfo.tex. It's used like this: +% +% \envdef\foo{...} +% \def\Efoo{...} +% +% It's the responsibility of \envdef to insert \begingroup before the +% actual body; @end closes the group after calling \Efoo. \envdef also +% defines \thisenv, so the current environment is known; @end checks +% whether the environment name matches. The \checkenv macro can also be +% used to check whether the current environment is the one expected. +% +% Non-false conditionals (@iftex, @ifset) don't fit into this, so they +% are not treated as environments; they don't open a group. (The +% implementation of @end takes care not to call \endgroup in this +% special case.) + + +% At run-time, environments start with this: +\def\startenvironment#1{\begingroup\def\thisenv{#1}} +% initialize +\let\thisenv\empty + +% ... but they get defined via ``\envdef\foo{...}'': +\long\def\envdef#1#2{\def#1{\startenvironment#1#2}} +\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}} + +% Check whether we're in the right environment: +\def\checkenv#1{% + \def\temp{#1}% + \ifx\thisenv\temp + \else + \badenverr + \fi +} + +% Environment mismatch, #1 expected: +\def\badenverr{% + \errhelp = \EMsimple + \errmessage{This command can appear only \inenvironment\temp, + not \inenvironment\thisenv}% +} +\def\inenvironment#1{% + \ifx#1\empty + outside of any environment% + \else + in environment \expandafter\string#1% + \fi +} + +% @end foo executes the definition of \Efoo. +% But first, it executes a specialized version of \checkenv +% +\parseargdef\end{% + \if 1\csname iscond.#1\endcsname + \else + % The general wording of \badenverr may not be ideal. + \expandafter\checkenv\csname#1\endcsname + \csname E#1\endcsname + \endgroup + \fi +} + +\newhelp\EMsimple{Press RETURN to continue.} + + +% Be sure we're in horizontal mode when doing a tie, since we make space +% equivalent to this in @example-like environments. Otherwise, a space +% at the beginning of a line will start with \penalty -- and +% since \penalty is valid in vertical mode, we'd end up putting the +% penalty on the vertical list instead of in the new paragraph. +{\catcode`@ = 11 + % Avoid using \@M directly, because that causes trouble + % if the definition is written into an index file. + \global\let\tiepenalty = \@M + \gdef\tie{\leavevmode\penalty\tiepenalty\ } +} + +% @: forces normal size whitespace following. +\def\:{\spacefactor=1000 } + +% @* forces a line break. +\def\*{\hfil\break\hbox{}\ignorespaces} + +% @/ allows a line break. +\let\/=\allowbreak + +% @. is an end-of-sentence period. +\def\.{.\spacefactor=\endofsentencespacefactor\space} + +% @! is an end-of-sentence bang. +\def\!{!\spacefactor=\endofsentencespacefactor\space} + +% @? is an end-of-sentence query. +\def\?{?\spacefactor=\endofsentencespacefactor\space} + +% @frenchspacing on|off says whether to put extra space after punctuation. +% +\def\onword{on} +\def\offword{off} +% +\parseargdef\frenchspacing{% + \def\temp{#1}% + \ifx\temp\onword \plainfrenchspacing + \else\ifx\temp\offword \plainnonfrenchspacing + \else + \errhelp = \EMsimple + \errmessage{Unknown @frenchspacing option `\temp', must be on|off}% + \fi\fi +} + +% @w prevents a word break. Without the \leavevmode, @w at the +% beginning of a paragraph, when TeX is still in vertical mode, would +% produce a whole line of output instead of starting the paragraph. +\def\w#1{\leavevmode\hbox{#1}} + +% @group ... @end group forces ... to be all on one page, by enclosing +% it in a TeX vbox. We use \vtop instead of \vbox to construct the box +% to keep its height that of a normal line. According to the rules for +% \topskip (p.114 of the TeXbook), the glue inserted is +% max (\topskip - \ht (first item), 0). If that height is large, +% therefore, no glue is inserted, and the space between the headline and +% the text is small, which looks bad. +% +% Another complication is that the group might be very large. This can +% cause the glue on the previous page to be unduly stretched, because it +% does not have much material. In this case, it's better to add an +% explicit \vfill so that the extra space is at the bottom. The +% threshold for doing this is if the group is more than \vfilllimit +% percent of a page (\vfilllimit can be changed inside of @tex). +% +\newbox\groupbox +\def\vfilllimit{0.7} +% +\envdef\group{% + \ifnum\catcode`\^^M=\active \else + \errhelp = \groupinvalidhelp + \errmessage{@group invalid in context where filling is enabled}% + \fi + \startsavinginserts + % + \setbox\groupbox = \vtop\bgroup + % Do @comment since we are called inside an environment such as + % @example, where each end-of-line in the input causes an + % end-of-line in the output. We don't want the end-of-line after + % the `@group' to put extra space in the output. Since @group + % should appear on a line by itself (according to the Texinfo + % manual), we don't worry about eating any user text. + \comment +} +% +% The \vtop produces a box with normal height and large depth; thus, TeX puts +% \baselineskip glue before it, and (when the next line of text is done) +% \lineskip glue after it. Thus, space below is not quite equal to space +% above. But it's pretty close. +\def\Egroup{% + % To get correct interline space between the last line of the group + % and the first line afterwards, we have to propagate \prevdepth. + \endgraf % Not \par, as it may have been set to \lisppar. + \global\dimen1 = \prevdepth + \egroup % End the \vtop. + % \dimen0 is the vertical size of the group's box. + \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox + % \dimen2 is how much space is left on the page (more or less). + \dimen2 = \pageheight \advance\dimen2 by -\pagetotal + % if the group doesn't fit on the current page, and it's a big big + % group, force a page break. + \ifdim \dimen0 > \dimen2 + \ifdim \pagetotal < \vfilllimit\pageheight + \page + \fi + \fi + \box\groupbox + \prevdepth = \dimen1 + \checkinserts +} +% +% TeX puts in an \escapechar (i.e., `@') at the beginning of the help +% message, so this ends up printing `@group can only ...'. +% +\newhelp\groupinvalidhelp{% +group can only be used in environments such as @example,^^J% +where each line of input produces a line of output.} + +% @need space-in-mils +% forces a page break if there is not space-in-mils remaining. + +\newdimen\mil \mil=0.001in + +\parseargdef\need{% + % Ensure vertical mode, so we don't make a big box in the middle of a + % paragraph. + \par + % + % If the @need value is less than one line space, it's useless. + \dimen0 = #1\mil + \dimen2 = \ht\strutbox + \advance\dimen2 by \dp\strutbox + \ifdim\dimen0 > \dimen2 + % + % Do a \strut just to make the height of this box be normal, so the + % normal leading is inserted relative to the preceding line. + % And a page break here is fine. + \vtop to #1\mil{\strut\vfil}% + % + % TeX does not even consider page breaks if a penalty added to the + % main vertical list is 10000 or more. But in order to see if the + % empty box we just added fits on the page, we must make it consider + % page breaks. On the other hand, we don't want to actually break the + % page after the empty box. So we use a penalty of 9999. + % + % There is an extremely small chance that TeX will actually break the + % page at this \penalty, if there are no other feasible breakpoints in + % sight. (If the user is using lots of big @group commands, which + % almost-but-not-quite fill up a page, TeX will have a hard time doing + % good page breaking, for example.) However, I could not construct an + % example where a page broke at this \penalty; if it happens in a real + % document, then we can reconsider our strategy. + \penalty9999 + % + % Back up by the size of the box, whether we did a page break or not. + \kern -#1\mil + % + % Do not allow a page break right after this kern. + \nobreak + \fi +} + +% @br forces paragraph break (and is undocumented). + +\let\br = \par + +% @page forces the start of a new page. +% +\def\page{\par\vfill\supereject} + +% @exdent text.... +% outputs text on separate line in roman font, starting at standard page margin + +% This records the amount of indent in the innermost environment. +% That's how much \exdent should take out. +\newskip\exdentamount + +% This defn is used inside fill environments such as @defun. +\parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break} + +% This defn is used inside nofill environments such as @example. +\parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount + \leftline{\hskip\leftskip{\rm#1}}}} + +% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current +% paragraph. For more general purposes, use the \margin insertion +% class. WHICH is `l' or `r'. Not documented, written for gawk manual. +% +\newskip\inmarginspacing \inmarginspacing=1cm +\def\strutdepth{\dp\strutbox} +% +\def\doinmargin#1#2{\strut\vadjust{% + \nobreak + \kern-\strutdepth + \vtop to \strutdepth{% + \baselineskip=\strutdepth + \vss + % if you have multiple lines of stuff to put here, you'll need to + % make the vbox yourself of the appropriate size. + \ifx#1l% + \llap{\ignorespaces #2\hskip\inmarginspacing}% + \else + \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}% + \fi + \null + }% +}} +\def\inleftmargin{\doinmargin l} +\def\inrightmargin{\doinmargin r} +% +% @inmargin{TEXT [, RIGHT-TEXT]} +% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right; +% else use TEXT for both). +% +\def\inmargin#1{\parseinmargin #1,,\finish} +\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing. + \setbox0 = \hbox{\ignorespaces #2}% + \ifdim\wd0 > 0pt + \def\lefttext{#1}% have both texts + \def\righttext{#2}% + \else + \def\lefttext{#1}% have only one text + \def\righttext{#1}% + \fi + % + \ifodd\pageno + \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin + \else + \def\temp{\inleftmargin\lefttext}% + \fi + \temp +} + +% @| inserts a changebar to the left of the current line. It should +% surround any changed text. This approach does *not* work if the +% change spans more than two lines of output. To handle that, we would +% have adopt a much more difficult approach (putting marks into the main +% vertical list for the beginning and end of each change). This command +% is not documented, not supported, and doesn't work. +% +\def\|{% + % \vadjust can only be used in horizontal mode. + \leavevmode + % + % Append this vertical mode material after the current line in the output. + \vadjust{% + % We want to insert a rule with the height and depth of the current + % leading; that is exactly what \strutbox is supposed to record. + \vskip-\baselineskip + % + % \vadjust-items are inserted at the left edge of the type. So + % the \llap here moves out into the left-hand margin. + \llap{% + % + % For a thicker or thinner bar, change the `1pt'. + \vrule height\baselineskip width1pt + % + % This is the space between the bar and the text. + \hskip 12pt + }% + }% +} + +% @include FILE -- \input text of FILE. +% +\def\include{\parseargusing\filenamecatcodes\includezzz} +\def\includezzz#1{% + \pushthisfilestack + \def\thisfile{#1}% + {% + \makevalueexpandable % we want to expand any @value in FILE. + \turnoffactive % and allow special characters in the expansion + \indexnofonts % Allow `@@' and other weird things in file names. + \wlog{texinfo.tex: doing @include of #1^^J}% + \edef\temp{\noexpand\input #1 }% + % + % This trickery is to read FILE outside of a group, in case it makes + % definitions, etc. + \expandafter + }\temp + \popthisfilestack +} +\def\filenamecatcodes{% + \catcode`\\=\other + \catcode`~=\other + \catcode`^=\other + \catcode`_=\other + \catcode`|=\other + \catcode`<=\other + \catcode`>=\other + \catcode`+=\other + \catcode`-=\other + \catcode`\`=\other + \catcode`\'=\other +} + +\def\pushthisfilestack{% + \expandafter\pushthisfilestackX\popthisfilestack\StackTerm +} +\def\pushthisfilestackX{% + \expandafter\pushthisfilestackY\thisfile\StackTerm +} +\def\pushthisfilestackY #1\StackTerm #2\StackTerm {% + \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}% +} + +\def\popthisfilestack{\errthisfilestackempty} +\def\errthisfilestackempty{\errmessage{Internal error: + the stack of filenames is empty.}} + +\def\thisfile{} + +% @center line +% outputs that line, centered. +% +\parseargdef\center{% + \ifhmode + \let\next\centerH + \else + \let\next\centerV + \fi + \next{\hfil \ignorespaces#1\unskip \hfil}% +} +\def\centerH#1{% + {% + \hfil\break + \advance\hsize by -\leftskip + \advance\hsize by -\rightskip + \line{#1}% + \break + }% +} +\def\centerV#1{\line{\kern\leftskip #1\kern\rightskip}} + +% @sp n outputs n lines of vertical space + +\parseargdef\sp{\vskip #1\baselineskip} + +% @comment ...line which is ignored... +% @c is the same as @comment +% @ignore ... @end ignore is another way to write a comment + +\def\comment{\begingroup \catcode`\^^M=\other% +\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% +\commentxxx} +{\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}} + +\let\c=\comment + +% @paragraphindent NCHARS +% We'll use ems for NCHARS, close enough. +% NCHARS can also be the word `asis' or `none'. +% We cannot feasibly implement @paragraphindent asis, though. +% +\def\asisword{asis} % no translation, these are keywords +\def\noneword{none} +% +\parseargdef\paragraphindent{% + \def\temp{#1}% + \ifx\temp\asisword + \else + \ifx\temp\noneword + \defaultparindent = 0pt + \else + \defaultparindent = #1em + \fi + \fi + \parindent = \defaultparindent +} + +% @exampleindent NCHARS +% We'll use ems for NCHARS like @paragraphindent. +% It seems @exampleindent asis isn't necessary, but +% I preserve it to make it similar to @paragraphindent. +\parseargdef\exampleindent{% + \def\temp{#1}% + \ifx\temp\asisword + \else + \ifx\temp\noneword + \lispnarrowing = 0pt + \else + \lispnarrowing = #1em + \fi + \fi +} + +% @firstparagraphindent WORD +% If WORD is `none', then suppress indentation of the first paragraph +% after a section heading. If WORD is `insert', then do indent at such +% paragraphs. +% +% The paragraph indentation is suppressed or not by calling +% \suppressfirstparagraphindent, which the sectioning commands do. +% We switch the definition of this back and forth according to WORD. +% By default, we suppress indentation. +% +\def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent} +\def\insertword{insert} +% +\parseargdef\firstparagraphindent{% + \def\temp{#1}% + \ifx\temp\noneword + \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent + \else\ifx\temp\insertword + \let\suppressfirstparagraphindent = \relax + \else + \errhelp = \EMsimple + \errmessage{Unknown @firstparagraphindent option `\temp'}% + \fi\fi +} + +% Here is how we actually suppress indentation. Redefine \everypar to +% \kern backwards by \parindent, and then reset itself to empty. +% +% We also make \indent itself not actually do anything until the next +% paragraph. +% +\gdef\dosuppressfirstparagraphindent{% + \gdef\indent{% + \restorefirstparagraphindent + \indent + }% + \gdef\noindent{% + \restorefirstparagraphindent + \noindent + }% + \global\everypar = {% + \kern -\parindent + \restorefirstparagraphindent + }% +} + +\gdef\restorefirstparagraphindent{% + \global \let \indent = \ptexindent + \global \let \noindent = \ptexnoindent + \global \everypar = {}% +} + + +% @refill is a no-op. +\let\refill=\relax + +% If working on a large document in chapters, it is convenient to +% be able to disable indexing, cross-referencing, and contents, for test runs. +% This is done with @novalidate (before @setfilename). +% +\newif\iflinks \linkstrue % by default we want the aux files. +\let\novalidate = \linksfalse + +% @setfilename is done at the beginning of every texinfo file. +% So open here the files we need to have open while reading the input. +% This makes it possible to make a .fmt file for texinfo. +\def\setfilename{% + \fixbackslash % Turn off hack to swallow `\input texinfo'. + \iflinks + \tryauxfile + % Open the new aux file. TeX will close it automatically at exit. + \immediate\openout\auxfile=\jobname.aux + \fi % \openindices needs to do some work in any case. + \openindices + \let\setfilename=\comment % Ignore extra @setfilename cmds. + % + % If texinfo.cnf is present on the system, read it. + % Useful for site-wide @afourpaper, etc. + \openin 1 texinfo.cnf + \ifeof 1 \else \input texinfo.cnf \fi + \closein 1 + % + \comment % Ignore the actual filename. +} + +% Called from \setfilename. +% +\def\openindices{% + \newindex{cp}% + \newcodeindex{fn}% + \newcodeindex{vr}% + \newcodeindex{tp}% + \newcodeindex{ky}% + \newcodeindex{pg}% +} + +% @bye. +\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} + + +\message{pdf,} +% adobe `portable' document format +\newcount\tempnum +\newcount\lnkcount +\newtoks\filename +\newcount\filenamelength +\newcount\pgn +\newtoks\toksA +\newtoks\toksB +\newtoks\toksC +\newtoks\toksD +\newbox\boxA +\newcount\countA +\newif\ifpdf +\newif\ifpdfmakepagedest + +% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1 +% can be set). So we test for \relax and 0 as well as being undefined. +\ifx\pdfoutput\thisisundefined +\else + \ifx\pdfoutput\relax + \else + \ifcase\pdfoutput + \else + \pdftrue + \fi + \fi +\fi + +% PDF uses PostScript string constants for the names of xref targets, +% for display in the outlines, and in other places. Thus, we have to +% double any backslashes. Otherwise, a name like "\node" will be +% interpreted as a newline (\n), followed by o, d, e. Not good. +% +% See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and +% related messages. The final outcome is that it is up to the TeX user +% to double the backslashes and otherwise make the string valid, so +% that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to +% do this reliably, so we use it. + +% #1 is a control sequence in which to do the replacements, +% which we \xdef. +\def\txiescapepdf#1{% + \ifx\pdfescapestring\relax + % No primitive available; should we give a warning or log? + % Many times it won't matter. + \else + % The expandable \pdfescapestring primitive escapes parentheses, + % backslashes, and other special chars. + \xdef#1{\pdfescapestring{#1}}% + \fi +} + +\newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images +with PDF output, and none of those formats could be found. (.eps cannot +be supported due to the design of the PDF format; use regular TeX (DVI +output) for that.)} + +\ifpdf + % + % Color manipulation macros based on pdfcolor.tex, + % except using rgb instead of cmyk; the latter is said to render as a + % very dark gray on-screen and a very dark halftone in print, instead + % of actual black. + \def\rgbDarkRed{0.50 0.09 0.12} + \def\rgbBlack{0 0 0} + % + % k sets the color for filling (usual text, etc.); + % K sets the color for stroking (thin rules, e.g., normal _'s). + \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}} + % + % Set color, and create a mark which defines \thiscolor accordingly, + % so that \makeheadline knows which color to restore. + \def\setcolor#1{% + \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}% + \domark + \pdfsetcolor{#1}% + } + % + \def\maincolor{\rgbBlack} + \pdfsetcolor{\maincolor} + \edef\thiscolor{\maincolor} + \def\lastcolordefs{} + % + \def\makefootline{% + \baselineskip24pt + \line{\pdfsetcolor{\maincolor}\the\footline}% + } + % + \def\makeheadline{% + \vbox to 0pt{% + \vskip-22.5pt + \line{% + \vbox to8.5pt{}% + % Extract \thiscolor definition from the marks. + \getcolormarks + % Typeset the headline with \maincolor, then restore the color. + \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}% + }% + \vss + }% + \nointerlineskip + } + % + % + \pdfcatalog{/PageMode /UseOutlines} + % + % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto). + \def\dopdfimage#1#2#3{% + \def\imagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% + \def\imageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% + % + % pdftex (and the PDF format) support .pdf, .png, .jpg (among + % others). Let's try in that order, PDF first since if + % someone has a scalable image, presumably better to use that than a + % bitmap. + \let\pdfimgext=\empty + \begingroup + \openin 1 #1.pdf \ifeof 1 + \openin 1 #1.PDF \ifeof 1 + \openin 1 #1.png \ifeof 1 + \openin 1 #1.jpg \ifeof 1 + \openin 1 #1.jpeg \ifeof 1 + \openin 1 #1.JPG \ifeof 1 + \errhelp = \nopdfimagehelp + \errmessage{Could not find image file #1 for pdf}% + \else \gdef\pdfimgext{JPG}% + \fi + \else \gdef\pdfimgext{jpeg}% + \fi + \else \gdef\pdfimgext{jpg}% + \fi + \else \gdef\pdfimgext{png}% + \fi + \else \gdef\pdfimgext{PDF}% + \fi + \else \gdef\pdfimgext{pdf}% + \fi + \closein 1 + \endgroup + % + % without \immediate, ancient pdftex seg faults when the same image is + % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.) + \ifnum\pdftexversion < 14 + \immediate\pdfimage + \else + \immediate\pdfximage + \fi + \ifdim \wd0 >0pt width \imagewidth \fi + \ifdim \wd2 >0pt height \imageheight \fi + \ifnum\pdftexversion<13 + #1.\pdfimgext + \else + {#1.\pdfimgext}% + \fi + \ifnum\pdftexversion < 14 \else + \pdfrefximage \pdflastximage + \fi} + % + \def\pdfmkdest#1{{% + % We have to set dummies so commands such as @code, and characters + % such as \, aren't expanded when present in a section title. + \indexnofonts + \turnoffactive + \makevalueexpandable + \def\pdfdestname{#1}% + \txiescapepdf\pdfdestname + \safewhatsit{\pdfdest name{\pdfdestname} xyz}% + }} + % + % used to mark target names; must be expandable. + \def\pdfmkpgn#1{#1} + % + % by default, use a color that is dark enough to print on paper as + % nearly black, but still distinguishable for online viewing. + \def\urlcolor{\rgbDarkRed} + \def\linkcolor{\rgbDarkRed} + \def\endlink{\setcolor{\maincolor}\pdfendlink} + % + % Adding outlines to PDF; macros for calculating structure of outlines + % come from Petr Olsak + \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% + \else \csname#1\endcsname \fi} + \def\advancenumber#1{\tempnum=\expnumber{#1}\relax + \advance\tempnum by 1 + \expandafter\xdef\csname#1\endcsname{\the\tempnum}} + % + % #1 is the section text, which is what will be displayed in the + % outline by the pdf viewer. #2 is the pdf expression for the number + % of subentries (or empty, for subsubsections). #3 is the node text, + % which might be empty if this toc entry had no corresponding node. + % #4 is the page number + % + \def\dopdfoutline#1#2#3#4{% + % Generate a link to the node text if that exists; else, use the + % page number. We could generate a destination for the section + % text in the case where a section has no node, but it doesn't + % seem worth the trouble, since most documents are normally structured. + \edef\pdfoutlinedest{#3}% + \ifx\pdfoutlinedest\empty + \def\pdfoutlinedest{#4}% + \else + \txiescapepdf\pdfoutlinedest + \fi + % + % Also escape PDF chars in the display string. + \edef\pdfoutlinetext{#1}% + \txiescapepdf\pdfoutlinetext + % + \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}% + } + % + \def\pdfmakeoutlines{% + \begingroup + % Read toc silently, to get counts of subentries for \pdfoutline. + \def\partentry##1##2##3##4{}% ignore parts in the outlines + \def\numchapentry##1##2##3##4{% + \def\thischapnum{##2}% + \def\thissecnum{0}% + \def\thissubsecnum{0}% + }% + \def\numsecentry##1##2##3##4{% + \advancenumber{chap\thischapnum}% + \def\thissecnum{##2}% + \def\thissubsecnum{0}% + }% + \def\numsubsecentry##1##2##3##4{% + \advancenumber{sec\thissecnum}% + \def\thissubsecnum{##2}% + }% + \def\numsubsubsecentry##1##2##3##4{% + \advancenumber{subsec\thissubsecnum}% + }% + \def\thischapnum{0}% + \def\thissecnum{0}% + \def\thissubsecnum{0}% + % + % use \def rather than \let here because we redefine \chapentry et + % al. a second time, below. + \def\appentry{\numchapentry}% + \def\appsecentry{\numsecentry}% + \def\appsubsecentry{\numsubsecentry}% + \def\appsubsubsecentry{\numsubsubsecentry}% + \def\unnchapentry{\numchapentry}% + \def\unnsecentry{\numsecentry}% + \def\unnsubsecentry{\numsubsecentry}% + \def\unnsubsubsecentry{\numsubsubsecentry}% + \readdatafile{toc}% + % + % Read toc second time, this time actually producing the outlines. + % The `-' means take the \expnumber as the absolute number of + % subentries, which we calculated on our first read of the .toc above. + % + % We use the node names as the destinations. + \def\numchapentry##1##2##3##4{% + \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}% + \def\numsecentry##1##2##3##4{% + \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}% + \def\numsubsecentry##1##2##3##4{% + \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}% + \def\numsubsubsecentry##1##2##3##4{% count is always zero + \dopdfoutline{##1}{}{##3}{##4}}% + % + % PDF outlines are displayed using system fonts, instead of + % document fonts. Therefore we cannot use special characters, + % since the encoding is unknown. For example, the eogonek from + % Latin 2 (0xea) gets translated to a | character. Info from + % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100. + % + % TODO this right, we have to translate 8-bit characters to + % their "best" equivalent, based on the @documentencoding. Too + % much work for too little return. Just use the ASCII equivalents + % we use for the index sort strings. + % + \indexnofonts + \setupdatafile + % We can have normal brace characters in the PDF outlines, unlike + % Texinfo index files. So set that up. + \def\{{\lbracecharliteral}% + \def\}{\rbracecharliteral}% + \catcode`\\=\active \otherbackslash + \input \tocreadfilename + \endgroup + } + {\catcode`[=1 \catcode`]=2 + \catcode`{=\other \catcode`}=\other + \gdef\lbracecharliteral[{]% + \gdef\rbracecharliteral[}]% + ] + % + \def\skipspaces#1{\def\PP{#1}\def\D{|}% + \ifx\PP\D\let\nextsp\relax + \else\let\nextsp\skipspaces + \ifx\p\space\else\addtokens{\filename}{\PP}% + \advance\filenamelength by 1 + \fi + \fi + \nextsp} + \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax} + \ifnum\pdftexversion < 14 + \let \startlink \pdfannotlink + \else + \let \startlink \pdfstartlink + \fi + % make a live url in pdf output. + \def\pdfurl#1{% + \begingroup + % it seems we really need yet another set of dummies; have not + % tried to figure out what each command should do in the context + % of @url. for now, just make @/ a no-op, that's the only one + % people have actually reported a problem with. + % + \normalturnoffactive + \def\@{@}% + \let\/=\empty + \makevalueexpandable + % do we want to go so far as to use \indexnofonts instead of just + % special-casing \var here? + \def\var##1{##1}% + % + \leavevmode\setcolor{\urlcolor}% + \startlink attr{/Border [0 0 0]}% + user{/Subtype /Link /A << /S /URI /URI (#1) >>}% + \endgroup} + \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} + \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} + \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} + \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} + \def\maketoks{% + \expandafter\poptoks\the\toksA|ENDTOKS|\relax + \ifx\first0\adn0 + \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 + \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 + \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 + \else + \ifnum0=\countA\else\makelink\fi + \ifx\first.\let\next=\done\else + \let\next=\maketoks + \addtokens{\toksB}{\the\toksD} + \ifx\first,\addtokens{\toksB}{\space}\fi + \fi + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi + \next} + \def\makelink{\addtokens{\toksB}% + {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} + \def\pdflink#1{% + \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}} + \setcolor{\linkcolor}#1\endlink} + \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} +\else + % non-pdf mode + \let\pdfmkdest = \gobble + \let\pdfurl = \gobble + \let\endlink = \relax + \let\setcolor = \gobble + \let\pdfsetcolor = \gobble + \let\pdfmakeoutlines = \relax +\fi % \ifx\pdfoutput + + +\message{fonts,} + +% Change the current font style to #1, remembering it in \curfontstyle. +% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in +% italics, not bold italics. +% +\def\setfontstyle#1{% + \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd. + \csname ten#1\endcsname % change the current font +} + +% Select #1 fonts with the current style. +% +\def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname} + +\def\rm{\fam=0 \setfontstyle{rm}} +\def\it{\fam=\itfam \setfontstyle{it}} +\def\sl{\fam=\slfam \setfontstyle{sl}} +\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf} +\def\tt{\fam=\ttfam \setfontstyle{tt}} + +% Unfortunately, we have to override this for titles and the like, since +% in those cases "rm" is bold. Sigh. +\def\rmisbold{\rm\def\curfontstyle{bf}} + +% Texinfo sort of supports the sans serif font style, which plain TeX does not. +% So we set up a \sf. +\newfam\sffam +\def\sf{\fam=\sffam \setfontstyle{sf}} +\let\li = \sf % Sometimes we call it \li, not \sf. + +% We don't need math for this font style. +\def\ttsl{\setfontstyle{ttsl}} + + +% Default leading. +\newdimen\textleading \textleading = 13.2pt + +% Set the baselineskip to #1, and the lineskip and strut size +% correspondingly. There is no deep meaning behind these magic numbers +% used as factors; they just match (closely enough) what Knuth defined. +% +\def\lineskipfactor{.08333} +\def\strutheightpercent{.70833} +\def\strutdepthpercent {.29167} +% +% can get a sort of poor man's double spacing by redefining this. +\def\baselinefactor{1} +% +\def\setleading#1{% + \dimen0 = #1\relax + \normalbaselineskip = \baselinefactor\dimen0 + \normallineskip = \lineskipfactor\normalbaselineskip + \normalbaselines + \setbox\strutbox =\hbox{% + \vrule width0pt height\strutheightpercent\baselineskip + depth \strutdepthpercent \baselineskip + }% +} + +% PDF CMaps. See also LaTeX's t1.cmap. +% +% do nothing with this by default. +\expandafter\let\csname cmapOT1\endcsname\gobble +\expandafter\let\csname cmapOT1IT\endcsname\gobble +\expandafter\let\csname cmapOT1TT\endcsname\gobble + +% if we are producing pdf, and we have \pdffontattr, then define cmaps. +% (\pdffontattr was introduced many years ago, but people still run +% older pdftex's; it's easy to conditionalize, so we do.) +\ifpdf \ifx\pdffontattr\thisisundefined \else + \begingroup + \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. + \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap +%%DocumentNeededResources: ProcSet (CIDInit) +%%IncludeResource: ProcSet (CIDInit) +%%BeginResource: CMap (TeX-OT1-0) +%%Title: (TeX-OT1-0 TeX OT1 0) +%%Version: 1.000 +%%EndComments +/CIDInit /ProcSet findresource begin +12 dict begin +begincmap +/CIDSystemInfo +<< /Registry (TeX) +/Ordering (OT1) +/Supplement 0 +>> def +/CMapName /TeX-OT1-0 def +/CMapType 2 def +1 begincodespacerange +<00> <7F> +endcodespacerange +8 beginbfrange +<00> <01> <0393> +<09> <0A> <03A8> +<23> <26> <0023> +<28> <3B> <0028> +<3F> <5B> <003F> +<5D> <5E> <005D> +<61> <7A> <0061> +<7B> <7C> <2013> +endbfrange +40 beginbfchar +<02> <0398> +<03> <039B> +<04> <039E> +<05> <03A0> +<06> <03A3> +<07> <03D2> +<08> <03A6> +<0B> <00660066> +<0C> <00660069> +<0D> <0066006C> +<0E> <006600660069> +<0F> <00660066006C> +<10> <0131> +<11> <0237> +<12> <0060> +<13> <00B4> +<14> <02C7> +<15> <02D8> +<16> <00AF> +<17> <02DA> +<18> <00B8> +<19> <00DF> +<1A> <00E6> +<1B> <0153> +<1C> <00F8> +<1D> <00C6> +<1E> <0152> +<1F> <00D8> +<21> <0021> +<22> <201D> +<27> <2019> +<3C> <00A1> +<3D> <003D> +<3E> <00BF> +<5C> <201C> +<5F> <02D9> +<60> <2018> +<7D> <02DD> +<7E> <007E> +<7F> <00A8> +endbfchar +endcmap +CMapName currentdict /CMap defineresource pop +end +end +%%EndResource +%%EOF + }\endgroup + \expandafter\edef\csname cmapOT1\endcsname#1{% + \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% + }% +% +% \cmapOT1IT + \begingroup + \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. + \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap +%%DocumentNeededResources: ProcSet (CIDInit) +%%IncludeResource: ProcSet (CIDInit) +%%BeginResource: CMap (TeX-OT1IT-0) +%%Title: (TeX-OT1IT-0 TeX OT1IT 0) +%%Version: 1.000 +%%EndComments +/CIDInit /ProcSet findresource begin +12 dict begin +begincmap +/CIDSystemInfo +<< /Registry (TeX) +/Ordering (OT1IT) +/Supplement 0 +>> def +/CMapName /TeX-OT1IT-0 def +/CMapType 2 def +1 begincodespacerange +<00> <7F> +endcodespacerange +8 beginbfrange +<00> <01> <0393> +<09> <0A> <03A8> +<25> <26> <0025> +<28> <3B> <0028> +<3F> <5B> <003F> +<5D> <5E> <005D> +<61> <7A> <0061> +<7B> <7C> <2013> +endbfrange +42 beginbfchar +<02> <0398> +<03> <039B> +<04> <039E> +<05> <03A0> +<06> <03A3> +<07> <03D2> +<08> <03A6> +<0B> <00660066> +<0C> <00660069> +<0D> <0066006C> +<0E> <006600660069> +<0F> <00660066006C> +<10> <0131> +<11> <0237> +<12> <0060> +<13> <00B4> +<14> <02C7> +<15> <02D8> +<16> <00AF> +<17> <02DA> +<18> <00B8> +<19> <00DF> +<1A> <00E6> +<1B> <0153> +<1C> <00F8> +<1D> <00C6> +<1E> <0152> +<1F> <00D8> +<21> <0021> +<22> <201D> +<23> <0023> +<24> <00A3> +<27> <2019> +<3C> <00A1> +<3D> <003D> +<3E> <00BF> +<5C> <201C> +<5F> <02D9> +<60> <2018> +<7D> <02DD> +<7E> <007E> +<7F> <00A8> +endbfchar +endcmap +CMapName currentdict /CMap defineresource pop +end +end +%%EndResource +%%EOF + }\endgroup + \expandafter\edef\csname cmapOT1IT\endcsname#1{% + \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% + }% +% +% \cmapOT1TT + \begingroup + \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. + \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap +%%DocumentNeededResources: ProcSet (CIDInit) +%%IncludeResource: ProcSet (CIDInit) +%%BeginResource: CMap (TeX-OT1TT-0) +%%Title: (TeX-OT1TT-0 TeX OT1TT 0) +%%Version: 1.000 +%%EndComments +/CIDInit /ProcSet findresource begin +12 dict begin +begincmap +/CIDSystemInfo +<< /Registry (TeX) +/Ordering (OT1TT) +/Supplement 0 +>> def +/CMapName /TeX-OT1TT-0 def +/CMapType 2 def +1 begincodespacerange +<00> <7F> +endcodespacerange +5 beginbfrange +<00> <01> <0393> +<09> <0A> <03A8> +<21> <26> <0021> +<28> <5F> <0028> +<61> <7E> <0061> +endbfrange +32 beginbfchar +<02> <0398> +<03> <039B> +<04> <039E> +<05> <03A0> +<06> <03A3> +<07> <03D2> +<08> <03A6> +<0B> <2191> +<0C> <2193> +<0D> <0027> +<0E> <00A1> +<0F> <00BF> +<10> <0131> +<11> <0237> +<12> <0060> +<13> <00B4> +<14> <02C7> +<15> <02D8> +<16> <00AF> +<17> <02DA> +<18> <00B8> +<19> <00DF> +<1A> <00E6> +<1B> <0153> +<1C> <00F8> +<1D> <00C6> +<1E> <0152> +<1F> <00D8> +<20> <2423> +<27> <2019> +<60> <2018> +<7F> <00A8> +endbfchar +endcmap +CMapName currentdict /CMap defineresource pop +end +end +%%EndResource +%%EOF + }\endgroup + \expandafter\edef\csname cmapOT1TT\endcsname#1{% + \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% + }% +\fi\fi + + +% Set the font macro #1 to the font named #2, adding on the +% specified font prefix (normally `cm'). +% #3 is the font's design size, #4 is a scale factor, #5 is the CMap +% encoding (currently only OT1, OT1IT and OT1TT are allowed, pass +% empty to omit). +\def\setfont#1#2#3#4#5{% + \font#1=\fontprefix#2#3 scaled #4 + \csname cmap#5\endcsname#1% +} +% This is what gets called when #5 of \setfont is empty. +\let\cmap\gobble +% emacs-page end of cmaps + +% Use cm as the default font prefix. +% To specify the font prefix, you must define \fontprefix +% before you read in texinfo.tex. +\ifx\fontprefix\thisisundefined +\def\fontprefix{cm} +\fi +% Support font families that don't use the same naming scheme as CM. +\def\rmshape{r} +\def\rmbshape{bx} %where the normal face is bold +\def\bfshape{b} +\def\bxshape{bx} +\def\ttshape{tt} +\def\ttbshape{tt} +\def\ttslshape{sltt} +\def\itshape{ti} +\def\itbshape{bxti} +\def\slshape{sl} +\def\slbshape{bxsl} +\def\sfshape{ss} +\def\sfbshape{ss} +\def\scshape{csc} +\def\scbshape{csc} + +% Definitions for a main text size of 11pt. This is the default in +% Texinfo. +% +\def\definetextfontsizexi{% +% Text fonts (11.2pt, magstep1). +\def\textnominalsize{11pt} +\edef\mainmagstep{\magstephalf} +\setfont\textrm\rmshape{10}{\mainmagstep}{OT1} +\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} +\setfont\textbf\bfshape{10}{\mainmagstep}{OT1} +\setfont\textit\itshape{10}{\mainmagstep}{OT1IT} +\setfont\textsl\slshape{10}{\mainmagstep}{OT1} +\setfont\textsf\sfshape{10}{\mainmagstep}{OT1} +\setfont\textsc\scshape{10}{\mainmagstep}{OT1} +\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} +\font\texti=cmmi10 scaled \mainmagstep +\font\textsy=cmsy10 scaled \mainmagstep +\def\textecsize{1095} + +% A few fonts for @defun names and args. +\setfont\defbf\bfshape{10}{\magstep1}{OT1} +\setfont\deftt\ttshape{10}{\magstep1}{OT1TT} +\setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT} +\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} + +% Fonts for indices, footnotes, small examples (9pt). +\def\smallnominalsize{9pt} +\setfont\smallrm\rmshape{9}{1000}{OT1} +\setfont\smalltt\ttshape{9}{1000}{OT1TT} +\setfont\smallbf\bfshape{10}{900}{OT1} +\setfont\smallit\itshape{9}{1000}{OT1IT} +\setfont\smallsl\slshape{9}{1000}{OT1} +\setfont\smallsf\sfshape{9}{1000}{OT1} +\setfont\smallsc\scshape{10}{900}{OT1} +\setfont\smallttsl\ttslshape{10}{900}{OT1TT} +\font\smalli=cmmi9 +\font\smallsy=cmsy9 +\def\smallecsize{0900} + +% Fonts for small examples (8pt). +\def\smallernominalsize{8pt} +\setfont\smallerrm\rmshape{8}{1000}{OT1} +\setfont\smallertt\ttshape{8}{1000}{OT1TT} +\setfont\smallerbf\bfshape{10}{800}{OT1} +\setfont\smallerit\itshape{8}{1000}{OT1IT} +\setfont\smallersl\slshape{8}{1000}{OT1} +\setfont\smallersf\sfshape{8}{1000}{OT1} +\setfont\smallersc\scshape{10}{800}{OT1} +\setfont\smallerttsl\ttslshape{10}{800}{OT1TT} +\font\smalleri=cmmi8 +\font\smallersy=cmsy8 +\def\smallerecsize{0800} + +% Fonts for title page (20.4pt): +\def\titlenominalsize{20pt} +\setfont\titlerm\rmbshape{12}{\magstep3}{OT1} +\setfont\titleit\itbshape{10}{\magstep4}{OT1IT} +\setfont\titlesl\slbshape{10}{\magstep4}{OT1} +\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} +\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} +\setfont\titlesf\sfbshape{17}{\magstep1}{OT1} +\let\titlebf=\titlerm +\setfont\titlesc\scbshape{10}{\magstep4}{OT1} +\font\titlei=cmmi12 scaled \magstep3 +\font\titlesy=cmsy10 scaled \magstep4 +\def\titleecsize{2074} + +% Chapter (and unnumbered) fonts (17.28pt). +\def\chapnominalsize{17pt} +\setfont\chaprm\rmbshape{12}{\magstep2}{OT1} +\setfont\chapit\itbshape{10}{\magstep3}{OT1IT} +\setfont\chapsl\slbshape{10}{\magstep3}{OT1} +\setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT} +\setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT} +\setfont\chapsf\sfbshape{17}{1000}{OT1} +\let\chapbf=\chaprm +\setfont\chapsc\scbshape{10}{\magstep3}{OT1} +\font\chapi=cmmi12 scaled \magstep2 +\font\chapsy=cmsy10 scaled \magstep3 +\def\chapecsize{1728} + +% Section fonts (14.4pt). +\def\secnominalsize{14pt} +\setfont\secrm\rmbshape{12}{\magstep1}{OT1} +\setfont\secit\itbshape{10}{\magstep2}{OT1IT} +\setfont\secsl\slbshape{10}{\magstep2}{OT1} +\setfont\sectt\ttbshape{12}{\magstep1}{OT1TT} +\setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT} +\setfont\secsf\sfbshape{12}{\magstep1}{OT1} +\let\secbf\secrm +\setfont\secsc\scbshape{10}{\magstep2}{OT1} +\font\seci=cmmi12 scaled \magstep1 +\font\secsy=cmsy10 scaled \magstep2 +\def\sececsize{1440} + +% Subsection fonts (13.15pt). +\def\ssecnominalsize{13pt} +\setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1} +\setfont\ssecit\itbshape{10}{1315}{OT1IT} +\setfont\ssecsl\slbshape{10}{1315}{OT1} +\setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT} +\setfont\ssecttsl\ttslshape{10}{1315}{OT1TT} +\setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1} +\let\ssecbf\ssecrm +\setfont\ssecsc\scbshape{10}{1315}{OT1} +\font\sseci=cmmi12 scaled \magstephalf +\font\ssecsy=cmsy10 scaled 1315 +\def\ssececsize{1200} + +% Reduced fonts for @acro in text (10pt). +\def\reducednominalsize{10pt} +\setfont\reducedrm\rmshape{10}{1000}{OT1} +\setfont\reducedtt\ttshape{10}{1000}{OT1TT} +\setfont\reducedbf\bfshape{10}{1000}{OT1} +\setfont\reducedit\itshape{10}{1000}{OT1IT} +\setfont\reducedsl\slshape{10}{1000}{OT1} +\setfont\reducedsf\sfshape{10}{1000}{OT1} +\setfont\reducedsc\scshape{10}{1000}{OT1} +\setfont\reducedttsl\ttslshape{10}{1000}{OT1TT} +\font\reducedi=cmmi10 +\font\reducedsy=cmsy10 +\def\reducedecsize{1000} + +\textleading = 13.2pt % line spacing for 11pt CM +\textfonts % reset the current fonts +\rm +} % end of 11pt text font size definitions + + +% Definitions to make the main text be 10pt Computer Modern, with +% section, chapter, etc., sizes following suit. This is for the GNU +% Press printing of the Emacs 22 manual. Maybe other manuals in the +% future. Used with @smallbook, which sets the leading to 12pt. +% +\def\definetextfontsizex{% +% Text fonts (10pt). +\def\textnominalsize{10pt} +\edef\mainmagstep{1000} +\setfont\textrm\rmshape{10}{\mainmagstep}{OT1} +\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} +\setfont\textbf\bfshape{10}{\mainmagstep}{OT1} +\setfont\textit\itshape{10}{\mainmagstep}{OT1IT} +\setfont\textsl\slshape{10}{\mainmagstep}{OT1} +\setfont\textsf\sfshape{10}{\mainmagstep}{OT1} +\setfont\textsc\scshape{10}{\mainmagstep}{OT1} +\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} +\font\texti=cmmi10 scaled \mainmagstep +\font\textsy=cmsy10 scaled \mainmagstep +\def\textecsize{1000} + +% A few fonts for @defun names and args. +\setfont\defbf\bfshape{10}{\magstephalf}{OT1} +\setfont\deftt\ttshape{10}{\magstephalf}{OT1TT} +\setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT} +\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} + +% Fonts for indices, footnotes, small examples (9pt). +\def\smallnominalsize{9pt} +\setfont\smallrm\rmshape{9}{1000}{OT1} +\setfont\smalltt\ttshape{9}{1000}{OT1TT} +\setfont\smallbf\bfshape{10}{900}{OT1} +\setfont\smallit\itshape{9}{1000}{OT1IT} +\setfont\smallsl\slshape{9}{1000}{OT1} +\setfont\smallsf\sfshape{9}{1000}{OT1} +\setfont\smallsc\scshape{10}{900}{OT1} +\setfont\smallttsl\ttslshape{10}{900}{OT1TT} +\font\smalli=cmmi9 +\font\smallsy=cmsy9 +\def\smallecsize{0900} + +% Fonts for small examples (8pt). +\def\smallernominalsize{8pt} +\setfont\smallerrm\rmshape{8}{1000}{OT1} +\setfont\smallertt\ttshape{8}{1000}{OT1TT} +\setfont\smallerbf\bfshape{10}{800}{OT1} +\setfont\smallerit\itshape{8}{1000}{OT1IT} +\setfont\smallersl\slshape{8}{1000}{OT1} +\setfont\smallersf\sfshape{8}{1000}{OT1} +\setfont\smallersc\scshape{10}{800}{OT1} +\setfont\smallerttsl\ttslshape{10}{800}{OT1TT} +\font\smalleri=cmmi8 +\font\smallersy=cmsy8 +\def\smallerecsize{0800} + +% Fonts for title page (20.4pt): +\def\titlenominalsize{20pt} +\setfont\titlerm\rmbshape{12}{\magstep3}{OT1} +\setfont\titleit\itbshape{10}{\magstep4}{OT1IT} +\setfont\titlesl\slbshape{10}{\magstep4}{OT1} +\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} +\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} +\setfont\titlesf\sfbshape{17}{\magstep1}{OT1} +\let\titlebf=\titlerm +\setfont\titlesc\scbshape{10}{\magstep4}{OT1} +\font\titlei=cmmi12 scaled \magstep3 +\font\titlesy=cmsy10 scaled \magstep4 +\def\titleecsize{2074} + +% Chapter fonts (14.4pt). +\def\chapnominalsize{14pt} +\setfont\chaprm\rmbshape{12}{\magstep1}{OT1} +\setfont\chapit\itbshape{10}{\magstep2}{OT1IT} +\setfont\chapsl\slbshape{10}{\magstep2}{OT1} +\setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT} +\setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT} +\setfont\chapsf\sfbshape{12}{\magstep1}{OT1} +\let\chapbf\chaprm +\setfont\chapsc\scbshape{10}{\magstep2}{OT1} +\font\chapi=cmmi12 scaled \magstep1 +\font\chapsy=cmsy10 scaled \magstep2 +\def\chapecsize{1440} + +% Section fonts (12pt). +\def\secnominalsize{12pt} +\setfont\secrm\rmbshape{12}{1000}{OT1} +\setfont\secit\itbshape{10}{\magstep1}{OT1IT} +\setfont\secsl\slbshape{10}{\magstep1}{OT1} +\setfont\sectt\ttbshape{12}{1000}{OT1TT} +\setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT} +\setfont\secsf\sfbshape{12}{1000}{OT1} +\let\secbf\secrm +\setfont\secsc\scbshape{10}{\magstep1}{OT1} +\font\seci=cmmi12 +\font\secsy=cmsy10 scaled \magstep1 +\def\sececsize{1200} + +% Subsection fonts (10pt). +\def\ssecnominalsize{10pt} +\setfont\ssecrm\rmbshape{10}{1000}{OT1} +\setfont\ssecit\itbshape{10}{1000}{OT1IT} +\setfont\ssecsl\slbshape{10}{1000}{OT1} +\setfont\ssectt\ttbshape{10}{1000}{OT1TT} +\setfont\ssecttsl\ttslshape{10}{1000}{OT1TT} +\setfont\ssecsf\sfbshape{10}{1000}{OT1} +\let\ssecbf\ssecrm +\setfont\ssecsc\scbshape{10}{1000}{OT1} +\font\sseci=cmmi10 +\font\ssecsy=cmsy10 +\def\ssececsize{1000} + +% Reduced fonts for @acro in text (9pt). +\def\reducednominalsize{9pt} +\setfont\reducedrm\rmshape{9}{1000}{OT1} +\setfont\reducedtt\ttshape{9}{1000}{OT1TT} +\setfont\reducedbf\bfshape{10}{900}{OT1} +\setfont\reducedit\itshape{9}{1000}{OT1IT} +\setfont\reducedsl\slshape{9}{1000}{OT1} +\setfont\reducedsf\sfshape{9}{1000}{OT1} +\setfont\reducedsc\scshape{10}{900}{OT1} +\setfont\reducedttsl\ttslshape{10}{900}{OT1TT} +\font\reducedi=cmmi9 +\font\reducedsy=cmsy9 +\def\reducedecsize{0900} + +\divide\parskip by 2 % reduce space between paragraphs +\textleading = 12pt % line spacing for 10pt CM +\textfonts % reset the current fonts +\rm +} % end of 10pt text font size definitions + + +% We provide the user-level command +% @fonttextsize 10 +% (or 11) to redefine the text font size. pt is assumed. +% +\def\xiword{11} +\def\xword{10} +\def\xwordpt{10pt} +% +\parseargdef\fonttextsize{% + \def\textsizearg{#1}% + %\wlog{doing @fonttextsize \textsizearg}% + % + % Set \globaldefs so that documents can use this inside @tex, since + % makeinfo 4.8 does not support it, but we need it nonetheless. + % + \begingroup \globaldefs=1 + \ifx\textsizearg\xword \definetextfontsizex + \else \ifx\textsizearg\xiword \definetextfontsizexi + \else + \errhelp=\EMsimple + \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'} + \fi\fi + \endgroup +} + + +% In order for the font changes to affect most math symbols and letters, +% we have to define the \textfont of the standard families. Since +% texinfo doesn't allow for producing subscripts and superscripts except +% in the main text, we don't bother to reset \scriptfont and +% \scriptscriptfont (which would also require loading a lot more fonts). +% +\def\resetmathfonts{% + \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy + \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf + \textfont\ttfam=\tentt \textfont\sffam=\tensf +} + +% The font-changing commands redefine the meanings of \tenSTYLE, instead +% of just \STYLE. We do this because \STYLE needs to also set the +% current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire +% \tenSTYLE to set the current font. +% +% Each font-changing command also sets the names \lsize (one size lower) +% and \lllsize (three sizes lower). These relative commands are used in +% the LaTeX logo and acronyms. +% +% This all needs generalizing, badly. +% +\def\textfonts{% + \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl + \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc + \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy + \let\tenttsl=\textttsl + \def\curfontsize{text}% + \def\lsize{reduced}\def\lllsize{smaller}% + \resetmathfonts \setleading{\textleading}} +\def\titlefonts{% + \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl + \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc + \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy + \let\tenttsl=\titlettsl + \def\curfontsize{title}% + \def\lsize{chap}\def\lllsize{subsec}% + \resetmathfonts \setleading{27pt}} +\def\titlefont#1{{\titlefonts\rmisbold #1}} +\def\chapfonts{% + \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl + \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc + \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy + \let\tenttsl=\chapttsl + \def\curfontsize{chap}% + \def\lsize{sec}\def\lllsize{text}% + \resetmathfonts \setleading{19pt}} +\def\secfonts{% + \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl + \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc + \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy + \let\tenttsl=\secttsl + \def\curfontsize{sec}% + \def\lsize{subsec}\def\lllsize{reduced}% + \resetmathfonts \setleading{16pt}} +\def\subsecfonts{% + \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl + \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc + \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy + \let\tenttsl=\ssecttsl + \def\curfontsize{ssec}% + \def\lsize{text}\def\lllsize{small}% + \resetmathfonts \setleading{15pt}} +\let\subsubsecfonts = \subsecfonts +\def\reducedfonts{% + \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl + \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc + \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy + \let\tenttsl=\reducedttsl + \def\curfontsize{reduced}% + \def\lsize{small}\def\lllsize{smaller}% + \resetmathfonts \setleading{10.5pt}} +\def\smallfonts{% + \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl + \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc + \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy + \let\tenttsl=\smallttsl + \def\curfontsize{small}% + \def\lsize{smaller}\def\lllsize{smaller}% + \resetmathfonts \setleading{10.5pt}} +\def\smallerfonts{% + \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl + \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc + \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy + \let\tenttsl=\smallerttsl + \def\curfontsize{smaller}% + \def\lsize{smaller}\def\lllsize{smaller}% + \resetmathfonts \setleading{9.5pt}} + +% Fonts for short table of contents. +\setfont\shortcontrm\rmshape{12}{1000}{OT1} +\setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12 +\setfont\shortcontsl\slshape{12}{1000}{OT1} +\setfont\shortconttt\ttshape{12}{1000}{OT1TT} + +% Define these just so they can be easily changed for other fonts. +\def\angleleft{$\langle$} +\def\angleright{$\rangle$} + +% Set the fonts to use with the @small... environments. +\let\smallexamplefonts = \smallfonts + +% About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample +% can fit this many characters: +% 8.5x11=86 smallbook=72 a4=90 a5=69 +% If we use \scriptfonts (8pt), then we can fit this many characters: +% 8.5x11=90+ smallbook=80 a4=90+ a5=77 +% For me, subjectively, the few extra characters that fit aren't worth +% the additional smallness of 8pt. So I'm making the default 9pt. +% +% By the way, for comparison, here's what fits with @example (10pt): +% 8.5x11=71 smallbook=60 a4=75 a5=58 +% --karl, 24jan03. + +% Set up the default fonts, so we can use them for creating boxes. +% +\definetextfontsizexi + + +\message{markup,} + +% Check if we are currently using a typewriter font. Since all the +% Computer Modern typewriter fonts have zero interword stretch (and +% shrink), and it is reasonable to expect all typewriter fonts to have +% this property, we can check that font parameter. +% +\def\ifmonospace{\ifdim\fontdimen3\font=0pt } + +% Markup style infrastructure. \defmarkupstylesetup\INITMACRO will +% define and register \INITMACRO to be called on markup style changes. +% \INITMACRO can check \currentmarkupstyle for the innermost +% style and the set of \ifmarkupSTYLE switches for all styles +% currently in effect. +\newif\ifmarkupvar +\newif\ifmarkupsamp +\newif\ifmarkupkey +%\newif\ifmarkupfile % @file == @samp. +%\newif\ifmarkupoption % @option == @samp. +\newif\ifmarkupcode +\newif\ifmarkupkbd +%\newif\ifmarkupenv % @env == @code. +%\newif\ifmarkupcommand % @command == @code. +\newif\ifmarkuptex % @tex (and part of @math, for now). +\newif\ifmarkupexample +\newif\ifmarkupverb +\newif\ifmarkupverbatim + +\let\currentmarkupstyle\empty + +\def\setupmarkupstyle#1{% + \csname markup#1true\endcsname + \def\currentmarkupstyle{#1}% + \markupstylesetup +} + +\let\markupstylesetup\empty + +\def\defmarkupstylesetup#1{% + \expandafter\def\expandafter\markupstylesetup + \expandafter{\markupstylesetup #1}% + \def#1% +} + +% Markup style setup for left and right quotes. +\defmarkupstylesetup\markupsetuplq{% + \expandafter\let\expandafter \temp + \csname markupsetuplq\currentmarkupstyle\endcsname + \ifx\temp\relax \markupsetuplqdefault \else \temp \fi +} + +\defmarkupstylesetup\markupsetuprq{% + \expandafter\let\expandafter \temp + \csname markupsetuprq\currentmarkupstyle\endcsname + \ifx\temp\relax \markupsetuprqdefault \else \temp \fi +} + +{ +\catcode`\'=\active +\catcode`\`=\active + +\gdef\markupsetuplqdefault{\let`\lq} +\gdef\markupsetuprqdefault{\let'\rq} + +\gdef\markupsetcodequoteleft{\let`\codequoteleft} +\gdef\markupsetcodequoteright{\let'\codequoteright} + +\gdef\markupsetnoligaturesquoteleft{\let`\noligaturesquoteleft} +} + +\let\markupsetuplqcode \markupsetcodequoteleft +\let\markupsetuprqcode \markupsetcodequoteright +% +\let\markupsetuplqexample \markupsetcodequoteleft +\let\markupsetuprqexample \markupsetcodequoteright +% +\let\markupsetuplqsamp \markupsetcodequoteleft +\let\markupsetuprqsamp \markupsetcodequoteright +% +\let\markupsetuplqverb \markupsetcodequoteleft +\let\markupsetuprqverb \markupsetcodequoteright +% +\let\markupsetuplqverbatim \markupsetcodequoteleft +\let\markupsetuprqverbatim \markupsetcodequoteright + +\let\markupsetuplqkbd \markupsetnoligaturesquoteleft + +% Allow an option to not use regular directed right quote/apostrophe +% (char 0x27), but instead the undirected quote from cmtt (char 0x0d). +% The undirected quote is ugly, so don't make it the default, but it +% works for pasting with more pdf viewers (at least evince), the +% lilypond developers report. xpdf does work with the regular 0x27. +% +\def\codequoteright{% + \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax + \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax + '% + \else \char'15 \fi + \else \char'15 \fi +} +% +% and a similar option for the left quote char vs. a grave accent. +% Modern fonts display ASCII 0x60 as a grave accent, so some people like +% the code environments to do likewise. +% +\def\codequoteleft{% + \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax + \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax + % [Knuth] pp. 380,381,391 + % \relax disables Spanish ligatures ?` and !` of \tt font. + \relax`% + \else \char'22 \fi + \else \char'22 \fi +} + +% Commands to set the quote options. +% +\parseargdef\codequoteundirected{% + \def\temp{#1}% + \ifx\temp\onword + \expandafter\let\csname SETtxicodequoteundirected\endcsname + = t% + \else\ifx\temp\offword + \expandafter\let\csname SETtxicodequoteundirected\endcsname + = \relax + \else + \errhelp = \EMsimple + \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}% + \fi\fi +} +% +\parseargdef\codequotebacktick{% + \def\temp{#1}% + \ifx\temp\onword + \expandafter\let\csname SETtxicodequotebacktick\endcsname + = t% + \else\ifx\temp\offword + \expandafter\let\csname SETtxicodequotebacktick\endcsname + = \relax + \else + \errhelp = \EMsimple + \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}% + \fi\fi +} + +% [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font. +\def\noligaturesquoteleft{\relax\lq} + +% Count depth in font-changes, for error checks +\newcount\fontdepth \fontdepth=0 + +% Font commands. + +% #1 is the font command (\sl or \it), #2 is the text to slant. +% If we are in a monospaced environment, however, 1) always use \ttsl, +% and 2) do not add an italic correction. +\def\dosmartslant#1#2{% + \ifusingtt + {{\ttsl #2}\let\next=\relax}% + {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}% + \next +} +\def\smartslanted{\dosmartslant\sl} +\def\smartitalic{\dosmartslant\it} + +% Output an italic correction unless \next (presumed to be the following +% character) is such as not to need one. +\def\smartitaliccorrection{% + \ifx\next,% + \else\ifx\next-% + \else\ifx\next.% + \else\ptexslash + \fi\fi\fi + \aftersmartic +} + +% like \smartslanted except unconditionally uses \ttsl, and no ic. +% @var is set to this for defun arguments. +\def\ttslanted#1{{\ttsl #1}} + +% @cite is like \smartslanted except unconditionally use \sl. We never want +% ttsl for book titles, do we? +\def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection} + +\def\aftersmartic{} +\def\var#1{% + \let\saveaftersmartic = \aftersmartic + \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}% + \smartslanted{#1}% +} + +\let\i=\smartitalic +\let\slanted=\smartslanted +\let\dfn=\smartslanted +\let\emph=\smartitalic + +% Explicit font changes: @r, @sc, undocumented @ii. +\def\r#1{{\rm #1}} % roman font +\def\sc#1{{\smallcaps#1}} % smallcaps font +\def\ii#1{{\it #1}} % italic font + +% @b, explicit bold. Also @strong. +\def\b#1{{\bf #1}} +\let\strong=\b + +% @sansserif, explicit sans. +\def\sansserif#1{{\sf #1}} + +% We can't just use \exhyphenpenalty, because that only has effect at +% the end of a paragraph. Restore normal hyphenation at the end of the +% group within which \nohyphenation is presumably called. +% +\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} +\def\restorehyphenation{\hyphenchar\font = `- } + +% Set sfcode to normal for the chars that usually have another value. +% Can't use plain's \frenchspacing because it uses the `\x notation, and +% sometimes \x has an active definition that messes things up. +% +\catcode`@=11 + \def\plainfrenchspacing{% + \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m + \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m + \def\endofsentencespacefactor{1000}% for @. and friends + } + \def\plainnonfrenchspacing{% + \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000 + \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250 + \def\endofsentencespacefactor{3000}% for @. and friends + } +\catcode`@=\other +\def\endofsentencespacefactor{3000}% default + +% @t, explicit typewriter. +\def\t#1{% + {\tt \rawbackslash \plainfrenchspacing #1}% + \null +} + +% @samp. +\def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}} + +% definition of @key that produces a lozenge. Doesn't adjust to text size. +%\setfont\keyrm\rmshape{8}{1000}{OT1} +%\font\keysy=cmsy9 +%\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{% +% \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% +% \vbox{\hrule\kern-0.4pt +% \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% +% \kern-0.4pt\hrule}% +% \kern-.06em\raise0.4pt\hbox{\angleright}}}} + +% definition of @key with no lozenge. If the current font is already +% monospace, don't change it; that way, we respect @kbdinputstyle. But +% if it isn't monospace, then use \tt. +% +\def\key#1{{\setupmarkupstyle{key}% + \nohyphenation + \ifmonospace\else\tt\fi + #1}\null} + +% ctrl is no longer a Texinfo command. +\def\ctrl #1{{\tt \rawbackslash \hat}#1} + +% @file, @option are the same as @samp. +\let\file=\samp +\let\option=\samp + +% @code is a modification of @t, +% which makes spaces the same size as normal in the surrounding text. +\def\tclose#1{% + {% + % Change normal interword space to be same as for the current font. + \spaceskip = \fontdimen2\font + % + % Switch to typewriter. + \tt + % + % But `\ ' produces the large typewriter interword space. + \def\ {{\spaceskip = 0pt{} }}% + % + % Turn off hyphenation. + \nohyphenation + % + \rawbackslash + \plainfrenchspacing + #1% + }% + \null % reset spacefactor to 1000 +} + +% We *must* turn on hyphenation at `-' and `_' in @code. +% Otherwise, it is too hard to avoid overfull hboxes +% in the Emacs manual, the Library manual, etc. + +% Unfortunately, TeX uses one parameter (\hyphenchar) to control +% both hyphenation at - and hyphenation within words. +% We must therefore turn them both off (\tclose does that) +% and arrange explicitly to hyphenate at a dash. +% -- rms. +{ + \catcode`\-=\active \catcode`\_=\active + \catcode`\'=\active \catcode`\`=\active + \global\let'=\rq \global\let`=\lq % default definitions + % + \global\def\code{\begingroup + \setupmarkupstyle{code}% + % The following should really be moved into \setupmarkupstyle handlers. + \catcode\dashChar=\active \catcode\underChar=\active + \ifallowcodebreaks + \let-\codedash + \let_\codeunder + \else + \let-\realdash + \let_\realunder + \fi + \codex + } +} + +\def\codex #1{\tclose{#1}\endgroup} + +\def\realdash{-} +\def\codedash{-\discretionary{}{}{}} +\def\codeunder{% + % this is all so @math{@code{var_name}+1} can work. In math mode, _ + % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.) + % will therefore expand the active definition of _, which is us + % (inside @code that is), therefore an endless loop. + \ifusingtt{\ifmmode + \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_. + \else\normalunderscore \fi + \discretionary{}{}{}}% + {\_}% +} + +% An additional complication: the above will allow breaks after, e.g., +% each of the four underscores in __typeof__. This is undesirable in +% some manuals, especially if they don't have long identifiers in +% general. @allowcodebreaks provides a way to control this. +% +\newif\ifallowcodebreaks \allowcodebreakstrue + +\def\keywordtrue{true} +\def\keywordfalse{false} + +\parseargdef\allowcodebreaks{% + \def\txiarg{#1}% + \ifx\txiarg\keywordtrue + \allowcodebreakstrue + \else\ifx\txiarg\keywordfalse + \allowcodebreaksfalse + \else + \errhelp = \EMsimple + \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}% + \fi\fi +} + +% @uref (abbreviation for `urlref') takes an optional (comma-separated) +% second argument specifying the text to display and an optional third +% arg as text to display instead of (rather than in addition to) the url +% itself. First (mandatory) arg is the url. +% (This \urefnobreak definition isn't used now, leaving it for a while +% for comparison.) +\def\urefnobreak#1{\dourefnobreak #1,,,\finish} +\def\dourefnobreak#1,#2,#3,#4\finish{\begingroup + \unsepspaces + \pdfurl{#1}% + \setbox0 = \hbox{\ignorespaces #3}% + \ifdim\wd0 > 0pt + \unhbox0 % third arg given, show only that + \else + \setbox0 = \hbox{\ignorespaces #2}% + \ifdim\wd0 > 0pt + \ifpdf + \unhbox0 % PDF: 2nd arg given, show only it + \else + \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url + \fi + \else + \code{#1}% only url given, so show it + \fi + \fi + \endlink +\endgroup} + +% This \urefbreak definition is the active one. +\def\urefbreak{\begingroup \urefcatcodes \dourefbreak} +\let\uref=\urefbreak +\def\dourefbreak#1{\urefbreakfinish #1,,,\finish} +\def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example + \unsepspaces + \pdfurl{#1}% + \setbox0 = \hbox{\ignorespaces #3}% + \ifdim\wd0 > 0pt + \unhbox0 % third arg given, show only that + \else + \setbox0 = \hbox{\ignorespaces #2}% + \ifdim\wd0 > 0pt + \ifpdf + \unhbox0 % PDF: 2nd arg given, show only it + \else + \unhbox0\ (\urefcode{#1})% DVI: 2nd arg given, show both it and url + \fi + \else + \urefcode{#1}% only url given, so show it + \fi + \fi + \endlink +\endgroup} + +% Allow line breaks around only a few characters (only). +\def\urefcatcodes{% + \catcode\ampChar=\active \catcode\dotChar=\active + \catcode\hashChar=\active \catcode\questChar=\active + \catcode\slashChar=\active +} +{ + \urefcatcodes + % + \global\def\urefcode{\begingroup + \setupmarkupstyle{code}% + \urefcatcodes + \let&\urefcodeamp + \let.\urefcodedot + \let#\urefcodehash + \let?\urefcodequest + \let/\urefcodeslash + \codex + } + % + % By default, they are just regular characters. + \global\def&{\normalamp} + \global\def.{\normaldot} + \global\def#{\normalhash} + \global\def?{\normalquest} + \global\def/{\normalslash} +} + +% we put a little stretch before and after the breakable chars, to help +% line breaking of long url's. The unequal skips make look better in +% cmtt at least, especially for dots. +\def\urefprestretch{\urefprebreak \hskip0pt plus.13em } +\def\urefpoststretch{\urefpostbreak \hskip0pt plus.1em } +% +\def\urefcodeamp{\urefprestretch \&\urefpoststretch} +\def\urefcodedot{\urefprestretch .\urefpoststretch} +\def\urefcodehash{\urefprestretch \#\urefpoststretch} +\def\urefcodequest{\urefprestretch ?\urefpoststretch} +\def\urefcodeslash{\futurelet\next\urefcodeslashfinish} +{ + \catcode`\/=\active + \global\def\urefcodeslashfinish{% + \urefprestretch \slashChar + % Allow line break only after the final / in a sequence of + % slashes, to avoid line break between the slashes in http://. + \ifx\next/\else \urefpoststretch \fi + } +} + +% One more complication: by default we'll break after the special +% characters, but some people like to break before the special chars, so +% allow that. Also allow no breaking at all, for manual control. +% +\parseargdef\urefbreakstyle{% + \def\txiarg{#1}% + \ifx\txiarg\wordnone + \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak} + \else\ifx\txiarg\wordbefore + \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak} + \else\ifx\txiarg\wordafter + \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak} + \else + \errhelp = \EMsimple + \errmessage{Unknown @urefbreakstyle setting `\txiarg'}% + \fi\fi\fi +} +\def\wordafter{after} +\def\wordbefore{before} +\def\wordnone{none} + +\urefbreakstyle after + +% @url synonym for @uref, since that's how everyone uses it. +% +\let\url=\uref + +% rms does not like angle brackets --karl, 17may97. +% So now @email is just like @uref, unless we are pdf. +% +%\def\email#1{\angleleft{\tt #1}\angleright} +\ifpdf + \def\email#1{\doemail#1,,\finish} + \def\doemail#1,#2,#3\finish{\begingroup + \unsepspaces + \pdfurl{mailto:#1}% + \setbox0 = \hbox{\ignorespaces #2}% + \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi + \endlink + \endgroup} +\else + \let\email=\uref +\fi + +% @kbd is like @code, except that if the argument is just one @key command, +% then @kbd has no effect. +\def\kbd#1{{\setupmarkupstyle{kbd}\def\look{#1}\expandafter\kbdfoo\look??\par}} + +% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), +% `example' (@kbd uses ttsl only inside of @example and friends), +% or `code' (@kbd uses normal tty font always). +\parseargdef\kbdinputstyle{% + \def\txiarg{#1}% + \ifx\txiarg\worddistinct + \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% + \else\ifx\txiarg\wordexample + \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% + \else\ifx\txiarg\wordcode + \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% + \else + \errhelp = \EMsimple + \errmessage{Unknown @kbdinputstyle setting `\txiarg'}% + \fi\fi\fi +} +\def\worddistinct{distinct} +\def\wordexample{example} +\def\wordcode{code} + +% Default is `distinct'. +\kbdinputstyle distinct + +\def\xkey{\key} +\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% +\ifx\one\xkey\ifx\threex\three \key{#2}% +\else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi +\else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi} + +% For @indicateurl, @env, @command quotes seem unnecessary, so use \code. +\let\indicateurl=\code +\let\env=\code +\let\command=\code + +% @clicksequence{File @click{} Open ...} +\def\clicksequence#1{\begingroup #1\endgroup} + +% @clickstyle @arrow (by default) +\parseargdef\clickstyle{\def\click{#1}} +\def\click{\arrow} + +% Typeset a dimension, e.g., `in' or `pt'. The only reason for the +% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. +% +\def\dmn#1{\thinspace #1} + +% @l was never documented to mean ``switch to the Lisp font'', +% and it is not used as such in any manual I can find. We need it for +% Polish suppressed-l. --karl, 22sep96. +%\def\l#1{{\li #1}\null} + +% @acronym for "FBI", "NATO", and the like. +% We print this one point size smaller, since it's intended for +% all-uppercase. +% +\def\acronym#1{\doacronym #1,,\finish} +\def\doacronym#1,#2,#3\finish{% + {\selectfonts\lsize #1}% + \def\temp{#2}% + \ifx\temp\empty \else + \space ({\unsepspaces \ignorespaces \temp \unskip})% + \fi + \null % reset \spacefactor=1000 +} + +% @abbr for "Comput. J." and the like. +% No font change, but don't do end-of-sentence spacing. +% +\def\abbr#1{\doabbr #1,,\finish} +\def\doabbr#1,#2,#3\finish{% + {\plainfrenchspacing #1}% + \def\temp{#2}% + \ifx\temp\empty \else + \space ({\unsepspaces \ignorespaces \temp \unskip})% + \fi + \null % reset \spacefactor=1000 +} + +% @asis just yields its argument. Used with @table, for example. +% +\def\asis#1{#1} + +% @math outputs its argument in math mode. +% +% One complication: _ usually means subscripts, but it could also mean +% an actual _ character, as in @math{@var{some_variable} + 1}. So make +% _ active, and distinguish by seeing if the current family is \slfam, +% which is what @var uses. +{ + \catcode`\_ = \active + \gdef\mathunderscore{% + \catcode`\_=\active + \def_{\ifnum\fam=\slfam \_\else\sb\fi}% + } +} +% Another complication: we want \\ (and @\) to output a math (or tt) \. +% FYI, plain.tex uses \\ as a temporary control sequence (for no +% particular reason), but this is not advertised and we don't care. +% +% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. +\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} +% +\def\math{% + \tex + \mathunderscore + \let\\ = \mathbackslash + \mathactive + % make the texinfo accent commands work in math mode + \let\"=\ddot + \let\'=\acute + \let\==\bar + \let\^=\hat + \let\`=\grave + \let\u=\breve + \let\v=\check + \let\~=\tilde + \let\dotaccent=\dot + $\finishmath +} +\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex. + +% Some active characters (such as <) are spaced differently in math. +% We have to reset their definitions in case the @math was an argument +% to a command which sets the catcodes (such as @item or @section). +% +{ + \catcode`^ = \active + \catcode`< = \active + \catcode`> = \active + \catcode`+ = \active + \catcode`' = \active + \gdef\mathactive{% + \let^ = \ptexhat + \let< = \ptexless + \let> = \ptexgtr + \let+ = \ptexplus + \let' = \ptexquoteright + } +} + +% @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}. +% Ignore unless FMTNAME == tex; then it is like @iftex and @tex, +% except specified as a normal braced arg, so no newlines to worry about. +% +\def\outfmtnametex{tex} +% +\long\def\inlinefmt#1{\doinlinefmt #1,\finish} +\long\def\doinlinefmt#1,#2,\finish{% + \def\inlinefmtname{#1}% + \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi +} +% For raw, must switch into @tex before parsing the argument, to avoid +% setting catcodes prematurely. Doing it this way means that, for +% example, @inlineraw{html, foo{bar} gets a parse error instead of being +% ignored. But this isn't important because if people want a literal +% *right* brace they would have to use a command anyway, so they may as +% well use a command to get a left brace too. We could re-use the +% delimiter character idea from \verb, but it seems like overkill. +% +\long\def\inlineraw{\tex \doinlineraw} +\long\def\doinlineraw#1{\doinlinerawtwo #1,\finish} +\def\doinlinerawtwo#1,#2,\finish{% + \def\inlinerawname{#1}% + \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi + \endgroup % close group opened by \tex. +} + + +\message{glyphs,} +% and logos. + +% @@ prints an @, as does @atchar{}. +\def\@{\char64 } +\let\atchar=\@ + +% @{ @} @lbracechar{} @rbracechar{} all generate brace characters. +% Unless we're in typewriter, use \ecfont because the CM text fonts do +% not have braces, and we don't want to switch into math. +\def\mylbrace{{\ifmonospace\else\ecfont\fi \char123}} +\def\myrbrace{{\ifmonospace\else\ecfont\fi \char125}} +\let\{=\mylbrace \let\lbracechar=\{ +\let\}=\myrbrace \let\rbracechar=\} +\begingroup + % Definitions to produce \{ and \} commands for indices, + % and @{ and @} for the aux/toc files. + \catcode`\{ = \other \catcode`\} = \other + \catcode`\[ = 1 \catcode`\] = 2 + \catcode`\! = 0 \catcode`\\ = \other + !gdef!lbracecmd[\{]% + !gdef!rbracecmd[\}]% + !gdef!lbraceatcmd[@{]% + !gdef!rbraceatcmd[@}]% +!endgroup + +% @comma{} to avoid , parsing problems. +\let\comma = , + +% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent +% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. +\let\, = \ptexc +\let\dotaccent = \ptexdot +\def\ringaccent#1{{\accent23 #1}} +\let\tieaccent = \ptext +\let\ubaraccent = \ptexb +\let\udotaccent = \d + +% Other special characters: @questiondown @exclamdown @ordf @ordm +% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. +\def\questiondown{?`} +\def\exclamdown{!`} +\def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}} +\def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}} + +% Dotless i and dotless j, used for accents. +\def\imacro{i} +\def\jmacro{j} +\def\dotless#1{% + \def\temp{#1}% + \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi + \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi + \else \errmessage{@dotless can be used only with i or j}% + \fi\fi +} + +% The \TeX{} logo, as in plain, but resetting the spacing so that a +% period following counts as ending a sentence. (Idea found in latex.) +% +\edef\TeX{\TeX \spacefactor=1000 } + +% @LaTeX{} logo. Not quite the same results as the definition in +% latex.ltx, since we use a different font for the raised A; it's most +% convenient for us to use an explicitly smaller font, rather than using +% the \scriptstyle font (since we don't reset \scriptstyle and +% \scriptscriptstyle). +% +\def\LaTeX{% + L\kern-.36em + {\setbox0=\hbox{T}% + \vbox to \ht0{\hbox{% + \ifx\textnominalsize\xwordpt + % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX. + % Revert to plain's \scriptsize, which is 7pt. + \count255=\the\fam $\fam\count255 \scriptstyle A$% + \else + % For 11pt, we can use our lllsize. + \selectfonts\lllsize A% + \fi + }% + \vss + }}% + \kern-.15em + \TeX +} + +% Some math mode symbols. +\def\bullet{$\ptexbullet$} +\def\geq{\ifmmode \ge\else $\ge$\fi} +\def\leq{\ifmmode \le\else $\le$\fi} +\def\minus{\ifmmode -\else $-$\fi} + +% @dots{} outputs an ellipsis using the current font. +% We do .5em per period so that it has the same spacing in the cm +% typewriter fonts as three actual period characters; on the other hand, +% in other typewriter fonts three periods are wider than 1.5em. So do +% whichever is larger. +% +\def\dots{% + \leavevmode + \setbox0=\hbox{...}% get width of three periods + \ifdim\wd0 > 1.5em + \dimen0 = \wd0 + \else + \dimen0 = 1.5em + \fi + \hbox to \dimen0{% + \hskip 0pt plus.25fil + .\hskip 0pt plus1fil + .\hskip 0pt plus1fil + .\hskip 0pt plus.5fil + }% +} + +% @enddots{} is an end-of-sentence ellipsis. +% +\def\enddots{% + \dots + \spacefactor=\endofsentencespacefactor +} + +% @point{}, @result{}, @expansion{}, @print{}, @equiv{}. +% +% Since these characters are used in examples, they should be an even number of +% \tt widths. Each \tt character is 1en, so two makes it 1em. +% +\def\point{$\star$} +\def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}} +\def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} +\def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}} +\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} +\def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}} + +% The @error{} command. +% Adapted from the TeXbook's \boxit. +% +\newbox\errorbox +% +{\tentt \global\dimen0 = 3em}% Width of the box. +\dimen2 = .55pt % Thickness of rules +% The text. (`r' is open on the right, `e' somewhat less so on the left.) +\setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt} +% +\setbox\errorbox=\hbox to \dimen0{\hfil + \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. + \advance\hsize by -2\dimen2 % Rules. + \vbox{% + \hrule height\dimen2 + \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. + \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. + \kern3pt\vrule width\dimen2}% Space to right. + \hrule height\dimen2} + \hfil} +% +\def\error{\leavevmode\lower.7ex\copy\errorbox} + +% @pounds{} is a sterling sign, which Knuth put in the CM italic font. +% +\def\pounds{{\it\$}} + +% @euro{} comes from a separate font, depending on the current style. +% We use the free feym* fonts from the eurosym package by Henrik +% Theiling, which support regular, slanted, bold and bold slanted (and +% "outlined" (blackboard board, sort of) versions, which we don't need). +% It is available from http://www.ctan.org/tex-archive/fonts/eurosym. +% +% Although only regular is the truly official Euro symbol, we ignore +% that. The Euro is designed to be slightly taller than the regular +% font height. +% +% feymr - regular +% feymo - slanted +% feybr - bold +% feybo - bold slanted +% +% There is no good (free) typewriter version, to my knowledge. +% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide. +% Hmm. +% +% Also doesn't work in math. Do we need to do math with euro symbols? +% Hope not. +% +% +\def\euro{{\eurofont e}} +\def\eurofont{% + % We set the font at each command, rather than predefining it in + % \textfonts and the other font-switching commands, so that + % installations which never need the symbol don't have to have the + % font installed. + % + % There is only one designed size (nominal 10pt), so we always scale + % that to the current nominal size. + % + % By the way, simply using "at 1em" works for cmr10 and the like, but + % does not work for cmbx10 and other extended/shrunken fonts. + % + \def\eurosize{\csname\curfontsize nominalsize\endcsname}% + % + \ifx\curfontstyle\bfstylename + % bold: + \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize + \else + % regular: + \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize + \fi + \thiseurofont +} + +% Glyphs from the EC fonts. We don't use \let for the aliases, because +% sometimes we redefine the original macro, and the alias should reflect +% the redefinition. +% +% Use LaTeX names for the Icelandic letters. +\def\DH{{\ecfont \char"D0}} % Eth +\def\dh{{\ecfont \char"F0}} % eth +\def\TH{{\ecfont \char"DE}} % Thorn +\def\th{{\ecfont \char"FE}} % thorn +% +\def\guillemetleft{{\ecfont \char"13}} +\def\guillemotleft{\guillemetleft} +\def\guillemetright{{\ecfont \char"14}} +\def\guillemotright{\guillemetright} +\def\guilsinglleft{{\ecfont \char"0E}} +\def\guilsinglright{{\ecfont \char"0F}} +\def\quotedblbase{{\ecfont \char"12}} +\def\quotesinglbase{{\ecfont \char"0D}} +% +% This positioning is not perfect (see the ogonek LaTeX package), but +% we have the precomposed glyphs for the most common cases. We put the +% tests to use those glyphs in the single \ogonek macro so we have fewer +% dummy definitions to worry about for index entries, etc. +% +% ogonek is also used with other letters in Lithuanian (IOU), but using +% the precomposed glyphs for those is not so easy since they aren't in +% the same EC font. +\def\ogonek#1{{% + \def\temp{#1}% + \ifx\temp\macrocharA\Aogonek + \else\ifx\temp\macrochara\aogonek + \else\ifx\temp\macrocharE\Eogonek + \else\ifx\temp\macrochare\eogonek + \else + \ecfont \setbox0=\hbox{#1}% + \ifdim\ht0=1ex\accent"0C #1% + \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}% + \fi + \fi\fi\fi\fi + }% +} +\def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A} +\def\aogonek{{\ecfont \char"A1}}\def\macrochara{a} +\def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E} +\def\eogonek{{\ecfont \char"A6}}\def\macrochare{e} +% +% Use the ec* fonts (cm-super in outline format) for non-CM glyphs. +\def\ecfont{% + % We can't distinguish serif/sans and italic/slanted, but this + % is used for crude hacks anyway (like adding French and German + % quotes to documents typeset with CM, where we lose kerning), so + % hopefully nobody will notice/care. + \edef\ecsize{\csname\curfontsize ecsize\endcsname}% + \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}% + \ifx\curfontstyle\bfstylename + % bold: + \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize + \else + % regular: + \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize + \fi + \thisecfont +} + +% @registeredsymbol - R in a circle. The font for the R should really +% be smaller yet, but lllsize is the best we can do for now. +% Adapted from the plain.tex definition of \copyright. +% +\def\registeredsymbol{% + $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}% + \hfil\crcr\Orb}}% + }$% +} + +% @textdegree - the normal degrees sign. +% +\def\textdegree{$^\circ$} + +% Laurent Siebenmann reports \Orb undefined with: +% Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 +% so we'll define it if necessary. +% +\ifx\Orb\thisisundefined +\def\Orb{\mathhexbox20D} +\fi + +% Quotes. +\chardef\quotedblleft="5C +\chardef\quotedblright=`\" +\chardef\quoteleft=`\` +\chardef\quoteright=`\' + + +\message{page headings,} + +\newskip\titlepagetopglue \titlepagetopglue = 1.5in +\newskip\titlepagebottomglue \titlepagebottomglue = 2pc + +% First the title page. Must do @settitle before @titlepage. +\newif\ifseenauthor +\newif\iffinishedtitlepage + +% Do an implicit @contents or @shortcontents after @end titlepage if the +% user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage. +% +\newif\ifsetcontentsaftertitlepage + \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue +\newif\ifsetshortcontentsaftertitlepage + \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue + +\parseargdef\shorttitlepage{% + \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}% + \endgroup\page\hbox{}\page} + +\envdef\titlepage{% + % Open one extra group, as we want to close it in the middle of \Etitlepage. + \begingroup + \parindent=0pt \textfonts + % Leave some space at the very top of the page. + \vglue\titlepagetopglue + % No rule at page bottom unless we print one at the top with @title. + \finishedtitlepagetrue + % + % Most title ``pages'' are actually two pages long, with space + % at the top of the second. We don't want the ragged left on the second. + \let\oldpage = \page + \def\page{% + \iffinishedtitlepage\else + \finishtitlepage + \fi + \let\page = \oldpage + \page + \null + }% +} + +\def\Etitlepage{% + \iffinishedtitlepage\else + \finishtitlepage + \fi + % It is important to do the page break before ending the group, + % because the headline and footline are only empty inside the group. + % If we use the new definition of \page, we always get a blank page + % after the title page, which we certainly don't want. + \oldpage + \endgroup + % + % Need this before the \...aftertitlepage checks so that if they are + % in effect the toc pages will come out with page numbers. + \HEADINGSon + % + % If they want short, they certainly want long too. + \ifsetshortcontentsaftertitlepage + \shortcontents + \contents + \global\let\shortcontents = \relax + \global\let\contents = \relax + \fi + % + \ifsetcontentsaftertitlepage + \contents + \global\let\contents = \relax + \global\let\shortcontents = \relax + \fi +} + +\def\finishtitlepage{% + \vskip4pt \hrule height 2pt width \hsize + \vskip\titlepagebottomglue + \finishedtitlepagetrue +} + +% Macros to be used within @titlepage: + +\let\subtitlerm=\tenrm +\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines} + +\parseargdef\title{% + \checkenv\titlepage + \leftline{\titlefonts\rmisbold #1} + % print a rule at the page bottom also. + \finishedtitlepagefalse + \vskip4pt \hrule height 4pt width \hsize \vskip4pt +} + +\parseargdef\subtitle{% + \checkenv\titlepage + {\subtitlefont \rightline{#1}}% +} + +% @author should come last, but may come many times. +% It can also be used inside @quotation. +% +\parseargdef\author{% + \def\temp{\quotation}% + \ifx\thisenv\temp + \def\quotationauthor{#1}% printed in \Equotation. + \else + \checkenv\titlepage + \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi + {\secfonts\rmisbold \leftline{#1}}% + \fi +} + + +% Set up page headings and footings. + +\let\thispage=\folio + +\newtoks\evenheadline % headline on even pages +\newtoks\oddheadline % headline on odd pages +\newtoks\evenfootline % footline on even pages +\newtoks\oddfootline % footline on odd pages + +% Now make TeX use those variables +\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline + \else \the\evenheadline \fi}} +\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline + \else \the\evenfootline \fi}\HEADINGShook} +\let\HEADINGShook=\relax + +% Commands to set those variables. +% For example, this is what @headings on does +% @evenheading @thistitle|@thispage|@thischapter +% @oddheading @thischapter|@thispage|@thistitle +% @evenfooting @thisfile|| +% @oddfooting ||@thisfile + + +\def\evenheading{\parsearg\evenheadingxxx} +\def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish} +\def\evenheadingyyy #1\|#2\|#3\|#4\finish{% +\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\def\oddheading{\parsearg\oddheadingxxx} +\def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish} +\def\oddheadingyyy #1\|#2\|#3\|#4\finish{% +\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}% + +\def\evenfooting{\parsearg\evenfootingxxx} +\def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish} +\def\evenfootingyyy #1\|#2\|#3\|#4\finish{% +\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\def\oddfooting{\parsearg\oddfootingxxx} +\def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish} +\def\oddfootingyyy #1\|#2\|#3\|#4\finish{% + \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% + % + % Leave some space for the footline. Hopefully ok to assume + % @evenfooting will not be used by itself. + \global\advance\pageheight by -12pt + \global\advance\vsize by -12pt +} + +\parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}} + +% @evenheadingmarks top \thischapter <- chapter at the top of a page +% @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page +% +% The same set of arguments for: +% +% @oddheadingmarks +% @evenfootingmarks +% @oddfootingmarks +% @everyheadingmarks +% @everyfootingmarks + +\def\evenheadingmarks{\headingmarks{even}{heading}} +\def\oddheadingmarks{\headingmarks{odd}{heading}} +\def\evenfootingmarks{\headingmarks{even}{footing}} +\def\oddfootingmarks{\headingmarks{odd}{footing}} +\def\everyheadingmarks#1 {\headingmarks{even}{heading}{#1} + \headingmarks{odd}{heading}{#1} } +\def\everyfootingmarks#1 {\headingmarks{even}{footing}{#1} + \headingmarks{odd}{footing}{#1} } +% #1 = even/odd, #2 = heading/footing, #3 = top/bottom. +\def\headingmarks#1#2#3 {% + \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname + \global\expandafter\let\csname get#1#2marks\endcsname \temp +} + +\everyheadingmarks bottom +\everyfootingmarks bottom + +% @headings double turns headings on for double-sided printing. +% @headings single turns headings on for single-sided printing. +% @headings off turns them off. +% @headings on same as @headings double, retained for compatibility. +% @headings after turns on double-sided headings after this page. +% @headings doubleafter turns on double-sided headings after this page. +% @headings singleafter turns on single-sided headings after this page. +% By default, they are off at the start of a document, +% and turned `on' after @end titlepage. + +\def\headings #1 {\csname HEADINGS#1\endcsname} + +\def\headingsoff{% non-global headings elimination + \evenheadline={\hfil}\evenfootline={\hfil}% + \oddheadline={\hfil}\oddfootline={\hfil}% +} + +\def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting +\HEADINGSoff % it's the default + +% When we turn headings on, set the page number to 1. +% For double-sided printing, put current file name in lower left corner, +% chapter name on inside top of right hand pages, document +% title on inside top of left hand pages, and page numbers on outside top +% edge of all pages. +\def\HEADINGSdouble{% +\global\pageno=1 +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\folio\hfil\thistitle}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +\global\let\contentsalignmacro = \chapoddpage +} +\let\contentsalignmacro = \chappager + +% For single-sided printing, chapter title goes across top left of page, +% page number on top right. +\def\HEADINGSsingle{% +\global\pageno=1 +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\thischapter\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +\global\let\contentsalignmacro = \chappager +} +\def\HEADINGSon{\HEADINGSdouble} + +\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} +\let\HEADINGSdoubleafter=\HEADINGSafter +\def\HEADINGSdoublex{% +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\folio\hfil\thistitle}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +\global\let\contentsalignmacro = \chapoddpage +} + +\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} +\def\HEADINGSsinglex{% +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\thischapter\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +\global\let\contentsalignmacro = \chappager +} + +% Subroutines used in generating headings +% This produces Day Month Year style of output. +% Only define if not already defined, in case a txi-??.tex file has set +% up a different format (e.g., txi-cs.tex does this). +\ifx\today\thisisundefined +\def\today{% + \number\day\space + \ifcase\month + \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr + \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug + \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec + \fi + \space\number\year} +\fi + +% @settitle line... specifies the title of the document, for headings. +% It generates no output of its own. +\def\thistitle{\putwordNoTitle} +\def\settitle{\parsearg{\gdef\thistitle}} + + +\message{tables,} +% Tables -- @table, @ftable, @vtable, @item(x). + +% default indentation of table text +\newdimen\tableindent \tableindent=.8in +% default indentation of @itemize and @enumerate text +\newdimen\itemindent \itemindent=.3in +% margin between end of table item and start of table text. +\newdimen\itemmargin \itemmargin=.1in + +% used internally for \itemindent minus \itemmargin +\newdimen\itemmax + +% Note @table, @ftable, and @vtable define @item, @itemx, etc., with +% these defs. +% They also define \itemindex +% to index the item name in whatever manner is desired (perhaps none). + +\newif\ifitemxneedsnegativevskip + +\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} + +\def\internalBitem{\smallbreak \parsearg\itemzzz} +\def\internalBitemx{\itemxpar \parsearg\itemzzz} + +\def\itemzzz #1{\begingroup % + \advance\hsize by -\rightskip + \advance\hsize by -\tableindent + \setbox0=\hbox{\itemindicate{#1}}% + \itemindex{#1}% + \nobreak % This prevents a break before @itemx. + % + % If the item text does not fit in the space we have, put it on a line + % by itself, and do not allow a page break either before or after that + % line. We do not start a paragraph here because then if the next + % command is, e.g., @kindex, the whatsit would get put into the + % horizontal list on a line by itself, resulting in extra blank space. + \ifdim \wd0>\itemmax + % + % Make this a paragraph so we get the \parskip glue and wrapping, + % but leave it ragged-right. + \begingroup + \advance\leftskip by-\tableindent + \advance\hsize by\tableindent + \advance\rightskip by0pt plus1fil\relax + \leavevmode\unhbox0\par + \endgroup + % + % We're going to be starting a paragraph, but we don't want the + % \parskip glue -- logically it's part of the @item we just started. + \nobreak \vskip-\parskip + % + % Stop a page break at the \parskip glue coming up. However, if + % what follows is an environment such as @example, there will be no + % \parskip glue; then the negative vskip we just inserted would + % cause the example and the item to crash together. So we use this + % bizarre value of 10001 as a signal to \aboveenvbreak to insert + % \parskip glue after all. Section titles are handled this way also. + % + \penalty 10001 + \endgroup + \itemxneedsnegativevskipfalse + \else + % The item text fits into the space. Start a paragraph, so that the + % following text (if any) will end up on the same line. + \noindent + % Do this with kerns and \unhbox so that if there is a footnote in + % the item text, it can migrate to the main vertical list and + % eventually be printed. + \nobreak\kern-\tableindent + \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 + \unhbox0 + \nobreak\kern\dimen0 + \endgroup + \itemxneedsnegativevskiptrue + \fi +} + +\def\item{\errmessage{@item while not in a list environment}} +\def\itemx{\errmessage{@itemx while not in a list environment}} + +% @table, @ftable, @vtable. +\envdef\table{% + \let\itemindex\gobble + \tablecheck{table}% +} +\envdef\ftable{% + \def\itemindex ##1{\doind {fn}{\code{##1}}}% + \tablecheck{ftable}% +} +\envdef\vtable{% + \def\itemindex ##1{\doind {vr}{\code{##1}}}% + \tablecheck{vtable}% +} +\def\tablecheck#1{% + \ifnum \the\catcode`\^^M=\active + \endgroup + \errmessage{This command won't work in this context; perhaps the problem is + that we are \inenvironment\thisenv}% + \def\next{\doignore{#1}}% + \else + \let\next\tablex + \fi + \next +} +\def\tablex#1{% + \def\itemindicate{#1}% + \parsearg\tabley +} +\def\tabley#1{% + {% + \makevalueexpandable + \edef\temp{\noexpand\tablez #1\space\space\space}% + \expandafter + }\temp \endtablez +} +\def\tablez #1 #2 #3 #4\endtablez{% + \aboveenvbreak + \ifnum 0#1>0 \advance \leftskip by #1\mil \fi + \ifnum 0#2>0 \tableindent=#2\mil \fi + \ifnum 0#3>0 \advance \rightskip by #3\mil \fi + \itemmax=\tableindent + \advance \itemmax by -\itemmargin + \advance \leftskip by \tableindent + \exdentamount=\tableindent + \parindent = 0pt + \parskip = \smallskipamount + \ifdim \parskip=0pt \parskip=2pt \fi + \let\item = \internalBitem + \let\itemx = \internalBitemx +} +\def\Etable{\endgraf\afterenvbreak} +\let\Eftable\Etable +\let\Evtable\Etable +\let\Eitemize\Etable +\let\Eenumerate\Etable + +% This is the counter used by @enumerate, which is really @itemize + +\newcount \itemno + +\envdef\itemize{\parsearg\doitemize} + +\def\doitemize#1{% + \aboveenvbreak + \itemmax=\itemindent + \advance\itemmax by -\itemmargin + \advance\leftskip by \itemindent + \exdentamount=\itemindent + \parindent=0pt + \parskip=\smallskipamount + \ifdim\parskip=0pt \parskip=2pt \fi + % + % Try typesetting the item mark that if the document erroneously says + % something like @itemize @samp (intending @table), there's an error + % right away at the @itemize. It's not the best error message in the + % world, but it's better than leaving it to the @item. This means if + % the user wants an empty mark, they have to say @w{} not just @w. + \def\itemcontents{#1}% + \setbox0 = \hbox{\itemcontents}% + % + % @itemize with no arg is equivalent to @itemize @bullet. + \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi + % + \let\item=\itemizeitem +} + +% Definition of @item while inside @itemize and @enumerate. +% +\def\itemizeitem{% + \advance\itemno by 1 % for enumerations + {\let\par=\endgraf \smallbreak}% reasonable place to break + {% + % If the document has an @itemize directly after a section title, a + % \nobreak will be last on the list, and \sectionheading will have + % done a \vskip-\parskip. In that case, we don't want to zero + % parskip, or the item text will crash with the heading. On the + % other hand, when there is normal text preceding the item (as there + % usually is), we do want to zero parskip, or there would be too much + % space. In that case, we won't have a \nobreak before. At least + % that's the theory. + \ifnum\lastpenalty<10000 \parskip=0in \fi + \noindent + \hbox to 0pt{\hss \itemcontents \kern\itemmargin}% + % + \vadjust{\penalty 1200}}% not good to break after first line of item. + \flushcr +} + +% \splitoff TOKENS\endmark defines \first to be the first token in +% TOKENS, and \rest to be the remainder. +% +\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% + +% Allow an optional argument of an uppercase letter, lowercase letter, +% or number, to specify the first label in the enumerated list. No +% argument is the same as `1'. +% +\envparseargdef\enumerate{\enumeratey #1 \endenumeratey} +\def\enumeratey #1 #2\endenumeratey{% + % If we were given no argument, pretend we were given `1'. + \def\thearg{#1}% + \ifx\thearg\empty \def\thearg{1}\fi + % + % Detect if the argument is a single token. If so, it might be a + % letter. Otherwise, the only valid thing it can be is a number. + % (We will always have one token, because of the test we just made. + % This is a good thing, since \splitoff doesn't work given nothing at + % all -- the first parameter is undelimited.) + \expandafter\splitoff\thearg\endmark + \ifx\rest\empty + % Only one token in the argument. It could still be anything. + % A ``lowercase letter'' is one whose \lccode is nonzero. + % An ``uppercase letter'' is one whose \lccode is both nonzero, and + % not equal to itself. + % Otherwise, we assume it's a number. + % + % We need the \relax at the end of the \ifnum lines to stop TeX from + % continuing to look for a . + % + \ifnum\lccode\expandafter`\thearg=0\relax + \numericenumerate % a number (we hope) + \else + % It's a letter. + \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax + \lowercaseenumerate % lowercase letter + \else + \uppercaseenumerate % uppercase letter + \fi + \fi + \else + % Multiple tokens in the argument. We hope it's a number. + \numericenumerate + \fi +} + +% An @enumerate whose labels are integers. The starting integer is +% given in \thearg. +% +\def\numericenumerate{% + \itemno = \thearg + \startenumeration{\the\itemno}% +} + +% The starting (lowercase) letter is in \thearg. +\def\lowercaseenumerate{% + \itemno = \expandafter`\thearg + \startenumeration{% + % Be sure we're not beyond the end of the alphabet. + \ifnum\itemno=0 + \errmessage{No more lowercase letters in @enumerate; get a bigger + alphabet}% + \fi + \char\lccode\itemno + }% +} + +% The starting (uppercase) letter is in \thearg. +\def\uppercaseenumerate{% + \itemno = \expandafter`\thearg + \startenumeration{% + % Be sure we're not beyond the end of the alphabet. + \ifnum\itemno=0 + \errmessage{No more uppercase letters in @enumerate; get a bigger + alphabet} + \fi + \char\uccode\itemno + }% +} + +% Call \doitemize, adding a period to the first argument and supplying the +% common last two arguments. Also subtract one from the initial value in +% \itemno, since @item increments \itemno. +% +\def\startenumeration#1{% + \advance\itemno by -1 + \doitemize{#1.}\flushcr +} + +% @alphaenumerate and @capsenumerate are abbreviations for giving an arg +% to @enumerate. +% +\def\alphaenumerate{\enumerate{a}} +\def\capsenumerate{\enumerate{A}} +\def\Ealphaenumerate{\Eenumerate} +\def\Ecapsenumerate{\Eenumerate} + + +% @multitable macros +% Amy Hendrickson, 8/18/94, 3/6/96 +% +% @multitable ... @end multitable will make as many columns as desired. +% Contents of each column will wrap at width given in preamble. Width +% can be specified either with sample text given in a template line, +% or in percent of \hsize, the current width of text on page. + +% Table can continue over pages but will only break between lines. + +% To make preamble: +% +% Either define widths of columns in terms of percent of \hsize: +% @multitable @columnfractions .25 .3 .45 +% @item ... +% +% Numbers following @columnfractions are the percent of the total +% current hsize to be used for each column. You may use as many +% columns as desired. + + +% Or use a template: +% @multitable {Column 1 template} {Column 2 template} {Column 3 template} +% @item ... +% using the widest term desired in each column. + +% Each new table line starts with @item, each subsequent new column +% starts with @tab. Empty columns may be produced by supplying @tab's +% with nothing between them for as many times as empty columns are needed, +% ie, @tab@tab@tab will produce two empty columns. + +% @item, @tab do not need to be on their own lines, but it will not hurt +% if they are. + +% Sample multitable: + +% @multitable {Column 1 template} {Column 2 template} {Column 3 template} +% @item first col stuff @tab second col stuff @tab third col +% @item +% first col stuff +% @tab +% second col stuff +% @tab +% third col +% @item first col stuff @tab second col stuff +% @tab Many paragraphs of text may be used in any column. +% +% They will wrap at the width determined by the template. +% @item@tab@tab This will be in third column. +% @end multitable + +% Default dimensions may be reset by user. +% @multitableparskip is vertical space between paragraphs in table. +% @multitableparindent is paragraph indent in table. +% @multitablecolmargin is horizontal space to be left between columns. +% @multitablelinespace is space to leave between table items, baseline +% to baseline. +% 0pt means it depends on current normal line spacing. +% +\newskip\multitableparskip +\newskip\multitableparindent +\newdimen\multitablecolspace +\newskip\multitablelinespace +\multitableparskip=0pt +\multitableparindent=6pt +\multitablecolspace=12pt +\multitablelinespace=0pt + +% Macros used to set up halign preamble: +% +\let\endsetuptable\relax +\def\xendsetuptable{\endsetuptable} +\let\columnfractions\relax +\def\xcolumnfractions{\columnfractions} +\newif\ifsetpercent + +% #1 is the @columnfraction, usually a decimal number like .5, but might +% be just 1. We just use it, whatever it is. +% +\def\pickupwholefraction#1 {% + \global\advance\colcount by 1 + \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}% + \setuptable +} + +\newcount\colcount +\def\setuptable#1{% + \def\firstarg{#1}% + \ifx\firstarg\xendsetuptable + \let\go = \relax + \else + \ifx\firstarg\xcolumnfractions + \global\setpercenttrue + \else + \ifsetpercent + \let\go\pickupwholefraction + \else + \global\advance\colcount by 1 + \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a + % separator; typically that is always in the input, anyway. + \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% + \fi + \fi + \ifx\go\pickupwholefraction + % Put the argument back for the \pickupwholefraction call, so + % we'll always have a period there to be parsed. + \def\go{\pickupwholefraction#1}% + \else + \let\go = \setuptable + \fi% + \fi + \go +} + +% multitable-only commands. +% +% @headitem starts a heading row, which we typeset in bold. +% Assignments have to be global since we are inside the implicit group +% of an alignment entry. \everycr resets \everytab so we don't have to +% undo it ourselves. +\def\headitemfont{\b}% for people to use in the template row; not changeable +\def\headitem{% + \checkenv\multitable + \crcr + \global\everytab={\bf}% can't use \headitemfont since the parsing differs + \the\everytab % for the first item +}% +% +% A \tab used to include \hskip1sp. But then the space in a template +% line is not enough. That is bad. So let's go back to just `&' until +% we again encounter the problem the 1sp was intended to solve. +% --karl, nathan@acm.org, 20apr99. +\def\tab{\checkenv\multitable &\the\everytab}% + +% @multitable ... @end multitable definitions: +% +\newtoks\everytab % insert after every tab. +% +\envdef\multitable{% + \vskip\parskip + \startsavinginserts + % + % @item within a multitable starts a normal row. + % We use \def instead of \let so that if one of the multitable entries + % contains an @itemize, we don't choke on the \item (seen as \crcr aka + % \endtemplate) expanding \doitemize. + \def\item{\crcr}% + % + \tolerance=9500 + \hbadness=9500 + \setmultitablespacing + \parskip=\multitableparskip + \parindent=\multitableparindent + \overfullrule=0pt + \global\colcount=0 + % + \everycr = {% + \noalign{% + \global\everytab={}% + \global\colcount=0 % Reset the column counter. + % Check for saved footnotes, etc. + \checkinserts + % Keeps underfull box messages off when table breaks over pages. + %\filbreak + % Maybe so, but it also creates really weird page breaks when the + % table breaks over pages. Wouldn't \vfil be better? Wait until the + % problem manifests itself, so it can be fixed for real --karl. + }% + }% + % + \parsearg\domultitable +} +\def\domultitable#1{% + % To parse everything between @multitable and @item: + \setuptable#1 \endsetuptable + % + % This preamble sets up a generic column definition, which will + % be used as many times as user calls for columns. + % \vtop will set a single line and will also let text wrap and + % continue for many paragraphs if desired. + \halign\bgroup &% + \global\advance\colcount by 1 + \multistrut + \vtop{% + % Use the current \colcount to find the correct column width: + \hsize=\expandafter\csname col\the\colcount\endcsname + % + % In order to keep entries from bumping into each other + % we will add a \leftskip of \multitablecolspace to all columns after + % the first one. + % + % If a template has been used, we will add \multitablecolspace + % to the width of each template entry. + % + % If the user has set preamble in terms of percent of \hsize we will + % use that dimension as the width of the column, and the \leftskip + % will keep entries from bumping into each other. Table will start at + % left margin and final column will justify at right margin. + % + % Make sure we don't inherit \rightskip from the outer environment. + \rightskip=0pt + \ifnum\colcount=1 + % The first column will be indented with the surrounding text. + \advance\hsize by\leftskip + \else + \ifsetpercent \else + % If user has not set preamble in terms of percent of \hsize + % we will advance \hsize by \multitablecolspace. + \advance\hsize by \multitablecolspace + \fi + % In either case we will make \leftskip=\multitablecolspace: + \leftskip=\multitablecolspace + \fi + % Ignoring space at the beginning and end avoids an occasional spurious + % blank line, when TeX decides to break the line at the space before the + % box from the multistrut, so the strut ends up on a line by itself. + % For example: + % @multitable @columnfractions .11 .89 + % @item @code{#} + % @tab Legal holiday which is valid in major parts of the whole country. + % Is automatically provided with highlighting sequences respectively + % marking characters. + \noindent\ignorespaces##\unskip\multistrut + }\cr +} +\def\Emultitable{% + \crcr + \egroup % end the \halign + \global\setpercentfalse +} + +\def\setmultitablespacing{% + \def\multistrut{\strut}% just use the standard line spacing + % + % Compute \multitablelinespace (if not defined by user) for use in + % \multitableparskip calculation. We used define \multistrut based on + % this, but (ironically) that caused the spacing to be off. + % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100. +\ifdim\multitablelinespace=0pt +\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip +\global\advance\multitablelinespace by-\ht0 +\fi +% Test to see if parskip is larger than space between lines of +% table. If not, do nothing. +% If so, set to same dimension as multitablelinespace. +\ifdim\multitableparskip>\multitablelinespace +\global\multitableparskip=\multitablelinespace +\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller + % than skip between lines in the table. +\fi% +\ifdim\multitableparskip=0pt +\global\multitableparskip=\multitablelinespace +\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller + % than skip between lines in the table. +\fi} + + +\message{conditionals,} + +% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext, +% @ifnotxml always succeed. They currently do nothing; we don't +% attempt to check whether the conditionals are properly nested. But we +% have to remember that they are conditionals, so that @end doesn't +% attempt to close an environment group. +% +\def\makecond#1{% + \expandafter\let\csname #1\endcsname = \relax + \expandafter\let\csname iscond.#1\endcsname = 1 +} +\makecond{iftex} +\makecond{ifnotdocbook} +\makecond{ifnothtml} +\makecond{ifnotinfo} +\makecond{ifnotplaintext} +\makecond{ifnotxml} + +% Ignore @ignore, @ifhtml, @ifinfo, and the like. +% +\def\direntry{\doignore{direntry}} +\def\documentdescription{\doignore{documentdescription}} +\def\docbook{\doignore{docbook}} +\def\html{\doignore{html}} +\def\ifdocbook{\doignore{ifdocbook}} +\def\ifhtml{\doignore{ifhtml}} +\def\ifinfo{\doignore{ifinfo}} +\def\ifnottex{\doignore{ifnottex}} +\def\ifplaintext{\doignore{ifplaintext}} +\def\ifxml{\doignore{ifxml}} +\def\ignore{\doignore{ignore}} +\def\menu{\doignore{menu}} +\def\xml{\doignore{xml}} + +% Ignore text until a line `@end #1', keeping track of nested conditionals. +% +% A count to remember the depth of nesting. +\newcount\doignorecount + +\def\doignore#1{\begingroup + % Scan in ``verbatim'' mode: + \obeylines + \catcode`\@ = \other + \catcode`\{ = \other + \catcode`\} = \other + % + % Make sure that spaces turn into tokens that match what \doignoretext wants. + \spaceisspace + % + % Count number of #1's that we've seen. + \doignorecount = 0 + % + % Swallow text until we reach the matching `@end #1'. + \dodoignore{#1}% +} + +{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source. + \obeylines % + % + \gdef\dodoignore#1{% + % #1 contains the command name as a string, e.g., `ifinfo'. + % + % Define a command to find the next `@end #1'. + \long\def\doignoretext##1^^M@end #1{% + \doignoretextyyy##1^^M@#1\_STOP_}% + % + % And this command to find another #1 command, at the beginning of a + % line. (Otherwise, we would consider a line `@c @ifset', for + % example, to count as an @ifset for nesting.) + \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}% + % + % And now expand that command. + \doignoretext ^^M% + }% +} + +\def\doignoreyyy#1{% + \def\temp{#1}% + \ifx\temp\empty % Nothing found. + \let\next\doignoretextzzz + \else % Found a nested condition, ... + \advance\doignorecount by 1 + \let\next\doignoretextyyy % ..., look for another. + % If we're here, #1 ends with ^^M\ifinfo (for example). + \fi + \next #1% the token \_STOP_ is present just after this macro. +} + +% We have to swallow the remaining "\_STOP_". +% +\def\doignoretextzzz#1{% + \ifnum\doignorecount = 0 % We have just found the outermost @end. + \let\next\enddoignore + \else % Still inside a nested condition. + \advance\doignorecount by -1 + \let\next\doignoretext % Look for the next @end. + \fi + \next +} + +% Finish off ignored text. +{ \obeylines% + % Ignore anything after the last `@end #1'; this matters in verbatim + % environments, where otherwise the newline after an ignored conditional + % would result in a blank line in the output. + \gdef\enddoignore#1^^M{\endgroup\ignorespaces}% +} + + +% @set VAR sets the variable VAR to an empty value. +% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. +% +% Since we want to separate VAR from REST-OF-LINE (which might be +% empty), we can't just use \parsearg; we have to insert a space of our +% own to delimit the rest of the line, and then take it out again if we +% didn't need it. +% We rely on the fact that \parsearg sets \catcode`\ =10. +% +\parseargdef\set{\setyyy#1 \endsetyyy} +\def\setyyy#1 #2\endsetyyy{% + {% + \makevalueexpandable + \def\temp{#2}% + \edef\next{\gdef\makecsname{SET#1}}% + \ifx\temp\empty + \next{}% + \else + \setzzz#2\endsetzzz + \fi + }% +} +% Remove the trailing space \setxxx inserted. +\def\setzzz#1 \endsetzzz{\next{#1}} + +% @clear VAR clears (i.e., unsets) the variable VAR. +% +\parseargdef\clear{% + {% + \makevalueexpandable + \global\expandafter\let\csname SET#1\endcsname=\relax + }% +} + +% @value{foo} gets the text saved in variable foo. +\def\value{\begingroup\makevalueexpandable\valuexxx} +\def\valuexxx#1{\expandablevalue{#1}\endgroup} +{ + \catcode`\- = \active \catcode`\_ = \active + % + \gdef\makevalueexpandable{% + \let\value = \expandablevalue + % We don't want these characters active, ... + \catcode`\-=\other \catcode`\_=\other + % ..., but we might end up with active ones in the argument if + % we're called from @code, as @code{@value{foo-bar_}}, though. + % So \let them to their normal equivalents. + \let-\realdash \let_\normalunderscore + } +} + +% We have this subroutine so that we can handle at least some @value's +% properly in indexes (we call \makevalueexpandable in \indexdummies). +% The command has to be fully expandable (if the variable is set), since +% the result winds up in the index file. This means that if the +% variable's value contains other Texinfo commands, it's almost certain +% it will fail (although perhaps we could fix that with sufficient work +% to do a one-level expansion on the result, instead of complete). +% +\def\expandablevalue#1{% + \expandafter\ifx\csname SET#1\endcsname\relax + {[No value for ``#1'']}% + \message{Variable `#1', used in @value, is not set.}% + \else + \csname SET#1\endcsname + \fi +} + +% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined +% with @set. +% +% To get special treatment of `@end ifset,' call \makeond and the redefine. +% +\makecond{ifset} +\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}} +\def\doifset#1#2{% + {% + \makevalueexpandable + \let\next=\empty + \expandafter\ifx\csname SET#2\endcsname\relax + #1% If not set, redefine \next. + \fi + \expandafter + }\next +} +\def\ifsetfail{\doignore{ifset}} + +% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been +% defined with @set, or has been undefined with @clear. +% +% The `\else' inside the `\doifset' parameter is a trick to reuse the +% above code: if the variable is not set, do nothing, if it is set, +% then redefine \next to \ifclearfail. +% +\makecond{ifclear} +\def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}} +\def\ifclearfail{\doignore{ifclear}} + +% @dircategory CATEGORY -- specify a category of the dir file +% which this file should belong to. Ignore this in TeX. +\let\dircategory=\comment + +% @defininfoenclose. +\let\definfoenclose=\comment + + +\message{indexing,} +% Index generation facilities + +% Define \newwrite to be identical to plain tex's \newwrite +% except not \outer, so it can be used within macros and \if's. +\edef\newwrite{\makecsname{ptexnewwrite}} + +% \newindex {foo} defines an index named foo. +% It automatically defines \fooindex such that +% \fooindex ...rest of line... puts an entry in the index foo. +% It also defines \fooindfile to be the number of the output channel for +% the file that accumulates this index. The file's extension is foo. +% The name of an index should be no more than 2 characters long +% for the sake of vms. +% +\def\newindex#1{% + \iflinks + \expandafter\newwrite \csname#1indfile\endcsname + \openout \csname#1indfile\endcsname \jobname.#1 % Open the file + \fi + \expandafter\xdef\csname#1index\endcsname{% % Define @#1index + \noexpand\doindex{#1}} +} + +% @defindex foo == \newindex{foo} +% +\def\defindex{\parsearg\newindex} + +% Define @defcodeindex, like @defindex except put all entries in @code. +% +\def\defcodeindex{\parsearg\newcodeindex} +% +\def\newcodeindex#1{% + \iflinks + \expandafter\newwrite \csname#1indfile\endcsname + \openout \csname#1indfile\endcsname \jobname.#1 + \fi + \expandafter\xdef\csname#1index\endcsname{% + \noexpand\docodeindex{#1}}% +} + + +% @synindex foo bar makes index foo feed into index bar. +% Do this instead of @defindex foo if you don't want it as a separate index. +% +% @syncodeindex foo bar similar, but put all entries made for index foo +% inside @code. +% +\def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}} +\def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}} + +% #1 is \doindex or \docodeindex, #2 the index getting redefined (foo), +% #3 the target index (bar). +\def\dosynindex#1#2#3{% + % Only do \closeout if we haven't already done it, else we'll end up + % closing the target index. + \expandafter \ifx\csname donesynindex#2\endcsname \relax + % The \closeout helps reduce unnecessary open files; the limit on the + % Acorn RISC OS is a mere 16 files. + \expandafter\closeout\csname#2indfile\endcsname + \expandafter\let\csname donesynindex#2\endcsname = 1 + \fi + % redefine \fooindfile: + \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname + \expandafter\let\csname#2indfile\endcsname=\temp + % redefine \fooindex: + \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}% +} + +% Define \doindex, the driver for all \fooindex macros. +% Argument #1 is generated by the calling \fooindex macro, +% and it is "foo", the name of the index. + +% \doindex just uses \parsearg; it calls \doind for the actual work. +% This is because \doind is more useful to call from other macros. + +% There is also \dosubind {index}{topic}{subtopic} +% which makes an entry in a two-level index such as the operation index. + +\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} +\def\singleindexer #1{\doind{\indexname}{#1}} + +% like the previous two, but they put @code around the argument. +\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} +\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} + +% Take care of Texinfo commands that can appear in an index entry. +% Since there are some commands we want to expand, and others we don't, +% we have to laboriously prevent expansion for those that we don't. +% +\def\indexdummies{% + \escapechar = `\\ % use backslash in output files. + \def\@{@}% change to @@ when we switch to @ as escape char in index files. + \def\ {\realbackslash\space }% + % + % Need these unexpandable (because we define \tt as a dummy) + % definitions when @{ or @} appear in index entry text. Also, more + % complicated, when \tex is in effect and \{ is a \delimiter again. + % We can't use \lbracecmd and \rbracecmd because texindex assumes + % braces and backslashes are used only as delimiters. Perhaps we + % should define @lbrace and @rbrace commands a la @comma. + \def\{{{\tt\char123}}% + \def\}{{\tt\char125}}% + % + % I don't entirely understand this, but when an index entry is + % generated from a macro call, the \endinput which \scanmacro inserts + % causes processing to be prematurely terminated. This is, + % apparently, because \indexsorttmp is fully expanded, and \endinput + % is an expandable command. The redefinition below makes \endinput + % disappear altogether for that purpose -- although logging shows that + % processing continues to some further point. On the other hand, it + % seems \endinput does not hurt in the printed index arg, since that + % is still getting written without apparent harm. + % + % Sample source (mac-idx3.tex, reported by Graham Percival to + % help-texinfo, 22may06): + % @macro funindex {WORD} + % @findex xyz + % @end macro + % ... + % @funindex commtest + % + % The above is not enough to reproduce the bug, but it gives the flavor. + % + % Sample whatsit resulting: + % .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}} + % + % So: + \let\endinput = \empty + % + % Do the redefinitions. + \commondummies +} + +% For the aux and toc files, @ is the escape character. So we want to +% redefine everything using @ as the escape character (instead of +% \realbackslash, still used for index files). When everything uses @, +% this will be simpler. +% +\def\atdummies{% + \def\@{@@}% + \def\ {@ }% + \let\{ = \lbraceatcmd + \let\} = \rbraceatcmd + % + % Do the redefinitions. + \commondummies + \otherbackslash +} + +% Called from \indexdummies and \atdummies. +% +\def\commondummies{% + % + % \definedummyword defines \#1 as \string\#1\space, thus effectively + % preventing its expansion. This is used only for control words, + % not control letters, because the \space would be incorrect for + % control characters, but is needed to separate the control word + % from whatever follows. + % + % For control letters, we have \definedummyletter, which omits the + % space. + % + % These can be used both for control words that take an argument and + % those that do not. If it is followed by {arg} in the input, then + % that will dutifully get written to the index (or wherever). + % + \def\definedummyword ##1{\def##1{\string##1\space}}% + \def\definedummyletter##1{\def##1{\string##1}}% + \let\definedummyaccent\definedummyletter + % + \commondummiesnofonts + % + \definedummyletter\_% + \definedummyletter\-% + % + % Non-English letters. + \definedummyword\AA + \definedummyword\AE + \definedummyword\DH + \definedummyword\L + \definedummyword\O + \definedummyword\OE + \definedummyword\TH + \definedummyword\aa + \definedummyword\ae + \definedummyword\dh + \definedummyword\exclamdown + \definedummyword\l + \definedummyword\o + \definedummyword\oe + \definedummyword\ordf + \definedummyword\ordm + \definedummyword\questiondown + \definedummyword\ss + \definedummyword\th + % + % Although these internal commands shouldn't show up, sometimes they do. + \definedummyword\bf + \definedummyword\gtr + \definedummyword\hat + \definedummyword\less + \definedummyword\sf + \definedummyword\sl + \definedummyword\tclose + \definedummyword\tt + % + \definedummyword\LaTeX + \definedummyword\TeX + % + % Assorted special characters. + \definedummyword\arrow + \definedummyword\bullet + \definedummyword\comma + \definedummyword\copyright + \definedummyword\registeredsymbol + \definedummyword\dots + \definedummyword\enddots + \definedummyword\entrybreak + \definedummyword\equiv + \definedummyword\error + \definedummyword\euro + \definedummyword\expansion + \definedummyword\geq + \definedummyword\guillemetleft + \definedummyword\guillemetright + \definedummyword\guilsinglleft + \definedummyword\guilsinglright + \definedummyword\leq + \definedummyword\minus + \definedummyword\ogonek + \definedummyword\pounds + \definedummyword\point + \definedummyword\print + \definedummyword\quotedblbase + \definedummyword\quotedblleft + \definedummyword\quotedblright + \definedummyword\quoteleft + \definedummyword\quoteright + \definedummyword\quotesinglbase + \definedummyword\result + \definedummyword\textdegree + % + % We want to disable all macros so that they are not expanded by \write. + \macrolist + % + \normalturnoffactive + % + % Handle some cases of @value -- where it does not contain any + % (non-fully-expandable) commands. + \makevalueexpandable +} + +% \commondummiesnofonts: common to \commondummies and \indexnofonts. +% +\def\commondummiesnofonts{% + % Control letters and accents. + \definedummyletter\!% + \definedummyaccent\"% + \definedummyaccent\'% + \definedummyletter\*% + \definedummyaccent\,% + \definedummyletter\.% + \definedummyletter\/% + \definedummyletter\:% + \definedummyaccent\=% + \definedummyletter\?% + \definedummyaccent\^% + \definedummyaccent\`% + \definedummyaccent\~% + \definedummyword\u + \definedummyword\v + \definedummyword\H + \definedummyword\dotaccent + \definedummyword\ogonek + \definedummyword\ringaccent + \definedummyword\tieaccent + \definedummyword\ubaraccent + \definedummyword\udotaccent + \definedummyword\dotless + % + % Texinfo font commands. + \definedummyword\b + \definedummyword\i + \definedummyword\r + \definedummyword\sansserif + \definedummyword\sc + \definedummyword\slanted + \definedummyword\t + % + % Commands that take arguments. + \definedummyword\acronym + \definedummyword\anchor + \definedummyword\cite + \definedummyword\code + \definedummyword\command + \definedummyword\dfn + \definedummyword\dmn + \definedummyword\email + \definedummyword\emph + \definedummyword\env + \definedummyword\file + \definedummyword\indicateurl + \definedummyword\kbd + \definedummyword\key + \definedummyword\math + \definedummyword\option + \definedummyword\pxref + \definedummyword\ref + \definedummyword\samp + \definedummyword\strong + \definedummyword\tie + \definedummyword\uref + \definedummyword\url + \definedummyword\var + \definedummyword\verb + \definedummyword\w + \definedummyword\xref +} + +% \indexnofonts is used when outputting the strings to sort the index +% by, and when constructing control sequence names. It eliminates all +% control sequences and just writes whatever the best ASCII sort string +% would be for a given command (usually its argument). +% +\def\indexnofonts{% + % Accent commands should become @asis. + \def\definedummyaccent##1{\let##1\asis}% + % We can just ignore other control letters. + \def\definedummyletter##1{\let##1\empty}% + % All control words become @asis by default; overrides below. + \let\definedummyword\definedummyaccent + % + \commondummiesnofonts + % + % Don't no-op \tt, since it isn't a user-level command + % and is used in the definitions of the active chars like <, >, |, etc. + % Likewise with the other plain tex font commands. + %\let\tt=\asis + % + \def\ { }% + \def\@{@}% + \def\_{\normalunderscore}% + \def\-{}% @- shouldn't affect sorting + % + % Unfortunately, texindex is not prepared to handle braces in the + % content at all. So for index sorting, we map @{ and @} to strings + % starting with |, since that ASCII character is between ASCII { and }. + \def\{{|a}% + \def\}{|b}% + % + % Non-English letters. + \def\AA{AA}% + \def\AE{AE}% + \def\DH{DZZ}% + \def\L{L}% + \def\OE{OE}% + \def\O{O}% + \def\TH{ZZZ}% + \def\aa{aa}% + \def\ae{ae}% + \def\dh{dzz}% + \def\exclamdown{!}% + \def\l{l}% + \def\oe{oe}% + \def\ordf{a}% + \def\ordm{o}% + \def\o{o}% + \def\questiondown{?}% + \def\ss{ss}% + \def\th{zzz}% + % + \def\LaTeX{LaTeX}% + \def\TeX{TeX}% + % + % Assorted special characters. + % (The following {} will end up in the sort string, but that's ok.) + \def\arrow{->}% + \def\bullet{bullet}% + \def\comma{,}% + \def\copyright{copyright}% + \def\dots{...}% + \def\enddots{...}% + \def\equiv{==}% + \def\error{error}% + \def\euro{euro}% + \def\expansion{==>}% + \def\geq{>=}% + \def\guillemetleft{<<}% + \def\guillemetright{>>}% + \def\guilsinglleft{<}% + \def\guilsinglright{>}% + \def\leq{<=}% + \def\minus{-}% + \def\point{.}% + \def\pounds{pounds}% + \def\print{-|}% + \def\quotedblbase{"}% + \def\quotedblleft{"}% + \def\quotedblright{"}% + \def\quoteleft{`}% + \def\quoteright{'}% + \def\quotesinglbase{,}% + \def\registeredsymbol{R}% + \def\result{=>}% + \def\textdegree{o}% + % + \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax + \else \indexlquoteignore \fi + % + % We need to get rid of all macros, leaving only the arguments (if present). + % Of course this is not nearly correct, but it is the best we can do for now. + % makeinfo does not expand macros in the argument to @deffn, which ends up + % writing an index entry, and texindex isn't prepared for an index sort entry + % that starts with \. + % + % Since macro invocations are followed by braces, we can just redefine them + % to take a single TeX argument. The case of a macro invocation that + % goes to end-of-line is not handled. + % + \macrolist +} + +% Undocumented (for FSFS 2nd ed.): @set txiindexlquoteignore makes us +% ignore left quotes in the sort term. +{\catcode`\`=\active + \gdef\indexlquoteignore{\let`=\empty}} + +\let\indexbackslash=0 %overridden during \printindex. +\let\SETmarginindex=\relax % put index entries in margin (undocumented)? + +% Most index entries go through here, but \dosubind is the general case. +% #1 is the index name, #2 is the entry text. +\def\doind#1#2{\dosubind{#1}{#2}{}} + +% Workhorse for all \fooindexes. +% #1 is name of index, #2 is stuff to put there, #3 is subentry -- +% empty if called from \doind, as we usually are (the main exception +% is with most defuns, which call us directly). +% +\def\dosubind#1#2#3{% + \iflinks + {% + % Store the main index entry text (including the third arg). + \toks0 = {#2}% + % If third arg is present, precede it with a space. + \def\thirdarg{#3}% + \ifx\thirdarg\empty \else + \toks0 = \expandafter{\the\toks0 \space #3}% + \fi + % + \edef\writeto{\csname#1indfile\endcsname}% + % + \safewhatsit\dosubindwrite + }% + \fi +} + +% Write the entry in \toks0 to the index file: +% +\def\dosubindwrite{% + % Put the index entry in the margin if desired. + \ifx\SETmarginindex\relax\else + \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}% + \fi + % + % Remember, we are within a group. + \indexdummies % Must do this here, since \bf, etc expand at this stage + \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now + % so it will be output as is; and it will print as backslash. + % + % Process the index entry with all font commands turned off, to + % get the string to sort by. + {\indexnofonts + \edef\temp{\the\toks0}% need full expansion + \xdef\indexsorttmp{\temp}% + }% + % + % Set up the complete index entry, with both the sort key and + % the original text, including any font commands. We write + % three arguments to \entry to the .?? file (four in the + % subentry case), texindex reduces to two when writing the .??s + % sorted result. + \edef\temp{% + \write\writeto{% + \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}% + }% + \temp +} + +% Take care of unwanted page breaks/skips around a whatsit: +% +% If a skip is the last thing on the list now, preserve it +% by backing up by \lastskip, doing the \write, then inserting +% the skip again. Otherwise, the whatsit generated by the +% \write or \pdfdest will make \lastskip zero. The result is that +% sequences like this: +% @end defun +% @tindex whatever +% @defun ... +% will have extra space inserted, because the \medbreak in the +% start of the @defun won't see the skip inserted by the @end of +% the previous defun. +% +% But don't do any of this if we're not in vertical mode. We +% don't want to do a \vskip and prematurely end a paragraph. +% +% Avoid page breaks due to these extra skips, too. +% +% But wait, there is a catch there: +% We'll have to check whether \lastskip is zero skip. \ifdim is not +% sufficient for this purpose, as it ignores stretch and shrink parts +% of the skip. The only way seems to be to check the textual +% representation of the skip. +% +% The following is almost like \def\zeroskipmacro{0.0pt} except that +% the ``p'' and ``t'' characters have catcode \other, not 11 (letter). +% +\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname} +% +\newskip\whatsitskip +\newcount\whatsitpenalty +% +% ..., ready, GO: +% +\def\safewhatsit#1{% +\ifhmode + #1% +\else + % \lastskip and \lastpenalty cannot both be nonzero simultaneously. + \whatsitskip = \lastskip + \edef\lastskipmacro{\the\lastskip}% + \whatsitpenalty = \lastpenalty + % + % If \lastskip is nonzero, that means the last item was a + % skip. And since a skip is discardable, that means this + % -\whatsitskip glue we're inserting is preceded by a + % non-discardable item, therefore it is not a potential + % breakpoint, therefore no \nobreak needed. + \ifx\lastskipmacro\zeroskipmacro + \else + \vskip-\whatsitskip + \fi + % + #1% + % + \ifx\lastskipmacro\zeroskipmacro + % If \lastskip was zero, perhaps the last item was a penalty, and + % perhaps it was >=10000, e.g., a \nobreak. In that case, we want + % to re-insert the same penalty (values >10000 are used for various + % signals); since we just inserted a non-discardable item, any + % following glue (such as a \parskip) would be a breakpoint. For example: + % + % @deffn deffn-whatever + % @vindex index-whatever + % Description. + % would allow a break between the index-whatever whatsit + % and the "Description." paragraph. + \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi + \else + % On the other hand, if we had a nonzero \lastskip, + % this make-up glue would be preceded by a non-discardable item + % (the whatsit from the \write), so we must insert a \nobreak. + \nobreak\vskip\whatsitskip + \fi +\fi +} + +% The index entry written in the file actually looks like +% \entry {sortstring}{page}{topic} +% or +% \entry {sortstring}{page}{topic}{subtopic} +% The texindex program reads in these files and writes files +% containing these kinds of lines: +% \initial {c} +% before the first topic whose initial is c +% \entry {topic}{pagelist} +% for a topic that is used without subtopics +% \primary {topic} +% for the beginning of a topic that is used with subtopics +% \secondary {subtopic}{pagelist} +% for each subtopic. + +% Define the user-accessible indexing commands +% @findex, @vindex, @kindex, @cindex. + +\def\findex {\fnindex} +\def\kindex {\kyindex} +\def\cindex {\cpindex} +\def\vindex {\vrindex} +\def\tindex {\tpindex} +\def\pindex {\pgindex} + +\def\cindexsub {\begingroup\obeylines\cindexsub} +{\obeylines % +\gdef\cindexsub "#1" #2^^M{\endgroup % +\dosubind{cp}{#2}{#1}}} + +% Define the macros used in formatting output of the sorted index material. + +% @printindex causes a particular index (the ??s file) to get printed. +% It does not print any chapter heading (usually an @unnumbered). +% +\parseargdef\printindex{\begingroup + \dobreak \chapheadingskip{10000}% + % + \smallfonts \rm + \tolerance = 9500 + \plainfrenchspacing + \everypar = {}% don't want the \kern\-parindent from indentation suppression. + % + % See if the index file exists and is nonempty. + % Change catcode of @ here so that if the index file contains + % \initial {@} + % as its first line, TeX doesn't complain about mismatched braces + % (because it thinks @} is a control sequence). + \catcode`\@ = 11 + \openin 1 \jobname.#1s + \ifeof 1 + % \enddoublecolumns gets confused if there is no text in the index, + % and it loses the chapter title and the aux file entries for the + % index. The easiest way to prevent this problem is to make sure + % there is some text. + \putwordIndexNonexistent + \else + % + % If the index file exists but is empty, then \openin leaves \ifeof + % false. We have to make TeX try to read something from the file, so + % it can discover if there is anything in it. + \read 1 to \temp + \ifeof 1 + \putwordIndexIsEmpty + \else + % Index files are almost Texinfo source, but we use \ as the escape + % character. It would be better to use @, but that's too big a change + % to make right now. + \def\indexbackslash{\backslashcurfont}% + \catcode`\\ = 0 + \escapechar = `\\ + \begindoublecolumns + \input \jobname.#1s + \enddoublecolumns + \fi + \fi + \closein 1 +\endgroup} + +% These macros are used by the sorted index file itself. +% Change them to control the appearance of the index. + +\def\initial#1{{% + % Some minor font changes for the special characters. + \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt + % + % Remove any glue we may have, we'll be inserting our own. + \removelastskip + % + % We like breaks before the index initials, so insert a bonus. + \nobreak + \vskip 0pt plus 3\baselineskip + \penalty 0 + \vskip 0pt plus -3\baselineskip + % + % Typeset the initial. Making this add up to a whole number of + % baselineskips increases the chance of the dots lining up from column + % to column. It still won't often be perfect, because of the stretch + % we need before each entry, but it's better. + % + % No shrink because it confuses \balancecolumns. + \vskip 1.67\baselineskip plus .5\baselineskip + \leftline{\secbf #1}% + % Do our best not to break after the initial. + \nobreak + \vskip .33\baselineskip plus .1\baselineskip +}} + +% \entry typesets a paragraph consisting of the text (#1), dot leaders, and +% then page number (#2) flushed to the right margin. It is used for index +% and table of contents entries. The paragraph is indented by \leftskip. +% +% A straightforward implementation would start like this: +% \def\entry#1#2{... +% But this freezes the catcodes in the argument, and can cause problems to +% @code, which sets - active. This problem was fixed by a kludge--- +% ``-'' was active throughout whole index, but this isn't really right. +% The right solution is to prevent \entry from swallowing the whole text. +% --kasal, 21nov03 +\def\entry{% + \begingroup + % + % Start a new paragraph if necessary, so our assignments below can't + % affect previous text. + \par + % + % Do not fill out the last line with white space. + \parfillskip = 0in + % + % No extra space above this paragraph. + \parskip = 0in + % + % Do not prefer a separate line ending with a hyphen to fewer lines. + \finalhyphendemerits = 0 + % + % \hangindent is only relevant when the entry text and page number + % don't both fit on one line. In that case, bob suggests starting the + % dots pretty far over on the line. Unfortunately, a large + % indentation looks wrong when the entry text itself is broken across + % lines. So we use a small indentation and put up with long leaders. + % + % \hangafter is reset to 1 (which is the value we want) at the start + % of each paragraph, so we need not do anything with that. + \hangindent = 2em + % + % When the entry text needs to be broken, just fill out the first line + % with blank space. + \rightskip = 0pt plus1fil + % + % A bit of stretch before each entry for the benefit of balancing + % columns. + \vskip 0pt plus1pt + % + % When reading the text of entry, convert explicit line breaks + % from @* into spaces. The user might give these in long section + % titles, for instance. + \def\*{\unskip\space\ignorespaces}% + \def\entrybreak{\hfil\break}% + % + % Swallow the left brace of the text (first parameter): + \afterassignment\doentry + \let\temp = +} +\def\entrybreak{\unskip\space\ignorespaces}% +\def\doentry{% + \bgroup % Instead of the swallowed brace. + \noindent + \aftergroup\finishentry + % And now comes the text of the entry. +} +\def\finishentry#1{% + % #1 is the page number. + % + % The following is kludged to not output a line of dots in the index if + % there are no page numbers. The next person who breaks this will be + % cursed by a Unix daemon. + \setbox\boxA = \hbox{#1}% + \ifdim\wd\boxA = 0pt + \ % + \else + % + % If we must, put the page number on a line of its own, and fill out + % this line with blank space. (The \hfil is overwhelmed with the + % fill leaders glue in \indexdotfill if the page number does fit.) + \hfil\penalty50 + \null\nobreak\indexdotfill % Have leaders before the page number. + % + % The `\ ' here is removed by the implicit \unskip that TeX does as + % part of (the primitive) \par. Without it, a spurious underfull + % \hbox ensues. + \ifpdf + \pdfgettoks#1.% + \ \the\toksA + \else + \ #1% + \fi + \fi + \par + \endgroup +} + +% Like plain.tex's \dotfill, except uses up at least 1 em. +\def\indexdotfill{\cleaders + \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill} + +\def\primary #1{\line{#1\hfil}} + +\newskip\secondaryindent \secondaryindent=0.5cm +\def\secondary#1#2{{% + \parfillskip=0in + \parskip=0in + \hangindent=1in + \hangafter=1 + \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill + \ifpdf + \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. + \else + #2 + \fi + \par +}} + +% Define two-column mode, which we use to typeset indexes. +% Adapted from the TeXbook, page 416, which is to say, +% the manmac.tex format used to print the TeXbook itself. +\catcode`\@=11 + +\newbox\partialpage +\newdimen\doublecolumnhsize + +\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns + % Grab any single-column material above us. + \output = {% + % + % Here is a possibility not foreseen in manmac: if we accumulate a + % whole lot of material, we might end up calling this \output + % routine twice in a row (see the doublecol-lose test, which is + % essentially a couple of indexes with @setchapternewpage off). In + % that case we just ship out what is in \partialpage with the normal + % output routine. Generally, \partialpage will be empty when this + % runs and this will be a no-op. See the indexspread.tex test case. + \ifvoid\partialpage \else + \onepageout{\pagecontents\partialpage}% + \fi + % + \global\setbox\partialpage = \vbox{% + % Unvbox the main output page. + \unvbox\PAGE + \kern-\topskip \kern\baselineskip + }% + }% + \eject % run that output routine to set \partialpage + % + % Use the double-column output routine for subsequent pages. + \output = {\doublecolumnout}% + % + % Change the page size parameters. We could do this once outside this + % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 + % format, but then we repeat the same computation. Repeating a couple + % of assignments once per index is clearly meaningless for the + % execution time, so we may as well do it in one place. + % + % First we halve the line length, less a little for the gutter between + % the columns. We compute the gutter based on the line length, so it + % changes automatically with the paper format. The magic constant + % below is chosen so that the gutter has the same value (well, +-<1pt) + % as it did when we hard-coded it. + % + % We put the result in a separate register, \doublecolumhsize, so we + % can restore it in \pagesofar, after \hsize itself has (potentially) + % been clobbered. + % + \doublecolumnhsize = \hsize + \advance\doublecolumnhsize by -.04154\hsize + \divide\doublecolumnhsize by 2 + \hsize = \doublecolumnhsize + % + % Double the \vsize as well. (We don't need a separate register here, + % since nobody clobbers \vsize.) + \vsize = 2\vsize +} + +% The double-column output routine for all double-column pages except +% the last. +% +\def\doublecolumnout{% + \splittopskip=\topskip \splitmaxdepth=\maxdepth + % Get the available space for the double columns -- the normal + % (undoubled) page height minus any material left over from the + % previous page. + \dimen@ = \vsize + \divide\dimen@ by 2 + \advance\dimen@ by -\ht\partialpage + % + % box0 will be the left-hand column, box2 the right. + \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ + \onepageout\pagesofar + \unvbox255 + \penalty\outputpenalty +} +% +% Re-output the contents of the output page -- any previous material, +% followed by the two boxes we just split, in box0 and box2. +\def\pagesofar{% + \unvbox\partialpage + % + \hsize = \doublecolumnhsize + \wd0=\hsize \wd2=\hsize + \hbox to\pagewidth{\box0\hfil\box2}% +} +% +% All done with double columns. +\def\enddoublecolumns{% + % The following penalty ensures that the page builder is exercised + % _before_ we change the output routine. This is necessary in the + % following situation: + % + % The last section of the index consists only of a single entry. + % Before this section, \pagetotal is less than \pagegoal, so no + % break occurs before the last section starts. However, the last + % section, consisting of \initial and the single \entry, does not + % fit on the page and has to be broken off. Without the following + % penalty the page builder will not be exercised until \eject + % below, and by that time we'll already have changed the output + % routine to the \balancecolumns version, so the next-to-last + % double-column page will be processed with \balancecolumns, which + % is wrong: The two columns will go to the main vertical list, with + % the broken-off section in the recent contributions. As soon as + % the output routine finishes, TeX starts reconsidering the page + % break. The two columns and the broken-off section both fit on the + % page, because the two columns now take up only half of the page + % goal. When TeX sees \eject from below which follows the final + % section, it invokes the new output routine that we've set after + % \balancecolumns below; \onepageout will try to fit the two columns + % and the final section into the vbox of \pageheight (see + % \pagebody), causing an overfull box. + % + % Note that glue won't work here, because glue does not exercise the + % page builder, unlike penalties (see The TeXbook, pp. 280-281). + \penalty0 + % + \output = {% + % Split the last of the double-column material. Leave it on the + % current page, no automatic page break. + \balancecolumns + % + % If we end up splitting too much material for the current page, + % though, there will be another page break right after this \output + % invocation ends. Having called \balancecolumns once, we do not + % want to call it again. Therefore, reset \output to its normal + % definition right away. (We hope \balancecolumns will never be + % called on to balance too much material, but if it is, this makes + % the output somewhat more palatable.) + \global\output = {\onepageout{\pagecontents\PAGE}}% + }% + \eject + \endgroup % started in \begindoublecolumns + % + % \pagegoal was set to the doubled \vsize above, since we restarted + % the current page. We're now back to normal single-column + % typesetting, so reset \pagegoal to the normal \vsize (after the + % \endgroup where \vsize got restored). + \pagegoal = \vsize +} +% +% Called at the end of the double column material. +\def\balancecolumns{% + \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120. + \dimen@ = \ht0 + \advance\dimen@ by \topskip + \advance\dimen@ by-\baselineskip + \divide\dimen@ by 2 % target to split to + %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}% + \splittopskip = \topskip + % Loop until we get a decent breakpoint. + {% + \vbadness = 10000 + \loop + \global\setbox3 = \copy0 + \global\setbox1 = \vsplit3 to \dimen@ + \ifdim\ht3>\dimen@ + \global\advance\dimen@ by 1pt + \repeat + }% + %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}% + \setbox0=\vbox to\dimen@{\unvbox1}% + \setbox2=\vbox to\dimen@{\unvbox3}% + % + \pagesofar +} +\catcode`\@ = \other + + +\message{sectioning,} +% Chapters, sections, etc. + +% Let's start with @part. +\outer\parseargdef\part{\partzzz{#1}} +\def\partzzz#1{% + \chapoddpage + \null + \vskip.3\vsize % move it down on the page a bit + \begingroup + \noindent \titlefonts\rmisbold #1\par % the text + \let\lastnode=\empty % no node to associate with + \writetocentry{part}{#1}{}% but put it in the toc + \headingsoff % no headline or footline on the part page + \chapoddpage + \endgroup +} + +% \unnumberedno is an oxymoron. But we count the unnumbered +% sections so that we can refer to them unambiguously in the pdf +% outlines by their "section number". We avoid collisions with chapter +% numbers by starting them at 10000. (If a document ever has 10000 +% chapters, we're in trouble anyway, I'm sure.) +\newcount\unnumberedno \unnumberedno = 10000 +\newcount\chapno +\newcount\secno \secno=0 +\newcount\subsecno \subsecno=0 +\newcount\subsubsecno \subsubsecno=0 + +% This counter is funny since it counts through charcodes of letters A, B, ... +\newcount\appendixno \appendixno = `\@ +% +% \def\appendixletter{\char\the\appendixno} +% We do the following ugly conditional instead of the above simple +% construct for the sake of pdftex, which needs the actual +% letter in the expansion, not just typeset. +% +\def\appendixletter{% + \ifnum\appendixno=`A A% + \else\ifnum\appendixno=`B B% + \else\ifnum\appendixno=`C C% + \else\ifnum\appendixno=`D D% + \else\ifnum\appendixno=`E E% + \else\ifnum\appendixno=`F F% + \else\ifnum\appendixno=`G G% + \else\ifnum\appendixno=`H H% + \else\ifnum\appendixno=`I I% + \else\ifnum\appendixno=`J J% + \else\ifnum\appendixno=`K K% + \else\ifnum\appendixno=`L L% + \else\ifnum\appendixno=`M M% + \else\ifnum\appendixno=`N N% + \else\ifnum\appendixno=`O O% + \else\ifnum\appendixno=`P P% + \else\ifnum\appendixno=`Q Q% + \else\ifnum\appendixno=`R R% + \else\ifnum\appendixno=`S S% + \else\ifnum\appendixno=`T T% + \else\ifnum\appendixno=`U U% + \else\ifnum\appendixno=`V V% + \else\ifnum\appendixno=`W W% + \else\ifnum\appendixno=`X X% + \else\ifnum\appendixno=`Y Y% + \else\ifnum\appendixno=`Z Z% + % The \the is necessary, despite appearances, because \appendixletter is + % expanded while writing the .toc file. \char\appendixno is not + % expandable, thus it is written literally, thus all appendixes come out + % with the same letter (or @) in the toc without it. + \else\char\the\appendixno + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi + \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} + +% Each @chapter defines these (using marks) as the number+name, number +% and name of the chapter. Page headings and footings can use +% these. @section does likewise. +\def\thischapter{} +\def\thischapternum{} +\def\thischaptername{} +\def\thissection{} +\def\thissectionnum{} +\def\thissectionname{} + +\newcount\absseclevel % used to calculate proper heading level +\newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count + +% @raisesections: treat @section as chapter, @subsection as section, etc. +\def\raisesections{\global\advance\secbase by -1} +\let\up=\raisesections % original BFox name + +% @lowersections: treat @chapter as section, @section as subsection, etc. +\def\lowersections{\global\advance\secbase by 1} +\let\down=\lowersections % original BFox name + +% we only have subsub. +\chardef\maxseclevel = 3 +% +% A numbered section within an unnumbered changes to unnumbered too. +% To achieve this, remember the "biggest" unnum. sec. we are currently in: +\chardef\unnlevel = \maxseclevel +% +% Trace whether the current chapter is an appendix or not: +% \chapheadtype is "N" or "A", unnumbered chapters are ignored. +\def\chapheadtype{N} + +% Choose a heading macro +% #1 is heading type +% #2 is heading level +% #3 is text for heading +\def\genhead#1#2#3{% + % Compute the abs. sec. level: + \absseclevel=#2 + \advance\absseclevel by \secbase + % Make sure \absseclevel doesn't fall outside the range: + \ifnum \absseclevel < 0 + \absseclevel = 0 + \else + \ifnum \absseclevel > 3 + \absseclevel = 3 + \fi + \fi + % The heading type: + \def\headtype{#1}% + \if \headtype U% + \ifnum \absseclevel < \unnlevel + \chardef\unnlevel = \absseclevel + \fi + \else + % Check for appendix sections: + \ifnum \absseclevel = 0 + \edef\chapheadtype{\headtype}% + \else + \if \headtype A\if \chapheadtype N% + \errmessage{@appendix... within a non-appendix chapter}% + \fi\fi + \fi + % Check for numbered within unnumbered: + \ifnum \absseclevel > \unnlevel + \def\headtype{U}% + \else + \chardef\unnlevel = 3 + \fi + \fi + % Now print the heading: + \if \headtype U% + \ifcase\absseclevel + \unnumberedzzz{#3}% + \or \unnumberedseczzz{#3}% + \or \unnumberedsubseczzz{#3}% + \or \unnumberedsubsubseczzz{#3}% + \fi + \else + \if \headtype A% + \ifcase\absseclevel + \appendixzzz{#3}% + \or \appendixsectionzzz{#3}% + \or \appendixsubseczzz{#3}% + \or \appendixsubsubseczzz{#3}% + \fi + \else + \ifcase\absseclevel + \chapterzzz{#3}% + \or \seczzz{#3}% + \or \numberedsubseczzz{#3}% + \or \numberedsubsubseczzz{#3}% + \fi + \fi + \fi + \suppressfirstparagraphindent +} + +% an interface: +\def\numhead{\genhead N} +\def\apphead{\genhead A} +\def\unnmhead{\genhead U} + +% @chapter, @appendix, @unnumbered. Increment top-level counter, reset +% all lower-level sectioning counters to zero. +% +% Also set \chaplevelprefix, which we prepend to @float sequence numbers +% (e.g., figures), q.v. By default (before any chapter), that is empty. +\let\chaplevelprefix = \empty +% +\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz +\def\chapterzzz#1{% + % section resetting is \global in case the chapter is in a group, such + % as an @include file. + \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 + \global\advance\chapno by 1 + % + % Used for \float. + \gdef\chaplevelprefix{\the\chapno.}% + \resetallfloatnos + % + % \putwordChapter can contain complex things in translations. + \toks0=\expandafter{\putwordChapter}% + \message{\the\toks0 \space \the\chapno}% + % + % Write the actual heading. + \chapmacro{#1}{Ynumbered}{\the\chapno}% + % + % So @section and the like are numbered underneath this chapter. + \global\let\section = \numberedsec + \global\let\subsection = \numberedsubsec + \global\let\subsubsection = \numberedsubsubsec +} + +\outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz +% +\def\appendixzzz#1{% + \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 + \global\advance\appendixno by 1 + \gdef\chaplevelprefix{\appendixletter.}% + \resetallfloatnos + % + % \putwordAppendix can contain complex things in translations. + \toks0=\expandafter{\putwordAppendix}% + \message{\the\toks0 \space \appendixletter}% + % + \chapmacro{#1}{Yappendix}{\appendixletter}% + % + \global\let\section = \appendixsec + \global\let\subsection = \appendixsubsec + \global\let\subsubsection = \appendixsubsubsec +} + +% normally unnmhead0 calls unnumberedzzz: +\outer\parseargdef\unnumbered{\unnmhead0{#1}} +\def\unnumberedzzz#1{% + \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 + \global\advance\unnumberedno by 1 + % + % Since an unnumbered has no number, no prefix for figures. + \global\let\chaplevelprefix = \empty + \resetallfloatnos + % + % This used to be simply \message{#1}, but TeX fully expands the + % argument to \message. Therefore, if #1 contained @-commands, TeX + % expanded them. For example, in `@unnumbered The @cite{Book}', TeX + % expanded @cite (which turns out to cause errors because \cite is meant + % to be executed, not expanded). + % + % Anyway, we don't want the fully-expanded definition of @cite to appear + % as a result of the \message, we just want `@cite' itself. We use + % \the to achieve this: TeX expands \the only once, + % simply yielding the contents of . (We also do this for + % the toc entries.) + \toks0 = {#1}% + \message{(\the\toks0)}% + % + \chapmacro{#1}{Ynothing}{\the\unnumberedno}% + % + \global\let\section = \unnumberedsec + \global\let\subsection = \unnumberedsubsec + \global\let\subsubsection = \unnumberedsubsubsec +} + +% @centerchap is like @unnumbered, but the heading is centered. +\outer\parseargdef\centerchap{% + % Well, we could do the following in a group, but that would break + % an assumption that \chapmacro is called at the outermost level. + % Thus we are safer this way: --kasal, 24feb04 + \let\centerparametersmaybe = \centerparameters + \unnmhead0{#1}% + \let\centerparametersmaybe = \relax +} + +% @top is like @unnumbered. +\let\top\unnumbered + +% Sections. +% +\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz +\def\seczzz#1{% + \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 + \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}% +} + +% normally calls appendixsectionzzz: +\outer\parseargdef\appendixsection{\apphead1{#1}} +\def\appendixsectionzzz#1{% + \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 + \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}% +} +\let\appendixsec\appendixsection + +% normally calls unnumberedseczzz: +\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} +\def\unnumberedseczzz#1{% + \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 + \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}% +} + +% Subsections. +% +% normally calls numberedsubseczzz: +\outer\parseargdef\numberedsubsec{\numhead2{#1}} +\def\numberedsubseczzz#1{% + \global\subsubsecno=0 \global\advance\subsecno by 1 + \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}% +} + +% normally calls appendixsubseczzz: +\outer\parseargdef\appendixsubsec{\apphead2{#1}} +\def\appendixsubseczzz#1{% + \global\subsubsecno=0 \global\advance\subsecno by 1 + \sectionheading{#1}{subsec}{Yappendix}% + {\appendixletter.\the\secno.\the\subsecno}% +} + +% normally calls unnumberedsubseczzz: +\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} +\def\unnumberedsubseczzz#1{% + \global\subsubsecno=0 \global\advance\subsecno by 1 + \sectionheading{#1}{subsec}{Ynothing}% + {\the\unnumberedno.\the\secno.\the\subsecno}% +} + +% Subsubsections. +% +% normally numberedsubsubseczzz: +\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} +\def\numberedsubsubseczzz#1{% + \global\advance\subsubsecno by 1 + \sectionheading{#1}{subsubsec}{Ynumbered}% + {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}% +} + +% normally appendixsubsubseczzz: +\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} +\def\appendixsubsubseczzz#1{% + \global\advance\subsubsecno by 1 + \sectionheading{#1}{subsubsec}{Yappendix}% + {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}% +} + +% normally unnumberedsubsubseczzz: +\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} +\def\unnumberedsubsubseczzz#1{% + \global\advance\subsubsecno by 1 + \sectionheading{#1}{subsubsec}{Ynothing}% + {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}% +} + +% These macros control what the section commands do, according +% to what kind of chapter we are in (ordinary, appendix, or unnumbered). +% Define them by default for a numbered chapter. +\let\section = \numberedsec +\let\subsection = \numberedsubsec +\let\subsubsection = \numberedsubsubsec + +% Define @majorheading, @heading and @subheading + +% NOTE on use of \vbox for chapter headings, section headings, and such: +% 1) We use \vbox rather than the earlier \line to permit +% overlong headings to fold. +% 2) \hyphenpenalty is set to 10000 because hyphenation in a +% heading is obnoxious; this forbids it. +% 3) Likewise, headings look best if no \parindent is used, and +% if justification is not attempted. Hence \raggedright. + +\def\majorheading{% + {\advance\chapheadingskip by 10pt \chapbreak }% + \parsearg\chapheadingzzz +} + +\def\chapheading{\chapbreak \parsearg\chapheadingzzz} +\def\chapheadingzzz#1{% + {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\ptexraggedright + \rmisbold #1\hfill}}% + \bigskip \par\penalty 200\relax + \suppressfirstparagraphindent +} + +% @heading, @subheading, @subsubheading. +\parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{} + \suppressfirstparagraphindent} +\parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{} + \suppressfirstparagraphindent} +\parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{} + \suppressfirstparagraphindent} + +% These macros generate a chapter, section, etc. heading only +% (including whitespace, linebreaking, etc. around it), +% given all the information in convenient, parsed form. + +% Args are the skip and penalty (usually negative) +\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} + +% Parameter controlling skip before chapter headings (if needed) +\newskip\chapheadingskip + +% Define plain chapter starts, and page on/off switching for it. +\def\chapbreak{\dobreak \chapheadingskip {-4000}} +\def\chappager{\par\vfill\supereject} +% Because \domark is called before \chapoddpage, the filler page will +% get the headings for the next chapter, which is wrong. But we don't +% care -- we just disable all headings on the filler page. +\def\chapoddpage{% + \chappager + \ifodd\pageno \else + \begingroup + \headingsoff + \null + \chappager + \endgroup + \fi +} + +\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} + +\def\CHAPPAGoff{% +\global\let\contentsalignmacro = \chappager +\global\let\pchapsepmacro=\chapbreak +\global\let\pagealignmacro=\chappager} + +\def\CHAPPAGon{% +\global\let\contentsalignmacro = \chappager +\global\let\pchapsepmacro=\chappager +\global\let\pagealignmacro=\chappager +\global\def\HEADINGSon{\HEADINGSsingle}} + +\def\CHAPPAGodd{% +\global\let\contentsalignmacro = \chapoddpage +\global\let\pchapsepmacro=\chapoddpage +\global\let\pagealignmacro=\chapoddpage +\global\def\HEADINGSon{\HEADINGSdouble}} + +\CHAPPAGon + +% Chapter opening. +% +% #1 is the text, #2 is the section type (Ynumbered, Ynothing, +% Yappendix, Yomitfromtoc), #3 the chapter number. +% +% To test against our argument. +\def\Ynothingkeyword{Ynothing} +\def\Yomitfromtockeyword{Yomitfromtoc} +\def\Yappendixkeyword{Yappendix} +% +\def\chapmacro#1#2#3{% + % Insert the first mark before the heading break (see notes for \domark). + \let\prevchapterdefs=\lastchapterdefs + \let\prevsectiondefs=\lastsectiondefs + \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}% + \gdef\thissection{}}% + % + \def\temptype{#2}% + \ifx\temptype\Ynothingkeyword + \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% + \gdef\thischapter{\thischaptername}}% + \else\ifx\temptype\Yomitfromtockeyword + \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% + \gdef\thischapter{}}% + \else\ifx\temptype\Yappendixkeyword + \toks0={#1}% + \xdef\lastchapterdefs{% + \gdef\noexpand\thischaptername{\the\toks0}% + \gdef\noexpand\thischapternum{\appendixletter}% + % \noexpand\putwordAppendix avoids expanding indigestible + % commands in some of the translations. + \gdef\noexpand\thischapter{\noexpand\putwordAppendix{} + \noexpand\thischapternum: + \noexpand\thischaptername}% + }% + \else + \toks0={#1}% + \xdef\lastchapterdefs{% + \gdef\noexpand\thischaptername{\the\toks0}% + \gdef\noexpand\thischapternum{\the\chapno}% + % \noexpand\putwordChapter avoids expanding indigestible + % commands in some of the translations. + \gdef\noexpand\thischapter{\noexpand\putwordChapter{} + \noexpand\thischapternum: + \noexpand\thischaptername}% + }% + \fi\fi\fi + % + % Output the mark. Pass it through \safewhatsit, to take care of + % the preceding space. + \safewhatsit\domark + % + % Insert the chapter heading break. + \pchapsepmacro + % + % Now the second mark, after the heading break. No break points + % between here and the heading. + \let\prevchapterdefs=\lastchapterdefs + \let\prevsectiondefs=\lastsectiondefs + \domark + % + {% + \chapfonts \rmisbold + % + % Have to define \lastsection before calling \donoderef, because the + % xref code eventually uses it. On the other hand, it has to be called + % after \pchapsepmacro, or the headline will change too soon. + \gdef\lastsection{#1}% + % + % Only insert the separating space if we have a chapter/appendix + % number, and don't print the unnumbered ``number''. + \ifx\temptype\Ynothingkeyword + \setbox0 = \hbox{}% + \def\toctype{unnchap}% + \else\ifx\temptype\Yomitfromtockeyword + \setbox0 = \hbox{}% contents like unnumbered, but no toc entry + \def\toctype{omit}% + \else\ifx\temptype\Yappendixkeyword + \setbox0 = \hbox{\putwordAppendix{} #3\enspace}% + \def\toctype{app}% + \else + \setbox0 = \hbox{#3\enspace}% + \def\toctype{numchap}% + \fi\fi\fi + % + % Write the toc entry for this chapter. Must come before the + % \donoderef, because we include the current node name in the toc + % entry, and \donoderef resets it to empty. + \writetocentry{\toctype}{#1}{#3}% + % + % For pdftex, we have to write out the node definition (aka, make + % the pdfdest) after any page break, but before the actual text has + % been typeset. If the destination for the pdf outline is after the + % text, then jumping from the outline may wind up with the text not + % being visible, for instance under high magnification. + \donoderef{#2}% + % + % Typeset the actual heading. + \nobreak % Avoid page breaks at the interline glue. + \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright + \hangindent=\wd0 \centerparametersmaybe + \unhbox0 #1\par}% + }% + \nobreak\bigskip % no page break after a chapter title + \nobreak +} + +% @centerchap -- centered and unnumbered. +\let\centerparametersmaybe = \relax +\def\centerparameters{% + \advance\rightskip by 3\rightskip + \leftskip = \rightskip + \parfillskip = 0pt +} + + +% I don't think this chapter style is supported any more, so I'm not +% updating it with the new noderef stuff. We'll see. --karl, 11aug03. +% +\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} +% +\def\unnchfopen #1{% +\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\ptexraggedright + \rmisbold #1\hfill}}\bigskip \par\nobreak +} +\def\chfopen #1#2{\chapoddpage {\chapfonts +\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% +\par\penalty 5000 % +} +\def\centerchfopen #1{% +\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt + \hfill {\rmisbold #1}\hfill}}\bigskip \par\nobreak +} +\def\CHAPFopen{% + \global\let\chapmacro=\chfopen + \global\let\centerchapmacro=\centerchfopen} + + +% Section titles. These macros combine the section number parts and +% call the generic \sectionheading to do the printing. +% +\newskip\secheadingskip +\def\secheadingbreak{\dobreak \secheadingskip{-1000}} + +% Subsection titles. +\newskip\subsecheadingskip +\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}} + +% Subsubsection titles. +\def\subsubsecheadingskip{\subsecheadingskip} +\def\subsubsecheadingbreak{\subsecheadingbreak} + + +% Print any size, any type, section title. +% +% #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is +% the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the +% section number. +% +\def\seckeyword{sec} +% +\def\sectionheading#1#2#3#4{% + {% + \checkenv{}% should not be in an environment. + % + % Switch to the right set of fonts. + \csname #2fonts\endcsname \rmisbold + % + \def\sectionlevel{#2}% + \def\temptype{#3}% + % + % Insert first mark before the heading break (see notes for \domark). + \let\prevsectiondefs=\lastsectiondefs + \ifx\temptype\Ynothingkeyword + \ifx\sectionlevel\seckeyword + \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}% + \gdef\thissection{\thissectionname}}% + \fi + \else\ifx\temptype\Yomitfromtockeyword + % Don't redefine \thissection. + \else\ifx\temptype\Yappendixkeyword + \ifx\sectionlevel\seckeyword + \toks0={#1}% + \xdef\lastsectiondefs{% + \gdef\noexpand\thissectionname{\the\toks0}% + \gdef\noexpand\thissectionnum{#4}% + % \noexpand\putwordSection avoids expanding indigestible + % commands in some of the translations. + \gdef\noexpand\thissection{\noexpand\putwordSection{} + \noexpand\thissectionnum: + \noexpand\thissectionname}% + }% + \fi + \else + \ifx\sectionlevel\seckeyword + \toks0={#1}% + \xdef\lastsectiondefs{% + \gdef\noexpand\thissectionname{\the\toks0}% + \gdef\noexpand\thissectionnum{#4}% + % \noexpand\putwordSection avoids expanding indigestible + % commands in some of the translations. + \gdef\noexpand\thissection{\noexpand\putwordSection{} + \noexpand\thissectionnum: + \noexpand\thissectionname}% + }% + \fi + \fi\fi\fi + % + % Go into vertical mode. Usually we'll already be there, but we + % don't want the following whatsit to end up in a preceding paragraph + % if the document didn't happen to have a blank line. + \par + % + % Output the mark. Pass it through \safewhatsit, to take care of + % the preceding space. + \safewhatsit\domark + % + % Insert space above the heading. + \csname #2headingbreak\endcsname + % + % Now the second mark, after the heading break. No break points + % between here and the heading. + \let\prevsectiondefs=\lastsectiondefs + \domark + % + % Only insert the space after the number if we have a section number. + \ifx\temptype\Ynothingkeyword + \setbox0 = \hbox{}% + \def\toctype{unn}% + \gdef\lastsection{#1}% + \else\ifx\temptype\Yomitfromtockeyword + % for @headings -- no section number, don't include in toc, + % and don't redefine \lastsection. + \setbox0 = \hbox{}% + \def\toctype{omit}% + \let\sectionlevel=\empty + \else\ifx\temptype\Yappendixkeyword + \setbox0 = \hbox{#4\enspace}% + \def\toctype{app}% + \gdef\lastsection{#1}% + \else + \setbox0 = \hbox{#4\enspace}% + \def\toctype{num}% + \gdef\lastsection{#1}% + \fi\fi\fi + % + % Write the toc entry (before \donoderef). See comments in \chapmacro. + \writetocentry{\toctype\sectionlevel}{#1}{#4}% + % + % Write the node reference (= pdf destination for pdftex). + % Again, see comments in \chapmacro. + \donoderef{#3}% + % + % Interline glue will be inserted when the vbox is completed. + % That glue will be a valid breakpoint for the page, since it'll be + % preceded by a whatsit (usually from the \donoderef, or from the + % \writetocentry if there was no node). We don't want to allow that + % break, since then the whatsits could end up on page n while the + % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000. + \nobreak + % + % Output the actual section heading. + \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright + \hangindent=\wd0 % zero if no section number + \unhbox0 #1}% + }% + % Add extra space after the heading -- half of whatever came above it. + % Don't allow stretch, though. + \kern .5 \csname #2headingskip\endcsname + % + % Do not let the kern be a potential breakpoint, as it would be if it + % was followed by glue. + \nobreak + % + % We'll almost certainly start a paragraph next, so don't let that + % glue accumulate. (Not a breakpoint because it's preceded by a + % discardable item.) + \vskip-\parskip + % + % This is purely so the last item on the list is a known \penalty > + % 10000. This is so \startdefun can avoid allowing breakpoints after + % section headings. Otherwise, it would insert a valid breakpoint between: + % @section sec-whatever + % @deffn def-whatever + \penalty 10001 +} + + +\message{toc,} +% Table of contents. +\newwrite\tocfile + +% Write an entry to the toc file, opening it if necessary. +% Called from @chapter, etc. +% +% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno} +% We append the current node name (if any) and page number as additional +% arguments for the \{chap,sec,...}entry macros which will eventually +% read this. The node name is used in the pdf outlines as the +% destination to jump to. +% +% We open the .toc file for writing here instead of at @setfilename (or +% any other fixed time) so that @contents can be anywhere in the document. +% But if #1 is `omit', then we don't do anything. This is used for the +% table of contents chapter openings themselves. +% +\newif\iftocfileopened +\def\omitkeyword{omit}% +% +\def\writetocentry#1#2#3{% + \edef\writetoctype{#1}% + \ifx\writetoctype\omitkeyword \else + \iftocfileopened\else + \immediate\openout\tocfile = \jobname.toc + \global\tocfileopenedtrue + \fi + % + \iflinks + {\atdummies + \edef\temp{% + \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}% + \temp + }% + \fi + \fi + % + % Tell \shipout to create a pdf destination on each page, if we're + % writing pdf. These are used in the table of contents. We can't + % just write one on every page because the title pages are numbered + % 1 and 2 (the page numbers aren't printed), and so are the first + % two pages of the document. Thus, we'd have two destinations named + % `1', and two named `2'. + \ifpdf \global\pdfmakepagedesttrue \fi +} + + +% These characters do not print properly in the Computer Modern roman +% fonts, so we must take special care. This is more or less redundant +% with the Texinfo input format setup at the end of this file. +% +\def\activecatcodes{% + \catcode`\"=\active + \catcode`\$=\active + \catcode`\<=\active + \catcode`\>=\active + \catcode`\\=\active + \catcode`\^=\active + \catcode`\_=\active + \catcode`\|=\active + \catcode`\~=\active +} + + +% Read the toc file, which is essentially Texinfo input. +\def\readtocfile{% + \setupdatafile + \activecatcodes + \input \tocreadfilename +} + +\newskip\contentsrightmargin \contentsrightmargin=1in +\newcount\savepageno +\newcount\lastnegativepageno \lastnegativepageno = -1 + +% Prepare to read what we've written to \tocfile. +% +\def\startcontents#1{% + % If @setchapternewpage on, and @headings double, the contents should + % start on an odd page, unlike chapters. Thus, we maintain + % \contentsalignmacro in parallel with \pagealignmacro. + % From: Torbjorn Granlund + \contentsalignmacro + \immediate\closeout\tocfile + % + % Don't need to put `Contents' or `Short Contents' in the headline. + % It is abundantly clear what they are. + \chapmacro{#1}{Yomitfromtoc}{}% + % + \savepageno = \pageno + \begingroup % Set up to handle contents files properly. + \raggedbottom % Worry more about breakpoints than the bottom. + \advance\hsize by -\contentsrightmargin % Don't use the full line length. + % + % Roman numerals for page numbers. + \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi +} + +% redefined for the two-volume lispref. We always output on +% \jobname.toc even if this is redefined. +% +\def\tocreadfilename{\jobname.toc} + +% Normal (long) toc. +% +\def\contents{% + \startcontents{\putwordTOC}% + \openin 1 \tocreadfilename\space + \ifeof 1 \else + \readtocfile + \fi + \vfill \eject + \contentsalignmacro % in case @setchapternewpage odd is in effect + \ifeof 1 \else + \pdfmakeoutlines + \fi + \closein 1 + \endgroup + \lastnegativepageno = \pageno + \global\pageno = \savepageno +} + +% And just the chapters. +\def\summarycontents{% + \startcontents{\putwordShortTOC}% + % + \let\partentry = \shortpartentry + \let\numchapentry = \shortchapentry + \let\appentry = \shortchapentry + \let\unnchapentry = \shortunnchapentry + % We want a true roman here for the page numbers. + \secfonts + \let\rm=\shortcontrm \let\bf=\shortcontbf + \let\sl=\shortcontsl \let\tt=\shortconttt + \rm + \hyphenpenalty = 10000 + \advance\baselineskip by 1pt % Open it up a little. + \def\numsecentry##1##2##3##4{} + \let\appsecentry = \numsecentry + \let\unnsecentry = \numsecentry + \let\numsubsecentry = \numsecentry + \let\appsubsecentry = \numsecentry + \let\unnsubsecentry = \numsecentry + \let\numsubsubsecentry = \numsecentry + \let\appsubsubsecentry = \numsecentry + \let\unnsubsubsecentry = \numsecentry + \openin 1 \tocreadfilename\space + \ifeof 1 \else + \readtocfile + \fi + \closein 1 + \vfill \eject + \contentsalignmacro % in case @setchapternewpage odd is in effect + \endgroup + \lastnegativepageno = \pageno + \global\pageno = \savepageno +} +\let\shortcontents = \summarycontents + +% Typeset the label for a chapter or appendix for the short contents. +% The arg is, e.g., `A' for an appendix, or `3' for a chapter. +% +\def\shortchaplabel#1{% + % This space should be enough, since a single number is .5em, and the + % widest letter (M) is 1em, at least in the Computer Modern fonts. + % But use \hss just in case. + % (This space doesn't include the extra space that gets added after + % the label; that gets put in by \shortchapentry above.) + % + % We'd like to right-justify chapter numbers, but that looks strange + % with appendix letters. And right-justifying numbers and + % left-justifying letters looks strange when there is less than 10 + % chapters. Have to read the whole toc once to know how many chapters + % there are before deciding ... + \hbox to 1em{#1\hss}% +} + +% These macros generate individual entries in the table of contents. +% The first argument is the chapter or section name. +% The last argument is the page number. +% The arguments in between are the chapter number, section number, ... + +% Parts, in the main contents. Replace the part number, which doesn't +% exist, with an empty box. Let's hope all the numbers have the same width. +% Also ignore the page number, which is conventionally not printed. +\def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}} +\def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}} +% +% Parts, in the short toc. +\def\shortpartentry#1#2#3#4{% + \penalty-300 + \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip + \shortchapentry{{\bf #1}}{\numeralbox}{}{}% +} + +% Chapters, in the main contents. +\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}} +% +% Chapters, in the short toc. +% See comments in \dochapentry re vbox and related settings. +\def\shortchapentry#1#2#3#4{% + \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}% +} + +% Appendices, in the main contents. +% Need the word Appendix, and a fixed-size box. +% +\def\appendixbox#1{% + % We use M since it's probably the widest letter. + \setbox0 = \hbox{\putwordAppendix{} M}% + \hbox to \wd0{\putwordAppendix{} #1\hss}} +% +\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}} + +% Unnumbered chapters. +\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}} +\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}} + +% Sections. +\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}} +\let\appsecentry=\numsecentry +\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}} + +% Subsections. +\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}} +\let\appsubsecentry=\numsubsecentry +\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}} + +% And subsubsections. +\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}} +\let\appsubsubsecentry=\numsubsubsecentry +\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}} + +% This parameter controls the indentation of the various levels. +% Same as \defaultparindent. +\newdimen\tocindent \tocindent = 15pt + +% Now for the actual typesetting. In all these, #1 is the text and #2 is the +% page number. +% +% If the toc has to be broken over pages, we want it to be at chapters +% if at all possible; hence the \penalty. +\def\dochapentry#1#2{% + \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip + \begingroup + \chapentryfonts + \tocentry{#1}{\dopageno\bgroup#2\egroup}% + \endgroup + \nobreak\vskip .25\baselineskip plus.1\baselineskip +} + +\def\dosecentry#1#2{\begingroup + \secentryfonts \leftskip=\tocindent + \tocentry{#1}{\dopageno\bgroup#2\egroup}% +\endgroup} + +\def\dosubsecentry#1#2{\begingroup + \subsecentryfonts \leftskip=2\tocindent + \tocentry{#1}{\dopageno\bgroup#2\egroup}% +\endgroup} + +\def\dosubsubsecentry#1#2{\begingroup + \subsubsecentryfonts \leftskip=3\tocindent + \tocentry{#1}{\dopageno\bgroup#2\egroup}% +\endgroup} + +% We use the same \entry macro as for the index entries. +\let\tocentry = \entry + +% Space between chapter (or whatever) number and the title. +\def\labelspace{\hskip1em \relax} + +\def\dopageno#1{{\rm #1}} +\def\doshortpageno#1{{\rm #1}} + +\def\chapentryfonts{\secfonts \rm} +\def\secentryfonts{\textfonts} +\def\subsecentryfonts{\textfonts} +\def\subsubsecentryfonts{\textfonts} + + +\message{environments,} +% @foo ... @end foo. + +% @tex ... @end tex escapes into raw TeX temporarily. +% One exception: @ is still an escape character, so that @end tex works. +% But \@ or @@ will get a plain @ character. + +\envdef\tex{% + \setupmarkupstyle{tex}% + \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 + \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 + \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie + \catcode `\%=14 + \catcode `\+=\other + \catcode `\"=\other + \catcode `\|=\other + \catcode `\<=\other + \catcode `\>=\other + \catcode`\`=\other + \catcode`\'=\other + \escapechar=`\\ + % + % ' is active in math mode (mathcode"8000). So reset it, and all our + % other math active characters (just in case), to plain's definitions. + \mathactive + % + \let\b=\ptexb + \let\bullet=\ptexbullet + \let\c=\ptexc + \let\,=\ptexcomma + \let\.=\ptexdot + \let\dots=\ptexdots + \let\equiv=\ptexequiv + \let\!=\ptexexclam + \let\i=\ptexi + \let\indent=\ptexindent + \let\noindent=\ptexnoindent + \let\{=\ptexlbrace + \let\+=\tabalign + \let\}=\ptexrbrace + \let\/=\ptexslash + \let\*=\ptexstar + \let\t=\ptext + \expandafter \let\csname top\endcsname=\ptextop % outer + \let\frenchspacing=\plainfrenchspacing + % + \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% + \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% + \def\@{@}% +} +% There is no need to define \Etex. + +% Define @lisp ... @end lisp. +% @lisp environment forms a group so it can rebind things, +% including the definition of @end lisp (which normally is erroneous). + +% Amount to narrow the margins by for @lisp. +\newskip\lispnarrowing \lispnarrowing=0.4in + +% This is the definition that ^^M gets inside @lisp, @example, and other +% such environments. \null is better than a space, since it doesn't +% have any width. +\def\lisppar{\null\endgraf} + +% This space is always present above and below environments. +\newskip\envskipamount \envskipamount = 0pt + +% Make spacing and below environment symmetrical. We use \parskip here +% to help in doing that, since in @example-like environments \parskip +% is reset to zero; thus the \afterenvbreak inserts no space -- but the +% start of the next paragraph will insert \parskip. +% +\def\aboveenvbreak{{% + % =10000 instead of <10000 because of a special case in \itemzzz and + % \sectionheading, q.v. + \ifnum \lastpenalty=10000 \else + \advance\envskipamount by \parskip + \endgraf + \ifdim\lastskip<\envskipamount + \removelastskip + % it's not a good place to break if the last penalty was \nobreak + % or better ... + \ifnum\lastpenalty<10000 \penalty-50 \fi + \vskip\envskipamount + \fi + \fi +}} + +\let\afterenvbreak = \aboveenvbreak + +% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will +% also clear it, so that its embedded environments do the narrowing again. +\let\nonarrowing=\relax + +% @cartouche ... @end cartouche: draw rectangle w/rounded corners around +% environment contents. +\font\circle=lcircle10 +\newdimen\circthick +\newdimen\cartouter\newdimen\cartinner +\newskip\normbskip\newskip\normpskip\newskip\normlskip +\circthick=\fontdimen8\circle +% +\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth +\def\ctr{{\hskip 6pt\circle\char'010}} +\def\cbl{{\circle\char'012\hskip -6pt}} +\def\cbr{{\hskip 6pt\circle\char'011}} +\def\carttop{\hbox to \cartouter{\hskip\lskip + \ctl\leaders\hrule height\circthick\hfil\ctr + \hskip\rskip}} +\def\cartbot{\hbox to \cartouter{\hskip\lskip + \cbl\leaders\hrule height\circthick\hfil\cbr + \hskip\rskip}} +% +\newskip\lskip\newskip\rskip + +\envdef\cartouche{% + \ifhmode\par\fi % can't be in the midst of a paragraph. + \startsavinginserts + \lskip=\leftskip \rskip=\rightskip + \leftskip=0pt\rightskip=0pt % we want these *outside*. + \cartinner=\hsize \advance\cartinner by-\lskip + \advance\cartinner by-\rskip + \cartouter=\hsize + \advance\cartouter by 18.4pt % allow for 3pt kerns on either + % side, and for 6pt waste from + % each corner char, and rule thickness + \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip + % Flag to tell @lisp, etc., not to narrow margin. + \let\nonarrowing = t% + % + % If this cartouche directly follows a sectioning command, we need the + % \parskip glue (backspaced over by default) or the cartouche can + % collide with the section heading. + \ifnum\lastpenalty>10000 \vskip\parskip \fi + % + \vbox\bgroup + \baselineskip=0pt\parskip=0pt\lineskip=0pt + \carttop + \hbox\bgroup + \hskip\lskip + \vrule\kern3pt + \vbox\bgroup + \kern3pt + \hsize=\cartinner + \baselineskip=\normbskip + \lineskip=\normlskip + \parskip=\normpskip + \vskip -\parskip + \comment % For explanation, see the end of def\group. +} +\def\Ecartouche{% + \ifhmode\par\fi + \kern3pt + \egroup + \kern3pt\vrule + \hskip\rskip + \egroup + \cartbot + \egroup + \checkinserts +} + + +% This macro is called at the beginning of all the @example variants, +% inside a group. +\newdimen\nonfillparindent +\def\nonfillstart{% + \aboveenvbreak + \hfuzz = 12pt % Don't be fussy + \sepspaces % Make spaces be word-separators rather than space tokens. + \let\par = \lisppar % don't ignore blank lines + \obeylines % each line of input is a line of output + \parskip = 0pt + % Turn off paragraph indentation but redefine \indent to emulate + % the normal \indent. + \nonfillparindent=\parindent + \parindent = 0pt + \let\indent\nonfillindent + % + \emergencystretch = 0pt % don't try to avoid overfull boxes + \ifx\nonarrowing\relax + \advance \leftskip by \lispnarrowing + \exdentamount=\lispnarrowing + \else + \let\nonarrowing = \relax + \fi + \let\exdent=\nofillexdent +} + +\begingroup +\obeyspaces +% We want to swallow spaces (but not other tokens) after the fake +% @indent in our nonfill-environments, where spaces are normally +% active and set to @tie, resulting in them not being ignored after +% @indent. +\gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}% +\gdef\nonfillindentcheck{% +\ifx\temp % +\expandafter\nonfillindentgobble% +\else% +\leavevmode\nonfillindentbox% +\fi% +}% +\endgroup +\def\nonfillindentgobble#1{\nonfillindent} +\def\nonfillindentbox{\hbox to \nonfillparindent{\hss}} + +% If you want all examples etc. small: @set dispenvsize small. +% If you want even small examples the full size: @set dispenvsize nosmall. +% This affects the following displayed environments: +% @example, @display, @format, @lisp +% +\def\smallword{small} +\def\nosmallword{nosmall} +\let\SETdispenvsize\relax +\def\setnormaldispenv{% + \ifx\SETdispenvsize\smallword + % end paragraph for sake of leading, in case document has no blank + % line. This is redundant with what happens in \aboveenvbreak, but + % we need to do it before changing the fonts, and it's inconvenient + % to change the fonts afterward. + \ifnum \lastpenalty=10000 \else \endgraf \fi + \smallexamplefonts \rm + \fi +} +\def\setsmalldispenv{% + \ifx\SETdispenvsize\nosmallword + \else + \ifnum \lastpenalty=10000 \else \endgraf \fi + \smallexamplefonts \rm + \fi +} + +% We often define two environments, @foo and @smallfoo. +% Let's do it in one command. #1 is the env name, #2 the definition. +\def\makedispenvdef#1#2{% + \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}% + \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}% + \expandafter\let\csname E#1\endcsname \afterenvbreak + \expandafter\let\csname Esmall#1\endcsname \afterenvbreak +} + +% Define two environment synonyms (#1 and #2) for an environment. +\def\maketwodispenvdef#1#2#3{% + \makedispenvdef{#1}{#3}% + \makedispenvdef{#2}{#3}% +} +% +% @lisp: indented, narrowed, typewriter font; +% @example: same as @lisp. +% +% @smallexample and @smalllisp: use smaller fonts. +% Originally contributed by Pavel@xerox. +% +\maketwodispenvdef{lisp}{example}{% + \nonfillstart + \tt\setupmarkupstyle{example}% + \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. + \gobble % eat return +} +% @display/@smalldisplay: same as @lisp except keep current font. +% +\makedispenvdef{display}{% + \nonfillstart + \gobble +} + +% @format/@smallformat: same as @display except don't narrow margins. +% +\makedispenvdef{format}{% + \let\nonarrowing = t% + \nonfillstart + \gobble +} + +% @flushleft: same as @format, but doesn't obey \SETdispenvsize. +\envdef\flushleft{% + \let\nonarrowing = t% + \nonfillstart + \gobble +} +\let\Eflushleft = \afterenvbreak + +% @flushright. +% +\envdef\flushright{% + \let\nonarrowing = t% + \nonfillstart + \advance\leftskip by 0pt plus 1fill\relax + \gobble +} +\let\Eflushright = \afterenvbreak + + +% @raggedright does more-or-less normal line breaking but no right +% justification. From plain.tex. +\envdef\raggedright{% + \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax +} +\let\Eraggedright\par + +\envdef\raggedleft{% + \parindent=0pt \leftskip0pt plus2em + \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt + \hbadness=10000 % Last line will usually be underfull, so turn off + % badness reporting. +} +\let\Eraggedleft\par + +\envdef\raggedcenter{% + \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em + \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt + \hbadness=10000 % Last line will usually be underfull, so turn off + % badness reporting. +} +\let\Eraggedcenter\par + + +% @quotation does normal linebreaking (hence we can't use \nonfillstart) +% and narrows the margins. We keep \parskip nonzero in general, since +% we're doing normal filling. So, when using \aboveenvbreak and +% \afterenvbreak, temporarily make \parskip 0. +% +\makedispenvdef{quotation}{\quotationstart} +% +\def\quotationstart{% + {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip + \parindent=0pt + % + % @cartouche defines \nonarrowing to inhibit narrowing at next level down. + \ifx\nonarrowing\relax + \advance\leftskip by \lispnarrowing + \advance\rightskip by \lispnarrowing + \exdentamount = \lispnarrowing + \else + \let\nonarrowing = \relax + \fi + \parsearg\quotationlabel +} + +% We have retained a nonzero parskip for the environment, since we're +% doing normal filling. +% +\def\Equotation{% + \par + \ifx\quotationauthor\thisisundefined\else + % indent a bit. + \leftline{\kern 2\leftskip \sl ---\quotationauthor}% + \fi + {\parskip=0pt \afterenvbreak}% +} +\def\Esmallquotation{\Equotation} + +% If we're given an argument, typeset it in bold with a colon after. +\def\quotationlabel#1{% + \def\temp{#1}% + \ifx\temp\empty \else + {\bf #1: }% + \fi +} + + +% LaTeX-like @verbatim...@end verbatim and @verb{...} +% If we want to allow any as delimiter, +% we need the curly braces so that makeinfo sees the @verb command, eg: +% `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org +% +% [Knuth]: Donald Ervin Knuth, 1996. The TeXbook. +% +% [Knuth] p.344; only we need to do the other characters Texinfo sets +% active too. Otherwise, they get lost as the first character on a +% verbatim line. +\def\dospecials{% + \do\ \do\\\do\{\do\}\do\$\do\&% + \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~% + \do\<\do\>\do\|\do\@\do+\do\"% + % Don't do the quotes -- if we do, @set txicodequoteundirected and + % @set txicodequotebacktick will not have effect on @verb and + % @verbatim, and ?` and !` ligatures won't get disabled. + %\do\`\do\'% +} +% +% [Knuth] p. 380 +\def\uncatcodespecials{% + \def\do##1{\catcode`##1=\other}\dospecials} +% +% Setup for the @verb command. +% +% Eight spaces for a tab +\begingroup + \catcode`\^^I=\active + \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }} +\endgroup +% +\def\setupverb{% + \tt % easiest (and conventionally used) font for verbatim + \def\par{\leavevmode\endgraf}% + \setupmarkupstyle{verb}% + \tabeightspaces + % Respect line breaks, + % print special symbols as themselves, and + % make each space count + % must do in this order: + \obeylines \uncatcodespecials \sepspaces +} + +% Setup for the @verbatim environment +% +% Real tab expansion. +\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount +% +% We typeset each line of the verbatim in an \hbox, so we can handle +% tabs. The \global is in case the verbatim line starts with an accent, +% or some other command that starts with a begin-group. Otherwise, the +% entire \verbbox would disappear at the corresponding end-group, before +% it is typeset. Meanwhile, we can't have nested verbatim commands +% (can we?), so the \global won't be overwriting itself. +\newbox\verbbox +\def\starttabbox{\global\setbox\verbbox=\hbox\bgroup} +% +\begingroup + \catcode`\^^I=\active + \gdef\tabexpand{% + \catcode`\^^I=\active + \def^^I{\leavevmode\egroup + \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab + \divide\dimen\verbbox by\tabw + \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw + \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw + \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox + }% + } +\endgroup + +% start the verbatim environment. +\def\setupverbatim{% + \let\nonarrowing = t% + \nonfillstart + \tt % easiest (and conventionally used) font for verbatim + % The \leavevmode here is for blank lines. Otherwise, we would + % never \starttabox and the \egroup would end verbatim mode. + \def\par{\leavevmode\egroup\box\verbbox\endgraf}% + \tabexpand + \setupmarkupstyle{verbatim}% + % Respect line breaks, + % print special symbols as themselves, and + % make each space count. + % Must do in this order: + \obeylines \uncatcodespecials \sepspaces + \everypar{\starttabbox}% +} + +% Do the @verb magic: verbatim text is quoted by unique +% delimiter characters. Before first delimiter expect a +% right brace, after last delimiter expect closing brace: +% +% \def\doverb'{'#1'}'{#1} +% +% [Knuth] p. 382; only eat outer {} +\begingroup + \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other + \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next] +\endgroup +% +\def\verb{\begingroup\setupverb\doverb} +% +% +% Do the @verbatim magic: define the macro \doverbatim so that +% the (first) argument ends when '@end verbatim' is reached, ie: +% +% \def\doverbatim#1@end verbatim{#1} +% +% For Texinfo it's a lot easier than for LaTeX, +% because texinfo's \verbatim doesn't stop at '\end{verbatim}': +% we need not redefine '\', '{' and '}'. +% +% Inspired by LaTeX's verbatim command set [latex.ltx] +% +\begingroup + \catcode`\ =\active + \obeylines % + % ignore everything up to the first ^^M, that's the newline at the end + % of the @verbatim input line itself. Otherwise we get an extra blank + % line in the output. + \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}% + % We really want {...\end verbatim} in the body of the macro, but + % without the active space; thus we have to use \xdef and \gobble. +\endgroup +% +\envdef\verbatim{% + \setupverbatim\doverbatim +} +\let\Everbatim = \afterenvbreak + + +% @verbatiminclude FILE - insert text of file in verbatim environment. +% +\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude} +% +\def\doverbatiminclude#1{% + {% + \makevalueexpandable + \setupverbatim + \indexnofonts % Allow `@@' and other weird things in file names. + \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}% + \input #1 + \afterenvbreak + }% +} + +% @copying ... @end copying. +% Save the text away for @insertcopying later. +% +% We save the uninterpreted tokens, rather than creating a box. +% Saving the text in a box would be much easier, but then all the +% typesetting commands (@smallbook, font changes, etc.) have to be done +% beforehand -- and a) we want @copying to be done first in the source +% file; b) letting users define the frontmatter in as flexible order as +% possible is very desirable. +% +\def\copying{\checkenv{}\begingroup\scanargctxt\docopying} +\def\docopying#1@end copying{\endgroup\def\copyingtext{#1}} +% +\def\insertcopying{% + \begingroup + \parindent = 0pt % paragraph indentation looks wrong on title page + \scanexp\copyingtext + \endgroup +} + + +\message{defuns,} +% @defun etc. + +\newskip\defbodyindent \defbodyindent=.4in +\newskip\defargsindent \defargsindent=50pt +\newskip\deflastargmargin \deflastargmargin=18pt +\newcount\defunpenalty + +% Start the processing of @deffn: +\def\startdefun{% + \ifnum\lastpenalty<10000 + \medbreak + \defunpenalty=10003 % Will keep this @deffn together with the + % following @def command, see below. + \else + % If there are two @def commands in a row, we'll have a \nobreak, + % which is there to keep the function description together with its + % header. But if there's nothing but headers, we need to allow a + % break somewhere. Check specifically for penalty 10002, inserted + % by \printdefunline, instead of 10000, since the sectioning + % commands also insert a nobreak penalty, and we don't want to allow + % a break between a section heading and a defun. + % + % As a further refinement, we avoid "club" headers by signalling + % with penalty of 10003 after the very first @deffn in the + % sequence (see above), and penalty of 10002 after any following + % @def command. + \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi + % + % Similarly, after a section heading, do not allow a break. + % But do insert the glue. + \medskip % preceded by discardable penalty, so not a breakpoint + \fi + % + \parindent=0in + \advance\leftskip by \defbodyindent + \exdentamount=\defbodyindent +} + +\def\dodefunx#1{% + % First, check whether we are in the right environment: + \checkenv#1% + % + % As above, allow line break if we have multiple x headers in a row. + % It's not a great place, though. + \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi + % + % And now, it's time to reuse the body of the original defun: + \expandafter\gobbledefun#1% +} +\def\gobbledefun#1\startdefun{} + +% \printdefunline \deffnheader{text} +% +\def\printdefunline#1#2{% + \begingroup + % call \deffnheader: + #1#2 \endheader + % common ending: + \interlinepenalty = 10000 + \advance\rightskip by 0pt plus 1fil\relax + \endgraf + \nobreak\vskip -\parskip + \penalty\defunpenalty % signal to \startdefun and \dodefunx + % Some of the @defun-type tags do not enable magic parentheses, + % rendering the following check redundant. But we don't optimize. + \checkparencounts + \endgroup +} + +\def\Edefun{\endgraf\medbreak} + +% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn; +% the only thing remaining is to define \deffnheader. +% +\def\makedefun#1{% + \expandafter\let\csname E#1\endcsname = \Edefun + \edef\temp{\noexpand\domakedefun + \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}% + \temp +} + +% \domakedefun \deffn \deffnx \deffnheader +% +% Define \deffn and \deffnx, without parameters. +% \deffnheader has to be defined explicitly. +% +\def\domakedefun#1#2#3{% + \envdef#1{% + \startdefun + \doingtypefnfalse % distinguish typed functions from all else + \parseargusing\activeparens{\printdefunline#3}% + }% + \def#2{\dodefunx#1}% + \def#3% +} + +\newif\ifdoingtypefn % doing typed function? +\newif\ifrettypeownline % typeset return type on its own line? + +% @deftypefnnewline on|off says whether the return type of typed functions +% are printed on their own line. This affects @deftypefn, @deftypefun, +% @deftypeop, and @deftypemethod. +% +\parseargdef\deftypefnnewline{% + \def\temp{#1}% + \ifx\temp\onword + \expandafter\let\csname SETtxideftypefnnl\endcsname + = \empty + \else\ifx\temp\offword + \expandafter\let\csname SETtxideftypefnnl\endcsname + = \relax + \else + \errhelp = \EMsimple + \errmessage{Unknown @txideftypefnnl value `\temp', + must be on|off}% + \fi\fi +} + +% Untyped functions: + +% @deffn category name args +\makedefun{deffn}{\deffngeneral{}} + +% @deffn category class name args +\makedefun{defop}#1 {\defopon{#1\ \putwordon}} + +% \defopon {category on}class name args +\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } + +% \deffngeneral {subind}category name args +% +\def\deffngeneral#1#2 #3 #4\endheader{% + % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}. + \dosubind{fn}{\code{#3}}{#1}% + \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}% +} + +% Typed functions: + +% @deftypefn category type name args +\makedefun{deftypefn}{\deftypefngeneral{}} + +% @deftypeop category class type name args +\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}} + +% \deftypeopon {category on}class type name args +\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } + +% \deftypefngeneral {subind}category type name args +% +\def\deftypefngeneral#1#2 #3 #4 #5\endheader{% + \dosubind{fn}{\code{#4}}{#1}% + \doingtypefntrue + \defname{#2}{#3}{#4}\defunargs{#5\unskip}% +} + +% Typed variables: + +% @deftypevr category type var args +\makedefun{deftypevr}{\deftypecvgeneral{}} + +% @deftypecv category class type var args +\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}} + +% \deftypecvof {category of}class type var args +\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} } + +% \deftypecvgeneral {subind}category type var args +% +\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{% + \dosubind{vr}{\code{#4}}{#1}% + \defname{#2}{#3}{#4}\defunargs{#5\unskip}% +} + +% Untyped variables: + +% @defvr category var args +\makedefun{defvr}#1 {\deftypevrheader{#1} {} } + +% @defcv category class var args +\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}} + +% \defcvof {category of}class var args +\def\defcvof#1#2 {\deftypecvof{#1}#2 {} } + +% Types: + +% @deftp category name args +\makedefun{deftp}#1 #2 #3\endheader{% + \doind{tp}{\code{#2}}% + \defname{#1}{}{#2}\defunargs{#3\unskip}% +} + +% Remaining @defun-like shortcuts: +\makedefun{defun}{\deffnheader{\putwordDeffunc} } +\makedefun{defmac}{\deffnheader{\putwordDefmac} } +\makedefun{defspec}{\deffnheader{\putwordDefspec} } +\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} } +\makedefun{defvar}{\defvrheader{\putwordDefvar} } +\makedefun{defopt}{\defvrheader{\putwordDefopt} } +\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} } +\makedefun{defmethod}{\defopon\putwordMethodon} +\makedefun{deftypemethod}{\deftypeopon\putwordMethodon} +\makedefun{defivar}{\defcvof\putwordInstanceVariableof} +\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof} + +% \defname, which formats the name of the @def (not the args). +% #1 is the category, such as "Function". +% #2 is the return type, if any. +% #3 is the function name. +% +% We are followed by (but not passed) the arguments, if any. +% +\def\defname#1#2#3{% + \par + % Get the values of \leftskip and \rightskip as they were outside the @def... + \advance\leftskip by -\defbodyindent + % + % Determine if we are typesetting the return type of a typed function + % on a line by itself. + \rettypeownlinefalse + \ifdoingtypefn % doing a typed function specifically? + % then check user option for putting return type on its own line: + \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else + \rettypeownlinetrue + \fi + \fi + % + % How we'll format the category name. Putting it in brackets helps + % distinguish it from the body text that may end up on the next line + % just below it. + \def\temp{#1}% + \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi} + % + % Figure out line sizes for the paragraph shape. We'll always have at + % least two. + \tempnum = 2 + % + % The first line needs space for \box0; but if \rightskip is nonzero, + % we need only space for the part of \box0 which exceeds it: + \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip + % + % If doing a return type on its own line, we'll have another line. + \ifrettypeownline + \advance\tempnum by 1 + \def\maybeshapeline{0in \hsize}% + \else + \def\maybeshapeline{}% + \fi + % + % The continuations: + \dimen2=\hsize \advance\dimen2 by -\defargsindent + % + % The final paragraph shape: + \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2 + % + % Put the category name at the right margin. + \noindent + \hbox to 0pt{% + \hfil\box0 \kern-\hsize + % \hsize has to be shortened this way: + \kern\leftskip + % Intentionally do not respect \rightskip, since we need the space. + }% + % + % Allow all lines to be underfull without complaint: + \tolerance=10000 \hbadness=10000 + \exdentamount=\defbodyindent + {% + % defun fonts. We use typewriter by default (used to be bold) because: + % . we're printing identifiers, they should be in tt in principle. + % . in languages with many accents, such as Czech or French, it's + % common to leave accents off identifiers. The result looks ok in + % tt, but exceedingly strange in rm. + % . we don't want -- and --- to be treated as ligatures. + % . this still does not fix the ?` and !` ligatures, but so far no + % one has made identifiers using them :). + \df \tt + \def\temp{#2}% text of the return type + \ifx\temp\empty\else + \tclose{\temp}% typeset the return type + \ifrettypeownline + % put return type on its own line; prohibit line break following: + \hfil\vadjust{\nobreak}\break + \else + \space % type on same line, so just followed by a space + \fi + \fi % no return type + #3% output function name + }% + {\rm\enskip}% hskip 0.5 em of \tenrm + % + \boldbrax + % arguments will be output next, if any. +} + +% Print arguments in slanted roman (not ttsl), inconsistently with using +% tt for the name. This is because literal text is sometimes needed in +% the argument list (groff manual), and ttsl and tt are not very +% distinguishable. Prevent hyphenation at `-' chars. +% +\def\defunargs#1{% + % use sl by default (not ttsl), + % tt for the names. + \df \sl \hyphenchar\font=0 + % + % On the other hand, if an argument has two dashes (for instance), we + % want a way to get ttsl. Let's try @var for that. + \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}% + #1% + \sl\hyphenchar\font=45 +} + +% We want ()&[] to print specially on the defun line. +% +\def\activeparens{% + \catcode`\(=\active \catcode`\)=\active + \catcode`\[=\active \catcode`\]=\active + \catcode`\&=\active +} + +% Make control sequences which act like normal parenthesis chars. +\let\lparen = ( \let\rparen = ) + +% Be sure that we always have a definition for `(', etc. For example, +% if the fn name has parens in it, \boldbrax will not be in effect yet, +% so TeX would otherwise complain about undefined control sequence. +{ + \activeparens + \global\let(=\lparen \global\let)=\rparen + \global\let[=\lbrack \global\let]=\rbrack + \global\let& = \& + + \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} + \gdef\magicamp{\let&=\amprm} +} + +\newcount\parencount + +% If we encounter &foo, then turn on ()-hacking afterwards +\newif\ifampseen +\def\amprm#1 {\ampseentrue{\bf\ }} + +\def\parenfont{% + \ifampseen + % At the first level, print parens in roman, + % otherwise use the default font. + \ifnum \parencount=1 \rm \fi + \else + % The \sf parens (in \boldbrax) actually are a little bolder than + % the contained text. This is especially needed for [ and ] . + \sf + \fi +} +\def\infirstlevel#1{% + \ifampseen + \ifnum\parencount=1 + #1% + \fi + \fi +} +\def\bfafterword#1 {#1 \bf} + +\def\opnr{% + \global\advance\parencount by 1 + {\parenfont(}% + \infirstlevel \bfafterword +} +\def\clnr{% + {\parenfont)}% + \infirstlevel \sl + \global\advance\parencount by -1 +} + +\newcount\brackcount +\def\lbrb{% + \global\advance\brackcount by 1 + {\bf[}% +} +\def\rbrb{% + {\bf]}% + \global\advance\brackcount by -1 +} + +\def\checkparencounts{% + \ifnum\parencount=0 \else \badparencount \fi + \ifnum\brackcount=0 \else \badbrackcount \fi +} +% these should not use \errmessage; the glibc manual, at least, actually +% has such constructs (when documenting function pointers). +\def\badparencount{% + \message{Warning: unbalanced parentheses in @def...}% + \global\parencount=0 +} +\def\badbrackcount{% + \message{Warning: unbalanced square brackets in @def...}% + \global\brackcount=0 +} + + +\message{macros,} +% @macro. + +% To do this right we need a feature of e-TeX, \scantokens, +% which we arrange to emulate with a temporary file in ordinary TeX. +\ifx\eTeXversion\thisisundefined + \newwrite\macscribble + \def\scantokens#1{% + \toks0={#1}% + \immediate\openout\macscribble=\jobname.tmp + \immediate\write\macscribble{\the\toks0}% + \immediate\closeout\macscribble + \input \jobname.tmp + } +\fi + +\def\scanmacro#1{\begingroup + \newlinechar`\^^M + \let\xeatspaces\eatspaces + % + % Undo catcode changes of \startcontents and \doprintindex + % When called from @insertcopying or (short)caption, we need active + % backslash to get it printed correctly. Previously, we had + % \catcode`\\=\other instead. We'll see whether a problem appears + % with macro expansion. --kasal, 19aug04 + \catcode`\@=0 \catcode`\\=\active \escapechar=`\@ + % + % ... and for \example: + \spaceisspace + % + % The \empty here causes a following catcode 5 newline to be eaten as + % part of reading whitespace after a control sequence. It does not + % eat a catcode 13 newline. There's no good way to handle the two + % cases (untried: maybe e-TeX's \everyeof could help, though plain TeX + % would then have different behavior). See the Macro Details node in + % the manual for the workaround we recommend for macros and + % line-oriented commands. + % + \scantokens{#1\empty}% +\endgroup} + +\def\scanexp#1{% + \edef\temp{\noexpand\scanmacro{#1}}% + \temp +} + +\newcount\paramno % Count of parameters +\newtoks\macname % Macro name +\newif\ifrecursive % Is it recursive? + +% List of all defined macros in the form +% \definedummyword\macro1\definedummyword\macro2... +% Currently is also contains all @aliases; the list can be split +% if there is a need. +\def\macrolist{} + +% Add the macro to \macrolist +\def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname} +\def\addtomacrolistxxx#1{% + \toks0 = \expandafter{\macrolist\definedummyword#1}% + \xdef\macrolist{\the\toks0}% +} + +% Utility routines. +% This does \let #1 = #2, with \csnames; that is, +% \let \csname#1\endcsname = \csname#2\endcsname +% (except of course we have to play expansion games). +% +\def\cslet#1#2{% + \expandafter\let + \csname#1\expandafter\endcsname + \csname#2\endcsname +} + +% Trim leading and trailing spaces off a string. +% Concepts from aro-bend problem 15 (see CTAN). +{\catcode`\@=11 +\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }} +\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@} +\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @} +\def\unbrace#1{#1} +\unbrace{\gdef\trim@@@ #1 } #2@{#1} +} + +% Trim a single trailing ^^M off a string. +{\catcode`\^^M=\other \catcode`\Q=3% +\gdef\eatcr #1{\eatcra #1Q^^MQ}% +\gdef\eatcra#1^^MQ{\eatcrb#1Q}% +\gdef\eatcrb#1Q#2Q{#1}% +} + +% Macro bodies are absorbed as an argument in a context where +% all characters are catcode 10, 11 or 12, except \ which is active +% (as in normal texinfo). It is necessary to change the definition of \ +% to recognize macro arguments; this is the job of \mbodybackslash. +% +% Non-ASCII encodings make 8-bit characters active, so un-activate +% them to avoid their expansion. Must do this non-globally, to +% confine the change to the current group. +% +% It's necessary to have hard CRs when the macro is executed. This is +% done by making ^^M (\endlinechar) catcode 12 when reading the macro +% body, and then making it the \newlinechar in \scanmacro. +% +\def\scanctxt{% used as subroutine + \catcode`\"=\other + \catcode`\+=\other + \catcode`\<=\other + \catcode`\>=\other + \catcode`\@=\other + \catcode`\^=\other + \catcode`\_=\other + \catcode`\|=\other + \catcode`\~=\other + \ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi +} + +\def\scanargctxt{% used for copying and captions, not macros. + \scanctxt + \catcode`\\=\other + \catcode`\^^M=\other +} + +\def\macrobodyctxt{% used for @macro definitions + \scanctxt + \catcode`\{=\other + \catcode`\}=\other + \catcode`\^^M=\other + \usembodybackslash +} + +\def\macroargctxt{% used when scanning invocations + \scanctxt + \catcode`\\=0 +} +% why catcode 0 for \ in the above? To recognize \\ \{ \} as "escapes" +% for the single characters \ { }. Thus, we end up with the "commands" +% that would be written @\ @{ @} in a Texinfo document. +% +% We already have @{ and @}. For @\, we define it here, and only for +% this purpose, to produce a typewriter backslash (so, the @\ that we +% define for @math can't be used with @macro calls): +% +\def\\{\normalbackslash}% +% +% We would like to do this for \, too, since that is what makeinfo does. +% But it is not possible, because Texinfo already has a command @, for a +% cedilla accent. Documents must use @comma{} instead. +% +% \anythingelse will almost certainly be an error of some kind. + + +% \mbodybackslash is the definition of \ in @macro bodies. +% It maps \foo\ => \csname macarg.foo\endcsname => #N +% where N is the macro parameter number. +% We define \csname macarg.\endcsname to be \realbackslash, so +% \\ in macro replacement text gets you a backslash. +% +{\catcode`@=0 @catcode`@\=@active + @gdef@usembodybackslash{@let\=@mbodybackslash} + @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} +} +\expandafter\def\csname macarg.\endcsname{\realbackslash} + +\def\margbackslash#1{\char`\#1 } + +\def\macro{\recursivefalse\parsearg\macroxxx} +\def\rmacro{\recursivetrue\parsearg\macroxxx} + +\def\macroxxx#1{% + \getargs{#1}% now \macname is the macname and \argl the arglist + \ifx\argl\empty % no arguments + \paramno=0\relax + \else + \expandafter\parsemargdef \argl;% + \if\paramno>256\relax + \ifx\eTeXversion\thisisundefined + \errhelp = \EMsimple + \errmessage{You need eTeX to compile a file with macros with more than 256 arguments} + \fi + \fi + \fi + \if1\csname ismacro.\the\macname\endcsname + \message{Warning: redefining \the\macname}% + \else + \expandafter\ifx\csname \the\macname\endcsname \relax + \else \errmessage{Macro name \the\macname\space already defined}\fi + \global\cslet{macsave.\the\macname}{\the\macname}% + \global\expandafter\let\csname ismacro.\the\macname\endcsname=1% + \addtomacrolist{\the\macname}% + \fi + \begingroup \macrobodyctxt + \ifrecursive \expandafter\parsermacbody + \else \expandafter\parsemacbody + \fi} + +\parseargdef\unmacro{% + \if1\csname ismacro.#1\endcsname + \global\cslet{#1}{macsave.#1}% + \global\expandafter\let \csname ismacro.#1\endcsname=0% + % Remove the macro name from \macrolist: + \begingroup + \expandafter\let\csname#1\endcsname \relax + \let\definedummyword\unmacrodo + \xdef\macrolist{\macrolist}% + \endgroup + \else + \errmessage{Macro #1 not defined}% + \fi +} + +% Called by \do from \dounmacro on each macro. The idea is to omit any +% macro definitions that have been changed to \relax. +% +\def\unmacrodo#1{% + \ifx #1\relax + % remove this + \else + \noexpand\definedummyword \noexpand#1% + \fi +} + +% This makes use of the obscure feature that if the last token of a +% is #, then the preceding argument is delimited by +% an opening brace, and that opening brace is not consumed. +\def\getargs#1{\getargsxxx#1{}} +\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} +\def\getmacname#1 #2\relax{\macname={#1}} +\def\getmacargs#1{\def\argl{#1}} + +% For macro processing make @ a letter so that we can make Texinfo private macro names. +\edef\texiatcatcode{\the\catcode`\@} +\catcode `@=11\relax + +% Parse the optional {params} list. Set up \paramno and \paramlist +% so \defmacro knows what to do. Define \macarg.BLAH for each BLAH +% in the params list to some hook where the argument si to be expanded. If +% there are less than 10 arguments that hook is to be replaced by ##N where N +% is the position in that list, that is to say the macro arguments are to be +% defined `a la TeX in the macro body. +% +% That gets used by \mbodybackslash (above). +% +% We need to get `macro parameter char #' into several definitions. +% The technique used is stolen from LaTeX: let \hash be something +% unexpandable, insert that wherever you need a #, and then redefine +% it to # just before using the token list produced. +% +% The same technique is used to protect \eatspaces till just before +% the macro is used. +% +% If there are 10 or more arguments, a different technique is used, where the +% hook remains in the body, and when macro is to be expanded the body is +% processed again to replace the arguments. +% +% In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the +% argument N value and then \edef the body (nothing else will expand because of +% the catcode regime underwhich the body was input). +% +% If you compile with TeX (not eTeX), and you have macros with 10 or more +% arguments, you need that no macro has more than 256 arguments, otherwise an +% error is produced. +\def\parsemargdef#1;{% + \paramno=0\def\paramlist{}% + \let\hash\relax + \let\xeatspaces\relax + \parsemargdefxxx#1,;,% + % In case that there are 10 or more arguments we parse again the arguments + % list to set new definitions for the \macarg.BLAH macros corresponding to + % each BLAH argument. It was anyhow needed to parse already once this list + % in order to count the arguments, and as macros with at most 9 arguments + % are by far more frequent than macro with 10 or more arguments, defining + % twice the \macarg.BLAH macros does not cost too much processing power. + \ifnum\paramno<10\relax\else + \paramno0\relax + \parsemmanyargdef@@#1,;,% 10 or more arguments + \fi +} +\def\parsemargdefxxx#1,{% + \if#1;\let\next=\relax + \else \let\next=\parsemargdefxxx + \advance\paramno by 1 + \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname + {\xeatspaces{\hash\the\paramno}}% + \edef\paramlist{\paramlist\hash\the\paramno,}% + \fi\next} + +\def\parsemmanyargdef@@#1,{% + \if#1;\let\next=\relax + \else + \let\next=\parsemmanyargdef@@ + \edef\tempb{\eatspaces{#1}}% + \expandafter\def\expandafter\tempa + \expandafter{\csname macarg.\tempb\endcsname}% + % Note that we need some extra \noexpand\noexpand, this is because we + % don't want \the to be expanded in the \parsermacbody as it uses an + % \xdef . + \expandafter\edef\tempa + {\noexpand\noexpand\noexpand\the\toks\the\paramno}% + \advance\paramno by 1\relax + \fi\next} + +% These two commands read recursive and nonrecursive macro bodies. +% (They're different since rec and nonrec macros end differently.) +% + +\catcode `\@\texiatcatcode +\long\def\parsemacbody#1@end macro% +{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% +\long\def\parsermacbody#1@end rmacro% +{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% +\catcode `\@=11\relax + +\let\endargs@\relax +\let\nil@\relax +\def\nilm@{\nil@}% +\long\def\nillm@{\nil@}% + +% This macro is expanded during the Texinfo macro expansion, not during its +% definition. It gets all the arguments values and assigns them to macros +% macarg.ARGNAME +% +% #1 is the macro name +% #2 is the list of argument names +% #3 is the list of argument values +\def\getargvals@#1#2#3{% + \def\macargdeflist@{}% + \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion. + \def\paramlist{#2,\nil@}% + \def\macroname{#1}% + \begingroup + \macroargctxt + \def\argvaluelist{#3,\nil@}% + \def\@tempa{#3}% + \ifx\@tempa\empty + \setemptyargvalues@ + \else + \getargvals@@ + \fi +} + +% +\def\getargvals@@{% + \ifx\paramlist\nilm@ + % Some sanity check needed here that \argvaluelist is also empty. + \ifx\argvaluelist\nillm@ + \else + \errhelp = \EMsimple + \errmessage{Too many arguments in macro `\macroname'!}% + \fi + \let\next\macargexpandinbody@ + \else + \ifx\argvaluelist\nillm@ + % No more arguments values passed to macro. Set remaining named-arg + % macros to empty. + \let\next\setemptyargvalues@ + \else + % pop current arg name into \@tempb + \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}% + \expandafter\@tempa\expandafter{\paramlist}% + % pop current argument value into \@tempc + \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}% + \expandafter\@tempa\expandafter{\argvaluelist}% + % Here \@tempb is the current arg name and \@tempc is the current arg value. + % First place the new argument macro definition into \@tempd + \expandafter\macname\expandafter{\@tempc}% + \expandafter\let\csname macarg.\@tempb\endcsname\relax + \expandafter\def\expandafter\@tempe\expandafter{% + \csname macarg.\@tempb\endcsname}% + \edef\@tempd{\long\def\@tempe{\the\macname}}% + \push@\@tempd\macargdeflist@ + \let\next\getargvals@@ + \fi + \fi + \next +} + +\def\push@#1#2{% + \expandafter\expandafter\expandafter\def + \expandafter\expandafter\expandafter#2% + \expandafter\expandafter\expandafter{% + \expandafter#1#2}% +} + +% Replace arguments by their values in the macro body, and place the result +% in macro \@tempa +\def\macvalstoargs@{% + % To do this we use the property that token registers that are \the'ed + % within an \edef expand only once. So we are going to place all argument + % values into respective token registers. + % + % First we save the token context, and initialize argument numbering. + \begingroup + \paramno0\relax + % Then, for each argument number #N, we place the corresponding argument + % value into a new token list register \toks#N + \expandafter\putargsintokens@\saveparamlist@,;,% + % Then, we expand the body so that argument are replaced by their + % values. The trick for values not to be expanded themselves is that they + % are within tokens and that tokens expand only once in an \edef . + \edef\@tempc{\csname mac.\macroname .body\endcsname}% + % Now we restore the token stack pointer to free the token list registers + % which we have used, but we make sure that expanded body is saved after + % group. + \expandafter + \endgroup + \expandafter\def\expandafter\@tempa\expandafter{\@tempc}% + } + +\def\macargexpandinbody@{% + %% Define the named-macro outside of this group and then close this group. + \expandafter + \endgroup + \macargdeflist@ + % First the replace in body the macro arguments by their values, the result + % is in \@tempa . + \macvalstoargs@ + % Then we point at the \norecurse or \gobble (for recursive) macro value + % with \@tempb . + \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname + % Depending on whether it is recursive or not, we need some tailing + % \egroup . + \ifx\@tempb\gobble + \let\@tempc\relax + \else + \let\@tempc\egroup + \fi + % And now we do the real job: + \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}% + \@tempd +} + +\def\putargsintokens@#1,{% + \if#1;\let\next\relax + \else + \let\next\putargsintokens@ + % First we allocate the new token list register, and give it a temporary + % alias \@tempb . + \toksdef\@tempb\the\paramno + % Then we place the argument value into that token list register. + \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname + \expandafter\@tempb\expandafter{\@tempa}% + \advance\paramno by 1\relax + \fi + \next +} + +% Save the token stack pointer into macro #1 +\def\texisavetoksstackpoint#1{\edef#1{\the\@cclvi}} +% Restore the token stack pointer from number in macro #1 +\def\texirestoretoksstackpoint#1{\expandafter\mathchardef\expandafter\@cclvi#1\relax} +% newtoks that can be used non \outer . +\def\texinonouternewtoks{\alloc@ 5\toks \toksdef \@cclvi} + +% Tailing missing arguments are set to empty +\def\setemptyargvalues@{% + \ifx\paramlist\nilm@ + \let\next\macargexpandinbody@ + \else + \expandafter\setemptyargvaluesparser@\paramlist\endargs@ + \let\next\setemptyargvalues@ + \fi + \next +} + +\def\setemptyargvaluesparser@#1,#2\endargs@{% + \expandafter\def\expandafter\@tempa\expandafter{% + \expandafter\def\csname macarg.#1\endcsname{}}% + \push@\@tempa\macargdeflist@ + \def\paramlist{#2}% +} + +% #1 is the element target macro +% #2 is the list macro +% #3,#4\endargs@ is the list value +\def\pop@#1#2#3,#4\endargs@{% + \def#1{#3}% + \def#2{#4}% +} +\long\def\longpop@#1#2#3,#4\endargs@{% + \long\def#1{#3}% + \long\def#2{#4}% +} + +% This defines a Texinfo @macro. There are eight cases: recursive and +% nonrecursive macros of zero, one, up to nine, and many arguments. +% Much magic with \expandafter here. +% \xdef is used so that macro definitions will survive the file +% they're defined in; @include reads the file inside a group. +% +\def\defmacro{% + \let\hash=##% convert placeholders to macro parameter chars + \ifrecursive + \ifcase\paramno + % 0 + \expandafter\xdef\csname\the\macname\endcsname{% + \noexpand\scanmacro{\temp}}% + \or % 1 + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \noexpand\braceorline + \expandafter\noexpand\csname\the\macname xxx\endcsname}% + \expandafter\xdef\csname\the\macname xxx\endcsname##1{% + \egroup\noexpand\scanmacro{\temp}}% + \else + \ifnum\paramno<10\relax % at most 9 + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \noexpand\csname\the\macname xx\endcsname}% + \expandafter\xdef\csname\the\macname xx\endcsname##1{% + \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% + \expandafter\expandafter + \expandafter\xdef + \expandafter\expandafter + \csname\the\macname xxx\endcsname + \paramlist{\egroup\noexpand\scanmacro{\temp}}% + \else % 10 or more + \expandafter\xdef\csname\the\macname\endcsname{% + \noexpand\getargvals@{\the\macname}{\argl}% + }% + \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp + \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble + \fi + \fi + \else + \ifcase\paramno + % 0 + \expandafter\xdef\csname\the\macname\endcsname{% + \noexpand\norecurse{\the\macname}% + \noexpand\scanmacro{\temp}\egroup}% + \or % 1 + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \noexpand\braceorline + \expandafter\noexpand\csname\the\macname xxx\endcsname}% + \expandafter\xdef\csname\the\macname xxx\endcsname##1{% + \egroup + \noexpand\norecurse{\the\macname}% + \noexpand\scanmacro{\temp}\egroup}% + \else % at most 9 + \ifnum\paramno<10\relax + \expandafter\xdef\csname\the\macname\endcsname{% + \bgroup\noexpand\macroargctxt + \expandafter\noexpand\csname\the\macname xx\endcsname}% + \expandafter\xdef\csname\the\macname xx\endcsname##1{% + \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% + \expandafter\expandafter + \expandafter\xdef + \expandafter\expandafter + \csname\the\macname xxx\endcsname + \paramlist{% + \egroup + \noexpand\norecurse{\the\macname}% + \noexpand\scanmacro{\temp}\egroup}% + \else % 10 or more: + \expandafter\xdef\csname\the\macname\endcsname{% + \noexpand\getargvals@{\the\macname}{\argl}% + }% + \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp + \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\norecurse + \fi + \fi + \fi} + +\catcode `\@\texiatcatcode\relax + +\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} + +% \braceorline decides whether the next nonwhitespace character is a +% {. If so it reads up to the closing }, if not, it reads the whole +% line. Whatever was read is then fed to the next control sequence +% as an argument (by \parsebrace or \parsearg). +% +\def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx} +\def\braceorlinexxx{% + \ifx\nchar\bgroup\else + \expandafter\parsearg + \fi \macnamexxx} + + +% @alias. +% We need some trickery to remove the optional spaces around the equal +% sign. Make them active and then expand them all to nothing. +% +\def\alias{\parseargusing\obeyspaces\aliasxxx} +\def\aliasxxx #1{\aliasyyy#1\relax} +\def\aliasyyy #1=#2\relax{% + {% + \expandafter\let\obeyedspace=\empty + \addtomacrolist{#1}% + \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}% + }% + \next +} + + +\message{cross references,} + +\newwrite\auxfile +\newif\ifhavexrefs % True if xref values are known. +\newif\ifwarnedxrefs % True if we warned once that they aren't known. + +% @inforef is relatively simple. +\def\inforef #1{\inforefzzz #1,,,,**} +\def\inforefzzz #1,#2,#3,#4**{% + \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, + node \samp{\ignorespaces#1{}}} + +% @node's only job in TeX is to define \lastnode, which is used in +% cross-references. The @node line might or might not have commas, and +% might or might not have spaces before the first comma, like: +% @node foo , bar , ... +% We don't want such trailing spaces in the node name. +% +\parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse} +% +% also remove a trailing comma, in case of something like this: +% @node Help-Cross, , , Cross-refs +\def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse} +\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}} + +\let\nwnode=\node +\let\lastnode=\empty + +% Write a cross-reference definition for the current node. #1 is the +% type (Ynumbered, Yappendix, Ynothing). +% +\def\donoderef#1{% + \ifx\lastnode\empty\else + \setref{\lastnode}{#1}% + \global\let\lastnode=\empty + \fi +} + +% @anchor{NAME} -- define xref target at arbitrary point. +% +\newcount\savesfregister +% +\def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi} +\def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} +\def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} + +% \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an +% anchor), which consists of three parts: +% 1) NAME-title - the current sectioning name taken from \lastsection, +% or the anchor name. +% 2) NAME-snt - section number and type, passed as the SNT arg, or +% empty for anchors. +% 3) NAME-pg - the page number. +% +% This is called from \donoderef, \anchor, and \dofloat. In the case of +% floats, there is an additional part, which is not written here: +% 4) NAME-lof - the text as it should appear in a @listoffloats. +% +\def\setref#1#2{% + \pdfmkdest{#1}% + \iflinks + {% + \atdummies % preserve commands, but don't expand them + \edef\writexrdef##1##2{% + \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef + ##1}{##2}}% these are parameters of \writexrdef + }% + \toks0 = \expandafter{\lastsection}% + \immediate \writexrdef{title}{\the\toks0 }% + \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc. + \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout + }% + \fi +} + +% @xrefautosectiontitle on|off says whether @section(ing) names are used +% automatically in xrefs, if the third arg is not explicitly specified. +% This was provided as a "secret" @set xref-automatic-section-title +% variable, now it's official. +% +\parseargdef\xrefautomaticsectiontitle{% + \def\temp{#1}% + \ifx\temp\onword + \expandafter\let\csname SETxref-automatic-section-title\endcsname + = \empty + \else\ifx\temp\offword + \expandafter\let\csname SETxref-automatic-section-title\endcsname + = \relax + \else + \errhelp = \EMsimple + \errmessage{Unknown @xrefautomaticsectiontitle value `\temp', + must be on|off}% + \fi\fi +} + + +% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is +% the node name, #2 the name of the Info cross-reference, #3 the printed +% node name, #4 the name of the Info file, #5 the name of the printed +% manual. All but the node name can be omitted. +% +\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} +\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} +\def\ref#1{\xrefX[#1,,,,,,,]} +% +\newbox\topbox +\newbox\printedrefnamebox +\newbox\printedmanualbox +% +\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup + \unsepspaces + % + \def\printedrefname{\ignorespaces #3}% + \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}% + % + \def\printedmanual{\ignorespaces #5}% + \setbox\printedmanualbox = \hbox{\printedmanual\unskip}% + % + % If the printed reference name (arg #3) was not explicitly given in + % the @xref, figure out what we want to use. + \ifdim \wd\printedrefnamebox = 0pt + % No printed node name was explicitly given. + \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax + % Not auto section-title: use node name inside the square brackets. + \def\printedrefname{\ignorespaces #1}% + \else + % Auto section-title: use chapter/section title inside + % the square brackets if we have it. + \ifdim \wd\printedmanualbox > 0pt + % It is in another manual, so we don't have it; use node name. + \def\printedrefname{\ignorespaces #1}% + \else + \ifhavexrefs + % We (should) know the real title if we have the xref values. + \def\printedrefname{\refx{#1-title}{}}% + \else + % Otherwise just copy the Info node name. + \def\printedrefname{\ignorespaces #1}% + \fi% + \fi + \fi + \fi + % + % Make link in pdf output. + \ifpdf + {\indexnofonts + \turnoffactive + % This expands tokens, so do it after making catcode changes, so _ + % etc. don't get their TeX definitions. + \getfilename{#4}% + % + \edef\pdfxrefdest{#1}% + \txiescapepdf\pdfxrefdest + % + \leavevmode + \startlink attr{/Border [0 0 0]}% + \ifnum\filenamelength>0 + goto file{\the\filename.pdf} name{\pdfxrefdest}% + \else + goto name{\pdfmkpgn{\pdfxrefdest}}% + \fi + }% + \setcolor{\linkcolor}% + \fi + % + % Float references are printed completely differently: "Figure 1.2" + % instead of "[somenode], p.3". We distinguish them by the + % LABEL-title being set to a magic string. + {% + % Have to otherify everything special to allow the \csname to + % include an _ in the xref name, etc. + \indexnofonts + \turnoffactive + \expandafter\global\expandafter\let\expandafter\Xthisreftitle + \csname XR#1-title\endcsname + }% + \iffloat\Xthisreftitle + % If the user specified the print name (third arg) to the ref, + % print it instead of our usual "Figure 1.2". + \ifdim\wd\printedrefnamebox = 0pt + \refx{#1-snt}{}% + \else + \printedrefname + \fi + % + % if the user also gave the printed manual name (fifth arg), append + % "in MANUALNAME". + \ifdim \wd\printedmanualbox > 0pt + \space \putwordin{} \cite{\printedmanual}% + \fi + \else + % node/anchor (non-float) references. + % + % If we use \unhbox to print the node names, TeX does not insert + % empty discretionaries after hyphens, which means that it will not + % find a line break at a hyphen in a node names. Since some manuals + % are best written with fairly long node names, containing hyphens, + % this is a loss. Therefore, we give the text of the node name + % again, so it is as if TeX is seeing it for the first time. + % + % Cross-manual reference. Only include the "Section ``foo'' in" if + % the foo is neither missing or Top. Thus, @xref{,,,foo,The Foo Manual} + % outputs simply "see The Foo Manual". + \ifdim \wd\printedmanualbox > 0pt + % What is the 7sp about? The idea is that we also want to omit + % the Section part if we would be printing "Top", since they are + % clearly trying to refer to the whole manual. But, this being + % TeX, we can't easily compare strings while ignoring the possible + % spaces before and after in the input. By adding the arbitrary + % 7sp, we make it much less likely that a real node name would + % happen to have the same width as "Top" (e.g., in a monospaced font). + % I hope it will never happen in practice. + % + % For the same basic reason, we retypeset the "Top" at every + % reference, since the current font is indeterminate. + % + \setbox\topbox = \hbox{Top\kern7sp}% + \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}% + \ifdim \wd2 > 7sp + \ifdim \wd2 = \wd\topbox \else + \putwordSection{} ``\printedrefname'' \putwordin{}\space + \fi + \fi + \cite{\printedmanual}% + \else + % Reference in this manual. + % + % _ (for example) has to be the character _ for the purposes of the + % control sequence corresponding to the node, but it has to expand + % into the usual \leavevmode...\vrule stuff for purposes of + % printing. So we \turnoffactive for the \refx-snt, back on for the + % printing, back off for the \refx-pg. + {\turnoffactive + % Only output a following space if the -snt ref is nonempty; for + % @unnumbered and @anchor, it won't be. + \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% + \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi + }% + % output the `[mynode]' via the macro below so it can be overridden. + \xrefprintnodename\printedrefname + % + % But we always want a comma and a space: + ,\space + % + % output the `page 3'. + \turnoffactive \putwordpage\tie\refx{#1-pg}{}% + \fi + \fi + \endlink +\endgroup} + +% This macro is called from \xrefX for the `[nodename]' part of xref +% output. It's a separate macro only so it can be changed more easily, +% since square brackets don't work well in some documents. Particularly +% one that Bob is working on :). +% +\def\xrefprintnodename#1{[#1]} + +% Things referred to by \setref. +% +\def\Ynothing{} +\def\Yomitfromtoc{} +\def\Ynumbered{% + \ifnum\secno=0 + \putwordChapter@tie \the\chapno + \else \ifnum\subsecno=0 + \putwordSection@tie \the\chapno.\the\secno + \else \ifnum\subsubsecno=0 + \putwordSection@tie \the\chapno.\the\secno.\the\subsecno + \else + \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno + \fi\fi\fi +} +\def\Yappendix{% + \ifnum\secno=0 + \putwordAppendix@tie @char\the\appendixno{}% + \else \ifnum\subsecno=0 + \putwordSection@tie @char\the\appendixno.\the\secno + \else \ifnum\subsubsecno=0 + \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno + \else + \putwordSection@tie + @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno + \fi\fi\fi +} + +% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. +% If its value is nonempty, SUFFIX is output afterward. +% +\def\refx#1#2{% + {% + \indexnofonts + \otherbackslash + \expandafter\global\expandafter\let\expandafter\thisrefX + \csname XR#1\endcsname + }% + \ifx\thisrefX\relax + % If not defined, say something at least. + \angleleft un\-de\-fined\angleright + \iflinks + \ifhavexrefs + {\toks0 = {#1}% avoid expansion of possibly-complex value + \message{\linenumber Undefined cross reference `\the\toks0'.}}% + \else + \ifwarnedxrefs\else + \global\warnedxrefstrue + \message{Cross reference values unknown; you must run TeX again.}% + \fi + \fi + \fi + \else + % It's defined, so just use it. + \thisrefX + \fi + #2% Output the suffix in any case. +} + +% This is the macro invoked by entries in the aux file. Usually it's +% just a \def (we prepend XR to the control sequence name to avoid +% collisions). But if this is a float type, we have more work to do. +% +\def\xrdef#1#2{% + {% The node name might contain 8-bit characters, which in our current + % implementation are changed to commands like @'e. Don't let these + % mess up the control sequence name. + \indexnofonts + \turnoffactive + \xdef\safexrefname{#1}% + }% + % + \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref + % + % Was that xref control sequence that we just defined for a float? + \expandafter\iffloat\csname XR\safexrefname\endcsname + % it was a float, and we have the (safe) float type in \iffloattype. + \expandafter\let\expandafter\floatlist + \csname floatlist\iffloattype\endcsname + % + % Is this the first time we've seen this float type? + \expandafter\ifx\floatlist\relax + \toks0 = {\do}% yes, so just \do + \else + % had it before, so preserve previous elements in list. + \toks0 = \expandafter{\floatlist\do}% + \fi + % + % Remember this xref in the control sequence \floatlistFLOATTYPE, + % for later use in \listoffloats. + \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0 + {\safexrefname}}% + \fi +} + +% Read the last existing aux file, if any. No error if none exists. +% +\def\tryauxfile{% + \openin 1 \jobname.aux + \ifeof 1 \else + \readdatafile{aux}% + \global\havexrefstrue + \fi + \closein 1 +} + +\def\setupdatafile{% + \catcode`\^^@=\other + \catcode`\^^A=\other + \catcode`\^^B=\other + \catcode`\^^C=\other + \catcode`\^^D=\other + \catcode`\^^E=\other + \catcode`\^^F=\other + \catcode`\^^G=\other + \catcode`\^^H=\other + \catcode`\^^K=\other + \catcode`\^^L=\other + \catcode`\^^N=\other + \catcode`\^^P=\other + \catcode`\^^Q=\other + \catcode`\^^R=\other + \catcode`\^^S=\other + \catcode`\^^T=\other + \catcode`\^^U=\other + \catcode`\^^V=\other + \catcode`\^^W=\other + \catcode`\^^X=\other + \catcode`\^^Z=\other + \catcode`\^^[=\other + \catcode`\^^\=\other + \catcode`\^^]=\other + \catcode`\^^^=\other + \catcode`\^^_=\other + % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc. + % in xref tags, i.e., node names. But since ^^e4 notation isn't + % supported in the main text, it doesn't seem desirable. Furthermore, + % that is not enough: for node names that actually contain a ^ + % character, we would end up writing a line like this: 'xrdef {'hat + % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first + % argument, and \hat is not an expandable control sequence. It could + % all be worked out, but why? Either we support ^^ or we don't. + % + % The other change necessary for this was to define \auxhat: + % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter + % and then to call \auxhat in \setq. + % + \catcode`\^=\other + % + % Special characters. Should be turned off anyway, but... + \catcode`\~=\other + \catcode`\[=\other + \catcode`\]=\other + \catcode`\"=\other + \catcode`\_=\other + \catcode`\|=\other + \catcode`\<=\other + \catcode`\>=\other + \catcode`\$=\other + \catcode`\#=\other + \catcode`\&=\other + \catcode`\%=\other + \catcode`+=\other % avoid \+ for paranoia even though we've turned it off + % + % This is to support \ in node names and titles, since the \ + % characters end up in a \csname. It's easier than + % leaving it active and making its active definition an actual \ + % character. What I don't understand is why it works in the *value* + % of the xrdef. Seems like it should be a catcode12 \, and that + % should not typeset properly. But it works, so I'm moving on for + % now. --karl, 15jan04. + \catcode`\\=\other + % + % Make the characters 128-255 be printing characters. + {% + \count1=128 + \def\loop{% + \catcode\count1=\other + \advance\count1 by 1 + \ifnum \count1<256 \loop \fi + }% + }% + % + % @ is our escape character in .aux files, and we need braces. + \catcode`\{=1 + \catcode`\}=2 + \catcode`\@=0 +} + +\def\readdatafile#1{% +\begingroup + \setupdatafile + \input\jobname.#1 +\endgroup} + + +\message{insertions,} +% including footnotes. + +\newcount \footnoteno + +% The trailing space in the following definition for supereject is +% vital for proper filling; pages come out unaligned when you do a +% pagealignmacro call if that space before the closing brace is +% removed. (Generally, numeric constants should always be followed by a +% space to prevent strange expansion errors.) +\def\supereject{\par\penalty -20000\footnoteno =0 } + +% @footnotestyle is meaningful for Info output only. +\let\footnotestyle=\comment + +{\catcode `\@=11 +% +% Auto-number footnotes. Otherwise like plain. +\gdef\footnote{% + \let\indent=\ptexindent + \let\noindent=\ptexnoindent + \global\advance\footnoteno by \@ne + \edef\thisfootno{$^{\the\footnoteno}$}% + % + % In case the footnote comes at the end of a sentence, preserve the + % extra spacing after we do the footnote number. + \let\@sf\empty + \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi + % + % Remove inadvertent blank space before typesetting the footnote number. + \unskip + \thisfootno\@sf + \dofootnote +}% + +% Don't bother with the trickery in plain.tex to not require the +% footnote text as a parameter. Our footnotes don't need to be so general. +% +% Oh yes, they do; otherwise, @ifset (and anything else that uses +% \parseargline) fails inside footnotes because the tokens are fixed when +% the footnote is read. --karl, 16nov96. +% +\gdef\dofootnote{% + \insert\footins\bgroup + % We want to typeset this text as a normal paragraph, even if the + % footnote reference occurs in (for example) a display environment. + % So reset some parameters. + \hsize=\pagewidth + \interlinepenalty\interfootnotelinepenalty + \splittopskip\ht\strutbox % top baseline for broken footnotes + \splitmaxdepth\dp\strutbox + \floatingpenalty\@MM + \leftskip\z@skip + \rightskip\z@skip + \spaceskip\z@skip + \xspaceskip\z@skip + \parindent\defaultparindent + % + \smallfonts \rm + % + % Because we use hanging indentation in footnotes, a @noindent appears + % to exdent this text, so make it be a no-op. makeinfo does not use + % hanging indentation so @noindent can still be needed within footnote + % text after an @example or the like (not that this is good style). + \let\noindent = \relax + % + % Hang the footnote text off the number. Use \everypar in case the + % footnote extends for more than one paragraph. + \everypar = {\hang}% + \textindent{\thisfootno}% + % + % Don't crash into the line above the footnote text. Since this + % expands into a box, it must come within the paragraph, lest it + % provide a place where TeX can split the footnote. + \footstrut + % + % Invoke rest of plain TeX footnote routine. + \futurelet\next\fo@t +} +}%end \catcode `\@=11 + +% In case a @footnote appears in a vbox, save the footnote text and create +% the real \insert just after the vbox finished. Otherwise, the insertion +% would be lost. +% Similarly, if a @footnote appears inside an alignment, save the footnote +% text to a box and make the \insert when a row of the table is finished. +% And the same can be done for other insert classes. --kasal, 16nov03. + +% Replace the \insert primitive by a cheating macro. +% Deeper inside, just make sure that the saved insertions are not spilled +% out prematurely. +% +\def\startsavinginserts{% + \ifx \insert\ptexinsert + \let\insert\saveinsert + \else + \let\checkinserts\relax + \fi +} + +% This \insert replacement works for both \insert\footins{foo} and +% \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}. +% +\def\saveinsert#1{% + \edef\next{\noexpand\savetobox \makeSAVEname#1}% + \afterassignment\next + % swallow the left brace + \let\temp = +} +\def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}} +\def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1} + +\def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi} + +\def\placesaveins#1{% + \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname + {\box#1}% +} + +% eat @SAVE -- beware, all of them have catcode \other: +{ + \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-) + \gdef\gobblesave @SAVE{} +} + +% initialization: +\def\newsaveins #1{% + \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}% + \next +} +\def\newsaveinsX #1{% + \csname newbox\endcsname #1% + \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts + \checksaveins #1}% +} + +% initialize: +\let\checkinserts\empty +\newsaveins\footins +\newsaveins\margin + + +% @image. We use the macros from epsf.tex to support this. +% If epsf.tex is not installed and @image is used, we complain. +% +% Check for and read epsf.tex up front. If we read it only at @image +% time, we might be inside a group, and then its definitions would get +% undone and the next image would fail. +\openin 1 = epsf.tex +\ifeof 1 \else + % Do not bother showing banner with epsf.tex v2.7k (available in + % doc/epsf.tex and on ctan). + \def\epsfannounce{\toks0 = }% + \input epsf.tex +\fi +\closein 1 +% +% We will only complain once about lack of epsf.tex. +\newif\ifwarnednoepsf +\newhelp\noepsfhelp{epsf.tex must be installed for images to + work. It is also included in the Texinfo distribution, or you can get + it from ftp://tug.org/tex/epsf.tex.} +% +\def\image#1{% + \ifx\epsfbox\thisiundefined + \ifwarnednoepsf \else + \errhelp = \noepsfhelp + \errmessage{epsf.tex not found, images will be ignored}% + \global\warnednoepsftrue + \fi + \else + \imagexxx #1,,,,,\finish + \fi +} +% +% Arguments to @image: +% #1 is (mandatory) image filename; we tack on .eps extension. +% #2 is (optional) width, #3 is (optional) height. +% #4 is (ignored optional) html alt text. +% #5 is (ignored optional) extension. +% #6 is just the usual extra ignored arg for parsing stuff. +\newif\ifimagevmode +\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup + \catcode`\^^M = 5 % in case we're inside an example + \normalturnoffactive % allow _ et al. in names + % If the image is by itself, center it. + \ifvmode + \imagevmodetrue + \nobreak\medskip + % Usually we'll have text after the image which will insert + % \parskip glue, so insert it here too to equalize the space + % above and below. + \nobreak\vskip\parskip + \nobreak + \fi + % + % Leave vertical mode so that indentation from an enclosing + % environment such as @quotation is respected. On the other hand, if + % it's at the top level, we don't want the normal paragraph indentation. + \noindent + % + % Output the image. + \ifpdf + \dopdfimage{#1}{#2}{#3}% + \else + % \epsfbox itself resets \epsf?size at each figure. + \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi + \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi + \epsfbox{#1.eps}% + \fi + % + \ifimagevmode \medskip \fi % space after the standalone image +\endgroup} + + +% @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables, +% etc. We don't actually implement floating yet, we always include the +% float "here". But it seemed the best name for the future. +% +\envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish} + +% There may be a space before second and/or third parameter; delete it. +\def\eatcommaspace#1, {#1,} + +% #1 is the optional FLOATTYPE, the text label for this float, typically +% "Figure", "Table", "Example", etc. Can't contain commas. If omitted, +% this float will not be numbered and cannot be referred to. +% +% #2 is the optional xref label. Also must be present for the float to +% be referable. +% +% #3 is the optional positioning argument; for now, it is ignored. It +% will somehow specify the positions allowed to float to (here, top, bottom). +% +% We keep a separate counter for each FLOATTYPE, which we reset at each +% chapter-level command. +\let\resetallfloatnos=\empty +% +\def\dofloat#1,#2,#3,#4\finish{% + \let\thiscaption=\empty + \let\thisshortcaption=\empty + % + % don't lose footnotes inside @float. + % + % BEWARE: when the floats start float, we have to issue warning whenever an + % insert appears inside a float which could possibly float. --kasal, 26may04 + % + \startsavinginserts + % + % We can't be used inside a paragraph. + \par + % + \vtop\bgroup + \def\floattype{#1}% + \def\floatlabel{#2}% + \def\floatloc{#3}% we do nothing with this yet. + % + \ifx\floattype\empty + \let\safefloattype=\empty + \else + {% + % the floattype might have accents or other special characters, + % but we need to use it in a control sequence name. + \indexnofonts + \turnoffactive + \xdef\safefloattype{\floattype}% + }% + \fi + % + % If label is given but no type, we handle that as the empty type. + \ifx\floatlabel\empty \else + % We want each FLOATTYPE to be numbered separately (Figure 1, + % Table 1, Figure 2, ...). (And if no label, no number.) + % + \expandafter\getfloatno\csname\safefloattype floatno\endcsname + \global\advance\floatno by 1 + % + {% + % This magic value for \lastsection is output by \setref as the + % XREFLABEL-title value. \xrefX uses it to distinguish float + % labels (which have a completely different output format) from + % node and anchor labels. And \xrdef uses it to construct the + % lists of floats. + % + \edef\lastsection{\floatmagic=\safefloattype}% + \setref{\floatlabel}{Yfloat}% + }% + \fi + % + % start with \parskip glue, I guess. + \vskip\parskip + % + % Don't suppress indentation if a float happens to start a section. + \restorefirstparagraphindent +} + +% we have these possibilities: +% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap +% @float Foo,lbl & no caption: Foo 1.1 +% @float Foo & @caption{Cap}: Foo: Cap +% @float Foo & no caption: Foo +% @float ,lbl & Caption{Cap}: 1.1: Cap +% @float ,lbl & no caption: 1.1 +% @float & @caption{Cap}: Cap +% @float & no caption: +% +\def\Efloat{% + \let\floatident = \empty + % + % In all cases, if we have a float type, it comes first. + \ifx\floattype\empty \else \def\floatident{\floattype}\fi + % + % If we have an xref label, the number comes next. + \ifx\floatlabel\empty \else + \ifx\floattype\empty \else % if also had float type, need tie first. + \appendtomacro\floatident{\tie}% + \fi + % the number. + \appendtomacro\floatident{\chaplevelprefix\the\floatno}% + \fi + % + % Start the printed caption with what we've constructed in + % \floatident, but keep it separate; we need \floatident again. + \let\captionline = \floatident + % + \ifx\thiscaption\empty \else + \ifx\floatident\empty \else + \appendtomacro\captionline{: }% had ident, so need a colon between + \fi + % + % caption text. + \appendtomacro\captionline{\scanexp\thiscaption}% + \fi + % + % If we have anything to print, print it, with space before. + % Eventually this needs to become an \insert. + \ifx\captionline\empty \else + \vskip.5\parskip + \captionline + % + % Space below caption. + \vskip\parskip + \fi + % + % If have an xref label, write the list of floats info. Do this + % after the caption, to avoid chance of it being a breakpoint. + \ifx\floatlabel\empty \else + % Write the text that goes in the lof to the aux file as + % \floatlabel-lof. Besides \floatident, we include the short + % caption if specified, else the full caption if specified, else nothing. + {% + \atdummies + % + % since we read the caption text in the macro world, where ^^M + % is turned into a normal character, we have to scan it back, so + % we don't write the literal three characters "^^M" into the aux file. + \scanexp{% + \xdef\noexpand\gtemp{% + \ifx\thisshortcaption\empty + \thiscaption + \else + \thisshortcaption + \fi + }% + }% + \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident + \ifx\gtemp\empty \else : \gtemp \fi}}% + }% + \fi + \egroup % end of \vtop + % + % place the captured inserts + % + % BEWARE: when the floats start floating, we have to issue warning + % whenever an insert appears inside a float which could possibly + % float. --kasal, 26may04 + % + \checkinserts +} + +% Append the tokens #2 to the definition of macro #1, not expanding either. +% +\def\appendtomacro#1#2{% + \expandafter\def\expandafter#1\expandafter{#1#2}% +} + +% @caption, @shortcaption +% +\def\caption{\docaption\thiscaption} +\def\shortcaption{\docaption\thisshortcaption} +\def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption} +\def\defcaption#1#2{\egroup \def#1{#2}} + +% The parameter is the control sequence identifying the counter we are +% going to use. Create it if it doesn't exist and assign it to \floatno. +\def\getfloatno#1{% + \ifx#1\relax + % Haven't seen this figure type before. + \csname newcount\endcsname #1% + % + % Remember to reset this floatno at the next chap. + \expandafter\gdef\expandafter\resetallfloatnos + \expandafter{\resetallfloatnos #1=0 }% + \fi + \let\floatno#1% +} + +% \setref calls this to get the XREFLABEL-snt value. We want an @xref +% to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we +% first read the @float command. +% +\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}% + +% Magic string used for the XREFLABEL-title value, so \xrefX can +% distinguish floats from other xref types. +\def\floatmagic{!!float!!} + +% #1 is the control sequence we are passed; we expand into a conditional +% which is true if #1 represents a float ref. That is, the magic +% \lastsection value which we \setref above. +% +\def\iffloat#1{\expandafter\doiffloat#1==\finish} +% +% #1 is (maybe) the \floatmagic string. If so, #2 will be the +% (safe) float type for this float. We set \iffloattype to #2. +% +\def\doiffloat#1=#2=#3\finish{% + \def\temp{#1}% + \def\iffloattype{#2}% + \ifx\temp\floatmagic +} + +% @listoffloats FLOATTYPE - print a list of floats like a table of contents. +% +\parseargdef\listoffloats{% + \def\floattype{#1}% floattype + {% + % the floattype might have accents or other special characters, + % but we need to use it in a control sequence name. + \indexnofonts + \turnoffactive + \xdef\safefloattype{\floattype}% + }% + % + % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE. + \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax + \ifhavexrefs + % if the user said @listoffloats foo but never @float foo. + \message{\linenumber No `\safefloattype' floats to list.}% + \fi + \else + \begingroup + \leftskip=\tocindent % indent these entries like a toc + \let\do=\listoffloatsdo + \csname floatlist\safefloattype\endcsname + \endgroup + \fi +} + +% This is called on each entry in a list of floats. We're passed the +% xref label, in the form LABEL-title, which is how we save it in the +% aux file. We strip off the -title and look up \XRLABEL-lof, which +% has the text we're supposed to typeset here. +% +% Figures without xref labels will not be included in the list (since +% they won't appear in the aux file). +% +\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish} +\def\listoffloatsdoentry#1-title\finish{{% + % Can't fully expand XR#1-lof because it can contain anything. Just + % pass the control sequence. On the other hand, XR#1-pg is just the + % page number, and we want to fully expand that so we can get a link + % in pdf output. + \toksA = \expandafter{\csname XR#1-lof\endcsname}% + % + % use the same \entry macro we use to generate the TOC and index. + \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}% + \writeentry +}} + + +\message{localization,} + +% For single-language documents, @documentlanguage is usually given very +% early, just after @documentencoding. Single argument is the language +% (de) or locale (de_DE) abbreviation. +% +{ + \catcode`\_ = \active + \globaldefs=1 +\parseargdef\documentlanguage{\begingroup + \let_=\normalunderscore % normal _ character for filenames + \tex % read txi-??.tex file in plain TeX. + % Read the file by the name they passed if it exists. + \openin 1 txi-#1.tex + \ifeof 1 + \documentlanguagetrywithoutunderscore{#1_\finish}% + \else + \globaldefs = 1 % everything in the txi-LL files needs to persist + \input txi-#1.tex + \fi + \closein 1 + \endgroup % end raw TeX +\endgroup} +% +% If they passed de_DE, and txi-de_DE.tex doesn't exist, +% try txi-de.tex. +% +\gdef\documentlanguagetrywithoutunderscore#1_#2\finish{% + \openin 1 txi-#1.tex + \ifeof 1 + \errhelp = \nolanghelp + \errmessage{Cannot read language file txi-#1.tex}% + \else + \globaldefs = 1 % everything in the txi-LL files needs to persist + \input txi-#1.tex + \fi + \closein 1 +} +}% end of special _ catcode +% +\newhelp\nolanghelp{The given language definition file cannot be found or +is empty. Maybe you need to install it? Putting it in the current +directory should work if nowhere else does.} + +% This macro is called from txi-??.tex files; the first argument is the +% \language name to set (without the "\lang@" prefix), the second and +% third args are \{left,right}hyphenmin. +% +% The language names to pass are determined when the format is built. +% See the etex.log file created at that time, e.g., +% /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log. +% +% With TeX Live 2008, etex now includes hyphenation patterns for all +% available languages. This means we can support hyphenation in +% Texinfo, at least to some extent. (This still doesn't solve the +% accented characters problem.) +% +\catcode`@=11 +\def\txisetlanguage#1#2#3{% + % do not set the language if the name is undefined in the current TeX. + \expandafter\ifx\csname lang@#1\endcsname \relax + \message{no patterns for #1}% + \else + \global\language = \csname lang@#1\endcsname + \fi + % but there is no harm in adjusting the hyphenmin values regardless. + \global\lefthyphenmin = #2\relax + \global\righthyphenmin = #3\relax +} + +% Helpers for encodings. +% Set the catcode of characters 128 through 255 to the specified number. +% +\def\setnonasciicharscatcode#1{% + \count255=128 + \loop\ifnum\count255<256 + \global\catcode\count255=#1\relax + \advance\count255 by 1 + \repeat +} + +\def\setnonasciicharscatcodenonglobal#1{% + \count255=128 + \loop\ifnum\count255<256 + \catcode\count255=#1\relax + \advance\count255 by 1 + \repeat +} + +% @documentencoding sets the definition of non-ASCII characters +% according to the specified encoding. +% +\parseargdef\documentencoding{% + % Encoding being declared for the document. + \def\declaredencoding{\csname #1.enc\endcsname}% + % + % Supported encodings: names converted to tokens in order to be able + % to compare them with \ifx. + \def\ascii{\csname US-ASCII.enc\endcsname}% + \def\latnine{\csname ISO-8859-15.enc\endcsname}% + \def\latone{\csname ISO-8859-1.enc\endcsname}% + \def\lattwo{\csname ISO-8859-2.enc\endcsname}% + \def\utfeight{\csname UTF-8.enc\endcsname}% + % + \ifx \declaredencoding \ascii + \asciichardefs + % + \else \ifx \declaredencoding \lattwo + \setnonasciicharscatcode\active + \lattwochardefs + % + \else \ifx \declaredencoding \latone + \setnonasciicharscatcode\active + \latonechardefs + % + \else \ifx \declaredencoding \latnine + \setnonasciicharscatcode\active + \latninechardefs + % + \else \ifx \declaredencoding \utfeight + \setnonasciicharscatcode\active + \utfeightchardefs + % + \else + \message{Unknown document encoding #1, ignoring.}% + % + \fi % utfeight + \fi % latnine + \fi % latone + \fi % lattwo + \fi % ascii +} + +% A message to be logged when using a character that isn't available +% the default font encoding (OT1). +% +\def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}} + +% Take account of \c (plain) vs. \, (Texinfo) difference. +\def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi} + +% First, make active non-ASCII characters in order for them to be +% correctly categorized when TeX reads the replacement text of +% macros containing the character definitions. +\setnonasciicharscatcode\active +% +% Latin1 (ISO-8859-1) character definitions. +\def\latonechardefs{% + \gdef^^a0{\tie} + \gdef^^a1{\exclamdown} + \gdef^^a2{\missingcharmsg{CENT SIGN}} + \gdef^^a3{{\pounds}} + \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} + \gdef^^a5{\missingcharmsg{YEN SIGN}} + \gdef^^a6{\missingcharmsg{BROKEN BAR}} + \gdef^^a7{\S} + \gdef^^a8{\"{}} + \gdef^^a9{\copyright} + \gdef^^aa{\ordf} + \gdef^^ab{\guillemetleft} + \gdef^^ac{$\lnot$} + \gdef^^ad{\-} + \gdef^^ae{\registeredsymbol} + \gdef^^af{\={}} + % + \gdef^^b0{\textdegree} + \gdef^^b1{$\pm$} + \gdef^^b2{$^2$} + \gdef^^b3{$^3$} + \gdef^^b4{\'{}} + \gdef^^b5{$\mu$} + \gdef^^b6{\P} + % + \gdef^^b7{$^.$} + \gdef^^b8{\cedilla\ } + \gdef^^b9{$^1$} + \gdef^^ba{\ordm} + % + \gdef^^bb{\guillemetright} + \gdef^^bc{$1\over4$} + \gdef^^bd{$1\over2$} + \gdef^^be{$3\over4$} + \gdef^^bf{\questiondown} + % + \gdef^^c0{\`A} + \gdef^^c1{\'A} + \gdef^^c2{\^A} + \gdef^^c3{\~A} + \gdef^^c4{\"A} + \gdef^^c5{\ringaccent A} + \gdef^^c6{\AE} + \gdef^^c7{\cedilla C} + \gdef^^c8{\`E} + \gdef^^c9{\'E} + \gdef^^ca{\^E} + \gdef^^cb{\"E} + \gdef^^cc{\`I} + \gdef^^cd{\'I} + \gdef^^ce{\^I} + \gdef^^cf{\"I} + % + \gdef^^d0{\DH} + \gdef^^d1{\~N} + \gdef^^d2{\`O} + \gdef^^d3{\'O} + \gdef^^d4{\^O} + \gdef^^d5{\~O} + \gdef^^d6{\"O} + \gdef^^d7{$\times$} + \gdef^^d8{\O} + \gdef^^d9{\`U} + \gdef^^da{\'U} + \gdef^^db{\^U} + \gdef^^dc{\"U} + \gdef^^dd{\'Y} + \gdef^^de{\TH} + \gdef^^df{\ss} + % + \gdef^^e0{\`a} + \gdef^^e1{\'a} + \gdef^^e2{\^a} + \gdef^^e3{\~a} + \gdef^^e4{\"a} + \gdef^^e5{\ringaccent a} + \gdef^^e6{\ae} + \gdef^^e7{\cedilla c} + \gdef^^e8{\`e} + \gdef^^e9{\'e} + \gdef^^ea{\^e} + \gdef^^eb{\"e} + \gdef^^ec{\`{\dotless i}} + \gdef^^ed{\'{\dotless i}} + \gdef^^ee{\^{\dotless i}} + \gdef^^ef{\"{\dotless i}} + % + \gdef^^f0{\dh} + \gdef^^f1{\~n} + \gdef^^f2{\`o} + \gdef^^f3{\'o} + \gdef^^f4{\^o} + \gdef^^f5{\~o} + \gdef^^f6{\"o} + \gdef^^f7{$\div$} + \gdef^^f8{\o} + \gdef^^f9{\`u} + \gdef^^fa{\'u} + \gdef^^fb{\^u} + \gdef^^fc{\"u} + \gdef^^fd{\'y} + \gdef^^fe{\th} + \gdef^^ff{\"y} +} + +% Latin9 (ISO-8859-15) encoding character definitions. +\def\latninechardefs{% + % Encoding is almost identical to Latin1. + \latonechardefs + % + \gdef^^a4{\euro} + \gdef^^a6{\v S} + \gdef^^a8{\v s} + \gdef^^b4{\v Z} + \gdef^^b8{\v z} + \gdef^^bc{\OE} + \gdef^^bd{\oe} + \gdef^^be{\"Y} +} + +% Latin2 (ISO-8859-2) character definitions. +\def\lattwochardefs{% + \gdef^^a0{\tie} + \gdef^^a1{\ogonek{A}} + \gdef^^a2{\u{}} + \gdef^^a3{\L} + \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} + \gdef^^a5{\v L} + \gdef^^a6{\'S} + \gdef^^a7{\S} + \gdef^^a8{\"{}} + \gdef^^a9{\v S} + \gdef^^aa{\cedilla S} + \gdef^^ab{\v T} + \gdef^^ac{\'Z} + \gdef^^ad{\-} + \gdef^^ae{\v Z} + \gdef^^af{\dotaccent Z} + % + \gdef^^b0{\textdegree} + \gdef^^b1{\ogonek{a}} + \gdef^^b2{\ogonek{ }} + \gdef^^b3{\l} + \gdef^^b4{\'{}} + \gdef^^b5{\v l} + \gdef^^b6{\'s} + \gdef^^b7{\v{}} + \gdef^^b8{\cedilla\ } + \gdef^^b9{\v s} + \gdef^^ba{\cedilla s} + \gdef^^bb{\v t} + \gdef^^bc{\'z} + \gdef^^bd{\H{}} + \gdef^^be{\v z} + \gdef^^bf{\dotaccent z} + % + \gdef^^c0{\'R} + \gdef^^c1{\'A} + \gdef^^c2{\^A} + \gdef^^c3{\u A} + \gdef^^c4{\"A} + \gdef^^c5{\'L} + \gdef^^c6{\'C} + \gdef^^c7{\cedilla C} + \gdef^^c8{\v C} + \gdef^^c9{\'E} + \gdef^^ca{\ogonek{E}} + \gdef^^cb{\"E} + \gdef^^cc{\v E} + \gdef^^cd{\'I} + \gdef^^ce{\^I} + \gdef^^cf{\v D} + % + \gdef^^d0{\DH} + \gdef^^d1{\'N} + \gdef^^d2{\v N} + \gdef^^d3{\'O} + \gdef^^d4{\^O} + \gdef^^d5{\H O} + \gdef^^d6{\"O} + \gdef^^d7{$\times$} + \gdef^^d8{\v R} + \gdef^^d9{\ringaccent U} + \gdef^^da{\'U} + \gdef^^db{\H U} + \gdef^^dc{\"U} + \gdef^^dd{\'Y} + \gdef^^de{\cedilla T} + \gdef^^df{\ss} + % + \gdef^^e0{\'r} + \gdef^^e1{\'a} + \gdef^^e2{\^a} + \gdef^^e3{\u a} + \gdef^^e4{\"a} + \gdef^^e5{\'l} + \gdef^^e6{\'c} + \gdef^^e7{\cedilla c} + \gdef^^e8{\v c} + \gdef^^e9{\'e} + \gdef^^ea{\ogonek{e}} + \gdef^^eb{\"e} + \gdef^^ec{\v e} + \gdef^^ed{\'{\dotless{i}}} + \gdef^^ee{\^{\dotless{i}}} + \gdef^^ef{\v d} + % + \gdef^^f0{\dh} + \gdef^^f1{\'n} + \gdef^^f2{\v n} + \gdef^^f3{\'o} + \gdef^^f4{\^o} + \gdef^^f5{\H o} + \gdef^^f6{\"o} + \gdef^^f7{$\div$} + \gdef^^f8{\v r} + \gdef^^f9{\ringaccent u} + \gdef^^fa{\'u} + \gdef^^fb{\H u} + \gdef^^fc{\"u} + \gdef^^fd{\'y} + \gdef^^fe{\cedilla t} + \gdef^^ff{\dotaccent{}} +} + +% UTF-8 character definitions. +% +% This code to support UTF-8 is based on LaTeX's utf8.def, with some +% changes for Texinfo conventions. It is included here under the GPL by +% permission from Frank Mittelbach and the LaTeX team. +% +\newcount\countUTFx +\newcount\countUTFy +\newcount\countUTFz + +\gdef\UTFviiiTwoOctets#1#2{\expandafter + \UTFviiiDefined\csname u8:#1\string #2\endcsname} +% +\gdef\UTFviiiThreeOctets#1#2#3{\expandafter + \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname} +% +\gdef\UTFviiiFourOctets#1#2#3#4{\expandafter + \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname} + +\gdef\UTFviiiDefined#1{% + \ifx #1\relax + \message{\linenumber Unicode char \string #1 not defined for Texinfo}% + \else + \expandafter #1% + \fi +} + +\begingroup + \catcode`\~13 + \catcode`\"12 + + \def\UTFviiiLoop{% + \global\catcode\countUTFx\active + \uccode`\~\countUTFx + \uppercase\expandafter{\UTFviiiTmp}% + \advance\countUTFx by 1 + \ifnum\countUTFx < \countUTFy + \expandafter\UTFviiiLoop + \fi} + + \countUTFx = "C2 + \countUTFy = "E0 + \def\UTFviiiTmp{% + \xdef~{\noexpand\UTFviiiTwoOctets\string~}} + \UTFviiiLoop + + \countUTFx = "E0 + \countUTFy = "F0 + \def\UTFviiiTmp{% + \xdef~{\noexpand\UTFviiiThreeOctets\string~}} + \UTFviiiLoop + + \countUTFx = "F0 + \countUTFy = "F4 + \def\UTFviiiTmp{% + \xdef~{\noexpand\UTFviiiFourOctets\string~}} + \UTFviiiLoop +\endgroup + +\begingroup + \catcode`\"=12 + \catcode`\<=12 + \catcode`\.=12 + \catcode`\,=12 + \catcode`\;=12 + \catcode`\!=12 + \catcode`\~=13 + + \gdef\DeclareUnicodeCharacter#1#2{% + \countUTFz = "#1\relax + %\wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}% + \begingroup + \parseXMLCharref + \def\UTFviiiTwoOctets##1##2{% + \csname u8:##1\string ##2\endcsname}% + \def\UTFviiiThreeOctets##1##2##3{% + \csname u8:##1\string ##2\string ##3\endcsname}% + \def\UTFviiiFourOctets##1##2##3##4{% + \csname u8:##1\string ##2\string ##3\string ##4\endcsname}% + \expandafter\expandafter\expandafter\expandafter + \expandafter\expandafter\expandafter + \gdef\UTFviiiTmp{#2}% + \endgroup} + + \gdef\parseXMLCharref{% + \ifnum\countUTFz < "A0\relax + \errhelp = \EMsimple + \errmessage{Cannot define Unicode char value < 00A0}% + \else\ifnum\countUTFz < "800\relax + \parseUTFviiiA,% + \parseUTFviiiB C\UTFviiiTwoOctets.,% + \else\ifnum\countUTFz < "10000\relax + \parseUTFviiiA;% + \parseUTFviiiA,% + \parseUTFviiiB E\UTFviiiThreeOctets.{,;}% + \else + \parseUTFviiiA;% + \parseUTFviiiA,% + \parseUTFviiiA!% + \parseUTFviiiB F\UTFviiiFourOctets.{!,;}% + \fi\fi\fi + } + + \gdef\parseUTFviiiA#1{% + \countUTFx = \countUTFz + \divide\countUTFz by 64 + \countUTFy = \countUTFz + \multiply\countUTFz by 64 + \advance\countUTFx by -\countUTFz + \advance\countUTFx by 128 + \uccode `#1\countUTFx + \countUTFz = \countUTFy} + + \gdef\parseUTFviiiB#1#2#3#4{% + \advance\countUTFz by "#10\relax + \uccode `#3\countUTFz + \uppercase{\gdef\UTFviiiTmp{#2#3#4}}} +\endgroup + +\def\utfeightchardefs{% + \DeclareUnicodeCharacter{00A0}{\tie} + \DeclareUnicodeCharacter{00A1}{\exclamdown} + \DeclareUnicodeCharacter{00A3}{\pounds} + \DeclareUnicodeCharacter{00A8}{\"{ }} + \DeclareUnicodeCharacter{00A9}{\copyright} + \DeclareUnicodeCharacter{00AA}{\ordf} + \DeclareUnicodeCharacter{00AB}{\guillemetleft} + \DeclareUnicodeCharacter{00AD}{\-} + \DeclareUnicodeCharacter{00AE}{\registeredsymbol} + \DeclareUnicodeCharacter{00AF}{\={ }} + + \DeclareUnicodeCharacter{00B0}{\ringaccent{ }} + \DeclareUnicodeCharacter{00B4}{\'{ }} + \DeclareUnicodeCharacter{00B8}{\cedilla{ }} + \DeclareUnicodeCharacter{00BA}{\ordm} + \DeclareUnicodeCharacter{00BB}{\guillemetright} + \DeclareUnicodeCharacter{00BF}{\questiondown} + + \DeclareUnicodeCharacter{00C0}{\`A} + \DeclareUnicodeCharacter{00C1}{\'A} + \DeclareUnicodeCharacter{00C2}{\^A} + \DeclareUnicodeCharacter{00C3}{\~A} + \DeclareUnicodeCharacter{00C4}{\"A} + \DeclareUnicodeCharacter{00C5}{\AA} + \DeclareUnicodeCharacter{00C6}{\AE} + \DeclareUnicodeCharacter{00C7}{\cedilla{C}} + \DeclareUnicodeCharacter{00C8}{\`E} + \DeclareUnicodeCharacter{00C9}{\'E} + \DeclareUnicodeCharacter{00CA}{\^E} + \DeclareUnicodeCharacter{00CB}{\"E} + \DeclareUnicodeCharacter{00CC}{\`I} + \DeclareUnicodeCharacter{00CD}{\'I} + \DeclareUnicodeCharacter{00CE}{\^I} + \DeclareUnicodeCharacter{00CF}{\"I} + + \DeclareUnicodeCharacter{00D0}{\DH} + \DeclareUnicodeCharacter{00D1}{\~N} + \DeclareUnicodeCharacter{00D2}{\`O} + \DeclareUnicodeCharacter{00D3}{\'O} + \DeclareUnicodeCharacter{00D4}{\^O} + \DeclareUnicodeCharacter{00D5}{\~O} + \DeclareUnicodeCharacter{00D6}{\"O} + \DeclareUnicodeCharacter{00D8}{\O} + \DeclareUnicodeCharacter{00D9}{\`U} + \DeclareUnicodeCharacter{00DA}{\'U} + \DeclareUnicodeCharacter{00DB}{\^U} + \DeclareUnicodeCharacter{00DC}{\"U} + \DeclareUnicodeCharacter{00DD}{\'Y} + \DeclareUnicodeCharacter{00DE}{\TH} + \DeclareUnicodeCharacter{00DF}{\ss} + + \DeclareUnicodeCharacter{00E0}{\`a} + \DeclareUnicodeCharacter{00E1}{\'a} + \DeclareUnicodeCharacter{00E2}{\^a} + \DeclareUnicodeCharacter{00E3}{\~a} + \DeclareUnicodeCharacter{00E4}{\"a} + \DeclareUnicodeCharacter{00E5}{\aa} + \DeclareUnicodeCharacter{00E6}{\ae} + \DeclareUnicodeCharacter{00E7}{\cedilla{c}} + \DeclareUnicodeCharacter{00E8}{\`e} + \DeclareUnicodeCharacter{00E9}{\'e} + \DeclareUnicodeCharacter{00EA}{\^e} + \DeclareUnicodeCharacter{00EB}{\"e} + \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}} + \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}} + \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}} + \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}} + + \DeclareUnicodeCharacter{00F0}{\dh} + \DeclareUnicodeCharacter{00F1}{\~n} + \DeclareUnicodeCharacter{00F2}{\`o} + \DeclareUnicodeCharacter{00F3}{\'o} + \DeclareUnicodeCharacter{00F4}{\^o} + \DeclareUnicodeCharacter{00F5}{\~o} + \DeclareUnicodeCharacter{00F6}{\"o} + \DeclareUnicodeCharacter{00F8}{\o} + \DeclareUnicodeCharacter{00F9}{\`u} + \DeclareUnicodeCharacter{00FA}{\'u} + \DeclareUnicodeCharacter{00FB}{\^u} + \DeclareUnicodeCharacter{00FC}{\"u} + \DeclareUnicodeCharacter{00FD}{\'y} + \DeclareUnicodeCharacter{00FE}{\th} + \DeclareUnicodeCharacter{00FF}{\"y} + + \DeclareUnicodeCharacter{0100}{\=A} + \DeclareUnicodeCharacter{0101}{\=a} + \DeclareUnicodeCharacter{0102}{\u{A}} + \DeclareUnicodeCharacter{0103}{\u{a}} + \DeclareUnicodeCharacter{0104}{\ogonek{A}} + \DeclareUnicodeCharacter{0105}{\ogonek{a}} + \DeclareUnicodeCharacter{0106}{\'C} + \DeclareUnicodeCharacter{0107}{\'c} + \DeclareUnicodeCharacter{0108}{\^C} + \DeclareUnicodeCharacter{0109}{\^c} + \DeclareUnicodeCharacter{0118}{\ogonek{E}} + \DeclareUnicodeCharacter{0119}{\ogonek{e}} + \DeclareUnicodeCharacter{010A}{\dotaccent{C}} + \DeclareUnicodeCharacter{010B}{\dotaccent{c}} + \DeclareUnicodeCharacter{010C}{\v{C}} + \DeclareUnicodeCharacter{010D}{\v{c}} + \DeclareUnicodeCharacter{010E}{\v{D}} + + \DeclareUnicodeCharacter{0112}{\=E} + \DeclareUnicodeCharacter{0113}{\=e} + \DeclareUnicodeCharacter{0114}{\u{E}} + \DeclareUnicodeCharacter{0115}{\u{e}} + \DeclareUnicodeCharacter{0116}{\dotaccent{E}} + \DeclareUnicodeCharacter{0117}{\dotaccent{e}} + \DeclareUnicodeCharacter{011A}{\v{E}} + \DeclareUnicodeCharacter{011B}{\v{e}} + \DeclareUnicodeCharacter{011C}{\^G} + \DeclareUnicodeCharacter{011D}{\^g} + \DeclareUnicodeCharacter{011E}{\u{G}} + \DeclareUnicodeCharacter{011F}{\u{g}} + + \DeclareUnicodeCharacter{0120}{\dotaccent{G}} + \DeclareUnicodeCharacter{0121}{\dotaccent{g}} + \DeclareUnicodeCharacter{0124}{\^H} + \DeclareUnicodeCharacter{0125}{\^h} + \DeclareUnicodeCharacter{0128}{\~I} + \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}} + \DeclareUnicodeCharacter{012A}{\=I} + \DeclareUnicodeCharacter{012B}{\={\dotless{i}}} + \DeclareUnicodeCharacter{012C}{\u{I}} + \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}} + + \DeclareUnicodeCharacter{0130}{\dotaccent{I}} + \DeclareUnicodeCharacter{0131}{\dotless{i}} + \DeclareUnicodeCharacter{0132}{IJ} + \DeclareUnicodeCharacter{0133}{ij} + \DeclareUnicodeCharacter{0134}{\^J} + \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}} + \DeclareUnicodeCharacter{0139}{\'L} + \DeclareUnicodeCharacter{013A}{\'l} + + \DeclareUnicodeCharacter{0141}{\L} + \DeclareUnicodeCharacter{0142}{\l} + \DeclareUnicodeCharacter{0143}{\'N} + \DeclareUnicodeCharacter{0144}{\'n} + \DeclareUnicodeCharacter{0147}{\v{N}} + \DeclareUnicodeCharacter{0148}{\v{n}} + \DeclareUnicodeCharacter{014C}{\=O} + \DeclareUnicodeCharacter{014D}{\=o} + \DeclareUnicodeCharacter{014E}{\u{O}} + \DeclareUnicodeCharacter{014F}{\u{o}} + + \DeclareUnicodeCharacter{0150}{\H{O}} + \DeclareUnicodeCharacter{0151}{\H{o}} + \DeclareUnicodeCharacter{0152}{\OE} + \DeclareUnicodeCharacter{0153}{\oe} + \DeclareUnicodeCharacter{0154}{\'R} + \DeclareUnicodeCharacter{0155}{\'r} + \DeclareUnicodeCharacter{0158}{\v{R}} + \DeclareUnicodeCharacter{0159}{\v{r}} + \DeclareUnicodeCharacter{015A}{\'S} + \DeclareUnicodeCharacter{015B}{\'s} + \DeclareUnicodeCharacter{015C}{\^S} + \DeclareUnicodeCharacter{015D}{\^s} + \DeclareUnicodeCharacter{015E}{\cedilla{S}} + \DeclareUnicodeCharacter{015F}{\cedilla{s}} + + \DeclareUnicodeCharacter{0160}{\v{S}} + \DeclareUnicodeCharacter{0161}{\v{s}} + \DeclareUnicodeCharacter{0162}{\cedilla{t}} + \DeclareUnicodeCharacter{0163}{\cedilla{T}} + \DeclareUnicodeCharacter{0164}{\v{T}} + + \DeclareUnicodeCharacter{0168}{\~U} + \DeclareUnicodeCharacter{0169}{\~u} + \DeclareUnicodeCharacter{016A}{\=U} + \DeclareUnicodeCharacter{016B}{\=u} + \DeclareUnicodeCharacter{016C}{\u{U}} + \DeclareUnicodeCharacter{016D}{\u{u}} + \DeclareUnicodeCharacter{016E}{\ringaccent{U}} + \DeclareUnicodeCharacter{016F}{\ringaccent{u}} + + \DeclareUnicodeCharacter{0170}{\H{U}} + \DeclareUnicodeCharacter{0171}{\H{u}} + \DeclareUnicodeCharacter{0174}{\^W} + \DeclareUnicodeCharacter{0175}{\^w} + \DeclareUnicodeCharacter{0176}{\^Y} + \DeclareUnicodeCharacter{0177}{\^y} + \DeclareUnicodeCharacter{0178}{\"Y} + \DeclareUnicodeCharacter{0179}{\'Z} + \DeclareUnicodeCharacter{017A}{\'z} + \DeclareUnicodeCharacter{017B}{\dotaccent{Z}} + \DeclareUnicodeCharacter{017C}{\dotaccent{z}} + \DeclareUnicodeCharacter{017D}{\v{Z}} + \DeclareUnicodeCharacter{017E}{\v{z}} + + \DeclareUnicodeCharacter{01C4}{D\v{Z}} + \DeclareUnicodeCharacter{01C5}{D\v{z}} + \DeclareUnicodeCharacter{01C6}{d\v{z}} + \DeclareUnicodeCharacter{01C7}{LJ} + \DeclareUnicodeCharacter{01C8}{Lj} + \DeclareUnicodeCharacter{01C9}{lj} + \DeclareUnicodeCharacter{01CA}{NJ} + \DeclareUnicodeCharacter{01CB}{Nj} + \DeclareUnicodeCharacter{01CC}{nj} + \DeclareUnicodeCharacter{01CD}{\v{A}} + \DeclareUnicodeCharacter{01CE}{\v{a}} + \DeclareUnicodeCharacter{01CF}{\v{I}} + + \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}} + \DeclareUnicodeCharacter{01D1}{\v{O}} + \DeclareUnicodeCharacter{01D2}{\v{o}} + \DeclareUnicodeCharacter{01D3}{\v{U}} + \DeclareUnicodeCharacter{01D4}{\v{u}} + + \DeclareUnicodeCharacter{01E2}{\={\AE}} + \DeclareUnicodeCharacter{01E3}{\={\ae}} + \DeclareUnicodeCharacter{01E6}{\v{G}} + \DeclareUnicodeCharacter{01E7}{\v{g}} + \DeclareUnicodeCharacter{01E8}{\v{K}} + \DeclareUnicodeCharacter{01E9}{\v{k}} + + \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}} + \DeclareUnicodeCharacter{01F1}{DZ} + \DeclareUnicodeCharacter{01F2}{Dz} + \DeclareUnicodeCharacter{01F3}{dz} + \DeclareUnicodeCharacter{01F4}{\'G} + \DeclareUnicodeCharacter{01F5}{\'g} + \DeclareUnicodeCharacter{01F8}{\`N} + \DeclareUnicodeCharacter{01F9}{\`n} + \DeclareUnicodeCharacter{01FC}{\'{\AE}} + \DeclareUnicodeCharacter{01FD}{\'{\ae}} + \DeclareUnicodeCharacter{01FE}{\'{\O}} + \DeclareUnicodeCharacter{01FF}{\'{\o}} + + \DeclareUnicodeCharacter{021E}{\v{H}} + \DeclareUnicodeCharacter{021F}{\v{h}} + + \DeclareUnicodeCharacter{0226}{\dotaccent{A}} + \DeclareUnicodeCharacter{0227}{\dotaccent{a}} + \DeclareUnicodeCharacter{0228}{\cedilla{E}} + \DeclareUnicodeCharacter{0229}{\cedilla{e}} + \DeclareUnicodeCharacter{022E}{\dotaccent{O}} + \DeclareUnicodeCharacter{022F}{\dotaccent{o}} + + \DeclareUnicodeCharacter{0232}{\=Y} + \DeclareUnicodeCharacter{0233}{\=y} + \DeclareUnicodeCharacter{0237}{\dotless{j}} + + \DeclareUnicodeCharacter{02DB}{\ogonek{ }} + + \DeclareUnicodeCharacter{1E02}{\dotaccent{B}} + \DeclareUnicodeCharacter{1E03}{\dotaccent{b}} + \DeclareUnicodeCharacter{1E04}{\udotaccent{B}} + \DeclareUnicodeCharacter{1E05}{\udotaccent{b}} + \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}} + \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}} + \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}} + \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}} + \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}} + \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}} + \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}} + \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}} + + \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}} + \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}} + + \DeclareUnicodeCharacter{1E20}{\=G} + \DeclareUnicodeCharacter{1E21}{\=g} + \DeclareUnicodeCharacter{1E22}{\dotaccent{H}} + \DeclareUnicodeCharacter{1E23}{\dotaccent{h}} + \DeclareUnicodeCharacter{1E24}{\udotaccent{H}} + \DeclareUnicodeCharacter{1E25}{\udotaccent{h}} + \DeclareUnicodeCharacter{1E26}{\"H} + \DeclareUnicodeCharacter{1E27}{\"h} + + \DeclareUnicodeCharacter{1E30}{\'K} + \DeclareUnicodeCharacter{1E31}{\'k} + \DeclareUnicodeCharacter{1E32}{\udotaccent{K}} + \DeclareUnicodeCharacter{1E33}{\udotaccent{k}} + \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}} + \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}} + \DeclareUnicodeCharacter{1E36}{\udotaccent{L}} + \DeclareUnicodeCharacter{1E37}{\udotaccent{l}} + \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}} + \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}} + \DeclareUnicodeCharacter{1E3E}{\'M} + \DeclareUnicodeCharacter{1E3F}{\'m} + + \DeclareUnicodeCharacter{1E40}{\dotaccent{M}} + \DeclareUnicodeCharacter{1E41}{\dotaccent{m}} + \DeclareUnicodeCharacter{1E42}{\udotaccent{M}} + \DeclareUnicodeCharacter{1E43}{\udotaccent{m}} + \DeclareUnicodeCharacter{1E44}{\dotaccent{N}} + \DeclareUnicodeCharacter{1E45}{\dotaccent{n}} + \DeclareUnicodeCharacter{1E46}{\udotaccent{N}} + \DeclareUnicodeCharacter{1E47}{\udotaccent{n}} + \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}} + \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}} + + \DeclareUnicodeCharacter{1E54}{\'P} + \DeclareUnicodeCharacter{1E55}{\'p} + \DeclareUnicodeCharacter{1E56}{\dotaccent{P}} + \DeclareUnicodeCharacter{1E57}{\dotaccent{p}} + \DeclareUnicodeCharacter{1E58}{\dotaccent{R}} + \DeclareUnicodeCharacter{1E59}{\dotaccent{r}} + \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}} + \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}} + \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}} + \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}} + + \DeclareUnicodeCharacter{1E60}{\dotaccent{S}} + \DeclareUnicodeCharacter{1E61}{\dotaccent{s}} + \DeclareUnicodeCharacter{1E62}{\udotaccent{S}} + \DeclareUnicodeCharacter{1E63}{\udotaccent{s}} + \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}} + \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}} + \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}} + \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}} + \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}} + \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}} + + \DeclareUnicodeCharacter{1E7C}{\~V} + \DeclareUnicodeCharacter{1E7D}{\~v} + \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}} + \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}} + + \DeclareUnicodeCharacter{1E80}{\`W} + \DeclareUnicodeCharacter{1E81}{\`w} + \DeclareUnicodeCharacter{1E82}{\'W} + \DeclareUnicodeCharacter{1E83}{\'w} + \DeclareUnicodeCharacter{1E84}{\"W} + \DeclareUnicodeCharacter{1E85}{\"w} + \DeclareUnicodeCharacter{1E86}{\dotaccent{W}} + \DeclareUnicodeCharacter{1E87}{\dotaccent{w}} + \DeclareUnicodeCharacter{1E88}{\udotaccent{W}} + \DeclareUnicodeCharacter{1E89}{\udotaccent{w}} + \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}} + \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}} + \DeclareUnicodeCharacter{1E8C}{\"X} + \DeclareUnicodeCharacter{1E8D}{\"x} + \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}} + \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}} + + \DeclareUnicodeCharacter{1E90}{\^Z} + \DeclareUnicodeCharacter{1E91}{\^z} + \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}} + \DeclareUnicodeCharacter{1E93}{\udotaccent{z}} + \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}} + \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}} + \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}} + \DeclareUnicodeCharacter{1E97}{\"t} + \DeclareUnicodeCharacter{1E98}{\ringaccent{w}} + \DeclareUnicodeCharacter{1E99}{\ringaccent{y}} + + \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}} + \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}} + + \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}} + \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}} + \DeclareUnicodeCharacter{1EBC}{\~E} + \DeclareUnicodeCharacter{1EBD}{\~e} + + \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}} + \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}} + \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}} + \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}} + + \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}} + \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}} + + \DeclareUnicodeCharacter{1EF2}{\`Y} + \DeclareUnicodeCharacter{1EF3}{\`y} + \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}} + + \DeclareUnicodeCharacter{1EF8}{\~Y} + \DeclareUnicodeCharacter{1EF9}{\~y} + + \DeclareUnicodeCharacter{2013}{--} + \DeclareUnicodeCharacter{2014}{---} + \DeclareUnicodeCharacter{2018}{\quoteleft} + \DeclareUnicodeCharacter{2019}{\quoteright} + \DeclareUnicodeCharacter{201A}{\quotesinglbase} + \DeclareUnicodeCharacter{201C}{\quotedblleft} + \DeclareUnicodeCharacter{201D}{\quotedblright} + \DeclareUnicodeCharacter{201E}{\quotedblbase} + \DeclareUnicodeCharacter{2022}{\bullet} + \DeclareUnicodeCharacter{2026}{\dots} + \DeclareUnicodeCharacter{2039}{\guilsinglleft} + \DeclareUnicodeCharacter{203A}{\guilsinglright} + \DeclareUnicodeCharacter{20AC}{\euro} + + \DeclareUnicodeCharacter{2192}{\expansion} + \DeclareUnicodeCharacter{21D2}{\result} + + \DeclareUnicodeCharacter{2212}{\minus} + \DeclareUnicodeCharacter{2217}{\point} + \DeclareUnicodeCharacter{2261}{\equiv} +}% end of \utfeightchardefs + + +% US-ASCII character definitions. +\def\asciichardefs{% nothing need be done + \relax +} + +% Make non-ASCII characters printable again for compatibility with +% existing Texinfo documents that may use them, even without declaring a +% document encoding. +% +\setnonasciicharscatcode \other + + +\message{formatting,} + +\newdimen\defaultparindent \defaultparindent = 15pt + +\chapheadingskip = 15pt plus 4pt minus 2pt +\secheadingskip = 12pt plus 3pt minus 2pt +\subsecheadingskip = 9pt plus 2pt minus 2pt + +% Prevent underfull vbox error messages. +\vbadness = 10000 + +% Don't be very finicky about underfull hboxes, either. +\hbadness = 6666 + +% Following George Bush, get rid of widows and orphans. +\widowpenalty=10000 +\clubpenalty=10000 + +% Use TeX 3.0's \emergencystretch to help line breaking, but if we're +% using an old version of TeX, don't do anything. We want the amount of +% stretch added to depend on the line length, hence the dependence on +% \hsize. We call this whenever the paper size is set. +% +\def\setemergencystretch{% + \ifx\emergencystretch\thisisundefined + % Allow us to assign to \emergencystretch anyway. + \def\emergencystretch{\dimen0}% + \else + \emergencystretch = .15\hsize + \fi +} + +% Parameters in order: 1) textheight; 2) textwidth; +% 3) voffset; 4) hoffset; 5) binding offset; 6) topskip; +% 7) physical page height; 8) physical page width. +% +% We also call \setleading{\textleading}, so the caller should define +% \textleading. The caller should also set \parskip. +% +\def\internalpagesizes#1#2#3#4#5#6#7#8{% + \voffset = #3\relax + \topskip = #6\relax + \splittopskip = \topskip + % + \vsize = #1\relax + \advance\vsize by \topskip + \outervsize = \vsize + \advance\outervsize by 2\topandbottommargin + \pageheight = \vsize + % + \hsize = #2\relax + \outerhsize = \hsize + \advance\outerhsize by 0.5in + \pagewidth = \hsize + % + \normaloffset = #4\relax + \bindingoffset = #5\relax + % + \ifpdf + \pdfpageheight #7\relax + \pdfpagewidth #8\relax + % if we don't reset these, they will remain at "1 true in" of + % whatever layout pdftex was dumped with. + \pdfhorigin = 1 true in + \pdfvorigin = 1 true in + \fi + % + \setleading{\textleading} + % + \parindent = \defaultparindent + \setemergencystretch +} + +% @letterpaper (the default). +\def\letterpaper{{\globaldefs = 1 + \parskip = 3pt plus 2pt minus 1pt + \textleading = 13.2pt + % + % If page is nothing but text, make it come out even. + \internalpagesizes{607.2pt}{6in}% that's 46 lines + {\voffset}{.25in}% + {\bindingoffset}{36pt}% + {11in}{8.5in}% +}} + +% Use @smallbook to reset parameters for 7x9.25 trim size. +\def\smallbook{{\globaldefs = 1 + \parskip = 2pt plus 1pt + \textleading = 12pt + % + \internalpagesizes{7.5in}{5in}% + {-.2in}{0in}% + {\bindingoffset}{16pt}% + {9.25in}{7in}% + % + \lispnarrowing = 0.3in + \tolerance = 700 + \hfuzz = 1pt + \contentsrightmargin = 0pt + \defbodyindent = .5cm +}} + +% Use @smallerbook to reset parameters for 6x9 trim size. +% (Just testing, parameters still in flux.) +\def\smallerbook{{\globaldefs = 1 + \parskip = 1.5pt plus 1pt + \textleading = 12pt + % + \internalpagesizes{7.4in}{4.8in}% + {-.2in}{-.4in}% + {0pt}{14pt}% + {9in}{6in}% + % + \lispnarrowing = 0.25in + \tolerance = 700 + \hfuzz = 1pt + \contentsrightmargin = 0pt + \defbodyindent = .4cm +}} + +% Use @afourpaper to print on European A4 paper. +\def\afourpaper{{\globaldefs = 1 + \parskip = 3pt plus 2pt minus 1pt + \textleading = 13.2pt + % + % Double-side printing via postscript on Laserjet 4050 + % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm. + % To change the settings for a different printer or situation, adjust + % \normaloffset until the front-side and back-side texts align. Then + % do the same for \bindingoffset. You can set these for testing in + % your texinfo source file like this: + % @tex + % \global\normaloffset = -6mm + % \global\bindingoffset = 10mm + % @end tex + \internalpagesizes{673.2pt}{160mm}% that's 51 lines + {\voffset}{\hoffset}% + {\bindingoffset}{44pt}% + {297mm}{210mm}% + % + \tolerance = 700 + \hfuzz = 1pt + \contentsrightmargin = 0pt + \defbodyindent = 5mm +}} + +% Use @afivepaper to print on European A5 paper. +% From romildo@urano.iceb.ufop.br, 2 July 2000. +% He also recommends making @example and @lisp be small. +\def\afivepaper{{\globaldefs = 1 + \parskip = 2pt plus 1pt minus 0.1pt + \textleading = 12.5pt + % + \internalpagesizes{160mm}{120mm}% + {\voffset}{\hoffset}% + {\bindingoffset}{8pt}% + {210mm}{148mm}% + % + \lispnarrowing = 0.2in + \tolerance = 800 + \hfuzz = 1.2pt + \contentsrightmargin = 0pt + \defbodyindent = 2mm + \tableindent = 12mm +}} + +% A specific text layout, 24x15cm overall, intended for A4 paper. +\def\afourlatex{{\globaldefs = 1 + \afourpaper + \internalpagesizes{237mm}{150mm}% + {\voffset}{4.6mm}% + {\bindingoffset}{7mm}% + {297mm}{210mm}% + % + % Must explicitly reset to 0 because we call \afourpaper. + \globaldefs = 0 +}} + +% Use @afourwide to print on A4 paper in landscape format. +\def\afourwide{{\globaldefs = 1 + \afourpaper + \internalpagesizes{241mm}{165mm}% + {\voffset}{-2.95mm}% + {\bindingoffset}{7mm}% + {297mm}{210mm}% + \globaldefs = 0 +}} + +% @pagesizes TEXTHEIGHT[,TEXTWIDTH] +% Perhaps we should allow setting the margins, \topskip, \parskip, +% and/or leading, also. Or perhaps we should compute them somehow. +% +\parseargdef\pagesizes{\pagesizesyyy #1,,\finish} +\def\pagesizesyyy#1,#2,#3\finish{{% + \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi + \globaldefs = 1 + % + \parskip = 3pt plus 2pt minus 1pt + \setleading{\textleading}% + % + \dimen0 = #1\relax + \advance\dimen0 by \voffset + % + \dimen2 = \hsize + \advance\dimen2 by \normaloffset + % + \internalpagesizes{#1}{\hsize}% + {\voffset}{\normaloffset}% + {\bindingoffset}{44pt}% + {\dimen0}{\dimen2}% +}} + +% Set default to letter. +% +\letterpaper + + +\message{and turning on texinfo input format.} + +\def^^L{\par} % remove \outer, so ^L can appear in an @comment + +% DEL is a comment character, in case @c does not suffice. +\catcode`\^^? = 14 + +% Define macros to output various characters with catcode for normal text. +\catcode`\"=\other \def\normaldoublequote{"} +\catcode`\$=\other \def\normaldollar{$}%$ font-lock fix +\catcode`\+=\other \def\normalplus{+} +\catcode`\<=\other \def\normalless{<} +\catcode`\>=\other \def\normalgreater{>} +\catcode`\^=\other \def\normalcaret{^} +\catcode`\_=\other \def\normalunderscore{_} +\catcode`\|=\other \def\normalverticalbar{|} +\catcode`\~=\other \def\normaltilde{~} + +% This macro is used to make a character print one way in \tt +% (where it can probably be output as-is), and another way in other fonts, +% where something hairier probably needs to be done. +% +% #1 is what to print if we are indeed using \tt; #2 is what to print +% otherwise. Since all the Computer Modern typewriter fonts have zero +% interword stretch (and shrink), and it is reasonable to expect all +% typewriter fonts to have this, we can check that font parameter. +% +\def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi} + +% Same as above, but check for italic font. Actually this also catches +% non-italic slanted fonts since it is impossible to distinguish them from +% italic fonts. But since this is only used by $ and it uses \sl anyway +% this is not a problem. +\def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi} + +% Turn off all special characters except @ +% (and those which the user can use as if they were ordinary). +% Most of these we simply print from the \tt font, but for some, we can +% use math or other variants that look better in normal text. + +\catcode`\"=\active +\def\activedoublequote{{\tt\char34}} +\let"=\activedoublequote +\catcode`\~=\active +\def~{{\tt\char126}} +\chardef\hat=`\^ +\catcode`\^=\active +\def^{{\tt \hat}} + +\catcode`\_=\active +\def_{\ifusingtt\normalunderscore\_} +\let\realunder=_ +% Subroutine for the previous macro. +\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em } + +\catcode`\|=\active +\def|{{\tt\char124}} +\chardef \less=`\< +\catcode`\<=\active +\def<{{\tt \less}} +\chardef \gtr=`\> +\catcode`\>=\active +\def>{{\tt \gtr}} +\catcode`\+=\active +\def+{{\tt \char 43}} +\catcode`\$=\active +\def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix + +% If a .fmt file is being used, characters that might appear in a file +% name cannot be active until we have parsed the command line. +% So turn them off again, and have \everyjob (or @setfilename) turn them on. +% \otherifyactive is called near the end of this file. +\def\otherifyactive{\catcode`+=\other \catcode`\_=\other} + +% Used sometimes to turn off (effectively) the active characters even after +% parsing them. +\def\turnoffactive{% + \normalturnoffactive + \otherbackslash +} + +\catcode`\@=0 + +% \backslashcurfont outputs one backslash character in current font, +% as in \char`\\. +\global\chardef\backslashcurfont=`\\ +\global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work + +% \realbackslash is an actual character `\' with catcode other, and +% \doublebackslash is two of them (for the pdf outlines). +{\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}} + +% In texinfo, backslash is an active character; it prints the backslash +% in fixed width font. +\catcode`\\=\active % @ for escape char from now on. + +% The story here is that in math mode, the \char of \backslashcurfont +% ends up printing the roman \ from the math symbol font (because \char +% in math mode uses the \mathcode, and plain.tex sets +% \mathcode`\\="026E). It seems better for @backslashchar{} to always +% print a typewriter backslash, hence we use an explicit \mathchar, +% which is the decimal equivalent of "715c (class 7, e.g., use \fam; +% ignored family value; char position "5C). We can't use " for the +% usual hex value because it has already been made active. +@def@normalbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}} +@let@backslashchar = @normalbackslash % @backslashchar{} is for user documents. + +% On startup, @fixbackslash assigns: +% @let \ = @normalbackslash +% \rawbackslash defines an active \ to do \backslashcurfont. +% \otherbackslash defines an active \ to be a literal `\' character with +% catcode other. We switch back and forth between these. +@gdef@rawbackslash{@let\=@backslashcurfont} +@gdef@otherbackslash{@let\=@realbackslash} + +% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of +% the literal character `\'. +% +@def@normalturnoffactive{% + @let"=@normaldoublequote + @let$=@normaldollar %$ font-lock fix + @let+=@normalplus + @let<=@normalless + @let>=@normalgreater + @let\=@normalbackslash + @let^=@normalcaret + @let_=@normalunderscore + @let|=@normalverticalbar + @let~=@normaltilde + @markupsetuplqdefault + @markupsetuprqdefault + @unsepspaces +} + +% Make _ and + \other characters, temporarily. +% This is canceled by @fixbackslash. +@otherifyactive + +% If a .fmt file is being used, we don't want the `\input texinfo' to show up. +% That is what \eatinput is for; after that, the `\' should revert to printing +% a backslash. +% +@gdef@eatinput input texinfo{@fixbackslash} +@global@let\ = @eatinput + +% On the other hand, perhaps the file did not have a `\input texinfo'. Then +% the first `\' in the file would cause an error. This macro tries to fix +% that, assuming it is called before the first `\' could plausibly occur. +% Also turn back on active characters that might appear in the input +% file name, in case not using a pre-dumped format. +% +@gdef@fixbackslash{% + @ifx\@eatinput @let\ = @normalbackslash @fi + @catcode`+=@active + @catcode`@_=@active +} + +% Say @foo, not \foo, in error messages. +@escapechar = `@@ + +% These (along with & and #) are made active for url-breaking, so need +% active definitions as the normal characters. +@def@normaldot{.} +@def@normalquest{?} +@def@normalslash{/} + +% These look ok in all fonts, so just make them not special. +% @hashchar{} gets its own user-level command, because of #line. +@catcode`@& = @other @def@normalamp{&} +@catcode`@# = @other @def@normalhash{#} +@catcode`@% = @other @def@normalpercent{%} + +@let @hashchar = @normalhash + +@c Finally, make ` and ' active, so that txicodequoteundirected and +@c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we +@c don't make ` and ' active, @code will not get them as active chars. +@c Do this last of all since we use ` in the previous @catcode assignments. +@catcode`@'=@active +@catcode`@`=@active +@markupsetuplqdefault +@markupsetuprqdefault + +@c Local variables: +@c eval: (add-hook 'write-file-hooks 'time-stamp) +@c page-delimiter: "^\\\\message" +@c time-stamp-start: "def\\\\texinfoversion{" +@c time-stamp-format: "%:y-%02m-%02d.%02H" +@c time-stamp-end: "}" +@c End: + +@c vim:sw=2: + +@ignore + arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115 +@end ignore diff --git a/eval.c b/eval.c new file mode 100644 index 0000000..2421aea --- /dev/null +++ b/eval.c @@ -0,0 +1,2778 @@ +/* + * eval.c - gawk bytecode interpreter + */ + +/* + * Copyright (C) 1986, 1988, 1989, 1991-2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "awk.h" + +extern void after_beginfile(IOBUF **curfile); +extern double pow(double x, double y); +extern double modf(double x, double *yp); +extern double fmod(double x, double y); +NODE **fcall_list; +long fcall_count = 0; +int currule = 0; +IOBUF *curfile = NULL; /* current data file */ +int exiting = FALSE; + +#ifdef DEBUGGING +extern int pre_execute(INSTRUCTION **); +extern void post_execute(INSTRUCTION *); +#else +#define r_interpret interpret +#endif + +/* + * Flag which executable this is; done here because eval.c is compiled + * differently for each of them. + */ +enum exe_mode which_gawk = +#ifdef PROFILING + exe_profiling /* pgawk */ +#else +# ifdef DEBUGGING + exe_debugging /* dgawk */ +# else + exe_normal /* normal gawk */ +# endif +#endif + ; /* which_gawk */ + +#if __GNUC__ < 2 +NODE *_t; /* used as a temporary in macros */ +#endif +int OFSlen; +int ORSlen; +int OFMTidx; +int CONVFMTidx; + +/* Profiling stuff */ +#ifdef PROFILING +#define INCREMENT(n) n++ +#else +#define INCREMENT(n) /* nothing */ +#endif + +/* This rather ugly macro is for VMS C */ +#ifdef C +#undef C +#endif +#define C(c) ((char)c) +/* + * This table is used by the regexp routines to do case independent + * matching. Basically, every ascii character maps to itself, except + * uppercase letters map to lower case ones. This table has 256 + * entries, for ISO 8859-1. Note also that if the system this + * is compiled on doesn't use 7-bit ascii, casetable[] should not be + * defined to the linker, so gawk should not load. + * + * Do NOT make this array static, it is used in several spots, not + * just in this file. + * + * 6/2004: + * This table is also used for IGNORECASE for == and !=, and index(). + * Although with GLIBC, we could use tolower() everywhere and RE_ICASE + * for the regex matcher, precomputing this table once gives us a + * performance improvement. I also think it's better for portability + * to non-GLIBC systems. All the world is not (yet :-) GNU/Linux. + */ +#if 'a' == 97 /* it's ascii */ +char casetable[] = { + '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', + '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', + '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', + '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', + /* ' ' '!' '"' '#' '$' '%' '&' ''' */ + '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', + /* '(' ')' '*' '+' ',' '-' '.' '/' */ + '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', + /* '0' '1' '2' '3' '4' '5' '6' '7' */ + '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', + /* '8' '9' ':' ';' '<' '=' '>' '?' */ + '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', + /* '@' 'A' 'B' 'C' 'D' 'E' 'F' 'G' */ + '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + /* 'H' 'I' 'J' 'K' 'L' 'M' 'N' 'O' */ + '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + /* 'P' 'Q' 'R' 'S' 'T' 'U' 'V' 'W' */ + '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + /* 'X' 'Y' 'Z' '[' '\' ']' '^' '_' */ + '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', + /* '`' 'a' 'b' 'c' 'd' 'e' 'f' 'g' */ + '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + /* 'h' 'i' 'j' 'k' 'l' 'm' 'n' 'o' */ + '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + /* 'p' 'q' 'r' 's' 't' 'u' 'v' 'w' */ + '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + /* 'x' 'y' 'z' '{' '|' '}' '~' */ + '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', + + /* Latin 1: */ + C('\200'), C('\201'), C('\202'), C('\203'), C('\204'), C('\205'), C('\206'), C('\207'), + C('\210'), C('\211'), C('\212'), C('\213'), C('\214'), C('\215'), C('\216'), C('\217'), + C('\220'), C('\221'), C('\222'), C('\223'), C('\224'), C('\225'), C('\226'), C('\227'), + C('\230'), C('\231'), C('\232'), C('\233'), C('\234'), C('\235'), C('\236'), C('\237'), + C('\240'), C('\241'), C('\242'), C('\243'), C('\244'), C('\245'), C('\246'), C('\247'), + C('\250'), C('\251'), C('\252'), C('\253'), C('\254'), C('\255'), C('\256'), C('\257'), + C('\260'), C('\261'), C('\262'), C('\263'), C('\264'), C('\265'), C('\266'), C('\267'), + C('\270'), C('\271'), C('\272'), C('\273'), C('\274'), C('\275'), C('\276'), C('\277'), + C('\340'), C('\341'), C('\342'), C('\343'), C('\344'), C('\345'), C('\346'), C('\347'), + C('\350'), C('\351'), C('\352'), C('\353'), C('\354'), C('\355'), C('\356'), C('\357'), + C('\360'), C('\361'), C('\362'), C('\363'), C('\364'), C('\365'), C('\366'), C('\327'), + C('\370'), C('\371'), C('\372'), C('\373'), C('\374'), C('\375'), C('\376'), C('\337'), + C('\340'), C('\341'), C('\342'), C('\343'), C('\344'), C('\345'), C('\346'), C('\347'), + C('\350'), C('\351'), C('\352'), C('\353'), C('\354'), C('\355'), C('\356'), C('\357'), + C('\360'), C('\361'), C('\362'), C('\363'), C('\364'), C('\365'), C('\366'), C('\367'), + C('\370'), C('\371'), C('\372'), C('\373'), C('\374'), C('\375'), C('\376'), C('\377'), +}; +#elif 'a' == 0x81 /* it's EBCDIC */ +char casetable[] = { + /*00 NU SH SX EX PF HT LC DL */ + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, + /*08 SM VT FF CR SO SI */ + 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, + /*10 DE D1 D2 TM RS NL BS IL */ + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, + /*18 CN EM CC C1 FS GS RS US */ + 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, + /*20 DS SS FS BP LF EB EC */ + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, + /*28 SM C2 EQ AK BL */ + 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, + /*30 SY PN RS UC ET */ + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, + /*38 C3 D4 NK SU */ + 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, + /*40 SP */ + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, + /*48 CENT . < ( + | */ + 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, + /*50 & */ + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, + /*58 ! $ * ) ; ^ */ + 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, + /*60 - / */ + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, + /*68 | , % _ > ? */ + 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, + /*70 */ + 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, + /*78 ` : # @ ' = " */ + 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, 0x7F, + /*80 a b c d e f g */ + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + /*88 h i { */ + 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, + /*90 j k l m n o p */ + 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + /*98 q r } */ + 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F, + /*A0 ~ s t u v w x */ + 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, + /*A8 y z [ */ + 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, + /*B0 */ + 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, + /*B8 ] */ + 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, + /*C0 { A B C D E F G */ + 0xC0, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, + /*C8 H I */ + 0x88, 0x89, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, + /*D0 } J K L M N O P */ + 0xD0, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, + /*D8 Q R */ + 0x98, 0x99, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, + /*E0 \ S T U V W X */ + 0xE0, 0xE1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, + /*E8 Y Z */ + 0xA8, 0xA9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, + /*F0 0 1 2 3 4 5 6 7 */ + 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, + /*F8 8 9 */ + 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF +}; +#else +#include "You lose. You will need a translation table for your character set." +#endif + +#undef C + +/* load_casetable --- for a non-ASCII locale, redo the table */ + +void +load_casetable(void) +{ +#if defined(LC_CTYPE) + int i; + char *cp; + static int loaded = FALSE; + + if (loaded || do_traditional) + return; + + loaded = TRUE; + cp = setlocale(LC_CTYPE, NULL); + + /* this is not per standard, but it's pretty safe */ + if (cp == NULL || strcmp(cp, "C") == 0 || strcmp(cp, "POSIX") == 0) + return; + +#ifndef ZOS_USS + for (i = 0200; i <= 0377; i++) { + if (isalpha(i) && islower(i) && i != toupper(i)) + casetable[i] = toupper(i); + } +#endif +#endif +} + +/* + * This table maps node types to strings for debugging. + * KEEP IN SYNC WITH awk.h!!!! + */ + +static const char *const nodetypes[] = { + "Node_illegal", + "Node_val", + "Node_regex", + "Node_dynregex", + "Node_var", + "Node_var_array", + "Node_var_new", + "Node_param_list", + "Node_func", + "Node_hashnode", + "Node_ahash", + "Node_array_ref", + "Node_arrayfor", + "Node_frame", + "Node_instruction", + "Node_final --- this should never appear", + NULL +}; + + +/* + * This table maps Op codes to strings. + * KEEP IN SYNC WITH awk.h!!!! + */ + +static struct optypetab { + char *desc; + char *operator; +} optypes[] = { + { "Op_illegal", NULL }, + { "Op_times", " * " }, + { "Op_times_i", " * " }, + { "Op_quotient", " / " }, + { "Op_quotient_i", " / " }, + { "Op_mod", " % " }, + { "Op_mod_i", " % " }, + { "Op_plus", " + " }, + { "Op_plus_i", " + " }, + { "Op_minus", " - " }, + { "Op_minus_i", " - " }, + { "Op_exp", " ^ " }, + { "Op_exp_i", " ^ " }, + { "Op_concat", " " }, + { "Op_line_range", NULL }, + { "Op_cond_pair", ", " }, + { "Op_subscript", "[]" }, + { "Op_sub_array", "[]" }, + { "Op_preincrement", "++" }, + { "Op_predecrement", "--" }, + { "Op_postincrement", "++" }, + { "Op_postdecrement", "--" }, + { "Op_unary_minus", "-" }, + { "Op_field_spec", "$" }, + { "Op_not", "! " }, + { "Op_assign", " = " }, + { "Op_store_var", " = " }, + { "Op_store_sub", " = " }, + { "Op_store_field", " = " }, + { "Op_assign_times", " *= " }, + { "Op_assign_quotient", " /= " }, + { "Op_assign_mod", " %= " }, + { "Op_assign_plus", " += " }, + { "Op_assign_minus", " -= " }, + { "Op_assign_exp", " ^= " }, + { "Op_assign_concat", " " }, + { "Op_and", " && " }, + { "Op_and_final", NULL }, + { "Op_or", " || " }, + { "Op_or_final", NULL }, + { "Op_equal", " == " }, + { "Op_notequal", " != " }, + { "Op_less", " < " }, + { "Op_greater", " > " }, + { "Op_leq", " <= " }, + { "Op_geq", " >= " }, + { "Op_match", " ~ " }, + { "Op_match_rec", NULL }, + { "Op_nomatch", " !~ " }, + { "Op_rule", NULL }, + { "Op_K_case", "case" }, + { "Op_K_default", "default" }, + { "Op_K_break", "break" }, + { "Op_K_continue", "continue" }, + { "Op_K_print", "print" }, + { "Op_K_print_rec", "print" }, + { "Op_K_printf", "printf" }, + { "Op_K_next", "next" }, + { "Op_K_exit", "exit" }, + { "Op_K_return", "return" }, + { "Op_K_delete", "delete" }, + { "Op_K_delete_loop", NULL }, + { "Op_K_getline_redir", "getline" }, + { "Op_K_getline", "getline" }, + { "Op_K_nextfile", "nextfile" }, + { "Op_builtin", NULL }, + { "Op_sub_builtin", NULL }, + { "Op_in_array", " in " }, + { "Op_func_call", NULL }, + { "Op_indirect_func_call", NULL }, + { "Op_push", NULL }, + { "Op_push_arg", NULL }, + { "Op_push_i", NULL }, + { "Op_push_re", NULL }, + { "Op_push_array", NULL }, + { "Op_push_param", NULL }, + { "Op_push_lhs", NULL }, + { "Op_subscript_lhs", "[]" }, + { "Op_field_spec_lhs", "$" }, + { "Op_no_op", NULL }, + { "Op_pop", NULL }, + { "Op_jmp", NULL }, + { "Op_jmp_true", NULL }, + { "Op_jmp_false", NULL }, + { "Op_get_record", NULL }, + { "Op_newfile", NULL }, + { "Op_arrayfor_init", NULL }, + { "Op_arrayfor_incr", NULL }, + { "Op_arrayfor_final", NULL }, + { "Op_var_update", NULL }, + { "Op_var_assign", NULL }, + { "Op_field_assign", NULL }, + { "Op_after_beginfile", NULL }, + { "Op_after_endfile", NULL }, + { "Op_ext_func", NULL }, + { "Op_func", NULL }, + { "Op_exec_count", NULL }, + { "Op_breakpoint", NULL }, + { "Op_lint", NULL }, + { "Op_atexit", NULL }, + { "Op_stop", NULL }, + { "Op_token", NULL }, + { "Op_symbol", NULL }, + { "Op_list", NULL }, + { "Op_K_do", "do" }, + { "Op_K_for", "for" }, + { "Op_K_arrayfor", "for" }, + { "Op_K_while", "while" }, + { "Op_K_switch", "switch" }, + { "Op_K_if", "if" }, + { "Op_K_else", "else" }, + { "Op_K_function", "function" }, + { "Op_cond_exp", NULL }, + { "Op_final --- this should never appear", NULL }, + { NULL, NULL }, +}; + +/* nodetype2str --- convert a node type into a printable value */ + +const char * +nodetype2str(NODETYPE type) +{ + static char buf[40]; + + if (type >= Node_illegal && type <= Node_final) + return nodetypes[(int) type]; + + sprintf(buf, _("unknown nodetype %d"), (int) type); + return buf; +} + +/* opcode2str --- convert a opcode type into a printable value */ + +const char * +opcode2str(OPCODE op) +{ + if (op >= Op_illegal && op < Op_final) + return optypes[(int) op].desc; + fatal(_("unknown opcode %d"), (int) op); + return NULL; +} + +const char * +op2str(OPCODE op) +{ + if (op >= Op_illegal && op < Op_final) { + if (optypes[(int) op].operator != NULL) + return optypes[(int) op].operator; + else + fatal(_("opcode %s not an operator or keyword"), + optypes[(int) op].desc); + } else + fatal(_("unknown opcode %d"), (int) op); + return NULL; +} + + +/* flags2str --- make a flags value readable */ + +const char * +flags2str(int flagval) +{ + static const struct flagtab values[] = { + { MALLOC, "MALLOC" }, + { PERM, "PERM" }, + { STRING, "STRING" }, + { STRCUR, "STRCUR" }, + { NUMCUR, "NUMCUR" }, + { NUMBER, "NUMBER" }, + { MAYBE_NUM, "MAYBE_NUM" }, + { ARRAYMAXED, "ARRAYMAXED" }, + { FUNC, "FUNC" }, + { FIELD, "FIELD" }, + { INTLSTR, "INTLSTR" }, + { NUMIND, "NUMIND" }, +#ifdef WSTRCUR + { WSTRCUR, "WSTRCUR" }, +#endif + { 0, NULL }, + }; + + return genflags2str(flagval, values); +} + +/* genflags2str --- general routine to convert a flag value to a string */ + +const char * +genflags2str(int flagval, const struct flagtab *tab) +{ + static char buffer[BUFSIZ]; + char *sp; + int i, space_left, space_needed; + + sp = buffer; + space_left = BUFSIZ; + for (i = 0; tab[i].name != NULL; i++) { + if ((flagval & tab[i].val) != 0) { + /* + * note the trick, we want 1 or 0 for whether we need + * the '|' character. + */ + space_needed = (strlen(tab[i].name) + (sp != buffer)); + if (space_left < space_needed) + fatal(_("buffer overflow in genflags2str")); + + if (sp != buffer) { + *sp++ = '|'; + space_left--; + } + strcpy(sp, tab[i].name); + /* note ordering! */ + space_left -= strlen(sp); + sp += strlen(sp); + } + } + + return buffer; +} + +/* posix_compare --- compare strings using strcoll */ + +static int +posix_compare(NODE *s1, NODE *s2) +{ + int ret = 0; + char save1, save2; + size_t l = 0; + + save1 = s1->stptr[s1->stlen]; + s1->stptr[s1->stlen] = '\0'; + + save2 = s2->stptr[s2->stlen]; + s2->stptr[s2->stlen] = '\0'; + + if (gawk_mb_cur_max == 1) { + if (strlen(s1->stptr) == s1->stlen && strlen(s2->stptr) == s2->stlen) + ret = strcoll(s1->stptr, s2->stptr); + else { + char b1[2], b2[2]; + char *p1, *p2; + size_t i; + + if (s1->stlen < s2->stlen) + l = s1->stlen; + else + l = s2->stlen; + + b1[1] = b2[1] = '\0'; + for (i = ret = 0, p1 = s1->stptr, p2 = s2->stptr; + ret == 0 && i < l; + p1++, p2++) { + b1[0] = *p1; + b2[0] = *p2; + ret = strcoll(b1, b2); + } + } + /* + * Either worked through the strings or ret != 0. + * In either case, ret will be the right thing to return. + */ + } +#if MBS_SUPPORT + else { + /* Similar logic, using wide characters */ + (void) force_wstring(s1); + (void) force_wstring(s2); + + if (wcslen(s1->wstptr) == s1->wstlen && wcslen(s2->wstptr) == s2->wstlen) + ret = wcscoll(s1->wstptr, s2->wstptr); + else { + wchar_t b1[2], b2[2]; + wchar_t *p1, *p2; + size_t i; + + if (s1->wstlen < s2->wstlen) + l = s1->wstlen; + else + l = s2->wstlen; + + b1[1] = b2[1] = L'\0'; + for (i = ret = 0, p1 = s1->wstptr, p2 = s2->wstptr; + ret == 0 && i < l; + p1++, p2++) { + b1[0] = *p1; + b2[0] = *p2; + ret = wcscoll(b1, b2); + } + } + /* + * Either worked through the strings or ret != 0. + * In either case, ret will be the right thing to return. + */ + } +#endif + + s1->stptr[s1->stlen] = save1; + s2->stptr[s2->stlen] = save2; + return ret; +} + + +/* cmp_nodes --- compare two nodes, returning negative, 0, positive */ + +int +cmp_nodes(NODE *t1, NODE *t2) +{ + int ret = 0; + size_t len1, len2; + int l, ldiff; + + if (t1 == t2) + return 0; + + if (t1->flags & MAYBE_NUM) + (void) force_number(t1); + if (t2->flags & MAYBE_NUM) + (void) force_number(t2); + if ((t1->flags & NUMBER) && (t2->flags & NUMBER)) { + if (t1->numbr == t2->numbr) + ret = 0; + /* don't subtract, in case one or both are infinite */ + else if (t1->numbr < t2->numbr) + ret = -1; + else + ret = 1; + return ret; + } + + (void) force_string(t1); + (void) force_string(t2); + len1 = t1->stlen; + len2 = t2->stlen; + ldiff = len1 - len2; + if (len1 == 0 || len2 == 0) + return ldiff; + + if (do_posix) + return posix_compare(t1, t2); + + l = (ldiff <= 0 ? len1 : len2); + if (IGNORECASE) { + const unsigned char *cp1 = (const unsigned char *) t1->stptr; + const unsigned char *cp2 = (const unsigned char *) t2->stptr; + +#if MBS_SUPPORT + if (gawk_mb_cur_max > 1) { + ret = strncasecmpmbs((const unsigned char *) cp1, + (const unsigned char *) cp2, l); + } else +#endif + /* Could use tolower() here; see discussion above. */ + for (ret = 0; l-- > 0 && ret == 0; cp1++, cp2++) + ret = casetable[*cp1] - casetable[*cp2]; + } else + ret = memcmp(t1->stptr, t2->stptr, l); + return (ret == 0 ? ldiff : ret); +} + + +#if defined(PROFILING) || defined(DEBUGGING) +static void +push_frame(NODE *f) +{ + static long max_fcall; + + /* NB: frame numbering scheme as in GDB. frame_ptr => frame #0. */ + + fcall_count++; + if (fcall_list == NULL) { + max_fcall = 10; + emalloc(fcall_list, NODE **, (max_fcall + 1) * sizeof(NODE *), "push_frame"); + } else if (fcall_count == max_fcall) { + max_fcall *= 2; + erealloc(fcall_list, NODE **, (max_fcall + 1) * sizeof(NODE *), "push_frame"); + } + + if (fcall_count > 1) + memmove(fcall_list + 2, fcall_list + 1, (fcall_count - 1) * sizeof(NODE *)); + fcall_list[1] = f; +} + +static void +pop_frame() +{ +#ifdef DEBUGGING + extern void frame_popped(); +#endif + if (fcall_count > 1) + memmove(fcall_list + 1, fcall_list + 2, (fcall_count - 1) * sizeof(NODE *)); + fcall_count--; + assert(fcall_count >= 0); +#ifdef DEBUGGING + frame_popped(); +#endif +} +#else /* not PROFILING or DEBUGGING */ +#define push_frame(p) /* nothing */ +#define pop_frame() /* nothing */ +#endif + + +#ifdef PROFILING + +/* dump_fcall_stack --- print a backtrace of the awk function calls */ + +void +dump_fcall_stack(FILE *fp) +{ + NODE *f, *func; + long i = 0; + + if (fcall_count == 0) + return; + fprintf(fp, _("\n\t# Function Call Stack:\n\n")); + + /* current frame */ + func = frame_ptr->func_node; + fprintf(fp, "\t# %3ld. %s\n", i, func->lnode->param); + + /* outer frames except main */ + for (i = 1; i < fcall_count; i++) { + f = fcall_list[i]; + func = f->func_node; + fprintf(fp, "\t# %3ld. %s\n", i, func->lnode->param); + } + + fprintf(fp, "\t# %3ld. -- main --\n", fcall_count); +} + +#endif /* PROFILING */ + +/* set_IGNORECASE --- update IGNORECASE as appropriate */ + +void +set_IGNORECASE() +{ + static short warned = FALSE; + + if ((do_lint || do_traditional) && ! warned) { + warned = TRUE; + lintwarn(_("`IGNORECASE' is a gawk extension")); + } + load_casetable(); + if (do_traditional) + IGNORECASE = FALSE; + else if ((IGNORECASE_node->var_value->flags & (STRING|STRCUR)) != 0) { + if ((IGNORECASE_node->var_value->flags & MAYBE_NUM) == 0) + IGNORECASE = (force_string(IGNORECASE_node->var_value)->stlen > 0); + else + IGNORECASE = (force_number(IGNORECASE_node->var_value) != 0.0); + } else if ((IGNORECASE_node->var_value->flags & (NUMCUR|NUMBER)) != 0) + IGNORECASE = (force_number(IGNORECASE_node->var_value) != 0.0); + else + IGNORECASE = FALSE; /* shouldn't happen */ + + set_RS(); /* set_RS() calls set_FS() if need be, for us */ +} + +/* set_BINMODE --- set translation mode (OS/2, DOS, others) */ + +void +set_BINMODE() +{ + static short warned = FALSE; + char *p; + NODE *v; + + if ((do_lint || do_traditional) && ! warned) { + warned = TRUE; + lintwarn(_("`BINMODE' is a gawk extension")); + } + if (do_traditional) + BINMODE = 0; + else if ((BINMODE_node->var_value->flags & NUMBER) != 0) { + BINMODE = (int) force_number(BINMODE_node->var_value); + /* Make sure the value is rational. */ + if (BINMODE < 0) + BINMODE = 0; + else if (BINMODE > 3) + BINMODE = 3; + } + else if ((BINMODE_node->var_value->flags & STRING) != 0) { + v = BINMODE_node->var_value; + p = v->stptr; + + /* + * Allow only one of the following: + * "0", "1", "2", "3", + * "r", "w", "rw", "wr" + * ANYTHING ELSE goes to 3. So there. + */ + switch (v->stlen) { + case 1: + switch (p[0]) { + case '0': + case '1': + case '2': + case '3': + BINMODE = p[0] - '0'; + break; + case 'r': + BINMODE = 1; + break; + case 'w': + BINMODE = 2; + break; + default: + BINMODE = 3; + goto bad_value; + break; + } + break; + case 2: + switch (p[0]) { + case 'r': + BINMODE = 3; + if (p[1] != 'w') + goto bad_value; + break; + case 'w': + BINMODE = 3; + if (p[1] != 'r') + goto bad_value; + break; + break; + default: + bad_value: + lintwarn(_("BINMODE value `%s' is invalid, treated as 3"), p); + break; + } + } + } + else + BINMODE = 3; /* shouldn't happen */ +} + +/* set_OFS --- update OFS related variables when OFS assigned to */ + +void +set_OFS() +{ + OFS = force_string(OFS_node->var_value)->stptr; + OFSlen = OFS_node->var_value->stlen; + OFS[OFSlen] = '\0'; +} + +/* set_ORS --- update ORS related variables when ORS assigned to */ + +void +set_ORS() +{ + ORS = force_string(ORS_node->var_value)->stptr; + ORSlen = ORS_node->var_value->stlen; + ORS[ORSlen] = '\0'; +} + +/* fmt_ok --- is the conversion format a valid one? */ + +NODE **fmt_list = NULL; +static int fmt_ok(NODE *n); +static int fmt_index(NODE *n); + +static int +fmt_ok(NODE *n) +{ + NODE *tmp = force_string(n); + const char *p = tmp->stptr; +#if ! defined(PRINTF_HAS_F_FORMAT) || PRINTF_HAS_F_FORMAT != 1 + static const char float_formats[] = "efgEG"; +#else + static const char float_formats[] = "efgEFG"; +#endif +#if defined(HAVE_LOCALE_H) + static const char flags[] = " +-#'"; +#else + static const char flags[] = " +-#"; +#endif + + if (*p++ != '%') + return 0; + while (*p && strchr(flags, *p) != NULL) /* flags */ + p++; + while (*p && isdigit((unsigned char) *p)) /* width - %*.*g is NOT allowed */ + p++; + if (*p == '\0' || (*p != '.' && ! isdigit((unsigned char) *p))) + return 0; + if (*p == '.') + p++; + while (*p && isdigit((unsigned char) *p)) /* precision */ + p++; + if (*p == '\0' || strchr(float_formats, *p) == NULL) + return 0; + if (*++p != '\0') + return 0; + return 1; +} + +/* fmt_index --- track values of OFMT and CONVFMT to keep semantics correct */ + +static int +fmt_index(NODE *n) +{ + int ix = 0; + static int fmt_num = 4; + static int fmt_hiwater = 0; + + if (fmt_list == NULL) + emalloc(fmt_list, NODE **, fmt_num*sizeof(*fmt_list), "fmt_index"); + (void) force_string(n); + while (ix < fmt_hiwater) { + if (cmp_nodes(fmt_list[ix], n) == 0) + return ix; + ix++; + } + /* not found */ + n->stptr[n->stlen] = '\0'; + if (do_lint && ! fmt_ok(n)) + lintwarn(_("bad `%sFMT' specification `%s'"), + n == CONVFMT_node->var_value ? "CONV" + : n == OFMT_node->var_value ? "O" + : "", n->stptr); + + if (fmt_hiwater >= fmt_num) { + fmt_num *= 2; + erealloc(fmt_list, NODE **, fmt_num * sizeof(*fmt_list), "fmt_index"); + } + fmt_list[fmt_hiwater] = dupnode(n); + return fmt_hiwater++; +} + +/* set_OFMT --- track OFMT correctly */ + +void +set_OFMT() +{ + OFMTidx = fmt_index(OFMT_node->var_value); + OFMT = fmt_list[OFMTidx]->stptr; +} + +/* set_CONVFMT --- track CONVFMT correctly */ + +void +set_CONVFMT() +{ + CONVFMTidx = fmt_index(CONVFMT_node->var_value); + CONVFMT = fmt_list[CONVFMTidx]->stptr; +} + +/* set_LINT --- update LINT as appropriate */ + +void +set_LINT() +{ +#ifndef NO_LINT + int old_lint = do_lint; + + if ((LINT_node->var_value->flags & (STRING|STRCUR)) != 0) { + if ((LINT_node->var_value->flags & MAYBE_NUM) == 0) { + const char *lintval; + size_t lintlen; + + do_lint = (force_string(LINT_node->var_value)->stlen > 0); + lintval = LINT_node->var_value->stptr; + lintlen = LINT_node->var_value->stlen; + if (do_lint) { + do_lint = LINT_ALL; + if (lintlen == 5 && strncmp(lintval, "fatal", 5) == 0) + lintfunc = r_fatal; + else if (lintlen == 7 && strncmp(lintval, "invalid", 7) == 0) + do_lint = LINT_INVALID; + else + lintfunc = warning; + } else + lintfunc = warning; + } else { + if (force_number(LINT_node->var_value) != 0.0) + do_lint = LINT_ALL; + else + do_lint = FALSE; + lintfunc = warning; + } + } else if ((LINT_node->var_value->flags & (NUMCUR|NUMBER)) != 0) { + if (force_number(LINT_node->var_value) != 0.0) + do_lint = LINT_ALL; + else + do_lint = FALSE; + lintfunc = warning; + } else + do_lint = FALSE; /* shouldn't happen */ + + if (! do_lint) + lintfunc = warning; + + /* explicitly use warning() here, in case lintfunc == r_fatal */ + if (old_lint != do_lint && old_lint && do_lint == FALSE) + warning(_("turning off `--lint' due to assignment to `LINT'")); +#endif /* ! NO_LINT */ +} + +/* set_TEXTDOMAIN --- update TEXTDOMAIN variable when TEXTDOMAIN assigned to */ + +void +set_TEXTDOMAIN() +{ + int len; + + TEXTDOMAIN = force_string(TEXTDOMAIN_node->var_value)->stptr; + len = TEXTDOMAIN_node->var_value->stlen; + TEXTDOMAIN[len] = '\0'; + /* + * Note: don't call textdomain(); this value is for + * the awk program, not for gawk itself. + */ +} + +/* update_ERRNO_saved --- update the value of ERRNO based on argument */ + +void +update_ERRNO_saved(int errcode) +{ + char *cp; + + if (errcode) { + cp = strerror(errcode); + cp = gettext(cp); + } else + cp = ""; + unref(ERRNO_node->var_value); + ERRNO_node->var_value = make_string(cp, strlen(cp)); +} + +/* update_ERRNO --- update the value of ERRNO based on errno */ + +void +update_ERRNO() +{ + update_ERRNO_saved(errno); +} + +/* update_NR --- update the value of NR */ + +void +update_NR() +{ + if (NR_node->var_value->numbr != NR) { + unref(NR_node->var_value); + NR_node->var_value = make_number((AWKNUM) NR); + } +} + +/* update_NF --- update the value of NF */ + +void +update_NF() +{ + if (NF == -1 || NF_node->var_value->numbr != NF) { + if (NF == -1) + (void) get_field(UNLIMITED - 1, NULL); /* parse record */ + unref(NF_node->var_value); + NF_node->var_value = make_number((AWKNUM) NF); + } +} + +/* update_FNR --- update the value of FNR */ + +void +update_FNR() +{ + if (FNR_node->var_value->numbr != FNR) { + unref(FNR_node->var_value); + FNR_node->var_value = make_number((AWKNUM) FNR); + } +} + + + +NODE *frame_ptr; /* current frame */ +STACK_ITEM *stack_ptr = NULL; +STACK_ITEM *stack_bottom; +STACK_ITEM *stack_top; +static unsigned long STACK_SIZE = 256; /* initial size of stack */ +int max_args = 0; /* maximum # of arguments to printf, print, sprintf, + * or # of array subscripts, or adjacent strings + * to be concatenated. + */ +NODE **args_array = NULL; + +/* grow_stack --- grow the size of runtime stack */ + +/* N.B. stack_ptr points to the topmost occupied location + * on the stack, not the first free location. + */ + +STACK_ITEM * +grow_stack() +{ + if (stack_ptr == NULL) { + char *val; + + if ((val = getenv("GAWK_STACKSIZE")) != NULL) { + if (isdigit((unsigned char) *val)) { + unsigned long n = 0; + for (; *val && isdigit((unsigned char) *val); val++) + n = (n * 10) + *val - '0'; + if (n >= 1) + STACK_SIZE = n; + } + } + + emalloc(stack_bottom, STACK_ITEM *, STACK_SIZE * sizeof(STACK_ITEM), "grow_stack"); + stack_ptr = stack_bottom - 1; + stack_top = stack_bottom + STACK_SIZE - 1; + + /* initialize frame pointer */ + getnode(frame_ptr); + frame_ptr->type = Node_frame; + frame_ptr->stack = NULL; + frame_ptr->func_node = NULL; /* in main */ + frame_ptr->vname = NULL; + return stack_ptr; + } + + STACK_SIZE *= 2; + erealloc(stack_bottom, STACK_ITEM *, STACK_SIZE * sizeof(STACK_ITEM), "grow_stack"); + stack_top = stack_bottom + STACK_SIZE - 1; + stack_ptr = stack_bottom + STACK_SIZE / 2; + return stack_ptr; +} + +/* + * r_get_lhs: + * This returns a POINTER to a node pointer (var's value). + * used to store the var's new value. + */ + +NODE ** +r_get_lhs(NODE *n, int reference) +{ + int isparam = FALSE; + + if (n->type == Node_param_list) { + if ((n->flags & FUNC) != 0) + fatal(_("can't use function name `%s' as variable or array"), + n->vname); + isparam = TRUE; + n = GET_PARAM(n->param_cnt); + } + + switch (n->type) { + case Node_var_array: + fatal(_("attempt to use array `%s' in a scalar context"), + array_vname(n)); + case Node_array_ref: + if (n->orig_array->type == Node_var_array) + fatal(_("attempt to use array `%s' in a scalar context"), + array_vname(n)); + n->orig_array->type = Node_var; + n->orig_array->var_value = Nnull_string; + /* fall through */ + case Node_var_new: + n->type = Node_var; + n->var_value = Nnull_string; + break; + + case Node_var: + break; + + default: + cant_happen(); + } + + if (do_lint && reference && var_uninitialized(n)) + lintwarn((isparam ? + _("reference to uninitialized argument `%s'") : + _("reference to uninitialized variable `%s'")), + n->vname); + return &n->var_value; +} + + +/* r_get_field --- get the address of a field node */ + +static inline NODE ** +r_get_field(NODE *n, Func_ptr *assign, int reference) +{ + long field_num; + NODE **lhs; + + if (assign) + *assign = NULL; + if (do_lint) { + if ((n->flags & NUMBER) == 0) { + lintwarn(_("attempt to field reference from non-numeric value")); + if (n->stlen == 0) + lintwarn(_("attempt to field reference from null string")); + } + } + + field_num = (long) force_number(n); + if (field_num < 0) + fatal(_("attempt to access field %ld"), field_num); + + if (field_num == 0 && field0_valid) { /* short circuit */ + lhs = &fields_arr[0]; + if (assign) + *assign = reset_record; + } else + lhs = get_field(field_num, assign); + if (do_lint && reference && (*lhs == Null_field || *lhs == Nnull_string)) + lintwarn(_("reference to uninitialized field `$%ld'"), + field_num); + return lhs; +} + + +/* + * calc_exp_posint --- calculate x^n for positive integral n, + * using exponentiation by squaring without recursion. + */ + +static AWKNUM +calc_exp_posint(AWKNUM x, long n) +{ + AWKNUM mult = 1; + + while (n > 1) { + if ((n % 2) == 1) + mult *= x; + x *= x; + n /= 2; + } + return mult * x; +} + +/* calc_exp --- calculate x1^x2 */ + +AWKNUM +calc_exp(AWKNUM x1, AWKNUM x2) +{ + long lx; + + if ((lx = x2) == x2) { /* integer exponent */ + if (lx == 0) + return 1; + return (lx > 0) ? calc_exp_posint(x1, lx) + : 1.0 / calc_exp_posint(x1, -lx); + } + return (AWKNUM) pow((double) x1, (double) x2); +} + + +/* setup_frame --- setup new frame for function call */ + +static INSTRUCTION * +setup_frame(INSTRUCTION *pc) +{ + NODE *r = NULL; + NODE *m; + NODE *f; + NODE **sp = NULL; + char **varnames; + int pcount, arg_count, i; + + f = pc->func_body; + pcount = f->lnode->param_cnt; + varnames = f->parmlist; + arg_count = (pc + 1)->expr_count; + + /* check for extra args */ + if (arg_count > pcount) { + warning( + _("function `%s' called with more arguments than declared"), + f->vname); + do { + r = POP(); + if (r->type == Node_val) + DEREF(r); + } while (--arg_count > pcount); + } + + if (pcount > 0) { + emalloc(sp, NODE **, pcount * sizeof(NODE *), "setup_frame"); + memset(sp, 0, pcount * sizeof(NODE *)); + } + + for (i = 0; i < pcount; i++) { + getnode(r); + memset(r, 0, sizeof(NODE)); + sp[i] = r; + if (i >= arg_count) { + /* local variable */ + r->type = Node_var_new; + r->vname = varnames[i]; + continue; + } + + m = PEEK(arg_count - i - 1); /* arguments in reverse order on runtime stack */ + + if (m->type == Node_param_list) + m = GET_PARAM(m->param_cnt); + + switch (m->type) { + case Node_var_new: + case Node_var_array: + r->type = Node_array_ref; + r->orig_array = r->prev_array = m; + break; + + case Node_array_ref: + r->type = Node_array_ref; + r->orig_array = m->orig_array; + r->prev_array = m; + break; + + case Node_var: + /* Untyped (Node_var_new) variable as param became a + * scalar during evaluation of expression for a + * subsequent param. + */ + r->type = Node_var; + r->var_value = Nnull_string; + break; + + case Node_val: + r->type = Node_var; + r->var_value = m; + break; + + default: + cant_happen(); + } + r->vname = varnames[i]; + } + stack_adj(-arg_count); /* adjust stack pointer */ + + if (pc->opcode == Op_indirect_func_call) { + r = POP(); /* indirect var */ + DEREF(r); + } + + frame_ptr->vname = source; /* save current source */ + + push_frame(frame_ptr); + + /* save current frame in stack */ + PUSH(frame_ptr); + + /* setup new frame */ + getnode(frame_ptr); + frame_ptr->type = Node_frame; + frame_ptr->stack = sp; + frame_ptr->prev_frame_size = (stack_ptr - stack_bottom); /* size of the previous stack frame */ + frame_ptr->func_node = f; + frame_ptr->vname = NULL; + frame_ptr->reti = pc; /* on return execute pc->nexti */ + + return f->code_ptr; +} + + +/* restore_frame --- clean up the stack and update frame */ + +static INSTRUCTION * +restore_frame(NODE *fp) +{ + NODE *r; + NODE **sp; + int n; + NODE *func; + INSTRUCTION *ri; + + func = frame_ptr->func_node; + n = func->lnode->param_cnt; + sp = frame_ptr->stack; + + for (; n > 0; n--) { + r = *sp++; + if (r->type == Node_var) /* local variable */ + DEREF(r->var_value); + else if (r->type == Node_var_array) /* local array */ + assoc_clear(r); + freenode(r); + } + if (frame_ptr->stack != NULL) + efree(frame_ptr->stack); + ri = frame_ptr->reti; /* execution in calling frame + * resumes from ri->nexti. + */ + freenode(frame_ptr); + pop_frame(); + + /* restore frame */ + frame_ptr = fp; + /* restore source */ + source = fp->vname; + fp->vname = NULL; + + return ri->nexti; +} + + +/* free_arrayfor --- free 'for (var in array)' related data */ + +static inline void +free_arrayfor(NODE *r) +{ + if (r->var_array != NULL) { + size_t num_elems = r->table_size; + NODE **list = r->var_array; + while (num_elems > 0) + unref(list[--num_elems]); + efree(list); + } + freenode(r); +} + + +/* unwind_stack --- pop items off the run-time stack; + * 'n' is the # of items left in the stack. + */ + +INSTRUCTION * +unwind_stack(long n) +{ + NODE *r; + INSTRUCTION *cp = NULL; + STACK_ITEM *sp; + + if (stack_empty()) + return NULL; + + sp = stack_bottom + n; + + if (stack_ptr < sp) + return NULL; + + while ((r = POP()) != NULL) { + switch (r->type) { + case Node_frame: + cp = restore_frame(r); + break; + case Node_arrayfor: + free_arrayfor(r); + break; + case Node_val: + DEREF(r); + break; + case Node_instruction: + freenode(r); + break; + default: + if (in_main_context()) + fatal(_("unwind_stack: unexpected type `%s'"), + nodetype2str(r->type)); + /* else + * Node_var_array, + * Node_param_list, + * Node_var (e.g: trying to use scalar for array) + * Node_regex/Node_dynregex + * ? + */ + break; + } + + if (stack_ptr < sp) + break; + } + return cp; +} + + +/* pop_fcall --- pop off the innermost frame */ +#define pop_fcall() unwind_stack(frame_ptr->prev_frame_size) + +/* pop the run-time stack */ +#define pop_stack() (void) unwind_stack(0) + + +/* + * This generated compiler warnings from GCC 4.4. Who knows why. + * +#define eval_condition(t) (((t)->flags & MAYBE_NUM) && force_number(t), \ + ((t)->flags & NUMBER) ? ((t)->numbr != 0.0) : ((t)->stlen != 0)) +*/ + + +static inline int +eval_condition(NODE *t) +{ + if ((t->flags & MAYBE_NUM) != 0) + force_number(t); + + if ((t->flags & NUMBER) != 0) + return (t->numbr != 0.0); + + return (t->stlen != 0); +} + +/* cmp_scalar -- compare two nodes on the stack */ + +static inline int +cmp_scalar() +{ + NODE *t1, *t2; + int di; + + t2 = POP_SCALAR(); + t1 = TOP(); + if (t1->type == Node_var_array) { + DEREF(t2); + fatal(_("attempt to use array `%s' in a scalar context"), array_vname(t1)); + } + di = cmp_nodes(t1, t2); + DEREF(t1); + DEREF(t2); + return di; +} + +/* op_assign --- assignment operators excluding = */ + +static void +op_assign(OPCODE op) +{ + NODE **lhs; + NODE *r = NULL; + AWKNUM x1, x2; +#ifndef HAVE_FMOD + AWKNUM x; +#endif + + lhs = POP_ADDRESS(); + x1 = force_number(*lhs); + TOP_NUMBER(x2); + unref(*lhs); + switch (op) { + case Op_assign_plus: + r = *lhs = make_number(x1 + x2); + break; + case Op_assign_minus: + r = *lhs = make_number(x1 - x2); + break; + case Op_assign_times: + r = *lhs = make_number(x1 * x2); + break; + case Op_assign_quotient: + if (x2 == (AWKNUM) 0) { + decr_sp(); + fatal(_("division by zero attempted in `/='")); + } + r = *lhs = make_number(x1 / x2); + break; + case Op_assign_mod: + if (x2 == (AWKNUM) 0) { + decr_sp(); + fatal(_("division by zero attempted in `%%='")); + } +#ifdef HAVE_FMOD + r = *lhs = make_number(fmod(x1, x2)); +#else /* ! HAVE_FMOD */ + (void) modf(x1 / x2, &x); + x = x1 - x2 * x; + r = *lhs = make_number(x); +#endif /* ! HAVE_FMOD */ + break; + case Op_assign_exp: + r = *lhs = make_number((AWKNUM) calc_exp((double) x1, (double) x2)); + break; + default: + break; + } + + UPREF(r); + REPLACE(r); +} + + +/* PUSH_CODE --- push a code onto the runtime stack */ + +void +PUSH_CODE(INSTRUCTION *cp) +{ + NODE *r; + getnode(r); + r->type = Node_instruction; + r->code_ptr = cp; + PUSH(r); +} + +/* POP_CODE --- pop a code off the runtime stack */ + +INSTRUCTION * +POP_CODE() +{ + NODE *r; + INSTRUCTION *cp; + r = POP(); + cp = r->code_ptr; + freenode(r); + return cp; +} + + +/* Implementation of BEGINFILE and ENDFILE requires saving an execution + * state and the ability to return to that state. The state is + * defined by the instruction triggering the BEGINFILE/ENDFILE rule, the + * run-time stack, the rule and the source file. The source line is available in + * the instruction and hence is not considered a part of the execution state. + */ + + +typedef struct exec_state { + struct exec_state *next; + + INSTRUCTION *cptr; /* either getline (Op_K_getline) or the + * implicit "open-file, read-record" loop (Op_newfile). + */ + + int rule; /* rule for the INSTRUCTION */ + + long stack_size; /* For this particular usage, it is sufficient to save + * only the size of the call stack. We do not + * store the actual stack pointer to avoid problems + * in case the stack gets realloc-ed. + */ + + const char *source; /* source file for the INSTRUCTION */ +} EXEC_STATE; + +static EXEC_STATE exec_state_stack; + +/* push_exec_state --- save an execution state on stack */ + +static void +push_exec_state(INSTRUCTION *cp, int rule, char *src, STACK_ITEM *sp) +{ + EXEC_STATE *es; + + emalloc(es, EXEC_STATE *, sizeof(EXEC_STATE), "push_exec_state"); + es->rule = rule; + es->cptr = cp; + es->stack_size = (sp - stack_bottom) + 1; + es->source = src; + es->next = exec_state_stack.next; + exec_state_stack.next = es; +} + + +/* pop_exec_state --- pop one execution state off the stack */ + +static INSTRUCTION * +pop_exec_state(int *rule, char **src, long *sz) +{ + INSTRUCTION *cp; + EXEC_STATE *es; + + es = exec_state_stack.next; + if (es == NULL) + return NULL; + cp = es->cptr; + if (rule != NULL) + *rule = es->rule; + if (src != NULL) + *src = (char *) es->source; + if (sz != NULL) + *sz = es->stack_size; + exec_state_stack.next = es->next; + efree(es); + return cp; +} + + +/* + * r_interpret: + * code is a list of instructions to run. returns the exit value + * from the awk code. + */ + + /* N.B.: + * 1) reference counting done for both number and string values. + * 2) TEMP flag no longer needed (consequence of the above; valref = 0 + * is the replacement). + * 3) Stack operations: + * Use REPLACE[_XX] if last stack operation was TOP[_XX], + * PUSH[_XX] if last operation was POP[_XX] instead. + * 4) UPREF and DREF -- see awk.h + */ + + +int +r_interpret(INSTRUCTION *code) +{ + INSTRUCTION *pc; /* current instruction */ + NODE *r = NULL; + NODE *m; + INSTRUCTION *ni; + NODE *t1, *t2; + NODE *f; /* function definition */ + NODE **lhs; + AWKNUM x, x1, x2; + int di, pre = FALSE; + Regexp *rp; +#if defined(GAWKDEBUG) || defined(ARRAYDEBUG) + int last_was_stopme = FALSE; /* builtin stopme() called ? */ +#endif + int stdio_problem = FALSE; + + + if (args_array == NULL) + emalloc(args_array, NODE **, (max_args + 2)*sizeof(NODE *), "r_interpret"); + else + erealloc(args_array, NODE **, (max_args + 2)*sizeof(NODE *), "r_interpret"); + +/* array subscript */ +#define mk_sub(n) (n == 1 ? POP_STRING() : concat_exp(n, TRUE)) + +#ifdef DEBUGGING +#define JUMPTO(x) do { post_execute(pc); pc = (x); goto top; } while(FALSE) +#else +#define JUMPTO(x) do { pc = (x); goto top; } while(FALSE) +#endif + + pc = code; + + /* N.B.: always use JUMPTO for next instruction, otherwise bad things + * may happen. DO NOT add a real loop (for/while) below to + * replace ' forever {'; this catches failure to use JUMPTO to execute + * next instruction (e.g. continue statement). + */ + + /* loop until hit Op_stop instruction */ + + /* forever { */ +top: + if (pc->source_line > 0) + sourceline = pc->source_line; + +#ifdef DEBUGGING + if (! pre_execute(&pc)) + goto top; +#endif + + switch (pc->opcode) { + case Op_rule: + currule = pc->in_rule; /* for sole use in Op_K_next, Op_K_nextfile, Op_K_getline* */ + /* fall through */ + case Op_func: + case Op_ext_func: + source = pc->source_file; + break; + + case Op_atexit: + /* avoid false source indications */ + source = NULL; + sourceline = 0; + (void) nextfile(&curfile, TRUE); /* close input data file */ + /* + * This used to be: + * + * if (close_io() != 0 && ! exiting && exit_val == 0) + * exit_val = 1; + * + * Other awks don't care about problems closing open files + * and pipes, in that it doesn't affect their exit status. + * So we no longer do either. + */ + (void) close_io(& stdio_problem); + /* + * However, we do want to exit non-zero if there was a problem + * with stdout/stderr, so we reinstate a slightly different + * version of the above: + */ + if (stdio_problem && ! exiting && exit_val == 0) + exit_val = 1; + break; + + case Op_stop: + return 0; + + case Op_push_i: + m = pc->memory; + PUSH((m->flags & INTLSTR) != 0 ? format_val(CONVFMT, CONVFMTidx, m): m); + break; + + case Op_push: + case Op_push_arg: + { + NODE *save_symbol; + int isparam = FALSE; + + save_symbol = m = pc->memory; + if (m->type == Node_param_list) { + if ((m->flags & FUNC) != 0) + fatal(_("can't use function name `%s' as variable or array"), + m->vname); + isparam = TRUE; + save_symbol = m = GET_PARAM(m->param_cnt); + if (m->type == Node_array_ref) + m = m->orig_array; + } + + switch (m->type) { + case Node_var: + if (do_lint && var_uninitialized(m)) + lintwarn(isparam ? + _("reference to uninitialized argument `%s'") : + _("reference to uninitialized variable `%s'"), + save_symbol->vname); + m = m->var_value; + UPREF(m); + PUSH(m); + break; + + case Node_var_new: + m->type = Node_var; + m->var_value = Nnull_string; + if (do_lint) + lintwarn(isparam ? + _("reference to uninitialized argument `%s'") : + _("reference to uninitialized variable `%s'"), + save_symbol->vname); + PUSH(Nnull_string); + break; + + case Node_var_array: + if (pc->opcode == Op_push_arg) + PUSH(m); + else + fatal(_("attempt to use array `%s' in a scalar context"), + array_vname(save_symbol)); + break; + + default: + cant_happen(); + } + } + break; + + case Op_push_param: /* function argument */ + m = pc->memory; + if (m->type == Node_param_list) + m = GET_PARAM(m->param_cnt); + if (m->type == Node_var) { + m = m->var_value; + UPREF(m); + PUSH(m); + break; + } + /* else + fall through */ + case Op_push_array: + PUSH(pc->memory); + break; + + case Op_push_lhs: + lhs = get_lhs(pc->memory, pc->do_reference); + PUSH_ADDRESS(lhs); + break; + + case Op_subscript: + t2 = mk_sub(pc->sub_count); + t1 = POP_ARRAY(); + r = *assoc_lookup(t1, t2, TRUE); + DEREF(t2); + if (r->type == Node_val) + UPREF(r); + PUSH(r); + break; + + case Op_sub_array: + t2 = mk_sub(pc->sub_count); + t1 = POP_ARRAY(); + r = in_array(t1, t2); + if (r == NULL) { + getnode(r); + r->type = Node_var_array; + r->var_array = NULL; + r->vname = estrdup(t2->stptr, t2->stlen); /* the subscript in parent array */ + r->parent_array = t1; + *assoc_lookup(t1, t2, FALSE) = r; + } else if (r->type != Node_var_array) + fatal(_("attempt to use scalar `%s[\"%.*s\"]' as an array"), + array_vname(t1), (int) t2->stlen, t2->stptr); + DEREF(t2); + PUSH(r); + break; + + case Op_subscript_lhs: + t2 = mk_sub(pc->sub_count); + t1 = POP_ARRAY(); + lhs = assoc_lookup(t1, t2, pc->do_reference); + if ((*lhs)->type == Node_var_array) + fatal(_("attempt to use array `%s[\"%.*s\"]' in a scalar context"), + array_vname(t1), (int) t2->stlen, t2->stptr); + DEREF(t2); + PUSH_ADDRESS(lhs); + break; + + case Op_field_spec: + t1 = TOP_SCALAR(); + lhs = r_get_field(t1, (Func_ptr *) 0, TRUE); + decr_sp(); + DEREF(t1); + /* This used to look like this: + PUSH(dupnode(*lhs)); + but was changed to bypass an apparent bug in the z/OS C compiler. + Please do not remerge. */ + r = dupnode(*lhs); /* can't use UPREF here */ + PUSH(r); + break; + + case Op_field_spec_lhs: + t1 = TOP_SCALAR(); + lhs = r_get_field(t1, &pc->target_assign->field_assign, pc->do_reference); + decr_sp(); + DEREF(t1); + PUSH_ADDRESS(lhs); + break; + + case Op_lint: + if (do_lint) { + switch (pc->lint_type) { + case LINT_assign_in_cond: + lintwarn(_("assignment used in conditional context")); + break; + + case LINT_no_effect: + lintwarn(_("statement has no effect")); + break; + + default: + cant_happen(); + } + } + break; + + case Op_K_break: + case Op_K_continue: + case Op_jmp: + JUMPTO(pc->target_jmp); + + case Op_jmp_false: + r = POP_SCALAR(); + di = eval_condition(r); + DEREF(r); + if (! di) + JUMPTO(pc->target_jmp); + break; + + case Op_jmp_true: + r = POP_SCALAR(); + di = eval_condition(r); + DEREF(r); + if (di) + JUMPTO(pc->target_jmp); + break; + + case Op_and: + case Op_or: + t1 = POP_SCALAR(); + di = eval_condition(t1); + DEREF(t1); + if ((pc->opcode == Op_and && di) + || (pc->opcode == Op_or && ! di)) + break; + r = make_number((AWKNUM) di); + PUSH(r); + ni = pc->target_jmp; + JUMPTO(ni->nexti); + + case Op_and_final: + case Op_or_final: + t1 = TOP_SCALAR(); + r = make_number((AWKNUM) eval_condition(t1)); + DEREF(t1); + REPLACE(r); + break; + + case Op_not: + t1 = TOP_SCALAR(); + r = make_number((AWKNUM) ! eval_condition(t1)); + DEREF(t1); + REPLACE(r); + break; + + case Op_equal: + r = make_number((AWKNUM) (cmp_scalar() == 0)); + REPLACE(r); + break; + + case Op_notequal: + r = make_number((AWKNUM) (cmp_scalar() != 0)); + REPLACE(r); + break; + + case Op_less: + r = make_number((AWKNUM) (cmp_scalar() < 0)); + REPLACE(r); + break; + + case Op_greater: + r = make_number((AWKNUM) (cmp_scalar() > 0)); + REPLACE(r); + break; + + case Op_leq: + r = make_number((AWKNUM) (cmp_scalar() <= 0)); + REPLACE(r); + break; + + case Op_geq: + r = make_number((AWKNUM) (cmp_scalar() >= 0)); + REPLACE(r); + break; + + case Op_plus_i: + x2 = force_number(pc->memory); + goto plus; + + case Op_plus: + POP_NUMBER(x2); +plus: + TOP_NUMBER(x1); + r = make_number(x1 + x2); + REPLACE(r); + break; + + case Op_minus_i: + x2 = force_number(pc->memory); + goto minus; + + case Op_minus: + POP_NUMBER(x2); +minus: + TOP_NUMBER(x1); + r = make_number(x1 - x2); + REPLACE(r); + break; + + case Op_times_i: + x2 = force_number(pc->memory); + goto times; + + case Op_times: + POP_NUMBER(x2); +times: + TOP_NUMBER(x1); + r = make_number(x1 * x2); + REPLACE(r); + break; + + case Op_exp_i: + x2 = force_number(pc->memory); + goto exponent; + + case Op_exp: + POP_NUMBER(x2); +exponent: + TOP_NUMBER(x1); + x = calc_exp(x1, x2); + r = make_number(x); + REPLACE(r); + break; + + case Op_quotient_i: + x2 = force_number(pc->memory); + goto quotient; + + case Op_quotient: + POP_NUMBER(x2); +quotient: + if (x2 == 0) + fatal(_("division by zero attempted")); + + TOP_NUMBER(x1); + x = x1 / x2; + r = make_number(x); + REPLACE(r); + break; + + case Op_mod_i: + x2 = force_number(pc->memory); + goto mod; + + case Op_mod: + POP_NUMBER(x2); +mod: + if (x2 == 0) + fatal(_("division by zero attempted in `%%'")); + + TOP_NUMBER(x1); +#ifdef HAVE_FMOD + x = fmod(x1, x2); +#else /* ! HAVE_FMOD */ + (void) modf(x1 / x2, &x); + x = x1 - x * x2; +#endif /* ! HAVE_FMOD */ + r = make_number(x); + REPLACE(r); + break; + + case Op_preincrement: + pre = TRUE; + case Op_postincrement: + x2 = 1.0; +post: + lhs = TOP_ADDRESS(); + x1 = force_number(*lhs); + unref(*lhs); + r = *lhs = make_number(x1 + x2); + if (pre) + UPREF(r); + else + r = make_number(x1); + REPLACE(r); + pre = FALSE; + break; + + case Op_predecrement: + pre = TRUE; + case Op_postdecrement: + x2 = -1.0; + goto post; + + case Op_unary_minus: + TOP_NUMBER(x1); + r = make_number(-x1); + REPLACE(r); + break; + + case Op_store_sub: + /* array[sub] assignment optimization, + * see awkgram.y (optimize_assignment) + */ + t1 = get_array(pc->memory, TRUE); /* array */ + t2 = mk_sub(pc->expr_count); /* subscript */ + lhs = assoc_lookup(t1, t2, FALSE); + if ((*lhs)->type == Node_var_array) + fatal(_("attempt to use array `%s[\"%.*s\"]' in a scalar context"), + array_vname(t1), (int) t2->stlen, t2->stptr); + DEREF(t2); + unref(*lhs); + *lhs = POP_SCALAR(); + break; + + case Op_store_var: + /* simple variable assignment optimization, + * see awkgram.y (optimize_assignment) + */ + + lhs = get_lhs(pc->memory, FALSE); + unref(*lhs); + *lhs = POP_SCALAR(); + break; + + case Op_store_field: + { + /* field assignment optimization, + * see awkgram.y (optimize_assignment) + */ + + Func_ptr assign; + t1 = TOP_SCALAR(); + lhs = r_get_field(t1, &assign, FALSE); + decr_sp(); + DEREF(t1); + unref(*lhs); + *lhs = POP_SCALAR(); + assert(assign != NULL); + assign(); + } + break; + + case Op_assign_concat: + /* x = x ... string concatenation optimization */ + lhs = get_lhs(pc->memory, FALSE); + t1 = force_string(*lhs); + t2 = POP_STRING(); + + free_wstr(*lhs); + + if (t1 != t2 && t1->valref == 1 && (t1->flags & PERM) == 0) { + size_t nlen = t1->stlen + t2->stlen; + erealloc(t1->stptr, char *, nlen + 2, "r_interpret"); + memcpy(t1->stptr + t1->stlen, t2->stptr, t2->stlen); + t1->stlen = nlen; + t1->stptr[nlen] = '\0'; + } else { + size_t nlen = t1->stlen + t2->stlen; + char *p; + + emalloc(p, char *, nlen + 2, "r_interpret"); + memcpy(p, t1->stptr, t1->stlen); + memcpy(p + t1->stlen, t2->stptr, t2->stlen); + unref(*lhs); + t1 = *lhs = make_str_node(p, nlen, ALREADY_MALLOCED); + } + t1->flags &= ~(NUMCUR|NUMBER); + DEREF(t2); + break; + + case Op_assign: + lhs = POP_ADDRESS(); + r = TOP_SCALAR(); + unref(*lhs); + *lhs = r; + UPREF(r); + REPLACE(r); + break; + + /* numeric assignments */ + case Op_assign_plus: + case Op_assign_minus: + case Op_assign_times: + case Op_assign_quotient: + case Op_assign_mod: + case Op_assign_exp: + op_assign(pc->opcode); + break; + + case Op_var_update: /* update value of NR, FNR or NF */ + pc->update_var(); + break; + + case Op_var_assign: + case Op_field_assign: + if (pc->assign_ctxt == Op_sub_builtin + && TOP()->numbr == 0.0 /* top of stack has a number == 0 */ + ) { + /* There wasn't any substitutions. If the target is a FIELD, + * this means no field re-splitting or $0 reconstruction. + * Skip the set_FOO routine if the target is a special variable. + */ + + break; + } else if ((pc->assign_ctxt == Op_K_getline + || pc->assign_ctxt == Op_K_getline_redir) + && TOP()->numbr <= 0.0 /* top of stack has a number <= 0 */ + ) { + /* getline returned EOF or error */ + + break; + } + + if (pc->opcode == Op_var_assign) + pc->assign_var(); + else + pc->field_assign(); + break; + + case Op_concat: + r = concat_exp(pc->expr_count, pc->concat_flag & CSUBSEP); + PUSH(r); + break; + + case Op_K_case: + if ((pc + 1)->match_exp) { + /* match a constant regex against switch expression instead of $0. */ + m = POP(); /* regex */ + t2 = TOP_SCALAR(); /* switch expression */ + (void) force_string(t2); + rp = re_update(m); + di = (research(rp, t2->stptr, 0, t2->stlen, + avoid_dfa(m, t2->stptr, t2->stlen)) >= 0); + } else { + t1 = POP_SCALAR(); /* case value */ + t2 = TOP_SCALAR(); /* switch expression */ + di = (cmp_nodes(t2, t1) == 0); + DEREF(t1); + } + + if (di) { /* match found */ + decr_sp(); + DEREF(t2); + JUMPTO(pc->target_jmp); + } + break; + + case Op_K_delete: + t1 = POP_ARRAY(); + do_delete(t1, pc->expr_count); + stack_adj(-pc->expr_count); + break; + + case Op_K_delete_loop: + t1 = POP_ARRAY(); + lhs = POP_ADDRESS(); /* item */ + do_delete_loop(t1, lhs); + break; + + case Op_in_array: + t1 = POP_ARRAY(); + t2 = mk_sub(pc->expr_count); + di = (in_array(t1, t2) != NULL); + DEREF(t2); + PUSH(make_number((AWKNUM) di)); + break; + + case Op_arrayfor_init: + { + NODE **list = NULL; + NODE *array, *sort_str; + size_t num_elems = 0; + static NODE *sorted_in = NULL; + const char *how_to_sort = "@unsorted"; + + /* get the array */ + array = POP_ARRAY(); + + /* sanity: check if empty */ + if (array->var_array == NULL || array->table_size == 0) + goto arrayfor; + + num_elems = array->table_size; + + if (sorted_in == NULL) /* do this once */ + sorted_in = make_string("sorted_in", 9); + + sort_str = NULL; + /* + * If posix, or if there's no PROCINFO[], + * there's no ["sorted_in"], so no sorting + */ + if (! do_posix && PROCINFO_node != NULL) + sort_str = in_array(PROCINFO_node, sorted_in); + + if (sort_str != NULL) { + sort_str = force_string(sort_str); + if (sort_str->stlen > 0) + how_to_sort = sort_str->stptr; + } + + list = assoc_list(array, how_to_sort, SORTED_IN); + + /* + * Actual array for use in lint warning + * in Op_arrayfor_incr + */ + list[num_elems] = array; + +arrayfor: + getnode(r); + r->type = Node_arrayfor; + r->var_array = list; + r->table_size = num_elems; /* # of elements in list */ + r->array_size = -1; /* current index */ + PUSH(r); + + if (num_elems == 0) + JUMPTO(pc->target_jmp); /* Op_arrayfor_final */ + } + break; + + case Op_arrayfor_incr: + r = TOP(); /* Node_arrayfor */ + if (++r->array_size == r->table_size) { + NODE *array; + array = r->var_array[r->table_size]; /* actual array */ + if (do_lint && array->table_size != r->table_size) + lintwarn(_("for loop: array `%s' changed size from %ld to %ld during loop execution"), + array_vname(array), (long) r->table_size, (long) array->table_size); + JUMPTO(pc->target_jmp); /* Op_arrayfor_final */ + } + + t1 = r->var_array[r->array_size]; + lhs = get_lhs(pc->array_var, FALSE); + unref(*lhs); + *lhs = make_string(t1->ahname_str, t1->ahname_len); + break; + + case Op_arrayfor_final: + r = POP(); + assert(r->type == Node_arrayfor); + free_arrayfor(r); + break; + + case Op_builtin: + r = pc->builtin(pc->expr_count); +#if defined(GAWKDEBUG) || defined(ARRAYDEBUG) + if (! r) + last_was_stopme = TRUE; + else +#endif + PUSH(r); + break; + + case Op_sub_builtin: /* sub, gsub and gensub */ + r = do_sub(pc->expr_count, pc->sub_flags); + PUSH(r); + break; + + case Op_K_print: + do_print(pc->expr_count, pc->redir_type); + break; + + case Op_K_printf: + do_printf(pc->expr_count, pc->redir_type); + break; + + case Op_K_print_rec: + do_print_rec(pc->expr_count, pc->redir_type); + break; + + case Op_push_re: + m = pc->memory; + if (m->type == Node_dynregex) { + r = POP_STRING(); + unref(m->re_exp); + m->re_exp = r; + } + PUSH(m); + break; + + case Op_match_rec: + m = pc->memory; + t1 = *get_field(0, (Func_ptr *) 0); +match_re: + rp = re_update(m); + /* + * Any place where research() is called with a last parameter of + * zero, we need to use the avoid_dfa test. This appears here and + * in the code for Op_K_case. + * + * A new or improved dfa that distinguishes beginning/end of + * string from beginning/end of line will allow us to get rid of + * this hack. + * + * The avoid_dfa() function is in re.c; it is not very smart. + */ + + di = research(rp, t1->stptr, 0, t1->stlen, + avoid_dfa(m, t1->stptr, t1->stlen)); + di = (di == -1) ^ (pc->opcode != Op_nomatch); + if(pc->opcode != Op_match_rec) { + decr_sp(); + DEREF(t1); + } + r = make_number((AWKNUM) di); + PUSH(r); + break; + + case Op_nomatch: + /* fall through */ + case Op_match: + m = pc->memory; + t1 = TOP_STRING(); + if (m->type == Node_dynregex) { + unref(m->re_exp); + m->re_exp = t1; + decr_sp(); + t1 = TOP_STRING(); + } + goto match_re; + break; + + case Op_indirect_func_call: + { + int arg_count; + + f = NULL; + arg_count = (pc + 1)->expr_count; + t1 = PEEK(arg_count); /* indirect var */ + assert(t1->type == Node_val); /* @a[1](p) not allowed in grammar */ + (void) force_string(t1); + if (t1->stlen > 0) { + /* retrieve function definition node */ + f = pc->func_body; + if (f != NULL && strcmp(f->vname, t1->stptr) == 0) + /* indirect var hasn't been reassigned */ + goto func_call; + f = lookup(t1->stptr); + } + + if (f == NULL || f->type != Node_func) + fatal(_("function called indirectly through `%s' does not exist"), pc->func_name); + pc->func_body = f; /* save for next call */ + + goto func_call; + } + + case Op_func_call: + /* retrieve function definition node */ + f = pc->func_body; + if (f == NULL) { + f = lookup(pc->func_name); + if (f == NULL || f->type != Node_func) + fatal(_("function `%s' not defined"), pc->func_name); + pc->func_body = f; /* save for next call */ + } + + /* save current frame along with source */ + +func_call: + ni = setup_frame(pc); + + if (ni->opcode == Op_ext_func) { + /* dynamically set source and line numbers for an extension builtin. */ + ni->source_file = source; + ni->source_line = sourceline; + ni->nexti->source_line = sourceline; /* Op_builtin */ + ni->nexti->nexti->source_line = sourceline; /* Op_K_return */ + } + + /* run the function instructions */ + JUMPTO(ni); /* Op_func or Op_ext_func */ + + case Op_K_return: + m = POP_SCALAR(); /* return value */ + + ni = pop_fcall(); + + /* put the return value back on stack */ + PUSH(m); + + JUMPTO(ni); + + case Op_K_getline_redir: + if ((currule == BEGINFILE || currule == ENDFILE) + && pc->into_var == FALSE + && pc->redir_type == redirect_input) + fatal(_("`getline' invalid inside `%s' rule"), ruletab[currule]); + r = do_getline_redir(pc->into_var, pc->redir_type); + PUSH(r); + break; + + case Op_K_getline: /* no redirection */ + if (! currule || currule == BEGINFILE || currule == ENDFILE) + fatal(_("non-redirected `getline' invalid inside `%s' rule"), + ruletab[currule]); + + do { + int ret; + ret = nextfile(& curfile, FALSE); + if (ret <= 0) + r = do_getline(pc->into_var, curfile); + else { + + /* Save execution state so that we can return to it + * from Op_after_beginfile or Op_after_endfile. + */ + + push_exec_state(pc, currule, source, stack_ptr); + + if (curfile == NULL) + JUMPTO((pc + 1)->target_endfile); + else + JUMPTO((pc + 1)->target_beginfile); + } + } while (r == NULL); /* EOF */ + + PUSH(r); + break; + + case Op_after_endfile: + /* Find the execution state to return to */ + ni = pop_exec_state(& currule, & source, NULL); + + assert(ni->opcode == Op_newfile || ni->opcode == Op_K_getline); + JUMPTO(ni); + + case Op_after_beginfile: + after_beginfile(& curfile); + + /* Find the execution state to return to */ + ni = pop_exec_state(& currule, & source, NULL); + + assert(ni->opcode == Op_newfile || ni->opcode == Op_K_getline); + if (ni->opcode == Op_K_getline + || curfile == NULL /* skipping directory argument */ + ) + JUMPTO(ni); + + break; /* read a record, Op_get_record */ + + case Op_newfile: + { + int ret; + + ret = nextfile(& curfile, FALSE); + + if (ret < 0) /* end of input */ + JUMPTO(pc->target_jmp); /* end block or Op_atexit */ + + if (ret == 0) /* read a record */ + JUMPTO((pc + 1)->target_get_record); + + /* ret > 0 */ + /* Save execution state for use in Op_after_beginfile or Op_after_endfile. */ + + push_exec_state(pc, currule, source, stack_ptr); + + if (curfile == NULL) /* EOF */ + JUMPTO(pc->target_endfile); + /* else + execute beginfile block */ + } + break; + + case Op_get_record: + { + int errcode = 0; + + ni = pc->target_newfile; + if (curfile == NULL) { + /* from non-redirected getline, e.g.: + * { + * while (getline > 0) ; + * } + */ + + ni = ni->target_jmp; /* end_block or Op_atexit */ + JUMPTO(ni); + } + + if (inrec(curfile, & errcode) != 0) { + if (errcode > 0 && (do_traditional || ! pc->has_endfile)) + fatal(_("error reading input file `%s': %s"), + curfile->name, strerror(errcode)); + + JUMPTO(ni); + } /* else + prog (rule) block */ + } + break; + + case Op_K_nextfile: + { + int ret; + + if (currule != Rule && currule != BEGINFILE) + fatal(_("`nextfile' cannot be called from a `%s' rule"), + ruletab[currule]); + + ret = nextfile(& curfile, TRUE); /* skip current file */ + + if (currule == BEGINFILE) { + long stack_size; + + ni = pop_exec_state(& currule, & source, & stack_size); + + assert(ni->opcode == Op_K_getline || ni->opcode == Op_newfile); + + /* pop stack returning to the state of Op_K_getline or Op_newfile. */ + unwind_stack(stack_size); + + if (ret == 0) { + /* There was an error opening the file; + * don't run ENDFILE block(s). + */ + + JUMPTO(ni); + } else { + /* do run ENDFILE block(s) first. */ + + /* Execution state to return to in Op_after_endfile. */ + push_exec_state(ni, currule, source, stack_ptr); + + JUMPTO(pc->target_endfile); + } + } /* else + Start over with the first rule. */ + + /* empty the run-time stack to avoid memory leak */ + pop_stack(); + + /* Push an execution state for Op_after_endfile to return to */ + push_exec_state(pc->target_newfile, currule, source, stack_ptr); + + JUMPTO(pc->target_endfile); + } + break; + + case Op_K_exit: + /* exit not allowed in user-defined comparison functions for "sorted_in"; + * This is done so that END blocks aren't executed more than once. + */ + if (! currule) + fatal(_("`exit' cannot be called in the current context")); + + exiting = TRUE; + POP_NUMBER(x1); + exit_val = (int) x1; +#ifdef VMS + if (exit_val == 0) + exit_val = EXIT_SUCCESS; + else if (exit_val == 1) + exit_val = EXIT_FAILURE; + /* else + just pass anything else on through */ +#endif + + if (currule == BEGINFILE || currule == ENDFILE) { + + /* Find the rule of the saved execution state (Op_K_getline/Op_newfile). + * This is needed to prevent multiple execution of any END rules: + * gawk 'BEGINFILE { exit(1) } \ + * END { while (getline > 0); }' in1 in2 + */ + + (void) pop_exec_state(& currule, & source, NULL); + } + + pop_stack(); /* empty stack, don't leak memory */ + + /* Jump to either the first END block instruction + * or to Op_atexit. + */ + + if (currule == END) + ni = pc->target_atexit; + else + ni = pc->target_end; + JUMPTO(ni); + + case Op_K_next: + if (currule != Rule) + fatal(_("`next' cannot be called from a `%s' rule"), ruletab[currule]); + + pop_stack(); + JUMPTO(pc->target_jmp); /* Op_get_record, read next record */ + + case Op_pop: +#if defined(GAWKDEBUG) || defined(ARRAYDEBUG) + if (last_was_stopme) + last_was_stopme = FALSE; + else +#endif + { + r = POP_SCALAR(); + DEREF(r); + } + break; + + case Op_line_range: + if (pc->triggered) /* evaluate right expression */ + JUMPTO(pc->target_jmp); + /* else + evaluate left expression */ + break; + + case Op_cond_pair: + { + int result; + INSTRUCTION *ip; + + t1 = TOP_SCALAR(); /* from right hand side expression */ + di = (eval_condition(t1) != 0); + DEREF(t1); + + ip = pc->line_range; /* Op_line_range */ + + if (! ip->triggered && di) { + /* not already triggered and left expression is TRUE */ + decr_sp(); + ip->triggered = TRUE; + JUMPTO(ip->target_jmp); /* evaluate right expression */ + } + + result = ip->triggered || di; + ip->triggered ^= di; /* update triggered flag */ + r = make_number((AWKNUM) result); /* final value of condition pair */ + REPLACE(r); + JUMPTO(pc->target_jmp); + } + + case Op_exec_count: + INCREMENT(pc->exec_count); + break; + + case Op_no_op: + case Op_K_do: + case Op_K_while: + case Op_K_for: + case Op_K_arrayfor: + case Op_K_switch: + case Op_K_default: + case Op_K_if: + case Op_K_else: + case Op_cond_exp: + break; + + default: + fatal(_("Sorry, don't know how to interpret `%s'"), opcode2str(pc->opcode)); + } + + JUMPTO(pc->nexti); + +/* } forever */ + + /* not reached */ + return 0; + +#undef mk_sub +#undef JUMPTO +} diff --git a/eval_d.c b/eval_d.c new file mode 100644 index 0000000..64a8e55 --- /dev/null +++ b/eval_d.c @@ -0,0 +1,27 @@ +/* + * eval_p.c - compile eval.c with debugging turned on. + */ + +/* + * Copyright (C) 2001 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +#define DEBUGGING 1 +#include "eval.c" diff --git a/eval_p.c b/eval_p.c new file mode 100644 index 0000000..c8afe66 --- /dev/null +++ b/eval_p.c @@ -0,0 +1,27 @@ +/* + * eval_p.c - compile eval.c with profiling turned on. + */ + +/* + * Copyright (C) 2001 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define PROFILING 1 +#include "eval.c" diff --git a/ext.c b/ext.c new file mode 100644 index 0000000..f3e783d --- /dev/null +++ b/ext.c @@ -0,0 +1,302 @@ +/* + * ext.c - Builtin function that links external gawk functions and related + * utilities. + * + * Christos Zoulas, Thu Jun 29 17:40:41 EDT 1995 + * Arnold Robbins, update for 3.1, Mon Nov 23 12:53:39 EST 1998 + */ + +/* + * Copyright (C) 1995 - 2001, 2003-2012 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "awk.h" + +#ifdef DYNAMIC + +#include + +/* do_ext --- load an extension */ + +NODE * +do_ext(int nargs) +{ + NODE *obj; + NODE *fun; + NODE *tmp = NULL; + NODE *(*func)(NODE *, void *); + void *dl; + int flags = RTLD_LAZY; + int fatal_error = FALSE; + int *gpl_compat; +#if 0 + static short warned = FALSE; +#endif + + if (do_sandbox) + fatal(_("extensions are not allowed in sandbox mode")); + +#if 0 + /* already done in parser */ + if (do_lint && ! warned) { + warned = TRUE; + lintwarn(_("`extension' is a gawk extension")); + } +#endif + + if (do_traditional || do_posix) + error(_("`extension' is a gawk extension")); + + fun = POP_STRING(); + obj = POP_STRING(); + +#ifdef RTLD_GLOBAL + flags |= RTLD_GLOBAL; +#endif + if ((dl = dlopen(obj->stptr, flags)) == NULL) { + /* fatal needs `obj', and we need to deallocate it! */ + msg(_("fatal: extension: cannot open `%s' (%s)\n"), obj->stptr, + dlerror()); + fatal_error = TRUE; + goto done; + } + + /* Per the GNU Coding standards */ + gpl_compat = (int *) dlsym(dl, "plugin_is_GPL_compatible"); + if (gpl_compat == NULL) { + msg(_("fatal: extension: library `%s': does not define `plugin_is_GPL_compatible' (%s)\n"), + obj->stptr, dlerror()); + fatal_error = TRUE; + goto done; + } + + + func = (NODE *(*)(NODE *, void *)) dlsym(dl, fun->stptr); + if (func == NULL) { + msg(_("fatal: extension: library `%s': cannot call function `%s' (%s)\n"), + obj->stptr, fun->stptr, dlerror()); + fatal_error = TRUE; + goto done; + } + + tmp = (*func)(obj, dl); + if (tmp == NULL) + tmp = Nnull_string; +done: + DEREF(obj); + DEREF(fun); + if (fatal_error) + gawk_exit(EXIT_FATAL); + return tmp; +} + + +/* make_builtin --- register name to be called as func with a builtin body */ + +void +make_builtin(const char *name, NODE *(*func)(int), int count) +{ + NODE *p, *symbol, *f; + INSTRUCTION *b, *r; + const char *sp; + char *pname; + char **vnames = NULL; + char c, buf[200]; + size_t space_needed; + int i; + + sp = name; + if (sp == NULL || *sp == '\0') + fatal(_("extension: missing function name")); + + while ((c = *sp++) != '\0') { + if ((sp == &name[1] && c != '_' && ! isalpha((unsigned char) c)) + || (sp > &name[1] && ! is_identchar((unsigned char) c))) + fatal(_("extension: illegal character `%c' in function name `%s'"), c, name); + } + + f = lookup(name); + + if (f != NULL) { + if (f->type == Node_func) { + INSTRUCTION *pc = f->code_ptr; + if (pc->opcode != Op_ext_func) /* user-defined function */ + fatal(_("extension: can't redefine function `%s'"), name); + else { + /* multiple extension() calls etc. */ + if (do_lint) + lintwarn(_("extension: function `%s' already defined"), name); + return; + } + } else + /* variable name etc. */ + fatal(_("extension: function name `%s' previously defined"), name); + } else if (check_special(name) >= 0) + fatal(_("extension: can't use gawk built-in `%s' as function name"), name); + /* count parameters, create artificial list of param names */ + + if (count < 0) + fatal(_("make_builtin: negative argument count for function `%s'"), + name); + + if (count > 0) { + sprintf(buf, "p%d", count); + space_needed = strlen(buf) + 1; + emalloc(vnames, char **, count * sizeof(char *), "make_builtin"); + for (i = 0; i < count; i++) { + emalloc(pname, char *, space_needed, "make_builtin"); + sprintf(pname, "p%d", i); + vnames[i] = pname; + } + } + + + getnode(p); + p->type = Node_param_list; + p->flags |= FUNC; + /* get our own copy for name */ + p->param = estrdup(name, strlen(name)); + p->param_cnt = count; + + /* actual source and line numbers set at runtime for these instructions */ + b = bcalloc(Op_builtin, 1, __LINE__); + b->builtin = func; + b->expr_count = count; + b->nexti = bcalloc(Op_K_return, 1, __LINE__); + r = bcalloc(Op_ext_func, 1, __LINE__); + r->source_file = __FILE__; + r->nexti = b; + + /* NB: extension sub must return something */ + + symbol = mk_symbol(Node_func, p); + symbol->parmlist = vnames; + symbol->code_ptr = r; + r->func_body = symbol; + (void) install_symbol(p->param, symbol); +} + + +/* get_curfunc_arg_count --- return number actual parameters */ + +size_t +get_curfunc_arg_count() +{ + size_t argc; + INSTRUCTION *pc; + + pc = (INSTRUCTION *) frame_ptr->reti; /* Op_func_call instruction */ + argc = (pc + 1)->expr_count; /* # of arguments supplied */ + return argc; +} + + +/* get_argument --- get the n'th argument of a dynamically linked function */ + +NODE * +get_argument(int i) +{ + int pcount; + NODE *t, *f; + int actual_args; + INSTRUCTION *pc; + + f = frame_ptr->func_node; + pcount = f->lnode->param_cnt; + + pc = (INSTRUCTION *) frame_ptr->reti; /* Op_func_call instruction */ + actual_args = (pc + 1)->expr_count; /* # of arguments supplied */ + + if (i < 0 || i >= pcount || i >= actual_args) + return NULL; + + t = GET_PARAM(i); + + if (t->type == Node_array_ref) + return t->orig_array; /* Node_var_new or Node_var_array */ + if (t->type == Node_var_new || t->type == Node_var_array) + return t; + return t->var_value; +} + + +/* get_actual_argument --- get a scalar or array, allowed to be optional */ + +NODE * +get_actual_argument(int i, int optional, int want_array) +{ + /* optional : if TRUE and i th argument not present return NULL, else fatal. */ + + NODE *t, *f; + int pcount; + char *fname; + + t = get_argument(i); + + f = frame_ptr->func_node; + pcount = f->lnode->param_cnt; + fname = f->lnode->param; + + if (t == NULL) { + if (i >= pcount) /* must be fatal */ + fatal(_("function `%s' defined to take no more than %d argument(s)"), + fname, pcount); + if (! optional) + fatal(_("function `%s': missing argument #%d"), + fname, i + 1); + return NULL; + } + + if (t->type == Node_var_new) { + if (want_array) + return get_array(t, FALSE); + else { + t->type = Node_var; + t->var_value = Nnull_string; + return Nnull_string; + } + } + + if (want_array) { + if (t->type != Node_var_array) + fatal(_("function `%s': argument #%d: attempt to use scalar as an array"), + fname, i + 1); + } else { + if (t->type != Node_val) + fatal(_("function `%s': argument #%d: attempt to use array as a scalar"), + fname, i + 1); + } + return t; +} + +#else + +/* do_ext --- dummy version if extensions not available */ + +NODE * +do_ext(int nargs) +{ + const char *emsg = _("Operation Not Supported"); + + unref(ERRNO_node->var_value); + ERRNO_node->var_value = make_string(emsg, strlen(emsg)); + return make_number((AWKNUM) -1); +} +#endif diff --git a/extension/ChangeLog b/extension/ChangeLog new file mode 100644 index 0000000..d684afe --- /dev/null +++ b/extension/ChangeLog @@ -0,0 +1,9 @@ +2012-03-28 Arnold D. Robbins + + * 4.0.1: Release tar ball made. + +2011-06-23 Arnold D. Robbins + + * ChangeLog.0: Rotated ChangeLog into this file. + * ChangeLog: Created anew for gawk 4.0.0 and on. + * 4.0.0: Release tar ball made. diff --git a/extension/ChangeLog.0 b/extension/ChangeLog.0 new file mode 100644 index 0000000..f13a7eb --- /dev/null +++ b/extension/ChangeLog.0 @@ -0,0 +1,91 @@ +Mon May 23 22:03:46 2011 John Haque + + * testarg.awk, testarg.c: Updated. + +Thu Mar 31 22:58:19 2011 Arnold D. Robbins + + * filefuncs.c (do_stat): Fix a comment. Also in doc. + +Thu Jan 13 20:37:02 2011 Andrew J. Schorr + + * filefuncs.c (do_stat): Malloc the buffer to read the contents + of the link. From mail of June 21, 2005. + +Sun Jan 2 21:08:17 2011 Arnold D. Robbins + + * filefuncs.c: Synched with code in gawk.texi, copyright dates + updated. + +Sat Dec 18 20:22:44 2010 Arnold D. Robbins + + * pcext.def: Removed, since we don't support MSFT compilers. + +Wed Nov 24 20:08:13 2010 Arnold D. Robbins + + * arrayparm.c, dl.c, filefuncs.c, fork.c, ordchr.c, readfile.c, + rwarray.c, testarg.c, xreadlink.c: Define `plugin_is_GPL_compatible' + per GNU Coding standards. + +Thu May 6 20:55:14 2010 Arnold D. Robbins + + * Release 3.1.8: Release tar file made. + +Tue Jul 21 22:28:56 2009 Arnold D. Robbins + + * Release 3.1.7: Release tar file made. + +Mon May 18 21:31:34 2009 Arnold D. Robbins + + * rwarray.c (write_value, read_value): Use htonl / ntohl to write / + read the code for double / string. Test read-in code for != 0 + to handle stuff written before this change. + +Sat May 16 22:52:34 2009 Arnold D. Robbins + + * rwarray.c (do_reada, read_elem, read_value): Made the code + actually work. + +Fri May 15 16:01:06 2009 Arnold D. Robbins + + * rwarray.c, rwarray.awk: New files. + * steps: Updated. + +Mon Oct 22 08:49:05 2007 Arnold D. Robbins + + * Release 3.1.6: Release tar file made. + +Tue Jul 26 21:46:16 2005 Arnold D. Robbins + + * Release 3.1.5: Release tar file made. + +Sun Jun 26 09:03:32 2005 Arnold D. Robbins + + * filefuncs.c (do_stat): Check return value from readlink() + for error. Pass in `sizeof(buf) - 1' to leave room for trailing + zero byte. From: Glenn Zazulia . + +Mon Aug 2 12:18:15 2004 Arnold D. Robbins + + * Release 3.1.4: Release tar file made. + +Mon Jun 21 17:02:37 2004 Arnold D. Robbins + + More from John Haque. + + * testarg.c, testarg.awk: New files. + * arrayparm.c (do_mkarray): Change call of `get_curfunc_parm_count' + to `get_curfunc_arg_count'. + * filefuncs.c (do_chdir, do_stat): Ditto. + * fork.c (do_fork, do_waitpid): Ditto. + * ordchr.c (do_ord, do_chr): Ditto. + * readfile.c (do_readfile): Ditto. + * steps: Updated. + +Mon Jun 14 14:01:16 2004 Arnold D. Robbins + + ChangeLog started. + + Changes from John Haque and ADR to rationalize extension functions. + + * extension/filefuncs.c: Revised for new functionality. See + corresponding entry in main ChangeLog. diff --git a/extension/arrayparm.c b/extension/arrayparm.c new file mode 100644 index 0000000..8a550ac --- /dev/null +++ b/extension/arrayparm.c @@ -0,0 +1,83 @@ +/* + * arrayparm.c --- figure out how to make a parameter be an array + * + * Arnold Robbins + * arnold@skeeve.com + * 10/2001 + * + * Revised 7/2003 + * Revised 6/2004 + */ + +/* + * Copyright (C) 2001, 2003, 2004, 2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "awk.h" + +int plugin_is_GPL_compatible; + +/* do_mkarray --- turn a variable into an array */ + +/* + * From awk, call + * + * mkarray(var, sub, val) + */ + +static NODE * +do_mkarray(int args) +{ + int ret = -1; + NODE *var, *sub, *val; + NODE **elemval; + + if (do_lint && get_curfunc_arg_count() > 3) + lintwarn("mkarray: called with too many arguments"); + + var = get_array_argument(0, FALSE); + sub = get_scalar_argument(1, FALSE); + val = get_scalar_argument(2, FALSE); + + printf("var->type = %s\n", nodetype2str(var->type)); + printf("sub->type = %s\n", nodetype2str(sub->type)); + printf("val->type = %s\n", nodetype2str(val->type)); + + assoc_clear(var); + + elemval = assoc_lookup(var, sub, 0); + *elemval = dupnode(val); + ret = 0; + + /* Set the return value */ + return make_number((AWKNUM) ret); +} + +/* dlload --- load new builtins in this library */ + +NODE * +dlload(tree, dl) +NODE *tree; +void *dl; +{ + make_builtin("mkarray", do_mkarray, 3); + + return make_number((AWKNUM) 0); +} diff --git a/extension/dl.c b/extension/dl.c new file mode 100644 index 0000000..afc16af --- /dev/null +++ b/extension/dl.c @@ -0,0 +1,92 @@ +/* + * dl.c - Example of adding a new builtin function to gawk. + * + * Christos Zoulas, Thu Jun 29 17:40:41 EDT 1995 + * Arnold Robbins, update for 3.1, Wed Sep 13 09:38:56 2000 + */ + +/* + * Copyright (C) 1995 - 2001, 2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "awk.h" +#include + +int plugin_is_GPL_compatible; + +static void *sdl = NULL; + +static NODE * +zaxxon(int nargs) +{ + NODE *obj; + int i; + int comma = 0; + + /* + * Print the arguments + */ + printf("External linkage zaxxon("); + + for (i = 0; i < nargs; i++) { + + obj = get_scalar_argument(i, TRUE); + + if (obj == NULL) + break; + + force_string(obj); + + printf(comma ? ", %s" : "%s", obj->stptr); + comma = 1; + } + + printf(");\n"); + + /* + * Do something useful + */ + obj = get_scalar_argument(0, FALSE); + + if (obj != NULL) { + force_string(obj); + if (strcmp(obj->stptr, "unload") == 0 && sdl) { + /* + * XXX: How to clean up the function? + * I would like the ability to remove a function... + */ + dlclose(sdl); + sdl = NULL; + } + } + + /* Set the return value */ + return make_number((AWKNUM) 3.14); +} + +NODE * +dlload(tree, dl) +NODE *tree; +void *dl; +{ + sdl = dl; + make_builtin("zaxxon", zaxxon, 4); + return make_number((AWKNUM) 0); +} diff --git a/extension/doit b/extension/doit new file mode 100755 index 0000000..29dff7d --- /dev/null +++ b/extension/doit @@ -0,0 +1 @@ +../gawk -f foo.awk diff --git a/extension/filefuncs.c b/extension/filefuncs.c new file mode 100644 index 0000000..ad7828f --- /dev/null +++ b/extension/filefuncs.c @@ -0,0 +1,338 @@ +/* + * filefuncs.c - Builtin functions that provide initial minimal iterface + * to the file system. + * + * Arnold Robbins, update for 3.1, Mon Nov 23 12:53:39 EST 1998 + * Arnold Robbins and John Haque, update for 3.1.4, applied Mon Jun 14 13:55:30 IDT 2004 + */ + +/* + * Copyright (C) 2001, 2004, 2005, 2010, 2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "awk.h" + +#include + +int plugin_is_GPL_compatible; + +/* do_chdir --- provide dynamically loaded chdir() builtin for gawk */ + +static NODE * +do_chdir(int nargs) +{ + NODE *newdir; + int ret = -1; + + if (do_lint && get_curfunc_arg_count() != 1) + lintwarn("chdir: called with incorrect number of arguments"); + + newdir = get_scalar_argument(0, FALSE); + (void) force_string(newdir); + ret = chdir(newdir->stptr); + if (ret < 0) + update_ERRNO(); + + return make_number((AWKNUM) ret); +} + +/* format_mode --- turn a stat mode field into something readable */ + +static char * +format_mode(unsigned long fmode) +{ + static char outbuf[12]; + int i; + + strcpy(outbuf, "----------"); + /* first, get the file type */ + i = 0; + switch (fmode & S_IFMT) { +#ifdef S_IFSOCK + case S_IFSOCK: + outbuf[i] = 's'; + break; +#endif +#ifdef S_IFLNK + case S_IFLNK: + outbuf[i] = 'l'; + break; +#endif + case S_IFREG: + outbuf[i] = '-'; /* redundant */ + break; + case S_IFBLK: + outbuf[i] = 'b'; + break; + case S_IFDIR: + outbuf[i] = 'd'; + break; +#ifdef S_IFDOOR /* Solaris weirdness */ + case S_IFDOOR: + outbuf[i] = 'D'; + break; +#endif /* S_IFDOOR */ + case S_IFCHR: + outbuf[i] = 'c'; + break; +#ifdef S_IFIFO + case S_IFIFO: + outbuf[i] = 'p'; + break; +#endif + } + + i++; + if ((fmode & S_IRUSR) != 0) + outbuf[i] = 'r'; + i++; + if ((fmode & S_IWUSR) != 0) + outbuf[i] = 'w'; + i++; + if ((fmode & S_IXUSR) != 0) + outbuf[i] = 'x'; + i++; + + if ((fmode & S_IRGRP) != 0) + outbuf[i] = 'r'; + i++; + if ((fmode & S_IWGRP) != 0) + outbuf[i] = 'w'; + i++; + if ((fmode & S_IXGRP) != 0) + outbuf[i] = 'x'; + i++; + + if ((fmode & S_IROTH) != 0) + outbuf[i] = 'r'; + i++; + if ((fmode & S_IWOTH) != 0) + outbuf[i] = 'w'; + i++; + if ((fmode & S_IXOTH) != 0) + outbuf[i] = 'x'; + i++; + + outbuf[i] = '\0'; + + if ((fmode & S_ISUID) != 0) { + if (outbuf[3] == 'x') + outbuf[3] = 's'; + else + outbuf[3] = 'S'; + } + + /* setgid without execute == locking */ + if ((fmode & S_ISGID) != 0) { + if (outbuf[6] == 'x') + outbuf[6] = 's'; + else + outbuf[6] = 'l'; + } + + if ((fmode & S_ISVTX) != 0) { + if (outbuf[9] == 'x') + outbuf[9] = 't'; + else + outbuf[9] = 'T'; + } + + return outbuf; +} + +/* do_stat --- provide a stat() function for gawk */ + +static NODE * +do_stat(int nargs) +{ + NODE *file, *array, *tmp; + struct stat sbuf; + int ret; + NODE **aptr; + char *pmode; /* printable mode */ + char *type = "unknown"; + + if (do_lint && get_curfunc_arg_count() > 2) + lintwarn("stat: called with too many arguments"); + + /* file is first arg, array to hold results is second */ + file = get_scalar_argument(0, FALSE); + array = get_array_argument(1, FALSE); + + /* empty out the array */ + assoc_clear(array); + + /* lstat the file, if error, set ERRNO and return */ + (void) force_string(file); + ret = lstat(file->stptr, & sbuf); + if (ret < 0) { + update_ERRNO(); + return make_number((AWKNUM) ret); + } + + /* fill in the array */ + aptr = assoc_lookup(array, tmp = make_string("name", 4), FALSE); + *aptr = dupnode(file); + unref(tmp); + + aptr = assoc_lookup(array, tmp = make_string("dev", 3), FALSE); + *aptr = make_number((AWKNUM) sbuf.st_dev); + unref(tmp); + + aptr = assoc_lookup(array, tmp = make_string("ino", 3), FALSE); + *aptr = make_number((AWKNUM) sbuf.st_ino); + unref(tmp); + + aptr = assoc_lookup(array, tmp = make_string("mode", 4), FALSE); + *aptr = make_number((AWKNUM) sbuf.st_mode); + unref(tmp); + + aptr = assoc_lookup(array, tmp = make_string("nlink", 5), FALSE); + *aptr = make_number((AWKNUM) sbuf.st_nlink); + unref(tmp); + + aptr = assoc_lookup(array, tmp = make_string("uid", 3), FALSE); + *aptr = make_number((AWKNUM) sbuf.st_uid); + unref(tmp); + + aptr = assoc_lookup(array, tmp = make_string("gid", 3), FALSE); + *aptr = make_number((AWKNUM) sbuf.st_gid); + unref(tmp); + + aptr = assoc_lookup(array, tmp = make_string("size", 4), FALSE); + *aptr = make_number((AWKNUM) sbuf.st_size); + unref(tmp); + + aptr = assoc_lookup(array, tmp = make_string("blocks", 6), FALSE); + *aptr = make_number((AWKNUM) sbuf.st_blocks); + unref(tmp); + + aptr = assoc_lookup(array, tmp = make_string("atime", 5), FALSE); + *aptr = make_number((AWKNUM) sbuf.st_atime); + unref(tmp); + + aptr = assoc_lookup(array, tmp = make_string("mtime", 5), FALSE); + *aptr = make_number((AWKNUM) sbuf.st_mtime); + unref(tmp); + + aptr = assoc_lookup(array, tmp = make_string("ctime", 5), FALSE); + *aptr = make_number((AWKNUM) sbuf.st_ctime); + unref(tmp); + + /* for block and character devices, add rdev, major and minor numbers */ + if (S_ISBLK(sbuf.st_mode) || S_ISCHR(sbuf.st_mode)) { + aptr = assoc_lookup(array, tmp = make_string("rdev", 4), FALSE); + *aptr = make_number((AWKNUM) sbuf.st_rdev); + unref(tmp); + + aptr = assoc_lookup(array, tmp = make_string("major", 5), FALSE); + *aptr = make_number((AWKNUM) major(sbuf.st_rdev)); + unref(tmp); + + aptr = assoc_lookup(array, tmp = make_string("minor", 5), FALSE); + *aptr = make_number((AWKNUM) minor(sbuf.st_rdev)); + unref(tmp); + } + +#ifdef HAVE_ST_BLKSIZE + aptr = assoc_lookup(array, tmp = make_string("blksize", 7), FALSE); + *aptr = make_number((AWKNUM) sbuf.st_blksize); + unref(tmp); +#endif /* HAVE_ST_BLKSIZE */ + + aptr = assoc_lookup(array, tmp = make_string("pmode", 5), FALSE); + pmode = format_mode(sbuf.st_mode); + *aptr = make_string(pmode, strlen(pmode)); + unref(tmp); + + /* for symbolic links, add a linkval field */ + if (S_ISLNK(sbuf.st_mode)) { + char *buf; + int linksize; + + emalloc(buf, char *, sbuf.st_size + 2, "do_stat"); + if (((linksize = readlink(file->stptr, buf, + sbuf.st_size + 2)) >= 0) && + (linksize <= sbuf.st_size)) { + /* + * set the linkval field only if we are able to + * retrieve the entire link value successfully. + */ + buf[linksize] = '\0'; + + aptr = assoc_lookup(array, tmp = make_string("linkval", 7), FALSE); + *aptr = make_str_node(buf, linksize, ALREADY_MALLOCED); + unref(tmp); + } + } + + /* add a type field */ + switch (sbuf.st_mode & S_IFMT) { +#ifdef S_IFSOCK + case S_IFSOCK: + type = "socket"; + break; +#endif +#ifdef S_IFLNK + case S_IFLNK: + type = "symlink"; + break; +#endif + case S_IFREG: + type = "file"; + break; + case S_IFBLK: + type = "blockdev"; + break; + case S_IFDIR: + type = "directory"; + break; +#ifdef S_IFDOOR + case S_IFDOOR: + type = "door"; + break; +#endif + case S_IFCHR: + type = "chardev"; + break; +#ifdef S_IFIFO + case S_IFIFO: + type = "fifo"; + break; +#endif + } + + aptr = assoc_lookup(array, tmp = make_string("type", 4), FALSE); + *aptr = make_string(type, strlen(type)); + unref(tmp); + + return make_number((AWKNUM) ret); +} + +/* dlload --- load new builtins in this library */ + +NODE * +dlload(NODE *tree, void *dl) +{ + make_builtin("chdir", do_chdir, 1); + make_builtin("stat", do_stat, 2); + + return make_number((AWKNUM) 0); +} diff --git a/extension/foo.awk b/extension/foo.awk new file mode 100644 index 0000000..00a89e5 --- /dev/null +++ b/extension/foo.awk @@ -0,0 +1,9 @@ +BEGIN { + extension("./dl.so","dlload") + zaxxon("hi there", "this is", "a test", "of argument passing") + zaxxon(1) + zaxxon(1,2) + z = zaxxon(1,2,3,4) + z = zaxxon(1,zaxxon(zaxxon("foo")),3,4) + print z +} diff --git a/extension/fork.c b/extension/fork.c new file mode 100644 index 0000000..aff9b56 --- /dev/null +++ b/extension/fork.c @@ -0,0 +1,104 @@ +/* + * fork.c - Provide fork and waitpid functions for gawk. + * + * Revised 6/2004 + */ + +/* + * Copyright (C) 2001, 2004, 2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "awk.h" + +int plugin_is_GPL_compatible; + +/* do_fork --- provide dynamically loaded fork() builtin for gawk */ + +static NODE * +do_fork(int nargs) +{ + int ret = -1; + NODE **aptr; + NODE *tmp; + + if (do_lint && get_curfunc_arg_count() > 0) + lintwarn("fork: called with too many arguments"); + + ret = fork(); + + if (ret < 0) + update_ERRNO(); + else if (ret == 0) { + /* update PROCINFO in the child */ + + aptr = assoc_lookup(PROCINFO_node, tmp = make_string("pid", 3), FALSE); + (*aptr)->numbr = (AWKNUM) getpid(); + unref(tmp); + + aptr = assoc_lookup(PROCINFO_node, tmp = make_string("ppid", 4), FALSE); + (*aptr)->numbr = (AWKNUM) getppid(); + unref(tmp); + } + + /* Set the return value */ + return make_number((AWKNUM) ret); +} + + +/* do_waitpid --- provide dynamically loaded waitpid() builtin for gawk */ + +static NODE * +do_waitpid(int nargs) +{ + NODE *pidnode; + int ret = -1; + double pidval; + pid_t pid; + int options = 0; + + if (do_lint && get_curfunc_arg_count() > 1) + lintwarn("waitpid: called with too many arguments"); + + pidnode = get_scalar_argument(0, FALSE); + if (pidnode != NULL) { + pidval = force_number(pidnode); + pid = (int) pidval; + options = WNOHANG|WUNTRACED; + ret = waitpid(pid, NULL, options); + if (ret < 0) + update_ERRNO(); + } else if (do_lint) + lintwarn("wait: called with no arguments"); + + /* Set the return value */ + return make_number((AWKNUM) ret); +} + +/* dlload --- load new builtins in this library */ + +NODE * +dlload(tree, dl) +NODE *tree; +void *dl; +{ + make_builtin("fork", do_fork, 0); + make_builtin("waitpid", do_waitpid, 1); + return make_number((AWKNUM) 0); +} diff --git a/extension/ordchr.c b/extension/ordchr.c new file mode 100644 index 0000000..efbc6d5 --- /dev/null +++ b/extension/ordchr.c @@ -0,0 +1,98 @@ +/* + * ordchr.c - Builtin functions that provide ord() and chr() functions. + * + * Arnold Robbins + * arnold@skeeve.com + * 8/2001 + * Revised 6/2004 + */ + +/* + * Copyright (C) 2001, 2004, 2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "awk.h" + +int plugin_is_GPL_compatible; + +/* do_ord --- return numeric value of first char of string */ + +static NODE * +do_ord(int nargs) +{ + NODE *str; + int ret = -1; + + if (do_lint && get_curfunc_arg_count() > 1) + lintwarn("ord: called with too many arguments"); + + str = get_scalar_argument(0, FALSE); + if (str != NULL) { + (void) force_string(str); + ret = str->stptr[0]; + } else if (do_lint) + lintwarn("ord: called with no arguments"); + + + /* Set the return value */ + return make_number((AWKNUM) ret); +} + +/* do_chr --- turn numeric value into a string */ + +static NODE * +do_chr(int nargs) +{ + NODE *num; + unsigned int ret = 0; + AWKNUM val = 0.0; + char str[2]; + + str[0] = str[1] = '\0'; + + if (do_lint && get_curfunc_arg_count() > 1) + lintwarn("chr: called with too many arguments"); + + num = get_scalar_argument(0, FALSE); + if (num != NULL) { + val = force_number(num); + ret = val; /* convert to int */ + ret &= 0xff; + str[0] = ret; + str[1] = '\0'; + } else if (do_lint) + lintwarn("chr: called with no arguments"); + + /* Set the return value */ + return make_string(str, 1); +} + +/* dlload --- load new builtins in this library */ + +NODE * +dlload(tree, dl) +NODE *tree; +void *dl; +{ + make_builtin("ord", do_ord, 1); + make_builtin("chr", do_chr, 1); + + return make_number((AWKNUM) 0); +} diff --git a/extension/readfile.c b/extension/readfile.c new file mode 100644 index 0000000..e6ee0f2 --- /dev/null +++ b/extension/readfile.c @@ -0,0 +1,109 @@ +/* + * readfile.c - Read an entire file into a string. + * + * Arnold Robbins + * Tue Apr 23 17:43:30 IDT 2002 + * Revised per Peter Tillier + * Mon Jun 9 17:05:11 IDT 2003 + * Revised for new dynamic function facilities + * Mon Jun 14 14:53:07 IDT 2004 + */ + +/* + * Copyright (C) 2002, 2003, 2004, 2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "awk.h" +#include + +#ifndef O_BINARY +#define O_BINARY 0 +#endif + +int plugin_is_GPL_compatible; + +/* do_readfile --- read a file into memory */ + +NODE * +do_readfile(int nargs) +{ + NODE *filename; + int ret = -1; + struct stat sbuf; + char *text; + int fd; + + if (do_lint && get_curfunc_arg_count() > 1) + lintwarn("readfile: called with too many arguments"); + + filename = get_scalar_argument(0, FALSE); + if (filename != NULL) { + (void) force_string(filename); + + ret = stat(filename->stptr, & sbuf); + if (ret < 0) { + update_ERRNO(); + goto done; + } else if ((sbuf.st_mode & S_IFMT) != S_IFREG) { + errno = EINVAL; + ret = -1; + update_ERRNO(); + goto done; + } + + if ((fd = open(filename->stptr, O_RDONLY|O_BINARY)) < 0) { + ret = -1; + update_ERRNO(); + goto done; + } + + emalloc(text, char *, sbuf.st_size + 2, "do_readfile"); + memset(text, '\0', sbuf.st_size + 2); + + if ((ret = read(fd, text, sbuf.st_size)) != sbuf.st_size) { + (void) close(fd); + ret = -1; + update_ERRNO(); + goto done; + } + + close(fd); + return make_string(text, sbuf.st_size); + } else if (do_lint) + lintwarn("filename: called with no arguments"); + + +done: + /* Set the return value */ + return make_number((AWKNUM) ret); +} + + +/* dlload --- load new builtins in this library */ + +NODE * +dlload(tree, dl) +NODE *tree; +void *dl; +{ + make_builtin("readfile", do_readfile, 1); + + return make_number((AWKNUM) 0); +} diff --git a/extension/rwarray.awk b/extension/rwarray.awk new file mode 100644 index 0000000..1057b39 --- /dev/null +++ b/extension/rwarray.awk @@ -0,0 +1,28 @@ +BEGIN { + extension("./rwarray.so","dlload") + + while ((getline word < "/usr/share/dict/words") > 0) + dict[word] = word word + + for (i in dict) + printf("dict[%s] = %s\n", i, dict[i]) > "orig.out" + close("orig.out"); + + writea("orig.bin", dict) + + reada("orig.bin", dict) + + for (i in dict) + printf("dict[%s] = %s\n", i, dict[i]) > "new.out" + close("new.out"); + + ret = system("cmp orig.out new.out") + + if (ret == 0) + print "old and new are equal - GOOD" + else + print "old and new are not equal - BAD" + + if (ret == 0 && !("keepit" in ENVIRON)) + system("rm orig.bin orig.out new.out") +} diff --git a/extension/rwarray.c b/extension/rwarray.c new file mode 100644 index 0000000..3c62957 --- /dev/null +++ b/extension/rwarray.c @@ -0,0 +1,462 @@ +/* + * rwarray.c - Builtin functions to binary read / write arrays to a file. + * + * Arnold Robbins + * May 2009 + */ + +/* + * Copyright (C) 2009, 2010, 2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "awk.h" +#include +#include +#include +#include + + +#define MAGIC "awkrulz\n" +#define MAJOR 1 +#define MINOR 0 + +int plugin_is_GPL_compatible; + +static int write_array(int fd, NODE *array); +static int write_elem(int fd, int index, NODE *item); +static int write_chain(int fd, int index, NODE *item); +static int write_value(int fd, NODE *val); + +static int read_array(int fd, NODE *array); +static NODE *read_elem(int fd, int *index, NODE *array); +static NODE *read_value(int fd); + +/* + * Format of array info: + * + * MAGIC 8 bytes + * Major version 4 bytes - network order + * Minor version 4 bytes - network order + * Element count 4 bytes - network order + * Array size 4 bytes - network order + * Elements + * + * For each element: + * Bucket number: 4 bytes - network order + * Hash of index val: 4 bytes - network order + * Length of index val: 4 bytes - network order + * Index val as characters (N bytes) + * Value type 1 byte (0 = string, 1 = number, 2 = array) + * IF string: + * Length of value 4 bytes + * Value as characters (N bytes) + * ELSE + * 8 bytes as native double + */ + +/* do_writea --- write an array */ + +static NODE * +do_writea(int nargs) +{ + NODE *file, *array; + int ret; + int fd; + uint32_t major = MAJOR; + uint32_t minor = MINOR; + + if (do_lint && get_curfunc_arg_count() > 2) + lintwarn("writea: called with too many arguments"); + + /* directory is first arg, array to dump is second */ + file = get_scalar_argument(0, FALSE); + array = get_array_argument(1, FALSE); + + /* open the file, if error, set ERRNO and return */ + (void) force_string(file); + fd = creat(file->stptr, 0600); + if (fd < 0) { + goto done1; + } + + if (write(fd, MAGIC, strlen(MAGIC)) != strlen(MAGIC)) + goto done1; + + major = htonl(major); + if (write(fd, & major, sizeof(major)) != sizeof(major)) + goto done1; + + minor = htonl(minor); + if (write(fd, & minor, sizeof(minor)) != sizeof(minor)) + goto done1; + + ret = write_array(fd, array); + if (ret != 0) + goto done1; + ret = 0; + goto done0; + +done1: + ret = -1; + update_ERRNO(); + unlink(file->stptr); + +done0: + close(fd); + + /* Set the return value */ + return make_number((AWKNUM) ret); +} + + +/* write_array --- write out an array or a sub-array */ + +static int +write_array(int fd, NODE *array) +{ + int ret; + uint32_t count; + uint32_t array_sz; + int i; + + count = htonl(array->table_size); + if (write(fd, & count, sizeof(count)) != sizeof(count)) + return -1; + + array_sz = htonl(array->array_size); + if (write(fd, & array_sz, sizeof(array_sz)) != sizeof(array_sz)) + return -1; + + for (i = 0; i < array->array_size; i++) { + ret = write_chain(fd, i, array->var_array[i]); + if (ret != 0) + return ret; + } + return 0; +} + + +/* write_chain --- write out a whole hash chain */ + +/* + * Write elements in the chain in reverse order so that + * when we read the elements back in we can just push them + * onto the front and thus recreate the array as it was. + */ + +static int +write_chain(int fd, int index, NODE *bucket) +{ + int ret; + + if (bucket == NULL) + return 0; + + ret = write_chain(fd, index, bucket->ahnext); + if (ret != 0) + return ret; + + return write_elem(fd, index, bucket); +} + +/* write_elem --- write out a single element */ + +static int +write_elem(int fd, int index, NODE *item) +{ + uint32_t hashval, indexval_len; + + index = htonl(index); + if (write(fd, & index, sizeof(index)) != sizeof(index)) + return -1; + + hashval = htonl(item->ahcode); + if (write(fd, & hashval, sizeof(hashval)) != sizeof(hashval)) + return -1; + + indexval_len = htonl(item->ahname_len); + if (write(fd, & indexval_len, sizeof(indexval_len)) != sizeof(indexval_len)) + return -1; + + if (write(fd, item->ahname_str, item->ahname_len) != item->ahname_len) + return -1; + + return write_value(fd, item->ahvalue); +} + +/* write_value --- write a number or a string or a array */ + +static int +write_value(int fd, NODE *val) +{ + int code, len; + + if (val->type == Node_var_array) { + code = htonl(2); + if (write(fd, & code, sizeof(code)) != sizeof(code)) + return -1; + return write_array(fd, val); + } + + if ((val->flags & NUMBER) != 0) { + code = htonl(1); + if (write(fd, & code, sizeof(code)) != sizeof(code)) + return -1; + + if (write(fd, & val->numbr, sizeof(val->numbr)) != sizeof(val->numbr)) + return -1; + } else { + code = 0; + if (write(fd, & code, sizeof(code)) != sizeof(code)) + return -1; + + len = htonl(val->stlen); + if (write(fd, & len, sizeof(len)) != sizeof(len)) + return -1; + + if (write(fd, val->stptr, val->stlen) != val->stlen) + return -1; + } + + return 0; +} + +/* do_reada --- read an array */ + +static NODE * +do_reada(int nargs) +{ + NODE *file, *array; + int ret; + int fd; + uint32_t major; + uint32_t minor; + char magic_buf[30]; + + if (do_lint && get_curfunc_arg_count() > 2) + lintwarn("reada: called with too many arguments"); + + /* directory is first arg, array to dump is second */ + file = get_scalar_argument(0, FALSE); + array = get_array_argument(1, FALSE); + + (void) force_string(file); + fd = open(file->stptr, O_RDONLY); + if (fd < 0) { + goto done1; + } + + memset(magic_buf, '\0', sizeof(magic_buf)); + if (read(fd, magic_buf, strlen(MAGIC)) != strlen(MAGIC)) { + goto done1; + } + + if (strcmp(magic_buf, MAGIC) != 0) { + goto done1; + } + + if (read(fd, & major, sizeof(major)) != sizeof(major)) { + goto done1; + } + major = ntohl(major); + + if (major != MAJOR) { + goto done1; + } + + if (read(fd, & minor, sizeof(minor)) != sizeof(minor)) { + goto done1; + } + minor = ntohl(minor); + if (minor != MINOR) { + goto done1; + } + + assoc_clear(array); + + ret = read_array(fd, array); + if (ret == 0) + goto done0; + +done1: + ret = -1; + update_ERRNO(); + +done0: + close(fd); + + /* Set the return value */ + return make_number((AWKNUM) ret); +} + + +/* read_array --- read in an array or sub-array */ + +static int +read_array(int fd, NODE *array) +{ + int i; + uint32_t count; + uint32_t array_sz; + int index; + NODE *new_elem; + + if (read(fd, & count, sizeof(count)) != sizeof(count)) { + return -1; + } + array->table_size = ntohl(count); + + if (read(fd, & array_sz, sizeof(array_sz)) != sizeof(array_sz)) { + return -1; + } + array->array_size = ntohl(array_sz); + + /* malloc var_array */ + array->var_array = (NODE **) malloc(array->array_size * sizeof(NODE *)); + memset(array->var_array, '\0', array->array_size * sizeof(NODE *)); + + for (i = 0; i < array->table_size; i++) { + if ((new_elem = read_elem(fd, & index, array)) != NULL) { + new_elem->ahnext = array->var_array[index]; + array->var_array[index] = new_elem; + } else + break; + } + if (i != array->table_size) + return -1; + return 0; +} + + +/* read_elem --- read in a single element */ + +static NODE * +read_elem(int fd, int *the_index, NODE *array) +{ + uint32_t hashval, indexval_len, index; + NODE *item; + NODE *val; + int ret; + + *the_index = 0; + + if ((ret = read(fd, & index, sizeof(index))) != sizeof(index)) { + return NULL; + } + *the_index = index = ntohl(index); + + getnode(item); + memset(item, 0, sizeof(*item)); + item->type = Node_ahash; + item->flags = MALLOC; + + if (read(fd, & hashval, sizeof(hashval)) != sizeof(hashval)) { + return NULL; + } + + item->ahcode = ntohl(hashval); + + if (read(fd, & indexval_len, sizeof(indexval_len)) != sizeof(indexval_len)) { + return NULL; + } + item->ahname_len = ntohl(indexval_len); + + item->ahname_str = malloc(item->ahname_len + 2); + if (read(fd, item->ahname_str, item->ahname_len) != item->ahname_len) { + return NULL; + } + item->ahname_str[item->ahname_len] = '\0'; + item->ahname_ref = 1; + + item->ahvalue = val = read_value(fd); + if (val == NULL) { + return NULL; + } + if (val->type == Node_var_array) { + char *aname; + size_t aname_len; + + /* construct the sub-array name */ + aname_len = strlen(array->vname) + item->ahname_len + 4; + emalloc(aname, char *, aname_len + 2, "read_elem"); + sprintf(aname, "%s[\"%.*s\"]", array->vname, (int) item->ahname_len, item->ahname_str); + val->vname = aname; + } + + return item; +} + +/* read_value --- read a number or a string */ + +static NODE * +read_value(int fd) +{ + NODE *val; + int code, len; + + getnode(val); + memset(val, 0, sizeof(*val)); + val->type = Node_val; + + if (read(fd, & code, sizeof(code)) != sizeof(code)) { + return NULL; + } + code = ntohl(code); + + if (code == 2) { + val->type = Node_var_array; + if (read_array(fd, val) != 0) + return NULL; + } else if (code == 1) { + if (read(fd, & val->numbr, sizeof(val->numbr)) != sizeof(val->numbr)) { + return NULL; + } + + val->flags = NUMBER|NUMCUR|MALLOC; + } else { + if (read(fd, & len, sizeof(len)) != sizeof(len)) { + return NULL; + } + val->stlen = ntohl(len); + val->stptr = malloc(val->stlen + 2); + memset(val->stptr, '\0', val->stlen + 2); + + if (read(fd, val->stptr, val->stlen) != val->stlen) { + return NULL; + } + + val->flags = STRING|STRCUR|MALLOC; + } + + return val; +} + +/* dlload --- load new builtins in this library */ + +NODE * +dlload(tree, dl) +NODE *tree; +void *dl; +{ + make_builtin("writea", do_writea, 2); + make_builtin("reada", do_reada, 2); + + return make_number((AWKNUM) 0); +} diff --git a/extension/steps b/extension/steps new file mode 100755 index 0000000..a6696dd --- /dev/null +++ b/extension/steps @@ -0,0 +1,23 @@ +# what to do under linux to make dl.so +# Tue Nov 24 15:04:14 EST 1998 +# Sun Aug 26 16:03:58 IDT 2001 +# Sun Apr 28 15:59:57 IDT 2002 +# Mon Jun 21 17:03:37 IDT 2004 +# Fri May 15 15:48:45 IDT 2009 + +gcc -fPIC -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. dl.c +gcc -fPIC -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. filefuncs.c +gcc -fPIC -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. fork.c +gcc -fPIC -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. ordchr.c +gcc -fPIC -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. arrayparm.c +gcc -fPIC -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. readfile.c +gcc -fPIC -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. testarg.c +gcc -fPIC -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. rwarray.c +ld -o dl.so -shared dl.o +ld -o filefuncs.so -shared filefuncs.o +ld -o fork.so -shared fork.o +ld -o ordchr.so -shared ordchr.o +ld -o arrayparm.so -shared arrayparm.o +ld -o readfile.so -shared readfile.o +ld -o testarg.so -shared testarg.o +ld -o rwarray.so -shared rwarray.o diff --git a/extension/testarg.awk b/extension/testarg.awk new file mode 100644 index 0000000..a91df1a --- /dev/null +++ b/extension/testarg.awk @@ -0,0 +1,7 @@ +BEGIN { + extension("./testarg.so", "dlload") + check_arg(x, a); + check_arg(y, b, z); + check_arg(u, v, u=1); + check_arg(p, q, r, s); +} diff --git a/extension/testarg.c b/extension/testarg.c new file mode 100644 index 0000000..ba4d56f --- /dev/null +++ b/extension/testarg.c @@ -0,0 +1,57 @@ +#include "awk.h" + +int plugin_is_GPL_compatible; + +static NODE * +do_check_arg(int nargs) +{ + int ret = 0, argc; + NODE *arg1, *arg2, *arg3; + + argc = get_curfunc_arg_count(); + printf("arg count: defined = %d, supplied = %d\n", + nargs, argc); + + arg1 = get_scalar_argument(0, FALSE); + arg2 = get_array_argument(1, FALSE); + arg3 = get_scalar_argument(2, TRUE); /* optional */ + if (argc > 3) { + /* try to use an extra arg */ + NODE *arg4; + arg4 = get_array_argument(3, TRUE); + printf("Shouldn't see this line\n"); + } + if (arg3 != NULL) { + printf("3rd arg present\n"); + if (arg3->type != Node_val) + printf("3nd arg type = %s (*** NOT OK ***)\n", nodetype2str(arg3->type)); + } else + printf("no 3rd arg\n"); + + if (arg2 != NULL) { + if (arg2->type != Node_var_array) + printf("2nd arg type = %s (*** NOT OK ***)\n", nodetype2str(arg2->type)); + } else + printf("2nd arg missing (NULL) (*** NOT OK ***)\n"); + + if (arg1 != NULL) { + if (arg1->type != Node_val) + printf("1st arg type = %s (*** NOT OK ***)\n", nodetype2str(arg1->type)); + } else + printf("1st arg missing (NULL) (*** NOT OK ***)\n"); + printf("\n"); + + /* Set the return value */ + return make_number((AWKNUM) ret); +} + +/* dlload --- load new builtins in this library */ + +NODE * +dlload(tree, dl) +NODE *tree; +void *dl; +{ + make_builtin("check_arg", do_check_arg, 3); + return make_number((AWKNUM) 0); +} diff --git a/extension/testarrayparm.awk b/extension/testarrayparm.awk new file mode 100644 index 0000000..08178f3 --- /dev/null +++ b/extension/testarrayparm.awk @@ -0,0 +1,10 @@ +#! /bin/awk -f + +BEGIN { + extension("./arrayparm.so", "dlload") + + mkarray(newvar, "hi", "hello") + + for (i in newvar) + printf ("newvar[\"%s\"] = \"%s\"\n", i, newvar[i]) +} diff --git a/extension/testff.awk b/extension/testff.awk new file mode 100644 index 0000000..0a0a9b2 --- /dev/null +++ b/extension/testff.awk @@ -0,0 +1,30 @@ +BEGIN { + extension("./filefuncs.so", "dlload") + +# printf "before: " +# fflush() +# system("pwd") +# +# chdir("..") +# +# printf "after: " +# fflush() +# system("pwd") + + chdir(".") + + data[1] = 1 + print "Info for testff.awk" + ret = stat("testff.awk", data) + print "ret =", ret + for (i in data) + printf "data[\"%s\"] = %s\n", i, data[i] + print "testff.awk modified:", strftime("%m %d %y %H:%M:%S", data["mtime"]) + + print "\nInfo for JUNK" + ret = stat("JUNK", data) + print "ret =", ret + for (i in data) + printf "data[\"%s\"] = %s\n", i, data[i] + print "JUNK modified:", strftime("%m %d %y %H:%M:%S", data["mtime"]) +} diff --git a/extension/testfork.awk b/extension/testfork.awk new file mode 100644 index 0000000..ca00dca --- /dev/null +++ b/extension/testfork.awk @@ -0,0 +1,20 @@ +BEGIN { + extension("./fork.so", "dlload") + + printf "before fork, pid = %d, ppid = %d\n", PROCINFO["pid"], + PROCINFO["ppid"] + + fflush() + ret = fork() + if (ret < 0) + printf("ret = %d, ERRNO = %s\n", ret, ERRNO) + else if (ret == 0) + printf "child, pid = %d, ppid = %d\n", PROCINFO["pid"], + PROCINFO["ppid"] + else { + system("sleep 3") + printf "parent, ret = %d\n", ret + printf "parent, pid = %d, ppid = %d\n", PROCINFO["pid"], + PROCINFO["ppid"] + } +} diff --git a/extension/testordchr.awk b/extension/testordchr.awk new file mode 100644 index 0000000..64e53d1 --- /dev/null +++ b/extension/testordchr.awk @@ -0,0 +1,6 @@ +BEGIN { + extension("./ordchr.so", "dlload") + + print "ord(\"a\") is", ord("a") + print "chr(65) is", chr(65) +} diff --git a/extension/xreadlink.c b/extension/xreadlink.c new file mode 100644 index 0000000..91e46d9 --- /dev/null +++ b/extension/xreadlink.c @@ -0,0 +1,95 @@ +/* xreadlink.c -- readlink wrapper to return the link name in malloc'd storage + + Copyright (C) 2001, 2003, 2004, 2005, 2011 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. + If not, write to the Free Software Foundation, + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Jim Meyering */ + +#if HAVE_CONFIG_H +# include +#endif + +#include "xreadlink.h" + +#include +#include +#include +#include +#include +#if HAVE_UNISTD_H +# include +#endif + +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif +#ifndef SSIZE_MAX +# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2)) +#endif + +#define MAXSIZE (SIZE_MAX < SSIZE_MAX ? SIZE_MAX : SSIZE_MAX) + +#include "xalloc.h" + +int plugin_is_GPL_compatible; + +/* Call readlink to get the symbolic link value of FILE. + SIZE is a hint as to how long the link is expected to be; + typically it is taken from st_size. It need not be correct. + Return a pointer to that NUL-terminated string in malloc'd storage. + If readlink fails, return NULL (caller may use errno to diagnose). + If malloc fails, or if the link value is longer than SSIZE_MAX :-), + give a diagnostic and exit. */ + +char * +xreadlink (char const *file, size_t size) +{ + /* The initial buffer size for the link value. A power of 2 + detects arithmetic overflow earlier, but is not required. */ + size_t buf_size = size < MAXSIZE ? size + 1 : MAXSIZE; + + while (1) + { + char *buffer = xmalloc (buf_size); + ssize_t r = readlink (file, buffer, buf_size); + size_t link_length = r; + + /* On AIX 5L v5.3 and HP-UX 11i v2 04/09, readlink returns -1 + with errno == ERANGE if the buffer is too small. */ + if (r < 0 && errno != ERANGE) + { + int saved_errno = errno; + free (buffer); + errno = saved_errno; + return NULL; + } + + if (link_length < buf_size) + { + buffer[link_length] = 0; + return buffer; + } + + free (buffer); + if (buf_size <= MAXSIZE / 2) + buf_size *= 2; + else if (buf_size < MAXSIZE) + buf_size = MAXSIZE; + else + xalloc_die (); + } +} diff --git a/extension/xreadlink.h b/extension/xreadlink.h new file mode 100644 index 0000000..0c16610 --- /dev/null +++ b/extension/xreadlink.h @@ -0,0 +1,23 @@ +/* readlink wrapper to return the link name in malloc'd storage + + Copyright (C) 2001, 2003, 2004, 2011 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. + If not, write to the Free Software Foundation, + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Jim Meyering */ + +#include +char *xreadlink (char const *, size_t); diff --git a/field.c b/field.c new file mode 100644 index 0000000..2e7c150 --- /dev/null +++ b/field.c @@ -0,0 +1,1684 @@ +/* + * field.c - routines for dealing with fields and record parsing + */ + +/* + * Copyright (C) 1986, 1988, 1989, 1991-2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "awk.h" + +/* + * In case that the system doesn't have isblank(). + * Don't bother with autoconf ifdef junk, just force it. + * See dfa.c and regex_internal.h and regcomp.c. Bleah. + */ +static int +is_blank(int c) +{ + return c == ' ' || c == '\t'; +} + +typedef void (* Setfunc)(long, char *, long, NODE *); + +static long (*parse_field)(long, char **, int, NODE *, + Regexp *, Setfunc, NODE *, NODE *, int); +static void rebuild_record(void); +static long re_parse_field(long, char **, int, NODE *, + Regexp *, Setfunc, NODE *, NODE *, int); +static long def_parse_field(long, char **, int, NODE *, + Regexp *, Setfunc, NODE *, NODE *, int); +static long posix_def_parse_field(long, char **, int, NODE *, + Regexp *, Setfunc, NODE *, NODE *, int); +static long null_parse_field(long, char **, int, NODE *, + Regexp *, Setfunc, NODE *, NODE *, int); +static long sc_parse_field(long, char **, int, NODE *, + Regexp *, Setfunc, NODE *, NODE *, int); +static long fw_parse_field(long, char **, int, NODE *, + Regexp *, Setfunc, NODE *, NODE *, int); +static long fpat_parse_field(long, char **, int, NODE *, + Regexp *, Setfunc, NODE *, NODE *, int); +static void set_element(long num, char * str, long len, NODE *arr); +static void grow_fields_arr(long num); +static void set_field(long num, char *str, long len, NODE *dummy); + +static char *parse_extent; /* marks where to restart parse of record */ +static long parse_high_water = 0; /* field number that we have parsed so far */ +static long nf_high_water = 0; /* size of fields_arr */ +static int resave_fs; +static NODE *save_FS; /* save current value of FS when line is read, + * to be used in deferred parsing + */ +static int *FIELDWIDTHS = NULL; + +NODE **fields_arr; /* array of pointers to the field nodes */ +int field0_valid; /* $(>0) has not been changed yet */ +int default_FS; /* TRUE when FS == " " */ +Regexp *FS_re_yes_case = NULL; +Regexp *FS_re_no_case = NULL; +Regexp *FS_regexp = NULL; +Regexp *FPAT_re_yes_case = NULL; +Regexp *FPAT_re_no_case = NULL; +Regexp *FPAT_regexp = NULL; +NODE *Null_field = NULL; + +/* init_fields --- set up the fields array to start with */ + +void +init_fields() +{ + emalloc(fields_arr, NODE **, sizeof(NODE *), "init_fields"); + fields_arr[0] = Nnull_string; + parse_extent = fields_arr[0]->stptr; + save_FS = dupnode(FS_node->var_value); + getnode(Null_field); + *Null_field = *Nnull_string; + Null_field->flags |= FIELD; + Null_field->flags &= ~(NUMCUR|NUMBER|MAYBE_NUM|PERM|MALLOC); + field0_valid = TRUE; +} + +/* grow_fields --- acquire new fields as needed */ + +static void +grow_fields_arr(long num) +{ + int t; + NODE *n; + + erealloc(fields_arr, NODE **, (num + 1) * sizeof(NODE *), "grow_fields_arr"); + for (t = nf_high_water + 1; t <= num; t++) { + getnode(n); + *n = *Null_field; + fields_arr[t] = n; + } + nf_high_water = num; +} + +/* set_field --- set the value of a particular field */ + +/*ARGSUSED*/ +static void +set_field(long num, + char *str, + long len, + NODE *dummy ATTRIBUTE_UNUSED) /* just to make interface same as set_element */ +{ + NODE *n; + + if (num > nf_high_water) + grow_fields_arr(num); + n = fields_arr[num]; + n->stptr = str; + n->stlen = len; + n->flags = (STRCUR|STRING|MAYBE_NUM|FIELD); +} + +/* rebuild_record --- Someone assigned a value to $(something). + Fix up $0 to be right */ + +static void +rebuild_record() +{ + /* + * use explicit unsigned longs for lengths, in case + * a size_t isn't big enough. + */ + unsigned long tlen; + unsigned long ofslen; + NODE *tmp; + NODE *ofs; + char *ops; + char *cops; + long i; + + assert(NF != -1); + + tlen = 0; + ofs = force_string(OFS_node->var_value); + ofslen = ofs->stlen; + for (i = NF; i > 0; i--) { + tmp = fields_arr[i]; + tmp = force_string(tmp); + tlen += tmp->stlen; + } + tlen += (NF - 1) * ofslen; + if ((long) tlen < 0) + tlen = 0; + emalloc(ops, char *, tlen + 2, "rebuild_record"); + cops = ops; + ops[0] = '\0'; + for (i = 1; i <= NF; i++) { + free_wstr(fields_arr[i]); + tmp = fields_arr[i]; + /* copy field */ + if (tmp->stlen == 1) + *cops++ = tmp->stptr[0]; + else if (tmp->stlen != 0) { + memcpy(cops, tmp->stptr, tmp->stlen); + cops += tmp->stlen; + } + /* copy OFS */ + if (i != NF) { + if (ofslen == 1) + *cops++ = ofs->stptr[0]; + else if (ofslen != 0) { + memcpy(cops, ofs->stptr, ofslen); + cops += ofslen; + } + } + } + tmp = make_str_node(ops, tlen, ALREADY_MALLOCED); + + /* + * Since we are about to unref fields_arr[0], we want to find + * any fields that still point into it, and have them point + * into the new field zero. This has to be done intelligently, + * so that unrefing a field doesn't try to unref into the old $0. + */ + for (cops = ops, i = 1; i <= NF; i++) { + if (fields_arr[i]->stlen > 0) { + NODE *n; + getnode(n); + + if ((fields_arr[i]->flags & FIELD) == 0) { + *n = *Null_field; + n->stlen = fields_arr[i]->stlen; + if ((fields_arr[i]->flags & (NUMCUR|NUMBER)) != 0) { + n->flags |= (fields_arr[i]->flags & (NUMCUR|NUMBER)); + n->numbr = fields_arr[i]->numbr; + } + } else { + *n = *(fields_arr[i]); + n->flags &= ~(MALLOC|PERM|STRING); + } + + n->stptr = cops; + unref(fields_arr[i]); + fields_arr[i] = n; + assert((n->flags & WSTRCUR) == 0); + } + cops += fields_arr[i]->stlen + ofslen; + } + + unref(fields_arr[0]); + + fields_arr[0] = tmp; + field0_valid = TRUE; +} + +/* + * set_record: + * setup $0, but defer parsing rest of line until reference is made to $(>0) + * or to NF. At that point, parse only as much as necessary. + * + * Manage a private buffer for the contents of $0. Doing so keeps us safe + * if `getline var' decides to rearrange the contents of the IOBUF that + * $0 might have been pointing into. The cost is the copying of the buffer; + * but better correct than fast. + */ +void +set_record(const char *buf, int cnt) +{ + NODE *n; + static char *databuf; + static unsigned long databuf_size; +#define INITIAL_SIZE 512 +#define MAX_SIZE ((unsigned long) ~0) /* maximally portable ... */ + + reset_record(); + + /* buffer management: */ + if (databuf_size == 0) { /* first time */ + emalloc(databuf, char *, INITIAL_SIZE, "set_record"); + databuf_size = INITIAL_SIZE; + memset(databuf, '\0', INITIAL_SIZE); + + } + /* + * Make sure there's enough room. Since we sometimes need + * to place a sentinel at the end, we make sure + * databuf_size is > cnt after allocation. + */ + if (cnt >= databuf_size) { + while (cnt >= databuf_size && databuf_size <= MAX_SIZE) + databuf_size *= 2; + erealloc(databuf, char *, databuf_size, "set_record"); + memset(databuf, '\0', databuf_size); + } + /* copy the data */ + memcpy(databuf, buf, cnt); + + /* manage field 0: */ + unref(fields_arr[0]); + getnode(n); + n->stptr = databuf; + n->stlen = cnt; + n->valref = 1; + n->type = Node_val; + n->stfmt = -1; + n->flags = (STRING|STRCUR|MAYBE_NUM|FIELD); + fields_arr[0] = n; + +#undef INITIAL_SIZE +#undef MAX_SIZE +} + +/* reset_record --- start over again with current $0 */ + +void +reset_record() +{ + int i; + NODE *n; + + (void) force_string(fields_arr[0]); + + NF = -1; + for (i = 1; i <= parse_high_water; i++) { + unref(fields_arr[i]); + getnode(n); + *n = *Null_field; + fields_arr[i] = n; + } + + parse_high_water = 0; + /* + * $0 = $0 should resplit using the current value of FS. + */ + if (resave_fs) { + resave_fs = FALSE; + unref(save_FS); + save_FS = dupnode(FS_node->var_value); + } + + field0_valid = TRUE; +} + +/* set_NF --- handle what happens to $0 and fields when NF is changed */ + +void +set_NF() +{ + int i; + long nf; + NODE *n; + + assert(NF != -1); + + nf = (long) force_number(NF_node->var_value); + if (nf < 0) + fatal(_("NF set to negative value")); + NF = nf; + + if (NF > nf_high_water) + grow_fields_arr(NF); + if (parse_high_water < NF) { + for (i = parse_high_water + 1; i >= 0 && i <= NF; i++) { + unref(fields_arr[i]); + getnode(n); + *n = *Null_field; + fields_arr[i] = n; + } + } else if (parse_high_water > 0) { + for (i = NF + 1; i >= 0 && i <= parse_high_water; i++) { + unref(fields_arr[i]); + getnode(n); + *n = *Null_field; + fields_arr[i] = n; + } + parse_high_water = NF; + } + field0_valid = FALSE; +} + +/* + * re_parse_field --- parse fields using a regexp. + * + * This is called both from get_field() and from do_split() + * via (*parse_field)(). This variation is for when FS is a regular + * expression -- either user-defined or because RS=="" and FS==" " + */ +static long +re_parse_field(long up_to, /* parse only up to this field number */ + char **buf, /* on input: string to parse; on output: point to start next */ + int len, + NODE *fs ATTRIBUTE_UNUSED, + Regexp *rp, + Setfunc set, /* routine to set the value of the parsed field */ + NODE *n, + NODE *sep_arr, /* array of field separators (maybe NULL) */ + int in_middle) +{ + char *scan = *buf; + long nf = parse_high_water; + char *field; + char *end = scan + len; + int regex_flags = RE_NEED_START; + char *sep; +#if MBS_SUPPORT + size_t mbclen = 0; + mbstate_t mbs; + if (gawk_mb_cur_max > 1) + memset(&mbs, 0, sizeof(mbstate_t)); +#endif + + if (in_middle) + regex_flags |= RE_NO_BOL; + + if (up_to == UNLIMITED) + nf = 0; + if (len == 0) + return nf; + + if (RS_is_null && default_FS) { + sep = scan; + while (scan < end && (*scan == ' ' || *scan == '\t' || *scan == '\n')) + scan++; + if (sep_arr != NULL && sep < scan) + set_element(nf, sep, (long)(scan - sep), sep_arr); + } + + if (rp == NULL) /* use FS */ + rp = FS_regexp; + + field = scan; + while (scan < end + && research(rp, scan, 0, (end - scan), regex_flags) != -1 + && nf < up_to) { + regex_flags |= RE_NO_BOL; + if (REEND(rp, scan) == RESTART(rp, scan)) { /* null match */ +#if MBS_SUPPORT + if (gawk_mb_cur_max > 1) { + mbclen = mbrlen(scan, end-scan, &mbs); + if ((mbclen == 1) || (mbclen == (size_t) -1) + || (mbclen == (size_t) -2) || (mbclen == 0)) { + /* We treat it as a singlebyte character. */ + mbclen = 1; + } + scan += mbclen; + } else +#endif + scan++; + if (scan == end) { + (*set)(++nf, field, (long)(scan - field), n); + up_to = nf; + break; + } + continue; + } + (*set)(++nf, field, + (long)(scan + RESTART(rp, scan) - field), n); + if (sep_arr != NULL) + set_element(nf, scan + RESTART(rp, scan), + (long) (REEND(rp, scan) - RESTART(rp, scan)), sep_arr); + scan += REEND(rp, scan); + field = scan; + if (scan == end) /* FS at end of record */ + (*set)(++nf, field, 0L, n); + } + if (nf != up_to && scan < end) { + (*set)(++nf, scan, (long)(end - scan), n); + scan = end; + } + *buf = scan; + return nf; +} + +/* + * def_parse_field --- default field parsing. + * + * This is called both from get_field() and from do_split() + * via (*parse_field)(). This variation is for when FS is a single space + * character. + */ + +static long +def_parse_field(long up_to, /* parse only up to this field number */ + char **buf, /* on input: string to parse; on output: point to start next */ + int len, + NODE *fs, + Regexp *rp ATTRIBUTE_UNUSED, + Setfunc set, /* routine to set the value of the parsed field */ + NODE *n, + NODE *sep_arr, /* array of field separators (maybe NULL) */ + int in_middle ATTRIBUTE_UNUSED) +{ + char *scan = *buf; + long nf = parse_high_water; + char *field; + char *end = scan + len; + char sav; + char *sep; + + if (up_to == UNLIMITED) + nf = 0; + if (len == 0) + return nf; + + /* + * Nasty special case. If FS set to "", return whole record + * as first field. This is not worth a separate function. + */ + if (fs->stlen == 0) { + (*set)(++nf, *buf, len, n); + *buf += len; + return nf; + } + + /* before doing anything save the char at *end */ + sav = *end; + /* because it will be destroyed now: */ + + *end = ' '; /* sentinel character */ + sep = scan; + for (; nf < up_to; scan++) { + /* + * special case: fs is single space, strip leading whitespace + */ + while (scan < end && (*scan == ' ' || *scan == '\t' || *scan == '\n')) + scan++; + + if (sep_arr != NULL && scan > sep) + set_element(nf, sep, (long) (scan - sep), sep_arr); + + if (scan >= end) + break; + + field = scan; + + while (*scan != ' ' && *scan != '\t' && *scan != '\n') + scan++; + + (*set)(++nf, field, (long)(scan - field), n); + + if (scan == end) + break; + + sep = scan; + } + + /* everything done, restore original char at *end */ + *end = sav; + + *buf = scan; + return nf; +} + +/* + * posix_def_parse_field --- default field parsing. + * + * This is called both from get_field() and from do_split() + * via (*parse_field)(). This variation is for when FS is a single space + * character. The only difference between this and def_parse_field() + * is that this one does not allow newlines to separate fields. + */ + +static long +posix_def_parse_field(long up_to, /* parse only up to this field number */ + char **buf, /* on input: string to parse; on output: point to start next */ + int len, + NODE *fs, + Regexp *rp ATTRIBUTE_UNUSED, + Setfunc set, /* routine to set the value of the parsed field */ + NODE *n, + NODE *dummy ATTRIBUTE_UNUSED, /* sep_arr not needed here: hence dummy */ + int in_middle ATTRIBUTE_UNUSED) +{ + char *scan = *buf; + long nf = parse_high_water; + char *field; + char *end = scan + len; + char sav; + + if (up_to == UNLIMITED) + nf = 0; + if (len == 0) + return nf; + + /* + * Nasty special case. If FS set to "", return whole record + * as first field. This is not worth a separate function. + */ + if (fs->stlen == 0) { + (*set)(++nf, *buf, len, n); + *buf += len; + return nf; + } + + /* before doing anything save the char at *end */ + sav = *end; + /* because it will be destroyed now: */ + + *end = ' '; /* sentinel character */ + for (; nf < up_to; scan++) { + /* + * special case: fs is single space, strip leading whitespace + */ + while (scan < end && (*scan == ' ' || *scan == '\t')) + scan++; + if (scan >= end) + break; + field = scan; + while (*scan != ' ' && *scan != '\t') + scan++; + (*set)(++nf, field, (long)(scan - field), n); + if (scan == end) + break; + } + + /* everything done, restore original char at *end */ + *end = sav; + + *buf = scan; + return nf; +} + +/* + * null_parse_field --- each character is a separate field + * + * This is called both from get_field() and from do_split() + * via (*parse_field)(). This variation is for when FS is the null string. + */ +static long +null_parse_field(long up_to, /* parse only up to this field number */ + char **buf, /* on input: string to parse; on output: point to start next */ + int len, + NODE *fs ATTRIBUTE_UNUSED, + Regexp *rp ATTRIBUTE_UNUSED, + Setfunc set, /* routine to set the value of the parsed field */ + NODE *n, + NODE *sep_arr, /* array of field separators (maybe NULL) */ + int in_middle ATTRIBUTE_UNUSED) +{ + char *scan = *buf; + long nf = parse_high_water; + char *end = scan + len; + + if (up_to == UNLIMITED) + nf = 0; + if (len == 0) + return nf; + +#if MBS_SUPPORT + if (gawk_mb_cur_max > 1) { + mbstate_t mbs; + memset(&mbs, 0, sizeof(mbstate_t)); + for (; nf < up_to && scan < end;) { + size_t mbclen = mbrlen(scan, end-scan, &mbs); + if ((mbclen == 1) || (mbclen == (size_t) -1) + || (mbclen == (size_t) -2) || (mbclen == 0)) { + /* We treat it as a singlebyte character. */ + mbclen = 1; + } + if (sep_arr != NULL && nf > 0) + set_element(nf, scan, 0L, sep_arr); + (*set)(++nf, scan, mbclen, n); + scan += mbclen; + } + } else +#endif + for (; nf < up_to && scan < end; scan++) { + if (sep_arr != NULL && nf > 0) + set_element(nf, scan, 0L, sep_arr); + (*set)(++nf, scan, 1L, n); + } + + *buf = scan; + return nf; +} + +/* + * sc_parse_field --- single character field separator + * + * This is called both from get_field() and from do_split() + * via (*parse_field)(). This variation is for when FS is a single character + * other than space. + */ +static long +sc_parse_field(long up_to, /* parse only up to this field number */ + char **buf, /* on input: string to parse; on output: point to start next */ + int len, + NODE *fs, + Regexp *rp ATTRIBUTE_UNUSED, + Setfunc set, /* routine to set the value of the parsed field */ + NODE *n, + NODE *sep_arr, /* array of field separators (maybe NULL) */ + int in_middle ATTRIBUTE_UNUSED) +{ + char *scan = *buf; + char fschar; + long nf = parse_high_water; + char *field; + char *end = scan + len; + char sav; +#if MBS_SUPPORT + size_t mbclen = 0; + mbstate_t mbs; + if (gawk_mb_cur_max > 1) + memset(&mbs, 0, sizeof(mbstate_t)); +#endif + + if (up_to == UNLIMITED) + nf = 0; + if (len == 0) + return nf; + + if (RS_is_null && fs->stlen == 0) + fschar = '\n'; + else + fschar = fs->stptr[0]; + + /* before doing anything save the char at *end */ + sav = *end; + /* because it will be destroyed now: */ + *end = fschar; /* sentinel character */ + + for (; nf < up_to;) { + field = scan; +#if MBS_SUPPORT + if (gawk_mb_cur_max > 1) { + while (*scan != fschar) { + mbclen = mbrlen(scan, end-scan, &mbs); + if ((mbclen == 1) || (mbclen == (size_t) -1) + || (mbclen == (size_t) -2) || (mbclen == 0)) { + /* We treat it as a singlebyte character. */ + mbclen = 1; + } + scan += mbclen; + } + } else +#endif + while (*scan != fschar) + scan++; + (*set)(++nf, field, (long)(scan - field), n); + if (scan == end) + break; + if (sep_arr != NULL) + set_element(nf, scan, 1L, sep_arr); + scan++; + if (scan == end) { /* FS at end of record */ + (*set)(++nf, field, 0L, n); + break; + } + } + + /* everything done, restore original char at *end */ + *end = sav; + + *buf = scan; + return nf; +} + +/* + * fw_parse_field --- field parsing using FIELDWIDTHS spec + * + * This is called from get_field() via (*parse_field)(). + * This variation is for fields are fixed widths. + */ +static long +fw_parse_field(long up_to, /* parse only up to this field number */ + char **buf, /* on input: string to parse; on output: point to start next */ + int len, + NODE *fs ATTRIBUTE_UNUSED, + Regexp *rp ATTRIBUTE_UNUSED, + Setfunc set, /* routine to set the value of the parsed field */ + NODE *n, + NODE *dummy ATTRIBUTE_UNUSED, /* sep_arr not needed here: hence dummy */ + int in_middle ATTRIBUTE_UNUSED) +{ + char *scan = *buf; + long nf = parse_high_water; + char *end = scan + len; +#if MBS_SUPPORT + int nmbc; + size_t mbclen; + size_t mbslen; + size_t lenrest; + char *mbscan; + mbstate_t mbs; + + memset(&mbs, 0, sizeof(mbstate_t)); +#endif + + if (up_to == UNLIMITED) + nf = 0; + if (len == 0) + return nf; + for (; nf < up_to && (len = FIELDWIDTHS[nf+1]) != -1; ) { +#if MBS_SUPPORT + if (gawk_mb_cur_max > 1) { + nmbc = 0; + mbslen = 0; + mbscan = scan; + lenrest = end - scan; + while (nmbc < len && mbslen < lenrest) { + mbclen = mbrlen(mbscan, end - mbscan, &mbs); + if ( mbclen == 1 + || mbclen == (size_t) -1 + || mbclen == (size_t) -2 + || mbclen == 0) { + /* We treat it as a singlebyte character. */ + mbclen = 1; + } + if (mbclen <= end - mbscan) { + mbscan += mbclen; + mbslen += mbclen; + ++nmbc; + } + } + (*set)(++nf, scan, (long) mbslen, n); + scan += mbslen; + } + else +#endif + { + if (len > end - scan) + len = end - scan; + (*set)(++nf, scan, (long) len, n); + scan += len; + } + } + if (len == -1) + *buf = end; + else + *buf = scan; + return nf; +} + +/* invalidate_field0 --- $0 needs reconstruction */ + +void +invalidate_field0() +{ + field0_valid = FALSE; +} + +/* get_field --- return a particular $n */ + +/* assign is not NULL if this field is on the LHS of an assign */ + +NODE ** +get_field(long requested, Func_ptr *assign) +{ + int in_middle = FALSE; + /* + * if requesting whole line but some other field has been altered, + * then the whole line must be rebuilt + */ + if (requested == 0) { + if (! field0_valid) { + /* first, parse remainder of input record */ + if (NF == -1) { + NF = (*parse_field)(UNLIMITED - 1, &parse_extent, + fields_arr[0]->stlen - + (parse_extent - fields_arr[0]->stptr), + save_FS, FS_regexp, set_field, + (NODE *) NULL, + (NODE *) NULL, + in_middle); + parse_high_water = NF; + } + rebuild_record(); + } + if (assign != NULL) + *assign = reset_record; + return &fields_arr[0]; + } + + /* assert(requested > 0); */ + +#if 0 + if (assign != NULL) + field0_valid = FALSE; /* $0 needs reconstruction */ +#else + /* + * Keep things uniform. Also, mere intention of assigning something + * to $n should not make $0 invalid. Makes sense to invalidate $0 + * after the actual assignment is performed. Not a real issue in + * the interpreter otherwise, but causes problem in the + * debugger when watching or printing fields. + */ + + if (assign != NULL) + *assign = invalidate_field0; /* $0 needs reconstruction */ +#endif + + if (requested <= parse_high_water) /* already parsed this field */ + return &fields_arr[requested]; + + if (NF == -1) { /* have not yet parsed to end of record */ + /* + * parse up to requested fields, calling set_field() for each, + * saving in parse_extent the point where the parse left off + */ + if (parse_high_water == 0) /* starting at the beginning */ + parse_extent = fields_arr[0]->stptr; + else + in_middle = TRUE; + parse_high_water = (*parse_field)(requested, &parse_extent, + fields_arr[0]->stlen - (parse_extent - fields_arr[0]->stptr), + save_FS, NULL, set_field, (NODE *) NULL, (NODE *) NULL, in_middle); + + /* + * if we reached the end of the record, set NF to the number of + * fields so far. Note that requested might actually refer to + * a field that is beyond the end of the record, but we won't + * set NF to that value at this point, since this is only a + * reference to the field and NF only gets set if the field + * is assigned to -- this case is handled below + */ + if (parse_extent == fields_arr[0]->stptr + fields_arr[0]->stlen) + NF = parse_high_water; + else if (parse_field == fpat_parse_field) { + /* FPAT parsing is wierd, isolate the special cases */ + char *rec_start = fields_arr[0]->stptr; + char *rec_end = fields_arr[0]->stptr + fields_arr[0]->stlen; + + if ( parse_extent > rec_end + || (parse_extent > rec_start && parse_extent < rec_end && requested == UNLIMITED-1)) + NF = parse_high_water; + else if (parse_extent == rec_start) /* could be no match for FPAT */ + NF = 0; + } + if (requested == UNLIMITED - 1) /* UNLIMITED-1 means set NF */ + requested = parse_high_water; + } + if (parse_high_water < requested) { /* requested beyond end of record */ + if (assign != NULL) { /* expand record */ + if (requested > nf_high_water) + grow_fields_arr(requested); + + NF = requested; + parse_high_water = requested; + } else + return &Null_field; + } + + return &fields_arr[requested]; +} + +/* set_element --- set an array element, used by do_split() */ + +static void +set_element(long num, char *s, long len, NODE *n) +{ + NODE *it; + NODE **lhs; + NODE *sub; + + it = make_string(s, len); + it->flags |= MAYBE_NUM; + sub = make_number((AWKNUM) (num)); + lhs = assoc_lookup(n, sub, FALSE); + unref(sub); + unref(*lhs); + *lhs = it; +} + +/* do_split --- implement split(), semantics are same as for field splitting */ + +NODE * +do_split(int nargs) +{ + NODE *src, *arr, *sep, *fs, *tmp, *sep_arr = NULL; + char *s; + long (*parseit)(long, char **, int, NODE *, + Regexp *, Setfunc, NODE *, NODE *, int); + Regexp *rp = NULL; + + if (nargs == 4) { + static short warned1 = FALSE, warned2 = FALSE; + + if (do_traditional || do_posix) { + fatal(_("split: fourth argument is a gawk extension")); + } + sep_arr = POP_PARAM(); + if (sep_arr->type != Node_var_array) + fatal(_("split: fourth argument is not an array")); + if (do_lint && ! warned1) { + warned1 = TRUE; + lintwarn(_("split: fourth argument is a gawk extension")); + } + if (do_lint_old && ! warned2) { + warned2 = TRUE; + warning(_("split: fourth argument is a gawk extension")); + } + } + + sep = POP(); + arr = POP_PARAM(); + if (arr->type != Node_var_array) + fatal(_("split: second argument is not an array")); + + if (sep_arr != NULL) { + if (sep_arr == arr) + fatal(_("split: cannot use the same array for second and fourth args")); + + /* This checks need to be done before clearing any of the arrays */ + for (tmp = sep_arr->parent_array; tmp != NULL; tmp = tmp->parent_array) + if (tmp == arr) + fatal(_("split: cannot use a subarray of second arg for fourth arg")); + for (tmp = arr->parent_array; tmp != NULL; tmp = tmp->parent_array) + if (tmp == sep_arr) + fatal(_("split: cannot use a subarray of fourth arg for second arg")); + assoc_clear(sep_arr); + } + assoc_clear(arr); + + src = TOP_STRING(); + if (src->stlen == 0) { + /* + * Skip the work if first arg is the null string. + */ + decr_sp(); + DEREF(src); + return make_number((AWKNUM) 0); + } + + if ((sep->re_flags & FS_DFLT) != 0 && current_field_sep() != Using_FIELDWIDTHS && ! RS_is_null) { + parseit = parse_field; + fs = force_string(FS_node->var_value); + rp = FS_regexp; + } else { + fs = sep->re_exp; + + if (fs->stlen == 0) { + static short warned = FALSE; + + parseit = null_parse_field; + + if (do_lint && ! warned) { + warned = TRUE; + lintwarn(_("split: null string for third arg is a gawk extension")); + } + } else if (fs->stlen == 1 && (sep->re_flags & CONSTANT) == 0) { + if (fs->stptr[0] == ' ') { + if (do_posix) + parseit = posix_def_parse_field; + else + parseit = def_parse_field; + } else + parseit = sc_parse_field; + } else { + parseit = re_parse_field; + rp = re_update(sep); + } + } + + s = src->stptr; + tmp = make_number((AWKNUM) (*parseit)(UNLIMITED, &s, (int) src->stlen, + fs, rp, set_element, arr, sep_arr, FALSE)); + + decr_sp(); + DEREF(src); + return tmp; +} + +/* + * do_patsplit --- implement patsplit(), semantics are same as for field + * splitting with FPAT. + */ + +NODE * +do_patsplit(int nargs) +{ + NODE *src, *arr, *sep, *fpat, *tmp, *sep_arr = NULL; + char *s; + Regexp *rp = NULL; + + if (nargs == 4) { + sep_arr = POP_PARAM(); + if (sep_arr->type != Node_var_array) + fatal(_("patsplit: fourth argument is not an array")); + } + sep = POP(); + arr = POP_PARAM(); + if (arr->type != Node_var_array) + fatal(_("patsplit: second argument is not an array")); + + src = TOP_STRING(); + + fpat = sep->re_exp; + if (fpat->stlen == 0) + fatal(_("patsplit: third argument must be non-null")); + + if (sep_arr != NULL) { + if (sep_arr == arr) + fatal(_("patsplit: cannot use the same array for second and fourth args")); + + /* This checks need to be done before clearing any of the arrays */ + for (tmp = sep_arr->parent_array; tmp != NULL; tmp = tmp->parent_array) + if (tmp == arr) + fatal(_("patsplit: cannot use a subarray of second arg for fourth arg")); + for (tmp = arr->parent_array; tmp != NULL; tmp = tmp->parent_array) + if (tmp == sep_arr) + fatal(_("patsplit: cannot use a subarray of fourth arg for second arg")); + assoc_clear(sep_arr); + } + assoc_clear(arr); + + if (src->stlen == 0) { + /* + * Skip the work if first arg is the null string. + */ + tmp = make_number((AWKNUM) 0); + } else { + rp = re_update(sep); + s = src->stptr; + tmp = make_number((AWKNUM) fpat_parse_field(UNLIMITED, &s, + (int) src->stlen, fpat, rp, + set_element, arr, sep_arr, FALSE)); + } + + decr_sp(); /* 1st argument not POP-ed */ + DEREF(src); + return tmp; +} + +/* set_FIELDWIDTHS --- handle an assignment to FIELDWIDTHS */ + +void +set_FIELDWIDTHS() +{ + char *scan; + char *end; + int i; + static int fw_alloc = 4; + static short warned = FALSE; + int fatal_error = FALSE; + + if (do_lint && ! warned) { + warned = TRUE; + lintwarn(_("`FIELDWIDTHS' is a gawk extension")); + } + if (do_traditional) /* quick and dirty, does the trick */ + return; + + /* + * If changing the way fields are split, obey least-suprise + * semantics, and force $0 to be split totally. + */ + if (fields_arr != NULL) + (void) get_field(UNLIMITED - 1, 0); + + parse_field = fw_parse_field; + scan = force_string(FIELDWIDTHS_node->var_value)->stptr; + + if (FIELDWIDTHS == NULL) + emalloc(FIELDWIDTHS, int *, fw_alloc * sizeof(int), "set_FIELDWIDTHS"); + FIELDWIDTHS[0] = 0; + for (i = 1; ; i++) { + unsigned long int tmp; + if (i + 2 >= fw_alloc) { + fw_alloc *= 2; + erealloc(FIELDWIDTHS, int *, fw_alloc * sizeof(int), "set_FIELDWIDTHS"); + } + /* Initialize value to be end of list */ + FIELDWIDTHS[i] = -1; + /* Ensure that there is no leading `-' sign. Otherwise, + strtoul would accept it and return a bogus result. */ + while (is_blank(*scan)) { + ++scan; + } + if (*scan == '-') { + fatal_error = TRUE; + break; + } + if (*scan == '\0') + break; + + /* Detect an invalid base-10 integer, a valid value that + is followed by something other than a blank or '\0', + or a value that is not in the range [1..INT_MAX]. */ + errno = 0; + tmp = strtoul(scan, &end, 10); + if (errno != 0 + || (*end != '\0' && ! is_blank(*end)) + || !(0 < tmp && tmp <= INT_MAX) + ) { + fatal_error = TRUE; + break; + } + FIELDWIDTHS[i] = tmp; + scan = end; + /* Skip past any trailing blanks. */ + while (is_blank(*scan)) { + ++scan; + } + if (*scan == '\0') + break; + } + FIELDWIDTHS[i+1] = -1; + + update_PROCINFO_str("FS", "FIELDWIDTHS"); + if (fatal_error) + fatal(_("invalid FIELDWIDTHS value, near `%s'"), + scan); +} + +/* set_FS --- handle things when FS is assigned to */ + +void +set_FS() +{ + char buf[10]; + NODE *fs; + static NODE *save_fs = NULL; + static NODE *save_rs = NULL; + int remake_re = TRUE; + + /* + * If changing the way fields are split, obey least-surprise + * semantics, and force $0 to be split totally. + */ + if (fields_arr != NULL) + (void) get_field(UNLIMITED - 1, 0); + + /* It's possible that only IGNORECASE changed, or FS = FS */ + /* + * This comparison can't use cmp_nodes(), which pays attention + * to IGNORECASE, and that's not what we want. + */ + if (save_fs + && FS_node->var_value->stlen == save_fs->stlen + && memcmp(FS_node->var_value->stptr, save_fs->stptr, save_fs->stlen) == 0 + && save_rs + && RS_node->var_value->stlen == save_rs->stlen + && memcmp(RS_node->var_value->stptr, save_rs->stptr, save_rs->stlen) == 0) { + if (FS_regexp != NULL) + FS_regexp = (IGNORECASE ? FS_re_no_case : FS_re_yes_case); + + /* FS = FS */ + if (current_field_sep() == Using_FS) { + return; + } else { + remake_re = FALSE; + goto choose_fs_function; + } + } + + unref(save_fs); + save_fs = dupnode(FS_node->var_value); + unref(save_rs); + save_rs = dupnode(RS_node->var_value); + resave_fs = TRUE; + + /* If FS_re_no_case assignment is fatal (make_regexp in remake_re) + * FS_regexp will be NULL with a non-null FS_re_yes_case. + * refree() handles null argument; no need for `if (FS_regexp != NULL)' below. + * Please do not remerge. + */ + refree(FS_re_yes_case); + refree(FS_re_no_case); + FS_re_yes_case = FS_re_no_case = FS_regexp = NULL; + + +choose_fs_function: + buf[0] = '\0'; + default_FS = FALSE; + fs = force_string(FS_node->var_value); + + if (! do_traditional && fs->stlen == 0) { + static short warned = FALSE; + + parse_field = null_parse_field; + + if (do_lint && ! warned) { + warned = TRUE; + lintwarn(_("null string for `FS' is a gawk extension")); + } + } else if (fs->stlen > 1) { + if (do_lint_old) + warning(_("old awk does not support regexps as value of `FS'")); + parse_field = re_parse_field; + } else if (RS_is_null) { + /* we know that fs->stlen <= 1 */ + parse_field = sc_parse_field; + if (fs->stlen == 1) { + if (fs->stptr[0] == ' ') { + default_FS = TRUE; + strcpy(buf, "[ \t\n]+"); + } else if (fs->stptr[0] == '\\') { + /* yet another special case */ + strcpy(buf, "[\\\\\n]"); + } else if (fs->stptr[0] != '\n') + sprintf(buf, "[%c\n]", fs->stptr[0]); + } + } else { + if (do_posix) + parse_field = posix_def_parse_field; + else + parse_field = def_parse_field; + + if (fs->stlen == 1) { + if (fs->stptr[0] == ' ') + default_FS = TRUE; + else if (fs->stptr[0] == '\\') + /* same special case */ + strcpy(buf, "[\\\\]"); + else + parse_field = sc_parse_field; + } + } + if (remake_re) { + refree(FS_re_yes_case); + refree(FS_re_no_case); + FS_re_yes_case = FS_re_no_case = FS_regexp = NULL; + + if (buf[0] != '\0') { + FS_re_yes_case = make_regexp(buf, strlen(buf), FALSE, TRUE, TRUE); + FS_re_no_case = make_regexp(buf, strlen(buf), TRUE, TRUE, TRUE); + FS_regexp = (IGNORECASE ? FS_re_no_case : FS_re_yes_case); + parse_field = re_parse_field; + } else if (parse_field == re_parse_field) { + FS_re_yes_case = make_regexp(fs->stptr, fs->stlen, FALSE, TRUE, TRUE); + FS_re_no_case = make_regexp(fs->stptr, fs->stlen, TRUE, TRUE, TRUE); + FS_regexp = (IGNORECASE ? FS_re_no_case : FS_re_yes_case); + } else + FS_re_yes_case = FS_re_no_case = FS_regexp = NULL; + } + + /* + * For FS = "c", we don't use IGNORECASE. But we must use + * re_parse_field to get the character and the newline as + * field separators. + */ + if (fs->stlen == 1 && parse_field == re_parse_field) + FS_regexp = FS_re_yes_case; + + update_PROCINFO_str("FS", "FS"); +} + +/* current_field_sep --- return what field separator is */ + +field_sep_type +current_field_sep() +{ + if (parse_field == fw_parse_field) + return Using_FIELDWIDTHS; + else if (parse_field == fpat_parse_field) + return Using_FPAT; + else + return Using_FS; +} + +/* update_PROCINFO_str --- update PROCINFO[sub] with string value */ + +void +update_PROCINFO_str(const char *subscript, const char *str) +{ + NODE **aptr; + NODE *tmp; + + if (PROCINFO_node == NULL) + return; + tmp = make_string(subscript, strlen(subscript)); + aptr = assoc_lookup(PROCINFO_node, tmp, FALSE); + unref(tmp); + unref(*aptr); + *aptr = make_string(str, strlen(str)); +} + +/* update_PROCINFO_num --- update PROCINFO[sub] with numeric value */ + +void +update_PROCINFO_num(const char *subscript, AWKNUM val) +{ + NODE **aptr; + NODE *tmp; + + if (PROCINFO_node == NULL) + return; + tmp = make_string(subscript, strlen(subscript)); + aptr = assoc_lookup(PROCINFO_node, tmp, FALSE); + unref(tmp); + unref(*aptr); + *aptr = make_number(val); +} + +/* set_FPAT --- handle an assignment to FPAT */ + +void +set_FPAT() +{ + static short warned = FALSE; + static NODE *save_fpat = NULL; + int remake_re = TRUE; + NODE *fpat; + + if (do_lint && ! warned) { + warned = TRUE; + lintwarn(_("`FPAT' is a gawk extension")); + } + if (do_traditional) /* quick and dirty, does the trick */ + return; + + /* + * If changing the way fields are split, obey least-suprise + * semantics, and force $0 to be split totally. + */ + if (fields_arr != NULL) + (void) get_field(UNLIMITED - 1, 0); + + /* It's possible that only IGNORECASE changed, or FPAT = FPAT */ + /* + * This comparison can't use cmp_nodes(), which pays attention + * to IGNORECASE, and that's not what we want. + */ + if (save_fpat + && FPAT_node->var_value->stlen == save_fpat->stlen + && memcmp(FPAT_node->var_value->stptr, save_fpat->stptr, save_fpat->stlen) == 0) { + if (FPAT_regexp != NULL) + FPAT_regexp = (IGNORECASE ? FPAT_re_no_case : FPAT_re_yes_case); + + /* FPAT = FPAT */ + if (current_field_sep() == Using_FPAT) { + return; + } else { + remake_re = FALSE; + goto set_fpat_function; + } + } + + unref(save_fpat); + save_fpat = dupnode(FPAT_node->var_value); + refree(FPAT_re_yes_case); + refree(FPAT_re_no_case); + FPAT_re_yes_case = FPAT_re_no_case = FPAT_regexp = NULL; + +set_fpat_function: + fpat = force_string(FPAT_node->var_value); + parse_field = fpat_parse_field; + + if (remake_re) { + refree(FPAT_re_yes_case); + refree(FPAT_re_no_case); + FPAT_re_yes_case = FPAT_re_no_case = FPAT_regexp = NULL; + + FPAT_re_yes_case = make_regexp(fpat->stptr, fpat->stlen, FALSE, TRUE, TRUE); + FPAT_re_no_case = make_regexp(fpat->stptr, fpat->stlen, TRUE, TRUE, TRUE); + FPAT_regexp = (IGNORECASE ? FPAT_re_no_case : FPAT_re_yes_case); + } + + update_PROCINFO_str("FS", "FPAT"); +} + +/* + * increment_scan --- macro to move scan pointer ahead by one character. + * Implementation varies if doing MBS or not. + */ + +#if MBS_SUPPORT +#define increment_scan(scanp, len) incr_scan(scanp, len, & mbs) +#else +#define increment_scan(scanp, len) ((*scanp)++) +#endif + +#if MBS_SUPPORT +/* incr_scan --- MBS version of increment_scan() */ + +static void +incr_scan(char **scanp, size_t len, mbstate_t *mbs) +{ + size_t mbclen = 0; + + if (gawk_mb_cur_max > 1) { + mbclen = mbrlen(*scanp, len, mbs); + if ( (mbclen == 1) + || (mbclen == (size_t) -1) + || (mbclen == (size_t) -2) + || (mbclen == 0)) { + /* We treat it as a singlebyte character. */ + mbclen = 1; + } + *scanp += mbclen; + } else + (*scanp)++; +} +#endif + +/* + * fpat_parse_field --- parse fields using a regexp. + * + * This is called both from get_field() and from do_patsplit() + * via (*parse_field)(). This variation is for when FPAT is a regular + * expression -- use the value to find field contents. + * + * This was really hard to get right. It happens to bear many resemblances + * to issues I had with getting gsub right with null matches. When dealing + * with that I prototyped in awk and had the foresight to save the awk code + * over in the C file. Starting with that as a base, I finally got to this + * awk code to do what I needed, and then translated it into C. Fortunately + * the C code bears a closer correspondance to the awk code here than over + * by gsub. + * + * BEGIN { + * FALSE = 0 + * TRUE = 1 + * + * fpat[1] = "([^,]*)|(\"[^\"]+\")" + * fpat[2] = fpat[1] + * fpat[3] = fpat[1] + * fpat[4] = "aa+" + * fpat[5] = fpat[4] + * + * data[1] = "Robbins,,Arnold," + * data[2] = "Smith,,\"1234 A Pretty Place, NE\",Sometown,NY,12345-6789,USA" + * data[3] = "Robbins,Arnold,\"1234 A Pretty Place, NE\",Sometown,NY,12345-6789,USA" + * data[4] = "bbbaaacccdddaaaaaqqqq" + * data[5] = "bbbaaacccdddaaaaaqqqqa" # should get trailing qqqa + * + * for (i = 1; i in data; i++) { + * printf("Splitting: <%s>\n", data[i]) + * n = mypatsplit(data[i], fields, fpat[i], seps) + * print "n =", n + * for (j = 1; j <= n; j++) + * printf("fields[%d] = <%s>\n", j, fields[j]) + * for (j = 0; j in seps; j++) + * printf("seps[%s] = <%s>\n", j, seps[j]) + * } + * } + * + * function mypatsplit(string, array, pattern, seps, + * eosflag, non_empty, nf) # locals + * { + * delete array + * delete seps + * if (length(string) == 0) + * return 0 + * + * eosflag = non_empty = FALSE + * nf = 0 + * while (match(string, pattern)) { + * if (RLENGTH > 0) { # easy case + * non_empty = TRUE + * if (! (nf in seps)) { + * if (RSTART == 1) # match at front of string + * seps[nf] = "" + * else + * seps[nf] = substr(string, 1, RSTART - 1) + * } + * array[++nf] = substr(string, RSTART, RLENGTH) + * string = substr(string, RSTART+RLENGTH) + * if (length(string) == 0) + * break + * } else if (non_empty) { + * # last match was non-empty, and at the + * # current character we get a zero length match, + * # which we don't want, so skip over it + * non_empty = FALSE + * seps[nf] = substr(string, 1, 1) + * string = substr(string, 2) + * } else { + * # 0 length match + * if (! (nf in seps)) { + * if (RSTART == 1) + * seps[nf] = "" + * else + * seps[nf] = substr(string, 1, RSTART - 1) + * } + * array[++nf] = "" + * if (! non_empty && ! eosflag) { # prev was empty + * seps[nf] = substr(string, 1, 1) + * } + * if (RSTART == 1) { + * string = substr(string, 2) + * } else { + * string = substr(string, RSTART + 1) + * } + * non_empty = FALSE + * } + * if (length(string) == 0) { + * if (eosflag) + * break + * else + * eosflag = TRUE + * } + * } + * if (length(string) > 0) + * seps[nf] = string + * + * return length(array) + * } + */ +static long +fpat_parse_field(long up_to, /* parse only up to this field number */ + char **buf, /* on input: string to parse; on output: point to start next */ + int len, + NODE *fs ATTRIBUTE_UNUSED, + Regexp *rp, + Setfunc set, /* routine to set the value of the parsed field */ + NODE *n, + NODE *sep_arr, /* array of field separators (may be NULL) */ + int in_middle) +{ + char *scan = *buf; + long nf = parse_high_water; + char *start; + char *end = scan + len; + int regex_flags = RE_NEED_START; + int need_to_set_sep; + int non_empty; + int eosflag; +#if MBS_SUPPORT + mbstate_t mbs; + + if (gawk_mb_cur_max > 1) + memset(&mbs, 0, sizeof(mbstate_t)); +#endif + + if (up_to == UNLIMITED) + nf = 0; + + if (len == 0) + return nf; + + if (rp == NULL) /* use FPAT */ + rp = FPAT_regexp; + + if (in_middle) { + regex_flags |= RE_NO_BOL; + non_empty = rp->non_empty; + } else + non_empty = FALSE; + + eosflag = FALSE; + need_to_set_sep = TRUE; + start = scan; + while (research(rp, scan, 0, (end - scan), regex_flags) != -1 + && nf < up_to) { + + if (REEND(rp, scan) > RESTART(rp, scan)) { /* if (RLENGTH > 0) */ + non_empty = TRUE; + if (sep_arr != NULL && need_to_set_sep) { + if (RESTART(rp, scan) == 0) /* match at front */ + set_element(nf, start, 0L, sep_arr); + else + set_element(nf, + start, + (long) RESTART(rp, scan), + sep_arr); + } + /* field is text that matched */ + (*set)(++nf, + scan + RESTART(rp, scan), + (long)(REEND(rp, scan) - RESTART(rp, scan)), + n); + + scan += REEND(rp, scan); + if (scan >= end) + break; + need_to_set_sep = TRUE; + } else if (non_empty) { /* else if non_empty */ + /* + * last match was non-empty, and at the + * current character we get a zero length match, + * which we don't want, so skip over it + */ + non_empty = FALSE; + if (sep_arr != NULL) { + need_to_set_sep = FALSE; + set_element(nf, start, 1L, sep_arr); + } + increment_scan(& scan, end - scan); + } else { + /* 0 length match */ + if (sep_arr != NULL && need_to_set_sep) { + if (RESTART(rp, scan) == 0) /* RSTART == 1 */ + set_element(nf, start, 0L, sep_arr); + else + set_element(nf, start, + (long) RESTART(rp, scan), + sep_arr); + } + need_to_set_sep = TRUE; + (*set)(++nf, scan, 0L, n); + if (! non_empty && ! eosflag) { /* prev was empty */ + if (sep_arr != NULL) { + set_element(nf, start, 1L, sep_arr); + need_to_set_sep = FALSE; + } + } + if (RESTART(rp, scan) == 0) + increment_scan(& scan, end - scan); + else { + scan += RESTART(rp, scan); + } + non_empty = FALSE; + } + if (scan >= end) { /* length(string) == 0 */ + if (eosflag) + break; + else + eosflag = TRUE; + } + + start = scan; + } + if (scan < end) { + if (sep_arr != NULL) + set_element(nf, scan, (long) (end - scan), sep_arr); + } + + *buf = scan; + rp->non_empty = non_empty; + return nf; +} diff --git a/floatcomp.c b/floatcomp.c new file mode 100644 index 0000000..9d24a67 --- /dev/null +++ b/floatcomp.c @@ -0,0 +1,112 @@ +/* + * floatcomp.c - Isolate floating point details. + */ + +/* + * Copyright (C) 1986, 1988, 1989, 1991-2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "awk.h" +#include + +/* Assume IEEE-754 arithmetic on pre-C89 hosts. */ +#ifndef FLT_RADIX +#define FLT_RADIX 2 +#endif +#ifndef FLT_MANT_DIG +#define FLT_MANT_DIG 24 +#endif +#ifndef DBL_MANT_DIG +#define DBL_MANT_DIG 53 +#endif + +/* + * The number of base-FLT_RADIX digits in an AWKNUM fraction, assuming + * that AWKNUM is not long double. + */ +#define AWKSMALL_MANT_DIG \ + (sizeof (AWKNUM) == sizeof (double) ? DBL_MANT_DIG : FLT_MANT_DIG) + +/* + * The number of base-FLT_DIGIT digits in an AWKNUM fraction, even if + * AWKNUM is long double. Don't mention 'long double' unless + * LDBL_MANT_DIG is defined, for the sake of ancient compilers that + * lack 'long double'. + */ +#ifdef LDBL_MANT_DIG +#define AWKNUM_MANT_DIG \ + (sizeof (AWKNUM) == sizeof (long double) ? LDBL_MANT_DIG : AWKSMALL_MANT_DIG) +#else +#define AWKNUM_MANT_DIG AWKSMALL_MANT_DIG +#endif + +/* + * The number of bits in an AWKNUM fraction, assuming FLT_RADIX is + * either 2 or 16. IEEE and VAX formats use radix 2, and IBM + * mainframe format uses radix 16; we know of no other radices in + * practical use. + */ +#if FLT_RADIX != 2 && FLT_RADIX != 16 +Please port the following code to your weird host; +#endif +#define AWKNUM_FRACTION_BITS (AWKNUM_MANT_DIG * (FLT_RADIX == 2 ? 1 : 4)) +#define DBL_FRACTION_BITS (DBL_MANT_DIG * (FLT_RADIX == 2 ? 1 : 4)) + +/* + * Floor and Ceil --- Work around a problem in conversion of + * doubles to exact integers. + */ + +/* Floor --- do floor(), also for Cray */ + +AWKNUM +Floor(AWKNUM n) +{ + return floor(n); +} + +/* Ceil --- do ceil(), also for Cray */ + +AWKNUM +Ceil(AWKNUM n) +{ + return ceil(n); +} + +#ifdef HAVE_UINTMAX_T +/* adjust_uint --- fiddle with values, ask Paul Eggert to explain */ + +uintmax_t +adjust_uint(uintmax_t n) +{ + /* + * If uintmax_t is so wide that AWKNUM cannot represent all its + * values, strip leading nonzero bits of integers that are so large + * that they cannot be represented exactly as AWKNUMs, so that their + * low order bits are represented exactly, without rounding errors. + * This is more desirable in practice, since it means the user sees + * integers that are the same width as the AWKNUM fractions. + */ + if (AWKNUM_FRACTION_BITS < CHAR_BIT * sizeof n) + n &= ((uintmax_t) 1 << AWKNUM_FRACTION_BITS) - 1; + + return n; +} +#endif /* HAVE_UINTMAX_T */ diff --git a/floatmagic.h b/floatmagic.h new file mode 100644 index 0000000..c6aabd9 --- /dev/null +++ b/floatmagic.h @@ -0,0 +1,54 @@ +/* + * floatmagic.h -- Definitions of isnan and isinf for gawk. + */ + +/* + * Copyright (C) 2009 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* + * NOTE: MUST be included before this file. Also . + * + * These definitions are taken from the Autoconf 2.63 manual. Not pretty. + */ + +#ifndef HAVE_ISNAN +#ifndef isnan +# define isnan(x) \ + (sizeof (x) == sizeof (long double) ? isnan_ld (x) \ + : sizeof (x) == sizeof (double) ? isnan_d (x) \ + : isnan_f (x)) +static inline int isnan_f (float x) { return x != x; } +static inline int isnan_d (double x) { return x != x; } +static inline int isnan_ld (long double x) { return x != x; } +#endif +#endif + +#ifndef HAVE_ISINF +#ifndef isinf +# define isinf(x) \ + (sizeof (x) == sizeof (long double) ? isinf_ld (x) \ + : sizeof (x) == sizeof (double) ? isinf_d (x) \ + : isinf_f (x)) +static inline int isinf_f (float x) { return isnan (x - x); } +static inline int isinf_d (double x) { return isnan (x - x); } +static inline int isinf_ld (long double x) { return isnan (x - x); } +#endif +#endif diff --git a/gawkmisc.c b/gawkmisc.c new file mode 100644 index 0000000..a729d88 --- /dev/null +++ b/gawkmisc.c @@ -0,0 +1,57 @@ +/* + * gawkmisc.c --- miscellanious gawk routines that are OS specific. + */ + +/* + * Copyright (C) 1986, 1988, 1989, 1991-2004, 2010, 2011 + * the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "awk.h" + +#if defined(HAVE_FCNTL_H) +#include +#endif + +/* some old compilers don't grok #elif. sigh */ + +#if defined(__EMX__) || defined(__DJGPP__) || defined(__MINGW32__) +#include "pc/gawkmisc.pc" +#else /* not __DJGPP__, not __MINGW32__ */ +#if defined(VMS) +#include "vms/gawkmisc.vms" +#else /* not VMS */ +#include "posix/gawkmisc.c" +#endif /* not VMS */ +#endif /* not __DJGPP__, not __MINGW32__ */ + +/* xmalloc --- provide this so that other GNU library routines work */ + +typedef void *pointer; + +extern pointer xmalloc(size_t bytes); /* get rid of gcc warning */ + +pointer +xmalloc(size_t bytes) +{ + pointer p; + emalloc(p, pointer, bytes, "xmalloc"); + return p; +} diff --git a/getopt.c b/getopt.c new file mode 100644 index 0000000..58df01a --- /dev/null +++ b/getopt.c @@ -0,0 +1,1293 @@ +/* Getopt for GNU. + NOTE: getopt is part of the C library, so if you don't know what + "Keep this file name-space clean" means, talk to drepper@gnu.org + before changing it! + Copyright (C) 1987-1996,1998-2004,2008,2009,2010,2011 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* This tells Alpha OSF/1 not to define a getopt prototype in . + Ditto for AIX 3.2 and . */ +#ifndef _NO_PROTO +# define _NO_PROTO +#endif + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#define GETOPT_INTERFACE_VERSION 2 +#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 +# include +# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +# define ELIDE_CODE +# endif +#endif + +/* !@#$%^&*() !!!!!!!! */ +#ifdef GAWK +#undef ELIDE_CODE +#endif + +#ifndef ELIDE_CODE + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#if defined (__GNU_LIBRARY__) || defined (__CYGWIN__) || defined(DJGPP) +/* Don't include stdlib.h for + * non-GNU C libraries + * non-Cygwin + * non-DJGPP + * because some of them contain conflicting prototypes for getopt. */ +# include +# include +#endif /* GNU C library. */ + +#include + +#ifdef VMS +# include +#endif + +#ifdef _LIBC +# include +#else +# include "gettext.h" +# define _(msgid) gettext (msgid) +#endif + +#if defined _LIBC +# include +#endif + +#ifndef attribute_hidden +# define attribute_hidden +#endif + +/* This version of `getopt' appears to the caller like standard Unix `getopt' + but it behaves differently for the user, since it allows the user + to intersperse the options with the other arguments. + + As `getopt' works, it permutes the elements of ARGV so that, + when it is done, all the options precede everything else. Thus + all application programs are extended to handle flexible argument order. + + Setting the environment variable POSIXLY_CORRECT disables permutation. + Then the behavior is completely standard. + + GNU application programs can use a third alternative mode in which + they can distinguish the relative order of options and other arguments. */ + +#include "getopt.h" +#include "getopt_int.h" + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +/* 1003.2 says this must be 1 before any call. */ +int optind = 1; + +/* Callers store zero here to inhibit the error message + for unrecognized options. */ + +int opterr = 1; + +/* Set to an option character which was unrecognized. + This must be initialized on some systems to avoid linking in the + system's own getopt implementation. */ + +int optopt = '?'; + +/* Keep a global copy of all internal members of getopt_data. */ + +static struct _getopt_data getopt_data; + + +#ifndef __GNU_LIBRARY__ + +/* Avoid depending on library functions or files + whose names are inconsistent. */ + +#ifndef getenv +extern char *getenv (); +#endif + +#endif /* not __GNU_LIBRARY__ */ + +#ifdef _LIBC +/* Stored original parameters. + XXX This is no good solution. We should rather copy the args so + that we can compare them later. But we must not use malloc(3). */ +extern int __libc_argc; +extern char **__libc_argv; + +/* Bash 2.0 gives us an environment variable containing flags + indicating ARGV elements that should not be considered arguments. */ + +# ifdef USE_NONOPTION_FLAGS +/* Defined in getopt_init.c */ +extern char *__getopt_nonoption_flags; +# endif + +# ifdef USE_NONOPTION_FLAGS +# define SWAP_FLAGS(ch1, ch2) \ + if (d->__nonoption_flags_len > 0) \ + { \ + char __tmp = __getopt_nonoption_flags[ch1]; \ + __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ + __getopt_nonoption_flags[ch2] = __tmp; \ + } +# else +# define SWAP_FLAGS(ch1, ch2) +# endif +#else /* !_LIBC */ +# define SWAP_FLAGS(ch1, ch2) +#endif /* _LIBC */ + +/* Exchange two adjacent subsequences of ARGV. + One subsequence is elements [first_nonopt,last_nonopt) + which contains all the non-options that have been skipped so far. + The other is elements [last_nonopt,optind), which contains all + the options processed since those non-options were skipped. + + `first_nonopt' and `last_nonopt' are relocated so that they describe + the new indices of the non-options in ARGV after they are moved. */ + +static void +exchange (char **argv, struct _getopt_data *d) +{ + int bottom = d->__first_nonopt; + int middle = d->__last_nonopt; + int top = d->optind; + char *tem; + + /* Exchange the shorter segment with the far end of the longer segment. + That puts the shorter segment into the right place. + It leaves the longer segment in the right place overall, + but it consists of two parts that need to be swapped next. */ + +#if defined _LIBC && defined USE_NONOPTION_FLAGS + /* First make sure the handling of the `__getopt_nonoption_flags' + string can work normally. Our top argument must be in the range + of the string. */ + if (d->__nonoption_flags_len > 0 && top >= d->__nonoption_flags_max_len) + { + /* We must extend the array. The user plays games with us and + presents new arguments. */ + char *new_str = malloc (top + 1); + if (new_str == NULL) + d->__nonoption_flags_len = d->__nonoption_flags_max_len = 0; + else + { + memset (__mempcpy (new_str, __getopt_nonoption_flags, + d->__nonoption_flags_max_len), + '\0', top + 1 - d->__nonoption_flags_max_len); + d->__nonoption_flags_max_len = top + 1; + __getopt_nonoption_flags = new_str; + } + } +#endif + + while (top > middle && middle > bottom) + { + if (top - middle > middle - bottom) + { + /* Bottom segment is the short one. */ + int len = middle - bottom; + register int i; + + /* Swap it with the top part of the top segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); + } + /* Exclude the moved bottom segment from further swapping. */ + top -= len; + } + else + { + /* Top segment is the short one. */ + int len = top - middle; + register int i; + + /* Swap it with the bottom part of the bottom segment. */ + for (i = 0; i < len; i++) + { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + SWAP_FLAGS (bottom + i, middle + i); + } + /* Exclude the moved top segment from further swapping. */ + bottom += len; + } + } + + /* Update records for the slots the non-options now occupy. */ + + d->__first_nonopt += (d->optind - d->__last_nonopt); + d->__last_nonopt = d->optind; +} + +/* Initialize the internal data when the first call is made. */ + +static const char * +_getopt_initialize (int argc, char *const *argv, const char *optstring, + struct _getopt_data *d, int posixly_correct) +{ + /* Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ + + d->__first_nonopt = d->__last_nonopt = d->optind; + + d->__nextchar = NULL; + + d->__posixly_correct = posixly_correct | !!getenv ("POSIXLY_CORRECT"); + + /* Determine how to handle the ordering of options and nonoptions. */ + + if (optstring[0] == '-') + { + d->__ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + d->__ordering = REQUIRE_ORDER; + ++optstring; + } + else if (d->__posixly_correct) + d->__ordering = REQUIRE_ORDER; + else + d->__ordering = PERMUTE; + +#if defined _LIBC && defined USE_NONOPTION_FLAGS + if (!d->__posixly_correct + && argc == __libc_argc && argv == __libc_argv) + { + if (d->__nonoption_flags_max_len == 0) + { + if (__getopt_nonoption_flags == NULL + || __getopt_nonoption_flags[0] == '\0') + d->__nonoption_flags_max_len = -1; + else + { + const char *orig_str = __getopt_nonoption_flags; + int len = d->__nonoption_flags_max_len = strlen (orig_str); + if (d->__nonoption_flags_max_len < argc) + d->__nonoption_flags_max_len = argc; + __getopt_nonoption_flags = + (char *) malloc (d->__nonoption_flags_max_len); + if (__getopt_nonoption_flags == NULL) + d->__nonoption_flags_max_len = -1; + else + memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), + '\0', d->__nonoption_flags_max_len - len); + } + } + d->__nonoption_flags_len = d->__nonoption_flags_max_len; + } + else + d->__nonoption_flags_len = 0; +#endif + + return optstring; +} + +/* Scan elements of ARGV (whose length is ARGC) for option characters + given in OPTSTRING. + + If an element of ARGV starts with '-', and is not exactly "-" or "--", + then it is an option element. The characters of this element + (aside from the initial '-') are option characters. If `getopt' + is called repeatedly, it returns successively each of the option characters + from each of the option elements. + + If `getopt' finds another option character, it returns that character, + updating `optind' and `nextchar' so that the next call to `getopt' can + resume the scan with the following option character or ARGV-element. + + If there are no more option characters, `getopt' returns -1. + Then `optind' is the index in ARGV of the first ARGV-element + that is not an option. (The ARGV-elements have been permuted + so that those that are not options now come last.) + + OPTSTRING is a string containing the legitimate option characters. + If an option character is seen that is not listed in OPTSTRING, + return '?' after printing an error message. If you set `opterr' to + zero, the error message is suppressed but we still return '?'. + + If a char in OPTSTRING is followed by a colon, that means it wants an arg, + so the following text in the same ARGV-element, or the text of the following + ARGV-element, is returned in `optarg'. Two colons mean an option that + wants an optional arg; if there is text in the current ARGV-element, + it is returned in `optarg', otherwise `optarg' is set to zero. + + If OPTSTRING starts with `-' or `+', it requests different methods of + handling the non-option ARGV-elements. + See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. + + Long-named options begin with `--' instead of `-'. + Their names may be abbreviated as long as the abbreviation is unique + or is an exact match for some defined option. If they have an + argument, it follows the option name in the same ARGV-element, separated + from the option name by a `=', or else the in next ARGV-element. + When `getopt' finds a long-named option, it returns 0 if that option's + `flag' field is nonzero, the value of the option's `val' field + if the `flag' field is zero. + + The elements of ARGV aren't really const, because we permute them. + But we pretend they're const in the prototype to be compatible + with other systems. + + LONGOPTS is a vector of `struct option' terminated by an + element containing a name which is zero. + + LONGIND returns the index in LONGOPT of the long-named option found. + It is only valid when a long-named option has been found by the most + recent call. + + If LONG_ONLY is nonzero, '-' as well as '--' can introduce + long-named options. */ + +int +_getopt_internal_r (int argc, char *const *argv, const char *optstring, + const struct option *longopts, int *longind, + int long_only, struct _getopt_data *d, int posixly_correct) +{ + int print_errors = d->opterr; + + if (argc < 1) + return -1; + + d->optarg = NULL; + + if (d->optind == 0 || !d->__initialized) + { + if (d->optind == 0) + d->optind = 1; /* Don't scan ARGV[0], the program name. */ + optstring = _getopt_initialize (argc, argv, optstring, d, + posixly_correct); + d->__initialized = 1; + } + else if (optstring[0] == '-' || optstring[0] == '+') + optstring++; + if (optstring[0] == ':') + print_errors = 0; + + /* Test whether ARGV[optind] points to a non-option argument. + Either it does not have option syntax, or there is an environment flag + from the shell indicating it is not an option. The later information + is only used when the used in the GNU libc. */ +#if defined _LIBC && defined USE_NONOPTION_FLAGS +# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0' \ + || (d->optind < d->__nonoption_flags_len \ + && __getopt_nonoption_flags[d->optind] == '1')) +#else +# define NONOPTION_P (argv[d->optind][0] != '-' || argv[d->optind][1] == '\0') +#endif + + if (d->__nextchar == NULL || *d->__nextchar == '\0') + { + /* Advance to the next ARGV-element. */ + + /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been + moved back by the user (who may also have changed the arguments). */ + if (d->__last_nonopt > d->optind) + d->__last_nonopt = d->optind; + if (d->__first_nonopt > d->optind) + d->__first_nonopt = d->optind; + + if (d->__ordering == PERMUTE) + { + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ + + if (d->__first_nonopt != d->__last_nonopt + && d->__last_nonopt != d->optind) + exchange ((char **) argv, d); + else if (d->__last_nonopt != d->optind) + d->__first_nonopt = d->optind; + + /* Skip any additional non-options + and extend the range of non-options previously skipped. */ + + while (d->optind < argc && NONOPTION_P) + d->optind++; + d->__last_nonopt = d->optind; + } + + /* The special ARGV-element `--' means premature end of options. + Skip it like a null option, + then exchange with previous non-options as if it were an option, + then skip everything else like a non-option. */ + + if (d->optind != argc && !strcmp (argv[d->optind], "--")) + { + d->optind++; + + if (d->__first_nonopt != d->__last_nonopt + && d->__last_nonopt != d->optind) + exchange ((char **) argv, d); + else if (d->__first_nonopt == d->__last_nonopt) + d->__first_nonopt = d->optind; + d->__last_nonopt = argc; + + d->optind = argc; + } + + /* If we have done all the ARGV-elements, stop the scan + and back over any non-options that we skipped and permuted. */ + + if (d->optind == argc) + { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (d->__first_nonopt != d->__last_nonopt) + d->optind = d->__first_nonopt; + return -1; + } + + /* If we have come to a non-option and did not permute it, + either stop the scan or describe it to the caller and pass it by. */ + + if (NONOPTION_P) + { + if (d->__ordering == REQUIRE_ORDER) + return -1; + d->optarg = argv[d->optind++]; + return 1; + } + + /* We have found another option-ARGV-element. + Skip the initial punctuation. */ + + d->__nextchar = (argv[d->optind] + 1 + + (longopts != NULL && argv[d->optind][1] == '-')); + } + + /* Decode the current option-ARGV-element. */ + + /* Check whether the ARGV-element is a long option. + + If long_only and the ARGV-element has the form "-f", where f is + a valid short option, don't consider it an abbreviated form of + a long option that starts with f. Otherwise there would be no + way to give the -f short option. + + On the other hand, if there's a long option "fubar" and + the ARGV-element is "-fu", do consider that an abbreviation of + the long option, just like "--fu", and not "-f" with arg "u". + + This distinction seems to be the most useful approach. */ + + if (longopts != NULL + && (argv[d->optind][1] == '-' + || (long_only && (argv[d->optind][2] + || !strchr (optstring, argv[d->optind][1]))))) + { + char *nameend; + unsigned int namelen; + const struct option *p; + const struct option *pfound = NULL; + struct option_list + { + const struct option *p; + struct option_list *next; + int needs_free; + } *ambig_list = NULL; + int exact = 0; + int indfound = -1; + int option_index; + + for (nameend = d->__nextchar; *nameend && *nameend != '='; nameend++) + /* Do nothing. */ ; + namelen = nameend - d->__nextchar; + + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, d->__nextchar, namelen)) + { + if (namelen == (unsigned int) strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else if (long_only + || pfound->has_arg != p->has_arg + || pfound->flag != p->flag + || pfound->val != p->val) + { + /* Second or later nonexact match found. */ + struct option_list *newp = malloc (sizeof (*newp)); + newp->p = p; + newp->needs_free = 1; + newp->next = ambig_list; + ambig_list = newp; + } + } + + if (ambig_list != NULL && !exact) + { + if (print_errors) + { + struct option_list first; + first.p = pfound; + first.next = ambig_list; + first.needs_free = 0; + ambig_list = &first; + +#if defined _LIBC + char *buf = NULL; + size_t buflen = 0; + + FILE *fp = open_memstream (&buf, &buflen); + if (fp != NULL) + { + fprintf (fp, + _("%s: option '%s' is ambiguous; possibilities:"), + argv[0], argv[d->optind]); + + do + { + fprintf (fp, " '--%s'", ambig_list->p->name); + ambig_list = ambig_list->next; + } + while (ambig_list != NULL); + + fputc_unlocked ('\n', fp); + + if (__builtin_expect (fclose (fp) != EOF, 1)) + { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + + __fxprintf (NULL, "%s", buf); + + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + + free (buf); + } + } +#else + fprintf (stderr, + _("%s: option '%s' is ambiguous; possibilities:"), + argv[0], argv[d->optind]); + do + { + struct option_list *tmp_next; + + fprintf (stderr, " '--%s'", ambig_list->p->name); + tmp_next = ambig_list->next; + if (ambig_list->needs_free) + free(ambig_list); + ambig_list = tmp_next; + } + while (ambig_list != NULL); + + fputc ('\n', stderr); +#endif + } + d->__nextchar += strlen (d->__nextchar); + d->optind++; + d->optopt = 0; + return '?'; + } + + if (pfound != NULL) + { + option_index = indfound; + d->optind++; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + d->optarg = nameend + 1; + else + { + if (print_errors) + { +#if defined _LIBC + char *buf; + int n; +#endif + + if (argv[d->optind - 1][1] == '-') + { + /* --option */ +#if defined _LIBC + n = __asprintf (&buf, _("\ +%s: option '--%s' doesn't allow an argument\n"), + argv[0], pfound->name); +#else + fprintf (stderr, _("\ +%s: option '--%s' doesn't allow an argument\n"), + argv[0], pfound->name); +#endif + } + else + { + /* +option or -option */ +#if defined _LIBC + n = __asprintf (&buf, _("\ +%s: option '%c%s' doesn't allow an argument\n"), + argv[0], argv[d->optind - 1][0], + pfound->name); +#else + fprintf (stderr, _("\ +%s: option '%c%s' doesn't allow an argument\n"), + argv[0], argv[d->optind - 1][0], + pfound->name); +#endif + } + +#if defined _LIBC + if (n >= 0) + { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 + |= _IO_FLAGS2_NOTCANCEL; + + __fxprintf (NULL, "%s", buf); + + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + + free (buf); + } +#endif + } + + d->__nextchar += strlen (d->__nextchar); + + d->optopt = pfound->val; + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (d->optind < argc) + d->optarg = argv[d->optind++]; + else + { + if (print_errors) + { +#if defined _LIBC + char *buf; + + if (__asprintf (&buf, _("\ +%s: option '--%s' requires an argument\n"), + argv[0], pfound->name) >= 0) + { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 + |= _IO_FLAGS2_NOTCANCEL; + + __fxprintf (NULL, "%s", buf); + + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + + free (buf); + } +#else + fprintf (stderr, + _("%s: option '--%s' requires an argument\n"), + argv[0], pfound->name); +#endif + } + d->__nextchar += strlen (d->__nextchar); + d->optopt = pfound->val; + return optstring[0] == ':' ? ':' : '?'; + } + } + d->__nextchar += strlen (d->__nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + + /* Can't find it as a long option. If this is not getopt_long_only, + or the option starts with '--' or is not a valid short + option, then it's an error. + Otherwise interpret it as a short option. */ + if (!long_only || argv[d->optind][1] == '-' + || strchr (optstring, *d->__nextchar) == NULL) + { + if (print_errors) + { +#if defined _LIBC + char *buf; + int n; +#endif + + if (argv[d->optind][1] == '-') + { + /* --option */ +#if defined _LIBC + n = __asprintf (&buf, _("%s: unrecognized option '--%s'\n"), + argv[0], d->__nextchar); +#else + fprintf (stderr, _("%s: unrecognized option '--%s'\n"), + argv[0], d->__nextchar); +#endif + } + else + { + /* +option or -option */ +#if defined _LIBC + n = __asprintf (&buf, _("%s: unrecognized option '%c%s'\n"), + argv[0], argv[d->optind][0], d->__nextchar); +#else + fprintf (stderr, _("%s: unrecognized option '%c%s'\n"), + argv[0], argv[d->optind][0], d->__nextchar); +#endif + } + +#if defined _LIBC + if (n >= 0) + { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + + __fxprintf (NULL, "%s", buf); + + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + + free (buf); + } +#endif + } + d->__nextchar = (char *) ""; + d->optind++; + d->optopt = 0; + return '?'; + } + } + + /* Look at and handle the next short option-character. */ + + { + char c = *d->__nextchar++; + char *temp = strchr (optstring, c); + + /* Increment `optind' when we start to process its last character. */ + if (*d->__nextchar == '\0') + ++d->optind; + + if (temp == NULL || c == ':' || c == ';') + { + if (print_errors) + { +#if defined _LIBC + char *buf; + int n; +#endif + +#if defined _LIBC + n = __asprintf (&buf, _("%s: invalid option -- '%c'\n"), + argv[0], c); +#else + fprintf (stderr, _("%s: invalid option -- '%c'\n"), argv[0], c); +#endif + +#if defined _LIBC + if (n >= 0) + { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + + __fxprintf (NULL, "%s", buf); + + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + + free (buf); + } +#endif + } + d->optopt = c; + return '?'; + } + /* Convenience. Treat POSIX -W foo same as long option --foo */ + if (temp[0] == 'W' && temp[1] == ';') + { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = 0; + int option_index; + + if (longopts == NULL) + goto no_longs; + + /* This is an option that requires an argument. */ + if (*d->__nextchar != '\0') + { + d->optarg = d->__nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + d->optind++; + } + else if (d->optind == argc) + { + if (print_errors) + { +#if defined _LIBC + char *buf; + + if (__asprintf (&buf, + _("%s: option requires an argument -- '%c'\n"), + argv[0], c) >= 0) + { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + + __fxprintf (NULL, "%s", buf); + + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + + free (buf); + } +#else + fprintf (stderr, + _("%s: option requires an argument -- '%c'\n"), + argv[0], c); +#endif + } + d->optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + return c; + } + else + /* We already incremented `d->optind' once; + increment it again when taking next ARGV-elt as argument. */ + d->optarg = argv[d->optind++]; + + /* optarg is now the argument, see if it's in the + table of longopts. */ + + for (d->__nextchar = nameend = d->optarg; *nameend && *nameend != '='; + nameend++) + /* Do nothing. */ ; + + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp (p->name, d->__nextchar, nameend - d->__nextchar)) + { + if ((unsigned int) (nameend - d->__nextchar) == strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else if (long_only + || pfound->has_arg != p->has_arg + || pfound->flag != p->flag + || pfound->val != p->val) + /* Second or later nonexact match found. */ + ambig = 1; + } + if (ambig && !exact) + { + if (print_errors) + { +#if defined _LIBC + char *buf; + + if (__asprintf (&buf, _("%s: option '-W %s' is ambiguous\n"), + argv[0], d->optarg) >= 0) + { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + + __fxprintf (NULL, "%s", buf); + + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + + free (buf); + } +#else + fprintf (stderr, _("%s: option '-W %s' is ambiguous\n"), + argv[0], d->optarg); +#endif + } + d->__nextchar += strlen (d->__nextchar); + d->optind++; + return '?'; + } + if (pfound != NULL) + { + option_index = indfound; + if (*nameend) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + d->optarg = nameend + 1; + else + { + if (print_errors) + { +#if defined _LIBC + char *buf; + + if (__asprintf (&buf, _("\ +%s: option '-W %s' doesn't allow an argument\n"), + argv[0], pfound->name) >= 0) + { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 + |= _IO_FLAGS2_NOTCANCEL; + + __fxprintf (NULL, "%s", buf); + + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + + free (buf); + } +#else + fprintf (stderr, _("\ +%s: option '-W %s' doesn't allow an argument\n"), + argv[0], pfound->name); +#endif + } + + d->__nextchar += strlen (d->__nextchar); + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (d->optind < argc) + d->optarg = argv[d->optind++]; + else + { + if (print_errors) + { +#if defined _LIBC + char *buf; + + if (__asprintf (&buf, _("\ +%s: option '-W %s' requires an argument\n"), + argv[0], pfound->name) >= 0) + { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 + |= _IO_FLAGS2_NOTCANCEL; + + __fxprintf (NULL, "%s", buf); + + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + + free (buf); + } +#else + fprintf (stderr, _("\ +%s: option '-W %s' requires an argument\n"), + argv[0], pfound->name); +#endif + } + d->__nextchar += strlen (d->__nextchar); + return optstring[0] == ':' ? ':' : '?'; + } + } + else + d->optarg = NULL; + d->__nextchar += strlen (d->__nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + + no_longs: + d->__nextchar = NULL; + return 'W'; /* Let the application handle it. */ + } + if (temp[1] == ':') + { + if (temp[2] == ':') + { + /* This is an option that accepts an argument optionally. */ + if (*d->__nextchar != '\0') + { + d->optarg = d->__nextchar; + d->optind++; + } + else + d->optarg = NULL; + d->__nextchar = NULL; + } + else + { + /* This is an option that requires an argument. */ + if (*d->__nextchar != '\0') + { + d->optarg = d->__nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + d->optind++; + } + else if (d->optind == argc) + { + if (print_errors) + { +#if defined _LIBC + char *buf; + + if (__asprintf (&buf, _("\ +%s: option requires an argument -- '%c'\n"), + argv[0], c) >= 0) + { + _IO_flockfile (stderr); + + int old_flags2 = ((_IO_FILE *) stderr)->_flags2; + ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL; + + __fxprintf (NULL, "%s", buf); + + ((_IO_FILE *) stderr)->_flags2 = old_flags2; + _IO_funlockfile (stderr); + + free (buf); + } +#else + fprintf (stderr, + _("%s: option requires an argument -- '%c'\n"), + argv[0], c); +#endif + } + d->optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + d->optarg = argv[d->optind++]; + d->__nextchar = NULL; + } + } + return c; + } +} + +int +_getopt_internal (int argc, char *const *argv, const char *optstring, + const struct option *longopts, int *longind, int long_only, + int posixly_correct) +{ + int result; + + getopt_data.optind = optind; + getopt_data.opterr = opterr; + + result = _getopt_internal_r (argc, argv, optstring, longopts, + longind, long_only, &getopt_data, + posixly_correct); + + optind = getopt_data.optind; + optarg = getopt_data.optarg; + optopt = getopt_data.optopt; + + return result; +} + +int +getopt (int argc, char *const *argv, const char *optstring) +{ + return _getopt_internal (argc, argv, optstring, + (const struct option *) 0, + (int *) 0, + 0, 0); +} + +#ifdef _LIBC +int +__posix_getopt (int argc, char *const *argv, const char *optstring) +{ + return _getopt_internal (argc, argv, optstring, + (const struct option *) 0, + (int *) 0, + 0, 1); +} +#endif + +#endif /* Not ELIDE_CODE. */ + +#ifdef TEST + +/* Compile with -DTEST to make an executable for use in testing + the above definition of `getopt'. */ + +int +main (int argc, char **argv) +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + + c = getopt (argc, argv, "abc:d:0123456789"); + if (c == -1) + break; + + switch (c) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value '%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/getopt.h b/getopt.h new file mode 100644 index 0000000..82d0ab9 --- /dev/null +++ b/getopt.h @@ -0,0 +1,192 @@ +/* Declarations for getopt. + Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2009,2010 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _GETOPT_H + +#ifndef __need_getopt +# define _GETOPT_H 1 +#endif + +/* If __GNU_LIBRARY__ is not already defined, either we are being used + standalone, or this is the first header included in the source file. + If we are being used with glibc, we need to include , but + that does not exist if we are standalone. So: if __GNU_LIBRARY__ is + not defined, include , which will pull in for us + if it's from glibc. (Why ctype.h? It's guaranteed to exist and it + doesn't flood the namespace with stuff the way some other headers do.) */ +#if !defined __GNU_LIBRARY__ +# include +#endif + +#ifndef __THROW +# ifndef __GNUC_PREREQ +# define __GNUC_PREREQ(maj, min) (0) +# endif +# if defined __cplusplus && __GNUC_PREREQ (2,8) +# define __THROW throw () +# else +# define __THROW +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Set to an option character which was unrecognized. */ + +extern int optopt; + +#ifndef __need_getopt +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of `struct option' terminated by an element containing a name which is + zero. + + The field `has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. + + If the field `flag' is not NULL, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `getopt' + returns the contents of the `val' field. */ + +struct option +{ + const char *name; + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; + +/* Names for the values of the `has_arg' field of `struct option'. */ + +# define no_argument 0 +# define required_argument 1 +# define optional_argument 2 +#endif /* need getopt */ + + +/* Get definitions and prototypes for functions to process the + arguments in ARGV (ARGC of them, minus the program name) for + options given in OPTS. + + Return the option character from OPTS just read. Return -1 when + there are no more options. For unrecognized options, or options + missing arguments, `optopt' is set to the option letter, and '?' is + returned. + + The OPTS string is a list of characters which are recognized option + letters, optionally followed by colons, specifying that that letter + takes an argument, to be placed in `optarg'. + + If a letter in OPTS is followed by two colons, its argument is + optional. This behavior is specific to the GNU `getopt'. + + The argument `--' causes premature termination of argument + scanning, explicitly telling `getopt' that there are no more + options. + + If OPTS begins with `--', then non-option arguments are treated as + arguments to the option '\0'. This behavior is specific to the GNU + `getopt'. */ + +#ifdef __GNU_LIBRARY__ +/* Many other libraries have conflicting prototypes for getopt, with + differences in the consts, in stdlib.h. To avoid compilation + errors, only prototype getopt for the GNU C library. */ +extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) + __THROW; + +# if defined __need_getopt && defined __USE_POSIX2 \ + && !defined __USE_POSIX_IMPLICITLY && !defined __USE_GNU +/* The GNU getopt has more functionality than the standard version. The + additional functionality can be disable at runtime. This redirection + helps to also do this at runtime. */ +# ifdef __REDIRECT + extern int __REDIRECT_NTH (getopt, (int ___argc, char *const *___argv, + const char *__shortopts), + __posix_getopt); +# else +extern int __posix_getopt (int ___argc, char *const *___argv, + const char *__shortopts) __THROW; +# define getopt __posix_getopt +# endif +# endif +#else /* not __GNU_LIBRARY__ */ +extern int getopt (); +#endif /* __GNU_LIBRARY__ */ + +#ifndef __need_getopt +extern int getopt_long (int ___argc, char *const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind) + __THROW; +extern int getopt_long_only (int ___argc, char *const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind) + __THROW; + +#endif + +#ifdef __cplusplus +} +#endif + +/* Make sure we later can get all the definitions and declarations. */ +#undef __need_getopt + +#endif /* getopt.h */ diff --git a/getopt1.c b/getopt1.c new file mode 100644 index 0000000..03fba35 --- /dev/null +++ b/getopt1.c @@ -0,0 +1,195 @@ +/* getopt_long and getopt_long_only entry points for GNU getopt. + Copyright (C) 1987-1994,1996-1998,2004,2009 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef _LIBC +# include +#else +# include "getopt.h" +#endif +#include "getopt_int.h" + +#include + +/* Comment out all this code if we are using the GNU C Library, and are not + actually compiling the library itself. This code is part of the GNU C + Library, but also included in many other GNU distributions. Compiling + and linking in this code is a waste when using the GNU C library + (especially if it is a shared library). Rather than having every GNU + program understand `configure --with-gnu-libc' and omit the object files, + it is simpler to just do this in the source for each such file. */ + +#define GETOPT_INTERFACE_VERSION 2 +#if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 +#include +#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +#define ELIDE_CODE +#endif +#endif + +/* !@#$%^&*() !!!!!!!! */ +#ifdef GAWK +#undef ELIDE_CODE +#endif + +#ifndef ELIDE_CODE + + +/* This needs to come after some library #include + to get __GNU_LIBRARY__ defined. */ +#ifdef __GNU_LIBRARY__ +#include +#endif + +#ifndef NULL +#define NULL 0 +#endif + +int +getopt_long (int argc, char *const *argv, const char *options, + const struct option *long_options, int *opt_index) +{ + return _getopt_internal (argc, argv, options, long_options, opt_index, 0, 0); +} + +int +_getopt_long_r (int argc, char *const *argv, const char *options, + const struct option *long_options, int *opt_index, + struct _getopt_data *d) +{ + return _getopt_internal_r (argc, argv, options, long_options, opt_index, + 0, d, 0); +} + +/* Like getopt_long, but '-' as well as '--' can indicate a long option. + If an option that starts with '-' (not '--') doesn't match a long option, + but does match a short option, it is parsed as a short option + instead. */ + +int +getopt_long_only (int argc, char *const *argv, const char *options, + const struct option *long_options, int *opt_index) +{ + return _getopt_internal (argc, argv, options, long_options, opt_index, 1, 0); +} + +int +_getopt_long_only_r (int argc, char *const *argv, const char *options, + const struct option *long_options, int *opt_index, + struct _getopt_data *d) +{ + return _getopt_internal_r (argc, argv, options, long_options, opt_index, + 1, d, 0); +} + +#endif /* Not ELIDE_CODE. */ + +#ifdef TEST + +#include + +int +main (int argc, char **argv) +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + int option_index = 0; + static struct option long_options[] = + { + {"add", 1, 0, 0}, + {"append", 0, 0, 0}, + {"delete", 1, 0, 0}, + {"verbose", 0, 0, 0}, + {"create", 0, 0, 0}, + {"file", 1, 0, 0}, + {0, 0, 0, 0} + }; + + c = getopt_long (argc, argv, "abc:d:0123456789", + long_options, &option_index); + if (c == -1) + break; + + switch (c) + { + case 0: + printf ("option %s", long_options[option_index].name); + if (optarg) + printf (" with arg %s", optarg); + printf ("\n"); + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case 'd': + printf ("option d with value `%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/getopt_int.h b/getopt_int.h new file mode 100644 index 0000000..b0d7695 --- /dev/null +++ b/getopt_int.h @@ -0,0 +1,130 @@ +/* Internal declarations for getopt. + Copyright (C) 1989-1994,1996-1999,2001,2003,2004,2009 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _GETOPT_INT_H +#define _GETOPT_INT_H 1 + +extern int _getopt_internal (int ___argc, char *const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind, + int __long_only, int posixly_correct); + + +/* Reentrant versions which can handle parsing multiple argument + vectors at the same time. */ + +/* Data type for reentrant functions. */ +struct _getopt_data +{ + /* These have exactly the same meaning as the corresponding global + variables, except that they are used for the reentrant + versions of getopt. */ + int optind; + int opterr; + int optopt; + char *optarg; + + /* Internal members. */ + + /* True if the internal members have been initialized. */ + int __initialized; + + /* The next char to be scanned in the option-element + in which the last option character we returned was found. + This allows us to pick up the scan where we left off. + + If this is zero, or a null string, it means resume the scan + by advancing to the next ARGV-element. */ + char *__nextchar; + + /* Describe how to deal with options that follow non-option ARGV-elements. + + If the caller did not specify anything, + the default is REQUIRE_ORDER if the environment variable + POSIXLY_CORRECT is defined, PERMUTE otherwise. + + REQUIRE_ORDER means don't recognize them as options; + stop option processing when the first non-option is seen. + This is what Unix does. + This mode of operation is selected by either setting the environment + variable POSIXLY_CORRECT, or using `+' as the first character + of the list of option characters. + + PERMUTE is the default. We permute the contents of ARGV as we + scan, so that eventually all the non-options are at the end. + This allows options to be given in any order, even with programs + that were not written to expect this. + + RETURN_IN_ORDER is an option available to programs that were + written to expect options and other ARGV-elements in any order + and that care about the ordering of the two. We describe each + non-option ARGV-element as if it were the argument of an option + with character code 1. Using `-' as the first character of the + list of option characters selects this mode of operation. + + The special argument `--' forces an end of option-scanning regardless + of the value of `ordering'. In the case of RETURN_IN_ORDER, only + `--' can cause `getopt' to return -1 with `optind' != ARGC. */ + + enum + { + REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER + } __ordering; + + /* If the POSIXLY_CORRECT environment variable is set. */ + int __posixly_correct; + + + /* Handle permutation of arguments. */ + + /* Describe the part of ARGV that contains non-options that have + been skipped. `first_nonopt' is the index in ARGV of the first + of them; `last_nonopt' is the index after the last of them. */ + + int __first_nonopt; + int __last_nonopt; + +#if defined _LIBC && defined USE_NONOPTION_FLAGS + int __nonoption_flags_max_len; + int __nonoption_flags_len; +# endif +}; + +/* The initializer is necessary to set OPTIND and OPTERR to their + default values and to clear the initialization flag. */ +#define _GETOPT_DATA_INITIALIZER { 1, 1 } + +extern int _getopt_internal_r (int ___argc, char *const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind, + int __long_only, struct _getopt_data *__data, + int posixly_correct); + +extern int _getopt_long_r (int ___argc, char *const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind, + struct _getopt_data *__data); + +extern int _getopt_long_only_r (int ___argc, char *const *___argv, + const char *__shortopts, + const struct option *__longopts, + int *__longind, + struct _getopt_data *__data); + +#endif /* getopt_int.h */ diff --git a/gettext.h b/gettext.h new file mode 100644 index 0000000..0c1a50e --- /dev/null +++ b/gettext.h @@ -0,0 +1,289 @@ +/* Convenience header for conditional use of GNU . + Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + USA. */ + +#ifndef _LIBGETTEXT_H +#define _LIBGETTEXT_H 1 + +/* NLS can be disabled through the configure --disable-nls option. */ +#if ENABLE_NLS + +/* ADR: Need this so gcc -g without -O works. */ +#ifdef HAVE_LOCALE_H +#include +#endif /* HAVE_LOCALE_H */ + +/* Get declarations of GNU message catalog functions. */ +# include + +/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by + the gettext() and ngettext() macros. This is an alternative to calling + textdomain(), and is useful for libraries. */ +# ifdef DEFAULT_TEXT_DOMAIN +# undef gettext +# define gettext(Msgid) \ + dgettext (DEFAULT_TEXT_DOMAIN, Msgid) +# undef ngettext +# define ngettext(Msgid1, Msgid2, N) \ + dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N) +# endif + +#else + +/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which + chokes if dcgettext is defined as a macro. So include it now, to make + later inclusions of a NOP. We don't include + as well because people using "gettext.h" will not include , + and also including would fail on SunOS 4, whereas + is OK. */ +/* ADR: Include even if not ENABLE_NLS so can pay attention + * to locale number formats, etc. + */ +#if defined(__sun) || defined(HAVE_LOCALE_H) +# include +#endif + +/* Many header files from the libstdc++ coming with g++ 3.3 or newer include + , which chokes if dcgettext is defined as a macro. So include + it now, to make later inclusions of a NOP. */ +#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) +# include +# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H +# include +# endif +#endif + +/* Disabled NLS. + The casts to 'const char *' serve the purpose of producing warnings + for invalid uses of the value returned from these functions. + On pre-ANSI systems without 'const', the config.h file is supposed to + contain "#define const". */ +/* ADR: BOGUS. Remove const. 19 Feb 2002 */ +# undef gettext +# define gettext(Msgid) ((char *) (Msgid)) +# undef dgettext +# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid)) +# undef dcgettext +# define dcgettext(Domainname, Msgid, Category) \ + ((void) (Category), dgettext (Domainname, Msgid)) +# undef ngettext +# define ngettext(Msgid1, Msgid2, N) \ + ((N) == 1 \ + ? ((void) (Msgid2), (const char *) (Msgid1)) \ + : ((void) (Msgid1), (const char *) (Msgid2))) +# undef dngettext +# define dngettext(Domainname, Msgid1, Msgid2, N) \ + ((void) (Domainname), ngettext (Msgid1, Msgid2, N)) +# undef dcngettext +# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ + ((void) (Category), dngettext(Domainname, Msgid1, Msgid2, N)) +# undef textdomain +# define textdomain(Domainname) ((const char *) (Domainname)) +# undef bindtextdomain +# define bindtextdomain(Domainname, Dirname) \ + ((void) (Domainname), (const char *) (Dirname)) +# undef bind_textdomain_codeset +# define bind_textdomain_codeset(Domainname, Codeset) \ + ((void) (Domainname), (const char *) (Codeset)) + +#endif + +/* A pseudo function call that serves as a marker for the automated + extraction of messages, but does not call gettext(). The run-time + translation is done at a different place in the code. + The argument, String, should be a literal string. Concatenated strings + and other string expressions won't work. + The macro's expansion is not parenthesized, so that it is suitable as + initializer for static 'char[]' or 'const char[]' variables. */ +#define gettext_noop(String) String + +/* The separator between msgctxt and msgid in a .mo file. */ +#define GETTEXT_CONTEXT_GLUE "\004" + +/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a + MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be + short and rarely need to change. + The letter 'p' stands for 'particular' or 'special'. */ +#ifdef DEFAULT_TEXT_DOMAIN +# define pgettext(Msgctxt, Msgid) \ + pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) +#else +# define pgettext(Msgctxt, Msgid) \ + pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) +#endif +#define dpgettext(Domainname, Msgctxt, Msgid) \ + pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) +#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \ + pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category) +#ifdef DEFAULT_TEXT_DOMAIN +# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ + npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) +#else +# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ + npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) +#endif +#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ + npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) +#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \ + npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category) + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static const char * +pgettext_aux (const char *domain, + const char *msg_ctxt_id, const char *msgid, + int category) +{ + const char *translation = dcgettext (domain, msg_ctxt_id, category); + if (translation == msg_ctxt_id) + return msgid; + else + return translation; +} + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static const char * +npgettext_aux (const char *domain, + const char *msg_ctxt_id, const char *msgid, + const char *msgid_plural, unsigned long int n, + int category) +{ + const char *translation = + dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); + if (translation == msg_ctxt_id || translation == msgid_plural) + return (n == 1 ? msgid : msgid_plural); + else + return translation; +} + +/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID + can be arbitrary expressions. But for string literals these macros are + less efficient than those above. */ + +#include + +#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \ + (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \ + /* || __STDC_VERSION__ >= 199901L */ ) + +#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS +#include +#endif + +#define pgettext_expr(Msgctxt, Msgid) \ + dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES) +#define dpgettext_expr(Domainname, Msgctxt, Msgid) \ + dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES) + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static const char * +dcpgettext_expr (const char *domain, + const char *msgctxt, const char *msgid, + int category) +{ + size_t msgctxt_len = strlen (msgctxt) + 1; + size_t msgid_len = strlen (msgid) + 1; + const char *translation; +#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + char msg_ctxt_id[msgctxt_len + msgid_len]; +#else + char buf[1024]; + char *msg_ctxt_id = + (msgctxt_len + msgid_len <= sizeof (buf) + ? buf + : (char *) malloc (msgctxt_len + msgid_len)); + if (msg_ctxt_id != NULL) +#endif + { + memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); + msg_ctxt_id[msgctxt_len - 1] = '\004'; + memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); + translation = dcgettext (domain, msg_ctxt_id, category); +#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + if (msg_ctxt_id != buf) + free (msg_ctxt_id); +#endif + if (translation != msg_ctxt_id) + return translation; + } + return msgid; +} + +#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \ + dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) +#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ + dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) + +#ifdef __GNUC__ +__inline +#else +#ifdef __cplusplus +inline +#endif +#endif +static const char * +dcnpgettext_expr (const char *domain, + const char *msgctxt, const char *msgid, + const char *msgid_plural, unsigned long int n, + int category) +{ + size_t msgctxt_len = strlen (msgctxt) + 1; + size_t msgid_len = strlen (msgid) + 1; + const char *translation; +#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + char msg_ctxt_id[msgctxt_len + msgid_len]; +#else + char buf[1024]; + char *msg_ctxt_id = + (msgctxt_len + msgid_len <= sizeof (buf) + ? buf + : (char *) malloc (msgctxt_len + msgid_len)); + if (msg_ctxt_id != NULL) +#endif + { + memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); + msg_ctxt_id[msgctxt_len - 1] = '\004'; + memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); + translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); +#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS + if (msg_ctxt_id != buf) + free (msg_ctxt_id); +#endif + if (!(translation == msg_ctxt_id || translation == msgid_plural)) + return translation; + } + return (n == 1 ? msgid : msgid_plural); +} + +#endif /* _LIBGETTEXT_H */ diff --git a/install-sh b/install-sh new file mode 100755 index 0000000..4fbbae7 --- /dev/null +++ b/install-sh @@ -0,0 +1,507 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2006-10-14.15 + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +nl=' +' +IFS=" "" $nl" + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +posix_glob= +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chmodcmd=$chmodprog +chowncmd= +chgrpcmd= +stripcmd= +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src= +dst= +dir_arg= +dstarg= +no_target_directory= + +usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: +-c (ignored) +-d create directories instead of installing files. +-g GROUP $chgrpprog installed files to GROUP. +-m MODE $chmodprog installed files to MODE. +-o USER $chownprog installed files to USER. +-s $stripprog installed files. +-t DIRECTORY install into DIRECTORY. +-T report an error if DSTFILE is a directory. +--help display this help and exit. +--version display version info and exit. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + shift + shift + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -s) stripcmd=$stripprog + shift + continue;; + + -t) dstarg=$2 + shift + shift + continue;; + + -T) no_target_directory=true + shift + continue;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac +done + +if test $# -ne 0 && test -z "$dir_arg$dstarg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dstarg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dstarg" + shift # fnord + fi + shift # arg + dstarg=$arg + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + trap '(exit $?); exit' 1 2 13 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src ;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dstarg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dstarg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst ;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dstarg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix=/ ;; + -*) prefix=./ ;; + *) prefix= ;; + esac + + case $posix_glob in + '') + if (set -f) 2>/dev/null; then + posix_glob=true + else + posix_glob=false + fi ;; + esac + + oIFS=$IFS + IFS=/ + $posix_glob && set -f + set fnord $dstdir + shift + $posix_glob && set +f + IFS=$oIFS + + prefixes= + + for d + do + test -z "$d" && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # Now rename the file to the real destination. + { $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null \ + || { + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + if test -f "$dst"; then + $doit $rmcmd -f "$dst" 2>/dev/null \ + || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null \ + && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }; }\ + || { + echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + else + : + fi + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + } || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/io.c b/io.c new file mode 100644 index 0000000..c57aef2 --- /dev/null +++ b/io.c @@ -0,0 +1,3237 @@ +/* + * io.c --- routines for dealing with input and output and records + */ + +/* + * Copyright (C) 1986, 1988, 1989, 1991-2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* For OSF/1 to get struct sockaddr_storage */ +#if defined(__osf__) && !defined(_OSF_SOURCE) +#define _OSF_SOURCE +#endif + +#include "awk.h" + +#ifdef HAVE_SYS_PARAM_H +#undef RE_DUP_MAX /* avoid spurious conflict w/regex.h */ +#include +#endif /* HAVE_SYS_PARAM_H */ +#ifdef HAVE_SYS_IOCTL_H +#include +#endif /* HAVE_SYS_IOCTL_H */ + +#ifndef O_ACCMODE +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) +#endif + +#ifdef HAVE_TERMIOS_H +#include +#endif +#ifdef HAVE_STROPTS_H +#include +#endif + +#ifdef HAVE_SOCKETS + +#ifdef HAVE_SYS_SOCKET_H +#include +#else +#include +#endif /* HAVE_SYS_SOCKET_H */ + +#ifdef HAVE_NETINET_IN_H +#include + +#ifdef HAVE_ARPA_INET_H +#include +#endif + +#else /* ! HAVE_NETINET_IN_H */ +#include +#endif /* HAVE_NETINET_IN_H */ + +#ifdef HAVE_NETDB_H +#include +#endif /* HAVE_NETDB_H */ + +#ifndef HAVE_GETADDRINFO +#include "missing_d/getaddrinfo.h" +#endif + +#ifndef AI_ADDRCONFIG /* This is a recent symbol, not everyone has it */ +#define AI_ADDRCONFIG 0 +#endif /* AI_ADDRCONFIG */ + +#ifndef HAVE_SOCKADDR_STORAGE +#define sockaddr_storage sockaddr /* for older systems */ +#endif /* HAVE_SOCKADDR_STORAGE */ + +#endif /* HAVE_SOCKETS */ + +#ifndef AF_UNSPEC +#define AF_UNSPEC 0 +#endif +#ifndef AF_INET +#define AF_INET 2 +#endif +#ifndef AF_INET6 +#define AF_INET6 10 +#endif + +#ifdef HAVE_LIMITS_H +#include +#endif + +#ifdef __EMX__ +#include +#endif + +#ifndef ENFILE +#define ENFILE EMFILE +#endif + +#ifdef HAVE_SOCKETS + +#ifndef SHUT_RD +#define SHUT_RD 0 +#endif + +#ifndef SHUT_WR +#define SHUT_WR 1 +#endif + +#ifndef SHUT_RDWR +#define SHUT_RDWR 2 +#endif + +#endif /* HAVE_SOCKETS */ + +#if defined(GAWK_AIX) +#undef TANDEM /* AIX defines this in one of its header files */ +#endif + +#if defined(__DJGPP__) || defined(__MINGW32__) +#define PIPES_SIMULATED +#endif + +typedef enum { CLOSE_ALL, CLOSE_TO, CLOSE_FROM } two_way_close_type; + +/* Several macros make the code a bit clearer: */ +/* */ +/* */ +/* = */ +#define at_eof(iop) (((iop)->flag & IOP_AT_EOF) != 0) +#define has_no_data(iop) ((iop)->dataend == NULL) +#define no_data_left(iop) ((iop)->off >= (iop)->dataend) +/* The key point to the design is to split out the code that searches through */ +/* a buffer looking for the record and the terminator into separate routines, */ +/* with a higher-level routine doing the reading of data and buffer management. */ +/* This makes the code easier to manage; the buffering code is the same independent */ +/* of how we find a record. Communication is via the return value: */ +/* */ +/* */ +/* = */ +typedef enum recvalues { + REC_OK, /* record and terminator found, recmatch struct filled in */ + NOTERM, /* no terminator found, give me more input data */ + TERMATEND, /* found terminator at end of buffer */ + TERMNEAREND /* found terminator close to end of buffer, for RE might be bigger */ +} RECVALUE; +/* Between calls to a scanning routine, the state is stored in */ +/* an [[enum scanstate]] variable. Not all states apply to all */ +/* variants, but the higher code doesn't really care. */ +/* */ +/* */ +/* = */ +typedef enum scanstate { + NOSTATE, /* scanning not started yet (all) */ + INLEADER, /* skipping leading data (RS = "") */ + INDATA, /* in body of record (all) */ + INTERM /* scanning terminator (RS = "", RS = regexp) */ +} SCANSTATE; +/* When a record is seen ([[REC_OK]] or [[TERMATEND]]), the following */ +/* structure is filled in. */ +/* */ +/* */ +/* = */ +struct recmatch { + char *start; /* record start */ + size_t len; /* length of record */ + char *rt_start; /* start of terminator */ + size_t rt_len; /* length of terminator */ +}; + + +static int iop_close(IOBUF *iop); +struct redirect *redirect(NODE *redir_exp, int redirtype, int *errflg); +static void close_one(void); +static int close_redir(struct redirect *rp, int exitwarn, two_way_close_type how); +#ifndef PIPES_SIMULATED +static int wait_any(int interesting); +#endif +static IOBUF *gawk_popen(const char *cmd, struct redirect *rp); +static IOBUF *iop_alloc(int fd, const char *name, IOBUF *buf, int do_openhooks); +static int gawk_pclose(struct redirect *rp); +static int str2mode(const char *mode); +static int two_way_open(const char *str, struct redirect *rp); +static int pty_vs_pipe(const char *command); +static void find_open_hook(IOBUF *iop); + +static RECVALUE rs1scan(IOBUF *iop, struct recmatch *recm, SCANSTATE *state); +static RECVALUE rsnullscan(IOBUF *iop, struct recmatch *recm, SCANSTATE *state); +static RECVALUE rsrescan(IOBUF *iop, struct recmatch *recm, SCANSTATE *state); + +static RECVALUE (*matchrec)(IOBUF *iop, struct recmatch *recm, SCANSTATE *state) = rs1scan; + +static int get_a_record(char **out, IOBUF *iop, int *errcode); + +static void free_rp(struct redirect *rp); +static int inetfile(const char *str, int *length, int *family); + +#if defined(HAVE_POPEN_H) +#include "popen.h" +#endif + +static struct redirect *red_head = NULL; +static NODE *RS; +static Regexp *RS_re_yes_case; +static Regexp *RS_re_no_case; +static Regexp *RS_regexp; + +int RS_is_null; + +extern int output_is_tty; +extern NODE *ARGC_node; +extern NODE *ARGV_node; +extern NODE *ARGIND_node; +extern NODE *ERRNO_node; +extern NODE **fields_arr; + +#if defined(__DJGPP__) || defined(__MINGW32__) || defined(__EMX__) || defined(__CYGWIN__) +/* binmode --- convert BINMODE to string for fopen */ + +static const char * +binmode(const char *mode) +{ + switch (mode[0]) { + case 'r': + if ((BINMODE & 1) != 0) + mode = "rb"; + break; + case 'w': + case 'a': + if ((BINMODE & 2) != 0) + mode = (mode[0] == 'w' ? "wb" : "ab"); + break; + } + return mode; +} +#else +#define binmode(mode) (mode) +#endif + +#ifdef VMS +/* File pointers have an extra level of indirection, and there are cases where + `stdin' can be null. That can crash gawk if fileno() is used as-is. */ +static int vmsrtl_fileno(FILE *); +static int vmsrtl_fileno(fp) FILE *fp; { return fileno(fp); } +#undef fileno +#define fileno(FP) (((FP) && *(FP)) ? vmsrtl_fileno(FP) : -1) +#endif /* VMS */ + +void +after_beginfile(IOBUF **curfile) +{ + IOBUF *iop; + + iop = *curfile; + assert(iop != NULL); + + if (iop->fd == INVALID_HANDLE) { + const char *fname; + int errcode; + + fname = iop->name; + errcode = iop->errcode; + iop->errcode = 0; + errno = 0; + update_ERRNO(); + iop_close(iop); + *curfile = NULL; + if (errcode == EISDIR && ! do_traditional) { + warning(_("command line argument `%s' is a directory: skipped"), fname); + return; /* read next file */ + } + fatal(_("cannot open file `%s' for reading (%s)"), + fname, strerror(errcode)); + } + + /* + * Open hooks could have been changed by BEGINFILE, + * so delay check until now. + */ + + find_open_hook(iop); +} + +/* nextfile --- move to the next input data file */ + +int +nextfile(IOBUF **curfile, int skipping) +{ + static long i = 1; + static int files = FALSE; + NODE *arg, *tmp; + static IOBUF mybuf; + const char *fname; + int fd = INVALID_HANDLE; + int errcode; + IOBUF *iop = *curfile; + + if (skipping) { /* for 'nextfile' call */ + errcode = 0; + if (iop != NULL) { + errcode = iop->errcode; + (void) iop_close(iop); + } + *curfile = NULL; + return (errcode == 0); + } + + if (iop != NULL) { + if (at_eof(iop)) { + assert(iop->fd != INVALID_HANDLE); + (void) iop_close(iop); + *curfile = NULL; + return 1; /* run endfile block */ + } else + return 0; + } + + for (; i < (long) (ARGC_node->lnode->numbr); i++) { + tmp = make_number((AWKNUM) i); + (void) force_string(tmp); + arg = in_array(ARGV_node, tmp); + unref(tmp); + if (arg == NULL || arg->stlen == 0) + continue; + arg = force_string(arg); + arg->stptr[arg->stlen] = '\0'; + if (! do_traditional) { + unref(ARGIND_node->var_value); + ARGIND_node->var_value = make_number((AWKNUM) i); + } + + if (! arg_assign(arg->stptr, FALSE)) { + files = TRUE; + fname = arg->stptr; + errno = 0; + fd = devopen(fname, binmode("r")); + errcode = errno; + if (! do_traditional) + update_ERRNO(); + + /* This is a kludge. */ + unref(FILENAME_node->var_value); + FILENAME_node->var_value = dupnode(arg); + FNR = 0; + iop = *curfile = iop_alloc(fd, fname, &mybuf, FALSE); + if (fd == INVALID_HANDLE) + iop->errcode = errcode; + else + iop->errcode = 0; + iop->flag |= IOP_NOFREE_OBJ; + return ++i; /* run beginfile block */ + } + } + + if (files == FALSE) { + files = TRUE; + /* no args. -- use stdin */ + /* FNR is init'ed to 0 */ + errno = 0; + if (! do_traditional) + update_ERRNO(); + unref(FILENAME_node->var_value); + FILENAME_node->var_value = make_string("-", 1); + FILENAME_node->var_value->flags |= MAYBE_NUM; /* be pedantic */ + fname = "-"; + iop = *curfile = iop_alloc(fileno(stdin), fname, &mybuf, FALSE); + iop->flag |= IOP_NOFREE_OBJ; + if (iop->fd == INVALID_HANDLE) { + errcode = errno; + errno = 0; + update_ERRNO(); + (void) iop_close(iop); + *curfile = NULL; + fatal(_("cannot open file `%s' for reading (%s)"), + fname, strerror(errcode)); + } + return ++i; /* run beginfile block */ + } + + return -1; /* end of input, run end block or Op_atexit */ +} + +/* set_FNR --- update internal FNR from awk variable */ + +void +set_FNR() +{ + FNR = (long) FNR_node->var_value->numbr; +} + +/* set_NR --- update internal NR from awk variable */ + +void +set_NR() +{ + NR = (long) NR_node->var_value->numbr; +} + +/* inrec --- This reads in a record from the input file */ + +int +inrec(IOBUF *iop, int *errcode) +{ + char *begin; + int cnt; + int retval = 0; + + if (at_eof(iop) && no_data_left(iop)) + cnt = EOF; + else if ((iop->flag & IOP_CLOSED) != 0) + cnt = EOF; + else + cnt = get_a_record(&begin, iop, errcode); + + if (cnt == EOF) { + retval = 1; + if (*errcode > 0) + update_ERRNO_saved(*errcode); + } else { + NR += 1; + FNR += 1; + set_record(begin, cnt); + } + + return retval; +} + +/* remap_std_file --- reopen a standard descriptor on /dev/null */ + +static int +remap_std_file(int oldfd) +{ + int newfd; + int ret = -1; + + /* + * Give OS-specific routines in gawkmisc.c chance to interpret + * "/dev/null" as appropriate for their platforms. + */ + newfd = os_devopen("/dev/null", O_RDWR); + if (newfd == INVALID_HANDLE) + newfd = open("/dev/null", O_RDWR); + if (newfd >= 0) { + /* dup2() will close oldfd for us first. */ + ret = dup2(newfd, oldfd); + if (ret == 0) + close(newfd); + } else + ret = 0; + + return ret; +} + +/* iop_close --- close an open IOP */ + +static int +iop_close(IOBUF *iop) +{ + int ret; + + if (iop == NULL) + return 0; + if (iop->fd == INVALID_HANDLE) { /* from nextfile(...) above */ + assert(iop->buf == NULL); + assert((iop->flag & IOP_NOFREE_OBJ) != 0); + return 0; + } + + errno = 0; + + iop->flag &= ~IOP_AT_EOF; + iop->flag |= IOP_CLOSED; /* there may be dangling pointers */ + iop->dataend = NULL; + /* + * Closing standard files can cause crufty code elsewhere to lose. + * So we remap the standard file to /dev/null. + * Thanks to Jim Meyering for the suggestion. + */ + if (iop->fd == fileno(stdin) + || iop->fd == fileno(stdout) + || iop->fd == fileno(stderr)) + ret = remap_std_file(iop->fd); + else + ret = close(iop->fd); + + if (iop->close_func != NULL) + (*iop->close_func)(iop); + + if (ret == -1) + warning(_("close of fd %d (`%s') failed (%s)"), iop->fd, + iop->name, strerror(errno)); + /* + * Be careful -- $0 may still reference the buffer even though + * an explicit close is being done; in the future, maybe we + * can do this a bit better. + */ + if (iop->buf) { + if ((fields_arr[0]->stptr >= iop->buf) + && (fields_arr[0]->stptr < (iop->buf + iop->size))) { + NODE *t; + + t = make_string(fields_arr[0]->stptr, + fields_arr[0]->stlen); + unref(fields_arr[0]); + fields_arr[0] = t; + /* + * 1/27/2003: This used to be here: + * + * reset_record(); + * + * Don't do that; reset_record() throws away all fields, + * saves FS etc. We just need to make sure memory isn't + * corrupted and that references to $0 and fields work. + */ + } + efree(iop->buf); + iop->buf = NULL; + } + if ((iop->flag & IOP_NOFREE_OBJ) == 0) + efree(iop); + return ret == -1 ? 1 : 0; +} + +/* redflags2str --- turn redirection flags into a string, for debugging */ + +const char * +redflags2str(int flags) +{ + static const struct flagtab redtab[] = { + { RED_FILE, "RED_FILE" }, + { RED_PIPE, "RED_PIPE" }, + { RED_READ, "RED_READ" }, + { RED_WRITE, "RED_WRITE" }, + { RED_APPEND, "RED_APPEND" }, + { RED_NOBUF, "RED_NOBUF" }, + { RED_EOF, "RED_EOF" }, + { RED_TWOWAY, "RED_TWOWAY" }, + { RED_PTY, "RED_PTY" }, + { RED_SOCKET, "RED_SOCKET" }, + { RED_TCP, "RED_TCP" }, + { 0, NULL } + }; + + return genflags2str(flags, redtab); +} + +/* redirect --- Redirection for printf and print commands */ + +struct redirect * +redirect(NODE *redir_exp, int redirtype, int *errflg) +{ + struct redirect *rp; + char *str; + int tflag = 0; + int outflag = 0; + const char *direction = "to"; + const char *mode; + int fd; + const char *what = NULL; + int new_rp = FALSE; + int len; /* used with /inet */ + static struct redirect *save_rp = NULL; /* hold onto rp that should + * be freed for reuse + */ + + if (do_sandbox) + fatal(_("redirection not allowed in sandbox mode")); + + switch (redirtype) { + case redirect_append: + tflag = RED_APPEND; + /* FALL THROUGH */ + case redirect_output: + outflag = (RED_FILE|RED_WRITE); + tflag |= outflag; + if (redirtype == redirect_output) + what = ">"; + else + what = ">>"; + break; + case redirect_pipe: + tflag = (RED_PIPE|RED_WRITE); + what = "|"; + break; + case redirect_pipein: + tflag = (RED_PIPE|RED_READ); + what = "|"; + break; + case redirect_input: + tflag = (RED_FILE|RED_READ); + what = "<"; + break; + case redirect_twoway: + tflag = (RED_READ|RED_WRITE|RED_TWOWAY); + what = "|&"; + break; + default: + cant_happen(); + } + if (do_lint && (redir_exp->flags & STRCUR) == 0) + lintwarn(_("expression in `%s' redirection only has numeric value"), + what); + redir_exp = force_string(redir_exp); + str = redir_exp->stptr; + + if (str == NULL || *str == '\0') + fatal(_("expression for `%s' redirection has null string value"), + what); + + if (do_lint && (strncmp(str, "0", redir_exp->stlen) == 0 + || strncmp(str, "1", redir_exp->stlen) == 0)) + lintwarn(_("filename `%s' for `%s' redirection may be result of logical expression"), + str, what); + + /* + * XXX: Use /inet4 and /inet6 with plain /inet being whatever + * we get back from the system. + */ +#ifdef HAVE_SOCKETS + if (inetfile(str, & len, NULL)) { + tflag |= RED_SOCKET; + if (strncmp(str + len, "tcp/", 4) == 0) + tflag |= RED_TCP; /* use shutdown when closing */ + } +#endif /* HAVE_SOCKETS */ + + for (rp = red_head; rp != NULL; rp = rp->next) { +#ifndef PIPES_SIMULATED + /* + * This is an efficiency hack. We want to + * recover the process slot for dead children, + * if at all possible. Messing with signal() for + * SIGCLD leads to lots of headaches. However, if + * we've gotten EOF from a child input pipeline, it's + * good bet that the child has died. So recover it. + */ + if ((rp->flag & RED_EOF) && redirtype == redirect_pipein) { + if (rp->pid != -1) + wait_any(0); + } +#endif /* PIPES_SIMULATED */ + + /* now check for a match */ + if (strlen(rp->value) == redir_exp->stlen + && memcmp(rp->value, str, redir_exp->stlen) == 0 + && ((rp->flag & ~(RED_NOBUF|RED_EOF|RED_PTY)) == tflag + || (outflag != 0 + && (rp->flag & (RED_FILE|RED_WRITE)) == outflag))) { + + int rpflag = (rp->flag & ~(RED_NOBUF|RED_EOF|RED_PTY)); + int newflag = (tflag & ~(RED_NOBUF|RED_EOF|RED_PTY)); + + if (do_lint && rpflag != newflag) + lintwarn( + _("unnecessary mixing of `>' and `>>' for file `%.*s'"), + (int) redir_exp->stlen, rp->value); + + break; + } + } + + if (rp == NULL) { + new_rp = TRUE; + if (save_rp != NULL) { + rp = save_rp; + efree(rp->value); + } else + emalloc(rp, struct redirect *, sizeof(struct redirect), "redirect"); + emalloc(str, char *, redir_exp->stlen + 1, "redirect"); + memcpy(str, redir_exp->stptr, redir_exp->stlen); + str[redir_exp->stlen] = '\0'; + rp->value = str; + rp->flag = tflag; + rp->fp = NULL; + rp->iop = NULL; + rp->pid = -1; + rp->status = 0; + } else + str = rp->value; /* get \0 terminated string */ + save_rp = rp; + + while (rp->fp == NULL && rp->iop == NULL) { + if (! new_rp && rp->flag & RED_EOF) { + /* + * encountered EOF on file or pipe -- must be cleared + * by explicit close() before reading more + */ + save_rp = NULL; + return rp; + } + mode = NULL; + errno = 0; + switch (redirtype) { + case redirect_output: + mode = binmode("w"); + if ((rp->flag & RED_USED) != 0) + mode = (rp->mode[1] == 'b') ? "ab" : "a"; + break; + case redirect_append: + mode = binmode("a"); + break; + case redirect_pipe: + /* synchronize output before new pipe */ + (void) flush_io(); + + os_restore_mode(fileno(stdin)); + if ((rp->fp = popen(str, binmode("w"))) == NULL) + fatal(_("can't open pipe `%s' for output (%s)"), + str, strerror(errno)); + + /* set close-on-exec */ + os_close_on_exec(fileno(rp->fp), str, "pipe", "to"); + rp->flag |= RED_NOBUF; + break; + case redirect_pipein: + direction = "from"; + if (gawk_popen(str, rp) == NULL) + fatal(_("can't open pipe `%s' for input (%s)"), + str, strerror(errno)); + break; + case redirect_input: + direction = "from"; + fd = devopen(str, binmode("r")); + if (fd == INVALID_HANDLE && errno == EISDIR) { + *errflg = EISDIR; + /* do not free rp, saving it for reuse (save_rp = rp) */ + return NULL; + } + rp->iop = iop_alloc(fd, str, NULL, TRUE); + break; + case redirect_twoway: + direction = "to/from"; + if (! two_way_open(str, rp)) { +#ifdef HAVE_SOCKETS + if (inetfile(str, NULL, NULL)) { + *errflg = errno; + /* do not free rp, saving it for reuse (save_rp = rp) */ + return NULL; + } else +#endif + fatal(_("can't open two way pipe `%s' for input/output (%s)"), + str, strerror(errno)); + } + break; + default: + cant_happen(); + } + + if (mode != NULL) { + errno = 0; + fd = devopen(str, mode); + + if (fd > INVALID_HANDLE) { + if (fd == fileno(stdin)) + rp->fp = stdin; + else if (fd == fileno(stdout)) + rp->fp = stdout; + else if (fd == fileno(stderr)) + rp->fp = stderr; + else { + const char *omode = mode; +#if defined(F_GETFL) && defined(O_APPEND) + int fd_flags; + + fd_flags = fcntl(fd, F_GETFL); + if (fd_flags != -1 && (fd_flags & O_APPEND) == O_APPEND) + omode = binmode("a"); +#endif + os_close_on_exec(fd, str, "file", ""); + rp->fp = fdopen(fd, (const char *) omode); + rp->mode = (const char *) mode; + /* don't leak file descriptors */ + if (rp->fp == NULL) + close(fd); + } + if (rp->fp != NULL && os_isatty(fd)) + rp->flag |= RED_NOBUF; + + /* Move rp to the head of the list. */ + if (! new_rp && red_head != rp) { + if ((rp->prev->next = rp->next) != NULL) + rp->next->prev = rp->prev; + red_head->prev = rp; + rp->prev = NULL; + rp->next = red_head; + red_head = rp; + } + } + } + + if (rp->fp == NULL && rp->iop == NULL) { + /* too many files open -- close one and try again */ + if (errno == EMFILE || errno == ENFILE) + close_one(); +#if defined __MINGW32__ || defined __sun + else if (errno == 0) /* HACK! */ + close_one(); +#endif +#ifdef VMS + /* Alpha/VMS V7.1's C RTL is returning this instead + of EMFILE (haven't tried other post-V6.2 systems) */ +#define SS$_EXQUOTA 0x001C + else if (errno == EIO && vaxc$errno == SS$_EXQUOTA) + close_one(); +#endif + else { + /* + * Some other reason for failure. + * + * On redirection of input from a file, + * just return an error, so e.g. getline + * can return -1. For output to file, + * complain. The shell will complain on + * a bad command to a pipe. + */ + if (errflg != NULL) + *errflg = errno; + if (redirtype == redirect_output + || redirtype == redirect_append + ) { + /* multiple messages make life easier for translators */ + if (*direction == 'f') + fatal(_("can't redirect from `%s' (%s)"), + str, strerror(errno)); + else + fatal(_("can't redirect to `%s' (%s)"), + str, strerror(errno)); + } else { + /* do not free rp, saving it for reuse (save_rp = rp) */ + return NULL; + } + } + } + } + + if (new_rp) { + /* + * It opened successfully, hook it into the list. + * Maintain the list in most-recently-used first order. + */ + if (red_head != NULL) + red_head->prev = rp; + rp->prev = NULL; + rp->next = red_head; + red_head = rp; + } + save_rp = NULL; + return rp; +} + +/* getredirect --- find the struct redirect for this file or pipe */ + +struct redirect * +getredirect(const char *str, int len) +{ + struct redirect *rp; + + for (rp = red_head; rp != NULL; rp = rp->next) + if (strlen(rp->value) == len && memcmp(rp->value, str, len) == 0) + return rp; + + return NULL; +} + +/* close_one --- temporarily close an open file to re-use the fd */ + +static void +close_one() +{ + struct redirect *rp; + struct redirect *rplast = NULL; + + static short warned = FALSE; + + if (do_lint && ! warned) { + warned = TRUE; + lintwarn(_("reached system limit for open files: starting to multiplex file descriptors")); + } + + /* go to end of list first, to pick up least recently used entry */ + for (rp = red_head; rp != NULL; rp = rp->next) + rplast = rp; + /* now work back up through the list */ + for (rp = rplast; rp != NULL; rp = rp->prev) { + /* don't close standard files! */ + if (rp->fp == NULL || rp->fp == stderr || rp->fp == stdout) + continue; + + if ((rp->flag & (RED_FILE|RED_WRITE)) == (RED_FILE|RED_WRITE)) { + rp->flag |= RED_USED; + errno = 0; + if (/* do_lint && */ fclose(rp->fp) != 0) + warning(_("close of `%s' failed (%s)."), + rp->value, strerror(errno)); + rp->fp = NULL; + break; + } + } + if (rp == NULL) + /* surely this is the only reason ??? */ + fatal(_("too many pipes or input files open")); +} + +/* do_close --- completely close an open file or pipe */ + +NODE * +do_close(int nargs) +{ + NODE *tmp, *tmp2; + struct redirect *rp; + two_way_close_type how = CLOSE_ALL; /* default */ + + if (nargs == 2) { + /* 2nd arg if present: "to" or "from" for two-way pipe */ + /* DO NOT use _() on the strings here! */ + tmp2 = POP_STRING(); + if (strcasecmp(tmp2->stptr, "to") == 0) + how = CLOSE_TO; + else if (strcasecmp(tmp2->stptr, "from") == 0) + how = CLOSE_FROM; + else { + DEREF(tmp2); + fatal(_("close: second argument must be `to' or `from'")); + } + DEREF(tmp2); + } + + tmp = POP_STRING(); /* 1st arg: redir to close */ + + for (rp = red_head; rp != NULL; rp = rp->next) { + if (strlen(rp->value) == tmp->stlen + && memcmp(rp->value, tmp->stptr, tmp->stlen) == 0) + break; + } + + if (rp == NULL) { /* no match, return -1 */ + char *cp; + + if (do_lint) + lintwarn(_("close: `%.*s' is not an open file, pipe or co-process"), + (int) tmp->stlen, tmp->stptr); + + if (! do_traditional) { + /* update ERRNO manually, using errno = ENOENT is a stretch. */ + cp = _("close of redirection that was never opened"); + unref(ERRNO_node->var_value); + ERRNO_node->var_value = make_string(cp, strlen(cp)); + } + + DEREF(tmp); + return make_number((AWKNUM) -1.0); + } + DEREF(tmp); + fflush(stdout); /* synchronize regular output */ + tmp = make_number((AWKNUM) close_redir(rp, FALSE, how)); + rp = NULL; + /* + * POSIX says close() returns 0 on success, non-zero otherwise. + * For POSIX, at this point we just return 0. Otherwise we + * return the exit status of the process or of pclose(), depending. + * This whole business is a mess. + */ + if (do_posix) { + unref(tmp); + return make_number((AWKNUM) 0); + } + return tmp; +} + +/* close_rp --- separate function to just do closing */ + +static int +close_rp(struct redirect *rp, two_way_close_type how) +{ + int status = 0; + + errno = 0; + if ((rp->flag & RED_TWOWAY) != 0) { /* two-way pipe */ + /* write end: */ + if ((how == CLOSE_ALL || how == CLOSE_TO) && rp->fp != NULL) { +#ifdef HAVE_SOCKETS + if ((rp->flag & RED_TCP) != 0) + (void) shutdown(fileno(rp->fp), SHUT_WR); +#endif /* HAVE_SOCKETS */ + + if ((rp->flag & RED_PTY) != 0) { + fwrite("\004\n", sizeof("\004\n") - 1, 1, rp->fp); + fflush(rp->fp); + } + status = fclose(rp->fp); + rp->fp = NULL; + } + + /* read end: */ + if (how == CLOSE_ALL || how == CLOSE_FROM) { + if ((rp->flag & RED_SOCKET) != 0 && rp->iop != NULL) { +#ifdef HAVE_SOCKETS + if ((rp->flag & RED_TCP) != 0) + (void) shutdown(rp->iop->fd, SHUT_RD); +#endif /* HAVE_SOCKETS */ + (void) iop_close(rp->iop); + } else + status = gawk_pclose(rp); + + rp->iop = NULL; + } + } else if ((rp->flag & (RED_PIPE|RED_WRITE)) == (RED_PIPE|RED_WRITE)) { /* write to pipe */ + status = pclose(rp->fp); + if ((BINMODE & 1) != 0) + os_setbinmode(fileno(stdin), O_BINARY); + + rp->fp = NULL; + } else if (rp->fp != NULL) { /* write to file */ + status = fclose(rp->fp); + rp->fp = NULL; + } else if (rp->iop != NULL) { /* read from pipe/file */ + if ((rp->flag & RED_PIPE) != 0) /* read from pipe */ + status = gawk_pclose(rp); + /* gawk_pclose sets rp->iop to null */ + else { /* read from file */ + status = iop_close(rp->iop); + rp->iop = NULL; + } + } + + return status; +} + +/* close_redir --- close an open file or pipe */ + +static int +close_redir(struct redirect *rp, int exitwarn, two_way_close_type how) +{ + int status = 0; + + if (rp == NULL) + return 0; + if (rp->fp == stdout || rp->fp == stderr) + goto checkwarn; /* bypass closing, remove from list */ + + if (do_lint && (rp->flag & RED_TWOWAY) == 0 && how != CLOSE_ALL) + lintwarn(_("close: redirection `%s' not opened with `|&', second argument ignored"), + rp->value); + + status = close_rp(rp, how); + + /* SVR4 awk checks and warns about status of close */ + if (status != 0) { + int save_errno = errno; + char *s = strerror(save_errno); + + /* + * Too many people have complained about this. + * As of 2.15.6, it is now under lint control. + */ + if (do_lint) { + if ((rp->flag & RED_PIPE) != 0) + lintwarn(_("failure status (%d) on pipe close of `%s' (%s)"), + status, rp->value, s); + else + lintwarn(_("failure status (%d) on file close of `%s' (%s)"), + status, rp->value, s); + } + + if (! do_traditional) { + /* set ERRNO too so that program can get at it */ + update_ERRNO_saved(save_errno); + } + } + +checkwarn: + if (exitwarn) { + /* + * Don't use lintwarn() here. If lint warnings are fatal, + * doing so prevents us from closing other open redirections. + * + * Using multiple full messages instead of string parameters + * for the types makes message translation easier. + */ + if ((rp->flag & RED_SOCKET) != 0) + warning(_("no explicit close of socket `%s' provided"), + rp->value); + else if ((rp->flag & RED_TWOWAY) != 0) + warning(_("no explicit close of co-process `%s' provided"), + rp->value); + else if ((rp->flag & RED_PIPE) != 0) + warning(_("no explicit close of pipe `%s' provided"), + rp->value); + else + warning(_("no explicit close of file `%s' provided"), + rp->value); + } + + /* remove it from the list if closing both or both ends have been closed */ + if (how == CLOSE_ALL || (rp->iop == NULL && rp->fp == NULL)) { + if (rp->next != NULL) + rp->next->prev = rp->prev; + if (rp->prev != NULL) + rp->prev->next = rp->next; + else + red_head = rp->next; + free_rp(rp); + } + + return status; +} + +/* flush_io --- flush all open output files */ + +int +flush_io() +{ + struct redirect *rp; + int status = 0; + + errno = 0; + if (fflush(stdout)) { + warning(_("error writing standard output (%s)"), strerror(errno)); + status++; + } + if (fflush(stderr)) { + warning(_("error writing standard error (%s)"), strerror(errno)); + status++; + } + for (rp = red_head; rp != NULL; rp = rp->next) + /* flush both files and pipes, what the heck */ + if ((rp->flag & RED_WRITE) && rp->fp != NULL) { + if (fflush(rp->fp)) { + if (rp->flag & RED_PIPE) + warning(_("pipe flush of `%s' failed (%s)."), + rp->value, strerror(errno)); + else if (rp->flag & RED_TWOWAY) + warning(_("co-process flush of pipe to `%s' failed (%s)."), + rp->value, strerror(errno)); + else + warning(_("file flush of `%s' failed (%s)."), + rp->value, strerror(errno)); + status++; + } + } + if (status != 0) + status = -1; /* canonicalize it */ + return status; +} + +/* close_io --- close all open files, called when exiting */ + +int +close_io(int *stdio_problem) +{ + struct redirect *rp; + struct redirect *next; + int status = 0; + + errno = 0; + for (rp = red_head; rp != NULL; rp = next) { + next = rp->next; + /* + * close_redir() will print a message if needed + * if do_lint, warn about lack of explicit close + */ + if (close_redir(rp, do_lint, CLOSE_ALL)) + status++; + rp = NULL; + } + /* + * Some of the non-Unix os's have problems doing an fclose + * on stdout and stderr. Since we don't really need to close + * them, we just flush them, and do that across the board. + */ + *stdio_problem = FALSE; + if (fflush(stdout)) { + warning(_("error writing standard output (%s)"), strerror(errno)); + status++; + *stdio_problem = TRUE; + } + if (fflush(stderr)) { + warning(_("error writing standard error (%s)"), strerror(errno)); + status++; + *stdio_problem = TRUE; + } + return status; +} + +/* str2mode --- convert a string mode to an integer mode */ + +static int +str2mode(const char *mode) +{ + int ret; + const char *second = & mode[1]; + + if (*second == 'b') + second++; + + switch(mode[0]) { + case 'r': + ret = O_RDONLY; + if (*second == '+' || *second == 'w') + ret = O_RDWR; + break; + + case 'w': + ret = O_WRONLY|O_CREAT|O_TRUNC; + if (*second == '+' || *second == 'r') + ret = O_RDWR|O_CREAT|O_TRUNC; + break; + + case 'a': + ret = O_WRONLY|O_APPEND|O_CREAT; + if (*second == '+') + ret = O_RDWR|O_APPEND|O_CREAT; + break; + + default: + ret = 0; /* lint */ + cant_happen(); + } + if (strchr(mode, 'b') != NULL) + ret |= O_BINARY; + return ret; +} + +#ifdef HAVE_SOCKETS + +/* socketopen --- open a socket and set it into connected state */ + +static int +socketopen(int family, int type, const char *localpname, + const char *remotepname, const char *remotehostname) +{ + struct addrinfo *lres, *lres0; + struct addrinfo lhints; + struct addrinfo *rres, *rres0; + struct addrinfo rhints; + + int lerror; + int rerror; + + int socket_fd = INVALID_HANDLE; + int any_remote_host = (strcmp(remotehostname, "0") == 0); + + memset (&lhints, '\0', sizeof (lhints)); + lhints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG; + lhints.ai_socktype = type; + lhints.ai_family = family; + + lerror = getaddrinfo (NULL, localpname, &lhints, &lres); + if (lerror) { + if (strcmp(localpname, "0") != 0) + fatal(_("local port %s invalid in `/inet'"), localpname); + lres0 = NULL; + lres = &lhints; + } else + lres0 = lres; + + while (lres != NULL) { + memset (&rhints, '\0', sizeof (rhints)); + rhints.ai_flags = lhints.ai_flags; + rhints.ai_socktype = lhints.ai_socktype; + rhints.ai_family = lhints.ai_family; + rhints.ai_protocol = lhints.ai_protocol; + + rerror = getaddrinfo (any_remote_host ? NULL : remotehostname, remotepname, &rhints, &rres); + if (rerror) { + if (lres0 != NULL) + freeaddrinfo(lres0); + fatal(_("remote host and port information (%s, %s) invalid"), remotehostname, remotepname); + } + rres0 = rres; + socket_fd = INVALID_HANDLE; + while (rres != NULL) { + socket_fd = socket(rres->ai_family, + rres->ai_socktype, rres->ai_protocol); + if (socket_fd < 0 || socket_fd == INVALID_HANDLE) + goto nextrres; + + if (type == SOCK_STREAM) { + int on = 1; +#ifdef SO_LINGER + struct linger linger; + memset(& linger, '\0', sizeof(linger)); +#endif + setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR, + (char *) & on, sizeof(on)); +#ifdef SO_LINGER + linger.l_onoff = 1; + linger.l_linger = 30; /* linger for 30/100 second */ + setsockopt(socket_fd, SOL_SOCKET, SO_LINGER, + (char *) & linger, sizeof(linger)); +#endif + } + if (bind(socket_fd, lres->ai_addr, lres->ai_addrlen) != 0) + goto nextrres; + + if (! any_remote_host) { /* not ANY => create a client */ + if (connect(socket_fd, rres->ai_addr, rres->ai_addrlen) == 0) + break; + } else { /* remote host is ANY => create a server */ + if (type == SOCK_STREAM) { + int clientsocket_fd = INVALID_HANDLE; + + struct sockaddr_storage remote_addr; + socklen_t namelen = sizeof (remote_addr); + + if (listen(socket_fd, 1) >= 0 + && (clientsocket_fd = accept(socket_fd, + (struct sockaddr *) &remote_addr, + &namelen)) >= 0) { + close(socket_fd); + socket_fd = clientsocket_fd; + break; + } + } else if (type == SOCK_DGRAM) { +#ifdef MSG_PEEK + char buf[10]; + struct sockaddr_storage remote_addr; + socklen_t readle; + + if (recvfrom(socket_fd, buf, 1, MSG_PEEK, + (struct sockaddr *) & remote_addr, + & readle) >= 0 + && readle + && connect(socket_fd, + (struct sockaddr *)& remote_addr, + readle) == 0) + break; +#endif + } + } + +nextrres: + if (socket_fd != INVALID_HANDLE) + close(socket_fd); + socket_fd = INVALID_HANDLE; + rres = rres->ai_next; + } + freeaddrinfo(rres0); + if (socket_fd != INVALID_HANDLE) + break; + lres = lres->ai_next; + } + if (lres0) + freeaddrinfo(lres0); + + return socket_fd; +} +#endif /* HAVE_SOCKETS */ + +/* devopen --- handle /dev/std{in,out,err}, /dev/fd/N, regular files */ + +/* + * Strictly speaking, "name" is not a "const char *" because we temporarily + * change the string. + */ + +int +devopen(const char *name, const char *mode) +{ + int openfd; + char *cp; + char *ptr; + int flag = 0; + int len; + int family; + + flag = str2mode(mode); + + if (strcmp(name, "-") == 0) + return fileno(stdin); + + openfd = INVALID_HANDLE; + + if (do_traditional) + goto strictopen; + + if ((openfd = os_devopen(name, flag)) != INVALID_HANDLE) { + os_close_on_exec(openfd, name, "file", ""); + return openfd; + } + + if (strncmp(name, "/dev/", 5) == 0) { + cp = (char *) name + 5; + + if (strcmp(cp, "stdin") == 0 && (flag & O_ACCMODE) == O_RDONLY) + openfd = fileno(stdin); + else if (strcmp(cp, "stdout") == 0 && (flag & O_ACCMODE) == O_WRONLY) + openfd = fileno(stdout); + else if (strcmp(cp, "stderr") == 0 && (flag & O_ACCMODE) == O_WRONLY) + openfd = fileno(stderr); + else if (strncmp(cp, "fd/", 3) == 0) { + struct stat sbuf; + + cp += 3; + openfd = (int) strtoul(cp, &ptr, 10); + if (openfd <= INVALID_HANDLE || ptr == cp + || fstat(openfd, &sbuf) < 0) + openfd = INVALID_HANDLE; + } + /* do not set close-on-exec for inherited fd's */ + if (openfd != INVALID_HANDLE) + return openfd; + } else if (inetfile(name, & len, & family)) { +#ifdef HAVE_SOCKETS + /* /inet/protocol/localport/hostname/remoteport */ + int protocol; + char *hostname; + char *hostnameslastcharp; + char *localpname; + char *localpnamelastcharp; + + cp = (char *) name + len; + /* which protocol? */ + if (strncmp(cp, "tcp/", 4) == 0) + protocol = SOCK_STREAM; + else if (strncmp(cp, "udp/", 4) == 0) + protocol = SOCK_DGRAM; + else { + protocol = SOCK_STREAM; /* shut up the compiler */ + fatal(_("no (known) protocol supplied in special filename `%s'"), + name); + } + cp += 4; + + /* which localport? */ + localpname = cp; + while (*cp != '/' && *cp != '\0') + cp++; + /* + * Require a port, let them explicitly put 0 if + * they don't care. + */ + if (*cp != '/' || cp == localpname) + fatal(_("special file name `%s' is incomplete"), name); + + /* + * We change the special file name temporarily because we + * need a 0-terminated string here for conversion with atoi(). + * By using atoi() the use of decimal numbers is enforced. + */ + *cp = '\0'; + localpnamelastcharp = cp; + + /* which hostname? */ + cp++; + hostname = cp; + while (*cp != '/' && *cp != '\0') + cp++; + if (*cp != '/' || cp == hostname) { + *localpnamelastcharp = '/'; + fatal(_("must supply a remote hostname to `/inet'")); + } + *cp = '\0'; + hostnameslastcharp = cp; + + /* which remoteport? */ + cp++; + /* + * The remote port ends the special file name. + * This means there already is a 0 at the end of the string. + * Therefore no need to patch any string ending. + * + * Here too, require a port, let them explicitly put 0 if + * they don't care. + */ + if (*cp == '\0') { + *localpnamelastcharp = '/'; + *hostnameslastcharp = '/'; + fatal(_("must supply a remote port to `/inet'")); + } + + { +#define DEFAULT_RETRIES 20 + static unsigned long def_retries = DEFAULT_RETRIES; + static int first_time = TRUE; + unsigned long retries = 0; + static long msleep = 1000; + + if (first_time) { + char *cp, *end; + unsigned long count = 0; + char *ms2; + + first_time = FALSE; + if ((cp = getenv("GAWK_SOCK_RETRIES")) != NULL) { + count = strtoul(cp, &end, 10); + if (end != cp && count > 0) + def_retries = count; + } + + /* + * Env var is in milliseconds, paramter to usleep() + * is microseconds, make the conversion. Default is + * 1 millisecond. + */ + if ((ms2 = getenv("GAWK_MSEC_SLEEP")) != NULL) { + msleep = strtol(ms2, &end, 10); + if (end == ms2 || msleep < 0) + msleep = 1000; + else + msleep *= 1000; + } + } + retries = def_retries; + + do { + openfd = socketopen(family, protocol, localpname, cp, hostname); + retries--; + } while (openfd == INVALID_HANDLE && retries > 0 && usleep(msleep) == 0); + } + + *localpnamelastcharp = '/'; + *hostnameslastcharp = '/'; +#else /* ! HAVE_SOCKETS */ + fatal(_("TCP/IP communications are not supported")); +#endif /* HAVE_SOCKETS */ + } + +strictopen: + if (openfd == INVALID_HANDLE) + openfd = open(name, flag, 0666); +#ifdef __EMX__ + if (openfd == INVALID_HANDLE && errno == EACCES) { + /* on OS/2 directory access via open() is not permitted */ + struct stat buf; + + if (stat(name, &buf) == 0 && S_ISDIR(buf.st_mode)) + errno = EISDIR; + } +#endif + if (openfd != INVALID_HANDLE) { + if (os_isdir(openfd)) { + (void) close(openfd); /* don't leak fds */ + /* Set useful error number. */ + errno = EISDIR; + return INVALID_HANDLE; + } + + if (openfd > fileno(stderr)) + os_close_on_exec(openfd, name, "file", ""); + } + /* + * XXX: FIXME: if fd is INVALID_HANDLE, see if an open hook + * can do something. + */ + return openfd; +} + +/* two_way_open --- open a two way communications channel */ + +static int +two_way_open(const char *str, struct redirect *rp) +{ + static int no_ptys = FALSE; + +#ifdef HAVE_SOCKETS + /* case 1: socket */ + if (inetfile(str, NULL, NULL)) { + int fd, newfd; + + fd = devopen(str, "rw"); + if (fd == INVALID_HANDLE) + return FALSE; + rp->fp = fdopen(fd, "w"); + if (rp->fp == NULL) { + close(fd); + return FALSE; + } + newfd = dup(fd); + if (newfd < 0) { + fclose(rp->fp); + return FALSE; + } + os_close_on_exec(newfd, str, "socket", "to/from"); + rp->iop = iop_alloc(newfd, str, NULL, TRUE); + if (rp->iop == NULL) { + fclose(rp->fp); + return FALSE; + } + rp->flag |= RED_SOCKET; + return TRUE; + } +#endif /* HAVE_SOCKETS */ + +#if defined(HAVE_TERMIOS_H) && ! defined(ZOS_USS) + /* case 2: use ptys for two-way communications to child */ + if (! no_ptys && pty_vs_pipe(str)) { + static int initialized = FALSE; + static char first_pty_letter; +#ifdef HAVE_GRANTPT + static int have_dev_ptmx; +#endif + char slavenam[32]; + char c; + int master, dup_master; + int slave; + int save_errno; + pid_t pid; + struct stat statb; + struct termios st; + /* Use array of chars to avoid ascii / ebcdic issues */ + static char pty_chars[] = "pqrstuvwxyzabcdefghijklmno"; + int i; + + if (! initialized) { + initialized = TRUE; +#ifdef HAVE_GRANTPT + have_dev_ptmx = (stat("/dev/ptmx", &statb) >= 0); +#endif + i = 0; + do { + c = pty_chars[i++]; + sprintf(slavenam, "/dev/pty%c0", c); + if (stat(slavenam, &statb) >= 0) { + first_pty_letter = c; + break; + } + } while (pty_chars[i] != '\0'); + } + +#ifdef HAVE_GRANTPT + if (have_dev_ptmx) { + master = open("/dev/ptmx", O_RDWR); + if (master >= 0) { + char *tem; + + grantpt(master); + unlockpt(master); + tem = ptsname(master); + if (tem != NULL) { + strcpy(slavenam, tem); + goto got_the_pty; + } + (void) close(master); + } + } +#endif + + if (first_pty_letter) { + /* + * Assume /dev/ptyXNN and /dev/ttyXN naming system. + * The FIRST_PTY_LETTER gives the first X to try. We try in the + * sequence FIRST_PTY_LETTER, .., 'z', 'a', .., FIRST_PTY_LETTER. + * Is this worthwhile, or just over-zealous? + */ + c = first_pty_letter; + do { + int i; + char *cp; + + for (i = 0; i < 16; i++) { + sprintf(slavenam, "/dev/pty%c%x", c, i); + if (stat(slavenam, &statb) < 0) { + no_ptys = TRUE; /* bypass all this next time */ + goto use_pipes; + } + + if ((master = open(slavenam, O_RDWR)) >= 0) { + slavenam[sizeof("/dev/") - 1] = 't'; + if (access(slavenam, R_OK | W_OK) == 0) + goto got_the_pty; + close(master); + } + } + /* move to next character */ + cp = strchr(pty_chars, c); + if (cp[1] != '\0') + cp++; + else + cp = pty_chars; + c = *cp; + } while (c != first_pty_letter); + } else + no_ptys = TRUE; + + /* Couldn't find a pty. Fall back to using pipes. */ + goto use_pipes; + + got_the_pty: + if ((slave = open(slavenam, O_RDWR)) < 0) { + close(master); + fatal(_("could not open `%s', mode `%s'"), + slavenam, "r+"); + } + +#ifdef I_PUSH + /* + * Push the necessary modules onto the slave to + * get terminal semantics. + */ + ioctl(slave, I_PUSH, "ptem"); + ioctl(slave, I_PUSH, "ldterm"); +#endif + + tcgetattr(slave, &st); + st.c_iflag &= ~(ISTRIP | IGNCR | INLCR | IXOFF); + st.c_iflag |= (ICRNL | IGNPAR | BRKINT | IXON); + st.c_oflag &= ~OPOST; + st.c_cflag &= ~CSIZE; + st.c_cflag |= CREAD | CS8 | CLOCAL; + st.c_lflag &= ~(ECHO | ECHOE | ECHOK | NOFLSH | TOSTOP); + st.c_lflag |= ISIG; +#if 0 + st.c_cc[VMIN] = 1; + st.c_cc[VTIME] = 0; +#endif + + /* Set some control codes to default values */ +#ifdef VINTR + st.c_cc[VINTR] = '\003'; /* ^c */ +#endif +#ifdef VQUIT + st.c_cc[VQUIT] = '\034'; /* ^| */ +#endif +#ifdef VERASE + st.c_cc[VERASE] = '\177'; /* ^? */ +#endif +#ifdef VKILL + st.c_cc[VKILL] = '\025'; /* ^u */ +#endif +#ifdef VEOF + st.c_cc[VEOF] = '\004'; /* ^d */ +#endif + tcsetattr(slave, TCSANOW, &st); + + switch (pid = fork ()) { + case 0: + /* Child process */ + setsid(); + +#ifdef TIOCSCTTY + ioctl(slave, TIOCSCTTY, 0); +#endif + + if (close(master) == -1) + fatal(_("close of master pty failed (%s)"), strerror(errno)); + if (close(1) == -1) + fatal(_("close of stdout in child failed (%s)"), + strerror(errno)); + if (dup(slave) != 1) + fatal(_("moving slave pty to stdout in child failed (dup: %s)"), strerror(errno)); + if (close(0) == -1) + fatal(_("close of stdin in child failed (%s)"), + strerror(errno)); + if (dup(slave) != 0) + fatal(_("moving slave pty to stdin in child failed (dup: %s)"), strerror(errno)); + if (close(slave)) + fatal(_("close of slave pty failed (%s)"), strerror(errno)); + + /* stderr does NOT get dup'ed onto child's stdout */ + + signal(SIGPIPE, SIG_DFL); + + execl("/bin/sh", "sh", "-c", str, NULL); + _exit(errno == ENOENT ? 127 : 126); + + case -1: + save_errno = errno; + close(master); + errno = save_errno; + return FALSE; + + } + + /* parent */ + if (close(slave)) { + close(master); + (void) kill(pid, SIGKILL); /* overkill? (pardon pun) */ + fatal(_("close of slave pty failed (%s)"), strerror(errno)); + } + + rp->pid = pid; + rp->iop = iop_alloc(master, str, NULL, TRUE); + if (rp->iop == NULL) { + (void) close(master); + (void) kill(pid, SIGKILL); /* overkill? (pardon pun) */ + return FALSE; + } + + /* + * Force read and write ends of two-way connection to + * be different fd's so they can be closed independently. + */ + if ((dup_master = dup(master)) < 0 + || (rp->fp = fdopen(dup_master, "w")) == NULL) { + iop_close(rp->iop); + rp->iop = NULL; + (void) close(master); + (void) kill(pid, SIGKILL); /* overkill? (pardon pun) */ + if (dup_master > 0) + (void) close(dup_master); + return FALSE; + } + rp->flag |= RED_PTY; + os_close_on_exec(master, str, "pipe", "from"); + os_close_on_exec(dup_master, str, "pipe", "to"); + first_pty_letter = '\0'; /* reset for next command */ + return TRUE; + } +#endif /* defined(HAVE_TERMIOS_H) && ! defined(ZOS_USS) */ + +use_pipes: +#ifndef PIPES_SIMULATED /* real pipes */ + /* case 3: two way pipe to a child process */ + { + int ptoc[2], ctop[2]; + int pid; + int save_errno; +#ifdef __EMX__ + int save_stdout, save_stdin; +#endif + + if (pipe(ptoc) < 0) + return FALSE; /* errno set, diagnostic from caller */ + + if (pipe(ctop) < 0) { + save_errno = errno; + close(ptoc[0]); + close(ptoc[1]); + errno = save_errno; + return FALSE; + } + +#ifdef __EMX__ + save_stdin = dup(0); /* duplicate stdin */ + save_stdout = dup(1); /* duplicate stdout */ + + if (save_stdout == -1 || save_stdin == -1) { + /* if an error occurrs close all open file handles */ + save_errno = errno; + if (save_stdin != -1) + close(save_stdin); + if (save_stdout != -1) + close(save_stdout); + close(ptoc[0]); close(ptoc[1]); + close(ctop[0]); close(ctop[1]); + errno = save_errno; + return FALSE; + } + + /* connect pipes to stdin and stdout */ + close(1); /* close stdout */ + if (dup(ctop[1]) != 1) { /* connect pipe input to stdout */ + close(save_stdin); close(save_stdout); + close(ptoc[0]); close(ptoc[1]); + close(ctop[0]); close(ctop[1]); + fatal(_("moving pipe to stdout in child failed (dup: %s)"), strerror(errno)); + } + close(0); /* close stdin */ + if (dup(ptoc[0]) != 0) { /* connect pipe output to stdin */ + close(save_stdin); close(save_stdout); + close(ptoc[0]); close(ptoc[1]); + close(ctop[0]); close(ctop[1]); + fatal(_("moving pipe to stdin in child failed (dup: %s)"), strerror(errno)); + } + + /* none of these handles must be inherited by the child process */ + (void) close(ptoc[0]); /* close pipe output, child will use stdin instead */ + (void) close(ctop[1]); /* close pipe input, child will use stdout instead */ + + os_close_on_exec(ptoc[1], str, "pipe", "from"); /* pipe input: output of the parent process */ + os_close_on_exec(ctop[0], str, "pipe", "from"); /* pipe output: input of the parent process */ + os_close_on_exec(save_stdin, str, "pipe", "from"); /* saved stdin of the parent process */ + os_close_on_exec(save_stdout, str, "pipe", "from"); /* saved stdout of the parent process */ + + /* stderr does NOT get dup'ed onto child's stdout */ + pid = spawnl(P_NOWAIT, "/bin/sh", "sh", "-c", str, NULL); + + /* restore stdin and stdout */ + close(1); + if (dup(save_stdout) != 1) { + close(save_stdin); close(save_stdout); + close(ptoc[1]); close(ctop[0]); + fatal(_("restoring stdout in parent process failed\n")); + } + close(save_stdout); + + close(0); + if (dup(save_stdin) != 0) { + close(save_stdin); + close(ptoc[1]); close(ctop[0]); + fatal(_("restoring stdin in parent process failed\n")); + } + close(save_stdin); + + if (pid < 0) { /* spawnl() failed */ + save_errno = errno; + close(ptoc[1]); + close(ctop[0]); + + errno = save_errno; + return FALSE; + } + +#else /* NOT __EMX__ */ + if ((pid = fork()) < 0) { + save_errno = errno; + close(ptoc[0]); close(ptoc[1]); + close(ctop[0]); close(ctop[1]); + errno = save_errno; + return FALSE; + } + + if (pid == 0) { /* child */ + if (close(1) == -1) + fatal(_("close of stdout in child failed (%s)"), + strerror(errno)); + if (dup(ctop[1]) != 1) + fatal(_("moving pipe to stdout in child failed (dup: %s)"), strerror(errno)); + if (close(0) == -1) + fatal(_("close of stdin in child failed (%s)"), + strerror(errno)); + if (dup(ptoc[0]) != 0) + fatal(_("moving pipe to stdin in child failed (dup: %s)"), strerror(errno)); + if ( close(ptoc[0]) == -1 || close(ptoc[1]) == -1 + || close(ctop[0]) == -1 || close(ctop[1]) == -1) + fatal(_("close of pipe failed (%s)"), strerror(errno)); + /* stderr does NOT get dup'ed onto child's stdout */ + execl("/bin/sh", "sh", "-c", str, NULL); + _exit(errno == ENOENT ? 127 : 126); + } +#endif /* NOT __EMX__ */ + + /* parent */ + rp->pid = pid; + rp->iop = iop_alloc(ctop[0], str, NULL, TRUE); + if (rp->iop == NULL) { + (void) close(ctop[0]); + (void) close(ctop[1]); + (void) close(ptoc[0]); + (void) close(ptoc[1]); + (void) kill(pid, SIGKILL); /* overkill? (pardon pun) */ + + return FALSE; + } + rp->fp = fdopen(ptoc[1], "w"); + if (rp->fp == NULL) { + iop_close(rp->iop); + rp->iop = NULL; + (void) close(ctop[0]); + (void) close(ctop[1]); + (void) close(ptoc[0]); + (void) close(ptoc[1]); + (void) kill(pid, SIGKILL); /* overkill? (pardon pun) */ + + return FALSE; + } + +#ifndef __EMX__ + os_close_on_exec(ctop[0], str, "pipe", "from"); + os_close_on_exec(ptoc[1], str, "pipe", "from"); + + (void) close(ptoc[0]); + (void) close(ctop[1]); +#endif + + return TRUE; + } + +#else /*PIPES_SIMULATED*/ + + fatal(_("`|&' not supported")); + /*NOTREACHED*/ + return FALSE; + +#endif +} + +#ifndef PIPES_SIMULATED /* real pipes */ + +/* wait_any --- wait for a child process, close associated pipe */ + +static int +wait_any(int interesting) /* pid of interest, if any */ +{ + RETSIGTYPE (*hstat)(int), (*istat)(int), (*qstat)(int); + int pid; + int status = 0; + struct redirect *redp; + + hstat = signal(SIGHUP, SIG_IGN); + istat = signal(SIGINT, SIG_IGN); + qstat = signal(SIGQUIT, SIG_IGN); + for (;;) { +#ifdef HAVE_SYS_WAIT_H /* POSIX compatible sys/wait.h */ + pid = wait(&status); +#else + pid = wait((union wait *)&status); +#endif + if (interesting && pid == interesting) { + break; + } else if (pid != -1) { + for (redp = red_head; redp != NULL; redp = redp->next) + if (pid == redp->pid) { + redp->pid = -1; + redp->status = status; + break; + } + } + if (pid == -1 && errno == ECHILD) + break; + } + signal(SIGHUP, hstat); + signal(SIGINT, istat); + signal(SIGQUIT, qstat); + return status; +} + +/* gawk_popen --- open an IOBUF on a child process */ + +static IOBUF * +gawk_popen(const char *cmd, struct redirect *rp) +{ + int p[2]; + int pid; +#ifdef __EMX__ + int save_stdout; +#endif + + /* + * used to wait for any children to synchronize input and output, + * but this could cause gawk to hang when it is started in a pipeline + * and thus has a child process feeding it input (shell dependent) + */ + /*(void) wait_any(0);*/ /* wait for outstanding processes */ + + if (pipe(p) < 0) + fatal(_("cannot open pipe `%s' (%s)"), cmd, strerror(errno)); + +#ifdef __EMX__ + save_stdout = dup(1); /* save stdout */ + rp->iop = NULL; + if (save_stdout == -1) { + close(p[0]); close(p[1]); + return rp->iop; /* failed */ + } + + close(1); /* close stdout */ + if (dup(p[1]) != 1) { + close(p[0]); close(p[1]); + fatal(_("moving pipe to stdout in child failed (dup: %s)"), strerror(errno)); + } + + /* none of these handles must be inherited by the child process */ + close(p[1]); /* close pipe input */ + + os_close_on_exec(p[0], cmd, "pipe", "from"); /* pipe output: input of the parent process */ + os_close_on_exec(save_stdout, cmd, "pipe", "from"); /* saved stdout of the parent process */ + + pid = spawnl(P_NOWAIT, "/bin/sh", "sh", "-c", cmd, NULL); + + /* restore stdout */ + close(1); + if (dup(save_stdout) != 1) { + close(p[0]); + fatal(_("restoring stdout in parent process failed\n")); + } + close(save_stdout); + +#else /* NOT __EMX__ */ + if ((pid = fork()) == 0) { + if (close(1) == -1) + fatal(_("close of stdout in child failed (%s)"), + strerror(errno)); + if (dup(p[1]) != 1) + fatal(_("moving pipe to stdout in child failed (dup: %s)"), strerror(errno)); + if (close(p[0]) == -1 || close(p[1]) == -1) + fatal(_("close of pipe failed (%s)"), strerror(errno)); + execl("/bin/sh", "sh", "-c", cmd, NULL); + _exit(errno == ENOENT ? 127 : 126); + } +#endif /* NOT __EMX__ */ + + if (pid == -1) { + close(p[0]); close(p[1]); + fatal(_("cannot create child process for `%s' (fork: %s)"), cmd, strerror(errno)); + } + rp->pid = pid; +#ifndef __EMX__ + if (close(p[1]) == -1) { + close(p[0]); + fatal(_("close of pipe failed (%s)"), strerror(errno)); + } +#endif + os_close_on_exec(p[0], cmd, "pipe", "from"); + rp->iop = iop_alloc(p[0], cmd, NULL, TRUE); + if (rp->iop == NULL) + (void) close(p[0]); + + return rp->iop; +} + +/* gawk_pclose --- close an open child pipe */ + +static int +gawk_pclose(struct redirect *rp) +{ + if (rp->iop != NULL) + (void) iop_close(rp->iop); + rp->iop = NULL; + + /* process previously found, return stored status */ + if (rp->pid == -1) + return rp->status; + rp->status = wait_any(rp->pid); + rp->pid = -1; + return rp->status; +} + +#else /* PIPES_SIMULATED */ + +/* + * use temporary file rather than pipe + * except if popen() provides real pipes too + */ + +/* gawk_popen --- open an IOBUF on a child process */ + +static IOBUF * +gawk_popen(const char *cmd, struct redirect *rp) +{ + FILE *current; + + os_restore_mode(fileno(stdin)); + current = popen(cmd, binmode("r")); + if ((BINMODE & 1) != 0) + os_setbinmode(fileno(stdin), O_BINARY); + if (current == NULL) + return NULL; + os_close_on_exec(fileno(current), cmd, "pipe", "from"); + rp->iop = iop_alloc(fileno(current), cmd, NULL, TRUE); + if (rp->iop == NULL) { + (void) pclose(current); + current = NULL; + } + rp->ifp = current; + return rp->iop; +} + +/* gawk_pclose --- close an open child pipe */ + +static int +gawk_pclose(struct redirect *rp) +{ + int rval, aval, fd = rp->iop->fd; + + if (rp->iop != NULL) { + rp->iop->fd = dup(fd); /* kludge to allow close() + pclose() */ + rval = iop_close(rp->iop); + } + rp->iop = NULL; + aval = pclose(rp->ifp); + rp->ifp = NULL; + return (rval < 0 ? rval : aval); +} + +#endif /* PIPES_SIMULATED */ + +/* do_getline --- read in a line, into var and with redirection */ + +NODE * +do_getline_redir(int intovar, int redirtype) +{ + struct redirect *rp = NULL; + IOBUF *iop; + int cnt = EOF; + char *s = NULL; + int errcode; + NODE *redir_exp = NULL; + NODE **lhs = NULL; + int redir_error = 0; + + if (intovar) + lhs = POP_ADDRESS(); + + assert(redirtype != 0); + redir_exp = TOP(); + rp = redirect(redir_exp, redirtype, &redir_error); + DEREF(redir_exp); + decr_sp(); + if (rp == NULL) { + if (redir_error) { /* failed redirect */ + if (! do_traditional) + update_ERRNO_saved(redir_error); + } + return make_number((AWKNUM) -1.0); + } + iop = rp->iop; + if (iop == NULL) /* end of input */ + return make_number((AWKNUM) 0.0); + + errcode = 0; + cnt = get_a_record(&s, iop, &errcode); + if (errcode != 0) { + if (! do_traditional && (errcode != -1)) + update_ERRNO_saved(errcode); + return make_number((AWKNUM) -1.0); + } + + if (cnt == EOF) { + /* + * Don't do iop_close() here if we are + * reading from a pipe; otherwise + * gawk_pclose will not be called. + */ + if ((rp->flag & (RED_PIPE|RED_TWOWAY)) == 0) { + (void) iop_close(iop); + rp->iop = NULL; + } + rp->flag |= RED_EOF; /* sticky EOF */ + return make_number((AWKNUM) 0.0); + } + + if (lhs == NULL) /* no optional var. */ + set_record(s, cnt); + else { /* assignment to variable */ + unref(*lhs); + *lhs = make_string(s, cnt); + (*lhs)->flags |= MAYBE_NUM; + } + + return make_number((AWKNUM) 1.0); +} + +/* do_getline --- read in a line, into var and without redirection */ + +NODE * +do_getline(int intovar, IOBUF *iop) +{ + int cnt = EOF; + char *s = NULL; + int errcode; + + if (iop == NULL) { /* end of input */ + if (intovar) + (void) POP_ADDRESS(); + return make_number((AWKNUM) 0.0); + } + + errcode = 0; + cnt = get_a_record(&s, iop, &errcode); + if (errcode != 0) { + if (! do_traditional && (errcode != -1)) + update_ERRNO_saved(errcode); + if (intovar) + (void) POP_ADDRESS(); + return make_number((AWKNUM) -1.0); + } + + if (cnt == EOF) + return NULL; /* try next file */ + NR++; + FNR++; + + if (! intovar) /* no optional var. */ + set_record(s, cnt); + else { /* assignment to variable */ + NODE **lhs; + lhs = POP_ADDRESS(); + unref(*lhs); + *lhs = make_string(s, cnt); + (*lhs)->flags |= MAYBE_NUM; + } + return make_number((AWKNUM) 1.0); +} + + +static char **awkpath = NULL; /* array containing library search paths */ +static int max_pathlen; /* length of the longest item in awkpath */ + +/* init_awkpath --- split path(=$AWKPATH) into components */ + +static void +init_awkpath(char *path) +{ + char *start, *end, *p; + int len, i; + static int max_path = 0; + +#define INC_PATH 5 + + max_pathlen = 0; + if (path == NULL || *path == '\0') + path = defpath; + + for (i = 0; i < max_path && awkpath[i]; i++) { + efree(awkpath[i]); + awkpath[i] = NULL; + } + + if (max_path == 0) { + max_path = INC_PATH; + emalloc(awkpath, char **, (max_path + 1) * sizeof(char *), "init_awkpath"); + memset(awkpath, 0, (max_path + 1) * sizeof(char *)); + } + + end = start = path; + i = 0; + while (*start) { + while (*end && *end != envsep) + end++; + len = end - start; + if (len > 0) { + emalloc(p, char *, len + 2, "init_awkpath"); + memcpy(p, start, len); + + /* add directory punctuation if necessary */ + if (! isdirpunct(*(end - 1))) + p[len++] = '/'; + p[len] = '\0'; + + if (i == max_path) { + max_path += INC_PATH; + erealloc(awkpath, char **, (max_path + 1) * sizeof(char *), "init_awkpath"); + memset(awkpath + i, 0, (INC_PATH + 1) * sizeof(char *)); + } + awkpath[i++] = p; + if (len > max_pathlen) + max_pathlen = len; + } + + /* skip one or more envsep char */ + while (*end && *end == envsep) + end++; + start = end; + } + awkpath[i] = NULL; + +#undef INC_PATH +} + +/* do_find_source --- search $AWKPATH for file, return NULL if not found */ + +static char * +do_find_source(const char *src, struct stat *stb, int *errcode) +{ + char *path; + int i; + + assert(errcode != NULL); + + /* some kind of path name, no search */ + if (ispath(src)) { + emalloc(path, char *, strlen(src) + 1, "do_find_source"); + strcpy(path, src); + if (stat(path, stb) == 0) + return path; + *errcode = errno; + efree(path); + return NULL; + } + + /* try current directory before path search */ + if (stat(src, stb) == 0) { + emalloc(path, char *, strlen(src) + 1, "do_find_source"); + strcpy(path, src); + return path; + } + + if (awkpath == NULL) + init_awkpath(getenv("AWKPATH")); + + emalloc(path, char *, max_pathlen + strlen(src) + 1, "do_find_source"); + for (i = 0; awkpath[i] != NULL; i++) { + if (strcmp(awkpath[i], "./") == 0 || strcmp(awkpath[i], ".") == 0) { + *path = '\0'; + } else + strcpy(path, awkpath[i]); + strcat(path, src); + if (stat(path, stb) == 0) + return path; + } + + /* not found, give up */ + *errcode = errno; + efree(path); + return NULL; +} + +/* find_source --- find source file with default file extension handling */ + +char * +find_source(const char *src, struct stat *stb, int *errcode) +{ + char *path; + + *errcode = 0; + if (src == NULL || *src == '\0') + return NULL; + path = do_find_source(src, stb, errcode); + +#ifdef DEFAULT_FILETYPE + if (! do_traditional && path == NULL) { + char *file_awk; + int save = errno; +#ifdef VMS + int vms_save = vaxc$errno; +#endif + + /* append ".awk" and try again */ + emalloc(file_awk, char *, strlen(src) + + sizeof(DEFAULT_FILETYPE) + 1, "find_source"); + sprintf(file_awk, "%s%s", src, DEFAULT_FILETYPE); + path = do_find_source(file_awk, stb, errcode); + efree(file_awk); + if (path == NULL) { + errno = save; +#ifdef VMS + vaxc$errno = vms_save; +#endif + } + } +#endif /*DEFAULT_FILETYPE*/ + + return path; +} + +/* srcopen --- open source file */ + +int +srcopen(SRCFILE *s) +{ + if (s->stype == SRC_STDIN) + return (0); + if (s->stype == SRC_FILE || s->stype == SRC_INC) + return devopen(s->fullpath, "r"); + return INVALID_HANDLE; +} + +#ifdef TEST +int bufsize = 8192; + +void +fatal(const char *s) +{ + printf("%s\n", s); + exit(EXIT_FAILURE); +} +#endif + +/* open hooks, mainly for use by extension functions */ + +static struct open_hook { + struct open_hook *next; + void *(*open_func)(IOBUF *); +} *open_hooks; + +/* register_open_hook --- add an open hook to the list */ + +void +register_open_hook(void *(*open_func)(IOBUF *)) +{ + struct open_hook *oh; + + emalloc(oh, struct open_hook *, sizeof(*oh), "register_open_hook"); + oh->open_func = open_func; + oh->next = open_hooks; + open_hooks = oh; +} + +/* find_open_hook --- search the list of open hooks */ + +static void +find_open_hook(IOBUF *iop) +{ + struct open_hook *oh; + + /* walk through open hooks, stop at first one that responds */ + for (oh = open_hooks; oh != NULL; oh = oh->next) { + if ((iop->opaque = (*oh->open_func)(iop)) != NULL) + break; + } +} + +/* iop_alloc --- allocate an IOBUF structure for an open fd */ + +static IOBUF * +iop_alloc(int fd, const char *name, IOBUF *iop, int do_openhooks) +{ + struct stat sbuf; + int iop_malloced = FALSE; + + if (iop == NULL) { + emalloc(iop, IOBUF *, sizeof(IOBUF), "iop_alloc"); + iop_malloced = TRUE; + } + memset(iop, '\0', sizeof(IOBUF)); + iop->flag = 0; + iop->fd = fd; + iop->name = name; + + if (do_openhooks) + find_open_hook(iop); + else if (iop->fd == INVALID_HANDLE) + return iop; + + /* test reached if tried to find open hook and could not */ + if (iop->fd == INVALID_HANDLE) { + if (iop_malloced) + efree(iop); + return NULL; + } + + if (os_isatty(iop->fd)) + iop->flag |= IOP_IS_TTY; + iop->readsize = iop->size = optimal_bufsize(iop->fd, & sbuf); + iop->sbuf = sbuf; + if (do_lint && S_ISREG(sbuf.st_mode) && sbuf.st_size == 0) + lintwarn(_("data file `%s' is empty"), name); + errno = 0; + iop->count = iop->scanoff = 0; + emalloc(iop->buf, char *, iop->size += 2, "iop_alloc"); + iop->off = iop->buf; + iop->dataend = NULL; + iop->end = iop->buf + iop->size; + iop->flag |= IOP_AT_START; + return iop; +} + +#define set_RT_to_null() \ + (void)(! do_traditional && (unref(RT_node->var_value), \ + RT_node->var_value = Nnull_string)) + +#define set_RT(str, len) \ + (void)(! do_traditional && (unref(RT_node->var_value), \ + RT_node->var_value = make_string(str, len))) + +/* grow must increase size of buffer, set end, make sure off and dataend point at */ +/* right spot. */ +/* */ +/* */ +/* = */ +/* grow_iop_buffer --- grow the buffer */ + +static void +grow_iop_buffer(IOBUF *iop) +{ + size_t valid = iop->dataend - iop->off; + size_t off = iop->off - iop->buf; + size_t newsize; + + /* + * Lop off original extra two bytes, double the size, + * add them back. + */ + newsize = ((iop->size - 2) * 2) + 2; + + /* Check for overflow */ + if (newsize <= iop->size) + fatal(_("could not allocate more input memory")); + + /* Make sure there's room for a disk block */ + if (newsize - valid < iop->readsize) + newsize += iop->readsize + 2; + + /* Check for overflow, again */ + if (newsize <= iop->size) + fatal(_("could not allocate more input memory")); + + iop->size = newsize; + erealloc(iop->buf, char *, iop->size, "grow_iop_buffer"); + iop->off = iop->buf + off; + iop->dataend = iop->off + valid; + iop->end = iop->buf + iop->size; +} + +/* Here are the routines. */ +/* */ +/* */ +/* = */ +/* rs1scan --- scan for a single character record terminator */ + +static RECVALUE +rs1scan(IOBUF *iop, struct recmatch *recm, SCANSTATE *state) +{ + char *bp; + char rs; +#if MBS_SUPPORT + size_t mbclen = 0; + mbstate_t mbs; +#endif + + memset(recm, '\0', sizeof(struct recmatch)); + rs = RS->stptr[0]; + *(iop->dataend) = rs; /* set sentinel */ + recm->start = iop->off; /* beginning of record */ + + bp = iop->off; + if (*state == INDATA) /* skip over data we've already seen */ + bp += iop->scanoff; + +#if MBS_SUPPORT + /* + * From: Bruno Haible + * To: Aharon Robbins , gnits@gnits.org + * Subject: Re: multibyte locales: any way to find if a character isn't multibyte? + * Date: Mon, 23 Jun 2003 12:20:16 +0200 + * Cc: isamu@yamato.ibm.com + * + * Hi, + * + * > Is there any way to make the following query to the current locale? + * > + * > Given an 8-bit value, can this value ever appear as part of + * > a multibyte character? + * + * There is no simple answer here. The easiest solution I see is to + * get the current locale's codeset (via locale_charset() which is a + * wrapper around nl_langinfo(CODESET)), and then perform a case-by-case + * treatment of the known multibyte encodings, from GB2312 to EUC-JISX0213; + * for the unibyte encodings, a single btowc() call will tell you. + * + * > This is particularly critical for me for ASCII newline ('\n'). If I + * > can be guaranteed that it never shows up as part of a multibyte character, + * > I can speed up gawk considerably in mulitbyte locales. + * + * This is much simpler to answer! + * In all ASCII based multibyte encodings used for locales today (this + * excludes EBCDIC based doublebyte encodings from IBM, and also excludes + * ISO-2022-JP which is used for email exchange but not as a locale encoding) + * ALL bytes in the range 0x00..0x2F occur only as a single character, not + * as part of a multibyte character. + * + * So it's safe to assume, but deserves a comment in the source. + * + * Bruno + *************************************************************** + * From: Bruno Haible + * To: Aharon Robbins + * Subject: Re: multibyte locales: any way to find if a character isn't multibyte? + * Date: Mon, 23 Jun 2003 14:27:49 +0200 + * + * On Monday 23 June 2003 14:11, you wrote: + * + * > if (rs != '\n' && MB_CUR_MAX > 1) { + * + * If you assume ASCII, you can even write + * + * if (rs >= 0x30 && MB_CUR_MAX > 1) { + * + * (this catches also the space character) but if portability to EBCDIC + * systems is desired, your code is fine as is. + * + * Bruno + */ + /* Thus, the check for \n here; big speedup ! */ + if (rs != '\n' && gawk_mb_cur_max > 1) { + int len = iop->dataend - bp; + int found = 0; + + memset(&mbs, 0, sizeof(mbstate_t)); + do { + if (*bp == rs) + found = 1; + if (is_valid_character(*bp)) + mbclen = 1; + else + mbclen = mbrlen(bp, len, &mbs); + if ( (mbclen == 1) + || (mbclen == (size_t) -1) + || (mbclen == (size_t) -2) + || (mbclen == 0)) { + /* We treat it as a singlebyte character. */ + mbclen = 1; + } + len -= mbclen; + bp += mbclen; + } while (len > 0 && ! found); + + /* Check that newline found isn't the sentinel. */ + if (found && (bp - mbclen) < iop->dataend) { + /* + * set len to what we have so far, in case this is + * all there is + */ + recm->len = bp - recm->start - mbclen; + recm->rt_start = bp - mbclen; + recm->rt_len = mbclen; + *state = NOSTATE; + return REC_OK; + } else { + /* also set len */ + recm->len = bp - recm->start; + *state = INDATA; + iop->scanoff = bp - iop->off; + return NOTERM; + } + } +#endif + while (*bp != rs) + bp++; + + /* set len to what we have so far, in case this is all there is */ + recm->len = bp - recm->start; + + if (bp < iop->dataend) { /* found it in the buffer */ + recm->rt_start = bp; + recm->rt_len = 1; + *state = NOSTATE; + return REC_OK; + } else { + *state = INDATA; + iop->scanoff = bp - iop->off; + return NOTERM; + } +} + +/* = */ +/* rsrescan --- search for a regex match in the buffer */ + +static RECVALUE +rsrescan(IOBUF *iop, struct recmatch *recm, SCANSTATE *state) +{ + char *bp; + size_t restart = 0, reend = 0; + Regexp *RSre = RS_regexp; + int regex_flags = RE_NEED_START; + + memset(recm, '\0', sizeof(struct recmatch)); + recm->start = iop->off; + + bp = iop->off; + if (*state == INDATA) + bp += iop->scanoff; + + if ((iop->flag & IOP_AT_START) == 0) + regex_flags |= RE_NO_BOL; +again: + /* case 1, no match */ + if (research(RSre, bp, 0, iop->dataend - bp, regex_flags) == -1) { + /* set len, in case this all there is. */ + recm->len = iop->dataend - iop->off; + return NOTERM; + } + + /* ok, we matched within the buffer, set start and end */ + restart = RESTART(RSre, iop->off); + reend = REEND(RSre, iop->off); + + /* case 2, null regex match, grow buffer, try again */ + if (restart == reend) { + *state = INDATA; + iop->scanoff = reend + 1; + /* + * If still room in buffer, skip over null match + * and restart search. Otherwise, return. + */ + if (bp + iop->scanoff < iop->dataend) { + bp += iop->scanoff; + goto again; + } + recm->len = (bp - iop->off) + restart; + return NOTERM; + } + + /* + * At this point, we have a non-empty match. + * + * First, fill in rest of data. The rest of the cases return + * a record and terminator. + */ + recm->len = restart; + recm->rt_start = bp + restart; + recm->rt_len = reend - restart; + *state = NOSTATE; + + /* + * 3. Match exactly at end: + * if re is a simple string match + * found a simple string match at end, return REC_OK + * else + * grow buffer, add more data, try again + * fi + */ + if (iop->off + reend >= iop->dataend) { + if (reisstring(RS->stptr, RS->stlen, RSre, iop->off)) + return REC_OK; + else + return TERMATEND; + } + + /* + * 4. Match within xxx bytes of end & maybe islong re: + * return TERMNEAREND + */ + + /* + * case 4, match succeeded, but there may be more in + * the next input buffer. + * + * Consider an RS of xyz(abc)? where the + * exact end of the buffer is xyza and the + * next two, unread, characters are bc. + * + * This matches the "xyz" and ends up putting the + * "abc" into the front of the next record. Ooops. + * + * The remaybelong() function looks to see if the + * regex contains one of: + * ? |. This is a very + * simple heuristic, but in combination with the + * "end of match within a few bytes of end of buffer" + * check, should keep things reasonable. + */ + + /* + * XXX: The reisstring and remaybelong tests should + * really be done once when RS is assigned to and + * then tested as flags here. Maybe one day. + */ + + /* succession of tests is easier to trace in GDB. */ + if (remaybelong(RS->stptr, RS->stlen)) { + char *matchend = iop->off + reend; + + if (iop->dataend - matchend < RS->stlen) + return TERMNEAREND; + } + + return REC_OK; +} + +/* = */ +/* rsnullscan --- handle RS = "" */ + +static RECVALUE +rsnullscan(IOBUF *iop, struct recmatch *recm, SCANSTATE *state) +{ + char *bp; + + if (*state == NOSTATE || *state == INLEADER) + memset(recm, '\0', sizeof(struct recmatch)); + + recm->start = iop->off; + + bp = iop->off; + if (*state != NOSTATE) + bp += iop->scanoff; + + /* set sentinel */ + *(iop->dataend) = '\n'; + + if (*state == INTERM) + goto find_longest_terminator; + else if (*state == INDATA) + goto scan_data; + /* else + fall into things from beginning, + either NOSTATE or INLEADER */ + +/* skip_leading: */ + /* leading newlines are ignored */ + while (*bp == '\n' && bp < iop->dataend) + bp++; + + if (bp >= iop->dataend) { /* LOTS of leading newlines, sheesh. */ + *state = INLEADER; + iop->scanoff = bp - iop->off; + return NOTERM; + } + + iop->off = recm->start = bp; /* real start of record */ +scan_data: + while (*bp++ != '\n') + continue; + + if (bp >= iop->dataend) { /* no full terminator */ + iop->scanoff = recm->len = bp - iop->off - 1; + if (bp == iop->dataend) { /* half a terminator */ + recm->rt_start = bp - 1; + recm->rt_len = 1; + } + *state = INDATA; + return NOTERM; + } + + /* found one newline before end of buffer, check next char */ + if (*bp != '\n') + goto scan_data; + + /* we've now seen at least two newlines */ + *state = INTERM; + recm->len = bp - iop->off - 1; + recm->rt_start = bp - 1; + +find_longest_terminator: + /* find as many newlines as we can, to set RT */ + while (*bp == '\n' && bp < iop->dataend) + bp++; + + recm->rt_len = bp - recm->rt_start; + iop->scanoff = bp - iop->off; + + if (bp >= iop->dataend) + return TERMATEND; + + return REC_OK; +} + +/* = */ +/* get_a_record --- read a record from IOP into out, return length of EOF, set RT */ + +static int +get_a_record(char **out, /* pointer to pointer to data */ + IOBUF *iop, /* input IOP */ + int *errcode) /* pointer to error variable */ +{ + struct recmatch recm; + SCANSTATE state; + RECVALUE ret; + int retval; + NODE *rtval = NULL; + static RECVALUE (*lastmatchrec)(IOBUF *iop, struct recmatch *recm, SCANSTATE *state) = NULL; + + if (at_eof(iop) && no_data_left(iop)) + return EOF; + + if (iop->get_record != NULL) + return (*iop->get_record)(out, iop, errcode); + + /* = */ + if (has_no_data(iop) || no_data_left(iop)) { + iop->count = read(iop->fd, iop->buf, iop->readsize); + if (iop->count == 0) { + iop->flag |= IOP_AT_EOF; + return EOF; + } else if (iop->count == -1) { + iop->flag |= IOP_AT_EOF; + if (errcode != NULL) + *errcode = errno; + return EOF; + } else { + iop->dataend = iop->buf + iop->count; + iop->off = iop->buf; + } + } + + /* = */ + state = NOSTATE; + for (;;) { + size_t dataend_off; + + ret = (*matchrec)(iop, & recm, & state); + iop->flag &= ~IOP_AT_START; + if (ret == REC_OK) + break; + + /* need to add more data to buffer */ + /* = */ + dataend_off = iop->dataend - iop->off; + memmove(iop->buf, iop->off, dataend_off); + iop->off = iop->buf; + iop->dataend = iop->buf + dataend_off; + + /* = */ + recm.start = iop->off; + if (recm.rt_start != NULL) + recm.rt_start = iop->off + recm.len; + + /* = */ + { +#define min(x, y) (x < y ? x : y) + /* subtract one in read count to leave room for sentinel */ + size_t room_left = iop->end - iop->dataend - 1; + size_t amt_to_read = min(iop->readsize, room_left); + + if (amt_to_read < iop->readsize) { + grow_iop_buffer(iop); + /* = */ + recm.start = iop->off; + if (recm.rt_start != NULL) + recm.rt_start = iop->off + recm.len; + + /* recalculate amt_to_read */ + room_left = iop->end - iop->dataend - 1; + amt_to_read = min(iop->readsize, room_left); + } + while (amt_to_read + iop->readsize < room_left) + amt_to_read += iop->readsize; + +#ifdef SSIZE_MAX + /* + * POSIX limits read to SSIZE_MAX. There are (bizarre) + * systems where this amount is small. + */ + amt_to_read = min(amt_to_read, SSIZE_MAX); +#endif + + iop->count = read(iop->fd, iop->dataend, amt_to_read); + if (iop->count == -1) { + *errcode = errno; + iop->flag |= IOP_AT_EOF; + break; + } else if (iop->count == 0) { + /* + * hit EOF before matching RS, so end + * the record and set RT to "" + */ + iop->flag |= IOP_AT_EOF; + break; + } else + iop->dataend += iop->count; + } + } + + /* = */ + + /* + * rtval is not a static pointer to avoid dangling pointer problems + * in case awk code assigns to RT. A remote possibility, to be sure, + * but Bitter Experience teaches us not to make ``that'll never + * happen'' kinds of assumptions. + */ + rtval = RT_node->var_value; + + if (recm.rt_len == 0) { + set_RT_to_null(); + lastmatchrec = NULL; + } else { + assert(recm.rt_start != NULL); + /* + * Optimization. For rs1 case, don't set RT if + * character is same as last time. This knocks a + * chunk of time off something simple like + * + * gawk '{ print }' /some/big/file + * + * Similarly, for rsnull case, if length of new RT is + * shorter than current RT, just bump length down in RT. + * + * Make sure that matchrec didn't change since the last + * check. (Ugh, details, details, details.) + */ + if (lastmatchrec == NULL || lastmatchrec != matchrec) { + lastmatchrec = matchrec; + set_RT(recm.rt_start, recm.rt_len); + } else if (matchrec == rs1scan) { + if (rtval->stlen != 1 || rtval->stptr[0] != recm.rt_start[0]) + set_RT(recm.rt_start, recm.rt_len); + /* else + leave it alone */ + } else if (matchrec == rsnullscan) { + if (rtval->stlen >= recm.rt_len) { + rtval->stlen = recm.rt_len; + free_wstr(rtval); + } else + set_RT(recm.rt_start, recm.rt_len); + } else + set_RT(recm.rt_start, recm.rt_len); + } + + if (recm.len == 0) { + *out = NULL; + retval = 0; + } else { + assert(recm.start != NULL); + *out = recm.start; + retval = recm.len; + } + + iop->off += recm.len + recm.rt_len; + + if (recm.len == 0 && recm.rt_len == 0 && at_eof(iop)) + return EOF; + else + return retval; +} + +/* set_RS --- update things as appropriate when RS is set */ + +void +set_RS() +{ + static NODE *save_rs = NULL; + + /* + * Don't use cmp_nodes(), which pays attention to IGNORECASE. + */ + if (save_rs + && RS_node->var_value->stlen == save_rs->stlen + && memcmp(RS_node->var_value->stptr, save_rs->stptr, save_rs->stlen) == 0) { + /* + * It could be that just IGNORECASE changed. If so, + * update the regex and then do the same for FS. + * set_IGNORECASE() relies on this routine to call + * set_FS(). + */ + RS_regexp = (IGNORECASE ? RS_re_no_case : RS_re_yes_case); + goto set_FS; + } + unref(save_rs); + save_rs = dupnode(RS_node->var_value); + RS_is_null = FALSE; + RS = force_string(RS_node->var_value); + /* + * used to be if (RS_regexp != NULL) { refree(..); refree(..); ...; }. + * Please do not remerge the if condition; hinders memory deallocation + * in case of fatal error in make_regexp. + */ + refree(RS_re_yes_case); /* NULL argument is ok */ + refree(RS_re_no_case); + RS_re_yes_case = RS_re_no_case = RS_regexp = NULL; + + if (RS->stlen == 0) { + RS_is_null = TRUE; + matchrec = rsnullscan; + } else if (RS->stlen > 1) { + static short warned = FALSE; + + RS_re_yes_case = make_regexp(RS->stptr, RS->stlen, FALSE, TRUE, TRUE); + RS_re_no_case = make_regexp(RS->stptr, RS->stlen, TRUE, TRUE, TRUE); + RS_regexp = (IGNORECASE ? RS_re_no_case : RS_re_yes_case); + + matchrec = rsrescan; + + if (do_lint && ! warned) { + lintwarn(_("multicharacter value of `RS' is a gawk extension")); + warned = TRUE; + } + } else + matchrec = rs1scan; +set_FS: + if (current_field_sep() == Using_FS) + set_FS(); +} + +/* pty_vs_pipe --- return true if should use pty instead of pipes for `|&' */ + +/* + * This works by checking if PROCINFO["command", "pty"] exists and is true. + */ + +static int +pty_vs_pipe(const char *command) +{ +#ifdef HAVE_TERMIOS_H + char *full_index; + size_t full_len; + NODE *val; + NODE *sub; + + if (PROCINFO_node == NULL) + return FALSE; + + full_len = strlen(command) + + SUBSEP_node->var_value->stlen + + 3 /* strlen("pty") */ + + 1; /* string terminator */ + emalloc(full_index, char *, full_len, "pty_vs_pipe"); + sprintf(full_index, "%s%.*spty", command, + (int) SUBSEP_node->var_value->stlen, SUBSEP_node->var_value->stptr); + + sub = make_string(full_index, strlen(full_index)); + val = in_array(PROCINFO_node, sub); + unref(sub); + efree(full_index); + + if (val) { + if (val->flags & MAYBE_NUM) + (void) force_number(val); + if (val->flags & NUMBER) + return (val->numbr != 0.0); + else + return (val->stlen != 0); + } +#endif /* HAVE_TERMIOS_H */ + return FALSE; +} + +/* iopflags2str --- make IOP flags printable */ + +const char * +iopflags2str(int flag) +{ + static const struct flagtab values[] = { + { IOP_IS_TTY, "IOP_IS_TTY" }, + { IOP_NOFREE_OBJ, "IOP_NOFREE_OBJ" }, + { IOP_AT_EOF, "IOP_AT_EOF" }, + { IOP_CLOSED, "IOP_CLOSED" }, + { IOP_AT_START, "IOP_AT_START" }, + { 0, NULL } + }; + + return genflags2str(flag, values); +} + +/* free_rp --- release the memory used by rp */ + +static void +free_rp(struct redirect *rp) +{ + efree(rp->value); + efree(rp); +} + +/* inetfile --- return true for a /inet special file, set other values */ + +static int +inetfile(const char *str, int *length, int *family) +{ + int ret = FALSE; + + if (strncmp(str, "/inet/", 6) == 0) { + ret = TRUE; + if (length != NULL) + *length = 6; + if (family != NULL) + *family = AF_UNSPEC; + } else if (strncmp(str, "/inet4/", 7) == 0) { + ret = TRUE; + if (length != NULL) + *length = 7; + if (family != NULL) + *family = AF_INET; + } else if (strncmp(str, "/inet6/", 7) == 0) { + ret = TRUE; + if (length != NULL) + *length = 7; + if (family != NULL) + *family = AF_INET6; +#ifndef HAVE_GETADDRINFO + fatal(_("IPv6 communication is not supported")); +#endif + } + + return ret; +} diff --git a/m4/ChangeLog b/m4/ChangeLog new file mode 100644 index 0000000..d684afe --- /dev/null +++ b/m4/ChangeLog @@ -0,0 +1,9 @@ +2012-03-28 Arnold D. Robbins + + * 4.0.1: Release tar ball made. + +2011-06-23 Arnold D. Robbins + + * ChangeLog.0: Rotated ChangeLog into this file. + * ChangeLog: Created anew for gawk 4.0.0 and on. + * 4.0.0: Release tar ball made. diff --git a/m4/ChangeLog.0 b/m4/ChangeLog.0 new file mode 100644 index 0000000..305c1cf --- /dev/null +++ b/m4/ChangeLog.0 @@ -0,0 +1,180 @@ +Wed Jan 5 20:36:10 2011 Arnold D. Robbins + + * readline.m4: Move call to AC_LANG([C]) from here to + ../configure.ac. + +Tue Jan 4 11:09:43 2011 Arnold D. Robbins + + * readline.m4: Really fixed to work correctly with Autoconf 2.68. + +Sat Dec 25 21:40:25 2010 Arnold D. Robbins + + * readline.m4: Fixed to work correctly with Autoconf 2.68. + +Fri Dec 24 13:00:26 2010 Arnold D. Robbins + + * readline.m4: Updated to work with Autoconf 2.68. + +2010-12-22 gettextize + + * gettext.m4: Upgrade to gettext-0.18.1. + * iconv.m4: Upgrade to gettext-0.18.1. + * lib-ld.m4: Upgrade to gettext-0.18.1. + * lib-link.m4: Upgrade to gettext-0.18.1. + * lib-prefix.m4: Upgrade to gettext-0.18.1. + * nls.m4: Upgrade to gettext-0.18.1. + * po.m4: Upgrade to gettext-0.18.1. + * progtest.m4: Upgrade to gettext-0.18.1. + +Thu May 6 20:55:14 2010 Arnold D. Robbins + + * Release 3.1.8: Release tar file made. + +Mon Apr 26 20:16:49 2010 Arnold D. Robbins + + * libtool.m4, ltoptions.m4, ltsugar.m4, ltversion.m4, + lt~obsolete.m4: Removed. + +Mon Mar 29 08:42:38 2010 Arnold D. Robbins + + * libsigsegv.m4: New file, from gnulib. + +Tue Jul 21 22:28:56 2009 Arnold D. Robbins + + * Release 3.1.7: Release tar file made. + +2009-06-08 gettextize + + * gettext.m4: Upgrade to gettext-0.17. + * iconv.m4: Upgrade to gettext-0.17. + * lib-link.m4: Upgrade to gettext-0.17. + * po.m4: Upgrade to gettext-0.17. + +Mon Jun 8 22:15:29 2009 Arnold D. Robbins + + * libtool.m4, lt~obsolete.m4 ltsugar.m4 ltversion.m4, + ltoptions.m4: New files. + +Mon Oct 22 08:49:05 2007 Arnold D. Robbins + + * Release 3.1.6: Release tar file made. + +Tue Mar 20 21:33:31 2007 Arnold D. Robbins + + * strtod.m4: Removed, not needed anymore. + +2007-01-08 gettextize + + * gettext.m4: Upgrade to gettext-0.16.1. + * lib-link.m4: Upgrade to gettext-0.16.1. + * lib-prefix.m4: Upgrade to gettext-0.16.1. + * nls.m4: Upgrade to gettext-0.16.1. + * po.m4: Upgrade to gettext-0.16.1. + * intl.m4: New file, copied in from move to current Autotools. + * intldir.m4: New file, copied in from move to current Autotools. + * lock.m4: New file, copied in from move to current Autotools. + * visibility.m4: New file, copied in from move to current Autotools. + +Tue Jul 26 21:46:16 2005 Arnold D. Robbins + + * Release 3.1.5: Release tar file made. + +Wed Jul 6 17:05:32 2005 Arnold D. Robbins + + * gettext.m4: Per Bruno Haible, revert the change for the test + for locale.h from Sergey Poznyakoff. + +Wed Jun 8 20:45:17 2005 Sergey Poznyakoff + + * gettext.m4: Move test for locale.h and LC_MESSAGES in AM_GNU_GETTEXT. + Makes things work when the library is external. + +Mon May 30 21:31:43 2005 Arnold D. Robbins + + * intmax_t.m4: Updated macro for intmax_t from Jim Meyering. + +Mon Aug 2 12:18:15 2004 Arnold D. Robbins + + * Release 3.1.4: Release tar file made. + +2004-02-19 gettextize + + * po.m4: Upgrade to gettext-0.14.1. + +2004-01-16 gettextize + + * gettext.m4: Upgrade to gettext-0.13.1. + * intmax.m4: New file, from gettext-0.13.1. + * lib-ld.m4: Upgrade to gettext-0.13.1. + * lib-prefix.m4: Upgrade to gettext-0.13.1. + * longdouble.m4: New file, from gettext-0.13.1. + * longlong.m4: Upgrade to gettext-0.13.1. + * po.m4: Upgrade to gettext-0.13.1. + * printf-posix.m4: New file, from gettext-0.13.1. + * signed.m4: New file, from gettext-0.13.1. + * size_max.m4: New file, from gettext-0.13.1. + * ulonglong.m4: Upgrade to gettext-0.13.1. + * wchar_t.m4: New file, from gettext-0.13.1. + * wint_t.m4: New file, from gettext-0.13.1. + * xsize.m4: New file, from gettext-0.13.1. + * Makefile.am: New file. + +Thu Jan 15 15:51:12 2004 Arnold D. Robbins + + * m4/arch.m4, m4/socket.m4, m4/strtod.m4: Quoting fixed for automake 1.8.x. + +Mon Jul 7 11:01:43 2003 Arnold D. Robbins + + * Release 3.1.3: Release tar file made. + +2003-06-16 gettextize + + * gettext.m4: Upgrade to gettext-0.12.1. + * inttypes_h.m4: Upgrade to gettext-0.12.1. + * lib-ld.m4: Upgrade to gettext-0.12.1. + * lib-link.m4: Upgrade to gettext-0.12.1. + * lib-prefix.m4: Upgrade to gettext-0.12.1. + * nls.m4: New file, from gettext-0.12.1. + * po.m4: New file, from gettext-0.12.1. + * progtest.m4: Upgrade to gettext-0.12.1. + * stdint_h.m4: Upgrade to gettext-0.12.1. + * uintmax_t.m4: New file, from gettext-0.12.1. + * ulonglong.m4: New file, from gettext-0.12.1. + * Makefile.am: New file. + +2003-03-26 Paul Eggert + + * longlong.m4, intmax_t.m4: New files. + * ulonglong.m4, uintmax_t.m4: Removed. + +Wed Mar 19 14:10:31 2003 Arnold D. Robbins + + This time for sure. + -- Bullwinkle + + * Release 3.1.2: Release tar file made. + +Tue Feb 4 14:28:06 2003 Arnold D. Robbins + + All relevant files: Copyright year updated to 2003. + +Wed Nov 20 13:15:59 2002 Arnold D. Robbins + + * arch.m4 (GAWK_AIX_TWEAK): Add -DGAWK_AIX for use in + io.c to get real pipes. Ugh. + Change test to -d /lpp so it actually works. Sigh. + +Wed May 1 16:41:32 2002 Arnold D. Robbins + + * Release 3.1.1: Release tar file made. + +2002-04-28 gettextize + + * gettext.m4: Upgrade to gettext-0.11.2. + * isc-posix.m4: Upgrade to gettext-0.11.2. + * lib-link.m4: Upgrade to gettext-0.11.2. + +2002-04-09 gettextize + + * gettext.m4: Upgrade to gettext-0.11.1. + diff --git a/m4/arch.m4 b/m4/arch.m4 new file mode 100644 index 0000000..2402435 --- /dev/null +++ b/m4/arch.m4 @@ -0,0 +1,74 @@ +dnl +dnl arch.m4 --- autoconf input file for gawk +dnl +dnl Copyright (C) 1995, 1996, 1998, 1999, 2000, 2003, 2004 the Free Software Foundation, Inc. +dnl +dnl This file is part of GAWK, the GNU implementation of the +dnl AWK Progamming Language. +dnl +dnl GAWK is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl GAWK is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +dnl + +dnl Check for AIX and add _XOPEN_SOURCE_EXTENDED +AC_DEFUN([GAWK_AC_AIX_TWEAK], [ +AC_MSG_CHECKING([for AIX compilation hacks]) +AC_CACHE_VAL(gawk_cv_aix_hack, [ +if test -d /lpp +then + CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED=1 -DGAWK_AIX=1" + gawk_cv_aix_hack=yes +else + gawk_cv_aix_hack=no +fi +])dnl +AC_MSG_RESULT([${gawk_cv_aix_hack}]) +])dnl + +dnl Check for Alpha Linux systems +AC_DEFUN([GAWK_AC_LINUX_ALPHA], [ +AC_MSG_CHECKING([for Linux/Alpha compilation hacks]) +AC_CACHE_VAL(gawk_cv_linux_alpha_hack, [ +if test "Linux" = "`uname`" && test "alpha" = "`uname -m`" +then + # this isn't necessarily always true, + # the vendor's compiler is also often found + if test "$GCC" = yes + then + CFLAGS="$CFLAGS -mieee" + gawk_cv_linux_alpha_hack=yes + else + gawk_cv_linux_alpha_hack=no + fi +else + gawk_cv_linux_alpha_hack=no +fi +])dnl +AC_MSG_RESULT([${gawk_cv_linux_alpha_hack}]) +])dnl + +dnl Check for z/OS Unix Systems Services +AC_DEFUN([AC_ZOS_USS], [ +AC_MSG_CHECKING([for z/OS USS compilation]) +if test "OS/390" = "`uname`" +then + CFLAGS="$CFLAGS -D_ALL_SOURCE -DZOS_USS -DUSE_EBCDIC" + # Must rebuild awkgram.c and command.c from Bison for EBCDIC + rm -f awkgram.c command.c + ac_cv_zos_uss=yes +else + ac_cv_zos_uss=no +fi +AC_MSG_RESULT([${ac_cv_zos_uss}]) +])dnl diff --git a/m4/codeset.m4 b/m4/codeset.m4 new file mode 100644 index 0000000..223955b --- /dev/null +++ b/m4/codeset.m4 @@ -0,0 +1,21 @@ +# codeset.m4 serial 2 (gettext-0.16) +dnl Copyright (C) 2000-2002, 2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([AM_LANGINFO_CODESET], +[ + AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset, + [AC_TRY_LINK([#include ], + [char* cs = nl_langinfo(CODESET); return !cs;], + am_cv_langinfo_codeset=yes, + am_cv_langinfo_codeset=no) + ]) + if test $am_cv_langinfo_codeset = yes; then + AC_DEFINE(HAVE_LANGINFO_CODESET, 1, + [Define if you have and nl_langinfo(CODESET).]) + fi +]) diff --git a/m4/gettext.m4 b/m4/gettext.m4 new file mode 100644 index 0000000..f84e6a5 --- /dev/null +++ b/m4/gettext.m4 @@ -0,0 +1,383 @@ +# gettext.m4 serial 63 (gettext-0.18) +dnl Copyright (C) 1995-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2006, 2008-2010. + +dnl Macro to add for using GNU gettext. + +dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]). +dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The +dnl default (if it is not specified or empty) is 'no-libtool'. +dnl INTLSYMBOL should be 'external' for packages with no intl directory, +dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory. +dnl If INTLSYMBOL is 'use-libtool', then a libtool library +dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static, +dnl depending on --{enable,disable}-{shared,static} and on the presence of +dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library +dnl $(top_builddir)/intl/libintl.a will be created. +dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext +dnl implementations (in libc or libintl) without the ngettext() function +dnl will be ignored. If NEEDSYMBOL is specified and is +dnl 'need-formatstring-macros', then GNU gettext implementations that don't +dnl support the ISO C 99 formatstring macros will be ignored. +dnl INTLDIR is used to find the intl libraries. If empty, +dnl the value `$(top_builddir)/intl/' is used. +dnl +dnl The result of the configuration is one of three cases: +dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled +dnl and used. +dnl Catalog format: GNU --> install in $(datadir) +dnl Catalog extension: .mo after installation, .gmo in source tree +dnl 2) GNU gettext has been found in the system's C library. +dnl Catalog format: GNU --> install in $(datadir) +dnl Catalog extension: .mo after installation, .gmo in source tree +dnl 3) No internationalization, always use English msgid. +dnl Catalog format: none +dnl Catalog extension: none +dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur. +dnl The use of .gmo is historical (it was needed to avoid overwriting the +dnl GNU format catalogs when building on a platform with an X/Open gettext), +dnl but we keep it in order not to force irrelevant filename changes on the +dnl maintainers. +dnl +AC_DEFUN([AM_GNU_GETTEXT], +[ + dnl Argument checking. + ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], , + [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT +])])])])]) + ifelse(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old], + [AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])]) + ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], , + [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT +])])])]) + define([gt_included_intl], + ifelse([$1], [external], + ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]), + [yes])) + define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], [])) + gt_NEEDS_INIT + AM_GNU_GETTEXT_NEED([$2]) + + AC_REQUIRE([AM_PO_SUBDIRS])dnl + ifelse(gt_included_intl, yes, [ + AC_REQUIRE([AM_INTL_SUBDIR])dnl + ]) + + dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + + dnl Sometimes libintl requires libiconv, so first search for libiconv. + dnl Ideally we would do this search only after the + dnl if test "$USE_NLS" = "yes"; then + dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then + dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT + dnl the configure script would need to contain the same shell code + dnl again, outside any 'if'. There are two solutions: + dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'. + dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE. + dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not + dnl documented, we avoid it. + ifelse(gt_included_intl, yes, , [ + AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) + ]) + + dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation. + gt_INTL_MACOSX + + dnl Set USE_NLS. + AC_REQUIRE([AM_NLS]) + + ifelse(gt_included_intl, yes, [ + BUILD_INCLUDED_LIBINTL=no + USE_INCLUDED_LIBINTL=no + ]) + LIBINTL= + LTLIBINTL= + POSUB= + + dnl Add a version number to the cache macros. + case " $gt_needs " in + *" need-formatstring-macros "*) gt_api_version=3 ;; + *" need-ngettext "*) gt_api_version=2 ;; + *) gt_api_version=1 ;; + esac + gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc" + gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl" + + dnl If we use NLS figure out what method + if test "$USE_NLS" = "yes"; then + gt_use_preinstalled_gnugettext=no + ifelse(gt_included_intl, yes, [ + AC_MSG_CHECKING([whether included gettext is requested]) + AC_ARG_WITH([included-gettext], + [ --with-included-gettext use the GNU gettext library included here], + nls_cv_force_use_gnu_gettext=$withval, + nls_cv_force_use_gnu_gettext=no) + AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext]) + + nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" + if test "$nls_cv_force_use_gnu_gettext" != "yes"; then + ]) + dnl User does not insist on using GNU NLS library. Figure out what + dnl to use. If GNU gettext is available we use this. Else we have + dnl to fall back to GNU NLS library. + + if test $gt_api_version -ge 3; then + gt_revision_test_code=' +#ifndef __GNU_GETTEXT_SUPPORTED_REVISION +#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1) +#endif +changequote(,)dnl +typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1]; +changequote([,])dnl +' + else + gt_revision_test_code= + fi + if test $gt_api_version -ge 2; then + gt_expression_test_code=' + * ngettext ("", "", 0)' + else + gt_expression_test_code= + fi + + AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc], + [AC_TRY_LINK([#include +$gt_revision_test_code +extern int _nl_msg_cat_cntr; +extern int *_nl_domain_bindings;], + [bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings], + [eval "$gt_func_gnugettext_libc=yes"], + [eval "$gt_func_gnugettext_libc=no"])]) + + if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then + dnl Sometimes libintl requires libiconv, so first search for libiconv. + ifelse(gt_included_intl, yes, , [ + AM_ICONV_LINK + ]) + dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL + dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv]) + dnl because that would add "-liconv" to LIBINTL and LTLIBINTL + dnl even if libiconv doesn't exist. + AC_LIB_LINKFLAGS_BODY([intl]) + AC_CACHE_CHECK([for GNU gettext in libintl], + [$gt_func_gnugettext_libintl], + [gt_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $INCINTL" + gt_save_LIBS="$LIBS" + LIBS="$LIBS $LIBINTL" + dnl Now see whether libintl exists and does not depend on libiconv. + AC_TRY_LINK([#include +$gt_revision_test_code +extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias (const char *);], + [bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], + [eval "$gt_func_gnugettext_libintl=yes"], + [eval "$gt_func_gnugettext_libintl=no"]) + dnl Now see whether libintl exists and depends on libiconv. + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then + LIBS="$LIBS $LIBICONV" + AC_TRY_LINK([#include +$gt_revision_test_code +extern int _nl_msg_cat_cntr; +extern +#ifdef __cplusplus +"C" +#endif +const char *_nl_expand_alias (const char *);], + [bindtextdomain ("", ""); +return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")], + [LIBINTL="$LIBINTL $LIBICONV" + LTLIBINTL="$LTLIBINTL $LTLIBICONV" + eval "$gt_func_gnugettext_libintl=yes" + ]) + fi + CPPFLAGS="$gt_save_CPPFLAGS" + LIBS="$gt_save_LIBS"]) + fi + + dnl If an already present or preinstalled GNU gettext() is found, + dnl use it. But if this macro is used in GNU gettext, and GNU + dnl gettext is already preinstalled in libintl, we update this + dnl libintl. (Cf. the install rule in intl/Makefile.in.) + if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \ + || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \ + && test "$PACKAGE" != gettext-runtime \ + && test "$PACKAGE" != gettext-tools; }; then + gt_use_preinstalled_gnugettext=yes + else + dnl Reset the values set by searching for libintl. + LIBINTL= + LTLIBINTL= + INCINTL= + fi + + ifelse(gt_included_intl, yes, [ + if test "$gt_use_preinstalled_gnugettext" != "yes"; then + dnl GNU gettext is not found in the C library. + dnl Fall back on included GNU gettext library. + nls_cv_use_gnu_gettext=yes + fi + fi + + if test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Mark actions used to generate GNU NLS library. + BUILD_INCLUDED_LIBINTL=yes + USE_INCLUDED_LIBINTL=yes + LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD" + LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD" + LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'` + fi + + CATOBJEXT= + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Mark actions to use GNU gettext tools. + CATOBJEXT=.gmo + fi + ]) + + if test -n "$INTL_MACOSX_LIBS"; then + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + dnl Some extra flags are needed during linking. + LIBINTL="$LIBINTL $INTL_MACOSX_LIBS" + LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS" + fi + fi + + if test "$gt_use_preinstalled_gnugettext" = "yes" \ + || test "$nls_cv_use_gnu_gettext" = "yes"; then + AC_DEFINE([ENABLE_NLS], [1], + [Define to 1 if translation of program messages to the user's native language + is requested.]) + else + USE_NLS=no + fi + fi + + AC_MSG_CHECKING([whether to use NLS]) + AC_MSG_RESULT([$USE_NLS]) + if test "$USE_NLS" = "yes"; then + AC_MSG_CHECKING([where the gettext function comes from]) + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then + gt_source="external libintl" + else + gt_source="libc" + fi + else + gt_source="included intl directory" + fi + AC_MSG_RESULT([$gt_source]) + fi + + if test "$USE_NLS" = "yes"; then + + if test "$gt_use_preinstalled_gnugettext" = "yes"; then + if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then + AC_MSG_CHECKING([how to link with libintl]) + AC_MSG_RESULT([$LIBINTL]) + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL]) + fi + + dnl For backward compatibility. Some packages may be using this. + AC_DEFINE([HAVE_GETTEXT], [1], + [Define if the GNU gettext() function is already present or preinstalled.]) + AC_DEFINE([HAVE_DCGETTEXT], [1], + [Define if the GNU dcgettext() function is already present or preinstalled.]) + fi + + dnl We need to process the po/ directory. + POSUB=po + fi + + ifelse(gt_included_intl, yes, [ + dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL + dnl to 'yes' because some of the testsuite requires it. + if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then + BUILD_INCLUDED_LIBINTL=yes + fi + + dnl Make all variables we use known to autoconf. + AC_SUBST([BUILD_INCLUDED_LIBINTL]) + AC_SUBST([USE_INCLUDED_LIBINTL]) + AC_SUBST([CATOBJEXT]) + + dnl For backward compatibility. Some configure.ins may be using this. + nls_cv_header_intl= + nls_cv_header_libgt= + + dnl For backward compatibility. Some Makefiles may be using this. + DATADIRNAME=share + AC_SUBST([DATADIRNAME]) + + dnl For backward compatibility. Some Makefiles may be using this. + INSTOBJEXT=.mo + AC_SUBST([INSTOBJEXT]) + + dnl For backward compatibility. Some Makefiles may be using this. + GENCAT=gencat + AC_SUBST([GENCAT]) + + dnl For backward compatibility. Some Makefiles may be using this. + INTLOBJS= + if test "$USE_INCLUDED_LIBINTL" = yes; then + INTLOBJS="\$(GETTOBJS)" + fi + AC_SUBST([INTLOBJS]) + + dnl Enable libtool support if the surrounding package wishes it. + INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix + AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX]) + ]) + + dnl For backward compatibility. Some Makefiles may be using this. + INTLLIBS="$LIBINTL" + AC_SUBST([INTLLIBS]) + + dnl Make all documented variables known to autoconf. + AC_SUBST([LIBINTL]) + AC_SUBST([LTLIBINTL]) + AC_SUBST([POSUB]) +]) + + +dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized. +m4_define([gt_NEEDS_INIT], +[ + m4_divert_text([DEFAULTS], [gt_needs=]) + m4_define([gt_NEEDS_INIT], []) +]) + + +dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL]) +AC_DEFUN([AM_GNU_GETTEXT_NEED], +[ + m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"]) +]) + + +dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version]) +AC_DEFUN([AM_GNU_GETTEXT_VERSION], []) diff --git a/m4/glibc2.m4 b/m4/glibc2.m4 new file mode 100644 index 0000000..e8f5bfe --- /dev/null +++ b/m4/glibc2.m4 @@ -0,0 +1,30 @@ +# glibc2.m4 serial 1 +dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Test for the GNU C Library, version 2.0 or newer. +# From Bruno Haible. + +AC_DEFUN([gt_GLIBC2], + [ + AC_CACHE_CHECK(whether we are using the GNU C Library 2 or newer, + ac_cv_gnu_library_2, + [AC_EGREP_CPP([Lucky GNU user], + [ +#include +#ifdef __GNU_LIBRARY__ + #if (__GLIBC__ >= 2) + Lucky GNU user + #endif +#endif + ], + ac_cv_gnu_library_2=yes, + ac_cv_gnu_library_2=no) + ] + ) + AC_SUBST(GLIBC2) + GLIBC2="$ac_cv_gnu_library_2" + ] +) diff --git a/m4/glibc21.m4 b/m4/glibc21.m4 new file mode 100644 index 0000000..d95fd98 --- /dev/null +++ b/m4/glibc21.m4 @@ -0,0 +1,30 @@ +# glibc21.m4 serial 3 +dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# Test for the GNU C Library, version 2.1 or newer. +# From Bruno Haible. + +AC_DEFUN([gl_GLIBC21], + [ + AC_CACHE_CHECK(whether we are using the GNU C Library 2.1 or newer, + ac_cv_gnu_library_2_1, + [AC_EGREP_CPP([Lucky GNU user], + [ +#include +#ifdef __GNU_LIBRARY__ + #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) + Lucky GNU user + #endif +#endif + ], + ac_cv_gnu_library_2_1=yes, + ac_cv_gnu_library_2_1=no) + ] + ) + AC_SUBST(GLIBC21) + GLIBC21="$ac_cv_gnu_library_2_1" + ] +) diff --git a/m4/iconv.m4 b/m4/iconv.m4 new file mode 100644 index 0000000..e2041b9 --- /dev/null +++ b/m4/iconv.m4 @@ -0,0 +1,214 @@ +# iconv.m4 serial 11 (gettext-0.18.1) +dnl Copyright (C) 2000-2002, 2007-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], +[ + dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([iconv]) +]) + +AC_DEFUN([AM_ICONV_LINK], +[ + dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and + dnl those with the standalone portable GNU libiconv installed). + AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles + + dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV + dnl accordingly. + AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) + + dnl Add $INCICONV to CPPFLAGS before performing the following checks, + dnl because if the user has installed libiconv and not disabled its use + dnl via --without-libiconv-prefix, he wants to use it. The first + dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. + am_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) + + AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [ + am_cv_func_iconv="no, consider installing GNU libiconv" + am_cv_lib_iconv=no + AC_TRY_LINK([#include +#include ], + [iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);], + [am_cv_func_iconv=yes]) + if test "$am_cv_func_iconv" != yes; then + am_save_LIBS="$LIBS" + LIBS="$LIBS $LIBICONV" + AC_TRY_LINK([#include +#include ], + [iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);], + [am_cv_lib_iconv=yes] + [am_cv_func_iconv=yes]) + LIBS="$am_save_LIBS" + fi + ]) + if test "$am_cv_func_iconv" = yes; then + AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ + dnl This tests against bugs in AIX 5.1, HP-UX 11.11, Solaris 10. + am_save_LIBS="$LIBS" + if test $am_cv_lib_iconv = yes; then + LIBS="$LIBS $LIBICONV" + fi + AC_TRY_RUN([ +#include +#include +int main () +{ + /* Test against AIX 5.1 bug: Failures are not distinguishable from successful + returns. */ + { + iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); + if (cd_utf8_to_88591 != (iconv_t)(-1)) + { + static const char input[] = "\342\202\254"; /* EURO SIGN */ + char buf[10]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_utf8_to_88591, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + return 1; + } + } + /* Test against Solaris 10 bug: Failures are not distinguishable from + successful returns. */ + { + iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); + if (cd_ascii_to_88591 != (iconv_t)(-1)) + { + static const char input[] = "\263"; + char buf[10]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_ascii_to_88591, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if (res == 0) + return 1; + } + } +#if 0 /* This bug could be worked around by the caller. */ + /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ + { + iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); + if (cd_88591_to_utf8 != (iconv_t)(-1)) + { + static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; + char buf[50]; + const char *inptr = input; + size_t inbytesleft = strlen (input); + char *outptr = buf; + size_t outbytesleft = sizeof (buf); + size_t res = iconv (cd_88591_to_utf8, + (char **) &inptr, &inbytesleft, + &outptr, &outbytesleft); + if ((int)res > 0) + return 1; + } + } +#endif + /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is + provided. */ + if (/* Try standardized names. */ + iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) + /* Try IRIX, OSF/1 names. */ + && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) + /* Try AIX names. */ + && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) + /* Try HP-UX names. */ + && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) + return 1; + return 0; +}], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no], + [case "$host_os" in + aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; + *) am_cv_func_iconv_works="guessing yes" ;; + esac]) + LIBS="$am_save_LIBS" + ]) + case "$am_cv_func_iconv_works" in + *no) am_func_iconv=no am_cv_lib_iconv=no ;; + *) am_func_iconv=yes ;; + esac + else + am_func_iconv=no am_cv_lib_iconv=no + fi + if test "$am_func_iconv" = yes; then + AC_DEFINE([HAVE_ICONV], [1], + [Define if you have the iconv() function and it works.]) + fi + if test "$am_cv_lib_iconv" = yes; then + AC_MSG_CHECKING([how to link with libiconv]) + AC_MSG_RESULT([$LIBICONV]) + else + dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV + dnl either. + CPPFLAGS="$am_save_CPPFLAGS" + LIBICONV= + LTLIBICONV= + fi + AC_SUBST([LIBICONV]) + AC_SUBST([LTLIBICONV]) +]) + +dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to +dnl avoid warnings like +dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". +dnl This is tricky because of the way 'aclocal' is implemented: +dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. +dnl Otherwise aclocal's initial scan pass would miss the macro definition. +dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. +dnl Otherwise aclocal would emit many "Use of uninitialized value $1" +dnl warnings. +m4_define([gl_iconv_AC_DEFUN], + m4_version_prereq([2.64], + [[AC_DEFUN_ONCE( + [$1], [$2])]], + [[AC_DEFUN( + [$1], [$2])]])) +gl_iconv_AC_DEFUN([AM_ICONV], +[ + AM_ICONV_LINK + if test "$am_cv_func_iconv" = yes; then + AC_MSG_CHECKING([for iconv declaration]) + AC_CACHE_VAL([am_cv_proto_iconv], [ + AC_TRY_COMPILE([ +#include +#include +extern +#ifdef __cplusplus +"C" +#endif +#if defined(__STDC__) || defined(__cplusplus) +size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); +#else +size_t iconv(); +#endif +], [], [am_cv_proto_iconv_arg1=""], [am_cv_proto_iconv_arg1="const"]) + am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) + am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` + AC_MSG_RESULT([ + $am_cv_proto_iconv]) + AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], + [Define as const if the declaration of iconv() needs const.]) + fi +]) diff --git a/m4/intdiv0.m4 b/m4/intdiv0.m4 new file mode 100644 index 0000000..b8d7817 --- /dev/null +++ b/m4/intdiv0.m4 @@ -0,0 +1,70 @@ +# intdiv0.m4 serial 1 (gettext-0.11.3) +dnl Copyright (C) 2002 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([gt_INTDIV0], +[ + AC_REQUIRE([AC_PROG_CC])dnl + AC_REQUIRE([AC_CANONICAL_HOST])dnl + + AC_CACHE_CHECK([whether integer division by zero raises SIGFPE], + gt_cv_int_divbyzero_sigfpe, + [ + AC_TRY_RUN([ +#include +#include + +static void +#ifdef __cplusplus +sigfpe_handler (int sig) +#else +sigfpe_handler (sig) int sig; +#endif +{ + /* Exit with code 0 if SIGFPE, with code 1 if any other signal. */ + exit (sig != SIGFPE); +} + +int x = 1; +int y = 0; +int z; +int nan; + +int main () +{ + signal (SIGFPE, sigfpe_handler); +/* IRIX and AIX (when "xlc -qcheck" is used) yield signal SIGTRAP. */ +#if (defined (__sgi) || defined (_AIX)) && defined (SIGTRAP) + signal (SIGTRAP, sigfpe_handler); +#endif +/* Linux/SPARC yields signal SIGILL. */ +#if defined (__sparc__) && defined (__linux__) + signal (SIGILL, sigfpe_handler); +#endif + + z = x / y; + nan = y / y; + exit (1); +} +], gt_cv_int_divbyzero_sigfpe=yes, gt_cv_int_divbyzero_sigfpe=no, + [ + # Guess based on the CPU. + case "$host_cpu" in + alpha* | i[34567]86 | m68k | s390*) + gt_cv_int_divbyzero_sigfpe="guessing yes";; + *) + gt_cv_int_divbyzero_sigfpe="guessing no";; + esac + ]) + ]) + case "$gt_cv_int_divbyzero_sigfpe" in + *yes) value=1;; + *) value=0;; + esac + AC_DEFINE_UNQUOTED(INTDIV0_RAISES_SIGFPE, $value, + [Define if integer division by zero raises signal SIGFPE.]) +]) diff --git a/m4/intl.m4 b/m4/intl.m4 new file mode 100644 index 0000000..dcefb11 --- /dev/null +++ b/m4/intl.m4 @@ -0,0 +1,259 @@ +# intl.m4 serial 3 (gettext-0.16) +dnl Copyright (C) 1995-2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2006. + +AC_PREREQ(2.52) + +dnl Checks for all prerequisites of the intl subdirectory, +dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS, +dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL. +AC_DEFUN([AM_INTL_SUBDIR], +[ + AC_REQUIRE([AC_PROG_INSTALL])dnl + AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake + AC_REQUIRE([AC_PROG_CC])dnl + AC_REQUIRE([AC_CANONICAL_HOST])dnl + AC_REQUIRE([gt_GLIBC2])dnl + AC_REQUIRE([AC_PROG_RANLIB])dnl + AC_REQUIRE([gl_VISIBILITY])dnl + AC_REQUIRE([gt_INTL_SUBDIR_CORE])dnl + AC_REQUIRE([AC_TYPE_LONG_LONG_INT])dnl + AC_REQUIRE([gt_TYPE_LONGDOUBLE])dnl + AC_REQUIRE([gt_TYPE_WCHAR_T])dnl + AC_REQUIRE([gt_TYPE_WINT_T])dnl + AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([gt_TYPE_INTMAX_T]) + AC_REQUIRE([gt_PRINTF_POSIX]) + AC_REQUIRE([gl_GLIBC21])dnl + AC_REQUIRE([gl_XSIZE])dnl + AC_REQUIRE([gt_INTL_MACOSX])dnl + + AC_CHECK_TYPE([ptrdiff_t], , + [AC_DEFINE([ptrdiff_t], [long], + [Define as the type of the result of subtracting two pointers, if the system doesn't define it.]) + ]) + AC_CHECK_HEADERS([stddef.h stdlib.h string.h]) + AC_CHECK_FUNCS([asprintf fwprintf putenv setenv setlocale snprintf wcslen]) + + dnl Use the _snprintf function only if it is declared (because on NetBSD it + dnl is defined as a weak alias of snprintf; we prefer to use the latter). + gt_CHECK_DECL(_snprintf, [#include ]) + gt_CHECK_DECL(_snwprintf, [#include ]) + + dnl Use the *_unlocked functions only if they are declared. + dnl (because some of them were defined without being declared in Solaris + dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built + dnl on Solaris 2.5.1 to run on Solaris 2.6). + dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. + gt_CHECK_DECL(getc_unlocked, [#include ]) + + case $gt_cv_func_printf_posix in + *yes) HAVE_POSIX_PRINTF=1 ;; + *) HAVE_POSIX_PRINTF=0 ;; + esac + AC_SUBST([HAVE_POSIX_PRINTF]) + if test "$ac_cv_func_asprintf" = yes; then + HAVE_ASPRINTF=1 + else + HAVE_ASPRINTF=0 + fi + AC_SUBST([HAVE_ASPRINTF]) + if test "$ac_cv_func_snprintf" = yes; then + HAVE_SNPRINTF=1 + else + HAVE_SNPRINTF=0 + fi + AC_SUBST([HAVE_SNPRINTF]) + if test "$ac_cv_func_wprintf" = yes; then + HAVE_WPRINTF=1 + else + HAVE_WPRINTF=0 + fi + AC_SUBST([HAVE_WPRINTF]) + + AM_LANGINFO_CODESET + gt_LC_MESSAGES + + dnl Compilation on mingw and Cygwin needs special Makefile rules, because + dnl 1. when we install a shared library, we must arrange to export + dnl auxiliary pointer variables for every exported variable, + dnl 2. when we install a shared library and a static library simultaneously, + dnl the include file specifies __declspec(dllimport) and therefore we + dnl must arrange to define the auxiliary pointer variables for the + dnl exported variables _also_ in the static library. + if test "$enable_shared" = yes; then + case "$host_os" in + cygwin*) is_woe32dll=yes ;; + *) is_woe32dll=no ;; + esac + else + is_woe32dll=no + fi + WOE32DLL=$is_woe32dll + AC_SUBST([WOE32DLL]) + + dnl Rename some macros and functions used for locking. + AH_BOTTOM([ +#define __libc_lock_t gl_lock_t +#define __libc_lock_define gl_lock_define +#define __libc_lock_define_initialized gl_lock_define_initialized +#define __libc_lock_init gl_lock_init +#define __libc_lock_lock gl_lock_lock +#define __libc_lock_unlock gl_lock_unlock +#define __libc_lock_recursive_t gl_recursive_lock_t +#define __libc_lock_define_recursive gl_recursive_lock_define +#define __libc_lock_define_initialized_recursive gl_recursive_lock_define_initialized +#define __libc_lock_init_recursive gl_recursive_lock_init +#define __libc_lock_lock_recursive gl_recursive_lock_lock +#define __libc_lock_unlock_recursive gl_recursive_lock_unlock +#define glthread_in_use libintl_thread_in_use +#define glthread_lock_init libintl_lock_init +#define glthread_lock_lock libintl_lock_lock +#define glthread_lock_unlock libintl_lock_unlock +#define glthread_lock_destroy libintl_lock_destroy +#define glthread_rwlock_init libintl_rwlock_init +#define glthread_rwlock_rdlock libintl_rwlock_rdlock +#define glthread_rwlock_wrlock libintl_rwlock_wrlock +#define glthread_rwlock_unlock libintl_rwlock_unlock +#define glthread_rwlock_destroy libintl_rwlock_destroy +#define glthread_recursive_lock_init libintl_recursive_lock_init +#define glthread_recursive_lock_lock libintl_recursive_lock_lock +#define glthread_recursive_lock_unlock libintl_recursive_lock_unlock +#define glthread_recursive_lock_destroy libintl_recursive_lock_destroy +#define glthread_once libintl_once +#define glthread_once_call libintl_once_call +#define glthread_once_singlethreaded libintl_once_singlethreaded +]) +]) + + +dnl Checks for the core files of the intl subdirectory: +dnl dcigettext.c +dnl eval-plural.h +dnl explodename.c +dnl finddomain.c +dnl gettextP.h +dnl gmo.h +dnl hash-string.h hash-string.c +dnl l10nflist.c +dnl libgnuintl.h.in (except the *printf stuff) +dnl loadinfo.h +dnl loadmsgcat.c +dnl localealias.c +dnl log.c +dnl plural-exp.h plural-exp.c +dnl plural.y +dnl Used by libglocale. +AC_DEFUN([gt_INTL_SUBDIR_CORE], +[ + AC_REQUIRE([AC_C_INLINE])dnl + AC_REQUIRE([AC_TYPE_SIZE_T])dnl + AC_REQUIRE([gl_AC_HEADER_STDINT_H]) + AC_REQUIRE([AC_FUNC_ALLOCA])dnl + AC_REQUIRE([AC_FUNC_MMAP])dnl + AC_REQUIRE([gt_INTDIV0])dnl + AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])dnl + AC_REQUIRE([gt_INTTYPES_PRI])dnl + AC_REQUIRE([gl_LOCK])dnl + + AC_TRY_LINK( + [int foo (int a) { a = __builtin_expect (a, 10); return a == 10 ? 0 : 1; }], + [], + [AC_DEFINE([HAVE_BUILTIN_EXPECT], 1, + [Define to 1 if the compiler understands __builtin_expect.])]) + + AC_CHECK_HEADERS([argz.h inttypes.h limits.h unistd.h sys/param.h]) + AC_CHECK_FUNCS([getcwd getegid geteuid getgid getuid mempcpy munmap \ + stpcpy strcasecmp strdup strtoul tsearch argz_count argz_stringify \ + argz_next __fsetlocking]) + + dnl Use the *_unlocked functions only if they are declared. + dnl (because some of them were defined without being declared in Solaris + dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built + dnl on Solaris 2.5.1 to run on Solaris 2.6). + dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13. + gt_CHECK_DECL(feof_unlocked, [#include ]) + gt_CHECK_DECL(fgets_unlocked, [#include ]) + + AM_ICONV + + dnl glibc >= 2.4 has a NL_LOCALE_NAME macro when _GNU_SOURCE is defined, + dnl and a _NL_LOCALE_NAME macro always. + AC_CACHE_CHECK([for NL_LOCALE_NAME macro], gt_cv_nl_locale_name, + [AC_TRY_LINK([#include +#include ], + [char* cs = nl_langinfo(_NL_LOCALE_NAME(LC_MESSAGES));], + gt_cv_nl_locale_name=yes, + gt_cv_nl_locale_name=no) + ]) + if test $gt_cv_nl_locale_name = yes; then + AC_DEFINE(HAVE_NL_LOCALE_NAME, 1, + [Define if you have and it defines the NL_LOCALE_NAME macro if _GNU_SOURCE is defined.]) + fi + + dnl intl/plural.c is generated from intl/plural.y. It requires bison, + dnl because plural.y uses bison specific features. It requires at least + dnl bison-1.26 because earlier versions generate a plural.c that doesn't + dnl compile. + dnl bison is only needed for the maintainer (who touches plural.y). But in + dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put + dnl the rule in general Makefile. Now, some people carelessly touch the + dnl files or have a broken "make" program, hence the plural.c rule will + dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not + dnl present or too old. + AC_CHECK_PROGS([INTLBISON], [bison]) + if test -z "$INTLBISON"; then + ac_verc_fail=yes + else + dnl Found it, now check the version. + AC_MSG_CHECKING([version of bison]) +changequote(<<,>>)dnl + ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'` + case $ac_prog_version in + '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; + 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*) +changequote([,])dnl + ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; + *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; + esac + AC_MSG_RESULT([$ac_prog_version]) + fi + if test $ac_verc_fail = yes; then + INTLBISON=: + fi +]) + + +dnl gt_CHECK_DECL(FUNC, INCLUDES) +dnl Check whether a function is declared. +AC_DEFUN([gt_CHECK_DECL], +[ + AC_CACHE_CHECK([whether $1 is declared], ac_cv_have_decl_$1, + [AC_TRY_COMPILE([$2], [ +#ifndef $1 + char *p = (char *) $1; +#endif +], ac_cv_have_decl_$1=yes, ac_cv_have_decl_$1=no)]) + if test $ac_cv_have_decl_$1 = yes; then + gt_value=1 + else + gt_value=0 + fi + AC_DEFINE_UNQUOTED([HAVE_DECL_]translit($1, [a-z], [A-Z]), [$gt_value], + [Define to 1 if you have the declaration of `$1', and to 0 if you don't.]) +]) diff --git a/m4/intldir.m4 b/m4/intldir.m4 new file mode 100644 index 0000000..7a28843 --- /dev/null +++ b/m4/intldir.m4 @@ -0,0 +1,19 @@ +# intldir.m4 serial 1 (gettext-0.16) +dnl Copyright (C) 2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +AC_PREREQ(2.52) + +dnl Tells the AM_GNU_GETTEXT macro to consider an intl/ directory. +AC_DEFUN([AM_GNU_GETTEXT_INTL_SUBDIR], []) diff --git a/m4/intlmacosx.m4 b/m4/intlmacosx.m4 new file mode 100644 index 0000000..d3f0d90 --- /dev/null +++ b/m4/intlmacosx.m4 @@ -0,0 +1,51 @@ +# intlmacosx.m4 serial 1 (gettext-0.17) +dnl Copyright (C) 2004-2007 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Checks for special options needed on MacOS X. +dnl Defines INTL_MACOSX_LIBS. +AC_DEFUN([gt_INTL_MACOSX], +[ + dnl Check for API introduced in MacOS X 10.2. + AC_CACHE_CHECK([for CFPreferencesCopyAppValue], + gt_cv_func_CFPreferencesCopyAppValue, + [gt_save_LIBS="$LIBS" + LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" + AC_TRY_LINK([#include ], + [CFPreferencesCopyAppValue(NULL, NULL)], + [gt_cv_func_CFPreferencesCopyAppValue=yes], + [gt_cv_func_CFPreferencesCopyAppValue=no]) + LIBS="$gt_save_LIBS"]) + if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then + AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], 1, + [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.]) + fi + dnl Check for API introduced in MacOS X 10.3. + AC_CACHE_CHECK([for CFLocaleCopyCurrent], gt_cv_func_CFLocaleCopyCurrent, + [gt_save_LIBS="$LIBS" + LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation" + AC_TRY_LINK([#include ], [CFLocaleCopyCurrent();], + [gt_cv_func_CFLocaleCopyCurrent=yes], + [gt_cv_func_CFLocaleCopyCurrent=no]) + LIBS="$gt_save_LIBS"]) + if test $gt_cv_func_CFLocaleCopyCurrent = yes; then + AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], 1, + [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.]) + fi + INTL_MACOSX_LIBS= + if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then + INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation" + fi + AC_SUBST([INTL_MACOSX_LIBS]) +]) diff --git a/m4/intmax.m4 b/m4/intmax.m4 new file mode 100644 index 0000000..ce7a8a4 --- /dev/null +++ b/m4/intmax.m4 @@ -0,0 +1,33 @@ +# intmax.m4 serial 3 (gettext-0.16) +dnl Copyright (C) 2002-2005 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Test whether the system has the 'intmax_t' type, but don't attempt to +dnl find a replacement if it is lacking. + +AC_DEFUN([gt_TYPE_INTMAX_T], +[ + AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([gl_AC_HEADER_STDINT_H]) + AC_CACHE_CHECK(for intmax_t, gt_cv_c_intmax_t, + [AC_TRY_COMPILE([ +#include +#include +#if HAVE_STDINT_H_WITH_UINTMAX +#include +#endif +#if HAVE_INTTYPES_H_WITH_UINTMAX +#include +#endif +], [intmax_t x = -1; + return !x;], + gt_cv_c_intmax_t=yes, + gt_cv_c_intmax_t=no)]) + if test $gt_cv_c_intmax_t = yes; then + AC_DEFINE(HAVE_INTMAX_T, 1, + [Define if you have the 'intmax_t' type in or .]) + fi +]) diff --git a/m4/intmax_t.m4 b/m4/intmax_t.m4 new file mode 100644 index 0000000..b9cb27f --- /dev/null +++ b/m4/intmax_t.m4 @@ -0,0 +1,40 @@ +#serial 6 + +dnl From Paul Eggert. + +AC_PREREQ(2.52) + +# Define intmax_t to long or long long if doesn't define. + +AC_DEFUN([gl_AC_TYPE_INTMAX_T], +[ + dnl For simplicity, we assume that a header file defines 'intmax_t' if and + dnl only if it defines 'uintmax_t'. + AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([gl_AC_HEADER_STDINT_H]) + if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then + AC_REQUIRE([gl_AC_TYPE_LONG_LONG]) + test $ac_cv_type_long_long = yes \ + && ac_type='long long' \ + || ac_type='long' + AC_DEFINE_UNQUOTED(intmax_t, $ac_type, + [Define to long or long long if and don't define.]) + else + AC_DEFINE(HAVE_INTMAX_T, 1, + [Define if you have the 'intmax_t' type in or .]) + fi +]) + +# Define uintmax_t to unsigned long or unsigned long long +# if doesn't define. + +AC_DEFUN([jm_AC_TYPE_UINTMAX_T], +[ + AC_REQUIRE([jm_AC_TYPE_UNSIGNED_LONG_LONG]) + AC_CHECK_TYPE(uintmax_t, , + [test $ac_cv_type_unsigned_long_long = yes \ + && ac_type='unsigned long long' \ + || ac_type='unsigned long' + AC_DEFINE_UNQUOTED(uintmax_t, $ac_type, + [Define to widest unsigned type if doesn't define.])]) +]) diff --git a/m4/inttypes-pri.m4 b/m4/inttypes-pri.m4 new file mode 100644 index 0000000..7c7f894 --- /dev/null +++ b/m4/inttypes-pri.m4 @@ -0,0 +1,36 @@ +# inttypes-pri.m4 serial 4 (gettext-0.16) +dnl Copyright (C) 1997-2002, 2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_PREREQ(2.52) + +# Define PRI_MACROS_BROKEN if exists and defines the PRI* +# macros to non-string values. This is the case on AIX 4.3.3. + +AC_DEFUN([gt_INTTYPES_PRI], +[ + AC_CHECK_HEADERS([inttypes.h]) + if test $ac_cv_header_inttypes_h = yes; then + AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken], + gt_cv_inttypes_pri_broken, + [ + AC_TRY_COMPILE([#include +#ifdef PRId32 +char *p = PRId32; +#endif +], [], gt_cv_inttypes_pri_broken=no, gt_cv_inttypes_pri_broken=yes) + ]) + fi + if test "$gt_cv_inttypes_pri_broken" = yes; then + AC_DEFINE_UNQUOTED(PRI_MACROS_BROKEN, 1, + [Define if exists and defines unusable PRI* macros.]) + PRI_MACROS_BROKEN=1 + else + PRI_MACROS_BROKEN=0 + fi + AC_SUBST([PRI_MACROS_BROKEN]) +]) diff --git a/m4/inttypes.m4 b/m4/inttypes.m4 new file mode 100644 index 0000000..5067702 --- /dev/null +++ b/m4/inttypes.m4 @@ -0,0 +1,30 @@ +# inttypes.m4 serial 1 (gettext-0.11.4) +dnl Copyright (C) 1997-2002 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert. + +# Define HAVE_INTTYPES_H if exists and doesn't clash with +# . + +AC_DEFUN([gt_HEADER_INTTYPES_H], +[ + if test "OS/390" = "`uname`" + then + gt_cv_header_inttypes_h=no + else + AC_CACHE_CHECK([for inttypes.h], gt_cv_header_inttypes_h, + [ + AC_TRY_COMPILE( + [#include +#include ], + [], gt_cv_header_inttypes_h=yes, gt_cv_header_inttypes_h=no) + ]) + if test $gt_cv_header_inttypes_h = yes; then + AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H, 1, + [Define if exists and doesn't clash with .]) + fi + fi +]) diff --git a/m4/inttypes_h.m4 b/m4/inttypes_h.m4 new file mode 100644 index 0000000..7617188 --- /dev/null +++ b/m4/inttypes_h.m4 @@ -0,0 +1,31 @@ +# inttypes_h.m4 serial 7 +dnl Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert. + +# Define HAVE_INTTYPES_H_WITH_UINTMAX if exists, +# doesn't clash with , and declares uintmax_t. + +AC_DEFUN([gl_AC_HEADER_INTTYPES_H], +[ + if test "OS/390" = "`uname`" + then + gl_cv_header_inttypes_h=no + else + AC_CACHE_CHECK([for inttypes.h], gl_cv_header_inttypes_h, + [AC_TRY_COMPILE( + [#include +#include ], + [uintmax_t i = (uintmax_t) -1; return !i;], + gl_cv_header_inttypes_h=yes, + gl_cv_header_inttypes_h=no)]) + if test $gl_cv_header_inttypes_h = yes; then + AC_DEFINE_UNQUOTED(HAVE_INTTYPES_H_WITH_UINTMAX, 1, + [Define if exists, doesn't clash with , + and declares uintmax_t. ]) + fi + fi +]) diff --git a/m4/isc-posix.m4 b/m4/isc-posix.m4 new file mode 100644 index 0000000..74dc8f2 --- /dev/null +++ b/m4/isc-posix.m4 @@ -0,0 +1,24 @@ +# isc-posix.m4 serial 2 (gettext-0.11.2) +dnl Copyright (C) 1995-2002 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +# This file is not needed with autoconf-2.53 and newer. Remove it in 2005. + +# This test replaces the one in autoconf. +# Currently this macro should have the same name as the autoconf macro +# because gettext's gettext.m4 (distributed in the automake package) +# still uses it. Otherwise, the use in gettext.m4 makes autoheader +# give these diagnostics: +# configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX +# configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX + +undefine([AC_ISC_POSIX]) + +AC_DEFUN([AC_ISC_POSIX], + [ + dnl This test replaces the obsolescent AC_ISC_POSIX kludge. + AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"]) + ] +) diff --git a/m4/lcmessage.m4 b/m4/lcmessage.m4 new file mode 100644 index 0000000..19aa77e --- /dev/null +++ b/m4/lcmessage.m4 @@ -0,0 +1,30 @@ +# lcmessage.m4 serial 4 (gettext-0.14.2) +dnl Copyright (C) 1995-2002, 2004-2005 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995. + +# Check whether LC_MESSAGES is available in . + +AC_DEFUN([gt_LC_MESSAGES], +[ + AC_CACHE_CHECK([for LC_MESSAGES], gt_cv_val_LC_MESSAGES, + [AC_TRY_LINK([#include ], [return LC_MESSAGES], + gt_cv_val_LC_MESSAGES=yes, gt_cv_val_LC_MESSAGES=no)]) + if test $gt_cv_val_LC_MESSAGES = yes; then + AC_DEFINE(HAVE_LC_MESSAGES, 1, + [Define if your file defines LC_MESSAGES.]) + fi +]) diff --git a/m4/lib-ld.m4 b/m4/lib-ld.m4 new file mode 100644 index 0000000..ebb3052 --- /dev/null +++ b/m4/lib-ld.m4 @@ -0,0 +1,110 @@ +# lib-ld.m4 serial 4 (gettext-0.18) +dnl Copyright (C) 1996-2003, 2009-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Subroutines of libtool.m4, +dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision +dnl with libtool.m4. + +dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. +AC_DEFUN([AC_LIB_PROG_LD_GNU], +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld], +[# I'd rather use --version here, but apparently some GNU ld's only accept -v. +case `$LD -v 2>&1 conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by GCC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]* | [A-Za-z]:[\\/]*)] + [re_direlt='/[^/][^/]*/\.\./'] + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL([acl_cv_path_LD], +[if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + acl_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in + *GNU* | *'with BFD'*) + test "$with_gnu_ld" != no && break ;; + *) + test "$with_gnu_ld" != yes && break ;; + esac + fi + done + IFS="$ac_save_ifs" +else + acl_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$acl_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT([$LD]) +else + AC_MSG_RESULT([no]) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_LIB_PROG_LD_GNU +]) diff --git a/m4/lib-link.m4 b/m4/lib-link.m4 new file mode 100644 index 0000000..c73bd8e --- /dev/null +++ b/m4/lib-link.m4 @@ -0,0 +1,774 @@ +# lib-link.m4 serial 21 (gettext-0.18) +dnl Copyright (C) 2001-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_PREREQ([2.54]) + +dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and +dnl augments the CPPFLAGS variable. +dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname +dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. +AC_DEFUN([AC_LIB_LINKFLAGS], +[ + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + pushdef([Name],[translit([$1],[./-], [___])]) + pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ + AC_LIB_LINKFLAGS_BODY([$1], [$2]) + ac_cv_lib[]Name[]_libs="$LIB[]NAME" + ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" + ac_cv_lib[]Name[]_cppflags="$INC[]NAME" + ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX" + ]) + LIB[]NAME="$ac_cv_lib[]Name[]_libs" + LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" + INC[]NAME="$ac_cv_lib[]Name[]_cppflags" + LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) + AC_SUBST([LIB]NAME) + AC_SUBST([LTLIB]NAME) + AC_SUBST([LIB]NAME[_PREFIX]) + dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the + dnl results of this search when this library appears as a dependency. + HAVE_LIB[]NAME=yes + popdef([NAME]) + popdef([Name]) +]) + +dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message]) +dnl searches for libname and the libraries corresponding to explicit and +dnl implicit dependencies, together with the specified include files and +dnl the ability to compile and link the specified testcode. The missing-message +dnl defaults to 'no' and may contain additional hints for the user. +dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} +dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and +dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs +dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. +dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname +dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. +AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], +[ + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + AC_REQUIRE([AC_LIB_RPATH]) + pushdef([Name],[translit([$1],[./-], [___])]) + pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + + dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME + dnl accordingly. + AC_LIB_LINKFLAGS_BODY([$1], [$2]) + + dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, + dnl because if the user has installed lib[]Name and not disabled its use + dnl via --without-lib[]Name-prefix, he wants to use it. + ac_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) + + AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ + ac_save_LIBS="$LIBS" + dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS, + dnl because these -l options might require -L options that are present in + dnl LIBS. -l options benefit only from the -L options listed before it. + dnl Otherwise, add it to the front of LIBS, because it may be a static + dnl library that depends on another static library that is present in LIBS. + dnl Static libraries benefit only from the static libraries listed after + dnl it. + case " $LIB[]NAME" in + *" -l"*) LIBS="$LIBS $LIB[]NAME" ;; + *) LIBS="$LIB[]NAME $LIBS" ;; + esac + AC_TRY_LINK([$3], [$4], + [ac_cv_lib[]Name=yes], + [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])']) + LIBS="$ac_save_LIBS" + ]) + if test "$ac_cv_lib[]Name" = yes; then + HAVE_LIB[]NAME=yes + AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.]) + AC_MSG_CHECKING([how to link with lib[]$1]) + AC_MSG_RESULT([$LIB[]NAME]) + else + HAVE_LIB[]NAME=no + dnl If $LIB[]NAME didn't lead to a usable library, we don't need + dnl $INC[]NAME either. + CPPFLAGS="$ac_save_CPPFLAGS" + LIB[]NAME= + LTLIB[]NAME= + LIB[]NAME[]_PREFIX= + fi + AC_SUBST([HAVE_LIB]NAME) + AC_SUBST([LIB]NAME) + AC_SUBST([LTLIB]NAME) + AC_SUBST([LIB]NAME[_PREFIX]) + popdef([NAME]) + popdef([Name]) +]) + +dnl Determine the platform dependent parameters needed to use rpath: +dnl acl_libext, +dnl acl_shlibext, +dnl acl_hardcode_libdir_flag_spec, +dnl acl_hardcode_libdir_separator, +dnl acl_hardcode_direct, +dnl acl_hardcode_minus_L. +AC_DEFUN([AC_LIB_RPATH], +[ + dnl Tell automake >= 1.10 to complain if config.rpath is missing. + m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) + AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS + AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld + AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host + AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir + AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [ + CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ + ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh + . ./conftest.sh + rm -f ./conftest.sh + acl_cv_rpath=done + ]) + wl="$acl_cv_wl" + acl_libext="$acl_cv_libext" + acl_shlibext="$acl_cv_shlibext" + acl_libname_spec="$acl_cv_libname_spec" + acl_library_names_spec="$acl_cv_library_names_spec" + acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" + acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" + acl_hardcode_direct="$acl_cv_hardcode_direct" + acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" + dnl Determine whether the user wants rpath handling at all. + AC_ARG_ENABLE([rpath], + [ --disable-rpath do not hardcode runtime library paths], + :, enable_rpath=yes) +]) + +dnl AC_LIB_FROMPACKAGE(name, package) +dnl declares that libname comes from the given package. The configure file +dnl will then not have a --with-libname-prefix option but a +dnl --with-package-prefix option. Several libraries can come from the same +dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar +dnl macro call that searches for libname. +AC_DEFUN([AC_LIB_FROMPACKAGE], +[ + pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + define([acl_frompackage_]NAME, [$2]) + popdef([NAME]) + pushdef([PACK],[$2]) + pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + define([acl_libsinpackage_]PACKUP, + m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1]) + popdef([PACKUP]) + popdef([PACK]) +]) + +dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and +dnl the libraries corresponding to explicit and implicit dependencies. +dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. +dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found +dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. +AC_DEFUN([AC_LIB_LINKFLAGS_BODY], +[ + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) + pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-], + [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) + pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) + dnl Autoconf >= 2.61 supports dots in --with options. + pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_ARG_WITH(P_A_C_K[-prefix], +[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib + --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + if test "$acl_libdirstem2" != "$acl_libdirstem" \ + && ! test -d "$withval/$acl_libdirstem"; then + additional_libdir="$withval/$acl_libdirstem2" + fi + fi + fi +]) + dnl Search the library and its dependencies in $additional_libdir and + dnl $LDFLAGS. Using breadth-first-seach. + LIB[]NAME= + LTLIB[]NAME= + INC[]NAME= + LIB[]NAME[]_PREFIX= + dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been + dnl computed. So it has to be reset here. + HAVE_LIB[]NAME= + rpathdirs= + ltrpathdirs= + names_already_handled= + names_next_round='$1 $2' + while test -n "$names_next_round"; do + names_this_round="$names_next_round" + names_next_round= + for name in $names_this_round; do + already_handled= + for n in $names_already_handled; do + if test "$n" = "$name"; then + already_handled=yes + break + fi + done + if test -z "$already_handled"; then + names_already_handled="$names_already_handled $name" + dnl See if it was already located by an earlier AC_LIB_LINKFLAGS + dnl or AC_LIB_HAVE_LINKFLAGS call. + uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` + eval value=\"\$HAVE_LIB$uppername\" + if test -n "$value"; then + if test "$value" = yes; then + eval value=\"\$LIB$uppername\" + test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" + eval value=\"\$LTLIB$uppername\" + test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" + else + dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined + dnl that this library doesn't exist. So just drop it. + : + fi + else + dnl Search the library lib$name in $additional_libdir and $LDFLAGS + dnl and the already constructed $LIBNAME/$LTLIBNAME. + found_dir= + found_la= + found_so= + found_a= + eval libname=\"$acl_libname_spec\" # typically: libname=lib$name + if test -n "$acl_shlibext"; then + shrext=".$acl_shlibext" # typically: shrext=.so + else + shrext= + fi + if test $use_additional = yes; then + dir="$additional_libdir" + dnl The same code as in the loop below: + dnl First look for a shared library. + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + dnl Then look for a static library. + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + fi + if test "X$found_dir" = "X"; then + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + dnl First look for a shared library. + if test -n "$acl_shlibext"; then + if test -f "$dir/$libname$shrext"; then + found_dir="$dir" + found_so="$dir/$libname$shrext" + else + if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then + ver=`(cd "$dir" && \ + for f in "$libname$shrext".*; do echo "$f"; done \ + | sed -e "s,^$libname$shrext\\\\.,," \ + | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ + | sed 1q ) 2>/dev/null` + if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then + found_dir="$dir" + found_so="$dir/$libname$shrext.$ver" + fi + else + eval library_names=\"$acl_library_names_spec\" + for f in $library_names; do + if test -f "$dir/$f"; then + found_dir="$dir" + found_so="$dir/$f" + break + fi + done + fi + fi + fi + dnl Then look for a static library. + if test "X$found_dir" = "X"; then + if test -f "$dir/$libname.$acl_libext"; then + found_dir="$dir" + found_a="$dir/$libname.$acl_libext" + fi + fi + if test "X$found_dir" != "X"; then + if test -f "$dir/$libname.la"; then + found_la="$dir/$libname.la" + fi + fi + ;; + esac + if test "X$found_dir" != "X"; then + break + fi + done + fi + if test "X$found_dir" != "X"; then + dnl Found the library. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" + if test "X$found_so" != "X"; then + dnl Linking with a shared library. We attempt to hardcode its + dnl directory into the executable's runpath, unless it's the + dnl standard /usr/lib. + if test "$enable_rpath" = no \ + || test "X$found_dir" = "X/usr/$acl_libdirstem" \ + || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then + dnl No hardcoding is needed. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $found_dir" + fi + dnl The hardcoding into $LIBNAME is system dependent. + if test "$acl_hardcode_direct" = yes; then + dnl Using DIR/libNAME.so during linking hardcodes DIR into the + dnl resulting binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode DIR into the resulting + dnl binary. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $found_dir" + fi + else + dnl Rely on "-L$found_dir". + dnl But don't add it if it's already contained in the LDFLAGS + dnl or the already constructed $LIBNAME + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$found_dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" + fi + if test "$acl_hardcode_minus_L" != no; then + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" + else + dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH + dnl here, because this doesn't fit in flags passed to the + dnl compiler. So give up. No hardcoding. This affects only + dnl very old systems. + dnl FIXME: Not sure whether we should use + dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" + dnl here. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + fi + fi + fi + fi + else + if test "X$found_a" != "X"; then + dnl Linking with a static library. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" + else + dnl We shouldn't come here, but anyway it's good to have a + dnl fallback. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" + fi + fi + dnl Assume the include files are nearby. + additional_includedir= + case "$found_dir" in + */$acl_libdirstem | */$acl_libdirstem/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` + if test "$name" = '$1'; then + LIB[]NAME[]_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + */$acl_libdirstem2 | */$acl_libdirstem2/) + basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` + if test "$name" = '$1'; then + LIB[]NAME[]_PREFIX="$basedir" + fi + additional_includedir="$basedir/include" + ;; + esac + if test "X$additional_includedir" != "X"; then + dnl Potentially add $additional_includedir to $INCNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's /usr/local/include and we are using GCC on Linux, + dnl 3. if it's already present in $CPPFLAGS or the already + dnl constructed $INCNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + for x in $CPPFLAGS $INC[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $INCNAME. + INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" + fi + fi + fi + fi + fi + dnl Look for dependencies. + if test -n "$found_la"; then + dnl Read the .la file. It defines the variables + dnl dlname, library_names, old_library, dependency_libs, current, + dnl age, revision, installed, dlopen, dlpreopen, libdir. + save_libdir="$libdir" + case "$found_la" in + */* | *\\*) . "$found_la" ;; + *) . "./$found_la" ;; + esac + libdir="$save_libdir" + dnl We use only dependency_libs. + for dep in $dependency_libs; do + case "$dep" in + -L*) + additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` + dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's /usr/local/lib and we are using GCC on Linux, + dnl 3. if it's already present in $LDFLAGS or the already + dnl constructed $LIBNAME, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ + && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then + haveit= + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ + || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + haveit= + for x in $LDFLAGS $LIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LIBNAME. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" + fi + fi + haveit= + for x in $LDFLAGS $LTLIB[]NAME; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LTLIBNAME. + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" + fi + fi + fi + fi + ;; + -R*) + dir=`echo "X$dep" | sed -e 's/^X-R//'` + if test "$enable_rpath" != no; then + dnl Potentially add DIR to rpathdirs. + dnl The rpathdirs will be appended to $LIBNAME at the end. + haveit= + for x in $rpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + rpathdirs="$rpathdirs $dir" + fi + dnl Potentially add DIR to ltrpathdirs. + dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. + haveit= + for x in $ltrpathdirs; do + if test "X$x" = "X$dir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + ltrpathdirs="$ltrpathdirs $dir" + fi + fi + ;; + -l*) + dnl Handle this in the next round. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` + ;; + *.la) + dnl Handle this in the next round. Throw away the .la's + dnl directory; it is already contained in a preceding -L + dnl option. + names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` + ;; + *) + dnl Most likely an immediate library name. + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" + ;; + esac + done + fi + else + dnl Didn't find the library; assume it is in the system directories + dnl known to the linker and runtime loader. (All the system + dnl directories known to the linker should also be known to the + dnl runtime loader, otherwise the system is severely misconfigured.) + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" + fi + fi + fi + done + done + if test "X$rpathdirs" != "X"; then + if test -n "$acl_hardcode_libdir_separator"; then + dnl Weird platform: only the last -rpath option counts, the user must + dnl pass all path elements in one option. We can arrange that for a + dnl single library, but not when more than one $LIBNAMEs are used. + alldirs= + for found_dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" + done + dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + else + dnl The -rpath options are cumulative. + for found_dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$found_dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" + done + fi + fi + if test "X$ltrpathdirs" != "X"; then + dnl When using libtool, the option that works for both libraries and + dnl executables is -R. The -R options are cumulative. + for found_dir in $ltrpathdirs; do + LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" + done + fi + popdef([P_A_C_K]) + popdef([PACKLIBS]) + popdef([PACKUP]) + popdef([PACK]) + popdef([NAME]) +]) + +dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, +dnl unless already present in VAR. +dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes +dnl contains two or three consecutive elements that belong together. +AC_DEFUN([AC_LIB_APPENDTOVAR], +[ + for element in [$2]; do + haveit= + for x in $[$1]; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X$element"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + [$1]="${[$1]}${[$1]:+ }$element" + fi + done +]) + +dnl For those cases where a variable contains several -L and -l options +dnl referring to unknown libraries and directories, this macro determines the +dnl necessary additional linker options for the runtime path. +dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) +dnl sets LDADDVAR to linker options needed together with LIBSVALUE. +dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, +dnl otherwise linking without libtool is assumed. +AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], +[ + AC_REQUIRE([AC_LIB_RPATH]) + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + $1= + if test "$enable_rpath" != no; then + if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then + dnl Use an explicit option to hardcode directories into the resulting + dnl binary. + rpathdirs= + next= + for opt in $2; do + if test -n "$next"; then + dir="$next" + dnl No need to hardcode the standard /usr/lib. + if test "X$dir" != "X/usr/$acl_libdirstem" \ + && test "X$dir" != "X/usr/$acl_libdirstem2"; then + rpathdirs="$rpathdirs $dir" + fi + next= + else + case $opt in + -L) next=yes ;; + -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` + dnl No need to hardcode the standard /usr/lib. + if test "X$dir" != "X/usr/$acl_libdirstem" \ + && test "X$dir" != "X/usr/$acl_libdirstem2"; then + rpathdirs="$rpathdirs $dir" + fi + next= ;; + *) next= ;; + esac + fi + done + if test "X$rpathdirs" != "X"; then + if test -n ""$3""; then + dnl libtool is used for linking. Use -R options. + for dir in $rpathdirs; do + $1="${$1}${$1:+ }-R$dir" + done + else + dnl The linker is used for linking directly. + if test -n "$acl_hardcode_libdir_separator"; then + dnl Weird platform: only the last -rpath option counts, the user + dnl must pass all path elements in one option. + alldirs= + for dir in $rpathdirs; do + alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" + done + acl_save_libdir="$libdir" + libdir="$alldirs" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + $1="$flag" + else + dnl The -rpath options are cumulative. + for dir in $rpathdirs; do + acl_save_libdir="$libdir" + libdir="$dir" + eval flag=\"$acl_hardcode_libdir_flag_spec\" + libdir="$acl_save_libdir" + $1="${$1}${$1:+ }$flag" + done + fi + fi + fi + fi + fi + AC_SUBST([$1]) +]) diff --git a/m4/lib-prefix.m4 b/m4/lib-prefix.m4 new file mode 100644 index 0000000..1601cea --- /dev/null +++ b/m4/lib-prefix.m4 @@ -0,0 +1,224 @@ +# lib-prefix.m4 serial 7 (gettext-0.18) +dnl Copyright (C) 2001-2005, 2008-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and +dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't +dnl require excessive bracketing. +ifdef([AC_HELP_STRING], +[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], +[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) + +dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed +dnl to access previously installed libraries. The basic assumption is that +dnl a user will want packages to use other packages he previously installed +dnl with the same --prefix option. +dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate +dnl libraries, but is otherwise very convenient. +AC_DEFUN([AC_LIB_PREFIX], +[ + AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) + AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) + dnl By default, look in $includedir and $libdir. + use_additional=yes + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + AC_LIB_ARG_WITH([lib-prefix], +[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib + --without-lib-prefix don't search for libraries in includedir and libdir], +[ + if test "X$withval" = "Xno"; then + use_additional=no + else + if test "X$withval" = "X"; then + AC_LIB_WITH_FINAL_PREFIX([ + eval additional_includedir=\"$includedir\" + eval additional_libdir=\"$libdir\" + ]) + else + additional_includedir="$withval/include" + additional_libdir="$withval/$acl_libdirstem" + fi + fi +]) + if test $use_additional = yes; then + dnl Potentially add $additional_includedir to $CPPFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/include, + dnl 2. if it's already present in $CPPFLAGS, + dnl 3. if it's /usr/local/include and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_includedir" != "X/usr/include"; then + haveit= + for x in $CPPFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-I$additional_includedir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_includedir" = "X/usr/local/include"; then + if test -n "$GCC"; then + case $host_os in + linux* | gnu* | k*bsd*-gnu) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_includedir"; then + dnl Really add $additional_includedir to $CPPFLAGS. + CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" + fi + fi + fi + fi + dnl Potentially add $additional_libdir to $LDFLAGS. + dnl But don't add it + dnl 1. if it's the standard /usr/lib, + dnl 2. if it's already present in $LDFLAGS, + dnl 3. if it's /usr/local/lib and we are using GCC on Linux, + dnl 4. if it doesn't exist as a directory. + if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then + haveit= + for x in $LDFLAGS; do + AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) + if test "X$x" = "X-L$additional_libdir"; then + haveit=yes + break + fi + done + if test -z "$haveit"; then + if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then + if test -n "$GCC"; then + case $host_os in + linux*) haveit=yes;; + esac + fi + fi + if test -z "$haveit"; then + if test -d "$additional_libdir"; then + dnl Really add $additional_libdir to $LDFLAGS. + LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" + fi + fi + fi + fi + fi +]) + +dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, +dnl acl_final_exec_prefix, containing the values to which $prefix and +dnl $exec_prefix will expand at the end of the configure script. +AC_DEFUN([AC_LIB_PREPARE_PREFIX], +[ + dnl Unfortunately, prefix and exec_prefix get only finally determined + dnl at the end of configure. + if test "X$prefix" = "XNONE"; then + acl_final_prefix="$ac_default_prefix" + else + acl_final_prefix="$prefix" + fi + if test "X$exec_prefix" = "XNONE"; then + acl_final_exec_prefix='${prefix}' + else + acl_final_exec_prefix="$exec_prefix" + fi + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the +dnl variables prefix and exec_prefix bound to the values they will have +dnl at the end of the configure script. +AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], +[ + acl_save_prefix="$prefix" + prefix="$acl_final_prefix" + acl_save_exec_prefix="$exec_prefix" + exec_prefix="$acl_final_exec_prefix" + $1 + exec_prefix="$acl_save_exec_prefix" + prefix="$acl_save_prefix" +]) + +dnl AC_LIB_PREPARE_MULTILIB creates +dnl - a variable acl_libdirstem, containing the basename of the libdir, either +dnl "lib" or "lib64" or "lib/64", +dnl - a variable acl_libdirstem2, as a secondary possible value for +dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or +dnl "lib/amd64". +AC_DEFUN([AC_LIB_PREPARE_MULTILIB], +[ + dnl There is no formal standard regarding lib and lib64. + dnl On glibc systems, the current practice is that on a system supporting + dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under + dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine + dnl the compiler's default mode by looking at the compiler's library search + dnl path. If at least one of its elements ends in /lib64 or points to a + dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI. + dnl Otherwise we use the default, namely "lib". + dnl On Solaris systems, the current practice is that on a system supporting + dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under + dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or + dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. + AC_REQUIRE([AC_CANONICAL_HOST]) + acl_libdirstem=lib + acl_libdirstem2= + case "$host_os" in + solaris*) + dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment + dnl . + dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." + dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the + dnl symlink is missing, so we set acl_libdirstem2 too. + AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], + [AC_EGREP_CPP([sixtyfour bits], [ +#ifdef _LP64 +sixtyfour bits +#endif + ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no]) + ]) + if test $gl_cv_solaris_64bit = yes; then + acl_libdirstem=lib/64 + case "$host_cpu" in + sparc*) acl_libdirstem2=lib/sparcv9 ;; + i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; + esac + fi + ;; + *) + searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` + if test -n "$searchpath"; then + acl_save_IFS="${IFS= }"; IFS=":" + for searchdir in $searchpath; do + if test -d "$searchdir"; then + case "$searchdir" in + */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; + */../ | */.. ) + # Better ignore directories of this form. They are misleading. + ;; + *) searchdir=`cd "$searchdir" && pwd` + case "$searchdir" in + */lib64 ) acl_libdirstem=lib64 ;; + esac ;; + esac + fi + done + IFS="$acl_save_IFS" + fi + ;; + esac + test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" +]) diff --git a/m4/libsigsegv.m4 b/m4/libsigsegv.m4 new file mode 100644 index 0000000..9d255d3 --- /dev/null +++ b/m4/libsigsegv.m4 @@ -0,0 +1,16 @@ +# libsigsegv.m4 serial 4 +dnl Copyright (C) 2002-2003, 2008-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible, Sam Steingold. + +AC_DEFUN([gl_LIBSIGSEGV], +[ + AC_LIB_HAVE_LINKFLAGS([sigsegv], [], + [#include ], [sigsegv_deinstall_handler();], + [no, consider installing GNU libsigsegv]) + dnl Some other autoconf macros and clisp's configure use this variable. + gl_cv_lib_sigsegv="$ac_cv_libsigsegv" +]) diff --git a/m4/lock.m4 b/m4/lock.m4 new file mode 100644 index 0000000..0224f2f --- /dev/null +++ b/m4/lock.m4 @@ -0,0 +1,311 @@ +# lock.m4 serial 6 (gettext-0.16) +dnl Copyright (C) 2005-2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl Tests for a multithreading library to be used. +dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS, +dnl USE_PTH_THREADS, USE_WIN32_THREADS +dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use +dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with +dnl libtool). +dnl Sets the variables LIBMULTITHREAD and LTLIBMULTITHREAD similarly, for +dnl programs that really need multithread functionality. The difference +dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak +dnl symbols, typically LIBTHREAD="" whereas LIBMULTITHREAD="-lpthread". +dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for +dnl multithread-safe programs. + +AC_DEFUN([gl_LOCK_EARLY], +[ + AC_REQUIRE([gl_LOCK_EARLY_BODY]) +]) + +dnl The guts of gl_LOCK_EARLY. Needs to be expanded only once. + +AC_DEFUN([gl_LOCK_EARLY_BODY], +[ + dnl Ordering constraints: This macro modifies CPPFLAGS in a way that + dnl influences the result of the autoconf tests that test for *_unlocked + dnl declarations, on AIX 5 at least. Therefore it must come early. + AC_BEFORE([$0], [gl_FUNC_GLIBC_UNLOCKED_IO])dnl + AC_BEFORE([$0], [gl_ARGP])dnl + + AC_REQUIRE([AC_CANONICAL_HOST]) + AC_REQUIRE([AC_GNU_SOURCE]) dnl needed for pthread_rwlock_t on glibc systems + dnl Check for multithreading. + AC_ARG_ENABLE(threads, +AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify multithreading API]) +AC_HELP_STRING([--disable-threads], [build without multithread safety]), + [gl_use_threads=$enableval], + [case "$host_os" in + dnl Disable multithreading by default on OSF/1, because it interferes + dnl with fork()/exec(): When msgexec is linked with -lpthread, its child + dnl process gets an endless segmentation fault inside execvp(). + osf*) gl_use_threads=no ;; + *) gl_use_threads=yes ;; + esac + ]) + if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then + # For using : + case "$host_os" in + osf*) + # On OSF/1, the compiler needs the flag -D_REENTRANT so that it + # groks . cc also understands the flag -pthread, but + # we don't use it because 1. gcc-2.95 doesn't understand -pthread, + # 2. putting a flag into CPPFLAGS that has an effect on the linker + # causes the AC_TRY_LINK test below to succeed unexpectedly, + # leading to wrong values of LIBTHREAD and LTLIBTHREAD. + CPPFLAGS="$CPPFLAGS -D_REENTRANT" + ;; + esac + # Some systems optimize for single-threaded programs by default, and + # need special flags to disable these optimizations. For example, the + # definition of 'errno' in . + case "$host_os" in + aix* | freebsd*) CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE" ;; + solaris*) CPPFLAGS="$CPPFLAGS -D_REENTRANT" ;; + esac + fi +]) + +dnl The guts of gl_LOCK. Needs to be expanded only once. + +AC_DEFUN([gl_LOCK_BODY], +[ + AC_REQUIRE([gl_LOCK_EARLY_BODY]) + gl_threads_api=none + LIBTHREAD= + LTLIBTHREAD= + LIBMULTITHREAD= + LTLIBMULTITHREAD= + if test "$gl_use_threads" != no; then + dnl Check whether the compiler and linker support weak declarations. + AC_MSG_CHECKING([whether imported symbols can be declared weak]) + gl_have_weak=no + AC_TRY_LINK([extern void xyzzy (); +#pragma weak xyzzy], [xyzzy();], [gl_have_weak=yes]) + AC_MSG_RESULT([$gl_have_weak]) + if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then + # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that + # it groks . It's added above, in gl_LOCK_EARLY_BODY. + AC_CHECK_HEADER(pthread.h, gl_have_pthread_h=yes, gl_have_pthread_h=no) + if test "$gl_have_pthread_h" = yes; then + # Other possible tests: + # -lpthreads (FSU threads, PCthreads) + # -lgthreads + gl_have_pthread= + # Test whether both pthread_mutex_lock and pthread_mutexattr_init exist + # in libc. IRIX 6.5 has the first one in both libc and libpthread, but + # the second one only in libpthread, and lock.c needs it. + AC_TRY_LINK([#include ], + [pthread_mutex_lock((pthread_mutex_t*)0); + pthread_mutexattr_init((pthread_mutexattr_t*)0);], + [gl_have_pthread=yes]) + # Test for libpthread by looking for pthread_kill. (Not pthread_self, + # since it is defined as a macro on OSF/1.) + if test -n "$gl_have_pthread"; then + # The program links fine without libpthread. But it may actually + # need to link with libpthread in order to create multiple threads. + AC_CHECK_LIB(pthread, pthread_kill, + [LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread + # On Solaris and HP-UX, most pthread functions exist also in libc. + # Therefore pthread_in_use() needs to actually try to create a + # thread: pthread_create from libc will fail, whereas + # pthread_create will actually create a thread. + case "$host_os" in + solaris* | hpux*) + AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], 1, + [Define if the pthread_in_use() detection is hard.]) + esac + ]) + else + # Some library is needed. Try libpthread and libc_r. + AC_CHECK_LIB(pthread, pthread_kill, + [gl_have_pthread=yes + LIBTHREAD=-lpthread LTLIBTHREAD=-lpthread + LIBMULTITHREAD=-lpthread LTLIBMULTITHREAD=-lpthread]) + if test -z "$gl_have_pthread"; then + # For FreeBSD 4. + AC_CHECK_LIB(c_r, pthread_kill, + [gl_have_pthread=yes + LIBTHREAD=-lc_r LTLIBTHREAD=-lc_r + LIBMULTITHREAD=-lc_r LTLIBMULTITHREAD=-lc_r]) + fi + fi + if test -n "$gl_have_pthread"; then + gl_threads_api=posix + AC_DEFINE([USE_POSIX_THREADS], 1, + [Define if the POSIX multithreading library can be used.]) + if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then + if test $gl_have_weak = yes; then + AC_DEFINE([USE_POSIX_THREADS_WEAK], 1, + [Define if references to the POSIX multithreading library should be made weak.]) + LIBTHREAD= + LTLIBTHREAD= + fi + fi + # OSF/1 4.0 and MacOS X 10.1 lack the pthread_rwlock_t type and the + # pthread_rwlock_* functions. + AC_CHECK_TYPE([pthread_rwlock_t], + [AC_DEFINE([HAVE_PTHREAD_RWLOCK], 1, + [Define if the POSIX multithreading library has read/write locks.])], + [], + [#include ]) + # glibc defines PTHREAD_MUTEX_RECURSIVE as enum, not as a macro. + AC_TRY_COMPILE([#include ], + [#if __FreeBSD__ == 4 +error "No, in FreeBSD 4.0 recursive mutexes actually don't work." +#else +int x = (int)PTHREAD_MUTEX_RECURSIVE; +return !x; +#endif], + [AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE], 1, + [Define if the defines PTHREAD_MUTEX_RECURSIVE.])]) + fi + fi + fi + if test -z "$gl_have_pthread"; then + if test "$gl_use_threads" = yes || test "$gl_use_threads" = solaris; then + gl_have_solaristhread= + gl_save_LIBS="$LIBS" + LIBS="$LIBS -lthread" + AC_TRY_LINK([#include +#include ], + [thr_self();], + [gl_have_solaristhread=yes]) + LIBS="$gl_save_LIBS" + if test -n "$gl_have_solaristhread"; then + gl_threads_api=solaris + LIBTHREAD=-lthread + LTLIBTHREAD=-lthread + LIBMULTITHREAD="$LIBTHREAD" + LTLIBMULTITHREAD="$LTLIBTHREAD" + AC_DEFINE([USE_SOLARIS_THREADS], 1, + [Define if the old Solaris multithreading library can be used.]) + if test $gl_have_weak = yes; then + AC_DEFINE([USE_SOLARIS_THREADS_WEAK], 1, + [Define if references to the old Solaris multithreading library should be made weak.]) + LIBTHREAD= + LTLIBTHREAD= + fi + fi + fi + fi + if test "$gl_use_threads" = pth; then + gl_save_CPPFLAGS="$CPPFLAGS" + AC_LIB_LINKFLAGS(pth) + gl_have_pth= + gl_save_LIBS="$LIBS" + LIBS="$LIBS -lpth" + AC_TRY_LINK([#include ], [pth_self();], gl_have_pth=yes) + LIBS="$gl_save_LIBS" + if test -n "$gl_have_pth"; then + gl_threads_api=pth + LIBTHREAD="$LIBPTH" + LTLIBTHREAD="$LTLIBPTH" + LIBMULTITHREAD="$LIBTHREAD" + LTLIBMULTITHREAD="$LTLIBTHREAD" + AC_DEFINE([USE_PTH_THREADS], 1, + [Define if the GNU Pth multithreading library can be used.]) + if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then + if test $gl_have_weak = yes; then + AC_DEFINE([USE_PTH_THREADS_WEAK], 1, + [Define if references to the GNU Pth multithreading library should be made weak.]) + LIBTHREAD= + LTLIBTHREAD= + fi + fi + else + CPPFLAGS="$gl_save_CPPFLAGS" + fi + fi + if test -z "$gl_have_pthread"; then + if test "$gl_use_threads" = yes || test "$gl_use_threads" = win32; then + if { case "$host_os" in + mingw*) true;; + *) false;; + esac + }; then + gl_threads_api=win32 + AC_DEFINE([USE_WIN32_THREADS], 1, + [Define if the Win32 multithreading API can be used.]) + fi + fi + fi + fi + AC_MSG_CHECKING([for multithread API to use]) + AC_MSG_RESULT([$gl_threads_api]) + AC_SUBST(LIBTHREAD) + AC_SUBST(LTLIBTHREAD) + AC_SUBST(LIBMULTITHREAD) + AC_SUBST(LTLIBMULTITHREAD) +]) + +AC_DEFUN([gl_LOCK], +[ + AC_REQUIRE([gl_LOCK_EARLY]) + AC_REQUIRE([gl_LOCK_BODY]) + gl_PREREQ_LOCK +]) + +# Prerequisites of lib/lock.c. +AC_DEFUN([gl_PREREQ_LOCK], [ + AC_REQUIRE([AC_C_INLINE]) +]) + +dnl Survey of platforms: +dnl +dnl Platform Available Compiler Supports test-lock +dnl flavours option weak result +dnl --------------- --------- --------- -------- --------- +dnl Linux 2.4/glibc posix -lpthread Y OK +dnl +dnl GNU Hurd/glibc posix +dnl +dnl FreeBSD 5.3 posix -lc_r Y +dnl posix -lkse ? Y +dnl posix -lpthread ? Y +dnl posix -lthr Y +dnl +dnl FreeBSD 5.2 posix -lc_r Y +dnl posix -lkse Y +dnl posix -lthr Y +dnl +dnl FreeBSD 4.0,4.10 posix -lc_r Y OK +dnl +dnl NetBSD 1.6 -- +dnl +dnl OpenBSD 3.4 posix -lpthread Y OK +dnl +dnl MacOS X 10.[123] posix -lpthread Y OK +dnl +dnl Solaris 7,8,9 posix -lpthread Y Sol 7,8: 0.0; Sol 9: OK +dnl solaris -lthread Y Sol 7,8: 0.0; Sol 9: OK +dnl +dnl HP-UX 11 posix -lpthread N (cc) OK +dnl Y (gcc) +dnl +dnl IRIX 6.5 posix -lpthread Y 0.5 +dnl +dnl AIX 4.3,5.1 posix -lpthread N AIX 4: 0.5; AIX 5: OK +dnl +dnl OSF/1 4.0,5.1 posix -pthread (cc) N OK +dnl -lpthread (gcc) Y +dnl +dnl Cygwin posix -lpthread Y OK +dnl +dnl Any of the above pth -lpth 0.0 +dnl +dnl Mingw win32 N OK +dnl +dnl BeOS 5 -- +dnl +dnl The test-lock result shows what happens if in test-lock.c EXPLICIT_YIELD is +dnl turned off: +dnl OK if all three tests terminate OK, +dnl 0.5 if the first test terminates OK but the second one loops endlessly, +dnl 0.0 if the first test already loops endlessly. diff --git a/m4/longdouble.m4 b/m4/longdouble.m4 new file mode 100644 index 0000000..25590f4 --- /dev/null +++ b/m4/longdouble.m4 @@ -0,0 +1,31 @@ +# longdouble.m4 serial 2 (gettext-0.15) +dnl Copyright (C) 2002-2003, 2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Test whether the compiler supports the 'long double' type. +dnl Prerequisite: AC_PROG_CC + +dnl This file is only needed in autoconf <= 2.59. Newer versions of autoconf +dnl have a macro AC_TYPE_LONG_DOUBLE with identical semantics. + +AC_DEFUN([gt_TYPE_LONGDOUBLE], +[ + AC_CACHE_CHECK([for long double], gt_cv_c_long_double, + [if test "$GCC" = yes; then + gt_cv_c_long_double=yes + else + AC_TRY_COMPILE([ + /* The Stardent Vistra knows sizeof(long double), but does not support it. */ + long double foo = 0.0; + /* On Ultrix 4.3 cc, long double is 4 and double is 8. */ + int array [2*(sizeof(long double) >= sizeof(double)) - 1]; + ], , + gt_cv_c_long_double=yes, gt_cv_c_long_double=no) + fi]) + if test $gt_cv_c_long_double = yes; then + AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define if you have the 'long double' type.]) + fi +]) diff --git a/m4/longlong.m4 b/m4/longlong.m4 new file mode 100644 index 0000000..3716c09 --- /dev/null +++ b/m4/longlong.m4 @@ -0,0 +1,48 @@ +# longlong.m4 serial 8 +dnl Copyright (C) 1999-2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert. + +# Define HAVE_LONG_LONG_INT if 'long long int' works. +# This fixes a bug in Autoconf 2.60, but can be removed once we +# assume 2.61 everywhere. + +# Note: If the type 'long long int' exists but is only 32 bits large +# (as on some very old compilers), AC_TYPE_LONG_LONG_INT will not be +# defined. In this case you can treat 'long long int' like 'long int'. + +AC_DEFUN([AC_TYPE_LONG_LONG_INT], +[ + AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[long long int ll = 9223372036854775807ll; + long long int nll = -9223372036854775807LL; + typedef int a[((-9223372036854775807LL < 0 + && 0 < 9223372036854775807ll) + ? 1 : -1)]; + int i = 63;]], + [[long long int llmax = 9223372036854775807ll; + return ((ll << 63) | (ll >> 63) | (ll < i) | (ll > i) + | (llmax / ll) | (llmax % ll));]])], + [ac_cv_type_long_long_int=yes], + [ac_cv_type_long_long_int=no])]) + if test $ac_cv_type_long_long_int = yes; then + AC_DEFINE([HAVE_LONG_LONG_INT], 1, + [Define to 1 if the system has the type `long long int'.]) + fi +]) + +# This macro is obsolescent and should go away soon. +AC_DEFUN([gl_AC_TYPE_LONG_LONG], +[ + AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) + ac_cv_type_long_long=$ac_cv_type_long_long_int + if test $ac_cv_type_long_long = yes; then + AC_DEFINE(HAVE_LONG_LONG, 1, + [Define if you have the 'long long' type.]) + fi +]) diff --git a/m4/nls.m4 b/m4/nls.m4 new file mode 100644 index 0000000..003704c --- /dev/null +++ b/m4/nls.m4 @@ -0,0 +1,32 @@ +# nls.m4 serial 5 (gettext-0.18) +dnl Copyright (C) 1995-2003, 2005-2006, 2008-2010 Free Software Foundation, +dnl Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2003. + +AC_PREREQ([2.50]) + +AC_DEFUN([AM_NLS], +[ + AC_MSG_CHECKING([whether NLS is requested]) + dnl Default is enabled NLS + AC_ARG_ENABLE([nls], + [ --disable-nls do not use Native Language Support], + USE_NLS=$enableval, USE_NLS=yes) + AC_MSG_RESULT([$USE_NLS]) + AC_SUBST([USE_NLS]) +]) diff --git a/m4/po.m4 b/m4/po.m4 new file mode 100644 index 0000000..47f36a4 --- /dev/null +++ b/m4/po.m4 @@ -0,0 +1,449 @@ +# po.m4 serial 17 (gettext-0.18) +dnl Copyright (C) 1995-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1995-2000. +dnl Bruno Haible , 2000-2003. + +AC_PREREQ([2.50]) + +dnl Checks for all prerequisites of the po subdirectory. +AC_DEFUN([AM_PO_SUBDIRS], +[ + AC_REQUIRE([AC_PROG_MAKE_SET])dnl + AC_REQUIRE([AC_PROG_INSTALL])dnl + AC_REQUIRE([AM_PROG_MKDIR_P])dnl defined by automake + AC_REQUIRE([AM_NLS])dnl + + dnl Release version of the gettext macros. This is used to ensure that + dnl the gettext macros and po/Makefile.in.in are in sync. + AC_SUBST([GETTEXT_MACRO_VERSION], [0.18]) + + dnl Perform the following tests also if --disable-nls has been given, + dnl because they are needed for "make dist" to work. + + dnl Search for GNU msgfmt in the PATH. + dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions. + dnl The second test excludes FreeBSD msgfmt. + AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, + [$ac_dir/$ac_word --statistics /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && + (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], + :) + AC_PATH_PROG([GMSGFMT], [gmsgfmt], [$MSGFMT]) + + dnl Test whether it is GNU msgfmt >= 0.15. +changequote(,)dnl + case `$MSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) MSGFMT_015=: ;; + *) MSGFMT_015=$MSGFMT ;; + esac +changequote([,])dnl + AC_SUBST([MSGFMT_015]) +changequote(,)dnl + case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;; + *) GMSGFMT_015=$GMSGFMT ;; + esac +changequote([,])dnl + AC_SUBST([GMSGFMT_015]) + + dnl Search for GNU xgettext 0.12 or newer in the PATH. + dnl The first test excludes Solaris xgettext and early GNU xgettext versions. + dnl The second test excludes FreeBSD xgettext. + AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, + [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1 && + (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)], + :) + dnl Remove leftover from FreeBSD xgettext call. + rm -f messages.po + + dnl Test whether it is GNU xgettext >= 0.15. +changequote(,)dnl + case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;; + *) XGETTEXT_015=$XGETTEXT ;; + esac +changequote([,])dnl + AC_SUBST([XGETTEXT_015]) + + dnl Search for GNU msgmerge 0.11 or newer in the PATH. + AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge, + [$ac_dir/$ac_word --update -q /dev/null /dev/null >&]AS_MESSAGE_LOG_FD[ 2>&1], :) + + dnl Installation directories. + dnl Autoconf >= 2.60 defines localedir. For older versions of autoconf, we + dnl have to define it here, so that it can be used in po/Makefile. + test -n "$localedir" || localedir='${datadir}/locale' + AC_SUBST([localedir]) + + dnl Support for AM_XGETTEXT_OPTION. + test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS= + AC_SUBST([XGETTEXT_EXTRA_OPTIONS]) + + AC_CONFIG_COMMANDS([po-directories], [[ + for ac_file in $CONFIG_FILES; do + # Support "outfile[:infile[:infile...]]" + case "$ac_file" in + *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + esac + # PO directories have a Makefile.in generated from Makefile.in.in. + case "$ac_file" in */Makefile.in) + # Adjust a relative srcdir. + ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` + ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" + ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` + # In autoconf-2.13 it is called $ac_given_srcdir. + # In autoconf-2.50 it is called $srcdir. + test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" + case "$ac_given_srcdir" in + .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; + /*) top_srcdir="$ac_given_srcdir" ;; + *) top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + # Treat a directory as a PO directory if and only if it has a + # POTFILES.in file. This allows packages to have multiple PO + # directories under different names or in different locations. + if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then + rm -f "$ac_dir/POTFILES" + test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES" + cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES" + POMAKEFILEDEPS="POTFILES.in" + # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend + # on $ac_dir but don't depend on user-specified configuration + # parameters. + if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then + # The LINGUAS file contains the set of available languages. + if test -n "$OBSOLETE_ALL_LINGUAS"; then + test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete" + fi + ALL_LINGUAS_=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"` + # Hide the ALL_LINGUAS assigment from automake < 1.5. + eval 'ALL_LINGUAS''=$ALL_LINGUAS_' + POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS" + else + # The set of available languages was given in configure.in. + # Hide the ALL_LINGUAS assigment from automake < 1.5. + eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS' + fi + # Compute POFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po) + # Compute UPDATEPOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update) + # Compute DUMMYPOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop) + # Compute GMOFILES + # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo) + case "$ac_given_srcdir" in + .) srcdirpre= ;; + *) srcdirpre='$(srcdir)/' ;; + esac + POFILES= + UPDATEPOFILES= + DUMMYPOFILES= + GMOFILES= + for lang in $ALL_LINGUAS; do + POFILES="$POFILES $srcdirpre$lang.po" + UPDATEPOFILES="$UPDATEPOFILES $lang.po-update" + DUMMYPOFILES="$DUMMYPOFILES $lang.nop" + GMOFILES="$GMOFILES $srcdirpre$lang.gmo" + done + # CATALOGS depends on both $ac_dir and the user's LINGUAS + # environment variable. + INST_LINGUAS= + if test -n "$ALL_LINGUAS"; then + for presentlang in $ALL_LINGUAS; do + useit=no + if test "%UNSET%" != "$LINGUAS"; then + desiredlanguages="$LINGUAS" + else + desiredlanguages="$ALL_LINGUAS" + fi + for desiredlang in $desiredlanguages; do + # Use the presentlang catalog if desiredlang is + # a. equal to presentlang, or + # b. a variant of presentlang (because in this case, + # presentlang can be used as a fallback for messages + # which are not translated in the desiredlang catalog). + case "$desiredlang" in + "$presentlang"*) useit=yes;; + esac + done + if test $useit = yes; then + INST_LINGUAS="$INST_LINGUAS $presentlang" + fi + done + fi + CATALOGS= + if test -n "$INST_LINGUAS"; then + for lang in $INST_LINGUAS; do + CATALOGS="$CATALOGS $lang.gmo" + done + fi + test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile" + sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile" + for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do + if test -f "$f"; then + case "$f" in + *.orig | *.bak | *~) ;; + *) cat "$f" >> "$ac_dir/Makefile" ;; + esac + fi + done + fi + ;; + esac + done]], + [# Capture the value of obsolete ALL_LINGUAS because we need it to compute + # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS. But hide it + # from automake < 1.5. + eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"' + # Capture the value of LINGUAS because we need it to compute CATALOGS. + LINGUAS="${LINGUAS-%UNSET%}" + ]) +]) + +dnl Postprocesses a Makefile in a directory containing PO files. +AC_DEFUN([AM_POSTPROCESS_PO_MAKEFILE], +[ + # When this code is run, in config.status, two variables have already been + # set: + # - OBSOLETE_ALL_LINGUAS is the value of LINGUAS set in configure.in, + # - LINGUAS is the value of the environment variable LINGUAS at configure + # time. + +changequote(,)dnl + # Adjust a relative srcdir. + ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'` + ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`" + ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'` + # In autoconf-2.13 it is called $ac_given_srcdir. + # In autoconf-2.50 it is called $srcdir. + test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir" + case "$ac_given_srcdir" in + .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;; + /*) top_srcdir="$ac_given_srcdir" ;; + *) top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + # Find a way to echo strings without interpreting backslash. + if test "X`(echo '\t') 2>/dev/null`" = 'X\t'; then + gt_echo='echo' + else + if test "X`(printf '%s\n' '\t') 2>/dev/null`" = 'X\t'; then + gt_echo='printf %s\n' + else + echo_func () { + cat < "$ac_file.tmp" + if grep -l '@TCLCATALOGS@' "$ac_file" > /dev/null; then + # Add dependencies that cannot be formulated as a simple suffix rule. + for lang in $ALL_LINGUAS; do + frobbedlang=`echo $lang | sed -e 's/\..*$//' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` + cat >> "$ac_file.tmp" < /dev/null; then + # Add dependencies that cannot be formulated as a simple suffix rule. + for lang in $ALL_LINGUAS; do + frobbedlang=`echo $lang | sed -e 's/_/-/g' -e 's/^sr-CS/sr-SP/' -e 's/@latin$/-Latn/' -e 's/@cyrillic$/-Cyrl/' -e 's/^sr-SP$/sr-SP-Latn/' -e 's/^uz-UZ$/uz-UZ-Latn/'` + cat >> "$ac_file.tmp" <> "$ac_file.tmp" < +#include +/* The string "%2$d %1$d", with dollar characters protected from the shell's + dollar expansion (possibly an autoconf bug). */ +static char format[] = { '%', '2', '$', 'd', ' ', '%', '1', '$', 'd', '\0' }; +static char buf[100]; +int main () +{ + sprintf (buf, format, 33, 55); + return (strcmp (buf, "55 33") != 0); +}], gt_cv_func_printf_posix=yes, gt_cv_func_printf_posix=no, + [ + AC_EGREP_CPP(notposix, [ +#if defined __NetBSD__ || defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ + notposix +#endif + ], gt_cv_func_printf_posix="guessing no", + gt_cv_func_printf_posix="guessing yes") + ]) + ]) + case $gt_cv_func_printf_posix in + *yes) + AC_DEFINE(HAVE_POSIX_PRINTF, 1, + [Define if your printf() function supports format strings with positions.]) + ;; + esac +]) diff --git a/m4/progtest.m4 b/m4/progtest.m4 new file mode 100644 index 0000000..2d804ac --- /dev/null +++ b/m4/progtest.m4 @@ -0,0 +1,92 @@ +# progtest.m4 serial 6 (gettext-0.18) +dnl Copyright (C) 1996-2003, 2005, 2008-2010 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +dnl +dnl This file can can be used in projects which are not available under +dnl the GNU General Public License or the GNU Library General Public +dnl License but which still want to provide support for the GNU gettext +dnl functionality. +dnl Please note that the actual code of the GNU gettext library is covered +dnl by the GNU Library General Public License, and the rest of the GNU +dnl gettext package package is covered by the GNU General Public License. +dnl They are *not* in the public domain. + +dnl Authors: +dnl Ulrich Drepper , 1996. + +AC_PREREQ([2.50]) + +# Search path for a program which passes the given test. + +dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, +dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) +AC_DEFUN([AM_PATH_PROG_WITH_TEST], +[ +# Prepare PATH_SEPARATOR. +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Find out how to test for executable files. Don't use a zero-byte file, +# as systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + ac_executable_p="test -x" +else + ac_executable_p="test -f" +fi +rm -f conf$$.file + +# Extract the first word of "$2", so it can be a program name with args. +set dummy $2; ac_word=[$]2 +AC_MSG_CHECKING([for $ac_word]) +AC_CACHE_VAL([ac_cv_path_$1], +[case "[$]$1" in + [[\\/]]* | ?:[[\\/]]*) + ac_cv_path_$1="[$]$1" # Let the user override the test with a path. + ;; + *) + ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in ifelse([$5], , $PATH, [$5]); do + IFS="$ac_save_IFS" + test -z "$ac_dir" && ac_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then + echo "$as_me: trying $ac_dir/$ac_word..." >&AS_MESSAGE_LOG_FD + if [$3]; then + ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext" + break 2 + fi + fi + done + done + IFS="$ac_save_IFS" +dnl If no 4th arg is given, leave the cache variable unset, +dnl so AC_PATH_PROGS will keep looking. +ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" +])dnl + ;; +esac])dnl +$1="$ac_cv_path_$1" +if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then + AC_MSG_RESULT([$][$1]) +else + AC_MSG_RESULT([no]) +fi +AC_SUBST([$1])dnl +]) diff --git a/m4/readline.m4 b/m4/readline.m4 new file mode 100644 index 0000000..73bbf2a --- /dev/null +++ b/m4/readline.m4 @@ -0,0 +1,64 @@ +dnl Check for readline and dependencies +dnl Copyright (C) 2004, 2005 Free Software Foundation, Inc. +dnl +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. +dnl +dnl Defines HAVE_LIBREADLINE to 1 if a working readline setup is +dnl found, and sets @LIBREADLINE@ to the necessary libraries. + +AC_DEFUN([GNUPG_CHECK_READLINE], +[ + AC_ARG_WITH([readline], + AC_HELP_STRING([--with-readline=DIR], + [look for the readline library in DIR]), + [_do_readline=$withval],[_do_readline=yes]) + + if test "$_do_readline" != "no" ; then + if test -d "$withval" ; then + CPPFLAGS="${CPPFLAGS} -I$withval/include" + LDFLAGS="${LDFLAGS} -L$withval/lib" + fi + + for _termcap in "" "-ltermcap" "-lcurses" "-lncurses" ; do + _readline_save_libs=$LIBS + _combo="-lreadline${_termcap:+ $_termcap}" + LIBS="$LIBS $_combo" + + AC_MSG_CHECKING([whether readline via \"$_combo\" is present and sane]) + + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([ +#include +#include +#include +],[ +rl_completion_func_t *completer; +add_history("foobar"); +rl_catch_signals=0; +rl_inhibit_completion=0; +rl_attempted_completion_function=NULL; +rl_completion_matches(NULL,NULL); +])],_found_readline=yes,_found_readline=no) + + AC_MSG_RESULT([$_found_readline]) + + LIBS=$_readline_save_libs + + if test $_found_readline = yes ; then + AC_DEFINE(HAVE_LIBREADLINE,1, + [Define to 1 if you have a fully functional readline library.]) + AC_SUBST(LIBREADLINE,$_combo) + break + fi + done + + unset _termcap + unset _readline_save_libs + unset _combo + unset _found_readline + fi +])dnl diff --git a/m4/signed.m4 b/m4/signed.m4 new file mode 100644 index 0000000..048f593 --- /dev/null +++ b/m4/signed.m4 @@ -0,0 +1,17 @@ +# signed.m4 serial 1 (gettext-0.10.40) +dnl Copyright (C) 2001-2002 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([bh_C_SIGNED], +[ + AC_CACHE_CHECK([for signed], bh_cv_c_signed, + [AC_TRY_COMPILE(, [signed char x;], bh_cv_c_signed=yes, bh_cv_c_signed=no)]) + if test $bh_cv_c_signed = no; then + AC_DEFINE(signed, , + [Define to empty if the C compiler doesn't support this keyword.]) + fi +]) diff --git a/m4/size_max.m4 b/m4/size_max.m4 new file mode 100644 index 0000000..bfba811 --- /dev/null +++ b/m4/size_max.m4 @@ -0,0 +1,62 @@ +# size_max.m4 serial 5 +dnl Copyright (C) 2003, 2005-2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +AC_DEFUN([gl_SIZE_MAX], +[ + AC_CHECK_HEADERS(stdint.h) + dnl First test whether the system already has SIZE_MAX. + AC_MSG_CHECKING([for SIZE_MAX]) + AC_CACHE_VAL([gl_cv_size_max], [ + gl_cv_size_max= + AC_EGREP_CPP([Found it], [ +#include +#if HAVE_STDINT_H +#include +#endif +#ifdef SIZE_MAX +Found it +#endif +], gl_cv_size_max=yes) + if test -z "$gl_cv_size_max"; then + dnl Define it ourselves. Here we assume that the type 'size_t' is not wider + dnl than the type 'unsigned long'. Try hard to find a definition that can + dnl be used in a preprocessor #if, i.e. doesn't contain a cast. + _AC_COMPUTE_INT([sizeof (size_t) * CHAR_BIT - 1], size_t_bits_minus_1, + [#include +#include ], size_t_bits_minus_1=) + _AC_COMPUTE_INT([sizeof (size_t) <= sizeof (unsigned int)], fits_in_uint, + [#include ], fits_in_uint=) + if test -n "$size_t_bits_minus_1" && test -n "$fits_in_uint"; then + if test $fits_in_uint = 1; then + dnl Even though SIZE_MAX fits in an unsigned int, it must be of type + dnl 'unsigned long' if the type 'size_t' is the same as 'unsigned long'. + AC_TRY_COMPILE([#include + extern size_t foo; + extern unsigned long foo; + ], [], fits_in_uint=0) + fi + dnl We cannot use 'expr' to simplify this expression, because 'expr' + dnl works only with 'long' integers in the host environment, while we + dnl might be cross-compiling from a 32-bit platform to a 64-bit platform. + if test $fits_in_uint = 1; then + gl_cv_size_max="(((1U << $size_t_bits_minus_1) - 1) * 2 + 1)" + else + gl_cv_size_max="(((1UL << $size_t_bits_minus_1) - 1) * 2 + 1)" + fi + else + dnl Shouldn't happen, but who knows... + gl_cv_size_max='((size_t)~(size_t)0)' + fi + fi + ]) + AC_MSG_RESULT([$gl_cv_size_max]) + if test "$gl_cv_size_max" != yes; then + AC_DEFINE_UNQUOTED([SIZE_MAX], [$gl_cv_size_max], + [Define as the maximum value of type 'size_t', if the system doesn't define it.]) + fi +]) diff --git a/m4/socket.m4 b/m4/socket.m4 new file mode 100644 index 0000000..ae86b34 --- /dev/null +++ b/m4/socket.m4 @@ -0,0 +1,85 @@ +dnl +dnl socket.m4 --- autoconf input file for gawk +dnl +dnl Copyright (C) 1995, 1996, 1998, 1999, 2000, 2003, 2004 the Free Software Foundation, Inc. +dnl +dnl This file is part of GAWK, the GNU implementation of the +dnl AWK Progamming Language. +dnl +dnl GAWK is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl GAWK is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +dnl + +dnl Find the socket libraries +dnl largely stolen from AC_PATH_XTRA +AC_DEFUN([GAWK_AC_LIB_SOCKETS], [ +gawk_have_sockets=no +# Check for system-dependent location of socket libraries + +SOCKET_LIBS= +if test "$ISC" = yes; then + SOCKET_LIBS="-lnsl_s -linet" +else + # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X + # libraries were built with DECnet support. And karl@cs.umb.edu says + # the Alpha needs dnet_stub (dnet does not exist). + # + # ADR: Is this needed just for sockets??? +# AC_CHECK_LIB(dnet, dnet_ntoa, [SOCKET_LIBS="$SOCKET_LIBS -ldnet"]) +# if test $ac_cv_lib_dnet_ntoa = no; then +# AC_CHECK_LIB(dnet_stub, dnet_ntoa, +# [SOCKET_LIBS="$SOCKET_LIBS -ldnet_stub"]) +# fi + + # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, + # to get the SysV transport functions. + # chad@anasazi.com says the Pyramid MIS-ES running DC/OSx (SVR4) + # needs -lnsl. + # The nsl library prevents programs from opening the X display + # on Irix 5.2, according to dickey@clark.net. + AC_CHECK_FUNC(gethostbyname) + if test $ac_cv_func_gethostbyname = no; then + AC_CHECK_LIB(nsl, gethostbyname, SOCKET_LIBS="$SOCKET_LIBS -lnsl") + fi + + # lieder@skyler.mavd.honeywell.com says without -lsocket, + # socket/setsockopt and other routines are undefined under SCO ODT + # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary + # on later versions), says simon@lia.di.epfl.ch: it contains + # gethostby* variants that don't use the nameserver (or something). + # -lsocket must be given before -lnsl if both are needed. + # We assume that if connect needs -lnsl, so does gethostbyname. + AC_CHECK_FUNC(connect) + if test $ac_cv_func_connect = no; then + AC_CHECK_LIB(socket, connect, SOCKET_LIBS="-lsocket $SOCKET_LIBS" + gawk_have_sockets=yes, , + $SOCKET_LIBS) + else + gawk_have_sockets=yes + fi +fi + +if test "${gawk_have_sockets}" = "yes" +then + AC_MSG_CHECKING([where to find the socket library calls]) + case "${SOCKET_LIBS}" in + ?*) gawk_lib_loc="${SOCKET_LIBS}" ;; + *) gawk_lib_loc="the standard library" ;; + esac + AC_MSG_RESULT([${gawk_lib_loc}]) + + AC_DEFINE(HAVE_SOCKETS, 1, [we have sockets on this system]) +fi +AC_SUBST(SOCKET_LIBS)dnl +])dnl diff --git a/m4/stdint_h.m4 b/m4/stdint_h.m4 new file mode 100644 index 0000000..86da6d7 --- /dev/null +++ b/m4/stdint_h.m4 @@ -0,0 +1,31 @@ +# stdint_h.m4 serial 6 +dnl Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert. + +# Define HAVE_STDINT_H_WITH_UINTMAX if exists, +# doesn't clash with , and declares uintmax_t. + +AC_DEFUN([gl_AC_HEADER_STDINT_H], +[ + if test "OS/390" = "`uname`" + then + gl_cv_header_stdint_h=no + else + AC_CACHE_CHECK([for stdint.h], gl_cv_header_stdint_h, + [AC_TRY_COMPILE( + [#include +#include ], + [uintmax_t i = (uintmax_t) -1; return !i;], + gl_cv_header_stdint_h=yes, + gl_cv_header_stdint_h=no)]) + if test $gl_cv_header_stdint_h = yes; then + AC_DEFINE_UNQUOTED(HAVE_STDINT_H_WITH_UINTMAX, 1, + [Define if exists, doesn't clash with , + and declares uintmax_t. ]) + fi + fi +]) diff --git a/m4/uintmax_t.m4 b/m4/uintmax_t.m4 new file mode 100644 index 0000000..bf83ed7 --- /dev/null +++ b/m4/uintmax_t.m4 @@ -0,0 +1,30 @@ +# uintmax_t.m4 serial 9 +dnl Copyright (C) 1997-2004 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert. + +AC_PREREQ(2.13) + +# Define uintmax_t to 'unsigned long' or 'unsigned long long' +# if it is not already defined in or . + +AC_DEFUN([gl_AC_TYPE_UINTMAX_T], +[ + AC_REQUIRE([gl_AC_HEADER_INTTYPES_H]) + AC_REQUIRE([gl_AC_HEADER_STDINT_H]) + if test $gl_cv_header_inttypes_h = no && test $gl_cv_header_stdint_h = no; then + AC_REQUIRE([gl_AC_TYPE_UNSIGNED_LONG_LONG]) + test $ac_cv_type_unsigned_long_long = yes \ + && ac_type='unsigned long long' \ + || ac_type='unsigned long' + AC_DEFINE_UNQUOTED(uintmax_t, $ac_type, + [Define to unsigned long or unsigned long long + if and don't define.]) + else + AC_DEFINE(HAVE_UINTMAX_T, 1, + [Define if you have the 'uintmax_t' type in or .]) + fi +]) diff --git a/m4/ulonglong.m4 b/m4/ulonglong.m4 new file mode 100644 index 0000000..9fae98e --- /dev/null +++ b/m4/ulonglong.m4 @@ -0,0 +1,48 @@ +# ulonglong.m4 serial 6 +dnl Copyright (C) 1999-2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Paul Eggert. + +# Define HAVE_UNSIGNED_LONG_LONG_INT if 'unsigned long long int' works. +# This fixes a bug in Autoconf 2.60, but can be removed once we +# assume 2.61 everywhere. + +# Note: If the type 'unsigned long long int' exists but is only 32 bits +# large (as on some very old compilers), AC_TYPE_UNSIGNED_LONG_LONG_INT +# will not be defined. In this case you can treat 'unsigned long long int' +# like 'unsigned long int'. + +AC_DEFUN([AC_TYPE_UNSIGNED_LONG_LONG_INT], +[ + AC_CACHE_CHECK([for unsigned long long int], + [ac_cv_type_unsigned_long_long_int], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[unsigned long long int ull = 18446744073709551615ULL; + typedef int a[(18446744073709551615ULL <= (unsigned long long int) -1 + ? 1 : -1)]; + int i = 63;]], + [[unsigned long long int ullmax = 18446744073709551615ull; + return (ull << 63 | ull >> 63 | ull << i | ull >> i + | ullmax / ull | ullmax % ull);]])], + [ac_cv_type_unsigned_long_long_int=yes], + [ac_cv_type_unsigned_long_long_int=no])]) + if test $ac_cv_type_unsigned_long_long_int = yes; then + AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], 1, + [Define to 1 if the system has the type `unsigned long long int'.]) + fi +]) + +# This macro is obsolescent and should go away soon. +AC_DEFUN([gl_AC_TYPE_UNSIGNED_LONG_LONG], +[ + AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) + ac_cv_type_unsigned_long_long=$ac_cv_type_unsigned_long_long_int + if test $ac_cv_type_unsigned_long_long = yes; then + AC_DEFINE(HAVE_UNSIGNED_LONG_LONG, 1, + [Define if you have the 'unsigned long long' type.]) + fi +]) diff --git a/m4/visibility.m4 b/m4/visibility.m4 new file mode 100644 index 0000000..2ff6330 --- /dev/null +++ b/m4/visibility.m4 @@ -0,0 +1,52 @@ +# visibility.m4 serial 1 (gettext-0.15) +dnl Copyright (C) 2005 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl Tests whether the compiler supports the command-line option +dnl -fvisibility=hidden and the function and variable attributes +dnl __attribute__((__visibility__("hidden"))) and +dnl __attribute__((__visibility__("default"))). +dnl Does *not* test for __visibility__("protected") - which has tricky +dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on +dnl MacOS X. +dnl Does *not* test for __visibility__("internal") - which has processor +dnl dependent semantics. +dnl Does *not* test for #pragma GCC visibility push(hidden) - which is +dnl "really only recommended for legacy code". +dnl Set the variable CFLAG_VISIBILITY. +dnl Defines and sets the variable HAVE_VISIBILITY. + +AC_DEFUN([gl_VISIBILITY], +[ + AC_REQUIRE([AC_PROG_CC]) + CFLAG_VISIBILITY= + HAVE_VISIBILITY=0 + if test -n "$GCC"; then + AC_MSG_CHECKING([for simple visibility declarations]) + AC_CACHE_VAL(gl_cv_cc_visibility, [ + gl_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fvisibility=hidden" + AC_TRY_COMPILE( + [extern __attribute__((__visibility__("hidden"))) int hiddenvar; + extern __attribute__((__visibility__("default"))) int exportedvar; + extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void); + extern __attribute__((__visibility__("default"))) int exportedfunc (void);], + [], + gl_cv_cc_visibility=yes, + gl_cv_cc_visibility=no) + CFLAGS="$gl_save_CFLAGS"]) + AC_MSG_RESULT([$gl_cv_cc_visibility]) + if test $gl_cv_cc_visibility = yes; then + CFLAG_VISIBILITY="-fvisibility=hidden" + HAVE_VISIBILITY=1 + fi + fi + AC_SUBST([CFLAG_VISIBILITY]) + AC_SUBST([HAVE_VISIBILITY]) + AC_DEFINE_UNQUOTED([HAVE_VISIBILITY], [$HAVE_VISIBILITY], + [Define to 1 or 0, depending whether the compiler supports simple visibility declarations.]) +]) diff --git a/m4/wchar_t.m4 b/m4/wchar_t.m4 new file mode 100644 index 0000000..cde2129 --- /dev/null +++ b/m4/wchar_t.m4 @@ -0,0 +1,20 @@ +# wchar_t.m4 serial 1 (gettext-0.12) +dnl Copyright (C) 2002-2003 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Test whether has the 'wchar_t' type. +dnl Prerequisite: AC_PROG_CC + +AC_DEFUN([gt_TYPE_WCHAR_T], +[ + AC_CACHE_CHECK([for wchar_t], gt_cv_c_wchar_t, + [AC_TRY_COMPILE([#include + wchar_t foo = (wchar_t)'\0';], , + gt_cv_c_wchar_t=yes, gt_cv_c_wchar_t=no)]) + if test $gt_cv_c_wchar_t = yes; then + AC_DEFINE(HAVE_WCHAR_T, 1, [Define if you have the 'wchar_t' type.]) + fi +]) diff --git a/m4/wint_t.m4 b/m4/wint_t.m4 new file mode 100644 index 0000000..b8fff9c --- /dev/null +++ b/m4/wint_t.m4 @@ -0,0 +1,20 @@ +# wint_t.m4 serial 1 (gettext-0.12) +dnl Copyright (C) 2003 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Test whether has the 'wint_t' type. +dnl Prerequisite: AC_PROG_CC + +AC_DEFUN([gt_TYPE_WINT_T], +[ + AC_CACHE_CHECK([for wint_t], gt_cv_c_wint_t, + [AC_TRY_COMPILE([#include + wint_t foo = (wchar_t)'\0';], , + gt_cv_c_wint_t=yes, gt_cv_c_wint_t=no)]) + if test $gt_cv_c_wint_t = yes; then + AC_DEFINE(HAVE_WINT_T, 1, [Define if you have the 'wint_t' type.]) + fi +]) diff --git a/m4/xsize.m4 b/m4/xsize.m4 new file mode 100644 index 0000000..85bb721 --- /dev/null +++ b/m4/xsize.m4 @@ -0,0 +1,13 @@ +# xsize.m4 serial 3 +dnl Copyright (C) 2003-2004 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_XSIZE], +[ + dnl Prerequisites of lib/xsize.h. + AC_REQUIRE([gl_SIZE_MAX]) + AC_REQUIRE([AC_C_INLINE]) + AC_CHECK_HEADERS(stdint.h) +]) diff --git a/main.c b/main.c new file mode 100644 index 0000000..3680e3f --- /dev/null +++ b/main.c @@ -0,0 +1,1463 @@ +/* + * main.c -- Code generator and main program for gawk. + */ + +/* + * Copyright (C) 1986, 1988, 1989, 1991-2012 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* FIX THIS BEFORE EVERY RELEASE: */ +#define UPDATE_YEAR 2012 + +#include "awk.h" +#include "getopt.h" + +#ifdef HAVE_MCHECK_H +#include +#endif + +#define DEFAULT_PROFILE "awkprof.out" /* where to put profile */ +#define DEFAULT_VARFILE "awkvars.out" /* where to put vars */ + +static const char *varfile = DEFAULT_VARFILE; +const char *command_file = NULL; /* debugger commands */ + +static void usage(int exitval, FILE *fp) ATTRIBUTE_NORETURN; +static void copyleft(void) ATTRIBUTE_NORETURN; +static void cmdline_fs(char *str); +static void init_args(int argc0, int argc, const char *argv0, char **argv); +static void init_vars(void); +static NODE *load_environ(void); +static NODE *load_procinfo(void); +static RETSIGTYPE catchsig(int sig); +#ifdef HAVE_LIBSIGSEGV +static int catchsegv(void *fault_address, int serious); +static void catchstackoverflow(int emergency, stackoverflow_context_t scp); +#endif +static void nostalgia(void) ATTRIBUTE_NORETURN; +static void version(void) ATTRIBUTE_NORETURN; +static void init_fds(void); +static void init_groupset(void); + +static void save_argv(int, char **); + +/* These nodes store all the special variables AWK uses */ +NODE *ARGC_node, *ARGIND_node, *ARGV_node, *BINMODE_node, *CONVFMT_node; +NODE *ENVIRON_node, *ERRNO_node, *FIELDWIDTHS_node, *FILENAME_node; +NODE *FNR_node, *FPAT_node, *FS_node, *IGNORECASE_node, *LINT_node; +NODE *NF_node, *NR_node, *OFMT_node, *OFS_node, *ORS_node, *PROCINFO_node; +NODE *RLENGTH_node, *RSTART_node, *RS_node, *RT_node, *SUBSEP_node; +NODE *TEXTDOMAIN_node; + +NODE *_r; /* used as temporary in stack macros */ + +long NF; +long NR; +long FNR; +int BINMODE; +int IGNORECASE; +char *OFS; +char *ORS; +char *OFMT; +char *TEXTDOMAIN; + +/* + * CONVFMT is a convenience pointer for the current number to string format. + * We must supply an initial value to avoid recursion problems of + * set_CONVFMT -> fmt_index -> r_force_string: gets NULL CONVFMT + * Fun, fun, fun, fun. + */ +char *CONVFMT = "%.6g"; + +NODE *Nnull_string; /* The global null string */ + +#if defined(HAVE_LOCALE_H) +struct lconv loc; /* current locale */ +static void init_locale(struct lconv *l); +#endif /* defined(HAVE_LOCALE_H) */ + +/* The name the program was invoked under, for error messages */ +const char *myname; + +/* A block of AWK code to be run */ +INSTRUCTION *code_block = NULL; + +char **d_argv; /* saved argv for debugger restarting */ +/* + * List of rules and functions with first and last instruction (source_line) + * information; used for profiling and debugging. + */ +INSTRUCTION *rule_list; + +int exit_val = EXIT_SUCCESS; /* exit value */ + +#if defined(YYDEBUG) || defined(GAWKDEBUG) +extern int yydebug; +#endif + +SRCFILE *srcfiles; /* source files */ + +/* + * structure to remember variable pre-assignments + */ +struct pre_assign { + enum assign_type { PRE_ASSIGN = 1, PRE_ASSIGN_FS } type; + char *val; +}; + +static struct pre_assign *preassigns = NULL; /* requested via -v or -F */ +static long numassigns = -1; /* how many of them */ + +static int disallow_var_assigns = FALSE; /* true for --exec */ + +static void add_preassign(enum assign_type type, char *val); + +#undef do_lint +#undef do_lint_old + +int do_traditional = FALSE; /* no gnu extensions, add traditional weirdnesses */ +int do_posix = FALSE; /* turn off gnu and unix extensions */ +int do_lint = FALSE; /* provide warnings about questionable stuff */ +int do_lint_old = FALSE; /* warn about stuff not in V7 awk */ +int do_intl = FALSE; /* dump locale-izable strings to stdout */ +int do_non_decimal_data = FALSE; /* allow octal/hex C style DATA. Use with caution! */ +int do_nostalgia = FALSE; /* provide a blast from the past */ +int do_intervals = FALSE; /* allow {...,...} in regexps, see resetup() */ +int do_profiling = FALSE; /* profile and pretty print the program */ +int do_dump_vars = FALSE; /* dump all global variables at end */ +int do_tidy_mem = FALSE; /* release vars when done */ +int do_optimize = TRUE; /* apply default optimizations */ +int do_binary = FALSE; /* hands off my data! */ +int do_sandbox = FALSE; /* sandbox mode - disable 'system' function & redirections */ +int use_lc_numeric = FALSE; /* obey locale for decimal point */ + +#if MBS_SUPPORT +int gawk_mb_cur_max; /* MB_CUR_MAX value, see comment in main() */ +#endif + +FILE *output_fp; /* default output for debugger */ +int output_is_tty = FALSE; /* control flushing of output */ + +/* default format for strftime(), available via PROCINFO */ +const char def_strftime_format[] = "%a %b %e %H:%M:%S %Z %Y"; + +extern const char *version_string; + +#if defined (HAVE_GETGROUPS) && defined(NGROUPS_MAX) && NGROUPS_MAX > 0 +GETGROUPS_T *groupset; /* current group set */ +int ngroups; /* size of said set */ +#endif + +void (*lintfunc)(const char *mesg, ...) = warning; + +/* + * Note: reserve -D for future use, to merge dgawk into gawk. + * Note: reserve -l for future use, for xgawk's -l option. + */ +static const struct option optab[] = { + { "traditional", no_argument, & do_traditional, 1 }, + { "lint", optional_argument, NULL, 'L' }, + { "lint-old", no_argument, & do_lint_old, 1 }, + { "optimize", no_argument, & do_optimize, 'O' }, + { "posix", no_argument, & do_posix, 1 }, + { "command", required_argument, NULL, 'R' }, + { "nostalgia", no_argument, & do_nostalgia, 1 }, + { "gen-pot", no_argument, & do_intl, 1 }, + { "non-decimal-data", no_argument, & do_non_decimal_data, 1 }, + { "profile", optional_argument, NULL, 'p' }, + { "copyright", no_argument, NULL, 'C' }, + { "field-separator", required_argument, NULL, 'F' }, + { "file", required_argument, NULL, 'f' }, + { "re-interval", no_argument, & do_intervals, 1 }, + { "source", required_argument, NULL, 'e' }, + { "dump-variables", optional_argument, NULL, 'd' }, + { "assign", required_argument, NULL, 'v' }, + { "version", no_argument, NULL, 'V' }, + { "help", no_argument, NULL, 'h' }, + { "exec", required_argument, NULL, 'E' }, + { "use-lc-numeric", no_argument, & use_lc_numeric, 1 }, + { "characters-as-bytes", no_argument, & do_binary, 'b' }, + { "sandbox", no_argument, & do_sandbox, 1 }, +#if defined(YYDEBUG) || defined(GAWKDEBUG) + { "parsedebug", no_argument, NULL, 'Y' }, +#endif + { NULL, 0, NULL, '\0' } +}; + +#ifdef NO_LINT +#define do_lint 0 +#define do_lint_old 0 +#endif + +/* main --- process args, parse program, run it, clean up */ + +int +main(int argc, char **argv) +{ + /* + * The + on the front tells GNU getopt not to rearrange argv. + * Note: reserve -D for future use, to merge dgawk into gawk. + * Note: reserve -l for future use, for xgawk's -l option. + */ + const char *optlist = "+F:f:v:W;m:bcCd::e:E:gh:L:nNOp::PrR:StVY"; + int stopped_early = FALSE; + int old_optind; + int i; + int c; + char *scan, *src; + char *extra_stack; + + /* do these checks early */ + do_tidy_mem = (getenv("TIDYMEM") != NULL); + +#ifdef HAVE_MCHECK_H +#ifdef HAVE_MTRACE + if (do_tidy_mem) + mtrace(); +#endif /* HAVE_MTRACE */ +#endif /* HAVE_MCHECK_H */ + +#if defined(LC_CTYPE) + setlocale(LC_CTYPE, ""); +#endif +#if defined(LC_COLLATE) + setlocale(LC_COLLATE, ""); +#endif +#if defined(LC_MESSAGES) + setlocale(LC_MESSAGES, ""); +#endif +#if defined(LC_NUMERIC) && defined(HAVE_LOCALE_H) + /* + * Force the issue here. According to POSIX 2001, decimal + * point is used for parsing source code and for command-line + * assignments and the locale value for processing input, + * number to string conversion, and printing output. + * + * 10/2005 --- see below also; we now only use the locale's + * decimal point if do_posix in effect. + * + * 9/2007: + * This is a mess. We need to get the locale's numeric info for + * the thousands separator for the %'d flag. + */ + setlocale(LC_NUMERIC, ""); + init_locale(& loc); + setlocale(LC_NUMERIC, "C"); +#endif +#if defined(LC_TIME) + setlocale(LC_TIME, ""); +#endif + +#if MBS_SUPPORT + /* + * In glibc, MB_CUR_MAX is actually a function. This value is + * tested *a lot* in many speed-critical places in gawk. Caching + * this value once makes a speed difference. + */ + gawk_mb_cur_max = MB_CUR_MAX; + /* Without MBS_SUPPORT, gawk_mb_cur_max is 1. */ + + /* init the cache for checking bytes if they're characters */ + init_btowc_cache(); +#endif + + (void) bindtextdomain(PACKAGE, LOCALEDIR); + (void) textdomain(PACKAGE); + + (void) signal(SIGFPE, catchsig); +#ifdef SIGBUS + (void) signal(SIGBUS, catchsig); +#endif + + (void) sigsegv_install_handler(catchsegv); +#define STACK_SIZE (16*1024) + emalloc(extra_stack, char *, STACK_SIZE, "main"); + (void) stackoverflow_install_handler(catchstackoverflow, extra_stack, STACK_SIZE); +#undef STACK_SIZE + + myname = gawk_name(argv[0]); + os_arg_fixup(&argc, &argv); /* emulate redirection, expand wildcards */ + + if (argc < 2) + usage(EXIT_FAILURE, stderr); + + /* Robustness: check that file descriptors 0, 1, 2 are open */ + init_fds(); + + /* init array handling. */ + array_init(); + + output_fp = stdout; + + /* we do error messages ourselves on invalid options */ + opterr = FALSE; + + /* copy argv before getopt gets to it; used to restart the debugger */ + save_argv(argc, argv); + + /* initialize global (main) execution context */ + push_context(new_context()); + + /* option processing. ready, set, go! */ + for (optopt = 0, old_optind = 1; + (c = getopt_long(argc, argv, optlist, optab, NULL)) != EOF; + optopt = 0, old_optind = optind) { + if (do_posix) + opterr = TRUE; + + switch (c) { + case 'F': + add_preassign(PRE_ASSIGN_FS, optarg); + break; + + case 'E': + disallow_var_assigns = TRUE; + /* fall through */ + case 'f': + /* + * Allow multiple -f options. + * This makes function libraries real easy. + * Most of the magic is in the scanner. + * + * The following is to allow for whitespace at the end + * of a #! /bin/gawk line in an executable file + */ + scan = optarg; + if (argv[optind-1] != optarg) + while (isspace((unsigned char) *scan)) + scan++; + src = (*scan == '\0' ? argv[optind++] : optarg); + (void) add_srcfile((src && src[0] == '-' && src[1] == '\0') ? + SRC_STDIN : SRC_FILE, + src, srcfiles, NULL, NULL); + + break; + + case 'v': + add_preassign(PRE_ASSIGN, optarg); + break; + + case 'm': + /* + * BWK awk extension. + * -mf nnn set # fields, gawk ignores + * -mr nnn set record length, ditto + * + * As of at least 10/2007, BWK awk also ignores it. + */ + if (do_lint) + lintwarn(_("`-m[fr]' option irrelevant in gawk")); + if (optarg[0] != 'r' && optarg[0] != 'f') + warning(_("-m option usage: `-m[fr] nnn'")); + break; + + case 'b': + do_binary = TRUE; + break; + + case 'c': + do_traditional = TRUE; + break; + + case 'C': + copyleft(); + break; + + case 'd': + do_dump_vars = TRUE; + if (optarg != NULL && optarg[0] != '\0') + varfile = optarg; + break; + + case 'e': + if (optarg[0] == '\0') + warning(_("empty argument to `-e/--source' ignored")); + else + (void) add_srcfile(SRC_CMDLINE, optarg, srcfiles, NULL, NULL); + break; + + case 'g': + do_intl = TRUE; + break; + + case 'h': + /* write usage to stdout, per GNU coding stds */ + usage(EXIT_SUCCESS, stdout); + break; + +#ifndef NO_LINT + case 'L': + do_lint = LINT_ALL; + if (optarg != NULL) { + if (strcmp(optarg, "fatal") == 0) + lintfunc = r_fatal; + else if (strcmp(optarg, "invalid") == 0) + do_lint = LINT_INVALID; + } + break; + + case 't': + do_lint_old = TRUE; + break; +#else + case 'L': + case 't': + break; +#endif + + case 'n': + do_non_decimal_data = TRUE; + break; + + case 'N': + use_lc_numeric = TRUE; + break; + + case 'O': + do_optimize++; + break; + + case 'p': + do_profiling = TRUE; + if (optarg != NULL) + set_prof_file(optarg); + else + set_prof_file(DEFAULT_PROFILE); + break; + + case 'P': + do_posix = TRUE; + break; + + case 'r': + do_intervals = TRUE; + break; + + case 'S': + do_sandbox = TRUE; + break; + + case 'V': + version(); + break; + + case 'W': /* gawk specific options - now in getopt_long */ + fprintf(stderr, _("%s: option `-W %s' unrecognized, ignored\n"), + argv[0], optarg); + break; + + case 0: + /* + * getopt_long found an option that sets a variable + * instead of returning a letter. Do nothing, just + * cycle around for the next one. + */ + break; + + case 'Y': + case 'R': +#if defined(YYDEBUG) || defined(GAWKDEBUG) + if (c == 'Y') { + yydebug = 2; + break; + } +#endif + if (c == 'R' && which_gawk == exe_debugging) { + if (optarg[0] != '\0') + command_file = optarg; + break; + } + /* if not debugging or dgawk, fall through */ + + case '?': + default: + /* + * If not posix, an unrecognized option stops argument + * processing so that it can go into ARGV for the awk + * program to see. This makes use of ``#! /bin/gawk -f'' + * easier. + * + * However, it's never simple. If optopt is set, + * an option that requires an argument didn't get the + * argument. We care because if opterr is 0, then + * getopt_long won't print the error message for us. + */ + if (! do_posix + && (optopt == '\0' || strchr(optlist, optopt) == NULL)) { + /* + * can't just do optind--. In case of an + * option with >= 2 letters, getopt_long + * won't have incremented optind. + */ + optind = old_optind; + stopped_early = TRUE; + goto out; + } else if (optopt != '\0') { + /* Use POSIX required message format */ + fprintf(stderr, + _("%s: option requires an argument -- %c\n"), + myname, optopt); + usage(EXIT_FAILURE, stderr); + } + /* else + let getopt print error message for us */ + break; + } + if (c == 'E') /* --exec ends option processing */ + break; + } +out: + + if (do_nostalgia) + nostalgia(); + + /* check for POSIXLY_CORRECT environment variable */ + if (! do_posix && getenv("POSIXLY_CORRECT") != NULL) { + do_posix = TRUE; + if (do_lint) + lintwarn( + _("environment variable `POSIXLY_CORRECT' set: turning on `--posix'")); + } + + if (do_posix) { + use_lc_numeric = TRUE; + if (do_traditional) /* both on command line */ + warning(_("`--posix' overrides `--traditional'")); + else + do_traditional = TRUE; + /* + * POSIX compliance also implies + * no GNU extensions either. + */ + } + + if (do_traditional && do_non_decimal_data) { + do_non_decimal_data = FALSE; + warning(_("`--posix'/`--traditional' overrides `--non-decimal-data'")); + } + + if (do_lint && os_is_setuid()) + warning(_("running %s setuid root may be a security problem"), myname); + +#if MBS_SUPPORT + if (do_binary) { + if (do_posix) + warning(_("`--posix' overrides `--binary'")); + else + gawk_mb_cur_max = 1; /* hands off my data! */ + } +#endif + + /* + * Force profiling if this is pgawk. + * Don't bother if the command line already set profiling up. + */ + if (! do_profiling) + init_profiling(& do_profiling, DEFAULT_PROFILE); + + /* load group set */ + init_groupset(); + + /* initialize the null string */ + Nnull_string = make_string("", 0); + Nnull_string->numbr = 0.0; + Nnull_string->type = Node_val; + Nnull_string->flags = (PERM|STRCUR|STRING|NUMCUR|NUMBER); + + /* + * Tell the regex routines how they should work. + * Do this before initializing variables, since + * they could want to do a regexp compile. + */ + resetup(); + + (void) grow_stack(); + + /* Set up the special variables */ + init_vars(); + + /* Set up the field variables */ + init_fields(); + + /* Now process the pre-assignments */ + for (i = 0; i <= numassigns; i++) { + if (preassigns[i].type == PRE_ASSIGN) + (void) arg_assign(preassigns[i].val, TRUE); + else /* PRE_ASSIGN_FS */ + cmdline_fs(preassigns[i].val); + efree(preassigns[i].val); + } + + if (preassigns != NULL) + efree(preassigns); + + if ((BINMODE & 1) != 0) + if (os_setbinmode(fileno(stdin), O_BINARY) == -1) + fatal(_("can't set binary mode on stdin (%s)"), strerror(errno)); + if ((BINMODE & 2) != 0) { + if (os_setbinmode(fileno(stdout), O_BINARY) == -1) + fatal(_("can't set binary mode on stdout (%s)"), strerror(errno)); + if (os_setbinmode(fileno(stderr), O_BINARY) == -1) + fatal(_("can't set binary mode on stderr (%s)"), strerror(errno)); + } + +#ifdef GAWKDEBUG + setbuf(stdout, (char *) NULL); /* make debugging easier */ +#endif + if (os_isatty(fileno(stdout))) + output_is_tty = TRUE; + /* No -f or --source options, use next arg */ + if (srcfiles->next == srcfiles) { + if (optind > argc - 1 || stopped_early) /* no args left or no program */ + usage(EXIT_FAILURE, stderr); + (void) add_srcfile(SRC_CMDLINE, argv[optind], srcfiles, NULL, NULL); + optind++; + } + + init_args(optind, argc, + do_posix ? argv[0] : myname, + argv); + +#if defined(LC_NUMERIC) + /* + * FRAGILE! CAREFUL! + * Pre-initing the variables with arg_assign() can change the + * locale. Force it to C before parsing the program. + */ + setlocale(LC_NUMERIC, "C"); +#endif + /* Read in the program */ + if (parse_program(&code_block) != 0) + exit(EXIT_FAILURE); + + if (do_intl) + exit(EXIT_SUCCESS); + + if (do_lint) + shadow_funcs(); + + if (do_lint && code_block->nexti->opcode == Op_atexit) + lintwarn(_("no program text at all!")); + + init_profiling_signals(); + +#if defined(LC_NUMERIC) + /* + * See comment above about using locale's decimal point. + * + * 10/2005: + * Bitter experience teaches us that most people the world over + * use period as the decimal point, not whatever their locale + * uses. Thus, only use the locale's decimal point if being + * posixly anal-retentive. + * + * 7/2007: + * Be a little bit kinder. Allow the --use-lc-numeric option + * to also use the local decimal point. This avoids the draconian + * strictness of POSIX mode if someone just wants to parse their + * data using the local decimal point. + */ + if (use_lc_numeric) + setlocale(LC_NUMERIC, ""); +#endif + + interpret(code_block); + + if (do_profiling) { + dump_prog(code_block); + dump_funcs(); + } + + if (do_dump_vars) + dump_vars(varfile); + + if (do_tidy_mem) + release_all_vars(); + + /* keep valgrind happier */ + if (extra_stack) + efree(extra_stack); + + exit(exit_val); /* more portable */ + return exit_val; /* to suppress warnings */ +} + +/* add_preassign --- add one element to preassigns */ + +static void +add_preassign(enum assign_type type, char *val) +{ + static long alloc_assigns; /* for how many are allocated */ + +#define INIT_SRC 4 + + ++numassigns; + + if (preassigns == NULL) { + emalloc(preassigns, struct pre_assign *, + INIT_SRC * sizeof(struct pre_assign), "add_preassign"); + alloc_assigns = INIT_SRC; + } else if (numassigns >= alloc_assigns) { + alloc_assigns *= 2; + erealloc(preassigns, struct pre_assign *, + alloc_assigns * sizeof(struct pre_assign), "add_preassigns"); + } + preassigns[numassigns].type = type; + preassigns[numassigns].val = estrdup(val, strlen(val)); + +#undef INIT_SRC +} + +/* usage --- print usage information and exit */ + +static void +usage(int exitval, FILE *fp) +{ + /* Not factoring out common stuff makes it easier to translate. */ + fprintf(fp, _("Usage: %s [POSIX or GNU style options] -f progfile [--] file ...\n"), + myname); + fprintf(fp, _("Usage: %s [POSIX or GNU style options] [--] %cprogram%c file ...\n"), + myname, quote, quote); + + /* GNU long options info. This is too many options. */ + + fputs(_("POSIX options:\t\tGNU long options: (standard)\n"), fp); + fputs(_("\t-f progfile\t\t--file=progfile\n"), fp); + fputs(_("\t-F fs\t\t\t--field-separator=fs\n"), fp); + fputs(_("\t-v var=val\t\t--assign=var=val\n"), fp); + fputs(_("Short options:\t\tGNU long options: (extensions)\n"), fp); + fputs(_("\t-b\t\t\t--characters-as-bytes\n"), fp); + fputs(_("\t-c\t\t\t--traditional\n"), fp); + fputs(_("\t-C\t\t\t--copyright\n"), fp); + fputs(_("\t-d[file]\t\t--dump-variables[=file]\n"), fp); + fputs(_("\t-e 'program-text'\t--source='program-text'\n"), fp); + fputs(_("\t-E file\t\t\t--exec=file\n"), fp); + fputs(_("\t-g\t\t\t--gen-pot\n"), fp); + fputs(_("\t-h\t\t\t--help\n"), fp); + fputs(_("\t-L [fatal]\t\t--lint[=fatal]\n"), fp); + fputs(_("\t-n\t\t\t--non-decimal-data\n"), fp); + fputs(_("\t-N\t\t\t--use-lc-numeric\n"), fp); + fputs(_("\t-O\t\t\t--optimize\n"), fp); + fputs(_("\t-p[file]\t\t--profile[=file]\n"), fp); + fputs(_("\t-P\t\t\t--posix\n"), fp); + fputs(_("\t-r\t\t\t--re-interval\n"), fp); + if (which_gawk == exe_debugging) + fputs(_("\t-R file\t\t\t--command=file\n"), fp); + fputs(_("\t-S\t\t\t--sandbox\n"), fp); + fputs(_("\t-t\t\t\t--lint-old\n"), fp); + fputs(_("\t-V\t\t\t--version\n"), fp); +#ifdef NOSTALGIA + fputs(_("\t-W nostalgia\t\t--nostalgia\n"), fp); +#endif +#ifdef GAWKDEBUG + fputs(_("\t-Y\t\t--parsedebug\n"), fp); +#endif + + /* This is one string to make things easier on translators. */ + /* TRANSLATORS: --help output 5 (end) + TRANSLATORS: the placeholder indicates the bug-reporting address + for this application. Please add _another line_ with the + address for translation bugs. + no-wrap */ + fputs(_("\nTo report bugs, see node `Bugs' in `gawk.info', which is\n\ +section `Reporting Problems and Bugs' in the printed version.\n\n"), fp); + + /* ditto */ + fputs(_("gawk is a pattern scanning and processing language.\n\ +By default it reads standard input and writes standard output.\n\n"), fp); + + /* ditto */ + fputs(_("Examples:\n\tgawk '{ sum += $1 }; END { print sum }' file\n\ +\tgawk -F: '{ print $1 }' /etc/passwd\n"), fp); + + fflush(fp); + + if (ferror(fp)) { + if (fp == stdout) + warning(_("error writing standard output (%s)"), strerror(errno)); + exit(EXIT_FAILURE); + } + + exit(exitval); +} + +/* copyleft --- print out the short GNU copyright information */ + +static void +copyleft() +{ + static const char blurb_part1[] = + N_("Copyright (C) 1989, 1991-%d Free Software Foundation.\n\ +\n\ +This program is free software; you can redistribute it and/or modify\n\ +it under the terms of the GNU General Public License as published by\n\ +the Free Software Foundation; either version 3 of the License, or\n\ +(at your option) any later version.\n\ +\n"); + static const char blurb_part2[] = + N_("This program is distributed in the hope that it will be useful,\n\ +but WITHOUT ANY WARRANTY; without even the implied warranty of\n\ +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n\ +GNU General Public License for more details.\n\ +\n"); + static const char blurb_part3[] = + N_("You should have received a copy of the GNU General Public License\n\ +along with this program. If not, see http://www.gnu.org/licenses/.\n"); + + /* multiple blurbs are needed for some brain dead compilers. */ + printf(_(blurb_part1), UPDATE_YEAR); /* Last update year */ + fputs(_(blurb_part2), stdout); + fputs(_(blurb_part3), stdout); + fflush(stdout); + + if (ferror(stdout)) { + warning(_("error writing standard output (%s)"), strerror(errno)); + exit(EXIT_FAILURE); + } + + exit(EXIT_SUCCESS); +} + +/* cmdline_fs --- set FS from the command line */ + +static void +cmdline_fs(char *str) +{ + NODE **tmp; + + tmp = &FS_node->var_value; + unref(*tmp); + /* + * Only if in full compatibility mode check for the stupid special + * case so -F\t works as documented in awk book even though the shell + * hands us -Ft. Bleah! + * + * Thankfully, POSIX didn't propagate this "feature". + */ + if (str[0] == 't' && str[1] == '\0') { + if (do_lint) + lintwarn(_("-Ft does not set FS to tab in POSIX awk")); + if (do_traditional && ! do_posix) + str[0] = '\t'; + } + *tmp = make_str_node(str, strlen(str), SCAN); /* do process escapes */ + set_FS(); +} + +/* init_args --- set up ARGV from stuff on the command line */ + +static void +init_args(int argc0, int argc, const char *argv0, char **argv) +{ + int i, j; + NODE **aptr; + NODE *tmp; + + ARGV_node = install_symbol(estrdup("ARGV", 4), mk_symbol(Node_var_array, (NODE *) NULL)); + tmp = make_number(0.0); + aptr = assoc_lookup(ARGV_node, tmp, FALSE); + unref(tmp); + unref(*aptr); + *aptr = make_string(argv0, strlen(argv0)); + (*aptr)->flags |= MAYBE_NUM; + for (i = argc0, j = 1; i < argc; i++, j++) { + tmp = make_number((AWKNUM) j); + aptr = assoc_lookup(ARGV_node, tmp, FALSE); + unref(tmp); + unref(*aptr); + *aptr = make_string(argv[i], strlen(argv[i])); + (*aptr)->flags |= MAYBE_NUM; + } + + ARGC_node = install_symbol(estrdup("ARGC", 4), + mk_symbol(Node_var, make_number((AWKNUM) j))); +} + +/* + * Set all the special variables to their initial values. + * Note that some of the variables that have set_FOO routines should + * *N*O*T* have those routines called upon initialization, and thus + * they have NULL entries in that field. This is notably true of FS + * and IGNORECASE. + */ + +struct varinit { + NODE **spec; + const char *name; + const char *strval; + AWKNUM numval; + Func_ptr update; + Func_ptr assign; + int do_assign; + int flags; +#define NO_INSTALL 0x01 +#define NON_STANDARD 0x02 +}; + +static const struct varinit varinit[] = { +{NULL, "ARGC", NULL, 0, NULL, NULL, FALSE, NO_INSTALL }, +{&ARGIND_node, "ARGIND", NULL, 0, NULL, NULL, FALSE, NON_STANDARD }, +{NULL, "ARGV", NULL, 0, NULL, NULL, FALSE, NO_INSTALL }, +{&BINMODE_node, "BINMODE", NULL, 0, NULL, set_BINMODE, FALSE, NON_STANDARD }, +{&CONVFMT_node, "CONVFMT", "%.6g", 0, NULL, set_CONVFMT,TRUE, 0 }, +{NULL, "ENVIRON", NULL, 0, NULL, NULL, FALSE, NO_INSTALL }, +{&ERRNO_node, "ERRNO", "", 0, NULL, NULL, FALSE, NON_STANDARD }, +{&FIELDWIDTHS_node, "FIELDWIDTHS", "", 0, NULL, set_FIELDWIDTHS, FALSE, NON_STANDARD }, +{&FILENAME_node, "FILENAME", "", 0, NULL, NULL, FALSE, 0 }, +{&FNR_node, "FNR", NULL, 0, update_FNR, set_FNR, TRUE, 0 }, +{&FS_node, "FS", " ", 0, NULL, set_FS, FALSE, 0 }, +{&FPAT_node, "FPAT", "[^[:space:]]+", 0, NULL, set_FPAT, FALSE, NON_STANDARD }, +{&IGNORECASE_node, "IGNORECASE", NULL, 0, NULL, set_IGNORECASE, FALSE, NON_STANDARD }, +{&LINT_node, "LINT", NULL, 0, NULL, set_LINT, FALSE, NON_STANDARD }, +{&NF_node, "NF", NULL, -1, update_NF, set_NF, FALSE, 0 }, +{&NR_node, "NR", NULL, 0, update_NR, set_NR, TRUE, 0 }, +{&OFMT_node, "OFMT", "%.6g", 0, NULL, set_OFMT, TRUE, 0 }, +{&OFS_node, "OFS", " ", 0, NULL, set_OFS, TRUE, 0 }, +{&ORS_node, "ORS", "\n", 0, NULL, set_ORS, TRUE, 0 }, +{NULL, "PROCINFO", NULL, 0, NULL, NULL, FALSE, NO_INSTALL | NON_STANDARD }, +{&RLENGTH_node, "RLENGTH", NULL, 0, NULL, NULL, FALSE, 0 }, +{&RS_node, "RS", "\n", 0, NULL, set_RS, TRUE, 0 }, +{&RSTART_node, "RSTART", NULL, 0, NULL, NULL, FALSE, 0 }, +{&RT_node, "RT", "", 0, NULL, NULL, FALSE, NON_STANDARD }, +{&SUBSEP_node, "SUBSEP", "\034", 0, NULL, set_SUBSEP, TRUE, 0 }, +{&TEXTDOMAIN_node, "TEXTDOMAIN", "messages", 0, NULL, set_TEXTDOMAIN, TRUE, NON_STANDARD }, +{0, NULL, NULL, 0, NULL, NULL, FALSE, 0 }, +}; + +/* init_vars --- actually initialize everything in the symbol table */ + +static void +init_vars() +{ + const struct varinit *vp; + NODE *n; + + for (vp = varinit; vp->name != NULL; vp++) { + if ((vp->flags & NO_INSTALL) != 0) + continue; + n = mk_symbol(Node_var, vp->strval == NULL + ? make_number(vp->numval) + : make_string(vp->strval, strlen(vp->strval))); + n->var_assign = (Func_ptr) vp->assign; + n->var_update = (Func_ptr) vp->update; + + *(vp->spec) = install_symbol(estrdup(vp->name, strlen(vp->name)), n); + if (vp->do_assign) + (*(vp->assign))(); + } + + /* Set up deferred variables (loaded only when accessed). */ + if (! do_traditional) + register_deferred_variable("PROCINFO", load_procinfo); + register_deferred_variable("ENVIRON", load_environ); +} + +/* load_environ --- populate the ENVIRON array */ + +static NODE * +load_environ() +{ +#if ! (defined(VMS) && defined(__DECC)) + extern char **environ; +#endif + char *var, *val; + NODE **aptr; + int i; + NODE *tmp; + + ENVIRON_node = install_symbol(estrdup("ENVIRON", 7), + mk_symbol(Node_var_array, (NODE *) NULL)); + + for (i = 0; environ[i] != NULL; i++) { + static char nullstr[] = ""; + + var = environ[i]; + val = strchr(var, '='); + if (val != NULL) + *val++ = '\0'; + else + val = nullstr; + tmp = make_string(var, strlen(var)); + aptr = assoc_lookup(ENVIRON_node, tmp, FALSE); + unref(tmp); + unref(*aptr); + *aptr = make_string(val, strlen(val)); + (*aptr)->flags |= MAYBE_NUM; + + /* restore '=' so that system() gets a valid environment */ + if (val != nullstr) + *--val = '='; + } + /* + * Put AWKPATH into ENVIRON if it's not there. + * This allows querying it from within awk programs. + */ + tmp = make_string("AWKPATH", 7); + if (! in_array(ENVIRON_node, tmp)) { + /* + * On VMS, environ[] only holds a subset of what getenv() can + * find, so look AWKPATH up before resorting to default path. + */ + val = getenv("AWKPATH"); + if (val == NULL) + val = defpath; + aptr = assoc_lookup(ENVIRON_node, tmp, FALSE); + unref(*aptr); + *aptr = make_string(val, strlen(val)); + } + unref(tmp); + return ENVIRON_node; +} + +/* load_procinfo --- populate the PROCINFO array */ + +static NODE * +load_procinfo() +{ +#if defined (HAVE_GETGROUPS) && defined(NGROUPS_MAX) && NGROUPS_MAX > 0 + int i; + char name[100]; +#endif + AWKNUM value; + + PROCINFO_node = install_symbol(estrdup("PROCINFO", 8), + mk_symbol(Node_var_array, (NODE *) NULL)); + + update_PROCINFO_str("version", VERSION); + update_PROCINFO_str("strftime", def_strftime_format); + +#ifdef GETPGRP_VOID +#define getpgrp_arg() /* nothing */ +#else +#define getpgrp_arg() getpid() +#endif + + value = getpgrp(getpgrp_arg()); + update_PROCINFO_num("pgrpid", value); + + /* + * Could put a lot of this into a table, but then there's + * portability problems declaring all the functions. So just + * do it the slow and stupid way. Sigh. + */ + + value = getpid(); + update_PROCINFO_num("pid", value); + + value = getppid(); + update_PROCINFO_num("ppid", value); + + value = getuid(); + update_PROCINFO_num("uid", value); + + value = geteuid(); + update_PROCINFO_num("euid", value); + + value = getgid(); + update_PROCINFO_num("gid", value); + + value = getegid(); + update_PROCINFO_num("egid", value); + + switch (current_field_sep()) { + case Using_FIELDWIDTHS: + update_PROCINFO_str("FS", "FIELDWIDTHS"); + break; + case Using_FPAT: + update_PROCINFO_str("FS", "FPAT"); + break; + case Using_FS: + update_PROCINFO_str("FS", "FS"); + break; + default: + fatal(_("unknown value for field spec: %d\n"), + current_field_sep()); + break; + } + + +#if defined (HAVE_GETGROUPS) && defined(NGROUPS_MAX) && NGROUPS_MAX > 0 + for (i = 0; i < ngroups; i++) { + sprintf(name, "group%d", i + 1); + value = groupset[i]; + update_PROCINFO_num(name, value); + } + if (groupset) { + efree(groupset); + groupset = NULL; + } +#endif + return PROCINFO_node; +} + +/* is_std_var --- return true if a variable is a standard variable */ + +int +is_std_var(const char *var) +{ + const struct varinit *vp; + + for (vp = varinit; vp->name != NULL; vp++) { + if (strcmp(vp->name, var) == 0) { + if ((do_traditional || do_posix) && (vp->flags & NON_STANDARD) != 0) + return FALSE; + + return TRUE; + } + } + + return FALSE; +} + + +/* get_spec_varname --- return the name of a special variable + with the given assign or update routine. +*/ + +const char * +get_spec_varname(Func_ptr fptr) +{ + const struct varinit *vp; + + if (! fptr) + return NULL; + for (vp = varinit; vp->name != NULL; vp++) { + if (vp->assign == fptr || vp->update == fptr) + return vp->name; + } + return NULL; +} + + +/* arg_assign --- process a command-line assignment */ + +int +arg_assign(char *arg, int initing) +{ + char *cp, *cp2; + int badvar; + NODE *var; + NODE *it; + NODE **lhs; + long save_FNR; + + if (! initing && disallow_var_assigns) + return FALSE; /* --exec */ + + cp = strchr(arg, '='); + + if (cp == NULL) { + if (! initing) + return FALSE; /* This is file name, not assignment. */ + + fprintf(stderr, + _("%s: `%s' argument to `-v' not in `var=value' form\n\n"), + myname, arg); + usage(EXIT_FAILURE, stderr); + } + + *cp++ = '\0'; + + /* avoid false source indications in a fatal message */ + source = NULL; + sourceline = 0; + save_FNR = FNR; + FNR = 0; + + /* first check that the variable name has valid syntax */ + badvar = FALSE; + if (! isalpha((unsigned char) arg[0]) && arg[0] != '_') + badvar = TRUE; + else + for (cp2 = arg+1; *cp2; cp2++) + if (! isalnum((unsigned char) *cp2) && *cp2 != '_') { + badvar = TRUE; + break; + } + + if (badvar) { + if (initing) + fatal(_("`%s' is not a legal variable name"), arg); + + if (do_lint) + lintwarn(_("`%s' is not a variable name, looking for file `%s=%s'"), + arg, arg, cp); + } else { + if (check_special(arg) >= 0) + fatal(_("cannot use gawk builtin `%s' as variable name"), arg); + + if (! initing) { + var = lookup(arg); + if (var != NULL && var->type == Node_func) + fatal(_("cannot use function `%s' as variable name"), arg); + } + + /* + * BWK awk expands escapes inside assignments. + * This makes sense, so we do it too. + */ + it = make_str_node(cp, strlen(cp), SCAN); + it->flags |= MAYBE_NUM; +#ifdef LC_NUMERIC + /* + * See comment above about locale decimal point. + */ + if (do_posix) + setlocale(LC_NUMERIC, "C"); + (void) force_number(it); + if (do_posix) + setlocale(LC_NUMERIC, ""); +#endif /* LC_NUMERIC */ + + /* + * since we are restoring the original text of ARGV later, + * need to copy the variable name part if we don't want + * name like v=abc instead of just v in var->vname + */ + + cp2 = estrdup(arg, cp - arg); /* var name */ + + var = variable(cp2, Node_var); + if (var == NULL) /* error */ + exit(EXIT_FATAL); + if (var->type == Node_var && var->var_update) + var->var_update(); + lhs = get_lhs(var, FALSE); + unref(*lhs); + *lhs = it; + /* check for set_FOO() routine */ + if (var->type == Node_var && var->var_assign) + var->var_assign(); + } + + if (! initing) + *--cp = '='; /* restore original text of ARGV */ + FNR = save_FNR; + return ! badvar; +} + +/* catchsig --- catch signals */ + +static RETSIGTYPE +catchsig(int sig) +{ + if (sig == SIGFPE) { + fatal(_("floating point exception")); + } else if (sig == SIGSEGV +#ifdef SIGBUS + || sig == SIGBUS +#endif + ) { + set_loc(__FILE__, __LINE__); + msg(_("fatal error: internal error")); + /* fatal won't abort() if not compiled for debugging */ + abort(); + } else + cant_happen(); + /* NOTREACHED */ +} + +#ifdef HAVE_LIBSIGSEGV +/* catchsegv --- for use with libsigsegv */ + +static int +catchsegv(void *fault_address, int serious) +{ + set_loc(__FILE__, __LINE__); + msg(_("fatal error: internal error: segfault")); + abort(); + /*NOTREACHED*/ + return 0; +} + +/* catchstackoverflow --- for use with libsigsegv */ + +static void +catchstackoverflow(int emergency, stackoverflow_context_t scp) +{ + set_loc(__FILE__, __LINE__); + msg(_("fatal error: internal error: stack overflow")); + abort(); + /*NOTREACHED*/ + return; +} +#endif /* HAVE_LIBSIGSEGV */ + +/* nostalgia --- print the famous error message and die */ + +static void +nostalgia() +{ + /* + * N.B.: This string is not gettextized, on purpose. + * So there. + */ + fprintf(stderr, "awk: bailing out near line 1\n"); + fflush(stderr); + abort(); +} + +/* version --- print version message */ + +static void +version() +{ + printf("%s\n", version_string); + /* + * Per GNU coding standards, print copyright info, + * then exit successfully, do nothing else. + */ + copyleft(); + exit(EXIT_SUCCESS); +} + +/* init_fds --- check for 0, 1, 2, open on /dev/null if possible */ + +static void +init_fds() +{ + struct stat sbuf; + int fd; + int newfd; + char const *const opposite_mode[] = {"w", "r", "r"}; + + /* maybe no stderr, don't bother with error mesg */ + for (fd = 0; fd <= 2; fd++) { + if (fstat(fd, &sbuf) < 0) { +#if MAKE_A_HEROIC_EFFORT + if (do_lint) + lintwarn(_("no pre-opened fd %d"), fd); +#endif + newfd = devopen("/dev/null", opposite_mode[fd]); + /* turn off some compiler warnings "set but not used" */ + newfd += 0; +#ifdef MAKE_A_HEROIC_EFFORT + if (do_lint && newfd < 0) + lintwarn(_("could not pre-open /dev/null for fd %d"), fd); +#endif + } + } +} + +/* init_groupset --- initialize groupset */ + +static void +init_groupset() +{ +#if defined(HAVE_GETGROUPS) && defined(NGROUPS_MAX) && NGROUPS_MAX > 0 +#ifdef GETGROUPS_NOT_STANDARD + /* For systems that aren't standards conformant, use old way. */ + ngroups = NGROUPS_MAX; +#else + /* + * If called with 0 for both args, return value is + * total number of groups. + */ + ngroups = getgroups(0, NULL); +#endif + /* If an error or no groups, just give up and get on with life. */ + if (ngroups <= 0) + return; + + /* fill in groups */ + emalloc(groupset, GETGROUPS_T *, ngroups * sizeof(GETGROUPS_T), "init_groupset"); + + ngroups = getgroups(ngroups, groupset); + /* same thing here, give up but keep going */ + if (ngroups == -1) { + efree(groupset); + ngroups = 0; + groupset = NULL; + } +#endif +} + +/* estrdup --- duplicate a string */ + +char * +estrdup(const char *str, size_t len) +{ + char *s; + emalloc(s, char *, len + 1, "estrdup"); + memcpy(s, str, len); + s[len] = '\0'; + return s; +} + +#if defined(HAVE_LOCALE_H) + +/* init_locale --- initialize locale info. */ + +/* + * On some operating systems, the pointers in the struct returned + * by localeconv() can become dangling pointers after a call to + * setlocale(). So we do a deep copy. + * + * Thanks to KIMURA Koichi . + */ + +static void +init_locale(struct lconv *l) +{ + struct lconv *t; + + t = localeconv(); + *l = *t; + l->thousands_sep = estrdup(t->thousands_sep, strlen(t->thousands_sep)); + l->decimal_point = estrdup(t->decimal_point, strlen(t->decimal_point)); + l->grouping = estrdup(t->grouping, strlen(t->grouping)); + l->int_curr_symbol = estrdup(t->int_curr_symbol, strlen(t->int_curr_symbol)); + l->currency_symbol = estrdup(t->currency_symbol, strlen(t->currency_symbol)); + l->mon_decimal_point = estrdup(t->mon_decimal_point, strlen(t->mon_decimal_point)); + l->mon_thousands_sep = estrdup(t->mon_thousands_sep, strlen(t->mon_thousands_sep)); + l->mon_grouping = estrdup(t->mon_grouping, strlen(t->mon_grouping)); + l->positive_sign = estrdup(t->positive_sign, strlen(t->positive_sign)); + l->negative_sign = estrdup(t->negative_sign, strlen(t->negative_sign)); +} +#endif /* LOCALE_H */ + +/* save_argv --- save argv array */ + +static void +save_argv(int argc, char **argv) +{ + int i; + + emalloc(d_argv, char **, (argc + 1) * sizeof(char *), "save_argv"); + for (i = 0; i < argc; i++) + d_argv[i] = estrdup(argv[i], strlen(argv[i])); + d_argv[argc] = NULL; +} + +/* + * update_global_values --- make sure the symbol table has correct values. + * Called from the grammar before dumping values. + */ + +void +update_global_values() +{ + const struct varinit *vp; + + for (vp = varinit; vp->name; vp++) { + if (vp->update != NULL) + vp->update(); + } +} diff --git a/mbsupport.h b/mbsupport.h new file mode 100644 index 0000000..db6788c --- /dev/null +++ b/mbsupport.h @@ -0,0 +1,94 @@ +/* + * mbsupport.h --- Localize determination of whether we have multibyte stuff. + */ + +/* + * Copyright (C) 2004, 2005, 2011, 2012 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* + * This file is needed because we test for i18n support in 3 different + * places, and we want a consistent definition in all of them. Following + * the ``Don't Repeat Yourself'' principle from "The Pragmatic Programmer", + * we centralize the tests here. + * + * This test is the union of all the current tests. + */ + +#ifdef HAVE_STDLIB_H +#include +#endif + +#ifndef NO_MBSUPPORT + +#if defined(HAVE_ISWCTYPE) \ + && defined(HAVE_LOCALE_H) \ + && (defined(HAVE_BTOWC) || defined(ZOS_USS)) \ + && defined(HAVE_MBRLEN) \ + && defined(HAVE_MBRTOWC) \ + && defined(HAVE_WCHAR_H) \ + && defined(HAVE_WCRTOMB) \ + && defined(HAVE_WCSCOLL) \ + && defined(HAVE_WCTYPE) \ + && defined(HAVE_WCTYPE_H) \ + && defined(HAVE_WCTYPE_T) \ + && defined(HAVE_WINT_T) \ + && defined(HAVE_ISWLOWER) \ + && defined(HAVE_ISWUPPER) \ + && defined(HAVE_TOWLOWER) \ + && defined(HAVE_TOWUPPER) \ + && (defined(HAVE_STDLIB_H) && defined(MB_CUR_MAX)) \ +/* We can handle multibyte strings. */ +# define MBS_SUPPORT 1 +#else +# define MBS_SUPPORT 0 +#endif + +#else /* NO_MBSUPPORT is defined */ +# define MBS_SUPPORT 0 +#endif + +#if ! MBS_SUPPORT +# undef MB_CUR_MAX +# define MB_CUR_MAX 1 + +/* All this glop is for dfa.c. Bleah. */ + +#ifndef DJGPP +#define wchar_t char +#endif + +#define wctype_t int +#define wint_t int +#define mbstate_t int +#define WEOF EOF +#define towupper toupper +#define towlower tolower +#ifndef DJGPP +#define btowc(x) ((int)x) +#endif +#define iswalnum isalnum +#define iswalpha isalpha +#define iswupper isupper + +extern wctype_t wctype(const char *name); +extern int iswctype(wint_t wc, wctype_t desc); +extern int wcscoll(const wchar_t *ws1, const wchar_t *ws2); +#endif diff --git a/missing b/missing new file mode 100755 index 0000000..1c8ff70 --- /dev/null +++ b/missing @@ -0,0 +1,367 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. + +scriptversion=2006-05-10.23 + +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006 +# Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: +sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' +sed_minuso='s/.* -o \([^ ]*\).*/\1/p' + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +msg="missing on your system" + +case $1 in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + # Exit code 63 means version mismatch. This often happens + # when the user try to use an ancient version of a tool on + # a file that requires a minimum version. In this case we + # we should proceed has if the program had been absent, or + # if --run hadn't been passed. + if test $? = 63; then + run=: + msg="probably too old" + fi + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + autom4te touch the output file, or create a stub one + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch] + +Send bug reports to ." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + +esac + +# Now exit if we have it, but it failed. Also exit now if we +# don't have it and --version was passed (most likely to detect +# the program). +case $1 in + lex|yacc) + # Not GNU programs, they don't have --version. + ;; + + tar) + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + exit 1 + fi + ;; + + *) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + # Could not run --version or --help. This is probably someone + # running `$TOOL --version' or `$TOOL --help' to check whether + # $TOOL exists and not knowing $TOOL uses missing. + exit 1 + fi + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case $1 in + aclocal*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case $f in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te) + echo 1>&2 "\ +WARNING: \`$1' is needed, but is $msg. + You might have modified some files without having the + proper tools for further handling them. + You can get \`$1' as part of \`Autoconf' from any GNU + archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' $msg. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if test $# -ne 1; then + eval LASTARG="\${$#}" + case $LASTARG in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if test ! -f y.tab.h; then + echo >y.tab.h + fi + if test ! -f y.tab.c; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if test $# -ne 1; then + eval LASTARG="\${$#}" + case $LASTARG in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if test ! -f lex.yy.c; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi + ;; + + makeinfo) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + # The file to touch is that specified with -o ... + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -z "$file"; then + # ... or it is the one specified with @setfilename ... + infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n ' + /^@setfilename/{ + s/.* \([^ ]*\) *$/\1/ + p + q + }' $infile` + # ... or it is derived from the source name (dir/f.texi becomes f.info) + test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info + fi + # If the file does not exist, the user really needs makeinfo; + # let's fail without touching anything. + test -f $file || exit 1 + touch $file + ;; + + tar) + shift + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar "$@" && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar "$@" && exit 0 + fi + firstarg="$1" + if shift; then + case $firstarg in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + case $firstarg in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and is $msg. + You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequisites for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/missing_d/COPYING.LIB b/missing_d/COPYING.LIB new file mode 100644 index 0000000..778d0bb --- /dev/null +++ b/missing_d/COPYING.LIB @@ -0,0 +1,482 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/missing_d/ChangeLog b/missing_d/ChangeLog new file mode 100644 index 0000000..c6913bc --- /dev/null +++ b/missing_d/ChangeLog @@ -0,0 +1,17 @@ +2012-03-28 Arnold D. Robbins + + * 4.0.1: Release tar ball made. + +2011-11-02 Pat Rankin + + * wcmisc.c: Make code be conditional upon corresponding !HAVE_WCxxx. + +2011-11-01 Arnold D. Robbins + + * wcmisc.c: New file. + +2011-06-23 Arnold D. Robbins + + * ChangeLog.0: Rotated ChangeLog into this file. + * ChangeLog: Created anew for gawk 4.0.0 and on. + * 4.0.0: Release tar ball made. diff --git a/missing_d/ChangeLog.0 b/missing_d/ChangeLog.0 new file mode 100644 index 0000000..4eaa802 --- /dev/null +++ b/missing_d/ChangeLog.0 @@ -0,0 +1,171 @@ +Mon Nov 29 20:09:40 2010 Eli Zaretskii + + * strftime.c : Don't declare for __MINGW32__. + +Thu Nov 25 21:16:58 2010 Arnold D. Robbins + + * strcoll.c: New file. + * memcmp.c, memcpy.c, memset.c, strchr.c, strtod.c: Remove + `register' keyword everywhere, as in mainline code. + +Sun Jun 6 21:44:19 2010 Arnold D. Robbins + + * getaddrinfo.h: Add undef for addrinfo, freeaddrinfo, and + getaddrinfo, just in case. + +Thu May 6 20:55:14 2010 Arnold D. Robbins + + * Release 3.1.8: Release tar file made. + +Fri Apr 30 11:38:49 2010 Arnold D. Robbins + + * snprintf.c: Add check to undef restrict and define as empty. + Allows !@#$%^&*() OSF/1 to compile and build. + +Mon Apr 26 19:48:07 2010 Arnold D. Robbins + + * snprintf.c (vsnprintf): Undo change of 21 April. vsnprintf + is needed for vprintf in that file. + +Wed Apr 21 23:32:51 2010 Arnold D. Robbins + + * snprintf.c (vsnprintf): Don't define if not STDARG_H. + Gawk doesn't use it. + +Fri Mar 19 09:19:17 2010 Arnold D. Robbins + + * usleep.c: New file. + +Tue Jul 21 22:28:56 2009 Arnold D. Robbins + + * Release 3.1.7: Release tar file made. + +Mon Oct 22 08:49:05 2007 Arnold D. Robbins + + * Release 3.1.6: Release tar file made. + +Sun Oct 14 19:37:33 2007 Arnold D. Robbins + + * snprintf.c (safe_tmpfile): If have `atexit', add call to a function + that closes the open fp and unlinks the file. Needed mainly for + PC which can't do Unix-style unlink-after-open. + +Tue Oct 2 22:12:13 2007 Arnold D. Robbins + + * snprintf.c (safe_tmpfile): Add use of TMPDIR and TEMP environment + variables for systems that may not have a /tmp. For MS systems + do unlink at close. Thanks to Eli Zaretskii and Scott Deifik + for motivating me to do the right thing. + +Fri Apr 13 06:05:05 2007 Arnold D. Robbins + + * getaddrinfo.c: Add test for HAVE_SOCKETS with error message + if not. Thanks to Pat Rankin. + +Sun Apr 8 16:15:27 2007 Arnold D. Robbins + + * getaddrinfo.c: Add include of , and . + +Fri Apr 6 13:23:04 2007 Arnold D. Robbins + + * memmove.c.BSD, strncasecmp.c.BSD: Removed so that they won't make + their way into a tarball; these were the original versions from BSD + that were in use until the Savannah CVS archive went into place; see + the entry from August 25, 2006. + +Thu Apr 5 17:01:15 2007 Arnold D. Robbins + + * sprintf.c (snprintf): Fix typo and call vsnprintf + instead of calling self recursively. Thanks to Pat Rankin. + +Tue Feb 27 20:58:01 2007 Arnold D. Robbins + + * snprintf.c: Change names from gawk_xxx to real xxx. + +Mon Jan 15 14:34:30 2007 Arnold D. Robbins + + * getaddrinfo.h, getaddrinfo.c: New files, based on + submission by Jan Pazdziora . + +Fri Sep 15 15:05:09 2006 Arnold D. Robbins + + * strncasecmp.c, memmove.c: Corrected the FSF's address. + +Fri Aug 25 13:21:57 2006 Arnold D. Robbins + + * README: New file. + * strncasecmp.c, memmove.c: Replaced with versions + from GLIBC, hacked unmercifully to work standalone. + +Fri Oct 21 11:18:10 2005 Arnold D. Robbins + + * strtod.c (gawk_strtod): Made check for locale's decimal + point conditional also upon do_posix. + +Tue Jul 26 21:46:16 2005 Arnold D. Robbins + + * Release 3.1.5: Release tar file made. + +Tue Jul 26 21:27:46 2005 Arnold D. Robbins + + * strtod.c (gawk_strtod) [ENABLE_NLS]: Removed from conditional + paralleling change to main.c. + * stroul.c (strtoul): Same. + +Mon Aug 2 12:18:15 2004 Arnold D. Robbins + + * Release 3.1.4: Release tar file made. + +Mon May 3 09:24:21 2004 Arnold D. Robbins + + * strtoul.c: New file. + +Sun May 2 18:03:54 2004 Arnold D. Robbins + + * strtod.c (gawk_strtod): Check for locale's decimal point + instead of hard-wiring period. + +Tue Jan 20 10:38:48 2004 Arnold D. Robbins + + * memmove.c: New file. + +Mon Jul 7 11:01:43 2003 Arnold D. Robbins + + * Release 3.1.3: Release tar file made. + +Wed Mar 19 14:10:31 2003 Arnold D. Robbins + + This time for sure. + -- Bullwinkle + + * Release 3.1.2: Release tar file made. + +Mon Feb 3 20:37:09 2003 Pat Rankin + + * strftime.c: Restore use of TIME_T_IN_SYS_TYPES_H to control + inclusion of . + (TYPE_SIGNED): Add workaround to avoid diagnostic from Compaq C V6.4. + (my_strftime) [case 's']: Likewise; exclude negative number handling + if TIME_T_UNSIGNED is defined. + +Mon Jan 27 12:09:50 2003 Stepan Kasal + + * strtod.c (gawk_strtod): Cleanup, changing the logic + so that ptr is correct. Fixes the bug that 0e0 is not + recognized as numeric. + +Wed May 1 16:41:32 2002 Arnold D. Robbins + + * Release 3.1.1: Release tar file made. + +Tue Dec 4 17:56:46 2001 Arnold D. Robbins + + * strftime.c: Replaced with glibc version. + * strftime.3: Removed + +Fri Aug 3 09:01:19 2001 Arnold D. Robbins + + ChangeLog created. + + * strtod.c (strtod): Fixed test at end for failure to + be a little smarter. diff --git a/missing_d/README b/missing_d/README new file mode 100644 index 0000000..735889d --- /dev/null +++ b/missing_d/README @@ -0,0 +1,14 @@ +Fri Aug 25 13:23:06 IDT 2006 +============================ + +The files memmove.c, mktime.c, snprintf.c, strerror.c, strftime.c, +strncasecmp.c, and system.c are copyright by the Free Software +Foundation. They are licensed under the GPL or the LGPL. See the +COPYING.LIB file in this directory and the COPYING file in the parent +directory for licensing information. + +All other files are public domain. + +Arnold Robbins +arnold@skeeve.com + diff --git a/missing_d/getaddrinfo.c b/missing_d/getaddrinfo.c new file mode 100644 index 0000000..677f27d --- /dev/null +++ b/missing_d/getaddrinfo.c @@ -0,0 +1,112 @@ +#ifndef HAVE_SOCKETS +#error getaddrinfo.c included by mistake! no socket support! +#else +#include +#include +#ifdef HAVE_NETDB_H +#include +#endif +#ifdef HAVE_NETINET_IN_H +#include +#endif +#ifdef HAVE_ARPA_INET_H +#include +#endif + +#include "getaddrinfo.h" + +void +freeaddrinfo(struct addrinfo *res) +{ + if (res->ai_addr != NULL) + free(res->ai_addr); + free(res); +} + +int +getaddrinfo(const char *hostname, const char *portname, + struct addrinfo *hints, struct addrinfo **res) +{ + struct addrinfo *out; + if (res == NULL) + return -1; + + out = (struct addrinfo *) malloc(sizeof(*out)); + if (out == NULL) { + *res = NULL; + return -1; + } + memset(out, '\0', sizeof(*out)); + + out->ai_addr = (struct sockaddr *) malloc(sizeof(struct sockaddr_in)); + if (out->ai_addr == NULL) { + free(out); + *res = NULL; + return -1; + } + + out->ai_socktype = SOCK_STREAM; + if (hints != NULL) { + if (hints->ai_socktype) + out->ai_socktype = hints->ai_socktype; + if (hints->ai_protocol) + out->ai_protocol = hints->ai_protocol; + } + + if (out->ai_protocol == 0) { + switch (out->ai_socktype) { + case SOCK_STREAM: + out->ai_protocol = IPPROTO_TCP; + break; + case SOCK_DGRAM: + out->ai_protocol = IPPROTO_UDP; + break; + case SOCK_RAW: + out->ai_protocol = IPPROTO_RAW; + break; + } + } + + out->ai_addrlen = sizeof(struct sockaddr_in); + memset(out->ai_addr, '\0', sizeof(struct sockaddr_in)); + + if (hostname != NULL) { + struct hostent *he; + he = gethostbyname(hostname); + if (he != NULL && he->h_addr_list != NULL) { + ((struct sockaddr_in *)out->ai_addr)->sin_addr.s_addr + = ((struct in_addr *)he->h_addr_list[0])->s_addr; + } else { + freeaddrinfo(out); + return -1; + } + } else { + if (!(out->ai_flags & AI_PASSIVE)) + ((struct sockaddr_in *)out->ai_addr)->sin_addr.s_addr + = htonl(INADDR_ANY); + } + ((struct sockaddr_in *)out->ai_addr)->sin_family = AF_INET; + out->ai_family = AF_INET; + + if (portname != NULL && *portname) { + long portnum; + char *end; + portnum = strtol(portname, &end, 10); + if (*end == '\0' && portnum > 0 && portnum < 65536) { + ((struct sockaddr_in *)out->ai_addr)->sin_port + = htons(portnum); + } else { + struct servent *se; + se = getservbyname(portname, NULL); + if (se != NULL) { + ((struct sockaddr_in *)out->ai_addr)->sin_port + = se->s_port; + } + } + } + + *res = out; + + return 0; +} +#endif diff --git a/missing_d/getaddrinfo.h b/missing_d/getaddrinfo.h new file mode 100644 index 0000000..3d816c9 --- /dev/null +++ b/missing_d/getaddrinfo.h @@ -0,0 +1,31 @@ +#ifndef AI_ADDRCONFIG +#define AI_ADDRCONFIG 0 +#endif /* AI_ADDRCONFIG */ +#ifndef AI_PASSIVE +#define AI_PASSIVE 1 +#endif /* AI_PASSIVE */ + +/* undef these, just in case, to avoid noisy warnings */ +#undef addrinfo +#undef freeaddrinfo +#undef getaddrinfo + +#define addrinfo xaddrinfo +#define freeaddrinfo xfreeaddrinfo +#define getaddrinfo xgetaddrinfo + +struct addrinfo +{ + int ai_flags; + int ai_socktype; + int ai_family; + int ai_protocol; + socklen_t ai_addrlen; + struct sockaddr * ai_addr; + struct xaddrinfo * ai_next; +}; + +void freeaddrinfo(struct xaddrinfo * res); + +int getaddrinfo(const char * hostname, const char * portname, + struct xaddrinfo * hints, struct xaddrinfo ** res); diff --git a/missing_d/memcmp.c b/missing_d/memcmp.c new file mode 100644 index 0000000..12b3775 --- /dev/null +++ b/missing_d/memcmp.c @@ -0,0 +1,18 @@ +/* + * memcmp --- compare strings. + * + * We use our own routine since it has to act like strcmp() for return + * value, and the BSD manual says bcmp() only returns zero/non-zero. + */ + +int +memcmp (s1, s2, l) +char *s1, *s2; +int l; +{ + for (; l-- > 0; s1++, s2++) { + if (*s1 != *s2) + return (*s1 - *s2); + } + return (0); +} diff --git a/missing_d/memcpy.c b/missing_d/memcpy.c new file mode 100644 index 0000000..568a006 --- /dev/null +++ b/missing_d/memcpy.c @@ -0,0 +1,18 @@ +/* + * memcpy --- copy strings. + * + * We supply this routine for those systems that aren't standard yet. + */ + +char * +memcpy (dest, src, l) +char *dest, *src; +int l; +{ + char *ret = dest; + + while (l--) + *dest++ = *src++; + + return ret; +} diff --git a/missing_d/memmove.c b/missing_d/memmove.c new file mode 100644 index 0000000..4f577b3 --- /dev/null +++ b/missing_d/memmove.c @@ -0,0 +1,139 @@ +/* Copy memory to memory until the specified number of bytes + has been copied. Overlap is handled correctly. + Copyright (C) 1991, 1995, 1996, 1997, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Torbjorn Granlund (tege@sics.se). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301 USA */ + +/* + * August 2006. For Gawk: Borrowed from GLIBC and hacked unmercifully. + * DON'T steal this for your own code, go straight to the GLIBC + * source for the original versions. + */ + + +/* This stuff from libc/sysdeps/generic/memcopy.h */ +typedef unsigned char byte; + +/* Copy exactly NBYTES bytes from SRC_BP to DST_BP, + without any assumptions about alignment of the pointers. */ +#define BYTE_COPY_FWD(dst_bp, src_bp, nbytes) \ + do \ + { \ + size_t __nbytes = (nbytes); \ + while (__nbytes > 0) \ + { \ + byte __x = ((byte *) src_bp)[0]; \ + src_bp += 1; \ + __nbytes -= 1; \ + ((byte *) dst_bp)[0] = __x; \ + dst_bp += 1; \ + } \ + } while (0) + +/* Copy exactly NBYTES_TO_COPY bytes from SRC_END_PTR to DST_END_PTR, + beginning at the bytes right before the pointers and continuing towards + smaller addresses. Don't assume anything about alignment of the + pointers. */ +#define BYTE_COPY_BWD(dst_ep, src_ep, nbytes) \ + do \ + { \ + size_t __nbytes = (nbytes); \ + while (__nbytes > 0) \ + { \ + byte __x; \ + src_ep -= 1; \ + __x = ((byte *) src_ep)[0]; \ + dst_ep -= 1; \ + __nbytes -= 1; \ + ((byte *) dst_ep)[0] = __x; \ + } \ + } while (0) + +/* end of stuff from memcopy.h */ + +void * +memmove (dest, src, len) + void *dest; + const void *src; + size_t len; +{ + unsigned long int dstp = (long int) dest; + unsigned long int srcp = (long int) src; + + /* This test makes the forward copying code be used whenever possible. + Reduces the working set. */ + if (dstp - srcp >= len) /* *Unsigned* compare! */ + { + /* Copy from the beginning to the end. */ +#if 0 /* screw all this */ + /* If there not too few bytes to copy, use word copy. */ + if (len >= OP_T_THRES) + { + /* Copy just a few bytes to make DSTP aligned. */ + len -= (-dstp) % OPSIZ; + BYTE_COPY_FWD (dstp, srcp, (-dstp) % OPSIZ); + + /* Copy whole pages from SRCP to DSTP by virtual address + manipulation, as much as possible. */ + + PAGE_COPY_FWD_MAYBE (dstp, srcp, len, len); + + /* Copy from SRCP to DSTP taking advantage of the known + alignment of DSTP. Number of bytes remaining is put + in the third argument, i.e. in LEN. This number may + vary from machine to machine. */ + + WORD_COPY_FWD (dstp, srcp, len, len); + + /* Fall out and copy the tail. */ + } + + /* There are just a few bytes to copy. Use byte memory operations. */ +#endif + BYTE_COPY_FWD (dstp, srcp, len); + } + else + { + /* Copy from the end to the beginning. */ + srcp += len; + dstp += len; + +#if 0 /* ditto */ + /* If there not too few bytes to copy, use word copy. */ + if (len >= OP_T_THRES) + { + /* Copy just a few bytes to make DSTP aligned. */ + len -= dstp % OPSIZ; + BYTE_COPY_BWD (dstp, srcp, dstp % OPSIZ); + + /* Copy from SRCP to DSTP taking advantage of the known + alignment of DSTP. Number of bytes remaining is put + in the third argument, i.e. in LEN. This number may + vary from machine to machine. */ + + WORD_COPY_BWD (dstp, srcp, len, len); + + /* Fall out and copy the tail. */ + } +#endif + /* There are just a few bytes to copy. Use byte memory operations. */ + BYTE_COPY_BWD (dstp, srcp, len); + } + + return (dest); +} diff --git a/missing_d/memset.c b/missing_d/memset.c new file mode 100644 index 0000000..0e509e8 --- /dev/null +++ b/missing_d/memset.c @@ -0,0 +1,20 @@ +/* + * memset --- initialize memory + * + * We supply this routine for those systems that aren't standard yet. + */ + +void * +memset(dest, val, l) +void *dest; +int val; +size_t l; +{ + char *ret = dest; + char *d = dest; + + while (l--) + *d++ = val; + + return ((void *) ret); +} diff --git a/missing_d/mktime.c b/missing_d/mktime.c new file mode 100644 index 0000000..d394ef1 --- /dev/null +++ b/missing_d/mktime.c @@ -0,0 +1,425 @@ +/* Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Paul Eggert (eggert@twinsun.com). + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 3 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ + +/* Define this to have a standalone program to test this implementation of + mktime. */ +/* #define DEBUG 1 */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef _LIBC +# define HAVE_LIMITS_H 1 +# define HAVE_LOCALTIME_R 1 +# define STDC_HEADERS 1 +#endif + +/* Assume that leap seconds are possible, unless told otherwise. + If the host has a `zic' command with a `-L leapsecondfilename' option, + then it supports leap seconds; otherwise it probably doesn't. */ +#ifndef LEAP_SECONDS_POSSIBLE +#define LEAP_SECONDS_POSSIBLE 1 +#endif + +#ifndef VMS +#include /* Some systems define `time_t' here. */ +#else +#include +#endif +#include + +#if HAVE_LIMITS_H +#include +#endif + +#if DEBUG +#include +#if STDC_HEADERS +#include +#endif +/* Make it work even if the system's libc has its own mktime routine. */ +#define mktime my_mktime +#endif /* DEBUG */ + +#ifndef __P +#if defined (__GNUC__) || (defined (__STDC__) && __STDC__) +#define __P(args) args +#else +#define __P(args) () +#endif /* GCC. */ +#endif /* Not __P. */ + +#ifndef CHAR_BIT +#define CHAR_BIT 8 +#endif + +#ifndef INT_MIN +#define INT_MIN (~0 << (sizeof (int) * CHAR_BIT - 1)) +#endif +#ifndef INT_MAX +#define INT_MAX (~0 - INT_MIN) +#endif + +#ifndef TIME_T_MIN +#define TIME_T_MIN (0 < (time_t) -1 ? (time_t) 0 \ + : ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1)) +#endif +#ifndef TIME_T_MAX +#define TIME_T_MAX (~ (time_t) 0 - TIME_T_MIN) +#endif + +#define TM_YEAR_BASE 1900 +#define EPOCH_YEAR 1970 + +#ifndef __isleap +/* Nonzero if YEAR is a leap year (every 4 years, + except every 100th isn't, and every 400th is). */ +#define __isleap(year) \ + ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) +#endif + +/* How many days come before each month (0-12). */ +const unsigned short int __mon_yday[2][13] = + { + /* Normal years. */ + { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, + /* Leap years. */ + { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } + }; + +static time_t ydhms_tm_diff __P ((int, int, int, int, int, const struct tm *)); +time_t __mktime_internal __P ((struct tm *, + struct tm *(*) (const time_t *, struct tm *), + time_t *)); + + +static struct tm *my_localtime_r __P ((const time_t *, struct tm *)); +static struct tm * +my_localtime_r (t, tp) + const time_t *t; + struct tm *tp; +{ + struct tm *l = localtime (t); + if (! l) + return 0; + *tp = *l; + return tp; +} + + +/* Yield the difference between (YEAR-YDAY HOUR:MIN:SEC) and (*TP), + measured in seconds, ignoring leap seconds. + YEAR uses the same numbering as TM->tm_year. + All values are in range, except possibly YEAR. + If overflow occurs, yield the low order bits of the correct answer. */ +static time_t +ydhms_tm_diff (year, yday, hour, min, sec, tp) + int year, yday, hour, min, sec; + const struct tm *tp; +{ + /* Compute intervening leap days correctly even if year is negative. + Take care to avoid int overflow. time_t overflow is OK, since + only the low order bits of the correct time_t answer are needed. + Don't convert to time_t until after all divisions are done, since + time_t might be unsigned. */ + int a4 = (year >> 2) + (TM_YEAR_BASE >> 2) - ! (year & 3); + int b4 = (tp->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (tp->tm_year & 3); + int a100 = a4 / 25 - (a4 % 25 < 0); + int b100 = b4 / 25 - (b4 % 25 < 0); + int a400 = a100 >> 2; + int b400 = b100 >> 2; + int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); + time_t years = year - (time_t) tp->tm_year; + time_t days = (365 * years + intervening_leap_days + + (yday - tp->tm_yday)); + return (60 * (60 * (24 * days + (hour - tp->tm_hour)) + + (min - tp->tm_min)) + + (sec - tp->tm_sec)); +} + + +static time_t localtime_offset; + +/* Convert *TP to a time_t value. */ +time_t +mktime (tp) + struct tm *tp; +{ +#ifdef _LIBC + /* POSIX.1 8.1.1 requires that whenever mktime() is called, the + time zone names contained in the external variable `tzname' shall + be set as if the tzset() function had been called. */ + __tzset (); +#endif + + return __mktime_internal (tp, my_localtime_r, &localtime_offset); +} + +/* Convert *TP to a time_t value, inverting + the monotonic and mostly-unit-linear conversion function CONVERT. + Use *OFFSET to keep track of a guess at the offset of the result, + compared to what the result would be for UTC without leap seconds. + If *OFFSET's guess is correct, only one CONVERT call is needed. */ +time_t +__mktime_internal (tp, convert, offset) + struct tm *tp; + struct tm *(*convert) __P ((const time_t *, struct tm *)); + time_t *offset; +{ + time_t t, dt, t0; + struct tm tm; + + /* The maximum number of probes (calls to CONVERT) should be enough + to handle any combinations of time zone rule changes, solar time, + and leap seconds. Posix.1 prohibits leap seconds, but some hosts + have them anyway. */ + int remaining_probes = 4; + + /* Time requested. Copy it in case CONVERT modifies *TP; this can + occur if TP is localtime's returned value and CONVERT is localtime. */ + int sec = tp->tm_sec; + int min = tp->tm_min; + int hour = tp->tm_hour; + int mday = tp->tm_mday; + int mon = tp->tm_mon; + int year_requested = tp->tm_year; + int isdst = tp->tm_isdst; + + /* Ensure that mon is in range, and set year accordingly. */ + int mon_remainder = mon % 12; + int negative_mon_remainder = mon_remainder < 0; + int mon_years = mon / 12 - negative_mon_remainder; + int year = year_requested + mon_years; + + /* The other values need not be in range: + the remaining code handles minor overflows correctly, + assuming int and time_t arithmetic wraps around. + Major overflows are caught at the end. */ + + /* Calculate day of year from year, month, and day of month. + The result need not be in range. */ + int yday = ((__mon_yday[__isleap (year + TM_YEAR_BASE)] + [mon_remainder + 12 * negative_mon_remainder]) + + mday - 1); + +#if LEAP_SECONDS_POSSIBLE + /* Handle out-of-range seconds specially, + since ydhms_tm_diff assumes every minute has 60 seconds. */ + int sec_requested = sec; + if (sec < 0) + sec = 0; + if (59 < sec) + sec = 59; +#endif + + /* Invert CONVERT by probing. First assume the same offset as last time. + Then repeatedly use the error to improve the guess. */ + + tm.tm_year = EPOCH_YEAR - TM_YEAR_BASE; + tm.tm_yday = tm.tm_hour = tm.tm_min = tm.tm_sec = 0; + t0 = ydhms_tm_diff (year, yday, hour, min, sec, &tm); + + for (t = t0 + *offset; + (dt = ydhms_tm_diff (year, yday, hour, min, sec, (*convert) (&t, &tm))); + t += dt) + if (--remaining_probes == 0) + return -1; + + /* Check whether tm.tm_isdst has the requested value, if any. */ + if (0 <= isdst && 0 <= tm.tm_isdst) + { + int dst_diff = (isdst != 0) - (tm.tm_isdst != 0); + if (dst_diff) + { + /* Move two hours in the direction indicated by the disagreement, + probe some more, and switch to a new time if found. + The largest known fallback due to daylight savings is two hours: + once, in Newfoundland, 1988-10-30 02:00 -> 00:00. */ + time_t ot = t - 2 * 60 * 60 * dst_diff; + while (--remaining_probes != 0) + { + struct tm otm; + if (! (dt = ydhms_tm_diff (year, yday, hour, min, sec, + (*convert) (&ot, &otm)))) + { + t = ot; + tm = otm; + break; + } + if ((ot += dt) == t) + break; /* Avoid a redundant probe. */ + } + } + } + + *offset = t - t0; + +#if LEAP_SECONDS_POSSIBLE + if (sec_requested != tm.tm_sec) + { + /* Adjust time to reflect the tm_sec requested, not the normalized value. + Also, repair any damage from a false match due to a leap second. */ + t += sec_requested - sec + (sec == 0 && tm.tm_sec == 60); + (*convert) (&t, &tm); + } +#endif + + if (TIME_T_MAX / INT_MAX / 366 / 24 / 60 / 60 < 3) + { + /* time_t isn't large enough to rule out overflows in ydhms_tm_diff, + so check for major overflows. A gross check suffices, + since if t has overflowed, it is off by a multiple of + TIME_T_MAX - TIME_T_MIN + 1. So ignore any component of + the difference that is bounded by a small value. */ + + double dyear = (double) year_requested + mon_years - tm.tm_year; + double dday = 366 * dyear + mday; + double dsec = 60 * (60 * (24 * dday + hour) + min) + sec_requested; + + if (TIME_T_MAX / 3 - TIME_T_MIN / 3 < (dsec < 0 ? - dsec : dsec)) + return -1; + } + + *tp = tm; + return t; +} + +#ifdef weak_alias +weak_alias (mktime, timelocal) +#endif + +#if DEBUG + +static int +not_equal_tm (a, b) + struct tm *a; + struct tm *b; +{ + return ((a->tm_sec ^ b->tm_sec) + | (a->tm_min ^ b->tm_min) + | (a->tm_hour ^ b->tm_hour) + | (a->tm_mday ^ b->tm_mday) + | (a->tm_mon ^ b->tm_mon) + | (a->tm_year ^ b->tm_year) + | (a->tm_mday ^ b->tm_mday) + | (a->tm_yday ^ b->tm_yday) + | (a->tm_isdst ^ b->tm_isdst)); +} + +static void +print_tm (tp) + struct tm *tp; +{ + printf ("%04d-%02d-%02d %02d:%02d:%02d yday %03d wday %d isdst %d", + tp->tm_year + TM_YEAR_BASE, tp->tm_mon + 1, tp->tm_mday, + tp->tm_hour, tp->tm_min, tp->tm_sec, + tp->tm_yday, tp->tm_wday, tp->tm_isdst); +} + +static int +check_result (tk, tmk, tl, tml) + time_t tk; + struct tm tmk; + time_t tl; + struct tm tml; +{ + if (tk != tl || not_equal_tm (&tmk, &tml)) + { + printf ("mktime ("); + print_tm (&tmk); + printf (")\nyields ("); + print_tm (&tml); + printf (") == %ld, should be %ld\n", (long) tl, (long) tk); + return 1; + } + + return 0; +} + +int +main (argc, argv) + int argc; + char **argv; +{ + int status = 0; + struct tm tm, tmk, tml; + time_t tk, tl; + char trailer; + + if ((argc == 3 || argc == 4) + && (sscanf (argv[1], "%d-%d-%d%c", + &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &trailer) + == 3) + && (sscanf (argv[2], "%d:%d:%d%c", + &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &trailer) + == 3)) + { + tm.tm_year -= TM_YEAR_BASE; + tm.tm_mon--; + tm.tm_isdst = argc == 3 ? -1 : atoi (argv[3]); + tmk = tm; + tl = mktime (&tmk); + tml = *localtime (&tl); + printf ("mktime returns %ld == ", (long) tl); + print_tm (&tmk); + printf ("\n"); + status = check_result (tl, tmk, tl, tml); + } + else if (argc == 4 || (argc == 5 && strcmp (argv[4], "-") == 0)) + { + time_t from = atol (argv[1]); + time_t by = atol (argv[2]); + time_t to = atol (argv[3]); + + if (argc == 4) + for (tl = from; tl <= to; tl += by) + { + tml = *localtime (&tl); + tmk = tml; + tk = mktime (&tmk); + status |= check_result (tk, tmk, tl, tml); + } + else + for (tl = from; tl <= to; tl += by) + { + /* Null benchmark. */ + tml = *localtime (&tl); + tmk = tml; + tk = tl; + status |= check_result (tk, tmk, tl, tml); + } + } + else + printf ("Usage:\ +\t%s YYYY-MM-DD HH:MM:SS [ISDST] # Test given time.\n\ +\t%s FROM BY TO # Test values FROM, FROM+BY, ..., TO.\n\ +\t%s FROM BY TO - # Do not test those values (for benchmark).\n", + argv[0], argv[0], argv[0]); + + return status; +} + +#endif /* DEBUG */ + +/* +Local Variables: +compile-command: "gcc -DDEBUG=1 -Wall -O -g mktime.c -o mktime" +End: +*/ diff --git a/missing_d/setenv.c b/missing_d/setenv.c new file mode 100644 index 0000000..2d1bf10 --- /dev/null +++ b/missing_d/setenv.c @@ -0,0 +1,178 @@ +/* $NetBSD: setenv.c,v 1.1.1.1 2009/04/12 15:33:26 christos Exp $ */ + +#if defined(LIBC_SCCS) && !defined(lint) +static const char sccsid[] = "@(#)setenv.c 8.1 (Berkeley) 6/4/93"; +static const char rcsid[] = "Id: setenv.c,v 1.2 2005/04/27 04:56:11 sra Exp"; +#endif /* LIBC_SCCS and not lint */ + +/* + * Copyright (c) 1987, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* #include "port_before.h" */ + +#include +#include +#include +#include + +/* #include "port_after.h" */ + +#define NEED_SETENV +#if !defined(NEED_SETENV) +int __bindcompat_setenv; +#else + +/* + * Gawk changes: + * 1. Comment out "port_before.h" and "port_after.h" includes. + * 2. Define NEED_SETENV. + * 3. Add leading "int" to setenv() for C99 compilers. Which is worse, + * that it wasn't there in the first place, or that C99 now makes + * such functions void, breaking 40+ years of historical practice? + * 4. Change return type of unsetenv to "int" for standards + * conformance and check for name containing an "=" in + * which case it return an error. (See unsetenv(3), at least on Linux.) + */ + +extern char **environ; + +static char *findenv(const char *name, int *offset); + +/*% + * setenv -- + * Set the value of the environmental variable "name" to be + * "value". If rewrite is set, replace any current value. + */ +int +setenv(const char *name, const char *value, int rewrite) +{ + extern char **environ; + static int alloced; /*%< if allocated space before */ + char *c; + int l_value, offset; + + if (*value == '=') /*%< no `=' in value */ + ++value; + l_value = strlen(value); + if ((c = findenv(name, &offset))) { /*%< find if already exists */ + if (!rewrite) + return (0); + if (strlen(c) >= l_value) { /*%< old larger; copy over */ + while (*c++ = *value++); + return (0); + } + } else { /*%< create new slot */ + int cnt; + char **p; + + for (p = environ, cnt = 0; *p; ++p, ++cnt); + if (alloced) { /*%< just increase size */ + environ = (char **)realloc((char *)environ, + (size_t)(sizeof(char *) * (cnt + 2))); + if (!environ) + return (-1); + } + else { /*%< get new space */ + alloced = 1; /*%< copy old entries into it */ + p = malloc((size_t)(sizeof(char *) * (cnt + 2))); + if (!p) + return (-1); + memcpy(p, environ, cnt * sizeof(char *)); + environ = p; + } + environ[cnt + 1] = NULL; + offset = cnt; + } + for (c = (char *)name; *c && *c != '='; ++c); /*%< no `=' in name */ + if (!(environ[offset] = /*%< name + `=' + value */ + malloc((size_t)((int)(c - name) + l_value + 2)))) + return (-1); + for (c = environ[offset]; (*c = *name++) && *c != '='; ++c); + for (*c++ = '='; *c++ = *value++;); + return (0); +} + +/*% + * unsetenv(name) -- + * Delete environmental variable "name". + */ +int +unsetenv(const char *name) +{ + char **p; + int offset; + + if (strchr(name, '=') != NULL) { + errno = EINVAL; + return -1; + } + + while (findenv(name, &offset)) /*%< if set multiple times */ + for (p = &environ[offset];; ++p) + if (!(*p = *(p + 1))) + break; + + return 0; +} + +/*% + * findenv -- + * Returns pointer to value associated with name, if any, else NULL. + * Sets offset to be the offset of the name/value combination in the + * environmental array, for use by setenv(3) and unsetenv(3). + * Explicitly removes '=' in argument name. + * + * This routine *should* be a static; don't use it. + */ +static char * +findenv(const char *name, int *offset) +{ + const char *np; + char **p, *c; + int len; + + if (name == NULL || environ == NULL) + return (NULL); + for (np = name; *np && *np != '='; ++np) + continue; + len = np - name; + for (p = environ; (c = *p) != NULL; ++p) + if (strncmp(c, name, len) == 0 && c[len] == '=') { + *offset = p - environ; + return (c + len + 1); + } + return (NULL); +} +#endif + +/*! \file */ diff --git a/missing_d/snprintf.c b/missing_d/snprintf.c new file mode 100644 index 0000000..254a8e0 --- /dev/null +++ b/missing_d/snprintf.c @@ -0,0 +1,202 @@ +/* + * snprintf.c - Implement snprintf and vsnprintf on platforms that need them. + */ + +/* + * Copyright (C) 2006, 2007 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + + +/* If using in a multi-threaded context, then SNPRINTF_REENTRANT must be + defined. But in that case, performance will be much worse, since a + temporary file is created and closed for each call to snprintf. */ + +#if defined(HAVE_MKSTEMP) +/* If mkstemp is available, use it instead of tmpfile(), since some older + implementations of tmpfile() were not secure. */ + +static char *tmpfilename = NULL; +static FILE *safe_f = NULL; + +#ifdef HAVE_ATEXIT +static void close_safe_f() +{ + if (safe_f != NULL) { + fclose(safe_f); + safe_f = NULL; + } + if (tmpfilename != NULL) { + unlink(tmpfilename); + free(tmpfilename); + tmpfilename = NULL; + } +} +#endif + +static FILE * +safe_tmpfile (void) +{ + static short first = TRUE; + static const char template[] = "snprintfXXXXXX"; + int fd; + static char *tmpdir = NULL; + static int len = 0; + + if (first) { + first = FALSE; + /* + * First try Unix stanadard env var, then Windows var, + * then fall back to /tmp. + */ + if ((tmpdir = getenv("TMPDIR")) != NULL && *tmpdir != '\0') + ; /* got it */ + else if ((tmpdir = getenv("TEMP")) != NULL && *tmpdir != '\0') + ; /* got it */ + else + tmpdir = "/tmp"; + + len = strlen(tmpdir) + 1 + strlen(template) + 1; +#ifdef HAVE_ATEXIT + atexit(close_safe_f); +#endif /* HAVE_ATEXIT */ + } + + if ((tmpfilename = (char *) malloc(len)) == NULL) + return NULL; + else + sprintf(tmpfilename, "%s/%s", tmpdir, template); + + if ((fd = mkstemp (tmpfilename)) < 0) + return NULL; + +#if ! defined(DJGPP) && ! defined(MSDOS) && ! defined(_MSC_VER) \ + && ! defined(_WIN32) && ! defined(__CRTRSXNT__) && ! defined(__EMX__) \ + && ! defined(__MINGW32__) && ! defined(__WIN32__) + /* If not MS, unlink after opening. */ + unlink (tmpfilename); + free(tmpfilename); + tmpfilename = NULL; +#endif + + if ((safe_f = fdopen (fd, "w+b")) == NULL) { + close (fd); + return NULL; + } + /* setvbuf(f,NULL,_IOFBF,4*BUFSIZ); */ + return safe_f; +} + +#elif defined(HAVE_TMPFILE) +#define safe_tmpfile tmpfile +#else +#error Neither mkstemp() nor tmpfile() is available on this platform. +#endif + +#if (__STDC_VERSION__ + 0) < 199901 +#undef restrict /* force it! */ +#define restrict +#endif + +int +vsnprintf (char *restrict buf, size_t len, + const char *restrict fmt, va_list args) +{ + int actual; + int nread; + size_t cnt = 0; +#ifndef SNPRINTF_REENTRANT + static +#endif + FILE *fp; + + if ((buf == NULL) || (len < 1)) + return -1; + + buf[0] = '\0'; /* in case the caller does not check the return code! */ + +#ifdef SNPRINTF_REENTRANT + if ((fp = safe_tmpfile ()) == NULL) + return -1; +#else + if ((fp == NULL) && ((fp = safe_tmpfile ()) == NULL)) + return -1; + rewind (fp); +#endif + actual = vfprintf (fp, fmt, args); + rewind (fp); + if (actual < 0) { +#ifdef SNPRINTF_REENTRANT + fclose (fp); + if (tmpfilename != NULL) { + unlink(tmpfilename); + free(tmpfilename); + tmpfilename = NULL; + } +#endif + return -1; + } + else if ((size_t) actual < len) + len = actual; + else + --len; + while (cnt < len && (nread = fread (buf + cnt, 1, len - cnt, fp)) > 0) + cnt += nread; + buf[cnt] = '\0'; +#ifdef SNPRINTF_REENTRANT + fclose (fp); + if (tmpfilename != NULL) { + unlink(tmpfilename); + free(tmpfilename); + tmpfilename = NULL; + } +#endif + if (cnt < len) + return -1; + + return actual; +} + +int +#if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__ +snprintf (char *restrict buf, size_t len, const char *restrict fmt, ...) +#else +snprintf (va_alist) + va_dcl +#endif +{ + int rv; + va_list args; + +#if defined(HAVE_STDARG_H) && defined(__STDC__) && __STDC__ + va_start (args, fmt); +#else + char *buf; + size_t len; + char *fmt; + + va_start (args); + buf = va_arg (args, char *); + len = va_arg (args, size_t); + fmt = va_arg (args, char *); +#endif + rv = vsnprintf (buf, len, fmt, args); + va_end (args); + return rv; +} diff --git a/missing_d/strchr.c b/missing_d/strchr.c new file mode 100644 index 0000000..e549099 --- /dev/null +++ b/missing_d/strchr.c @@ -0,0 +1,47 @@ +/* + * strchr --- search a string for a character + * + * We supply this routine for those systems that aren't standard yet. + */ + +#if 0 +#include +#endif + +char * +strchr(str, c) +const char *str, c; +{ + if (c == '\0') { + /* thanks to Mike Brennan ... */ + do { + if (*str == c) + return (char *) str; + } while (*str++); + } else { + for (; *str; str++) + if (*str == c) + return (char *) str; + } + + return NULL; +} + +/* + * strrchr --- find the last occurrence of a character in a string + * + * We supply this routine for those systems that aren't standard yet. + */ + +char * +strrchr(str, c) +const char *str, c; +{ + const char *save = NULL; + + for (; *str; str++) + if (*str == c) + save = str; + + return (char *) save; +} diff --git a/missing_d/strcoll.c b/missing_d/strcoll.c new file mode 100644 index 0000000..ac65795 --- /dev/null +++ b/missing_d/strcoll.c @@ -0,0 +1,7 @@ +/* replacement strcoll.c */ + +int +strcoll(const char *s1, const char *s2) +{ + return strcmp(s1, s2); /* nyah, nyah, so there */ +} diff --git a/missing_d/strerror.c b/missing_d/strerror.c new file mode 100644 index 0000000..f3e8c28 --- /dev/null +++ b/missing_d/strerror.c @@ -0,0 +1,37 @@ +/* strerror.c --- ANSI C compatible system error routine + + Copyright (C) 1986, 1988, 1989, 1991 the Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#if 0 +#include +#endif + +extern int sys_nerr; +extern char *sys_errlist[]; + +char * +strerror(n) +int n; +{ + static char mesg[30]; + + if (n < 0 || n >= sys_nerr) { + sprintf(mesg, "Unknown error (%d)", n); + return mesg; + } else + return sys_errlist[n]; +} diff --git a/missing_d/strftime.c b/missing_d/strftime.c new file mode 100644 index 0000000..d4b9ecf --- /dev/null +++ b/missing_d/strftime.c @@ -0,0 +1,1475 @@ +/* Copyright (C) 1991-1999, 2000, 2001, 2002, 2003 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301 USA. */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#ifdef _LIBC +# define HAVE_LIMITS_H 1 +# define HAVE_MBLEN 1 +# define HAVE_MBRLEN 1 +# define HAVE_STRUCT_ERA_ENTRY 1 +# define HAVE_TM_GMTOFF 1 +# define HAVE_TM_ZONE 1 +# define HAVE_TZNAME 1 +# define HAVE_TZSET 1 +# define MULTIBYTE_IS_FORMAT_SAFE 1 +# define STDC_HEADERS 1 +# include "../locale/localeinfo.h" +#endif + +#if defined emacs && !defined HAVE_BCOPY +# define HAVE_MEMCPY 1 +#endif + +#include +#ifdef TIME_T_IN_SYS_TYPES +#include /* Some systems define `time_t' here. */ +#endif + +#ifdef TIME_WITH_SYS_TIME +# include +# include +#else +# ifdef HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif +#if HAVE_TZNAME +#ifndef __MINGW32__ +extern char *tzname[]; +#endif +#endif + +/* Do multibyte processing if multibytes are supported, unless + multibyte sequences are safe in formats. Multibyte sequences are + safe if they cannot contain byte sequences that look like format + conversion specifications. The GNU C Library uses UTF8 multibyte + encoding, which is safe for formats, but strftime.c can be used + with other C libraries that use unsafe encodings. */ +#define DO_MULTIBYTE (HAVE_MBLEN && ! MULTIBYTE_IS_FORMAT_SAFE) + +#if DO_MULTIBYTE +# if HAVE_MBRLEN +# include +# else + /* Simulate mbrlen with mblen as best we can. */ +# define mbstate_t int +# define mbrlen(s, n, ps) mblen (s, n) +# define mbsinit(ps) (*(ps) == 0) +# endif + static const mbstate_t mbstate_zero; +#endif + +#if HAVE_LIMITS_H +# include +#endif + +#if STDC_HEADERS +# include +# include +# include +#else +# ifndef HAVE_MEMCPY +# define memcpy(d, s, n) bcopy ((s), (d), (n)) +# endif +#endif + +#ifdef COMPILE_WIDE +# include +# define CHAR_T wchar_t +# define UCHAR_T unsigned int +# define L_(Str) L##Str +# define NLW(Sym) _NL_W##Sym + +# define MEMCPY(d, s, n) __wmemcpy (d, s, n) +# define STRLEN(s) __wcslen (s) + +#else +# define CHAR_T char +# define UCHAR_T unsigned char +# define L_(Str) Str +# define NLW(Sym) Sym + +# if !defined STDC_HEADERS && !defined HAVE_MEMCPY +# define MEMCPY(d, s, n) bcopy ((s), (d), (n)) +# else +# define MEMCPY(d, s, n) memcpy ((d), (s), (n)) +# endif +# define STRLEN(s) strlen (s) + +# ifdef _LIBC +# define MEMPCPY(d, s, n) __mempcpy (d, s, n) +# else +# ifndef HAVE_MEMPCPY +# define MEMPCPY(d, s, n) ((void *) ((char *) memcpy (d, s, n) + (n))) +# endif +# endif +#endif + +#ifndef __P +# if defined __GNUC__ || (defined __STDC__ && __STDC__) +# define __P(args) args +# else +# define __P(args) () +# endif /* GCC. */ +#endif /* Not __P. */ + +#ifndef PTR +# ifdef __STDC__ +# define PTR void * +# else +# define PTR char * +# endif +#endif + +#ifndef CHAR_BIT +# define CHAR_BIT 8 +#endif + +#ifndef NULL +# define NULL 0 +#endif + +/* Test for checking whether a given type is signed or not. + Some compilers issue a diagnostic about suspicious construct for + a test that will always fail when comparing a value that can't be + negative against 0 using `<' or `<=' operator. */ +/* #define TYPE_SIGNED(t) ((t) -1 < 0) */ +#define TYPE_SIGNED(t) ((t) -1 < 1) + +#ifndef INT_STRLEN_BOUND +/* Bound on length of the string representing an integer value of type t. + Subtract one for the sign bit if t is signed; + 302 / 1000 is log10 (2) rounded up; + add one for integer division truncation; + add one more for a minus sign if t is signed. */ +#define INT_STRLEN_BOUND(t) \ + ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 + 1 + TYPE_SIGNED (t)) +#endif + +#define TM_YEAR_BASE 1900 + +#ifndef __isleap +/* Nonzero if YEAR is a leap year (every 4 years, + except every 100th isn't, and every 400th is). */ +# define __isleap(year) \ + ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) +#endif + + +#ifdef _LIBC +# define my_strftime_gmtime_r __gmtime_r +# define my_strftime_localtime_r __localtime_r +# define tzname __tzname +# define tzset __tzset +#else + +/* If we're a strftime substitute in a GNU program, then prefer gmtime + to gmtime_r, since many gmtime_r implementations are buggy. + Similarly for localtime_r. */ + +# if ! HAVE_TM_GMTOFF +static struct tm *my_strftime_gmtime_r __P ((const time_t *, struct tm *)); +static struct tm * +my_strftime_gmtime_r (t, tp) + const time_t *t; + struct tm *tp; +{ + struct tm *l = gmtime (t); + if (! l) + return 0; + *tp = *l; + return tp; +} +# endif /* ! HAVE_TM_GMTOFF */ + +static struct tm *my_strftime_localtime_r __P ((const time_t *, struct tm *)); +static struct tm * +my_strftime_localtime_r (t, tp) + const time_t *t; + struct tm *tp; +{ + struct tm *l = localtime (t); + if (! l) + return 0; + *tp = *l; + return tp; +} +#endif /* ! defined _LIBC */ + + +#if !defined memset && !defined HAVE_MEMSET && !defined _LIBC +/* Some systems lack the `memset' function and we don't want to + introduce additional dependencies. */ +/* The SGI compiler reportedly barfs on the trailing null + if we use a string constant as the initializer. 28 June 1997, rms. */ +static const CHAR_T spaces[16] = /* " " */ +{ + L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '), + L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' ') +}; +static const CHAR_T zeroes[16] = /* "0000000000000000" */ +{ + L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'), + L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0') +}; + +# define memset_space(P, Len) \ + do { \ + int _len = (Len); \ + \ + do \ + { \ + int _this = _len > 16 ? 16 : _len; \ + (P) = MEMPCPY ((P), spaces, _this * sizeof (CHAR_T)); \ + _len -= _this; \ + } \ + while (_len > 0); \ + } while (0) + +# define memset_zero(P, Len) \ + do { \ + int _len = (Len); \ + \ + do \ + { \ + int _this = _len > 16 ? 16 : _len; \ + (P) = MEMPCPY ((P), zeroes, _this * sizeof (CHAR_T)); \ + _len -= _this; \ + } \ + while (_len > 0); \ + } while (0) +#else +# ifdef COMPILE_WIDE +# define memset_space(P, Len) (wmemset ((P), L' ', (Len)), (P) += (Len)) +# define memset_zero(P, Len) (wmemset ((P), L'0', (Len)), (P) += (Len)) +# else +# define memset_space(P, Len) (memset ((P), ' ', (Len)), (P) += (Len)) +# define memset_zero(P, Len) (memset ((P), '0', (Len)), (P) += (Len)) +# endif +#endif + +#define add(n, f) \ + do \ + { \ + int _n = (n); \ + int _delta = width - _n; \ + int _incr = _n + (_delta > 0 ? _delta : 0); \ + if ((size_t) _incr >= maxsize - i) \ + return 0; \ + if (p) \ + { \ + if (_delta > 0) \ + { \ + if (pad == L_('0')) \ + memset_zero (p, _delta); \ + else \ + memset_space (p, _delta); \ + } \ + f; \ + p += _n; \ + } \ + i += _incr; \ + } while (0) + +#define cpy(n, s) \ + add ((n), \ + if (to_lowcase) \ + memcpy_lowcase (p, (s), _n LOCALE_ARG); \ + else if (to_uppcase) \ + memcpy_uppcase (p, (s), _n LOCALE_ARG); \ + else \ + MEMCPY ((PTR) p, (const PTR) (s), _n)) + +#ifdef COMPILE_WIDE +# ifndef USE_IN_EXTENDED_LOCALE_MODEL +# undef __mbsrtowcs_l +# define __mbsrtowcs_l(d, s, l, st, loc) __mbsrtowcs (d, s, l, st) +# endif +# define widen(os, ws, l) \ + { \ + mbstate_t __st; \ + const char *__s = os; \ + memset (&__st, '\0', sizeof (__st)); \ + l = __mbsrtowcs_l (NULL, &__s, 0, &__st, loc); \ + ws = alloca ((l + 1) * sizeof (wchar_t)); \ + (void) __mbsrtowcs_l (ws, &__s, l, &__st, loc); \ + } +#endif + +/* For gawk */ +#undef TOLOWER +#undef TOUPPER +#undef ISDIGIT + +#if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL +/* We use this code also for the extended locale handling where the + function gets as an additional argument the locale which has to be + used. To access the values we have to redefine the _NL_CURRENT + macro. */ +# define strftime __strftime_l +# define wcsftime __wcsftime_l +# undef _NL_CURRENT +# define _NL_CURRENT(category, item) \ + (current->values[_NL_ITEM_INDEX (item)].string) +# define LOCALE_PARAM , loc +# define LOCALE_ARG , loc +# define LOCALE_PARAM_DECL __locale_t loc; +# define LOCALE_PARAM_PROTO , __locale_t loc +# define HELPER_LOCALE_ARG , current +#else +# define LOCALE_PARAM +# define LOCALE_PARAM_PROTO +# define LOCALE_ARG +# define LOCALE_PARAM_DECL +# ifdef _LIBC +# define HELPER_LOCALE_ARG , _NL_CURRENT_DATA (LC_TIME) +# else +# define HELPER_LOCALE_ARG +# endif +#endif + +#ifdef COMPILE_WIDE +# ifdef USE_IN_EXTENDED_LOCALE_MODEL +# define TOUPPER(Ch, L) __towupper_l (Ch, L) +# define TOLOWER(Ch, L) __towlower_l (Ch, L) +# else +# define TOUPPER(Ch, L) towupper (Ch) +# define TOLOWER(Ch, L) towlower (Ch) +# endif +#else +# ifdef _LIBC +# ifdef USE_IN_EXTENDED_LOCALE_MODEL +# define TOUPPER(Ch, L) __toupper_l (Ch, L) +# define TOLOWER(Ch, L) __tolower_l (Ch, L) +# else +# define TOUPPER(Ch, L) toupper (Ch) +# define TOLOWER(Ch, L) tolower (Ch) +# endif +# else +# define TOUPPER(Ch, L) (islower (Ch) ? toupper (Ch) : (Ch)) +# define TOLOWER(Ch, L) (isupper (Ch) ? tolower (Ch) : (Ch)) +# endif +#endif +/* We don't use `isdigit' here since the locale dependent + interpretation is not what we want here. We only need to accept + the arabic digits in the ASCII range. One day there is perhaps a + more reliable way to accept other sets of digits. */ +#define ISDIGIT(Ch) ((unsigned int) (Ch) - L_('0') <= 9) + +static CHAR_T *memcpy_lowcase __P ((CHAR_T *dest, const CHAR_T *src, + size_t len LOCALE_PARAM_PROTO)); + +static CHAR_T * +memcpy_lowcase (dest, src, len LOCALE_PARAM) + CHAR_T *dest; + const CHAR_T *src; + size_t len; + LOCALE_PARAM_DECL +{ + while (len-- > 0) + dest[len] = TOLOWER ((UCHAR_T) src[len], loc); + return dest; +} + +static CHAR_T *memcpy_uppcase __P ((CHAR_T *dest, const CHAR_T *src, + size_t len LOCALE_PARAM_PROTO)); + +static CHAR_T * +memcpy_uppcase (dest, src, len LOCALE_PARAM) + CHAR_T *dest; + const CHAR_T *src; + size_t len; + LOCALE_PARAM_DECL +{ + while (len-- > 0) + dest[len] = TOUPPER ((UCHAR_T) src[len], loc); + return dest; +} + + +#if ! HAVE_TM_GMTOFF +/* Yield the difference between *A and *B, + measured in seconds, ignoring leap seconds. */ +# define tm_diff ftime_tm_diff +static int tm_diff __P ((const struct tm *, const struct tm *)); +static int +tm_diff (a, b) + const struct tm *a; + const struct tm *b; +{ + /* Compute intervening leap days correctly even if year is negative. + Take care to avoid int overflow in leap day calculations, + but it's OK to assume that A and B are close to each other. */ + int a4 = (a->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (a->tm_year & 3); + int b4 = (b->tm_year >> 2) + (TM_YEAR_BASE >> 2) - ! (b->tm_year & 3); + int a100 = a4 / 25 - (a4 % 25 < 0); + int b100 = b4 / 25 - (b4 % 25 < 0); + int a400 = a100 >> 2; + int b400 = b100 >> 2; + int intervening_leap_days = (a4 - b4) - (a100 - b100) + (a400 - b400); + int years = a->tm_year - b->tm_year; + int days = (365 * years + intervening_leap_days + + (a->tm_yday - b->tm_yday)); + return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) + + (a->tm_min - b->tm_min)) + + (a->tm_sec - b->tm_sec)); +} +#endif /* ! HAVE_TM_GMTOFF */ + + + +/* The number of days from the first day of the first ISO week of this + year to the year day YDAY with week day WDAY. ISO weeks start on + Monday; the first ISO week has the year's first Thursday. YDAY may + be as small as YDAY_MINIMUM. */ +#define ISO_WEEK_START_WDAY 1 /* Monday */ +#define ISO_WEEK1_WDAY 4 /* Thursday */ +#define YDAY_MINIMUM (-366) +static int iso_week_days __P ((int, int)); +#ifdef __GNUC__ +__inline__ +#endif +static int +iso_week_days (yday, wday) + int yday; + int wday; +{ + /* Add enough to the first operand of % to make it nonnegative. */ + int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; + return (yday + - (yday - wday + ISO_WEEK1_WDAY + big_enough_multiple_of_7) % 7 + + ISO_WEEK1_WDAY - ISO_WEEK_START_WDAY); +} + + +#if !(defined _NL_CURRENT || HAVE_STRFTIME) +static CHAR_T const weekday_name[][10] = + { + L_("Sunday"), L_("Monday"), L_("Tuesday"), L_("Wednesday"), + L_("Thursday"), L_("Friday"), L_("Saturday") + }; +static CHAR_T const month_name[][10] = + { + L_("January"), L_("February"), L_("March"), L_("April"), L_("May"), + L_("June"), L_("July"), L_("August"), L_("September"), L_("October"), + L_("November"), L_("December") + }; +#endif + + +#ifdef emacs +# define my_strftime emacs_strftimeu +# define ut_argument , ut +# define ut_argument_spec int ut; +# define ut_argument_spec_iso , int ut +#else +# ifdef COMPILE_WIDE +# define my_strftime wcsftime +# define nl_get_alt_digit _nl_get_walt_digit +# else +# define my_strftime strftime +# define nl_get_alt_digit _nl_get_alt_digit +# endif +# define ut_argument +# define ut_argument_spec +# define ut_argument_spec_iso +/* We don't have this information in general. */ +# define ut 0 +#endif + +#if !defined _LIBC && HAVE_TZNAME && HAVE_TZSET + /* Solaris 2.5 tzset sometimes modifies the storage returned by localtime. + Work around this bug by copying *tp before it might be munged. */ + size_t _strftime_copytm __P ((char *, size_t, const char *, + const struct tm * ut_argument_spec_iso)); + size_t + my_strftime (s, maxsize, format, tp ut_argument) + CHAR_T *s; + size_t maxsize; + const CHAR_T *format; + const struct tm *tp; + ut_argument_spec + { + struct tm tmcopy; + tmcopy = *tp; + return _strftime_copytm (s, maxsize, format, &tmcopy ut_argument); + } +# undef my_strftime +# define my_strftime _strftime_copytm +#endif + + +/* Write information from TP into S according to the format + string FORMAT, writing no more that MAXSIZE characters + (including the terminating '\0') and returning number of + characters written. If S is NULL, nothing will be written + anywhere, so to determine how many characters would be + written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */ +size_t +my_strftime (s, maxsize, format, tp ut_argument LOCALE_PARAM) + CHAR_T *s; + size_t maxsize; + const CHAR_T *format; + const struct tm *tp; + ut_argument_spec + LOCALE_PARAM_DECL +{ +#if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL + struct locale_data *const current = loc->__locales[LC_TIME]; +#endif + + int hour12 = tp->tm_hour; +#ifdef _NL_CURRENT + /* We cannot make the following values variables since we must delay + the evaluation of these values until really needed since some + expressions might not be valid in every situation. The `struct tm' + might be generated by a strptime() call that initialized + only a few elements. Dereference the pointers only if the format + requires this. Then it is ok to fail if the pointers are invalid. */ +# define a_wkday \ + ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABDAY_1) + tp->tm_wday)) +# define f_wkday \ + ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(DAY_1) + tp->tm_wday)) +# define a_month \ + ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ABMON_1) + tp->tm_mon)) +# define f_month \ + ((const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(MON_1) + tp->tm_mon)) +# define ampm \ + ((const CHAR_T *) _NL_CURRENT (LC_TIME, tp->tm_hour > 11 \ + ? NLW(PM_STR) : NLW(AM_STR))) + +# define aw_len STRLEN (a_wkday) +# define am_len STRLEN (a_month) +# define ap_len STRLEN (ampm) +#else +# if !HAVE_STRFTIME +# define f_wkday (weekday_name[tp->tm_wday]) +# define f_month (month_name[tp->tm_mon]) +# define a_wkday f_wkday +# define a_month f_month +# define ampm (L_("AMPM") + 2 * (tp->tm_hour > 11)) + + size_t aw_len = 3; + size_t am_len = 3; + size_t ap_len = 2; +# endif +#endif + const char *zone; + size_t i = 0; + CHAR_T *p = s; + const CHAR_T *f; +#if DO_MULTIBYTE && !defined COMPILE_WIDE + const char *format_end = NULL; +#endif + + zone = NULL; +#if HAVE_TM_ZONE + /* The POSIX test suite assumes that setting + the environment variable TZ to a new value before calling strftime() + will influence the result (the %Z format) even if the information in + TP is computed with a totally different time zone. + This is bogus: though POSIX allows bad behavior like this, + POSIX does not require it. Do the right thing instead. */ + zone = (const char *) tp->tm_zone; +#endif +#if HAVE_TZNAME + if (ut) + { + if (! (zone && *zone)) + zone = "GMT"; + } + else + { + /* POSIX.1 requires that local time zone information is used as + though strftime called tzset. */ +# if HAVE_TZSET + tzset (); +# endif + } +#endif + + if (hour12 > 12) + hour12 -= 12; + else + if (hour12 == 0) + hour12 = 12; + + for (f = format; *f != '\0'; ++f) + { + int pad = 0; /* Padding for number ('-', '_', or 0). */ + int modifier; /* Field modifier ('E', 'O', or 0). */ + int digits; /* Max digits for numeric format. */ + int number_value; /* Numeric value to be printed. */ + int negative_number; /* 1 if the number is negative. */ + const CHAR_T *subfmt; + CHAR_T *bufp; + CHAR_T buf[1 + (sizeof (int) < sizeof (time_t) + ? INT_STRLEN_BOUND (time_t) + : INT_STRLEN_BOUND (int))]; + int width = -1; + int to_lowcase = 0; + int to_uppcase = 0; + int change_case = 0; + int format_char; + +#if DO_MULTIBYTE && !defined COMPILE_WIDE + switch (*f) + { + case L_('%'): + break; + + case L_('\b'): case L_('\t'): case L_('\n'): + case L_('\v'): case L_('\f'): case L_('\r'): + case L_(' '): case L_('!'): case L_('"'): case L_('#'): case L_('&'): + case L_('\''): case L_('('): case L_(')'): case L_('*'): case L_('+'): + case L_(','): case L_('-'): case L_('.'): case L_('/'): case L_('0'): + case L_('1'): case L_('2'): case L_('3'): case L_('4'): case L_('5'): + case L_('6'): case L_('7'): case L_('8'): case L_('9'): case L_(':'): + case L_(';'): case L_('<'): case L_('='): case L_('>'): case L_('?'): + case L_('A'): case L_('B'): case L_('C'): case L_('D'): case L_('E'): + case L_('F'): case L_('G'): case L_('H'): case L_('I'): case L_('J'): + case L_('K'): case L_('L'): case L_('M'): case L_('N'): case L_('O'): + case L_('P'): case L_('Q'): case L_('R'): case L_('S'): case L_('T'): + case L_('U'): case L_('V'): case L_('W'): case L_('X'): case L_('Y'): + case L_('Z'): case L_('['): case L_('\\'): case L_(']'): case L_('^'): + case L_('_'): case L_('a'): case L_('b'): case L_('c'): case L_('d'): + case L_('e'): case L_('f'): case L_('g'): case L_('h'): case L_('i'): + case L_('j'): case L_('k'): case L_('l'): case L_('m'): case L_('n'): + case L_('o'): case L_('p'): case L_('q'): case L_('r'): case L_('s'): + case L_('t'): case L_('u'): case L_('v'): case L_('w'): case L_('x'): + case L_('y'): case L_('z'): case L_('{'): case L_('|'): case L_('}'): + case L_('~'): + /* The C Standard requires these 98 characters (plus '%') to + be in the basic execution character set. None of these + characters can start a multibyte sequence, so they need + not be analyzed further. */ + add (1, *p = *f); + continue; + + default: + /* Copy this multibyte sequence until we reach its end, find + an error, or come back to the initial shift state. */ + { + mbstate_t mbstate = mbstate_zero; + size_t len = 0; + size_t fsize; + + if (! format_end) + format_end = f + strlen (f) + 1; + fsize = format_end - f; + + do + { + size_t bytes = mbrlen (f + len, fsize - len, &mbstate); + + if (bytes == 0) + break; + + if (bytes == (size_t) -2) + { + len += strlen (f + len); + break; + } + + if (bytes == (size_t) -1) + { + len++; + break; + } + + len += bytes; + } + while (! mbsinit (&mbstate)); + + cpy (len, f); + f += len - 1; + continue; + } + } + +#else /* ! DO_MULTIBYTE */ + + /* Either multibyte encodings are not supported, they are + safe for formats, so any non-'%' byte can be copied through, + or this is the wide character version. */ + if (*f != L_('%')) + { + add (1, *p = *f); + continue; + } + +#endif /* ! DO_MULTIBYTE */ + + /* Check for flags that can modify a format. */ + while (1) + { + switch (*++f) + { + /* This influences the number formats. */ + case L_('_'): + case L_('-'): + case L_('0'): + pad = *f; + continue; + + /* This changes textual output. */ + case L_('^'): + to_uppcase = 1; + continue; + case L_('#'): + change_case = 1; + continue; + + default: + break; + } + break; + } + + /* As a GNU extension we allow to specify the field width. */ + if (ISDIGIT (*f)) + { + width = 0; + do + { + if (width > INT_MAX / 10 + || (width == INT_MAX / 10 && *f - L_('0') > INT_MAX % 10)) + /* Avoid overflow. */ + width = INT_MAX; + else + { + width *= 10; + width += *f - L_('0'); + } + ++f; + } + while (ISDIGIT (*f)); + } + + /* Check for modifiers. */ + switch (*f) + { + case L_('E'): + case L_('O'): + modifier = *f++; + break; + + default: + modifier = 0; + break; + } + + /* Now do the specified format. */ + format_char = *f; + switch (format_char) + { +#define DO_NUMBER(d, v) \ + digits = d > width ? d : width; \ + number_value = v; goto do_number +#define DO_NUMBER_SPACEPAD(d, v) \ + digits = d > width ? d : width; \ + number_value = v; goto do_number_spacepad + + case L_('%'): + if (modifier != 0) + goto bad_format; + add (1, *p = *f); + break; + + case L_('a'): + if (modifier != 0) + goto bad_format; + if (change_case) + { + to_uppcase = 1; + to_lowcase = 0; + } +#if defined _NL_CURRENT || !HAVE_STRFTIME + cpy (aw_len, a_wkday); + break; +#else + goto underlying_strftime; +#endif + + case 'A': + if (modifier != 0) + goto bad_format; + if (change_case) + { + to_uppcase = 1; + to_lowcase = 0; + } +#if defined _NL_CURRENT || !HAVE_STRFTIME + cpy (STRLEN (f_wkday), f_wkday); + break; +#else + goto underlying_strftime; +#endif + + case L_('b'): + case L_('h'): + if (change_case) + { + to_uppcase = 1; + to_lowcase = 0; + } + if (modifier != 0) + goto bad_format; +#if defined _NL_CURRENT || !HAVE_STRFTIME + cpy (am_len, a_month); + break; +#else + goto underlying_strftime; +#endif + + case L_('B'): + if (modifier != 0) + goto bad_format; + if (change_case) + { + to_uppcase = 1; + to_lowcase = 0; + } +#if defined _NL_CURRENT || !HAVE_STRFTIME + cpy (STRLEN (f_month), f_month); + break; +#else + goto underlying_strftime; +#endif + + case L_('c'): + if (modifier == L_('O')) + goto bad_format; +#ifdef _NL_CURRENT + if (! (modifier == 'E' + && (*(subfmt = + (const CHAR_T *) _NL_CURRENT (LC_TIME, + NLW(ERA_D_T_FMT))) + != '\0'))) + subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_T_FMT)); +#else +# if HAVE_STRFTIME + goto underlying_strftime; +# else + subfmt = L_("%a %b %e %H:%M:%S %Y"); +# endif +#endif + + subformat: + { + CHAR_T *old_start = p; + size_t len = my_strftime (NULL, (size_t) -1, subfmt, + tp ut_argument LOCALE_ARG); + add (len, my_strftime (p, maxsize - i, subfmt, + tp ut_argument LOCALE_ARG)); + + if (to_uppcase) + while (old_start < p) + { + *old_start = TOUPPER ((UCHAR_T) *old_start, loc); + ++old_start; + } + } + break; + +#if HAVE_STRFTIME && ! (defined _NL_CURRENT && HAVE_STRUCT_ERA_ENTRY) + underlying_strftime: + { + /* The relevant information is available only via the + underlying strftime implementation, so use that. */ + char ufmt[4]; + char *u = ufmt; + char ubuf[1024]; /* enough for any single format in practice */ + size_t len; + /* Make sure we're calling the actual underlying strftime. + In some cases, config.h contains something like + "#define strftime rpl_strftime". */ +# ifdef strftime +# undef strftime + size_t strftime (); +# endif + + *u++ = '%'; + if (modifier != 0) + *u++ = modifier; + *u++ = format_char; + *u = '\0'; + len = strftime (ubuf, sizeof ubuf, ufmt, tp); + if (len == 0 && ubuf[0] != '\0') + return 0; + cpy (len, ubuf); + } + break; +#endif + + case L_('C'): + if (modifier == L_('O')) + goto bad_format; + if (modifier == L_('E')) + { +#if HAVE_STRUCT_ERA_ENTRY + struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); + if (era) + { +# ifdef COMPILE_WIDE + size_t len = __wcslen (era->era_wname); + cpy (len, era->era_wname); +# else + size_t len = strlen (era->era_name); + cpy (len, era->era_name); +# endif + break; + } +#else +# if HAVE_STRFTIME + goto underlying_strftime; +# endif +#endif + } + + { + int year = tp->tm_year + TM_YEAR_BASE; + DO_NUMBER (1, year / 100 - (year % 100 < 0)); + } + + case L_('x'): + if (modifier == L_('O')) + goto bad_format; +#ifdef _NL_CURRENT + if (! (modifier == L_('E') + && (*(subfmt = + (const CHAR_T *)_NL_CURRENT (LC_TIME, NLW(ERA_D_FMT))) + != L_('\0')))) + subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(D_FMT)); + goto subformat; +#else +# if HAVE_STRFTIME + goto underlying_strftime; +# else + /* Fall through. */ +# endif +#endif + case L_('D'): + if (modifier != 0) + goto bad_format; + subfmt = L_("%m/%d/%y"); + goto subformat; + + case L_('d'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, tp->tm_mday); + + case L_('e'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER_SPACEPAD (2, tp->tm_mday); + + /* All numeric formats set DIGITS and NUMBER_VALUE and then + jump to one of these two labels. */ + + do_number_spacepad: + /* Force `_' flag unless overwritten by `0' flag. */ + if (pad != L_('0')) + pad = L_('_'); + + do_number: + /* Format the number according to the MODIFIER flag. */ + + if (modifier == L_('O') && 0 <= number_value) + { +#ifdef _NL_CURRENT + /* Get the locale specific alternate representation of + the number NUMBER_VALUE. If none exist NULL is returned. */ + const CHAR_T *cp = nl_get_alt_digit (number_value + HELPER_LOCALE_ARG); + + if (cp != NULL) + { + size_t digitlen = STRLEN (cp); + if (digitlen != 0) + { + cpy (digitlen, cp); + break; + } + } +#else +# if HAVE_STRFTIME + goto underlying_strftime; +# endif +#endif + } + { + unsigned int u = number_value; + + bufp = buf + sizeof (buf) / sizeof (buf[0]); + negative_number = number_value < 0; + + if (negative_number) + u = -u; + + do + *--bufp = u % 10 + L_('0'); + while ((u /= 10) != 0); + } + + do_number_sign_and_padding: + if (negative_number) + *--bufp = L_('-'); + + if (pad != L_('-')) + { + int padding = digits - (buf + (sizeof (buf) / sizeof (buf[0])) + - bufp); + + if (padding > 0) + { + if (pad == L_('_')) + { + if ((size_t) padding >= maxsize - i) + return 0; + + if (p) + memset_space (p, padding); + i += padding; + width = width > padding ? width - padding : 0; + } + else + { + if ((size_t) digits >= maxsize - i) + return 0; + + if (negative_number) + { + ++bufp; + + if (p) + *p++ = L_('-'); + ++i; + } + + if (p) + memset_zero (p, padding); + i += padding; + width = 0; + } + } + } + + cpy (buf + sizeof (buf) / sizeof (buf[0]) - bufp, bufp); + break; + + case L_('F'): + if (modifier != 0) + goto bad_format; + subfmt = L_("%Y-%m-%d"); + goto subformat; + + case L_('H'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, tp->tm_hour); + + case L_('I'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, hour12); + + case L_('k'): /* GNU extension. */ + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER_SPACEPAD (2, tp->tm_hour); + + case L_('l'): /* GNU extension. */ + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER_SPACEPAD (2, hour12); + + case L_('j'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (3, 1 + tp->tm_yday); + + case L_('M'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, tp->tm_min); + + case L_('m'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, tp->tm_mon + 1); + + case L_('n'): + add (1, *p = L_('\n')); + break; + + case L_('P'): + to_lowcase = 1; +#if !defined _NL_CURRENT && HAVE_STRFTIME + format_char = L_('p'); +#endif + /* FALLTHROUGH */ + + case L_('p'): + if (change_case) + { + to_uppcase = 0; + to_lowcase = 1; + } +#if defined _NL_CURRENT || !HAVE_STRFTIME + cpy (ap_len, ampm); + break; +#else + goto underlying_strftime; +#endif + + case L_('R'): + subfmt = L_("%H:%M"); + goto subformat; + + case L_('r'): +#ifdef _NL_CURRENT + if (*(subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, + NLW(T_FMT_AMPM))) + == L_('\0')) +#endif + subfmt = L_("%I:%M:%S %p"); + goto subformat; + + case L_('S'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, tp->tm_sec); + + case L_('s'): /* GNU extension. */ + { + struct tm ltm; + time_t t; + + ltm = *tp; + t = mktime (<m); + + /* Generate string value for T using time_t arithmetic; + this works even if sizeof (long) < sizeof (time_t). */ + + bufp = buf + sizeof (buf) / sizeof (buf[0]); +#ifndef TIME_T_UNSIGNED + negative_number = t < 0; +#endif + + do + { + int d = t % 10; + t /= 10; + +#ifndef TIME_T_UNSIGNED + if (negative_number) + { + d = -d; + + /* Adjust if division truncates to minus infinity. */ + if (0 < -1 % 10 && d < 0) + { + t++; + d += 10; + } + } +#endif + + *--bufp = d + L_('0'); + } + while (t != 0); + + digits = 1; + goto do_number_sign_and_padding; + } + + case L_('X'): + if (modifier == L_('O')) + goto bad_format; +#ifdef _NL_CURRENT + if (! (modifier == L_('E') + && (*(subfmt = + (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(ERA_T_FMT))) + != L_('\0')))) + subfmt = (const CHAR_T *) _NL_CURRENT (LC_TIME, NLW(T_FMT)); + goto subformat; +#else +# if HAVE_STRFTIME + goto underlying_strftime; +# else + /* Fall through. */ +# endif +#endif + case L_('T'): + subfmt = L_("%H:%M:%S"); + goto subformat; + + case L_('t'): + add (1, *p = L_('\t')); + break; + + case L_('u'): + DO_NUMBER (1, (tp->tm_wday - 1 + 7) % 7 + 1); + + case L_('U'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, (tp->tm_yday - tp->tm_wday + 7) / 7); + + case L_('V'): + case L_('g'): + case L_('G'): + if (modifier == L_('E')) + goto bad_format; + { + int year = tp->tm_year + TM_YEAR_BASE; + int days = iso_week_days (tp->tm_yday, tp->tm_wday); + + if (days < 0) + { + /* This ISO week belongs to the previous year. */ + year--; + days = iso_week_days (tp->tm_yday + (365 + __isleap (year)), + tp->tm_wday); + } + else + { + int d = iso_week_days (tp->tm_yday - (365 + __isleap (year)), + tp->tm_wday); + if (0 <= d) + { + /* This ISO week belongs to the next year. */ + year++; + days = d; + } + } + + switch (*f) + { + case L_('g'): + DO_NUMBER (2, (year % 100 + 100) % 100); + + case L_('G'): + DO_NUMBER (1, year); + + default: + DO_NUMBER (2, days / 7 + 1); + } + } + + case L_('W'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (2, (tp->tm_yday - (tp->tm_wday - 1 + 7) % 7 + 7) / 7); + + case L_('w'): + if (modifier == L_('E')) + goto bad_format; + + DO_NUMBER (1, tp->tm_wday); + + case L_('Y'): + if (modifier == 'E') + { +#if HAVE_STRUCT_ERA_ENTRY + struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); + if (era) + { +# ifdef COMPILE_WIDE + subfmt = era->era_wformat; +# else + subfmt = era->era_format; +# endif + goto subformat; + } +#else +# if HAVE_STRFTIME + goto underlying_strftime; +# endif +#endif + } + if (modifier == L_('O')) + goto bad_format; + else + DO_NUMBER (1, tp->tm_year + TM_YEAR_BASE); + + case L_('y'): + if (modifier == L_('E')) + { +#if HAVE_STRUCT_ERA_ENTRY + struct era_entry *era = _nl_get_era_entry (tp HELPER_LOCALE_ARG); + if (era) + { + int delta = tp->tm_year - era->start_date[0]; + DO_NUMBER (1, (era->offset + + delta * era->absolute_direction)); + } +#else +# if HAVE_STRFTIME + goto underlying_strftime; +# endif +#endif + } + DO_NUMBER (2, (tp->tm_year % 100 + 100) % 100); + + case L_('Z'): + if (change_case) + { + to_uppcase = 0; + to_lowcase = 1; + } + +#if HAVE_TZNAME + /* The tzset() call might have changed the value. */ + if (!(zone && *zone) && tp->tm_isdst >= 0) + zone = tzname[tp->tm_isdst]; +#endif + if (! zone) + zone = ""; + +#ifdef COMPILE_WIDE + { + /* The zone string is always given in multibyte form. We have + to transform it first. */ + wchar_t *wczone; + size_t len; + widen (zone, wczone, len); + cpy (len, wczone); + } +#else + cpy (strlen (zone), zone); +#endif + break; + + case L_('z'): + if (tp->tm_isdst < 0) + break; + + { + int diff; +#if HAVE_TM_GMTOFF + diff = tp->tm_gmtoff; +#else + if (ut) + diff = 0; + else + { + struct tm gtm; + struct tm ltm; + time_t lt; + + ltm = *tp; + lt = mktime (<m); + + if (lt == (time_t) -1) + { + /* mktime returns -1 for errors, but -1 is also a + valid time_t value. Check whether an error really + occurred. */ + struct tm tm; + + if (! my_strftime_localtime_r (<, &tm) + || ((ltm.tm_sec ^ tm.tm_sec) + | (ltm.tm_min ^ tm.tm_min) + | (ltm.tm_hour ^ tm.tm_hour) + | (ltm.tm_mday ^ tm.tm_mday) + | (ltm.tm_mon ^ tm.tm_mon) + | (ltm.tm_year ^ tm.tm_year))) + break; + } + + if (! my_strftime_gmtime_r (<, >m)) + break; + + diff = tm_diff (<m, >m); + } +#endif + + if (diff < 0) + { + add (1, *p = L_('-')); + diff = -diff; + } + else + add (1, *p = L_('+')); + + diff /= 60; + DO_NUMBER (4, (diff / 60) * 100 + diff % 60); + } + + case L_('\0'): /* GNU extension: % at end of format. */ + --f; + /* Fall through. */ + default: + /* Unknown format; output the format, including the '%', + since this is most likely the right thing to do if a + multibyte string has been misparsed. */ + bad_format: + { + int flen; + for (flen = 1; f[1 - flen] != L_('%'); flen++) + continue; + cpy (flen, &f[1 - flen]); + } + break; + } + } + + if (p && maxsize != 0) + *p = L_('\0'); + return i; +} +#ifdef _LIBC +libc_hidden_def (my_strftime) +#endif + + +#ifdef emacs +/* For Emacs we have a separate interface which corresponds to the normal + strftime function and does not have the extra information whether the + TP arguments comes from a `gmtime' call or not. */ +size_t +emacs_strftime (s, maxsize, format, tp) + char *s; + size_t maxsize; + const char *format; + const struct tm *tp; +{ + return my_strftime (s, maxsize, format, tp, 0); +} +#endif diff --git a/missing_d/strncasecmp.c b/missing_d/strncasecmp.c new file mode 100644 index 0000000..7487235 --- /dev/null +++ b/missing_d/strncasecmp.c @@ -0,0 +1,97 @@ +/* Copyright (C) 1991,1992,1995,1996,1997,2001,2002, 2004 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301 USA */ + +/* + * August 2006. For Gawk: Borrowed from GLIBC to replace BSD licensed version. + * DON'T steal this for your own code, just go to the GLIBC sources. + * This version hacked unmercifully. + */ + + +/* Compare S1 and S2, ignoring case, returning less than, equal to or + greater than zero if S1 is lexicographically less than, + equal to or greater than S2. */ +int +strcasecmp (s1, s2) + const char *s1; + const char *s2; +{ + const unsigned char *p1 = (const unsigned char *) s1; + const unsigned char *p2 = (const unsigned char *) s2; + int result; + + if (p1 == p2) + return 0; + + while ((result = tolower (*p1) - tolower (*p2++)) == 0) + if (*p1++ == '\0') + break; + + return result; +} + +/* Compare at most N characters of two strings without taking care for + the case. + Copyright (C) 1992, 1996, 1997, 2001, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +/* + * August 2006, for gawk, same comment applies. See strncase.c + * in the GLIBC sources. + */ + + +/* Compare no more than N characters of S1 and S2, + ignoring case, returning less than, equal to or + greater than zero if S1 is lexicographically less + than, equal to or greater than S2. */ +int +strncasecmp (s1, s2, n) + const char *s1; + const char *s2; + size_t n; +{ + const unsigned char *p1 = (const unsigned char *) s1; + const unsigned char *p2 = (const unsigned char *) s2; + int result; + + if (p1 == p2 || n == 0) + return 0; + + while ((result = tolower (*p1) - tolower (*p2++)) == 0) + if (*p1++ == '\0' || --n == 0) + break; + + return result; +} diff --git a/missing_d/strtod.c b/missing_d/strtod.c new file mode 100644 index 0000000..570f640 --- /dev/null +++ b/missing_d/strtod.c @@ -0,0 +1,134 @@ +/* + * gawk wrapper for strtod + */ +/* + * Stupid version of System V strtod(3) library routine. + * Does no overflow/underflow checking. + * + * A real number is defined to be + * optional leading white space + * optional sign + * string of digits with optional decimal point + * optional 'e' or 'E' + * followed by optional sign or space + * followed by an integer + * + * if ptr is not NULL a pointer to the character terminating the + * scan is returned in *ptr. If no number formed, *ptr is set to str + * and 0 is returned. + * + * For speed, we don't do the conversion ourselves. Instead, we find + * the end of the number and then call atof() to do the dirty work. + * This bought us a 10% speedup on a sample program at uunet.uu.net. + * + * Fall 2000: Changed to enforce C89 semantics, so that 0x... returns 0. + * C99 has hexadecimal floating point numbers. + * + * Summer 2001. Try to make it smarter, so that a string like "0000" + * doesn't look like we failed. Sigh. + * + * Xmass 2002. Fix a bug in ptr determination, eg. for "0e0". + * + * Spring 2004. Update for I18N. Oh joy. + */ + +#if 0 +#include +#endif + +extern double atof(); + +double +gawk_strtod(s, ptr) +const char *s; +const char **ptr; +{ + const char *start = s; /* save original start of string */ + const char *begin = NULL; /* where the number really begins */ + int dig = 0; + int dig0 = 0; + + /* optional white space */ + while (isspace(*s)) + s++; + + begin = s; + + /* optional sign */ + if (*s == '+' || *s == '-') + s++; + + /* string of digits with optional decimal point */ + while (*s == '0') { + s++; + dig0++; + } + while (isdigit(*s)) { + s++; + dig++; + } + + if ( +#if defined(HAVE_LOCALE_H) + loc.decimal_point != NULL && do_posix + ? *s == loc.decimal_point[0] + : *s == '.' +#else + *s == '.' +#endif + ) { + s++; + while (*s == '0') { + s++; + dig0++; + } + while (isdigit(*s)) { + s++; + dig++; + } + } + + dig0 += dig; /* any digit has appeared */ + + /* + * optional 'e' or 'E' + * if a digit (or at least zero) was seen + * followed by optional sign + * followed by an integer + */ + if (dig0 + && (*s == 'e' || *s == 'E') + && (isdigit(s[1]) + || ((s[1] == '-' || s[1] == '+') && isdigit(s[2])))) { + s++; + if (*s == '+' || *s == '-') + s++; + while (isdigit(*s)) + s++; + } + + /* In case we haven't found a number, set ptr to start. */ + if (ptr) + *ptr = (dig0 ? s : start); + + /* Go for it. */ + return (dig ? atof(begin) : 0.0); +} + +#ifdef TEST +int +main(argc, argv) +int argc; +char **argv; +{ + double d; + char *p; + + for (argc--, argv++; argc; argc--, argv++) { + d = strtod (*argv, & p); + printf ("%lf [%s]\n", d, p); + } + + return 0; +} +#endif diff --git a/missing_d/strtoul.c b/missing_d/strtoul.c new file mode 100644 index 0000000..d265575 --- /dev/null +++ b/missing_d/strtoul.c @@ -0,0 +1,223 @@ +/* + * Very simple implementation of strtoul() for gawk, + * for old systems. Descriptive prose from the Linux man page. + * + * May 2004 + */ + +/* #define TEST 1 */ + +#ifdef TEST +#include +#include +#include +#include +#include +#include +#define TRUE 1 +#define FALSE 0 +#define strtoul mystrtoul +#endif + +#ifndef ULONG_MAX +#define ULONG_MAX (~ 0UL) +#endif + +unsigned long int +strtoul(nptr, endptr, base) +const char *nptr; +char **endptr; +int base; +{ + static char lower[] = "abcdefghijklmnopqrstuvwxyz"; + + unsigned long result = 0UL; + char *nptr_orig = (char *) nptr; + int neg = FALSE; + char *cp, c; + int val; + int sawdigs = FALSE; + + /* + * The strtoul() function converts the initial part of the + * string in nptr to an unsigned long integer value according + * to the given base, which must be between 2 and 36 inclusive, + * or be the special value 0. + */ + + if ((base != 0 && (base < 2 || base > 36)) || nptr == NULL) { + if (endptr != NULL) + *endptr = nptr_orig; + errno = EINVAL; + return 0; + } + + /* + * The string must [sic] begin with an arbitrary amount of white space + * (as determined by isspace(3)) followed by a single optional + * `+' or `-' sign. + */ + while (isspace(*nptr)) + nptr++; + + if (*nptr == '+') + nptr++; + else if (*nptr == '-') { + nptr++; + neg = TRUE; + } + + /* + * If base is zero or 16, the string may then include a `0x' prefix, + * and the number will be read in base 16; otherwise, a zero base is + * taken as 10 (decimal) unless the next character is `0', in which + * case it is taken as 8 (octal). + */ + if ((base == 0 || base == 16) + && nptr[0] == '0' + && (nptr[1] == 'x' || nptr[1] == 'X')) { + base = 16; /* force it */ + nptr += 2; /* skip 0x */ + } else if ((base == 0 || base == 8) && nptr[0] == '0') { + base = 8; + nptr++; + } else if (base == 0) + base = 10; + + /* + * The remainder of the string is converted to an unsigned long int + * value in the obvious manner, stopping at the first character + * which is not a valid digit in the given base. (In bases above 10, + * the letter `A' in either upper or lower case represents 10, + * `B' represents 11, and so forth, with `Z' representing 35.) + */ + for (; *nptr != '\0'; nptr++) { + c = *nptr; +#if defined(HAVE_LOCALE_H) + if (base == 10 + && loc.thousands_sep != NULL + && loc.thousands_sep[0] != '\0' + && c == loc.thousands_sep[0]) + continue; +#endif + switch (c) { + case '0': case '1': case '2': + case '3': case '4': case '5': + case '6': case '7': case '8': + case '9': + val = c - '0'; + if (val >= base) /* even base 2 allowed ... */ + goto out; + result *= base; + result += val; + sawdigs = TRUE; + break; + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + c += 'a' - 'A'; /* downcase */ + /* fall through */ + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': + cp = strchr(lower, c); + val = cp - lower; + val += 10; /* 'a' == 10 */ + if (val >= base) + goto out; + result *= base; + result += val; + sawdigs = TRUE; + break; + default: + goto out; + } + } +out: + /* + * If endptr is not NULL, strtoul() stores the address of the + * first invalid character in *endptr. If there were no digits + * at all, strtoul() stores the original value of nptr in *endptr + * (and returns 0). In particular, if *nptr is not `\0' but + * **endptr is `\0' on return, the entire string is valid. + */ + if (endptr != NULL) { + if (! sawdigs) { + *endptr = nptr_orig; + return 0; + } else + *endptr = (char *) nptr; + } + + /* + * RETURN VALUE + * The strtoul() function returns either the result of the + * conversion or, if there was a leading minus sign, the + * negation of the result of the conversion, unless the original + * (non-negated) value would overflow; in the latter case, + * strtoul() returns ULONG_MAX and sets the global variable errno + * to ERANGE. + */ + + /* + * ADR: This computation is probably bogus. If it's a + * problem, upgrade to a modern system. + */ + if (neg && result == ULONG_MAX) { + errno = ERANGE; + return ULONG_MAX; + } else if (neg) + result = -result; + + return result; +} + +#ifdef TEST +#undef strtoul +int main(void) +{ + char *endptr; + unsigned long res1, res2; + + res1 = strtoul("0xdeadBeeF", & endptr, 0), + res2 = mystrtoul("0xdeadBeeF", & endptr, 0), +printf("(real,my)strtoul(\"0xdeadBeeF\", & endptr, 0) is %lu, %lu *endptr = %d\n", + res1, res2, *endptr); + + res1 = strtoul("0101101", & endptr, 2), + res2 = mystrtoul("0101101", & endptr, 2), +printf("(real,my)strtoul(\"0101101\", & endptr, 2) is %lu, %lu *endptr = %d\n", + res1, res2, *endptr); + + res1 = strtoul("01011012", & endptr, 2), + res2 = mystrtoul("01011012", & endptr, 2), +printf("(real,my)strtoul(\"01011012\", & endptr, 2) is %lu, %lu *endptr = %d\n", + res1, res2, *endptr); + + res1 = strtoul(" +42a", & endptr, 0), + res2 = mystrtoul(" +42a", & endptr, 0), +printf("(real,my)strtoul(\" +42a\", & endptr, 0) is %lu, %lu *endptr = %d\n", + res1, res2, *endptr); + + res1 = strtoul("0377", & endptr, 0), + res2 = mystrtoul("0377", & endptr, 0), +printf("(real,my)strtoul(\"0377\", & endptr, 0) is %lu, %lu *endptr = %d\n", + res1, res2, *endptr); + + res1 = strtoul("Z", & endptr, 36), + res2 = mystrtoul("Z", & endptr, 36), +printf("(real,my)strtoul(\"Z\", & endptr, 36) is %lu, %lu *endptr = %d\n", + res1, res2, *endptr); + + res1 = strtoul("qZ*", & endptr, 36), + res2 = mystrtoul("qZ*", & endptr, 36), +printf("(real,my)strtoul(\"qZ*\", & endptr, 36) is %lu, %lu *endptr = %d\n", + res1, res2, *endptr); +} +#endif diff --git a/missing_d/system.c b/missing_d/system.c new file mode 100644 index 0000000..7d1a4ee --- /dev/null +++ b/missing_d/system.c @@ -0,0 +1,27 @@ +/* system.c --- replacement system() for systems missing one + + Copyright (C) 1986, 1988, 1989, 1991 the Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +extern void fatal(); + +int +system(s) +char *s; +{ + fatal("system() not supported on this system"); + return 0; +} diff --git a/missing_d/tzset.c b/missing_d/tzset.c new file mode 100644 index 0000000..678ec66 --- /dev/null +++ b/missing_d/tzset.c @@ -0,0 +1,39 @@ +/* + * tzset.c + * + * Quick and dirty emulation of tzset(), tzname[], and daylight + * for old BSD systems without it. + * + * Thanks to Rick Adams, rick@uunet.uu.net, for the basics. + * + * BUGS: + * Totally ignores the value of the TZ environment variable. + */ + +#if 0 +#include +#endif +#include + +static char tz1[1024]; +static char tz2[1024]; + +/* external variables */ +char *tzname[2] = { + tz1, tz2 +}; +int daylight; + +extern char *timezone(); + +void +tzset() +{ + struct timeval tp; + struct timezone tz; + + (void) gettimeofday(&tp, &tz); + (void) strcpy(tz1, timezone(tz.tz_minuteswest, 0)); + (void) strcpy(tz2, timezone(tz.tz_minuteswest, 1)); + daylight = tz.tz_dsttime; +} diff --git a/missing_d/usleep.c b/missing_d/usleep.c new file mode 100644 index 0000000..cb1c7ab --- /dev/null +++ b/missing_d/usleep.c @@ -0,0 +1,17 @@ +/* + * usleep - round microseconds up to an integral number of seconds. + * + * The real usleep() doesn't work this way; this is a hack for systems + * that don't have usleep(). + */ + +int +usleep(unsigned int usec) +{ + unsigned int seconds = usec / 1000000; + + /* Round up: */ + seconds += (usec % 1000000 > 0); /* 1 or 0 */ + + return sleep(seconds); +} diff --git a/missing_d/wcmisc.c b/missing_d/wcmisc.c new file mode 100644 index 0000000..d2b7aa0 --- /dev/null +++ b/missing_d/wcmisc.c @@ -0,0 +1,100 @@ +/* wcmisc.c - replace wcXXXX routines + Copyright (C) 2011 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., + 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA */ + +#if !defined(HAVE_WCTYPE) || !defined(HAVE_ISWCTYPE) +static const char *classes[] = { + "", + "alnum", + "alpha", + "blank", + "cntrl", + "digit", + "graph", + "lower", + "print", + "punct", + "space", + "upper", + "xdigit", + NULL +}; +#endif + +#ifndef HAVE_ISWCTYPE +static int is_blank (int c) +{ + return (c == ' ' || c == '\t'); +} +#endif + +#ifndef HAVE_WCTYPE +wctype_t wctype(const char *name) +{ + int i; + + for (i = 1; classes[i] != NULL; i++) + if (strcmp(name, classes[i]) == 0) + return i; + + return 0; +} +#endif + +#ifndef HAVE_ISWCTYPE +int iswctype(wint_t wc, wctype_t desc) +{ + int j = sizeof(classes) / sizeof(classes[0]); + + if (desc >= j || desc == 0) + return 0; + + switch (desc) { + case 1: return isalnum(wc); + case 2: return isalpha(wc); + case 3: return is_blank(wc); + case 4: return iscntrl(wc); + case 5: return isdigit(wc); + case 6: return isgraph(wc); + case 7: return islower(wc); + case 8: return isprint(wc); + case 9: return ispunct(wc); + case 10: return isspace(wc); + case 11: return isupper(wc); + case 12: return isxdigit(wc); + default: return 0; + } +} +#endif + +#ifndef HAVE_WCSCOLL +int wcscoll(const wchar_t *ws1, const wchar_t *ws2) +{ + size_t i; + + for (i = 0; ws1[i] != 0 && ws2[i] != 0; i++) { + if (ws1[i] < ws2[i]) + return -1; + else if (ws1[i] > ws2[i]) + return 1; + } + + return (ws1[i] - ws2[i]); +} +#endif + +/*wcmisc.c*/ diff --git a/mkinstalldirs b/mkinstalldirs new file mode 100755 index 0000000..ef7e16f --- /dev/null +++ b/mkinstalldirs @@ -0,0 +1,161 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy + +scriptversion=2006-05-11.19 + +# Original author: Noah Friedman +# Created: 1993-05-16 +# Public domain. +# +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +nl=' +' +IFS=" "" $nl" +errstatus=0 +dirmode= + +usage="\ +Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... + +Create each directory DIR (with mode MODE, if specified), including all +leading file name components. + +Report bugs to ." + +# process command line arguments +while test $# -gt 0 ; do + case $1 in + -h | --help | --h*) # -h for help + echo "$usage" + exit $? + ;; + -m) # -m PERM arg + shift + test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } + dirmode=$1 + shift + ;; + --version) + echo "$0 $scriptversion" + exit $? + ;; + --) # stop option processing + shift + break + ;; + -*) # unknown option + echo "$usage" 1>&2 + exit 1 + ;; + *) # first non-opt arg + break + ;; + esac +done + +for file +do + if test -d "$file"; then + shift + else + break + fi +done + +case $# in + 0) exit 0 ;; +esac + +# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and +# mkdir -p a/c at the same time, both will detect that a is missing, +# one will create a, then the other will try to create a and die with +# a "File exists" error. This is a problem when calling mkinstalldirs +# from a parallel make. We use --version in the probe to restrict +# ourselves to GNU mkdir, which is thread-safe. +case $dirmode in + '') + if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + echo "mkdir -p -- $*" + exec mkdir -p -- "$@" + else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + test -d ./-p && rmdir ./-p + test -d ./--version && rmdir ./--version + fi + ;; + *) + if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && + test ! -d ./--version; then + echo "mkdir -m $dirmode -p -- $*" + exec mkdir -m "$dirmode" -p -- "$@" + else + # Clean up after NextStep and OpenStep mkdir. + for d in ./-m ./-p ./--version "./$dirmode"; + do + test -d $d && rmdir $d + done + fi + ;; +esac + +for file +do + case $file in + /*) pathcomp=/ ;; + *) pathcomp= ;; + esac + oIFS=$IFS + IFS=/ + set fnord $file + shift + IFS=$oIFS + + for d + do + test "x$d" = x && continue + + pathcomp=$pathcomp$d + case $pathcomp in + -*) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + else + if test ! -z "$dirmode"; then + echo "chmod $dirmode $pathcomp" + lasterr= + chmod "$dirmode" "$pathcomp" || lasterr=$? + + if test ! -z "$lasterr"; then + errstatus=$lasterr + fi + fi + fi + fi + + pathcomp=$pathcomp/ + done +done + +exit $errstatus + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/msg.c b/msg.c new file mode 100644 index 0000000..3ed0233 --- /dev/null +++ b/msg.c @@ -0,0 +1,148 @@ +/* + * msg.c - routines for error messages. + */ + +/* + * Copyright (C) 1986, 1988, 1989, 1991-2001, 2003, 2010 + * the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "awk.h" + +extern FILE *output_fp; +int sourceline = 0; +char *source = NULL; +static const char *srcfile = NULL; +static int srcline; + +jmp_buf fatal_tag; +int fatal_tag_valid = FALSE; + +/* err --- print an error message with source line and file and record */ + +/* VARARGS2 */ +void +err(const char *s, const char *emsg, va_list argp) +{ + char *file; + const char *me; + + (void) fflush(output_fp); + me = myname; + if (strncmp(me, "dgawk", 5) == 0) + me = &myname[1]; + (void) fprintf(stderr, "%s: ", me); +#ifdef GAWKDEBUG + if (srcfile != NULL) { + fprintf(stderr, "%s:%d:", srcfile, srcline); + srcfile = NULL; + } +#endif /* GAWKDEBUG */ + + if (sourceline > 0) { + if (source != NULL) + (void) fprintf(stderr, "%s:", source); + else + (void) fprintf(stderr, _("cmd. line:")); + + (void) fprintf(stderr, "%d: ", sourceline); + } + if (FNR > 0) { + file = FILENAME_node->var_value->stptr; + (void) putc('(', stderr); + if (file) + (void) fprintf(stderr, "FILENAME=%s ", file); + (void) fprintf(stderr, "FNR=%ld) ", FNR); + } + (void) fprintf(stderr, "%s", s); + vfprintf(stderr, emsg, argp); + (void) fprintf(stderr, "\n"); + (void) fflush(stderr); +} + +/* msg --- take a varargs error message and print it */ + +void +msg(const char *mesg, ...) +{ + va_list args; + va_start(args, mesg); + err("", mesg, args); + va_end(args); +} + +/* warning --- print a warning message */ + +void +warning(const char *mesg, ...) +{ + va_list args; + va_start(args, mesg); + err(_("warning: "), mesg, args); + va_end(args); +} + +void +error(const char *mesg, ...) +{ + va_list args; + va_start(args, mesg); + err(_("error: "), mesg, args); + va_end(args); +} + +/* set_loc --- set location where a fatal error happened */ + +void +set_loc(const char *file, int line) +{ + srcfile = file; + srcline = line; + + /* This stupid line keeps some compilers happy: */ + file = srcfile; line = srcline; +} + +/* r_fatal --- print a fatal error message */ + +void +r_fatal(const char *mesg, ...) +{ + va_list args; + va_start(args, mesg); + err(_("fatal: "), mesg, args); + va_end(args); +#ifdef GAWKDEBUG + abort(); +#endif + gawk_exit(EXIT_FATAL); +} + +/* gawk_exit --- longjmp out if necessary */ + +void +gawk_exit(int status) +{ + if (fatal_tag_valid) { + exit_val = status; + longjmp(fatal_tag, 1); + } + exit(status); +} diff --git a/node.c b/node.c new file mode 100644 index 0000000..204a91f --- /dev/null +++ b/node.c @@ -0,0 +1,965 @@ +/* + * node.c -- routines for node management + */ + +/* + * Copyright (C) 1986, 1988, 1989, 1991-2001, 2003-2011, + * the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "awk.h" +#include "math.h" + +static int is_ieee_magic_val(const char *val); +static AWKNUM get_ieee_magic_val(const char *val); + +/* force_number --- force a value to be numeric */ + +AWKNUM +r_force_number(NODE *n) +{ + char *cp; + char *cpend; + char save; + char *ptr; + unsigned int newflags; + extern double strtod(); + + if (n->flags & NUMCUR) + return n->numbr; + + /* all the conditionals are an attempt to avoid the expensive strtod */ + + /* Note: only set NUMCUR if we actually convert some digits */ + + n->numbr = 0.0; + + if (n->stlen == 0) { + return 0.0; + } + + cp = n->stptr; + /* + * 2/2007: + * POSIX, by way of severe language lawyering, seems to + * allow things like "inf" and "nan" to mean something. + * So if do_posix, the user gets what he deserves. + * This also allows hexadecimal floating point. Ugh. + */ + if (! do_posix) { + if (isalpha((unsigned char) *cp)) { + return 0.0; + } else if (n->stlen == 4 && is_ieee_magic_val(n->stptr)) { + if (n->flags & MAYBE_NUM) + n->flags &= ~MAYBE_NUM; + n->flags |= NUMBER|NUMCUR; + n->numbr = get_ieee_magic_val(n->stptr); + + return n->numbr; + } + /* else + fall through */ + } + /* else not POSIX, so + fall through */ + + cpend = cp + n->stlen; + while (cp < cpend && isspace((unsigned char) *cp)) + cp++; + + if ( cp == cpend /* only spaces, or */ + || (! do_posix /* not POSIXLY paranoid and */ + && (isalpha((unsigned char) *cp) /* letter, or */ + /* CANNOT do non-decimal and saw 0x */ + || (! do_non_decimal_data && cp[0] == '0' + && (cp[1] == 'x' || cp[1] == 'X'))))) { + return 0.0; + } + + if (n->flags & MAYBE_NUM) { + newflags = NUMBER; + n->flags &= ~MAYBE_NUM; + } else + newflags = 0; + + if (cpend - cp == 1) { /* only one character */ + if (isdigit((unsigned char) *cp)) { /* it's a digit! */ + n->numbr = (AWKNUM)(*cp - '0'); + n->flags |= newflags; + n->flags |= NUMCUR; + } + return n->numbr; + } + + if (do_non_decimal_data) { /* main.c assures false if do_posix */ + errno = 0; + if (! do_traditional && isnondecimal(cp, TRUE)) { + n->numbr = nondec2awknum(cp, cpend - cp); + n->flags |= NUMCUR; + ptr = cpend; + goto finish; + } + } + + errno = 0; + save = *cpend; + *cpend = '\0'; + n->numbr = (AWKNUM) strtod((const char *) cp, &ptr); + + /* POSIX says trailing space is OK for NUMBER */ + while (isspace((unsigned char) *ptr)) + ptr++; + *cpend = save; +finish: + if (errno == 0 && ptr == cpend) { + n->flags |= newflags; + n->flags |= NUMCUR; + } else { + errno = 0; + } + + return n->numbr; +} + + +/* + * The following lookup table is used as an optimization in force_string; + * (more complicated) variations on this theme didn't seem to pay off, but + * systematic testing might be in order at some point. + */ +static const char *values[] = { + "0", + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", +}; +#define NVAL (sizeof(values)/sizeof(values[0])) + +/* format_val --- format a numeric value based on format */ + +NODE * +format_val(const char *format, int index, NODE *s) +{ + char buf[BUFSIZ]; + char *sp = buf; + double val; + char *orig, *trans, save; + + if (! do_traditional && (s->flags & INTLSTR) != 0) { + save = s->stptr[s->stlen]; + s->stptr[s->stlen] = '\0'; + + orig = s->stptr; + trans = dgettext(TEXTDOMAIN, orig); + + s->stptr[s->stlen] = save; + return make_string(trans, strlen(trans)); + } + + /* + * 2/2007: Simplify our lives here. Instead of worrying about + * whether or not the value will fit into a long just so we + * can use sprintf("%ld", val) on it, always format it ourselves. + * The only thing to worry about is that integral values always + * format as integers. %.0f does that very well. + * + * 6/2008: Would that things were so simple. Always using %.0f + * imposes a notable performance penalty for applications that + * do a lot of conversion of integers to strings. So, we reinstate + * the old code, but use %.0f for integral values that are outside + * the range of a long. This seems a reasonable compromise. + * + * 12/2009: Use <= and >= in the comparisons with LONG_xxx instead of + * < and > so that things work correctly on systems with 64 bit integers. + */ + + /* not an integral value, or out of range */ + if ((val = double_to_int(s->numbr)) != s->numbr + || val <= LONG_MIN || val >= LONG_MAX) { + /* + * Once upon a time, we just blindly did this: + * sprintf(sp, format, s->numbr); + * s->stlen = strlen(sp); + * s->stfmt = (char) index; + * but that's no good if, e.g., OFMT is %s. So we punt, + * and just always format the value ourselves. + */ + + NODE *dummy[2], *r; + unsigned short oflags; + extern NODE **fmt_list; /* declared in eval.c */ + + /* create dummy node for a sole use of format_tree */ + dummy[1] = s; + oflags = s->flags; + if (val == s->numbr) { + /* integral value, but outside range of %ld, use %.0f */ + r = format_tree("%.0f", 4, dummy, 2); + s->stfmt = -1; + } else { + r = format_tree(format, fmt_list[index]->stlen, dummy, 2); + assert(r != NULL); + s->stfmt = (char) index; + } + s->flags = oflags; + s->stlen = r->stlen; + if ((s->flags & STRCUR) != 0) + efree(s->stptr); + s->stptr = r->stptr; + freenode(r); /* Do not unref(r)! We want to keep s->stptr == r->stpr. */ + + goto no_malloc; + } else { + /* + * integral value + * force conversion to long only once + */ + long num = (long) val; + + if (num < NVAL && num >= 0) { + sp = (char *) values[num]; + s->stlen = 1; + } else { + (void) sprintf(sp, "%ld", num); + s->stlen = strlen(sp); + } + s->stfmt = -1; + } + if (s->stptr != NULL) + efree(s->stptr); + emalloc(s->stptr, char *, s->stlen + 2, "format_val"); + memcpy(s->stptr, sp, s->stlen+1); +no_malloc: + s->flags |= STRCUR; + free_wstr(s); + return s; +} + +/* force_string --- force a value to be a string */ + +NODE * +r_force_string(NODE *s) +{ + if ((s->flags & STRCUR) != 0 + && (s->stfmt == -1 || s->stfmt == CONVFMTidx) + ) + return s; + return format_val(CONVFMT, CONVFMTidx, s); +} + +/* dupnode --- duplicate a node */ + +NODE * +dupnode(NODE *n) +{ + NODE *r; + + if (n->type == Node_ahash) { + n->ahname_ref++; + return n; + } + + assert(n->type == Node_val); + + if ((n->flags & PERM) != 0) + return n; + + if ((n->flags & MALLOC) != 0) { + n->valref++; + return n; + } + + getnode(r); + *r = *n; + r->flags &= ~FIELD; + r->flags |= MALLOC; + r->valref = 1; +#if MBS_SUPPORT + /* + * DON'T call free_wstr(r) here! + * r->wstptr still points at n->wstptr's value, and we + * don't want to free it! + */ + r->wstptr = NULL; + r->wstlen = 0; +#endif /* MBS_SUPPORT */ + + if ((n->flags & STRCUR) != 0) { + emalloc(r->stptr, char *, n->stlen + 2, "dupnode"); + memcpy(r->stptr, n->stptr, n->stlen); + r->stptr[n->stlen] = '\0'; +#if MBS_SUPPORT + if ((n->flags & WSTRCUR) != 0) { + r->wstlen = n->wstlen; + emalloc(r->wstptr, wchar_t *, sizeof(wchar_t) * (n->wstlen + 2), "dupnode"); + memcpy(r->wstptr, n->wstptr, n->wstlen * sizeof(wchar_t)); + r->wstptr[n->wstlen] = L'\0'; + r->flags |= WSTRCUR; + } +#endif /* MBS_SUPPORT */ + } + + return r; +} + +/* mk_number --- allocate a node with defined number */ + +NODE * +mk_number(AWKNUM x, unsigned int flags) +{ + NODE *r; + + getnode(r); + r->type = Node_val; + r->numbr = x; + r->valref = 1; + r->flags = flags; + r->stptr = NULL; + r->stlen = 0; + free_wstr(r); + return r; +} + +/* make_str_node --- make a string node */ + +NODE * +r_make_str_node(const char *s, unsigned long len, int flags) +{ + NODE *r; + + getnode(r); + r->type = Node_val; + r->numbr = 0; + r->flags = (STRING|STRCUR|MALLOC); +#if MBS_SUPPORT + r->wstptr = NULL; + r->wstlen = 0; +#endif /* MBS_SUPPORT */ + + if (flags & ALREADY_MALLOCED) + r->stptr = (char *) s; + else { + emalloc(r->stptr, char *, len + 2, "make_str_node"); + memcpy(r->stptr, s, len); + } + r->stptr[len] = '\0'; + + if ((flags & SCAN) != 0) { /* scan for escape sequences */ + const char *pf; + char *ptm; + int c; + const char *end; +#if MBS_SUPPORT + mbstate_t cur_state; + + memset(& cur_state, 0, sizeof(cur_state)); +#endif + + end = &(r->stptr[len]); + for (pf = ptm = r->stptr; pf < end;) { +#if MBS_SUPPORT + /* + * Keep multibyte characters together. This avoids + * problems if a subsequent byte of a multibyte + * character happens to be a backslash. + */ + if (gawk_mb_cur_max > 1) { + int mblen = mbrlen(pf, end-pf, &cur_state); + + if (mblen > 1) { + int i; + + for (i = 0; i < mblen; i++) + *ptm++ = *pf++; + continue; + } + } +#endif + c = *pf++; + if (c == '\\') { + c = parse_escape(&pf); + if (c < 0) { + if (do_lint) + lintwarn(_("backslash at end of string")); + c = '\\'; + } + *ptm++ = c; + } else + *ptm++ = c; + } + len = ptm - r->stptr; + erealloc(r->stptr, char *, len + 1, "make_str_node"); + r->stptr[len] = '\0'; + r->flags &= ~MALLOC; + r->flags |= PERM; + } + r->stlen = len; + r->valref = 1; + r->stfmt = -1; + + return r; +} + +/* more_nodes --- allocate more nodes */ + +#define NODECHUNK 100 + +NODE *nextfree = NULL; + +NODE * +more_nodes() +{ + NODE *np; + + /* get more nodes and initialize list */ + emalloc(nextfree, NODE *, NODECHUNK * sizeof(NODE), "more_nodes"); + memset(nextfree, 0, NODECHUNK * sizeof(NODE)); + for (np = nextfree; np <= &nextfree[NODECHUNK - 1]; np++) { + np->nextp = np + 1; + } + --np; + np->nextp = NULL; + np = nextfree; + nextfree = nextfree->nextp; + return np; +} + +/* unref --- remove reference to a particular node */ + +void +unref(NODE *tmp) +{ + if (tmp == NULL) + return; + if ((tmp->flags & PERM) != 0) + return; + + if (tmp->type == Node_ahash) { + if (tmp->ahname_ref > 1) + tmp->ahname_ref--; + else { + efree(tmp->ahname_str); + freenode(tmp); + } + return; + } + + if ((tmp->flags & MALLOC) != 0) { + if (tmp->valref > 1) { + tmp->valref--; + return; + } + if (tmp->flags & STRCUR) + efree(tmp->stptr); + } + free_wstr(tmp); + freenode(tmp); +} + + +/* + * parse_escape: + * + * Parse a C escape sequence. STRING_PTR points to a variable containing a + * pointer to the string to parse. That pointer is updated past the + * characters we use. The value of the escape sequence is returned. + * + * A negative value means the sequence \ newline was seen, which is supposed to + * be equivalent to nothing at all. + * + * If \ is followed by a null character, we return a negative value and leave + * the string pointer pointing at the null character. + * + * If \ is followed by 000, we return 0 and leave the string pointer after the + * zeros. A value of 0 does not mean end of string. + * + * POSIX doesn't allow \x. + */ + +int +parse_escape(const char **string_ptr) +{ + int c = *(*string_ptr)++; + int i; + int count; + int j; + const char *start; + + if (do_lint_old) { + switch (c) { + case 'a': + case 'b': + case 'f': + case 'r': + warning(_("old awk does not support the `\\%c' escape sequence"), c); + break; + } + } + + switch (c) { + case 'a': + return '\a'; + case 'b': + return '\b'; + case 'f': + return '\f'; + case 'n': + return '\n'; + case 'r': + return '\r'; + case 't': + return '\t'; + case 'v': + return '\v'; + case '\n': + return -2; + case 0: + (*string_ptr)--; + return -1; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + i = c - '0'; + count = 0; + while (++count < 3) { + if ((c = *(*string_ptr)++) >= '0' && c <= '7') { + i *= 8; + i += c - '0'; + } else { + (*string_ptr)--; + break; + } + } + return i; + case 'x': + if (do_lint) { + static short warned = FALSE; + + if (! warned) { + warned = TRUE; + lintwarn(_("POSIX does not allow `\\x' escapes")); + } + } + if (do_posix) + return ('x'); + if (! isxdigit((unsigned char) (*string_ptr)[0])) { + warning(_("no hex digits in `\\x' escape sequence")); + return ('x'); + } + i = j = 0; + start = *string_ptr; + for (;; j++) { + /* do outside test to avoid multiple side effects */ + c = *(*string_ptr)++; + if (isxdigit(c)) { + i *= 16; + if (isdigit(c)) + i += c - '0'; + else if (isupper(c)) + i += c - 'A' + 10; + else + i += c - 'a' + 10; + } else { + (*string_ptr)--; + break; + } + } + if (do_lint && j > 2) + lintwarn(_("hex escape \\x%.*s of %d characters probably not interpreted the way you expect"), j, start, j); + return i; + case '\\': + case '"': + return c; + default: + { + static short warned[256]; + unsigned char uc = (unsigned char) c; + + /* N.B.: use unsigned char here to avoid Latin-1 problems */ + + if (! warned[uc]) { + warned[uc] = TRUE; + + warning(_("escape sequence `\\%c' treated as plain `%c'"), uc, uc); + } + } + return c; + } +} + +/* isnondecimal --- return true if number is not a decimal number */ + +int +isnondecimal(const char *str, int use_locale) +{ + int dec_point = '.'; +#if defined(HAVE_LOCALE_H) + /* + * loc.decimal_point may not have been initialized yet, + * so double check it before using it. + */ + if (use_locale && loc.decimal_point != NULL && loc.decimal_point[0] != '\0') + dec_point = loc.decimal_point[0]; /* XXX --- assumes one char */ +#endif + + if (str[0] != '0') + return FALSE; + + /* leading 0x or 0X */ + if (str[1] == 'x' || str[1] == 'X') + return TRUE; + + /* + * Numbers with '.', 'e', or 'E' are decimal. + * Have to check so that things like 00.34 are handled right. + * + * These beasts can have trailing whitespace. Deal with that too. + */ + for (; *str != '\0'; str++) { + if (*str == 'e' || *str == 'E' || *str == dec_point) + return FALSE; + else if (! isdigit((unsigned char) *str)) + break; + } + + return TRUE; +} + +#if MBS_SUPPORT +/* str2wstr --- convert a multibyte string to a wide string */ + +NODE * +str2wstr(NODE *n, size_t **ptr) +{ + size_t i, count, src_count; + char *sp; + mbstate_t mbs; + wchar_t wc, *wsp; + static short warned = FALSE; + + assert((n->flags & (STRING|STRCUR)) != 0); + + /* + * Don't convert global null string or global null field + * variables to a wide string. They are both zero-length anyway. + * This also avoids future double-free errors while releasing + * shallow copies, eg. *tmp = *Null_field; free_wstr(tmp); + */ + if (n == Nnull_string || n == Null_field) + return n; + + if ((n->flags & WSTRCUR) != 0) { + if (ptr == NULL) + return n; + /* otherwise + fall through and recompute to fill in the array */ + free_wstr(n); + } + + /* + * After consideration and consultation, this + * code trades space for time. We allocate + * an array of wchar_t that is n->stlen long. + * This is needed in the worst case anyway, where + * each input byte maps to one wchar_t. The + * advantage is that we only have to convert the string + * once, instead of twice, once to find out how many + * wide characters, and then again to actually fill in + * the info. If there's a lot left over, we can + * realloc the wide string down in size. + */ + + emalloc(n->wstptr, wchar_t *, sizeof(wchar_t) * (n->stlen + 2), "str2wstr"); + wsp = n->wstptr; + + /* + * For use by do_match, create and fill in an array. + * For each byte `i' in n->stptr (the original string), + * a[i] is equal to `j', where `j' is the corresponding wchar_t + * in the converted wide string. + * + * Create the array. + */ + if (ptr != NULL) { + emalloc(*ptr, size_t *, sizeof(size_t) * n->stlen, "str2wstr"); + memset(*ptr, 0, sizeof(size_t) * n->stlen); + } + + sp = n->stptr; + src_count = n->stlen; + memset(& mbs, 0, sizeof(mbs)); + for (i = 0; src_count > 0; i++) { + /* + * 9/2010: Check the current byte; if it's a valid character, + * then it doesn't start a multibyte sequence. This brings a + * big speed up. Thanks to Ulrich Drepper for the tip. + * 11/2010: Thanks to Paolo Bonzini for some even faster code. + */ + if (is_valid_character(*sp)) { + count = 1; + wc = btowc_cache(*sp); + } else + count = mbrtowc(& wc, sp, src_count, & mbs); + switch (count) { + case (size_t) -2: + case (size_t) -1: + /* + * Just skip the bad byte and keep going, so that + * we get a more-or-less full string, instead of + * stopping early. This is particularly important + * for match() where we need to build the indices. + */ + sp++; + src_count--; + /* + * mbrtowc(3) says the state of mbs becomes undefined + * after a bad character, so reset it. + */ + memset(& mbs, 0, sizeof(mbs)); + /* And warn the user something's wrong */ + if (do_lint && ! warned) { + warned = TRUE; + lintwarn(_("Invalid multibyte data detected. There may be a mismatch between your data and your locale.")); + } + break; + + case 0: + count = 1; + /* fall through */ + default: + *wsp++ = wc; + src_count -= count; + while (count--) { + if (ptr != NULL) + (*ptr)[sp - n->stptr] = i; + sp++; + } + break; + } + } + + *wsp = L'\0'; + n->wstlen = wsp - n->wstptr; + n->flags |= WSTRCUR; +#define ARBITRARY_AMOUNT_TO_GIVE_BACK 100 + if (n->stlen - n->wstlen > ARBITRARY_AMOUNT_TO_GIVE_BACK) + erealloc(n->wstptr, wchar_t *, sizeof(wchar_t) * (n->wstlen + 2), "str2wstr"); + + return n; +} + +/* wstr2str --- convert a wide string back into multibyte one */ + +NODE * +wstr2str(NODE *n) +{ + size_t result; + size_t length; + wchar_t *wp; + mbstate_t mbs; + char *newval, *cp; + + assert(n->valref == 1); + assert((n->flags & WSTRCUR) != 0); + + /* + * Convert the wide chars in t1->wstptr back into m.b. chars. + * This is pretty grotty, but it's the most straightforward + * way to do things. + */ + memset(& mbs, 0, sizeof(mbs)); + + length = n->wstlen; + emalloc(newval, char *, (length * gawk_mb_cur_max) + 2, "wstr2str"); + + wp = n->wstptr; + for (cp = newval; length > 0; length--) { + result = wcrtomb(cp, *wp, & mbs); + if (result == (size_t) -1) /* what to do? break seems best */ + break; + cp += result; + wp++; + } + *cp = '\0'; + + efree(n->stptr); + n->stptr = newval; + n->stlen = cp - newval; + + return n; +} + +/* free_wstr --- release the wide string part of a node */ + +void +free_wstr(NODE *n) +{ + assert(n->type == Node_val); + + if ((n->flags & WSTRCUR) != 0) { + assert(n->wstptr != NULL); + efree(n->wstptr); + } + n->wstptr = NULL; + n->wstlen = 0; + n->flags &= ~WSTRCUR; +} + +static void __attribute__ ((unused)) +dump_wstr(FILE *fp, const wchar_t *str, size_t len) +{ + if (str == NULL || len == 0) + return; + + for (; len--; str++) + putwc(*str, fp); +} + +/* wstrstr --- walk haystack, looking for needle, wide char version */ + +const wchar_t * +wstrstr(const wchar_t *haystack, size_t hs_len, + const wchar_t *needle, size_t needle_len) +{ + size_t i; + + if (haystack == NULL || needle == NULL || needle_len > hs_len) + return NULL; + + for (i = 0; i < hs_len; i++) { + if (haystack[i] == needle[0] + && i+needle_len-1 < hs_len + && haystack[i+needle_len-1] == needle[needle_len-1]) { + /* first & last chars match, check string */ + if (memcmp(haystack+i, needle, sizeof(wchar_t) * needle_len) == 0) { + return haystack + i; + } + } + } + + return NULL; +} + +/* wcasestrstr --- walk haystack, nocase look for needle, wide char version */ + +const wchar_t * +wcasestrstr(const wchar_t *haystack, size_t hs_len, + const wchar_t *needle, size_t needle_len) +{ + size_t i, j; + + if (haystack == NULL || needle == NULL || needle_len > hs_len) + return NULL; + + for (i = 0; i < hs_len; i++) { + if (towlower(haystack[i]) == towlower(needle[0]) + && i+needle_len-1 < hs_len + && towlower(haystack[i+needle_len-1]) == towlower(needle[needle_len-1])) { + /* first & last chars match, check string */ + const wchar_t *start; + + start = haystack+i; + for (j = 0; j < needle_len; j++, start++) { + wchar_t h, n; + + h = towlower(*start); + n = towlower(needle[j]); + if (h != n) + goto out; + } + return haystack + i; + } +out: ; + } + + return NULL; +} +#endif /* MBS_SUPPORT */ + +/* is_ieee_magic_val --- return true for +inf, -inf, +nan, -nan */ + +static int +is_ieee_magic_val(const char *val) +{ + /* + * Avoid strncasecmp: it mishandles ASCII bytes in some locales. + * Assume the length is 4, as the caller checks this. + */ + return ( (val[0] == '+' || val[0] == '-') + && ( ( (val[1] == 'i' || val[1] == 'I') + && (val[2] == 'n' || val[2] == 'N') + && (val[3] == 'f' || val[3] == 'F')) + || ( (val[1] == 'n' || val[1] == 'N') + && (val[2] == 'a' || val[2] == 'A') + && (val[3] == 'n' || val[3] == 'N')))); +} + +/* get_ieee_magic_val --- return magic value for string */ + +static AWKNUM +get_ieee_magic_val(const char *val) +{ + static short first = TRUE; + static AWKNUM inf; + static AWKNUM nan; + + char *ptr; + AWKNUM v = strtod(val, &ptr); + + if (val == ptr) { /* Older strtod implementations don't support inf or nan. */ + if (first) { + first = FALSE; + nan = sqrt(-1.0); + inf = -log(0.0); + } + + v = ((val[1] == 'i' || val[1] == 'I') ? inf : nan); + if (val[0] == '-') + v = -v; + } + + return v; +} + +#if MBS_SUPPORT +wint_t btowc_cache[256]; + +/* init_btowc_cache --- initialize the cache */ + +void init_btowc_cache() +{ + int i; + + for (i = 0; i < 255; i++) { + btowc_cache[i] = btowc(i); + } +} +#endif diff --git a/pc/ChangeLog b/pc/ChangeLog new file mode 100644 index 0000000..837c5b5 --- /dev/null +++ b/pc/ChangeLog @@ -0,0 +1,109 @@ +2012-03-28 Arnold D. Robbins + + * 4.0.1: Release tar ball made. + +2012-03-20 Arnold D. Robbins + + * Makefile.tst (printfbad3): New test. + +2012-03-14 Eli Zaretskii + + * gawkmisc.pc (btowc): New version for DJGPP. + +2012-03-01 Scott Deifik + + * Makefile.tst: Sync with mainline version. + +2012-03-01 Eli Zaretskii + + * Makefile: Quiet confusing info messages from the linker when + gawk is linked against readline as a shared library. + +2012-02-22 Eli Zaretskii + + * Makefile.tst: Update CMP and CP definitions, add "Expect xxxx to + fail with MinGW" messages as needed. + +2012-02-15 Arnold D. Robbins + + * gawkmisc.pc (execvp): Modify signature, return -1 + on error. + +2012-02-11 Eli Zaretskii + + Fix dependencies in pc/Makefile. + * Makefile ($(ALLOBJS) $(LIBOBJS) eval_p$O profile_p$O): Add eval_d$O, + debug$O, and command$O. + + Support MinGW build with the readline library. + * Makefile (default): Add a line for the mingw32-readline target. + (mingw32-readline): New target, passes -DHAVE_LIBREADLINE to the + compiler and adds -lreadline to the linker command line. + + * config.sed: Comment out "#undef HAVE_LIBREADLINE", so that it + could be #define'd on the compiler command line. + +2012-02-10 Arnold D. Robbins + + * gawkmisc.pc (execvp): New function based on code from Eli + Zaretskii to make dgawk's restarting the debugger work. + +2012-01-27 Scott Deifik + + * Makefile.tst: Sync with mainline version. + +2011-12-06 Scott Deifik + + * Makefile.tst: Sync with mainline version. + Use testoutcmp.awk script. + +2011-12-06 Arnold D. Robbins + + * testoutcmp.awk: Script to replace cmd for DJGPP. + +2011-11-01 Scott Deifik + + * config.sed: Additional update. + +2011-10-29 Eli Zaretskii + + * config.sed: Fix some edits, to be consistent with the old + config.h file. Make regexps match #undef lines with whitespace + at the end of the line. Add forgotten EMX #defines. + +2011-10-27 Scott Deifik + + * Makefile.tst: Sync with mainline version. + +2011-10-24 Eli Zaretskii + + * gawkmisc.pc (wctob) [__MINGW32__]: A replacement for the + function of the same name in MS runtime, which does a better job + with 8-bit characters that have their high bit set. + Original supplied by Jim Meyering . + + * popen.h (system) [__MINGW32__]: Redirect to os_system. + + * Makefile (./doc/awkcard.tr): Don't use Unixy forward slashes in + redirection. + (builtin$O): Depend on popen.h. + (random$O): New target, separated from builtin$O. + + * configpk.sed: + * config.sed: + * make-config.bat: New files, to produce pc/config.h from the top-level + configh.in file. + +2011-10-18 Juan Manuel Guerrero + + * Makefile: doc target to create all documentation files. + +2011-09-30 Eli Zaretskii + + * config.h: Update packaging related versions. + +2011-06-23 Arnold D. Robbins + + * ChangeLog.0: Rotated ChangeLog into this file. + * ChangeLog: Created anew for gawk 4.0.0 and on. + * 4.0.0: Release tar ball made. diff --git a/pc/ChangeLog.0 b/pc/ChangeLog.0 new file mode 100644 index 0000000..9662120 --- /dev/null +++ b/pc/ChangeLog.0 @@ -0,0 +1,680 @@ +Mon Jun 20 20:37:19 2011 Arnold D. Robbins + + * Makefile.tst: Sync with mainline version. + +Mon Jun 20 20:16:58 2011 Eli Zaretskii + + * Makefile (LIBOBJS): Remove hard-locale$O. + (dfa$O): Remove hard-locale.h from prerequisites. + +Sun Jun 5 21:47:33 2011 Scott Deifik + + * Makefile.tst: Sync with mainline version. + +Tue May 31 23:09:13 2011 Arnold D. Robbins + + * Makefile.tst: Sync with mainline version. + +Tue May 31 23:07:20 2011 Scott Deifik + + * Makefile.tst (fpat2): Fix the test. + +Thu May 26 22:12:28 2011 Arnold D. Robbins + + * Makefile.tst: Sync with mainline version. + +Mon May 23 21:52:49 2011 Scott Deifik + + * Makefile.tst: Sync with mainline version. + +Sat May 14 22:30:06 2011 Arnold D. Robbins + + * Makefile.tst: Sync with mainline version. + +Mon May 9 15:13:18 2011 Arnold D. Robbins + + * Makefile.tst: Sync with mainline version. + +Sun May 8 20:57:16 2011 Arnold D. Robbins + + * Makefile.tst: Sync with mainline version. + +Mon May 2 23:34:54 2011 Scott Deifik + + * Makefile.tst: Sync with mainline version. + +Fri Apr 29 12:35:21 2011 Arnold D. Robbins + + * Makefile: Remove dependencies on awkprintf.h. + +Sun Apr 24 11:54:58 2011 Scott Deifik + + * Makefile.tst: Sync with mainline version. + +Fri Apr 1 11:50:59 2011 Arnold D. Robbins + + * config.h (ISATTY): Remove definition. + * gawkmisc.pc (os_iastty): New function. + +Sun Feb 27 22:58:08 2011 Scott Deifik + + * Makefile.tst: Sync with mainline version. + +Mon Feb 21 20:32:36 2011 Arnold D. Robbins + + * Makefile.tst (GAWK_EXT_TESTS): Include profile3. Thanks to + Scott Deifik for pointing out the omission. + +Wed Feb 16 21:09:50 2011 Arnold D. Robbins + + * Makefile.tst (lintwarn): New test. + +Wed Feb 16 20:40:27 2011 Scott Deifik + + * Makefile.tst: Sync with mainline version. + +Mon Feb 14 21:30:48 2011 Arnold Robbins + + * Makefile.tst: Sync with mainline version. + +Sun Feb 13 20:23:07 2011 Eli Zaretskii + + * gawkmisc.pc (files_are_same): Change arguments. Compare file + names and modification times in addition to devices and inodes. + * Makefile (LIBOBJS): Add hard-locale$O. + Update prerequisites. + * config.h (ISATTY) [__MINGW32__ || _MSC_VER]: Define. + +Mon Feb 7 22:45:28 2011 Arnold Robbins + + * Makefile.tst: Sync with mainline version. + +Tue Feb 1 23:15:45 2011 Scott Deifik + + * Makefile.tst: Sync with mainline version. + +Thu Jan 27 21:31:23 2011 Scott Deifik + + * Makefile.tst: Fixes for dumpvars and mv, cp, et. al. + +Mon Jan 17 22:21:07 2011 Scott Deifik + + * Makefile.tst: Sync with mainline version. + +Mon Jan 17 22:17:07 2011 Arnold Robbins + + * config.h: Remove definitions of PIPES_SIMULATED and _NFILE for + DJGPP. Per Eli, they aren't needed here. + +2011-01-08 Eli Zaretskii + + * popen.c (scriptify): Fix syntax error. + + * config.h (HAVE___ARGZ_COUNT, HAVE___ARGZ_NEXT) + (HAVE___ARGZ_STRINGIFY): Don't define. + (HAVE_PORTALS): Remove reference. + + * gawkmisc.pc (unsetenv) [__DJGPP__]: Implement. + (usleep) [__MINGW32__]: Resurrect. + +Tue Jan 4 11:20:40 2011 Arnold Robbins + + * config.h: Add PIPES_SIMULATED and definition of _NFILE for + DJGPP. + +Sat Dec 18 22:12:42 2010 Arnold Robbins + + * gawkw32.def: Removed. + * Makefile (gawk.exp): Removed target and rule. + +Sat Dec 18 20:13:35 2010 Eli Zaretskii + + * popen.h: Remove the parts conditioned by _MSC_VER and OS2. Use + __DJGPP__ instead of __GO32__. + + * popen.c (popen, pclose) [OS2, _MSC_VER]: Remove definitions. + (unixshell, scriptify, os_pclose): Remove OS2 parts. + + * getid.c: Remove the parts conditioned by _MSC_VER and OS2. + + * config.h: Remove the parts conditioned by _MSC_VER. + + * Makefile: Drop support for DJGPP v1.x and for Microsoft + compilers on DOS/Windows. + + * gawkmisc.pc (setenv, unsetenv) [__MINGW32__]: Emulations for MinGW. + + * Makefile (DLMINGW32): New variable. + (mingw32): Pass it to sub-Make. + + * dlfnc.h, dlfcn.c, include/*: Removed. + +Mon Nov 29 20:10:00 2010 Eli Zaretskii + + * config.h (HAVE_STRFTIME): Don't define for __MINGW32__. Define + strftime to rpl_strftime, to avoid infinite recursion in + missing_d/strftime.c. + +Fri Nov 12 12:36:18 2010 Scott Deifik + + * Makefile.tst: Sync with mainline version. + +Thu Oct 28 08:17:00 2010 Scott Deifik + + * Makefile.tst: Sync with mainline version. + +Wed Jul 14 23:05:57 2010 Eli Zaretskii + + * config.h (HAVE_USLEEP) [__MINGW32__]: Define. + + * gawkmisc.pc (usleep) [__MINGW32__]: Implementation of `usleep' + for MinGW. + +Thu May 6 20:55:14 2010 Arnold D. Robbins + + * Release 3.1.8: Release tar file made. + +Mon May 3 21:15:49 2010 Scott Deifik + + * Makefile.tst (lc_num1): Now passes, remove "expect to fail" + message. + +Tue Apr 13 22:13:51 2010 Scott Deifik + + * config.h, Makefile.tst: Sync with mainline. + +Tue Feb 2 20:49:20 2010 Scott Deifik + + * Makefile.tst: Sync with mainline. + +Tue Jul 21 22:28:56 2009 Arnold D. Robbins + + * Release 3.1.7: Release tar file made. + +Mon Jul 13 05:43:07 2009 Scott Deifik + + * Makefile.tst: Still more sync with mainline. + +Tue Jun 23 05:24:12 2009 Scott Deifik + + * Makefile.tst: More sync with mainline. + +Thu Jun 18 06:24:29 2009 Scott Deifik + + * Makefile.tst: Sync with mainline. + +2008-07-26 Eli Zaretskii + + * config.h (WEXITSTATUS) [_MSC_VER || __MINGW32__]: Define. + +Mon Oct 22 08:49:05 2007 Arnold D. Robbins + + * Release 3.1.6: Release tar file made. + +Sat Oct 20 22:42:08 2007 Scott Deifik + + * Makefile.tst: Sync with mainline, Revise inftest. + +Fri Oct 19 05:37:37 2007 Scott Deifik + + * config.h: Add definition of HAVE_ATEXIT. Needed for replacement + sprintf. + +Thu Oct 4 21:19:54 2007 Juan M. Guerrero + + * Makefile.tst (fmtspcl.ok): Remove unneeded dependency on Makefile. + +Wed Sep 26 15:10:17 2007 Scott Deifik + + * Makefile.tst (poundbang): Fix path in call to gawk. + (nofile): Fix output message with sed to match what test suite wants. + +Wed Sep 26 14:46:34 2007 Eli Zaretskii + + * Makefile.tst (msg): Use $(CMP) instead a literal "cmp". + (nonl): Use NUL instead of /dev/null. + (devfd, pid, fmtspcl, nofile, rstest4, rstest5, getlnhd, clos1way): + Expect to fail on MinGW. + (fmtspcl.ok): Depend on Makefile, not Makefile.tst. + (pipeio2, hsprint, fmttest): Expect formatting or whitespace + differences. + (exitval2): Use exitval2.w32 instead of exitval2.awk. + + * config.h (HAVE_DECL_TZNAME) [__MINGW32__]: Define. + (HAVE_ALLOCA) [__MINGW32__]: Don't define. + (HAVE_SNPRINTF) [__MINGW32__]: Remove _MSC_VER condition. + +Tue Sep 25 08:22:11 2007 KIMURA Koichi + + * config.h: For Visual Studio, undef restrict, define HAVE_TMPFILE, + undef TIME_WITH_SYS_TIME. + +Mon May 21 05:46:46 2007 Scott Deifik + + * config.h (HAVE_MKTIME): Define. + +Wed May 16 22:12:55 2007 Scott Deifik + + * Makfile.tst: Changes for DJGPP, bring in sync with main + test/Makefile. + +Wed May 9 21:01:18 2007 Scott Deifik + + DJGPP changes: + + * config.h: Add HAVE_MKTME, HAVE_MKSTEMP, conditionalize + HAVE_SNPRINTF. (ADR: #define out restrict). + * Makefile: Add replace$0 to AWKOBJS2 and PAWKOBJS2. + +2007-03-19 Juan M. Guerrero + + * config.h: Undef HAVE_ALLOCA for DJGPP. + * Makefile: Add floatcomp$O to AWKOBJS1 and PAWKOBJS1. + +2007-02-25 Juan M. Guerrero + + * config.h: Let DEFPATH reflect DJGPP installation directory tree. + * Makefile: pkgdatadir variable defined to $(prefix)/lib/awk. + * Makefile: In DJGPP section use the DJGPP environment variable to + redefine the pkgdatadir variable. + +2006-07-22 Eli Zaretskii + + * Makefile.tst: Update copyright years. + (COMSPEC): If it's empty, use ComSpec instead. + (CMP): Ignore white space differences. + (BASIC_TESTS): Add concat4, nofile, ovrflow1, subi18n. + (GAWK_EXT_TESTS): Add binmode1, devfd1, devfd2, fwtest, nondec2. + (msg): Use $(CMP) instead of literal "cmp". + (inftest): Uncomment the test. + (nonl): Use NUL, so it works with any DOS/Windows shell. + (fsspcoln): Run `head' though the system shell. + (nondec2, nofile, binmode1, subi18n, concat4, devfd1, devfd2) + (ovrflow1, fwtest, mixed1): New tests. + (fmttest, hsprint, ovrflow1, posix): Run output through Sed to + adjust the number of leading zeros in the exponent produced by %e. + (longwrds): Set SORT to just "sort". + (exitval2): Use exitval2.w32. + +2006-07-01 Eli Zaretskii + + * popen.h (os_popen): Declare 1st argument "const char *". + + * popen.c (scriptify): Declare argument "const char *". + (os_system): Declare argument "const char *". Add a new local + variable cmd1 to hold the results of scriptify. + (os_popen): Declare 1st argument "const char *". Add a new local + variable cmd to hold the results of scriptify. + + * Makefile (mingw32): Update definitions for CF, LF, and LF2. Use + libmsvcrtp60 during linking (for multibyte and wide character + support). + (io$O): Depend on popen.h. + + * config.h (HAVE_BTOWC) [_WIN32]: Define. + (HAVE_INTMAX_T, HAVE_UINTMAX_T, HAVE_INTTYPES_H, HAVE_STDINT_H) + (HAVE_INTTYPES_H_WITH_UINTMAX, HAVE_ISASCII, HAVE_ISWCTYPE) + (HAVE_ISWLOWER, HAVE_ISWUPPER, HAVE_LONG_LONG, HAVE_MBRLEN) + (HAVE_MBRTOWC, HAVE_TOWLOWER, HAVE_TOWUPPER, HAVE_WCHAR_H) + (HAVE_WCRTOMB, HAVE_WCSCOLL, HAVE_WCTYPE, HAVE_WCTYPE_H) + (HAVE_WCTYPE_T, HAVE_WINT_T) [__MINGW32__]: Define. + (inline) [__GNUC__]: Define to __inline__. + (HAVE_MEMMOVE, HAVE_PUTENV, HAVE_SETLOCALE, HAVE_LOCALE_H) + (HAVE_SNPRINTF, HAVE_STRTOUL, HAVE_STDLIB_H, HAVE_SYS_STAT_H) + (HAVE_SYS_TIME_H, HAVE_UNSIGNED_LONG_LONG) [__MINGW32__]: Define. + (HAVE_UNISTD_H): Define also for __MINGW32__. + (PACKAGE_BUGREPORT, PACKAGE_NAME, PACKAGE_STRING) + (PACKAGE_TARNAME, PACKAGE_VERSION): Define. + (VERSION): Update. + [__MINGW32__]: Include . + (HAVE_POPEN_H): Define as 1. + (ssize_t, intmax_t, uintmax_t): Don't redefine for __MINGW32__. + +Tue Jul 26 21:46:16 2005 Arnold D. Robbins + + * Release 3.1.5: Release tar file made. + +Sun Jun 26 09:31:35 2005 Scott Deifik + + * Makefile: Decrease stack size for MSC. + * Makefile.tst (Maketests): Syncronized with what's happening in + the main dist. + +Thu Apr 28 23:08:51 2005 Scott Deifik + + * config.h, Makefile.tst: Synced to main distribution. + +Wed Feb 16 10:20:18 2005 Scott Deifik + + * Makefile: Decrease stack size for MSC. + * Makefile.tst: Syncronized with what's happening in the main dist. + * config.h: Improved for DJGPP. + +Wed Feb 9 14:38:38 2005 Scott Deifik + + * Makefile, Makefile.tst: Syncronized with what's happening + in the main dist. + +Thu Feb 3 14:57:28 2005 Scott Deifik + + * config.h (SIZEOF_UNSIGNED_INT, SIZEOF_UNSIGNED_LONG): Add definitions. + +Mon Aug 2 12:18:15 2004 Arnold D. Robbins + + * Release 3.1.4: Release tar file made. + +Sun Jun 13 17:40:09 2004 Scott Deifik + + * Makefile: Reduce the stack size for MSC. + * Makefile.tst: Synchronized with main distribution. + +Sun Jun 13 17:39:47 2004 Arnold D. Robbins + + * Makefile (AWKOBJS2, PAWKOBJS2): Restore version.o. + +Tue Jun 1 22:31:36 2004 Arnold D. Robbins + + * Makefile (AWKOBJS2, PAWKOBJS2): Remove version.o. + + Per Jim Meyering: + * popen.c (scriptify): Check `realloc' return value. + +Tue Mar 2 18:10:55 2004 Arnold D. Robbins + + * Makefile (LIBOJBS): Add `dfa$O' into list. + (main$O rule): Removed, since patchlev.h not part of dist + anymore. + +Tue Mar 2 18:09:54 2004 Scott Deifik + + * config.h (HAVE_ALLOCA_H): Undefine. + * Makefile (LMSC): Adjust stack size for MSC. + +Mon Jul 7 11:01:43 2003 Arnold D. Robbins + + * Release 3.1.3: Release tar file made. + +Thu Jun 26 15:00:20 2003 Scott Deifik + + * Makefile.tst: Synchronized to main dist. + +Sun Jun 15 19:27:58 2003 Patrick T.J. McPhee + + * config.h: Separate the ifdefs for os_system from ssize_t etc. + +Sun Jun 15 19:05:15 2003 Scott Deifik + + * Makefile.tst: Synchronized to main dist. + +Mon Jun 9 17:12:24 2003 Patrick T.J. McPhee + + * dlfcn.c, dlfcn.h, gawke32.def: New files. + * Makefile: Changes to allow dynamic linking of libraries + under Windows32. + +Sun May 11 15:19:52 2003 Scott Deifik + + * config.h: Update defs for ssize_t, intmax_t, uintmax_t. + * Makefile: Update compile options. + * gawkmisc.pc (memcpy_long, memset_long): New functions. + * Makefile.tst: Synchronized with test/Makefile. + +Wed Mar 19 14:10:31 2003 Arnold D. Robbins + + This time for sure. + -- Bullwinkle + + * Release 3.1.2: Release tar file made. + +Sun Feb 23 16:25:44 2003 Scott Deifik + + * Makefile, Makefile.tst: Synchronized to main dist. + +Sun Feb 16 15:44:20 2003 Scott Deifik + + * config.h: Updated. + +Sun Feb 9 11:57:11 2003 Scott Deifik + + * Makefile, Makefile.tst: Synchronized to main dist. + +Tue Feb 4 14:28:06 2003 Arnold D. Robbins + + All relevant files: Copyright year updated to 2003. + +Sun Nov 24 18:37:31 2002 Scott Deifik + + * Makefile, Makefile.tst: Synchronized to main dist. + +Wed May 1 16:41:32 2002 Arnold D. Robbins + + * Release 3.1.1: Release tar file made. + +Thu Apr 18 17:29:16 2002 Scott Deifik + + * Makefile.tst (strftime): Remove comment on call to $(CMP). + +Sun Mar 10 17:05:35 2002 Scott Deifik + + * Makefile.tst: More clean up and sync with ../test/Makefile. + +Thu Jan 3 15:20:17 2002 Scott Deifik + + * Makefile.tst: Minor clean up and sync with ../test/Makefile. + +Wed Dec 19 16:01:58 2001 Peter J. Farley III + + * gawkmisc.pc: Just use single quote for `quote' for all cases. + +Wed Dec 19 15:59:52 2001 Eli Zaretskii + + * install.awk: Install gawkinet.info as well. + * awklib/igawk.awk: Bring in sync with awklib/eg/prog/igawk.sh. + * makefile (PRSPFILE, PRSP, PLDRSP, DO_PLNK, DO_PBIND, PLDJG): New + variables. + (djgpp, djgpp-debug): Set PLNK and PBIND. + (PBIND): Define to EMPTY as default. + (PAWKOBJS1, PAWKOBJS2, PGAWKOBJS): New variables. + (all): Add pgawk.exe. + (pgawk.exe, $(PRSPFILE)): New rules. + ($(ALLOBJS)): Add eval_p.o and profile_p.o to the list of files + that are dependent on awk.h, dfa.h, regex.h, and config.h. + (eval_p$O, profile_p$O): New dependencies. + (clean): Add pgawk and $(PRSPFILE) to files that are to be cleaned + up. + +Tue Dec 4 16:44:07 2001 Andreas Buening + + Updated OS/2 support. + + * gawkmisc.pc (quote): Use single quote for __EMX__. + (os_arg_fixup): new OS/2 code. + (os_devopen): for OS/2 return -1. + (ispath): check for leading drive letter for __EMX__. + (os_close_on_exec): Add check for defined __EMX__. + (os_is_setuid): Add real code for __EMX__. + (_os2_is_abs_path): new function. + (_os2_unixroot): new function. + (_os2_unixroot_path): new function. + +Tue Sep 25 15:19:53 2001 Arnold D. Robbins + + * gawkmisc.pc (os_close_on_exec): If fd <= 2, return. + +Sun Jun 3 13:04:44 2001 Arnold D. Robbins + + * Release 3.1.0: Release tar file made. And there was + rejoicing. + +Tue Jan 30 10:56:05 2001 Arnold D. Robbins + + * config.h: Per Kay Uwe Rommel, turn on HAVE_FCNTL_H for + all PC platforms so that BINMODE works on all. + +Sun Jan 28 15:50:02 2001 Eli Zaretskii + + * gawkmisc.pc (gawk_name): Support file names with mixed forward- + and back-slashes. + (orig_tty_mode): New variable. + (os_setbinmode): Save the original mode of the console device. + [__DJGPP__]: Allow the program to be interrupted with Ctrl-C even + though the console was switched to binary mode. + (os_restore_mode): New function. + +Wed Jan 17 10:59:32 2001 Eli Zaretskii + + * gawkmisc.pc (os_close_on_exec) [__DJGPP__]: Don't print the + warning about failure to set close-on-exec bit, unless it's DJGPP + 2.04 or later. + +Wed Jan 3 19:11:00 2001 Darrel Hankerson + + * popen.c: write script files in binary only if the shell is + unix-like. + * Makefile: set threshold (-Gt) on MSC 16bit versions to obtain + sufficient stack. 3.0.91 builtin.c compiles with optimization, + in MSC[67], so remove the special compile + +Wed Jan 3 19:54:12 2001 Arnold D. Robbins + + * config.h, gawkmisc.pc: Allow fcntl if DGJPP. From Scott. + +Sun Dec 3 16:53:37 2000 Arnold D. Robbins + + * gawkmisc.pc (os_setbinmode): new function. + +Sun Dec 3 14:56:38 2000 Arnold D. Robbins + + * Makefile, Makefile.tst, gawkmisc.pc: updated from Scottd. + * popen.c: updated from Darrell Hankerson. + +Wed Nov 22 11:47:00 2000 Arnold D. Robbins + + * gawk.rsp, pc_popen.c, pc_popen.h, Makefile, Makefile.tst, + gawkmisc.pc: Synched with diffs from Scott Deifik. + * config.h: Updated from main dist, best guess by me, will + probably need tweaking. + +Tue Nov 7 14:09:14 2000 Arnold D. Robbins + + * gawkmisc.pc (os_is_setuid): new function. + +Thu Nov 5 16:50:09 1998 Arnold D. Robbins + + * gawkmisc.pc (os_devopen): handle "/dev/null". + +Wed Jul 30 19:53:52 1997 Arnold D. Robbins + + * Close-on-exec changes: + gawkmisc.pc: (os_close_on_exec, os_isdir): new functions. + +Mon Aug 7 15:23:00 2000 Arnold D. Robbins + + * Release 3.0.6: Release tar file made. + +Sun Jun 25 15:08:19 2000 Arnold D. Robbins + + * Release 3.0.5: Release tar file made. + +Wed Jun 21 16:44:54 2000 Scott Deifik + + * Makefile, Makefile.tst: synchronized with main dist, again. + +Thu May 18 14:07:52 2000 Scott Deifik + + * Makefile, Makefile.tst: synchronized with main dist. + * config.h: Define HAVE_LIMITS_H as 1. + +Wed Jun 30 16:14:36 1999 Arnold D. Robbins + + * Release 3.0.4: Release tar file made. This time for sure. + +Sun Jun 27 12:27:00 1999 Darrel Hankerson + + * Makefile, Makefile.tst, ../README_d/README.pc: finalized. + * include/process.h: new file + +Fri May 21 00:00:00 1999 Darrel Hankerson + + * popen.c: MSC (on DOS/Windows32) and MINGW32 now honor SHELL. + * io.c: MINGW32 reports errno==0 after failure in redirect(); + assume close_one() in this case. + * io.c: Add HAVE_POPEN_H and let pc/config.h deal with the mess. + (Can't move everything to config.h because of popen define.) + +Sun May 9 09:12:33 1999 Darrel Hankerson + + * Add 1999-04-30 changes from Eli Zaretskii + 1. Makefile (TAGS, tags): New targets. + 2. Makefile.tst (regtes): Pass the value of $CMP to the + regtest script. + +Thu Nov 18 03:48:32 1998 Scott Deifik + + * Readme.pc: More LFN-based comments. + +Thu Nov 12 21:01:24 1998 Darrel Hankerson + + * mingw32 target added with corresponding minor changes to getid.c, + io.c, and config.h. + + * vcWin32 needed popen defines in config.h which were inadvertently + omitted from 3.0.3. + + * README.pc updated to clarify the procedure for building + non-LFN versions on LFN systems, and to note that Windows32 gawk + may require Windows32 utilities. + + * emxbnd target modified to accomodate older versions of emx. + +Thu Nov 08 09:11:44 1998 Scott Deifik + + * pc/Makefile: Stack reduced again for 16bit MSC versions. + + * pc/Makefile.tst: Updated to keep in sync with new + test/Makefile.in. In addition, made to work in Windows 9x + with non-LFN tools. + +Thu May 15 12:49:08 1997 Arnold D. Robbins + + * Release 3.0.3: Release tar file made. + +Tue May 13 20:06:09 1997 Darrel Hankerson + + * vcWin32 target added. Some new tests for WIN32 in gawkmisc.c + io.c, and regex.c. Makefile changes for nmake, which can't + expand $($x). + + * config.h updated for BITOPS and NONDECDATA (also in Makefile). + +Fri Apr 18 07:55:47 1997 Arnold D. Robbins + + * BETA Release 3.0.34: Release tar file made. + +Fri Jan 17 19:20:45 1997 Darrel Hankerson + + * Makefile: add KUR's emxnt target for emx+RSXNT. Create awk.exe + "link" to gawk.exe for djgpp target. (Suggested by Eli Zaretskii. + Should be done as part of a smarter install, since awk.exe only + works with djgpp gawk.exe.) Separate djgpp-v1 into djgppv1 + target. Install awk.exe if present. + + * install.awk: install awk.exe if present (only for djgpp) + + * config.h: additional include for emx+RSXNT. + +Wed Dec 25 11:25:22 1996 Arnold D. Robbins + + * Release 3.0.2: Release tar file made. + +Tue Dec 10 23:09:26 1996 Arnold D. Robbins + + * Release 3.0.1: Release tar file made. + +Thu Aug 1 19:46:00 1996 Scott Deifik + + * Makefile: Changes for MSC 8. + +Wed Jan 10 22:58:55 1996 Arnold D. Robbins + + * ChangeLog created. diff --git a/pc/Makefile b/pc/Makefile new file mode 100644 index 0000000..af3044d --- /dev/null +++ b/pc/Makefile @@ -0,0 +1,392 @@ +# Makefile for gawk (GNU awk) Dec 2010 +# +# - for GNU C (djgpp) [32bit protected-mode executable for DOS] +# - for GNU C (emx) [32bit executable for OS/2 or DOS or Windows32] +# - for GNU C (mingw32) [Windows32 executable for Windows 9x/NT/2K/XP/7] + +# Tested with GNU make on Windows, OS/2 and DOS. + +default: + @echo "Enter $(MAK) target " + @echo " where 'target' is chosen from " + @echo " djgpp ... DOS 32-bit exe [GNU C, Delorie, v2] " + @echo " emx ..... OS/2 32-bit exe [emx/gcc; uses emxlibc.dll] " + @echo " emxnt ... NT exe [emx/gcc with RSXNT] " + @echo " emxbnd .. OS/2 and DOS 32-bit exe [emx/gcc] " + @echo " mingw32 . Windows32 exe [Mingw32 GNU C] " + @echo " mingw32-readline . Like mingw32, but with readline " + @echo " [You will need to have GNU readline library installed.] " + @echo " ----------------------------------------------------- " + @echo " test .... Perform tests (see README_d/README.pc) " + @echo " install . Install gawk under $(prefix)/ " + @echo " doc ..... Create documentation " + +# Support dropped in 4.0 +# - for DJGPP v1.x [DOS 32bit protected-mode executable] +# - for MS-Visual C/C++ 4.x [Windows32 executable for Windows 9x/NT] +# - for Microsoft C 7 [16bit ececutable for DOS] +# - for Microsoft C 6.00A [16bit executable for OS/2 or DOS] +# @echo " djgppv1 . DOS 32-bit exe [GNU C, Delorie, v1] " +# @echo " msc ..... DOS exe [Microsoft C 7 & 8 (AKA 1.52)] " +# @echo " msc6 .... DOS exe [Microsoft C 6.00a] " +# @echo " msc6os2 . OS/2 exe [Microsoft C 6.00a] " +# @echo " msc6bnd . OS/2 and DOS exe [Microsoft C 6.00a] " +# @echo " vcWin32 . Windows32 exe [Microsoft Visual C] " +# Support dropped in 3.0 +# - for Microsoft C 5.1 [16bit executable for OS/2 or DOS] +# @echo " msc51 DOS exe [Microsoft C 5.1] " +# @echo " msc51bnd OS/2 and DOS exe [Microsoft C 5.1] " + +#======================= Configuration ================================== +RSPFILE = gawk.rsp +PRSPFILE = pgawk.rsp +DRSPFILE = dgawk.rsp +# +# Choose method for passing arguments to the linker. +# +# If compiling under OS/2 or if make can pass long lines +#LDRSP = $(GAWKOBJS) +#LNKRSP = $(LDRSP) +# +# else use brain-dead approach (emxbnd will need 'tr'). +RSP = $(RSPFILE) +PRSP = $(PRSPFILE) +DRSP = $(DRSPFILE) +LDRSP = @$(RSP) +PLDRSP = @$(PRSP) +DLDRSP = @$(DRSP) +LNKRSP = $(LDRSP) +#------------------------------------------------------------------------ +# Some makes do not define MAKE (and ndmake does not allow a define). +# Define MAK to be your make command. +#MAKE = dmake +MAK = $(MAKE) $(MAKEFILE) +#MAK = $(MAKE) +#MAKEFILE = -f Makefile +#MAK = make45 $(MAKEFILE) +#------------------------------------------------------------------------ +# Define the base directory for the install. "make install" will install +# in bin, lib/awk, man, and info under $(prefix)/. Most likely, you should +# edit config.h so that $(prefix)/lib/awk appears as part of DEFPATH. +#prefix = +prefix = c:/gnu +pkgdatadir = $(prefix)/lib/awk +# +# Define the install method. Method 1 is Unix-like (and requires cat, +# cp, mkdir, sed, and sh); method 2 uses gawk and batch files. +install = 1 +#------------------------------------------------------------------------ +# To work around command-line length problems, this makefile assumes +# that $($X) can be expanded. +DO_LNK = $($(LNK)) +DO_BIND= $($(BIND)) +DO_PLNK = $($(PLNK)) +DO_PBIND= $($(PBIND)) +DO_DLNK = $($(DLNK)) +DO_DBIND= $($(DBIND)) +#======================================================================== +# End of general configuration. Some platform-specific configuration +# notes appear below. + +#======================================================================== +#========================== DJGPP ======================================= +#======================================================================== + +ifneq ($(DJGPP),) +prefix = $(DJDIR) +pkgdatadir = $(prefix)/share/awk +endif +LDJG = $(CC) $(LF) -o gawk.exe $(LDRSP) $(LF2) +PLDJG = $(CC) $(LF) -o pgawk.exe $(PLDRSP) $(LF2) +DLDJG = $(CC) $(LF) -o dgawk.exe $(DLDRSP) $(LF2) +BDJG = stubify -g awk.exe | stubedit awk.exe runfile=gawk + +djgpp: + $(MAK) all \ + CC=gcc O=.o CF=-O2 \ + LNK=LDJG PLNK=PLDJG DLNK=DLDJG LF=-s LF2=-lm \ + BIND=BDJG PBIND='' DBIND='' + +djgpp-debug: + $(MAK) all \ + CC=gcc O=.o CF='-O2 -g' \ + LNK=LDJG PLNK=PLDJG DLNK=DLDJG LF2=-lm \ + BIND=BDJG PBIND='' DBIND='' + +#======================================================================== +#========================== EMX ========================================= +#======================================================================== + +# Link command for OS/2 versions. +LEMX = $(CC) $(LF) -o $@ $(GAWKOBJS) gawk.def -lbsd $(LF2) + +# Link and bind for DOS and OS/2 versions. +# emx-09 needs '-p' emx option here or in EMXOPT environ var. +# The following works with 0.9a or newer +LEMXBND = $(CC) $(LF) -o gawk $(LDRSP) gawk.def -lbsd $(LF2) +BEMX = emxbind -bs gawk -p +# The following works with 0.9c or newer +#LEMXBND = $(CC) $(LF) -o a.out $(LDRSP) gawk.def -lbsd $(LF2) +#BEMX = emxbind -bs -o $@ a.out -p +#BEMX = emxbind -bs /emx/bin/emx.exe a.out $@ -p +BEMXD = emxbind -b -o $@ a.out -p + +emx: + $(MAK) all \ + "CC=gcc -Zomf" O=.obj "CF=-O -DOS2" \ + LNK=LEMX "LF=-s -Zcrtdll -Zstack 512" RSP= + +emxnt: + $(MAK) all \ + "CC=gcc -Zwin32 -Zcrtdll=rsxntcs" O=.o "CF=-O -DOS2" \ + LNK=LEMX "LF=-s -Zstack 512" RSP= + +emxbnd: + $(MAK) all \ + CC=gcc O=.o "CF=-O -DOS2 -DMSDOS" OBJ=popen.o \ + LNK=LEMXBND \ + BIND=BEMX "P=|tr \" \" \"\n\"" + +emxbnd-debug: + $(MAK) all \ + CC=gcc O=.o "CF=-g -DOS2 -DMSDOS" OBJ=popen.o \ + LNK=LEMXBND \ + BIND=BEMXD "P=|tr \" \" \"\n\"" + +#======================================================================== +#========================== MINGW32 ===================================== +#======================================================================== + +LMINGW32 = $(CC) $(LF) -o $@ $(GAWKOBJS) $(LF2) +PLMINGW32 = $(CC) $(LF) -o $@ $(PGAWKOBJS) $(LF2) +DLMINGW32 = $(CC) $(LF) -o $@ $(DGAWKOBJS) $(LF2) +# The following might work around command-line length limitations: +#LMINGW32 = $(CC) $(LF) -o $@ *.o $(LF2) + +mingw32: + $(MAK) all \ + CC=gcc O=.o CF="-O2 -gdwarf-2 -g3" OBJ=popen.o \ + LNK=LMINGW32 PLNK=PLMINGW32 DLNK=DLMINGW32 \ + LF="-gdwarf-2 -g3" LF2=-lmsvcp60 RSP= + +mingw32-readline: + $(MAK) all \ + CC=gcc O=.o CF="-DHAVE_LIBREADLINE -O2 -gdwarf-2 -g3" OBJ=popen.o \ + LNK=LMINGW32 PLNK=PLMINGW32 DLNK=DLMINGW32 \ + LF="-gdwarf-2 -g3" \ + LF2="-lreadline -lmsvcp60 -Wl,--enable-auto-import" RSP= + +# Define BIND for BINDless compiles, otherwise $($(BIND)) may break. +BIND = EMPTY +PBIND = EMPTY +EMPTY= + +# bitwise operations (-DBITOPS) and non-decimal input data (-DNONDECDATA) are +# undocumented in 3.0.3. They may be enabled in config.h, or added to CFLAGS. +CFLAGS = $(CF) -DGAWK -I. -DHAVE_CONFIG_H $(DYN_FLAGS) + +# object files +AWKOBJS1 = array$O builtin$O eval$O field$O floatcomp$O gawkmisc$O io$O main$O +AWKOBJS2 = ext$O msg$O node$O profile$O re$O replace$O version$O $(DYN_OBJ) +PAWKOBJS1 = array$O builtin$O eval_p$O field$O floatcomp$O gawkmisc$O io$O main$O +PAWKOBJS2 = ext$O msg$O node$O profile_p$O re$O replace$O version$O $(DYN_OBJ) +DAWKOBJS1 = array$O builtin$O debug$O eval_d$O field$O floatcomp$O gawkmisc$O io$O main$O +DAWKOBJS2 = ext$O msg$O node$O profile$O re$O replace$O version$O command$O $(DYN_OBJ) +AWKOBJS = $(AWKOBJS1) $(AWKOBJS2) + +ALLOBJS = $(AWKOBJS) awkgram$O getid$O $(OBJ) + +# LIBOBJS +# GNU and other stuff that gawk uses as library routines. +LIBOBJS= getopt$O getopt1$O dfa$O regex$O random$O + +GAWKOBJS = $(ALLOBJS) $(LIBOBJS) +PGAWKOBJS = $(PAWKOBJS1) $(PAWKOBJS2) $(LIBOBJS) awkgram$O getid$O $(OBJ) +DGAWKOBJS = $(DAWKOBJS1) $(DAWKOBJS2) $(LIBOBJS) awkgram$O getid$O $(OBJ) + +# clear out suffixes list +# .SUFFIXES: +.SUFFIXES: .c $O + +.c$O: + $(CC) -c $(CFLAGS) $< + +# rules to build gawk +all : gawk.exe pgawk.exe dgawk.exe + +gawk.exe:: $(GAWKOBJS) $(RSP) + $(DO_LNK) + $(DO_BIND) + +pgawk.exe:: $(PGAWKOBJS) $(PRSP) + $(DO_PLNK) + $(DO_PBIND) + +dgawk.exe:: $(DGAWKOBJS) $(DRSP) + $(DO_DLNK) + $(DO_DBIND) + +$(RSPFILE) : $(GAWKOBJS) + echo $(AWKOBJS1)$P > $@ + echo $(AWKOBJS2)$P >> $@ + echo awkgram$O getid$O $(OBJ) $(LIBOBJS)$P >> $@ + +$(PRSPFILE) : $(PGAWKOBJS) + echo $(PAWKOBJS1)$P > $@ + echo $(PAWKOBJS2)$P >> $@ + echo awkgram$O getid$O $(OBJ) $(LIBOBJS)$P >> $@ + +$(DRSPFILE) : $(DGAWKOBJS) + echo $(DAWKOBJS1)$P > $@ + echo $(DAWKOBJS2)$P >> $@ + echo awkgram$O getid$O $(OBJ) $(LIBOBJS)$P >> $@ + +# Notes to dependencies: +# 1. The dependency on getopt.h is because unistd.h includes it, +# and we have -I. on the compiler command line. unistd.h is +# included by awk.h. +# 2. custom.h is not mentioned because pc ports don't use it. +$(ALLOBJS) $(LIBOBJS) eval_p$O profile_p$O eval_d$O debug$O command$O: \ + awk.h regex.h config.h gettext.h mbsupport.h protos.h dfa.h getopt.h + +builtin$O: floatmagic.h random.h popen.h + +random$O: floatmagic.h random.h + +debug$O: floatmagic.h + +command$O debug$O: cmd.h + +dfa$O: xalloc.h + +gawkmisc$O: pc/gawkmisc.pc + +getopt$O getopt1$O : getopt_int.h + +io$O: popen.h + +regex$O: regcomp.c regexec.c regex_internal.h + +eval_p$O: eval.c + +profile_p$O: profile.c + +# A bug in ndmake requires the following rule +awkgram$O: awk.h awkgram.c + $(CC) -c $(CFLAGS) awkgram.c + +awkgram.c: awkgram.y + bison -o $@ awkgram.y + +alloca$O: alloca.c + + +install: install$(install) + +install1: + echo extproc sh $(prefix)/bin/igawk.cmd > igawk.cmd + echo shift >> igawk.cmd + cat pc/awklib/igawk >> igawk.cmd + sed "s;igawk;$(prefix)/bin/igawk;" pc/awklib/igawk.bat > igawk.bat + sh mkinstal.sh $(prefix)/bin + sh mkinstal.sh $(pkgdatadir) $(prefix)/man/man1 $(prefix)/info + cp *awk.exe igawk.bat igawk.cmd pc/awklib/igawk $(prefix)/bin + cp awklib/eg/lib/* pc/awklib/igawk.awk $(pkgdatadir) + cp doc/*.1 $(prefix)/man/man1 + cp doc/gawk.info $(prefix)/info + +# install2 is equivalent to install1, but doesn't require cp, sed, etc. +install2: + gawk -v prefix=$(prefix) -f install.awk + +clean: + rm -rf gawk pgawk dgawk *.exe gawk.map *.o *.obj core a.out $(RSPFILE) $(PRSPFILE) $(DRSPFILE) $(DYN_EXP) +# cd doc && $(MAKE) clean +# cd test && $(MAKE) clean +# cd awklib && $(MAKE) clean + +awklib/eg: doc/gawk.texi + rm -fr awklib/eg + sh -c "cd awklib && ../gawk -f extract.awk ../doc/gawk.texi" + +check: + @echo "Running the tests requires several unix-like utilities. The" + @echo "recommendation is to copy pc/Makefile.tst to test/Makefile. Under" + @echo "DOS, it may be necessary to run make from the test directory." +# The `-k' option to make should be unnecessary if using pc/Makefile.tst. + sh -c "cd test && $(MAK) -k AWK=../gawk.exe" +# sh -c "cd test && $(MAK) AWK=../gawk.exe bigtest extra" + +test: check + +# for those who have the necessary tools: +TAGS: + etags awk.h *.y custom.h *.c *.h + +tags: + ctags awk.h *.y custom.h *.c *.h + +#======================================================================== +#================================= DOC ================================== +#======================================================================== + +DVIS = ./doc/gawk.dvi ./doc/gawkinet.dvi +PDFS = ./doc/gawk.pdf ./doc/gawkinet.pdf +PSS = ./doc/gawk.ps ./doc/gawkinet.ps +HTMLS = ./doc/gawk.html ./doc/gawkinet.html +INFOS = ./doc/gawk.info ./doc/gawkinet.info +TEXINFOS = ./doc/gawk.texi ./doc/gawkinet.texi + +TEXI2DVI = texi2dvi --build-dir=./doc +TEXI2PDF = $(TEXI2DVI) --pdf --batch +DVIPS = dvips +MAKEINFO = makeinfo --no-split --force +MAKEINFOHTML = $(MAKEINFO) --html + +TROFF = groff -t -Tps -U +#SEDME = sed -e "s/^level0 restore/level0 restore flashme 100 72 moveto (Copyright `date '+%m-%d-%y %T'`, FSF, Inc. (all)) show/" \ +# -e "s/^\/level0 save def/\/level0 save def 30 -48 translate/" + +SEDME = sed "s/^\/level0 save def/\/level0 save def 30 -48 translate/" + +SEDME2 = sed "/%%Page: 10 10/,/0 Cg EP/d" + +.SUFFIXES: .dvi .html .info .pdf .ps .texi + +.texi.info: + $(MAKEINFO) -o $@ $< + +.texi.html: + $(MAKEINFOHTML) -o $@ $< + +.texi.dvi: + $(TEXI2DVI) -o $@ $< + +.texi.pdf: + $(TEXI2PDF) -o $@ $< + +.dvi.ps: + $(DVIPS) -o $@ $< + +./doc/awkcard.tr: ./doc/awkcard.in + cd doc + sed "s,SRCDIR,.," < awkcard.in > awkcard.tr + cd .. + +./doc/awkcard.nc: export GROFF_TMPDIR ?= . +./doc/awkcard.nc: ./doc/macros ./doc/cardfonts ./doc/no.colors ./doc/awkcard.tr ./doc/ad.block ./doc/awkcard.in ./doc/setter.outline + cd doc + $(TROFF) ./macros ./cardfonts ./no.colors awkcard.tr | $(SEDME) | cat ./setter.outline - | $(SEDME2) > awkcard.ps + cd .. + +./doc/awkcard.ps: ./doc/awkcard.nc + cd doc + touch awkcard.nc + cd .. + +./doc/awkcard.pdf: ./doc/awkcard.ps + cd doc + ps2pdf ./awkcard.ps ./awkcard.pdf + cd .. + +doc: $(INFOS) $(DVIS) $(HTMLS) $(PSS) $(PDFS) ./doc/awkcard.ps ./doc/awkcard.pdf diff --git a/pc/Makefile.tst b/pc/Makefile.tst new file mode 100644 index 0000000..c10430a --- /dev/null +++ b/pc/Makefile.tst @@ -0,0 +1,2080 @@ +# Makefile for GNU Awk test suite. +# +# Copyright (C) 1988-2012 the Free Software Foundation, Inc. +# +# This file is part of GAWK, the GNU implementation of the +# AWK Programming Language. +# +# GAWK is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +# ============================================================================ +# MS-DOS & OS/2 Notes: READ THEM! +# ============================================================================ + +# As of version 2.91, efforts to make this makefile run in MS-DOS and OS/2 +# have started in earnest. The following steps need to be followed in order +# to run this makefile: +# +# 1. The first thing that you will need to do is to convert all of the +# files ending in ".ok" in the test directory, all of the files ending +# in ".good" (or ".goo") in the test/reg directory, and mmap8k.in from +# having a linefeed to having carriage return/linefeed at the end of each +# line. There are various public domain UNIX to DOS converters and any +# should work. Alternatively, you can use diff instead of cmp--most +# versions of diff don't care about how the lines end. +# +# 2. You will need an sh-compatible shell. Please refer to the "README.pc" +# file in the README_d directory for information about obtaining a copy. +# You will also need various UNIX utilities. At a minimum, you will +# need: rm, tr, cmp (or diff, see above), cat, wc, and sh. +# You should also have a UNIX-compatible date program. +# +# The makefile has only been tested with dmake 3.8 and DJGPP Make 3.74 or +# later. After making all of these changes, typing "dmake check extra" +# or "make check extra" (with DJGPP Make) should run successfully. + +# The Bash shell (compiled with djgpp) works very well with the +# djgpp-compiled gawk. It is currently the recommended shell to use +# for testing, along with DJGPP make. See README.pc for +# more information on OS/2 and DOS shells. + +# You will almost certainly need to change some of the values (MACROS) +# defined on the next few lines. + +# This won't work unless you have "sh" and set SHELL equal to it (Make 3.74 +# or later which comes with DJGPP will work with SHELL=/bin/sh if you have +# sh.exe anywhere on your PATH). +#SHELL = e:\bin\sh.exe +SHELL = /bin/sh + +# Point to gawk +AWK = ../gawk.exe +# Also point to gawk but for DOS commands needing backslashes. We need +# the forward slash version too or 'arrayparam' fails. +AWK2 = '..\gawk.exe' +AWKPROG = ../gawk.exe + +# Define PGAWK +PGAWK = ../pgawk.exe + +# Set your cmp command here (you can use most versions of diff instead of cmp +# if you don't want to convert the .ok files to the DOS CR/LF format). +# This is also an issue for the "mmap8k" test. If it fails, make sure that +# mmap8k.in has CR/LFs or that you've used diff. +# +# The following comment is for users of OSs which support long file names +# (such as Windows 95) for all versions of gawk (both 16 & 32-bit). +# If you use a shell which doesn't support long filenames, temporary files +# created by this makefile will be truncated by your shell. "_argarra" is an +# example of this. If $(CMP) is a DJGPP-compiled program, then it will fail +# because it looks for the long filename (eg. _argarray). To fix this, you +# need to set LFN=n in your shell's environment. +# NOTE: Setting LFN in the makefile most probably won't help you because LFN +# needs to be an environment variable. +#CMP = cmp +# See the comment above for why you might want to set CMP to "env LFN=n diff" +#CMP = env LFN=n diff +#CMP = diff +CMP = diff -u +#CMP = gcmp + +# cmp replacement program for PC where the error messages aren't +# exactly the same. Should run even on old awk. +TESTOUTCMP = $(AWK) -f ../testoutcmp.awk + +# Set your "cp," "mv," and "mkdir" commands here. Note: DOS's copy must take +# forward slashes. +CP = cp +#CP = : && command -c copy +#CP = command.com /c copy + +MV = cmd.exe /c ren + +#MKDIR = mkdir +#MKDIR = gmkdir +#MKDIR = : && command -c mkdir +MKDIR = command.com /c mkdir + +# Set your unix-style date function here +#DATE = date +DATE = gdate + +# MS-DOS and OS/2 use ; as a PATH delimiter +PATH_SEPARATOR = ; + +# ============================================================================ +# You shouldn't need to modify anything below this line. +# ============================================================================ + +srcdir = . +abs_builddir = . + +# Get rid of core files when cleaning and generated .ok file +CLEANFILES = core core.* fmtspcl.ok + +# try to keep these sorted. each letter starts a new line +BASIC_TESTS = \ + addcomma anchgsub argarray arrayparm arrayprm2 arrayprm3 \ + arrayref arrymem1 arryref2 arryref3 arryref4 arryref5 arynasty \ + arynocls aryprm1 aryprm2 aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 \ + aryprm8 arysubnm asgext awkpath \ + back89 backgsub \ + childin clobber closebad clsflnam compare compare2 concat1 concat2 \ + concat3 concat4 convfmt \ + datanonl defref delargv delarpm2 delarprm delfunc dfastress dynlj \ + eofsplit exitval1 exitval2 \ + fcall_exit fcall_exit2 fldchg fldchgnf fnamedat fnarray fnarray2 \ + fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fsrs fsspcoln \ + fstabplus funsemnl funsmnam funstack \ + getline getline2 getline3 getline4 getlnbuf getnr2tb getnr2tm \ + gsubasgn gsubtest gsubtst2 gsubtst3 gsubtst4 gsubtst5 gsubtst6 \ + gsubtst7 gsubtst8 \ + hex hsprint \ + inputred intest intprec iobug1 \ + leaddig leadnl litoct longsub longwrds \ + manglprm math membug1 messages minusstr mmap8k mtchi18n \ + nasty nasty2 negexp negrange nested nfldstr nfneg nfset nlfldsep \ + nlinstr nlstrina noeffect nofile nofmtch noloop1 noloop2 nonl \ + noparms nors nulrsend numindex numsubstr \ + octsub ofmt ofmta ofmtbig ofmtfidl ofmts onlynl opasnidx opasnslf \ + paramdup paramres paramtyp parse1 parsefld parseme pcntplus \ + posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \ + prt1eval prtoeval \ + rand range1 rebt8b1 redfilnm regeq regrange reindops reparse \ + resplit rri1 rs rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \ + rstest3 rstest4 rstest5 rswhite \ + scalar sclforin sclifin sortempty splitargv splitarr splitdef \ + splitvar splitwht strcat1 strnum1 strtod subamp subi18n \ + subsepnm subslash substr swaplns synerr1 synerr2 tradanch tweakfld \ + uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs \ + wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \ + zero2 zeroe0 zeroflag + +UNIX_TESTS = \ + fflush getlnhd localenl pid pipeio1 pipeio2 poundbang rtlen rtlen01 \ + space strftlng + +GAWK_EXT_TESTS = \ + aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \ + backw badargs beginfile1 beginfile2 binmode1 \ + clos1way delsub devfd devfd1 devfd2 dumpvars exit \ + fieldwdth fpat1 fpat2 fpat3 fpatnull fsfwfs funlen \ + fwtest fwtest2 fwtest3 \ + gensub gensub2 getlndir gnuops2 gnuops3 gnureops \ + icasefs icasers igncdym igncfs ignrcas2 ignrcase indirectcall \ + lint lintold lintwarn \ + manyfiles match1 match2 match3 mbstr1 \ + nastyparm next nondec nondec2 \ + patsplit posix printfbad1 printfbad2 printfbad3 procinfs \ + profile1 profile2 profile3 pty1 \ + rebuf regx8bit reint reint2 rsstart1 \ + rsstart2 rsstart3 rstest6 shadow sortfor sortu splitarg4 strftime \ + strtonum switch2 + +EXTRA_TESTS = inftest regtest +INET_TESTS = inetdayu inetdayt inetechu inetecht +MACHINE_TESTS = double1 double2 fmtspcl intformat +LOCALE_CHARSET_TESTS = \ + asort asorti fmttest fnarydel fnparydl lc_num1 mbfw1 \ + mbprintf1 mbprintf2 mbprintf3 rebt8b2 rtlenmb sort1 sprintfc + +# List of the tests which should be run with --lint option: +NEED_LINT = \ + defref fmtspcl lintwarn noeffect nofmtch shadow \ + uninit2 uninit3 uninit4 uninit5 uninitialized + + +# List of the tests which should be run with --lint-old option: +NEED_LINT_OLD = lintold + +# List of the tests which fail with EXIT CODE 1 +FAIL_CODE1 = \ + fnarray2 fnmisc gsubasgn mixed1 noparms paramdup synerr1 synerr2 unterm + + +# List of the files that appear in manual tests or are for reserve testing: +GENTESTS_UNUSED = Makefile.in gtlnbufv.awk printfloat.awk + +# Message stuff is to make it a little easier to follow. +# Make the pass-fail last and dependent on others to avoid +# spurious errors if `make -j' in effect. +check: msg \ + printlang \ + basic-msg-start basic basic-msg-end \ + unix-msg-start unix-tests unix-msg-end \ + extend-msg-start gawk-extensions extend-msg-end \ + machine-msg-start machine-tests machine-msg-end \ + charset-msg-start charset-tests charset-msg-end \ + pass-fail + +basic: $(BASIC_TESTS) + +unix-tests: $(UNIX_TESTS) + +gawk-extensions: $(GAWK_EXT_TESTS) + +charset-tests: $(LOCALE_CHARSET_TESTS) + +extra: $(EXTRA_TESTS) inet + +inet: inetmesg $(INET_TESTS) + +machine-tests: $(MACHINE_TESTS) + +msg:: + @echo "" + @echo "Any output from $(CMP) is bad news, although some differences" + @echo "in floating point values are probably benign -- in particular," + @echo "some systems may omit a leading zero and the floating point" + @echo "precision may lead to slightly different output in a few cases." + +printlang:: + @$(AWK) -f $(srcdir)/printlang.awk + +basic-msg-start: + @echo "======== Starting basic tests ========" + +basic-msg-end: + @echo "======== Done with basic tests ========" + +unix-msg-start: + @echo "======== Starting Unix tests ========" + +unix-msg-end: + @echo "======== Done with Unix tests ========" + +extend-msg-start: + @echo "======== Starting gawk extension tests ========" + +extend-msg-end: + @echo "======== Done with gawk extension tests ========" + +machine-msg-start: + @echo "======== Starting machine-specific tests ========" + +machine-msg-end: + @echo "======== Done with machine-specific tests ========" + +charset-msg-start: + @echo "======== Starting tests that can vary based on character set or locale support ========" + +charset-msg-end: + @echo "======== Done with tests that can vary based on character set or locale support ========" + +lc_num1: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +# This test is a PITA because increasingly, /tmp is getting +# mounted noexec. So, we'll test it locally. Sigh. +# +# More PITA; some systems have medium short limits on #! paths, +# so this can still fail +poundbang:: + @echo $@ + @sed "s;/tmp/gawk;`pwd`/$(AWKPROG);" < $(srcdir)/poundbang.awk > ./_pbd.awk + @chmod +x ./_pbd.awk + @if ./_pbd.awk $(srcdir)/poundbang.awk > _`basename $@` ; \ + then : ; \ + else \ + sed "s;/tmp/gawk;../$(AWKPROG);" < $(srcdir)/poundbang.awk > ./_pbd.awk ; \ + chmod +x ./_pbd.awk ; \ + LC_ALL=$${GAWKLOCALE:-C} LANG=$${GAWKLOCALE:-C} ./_pbd.awk $(srcdir)/poundbang.awk > _`basename $@`; \ + fi + @-$(CMP) $(srcdir)/poundbang.awk _`basename $@` && rm -f _`basename $@` _pbd.awk + +messages:: + @echo $@ + @$(AWK) -f $(srcdir)/messages.awk >out2 2>out3 + @-$(CMP) $(srcdir)/out1.ok out1 && $(CMP) $(srcdir)/out2.ok out2 && $(CMP) $(srcdir)/out3.ok out3 && rm -f out1 out2 out3 + +argarray:: + @echo $@ + @case $(srcdir) in \ + .) : ;; \ + *) cp $(srcdir)/argarray.in . ;; \ + esac + @TEST=test echo just a test | $(AWK) -f $(srcdir)/argarray.awk ./argarray.in - >_$@ + @case $(srcdir) in \ + .) : ;; \ + *) rm -f ./argarray.in ;; \ + esac + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +regtest:: + @echo 'Some of the output from regtest is very system specific, do not' + @echo 'be distressed if your output differs from that distributed.' + @echo 'Manual inspection is called for.' + AWK=$(AWKPROG) $(srcdir)/regtest.sh + +manyfiles:: + @echo manyfiles + @rm -rf junk + @mkdir junk + @$(AWK) 'BEGIN { for (i = 1; i <= 1030; i++) print i, i}' >_$@ + @$(AWK) -f $(srcdir)/manyfiles.awk _$@ _$@ + @wc -l junk/* | $(AWK) '$$1 != 2' | wc -l | sed "s/ *//g" > _$@ + @rm -rf junk + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +compare:: + @echo $@ + @$(AWK) -f $(srcdir)/compare.awk 0 1 $(srcdir)/compare.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +inftest:: + @echo $@ + @echo This test is very machine specific... + @echo Expect inftest to fail with DJGPP. + @$(AWK) -f $(srcdir)/inftest.awk | sed "s/inf/Inf/g" >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getline2:: + @echo $@ + @$(AWK) -f $(srcdir)/getline2.awk $(srcdir)/getline2.awk $(srcdir)/getline2.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +awkpath:: + @echo $@ + @AWKPATH="$(srcdir)$(PATH_SEPARATOR)$(srcdir)/lib" $(AWK) -f awkpath.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +argtest:: + @echo $@ + @$(AWK) -f $(srcdir)/argtest.awk -x -y abc >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +badargs:: + @echo $@ + @-$(AWK) -f 2>&1 | grep -v patchlevel >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nonl:: + @echo $@ + @-AWKPATH=$(srcdir) $(AWK) --lint -f nonl.awk /dev/null >_$@ 2>&1 + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +strftime:: + @echo This test could fail on slow machines or on a minute boundary, + @echo so if it does, double check the actual results: + @echo $@ +# @GAWKLOCALE=C; export GAWKLOCALE; \ +# TZ=GMT0; export TZ; \ +# (LC_ALL=C date) | $(AWK) -v OUTPUT=_$@ -f $(srcdir)/strftime.awk + @GAWKLOCALE=C; export GAWKLOCALE; \ + TZ=GMT0; export TZ; \ + (LC_ALL=C $(DATE)) | $(AWK) -v OUTPUT=_$@ -f $(srcdir)/strftime.awk + @-$(CMP) strftime.ok _$@ && rm -f _$@ strftime.ok || exit 0 + +litoct:: + @echo $@ + @echo ab | $(AWK) --traditional -f $(srcdir)/litoct.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +devfd:: + @echo $@ + @echo Expect devfd to fail in MinGW + @$(AWK) 1 /dev/fd/4 /dev/fd/5 4<$(srcdir)/devfd.in4 5<$(srcdir)/devfd.in5 >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fflush:: + @echo $@ + @$(srcdir)/fflush.sh >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +tweakfld:: + @echo $@ + @$(AWK) -f $(srcdir)/tweakfld.awk $(srcdir)/tweakfld.in >_$@ + @rm -f errors.cleanup + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mmap8k:: + @echo $@ + @$(AWK) '{ print }' $(srcdir)/mmap8k.in >_$@ + @-$(CMP) $(srcdir)/mmap8k.in _$@ && rm -f _$@ + +tradanch:: + @echo $@ + @$(AWK) --traditional -f $(srcdir)/tradanch.awk $(srcdir)/tradanch.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +# AIX /bin/sh exec's the last command in a list, therefore issue a ":" +# command so that pid.sh is fork'ed as a child before being exec'ed. +pid:: + @echo pid + @echo Expect pid to fail with DJGPP and MinGW. + @AWKPATH=$(srcdir) AWK=$(AWKPROG) $(SHELL) $(srcdir)/pid.sh $$$$ > _`basename $@` ; : + @-$(CMP) $(srcdir)/pid.ok _`basename $@` && rm -f _`basename $@` + +strftlng:: + @echo $@ + @TZ=UTC; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@ + @if $(CMP) $(srcdir)/strftlng.ok _$@ >/dev/null 2>&1 ; then : ; else \ + TZ=UTC0; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@ ; \ + fi + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nors:: + @echo $@ + @echo A B C D E | tr -d '\12\15' | $(AWK) '{ print $$NF }' - $(srcdir)/nors.in > _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fmtspcl.ok: fmtspcl.tok + @$(AWK) -v "sd=$(srcdir)" 'BEGIN {pnan = sprintf("%g",sqrt(-1)); nnan = sprintf("%g",-sqrt(-1)); pinf = sprintf("%g",-log(0)); ninf = sprintf("%g",log(0))} {sub(/positive_nan/,pnan); sub(/negative_nan/,nnan); sub(/positive_infinity/,pinf); sub(/negative_infinity/,ninf); sub(/fmtspcl/,(sd"/fmtspcl")); print}' < $(srcdir)/fmtspcl.tok > $@ 2>/dev/null + +fmtspcl: fmtspcl.ok + @echo fmtspcl + @echo Expect $@ to fail with MinGW + @$(AWK) -f $(srcdir)/fmtspcl.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $@.ok _$@ && rm -f _$@ + +reint:: + @echo $@ + @$(AWK) --re-interval -f $(srcdir)/reint.awk $(srcdir)/reint.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +pipeio1:: + @echo $@ + @$(AWK) -f $(srcdir)/pipeio1.awk >_$@ + @rm -f test1 test2 + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +pipeio2:: + @echo $@ + @echo Expect pipeio2 to fail with MinGW + @$(AWK) -v SRCDIR=$(srcdir) -f $(srcdir)/pipeio2.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +clobber:: + @echo $@ + @$(AWK) -f $(srcdir)/clobber.awk >_$@ + @-$(CMP) $(srcdir)/clobber.ok seq && $(CMP) $(srcdir)/clobber.ok _$@ && rm -f _$@ + @rm -f seq + +arynocls:: + @echo $@ + @-AWKPATH=$(srcdir) $(AWK) -v INPUT=$(srcdir)/arynocls.in -f arynocls.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getlnbuf:: + @echo $@ + @-AWKPATH=$(srcdir) $(AWK) -f getlnbuf.awk $(srcdir)/getlnbuf.in > _$@ + @-AWKPATH=$(srcdir) $(AWK) -f gtlnbufv.awk $(srcdir)/getlnbuf.in > _2$@ + @-$(CMP) $(srcdir)/getlnbuf.ok _$@ && $(CMP) $(srcdir)/getlnbuf.ok _2$@ && rm -f _$@ _2$@ + +inetmesg:: + @echo These tests only work if your system supports the services + @echo "'discard'" at port 9 and "'daytimed'" at port 13. Check your + @echo file /etc/services and do "'netstat -a'". + +inetechu:: + @echo Expect inetechu to fail with DJGPP. + @echo This test is for establishing UDP connections +# @$(AWK) 'BEGIN {print "" |& "/inet/udp/0/127.0.0.1/9"}' + @-$(AWK) 'BEGIN {print "" |& "/inet/udp/0/127.0.0.1/9"}' + +inetecht:: + @echo Expect inetecht to fail with DJGPP. + @echo This test is for establishing TCP connections +# @$(AWK) 'BEGIN {print "" |& "/inet/tcp/0/127.0.0.1/9"}' + @-$(AWK) 'BEGIN {print "" |& "/inet/tcp/0/127.0.0.1/9"}' + +inetdayu:: + @echo Expect inetdayu to fail with DJGPP. + @echo This test is for bidirectional UDP transmission +# @$(AWK) 'BEGIN { print "" |& "/inet/udp/0/127.0.0.1/13"; \ +# "/inet/udp/0/127.0.0.1/13" |& getline; print $0}' + @-$(AWK) 'BEGIN { print "" |& "/inet/udp/0/127.0.0.1/13"; \ + "/inet/udp/0/127.0.0.1/13" |& getline; print $0}' + +inetdayt:: + @echo Expect inetdayt to fail with DJGPP. + @echo This test is for bidirectional TCP transmission +# @$(AWK) 'BEGIN { print "" |& "/inet/tcp/0/127.0.0.1/13"; \ +# "/inet/tcp/0/127.0.0.1/13" |& getline; print $0}' + @-$(AWK) 'BEGIN { print "" |& "/inet/tcp/0/127.0.0.1/13"; \ + "/inet/tcp/0/127.0.0.1/13" |& getline; print $0}' + +redfilnm:: + @echo $@ + @$(AWK) -f $(srcdir)/redfilnm.awk srcdir=$(srcdir) $(srcdir)/redfilnm.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +leaddig:: + @echo $@ + @$(AWK) -v x=2E -f $(srcdir)/leaddig.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst3:: + @echo $@ + @$(AWK) --re-interval -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +space:: + @echo $@ + @$(AWK) -f ' ' $(srcdir)/space.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ +# @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + @-$(TESTOUTCMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +printf0:: + @echo $@ + @$(AWK) --posix -f $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsnulbig:: + @echo $@ + @ : Suppose that block size for pipe is at most 128kB: + @$(AWK) 'BEGIN { for (i = 1; i <= 128*64+1; i++) print "abcdefgh123456\n" }' 2>&1 | \ + $(AWK) 'BEGIN { RS = ""; ORS = "\n\n" }; { print }' 2>&1 | \ + $(AWK) '/^[^a]/; END{ print NR }' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsnulbig2:: + @echo $@ + @$(AWK) 'BEGIN { ORS = ""; n = "\n"; for (i = 1; i <= 10; i++) n = (n n); \ + for (i = 1; i <= 128; i++) print n; print "abc\n" }' 2>&1 | \ + $(AWK) 'BEGIN { RS = ""; ORS = "\n\n" };{ print }' 2>&1 | \ + $(AWK) '/^[^a]/; END { print NR }' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +wideidx:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +wideidx2:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +widesub:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +widesub2:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +widesub3:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +widesub4:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ignrcas2:: + @echo $@ + @GAWKLOCALE=en_US ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +subamp:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +# This test makes sure gawk exits with a zero code. +# Thus, unconditionally generate the exit code. +exitval1:: + @echo $@ + @$(AWK) -f $(srcdir)/exitval1.awk >_$@ 2>&1; echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fsspcoln:: + @echo $@ + @$(AWK) -f $(srcdir)/$@.awk 'FS=[ :]+' $(srcdir)/$@.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsstart1:: + @echo $@ + @$(AWK) -f $(srcdir)/$@.awk $(srcdir)/rsstart1.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsstart2:: + @echo $@ + @$(AWK) -f $(srcdir)/$@.awk $(srcdir)/rsstart1.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsstart3:: + @echo $@ + @head $(srcdir)/rsstart1.in | $(AWK) -f $(srcdir)/rsstart2.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rtlen:: + @echo $@ + @$(srcdir)/$@.sh >_$@ || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rtlen01:: + @echo $@ + @$(srcdir)/$@.sh >_$@ || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rtlenmb:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ + $(srcdir)/rtlen.sh >_$@ || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/rtlen.ok _$@ && rm -f _$@ + +nondec2:: + @echo $@ + @$(AWK) --non-decimal-data -v a=0x1 -f $(srcdir)/$@.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nofile:: + @echo $@ + @$(AWK) '{}' no/such/file >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @sed "s/ (ENOENT)//" _$@ > _$@.2 + @rm -f _$@ +# @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + @-$(CMP) $(srcdir)/$@.ok _$@.2 && rm -f _$@.2 + +binmode1:: + @echo $@ + @$(AWK) -v BINMODE=3 'BEGIN { print BINMODE }' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +subi18n:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; $(AWK) -f $(srcdir)/$@.awk > _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +concat4:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in > _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +devfd1:: + @echo $@ + @echo Expect devfd1 to fail in MinGW + @$(AWK) -f $(srcdir)/$@.awk 4< $(srcdir)/devfd.in1 5< $(srcdir)/devfd.in2 >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +# The program text is the '1' which will print each record. How compact can you get? +devfd2:: + @echo $@ + @echo Expect devfd2 to fail in MinGW + @$(AWK) 1 /dev/fd/4 /dev/fd/5 4< $(srcdir)/devfd.in1 5< $(srcdir)/devfd.in2 >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mixed1:: + @echo $@ + @$(AWK) -f /dev/null --source 'BEGIN {return junk}' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mtchi18n:: + @echo $@ + @GAWKLOCALE=ru_RU.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +reint2:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) --re-interval -f $@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +localenl:: + @echo $@ + @$(srcdir)/$@.sh >_$@ 2>/dev/null + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mbprintf1:: + @echo $@ + @echo Expect mbprintf1 to fail with DJGPP and MinGW. + @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mbprintf2:: + @echo $@ + @GAWKLOCALE=ja_JP.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mbprintf3:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mbfw1:: + @echo $@ + @echo Expect mbfw1 to fail with DJGPP and MinGW. + @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst6:: + @echo $@ + @GAWKLOCALE=C ; $(AWK) -f $(srcdir)/$@.awk > _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mbstr1:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +printfbad2: printfbad2.ok + @echo $@ + @$(AWK) --lint -f $(srcdir)/$@.awk $(srcdir)/$@.in 2>&1 | sed 's;\$(srcdir)/;;g' >_$@ || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +beginfile1:: + @echo $@ + @echo Expect beginfile1 to fail with DJGPP and MinGW + @AWKPATH=$(srcdir) $(AWK) -f $@.awk $(srcdir)/$@.awk . ./no/such/file Makefile >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +beginfile2: + @echo $@ + @-( cd $(srcdir) && LC_ALL=C AWK="$(abs_builddir)/$(AWKPROG)" $(srcdir)/$@.sh $(srcdir)/$@.in ) > _$@ 2>&1 +# @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + @-$(TESTOUTCMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +dumpvars:: + @echo $@ + @AWKPATH=$(srcdir) $(AWK) --dump-variables 1 < $(srcdir)/$@.in >/dev/null 2>&1 || echo EXIT CODE: $$? >>_$@ +# @mv awkvars.out _$@ + @$(MV) awkvars.out _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +profile1: + @echo $@ + @$(AWK) --profile=ap-$@.out -f $(srcdir)/xref.awk $(srcdir)/dtdgport.awk > _$@.out1 + @$(AWK) -f ap-$@.out $(srcdir)/dtdgport.awk > _$@.out2 ; rm ap-$@.out + @cmp _$@.out1 _$@.out2 && rm _$@.out[12] || echo EXIT CODE: $$? >>_$@ + +profile2: + @echo $@ + @$(PGAWK) --profile=ap-$@.out -v sortcmd=sort -f $(srcdir)/xref.awk $(srcdir)/dtdgport.awk > /dev/null + @sed 1,2d < ap-$@.out > _$@; rm ap-$@.out + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +profile3: + @echo $@ + @$(PGAWK) --profile=ap-$@.out -f $(srcdir)/$@.awk > /dev/null + @sed 1,2d < ap-$@.out > _$@; rm ap-$@.out + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +posix2008sub: + @echo $@ + @$(AWK) --posix -f $(srcdir)/$@.awk > _$@ 2>&1 + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +next: + @echo $@ + @-AWK="$(AWKPROG)" $(srcdir)/$@.sh > _$@ 2>&1 + @-LC_ALL=C $(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +exit: + @echo $@ + @echo Expect exit to fail with MinGW + @-AWK="$(AWKPROG)" $(srcdir)/$@.sh > _$@ 2>&1 + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rri1:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ +Gt-dummy: +# file Maketests, generated from Makefile.am by the Gentests program +addcomma: + @echo addcomma + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +anchgsub: + @echo anchgsub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arrayparm: + @echo arrayparm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arrayprm2: + @echo arrayprm2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arrayprm3: + @echo arrayprm3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arrayref: + @echo arrayref + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arrymem1: + @echo arrymem1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arryref2: + @echo arryref2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arryref3: + @echo arryref3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arryref4: + @echo arryref4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arryref5: + @echo arryref5 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arynasty: + @echo arynasty + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm1: + @echo aryprm1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm2: + @echo aryprm2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm3: + @echo aryprm3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm4: + @echo aryprm4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm5: + @echo aryprm5 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm6: + @echo aryprm6 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm7: + @echo aryprm7 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm8: + @echo aryprm8 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arysubnm: + @echo arysubnm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +asgext: + @echo asgext + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +back89: + @echo back89 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +backgsub: + @echo backgsub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +childin: + @echo childin + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +closebad: + @echo closebad + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +clsflnam: + @echo clsflnam + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +compare2: + @echo compare2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +concat1: + @echo concat1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +concat2: + @echo concat2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +concat3: + @echo concat3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +convfmt: + @echo convfmt + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +datanonl: + @echo datanonl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +defref: + @echo defref + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +delargv: + @echo delargv + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +delarpm2: + @echo delarpm2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +delarprm: + @echo delarprm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +delfunc: + @echo delfunc + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +dfastress: + @echo dfastress + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +dynlj: + @echo dynlj + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +eofsplit: + @echo eofsplit + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +exitval2: + @echo exitval2 + @echo Expect exitval2 to fail with MinGW + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fcall_exit: + @echo fcall_exit + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fcall_exit2: + @echo fcall_exit2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fldchg: + @echo fldchg + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fldchgnf: + @echo fldchgnf + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnamedat: + @echo fnamedat + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnarray: + @echo fnarray + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnarray2: + @echo fnarray2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnaryscl: + @echo fnaryscl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnasgnm: + @echo fnasgnm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnmisc: + @echo fnmisc + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fordel: + @echo fordel + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +forref: + @echo forref + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +forsimp: + @echo forsimp + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fsbs: + @echo fsbs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fsrs: + @echo fsrs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fstabplus: + @echo fstabplus + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +funsemnl: + @echo funsemnl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +funsmnam: + @echo funsmnam + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +funstack: + @echo funstack + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getline: + @echo getline + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getline3: + @echo getline3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getline4: + @echo getline4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getnr2tb: + @echo getnr2tb + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getnr2tm: + @echo getnr2tm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubasgn: + @echo gsubasgn + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtest: + @echo gsubtest + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst2: + @echo gsubtst2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst4: + @echo gsubtst4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst5: + @echo gsubtst5 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst7: + @echo gsubtst7 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst8: + @echo gsubtst8 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +hex: + @echo hex + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +hsprint: + @echo hsprint + @echo Expect hsprint to fail with MinGW due to 3 digits in %e output + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +inputred: + @echo inputred + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +intest: + @echo intest + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +intprec: + @echo intprec + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +iobug1: + @echo iobug1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +leadnl: + @echo leadnl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +longsub: + @echo longsub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +longwrds: + @echo longwrds + @AWKPATH=$(srcdir) $(AWK) -f $@.awk SORT=sort < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ +# @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +manglprm: + @echo manglprm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +math: + @echo math + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +membug1: + @echo membug1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +minusstr: + @echo minusstr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nasty: + @echo nasty + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nasty2: + @echo nasty2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +negexp: + @echo negexp + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +negrange: + @echo negrange + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nested: + @echo nested + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nfldstr: + @echo nfldstr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nfneg: + @echo nfneg + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nfset: + @echo nfset + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nlfldsep: + @echo nlfldsep + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nlinstr: + @echo nlinstr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nlstrina: + @echo nlstrina + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +noeffect: + @echo noeffect + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nofmtch: + @echo nofmtch + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +noloop1: + @echo noloop1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +noloop2: + @echo noloop2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +noparms: + @echo noparms + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nulrsend: + @echo nulrsend + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +numindex: + @echo numindex + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +numsubstr: + @echo numsubstr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +octsub: + @echo octsub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ofmt: + @echo ofmt + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ofmta: + @echo ofmta + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ofmtbig: + @echo ofmtbig + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ofmtfidl: + @echo ofmtfidl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ofmts: + @echo ofmts + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +onlynl: + @echo onlynl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +opasnidx: + @echo opasnidx + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +opasnslf: + @echo opasnslf + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +paramdup: + @echo paramdup + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +paramres: + @echo paramres + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +paramtyp: + @echo paramtyp + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +parse1: + @echo parse1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +parsefld: + @echo parsefld + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +parseme: + @echo parseme + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +pcntplus: + @echo pcntplus + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prdupval: + @echo prdupval + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prec: + @echo prec + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +printf1: + @echo printf1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prmarscl: + @echo prmarscl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prmreuse: + @echo prmreuse + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prt1eval: + @echo prt1eval + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prtoeval: + @echo prtoeval + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rand: + @echo rand + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +range1: + @echo range1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rebt8b1: + @echo rebt8b1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +regeq: + @echo regeq + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +regrange: + @echo regrange + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +reindops: + @echo reindops + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +reparse: + @echo reparse + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +resplit: + @echo resplit + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rs: + @echo rs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsnul1nl: + @echo rsnul1nl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest1: + @echo rstest1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest2: + @echo rstest2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest3: + @echo rstest3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest4: + @echo rstest4 + @echo Expect rstest4 to fail with MinGW + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest5: + @echo rstest5 + @echo Expect rstest5 to fail with MinGW + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rswhite: + @echo rswhite + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +scalar: + @echo scalar + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sclforin: + @echo sclforin + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sclifin: + @echo sclifin + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sortempty: + @echo sortempty + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitargv: + @echo splitargv + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitarr: + @echo splitarr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitdef: + @echo splitdef + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitvar: + @echo splitvar + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitwht: + @echo splitwht + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +strcat1: + @echo strcat1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +strnum1: + @echo strnum1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +strtod: + @echo strtod + @echo Expect strtod to fail with DJGPP. + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +subsepnm: + @echo subsepnm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +subslash: + @echo subslash + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +substr: + @echo substr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +swaplns: + @echo swaplns + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +synerr1: + @echo synerr1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +synerr2: + @echo synerr2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uninit2: + @echo uninit2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uninit3: + @echo uninit3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uninit4: + @echo uninit4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uninit5: + @echo uninit5 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uninitialized: + @echo uninitialized + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +unterm: + @echo unterm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uparrfs: + @echo uparrfs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +wjposer1: + @echo wjposer1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +zero2: + @echo zero2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +zeroe0: + @echo zeroe0 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +zeroflag: + @echo zeroflag + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getlnhd: + @echo getlnhd + @echo Expect getlnhd to fail if pipe does not use a Unixy shell + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aadelete1: + @echo aadelete1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aadelete2: + @echo aadelete2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aarray1: + @echo aarray1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aasort: + @echo aasort + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aasorti: + @echo aasorti + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arraysort: + @echo arraysort + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +backw: + @echo backw + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +clos1way: + @echo clos1way + @echo Expect clos1way to fail with DJGPP and MinGW. + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +delsub: + @echo delsub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fieldwdth: + @echo fieldwdth + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fpat1: + @echo fpat1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fpat2: + @echo fpat2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fpat3: + @echo fpat3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fpatnull: + @echo fpatnull + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fsfwfs: + @echo fsfwfs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +funlen: + @echo funlen + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fwtest: + @echo fwtest + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fwtest2: + @echo fwtest2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fwtest3: + @echo fwtest3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gensub: + @echo gensub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gensub2: + @echo gensub2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getlndir: + @echo getlndir + @echo Expect getlndir to fail with DJGPP and MinGW. + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gnuops2: + @echo gnuops2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gnuops3: + @echo gnuops3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gnureops: + @echo gnureops + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +icasefs: + @echo icasefs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +icasers: + @echo icasers + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +igncdym: + @echo igncdym + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +igncfs: + @echo igncfs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ignrcase: + @echo ignrcase + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +indirectcall: + @echo indirectcall + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +lint: + @echo lint + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +lintold: + @echo lintold + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint-old < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +lintwarn: + @echo lintwarn + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +match1: + @echo match1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +match2: + @echo match2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +match3: + @echo match3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nastyparm: + @echo nastyparm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nondec: + @echo nondec + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +patsplit: + @echo patsplit + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +posix: + @echo posix + @echo Expect posix to fail with MinGW due to 3 digits in e+NNN exponent + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +printfbad1: + @echo printfbad1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +printfbad3: + @echo printfbad3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +procinfs: + @echo procinfs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +pty1: + @echo pty1 + @echo Expect pty1 to fail with DJGPP and MinGW. + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rebuf: + @echo rebuf + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +regx8bit: + @echo regx8bit + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest6: + @echo rstest6 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +shadow: + @echo shadow + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sortfor: + @echo sortfor + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sortu: + @echo sortu + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitarg4: + @echo splitarg4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +strtonum: + @echo strtonum + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +switch2: + @echo switch2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +double1: + @echo double1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +double2: + @echo double2 + @echo Expect double2 to fail with MinGW due to 3 digits in e+NNN exponents + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +intformat: + @echo intformat + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +asort: + @echo asort + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +asorti: + @echo asorti + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fmttest: + @echo fmttest + @echo Expect fmttest to fail with MinGW due to 3 digits in e+NNN exponents + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnarydel: + @echo fnarydel + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnparydl: + @echo fnparydl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rebt8b2: + @echo rebt8b2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sort1: + @echo sort1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sprintfc: + @echo sprintfc + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +# end of file Maketests + +# Targets generated for other tests: + +$(srcdir)/Maketests: $(srcdir)/Makefile.am $(srcdir)/Gentests + files=`cd "$(srcdir)" && echo *.awk *.in`; \ + $(AWK) -f $(srcdir)/Gentests "$(srcdir)/Makefile.am" $$files > $(srcdir)/Maketests + +clean: + rm -fr _* core core.* fmtspcl.ok junk out1 out2 out3 strftime.ok test1 test2 seq *~ + +# An attempt to print something that can be grepped for in build logs +pass-fail: + @COUNT=`ls _* 2>/dev/null | wc -l` ; \ + if test $$COUNT = 0 ; \ + then echo ALL TESTS PASSED ; \ + else echo $$COUNT TESTS FAILED ; \ + fi + +# This target for my convenience to look at all the results +diffout: + for i in _* ; \ + do \ + if [ "$$i" != "_*" ]; then \ + echo ============== $$i ============= ; \ + if [ -r $${i#_}.ok ]; then \ + diff -c $${i#_}.ok $$i ; \ + else \ + diff -c $(srcdir)/$${i#_}.ok $$i ; \ + fi ; \ + fi ; \ + done | more + +# convenient way to scan valgrind results for errors +valgrind-scan: + @echo "Scanning valgrind log files for problems:" + @$(AWK) '\ + function show() {if (cmd) {printf "%s: %s\n",FILENAME,cmd; cmd = ""}; \ + printf "\t%s\n",$$0}; \ + {$$1 = ""}; \ + /Prog and args are:/ {incmd = 1; cmd = ""; next}; \ + incmd {if (NF == 1) incmd = 0; else {cmd = (cmd $$0); next}}; \ + /ERROR SUMMARY:/ && !/: 0 errors from 0 contexts/ {show()}; \ + /definitely lost:/ && !/: 0 bytes in 0 blocks/ {show()}; \ + /possibly lost:/ && !/: 0 bytes in 0 blocks/ {show()}; \ + / suppressed:/ && !/: 0 bytes in 0 blocks/ {show()}; \ + ' log.[0-9]* + +# This target is for testing with electric fence. +efence: + for i in $$(ls _* | sed 's;_\(.*\);\1;') ; \ + do \ + bad=$$(wc -l < _$$i) \ + ok=$$(wc -l < $$i.ok) ; \ + if (( $$bad == $$ok + 2 )) ; \ + then \ + rm _$$i ; \ + fi ; \ + done + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/pc/awklib/igawk b/pc/awklib/igawk new file mode 100644 index 0000000..7c599dc --- /dev/null +++ b/pc/awklib/igawk @@ -0,0 +1,85 @@ +#! /bin/sh + +# igawk --- like gawk but do @include processing +# Arnold Robbins, arnold@gnu.ai.mit.edu, Public Domain +# July 1993 + +igs=${TMP:-/tmp}/igs$$ +ige=${TMP:-/tmp}/ige$$ + +if [ "$1" = debug ] +then + set -x + shift +else + # cleanup on exit, hangup, interrupt, quit, termination + #trap 'rm -f $igs $ige' 0 1 2 3 15 + trap 'rm -f $igs $ige' 0 2 15 +fi + +while [ $# -ne 0 ] # loop over arguments +do + case $1 in + --) shift; break;; + + -W) shift + set -- -W"$@" + continue;; + + -[vF]) opts="$opts $1 '$2'" + shift;; + + -[vF]*) opts="$opts '$1'" ;; + + -f) echo @include "$2" >> $igs + shift;; + + -f*) f=`echo "$1" | sed 's/-f//'` + echo @include "$f" >> $igs ;; + + -?file=*) # -Wfile or --file + f=`echo "$1" | sed 's/-.file=//'` + echo @include "$f" >> $igs ;; + + -?file) # get arg, $2 + echo @include "$2" >> $igs + shift;; + + -?source=*) # -Wsource or --source + t=`echo "$1" | sed 's/-.source=//'` + echo "$t" >> $igs ;; + + -?source) # get arg, $2 + echo "$2" >> $igs + shift;; + + -?version) + echo igawk: version 1.0 1>&2 + gawk --version + exit 0 ;; + + -[W-]*) opts="$opts '$1'" ;; + + *) break;; + esac + + shift +done + +if [ ! -s $igs ] +then + if [ -z "$1" ] + then + echo igawk: no program! 1>&2 + exit 1 + else + echo "$1" > $igs + shift + fi +fi + +# at this point, $igs has the program +gawk -f igawk.awk $igs > $ige +eval gawk -f '$ige' $opts -- "$@" + +exit $? diff --git a/pc/awklib/igawk.awk b/pc/awklib/igawk.awk new file mode 100644 index 0000000..c660b8d --- /dev/null +++ b/pc/awklib/igawk.awk @@ -0,0 +1,51 @@ +# igawk.awk +# process @include directives + +function pathto(file, i, t, junk) +{ + if (index(file, "/") != 0) + return file + + for (i = 1; i <= ndirs; i++) { + t = (pathlist[i] "/" file) + if ((getline junk < t) > 0) { + # found it + close(t) + return t + } + } + return "" +} +BEGIN { + path = ENVIRON["AWKPATH"] + ndirs = split(path, pathlist, ";") + for (i = 1; i <= ndirs; i++) { + if (pathlist[i] == "") + pathlist[i] = "." + } + stackptr = 0 + input[stackptr] = ARGV[1] # ARGV[1] is first file + + for (; stackptr >= 0; stackptr--) { + while ((getline < input[stackptr]) > 0) { + if (tolower($1) != "@include") { + print + continue + } + fpath = pathto($2) + if (fpath == "") { + printf("igawk:%s:%d: cannot find %s\n", + input[stackptr], FNR, $2) > "/dev/stderr" + continue + } + if (! (fpath in processed)) { + processed[fpath] = input[stackptr] + input[++stackptr] = fpath # push onto stack + } else + print $2, "included in", input[stackptr], + "already included in", + processed[fpath] > "/dev/stderr" + } + close(input[stackptr]) + } +} diff --git a/pc/awklib/igawk.bat b/pc/awklib/igawk.bat new file mode 100644 index 0000000..bfc9b2a --- /dev/null +++ b/pc/awklib/igawk.bat @@ -0,0 +1 @@ +@sh igawk %1 %2 %3 %4 %5 %6 %7 %8 %9 \ No newline at end of file diff --git a/pc/config.h b/pc/config.h new file mode 100644 index 0000000..8e6bb26 --- /dev/null +++ b/pc/config.h @@ -0,0 +1,597 @@ +/* configh.in. Generated from configure.ac by autoheader. */ +/* pc/config.h. Generated automatically by pc/config.sed. */ + +/* dynamic loading is possible */ +#undef DYNAMIC + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +#undef ENABLE_NLS + +/* Define to the type of elements in the array set by `getgroups'. Usually + this is either `int' or `gid_t'. */ +#define GETGROUPS_T gid_t + +/* Define to 1 if the `getpgrp' function requires zero arguments. */ +#define GETPGRP_VOID 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_ARPA_INET_H + +/* Define to 1 if you have the `atexit' function. */ +#define HAVE_ATEXIT 1 + +/* Define to 1 if you have the `btowc' function. */ +#ifdef _WIN32 +#define HAVE_BTOWC 1 +#endif + +/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the + CoreFoundation framework. */ +#undef HAVE_CFLOCALECOPYCURRENT + +/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in + the CoreFoundation framework. */ +#undef HAVE_CFPREFERENCESCOPYAPPVALUE + +/* Define if the GNU dcgettext() function is already present or preinstalled. + */ +#undef HAVE_DCGETTEXT + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +#ifdef __MINGW32__ +#define HAVE_DECL_TZNAME 1 +#endif + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +#undef HAVE_DOPRNT + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `fmod' function. */ +#define HAVE_FMOD 1 + +/* have getaddrinfo */ +#undef HAVE_GETADDRINFO + +/* Define to 1 if you have the `getgrent' function. */ +#undef HAVE_GETGRENT + +/* Define to 1 if you have the `getgroups' function. */ +#undef HAVE_GETGROUPS + +/* Define if the GNU gettext() function is already present or preinstalled. */ +#undef HAVE_GETTEXT + +/* Define to 1 if you have the `grantpt' function. */ +#undef HAVE_GRANTPT + +/* Define if you have the iconv() function and it works. */ +#undef HAVE_ICONV + +/* Define if you have the 'intmax_t' type in or . */ +#ifdef __MINGW32__ +#define HAVE_INTMAX_T 1 +#endif + +/* Define to 1 if you have the header file. */ +#ifdef __MINGW32__ +#define HAVE_INTTYPES_H 1 +#endif + +/* Define if exists, doesn't clash with , and + declares uintmax_t. */ +#ifdef __MINGW32__ +#define HAVE_INTTYPES_H_WITH_UINTMAX 1 +#endif + +/* Define to 1 if you have the `isascii' function. */ +#ifdef __MINGW32__ +#define HAVE_ISASCII 1 +#endif + +/* Define to 1 if you have the `iswctype' function. */ +#ifdef __MINGW32__ +#define HAVE_ISWCTYPE 1 +#endif + +/* Define to 1 if you have the `iswlower' function. */ +#ifdef __MINGW32__ +#define HAVE_ISWLOWER 1 +#endif + +/* Define to 1 if you have the `iswupper' function. */ +#ifdef __MINGW32__ +#define HAVE_ISWUPPER 1 +#endif + +/* Define if you have and nl_langinfo(CODESET). */ +#undef HAVE_LANGINFO_CODESET + +/* Define if your file defines LC_MESSAGES. */ +#undef HAVE_LC_MESSAGES + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBINTL_H + +/* Define to 1 if you have the `m' library (-lm). */ +#define HAVE_LIBM 1 + +/* Define to 1 if you have a fully functional readline library. */ +/* #undef HAVE_LIBREADLINE */ + +/* Define if you have the libsigsegv library. */ +#undef HAVE_LIBSIGSEGV + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the header file. */ +#ifdef __MINGW32__ +#define HAVE_LOCALE_H 1 +#endif + +/* Define if you have the 'long long' type. */ +#ifdef __MINGW32__ +#define HAVE_LONG_LONG 1 +#endif + +/* Define to 1 if the system has the type `long long int'. */ +#undef HAVE_LONG_LONG_INT + +/* Define to 1 if you have the `mbrlen' function. */ +#ifdef __MINGW32__ +#define HAVE_MBRLEN 1 +#endif + +/* Define to 1 if mbrtowc and mbstate_t are properly declared. */ +#ifdef __MINGW32__ +#define HAVE_MBRTOWC 1 +#endif + +/* Define to 1 if you have the header file. */ +#undef HAVE_MCHECK_H + +/* Define to 1 if you have the `memcmp' function. */ +#define HAVE_MEMCMP 1 + +/* Define to 1 if you have the `memcpy' function. */ +#define HAVE_MEMCPY 1 + +/* Define to 1 if you have the `memcpy_ulong' function. */ +#undef HAVE_MEMCPY_ULONG + +/* Define to 1 if you have the `memmove' function. */ +#ifdef __MINGW32__ +#define HAVE_MEMMOVE 1 +#endif + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if you have the `memset_ulong' function. */ +#undef HAVE_MEMSET_ULONG + +/* Define to 1 if you have the `mkstemp' function. */ +#ifdef DJGPP +#define HAVE_MKSTEMP 1 +#endif + +/* we have the mktime function */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETDB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_IN_H + +/* Define to 1 if you have the `setenv' function. */ +#if defined(__MINGW32__) || defined(__DJGPP__) +#define HAVE_SETENV 1 +#endif + +/* Define to 1 if you have the `setlocale' function. */ +#ifdef __MINGW32__ +#define HAVE_SETLOCALE 1 +#endif + +/* Define to 1 if you have the `setsid' function. */ +#undef HAVE_SETSID + +/* Define to 1 if you have the `snprintf' function. */ +#ifdef __MINGW32__ +#define HAVE_SNPRINTF 1 +#endif + +/* newer systems define this type here */ +#undef HAVE_SOCKADDR_STORAGE + +/* we have sockets on this system */ +#undef HAVE_SOCKETS + +/* Define to 1 if you have the header file. */ +#define HAVE_STDARG_H 1 + +/* Define to 1 if you have the header file. */ +#ifdef __GNUC__ +#define HAVE_STDDEF_H 1 +#endif + +/* Define to 1 if you have the header file. */ +#ifdef __MINGW32__ +#define HAVE_STDINT_H 1 +#endif + +/* Define if exists, doesn't clash with , and declares + uintmax_t. */ +#undef HAVE_STDINT_H_WITH_UINTMAX + +/* Define to 1 if you have the header file. */ +#ifdef __MINGW32__ +#define HAVE_STDLIB_H 1 +#endif + +/* Define to 1 if you have the `strchr' function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the `strcoll' function. */ +#undef HAVE_STRCOLL + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the `strftime' function. */ +#ifdef __MINGW32__ +/* MinGW uses the replacement from missing_d, to support the %e specifier. */ +#define strftime rpl_strftime +#else +#define HAVE_STRFTIME 1 +#endif + +/* Define to 1 if cpp supports the ANSI # stringizing operator. */ +#define HAVE_STRINGIZE 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strncasecmp' function. */ +#define HAVE_STRNCASECMP 1 +#ifdef __EMX__ +#define strncasecmp strnicmp +#endif + +/* Define to 1 if you have the header file. */ +#undef HAVE_STROPTS_H + +/* Define to 1 if you have the `strtod' function. */ +#define HAVE_STRTOD 1 + +/* Define to 1 if you have the `strtoul' function. */ +#ifdef __MINGW32__ +#define HAVE_STRTOUL 1 +#endif + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_BLKSIZE + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#undef HAVE_STRUCT_TM_TM_ZONE + +/* Define to 1 if your `struct stat' has `st_blksize'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLKSIZE' instead. */ +#undef HAVE_ST_BLKSIZE + +/* Define to 1 if you have the `system' function. */ +#define HAVE_SYSTEM 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define to 1 if you have the header file. */ +#ifndef __MINGW32__ +#define HAVE_SYS_PARAM_H 1 +#endif + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the header file. */ +#ifdef __MINGW32__ +#define HAVE_SYS_STAT_H 1 +#endif + +/* Define to 1 if you have the header file. */ +#if defined(DJGPP) || defined(__MINGW32__) +#define HAVE_SYS_TIME_H 1 +#endif + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#undef HAVE_SYS_WAIT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_TERMIOS_H + +/* Define to 1 if you have the `tmpfile' function. */ +#undef HAVE_TMPFILE + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#undef HAVE_TM_ZONE + +/* Define to 1 if you have the `towlower' function. */ +#ifdef __MINGW32__ +#define HAVE_TOWLOWER 1 +#endif + +/* Define to 1 if you have the `towupper' function. */ +#ifdef __MINGW32__ +#define HAVE_TOWUPPER 1 +#endif + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +#define HAVE_TZNAME 1 + +/* Define to 1 if you have the `tzset' function. */ +#define HAVE_TZSET 1 + +/* Define if you have the 'uintmax_t' type in or . */ +#if defined(DJGPP) || defined(__MINGW32__) +#define HAVE_UINTMAX_T 1 +#ifdef DJGPP +#define uintmax_t unsigned long long +#endif +#endif + +/* Define to 1 if you have the header file. */ +#if defined(DJGPP) || defined(__MINGW32__) +#define HAVE_UNISTD_H 1 +#endif + +/* Define if you have the 'unsigned long long' type. */ +#define HAVE_UNSIGNED_LONG_LONG 1 + +/* Define to 1 if the system has the type `unsigned long long int'. */ +#undef HAVE_UNSIGNED_LONG_LONG_INT + +/* Define to 1 if you have the `usleep' function. */ +#if defined(DJGPP) || defined(__MINGW32__) +#define HAVE_USLEEP 1 +#endif + +/* Define to 1 if you have the `vprintf' function. */ +#define HAVE_VPRINTF 1 + +/* Define to 1 if you have the header file. */ +#ifdef __MINGW32__ +#define HAVE_WCHAR_H 1 +#endif + +/* Define to 1 if you have the `wcrtomb' function. */ +#ifdef __MINGW32__ +#define HAVE_WCRTOMB 1 +#endif + +/* Define to 1 if you have the `wcscoll' function. */ +#ifdef __MINGW32__ +#define HAVE_WCSCOLL 1 +#endif + +/* Define to 1 if you have the `wctype' function. */ +#ifdef __MINGW32__ +#define HAVE_WCTYPE 1 +#endif + +/* Define to 1 if you have the header file. */ +#ifdef __MINGW32__ +#define HAVE_WCTYPE_H 1 +#endif + +/* systems should define this type here */ +#ifdef __MINGW32__ +#define HAVE_WCTYPE_T 1 +#endif + +/* systems should define this type here */ +#ifdef __MINGW32__ +#define HAVE_WINT_T 1 +#endif + +/* disable lint checks */ +#undef NO_LINT + +/* Name of package */ +#define PACKAGE "gawk" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "bug-gawk@gnu.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "GNU Awk" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "GNU Awk 4.0.0l" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "gawk" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "http://www.gnu.org/software/gawk/" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "4.0.0l" + +/* Define to 1 if *printf supports %F format */ +#undef PRINTF_HAS_F_FORMAT + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +#if defined(DJGPP) || defined(__MINGW32__) +#include +#endif + +/* The size of `unsigned int', as computed by sizeof. */ +#if UINT_MAX == 65536 +#define SIZEOF_UNSIGNED_INT 2 +#elif UINT_MAX == 4294967295U +#define SIZEOF_UNSIGNED_INT 4 +#endif + +/* The size of `unsigned long', as computed by sizeof. */ +#if ULONG_MAX == 4294967295UL +#define SIZEOF_UNSIGNED_LONG 4 +#endif + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* some systems define this type here */ +#undef TIME_T_IN_SYS_TYPES_H + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +#undef TM_IN_SYS_TIME + +/* force use of our version of strftime */ +#undef USE_INCLUDED_STRFTIME + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif + + +/* Version number of package */ +#define VERSION "4.0.0l" + +/* Number of bits in a file offset, on hosts where this is settable. */ +#undef _FILE_OFFSET_BITS + +/* Define for large files, on AIX-style hosts. */ +#undef _LARGE_FILES + +/* Define to 1 if on MINIX. */ +#undef _MINIX + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +#undef _POSIX_1_SOURCE + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +#undef _POSIX_SOURCE + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +# undef __CHAR_UNSIGNED__ +#endif + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `int' if doesn't define. */ +#undef gid_t + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#ifdef __GNUC__ +#define inline __inline__ +#endif +#endif + +/* Define to long or long long if and don't define. */ +#ifdef DJGPP +#define intmax_t long long +#endif + +/* Define to `int' if does not define. */ +#undef pid_t + +/* Define to the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported directly. */ +#ifdef DJGPP +#define restrict +#endif +/* Work around a bug in Sun C++: it does not support _Restrict or + __restrict__, even though the corresponding Sun C compiler ends up with + "#define restrict _Restrict" or "#define restrict __restrict__" in the + previous line. Perhaps some future version of Sun C++ will work with + restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ +#if defined __SUNPRO_CC && !defined __RESTRICT +# define _Restrict +# define __restrict__ +#endif + +/* Define to `unsigned int' if does not define. */ +#undef size_t + +/* type to use in place of socklen_t if not defined */ +#undef socklen_t + +/* Define to `int' if does not define. */ +#undef ssize_t + +/* Define to `int' if doesn't define. */ +#undef uid_t + +/* Define to unsigned long or unsigned long long if and + don't define. */ +#ifdef DJGPP +#define uintmax_t unsigned long long +#endif + +#include "custom.h" +/* Library search path */ +#if defined(__DJGPP__) && (__DJGPP__ > 2 || __DJGPP_MINOR__ >= 3) +# define DEFPATH ".;/dev/env/DJDIR/share/awk" +#else +# define DEFPATH ".;c:/lib/awk;c:/gnu/lib/awk" +#endif + +#ifndef DJGPP +#define HAVE_POPEN_H 1 +#endif + +#if defined(__EMX__) +#define strcasecmp stricmp +#define strncasecmp strnicmp +#endif + +#if defined(__MINGW32__) +# define WEXITSTATUS(stat_val) ((stat_val) & ~0xC0000000) +#endif diff --git a/pc/config.sed b/pc/config.sed new file mode 100644 index 0000000..96b2c2d --- /dev/null +++ b/pc/config.sed @@ -0,0 +1,279 @@ +# -config.sed----------------------------------------------------------- +# Configuration script for pc/config.h +# ---------------------------------------------------------------------- + +# Copyright (C) 2011 the Free Software Foundation, Inc. + +# This file is part of GAWK, the GNU implementation of the +# AWK Programming Language. + +# GAWK is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +# ---------------------------------------------------------------------- + +/configh\.in/a\ +/* pc/config.h. Generated automatically by pc/config.sed. */ + +s/^#undef GETPGRP_VOID *$/#define GETPGRP_VOID 1/ +s/^#undef GETGROUPS_T *$/#define GETGROUPS_T gid_t/ +/^#undef GETPGRP_VOID$/c\ +#ifdef DJGPP\ +#define GETPGRP_VOID 1\ +#endif +s/^#undef HAVE_ALARM *$/#define HAVE_ALARM 1/ +s/^#undef HAVE_ATEXIT *$/#define HAVE_ATEXIT 1/ +/^#undef HAVE_BTOWC *$/c\ +#ifdef _WIN32\ +#define HAVE_BTOWC 1\ +#endif +/^#undef HAVE_DECL_TZNAME *$/c\ +#ifdef __MINGW32__\ +#define HAVE_DECL_TZNAME 1\ +#endif +s/^#undef HAVE_FCNTL_H *$/#define HAVE_FCNTL_H 1/ +s/^#undef HAVE_FMOD *$/#define HAVE_FMOD 1/ +/^#undef HAVE_INTMAX_T *$/c\ +#ifdef __MINGW32__\ +#define HAVE_INTMAX_T 1\ +#endif +/^#undef HAVE_INTTYPES_H *$/c\ +#ifdef __MINGW32__\ +#define HAVE_INTTYPES_H 1\ +#endif +/^#undef HAVE_INTTYPES_H_WITH_UINTMAX *$/c\ +#ifdef __MINGW32__\ +#define HAVE_INTTYPES_H_WITH_UINTMAX 1\ +#endif +/^#undef HAVE_ISASCII *$/c\ +#ifdef __MINGW32__\ +#define HAVE_ISASCII 1\ +#endif +/^#undef HAVE_ISWCTYPE *$/c\ +#ifdef __MINGW32__\ +#define HAVE_ISWCTYPE 1\ +#endif +/^#undef HAVE_ISWLOWER *$/c\ +#ifdef __MINGW32__\ +#define HAVE_ISWLOWER 1\ +#endif +/^#undef HAVE_ISWUPPER *$/c\ +#ifdef __MINGW32__\ +#define HAVE_ISWUPPER 1\ +#endif +s/^#undef HAVE_LIBM *$/#define HAVE_LIBM 1/ +/^#undef HAVE_LIBREADLINE *$/c\ +/* #undef HAVE_LIBREADLINE */ +s/^#undef HAVE_LIMITS_H *$/#define HAVE_LIMITS_H 1/ +/^#undef HAVE_LOCALE_H *$/c\ +#ifdef __MINGW32__\ +#define HAVE_LOCALE_H 1\ +#endif +/^#undef HAVE_LONG_LONG *$/c\ +#ifdef __MINGW32__\ +#define HAVE_LONG_LONG 1\ +#endif +/^#undef HAVE_MBRLEN *$/c\ +#ifdef __MINGW32__\ +#define HAVE_MBRLEN 1\ +#endif +/^#undef HAVE_MBRTOWC *$/c\ +#ifdef __MINGW32__\ +#define HAVE_MBRTOWC 1\ +#endif +s/^#undef HAVE_MEMCMP *$/#define HAVE_MEMCMP 1/ +s/^#undef HAVE_MEMCPY *$/#define HAVE_MEMCPY 1/ +/^#undef HAVE_MEMMOVE *$/c\ +#ifdef __MINGW32__\ +#define HAVE_MEMMOVE 1\ +#endif +s/^#undef HAVE_MEMSET *$/#define HAVE_MEMSET 1/ +/^#undef HAVE_MKSTEMP *$/c\ +#ifdef DJGPP\ +#define HAVE_MKSTEMP 1\ +#endif +s/^#undef HAVE_MKTIME *$/#define HAVE_MKTIME 1/ +/^#undef HAVE_SETENV *$/c\ +#if defined(__MINGW32__) || defined(__DJGPP__)\ +#define HAVE_SETENV 1\ +#endif +/^#undef HAVE_SETLOCALE *$/c\ +#ifdef __MINGW32__\ +#define HAVE_SETLOCALE 1\ +#endif +/^#undef HAVE_SNPRINTF *$/c\ +#ifdef __MINGW32__\ +#define HAVE_SNPRINTF 1\ +#endif +s/^#undef HAVE_STDARG_H *$/#define HAVE_STDARG_H 1/ +/^#undef HAVE_STDDEF_H *$/c\ +#ifdef __GNUC__\ +#define HAVE_STDDEF_H 1\ +#endif +/^#undef HAVE_STDINT_H *$/c\ +#ifdef __MINGW32__\ +#define HAVE_STDINT_H 1\ +#endif +/^#undef HAVE_STDLIB_H *$/c\ +#ifdef __MINGW32__\ +#define HAVE_STDLIB_H 1\ +#endif +s/^#undef HAVE_STRCHR *$/#define HAVE_STRCHR 1/ +s/^#undef HAVE_STRERROR *$/#define HAVE_STRERROR 1/ +/^#undef HAVE_STRFTIME *$/c\ +#ifdef __MINGW32__\ +/* MinGW uses the replacement from missing_d, to support the %e specifier. */\ +#define strftime rpl_strftime\ +#else\ +#define HAVE_STRFTIME 1\ +#endif +s/^#undef HAVE_STRINGIZE *$/#define HAVE_STRINGIZE 1/ +s/^#undef HAVE_STRING_H *$/#define HAVE_STRING_H 1/ +/^#undef HAVE_STRNCASECMP *$/c\ +#define HAVE_STRNCASECMP 1\ +#ifdef __EMX__\ +#define strncasecmp strnicmp\ +#endif +s/^#undef HAVE_STRTOD *$/#define HAVE_STRTOD 1/ +/^#undef HAVE_STRTOUL *$/c\ +#ifdef __MINGW32__\ +#define HAVE_STRTOUL 1\ +#endif +s/^#undef HAVE_SYSTEM *$/#define HAVE_SYSTEM 1/ +/^#undef HAVE_SYS_PARAM_H *$/c\ +#ifndef __MINGW32__\ +#define HAVE_SYS_PARAM_H 1\ +#endif +/^#undef HAVE_SYS_STAT_H *$/c\ +#ifdef __MINGW32__\ +#define HAVE_SYS_STAT_H 1\ +#endif +/^#undef HAVE_SYS_TIME_H *$/c\ +#if defined(DJGPP) || defined(__MINGW32__)\ +#define HAVE_SYS_TIME_H 1\ +#endif +s/^#undef HAVE_SYS_TYPES_H *$/#define HAVE_SYS_TYPES_H 1/ +/^#undef HAVE_TOWLOWER *$/c\ +#ifdef __MINGW32__\ +#define HAVE_TOWLOWER 1\ +#endif +/^#undef HAVE_TOWUPPER *$/c\ +#ifdef __MINGW32__\ +#define HAVE_TOWUPPER 1\ +#endif +s/^#undef HAVE_TZNAME *$/#define HAVE_TZNAME 1/ +s/^#undef HAVE_TZSET *$/#define HAVE_TZSET 1/ +/^#undef HAVE_UINTMAX_T *$/c\ +#if defined(DJGPP) || defined(__MINGW32__)\ +#define HAVE_UINTMAX_T 1\ +#ifdef DJGPP\ +#define uintmax_t unsigned long long\ +#endif\ +#endif +/^#undef HAVE_UNISTD_H *$/c\ +#if defined(DJGPP) || defined(__MINGW32__)\ +#define HAVE_UNISTD_H 1\ +#endif +s/^#undef HAVE_UNSIGNED_LONG_LONG *$/#define HAVE_UNSIGNED_LONG_LONG 1/ +/^#undef HAVE_USLEEP *$/c\ +#if defined(DJGPP) || defined(__MINGW32__)\ +#define HAVE_USLEEP 1\ +#endif +s/^#undef HAVE_VPRINTF *$/#define HAVE_VPRINTF 1/ +/^#undef HAVE_WCHAR_H *$/c\ +#ifdef __MINGW32__\ +#define HAVE_WCHAR_H 1\ +#endif +/^#undef HAVE_WCRTOMB *$/c\ +#ifdef __MINGW32__\ +#define HAVE_WCRTOMB 1\ +#endif +/^#undef HAVE_WCSCOLL *$/c\ +#ifdef __MINGW32__\ +#define HAVE_WCSCOLL 1\ +#endif +/^#undef HAVE_WCTYPE *$/c\ +#ifdef __MINGW32__\ +#define HAVE_WCTYPE 1\ +#endif +/^#undef HAVE_WCTYPE_H *$/c\ +#ifdef __MINGW32__\ +#define HAVE_WCTYPE_H 1\ +#endif +/^#undef HAVE_WCTYPE_T *$/c\ +#ifdef __MINGW32__\ +#define HAVE_WCTYPE_T 1\ +#endif +/^#undef HAVE_WINT_T *$/c\ +#ifdef __MINGW32__\ +#define HAVE_WINT_T 1\ +#endif +s/^#undef PROTOTYPES *$/#define PROTOTYPES 1/ +s/^#undef RETSIGTYPE *$/#define RETSIGTYPE void/ +/^#.*RETSIGTYPE /a\ +\ +#if defined(DJGPP) || defined(__MINGW32__)\ +#include \ +#endif +/^#undef SIZEOF_UNSIGNED_INT *$/c\ +#if UINT_MAX == 65536\ +#define SIZEOF_UNSIGNED_INT 2\ +#elif UINT_MAX == 4294967295U\ +#define SIZEOF_UNSIGNED_INT 4\ +#endif +/^#undef SIZEOF_UNSIGNED_LONG *$/c\ +#if ULONG_MAX == 4294967295UL\ +#define SIZEOF_UNSIGNED_LONG 4\ +#endif +s/^#undef STDC_HEADERS *$/#define STDC_HEADERS 1/ +s/^#undef TIME_WITH_SYS_TIME *$/#define TIME_WITH_SYS_TIME 1/ +/^#undef inline *$/c\ +#ifdef __GNUC__\ +#define inline __inline__\ +#endif +/^#undef intmax_t *$/c\ +#ifdef DJGPP\ +#define intmax_t long long\ +#endif +/^#undef restrict *$/c\ +#ifdef DJGPP\ +#define restrict\ +#endif +/^#undef uintmax_t *$/c\ +#ifdef DJGPP\ +#define uintmax_t unsigned long long\ +#endif + +s|^#undef PACKAGE_URL *$|#define PACKAGE_URL "http://www.gnu.org/software/gawk/"| + +$a\ +/* Library search path */\ +#if defined(__DJGPP__) && (__DJGPP__ > 2 || __DJGPP_MINOR__ >= 3)\ +# define DEFPATH ".;/dev/env/DJDIR/share/awk"\ +#else\ +# define DEFPATH ".;c:/lib/awk;c:/gnu/lib/awk"\ +#endif\ +\ +#ifndef DJGPP\ +#define HAVE_POPEN_H 1\ +#endif\ +\ +#if defined(__EMX__)\ +#define strcasecmp stricmp\ +#define strncasecmp strnicmp\ +#endif\ +\ +#if defined(__MINGW32__)\ +# define WEXITSTATUS(stat_val) ((stat_val) & ~0xC0000000)\ +#endif diff --git a/pc/configpk.sed b/pc/configpk.sed new file mode 100644 index 0000000..26e6e94 --- /dev/null +++ b/pc/configpk.sed @@ -0,0 +1,9 @@ +s/^AC_INIT([[]\{0,1\}\([^],]*\)[]]\{0,1\}, *[[]\{0,1\}\([^],]*\)[]]\{0,1\}, *[[]\{0,1\}\([^],]*\)[]]\{0,1\}, *[[]\{0,1\}\([^],)]*\).*$/\ +s|^#undef PACKAGE_NAME *$|#define PACKAGE_NAME "\1"|\ +s|^#undef VERSION *$|#define VERSION "\2"\|\ +s|^#undef PACKAGE_VERSION *$|#define PACKAGE_VERSION "\2"|\ +s|^#undef PACKAGE_STRING *$|#define PACKAGE_STRING "\1 \2"|\ +s|^#undef PACKAGE_BUGREPORT *$|#define PACKAGE_BUGREPORT "\3"|\ +s|^#undef PACKAGE *$|#define PACKAGE "\4"|\ +s|^#undef PACKAGE_TARNAME *$|#define PACKAGE_TARNAME "\4"|\ +/p diff --git a/pc/gawk.def b/pc/gawk.def new file mode 100644 index 0000000..ac1a5a2 --- /dev/null +++ b/pc/gawk.def @@ -0,0 +1,2 @@ +NAME gawk WINDOWCOMPAT NEWFILES +DESCRIPTION 'GNU awk for OS/2' diff --git a/pc/gawkmisc.pc b/pc/gawkmisc.pc new file mode 100644 index 0000000..b2a67a5 --- /dev/null +++ b/pc/gawkmisc.pc @@ -0,0 +1,606 @@ +/* + * gawkmisc.c --- miscellaneous gawk routines that are OS specific. + */ + +/* + * Copyright (C) 1986, 1988, 1989, 1991 - 2003, 2012 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Progamming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +char quote = '\''; +char envsep = ';'; + +# ifdef DEFPATH +char *defpath = DEFPATH; +# else +char *defpath = ".;c:\\lib\\awk;c:\\gnu\\lib\\awk"; +# endif + +#ifdef __EMX__ +#include + +static int _os2_is_abs_path(const char *dirname); +static char* _os2_unixroot(const char *path); +static const char* _os2_unixroot_path(const char *path); +#endif + +/* gawk_name --- pull out the "gawk" part from how the OS called us */ + +char * +gawk_name(filespec) +const char *filespec; +{ + char *p, *q; + + p = (char *) filespec; /* Sloppy... */ + + /* OS/2 allows / for directory separator too */ + if ((q = strrchr(p, '\\')) != NULL) + p = q + 1; + if ((q = strrchr(p, '/')) != NULL + && (p == NULL || q > p)) /* support mixed d:\foo/bar\gawk.exe */ + p = q + 1; + if ((q = strchr(p, '.')) != NULL) + *q = '\0'; + return strlwr(p); +} + + +/* + * memcpy_long() & memset_ulong() are 32-bit replacements for MSC which + * has a 16-bit size_t. + */ +char * +memcpy_ulong (dest, src, l) +register char *dest; +register const char *src; +register unsigned long l; +{ + register char *ret = dest; + + while (l--) + *dest++ = *src++; + + return ret; +} + + +void * +memset_ulong(dest, val, l) +void *dest; +register int val; +register unsigned long l; +{ + register char *ret = dest; + register char *d = dest; + + while (l--) + *d++ = val; + + return ((void *) ret); +} + + +/* os_arg_fixup --- fixup the command line */ + +void +os_arg_fixup(argcp, argvp) +int *argcp; +char ***argvp; +{ +#ifdef __EMX__ +# ifdef initialize_main + initialize_main(argcp, argvp); +# else + _wildcard(argcp, argvp); + _response(argcp, argvp); +# endif + + setvbuf(stdout, NULL, _IOLBF, BUFSIZ); + defpath = (char*) _os2_unixroot_path(defpath); +#endif /* __EMX__ */ + return; +} + +/* os_devopen --- open special per-OS devices */ + +int +os_devopen(name, flag) +const char *name; +int flag; +{ +#ifdef __EMX__ + /* do not use open(name, flag) here !!! */ + return -1; +#else + if (strcmp(name, "/dev/null") == 0) + return open("NUL", flag); + /* FIXME: */ + /* else if (strcmp(name, "/dev/tty") == 0) + * return open("???", flag); + */ + return -1; +#endif +} + +/* optimal_bufsize --- determine optimal buffer size */ + +size_t +optimal_bufsize(fd, stb) +int fd; +struct stat *stb; +{ + /* force all members to zero in case OS doesn't use all of them. */ + memset(stb, '\0', sizeof(struct stat)); + + /* + * DOS doesn't have the file system block size in the + * stat structure. So we have to make some sort of reasonable + * guess. We use stdio's BUFSIZ, since that is what it was + * meant for in the first place. + */ +#define DEFBLKSIZE BUFSIZ + + if (fstat(fd, stb) == -1) + fatal("can't stat fd %d (%s)", fd, strerror(errno)); + if (S_ISREG(stb->st_mode) + && 0 < stb->st_size && stb->st_size < DEFBLKSIZE) /* small file */ + return stb->st_size; + return DEFBLKSIZE; +} + +/* ispath --- return true if path has directory components */ + +int +ispath(file) +const char *file; +{ +#ifdef __EMX__ + return (strpbrk(file, "/\\") != NULL || + (toupper(file[0]) >= 'A' && toupper(file[0]) <= 'Z' && file[1] == ':')); +#else + for (; *file; file++) { + switch (*file) { + case '/': + case '\\': + case ':': + return 1; + } + } + return 0; +#endif +} + +/* isdirpunct --- return true if char is a directory separator */ + +int +isdirpunct(c) +int c; +{ + return (strchr(":\\/", c) != NULL); +} + +/* os_close_on_exec --- set close on exec flag, print warning if fails */ + +void +os_close_on_exec(fd, name, what, dir) +int fd; +const char *name, *what, *dir; +{ +#if ! defined(_MSC_VER) && ! defined(__MINGW32__) +# if (defined(__DJGPP__) && (__DJGPP__ > 2 || __DJGPP_MINOR__ >= 4)) || defined __EMX__ + if (fd <= 2) /* sanity */ + return; + + if (fcntl(fd, F_SETFD, 1) < 0) + warning("%s %s `%s': could not set close-on-exec: %s", + what, dir, name, strerror(errno)); +# endif +#endif +} + +/* os_isdir --- is this an fd on a directory? */ + +#if ! defined(S_ISDIR) && defined(S_IFDIR) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif + +int +os_isdir(fd) +int fd; +{ + struct stat sbuf; + + return (fstat(fd, &sbuf) == 0 && S_ISDIR(sbuf.st_mode)); +} + +/* os_is_setuid --- true if running setuid root */ + +int +os_is_setuid() +{ +#ifdef __EMX__ + long uid, euid; + + uid = getuid(); + euid = geteuid(); + + return (euid == 0 && euid != uid); +#else + return 0; +#endif +} + +/* os_setbinmode --- set binary mode on file */ + +#ifdef __DJGPP__ +#include +#endif +static int orig_tty_mode = -1; + +int +os_setbinmode(fd, mode) +int fd, mode; +{ + int prev_mode = setmode(fd, mode); + +#ifdef __DJGPP__ + if ((mode & O_BINARY) != 0) + __djgpp_set_ctrl_c(1); /* allow to interrupt with Ctrl-C */ +#endif + /* Save the original tty mode as we found it. */ + if (orig_tty_mode == -1 && fd >= 0 && fd <= 2) + orig_tty_mode = prev_mode; + return prev_mode; +} + +/* os_restore_mode --- restore the original mode of the console device */ + +void +os_restore_mode (fd) +int fd; +{ + if (orig_tty_mode != -1) { + setmode(fd, orig_tty_mode); + } +} + +/* os_isatty --- return true if fd is a tty */ + +int +os_isatty(int fd) +{ +#if defined(__MINGW32__) || defined(_MSC_VER) + return (isatty(fd) && lseek(fd, SEEK_CUR, 0) == -1); +#else + return isatty(fd); +#endif +} + +/* files_are_same --- return true if files are identical */ + +int +files_are_same(char *path, SRCFILE *src) +{ + struct stat st; + size_t pathlen; + char *p, *s; + + if (stat (path, & st) == 0) { + /* If they have a working `stat', honor that. */ + if (!(st.st_dev == src->sbuf.st_dev + && st.st_ino == src->sbuf.st_ino)) + return 0; + + /* Compare modification times. */ + if (st.st_mtime != src->mtime) + return 0; + + /* Compare absolute file names case-insensitively, and + treat forward- and back-slashes as equal. */ + pathlen = strlen(path); + for (p = path, s = src->fullpath; + p <= path + pathlen; + p++, s++) { + if (tolower(*p) != tolower(*s) + && !((*p == '/' || *p == '\\') + && (*s == '/' || *s == '\\'))) + return 0; + } + return 1; + } + return 0; +} + + +#ifdef __EMX__ +# ifndef PATH_SEPARATOR +# define PATH_SEPARATOR ';' +# endif + +/* result is 0 if dirname is no absolute path, 1 otherwise */ + +static int +_os2_is_abs_path(const char *dirname) +{ + int result = 0; + if (dirname != NULL && dirname[0] != '\0') { + /* if dirname contains a valid drive letter like "c:" */ + if (((dirname[0] >= 'A' && dirname[0] <= 'Z') || (dirname[0] >= 'a' && dirname[0] <= 'z')) + && dirname[1] == ':') dirname += 2; /* remove the drive letter */ + + if (dirname[0] == '/' || dirname[0] == '\\') result = 1; /* asbolute path */ + } + + return result; +} + + +/* path is assumed to be a list of directories separated by PATH_SEPARATOR. + This function determines if the first directory of path is on the + drive specified by the environment variable UNIXROOT. + If it is the case, NULL is returned, otherwise a new directory name + is allocated using the drive letter from UNIXROOT and returned as result. + If the first directory is a relative path NULL is returned, too. + The new directory name is allocated by malloc(). + Example (UNIXROOT is set to "e:"): + "c:/usr/share" -> "e:/usr/share" + "e:/usr/share" -> NULL (already on the $UNIXROOT drive) + "/usr/share" -> "e:/usr/share" + "." -> NULL (not an absolute path) + "usr/share" -> NULL (not an absolute path) + "c:usr/share" -> NULL (not an absolute path) + "c:/usr/share;d:/etc" -> "e:/usr/share" (only the first directory in path is used) */ + +static char* +_os2_unixroot(const char *path) +{ + static const char *unixroot = NULL; + static int unixroot_init = 0; + char *result = NULL; + + if (unixroot_init == 0) { + /* get $UNIXROOT only one time */ + unixroot = getenv("UNIXROOT"); + + /* check whether unixroot is valid (must be "x:") */ + if (unixroot != NULL) { + int drive = toupper(unixroot[0]); + if (drive < 'A' || drive > 'Z' || unixroot[1] != ':' || unixroot[2] != '\0') + unixroot = NULL; /* unixroot not valid */ + } + + unixroot_init = 1; /* initialized */ + } + + /* note: if unixroot != NULL then it contains a valid drive letter */ + if (unixroot != NULL && _os2_is_abs_path(path)) { + /* dirname is an absolute path and unixroot is a drive letter, "c:" for example */ + size_t old_path_len = strlen(path); + + /* end points to the first ';' in path or to NULL */ + const char *end = strchr(path, PATH_SEPARATOR); + + /* dir_len is the length of the first directory in path */ + size_t dir_len = (end) ? end - path : old_path_len; + + if (toupper(unixroot[0]) != toupper(path[0]) || path[1] != ':') { + /* the first directory of path does not start with the string $UNIXROOT */ + if (path[1] == ':') { + /* if there is a drive letter remove it */ + dir_len -= 2; + path += 2; + } + + result = malloc(dir_len + 3); + if (result) { /* do nothing if we are out of memory */ + result[0] = unixroot[0]; + result[1] = unixroot[1]; + memcpy(result + 2, path, dir_len); + result[dir_len + 2] = '\0'; + } + } + } + return result; +} + +/* path is assumed to be a list of directories separated by PATH_SEPARATOR. + Every directory is processed. _os2_unixroot() is used to find out whether + these directories are on the drive specified by the environment variable + UNIXROOT. If this is not the case the same directory on the UNIXROOT drive + is added to the end of path. If path is a valid path this function returns a valid path, too. + Example ($UNIXROOT is set to "e:"): + ".;c:/usr/local;d:/usr/local;d:/etc;e:/etc" + -> ".;c:/usr/local;d:/usr/local;d:/etc;e:/etc;e:/usr/local;e:/usr/local;e:/etc" */ + +static const char* +_os2_unixroot_path(const char *path) +{ + char *result = NULL; + const char *p = path; + unsigned dir_count = 1; + + if (path == NULL || path[0] == '\0') return NULL; /* empty path */ + + /* save number of path components in dir_count */ + while(*p) { + if (*p++ == PATH_SEPARATOR && *p != '\0' && *p != PATH_SEPARATOR) + dir_count += 1; + } + + { + const char *list[dir_count]; /* list of char pointers */ + size_t dir_len[dir_count]; /* the according directory length */ + size_t old_path_len = strlen(path); /* the old path length */ + size_t total_len; + unsigned i = 0; + + if (path[old_path_len - 1] == PATH_SEPARATOR) /* last character is ';' */ + old_path_len--; + + list[0] = p = path; /* first directory */ + + while(*p) { + if (*p++ == PATH_SEPARATOR && *p != '\0' && *p != PATH_SEPARATOR) + list[++i] = p; + } + /* now list[i] contains the ith directory of path (no 0-terminated strings!!!) */ + + /* determine the total length for the new path */ + total_len = old_path_len; + + for(i = 0; i < dir_count; i++) { + list[i] = _os2_unixroot(list[i]); + if (list[i] != NULL) { + dir_len[i] = strlen(list[i]); + total_len += dir_len[i] + 1; /* one character for ';' or '\0' */ + } + else dir_len[i] = 0; + } + /* now list[] contains the according directories on the UNIXROOT drive or NULL + total_len contains the total length for the new path */ + result = malloc(total_len + 1); + + if (result) { + /* copy the old path and the new directories into the new path */ + char *q = result; + memcpy(q, path, old_path_len); + q += old_path_len; + + for(i = 0; i < dir_count; i++) { + if (dir_len[i] != 0) { + *q++ = PATH_SEPARATOR; + memcpy(q, list[i], dir_len[i]); + q += dir_len[i]; + } + } + + *q = '\0'; /* terminating '\0' */ + } + + for(i = 0; i < dir_count; i++) free((void*) list[i]); + } + + return (result) ? (const char*) result : path; +} +#endif /* __EMX__ */ + +#ifdef __MINGW32__ + +extern void *xmalloc (size_t); + +int +setenv (const char *name, const char *value, int rewrite) +{ + char *entry; + + if (*value == '=') + ++value; + + if (getenv (name) && !rewrite) + return 0; + + entry = xmalloc (strlen (name) + 1 + strlen (value) + 1); + strcat (strcat (strcpy (entry, name), "="), value); + if (putenv (entry) != 0) + { + free (entry); + return -1; + } + return 0; +} + +int +unsetenv (const char *name) +{ + if (!name || !*name || strchr (name, '=') != NULL) + return -1; + + return setenv (name, "", 1); +} + +#include + +int +usleep(unsigned int usec) +{ + double msecf = usec / 1000.0; + + Sleep ((DWORD)msecf); + + return usec - msecf * 1000 < 0 ? 0 : (int)(usec - msecf * 1000); +} + +/* The implementation of wctob in the MS runtime is problematic + because it doesn't allow to distinguish between WEOF and 0xff, due + to integer sign extension. It also causes failures in dfa.c when + characters with the 8th bit set are involved. This replacement + version fixes that. */ + +#include + +int +wctob (wint_t wc) +{ + char buf[64]; + + if (!(MB_CUR_MAX <= sizeof (buf))) + abort (); + /* Handle the case where WEOF is a value that does not fit in a wchar_t. */ + if (wc == (wchar_t)wc) + if (wctomb (buf, (wchar_t)wc) == 1) + return (unsigned char) buf[0]; + return EOF; +} + +/* + * On MS-Windows with MinGW, execvp causes the shell and the re-exec'ed + * dgawk to compete for the keyboard input. + * + * This will need work if we ever need a real version of execvp. + */ +int execvp(const char *file, const char *const *argv) +{ + if (_spawnvp(_P_WAIT, file, (const char * const *)argv) != -1) + exit(EXIT_SUCCESS); + + return -1; +} +#endif /* __MINGW32__ */ + +#ifdef __DJGPP__ + +int +unsetenv (const char *name) +{ + if (!name || !*name || strchr (name, '=') != NULL) + return -1; + + return putenv (name); +} + +/* This is needed to defeat too-clever GCC warnings in dfa.c about + comparison being always false due to limited range of data type. */ +wint_t +btowc (int c) +{ + return c; +} + +#endif /* __DJGPP__ */ diff --git a/pc/getid.c b/pc/getid.c new file mode 100644 index 0000000..eb30ae4 --- /dev/null +++ b/pc/getid.c @@ -0,0 +1,37 @@ +#ifdef __MINGW32__ + +#include + +unsigned int getuid (void) +{ + return (0); /* root! */ +} + +unsigned int geteuid (void) +{ + return (0); +} + +unsigned int getgid (void) +{ + return (0); +} + +unsigned int getegid (void) +{ + return (0); +} + +#endif /* __MINGW32__ */ + +int getpgrp(void) +{ + return (0); +} + +#if defined(__DJGPP__) || defined(__MINGW32__) +int getppid(void) +{ + return (0); +} +#endif /* __DJGPP__ || __MINGW32__ */ diff --git a/pc/install.awk b/pc/install.awk new file mode 100644 index 0000000..367e8b9 --- /dev/null +++ b/pc/install.awk @@ -0,0 +1,62 @@ +# install.awk +# awk script to handle "make install". Goal is to eliminate need for +# extra utilities (such as sh, mkdir, and cp). This is a hack. + +function mkinstalldirs(dir, i, ii, j, jj, s, comp, mkdir) +{ + gsub("/", "\\", dir); ii = split(dir, s, " ") + print "@echo off" > install_bat + print "@echo off" > install_cmd + for (i = 1; i <= ii; i++) { + jj = split(s[i], comp, "\\"); dir = comp[1]; + for (j = 1; j <= jj; dir=dir "\\" comp[++j]) { + if (substr(dir, length(dir)) == ":" || mkdir[dir]) continue; + printf("if not exist %s\\*.* mkdir %s\n", dir, dir) > install_bat + printf("if not exist %s\\* mkdir %s\n", dir, dir) > install_cmd + mkdir[dir] = 1 + } + } + close(install_bat); close(install_cmd) + system(install) +} + +function cp(s, j, n, comp) +{ + gsub("/", "\\", s); n = split(s, comp, " "); + print "@echo off" > install_bat + print "@echo off" > install_cmd + for (j = 1; j < n; j++) { + printf("copy %s %s\n", comp[j], comp[n]) > install_cmd + if (substr(comp[j], length(comp[j]), 1) == "*") + comp[j] = comp[j] ".*" + printf("copy %s %s\n", comp[j], comp[n]) > install_bat + } + close(install_bat); close(install_cmd) + system(install) +} + +BEGIN{ +install = "installg" +install_bat = install ".bat"; install_cmd = install ".cmd" +igawk_cmd = prefix "/bin/igawk.cmd" +igawk_bat = prefix "/bin/igawk.bat" +igawk = "pc/awklib/igawk" + +# Make the bin directory +mkinstalldirs(prefix "/bin"); + +# Create igawk.cmd for OS/2 +printf("extproc sh %s/bin/igawk.cmd\nshift\n", prefix) > igawk_cmd +while (getline < igawk) print $0 > igawk_cmd + +# Create igawk.bat for DOS +printf("@sh %s/bin/igawk %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9", prefix) > igawk_bat + +# Do common +cp(igawk " *awk.exe " prefix "/bin") +mkinstalldirs(prefix "/lib/awk " prefix "/man/man1 " prefix "/info") +cp("awklib/eg/lib/* pc/awklib/igawk.awk " prefix "/lib/awk"); +cp("doc/*.1 " prefix "/man/man1"); +cp("doc/gawk.info " prefix "/info"); +cp("doc/gawkinet.info " prefix "/info"); +} diff --git a/pc/make-config.bat b/pc/make-config.bat new file mode 100755 index 0000000..d224804 --- /dev/null +++ b/pc/make-config.bat @@ -0,0 +1,6 @@ +@echo off +sed -n -f configpk.sed < ..\configure.ac > tmp.sed +sed -f config.sed < ..\configh.in > config.tmp +sed -f tmp.sed < config.tmp > config.h +del tmp.sed +del config.tmp diff --git a/pc/mkinstal.sh b/pc/mkinstal.sh new file mode 100644 index 0000000..f5e45f3 --- /dev/null +++ b/pc/mkinstal.sh @@ -0,0 +1,33 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Last modified: 1994-03-25 +# Public domain + +errstatus=0 + +for file in ${1+"$@"} ; do + #set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + set fnord `echo "$file" | sed 's/\([^:]\)\//\1 /g'` + shift + + pathcomp= + for d in ${1+"$@"} ; do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" 1>&2 + mkdir "$pathcomp" || errstatus=$? + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here diff --git a/pc/popen.c b/pc/popen.c new file mode 100644 index 0000000..97ff264 --- /dev/null +++ b/pc/popen.c @@ -0,0 +1,244 @@ +#include +#include +#include +#include +#include + +#ifndef _NFILE +#define _NFILE 40 +#endif + +static char template[] = "piXXXXXX"; +static struct { + char *command; + char *name; + char pmode[4]; +} pipes[_NFILE]; + + +/* + * For systems where system() and popen() do not follow SHELL: + * 1. Write command to temp file. Temp filename must have slashes + * compatible with SHELL (if set) or COMSPEC. + * 2. Convert slashes in SHELL (if present) to be compatible with COMSPEC. + * Currently, only MSC (running under DOS) and MINGW versions are managed. + */ + +#if defined(__MINGW32__) + +static int +unixshell(char *p) +{ + static char *shell[] = {"sh", "bash", "csh", "tcsh", "sh32", "sh16", "ksh", NULL}; + char **shellp = shell, *s, *q; + + if (p == NULL) return (0); + s = p = strdup(p); + if ((q = strrchr(p, '\\')) != NULL) + p = q + 1; + if ((q = strrchr(p, '/')) != NULL) + p = q + 1; + if ((q = strchr(p, '.')) != NULL) + *q = '\0'; + strlwr(p); + do { + if (strcmp(*shellp, p) == 0) break; + } while (*++shellp); + free(s); + return(*shellp ? 1 : 0); +} + +static char * +slashify(char *p, char *s) +{ + if (unixshell(s)) + while (s = strchr(p, '\\')) *s = '/'; + else + while (s = strchr(p, '/')) *s = '\\'; + return(p); +} + +static char * +scriptify(const char *command) +{ + FILE *fp; + char *cmd, *name, *s, *p; + int i; + + if((name = tempnam(".", "pip")) == NULL) return(NULL); + p = getenv("COMSPEC"); s = getenv("SHELL"); + cmd = malloc(strlen(name) + (s ? strlen(s) : 0) + 9); *cmd = '\0'; + if (s) { + slashify(strcpy(cmd, s), p); + p = s; + } + slashify(name, p); + if (! (i = unixshell(p))) { + char *p = (char *) realloc(name, strlen(name) + 5); + if (p == NULL) { + free(cmd); + return NULL; + } + name = p; + strcat(name, ".bat"); + } + if (s) sprintf(cmd + strlen(cmd), " %cc ", unixshell(s) ? '-' : '/'); + strcpy(p = cmd + strlen(cmd), name); free(name); + + if ((fp = fopen(p, i ? "wb" : "w")) != NULL) { + if (! i) fputs("@echo off\n", fp); + i = strlen(command); + if ((fwrite(command, 1, i, fp) < i) || (fputc('\n', fp) == EOF)) { + free(cmd); + cmd = NULL; + } + } else { + free(cmd); + cmd = NULL; + } + if (fp) fclose(fp); + return(cmd); +} + +static void +unlink_and_free(char *cmd) +{ + char *s; + + if (s = strrchr(cmd, ' ')) + s++; + else + s = cmd; + unlink(s); free(cmd); +} + +int +os_system(const char *cmd) +{ + char *s; + int i; + char *cmd1; + + if ((cmd1 = scriptify(cmd)) == NULL) return(1); + if (s = getenv("SHELL")) + i = spawnlp(P_WAIT, s, s, cmd1 + strlen(s), NULL); + else + i = system(cmd1); + unlink_and_free(cmd1); + return(i); +} +#else /* !__MINGW32__ */ +#define os_system(cmd) system(cmd) +#endif + + +FILE * +os_popen(const char *command, char *mode ) +{ + FILE *current; + char *name; + int cur; + char curmode[4]; +#if defined(__MINGW32__) + char *cmd; +#endif + + if (*mode != 'r' && *mode != 'w') + return NULL; + strncpy(curmode, mode, 3); curmode[3] = '\0'; + +#if defined(__MINGW32__) + current = popen(cmd = scriptify(command), mode); + cur = fileno(current); + strcpy(pipes[cur].pmode, curmode); + pipes[cur].command = cmd; + return(current); +#endif + + /* + ** get a name to use. + */ + if((name = tempnam(".","pip"))==NULL) + return NULL; + /* + ** If we're reading, just call system to get a file filled with + ** output. + */ + if (*curmode == 'r') { + FILE *fp; + if ((cur = dup(fileno(stdout))) == -1) + return NULL; + *curmode = 'w'; + if ((current = freopen(name, curmode, stdout)) == NULL) + return NULL; + os_system(command); + if (dup2(cur, fileno(stdout)) == -1) + return NULL; + close(cur); + *curmode = 'r'; + if ((current = fopen(name, curmode)) == NULL) + return NULL; + } else { + if ((current = fopen(name, curmode)) == NULL) + return NULL; + } + cur = fileno(current); + pipes[cur].name = name; + strcpy(pipes[cur].pmode, curmode); + pipes[cur].command = strdup(command); + return current; +} + +int +os_pclose( FILE * current) +{ + int cur = fileno(current); + int fd, rval; + +#if defined(__MINGW32__) + rval = pclose(current); + *pipes[cur].pmode = '\0'; + unlink_and_free(pipes[cur].command); + return rval; +#endif + + /* + ** check for an open file. + */ + switch (*pipes[cur].pmode) { + case 'r': + /* + ** input pipes are just files we're done with. + */ + rval = fclose(current); + unlink(pipes[cur].name); + break; + case 'w': + /* + ** output pipes are temporary files we have + ** to cram down the throats of programs. + */ + fclose(current); + rval = -1; + if ((fd = dup(fileno(stdin))) != -1) { + char *mode = pipes[cur].pmode; *mode = 'r'; + if (current = freopen(pipes[cur].name, mode, stdin)) { + rval = os_system(pipes[cur].command); + fclose(current); + if (dup2(fd, fileno(stdin)) == -1) rval = -1; + close(fd); + } + } + unlink(pipes[cur].name); + break; + default: + return -1; + } + /* + ** clean up current pipe. + */ + *pipes[cur].pmode = '\0'; + free(pipes[cur].name); + free(pipes[cur].command); + return rval; +} diff --git a/pc/popen.h b/pc/popen.h new file mode 100644 index 0000000..9a04299 --- /dev/null +++ b/pc/popen.h @@ -0,0 +1,17 @@ +/* +** popen.h -- prototypes for pipe functions +*/ +#if !defined (__DJGPP__) +# if defined (popen) +# undef popen +# undef pclose +# endif +# define popen(c, m) os_popen(c, m) +# define pclose(f) os_pclose(f) + extern FILE *os_popen( const char *, const char * ); + extern int os_pclose( FILE * ); +# ifdef __MINGW32__ +# define system(c) os_system(c) + extern int os_system( const char * ); +# endif /* __MINGW32__ */ +#endif /* !__DJGPP__ */ diff --git a/pc/testoutcmp.awk b/pc/testoutcmp.awk new file mode 100644 index 0000000..33dcaa3 --- /dev/null +++ b/pc/testoutcmp.awk @@ -0,0 +1,57 @@ +# cmp replacement program for PC where the error messages aren't +# exactly the same. should run even on old awk +# +# Copyright (C) 2011 the Free Software Foundation, Inc. +# +# This file is part of GAWK, the GNU implementation of the +# AWK Programming Language. +# +# GAWK is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +{ + if (FNR == NR) + file = 0 + else + file = 1 + gsub(/\r/, "", $0) + lines[file, FNR] = $0 +} + +END { + if (NR/2 != FNR) { + printf("testoutcmp: warning: files are not of equal length!\n") > "/dev/stderr" + exit 1 + } + + for (i = 1; i <= FNR; i++) { + good = lines[0, i] + actual = lines[1, i] + if (good == actual) + continue + + l = length(good) + if (substr(good, l, 1) == ")") + l-- + if (substr(good, 1, l) == substr(actual, 1, l)) + continue + else { + printf("%s and %s are not equal\n", ARGV[1], + ARGV[2]) > "/dev/stderr" + exit 1 + } + } + + exit 0 +} diff --git a/po/ChangeLog b/po/ChangeLog new file mode 100644 index 0000000..d17674d --- /dev/null +++ b/po/ChangeLog @@ -0,0 +1,21 @@ +2012-03-28 Arnold D. Robbins + + * 4.0.1: Release tar ball made. + +2011-07-17 Arnold D. Robbins + + * Makefile.in.in (dist2): Remove README from list of files checked for + manually. Added in main directory's Makefile.am EXTRA_DIST, per + advice from Bruno Haible. + +2011-06-23 Arnold D. Robbins + + * Makefile.in.in (dist2): Add README to list of files checked for + manually. + * 4.0.0: Remake the tar ball. + +2011-06-23 Arnold D. Robbins + + * ChangeLog.0: Rotated ChangeLog into this file. + * ChangeLog: Created anew for gawk 4.0.0 and on. + * 4.0.0: Release tar ball made. diff --git a/po/ChangeLog.0 b/po/ChangeLog.0 new file mode 100644 index 0000000..3c95100 --- /dev/null +++ b/po/ChangeLog.0 @@ -0,0 +1,127 @@ +Wed Jun 8 22:14:07 2011 Arnold D. Robbins + + * sv.po, sv.gmo: Updated! + * LINGUAS: Updated and sorted. + +Thu May 19 17:10:07 2011 Arnold D. Robbins + + * LINGUAS: Updated and sorted. + +Wed May 18 21:45:31 2011 Arnold D. Robbins + + * LINGUAS: Updated and sorted. + +Sun May 1 20:32:10 2011 Arnold D. Robbins + + * LINGUAS: Removed all files not updated recently; some have been + abandoned all the way back to 2002. + * README: New file. + +Mon Mar 21 20:40:28 2011 Arnold D. Robbins + + * LINGUAS: Sorted. + +Fri Mar 18 12:01:21 2011 Arnold D. Robbins + + * fi.po, fi.gmo: New files. + * LINGUAS: Updated. + +2010-12-22 gettextize + + * Makefile.in.in: Upgrade to gettext-0.18.1. + * Rules-quot: Upgrade to gettext-0.18.1. + +Thu May 6 20:55:14 2010 Arnold D. Robbins + + * Release 3.1.8: Release tar file made. + +Tue Jul 21 22:28:56 2009 Arnold D. Robbins + + * Release 3.1.7: Release tar file made. + +Mon Jun 8 23:12:09 2009 Arnold D. Robbins + + * Makefile.in.in: Reinstate change of 2008.12.18. + +2009-06-08 gettextize + + * Makefile.in.in: Upgrade to gettext-0.17. + +Thu Dec 18 20:36:34 2008 Arnold D. Robbins + + * Makefile.in.in (install-dvi, install-ps): New targets that + do nothing, per email from "Stoddard, Isaac A" + . + +Mon Oct 22 08:49:05 2007 Arnold D. Robbins + + * Release 3.1.6: Release tar file made. + +Mon Sep 10 12:41:34 2007 Arnold D. Robbins + + * All .po files: Updated to GPL 3. + +2007-01-08 gettextize + + * Makefile.in.in: Upgrade to gettext-0.16.1. + * Makevar.template: New file, copied in from gettext-0.16.1. + +Tue Jul 26 21:46:16 2005 Arnold D. Robbins + + * Release 3.1.5: Release tar file made. + +Mon Aug 2 12:18:15 2004 Arnold D. Robbins + + * Release 3.1.4: Release tar file made. + +2004-02-19 gettextize + + * Makefile.in.in: Upgrade to gettext-0.14.1. + * Rules-quot: Upgrade to gettext-0.14.1. + +2004-01-16 gettextize + + * Makefile.in.in: Upgrade to gettext-0.13.1. + +Mon Jul 7 11:01:43 2003 Arnold D. Robbins + + * Release 3.1.3: Release tar file made. + +2003-06-16 gettextize + + * Makefile.in.in: Upgrade to gettext-0.12.1. + * Rules-quot: New file, from gettext-0.12.1. + * boldquot.sed: New file, from gettext-0.12.1. + * en@boldquot.header: New file, from gettext-0.12.1. + * en@quot.header: New file, from gettext-0.12.1. + * insert-header.sin: New file, from gettext-0.12.1. + * quot.sed: New file, from gettext-0.12.1. + +Wed Mar 19 14:10:31 2003 Arnold D. Robbins + + This time for sure. + -- Bullwinkle + + * Release 3.1.2: Release tar file made. + +Mon Dec 2 11:49:59 2002 Arnold D. Robbins + + * Rules-quot, en@quot.reader, en@boldquot.reader: removed. + +Thu Sep 19 11:00:00 2002 Arnold D. Robbins + + * Updated to gettext 0.11.5. + +Mon Jun 17 18:26:23 2002 Arnold D. Robbins + + * POTFILES.in: Updated with list of new regex files. + +Wed May 1 16:41:32 2002 Arnold D. Robbins + + * Release 3.1.1: Release tar file made. + +2002-04-09 gettextize + + * Makefile.in.in: Upgrade to gettext-0.11.1. + * remove-potcdate.sin: New file, from gettext-0.11.1. + diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 0000000..1e55e05 --- /dev/null +++ b/po/LINGUAS @@ -0,0 +1,10 @@ +da +de +es +fi +fr +it +ja +nl +pl +sv diff --git a/po/Makefile.in.in b/po/Makefile.in.in new file mode 100644 index 0000000..83d8838 --- /dev/null +++ b/po/Makefile.in.in @@ -0,0 +1,444 @@ +# Makefile for PO directory in any package using GNU gettext. +# Copyright (C) 1995-1997, 2000-2007, 2009-2010 by Ulrich Drepper +# +# This file can be copied and used freely without restrictions. It can +# be used in projects which are not available under the GNU General Public +# License but which still want to provide support for the GNU gettext +# functionality. +# Please note that the actual code of GNU gettext is covered by the GNU +# General Public License and is *not* in the public domain. +# +# Origin: gettext-0.18 +GETTEXT_MACRO_VERSION = 0.18 + +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ + +SHELL = /bin/sh +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +datarootdir = @datarootdir@ +datadir = @datadir@ +localedir = @localedir@ +gettextsrcdir = $(datadir)/gettext/po + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ + +# We use $(mkdir_p). +# In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as +# "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions, +# @install_sh@ does not start with $(SHELL), so we add it. +# In automake >= 1.10, @mkdir_p@ is derived from ${MKDIR_P}, which is defined +# either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake +# versions, $(mkinstalldirs) and $(install_sh) are unused. +mkinstalldirs = $(SHELL) @install_sh@ -d +install_sh = $(SHELL) @install_sh@ +MKDIR_P = @MKDIR_P@ +mkdir_p = @mkdir_p@ + +GMSGFMT_ = @GMSGFMT@ +GMSGFMT_no = @GMSGFMT@ +GMSGFMT_yes = @GMSGFMT_015@ +GMSGFMT = $(GMSGFMT_$(USE_MSGCTXT)) +MSGFMT_ = @MSGFMT@ +MSGFMT_no = @MSGFMT@ +MSGFMT_yes = @MSGFMT_015@ +MSGFMT = $(MSGFMT_$(USE_MSGCTXT)) +XGETTEXT_ = @XGETTEXT@ +XGETTEXT_no = @XGETTEXT@ +XGETTEXT_yes = @XGETTEXT_015@ +XGETTEXT = $(XGETTEXT_$(USE_MSGCTXT)) +MSGMERGE = msgmerge +MSGMERGE_UPDATE = @MSGMERGE@ --update +MSGINIT = msginit +MSGCONV = msgconv +MSGFILTER = msgfilter + +POFILES = @POFILES@ +GMOFILES = @GMOFILES@ +UPDATEPOFILES = @UPDATEPOFILES@ +DUMMYPOFILES = @DUMMYPOFILES@ +DISTFILES.common = Makefile.in.in remove-potcdate.sin \ +$(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3) +DISTFILES = $(DISTFILES.common) Makevars POTFILES.in \ +$(POFILES) $(GMOFILES) \ +$(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3) + +POTFILES = \ + +CATALOGS = @CATALOGS@ + +# Makevars gets inserted here. (Don't remove this line!) + +.SUFFIXES: +.SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update + +.po.mo: + @echo "$(MSGFMT) -c -o $@ $<"; \ + $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@ + +.po.gmo: + @lang=`echo $* | sed -e 's,.*/,,'`; \ + test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ + echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o $${lang}.gmo $${lang}.po"; \ + cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo + +.sin.sed: + sed -e '/^#/d' $< > t-$@ + mv t-$@ $@ + + +all: check-macro-version all-@USE_NLS@ + +all-yes: stamp-po +all-no: + +# Ensure that the gettext macros and this Makefile.in.in are in sync. +check-macro-version: + @test "$(GETTEXT_MACRO_VERSION)" = "@GETTEXT_MACRO_VERSION@" \ + || { echo "*** error: gettext infrastructure mismatch: using a Makefile.in.in from gettext version $(GETTEXT_MACRO_VERSION) but the autoconf macros are from gettext version @GETTEXT_MACRO_VERSION@" 1>&2; \ + exit 1; \ + } + +# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no +# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because +# we don't want to bother translators with empty POT files). We assume that +# LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty. +# In this case, stamp-po is a nop (i.e. a phony target). + +# stamp-po is a timestamp denoting the last time at which the CATALOGS have +# been loosely updated. Its purpose is that when a developer or translator +# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS, +# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent +# invocations of "make" will do nothing. This timestamp would not be necessary +# if updating the $(CATALOGS) would always touch them; however, the rule for +# $(POFILES) has been designed to not touch files that don't need to be +# changed. +stamp-po: $(srcdir)/$(DOMAIN).pot + test ! -f $(srcdir)/$(DOMAIN).pot || \ + test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES) + @test ! -f $(srcdir)/$(DOMAIN).pot || { \ + echo "touch stamp-po" && \ + echo timestamp > stamp-poT && \ + mv stamp-poT stamp-po; \ + } + +# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update', +# otherwise packages like GCC can not be built if only parts of the source +# have been downloaded. + +# This target rebuilds $(DOMAIN).pot; it is an expensive operation. +# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed. +$(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed + if LC_ALL=C grep 'GNU @PACKAGE@' $(top_srcdir)/* 2>/dev/null | grep -v 'libtool:' >/dev/null; then \ + package_gnu='GNU '; \ + else \ + package_gnu=''; \ + fi; \ + if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \ + msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \ + else \ + msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \ + fi; \ + case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \ + $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ + --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \ + --files-from=$(srcdir)/POTFILES.in \ + --copyright-holder='$(COPYRIGHT_HOLDER)' \ + --msgid-bugs-address="$$msgid_bugs_address" \ + ;; \ + *) \ + $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ + --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) @XGETTEXT_EXTRA_OPTIONS@ \ + --files-from=$(srcdir)/POTFILES.in \ + --copyright-holder='$(COPYRIGHT_HOLDER)' \ + --package-name="$${package_gnu}@PACKAGE@" \ + --package-version='@VERSION@' \ + --msgid-bugs-address="$$msgid_bugs_address" \ + ;; \ + esac + test ! -f $(DOMAIN).po || { \ + if test -f $(srcdir)/$(DOMAIN).pot; then \ + sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \ + sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \ + if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \ + rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \ + else \ + rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \ + mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ + fi; \ + else \ + mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ + fi; \ + } + +# This rule has no dependencies: we don't need to update $(DOMAIN).pot at +# every "make" invocation, only create it when it is missing. +# Only "make $(DOMAIN).pot-update" or "make dist" will force an update. +$(srcdir)/$(DOMAIN).pot: + $(MAKE) $(DOMAIN).pot-update + +# This target rebuilds a PO file if $(DOMAIN).pot has changed. +# Note that a PO file is not touched if it doesn't need to be changed. +$(POFILES): $(srcdir)/$(DOMAIN).pot + @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \ + if test -f "$(srcdir)/$${lang}.po"; then \ + test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ + echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot"; \ + cd $(srcdir) \ + && { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \ + $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $${lang}.po $(DOMAIN).pot;; \ + *) \ + $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot;; \ + esac; \ + }; \ + else \ + $(MAKE) $${lang}.po-create; \ + fi + + +install: install-exec install-data +install-exec: +install-data: install-data-@USE_NLS@ + if test "$(PACKAGE)" = "gettext-tools"; then \ + $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \ + for file in $(DISTFILES.common) Makevars.template; do \ + $(INSTALL_DATA) $(srcdir)/$$file \ + $(DESTDIR)$(gettextsrcdir)/$$file; \ + done; \ + for file in Makevars; do \ + rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ + done; \ + else \ + : ; \ + fi +install-data-no: all +install-data-yes: all + @catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ + dir=$(localedir)/$$lang/LC_MESSAGES; \ + $(mkdir_p) $(DESTDIR)$$dir; \ + if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \ + $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \ + echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \ + for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ + if test -n "$$lc"; then \ + if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ + link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ + mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ + for file in *; do \ + if test -f $$file; then \ + ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ + fi; \ + done); \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + else \ + if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ + :; \ + else \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + fi; \ + fi; \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ + ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ + ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ + cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ + echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \ + fi; \ + done; \ + done + +install-strip: install + +installdirs: installdirs-exec installdirs-data +installdirs-exec: +installdirs-data: installdirs-data-@USE_NLS@ + if test "$(PACKAGE)" = "gettext-tools"; then \ + $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \ + else \ + : ; \ + fi +installdirs-data-no: +installdirs-data-yes: + @catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ + dir=$(localedir)/$$lang/LC_MESSAGES; \ + $(mkdir_p) $(DESTDIR)$$dir; \ + for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ + if test -n "$$lc"; then \ + if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ + link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ + mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ + for file in *; do \ + if test -f $$file; then \ + ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ + fi; \ + done); \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + else \ + if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ + :; \ + else \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + fi; \ + fi; \ + fi; \ + done; \ + done + +# Define this as empty until I found a useful application. +installcheck: + +uninstall: uninstall-exec uninstall-data +uninstall-exec: +uninstall-data: uninstall-data-@USE_NLS@ + if test "$(PACKAGE)" = "gettext-tools"; then \ + for file in $(DISTFILES.common) Makevars.template; do \ + rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ + done; \ + else \ + : ; \ + fi +uninstall-data-no: +uninstall-data-yes: + catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ + for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ + done; \ + done + +check: all + +info dvi ps pdf html tags TAGS ctags CTAGS ID: + +mostlyclean: + rm -f remove-potcdate.sed + rm -f stamp-poT + rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po + rm -fr *.o + +clean: mostlyclean + +distclean: clean + rm -f Makefile Makefile.in POTFILES *.mo + +maintainer-clean: distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + rm -f stamp-po $(GMOFILES) + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) +dist distdir: + $(MAKE) update-po + @$(MAKE) dist2 +# This is a separate target because 'update-po' must be executed before. +dist2: stamp-po $(DISTFILES) + dists="$(DISTFILES)"; \ + if test "$(PACKAGE)" = "gettext-tools"; then \ + dists="$$dists Makevars.template"; \ + fi; \ + if test -f $(srcdir)/$(DOMAIN).pot; then \ + dists="$$dists $(DOMAIN).pot stamp-po"; \ + fi; \ + if test -f $(srcdir)/ChangeLog; then \ + dists="$$dists ChangeLog"; \ + fi; \ + for i in 0 1 2 3 4 5 6 7 8 9; do \ + if test -f $(srcdir)/ChangeLog.$$i; then \ + dists="$$dists ChangeLog.$$i"; \ + fi; \ + done; \ + if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \ + for file in $$dists; do \ + if test -f $$file; then \ + cp -p $$file $(distdir) || exit 1; \ + else \ + cp -p $(srcdir)/$$file $(distdir) || exit 1; \ + fi; \ + done + +update-po: Makefile + $(MAKE) $(DOMAIN).pot-update + test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES) + $(MAKE) update-gmo + +# General rule for creating PO files. + +.nop.po-create: + @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \ + echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \ + exit 1 + +# General rule for updating PO files. + +.nop.po-update: + @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \ + if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \ + tmpdir=`pwd`; \ + echo "$$lang:"; \ + test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ + echo "$${cdcmd}$(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \ + cd $(srcdir); \ + if { case `$(MSGMERGE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \ + '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \ + $(MSGMERGE) $(MSGMERGE_OPTIONS) -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \ + *) \ + $(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \ + esac; \ + }; then \ + if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ + rm -f $$tmpdir/$$lang.new.po; \ + else \ + if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ + :; \ + else \ + echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ + exit 1; \ + fi; \ + fi; \ + else \ + echo "msgmerge for $$lang.po failed!" 1>&2; \ + rm -f $$tmpdir/$$lang.new.po; \ + fi + +$(DUMMYPOFILES): + +update-gmo: Makefile $(GMOFILES) + @: + +# Recreate Makefile by invoking config.status. Explicitly invoke the shell, +# because execution permission bits may not work on the current file system. +# Use @SHELL@, which is the shell determined by autoconf for the use by its +# scripts, not $(SHELL) which is hardwired to /bin/sh and may be deficient. +Makefile: Makefile.in.in Makevars $(top_builddir)/config.status @POMAKEFILEDEPS@ + cd $(top_builddir) \ + && @SHELL@ ./config.status $(subdir)/$@.in po-directories + +force: + +# Tell versions [3.59,3.63) of GNU make not to export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/po/Makevars b/po/Makevars new file mode 100644 index 0000000..c5a271d --- /dev/null +++ b/po/Makevars @@ -0,0 +1,41 @@ +# Makefile variables for PO directory in any package using GNU gettext. + +# Usually the message domain is the same as the package name. +DOMAIN = $(PACKAGE) + +# These two variables depend on the location of this directory. +subdir = po +top_builddir = .. + +# These options get passed to xgettext. +XGETTEXT_OPTIONS = --keyword=_ --keyword=N_ + +# This is the copyright holder that gets inserted into the header of the +# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding +# package. (Note that the msgstr strings, extracted from the package's +# sources, belong to the copyright holder of the package.) Translators are +# expected to transfer the copyright for their translations to this person +# or entity, or to disclaim their copyright. The empty string stands for +# the public domain; in this case the translators are expected to disclaim +# their copyright. +COPYRIGHT_HOLDER = Free Software Foundation, Inc. + +# This is the email address or URL to which the translators shall report +# bugs in the untranslated strings: +# - Strings which are not entire sentences, see the maintainer guidelines +# in the GNU gettext documentation, section 'Preparing Strings'. +# - Strings which use unclear terms or require additional context to be +# understood. +# - Strings which make invalid assumptions about notation of date, time or +# money. +# - Pluralisation problems. +# - Incorrect English spelling. +# - Incorrect formatting. +# It can be your email address, or a mailing list address where translators +# can write to without being subscribed, or the URL of a web page through +# which the translators can contact you. +MSGID_BUGS_ADDRESS = arnold@skeeve.com + +# This is the list of locale categories, beyond LC_MESSAGES, for which the +# message catalogs shall be used. It is usually empty. +EXTRA_LOCALE_CATEGORIES = diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 0000000..807df33 --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1,24 @@ +# List of source files containing translatable strings. +# Copyright (C) 1999, 2002 Free Software Foundation, Inc. + +array.c +awkgram.c +builtin.c +eval.c +ext.c +field.c +gawkmisc.c +getopt.c +getopt1.c +io.c +main.c +msg.c +node.c +posix/gawkmisc.c +profile.c +random.c +re.c +regcomp.c +regex_internal.c +regexec.c +replace.c diff --git a/po/README b/po/README new file mode 100644 index 0000000..dbe9ebd --- /dev/null +++ b/po/README @@ -0,0 +1,15 @@ +Sun May 1 20:34:31 IDT 2011 +============================ + +For gawk 4.0, I have removed .po files that are not being maintained +from the distribution, since the code base has changed so much. + +The original files are still available from the gawk git repository +and/or from the translation project. If your language used to be supported +and no longer is, please consider updating the translation so that it +can be restored to the distribution. + +Thanks! + +Arnold Robbins +arnold@skeeve.com diff --git a/po/Rules-quot b/po/Rules-quot new file mode 100644 index 0000000..af52487 --- /dev/null +++ b/po/Rules-quot @@ -0,0 +1,47 @@ +# Special Makefile rules for English message catalogs with quotation marks. + +DISTFILES.common.extra1 = quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot + +.SUFFIXES: .insert-header .po-update-en + +en@quot.po-create: + $(MAKE) en@quot.po-update +en@boldquot.po-create: + $(MAKE) en@boldquot.po-update + +en@quot.po-update: en@quot.po-update-en +en@boldquot.po-update: en@boldquot.po-update-en + +.insert-header.po-update-en: + @lang=`echo $@ | sed -e 's/\.po-update-en$$//'`; \ + if test "$(PACKAGE)" = "gettext"; then PATH=`pwd`/../src:$$PATH; GETTEXTLIBDIR=`cd $(top_srcdir)/src && pwd`; export GETTEXTLIBDIR; fi; \ + tmpdir=`pwd`; \ + echo "$$lang:"; \ + ll=`echo $$lang | sed -e 's/@.*//'`; \ + LC_ALL=C; export LC_ALL; \ + cd $(srcdir); \ + if $(MSGINIT) -i $(DOMAIN).pot --no-translator -l $$lang -o - 2>/dev/null | sed -f $$tmpdir/$$lang.insert-header | $(MSGCONV) -t UTF-8 | $(MSGFILTER) sed -f `echo $$lang | sed -e 's/.*@//'`.sed 2>/dev/null > $$tmpdir/$$lang.new.po; then \ + if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ + rm -f $$tmpdir/$$lang.new.po; \ + else \ + if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ + :; \ + else \ + echo "creation of $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ + exit 1; \ + fi; \ + fi; \ + else \ + echo "creation of $$lang.po failed!" 1>&2; \ + rm -f $$tmpdir/$$lang.new.po; \ + fi + +en@quot.insert-header: insert-header.sin + sed -e '/^#/d' -e 's/HEADER/en@quot.header/g' $(srcdir)/insert-header.sin > en@quot.insert-header + +en@boldquot.insert-header: insert-header.sin + sed -e '/^#/d' -e 's/HEADER/en@boldquot.header/g' $(srcdir)/insert-header.sin > en@boldquot.insert-header + +mostlyclean: mostlyclean-quot +mostlyclean-quot: + rm -f *.insert-header diff --git a/po/boldquot.sed b/po/boldquot.sed new file mode 100644 index 0000000..4b937aa --- /dev/null +++ b/po/boldquot.sed @@ -0,0 +1,10 @@ +s/"\([^"]*\)"/“\1”/g +s/`\([^`']*\)'/‘\1’/g +s/ '\([^`']*\)' / ‘\1’ /g +s/ '\([^`']*\)'$/ ‘\1’/g +s/^'\([^`']*\)' /‘\1’ /g +s/“”/""/g +s/“/“/g +s/”/”/g +s/‘/‘/g +s/’/’/g diff --git a/po/da.gmo b/po/da.gmo new file mode 100644 index 0000000000000000000000000000000000000000..29775fa1aa7e908e67b76b84f2a7d1cba6437bf2 GIT binary patch literal 48955 zcmd6wd7NZbdH1iz2(*BJvTv7Rnwnv{dN$UEf!T+_*_;_b9ALV->vnfdS64N)%uE9! zsNf1}5JfafL{u;;nxMEQX!Ld0s4*rcMuRhIG@6%JbWB{{@9#P1-nzAQ_mKRN`pli* zU7mC9S)TJe&w0+dPk-;2XWSj|``FWh;1uv@M+Cw1pB@CCI9Yf3^#;LFz|+9P!DB$t zoemxYUJM=&ZU#>SNB#5L{r&sFqq+Za@JR40;7Q;=fy(#S9uGY$2=vMmLFIccsP|k3 zJ{OF@Gr=3c1>oC2z3+>l^7#o!(S!d4PXrImxb$;CrN0zZIktmJHv+00w}BKPxDT8H zKL;xR<@18ze6R>!489Yb1O5Qag3p*A1jm6(zyWYQxDC0K#CB&7Sww_0*2r|kXHxKq;O;rECi`)a5bp=w}2|ggP`j3L-2I4 zhs=d%gUau6Q2Fl#PX+G-)y|&+NfLY)oChx)0`aw6FY0&gekZ87Wx4gUHi;7_@J2o!(4afvJ6gC0Nb@hjlrJpUJP z1^6?M{dDeaTu*`*fWHFI1s9&<+9d+jo;QKwgL^^M^Q)lB|07WK=^>HQ_3>W_4uPuw zOF`A|9ia069H?}E0G02Y^IZDnpz1pWhTw}pSR;5FsQP~a6hHh1RQfqEF-;V#0qLq> zHzGAz7K#WfL{e+mEcF9%KzL89bYU3mG2ht z7;ulj|0+=Re>X^z244V48vGVizURWc;_K@`-G7D0$3T_uKS7n_)Qf_EB*6-gH-ftV z2q?b$2T%u zpxW!1D_uPngL>ZUuww9La1Ho1Q1r*Ha``U@d$=z7>nTw6dN-(c`$tgiaoB2? z-zDH2u7~~g?H=C?p2_{MgQtPN1XZu+@Y3VK0Z{pE1?Pgdf~wcMK;`!ssPsSd*N3ik z{l5TIe_jQuy>0;|CmsgX-roV0{#W2~@WgelonGkiCQ#4c1|9-F28yq~0EXa`pq?Lh znQNyDJ(j@?_a6Yo*IxnWfzMp;_-G->&p=DYouJ0uhd}Y|FF@tryVceE z8nDLoOF-5C*C0g;!fmd6WpF;%9|6^_KLGo{!?(MBzR=?}p!o2`pz8Zh@D%WG{Php~ z^QT?m`u8kQe6r5tF7RBg?*I{5!Dm2*V(0Ag8RU8z!P8K_+b+$zI-vL`o9}g`mcj3&y!#lTyV9cyV~Qepx*x= zsP}&pd=B^<@Obcu7dpAr3+jDWfy)0i;3Du5@B(l@sD3|vhs%F0xR~n_xCFcpRR4Vw zRJo42#^rM^sP|t7ivAVg`QXPu)#nLN?>p&QmwuJUTR^qbCqbqEt;e&jbJtry_1_KP za`0YI`F$6BF8D_~U3;DYGGv0wz$3vofU3v+pyitiEYX6f5-Sg*xdR_tb{9aJ~ z@)__#@Yfy}=NzAogKCF&fGY3bdHe&Yde0wn_jiEe&)Y!t+r!{R;C^rgIA_@LQ63ck zz7AABd=fkZ{5hy{9hG-{djU9y>nlLf?*&f;9{|q;{|cN7J`Sqfhei%pf_m>wpvvI=08ayZcR7Av4QgEM z0@Y6U`1>CR)viAPRj*^l-MBapJeupvLACcapz^)hKmQ=8d_D^*{g3_q6N~PC7F2(4 z0hfa>0oAXc0o5;mJb_LHPY0Fnd{E=-8gL$XH#i^s6!_57$R8Bn-c=5QXMyhkPY2%* z9s_>w}Hz4F7PDqeW22R9y}WSXHf0;3s7{&R9yS_fnVl& z3#j^^T6KD3oyXfi_0wm-CE$-hz5k?|Yv=Pp$(6mJ-up19=U)P!4gMHZ{SSb8?;&+p zo-@FOTrc%F4EAz;7q|%gD5!e>8z{a#e7AeP6x2Al+F#!cUe5J9!7TU-P~+m%Jr2(W zmvX%kR6e(Y>c{thr-Gjc`@#L7=5xpHb@RDPrrdkp3LeMv$H3#k?|A$VkB8n61UtDO zf@-H*z!SiCdi*5#9In3&s-OQ26hA%lMyKbF0acErpwc}bR6pzjmERjc)%Q_QeEQG+ z{xffK?RhqMHuqP9s(%?g6#P?A^?euk1o#zD_5SM@x%zzHlVjvy`ai}8F(%@0jl5c2gQ%y1T)~T zK)vs@TOIulQ2E{hitg>;$>68KGr;eGePHksrw6j2uJfSU?e(DE_Xw!|{V5oNC%x3Q z<3*s#l?RpYD?z1yz~eXk^FM%U_qi`~{Jjwr-57W}csHnWJ_3f|w?OgBlm7bf+gy3G zp!jezxD0$LsD6G7RQ^8&*MrZ!-Qjhh+T}f<`tj?a`25!%SH9e(y8{&6he74{J#Ybd z=qnswoCBW8^-l0Y@TH)}*C#>c`*VMN>?>Wrt_9UUF9wy*2SAPc?}F!nN50DCy9U(# zNpKE$KX?lGIe-6g@KUaid$p_gl^$OOsy{vjsyzP=Dt+cPuAMITSOnExcY=D)r@_VG zlc4w{bBC)(9-Pnh-Jt6ES6~)=98`IazSHG<890yYU7+fH7pQjo7%2LG1$)7xUhC4G z2O7VEdf)xvM)3RK*oQpx*m!a1nUK>z%*p5^yfpQ=sbmHgF;M z7^rgmUr^;b@lRYmmV^CV=fPvayTEh62f;q@d!X9;S$8@5d7$#&;IFR-mEYa|{wF}y z=LewL>-aY~zFz^VJlBHik6S=J|Cq-gf-2vUcO$dF^FX!NGH?kv4qAOc)&DW@9PoFb z%DLo?L9i0s393Eb0jhnz2`YWho7}ir2C6--0~dgIg39M(;PK!uK-KS%dmQ$Ghj9IT zQ02QC6#cEB%J*T9KlFIao1I)+4(j=>p!)Fx;5zUh!7bpNdtHB5!3|tL45~c8169BI zZ*lX&2)vx@hd{meNl@iD`>l?Twt`B(7d#I9EckrzpFp)^|DU>i&jl~!ItS*#w}4B* z;BC%+IR})y+YPP<@A3GrpvG6<+ueMu2&&&c4qgK81DAty?{j<_fvWGDz+1pigR0l6 zKf^}=mO<6$)1dM>;vH_hoDZrW2f;bu9pGu;!~Xhf;K^J+0Uiq;dB4+Vb3wK9O7L`W z5)8rDfpfqQg5ra3fy=>Xz0>u>22k&N1E}&n28!Dk1O8i^1l;2oBQ7a=YxOn*Yn@++GRVa zbhm4l)`c@rppz8@4Hd>T|g>;pA!&wRwyV*u>sdI($(zQW@-z?EE| z@?rO$ouJy~)u8(8FF?KL=iprM*pIkzFaYX$2ly=T7Et5pHK6MM9`FqCN1)o_ut!}z z&j*)tT>_Q<1K?KhTcG$b^HGQEK(+5EsP=j~nEKknMS4^+K&fTDY;zyCo{^xp^7zbAge&0|)BM{#`>sB(>g3&B@_%J)%FeDFUd3?;*RSMwrhmRWMfYs({~wO?Qui+9{2ScUd;Xb2zaq!|+`pWo$bq=B z-{T%%&AsRO^BX+AmV58xID_jY;ETaua@08<k7f)m z<9I{revR{YafIA|75H?H{ha@dLw%v&>p9Nh{#p)LG`NpriX;9-oIHzX;(77ud;NpI z1#jm*-5zWKPX+rx{q}(OaD*JM;ZXlw!m)z$5sos4es2b!3*OD~9L}%cxQ_GZbKJ~v z7{`+ww{slIvkSp{L0Hp%zvKV^@aMk^;`~239^g3M(>;T8jg1`FZv+RyKLM}ccp1lW9R1uI2Hyyt1Tx(1cLLWV zoE-taokPE69?u4U&b7w1e*eYs7VcdHN`{`tv4dk5NBmpB^Otk{kQi;Sjt4o;gl3rI-~F?9az4eeo9nCnJ;4h(hB&V0&{#$!n~$Ult$x>eyp8kw z{Q1kkH*-C~@lPD5`}@a%ujjakBhUTK;QKiwqfiaO&78lNLo#eT$E!HTIZoyn<^DO~ zLQpdG3mmWDSi|*BP`_=QpT%(vhkifhkephg3x4C=p9J5^@nep6alF9Oa+>^B`m~8`VMdf$B~@BgyTz` zzZH}W9Ru~d3jA}98~yd0JYMWkG;=uSr>-B?O@9BtaSZp*wJZ1EE>Cx_zxO9xzlbC9 z_siVh!TE2%wVvip;2-&O!AU&73cS(Zdja?~pZ?Fl4|2VjCO>!0l1=5PZ>NiThvWd@J~Na4*M~IsTF3I~+sY zznbGUoWG9a7LFr1(!Z@-9M6$~?*D>+1bz#A0L*}EI1cArzw^PHzz>2I@Y5WpaTK^N zfh)lp_#=)i=c~c=FXu0|^XyMKzn|l?98cGM?tP5odz_vIJ_kIO<3$`3T)zj@?=a5a z2X5hbi1U|&o51tIA8@>z^XG9a=ZJsr=H#Uu8&dZcaNWc8_rdh9my4hH8@KTMRF1d! z>%Zju#T>8Xh<|r*zL|?_!Sx)U<9rcEmE&JHg2T=Xd#mA4u{=CJuR6b{M>n?Ci&1hh zn%grTPFBhzg<{kf4p*XFEy|My%IvDc4m&KH9WGB!RSKhHHQibhiqP&yd!ylHy3+l% z;Yii)jufI|K3k0@bCq1JTv;|^Ic*4cjO1#$;L9maB!mBG}p}%y4;PB3H^M<=JMGRc;NHjrK~ru{)|% z3+0j$Ulo?hRf;rP$f;1tg`QolJJg^W<)fkcsBR5e`r$FEHC!W?Y_6IenyN)syl2gN-MLC3H&l$O)Ljom6NMStezcOC$kw90wG6MVmg|+_ zXj$`p(T=E_MqTq~v%+QZ4Lu&UGK@y0>}1)xYRqnoMa4-yF4&hLbtWv7!a*@|f1xx|&h&+Q#tOq@VWHYnjoe!Yw_5T-X*AqYDbooP)eznY zljOCrh~`x#^Py*we#+OICl|7(W(CSs4Pnors1lY(!dzt(RxQ=4;Yhi{fC(69{2T18 zW(LCHa=n1L zR4rv{;hu73T%DpmA;$r0m88YOS~(od?#@^l)ODUy>QP2*IiYqZO|DYOP3^2iBchi; z(oJiUwvt5?leMXEUa4Lz&UbYF&J9te?C->#D0xEDWV2z0B0Fl@BWWCW$5TNvAPx$g3}WmYuRv^Y$XdXF=BJg=&ofIEoN}MRP@swqg#R zW}s=jRqI35TA^02MR2+JH;hI`9LI_+Vd0%s3K=egPy0OcBsW}1(shYT?|OKe=hmq` zL8dx|Y?^>WV@YNsNDRRkfs4Ja(Xfbu?An?!jj_0f^4e|UVu~r!Et|Kke?h3Rk)4Rk zQLpAkBL+%#V#i43+OSkAWrF2}(r~ekm{WJ!Uo#2xu8T_6*<0#E#lmp7p)gGK5MjJmcdBDF?$A_^$h#HvqA)7(yb{apaB2Jk zpIcv8uJp{y)l^_aw~hb#lyVCGk~B=o`!#!W6O*Xufu6(6Fv{Er-%W%ImW6W{hcCJ) zT(fC)c%xGk_TWYE147bMXV(sdq%b{V2{Pfrs5ZQC5{3#?(zW}nBrQ7w>$6|G1Eg;A+d^$x@vqlt25isWNC z)Ev#UX)Q)TO=GGQjZ$aSo(+UxQ<*YTPMz?s-326Ir`K@ba!VwqNqZ-w(P zTp6a7Ji2X5C8EN0`ieGG_jYK$t!>Ru%aubEM6hj4W>uVX$Co8ChY3Wmtz4;0^&#A( z=f_K^!!Zu}!3;!Nyk@c}*j67Nrl*7LtF|m$zonV$k!BRPneSU=O+%!Zbd>-Yqn!{O z3}j@=o&t6xoXNCdq+aanLHLAMt>1px<}0>`D>hvnUbSND))kw!UwsjjwXrf!qup?= z@+mOH3&<4&9?XZ~P#)>oxMu6B%b;Jea{Y$&+pk7qglpGt-?V1iws7s{t>KDr%Zjbr z*RQ%_!-}opmMgZx3v2qra2xWF9DAmbWHJunU4~aw!=9?js@z`TOv6HhyvjHp3$7>` z*HWr^diOQ+Qg`Oto%yLdJ9KBqb*Veo+!$QpGzjM24#%p{s9@FFl*~I5d(~^h)I1{G zkzQp1ma2EyD~8_TR1R085~{Q|#;=*85&(=%OlLS?QY}4$oDP zY^b09aQ%ol#@YU3wc6ys!i9VG?CBpZ)%(kp(S>LaX^!eb>anAGt;yh#0kbDznCc{x z9y3;xk!|H0E|+SRaxpAMH8epwp;N29qtbig9t|v$RO-;d-d>rzGFEf7;5t1qB0aNG zmrGF)tK?j`GJ;n(TO~AWidQ?Mzfh?} z#b`H!UL~~I$)LBR%zA1wvIf_#U$bHLRqI!8zieAKiY+U)cX_ma-KNc3*Q{ExZA}+~ z4R(Jb%9Uta%nsRaYBbMT)r(?-I~W|oo*OrE>p^dK!kJZCR6SZQPf99O89HdcL2-7W zq$!m*F-(&&5}T6*gLzs6?QgTKF2!^t^NeJ^r%_|eWU;xU%?eZO80{_8GAS0;Jf2rm zImzGQI^94QsE8yA29uOs-p?EwaVZU7fx;U|1AR+pcx=mS}(u%{5XfPtdce8ahH$p0y>C-p%ua zK|Rp0oOLda7}jWK`9@wHUW9(HS4tVF-3BWqQ=+6tZ#v7(?h}a+q~3W=oN=W& zFO&QrSA@IsQ}nIPck)a!5Fgw|>=)skdv0=AKQ#)J)0FPeP;K5;#P2>;rp3;(8_V_fUEky}(m=yS>WEN`OlEqpHlsexbZ%ZVV+wp<;$##_I(N@%2w-Mk&Zd!Z;6`1e5Jsk(PTEKd zg-mLcC?319gHM2?vi-r@rDs}%htX0JJayV77wbRue%-Zs7^;blR#=2+WPW+pb(>Fo>K z^H(ljJH%#aCY_~xQLdI6Mpl{B3zMge$<}9bCpe?jTzKlyY7M_tC7pd|B6>0PlFl?# zB~7HhN;*PL99JG#F)_U9GdE7X)^KZcxONH%5hh=nUR%q$n$XANZb8A*Tc0)>Nj%Wn z2V&%wu8%9CM@@yax1`Hwt|$L4QJPg_lNs8h3$+$BjK5{IrPdev1LxS6Dnvpu3swg6 z(g-SREel*>pNf#YRNy> z9Ub2Wje5O1k=8|!on}m$RnM$R15usU=LQ6wHeAm7-gc#vrgBWKYFIGJjY6~ZRj-bz)2(0P zk(X*QI^V6{TH3^Da#gcZx$5Epq}1bu$w_ro8841Z!ujpiUJ z7$m0MaG9l$j@Dv|Bwh{FBuv(+a|snnlAaUh+oVDW4k`0tca zpA%`yGxZo}UDn>UFdyw+sKqm9h-m-@=GkpX54ypY)Pnpl(=1Kf{GuKYjCEyPute%y zz!gjpFA&i1t;4?lseiZtng_;|f1aW@Zvx zsxxG>P$YG{g4Q=oiAQqG1Xy(Q-f+FkO{~MAa-Lcxw8J?Bn%Px0cTW*nUqm@P<`rhA z>E&708mV7}!H$HdAyR9#ZrL(s9GQ-T*=S+BDF8v?*53k0r|vP`ksFafT<)h&{%O2$ zqt22xOAoRjD(x;*%FZ@UG|r&;4L4l9bJgap_$_3@MD(*}eBwY!o7h_upcpBBtWX>$ zC+yYC5CLUB5QK;mdNml6+v9MGXcQsKp2sBx7YXy>>oz_~VNwoX{ht*i?nb(`g zVeXV@m{=87U1Pc~QO^VDwrJXRze8ADd?v^tW zc5Y%Du!=NMKx~-jC*>kclS&Xb=$ugCx=^-6C=+?B>;G;%+{GAhoi_ANj2;=jJ2|Qp|SZ!ekEJOiA7~Ku2&-yX9>}Qv9)qZxG1Jd zF?!lsPPn9}17Wc+RKaC!V=Qrq*n}-%-GfMRs7~sZKvEyOHY`qrCU?!tBPUJhnXOZXZfB$W=}g|V}2YB+9JcT&L*(_o|R@`X$qp1 zUUl3&^w z)Rf0LUu+`1TTB6on-!;4k)6$t28-~mi>(qOHI3~_4Y8_HQa#Q@8z6@(1y&SN51pSl zRa7^vP72xfTq_H{DH}xEw}sMRBM_B{->2!sLYz6ZOn|OQy(00S#2JLWqpc*VMYEVH zC|1V`BejEF#%oWNyx-5eZ7Wbm2TprhZF@q?u;a`M<9cHn7m&*#UHMeanir^i{kqV$ za^nO#WT*F*G7REPY;j|GLs*JCku%0EwoRyQWSf9#Syt{!Y5tm6CrpgHYAuekJ@T*YnRO-wz(4d47;(+k&Tx*cj)FBcTo46cI9Yo{8W2S|+HKhuPqi*#C^`SZOy|odKzk zE4aY4`6%|&r`)*WKIONYT^ISz)D4?`db);fK0RHPua^9N!lpM%Yvl{01-`wIkZNqf zO#DMCA9lRCH&Io#rr_?`$2ROk#wP~LW4WHe{ZckIwIQCxK9a5}wA0!4YEdxTo}vxI zev^jjg;NphJ9Oh~mm$mv}HVe$bDw2OQ_?nI>E| z17+o4)n2(NMWP>ORC(n}7X{R!th&;*Dk{v@Dq>;U-7D!r@nk%EkKz$9*@uBMVV?z&AP@tQ@f0~@7`vx;{qb*F4Gtz#dPB!dQe zU@~r+DZlqu+dfrzrxe-<)qGVV!`~$*1UP^Ol;^KEC*|o1Z&vAQ`g`#rEGLstNLzF zIeXph({@nYZJwI$q)qc&Pu6OLCu&>`)-CTw9Xs0()$85nUSksTZztm~<_Nh+99h#$ zxy`9mMKgEXeH`Z%w0Qh<&3*~#hUPD0QK}En7FQTEA)S<{filnmN}t ztxVTYyW|_EPYUff9yG1`bRctPkXz(#X}wOlikw_Dc3aHUM&2#ipd#4*X3qCTvYPz& zY{rDD^Uhk(aF|Ieq;|Jr{Wq5GjZD^ubCuCini!fb!wAx@74B#%5uv+04f!>f6ZKH6 z&+m|xQ>)=6%UF9sWzkCVk(FY;vnT*dyXDpS#*puE|l>P8(H< zKbLE4kMBg^QtR%CykLq;Rdw5T-0PB(wB%+I$#iEQD>drtMy1$Ixvy*L($K!X3qTbU@Wc#&GBkRO3A z8F_kYO%rU*wy}eTON?qrNIvsxLVZ#&+Lr7PH8`f{)&qLMuyhFZv z>gY9yMo;rj=h%C%5E~K%vcKbd@eI0g$Ia-ij<%92g@hxI@14=#d__^MYSnzAuvc9! zo9>c~nOK9DaN?55Lt#51NrF>-f^WlAKxf8wx~C!P%Pgl;M-rZUkNn^@ym6WYzEkR@ zJ&doN@FKxU!c;?98`z{l3-7AJHQ||jF^NTuCr@U!KDBaoq94+-AN6Te;8P^q=H~63 zL&`bWkxoJLDb%nnHQ@D(7_e@Ww0$vO9p<~yMg}a_+Qz%5nu7#`Umeh*hrYYv3s_lL zY&hB5>~EOO_cbj^5|uZji-LqLgE&@$%|ca$>O$C}4EPATtmq}#_4(|TF2v7(+mC!s z|DygyV?8eXOLk**w2;p#=u38cS?i}ITsh0D;}Khc`!SY!wrt*>UBv`dCVzG{OgIoO zS+sabcG1%8k_*BmO9mD#U9f1$qD2s9x3U{byB3@1AU!W!yl7zQ`3n{;hHe95EX()4 zB|Obc7Y4%TF$W5_6(*RPF>}6noXh3h=nnwK>_b=*MrBCb#)3cpX%%TBa&xPiAxX4!cu&S3~ zo@Ot&;M@zdiyOo$E|cBt8VpDo)C1uKLxoz;3$iX+gVke0dEBPepF1tf|CQinRs=oA8IRJ#ha%`UcJcqsMU8;7>a*yfLMY4xzc=nY5qh3qB_Cjl4XDix!u zEx=V1{!m@$xxkquZU}y`3<+cuI5s$%8rOvdQS+!%lES68EV?8AO&uGdur!R^xP#6!Jnrqtgaw0JZJLgT_2BGdVXc-KB2S}&HA-%d;ChU&C!%71 zxVrAtfRBZx=_J#qusphu@E-_$i4k|p#lup7LpqNNR3uQR35P`hEBcqffrZi0T}&)` zXsK?|u=;2pOukrK5DW`q9~`B`Llq^QH-_mdg|)jtz`Uq5rtycyP?@Dc(2d$gwr0GF zzlQ_|7Y^$nqG4sFz*tNfcatYK?WrB0shJ%ik%KFoY9dn3Xr1PZ!(sW`xNecj~bOrEO6 zx()C6fp!2kr?{+cdY=+#Z?(ow%>rVfi#52o>nCHODVAVkL%$JrOV-IW#o27jEN}qX zwD*VG?eB&>O=22Biq6NrYI(rU40_l?>|pW`e+gdiNExr~@XkylOjdJl%`|K`u(D(& zG6<5T-IEql&fRDVk+l{phK&;p9~gtymBrH9rdyla*eo9{@YH5_O(KOV=-DfO!p`Za zN~<%FtZl}2vmF8B(2M~yU}$yfQ-#p*Si!cCjk@&C5X8^g=iY}mFvT(?4TveqMGMyvba$++7o zXSKGEyhaHdii4wv+_$aRux{mwt(UD??FGr2b(_{~*QJ7FDd+9swk>N`5j1DJZf*SR zhJJ!%NwoF2xnnVGiS);7!YM`Z9qz~Ih4iwRGjGXcWER?4Y$1D4!B}aoR z*vOmXdoYC^o9D}<*jcID^W)nD&`RCj;cqL7R_Zo!v{o{nY&Yi)(~5=A@tLQmD!8f( z#dIL8B#xE~qcz(MT0&^K#AuPB0~KfHj;Q(RkMZ(kL1LVDcMF)vmI!*7UKRtUG*y3i znMA#Kkq?6RX@+vJ!Lw|EX(SfW&gPH|kqkn`m%Z)M6gvZZxja$XMugZs@S|+V2OBCRB-zS1a8^p$rye8Bho(klj>Z-Vd&AXU3^*HoHgHTjQwd6BV!(@wP@UX5J3d0u+Nw+^cU}F<*m>C!B%EB5&bXq)ZY4=t8Pl7$x#nhA#_g)LC{? z@t}yCqi=QQ5f@dfwc*sTR8I$Tx9~peR?0G zX#hM%GI;We1TM3KsJ(b-w9bfAB&xNhX)F_@(%9zxiT$`yWCp-j3dE(aKb2a6pvL7L zup!`<3aW(2JAi%Cm>W++Ngh^5=NO73Vwl__v&gEYNE+fTwQ-dstCss+Y6)RWo^91c z0!xPAEQ!a7GlO6vllNv5jqSIHSQg@Ic8ug=e08L4E>S=&s|Wbpa-ZyOyrH@LDAN#| zgpEXez13UHH`BNoEOstM7t0xyBuz7KyJ=ff?p;&L&F5T3&9Cxo&31n@0gfUWHEx_Y z1 zYl{1;-NUSXj@-4H&Aog+Y4=TwB+56 zS~J0nHe$GmB(_gmT`gI>@S<@h%eQp_rawqg_y}eqoZm*7CUk+!vI;WRnqitOUGM4W z63&!HG^tl)-3#T&oGesZ*V4J#r*AX9JK;!iSHYP`zH6r|N|Fo?n<14CF_v+W&|+Z) zOY9rsKe&TAeLRT$L~J~ch!zJ#OV>PRCabkg)U4`EFY=)*WBxWslRcQ40Q#b|JeLS< zo4Ix-m3VZ1w~QjAxlxjF!O>!OiRpxaAgO~q$|l3$t)!y7FcBTC?c7gV=XtTL;*~hZ zm?|t*I}OG+yZH3vKA6N7XO0%wZeZE(^RWz-#Z0DqI>ABO?UuBQQndwPcQwn;L|Hcv@xV04Qsm4pwn{=_!Dk0RWS{kd^UFamMI%db-OTW5hO`fJH zNZz4#=swG}TVS=6%%j7w;L>5$tjOFp-WBKB;yg(|%1GaCO*hMi0Dgg)Wzin1E}V-`SvGFYL4r$p(Mj^cgrBeDc&Ei@5V!MC2l^ zF*eaEOe|fPwen=%)|)Y_*gZWwmL0E@CxbkH00uHeSj)x}%q9wTkgZ(V^xUjZzdeAD z1P<`&3ytW8Agvfr)os53E#6qdb|bArm^IB_jgsz?7Vyry<#CubS>Ap@(0nS=;7vob z6igI~yAC+5Xcul@Qb7TJ?gp z(#aA(w@p*jd5p~X<(8M_lum-9UwibLse;4{Ngp)(Imu9e536M}fcOfwOro@D;tMmU zOed>B!mF*cDZ;d-OeK;^Gvhgq)n*qim{t3I3(|($v8IAeL&OxqPrl-?STSY@t>w5n zC392m)a7nR3FZ+qP}@3&BaazjOpgD~S0%oaWMI~q;*up6lcKY!`;dnz7EkQ;hL#q4 z_;6^=v_phTD-bzh+}JlYel=-r4BdEm%{m`HoSaV0%rZ`!Rm{l(76{nZPG!*#8qgAD z>gZTInXcBhDgtb&1sv}(oJqpCLp3<*$MQs;dN`FfS=sL*wQ24j2Xtf1d2&tjeP$Az z@=bY@iq}d#xH2S;i#Ui{EJ9-AV>U*3oHpqznY3&-Zs;jD`!Esi)fww9vQQG0l|*rC z&7^IhixFIVbj^y&`?g{`Mx&vUl^(B4dNWzqUfM$>Pn=IQJzasAnGK8G+N<3{_Z9;M zHG2Z-eM_-SklMo#AZvszs9>E=*-MKBE7i*pt0pl5OQd7Owfeh z)!Firq~J}}u?k`oo3E>_U`ZNlLG7`j104I>OhnR;t+b8t)s_Q8&bU3vDWUL^Do!h7 zggkBUDLm8gEjvNtta({oR9ONhhk#8RB;thl@2gCklS|yBsWkKg1h1eGFj zo0^X#e(pQ8EqzBfqpwVymH>bLZ`8I{EVe+}E0|CwFHSO{A^WU}+4zRG(t3c^IZZH4 za-X4_MUQKzff<`k@#9zkjSJ7Tn}H%L-Fr=U7jkY;vf|3FK(p}02uX@o!>xn4XJ0|+ zz3{pw8^(lwc9TVAXrHDHV;*I_X^#J=zh^~}IKGO7(A$VxJ?%rwfA$pIv6{Bd#^ z0?CNvSv{YQCASC*rFD;W^Hg9l6H+ExRFf*iQ`ESal{`!W@Q~m71QcXpV7t z9GX`S6Wf)-`-PO4vfUG8C2k_@fNXC{F5t*VPB z7q7ynwoSM#e#Dc*m5iqy+po@%xE(7Vb{#cp=ui zaacHsAokq+#8%0C^DseRcxc;#Yd>nil818%)RKU5zQQpdn%HjVH%ue9#)J`*wiKJ> z7-c|qnc36Hb)CeK>zG-qNIdAA8h-ZwcA>gtHNB5Lsa{4=>NITaqX^6^w{4@dtTGy8 ztHRU`4PhH2Ky8O!qm_-1HjqEIG@OL6@Gq$yyANXdi_{j_grYJ4KikhS& z2~r*In`a{5hp`(cj9q!s&2MloD5NOg9C}OJ^ehrysSxr$j$O)OkoeoRY1)i(KUbPA zQECP=3+hJG%>E74@_4fR)%=QPJ<4A%Ma&>bJ8r3V^>*t{ZhqA8MEm+RIV$DN7~?+_ z>=}VZRl_x=Da*7Qy8LFS=~5+jZYV{g?PA2VYHXHjan@xN2d|^T?7Rcgjb!FGFr+uE z#jUBhc$#)-JHbJvXX(!c$;-y;HVTxd+LHO~vufU@o_VSXai!0?^m2dioy^b}8r>#k z-3(U|_GX=nbM7J~cjGYhX4~vjmk!WOY;_m=DE6M8r^Y_>45D7q_r`tny}09Gj<~^M zS3N<*eO}PJKztgp*LB#^24i)uUUN!f^O^8>ER(E_bW7S4cyCswMf11w2WeL5qwtQ} zz10-xO4wosG@{uhz7#isqi?Jo+%yu6DLIU*ph?F*<;DrRzjFTiYfP^VL~6g0w4!Kw<97pG+L>&jqRozZRU@aeuRB_I)$LOFQenYe|$P72Ow*a z?CF`5kz5J<3~pbAzf>MrK))r-8wj;A<)(J&l^y+prm1gw%CNSf|0Ll}9%_wET%~kf@5fknlo8iS2Jk@wq z?WnMSX(|r_0=DF^V8L{G#06kmZ_{UN#ztvRjLn&BHfbROae$gGQz6nH%*lKyE&6+Zo&mB^sj}mZA;F#QU`YFLj|1au!JRsrQ|AMr)cZTI#D<6GIiE0 zCDo^%HuX(?!=w#aE^MHm3r7~4f84&&wUQ^^7B@>_Xziyc6*p0lt(tN!yTJaP65AAD zhP3UG{${1z+LIlmf@{w}^5fv=&2j9&St-kDiJO%Ht4`rKzHnUMFm@x(VB(&aa?)t1 z5CK&_IJPCYSc8ldF5M)dX>w=liFBT1Vmyi!Y0&NaO}gBXHHR8>K1AX*X(w?UY_MaM zW5J$y6JZu>+2qsLCO-9^$TnAW>uyJijDa4cZfmb=Vrt7H#fu1ZWxJ1vEZ9B|lL)Ev zSJj#NvmC+ahjIMD7PU{q9<)K?#Q*#%0v_?ATbWo;<&!U4JLKC%k|GLwPw;KDJ zJzdKrsnzpJ3wM1*OWh%Dd4q*3bc|*WM)$`DQtB}YRw%|(V*eM=5y=VH`ACJ+vu48T zb#@K=U2BxPEpP$CyeU$l34RoOmpFy|i7WdHdXz_ILXb+XPet_i!fpjSZ|?d z{g|Y=$=az~Y;of!*QjalXX7Q!`60vY+kdSTE%Ni6SO&UJwtd7xO_$lomEO1IXT}Y7 zNW$wCG1D}=W}}Vv3DMMwzHAwA%Xa=@dPxMulrs5SeBW#bOvf#3WEpc!bL7H~&l_R< z;urD$xPIP$rcQ8$GmpKCU#Q)DZp|STzc7_YlaHC;mbjs`zYdKH@W*L63*#x?oR*4nIJ+XKgS9Bvm_Mqu=o=m|l}akspi3rB5W1-k&7+$( zjj$O7`|W(x!`T%gA2scrLnZN7TWMB8q%qc7Y&++W^kEQfi3wlBl&LXWKyqbr1<#Gd z{S?nynt~zv`HJ^v5DU@WaAHd})?~mwt>86h!$A z^#`GYx_iGqvu-g+r+K6aQG>ZO*tNBOx&*Oix7|1dNt`hQ*Em5-q(tAAjWCHC3|7ZD zPNJH`8k&=ueU_l`8SsG#(Z-i4al-a+iEjMpOBviH@*lfN3PGUYVx(T|;-R^;o7$EH zldv-X!`YceOnEBI*_g{Sl&X<7PPRlwoRyi~lI9?7Y>SlGQ5Clcd>2!(BW1JB3jROk CE6Pm( literal 0 HcmV?d00001 diff --git a/po/da.po b/po/da.po new file mode 100644 index 0000000..e7b3da8 --- /dev/null +++ b/po/da.po @@ -0,0 +1,2249 @@ +# Danish translation of gawk +# Copyright (C) 2001 Free Software Foundation, Inc. +# This file is distributed under the same license as the gawk package. +# Martin Sjögren , 2001-2002. +# Christer Andersson , 2007. +# Keld Simonsen , 2002,2011,2012. +# Review by Torben Grøn Helligsø , 2011. +# Review by Ask Hjorth Larsen , 2011. +msgid "" +msgstr "" +"Project-Id-Version: gawk 4.0.0h\n" +"Report-Msgid-Bugs-To: arnold@skeeve.com\n" +"POT-Creation-Date: 2012-03-28 22:03+0200\n" +"PO-Revision-Date: 2012-02-06 10:37+0100\n" +"Last-Translator: Keld Simonsen \n" +"Language-Team: Danish \n" +"Language: da\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=iso-8859-1\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.0\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: array.c:140 +#, c-format +msgid "from %s" +msgstr "fra %s" + +#: array.c:248 +msgid "attempt to use a scalar value as array" +msgstr "forsøg på at bruge en skalar som array" + +#: array.c:251 +#, c-format +msgid "attempt to use function `%s' as an array" +msgstr "forsøg på at bruge funktionen '%s' som et array" + +#: array.c:254 +#, c-format +msgid "attempt to use scalar parameter `%s' as an array" +msgstr "forsøg på at bruge skalarparameteren '%s' som et array" + +#: array.c:257 +#, c-format +msgid "attempt to use scalar `%s' as an array" +msgstr "forsøg på at bruge skalar '%s' som et array" + +#: array.c:302 array.c:707 builtin.c:84 builtin.c:1385 builtin.c:1427 +#: builtin.c:1440 builtin.c:1859 builtin.c:1871 eval.c:1135 eval.c:1139 +#: eval.c:1495 eval.c:1812 +#, c-format +msgid "attempt to use array `%s' in a scalar context" +msgstr "forsøg på at bruge array '%s' i skalarsammenhæng" + +#: array.c:513 +#, c-format +msgid "reference to uninitialized element `%s[\"%.*s\"]'" +msgstr "reference til ikke-initieret element '%s[\"%.*s\"]'" + +#: array.c:519 +#, c-format +msgid "subscript of array `%s' is null string" +msgstr "indeks i array '%s' er en tom streng" + +#: array.c:723 +#, c-format +msgid "delete: index `%s' not in array `%s'" +msgstr "delete: indeks '%s' findes ikke i array '%s'" + +#: array.c:734 eval.c:1865 +#, c-format +msgid "attempt to use scalar `%s[\"%.*s\"]' as an array" +msgstr "forsøg på at bruge skalaren '%s[\"%.*s\"]' som array" + +#: array.c:910 +#, c-format +msgid "%s: empty (null)\n" +msgstr "%s: tom (null)\n" + +#: array.c:915 +#, c-format +msgid "%s: empty (zero)\n" +msgstr "%s: tom (nul)\n" + +#: array.c:919 +#, c-format +msgid "%s: table_size = %d, array_size = %d\n" +msgstr "%s: tabelstørrelse = %d, arraystørrelse = %d\n" + +#: array.c:954 +#, c-format +msgid "%s: is parameter\n" +msgstr "%s: er parameter\n" + +#: array.c:958 +#, c-format +msgid "%s: array_ref to %s\n" +msgstr "%s: arrayreference til %s\n" + +#: array.c:963 +msgid "adump: argument not an array" +msgstr "adump: argument er ikke et array" + +#: array.c:1086 +msgid "asort: second argument not an array" +msgstr "asort: andet argument er ikke et array" + +#: array.c:1087 +msgid "asorti: second argument not an array" +msgstr "asorti: andet argument er ikke et array" + +#: array.c:1094 +msgid "asort: first argument not an array" +msgstr "asort: første argument er ikke et array" + +#: array.c:1095 +msgid "asorti: first argument not an array" +msgstr "asorti: første argument er ikke et array" + +#: array.c:1102 +msgid "asort: cannot use a subarray of first arg for second arg" +msgstr "" +"asort: kan ikke bruge et underarray af første argument for andet argument" + +#: array.c:1103 +msgid "asorti: cannot use a subarray of first arg for second arg" +msgstr "" +"asorti: kan ikke bruge et underarray af første argument for andet argument" + +#: array.c:1108 +msgid "asort: cannot use a subarray of second arg for first arg" +msgstr "" +"asort: kan ikke bruge et underarray af andet argument for første argument" + +#: array.c:1109 +msgid "asorti: cannot use a subarray of second arg for first arg" +msgstr "" +"asorti: kan ikke bruge et underarray af andet argument for første argument" + +#: array.c:1655 +#, c-format +msgid "`%s' is invalid as a function name" +msgstr "'%s' er ugyldigt som funktionsnavn" + +#: array.c:1659 +#, c-format +msgid "sort comparison function `%s' is not defined" +msgstr "funktionen for sorteringssammenligning '%s' er ikke defineret" + +#: awkgram.y:249 +#, c-format +msgid "%s blocks must have an action part" +msgstr "%s-blokke skal have en handlingsdel" + +#: awkgram.y:252 +msgid "each rule must have a pattern or an action part" +msgstr "hver regel skal have et mønster eller en handlingsdel" + +#: awkgram.y:323 awkgram.y:334 +msgid "old awk does not support multiple `BEGIN' or `END' rules" +msgstr "" +"gamle versioner af awk understøtter ikke flere 'BEGIN'- eller 'END'-regler" + +#: awkgram.y:371 +#, c-format +msgid "`%s' is a built-in function, it cannot be redefined" +msgstr "'%s' er en indbygget funktion, den kan ikke omdefineres" + +#: awkgram.y:432 +msgid "regexp constant `//' looks like a C++ comment, but is not" +msgstr "regexp-konstanten '//' ser ud som en C++-kommentar, men er det ikke" + +#: awkgram.y:436 +#, c-format +msgid "regexp constant `/%s/' looks like a C comment, but is not" +msgstr "regexp-konstanten '/%s/' ser ud som en C-kommentar, men er det ikke" + +#: awkgram.y:528 +#, c-format +msgid "duplicate case values in switch body: %s" +msgstr "dublet case-værdier i switch-krop %s" + +#: awkgram.y:549 +msgid "duplicate `default' detected in switch body" +msgstr "dublet 'default' opdaget i switch-krop" + +#: awkgram.y:809 +msgid "`break' is not allowed outside a loop or switch" +msgstr "'break' uden for en løkke eller switch er ikke tilladt" + +#: awkgram.y:818 +msgid "`continue' is not allowed outside a loop" +msgstr "'continue' uden for en løkke er ikke tilladt" + +#: awkgram.y:828 +#, c-format +msgid "`next' used in %s action" +msgstr "'next' brugt i %s-handling" + +#: awkgram.y:836 +msgid "`nextfile' is a gawk extension" +msgstr "'nextfile' er en gawk-udvidelse" + +#: awkgram.y:841 +#, c-format +msgid "`nextfile' used in %s action" +msgstr "'nextfile' brugt i %s-handling" + +#: awkgram.y:865 +msgid "`return' used outside function context" +msgstr "'return' brugt uden for funktion" + +#: awkgram.y:925 +msgid "plain `print' in BEGIN or END rule should probably be `print \"\"'" +msgstr "" +"alenestående 'print' i BEGIN eller END-regel skulle muligvis være 'print " +"\"\"'" + +#: awkgram.y:995 awkgram.y:999 awkgram.y:1023 +msgid "`delete array' is a gawk extension" +msgstr "'delete array' er en gawk-udvidelse" + +#: awkgram.y:1019 +msgid "`delete(array)' is a non-portable tawk extension" +msgstr "'delete array' er en ikke-portabel udvidelse fra tawk" + +#: awkgram.y:1135 +msgid "multistage two-way pipelines don't work" +msgstr "flertrins dobbeltrettede datakanaler fungerer ikke" + +#: awkgram.y:1238 +msgid "regular expression on right of assignment" +msgstr "regulært udtryk i højreleddet af en tildeling" + +#: awkgram.y:1249 +msgid "regular expression on left of `~' or `!~' operator" +msgstr "regulært udtryk på venstre side af en '~'- eller '!~'-operator" + +#: awkgram.y:1265 awkgram.y:1419 +msgid "old awk does not support the keyword `in' except after `for'" +msgstr "" +"gamle versioner af awk understøtter ikke nøgleordet 'in' undtagen efter 'for'" + +#: awkgram.y:1275 +msgid "regular expression on right of comparison" +msgstr "regulært udtryk i højreleddet af en sammenligning" + +#: awkgram.y:1394 +#, c-format +msgid "`getline var' invalid inside `%s' rule" +msgstr "'getline var' ugyldig inden i '%s' regel" + +#: awkgram.y:1397 eval.c:2504 +#, c-format +msgid "`getline' invalid inside `%s' rule" +msgstr "'getline' ugyldig inden i '%s' regel" + +#: awkgram.y:1402 +msgid "non-redirected `getline' undefined inside END action" +msgstr "ikke-omdirigeret 'getline' udefineret inden i END-handling" + +#: awkgram.y:1421 +msgid "old awk does not support multidimensional arrays" +msgstr "gamle versioner af awk understøtter ikke flerdimensionale array" + +#: awkgram.y:1517 +msgid "call of `length' without parentheses is not portable" +msgstr "kald af 'length' uden parenteser er ikke portabelt" + +#: awkgram.y:1580 +msgid "indirect function calls are a gawk extension" +msgstr "indirekte funktionskald er en gawk-udvidelse" + +#: awkgram.y:1593 +#, c-format +msgid "can not use special variable `%s' for indirect function call" +msgstr "kan ikke bruge specialvariabel '%s' til indirekte funktionskald" + +#: awkgram.y:1671 +msgid "invalid subscript expression" +msgstr "ugyldigt indeksudtryk" + +#: awkgram.y:1711 +msgid "use of non-array as array" +msgstr "brug af ikke-array som array" + +#: awkgram.y:1975 awkgram.y:1995 msg.c:98 +msgid "warning: " +msgstr "advarsel: " + +#: awkgram.y:1993 msg.c:130 +msgid "fatal: " +msgstr "fatal: " + +#: awkgram.y:2043 +msgid "unexpected newline or end of string" +msgstr "uventet nylinjetegn eller strengafslutning" + +#: awkgram.y:2300 awkgram.y:2358 awkgram.y:2542 +#, c-format +msgid "can't open source file `%s' for reading (%s)" +msgstr "kan ikke åbne kildefilen '%s' for læsning (%s)" + +#: awkgram.y:2301 awkgram.y:2359 builtin.c:122 +msgid "reason unknown" +msgstr "ukendt årsag" + +#: awkgram.y:2317 +#, c-format +msgid "already included source file `%s'" +msgstr "allerede inkluderet kildefil '%s'" + +#: awkgram.y:2343 +msgid "@include is a gawk extension" +msgstr "@include er en gawk-udvidelse" + +#: awkgram.y:2349 +msgid "empty filename after @include" +msgstr "tomt filnavn efter @include" + +#: awkgram.y:2494 +msgid "empty program text on command line" +msgstr "tom programtekst på kommandolinjen" + +#: awkgram.y:2609 +#, c-format +msgid "can't read sourcefile `%s' (%s)" +msgstr "kan ikke læse kildefilen '%s' (%s)" + +#: awkgram.y:2620 +#, c-format +msgid "source file `%s' is empty" +msgstr "kildefilen '%s' er tom" + +#: awkgram.y:2797 +msgid "source file does not end in newline" +msgstr "kildefilen slutter ikke med en ny linje" + +#: awkgram.y:2900 +msgid "unterminated regexp ends with `\\' at end of file" +msgstr "uafsluttet regulært udtryk slutter med '\\' i slutningen af filen" + +#: awkgram.y:2924 +#, c-format +msgid "%s: %d: tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "%s: %d: regex-ændringstegn '/.../%c' fra tawk virker ikke i gawk" + +#: awkgram.y:2928 +#, c-format +msgid "tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "regex-ændringstegn '/.../%c' fra tawk virker ikke i gawk" + +#: awkgram.y:2935 +msgid "unterminated regexp" +msgstr "uafsluttet regulært udtryk" + +#: awkgram.y:2939 +msgid "unterminated regexp at end of file" +msgstr "uafsluttet regulært udtryk i slutningen af filen" + +#: awkgram.y:2998 +msgid "use of `\\ #...' line continuation is not portable" +msgstr "brug af '\\ #...' for linjefortsættelse er ikke portabelt" + +#: awkgram.y:3014 +msgid "backslash not last character on line" +msgstr "sidste tegn på linjen er ikke en omvendt skråstreg" + +#: awkgram.y:3075 +msgid "POSIX does not allow operator `**='" +msgstr "POSIX tillader ikke operatoren '**='" + +#: awkgram.y:3077 +msgid "old awk does not support operator `**='" +msgstr "gamle versioner af awk understøtter ikke operatoren '**='" + +#: awkgram.y:3086 +msgid "POSIX does not allow operator `**'" +msgstr "POSIX tillader ikke operatoren '**'" + +#: awkgram.y:3088 +msgid "old awk does not support operator `**'" +msgstr "gamle versioner af awk understøtter ikke operatoren '**'" + +#: awkgram.y:3123 +msgid "operator `^=' is not supported in old awk" +msgstr "operatoren '^=' understøttes ikke i gamle versioner af awk" + +#: awkgram.y:3131 +msgid "operator `^' is not supported in old awk" +msgstr "operatoren '^' understøttes ikke i gamle versioner af awk" + +#: awkgram.y:3224 awkgram.y:3240 +msgid "unterminated string" +msgstr "uafsluttet streng" + +#: awkgram.y:3436 +#, c-format +msgid "invalid char '%c' in expression" +msgstr "ugyldigt tegn '%c' i udtryk" + +#: awkgram.y:3483 +#, c-format +msgid "`%s' is a gawk extension" +msgstr "'%s' er en gawk-udvidelse" + +#: awkgram.y:3488 +#, c-format +msgid "`%s' is a Bell Labs extension" +msgstr "'%s' er en Bell Labs-udvidelse" + +#: awkgram.y:3493 +#, c-format +msgid "POSIX does not allow `%s'" +msgstr "POSIX tillader ikke '%s'" + +#: awkgram.y:3501 +#, c-format +msgid "`%s' is not supported in old awk" +msgstr "'%s' understøttes ikke i gamle versioner af awk" + +#: awkgram.y:3568 +msgid "`goto' considered harmful!\n" +msgstr "'goto' anses for skadelig!\n" + +#: awkgram.y:3619 +#, c-format +msgid "%d is invalid as number of arguments for %s" +msgstr "%d er et ugyldigt antal argumenter for %s" + +#: awkgram.y:3654 +#, c-format +msgid "%s: string literal as last arg of substitute has no effect" +msgstr "" +"%s: bogstavelig streng som sidste argument til erstatning har ingen effekt" + +#: awkgram.y:3659 +#, c-format +msgid "%s third parameter is not a changeable object" +msgstr "%s: tredje argument er ikke et ændringsbart objekt" + +#: awkgram.y:3732 awkgram.y:3735 +msgid "match: third argument is a gawk extension" +msgstr "match: tredje argument er en gawk-udvidelse" + +#: awkgram.y:3789 awkgram.y:3792 +msgid "close: second argument is a gawk extension" +msgstr "close: andet argument er en gawk-udvidelse" + +#: awkgram.y:3804 +msgid "use of dcgettext(_\"...\") is incorrect: remove leading underscore" +msgstr "" +"brug af dcgettext(_\"...\") er forkert: fjern det indledende " +"understregningstegn" + +#: awkgram.y:3819 +msgid "use of dcngettext(_\"...\") is incorrect: remove leading underscore" +msgstr "" +"brug af dcgettext(_\"...\") er forkert: fjern det indledende " +"understregningstegn" + +#: awkgram.y:3911 +#, c-format +msgid "function `%s': parameter #%d, `%s', duplicates parameter #%d" +msgstr "funktionen '%s': parameter %d, '%s', er samme som parameter %d" + +#: awkgram.y:3953 +#, c-format +msgid "function `%s': parameter `%s' shadows global variable" +msgstr "funktionen '%s': parameteren '%s' overskygger en global variabel" + +#: awkgram.y:4111 +#, c-format +msgid "could not open `%s' for writing (%s)" +msgstr "kunne ikke åbne '%s' for skrivning (%s)" + +#: awkgram.y:4112 +msgid "sending variable list to standard error" +msgstr "sender variabelliste til standard fejl" + +#: awkgram.y:4118 +#, c-format +msgid "%s: close failed (%s)" +msgstr "%s: lukning mislykkedes (%s)" + +#: awkgram.y:4170 +msgid "shadow_funcs() called twice!" +msgstr "shadow_funcs() kaldt to gange!" + +#: awkgram.y:4176 +msgid "there were shadowed variables." +msgstr "der var skyggede variable." + +#: awkgram.y:4206 +#, c-format +msgid "function `%s': can't use function name as parameter name" +msgstr "funktionen '%s': kan ikke bruge funktionsnavn som parameternavn" + +#: awkgram.y:4210 +#, c-format +msgid "function `%s': can't use special variable `%s' as a function parameter" +msgstr "" +"funktionen '%s': kan ikke bruge specialvariabel '%s' som en " +"funktionsparameter" + +#: awkgram.y:4226 +#, c-format +msgid "function name `%s' previously defined" +msgstr "funktionsnavnet '%s' er allerede defineret" + +#: awkgram.y:4394 awkgram.y:4400 +#, c-format +msgid "function `%s' called but never defined" +msgstr "funktionen '%s' kaldt, men aldrig defineret" + +#: awkgram.y:4403 +#, c-format +msgid "function `%s' defined but never called directly" +msgstr "funktionen '%s' defineret, men aldrig kaldt direkte" + +#: awkgram.y:4435 +#, c-format +msgid "regexp constant for parameter #%d yields boolean value" +msgstr "konstant regulært udtryk for parameter %d giver en boolesk værdi" + +#: awkgram.y:4544 +#, c-format +msgid "" +"function `%s' called with space between name and `(',\n" +"or used as a variable or an array" +msgstr "" +"funktionen '%s' kaldt med blanktegn mellem navnet og '(',\n" +"eller brugt som en variabel eller et array" + +#: awkgram.y:4791 eval.c:2056 +msgid "division by zero attempted" +msgstr "forsøgte at dividere med nul" + +#: awkgram.y:4800 eval.c:2072 +#, c-format +msgid "division by zero attempted in `%%'" +msgstr "forsøgte at dividere med nul i '%%'" + +#: builtin.c:120 +#, c-format +msgid "%s to \"%s\" failed (%s)" +msgstr "%s til '%s' mislykkedes (%s)" + +#: builtin.c:121 +msgid "standard output" +msgstr "standard ud" + +#: builtin.c:135 +msgid "exp: received non-numeric argument" +msgstr "exp: fik et ikke-numerisk argument" + +#: builtin.c:141 +#, c-format +msgid "exp: argument %g is out of range" +msgstr "exp: argumentet %g er uden for det tilladte område" + +#: builtin.c:200 +#, c-format +msgid "fflush: cannot flush: pipe `%s' opened for reading, not writing" +msgstr "" +"fflush: kan ikke rense: datakanalen '%s' åbnet for læsning, ikke skrivning" + +#: builtin.c:203 +#, c-format +msgid "fflush: cannot flush: file `%s' opened for reading, not writing" +msgstr "fflush: kan ikke rense: filen '%s' åbnet for læsning, ikke skrivning" + +#: builtin.c:215 +#, c-format +msgid "fflush: `%s' is not an open file, pipe or co-process" +msgstr "fflush: '%s' er ikke en åben fil, datakanal eller ko-proces" + +#: builtin.c:333 +msgid "index: received non-string first argument" +msgstr "indeks: første argument er ikke en streng" + +#: builtin.c:335 +msgid "index: received non-string second argument" +msgstr "indeks: andet argument er ikke en streng" + +#: builtin.c:457 +msgid "int: received non-numeric argument" +msgstr "int: fik et ikke-numerisk argument" + +#: builtin.c:493 +msgid "length: received array argument" +msgstr "length: fik et array-argument" + +#: builtin.c:496 +msgid "`length(array)' is a gawk extension" +msgstr "'length(array)' er en gawk-udvidelse" + +#: builtin.c:504 +msgid "length: received non-string argument" +msgstr "length: fik et argument som ikke er en streng" + +#: builtin.c:535 +msgid "log: received non-numeric argument" +msgstr "log: fik et ikke-numerisk argument" + +#: builtin.c:538 +#, c-format +msgid "log: received negative argument %g" +msgstr "log: fik et negativt argument %g" + +#: builtin.c:694 builtin.c:699 +msgid "fatal: must use `count$' on all formats or none" +msgstr "fatal: skal bruge 'count$' på alle formater eller ikke nogen" + +#: builtin.c:762 +#, c-format +msgid "field width is ignored for `%%' specifier" +msgstr "feltbredde ignoreret for '%%'-angivelse" + +#: builtin.c:764 +#, c-format +msgid "precision is ignored for `%%' specifier" +msgstr "præcision ignoreret for '%%'-angivelse" + +#: builtin.c:766 +#, c-format +msgid "field width and precision are ignored for `%%' specifier" +msgstr "feltbredde og præcision ignoreret for '%%'-angivelse" + +#: builtin.c:817 +msgid "fatal: `$' is not permitted in awk formats" +msgstr "fatal: '$' tillades ikke i awk-formater" + +#: builtin.c:826 +msgid "fatal: arg count with `$' must be > 0" +msgstr "fatal: argumentantallet med '$' skal være > 0" + +#: builtin.c:830 +#, c-format +msgid "fatal: arg count %ld greater than total number of supplied arguments" +msgstr "fatal: argumentantallet %ld er større end antal givne argumenter" + +#: builtin.c:834 +msgid "fatal: `$' not permitted after period in format" +msgstr "fatal: '$' tillades ikke efter et punktum i formatet" + +#: builtin.c:850 +msgid "fatal: no `$' supplied for positional field width or precision" +msgstr "" +"fatal: intet '$' angivet for bredde eller præcision af positionsangivet felt" + +#: builtin.c:921 +msgid "`l' is meaningless in awk formats; ignored" +msgstr "'l' er meningsløst i awk-formater, ignoreret" + +#: builtin.c:925 +msgid "fatal: `l' is not permitted in POSIX awk formats" +msgstr "fatal: 'l' tillades ikke i POSIX awk-formater" + +#: builtin.c:938 +msgid "`L' is meaningless in awk formats; ignored" +msgstr "'L' er meningsløst i awk-formater, ignoreret" + +#: builtin.c:942 +msgid "fatal: `L' is not permitted in POSIX awk formats" +msgstr "fatal: 'L' tillades ikke i POSIX awk-formater" + +#: builtin.c:955 +msgid "`h' is meaningless in awk formats; ignored" +msgstr "'h' er meningsløst i awk-formater, ignoreret" + +#: builtin.c:959 +msgid "fatal: `h' is not permitted in POSIX awk formats" +msgstr "fatal: 'h' tillades ikke i POSIX awk-formater" + +#: builtin.c:1272 +#, c-format +msgid "[s]printf: value %g is out of range for `%%%c' format" +msgstr "[s]printf: værdi %g er uden for område for '%%%c'-format" + +#: builtin.c:1332 +#, c-format +msgid "ignoring unknown format specifier character `%c': no argument converted" +msgstr "" +"ignorerer ukendt formatspecificeringstegn '%c': intet argument konverteret" + +#: builtin.c:1337 +msgid "fatal: not enough arguments to satisfy format string" +msgstr "fatal: for få argumenter til formatstrengen" + +#: builtin.c:1339 +msgid "^ ran out for this one" +msgstr "^ sluttede her" + +#: builtin.c:1346 +msgid "[s]printf: format specifier does not have control letter" +msgstr "[s]printf: formatspecifikation har intet kommandobogstav" + +#: builtin.c:1349 +msgid "too many arguments supplied for format string" +msgstr "for mange argumenter til formatstrengen" + +#: builtin.c:1423 builtin.c:1434 +msgid "printf: no arguments" +msgstr "printf: ingen argumenter" + +#: builtin.c:1475 +msgid "sqrt: received non-numeric argument" +msgstr "sqrt: fik ikke-numerisk argument" + +#: builtin.c:1479 +#, c-format +msgid "sqrt: called with negative argument %g" +msgstr "sqrt: kaldt med negativt argument %g" + +#: builtin.c:1503 +#, c-format +msgid "substr: length %g is not >= 1" +msgstr "substr: længden %g er ikke >= 1" + +#: builtin.c:1505 +#, c-format +msgid "substr: length %g is not >= 0" +msgstr "substr: længden %g er ikke >= 0" + +#: builtin.c:1512 +#, c-format +msgid "substr: non-integer length %g will be truncated" +msgstr "substr: længden %g som ikke er et heltal vil blive trunkeret" + +#: builtin.c:1517 +#, c-format +msgid "substr: length %g too big for string indexing, truncating to %g" +msgstr "substr: længden %g for stor til strengindeksering, trunkerer til %g" + +#: builtin.c:1529 +#, c-format +msgid "substr: start index %g is invalid, using 1" +msgstr "substr: startindeks %g er ugyldigt, bruger 1" + +#: builtin.c:1534 +#, c-format +msgid "substr: non-integer start index %g will be truncated" +msgstr "substr: startindeks %g som ikke er et heltal vil blive trunkeret" + +#: builtin.c:1559 +msgid "substr: source string is zero length" +msgstr "substr: kildestrengen er tom" + +#: builtin.c:1575 +#, c-format +msgid "substr: start index %g is past end of string" +msgstr "substr: startindeks %g er forbi slutningen på strengen" + +#: builtin.c:1583 +#, c-format +msgid "" +"substr: length %g at start index %g exceeds length of first argument (%lu)" +msgstr "" +"substr: længden %g ved startindeks %g overskrider længden af første argument " +"(%lu)" + +#: builtin.c:1657 +msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" +msgstr "strftime: formatværdi i PROCINFO[\"strftime\"] har numerisk type" + +#: builtin.c:1680 +msgid "strftime: received non-numeric second argument" +msgstr "strftime: fik et ikke-numerisk andet argument" + +#: builtin.c:1683 +msgid "strftime: second argument less than 0 or too big for time_t" +msgstr "strftime: andet argument mindre end 0 eller for stort til time_t" + +#: builtin.c:1690 +msgid "strftime: received non-string first argument" +msgstr "strftime: fik et første argument som ikke er en streng" + +#: builtin.c:1696 +msgid "strftime: received empty format string" +msgstr "strftime: fik en tom formatstreng" + +#: builtin.c:1762 +msgid "mktime: received non-string argument" +msgstr "mktime: fik et argument som ikke er en streng" + +#: builtin.c:1779 +msgid "mktime: at least one of the values is out of the default range" +msgstr "mktime: mindst én af værdierne er udenfor standardområdet" + +#: builtin.c:1814 +msgid "'system' function not allowed in sandbox mode" +msgstr "'system'-funktion ikke tilladt i sandkasse-tilstand" + +#: builtin.c:1819 +msgid "system: received non-string argument" +msgstr "system: fik et argument som ikke er en streng" + +#: builtin.c:1874 eval.c:1159 eval.c:1790 eval.c:1803 +#, c-format +msgid "reference to uninitialized variable `%s'" +msgstr "reference til ikke-initieret variabel '%s'" + +#: builtin.c:1941 +#, c-format +msgid "reference to uninitialized field `$%d'" +msgstr "reference til ikke-initieret felt '$%d'" + +#: builtin.c:2028 +msgid "tolower: received non-string argument" +msgstr "tolower: fik et argument som ikke er en streng" + +#: builtin.c:2062 +msgid "toupper: received non-string argument" +msgstr "toupper: fik et argument som ikke er en streng" + +#: builtin.c:2098 +msgid "atan2: received non-numeric first argument" +msgstr "atan2: fik et ikke-numerisk første argument" + +#: builtin.c:2100 +msgid "atan2: received non-numeric second argument" +msgstr "atan2: fik et ikke-numerisk andet argument" + +#: builtin.c:2119 +msgid "sin: received non-numeric argument" +msgstr "sin: fik et ikke-numerisk argument" + +#: builtin.c:2135 +msgid "cos: received non-numeric argument" +msgstr "cos: fik et ikke-numerisk argument" + +#: builtin.c:2188 +msgid "srand: received non-numeric argument" +msgstr "srand: fik et ikke-numerisk argument" + +#: builtin.c:2219 +msgid "match: third argument is not an array" +msgstr "match: tredje argument er ikke et array" + +#: builtin.c:2483 +msgid "gensub: third argument of 0 treated as 1" +msgstr "gensub: 0 i tredje argument behandlet som 1" + +#: builtin.c:2776 +msgid "lshift: received non-numeric first argument" +msgstr "lshift: fik et ikke-numerisk første argument" + +#: builtin.c:2778 +msgid "lshift: received non-numeric second argument" +msgstr "lshift: fik et ikke-numerisk andet argument" + +#: builtin.c:2784 +#, c-format +msgid "lshift(%lf, %lf): negative values will give strange results" +msgstr "lshift(%lf, %lf): negative værdier vil give mærkelige resultater" + +#: builtin.c:2786 +#, c-format +msgid "lshift(%lf, %lf): fractional values will be truncated" +msgstr "lshift(%lf, %lf): kommatalsværdier vil blive trunkeret" + +#: builtin.c:2788 +#, c-format +msgid "lshift(%lf, %lf): too large shift value will give strange results" +msgstr "" +"lshift(%lf, %lf): for store skifteværdier vil give mærkelige resultater" + +#: builtin.c:2813 +msgid "rshift: received non-numeric first argument" +msgstr "rshift: fik et ikke-numerisk første argument" + +#: builtin.c:2815 +msgid "rshift: received non-numeric second argument" +msgstr "rshift: fik et ikke-numerisk andet argument" + +#: builtin.c:2821 +#, c-format +msgid "rshift(%lf, %lf): negative values will give strange results" +msgstr "rshift(%lf, %lf): negative værdier vil give mærkelige resultater" + +#: builtin.c:2823 +#, c-format +msgid "rshift(%lf, %lf): fractional values will be truncated" +msgstr "rshift(%lf, %lf): kommatalsværdier vil blive trunkeret" + +#: builtin.c:2825 +#, c-format +msgid "rshift(%lf, %lf): too large shift value will give strange results" +msgstr "" +"rshift(%lf, %lf): for store skifteværdier vil give mærkelige resultater" + +#: builtin.c:2850 +msgid "and: received non-numeric first argument" +msgstr "and: fik et ikke-numerisk første argument" + +#: builtin.c:2852 +msgid "and: received non-numeric second argument" +msgstr "and: fik et ikke-numerisk andet argument" + +#: builtin.c:2858 +#, c-format +msgid "and(%lf, %lf): negative values will give strange results" +msgstr "and(%lf, %lf): negative værdier vil give mærkelige resultater" + +#: builtin.c:2860 +#, c-format +msgid "and(%lf, %lf): fractional values will be truncated" +msgstr "and(%lf, %lf): kommatalsværdier vil blive trunkeret" + +#: builtin.c:2885 +msgid "or: received non-numeric first argument" +msgstr "or: fik et ikke-numerisk første argument" + +#: builtin.c:2887 +msgid "or: received non-numeric second argument" +msgstr "or: fik et ikke-numerisk andet argument" + +#: builtin.c:2893 +#, c-format +msgid "or(%lf, %lf): negative values will give strange results" +msgstr "or(%lf, %lf): negative værdier vil give mærkelige resultater" + +#: builtin.c:2895 +#, c-format +msgid "or(%lf, %lf): fractional values will be truncated" +msgstr "or(%lf, %lf): kommatalsværdier vil blive trunkeret" + +#: builtin.c:2923 +msgid "xor: received non-numeric first argument" +msgstr "xor: fik et ikke-numerisk første argument" + +#: builtin.c:2925 +msgid "xor: received non-numeric second argument" +msgstr "xor: fik et ikke-numerisk andet argument" + +#: builtin.c:2931 +#, c-format +msgid "xor(%lf, %lf): negative values will give strange results" +msgstr "xor(%lf, %lf): negative værdier vil give mærkelige resultater" + +#: builtin.c:2933 +#, c-format +msgid "xor(%lf, %lf): fractional values will be truncated" +msgstr "xor(%lf, %lf): kommatalsværdier vil blive trunkeret" + +#: builtin.c:2957 builtin.c:2963 +msgid "compl: received non-numeric argument" +msgstr "compl: fik et ikke-numerisk argument" + +#: builtin.c:2965 +#, c-format +msgid "compl(%lf): negative value will give strange results" +msgstr "compl(%lf): negative værdier vil give mærkelige resultater" + +#: builtin.c:2967 +#, c-format +msgid "compl(%lf): fractional value will be truncated" +msgstr "compl(%lf): kommatalsværdier vil blive trunkeret" + +#: builtin.c:3136 +#, c-format +msgid "dcgettext: `%s' is not a valid locale category" +msgstr "dcgettext: '%s' er ikke en gyldig lokalitetskategori" + +#: eval.c:412 +#, c-format +msgid "unknown nodetype %d" +msgstr "ukendt nodetype %d" + +#: eval.c:423 eval.c:437 +#, c-format +msgid "unknown opcode %d" +msgstr "ukendt opkode %d" + +#: eval.c:434 +#, c-format +msgid "opcode %s not an operator or keyword" +msgstr "opkode %s er ikke en operator eller et nøgleord" + +#: eval.c:488 +msgid "buffer overflow in genflags2str" +msgstr "bufferoverløb i genflags2str" + +#: eval.c:698 +#, c-format +msgid "" +"\n" +"\t# Function Call Stack:\n" +"\n" +msgstr "" +"\n" +"\t# Funktionskaldsstak:\n" +"\n" + +#: eval.c:725 +msgid "`IGNORECASE' is a gawk extension" +msgstr "'IGNORECASE' er en gawk-udvidelse" + +#: eval.c:754 +msgid "`BINMODE' is a gawk extension" +msgstr "'BINMODE' er en gawk-udvidelse" + +#: eval.c:812 +#, c-format +msgid "BINMODE value `%s' is invalid, treated as 3" +msgstr "BINMODE værdi '%s' er ugyldig, behandles som 3" + +#: eval.c:902 +#, c-format +msgid "bad `%sFMT' specification `%s'" +msgstr "forkert '%sFMT'-specifikation '%s'" + +#: eval.c:980 +msgid "turning off `--lint' due to assignment to `LINT'" +msgstr "deaktiverer '--lint' på grund af en tildeling til 'LINT'" + +#: eval.c:1127 eval.c:1777 +#, c-format +msgid "can't use function name `%s' as variable or array" +msgstr "kan ikke bruge funktionsnavnet '%s' som variabel eller array" + +#: eval.c:1158 eval.c:1789 eval.c:1802 +#, c-format +msgid "reference to uninitialized argument `%s'" +msgstr "reference til ikke-initieret argument '%s'" + +#: eval.c:1177 +msgid "attempt to field reference from non-numeric value" +msgstr "forsøg på at referere til et felt fra ikke-numerisk værdi" + +#: eval.c:1179 +msgid "attempt to field reference from null string" +msgstr "forsøg på at referere til et felt fra tom streng" + +#: eval.c:1185 +#, c-format +msgid "attempt to access field %ld" +msgstr "forsøg på at få adgang til felt %ld" + +#: eval.c:1194 +#, c-format +msgid "reference to uninitialized field `$%ld'" +msgstr "reference til ikke-initieret felt '$%ld'" + +#: eval.c:1256 +#, c-format +msgid "function `%s' called with more arguments than declared" +msgstr "funktionen '%s' kaldt med flere argumenter end deklareret" + +#: eval.c:1437 +#, c-format +msgid "unwind_stack: unexpected type `%s'" +msgstr "unwind_stack: uventet type `%s'" + +#: eval.c:1532 +msgid "division by zero attempted in `/='" +msgstr "forsøgte at dividere med nul i '/='" + +#: eval.c:1539 +#, c-format +msgid "division by zero attempted in `%%='" +msgstr "forsøgte at dividere med nul i '%%='" + +#: eval.c:1876 eval.c:2122 +#, c-format +msgid "attempt to use array `%s[\"%.*s\"]' in a scalar context" +msgstr "forsøg på at bruge array '%s[\"%.*s\"]' i skalarsammenhæng" + +#: eval.c:1907 +msgid "assignment used in conditional context" +msgstr "tildeling brugt i sammenligningsammenhæng" + +#: eval.c:1911 +msgid "statement has no effect" +msgstr "kommandoen har ingen effekt" + +#: eval.c:2343 +#, c-format +msgid "for loop: array `%s' changed size from %ld to %ld during loop execution" +msgstr "" +"for-løkke: array '%s' ændrede størrelse fra %ld til %ld under udførelse af " +"løkken" + +#: eval.c:2458 +#, c-format +msgid "function called indirectly through `%s' does not exist" +msgstr "funktion kaldt indirekte via '%s' eksisterer ikke" + +#: eval.c:2470 +#, c-format +msgid "function `%s' not defined" +msgstr "funktionen '%s' er ikke defineret" + +#: eval.c:2511 +#, c-format +msgid "non-redirected `getline' invalid inside `%s' rule" +msgstr "ikke-omdirigeret 'getline' ugyldig inden i '%s'-regel" + +#: eval.c:2600 +#, c-format +msgid "error reading input file `%s': %s" +msgstr "fejl ved læsning af inddatafilen '%s': %s" + +#: eval.c:2614 +#, c-format +msgid "`nextfile' cannot be called from a `%s' rule" +msgstr "'nextfile' kan ikke kaldes fra en '%s'-regel" + +#: eval.c:2661 +msgid "`exit' cannot be called in the current context" +msgstr "'exit' kan ikke kaldes i den aktuelle kontekst" + +#: eval.c:2700 +#, c-format +msgid "`next' cannot be called from a `%s' rule" +msgstr "'next' kan ikke kaldes fra en '%s'-regel" + +#: eval.c:2766 +#, c-format +msgid "Sorry, don't know how to interpret `%s'" +msgstr "Véd desværre ikke hvordan '%s' skal fortolkes" + +#: ext.c:54 +msgid "extensions are not allowed in sandbox mode" +msgstr "udvidelser er ikke tilladt i sandkasse-tilstand" + +#: ext.c:60 ext.c:65 +msgid "`extension' is a gawk extension" +msgstr "'extension' er en gawk-udvidelse" + +#: ext.c:75 +#, c-format +msgid "fatal: extension: cannot open `%s' (%s)\n" +msgstr "atalt: extension: kan ikke åbne '%s' (%s)\n" + +#: ext.c:84 +#, c-format +msgid "" +"fatal: extension: library `%s': does not define " +"`plugin_is_GPL_compatible' (%s)\n" +msgstr "" +"fatalt: extension: bibliotek '%s': definer ikke " +"'plugin_is_GPL_compatible' (%s)\n" + +#: ext.c:93 +#, c-format +msgid "fatal: extension: library `%s': cannot call function `%s' (%s)\n" +msgstr "" +"fatalt: extension: bibliotek '%s': kan ikke kalde funktionen '%s' (%s)\n" + +#: ext.c:127 +msgid "extension: missing function name" +msgstr "extension: mangler funktionsnavn" + +#: ext.c:132 +#, c-format +msgid "extension: illegal character `%c' in function name `%s'" +msgstr "extension: ugyldigt tegn '%c' i funktionsnavn '%s'" + +#: ext.c:141 +#, c-format +msgid "extension: can't redefine function `%s'" +msgstr "extension: kan ikke omdefinere funktion '%s'" + +#: ext.c:145 +#, c-format +msgid "extension: function `%s' already defined" +msgstr "extension: funktionen '%s' er allerede defineret" + +#: ext.c:150 +#, c-format +msgid "extension: function name `%s' previously defined" +msgstr "extension: funktionsnavnet '%s' er defineret tidligere" + +#: ext.c:152 +#, c-format +msgid "extension: can't use gawk built-in `%s' as function name" +msgstr "extension: kan ikke bruge gawk's indbyggede '%s' som funktionsnavn" + +#: ext.c:156 +#, c-format +msgid "make_builtin: negative argument count for function `%s'" +msgstr "make_builtin: negativt argumentantal for funktion '%s'" + +#: ext.c:259 +#, c-format +msgid "function `%s' defined to take no more than %d argument(s)" +msgstr "funktionen '%s' defineret til at tage ikke mere end %d argumenter" + +#: ext.c:262 +#, c-format +msgid "function `%s': missing argument #%d" +msgstr "funktion '%s': mangler argument nummer %d" + +#: ext.c:279 +#, c-format +msgid "function `%s': argument #%d: attempt to use scalar as an array" +msgstr "" +"funktion '%s': argument nummer %d: forsøg på at bruge skalar som et array" + +#: ext.c:283 +#, c-format +msgid "function `%s': argument #%d: attempt to use array as a scalar" +msgstr "" +"funktion '%s': argument nummer %d: forsøg på at bruge array som en skalar" + +#: ext.c:296 +msgid "Operation Not Supported" +msgstr "Operationen understøttes ikke" + +#: field.c:328 +msgid "NF set to negative value" +msgstr "NF sat til en negativ værdi" + +#: field.c:951 field.c:958 field.c:962 +msgid "split: fourth argument is a gawk extension" +msgstr "split: fjerde argument er en gawk-udvidelse" + +#: field.c:955 +msgid "split: fourth argument is not an array" +msgstr "split: fjerde argument er ikke et array" + +#: field.c:969 +msgid "split: second argument is not an array" +msgstr "split: andet argument er ikke et array" + +#: field.c:973 +msgid "split: cannot use the same array for second and fourth args" +msgstr "split: kan ikke bruge det samme array som andet og fjerde argument" + +#: field.c:978 +msgid "split: cannot use a subarray of second arg for fourth arg" +msgstr "" +"split: kan ikke bruge et underarray af andet argument som fjerde argument" + +#: field.c:981 +msgid "split: cannot use a subarray of fourth arg for second arg" +msgstr "" +"split: kan ikke bruge et underarray af fjerde argument som andet argument" + +#: field.c:1010 +msgid "split: null string for third arg is a gawk extension" +msgstr "split: tom streng som tredje argument er en gawk-udvidelse" + +#: field.c:1050 +msgid "patsplit: fourth argument is not an array" +msgstr "patsplit: fjerde argument er ikke et array" + +#: field.c:1055 +msgid "patsplit: second argument is not an array" +msgstr "patsplit: andet argument er ikke et array" + +#: field.c:1061 +msgid "patsplit: third argument must be non-null" +msgstr "patmatch: tredje argument er ikke et array" + +#: field.c:1065 +msgid "patsplit: cannot use the same array for second and fourth args" +msgstr "patsplit: kan ikke bruge det samme array som andet og fjerde argument" + +#: field.c:1070 +msgid "patsplit: cannot use a subarray of second arg for fourth arg" +msgstr "" +"patsplit: kan ikke bruge et underarray af andet argument som fjerde argument" + +#: field.c:1073 +msgid "patsplit: cannot use a subarray of fourth arg for second arg" +msgstr "" +"patsplit: kan ikke bruge et underarray af fjerde argument som andet argument" + +#: field.c:1110 +msgid "`FIELDWIDTHS' is a gawk extension" +msgstr "'FIELDWIDTHS' er en gawk-udvidelse" + +#: field.c:1173 +#, c-format +msgid "invalid FIELDWIDTHS value, near `%s'" +msgstr "ugyldig FIELDWIDTHS værdi, nær '%s" + +#: field.c:1246 +msgid "null string for `FS' is a gawk extension" +msgstr "tom streng som 'FS' er en gawk-udvidelse" + +#: field.c:1250 +msgid "old awk does not support regexps as value of `FS'" +msgstr "gamle versioner af awk understøtter ikke regexp'er som værdi for 'FS'" + +#: field.c:1369 +msgid "`FPAT' is a gawk extension" +msgstr "'FPAT' er en gawk-udvidelse" + +#: getopt.c:604 getopt.c:633 +#, fuzzy, c-format +msgid "%s: option '%s' is ambiguous; possibilities:" +msgstr "%s: flaget '%s' er flertydigt\n" + +#: getopt.c:679 getopt.c:683 +#, c-format +msgid "%s: option '--%s' doesn't allow an argument\n" +msgstr "%s: flaget '--%s' tillader ikke noget argument\n" + +#: getopt.c:692 getopt.c:697 +#, c-format +msgid "%s: option '%c%s' doesn't allow an argument\n" +msgstr "%s: flaget '%c%s' tillader ikke noget argument\n" + +#: getopt.c:740 getopt.c:759 +#, c-format +msgid "%s: option '--%s' requires an argument\n" +msgstr "%s: flaget '--%s' kræver et argument\n" + +#: getopt.c:797 getopt.c:800 +#, c-format +msgid "%s: unrecognized option '--%s'\n" +msgstr "%s: ukendt flag '--%s'\n" + +#: getopt.c:808 getopt.c:811 +#, c-format +msgid "%s: unrecognized option '%c%s'\n" +msgstr "%s: ukendt flag '%c%s'\n" + +#: getopt.c:860 getopt.c:863 +#, c-format +msgid "%s: invalid option -- '%c'\n" +msgstr "%s: ugyldigt flag - '%c'\n" + +#: getopt.c:916 getopt.c:933 getopt.c:1143 getopt.c:1161 +#, c-format +msgid "%s: option requires an argument -- '%c'\n" +msgstr "%s: flaget kræver et argument - '%c'\n" + +#: getopt.c:989 getopt.c:1005 +#, c-format +msgid "%s: option '-W %s' is ambiguous\n" +msgstr "%s: flaget '-W %s' er flertydigt\n" + +#: getopt.c:1029 getopt.c:1047 +#, c-format +msgid "%s: option '-W %s' doesn't allow an argument\n" +msgstr "%s: flaget '-W %s' tillader ikke noget argument\n" + +#: getopt.c:1068 getopt.c:1086 +#, c-format +msgid "%s: option '-W %s' requires an argument\n" +msgstr "%s: flaget '-W %s' kræver et argument\n" + +#: io.c:280 +#, c-format +msgid "command line argument `%s' is a directory: skipped" +msgstr "kommandolinjeargument '%s' er et katalog, oversprunget" + +#: io.c:283 io.c:385 +#, c-format +msgid "cannot open file `%s' for reading (%s)" +msgstr "kan ikke åbne filen '%s' for læsning (%s)" + +#: io.c:501 +#, c-format +msgid "close of fd %d (`%s') failed (%s)" +msgstr "lukning af fd %d ('%s') mislykkedes (%s)" + +#: io.c:578 +msgid "redirection not allowed in sandbox mode" +msgstr "omdirigering ikke tilladt i sandkasse-tilstand" + +#: io.c:612 +#, c-format +msgid "expression in `%s' redirection only has numeric value" +msgstr "udtrykket i '%s'-omdirigering har kun numerisk værdi" + +#: io.c:618 +#, c-format +msgid "expression for `%s' redirection has null string value" +msgstr "udtrykket for '%s'-omdirigering har en tom streng som værdi" + +#: io.c:623 +#, c-format +msgid "filename `%s' for `%s' redirection may be result of logical expression" +msgstr "" +"filnavnet '%s' for '%s'-omdirigering kan være resultatet af et logisk udtryk" + +#: io.c:666 +#, c-format +msgid "unnecessary mixing of `>' and `>>' for file `%.*s'" +msgstr "unødig blanding af '>' og '>>' for filen '%.*s'" + +#: io.c:719 +#, c-format +msgid "can't open pipe `%s' for output (%s)" +msgstr "kan ikke åbne datakanalen '%s' for udskrivning (%s)" + +#: io.c:729 +#, c-format +msgid "can't open pipe `%s' for input (%s)" +msgstr "kan ikke åbne datakanalen '%s' for indtastning (%s)" + +#: io.c:752 +#, c-format +msgid "can't open two way pipe `%s' for input/output (%s)" +msgstr "kan ikke åbne tovejsdatakanalen '%s' for ind-/uddata (%s)" + +#: io.c:834 +#, c-format +msgid "can't redirect from `%s' (%s)" +msgstr "kan ikke omdirigere fra '%s' (%s)" + +#: io.c:837 +#, c-format +msgid "can't redirect to `%s' (%s)" +msgstr "kan ikke omdirigere til '%s' (%s)" + +#: io.c:888 +msgid "" +"reached system limit for open files: starting to multiplex file descriptors" +msgstr "" +"nåede systembegrænsningen for åbne filer: begynder at multiplekse " +"fildeskriptorer" + +#: io.c:904 +#, c-format +msgid "close of `%s' failed (%s)." +msgstr "lukning af '%s' mislykkedes (%s)." + +#: io.c:912 +msgid "too many pipes or input files open" +msgstr "for mange datakanaler eller inddatafiler åbne" + +#: io.c:934 +msgid "close: second argument must be `to' or `from'" +msgstr "close: andet argument skal være 'to' eller 'from'" + +#: io.c:951 +#, c-format +msgid "close: `%.*s' is not an open file, pipe or co-process" +msgstr "close: '%.*s' er ikke en åben fil, datakanal eller ko-proces" + +#: io.c:956 +msgid "close of redirection that was never opened" +msgstr "lukning af omdirigering som aldrig blev åbnet" + +#: io.c:1053 +#, c-format +msgid "close: redirection `%s' not opened with `|&', second argument ignored" +msgstr "" +"close: omdirigeringen '%s' blev ikke åbnet med '|&', andet argument ignoreret" + +#: io.c:1069 +#, c-format +msgid "failure status (%d) on pipe close of `%s' (%s)" +msgstr "fejlstatus (%d) fra lukning af datakanalen '%s' (%s)" + +#: io.c:1072 +#, c-format +msgid "failure status (%d) on file close of `%s' (%s)" +msgstr "fejlstatus (%d) fra fillukning af '%s' (%s)" + +#: io.c:1092 +#, c-format +msgid "no explicit close of socket `%s' provided" +msgstr "ingen eksplicit lukning af soklen '%s' angivet" + +#: io.c:1095 +#, c-format +msgid "no explicit close of co-process `%s' provided" +msgstr "ingen eksplicit lukning af ko-processen '%s' angivet" + +#: io.c:1098 +#, c-format +msgid "no explicit close of pipe `%s' provided" +msgstr "ingen eksplicit lukning af datakanalen '%s' angivet" + +#: io.c:1101 +#, c-format +msgid "no explicit close of file `%s' provided" +msgstr "ingen eksplicit lukning af filen '%s' angivet" + +#: io.c:1129 io.c:1184 main.c:794 main.c:831 +#, c-format +msgid "error writing standard output (%s)" +msgstr "fejl ved skrivning til standard ud (%s)" + +#: io.c:1133 io.c:1189 +#, c-format +msgid "error writing standard error (%s)" +msgstr "fejl ved skrivning til standard fejl (%s)" + +#: io.c:1141 +#, c-format +msgid "pipe flush of `%s' failed (%s)." +msgstr "datakanalsrensning af '%s' mislykkedes (%s)." + +#: io.c:1144 +#, c-format +msgid "co-process flush of pipe to `%s' failed (%s)." +msgstr "ko-procesrensning af datakanalen til '%s' mislykkedes (%s)." + +#: io.c:1147 +#, c-format +msgid "file flush of `%s' failed (%s)." +msgstr "filrensning af '%s' mislykkedes (%s)." + +#: io.c:1262 +#, c-format +msgid "local port %s invalid in `/inet'" +msgstr "lokal port %s ugyldig i '/inet'" + +#: io.c:1279 +#, c-format +msgid "remote host and port information (%s, %s) invalid" +msgstr "fjernvært og portinformation (%s, %s) ugyldige" + +#: io.c:1431 +#, c-format +msgid "no (known) protocol supplied in special filename `%s'" +msgstr "ingen (kendt) protokol opgivet i special-filnavn '%s'" + +#: io.c:1445 +#, c-format +msgid "special file name `%s' is incomplete" +msgstr "special-filnavn '%s' er ufuldstændigt" + +#: io.c:1462 +msgid "must supply a remote hostname to `/inet'" +msgstr "fjernmaskinenavn til '/inet' skal angives" + +#: io.c:1480 +msgid "must supply a remote port to `/inet'" +msgstr "fjernport til '/inet' skal angives" + +#: io.c:1526 +msgid "TCP/IP communications are not supported" +msgstr "TCP/IP-kommunikation understøttes ikke" + +#: io.c:1693 +#, c-format +msgid "could not open `%s', mode `%s'" +msgstr "kunne ikke åbne '%s', tilstand '%s'" + +#: io.c:1747 +#, c-format +msgid "close of master pty failed (%s)" +msgstr "lukning af master-pty mislykkedes (%s)" + +#: io.c:1749 io.c:1917 io.c:2074 +#, c-format +msgid "close of stdout in child failed (%s)" +msgstr "lukning af standard ud i underproces mislykkedes (%s)" + +#: io.c:1752 +#, c-format +msgid "moving slave pty to stdout in child failed (dup: %s)" +msgstr "" +"flytning af slave-pty til standard ud i underproces mislykkedes (dup: %s)" + +#: io.c:1754 io.c:1922 +#, c-format +msgid "close of stdin in child failed (%s)" +msgstr "lukning af standard ind i underproces mislykkedes (%s)" + +#: io.c:1757 +#, c-format +msgid "moving slave pty to stdin in child failed (dup: %s)" +msgstr "" +"flytning af slave-pty til standard ind i underproces mislykkedes (dup: %s)" + +#: io.c:1759 io.c:1780 +#, c-format +msgid "close of slave pty failed (%s)" +msgstr "lukning af slave-pty mislykkedes (%s)" + +#: io.c:1858 io.c:1920 io.c:2052 io.c:2077 +#, c-format +msgid "moving pipe to stdout in child failed (dup: %s)" +msgstr "" +"flytning af datakanal til standard ud i underproces mislykkedes (dup: %s)" + +#: io.c:1865 io.c:1925 +#, c-format +msgid "moving pipe to stdin in child failed (dup: %s)" +msgstr "" +"flytning af datakanalen til standard ind i underproces mislykkedes (dup: %s)" + +#: io.c:1885 io.c:2067 +msgid "restoring stdout in parent process failed\n" +msgstr "genskabelse af standard ud i forælderprocessen mislykkedes\n" + +#: io.c:1893 +msgid "restoring stdin in parent process failed\n" +msgstr "genskabelse af standard ind i forælderprocessen mislykkedes\n" + +#: io.c:1928 io.c:2079 io.c:2093 +#, c-format +msgid "close of pipe failed (%s)" +msgstr "lukning af datakanalen mislykkedes (%s)" + +#: io.c:1973 +msgid "`|&' not supported" +msgstr "'|&' understøttes ikke" + +#: io.c:2039 +#, c-format +msgid "cannot open pipe `%s' (%s)" +msgstr "kan ikke åbne datakanalen '%s' (%s)" + +#: io.c:2087 +#, c-format +msgid "cannot create child process for `%s' (fork: %s)" +msgstr "kan ikke oprette barneproces for '%s' (fork: %s)" + +#: io.c:2520 +#, c-format +msgid "data file `%s' is empty" +msgstr "datafilen '%s' er tom" + +#: io.c:2561 io.c:2569 +msgid "could not allocate more input memory" +msgstr "kunne ikke allokere mere hukommelse til inddata" + +#: io.c:3127 +msgid "multicharacter value of `RS' is a gawk extension" +msgstr "'RS' som flertegnsværdi er en gawk-udvidelse" + +#: io.c:3232 +msgid "IPv6 communication is not supported" +msgstr "IPv6-kommunikation understøttes ikke" + +#: main.c:366 +msgid "`-m[fr]' option irrelevant in gawk" +msgstr "'-m[fr]'-flaget er irrelevant i gawk" + +#: main.c:368 +msgid "-m option usage: `-m[fr] nnn'" +msgstr "brug af flaget -m: '-m[fr] nnn'" + +#: main.c:391 +msgid "empty argument to `-e/--source' ignored" +msgstr "tomt argument til '-e/--source' ignoreret" + +#: main.c:462 +#, c-format +msgid "%s: option `-W %s' unrecognized, ignored\n" +msgstr "%s: flaget '-W %s' ukendt, ignoreret\n" + +#: main.c:515 +#, c-format +msgid "%s: option requires an argument -- %c\n" +msgstr "%s: flaget kræver et argument -- %c\n" + +#: main.c:536 +msgid "environment variable `POSIXLY_CORRECT' set: turning on `--posix'" +msgstr "miljøvariablen 'POSIXLY_CORRECT' sat: aktiverer '--posix'" + +#: main.c:542 +msgid "`--posix' overrides `--traditional'" +msgstr "'--posix' tilsidesætter '--traditional'" + +#: main.c:553 +msgid "`--posix'/`--traditional' overrides `--non-decimal-data'" +msgstr "'--posix'/'--traditional' tilsidesætter '--non-decimal-data'" + +#: main.c:557 +#, c-format +msgid "running %s setuid root may be a security problem" +msgstr "at køre %s setuid root kan være et sikkerhedsproblem" + +#: main.c:562 +msgid "`--posix' overrides `--binary'" +msgstr "'--posix' tilsidesætter '--binary'" + +#: main.c:613 +#, c-format +msgid "can't set binary mode on stdin (%s)" +msgstr "kan ikke sætte binær tilstand på standard ind (%s)" + +#: main.c:616 +#, c-format +msgid "can't set binary mode on stdout (%s)" +msgstr "kan ikke sætte binær tilstand på standard ud (%s)" + +#: main.c:618 +#, c-format +msgid "can't set binary mode on stderr (%s)" +msgstr "kan ikke sætte binær tilstand på standard fejl (%s)" + +#: main.c:657 +msgid "no program text at all!" +msgstr "ingen programtekst overhovedet!" + +#: main.c:734 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] -f progfile [--] file ...\n" +msgstr "Brug: %s [flag i POSIX- eller GNU-stil] -f progfil [--] fil ...\n" + +#: main.c:736 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] [--] %cprogram%c file ...\n" +msgstr "Brug: %s [flag i POSIX- eller GNU-stil] %cprogram%c fil ...\n" + +#: main.c:741 +msgid "POSIX options:\t\tGNU long options: (standard)\n" +msgstr "POSIX-flag:\t\tlange GNU-flag: (standard)\n" + +#: main.c:742 +msgid "\t-f progfile\t\t--file=progfile\n" +msgstr "\t-f progfil\t\t--file=progfil\n" + +#: main.c:743 +msgid "\t-F fs\t\t\t--field-separator=fs\n" +msgstr "\t-F fs\t\t\t--field-separator=fs\n" + +#: main.c:744 +msgid "\t-v var=val\t\t--assign=var=val\n" +msgstr "\t-v var=værdi\t\t--assign=var=værdi\n" + +#: main.c:745 +msgid "Short options:\t\tGNU long options: (extensions)\n" +msgstr "POSIX-flag:\t\tlange GNU-flag: (udvidelser)\n" + +#: main.c:746 +msgid "\t-b\t\t\t--characters-as-bytes\n" +msgstr "\t-b\t\t\t--characters-as-bytes\n" + +#: main.c:747 +msgid "\t-c\t\t\t--traditional\n" +msgstr "\t-c\t\t\t--traditional\n" + +#: main.c:748 +msgid "\t-C\t\t\t--copyright\n" +msgstr "\t-C\t\t\t--copyright\n" + +#: main.c:749 +msgid "\t-d[file]\t\t--dump-variables[=file]\n" +msgstr "\t-d[fil]\t\t--dump-variables[=fil]\n" + +#: main.c:750 +msgid "\t-e 'program-text'\t--source='program-text'\n" +msgstr "\t-e 'programtekst'\t--source='programtekst'\n" + +#: main.c:751 +msgid "\t-E file\t\t\t--exec=file\n" +msgstr "\t-E fil\t\t\t--exec=fil\n" + +#: main.c:752 +msgid "\t-g\t\t\t--gen-pot\n" +msgstr "\t-g\t\t\t--gen-pot\n" + +#: main.c:753 +msgid "\t-h\t\t\t--help\n" +msgstr "\t-h\t\t\t--help\n" + +#: main.c:754 +msgid "\t-L [fatal]\t\t--lint[=fatal]\n" +msgstr "\t-L [fatal]\t\t--lint[=fatal]\n" + +#: main.c:755 +msgid "\t-n\t\t\t--non-decimal-data\n" +msgstr "\t-n\t\t\t--non-decimal-data\n" + +#: main.c:756 +msgid "\t-N\t\t\t--use-lc-numeric\n" +msgstr "\t-N\t\t\t--use-lc-numeric\n" + +#: main.c:757 +msgid "\t-O\t\t\t--optimize\n" +msgstr "\t-O\t\t\t--optimize\n" + +#: main.c:758 +msgid "\t-p[file]\t\t--profile[=file]\n" +msgstr "\t-p[fil]\t\t--profile[=fil]\n" + +#: main.c:759 +msgid "\t-P\t\t\t--posix\n" +msgstr "\t-P\t\t\t--posix\n" + +#: main.c:760 +msgid "\t-r\t\t\t--re-interval\n" +msgstr "\t-r\t\t\t--re-interval\n" + +#: main.c:762 +msgid "\t-R file\t\t\t--command=file\n" +msgstr "\t-R file\t\t\t--command=fil\n" + +#: main.c:763 +msgid "\t-S\t\t\t--sandbox\n" +msgstr "\t-S\t\t\t--sandbox\n" + +#: main.c:764 +msgid "\t-t\t\t\t--lint-old\n" +msgstr "\t-t\t\t\t--lint-old\n" + +#: main.c:765 +msgid "\t-V\t\t\t--version\n" +msgstr "\t-V\t\t\t--version\n" + +#: main.c:767 +msgid "\t-W nostalgia\t\t--nostalgia\n" +msgstr "\t-W nostalgia\t\t--nostalgia\n" + +#: main.c:770 +msgid "\t-Y\t\t--parsedebug\n" +msgstr "\t-Y\t\t--parsedebug\n" + +#. TRANSLATORS: --help output 5 (end) +#. TRANSLATORS: the placeholder indicates the bug-reporting address +#. for this application. Please add _another line_ with the +#. address for translation bugs. +#. no-wrap +#: main.c:779 +msgid "" +"\n" +"To report bugs, see node `Bugs' in `gawk.info', which is\n" +"section `Reporting Problems and Bugs' in the printed version.\n" +"\n" +msgstr "" +"\n" +"For at rapportere fejl kan du se punktet 'Bugs' i 'gawk.info', som er\n" +"sektionen 'Reporting Problems and Bugs' i den trykte version.\n" +"\n" +"Rapportér kommentarer til oversættelsen til .\n" + +#: main.c:783 +msgid "" +"gawk is a pattern scanning and processing language.\n" +"By default it reads standard input and writes standard output.\n" +"\n" +msgstr "" +"gawk er et sprog til mønster-genkendelse og -behandling.\n" +"Almindeligvis læser gawk fra standard ind og skriver til standard ud.\n" +"\n" + +#: main.c:787 +msgid "" +"Examples:\n" +"\tgawk '{ sum += $1 }; END { print sum }' file\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" +msgstr "" +"Eksempler:\n" +"\tgawk '{ sum += $1 }; END { print sum }' fil\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" + +#: main.c:807 +#, c-format +msgid "" +"Copyright (C) 1989, 1991-%d Free Software Foundation.\n" +"\n" +"This program is free software; you can redistribute it and/or modify\n" +"it under the terms of the GNU General Public License as published by\n" +"the Free Software Foundation; either version 3 of the License, or\n" +"(at your option) any later version.\n" +"\n" +msgstr "" +"Copyright © 1989, 1991-%d Free Software Foundation.\n" +"\n" +"Dette program er frit programmel. Du kan distribuere det og/eller\n" +"ændre det under betingelserne i GNU General Public License, offentliggjort\n" +"af Free Software Foundation, enten version 3 af licensen, eller (hvis du " +"vil)\n" +"enhver senere version.\n" +"\n" + +#: main.c:815 +msgid "" +"This program is distributed in the hope that it will be useful,\n" +"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +"GNU General Public License for more details.\n" +"\n" +msgstr "" +"Dette program distribueres i håb om at det vil være nyttigt,\n" +"men UDEN NOGEN SOM HELST GARANTI, også uden underforstået garanti\n" +"om SALGBARHED eller EGNETHED FOR NOGET SPECIELT FORMÅL. Se GNU\n" +"General Public License for yderligere information.\n" +"\n" + +#: main.c:821 +msgid "" +"You should have received a copy of the GNU General Public License\n" +"along with this program. If not, see http://www.gnu.org/licenses/.\n" +msgstr "" +"Du bør have fået en kopi af GNU General Public License sammen\n" +"med dette program. Hvis ikke, så se http://www.gnu.org/licenses/.\n" + +#: main.c:856 +msgid "-Ft does not set FS to tab in POSIX awk" +msgstr "-Ft sætter ikke FS til tab i POSIX-awk" + +#: main.c:1090 +#, c-format +msgid "unknown value for field spec: %d\n" +msgstr "ukendt værdi for felt-spec: %d\n" + +#: main.c:1171 +#, c-format +msgid "" +"%s: `%s' argument to `-v' not in `var=value' form\n" +"\n" +msgstr "" +"%s: '%s' argument til '-v' ikke på formen 'var=værdi'\n" +"\n" + +#: main.c:1197 +#, c-format +msgid "`%s' is not a legal variable name" +msgstr "'%s' er ikke et gyldigt variabelnavn" + +#: main.c:1200 +#, c-format +msgid "`%s' is not a variable name, looking for file `%s=%s'" +msgstr "'%s' er ikke et variabelnavn, leder efter fil '%s=%s'" + +#: main.c:1204 +#, c-format +msgid "cannot use gawk builtin `%s' as variable name" +msgstr "kan ikke bruge gawk's indbyggede '%s' som variabelnavn" + +#: main.c:1209 +#, c-format +msgid "cannot use function `%s' as variable name" +msgstr "kan ikke bruge funktion '%s' som variabelnavn" + +#: main.c:1262 +msgid "floating point exception" +msgstr "flydendetalsundtagelse" + +#: main.c:1269 +msgid "fatal error: internal error" +msgstr "fatal fejl: intern fejl" + +#: main.c:1284 +msgid "fatal error: internal error: segfault" +msgstr "fatal fejl: intern fejl: segmentfejl" + +#: main.c:1296 +msgid "fatal error: internal error: stack overflow" +msgstr "fatal fejl: intern fejl: stakoverløb" + +#: main.c:1346 +#, c-format +msgid "no pre-opened fd %d" +msgstr "ingen fd %d åbnet i forvejen" + +#: main.c:1353 +#, c-format +msgid "could not pre-open /dev/null for fd %d" +msgstr "kunne ikke i forvejen åbne /dev/null for fd %d" + +#: msg.c:63 +#, c-format +msgid "cmd. line:" +msgstr "kommandolinje:" + +#: msg.c:107 +msgid "error: " +msgstr "fejl: " + +#: node.c:406 +msgid "backslash at end of string" +msgstr "omvendt skråstreg i slutningen af strengen" + +#: node.c:517 +#, c-format +msgid "old awk does not support the `\\%c' escape sequence" +msgstr "gamle versioner af awk understøtter ikke '\\%c' undvigesekvens" + +#: node.c:568 +msgid "POSIX does not allow `\\x' escapes" +msgstr "POSIX tillader ikke '\\x'-kontrolsekvenser" + +#: node.c:574 +msgid "no hex digits in `\\x' escape sequence" +msgstr "ingen heksadecimale cifre i '\\x'-kontrolsekvenser" + +#: node.c:596 +#, c-format +msgid "" +"hex escape \\x%.*s of %d characters probably not interpreted the way you " +"expect" +msgstr "" +"den heksadecimale sekvens \\x%.*s på %d tegn nok ikke forstået som du " +"forventer det" + +#: node.c:611 +#, c-format +msgid "escape sequence `\\%c' treated as plain `%c'" +msgstr "kontrolsekvensen '\\%c' behandlet som kun '%c'" + +#: node.c:750 +msgid "" +"Invalid multibyte data detected. There may be a mismatch between your data " +"and your locale." +msgstr "" +"Ugyldigt multibyte data fundet. Måske er der uoverensstemmelse mellem dine " +"data og dit locale." + +#: posix/gawkmisc.c:176 +#, c-format +msgid "%s %s `%s': could not get fd flags: (fcntl F_GETFD: %s)" +msgstr "%s %s '%s': kunne ikke få fat på fd flag: (fcntl F_GETFD: %s)" + +#: posix/gawkmisc.c:188 +#, c-format +msgid "%s %s `%s': could not set close-on-exec: (fcntl F_SETFD: %s)" +msgstr "%s %s '%s': kunne ikke sætte luk-ved-exec (fcntl F_SETFD: %s)" + +#: profile.c:83 +#, c-format +msgid "could not open `%s' for writing: %s" +msgstr "kunne ikke åbne '%s' for skrivning: %s" + +#: profile.c:85 +msgid "sending profile to standard error" +msgstr "sender profilen til standard fejl" + +#: profile.c:203 +#, c-format +msgid "" +"\t# %s block(s)\n" +"\n" +msgstr "" +"\t# %s blokke\n" +"\n" + +#: profile.c:208 +#, c-format +msgid "" +"\t# Rule(s)\n" +"\n" +msgstr "" +"\t# Regler\n" +"\n" + +#: profile.c:279 +#, c-format +msgid "internal error: %s with null vname" +msgstr "intern fejl: %s med null vname" + +#: profile.c:952 +#, c-format +msgid "\t# gawk profile, created %s\n" +msgstr "\t# profil til gawk oprettet %s\n" + +#: profile.c:1331 +#, c-format +msgid "" +"\n" +"\t# Functions, listed alphabetically\n" +msgstr "" +"\n" +"\t# Funktioner, listede alfabetisk\n" + +#: profile.c:1370 +#, c-format +msgid "redir2str: unknown redirection type %d" +msgstr "redir2str: uykendt omdirigeringstype %d" + +#: re.c:573 +#, c-format +msgid "range of the form `[%c-%c]' is locale dependent" +msgstr "område på formen `[%c-%c]' er locale-afhængig" + +#: re.c:600 +#, c-format +msgid "regexp component `%.*s' should probably be `[%.*s]'" +msgstr "regexp-komponent `%.*s' skulle nok være `[%.*s]'" + +#: regcomp.c:131 +msgid "Success" +msgstr "Lykkedes" + +#: regcomp.c:134 +msgid "No match" +msgstr "Mislykkedes" + +#: regcomp.c:137 +msgid "Invalid regular expression" +msgstr "Ugyldigt regulært udtryk" + +#: regcomp.c:140 +msgid "Invalid collation character" +msgstr "Ugyldigt sorteringstegn" + +#: regcomp.c:143 +msgid "Invalid character class name" +msgstr "Ugyldigt tegnklassenavn" + +#: regcomp.c:146 +msgid "Trailing backslash" +msgstr "Efterfølgende omvendt skråstreg" + +#: regcomp.c:149 +msgid "Invalid back reference" +msgstr "Ugyldig bagudreference" + +#: regcomp.c:152 +msgid "Unmatched [ or [^" +msgstr "Ubalanceret [ eller [^" + +#: regcomp.c:155 +msgid "Unmatched ( or \\(" +msgstr "Ubalanceret ( eller \\(" + +#: regcomp.c:158 +msgid "Unmatched \\{" +msgstr "Ubalanceret \\{" + +#: regcomp.c:161 +msgid "Invalid content of \\{\\}" +msgstr "Ugyldigt indhold i \\{\\}" + +#: regcomp.c:164 +msgid "Invalid range end" +msgstr "Ugyldig intervalslutning" + +#: regcomp.c:167 +msgid "Memory exhausted" +msgstr "Hukommelsen opbrugt" + +#: regcomp.c:170 +msgid "Invalid preceding regular expression" +msgstr "Ugyldigt foregående regulært udtryk" + +#: regcomp.c:173 +msgid "Premature end of regular expression" +msgstr "For tidligt slut på regulært udtryk" + +#: regcomp.c:176 +msgid "Regular expression too big" +msgstr "Regulært udtryk for stort" + +#: regcomp.c:179 +msgid "Unmatched ) or \\)" +msgstr "Ubalanceret ) eller \\)" + +#: regcomp.c:700 +msgid "No previous regular expression" +msgstr "Intet foregående regulært udtryk" + +#~ msgid "could not find groups: %s" +#~ msgstr "kunne ikke finde grupper: %s" + +#~ msgid "assignment is not allowed to result of builtin function" +#~ msgstr "tildeling er ikke tilladt til resultatet fra en indbygget funktion" + +#~ msgid "attempt to use array in a scalar context" +#~ msgstr "forsøg på at bruge array i skalarsammenhæng" + +#~ msgid "statement may have no effect" +#~ msgstr "kommandoen har måske ikke nogen effekt" + +#~ msgid "out of memory" +#~ msgstr "slut på hukommelsen" + +#~ msgid "attempt to use scalar `%s' as array" +#~ msgstr "forsøg på at bruge skalaren '%s' som array" + +#~ msgid "attempt to use array `%s' in scalar context" +#~ msgstr "forsøg på at bruge array '%s' i skalarsammenhæng" + +#~ msgid "call of `length' without parentheses is deprecated by POSIX" +#~ msgstr "kald af 'length' uden parenteser er forældet ifølge POSIX" + +#~ msgid "division by zero attempted in `/'" +#~ msgstr "forsøgte at dividere med nul i '/'" + +#~ msgid "length: untyped parameter argument will be forced to scalar" +#~ msgstr "length: parameter uden type vil blive brugt som skalar" + +#~ msgid "length: untyped argument will be forced to scalar" +#~ msgstr "length: argument uden type vil blive brugt som skalar" + +#~ msgid "`break' outside a loop is not portable" +#~ msgstr "'break' uden for en løkke er ikke portabelt" + +#~ msgid "`continue' outside a loop is not portable" +#~ msgstr "'continue' uden for en løkke er ikke portabelt" + +#~ msgid "`next' cannot be called from a BEGIN rule" +#~ msgstr "'next' kan ikke kaldes fra en BEGIN-regel" + +#~ msgid "`nextfile' cannot be called from a BEGIN rule" +#~ msgstr "'nextfile' kan ikke kaldes fra en BEGIN-regel" + +#~ msgid "" +#~ "concatenation: side effects in one expression have changed the length of " +#~ "another!" +#~ msgstr "" +#~ "konkatenering: sideeffekter i et udtryk har ændret længden af et andet!" + +#~ msgid "illegal type (%s) in tree_eval" +#~ msgstr "ugyldig type (%s) i tree_eval" + +#~ msgid "\t# -- main --\n" +#~ msgstr "\t# -- main --\n" + +#~ msgid "invalid tree type %s in redirect()" +#~ msgstr "ugyldig trætype %s i redirect()" + +#~ msgid "/inet/raw client not ready yet, sorry" +#~ msgstr "/inet/raw-klient er desværre ikke klar endnu" + +#~ msgid "only root may use `/inet/raw'." +#~ msgstr "kun root kan bruge '/inet/raw'." + +#~ msgid "/inet/raw server not ready yet, sorry" +#~ msgstr "/inet/raw-server er desværre ikke klar endnu" + +#~ msgid "file `%s' is a directory" +#~ msgstr "filen '%s' er et katalog" + +#~ msgid "use `PROCINFO[\"%s\"]' instead of `%s'" +#~ msgstr "brug 'PROCINFO[\"%s\"]' i stedet for '%s'" + +#~ msgid "use `PROCINFO[...]' instead of `/dev/user'" +#~ msgstr "brug 'PROCINFO[...]' i stedet for '/dev/user'" + +#~ msgid "\t-m[fr] val\n" +#~ msgstr "\t-m[fr] værdi\n" + +#~ msgid "\t-W compat\t\t--compat\n" +#~ msgstr "\t-W compat\t\t--compat\n" + +#~ msgid "\t-W copyleft\t\t--copyleft\n" +#~ msgstr "\t-W copyleft\t\t--copyleft\n" + +#~ msgid "\t-W usage\t\t--usage\n" +#~ msgstr "\t-W usage\t\t--usage\n" + +#~ msgid "can't convert string to float" +#~ msgstr "kan ikke konvertere en streng til flydende tal" + +#~ msgid "# treated internally as `delete'" +#~ msgstr "# behandlet internt som 'delete'" + +#~ msgid "# this is a dynamically loaded extension function" +#~ msgstr "# dette er en dynamisk indlæst udvidelsesfunktion" + +#~ msgid "" +#~ "\t# BEGIN block(s)\n" +#~ "\n" +#~ msgstr "" +#~ "\t# BEGIN-blok\n" +#~ "\n" + +#~ msgid "unexpected type %s in prec_level" +#~ msgstr "uventet type %s i prec_level" + +#~ msgid "Unknown node type %s in pp_var" +#~ msgstr "Ukendt nodetype %s i pp_var" diff --git a/po/de.gmo b/po/de.gmo new file mode 100644 index 0000000000000000000000000000000000000000..756fbf0f34830278e77706efdc0acd8bd6c71ebb GIT binary patch literal 52410 zcmd6w37nl(dH-KmWQqu=CQ14#~svI8xRiAHx z=YU-#F1!#_dRK!={}6aK_%2ZG{5v2~qQ3-}LJKDl_y(R=_PTa|J*fJA1XTD(LDl0s zp!)yuE23yWcqVv0co0;*-v+9ke-l(ceI9%^_~+nLz#oF@kN*Od&Y3G+|E&hk<#`*Z zb}xbI|2KiE$3y=4o1oG^VHIrxE&)})-QWq}tbcwv_&uKQ2Ss0RS?$XA0gp#KehEB@ z?|%#SgWvbqOXt3l=V|aV@ISyyz!lGP?UI0M&s#vz!QG(h`G=s&{|}(*(?ul3Th4zm zI1H-(uK-oQ_kc?ObD-k=98|hXE_LzOfvWE?7=yQhkVfiw%dei~Hyegdi-XI~LTM2Y%6 z-VEyfL!jvH&q3w?Gf?&DX7GxxcY)6VZvi2J=&klHmGtgd4UVR2~_({f@+Vqg6DvL z0Gi|Q7T5wTco`!uNd z-}28-+2s2FB2fLg4^(@-6cnHMFsSzaGf?sW16&85vDvlL^&W2l_5B^-3E-ze(bc11 z4E_kz_tUR(?R2@vGT6iWdqL6lm%ydqleaiJS^+Zjq9HH_-wLW-KMAUy-}3nMs~tV8 z2fKNHBdGju2TuS$3|i^e+8h0N7MYsO~ zD*f)=uHFa08qY5WRsa74DOwZ{y7HC5WjuczRJ(oyTn?VJ$My5&9uI(`!*pI z;Ai~vH~jaAOeW2oh1yp%{1m?htu5;n8 z^Y}7Q`F{XZ{(lTU9sDu)EbytK|ILEyz`H@E_m|)^z$e_~+Vj~ULngWkJQ=(bR6X7cD*P8f<^Mxa?f;x1_kAm< z?-fwr?*`Q`$H2?M|Ma*j@91jYG} z?gW+Jr$K%HZxEIjoj>9DdD-LZK&A5lsQ&mKsPa6g;PTxCs=Rej>AuUq{}QP7{~`EX zu=_=h-Zz387cTB ze}6{Nz0ZN_?_JD~vbJf8;70)GgqU!FGY>eB;?{x1jh{VMPjF!6X0RJyMMmF{~% zg?kv(c=}^d{q|i@<$KzTT{~Y6p2G7B!KZ=+Q018c&jH^AD*l7uso>|p82mF(>Hiqa zfu~nUhx%>=MPGZXQ3T0Gv*0%HZ@~+}J3)qg^il9C@U*(ie?O@2bx`HI z6IA)`1!M4|;OXGkz>C1|fy=>X9dzZ{=&=H-U)}|-1Rn+az@LC>hf8K$yqmy{JiiuH zdS3;N&OM%g$i>?V_VE1he}e6Rz>HRgRc0KWCSDy30r}MlG zRKE>@kYaQTxB~nx_-ydmx43>-1&YqE0lUFEcoO(FQ2D>#zyC6LCeJ?tMdzp7>dJdD zsCL*7D*f9*)&FB)4E_yx3HWnxGkD2u=uF_Pp!)ZA@O1utHHkqcY)7*rR(Q0 zQ2D+a6g_;=zyH6W%5m`>Zrtw&pU3l^;CbMqpwjzikMXNq{6SE3_Y&}Y@KfMA@NdBj z!1&d!Je$Fbd7cKJ3*G~s3myYij&Fmi=c%v31_HhSRQ%U~J>ZAI1pG6PYk%3jzXx2( z`!9lH;Ey~W_!am57`Tl0-v`eEPk*g@e=(@{2SAnM4p8-bKdAEjC8+wJ@H*G-SAyGl zemQsr_!Us~KI!$29yWsmJii81KYSTfxF3SzH@$CgxC0cOl)xLnd%=G232$^b0A9)S ztH8bBXF!$X%s07m?F296`DSnsd>^QC{lw!{Z;qn%Jii50I)4tT9H;-P;|IIJjXb{u z+y;IITmhbXr+eQID!n_v<>1#qmG^OXx%ZcW&(n8s6LifIF%fYXM zCxfT_n$w%k0k7uyMo{(m0I2eO4OBm#@m4oJ)`P0Y2zW90KJZfTFF^IvslV>z@kUVN z@^^ccU} zJ?{gr;r;7Dwd3D`O7Hadxbj`&@d5BE-aqNRuK#y{O7AXE_4y*W8$9tIm)-$zJHUt641q7?`F^kme8LAD-CP8&<9QNX3w{vP_wRuu5k38W*Iq}!13dp5I1281 zz|qq~pu+zZsP=l|2c2Hi2QJ}xHz+<*2bY8I2G0cl5Ih_FM=%CY_)XWZOF@0V9y|-I zgKDoggWJGkpz3wXhaBG;1vP$N5B7tf1Vump<-f1|EhkT|2hZpIdqB1C?|VG^!`Se6 zu6q0@Q0@$Ltg zgMR}mzhC;elaqVE3wWLd3*fsw{?aEL9o0eA^GhCo46f$6`;)GoF9dh+{Ay73{8R8* z;EA7d^*I+5eH6jdz^{U$k8go$r<0Dj^sWT^crN?r`$3iaufa>eQy+2sVKaCg&v$|Q zz<&wvf7|iZyF7jwRQsR!JC3d|1J%BVJRSqp{wM#gOZNrfAkVJ@mx12^MMuB%d#+tC z1ux_IW^e%f7$|!F2^fQCf7*px3qF_USAZ)2dqCCq>);spGmptp)=GH(BKSP;++&W< zUkmp0{1X5CY4BX0|Hiw%h zwckTv3_kU94tv3^JnsZA1>Xi<0sawq7I^aSyZ0A?&*ym@NuAiuMRivF?tfu z8@Nv3`88Zm_TLX?!l`d)is;hJyBBc(N4#6c_19eb6}jHa`>VN%T=&>p=Jg(bg?C&1 z{jA3~@a{Lc&gFSE_!98nx$0aW;Q0pdjr;d; z#eDl^@bO&V;r{zv8ngPniR*d1-^2w=iQdI^m@E7eZhnbxTZCK>_zzzN@8CVdI@$%E z4K4@un*ra-6?46oOMFFr-_QLRSD8z{Uk9H7-o^EF?)P%t$o(~3w{fX|f5deM*Hid* zIe0e+%dy{o^Z)#1CQyn7E9EF=13 zu7BYQzn6s@@Mr#B^Qz5UXL0?IcfaM|i~l{7clyC*qeK2)&p*|F{&$mq|2zH})?h!) z$M5IvCtUY(J$= z{nmKA5c~np8b|v57uVZ(Cw{S<>r$@$Trc7Zzl-?(Dz0zwVlDW7F8%7@8h2~|zuw=A zC%=R116=13W`ygX{kMC#Kg@NIXUT-{yPlh2t`~DH<@y-cXUX2ZS91R@e}6mp z>pV|!{T0_a{{89To4Bsv8s+^?@IzduaQ{)R+qi##>q74LaQ!mZB-eAe#(Doda0R#l ze3a|eTmwAc1nM`){RLbHxb*uT*I8Vv^}uhE_tW6pxxUNwKCTz~u-vA<_5SWxJkAp4 z=iG1Sy2gip0r&sG^%1VOa_RT_Oj;H0PvYGr;BSM!$JNF45YMjz`?*f${^eYM!2R1n z$+!tnzkT2bxo-B)zvl5uj|#JdYgy*`!+Oc@&$&+H{U!F~{(F%Rcej7{W}a{5O8omW z@Aq^6V{nrX^K0M}{Jr2zzDo|=?BBf*e4LN}Zty{#S8@Fl*BiM0p6gn!U**#8lRoT| zxqlMZQl9Vf?>@-$cJ8kRKh34z1ze;4yPkiQ`vc%QJ@C7XYctn}dH)WsFY6`0S8{(U z*DYL6;dvvd-^1X$!B>Evw>MGr8~)q*Jb%RBzYP2m&nJL)f=~4C&+~E4;Q6<>R{HlJ z_wNOt$=nyXpWvF|+Q#*#T&=&Sk;dg*FZUnb$o=(PSMogW-~9=AF7K}5((f{l&j5#b z{!6{|zlS_t%eQW>ukgGIJOlg$_+l>o{>?%31&<}({~`Cg!FPg(xW35s7hHeFHO%|# zxL(Ws8@XP}buw4>x0{D&arF@HU%@AUUjy$2d%yv%lepLK`QRQ{YtJX*WYqQC!QB~SL5Mgd1P{Fby-)JUhJ+Hlk{Oc zKQkFmSIT3BVzN9QsU-PYGD;jm<~E#o;)%K3NO}5jr7%8G)2o440quQqC>dF!C%xYk zk5%pMSRpBn=BmkbzLKw%D{ICqrET&4v3xCGyg>;T3#HorHSSq)cUZ)FHOUo6a;5rI zQYnn+{Z4ydo~{+93bU5WE_*Xwt`-g{!0tw2M#@uD`O;`wo(7<)+KlRTK7NA}LPmbIG1c*G<@9urDPYB-RgxTimQ)V9n$_&3x-nNSjw+3VF|}L6XEj{DS}ly1c(ONLQ5Q6~ zsa_gU)5II{#bP{I%a2U$aW96RZ@ytYFWFjt9yQ+!Hb!fLmFO{nox>0pf+43>;TpCYA zm2r9aMKqR$F2_r{t4rdsJTx{MFLi~au%mr(P3)qQj3qPkPjrQ)+kO7_METgj5C>Du9VX{lZ;E_31ho7tpN_HRNbil5Llxm?^skzHuoBW)b_#)l#Z z{h8JaaxBkS`})pr4xGy!ci>9$;(DQyh#J%OX-RY+m0x@jTxcqkpBgTV*UNR^aG^r* zJtenbzC%7>y;Mm?%Ht(C@aXcGab2z?40-j1PqI@|YTj;`_#%QedZAil0FJ{1AklnL zqpg^SrWt4&Z`Jy6wN|LrYY9{?`i+yZF-Nf?OGx;pDus;KK&Q(+@uV+YNwRebrFT6% z&v)z8uBfMa7~V7mg$7P$BS-|n7=enttkJMYqTHsM5si_!hVrICQ8C3-&|NzRx4bac z*vL(Va@4E&@q~ero7z8CxgjoPmXhRU;@zM>;;#HSlcKLGtzkF2={UZ@f7vS!eI64;Kp~@wUPU)q{nRuijKAXx!n$T?#%|L9d9D0^civ zZ^svh418+K<8q~IX}+cc!@6z!FQb%)p)Ya648I>Zl%JYLME7-_Xo^wK&CuOce9@Zt z{8jO-SHuH5HpVwQL17>BNm}2UXj#BR!k!iXBaeFb{)JF(J(bt zFCp5D4biHiqiTIx;w>4Cws=`HjD)0R$C64?8cEXEsR9BgB-OYCM{j&A7palBTN*6$ z4cS(zsc8<}eBjpf{ZzeJD@c)vr4PiT$OrVB(cX9uO`610`NQ!r{Si+Us#EzIQWd#8 zlO!eAm=;HZ)S4D8Gha-4)3m2y9nc128i`Ra<|~jd?@$k*-%!ztBv71`8ddKQczZHc zt{f)%L>@6mGws-f5>V5aDkbC88L?*rA=*)<%#>3%wKbW?^ z8=Dej)-jIbYjj1OzZ^K!6DQS?{B%<79HML)F&>64yl{?0vO(5_Fpf^EeJ7r%aZ)VP zis4nf6vdTcS{X&Q?W!bHxK3ZuhU(r9&9}R)`DwXwjDUy+C!|(|lsjgY@*E}*(O|h! zIlLU^COJP@LL5$T(GR8|(&9DaMbTh=WQ3lM_H5X-V#}^(s)w6V+-ACO zV1jmnaWIhKDKiE1NGOwO!&tqzybI$hy%vgbNDM!aduo*e^&gYl-FyW{?N zSO4xkTQ=<7*1tR6wRbnPFwh&vgYZLA?3#y@NjZde8D2>ZeX1(0a!-Xj4GRtOD&u$} z+FLTJrBq9m_kpFEH_PnJvdo+Pdb9t=%$ox@vj@l|2NJxcQ&!WFZRHy&mui)AF)k)GBtbT!6RX|hl6#^a4J_kS>d>L?ZmGLcR`a#!Mt!kB z`evmrmy#%mdYs4|( zl#a{vL(p*%pZPR7CnG{!C7P$c<7il6M%pPv(>G>j{J7=^R)Zn#j&R}K@u^XJT5Ium9Ep|f9_lWd*bDxzsqWbKsx zLZy-vlY-6amy+-mLU;wKfEp|dfX!yGXhlOl*t|i?wK4@O zTU-VfT&gmK{5ZEO8k(@&7u6ZX;|Q9R#%mMJZPz+_OEf@-<{GP%r|8*C4P8J)p0y>M z-p%u)A$`!WTy!cfFr?8=@{P1QWQ2ULS4uq+yA4uGr$lLw-g1GP-KQKO%F70(Nxie0 zIOR%nUMBfbz6f=X9;RBb)YN`*^ zD$LJh!)%SxtS9;i<5C=%yBKFjGesG$Dqw#%I3xV2xrdoN8+8 zbG6MzNHy{pt%(*3^qT&3g65X^Noxm%dex|RgM8kD#R@flW zgvMk_q{*<@n{jwG*+deQ;s--T6B|A01}`Vy&R16$onGDmfjLFt-GAB5t)J%Bl(P|C5RVABz=Rovg zCX>!#s7f}F`YP=R8F5^BAjMSirqA3s^-{yF&0*Rpz(kmQX?krf>uN$DPr3yKAKv=3 z(MY0!);@&>K0!zCccbHuUqb)OL}rGB87fr5Fd(xamdMdYB23Fs4d%=P z(x8_7bKTJ~H^Qjb=MJQG5qPI5lcv=(Ytleer!98_f=(ML=X`Iw(n(S|B3Cu6p+i5S zliAF92>nYl5#N(iZ~>p)f0_OVK)>T?28(OX6dV5 zolvJ+zl4#OX)!wAt=?MPRB3Wmvr@V0VgaPolZEMNbyOKEj#R>B?b=`mWiT7OSrc@D zJ1T+}X%598RqaN~EQNH`7BfM@YM>@z(oUU8s8AC3oHE-c6$*ij2CQE-W@jqsD=FWc zKaj?Mr-YU}mZmf_pE1_uEUy)#$-xy`JadYe24G~C-3Ird8*E7}8XaMprD>aA)Z>GZ zu9ORwNSz57MYooW(_fLBI`&EWuwg4D4JTHi1w9?LTmVA0K6!~MG*BC}TOmMsI}NOc^_B`dbg)nyI74PP+;-hf8+Pu-ZXp#Wp`SJ569tOf1Zz!% zV5Im#pg2lS$;H*(LIm;+7VFqWG%@3D+d^cez6I%vBWGf#JTIQt_}`ykxS% zCYLmpU(>T`7TOqb%;MM35Nw#xk8bTRglm?%G9lUkL#8#U78EOun0{~}{k%IE7&`@Q zC@0j-mQ$!ihX~l?&8XPWiHFoh6e`U#O)6U=7M7}_uBK3p0Gh10wF2?ZPHU}_BwGG} z!fLGbEbSh}VD5xyoN5(TT_d_Vf}3#a7@R#qj%dZjG;YIlWLuazf0K9}H!iY3DD8wv z=L0S*16Gly3a|~c{A5go*`Q*?jc|@B@LVWcB!r2q)gkF^os)J;2c0r- z_Oa$X=-s&^6pu3p*d9!(&TO42ay$-i5m!S`Ls=`U7aE&yWLL5^oWLrpp-PE=;ML#5iUNbi~?8VJ;Q#rich&sn_OlF;CKTmwK%D5)bQg+$~#(BKNwdhhe!mK{2MA^1O z4VpJ38bGQC8|~8M8WR*wMFw(Yo7U192A9f%()rTG%TH3R`iz+fKY?EFd z!Rq!}1{KTfUCrtGLS~BX>)|FF#ltP-2;pgu6#_ng?54bGi$}_7*fn4>q=@2FNNA=?B-OncZ-1X)yh+{?111Y;Lk5r*Tqi zTWj%yw?&b%s` zU{dB)>jQ^mix6jlm{TRr_J0kt$amOyZo0{Xfu^NA8SbsJraaF0ViW0uA_{`IS#f3++3Ea9umsz>$SMt_rm;P#Fy3F#KrV%BznqxzNX3tO)Js*f^^5uwo|ye z2GO#pJ$OemYHRq0#dh&|w8mK=Bkh%Ja4>5gwbjt>IW~vb=1TZ8mC`NLH?wdD5`Hsvg-HCh-i zaP~q>s<8z#wGXL$=<#OWL{!$rCd<83A~7XBy+~lPG{Sz zMZs))iZ%@UO&TT_f)taAziAGt@jIt78_3=6R3@^}-zdY?c7VgOjoDYD`6IBOnR7A& zo44$6wt9+$SqhuvJQ0~Q+3_v6X?4!@v%xT-&KZs^sn8apR?A!3uC75t_2-TuPUCER zEtbFeqf91;8Bp|Lfjug2{u4Vp$PlcQ{H8~AYzQgmnP6H2I>bjNP^kQksRcvh2l)tj zKykjF*??;n2w6E^u~%-2k;;b!MP9iwhX863R&$1H6;!CLRoKG3yI0t)gZ%*6Wz*zF z3eh4WH$q$Fu{5pDkwq9)t(Q7QM*=dWfJ)qmUCl&qymgyI!kR^pfsImzq{1$xxkI+7 z*1^Uk&Y*!F8IPN1%J1#fwoet>DaAHIHD49Wuq6Y(krp256mTuLxw8dJ@cZ5{Q&7lx zY!6{4Y(~?rMsCBC7xPlm;I!Yc%z)6{L5 z_Ap8V^TO;q8@qE@gBu%ZC5~rleAyHOz zS6B4N1T;zK7O-CA;|)qu)m&~S5J%}9Vz$M*=%Pi%)W~d_y~l@TXyY()xs0Y+a*{w9 zwww%+L9>{Qp@||SZgVp0T%l*nb40Nt%8KKTpQ>gHg)}2;r2sV&GS#_kZf!c1PLs-J zE;?lGfX#>1Wein#a6trF<$SaB+Ekx)n{=eAxV;&6ezL1Mq}MR#3i_C)NR_r&ioqT!CS zySaupo7h5P8X_HHI&s`7oSBMl($uTEbQ#OpX5p;OaLC}?h~=s|Y8yCAq@9&EWU)hv z*)`4K!UnEj6KvZq#aMKU?b$C4>l1Pgc~MGcY{ywvn>TBnu?^+Hav z%toiRitqNAijkH^mK}4|q z&5Z9Wr8W8UY(|8t^G&s=VK9?a$n0)K`)@4WTQF%K&QwN6X<}%)3?oRpR(PYSM1t({ zVMwpJoQQ{FeOZU3oLG(5u3_y_NYjVbG{M$v8#`!tM5!hS(HG7(?9CZNS#qvb*tWzB8=`0^LV6n7wq*x@ z9;(jq4%zCdqn98WJ|e}{Kr2Hkk$X7pA^TS=8b!jQ*#XXH1hD5_Ph znokuDsmrC)t?e-tYiKPuE}AS9wiA*l7}cjZ8>Rv}HMY|`4N+fa8J#)?;k&oU4;>)K zc_R2ush4ILUpGOEI46lS4P|X$lLjrks|p9=^EfeyMvWy;YPODAIX%%2Y3YwT8Ws5% z>9)D0H!UIN67)zXpg9UPVoMEJJrf43+azr#=Bp!|8*L=OVy$hwd#ovlG5FO1EqdtO z4JTlwVX@)lP_w;ZG3RSqqNE~kK@$ZLTLy6ugUw7;g_YUR_9h;oLhZayn1!t%8M^rxq9VF0_JwJ8%nzto5HQiUA!`0b!p$~RTr&X zMYwISu^i`pOIVtjF7(B_*uKpUR*u(~*~c7TIbEArSA|G=N0YULc1wV{JxPA559bKX zK1%VGI-jKY%B;p0T==Y$;#%!>e3(JRvLP!qjTHKra(8XtvVEY@9;HTBw9?y^QW<;=V{H-IiF-MTNnY`7rzLgrU$eeu}Cm}psX zlv^o8PO;SFSSm-qFg};FM`|{yk862J-hw*%l~QXL%(0L;ma<0$-V|?Q+Q?2nn2Ga7 zWYg`8i>b_aMfl(HHPtAfCeEm7Ytl0Q|KM#Z-fzX}=x@q>QRConiawFUsVVh-#^F@< zwL*?bN!+}!qErVz2Kwd zi`95*ewsD>B0=VHP~}pQ3l+BORO%y>Du!os=%KREvFPv0q{=AdvA5%ynH2bzgKr=^Aknw92h(HNX8r1(Iee7 zLSMX*CfdpfrZAL4N5G9FxtY|8HfF(ivRo2xigArH!NSb&c!CguWuSUd_Kf$dHrH7p z6I-p0;>n&1*KZWA~u1_SdVUm1B>696oyFTEC%cjfNKl=^Q4B^CAb$FghFO>+BtA z^3$c%tbTatQBl$g788Btn^QNOXJ5LVXX`L+UZX2<4=mhj*zp}AT)B? z`tG&J%tugYtDO9WOsXT(YIg`LCr{MAJuKs2E!Lc{f^vY5g(g)>ogG@VLum7(wdk}% zXjO13nIH#t-i^~WVvDc4KG$t1gw%rz6cA6PMSTX(2WTV6Q$m^+h}mZ5{@3EUSC z&{l(PqAwPNZE99qm_qXzCECO^IQsH^SBeKXIBA2YFW$o##MDw6uN-^$*gJ#AFVSN5 zO+#I^_ON~)MD5gd4cj#1R0#ETd<=KL`RRT^G7{={zl#!-noIw zjEyxCNj-#V$ZGV6Y+a@N=z3J%F;lhSN#p_i6) znrF*|`0zf&9dkJJZW;{c(p8;4b`MoaLK51Bw>~LUrTb!4lxt_cRN@_4STzx26m@+f!Bv_pVo69c0jsh9l6hB&x0ELG zG@<&B+2Z@eMn2wbBAT5xkDT&!e zGSOBVhRxE@bR`~~w)Vll6O5XAS8Vi@(fcN00 zzChMW=b=lhQHKt)ex9v!dZc{povylRHs;(ceTtW=Aem{YJpcmNflIPN{5Eq0)`@=)vKz`Pv$f~-X4 zSCz-cq);=XV0@~8C5?44LuJ3b%gVj;svQII)dL#`;>`p5j@^FM?rj5G2KVgUvH1!= zo}f~^0b`%jCUx8d$T`|9>RJi&!_2XJCMvnEB7CeyPNol&asQ5u1KZa3@7_AFWshTx ziaCJ0BhrmG9eew39(D}uU{Ax~o-NzA@8S0PeFGb|_I3@n&X{OKvF$myw(%lYdzeG; zpoXAiti!y=B|O%rPSkLnrh*(;+RO-@hFz9MA8|Cyf-GwdB2j_`CBn6u0_?xBHGs5q zm&Spc-S~DxFPplXXWCX^=YuWhQlo|`-I)irFq3v3*laH3T(B)N1$kEuX`r8F63}F{ ziXTXIpfT~SWkis5ZF@T>$T#P3a~A)j+6^E&=rY-dn&J%wXmsN2e6-n5FRZNO=V>?w z6EkZ}fx8y(noTo{d@TnToy9fVq%)tU8aSS!u~p%lO&hkdj@gWl+M!NniFNcp6>iv= zMBwC3gt_!JL~+)J)^uY$!Pqp48e`tY+%2g_8MVk-E5i${&DICkZEYb5&T!1j=V_`I zN}rNm9VGCSE%B0Tn0dCP(x$XE7YNbWm}@f`^ZIAic9&;@ij&7d!dK!jTPt-8*Yp+J zoUG*NfTrDu_8m1Tbv(Sm#-Z>!bMjDj3yc=)NTQ*|Hpw6~R_FGO`07)bx`dmgWUOz_ z(}wA?^9RH*5ghikgkGU^nm%{TNoMb?%X3n3V$`;E1kIXaN;Ot1sz$?{z^#krRT=YC z+&hW$p^Q>G^jv0}|3V>g8n-}@hV!@u0&er)DZ6F>j_eteO?B|Dn?;IL$DGOeXqhpj zdZE_9=#s)13mqZ`y{pE9tZI);U>{*eZkXMqgh_&a2_#uCO~*5{QJseXw;-`VOV<9I4AMrRNv6Gt^HcioVP4Wm8SrTxtR*(m~qemuulE*;`#m5jO>(b6g zpKD0SnH)hfOp&rVI?FbSCUctmvfJCuVW^Cc>e!7;YdL3#YlQWIWSefzBhM5(WODQY zVp_|~K-JdS!Q0&;>f!U5zd+7G9;sQdw!sxRcvB^Axgdmh!=s6lddGPiSu9G;Bw|&@ z@@4dhuF>phRLdu^7YR1+f&nm3VUIj5fuyo&R)m(F-HE&r*^BmPrcGC1?5Q!0|dwqh=|ALW;g9+NW|e$kkDF~F>NxWuu3?h&`l>ntTqn$!WSG*R1XlEl|D zqgIA4*sLjibBA-T>!_KtAdDv%<51sVRcaE`1}vwBX$}i>Lo#asxhyiR+D3!kYu~)N zxK!rJ#)`3sT-3pHG>+9Nc=S`axmqU^5Z`$7mirgfItyj<3u+#+SzP=0fb%!d^>wJL zstHZXj8f}Uxa`Kn0vDJ5SZvXrw_IRbF2ouN20{Sb@jrXSCYQ5Z)mRmi!yA z%*616r<ep z@u$&Xu^Gx?5R{_!NUExZ^K8bq9>z~ghZP(x1C}ORiZg+rW(hSdDYsDq|$Yaz`;AGl1_E`>mI>2QVGU5j!Lo9Q+?#j>fyan znp8QAc5JjsWk(~irI>(@KCmp>M6M8@l>rZiXe>;$u_E|FMZ3&<;ju>$EEu-OOk2)+ zFYLEvRoWl(XZtR)?T(2HN9lXRM|Tz=eEe85Ha0ERC^b(C z?Gidut67$px7jRu?(By-_N5B5n$2HWSWJC#E9NhfDm8DhP*tr^P9Jkich|yQ+MBUH zrLbD{&W63dzUZJEq1i!}g6LV<`qmdpW_9Hch@i*0PN%f2-kXU~lXpy@zQG&xG!k(MZ zDXdp|2a)Rg#w4F1dK}a^$584_x(ig)mK!9AG8T*W0X#}+)jzGqmi8KF8_!H1?THzw zF>@*;SdQFg4xf&?-gMv0T6J&K629Zk1$I5aK{dnEuDvWNmTWqe*d`^9t;B=P z4erm&OvPCuZf*KbMF<=q9be5!bZh{tzE)7Rzf@WV9fTJ#NDlKkONFrw1bGxfL9=$W zQMa|My=xj?!Rcn&YGJ6kNtTmkvYsD3vS0JKv?k$QdE5~k1# z&qpnh#mq>}z2_+1lh#ZW^3pDETR>ucTitX zNAgxJ8$69&TrsS$H8r!gHc1;bp!WM@eTins#kFlPX8RT1+*a%xcoZ$5;i7D4W9}C8 z#Y0*8409l#mMbO(XTL1FF?bopw-sYu^CP!FEh*tF+?|4ikJ5HYx!df=-d|}ZrPg4q ze^T>>!mUuS(J~wTvB7BIdhZ%yRP<%W>PowgITKC@&Y#lcuS4!LQ%p->>*}lFa&A+u zJm6tmDDj88yh)dJc=MrbEJ92M14jEUH>h6ylrh&>r_1i{HXc*V7Jg>o{Stx}AKa?K zy5N~~t9U_JS8`4m(Aia}CO%>`vlq1ztJQe*U}HvLOWO?xrD`T8aJ7-h_Q|BH4puO- zGr=MgS1s~eB!?54%W2%o*$+!6aUJbg`(;BnMwRA0lA1vlHEW|bG#3{!2(e5Q_Tg_T zYN^G!Ih}IkZZqt@6vQ%o%*E`o-$@)Tb>-?J*3ziE-q38}_#~Lb4JUo934-z%<9qNqXq7S@9L7F8`zma|OG_l>zhhL=iin!t1R(xjofhmHIbG+o>47E(8IIAa#+U)5 zD`c1%41L%u_)Dc_P7zM}AwDlFLVz?cLLFbq>6j<4xm?Cl6W7ri7ipQbO3NfJZ4OB? zoon}mg--~Ycm^9w&;#89u!5ONRt=SRO=?_0>?C-Tt>%YqPY!E98id7BR+-sH0qNv%d>EjSynY)ikU{!PLj=yHVc-uv}I@nG|^z6O*e0& z;-u|v3ebWPH1o{VpotsXnABt?V-m5m4;ISQJKq_Wjb!xPlHA6YCQ@N}&}2FqCVp&{ zMP_54AEhQGCN*Q_01u*Q0*{Iqv2qe1+MvKNqqcs``MtcH+_qwD_Ity%9?~uL(zG5Q zQqbBZUn2`ujr!A}*}kS={pR-j!kdCB5d~QqN+Cl4i5}Fh-^QXKw~b-n7RNeD5!DYi zOD6p6jBgb)l8GFS9$Cu3Zltq3?lSc~YxQ!2&6$D*nrX<@8t1>Yc42*hd!rxn-oRv3XZ9qw*XNIyHhG}}OVKRqS%vJ6{rxh(n z56aswY^f)FGn5`vigbieN~v1A&YxzenrTj@IP7$HwNo1DN{@z*HtCe=GJLm}PBM+7 z)SUYfk4|mEzR5C@swvg9zJZCiCu}+mbLWgnL%wrE$vq`=QZ+r_$xu@hx> zdN&1_FTRgTSFjO_Wda+a&I@m&X0{CECe(o}{3=g|<}>5cobZ}DZ;jiUzn|KNJrE7T zvi)5e%~p!RY5tNROJ1`u`9Y>$e!{BpHp(LEwJbDLP$RVYQB1;3n>jGB!%f1Z6LTco zI2HS6;cj7aYr&>%arcs~n>ZrXG!s4G*drxA zX-8Z(an&&00?q2SPmK=qa|>0-No}LubYG|Cmx`%AZ$JzDfj{HSWM8_64xcc!NDgsU zNIOL`HCCTV;M1bEsO^JYZ_|=a;i_pkw^$el68CF`j4#b%95qTS&uDc~D4HpzPR}rN z-xjrpl+ZBE=&st{Y4a%Jy#6wA@Tb=Z)%g3dW~#v+qCcS?cIsr#8+4kfsc2K_q&pK> zr!8nC$wk`>AGy`m443p2Zak~=*KAvEq(a3qtI@12%5_l~fi!tq8%Tlo<`Ed9mAM2C z=GRQ?2UoyzwO_kS-UZCP?GZw*W&$|AZAk5jUGL8dV9}9xVsB6LYi98Jg-yx9MX<&O zhQxVxH)TV1vi4`lY!3Ipev%_r6dD-LWZG9CZr^v2cmKPQQu(8*A%>B3XR7y+RFzJV zjAU$oMC$k#Umb`N_#>4!Q;s-*H%dZ1Ep{hwyULiIf&*cdv#Eehcd{kkyOyEWVeR)tc(!OC*MR0CJW){$MV((r0pvYI#5#jTzF!Ygz9*&cUo?L1fN z64|jhQ6~r52hmnjIoq~|B{h*lC1X0{D;7S(>^`SHwLe}IPA@~;PP*$@LpYTUA2Kdv z1Xseu&9ajIERXal&0*20qL%O}-|}&c$%U{3{-BzZE=&E<*aTmH2=iKblG7A2b)}P@ zbPq&olZZr07*O5G8QVea7nr4HHCEYp@SN3V&+|oVF^nxDe0G+(U~p7qbFSP{pe^ob zkv|gFY>YNx=~xsFnDe7ToFHah+JOs@~wiSLGgXWCX%j-+CQl12peld3uMrj4j|INii5pU7bb_ylcm^px%Tv;MdG)tg(2O z9*DF}10wt81m`O@-IPW@dgR9AZ|EBv?cD6MX#qW|Iq?5Lhmsc~HRAlbP6)Mtp3`u> zJU}xx3oJk377N9m!jAKX((@QLb1yO{SKfJYaz)7~D@<#fk1jNF5=pxRHEqJHoK+(e zH#3b_la6E8(j2tefD^U}G}0AyyROXjwZ zM2TjshFQ_mrWs*_j_6$DQ4%-ikXpI{TA;krduAm@>yByY_@e9>Q*}GpAELxdmJrLb zZ?cTaD7B!OGkC$4kZP=FCn{K20#$*eSZex8p8K6YY!y^`Y_M&o^Ln&D^InmjLD$54 z@Gz?Ilr100QJgjydHDzNnlgmHH`%?lIY>)*exkuS-nd0f5+ShmhEazpU{Fuuy_Kri zKJJAx4z$D9%#vyq_jQuF=^863FJ}3!X@j|weZiY{wUv&YxQ*5)9B`MpMrxKPn$|c2 z-nq7-G`3B1mOJA`Mq{B-H__x!CzhWn zPTkYy;^j7lV1dnf1-Ai}no3Lo*yk*zCMM;srpeex`NCv%0EMtpn)aJ{Ti9pU!bxT3 zYzrjS?(2I2oxw$5fwDM8HEna=|3GnQ&;EaId7#y;r`{aV0k3Nv~8?zY>4ThtD&E{TB(Hh&>)roF>+h}ha zWZ(|%2Uf)SR9k&%F&fXAit}WfdN5aw<>sNWy5s$rtKr)0F1{VaPSP<^9cws0vi&_y z<`R7n9U6f^-9@~Pp*ChoN~HaufkGCw2e9Sy#Ic7_$Xyy*64N-Iawk{V0K~Et73jPK zsTA?KhVH9hI8>XbfFQ9&n#Qq6BC;+t&a z3q+DIa+;+Nn4KuA_)f)ap}PgMnrqPdtjq^{6E%A$5hZtO)w^GB3L%jwv%?k)Tzt;)Y%7GknpU?>L>@yJA=I zZNtx($MBy(sZbr-SeNOo}B-WJUk5;ILSPh4ZiuCX&@-}brREUP{ONc`^U_Di*0iBWC#>#-x0!MXrpYS$eY&d?O zH(zbSMroFFg=|mTMrTbfv4o>a%jY{G8g9odFtbQ(7K|tM(febe?5rKesTO|(Tw~bx zR?E@S#@v(b+Wc`1v|>NAOedxCTIl}5n*75zCZlH8Gljv}ycht+b2c)v(;7$ddrPHb z51YGBCOC2pW4>A3I>K7YFMa#yk+r(DL~N?e8#nFp#^K>a3W91>NvCV+1YfEnMV1G7-(2E^M5w;fHF$b^Y-qoGGMery3jQ%ZY?|kl-?A#*f{@g*mI&kex%QdI6jU>nKibbeJyk{{TZvYjgkr literal 0 HcmV?d00001 diff --git a/po/de.po b/po/de.po new file mode 100644 index 0000000..b69e0c0 --- /dev/null +++ b/po/de.po @@ -0,0 +1,2215 @@ +# Deutsche Meldungen für GNU awk +# Copyright (C) 2000 Free Software Foundation, Inc. +# This file is distributed under the same license as the gawk package. +# +# Philipp Thomas , 2011 2012 +# +msgid "" +msgstr "" +"Project-Id-Version: gawk 4.0.0h\n" +"Report-Msgid-Bugs-To: arnold@skeeve.com\n" +"POT-Creation-Date: 2012-03-28 22:03+0200\n" +"PO-Revision-Date: 2012-01-30 16:21+0100\n" +"Last-Translator: Philipp Thomas \n" +"Language-Team: German \n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: array.c:140 +#, c-format +msgid "from %s" +msgstr "von %s" + +#: array.c:248 +msgid "attempt to use a scalar value as array" +msgstr "Es wird versucht, einen Skalar als Feld zu verwenden" + +#: array.c:251 +#, c-format +msgid "attempt to use function `%s' as an array" +msgstr "Es wird versucht, die Funktion »%s« als Feld zu verwenden" + +#: array.c:254 +#, c-format +msgid "attempt to use scalar parameter `%s' as an array" +msgstr "Es wird versucht, den skalaren Parameter »%s« als Feld zu verwenden" + +#: array.c:257 +#, c-format +msgid "attempt to use scalar `%s' as an array" +msgstr "Es wird versucht, den Skalar »%s« als Array zu verwenden" + +#: array.c:302 array.c:707 builtin.c:84 builtin.c:1385 builtin.c:1427 +#: builtin.c:1440 builtin.c:1859 builtin.c:1871 eval.c:1135 eval.c:1139 +#: eval.c:1495 eval.c:1812 +#, c-format +msgid "attempt to use array `%s' in a scalar context" +msgstr "Es wird versucht, das Feld »%s« in einem Skalarkontext zu verwenden" + +#: array.c:513 +#, c-format +msgid "reference to uninitialized element `%s[\"%.*s\"]'" +msgstr "Bezug auf ein nicht initialisiertes Element »%s[\"%.*s\"]«" + +#: array.c:519 +#, c-format +msgid "subscript of array `%s' is null string" +msgstr "Der Index von Feld »%s« ist ein Nullstring" + +#: array.c:723 +#, c-format +msgid "delete: index `%s' not in array `%s'" +msgstr "delete: Index »%s« ist in Feld »%s« nicht vorhanden" + +#: array.c:734 eval.c:1865 +#, c-format +msgid "attempt to use scalar `%s[\"%.*s\"]' as an array" +msgstr "Es wird versucht, den Skalar »%s[\"%.*s\"]« als Feld zu verwenden" + +#: array.c:910 +#, c-format +msgid "%s: empty (null)\n" +msgstr "%s: leer (Null)\n" + +#: array.c:915 +#, c-format +msgid "%s: empty (zero)\n" +msgstr "%s: leer (0)\n" + +#: array.c:919 +#, c-format +msgid "%s: table_size = %d, array_size = %d\n" +msgstr "%s: Tabellengröße = %d, Feldgröße = %d\n" + +#: array.c:954 +#, c-format +msgid "%s: is parameter\n" +msgstr "%s: ist ein Parameter\n" + +#: array.c:958 +#, c-format +msgid "%s: array_ref to %s\n" +msgstr "%s: Feld-Referenz auf %s\n" + +#: array.c:963 +msgid "adump: argument not an array" +msgstr "adump: Das Argument ist kein Feld" + +#: array.c:1086 +msgid "asort: second argument not an array" +msgstr "asort: Das zweite Argument ist kein Feld" + +#: array.c:1087 +msgid "asorti: second argument not an array" +msgstr "asorti: Das zweite Argument ist kein Feld" + +#: array.c:1094 +msgid "asort: first argument not an array" +msgstr "asort: Das erste Argument ist kein Feld" + +#: array.c:1095 +msgid "asorti: first argument not an array" +msgstr "asorti: Das erste Argument ist kein Feld" + +#: array.c:1102 +msgid "asort: cannot use a subarray of first arg for second arg" +msgstr "" +"asort: ein untergeordnetes Feld des ersten Arguments kann nicht als zweites " +"Argument verwendet werden" + +#: array.c:1103 +msgid "asorti: cannot use a subarray of first arg for second arg" +msgstr "" +"asorti: ein untergeordnetes Feld des ersten Arguments kann nicht als zweites " +"Argument verwendet werden" + +#: array.c:1108 +msgid "asort: cannot use a subarray of second arg for first arg" +msgstr "" +"asort: ein untergeordnetes Feld des zweiten Arguments kann nicht als erstes " +"Argument verwendet werden" + +#: array.c:1109 +msgid "asorti: cannot use a subarray of second arg for first arg" +msgstr "" +"asorti: ein untergeordnetes Feld des zweiten Arguments kann nicht als erstes " +"Argument verwendet werden" + +#: array.c:1655 +#, c-format +msgid "`%s' is invalid as a function name" +msgstr "»%s« ist ein unzulässiger Funktionsname" + +#: array.c:1659 +#, c-format +msgid "sort comparison function `%s' is not defined" +msgstr "Die Vergleichsfunktion »%s« für das Sortieren ist nicht definiert" + +#: awkgram.y:249 +#, c-format +msgid "%s blocks must have an action part" +msgstr "%s-Blöcke müssen einen Aktionsteil haben" + +#: awkgram.y:252 +msgid "each rule must have a pattern or an action part" +msgstr "Jede Regel muss entweder ein Muster oder einen Aktionsteil haben" + +#: awkgram.y:323 awkgram.y:334 +msgid "old awk does not support multiple `BEGIN' or `END' rules" +msgstr "Das alte awk erlaubt keine mehrfachen »BEGIN«- oder »END«-Regeln" + +#: awkgram.y:371 +#, c-format +msgid "`%s' is a built-in function, it cannot be redefined" +msgstr "»%s« ist eine eingebaute Funktion und kann nicht umdefiniert werden" + +#: awkgram.y:432 +msgid "regexp constant `//' looks like a C++ comment, but is not" +msgstr "" +"Die Regulärer-Ausdruck-Konstante »//« sieht wie ein C-Kommentar aus, ist " +"aber keiner" + +#: awkgram.y:436 +#, c-format +msgid "regexp constant `/%s/' looks like a C comment, but is not" +msgstr "" +"Die Regulärer-Ausdruck-Konstante »/%s/« sieht wie ein C-Kommentar aus, ist " +"aber keiner" + +#: awkgram.y:528 +#, c-format +msgid "duplicate case values in switch body: %s" +msgstr "doppelte Case-Werte im Switch-Block: %s" + +#: awkgram.y:549 +msgid "duplicate `default' detected in switch body" +msgstr "doppeltes »default« im Switch-Block gefunden" + +#: awkgram.y:809 +msgid "`break' is not allowed outside a loop or switch" +msgstr "" +"»break« ist außerhalb einer Schleife oder eines Switch-Blocks nicht zulässig" + +#: awkgram.y:818 +msgid "`continue' is not allowed outside a loop" +msgstr "»continue« ist außerhalb einer Schleife nicht zulässig" + +#: awkgram.y:828 +#, c-format +msgid "`next' used in %s action" +msgstr "»next« wird in %s-Aktion verwendet" + +#: awkgram.y:836 +msgid "`nextfile' is a gawk extension" +msgstr "»nextfile« ist eine gawk-Erweiterung" + +#: awkgram.y:841 +#, c-format +msgid "`nextfile' used in %s action" +msgstr "»nextfile« wird in %s-Aktion verwendet" + +#: awkgram.y:865 +msgid "`return' used outside function context" +msgstr "»return« wird außerhalb einer Funktion verwendet" + +#: awkgram.y:925 +msgid "plain `print' in BEGIN or END rule should probably be `print \"\"'" +msgstr "" +"Einfaches »print« in BEGIN- oder END-Regel soll vermutlich »print \"\"« sein" + +#: awkgram.y:995 awkgram.y:999 awkgram.y:1023 +msgid "`delete array' is a gawk extension" +msgstr "»delete array« ist eine gawk-Erweiterung" + +#: awkgram.y:1019 +msgid "`delete(array)' is a non-portable tawk extension" +msgstr "»delete(array)« ist eine gawk-Erweiterung" + +#: awkgram.y:1135 +msgid "multistage two-way pipelines don't work" +msgstr "mehrstufige Zweiwege-Pipes funktionieren nicht" + +#: awkgram.y:1238 +msgid "regular expression on right of assignment" +msgstr "Regulärer Ausdruck auf der rechten Seite einer Zuweisung" + +#: awkgram.y:1249 +msgid "regular expression on left of `~' or `!~' operator" +msgstr "Regulärer Ausdruck links vom »~«- oder »!~«-Operator" + +#: awkgram.y:1265 awkgram.y:1419 +msgid "old awk does not support the keyword `in' except after `for'" +msgstr "Das alte awk unterstützt das Schlüsselwort »in« nur nach »for«" + +#: awkgram.y:1275 +msgid "regular expression on right of comparison" +msgstr "Regulärer Ausdruck rechts von einem Vergleich" + +#: awkgram.y:1394 +#, c-format +msgid "`getline var' invalid inside `%s' rule" +msgstr "»getline var« ist ungültig innerhalb der »%s«-Regel" + +#: awkgram.y:1397 eval.c:2504 +#, c-format +msgid "`getline' invalid inside `%s' rule" +msgstr "»getline« ist ungültig innerhalb der »%s«-Regel" + +#: awkgram.y:1402 +msgid "non-redirected `getline' undefined inside END action" +msgstr "" +"Nicht-umgelenktes »getline« ist innerhalb der END-Aktion nicht definiert" + +#: awkgram.y:1421 +msgid "old awk does not support multidimensional arrays" +msgstr "Das alte awk unterstützt keine mehrdimensionalen Felder" + +#: awkgram.y:1517 +msgid "call of `length' without parentheses is not portable" +msgstr "Aufruf von »length« ohne Klammern ist nicht portabel" + +#: awkgram.y:1580 +msgid "indirect function calls are a gawk extension" +msgstr "indirekte Funktionsaufrufe sind eine gawk-Erweiterung" + +#: awkgram.y:1593 +#, c-format +msgid "can not use special variable `%s' for indirect function call" +msgstr "" +"die besondere Variable »%s« kann nicht für den indirekten Funktionsaufruf " +"verwendet werden" + +#: awkgram.y:1671 +msgid "invalid subscript expression" +msgstr "Ungültiger Index-Ausdruck" + +#: awkgram.y:1711 +msgid "use of non-array as array" +msgstr "Verwendung eines Nicht-Feldes als Feld" + +#: awkgram.y:1975 awkgram.y:1995 msg.c:98 +msgid "warning: " +msgstr "Warnung: " + +#: awkgram.y:1993 msg.c:130 +msgid "fatal: " +msgstr "Fatal: " + +#: awkgram.y:2043 +msgid "unexpected newline or end of string" +msgstr "Unerwarteter Zeilenumbruch oder Ende der Zeichenkette" + +#: awkgram.y:2300 awkgram.y:2358 awkgram.y:2542 +#, c-format +msgid "can't open source file `%s' for reading (%s)" +msgstr "Quelldatei »%s« kann nicht zum Lesen geöffnet werden (%s)" + +#: awkgram.y:2301 awkgram.y:2359 builtin.c:122 +msgid "reason unknown" +msgstr "Unbekannte Ursache" + +#: awkgram.y:2317 +#, c-format +msgid "already included source file `%s'" +msgstr "Quelldatei »%s« wurde bereits eingebunden" + +#: awkgram.y:2343 +msgid "@include is a gawk extension" +msgstr "»@include« ist eine gawk-Erweiterung" + +#: awkgram.y:2349 +msgid "empty filename after @include" +msgstr "leerer Dateiname nach @include" + +#: awkgram.y:2494 +msgid "empty program text on command line" +msgstr "Kein Programmtext auf der Kommandozeile" + +#: awkgram.y:2609 +#, c-format +msgid "can't read sourcefile `%s' (%s)" +msgstr "Die Quelldatei »%s« kann nicht gelesen werden (%s)" + +#: awkgram.y:2620 +#, c-format +msgid "source file `%s' is empty" +msgstr "Die Quelldatei »%s« ist leer" + +#: awkgram.y:2797 +msgid "source file does not end in newline" +msgstr "Die Quelldatei hört nicht mit einem Zeilenende auf" + +#: awkgram.y:2900 +msgid "unterminated regexp ends with `\\' at end of file" +msgstr "" +"Nicht beendeter regulärer Ausdruck (hört mit '\\' auf) am Ende der Datei" + +#: awkgram.y:2924 +#, c-format +msgid "%s: %d: tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "" +"%s: %d: der tawk-Modifizierer für reguläre Ausdrücke »/.../%c« funktioniert " +"nicht in gawk" + +#: awkgram.y:2928 +#, c-format +msgid "tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "" +"Der tawk-Modifizierer für reguläre Ausdrücke »/.../%c« funktioniert nicht in " +"gawk" + +#: awkgram.y:2935 +msgid "unterminated regexp" +msgstr "Nicht beendeter regulärer Ausdruck" + +#: awkgram.y:2939 +msgid "unterminated regexp at end of file" +msgstr "Nicht beendeter regulärer Ausdruck am Dateiende" + +#: awkgram.y:2998 +msgid "use of `\\ #...' line continuation is not portable" +msgstr "" +"Die Verwendung von »\\#...« zur Fortsetzung von Zeilen ist nicht portabel" + +#: awkgram.y:3014 +msgid "backslash not last character on line" +msgstr "das letzte Zeichen auf der Zeile ist kein Backslash (»\\«)" + +#: awkgram.y:3075 +msgid "POSIX does not allow operator `**='" +msgstr "POSIX erlaubt den Operator »**=« nicht" + +#: awkgram.y:3077 +msgid "old awk does not support operator `**='" +msgstr "Das alte awk unterstützt den Operator »**=« nicht" + +#: awkgram.y:3086 +msgid "POSIX does not allow operator `**'" +msgstr "POSIX erlaubt den Operator »**« nicht" + +#: awkgram.y:3088 +msgid "old awk does not support operator `**'" +msgstr "Das alte awk unterstützt den Operator »**« nicht" + +#: awkgram.y:3123 +msgid "operator `^=' is not supported in old awk" +msgstr "Das alte awk unterstützt den Operator »^=« nicht" + +#: awkgram.y:3131 +msgid "operator `^' is not supported in old awk" +msgstr "Das alte awk unterstützt den Operator »^« nicht" + +#: awkgram.y:3224 awkgram.y:3240 +msgid "unterminated string" +msgstr "Nicht beendete Zeichenkette" + +#: awkgram.y:3436 +#, c-format +msgid "invalid char '%c' in expression" +msgstr "Ungültiges Zeichen »%c« in einem Ausdruck" + +#: awkgram.y:3483 +#, c-format +msgid "`%s' is a gawk extension" +msgstr "»%s« ist eine gawk-Erweiterung" + +#: awkgram.y:3488 +#, c-format +msgid "`%s' is a Bell Labs extension" +msgstr "»%s« ist eine Erweiterung der Bell Labs" + +#: awkgram.y:3493 +#, c-format +msgid "POSIX does not allow `%s'" +msgstr "POSIX erlaubt »%s« nicht" + +#: awkgram.y:3501 +#, c-format +msgid "`%s' is not supported in old awk" +msgstr "»%s« wird im alten awk nicht unterstützt" + +#: awkgram.y:3568 +msgid "`goto' considered harmful!\n" +msgstr "»goto« gilt als schlechter Stil!\n" + +#: awkgram.y:3619 +#, c-format +msgid "%d is invalid as number of arguments for %s" +msgstr "Unzulässige Argumentzahl %d für %s" + +#: awkgram.y:3654 +#, c-format +msgid "%s: string literal as last arg of substitute has no effect" +msgstr "%s: Ein String als letztes Argument von substitute hat keinen Effekt" + +#: awkgram.y:3659 +#, c-format +msgid "%s third parameter is not a changeable object" +msgstr "Der dritte Parameter von %s ist ein unveränderliches Objekt" + +#: awkgram.y:3732 awkgram.y:3735 +msgid "match: third argument is a gawk extension" +msgstr "match: Das dritte Argument ist eine gawk-Erweiterung" + +#: awkgram.y:3789 awkgram.y:3792 +msgid "close: second argument is a gawk extension" +msgstr "close: Das zweite Argument ist eine gawk-Erweiterung" + +#: awkgram.y:3804 +msgid "use of dcgettext(_\"...\") is incorrect: remove leading underscore" +msgstr "" +"Fehlerhafte Verwendung von dcgettext(_\"...\"): \n" +"Entfernen Sie den führenden Unterstrich" + +#: awkgram.y:3819 +msgid "use of dcngettext(_\"...\") is incorrect: remove leading underscore" +msgstr "" +"Fehlerhafte Verwendung von dcngettext(_\"...\"): \n" +"Entfernen Sie den führenden Unterstrich" + +#: awkgram.y:3911 +#, c-format +msgid "function `%s': parameter #%d, `%s', duplicates parameter #%d" +msgstr "Funktion »%s«: Parameter #%d, »%s« wiederholt Parameter #%d" + +#: awkgram.y:3953 +#, c-format +msgid "function `%s': parameter `%s' shadows global variable" +msgstr "Funktion »%s«: Parameter »%s« verdeckt eine globale Variable" + +#: awkgram.y:4111 +#, c-format +msgid "could not open `%s' for writing (%s)" +msgstr "»%s« kann nicht zum Schreiben geöffne werden(%s)" + +#: awkgram.y:4112 +msgid "sending variable list to standard error" +msgstr "Die Liste der Variablen wird auf der Standardfehlerausgabe ausgegeben" + +#: awkgram.y:4118 +#, c-format +msgid "%s: close failed (%s)" +msgstr "%s: close ist gescheitert (%s)" + +#: awkgram.y:4170 +msgid "shadow_funcs() called twice!" +msgstr "shadow_funcs() zweimal aufgerufen!" + +#: awkgram.y:4176 +msgid "there were shadowed variables." +msgstr "es sind verdeckte Variablen vorhanden" + +#: awkgram.y:4206 +#, c-format +msgid "function `%s': can't use function name as parameter name" +msgstr "Funktion »%s«: Funktionsnamen können nicht als Parameternamen benutzen" + +#: awkgram.y:4210 +#, c-format +msgid "function `%s': can't use special variable `%s' as a function parameter" +msgstr "" +"Funktion »%s«: die spezielle Variable »%s« kann nicht als Parameter " +"verwendet werden" + +#: awkgram.y:4226 +#, c-format +msgid "function name `%s' previously defined" +msgstr "Funktion »%s« wurde bereits definiert" + +#: awkgram.y:4394 awkgram.y:4400 +#, c-format +msgid "function `%s' called but never defined" +msgstr "Aufgerufene Funktion »%s« ist nirgends definiert" + +#: awkgram.y:4403 +#, c-format +msgid "function `%s' defined but never called directly" +msgstr "Funktion »%s« wurde definiert aber nirgends aufgerufen" + +#: awkgram.y:4435 +#, c-format +msgid "regexp constant for parameter #%d yields boolean value" +msgstr "" +"Regulärer-Ausdruck-Konstante für Parameter #%d ergibt einen \n" +"logischen Wert" + +#: awkgram.y:4544 +#, c-format +msgid "" +"function `%s' called with space between name and `(',\n" +"or used as a variable or an array" +msgstr "" +"Funktion »%s« wird mit Leerzeichen zwischen Name und »(« aufgerufen, \n" +"oder als Variable oder Feld verwendet" + +#: awkgram.y:4791 eval.c:2056 +msgid "division by zero attempted" +msgstr "Division durch Null wurde versucht" + +#: awkgram.y:4800 eval.c:2072 +#, c-format +msgid "division by zero attempted in `%%'" +msgstr "Division durch Null versucht in »%%«" + +#: builtin.c:120 +#, c-format +msgid "%s to \"%s\" failed (%s)" +msgstr "%s to \"%s\" fehlgeschlagen (%s)" + +#: builtin.c:121 +msgid "standard output" +msgstr "Standardausgabe" + +#: builtin.c:135 +msgid "exp: received non-numeric argument" +msgstr "exp: das Argument ist keine Zahl" + +#: builtin.c:141 +#, c-format +msgid "exp: argument %g is out of range" +msgstr "exp: das Argument %g liegt außerhalb des gültigen Bereichs" + +#: builtin.c:200 +#, c-format +msgid "fflush: cannot flush: pipe `%s' opened for reading, not writing" +msgstr "" +"fflush: Leeren der Puffer nicht möglich, Pipe »%s« ist nur zum Lesen geöffnet" + +#: builtin.c:203 +#, c-format +msgid "fflush: cannot flush: file `%s' opened for reading, not writing" +msgstr "" +"fflush: Leeren der Puffer nicht möglich, Datei »%s« ist nur zum Lesen " +"geöffnet" + +#: builtin.c:215 +#, c-format +msgid "fflush: `%s' is not an open file, pipe or co-process" +msgstr "fflush: »%s« ist keine geöffnete Datei, Pipe oder Prozess" + +#: builtin.c:333 +msgid "index: received non-string first argument" +msgstr "index: Erstes Argument ist kein String" + +#: builtin.c:335 +msgid "index: received non-string second argument" +msgstr "index: Zweites Argument ist kein string" + +#: builtin.c:457 +msgid "int: received non-numeric argument" +msgstr "Argument ist keine Zahl" + +#: builtin.c:493 +msgid "length: received array argument" +msgstr "length: Argument ist ein Feld" + +#: builtin.c:496 +msgid "`length(array)' is a gawk extension" +msgstr "»length(array)« ist eine gawk-Erweiterung" + +#: builtin.c:504 +msgid "length: received non-string argument" +msgstr "length: Argument ist kein String" + +#: builtin.c:535 +msgid "log: received non-numeric argument" +msgstr "log: Argument ist keine Zahl" + +#: builtin.c:538 +#, c-format +msgid "log: received negative argument %g" +msgstr "log: Negatives Argument %g" + +#: builtin.c:694 builtin.c:699 +msgid "fatal: must use `count$' on all formats or none" +msgstr "Fatal: »count$« muss auf alle Formate angewandt werden oder auf keines" + +#: builtin.c:762 +#, c-format +msgid "field width is ignored for `%%' specifier" +msgstr "Feldbreite wird für die »%%«-Angabe ignoriert" + +#: builtin.c:764 +#, c-format +msgid "precision is ignored for `%%' specifier" +msgstr "Genauigkeit wird für die »%%«-Angabe ignoriert" + +#: builtin.c:766 +#, c-format +msgid "field width and precision are ignored for `%%' specifier" +msgstr "Feldbreite und Genauigkeit werden für die »%%«-Angabe ignoriert" + +#: builtin.c:817 +msgid "fatal: `$' is not permitted in awk formats" +msgstr "Fatal: »$« ist in awk-Formaten nicht zulässig" + +#: builtin.c:826 +msgid "fatal: arg count with `$' must be > 0" +msgstr "Fatal: die Anzahl der Argumen bei »$« muss > 0 sein" + +#: builtin.c:830 +#, c-format +msgid "fatal: arg count %ld greater than total number of supplied arguments" +msgstr "" +"Fatal: Argumentenanzahl %ld ist größer als die Gesamtzahl angegebener " +"Argumente" + +#: builtin.c:834 +msgid "fatal: `$' not permitted after period in format" +msgstr "Fatal: »$« nach Punkt in Formatangabe nicht zulässig" + +#: builtin.c:850 +msgid "fatal: no `$' supplied for positional field width or precision" +msgstr "Fatal: »$« fehlt in positionsabhängiger Feldbreite oder Genauigkeit" + +# +#: builtin.c:921 +msgid "`l' is meaningless in awk formats; ignored" +msgstr "»l« ist in awk-Formaten bedeutungslos, ignoriert" + +#: builtin.c:925 +msgid "fatal: `l' is not permitted in POSIX awk formats" +msgstr "Fatal: »l« ist in POSIX-awk-Formaten nicht zulässig" + +#: builtin.c:938 +msgid "`L' is meaningless in awk formats; ignored" +msgstr "»L« ist in awk-Formaten bedeutungslos, ignoriert" + +#: builtin.c:942 +msgid "fatal: `L' is not permitted in POSIX awk formats" +msgstr "Fatal: »L« ist in POSIX-awk-Formaten nicht zulässig" + +#: builtin.c:955 +msgid "`h' is meaningless in awk formats; ignored" +msgstr "»h« ist in awk-Formaten bedeutungslos, ignoriert" + +#: builtin.c:959 +msgid "fatal: `h' is not permitted in POSIX awk formats" +msgstr "Fatal: »h« ist in POSIX-awk-Formaten nicht zulässig" + +#: builtin.c:1272 +#, c-format +msgid "[s]printf: value %g is out of range for `%%%c' format" +msgstr "[s]printf: Wert %g ist außerhalb des Bereichs für Format »%%%c«" + +#: builtin.c:1332 +#, c-format +msgid "ignoring unknown format specifier character `%c': no argument converted" +msgstr "" +"das unbekannte Zeichen »%c« in der Formatspezifikation wird ignoriert: keine " +"Argumente umgewandelt" + +#: builtin.c:1337 +msgid "fatal: not enough arguments to satisfy format string" +msgstr "Fatal: Nicht genügend Argumente für die Formatangabe" + +#: builtin.c:1339 +msgid "^ ran out for this one" +msgstr "^ hierfür fehlte es" + +#: builtin.c:1346 +msgid "[s]printf: format specifier does not have control letter" +msgstr "[s]printf: Format-Spezifikation hat keinen Controlcode" + +#: builtin.c:1349 +msgid "too many arguments supplied for format string" +msgstr "Zu viele Argumente für den Formatstring" + +#: builtin.c:1423 builtin.c:1434 +msgid "printf: no arguments" +msgstr "printf: Keine Argumente" + +#: builtin.c:1475 +msgid "sqrt: received non-numeric argument" +msgstr "sqrt: das Argument ist keine Zahl" + +#: builtin.c:1479 +#, c-format +msgid "sqrt: called with negative argument %g" +msgstr "sqrt: das Argument %g ist negativ" + +#: builtin.c:1503 +#, c-format +msgid "substr: length %g is not >= 1" +msgstr "substr: Länge %g ist nicht >= 1" + +#: builtin.c:1505 +#, c-format +msgid "substr: length %g is not >= 0" +msgstr "substr: Länge %g ist nicht >= 0" + +#: builtin.c:1512 +#, c-format +msgid "substr: non-integer length %g will be truncated" +msgstr "substr: Nicht ganzzahlige Länge %g wird abgeschnitten" + +#: builtin.c:1517 +#, c-format +msgid "substr: length %g too big for string indexing, truncating to %g" +msgstr "" +"substr: Länge %g ist zu groß für Stringindizierung, wird auf %g gekürzt" + +#: builtin.c:1529 +#, c-format +msgid "substr: start index %g is invalid, using 1" +msgstr "substr: Start-Index %g ist ungültig, 1 wird verwendet" + +#: builtin.c:1534 +#, c-format +msgid "substr: non-integer start index %g will be truncated" +msgstr "substr: Nicht ganzzahliger Start-Wert %g wird abgeschnitten" + +#: builtin.c:1559 +msgid "substr: source string is zero length" +msgstr "substr: Quellstring ist leer" + +#: builtin.c:1575 +#, c-format +msgid "substr: start index %g is past end of string" +msgstr "substr: Start-Wert %g liegt hinter dem Ende des Strings" + +#: builtin.c:1583 +#, c-format +msgid "" +"substr: length %g at start index %g exceeds length of first argument (%lu)" +msgstr "" +"substr: Länge %g am Start-Wert %g überschreitet die Länge des ersten " +"Arguments (%lu)" + +#: builtin.c:1657 +msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" +msgstr "strftime: Formatwert in PROCINFO[\"strftime\"] ist numerischen Typs" + +#: builtin.c:1680 +msgid "strftime: received non-numeric second argument" +msgstr "strftime: Das zweite Argument ist keine Zahl" + +#: builtin.c:1683 +msgid "strftime: second argument less than 0 or too big for time_t" +msgstr "" +"strftime: das zweite Argument ist kleiner als 0 oder zu groß für time_t" + +#: builtin.c:1690 +msgid "strftime: received non-string first argument" +msgstr "strftime: Das erste Argument ist kein String" + +#: builtin.c:1696 +msgid "strftime: received empty format string" +msgstr "strftime: Der Format-String ist leer" + +#: builtin.c:1762 +msgid "mktime: received non-string argument" +msgstr "mktime: Das Argument ist kein String" + +#: builtin.c:1779 +msgid "mktime: at least one of the values is out of the default range" +msgstr "mktime: mindestens einer der Werte ist außerhalb des normalen Bereichs" + +#: builtin.c:1814 +msgid "'system' function not allowed in sandbox mode" +msgstr "Die Funktion »system« ist im Sandbox-Modus nicht erlaubt" + +#: builtin.c:1819 +msgid "system: received non-string argument" +msgstr "system: Das Argument ist kein String" + +#: builtin.c:1874 eval.c:1159 eval.c:1790 eval.c:1803 +#, c-format +msgid "reference to uninitialized variable `%s'" +msgstr "Referenz auf die nicht initialisierte Variable »%s«" + +#: builtin.c:1941 +#, c-format +msgid "reference to uninitialized field `$%d'" +msgstr "Referenz auf das nicht initialisierte Feld »$%d«" + +#: builtin.c:2028 +msgid "tolower: received non-string argument" +msgstr "tolower: das Argument ist kein String" + +#: builtin.c:2062 +msgid "toupper: received non-string argument" +msgstr "toupper: das Argument ist kein String" + +#: builtin.c:2098 +msgid "atan2: received non-numeric first argument" +msgstr "atan2: das erste Argument ist keine Zahl" + +#: builtin.c:2100 +msgid "atan2: received non-numeric second argument" +msgstr "atan2: das zweite Argument ist keine Zahl" + +#: builtin.c:2119 +msgid "sin: received non-numeric argument" +msgstr "sin: das Argument ist keine Zahl" + +#: builtin.c:2135 +msgid "cos: received non-numeric argument" +msgstr "cos: das Argument ist keine Zahl" + +#: builtin.c:2188 +msgid "srand: received non-numeric argument" +msgstr "srand: das Argument ist keine Zahl" + +#: builtin.c:2219 +msgid "match: third argument is not an array" +msgstr "match: das dritte Argument ist kein Array" + +#: builtin.c:2483 +msgid "gensub: third argument of 0 treated as 1" +msgstr "gensub: 0 als drittes Argument wird als 1 interpretiert" + +#: builtin.c:2776 +msgid "lshift: received non-numeric first argument" +msgstr "lshift: das erste Argument ist keine Zahl" + +#: builtin.c:2778 +msgid "lshift: received non-numeric second argument" +msgstr "lshift: das zweite Argument ist keine Zahl" + +#: builtin.c:2784 +#, c-format +msgid "lshift(%lf, %lf): negative values will give strange results" +msgstr "" +"lshift(%lf, %lf): Negative Werte werden zu merkwürdigen Ergebnissen führen" + +#: builtin.c:2786 +#, c-format +msgid "lshift(%lf, %lf): fractional values will be truncated" +msgstr "lshift(%lf, %lf): Dezimalteil wird abgeschnitten" + +#: builtin.c:2788 +#, c-format +msgid "lshift(%lf, %lf): too large shift value will give strange results" +msgstr "" +"lshift(%lf, %lf): Zu große Shift-Werte werden zu merkwürdigen Ergebnissen " +"führen" + +#: builtin.c:2813 +msgid "rshift: received non-numeric first argument" +msgstr "rshift: das erste Argument ist keine Zahl" + +#: builtin.c:2815 +msgid "rshift: received non-numeric second argument" +msgstr "rshift: das zweite Argument ist keine Zahl" + +#: builtin.c:2821 +#, c-format +msgid "rshift(%lf, %lf): negative values will give strange results" +msgstr "" +"rshift (%lf, %lf): Negative Werte werden zu merkwürdigen Ergebnissen führen" + +#: builtin.c:2823 +#, c-format +msgid "rshift(%lf, %lf): fractional values will be truncated" +msgstr "rshift(%lf, %lf): Dezimalteil wird abgeschnitten" + +#: builtin.c:2825 +#, c-format +msgid "rshift(%lf, %lf): too large shift value will give strange results" +msgstr "" +"rshift(%lf, %lf): Zu große Shift-Werte werden zu merkwürdigen Ergebnissen " +"führen" + +#: builtin.c:2850 +msgid "and: received non-numeric first argument" +msgstr "and: das erste Argument ist keine Zahl" + +#: builtin.c:2852 +msgid "and: received non-numeric second argument" +msgstr "and: das zweite Argument ist keine Zahl" + +#: builtin.c:2858 +#, c-format +msgid "and(%lf, %lf): negative values will give strange results" +msgstr "" +"and(%lf, %lf): Negative Werte werden zu merkwürdigen Ergebnissen führen" + +#: builtin.c:2860 +#, c-format +msgid "and(%lf, %lf): fractional values will be truncated" +msgstr "and(%lf, %lf): Dezimalteil wird abgeschnitten" + +#: builtin.c:2885 +msgid "or: received non-numeric first argument" +msgstr "or: das erste Argument ist keine Zahl" + +#: builtin.c:2887 +msgid "or: received non-numeric second argument" +msgstr "or: das zweite Argument ist keine Zahl" + +#: builtin.c:2893 +#, c-format +msgid "or(%lf, %lf): negative values will give strange results" +msgstr "or(%lf, %lf): Negative Werte werden zu merkwürdigen Ergebnissen führen" + +#: builtin.c:2895 +#, c-format +msgid "or(%lf, %lf): fractional values will be truncated" +msgstr "or(%lf, %lf): Dezimalteil wird abgeschnitten" + +#: builtin.c:2923 +msgid "xor: received non-numeric first argument" +msgstr "xor: das erste Argument ist keine Zahl" + +#: builtin.c:2925 +msgid "xor: received non-numeric second argument" +msgstr "xor: das zweite Argument ist keine Zahl" + +#: builtin.c:2931 +#, c-format +msgid "xor(%lf, %lf): negative values will give strange results" +msgstr "xor(%lf, %lf: Negative Werte werden zu merkwürdigen Ergebnissen führen" + +#: builtin.c:2933 +#, c-format +msgid "xor(%lf, %lf): fractional values will be truncated" +msgstr "xor(%lf, %lf): Dezimalteil wird abgeschnitten" + +#: builtin.c:2957 builtin.c:2963 +msgid "compl: received non-numeric argument" +msgstr "compl: das erste Argument ist keine Zahl" + +#: builtin.c:2965 +#, c-format +msgid "compl(%lf): negative value will give strange results" +msgstr "compl(%lf): Negativer Wert wird zu merkwürdigen Ergebnissen führen" + +#: builtin.c:2967 +#, c-format +msgid "compl(%lf): fractional value will be truncated" +msgstr "compl(%lf): Dezimalteil wird abgeschnitten" + +#: builtin.c:3136 +#, c-format +msgid "dcgettext: `%s' is not a valid locale category" +msgstr "dcgettext: »%s« ist keine gültige Locale-Kategorie" + +#: eval.c:412 +#, c-format +msgid "unknown nodetype %d" +msgstr "Unbekannter Knotentyp %d" + +#: eval.c:423 eval.c:437 +#, c-format +msgid "unknown opcode %d" +msgstr "Unbekannter Opcode %d" + +#: eval.c:434 +#, c-format +msgid "opcode %s not an operator or keyword" +msgstr "Opcode %s ist weder ein Operator noch ein Schlüsselwort" + +#: eval.c:488 +msgid "buffer overflow in genflags2str" +msgstr "Pufferüberlauf in genflags2str" + +#: eval.c:698 +#, c-format +msgid "" +"\n" +"\t# Function Call Stack:\n" +"\n" +msgstr "" +"\n" +"\t# Funktions-Aufruf-Stack\n" +"\n" + +#: eval.c:725 +msgid "`IGNORECASE' is a gawk extension" +msgstr "»IGNORECASE« ist eine gawk-Erweiterung" + +#: eval.c:754 +msgid "`BINMODE' is a gawk extension" +msgstr "»BINMODE« ist eine gawk-Erweiterung" + +#: eval.c:812 +#, c-format +msgid "BINMODE value `%s' is invalid, treated as 3" +msgstr "BINMODE Wert »%s« ist ungültig und wird als 3 behandelt" + +#: eval.c:902 +#, c-format +msgid "bad `%sFMT' specification `%s'" +msgstr "Falsche »%sFMT«-Angabe »%s«" + +#: eval.c:980 +msgid "turning off `--lint' due to assignment to `LINT'" +msgstr "»--lint« wird abgeschaltet, da an »LINT« zugewiesen wird" + +#: eval.c:1127 eval.c:1777 +#, c-format +msgid "can't use function name `%s' as variable or array" +msgstr "Funktion »%s« kann nicht als Variable oder Feld verwendet werden" + +#: eval.c:1158 eval.c:1789 eval.c:1802 +#, c-format +msgid "reference to uninitialized argument `%s'" +msgstr "Referenz auf nicht initialisiertes Argument »%s«" + +#: eval.c:1177 +msgid "attempt to field reference from non-numeric value" +msgstr "Nicht numerischer Wert für Feldreferenz verwendet" + +#: eval.c:1179 +msgid "attempt to field reference from null string" +msgstr "Referenz auf ein Feld von einem Null-String" + +#: eval.c:1185 +#, c-format +msgid "attempt to access field %ld" +msgstr "Versuch des Zugriffs auf Feld %ld" + +#: eval.c:1194 +#, c-format +msgid "reference to uninitialized field `$%ld'" +msgstr "Referenz auf das nicht initialisierte Feld »$%ld«" + +#: eval.c:1256 +#, c-format +msgid "function `%s' called with more arguments than declared" +msgstr "Funktion »%s« mit zu vielen Argumenten aufgerufen" + +#: eval.c:1437 +#, c-format +msgid "unwind_stack: unexpected type `%s'" +msgstr "unwind_stack: unerwarteter Typ »%s«" + +#: eval.c:1532 +msgid "division by zero attempted in `/='" +msgstr "Division durch Null versucht in »/=«" + +#: eval.c:1539 +#, c-format +msgid "division by zero attempted in `%%='" +msgstr "Division durch Null versucht in »%%=«" + +#: eval.c:1876 eval.c:2122 +#, c-format +msgid "attempt to use array `%s[\"%.*s\"]' in a scalar context" +msgstr "" +"Es wird versucht, das Feld »%s[\"%.*s\"]« in einem Skalarkontext zu verwenden" + +#: eval.c:1907 +msgid "assignment used in conditional context" +msgstr "Zuweisung in einer Bedingung" + +#: eval.c:1911 +msgid "statement has no effect" +msgstr "Anweisung hat keinen Effekt" + +#: eval.c:2343 +#, c-format +msgid "for loop: array `%s' changed size from %ld to %ld during loop execution" +msgstr "" +"for-Schleife: Feld »%s« ändert seine Größe von %ld innerhalb der Schleife zu " +"%ld" + +#: eval.c:2458 +#, c-format +msgid "function called indirectly through `%s' does not exist" +msgstr "die durch »%s« indirekt aufgerufene Funktion existiert nicht" + +#: eval.c:2470 +#, c-format +msgid "function `%s' not defined" +msgstr "Funktion »%s« ist nicht definiert" + +#: eval.c:2511 +#, c-format +msgid "non-redirected `getline' invalid inside `%s' rule" +msgstr "Nicht umgelenktes »getline« ist innerhalb der »%s«-Aktion unzuässig" + +#: eval.c:2600 +#, c-format +msgid "error reading input file `%s': %s" +msgstr "Fehler beim Lesen der Eingabedatei »%s«: %s" + +#: eval.c:2614 +#, c-format +msgid "`nextfile' cannot be called from a `%s' rule" +msgstr "»nextfile« kann nicht aus einer »«%s-Regel aufgerufen werden" + +#: eval.c:2661 +msgid "`exit' cannot be called in the current context" +msgstr "»exit« kann im aktuellen Kontext nicht aufgerufen werden" + +#: eval.c:2700 +#, c-format +msgid "`next' cannot be called from a `%s' rule" +msgstr "»next« kann nicht in einer »%s«-Regel verwendet werden" + +#: eval.c:2766 +#, c-format +msgid "Sorry, don't know how to interpret `%s'" +msgstr "Entschuldigung, aber es ist unbekannt, wie »%s« zu interpretieren ist" + +#: ext.c:54 +msgid "extensions are not allowed in sandbox mode" +msgstr "Erweiterungen sind im Sandbox-Modus nicht erlaubt" + +#: ext.c:60 ext.c:65 +msgid "`extension' is a gawk extension" +msgstr "»extension« ist eine gawk-Erweiterung" + +#: ext.c:75 +#, c-format +msgid "fatal: extension: cannot open `%s' (%s)\n" +msgstr "Fatal: extension: »%s« kann nicht geöffnet werden (%s)\n" + +#: ext.c:84 +#, c-format +msgid "" +"fatal: extension: library `%s': does not define " +"`plugin_is_GPL_compatible' (%s)\n" +msgstr "" +"Fatal: Erweiterung: Bibliothek »%s«: definiert »plugin_is_GPL_compatible« " +"nicht (%s)\n" + +#: ext.c:93 +#, c-format +msgid "fatal: extension: library `%s': cannot call function `%s' (%s)\n" +msgstr "" +"Fatal: Erweiterung: Bibliothek »%s«: Funktion »%s« kann nicht aufgerufen " +"werden (%s)\n" + +#: ext.c:127 +msgid "extension: missing function name" +msgstr "Erweiterung: Funktionsname fehlt" + +#: ext.c:132 +#, c-format +msgid "extension: illegal character `%c' in function name `%s'" +msgstr "Erweiterung: unzulässiges Zeichen »%c« in Funktionsname »%s«" + +#: ext.c:141 +#, c-format +msgid "extension: can't redefine function `%s'" +msgstr "Erweiterung: Funktion »%s« kann nicht neu definiert werden" + +#: ext.c:145 +#, c-format +msgid "extension: function `%s' already defined" +msgstr "Erweiterung: Funktion »%s« wurde bereits definiert" + +#: ext.c:150 +#, c-format +msgid "extension: function name `%s' previously defined" +msgstr "Erweiterung: Funktion »%s« wurde bereits vorher definiert" + +#: ext.c:152 +#, c-format +msgid "extension: can't use gawk built-in `%s' as function name" +msgstr "" +"Erweiterung: die eingebaute Funktion »%s« kann nicht als Funktionsname " +"verwendet werden" + +#: ext.c:156 +#, c-format +msgid "make_builtin: negative argument count for function `%s'" +msgstr "make_builtin: negative Anzahl von Argumenten für Funktion »%s«" + +#: ext.c:259 +#, c-format +msgid "function `%s' defined to take no more than %d argument(s)" +msgstr "" +"Funktion »%s« wird als Funktion definiert, die nie mehr als %d Argument(e) " +"akzeptiert" + +#: ext.c:262 +#, c-format +msgid "function `%s': missing argument #%d" +msgstr "Funktion »%s«: fehlendes Argument #%d" + +#: ext.c:279 +#, c-format +msgid "function `%s': argument #%d: attempt to use scalar as an array" +msgstr "" +"Funktion »%s«: Argument #%d: Es wird versucht, einen Skalar als Feld zu " +"verwenden" + +#: ext.c:283 +#, c-format +msgid "function `%s': argument #%d: attempt to use array as a scalar" +msgstr "" +"Funktion »%s«: Argument #%d: Es wird versucht, ein Feld als Skalar zu " +"verwenden" + +#: ext.c:296 +msgid "Operation Not Supported" +msgstr "Die Operation wird nicht unterstützt" + +#: field.c:328 +msgid "NF set to negative value" +msgstr "NF wird ein negativer Wert zugewiesen" + +#: field.c:951 field.c:958 field.c:962 +msgid "split: fourth argument is a gawk extension" +msgstr "split: das vierte Argument ist eine gawk-Erweiterung" + +#: field.c:955 +msgid "split: fourth argument is not an array" +msgstr "split: das vierte Argument ist kein Feld" + +#: field.c:969 +msgid "split: second argument is not an array" +msgstr "split: das zweite Argument ist kein Feld" + +#: field.c:973 +msgid "split: cannot use the same array for second and fourth args" +msgstr "" +"split: als zweites und viertes Argument kann nicht das gleiche Feld " +"verwendet werden" + +#: field.c:978 +msgid "split: cannot use a subarray of second arg for fourth arg" +msgstr "" +"split: Ein untergeordnetes Feld des zweiten Arguments kann nicht als viertes " +"Argument verwendet werden" + +#: field.c:981 +msgid "split: cannot use a subarray of fourth arg for second arg" +msgstr "" +"split: Ein untergeordnetes Feld des vierten Arguments kann nicht als zweites " +"Argument verwendet werden" + +#: field.c:1010 +msgid "split: null string for third arg is a gawk extension" +msgstr "split: Null-String als drittes Argument ist eine gawk-Erweiterung" + +#: field.c:1050 +msgid "patsplit: fourth argument is not an array" +msgstr "patsplit: Das vierte Argument ist kein Feld" + +#: field.c:1055 +msgid "patsplit: second argument is not an array" +msgstr "patsplit: Das zweite Argument ist kein Feld" + +#: field.c:1061 +msgid "patsplit: third argument must be non-null" +msgstr "patsplit: Das dritte Argument darf nicht Null sein" + +#: field.c:1065 +msgid "patsplit: cannot use the same array for second and fourth args" +msgstr "" +"patsplit: als zweites und viertes Argument kann nicht das gleiche Feld " +"verwendet werden" + +#: field.c:1070 +msgid "patsplit: cannot use a subarray of second arg for fourth arg" +msgstr "" +"patsplit: Ein untergeordnetes Feld des zweiten Arguments kann nicht als " +"viertes Argument verwendet werden" + +#: field.c:1073 +msgid "patsplit: cannot use a subarray of fourth arg for second arg" +msgstr "" +"patsplit: Ein untergeordnetes Feld des vierten Arguments kann nicht als " +"zweites Argument verwendet werden" + +#: field.c:1110 +msgid "`FIELDWIDTHS' is a gawk extension" +msgstr "»FIELDWIDTHS« ist eine gawk-Erweiterung" + +#: field.c:1173 +#, c-format +msgid "invalid FIELDWIDTHS value, near `%s'" +msgstr "ungültiger FIELDWIDTHS-Wert nah bei »%s«" + +#: field.c:1246 +msgid "null string for `FS' is a gawk extension" +msgstr "Null-String für »FS« ist eine gawk-Erweiterung" + +#: field.c:1250 +msgid "old awk does not support regexps as value of `FS'" +msgstr "Das alte awk unterstützt keine regulären Ausdrücke als Wert von »FS«" + +#: field.c:1369 +msgid "`FPAT' is a gawk extension" +msgstr "»FPAT« ist eine gawk-Erweiterung" + +#: getopt.c:604 getopt.c:633 +#, fuzzy, c-format +msgid "%s: option '%s' is ambiguous; possibilities:" +msgstr "%s: Option »%s« ist mehrdeutig\n" + +#: getopt.c:679 getopt.c:683 +#, c-format +msgid "%s: option '--%s' doesn't allow an argument\n" +msgstr "%s: Die Option »--%s« hat keine Argumente\n" + +#: getopt.c:692 getopt.c:697 +#, c-format +msgid "%s: option '%c%s' doesn't allow an argument\n" +msgstr "%s: Die Option »%c%s« hat keine Argument\n" + +#: getopt.c:740 getopt.c:759 +#, c-format +msgid "%s: option '--%s' requires an argument\n" +msgstr "%s: Die Option »%s« erfordert ein Argument\n" + +#: getopt.c:797 getopt.c:800 +#, c-format +msgid "%s: unrecognized option '--%s'\n" +msgstr "%s: Die Option »--%s« ist unbekannt\n" + +#: getopt.c:808 getopt.c:811 +#, c-format +msgid "%s: unrecognized option '%c%s'\n" +msgstr "%s: Die Option »%c%s« ist unbekannt\n" + +#: getopt.c:860 getopt.c:863 +#, c-format +msgid "%s: invalid option -- '%c'\n" +msgstr "%s: Ungültige Option -- »%c«\n" + +#: getopt.c:916 getopt.c:933 getopt.c:1143 getopt.c:1161 +#, c-format +msgid "%s: option requires an argument -- '%c'\n" +msgstr "%s Die Option »%c« erfordert ein Argument\n" + +#: getopt.c:989 getopt.c:1005 +#, c-format +msgid "%s: option '-W %s' is ambiguous\n" +msgstr "%s: Die Option »-W %s« ist mehrdeutig\n" + +#: getopt.c:1029 getopt.c:1047 +#, c-format +msgid "%s: option '-W %s' doesn't allow an argument\n" +msgstr "%s: Die Option »-W %s« hat keine Argumente\n" + +#: getopt.c:1068 getopt.c:1086 +#, c-format +msgid "%s: option '-W %s' requires an argument\n" +msgstr "%s: Die Option »-W %s« erfordert ein Argument\n" + +#: io.c:280 +#, c-format +msgid "command line argument `%s' is a directory: skipped" +msgstr "" +"das Kommandozeilen-Argument »%s« ist ein Verzeichnis: wird übersprungen" + +#: io.c:283 io.c:385 +#, c-format +msgid "cannot open file `%s' for reading (%s)" +msgstr "Die Datei »%s« kann nicht zum Lesen geöffnet werden (%s)" + +#: io.c:501 +#, c-format +msgid "close of fd %d (`%s') failed (%s)" +msgstr "Das Schließen des Dateideskriptors %d (»%s«) ist gescheitert (%s)" + +#: io.c:578 +msgid "redirection not allowed in sandbox mode" +msgstr "Umlenkungen sind im Sandbox-Modus nicht erlaubt" + +#: io.c:612 +#, c-format +msgid "expression in `%s' redirection only has numeric value" +msgstr "" +"Der Ausdruck in einer Umlenkung mittels »%s« hat nur einen numerischen Wert" + +#: io.c:618 +#, c-format +msgid "expression for `%s' redirection has null string value" +msgstr "Der Ausdruck für eine Umlenkung mittels »%s« ist ein leerer String" + +#: io.c:623 +#, c-format +msgid "filename `%s' for `%s' redirection may be result of logical expression" +msgstr "" +"Der Dateiname »%s« für eine Umlenkung mittels »%s« kann das Ergebnis eines " +"logischen Ausdrucks sein" + +#: io.c:666 +#, c-format +msgid "unnecessary mixing of `>' and `>>' for file `%.*s'" +msgstr "Unnötige Kombination von »>« und »>>« für Datei »%.*s«" + +#: io.c:719 +#, c-format +msgid "can't open pipe `%s' for output (%s)" +msgstr "Die Pipe »%s« kann nicht für die Ausgabe geöffnet werden (%s)" + +#: io.c:729 +#, c-format +msgid "can't open pipe `%s' for input (%s)" +msgstr "Die Pipe »%s« kann nicht für die Eingabe geöffnet werden (%s)" + +#: io.c:752 +#, c-format +msgid "can't open two way pipe `%s' for input/output (%s)" +msgstr "" +"Die bidirektionale Pipe »%s« kann nicht für die Ein-/Ausgabe geöffnet werden " +"(%s)" + +#: io.c:834 +#, c-format +msgid "can't redirect from `%s' (%s)" +msgstr "Von »%s« kann nicht umgelenkt werden (%s)" + +#: io.c:837 +#, c-format +msgid "can't redirect to `%s' (%s)" +msgstr "Zu »%s« kann nicht umgelenkt werden (%s)" + +#: io.c:888 +msgid "" +"reached system limit for open files: starting to multiplex file descriptors" +msgstr "" +"Die Systemgrenze offener Dateien ist erreicht, daher werden nun " +"Dateideskriptoren mehrfach verwendet" + +#: io.c:904 +#, c-format +msgid "close of `%s' failed (%s)." +msgstr "Das Schließen von »%s« ist gescheitert (%s)." + +#: io.c:912 +msgid "too many pipes or input files open" +msgstr "Zu viele Pipes oder Eingabedateien offen" + +#: io.c:934 +msgid "close: second argument must be `to' or `from'" +msgstr "close: Das zweite Argument muss »to« oder »from« sein" + +#: io.c:951 +#, c-format +msgid "close: `%.*s' is not an open file, pipe or co-process" +msgstr "close: »%.*s« ist weder offene Datei, noch Pipe oder Ko-Prozess" + +#: io.c:956 +msgid "close of redirection that was never opened" +msgstr "»close« für eine Umlenkung, die nie geöffnet wurde" + +#: io.c:1053 +#, c-format +msgid "close: redirection `%s' not opened with `|&', second argument ignored" +msgstr "" +"close: Umlenkung »%s« wurde nicht mit »[&« geöffnet, das zweite Argument " +"wird ignoriert" + +#: io.c:1069 +#, c-format +msgid "failure status (%d) on pipe close of `%s' (%s)" +msgstr "Fehlerstatus (%d) beim Schließen der Pipe »%s« (%s)" + +#: io.c:1072 +#, c-format +msgid "failure status (%d) on file close of `%s' (%s)" +msgstr "Fehlerstatus (%d) beim Schließen der Datei »%s« (%s)" + +#: io.c:1092 +#, c-format +msgid "no explicit close of socket `%s' provided" +msgstr "Das explizite Schließen des Sockets »%s« fehlt" + +#: io.c:1095 +#, c-format +msgid "no explicit close of co-process `%s' provided" +msgstr "Das explizite Schließen des Ko-Prozesses »%s« fehlt" + +#: io.c:1098 +#, c-format +msgid "no explicit close of pipe `%s' provided" +msgstr "Das explizite Schließen der Pipe »%s« fehlt" + +#: io.c:1101 +#, c-format +msgid "no explicit close of file `%s' provided" +msgstr "Das explizite Schließen der Datei »%s« fehlt" + +#: io.c:1129 io.c:1184 main.c:794 main.c:831 +#, c-format +msgid "error writing standard output (%s)" +msgstr "Fehler beim Schreiben auf die Standardausgabe (%s)" + +#: io.c:1133 io.c:1189 +#, c-format +msgid "error writing standard error (%s)" +msgstr "Fehler beim Schreiben auf die Standardfehlerausgabe (%s)" + +#: io.c:1141 +#, c-format +msgid "pipe flush of `%s' failed (%s)." +msgstr "Das Leeren der Pipe »%s« ist gescheitert (%s)" + +#: io.c:1144 +#, c-format +msgid "co-process flush of pipe to `%s' failed (%s)." +msgstr "Ko-Prozess: Das Leeren der Pipe zu »%s« ist gescheitert (%s)" + +#: io.c:1147 +#, c-format +msgid "file flush of `%s' failed (%s)." +msgstr "Das Leeren der Datei »%s« ist gescheitert (%s)" + +#: io.c:1262 +#, c-format +msgid "local port %s invalid in `/inet'" +msgstr "Der lokale Port »%s« ist ungültig in »/inet«" + +#: io.c:1279 +#, c-format +msgid "remote host and port information (%s, %s) invalid" +msgstr "Die Angaben zu entferntem Host und Port (%s, %s) sind ungültig" + +#: io.c:1431 +#, c-format +msgid "no (known) protocol supplied in special filename `%s'" +msgstr "Es wurde kein (bekanntes) Protokoll im Dateinamen »%s« angegeben" + +#: io.c:1445 +#, c-format +msgid "special file name `%s' is incomplete" +msgstr "Der Dateiname »%s« ist unvollständig" + +#: io.c:1462 +msgid "must supply a remote hostname to `/inet'" +msgstr "Sie müssen in /inet einen Rechnernamen angeben" + +#: io.c:1480 +msgid "must supply a remote port to `/inet'" +msgstr "Sie müssen in »/inet« einen Port angeben" + +#: io.c:1526 +msgid "TCP/IP communications are not supported" +msgstr "TCP/IP-Verbindungen werden nicht unterstützt" + +#: io.c:1693 +#, c-format +msgid "could not open `%s', mode `%s'" +msgstr "»%s« konnte nicht geöffnet werden, Modus »%s«" + +#: io.c:1747 +#, c-format +msgid "close of master pty failed (%s)" +msgstr "" +"Das Schließen der übergeordneten Terminal-Gerätedatei ist gescheitert (%s)" + +#: io.c:1749 io.c:1917 io.c:2074 +#, c-format +msgid "close of stdout in child failed (%s)" +msgstr "Das Schließen der Standardausgabe im Kindprozess ist gescheitert (%s)" + +#: io.c:1752 +#, c-format +msgid "moving slave pty to stdout in child failed (dup: %s)" +msgstr "" +"Das Verschieben der untergeordneten Terminal-Gerätedatei zur Standardausgabe " +"im Kindprozess ist gescheitert (dup: %s)" + +#: io.c:1754 io.c:1922 +#, c-format +msgid "close of stdin in child failed (%s)" +msgstr "Schließen von stdin im Kindprozess gescheitert (%s)" + +#: io.c:1757 +#, c-format +msgid "moving slave pty to stdin in child failed (dup: %s)" +msgstr "" +"Das Verschieben der untergeordneten Terminal-Gerätedatei zur Standardeingabe " +"im Kindprozess ist gescheitert (dup: %s)" + +#: io.c:1759 io.c:1780 +#, c-format +msgid "close of slave pty failed (%s)" +msgstr "" +"Das Schließen der untergeordneten Terminal-Gerätedatei ist gescheitert (%s)" + +#: io.c:1858 io.c:1920 io.c:2052 io.c:2077 +#, c-format +msgid "moving pipe to stdout in child failed (dup: %s)" +msgstr "" +"Das Verschieben der Pipe zur Standardausgabe im Kindprozess ist gescheitert " +"(dup: %s)" + +#: io.c:1865 io.c:1925 +#, c-format +msgid "moving pipe to stdin in child failed (dup: %s)" +msgstr "" +"Das Verschieben der Pipe zur Standardeingabe im Kindprozess ist gescheitert " +"(dup: %s)" + +#: io.c:1885 io.c:2067 +msgid "restoring stdout in parent process failed\n" +msgstr "" +"Das Wiederherstellen der Standardausgabe im Elternprozess ist gescheitert\n" + +#: io.c:1893 +msgid "restoring stdin in parent process failed\n" +msgstr "" +"Das Wiederherstellen der Standardeingabe im Elternprozess ist gescheitert\n" + +#: io.c:1928 io.c:2079 io.c:2093 +#, c-format +msgid "close of pipe failed (%s)" +msgstr "Das Schließen der Pipe ist gescheitert (%s)" + +#: io.c:1973 +msgid "`|&' not supported" +msgstr "»|&« wird nicht unterstützt" + +#: io.c:2039 +#, c-format +msgid "cannot open pipe `%s' (%s)" +msgstr "Pipe »%s« kann nicht geöffnet werden (%s)" + +#: io.c:2087 +#, c-format +msgid "cannot create child process for `%s' (fork: %s)" +msgstr "Kindprozess für »%s« kann nicht erzeugt werden (fork: %s)" + +#: io.c:2520 +#, c-format +msgid "data file `%s' is empty" +msgstr "Die Datei »%s« ist leer" + +#: io.c:2561 io.c:2569 +msgid "could not allocate more input memory" +msgstr "Es konnte kein weiterer Speicher für die Eingabe beschafft werden" + +#: io.c:3127 +msgid "multicharacter value of `RS' is a gawk extension" +msgstr "Multicharacter-Wert von »RS« ist eine gawk-Erweiterung" + +#: io.c:3232 +msgid "IPv6 communication is not supported" +msgstr "IPv6-Verbindungen werden nicht unterstützt" + +#: main.c:366 +msgid "`-m[fr]' option irrelevant in gawk" +msgstr "Die Option »-m[fr]« ist in gawk bedeutungslos" + +#: main.c:368 +msgid "-m option usage: `-m[fr] nnn'" +msgstr "Anwendung der Option -m: »-m[fr] nnn«" + +#: main.c:391 +msgid "empty argument to `-e/--source' ignored" +msgstr "Das leere Argument für »--source« wird ignoriert" + +#: main.c:462 +#, c-format +msgid "%s: option `-W %s' unrecognized, ignored\n" +msgstr "%s: Die Option »-W %s« ist unbekannt und wird ignoriert\n" + +#: main.c:515 +#, c-format +msgid "%s: option requires an argument -- %c\n" +msgstr "%s: Die Option %c erfordert ein Argument\n" + +#: main.c:536 +msgid "environment variable `POSIXLY_CORRECT' set: turning on `--posix'" +msgstr "" +"Die Umgebungsvariable »POSIXLY_CORRECT« ist gesetzt: »--posix« wird " +"eingeschaltet" + +#: main.c:542 +msgid "`--posix' overrides `--traditional'" +msgstr "»--posix« hat Vorrang vor »--traditional«" + +#: main.c:553 +msgid "`--posix'/`--traditional' overrides `--non-decimal-data'" +msgstr "»--posix« /»--traditional« hat Vorrang vor »--non-decimal-data«" + +#: main.c:557 +#, c-format +msgid "running %s setuid root may be a security problem" +msgstr "%s als setuid root auszuführen kann zu Sicherheitsproblemen führen" + +#: main.c:562 +msgid "`--posix' overrides `--binary'" +msgstr "»--posix« hat Vorrang vor »--binary«" + +#: main.c:613 +#, c-format +msgid "can't set binary mode on stdin (%s)" +msgstr "" +"Das Setzen des Binärermodus für die Standardeingabe ist nicht möglich (%s)" + +#: main.c:616 +#, c-format +msgid "can't set binary mode on stdout (%s)" +msgstr "" +"Das Setzen des Binärermodus für die Standardausgabe ist nicht möglich (%s)" + +#: main.c:618 +#, c-format +msgid "can't set binary mode on stderr (%s)" +msgstr "" +"Das Setzen des Binärermodus für die Standardfehlerausgabe ist nicht möglich " +"(%s)" + +#: main.c:657 +msgid "no program text at all!" +msgstr "Es wurde überhaupt kein Programmtext angegeben!" + +#: main.c:734 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] -f progfile [--] file ...\n" +msgstr "Aufruf: %s [POSIX- oder GNU-Optionen] -f PROGRAMM [--] Datei ...\n" + +#: main.c:736 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] [--] %cprogram%c file ...\n" +msgstr "Aufruf: %s [POSIX- oder GNU-Optionen] -- %cPROGRAMM%c Datei ...\n" + +#: main.c:741 +msgid "POSIX options:\t\tGNU long options: (standard)\n" +msgstr "POSIX-Optionen\t\tlange GNU-Optionen: (standard)\n" + +#: main.c:742 +msgid "\t-f progfile\t\t--file=progfile\n" +msgstr "\t-f PROGRAMM\t\t--file=PROGRAMM\n" + +#: main.c:743 +msgid "\t-F fs\t\t\t--field-separator=fs\n" +msgstr "\t-F Feldtrenner\t\t\t--field-separator=Feldtrenner\n" + +#: main.c:744 +msgid "\t-v var=val\t\t--assign=var=val\n" +msgstr "\t-v var=Wert\t\t--assign=var=Wert\n" + +#: main.c:745 +msgid "Short options:\t\tGNU long options: (extensions)\n" +msgstr "POSIX-Optionen\t\tGNU-Optionen (lang): (Erweiterungen)\n" + +#: main.c:746 +msgid "\t-b\t\t\t--characters-as-bytes\n" +msgstr "\t-b\t\t\t--characters-as-bytes\n" + +#: main.c:747 +msgid "\t-c\t\t\t--traditional\n" +msgstr "\t-c\t\t\t--traditional\n" + +#: main.c:748 +msgid "\t-C\t\t\t--copyright\n" +msgstr "\t-C\t\t\t--copyright\n" + +#: main.c:749 +msgid "\t-d[file]\t\t--dump-variables[=file]\n" +msgstr "\t-d [Datei]\t\t--dump-variables[=Datei]\n" + +#: main.c:750 +msgid "\t-e 'program-text'\t--source='program-text'\n" +msgstr "\t-e 'Programmtext'\t--source=Programmtext\n" + +#: main.c:751 +msgid "\t-E file\t\t\t--exec=file\n" +msgstr "\t-E Datei\t\t\t--exec=Datei\n" + +#: main.c:752 +msgid "\t-g\t\t\t--gen-pot\n" +msgstr "\t-g\t\t\t--gen-pot\n" + +#: main.c:753 +msgid "\t-h\t\t\t--help\n" +msgstr "\t-h\t\t\t--help\n" + +#: main.c:754 +msgid "\t-L [fatal]\t\t--lint[=fatal]\n" +msgstr "\t-L [fatal]\t\t--lint[=fatal]\n" + +#: main.c:755 +msgid "\t-n\t\t\t--non-decimal-data\n" +msgstr "\t-n\t\t\t--non-decimal-data\n" + +#: main.c:756 +msgid "\t-N\t\t\t--use-lc-numeric\n" +msgstr "\t-N\t\t\t--use-lc-numeric\n" + +#: main.c:757 +msgid "\t-O\t\t\t--optimize\n" +msgstr "\t-O\t\t\t--optimize\n" + +#: main.c:758 +msgid "\t-p[file]\t\t--profile[=file]\n" +msgstr "\t-p [Datei]\t\t--profile[=Datei]\n" + +#: main.c:759 +msgid "\t-P\t\t\t--posix\n" +msgstr "\t-P\t\t\t--posix\n" + +#: main.c:760 +msgid "\t-r\t\t\t--re-interval\n" +msgstr "\t-r\t\t\t--re-interval\n" + +#: main.c:762 +msgid "\t-R file\t\t\t--command=file\n" +msgstr "\t-R Datei\t\t\t--command=Datei\n" + +#: main.c:763 +msgid "\t-S\t\t\t--sandbox\n" +msgstr "\t-S\t\t\t--sandbox\n" + +#: main.c:764 +msgid "\t-t\t\t\t--lint-old\n" +msgstr "\t-t\t\t\t--lint-old\n" + +#: main.c:765 +msgid "\t-V\t\t\t--version\n" +msgstr "\t-V\t\t\t--version\n" + +#: main.c:767 +msgid "\t-W nostalgia\t\t--nostalgia\n" +msgstr "\t-W nostalgia\t\t--nostalgia\n" + +#: main.c:770 +msgid "\t-Y\t\t--parsedebug\n" +msgstr "\t-Y\t\t--parsedebug\n" + +#. TRANSLATORS: --help output 5 (end) +#. TRANSLATORS: the placeholder indicates the bug-reporting address +#. for this application. Please add _another line_ with the +#. address for translation bugs. +#. no-wrap +#: main.c:779 +msgid "" +"\n" +"To report bugs, see node `Bugs' in `gawk.info', which is\n" +"section `Reporting Problems and Bugs' in the printed version.\n" +"\n" +msgstr "" +"\n" +"Zum Berichten von Fehlern sehen Sie bitte den Punkt »Bugs«\n" +"in »gawk.info«, den Sie als Kapitel »Reporting Problems and Bugs«\n" +"in der gedruckten Version finden.\n" +"\n" +"Fehler in der Übersetzuung senden Sie bitte als E-Mail an\n" +"an translation-team-de@lists.sourceforge.net\n" +"\n" + +#: main.c:783 +msgid "" +"gawk is a pattern scanning and processing language.\n" +"By default it reads standard input and writes standard output.\n" +"\n" +msgstr "" +"gawk ist eine Sprache zur Suche nach und dem Verarbeiten von Mustern.\n" +"Normalerweise ließt das Programm von der Standardeingabe und gibt\n" +"auf der Standardausgabe aus.\n" +"\n" + +#: main.c:787 +msgid "" +"Examples:\n" +"\tgawk '{ sum += $1 }; END { print sum }' file\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" +msgstr "" +"Beispiele:\n" +"\tgawk '{ sum += $1 }; END { print sum }' file\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" + +#: main.c:807 +#, c-format +msgid "" +"Copyright (C) 1989, 1991-%d Free Software Foundation.\n" +"\n" +"This program is free software; you can redistribute it and/or modify\n" +"it under the terms of the GNU General Public License as published by\n" +"the Free Software Foundation; either version 3 of the License, or\n" +"(at your option) any later version.\n" +"\n" +msgstr "" +"Copyright © 1989, 1991-%d Free Software Foundation.\n" +"\n" +"Dieses Programm ist Freie Software. Sie können es unter den Bedingungen\n" +"der von der Free Software Foundation veröffentlichten GNU \n" +"General Public License weitergeben und/oder ändern.\n" +"Es gilt Version 2 dieser Lizenz oder (nach Ihrer Wahl) irgendeine\n" +"spätere Version.\n" +"\n" + +#: main.c:815 +msgid "" +"This program is distributed in the hope that it will be useful,\n" +"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +"GNU General Public License for more details.\n" +"\n" +msgstr "" +"Dieses Programm wird weitergegeben in der Hoffnung, dass es nützlich ist,\n" +"aber OHNE JEDE GEWÄHRLEISTUNG; nicht einmal mit der impliziten Gewähr-\n" +"leistung einer HANDELBARKEIT oder der EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.\n" +"Sehen Sie bitte die GNU General Public License für weitere Details.\n" + +#: main.c:821 +msgid "" +"You should have received a copy of the GNU General Public License\n" +"along with this program. If not, see http://www.gnu.org/licenses/.\n" +msgstr "" +"Sie sollten eine Kopie der GNU General Publice License zusammen mit\n" +"diesem Programm erhalten haben. Wenn nicht, lesen Sie bitte\n" +"http://www.gnu.org/licenses/.\n" + +#: main.c:856 +msgid "-Ft does not set FS to tab in POSIX awk" +msgstr "-Ft setzt FS im POSIX-awk nicht auf Tab" + +#: main.c:1090 +#, c-format +msgid "unknown value for field spec: %d\n" +msgstr "unbekannter Wert für eine Feldangabe: %d\n" + +#: main.c:1171 +#, c-format +msgid "" +"%s: `%s' argument to `-v' not in `var=value' form\n" +"\n" +msgstr "" +"%s: Argument »%s« von »-v« ist nicht in der Form »Variable=Wert«\n" +"\n" + +#: main.c:1197 +#, c-format +msgid "`%s' is not a legal variable name" +msgstr "»%s« ist kein gültiger Variablenname" + +#: main.c:1200 +#, c-format +msgid "`%s' is not a variable name, looking for file `%s=%s'" +msgstr "»%s« ist kein Variablenname, es wird nach der Datei »%s=%s« gesucht" + +#: main.c:1204 +#, c-format +msgid "cannot use gawk builtin `%s' as variable name" +msgstr "" +"die eingebaute Funktion »%s« kann nicht als Variablenname verwendet werden" + +# c-format +#: main.c:1209 +#, c-format +msgid "cannot use function `%s' as variable name" +msgstr "Funktion »%s« kann nicht als Name einer Variablen verwendet werden" + +#: main.c:1262 +msgid "floating point exception" +msgstr "Fließkomma-Ausnahme" + +#: main.c:1269 +msgid "fatal error: internal error" +msgstr "Fataler Fehler: interner Fehler" + +#: main.c:1284 +msgid "fatal error: internal error: segfault" +msgstr "Fataler Fehler: interner Fehler: Speicherbegrenzungsfehler" + +#: main.c:1296 +msgid "fatal error: internal error: stack overflow" +msgstr "Fataler Fehler: interner Fehler: Stapelüberlauf" + +#: main.c:1346 +#, c-format +msgid "no pre-opened fd %d" +msgstr "Kein bereits geöffneter Dateideskriptor %d" + +#: main.c:1353 +#, c-format +msgid "could not pre-open /dev/null for fd %d" +msgstr "/dev/null konnte nicht für Dateideskriptor %d geöffnet werden" + +#: msg.c:63 +#, c-format +msgid "cmd. line:" +msgstr "Kommandozeile:" + +#: msg.c:107 +msgid "error: " +msgstr "Fehler: " + +#: node.c:406 +msgid "backslash at end of string" +msgstr "Backslash am Ende der Zeichenkette" + +#: node.c:517 +#, c-format +msgid "old awk does not support the `\\%c' escape sequence" +msgstr "Das alte awk unterstützt die Fluchsequenz »\\%c« nicht" + +#: node.c:568 +msgid "POSIX does not allow `\\x' escapes" +msgstr "POSIX erlaubt keine »\\x«-Escapes" + +#: node.c:574 +msgid "no hex digits in `\\x' escape sequence" +msgstr "In der »\\x«-Fluchtsequenz sind keine hexadezimalen Zahlen" + +#: node.c:596 +#, c-format +msgid "" +"hex escape \\x%.*s of %d characters probably not interpreted the way you " +"expect" +msgstr "" +"Die Hex-Sequenz \\x%.*s aus %d Zeichen wird wahrscheinlich nicht wie " +"gewünscht interpretiert" + +#: node.c:611 +#, c-format +msgid "escape sequence `\\%c' treated as plain `%c'" +msgstr "Fluchtsequenz »\\%c« wird wie ein normales »%c« behandelt" + +#: node.c:750 +msgid "" +"Invalid multibyte data detected. There may be a mismatch between your data " +"and your locale." +msgstr "" +"Es wurden unbekannte Multibyte-Daten gefunden. Ihre Daten entsprechen " +"neventuell nicht der gesetzten Locale" + +#: posix/gawkmisc.c:176 +#, c-format +msgid "%s %s `%s': could not get fd flags: (fcntl F_GETFD: %s)" +msgstr "" +"%s %s »%s«: Die Kennungen des Dateideskriptors konnten nicht abgefragt " +"werden: (fcntl F_GETFD: %s)" + +#: posix/gawkmisc.c:188 +#, c-format +msgid "%s %s `%s': could not set close-on-exec: (fcntl F_SETFD: %s)" +msgstr "" +"%s %s »%s«: close-on-exec konnte nicht gesetzt werden: (fcntl F_SETFD: %s)" + +#: profile.c:83 +#, c-format +msgid "could not open `%s' for writing: %s" +msgstr "»%s« konnte nicht zum Schreiben geöffnet werden: %s" + +#: profile.c:85 +msgid "sending profile to standard error" +msgstr "Das Profil wird auf der Standardfehlerausgabe ausgegeben" + +#: profile.c:203 +#, c-format +msgid "" +"\t# %s block(s)\n" +"\n" +msgstr "" +"\t# %s Blöcke\n" +"\n" + +#: profile.c:208 +#, c-format +msgid "" +"\t# Rule(s)\n" +"\n" +msgstr "" +"\t# Regeln(s)\n" +"\n" + +#: profile.c:279 +#, c-format +msgid "internal error: %s with null vname" +msgstr "Interner Fehler: %s mit null vname" + +#: profile.c:952 +#, c-format +msgid "\t# gawk profile, created %s\n" +msgstr "\t# gawk-Profil, erzeugt %s\n" + +#: profile.c:1331 +#, c-format +msgid "" +"\n" +"\t# Functions, listed alphabetically\n" +msgstr "" +"\n" +"\t# Funktionen in alphabetischer Reihenfolge\n" + +#: profile.c:1370 +#, c-format +msgid "redir2str: unknown redirection type %d" +msgstr "redir2str: unbekannter Umlenkungstyp %d" + +#: re.c:573 +#, c-format +msgid "range of the form `[%c-%c]' is locale dependent" +msgstr "" +"Ein Bereich in der Form »[%c-%c]« ist abhängig von der gesetzten Locale" + +#: re.c:600 +#, c-format +msgid "regexp component `%.*s' should probably be `[%.*s]'" +msgstr "" +"Regulärer-Ausdruck-Komponente »%.*s« sollte wahrscheinlich »[%.*s]« sein" + +#: regcomp.c:131 +msgid "Success" +msgstr "Erfolg" + +#: regcomp.c:134 +msgid "No match" +msgstr "Kein Treffer" + +#: regcomp.c:137 +msgid "Invalid regular expression" +msgstr "Ungültiger Regulärer Ausdruck" + +#: regcomp.c:140 +msgid "Invalid collation character" +msgstr "Ungültiges Zeichen" + +#: regcomp.c:143 +msgid "Invalid character class name" +msgstr "Ungültiger Name für eine Zeichenklasse" + +#: regcomp.c:146 +msgid "Trailing backslash" +msgstr "Angehängter Backslash" + +#: regcomp.c:149 +msgid "Invalid back reference" +msgstr "Ungültige Rück-Referenz" + +#: regcomp.c:152 +msgid "Unmatched [ or [^" +msgstr "[ oder [^ werden nicht geschlossen" + +#: regcomp.c:155 +msgid "Unmatched ( or \\(" +msgstr "( oder \\( werden nicht geschlossen" + +#: regcomp.c:158 +msgid "Unmatched \\{" +msgstr "\\{ wird nicht geschlossen" + +#: regcomp.c:161 +msgid "Invalid content of \\{\\}" +msgstr "Ungültiger Inhalt von \\{\\}" + +#: regcomp.c:164 +msgid "Invalid range end" +msgstr "Ungültiges Bereichsende" + +#: regcomp.c:167 +msgid "Memory exhausted" +msgstr "Kein freier Speicher mehr vorhanden" + +#: regcomp.c:170 +msgid "Invalid preceding regular expression" +msgstr "Vorangehender regulärer Ausdruck ist ungültig" + +#: regcomp.c:173 +msgid "Premature end of regular expression" +msgstr "Vorzeitiges Ende des regulären Ausdrucks" + +#: regcomp.c:176 +msgid "Regular expression too big" +msgstr "Regulärer Ausdruck ist zu groß" + +#: regcomp.c:179 +msgid "Unmatched ) or \\)" +msgstr ") oder \\) werden nicht geöffnet" + +#: regcomp.c:700 +msgid "No previous regular expression" +msgstr "Kein vorangehender regulärer Ausdruck" + +#~ msgid "could not find groups: %s" +#~ msgstr "Die Gruppen konnten nicht gefunden werden: %s" + +#~ msgid "assignment is not allowed to result of builtin function" +#~ msgstr "" +#~ "Zuweisungen an das Ergebnis einer eingebauten Funktion sind nicht erlaubt" diff --git a/po/en@boldquot.header b/po/en@boldquot.header new file mode 100644 index 0000000..fedb6a0 --- /dev/null +++ b/po/en@boldquot.header @@ -0,0 +1,25 @@ +# All this catalog "translates" are quotation characters. +# The msgids must be ASCII and therefore cannot contain real quotation +# characters, only substitutes like grave accent (0x60), apostrophe (0x27) +# and double quote (0x22). These substitutes look strange; see +# http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html +# +# This catalog translates grave accent (0x60) and apostrophe (0x27) to +# left single quotation mark (U+2018) and right single quotation mark (U+2019). +# It also translates pairs of apostrophe (0x27) to +# left single quotation mark (U+2018) and right single quotation mark (U+2019) +# and pairs of quotation mark (0x22) to +# left double quotation mark (U+201C) and right double quotation mark (U+201D). +# +# When output to an UTF-8 terminal, the quotation characters appear perfectly. +# When output to an ISO-8859-1 terminal, the single quotation marks are +# transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to +# grave/acute accent (by libiconv), and the double quotation marks are +# transliterated to 0x22. +# When output to an ASCII terminal, the single quotation marks are +# transliterated to apostrophes, and the double quotation marks are +# transliterated to 0x22. +# +# This catalog furthermore displays the text between the quotation marks in +# bold face, assuming the VT100/XTerm escape sequences. +# diff --git a/po/en@quot.header b/po/en@quot.header new file mode 100644 index 0000000..a9647fc --- /dev/null +++ b/po/en@quot.header @@ -0,0 +1,22 @@ +# All this catalog "translates" are quotation characters. +# The msgids must be ASCII and therefore cannot contain real quotation +# characters, only substitutes like grave accent (0x60), apostrophe (0x27) +# and double quote (0x22). These substitutes look strange; see +# http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html +# +# This catalog translates grave accent (0x60) and apostrophe (0x27) to +# left single quotation mark (U+2018) and right single quotation mark (U+2019). +# It also translates pairs of apostrophe (0x27) to +# left single quotation mark (U+2018) and right single quotation mark (U+2019) +# and pairs of quotation mark (0x22) to +# left double quotation mark (U+201C) and right double quotation mark (U+201D). +# +# When output to an UTF-8 terminal, the quotation characters appear perfectly. +# When output to an ISO-8859-1 terminal, the single quotation marks are +# transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to +# grave/acute accent (by libiconv), and the double quotation marks are +# transliterated to 0x22. +# When output to an ASCII terminal, the single quotation marks are +# transliterated to apostrophes, and the double quotation marks are +# transliterated to 0x22. +# diff --git a/po/es.gmo b/po/es.gmo new file mode 100644 index 0000000000000000000000000000000000000000..54dd057ce77fdf14a30f26ec631c87e53c3e5057 GIT binary patch literal 51691 zcmd6w37BM6dH1g?(7^>z5pcOP(DV#5-90nx4FfaG#=vaM0+Jb+s;;W;E~dJwtz|ZF z!3B+qy9P}}$Bm#87c?Tq7-==p#F%IjHD)tz$){fu{alhr^!xqabI!fDw(cJCe9!as z!{uN1-m{K{--0Ul=N?ZyH;Po{8KBC&5L7)^ zgHHiV;Mw3&a2a?vsQSJLs+@lTX?pZu;2GeFLoWYfQ2DO})sEeu@=bth$4fz)5WNFD z0)8G;`D>O$(Zyf|yc~QtxETBvI1D~^X%syTTm_DSo5AzJmw>A80r08dmq69~ZI3?% z)z1^obI;EPmveui$8nG*M6Ur=&&RZ0uXM*Q|2SN4ww?K{aeW2#)kHM#d-vCbpe++6qegUeSGgr9zTLmuSeha8^ zuY#KY*MaKC$Nc@bL6v{PO2!0S461)S!4trv{{BVa54e9HDEfNyD%ZYyJ$};Tm%x*G z{}13=@P{5pnB13gKLcI@{tUbj9KFDeO9|9?-Uf;e-U_Ope+H`k-v`y70WvAya{d>C z2#Oxw1B!k=2P)kULCxors9fbO^LRa|cHIuD-1mS_2mcI&RHE;LYX4I%b#!q) zsB(9Jr-Fz4^H+fC|2-f>8hrsIYxFRvaxa8UXWQo># zycN{*kAb4QZ-A=*m!SGF$l?`U?*PvNZv!EL=q~^Ki=fi~3=~~GbG4hFYeBW^c2Mu% z2WtHO0@Qd$SGajt398;LpvK|3pvL#LAX6TF2&CxfyP(>+_)3?4BdGB^0BSt$0-p{3 z3HVI#2cX(}(i)e35LEta{CyQvKi&Xp-aiMboj(Q71fQ|ijpxOn`jrRu{59Yr@O_}_ z`%~}?@Q0wr>+x5)eyjvl-wsgyYl4ts^cHXf_+?P(pSsSKzXlxOzUuFffa=#hpvLWQ zK#j*q>s@(QfQz{=`1?CNz8^fB=YI}93;YSFew{|8r-Ngl%G(K^1Ktj*U+)D~-e*AN z|Bk;uaig36WuWHs22kVmLQs6-L!id{>!9-g3|s@AvB{0ouY0@=)cd=^6Tr`aqN^`} zG5AwZ@1J(H8>dS>*1#d2zXudue+gUyK7O;KqfwBh7v;bhybIL0egafKzvJ<=YaBgX z1rGB3W>EFN1Uv!!5O^N=0I2?b8x)R6UBf&9n2Y3`z zIe!8|y3sE{&EMEohc!^?-|g``p!#>tHb-|ifugUMfedMM5BPNOUqOZ{I$^tO_jd4H z?r#8LS<&;s8^Di&qu>*0jMn>VP;`0-WC=#E1J$lCgR1w5*SUH&ftvqUgIaeV0Y$g} z2CDqQovz>ez$W)E0@eSYgETFQce(b}z@^-O9Mrge3tSGKyxYz5r5^WzqQe(}>hHV3 zXMmse_uumGAGOEL@42ApWRu5Rzzey*6NF_&vmi?``W3hgTzkE%cN!F(ycJZtz5;6g z9tJfIiy1VvBM**%cYqqdkAdfd-vuuK&v=fbhi#zf@&%y!e-Ehqe-5fWKLv-uWjDHX zH+sAsRQ>mYs{gCtY2bf?r-M)Ub;p+mLDhEysPbP0t^hvO1o$mw%nd7lIn6Pl3w+u*Y+6 zcK16#&EHXQ4fs}2<$V);3iz1)Zakk3vSgyG!6$-m1l5msflB{HQ1$;9)cBv3bMLPO z^}Y`3{aZoJ%Pe>)_;Zgd^NvmrfEtH)f@<$ydHfZqelHz&&-a3&&zFLlw-14rf!_ny zf{P1|j*6h@_qCwr;Zxuu@Lxf->&Zn&x0is6x!(gS{bBG7@IBz!;HSZJz;Ay4o5`wXb}{|&A|RJlt*t*?FH67WsnQt%JJ;-e@ZRC~78 zoV~Okd?xqP;Hls%!DoPXgX;Gu{r%s7nwOu0%KxMpNB@h!nEMsrlfmmej)P}$-vCwa zYe1FzPEhOV)1cb*m*5ciOHlQl`&?Jf2Ji{oUk|FEMNs4Pd{Ft1fv14K=b!&EC_4H9 zxD0%9J&L{tUJkATpVGia12=&iz}JDJ;Mc&5z!RFzUb_O^$^C9nbaM}Q8u)$x{ukh> z+@I2Ncn+v`UkpAKydG426_0NRmvjFW@O@qeJOY~^Zp4i$Ni&^x^x9_5%+h1D))E%{hxuF zw|@s=rP0Z^y7?)CPv`!1pyu&?;FG{V0yXYm12s+$`}-%~=Jc`)!KdcQFbx`B~#pk9_3JU;aW zj-Hl*lJA#;+rd|YuK~Xat_2UgFpAcJ_km9Xe*|hBpLn|)$K{~v$$^^B7l3N-2f)?f zS3#veZr#__+w zJ>Yr2;qZl^p8qvC3_j)+uAG&i=(z}90Nw@0;FrLS;J<>BM;E@*)n5ZI;{F(T1^9LU z{Pb73aor4R-j0Hrp9eto=O>`bIrC0;zZ=y3QE&|WD7XduH}GQc@>jchnxNjlAG{j; z9=IGFg~(LyK5!BEBJf)9-QYU#-@&WE3tsE^(jido{uHSG{sbHXm%PrkV+VK*_pboY z0{;qB`9A_RZ>PWB)pI#G!u`#lp5F;x2z~_A`291e{y*~#QM3!(3+nv`!ByaQ!IQzK zztN=|1UGPB09Ee2;3eSK!SlgW-sHx81E_u<0?z~A4T|2r466VC30?@E^=8-Z>p<0a z$m9FK#oYfLsQl4yI(k_K>iz~$>*GbB%K0>SG5AwZ8r06Tr8Fn!kHMwfCREmEg&5b^X2qT+97SKt2CFxCi_XP~~jOU@pfm=9RNjdzYksqM(=QRxD&jb+q=Q*!Eb^$fUAxo5$~i z+qqx)o+x?_csn=<{tc-7(RIIenxK?%@6-pq@YG zcilSN1!^8&1*%_P07XA1e9*1$i@}Syew}NBfm%;PEfsZ)65Y#%zf$GOQ!K=Zq`{#@9cXV0+M|u8w@DlJL z@JjF(;0o}vkGgTKfTGL0J^l>b#{IUBxpLkHs+>Rd_YeE~Wxwa>d@pzb@9zPh2L3Im z^8XK51JC)m)92m@jwl@{I{0gFIr!KI+_&4*xql0&as3jw9z6Mzj&804HJ@+t_g?{3?$dtX^`i`4$o<`*#_KP^ zRp3)T<;vRxYTeuct^_{-YCZlvsCixV2d>>4K((U*?gsDi_%L`a_t$;e)%P|~^!XJ~ z^Y}|p0#BHAxD?#O{k5RR{TO%=_+?P@|M<_k`-{MJ+)smQ*M~vX|9$XuaMkBrx@*9- z+}{qW-LwAr&q1|sb%n9Vj|0fa}4#z|+9L0~doo z0#)Br{@BTt>%ooO|2C-i-v&Ru@Wb6kkK=wF zm&*AKuE+cL2Q%rO#B-VwU6grtCBMJIv!z^r$ECjt*SmOr4OfNh-S(7rdVD3%L?`+? z>L7Xz&+g+|#QiGp1>jG(T3q*XuX+7AsK4_)zLVc)@%w&%Z!h^DWNq~J#?133zu(Ih z^X?Vkqq)Av?;moB2K4tjt_yg+k&7iBy@TrrSNJROd8i|ajHr~7n|<@d9>^4z}}%z>{5_i(+0>uFpgJS%{22G0axr}p=B?kD*5 z1n})#`djVsJn&z+7oX7IFSve-XP1HET^Dif<+_C{{4L}C%ecP7gDb$_;nH6VTjT>H56_XDnHaIMk}e+PIz1O7JGKXbj8>p4CxKa;*V4@WhxCxYZ*ZN;^9$|H{qGi^?ydgW z>$!g(SIIxG@q918{}bHk)BGm*82?*vChu_X(f&@%(-q*AnjEp)G2K)?{{?6qp`uDnj1HboyYjnfkC0v`hKE(68 zxxTE2{JoUlr*PfIbt3ocLH+$6cno|o_{a7HUEaSthx?EC-?xKb;{F8ijo@Sb^Rs=P zGr0dC*9!mqIF@tIh`#8t%JVYzAk?u#}W5B-z-vbVT8@Nv9xBe~$Zv#IJ z*1?Ckp2bz>z6xFiHo@<64fA_FnElK9o87#78^7Ph^*OFb>p9OJE!P^Z@OKYCUd**6^K2RS1Kj^3nEe~% z=3o4S7xMm@T)*Y-Kg#bHaQy~X_`8$e+qt<3+|2cPey`waaQy>Ubkf=JU?U!{)Cvcd zG?oqw=)ulbrIg%E<_{f+XX>?ya;3C9F4Rl;W~oRXQVy>>>7<`)^w>}F6jAodtRGqmZ!@{t(G13WTw_AA69~$X=4ht>FIp6n6zh? zrEKtMyk=>yw+9DH^+vf?RpuMwYOO(&Cd+v>D!I|S8})=9G)l$NcxzIR#w~wgif$E} zlro%e438gamaKaPd)ch#i{&Q8=PSxl+^fN{9v55FGs6e-^>Ti^Qfkn5y-=D`JjB>f z*7MWD&C=oK5Y;wnt$Lxfy8XG*PH37Y-S7_&3s;8+dOc}vm@HL?XKFT8Q}$r0RGHE1 zs@+v<)!|~PP@c|LhKo#y-pr)!^mLGEVBNCSOT)}rseaJ)tZ5H5jl;D{QDq#A>D_8x zYvA&YMtQQzojnOvUBKK%?Yp z&F!@8a~*8J70R*C1b^Qe#mtWm;;P%)8n$+v0A-)2&7`p2{CA(XkjB)nG%yO_krAD%Xp; z%TJe>M)gT;%g4}jb+RO?jBDe!Fj$tl7B3!bERHAg&{#2E;u=X~i(_$9?4n+pEFF%g zYsE6Fy&mUAM@B|Q2Ma@Su~uqShnn%BTK#|~MRP)lV>T+uh{erXoEttkWNpyYc}i)O zhBTJb8h7&K>-GGR{q@p>(u*PKp$$n_%SzKT%_H%WYO7LN>eBfqM@#jZe-b89{Dh$y z9*&1-vP;c)B!lCg_*5ieK9hbyj&^Lut!lkgs7+Skz{TY;>$+AivE(%uzQ|rhX?O== z;tNQY&O)Qf0-S^iK%)7IR$C(HA_&r=r=A+OgM@aSwh158#FRr z4V^Cc#FIR5Ey?yJwBF6|9Pe#X2cn_I5qQ%y6dE|0tsoHuYXmCxvPR3I6b)}|8qpYu zYbkHsB`T(wO1fkFuFcPhwKj&QLpxfH{A7uRGCaL^qJC3ctyYJkHRWod(t^!tI&Cq< z2#HcvA}qRU^R}(q*KdIFR$4GZO)AMel`oH*UXn9Z=SS;;2#=SnTN#R( zH8*7@tXdp}B^rM?GQb0hgiVOWGP7`AW>Yttw(W^Gm8v$`J6hwFav|PQF3>$#81?E& zV~W8YKQf@?{Tg~%Tq^Uv9{6^AeyG5gwmh!Y2bScUYA~$Z*8fskc?9|rH_Y(+4Ttm7 zGl=N1fs;%z8oCv_n~s;Qj?Y;cKku@5!?yMDtxizbi|0WPFiD?!c;i@14wEC6VJIFg zH4CFNNW?=dn$0^7UW90vo^DkUZN`QeRnbwSH6!s>Dn^^VtQki_GO`n;dZ}6{C65yY z1Wrh)aTSi9zN}T~k+@ruEb|W8R&8o%_T9SgdCBwXR;5{%A`?p=h>OSv^qb;Hyqh5{ z#nbsC@i_AlPnR3h`6f~oxqPTps=C3nJQAcfv}l?6N@*l1dj{44ZLp@17_Caa4*Bv7 z^#J+}9j!|O#ieT6^&W}0mZodwT^nRZml}oqOsUa3Ma?Q=J>t3u7m;l{>LohdVy+lNO>d9k+u1ezj9e{7 zKt#Kyq*jHJdsde491MtPSFK(@vK;0nIe(yvIGo~Q9!x=G#GA&8qFt>*ftikWuiG)Y zc}F|d!_8=JJKcBknv|s&cNGJeVw_+cEM$1fp)z_Tl!@6e(W)#TfceBXY~FqK_C34f zwcBotZ&RJJ#;py?Nc9Eo*niJNE2^7B-B;@h7t#WsrUs@Jgf$ri2?22@OUY z<=0eEF#y&ksxuTYqmiD6^AF^W(luwKOvTSgym>+t<8=S2W^-n2bo9`nLnD*b)<~^B zIg0d<@gHm^;tmd21&3a>r^v+sctCpf5lJoIZC1`a^e!P(p-|5@&R=Lu|zDhI; z)GT!Wd{qks3P-$_CdyTqUYf^*Q?f3T7eU8GeCCtloQw#0RcN06PNHE2i?mmYws%-& zwb}tuta>Pk7gOG9am8%8i4>EPgJozcP7X_22K!K4L(taCMK~+Z#>>@w{RsJczs}gw znKYxM&c10cveUR#M$@LK+A00zdc9OB9c0m~g=U@PydGuRQ5?q5Bujl7 z4YpJkvmMPU%#dU0aJe~@Az|6^R88l^e+w<9fhkZE$rR<1oPFxYhK5~A!q-XR6{Iq1 zusi@}&EV0Baz5FdNovg+4XasR78YEpK8^fXG!W&cto8*>M&&q?ma3D@srIq!T)kBW zpvQ1c)N9ksY^H}UAtKMl5>D^z{3xdvT9ykg#U+L`x=B7Qt4Br1_g1|+B(a;4QeqM% zGkV*(&bm)HLX?*eOh&!)nmFZ3HZMkgl&?VD#UsqE**isy3^~CPPBRpt?kpLsOe~N2 z-%{ARyl`ld#>B9H8i_v8tYe?ahuN8>T~G8GCZ#xHyBKFjGesG0DB~Dh*Gn!Dx_3&_ zp1Lzg&GR!yLi|oOw6W0JDBobI;Jt86oxx+=F=(y#5-mx=#$eOj^JYwwde-b47&0aW zTZ=nJ-8CvLqF=>I{A}Sis7ggxSt>^?^ z>GYPqx)P1I@LA!5KogpfE0H0?V{gvkRa6s6P>LVqDke6D661v?L&j4jG~6K2gY+d+ z)fTp<#p=web~b|2+R6|^FcLY(zCshj~ONGs`)L{v}JfO$kYC2^;Ee(b-EG?32{?nlMds(xz!*PC{!aDoo=y z6dN3i(nhoO)oM&>(rsSC%FB!xlkawKEpMVUxvp8OTzByR(&_`{nHfz~4KI#V!lm8X zU=L+5o4j2UbcuT^f|jX|VvwkIg&JESJ+;M5lCT>nBTU+Au#aV)!8?L&XVI7axiu5W;Tgb!E zOs_KAJ(I}hqLjyDUdKAkZqKsUNdM|Ab~ro(k=d(t+m?ZFq&nt?OQYdX0F1)zzeO&c zrpIJQenJd!jW?hC+puw?$&xh7F0!apJy@>SoNk;*oSgX$x7@gY-S(aMEu_Mfm}gmh zqCjz*;H`-ej5I$86i3MkxwyVtia@@>V;#GUCT85vt`u3RZ%M}D$hp{Q&vRSa4~cX8 z6w{@Hbx%v_@x?xEfeO^?fr#x?NV1RL|b6Uv^Ld(W+fSu7cQl@ zyMu$VSHe^|p>MXGLMM7;z#nf;#Z)KGX^Lo6QfE?Bwnc0#HAG!)snP^8R@`2JcxSJ@ zR!I_Ve?VbP_Ij2K7IBz6AsQ!Ig>~16u1|6kPCb)zM#vGZxR};$xR2}zQ}1^Yuam|_ z=1HZKFo`|j(n9W5G931tL^og;X}S#CFwalMMVL)0Mx3T|Oo97y%`zcOO z5T^+-fhd0xLI*e}Au37+Oe%%^ z@!ospybp)UMfO|t2CitLIL$6IxYnASO7t?06V*8F&@4A5P{56-g5zPrbiEGEU_PZb zWbzZ?i%4XN*UXI#dvUYeR1PmUqTcyaW7cW*bL2O#j2i-NWhY}`oX1OC%Pw^zSoNiP zlpQCD+H|Ehsq=AhDsv)S3QP;UbfyNU z;!UAs`yP=dT^j`cP?akkM$OJU*0fH|nAb_mj=2>STkb55b`^B`tR;GhTq@RDa3NST zwFW3hJFw1{3eurxGFz6mBbuyTx5hb_h`$M)uYb12Odi=EP9QkdhZ)N)8CpI-7g-i| zNH33Ib!RPuie>(;_HunAGtKt>aK=XENJl$DdIqSOKOm9hlz8J$gQ>5VleHZ=#WH&i zNk&UKTZijTBRp| z;3-4TX-?IR_gVggWwX82K#+z-kf=4ufs>4eWL^<7VuRMt#8ge6cFe~7I9jw7mSc-U zU?T%pnSvz~L_5J^dJSnecH#paL`I|XiUHydOx`%XSqBX8DYCnO=5FUclktUXtjOxj zE2AllGOt?iJ1k#>I19v_C~vr(<9+Asxjt7O1|osyZ5i z66VE2vi+VE%v2U2C00?=JiHZnVzhN*)?$ZM?YyuZn*wvC>~Mc5X%7de(=WSr!RTm5 z{b3I%G?((S%Aiah=X^0k`k;t{B+e?%>>@jz9|=~%w=S|u5@~4cOlpi)mEr245FLOl z)XVHBWL`Qyai*!xtWFx)^9Ey-NnJN2b?gZ#!-+F%jGK))TtKdbZ09pQ zYu}*q{p*vqlNzUyA^W|zlw}YOv4z3%im(KC!e@+H?3hs3$~Femv8~)UrTJ@uOqf2v z=M@}0WxJzN(s5gKM==4d?%>x*PQd6PlFT@h?U_a)dz&@gNng{ogQk^ee?huqZ{I0g zU5jXG)SbMi8?`fi>aksT9i4gRsYqufQx0asqp`~E>~lE84p+jTAvd-;hQl_8T%-+u zgic50BU9>4ML&YD=RjW#7vU72rs#*HiLQ+WqDby4h{I@Q_dPM7NDbEj+Y)sjC?*jBToRlg@Tl zi-y_p6df4$hcrws1SuvJe`6o2@h7J;2gu#&R18_@ugG$>6X39HWA=?`?hKq~<~x}U zn>KHAzIvL3TMD1#92v2h?DH*mXti(o*<`p-`=;YaDzt^D)%KQ-t83BF{r)+`X`GL* z!}B+HmII|DEGXu%%o!DD|HRG@l7p2}-%LTD4I$+`6HI!*g!s%P3Z1_>@nC5EARi$Q zD9-mYn{f3!DeK28_G)c868SK%$g9=+2%rvO)i+(Iph9hJz!v5_y~1f7{0GP`Gn3O2 zq6K75Q(NYVq^#bVMHmh3mpVm90y304{4E#Y_c%)Onwc+NzEm%z4_tZ^6Bj@lv zgp;rtO}i1f15aMeOG%G&dj|`{g9RPq;JX_;$d9OJH?qjNg9sa>pieQ}M=(IGn0~>>RPK)H);kxD{mrji(0P34`bmG0?=vdwoQ8k zr2)Gz`^?sEA8&AakcL+9okbN-7dumYy(Ic{^KXjO90@rQX@`bLmmDjh0sdPIsW9yY zJ4aCNoWbJIf|6C{P8SSQXC64-sok3yR5RQK0j5@=1XZ#)_NIgBxRy=nQd)4mA)pG&s=oK z-T{XX8%tTL@ZhotvcdPw(rXia)*aH3s^ZRO*!PnI?J2#6*)QoMGLhILT>#5~MZzkS%tX>or_y$tOvq$4kj65OGMBY}9~TnW5o6XLq)S zcbnKoVv-_RV*28^S2}YQ?U(7*ShAGuZ1Zq75Al(~qKNIPKD`YbCeq1DTeA2e#q8Q_ zxNv|g_yoI-OR*N+W_$Kc>U~1aAup<>Lw4dUtIeCY&e(?PU^`fcB-q1_9=QacFK0Sw zo#MMY=fY*T&)Y+AcX?|1CvCHHeX>p^JQ3p>uzqEyeeA72G@k1Y_ZpFye>+)!fgOF>hSpKp7Rot4eejXB2*`wb?^9?SH2;h9Xq$L+q`Y#_PvWk zn#DJ@?MycjyObO9Cyn+8588HpdL(mdklW<$7`VabeMHpdOV?P+H95)N zY1*amxm+ID9t#M$r_cI2MUOg8#;AnFy`0Ni9{# zuRxcLGJR^93ASgOo}l3trJ5vUpTF90HfI85$%R(o*b){tM3E{&y31|Zyp4Yzs>SCW z^3~HvFF~|=+D|$M@4Z57h!IHt4$p!Goj!3Ez4g&{QYDaZC`g`@4ZJpw~rd<$lxcX zRXxP|+7B%foFvW+l#PKI4cd5D7xu+x^Ti|@HJ&`F+4|JV>4|n1T5Mq&5Lg*F%8ehmlq~llle9F|B>m#S5Sc4 z6&&7O%1@8QyJq-SkmIzMml|s-WqtXYCK+QZZ(!@@tsBxYSUIv{V4Xg*BUI0BRx%q0 zcs@tX`EZ%-@}XI;-m`n-@Fi(FwH8}r70khJ}av ze-~5Aw}>XmL`ESaU{lhn|4$-IS$p~fmvZkkgv6K9gxd-7$!v6~%u}V4K2w;&jv|Vb zk1Z7*==J|7wp7|u$``j*c&W6B#~Wd)MuyH9Q^fbMP*OX}6@{>fw^Z`e`6AwCes4ri zVwEbUM;dR+9xO+M=pd%0%vUDz~$UxFKRq(?T zZh-@7HHh2Cpu!K9(+=E-k3q%jLW_7=FmYT3_-<$mpXqXzqf{uAwe)jy2Bo4r60;%R zu*3u{pqTuKXJv?r8djo?*lH`u-O}(z{ub`ZOO^TA53}SC_CZFXrjmjJL;3RGu+pQ!OlT|ohzP-%7H3rPgpb2oq-ZkMXa+W{l)-5}VJ%QOjd%u$9T|_K9K&qHVI;}&YA#o8Eit^B`m<^k*;MNMUv2uEE zx+yiv8^BQIHBTZL#@C8V8<(@qHjTayl%-Zu0u*72WD+xrO%2Fe`Awo*xGYVXd*(af zw)2w4AIukK?_-Y;BPayN3Xd3~@JQ1sDh-5^kBRA&25WMo#z@Z|Bc@or<|?FpA)gPO zMR)T>yu}=tLX^xtD4)A?!}iGH0%$#gEEa=G3OqA8SNSgZ)$vu}^3Y!wQHz*)8t!aQ zvoW=LH-Z{jG^l#DD!##NW*=uuU+XZzoDD*6?5d$>_cR|N##W{^ebc6MN9qt{3z{nA zS;>me0UMZokR3)a8AB1BS&A<57X4_JS@Fc)(rU4hXu@mZH2bxH^FI7mc!u+|UOs9M zU8njFL^crD9I1RbE|&sz!$^yIZB2<@lR#Z8F4m`xs#*|8i^)Z{gwrS{S6(5x@IPw- zlb$85lh5?oPBo)@8%NBH?l3x75>r zVQJMa)9mvVIsuq$8Xj@Pt_^${CwHhKO41f=&=A;5rcT`IpFT!|1j?9ynp}1y|v4qfrwI}&F-VC=d*XojX8*ag6 zMQ4sHqL*nW3k>SzDADscx=H^nyqDvi3i%c7^jk-a+*DrU$Euh;md<~kU{%vhkNT^y zUhW6nUy(*rDv8#GN2Ftyn^oJ+qH6?tlddnRp3s&GwTNH4RIH+V<@xYO(Y~11H2PPP zzA+N-kZ@;8>M_c`L}Y>U#D#JZtEIsg7A`BSOjBW7g(K01ZqcU=N+}6YWGFlzZN#)U z`#?L8nO62HAkAgrzcg->dM>ay7vp_(_+cwfXZ72Fg=Izj$0)S0%Jkht^2sb>F zlF&m~)8d0=O$LFT;aI|83P_B$I5fm(WpwnzNO7$Y#P-phV~9b6->`eb&aIobtzEyJU}4w8;wt%p zd6}pw-P7U^3K_z( zk;ROWy5M5RU0i#ZvAo3@%apgiG_K_jlPQlQ!nC9bF$R;M$;{n+!#r>cu10Y-nMxU< zITG(Gd#fPdn7uEx_XZXobd2RI>Qlrq1R$%NCOQ8vhE~v^*q5tA-@Kv?3PP5RK9;Bq z+I!HNM!$iYNnNopWH2BZ2i%2nT}U!<#yrLg19P)WGJ7w*i-N}C7#||SSt(S0RftX2 zmL}1r{2}MCdK2A2r`*c*wmdyFpHOY!&nv^=xmN2xNp{zkX=1fnknzKBN8z2ReU_&=bv-&&wS%dnIbUj zG_uaw7;2`xayl7``q~x%t!Hg+0y@K>dH;=6Ea$m_YVbSof33Urcxdyaedt&Y)rw#a zkS49u(N%F9>^jtc9~|uw&uXsnKOl*m+f(fo_g2ZU?Uq-ZJ|Y4QSxw_b=S>nt(k50`ox`eCuu^swLs1?uRQJ0BO07=PuE6o zhA93=h`5G~NUeENc>;5md1R&+Y6WrEjxZP!D4t_drBrt#CDgy{`BklBvuG(xJ4NQq z!r;<59n>sbake=v4P=g-K~a}MVY%>~;aHX8;E2mg zD705gy5`mgog-~`1-%m!P;CLt?QB%i+OBF`a~D=>SLUSH&iay47d{F!VPV4%R-P6w z*3V=xv0)ELpJegzqgXbwuS7n4T(8FTCpZ^Ju4kM2W}jkG)^aMs(gk!p#h`RM_aV+?v&)kf`UT|ckwxsH$zlDeZJz(M z)ukl|PxH&oDUa>r?u%*fX;-%7(5~cdcG~939yqCSJZ5^Hb~1ILPu9?dWRT+|n=5VS zLUO}tystf5MrTWjG1p-!1{={EMsB{OVRj~TJb{h{FEGw%=Yn#=v7&wIe3Y6t&ih37 zE!>@(uX-J0pH$G(jnocK_@k}Z=QS&oh0s?jhW~nj2&CV0ZLe&zFD&^We_D&57KHp zQpv`WZ}VusHdIQmmp)DC>ZhH~=Zh?vy3)0*nmJPW@#{)~t*f0k?bK1Vx$n*BDzk1( zN%E~Vn^=A>k%$W;bo^z7SxXB${xZ7S(^Z7=K{}IKyi86HW|PpVPKIgMq>Ydi{LjV& z=RQZOaBY@x(i{D`vBs|Q;s3IWz|mi37Ss7Z4hrf$o7S=3eM$Qodezn$f=Td2hGX{T z$9Dceqyn=kB{{Q1dlcn&H6{9(dWuQfH$vEwineUicl5nzpS1gkf;KfnJ|}JMs};u-O|I&MCc0OwS(v@QXWLXOa)e-mbJW^Rs4NCLW;D>Z ztzD$qnaQ?=6|BW#5IXLUv$+po|>$ZRF z^iQ0IL^K}Dlo%J$Y=`y1^tzoeYl8_9=1oT{x`HHzwIyxY0wYR;u$?o+vQFVhU($yf zW~QKKVO)42YFXs~cJeQy8%In@s%?vTS{Oy`JZmRaM>!UdMCDo-#raF~N!g8BU|NM$ zB&pkVbd;9!;RAF?+2So?pgX=)z`>0j!>Gc8yn8P=87#_TlEIyCVu5z&u({W!v-kAa z@(%}t5SQ$`GCa-#VPf%bP+vGDWKB)kQ@X1C=@=(%v+)=qqOflpsKTd(&&{;(y{r5+ zAugkH`tc;$q4%lX-0Co~iNL@$q@)J{Y7OO|bYs;(8MX_U4bFH^d1PA9uEWs?$$*Cb1s|=C5bUvy2X}3mxE+&-UC!fVd^9VwHEPq(qi%8M zj>JH=j%_m{S);hU6gP_9W#EcrKh2fois5V`=P%^Z@-nZ+XJ=WiMImk*M#8C0qwJUC zkttrG=xnK-HO4p++i5VHn)%7B6rFz4GBmzvi_UN5XBcocHwwe-F?STgg_yL!l8$Sn z#dfwRTLStX^wZXgO!6QK+_ra5F!pJc#vj?%ZZ zqecQ(K7w3qS}Y_NV=TsH2Ln<)iesq+(SvsQSQS|;txDAA581kCmTGf23Ta`sklN-_ zl;7OPV3T&QiFkdtMi&tSMXQ9u#S1>$$G&|5l~ zjaf^_QJnkil~4u?3wUV^0wq4-UAYkWlIdx3MnT~UGQ?;4gwC3_SRm~LQLlv|wwRcK zq35fGDXEx>45bq@ihwEpWJZ8FS0zBbw>K?Ohl?65mb%Ggj)!I@Q=9WHL?$jTytFFW z%LJx9A@XdvOa>ZyS-AZb!d_0cS zV(Cx9trk?SO`}t;+-{d2^mLH*&v9ml-!-iBC`Hg!6GM_rVFJ^#=E&=9f3me%dts2W ztk;aY@FLU8UOIqVB(gLUyGs(nnXC|%BPo0nirR^6A~dIyf+WHyV@*{!+Xi2c+!i-9 zVuy?~3O^Kt0*D?>7JtB2KgDS{^3DGV+NlyWjwMdBw?YN{Ly6ipj~FwhZ%8TEa;B&r z%h^sxRfF%ssTi~O&z(p7$n3k!BA_ZQOc&PEjw7Yj(!!usI0>l&P?-@@TEE2g&PZ!K zBsguCD8{D<+jeaehk2qOcWx_$hHEt1>uT?y9|&iayKg_Dt}I5qK}*r%ZZc&GwCj4U zQBC8E)D!}=s|Z`)GUQytF!|bAl}7WdDb%Gc;ncbdn~|OxeD4`C+f_OKl0r_AUfaNR zv?hAElB9u9hG2T5Tf_E2SK!HI^K5MUBbG|@H3 zvSoFL6BU(ZDhu&MduKOpP-_r?0%x^IEa`=dE-IbU!i3t((CTDkBiV3p-UjHYoIYICUaKXC_*F38WFDf%@oxh&`;UT5QoW@F0h67*fbA)}g+UfgR{7 zkf+>JG7{A!k%myH(8@)cfS)p~DG3r*TzanOgK7zZk zqey$vsC`UQx4gn`6kXIg^Miac>Bz~nVOXrQ=4p}1SIT3dC#Qv-=+PXf=7b|S7<}g; zJu@&QVQl1zIO<$Y-1E;SG{u9vzGjK++x!KcRgh3{+CU~#x5v}@+maIwnOw3^Odr!X zZV4@+f+XvMga6w4WZt^JM_{~;(-3a6I_xB<__f72RVam8lo-C*NTs+_=nonFe#*Q_Q|D)9tP$*Z!M(R` zFg>&{IhDj^v;e8lw3{->13F7NQR0{laZVR327v<2yQe0LDjxz69DPU32hfUDV@ zp;dFAzv-@>1}D=kORkbX8kos+>xe%rK9>(V#8hRBI*)ev0ZeGVa}@d<q*Iu(TD$lde5lU?nwV>SBIGkgtUmbf^Xx}EeN20vbjyDBp7SY z@~nVPIidBl!2D9|vpZ$~;|BFCaA6IkDUST@+nI!wiMJ^XY=5dSrfo+k%qxuevk$Gv zm~PKonclwy4Vd1*hoV(!-)8IMISw|g%t{{@7J|vB3;F6qnGIx_uol+LwgKkJ?YW#! z@1$L(F5Fx8?Iw>bo-9tUARCwZdCaIQ{sdv0J{Kir9z?NV5VdnEHyS*i{W3nS5Xtj6 z*GIFZ)dxy`ph)abQD zy6*O={kE$tVLnDO{V;my*f#euQ_wn+4Fssib`=(7j{8!m`IkA5q4CX%tohFhw`Z14 zBeREc+OmdovQ$sFN*OyDkGHgFNK@f$`>zK2tBrnt=02uce|FXQA_{6(wA)f6>YvGu zEU_ujpzEA~X2Uf^yp3}Tc-ucKWp;dP)wh=8N$NBg`&Pz(3r^e2PD+HQMZoP_8DrX; zY;4z~-{_HRhJ$weOEvnEkccw5G!m}nFx{2Pp(Wd}@I@BEluh8+Ksc|#VD{U1Q=}0! zVdE@Qfd)1mznhc2fA{sAWAT}Z?nqA9TxK5T<|n^9eS2J*tVGQ2j`uiu+&|;O6d(Ct z=-a|I6rW*UJwDY=(zvs35S$Om+u2Ni+sR`-bd?^O>Wa3?Xkk}{(Q%dAmEA303hu0N zu5zI}{y7iaSWc};$_S44M>^e*=2Dikh12N1KBlk9T04QD%JUWe zO_HOtX0{-V?dux}W6oJ}Ow;SeUc_Q$x`ROkL4co?_`=do*{30Yb+F4Ee<9{C^GIWS zeqs+(lf3J}yv|1^u3QY@X4xGAXxkyhxt2}tS4;Zwe_LXvp>4Y^1ny;P8Mi?)QZ{ag zHnyDIVKh?#+7tUgz;GzWxFcvrXgda78QOvayQcI_nT-#uq?*UXztmN- zcNZ}iEEPT`2-98rmT2OpjS4l&}A`Ki5Y23st#dGndifn z4!u6s0U%r8!PBq3I!OswR1&S&efp&>MLQbFWUw32%(GXJSTQ@?PHA(JV{$&@|y^=a7F4vQ^D zMKgsm8ywlG5E3tRNlP8EW7MPy>KqL!ir@3Ezv={<8tVeK8SQn=o>spOA7rvXDGHfv zMFy56za!84XMgAzb^3i47hyArtZb$)T%_T{DwEK49AQKc(&6ao8O!)PX{$J3SS;d0 zE<}cRX_(|TouX|Ih9L;1W9EZ5n3huc(|p}&C07-^&#C zr6=K;vCrKQYh;Oe&2Dy#T6bF{Flrj}pCr zY?(anTN9&f?c+!)`@LBw2Sn8D5wYf7Y$r~_`{>cMJ~3KN+#q4lvU&!Qc14&LmmXkC zi)wFjGBK>yP_QjJJ|)Z6-aYDlxnomt<8 literal 0 HcmV?d00001 diff --git a/po/es.po b/po/es.po new file mode 100644 index 0000000..6aeeeb7 --- /dev/null +++ b/po/es.po @@ -0,0 +1,2392 @@ +# Mensajes en español para gawk-4.0.0h. +# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. +# This file is distributed under the same license as the gawk package. +# Cristian Othón Martínez Vera , 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012. +# +msgid "" +msgstr "" +"Project-Id-Version: gawk 4.0.0h\n" +"Report-Msgid-Bugs-To: arnold@skeeve.com\n" +"POT-Creation-Date: 2012-03-28 22:03+0200\n" +"PO-Revision-Date: 2012-01-30 07:42-0600\n" +"Last-Translator: Cristian Othón Martínez Vera \n" +"Language-Team: Spanish \n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: array.c:140 +#, c-format +msgid "from %s" +msgstr "desde %s" + +#: array.c:248 +msgid "attempt to use a scalar value as array" +msgstr "se intentó usar un valor escalar como una matriz" + +#: array.c:251 +#, c-format +msgid "attempt to use function `%s' as an array" +msgstr "se intentó usar la función `%s' como una matriz" + +#: array.c:254 +#, c-format +msgid "attempt to use scalar parameter `%s' as an array" +msgstr "se intentó usar el parámetro escalar `%s como una matriz'" + +#: array.c:257 +#, c-format +msgid "attempt to use scalar `%s' as an array" +msgstr "se intentó usar el escalar `%s' como una matriz" + +#: array.c:302 array.c:707 builtin.c:84 builtin.c:1385 builtin.c:1427 +#: builtin.c:1440 builtin.c:1859 builtin.c:1871 eval.c:1135 eval.c:1139 +#: eval.c:1495 eval.c:1812 +#, c-format +msgid "attempt to use array `%s' in a scalar context" +msgstr "se intentó usar la matriz `%s' en un contexto escalar" + +#: array.c:513 +#, c-format +msgid "reference to uninitialized element `%s[\"%.*s\"]'" +msgstr "referencia al elemento sin inicializar `%s[\"%.*s\"]'" + +#: array.c:519 +#, c-format +msgid "subscript of array `%s' is null string" +msgstr "el subíndice de la matriz `%s' es la cadena nula" + +#: array.c:723 +#, c-format +msgid "delete: index `%s' not in array `%s'" +msgstr "delete: el índice `%s' no está en la matriz `%s'" + +#: array.c:734 eval.c:1865 +#, c-format +msgid "attempt to use scalar `%s[\"%.*s\"]' as an array" +msgstr "se intentó usar el dato escalar `%s[\"%.*s\"]' como una matriz" + +#: array.c:910 +#, c-format +msgid "%s: empty (null)\n" +msgstr "%s: vacío (nulo)\n" + +#: array.c:915 +#, c-format +msgid "%s: empty (zero)\n" +msgstr "%s: vacío (cero)\n" + +#: array.c:919 +#, c-format +msgid "%s: table_size = %d, array_size = %d\n" +msgstr "%s: tamaño_tabla = %d, tamaño_matriz = %d\n" + +#: array.c:954 +#, c-format +msgid "%s: is parameter\n" +msgstr "%s: es un parámetro\n" + +#: array.c:958 +#, c-format +msgid "%s: array_ref to %s\n" +msgstr "%s: array_ref a %s\n" + +#: array.c:963 +msgid "adump: argument not an array" +msgstr "adump: el argumento no es una matriz" + +#: array.c:1086 +msgid "asort: second argument not an array" +msgstr "asort: el segundo argumento no es una matriz" + +#: array.c:1087 +msgid "asorti: second argument not an array" +msgstr "asorti: el segundo argumento no es una matriz" + +#: array.c:1094 +msgid "asort: first argument not an array" +msgstr "asort: el primer argumento no es una matriz" + +#: array.c:1095 +msgid "asorti: first argument not an array" +msgstr "asorti: el primer argumento no es una matriz" + +#: array.c:1102 +msgid "asort: cannot use a subarray of first arg for second arg" +msgstr "" +"asort: no se puede usar una submatriz del primer argumento para el segundo " +"argumento" + +#: array.c:1103 +msgid "asorti: cannot use a subarray of first arg for second arg" +msgstr "" +"asorti: no se puede usar una submatriz del primer argumento para el segundo " +"argumento" + +#: array.c:1108 +msgid "asort: cannot use a subarray of second arg for first arg" +msgstr "" +"asort: no se puede usar una submatriz del segundo argumento para el primer " +"argumento" + +#: array.c:1109 +msgid "asorti: cannot use a subarray of second arg for first arg" +msgstr "" +"asorti: no se puede usar una submatriz del segundo argumento para el primer " +"argumento" + +#: array.c:1655 +#, c-format +msgid "`%s' is invalid as a function name" +msgstr "`%s' es inválido como un nombre de función" + +#: array.c:1659 +#, c-format +msgid "sort comparison function `%s' is not defined" +msgstr "la función de comparación de ordenamiento `%s' no está definida" + +#: awkgram.y:249 +#, c-format +msgid "%s blocks must have an action part" +msgstr "los bloques %s deben tener una parte de acción" + +#: awkgram.y:252 +msgid "each rule must have a pattern or an action part" +msgstr "cada regla debe tener un patrón o una parte de acción" + +#: awkgram.y:323 awkgram.y:334 +msgid "old awk does not support multiple `BEGIN' or `END' rules" +msgstr "el awk antiguo no admite múltiples reglas `BEGIN' o `END'" + +#: awkgram.y:371 +#, c-format +msgid "`%s' is a built-in function, it cannot be redefined" +msgstr "`%s' es una función interna, no se puede redefinir" + +#: awkgram.y:432 +msgid "regexp constant `//' looks like a C++ comment, but is not" +msgstr "" +"la constante de expresión regular `//' parece un comentario de C++, pero no " +"lo es" + +#: awkgram.y:436 +#, c-format +msgid "regexp constant `/%s/' looks like a C comment, but is not" +msgstr "" +"la constante de expresión regular `/%s/' parece un comentario de C, pero no " +"lo es" + +#: awkgram.y:528 +#, c-format +msgid "duplicate case values in switch body: %s" +msgstr "valores case duplicados en el cuerpo de un switch: %s" + +#: awkgram.y:549 +msgid "duplicate `default' detected in switch body" +msgstr "se detectó un `default' duplicado en el cuerpo de un switch" + +#: awkgram.y:809 +msgid "`break' is not allowed outside a loop or switch" +msgstr "no se permite `break' fuera de un bucle o switch" + +#: awkgram.y:818 +msgid "`continue' is not allowed outside a loop" +msgstr "no se permite `continue' fuera de un bucle" + +#: awkgram.y:828 +#, c-format +msgid "`next' used in %s action" +msgstr "se usó `next' en la acción %s" + +#: awkgram.y:836 +msgid "`nextfile' is a gawk extension" +msgstr "`nextfile' es una extensión de gawk" + +#: awkgram.y:841 +#, c-format +msgid "`nextfile' used in %s action" +msgstr "se usó `nextfile' en la acción %s" + +#: awkgram.y:865 +msgid "`return' used outside function context" +msgstr "se usó `return' fuera del contexto de la función" + +#: awkgram.y:925 +msgid "plain `print' in BEGIN or END rule should probably be `print \"\"'" +msgstr "" +"el `print' simple en la regla BEGIN o END probablemente debe ser `print \"\"'" + +#: awkgram.y:995 awkgram.y:999 awkgram.y:1023 +msgid "`delete array' is a gawk extension" +msgstr "`delete array' es una extensión de gawk" + +#: awkgram.y:1019 +msgid "`delete(array)' is a non-portable tawk extension" +msgstr "`delete(array)' es una extensión de tawk que no es transportable" + +#: awkgram.y:1135 +msgid "multistage two-way pipelines don't work" +msgstr "las líneas de trabajo de dos vías multiestado no funcionan" + +#: awkgram.y:1238 +msgid "regular expression on right of assignment" +msgstr "expresión regular del lado derecho de una asignación" + +#: awkgram.y:1249 +msgid "regular expression on left of `~' or `!~' operator" +msgstr "expresión regular a la izquierda del operador `~' o `!~'" + +#: awkgram.y:1265 awkgram.y:1419 +msgid "old awk does not support the keyword `in' except after `for'" +msgstr "" +"el awk antiguo no admite la palabra clave `in' excepto después de `for'" + +#: awkgram.y:1275 +msgid "regular expression on right of comparison" +msgstr "expresión regular a la derecha de una comparación" + +#: awkgram.y:1394 +#, c-format +msgid "`getline var' invalid inside `%s' rule" +msgstr "`getline var' inválido dentro de la regla `%s'" + +#: awkgram.y:1397 eval.c:2504 +#, c-format +msgid "`getline' invalid inside `%s' rule" +msgstr "`getline' inválido dentro de la regla `%s'" + +#: awkgram.y:1402 +msgid "non-redirected `getline' undefined inside END action" +msgstr "`getline' no redirigido indefinido dentro de la acción de END" + +#: awkgram.y:1421 +msgid "old awk does not support multidimensional arrays" +msgstr "el awk antiguo no admite matrices multidimensionales" + +#: awkgram.y:1517 +msgid "call of `length' without parentheses is not portable" +msgstr "la llamada de `length' sin paréntesis no es transportable" + +#: awkgram.y:1580 +msgid "indirect function calls are a gawk extension" +msgstr "las llamadas indirectas a función son una extensión de gawk" + +#: awkgram.y:1593 +#, c-format +msgid "can not use special variable `%s' for indirect function call" +msgstr "" +"no se puede usar la variable especial `%s' como llamada indirecta a función" + +#: awkgram.y:1671 +msgid "invalid subscript expression" +msgstr "expresión de subíndice inválida" + +#: awkgram.y:1711 +msgid "use of non-array as array" +msgstr "uso de una matriz que no es matriz" + +#: awkgram.y:1975 awkgram.y:1995 msg.c:98 +msgid "warning: " +msgstr "aviso: " + +#: awkgram.y:1993 msg.c:130 +msgid "fatal: " +msgstr "fatal: " + +#: awkgram.y:2043 +msgid "unexpected newline or end of string" +msgstr "nueva línea o fin de la cadena inesperados" + +#: awkgram.y:2300 awkgram.y:2358 awkgram.y:2542 +#, c-format +msgid "can't open source file `%s' for reading (%s)" +msgstr "no se puede abrir el fichero fuente `%s' para lectura (%s)" + +#: awkgram.y:2301 awkgram.y:2359 builtin.c:122 +msgid "reason unknown" +msgstr "razón desconocida" + +#: awkgram.y:2317 +#, c-format +msgid "already included source file `%s'" +msgstr "ya se incluyó el fichero fuente `%s'" + +#: awkgram.y:2343 +msgid "@include is a gawk extension" +msgstr "@include es una extensión de gawk" + +#: awkgram.y:2349 +msgid "empty filename after @include" +msgstr "nombre de fichero vacío después de @include" + +#: awkgram.y:2494 +msgid "empty program text on command line" +msgstr "texto de programa vacío en la linea de órdenes" + +#: awkgram.y:2609 +#, c-format +msgid "can't read sourcefile `%s' (%s)" +msgstr "no se puede leer el fichero fuente `%s' (%s)" + +#: awkgram.y:2620 +#, c-format +msgid "source file `%s' is empty" +msgstr "el fichero fuente `%s' está vacío" + +#: awkgram.y:2797 +msgid "source file does not end in newline" +msgstr "el fichero fuente no termina con línea nueva" + +#: awkgram.y:2900 +msgid "unterminated regexp ends with `\\' at end of file" +msgstr "expresión regular sin terminar termina con `\\` al final del fichero" + +#: awkgram.y:2924 +#, c-format +msgid "%s: %d: tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "" +"%s: %d: el modificador de expresión regular `/.../%c` de tawk no funciona en " +"gawk" + +#: awkgram.y:2928 +#, c-format +msgid "tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "" +"el modificador de expresión regular `/.../%c` de tawk no funciona en gawk" + +#: awkgram.y:2935 +msgid "unterminated regexp" +msgstr "expresión regular sin terminar" + +#: awkgram.y:2939 +msgid "unterminated regexp at end of file" +msgstr "expresión regular sin terminar al final del fichero" + +#: awkgram.y:2998 +msgid "use of `\\ #...' line continuation is not portable" +msgstr "el uso de la continuación de línea `\\ #...' no es transportable" + +#: awkgram.y:3014 +msgid "backslash not last character on line" +msgstr "la barra invertida no es el último caracter en la línea" + +#: awkgram.y:3075 +msgid "POSIX does not allow operator `**='" +msgstr "POSIX no permite el operador `**='" + +#: awkgram.y:3077 +msgid "old awk does not support operator `**='" +msgstr "el awk antiguo no admite el operador `**='" + +#: awkgram.y:3086 +msgid "POSIX does not allow operator `**'" +msgstr "POSIX no permite el operador `**'" + +#: awkgram.y:3088 +msgid "old awk does not support operator `**'" +msgstr "el awk antiguo no admite el operador `**='" + +#: awkgram.y:3123 +msgid "operator `^=' is not supported in old awk" +msgstr "el operador `^=' no se admite en el awk antiguo" + +#: awkgram.y:3131 +msgid "operator `^' is not supported in old awk" +msgstr "el operador `^' no se admite en el awk antiguo" + +#: awkgram.y:3224 awkgram.y:3240 +msgid "unterminated string" +msgstr "cadena sin terminar" + +#: awkgram.y:3436 +#, c-format +msgid "invalid char '%c' in expression" +msgstr "caracter '%c' inválido en la expresión" + +#: awkgram.y:3483 +#, c-format +msgid "`%s' is a gawk extension" +msgstr "`%s' es una extensión de gawk" + +#: awkgram.y:3488 +#, c-format +msgid "`%s' is a Bell Labs extension" +msgstr "`%s' es una extensión de Bell Labs" + +#: awkgram.y:3493 +#, c-format +msgid "POSIX does not allow `%s'" +msgstr "POSIX no permite `%s'" + +#: awkgram.y:3501 +#, c-format +msgid "`%s' is not supported in old awk" +msgstr "`%s' no se admite en el awk antiguo" + +#: awkgram.y:3568 +msgid "`goto' considered harmful!\n" +msgstr "¡`goto' se considera dañino!\n" + +#: awkgram.y:3619 +#, c-format +msgid "%d is invalid as number of arguments for %s" +msgstr "%d es inválido como número de argumentos para %s" + +#: awkgram.y:3654 +#, c-format +msgid "%s: string literal as last arg of substitute has no effect" +msgstr "" +"%s: la literal de cadena como último argumento de substitute no tiene efecto" + +#: awkgram.y:3659 +#, c-format +msgid "%s third parameter is not a changeable object" +msgstr "el tercer argumento de %s no es un objecto modificable" + +#: awkgram.y:3732 awkgram.y:3735 +msgid "match: third argument is a gawk extension" +msgstr "match: el tercer argumento es una extensión de gawk" + +#: awkgram.y:3789 awkgram.y:3792 +msgid "close: second argument is a gawk extension" +msgstr "close: el segundo argumento es una extensión de gawk" + +#: awkgram.y:3804 +msgid "use of dcgettext(_\"...\") is incorrect: remove leading underscore" +msgstr "" +"el uso de dcgettext(_\"...\") es incorrecto: quite el subrayado inicial" + +#: awkgram.y:3819 +msgid "use of dcngettext(_\"...\") is incorrect: remove leading underscore" +msgstr "" +"el uso de dcngettext(_\"...\") es incorrecto: quite el subrayado inicial" + +#: awkgram.y:3911 +#, c-format +msgid "function `%s': parameter #%d, `%s', duplicates parameter #%d" +msgstr "función `%s': parámetro #%d, `%s', duplica el parámetro #%d" + +#: awkgram.y:3953 +#, c-format +msgid "function `%s': parameter `%s' shadows global variable" +msgstr "función `%s': parámetro `%s' oscurece la variable global" + +#: awkgram.y:4111 +#, c-format +msgid "could not open `%s' for writing (%s)" +msgstr "no se puede abrir `%s' para escritura (%s)" + +#: awkgram.y:4112 +msgid "sending variable list to standard error" +msgstr "se envía la lista de variables a la salida estándar de error" + +#: awkgram.y:4118 +#, c-format +msgid "%s: close failed (%s)" +msgstr "%s: falló close (%s)" + +#: awkgram.y:4170 +msgid "shadow_funcs() called twice!" +msgstr "¡se llamó shadow_funcs() dos veces!" + +#: awkgram.y:4176 +msgid "there were shadowed variables." +msgstr "hay variables opacadas." + +#: awkgram.y:4206 +#, c-format +msgid "function `%s': can't use function name as parameter name" +msgstr "" +"función `%s': no se puede usar un nombre de función como nombre de parámetro" + +#: awkgram.y:4210 +#, c-format +msgid "function `%s': can't use special variable `%s' as a function parameter" +msgstr "" +"función `%s': no se puede usar la variable especial `%s' como un parámetro " +"de función" + +#: awkgram.y:4226 +#, c-format +msgid "function name `%s' previously defined" +msgstr "el nombre de función `%s' se definió previamente" + +#: awkgram.y:4394 awkgram.y:4400 +#, c-format +msgid "function `%s' called but never defined" +msgstr "se llamó a la función `%s' pero nunca se definió" + +#: awkgram.y:4403 +#, c-format +msgid "function `%s' defined but never called directly" +msgstr "se definió la función `%s' pero nunca se llamó directamente" + +#: awkgram.y:4435 +#, c-format +msgid "regexp constant for parameter #%d yields boolean value" +msgstr "" +"la constante de expresión regular para el parámetro #%d da un valor booleano" + +#: awkgram.y:4544 +#, c-format +msgid "" +"function `%s' called with space between name and `(',\n" +"or used as a variable or an array" +msgstr "" +"se llamó la función `%s' con espacio entre el nombre y el `(',\n" +"o se usó como una variable o una matriz" + +#: awkgram.y:4791 eval.c:2056 +msgid "division by zero attempted" +msgstr "se intentó una división por cero" + +#: awkgram.y:4800 eval.c:2072 +#, c-format +msgid "division by zero attempted in `%%'" +msgstr "se intentó una división por cero en `%%'" + +#: builtin.c:120 +#, c-format +msgid "%s to \"%s\" failed (%s)" +msgstr "falló %s a \"%s\" (%s)" + +#: builtin.c:121 +msgid "standard output" +msgstr "salida estándar" + +#: builtin.c:135 +msgid "exp: received non-numeric argument" +msgstr "exp: se recibió un argumento que no es númerico" + +#: builtin.c:141 +#, c-format +msgid "exp: argument %g is out of range" +msgstr "exp: el argumento %g está fuera de rango" + +#: builtin.c:200 +#, c-format +msgid "fflush: cannot flush: pipe `%s' opened for reading, not writing" +msgstr "" +"fflush: no se puede limpiar: se abrió la tubería `%s' para lectura, no para " +"escritura" + +#: builtin.c:203 +#, c-format +msgid "fflush: cannot flush: file `%s' opened for reading, not writing" +msgstr "" +"fflush: no se puede limpiar: se abrió el fichero `%s' para lectura, no para " +"escritura" + +#: builtin.c:215 +#, c-format +msgid "fflush: `%s' is not an open file, pipe or co-process" +msgstr "fflush: `%s' no es un fichero abierto, tubería o co-proceso" + +#: builtin.c:333 +msgid "index: received non-string first argument" +msgstr "index: el primer argumento recibido no es una cadena" + +#: builtin.c:335 +msgid "index: received non-string second argument" +msgstr "index: el segundo argumento recibido no es una cadena" + +#: builtin.c:457 +msgid "int: received non-numeric argument" +msgstr "int: se recibió un argumento que no es númerico" + +#: builtin.c:493 +msgid "length: received array argument" +msgstr "length: se recibió un argumento de matriz" + +#: builtin.c:496 +msgid "`length(array)' is a gawk extension" +msgstr "`length(array)' es una extensión de gawk" + +#: builtin.c:504 +msgid "length: received non-string argument" +msgstr "length: se recibió un argumento que no es una cadena" + +#: builtin.c:535 +msgid "log: received non-numeric argument" +msgstr "log: se recibió un argumento que no es númerico" + +#: builtin.c:538 +#, c-format +msgid "log: received negative argument %g" +msgstr "log: se recibió el argumento negativo %g" + +#: builtin.c:694 builtin.c:699 +msgid "fatal: must use `count$' on all formats or none" +msgstr "fatal: se debe utilizar `count$' en todos los formatos o en ninguno" + +#: builtin.c:762 +#, c-format +msgid "field width is ignored for `%%' specifier" +msgstr "se descarta la anchura del campo para el especificador `%%'" + +#: builtin.c:764 +#, c-format +msgid "precision is ignored for `%%' specifier" +msgstr "se descarta la precisión para el especificador `%%'" + +#: builtin.c:766 +#, c-format +msgid "field width and precision are ignored for `%%' specifier" +msgstr "" +"se descartan la anchura del campo y la precisión para el especificador `%%'" + +#: builtin.c:817 +msgid "fatal: `$' is not permitted in awk formats" +msgstr "fatal: no se permite `$' en los formatos de awk" + +#: builtin.c:826 +msgid "fatal: arg count with `$' must be > 0" +msgstr "fatal: la cuenta de argumentos con `$' debe ser > 0" + +#: builtin.c:830 +#, c-format +msgid "fatal: arg count %ld greater than total number of supplied arguments" +msgstr "" +"fatal: la cuenta de argumentos %ld es mayor que el número total de " +"argumentos proporcionados" + +#: builtin.c:834 +msgid "fatal: `$' not permitted after period in format" +msgstr "fatal: no se permite `$' después de un punto en el formato" + +#: builtin.c:850 +msgid "fatal: no `$' supplied for positional field width or precision" +msgstr "" +"fatal: no se proporciona `$' para la anchura o la precisión del campo " +"posicional" + +#: builtin.c:921 +msgid "`l' is meaningless in awk formats; ignored" +msgstr "`l' no tiene significado en los formatos de awk; se descarta" + +#: builtin.c:925 +msgid "fatal: `l' is not permitted in POSIX awk formats" +msgstr "fatal: no se permite `l' en los formatos POSIX de awk" + +#: builtin.c:938 +msgid "`L' is meaningless in awk formats; ignored" +msgstr "`L' no tiene significado en los formatos de awk; se descarta" + +#: builtin.c:942 +msgid "fatal: `L' is not permitted in POSIX awk formats" +msgstr "fatal: no se permite `L' en los formatos POSIX de awk" + +#: builtin.c:955 +msgid "`h' is meaningless in awk formats; ignored" +msgstr "`h' no tiene significado en los formatos de awk; se descarta" + +#: builtin.c:959 +msgid "fatal: `h' is not permitted in POSIX awk formats" +msgstr "fatal: no se permite `h' en los formatos POSIX de awk" + +#: builtin.c:1272 +#, c-format +msgid "[s]printf: value %g is out of range for `%%%c' format" +msgstr "[s]printf: el valor %g está fuera del rango para el formato `%%%c'" + +#: builtin.c:1332 +#, c-format +msgid "ignoring unknown format specifier character `%c': no argument converted" +msgstr "" +"se descarta el carácter especificador de formato `%c' desconocido: no se " +"convirtió ningún argumento" + +#: builtin.c:1337 +msgid "fatal: not enough arguments to satisfy format string" +msgstr "" +"fatal: no hay suficientes argumentos para satisfacer a la cadena de formato" + +#: builtin.c:1339 +msgid "^ ran out for this one" +msgstr "se acabó ^ para éste" + +#: builtin.c:1346 +msgid "[s]printf: format specifier does not have control letter" +msgstr "[s]printf: el especificador de formato no tiene letras de control" + +#: builtin.c:1349 +msgid "too many arguments supplied for format string" +msgstr "se proporcionaron demasiados argumentos para la cadena de formato" + +#: builtin.c:1423 builtin.c:1434 +msgid "printf: no arguments" +msgstr "printf: sin argumentos" + +#: builtin.c:1475 +msgid "sqrt: received non-numeric argument" +msgstr "sqrt: se recibió un argumento que no es un númerico" + +#: builtin.c:1479 +#, c-format +msgid "sqrt: called with negative argument %g" +msgstr "sqrt: se llamó con el argumento negativo %g" + +#: builtin.c:1503 +#, c-format +msgid "substr: length %g is not >= 1" +msgstr "substr: la longitud %g no es >= 1" + +#: builtin.c:1505 +#, c-format +msgid "substr: length %g is not >= 0" +msgstr "substr: la longitud %g no es >= 0" + +#: builtin.c:1512 +#, c-format +msgid "substr: non-integer length %g will be truncated" +msgstr "substr: se truncará la longitud no entera %g" + +#: builtin.c:1517 +#, c-format +msgid "substr: length %g too big for string indexing, truncating to %g" +msgstr "" +"substr: la longitud %g es demasiado grande para ser índice de cadena, se " +"trunca a %g" + +#: builtin.c:1529 +#, c-format +msgid "substr: start index %g is invalid, using 1" +msgstr "substr: el índice de inicio %g es inválido, se usa 1" + +#: builtin.c:1534 +#, c-format +msgid "substr: non-integer start index %g will be truncated" +msgstr "substr: se truncará el índice de inicio no entero %g" + +#: builtin.c:1559 +msgid "substr: source string is zero length" +msgstr "substr: la cadena de origen es de longitud cero" + +#: builtin.c:1575 +#, c-format +msgid "substr: start index %g is past end of string" +msgstr "substr: el índice de inicio %g está después del fin de la cadena" + +#: builtin.c:1583 +#, c-format +msgid "" +"substr: length %g at start index %g exceeds length of first argument (%lu)" +msgstr "" +"substr: la cadena %g en el índice de inicio %g excede la longitud del primer " +"argumento (%lu)" + +#: builtin.c:1657 +msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" +msgstr "" +"strftime: el valor de formato en PROCINFO[\"strftime\"] tiene tipo numérico" + +#: builtin.c:1680 +msgid "strftime: received non-numeric second argument" +msgstr "strftime: el segundo argumento recibido no es númerico" + +#: builtin.c:1683 +msgid "strftime: second argument less than 0 or too big for time_t" +msgstr "" +"strftime: el segundo argumento es menor que 0 o demasiado grande para time_t" + +#: builtin.c:1690 +msgid "strftime: received non-string first argument" +msgstr "strftime: el primer argumento recibido no es una cadena" + +#: builtin.c:1696 +msgid "strftime: received empty format string" +msgstr "strftime: se recibió una cadena de formato vacía" + +#: builtin.c:1762 +msgid "mktime: received non-string argument" +msgstr "mktime: se recibió un argumento que no es una cadena" + +#: builtin.c:1779 +msgid "mktime: at least one of the values is out of the default range" +msgstr "" +"mktime: por lo menos uno de los valores está fuera del rango por defecto" + +#: builtin.c:1814 +msgid "'system' function not allowed in sandbox mode" +msgstr "no se permite la función 'system' en modo sandbox" + +#: builtin.c:1819 +msgid "system: received non-string argument" +msgstr "system: se recibió un argumento que no es una cadena" + +#: builtin.c:1874 eval.c:1159 eval.c:1790 eval.c:1803 +#, c-format +msgid "reference to uninitialized variable `%s'" +msgstr "referencia a la variable sin inicializar `%s'" + +#: builtin.c:1941 +#, c-format +msgid "reference to uninitialized field `$%d'" +msgstr "referencia al campo sin inicializar `$%d'" + +#: builtin.c:2028 +msgid "tolower: received non-string argument" +msgstr "tolower: se recibió un argumento que no es una cadena" + +#: builtin.c:2062 +msgid "toupper: received non-string argument" +msgstr "toupper: se recibió un argumento que no es una cadena" + +#: builtin.c:2098 +msgid "atan2: received non-numeric first argument" +msgstr "atan2: el primer argumento recibido no es númerico" + +#: builtin.c:2100 +msgid "atan2: received non-numeric second argument" +msgstr "atan2: el segundo argumento recibido no es númerico" + +#: builtin.c:2119 +msgid "sin: received non-numeric argument" +msgstr "sin: se recibió un argumento que no es númerico" + +#: builtin.c:2135 +msgid "cos: received non-numeric argument" +msgstr "cos: se recibió un argumento que no es númerico" + +#: builtin.c:2188 +msgid "srand: received non-numeric argument" +msgstr "srand: se recibió un argumento que no es númerico" + +#: builtin.c:2219 +msgid "match: third argument is not an array" +msgstr "match: el tercer argumento no es una matriz" + +#: builtin.c:2483 +msgid "gensub: third argument of 0 treated as 1" +msgstr "gensub: el tercer argumento de 0 se trata como 1" + +#: builtin.c:2776 +msgid "lshift: received non-numeric first argument" +msgstr "lshift: el primer argumento recibido no es númerico" + +#: builtin.c:2778 +msgid "lshift: received non-numeric second argument" +msgstr "lshift: el segundo argumento recibido no es númerico" + +#: builtin.c:2784 +#, c-format +msgid "lshift(%lf, %lf): negative values will give strange results" +msgstr "lshift(%lf, %lf): los valores negativos darán resultados extraños" + +#: builtin.c:2786 +#, c-format +msgid "lshift(%lf, %lf): fractional values will be truncated" +msgstr "lshift(%lf, %lf): los valores fraccionarios se truncarán" + +#: builtin.c:2788 +#, c-format +msgid "lshift(%lf, %lf): too large shift value will give strange results" +msgstr "" +"lshift(%lf, %lf): un valor de desplazamiento muy grande dará resultados " +"extraños" + +#: builtin.c:2813 +msgid "rshift: received non-numeric first argument" +msgstr "rshift: el primer argumento recibido no es númerico" + +#: builtin.c:2815 +msgid "rshift: received non-numeric second argument" +msgstr "rshift: el segundo argumento recibido no es númerico" + +#: builtin.c:2821 +#, c-format +msgid "rshift(%lf, %lf): negative values will give strange results" +msgstr "rshift(%lf, %lf): los valores negativos darán resultados extraños" + +#: builtin.c:2823 +#, c-format +msgid "rshift(%lf, %lf): fractional values will be truncated" +msgstr "rshift(%lf, %lf): los valores fraccionarios serán truncados" + +#: builtin.c:2825 +#, c-format +msgid "rshift(%lf, %lf): too large shift value will give strange results" +msgstr "" +"rshift(%lf, %lf): un valor de desplazamiento muy grande dará resultados " +"extraños" + +#: builtin.c:2850 +msgid "and: received non-numeric first argument" +msgstr "and: el primer argumento recibido no es númerico" + +#: builtin.c:2852 +msgid "and: received non-numeric second argument" +msgstr "and: el segundo argumento recibido no es númerico" + +#: builtin.c:2858 +#, c-format +msgid "and(%lf, %lf): negative values will give strange results" +msgstr "and(%lf, %lf): los valores negativos darán resultados extraños" + +#: builtin.c:2860 +#, c-format +msgid "and(%lf, %lf): fractional values will be truncated" +msgstr "and(%lf, %lf): los valores fraccionarios serán truncados" + +#: builtin.c:2885 +msgid "or: received non-numeric first argument" +msgstr "or: el primer argumento recibido no es númerico" + +#: builtin.c:2887 +msgid "or: received non-numeric second argument" +msgstr "or: el segundo argumento recibido no es númerico" + +#: builtin.c:2893 +#, c-format +msgid "or(%lf, %lf): negative values will give strange results" +msgstr "or(%lf, %lf): los valores negativos darán resultados extraños" + +#: builtin.c:2895 +#, c-format +msgid "or(%lf, %lf): fractional values will be truncated" +msgstr "or(%lf, %lf): los valores fraccionarios serán truncados" + +#: builtin.c:2923 +msgid "xor: received non-numeric first argument" +msgstr "xor: el primer argumento recibido no es númerico" + +#: builtin.c:2925 +msgid "xor: received non-numeric second argument" +msgstr "xor: el segundo argumento recibido no es númerico" + +#: builtin.c:2931 +#, c-format +msgid "xor(%lf, %lf): negative values will give strange results" +msgstr "xor(%lf, %lf): los valores negativos darán resultados extraños" + +#: builtin.c:2933 +#, c-format +msgid "xor(%lf, %lf): fractional values will be truncated" +msgstr "xor(%lf, %lf): los valores fraccionarios se truncarán" + +#: builtin.c:2957 builtin.c:2963 +msgid "compl: received non-numeric argument" +msgstr "compl: se recibió un argumento que no es númerico" + +#: builtin.c:2965 +#, c-format +msgid "compl(%lf): negative value will give strange results" +msgstr "compl(%lf): el valor negativo dará resultados extraños" + +#: builtin.c:2967 +#, c-format +msgid "compl(%lf): fractional value will be truncated" +msgstr "compl(%lf): el valor fraccionario se truncará" + +#: builtin.c:3136 +#, c-format +msgid "dcgettext: `%s' is not a valid locale category" +msgstr "dcgettext: `%s' no es una categoría local válida" + +#: eval.c:412 +#, c-format +msgid "unknown nodetype %d" +msgstr "tipo de nodo %d desconocido" + +#: eval.c:423 eval.c:437 +#, c-format +msgid "unknown opcode %d" +msgstr "código de operación %d desconocido" + +#: eval.c:434 +#, c-format +msgid "opcode %s not an operator or keyword" +msgstr "el código de operación %s no es un operador o una palabra clave" + +#: eval.c:488 +msgid "buffer overflow in genflags2str" +msgstr "desbordamiento de almacenamiento temporal en genflags2str" + +#: eval.c:698 +#, c-format +msgid "" +"\n" +"\t# Function Call Stack:\n" +"\n" +msgstr "" +"\n" +"\t# Pila de Llamadas de Funciones:\n" +"\n" + +#: eval.c:725 +msgid "`IGNORECASE' is a gawk extension" +msgstr "`IGNORECASE' es una extensión de gawk" + +#: eval.c:754 +msgid "`BINMODE' is a gawk extension" +msgstr "`BINMODE' es una extensión de gawk" + +#: eval.c:812 +#, c-format +msgid "BINMODE value `%s' is invalid, treated as 3" +msgstr "el valor BINMODE `%s' es inválido; se trata como 3" + +#: eval.c:902 +#, c-format +msgid "bad `%sFMT' specification `%s'" +msgstr "especificación `%sFMT' `%s' errónea" + +#: eval.c:980 +msgid "turning off `--lint' due to assignment to `LINT'" +msgstr "se desactiva `--lint' debido a una asignación a `LINT'" + +#: eval.c:1127 eval.c:1777 +#, c-format +msgid "can't use function name `%s' as variable or array" +msgstr "no se puede usar el nombre de la función `%s' como variable o matriz" + +#: eval.c:1158 eval.c:1789 eval.c:1802 +#, c-format +msgid "reference to uninitialized argument `%s'" +msgstr "referencia al argumento sin inicializar `%s'" + +#: eval.c:1177 +msgid "attempt to field reference from non-numeric value" +msgstr "se intentó una referencia de campo desde un valor que no es númerico" + +#: eval.c:1179 +msgid "attempt to field reference from null string" +msgstr "se intentó una referencia de campo desde una cadena nula" + +#: eval.c:1185 +#, c-format +msgid "attempt to access field %ld" +msgstr "se intentó acceder al campo %ld" + +#: eval.c:1194 +#, c-format +msgid "reference to uninitialized field `$%ld'" +msgstr "referencia al campo sin inicializar `$%ld'" + +#: eval.c:1256 +#, c-format +msgid "function `%s' called with more arguments than declared" +msgstr "se llamó a la función `%s' con más argumentos de los declarados" + +#: eval.c:1437 +#, c-format +msgid "unwind_stack: unexpected type `%s'" +msgstr "unwind_stack: tipo `%s' inesperado" + +#: eval.c:1532 +msgid "division by zero attempted in `/='" +msgstr "se intentó una división por cero en `/='" + +#: eval.c:1539 +#, c-format +msgid "division by zero attempted in `%%='" +msgstr "se intentó una división por cero en `%%='" + +#: eval.c:1876 eval.c:2122 +#, c-format +msgid "attempt to use array `%s[\"%.*s\"]' in a scalar context" +msgstr "se intentó usar la matriz `%s[\"%.*s\"]' en un contexto escalar" + +#: eval.c:1907 +msgid "assignment used in conditional context" +msgstr "se usó una asignación en un contexto condicional" + +#: eval.c:1911 +msgid "statement has no effect" +msgstr "la declaración no tiene efecto" + +#: eval.c:2343 +#, c-format +msgid "for loop: array `%s' changed size from %ld to %ld during loop execution" +msgstr "" +"bucle for: la matriz `%s' cambió de tamaño de %ld a %ld durante la ejecución " +"del bucle" + +#: eval.c:2458 +#, c-format +msgid "function called indirectly through `%s' does not exist" +msgstr "no existe la función llamada indirectamente a través de `%s'" + +#: eval.c:2470 +#, c-format +msgid "function `%s' not defined" +msgstr "la función `%s' no está definida" + +#: eval.c:2511 +#, c-format +msgid "non-redirected `getline' invalid inside `%s' rule" +msgstr "`getline' no redirigido es inválido dentro de la regla `%s'" + +#: eval.c:2600 +#, c-format +msgid "error reading input file `%s': %s" +msgstr "error al leer el fichero de entrada `%s': %s" + +#: eval.c:2614 +#, c-format +msgid "`nextfile' cannot be called from a `%s' rule" +msgstr "`nextfile' no se puede llamar desde una regla `%s'" + +#: eval.c:2661 +msgid "`exit' cannot be called in the current context" +msgstr "`exit' no se puede llamar en el contexto actual" + +#: eval.c:2700 +#, c-format +msgid "`next' cannot be called from a `%s' rule" +msgstr "`next' no se puede llamar desde una regla `%s'" + +#: eval.c:2766 +#, c-format +msgid "Sorry, don't know how to interpret `%s'" +msgstr "Perdón, no se cómo interpretar `%s'" + +#: ext.c:54 +msgid "extensions are not allowed in sandbox mode" +msgstr "no se permiten las extensiones en modo sandbox" + +#: ext.c:60 ext.c:65 +msgid "`extension' is a gawk extension" +msgstr "`extension' es una extensión de gawk" + +#: ext.c:75 +#, c-format +msgid "fatal: extension: cannot open `%s' (%s)\n" +msgstr "fatal: extension: no se puede abrir `%s' (%s)\n" + +#: ext.c:84 +#, c-format +msgid "" +"fatal: extension: library `%s': does not define " +"`plugin_is_GPL_compatible' (%s)\n" +msgstr "" +"fatal: extension: la biblioteca `%s': no define " +"`plugin_is_GPL_compatible' (%s)\n" + +#: ext.c:93 +#, c-format +msgid "fatal: extension: library `%s': cannot call function `%s' (%s)\n" +msgstr "" +"fatal: extension: la biblioteca `%s': no puede llamar a la función `" +"%s' (%s)\n" + +#: ext.c:127 +msgid "extension: missing function name" +msgstr "extension: falta el nombre de la función" + +#: ext.c:132 +#, c-format +msgid "extension: illegal character `%c' in function name `%s'" +msgstr "extension: carácter ilegal `%c' en el nombre de la función `%s'" + +#: ext.c:141 +#, c-format +msgid "extension: can't redefine function `%s'" +msgstr "extension: no se puede redefinir la función `%s'" + +#: ext.c:145 +#, c-format +msgid "extension: function `%s' already defined" +msgstr "extension: la función `%s' ya está definida" + +#: ext.c:150 +#, c-format +msgid "extension: function name `%s' previously defined" +msgstr "extension: el nombre de función `%s' se definió previamente" + +#: ext.c:152 +#, c-format +msgid "extension: can't use gawk built-in `%s' as function name" +msgstr "" +"extension: no se puede utilizar la orden interna de gawk `%s' como nombre de " +"función" + +#: ext.c:156 +#, c-format +msgid "make_builtin: negative argument count for function `%s'" +msgstr "make_builtin: cuenta de argumento negativa para la función `%s'" + +#: ext.c:259 +#, c-format +msgid "function `%s' defined to take no more than %d argument(s)" +msgstr "la función `%s' se definió para tomar no más de %d argumento(s)" + +#: ext.c:262 +#, c-format +msgid "function `%s': missing argument #%d" +msgstr "función `%s': falta el argumento #%d" + +#: ext.c:279 +#, c-format +msgid "function `%s': argument #%d: attempt to use scalar as an array" +msgstr "" +"función `%s': argumento #%d: se intentó usar un escalar como una matriz" + +#: ext.c:283 +#, c-format +msgid "function `%s': argument #%d: attempt to use array as a scalar" +msgstr "" +"función `%s': argumento #%d: se intentó usar una matriz como un escalar" + +#: ext.c:296 +msgid "Operation Not Supported" +msgstr "No Se Admite La Operación" + +#: field.c:328 +msgid "NF set to negative value" +msgstr "se definió NF con un valor negativo" + +#: field.c:951 field.c:958 field.c:962 +msgid "split: fourth argument is a gawk extension" +msgstr "split: el cuarto argumento es una extensión de gawk" + +#: field.c:955 +msgid "split: fourth argument is not an array" +msgstr "split: el cuarto argumento no es una matriz" + +#: field.c:969 +msgid "split: second argument is not an array" +msgstr "split: el segundo argumento no es una matriz" + +#: field.c:973 +msgid "split: cannot use the same array for second and fourth args" +msgstr "" +"split: no se puede usar la misma matriz para el segundo y cuarto argumentos" + +#: field.c:978 +msgid "split: cannot use a subarray of second arg for fourth arg" +msgstr "" +"split: no se puede usar una submatriz del segundo argumento para el cuarto " +"argumento" + +#: field.c:981 +msgid "split: cannot use a subarray of fourth arg for second arg" +msgstr "" +"split: no se puede usar una submatriz del cuarto argumento para el segundo " +"argumento" + +#: field.c:1010 +msgid "split: null string for third arg is a gawk extension" +msgstr "" +"split: la cadena nula para el tercer argumento es una extensión de gawk" + +#: field.c:1050 +msgid "patsplit: fourth argument is not an array" +msgstr "patsplit: el cuarto argumento no es una matriz" + +#: field.c:1055 +msgid "patsplit: second argument is not an array" +msgstr "patsplit: el segundo argumento no es una matriz" + +#: field.c:1061 +msgid "patsplit: third argument must be non-null" +msgstr "patsplit: el tercer argumento no debe ser nulo" + +#: field.c:1065 +msgid "patsplit: cannot use the same array for second and fourth args" +msgstr "" +"patsplit: no se puede usar la misma matriz para el segundo y cuarto " +"argumentos" + +#: field.c:1070 +msgid "patsplit: cannot use a subarray of second arg for fourth arg" +msgstr "" +"patsplit: no se puede usar una submatriz del segundo argumento para el " +"cuarto argumento" + +#: field.c:1073 +msgid "patsplit: cannot use a subarray of fourth arg for second arg" +msgstr "" +"patsplit: no se puede usar una submatriz del cuarto argumento para el " +"segundo argumento" + +#: field.c:1110 +msgid "`FIELDWIDTHS' is a gawk extension" +msgstr "`FIELDWIDTHS' es una extensión gawk" + +#: field.c:1173 +#, c-format +msgid "invalid FIELDWIDTHS value, near `%s'" +msgstr "valor de FIELDWIDTHS inválido, cerca de `%s'" + +#: field.c:1246 +msgid "null string for `FS' is a gawk extension" +msgstr "la cadena nula para `FS' es una extensión de gawk" + +#: field.c:1250 +msgid "old awk does not support regexps as value of `FS'" +msgstr "el awk antiguo no admite expresiones regulares como valor de `FS'" + +#: field.c:1369 +msgid "`FPAT' is a gawk extension" +msgstr "`FPAT' es una extensión de gawk" + +#: getopt.c:604 getopt.c:633 +#, fuzzy, c-format +msgid "%s: option '%s' is ambiguous; possibilities:" +msgstr "%s: la opción '%s' es ambigua\n" + +#: getopt.c:679 getopt.c:683 +#, c-format +msgid "%s: option '--%s' doesn't allow an argument\n" +msgstr "%s: la opción '--%s' no admite ningún argumento\n" + +#: getopt.c:692 getopt.c:697 +#, c-format +msgid "%s: option '%c%s' doesn't allow an argument\n" +msgstr "%s: la opción '%c%s' no admite ningún argumento\n" + +#: getopt.c:740 getopt.c:759 +#, c-format +msgid "%s: option '--%s' requires an argument\n" +msgstr "%s: la opción '--%s' requiere un argumento\n" + +#: getopt.c:797 getopt.c:800 +#, c-format +msgid "%s: unrecognized option '--%s'\n" +msgstr "%s: no se reconoce la opción '--%s'\n" + +#: getopt.c:808 getopt.c:811 +#, c-format +msgid "%s: unrecognized option '%c%s'\n" +msgstr "%s: no se reconoce la opción '%c%s'\n" + +#: getopt.c:860 getopt.c:863 +#, c-format +msgid "%s: invalid option -- '%c'\n" +msgstr "%s: opción inválida -- '%c'\n" + +#: getopt.c:916 getopt.c:933 getopt.c:1143 getopt.c:1161 +#, c-format +msgid "%s: option requires an argument -- '%c'\n" +msgstr "%s: la opción requiere un argumento -- '%c'\n" + +#: getopt.c:989 getopt.c:1005 +#, c-format +msgid "%s: option '-W %s' is ambiguous\n" +msgstr "%s: la opción '-W %s' es ambigua\n" + +#: getopt.c:1029 getopt.c:1047 +#, c-format +msgid "%s: option '-W %s' doesn't allow an argument\n" +msgstr "%s: la opción '-W %s' no admite ningún argumento\n" + +#: getopt.c:1068 getopt.c:1086 +#, c-format +msgid "%s: option '-W %s' requires an argument\n" +msgstr "%s: la opción '-W %s' requiere un argumento\n" + +#: io.c:280 +#, c-format +msgid "command line argument `%s' is a directory: skipped" +msgstr "el argumento de la línea de órdenes `%s' es un directorio: se salta" + +#: io.c:283 io.c:385 +#, c-format +msgid "cannot open file `%s' for reading (%s)" +msgstr "no se puede abrir el fichero `%s' para lectura (%s)" + +#: io.c:501 +#, c-format +msgid "close of fd %d (`%s') failed (%s)" +msgstr "falló al cerrar el df %d (`%s') (%s)" + +#: io.c:578 +msgid "redirection not allowed in sandbox mode" +msgstr "no se permite la redirección en modo sandbox" + +#: io.c:612 +#, c-format +msgid "expression in `%s' redirection only has numeric value" +msgstr "la expresión en la redirección `%s' sólo tiene valor numérico" + +#: io.c:618 +#, c-format +msgid "expression for `%s' redirection has null string value" +msgstr "la expresión para la redirección `%s' tiene un valor de cadena nula" + +#: io.c:623 +#, c-format +msgid "filename `%s' for `%s' redirection may be result of logical expression" +msgstr "" +"el fichero `%s' para la redirección `%s' puede ser resultado de una " +"expresión lógica" + +#: io.c:666 +#, c-format +msgid "unnecessary mixing of `>' and `>>' for file `%.*s'" +msgstr "mezcla innecesaria de `>' y `>>' para el fichero `%.*s'" + +#: io.c:719 +#, c-format +msgid "can't open pipe `%s' for output (%s)" +msgstr "no se puede abrir la tubería `%s' para la salida (%s)" + +#: io.c:729 +#, c-format +msgid "can't open pipe `%s' for input (%s)" +msgstr "no se puede abrir la tubería `%s' para la entrada (%s)" + +#: io.c:752 +#, c-format +msgid "can't open two way pipe `%s' for input/output (%s)" +msgstr "no se puede abrir la tubería de dos vías `%s' para entrada/salida (%s)" + +#: io.c:834 +#, c-format +msgid "can't redirect from `%s' (%s)" +msgstr "no se puede redirigir desde `%s' (%s)" + +#: io.c:837 +#, c-format +msgid "can't redirect to `%s' (%s)" +msgstr "no se puede redirigir a `%s' (%s)" + +#: io.c:888 +msgid "" +"reached system limit for open files: starting to multiplex file descriptors" +msgstr "" +"se alcanzó el límite del sistema para ficheros abiertos: comenzando a " +"multiplexar los descriptores de fichero" + +#: io.c:904 +#, c-format +msgid "close of `%s' failed (%s)." +msgstr "falló al cerrar `%s' (%s)." + +#: io.c:912 +msgid "too many pipes or input files open" +msgstr "demasiadas tuberías o ficheros de entrada abiertos" + +#: io.c:934 +msgid "close: second argument must be `to' or `from'" +msgstr "close: el segundo argumento debe ser `to' o `from'" + +#: io.c:951 +#, c-format +msgid "close: `%.*s' is not an open file, pipe or co-process" +msgstr "close: `%.*s' no es un fichero abierto, tubería o co-proceso" + +#: io.c:956 +msgid "close of redirection that was never opened" +msgstr "se cerró una redirección que nunca se abrió" + +#: io.c:1053 +#, c-format +msgid "close: redirection `%s' not opened with `|&', second argument ignored" +msgstr "" +"close: la redirección `%s' no se abrió con `|&', se descarta el segundo " +"argumento" + +#: io.c:1069 +#, c-format +msgid "failure status (%d) on pipe close of `%s' (%s)" +msgstr "estado de fallo (%d) al cerrar la tubería de `%s' (%s)" + +#: io.c:1072 +#, c-format +msgid "failure status (%d) on file close of `%s' (%s)" +msgstr "estado de fallo (%d) al cerrar el fichero de `%s' (%s)" + +#: io.c:1092 +#, c-format +msgid "no explicit close of socket `%s' provided" +msgstr "no se provee el cerrado explícito del `socket' `%s'" + +#: io.c:1095 +#, c-format +msgid "no explicit close of co-process `%s' provided" +msgstr "no se provee el cerrado explícito del co-proceso `%s'" + +#: io.c:1098 +#, c-format +msgid "no explicit close of pipe `%s' provided" +msgstr "no se provee el cerrado explícito del la tubería `%s'" + +#: io.c:1101 +#, c-format +msgid "no explicit close of file `%s' provided" +msgstr "no se provee el cerrado explícito del fichero `%s'" + +#: io.c:1129 io.c:1184 main.c:794 main.c:831 +#, c-format +msgid "error writing standard output (%s)" +msgstr "error al escribir en la salida estándar (%s)" + +#: io.c:1133 io.c:1189 +#, c-format +msgid "error writing standard error (%s)" +msgstr "error al escribir en la salida estándar de error (%s)" + +#: io.c:1141 +#, c-format +msgid "pipe flush of `%s' failed (%s)." +msgstr "falló la limpieza de la tubería de `%s' (%s)." + +#: io.c:1144 +#, c-format +msgid "co-process flush of pipe to `%s' failed (%s)." +msgstr "falló la limpieza del co-proceso de la tubería a `%s' (%s)." + +#: io.c:1147 +#, c-format +msgid "file flush of `%s' failed (%s)." +msgstr "falló la limpieza del fichero de `%s' (%s)." + +#: io.c:1262 +#, c-format +msgid "local port %s invalid in `/inet'" +msgstr "puerto local %s inválido en `/inet'" + +#: io.c:1279 +#, c-format +msgid "remote host and port information (%s, %s) invalid" +msgstr "anfitrión remoto e información de puerto (%s, %s) inválidos" + +#: io.c:1431 +#, c-format +msgid "no (known) protocol supplied in special filename `%s'" +msgstr "" +"no se proporciona algún protocolo (conocido) en el nombre de fichero " +"especial `%s'" + +#: io.c:1445 +#, c-format +msgid "special file name `%s' is incomplete" +msgstr "el nombre de fichero especial `%s' está incompleto" + +#: io.c:1462 +msgid "must supply a remote hostname to `/inet'" +msgstr "se debe proporcionar a `/inet' un nombre de anfitrión remoto" + +#: io.c:1480 +msgid "must supply a remote port to `/inet'" +msgstr "se debe proporcionar a `/inet' un puerto remoto" + +#: io.c:1526 +msgid "TCP/IP communications are not supported" +msgstr "no se admiten las comunicaciones TCP/IP" + +#: io.c:1693 +#, c-format +msgid "could not open `%s', mode `%s'" +msgstr "no se puede abrir `%s', modo `%s'" + +#: io.c:1747 +#, c-format +msgid "close of master pty failed (%s)" +msgstr "falló al cerrar el pty maestro (%s)" + +#: io.c:1749 io.c:1917 io.c:2074 +#, c-format +msgid "close of stdout in child failed (%s)" +msgstr "falló al cerrar la salida estándar en el hijo (%s)" + +#: io.c:1752 +#, c-format +msgid "moving slave pty to stdout in child failed (dup: %s)" +msgstr "" +"falló el movimiento del pty esclavo a la salida estándar en el hijo (dup: %s)" + +#: io.c:1754 io.c:1922 +#, c-format +msgid "close of stdin in child failed (%s)" +msgstr "falló al cerrar la entrada estándar en el hijo (%s)" + +#: io.c:1757 +#, c-format +msgid "moving slave pty to stdin in child failed (dup: %s)" +msgstr "" +"falló el movimiento del pty esclavo a la entrada estándar en el hijo (dup: " +"%s)" + +#: io.c:1759 io.c:1780 +#, c-format +msgid "close of slave pty failed (%s)" +msgstr "falló al cerrar el pty esclavo (%s)" + +#: io.c:1858 io.c:1920 io.c:2052 io.c:2077 +#, c-format +msgid "moving pipe to stdout in child failed (dup: %s)" +msgstr "falló el movimiento a la salida estándar en el hijo (dup: %s)" + +#: io.c:1865 io.c:1925 +#, c-format +msgid "moving pipe to stdin in child failed (dup: %s)" +msgstr "" +"falló el movimiento de la tubería a la entrada estándar en el hijo (dup: %s)" + +#: io.c:1885 io.c:2067 +msgid "restoring stdout in parent process failed\n" +msgstr "falló la restauración de la salida estándar en el proceso padre\n" + +#: io.c:1893 +msgid "restoring stdin in parent process failed\n" +msgstr "falló la restauración de la entrada estándar en el proceso padre\n" + +#: io.c:1928 io.c:2079 io.c:2093 +#, c-format +msgid "close of pipe failed (%s)" +msgstr "falló al cerrar la tubería (%s)" + +#: io.c:1973 +msgid "`|&' not supported" +msgstr "no se admite `|&'" + +#: io.c:2039 +#, c-format +msgid "cannot open pipe `%s' (%s)" +msgstr "no se puede abrir la tubería `%s' (%s)" + +#: io.c:2087 +#, c-format +msgid "cannot create child process for `%s' (fork: %s)" +msgstr "no se puede crear el proceso hijo para `%s' (fork: %s)" + +#: io.c:2520 +#, c-format +msgid "data file `%s' is empty" +msgstr "el fichero de datos `%s' está vacío" + +#: io.c:2561 io.c:2569 +msgid "could not allocate more input memory" +msgstr "no se puede reservar más memoria de entrada" + +#: io.c:3127 +msgid "multicharacter value of `RS' is a gawk extension" +msgstr "el valor multicaracter de `RS' es una extensión de gawk" + +#: io.c:3232 +msgid "IPv6 communication is not supported" +msgstr "no se admite la comunicación IPv6" + +#: main.c:366 +msgid "`-m[fr]' option irrelevant in gawk" +msgstr "la opción -m[fr] es irrelevante en gawk" + +#: main.c:368 +msgid "-m option usage: `-m[fr] nnn'" +msgstr "uso de la opción -m: `-m[fr]' nnn" + +#: main.c:391 +msgid "empty argument to `-e/--source' ignored" +msgstr "se descarta el argumento vacío para `-e/--source'" + +#: main.c:462 +#, c-format +msgid "%s: option `-W %s' unrecognized, ignored\n" +msgstr "%s: no se reconoce la opción `-W %s', se descarta\n" + +#: main.c:515 +#, c-format +msgid "%s: option requires an argument -- %c\n" +msgstr "%s: la opción requiere un argumento -- %c\n" + +#: main.c:536 +msgid "environment variable `POSIXLY_CORRECT' set: turning on `--posix'" +msgstr "" +"la variable de ambiente `POSIXLY_CORRECT' está definida: se activa `--posix'" + +#: main.c:542 +msgid "`--posix' overrides `--traditional'" +msgstr "`--posix' se impone a `--traditional'" + +#: main.c:553 +msgid "`--posix'/`--traditional' overrides `--non-decimal-data'" +msgstr "`--posix'/`--traditional' se imponen a `--non-decimal-data'" + +#: main.c:557 +#, c-format +msgid "running %s setuid root may be a security problem" +msgstr "ejecutar %s como setuid root puede ser un problema de seguridad" + +#: main.c:562 +msgid "`--posix' overrides `--binary'" +msgstr "`--posix' se impone a `--binary'" + +#: main.c:613 +#, c-format +msgid "can't set binary mode on stdin (%s)" +msgstr "no se puede establecer el modo binario en la entrada estándar (%s)" + +#: main.c:616 +#, c-format +msgid "can't set binary mode on stdout (%s)" +msgstr "no se puede establecer el modo binario en la salida estándar (%s)" + +#: main.c:618 +#, c-format +msgid "can't set binary mode on stderr (%s)" +msgstr "" +"no se puede establecer el modo binario en la salida estándar de error (%s)" + +#: main.c:657 +msgid "no program text at all!" +msgstr "¡No hay ningún programa de texto!" + +#: main.c:734 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] -f progfile [--] file ...\n" +msgstr "" +"Modo de empleo: %s [opciones estilo POSIX o GNU] -f fichprog [--] " +"fichero ...\n" + +#: main.c:736 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] [--] %cprogram%c file ...\n" +msgstr "" +"Modo de empleo: %s [opciones estilo POSIX o GNU] [--] %cprograma%c " +"fichero ...\n" + +#: main.c:741 +msgid "POSIX options:\t\tGNU long options: (standard)\n" +msgstr "Opciones POSIX:\t\tOpciones largas GNU: (estándar)\n" + +#: main.c:742 +msgid "\t-f progfile\t\t--file=progfile\n" +msgstr "\t-f fichprog\t\t--file=fichprog\n" + +#: main.c:743 +msgid "\t-F fs\t\t\t--field-separator=fs\n" +msgstr "\t-F sc\t\t\t--field-separator=sc\n" + +#: main.c:744 +msgid "\t-v var=val\t\t--assign=var=val\n" +msgstr "\t-v var=valor\t\t--assign=var=valor\n" + +#: main.c:745 +msgid "Short options:\t\tGNU long options: (extensions)\n" +msgstr "Opciones cortas:\t\tOpciones largas GNU: (extensiones)\n" + +#: main.c:746 +msgid "\t-b\t\t\t--characters-as-bytes\n" +msgstr "\t-b\t\t\t--characters-as-bytes\n" + +#: main.c:747 +msgid "\t-c\t\t\t--traditional\n" +msgstr "\t-c\t\t\t--traditional\n" + +#: main.c:748 +msgid "\t-C\t\t\t--copyright\n" +msgstr "\t-C\t\t\t--copyright\n" + +#: main.c:749 +msgid "\t-d[file]\t\t--dump-variables[=file]\n" +msgstr "\t-d[fichero]\t\t--dump-variables[=fichero]\n" + +# Esta es la línea más larga de la lista de argumentos. +# Probar con gawk para revisar tabuladores. cfuga +#: main.c:750 +msgid "\t-e 'program-text'\t--source='program-text'\n" +msgstr "\t-e 'texto-prog'\t--source='texto-prog'\n" + +#: main.c:751 +msgid "\t-E file\t\t\t--exec=file\n" +msgstr "\t-E fichero\t\t--exec=fichero\n" + +#: main.c:752 +msgid "\t-g\t\t\t--gen-pot\n" +msgstr "\t-g\t\t\t--gen-pot\n" + +#: main.c:753 +msgid "\t-h\t\t\t--help\n" +msgstr "\t-h\t\t\t--help\n" + +#: main.c:754 +msgid "\t-L [fatal]\t\t--lint[=fatal]\n" +msgstr "\t-L [fatal]\t\t--lint[=fatal]\n" + +#: main.c:755 +msgid "\t-n\t\t\t--non-decimal-data\n" +msgstr "\t-n\t\t\t--non-decimal-data\n" + +#: main.c:756 +msgid "\t-N\t\t\t--use-lc-numeric\n" +msgstr "\t-N\t\t\t--use-lc-numeric\n" + +#: main.c:757 +msgid "\t-O\t\t\t--optimize\n" +msgstr "\t-O\t\t\t--optimize\n" + +#: main.c:758 +msgid "\t-p[file]\t\t--profile[=file]\n" +msgstr "\t-p[fichero]\t\t--profile[=fichero]\n" + +#: main.c:759 +msgid "\t-P\t\t\t--posix\n" +msgstr "\t-P\t\t\t--posix\n" + +#: main.c:760 +msgid "\t-r\t\t\t--re-interval\n" +msgstr "\t-r\t\t\t--re-interval\n" + +#: main.c:762 +msgid "\t-R file\t\t\t--command=file\n" +msgstr "\t-R fichero\t\t\t--command=fichero\n" + +#: main.c:763 +msgid "\t-S\t\t\t--sandbox\n" +msgstr "\t-S\t\t\t--sandbox\n" + +#: main.c:764 +msgid "\t-t\t\t\t--lint-old\n" +msgstr "\t-t\t\t\t--lint-old\n" + +#: main.c:765 +msgid "\t-V\t\t\t--version\n" +msgstr "\t-V\t\t\t--version\n" + +#: main.c:767 +msgid "\t-W nostalgia\t\t--nostalgia\n" +msgstr "\t-W nostalgia\t\t--nostalgia\n" + +#: main.c:770 +msgid "\t-Y\t\t--parsedebug\n" +msgstr "\t-Y\t\t--parsedebug\n" + +#. TRANSLATORS: --help output 5 (end) +#. TRANSLATORS: the placeholder indicates the bug-reporting address +#. for this application. Please add _another line_ with the +#. address for translation bugs. +#. no-wrap +#: main.c:779 +msgid "" +"\n" +"To report bugs, see node `Bugs' in `gawk.info', which is\n" +"section `Reporting Problems and Bugs' in the printed version.\n" +"\n" +msgstr "" +"\n" +"Para reportar bichos, consulte el nodo `Bugs' en `gawk.info', el cual\n" +"corresponde a la sección `Reporting Problems and Bugs' en la versión " +"impresa.\n" +"Reporte los errores de los mensajes en español a .\n" +"\n" + +#: main.c:783 +msgid "" +"gawk is a pattern scanning and processing language.\n" +"By default it reads standard input and writes standard output.\n" +"\n" +msgstr "" +"gawk es un lenguaje de reconocimiento y procesamiento de patrones.\n" +"Por defecto lee la entrada estándar y escribe en la salida estándar.\n" +"\n" + +#: main.c:787 +msgid "" +"Examples:\n" +"\tgawk '{ sum += $1 }; END { print sum }' file\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" +msgstr "" +"Ejemplos:\n" +"\tgawk '{ sum += $1 }; END { print sum }' fichero\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" + +#: main.c:807 +#, c-format +msgid "" +"Copyright (C) 1989, 1991-%d Free Software Foundation.\n" +"\n" +"This program is free software; you can redistribute it and/or modify\n" +"it under the terms of the GNU General Public License as published by\n" +"the Free Software Foundation; either version 3 of the License, or\n" +"(at your option) any later version.\n" +"\n" +msgstr "" +"Copyright (C) 1989, 1991-%d Free Software Foundation.\n" +"\n" +"Este programa es software libre; se puede redistribuir y/o modificar\n" +"bajo los términos de la Licencia Pública General de GNU tal como es " +"publicada\n" +"por la Free Software Foundation; ya sea por la versión 3 de la Licencia, o\n" +"(a su elección) cualquier versión posterior.\n" +"\n" + +#: main.c:815 +msgid "" +"This program is distributed in the hope that it will be useful,\n" +"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +"GNU General Public License for more details.\n" +"\n" +msgstr "" +"Este programa se distribuye con la esperanza que será útil,\n" +"pero SIN NINGUNA GARANTÍA; aún sin la garantía implícita de\n" +"COMERCIABILIDAD o IDONEIDAD PARA UN FIN DETERMINADO. Vea la\n" +"Licencia Pública General de GNU para más detalles.\n" +"\n" + +#: main.c:821 +msgid "" +"You should have received a copy of the GNU General Public License\n" +"along with this program. If not, see http://www.gnu.org/licenses/.\n" +msgstr "" +"Debió recibir una copia de la Licencia Pública General de GNU\n" +"junto con este programa. Si no es así, consulte\n" +"http://www.gnu.org/licenses/.\n" + +#: main.c:856 +msgid "-Ft does not set FS to tab in POSIX awk" +msgstr "-Ft no establece FS a tabulador en el awk de POSIX" + +#: main.c:1090 +#, c-format +msgid "unknown value for field spec: %d\n" +msgstr "valor desconocido para la especificación de campo: %d\n" + +#: main.c:1171 +#, c-format +msgid "" +"%s: `%s' argument to `-v' not in `var=value' form\n" +"\n" +msgstr "" +"%s: el argumento `%s' para `-v' no es de la forma `var=valor'\n" +"\n" + +#: main.c:1197 +#, c-format +msgid "`%s' is not a legal variable name" +msgstr "`%s' no es un nombre de variable legal" + +#: main.c:1200 +#, c-format +msgid "`%s' is not a variable name, looking for file `%s=%s'" +msgstr "`%s' no es un nombre de variable, se busca el fichero `%s=%s'" + +#: main.c:1204 +#, c-format +msgid "cannot use gawk builtin `%s' as variable name" +msgstr "" +"no se puede utilizar la orden interna de gawk `%s' como nombre de variable" + +#: main.c:1209 +#, c-format +msgid "cannot use function `%s' as variable name" +msgstr "no se puede usar la función `%s' como nombre de variable" + +#: main.c:1262 +msgid "floating point exception" +msgstr "excepción de coma flotante" + +#: main.c:1269 +msgid "fatal error: internal error" +msgstr "error fatal: error interno" + +#: main.c:1284 +msgid "fatal error: internal error: segfault" +msgstr "error fatal: error interno: falla de segmentación" + +#: main.c:1296 +msgid "fatal error: internal error: stack overflow" +msgstr "error fatal: error interno: desbordamiento de pila" + +#: main.c:1346 +#, c-format +msgid "no pre-opened fd %d" +msgstr "no existe el df %d abierto previamente" + +#: main.c:1353 +#, c-format +msgid "could not pre-open /dev/null for fd %d" +msgstr "no se puede abrir previamente /dev/null para el df %d" + +#: msg.c:63 +#, c-format +msgid "cmd. line:" +msgstr "línea ord.:" + +#: msg.c:107 +msgid "error: " +msgstr "error: " + +#: node.c:406 +msgid "backslash at end of string" +msgstr "barra invertida al final de la cadena" + +#: node.c:517 +#, c-format +msgid "old awk does not support the `\\%c' escape sequence" +msgstr "el awk antiguo no admite la secuencia de escape `\\%c'" + +#: node.c:568 +msgid "POSIX does not allow `\\x' escapes" +msgstr "POSIX no permite escapes `\\x'" + +#: node.c:574 +msgid "no hex digits in `\\x' escape sequence" +msgstr "no hay dígitos hexadecimales en la secuencia de escape `\\x'" + +#: node.c:596 +#, c-format +msgid "" +"hex escape \\x%.*s of %d characters probably not interpreted the way you " +"expect" +msgstr "" +"el escape hexadecimal \\x%.*s de %d caracteres tal vez no se interprete de " +"la forma esperada" + +#: node.c:611 +#, c-format +msgid "escape sequence `\\%c' treated as plain `%c'" +msgstr "la secuencia de escape `\\%c' se trata como una simple `%c'" + +#: node.c:750 +msgid "" +"Invalid multibyte data detected. There may be a mismatch between your data " +"and your locale." +msgstr "" +"Se detectaron datos multibyte inválidos. Puede ser que no coincidan sus " +"datos con su local." + +#: posix/gawkmisc.c:176 +#, c-format +msgid "%s %s `%s': could not get fd flags: (fcntl F_GETFD: %s)" +msgstr "" +"%s %s `%s': no se pueden obtener las opciones del fd: (fcntl F_GETFD: %s)" + +#: posix/gawkmisc.c:188 +#, c-format +msgid "%s %s `%s': could not set close-on-exec: (fcntl F_SETFD: %s)" +msgstr "%s %s `%s': no se puede establecer close-on-exec: (fcntl F_SETFD: %s)" + +#: profile.c:83 +#, c-format +msgid "could not open `%s' for writing: %s" +msgstr "no se puede abrir `%s' para escritura: %s" + +#: profile.c:85 +msgid "sending profile to standard error" +msgstr "se envía el perfil a la salida estándar de error" + +#: profile.c:203 +#, c-format +msgid "" +"\t# %s block(s)\n" +"\n" +msgstr "" +"\t# bloque(s) %s\n" +"\n" + +#: profile.c:208 +#, c-format +msgid "" +"\t# Rule(s)\n" +"\n" +msgstr "" +"\t# Regla(s)\n" +"\n" + +#: profile.c:279 +#, c-format +msgid "internal error: %s with null vname" +msgstr "error interno: %s con vname nulo" + +#: profile.c:952 +#, c-format +msgid "\t# gawk profile, created %s\n" +msgstr "\t# perfil de gawk, creado %s\n" + +#: profile.c:1331 +#, c-format +msgid "" +"\n" +"\t# Functions, listed alphabetically\n" +msgstr "" +"\n" +"\t# Funciones, enumeradas alfabéticamente\n" + +#: profile.c:1370 +#, c-format +msgid "redir2str: unknown redirection type %d" +msgstr "redir2str: tipo de redirección %d desconocida" + +#: re.c:573 +#, c-format +msgid "range of the form `[%c-%c]' is locale dependent" +msgstr "el rango de la forma `[%c-%c]' depende del local" + +#: re.c:600 +#, c-format +msgid "regexp component `%.*s' should probably be `[%.*s]'" +msgstr "" +"el componente de expresión regular `%.*s' probablemente debe ser `[%.*s]'" + +#: regcomp.c:131 +msgid "Success" +msgstr "Éxito" + +#: regcomp.c:134 +msgid "No match" +msgstr "No hay coincidencia" + +#: regcomp.c:137 +msgid "Invalid regular expression" +msgstr "Expresión regular inválida" + +#: regcomp.c:140 +msgid "Invalid collation character" +msgstr "Caracter de ordenación inválido" + +#: regcomp.c:143 +msgid "Invalid character class name" +msgstr "Nombre de clase de caracter inválido" + +#: regcomp.c:146 +msgid "Trailing backslash" +msgstr "Barra invertida extra al final" + +#: regcomp.c:149 +msgid "Invalid back reference" +msgstr "Referencia hacia atrás inválida" + +#: regcomp.c:152 +msgid "Unmatched [ or [^" +msgstr "[ o [^ desemparejados" + +#: regcomp.c:155 +msgid "Unmatched ( or \\(" +msgstr "( o \\( desemparejados" + +#: regcomp.c:158 +msgid "Unmatched \\{" +msgstr "\\{ desemparejado" + +#: regcomp.c:161 +msgid "Invalid content of \\{\\}" +msgstr "Contenido inválido de \\{\\}" + +#: regcomp.c:164 +msgid "Invalid range end" +msgstr "Final de rango inválido" + +#: regcomp.c:167 +msgid "Memory exhausted" +msgstr "Memoria agotada" + +#: regcomp.c:170 +msgid "Invalid preceding regular expression" +msgstr "Expresión regular precedente inválida" + +#: regcomp.c:173 +msgid "Premature end of regular expression" +msgstr "Fin prematuro de la expresión regular" + +#: regcomp.c:176 +msgid "Regular expression too big" +msgstr "La expresión regular es demasiado grande" + +#: regcomp.c:179 +msgid "Unmatched ) or \\)" +msgstr ") o \\) desemparejados" + +#: regcomp.c:700 +msgid "No previous regular expression" +msgstr "No hay una expresión regular previa" + +#~ msgid "could not find groups: %s" +#~ msgstr "no se pueden encontrar los grupos: %s" + +#~ msgid "assignment is not allowed to result of builtin function" +#~ msgstr "no se permite la asignación como resultado de una función interna" + +#~ msgid "attempt to use array in a scalar context" +#~ msgstr "se intentó usar una matriz en un contexto escalar" + +#~ msgid "statement may have no effect" +#~ msgstr "la sentencia puede no tener efecto" + +#~ msgid "out of memory" +#~ msgstr "memoria agotada" + +#~ msgid "attempt to use scalar `%s' as array" +#~ msgstr "se intentó usar el dato escalar `%s' como una matriz" + +#~ msgid "attempt to use array `%s' in scalar context" +#~ msgstr "se intentó usar la matriz `%s' en un contexto escalar" + +#~ msgid "call of `length' without parentheses is deprecated by POSIX" +#~ msgstr "la llamada de `length' sin paréntesis está obsoleta por POSIX" + +#~ msgid "division by zero attempted in `/'" +#~ msgstr "se intentó una división por cero en `/'" + +#~ msgid "length: untyped parameter argument will be forced to scalar" +#~ msgstr "length: un argumento de parámetro sin tipo se forzará a escalar" + +#~ msgid "length: untyped argument will be forced to scalar" +#~ msgstr "length: un argumento sin tipo se forzará a escalar" + +#~ msgid "`break' outside a loop is not portable" +#~ msgstr "`break' fuera de un ciclo no es transportable" + +#~ msgid "`continue' outside a loop is not portable" +#~ msgstr "`continue' fuera de un ciclo no es transportable" + +#~ msgid "`next' cannot be called from a BEGIN rule" +#~ msgstr "`next' no se puede llamar desde una regla BEGIN" + +#~ msgid "`nextfile' cannot be called from a BEGIN rule" +#~ msgstr "`nextfile' no se puede llamar desde una regla BEGIN" + +#~ msgid "" +#~ "concatenation: side effects in one expression have changed the length of " +#~ "another!" +#~ msgstr "" +#~ "concatenación: ¡Los efectos laterales en una expresión han cambiado la " +#~ "longitud de otra!" + +#~ msgid "illegal type (%s) in tree_eval" +#~ msgstr "tipo ilegal (%s) en tree_eval" + +#~ msgid "\t# -- main --\n" +#~ msgstr "\t# -- principal --\n" + +#~ msgid "invalid tree type %s in redirect()" +#~ msgstr "tipo de árbol %s inválido en redirect()" + +#~ msgid "/inet/raw client not ready yet, sorry" +#~ msgstr "el cliente /inet/raw no está listo aún, perdón" + +#~ msgid "only root may use `/inet/raw'." +#~ msgstr "sólo root puede utilizar `/inet/raw'." + +#~ msgid "/inet/raw server not ready yet, sorry" +#~ msgstr "el servidor /inet/raw no está listo aún, perdón" + +#~ msgid "file `%s' is a directory" +#~ msgstr "el fichero `%s' es un directorio" + +#~ msgid "use `PROCINFO[\"%s\"]' instead of `%s'" +#~ msgstr "use `PROCINFO[\"%s\"]' en lugar de `%s'" + +#~ msgid "use `PROCINFO[...]' instead of `/dev/user'" +#~ msgstr "use `PROCINFO[...]' en lugar de `/dev/user'" + +#~ msgid "\t-m[fr] val\n" +#~ msgstr "\t-m[fr] valor\n" + +#~ msgid "\t-W compat\t\t--compat\n" +#~ msgstr "\t-W compat\t\t--compat\n" + +#~ msgid "\t-W copyleft\t\t--copyleft\n" +#~ msgstr "\t-W copyleft\t\t--copyleft\n" + +#~ msgid "\t-W usage\t\t--usage\n" +#~ msgstr "\t-W usage\t\t--usage\n" + +#~ msgid "can't convert string to float" +#~ msgstr "no se puede convertir una cadena a coma flotante" + +#~ msgid "# treated internally as `delete'" +#~ msgstr "# se trata internamente como `delete'" + +#~ msgid "# this is a dynamically loaded extension function" +#~ msgstr "# esta es una función de extensión cargada dinámicamente" + +#~ msgid "" +#~ "\t# BEGIN block(s)\n" +#~ "\n" +#~ msgstr "" +#~ "\t# bloque(s) BEGIN\n" +#~ "\n" + +#~ msgid "unexpected type %s in prec_level" +#~ msgstr "tipo %s inesperado en prec_level" + +#~ msgid "Unknown node type %s in pp_var" +#~ msgstr "Tipo de nodo %s desconocido en pp_var" + +#~ msgid "can't open two way socket `%s' for input/output (%s)" +#~ msgstr "" +#~ "no se puede abrir el `socket' de dos vías `%s' para entrada/salida (%s)" + +#~ msgid "%s: illegal option -- %c\n" +#~ msgstr "%s: opción ilegal -- %c\n" + +#~ msgid "function %s called\n" +#~ msgstr "se llamó a la función %s\n" + +#~ msgid "field %d in FIELDWIDTHS, must be > 0" +#~ msgstr "el campo %d en FIELDWIDTHS, debe ser > 0" + +#~ msgid "or used as a variable or an array" +#~ msgstr "o se usó como una variable o una matriz" + +#~ msgid "substr: length %g is < 0" +#~ msgstr "substr: la longitud %g es < 0" + +#~ msgid "regex match failed, not enough memory to match string \"%.*s%s\"" +#~ msgstr "" +#~ "falló la coincidencia de la expresión regular, no hay suficiente memoria " +#~ "para que coincida la cadena \"%.*s%s\"" + +#~ msgid "delete: illegal use of variable `%s' as array" +#~ msgstr "delete: uso ilegal de la variable `%s' como una matriz" + +#~ msgid "internal error: Node_var_array with null vname" +#~ msgstr "error interno: Node_var_array con vname nulo" + +#~ msgid "invalid syntax in name `%s' for variable assignment" +#~ msgstr "sintaxis inválida en el nombre `%s' para la asignación de variable" + +#~ msgid "or used in other expression context" +#~ msgstr "se usó or en otro contexto de la expresión" + +#~ msgid "`%s' is a function, assignment is not allowed" +#~ msgstr "`%s' es una función, no se permite asignación" + +#~ msgid "BEGIN blocks must have an action part" +#~ msgstr "Los bloques BEGIN deben tener una parte de acción" + +#~ msgid "`nextfile' used in BEGIN or END action" +#~ msgstr "`nextfile' es usado en la acción de BEGIN o END" + +#~ msgid "non-redirected `getline' undefined inside BEGIN or END action" +#~ msgstr "" +#~ "`getline' no redirigido indefinido dentro de la acción de BEGIN o END" + +# tokentab? cfuga +#~ msgid "fptr %x not in tokentab\n" +#~ msgstr "fptr %x no está en tokentab\n" + +#~ msgid "gsub third parameter is not a changeable object" +#~ msgstr "el tercer argumento de gsub no es un objecto que se puede cambiar" + +#~ msgid "Unbalanced [" +#~ msgstr "[ desbalanceado" + +#~ msgid "Unfinished \\ escape" +#~ msgstr "Escape \\ sin terminar" + +#~ msgid "unfinished repeat count" +#~ msgstr "cuenta de repetición sin terminar" + +#~ msgid "malformed repeat count" +#~ msgstr "cuenta de repetición malformada" + +#~ msgid "Unbalanced (" +#~ msgstr "( desbalanceado" + +#~ msgid "No regexp syntax bits specified" +#~ msgstr "No se especifican los bits de sintaxis de la expresión regular" + +#~ msgid "Unbalanced )" +#~ msgstr ") desbalanceado" + +#~ msgid "internal error: file `%s', line %d\n" +#~ msgstr "error interno: fichero `%s', línea %d\n" + +#~ msgid "" +#~ "\n" +#~ "To report bugs, see node `Bugs' in `gawk.info', which is\n" +#~ msgstr "" +#~ "\n" +#~ "Para reportar `bugs', vea el nodo `Bugs' en gawk.info, que es\n" + +#~ msgid "pipe from `%s': could not set close-on-exec (fcntl: %s)" +#~ msgstr "tubería de `%s': no se puede establecer close-on-exec (fcntl: %s)" + +#~ msgid "pipe to `%s': could not set close-on-exec (fcntl: %s)" +#~ msgstr "tubería a `%s': no se puede establecer close-on-exec (fcntl: %s)" diff --git a/po/fi.gmo b/po/fi.gmo new file mode 100644 index 0000000000000000000000000000000000000000..75bc4bfb81d57e5c8442db4d76599b73a1dcd88e GIT binary patch literal 51928 zcmd7537lnBb?<-FM4%#yfFdArXeg>1`c`!}G8Hs-({w{a)7|y}VmDB?s!mniu3Pt( zcc|`SQjCgmo-pEw*k~N%1Zqs2I{MVaA^MW1FL_1->htL{i7#qQjQ+pBwf8>f+^Gig zKA-=)pFaIN!`k!OYpuQZP~SQJckYh({mG-E=&9gOj*X&cK01p2^i;j&*B?d40gnP7 z2ObZK?sV{Y@KW$3a0mD_aMFK&k$?XV@QJ+tB=~snE8r>M-+_wvmmZHkJBpO#$)Msr zA5=P5fhU3qcqVuYcrN%>Q0aXcR6IWd$$Io};K|_811|guP~o2eDj$15g_{7Cj~9Yu zA-Wfw2fqL+{tYXm=t8gzUJ4!tSAgFG3*hgpilQfj>%d`fD|jCG0#NCF9DEY^6;SCu z!LdMueEif9O=sL>6e-aijiKHd$g zJP(7XgMCCUJO@;KSA&ZG5O^ARFQ|I{6iAThZ^4!D!ch?4$n%;(SMRR?Ro)MSqW==8 za{K^P`#*XpiuQr0fMo7(fNK9&gDS@Z{`nzL@gKF8IssRJD&H>fDDW2l{Cx1oJiiANf4zR4%ip^_e$wMt zz{m0Z@4=1WPdpCNxG&^+7Q6`j1$aI<^mJD*38?zK4HO@|5mY(93M&6U1XZ3s0x8^T z{)@p;Q04!9Q02Q1RQz8674Em7;$3lp3%>zWc}Kw*yd8u!qPK!7|Cd1V!>>SvUjY+S zMbT!Eri$i3@x%R~_~-MW=zapKJ)c10itk*H*MZ8{ouJ~qAAAbgfBR^10#}j(!WM`kMw-A8!Cp z2mb;*4g4{v{2sHx(f5N2f3<(EfGWppLACqmLFM!3;3?o!H@f<~5LCH}px(a{JOg|W zsPz64JQ@56sQP;B<*poSL8Z47RQVbptQg$`ZU(;wivCHPT>KlrKAtQ7c^*``-UX`O z{yV7pIOYl$-(}zmp2z(2i#)y;Jd^id2cHK13#f9PK%yss!=U2Z1)c@o394N01Qp+B zL4|+VKOeotwg0)G+Vgr)_4PbZa^i!a>ib)u!v6x?0G@oMtEXpsybaX%w}MB3p9RHN zUjk$B=b*kn`6^dW7kjLN1H8W<6kmS@TnRpQtK*{~kggYvfHC+6Q1$u=Q008s;|W(g zez+X$=lxBf(tiPX6!<~#9Ps0y%J&c`K0VderPEhgu7*u|qxD6c%4uduaFWef%?BI#+^f|5t$OcOM4D zxBmz#{{CIA-21@>&(8-{{$GM*EsA%${8hnKJbw&Sy?zf|4L)vd44&F$cm1Dbj9em;JM(&>s-1sp!npCpz`$% zQ0@0?Q1!5aN>e_H;2`)SQ1$l!cpmtD@af>m&vN{*9TZ;$2&o#|87v}e-k_b{1tc-cPC!osnGf?TBa-$2s$>Z}t)zhDW3jb@5 zXW!(WcYzkluVx1h?sYSg{o2Z}#m2&&ya2wnpI z0Ne5E zh5w)a{mEtbz5uGdcY+(h=Ywk3BcR&lcW2P4;OU^^T?MLt?FUzacY~|IPl4}#6!C+{ z@%);qtM7M!r}F#}@ObcR{`nt3mHRi~Q^C__z5WGNo?W2$e;hm=tb@maul0BsRJ;#> ziubQT#q%(z{`9ElIKF(c$IHRhysv;y0N(^23%(arIX?l4PreB%{J(-v1dpw`b~zms z-)sigf;WP1178V>PloEQ|4)OPczzG4cKRtOd3k)p)z?PwQl1Zh+rf8%YM)<#F?e#* zm1h_{f#+*M@m~>CeqIa~z&CpQB6tqZzW|la8FQ|kcY^2gd?$E5_>59=Yx47?B@FbpJ0-grm z2dce3CboiXbilR=Qn{jfZqbwf$M(X^_K)xy}S@qdEO1K0KWi=?nmGi;8S1V z9eP15kYUIZ*NalgBe(-@%Uyo=f~WEP8gKyoAgKI(3sgQH^$JIKE_fBsQ(yu7kjK9V z72mP1#1{l^1*N5S8K%5U*?POiKR zd>qgJ1-u6Qub}uYzT5HXvp}`)t>9Yl!{8A3FxU^C_Z&3P~pD>DnI`U9u4-t)ul5Cir=Qei@=Y1{NEnW zep?jX%=??cE#RlY3&6+Ti*5qfgZsdj`sW{ldwD+p?T-GX;Ci0F0p0)}cc1Hz2SC05 zEU0$)EvR}}`wnC|SO=d7eic;u-vy5aHyn2HZU;B=Z8SO zKl+^x_kx%6d>^z&|c@L^DVbIu>(djW3(hrzFd6X5T?+tou2 zyo~41fU3vef~xO}-s9Ri0ng_7Zcyd@Q*agdQ}A@~Derai;381{st8^Jz78~g0gYck zg&TaIYrkiK&*1rPkADqb%=44p@AAI`JV)QbmEdPU)!UCirBnET%m0YS4}j0&{jWXl z{bQHj2SDZfTi}IY-v?dz%fW3tH^EE6&w)z+x1jjs;t#p{n)Ucza1HN&0Gp|7u?ce}-*uVcva2?N&`>1QbXMn1w7l4D{NB#3dU_Z|% zJmA{rVo>#41J4IP0A2?^3|p_+KOaA@8fNJmfPh7iP4esLk9UgxH zichzG(%F-*1XZ5zfaifH{;7Mu3LNJ74p8O(1gLm_4qghL{%5W{`#ruHyqNcY2W|zQ z{3%!eBcST_F7OQSK~VMmE$~9{=uf-%8$gw76jZ&u0#to|(&H083jbM9`FqUgoqQ;OD(^I?c6$f-bntJ$v%uf`f~)^E zpx%#z%GW*q{TIP2dHyx1@?G&?oL;JVd>JS{cqe!z_*bC%@5x_u?RYu3hv(bDQ^9Y5 z%HK~x<@+gLa{RXo+{E+U;OXGE!DGN*foFq{`Ld%w2NWNSgBO5r2OkCM_u_El9;4so zc@x)BJpTdLWBvEJ9NiOmPnM$#a_^qO{Wo~GitB%H=~w1@2k)=uDsvsSx5#aeFXi1e z{{9w^ujJkPxz6Bu9r#@EU$~lF8iU>lehk#_JdgKre=7GM@z3^=|6qU9f3M5EZ*c!k zu9$Bx0Uyov1MYvqC0^I>)m%^K{T41nLv%0KJXiQ7-25KjwhFo4>p%Pz_#)oZJ)@nV zcyBeR-$C#VTrtPjFSa^t%T<5xkr01n&28-NgMfx$fXPhU@2CFXB3y zZ{mkHf`|(H{RjX5lfVBZ_!NJ?0-Eo0FFySnt`GS4d6@7g zlj|S3!tc&-1OCR}p9SreTu4f1Xbd_8yy_z5okp2G74cr5rf zF8$Vf)VTMjJgfie_wQV9;+^D=|6k$n zB{Sd3^=_^+p&8@)-~QWS?&rDYc)r2E6Fi%1l+iTu_wSz!zMAV2u5sS)06)NW9QPmLx`X@oa-GAy%Y zJP(`#^}8N?AJ?t^`42r_>QOW+xK`z!Kd6`dzRh(!@6Wd<_um0e_eTHjH9X(WmH78n z-tXi7SKt;;^M~ML{Jr25zF!aC>fb#Je3TFWcJMb`zzZ3il&qsl;1AoWAKhuXfndd*|TI1h; z%)b}>dG5Z%{S?-qk}tGItQ*QGp9`geZ~p254Txb(Zo-g5s^>v=tf+vF?2cN^G-~VwCec5A$_h03H7x*^t5Z7OF{dcZ!agFl+ z2CkQJ|0=HMaXp?Z|J%jGNn8Wa{WJI&@V|ohg9G4ZuE%k&--Y09;D^8(_&Khpag}(k zfR}>}@P}Ll?ymszzoLKG!?(9^{|>Itb3Iz`dG{w=-{JOY;0fT9xNhf~;rWk1{f^=O z{oqcn_i%p~xE;I@{2tf4xW9&L16TOHi<{r)+Ln8FF3){De;3UE`g!<~fAKuNpT_kj z|NK$zpUd?JT;ca}?sxETBe<383*4{as&oB4S9HvoaeqA?Emy~;SJqec_36c~W;sb8 zCW{BB+$78jm*ht0+17%^;F~=NJD2!ES=WC_OsfJ!{jzwtilS9eadOhj= zmUyCWZzoDgdAv|hW{b6Aqgq=(VKHrs_e~TV#qy1cuw1G%_N{l%3cK9`HtR{DJXWYQ zXOdcJOz(Ht`|50?G*i08QrT&5W~=qmArb7#GBZ}4nJHGr)BNl<$~vz`t44dBy_idC z^-{H>z}Lr>YMm@imWs+$`k-$&=nW;PC*#Rzb5gHHE&SLN#Tsi6OQBdVjLtU_E8duW zY}AV5r3TR#%L*~RPnBaO9&gUf7UqhzQgO7L)G50@h$e{#sQbxUai-8n4mAcywq9-4 z#*+1|??pSIW}0->UnmIIhZp)hX?d7TDuvmqHPw{8m`cjC`dqQ6O0`lLPsU0!#d2Ys z2GN(H_^0?xdiz(fDKC9x2^?GTt!jrw}i~8WX zEzQc9swUo4ESKZmjpEq!Fx;5`R9_vJOLcKyu{=9f98DUfF^K1(+Ea~d$!xXOh-nSz z>PbTDjVJNQrAj;^Mjk9xCaMFgmMf;qNijf@>P#v&(Wk7S100PZ4y?kH0tq0wMK`D=x6*J z>8}qA$79uId7LaZ;>n~DPmISC<>F+0I9@q1R%w*uEjM4edC!(Bh6%8$N4PrS#>!PX z1x==|mJ7VQC9rkwdOXvtH{z+{TtdNOcvO`Q3pW&hW2#ge*HdvOp&3;s<*gXQ&y~qU zTp3qK4^UY~U5!`t*H^?7MR;sHUg z#N*YZUKwb_2dlMdHHzAV7>BJ^(i)2!)p(>ZH(+^C(|Jy5CIhO=8Pz*sinUsC{^nXT zA$kcUy|gOn$XPNo+nA46R+{DVDo5wv+>+F){!M5^$rGxkP>2V}vZJOx(#mmfJQXCg zXId`Uv3k(z*EfDEaiOqm;#%^YW~r8l8`Jt}i}ZR5zw|6PY6?`G87)mVt4&{Vp+Lwz zMYm|WBc8BXsU>68$qEv9e05B}uGSK|yxPJ?*)1wnZ$CnO31nF-)EjibNrV6_S}d!# zm5cB+9ZmhM-W;trN{wbCfy>3eaWXOCI96;43*THPlks}^bhT%m^o7ewzAPd4u7wx) zZjIU(4blbbZ`my_CYvJNxnuX%XT|Cp zg_)3#X1zF>&`}CA`zC5P#+6ECAlgu>jFp>+IW?zsrWhrWRHVY9%eQX7cE=T)5xnIl zf>4bLndkD=al>nJs_MLGQ&8dY%1x`{wHIG>@oN6Rcx?gswxxzJ-Cdn%94yw7cuTce zK{1d3;&0ECI)>9vihM$(bx(RpJYQ|bWAH5uf!wZ@M%6YY8muxtgh({`FyF@uqC`wc z#L}`zURqNRS8m@MUzt>_v3E8{%cZe+TWO5qA;L&kZ|YN2?&y4<$a`hni7L9n2PP29A+y$tHnVDt< z)n;OdS`{DFo3m1H$#}HY>zYwCBsDvc)RM|rlDBk$pfzcrIH_bs??QZSGE=S1 z6MU+OnxmSwZ@~y?s83arNy?1cvyKpLuaal-sT)-WF zDKcvqC-K$0qV8Yz9~y|0`dD!`sduNST0-=Pk#o-J5lNn8eV}oCS|2{<81<8Km0Aq1 z;*}V#bko{6x@~7Ip}+`*vBAi4>Er5&%=w z6M}<|j7&LL!j6P988%Eb%d7hkKJoQi_guAO@1A($_8a2sH}2ZCar>SdE`hQ!Rpo0k z2iGc|5?#E6TtVQ$d>9VZiN0$$@7i<~^cyeVx^3&88;}_BmaTiXZ{EE--m+s?yfNOn zao3)$oAz$oxGUbdcNe^{c`%N5BM*tOZvjar;}G7ZdnFC*sk*GnJvHvsE!4^D^y8^$ zZ^gKlT&+~v`&Z`Ptg<(&a&PwO&Ayv*Z}#6B?R6Rib8nwxRcMs4dShPZor%5rjd5-q z5$`J$ZZrWFW5M+;H3kdSKjsxf|5z@D8&C;#Y8&I%Oi>8{`X;6`95AbzUPSWu6^+x? zW>9A8XE5G6A&zmj|5T$fJ3KUW@ZiD0$x3suTALg~dq{KChbYIs`i&-oCx*?QgkkEl z40_C1O?$TGZ>(Br)T-sUoHWn``G8KX_D@RhiF?$sOj4;qNBa9^?#fs#HlmyK#fbFH za$T(?QBcXn`0@l^-Bui}=hS!hb+lP3HyB@~mIY=Owtumr4g!axUXzJZ1)-OPG3Au@ z%k)FAaZ#VeG&-jvLRdvwq`Z?@SYbrkjiTinBeQCCS{$nqO5?@Ew_Z{)A8)F~WaKb1 zG!tipk+cTv1925aTPuwtS$Q{FsuXMUgzx@2H6Jqpos4)p%B-gjBWq;K*3H|lxPI#ud#>8ui(==-Jv}~cy>k1GU7I&;+`YL6 z!8Ut8lN2k|EoO)8H&vSFtokLv;EqN{vFE0Z+*;7vop5HI8dZx{tFw{{b-E7PZ$zA3 zs%S{%O$^gy^u*R6(a1P8g7&x3R*!5tl9fiX%G0Q_WwO}V(ME+ic1#YH8Ur~N);OM| zDV*f*Sd(U;36wPu>j@-j%1%4B1zweH$`Z-olzQe6|Z>I^NLE1@GqD@R# z8qo)J%O%I+h+&ORme1nqk`Vg6S*r|4?Pjc$4vEqhz3pr_x=$rSRFn@)gL>yRamJO# zybSWAVj1oppQmkYyfe-qLr$<%(hNkHJ1hIk6RTtXTZLGc7Y-}Zgc#$WdTI|eYK+h1 z!)y=IYA5;tlQJ9`yO?ChGQ}9KE8s9v*J~~@x_3&FpPCzxn&)Q$Li|outg%qqs92|~ z;Jt7{oyw!$8PHnkrCQR6O~7WM7Y&$^deQ7N7y_mdTaMdm-DN6^q8Cl+5$AlNkXgFj zvQEfF^A1fGN!QHF5h*8~<5%R5n#KEQQ~ATVr?PH|ExrJ0TUMeXCIx;e*~Ue)g((oe zaX1*>%)Yso=|~UOrq}10&W&pp4T0}VoQxvL$L?7T0nF&j*)%c^T(8SAVPtygq>Z#t z%%DbrLZ8lMpoMzhivGcK>ML%P*j+SKDk)5;DJQ82Xw8gIeCcFaHWrUH_4T>Z<^!Y_ zd5qQQ2UNaRvrp2%=9)@}*)d~osiHRo?n8f=MfMD5bs`nM#!EXej48wab5#OAxDKGYe% zV)5D`n4tstDCLWCrBpYv!sHT6ztSh$zsa58j8b#qsYUAz{8qJm^xcVQ#atrYX(&pb zNNtrigq%1oKd@qIc++OCpL(s~=H_tiln^2ezBIhHnsp_iji=p&f~U7O%_>Pe(B1}O z?rzJ|WYHTn=ee|H#gog3AthU_z!eHba`%;BSNJhbmU{#(Z zqnN=fOed1dKNm&z-T1icm(c!lk(ndmAO))67?4{KPvm$O3Bz(sgPv)?8kCZMt~t7< z28~+1H<9K=key~snpMxJNgYv*w%T@SU! zTa1u&EMZmMsXDtEgFQ%Xu8E=Ph^%R{I3lGr5RJ{?H(~{Z!K(UG`XT#u3T~P0FvwJ((J4ns)`p!CgG}1Yp{zkm?v+w1RZf#L(l^CFbq=D zZmh~wNLOnyM-pZOH3*Y+>Rdvlilpa^`8Fv~ATl1Xc2%D}Si@dP<>taf>i^v$TJ1!d z;>>-;p7 zB$KpPR0$-1{Np5rMgHo zLn3M76|}ZtNIX$wB*3Jb_l7GiH?WRJtK*a^r5!6G(9Eu~v3ril+9E09F|RQ?%}>uV z*GTzlbao^>6_J~(b<>uCab!A<6q2E^C;&m>=HDVmr{*!;QJj!K+~9{#{%e@HQDaG) zS zJbsylVBLgvbaQ`!u2t*Gg=ifNoz`MnkgYUe`oU59ad&Vqb|cJ;6Ut`ODHNhh0Q~Xh zRLpGR5j7E+O4CfE%IAoQrMkGQg(@S^V8zW9NOpFcYn3L^^amW)V6JCn|2PhFr$pn_ zs<7f3)Ab-X<WvIvz{!ldH?M+>`K%t+X?Qrm!8 zq?r<8!#qDZ7h#@Mf;gjdLV@Q})dHbRy&0fb);Fra|lW4p3fZ3Wz;~ zRFly!Dm(B+e3|27|S7S-d7t4(m3-i`hrw6Rh$La zFu2;BoJ#F7mJ?N3?a(OICosT`se=y`cUKv*fn#xY=z$A~?xE5UIMi|v6wJ2YAm_Z9tVgaOfuyIL?{hKOs z_lbtEo4oGu6Y1E(MweSvp%qQt@Rhv3ZY3jjjm-zo^Q^j-Y1d zozb*b&6w9o-Hx^uj5pm{9L*|d^;uK=5;-dRT5us)Hq{4+M>DW)EETjvS2F9CHY1w$ zUDwB1mx#X!o3D4U`fL&1A66hZ(}xxtSvjz}k0R17Y>{3O#p>2t1{2HtU9Iu@Oy;uf z%i#ta<@vUJ1bQl{QJj`aaz?z#r~b^>%gWlekP?|)t0ZTooTj#m%XS$l#Ua4BummWK=71d=QO5jCi^UWDzcg0s-s9l zCrHhjbiql^LNc$24Pt}UPs3Eqo_4~<{5a~gWx8XNMPP${mz#m5A&6#zCG_gDZfwN| zHi!m|3M&DKJ23s?>}D-6z^BOU0+ze2`%LQ>sj((+Gp~)N7?gR_djBE$A|zR0=G2I@ z^TBhtDplm-idC`3q4!-*lBIgNn`U6V^9^`C?Y;{M5YlH8r$hSjnsv+fhP5y*v0d z(iJdzi6%42WOJrb2;MT9Zs)I=>YQ06nqQFZ*xh%ER97cj6?Kw#b)&Y^XCB+7r_ml} zk%Y8XGLv9dJ*umbT|E|u*y2j$GwjARM&NoEul% zr}*Yrbur$ZIps7+b*q-$4Hn5}ih!h)+;SgnKq0NrK7l zh8Qr3v(WWi@a(NyBogKmMuh zk7*eP`)+I@KdPSD$Z^&kM2tbkv=zf`f?=KxU!*k`eZ{$2nFK@8)y(~XE;3Pt)xzdke|7tl0~Tf%!$j5jGt6?3(@Kpdxc z3E2_u+;f){Qa!U}^d8U4(Z*)vY86Yf;xvI0Y}*+khh{mMz!F7C+~IWA8A30Xdjzp9 z$_nGQpQ>bwQJRyrR)QO$Ol>Y3TboU#-K6rFiw~JQVDVvn6ToOap+21U?HnnHn zA|073Zf%C`pX_U;^cH3>(nmBzs&#}~y1wWPyWAm?i(zS6XF=LF;Ty4%)BGf8Yvv)F z%r4iexYE)sNzmh^WEF@cBwaSDBdu(p;kL88v4(e>*hFGVk#;fdIPOMguA-YY^s291 z#dNlLI2#AqWN=2rbXAYi1_={sWuWZ_gZ}%;)>cletKrT zgmgpe&RCS{gd5#EIp&RTm}lp%9h zOVI{fUOu5 zM13%7RJHD)eOT3zE{;V`Ai;m*txS|wn532|I!jZ>*XY@C_DC%|1n$MIDsmW#2T{d7Q*2rbtxM1>7*h)x(;8dSs zZzUAD-6Cn* zF<&2J-)I&AleM<+?vchI!Qf{HH0hyzH|&6wg~fuCL#_UXrR=Y13zDk5MO_pGZ0p29 z4YmqZWvT~Zn=)V%bXBL96t<2Ru5(BH47>HnPaj+}xMr%)9sg3ewmw-JFX+&h!k((; zPb;``Hq@sRmH-c8EcNZ&v8S+!0jf;?!WA&#aJ+8K+I59B=M~mn6t7!1yym=f*Q{H! z2ExKFRzqpkVjJDs^WwD^4X;__=(Zuo3hei-;Av*KFdSbk)frz?tj%dO7hgKeO^~Wy2pxwfo57BZn)MBM&y1yM#a!8Cvr^QDU1kdrzCyMw3uFXlMyXQZ?AyjqAKB z^8cTXr3zWFbCT?wtnfye`hVhVs*s_s=ToI0mEGl?QB|Efkd!rMc8#F(pd_K!x4l=y z`4g-3yz~RBLhP1#W0Z2TZ+-e!kuB@sD)qtK$yGDWW~0$OP+YI~=^<52lvStMZ`+(L zRjRqetMncx3T|!0bGgb9HF2>xJzcFIIC8jl058G(G`n`{M-CIyb*0)=!UPIi2g);$ zHi|5Q;Mfh!4SM40cp7Ib6J*u$OtTpO!}H!EQ3b@IXy{VCRtFiBcY^!XeFv)3MLA8T zi?g$wzafGJj=NHHv#gb6M6KAEaYu-8=a0K09##fVC2U!TMjle-=Txnvtm2ZQ5lT}SJQhZ$ zVbQRTe5#SK@rud_*^86eBZsS!$G9cr8qz6VvU!lAG|jNi#K8ksaMfik;?Kw;1|?@% zGC4O))mz{+?ySZ&USpDr(TwUCg2J2+uk3OQ+Zd1P(@e99*sB*2p~{OXc%7bAm@BbN zgnTt=!09UO8_v>Vx9fC5%}}uJ`rxRH8h!4rN+C^;{9Tl*L@)9KeoSdP1W$64mPh@h_g2x7Z0>YH-@DAzv7h0?ArMPE@C8Q+h>v3LUY=xr4aU z3hYW{ZNPsn&kWtCr%MN_7)W*;7mTP*mGu-PAt&(^=}epo*hIofZosJ&zXH!>Ok8p7 zy|fd$T8i1y;yQ>e&0TLY&lr6X_2$Nl>KnMrDPAO>o#RDAnr%ah z2a-yqSr4apVVKWV6;Oq=2G4gY^um$DEZI$%{>6D?7GtsHSg+5$dl{#C9XX6#f`v>` zi@DH6QV5kxOk&3eiqptj(u0bf2*@7FeV{nR`8CYzplqlX``Xv*NUrz*qNNBc%#;Xv zC5O;-Kj#aT0J~`Yf1lGsmH0ed8>F*R)mmv3>q?UBR8}#9tWXVnW!)-@Yi9n)gHuNi zD-ntV_xYneX(z@46${2k&Ww|0+bk&xOD71lWgPAm^zJea_(I+)(F(Pv`a{-Z7!)JZ z{6VRrrkhQZ%dPKSufyJjD=R3i)~}RMM+j-}2z|5lo6htqAbVg{c(C=`OqEHn;v7qO z6Z`<2ds9R{H3#FJ#S+X<6NuB*g{kZVs7sMyx1hg`@yisWP8X39meh|aS=}@n|B2&g z=I3#fv=mTm0~ry-WXT!#-k>ORf>$z~w9?DA(82)Ptz5-QX#LtNiffyQ#F7h9(ve^) z2nxLE*HdX*nW9vOVUA}rZQ-)cQGQ1b>)F_wNZRsgFMLKRceKY_5GDX!d%A58G_TWE zHaX?&p|l(O^T1LXdiMT9{8vB=GkTJ_K}8qa$#PMdv3Jfngjt+ueM-eiv)*iIxYNT5 zv!w=Irx9coDi|Ydt~g!N;h3B8(p1C>W(nl$T0-5`0wd(mGP}FCr_I`xO3dpq;Sp_{ zpPFao&eAdxq#+#0h)~Ufp@xiUAVgqXRE#srvWnf|O)r1CSdT8Zha%IkUeM{#qd93! z%fBqJIhjkVV;Dxwk7K72Pa#ys=N+fAX_8?;v2W|PYd3C>uid)m$P13VV0*l0<28Ht z?%BxEJV;F}C!J@cu1w=&v$Hgu!2<*QjeB=)+_r7&?!9}j*t~ns#y$zP-8*(}z0SXg z_iWv~XU`2cD8gOW?AW?z?=`zOZ{9wLYd}K)84`{8Qe9;)HWoNwtdLBNS7jMU%3V!| zrRUOyGH5Yi>OQrdWJZPNP(cgSc>*Kp=h^-v$n0*tYaj${Znw;;%CjOGv+60+W^8jN>4Q^5v&v1taa zOfO4uG&#Q142YJ<+KixlM)Gz~NC8zSqcV%a)jP6@y0e0X5xXhPG&)a~|ETV6wu?-L zz&ftxbe5UXqQRR8l)sO~E{;qyvLG z!X2{{7NJJnrf&KLh6`#i-{lmEcmF2~#?v0i?Tg1U!40o~U2Dw|`Lo0F(U)|Poz#{L zEO{JSJFSji^W?Z-#*ut-TNUHV{4^@X=?AswJVTm!^cVU<1xYtW_RLW3AU4so^wrdG z$hk?JL5dtu^gi$-2#ByGQ~?vFK0Qx~XYrs>cy-|^Y+18mF=05w4YDaEKy@yI4a$!o zNd8ziAH0+8b(ESu!d@*6!8?;Rg|yPlAmw!kL0LJIm)?duqTn1@{DlIF6c5o$a&h%;&b_;IQI-7Yu%?h&&#^6>3A8 zvabs`Nv2@Q`Iey|PA9ZkHIZLod!UF3iPg{Ap7~kSxo4NCjm*ti*)V~%;6~4KIR;29 zK5NQ0mkr9Axl&Of@oBQ~TBA+VIjL=7>LF__OG`#cBb1$Cnm=fmlPnRMe2KtWHAS zLMD8jEJnydZ{4z+%TJcrGAf}*wEx*!P_)ab2Iv>BhdRzUrWVZQmdXa%{u;m|!e!q2 z&L=V9&$MgF$8tE&opa~2wTyuLr5K4VxvB6OFfVRn5UDCjYjze#ISMREQ(|&Z+aOF` zkP@z@=QE|@B|@$rEfiKudJ4`pBDW>cv?P^vow|Aa*dI({8n8LPIBv>(>=}6=@J6Df zScsve#+MX2EGJ%OEMB}at_%Wi@qC9&{wKoZa~rCmXFY}V(rK0M38y1cQ_#-EY_0{( zMn&0I-}p6zbMP!nqM<=x z?-7Grzoe+lVDck;O_MmEo1BM%E9-e1EOOGxsZHZ`P6a7VBYwl!BUc%kYpFM@Opzm* zgW{BdCgJQOk_syFClDH%IlcG zlm7fwra+{s;mttt{=xHU5&=4i3` z@gnR0;%vRd47pT|G;=yIP#XJ67L53l16%khm|3}cUIK5l^Xwxmmml$WmfVc& z)For)p}A|)@}yz_4}=B_X;t|sTe!(hT%}d9(2OVx0lnQBJRBrYLL#8nIIl3ov5IAX z3rwp*mK|TnLt#N`t4uWMLNW63fY-RKMPt9h0gla)z>+w@g~6HxO{GMnn{IsNp6TiZ zQ?ULJ*t>nG`G|9+Bgxb;sMQ-% z2P~KKg~qmvY-522T&sqeGIC?BwxL#@WEtZu3#Q3_1iT!#i;t4*0LEp|JDFl0J@&XF zA~nQBP#A|NGd8DG^okfNr;0=0&j~|$X*-tiwRup?S3W#V@F zlmp})bs@9k9YZPFB$(7ezdQ1=5J=Jly| z_e>V+AV>z#&Y9&-g2a5t;`cE)9VQ<~`iY&{c&_EyW=a}cJu|T*_agnCeaWv(3UT$T z4=ozPRzX?X{Wh1j^Z-LfFRO^Yom++Fk4hl*bk;RE6Is1KY5p9ur5GzQmqdffs?m{> zwjO|4b~clYO%=@NZmSPMFyj;rl5Btvp^dLtL1|9+OrY?09$89bCPID@lwZY@>+-3e z+M5QsQzw=EbiGOBg9bK{!#zEC5=DYOMEhy^x?4NsHMR2!IrGEGF=aHGpTQPphm?)4VgL6hXw={p{E$+$sys2RZ6xNXB%oH%ul;XHLwVT~JYh1HW zxt#eg)-GWN4QFK#t7^b5E-M!mRQSzcFm>ah9O~=%NBm5+z@I&`Ly3rZ&Lwhv1e(t|h#|BM{ zfHobn?0{KCX?ohRHlj<12_h`;7O=&7mbquiHEduG5Rhr7m0DRy9`b=(N|aIMNwUzv zW>>2zMQ>8;&`-}ixMe$pi?i;s1=p@`iiP{S2D7Potl_ll2hVhvWAoiCCzVWHEGM=g z7ElB>Oz(9vs0!+GnrB>!ZbFaRb@PLexuZfwkHs);HRYy6CFo@x(AqkU&s1tlt@D9k zZ9PF@uzfY8#4Rl^ulMA#=0p>UQpe6M!9q2!KH6iQ)+!s>foZ!YOt+A$1}=)Q_EeVV z{J54?9wvLtES1vJKFO79E6=D)8xe-HLJ7nO((GEKhKh|3-Vg87rVYd9cCQC(2;k$K z^)Gv8p_tw1G|jOejV~$Me8tu=gH`jYQ#J{PCBT+n)_o9v&iA24kULd%XU(#-5FN@s zC*?y0@h20*c(copGNqDbn3g%*bXpT)mX_s(oKi7qL*&$$fDPo!jLIb>i+Vrjo3fOX z<+Hf1SoNs6`f2tR_#s3t%hT0qokgPU9O5*aT`-ZPdwPnbQ##i#rz}$}jGB=u3}J9} zhd~M5nW0&izHN?ToA2<;#fXj?54ys8Tv{!I4(lO{L`Rqw`Ahcdm!V@=cQvuenoJpo z8i4nTgLNvjcL~qegRGIW(SXbYt>0B+$W3LFBwBH6gqY!O#cdE8Y}NFpc&Br*Bh?_P zT&@)W|{<>cr`!Q)gseHsx~RX}o=!POwZmVMYe7Wbi?~bxAvo$eq|4qTtVw_%W_?5!j!iXYb8ok%aJ? zjX0oLJ=_3gb{PaFWzGnzt;NqZUDUcw^F|?*1Dc3G8aTI_XAzP=>QLoeWB8z=WbSX4%ZX{~@ z*5QV53Yeu}OndDYRe3sr4*} zPQjaU(5Ti-DB9C6E6nJMk)3zYHl4oMfHpH9LU8Y$T}Hrkj?VsER=V?#Wg%J{(zeit zW?z=WvTbZ5$AdeN!VZnKmZesm=Ym$WR?aP;GXnM-GIeHcoGRJY5NRd5Jy^H{weB9i z6SubvD^K*9)uY|V53~4B3D7(4z1M$eM`;DKy%6$ zndZf+jJzPpBV@wZ6plQ%4KvpwNQ$qg1fzxnOH|HnG0}{X|nVnTkj?5j4iJQ=*YP# zUAeehjqo%!>brfG@BdCVmlE+K&GD|?#9q*jC0EPpNm8-xd;x*>&uF_Le}+E49)V}8 zN6z~w!3{dyi;+k~9DdM>(qa+#k;AOsk=Z~>C03LMf#WTSRN{1o^D?V<5O{N?b|}if zQCt<O#McvemS~_=4rOtEtEFyyXF?Bk8O-J)#7=SIN$$IJ@ ztCavP6BE4Enuv;K$Ipnuo=3T>-G*Dqu3pQR`DBiWY%MR6+^t$w*328iE}UL*=h!v|`y1op6AlVeUt@Hw9n10t z2Z_qQv<^}X2<^urSv#y0ben*3K7_W$1|a)G|8F(r*~FbqgWpDEGxuxk-t*#-j4A6q5RkJ#6dXQP|}hCE4k{RFYq2pDo|4BxQIJVVoI<4C9utOnTvH$!6Osjx0(| zRj0|S7X}jte@qfB9Ipn+StsO9=_n33d?|4{8lCUdK5Y>?b}j?Hu9rmHX{~uiPUB5w zZV@z7IYluCOhrSVzIHw87E{U6rFfsn%kzk(p`S}F{)M!s4s?tlDUnRpS}W<$6ZLI;#JD-xg^gKYyZB*M+a4d3 zw5CE}RXZ|aY|hq%>6`KUkp5=?rw*gLa-wxvD=8$8j>2&^&*-CLMlr0Bw52 za`sj`S79utnpjspKR?U#jFe-``yj8vtXJPRyEiXVDG$;i~^PI9C19J8JbU4j)OE{X@m(ed( zTaZ27NzKac0ukFtLRrx9&46~D+GGg!$|jVS9p7BSJrf+Su1hX0%8m%nJ@-EoW$N~m zu)?Wlqu*jU?Aeqw9l$(NwoJtajo#g$BHqE3S`%m3Q%cKDw0VY7FGjs&=0kAsX(J+sKA2>l z-6^E$>C>t2db-H&HypA42BHhUm)Q0Wf&`6#A?osDpx7F7Uo!p&XS-L+u@qg8(^M^opi*q4^Zb5r)fjA$T zF&9p%Hp8{WlItAJ^`>>IARW$y6TsVtkY?8D6v+I{4i7z(THI!I$6TjOo0BLVvzqCl z*vnvLe?s;$LgZzsAC1}cg|8yGj?Bt#$sJ8?3lZdeviS|0VUm#UdTus#B_An+Z?mCt zv9xB=FNthh|1|EcxTH}uvrdp%GT}h*8^EBk{9#tsO@xx zs@$EJ+nU`ZFbdDjEwpy?HXe+^Nz@ojTG*fixY=>#Lz<<}D^_c1DFd=NEos{T%!2D^ zMb@R~&f?Bu_3hnq7I(L=*|F5w*L<0?+T-xtbn2wUv1~1yjWK@R8iVX??$+;V?5+D9 zwPpbsXm0AXZdyaym_TP}D|M{`T|x{_lxKNY7q|7(%7z;?_!GoCVi##@*)YDa^T@O% z+o`>^!`!4f?HW2u)@g{GdnBCd-P%{OfkV(FSrjnX!D(#mC7-dVlOLiw6S33*&KJA{ zZZ6ptplQ*O=C%)%ifr)-XMHatH*Niyx}qof0!* z;Gan#?et4Gy5q3{93ym?o5(KuZs5$MQ6l zz5QHn6LV5x9&0I)W=+5;==lT8^X=waK^36&%8`jZm8uO;_gQ4Tu zgk)GvnC$@x$B+k8`N4K6!J-jZPJCZ3+8I>dJ3tieN0~1_j-*sb)l8b<;EFP5Z_T#L m54WFe-fJk-^)z!TX7TA, 2010-2012. +# +msgid "" +msgstr "" +"Project-Id-Version: gawk 4.0.0h\n" +"Report-Msgid-Bugs-To: arnold@skeeve.com\n" +"POT-Creation-Date: 2012-03-28 22:03+0200\n" +"PO-Revision-Date: 2012-03-13 18:00+0200\n" +"Last-Translator: Jorma Karvonen \n" +"Language-Team: Finnish \n" +"Language: fi\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: array.c:140 +#, c-format +msgid "from %s" +msgstr "taulukosta %s" + +#: array.c:248 +msgid "attempt to use a scalar value as array" +msgstr "yritettiin käyttää skalaariarvoa taulukkona" + +#: array.c:251 +#, c-format +msgid "attempt to use function `%s' as an array" +msgstr "yritettiin käyttää funktiota ”%s” taulukkona" + +#: array.c:254 +#, c-format +msgid "attempt to use scalar parameter `%s' as an array" +msgstr "yritettiin käyttää skalaariparametria ”%s” taulukkona" + +#: array.c:257 +#, c-format +msgid "attempt to use scalar `%s' as an array" +msgstr "yritettiin käyttää skalaaria ”%s” taulukkona" + +#: array.c:302 array.c:707 builtin.c:84 builtin.c:1385 builtin.c:1427 +#: builtin.c:1440 builtin.c:1859 builtin.c:1871 eval.c:1135 eval.c:1139 +#: eval.c:1495 eval.c:1812 +#, c-format +msgid "attempt to use array `%s' in a scalar context" +msgstr "yritettiin käyttää taulukkoa ”%s” skalaarikontekstissa" + +#: array.c:513 +#, c-format +msgid "reference to uninitialized element `%s[\"%.*s\"]'" +msgstr "viite alustamattomaan elementtiin ”%s[\"%.*s\"]”" + +#: array.c:519 +#, c-format +msgid "subscript of array `%s' is null string" +msgstr "taulukon alaindeksi ”%s” on null-merkkijono" + +#: array.c:723 +#, c-format +msgid "delete: index `%s' not in array `%s'" +msgstr "delete: indeksi ”%s” ei ole taulukossa ”%s”" + +#: array.c:734 eval.c:1865 +#, c-format +msgid "attempt to use scalar `%s[\"%.*s\"]' as an array" +msgstr "yritettiin käyttää skalaaria ”%s[\"%.*s\"]” taulukkona" + +#: array.c:910 +#, c-format +msgid "%s: empty (null)\n" +msgstr "%s: tyhjä (null)\n" + +#: array.c:915 +#, c-format +msgid "%s: empty (zero)\n" +msgstr "%s: tyhjä (nolla)\n" + +#: array.c:919 +#, c-format +msgid "%s: table_size = %d, array_size = %d\n" +msgstr "%s: table_size = %d, array_size = %d\n" + +#: array.c:954 +#, c-format +msgid "%s: is parameter\n" +msgstr "%s: on parametri\n" + +#: array.c:958 +#, c-format +msgid "%s: array_ref to %s\n" +msgstr "%s: array_ref-viite taulukkoon %s\n" + +#: array.c:963 +msgid "adump: argument not an array" +msgstr "adump: argumentti ei ole taulukko" + +#: array.c:1086 +msgid "asort: second argument not an array" +msgstr "asort: toinen argumentti ei ole taulukko" + +#: array.c:1087 +msgid "asorti: second argument not an array" +msgstr "asorti: toinen argumentti ei ole taulukko" + +#: array.c:1094 +msgid "asort: first argument not an array" +msgstr "asort: ensimmäinen argumentti ei ole taulukko" + +#: array.c:1095 +msgid "asorti: first argument not an array" +msgstr "asorti: ensimmäinen argumentti ei ole taulukko" + +#: array.c:1102 +msgid "asort: cannot use a subarray of first arg for second arg" +msgstr "" +"asort: ei voida käyttää ensimmäisen argumentin alitaulukkoa toiselle " +"argumentille" + +#: array.c:1103 +msgid "asorti: cannot use a subarray of first arg for second arg" +msgstr "" +"asorti: ei voida käyttää ensimmäisen argumentin alitaulukkoa toiselle " +"argumentille" + +#: array.c:1108 +msgid "asort: cannot use a subarray of second arg for first arg" +msgstr "" +"asort: ei voida käyttää toisen argumentin alitaulukkoa ensimmäiselle " +"argumentille" + +#: array.c:1109 +msgid "asorti: cannot use a subarray of second arg for first arg" +msgstr "" +"asorti: ei voida käyttää toisen argumentin alitaulukkoa ensimmäiselle " +"argumentille" + +#: array.c:1655 +#, c-format +msgid "`%s' is invalid as a function name" +msgstr "”%s” on virheellinen funktionimenä" + +#: array.c:1659 +#, c-format +msgid "sort comparison function `%s' is not defined" +msgstr "lajitteluvertailufunktiota ”%s” ei ole määritelty" + +#: awkgram.y:249 +#, c-format +msgid "%s blocks must have an action part" +msgstr "%s lohkoilla on oltava toiminto-osa" + +#: awkgram.y:252 +msgid "each rule must have a pattern or an action part" +msgstr "jokaisella säännöllä on oltava malli tai toiminto-osa" + +#: awkgram.y:323 awkgram.y:334 +msgid "old awk does not support multiple `BEGIN' or `END' rules" +msgstr "vanha awk ei tue useita ”BEGIN”- tai ”END”-sääntöjä" + +#: awkgram.y:371 +#, c-format +msgid "`%s' is a built-in function, it cannot be redefined" +msgstr "”%s” on sisäänrakennettu funktio. Sitä ei voi määritellä uudelleen" + +#: awkgram.y:432 +msgid "regexp constant `//' looks like a C++ comment, but is not" +msgstr "" +"säännöllisen lausekkeen vakio ”//” näyttää C++-kommentilta, mutta ei ole" + +#: awkgram.y:436 +#, c-format +msgid "regexp constant `/%s/' looks like a C comment, but is not" +msgstr "" +"säännöllisen lausekkeen vakio ”/%s/” näyttää C-kommentilta, mutta ei ole" + +#: awkgram.y:528 +#, c-format +msgid "duplicate case values in switch body: %s" +msgstr "kaksi samanlaista case-arvoa switch-rakenteen rungossa: %s" + +#: awkgram.y:549 +msgid "duplicate `default' detected in switch body" +msgstr "kaksoiskappale ”default” havaittu switch-rungossa" + +#: awkgram.y:809 +msgid "`break' is not allowed outside a loop or switch" +msgstr "”break” ei ole sallittu silmukan tai switch-lauseen ulkopuolella" + +#: awkgram.y:818 +msgid "`continue' is not allowed outside a loop" +msgstr "”continue” ei ole sallittu silmukan ulkopuolella" + +#: awkgram.y:828 +#, c-format +msgid "`next' used in %s action" +msgstr "”next” käytetty %s-toiminnossa" + +#: awkgram.y:836 +msgid "`nextfile' is a gawk extension" +msgstr "”nextfile” on gawk-laajennus" + +#: awkgram.y:841 +#, c-format +msgid "`nextfile' used in %s action" +msgstr "”nextfile” käytetty %s-toiminnossa" + +#: awkgram.y:865 +msgid "`return' used outside function context" +msgstr "”return” käytetty funktiokontekstin ulkopuolella" + +#: awkgram.y:925 +msgid "plain `print' in BEGIN or END rule should probably be `print \"\"'" +msgstr "" +"pelkkä ”print” BEGIN- tai END-säännössä pitäisi luultavasti olla ”print \"\"”" + +#: awkgram.y:995 awkgram.y:999 awkgram.y:1023 +msgid "`delete array' is a gawk extension" +msgstr "”delete array” on gawk-laajennus" + +#: awkgram.y:1019 +msgid "`delete(array)' is a non-portable tawk extension" +msgstr "”delete(array)” ei ole siirrettävä tawk-laajennus" + +#: awkgram.y:1135 +msgid "multistage two-way pipelines don't work" +msgstr "monivaiheiset kaksisuuntaiset putket eivät toimi" + +#: awkgram.y:1238 +msgid "regular expression on right of assignment" +msgstr "säännöllinen lauseke sijoituksen oikealla puolella" + +#: awkgram.y:1249 +msgid "regular expression on left of `~' or `!~' operator" +msgstr "säännöllinen lauseke ”~”- tai ”!~”-operaattorin vasemmalla puolella" + +#: awkgram.y:1265 awkgram.y:1419 +msgid "old awk does not support the keyword `in' except after `for'" +msgstr "vanha awk ei tue avainsanaa ”in” paitsi ”for”-sanan jälkeen" + +#: awkgram.y:1275 +msgid "regular expression on right of comparison" +msgstr "säännöllinen lauseke vertailun oikealla puolella" + +#: awkgram.y:1394 +#, c-format +msgid "`getline var' invalid inside `%s' rule" +msgstr "”getline var” virheellinen säännön ”%s” sisällä" + +#: awkgram.y:1397 eval.c:2504 +#, c-format +msgid "`getline' invalid inside `%s' rule" +msgstr "”getline” virheellinen säännön ”%s” sisällä" + +#: awkgram.y:1402 +msgid "non-redirected `getline' undefined inside END action" +msgstr "edelleenohjaamaton ”getline” määrittelemätön END-toiminnon sisällä" + +#: awkgram.y:1421 +msgid "old awk does not support multidimensional arrays" +msgstr "vanha awk ei tue moniulotteisia taulukkoja" + +#: awkgram.y:1517 +msgid "call of `length' without parentheses is not portable" +msgstr "”length”-kutsu ilman sulkumerkkejä ei ole siirrettävä" + +#: awkgram.y:1580 +msgid "indirect function calls are a gawk extension" +msgstr "epäsuorat funktiokutsut ovat gawk-laajennus" + +#: awkgram.y:1593 +#, c-format +msgid "can not use special variable `%s' for indirect function call" +msgstr "ei voi käyttää erikoismuuttujaa ”%s” epäsuoralle funktiokutsulle" + +#: awkgram.y:1671 +msgid "invalid subscript expression" +msgstr "virheellinen indeksointilauseke" + +#: awkgram.y:1711 +msgid "use of non-array as array" +msgstr "ei-taulukon käyttö taulukkona" + +#: awkgram.y:1975 awkgram.y:1995 msg.c:98 +msgid "warning: " +msgstr "varoitus:" + +#: awkgram.y:1993 msg.c:130 +msgid "fatal: " +msgstr "tuhoisa:" + +#: awkgram.y:2043 +msgid "unexpected newline or end of string" +msgstr "odottamaton rivinvaihto tai merkkijonon loppu" + +#: awkgram.y:2300 awkgram.y:2358 awkgram.y:2542 +#, c-format +msgid "can't open source file `%s' for reading (%s)" +msgstr "ei voi avata lähdetiedostoa ”%s” lukemista varten (%s)" + +#: awkgram.y:2301 awkgram.y:2359 builtin.c:122 +msgid "reason unknown" +msgstr "syy tuntematon" + +#: awkgram.y:2317 +#, c-format +msgid "already included source file `%s'" +msgstr "on jo sisällytetty lähdetiedostoon ”%s”" + +#: awkgram.y:2343 +msgid "@include is a gawk extension" +msgstr "@include on gawk-laajennus" + +#: awkgram.y:2349 +msgid "empty filename after @include" +msgstr "tyhjä tiedostonimi @include:n jälkeen" + +#: awkgram.y:2494 +msgid "empty program text on command line" +msgstr "tyhjä ohjelmateksti komentorivillä" + +#: awkgram.y:2609 +#, c-format +msgid "can't read sourcefile `%s' (%s)" +msgstr "ei voi lukea lähdetiedostoa ”%s” (%s)" + +#: awkgram.y:2620 +#, c-format +msgid "source file `%s' is empty" +msgstr "lähdetiedosto ”%s” on tyhjä" + +#: awkgram.y:2797 +msgid "source file does not end in newline" +msgstr "lähdetiedoston lopussa ei ole rivinvaihtoa" + +#: awkgram.y:2900 +msgid "unterminated regexp ends with `\\' at end of file" +msgstr "" +"päättämätön säännöllinen lauseke loppuu ”\\”-merkkeihin tiedoston lopussa" + +#: awkgram.y:2924 +#, c-format +msgid "%s: %d: tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "%s: %d: tawk:n regex-määre ”/.../%c” ei toimi gawk:ssa" + +#: awkgram.y:2928 +#, c-format +msgid "tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "tawkin regex-määre ”/.../%c” ei toimi gawkissa" + +#: awkgram.y:2935 +msgid "unterminated regexp" +msgstr "päättämätön säännöllinen lauseke" + +#: awkgram.y:2939 +msgid "unterminated regexp at end of file" +msgstr "päättämätön säännöllinen lauseke tiedoston lopussa" + +#: awkgram.y:2998 +msgid "use of `\\ #...' line continuation is not portable" +msgstr "”\\ #...”-rivijatkamisen käyttö ei ole siirrettävä" + +#: awkgram.y:3014 +msgid "backslash not last character on line" +msgstr "kenoviiva ei ole rivin viimeinen merkki" + +#: awkgram.y:3075 +msgid "POSIX does not allow operator `**='" +msgstr "POSIX ei salli operaattoria ”**=”" + +#: awkgram.y:3077 +msgid "old awk does not support operator `**='" +msgstr "vanha awk ei tue operaattoria ”**=”" + +#: awkgram.y:3086 +msgid "POSIX does not allow operator `**'" +msgstr "POSIX ei salli operaattoria ”**”" + +#: awkgram.y:3088 +msgid "old awk does not support operator `**'" +msgstr "vanha awk ei tue operaattoria ”**”" + +#: awkgram.y:3123 +msgid "operator `^=' is not supported in old awk" +msgstr "operaattoria ”^=” ei tueta vanhassa awk:ssa" + +#: awkgram.y:3131 +msgid "operator `^' is not supported in old awk" +msgstr "operaattoria ”^” ei tueta vanhassa awk:ssa" + +#: awkgram.y:3224 awkgram.y:3240 +msgid "unterminated string" +msgstr "päättämätön merkkijono" + +#: awkgram.y:3436 +#, c-format +msgid "invalid char '%c' in expression" +msgstr "virheellinen merkki ’%c’ lausekkeessa" + +#: awkgram.y:3483 +#, c-format +msgid "`%s' is a gawk extension" +msgstr "”%s” on gawk-laajennus" + +#: awkgram.y:3488 +#, c-format +msgid "`%s' is a Bell Labs extension" +msgstr "”%s” on Bell Labs -laajennus" + +#: awkgram.y:3493 +#, c-format +msgid "POSIX does not allow `%s'" +msgstr "POSIX ei salli operaattori ”%s”" + +#: awkgram.y:3501 +#, c-format +msgid "`%s' is not supported in old awk" +msgstr "”%s” ei ole tuettu vanhassa awk-ohjelmassa" + +#: awkgram.y:3568 +msgid "`goto' considered harmful!\n" +msgstr "”goto”-käskyä pidetään haitallisena!\n" + +#: awkgram.y:3619 +#, c-format +msgid "%d is invalid as number of arguments for %s" +msgstr "%d on virheellinen argumenttilukumäärä operaattorille %s" + +#: awkgram.y:3654 +#, c-format +msgid "%s: string literal as last arg of substitute has no effect" +msgstr "" +"%s: merkkijonoliteraalilla ei ole vaikutusta korvauksen viimeisenä " +"argumenttina" + +#: awkgram.y:3659 +#, c-format +msgid "%s third parameter is not a changeable object" +msgstr "%s kolmas parametri ei ole vaihdettava objekti" + +#: awkgram.y:3732 awkgram.y:3735 +msgid "match: third argument is a gawk extension" +msgstr "match: kolmas argumentti on gawk-laajennus" + +#: awkgram.y:3789 awkgram.y:3792 +msgid "close: second argument is a gawk extension" +msgstr "close: toinen argumentti on gawk-laajennus" + +#: awkgram.y:3804 +msgid "use of dcgettext(_\"...\") is incorrect: remove leading underscore" +msgstr "dcgettext(_\"...\")-käyttö on virheellinen: poista alaviiva alusta" + +#: awkgram.y:3819 +msgid "use of dcngettext(_\"...\") is incorrect: remove leading underscore" +msgstr "dcngettext(_\"...\")-käyttö on virheellinen: poista alaviiva alusta" + +#: awkgram.y:3911 +#, c-format +msgid "function `%s': parameter #%d, `%s', duplicates parameter #%d" +msgstr "funktio ”%s”: parametri #%d, ”%s”, samanlainen parametri #%d" + +#: awkgram.y:3953 +#, c-format +msgid "function `%s': parameter `%s' shadows global variable" +msgstr "funktio ”%s”: parametri ”%s” varjostaa yleismuuttujaa" + +#: awkgram.y:4111 +#, c-format +msgid "could not open `%s' for writing (%s)" +msgstr "ei voitu avata tiedostoa ”%s” kirjoittamista varten (%s)" + +#: awkgram.y:4112 +msgid "sending variable list to standard error" +msgstr "lähetetään muuttujaluettelo vakiovirheeseen" + +#: awkgram.y:4118 +#, c-format +msgid "%s: close failed (%s)" +msgstr "%s: sulkeminen epäonnistui (%s)" + +#: awkgram.y:4170 +msgid "shadow_funcs() called twice!" +msgstr "shadow_funcs() kutsuttu kahdesti!" + +#: awkgram.y:4176 +msgid "there were shadowed variables." +msgstr "siellä oli varjostettuja muuttujia." + +#: awkgram.y:4206 +#, c-format +msgid "function `%s': can't use function name as parameter name" +msgstr "funktio ”%s”: ei voi käyttää funktionimeä parametrinimenä" + +#: awkgram.y:4210 +#, c-format +msgid "function `%s': can't use special variable `%s' as a function parameter" +msgstr "funktio ”%s”: ei voi käyttää erikoismuuttujaa ”%s” funktioparametrina" + +#: awkgram.y:4226 +#, c-format +msgid "function name `%s' previously defined" +msgstr "funktionimi ”%s” on jo aikaisemmin määritelty" + +#: awkgram.y:4394 awkgram.y:4400 +#, c-format +msgid "function `%s' called but never defined" +msgstr "funktiota ”%s” kutsuttiin, mutta sitä ei ole koskaan määritelty" + +#: awkgram.y:4403 +#, c-format +msgid "function `%s' defined but never called directly" +msgstr "funktio ”%s” määriteltiin, mutta sitä ei ole koskaan kutsuttu suoraan" + +#: awkgram.y:4435 +#, c-format +msgid "regexp constant for parameter #%d yields boolean value" +msgstr "säännöllisen lausekkeen vakio parametrille #%d antaa boolean-arvon" + +#: awkgram.y:4544 +#, c-format +msgid "" +"function `%s' called with space between name and `(',\n" +"or used as a variable or an array" +msgstr "" +"funktio ”%s” kutsuttu välilyönnillä nimen ja ”(”-merkin\n" +"välillä, tai käytetty muuttujana tai taulukkona" + +#: awkgram.y:4791 eval.c:2056 +msgid "division by zero attempted" +msgstr "nollalla jakoa yritettiin" + +#: awkgram.y:4800 eval.c:2072 +#, c-format +msgid "division by zero attempted in `%%'" +msgstr "jakoa nollalla yritettiin operaattorissa ”%%”" + +# kohteena voi olla vakiotuloste tai joku muu +#: builtin.c:120 +#, c-format +msgid "%s to \"%s\" failed (%s)" +msgstr "%s kohteeseen ”%s” epäonnistui (%s)" + +#: builtin.c:121 +msgid "standard output" +msgstr "vakiotuloste" + +#: builtin.c:135 +msgid "exp: received non-numeric argument" +msgstr "exp: vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:141 +#, c-format +msgid "exp: argument %g is out of range" +msgstr "exp: argumentti %g on lukualueen ulkopuolella" + +#: builtin.c:200 +#, c-format +msgid "fflush: cannot flush: pipe `%s' opened for reading, not writing" +msgstr "" +"fflush: ei voi tyhjentää: putki ”%s” avattu lukemista varten, ei " +"kirjoittamiseen" + +#: builtin.c:203 +#, c-format +msgid "fflush: cannot flush: file `%s' opened for reading, not writing" +msgstr "" +"fflush: ei voi tyhjentää: tiedosto ”%s” avattu lukemista varten, ei " +"kirjoittamiseen" + +#: builtin.c:215 +#, c-format +msgid "fflush: `%s' is not an open file, pipe or co-process" +msgstr "fflush: ”%s” ei ole avoin tiedosto, putki tai apuprosessi" + +#: builtin.c:333 +msgid "index: received non-string first argument" +msgstr "index: ensimmäinen vastaanotettu argumentti ei ole merkkijono" + +#: builtin.c:335 +msgid "index: received non-string second argument" +msgstr "index: toinen vastaanotettu argumentti ei ole merkkijono" + +#: builtin.c:457 +msgid "int: received non-numeric argument" +msgstr "int: vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:493 +msgid "length: received array argument" +msgstr "length: vastaanotettu taulukkoargumentti" + +#: builtin.c:496 +msgid "`length(array)' is a gawk extension" +msgstr "”length(array)” on gawk-laajennus" + +#: builtin.c:504 +msgid "length: received non-string argument" +msgstr "length: vastaanotettu argumentti ei ole merkkijono" + +#: builtin.c:535 +msgid "log: received non-numeric argument" +msgstr "log: vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:538 +#, c-format +msgid "log: received negative argument %g" +msgstr "log: vastaanotettu negatiivinen argumentti %g" + +#: builtin.c:694 builtin.c:699 +msgid "fatal: must use `count$' on all formats or none" +msgstr "kohtalokas: on käytettävä ”count$” kaikilla muodoilla tai ei missään" + +#: builtin.c:762 +#, c-format +msgid "field width is ignored for `%%' specifier" +msgstr "kenttäleveys ohitetaan ”%%%%”-määritteelle" + +#: builtin.c:764 +#, c-format +msgid "precision is ignored for `%%' specifier" +msgstr "tarkkuus ohitetaan ”%%%%”-määritteelle" + +#: builtin.c:766 +#, c-format +msgid "field width and precision are ignored for `%%' specifier" +msgstr "kenttäleveys ja tarkkuus ohitetaan ”%%%%”-määritteelle" + +#: builtin.c:817 +msgid "fatal: `$' is not permitted in awk formats" +msgstr "kohtalokas: ”$”-argumentti ei ole sallittu awk-muodoissa" + +#: builtin.c:826 +msgid "fatal: arg count with `$' must be > 0" +msgstr "kohtalokas: argumenttilukumäärän argumentilla ”$” on oltava > 0" + +#: builtin.c:830 +#, c-format +msgid "fatal: arg count %ld greater than total number of supplied arguments" +msgstr "" +"kohtalokas: argumenttilukumäärä %ld on suurempi kuin toimitettujen " +"argumenttien lukumäärä" + +#: builtin.c:834 +msgid "fatal: `$' not permitted after period in format" +msgstr "kohtalokas: ”$”-argumentti ei ole sallittu pisteen jälkeen muodossa" + +#: builtin.c:850 +msgid "fatal: no `$' supplied for positional field width or precision" +msgstr "" +"kohtalokas: ei ”$”-argumenttia tarjottu sijantikenttäleveydelle tai " +"tarkkuudelle" + +#: builtin.c:921 +msgid "`l' is meaningless in awk formats; ignored" +msgstr "”l” on merkityksetön awk-muodoissa; ohitetaan" + +#: builtin.c:925 +msgid "fatal: `l' is not permitted in POSIX awk formats" +msgstr "kohtalokas: ”l” ei ole sallittu POSIX awk -muodoissa" + +#: builtin.c:938 +msgid "`L' is meaningless in awk formats; ignored" +msgstr "”L” on merkityksetön awk-muodoissa; ohitetaan" + +#: builtin.c:942 +msgid "fatal: `L' is not permitted in POSIX awk formats" +msgstr "kohtalokas: ”L” ei ole sallittu POSIX awk -muodoissa" + +#: builtin.c:955 +msgid "`h' is meaningless in awk formats; ignored" +msgstr "”h” on merkityksetön awk-muodoissa; ohitetaan" + +#: builtin.c:959 +msgid "fatal: `h' is not permitted in POSIX awk formats" +msgstr "kohtalokas: ”h” ei ole sallittu POSIX awk -muodoissa" + +#: builtin.c:1272 +#, c-format +msgid "[s]printf: value %g is out of range for `%%%c' format" +msgstr "[s]printf: arvo %g on lukualueen ulkopuolella ”%%%c”-muodolle" + +#: builtin.c:1332 +#, c-format +msgid "ignoring unknown format specifier character `%c': no argument converted" +msgstr "" +"ohitetaan tuntematon muotoargumenttimerkki ”%c”: ei muunnettu argumenttia" + +#: builtin.c:1337 +msgid "fatal: not enough arguments to satisfy format string" +msgstr "kohtalokas: ei kylliksi argumentteja muotomerkkijonon tyydyttämiseksi" + +#: builtin.c:1339 +msgid "^ ran out for this one" +msgstr "^ tällainen loppui kesken" + +#: builtin.c:1346 +msgid "[s]printf: format specifier does not have control letter" +msgstr "[s]printf: muotoargumentilla ei ole ohjauskirjainta" + +#: builtin.c:1349 +msgid "too many arguments supplied for format string" +msgstr "muotomerkkijonoon toimitettu liian monta argumenttia" + +#: builtin.c:1423 builtin.c:1434 +msgid "printf: no arguments" +msgstr "printf: ei argumentteja" + +#: builtin.c:1475 +msgid "sqrt: received non-numeric argument" +msgstr "sqrt: vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:1479 +#, c-format +msgid "sqrt: called with negative argument %g" +msgstr "sqrt: kutsuttu negatiivisella argumentilla %g" + +#: builtin.c:1503 +#, c-format +msgid "substr: length %g is not >= 1" +msgstr "substr: pituus %g ei ole >= 1" + +#: builtin.c:1505 +#, c-format +msgid "substr: length %g is not >= 0" +msgstr "substr: pituus %g ei ole >= 0" + +#: builtin.c:1512 +#, c-format +msgid "substr: non-integer length %g will be truncated" +msgstr "substr: typistetään pituus %g, joka ei ole kokonaisluku" + +#: builtin.c:1517 +#, c-format +msgid "substr: length %g too big for string indexing, truncating to %g" +msgstr "" +"substr: pituus %g liian suuri merkkijononindeksointiin, typistetään arvoon %g" + +#: builtin.c:1529 +#, c-format +msgid "substr: start index %g is invalid, using 1" +msgstr "substr: aloitusindeksi %g on virheellinen, käytetään 1:tä" + +#: builtin.c:1534 +#, c-format +msgid "substr: non-integer start index %g will be truncated" +msgstr "substr: typistetään aloitusindeksi %g, joka ei ole kokonaisluku" + +#: builtin.c:1559 +msgid "substr: source string is zero length" +msgstr "substr: lähdemerkkijono on nollapituinen" + +#: builtin.c:1575 +#, c-format +msgid "substr: start index %g is past end of string" +msgstr "substr: aloitusindeksi %g on merkkijonon lopun jälkeen" + +#: builtin.c:1583 +#, c-format +msgid "" +"substr: length %g at start index %g exceeds length of first argument (%lu)" +msgstr "" +"substr: pituus %g alkuindeksissä %g ylittää ensimmäisen argumentin pituuden " +"(%lu)" + +#: builtin.c:1657 +msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" +msgstr "" +"strftime: muotoarvolla kohteessa PROCINFO[\"strftime\"] on numerotyyppi" + +#: builtin.c:1680 +msgid "strftime: received non-numeric second argument" +msgstr "strftime: toinen vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:1683 +msgid "strftime: second argument less than 0 or too big for time_t" +msgstr "" +"strftime: toinen argumentti on pienempi kuin 0 tai liian suuri time_t-" +"rakenteeseen" + +#: builtin.c:1690 +msgid "strftime: received non-string first argument" +msgstr "strftime: ensimmäinen vastaanotettu argumentti ei ole merkkijono" + +#: builtin.c:1696 +msgid "strftime: received empty format string" +msgstr "strftime: vastaanotettu tyhjä muotomerkkijono" + +#: builtin.c:1762 +msgid "mktime: received non-string argument" +msgstr "mktime: vastaanotettu argumentti ei ole merkkijono" + +#: builtin.c:1779 +msgid "mktime: at least one of the values is out of the default range" +msgstr "mktime: vähintään yksi arvoista on oletuslukualueen ulkopuolella" + +#: builtin.c:1814 +msgid "'system' function not allowed in sandbox mode" +msgstr "”system”-funktio ei ole sallittu hiekkalaatikkotilassa" + +#: builtin.c:1819 +msgid "system: received non-string argument" +msgstr "system: vastaanotettu argumentti ei ole merkkijono" + +#: builtin.c:1874 eval.c:1159 eval.c:1790 eval.c:1803 +#, c-format +msgid "reference to uninitialized variable `%s'" +msgstr "viite alustamattomaan muuttujaan ”%s”" + +#: builtin.c:1941 +#, c-format +msgid "reference to uninitialized field `$%d'" +msgstr "viite alustamattomaan kenttään ”$%d”" + +#: builtin.c:2028 +msgid "tolower: received non-string argument" +msgstr "tolower: vastaanotettu argumentti ei ole merkkijono" + +#: builtin.c:2062 +msgid "toupper: received non-string argument" +msgstr "toupper: vastaanotettu argumentti ei ole merkkijono" + +#: builtin.c:2098 +msgid "atan2: received non-numeric first argument" +msgstr "atan2: ensimmäinen vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:2100 +msgid "atan2: received non-numeric second argument" +msgstr "atan2: toinen vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:2119 +msgid "sin: received non-numeric argument" +msgstr "sin: vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:2135 +msgid "cos: received non-numeric argument" +msgstr "cos: vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:2188 +msgid "srand: received non-numeric argument" +msgstr "srand: vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:2219 +msgid "match: third argument is not an array" +msgstr "match: kolmas argumentti ei ole taulukko" + +#: builtin.c:2483 +msgid "gensub: third argument of 0 treated as 1" +msgstr "gensub: 0-arvoinen kolmas argumentti käsitellään kuin 1" + +#: builtin.c:2776 +msgid "lshift: received non-numeric first argument" +msgstr "lshift: ensimmäinen vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:2778 +msgid "lshift: received non-numeric second argument" +msgstr "lshift: toinen vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:2784 +#, c-format +msgid "lshift(%lf, %lf): negative values will give strange results" +msgstr "lshift(%lf, %lf): negatiiviset arvot antavat outoja tuloksia" + +#: builtin.c:2786 +#, c-format +msgid "lshift(%lf, %lf): fractional values will be truncated" +msgstr "lshift(%lf, %lf): jaosarvot typistetään" + +#: builtin.c:2788 +#, c-format +msgid "lshift(%lf, %lf): too large shift value will give strange results" +msgstr "lshift(%lf, %lf): liian suuri siirrosarvo antaa outoja tuloksia" + +#: builtin.c:2813 +msgid "rshift: received non-numeric first argument" +msgstr "rshift: ensimmäinen vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:2815 +msgid "rshift: received non-numeric second argument" +msgstr "rshift: toinen vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:2821 +#, c-format +msgid "rshift(%lf, %lf): negative values will give strange results" +msgstr "rshift(%lf, %lf): negatiiviset arvot antavat outoja tuloksia" + +#: builtin.c:2823 +#, c-format +msgid "rshift(%lf, %lf): fractional values will be truncated" +msgstr "rshift(%lf, %lf): jaosarvot typistetään" + +#: builtin.c:2825 +#, c-format +msgid "rshift(%lf, %lf): too large shift value will give strange results" +msgstr "rshift(%lf, %lf): liian suuri siirrosarvo antaa outoja tuloksia" + +#: builtin.c:2850 +msgid "and: received non-numeric first argument" +msgstr "and: ensimmäinen vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:2852 +msgid "and: received non-numeric second argument" +msgstr "and: toinen vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:2858 +#, c-format +msgid "and(%lf, %lf): negative values will give strange results" +msgstr "and(%lf, %lf): negatiiviset arvot antavat outoja tuloksia" + +#: builtin.c:2860 +#, c-format +msgid "and(%lf, %lf): fractional values will be truncated" +msgstr "and(%lf, %lf): jaosarvot typistetään" + +#: builtin.c:2885 +msgid "or: received non-numeric first argument" +msgstr "or: ensimmäinen vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:2887 +msgid "or: received non-numeric second argument" +msgstr "or: toinen vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:2893 +#, c-format +msgid "or(%lf, %lf): negative values will give strange results" +msgstr "or(%lf, %lf): negatiiviset arvot antavat outoja tuloksia" + +#: builtin.c:2895 +#, c-format +msgid "or(%lf, %lf): fractional values will be truncated" +msgstr "or(%lf, %lf): jaosarvot typistetään" + +#: builtin.c:2923 +msgid "xor: received non-numeric first argument" +msgstr "xor: ensimmäinen vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:2925 +msgid "xor: received non-numeric second argument" +msgstr "xor: toinen vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:2931 +#, c-format +msgid "xor(%lf, %lf): negative values will give strange results" +msgstr "xor(%lf, %lf): negatiiviset arvot antavat outoja tuloksia" + +#: builtin.c:2933 +#, c-format +msgid "xor(%lf, %lf): fractional values will be truncated" +msgstr "xor(%lf, %lf): jaosarvot typistetään" + +#: builtin.c:2957 builtin.c:2963 +msgid "compl: received non-numeric argument" +msgstr "compl: vastaanotettu argumentti ei ole numeerinen" + +#: builtin.c:2965 +#, c-format +msgid "compl(%lf): negative value will give strange results" +msgstr "compl(%lf): negatiiviset arvot antavat outoja tuloksia" + +#: builtin.c:2967 +#, c-format +msgid "compl(%lf): fractional value will be truncated" +msgstr "compl(%lf): jaosarvo typistetään" + +#: builtin.c:3136 +#, c-format +msgid "dcgettext: `%s' is not a valid locale category" +msgstr "dcgettext: ”%s” ei ole kelvollinen paikallinen kategoria" + +#: eval.c:412 +#, c-format +msgid "unknown nodetype %d" +msgstr "tuntematon solmutyyppi %d" + +#: eval.c:423 eval.c:437 +#, c-format +msgid "unknown opcode %d" +msgstr "tuntematon käskykoodi %d" + +#: eval.c:434 +#, c-format +msgid "opcode %s not an operator or keyword" +msgstr "käskykoodi %s ei ole operaattori tai avainsana" + +#: eval.c:488 +msgid "buffer overflow in genflags2str" +msgstr "puskurin ylivuoto funktiossa genflags2str" + +#: eval.c:698 +#, c-format +msgid "" +"\n" +"\t# Function Call Stack:\n" +"\n" +msgstr "" +"\n" +"\t# Funktiokutsupino:\n" +"\n" + +#: eval.c:725 +msgid "`IGNORECASE' is a gawk extension" +msgstr "”IGNORECASE” on gawk-laajennus" + +#: eval.c:754 +msgid "`BINMODE' is a gawk extension" +msgstr "”BINMODE” on gawk-laajennus" + +#: eval.c:812 +#, c-format +msgid "BINMODE value `%s' is invalid, treated as 3" +msgstr "BINMODE-arvo ”%s” on virheellinen, käsiteltiin arvona 3" + +#: eval.c:902 +#, c-format +msgid "bad `%sFMT' specification `%s'" +msgstr "väärä ”%sFMT”-määritys ”%s”" + +#: eval.c:980 +msgid "turning off `--lint' due to assignment to `LINT'" +msgstr "käännetään pois ”--lint”-valitsin ”LINT”-sijoituksen vuoksi" + +#: eval.c:1127 eval.c:1777 +#, c-format +msgid "can't use function name `%s' as variable or array" +msgstr "funktionimeä ”%s” ei voi käyttää muuttujana tai taulukkona" + +#: eval.c:1158 eval.c:1789 eval.c:1802 +#, c-format +msgid "reference to uninitialized argument `%s'" +msgstr "viite alustamattomaan argumenttiin ”%s”" + +#: eval.c:1177 +msgid "attempt to field reference from non-numeric value" +msgstr "yritettiin kenttäviitettä arvosta, joka ei ole numeerinen" + +#: eval.c:1179 +msgid "attempt to field reference from null string" +msgstr "yritettiin kenttäviitettä null-merkkijonosta" + +#: eval.c:1185 +#, c-format +msgid "attempt to access field %ld" +msgstr "yritettiin saantia kenttään %ld" + +#: eval.c:1194 +#, c-format +msgid "reference to uninitialized field `$%ld'" +msgstr "viite alustamattomaan kenttään ”$%ld”" + +#: eval.c:1256 +#, c-format +msgid "function `%s' called with more arguments than declared" +msgstr "funktio ”%s” kutsuttiin useammalla argumentilla kuin esiteltiin" + +#: eval.c:1437 +#, c-format +msgid "unwind_stack: unexpected type `%s'" +msgstr "unwind_stack: odottamaton tyyppi ”%s”" + +#: eval.c:1532 +msgid "division by zero attempted in `/='" +msgstr "jakoa nollalla yritettiin operaatiossa ”/=”" + +#: eval.c:1539 +#, c-format +msgid "division by zero attempted in `%%='" +msgstr "jakoa nollalla yritettiin operaatiossa ”%%=”" + +#: eval.c:1876 eval.c:2122 +#, c-format +msgid "attempt to use array `%s[\"%.*s\"]' in a scalar context" +msgstr "yritettiin käyttää taulukkoa ”%s[\"%.*s\"]” skalaarikontekstissa" + +#: eval.c:1907 +msgid "assignment used in conditional context" +msgstr "sijoitusta käytetty ehdollisessa kontekstissa" + +#: eval.c:1911 +msgid "statement has no effect" +msgstr "käskyllä ei ole vaikutusta" + +#: eval.c:2343 +#, c-format +msgid "for loop: array `%s' changed size from %ld to %ld during loop execution" +msgstr "" +"for-silmukka: taulukon ”%s” koko muuttui arvosta %ld arvoon %ld silmukan " +"suorituksen aikana" + +#: eval.c:2458 +#, c-format +msgid "function called indirectly through `%s' does not exist" +msgstr "kohteen ”%s” kautta epäsuorasti kutsuttu funktio ei ole olemassa" + +#: eval.c:2470 +#, c-format +msgid "function `%s' not defined" +msgstr "funktio ”%s” ei ole määritelty" + +#: eval.c:2511 +#, c-format +msgid "non-redirected `getline' invalid inside `%s' rule" +msgstr "edelleenohjaamaton ”getline” virheellinen ”%s”-säännön sisällä" + +#: eval.c:2600 +#, c-format +msgid "error reading input file `%s': %s" +msgstr "virhe luettaessa syötetiedostoa ”%s”: %s" + +#: eval.c:2614 +#, c-format +msgid "`nextfile' cannot be called from a `%s' rule" +msgstr "”nextfile” ei voida kutsua ”%s”-säännöstä" + +#: eval.c:2661 +msgid "`exit' cannot be called in the current context" +msgstr "”exit” ei voida kutsua nykyisessä asiayhteydessä" + +#: eval.c:2700 +#, c-format +msgid "`next' cannot be called from a `%s' rule" +msgstr "”next” ei voida kutsua ”%s”-säännöstä" + +#: eval.c:2766 +#, c-format +msgid "Sorry, don't know how to interpret `%s'" +msgstr "Ei osata tulkita kohdetta ”%s”" + +#: ext.c:54 +msgid "extensions are not allowed in sandbox mode" +msgstr "laajennuksia ei sallita hiekkalaatikkotilassa" + +#: ext.c:60 ext.c:65 +msgid "`extension' is a gawk extension" +msgstr "”extension” on gawk-laajennus" + +#: ext.c:75 +#, c-format +msgid "fatal: extension: cannot open `%s' (%s)\n" +msgstr "tuhoisa: extension: ei voi avata solmua ”%s” (%s)\n" + +#: ext.c:84 +#, c-format +msgid "" +"fatal: extension: library `%s': does not define " +"`plugin_is_GPL_compatible' (%s)\n" +msgstr "" +"tuhoisa: extension: kirjasto ”%s”: ei määrittele " +"”plugin_is_GPL_compatible” (%s)\n" + +#: ext.c:93 +#, c-format +msgid "fatal: extension: library `%s': cannot call function `%s' (%s)\n" +msgstr "tuhoisa: extension: kirjasto ”%s”: ei voi kutsua funktiota ”%s” (%s)\n" + +#: ext.c:127 +msgid "extension: missing function name" +msgstr "extension: puuttuva funktionimi" + +#: ext.c:132 +#, c-format +msgid "extension: illegal character `%c' in function name `%s'" +msgstr "extension: virheellinen merkki ”%c” funktionimessä ”%s”" + +#: ext.c:141 +#, c-format +msgid "extension: can't redefine function `%s'" +msgstr "extension: ei voi määritellä uudelleen funktiota ”%s”" + +#: ext.c:145 +#, c-format +msgid "extension: function `%s' already defined" +msgstr "extension: funktio ”%s” on jo määritelty" + +#: ext.c:150 +#, c-format +msgid "extension: function name `%s' previously defined" +msgstr "extension: funktionimi ”%s” on määritelty jo aiemmin" + +#: ext.c:152 +#, c-format +msgid "extension: can't use gawk built-in `%s' as function name" +msgstr "" +"extension: ei voi käyttää gawk-ohjelman sisäistä muuttujanimeä ”%s” " +"funktionimenä" + +#: ext.c:156 +#, c-format +msgid "make_builtin: negative argument count for function `%s'" +msgstr "make_builtin: negatiivinen argumenttilukumäärä funktiolle ”%s”" + +#: ext.c:259 +#, c-format +msgid "function `%s' defined to take no more than %d argument(s)" +msgstr "funktio ”%s” on määritelty ottamaan enemmän kuin %d argumenttia" + +#: ext.c:262 +#, c-format +msgid "function `%s': missing argument #%d" +msgstr "function ”%s”: puuttuva argumentti #%d" + +#: ext.c:279 +#, c-format +msgid "function `%s': argument #%d: attempt to use scalar as an array" +msgstr "funktio ”%s”: argumentti #%d: yritettiin käyttää skalaaria taulukkona" + +#: ext.c:283 +#, c-format +msgid "function `%s': argument #%d: attempt to use array as a scalar" +msgstr "funktio ”%s”: argumentti #%d: yritettiin käyttää taulukkoa skalaarina" + +#: ext.c:296 +msgid "Operation Not Supported" +msgstr "Toimintoa ei tueta" + +#: field.c:328 +msgid "NF set to negative value" +msgstr "NF asetettu negatiiviseen arvoon" + +#: field.c:951 field.c:958 field.c:962 +msgid "split: fourth argument is a gawk extension" +msgstr "split: neljäs argumentti on gawk-laajennus" + +#: field.c:955 +msgid "split: fourth argument is not an array" +msgstr "split: neljäs argumentti ei ole taulukko" + +#: field.c:969 +msgid "split: second argument is not an array" +msgstr "split: toinen argumentti ei ole taulukko" + +#: field.c:973 +msgid "split: cannot use the same array for second and fourth args" +msgstr "" +"split: ei voida käyttää samaa taulukkoa toiselle ja neljännelle argumentille" + +#: field.c:978 +msgid "split: cannot use a subarray of second arg for fourth arg" +msgstr "" +"split: ei voida käyttää toisen argumentin alitaulukkoa neljännelle " +"argumentille" + +#: field.c:981 +msgid "split: cannot use a subarray of fourth arg for second arg" +msgstr "" +"split: ei voida käyttää neljännen argumentin alitaulukkoa toiselle " +"argumentille" + +#: field.c:1010 +msgid "split: null string for third arg is a gawk extension" +msgstr "split: null-merkkijono kolmantena argumenttina on gawk-laajennus" + +#: field.c:1050 +msgid "patsplit: fourth argument is not an array" +msgstr "patsplit: neljäs argumentti ei ole taulukko" + +#: field.c:1055 +msgid "patsplit: second argument is not an array" +msgstr "patsplit: toinen argumentti ei ole taulukko" + +#: field.c:1061 +msgid "patsplit: third argument must be non-null" +msgstr "patsplit: kolmas argumentti ei ole taulukko" + +#: field.c:1065 +msgid "patsplit: cannot use the same array for second and fourth args" +msgstr "" +"patsplit: ei voida käyttää samaa taulukkoa toiselle ja neljännelle " +"argumentille" + +#: field.c:1070 +msgid "patsplit: cannot use a subarray of second arg for fourth arg" +msgstr "" +"patsplit: ei voida käyttää toisen argumentin alitaulukkkoa neljännelle " +"argumentille" + +#: field.c:1073 +msgid "patsplit: cannot use a subarray of fourth arg for second arg" +msgstr "" +"patsplit: ei voida käyttää neljännen argumentin alitaulukkoa toiselle " +"argumentille" + +#: field.c:1110 +msgid "`FIELDWIDTHS' is a gawk extension" +msgstr "”FIELDWIDTHS” on gawk-laajennus" + +#: field.c:1173 +#, c-format +msgid "invalid FIELDWIDTHS value, near `%s'" +msgstr "virheellinen FIELDWIDTHS-arvo, lähellä ”%s”" + +#: field.c:1246 +msgid "null string for `FS' is a gawk extension" +msgstr "null-merkkijono ”FS”-kenttäerotinmuuttujalle on gawk-laajennus" + +#: field.c:1250 +msgid "old awk does not support regexps as value of `FS'" +msgstr "vanha awk ei tue regexp-arvoja ”FS”-kenttäerotinmuuttujana" + +#: field.c:1369 +msgid "`FPAT' is a gawk extension" +msgstr "”FPAT” on gawk-laajennus" + +#: getopt.c:604 getopt.c:633 +#, fuzzy, c-format +msgid "%s: option '%s' is ambiguous; possibilities:" +msgstr "%s: valitsin ’%s’ ei ole yksiselitteinen\n" + +#: getopt.c:679 getopt.c:683 +#, c-format +msgid "%s: option '--%s' doesn't allow an argument\n" +msgstr "%s: valitsin ’--%s’ ei salli argumenttia\n" + +#: getopt.c:692 getopt.c:697 +#, c-format +msgid "%s: option '%c%s' doesn't allow an argument\n" +msgstr "%s: valitsin ’%c%s’ ei salli argumenttia\n" + +#: getopt.c:740 getopt.c:759 +#, c-format +msgid "%s: option '--%s' requires an argument\n" +msgstr "%s: valitsin ’--%s’ vaatii argumentin\n" + +#: getopt.c:797 getopt.c:800 +#, c-format +msgid "%s: unrecognized option '--%s'\n" +msgstr "%s: tunnistamaton valitsin ’--%s’\n" + +#: getopt.c:808 getopt.c:811 +#, c-format +msgid "%s: unrecognized option '%c%s'\n" +msgstr "%s: tunnistamaton valitsin ’%c%s’\n" + +#: getopt.c:860 getopt.c:863 +#, c-format +msgid "%s: invalid option -- '%c'\n" +msgstr "%s: virheellinen valitsin -- ’%c’\n" + +#: getopt.c:916 getopt.c:933 getopt.c:1143 getopt.c:1161 +#, c-format +msgid "%s: option requires an argument -- '%c'\n" +msgstr "%s: valitsin vaatii argumentin -- ’%c’\n" + +#: getopt.c:989 getopt.c:1005 +#, c-format +msgid "%s: option '-W %s' is ambiguous\n" +msgstr "%s: valitsin ’-W %s’ ei ole yksiselitteinen\n" + +#: getopt.c:1029 getopt.c:1047 +#, c-format +msgid "%s: option '-W %s' doesn't allow an argument\n" +msgstr "%s: valitsin ’-W %s’ ei salli argumenttia\n" + +#: getopt.c:1068 getopt.c:1086 +#, c-format +msgid "%s: option '-W %s' requires an argument\n" +msgstr "%s: valitsin ’-W %s’ vaatii argumentin\n" + +#: io.c:280 +#, c-format +msgid "command line argument `%s' is a directory: skipped" +msgstr "komentoriviargumentti ”%s” on hakemisto: ohitettiin" + +#: io.c:283 io.c:385 +#, c-format +msgid "cannot open file `%s' for reading (%s)" +msgstr "ei voi avata tiedostoa ”%s” lukemista varten (%s)" + +#: io.c:501 +#, c-format +msgid "close of fd %d (`%s') failed (%s)" +msgstr "tiedostomäärittelijän %d (”%s”) sulkeminen epäonnistui (%s)" + +#: io.c:578 +msgid "redirection not allowed in sandbox mode" +msgstr "edelleenohjaus ei ole sallittua hiekkalaatikkotilassa" + +#: io.c:612 +#, c-format +msgid "expression in `%s' redirection only has numeric value" +msgstr "lausekkeella ”%s”-uudellenohjauksessa on vain numeerinen arvo" + +#: io.c:618 +#, c-format +msgid "expression for `%s' redirection has null string value" +msgstr "lausekkeella ”%s”-uudelleenohjauksessa on null-merkkijonoarvo" + +#: io.c:623 +#, c-format +msgid "filename `%s' for `%s' redirection may be result of logical expression" +msgstr "" +"tiedostonimi ”%s” ”%s”-uudelleenohjaukselle saattaa olla loogisen lausekkeen " +"tulos" + +#: io.c:666 +#, c-format +msgid "unnecessary mixing of `>' and `>>' for file `%.*s'" +msgstr "turha merkkien ”>” ja ”>>” sekoittaminen tiedostolle ”%.*s”" + +#: io.c:719 +#, c-format +msgid "can't open pipe `%s' for output (%s)" +msgstr "ei voi avata putkea ”%s” tulosteelle (%s)" + +#: io.c:729 +#, c-format +msgid "can't open pipe `%s' for input (%s)" +msgstr "ei voi avata putkea ”%s” syötteelle (%s)" + +#: io.c:752 +#, c-format +msgid "can't open two way pipe `%s' for input/output (%s)" +msgstr "ei voi avata kaksisuuntaista putkea ”%s” syötteelle/tulosteelle (%s)" + +#: io.c:834 +#, c-format +msgid "can't redirect from `%s' (%s)" +msgstr "ei voi uudelleenohjata putkesta ”%s” (%s)" + +#: io.c:837 +#, c-format +msgid "can't redirect to `%s' (%s)" +msgstr "ei voi uudelleenohjata putkeen ”%s” (%s)" + +#: io.c:888 +msgid "" +"reached system limit for open files: starting to multiplex file descriptors" +msgstr "" +"saavutettiin avoimien tiedostojen järjestelmäraja: aloitetaan " +"tiedostomäärittelijöiden lomittaminen" + +#: io.c:904 +#, c-format +msgid "close of `%s' failed (%s)." +msgstr "uudelleenohjauksen ”%s” sulkeminen epäonnistui (%s)." + +#: io.c:912 +msgid "too many pipes or input files open" +msgstr "avoinna liian monta putkea tai syötetiedostoa" + +#: io.c:934 +msgid "close: second argument must be `to' or `from'" +msgstr "close: toisen argumentin on oltava ”to” tai ”from”" + +#: io.c:951 +#, c-format +msgid "close: `%.*s' is not an open file, pipe or co-process" +msgstr "close: ”%.*s” ei ole avoin tiedosto, putki tai apuprosessi" + +#: io.c:956 +msgid "close of redirection that was never opened" +msgstr "suljettiin uudelleenohjaus, jota ei avattu koskaan" + +#: io.c:1053 +#, c-format +msgid "close: redirection `%s' not opened with `|&', second argument ignored" +msgstr "" +"close: uudelleenohjaus ”%s” ei ole avattu operaattoreilla ”|&”, toinen " +"argumentti ohitettu" + +#: io.c:1069 +#, c-format +msgid "failure status (%d) on pipe close of `%s' (%s)" +msgstr "virhetila (%d) putken ”%s” sulkemisessa (%s)" + +#: io.c:1072 +#, c-format +msgid "failure status (%d) on file close of `%s' (%s)" +msgstr "virhetila (%d) tiedoston ”%s” sulkemisessa (%s)" + +#: io.c:1092 +#, c-format +msgid "no explicit close of socket `%s' provided" +msgstr "pistokkeen ”%s” eksplisiittistä sulkemista ei tarjota" + +#: io.c:1095 +#, c-format +msgid "no explicit close of co-process `%s' provided" +msgstr "apuprosessin ”%s” eksplisiittistä sulkemista ei tarjota" + +#: io.c:1098 +#, c-format +msgid "no explicit close of pipe `%s' provided" +msgstr "putken ”%s” eksplisiittistä sulkemista ei tarjota" + +#: io.c:1101 +#, c-format +msgid "no explicit close of file `%s' provided" +msgstr "tiedoston ”%s” eksplisiittistä sulkemista ei tarjota" + +#: io.c:1129 io.c:1184 main.c:794 main.c:831 +#, c-format +msgid "error writing standard output (%s)" +msgstr "virhe kirjoitettaessa vakiotulosteeseen (%s)" + +#: io.c:1133 io.c:1189 +#, c-format +msgid "error writing standard error (%s)" +msgstr "virhe kirjoitettaessa vakiovirheeseen (%s)" + +#: io.c:1141 +#, c-format +msgid "pipe flush of `%s' failed (%s)." +msgstr "uudelleenohjauksen ”%s” putken tyhjennys epäonnistui (%s)." + +#: io.c:1144 +#, c-format +msgid "co-process flush of pipe to `%s' failed (%s)." +msgstr "putken apuprosessityhjennys uudelleenohjaukseen ”%s” epäonnistui (%s)." + +#: io.c:1147 +#, c-format +msgid "file flush of `%s' failed (%s)." +msgstr "uudelleenohjauksen ”%s” tiedostontyhjennys epäonnistui (%s)." + +#: io.c:1262 +#, c-format +msgid "local port %s invalid in `/inet'" +msgstr "paikallinen portti %s virheellinen pistokkeessa ”/inet”" + +#: io.c:1279 +#, c-format +msgid "remote host and port information (%s, %s) invalid" +msgstr "etäkone- ja porttitiedot (%s, %s) ovat virheellisiä" + +#: io.c:1431 +#, c-format +msgid "no (known) protocol supplied in special filename `%s'" +msgstr "ei (tunnettua) yhteyskäytäntöä tarjottu erikoistiedostonimessä ”%s”" + +#: io.c:1445 +#, c-format +msgid "special file name `%s' is incomplete" +msgstr "erikoistiedostonimi ”%s” on vaillinainen" + +#: io.c:1462 +msgid "must supply a remote hostname to `/inet'" +msgstr "on tarjottava etäkoneen nimi pistokkeeseen ”/inet”" + +#: io.c:1480 +msgid "must supply a remote port to `/inet'" +msgstr "on tarjottava etäportti pistokkeeseen ”/inet”" + +#: io.c:1526 +msgid "TCP/IP communications are not supported" +msgstr "TCP/IP-viestintää ei tueta" + +#: io.c:1693 +#, c-format +msgid "could not open `%s', mode `%s'" +msgstr "ei voitu avata laitetta ”%s”, tila ”%s”" + +#: io.c:1747 +#, c-format +msgid "close of master pty failed (%s)" +msgstr "”master pty”-sulkeminen epäonnistui (%s)" + +#: io.c:1749 io.c:1917 io.c:2074 +#, c-format +msgid "close of stdout in child failed (%s)" +msgstr "vakiotulosteen sulkeminen lapsiprosessissa epäonnistui (%s)" + +#: io.c:1752 +#, c-format +msgid "moving slave pty to stdout in child failed (dup: %s)" +msgstr "" +"”slave pty”:n siirtäminen vakiotulosteeseen lapsiprosessissa epäonnistui " +"(dup: %s)" + +#: io.c:1754 io.c:1922 +#, c-format +msgid "close of stdin in child failed (%s)" +msgstr "vakiosyötteen sulkeminen lapsiprosessissa epäonnistui (%s)" + +#: io.c:1757 +#, c-format +msgid "moving slave pty to stdin in child failed (dup: %s)" +msgstr "" +"”slave pty”:n siirtäminen vakiosyötteeseen lapsiprosessissa epäonnistui " +"(dup: %s)" + +#: io.c:1759 io.c:1780 +#, c-format +msgid "close of slave pty failed (%s)" +msgstr "”slave pty”:n sulkeminen epäonnistui (%s)" + +#: io.c:1858 io.c:1920 io.c:2052 io.c:2077 +#, c-format +msgid "moving pipe to stdout in child failed (dup: %s)" +msgstr "" +"putken siirtäminen vakiotulosteeseen lapsiprosessissa epäonnistui (dup: %s)" + +#: io.c:1865 io.c:1925 +#, c-format +msgid "moving pipe to stdin in child failed (dup: %s)" +msgstr "" +"putken siirtäminen vakiosyötteeseen lapsiprosessissa epäonnistui (dup: %s)" + +#: io.c:1885 io.c:2067 +msgid "restoring stdout in parent process failed\n" +msgstr "vakiotulosteen palauttaminen äitiprosessissa epäonnistui\n" + +#: io.c:1893 +msgid "restoring stdin in parent process failed\n" +msgstr "vakiosyötön palauttaminen äitiprosessissa epäonnistui\n" + +#: io.c:1928 io.c:2079 io.c:2093 +#, c-format +msgid "close of pipe failed (%s)" +msgstr "putken sulkeminen epäonnistui (%s)" + +#: io.c:1973 +msgid "`|&' not supported" +msgstr "”|&” ei tueta" + +#: io.c:2039 +#, c-format +msgid "cannot open pipe `%s' (%s)" +msgstr "ei voi avata putkea ”%s” (%s)" + +#: io.c:2087 +#, c-format +msgid "cannot create child process for `%s' (fork: %s)" +msgstr "ei voida luoda lapsiprosessia komennolle ”%s” (fork: %s)" + +#: io.c:2520 +#, c-format +msgid "data file `%s' is empty" +msgstr "data-tiedosto ”%s” on tyhjä" + +#: io.c:2561 io.c:2569 +msgid "could not allocate more input memory" +msgstr "ei voitu varata lisää syötemuistia" + +#: io.c:3127 +msgid "multicharacter value of `RS' is a gawk extension" +msgstr "”RS”-monimerkkiarvo on gawk-laajennus" + +#: io.c:3232 +msgid "IPv6 communication is not supported" +msgstr "IPv6-viestintää ei tueta" + +#: main.c:366 +msgid "`-m[fr]' option irrelevant in gawk" +msgstr "”-m[fr]”-valitsin asiaanliittymätön gawk:ssa" + +#: main.c:368 +msgid "-m option usage: `-m[fr] nnn'" +msgstr "-m valitsinkäyttö: ”-m[fr] nnn”" + +#: main.c:391 +msgid "empty argument to `-e/--source' ignored" +msgstr "tyhjä argumentti valitsimelle ”-e/--source” ohitetaan" + +#: main.c:462 +#, c-format +msgid "%s: option `-W %s' unrecognized, ignored\n" +msgstr "%s: valitsin ”-W %s” on tunnistamaton, ohitetaan\n" + +#: main.c:515 +#, c-format +msgid "%s: option requires an argument -- %c\n" +msgstr "%s: valitsin vaatii argumentin -- %c\n" + +#: main.c:536 +msgid "environment variable `POSIXLY_CORRECT' set: turning on `--posix'" +msgstr "" +"ympäristömuuttuja ”POSIXLY_CORRECT” asetettu: käännetään päälle valitsin ”--" +"posix”" + +#: main.c:542 +msgid "`--posix' overrides `--traditional'" +msgstr "valitsin ”--posix” korvaa valitsimen ”--traditional”" + +#: main.c:553 +msgid "`--posix'/`--traditional' overrides `--non-decimal-data'" +msgstr "" +"valitsin ”--posix” tai ”--traditional” korvaa valitsimen ”--non-decimal-data”" + +#: main.c:557 +#, c-format +msgid "running %s setuid root may be a security problem" +msgstr "suorittaminen ”%s setuid root”-käyttäjänä saattaa olla turvapulma" + +#: main.c:562 +msgid "`--posix' overrides `--binary'" +msgstr "valitsin ”--posix” korvaa valitsimen ”--binary”" + +#: main.c:613 +#, c-format +msgid "can't set binary mode on stdin (%s)" +msgstr "ei voi asettaa binaaritilaa vakiosyötteessä (%s)" + +#: main.c:616 +#, c-format +msgid "can't set binary mode on stdout (%s)" +msgstr "ei voi asettaa binaaritilaa vakiotulosteessa (%s)" + +#: main.c:618 +#, c-format +msgid "can't set binary mode on stderr (%s)" +msgstr "ei voi asettaa binaaritilaa vakiovirheessä (%s)" + +#: main.c:657 +msgid "no program text at all!" +msgstr "ei ohjelmatekstiä ollenkaan!" + +#: main.c:734 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] -f progfile [--] file ...\n" +msgstr "" +"Käyttö: %s [POSIX- tai GNU-tyyliset valitsimet] -f ohjelmatiedosto [--] " +"tiedosto ...\n" + +#: main.c:736 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] [--] %cprogram%c file ...\n" +msgstr "" +"Käyttö: %s [POSIX- tai GNU-tyyliset valitsimet] [--] %cohjelma%c " +"tiedosto ...\n" + +#: main.c:741 +msgid "POSIX options:\t\tGNU long options: (standard)\n" +msgstr "POSIX-valitsimet:\t\tGNU-pitkät valitsimet: (vakio)\n" + +#: main.c:742 +msgid "\t-f progfile\t\t--file=progfile\n" +msgstr "\t-f ohjelmatiedosto\t\t--file=ohjelmatiedosto\n" + +#: main.c:743 +msgid "\t-F fs\t\t\t--field-separator=fs\n" +msgstr "\t-F fs\t\t\t--field-separator=fs\n" + +#: main.c:744 +msgid "\t-v var=val\t\t--assign=var=val\n" +msgstr "\t-v var=arvo\t\t--assign=muuttuja=arvo\n" + +#: main.c:745 +msgid "Short options:\t\tGNU long options: (extensions)\n" +msgstr "Lyhyet valitsimet:\t\tGNU-pitkät valitsimet: (laajennukset)\n" + +#: main.c:746 +msgid "\t-b\t\t\t--characters-as-bytes\n" +msgstr "\t-b\t\t\t--characters-as-bytes\n" + +#: main.c:747 +msgid "\t-c\t\t\t--traditional\n" +msgstr "\t-c\t\t\t--traditional\n" + +#: main.c:748 +msgid "\t-C\t\t\t--copyright\n" +msgstr "\t-C\t\t\t--copyright\n" + +#: main.c:749 +msgid "\t-d[file]\t\t--dump-variables[=file]\n" +msgstr "\t-d[tiedosto]\t\t--dump-variables[=tiedosto]\n" + +#: main.c:750 +msgid "\t-e 'program-text'\t--source='program-text'\n" +msgstr "\t-e 'program-text'\t--source='program-text'\n" + +#: main.c:751 +msgid "\t-E file\t\t\t--exec=file\n" +msgstr "\t-E file\t\t\t--exec=tiedosto\n" + +#: main.c:752 +msgid "\t-g\t\t\t--gen-pot\n" +msgstr "\t-g\t\t\t--gen-po\n" + +#: main.c:753 +msgid "\t-h\t\t\t--help\n" +msgstr "\t-h\t\t\t--help\n" + +#: main.c:754 +msgid "\t-L [fatal]\t\t--lint[=fatal]\n" +msgstr "\t-L [fatal]\t\t--lint[=fatal]\n" + +#: main.c:755 +msgid "\t-n\t\t\t--non-decimal-data\n" +msgstr "\t-n\t\t\t--non-decimal-data\n" + +#: main.c:756 +msgid "\t-N\t\t\t--use-lc-numeric\n" +msgstr "\t-N\t\t\t--use-lc-numeric\n" + +#: main.c:757 +msgid "\t-O\t\t\t--optimize\n" +msgstr "\t-O\t\t\t--optimize\n" + +#: main.c:758 +msgid "\t-p[file]\t\t--profile[=file]\n" +msgstr "\t-p[tiedosto]\t\t--profile[=tiedosto]\n" + +#: main.c:759 +msgid "\t-P\t\t\t--posix\n" +msgstr "\t-P\t\t\t--posix\n" + +#: main.c:760 +msgid "\t-r\t\t\t--re-interval\n" +msgstr "\t-r\t\t\t--re-interval\n" + +#: main.c:762 +msgid "\t-R file\t\t\t--command=file\n" +msgstr "\t-R tiedosto\t\t\t--exec=tiedosto\n" + +#: main.c:763 +msgid "\t-S\t\t\t--sandbox\n" +msgstr "\t-S\t\t\t--sandbox\n" + +#: main.c:764 +msgid "\t-t\t\t\t--lint-old\n" +msgstr "\t-t\t\t\t--lint-old\n" + +#: main.c:765 +msgid "\t-V\t\t\t--version\n" +msgstr "\t-V\t\t\t--version\n" + +#: main.c:767 +msgid "\t-W nostalgia\t\t--nostalgia\n" +msgstr "\t-W nostalgia\t\t--nostalgia\n" + +#: main.c:770 +msgid "\t-Y\t\t--parsedebug\n" +msgstr "\t-Y\t\t--parsedebug\n" + +#. TRANSLATORS: --help output 5 (end) +#. TRANSLATORS: the placeholder indicates the bug-reporting address +#. for this application. Please add _another line_ with the +#. address for translation bugs. +#. no-wrap +#: main.c:779 +msgid "" +"\n" +"To report bugs, see node `Bugs' in `gawk.info', which is\n" +"section `Reporting Problems and Bugs' in the printed version.\n" +"\n" +msgstr "" +"\n" +"Virheiden ilmoittamista varten, katso solmua ”Bugs” tiedostossa ”gawk." +"info”,\n" +"joka on kappale ”Reporting Problems and Bugs” painetussa versiossa.\n" +"\n" + +#: main.c:783 +msgid "" +"gawk is a pattern scanning and processing language.\n" +"By default it reads standard input and writes standard output.\n" +"\n" +msgstr "" +"gawk on mallietsintä- ja käsittelykieli.\n" +"Oletuksena se lukee vakiosyötettä ja kirjoittaa vakiotulosteeseen.\n" +"\n" + +#: main.c:787 +msgid "" +"Examples:\n" +"\tgawk '{ sum += $1 }; END { print sum }' file\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" +msgstr "" +"Esimerkkejä:\n" +"\tgawk '{ sum += $1 }; END { print sum }' tiedosto\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" + +#: main.c:807 +#, c-format +msgid "" +"Copyright (C) 1989, 1991-%d Free Software Foundation.\n" +"\n" +"This program is free software; you can redistribute it and/or modify\n" +"it under the terms of the GNU General Public License as published by\n" +"the Free Software Foundation; either version 3 of the License, or\n" +"(at your option) any later version.\n" +"\n" +msgstr "" +"Copyright © 1989, 1991-%d Free Software Foundation.\n" +"\n" +"Tämä ohjelma on ilmainen; voit jakaa sitä edelleen ja/tai muokata sitä\n" +"Free Software Foundation julkaisemien GNU General Public License-lisenssin\n" +"version 3, tai (valintasi mukaan) minkä tahansa myöhäisemmän version\n" +"ehtojen mukaisesti.\n" +"\n" + +#: main.c:815 +msgid "" +"This program is distributed in the hope that it will be useful,\n" +"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +"GNU General Public License for more details.\n" +"\n" +msgstr "" +"Tätä ohjelmaa levitetään toivossa, että se on hyödyllinen, mutta\n" +"ILMAN MITÄÄN TAKUUTA; ilman edes viitattua takuuta KAUPALLISUUDESTA\n" +"tai SOPIVUUDESTA TIETTYYN TARKOITUKSEEN. Katso yksityiskohdat\n" +"GNU General Public License-ehdoista.\n" +"\n" + +#: main.c:821 +msgid "" +"You should have received a copy of the GNU General Public License\n" +"along with this program. If not, see http://www.gnu.org/licenses/.\n" +msgstr "" +"Sinun pitäisi vastaanottaa kopion GNU General Public Licence-lisenssistä\n" +"tämän ohjelman mukana. Jos näin ei ole, katso http://www.gnu.org/licenses/.\n" + +#: main.c:856 +msgid "-Ft does not set FS to tab in POSIX awk" +msgstr "-Ft ei aseta FS välilehteen POSIX awk:ssa" + +#: main.c:1090 +#, c-format +msgid "unknown value for field spec: %d\n" +msgstr "tuntematon arvo kenttämääritteelle: %d\n" + +#: main.c:1171 +#, c-format +msgid "" +"%s: `%s' argument to `-v' not in `var=value' form\n" +"\n" +msgstr "" +"%s: ”%s” argumentti valitsimelle ”-v” ei ole ”var=arvo”-muodossa\n" +"\n" + +#: main.c:1197 +#, c-format +msgid "`%s' is not a legal variable name" +msgstr "”%s” ei ole laillinen muuttujanimi" + +#: main.c:1200 +#, c-format +msgid "`%s' is not a variable name, looking for file `%s=%s'" +msgstr "”%s” ei ole muuttujanimi, etsitään tiedostoa ”%s=%s”" + +#: main.c:1204 +#, c-format +msgid "cannot use gawk builtin `%s' as variable name" +msgstr "ei voi käyttää gawk-ohjelman sisäistä ”%s”-määrittelyä muuttujanimenä" + +#: main.c:1209 +#, c-format +msgid "cannot use function `%s' as variable name" +msgstr "funktionimeä ”%s” ei voi käyttää muuttujanimenä" + +#: main.c:1262 +msgid "floating point exception" +msgstr "liukulukupoikkeus" + +#: main.c:1269 +msgid "fatal error: internal error" +msgstr "tuhoisa virhe: sisäinen virhe" + +#: main.c:1284 +msgid "fatal error: internal error: segfault" +msgstr "tuhoisa virhe: sisäinen virhe: segmenttivirhe" + +#: main.c:1296 +msgid "fatal error: internal error: stack overflow" +msgstr "tuhoisa virhe: sisäinen virhe: pinoylivuoto" + +#: main.c:1346 +#, c-format +msgid "no pre-opened fd %d" +msgstr "ei avattu uudelleen tiedostomäärittelijää %d" + +#: main.c:1353 +#, c-format +msgid "could not pre-open /dev/null for fd %d" +msgstr "ei voitu avata uudelleen laitetta /dev/null tiedostomäärittelijälle %d" + +#: msg.c:63 +#, c-format +msgid "cmd. line:" +msgstr "komentorivi:" + +#: msg.c:107 +msgid "error: " +msgstr "virhe:" + +#: node.c:406 +msgid "backslash at end of string" +msgstr "kenoviiva merkkijonon lopussa" + +#: node.c:517 +#, c-format +msgid "old awk does not support the `\\%c' escape sequence" +msgstr "vanha awk ei tue ”\\%c”-koodinvaihtosekvenssiä" + +#: node.c:568 +msgid "POSIX does not allow `\\x' escapes" +msgstr "POSIX ei salli ”\\x”-koodinvaihtoja" + +#: node.c:574 +msgid "no hex digits in `\\x' escape sequence" +msgstr "ei heksadesimaalilukuja ”\\x”-koodinvaihtosekvenssissä" + +#: node.c:596 +#, c-format +msgid "" +"hex escape \\x%.*s of %d characters probably not interpreted the way you " +"expect" +msgstr "" +"heksadesimaalikoodinvaihtomerkkejä \\x%.*s / %d ei ole luultavasti tulkittu " +"sillä tavalla kuin odotat" + +#: node.c:611 +#, c-format +msgid "escape sequence `\\%c' treated as plain `%c'" +msgstr "koodinvaihtosekvenssi ”\\%c” käsitelty kuin pelkkä ”%c”" + +#: node.c:750 +msgid "" +"Invalid multibyte data detected. There may be a mismatch between your data " +"and your locale." +msgstr "" +"Virheellinen monitavutieto havaittu. Paikallisasetuksesi ja tietojesi " +"välillä saattaa olla täsmäämättömyys." + +#: posix/gawkmisc.c:176 +#, c-format +msgid "%s %s `%s': could not get fd flags: (fcntl F_GETFD: %s)" +msgstr "%s %s ”%s”: ei voitu hakea fd-lippuja: (fcntl F_GETFD: %s)" + +#: posix/gawkmisc.c:188 +#, c-format +msgid "%s %s `%s': could not set close-on-exec: (fcntl F_SETFD: %s)" +msgstr "%s %s ”%s”: ei voitu asettaa close-on-exec: (fcntl F_SETFD: %s)" + +#: profile.c:83 +#, c-format +msgid "could not open `%s' for writing: %s" +msgstr "ei voitu avata tiedostoa ”%s” kirjoittamista varten: %s" + +#: profile.c:85 +msgid "sending profile to standard error" +msgstr "lähetetään profiili vakiovirheeseen" + +#: profile.c:203 +#, c-format +msgid "" +"\t# %s block(s)\n" +"\n" +msgstr "" +"\t# %s-lohko(t)\n" +"\n" + +#: profile.c:208 +#, c-format +msgid "" +"\t# Rule(s)\n" +"\n" +msgstr "" +"\t# Säännöt\n" +"\n" + +#: profile.c:279 +#, c-format +msgid "internal error: %s with null vname" +msgstr "sisäinen virhe: %s null vname-arvolla" + +#: profile.c:952 +#, c-format +msgid "\t# gawk profile, created %s\n" +msgstr "\t# gawk-profiili, luotu %s\n" + +#: profile.c:1331 +#, c-format +msgid "" +"\n" +"\t# Functions, listed alphabetically\n" +msgstr "" +"\n" +"\t# Funktiot, luetteloitu aakkosjärjestyksessä\n" + +#: profile.c:1370 +#, c-format +msgid "redir2str: unknown redirection type %d" +msgstr "redir2str: tuntematon edelleenohjaustyyppi %d" + +#: re.c:573 +#, c-format +msgid "range of the form `[%c-%c]' is locale dependent" +msgstr "muodon ”[%c-%c]” lukualue on paikallisasetuksesta riippuvainen" + +#: re.c:600 +#, c-format +msgid "regexp component `%.*s' should probably be `[%.*s]'" +msgstr "" +"säännöllisen lausekkeen komponentin ”%.*s” pitäisi luultavasti olla ”[%.*s]”" + +#: regcomp.c:131 +msgid "Success" +msgstr "Onnistui" + +#: regcomp.c:134 +msgid "No match" +msgstr "Ei täsmäystä" + +#: regcomp.c:137 +msgid "Invalid regular expression" +msgstr "Virheellinen säännöllinen lauseke" + +#: regcomp.c:140 +msgid "Invalid collation character" +msgstr "Virheellinen vertailumerkki" + +#: regcomp.c:143 +msgid "Invalid character class name" +msgstr "Virheellinen merkkiluokkanimi" + +#: regcomp.c:146 +msgid "Trailing backslash" +msgstr "Jäljessä oleva kenoviiva" + +#: regcomp.c:149 +msgid "Invalid back reference" +msgstr "Virheellinen paluuviite" + +#: regcomp.c:152 +msgid "Unmatched [ or [^" +msgstr "Pariton [ tai [^" + +#: regcomp.c:155 +msgid "Unmatched ( or \\(" +msgstr "Pariton ( tai \\(" + +#: regcomp.c:158 +msgid "Unmatched \\{" +msgstr "Pariton \\{" + +#: regcomp.c:161 +msgid "Invalid content of \\{\\}" +msgstr "Virheellinen \\{\\}-sisältö" + +#: regcomp.c:164 +msgid "Invalid range end" +msgstr "Virheellinen lukualueen loppu" + +#: regcomp.c:167 +msgid "Memory exhausted" +msgstr "Muisti loppui" + +#: regcomp.c:170 +msgid "Invalid preceding regular expression" +msgstr "Virheellinen edeltävä säännöllinen lauseke" + +#: regcomp.c:173 +msgid "Premature end of regular expression" +msgstr "Ennenaikainen säännöllisen lausekkeen loppu" + +#: regcomp.c:176 +msgid "Regular expression too big" +msgstr "Säännöllinen lauseke on liian iso" + +#: regcomp.c:179 +msgid "Unmatched ) or \\)" +msgstr "Pariton ) tai \\)" + +#: regcomp.c:700 +msgid "No previous regular expression" +msgstr "Ei edellistä säännöllistä lauseketta" + +#~ msgid "could not find groups: %s" +#~ msgstr "ei voitu löytää ryhmiä: %s" + +#~ msgid "assignment is not allowed to result of builtin function" +#~ msgstr "sijoitusta ei sallita sisäänrakennetun funktion tulokselle" + +#~ msgid "attempt to use array in a scalar context" +#~ msgstr "yritettiin käyttää taulukkoa skalaarikontekstissa" + +#~ msgid "statement may have no effect" +#~ msgstr "käsky saattaa olla tehoton" + +#~ msgid "out of memory" +#~ msgstr "muisti loppui" + +#~ msgid "call of `length' without parentheses is deprecated by POSIX" +#~ msgstr "" +#~ "”length”-kutsu ilman sulkumerkkejä on vanhentunut POSIX-standardissa" + +#~ msgid "division by zero attempted in `/'" +#~ msgstr "jakoa nollalla yritettiin operaatiossa ”/”" + +#~ msgid "length: untyped parameter argument will be forced to scalar" +#~ msgstr "length: tyypitön parametri pakotetaan skalaariksi" + +#~ msgid "length: untyped argument will be forced to scalar" +#~ msgstr "length: tyypitön argumentti pakotetaan skalaariksi" + +#~ msgid "`break' outside a loop is not portable" +#~ msgstr "”break” silmukan ulkopuolella ei ole siirrettävä" + +#~ msgid "`continue' outside a loop is not portable" +#~ msgstr "”continue” silmukan ulkopuolella ei ole siirrettävä" + +#~ msgid "`next' cannot be called from a BEGIN rule" +#~ msgstr "”next” ei voida kutsua BEGIN-säännöstä" + +#~ msgid "`nextfile' cannot be called from a BEGIN rule" +#~ msgstr "”nextfile” ei voida kutsua BEGIN-säännöstä" + +#~ msgid "" +#~ "concatenation: side effects in one expression have changed the length of " +#~ "another!" +#~ msgstr "" +#~ "concatenation: sivuvaikutukset yhdessä lausekkeessa ovat muuttaneet " +#~ "toisen pituutta!" + +#~ msgid "illegal type (%s) in tree_eval" +#~ msgstr "virheellinen tyyppi (%s) funktiossa tree_eval" + +#~ msgid "\t# -- main --\n" +#~ msgstr "\t# -- main --\n" + +#~ msgid "invalid tree type %s in redirect()" +#~ msgstr "virheellinen puutyyppi %s funktiossa redirec()" + +#~ msgid "/inet/raw client not ready yet, sorry" +#~ msgstr "/inet/raw-asiakas ei ole vielä valitettavasti valmis" + +#~ msgid "only root may use `/inet/raw'." +#~ msgstr "vain root-käyttäjä voi käyttää asiakasta ”/inet/raw”." + +#~ msgid "/inet/raw server not ready yet, sorry" +#~ msgstr "/inet/raw-palvelin ei ole vielä valitettavasti valmis" + +#~ msgid "file `%s' is a directory" +#~ msgstr "tiedosto `%s' on hakemisto" + +#~ msgid "use `PROCINFO[\"%s\"]' instead of `%s'" +#~ msgstr "käytä ”PROCINFO[\"%s\"]” eikä ”%s”" + +#~ msgid "use `PROCINFO[...]' instead of `/dev/user'" +#~ msgstr "käytä ”PROCINFO[...]” eikä ”/dev/user”" + +#~ msgid "\t-m[fr] val\n" +#~ msgstr "\t-m[fr] arvo\n" + +#~ msgid "\t-W compat\t\t--compat\n" +#~ msgstr "\t-W compat\t\t--compat\n" + +#~ msgid "\t-W copyleft\t\t--copyleft\n" +#~ msgstr "\t-W copyleft\t\t--copyleft\n" + +#~ msgid "\t-W usage\t\t--usage\n" +#~ msgstr "\t-W usage\t\t--usage\n" + +#~ msgid "can't convert string to float" +#~ msgstr "ei voi muuntaa merkkijonoa liukuluvuksi" + +#~ msgid "# treated internally as `delete'" +#~ msgstr "# käsitelty sisäisesti kuin ”delete”" + +#~ msgid "# this is a dynamically loaded extension function" +#~ msgstr "# tämä on dynaamisesti ladattu laajennusfunktio" + +#~ msgid "" +#~ "\t# BEGIN block(s)\n" +#~ "\n" +#~ msgstr "" +#~ "\t# BEGIN-lohko(t)\n" +#~ "\n" + +#~ msgid "unexpected type %s in prec_level" +#~ msgstr "odottamaton tyyppi %s funktiossa prec_level" + +#~ msgid "Unknown node type %s in pp_var" +#~ msgstr "Tuntematon solmutyyppi %s funktiossa pp_var" + +#~ msgid "can't open two way socket `%s' for input/output (%s)" +#~ msgstr "" +#~ "ei voi avata kaksisuuntaista pistoketta ”%s” syötteelle/tulosteelle (%s)" + +#~ msgid "attempt to use scalar `%s' as array" +#~ msgstr "yritettiin käyttää skalaaria ”%s” taulukkona" + +#~ msgid "attempt to use array `%s' in scalar context" +#~ msgstr "yritettiin käyttää taulukkoa ”%s” skalaarikontekstissa" diff --git a/po/fr.gmo b/po/fr.gmo new file mode 100644 index 0000000000000000000000000000000000000000..840e6c9bc86799d492171f324b59bd19df4d5d4d GIT binary patch literal 53536 zcmd6w37q9sb?5&Y6{)y_8zAzhp{Q=Cs$N)xYP#vYY3$8jMC^vHS5>d79{uXQ;w{x( zfE#ha1<|+!(I~Fa5aS+AG#Y6&YQ!zeBs!CfafvfBnS_ZN6OHrzopb-od-YybHRkh~ zsZam=_h0UQ&pqedbI-l+Z%=vDnP$)<>1r7UEs68iSYdu;r)BSC-eSO;1j?Hz|+D13M$>71$^vzQKT$S1C{Q@ zpz^sAdGD!;FQO6Pxo6g~Pk@HFtTeI9=asQ6caD#t!h@y0=wRiM&83Z4nx1*)At0}>_r4!9IrIEld5^1Ncu+x>N*>iZE;;lB*3 z9zO)t|BqZAMF+ss!E?bGQ1yNrsCNDUsDAnq_zduGz{i3Qf$EQc2bIq0E4=?!foJo) z9aOtlK=uC{K-J^p;rV-@(m!b>Z2~Ri=7y>i2F?>3e0*K6#-74e!D@{uK_}e(ObdI;MYNgf9gh0e;wGvb0s{_f~wcupxW)* zpxWc)O`hIba0$<&;rSH-?*q@_{Wrj8f&T)kUZ;}j)4?H7>Foi}1z!rPUhfB$-seEY z|9*IW>=y6;3qbYf)u7tzC7}4khd{OWUxSMOQ*a%4+E#C;7X-W+)c1FQCxM>>MOR-2 zWAG=SzCZ0sZ>P%wR>3~rzYi2$KL9QTAG6KrXgSExi-y4%yaQCb{voJ(em~%;S2;aw z0DF0V9jN?Y2A%|d2s|JBB&hm*4-}oA`W(ki0h=IA8oeJ>IzI+go+ocdMuJ1&ZtzA> z>HHZ8=|=w!s{e*|I95T0e{aC=gR0-TJDu*X1w~)41ZmRfZtxl4KY}z>bkZ&__b%`} zp05UBS<#EYtHF)Nepy>1n$PkR)0IFPH2bJ#=p6mH+1=atr12yhG0*Y?` zH>mV`_jtVzf(@Q;0agE>ffOx@_j>uN;4+>+0jgcU3-*JL+voj!S-^v!=ib^s znc(Nc^LNAdN9_0hJr5L}Yz=rlcrnknfv~LTILJ_peg$3tu795AI|YhP?gUk?Z-MH+ zUw~?dB{Z7KQ2+i4q_c=}twl{{C# zRp4Eq`tQ#{mFr0dJ)Mg|<$oQh@VA1`2LA|DeI5dp-|5$S{EY!$0;-+<7*zaU1U&CL zf8GtM|84}=fp>yR?>pdAz~4CJ?fDFlAroB*J^_3asCv8yRQRue%Ksry?SICwe}4|B z?=?{0?*!E^$HB|Mp9Nf5a5_BPfy==ta9{@$4F9+3c9|Bi{KLpo< zOGcfJ#z4{U>p}IyAA@Iu{|KsFPa1Q&y%b!+^L|j_kAkOx?*q>PKMS4`L6zr|pxWhopy;4y+@G%qI1Vbk+d!rFVepCIUxA{dAA(na{{fx{uAOkYE`lo8 zn?U9FIZ)q!3BvNCb0?jjR|DP#DxLd4^~aAvmFJ9-=erwJd7Gfpy(_$b095-w1U?Jw zz25146R2@sCu1p*vG{s;FEd23RHU^1eNZK!uJn@O6Lop;{PbT zKdtQV2SD}rZg3rV3#fiQ4ys=sJ%vmK&jOY1GEn2|Ah;BKGq?==4EWwhkUpq(zOCx? z`@7&7JpUee3iu`Pnc#Oo)%#z=^V6rjUoHYwpY5RN|2i-Rr@$wHuM7B2Q0aaMRJvaU zmG0kx8c)9fRjw!B;QhBc;0X96-oFZbJa{Lldfo%7o$dz}{|Dfc!G8lqKaZ<<|EvW2 zc)l7uo%+5QT+Z{Ib#w;sE1>xNnGNsnGI$ZsZw1c=zXn2b(LaH(%;@T->-Qf7_5F*W z%JU=e6!4KVUjC{vpP_=Jf&;VO?>B&F@q90MCHNI^nszw#Mz7b)ZVKZ7RJb#4_ViZ= z90gD3{cAvq5WOFiJbBg&z5jQBYKJ1I`o9wF2k#8ee+sG|-v&Gc5Ih_F1!(Q@GRGa@b9jF< zD0==9sPa7os{H4^-0A25sCs@BRJuO`)lN@*h4YIcQ1Pz=74KGX9r#&rBN)BX`S>RA zavrC_XM-OAHO_wkt^=QNtAF1GUdHolL8bS_fWHJ){)=Aa>5hUb$KBvo@LOOXc>1e7 z+y-zp&o_YT&kul0!9N8>=l=u_f#j{89M`&$Bj9#s22 z6!7BPJl~@M?*=t~{t8sP_PoydWyBW39z5%w}5(o9J~;g;F9n|i zejZf0p7d59M^}NOhc|-ffu9DKgWm&JfT!N+{k93z`x#Jt;QgS=^?mS4@QH8p_I*C6 ze*GO#;XeT?oqq_=&v?7H)0N;wyuTgPc=$Z{Z154k>*-zws=j030q_oR9r!QcCE&&H z@bG1@hv)Z#D#r)GbHRTFRi888>HV<@)c0FK<@ZhSAozs4yc~zY%Xq#Ed@lHHuovuq zm(%4QQ2lxvxDNa#_;m1;cYFJs52_yzf+vHwgR8-}f@{IQ1TO`j@*c+>0bc=b=ly5F zA@FhUb=(S$@_Y+80sau&3+{X$Hc;^0;1=*_;4X0O`;l4T>p->F_d)T4b$5Gyw}R@2 z&wJXKZECi7ktoh4|p-pv!MFpgWxm4zXz4iufX%cWgqf>-v^$}^Q%Cmb02sG_$_cJ zc*=*PXa`sTEj>_l`uE^g@br)PxEldg&o_W7?`J^ebMi+$+(qD(Jl_mH7yJUa2YmX+ zJpJoI)#sA|9|BkL-2ZX!_d}rC|D&Mj=%2xh!SnyX+iMt9dEO451AZSo1$^u$JpD63 zeJ_FQzz>6>&xgRx;NT~HTs6RF^L!t;9sC}+1zhom&S#H+8b6-~mH*GdOTguSR1HKDXxPJzhgO`8Wu^jO2p!(~p;C}F@;DzA!KX&>45>WMd zD>wyy7knbP>od-84}q8S{2EZ@{1Uhp{0~s+tof{$>jqHueLr{*{991vTKy-EuK<@o z_4hTfkN58cmx6x^sy+V+d=?me$?I_zsB|iz+VO3m`uFRg>i?)O`}_5v>fHpD?&kwO z2wukXQ@-N$+zD>t`F3z6_!r=M@G*bp{Ps%le4bwmz5x6Lcn)~VSG}Jv0S9;<0Yyiz z5AXj3+|KiZ;r(R~INg-M(|LajsPg|VxEuT?crLi)YfjHwL5e%zgv?Ve~cc@^G2?dczzYv zW5V~DT(~Flp00^5$-TRR`)~1X8P|W~(qEbDJ-ok)tIYLYd&{^E_!{1+eEPf5A-bJ+ zAK*HhXX)rK2LFYt$#sn9Yr#)|`nxdTySYDu`;Ufa`^bNv=DL#WO}Y0C?%&T9^ZwP~ zBe{Oa{exU;BmKRB>muH7;ewS#cX7>fC4WV3ev@z8gk1N958nh|!F$+Bv>QAV><9IC z1iXVQ=6WsHPTq+ptml55tIDOnw}MXr-^_I?_xri7tSpN4P(iuv@vF$@LKLJ{aB)fluX~{$T6T(QvQlU+BN^cPPC7On8Ph+250Re=m3c z#`Qj~r-yKl;{GhI0?%&&hr!uFqryc-4I0-g>cHtg>iJdbntc<`NE`dbt5 zeDEK69tkG!wROVk@4A35=l-s6|1$8cJWp}` zSFW?d`=^0#;9AW!#`|61?{htg`;T(Hi2M7v#9Q`py_)MV*BM+ByuS!s4sHa$%ylc* zW}Xj$`rFI>d0Yp%^!H<~XL7C51Am8kKMlT}>qlJg=X!n!%We9%A>6$t;Eja&756*1 zo*Tkn!TnFUKEibem;PRtORL8H<9K&5_{ZR%aP@F~oafuX^;}Qj{uZu38mz;Fs(TGBJERm*ZCh$?={W&4dX*_?BYejhfiSS-F=xxT^kO7JxBli&?p`ujf)(N_Xic>gu-_kiyNk8*vL>)Tv^%{9XNYq(y^ z{p-12!u15M{NElPp3c=rxPJzJ1N;l{ePAEBnd@=f>+jj%&ESW@8hAg~v$#q;SHKNm z1N;ZB0q!?}`M*MV*vGfu<^DZfU*LMA-t+E{xc-*gXMv}JPvv?c*A&n9fciU``wxJ- zx$foumEcbB+2D7%?&khETuurr zW8A-(>s4II-)-FQ;^A6w8`l@PU%^%9`a7=ZT8K`H}<`oPF+qiEF| zwU3QjVXV|3`9fJS#tx`)tj1%_sp)~4LakI7DHrS1T^|&t828ck6SczBK%;oH(MPuR zYO^+4T+{kqVaL@?6W;s-1Hv`Q3w@rjGE5XJ1JhOOs!4k>Su9WMbH$!2)ylwFakMm5 zC=ZO$A^I|%l{3&mu7EX*Rx1wBXT{o#*Q{YL)r|wy@|e@D3{~Cjl$^RA*eC`soo!#OLb9Sp*%fV7%4VNqXeEM)V^w5D^6Ey zjhNmbT)kMN_r{9x@CKgy;!-6Z79kIoD&y6@{`kmbX>>9!)qCni&vkf@MK4t*;@!0> zoiJ68p^Z3=-k2=XysG3_9EfC)^7W393dvKm66LDLkmpFT7FWmPLTv(4tu*TKc(ulW zi5O@68}6<54aK9?W_gSvHsXn5BOV`%$IFF@`cS-de6-Ri$6F3<-MnwhrXeCM>k_X{ zywP%%K|z;ksO2K>ZHa7yyB<$9>y3D_FjJ&rF*K^ihJ+hRzcE>=jp?Z{RiqnLCzY)b zL(i3oqNp;ij$BV;S?FrKq_@5#9xp&+WARciB!wLtiW_1Vwc2$@@$mA& z!NKLdqkZvMwOFt8HR2=H+F^By`h*mRtX0w$iyPH=cwnZ_%Al?bl+rBrsV%3}?!+n7 zYK7TDwc@zKiy`TyHOZWk6{n^fv+>eOvs_;0;li66i?wQalXRl^2~9IF5cg4J4^4Zd zjpJ`ZD1y+RX}uuF>Je+-(D|)_2L?_!aIJVlvs5dJ8q@Y^OY~|gzxX0}Xev~g8YxXQ ztIg1GNrm8hN^Ze?heN<-rB)oRPE_E)WBoDXx>_qTdldQqts|Nicq=eH!hBkJH?7DA>l)H3K_3~PWuD#q%XWA z`MM;f_a2_-yLD<$)K{N{H%&pI2`94=B!Xa!K*d4UXjl}Zfh`Rq8Y6KHO0YoX{c$5ma+>PGXk#M6H9e zP0-y`e8HOd+?DYQSI3)oZi;VmL17r?@O6Ow9Nfum<1 zt7U2=?v@72eM7cY8fuz@HywOo`hKceZj_|R#L@@iG2{dK&DdbPk0vd~Q-#@hg#L)9 zO7*Ei1F4E!K2j`JyfH0~1gSMGT4teK98A-mhIK$2jA~~E= zch*)rY5%=x`}^3GAhV8fj<3-bb^dbjXkT2cj~1qj_0A!xmJ#D&`26#`B$5xZCJEzo zS|2+3WQ~(@l~zn%#Y<6K8K$){WZUjqkqS5IE80-q+oAdP%xQjFt{NjCqP>$+tCEyE zW|s0CCJ@oyYOOZg4|9{8KU_f^PIA!?rXbSd4dX@8-sb2iJss`axO@4w-K|s)H>0?% zbl=WvGL~Z8RSaN~c7ky*kl`suO6ZYLCew!TX1Tuy<`ZANZQqr<_V0_=@4P0ydi|a~ z>v!(EW;G!jlU2SJXP{c8Q(}mh;43gZh!4e~I^MHm^PY`Y5`O)LZQHl)y9SOCZ`rnQ z=jOe8<1M@P#OveT>-X&2wsHUV^?Tyo`}aT#n+M}~FZ_@cd*dDxzsqWbI0Ssa7kNi!%&*mC$A~E3uqeA!(UdBv7$(UWiLFth;W1hS>2I^GF2(d9OD)K<5JrtHmBr?c zHY?1LWASLI(U&7(&Ev_M%8CDuHt7bsKt&`{G@Qoll0S23*rgO%D-(^$*0yUOy%iduLvxMS zs#ElAu7(~Ek!NiQr}ue&G^`IAmWxis149~fNj^)fLq^E=X06gEv73=nIweYb^yc$? zcAs*Ds304dCiQMLapg*LUMBfbp$v78&C<6v-x*_)AtPAIY5F46ou$3y@&1_qmciC# zg+q%pCdT}yp6UaQ8uK&RFx#WF>WLx3gcL{SF2>o>Oi_mGiZ}$<4U$WQ9*mNdr{)t< zv;52x5W7wJVt8_6ROav*(XV0Gfkz_?3g*XL{v0V7*nEKcAygkr8CU* zRh4L@iOmWd1e(yeOo=oZ7JD-euOgdBf>QioxNKshFP*$lWXO23h=!X8^hEj+sbT|L z-C}v>RXb}zX>BD4AEt&iIx%1=Geu@1$IJ?Aaf$g=F8nlVuNi;4hC!F;6sVnh+xQlT zmj>CMV&h1anb>Tn+?UTyU#SG?kf@=3`6OkF@>*&bS!Hq=re7J8?cZchaHZ5tca7bpsN?=(&NETuWt1yE|CjVR#*>|Jkj$e}gmx;^_2}h_<1;c>Mf>Xf#>)iusT?F1~%A{%a%$hV1)oJ}cAn3Hw>OkmiFP$Wn z6S=Bk4W0BOI+@L!hta<@Q*Kd0(z%2+^<2@}Ng3=C)Yh7qnhr~wrijB5T7A*z6m~E#`tGtAUz?Njr6uP^lvBIc2s@DwG5=8nAxV zm_1TMUrG7q{DCz7J0;ZbEKOGZu9ORwNZkaCqT47=&|i^H9fu@+STanBl`-MEuN7&mG*gmI7)yVw6+2|F zsZMlr_fHyE*kSq>4uVN_fn=5|NE54|^$k%HbAhZciUlm@HD;&zKxp>_zL_)ra#X9zgCT9G0PKdnJw;)4tA@T4* z8Q^k@T+`)(5yWU;#3Dm(qB+-u=KBu^u*aKGG1G~M)kPF4%`;6ZUm_Nk>Y}ceP+0&?R(!2MytC6< zt0ak*KcKJ%YduSQ$1s??5RFr+o+EQ%>ikXOb;7vF z0-@vylgtg!!Oi#926J3Otvp771Y@Yju+J_RdNB z(m|&T+&ZH%P`5u323q+bD`q%)=K80#(i0#`IqoJH3(xZ0eUO!YF{iK=)zG)nbx6mTP|#PBd~x?Y=Ru#i%l zL<$`dl1ODq(9Deu2XWJHDo2nTQRn#CWY#tNdE%Q@#+yJ(*=ZXX=Lr(mqD$RKX7$Bd zly5uKpm{^00i=4cQAvybn+kIOL`T?7UUr0qc(+kXn=V%;k%( zzKj-a-6K+`Yk?p*Re9<#YF6HvP0MS>tWFws^sQj5>ApBxRgm{tQ}hyfD8^c1La<_L z43LgiV0|u?NQaKWY*^ZgXgYR%jN_Mxy$PMKd$js=0ok8;Ah_y7j}0&F>+hk83=4D8 zDK+J*Z7uTERV1P}L)de(n^ZQKO7p}1)uQRWV zCYh84)%xI3*&@VQAm&twGyks<7Wrn4=cY~`3^Xm}$#5q(Fqn{B@r(tkF3pNuLr}tk zcu1Gu(}d~DQAmkVlok(b1(p~s-PmlgZC348*tSK1`9ijtKNPfs0o3)&Ijdk)v@QQ+ z4Jaut>E)F{O?lk-ViV~Z5d}efR-9W!cAXyyR>Zb0vPuJ~Y0M`zMytwk^&}BFK#tZ* ztSIC@x}7*zRG(I-g`D$UD+{41vq19OLTKO!L?x2^G@V$EF{jZNA!~A3r1p~}fw*^~ zJxFfRED05r>yxGN#)&TD&5f1jALiZW3e?enGdHf>o{%zloLOPKH|8+`c?$W;=W5ov zKo#oOC2Tu2P9Z}M1#2n8AaP<#8Y?Km65J`DF={b4p*bVl7);x;a@UY%uSsOW)M2() z;CRY%N4Y3>TXaV;0gdj&u914c=p~ZOIFqfJMoILR*>pR7O;u-1E7AIbbjQxNQ@FYY z(Xwc6@Q!BG_VAg-cJX<%$5|jF`ATLS%$i4SHN2;bbBH-t!k-~GmN^EJWe%B0>%oOi zuJVy7^`@fFBJ6SKt70OYWP6H<7OImB#Et=N;N}9sQpvtAx~%X)uLeL zo+5|g;G|)4A(3KI@warLn&3H=b0Bx`R3@^}-x$NyJiuYu#_a3S{1NbHW}nRFt=o3G zt)3!bmck}EPekTSwtdT;R=cL34~7Y~YdBm|p)EwMmbc`tu0ccfyT=fxaT{NoBUJNMu?$->2#&PyNLRqM;O2V^mMrOuGBX8*oX7T%c*5p1 z?Rw-6PeIH}NsosQ^o|bnj>?ULeK+RFkEmxgatyzNh&jlpwqp1u7}n{qMOt?;R@~Ie zA{c_MX66TEk+CW`&rw^1^X z+1Tx34bB{CC|siy;-JHDNad4WHXP z*0-o&<@v)U6H}iaIPcWz%`~bRW}UER+=)64XbN|&3L$<=oQfugL|NWjU*0DZ&|x~a zg!Q5jZ&Z@1X1|$0oYFhQoD=VY3lRdLrHl0elNo6w^9kOd0)o0yFN2-eZX4wA8p4N~-!|WFHVNH>0b7C!CUd)YqqEjSKVR2Gt z-mq=VH^P(C>?BBQ)*+j$F4wA<($XzSgvUyW7l=3{LpG|zt!$#<+u41t5zHpGkeG%@ zhnRL8cM4~wqC=W`)t4?~Iom9pjU#L_I6Gpws!MGX4im|<(uOQ{NHM#XIb7nvmDmL5 zxJxk>eX%|NC9^&u=a3hb;t}&W%WLyytuwZvJXj8vlLTwn(ZiSE3&qSjtzCT2jk$Q) z9pZKn+;c27-GjEwb3?FpB|H`5YOro;XLanXKh$q<=UyWcvu~&4FQEvTNIY1}OnHt` zsg7js=6#%`6}4IX^o+lRWJBxDScK}h&+eU%1?3y!*}Z4i#%(*d>^iU{3A5zdmX+xS zVwZH2_-Ubo<3Y=+PlsTx2Kgd)TkCa7Rl!L`W4BFB&C+g51`&b#n;G9%NNWoF*^CHP z=R=JsGnh##reI%VqBI zox-=(x_hL+n37V}-EGISOH0z0nsFqPo&BuTsIRk1&kf3+*>(q9S3cWVZzw`KHXgS?h(=GV zr*mSx*AW|H1k%5gcgYMod*d^DtD~)?N+4m#W4|-n7nN=Mb@(&^UrnTj>M zmK%>I3x#^O@Ej_e^m`l(jT|l!H zYSfk*uzD65u>JGzV6oO5?;dUnVhmw*K#LyQcf$@?X;?U%9Bs8XEM|XA zTa;AfEoh=3V%s22#9%8^RiU~BY!e1-g0AZHl7Vew1JCm#eums1`J%xUgDWO`{P>rF z9rcOQ*nkdw8Q53V`e_AI&bs>HA}+v#C`&!NckLV4$OKg?|G*}Qa4252V&$rV6&DVy zx-?$3YG}oU7pz#dVg&&Q_TUXAuf>*dD+exI5wE&%=;BoutXN67?Xa-{_WM?_G&5Zo zimzhoGq4*UZn?3>Tbsv^;Z!mfUw*ybPlxw|6HQD|wXt5 zSZ!;6=-X@d@7pqPX%+oQV{xlsby)_&w}HzEuC897|~b=de^V1?hf_@z z`_#rR_0yxNc&lL2g)Gt`x{p(+!r4^$mkRc4ollh&IFN{rsLD!uqNh|9n?^G(Ad`ct zca@x$5|_MhQPvQroQ) zN3;ozb20EwL0A+jRSw@O>8v%ZGZ^%XH?klp8>X2V?!WK;yTqUFzw7=_A;*)Z?a_OU zib2^V^sztY;2_rSaV=qBwkI*qaaW4mLzT#s)pm2c=0Jp6Y3lefTo2|Jn29qjqegJ< zqGI+Vd}pe&6unu&e;o+Dn5#y zQlVMc;vA3lW%`rpis}hiK!g#1e`z`CvDA(BRk{o*D`Kt5}n9}xxp9Kxt>`+V=8my+w3N5f!;3|WF!pc)QVElB(>W)d`t>lfN~5V6{6w+i_brse zyv52jnw>D_g`yMCgR2z|EC`2;!HwqRV<(N_A(XFfOt1M#W9sL$Q@RD6+reVWtmz;B zeUN3Yh7>Y}4$B&B{;TMGyQF35P6f7!vkoGYSy=7D$zK@k*x0Gl^Hhq(oJOW_ITB22 zA1Kf}D`|jk;S&1kiMDH4g%cK4MV~5L+p2`-s>Hr$s}=^yu)eWWXO$%fmo2kH%cx%% zJII;xw1XFs4b4EhlPHqVYqd`Tmat;b} zj?81d$U!$ItTf@3%rcQ|$JpTGYNwx}L&Ouuk5vLmZsjnarTo{^`Ovgw7=^^nQ4B(S z#*i47#B$5wX+2xgQ{GhSdX>ezP@YUFxKJe;)s&O^akkDVBQqBgBIrr<2ecT9Sb~q6 z9Gj_1pp8yeOGhQ?Hy_1lh?Jq@bEm2qL3KV?%|6-5YNp{W@^CfDF_CF{wpu;5^VT$C znd>+|F4b8?lfqDs_8=lCwe2QC;*^fxL!mQi!1-ZQ)&e?a&8jtON53kVyay7g5p7Ig z!yjy**~x5fkIjd(30G5T>HxNU5}ROr^p(!=#KEJAaR$$p5LJR7;$Y~ZAu7;dygN~P zWZ<7n>VUSP=1-D>+%lPkxIcbu0)8c(XsNI6E*qq05`7@A4nXK|@Z-m{@Y~WN8>%%L z6S*q>n5$WrWO5;P96vUN9wZJj-7M9qMkFQ@1~hdKN4OQlVi>Qkn2UTFxjVN+>zktr zkAPr8j2gl)4zDtmrfU_VUDFys#;a5&P8JJ95c%E}WOh?ad33XcwuuPiFP*=uKd6Fl zM3an{Vxp;nS>P4>;89~~9a9%awBkr5Q{eN@KcT>DEc7lv&C8iC1MB3IlQ%j(OXs1$ zC&X#E~qRh!lqQHYe6>jb$?$B!X_ zjvwofuZN5ze=voq;Z4XeQf&~apxXYE>kS<#cl@3@y7Qco9!{B4YMsV9+&g8~V&2K& za*!Hw9{p53Le4id`%3uAVS6#z0mqwC;r6cIxi?$ekT8hZh~UoBGyoTEBbW`hDAW?TnAVB;LO>-mrgP&)(g~U$t@DmTk}7 zzgc1dj<9jp4xK=^ZTh^}i$j23(9O(q8|lSqWJ+F8lL@P8da zBCfpwo`|iJGdLwqSoCJPkqrKbGwPb0QRkWuLsBX}2dmh?Wb+;0mUaBbxphs>t?T&h zAV+OVk!nkBf2L4~o_jgn&eb6!aiwR&%+9sTn;ep}?M#G(S6qYCxiM490s)Ft1#P_bm1h zJT;prTnFH3#Yikr77ckec$4e&JIM~?u#MXBk72h?&(Kr!z^HpCa7ty?Y3@H1P85nL z2uayU?d`SM6KCRyOy$ev!A6VaW@%uw6lLQ%s8M-MZ$olWUZ-HGf@}Pt!r(M*hcQ20 zWJkpDdsPSAgna5(?36^xhg_%3l_gUj-4@|Z6f|nrDDw$+3Z5((h3VvCgZFFZ!wQsU z*_pv7_Ofxrp7DF;*A-Mv*R-jz$*>@==(emPmg|6@xTlygZaIxURMp3~r)KB(Sw*rYXH|^#7Sm2>5i>|A z=P(nnz+EO03YOc8v0zY+_FE`ScE;aAA-7uql#RF`bp|m5w=3k&;Gk?tI6O zS!de8e`(suOwQ-0HX40aI#O+p(!lUTJtxNis={bZTApHp0y(H*9!47ZLju!uq>^x1i?Oze~u%k;%2`r_G^;L^=wbuHXq zJs58)U4NK`$pRXavYiYWo*?yGWeT2Y!mmYZ(v znxt8Sim)A_DB5xA#k~pHcs+92Ct0uoCSIu7 z5!!s-JzeUoOMIV&!f9=GEH^yP48dQH|8HRBl38?1R4ZXVax$@l&oM9c$XZw-Q!Rbq zSq?MOuGh*~)6()3Br>L2EN@w5St>?Zmr|;{L-@AkU?i%vvCfg?nirz2LNcbtJxNs= zLNd}78%5I_2#qW0ys}t}>@3HS0?#Ly0(s7pLduMCeVWg&wZvURmwx>UCQ1AnHSC0Fo z6-h7K^3=2)`k4DJCYYI@7?Sk22b?J}_kCLAxSx zoLdXB&A5#>;Usf|hp9s|VKzCzn8?hm?UPhHWZNa3#M9pRU!oSJta6_8s0Q=hgp1}& zwNQ-|6N^F806A9quwu5mT7%m z`6*F%9<)@=4nWf|o+dH)ATY8rCt73FviO@4G__9WVP1F{D|0<-lUB&y^G^4KQ;39u zT2scDU$a$Zj=^FBPA(-`j7ru^Lhl-<p|oBb}X0+E$KSZu|m= zZLmjOZ6lwyIPGmnG|_dJc(x~8O=T^|J~N-Fn0{6%Ns~w@%`3tY7xva#1X3qJwwoMn zKTVHfZQzNT69yNB?cu57EVpo+Y_1S%@gy)W_gy7<(}0m6Yn`)mxEOo z6D-d<``D*d#dS8Un;;~Tg-4v9TvoR-p};0{?Fw&%cd)H&UIE)Bg31dgX(`g2EW%-| zSrRSbF`&?Q10hy+GHYUNPj=E4o5`^TP)#!OAc}MWI7{DXLcUMg;jJoYEXNa+g(&iBJ|GKPe#LGoYXdJgS?QEsKD@7=E;_<;53hAN`8T*O6OKSJ1}J-o^KbNCU!xCJT^r3c zPCa1AhhJrx`%0`rDy`a=wJ(gF8o8FBQ9sm#La!ybV2w0RJGgaO%Un+Zryu%WMCp&4g*B6JBopLMPK| zZN03Osz9_sU#26H+T@h?j4s3QZBIZ8{DC1D*JjP!vtXx)pUGu{b-`$O`MToYDW39< zQnvyu2-09$y$XD3P42WMd4iafG1tF342NE@ium#yZV^5>)Bb1ePQx;{eizLRl<|Qa zA8v6GF#gb8Vw;)I=&{xKa3X0)F=8P;Zv@F~e(8FHs+Z@p43K2$kG}6{51_(~dwD#! zN6smuxtL*{v5Qig43ETm+md)E?O)9w46q3?x0WcR*tzg+QCnl?X73!sD|s9ydqxe; z{veQfGiXh*t#;blc0&^fhe$d@T2(B<;(y74l0I=LemDO@IGbC219hXx+hM($ys6Te zKA(-#Y;d~feIjXeoWI!dx9a~eTtg@Od8c#V=ib0eIMY{7KE`_Hi$VXkm_VrAw6>|G znP+#Z;JL=(vcVVJk<#T4+SS(w*^uZF@TU3@+2{4*PEpoCNAjTb}VQX zU0M60q)0RAM5h+1^X?&#`F5uHDx$APJ&cIHB6WfhMZCrYs}oEY7k^+itKPfratQs~M-=BRl_ui@Cm4cpDo)4qhmAJd@=^HEA5L$%_DT%$ z?)SkiRyjh6Ya}F$a$?G?t%7IN=!@c67kIaMP^zLI&!ppstic2u@N{pK?Pn;=4#<&Vf9JYL%|fe(2O^k{pRO$x%9$h zFzae%lISM6%%CdyyJrR)Z8kD4o9ZMBrAnitzeaoI8JZ4J@1T&eCGL zncJGbV__3^m*iTQmAj`VP=%wVspgb5J*&xh$RyIm&T-D~sR-spjgh1 zHTBb}=MsdHWTfW;<`U$mswCj^_4d=Ji&1_=Cd*LHKT@jJT5v8g6hs|7t-R_{d&lI$ zL7npQ2t*pm^~uyEYNj)$%?hdMQsQ;U7=^3Yw9*S8Q-m23__gZY7-f_aIw?D|wAY1w zEQv8q$E5fSm^54>*-{L3Yn$q3r&5RZx-e&uogwjfg(Yvk*I|a6O>kGLwYpA@IS#Zi z7>Dz##UDApnr>segzwdm-i}8%Mhcyy=T(#xHH}x|EH|6B9X#c}(o_LusCZ+PC8RbA zDzWxmuvN|b#-~`pZlcP$B9oFNK_$aW5uIGb(aWi&yMv49J!m5>QQA$?*>oWvLyDHs zkE-Wf(X1fJSO_yV7iwWP>@JkFh7~STud^I-)_~S&lVbFe;|y~-$jeT>*5Nu)a9^O! za{iX4U+@KUB6^IOlL(MeZoaj}W<6-Wnce)5+p~ZWPWP~=!U&)&CX-eD_-NB1&P{(sb$(*dDX~H*$ySn^E9WgIS#Vjf@gi5BT7G9TZyNp-m=L< zwP4cW$_R~ftmy8ACT!U0NYf*d64o8g>9%rq8sK^Qrt88YE4^rYCT(Mr6jk{Ym;&B) zg^@$Km5J7)lXUP%o-ds)OOA_5NI%b*EQlr(gI}*`T~b`QkaUb`wmB6{9AM90Qz~I| z*%Cq~Q<%va8=6BVoz*9GyZV5023j0DY(j{5WVI%8az$^NJpM7QDxfe()y+-N!^9d5 zp_N4u)A-s6L~&7vV6{WWSsXXHxXc!AeNiN2=6pM~KqfP^L`8JtRB*!UUovE~36PKF)+m zN{qNBng=dX$&nt(HbeST!%338ZI@x}RTfjVABRw8?&2WLM(c&oamlX|-9S&S`=6Ld>Iu zD;0i}QH{}-Ot!t2c@p!A0dw_H_!28IbS0}jVRcb2%|xO^G+C#3VZW^Qt@Y-WEvPHE zl~$$&&Y}sax0S&7AO=F4I;qNYI^ntwGkluGP|ja$xVLST6jP~M@Oa4*8ypYA@EchI<06*U zSuukfGrY7^m*U~@c`uok6s0nQ2!ij(M>;Lp~X?bE5WNzm3A zRp#2}?OM zD?vLYl3epvW=s(wu+=#C>4cX~)59uI+~}Uvz90sZoN|v2X#M8Y5TO9H#X5crH1W&q~=JbYnAjB&!#Bvq`={(AESaRa=o|M9#@qv4a;`MT6pVwmr?0 z&{&NXXio@+pKaM$Y!up1Rn>^I!P9aGg82-DISzbV%_5sjn7f!SyC2t&hL|1+;pUk( zPhZY1XcRcK(l^GZ&a=PRY^lnut6M^NpwGRa&GH(h{Y!B9aZPoF1YfMIo7U(_k>&UYi5^c~-gK z3do%dK(#dJ%PuCM3Ps1Qi{)Y+W>_+7znwqoCXUR8jgMNZzgH5$NWcy}G!d2XEP7LC z^Uaq)_$kWt2L{rEZ?q#uejn@!X55zW0kq#6ur}>vxXCw3&VogYq+5F@W(b}7=hW0HuXZjX*L<6F&XwOnP%DQ;taNE0(^s5Bnax|jh_D#awqHe9RKQjT zOD!9Tm+^~_&fir-Q+EBhJ~TJ`fdorBJz!3nqxn8bAME%`2}*`grt#%QU|Vuw6-Obn z^c2+wQcGYBA@qv;cI0&9>)Z^ixROm>4dglNNt9%ypQLZgBk2mQy=QiMv$TZYP+%#{ zS5?F}<~VYv=F6n2UNie8g3zXZ9u-C@98l3NU=0nn)6pb6(>3A|#zt)eqiwLxRNMTI zDs)ILqrcqGD=ZW)`OSe2;nX!*Gq6O(gYR=U=ZoYg7COYtN|MO#a5zm^&J4*!{+kPy zfZA0*V~B#}6A{`YONL>rl!~?dqNt~mPbBkO3LHBSX4>e!^>@+Px`M=PF>lH)roYqB zwcyIO(Bv$aGF?oS74?l1)d(iHAcP+3?ySj>$dCTWL#Kk4*=4enu1Ttz&h7hQ!WxAi zfml>Yprd*x&v<^L046JoDb`(|z`9pOPA3m=>*^JnA-eiI-4c=RhipUn6sCJZL$`_URNeMRe$cMpKd0CLNpO?@q zi>6Zr)_P6-ETXmkMd5v{KmqKnyA65l&WdDaf7+{{E1N%tTsm*$, 1996-2005. +# Jean-Philippe Guérard , 2010, 2011. +# +msgid "" +msgstr "" +"Project-Id-Version: gawk 4.0.0h\n" +"Report-Msgid-Bugs-To: arnold@skeeve.com\n" +"POT-Creation-Date: 2012-03-28 22:03+0200\n" +"PO-Revision-Date: 2012-01-30 23:52+0100\n" +"Last-Translator: Jean-Philippe Guérard \n" +"Language-Team: French \n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#: array.c:140 +#, c-format +msgid "from %s" +msgstr "de %s" + +#: array.c:248 +msgid "attempt to use a scalar value as array" +msgstr "tentative d'utiliser un scalaire comme tableau" + +#: array.c:251 +#, c-format +msgid "attempt to use function `%s' as an array" +msgstr "tentative d'utiliser la fonction « %s » comme tableau" + +#: array.c:254 +#, c-format +msgid "attempt to use scalar parameter `%s' as an array" +msgstr "tentative d'utiliser le paramètre scalaire « %s » comme tableau" + +#: array.c:257 +#, c-format +msgid "attempt to use scalar `%s' as an array" +msgstr "tentative d'utiliser le scalaire « %s » comme tableau" + +#: array.c:302 array.c:707 builtin.c:84 builtin.c:1385 builtin.c:1427 +#: builtin.c:1440 builtin.c:1859 builtin.c:1871 eval.c:1135 eval.c:1139 +#: eval.c:1495 eval.c:1812 +#, c-format +msgid "attempt to use array `%s' in a scalar context" +msgstr "tentative d'utilisation du tableau « %s » dans un contexte scalaire" + +#: array.c:513 +#, c-format +msgid "reference to uninitialized element `%s[\"%.*s\"]'" +msgstr "référence à un élément non initialisé « %s[\"%.*s\"] »" + +#: array.c:519 +#, c-format +msgid "subscript of array `%s' is null string" +msgstr "l'indice du tableau « %s » est une chaîne vide" + +#: array.c:723 +#, c-format +msgid "delete: index `%s' not in array `%s'" +msgstr "delete : l'indice « %s » est absent du tableau « %s »" + +#: array.c:734 eval.c:1865 +#, c-format +msgid "attempt to use scalar `%s[\"%.*s\"]' as an array" +msgstr "tentative d'utiliser le scalaire « %s[\"%.*s\"] » comme tableau" + +#: array.c:910 +#, c-format +msgid "%s: empty (null)\n" +msgstr "%s : vide (non défini)\n" + +#: array.c:915 +#, c-format +msgid "%s: empty (zero)\n" +msgstr "%s : vide (vide)\n" + +#: array.c:919 +#, c-format +msgid "%s: table_size = %d, array_size = %d\n" +msgstr "%s : table_size = %d, array_size = %d\n" + +#: array.c:954 +#, c-format +msgid "%s: is parameter\n" +msgstr "%s : est un paramètre\n" + +#: array.c:958 +#, c-format +msgid "%s: array_ref to %s\n" +msgstr "%s : array_ref à %s\n" + +#: array.c:963 +msgid "adump: argument not an array" +msgstr "adump : l'argument n'est pas un tableau" + +#: array.c:1086 +msgid "asort: second argument not an array" +msgstr "asort : le 2nd argument n'est pas un tableau" + +#: array.c:1087 +msgid "asorti: second argument not an array" +msgstr "asorti : le 2nd argument n'est pas un tableau" + +#: array.c:1094 +msgid "asort: first argument not an array" +msgstr "asort : le 1er argument n'est pas un tableau" + +#: array.c:1095 +msgid "asorti: first argument not an array" +msgstr "asorti : le 1er argument n'est pas un tableau" + +#: array.c:1102 +msgid "asort: cannot use a subarray of first arg for second arg" +msgstr "asort : le 2nd argument ne doit pas être un sous-tableau du 1er" + +#: array.c:1103 +msgid "asorti: cannot use a subarray of first arg for second arg" +msgstr "asorti : le 2nd argument ne doit pas être un sous-tableau du 1er" + +#: array.c:1108 +msgid "asort: cannot use a subarray of second arg for first arg" +msgstr "asort : le 1er argument ne doit pas être un sous-tableau du 2nd" + +#: array.c:1109 +msgid "asorti: cannot use a subarray of second arg for first arg" +msgstr "asorti : le 1er argument ne doit pas être un sous-tableau du 2nd" + +#: array.c:1655 +#, c-format +msgid "`%s' is invalid as a function name" +msgstr "« %s » n'est pas un nom de fonction valide" + +#: array.c:1659 +#, c-format +msgid "sort comparison function `%s' is not defined" +msgstr "la fonction de comparaison « %s » du tri n'est pas définie" + +#: awkgram.y:249 +#, c-format +msgid "%s blocks must have an action part" +msgstr "les blocs %s doivent avoir une partie action" + +#: awkgram.y:252 +msgid "each rule must have a pattern or an action part" +msgstr "chaque règle doit avoir au moins une partie motif ou action" + +#: awkgram.y:323 awkgram.y:334 +msgid "old awk does not support multiple `BEGIN' or `END' rules" +msgstr "l'ancien awk ne permet pas les « BEGIN » ou « END » multiples" + +#: awkgram.y:371 +#, c-format +msgid "`%s' is a built-in function, it cannot be redefined" +msgstr "« %s » est une fonction interne, elle ne peut être redéfinie" + +#: awkgram.y:432 +msgid "regexp constant `//' looks like a C++ comment, but is not" +msgstr "l'expression rationnelle constante « // » n'est pas un commentaire C++" + +#: awkgram.y:436 +#, c-format +msgid "regexp constant `/%s/' looks like a C comment, but is not" +msgstr "l'expression rationnelle constante « /%s/ » n'est pas un commentaire C" + +#: awkgram.y:528 +#, c-format +msgid "duplicate case values in switch body: %s" +msgstr "le corps du switch comporte des cas répétés : %s" + +#: awkgram.y:549 +msgid "duplicate `default' detected in switch body" +msgstr "plusieurs « default » ont été détectés dans le corps du switch" + +#: awkgram.y:809 +msgid "`break' is not allowed outside a loop or switch" +msgstr "« break » est interdit en dehors d'une boucle ou d'un switch" + +#: awkgram.y:818 +msgid "`continue' is not allowed outside a loop" +msgstr "« continue » est interdit en dehors d'une boucle ou d'un switch" + +#: awkgram.y:828 +#, c-format +msgid "`next' used in %s action" +msgstr "« next » est utilisé dans l'action %s" + +#: awkgram.y:836 +msgid "`nextfile' is a gawk extension" +msgstr "« nextfile » est une extension gawk" + +#: awkgram.y:841 +#, c-format +msgid "`nextfile' used in %s action" +msgstr "« nextfile » est utilisé dans l'action %s" + +#: awkgram.y:865 +msgid "`return' used outside function context" +msgstr "« return » est utilisé hors du contexte d'une fonction" + +#: awkgram.y:925 +msgid "plain `print' in BEGIN or END rule should probably be `print \"\"'" +msgstr "" +"dans BEGIN ou END, un « print » seul devrait sans doute être un « print " +"\"\" »" + +#: awkgram.y:995 awkgram.y:999 awkgram.y:1023 +msgid "`delete array' is a gawk extension" +msgstr "« delete array » est une extension gawk" + +#: awkgram.y:1019 +msgid "`delete(array)' is a non-portable tawk extension" +msgstr "« delete(array) » est une extension non portable de tawk" + +#: awkgram.y:1135 +msgid "multistage two-way pipelines don't work" +msgstr "impossible d'utiliser des tubes bidirectionnels en série" + +#: awkgram.y:1238 +msgid "regular expression on right of assignment" +msgstr "expression rationnelle à droite d'une affectation" + +#: awkgram.y:1249 +msgid "regular expression on left of `~' or `!~' operator" +msgstr "expression rationnelle à gauche d'un opérateur « ~ » ou « !~ »" + +#: awkgram.y:1265 awkgram.y:1419 +msgid "old awk does not support the keyword `in' except after `for'" +msgstr "l'ancien awk n'autorise le mot-clef « in » qu'après « for »" + +#: awkgram.y:1275 +msgid "regular expression on right of comparison" +msgstr "expression rationnelle à droite d'une comparaison" + +#: awkgram.y:1394 +#, c-format +msgid "`getline var' invalid inside `%s' rule" +msgstr "« getline var » n'est pas valable dans une règle « %s »" + +#: awkgram.y:1397 eval.c:2504 +#, c-format +msgid "`getline' invalid inside `%s' rule" +msgstr "« getline » n'est pas valable dans une règle « %s »" + +#: awkgram.y:1402 +msgid "non-redirected `getline' undefined inside END action" +msgstr "dans une action END, un « getline » non redirigé n'est pas défini" + +#: awkgram.y:1421 +msgid "old awk does not support multidimensional arrays" +msgstr "l'ancien awk ne dispose pas des tableaux multidimensionnels" + +#: awkgram.y:1517 +msgid "call of `length' without parentheses is not portable" +msgstr "l'appel de « length » sans parenthèses n'est pas portable" + +#: awkgram.y:1580 +msgid "indirect function calls are a gawk extension" +msgstr "les appels indirects de fonctions sont une extension gawk" + +#: awkgram.y:1593 +#, c-format +msgid "can not use special variable `%s' for indirect function call" +msgstr "" +"impossible d'utiliser la variable spéciale « %s » pour un appel indirect de " +"fonction" + +#: awkgram.y:1671 +msgid "invalid subscript expression" +msgstr "expression indice non valide" + +#: awkgram.y:1711 +msgid "use of non-array as array" +msgstr "utilisation d'un non tableau comme tableau" + +#: awkgram.y:1975 awkgram.y:1995 msg.c:98 +msgid "warning: " +msgstr "avertissement : " + +#: awkgram.y:1993 msg.c:130 +msgid "fatal: " +msgstr "fatal : " + +#: awkgram.y:2043 +msgid "unexpected newline or end of string" +msgstr "fin de chaîne ou passage à la ligne inattendu" + +#: awkgram.y:2300 awkgram.y:2358 awkgram.y:2542 +#, c-format +msgid "can't open source file `%s' for reading (%s)" +msgstr "impossible d'ouvrir le fichier source « %s » en lecture (%s)" + +#: awkgram.y:2301 awkgram.y:2359 builtin.c:122 +msgid "reason unknown" +msgstr "raison inconnue" + +#: awkgram.y:2317 +#, c-format +msgid "already included source file `%s'" +msgstr "le fichier source « %s » a déjà été intégré" + +#: awkgram.y:2343 +msgid "@include is a gawk extension" +msgstr "@include est une extension gawk" + +#: awkgram.y:2349 +msgid "empty filename after @include" +msgstr "Le nom de fichier après @include est vide" + +#: awkgram.y:2494 +msgid "empty program text on command line" +msgstr "le programme indiqué en ligne de commande est vide" + +#: awkgram.y:2609 +#, c-format +msgid "can't read sourcefile `%s' (%s)" +msgstr "impossible de lire le fichier source « %s » (%s)" + +#: awkgram.y:2620 +#, c-format +msgid "source file `%s' is empty" +msgstr "le fichier source « %s » est vide" + +#: awkgram.y:2797 +msgid "source file does not end in newline" +msgstr "le fichier source ne se termine pas par un passage à la ligne" + +#: awkgram.y:2900 +msgid "unterminated regexp ends with `\\' at end of file" +msgstr "" +"expression rationnelle non refermée terminée par un « \\ » en fin de fichier" + +#: awkgram.y:2924 +#, c-format +msgid "%s: %d: tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "" +"%s : %d : le modificateur d'expressions rationnelles « /.../%c » de tawk ne " +"marche pas dans gawk" + +#: awkgram.y:2928 +#, c-format +msgid "tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "" +"le modificateur d'expressions rationnelles « /.../%c » de tawk ne marche pas " +"dans gawk" + +#: awkgram.y:2935 +msgid "unterminated regexp" +msgstr "expression rationnelle non refermée" + +#: awkgram.y:2939 +msgid "unterminated regexp at end of file" +msgstr "expression rationnelle non refermée en fin de fichier" + +#: awkgram.y:2998 +msgid "use of `\\ #...' line continuation is not portable" +msgstr "" +"l'utilisation de « \\ #... » pour prolonger une ligne n'est pas portable" + +#: awkgram.y:3014 +msgid "backslash not last character on line" +msgstr "la barre oblique inverse n'est pas le dernier caractère de la ligne" + +#: awkgram.y:3075 +msgid "POSIX does not allow operator `**='" +msgstr "POSIX n'autorise pas l'opérateur « **= »" + +#: awkgram.y:3077 +msgid "old awk does not support operator `**='" +msgstr "l'ancien awk ne dispose pas de l'opérateur « **= »" + +#: awkgram.y:3086 +msgid "POSIX does not allow operator `**'" +msgstr "POSIX n'autorise pas l'opérateur « ** »" + +#: awkgram.y:3088 +msgid "old awk does not support operator `**'" +msgstr "l'ancien awk ne dispose pas de l'opérateur « ** »" + +#: awkgram.y:3123 +msgid "operator `^=' is not supported in old awk" +msgstr "l'ancien awk ne dispose pas de l'opérateur « ^= »" + +#: awkgram.y:3131 +msgid "operator `^' is not supported in old awk" +msgstr "l'ancien awk ne dispose pas de l'opérateur « ^ »" + +#: awkgram.y:3224 awkgram.y:3240 +msgid "unterminated string" +msgstr "chaîne non refermée" + +#: awkgram.y:3436 +#, c-format +msgid "invalid char '%c' in expression" +msgstr "caractère non valide « %c » dans l'expression" + +#: awkgram.y:3483 +#, c-format +msgid "`%s' is a gawk extension" +msgstr "« %s » est une extension gawk" + +#: awkgram.y:3488 +#, c-format +msgid "`%s' is a Bell Labs extension" +msgstr "« %s » est une extension Bell Labs" + +#: awkgram.y:3493 +#, c-format +msgid "POSIX does not allow `%s'" +msgstr "POSIX n'autorise pas « %s »" + +#: awkgram.y:3501 +#, c-format +msgid "`%s' is not supported in old awk" +msgstr "l'ancien awk ne dispose pas de « %s »" + +#: awkgram.y:3568 +msgid "`goto' considered harmful!\n" +msgstr "« goto est jugé dangereux ! » (Edsger W. Dijkstra)\n" + +#: awkgram.y:3619 +#, c-format +msgid "%d is invalid as number of arguments for %s" +msgstr "%d n'est pas un nombre d'arguments valide de %s" + +#: awkgram.y:3654 +#, c-format +msgid "%s: string literal as last arg of substitute has no effect" +msgstr "" +"%s : une chaîne littérale en dernier argument d'une substitution est sans " +"effet" + +#: awkgram.y:3659 +#, c-format +msgid "%s third parameter is not a changeable object" +msgstr "le 3e paramètre de %s n'est pas un objet modifiable" + +#: awkgram.y:3732 awkgram.y:3735 +msgid "match: third argument is a gawk extension" +msgstr "match : le 3e argument est une extension gawk" + +#: awkgram.y:3789 awkgram.y:3792 +msgid "close: second argument is a gawk extension" +msgstr "close : le 2e argument est une extension gawk" + +#: awkgram.y:3804 +msgid "use of dcgettext(_\"...\") is incorrect: remove leading underscore" +msgstr "" +"utilisation incorrecte de dcgettext(_\"...\") : enlevez le souligné de tête" + +#: awkgram.y:3819 +msgid "use of dcngettext(_\"...\") is incorrect: remove leading underscore" +msgstr "" +"utilisation incorrecte de dcngettext(_\"...\") : enlevez le souligné de tête" + +#: awkgram.y:3911 +#, c-format +msgid "function `%s': parameter #%d, `%s', duplicates parameter #%d" +msgstr "" +"fonction « %s » : paramètre #%d, « %s » est un doublon du paramètre #%d" + +#: awkgram.y:3953 +#, c-format +msgid "function `%s': parameter `%s' shadows global variable" +msgstr "fonction « %s » : le paramètre « %s » masque la variable globale" + +#: awkgram.y:4111 +#, c-format +msgid "could not open `%s' for writing (%s)" +msgstr "impossible d'ouvrir « %s » en écriture (%s)" + +#: awkgram.y:4112 +msgid "sending variable list to standard error" +msgstr "envoi de la liste des variables vers la sortie d'erreur standard" + +#: awkgram.y:4118 +#, c-format +msgid "%s: close failed (%s)" +msgstr "%s : échec de la fermeture (%s)" + +#: awkgram.y:4170 +msgid "shadow_funcs() called twice!" +msgstr "shadows_funcs() a été appelé deux fois !" + +#: awkgram.y:4176 +msgid "there were shadowed variables." +msgstr "il y avait des variables masquées." + +#: awkgram.y:4206 +#, c-format +msgid "function `%s': can't use function name as parameter name" +msgstr "" +"fonction « %s » : impossible d'utiliser un nom de fonction comme paramètre" + +#: awkgram.y:4210 +#, c-format +msgid "function `%s': can't use special variable `%s' as a function parameter" +msgstr "" +"fonction « %s » : impossible d'utiliser la variable spéciale « %s » comme " +"paramètre d'une fonction" + +#: awkgram.y:4226 +#, c-format +msgid "function name `%s' previously defined" +msgstr "nom de fonction « %s » déjà défini" + +#: awkgram.y:4394 awkgram.y:4400 +#, c-format +msgid "function `%s' called but never defined" +msgstr "fonction « %s » appelée sans être définie" + +#: awkgram.y:4403 +#, c-format +msgid "function `%s' defined but never called directly" +msgstr "fonction « %s » définie mais jamais appelée directement" + +#: awkgram.y:4435 +#, c-format +msgid "regexp constant for parameter #%d yields boolean value" +msgstr "le paramètre #%d, une expr. rationnelle constante, fournit un booléen" + +#: awkgram.y:4544 +#, c-format +msgid "" +"function `%s' called with space between name and `(',\n" +"or used as a variable or an array" +msgstr "" +"fonction « %s » appelée avec un espace entre son nom\n" +"et « ( », ou utilisée comme variable ou tableau" + +#: awkgram.y:4791 eval.c:2056 +msgid "division by zero attempted" +msgstr "tentative de division par zéro" + +#: awkgram.y:4800 eval.c:2072 +#, c-format +msgid "division by zero attempted in `%%'" +msgstr "tentative de division par zéro dans « %% »" + +#: builtin.c:120 +#, c-format +msgid "%s to \"%s\" failed (%s)" +msgstr "échec de %s vers « %s » (%s)" + +#: builtin.c:121 +msgid "standard output" +msgstr "sortie standard" + +#: builtin.c:135 +msgid "exp: received non-numeric argument" +msgstr "exp : l'argument n'est pas numérique" + +#: builtin.c:141 +#, c-format +msgid "exp: argument %g is out of range" +msgstr "exp : l'argument %g est hors limite" + +#: builtin.c:200 +#, c-format +msgid "fflush: cannot flush: pipe `%s' opened for reading, not writing" +msgstr "" +"fflush : vidage impossible : le tube « %s » est ouvert en lecture et non en " +"écriture" + +#: builtin.c:203 +#, c-format +msgid "fflush: cannot flush: file `%s' opened for reading, not writing" +msgstr "" +"fflush : vidage impossible : fichier « %s » ouvert en lecture, pas en " +"écriture" + +#: builtin.c:215 +#, c-format +msgid "fflush: `%s' is not an open file, pipe or co-process" +msgstr "" +"fflush : « %s » n'est ni un fichier ouvert, ni un tube, ni un co-processus" + +#: builtin.c:333 +msgid "index: received non-string first argument" +msgstr "index : le premier argument n'est pas une chaîne" + +#: builtin.c:335 +msgid "index: received non-string second argument" +msgstr "index : le second argument n'est pas une chaîne" + +#: builtin.c:457 +msgid "int: received non-numeric argument" +msgstr "int : l'argument n'est pas numérique" + +#: builtin.c:493 +msgid "length: received array argument" +msgstr "length : l'argument reçu est un tableau" + +#: builtin.c:496 +msgid "`length(array)' is a gawk extension" +msgstr "« length(tableau) » est une extension gawk" + +#: builtin.c:504 +msgid "length: received non-string argument" +msgstr "length : l'argument n'est pas une chaîne" + +#: builtin.c:535 +msgid "log: received non-numeric argument" +msgstr "log : l'argument n'est pas numérique" + +#: builtin.c:538 +#, c-format +msgid "log: received negative argument %g" +msgstr "log : l'argument est négatif %g" + +#: builtin.c:694 builtin.c:699 +msgid "fatal: must use `count$' on all formats or none" +msgstr "" +"fatal : « numéro$ » doit être utilisé pour toutes les formats ou pour aucun" + +#: builtin.c:762 +#, c-format +msgid "field width is ignored for `%%' specifier" +msgstr "taille du champ de la spécification « %% » ignorée" + +#: builtin.c:764 +#, c-format +msgid "precision is ignored for `%%' specifier" +msgstr "précision de la spécification « %% » ignorée" + +#: builtin.c:766 +#, c-format +msgid "field width and precision are ignored for `%%' specifier" +msgstr "taille du champ et précision de la spécification « %% » ignorées" + +#: builtin.c:817 +msgid "fatal: `$' is not permitted in awk formats" +msgstr "fatal : « $ » n'est pas autorisé dans les formats awk" + +#: builtin.c:826 +msgid "fatal: arg count with `$' must be > 0" +msgstr "fatal : le numéro d'argument de « $ » doit être > 0" + +#: builtin.c:830 +#, c-format +msgid "fatal: arg count %ld greater than total number of supplied arguments" +msgstr "" +"fatal : le numéro d'argument %ld est > au nombre total d'arguments fournis" + +#: builtin.c:834 +msgid "fatal: `$' not permitted after period in format" +msgstr "fatal : dans un format, « $ » ne doit pas suivre un point" + +#: builtin.c:850 +msgid "fatal: no `$' supplied for positional field width or precision" +msgstr "" +"fatal : aucun « $ » fourni pour la taille ou la précision du champ positionné" + +#: builtin.c:921 +msgid "`l' is meaningless in awk formats; ignored" +msgstr "« l » n'a aucun sens dans un format awk ; ignoré" + +#: builtin.c:925 +msgid "fatal: `l' is not permitted in POSIX awk formats" +msgstr "fatal : « l » est interdit dans un format awk POSIX" + +#: builtin.c:938 +msgid "`L' is meaningless in awk formats; ignored" +msgstr "« L » n'a aucun sens dans un format awk ; ignoré" + +#: builtin.c:942 +msgid "fatal: `L' is not permitted in POSIX awk formats" +msgstr "fatal : « L » est interdit dans un format awk POSIX" + +#: builtin.c:955 +msgid "`h' is meaningless in awk formats; ignored" +msgstr "« h » n'a aucun sens dans un format awk ; ignoré" + +#: builtin.c:959 +msgid "fatal: `h' is not permitted in POSIX awk formats" +msgstr "fatal : « h » est interdit dans un format awk POSIX" + +#: builtin.c:1272 +#, c-format +msgid "[s]printf: value %g is out of range for `%%%c' format" +msgstr "[s]printf : valeur %g hors limite pour le format « %%%c »" + +#: builtin.c:1332 +#, c-format +msgid "ignoring unknown format specifier character `%c': no argument converted" +msgstr "caractère de format inconnu « %c » ignoré : aucun argument converti" + +#: builtin.c:1337 +msgid "fatal: not enough arguments to satisfy format string" +msgstr "fatal : pas assez d'arguments pour satisfaire la chaîne de formatage" + +#: builtin.c:1339 +msgid "^ ran out for this one" +msgstr "^ à court pour celui-ci" + +#: builtin.c:1346 +msgid "[s]printf: format specifier does not have control letter" +msgstr "[s]printf : spécification de format sans lettre de contrôle" + +#: builtin.c:1349 +msgid "too many arguments supplied for format string" +msgstr "trop d'arguments pour la chaîne de formatage" + +#: builtin.c:1423 builtin.c:1434 +msgid "printf: no arguments" +msgstr "printf : aucun argument" + +#: builtin.c:1475 +msgid "sqrt: received non-numeric argument" +msgstr "sqrt : l'argument n'est pas numérique" + +#: builtin.c:1479 +#, c-format +msgid "sqrt: called with negative argument %g" +msgstr "sqrt : appelé avec un argument négatif %g" + +#: builtin.c:1503 +#, c-format +msgid "substr: length %g is not >= 1" +msgstr "substr : la longueur %g n'est pas >= 1" + +#: builtin.c:1505 +#, c-format +msgid "substr: length %g is not >= 0" +msgstr "substr : la longueur %g n'est pas >= 0" + +#: builtin.c:1512 +#, c-format +msgid "substr: non-integer length %g will be truncated" +msgstr "substr : la longueur %g n'est pas entière, elle sera tronquée" + +#: builtin.c:1517 +#, c-format +msgid "substr: length %g too big for string indexing, truncating to %g" +msgstr "substr : la longueur %g est trop grande, tronquée à %g" + +#: builtin.c:1529 +#, c-format +msgid "substr: start index %g is invalid, using 1" +msgstr "substr : l'index de début %g n'est pas valide, utilisation de 1" + +#: builtin.c:1534 +#, c-format +msgid "substr: non-integer start index %g will be truncated" +msgstr "substr : l'index de début %g n'est pas un entier, il sera tronqué" + +#: builtin.c:1559 +msgid "substr: source string is zero length" +msgstr "substr : la chaîne source est de longueur nulle" + +#: builtin.c:1575 +#, c-format +msgid "substr: start index %g is past end of string" +msgstr "substr : l'index de début %g est au-delà de la fin de la chaîne" + +#: builtin.c:1583 +#, c-format +msgid "" +"substr: length %g at start index %g exceeds length of first argument (%lu)" +msgstr "" +"substr : la longueur %g à partir de %g dépasse la fin du 1er argument (%lu)" + +# Exemple : gawk --lint 'BEGIN { PROCINFO["strftime"]=123 ; print strftime() }' +#: builtin.c:1657 +msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" +msgstr "" +"strftime : la valeur de formatage PROCINFO[\"strftime\"] est de type " +"numérique" + +#: builtin.c:1680 +msgid "strftime: received non-numeric second argument" +msgstr "strftime : le second argument n'est pas numérique" + +#: builtin.c:1683 +msgid "strftime: second argument less than 0 or too big for time_t" +msgstr "strftime: second argument négatif ou trop grand pour time_t" + +#: builtin.c:1690 +msgid "strftime: received non-string first argument" +msgstr "strftim : le premier argument n'est pas une chaîne" + +#: builtin.c:1696 +msgid "strftime: received empty format string" +msgstr "strftime : la chaîne de formatage est vide" + +#: builtin.c:1762 +msgid "mktime: received non-string argument" +msgstr "mktime : l'argument n'est pas une chaîne" + +#: builtin.c:1779 +msgid "mktime: at least one of the values is out of the default range" +msgstr "" +"mktime : au moins l'une des valeurs est en dehors de la plage par défaut" + +#: builtin.c:1814 +msgid "'system' function not allowed in sandbox mode" +msgstr "La fonction « system » est interdite en isolement (mode sandbox)" + +#: builtin.c:1819 +msgid "system: received non-string argument" +msgstr "system : l'argument n'est pas une chaîne" + +#: builtin.c:1874 eval.c:1159 eval.c:1790 eval.c:1803 +#, c-format +msgid "reference to uninitialized variable `%s'" +msgstr "référence à une variable non initialisée « %s »" + +#: builtin.c:1941 +#, c-format +msgid "reference to uninitialized field `$%d'" +msgstr "référence à un champ non initialisé « $%d »" + +#: builtin.c:2028 +msgid "tolower: received non-string argument" +msgstr "tolower : l'argument n'est pas une chaîne" + +#: builtin.c:2062 +msgid "toupper: received non-string argument" +msgstr "toupper : l'argument n'est pas une chaîne" + +#: builtin.c:2098 +msgid "atan2: received non-numeric first argument" +msgstr "atan2 : le premier argument n'est pas numérique" + +#: builtin.c:2100 +msgid "atan2: received non-numeric second argument" +msgstr "atan2 : le second argument n'est pas numérique" + +#: builtin.c:2119 +msgid "sin: received non-numeric argument" +msgstr "sin : l'argument n'est pas numérique" + +#: builtin.c:2135 +msgid "cos: received non-numeric argument" +msgstr "cos : l'argument n'est pas numérique" + +#: builtin.c:2188 +msgid "srand: received non-numeric argument" +msgstr "srand : l'argument n'est pas numérique" + +#: builtin.c:2219 +msgid "match: third argument is not an array" +msgstr "match : le 3e argument n'est pas un tableau" + +#: builtin.c:2483 +msgid "gensub: third argument of 0 treated as 1" +msgstr "gensub : le 3e argument vaut 0, il sera traité comme un 1" + +#: builtin.c:2776 +msgid "lshift: received non-numeric first argument" +msgstr "lshift : le premier argument n'est pas numérique" + +#: builtin.c:2778 +msgid "lshift: received non-numeric second argument" +msgstr "lshift : le second argument reçu n'est pas numérique" + +#: builtin.c:2784 +#, c-format +msgid "lshift(%lf, %lf): negative values will give strange results" +msgstr "" +"lshift(%lf, %lf) : les valeurs négatives donneront des résultats inattendus" + +#: builtin.c:2786 +#, c-format +msgid "lshift(%lf, %lf): fractional values will be truncated" +msgstr "lshift(%lf, %lf) : les valeurs non entières seront tronquées" + +#: builtin.c:2788 +#, c-format +msgid "lshift(%lf, %lf): too large shift value will give strange results" +msgstr "" +"lshift(%lf, %lf) : un décalage trop grand donnera des résultats inattendus" + +#: builtin.c:2813 +msgid "rshift: received non-numeric first argument" +msgstr "rshift : le premier argument n'est pas numérique" + +#: builtin.c:2815 +msgid "rshift: received non-numeric second argument" +msgstr "rshift : le second argument reçu n'est pas numérique" + +#: builtin.c:2821 +#, c-format +msgid "rshift(%lf, %lf): negative values will give strange results" +msgstr "" +"rshift(%lf, %lf) : les valeurs négatives donneront des résultats inattendus" + +#: builtin.c:2823 +#, c-format +msgid "rshift(%lf, %lf): fractional values will be truncated" +msgstr "rshift(%lf, %lf) : les valeurs non entières seront tronquées" + +#: builtin.c:2825 +#, c-format +msgid "rshift(%lf, %lf): too large shift value will give strange results" +msgstr "" +"rshift(%lf, %lf) : un décalage trop grand donnera des résultats inattendus" + +#: builtin.c:2850 +msgid "and: received non-numeric first argument" +msgstr "and : le premier argument n'est pas numérique" + +#: builtin.c:2852 +msgid "and: received non-numeric second argument" +msgstr "and : le second argument reçu n'est pas numérique" + +#: builtin.c:2858 +#, c-format +msgid "and(%lf, %lf): negative values will give strange results" +msgstr "" +"and(%lf, %lf) : les valeurs négatives donneront des résultats inattendus" + +#: builtin.c:2860 +#, c-format +msgid "and(%lf, %lf): fractional values will be truncated" +msgstr "and(%lf, %lf): les valeurs non entières seront tronquées" + +#: builtin.c:2885 +msgid "or: received non-numeric first argument" +msgstr "or : le premier argument n'est pas numérique" + +#: builtin.c:2887 +msgid "or: received non-numeric second argument" +msgstr "or : le second argument reçu n'est pas numérique" + +#: builtin.c:2893 +#, c-format +msgid "or(%lf, %lf): negative values will give strange results" +msgstr "" +"or(%lf, %lf) : les valeurs négatives donneront des résultats inattendus" + +#: builtin.c:2895 +#, c-format +msgid "or(%lf, %lf): fractional values will be truncated" +msgstr "or(%lf, %lf) : les valeurs non entières seront tronquées" + +#: builtin.c:2923 +msgid "xor: received non-numeric first argument" +msgstr "xor : le premier argument n'est pas numérique" + +#: builtin.c:2925 +msgid "xor: received non-numeric second argument" +msgstr "xor : le second argument reçu n'est pas numérique" + +#: builtin.c:2931 +#, c-format +msgid "xor(%lf, %lf): negative values will give strange results" +msgstr "" +"xor(%lf, %lf) : les valeurs négatives donneront des résultats inattendus" + +#: builtin.c:2933 +#, c-format +msgid "xor(%lf, %lf): fractional values will be truncated" +msgstr "xor(%lf, %lf) : les valeurs non entières seront tronquées" + +#: builtin.c:2957 builtin.c:2963 +msgid "compl: received non-numeric argument" +msgstr "compl : l'argument n'est pas numérique" + +#: builtin.c:2965 +#, c-format +msgid "compl(%lf): negative value will give strange results" +msgstr "compl(%lf) : les valeurs négatives donneront des résultats inattendus" + +#: builtin.c:2967 +#, c-format +msgid "compl(%lf): fractional value will be truncated" +msgstr "compl(%lf) : les valeurs non entières seront tronquées" + +#: builtin.c:3136 +#, c-format +msgid "dcgettext: `%s' is not a valid locale category" +msgstr "dcgettext : « %s » n'est pas dans un catégorie valide de la locale" + +#: eval.c:412 +#, c-format +msgid "unknown nodetype %d" +msgstr "type de nœud %d inconnu" + +#: eval.c:423 eval.c:437 +#, c-format +msgid "unknown opcode %d" +msgstr "code opération %d inconnu" + +#: eval.c:434 +#, c-format +msgid "opcode %s not an operator or keyword" +msgstr "le code opération %s n'est pas un opérateur ou un mot-clef" + +#: eval.c:488 +msgid "buffer overflow in genflags2str" +msgstr "débordement de tampon dans genflag2str" + +#: eval.c:698 +#, c-format +msgid "" +"\n" +"\t# Function Call Stack:\n" +"\n" +msgstr "" +"\n" +"\t# Pile des appels de fonctions :\n" +"\n" + +#: eval.c:725 +msgid "`IGNORECASE' is a gawk extension" +msgstr "« IGNORECASE » est une extension gawk" + +#: eval.c:754 +msgid "`BINMODE' is a gawk extension" +msgstr "« BINMODE » est une extension gawk" + +#: eval.c:812 +#, c-format +msgid "BINMODE value `%s' is invalid, treated as 3" +msgstr "la valeur « %s » de BINMODE n'est pas valide, 3 utilisé à la place" + +#: eval.c:902 +#, c-format +msgid "bad `%sFMT' specification `%s'" +msgstr "spécification de « %sFMT » erronée « %s »" + +#: eval.c:980 +msgid "turning off `--lint' due to assignment to `LINT'" +msgstr "désactivation de « --lint » en raison d'une affectation à « LINT »" + +#: eval.c:1127 eval.c:1777 +#, c-format +msgid "can't use function name `%s' as variable or array" +msgstr "impossible d'utiliser la fonction « %s » comme variable ou tableau" + +#: eval.c:1158 eval.c:1789 eval.c:1802 +#, c-format +msgid "reference to uninitialized argument `%s'" +msgstr "référence à un argument non initialisé « %s »" + +#: eval.c:1177 +msgid "attempt to field reference from non-numeric value" +msgstr "tentative de référence à un champ via une valeur non numérique" + +#: eval.c:1179 +msgid "attempt to field reference from null string" +msgstr "tentative de référence à un champ via une chaîne nulle" + +#: eval.c:1185 +#, c-format +msgid "attempt to access field %ld" +msgstr "tentative d'accès au champ %ld" + +#: eval.c:1194 +#, c-format +msgid "reference to uninitialized field `$%ld'" +msgstr "référence à un champ non initialisé « $%ld »" + +#: eval.c:1256 +#, c-format +msgid "function `%s' called with more arguments than declared" +msgstr "la fonction « %s » a été appelée avec trop d'arguments" + +#: eval.c:1437 +#, c-format +msgid "unwind_stack: unexpected type `%s'" +msgstr "unwind_stack: type « %s » inattendu" + +#: eval.c:1532 +msgid "division by zero attempted in `/='" +msgstr "tentative de division par zéro dans « /= »" + +#: eval.c:1539 +#, c-format +msgid "division by zero attempted in `%%='" +msgstr "tentative de division par zéro dans « %%= »" + +#: eval.c:1876 eval.c:2122 +#, c-format +msgid "attempt to use array `%s[\"%.*s\"]' in a scalar context" +msgstr "" +"tentative d'utilisation du tableau « %s[\"%.*s\"] » dans un contexte scalaire" + +#: eval.c:1907 +msgid "assignment used in conditional context" +msgstr "affectation utilisée dans un contexte conditionnel" + +#: eval.c:1911 +msgid "statement has no effect" +msgstr "la déclaration est sans effet" + +#: eval.c:2343 +#, c-format +msgid "for loop: array `%s' changed size from %ld to %ld during loop execution" +msgstr "boucle for : la taille du tableau « %s » est passée de %ld à %ld" + +#: eval.c:2458 +#, c-format +msgid "function called indirectly through `%s' does not exist" +msgstr "la fonction indirectement appelée via « %s » n'existe pas" + +#: eval.c:2470 +#, c-format +msgid "function `%s' not defined" +msgstr "fonction « %s » non définie" + +#: eval.c:2511 +#, c-format +msgid "non-redirected `getline' invalid inside `%s' rule" +msgstr "un « getline » non redirigé n'est pas valable dans une règle « %s »" + +#: eval.c:2600 +#, c-format +msgid "error reading input file `%s': %s" +msgstr "erreur lors de la lecture du fichier en entrée « %s » : %s" + +#: eval.c:2614 +#, c-format +msgid "`nextfile' cannot be called from a `%s' rule" +msgstr "« nextfile » ne peut pas être appelé depuis une règle « %s »" + +#: eval.c:2661 +msgid "`exit' cannot be called in the current context" +msgstr "« exit » ne peut pas être appelé dans ce contexte" + +#: eval.c:2700 +#, c-format +msgid "`next' cannot be called from a `%s' rule" +msgstr "« next » ne peut pas être appelé depuis une règle « %s »" + +#: eval.c:2766 +#, c-format +msgid "Sorry, don't know how to interpret `%s'" +msgstr "Désolé, je ne sais pas comment interpréter « %s »" + +#: ext.c:54 +msgid "extensions are not allowed in sandbox mode" +msgstr "les extensions sont interdites en isolement (mode sandbox)" + +#: ext.c:60 ext.c:65 +msgid "`extension' is a gawk extension" +msgstr "« extension » est une extension gawk" + +#: ext.c:75 +#, c-format +msgid "fatal: extension: cannot open `%s' (%s)\n" +msgstr "fatal : extension : impossible d'ouvrir « %s » (%s)\n" + +#: ext.c:84 +#, c-format +msgid "" +"fatal: extension: library `%s': does not define " +"`plugin_is_GPL_compatible' (%s)\n" +msgstr "" +"fatal : extension : la bibliothèque « %s »ne définit pas " +"« plugin_is_GPL_compatible » (%s)\n" + +#: ext.c:93 +#, c-format +msgid "fatal: extension: library `%s': cannot call function `%s' (%s)\n" +msgstr "" +"fatal : extension : bibliothèque « %s » : impossible d'appeler la fonction " +"« %s » (%s)\n" + +#: ext.c:127 +msgid "extension: missing function name" +msgstr "extension : nom de fonction manquant" + +#: ext.c:132 +#, c-format +msgid "extension: illegal character `%c' in function name `%s'" +msgstr "extension : caractère illégal « %c » dans le nom de la fonction « %s »" + +#: ext.c:141 +#, c-format +msgid "extension: can't redefine function `%s'" +msgstr "extension : impossible de redéfinir la fonction « %s »" + +#: ext.c:145 +#, c-format +msgid "extension: function `%s' already defined" +msgstr "extension : fonction « %s » est déjà définie" + +#: ext.c:150 +#, c-format +msgid "extension: function name `%s' previously defined" +msgstr "extension : nom de la fonction « %s » déjà défini" + +#: ext.c:152 +#, c-format +msgid "extension: can't use gawk built-in `%s' as function name" +msgstr "" +"extension : impossible d'utiliser la fonction interne gawk « %s » comme nom " +"de fonction" + +#: ext.c:156 +#, c-format +msgid "make_builtin: negative argument count for function `%s'" +msgstr "make_builtin : la fonction « %s » a un nombre négatif d'arguments" + +#: ext.c:259 +#, c-format +msgid "function `%s' defined to take no more than %d argument(s)" +msgstr "fonction « %s » définie comme ayant au maximum« %d » argument(s)" + +#: ext.c:262 +#, c-format +msgid "function `%s': missing argument #%d" +msgstr "fonction « %s » : argument #%d manquant" + +#: ext.c:279 +#, c-format +msgid "function `%s': argument #%d: attempt to use scalar as an array" +msgstr "" +"fonction « %s » : argument #%d : tentative d'utilisation d'un scalaire comme " +"tableau" + +#: ext.c:283 +#, c-format +msgid "function `%s': argument #%d: attempt to use array as a scalar" +msgstr "" +"fonction « %s » : argument #%d : tentative d'utiliser un tableau comme " +"scalaire" + +#: ext.c:296 +msgid "Operation Not Supported" +msgstr "Opération non disponible" + +#: field.c:328 +msgid "NF set to negative value" +msgstr "une valeur négative a été assignée à NF" + +#: field.c:951 field.c:958 field.c:962 +msgid "split: fourth argument is a gawk extension" +msgstr "split : le 4e argument est une extension gawk" + +#: field.c:955 +msgid "split: fourth argument is not an array" +msgstr "split : le 4e argument n'est pas un tableau" + +#: field.c:969 +msgid "split: second argument is not an array" +msgstr "split : le 2e argument n'est pas un tableau" + +#: field.c:973 +msgid "split: cannot use the same array for second and fourth args" +msgstr "split : impossible d'utiliser le même tableau comme 2e et 4e argument" + +#: field.c:978 +msgid "split: cannot use a subarray of second arg for fourth arg" +msgstr "" +"split : impossible d'utiliser un sous-tableau du 2e argument en 4e argument" + +#: field.c:981 +msgid "split: cannot use a subarray of fourth arg for second arg" +msgstr "" +"split : impossible d'utiliser un sous-tableau du 4e argument en 2e argument" + +#: field.c:1010 +msgid "split: null string for third arg is a gawk extension" +msgstr "split : utiliser une chaîne vide en 3e argument est une extension gawk" + +#: field.c:1050 +msgid "patsplit: fourth argument is not an array" +msgstr "patsplit : le 4e argument n'est pas un tableau" + +#: field.c:1055 +msgid "patsplit: second argument is not an array" +msgstr "patsplit : le 2e argument n'est pas un tableau" + +#: field.c:1061 +msgid "patsplit: third argument must be non-null" +msgstr "patsplit : le 3e argument n'est pas un tableau" + +#: field.c:1065 +msgid "patsplit: cannot use the same array for second and fourth args" +msgstr "" +"patsplit : impossible d'utiliser le même tableau comme 2e et 4e argument" + +#: field.c:1070 +msgid "patsplit: cannot use a subarray of second arg for fourth arg" +msgstr "" +"patsplit : impossible d'utiliser un sous-tableau du 2e argument en 4e " +"argument" + +#: field.c:1073 +msgid "patsplit: cannot use a subarray of fourth arg for second arg" +msgstr "" +"patsplit : impossible d'utiliser un sous-tableau du 4e argument en 2e " +"argument" + +#: field.c:1110 +msgid "`FIELDWIDTHS' is a gawk extension" +msgstr "« FIELDWIDTHS » est une extension gawk" + +#: field.c:1173 +#, c-format +msgid "invalid FIELDWIDTHS value, near `%s'" +msgstr "valeur de FIELDWIDTHS non valide, près de « %s »" + +#: field.c:1246 +msgid "null string for `FS' is a gawk extension" +msgstr "utiliser une chaîne vide pour « FS » est une extension gawk" + +#: field.c:1250 +msgid "old awk does not support regexps as value of `FS'" +msgstr "" +"l'ancien awk n'accepte pas les expr. rationnelles comme valeur de « FS »" + +#: field.c:1369 +msgid "`FPAT' is a gawk extension" +msgstr "« FPAT » est une extension gawk" + +#: getopt.c:604 getopt.c:633 +#, fuzzy, c-format +msgid "%s: option '%s' is ambiguous; possibilities:" +msgstr "%s : l'option « %s » est ambiguë\n" + +#: getopt.c:679 getopt.c:683 +#, c-format +msgid "%s: option '--%s' doesn't allow an argument\n" +msgstr "%s : l'option « --%s » n'accepte pas d'argument\n" + +#: getopt.c:692 getopt.c:697 +#, c-format +msgid "%s: option '%c%s' doesn't allow an argument\n" +msgstr "%s : l'option « %c%s » n'accepte pas d'argument\n" + +#: getopt.c:740 getopt.c:759 +#, c-format +msgid "%s: option '--%s' requires an argument\n" +msgstr "%s : l'option « --%s » nécessite un argument\n" + +#: getopt.c:797 getopt.c:800 +#, c-format +msgid "%s: unrecognized option '--%s'\n" +msgstr "%s : option non reconnue « --%s »\n" + +#: getopt.c:808 getopt.c:811 +#, c-format +msgid "%s: unrecognized option '%c%s'\n" +msgstr "%s : option non reconnue « %c%s »\n" + +#: getopt.c:860 getopt.c:863 +#, c-format +msgid "%s: invalid option -- '%c'\n" +msgstr "%s : option non valide -- « %c »\n" + +#: getopt.c:916 getopt.c:933 getopt.c:1143 getopt.c:1161 +#, c-format +msgid "%s: option requires an argument -- '%c'\n" +msgstr "%s : l'option requiert un argument -- « %c »\n" + +#: getopt.c:989 getopt.c:1005 +#, c-format +msgid "%s: option '-W %s' is ambiguous\n" +msgstr "%s : l'option « -W %s » est ambiguë\n" + +#: getopt.c:1029 getopt.c:1047 +#, c-format +msgid "%s: option '-W %s' doesn't allow an argument\n" +msgstr "%s : l'option « -W %s » n'accepte pas d'argument\n" + +#: getopt.c:1068 getopt.c:1086 +#, c-format +msgid "%s: option '-W %s' requires an argument\n" +msgstr "%s : l'option « -W %s » nécessite un argument\n" + +#: io.c:280 +#, c-format +msgid "command line argument `%s' is a directory: skipped" +msgstr "L'argument « %s » de la ligne de commande est un répertoire : ignoré" + +#: io.c:283 io.c:385 +#, c-format +msgid "cannot open file `%s' for reading (%s)" +msgstr "impossible d'ouvrir le fichier « %s » en lecture (%s)" + +#: io.c:501 +#, c-format +msgid "close of fd %d (`%s') failed (%s)" +msgstr "échec de la fermeture du fd %d (« %s ») : %s" + +#: io.c:578 +msgid "redirection not allowed in sandbox mode" +msgstr "les redirections sont interdites en isolement (mode sandbox)" + +#: io.c:612 +#, c-format +msgid "expression in `%s' redirection only has numeric value" +msgstr "l'expression dans la redirection « %s » n'a qu'une valeur numérique" + +#: io.c:618 +#, c-format +msgid "expression for `%s' redirection has null string value" +msgstr "l'expression dans la redirection « %s » donne une chaîne nulle" + +#: io.c:623 +#, c-format +msgid "filename `%s' for `%s' redirection may be result of logical expression" +msgstr "" +"le fichier « %s » de la redirection « %s » pourrait être le résultat d'une " +"expression booléenne" + +#: io.c:666 +#, c-format +msgid "unnecessary mixing of `>' and `>>' for file `%.*s'" +msgstr "mélange non nécessaire de « > » et « >> » pour le fichier « %.*s »" + +#: io.c:719 +#, c-format +msgid "can't open pipe `%s' for output (%s)" +msgstr "impossible d'ouvrir le tube « %s » en sortie (%s)" + +#: io.c:729 +#, c-format +msgid "can't open pipe `%s' for input (%s)" +msgstr "impossible d'ouvrir le tube « %s » en entrée (%s)" + +#: io.c:752 +#, c-format +msgid "can't open two way pipe `%s' for input/output (%s)" +msgstr "" +"impossible d'ouvrir un tube bidirectionnel « %s » en entrées-sorties (%s)" + +#: io.c:834 +#, c-format +msgid "can't redirect from `%s' (%s)" +msgstr "impossible de rediriger depuis « %s » (%s)" + +#: io.c:837 +#, c-format +msgid "can't redirect to `%s' (%s)" +msgstr "impossible de rediriger vers « %s » (%s)" + +#: io.c:888 +msgid "" +"reached system limit for open files: starting to multiplex file descriptors" +msgstr "" +"limite système du nombre de fichiers ouverts atteinte : début du " +"multiplexage des descripteurs de fichiers" + +#: io.c:904 +#, c-format +msgid "close of `%s' failed (%s)." +msgstr "échec de la fermeture de « %s » (%s)" + +#: io.c:912 +msgid "too many pipes or input files open" +msgstr "trop de fichiers d'entrées ou de tubes ouverts" + +#: io.c:934 +msgid "close: second argument must be `to' or `from'" +msgstr "close : le second argument doit être « to » ou « from »" + +#: io.c:951 +#, c-format +msgid "close: `%.*s' is not an open file, pipe or co-process" +msgstr "" +"close : « %.*s » n'est ni un fichier ouvert, ni un tube ou un co-processus" + +#: io.c:956 +msgid "close of redirection that was never opened" +msgstr "fermeture d'une redirection qui n'a jamais été ouverte" + +#: io.c:1053 +#, c-format +msgid "close: redirection `%s' not opened with `|&', second argument ignored" +msgstr "" +"close : la redirection « %s » n'a pas été ouverte avec « |& », second " +"argument ignoré" + +#: io.c:1069 +#, c-format +msgid "failure status (%d) on pipe close of `%s' (%s)" +msgstr "résultat d'échec (%d) sur la fermeture du tube « %s » (%s)" + +#: io.c:1072 +#, c-format +msgid "failure status (%d) on file close of `%s' (%s)" +msgstr "résultat d'échec (%d) sur la fermeture du fichier « %s » (%s)" + +#: io.c:1092 +#, c-format +msgid "no explicit close of socket `%s' provided" +msgstr "aucune fermeture explicite du connecteur « %s » fournie" + +#: io.c:1095 +#, c-format +msgid "no explicit close of co-process `%s' provided" +msgstr "aucune fermeture explicite du co-processus « %s » fournie" + +#: io.c:1098 +#, c-format +msgid "no explicit close of pipe `%s' provided" +msgstr "aucune fermeture explicite du tube « %s » fournie" + +#: io.c:1101 +#, c-format +msgid "no explicit close of file `%s' provided" +msgstr "aucune fermeture explicite du fichier « %s » fournie" + +#: io.c:1129 io.c:1184 main.c:794 main.c:831 +#, c-format +msgid "error writing standard output (%s)" +msgstr "erreur lors de l'écriture vers la sortie standard (%s)" + +#: io.c:1133 io.c:1189 +#, c-format +msgid "error writing standard error (%s)" +msgstr "erreur lors de l'écriture vers l'erreur standard (%s)" + +#: io.c:1141 +#, c-format +msgid "pipe flush of `%s' failed (%s)." +msgstr "échec du vidage du tube « %s » (%s)." + +#: io.c:1144 +#, c-format +msgid "co-process flush of pipe to `%s' failed (%s)." +msgstr "échec du vidage du tube vers « %s » par le co-processus (%s)." + +#: io.c:1147 +#, c-format +msgid "file flush of `%s' failed (%s)." +msgstr "échec du vidage vers le fichier « %s » (%s)" + +#: io.c:1262 +#, c-format +msgid "local port %s invalid in `/inet'" +msgstr "le port local %s n'est pas valide dans « /inet »" + +#: io.c:1279 +#, c-format +msgid "remote host and port information (%s, %s) invalid" +msgstr "" +"les informations sur l'hôte et le port distants (%s, %s) ne sont pas valides" + +#: io.c:1431 +#, c-format +msgid "no (known) protocol supplied in special filename `%s'" +msgstr "" +"aucun protocole (connu) n'a été fourni dans le nom de fichier spécial « %s »" + +#: io.c:1445 +#, c-format +msgid "special file name `%s' is incomplete" +msgstr "nom de fichier spécial « %s » incomplet" + +#: io.c:1462 +msgid "must supply a remote hostname to `/inet'" +msgstr "un nom d'hôte distant doit être fourni à « /inet »" + +#: io.c:1480 +msgid "must supply a remote port to `/inet'" +msgstr "un port distant doit être fourni à « /inet »" + +#: io.c:1526 +msgid "TCP/IP communications are not supported" +msgstr "les communications TCP/IP ne sont pas disponibles" + +#: io.c:1693 +#, c-format +msgid "could not open `%s', mode `%s'" +msgstr "impossible d'ouvrir « %s », mode « %s »" + +#: io.c:1747 +#, c-format +msgid "close of master pty failed (%s)" +msgstr "échec de la fermeture du pty maître (%s)" + +#: io.c:1749 io.c:1917 io.c:2074 +#, c-format +msgid "close of stdout in child failed (%s)" +msgstr "échec de la fermeture de stdout du processus fils (%s)" + +#: io.c:1752 +#, c-format +msgid "moving slave pty to stdout in child failed (dup: %s)" +msgstr "" +"échec du déplacement du pty esclave vers le stdout du processus fils (dup : " +"%s)" + +#: io.c:1754 io.c:1922 +#, c-format +msgid "close of stdin in child failed (%s)" +msgstr "échec de fermeture du stdin du processus fils (%s)" + +#: io.c:1757 +#, c-format +msgid "moving slave pty to stdin in child failed (dup: %s)" +msgstr "" +"échec du déplacement du pty esclave vers le stdin du processus fils (dup : " +"%s)" + +#: io.c:1759 io.c:1780 +#, c-format +msgid "close of slave pty failed (%s)" +msgstr "échec de la fermeture du pty esclave (%s)" + +#: io.c:1858 io.c:1920 io.c:2052 io.c:2077 +#, c-format +msgid "moving pipe to stdout in child failed (dup: %s)" +msgstr "échec du déplacement du tube vers stdout du processus fils (dup : %s)" + +#: io.c:1865 io.c:1925 +#, c-format +msgid "moving pipe to stdin in child failed (dup: %s)" +msgstr "échec de déplacement du tube vers stdin du processus fils (dup : %s)" + +#: io.c:1885 io.c:2067 +msgid "restoring stdout in parent process failed\n" +msgstr "échec de la restauration du stdout dans le processus parent\n" + +#: io.c:1893 +msgid "restoring stdin in parent process failed\n" +msgstr "échec de la restauration du stdin dans le processus parent\n" + +#: io.c:1928 io.c:2079 io.c:2093 +#, c-format +msgid "close of pipe failed (%s)" +msgstr "échec de la fermeture du tube (%s)" + +#: io.c:1973 +msgid "`|&' not supported" +msgstr "« |& » non disponible" + +#: io.c:2039 +#, c-format +msgid "cannot open pipe `%s' (%s)" +msgstr "impossible d'ouvrir le tube « %s » (%s)" + +#: io.c:2087 +#, c-format +msgid "cannot create child process for `%s' (fork: %s)" +msgstr "impossible de créer le processus fils pour « %s » (fork : %s)" + +#: io.c:2520 +#, c-format +msgid "data file `%s' is empty" +msgstr "le fichier de données « %s » est vide" + +#: io.c:2561 io.c:2569 +msgid "could not allocate more input memory" +msgstr "impossible d'allouer plus de mémoire d'entrée" + +#: io.c:3127 +msgid "multicharacter value of `RS' is a gawk extension" +msgstr "" +"l'utilisation d'un « RS » de plusieurs caractères est une extension gawk" + +#: io.c:3232 +msgid "IPv6 communication is not supported" +msgstr "les communications IPv6 ne sont pas disponibles" + +#: main.c:366 +msgid "`-m[fr]' option irrelevant in gawk" +msgstr "l'option « -m[fr] » n'est pas pertinente en gawk" + +#: main.c:368 +msgid "-m option usage: `-m[fr] nnn'" +msgstr "utilisation de l'option « -m » : « -m[fr] nnn »" + +#: main.c:391 +msgid "empty argument to `-e/--source' ignored" +msgstr "argument vide de l'option « -e / --source » ignoré" + +#: main.c:462 +#, c-format +msgid "%s: option `-W %s' unrecognized, ignored\n" +msgstr "%s : option « -W %s » non reconnue, ignorée\n" + +#: main.c:515 +#, c-format +msgid "%s: option requires an argument -- %c\n" +msgstr "%s : l'option requiert un argument -- %c\n" + +#: main.c:536 +msgid "environment variable `POSIXLY_CORRECT' set: turning on `--posix'" +msgstr "" +"variable d'environnement « POSIXLY__CORRECT » définie : activation de « --" +"posix »" + +#: main.c:542 +msgid "`--posix' overrides `--traditional'" +msgstr "« --posix » prend le pas sur « --traditional »" + +#: main.c:553 +msgid "`--posix'/`--traditional' overrides `--non-decimal-data'" +msgstr "" +"« --posix » et « --traditional » prennent le pas sur « --non-decimal-data »" + +#: main.c:557 +#, c-format +msgid "running %s setuid root may be a security problem" +msgstr "" +"l'exécution de %s en mode setuid root peut être un problème de sécurité" + +#: main.c:562 +msgid "`--posix' overrides `--binary'" +msgstr "« --posix » prend le pas sur « --binary »" + +#: main.c:613 +#, c-format +msgid "can't set binary mode on stdin (%s)" +msgstr "impossible d'activer le mode binaire sur stdin (%s)" + +#: main.c:616 +#, c-format +msgid "can't set binary mode on stdout (%s)" +msgstr "impossible d'activer le mode binaire sur stdout (%s)" + +#: main.c:618 +#, c-format +msgid "can't set binary mode on stderr (%s)" +msgstr "impossible d'activer le mode binaire sur stderr (%s)" + +#: main.c:657 +msgid "no program text at all!" +msgstr "aucun programme !" + +#: main.c:734 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] -f progfile [--] file ...\n" +msgstr "" +"Utilisation : %s [options GNU ou POSIX] -f fichier_prog [--] fichier ...\n" + +#: main.c:736 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] [--] %cprogram%c file ...\n" +msgstr "" +"Utilisation : %s [options GNU ou POSIX] [--] %cprogramme%c fichier ...\n" + +#: main.c:741 +msgid "POSIX options:\t\tGNU long options: (standard)\n" +msgstr "Options POSIX :\t\tOptions longues GNU : (standard)\n" + +#: main.c:742 +msgid "\t-f progfile\t\t--file=progfile\n" +msgstr "\t-f fichier_prog\t\t--file=fichier_prog\n" + +#: main.c:743 +msgid "\t-F fs\t\t\t--field-separator=fs\n" +msgstr "\t-F fs\t\t\t--field-separator=fs\n" + +#: main.c:744 +msgid "\t-v var=val\t\t--assign=var=val\n" +msgstr "\t-v var=valeur\t\t--assign=var=valeur\n" + +#: main.c:745 +msgid "Short options:\t\tGNU long options: (extensions)\n" +msgstr "Options POSIX :\t\tOptions longues GNU : (extensions)\n" + +#: main.c:746 +msgid "\t-b\t\t\t--characters-as-bytes\n" +msgstr "\t-b\t\t\t--characters-as-bytes\n" + +#: main.c:747 +msgid "\t-c\t\t\t--traditional\n" +msgstr "\t-c\t\t\t--traditional\n" + +#: main.c:748 +msgid "\t-C\t\t\t--copyright\n" +msgstr "\t-C\t\t\t--copyright\n" + +#: main.c:749 +msgid "\t-d[file]\t\t--dump-variables[=file]\n" +msgstr "\t-d[fichier]\t\t--dump-variables[=fichier]\n" + +#: main.c:750 +msgid "\t-e 'program-text'\t--source='program-text'\n" +msgstr "\t-e 'programme'\t\t--source='programme'\n" + +#: main.c:751 +msgid "\t-E file\t\t\t--exec=file\n" +msgstr "\t-E fichier\t\t--exec=fichier\n" + +#: main.c:752 +msgid "\t-g\t\t\t--gen-pot\n" +msgstr "\t-g\t\t\t--gen-pot\n" + +#: main.c:753 +msgid "\t-h\t\t\t--help\n" +msgstr "\t-h\t\t\t--help\n" + +#: main.c:754 +msgid "\t-L [fatal]\t\t--lint[=fatal]\n" +msgstr "\t-L [fatal]\t\t--lint[=fatal]\n" + +#: main.c:755 +msgid "\t-n\t\t\t--non-decimal-data\n" +msgstr "\t-n\t\t\t--non-decimal-data\n" + +#: main.c:756 +msgid "\t-N\t\t\t--use-lc-numeric\n" +msgstr "\t-N\t\t\t--use-lc-numeric\n" + +#: main.c:757 +msgid "\t-O\t\t\t--optimize\n" +msgstr "\t-O\t\t\t--optimize\n" + +#: main.c:758 +msgid "\t-p[file]\t\t--profile[=file]\n" +msgstr "\t-p[fichier]\t\t--profile[=fichier]\n" + +#: main.c:759 +msgid "\t-P\t\t\t--posix\n" +msgstr "\t-P\t\t\t--posix\n" + +#: main.c:760 +msgid "\t-r\t\t\t--re-interval\n" +msgstr "\t-r\t\t\t--re-interval\n" + +#: main.c:762 +msgid "\t-R file\t\t\t--command=file\n" +msgstr "\t-R fichier\t\t\t--command=fichier\n" + +#: main.c:763 +msgid "\t-S\t\t\t--sandbox\n" +msgstr "\t-S\t\t\t--sandbox\n" + +#: main.c:764 +msgid "\t-t\t\t\t--lint-old\n" +msgstr "\t-t\t\t\t--lint-old\n" + +#: main.c:765 +msgid "\t-V\t\t\t--version\n" +msgstr "\t-V\t\t\t--version\n" + +#: main.c:767 +msgid "\t-W nostalgia\t\t--nostalgia\n" +msgstr "\t-W nostalgia\t\t--nostalgia\n" + +#: main.c:770 +msgid "\t-Y\t\t--parsedebug\n" +msgstr "\t-Y\t\t--parsedebug\n" + +#. TRANSLATORS: --help output 5 (end) +#. TRANSLATORS: the placeholder indicates the bug-reporting address +#. for this application. Please add _another line_ with the +#. address for translation bugs. +#. no-wrap +#: main.c:779 +msgid "" +"\n" +"To report bugs, see node `Bugs' in `gawk.info', which is\n" +"section `Reporting Problems and Bugs' in the printed version.\n" +"\n" +msgstr "" +"\n" +"Pour signaler une anomalie, consultez la section « Bugs » du fichier\n" +"« gawk.info », qui est dans la section « Reporting Problems and Bugs »\n" +"de la version imprimée.\n" +"Pour signaler une erreur de traduction, envoyez un message à la liste\n" +".\n" +"\n" + +#: main.c:783 +msgid "" +"gawk is a pattern scanning and processing language.\n" +"By default it reads standard input and writes standard output.\n" +"\n" +msgstr "" +"gawk est un langage de recherche et de traitement des motifs.\n" +"Par défaut, il lit l'entrée standard et écrit sur la sortie standard.\n" +"\n" + +#: main.c:787 +msgid "" +"Examples:\n" +"\tgawk '{ sum += $1 }; END { print sum }' file\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" +msgstr "" +"Exemples :\n" +"\tgawk '{ somme += $1 }; END { print somme }' fichier\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" + +#: main.c:807 +#, c-format +msgid "" +"Copyright (C) 1989, 1991-%d Free Software Foundation.\n" +"\n" +"This program is free software; you can redistribute it and/or modify\n" +"it under the terms of the GNU General Public License as published by\n" +"the Free Software Foundation; either version 3 of the License, or\n" +"(at your option) any later version.\n" +"\n" +msgstr "" +"Copyright © 1998, 1991-%d Free Software Foundation.\n" +"\n" +"Ce programme est un logiciel libre ; vous pouvez le redistribuer et le\n" +"modifier selon les termes de la licence publique générale GNU (GNU\n" +"General Public License), telle que publiée par la Free Software\n" +"Foundation ; soit selon la version 3 de cette licence, soit selon une\n" +"version ultérieure de votre choix.\n" +"\n" + +#: main.c:815 +msgid "" +"This program is distributed in the hope that it will be useful,\n" +"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +"GNU General Public License for more details.\n" +"\n" +msgstr "" +"Ce logiciel est distribué en espérant qu'il sera utile, mais SANS AUCUNE\n" +"GARANTIE, y compris les garanties implicites D'ADAPTATION À UN BUT\n" +"SPÉCIFIQUE et de COMMERCIALISATION. Pour plus d'informations à ce\n" +"sujet, consultez le texte de la licence publique générale GNU (GNU\n" +"General Public License).\n" +"\n" + +#: main.c:821 +msgid "" +"You should have received a copy of the GNU General Public License\n" +"along with this program. If not, see http://www.gnu.org/licenses/.\n" +msgstr "" +"Vous devriez avoir reçu copie de la licence publique générale GNU\n" +"(GNU General Public License) avec ce programme. Sinon, consultez\n" +"http://www.gnu.org/licenses/.\n" + +#: main.c:856 +msgid "-Ft does not set FS to tab in POSIX awk" +msgstr "-Ft ne définit pas le FS comme étant une tabulation en awk POSIX" + +#: main.c:1090 +#, c-format +msgid "unknown value for field spec: %d\n" +msgstr "valeur inconnue pour la définition de champ : %d\n" + +#: main.c:1171 +#, c-format +msgid "" +"%s: `%s' argument to `-v' not in `var=value' form\n" +"\n" +msgstr "" +"%s : « %s » l'argument de « -v » ne respecte pas la forme « var=valeur »\n" +"\n" + +#: main.c:1197 +#, c-format +msgid "`%s' is not a legal variable name" +msgstr "« %s » n'est pas un nom de variable valide" + +#: main.c:1200 +#, c-format +msgid "`%s' is not a variable name, looking for file `%s=%s'" +msgstr "« %s » n'est pas un nom de variable, recherche du fichier « %s=%s »" + +#: main.c:1204 +#, c-format +msgid "cannot use gawk builtin `%s' as variable name" +msgstr "impossible d'utiliser le mot clef gawk « %s » comme variable" + +#: main.c:1209 +#, c-format +msgid "cannot use function `%s' as variable name" +msgstr "impossible d'utiliser la fonction « %s » comme variable" + +#: main.c:1262 +msgid "floating point exception" +msgstr "exception du traitement en virgule flottante" + +#: main.c:1269 +msgid "fatal error: internal error" +msgstr "fatal : erreur interne" + +#: main.c:1284 +msgid "fatal error: internal error: segfault" +msgstr "fatal : erreur interne : erreur de segmentation" + +#: main.c:1296 +msgid "fatal error: internal error: stack overflow" +msgstr "fatal : erreur interne : débordement de la pile" + +#: main.c:1346 +#, c-format +msgid "no pre-opened fd %d" +msgstr "aucun descripteur fd %d pré-ouvert" + +#: main.c:1353 +#, c-format +msgid "could not pre-open /dev/null for fd %d" +msgstr "impossible de pré-ouvrir /dev/null pour le descripteud fd %d" + +#: msg.c:63 +#, c-format +msgid "cmd. line:" +msgstr "ligne de commande:" + +#: msg.c:107 +msgid "error: " +msgstr "erreur : " + +#: node.c:406 +msgid "backslash at end of string" +msgstr "barre oblique inverse à la fin de la chaîne" + +#: node.c:517 +#, c-format +msgid "old awk does not support the `\\%c' escape sequence" +msgstr "l'ancien awk ne dispose pas de la séquence d'échappement « \\%c »" + +#: node.c:568 +msgid "POSIX does not allow `\\x' escapes" +msgstr "POSIX n'autorise pas les séquences d'échappement « \\x »" + +#: node.c:574 +msgid "no hex digits in `\\x' escape sequence" +msgstr "aucun chiffre hexadécimal dans la séquence d'échappement « \\x » " + +#: node.c:596 +#, c-format +msgid "" +"hex escape \\x%.*s of %d characters probably not interpreted the way you " +"expect" +msgstr "" +"la séquence d'échappement hexa. \\x%.*s de %d caractères ne sera " +"probablement pas interprétée comme vous l'imaginez" + +#: node.c:611 +#, c-format +msgid "escape sequence `\\%c' treated as plain `%c'" +msgstr "séquence d'échappement « \\%c » traitée comme un simple « %c »" + +#: node.c:750 +msgid "" +"Invalid multibyte data detected. There may be a mismatch between your data " +"and your locale." +msgstr "" +"Données multioctets non valables détectées. Possible incohérence entre " +"données et paramètres régionaux (locale)." + +#: posix/gawkmisc.c:176 +#, c-format +msgid "%s %s `%s': could not get fd flags: (fcntl F_GETFD: %s)" +msgstr "" +"%s %s « %s » : impossible d'obtenir les drapeaux du fd : (fcntl F_GETFD: %s)" + +#: posix/gawkmisc.c:188 +#, c-format +msgid "%s %s `%s': could not set close-on-exec: (fcntl F_SETFD: %s)" +msgstr "" +"%s %s « %s »: impossible de positionner close-on-exec: (fcntl F_SETFD: %s)" + +#: profile.c:83 +#, c-format +msgid "could not open `%s' for writing: %s" +msgstr "impossible d'ouvrir « %s » en écriture : %s" + +#: profile.c:85 +msgid "sending profile to standard error" +msgstr "envoi du profil vers la sortie d'erreur standard" + +#: profile.c:203 +#, c-format +msgid "" +"\t# %s block(s)\n" +"\n" +msgstr "" +"\t# Bloc(s) %s\n" +"\n" + +#: profile.c:208 +#, c-format +msgid "" +"\t# Rule(s)\n" +"\n" +msgstr "" +"\t# Règle(s)\n" +"\n" + +#: profile.c:279 +#, c-format +msgid "internal error: %s with null vname" +msgstr "erreur interne : %s avec un vname nul" + +#: profile.c:952 +#, c-format +msgid "\t# gawk profile, created %s\n" +msgstr "\t# profile gawk, créé %s\n" + +#: profile.c:1331 +#, c-format +msgid "" +"\n" +"\t# Functions, listed alphabetically\n" +msgstr "" +"\n" +"\t# Fonctions, par ordre alphabétique\n" + +#: profile.c:1370 +#, c-format +msgid "redir2str: unknown redirection type %d" +msgstr "redir2str : type de redirection %d inconnu" + +#: re.c:573 +#, c-format +msgid "range of the form `[%c-%c]' is locale dependent" +msgstr "les plages « [%c-%c] » sont dépendantes des paramètres régionaux" + +#: re.c:600 +#, c-format +msgid "regexp component `%.*s' should probably be `[%.*s]'" +msgstr "" +"le composant d'expression rationnelle « %.*s » devrait probablement être " +"« [%.*s] »" + +#: regcomp.c:131 +msgid "Success" +msgstr "Succès" + +#: regcomp.c:134 +msgid "No match" +msgstr "Aucune concordance" + +#: regcomp.c:137 +msgid "Invalid regular expression" +msgstr "Expression rationnelle non valide" + +#: regcomp.c:140 +msgid "Invalid collation character" +msgstr "Caractère d'interclassement non valide" + +#: regcomp.c:143 +msgid "Invalid character class name" +msgstr "Nom de classe de caractères non valide" + +#: regcomp.c:146 +msgid "Trailing backslash" +msgstr "Barre oblique inverse finale" + +#: regcomp.c:149 +msgid "Invalid back reference" +msgstr "Référence arrière non valide" + +#: regcomp.c:152 +msgid "Unmatched [ or [^" +msgstr "[ ou [^ sans correspondance" + +#: regcomp.c:155 +msgid "Unmatched ( or \\(" +msgstr "( ou \\( sans correspondance" + +#: regcomp.c:158 +msgid "Unmatched \\{" +msgstr "\\{ sans correspondance" + +#: regcomp.c:161 +msgid "Invalid content of \\{\\}" +msgstr "Contenu de \\{\\} non valide" + +#: regcomp.c:164 +msgid "Invalid range end" +msgstr "Borne finale non valide" + +#: regcomp.c:167 +msgid "Memory exhausted" +msgstr "Mémoire épuisée" + +#: regcomp.c:170 +msgid "Invalid preceding regular expression" +msgstr "Expression rationnelle précédente non valide" + +#: regcomp.c:173 +msgid "Premature end of regular expression" +msgstr "Fin prématurée de l'expression rationnelle" + +#: regcomp.c:176 +msgid "Regular expression too big" +msgstr "Expression rationnelle trop grande" + +#: regcomp.c:179 +msgid "Unmatched ) or \\)" +msgstr ") ou \\) sans correspondance" + +#: regcomp.c:700 +msgid "No previous regular expression" +msgstr "Aucune expression rationnelle précédente" + +#~ msgid "could not find groups: %s" +#~ msgstr "impossible de trouver les groupes : %s" + +#~ msgid "assignment is not allowed to result of builtin function" +#~ msgstr "impossible d'affecter au résultat d'une fonction interne" diff --git a/po/gawk.pot b/po/gawk.pot new file mode 100644 index 0000000..7a0ddbc --- /dev/null +++ b/po/gawk.pot @@ -0,0 +1,2049 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Free Software Foundation, Inc. +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: gawk 4.0.1\n" +"Report-Msgid-Bugs-To: arnold@skeeve.com\n" +"POT-Creation-Date: 2012-03-28 22:03+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: array.c:140 +#, c-format +msgid "from %s" +msgstr "" + +#: array.c:248 +msgid "attempt to use a scalar value as array" +msgstr "" + +#: array.c:251 +#, c-format +msgid "attempt to use function `%s' as an array" +msgstr "" + +#: array.c:254 +#, c-format +msgid "attempt to use scalar parameter `%s' as an array" +msgstr "" + +#: array.c:257 +#, c-format +msgid "attempt to use scalar `%s' as an array" +msgstr "" + +#: array.c:302 array.c:707 builtin.c:84 builtin.c:1385 builtin.c:1427 +#: builtin.c:1440 builtin.c:1859 builtin.c:1871 eval.c:1135 eval.c:1139 +#: eval.c:1495 eval.c:1812 +#, c-format +msgid "attempt to use array `%s' in a scalar context" +msgstr "" + +#: array.c:513 +#, c-format +msgid "reference to uninitialized element `%s[\"%.*s\"]'" +msgstr "" + +#: array.c:519 +#, c-format +msgid "subscript of array `%s' is null string" +msgstr "" + +#: array.c:723 +#, c-format +msgid "delete: index `%s' not in array `%s'" +msgstr "" + +#: array.c:734 eval.c:1865 +#, c-format +msgid "attempt to use scalar `%s[\"%.*s\"]' as an array" +msgstr "" + +#: array.c:910 +#, c-format +msgid "%s: empty (null)\n" +msgstr "" + +#: array.c:915 +#, c-format +msgid "%s: empty (zero)\n" +msgstr "" + +#: array.c:919 +#, c-format +msgid "%s: table_size = %d, array_size = %d\n" +msgstr "" + +#: array.c:954 +#, c-format +msgid "%s: is parameter\n" +msgstr "" + +#: array.c:958 +#, c-format +msgid "%s: array_ref to %s\n" +msgstr "" + +#: array.c:963 +msgid "adump: argument not an array" +msgstr "" + +#: array.c:1086 +msgid "asort: second argument not an array" +msgstr "" + +#: array.c:1087 +msgid "asorti: second argument not an array" +msgstr "" + +#: array.c:1094 +msgid "asort: first argument not an array" +msgstr "" + +#: array.c:1095 +msgid "asorti: first argument not an array" +msgstr "" + +#: array.c:1102 +msgid "asort: cannot use a subarray of first arg for second arg" +msgstr "" + +#: array.c:1103 +msgid "asorti: cannot use a subarray of first arg for second arg" +msgstr "" + +#: array.c:1108 +msgid "asort: cannot use a subarray of second arg for first arg" +msgstr "" + +#: array.c:1109 +msgid "asorti: cannot use a subarray of second arg for first arg" +msgstr "" + +#: array.c:1655 +#, c-format +msgid "`%s' is invalid as a function name" +msgstr "" + +#: array.c:1659 +#, c-format +msgid "sort comparison function `%s' is not defined" +msgstr "" + +#: awkgram.y:249 +#, c-format +msgid "%s blocks must have an action part" +msgstr "" + +#: awkgram.y:252 +msgid "each rule must have a pattern or an action part" +msgstr "" + +#: awkgram.y:323 awkgram.y:334 +msgid "old awk does not support multiple `BEGIN' or `END' rules" +msgstr "" + +#: awkgram.y:371 +#, c-format +msgid "`%s' is a built-in function, it cannot be redefined" +msgstr "" + +#: awkgram.y:432 +msgid "regexp constant `//' looks like a C++ comment, but is not" +msgstr "" + +#: awkgram.y:436 +#, c-format +msgid "regexp constant `/%s/' looks like a C comment, but is not" +msgstr "" + +#: awkgram.y:528 +#, c-format +msgid "duplicate case values in switch body: %s" +msgstr "" + +#: awkgram.y:549 +msgid "duplicate `default' detected in switch body" +msgstr "" + +#: awkgram.y:809 +msgid "`break' is not allowed outside a loop or switch" +msgstr "" + +#: awkgram.y:818 +msgid "`continue' is not allowed outside a loop" +msgstr "" + +#: awkgram.y:828 +#, c-format +msgid "`next' used in %s action" +msgstr "" + +#: awkgram.y:836 +msgid "`nextfile' is a gawk extension" +msgstr "" + +#: awkgram.y:841 +#, c-format +msgid "`nextfile' used in %s action" +msgstr "" + +#: awkgram.y:865 +msgid "`return' used outside function context" +msgstr "" + +#: awkgram.y:925 +msgid "plain `print' in BEGIN or END rule should probably be `print \"\"'" +msgstr "" + +#: awkgram.y:995 awkgram.y:999 awkgram.y:1023 +msgid "`delete array' is a gawk extension" +msgstr "" + +#: awkgram.y:1019 +msgid "`delete(array)' is a non-portable tawk extension" +msgstr "" + +#: awkgram.y:1135 +msgid "multistage two-way pipelines don't work" +msgstr "" + +#: awkgram.y:1238 +msgid "regular expression on right of assignment" +msgstr "" + +#: awkgram.y:1249 +msgid "regular expression on left of `~' or `!~' operator" +msgstr "" + +#: awkgram.y:1265 awkgram.y:1419 +msgid "old awk does not support the keyword `in' except after `for'" +msgstr "" + +#: awkgram.y:1275 +msgid "regular expression on right of comparison" +msgstr "" + +#: awkgram.y:1394 +#, c-format +msgid "`getline var' invalid inside `%s' rule" +msgstr "" + +#: awkgram.y:1397 eval.c:2504 +#, c-format +msgid "`getline' invalid inside `%s' rule" +msgstr "" + +#: awkgram.y:1402 +msgid "non-redirected `getline' undefined inside END action" +msgstr "" + +#: awkgram.y:1421 +msgid "old awk does not support multidimensional arrays" +msgstr "" + +#: awkgram.y:1517 +msgid "call of `length' without parentheses is not portable" +msgstr "" + +#: awkgram.y:1580 +msgid "indirect function calls are a gawk extension" +msgstr "" + +#: awkgram.y:1593 +#, c-format +msgid "can not use special variable `%s' for indirect function call" +msgstr "" + +#: awkgram.y:1671 +msgid "invalid subscript expression" +msgstr "" + +#: awkgram.y:1711 +msgid "use of non-array as array" +msgstr "" + +#: awkgram.y:1975 awkgram.y:1995 msg.c:98 +msgid "warning: " +msgstr "" + +#: awkgram.y:1993 msg.c:130 +msgid "fatal: " +msgstr "" + +#: awkgram.y:2043 +msgid "unexpected newline or end of string" +msgstr "" + +#: awkgram.y:2300 awkgram.y:2358 awkgram.y:2542 +#, c-format +msgid "can't open source file `%s' for reading (%s)" +msgstr "" + +#: awkgram.y:2301 awkgram.y:2359 builtin.c:122 +msgid "reason unknown" +msgstr "" + +#: awkgram.y:2317 +#, c-format +msgid "already included source file `%s'" +msgstr "" + +#: awkgram.y:2343 +msgid "@include is a gawk extension" +msgstr "" + +#: awkgram.y:2349 +msgid "empty filename after @include" +msgstr "" + +#: awkgram.y:2494 +msgid "empty program text on command line" +msgstr "" + +#: awkgram.y:2609 +#, c-format +msgid "can't read sourcefile `%s' (%s)" +msgstr "" + +#: awkgram.y:2620 +#, c-format +msgid "source file `%s' is empty" +msgstr "" + +#: awkgram.y:2797 +msgid "source file does not end in newline" +msgstr "" + +#: awkgram.y:2900 +msgid "unterminated regexp ends with `\\' at end of file" +msgstr "" + +#: awkgram.y:2924 +#, c-format +msgid "%s: %d: tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "" + +#: awkgram.y:2928 +#, c-format +msgid "tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "" + +#: awkgram.y:2935 +msgid "unterminated regexp" +msgstr "" + +#: awkgram.y:2939 +msgid "unterminated regexp at end of file" +msgstr "" + +#: awkgram.y:2998 +msgid "use of `\\ #...' line continuation is not portable" +msgstr "" + +#: awkgram.y:3014 +msgid "backslash not last character on line" +msgstr "" + +#: awkgram.y:3075 +msgid "POSIX does not allow operator `**='" +msgstr "" + +#: awkgram.y:3077 +msgid "old awk does not support operator `**='" +msgstr "" + +#: awkgram.y:3086 +msgid "POSIX does not allow operator `**'" +msgstr "" + +#: awkgram.y:3088 +msgid "old awk does not support operator `**'" +msgstr "" + +#: awkgram.y:3123 +msgid "operator `^=' is not supported in old awk" +msgstr "" + +#: awkgram.y:3131 +msgid "operator `^' is not supported in old awk" +msgstr "" + +#: awkgram.y:3224 awkgram.y:3240 +msgid "unterminated string" +msgstr "" + +#: awkgram.y:3436 +#, c-format +msgid "invalid char '%c' in expression" +msgstr "" + +#: awkgram.y:3483 +#, c-format +msgid "`%s' is a gawk extension" +msgstr "" + +#: awkgram.y:3488 +#, c-format +msgid "`%s' is a Bell Labs extension" +msgstr "" + +#: awkgram.y:3493 +#, c-format +msgid "POSIX does not allow `%s'" +msgstr "" + +#: awkgram.y:3501 +#, c-format +msgid "`%s' is not supported in old awk" +msgstr "" + +#: awkgram.y:3568 +msgid "`goto' considered harmful!\n" +msgstr "" + +#: awkgram.y:3619 +#, c-format +msgid "%d is invalid as number of arguments for %s" +msgstr "" + +#: awkgram.y:3654 +#, c-format +msgid "%s: string literal as last arg of substitute has no effect" +msgstr "" + +#: awkgram.y:3659 +#, c-format +msgid "%s third parameter is not a changeable object" +msgstr "" + +#: awkgram.y:3732 awkgram.y:3735 +msgid "match: third argument is a gawk extension" +msgstr "" + +#: awkgram.y:3789 awkgram.y:3792 +msgid "close: second argument is a gawk extension" +msgstr "" + +#: awkgram.y:3804 +msgid "use of dcgettext(_\"...\") is incorrect: remove leading underscore" +msgstr "" + +#: awkgram.y:3819 +msgid "use of dcngettext(_\"...\") is incorrect: remove leading underscore" +msgstr "" + +#: awkgram.y:3911 +#, c-format +msgid "function `%s': parameter #%d, `%s', duplicates parameter #%d" +msgstr "" + +#: awkgram.y:3953 +#, c-format +msgid "function `%s': parameter `%s' shadows global variable" +msgstr "" + +#: awkgram.y:4111 +#, c-format +msgid "could not open `%s' for writing (%s)" +msgstr "" + +#: awkgram.y:4112 +msgid "sending variable list to standard error" +msgstr "" + +#: awkgram.y:4118 +#, c-format +msgid "%s: close failed (%s)" +msgstr "" + +#: awkgram.y:4170 +msgid "shadow_funcs() called twice!" +msgstr "" + +#: awkgram.y:4176 +msgid "there were shadowed variables." +msgstr "" + +#: awkgram.y:4206 +#, c-format +msgid "function `%s': can't use function name as parameter name" +msgstr "" + +#: awkgram.y:4210 +#, c-format +msgid "function `%s': can't use special variable `%s' as a function parameter" +msgstr "" + +#: awkgram.y:4226 +#, c-format +msgid "function name `%s' previously defined" +msgstr "" + +#: awkgram.y:4394 awkgram.y:4400 +#, c-format +msgid "function `%s' called but never defined" +msgstr "" + +#: awkgram.y:4403 +#, c-format +msgid "function `%s' defined but never called directly" +msgstr "" + +#: awkgram.y:4435 +#, c-format +msgid "regexp constant for parameter #%d yields boolean value" +msgstr "" + +#: awkgram.y:4544 +#, c-format +msgid "" +"function `%s' called with space between name and `(',\n" +"or used as a variable or an array" +msgstr "" + +#: awkgram.y:4791 eval.c:2056 +msgid "division by zero attempted" +msgstr "" + +#: awkgram.y:4800 eval.c:2072 +#, c-format +msgid "division by zero attempted in `%%'" +msgstr "" + +#: builtin.c:120 +#, c-format +msgid "%s to \"%s\" failed (%s)" +msgstr "" + +#: builtin.c:121 +msgid "standard output" +msgstr "" + +#: builtin.c:135 +msgid "exp: received non-numeric argument" +msgstr "" + +#: builtin.c:141 +#, c-format +msgid "exp: argument %g is out of range" +msgstr "" + +#: builtin.c:200 +#, c-format +msgid "fflush: cannot flush: pipe `%s' opened for reading, not writing" +msgstr "" + +#: builtin.c:203 +#, c-format +msgid "fflush: cannot flush: file `%s' opened for reading, not writing" +msgstr "" + +#: builtin.c:215 +#, c-format +msgid "fflush: `%s' is not an open file, pipe or co-process" +msgstr "" + +#: builtin.c:333 +msgid "index: received non-string first argument" +msgstr "" + +#: builtin.c:335 +msgid "index: received non-string second argument" +msgstr "" + +#: builtin.c:457 +msgid "int: received non-numeric argument" +msgstr "" + +#: builtin.c:493 +msgid "length: received array argument" +msgstr "" + +#: builtin.c:496 +msgid "`length(array)' is a gawk extension" +msgstr "" + +#: builtin.c:504 +msgid "length: received non-string argument" +msgstr "" + +#: builtin.c:535 +msgid "log: received non-numeric argument" +msgstr "" + +#: builtin.c:538 +#, c-format +msgid "log: received negative argument %g" +msgstr "" + +#: builtin.c:694 builtin.c:699 +msgid "fatal: must use `count$' on all formats or none" +msgstr "" + +#: builtin.c:762 +#, c-format +msgid "field width is ignored for `%%' specifier" +msgstr "" + +#: builtin.c:764 +#, c-format +msgid "precision is ignored for `%%' specifier" +msgstr "" + +#: builtin.c:766 +#, c-format +msgid "field width and precision are ignored for `%%' specifier" +msgstr "" + +#: builtin.c:817 +msgid "fatal: `$' is not permitted in awk formats" +msgstr "" + +#: builtin.c:826 +msgid "fatal: arg count with `$' must be > 0" +msgstr "" + +#: builtin.c:830 +#, c-format +msgid "fatal: arg count %ld greater than total number of supplied arguments" +msgstr "" + +#: builtin.c:834 +msgid "fatal: `$' not permitted after period in format" +msgstr "" + +#: builtin.c:850 +msgid "fatal: no `$' supplied for positional field width or precision" +msgstr "" + +#: builtin.c:921 +msgid "`l' is meaningless in awk formats; ignored" +msgstr "" + +#: builtin.c:925 +msgid "fatal: `l' is not permitted in POSIX awk formats" +msgstr "" + +#: builtin.c:938 +msgid "`L' is meaningless in awk formats; ignored" +msgstr "" + +#: builtin.c:942 +msgid "fatal: `L' is not permitted in POSIX awk formats" +msgstr "" + +#: builtin.c:955 +msgid "`h' is meaningless in awk formats; ignored" +msgstr "" + +#: builtin.c:959 +msgid "fatal: `h' is not permitted in POSIX awk formats" +msgstr "" + +#: builtin.c:1272 +#, c-format +msgid "[s]printf: value %g is out of range for `%%%c' format" +msgstr "" + +#: builtin.c:1332 +#, c-format +msgid "ignoring unknown format specifier character `%c': no argument converted" +msgstr "" + +#: builtin.c:1337 +msgid "fatal: not enough arguments to satisfy format string" +msgstr "" + +#: builtin.c:1339 +msgid "^ ran out for this one" +msgstr "" + +#: builtin.c:1346 +msgid "[s]printf: format specifier does not have control letter" +msgstr "" + +#: builtin.c:1349 +msgid "too many arguments supplied for format string" +msgstr "" + +#: builtin.c:1423 builtin.c:1434 +msgid "printf: no arguments" +msgstr "" + +#: builtin.c:1475 +msgid "sqrt: received non-numeric argument" +msgstr "" + +#: builtin.c:1479 +#, c-format +msgid "sqrt: called with negative argument %g" +msgstr "" + +#: builtin.c:1503 +#, c-format +msgid "substr: length %g is not >= 1" +msgstr "" + +#: builtin.c:1505 +#, c-format +msgid "substr: length %g is not >= 0" +msgstr "" + +#: builtin.c:1512 +#, c-format +msgid "substr: non-integer length %g will be truncated" +msgstr "" + +#: builtin.c:1517 +#, c-format +msgid "substr: length %g too big for string indexing, truncating to %g" +msgstr "" + +#: builtin.c:1529 +#, c-format +msgid "substr: start index %g is invalid, using 1" +msgstr "" + +#: builtin.c:1534 +#, c-format +msgid "substr: non-integer start index %g will be truncated" +msgstr "" + +#: builtin.c:1559 +msgid "substr: source string is zero length" +msgstr "" + +#: builtin.c:1575 +#, c-format +msgid "substr: start index %g is past end of string" +msgstr "" + +#: builtin.c:1583 +#, c-format +msgid "" +"substr: length %g at start index %g exceeds length of first argument (%lu)" +msgstr "" + +#: builtin.c:1657 +msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" +msgstr "" + +#: builtin.c:1680 +msgid "strftime: received non-numeric second argument" +msgstr "" + +#: builtin.c:1683 +msgid "strftime: second argument less than 0 or too big for time_t" +msgstr "" + +#: builtin.c:1690 +msgid "strftime: received non-string first argument" +msgstr "" + +#: builtin.c:1696 +msgid "strftime: received empty format string" +msgstr "" + +#: builtin.c:1762 +msgid "mktime: received non-string argument" +msgstr "" + +#: builtin.c:1779 +msgid "mktime: at least one of the values is out of the default range" +msgstr "" + +#: builtin.c:1814 +msgid "'system' function not allowed in sandbox mode" +msgstr "" + +#: builtin.c:1819 +msgid "system: received non-string argument" +msgstr "" + +#: builtin.c:1874 eval.c:1159 eval.c:1790 eval.c:1803 +#, c-format +msgid "reference to uninitialized variable `%s'" +msgstr "" + +#: builtin.c:1941 +#, c-format +msgid "reference to uninitialized field `$%d'" +msgstr "" + +#: builtin.c:2028 +msgid "tolower: received non-string argument" +msgstr "" + +#: builtin.c:2062 +msgid "toupper: received non-string argument" +msgstr "" + +#: builtin.c:2098 +msgid "atan2: received non-numeric first argument" +msgstr "" + +#: builtin.c:2100 +msgid "atan2: received non-numeric second argument" +msgstr "" + +#: builtin.c:2119 +msgid "sin: received non-numeric argument" +msgstr "" + +#: builtin.c:2135 +msgid "cos: received non-numeric argument" +msgstr "" + +#: builtin.c:2188 +msgid "srand: received non-numeric argument" +msgstr "" + +#: builtin.c:2219 +msgid "match: third argument is not an array" +msgstr "" + +#: builtin.c:2483 +msgid "gensub: third argument of 0 treated as 1" +msgstr "" + +#: builtin.c:2776 +msgid "lshift: received non-numeric first argument" +msgstr "" + +#: builtin.c:2778 +msgid "lshift: received non-numeric second argument" +msgstr "" + +#: builtin.c:2784 +#, c-format +msgid "lshift(%lf, %lf): negative values will give strange results" +msgstr "" + +#: builtin.c:2786 +#, c-format +msgid "lshift(%lf, %lf): fractional values will be truncated" +msgstr "" + +#: builtin.c:2788 +#, c-format +msgid "lshift(%lf, %lf): too large shift value will give strange results" +msgstr "" + +#: builtin.c:2813 +msgid "rshift: received non-numeric first argument" +msgstr "" + +#: builtin.c:2815 +msgid "rshift: received non-numeric second argument" +msgstr "" + +#: builtin.c:2821 +#, c-format +msgid "rshift(%lf, %lf): negative values will give strange results" +msgstr "" + +#: builtin.c:2823 +#, c-format +msgid "rshift(%lf, %lf): fractional values will be truncated" +msgstr "" + +#: builtin.c:2825 +#, c-format +msgid "rshift(%lf, %lf): too large shift value will give strange results" +msgstr "" + +#: builtin.c:2850 +msgid "and: received non-numeric first argument" +msgstr "" + +#: builtin.c:2852 +msgid "and: received non-numeric second argument" +msgstr "" + +#: builtin.c:2858 +#, c-format +msgid "and(%lf, %lf): negative values will give strange results" +msgstr "" + +#: builtin.c:2860 +#, c-format +msgid "and(%lf, %lf): fractional values will be truncated" +msgstr "" + +#: builtin.c:2885 +msgid "or: received non-numeric first argument" +msgstr "" + +#: builtin.c:2887 +msgid "or: received non-numeric second argument" +msgstr "" + +#: builtin.c:2893 +#, c-format +msgid "or(%lf, %lf): negative values will give strange results" +msgstr "" + +#: builtin.c:2895 +#, c-format +msgid "or(%lf, %lf): fractional values will be truncated" +msgstr "" + +#: builtin.c:2923 +msgid "xor: received non-numeric first argument" +msgstr "" + +#: builtin.c:2925 +msgid "xor: received non-numeric second argument" +msgstr "" + +#: builtin.c:2931 +#, c-format +msgid "xor(%lf, %lf): negative values will give strange results" +msgstr "" + +#: builtin.c:2933 +#, c-format +msgid "xor(%lf, %lf): fractional values will be truncated" +msgstr "" + +#: builtin.c:2957 builtin.c:2963 +msgid "compl: received non-numeric argument" +msgstr "" + +#: builtin.c:2965 +#, c-format +msgid "compl(%lf): negative value will give strange results" +msgstr "" + +#: builtin.c:2967 +#, c-format +msgid "compl(%lf): fractional value will be truncated" +msgstr "" + +#: builtin.c:3136 +#, c-format +msgid "dcgettext: `%s' is not a valid locale category" +msgstr "" + +#: eval.c:412 +#, c-format +msgid "unknown nodetype %d" +msgstr "" + +#: eval.c:423 eval.c:437 +#, c-format +msgid "unknown opcode %d" +msgstr "" + +#: eval.c:434 +#, c-format +msgid "opcode %s not an operator or keyword" +msgstr "" + +#: eval.c:488 +msgid "buffer overflow in genflags2str" +msgstr "" + +#: eval.c:698 +#, c-format +msgid "" +"\n" +"\t# Function Call Stack:\n" +"\n" +msgstr "" + +#: eval.c:725 +msgid "`IGNORECASE' is a gawk extension" +msgstr "" + +#: eval.c:754 +msgid "`BINMODE' is a gawk extension" +msgstr "" + +#: eval.c:812 +#, c-format +msgid "BINMODE value `%s' is invalid, treated as 3" +msgstr "" + +#: eval.c:902 +#, c-format +msgid "bad `%sFMT' specification `%s'" +msgstr "" + +#: eval.c:980 +msgid "turning off `--lint' due to assignment to `LINT'" +msgstr "" + +#: eval.c:1127 eval.c:1777 +#, c-format +msgid "can't use function name `%s' as variable or array" +msgstr "" + +#: eval.c:1158 eval.c:1789 eval.c:1802 +#, c-format +msgid "reference to uninitialized argument `%s'" +msgstr "" + +#: eval.c:1177 +msgid "attempt to field reference from non-numeric value" +msgstr "" + +#: eval.c:1179 +msgid "attempt to field reference from null string" +msgstr "" + +#: eval.c:1185 +#, c-format +msgid "attempt to access field %ld" +msgstr "" + +#: eval.c:1194 +#, c-format +msgid "reference to uninitialized field `$%ld'" +msgstr "" + +#: eval.c:1256 +#, c-format +msgid "function `%s' called with more arguments than declared" +msgstr "" + +#: eval.c:1437 +#, c-format +msgid "unwind_stack: unexpected type `%s'" +msgstr "" + +#: eval.c:1532 +msgid "division by zero attempted in `/='" +msgstr "" + +#: eval.c:1539 +#, c-format +msgid "division by zero attempted in `%%='" +msgstr "" + +#: eval.c:1876 eval.c:2122 +#, c-format +msgid "attempt to use array `%s[\"%.*s\"]' in a scalar context" +msgstr "" + +#: eval.c:1907 +msgid "assignment used in conditional context" +msgstr "" + +#: eval.c:1911 +msgid "statement has no effect" +msgstr "" + +#: eval.c:2343 +#, c-format +msgid "for loop: array `%s' changed size from %ld to %ld during loop execution" +msgstr "" + +#: eval.c:2458 +#, c-format +msgid "function called indirectly through `%s' does not exist" +msgstr "" + +#: eval.c:2470 +#, c-format +msgid "function `%s' not defined" +msgstr "" + +#: eval.c:2511 +#, c-format +msgid "non-redirected `getline' invalid inside `%s' rule" +msgstr "" + +#: eval.c:2600 +#, c-format +msgid "error reading input file `%s': %s" +msgstr "" + +#: eval.c:2614 +#, c-format +msgid "`nextfile' cannot be called from a `%s' rule" +msgstr "" + +#: eval.c:2661 +msgid "`exit' cannot be called in the current context" +msgstr "" + +#: eval.c:2700 +#, c-format +msgid "`next' cannot be called from a `%s' rule" +msgstr "" + +#: eval.c:2766 +#, c-format +msgid "Sorry, don't know how to interpret `%s'" +msgstr "" + +#: ext.c:54 +msgid "extensions are not allowed in sandbox mode" +msgstr "" + +#: ext.c:60 ext.c:65 +msgid "`extension' is a gawk extension" +msgstr "" + +#: ext.c:75 +#, c-format +msgid "fatal: extension: cannot open `%s' (%s)\n" +msgstr "" + +#: ext.c:84 +#, c-format +msgid "" +"fatal: extension: library `%s': does not define " +"`plugin_is_GPL_compatible' (%s)\n" +msgstr "" + +#: ext.c:93 +#, c-format +msgid "fatal: extension: library `%s': cannot call function `%s' (%s)\n" +msgstr "" + +#: ext.c:127 +msgid "extension: missing function name" +msgstr "" + +#: ext.c:132 +#, c-format +msgid "extension: illegal character `%c' in function name `%s'" +msgstr "" + +#: ext.c:141 +#, c-format +msgid "extension: can't redefine function `%s'" +msgstr "" + +#: ext.c:145 +#, c-format +msgid "extension: function `%s' already defined" +msgstr "" + +#: ext.c:150 +#, c-format +msgid "extension: function name `%s' previously defined" +msgstr "" + +#: ext.c:152 +#, c-format +msgid "extension: can't use gawk built-in `%s' as function name" +msgstr "" + +#: ext.c:156 +#, c-format +msgid "make_builtin: negative argument count for function `%s'" +msgstr "" + +#: ext.c:259 +#, c-format +msgid "function `%s' defined to take no more than %d argument(s)" +msgstr "" + +#: ext.c:262 +#, c-format +msgid "function `%s': missing argument #%d" +msgstr "" + +#: ext.c:279 +#, c-format +msgid "function `%s': argument #%d: attempt to use scalar as an array" +msgstr "" + +#: ext.c:283 +#, c-format +msgid "function `%s': argument #%d: attempt to use array as a scalar" +msgstr "" + +#: ext.c:296 +msgid "Operation Not Supported" +msgstr "" + +#: field.c:328 +msgid "NF set to negative value" +msgstr "" + +#: field.c:951 field.c:958 field.c:962 +msgid "split: fourth argument is a gawk extension" +msgstr "" + +#: field.c:955 +msgid "split: fourth argument is not an array" +msgstr "" + +#: field.c:969 +msgid "split: second argument is not an array" +msgstr "" + +#: field.c:973 +msgid "split: cannot use the same array for second and fourth args" +msgstr "" + +#: field.c:978 +msgid "split: cannot use a subarray of second arg for fourth arg" +msgstr "" + +#: field.c:981 +msgid "split: cannot use a subarray of fourth arg for second arg" +msgstr "" + +#: field.c:1010 +msgid "split: null string for third arg is a gawk extension" +msgstr "" + +#: field.c:1050 +msgid "patsplit: fourth argument is not an array" +msgstr "" + +#: field.c:1055 +msgid "patsplit: second argument is not an array" +msgstr "" + +#: field.c:1061 +msgid "patsplit: third argument must be non-null" +msgstr "" + +#: field.c:1065 +msgid "patsplit: cannot use the same array for second and fourth args" +msgstr "" + +#: field.c:1070 +msgid "patsplit: cannot use a subarray of second arg for fourth arg" +msgstr "" + +#: field.c:1073 +msgid "patsplit: cannot use a subarray of fourth arg for second arg" +msgstr "" + +#: field.c:1110 +msgid "`FIELDWIDTHS' is a gawk extension" +msgstr "" + +#: field.c:1173 +#, c-format +msgid "invalid FIELDWIDTHS value, near `%s'" +msgstr "" + +#: field.c:1246 +msgid "null string for `FS' is a gawk extension" +msgstr "" + +#: field.c:1250 +msgid "old awk does not support regexps as value of `FS'" +msgstr "" + +#: field.c:1369 +msgid "`FPAT' is a gawk extension" +msgstr "" + +#: getopt.c:604 getopt.c:633 +#, c-format +msgid "%s: option '%s' is ambiguous; possibilities:" +msgstr "" + +#: getopt.c:679 getopt.c:683 +#, c-format +msgid "%s: option '--%s' doesn't allow an argument\n" +msgstr "" + +#: getopt.c:692 getopt.c:697 +#, c-format +msgid "%s: option '%c%s' doesn't allow an argument\n" +msgstr "" + +#: getopt.c:740 getopt.c:759 +#, c-format +msgid "%s: option '--%s' requires an argument\n" +msgstr "" + +#: getopt.c:797 getopt.c:800 +#, c-format +msgid "%s: unrecognized option '--%s'\n" +msgstr "" + +#: getopt.c:808 getopt.c:811 +#, c-format +msgid "%s: unrecognized option '%c%s'\n" +msgstr "" + +#: getopt.c:860 getopt.c:863 +#, c-format +msgid "%s: invalid option -- '%c'\n" +msgstr "" + +#: getopt.c:916 getopt.c:933 getopt.c:1143 getopt.c:1161 +#, c-format +msgid "%s: option requires an argument -- '%c'\n" +msgstr "" + +#: getopt.c:989 getopt.c:1005 +#, c-format +msgid "%s: option '-W %s' is ambiguous\n" +msgstr "" + +#: getopt.c:1029 getopt.c:1047 +#, c-format +msgid "%s: option '-W %s' doesn't allow an argument\n" +msgstr "" + +#: getopt.c:1068 getopt.c:1086 +#, c-format +msgid "%s: option '-W %s' requires an argument\n" +msgstr "" + +#: io.c:280 +#, c-format +msgid "command line argument `%s' is a directory: skipped" +msgstr "" + +#: io.c:283 io.c:385 +#, c-format +msgid "cannot open file `%s' for reading (%s)" +msgstr "" + +#: io.c:501 +#, c-format +msgid "close of fd %d (`%s') failed (%s)" +msgstr "" + +#: io.c:578 +msgid "redirection not allowed in sandbox mode" +msgstr "" + +#: io.c:612 +#, c-format +msgid "expression in `%s' redirection only has numeric value" +msgstr "" + +#: io.c:618 +#, c-format +msgid "expression for `%s' redirection has null string value" +msgstr "" + +#: io.c:623 +#, c-format +msgid "filename `%s' for `%s' redirection may be result of logical expression" +msgstr "" + +#: io.c:666 +#, c-format +msgid "unnecessary mixing of `>' and `>>' for file `%.*s'" +msgstr "" + +#: io.c:719 +#, c-format +msgid "can't open pipe `%s' for output (%s)" +msgstr "" + +#: io.c:729 +#, c-format +msgid "can't open pipe `%s' for input (%s)" +msgstr "" + +#: io.c:752 +#, c-format +msgid "can't open two way pipe `%s' for input/output (%s)" +msgstr "" + +#: io.c:834 +#, c-format +msgid "can't redirect from `%s' (%s)" +msgstr "" + +#: io.c:837 +#, c-format +msgid "can't redirect to `%s' (%s)" +msgstr "" + +#: io.c:888 +msgid "" +"reached system limit for open files: starting to multiplex file descriptors" +msgstr "" + +#: io.c:904 +#, c-format +msgid "close of `%s' failed (%s)." +msgstr "" + +#: io.c:912 +msgid "too many pipes or input files open" +msgstr "" + +#: io.c:934 +msgid "close: second argument must be `to' or `from'" +msgstr "" + +#: io.c:951 +#, c-format +msgid "close: `%.*s' is not an open file, pipe or co-process" +msgstr "" + +#: io.c:956 +msgid "close of redirection that was never opened" +msgstr "" + +#: io.c:1053 +#, c-format +msgid "close: redirection `%s' not opened with `|&', second argument ignored" +msgstr "" + +#: io.c:1069 +#, c-format +msgid "failure status (%d) on pipe close of `%s' (%s)" +msgstr "" + +#: io.c:1072 +#, c-format +msgid "failure status (%d) on file close of `%s' (%s)" +msgstr "" + +#: io.c:1092 +#, c-format +msgid "no explicit close of socket `%s' provided" +msgstr "" + +#: io.c:1095 +#, c-format +msgid "no explicit close of co-process `%s' provided" +msgstr "" + +#: io.c:1098 +#, c-format +msgid "no explicit close of pipe `%s' provided" +msgstr "" + +#: io.c:1101 +#, c-format +msgid "no explicit close of file `%s' provided" +msgstr "" + +#: io.c:1129 io.c:1184 main.c:794 main.c:831 +#, c-format +msgid "error writing standard output (%s)" +msgstr "" + +#: io.c:1133 io.c:1189 +#, c-format +msgid "error writing standard error (%s)" +msgstr "" + +#: io.c:1141 +#, c-format +msgid "pipe flush of `%s' failed (%s)." +msgstr "" + +#: io.c:1144 +#, c-format +msgid "co-process flush of pipe to `%s' failed (%s)." +msgstr "" + +#: io.c:1147 +#, c-format +msgid "file flush of `%s' failed (%s)." +msgstr "" + +#: io.c:1262 +#, c-format +msgid "local port %s invalid in `/inet'" +msgstr "" + +#: io.c:1279 +#, c-format +msgid "remote host and port information (%s, %s) invalid" +msgstr "" + +#: io.c:1431 +#, c-format +msgid "no (known) protocol supplied in special filename `%s'" +msgstr "" + +#: io.c:1445 +#, c-format +msgid "special file name `%s' is incomplete" +msgstr "" + +#: io.c:1462 +msgid "must supply a remote hostname to `/inet'" +msgstr "" + +#: io.c:1480 +msgid "must supply a remote port to `/inet'" +msgstr "" + +#: io.c:1526 +msgid "TCP/IP communications are not supported" +msgstr "" + +#: io.c:1693 +#, c-format +msgid "could not open `%s', mode `%s'" +msgstr "" + +#: io.c:1747 +#, c-format +msgid "close of master pty failed (%s)" +msgstr "" + +#: io.c:1749 io.c:1917 io.c:2074 +#, c-format +msgid "close of stdout in child failed (%s)" +msgstr "" + +#: io.c:1752 +#, c-format +msgid "moving slave pty to stdout in child failed (dup: %s)" +msgstr "" + +#: io.c:1754 io.c:1922 +#, c-format +msgid "close of stdin in child failed (%s)" +msgstr "" + +#: io.c:1757 +#, c-format +msgid "moving slave pty to stdin in child failed (dup: %s)" +msgstr "" + +#: io.c:1759 io.c:1780 +#, c-format +msgid "close of slave pty failed (%s)" +msgstr "" + +#: io.c:1858 io.c:1920 io.c:2052 io.c:2077 +#, c-format +msgid "moving pipe to stdout in child failed (dup: %s)" +msgstr "" + +#: io.c:1865 io.c:1925 +#, c-format +msgid "moving pipe to stdin in child failed (dup: %s)" +msgstr "" + +#: io.c:1885 io.c:2067 +msgid "restoring stdout in parent process failed\n" +msgstr "" + +#: io.c:1893 +msgid "restoring stdin in parent process failed\n" +msgstr "" + +#: io.c:1928 io.c:2079 io.c:2093 +#, c-format +msgid "close of pipe failed (%s)" +msgstr "" + +#: io.c:1973 +msgid "`|&' not supported" +msgstr "" + +#: io.c:2039 +#, c-format +msgid "cannot open pipe `%s' (%s)" +msgstr "" + +#: io.c:2087 +#, c-format +msgid "cannot create child process for `%s' (fork: %s)" +msgstr "" + +#: io.c:2520 +#, c-format +msgid "data file `%s' is empty" +msgstr "" + +#: io.c:2561 io.c:2569 +msgid "could not allocate more input memory" +msgstr "" + +#: io.c:3127 +msgid "multicharacter value of `RS' is a gawk extension" +msgstr "" + +#: io.c:3232 +msgid "IPv6 communication is not supported" +msgstr "" + +#: main.c:366 +msgid "`-m[fr]' option irrelevant in gawk" +msgstr "" + +#: main.c:368 +msgid "-m option usage: `-m[fr] nnn'" +msgstr "" + +#: main.c:391 +msgid "empty argument to `-e/--source' ignored" +msgstr "" + +#: main.c:462 +#, c-format +msgid "%s: option `-W %s' unrecognized, ignored\n" +msgstr "" + +#: main.c:515 +#, c-format +msgid "%s: option requires an argument -- %c\n" +msgstr "" + +#: main.c:536 +msgid "environment variable `POSIXLY_CORRECT' set: turning on `--posix'" +msgstr "" + +#: main.c:542 +msgid "`--posix' overrides `--traditional'" +msgstr "" + +#: main.c:553 +msgid "`--posix'/`--traditional' overrides `--non-decimal-data'" +msgstr "" + +#: main.c:557 +#, c-format +msgid "running %s setuid root may be a security problem" +msgstr "" + +#: main.c:562 +msgid "`--posix' overrides `--binary'" +msgstr "" + +#: main.c:613 +#, c-format +msgid "can't set binary mode on stdin (%s)" +msgstr "" + +#: main.c:616 +#, c-format +msgid "can't set binary mode on stdout (%s)" +msgstr "" + +#: main.c:618 +#, c-format +msgid "can't set binary mode on stderr (%s)" +msgstr "" + +#: main.c:657 +msgid "no program text at all!" +msgstr "" + +#: main.c:734 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] -f progfile [--] file ...\n" +msgstr "" + +#: main.c:736 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] [--] %cprogram%c file ...\n" +msgstr "" + +#: main.c:741 +msgid "POSIX options:\t\tGNU long options: (standard)\n" +msgstr "" + +#: main.c:742 +msgid "\t-f progfile\t\t--file=progfile\n" +msgstr "" + +#: main.c:743 +msgid "\t-F fs\t\t\t--field-separator=fs\n" +msgstr "" + +#: main.c:744 +msgid "\t-v var=val\t\t--assign=var=val\n" +msgstr "" + +#: main.c:745 +msgid "Short options:\t\tGNU long options: (extensions)\n" +msgstr "" + +#: main.c:746 +msgid "\t-b\t\t\t--characters-as-bytes\n" +msgstr "" + +#: main.c:747 +msgid "\t-c\t\t\t--traditional\n" +msgstr "" + +#: main.c:748 +msgid "\t-C\t\t\t--copyright\n" +msgstr "" + +#: main.c:749 +msgid "\t-d[file]\t\t--dump-variables[=file]\n" +msgstr "" + +#: main.c:750 +msgid "\t-e 'program-text'\t--source='program-text'\n" +msgstr "" + +#: main.c:751 +msgid "\t-E file\t\t\t--exec=file\n" +msgstr "" + +#: main.c:752 +msgid "\t-g\t\t\t--gen-pot\n" +msgstr "" + +#: main.c:753 +msgid "\t-h\t\t\t--help\n" +msgstr "" + +#: main.c:754 +msgid "\t-L [fatal]\t\t--lint[=fatal]\n" +msgstr "" + +#: main.c:755 +msgid "\t-n\t\t\t--non-decimal-data\n" +msgstr "" + +#: main.c:756 +msgid "\t-N\t\t\t--use-lc-numeric\n" +msgstr "" + +#: main.c:757 +msgid "\t-O\t\t\t--optimize\n" +msgstr "" + +#: main.c:758 +msgid "\t-p[file]\t\t--profile[=file]\n" +msgstr "" + +#: main.c:759 +msgid "\t-P\t\t\t--posix\n" +msgstr "" + +#: main.c:760 +msgid "\t-r\t\t\t--re-interval\n" +msgstr "" + +#: main.c:762 +msgid "\t-R file\t\t\t--command=file\n" +msgstr "" + +#: main.c:763 +msgid "\t-S\t\t\t--sandbox\n" +msgstr "" + +#: main.c:764 +msgid "\t-t\t\t\t--lint-old\n" +msgstr "" + +#: main.c:765 +msgid "\t-V\t\t\t--version\n" +msgstr "" + +#: main.c:767 +msgid "\t-W nostalgia\t\t--nostalgia\n" +msgstr "" + +#: main.c:770 +msgid "\t-Y\t\t--parsedebug\n" +msgstr "" + +#. TRANSLATORS: --help output 5 (end) +#. TRANSLATORS: the placeholder indicates the bug-reporting address +#. for this application. Please add _another line_ with the +#. address for translation bugs. +#. no-wrap +#: main.c:779 +msgid "" +"\n" +"To report bugs, see node `Bugs' in `gawk.info', which is\n" +"section `Reporting Problems and Bugs' in the printed version.\n" +"\n" +msgstr "" + +#: main.c:783 +msgid "" +"gawk is a pattern scanning and processing language.\n" +"By default it reads standard input and writes standard output.\n" +"\n" +msgstr "" + +#: main.c:787 +msgid "" +"Examples:\n" +"\tgawk '{ sum += $1 }; END { print sum }' file\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" +msgstr "" + +#: main.c:807 +#, c-format +msgid "" +"Copyright (C) 1989, 1991-%d Free Software Foundation.\n" +"\n" +"This program is free software; you can redistribute it and/or modify\n" +"it under the terms of the GNU General Public License as published by\n" +"the Free Software Foundation; either version 3 of the License, or\n" +"(at your option) any later version.\n" +"\n" +msgstr "" + +#: main.c:815 +msgid "" +"This program is distributed in the hope that it will be useful,\n" +"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +"GNU General Public License for more details.\n" +"\n" +msgstr "" + +#: main.c:821 +msgid "" +"You should have received a copy of the GNU General Public License\n" +"along with this program. If not, see http://www.gnu.org/licenses/.\n" +msgstr "" + +#: main.c:856 +msgid "-Ft does not set FS to tab in POSIX awk" +msgstr "" + +#: main.c:1090 +#, c-format +msgid "unknown value for field spec: %d\n" +msgstr "" + +#: main.c:1171 +#, c-format +msgid "" +"%s: `%s' argument to `-v' not in `var=value' form\n" +"\n" +msgstr "" + +#: main.c:1197 +#, c-format +msgid "`%s' is not a legal variable name" +msgstr "" + +#: main.c:1200 +#, c-format +msgid "`%s' is not a variable name, looking for file `%s=%s'" +msgstr "" + +#: main.c:1204 +#, c-format +msgid "cannot use gawk builtin `%s' as variable name" +msgstr "" + +#: main.c:1209 +#, c-format +msgid "cannot use function `%s' as variable name" +msgstr "" + +#: main.c:1262 +msgid "floating point exception" +msgstr "" + +#: main.c:1269 +msgid "fatal error: internal error" +msgstr "" + +#: main.c:1284 +msgid "fatal error: internal error: segfault" +msgstr "" + +#: main.c:1296 +msgid "fatal error: internal error: stack overflow" +msgstr "" + +#: main.c:1346 +#, c-format +msgid "no pre-opened fd %d" +msgstr "" + +#: main.c:1353 +#, c-format +msgid "could not pre-open /dev/null for fd %d" +msgstr "" + +#: msg.c:63 +#, c-format +msgid "cmd. line:" +msgstr "" + +#: msg.c:107 +msgid "error: " +msgstr "" + +#: node.c:406 +msgid "backslash at end of string" +msgstr "" + +#: node.c:517 +#, c-format +msgid "old awk does not support the `\\%c' escape sequence" +msgstr "" + +#: node.c:568 +msgid "POSIX does not allow `\\x' escapes" +msgstr "" + +#: node.c:574 +msgid "no hex digits in `\\x' escape sequence" +msgstr "" + +#: node.c:596 +#, c-format +msgid "" +"hex escape \\x%.*s of %d characters probably not interpreted the way you " +"expect" +msgstr "" + +#: node.c:611 +#, c-format +msgid "escape sequence `\\%c' treated as plain `%c'" +msgstr "" + +#: node.c:750 +msgid "" +"Invalid multibyte data detected. There may be a mismatch between your data " +"and your locale." +msgstr "" + +#: posix/gawkmisc.c:176 +#, c-format +msgid "%s %s `%s': could not get fd flags: (fcntl F_GETFD: %s)" +msgstr "" + +#: posix/gawkmisc.c:188 +#, c-format +msgid "%s %s `%s': could not set close-on-exec: (fcntl F_SETFD: %s)" +msgstr "" + +#: profile.c:83 +#, c-format +msgid "could not open `%s' for writing: %s" +msgstr "" + +#: profile.c:85 +msgid "sending profile to standard error" +msgstr "" + +#: profile.c:203 +#, c-format +msgid "" +"\t# %s block(s)\n" +"\n" +msgstr "" + +#: profile.c:208 +#, c-format +msgid "" +"\t# Rule(s)\n" +"\n" +msgstr "" + +#: profile.c:279 +#, c-format +msgid "internal error: %s with null vname" +msgstr "" + +#: profile.c:952 +#, c-format +msgid "\t# gawk profile, created %s\n" +msgstr "" + +#: profile.c:1331 +#, c-format +msgid "" +"\n" +"\t# Functions, listed alphabetically\n" +msgstr "" + +#: profile.c:1370 +#, c-format +msgid "redir2str: unknown redirection type %d" +msgstr "" + +#: re.c:573 +#, c-format +msgid "range of the form `[%c-%c]' is locale dependent" +msgstr "" + +#: re.c:600 +#, c-format +msgid "regexp component `%.*s' should probably be `[%.*s]'" +msgstr "" + +#: regcomp.c:131 +msgid "Success" +msgstr "" + +#: regcomp.c:134 +msgid "No match" +msgstr "" + +#: regcomp.c:137 +msgid "Invalid regular expression" +msgstr "" + +#: regcomp.c:140 +msgid "Invalid collation character" +msgstr "" + +#: regcomp.c:143 +msgid "Invalid character class name" +msgstr "" + +#: regcomp.c:146 +msgid "Trailing backslash" +msgstr "" + +#: regcomp.c:149 +msgid "Invalid back reference" +msgstr "" + +#: regcomp.c:152 +msgid "Unmatched [ or [^" +msgstr "" + +#: regcomp.c:155 +msgid "Unmatched ( or \\(" +msgstr "" + +#: regcomp.c:158 +msgid "Unmatched \\{" +msgstr "" + +#: regcomp.c:161 +msgid "Invalid content of \\{\\}" +msgstr "" + +#: regcomp.c:164 +msgid "Invalid range end" +msgstr "" + +#: regcomp.c:167 +msgid "Memory exhausted" +msgstr "" + +#: regcomp.c:170 +msgid "Invalid preceding regular expression" +msgstr "" + +#: regcomp.c:173 +msgid "Premature end of regular expression" +msgstr "" + +#: regcomp.c:176 +msgid "Regular expression too big" +msgstr "" + +#: regcomp.c:179 +msgid "Unmatched ) or \\)" +msgstr "" + +#: regcomp.c:700 +msgid "No previous regular expression" +msgstr "" diff --git a/po/insert-header.sin b/po/insert-header.sin new file mode 100644 index 0000000..b26de01 --- /dev/null +++ b/po/insert-header.sin @@ -0,0 +1,23 @@ +# Sed script that inserts the file called HEADER before the header entry. +# +# At each occurrence of a line starting with "msgid ", we execute the following +# commands. At the first occurrence, insert the file. At the following +# occurrences, do nothing. The distinction between the first and the following +# occurrences is achieved by looking at the hold space. +/^msgid /{ +x +# Test if the hold space is empty. +s/m/m/ +ta +# Yes it was empty. First occurrence. Read the file. +r HEADER +# Output the file's contents by reading the next line. But don't lose the +# current line while doing this. +g +N +bb +:a +# The hold space was nonempty. Following occurrences. Do nothing. +x +:b +} diff --git a/po/it.gmo b/po/it.gmo new file mode 100644 index 0000000000000000000000000000000000000000..05925e491476ef670e148198f0c7d37c280de6aa GIT binary patch literal 44170 zcmeI5d7KF${+)YCQY zMbgOFY_{1k5H_=#eG7p=AR&f_L-2#Vu!JRH3xotn9N;}-AS5JC$oF^dt)+XqXGY}n z-d}G%F8#Wy&fU*F=iGB|9e?kXhrK4??-j=d!I|Kj9u)*nYEd1i@p$SAx6> z-VTcHL*Oak7r;}&zX8t%|HZ$5;!^i~EqF4|p9Y=;-UvPktbxk+1s-1yp27Y5K;?TM zsB*puJ|6sMa5*?|t}EwaQ0e!Aj|L||Rk;O<{^g*`eFvy|eGF8&Uk8_gKLcmMC!FW< zy%T&g_xFHL0e=BfWUvb2BDfoTBKTZz1bjWX7W^8h@*Z(Md4XqwDtC>?O`zI!t-o)8 zE4aVSnzyw^YfGN^j|D@YZBwGf{JUhi=hRDO4X zkOZFt&jNo2s$U;Xrs~fNz`^6FA9y48&%PiC=$hcWpxS#JM4~?pR68yLHQv{N`@jgK ztAhJLwfo1Q`uRan<8vyFJq;WLPXIT78jq_$oJ!{7#RoyS|i z+qwTVsD2w=<;J@Vsy(j*Ro@ST7lB^|L-2&vu6;wG>U$-430MQwu6KdT@AIJ2|2?So zoUq2FKNqCPU=zqt1uanN-V9Pia4)EFegG6doD37{{UxBrXCJ6?4}(hoMo{(rEJ#-d z-v!nG0~fk+9RiilX7Chn+CP5|sQSGbq^RK2pxW_sQ28#W(c;TJpvu1$RJm{ScpoUf z_(xFrpL8+223`ch8o?N-`o0vT3xfCh=idfJe>{_sp$m$j%G(F(`E4LW7<>R!e|#HM z|2>k*sl4++weM-5`stYXDR6QRAMIT=3`ehVUI~$yUjr{ZzHJm6aN0ipvL)wpvLc8p!(+_m%I78 z20SYWf*U}kKLYY!@J9X--~F}6{{;0u+~DT-Mo{@a4Gh7T!c z+Z~|l@j_61^ZOvI6Z{<*f=}A$`gI+sc20PF4R{9kp9LjnzYnVX<2SkbtO1qp2uKry zGPo0b2dIAkrGGxe;OTt?o&&xQ+zkF1cpCUvZnl6!pyb$1;Q8Pz$dm}~2CoCZ0jeKY zLJTVg2SD-BT_8gmd=zAef(JlYJXm$5D<=Za<^IDUEE0SjRDYek)#bkhT*m#aU<-UF zI0&A86}$>w0S zCx{3PJ`HMoegTRf26s4qxgJ!zp9?De`$5&`%U}_FID=aN*LvIss{H4JD*uDvYP^39D*teoOLrxx`Fs@AxP1^*y?zX;o{!n> z%D)6$&HXs2et9*he7*pR?w6qIdDb3>TRh$bYMkB(UJl*^J|27!WQc;3_jS2&#T>@%VXA?fJRC zKkw;|@3w;%@q88(e|!iOfBXa#e-y8G{Bb>~{=EZS0{$T=KKvFae*G1AI(YgGZeFYf z)vwoq;_qjHYVUi%3&Ah>`-kpx&o2NqpRNIwt_?m0d;@qY_zXmlvXO&!k9{^9}eil@|&j&97KMsmteg=vUP8-J_J&ydrQ@Fpo?D+7b z;2GS12GsNKf$HxEK(+V8iW}!aP|rs}wdY3gBrpb_1l|fh7QD;j`$6S<52$><0iFr| z7}R`tMAh-{nPABMwV=`;1|JQ+5EMVX78L!5L6v(Scpmr-Q1j+NP<(pc1hx#g6O>%} zOYm~=p_5JzYyy{Z|5ET$@I&Ae!G8o1SwS%6=Fbi=VGe&^1lY21O5n9 zeIFhncoz6Q|NcSn3dVU&&8;We(~j@H0xG{>fP>)U>W)vJ0xF*|5Y`WF0rmbn zpz?iK>~JZl_FfJy0j~koe@(Cez8KVaeFPMrd;t{y{17}BeCUiDw*t75`)#1gc^0?~ zd>1G_|8xKRKfn{XKmR6|ekJ$-_q)LXaJ1pZW2eV)k1g=gyuSn72)-H|1-}Wt0zA9v z>h&RT4fkIHRqx|kt{rE9lA{|z)$1rIKE4}NyFcmQf6u>vLfhrH4itag0E+$=Q1o|! znveH@8s}ev>W?LdT=}D5$o&!ULhvqd75F7k`1*FT#;<$nmg2z(VNy3c#O z9~AuwN1Plff+}wVsPU+RD(5!v$>1kI$;}5qjmK%TjxRTWs&5Tk4&DV8!TUg^`voZa zOnh+AAfPX|@b?V#%S2cX9Nr~dt#TV4GQfEt(Qf$E2Mf-3)8{{GR= zcJ|H{pz?VxsC+*GiXZL=&jwF=j=L{{nvc7|bHH0b&4)LGdVU|Ma()JCyv}>B(?d6a zo4J1jsPX<=Q2cnx^XLO`6jVQ6hU>H?f(_H1RQ+6EB7i;0g z{zZ38!eGvN8)M?8KDRR07oaPxZ*R6nl<)t(4E1AGa11^6EDGVsTs>N)g6r{DL1 z%J2uza`oK;ivF3P@_!S!4*WWJ7Wmi~yLt?R>X&Q56TsU*wew}*Ht%op*Mh3Y4d7nzwV=xT zsec~6-09Q(;3&@zd;Ao*nfr&{iH`uh3S0`l6}%Mu45)s15LEsbA?#LwH-U6r@D^|- zc>XKVA>g&(a`2D9BKSj4{CUc&T>oDQp2vL!RJs>|qW^?{|08ga`{RDc&4UX-jr&gU zNni`qINk}W|33hVpML^XK?Cx_-F| zlpMGnTn&C4R5|y9s?V8ka_!#@svfhT#^r4uzXB@Vac_40x)xM_-Uyxwz8TcGe++yA zc&{{APR+HuBP-MCx{ZsGngD1Q93$K&sI^7v{{{rMJ;UjfBm z4||)-cMYg|PJyC(1E~J^A~*s*{Ozv)E(eFWzZDdJycg7Xe;o|L)8FCve*`>-`x`-x z(=DL-@wNW_=RmdV$Ds0g(mS1=*$k>(&j-cF9|q3^zXdJEQ2hUB&ef?!N{;lXL7$E$M2_-J_2`x{|lT2FYq)^;P>fV_i~Sz4!+0rBQE{@ zs{{M@DgO5X@E^FwNplF?4!#*If_u62_ayKyzzDpBOLP26uBZ6-{0z48dm~r?mvjBO z9`ZMxqbd2{D|r4iu9y4!{}5r<-&x#0*1!KXza=mJfa{xF599iMt}5@p1D?qBQm(7G zp8{j9&0P9>8P^r|%l-2!;5wgg@>sgzQr-CH@AWU<>ha+`-^Fzc_dB=-{PX8}`cdv5 z;eYFud@3dICh!!lhx7Z1To>@W0bU6vf6wH{A9Kz42iJQ11o%m=RnTto&z{Ba-TeL` z7osz`ko$F9yZHTWu1|A)f$L3N8+oq3gW&VQXK~%Z?+xH#@Bwf=_=n&W_`kuw=Xw>F z{+4q+j_0r7k_^}1VF&i_@jPG0FX^M?@0mP%6gOqApKv{$`$vMOa^22v{S~-sTt~Q` z!Lyfu`di8GC%B)%GJc=U^+N9d2iH!1U&M7X*E6_3+tUe_@JxTd$Mqrm<^I_U{G97z z-al5z^*nyJz!QC%Gx@E*ssq!(H~8N_2LFlcwOsq5e<;_}e7YBbH~8QCc>ix)NBsR7 ze&5bD!TrOyuH*Mf8H*!n|1Z{_*`*Hd-F z-#55E$8|E-%ee+fcOUp@@T;Ky&f@oRTz|*!|KvJD5BXclHOX}c*J|EB1k~T#xt_yy zC(m97CV%hZ$2D9-T$l0ga!`N2;kt|KsBZXsJnxdfz5d7J!J|AM1DAr=a(#>6A(#H% z?;w}}|JMH&+?4zMYXAF}xo6KOpD%KM8hE3B{zQK3@1kO_6_iy9+I@h0YZQ}|~ zJU3j{499D6`QTu4Xkb7OcC~BO^k%Yj_+U8Gh$o_2bwyZiR7WnKVdm-3-?WwTBX{J z%CHvITl?0#d!^lO3ERzTu~shD+tbxXRMzty_B@_xMbptyD`lrWnTeax5fSXlDpQW9 zr%UxpTA$rU+2ql9Y_!+fgG1FuGm7gC00ztK1@&VyRgipKVpGd1ZUqYLqHbi|k7^rKpAl`gO8Vnl84gM_L84Y{u3=T18}s!b7FTdS0vDrDijltaE2i27&=tW^=n2|XfPL&Q-X;=u0sk7n0mhx{+MU9H?O4C(_QEgJ)N+Il6pRAVXkT4#9CY@!}akz9@ zb7?qHf{iNSpsOU6t&D^%&GtrhvU(((jw=z9wGoc393CECxvX3WD{-}1FSNqLapRx{ zMPovaBi1WvkASV@g8Fh={Z5)vqfweY(5Oy`Uh+f_txM+AtU5i@ znhgi*?OJWf(fKDwtBu${Nd{5kfUYSP!va-y)bvN%Iqr$4f`su*+XXwuhpm78;CB)i zi^ojdsNU3$8dY&)+CN>HUPt2>Uj;`^gG$rm(PTSr`;JQ*gxFGc3zj?P3ETBXwH!~@ z5ulY7A@e$JRGIP`3!i1Ltkk{Bkim-}%SNHuVggPg1YprpO|z|5f~T2ins3eac(WC? z+N~;FF8&Rx6BCYO#g?$}fhLs<*TbhPJoBUvTut(ANowy#c%Jt*r~^TvIg4zXhC>rc zW-~|(!5o2$y{gc(s0PK&En^yEaZTmTyT!#+Q=~h0?B4qHP;;X=oz$bqzE?*J0ydtKn z)&?6B4IB<`912%odda0L`1jJ)MdaJ&2EufAJkdH_YE;9`al4M}rvSv?o+(WXr-GFE zgh-p7bX_u>^&1WwljaIfF(#%%s`6^U%ephUw{c9o1%Hh+Y*RHQO^%Z`De$ z)$5vZG$cJcQEgP~*R>SGiY&gz%gws)Ty3|6eqL&X>t993zmPU%yx)vj`RI3iB zdCwp^;0@+98lzn+HDF(!VIIK0NkbdbKw-6>HN6M%)z#^^F-!8P5^9ca+P)bhprtug zuTIit)SgX*V0%oRsi%HW)}aUq*sJ&*Gw_}D)pq)SciR7MZc35az&MGo*%kDDv;RmT ztTxM~nQF5)MQjBzAI2`Ypid@wlJyCVI6?EIqMwJG) z87ulw!`q|#cFpO2dM*x85W(&#nN>;7Jqt@^4)%YrJ8m>)S0LP^=MUCVhf`dPgBghQ zc*|r_u)AF@Gt$AHjXPIv-Py_YNHeP2$@kr|CKD+pT_pgf=qCgR6B(IuIKqyEGqL(7 z+O-t}2%qq}t$VKAv3F0nVf*#rbsKi=+OU1k_3NN)O~t&e9)fF?Ps9|DkShp0m=D7t zo*1}#bl1i!q2F-D)@@t&T#v*EH*ejueRTKkaPy8`;f8SMhFyEMZrr(}W-d*s* z=x`YBMjn#mz&w&n#v#1R^s2V7r<$@V_cZvWX`xBpWFAiid+Wxv)M`*=?;p%P8L}rs zxhMPdWZyG#Pxjv&>~$Ihb8nwxRcKVPW@}dFor%5XjbU!75bi4$Z!`fGV!;h8HU~?! ztn3xTvT`nm>rn|!dK=@{Oi>8{<|d{y95ADvUO@5>l#J6gW>9A8XE@wCA&zmj|5U3r zGqQ5!;lqcAC+qFuxG}jB?IF$4TuD0;WmpQYsKO=NO5@F(;>_NTx1(B%l})PCF>tWD zOLeg(yoF+`PDFLYO_s*gLOLVT7fMkIYsjLSmO_!4)Fzyhq>iHF9Sfc~J}5>Imq?L> zP_LJ;$)`${gKP&DTxL0pvA)zYwh+eXuSQfsVDW4`s+StGr0@MYx5CWPtb{uMrZda# zWuX$9kwVeVmW~>YYOQ*RxuhDJ(Ld(R6EjNY*e+w6w~lVxbluiXd#>Ewk7DPBJ$+tn z-LiehuF;Jfc8~TU7{~TGXz#4ky^V$pXwpp@rZ}F_3~It=Xo|6NTyI5nEkC?EHmMKS zb|wkNDl`*KX)BXHWjm5VBN_5E>OrY@V+vbA$IiCb}jd1z_jZKh~r8sWKw8B?p)CtFjU)$V5XI#nfoIz6;HCzpvvJWZ$O z>f#8I%qF@KNNzdGAt`bYn=d*SN6e_qWuYvu9tEL>+KqZa+94ao)N?86i(ucalzX#wVDReS?W@rV<7eHd|8(M-Wk7z>3Gb>x=p{+`7pe z6!Q?`9*Hp;lGX;LCR|FjJJNUcfg|Zk*@GrpL_W|gkdZt|^0K&*M7pTL-bbe2HjWss z^)-v^i+M=9suGl1Ecj;3$Sj#LL&xBoWNaC=?45gnfb@S7$p_o9@P4Xq{=YlR25?*(HDtuCsEy| zf;!mB%$oz&gVOX7EX>5kF_`!gRG1QDQ)A@fxQj4#bM!OVujYsAOM|NFMbs^!%+in) zlhx6kW9x8?Q9RqL^p$h-S1w)xCZ{)|gy@>06c#-S4!rbB2t0Q#7K@ z7A}NFKKtH8jAE{k-ZV5NPt-9PWU{&Xz>2A{#+bPo=arw^a3;YNx^wj$ueOjgPQ7F21Cf`@Sp3po~1#f(dkbl zS2DuIY$Y@9u!uEb)VV7hF{7GcgOv0)_JJ)nWD96<(V-9%e`k`* zoYy@J6C0Jedd=MPtSQE1gHgpXnN5YDJdLYG;%X$wD$Q;|yE&ynw{b~kNUp~ie79d^ zX;TI6nr7ybYc5U`s&X)znbAPSEPQ32^sr2N7$$l0POHQb_cTf@Q6E*Dni=I7?{QDd zB}bBMpvV@NrQ}x8QC(7Q+T1}jC?PT)uyNJgI^4iQNafr7M4G3)GFst8kMhjD#=lXt zvQ}2AhgNF8!7bf10RwY}WwV@Nuw96tQpPx!q2l*Jl0}BpIlD^EYldCjs!lRqfm=b0 zNK3HGk}@lE!eo#=2`bT{NNzNoqoFoA(2=Iy8Rq`4G_S^%Eh{Wcf){FmY*vb-jU&az zhLzDo39FQS3hzKvS#Et5j>i>RmC}|=2sE=~fG7<*PD@lEBYRiQjj_ubLU2b1srdBeBC>H|!vbjaivPl^>62yog zTXZ;r`KN5=+s#yAUhLYgO=jde7Es3CBkZ^n(VkBf*K4zGzsGIsr>Xol2s?siHIc?# zHJM3eGna96+a(E|l)bHMQ{RtGFmzgKi<#FZmoRv;Wf`K8Ez^-ht=Hv6)(XGO8blng_P*+;%`3l8p!U zE1k7Wg-qRdDTjsZnk12Lq|YK1C*C;AoBJzlW#UCgT4-nbY~A6EyLr;fTbbG^);%5e zNh)aFD_J};VDod^?=3lhhD1#*p45>K#xRiy0ZTJF3tpdz;UwOatLAeIr03$lUS8#BiQ^>tktCw1eLbiUY7Gu2P)dy{RtdZGw2*?4L7Z8WphSiL-#p;e(J) z=%z^%>*We#T=vrv^C(}@c@x`oYEG3Z@!@7TS&PSWu7<2g&j5+X0X@{3YQ*iyDK}wK zSyes47Jim2RXgb(YEFZh{?l*(zetT$d7EZ+Fon_VO`rWov{sa4 zftgb!YeyQ!@x{-YKuq^7nP}P_lmkR38xTS|U1C;v*J{Oip}O3p^HFxK8%5f~0p#@d z98WhD>?%L;^CrDOet9J;Q_?MJZGmz~g9(XSZRB=doGpb~sNz}_JEcVGD?1()VvFRY zagvG7;*=W^zR}!Ew}p_as-NuMl^)D_FCVGz%Csf67(&>yCru-g@?@s2WRct|1n7ud z5$U=#$sk-d*-esjj3-n}OYw?s*jcdSyn`D;2p zWY&cItEjy`J}IQJCectZm%OKYs+&IZge|^|?lcP&q+>g&Nb|fyUybeBZN9NNQpC>r zAXi~G+`Pra%`4Ya)1T(hsm;LrRN4DGoZDN}xH(MC?gu6E{bMMKP#D zBK0Aug;rdS+2c^=I)A~ePLyqjwHS~Jxq@p!yYY$tGv^)?_bIOGnAlHkD{H;ux@mRCXFDU3aT~iQ9-qo3GYAv!mS{iNn_b%VTja;d#B7 zn8*+>Vpq3s3LUz$!wXc*Hj8z3&2Pk-UP!bU^LlJ^AFlDI4RU80-9agQGw@%9>1u}& zF+FSwH-q^TaI}si+oM~yZg)OVs>G52U(Y-VS%}z&0Pg%$-~97rxTgBjaXJd#Le zualFSG&H||3P~F0JL&SM%%9|7b(RUm7)IjXPm&I`e`1q_H! z3{lefXV|nBX}Vc0j`Quz6Rux?vT>|xFYZW@>W2kYUfk%TfVz}bU%GBZg}K>8ENF+C zjdxB6r79|MsV2*UjIt|_WXCRDKxC9%mSy6wcRRUk&zY#0XT|H?X?FV4oH)kl@>pu- znMczfjY8Bo`&0V??zHIArG>zLO`w7C<|ZE(1enTY9fEbok8$@;BNU~JVGZZ8!IzF) zZ`djs(Q7l4iFU;HM9`7WQi~f+<<-Q^)2^FH<`yeddz~Z6Bjmj^Ol`Mk79Gj*CI8G= zwU1LN+X1H*oN%q^hSxA7HIIVQ$~C zTb+nrBJ@(IPZImKOLEkG_@e<_h|-*3jRrajgbfy-fWLUvx- zE+H9kILVgtC?~cv+H6uaVl+>B7#w<>X>2A-k}+k2Cg(HEu6Ex6I@8*(?rlFJaGr_- zT0t}ihs?W*U}zoY*yfS|Z+4$nB!ZAYS)E6%B*@+NTK-Mu&%l|0daPFu+gXsjooW6b z=l&oMHh{D(%C1$=U$@M$ru&n2tY|!0x4D&S8a1L{-d$rdM{zZ8(orq%-!Ttl%6dts zX))}`I@UyU+y_k-Q2ox5C3yv1J{jG!<0!G%`8f{yWWufE+!Xd^7K5>K*N%-_w{PCD zZ)rla^u~_8ofaC0e3SHPrTx~ONd)G+9g*rm<}|f^{R!K4Y~=UKRpc(SZck3;-jGns zovOlC%QmnA`yvVD=^Pt$w#;}_#c-AOZh0cZuZrmPH00N5{2<+G?V%o7Ijs<0wmw`n z@7vWq-ukosW+wO+T7{UQ`Y^~&9%{CtPQ@Ymu!?4=KjcW7WM4FEQgY5dJFwV`zN^*! z6Zy%S)T-$=uU&CzO}cWkS!$wx1^#eVJZtn^Qa-lnJ}%~Lr!EQOtB~^dZ}DX#D+4ys z4(lH$-jHaC3DF!5TCsNDx{csD<>Ch7%VT%y3ipPNhshnP6)d+{d1S<@YvGKNJ?9Bl zH0~p5w&PjhFwB`|*4@~)t=sn$f;LBJ<>RE*UQVj?&XacDR)jg&*!Kou@+?`wRLIFJ zNlTTVi!jWpFW{bIH}rfYMX63I-)_;!s{~52x_Dk9~%`%^m z1Zf6ra@m2B-!=zLb?=>((^+Sm`4~njpN-Tbo$I~DoMG-tk}9GFmxv_nnwE)j>J*cz zR3E}_Nx!oZ>qF+^)=KeO_p$zn+wosJyn6VO)dTKJ@Z#0Y$*5A)_us`mvG$$nETu1R z9;|Y-Z5WeaVCRlK#f_|(WP=tr!Gt5>npLaU6j!Y+uDK*!vu0$~+U2X(tXc(OaTmM% zI*pUjtrp$tOT*O{k6g57`Kr~>Z9^~>`Shobrw{veB-~JM#q}r-HzFsd$K&uRrK4pC zFQ1&od{rGTBaPcYDekG3rboi9Y^+BZ@K1?am)9bF_mYvY)!rJodh6ArS+iFUuNv5> zGtzvhzlX_-uNG(1N?WL|vkeifyY*Xl?HpFx(9~h$7YXxYK-BGJ5i6S)Uw?(?JO!#8z|6zm(1limm5j=FkAPT!Bayc2X zGpdz_!i`f=iDe)k|F-K#nPAmi&E2^1ZQ zp#!vDAsHW~Mbc_$!!!uQn6@p3eGG|sW=2P3Y9)e5Skd9wyg?-Dd}_uny%RZhX1~R^ z#3dg^0*Nc_7*QS*o2_;oXNqwhBY7ryfZ7OA@yw`zMHl~#*|xNjH6mO%sPHgG=JU0* zj$M={!@@*`ed~n+N_1qvhmVR_LJkFUt0$o)^7-UqODM1eXLVH@0;){mvX601wdZKthY4WS=KuM>jbVqR;XqZFp`bTNZsH*T*n}#*$L}v6`fpt;>Dz2|J8ziVK%sPKS#|kp!Rck8S=0)BX;x>sYhf#3Cu@1SgHk=f*MTNMT>OgM3&(se zu!ZZdqze!WNvpM6&#as0y^mvojKT-wcrT4M7Lp4EG@08zaz`=)zQ!YyB$@@y=M*3!c^$r5Vo$^oQb)tfzBrPmx-t`As4ATf zQ(Y>NS{Z54k5J?2iuDFP)Bl5THZI%aigh6dt&mY^p1>BIsLRVC?Gffw%vzlLJQ&!f zPoIy%_z0a6M~`*3s#JH7weN z>nMwWp#k-qSSapbS0-rXH;Jk(v`9AS1ae?ptPaJaMmb5v2Y+9*fXwJ0>( zn>b3pH<&mssjLRr!)ZJC2`3#2QNB7{t{BoA##finE0rOo08%_U7UzetON?KDWjj3p)>dA2&J&QTKj$2~P~R_$O1 zV#ApO;dTagx7#3wyL~teRox_u^pqxaujhVeRr}|?UP~~$jZm`4!f144-9^J5@D7tf zkrPbB(Qq;;3Ty59BzwBdQS2wCZW2i&>Gz&3#t(rvqlMG6)O#f1T4K0JD&b8=il)W$ zHTt2bU-797j1*gACgLzCyr84H%n>i+j1TB>v)rr)eQ=F9=$u_X)`q1`hM^jGNtZ4c z5Ot|&gC`JUVpkf+q7Oc1w~_O+a7qg^ZN1Y*+5v08@6s( zhgB`|dNr|=vAC22NiDzzhc^&#QMhr()e5e$)kW607a_HE(~j+ZrBv=-R>i6 z>>#qnXt;ahj-5M(2dngXTnkTfz{JC@n*O)GKgxA;1`JJ` zC7EL$SZ3mFTU6A&R&f4S4TfytCjUQ`1?Vs$5Z}bB;nOW8gFK74;j&MalcEa|&!ehk z5Ym$cMfx=leoO5I5cePny3zYxKCVVaF(=|iE;s7X5r(lqvNYa?Gu#NcLDdy-gC#AT zU~8Q$^xYxOpp9Sl~xjnquf^PIqo{zfGo5F|PP#;n$8w_kso1CV2$`Pwh=2}H} zvMw$B2F*hR`S=@s)1tR5d3Ows-ZgQb(52BVx`}MvsBU(yS-LV9OTQcG*Ec@E2I@15 z!%>n&R&X3myUc!ft5dNRE%S+V9Kf@DYZ+e+Y~B;cf-~jbCJ85_@6&L?dLTeB2=Ygy%wCF2 zPx|PnW=Ny!U}Chs;&?=T5_uy_cA=xk!a`@szGQJxs#`idw>9K&=i*U)eZO-PG5pHj z$eg!3zsl?;bn!X*=9udSAMFFuez|rN6R%^@89UlVFb#z%Kt1$Z z&)kwrsvS#AQ9t@t$nPZ3cPU}N+N7j%l`}YpYqwScCcCwVSK=Iq4;JE;Z6dlU$byNeK=!H;%zk}ohw>s0b6G?Y$vpbAbWod4*)nY_R9l1NK8JsB^Z3J~@=ve*ai_BV{^@>)|$WCM?^Clg> zT!tki4LKHcoUxGd0|#LEX4yMov(kGL>qKD}dE%tzte?xjhm56T7FEnR2a6l#b59#7 zBgdy*IZx@(;A^IJJxaGPS+kb$AwQ)=M$L4!uAGOYH$~=9$6tnbzx90=w**VP*~Y-J zpe2Q_Y!^<%iQ!{T!|Ar}M2>Y5LpkMzjB7HMic{I49!dt&qPf$XtP!+#AG2@73d>9q z-(h&qeWa6ox=tpr@_LPZQcOyo=Sk}TTe68Q;bqGv?`t2{ylOZ7>#i6mIhTBrCQn@; zN{K!pK;=g>;xa3)H>J&!In|Mnc0A;FhuE}*_iaJhJ0F$k6p+5;oTo%P)o6~@IX&OM znj{hn*n*{dyjDOT^8(={~84}w;eNYx~c3a$p1zN5`HCd$e+ z9D2Tius|vnbpaV|$FOqdN|H@aqob!a>&xw#fFKobBb=Yu_w;{#9Nv_yp6eO*q3X3^)aKnXKDap8_v*ZPm z5lN^Ouc_5H9rok*6XUTbdE%av<@kMOWS7}!1!(7_+ssXk4GXd|&-<AsS z_zeYFfl*ENvdH03lBtn7(>9sl^9bg2iqD~yXQh9(7KO!ib_Wp?qgwQuCJV))nrd5A zr`C(G+6LU5NG!=LfGzMu6Mco|7M#DfpmB>TrNFHvu`^MuilU)$S2}8d4rl$~ zTm-hVu(zFdl)|W(5vj^)|8IfUGR`_;w73<%#dvXco$b#+q5v#D3QQjw#b`0^WBnly znfqFe{kXn+PNG*W{;hME5Y} z90>?31qIA^3&J@uT@nv^$v$Y;@*wpCxu`BWu7%|x!QdEA-g}+m6T4XF*ePg?QA{V| z5ZmUO_dL637(R5`JYa_pevw3Z9+f+LpxO1r}Yp22%Wwc{*1wu+=G^_u>zdWVh6CboY}L>HLG;>Nf=%*?o=PBsOseP($qHXST7 z#{%?eEw~FK?QgxuEtz}0-{#`U%$tjSJ~bzz428K!F)Fo#b247*)M{$0k1o@dM)76v z;yELui(TnBPBWorymWcJKx33yBIU9Co zPl~DiqRn~xxle6`GyqM{tnz%|ZOeHx>$LJ%__Bz0Gr7~G%XEhIvY9r$WS2H2yj_Xm znOI-8rk2vm%PtqRCSZ@iF9bS6)&$P$%|Z!FFzPS081XX;c-(#dfW?I!Exk(|G7ZnT@u zm))7CP4OzZq~lI}F`coJi+WQHP#j4OlWh(e$$7>RgYxC97YgbOoNkEqtkA{iWo@rG ziHQ}d$TpMS8^Sz8dTbWchKaG`bW;!a$q6{4RuI{$>B?Su>D2K(J))_1elEY}ZeN(F*Z#c%w z{&-Z5FqoWH50buPl_Tq01v)~?!G6szeS(ZHR0~^HCi{b!WeUXKxw1!j@G*7lI4=w~tj`wQDeIeV;mxwXN&Vp) zyf5glep_ux03Bw{0=sQF%6=@Ga#LsY92iLx5B5rW4cpp9)Ny{(ysVNA3w&&xo>RHU zA<6#a$>1kuMvw%=DQOz#7g6^!liap^;sjviSY{yw(1;4Dlct^PK+4Z#XI#-RG_Dhd zWMOdpaww>+0{6h8I=|@rHe-s})6@599U+HB!KFh{RM0s24HCC>^OCVtm*CQubS5v7 zwP8W=dlY+-FYQfW`H7#BvQpR9lcTV0Do;UhAkGF#&b#0}Fv%caILAXSa*svScZXzT zaa)L>j@_xiWq_%hxayI87TAZv?2I=}GB-iqFKhE+(J50~fANLomKVp6$i)D1duBo1 z`HJ|z3YemoGS&Y$RkL00kRBS>4mUcB$()qvPF$GUFp$5}y^w9s|KgBQGI^i_T6&av zvXD>76V+`9aJQ*;O4ro4i49A%l7{ zEj7=bm@-Y69H{c5$sevwS3PuFFkdRIPngY;Jjtn*B#2NrrWiu=rtUfzdQ8MPQ0J>y zrpTrBv;!}z!In@KQ)s@ly_uw-AkFiZNji*3j_wp?8L|H{CMoOB?wJF0jQOvix1pmNK$-bH;3iAPqx|V%`*+Tk?-L1Q^fwVIs ziSE-{0pY8DV#L=T#Gsy&TP9i^%ls+J#T)ige=oI@Z zycFaD7_}li|CH9@hE{h;TS>mod4c5Z_q9vM(VWbQ;7*cpOqDavR$X#7RnAE$*hJLg(Q=A`Vdp@w}N!LogaH#t{qB&X4W< zesRhhoh!qHN0RVInLx~arpHbs3tX+eS6VP6HX?|(EvG)ky6uOJZ1l0Lq~%x`_jfFi zoWzGSa@i0WsaGb;moFk4+UHHNG(&lhl7+cBG4y`|V&^0w^l_8o-u04TvF(?f&{WW* zaE#bVy^}b{m^rO*wexW*%}e(5YyA2ob0ZurPSE#Fx3IA9 zn{-ht#3V@4!s;SN*-r_iD@1&^llB!E8rU2SE~XL&xq>R?NYV4#H4rD8K8&{7r2 zDErX-E$++uywk`wH#m@Hp`fz>OUaotMF2Sz^PPkbvov=_msZq7b?3QQw{PD0Leta> zVQWvenkh&w&BTQu^Rss>2VhT08a4&uB-#>P&G%^ySTR{JJ3q%9kB*O})QesfvVDxi zH{xmM*sm1MSHt$fGNldoUUX#z^&44DRp-k0;gw`Ju`s9g)Ff+1y6{iqFy-DsnRdJn zz%z2~Xs{@?z>(U?y{P zm_aO|sM84gc!^zacaBpBEVBe|$<=utyDLtUeM06lSLb)eY3lJd3t5zvL-AfL+5bKj z{*g-XjrFaPGnXUgvXgSLnzB4pxOp=5o~=xs7P1tuW7-!<|K*yVrqkYkXFBGl4+)j@ zY`)J_bjh7$NyvI+@6Qv!eda6GC&5_{^rlBfp#~WUJGILgWYafDA~?;RA$dl@CGGwv zfAYUk=bqNc!a)Pd1$_#~kw`lmf@Mm?IQAacEy%@mn!hGCtmz@!?n5EY8qUHx&7T(^ z>$$Isu_%(TPLi`25o#nxw=4)}M`0_v*iLh0G6qThI5bR?e9#yLZqCc0pM6qpR`Z-i zWY>EyUBpagXp4W-7m9ub%K9Oh0MZ64r8v&G1w==1u`Vn*fCC$mCDWQ&o`kWs!z?No>MQ2k0l^FVD* zf=0<*%>Q}V+iUJ. +# +msgid "" +msgstr "" +"Project-Id-Version: gawk 3.1.81\n" +"Report-Msgid-Bugs-To: arnold@skeeve.com\n" +"POT-Creation-Date: 2012-03-28 22:03+0200\n" +"PO-Revision-Date: 2011-03-19 16:52+0100\n" +"Last-Translator: Antonio Colombo \n" +"Language-Team: Italian \n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-1\n" +"Content-Transfer-Encoding: 8-bit\n" + +#: array.c:140 +#, c-format +msgid "from %s" +msgstr "da %s" + +#: array.c:248 +msgid "attempt to use a scalar value as array" +msgstr "tentativo di usare valore scalare come vettore" + +#: array.c:251 +#, c-format +msgid "attempt to use function `%s' as an array" +msgstr "tentativo di usare funzione '%s' come vettore" + +#: array.c:254 +#, c-format +msgid "attempt to use scalar parameter `%s' as an array" +msgstr "tentativo di usare il parametro scalare `%s' come un vettore" + +#: array.c:257 +#, c-format +msgid "attempt to use scalar `%s' as an array" +msgstr "tentativo di usare scalare '%s' come vettore" + +#: array.c:302 array.c:707 builtin.c:84 builtin.c:1385 builtin.c:1427 +#: builtin.c:1440 builtin.c:1859 builtin.c:1871 eval.c:1135 eval.c:1139 +#: eval.c:1495 eval.c:1812 +#, c-format +msgid "attempt to use array `%s' in a scalar context" +msgstr "tentativo di usare vettore `%s' in un contesto scalare" + +#: array.c:513 +#, c-format +msgid "reference to uninitialized element `%s[\"%.*s\"]'" +msgstr "riferimento a elemento non inizializzato `%s[\"%.*s\"]'" + +#: array.c:519 +#, c-format +msgid "subscript of array `%s' is null string" +msgstr "l'indice del vettore '%s' è una stringa nulla" + +#: array.c:723 +#, c-format +msgid "delete: index `%s' not in array `%s'" +msgstr "delete: indice `%s' non presente nel vettore `%s'" + +#: array.c:734 eval.c:1865 +#, c-format +msgid "attempt to use scalar `%s[\"%.*s\"]' as an array" +msgstr "tentativo di usare scalare`%s[\"%.*s\"]' come vettore" + +#: array.c:910 +#, c-format +msgid "%s: empty (null)\n" +msgstr "%s: vuoto (nullo)\n" + +#: array.c:915 +#, c-format +msgid "%s: empty (zero)\n" +msgstr "%s: vuoto (zero)\n" + +#: array.c:919 +#, c-format +msgid "%s: table_size = %d, array_size = %d\n" +msgstr "%s: dimensione_tabella = %d, dimensione_vettore = %d\n" + +#: array.c:954 +#, c-format +msgid "%s: is parameter\n" +msgstr "%s: è parametro\n" + +#: array.c:958 +#, c-format +msgid "%s: array_ref to %s\n" +msgstr "%s: riferimento_vettoriale a %s\n" + +#: array.c:963 +msgid "adump: argument not an array" +msgstr "adump: l'argomento non è un vettore" + +#: array.c:1086 +msgid "asort: second argument not an array" +msgstr "asort: il secondo argomento non è un vettore" + +#: array.c:1087 +msgid "asorti: second argument not an array" +msgstr "asorti: il secondo argomento non è un vettore" + +#: array.c:1094 +msgid "asort: first argument not an array" +msgstr "asort: il primo argomento non è un vettore" + +#: array.c:1095 +msgid "asorti: first argument not an array" +msgstr "asorti: il primo argomento non è un vettore" + +#: array.c:1102 +#, fuzzy +msgid "asort: cannot use a subarray of first arg for second arg" +msgstr "" +"patsplit: non si può usare lo stesso vettore come secondo e quarto argomento" + +#: array.c:1103 +#, fuzzy +msgid "asorti: cannot use a subarray of first arg for second arg" +msgstr "" +"patsplit: non si può usare lo stesso vettore come secondo e quarto argomento" + +#: array.c:1108 +#, fuzzy +msgid "asort: cannot use a subarray of second arg for first arg" +msgstr "" +"split: non si può usare lo stesso vettore come secondo e quarto argomento" + +#: array.c:1109 +#, fuzzy +msgid "asorti: cannot use a subarray of second arg for first arg" +msgstr "" +"split: non si può usare lo stesso vettore come secondo e quarto argomento" + +#: array.c:1655 +#, fuzzy, c-format +msgid "`%s' is invalid as a function name" +msgstr "estensione: manca nome di funzione" + +#: array.c:1659 +#, fuzzy, c-format +msgid "sort comparison function `%s' is not defined" +msgstr "funzione `%s' non definita" + +#: awkgram.y:249 +#, c-format +msgid "%s blocks must have an action part" +msgstr "blocchi %s richiedono una 'azione'" + +#: awkgram.y:252 +msgid "each rule must have a pattern or an action part" +msgstr "ogni regola deve avere una parte 'espressione' o una parte 'azione'" + +#: awkgram.y:323 awkgram.y:334 +msgid "old awk does not support multiple `BEGIN' or `END' rules" +msgstr "il vecchio awk non supporta più di una regola `BEGIN' o `END'" + +#: awkgram.y:371 +#, c-format +msgid "`%s' is a built-in function, it cannot be redefined" +msgstr "`%s' è una funzione interna, non si può ridefinire" + +#: awkgram.y:432 +msgid "regexp constant `//' looks like a C++ comment, but is not" +msgstr "espressione regolare costante `//' sembra un commento C++, ma non lo è" + +#: awkgram.y:436 +#, c-format +msgid "regexp constant `/%s/' looks like a C comment, but is not" +msgstr "espressione regolare costante `/%s/' sembra un commento C, ma non lo è" + +#: awkgram.y:528 +#, c-format +msgid "duplicate case values in switch body: %s" +msgstr "valori di 'case' doppi all'interno di uno 'switch': %s" + +#: awkgram.y:549 +msgid "duplicate `default' detected in switch body" +msgstr "valori di default doppi all'interno di uno 'switch'" + +#: awkgram.y:809 +msgid "`break' is not allowed outside a loop or switch" +msgstr "`break' non permesso fuori da un ciclo o da uno 'switch'" + +#: awkgram.y:818 +msgid "`continue' is not allowed outside a loop" +msgstr "`continue' non permesso fuori da un un ciclo" + +#: awkgram.y:828 +#, c-format +msgid "`next' used in %s action" +msgstr "`next' usato in 'azione' %s" + +#: awkgram.y:836 +msgid "`nextfile' is a gawk extension" +msgstr "`nextfile' è un'estensione gawk" + +#: awkgram.y:841 +#, c-format +msgid "`nextfile' used in %s action" +msgstr "`nextfile' usato in 'azione' %s" + +#: awkgram.y:865 +msgid "`return' used outside function context" +msgstr "`return' usato fuori da una funzione" + +#: awkgram.y:925 +msgid "plain `print' in BEGIN or END rule should probably be `print \"\"'" +msgstr "`print' da solo in BEGIN o END dovrebbe forse essere `print \"\"'" + +#: awkgram.y:995 awkgram.y:999 awkgram.y:1023 +msgid "`delete array' is a gawk extension" +msgstr "`delete array' è un'estensione gawk" + +#: awkgram.y:1019 +msgid "`delete(array)' is a non-portable tawk extension" +msgstr "`delete(array)' è un'estensione tawk non-portabile" + +#: awkgram.y:1135 +msgid "multistage two-way pipelines don't work" +msgstr "'pipeline' multistadio bidirezionali non funzionano" + +#: awkgram.y:1238 +msgid "regular expression on right of assignment" +msgstr "espressione regolare usata per assegnare un valore" + +#: awkgram.y:1249 +msgid "regular expression on left of `~' or `!~' operator" +msgstr "espressione regolare prima di operatore `~' o `!~'" + +#: awkgram.y:1265 awkgram.y:1419 +msgid "old awk does not support the keyword `in' except after `for'" +msgstr "il vecchio awk non supporta la parola-chiave `in' se non dopo `for'" + +#: awkgram.y:1275 +msgid "regular expression on right of comparison" +msgstr "espressione regolare a destra in un confronto" + +#: awkgram.y:1394 +#, c-format +msgid "`getline var' invalid inside `%s' rule" +msgstr "`getline var' invalida all'interno della regola `%s'" + +#: awkgram.y:1397 eval.c:2504 +#, c-format +msgid "`getline' invalid inside `%s' rule" +msgstr "`getline' invalida all'interno della regola `%s'" + +#: awkgram.y:1402 +msgid "non-redirected `getline' undefined inside END action" +msgstr "`getline' non re-diretta indefinita dentro 'azione' END" + +#: awkgram.y:1421 +msgid "old awk does not support multidimensional arrays" +msgstr "il vecchio awk non supporta vettori multidimensionali" + +#: awkgram.y:1517 +msgid "call of `length' without parentheses is not portable" +msgstr "chiamata a `length' senza parentesi non portabile" + +#: awkgram.y:1580 +msgid "indirect function calls are a gawk extension" +msgstr "chiamate a funzione indirette sono un'estensione gawk" + +#: awkgram.y:1593 +#, c-format +msgid "can not use special variable `%s' for indirect function call" +msgstr "" +"non posso usare la variabile speciale `%s' come parametro indiretto di " +"funzione " + +#: awkgram.y:1671 +msgid "invalid subscript expression" +msgstr "espressione indice invalida" + +#: awkgram.y:1711 +msgid "use of non-array as array" +msgstr "uso di non-vettore come vettore" + +#: awkgram.y:1975 awkgram.y:1995 msg.c:98 +msgid "warning: " +msgstr "attenzione: " + +#: awkgram.y:1993 msg.c:130 +msgid "fatal: " +msgstr "fatale: " + +#: awkgram.y:2043 +msgid "unexpected newline or end of string" +msgstr "carattere 'a capo' o fine stringa inaspettati" + +#: awkgram.y:2300 awkgram.y:2358 awkgram.y:2542 +#, c-format +msgid "can't open source file `%s' for reading (%s)" +msgstr "non riesco ad aprire file sorgente `%s' in lettura (%s)" + +#: awkgram.y:2301 awkgram.y:2359 builtin.c:122 +msgid "reason unknown" +msgstr "ragione indeterminata" + +#: awkgram.y:2317 +#, c-format +msgid "already included source file `%s'" +msgstr "file sorgente `%s' già incluso" + +#: awkgram.y:2343 +msgid "@include is a gawk extension" +msgstr "@include è un'estensione gawk" + +#: awkgram.y:2349 +msgid "empty filename after @include" +msgstr "nome-file mancante dopo @include" + +#: awkgram.y:2494 +msgid "empty program text on command line" +msgstr "programma nullo sulla linea comandi" + +#: awkgram.y:2609 +#, c-format +msgid "can't read sourcefile `%s' (%s)" +msgstr "non riesco a leggere file sorgente `%s' (%s)" + +#: awkgram.y:2620 +#, c-format +msgid "source file `%s' is empty" +msgstr "file sorgente `%s' vuoto" + +#: awkgram.y:2797 +msgid "source file does not end in newline" +msgstr "file sorgente non termina con carattere 'a capo'" + +#: awkgram.y:2900 +msgid "unterminated regexp ends with `\\' at end of file" +msgstr "espressione regolare non completata termina con `\\' a fine file" + +#: awkgram.y:2924 +#, c-format +msgid "%s: %d: tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "" +"%s: %d: modificatore di espressione regolare tawk `/.../%c' non valido in " +"gawk" + +#: awkgram.y:2928 +#, c-format +msgid "tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "modificatore di espressione regolare tawk `/.../%c' non valido in gawk" + +#: awkgram.y:2935 +msgid "unterminated regexp" +msgstr "espressione regolare non completata" + +#: awkgram.y:2939 +msgid "unterminated regexp at end of file" +msgstr "espressione regolare non completata a fine file" + +#: awkgram.y:2998 +msgid "use of `\\ #...' line continuation is not portable" +msgstr "uso di `\\ #...' continuazione linea non portabile" + +#: awkgram.y:3014 +msgid "backslash not last character on line" +msgstr "'\\' non è l'ultimo carattere della linea" + +#: awkgram.y:3075 +msgid "POSIX does not allow operator `**='" +msgstr "POSIX non permette l'operatore `**='" + +#: awkgram.y:3077 +msgid "old awk does not support operator `**='" +msgstr "il vecchio awk non supporta l'operatore `**='" + +#: awkgram.y:3086 +msgid "POSIX does not allow operator `**'" +msgstr "POSIX non permette l'operatore `**'" + +#: awkgram.y:3088 +msgid "old awk does not support operator `**'" +msgstr "il vecchio awk non supporta l'operatore `**'" + +#: awkgram.y:3123 +msgid "operator `^=' is not supported in old awk" +msgstr "l'operatore `^=' non è supportato nel vecchio awk" + +#: awkgram.y:3131 +msgid "operator `^' is not supported in old awk" +msgstr "l'operatore `^' non è supportato nel vecchio awk" + +#: awkgram.y:3224 awkgram.y:3240 +msgid "unterminated string" +msgstr "stringa non terminata" + +#: awkgram.y:3436 +#, c-format +msgid "invalid char '%c' in expression" +msgstr "carattere '%c' non valido in un'espressione" + +#: awkgram.y:3483 +#, c-format +msgid "`%s' is a gawk extension" +msgstr "`%s' è un'estensione gawk" + +#: awkgram.y:3488 +#, c-format +msgid "`%s' is a Bell Labs extension" +msgstr "`%s' è un'estensione Bell Labs" + +#: awkgram.y:3493 +#, c-format +msgid "POSIX does not allow `%s'" +msgstr "POSIX non permette `%s'" + +#: awkgram.y:3501 +#, c-format +msgid "`%s' is not supported in old awk" +msgstr "`%s' non è supportato nel vecchio awk" + +#: awkgram.y:3568 +msgid "`goto' considered harmful!\n" +msgstr "`goto' considerato pericoloso!\n" + +#: awkgram.y:3619 +#, c-format +msgid "%d is invalid as number of arguments for %s" +msgstr "%d non valido come numero di argomenti per %s" + +#: awkgram.y:3654 +#, c-format +msgid "%s: string literal as last arg of substitute has no effect" +msgstr "%s: una stringa come ultimo argomento di 'substitute' non ha effetto" + +#: awkgram.y:3659 +#, c-format +msgid "%s third parameter is not a changeable object" +msgstr "il terzo parametro di '%s' non è un oggetto modificabile" + +#: awkgram.y:3732 awkgram.y:3735 +msgid "match: third argument is a gawk extension" +msgstr "match: il terzo argomento è un'estensione gawk" + +#: awkgram.y:3789 awkgram.y:3792 +msgid "close: second argument is a gawk extension" +msgstr "close: il secondo argomento è un'estensione gawk" + +#: awkgram.y:3804 +msgid "use of dcgettext(_\"...\") is incorrect: remove leading underscore" +msgstr "" +"uso scorretto di dcgettext(_\"...\"): togliere il carattere '_' iniziale" + +#: awkgram.y:3819 +msgid "use of dcngettext(_\"...\") is incorrect: remove leading underscore" +msgstr "" +"uso scorretto di dcngettext(_\"...\"): togliere il carattere '_' iniziale" + +#: awkgram.y:3911 +#, c-format +msgid "function `%s': parameter #%d, `%s', duplicates parameter #%d" +msgstr "funzione `%s': parametro #%d, `%s', duplica parametro #%d" + +#: awkgram.y:3953 +#, c-format +msgid "function `%s': parameter `%s' shadows global variable" +msgstr "funzione `%s': parametro `%s' nasconde variabile globale" + +#: awkgram.y:4111 +#, c-format +msgid "could not open `%s' for writing (%s)" +msgstr "non riesco ad aprire `%s' in scrittura (%s)" + +#: awkgram.y:4112 +#, fuzzy +msgid "sending variable list to standard error" +msgstr "mando profilo a 'standard error'" + +#: awkgram.y:4118 +#, c-format +msgid "%s: close failed (%s)" +msgstr "%s: 'close' fallita (%s)" + +#: awkgram.y:4170 +msgid "shadow_funcs() called twice!" +msgstr "shadow_funcs() chiamata due volte!" + +#: awkgram.y:4176 +msgid "there were shadowed variables." +msgstr "c'erano variabili nascoste." + +#: awkgram.y:4206 +#, c-format +msgid "function `%s': can't use function name as parameter name" +msgstr "funzione `%s': non posso usare nome della funzione come nome parametro" + +#: awkgram.y:4210 +#, c-format +msgid "function `%s': can't use special variable `%s' as a function parameter" +msgstr "" +"funzione `%s': non posso usare la variabile speciale `%s' come parametro di " +"funzione" + +#: awkgram.y:4226 +#, c-format +msgid "function name `%s' previously defined" +msgstr "funzione di nome `%s' definita in precedenza" + +#: awkgram.y:4394 awkgram.y:4400 +#, c-format +msgid "function `%s' called but never defined" +msgstr "funzione `%s' chiamata ma mai definita" + +#: awkgram.y:4403 +#, c-format +msgid "function `%s' defined but never called directly" +msgstr "funzione `%s' definita ma mai chiamata direttamente" + +#: awkgram.y:4435 +#, c-format +msgid "regexp constant for parameter #%d yields boolean value" +msgstr "" +"espressione regolare di valore costante per parametro #%d genera valore " +"booleano" + +#: awkgram.y:4544 +#, c-format +msgid "" +"function `%s' called with space between name and `(',\n" +"or used as a variable or an array" +msgstr "" +"funzione `%s' chiamata con spazio tra il nome e `(',\n" +"o usata come variabile o vettore" + +#: awkgram.y:4791 eval.c:2056 +msgid "division by zero attempted" +msgstr "tentativo di dividere per zero" + +#: awkgram.y:4800 eval.c:2072 +#, c-format +msgid "division by zero attempted in `%%'" +msgstr "tentativo di dividere per zero in `%%'" + +#: builtin.c:120 +#, c-format +msgid "%s to \"%s\" failed (%s)" +msgstr "%s a \"%s\" fallita (%s)" + +#: builtin.c:121 +msgid "standard output" +msgstr "standard output" + +#: builtin.c:135 +msgid "exp: received non-numeric argument" +msgstr "exp: argomento non numerico" + +#: builtin.c:141 +#, c-format +msgid "exp: argument %g is out of range" +msgstr "exp: argomento %g non accettabile" + +#: builtin.c:200 +#, c-format +msgid "fflush: cannot flush: pipe `%s' opened for reading, not writing" +msgstr "" +"fflush: non posso scaricare: 'pipe' `%s' aperta in lettura, non in scrittura" + +#: builtin.c:203 +#, c-format +msgid "fflush: cannot flush: file `%s' opened for reading, not writing" +msgstr "" +"fflush: non posso scaricare: file `%s' aperto in lettura, non in scrittura" + +#: builtin.c:215 +#, c-format +msgid "fflush: `%s' is not an open file, pipe or co-process" +msgstr "fflush: `%s' non è un file aperto, una 'pipe' o un co-processo" + +#: builtin.c:333 +msgid "index: received non-string first argument" +msgstr "index: il primo argomento non è una stringa" + +#: builtin.c:335 +msgid "index: received non-string second argument" +msgstr "index: il secondo argomento non è una stringa" + +#: builtin.c:457 +msgid "int: received non-numeric argument" +msgstr "int: argomento non numerico" + +#: builtin.c:493 +msgid "length: received array argument" +msgstr "length: l'argomento fornito è un vettore" + +#: builtin.c:496 +msgid "`length(array)' is a gawk extension" +msgstr "`length(array)' è un'estensione gawk" + +#: builtin.c:504 +msgid "length: received non-string argument" +msgstr "length: l'argomento non è una stringa" + +#: builtin.c:535 +msgid "log: received non-numeric argument" +msgstr "log: argomento non numerico" + +#: builtin.c:538 +#, c-format +msgid "log: received negative argument %g" +msgstr "log: argomento negativo %g" + +#: builtin.c:694 builtin.c:699 +msgid "fatal: must use `count$' on all formats or none" +msgstr "" + +#: builtin.c:762 +#, c-format +msgid "field width is ignored for `%%' specifier" +msgstr "" + +#: builtin.c:764 +#, c-format +msgid "precision is ignored for `%%' specifier" +msgstr "" + +#: builtin.c:766 +#, c-format +msgid "field width and precision are ignored for `%%' specifier" +msgstr "" + +#: builtin.c:817 +#, fuzzy +msgid "fatal: `$' is not permitted in awk formats" +msgstr "l'operatore `^' non è supportato nel vecchio awk" + +#: builtin.c:826 +msgid "fatal: arg count with `$' must be > 0" +msgstr "" + +#: builtin.c:830 +#, c-format +msgid "fatal: arg count %ld greater than total number of supplied arguments" +msgstr "" + +#: builtin.c:834 +msgid "fatal: `$' not permitted after period in format" +msgstr "" + +#: builtin.c:850 +msgid "fatal: no `$' supplied for positional field width or precision" +msgstr "" + +#: builtin.c:921 +msgid "`l' is meaningless in awk formats; ignored" +msgstr "" + +#: builtin.c:925 +msgid "fatal: `l' is not permitted in POSIX awk formats" +msgstr "" + +#: builtin.c:938 +msgid "`L' is meaningless in awk formats; ignored" +msgstr "" + +#: builtin.c:942 +msgid "fatal: `L' is not permitted in POSIX awk formats" +msgstr "" + +#: builtin.c:955 +msgid "`h' is meaningless in awk formats; ignored" +msgstr "" + +#: builtin.c:959 +msgid "fatal: `h' is not permitted in POSIX awk formats" +msgstr "" + +#: builtin.c:1272 +#, c-format +msgid "[s]printf: value %g is out of range for `%%%c' format" +msgstr "" + +#: builtin.c:1332 +#, c-format +msgid "ignoring unknown format specifier character `%c': no argument converted" +msgstr "" + +#: builtin.c:1337 +msgid "fatal: not enough arguments to satisfy format string" +msgstr "" + +#: builtin.c:1339 +msgid "^ ran out for this one" +msgstr "" + +#: builtin.c:1346 +msgid "[s]printf: format specifier does not have control letter" +msgstr "" + +#: builtin.c:1349 +msgid "too many arguments supplied for format string" +msgstr "" + +#: builtin.c:1423 builtin.c:1434 +msgid "printf: no arguments" +msgstr "printf: manca argomento" + +#: builtin.c:1475 +msgid "sqrt: received non-numeric argument" +msgstr "sqrt: argomento non numerico" + +#: builtin.c:1479 +#, c-format +msgid "sqrt: called with negative argument %g" +msgstr "sqrt: chiamata con argomento negativo %g" + +#: builtin.c:1503 +#, c-format +msgid "substr: length %g is not >= 1" +msgstr "substr: lunghezza %g non >= 1" + +#: builtin.c:1505 +#, c-format +msgid "substr: length %g is not >= 0" +msgstr "substr: lunghezza %g non >= 0" + +#: builtin.c:1512 +#, c-format +msgid "substr: non-integer length %g will be truncated" +msgstr "substr: lunghezza non intera %g: sarà troncata" + +#: builtin.c:1517 +#, c-format +msgid "substr: length %g too big for string indexing, truncating to %g" +msgstr "substr: lunghezza %g troppo elevata per indice stringa, tronco a %g" + +#: builtin.c:1529 +#, c-format +msgid "substr: start index %g is invalid, using 1" +msgstr "substr: indice di partenza %g non valido, uso 1" + +#: builtin.c:1534 +#, c-format +msgid "substr: non-integer start index %g will be truncated" +msgstr "substr: indice di partenza non intero %g: sarà troncato" + +#: builtin.c:1559 +msgid "substr: source string is zero length" +msgstr "substr: stringa di partenza lunga zero" + +#: builtin.c:1575 +#, c-format +msgid "substr: start index %g is past end of string" +msgstr "substr: indice di partenza %g oltre la fine della stringa" + +#: builtin.c:1583 +#, c-format +msgid "" +"substr: length %g at start index %g exceeds length of first argument (%lu)" +msgstr "" +"substr: lunghezza %g all'indice di partenza %g supera la lunghezza del primo " +"argomento (%lu)" + +#: builtin.c:1657 +msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" +msgstr "" +"strftime: il valore del 'format' in PROCINFO[\"strftime\"] è di tipo numerico" + +#: builtin.c:1680 +msgid "strftime: received non-numeric second argument" +msgstr "strftime: il secondo argomento non è numerico" + +#: builtin.c:1683 +msgid "strftime: second argument less than 0 or too big for time_t" +msgstr "" + +#: builtin.c:1690 +msgid "strftime: received non-string first argument" +msgstr "strftime: il primo argomento non è una stringa" + +#: builtin.c:1696 +msgid "strftime: received empty format string" +msgstr "strftime: 'format' è una stringa nulla" + +#: builtin.c:1762 +msgid "mktime: received non-string argument" +msgstr "mktime: l'argomento non è una stringa" + +#: builtin.c:1779 +msgid "mktime: at least one of the values is out of the default range" +msgstr "mktime: almeno un valore è fuori dall'intervallo di default" + +#: builtin.c:1814 +msgid "'system' function not allowed in sandbox mode" +msgstr "la funzione 'system' non è permessa in modo 'sandbox'" + +#: builtin.c:1819 +msgid "system: received non-string argument" +msgstr "system: l'argomento non è una stringa" + +#: builtin.c:1874 eval.c:1159 eval.c:1790 eval.c:1803 +#, c-format +msgid "reference to uninitialized variable `%s'" +msgstr "riferimento a variabile non inizializzata `%s'" + +#: builtin.c:1941 +#, c-format +msgid "reference to uninitialized field `$%d'" +msgstr "riferimento a variabile non inizializzata `$%d'" + +#: builtin.c:2028 +msgid "tolower: received non-string argument" +msgstr "tolower: l'argomento non è una stringa" + +#: builtin.c:2062 +msgid "toupper: received non-string argument" +msgstr "toupper: l'argomento non è una stringa" + +#: builtin.c:2098 +msgid "atan2: received non-numeric first argument" +msgstr "atan2: il primo argomento non è numerico" + +#: builtin.c:2100 +msgid "atan2: received non-numeric second argument" +msgstr "atan2: il secondo argomento non è numerico" + +#: builtin.c:2119 +msgid "sin: received non-numeric argument" +msgstr "sin: l'argomento non è numerico" + +#: builtin.c:2135 +msgid "cos: received non-numeric argument" +msgstr "cos: l'argomento non è numerico" + +#: builtin.c:2188 +msgid "srand: received non-numeric argument" +msgstr "srand: l'argomento non è numerico" + +#: builtin.c:2219 +msgid "match: third argument is not an array" +msgstr "match: il terzo argomento non è un vettore" + +#: builtin.c:2483 +msgid "gensub: third argument of 0 treated as 1" +msgstr "gensub: il terzo argomento è 0, trattato come 1" + +#: builtin.c:2776 +msgid "lshift: received non-numeric first argument" +msgstr "lshift: il primo argomento non è numerico" + +#: builtin.c:2778 +msgid "lshift: received non-numeric second argument" +msgstr "lshift: il secondo argomento non è numerico" + +#: builtin.c:2784 +#, c-format +msgid "lshift(%lf, %lf): negative values will give strange results" +msgstr "lshift(%lf, %lf): valori negativi daranno risultati strani" + +#: builtin.c:2786 +#, c-format +msgid "lshift(%lf, %lf): fractional values will be truncated" +msgstr "lshift(%lf, %lf): valori con decimali verranno troncati" + +#: builtin.c:2788 +#, c-format +msgid "lshift(%lf, %lf): too large shift value will give strange results" +msgstr "lshift(%lf, %lf): valori troppo alti daranno risultati strani" + +#: builtin.c:2813 +msgid "rshift: received non-numeric first argument" +msgstr "rshift: il primo argomento non è numerico" + +#: builtin.c:2815 +msgid "rshift: received non-numeric second argument" +msgstr "rshift: il secondo argomento non è numerico" + +#: builtin.c:2821 +#, c-format +msgid "rshift(%lf, %lf): negative values will give strange results" +msgstr "rshift(%lf, %lf): valori negativi daranno risultati strani" + +#: builtin.c:2823 +#, c-format +msgid "rshift(%lf, %lf): fractional values will be truncated" +msgstr "rshift(%lf, %lf): valori con decimali verranno troncati" + +#: builtin.c:2825 +#, c-format +msgid "rshift(%lf, %lf): too large shift value will give strange results" +msgstr "rshift(%lf, %lf): valori troppo alti daranno risultati strani" + +#: builtin.c:2850 +msgid "and: received non-numeric first argument" +msgstr "and: il primo argomento non è numerico" + +#: builtin.c:2852 +msgid "and: received non-numeric second argument" +msgstr "and: il secondo argomento non è numerico" + +#: builtin.c:2858 +#, c-format +msgid "and(%lf, %lf): negative values will give strange results" +msgstr "and(%lf, %lf): valori negativi daranno risultati strani" + +#: builtin.c:2860 +#, c-format +msgid "and(%lf, %lf): fractional values will be truncated" +msgstr "and(%lf, %lf): valori con decimali verranno troncati" + +#: builtin.c:2885 +msgid "or: received non-numeric first argument" +msgstr "or: il primo argomento non è numerico" + +#: builtin.c:2887 +msgid "or: received non-numeric second argument" +msgstr "or: il secondo argomento non è numerico" + +#: builtin.c:2893 +#, c-format +msgid "or(%lf, %lf): negative values will give strange results" +msgstr "or(%lf, %lf): valori negativi daranno risultati strani" + +#: builtin.c:2895 +#, c-format +msgid "or(%lf, %lf): fractional values will be truncated" +msgstr "or(%lf, %lf): valori con decimali verranno troncati" + +#: builtin.c:2923 +msgid "xor: received non-numeric first argument" +msgstr "xor: il primo argomento non è numerico" + +#: builtin.c:2925 +msgid "xor: received non-numeric second argument" +msgstr "xor: il secondo argomento non è numerico" + +#: builtin.c:2931 +#, c-format +msgid "xor(%lf, %lf): negative values will give strange results" +msgstr "xor(%lf, %lf): valori negativi daranno risultati strani" + +#: builtin.c:2933 +#, c-format +msgid "xor(%lf, %lf): fractional values will be truncated" +msgstr "xor(%lf, %lf): valori con decimali verranno troncati" + +#: builtin.c:2957 builtin.c:2963 +msgid "compl: received non-numeric argument" +msgstr "compl: l'argomento non è numerico" + +#: builtin.c:2965 +#, c-format +msgid "compl(%lf): negative value will give strange results" +msgstr "compl(%lf): valore negativo darà risultati strani" + +#: builtin.c:2967 +#, c-format +msgid "compl(%lf): fractional value will be truncated" +msgstr "compl(%lf): valore con decimali verrà troncato" + +#: builtin.c:3136 +#, c-format +msgid "dcgettext: `%s' is not a valid locale category" +msgstr "dcgettext: `%s' non è una categoria 'locale' valida" + +#: eval.c:412 +#, c-format +msgid "unknown nodetype %d" +msgstr "tipo nodo sconosciuto %d" + +#: eval.c:423 eval.c:437 +#, c-format +msgid "unknown opcode %d" +msgstr "codice operativo sconosciuto %d" + +#: eval.c:434 +#, c-format +msgid "opcode %s not an operator or keyword" +msgstr "codice operativo %s non è un operatore o una parola chiave" + +#: eval.c:488 +msgid "buffer overflow in genflags2str" +msgstr "superamento limiti buffer in 'genflags2str'" + +#: eval.c:698 +#, c-format +msgid "" +"\n" +"\t# Function Call Stack:\n" +"\n" +msgstr "" +"\n" +"\t# 'Stack' (Pila) Chiamate Funzione:\n" +"\n" + +#: eval.c:725 +msgid "`IGNORECASE' is a gawk extension" +msgstr "`IGNORECASE' è un'estensione gawk" + +#: eval.c:754 +msgid "`BINMODE' is a gawk extension" +msgstr "`BINMODE' è un'estensione gawk" + +#: eval.c:812 +#, c-format +msgid "BINMODE value `%s' is invalid, treated as 3" +msgstr "valore di BINMODE `%s' non valido, considerato come 3" + +#: eval.c:902 +#, c-format +msgid "bad `%sFMT' specification `%s'" +msgstr "specificazione invalida `%sFMT' `%s'" + +#: eval.c:980 +msgid "turning off `--lint' due to assignment to `LINT'" +msgstr "disabilito `--lint' a causa di assegnamento a `LINT'" + +#: eval.c:1127 eval.c:1777 +#, c-format +msgid "can't use function name `%s' as variable or array" +msgstr "non posso usare nome di funzione `%s' come variabile o vettore" + +#: eval.c:1158 eval.c:1789 eval.c:1802 +#, c-format +msgid "reference to uninitialized argument `%s'" +msgstr "riferimento ad argomento non inizializzato `%s'" + +#: eval.c:1177 +msgid "attempt to field reference from non-numeric value" +msgstr "tentativo di riferimento a un campo da valore non numerico" + +#: eval.c:1179 +msgid "attempt to field reference from null string" +msgstr "tentativo di riferimento a un campo da una stringa nulla" + +#: eval.c:1185 +#, c-format +msgid "attempt to access field %ld" +msgstr "tentativo di accedere al campo %ld" + +#: eval.c:1194 +#, c-format +msgid "reference to uninitialized field `$%ld'" +msgstr "riferimento a campo non inizializzato `$%ld'" + +#: eval.c:1256 +#, c-format +msgid "function `%s' called with more arguments than declared" +msgstr "funzione `%s' chiamata con più argomenti di quelli previsti" + +#: eval.c:1437 +#, c-format +msgid "unwind_stack: unexpected type `%s'" +msgstr "unwind_stack: tipo non previsto `%s'" + +#: eval.c:1532 +msgid "division by zero attempted in `/='" +msgstr "divisione per zero tentata in `/='" + +#: eval.c:1539 +#, c-format +msgid "division by zero attempted in `%%='" +msgstr "divisione per zero tentata in `%%='" + +#: eval.c:1876 eval.c:2122 +#, fuzzy, c-format +msgid "attempt to use array `%s[\"%.*s\"]' in a scalar context" +msgstr "tentativo di usare vettore `%s' in un contesto scalare" + +#: eval.c:1907 +msgid "assignment used in conditional context" +msgstr "assegnamento usato nel contesto di un test condizionale" + +#: eval.c:1911 +msgid "statement has no effect" +msgstr "istruzione che non fa nulla" + +#: eval.c:2343 +#, c-format +msgid "for loop: array `%s' changed size from %ld to %ld during loop execution" +msgstr "" +"ciclo for: vettore `%s' ha cambiato dimensione da %ld a %ld durante " +"l'esecuzione del ciclo" + +#: eval.c:2458 +#, c-format +msgid "function called indirectly through `%s' does not exist" +msgstr "la funzione chiamata indirettamente tramite `%s' non esiste" + +#: eval.c:2470 +#, c-format +msgid "function `%s' not defined" +msgstr "funzione `%s' non definita" + +#: eval.c:2511 +#, c-format +msgid "non-redirected `getline' invalid inside `%s' rule" +msgstr "`getline' non-diretta indefinita dentro regola '%s'" + +#: eval.c:2600 +#, c-format +msgid "error reading input file `%s': %s" +msgstr "errore leggendo file di input `%s': %s" + +#: eval.c:2614 +#, c-format +msgid "`nextfile' cannot be called from a `%s' rule" +msgstr "`nextfile' non può essere chiamato da una regola `%s'" + +#: eval.c:2661 +#, fuzzy +msgid "`exit' cannot be called in the current context" +msgstr "`next' non può essere chiamato da una regola `%s'" + +#: eval.c:2700 +#, c-format +msgid "`next' cannot be called from a `%s' rule" +msgstr "`next' non può essere chiamato da una regola `%s'" + +#: eval.c:2766 +#, c-format +msgid "Sorry, don't know how to interpret `%s'" +msgstr "Spiacente, non so come interpretare `%s'" + +#: ext.c:54 +msgid "extensions are not allowed in sandbox mode" +msgstr "le estensioni non sono permesse in modo 'sandbox'" + +#: ext.c:60 ext.c:65 +msgid "`extension' is a gawk extension" +msgstr "`extension' è un'estensione gawk" + +#: ext.c:75 +#, c-format +msgid "fatal: extension: cannot open `%s' (%s)\n" +msgstr "fatale: estensione: non riesco ad aprire `%s' (%s)\n" + +#: ext.c:84 +#, c-format +msgid "" +"fatal: extension: library `%s': does not define " +"`plugin_is_GPL_compatible' (%s)\n" +msgstr "" +"fatale: estensione: libreria `%s': non definisce " +"`plugin_is_GPL_compatible' (%s)\n" + +#: ext.c:93 +#, c-format +msgid "fatal: extension: library `%s': cannot call function `%s' (%s)\n" +msgstr "" +"fatale: estensione: libreria `%s': non riesco a chiamare funzione `%s' (%s)\n" + +#: ext.c:127 +msgid "extension: missing function name" +msgstr "estensione: manca nome di funzione" + +#: ext.c:132 +#, c-format +msgid "extension: illegal character `%c' in function name `%s'" +msgstr "estensione: carattere non ammesso `%c' nel nome di funzione `%s'" + +#: ext.c:141 +#, c-format +msgid "extension: can't redefine function `%s'" +msgstr "estensione: non riesco a ridefinire funzione `%s'" + +#: ext.c:145 +#, c-format +msgid "extension: function `%s' already defined" +msgstr "estensione: funzione `%s' già definita" + +#: ext.c:150 +#, c-format +msgid "extension: function name `%s' previously defined" +msgstr "estensione: funzione di nome `%s' definita in precedenza" + +#: ext.c:152 +#, c-format +msgid "extension: can't use gawk built-in `%s' as function name" +msgstr "" +"estensione: nome funzione interna gawk `%s' non ammesso come nome funzione" + +#: ext.c:156 +#, c-format +msgid "make_builtin: negative argument count for function `%s'" +msgstr "make_builtin: contatore argomenti negativo per la funzione `%s'" + +#: ext.c:259 +#, c-format +msgid "function `%s' defined to take no more than %d argument(s)" +msgstr "funzione `%s' definita per avere al massimo %d argomenti(o)" + +#: ext.c:262 +#, c-format +msgid "function `%s': missing argument #%d" +msgstr "funzione `%s': manca argomento #%d" + +#: ext.c:279 +#, c-format +msgid "function `%s': argument #%d: attempt to use scalar as an array" +msgstr "funzione `%s': argomento #%d: tentativo di usare scalare come vettore" + +#: ext.c:283 +#, c-format +msgid "function `%s': argument #%d: attempt to use array as a scalar" +msgstr "funzione `%s': argomento #%d: tentativo di usare vettore come scalare" + +#: ext.c:296 +msgid "Operation Not Supported" +msgstr "Operazione Non Supportata" + +#: field.c:328 +msgid "NF set to negative value" +msgstr "NF impostato a un valore negativo" + +#: field.c:951 field.c:958 field.c:962 +msgid "split: fourth argument is a gawk extension" +msgstr "split: il quarto argomento è un'estensione gawk" + +#: field.c:955 +msgid "split: fourth argument is not an array" +msgstr "split: il quarto argomento non è un vettore" + +#: field.c:969 +msgid "split: second argument is not an array" +msgstr "split: il secondo argomento non è un vettore" + +#: field.c:973 +#, fuzzy +msgid "split: cannot use the same array for second and fourth args" +msgstr "" +"split: non si può usare lo stesso vettore come secondo e quarto argomento" + +#: field.c:978 +#, fuzzy +msgid "split: cannot use a subarray of second arg for fourth arg" +msgstr "" +"split: non si può usare lo stesso vettore come secondo e quarto argomento" + +#: field.c:981 +#, fuzzy +msgid "split: cannot use a subarray of fourth arg for second arg" +msgstr "" +"split: non si può usare lo stesso vettore come secondo e quarto argomento" + +#: field.c:1010 +msgid "split: null string for third arg is a gawk extension" +msgstr "split: la stringa nulla come terzo arg. è un'estensione gawk" + +#: field.c:1050 +msgid "patsplit: fourth argument is not an array" +msgstr "patsplit: il secondo argomento non è un vettore" + +#: field.c:1055 +msgid "patsplit: second argument is not an array" +msgstr "patsplit: il secondo argomento non è un vettore" + +#: field.c:1061 +msgid "patsplit: third argument must be non-null" +msgstr "patsplit: il terzo argomento non può essere nullo" + +#: field.c:1065 +#, fuzzy +msgid "patsplit: cannot use the same array for second and fourth args" +msgstr "" +"patsplit: non si può usare lo stesso vettore come secondo e quarto argomento" + +#: field.c:1070 +#, fuzzy +msgid "patsplit: cannot use a subarray of second arg for fourth arg" +msgstr "" +"patsplit: non si può usare lo stesso vettore come secondo e quarto argomento" + +#: field.c:1073 +#, fuzzy +msgid "patsplit: cannot use a subarray of fourth arg for second arg" +msgstr "" +"patsplit: non si può usare lo stesso vettore come secondo e quarto argomento" + +#: field.c:1110 +msgid "`FIELDWIDTHS' is a gawk extension" +msgstr "`FIELDWIDTHS' è un'estensione gawk" + +#: field.c:1173 +#, c-format +msgid "invalid FIELDWIDTHS value, near `%s'" +msgstr "valore di FIELDWIDTHS non valido, vicino a `%s'" + +#: field.c:1246 +msgid "null string for `FS' is a gawk extension" +msgstr "la stringa nulla usata come `FS' è un'estensione gawk" + +#: field.c:1250 +msgid "old awk does not support regexps as value of `FS'" +msgstr "il vecchio awk non supporta espressioni come valori di `FS'" + +#: field.c:1369 +msgid "`FPAT' is a gawk extension" +msgstr "`FPAT' è un'estensione gawk" + +#: getopt.c:604 getopt.c:633 +#, fuzzy, c-format +msgid "%s: option '%s' is ambiguous; possibilities:" +msgstr "%s: opzione '%s' ambigua\n" + +#: getopt.c:679 getopt.c:683 +#, c-format +msgid "%s: option '--%s' doesn't allow an argument\n" +msgstr "%s: l'opzione '--%s' non ammette un argomento\n" + +#: getopt.c:692 getopt.c:697 +#, c-format +msgid "%s: option '%c%s' doesn't allow an argument\n" +msgstr "%s: l'opzione '%c%s' non ammette un argomento\n" + +#: getopt.c:740 getopt.c:759 +#, c-format +msgid "%s: option '--%s' requires an argument\n" +msgstr "%s: l'opzione '--%s' richiede un argomento\n" + +#: getopt.c:797 getopt.c:800 +#, c-format +msgid "%s: unrecognized option '--%s'\n" +msgstr "%s: opzione sconosciuta '--%s'\n" + +#: getopt.c:808 getopt.c:811 +#, c-format +msgid "%s: unrecognized option '%c%s'\n" +msgstr "%s: opzione sconosciuta '%c%s'\n" + +#: getopt.c:860 getopt.c:863 +#, c-format +msgid "%s: invalid option -- '%c'\n" +msgstr "%s: opzione non valida -- '%c'\n" + +#: getopt.c:916 getopt.c:933 getopt.c:1143 getopt.c:1161 +#, c-format +msgid "%s: option requires an argument -- '%c'\n" +msgstr "%s: l'opzione richiede un argomento -- '%c'\n" + +#: getopt.c:989 getopt.c:1005 +#, c-format +msgid "%s: option '-W %s' is ambiguous\n" +msgstr "%s: l'opzione '-W %s' è ambigua\n" + +#: getopt.c:1029 getopt.c:1047 +#, c-format +msgid "%s: option '-W %s' doesn't allow an argument\n" +msgstr "%s: l'opzione '-W %s' non ammette un argomento\n" + +#: getopt.c:1068 getopt.c:1086 +#, c-format +msgid "%s: option '-W %s' requires an argument\n" +msgstr "%s: l'opzione '-W %s' richiede un argomento\n" + +#: io.c:280 +#, c-format +msgid "command line argument `%s' is a directory: skipped" +msgstr "l'argomento in linea comando `%s' è una directory: saltato" + +#: io.c:283 io.c:385 +#, c-format +msgid "cannot open file `%s' for reading (%s)" +msgstr "non riesco ad aprire file `%s' in lettura (%s)" + +#: io.c:501 +#, c-format +msgid "close of fd %d (`%s') failed (%s)" +msgstr "chiusura di fd %d (`%s') fallita (%s)" + +#: io.c:578 +msgid "redirection not allowed in sandbox mode" +msgstr "re-direzione non permessa in modo 'sandbox'" + +#: io.c:612 +#, c-format +msgid "expression in `%s' redirection only has numeric value" +msgstr "espressione nella re-direzione `%s' ha solo un valore numerico" + +#: io.c:618 +#, c-format +msgid "expression for `%s' redirection has null string value" +msgstr "espressione nella re-direzione `%s' ha per valore la stringa nulla" + +#: io.c:623 +#, c-format +msgid "filename `%s' for `%s' redirection may be result of logical expression" +msgstr "" +"nome-file `%s' per la re-direzione `%s' può essere il risultato di una " +"espressione logica" + +#: io.c:666 +#, c-format +msgid "unnecessary mixing of `>' and `>>' for file `%.*s'" +msgstr "mistura non necessaria di `>' e `>>' per il file `%.*s'" + +#: io.c:719 +#, c-format +msgid "can't open pipe `%s' for output (%s)" +msgstr "non posso aprire 'pipe' `%s' in scrittura (%s)" + +#: io.c:729 +#, c-format +msgid "can't open pipe `%s' for input (%s)" +msgstr "non posso aprire 'pipe' `%s' in lettura (%s)" + +#: io.c:752 +#, c-format +msgid "can't open two way pipe `%s' for input/output (%s)" +msgstr "non posso aprire 'pipe' bidirezionale `%s' per lettura/scrittura (%s)" + +#: io.c:834 +#, c-format +msgid "can't redirect from `%s' (%s)" +msgstr "non posso re-dirigere da `%s' (%s)" + +#: io.c:837 +#, c-format +msgid "can't redirect to `%s' (%s)" +msgstr "non posso re-dirigere a `%s' (%s)" + +#: io.c:888 +msgid "" +"reached system limit for open files: starting to multiplex file descriptors" +msgstr "" +"numero massimo consentito di file aperti raggiunto: comincio a riutilizzare " +"i descrittori di file" + +#: io.c:904 +#, c-format +msgid "close of `%s' failed (%s)." +msgstr "chiusura di `%s' fallita (%s)." + +#: io.c:912 +msgid "too many pipes or input files open" +msgstr "troppe 'pipe' o file di input aperti" + +#: io.c:934 +msgid "close: second argument must be `to' or `from'" +msgstr "close: il secondo argomento deve essere `a' o `da'" + +#: io.c:951 +#, c-format +msgid "close: `%.*s' is not an open file, pipe or co-process" +msgstr "close: `%.*s' non è un file aperto, una 'pipe' o un co-processo" + +#: io.c:956 +msgid "close of redirection that was never opened" +msgstr "chiusura di una re-direzione mai aperta" + +#: io.c:1053 +#, c-format +msgid "close: redirection `%s' not opened with `|&', second argument ignored" +msgstr "close: re-direzione `%s' non aperta con `|&', ignoro secondo argomento" + +#: io.c:1069 +#, c-format +msgid "failure status (%d) on pipe close of `%s' (%s)" +msgstr "errore ritornato (%d) dalla chiusura della 'pipe' `%s' (%s)" + +#: io.c:1072 +#, c-format +msgid "failure status (%d) on file close of `%s' (%s)" +msgstr "errore ritornato (%d) dalla chiusura del file `%s' (%s)" + +#: io.c:1092 +#, c-format +msgid "no explicit close of socket `%s' provided" +msgstr "nessuna chiusura esplicita richiesta per 'socket' `%s'" + +#: io.c:1095 +#, c-format +msgid "no explicit close of co-process `%s' provided" +msgstr "nessuna chiusura esplicita richiesta per co-processo `%s'" + +#: io.c:1098 +#, c-format +msgid "no explicit close of pipe `%s' provided" +msgstr "nessuna chiusura esplicita richiesta per 'pipe' `%s'" + +#: io.c:1101 +#, c-format +msgid "no explicit close of file `%s' provided" +msgstr "nessuna chiusura esplicita richiesta per file `%s'" + +#: io.c:1129 io.c:1184 main.c:794 main.c:831 +#, c-format +msgid "error writing standard output (%s)" +msgstr "errore scrivendo 'standard output' (%s)" + +#: io.c:1133 io.c:1189 +#, c-format +msgid "error writing standard error (%s)" +msgstr "errore scrivendo 'standard error' (%s)" + +#: io.c:1141 +#, c-format +msgid "pipe flush of `%s' failed (%s)." +msgstr "scaricamento di 'pipe' `%s' fallita (%s)." + +#: io.c:1144 +#, c-format +msgid "co-process flush of pipe to `%s' failed (%s)." +msgstr "scaricamento da co-processo di 'pipe' a `%s' fallita (%s)." + +#: io.c:1147 +#, c-format +msgid "file flush of `%s' failed (%s)." +msgstr "scaricamento di file `%s' fallita (%s)." + +#: io.c:1262 +#, c-format +msgid "local port %s invalid in `/inet'" +msgstr "porta locale %s invalida in `/inet'" + +#: io.c:1279 +#, c-format +msgid "remote host and port information (%s, %s) invalid" +msgstr "host remoto e informazione di porta (%s, %s) invalidi" + +#: io.c:1431 +#, c-format +msgid "no (known) protocol supplied in special filename `%s'" +msgstr "nessuno protocollo (noto) specificato nel filename speciale `%s'" + +#: io.c:1445 +#, c-format +msgid "special file name `%s' is incomplete" +msgstr "nome-file speciale `%s' incompleto" + +#: io.c:1462 +msgid "must supply a remote hostname to `/inet'" +msgstr "va fornito nome di 'host' remoto a `/inet'" + +#: io.c:1480 +msgid "must supply a remote port to `/inet'" +msgstr "va fornita porta remota a `/inet'" + +#: io.c:1526 +msgid "TCP/IP communications are not supported" +msgstr "comunicazioni TCP/IP non supportate" + +#: io.c:1693 +#, c-format +msgid "could not open `%s', mode `%s'" +msgstr "non riesco ad aprire `%s', modo `%s'" + +#: io.c:1747 +#, c-format +msgid "close of master pty failed (%s)" +msgstr "fallita chiusura di 'pty' principale (%s)" + +#: io.c:1749 io.c:1917 io.c:2074 +#, c-format +msgid "close of stdout in child failed (%s)" +msgstr "fallita chiusura di 'stdout' nel processo-figlio (%s)" + +#: io.c:1752 +#, c-format +msgid "moving slave pty to stdout in child failed (dup: %s)" +msgstr "" +"fallito trasferimento di 'pty' secondaria a 'stdout' nel processo-figlio " +"(dup: %s)" + +#: io.c:1754 io.c:1922 +#, c-format +msgid "close of stdin in child failed (%s)" +msgstr "fallita chiusura di 'stdin' nel processo-figlio (%s)" + +#: io.c:1757 +#, c-format +msgid "moving slave pty to stdin in child failed (dup: %s)" +msgstr "" +"fallito trasferimento di 'pty' secondaria a 'stdin' nel processo-figlio " +"(dup: %s)" + +#: io.c:1759 io.c:1780 +#, c-format +msgid "close of slave pty failed (%s)" +msgstr "fallita chiusura di 'pty' secondaria (%s)" + +#: io.c:1858 io.c:1920 io.c:2052 io.c:2077 +#, c-format +msgid "moving pipe to stdout in child failed (dup: %s)" +msgstr "fallito passaggio di 'pipe' a 'stdout' nel processo-figlio (dup: %s)" + +#: io.c:1865 io.c:1925 +#, c-format +msgid "moving pipe to stdin in child failed (dup: %s)" +msgstr "fallito passaggio di pipe a 'stdin' nel processo-figlio (dup: %s)" + +#: io.c:1885 io.c:2067 +msgid "restoring stdout in parent process failed\n" +msgstr "fallito ripristino di 'stdout' nel processo-padre\n" + +#: io.c:1893 +msgid "restoring stdin in parent process failed\n" +msgstr "fallito ripristino di 'stdin' nel processo-padre\n" + +#: io.c:1928 io.c:2079 io.c:2093 +#, c-format +msgid "close of pipe failed (%s)" +msgstr "fallita chiusura di 'pipe' (%s)" + +#: io.c:1973 +msgid "`|&' not supported" +msgstr "`|&' non supportato" + +#: io.c:2039 +#, c-format +msgid "cannot open pipe `%s' (%s)" +msgstr "non riesco ad aprire 'pipe' `%s' (%s)" + +#: io.c:2087 +#, c-format +msgid "cannot create child process for `%s' (fork: %s)" +msgstr "non riesco a creare processo-figlio per `%s' (fork: %s)" + +#: io.c:2520 +#, c-format +msgid "data file `%s' is empty" +msgstr "file dati `%s' vuoto" + +#: io.c:2561 io.c:2569 +msgid "could not allocate more input memory" +msgstr "non riesco ad allocare ulteriore memoria per l'input" + +#: io.c:3127 +msgid "multicharacter value of `RS' is a gawk extension" +msgstr "valore multicarattere per `RS' è un'estensione gawk" + +#: io.c:3232 +msgid "IPv6 communication is not supported" +msgstr "comunicazioni IPv6 non supportate" + +#: main.c:366 +msgid "`-m[fr]' option irrelevant in gawk" +msgstr "`-m[fr]' opzione irrilevante per gawk" + +#: main.c:368 +msgid "-m option usage: `-m[fr] nnn'" +msgstr "-m uso opzione: `-m[fr] nnn'" + +#: main.c:391 +msgid "empty argument to `-e/--source' ignored" +msgstr "argomento di `-e/--source' nullo, ignorato" + +#: main.c:462 +#, c-format +msgid "%s: option `-W %s' unrecognized, ignored\n" +msgstr "%s: opzione `-W %s' non riconosciuta, ignorata\n" + +#: main.c:515 +#, c-format +msgid "%s: option requires an argument -- %c\n" +msgstr "%s: l'opzione richiede un argomento -- %c\n" + +#: main.c:536 +msgid "environment variable `POSIXLY_CORRECT' set: turning on `--posix'" +msgstr "variable d'ambiente `POSIXLY_CORRECT' impostata: attivo `--posix'" + +#: main.c:542 +msgid "`--posix' overrides `--traditional'" +msgstr "`--posix' annulla `--traditional'" + +#: main.c:553 +msgid "`--posix'/`--traditional' overrides `--non-decimal-data'" +msgstr "`--posix'/`--traditional' annulla `--non-decimal-data'" + +#: main.c:557 +#, c-format +msgid "running %s setuid root may be a security problem" +msgstr "eseguire %s con 'setuid' root può essere un rischio per la sicurezza" + +#: main.c:562 +msgid "`--posix' overrides `--binary'" +msgstr "`--posix' annulla `--binary" + +#: main.c:613 +#, c-format +msgid "can't set binary mode on stdin (%s)" +msgstr "non posso impostare modalità binaria su 'stdin'(%s)" + +#: main.c:616 +#, c-format +msgid "can't set binary mode on stdout (%s)" +msgstr "non posso impostare modalità binaria su 'stdout'(%s)" + +#: main.c:618 +#, c-format +msgid "can't set binary mode on stderr (%s)" +msgstr "non posso impostare modalità binaria su 'stderr'(%s)" + +#: main.c:657 +msgid "no program text at all!" +msgstr "manca del tutto il testo del programma!" + +#: main.c:734 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] -f progfile [--] file ...\n" +msgstr "Uso: %s [opzioni in stile POSIX o GNU] -f file-prog. [--] file ...\n" + +#: main.c:736 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] [--] %cprogram%c file ...\n" +msgstr "Usage: %s [opzioni in stile POSIX o GNU] [--] %cprogramma%c file ...\n" + +#: main.c:741 +msgid "POSIX options:\t\tGNU long options: (standard)\n" +msgstr "Opzioni POSIX:\t\topzioni lunghe GNU: (standard)\n" + +#: main.c:742 +msgid "\t-f progfile\t\t--file=progfile\n" +msgstr "\t-f fileprog\t\t--file=file-prog.\n" + +#: main.c:743 +msgid "\t-F fs\t\t\t--field-separator=fs\n" +msgstr "\t-F fs\t\t\t--field-separator=fs\n" + +#: main.c:744 +msgid "\t-v var=val\t\t--assign=var=val\n" +msgstr "\t-v var=valore\t\t--assign=var=valore\n" + +#: main.c:745 +msgid "Short options:\t\tGNU long options: (extensions)\n" +msgstr "Opzioni brevi:\t\topzioni lunghe GNU: (estensioni)\n" + +#: main.c:746 +msgid "\t-b\t\t\t--characters-as-bytes\n" +msgstr "\t-b\t\t\t--characters-as-bytes\n" + +#: main.c:747 +msgid "\t-c\t\t\t--traditional\n" +msgstr "\t-c\t\t\t--traditional\n" + +#: main.c:748 +msgid "\t-C\t\t\t--copyright\n" +msgstr "\t-C\t\t\t--copyright\n" + +#: main.c:749 +#, fuzzy +msgid "\t-d[file]\t\t--dump-variables[=file]\n" +msgstr "\t-d [file]\t\t--dump-variables[=file]\n" + +#: main.c:750 +msgid "\t-e 'program-text'\t--source='program-text'\n" +msgstr "\t-e 'testo-del-programma'\t--source='testo-del-programma'\n" + +#: main.c:751 +msgid "\t-E file\t\t\t--exec=file\n" +msgstr "\t-E file\t\t\t--exec=file\n" + +#: main.c:752 +msgid "\t-g\t\t\t--gen-pot\n" +msgstr "\t-g\t\t\t--gen-pot\n" + +#: main.c:753 +msgid "\t-h\t\t\t--help\n" +msgstr "\t-h\t\t\t--help\n" + +#: main.c:754 +msgid "\t-L [fatal]\t\t--lint[=fatal]\n" +msgstr "\t-L [fatal]\t\t--lint[=fatal]\n" + +#: main.c:755 +msgid "\t-n\t\t\t--non-decimal-data\n" +msgstr "\t-n\t\t\t--non-decimal-data\n" + +#: main.c:756 +msgid "\t-N\t\t\t--use-lc-numeric\n" +msgstr "\t-N\t\t\t--use-lc-numeric\n" + +#: main.c:757 +msgid "\t-O\t\t\t--optimize\n" +msgstr "\t-O\t\t\t--optimize\n" + +#: main.c:758 +#, fuzzy +msgid "\t-p[file]\t\t--profile[=file]\n" +msgstr "\t-p [file]\t\t--profile[=file]\n" + +#: main.c:759 +msgid "\t-P\t\t\t--posix\n" +msgstr "\t-P\t\t\t--posix\n" + +#: main.c:760 +msgid "\t-r\t\t\t--re-interval\n" +msgstr "\t-r\t\t\t--re-interval\n" + +#: main.c:762 +msgid "\t-R file\t\t\t--command=file\n" +msgstr "\t-R file\t\t\t--command=file\n" + +#: main.c:763 +msgid "\t-S\t\t\t--sandbox\n" +msgstr "\t-S\t\t\t--sandbox\n" + +#: main.c:764 +msgid "\t-t\t\t\t--lint-old\n" +msgstr "\t-t\t\t\t--lint-old\n" + +#: main.c:765 +msgid "\t-V\t\t\t--version\n" +msgstr "\t-V\t\t\t--version\n" + +#: main.c:767 +msgid "\t-W nostalgia\t\t--nostalgia\n" +msgstr "\t-W nostalgia\t\t--nostalgia\n" + +#: main.c:770 +msgid "\t-Y\t\t--parsedebug\n" +msgstr "\t-Y\t\t--parsedebug\n" + +#. TRANSLATORS: --help output 5 (end) +#. TRANSLATORS: the placeholder indicates the bug-reporting address +#. for this application. Please add _another line_ with the +#. address for translation bugs. +#. no-wrap +#: main.c:779 +msgid "" +"\n" +"To report bugs, see node `Bugs' in `gawk.info', which is\n" +"section `Reporting Problems and Bugs' in the printed version.\n" +"\n" +msgstr "" +"\n" +"Per segnalare problemi, vedi nodo `Bugs' in `gawk.info', oppure la\n" +"sezione `Reporting Problems and Bugs' nella versione a stampa.\n" +"\n" + +#: main.c:783 +msgid "" +"gawk is a pattern scanning and processing language.\n" +"By default it reads standard input and writes standard output.\n" +"\n" +msgstr "" +"gawk è un linguaggio per scandire e processare espressioni.\n" +"Senza parametri, legge da 'standard input' e scrive su 'standard output'.\n" +"\n" + +#: main.c:787 +msgid "" +"Examples:\n" +"\tgawk '{ sum += $1 }; END { print sum }' file\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" +msgstr "" +"Esempi:\n" +"\tgawk '{ sum += $1 }; END { print sum }' file\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" + +#: main.c:807 +#, c-format +msgid "" +"Copyright (C) 1989, 1991-%d Free Software Foundation.\n" +"\n" +"This program is free software; you can redistribute it and/or modify\n" +"it under the terms of the GNU General Public License as published by\n" +"the Free Software Foundation; either version 3 of the License, or\n" +"(at your option) any later version.\n" +"\n" +msgstr "" +"Copyright (C) 1989, 1991-%d Free Software Foundation.\n" +"\n" +"Questo software è libero; lo puoi distribuire e/o modificare\n" +"alle condizioni stabilite nella 'GNU General Public License' pubblicata\n" +"dalla Free Software Foundation; fai riferimento alla versione 3 della\n" +"Licenza, o (a tua scelta) a una qualsiasi versione successiva.\n" +"\n" + +#: main.c:815 +msgid "" +"This program is distributed in the hope that it will be useful,\n" +"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +"GNU General Public License for more details.\n" +"\n" +msgstr "" +"Questo programma è distribuito con la speranza che sia utile,\n" +"ma SENZA ALCUNA GARANZIA; senza neppure la garanzia implicita\n" +"di COMMERCIABILITÀ o IDONEITÀ AD UN PARTICOLARE SCOPO.\n" +"Vedi la 'GNU General Public License' per ulteriori dettagli.\n" +"\n" + +#: main.c:821 +msgid "" +"You should have received a copy of the GNU General Public License\n" +"along with this program. If not, see http://www.gnu.org/licenses/.\n" +msgstr "" +"Dovresti aver ricevuto una copia della GNU General Public License\n" +"assieme a questo programma; se non è così, vedi http://www.gnu.org/" +"licenses/.\n" + +#: main.c:856 +msgid "-Ft does not set FS to tab in POSIX awk" +msgstr "-Ft non imposta FS a 'tab' nell'awk POSIX" + +#: main.c:1090 +#, c-format +msgid "unknown value for field spec: %d\n" +msgstr "valore non noto per specifica campo: %d\n" + +#: main.c:1171 +#, c-format +msgid "" +"%s: `%s' argument to `-v' not in `var=value' form\n" +"\n" +msgstr "" +"%s: `%s' argomento di `-v' non in forma `var=valore'\n" +"\n" + +#: main.c:1197 +#, c-format +msgid "`%s' is not a legal variable name" +msgstr "`%s' non è un nome di variabile ammesso" + +#: main.c:1200 +#, c-format +msgid "`%s' is not a variable name, looking for file `%s=%s'" +msgstr "`%s' non è un nome di variabile, cerco il file `%s=%s'" + +#: main.c:1204 +#, fuzzy, c-format +msgid "cannot use gawk builtin `%s' as variable name" +msgstr "" +"estensione: nome funzione interna gawk `%s' non ammesso come nome funzione" + +#: main.c:1209 +#, fuzzy, c-format +msgid "cannot use function `%s' as variable name" +msgstr "non posso usare nome di funzione `%s' come variabile o vettore" + +#: main.c:1262 +msgid "floating point exception" +msgstr "eccezione floating point" + +#: main.c:1269 +msgid "fatal error: internal error" +msgstr "errore fatale: errore interno" + +#: main.c:1284 +msgid "fatal error: internal error: segfault" +msgstr "errore fatale: errore interno: segfault" + +#: main.c:1296 +msgid "fatal error: internal error: stack overflow" +msgstr "errore fatale: errore interno: stack overflow" + +#: main.c:1346 +#, c-format +msgid "no pre-opened fd %d" +msgstr "manca 'fd' pre-aperta %d" + +#: main.c:1353 +#, c-format +msgid "could not pre-open /dev/null for fd %d" +msgstr "non riesco a pre-aprire /dev/null per 'fd' %d" + +#: msg.c:63 +#, c-format +msgid "cmd. line:" +msgstr "linea com.:" + +#: msg.c:107 +msgid "error: " +msgstr "errore: " + +#: node.c:406 +msgid "backslash at end of string" +msgstr "'\\' a fine stringa" + +#: node.c:517 +#, c-format +msgid "old awk does not support the `\\%c' escape sequence" +msgstr "il vecchio awk non supporta la sequenza di escape '\\%c'" + +#: node.c:568 +msgid "POSIX does not allow `\\x' escapes" +msgstr "POSIX non permette escape `\\x'" + +#: node.c:574 +msgid "no hex digits in `\\x' escape sequence" +msgstr "niente cifre esadecimali nella sequenza di escape `\\x'" + +#: node.c:596 +#, c-format +msgid "" +"hex escape \\x%.*s of %d characters probably not interpreted the way you " +"expect" +msgstr "" +"sequenza di escape esadec.\\x%.*s di %d caratteri probabilmente non " +"interpretata nel modo previsto" + +#: node.c:611 +#, c-format +msgid "escape sequence `\\%c' treated as plain `%c'" +msgstr "sequenza di escape `\\%c' considerata come semplice `%c'" + +#: node.c:750 +msgid "" +"Invalid multibyte data detected. There may be a mismatch between your data " +"and your locale." +msgstr "" +"Trovati dati multi-byte invalidi. Può esserci una differenza tra i dati e la " +"codifica locale." + +#: posix/gawkmisc.c:176 +#, c-format +msgid "%s %s `%s': could not get fd flags: (fcntl F_GETFD: %s)" +msgstr "%s %s `%s': non riesco a ottenere flag 'fd': (fcntl F_GETFD: %s)" + +#: posix/gawkmisc.c:188 +#, c-format +msgid "%s %s `%s': could not set close-on-exec: (fcntl F_SETFD: %s)" +msgstr "" +"%s %s `%s': non riesco a impostare 'close-on-exec': (fcntl F_SETFD: %s)" + +#: profile.c:83 +#, c-format +msgid "could not open `%s' for writing: %s" +msgstr "non riesco ad aprire `%s' in scrittura: %s" + +#: profile.c:85 +msgid "sending profile to standard error" +msgstr "mando profilo a 'standard error'" + +#: profile.c:203 +#, c-format +msgid "" +"\t# %s block(s)\n" +"\n" +msgstr "" +"\t# blocco(hi) %s\n" +"\n" + +#: profile.c:208 +#, c-format +msgid "" +"\t# Rule(s)\n" +"\n" +msgstr "" +"\t# Regola(e)\n" +"\n" + +#: profile.c:279 +#, c-format +msgid "internal error: %s with null vname" +msgstr "errore interno: %s con 'vname' nullo" + +#: profile.c:952 +#, c-format +msgid "\t# gawk profile, created %s\n" +msgstr "\t# profilo gawk, creato %s\n" + +#: profile.c:1331 +#, c-format +msgid "" +"\n" +"\t# Functions, listed alphabetically\n" +msgstr "" +"\n" +"\t# Funzioni, listate in ordine alfabetico\n" + +#: profile.c:1370 +#, c-format +msgid "redir2str: unknown redirection type %d" +msgstr "redir2str: tipo di re-direzione non noto %d" + +#: re.c:573 +#, fuzzy, c-format +msgid "range of the form `[%c-%c]' is locale dependent" +msgstr "intervallo nella forma `[%c-%c]' dipende da 'locale'" + +#: re.c:600 +#, c-format +msgid "regexp component `%.*s' should probably be `[%.*s]'" +msgstr "" +"componente di espressione `%.*s' dovrebbe probabilmente essere `[%.*s]'" + +#: regcomp.c:131 +msgid "Success" +msgstr "Successo" + +#: regcomp.c:134 +msgid "No match" +msgstr "Nessuna corrispondenza" + +#: regcomp.c:137 +msgid "Invalid regular expression" +msgstr "Espressione regolare invalida" + +#: regcomp.c:140 +msgid "Invalid collation character" +msgstr "Carattere di ordinamento non valido" + +#: regcomp.c:143 +msgid "Invalid character class name" +msgstr "Nome di 'classe di caratteri' non valido" + +#: regcomp.c:146 +msgid "Trailing backslash" +msgstr "'\\' finale" + +#: regcomp.c:149 +msgid "Invalid back reference" +msgstr "Riferimento indietro non valido" + +#: regcomp.c:152 +msgid "Unmatched [ or [^" +msgstr "[ o [^ non chiusa" + +#: regcomp.c:155 +msgid "Unmatched ( or \\(" +msgstr "( o \\( non chiusa" + +#: regcomp.c:158 +msgid "Unmatched \\{" +msgstr "\\{ non chiusa" + +#: regcomp.c:161 +msgid "Invalid content of \\{\\}" +msgstr "Contenuto di \\{\\} non valido" + +#: regcomp.c:164 +msgid "Invalid range end" +msgstr "Fine di intervallo non valido" + +#: regcomp.c:167 +msgid "Memory exhausted" +msgstr "Memoria esaurita" + +#: regcomp.c:170 +msgid "Invalid preceding regular expression" +msgstr "Espressione regolare precedente invalida" + +#: regcomp.c:173 +msgid "Premature end of regular expression" +msgstr "Fine di espressione regolare inaspettata" + +#: regcomp.c:176 +msgid "Regular expression too big" +msgstr "Espressione regolare troppo complessa" + +#: regcomp.c:179 +msgid "Unmatched ) or \\)" +msgstr ") o \\) non aperta" + +#: regcomp.c:700 +msgid "No previous regular expression" +msgstr "Nessuna espressione regolare precedente" + +#~ msgid "could not find groups: %s" +#~ msgstr "non riesco a trovare gruppi: %s" + +#~ msgid "assignment is not allowed to result of builtin function" +#~ msgstr "assegnamento non permesso al risultato di una funzione interna" + +#~ msgid "attempt to use array in a scalar context" +#~ msgstr "tentativo di usare vettore in un contesto scalare" + +#~ msgid "sorted array traversal is a gawk extension" +#~ msgstr "`sorted array traversal' è un'estensione gawk" + +#~ msgid "`PROCINFO[\"sorted_in\"]' value is not recognized" +#~ msgstr "`PROCINFO[\"sorted_in\"]' valore non riconosciuto" + +#~ msgid "out of memory" +#~ msgstr "memoria esaurita" diff --git a/po/ja.gmo b/po/ja.gmo new file mode 100644 index 0000000000000000000000000000000000000000..fae94fede7010068b55520b909b74cd968b0e626 GIT binary patch literal 55401 zcmeIb3z${KneV-Fn`puWUX~0Xg5fu>>MIeAtgGz6@cXw~;-n+B+ZjhK5 zx*L?MC<=(6fFdAB6BQK^A&EK3%w#f?%p@mcW|GNdv%4WPIdf)`Iq}R)=6t{Rt*W)w zzV!t?-}8LmGyPEf*Q!-jt1fT7x2je97ax7^29Lj2-sO2`gFpVD=iT&f&s+0ZiS@ig z=X>6V!B@dEz&`~g-A}=fg1-Yl1-^fT=bZzd3(E7WK#89Regw>b9|D(yXMvA`QtknZ z-vs5AKLVxP-+)q%cY)`99QYh~9ylJn2>c=_@9P4koE;!l_g(-$1AY^f{67OF|L;Mm z#~IZo-#MVvV%e!7^1O?| zD?xc*JNOB3IVkVlVsSqx?L21h{{|e*{ckLub)o0+YVUeb-jf1-@ClGtc}GE#dVL^G z@;*XkCH`_y>JbB_JzK$Z!Eamq6)5Gso0m!XW5LgXw}H}6i$IcikANegg=65I+@Bzm z^!wB?roDHAlD-p^c038nI3EV*fqw}?65g0v)9yK-^m81Paasy~8hjW$4crULIKBu< zIe!Vt`289j2EKQ!>GumjsmC->+RHk)i`Jp91qHU9rzF60#N8{ z#&}b|n8l36<=`1S-vmwqcUtTPmvcXoLB1U90WSsnK%s-rU1Iw45>V)1HYn}99~8RT z218K<9tlK(AG+I!YzCjX@%q~LuKl=gRm zLJ!Y_lK*EQUE=)#6nYo~Q48J70OffHDC77TDCHcq_;;Yxr;5r*d1F9n&#fS&;kAQO z?X`mcjRPrE?6*84Fi z^{Sd^o?i??(%zRq>Bp7eS>Rz%-un|!`r+R|>EF*><#`OPcLhjMUJ{i0?*k?MUx3no zzXPQ|hFxv)%>_TleHN7Zt_LN34=DNn%HIDTly;nbjT!G5ptR#YQ0nyzDE;|OP}=ot zP~ty5$&ACr;JMu20)7VU0Hwdyf#-mSL3!VspuGPNp!Cb|YdvoYcpE6`p9H1+KLM-2 z-`o3lPd4ou3rfE=fYKl9K`HNh;BfFC?fse8nfOb<^N7D4lzMy(ly+?eKLx%4N_l?+ zo)1=08EIE7DCOM&^3O@cqQ!2uiuLK_9#il>FO3>8Ed7d<(4Re#{Mqp1%l6J=TFjM~6VBn0FHN!C})( zzg`PUJKHR71%)2I4~_u)KzaWMZ#4C}0+jKX1WNl_K`DQ$#UEJwPmr$jYHu>-WI?IV z;~*sEy#dYw-!t8mGZ%zJy=9<`-y0U+0wsOT%?8^*nXmi7QD849^!4Ex$P92S_-Sx4 zNSAmIf$svFdj7{_&u^{|@kDU>Eo)a3eSl>;dI{zXXN8KJg{<-mAdNxle&I z?t4Hf|1Utv_j_CsG3d*?jfs+0scbI;e3`#lof|BlO@JjH{ES`R+ z>8Gin*_fWx43zSE!SlhYCTJC`1%-aD2CoKh1upCs9DDZEyiadTT)G zpML=_1pN*}pEp^Y2MS#*1V0Ww3{C}iS^N$7dG0S+WZv5fj^_R#DC6|^;LYG!i%onB zDCswVG4KcAOtAJI(~hrOJP6Jv{v=ojUb)27e=#WixEs6<{4OYV+XueF*l~Z!y(Zlw zpp4HO;4tv-?ESmGYUa=9!25`w0Lt^jprrp>i*JE4e?I;-(=S(mGR}=)HMkfY3vRRc zLr~`7yD0Pua1to>z89PVz6?tL{s$=UtNyx)p9aq5ejRuQcpMxD{xkRw;CV|;`ZGHX zjj2mT&B8~p73X1-qzPT_tYI33&p zUIqRS@O-f50Ye|N!C~C50;T@X+4vKn^t->pl=B5p-n$7L0sah>e)m?Ic1-}U=Qa!a z;1Tdj@aN!V;909o{1-r(r)ltN@JUd{@fYAt;HOuc{%f@OI4JG@p~cZ_%($(vco@8c z=l^JN+FHZEc3FHAlzN=;plRS_0{;z^cHH!k zN#6xt$Ne!-`uV*NoAftYd<2w!{#$Sw_^$P)zit9&aDP8I9{h>L(;hM9O#o$_mV!br z$G~ymTi_V*!beTI+rdfPKWXuopwwgd2E*T5KpD?x!BJoyl=`2!(TvknP|AA{l=#;{ z8PDH=lD>A68SmRciQfuJy?zSHIDhgnY+~>(a1r<|a3py7W;2d4@RQu{2k!#E1Ktjv z_qciA*FfptgP^qU4`3}=yT$bHeDD(Pw}KagKLVv*@7rqf*Mb*v-vmm!he0XtyI>7? z<`bs>CW4o7zX-e(+z$#J=Rj%41y7p#CPC@%!=R-9Ehz83a2qxcco#Sm{607u{Oop9 zpBumraGwTcobLl=KK(H$_5C#{@BR1=Lq|7)GVWWzdElRe^4<%dGUL?%-pc(p@B;An z;7#B;Pa8VF8{tUd8`wI^l>;i9+eBce> z1+SX?Dez|Q4}%Htw8Ms9r@wI_nn}We;AZ@{0^J}UVYT`!-JrV-!H+>gVo1OzWEj(10~;&z)Qfh zziIFbpw#1ji@&mX)wj&^$1VN^c#Q`?|F$W23OJwp`|SNMK%e_hy@BlyUJjlCJ`Y|D z9tEX;{{@tG-1r?c50`%=4L`^#4k54)_yrHaP0LCf!%TY21Gc6uS7p z_slrl080D{unzo7iy!=BlkNsk`fWKV^z&m-`ul=EvHb1oBq5CJcsz3z-z#}K^gCTptLs!P6W^S3p0Q20Nc4=14Y;H7_M;+KJv?~uL! z9e6JHBY$l4u^T|?|ApX8a3?6`{tlG#&i#qu>+?bB=T||g-`|7M{~!AA=#bzIU=}!=zkRVVlPMk z#&Zw(sa$=EYo?C3$EJA?*H>{p8~h+R-^MQoy9k%qdmihb(BLPCn??9A*LC2hZJGxy z{wwhZ2~QHu{jxE7wZo9jmiO@#Llgil5PzG!b=4A=5^6W1%u zrTWvp#{DDQKLN_$`QR7KrT%{}_uC0mxceR9e@C9lWslA0qOY*`X(AR8-c5LkxEbI625Muw}EYhNrck~y9ld!ejE51@OH2o{44Nl zgwGOwPN*TQB0S8q^9Z+a?f(9V`$OD3PgueAC&Bv&M+jNMM+xq)o9EHLUH1Nda6S*7 zCEQJDCBz9;gf%>y1KtNdKzNhu4-n2GZ05e5a5~rT0{({3 zDZV7s`1n2XhKX_~@l*Y#jK(%4;;oG}nRt6F9m}TD6PvW8>HfT?ST@#rrxe(lNM`3v zH20EshGy)@#A{j`YLXpo@pPg=;%91nsy&-%OMFG&GD~CHQ<=m)l3;dNnTAwbTP)ca z)Mt*S%n-F8rD?yY5sTvKOd^$(%(wcOvLhWNz7cuCtN!_;iLzotfTqKlBn&02@%c(SHFr9;)C z5iRl7c6prCyJRX^(-?0^w8dI$8W|9I(jL~+(m|wxY0Z|7*Dz-B^di%;tVYT()}&e+ zrHn;Bt((YW>9|-XlW0zIr!iGt6*M=sBiSHb<4=yYw)%6jv4(|pP-FB_X0+d$$O!et zTH9M<3*y;C1BsWAYHrF;$Jp+6=vyKgL;XfHQVPY>vIOkvaJiv#tKr`PWaGJN3FcGK{K_FGIeD))bS1A(N>V$vmeZvrg`e-`0`I`Yo|VaT?}B zqte-sa8}CCwj|Pxau;ihGmO$Esawp4o|DaSp-Mls;BGogQ>XmlBQnGNrWiEV=#Mm& zq_T~5epc8;I^G<=$8SqDCYbGMzrJ?Nm@%~@8mj%qR6LWc&iac}>4h>VGA5K*r@a#N zn4eAg^)-vCwGJ|LmQp(6)zX)3((mMnrPHw`^V9JrNiPgZBDG6OY8G#6&o1#tCOcYN zN11ds<}2}Z%Eq`s6n;Y2)YSOZRN17aKZ4FNF*X%R7|)2)-x94fx)Ao3JC9jyI&5lW^e1 z(LVD!m5wvzWh`uw<%*K-9RU*`M6z%cGFc{IGfV&yjkU^bYmGtEOf;EqnT`dSY$Dr{ zjYH)^zka-_$xy72B_upQLnZx*(CKJPJVAu1Nwh7l_GX0pd9H(6F|G#wHZ=`1os(+HE{>(+{?t@Q62ZU=V1IL4WMUZk zB!xFg(u_?y!C#W<@Ef382m-#HPArhINibl^##&gS@`oi=L{KDbLRc+H7t<>vYs zxA@n`lRDV5Iu^7h8vN;r2AT&8Q)XP} z-)jVgKKL5+0F$(-Yo^xu6$z4 zz2j>^d|O9rHX(|PFZzJrh`OTElR)v%e{VPJ9MXgHG}@26ZF5CnqT@emv6{6&D5QKy3CW-6us!8 z{E;ZGOw)8DvTas6PJ=rbEBa7|w@mlVF6n-HF6AR2yg4nRR=JYPzAWH57!cl^R64z6 zG|Wxp{K6#Su!X=lsDen3XO$Oub2=It7-?_rGiL(tRE%r_H@#<}GvmNi%NuZ=E!I_M{neZ=XQQY)gu# z@kLOrl#^hJC*UhEJctj)A=OlM^OV_>Zy^1oYo|@0HurWohCg-M+!<5m%<-qrob6BY zXHA+tciQAzrcavf&$?wcLo{WK@6UlBQessj?M#{VSjv|a1r7@!-G4mv5-d&NHJMQ&vF%krIZ=R)~w6fStc8REW%JwpM z`Vl+ApI1|Jr!p`f4X$diC1|b@4OTFWXo!?>J0c-NZ=?LGDk=UW~2kscyBGPSg0Ugl2a!A*6l zPeL%6c8nfXR)d+X^=n8av*}c;-x|*%38EQ|SRK(Ua!;s7CYEw48PNI>BShU5Wi^)d z?vf{(NSyvNnw%2#;s&j zZHiYLr9Y8Q$6MoznDkOZwNC1-9;Mn-iIP=6b=s8a*WEhpy16&Zsgz>Yq`4IyO}l=^ z%-K^WPnt8OLW1cU-xiN0>08te(ch%gEM;XTIECA*Uw}ThP?PHjTD=p>%+RAUqN!B7 zaD@z02kBQYl$}V5No7?Gm1NAs!Yp2WBRzujS8J<6HBFL{nq-tsBb_ZOi`tHA6-LN0 zxU5hhMlt+PM0T1KR^v&a*NRE6<_Rt;uihr>H%Tg+s)n~{USTdKOkwe3P`9RZs*RzFw9q6(hN+N)bsNLotCt5d&jwwJ zNz7Q6(r{Q-nHM3jJJQK&k)t7P1U8OP5jFAZzj}c&*Mlj}7H6DVVx=25h|!kBh{bC6 zVy%#C;}XVJ4VXr(2JvbItfSgPe;GNVwQ01^f1}{j;#NZ~RIY?UlL-WTHjTk0PRZgd zg^Hie&@7rD#)z_NR86$ojAX2XjapG8lxw|=)F*8$Om*e-lMqKz3iZmh){AAJecTad zi0M4~9Sc=kFR~&iSUF~xd%%ogQp;;?1zpCVV6AacubWDRMN~?YIOUr6mot2CxvGFMra5Ras8&l<$2I1_6 zf}zdunTZTcH#6&_L}v_@0dwHY5=urgL`%1%21mi1GD?a_do%08N@y~PG~7nSijS2d znZjNQnp2Q^-tZA)F3b$SQ`qi+xdKk1OigMMuzNrp;K>0$XhMan(opRZ$Sr6D4YtYHcjFiq|0!@ ztG9PNuknQQ3qPoDRk2YWSR+&!GH!{ZvN{Rv#3`AQI-;N%u-rS05P!7r^D(2ogzlFn#N?2TCc5w>RYDu}b*Orzq zrC90U^vddJk>Xr3trX#@jfuQ4c*>kCekT3_qh+d3PDV77#SxW`7GFLQqZoNf`7|^o znn=bf7zpvonEF79fhNtEnR#lZhFNUGSCfE=U`>g=tUYU5!Wb_!D+D&Zj%nCQLIcHP zAcR~r^sXWDsGySimT3Ldmt@~1DOIac>xBNOkXlwKl)go4i!2z7@r}GRZYhXl8GpTHrh-G2CX4gV@KQ6P9&8fa%qNkv>QisGBt%o z{}R);KnV$q1MTWk(OFIztdLX}kFYiCMVqFI^`fd)dkt+k0)-9Md10kl%j(Fq$e`=E zxS1E}F$Ui($7O&wQESRwoz7Fj3jZ(dtz0Ic4~Y)iKKAPHg#6gAeTsKK*v?)?BX=~O29Y!PbBld zTtTA^OOrAqkMX|M=(}ng_th#jCKe^c$&2gWmnAr4uj(2MbLB@euW+nX z51a%a=>WylN|FxTd^$GRxJ@xE0anqhdt2UREM^{kscbjs+)fyAj-N8t3^=TDwF8%KnwFmc9NEIy$?;Wp0w;vpER zz7r^hk^^!vZPyfze4Pv0HyKsTn9GtBQK_#<>U_`m%&E_pJ7j^wufIb)YLQi|_STpZ zL_@X5szJoiEcMBm1pQChaOEKsu~D|GYl@-DZAd^0w(Av!I$`b6OsQn+60;hKvBIvE zAeUXFQ!@)~j6CYX3pE6tCXAz5%ya1qrLOn{b%G(&3RDZK6=Vz^n3UG;b{@lW2}9+C zw(0r^jVO}=2fKO+L!G!@hKNc9?+l8H)`*p&j8IoWsxW~VE5`XRytCZmsYnu8&w#?R zEZ&S9(TE4!2vI-KDzv#ubQO}Ta4MUeO+SWcg^S6&b@!g`Nh<$L#A~y1kpWW4)|S8? zFlixoEg24bexMt$EYy~OZK&rb;`56p6-FGUGfaW|L`pLuOvL@{ik@D+XtNej?ghp_ zR`?D^w{nKoA-(~&2b1c+TE|58o8c|O)zH&W)>1MG;cgo7E9s()W0e`#uCNfJ3DJX2 zTe->~>rzDsJ*q7SR8mzYVQXSR8XvUIvA`js23tV7L&zU2EZC`D-`?8MoJh`3WaeK# zYx;aqJy>sKn}RWKf(mJ4Wa8IrSJ6CZU93hkysSQ?5y)7gcAVMxAXF4|n5Y!uV7J~g z<9%41Xk-CJp1>7V6o=Wx3{G`4w*-0_`-4(!U&tmhO(@_>RL=3xq`F>_W-yRa>oVDa zutfy2#A@cshOM|6tty9=8(#VRp)qST`+oAPSH^UKtW5`fpq$4_T+J@(hO_G9X)oG$ zs6qXvL<0!)V5O1*{WlQg<`Dy-7g5<^SJsV>QncyTRI_Y&^Fx{A;Zk5&;HB*;I2BJC z;<}LG$)JnJ-|mt!rNgLMO2?X(Z7}L3N&_@%{8)2Alu10gkC(8in-=o2wF{< z1C%36s>YUb(xGfJotC=98O&WX$JuCzzX_eMa<)u+4B79t6d2Wq5vw0rJ-Uh}GA(r1 zT@1l$HcvVgOZ{Di<=RR{s%_h0jE&YMMfGs$>7Z-@+arK?#cXZ&>3B_rG%<^!w5-z(5ocbNDXup}2PBSgB#?<1B-`tv7z{GJh z628(Bfb*20=VV*b%KJ2bz_R1_uz@Me7N|AB4w8t5q+SsKapZttwbzg2>XYFujauH@bxb9Yl;q$tw&HcVO_u=*_ZY0G}eO3ux}Tku&ID zxW?G1&OFX*!6>t;^&R(!FG4sA#2hGbx}j?Ut9DD2=LWkrm}s&$LL7IpuL~w5d+U@1 zN?SUTveyG8%!-F#Jv}Ixp=^MZm_m_;>QY`*85EPpIA7F|UL-_85@QudmW7SZj|7Y3TNknl5=qzSCQ~1+ zD#F!WA+n>fA)R1FA@b1pi6d3DOv5g-c_q(fWx;l3&=NJ;5gP35p%LzVVoucJ%*j@J z$ePG20{@9Cz#q|EoFuYn=2CgBnU+LTcBspErMZIlTf1BL_LOztl;)LvOh_5FkZEPi zX!PR(G9^SCA8A?P0+nrFg|x-g*oF+5Z@r~V1Gg*9b(U3xMQ{gc; zYLRLsvc4d?V|m{xTwNy7D6cemSvP8N`p{!L_;(cN8Q?{-`7z{R+C9=&^|LGN_R!su z@Mp-4WsVxR%poq)jNKC_d*3}(>QzNwg0N?YUJ4gs3*VclXrVc7B9=|46E~6wo;p(5 z?01#}vY(!abFNe@N+3Biw8^#gK*m8kw%T zr5hDSnSI9VKLZ<-`S4}R_0wh;Up-aAErn0ApN!Z{`aPD}g<7%vXfj-=71OcD6xu@6 z%JP=%KbJ{E^DE~NPGfw0MV`O@vn-4+VL~y63HGQM`^Ptaka}1t?`v<6?|_hUmI($e zU_fkU61m3T6?iaY{vaPA4=B#IGn#PX04dW$6?>_I9D#foP~@f36$DU`u&S7@SWuz1 zW?&2b?p|TH4*mmVmzv383Em(whp9DlQ&3j<%t9C$SuZt;jtEFs0xEHsI}^zs#+pqc zZq35Uz_6CCD7Q^pr+WDA-Gsr~ul*jdB@>_qkZajr{lD^JRu~&s<=#qim84Hgz z3b-t|nU4jA53lw@HwBgK$M@j2wnjAVjE7CpAm2)uuT)rf!?&p25A7S*DT`VNuC%%n zkS)r3;3W6x;v`CdQAJZ}Eh~c$%BuVnjhZc+8R}dV0?laNy6n0HB>+1w8mDuyf_FFE z7(*@i5F&}^ij^ilFA{n)sSH`?>WB)d~8A^ej(Nip`wQad73TP-e~g?#mtz#9?s zCrgpi%+c!7FqB&+XGy+`E*ex$nP~;qxW7akXM8Q3N})L>4QH1Z7Ja%Q4$9Ve6PhJV z|2`vwh6!3WTOo^nLo9jB_o33Vfl{i|G@XDNNg3!+YAdUbB%gbV4_xSwwE#8~W=1jf z;He2A$P6DKi=G5dC>{gqsSg8)gvUFIbvcoo(*9S6RHk);oNYq~)%s)pF;_@)b3M}6e zCs777xzcW8SC&`g!IOLTKZtB7{B#we+GNaa!^f;L4e`vHJ#+H38B=G@8}8B!zq4Sa zIg8k(T$ewnwB1Nhu!>VAnNe%ZqIFU4l`B<}Q;N*pBDFJgVhLxD>^Mau50}$DNhTVE zabMBdVyvk?!Yq)TB*ch%A4mS!G?Z8PE?9hP$EY$z8PVupHIene(ieqK$CY_%zk}1c zVOyvbqN(x`t?oUSW}{OGh1h0De~7!Vnf1)DN$#7paLanR^hK?%oXIj5SF4QKN@HFZ z)TF31|ovWAd3X zUN$9r0g6qXlK0~5oRO%WaXI$WD~D}?oK2Nj_x)- zz>*3YRkU23Oi^2BaRil3!gK2-ufKyg_LIR5N=I@r^J_k|$O#~Rq@%PCRPmRkGHJpc z{&{?sh*peuO;lz1p2_HXc1nv5DBmA>Hb=0PZRGsnu2ei20qRV3t$0NH^ZH33Bnkx$6gj9bCW5$jdTV;+|sku4RoM^0(gH>wg zresMoiFf6i%)&Uka>tw`Q{J1wm`Cxegkv^T&@JH@;@<#WmwE_s5T~8+-9Z zW5L*vsq2Uw+ZpD@ZpTE>^=gwMm@6X#92l?XgTp zY+=Hm%Xf9n9c<|JuUulHvez`Xq4Y~Vt|FgVpR1W0kG0kLH^$myxN+nDmGb$JlqE0D z@~r0W*fpYuX2uwn%zR>1kA;-5j5`1BSk=wbZk`f$%{cmGvV4)kF*$RY;Q07)Qr4=U zV1h2lp)^mtW$x6P%foc?X3W@{DX4~`D%bg!FGysoX0aiPBYUPI*0JN0Y%Sq7GjZGm z-&{@{JAq?(^sJ{`_r_fJ{#=*R>4{yt|LMqzT-Q@dxJsejnIT0$?{ZOupV%F!kKc9bi zRjzY$u4{F!b6>9W0EApGG(JYW0~B;(_4B)k}|6D>$>`u z@6L5@%60C_b*{^GZqIdY$aOBuE$#C2Yrm0S@rvAct;uz6%XL4Q>t3Dfe#X|Xb9es0 z(fqNkwgz3VG3|0)ujIOS=el34veoJL^r>7YZ{EzSs;c^qy>?>Hi!_72umzfSb{-f4 zQzF0Xl`;+DsGCMQ;s6ue?|XC)U6MbtL58HWNB<|rEr!RpV+nT z#Ew0E>y92j)^qadqxt<0;s0|-XvxSJ4&Ax?`0K}XgbF%VOVrwK3g`^2l;gC5p)?K# z8t>QBGDdac@zwHY7VULjD&gXkKKo$I>@A!Y4_K6nU_w3<<)4KFN za#ok4yuHQkEI73*GKgU!iCvx1zASycIkqdzb*jw>%IV#*vG+0ht)H&5M}V2xHH6x_v%{$EiM?x2?0>AN zi=i+^_{6S_j;mS%FBzrec$WQ z?%LjU%;y!oTbJgKLLLFD*ykps5jK0^j=fL9`AJjEBjq#E5X=DJtry0;qfETXy_QA|^q z-%!f|KR64`3Uh{e&-1WRH=M}Oke%4$j12qJ>~c7o6vLTl)L!)fC}E#t|At|R43Xo} zN(Q*c3_|aV8`zd?PfLTv32zGzOq1f3i}tSGkw5a1q4MC!G}1a2Ss>(~OBiLYYn^iZ zeHx>_L_1~MhT za&7O%SDnfy?9U6H8MdJEALZuN{6i=-g(=Vz^AD}C>C7`ZPfdjH@k9Gh9EP#4am5wp zRLv1ftW$MYOs*BV?gymCD8ijKZc+ zVZJQaMf>kJwI+MmG}G*;`ccxf1IzMTUg&$N>-b??K$yEszFhYXWel)qnIybhnc=pm z$d_~4sOgCpwhJ3wx-&A(i^gcP7io@DwvNB{4Amx6;pU$I;X_J~t1%ek+v!jVz>3kNNbJJnpiQP}1e1NH8MEC0a z3P>C^KBC#<`pB<>dUe*?W9x>%U*<+mD-*xt|DO-AW9a+#A?|yGm8qvmwFGo1yiVA@ z&v+xDO=dCOd4R+0xPe=(bu(OhSd51th1`^+m={Sg@2+ww?zp#HY(zo8TC<1Yg)h6F z;}k2=eZR-!y{&TpzjSC`@0LT@hrMeaz#NB7!GH5BUd|ug;iO&(|BW2DC%P4Dd5pU$ zh54vw^eJ?FLar8*8^O)02Fn39wHY_YO_!gpiA0rhl6rLvuugq)?XvFH8?=~^SLOmBPP;eYb_ zQiGxJ_`gbN^Z>vL52Hr_mQUjRLXkPAM9Lsd*9kz+_AXnOe;AQxshJoxo+BOY&IjZj zVsDDIW}Yeswx<|CRc`k6t8&!a#Wp@wEi7-4+07XdX8B8tDA%Ftyr>7AlnI$V^9A6_K^J)XQn6(Lj0Ku!P>x z`er?ckm7o`uFUr^RNHYbo!GTnmGWX$m%|DB8FfC(Hq{z<)cYx=b#SG4^=3aobR5c! zmN}?UJJ9eaVcB@}bDb}$*@B7(ABR7#;kNgQXF?7u4%0%%EaL$w`}MBOHAb)&**?)T z5X1L|Lo?_K=zC-VyCT7a2PBFDS*gMmYUvJ8B&(GaDrk_E!E__1Iu($c$Q|b8HgljN z&2oi8o1s(^{%(&~44h%sOC&6yn3KV*UspR4M@=X*tVn<&Hz7Ipo!E=weN2VpQC-PE ziWw)(W{(|B(cSF%Z>+) z#kmfz87P-IDY4)UxVgLcU>7)l+V?3k^j#S{DESEw?{)pb3+Mb%64r#wX$7q zp*wZY8>vz3iY!~3fpc&YEY25Hxl%sm2v1v=QTIwc3c#%C zIHt^kC2M>=C!U2N95X707rv&z|Hg_nkf}I|Ma#81n9G zINw$YW+%fb)gkbb1XO999onH{gqCG=#U!cytrXcKjwftbS@KX3g@o(b#>`d`743C) zIX z&wx2q2x+xTD}trXtP7;Cj2}Z+Xy1q%rF27wJKwe_Z5aoHtzU7%dO43aU?KKcS|VVA zkP9M**=hjs~jiFBxO zOshN(mp01H73DnT-fGOyppRuSw+n6D2@t4V)r&e`XPWNX6~A4f&7dENiGj|^xI?hb zquJh;VXg%gn&tzT*Ls9*Xhfjon=OWwtdvj_3D%U+qht;55r$aZ5Ucv0I(+=t6Ggo* z9q+gyE^OobHyTZmBA^*X0gH-h-0FkNB{ z`|;OI%|T39wO;* z`i)cetj;{tj4W~wkdrAZ8+NFpv$5+r{defOtdHFI?aT`I$p_Y+*!h6**!lJLoE+_t zvb#0Bfr`+xg>@H1k#`{At(%q5@((S`g^tdBjIHu15yUb^(ooT;a)oZy(*3SFI|_~) zHm1K)lADuCIAvJ(HSWhJkzKkCZlB2(6-KJ^M5#jz?~wVbw#Gu15mDbz6?Z#ZUr+2| zN8p-(p1r>H-^f4JZL}Z1^vq(?8jH*^#<06+Vd>gWuu{eJ#v3nNnCU}Ek$&6kS=nAX z!wU68r2y#LDdy#DIUTHG4PH0Q25coLpg>bM`a!=bgN%GPB-f&exveH$EV08Lxn;?e zd8$VzLlDeZ4(P=VpMPjg-+nZKeZ4E6kIatE9-pNlLzEetRoXShi?Wdv((k&lPT5Y0 zN@4hJslo=iJpB6c*LLa_V;N=f0;!l&dNivurN&V-*FN`NGOmVNP8>tX8=)ACy;VbK zQg9Y>fm)8NskG=D$x=ookGRLXR@0?s89K0Ubd`g8?JBS1N6Id!j`PF2W$2>T$j}tE zgUJ=V-AI$6=2iC2^flZpSe-U55y~ESzLHBtW>mILP(`UYVA0uVTU&GCb`Wd3TK-K3 z*u9wju02NC3sp2t2y6i1dl&$ie?5JxUhZ9vYRY@ziV*u6v*VnJHtu{*jE)NYi_g!D z65yU0CG~?NQxAEYn@SCOO%;A-`_z zV2d%9n~~+rHu|W*ITaQIg9&P8PN)`EB1?;AmrO8z{q2t{Eddr7ZX%HtKLo*}Vt>fq zua$m1A9e*H^Xp!* z?)l)$0Otib#P&H9En|glgE^|+waV?U!~9YGu4E8)JGm*gPSLv1K%eKz=y`hJflZMCzzo4NXjSr?m^}kUD)Sr zAK|cd<2Z7Qtzy`0VV}O?D9%ciZ6>;~;Pr0Z>zGbYWey0Fa9Q&`PoLPs^oy`4_CtnJ z0q54Tz~ds#*LAN!6>Sn3SGF9(P93QeZemO!+^mnQ;el$g9y3bkE-pg(pjR0<%FFr) z&lV+F8JgH#OrolQCBdHD>cHyKb%FAuRq!5oZFx4$KBP7BB|8i1@Vu_BzAXpw_eCld z=`-n1Ve3Wid|}HfZbONwtWC_T#%kYfirG`C21UhHs%i0?1G`L5j<>zS^bx}k5|kzI zBGbdTFbkHwBb`)OUO_Ra({{&*Q!wm@rXr~-mlx6o&QkXQtsxaPuPazY1$FAHxP+;n zg=4F@f{PkkyarNGs-JSj*TlrR|%26b8Fwhr>K^#uILajSo~}2^AGHT16zXIv-HH?CymOf zvs%2C)D#MZPFJ|k_*6nJ?JQbQiHclmV4qrl$UY-x8EUP8V;kY|_qru%rBh_raQJ;t zjd9YS(XaQM_GS1cejoId<@--AeWA#k;@flb`I#ZRYej5Fg!?LOJ%;7FP@HhXEEgMENjxy0sW&PiqmZ-Bh^_;BOp#;|7P z2!|lkkAHUezv-lct}$o&+mG==Cm_?i?AA*Ck$@o&R_PJ_p@uc!e$vv+Z)@eMw78r& zQ&31(7&F3uZ94byMFARqkum6xbU!p8tYT2*Ir(&I<(1i=@Q&28a=AmO zFAH3%-S(IPpbvfh^#dfFlc4Iq5Z{EQpT3o^>OO-W=g<|3)4tsKcyG^3Cm&}v?JnJ- zMbY^c&#GlAf>haO`Tg&nV{b;xMm9pN$aSMP>uy^<&6YKL-UUq|dn;@P=&vZtDUI)K zP^DQTNSFxz7MLvp+WIXbD%d_bbtrl$L)U7KAF}IU-8k~_S))HxTGdj^pmaBa)iNRS z#~$q4X;dT>M-&uR(*or|GRs&*t2We}g?@^`zL1X)WJ#(U<~p<&>hC=iX=Tc%!!<5Z zi=Fn_@M8(d z>DoP(=4PZb9J50A>Y@yOXSxN> zpr{7oQH1m$eB5&`Nds~mVw zLuoOvvzin3bN~_Kb`k<@M*ToJOhpjo3(oP9aey1hZg*GZb)Dj3- zQ4e0(b>b+-MDYE3R3=wJ3q{>FCriq4l6;o)qA9C#<^zwOIMS`AUzj@D7%9;% zMijr+N37A*ixD!2Bu<1s5paCw5Viu>)R{ zGD^1o=Z`+yy9qksU$~G=9a#Ubl-2Y(onJ9)>5sV#L1!t={I>L#(&FB(bIkpC%#gLA zN*MzchdwRqqKy9R3`3=QD{1YALdL$?BP$)Us|qLSGs>^|X7}mihnTWG`3>t%?m%h< zAL>b#{Pu$!@kV6C8dU#=v*1HP#7r};95G+*8r{B=vTzbTRTUSr9>XdxH{?3VZ045| zf?v7eZKAAfc`~v@!~_p{lKttMX#Wr3PP1Reb+72vnOW#w>~Aj&0`wxf{Rtp=mRU^{<|Q8Y1E&5cuU4xG3o!fj?c$?zuZwO_o|OhKj<&2|A`LEU@Fsl! zgE_&&*n3Xn>v8LAYl{6=Mrm`usDovZ-_1^~lCM_SGTe;1#UnhUJ$lUH2A?g#5_zDY zLhdPDQo1&Q=5X=((VrV~B}qB5^6VBqgl-~&!VIGQnV`Zv;|7(-_~Atvwa2J&3NhOX zRI4kkCJKopLompu6}+9!0CN3QR9w#h`bJ6q%KfYzp|o<4+S1p$I^K!2HH2C5(3rxi z>B6TSCy}}K3nAg=qVc)J1Jom`+mUUY=@GZspo;4tOEMist%5@i&DSrHG2ZOCUr7oQ z>*O08|9Iz4f{*MkF`Uh9Jt`iD%%Cf7n0YwJC)ii`AnBQY!##3z8aTE#jMzj@I*GhmgNq+1lrkA4?G45P3~-zz3f{(GES1 zwor{!_7Myd*~`6!(bN_c{w!6|(90O&ThZ5u2^{<~Rd9?bnrz?8oAtBe=rMNDQPS50 zpKZF|my+I6dzbUfsUo{+)ch~79@q}FoL@d+uQJEkV*Fy{F4g@WuZlaN>#33RM=_51 zm8;arFDg&;H%z?7hT_=%^Rr-Tj1IR7} izWoezbMa4Yy)8poe<7<_DH`y^rn0#L?Y5FC_5T3;S_TsU literal 0 HcmV?d00001 diff --git a/po/ja.po b/po/ja.po new file mode 100644 index 0000000..e6b2680 --- /dev/null +++ b/po/ja.po @@ -0,0 +1,2133 @@ +# Japanese messages for gawk. +# Copyright (C) 2003, 2011 Free Software Foundation, Inc. +# This file is distributed under the same license as the gawk package. +# Makoto Hosoya , 2003. +# Yasuaki Taniguchi , 2011. +# +msgid "" +msgstr "" +"Project-Id-Version: gawk 4.0.0\n" +"Report-Msgid-Bugs-To: arnold@skeeve.com\n" +"POT-Creation-Date: 2012-03-28 22:03+0200\n" +"PO-Revision-Date: 2011-07-17 08:28+0900\n" +"Last-Translator: Yasuaki Taniguchi \n" +"Language-Team: Japanese \n" +"Language: ja\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#: array.c:140 +#, c-format +msgid "from %s" +msgstr "%s から" + +#: array.c:248 +msgid "attempt to use a scalar value as array" +msgstr "スカラー値を配列として使用する試みです" + +#: array.c:251 +#, c-format +msgid "attempt to use function `%s' as an array" +msgstr "関数 `%s' を配列として使用する試みです" + +#: array.c:254 +#, c-format +msgid "attempt to use scalar parameter `%s' as an array" +msgstr "スカラー仮引数 `%s' を配列として使用する試みです" + +#: array.c:257 +#, c-format +msgid "attempt to use scalar `%s' as an array" +msgstr "スカラー `%s' を配列として使用する試みです" + +#: array.c:302 array.c:707 builtin.c:84 builtin.c:1385 builtin.c:1427 +#: builtin.c:1440 builtin.c:1859 builtin.c:1871 eval.c:1135 eval.c:1139 +#: eval.c:1495 eval.c:1812 +#, c-format +msgid "attempt to use array `%s' in a scalar context" +msgstr "スカラーコンテキストで配列 `%s' を使用する試みです" + +#: array.c:513 +#, c-format +msgid "reference to uninitialized element `%s[\"%.*s\"]'" +msgstr "初期化されていない要素 `%s[\"%.*s\"]' への参照です" + +#: array.c:519 +#, c-format +msgid "subscript of array `%s' is null string" +msgstr "配列 `%s' の添字が NULL 文字列です" + +#: array.c:723 +#, c-format +msgid "delete: index `%s' not in array `%s'" +msgstr "delete: 配列 `%2$s' 内にインデックス `%1$s' がありません" + +#: array.c:734 eval.c:1865 +#, c-format +msgid "attempt to use scalar `%s[\"%.*s\"]' as an array" +msgstr "スカラー `%s[\"%.*s\"]' を配列として使用する試みです" + +#: array.c:910 +#, c-format +msgid "%s: empty (null)\n" +msgstr "%s: 空 (null)\n" + +#: array.c:915 +#, c-format +msgid "%s: empty (zero)\n" +msgstr "%s: 空 (zero)\n" + +#: array.c:919 +#, c-format +msgid "%s: table_size = %d, array_size = %d\n" +msgstr "%s: テーブルサイズ (table_size) = %d, 配列サイズ (array_size) = %d\n" + +#: array.c:954 +#, c-format +msgid "%s: is parameter\n" +msgstr "%s: 仮引数です\n" + +#: array.c:958 +#, c-format +msgid "%s: array_ref to %s\n" +msgstr "%s: %s への配列参照 (array_ref) です\n" + +#: array.c:963 +msgid "adump: argument not an array" +msgstr "adump: 引数が配列ではありません" + +#: array.c:1086 +msgid "asort: second argument not an array" +msgstr "asort: 第二引数が配列ではありません" + +#: array.c:1087 +msgid "asorti: second argument not an array" +msgstr "asorti: 第二引数が配列ではありません" + +#: array.c:1094 +msgid "asort: first argument not an array" +msgstr "asort: 第一引数が配列ではありません" + +#: array.c:1095 +msgid "asorti: first argument not an array" +msgstr "asorti: 第一引数が配列ではありません" + +#: array.c:1102 +msgid "asort: cannot use a subarray of first arg for second arg" +msgstr "asort: 第一引数の部分配列を第二引数用に使用することは出来ません" + +#: array.c:1103 +msgid "asorti: cannot use a subarray of first arg for second arg" +msgstr "asorti: 第一引数の部分配列を第二引数用に使用することは出来ません" + +#: array.c:1108 +msgid "asort: cannot use a subarray of second arg for first arg" +msgstr "asort: 第二引数の部分配列を第一引数用に使用することは出来ません" + +#: array.c:1109 +msgid "asorti: cannot use a subarray of second arg for first arg" +msgstr "asorti: 第二引数の部分配列を第一引数用に使用することは出来ません" + +#: array.c:1655 +#, c-format +msgid "`%s' is invalid as a function name" +msgstr "`%s' は関数名としては無効です" + +#: array.c:1659 +#, c-format +msgid "sort comparison function `%s' is not defined" +msgstr "ソート比較関数 `%s' が定義されていません" + +#: awkgram.y:249 +#, c-format +msgid "%s blocks must have an action part" +msgstr "%s ブロックにはアクション部が必須です" + +#: awkgram.y:252 +msgid "each rule must have a pattern or an action part" +msgstr "各ルールにはパターンまたはアクション部が必須です。" + +#: awkgram.y:323 awkgram.y:334 +msgid "old awk does not support multiple `BEGIN' or `END' rules" +msgstr "古い awk は複数の `BEGIN' または `END' ルールをサポートしません" + +#: awkgram.y:371 +#, c-format +msgid "`%s' is a built-in function, it cannot be redefined" +msgstr "`%s' は組込み関数です。再定義できません" + +#: awkgram.y:432 +msgid "regexp constant `//' looks like a C++ comment, but is not" +msgstr "正規表現定数 `//' は C++コメントに似ていますが、違います。" + +#: awkgram.y:436 +#, c-format +msgid "regexp constant `/%s/' looks like a C comment, but is not" +msgstr "正規表現定数 `/%s/' は C コメントに似ていますが、異なります" + +#: awkgram.y:528 +#, c-format +msgid "duplicate case values in switch body: %s" +msgstr "switch 文の中で重複した case 値が使用されています: %s" + +#: awkgram.y:549 +msgid "duplicate `default' detected in switch body" +msgstr "switch 文の中で重複した `default' が検出されました" + +#: awkgram.y:809 +msgid "`break' is not allowed outside a loop or switch" +msgstr "`break' はループまたは switch の外では許可されていません" + +#: awkgram.y:818 +msgid "`continue' is not allowed outside a loop" +msgstr "`continue' はループの外では許可されていません" + +#: awkgram.y:828 +#, c-format +msgid "`next' used in %s action" +msgstr "%s アクション内で `next' が使用されました" + +#: awkgram.y:836 +msgid "`nextfile' is a gawk extension" +msgstr "`nextfile' は gawk 拡張です" + +#: awkgram.y:841 +#, c-format +msgid "`nextfile' used in %s action" +msgstr "`nextfile' が %s アクション内で使用されました" + +#: awkgram.y:865 +msgid "`return' used outside function context" +msgstr "`return' が関数定義文の外で使われました" + +#: awkgram.y:925 +msgid "plain `print' in BEGIN or END rule should probably be `print \"\"'" +msgstr "" +"BEGIN または END ルール内の引数の無い `print' は `print \"\"' だと思われます" + +#: awkgram.y:995 awkgram.y:999 awkgram.y:1023 +msgid "`delete array' is a gawk extension" +msgstr "`delete array' は gawk 拡張です" + +#: awkgram.y:1019 +msgid "`delete(array)' is a non-portable tawk extension" +msgstr "`delete(array)' は移植性の無い tawk 拡張です" + +#: awkgram.y:1135 +msgid "multistage two-way pipelines don't work" +msgstr "多段階で双方向パイプを利用した式は使用できません" + +#: awkgram.y:1238 +msgid "regular expression on right of assignment" +msgstr "正規表現が代入式の右辺に使用されています" + +#: awkgram.y:1249 +msgid "regular expression on left of `~' or `!~' operator" +msgstr "`~' や `!~' 演算子の左辺に正規表現が使用されています" + +#: awkgram.y:1265 awkgram.y:1419 +msgid "old awk does not support the keyword `in' except after `for'" +msgstr "古い awk では `in' 予約語は `for' の後を除きサポートしません" + +#: awkgram.y:1275 +msgid "regular expression on right of comparison" +msgstr "比較式の右辺に正規表現が使用されています。" + +#: awkgram.y:1394 +#, c-format +msgid "`getline var' invalid inside `%s' rule" +msgstr "`%s' ルールの内部では `getline var' は無効です" + +#: awkgram.y:1397 eval.c:2504 +#, c-format +msgid "`getline' invalid inside `%s' rule" +msgstr "`%s' ルールの内部では `getline' は無効です" + +#: awkgram.y:1402 +msgid "non-redirected `getline' undefined inside END action" +msgstr "リダイレクトされていない `getline' は END アクションでは未定義です。" + +#: awkgram.y:1421 +msgid "old awk does not support multidimensional arrays" +msgstr "古い awk は多次元配列をサポートしません" + +#: awkgram.y:1517 +msgid "call of `length' without parentheses is not portable" +msgstr "小括弧が無い `length' は移植性がありません" + +#: awkgram.y:1580 +msgid "indirect function calls are a gawk extension" +msgstr "間接関数呼び出しは gawk 拡張です" + +#: awkgram.y:1593 +#, c-format +msgid "can not use special variable `%s' for indirect function call" +msgstr "特別な変数 `%s' は間接関数呼び出し用には使用出来ません" + +#: awkgram.y:1671 +msgid "invalid subscript expression" +msgstr "添字の式が無効です" + +#: awkgram.y:1711 +msgid "use of non-array as array" +msgstr "配列でないものを配列として使用しています" + +#: awkgram.y:1975 awkgram.y:1995 msg.c:98 +msgid "warning: " +msgstr "警告: " + +#: awkgram.y:1993 msg.c:130 +msgid "fatal: " +msgstr "致命的: " + +#: awkgram.y:2043 +msgid "unexpected newline or end of string" +msgstr "予期しない改行または文字列終端です" + +#: awkgram.y:2300 awkgram.y:2358 awkgram.y:2542 +#, c-format +msgid "can't open source file `%s' for reading (%s)" +msgstr "ソースファイル `%s' を読み込み用に開けません (%s)" + +#: awkgram.y:2301 awkgram.y:2359 builtin.c:122 +msgid "reason unknown" +msgstr "原因不明" + +#: awkgram.y:2317 +#, c-format +msgid "already included source file `%s'" +msgstr "ソースファイル `%s' は既に読み込まれています" + +#: awkgram.y:2343 +msgid "@include is a gawk extension" +msgstr "@include は gawk 拡張です" + +#: awkgram.y:2349 +msgid "empty filename after @include" +msgstr "@include の後に空のファイル名があります" + +#: awkgram.y:2494 +msgid "empty program text on command line" +msgstr "コマンド行のプログラム表記が空です" + +#: awkgram.y:2609 +#, c-format +msgid "can't read sourcefile `%s' (%s)" +msgstr "ソースファイル `%s' を読み込めません (%s)" + +#: awkgram.y:2620 +#, c-format +msgid "source file `%s' is empty" +msgstr "ソースファイル `%s' は空です" + +#: awkgram.y:2797 +msgid "source file does not end in newline" +msgstr "ソースファイルが改行で終っていません" + +#: awkgram.y:2900 +msgid "unterminated regexp ends with `\\' at end of file" +msgstr "終端されていない正規表現がファイル最後の `\\' で終っています。" + +#: awkgram.y:2924 +#, c-format +msgid "%s: %d: tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "%s: %d: tawk の正規表現修飾子 `/.../%c' は gawk で使用できません" + +#: awkgram.y:2928 +#, c-format +msgid "tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "tawk の正規表現修飾子 `/.../%c' は gawk で使用できません" + +#: awkgram.y:2935 +msgid "unterminated regexp" +msgstr "正規表現が終端されていません" + +#: awkgram.y:2939 +msgid "unterminated regexp at end of file" +msgstr "ファイルの中で正規表現が終端されていません" + +#: awkgram.y:2998 +msgid "use of `\\ #...' line continuation is not portable" +msgstr "`\\ #...' 形式の行継続は移植性がありません" + +#: awkgram.y:3014 +msgid "backslash not last character on line" +msgstr "バックスラッシュが行最後の文字になっていません。" + +#: awkgram.y:3075 +msgid "POSIX does not allow operator `**='" +msgstr "POSIX では演算子 `**=' は許可されていません" + +#: awkgram.y:3077 +msgid "old awk does not support operator `**='" +msgstr "古い awk は演算子 `**=' をサポートしません" + +#: awkgram.y:3086 +msgid "POSIX does not allow operator `**'" +msgstr "POSIX では演算子 `**' は許可されていません" + +#: awkgram.y:3088 +msgid "old awk does not support operator `**'" +msgstr "古い awk は演算子 `**' をサポートしません" + +#: awkgram.y:3123 +msgid "operator `^=' is not supported in old awk" +msgstr "古い awk は演算子 `^=' をサポートしません" + +#: awkgram.y:3131 +msgid "operator `^' is not supported in old awk" +msgstr "古い awk は演算子 `^' をサポートしません" + +#: awkgram.y:3224 awkgram.y:3240 +msgid "unterminated string" +msgstr "文字列が終端されていません" + +#: awkgram.y:3436 +#, c-format +msgid "invalid char '%c' in expression" +msgstr "式内に無効な文字 '%c' があります" + +#: awkgram.y:3483 +#, c-format +msgid "`%s' is a gawk extension" +msgstr "`%s' は gawk 拡張です" + +#: awkgram.y:3488 +#, c-format +msgid "`%s' is a Bell Labs extension" +msgstr "`%s' はベル研究所による拡張です" + +#: awkgram.y:3493 +#, c-format +msgid "POSIX does not allow `%s'" +msgstr "POSIX では `%s' は許可されていません" + +#: awkgram.y:3501 +#, c-format +msgid "`%s' is not supported in old awk" +msgstr "古い awk は `%s' をサポートしません" + +#: awkgram.y:3568 +msgid "`goto' considered harmful!\n" +msgstr "`goto' は有害だと見なされています!\n" + +#: awkgram.y:3619 +#, c-format +msgid "%d is invalid as number of arguments for %s" +msgstr "%d は %s 用の引数の数としては無効です" + +#: awkgram.y:3654 +#, c-format +msgid "%s: string literal as last arg of substitute has no effect" +msgstr "%s: 文字列リテラルを置き換え最後の引数に使用すると効果がありません" + +#: awkgram.y:3659 +#, c-format +msgid "%s third parameter is not a changeable object" +msgstr "%s 第三仮引数は可変オブジェクトではありません" + +#: awkgram.y:3732 awkgram.y:3735 +msgid "match: third argument is a gawk extension" +msgstr "match: 第三引数は gawk 拡張です" + +#: awkgram.y:3789 awkgram.y:3792 +msgid "close: second argument is a gawk extension" +msgstr "close: 第二引数は gawk 拡張です" + +#: awkgram.y:3804 +msgid "use of dcgettext(_\"...\") is incorrect: remove leading underscore" +msgstr "" +"dcgettext(_\"...\")の使用法が間違っています: 先頭のアンダースコア(_)を削除し" +"てください" + +#: awkgram.y:3819 +msgid "use of dcngettext(_\"...\") is incorrect: remove leading underscore" +msgstr "" +"dcngettext(_\"...\")の使用法が間違っています: 先頭のアンダースコア(_)を削除し" +"てください" + +#: awkgram.y:3911 +#, c-format +msgid "function `%s': parameter #%d, `%s', duplicates parameter #%d" +msgstr "関数 `%s': 仮引数 #%d, `%s' が仮引数 #%d と重複しています" + +#: awkgram.y:3953 +#, c-format +msgid "function `%s': parameter `%s' shadows global variable" +msgstr "関数 `%s': 仮引数 `%s' が大域変数を覆い隠しています" + +#: awkgram.y:4111 +#, c-format +msgid "could not open `%s' for writing (%s)" +msgstr "`%s' を書込み用に開けませんでした (%s)" + +#: awkgram.y:4112 +msgid "sending variable list to standard error" +msgstr "変数リストを標準エラーに送っています" + +#: awkgram.y:4118 +#, c-format +msgid "%s: close failed (%s)" +msgstr "%s: 閉じるのに失敗しました (%s)" + +#: awkgram.y:4170 +msgid "shadow_funcs() called twice!" +msgstr "shadow_funcs() を二回呼び出しています!" + +#: awkgram.y:4176 +msgid "there were shadowed variables." +msgstr "覆い隠された変数がありました" + +#: awkgram.y:4206 +#, c-format +msgid "function `%s': can't use function name as parameter name" +msgstr "関数 `%s': 関数名を仮引数名として使用出来ません" + +#: awkgram.y:4210 +#, c-format +msgid "function `%s': can't use special variable `%s' as a function parameter" +msgstr "関数 `%s': 特別な変数 `%s' は関数の仮引数として使用出来ません" + +#: awkgram.y:4226 +#, c-format +msgid "function name `%s' previously defined" +msgstr "関数名 `%s' は前に定義されています" + +#: awkgram.y:4394 awkgram.y:4400 +#, c-format +msgid "function `%s' called but never defined" +msgstr "未定義の関数 `%s' を呼び出しました" + +#: awkgram.y:4403 +#, c-format +msgid "function `%s' defined but never called directly" +msgstr "関数 `%s' は定義されていますが、一度も直接呼び出されていません" + +#: awkgram.y:4435 +#, c-format +msgid "regexp constant for parameter #%d yields boolean value" +msgstr "仮引数 #%d 用の正規表現定数は真偽値を出力します" + +#: awkgram.y:4544 +#, c-format +msgid "" +"function `%s' called with space between name and `(',\n" +"or used as a variable or an array" +msgstr "" +"関数名と `(' の間にスペースを入れて関数 `%s' を呼び出しています。\n" +"または、変数か配列として使われています。" + +#: awkgram.y:4791 eval.c:2056 +msgid "division by zero attempted" +msgstr "ゼロによる除算が試みられました" + +#: awkgram.y:4800 eval.c:2072 +#, c-format +msgid "division by zero attempted in `%%'" +msgstr "`%%' 内でゼロによる除算が試みられました" + +#: builtin.c:120 +#, c-format +msgid "%s to \"%s\" failed (%s)" +msgstr "%s から \"%s\" へ出力できません (%s)。" + +#: builtin.c:121 +msgid "standard output" +msgstr "標準出力" + +#: builtin.c:135 +msgid "exp: received non-numeric argument" +msgstr "exp: 引数が数値ではありません" + +#: builtin.c:141 +#, c-format +msgid "exp: argument %g is out of range" +msgstr "exp: 引数 %g が範囲外です" + +#: builtin.c:200 +#, c-format +msgid "fflush: cannot flush: pipe `%s' opened for reading, not writing" +msgstr "" +"fflush: flush できません: パイプ `%s' は読み込み用に開かれています。書き込み" +"用ではありません" + +#: builtin.c:203 +#, c-format +msgid "fflush: cannot flush: file `%s' opened for reading, not writing" +msgstr "" +"fflush: flush できません: ファイル `%s' は読み込み用に開かれています。書き込" +"み用ではありません" + +#: builtin.c:215 +#, c-format +msgid "fflush: `%s' is not an open file, pipe or co-process" +msgstr "fflush: `%s' が開かれたファイル、パイプ、プロセス共有ではありません" + +#: builtin.c:333 +msgid "index: received non-string first argument" +msgstr "index: 文字列では無い第一引数を受け取りました" + +#: builtin.c:335 +msgid "index: received non-string second argument" +msgstr "index: 文字列では無い第二引数を受け取りました" + +#: builtin.c:457 +msgid "int: received non-numeric argument" +msgstr "int: 数値では無い引数を受け取りました" + +#: builtin.c:493 +msgid "length: received array argument" +msgstr "length: 配列引数を受け取りました" + +#: builtin.c:496 +msgid "`length(array)' is a gawk extension" +msgstr "`length(array)' は gawk 拡張です" + +#: builtin.c:504 +msgid "length: received non-string argument" +msgstr "length: 文字列では無い引数を受け取りました" + +#: builtin.c:535 +msgid "log: received non-numeric argument" +msgstr "log: 数値では無い引数を受け取りました" + +#: builtin.c:538 +#, c-format +msgid "log: received negative argument %g" +msgstr "log: 負の引数 %g を受け取りました" + +#: builtin.c:694 builtin.c:699 +msgid "fatal: must use `count$' on all formats or none" +msgstr "" +"致命的: `count$’ は全ての書式使用する、または全てに使用しないのいずれかでなけ" +"ればいけません" + +#: builtin.c:762 +#, c-format +msgid "field width is ignored for `%%' specifier" +msgstr "`%%' 指定用のフィールド幅は無視されます" + +#: builtin.c:764 +#, c-format +msgid "precision is ignored for `%%' specifier" +msgstr "`%%' 指定用のフィールド幅は無視されます" + +#: builtin.c:766 +#, c-format +msgid "field width and precision are ignored for `%%' specifier" +msgstr "`%%' 指定用のフィールド幅および精度は無視されます" + +#: builtin.c:817 +msgid "fatal: `$' is not permitted in awk formats" +msgstr "致命的: `$' は awk 形式内では許可されていません" + +#: builtin.c:826 +msgid "fatal: arg count with `$' must be > 0" +msgstr "致命的: `$' で指定する引数の番号は正でなければいけません" + +#: builtin.c:830 +#, c-format +msgid "fatal: arg count %ld greater than total number of supplied arguments" +msgstr "致命的: 引数の番号 %ld は引数として与えられた数より大きいです" + +#: builtin.c:834 +msgid "fatal: `$' not permitted after period in format" +msgstr "致命的: `$' は書式指定内のピリオド `.' の後に使用できません" + +#: builtin.c:850 +msgid "fatal: no `$' supplied for positional field width or precision" +msgstr "致命的: フィールド幅、または精度の指定子に `$' が与えられていません" + +#: builtin.c:921 +msgid "`l' is meaningless in awk formats; ignored" +msgstr "awk の書式指定では `l' は無意味です。無視します" + +#: builtin.c:925 +msgid "fatal: `l' is not permitted in POSIX awk formats" +msgstr "致命的: POSIX awk 書式内では `l' は許可されていません" + +#: builtin.c:938 +msgid "`L' is meaningless in awk formats; ignored" +msgstr "awk の書式指定では `L' は無意味です。無視します。" + +#: builtin.c:942 +msgid "fatal: `L' is not permitted in POSIX awk formats" +msgstr "致命的: POSIX awk 書式内では `L' は許可されていません" + +#: builtin.c:955 +msgid "`h' is meaningless in awk formats; ignored" +msgstr "awk の書式指定では `h' は無意味です。無視します。" + +#: builtin.c:959 +msgid "fatal: `h' is not permitted in POSIX awk formats" +msgstr "致命的: POSIX awk 書式内では `h' は許可されていません" + +#: builtin.c:1272 +#, c-format +msgid "[s]printf: value %g is out of range for `%%%c' format" +msgstr "[s]printf: 値 %g は書式 `%%%c' の範囲外です" + +#: builtin.c:1332 +#, c-format +msgid "ignoring unknown format specifier character `%c': no argument converted" +msgstr "不明な書式指定文字 `%c' を無視しています: 変換される引数はありません" + +#: builtin.c:1337 +msgid "fatal: not enough arguments to satisfy format string" +msgstr "致命的: 書式文字列を満たす十分な数の引数がありません" + +#: builtin.c:1339 +msgid "^ ran out for this one" +msgstr "^ ここから足りません" + +#: builtin.c:1346 +msgid "[s]printf: format specifier does not have control letter" +msgstr "[s]printf: 書式指定子に制御文字がありません" + +#: builtin.c:1349 +msgid "too many arguments supplied for format string" +msgstr "書式文字列に与えられている引数が多すぎます" + +#: builtin.c:1423 builtin.c:1434 +msgid "printf: no arguments" +msgstr "printf: 引数がありません" + +#: builtin.c:1475 +msgid "sqrt: received non-numeric argument" +msgstr "sqrt: 数値では無い引数を受け取りました" + +#: builtin.c:1479 +#, c-format +msgid "sqrt: called with negative argument %g" +msgstr "sqrt: 負の値 %g を引数に使用して呼び出されました" + +#: builtin.c:1503 +#, c-format +msgid "substr: length %g is not >= 1" +msgstr "substr: 長さ %g が 1 以上ではありません" + +#: builtin.c:1505 +#, c-format +msgid "substr: length %g is not >= 0" +msgstr "substr: 長さ %g が 0 以上ではありません" + +#: builtin.c:1512 +#, c-format +msgid "substr: non-integer length %g will be truncated" +msgstr "substr: 文字数 %g の小数点以下は切り捨てます。" + +#: builtin.c:1517 +#, c-format +msgid "substr: length %g too big for string indexing, truncating to %g" +msgstr "substr: 文字数 %g は最大値を超えています。%g を使います。" + +#: builtin.c:1529 +#, c-format +msgid "substr: start index %g is invalid, using 1" +msgstr "substr: 開始インデックス %g が無効です。1を使用します" + +#: builtin.c:1534 +#, c-format +msgid "substr: non-integer start index %g will be truncated" +msgstr "substr: 開始インデックス %g が非整数のため、値は切り捨てられます" + +#: builtin.c:1559 +msgid "substr: source string is zero length" +msgstr "substr: 文字列の長さがゼロです。" + +#: builtin.c:1575 +#, c-format +msgid "substr: start index %g is past end of string" +msgstr "substr: 開始インデックス %g が文字列終端の後にあります" + +#: builtin.c:1583 +#, c-format +msgid "" +"substr: length %g at start index %g exceeds length of first argument (%lu)" +msgstr "" +"substr: 開始インデックス %2$g からの長さ %1$g は第一引数の長さを超えています " +"(%3$lu)" + +#: builtin.c:1657 +msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" +msgstr "strftime: PROCINFO[\"strftime\"] の書式の値は数値型です" + +#: builtin.c:1680 +msgid "strftime: received non-numeric second argument" +msgstr "strftime: 非数値の第二引数を受け取りました" + +#: builtin.c:1683 +msgid "strftime: second argument less than 0 or too big for time_t" +msgstr "" + +#: builtin.c:1690 +msgid "strftime: received non-string first argument" +msgstr "strftime: 非文字列の第一引数を受け取りました" + +#: builtin.c:1696 +msgid "strftime: received empty format string" +msgstr "strftime: 空の書式文字列を受け取りました" + +#: builtin.c:1762 +msgid "mktime: received non-string argument" +msgstr "mktime: 非文字列引数を受け取りました" + +#: builtin.c:1779 +msgid "mktime: at least one of the values is out of the default range" +msgstr "mktime: 一つ以上の値がデフォルトの範囲を超えています" + +#: builtin.c:1814 +msgid "'system' function not allowed in sandbox mode" +msgstr "サンドボックスモードでは 'system' 関数は許可されていません" + +#: builtin.c:1819 +msgid "system: received non-string argument" +msgstr "system: 文字列では無い引数を受け取りました" + +#: builtin.c:1874 eval.c:1159 eval.c:1790 eval.c:1803 +#, c-format +msgid "reference to uninitialized variable `%s'" +msgstr "初期化されていない変数 `%s' への参照です" + +#: builtin.c:1941 +#, c-format +msgid "reference to uninitialized field `$%d'" +msgstr "初期化されていないフィールド `$%d' への参照です" + +#: builtin.c:2028 +msgid "tolower: received non-string argument" +msgstr "tolower: 非文字列引数を受け取りました" + +#: builtin.c:2062 +msgid "toupper: received non-string argument" +msgstr "toupper: 非文字列引数を受け取りました" + +#: builtin.c:2098 +msgid "atan2: received non-numeric first argument" +msgstr "atan2: 非数値の第一引数を受け取りました" + +#: builtin.c:2100 +msgid "atan2: received non-numeric second argument" +msgstr "atan2: 非数値の第二引数を受け取りました" + +#: builtin.c:2119 +msgid "sin: received non-numeric argument" +msgstr "sin: 非数値の引数を受け取りました" + +#: builtin.c:2135 +msgid "cos: received non-numeric argument" +msgstr "cos: 非数値の引数を受け取りました" + +#: builtin.c:2188 +msgid "srand: received non-numeric argument" +msgstr "srand: 非数値の引数を受け取りました" + +#: builtin.c:2219 +msgid "match: third argument is not an array" +msgstr "match: 第三引数が配列ではありません" + +#: builtin.c:2483 +msgid "gensub: third argument of 0 treated as 1" +msgstr "gensub: 第三引数が 0 です。1 を代わりに使用します" + +#: builtin.c:2776 +msgid "lshift: received non-numeric first argument" +msgstr "lshift: 非数値の第一引数を受け取りました" + +#: builtin.c:2778 +msgid "lshift: received non-numeric second argument" +msgstr "lshift: 非数値の第二引数を受け取りました" + +#: builtin.c:2784 +#, c-format +msgid "lshift(%lf, %lf): negative values will give strange results" +msgstr "lshift(%lf, %lf): 負の数値を使用すると異常な結果になります" + +#: builtin.c:2786 +#, c-format +msgid "lshift(%lf, %lf): fractional values will be truncated" +msgstr "lshift(%lf, %lf): 小数点以下は切り捨てられます" + +#: builtin.c:2788 +#, c-format +msgid "lshift(%lf, %lf): too large shift value will give strange results" +msgstr "lshift(%lf, %lf): シフト値が大き過ぎると異常な結果になります" + +#: builtin.c:2813 +msgid "rshift: received non-numeric first argument" +msgstr "rshift: 非数値の第一引数を受け取りました" + +#: builtin.c:2815 +msgid "rshift: received non-numeric second argument" +msgstr "rshift: 非数値の第二引数を受け取りました" + +#: builtin.c:2821 +#, c-format +msgid "rshift(%lf, %lf): negative values will give strange results" +msgstr "rshift(%lf, %lf): 負の数値を使用すると異常な結果になります" + +#: builtin.c:2823 +#, c-format +msgid "rshift(%lf, %lf): fractional values will be truncated" +msgstr "rshift(%lf, %lf): 小数点以下は切り捨てられます" + +#: builtin.c:2825 +#, c-format +msgid "rshift(%lf, %lf): too large shift value will give strange results" +msgstr "rshift(%lf, %lf): シフト値が大き過ぎると異常な結果になります" + +#: builtin.c:2850 +msgid "and: received non-numeric first argument" +msgstr "and: 非数値の第一引数を受け取りました" + +#: builtin.c:2852 +msgid "and: received non-numeric second argument" +msgstr "and: 非数値の第二引数を受け取りました" + +#: builtin.c:2858 +#, c-format +msgid "and(%lf, %lf): negative values will give strange results" +msgstr "and(%lf, %lf): 負の数値を使用すると異常な結果になります" + +#: builtin.c:2860 +#, c-format +msgid "and(%lf, %lf): fractional values will be truncated" +msgstr "and(%lf, %lf): 小数点以下は切り捨てられます" + +#: builtin.c:2885 +msgid "or: received non-numeric first argument" +msgstr "or: 非数値の第一引数を受け取りました" + +#: builtin.c:2887 +msgid "or: received non-numeric second argument" +msgstr "or: 非数値の第二引数を受け取りました" + +#: builtin.c:2893 +#, c-format +msgid "or(%lf, %lf): negative values will give strange results" +msgstr "or(%lf, %lf): 負の数値を使用すると異常な結果になります" + +#: builtin.c:2895 +#, c-format +msgid "or(%lf, %lf): fractional values will be truncated" +msgstr "or(%lf, %lf): 小数点以下は切り捨てられます" + +#: builtin.c:2923 +msgid "xor: received non-numeric first argument" +msgstr "xor: 非数値の第一引数を受け取りました" + +#: builtin.c:2925 +msgid "xor: received non-numeric second argument" +msgstr "xor: 非数値の第二引数を受け取りました" + +#: builtin.c:2931 +#, c-format +msgid "xor(%lf, %lf): negative values will give strange results" +msgstr "xor(%lf, %lf): 負の数値を使用すると異常な結果になります" + +#: builtin.c:2933 +#, c-format +msgid "xor(%lf, %lf): fractional values will be truncated" +msgstr "xor(%lf, %lf): 小数点以下は切り捨てられます" + +#: builtin.c:2957 builtin.c:2963 +msgid "compl: received non-numeric argument" +msgstr "compl: 非数値の引数を受け取りました" + +#: builtin.c:2965 +#, c-format +msgid "compl(%lf): negative value will give strange results" +msgstr "compl(%lf): 負の数値を使用すると異常な結果になります" + +#: builtin.c:2967 +#, c-format +msgid "compl(%lf): fractional value will be truncated" +msgstr "compl(%lf): 小数点以下は切り捨てられます" + +#: builtin.c:3136 +#, c-format +msgid "dcgettext: `%s' is not a valid locale category" +msgstr "dcgettext: `%s' は無効なロケール区分です" + +#: eval.c:412 +#, c-format +msgid "unknown nodetype %d" +msgstr "不明なノード型 %d です" + +#: eval.c:423 eval.c:437 +#, c-format +msgid "unknown opcode %d" +msgstr "不明なオペコード %d です" + +#: eval.c:434 +#, c-format +msgid "opcode %s not an operator or keyword" +msgstr "オペコード %s は演算子または予約語ではありません" + +#: eval.c:488 +msgid "buffer overflow in genflags2str" +msgstr "genflags2str 内でバッファオーバーフローが発生しました" + +#: eval.c:698 +#, c-format +msgid "" +"\n" +"\t# Function Call Stack:\n" +"\n" +msgstr "" +"\n" +"\t# 呼出関数スタック:\n" +"\n" + +#: eval.c:725 +msgid "`IGNORECASE' is a gawk extension" +msgstr "`IGNORECASE' は gawk 拡張です" + +#: eval.c:754 +msgid "`BINMODE' is a gawk extension" +msgstr "`BINMODE' は gawk 拡張です" + +#: eval.c:812 +#, c-format +msgid "BINMODE value `%s' is invalid, treated as 3" +msgstr "BINMODE 値 `%s' は無効です。代わりに 3 を使用します" + +#: eval.c:902 +#, c-format +msgid "bad `%sFMT' specification `%s'" +msgstr "誤った `%sFMT' 指定 `%s' です" + +#: eval.c:980 +msgid "turning off `--lint' due to assignment to `LINT'" +msgstr "`LINT' への代入に従い `--lint' を無効にします" + +#: eval.c:1127 eval.c:1777 +#, c-format +msgid "can't use function name `%s' as variable or array" +msgstr "関数名 `%s' は変数または配列として使用出来ません" + +#: eval.c:1158 eval.c:1789 eval.c:1802 +#, c-format +msgid "reference to uninitialized argument `%s'" +msgstr "初期化されていない引数 `%s' への参照です" + +#: eval.c:1177 +msgid "attempt to field reference from non-numeric value" +msgstr "非数値を使用したフイールド参照の試みです" + +#: eval.c:1179 +msgid "attempt to field reference from null string" +msgstr "NULL 文字列を使用してフィールドの参照を試みています" + +#: eval.c:1185 +#, c-format +msgid "attempt to access field %ld" +msgstr "フィールド %ld へのアクセスの試みです" + +#: eval.c:1194 +#, c-format +msgid "reference to uninitialized field `$%ld'" +msgstr "初期化されていないフィールド `$%ld' への参照です" + +#: eval.c:1256 +#, c-format +msgid "function `%s' called with more arguments than declared" +msgstr "宣言されている数より多い引数を使って関数 `%s' を呼び出しました" + +#: eval.c:1437 +#, c-format +msgid "unwind_stack: unexpected type `%s'" +msgstr "unwind_stack: 予期しない型 `%s' です" + +#: eval.c:1532 +msgid "division by zero attempted in `/='" +msgstr "`/=' 内でゼロによる除算が行われました" + +#: eval.c:1539 +#, c-format +msgid "division by zero attempted in `%%='" +msgstr "`%%=' 内でゼロによる除算が行われました" + +#: eval.c:1876 eval.c:2122 +#, c-format +msgid "attempt to use array `%s[\"%.*s\"]' in a scalar context" +msgstr "スカラーコンテキスト内で配列 `%s[\"%.*s\"]' の使用の試みです" + +#: eval.c:1907 +msgid "assignment used in conditional context" +msgstr "条件コンテキスト内で代入が使用されました" + +#: eval.c:1911 +msgid "statement has no effect" +msgstr "文に効果がありません" + +#: eval.c:2343 +#, c-format +msgid "for loop: array `%s' changed size from %ld to %ld during loop execution" +msgstr "" +"for ループ: ループ実行中に配列 `%s' のサイズが %ld から %ld へ変更されました" + +#: eval.c:2458 +#, c-format +msgid "function called indirectly through `%s' does not exist" +msgstr "`%s' を通して間接的に呼び出された関数が存在しません" + +#: eval.c:2470 +#, c-format +msgid "function `%s' not defined" +msgstr "関数 `%s' は定義されていません" + +#: eval.c:2511 +#, c-format +msgid "non-redirected `getline' invalid inside `%s' rule" +msgstr "`%s' ルールの内側ではリダイレクトされていない `getline' は無効です" + +#: eval.c:2600 +#, c-format +msgid "error reading input file `%s': %s" +msgstr "入力ファイル `%s' を読み込み中にエラーが発生しました: %s" + +#: eval.c:2614 +#, c-format +msgid "`nextfile' cannot be called from a `%s' rule" +msgstr "`nextfile' は `%s' ルールから呼び出すことが出来ません" + +#: eval.c:2661 +#, fuzzy +msgid "`exit' cannot be called in the current context" +msgstr "`next' は `%s' から呼び出すことが出来ません" + +#: eval.c:2700 +#, c-format +msgid "`next' cannot be called from a `%s' rule" +msgstr "`next' は `%s' から呼び出すことが出来ません" + +#: eval.c:2766 +#, c-format +msgid "Sorry, don't know how to interpret `%s'" +msgstr "申し訳ありませんが `%s' をどのように解釈するか分かりません" + +#: ext.c:54 +msgid "extensions are not allowed in sandbox mode" +msgstr "サンドボックスモード内では拡張は許可されていません" + +#: ext.c:60 ext.c:65 +msgid "`extension' is a gawk extension" +msgstr "`extension' は gawk 拡張です" + +#: ext.c:75 +#, c-format +msgid "fatal: extension: cannot open `%s' (%s)\n" +msgstr "致命的: extension: `%s' を開くことが出来ません (%s)\n" + +#: ext.c:84 +#, c-format +msgid "" +"fatal: extension: library `%s': does not define " +"`plugin_is_GPL_compatible' (%s)\n" +msgstr "" +"致命的: extension: ライブラリ `%s': `plugin_is_GPL_compatible' が定義されてい" +"ません (%s)\n" + +#: ext.c:93 +#, c-format +msgid "fatal: extension: library `%s': cannot call function `%s' (%s)\n" +msgstr "" +"致命的: extension: ライブラリ `%s': 関数 `%s' を呼び出すことが出来ません " +"(%s)\n" + +#: ext.c:127 +msgid "extension: missing function name" +msgstr "extension: 関数名がありません" + +#: ext.c:132 +#, c-format +msgid "extension: illegal character `%c' in function name `%s'" +msgstr "extension: 関数名 `%2$s' の中で不正な文字 `%1$c' が使用されています" + +#: ext.c:141 +#, c-format +msgid "extension: can't redefine function `%s'" +msgstr "extension: 関数 `%s' を再定義できません" + +#: ext.c:145 +#, c-format +msgid "extension: function `%s' already defined" +msgstr "extension: 関数 `%s' は既に定義されています" + +#: ext.c:150 +#, c-format +msgid "extension: function name `%s' previously defined" +msgstr "extension: 関数名 `%s' は前に定義されています" + +#: ext.c:152 +#, c-format +msgid "extension: can't use gawk built-in `%s' as function name" +msgstr "extension: gawk に組み込まれている `%s' は関数名として使用出来ません" + +#: ext.c:156 +#, c-format +msgid "make_builtin: negative argument count for function `%s'" +msgstr "make_builtin: 関数 `%s' の引数の数が負です" + +#: ext.c:259 +#, c-format +msgid "function `%s' defined to take no more than %d argument(s)" +msgstr "関数 `%s' に使える引数の数は `%d' 以下と定義されています" + +#: ext.c:262 +#, c-format +msgid "function `%s': missing argument #%d" +msgstr "関数 `%s': 引数 #%d がありません" + +#: ext.c:279 +#, c-format +msgid "function `%s': argument #%d: attempt to use scalar as an array" +msgstr "関数 `%s': 引数 #%d: スカラーを配列として使用する試みです" + +#: ext.c:283 +#, c-format +msgid "function `%s': argument #%d: attempt to use array as a scalar" +msgstr "関数 `%s': 引数 #%d: 配列をスカラーとして使用する試みです" + +#: ext.c:296 +msgid "Operation Not Supported" +msgstr "この操作はサポートされていません" + +#: field.c:328 +msgid "NF set to negative value" +msgstr "NF が負の値に設定されています" + +#: field.c:951 field.c:958 field.c:962 +msgid "split: fourth argument is a gawk extension" +msgstr "split: 第四引数は gawk 拡張です" + +#: field.c:955 +msgid "split: fourth argument is not an array" +msgstr "split: 第四引数が配列ではありません" + +#: field.c:969 +msgid "split: second argument is not an array" +msgstr "split: 第二引数が配列ではありません" + +#: field.c:973 +msgid "split: cannot use the same array for second and fourth args" +msgstr "split: 第二引数と第四引数に同じ配列を使用することは出来ません" + +#: field.c:978 +msgid "split: cannot use a subarray of second arg for fourth arg" +msgstr "split: 第四引数に第二引数の部分配列を使用することは出来ません" + +#: field.c:981 +msgid "split: cannot use a subarray of fourth arg for second arg" +msgstr "split: 第二引数に第四引数の部分配列を使用することは出来ません" + +#: field.c:1010 +msgid "split: null string for third arg is a gawk extension" +msgstr "split: 第三引数に NULL 文字列を使用することは gawk 拡張です" + +#: field.c:1050 +msgid "patsplit: fourth argument is not an array" +msgstr "patsplit: 第四引数が配列ではありません" + +#: field.c:1055 +msgid "patsplit: second argument is not an array" +msgstr "patsplit: 第二引数が配列ではありません" + +#: field.c:1061 +msgid "patsplit: third argument must be non-null" +msgstr "patsplit: 第三引数は非 NULL でなければいけません" + +#: field.c:1065 +msgid "patsplit: cannot use the same array for second and fourth args" +msgstr "patsplit: 第二引数と第四引数に同じ配列を使用することは出来ません" + +#: field.c:1070 +msgid "patsplit: cannot use a subarray of second arg for fourth arg" +msgstr "patsplit: 第四引数に第二引数の部分配列を使用することは出来ません" + +#: field.c:1073 +msgid "patsplit: cannot use a subarray of fourth arg for second arg" +msgstr "patsplit: 第二引数に第四引数の部分配列を使用することは出来ません" + +#: field.c:1110 +msgid "`FIELDWIDTHS' is a gawk extension" +msgstr "`FIELDWIDTHS' は gawk 拡張です" + +#: field.c:1173 +#, c-format +msgid "invalid FIELDWIDTHS value, near `%s'" +msgstr "`%s' 付近の FIELDWIDTHS 値が無効です" + +#: field.c:1246 +msgid "null string for `FS' is a gawk extension" +msgstr "`FS' に NULL 文字列を使用するのは gawk 拡張です" + +#: field.c:1250 +msgid "old awk does not support regexps as value of `FS'" +msgstr "古い awk は `FS' の値として正規表現をサポートしません" + +#: field.c:1369 +msgid "`FPAT' is a gawk extension" +msgstr "`FPAT' は gawk 拡張です" + +#: getopt.c:604 getopt.c:633 +#, fuzzy, c-format +msgid "%s: option '%s' is ambiguous; possibilities:" +msgstr "%s: オプション '%s' は曖昧です\n" + +#: getopt.c:679 getopt.c:683 +#, c-format +msgid "%s: option '--%s' doesn't allow an argument\n" +msgstr "%s: オプション '--%s' は引数を取ることができません\n" + +#: getopt.c:692 getopt.c:697 +#, c-format +msgid "%s: option '%c%s' doesn't allow an argument\n" +msgstr "%s: オプション '%c%s' は引数を取ることができません\n" + +#: getopt.c:740 getopt.c:759 +#, c-format +msgid "%s: option '--%s' requires an argument\n" +msgstr "%s: オプション '--%s' には引数が必要です\n" + +#: getopt.c:797 getopt.c:800 +#, c-format +msgid "%s: unrecognized option '--%s'\n" +msgstr "%s: オプション '--%s' を認識できません\n" + +#: getopt.c:808 getopt.c:811 +#, c-format +msgid "%s: unrecognized option '%c%s'\n" +msgstr "%s: オプション '%c%s' を認識できません\n" + +#: getopt.c:860 getopt.c:863 +#, c-format +msgid "%s: invalid option -- '%c'\n" +msgstr "%s: 無効なオプション -- '%c'\n" + +#: getopt.c:916 getopt.c:933 getopt.c:1143 getopt.c:1161 +#, c-format +msgid "%s: option requires an argument -- '%c'\n" +msgstr "%s: オプションには引数が必要です -- '%c'\n" + +#: getopt.c:989 getopt.c:1005 +#, c-format +msgid "%s: option '-W %s' is ambiguous\n" +msgstr "%s: オプション '-W %s' は曖昧です\n" + +#: getopt.c:1029 getopt.c:1047 +#, c-format +msgid "%s: option '-W %s' doesn't allow an argument\n" +msgstr "%s: オプション '-W %s' は引数を取ることができません\n" + +#: getopt.c:1068 getopt.c:1086 +#, c-format +msgid "%s: option '-W %s' requires an argument\n" +msgstr "%s: オプション '-W %s' には引数が必要です\n" + +#: io.c:280 +#, c-format +msgid "command line argument `%s' is a directory: skipped" +msgstr "コマンドライン引数 `%s' はディレクトリです: スキップされました" + +#: io.c:283 io.c:385 +#, c-format +msgid "cannot open file `%s' for reading (%s)" +msgstr "ファイル `%s' を読み込み用に開けません (%s)" + +#: io.c:501 +#, c-format +msgid "close of fd %d (`%s') failed (%s)" +msgstr "fd %d (`%s') を閉じることができません (%s)" + +#: io.c:578 +msgid "redirection not allowed in sandbox mode" +msgstr "サンドボックスモード内ではリダイレクトは許可されていません" + +#: io.c:612 +#, c-format +msgid "expression in `%s' redirection only has numeric value" +msgstr "`%s' リダイレクトの命令式に数値しか記述されていません。" + +#: io.c:618 +#, c-format +msgid "expression for `%s' redirection has null string value" +msgstr "`%s' リダイレクトの命令式が空列です。" + +#: io.c:623 +#, c-format +msgid "filename `%s' for `%s' redirection may be result of logical expression" +msgstr "" +"`%2$s' リダイレクトに論理演算の結果と思われるファイル名 `%1$s' が使われていま" +"す。" + +#: io.c:666 +#, c-format +msgid "unnecessary mixing of `>' and `>>' for file `%.*s'" +msgstr "ファイル `%.*s' で必要以上に `>' と `>>' を組合せています。" + +#: io.c:719 +#, c-format +msgid "can't open pipe `%s' for output (%s)" +msgstr "出力用にパイプ `%s' を開けません (%s)" + +#: io.c:729 +#, c-format +msgid "can't open pipe `%s' for input (%s)" +msgstr "入力用にパイプ `%s' を開けません (%s)" + +#: io.c:752 +#, c-format +msgid "can't open two way pipe `%s' for input/output (%s)" +msgstr "入出力用の双方向パイプ `%s' が開けません (%s)" + +#: io.c:834 +#, c-format +msgid "can't redirect from `%s' (%s)" +msgstr "`%s' からリダイレクトできません (%s)" + +#: io.c:837 +#, c-format +msgid "can't redirect to `%s' (%s)" +msgstr "`%s' にリダイレクトできません (%s)" + +#: io.c:888 +msgid "" +"reached system limit for open files: starting to multiplex file descriptors" +msgstr "" +"開いているファイルの数がシステム制限に達しました。ファイル記述子を多重化しま" +"す。" + +#: io.c:904 +#, c-format +msgid "close of `%s' failed (%s)." +msgstr "`%s' を閉じるのに失敗しました (%s)" + +#: io.c:912 +msgid "too many pipes or input files open" +msgstr "開いているパイプまたは入力ファイルの数が多過ぎます。" + +#: io.c:934 +msgid "close: second argument must be `to' or `from'" +msgstr "close: 第二引数は `to' または `from' でなければいけません" + +#: io.c:951 +#, c-format +msgid "close: `%.*s' is not an open file, pipe or co-process" +msgstr "close: `%.*s' は開いているファイル、パイプ、プロセス共有ではありません" + +#: io.c:956 +msgid "close of redirection that was never opened" +msgstr "開いてないリダイレクトを閉じようとしています" + +#: io.c:1053 +#, c-format +msgid "close: redirection `%s' not opened with `|&', second argument ignored" +msgstr "" +"close: リダイレクト `%s' は `|&' を使用して開かれていません。第二引数は無視さ" +"れました" + +#: io.c:1069 +#, c-format +msgid "failure status (%d) on pipe close of `%s' (%s)" +msgstr "パイプ `%2$s' を閉じたときの状態コードが失敗 (%1$d) でした (%3$s)。" + +#: io.c:1072 +#, c-format +msgid "failure status (%d) on file close of `%s' (%s)" +msgstr "ファイル `%2$s' を閉じたときの状態コードが失敗 (%1$d) でした (%3$s)。" + +#: io.c:1092 +#, c-format +msgid "no explicit close of socket `%s' provided" +msgstr "ソケット `%s' を明示して閉じていません。" + +#: io.c:1095 +#, c-format +msgid "no explicit close of co-process `%s' provided" +msgstr "並行プロセス `%s' を明示して閉じていません。" + +#: io.c:1098 +#, c-format +msgid "no explicit close of pipe `%s' provided" +msgstr "パイプ `%s' を明示して閉じていません。" + +#: io.c:1101 +#, c-format +msgid "no explicit close of file `%s' provided" +msgstr "ファイル `%s' を明示して閉じていません。" + +#: io.c:1129 io.c:1184 main.c:794 main.c:831 +#, c-format +msgid "error writing standard output (%s)" +msgstr "標準出力への書込みエラー (%s)" + +#: io.c:1133 io.c:1189 +#, c-format +msgid "error writing standard error (%s)" +msgstr "標準エラーへの書込みエラー (%s)" + +#: io.c:1141 +#, c-format +msgid "pipe flush of `%s' failed (%s)." +msgstr "パイプ `%s' をフラッシュできません (%s)。" + +#: io.c:1144 +#, c-format +msgid "co-process flush of pipe to `%s' failed (%s)." +msgstr "`%s' へ接続するパイプを並行プロセスからフラッシュできません (%s)。" + +#: io.c:1147 +#, c-format +msgid "file flush of `%s' failed (%s)." +msgstr "ファイル `%s' をフラッシュできません (%s)。" + +#: io.c:1262 +#, c-format +msgid "local port %s invalid in `/inet'" +msgstr "`/inet' 内のローカルポート %s が無効です" + +#: io.c:1279 +#, c-format +msgid "remote host and port information (%s, %s) invalid" +msgstr "リモートのホストおよびポート情報 (%s, %s) が無効です" + +#: io.c:1431 +#, c-format +msgid "no (known) protocol supplied in special filename `%s'" +msgstr "" +"スペシャルファイル名 `%s' に(認識できる)プロトコルが指定されていません" + +#: io.c:1445 +#, c-format +msgid "special file name `%s' is incomplete" +msgstr "スペシャルファイル名 `%s' は不完全です" + +#: io.c:1462 +msgid "must supply a remote hostname to `/inet'" +msgstr "`/inet' にはリモートホスト名を与えなければいけません" + +#: io.c:1480 +msgid "must supply a remote port to `/inet'" +msgstr "`/inet' にはリモートポート番号を与えなければいけません" + +#: io.c:1526 +msgid "TCP/IP communications are not supported" +msgstr "TCP/IP 通信はサポートされていません" + +#: io.c:1693 +#, c-format +msgid "could not open `%s', mode `%s'" +msgstr "`%s' をモード `%s' で開けません" + +#: io.c:1747 +#, c-format +msgid "close of master pty failed (%s)" +msgstr "マスター pty を閉じるのに失敗しました (%s)" + +#: io.c:1749 io.c:1917 io.c:2074 +#, c-format +msgid "close of stdout in child failed (%s)" +msgstr "子プロセスが標準出力を閉じるのに失敗しました (%s)" + +#: io.c:1752 +#, c-format +msgid "moving slave pty to stdout in child failed (dup: %s)" +msgstr "子プロセスがスレーブ pty を標準出力に移動できません (dup: %s)。" + +#: io.c:1754 io.c:1922 +#, c-format +msgid "close of stdin in child failed (%s)" +msgstr "子プロセスが標準入力を閉じられません (%s)。" + +#: io.c:1757 +#, c-format +msgid "moving slave pty to stdin in child failed (dup: %s)" +msgstr "子プロセスがスレーブ pty を標準入力に移動できません (dup: %s)。" + +#: io.c:1759 io.c:1780 +#, c-format +msgid "close of slave pty failed (%s)" +msgstr "スレーブ pty を閉じるのに失敗しました (%s)" + +#: io.c:1858 io.c:1920 io.c:2052 io.c:2077 +#, c-format +msgid "moving pipe to stdout in child failed (dup: %s)" +msgstr "子プロセスがパイプを標準出力に移動できません (dup: %s)。" + +#: io.c:1865 io.c:1925 +#, c-format +msgid "moving pipe to stdin in child failed (dup: %s)" +msgstr "子プロセスがパイプを標準入力に移動できません (dup: %s)。" + +#: io.c:1885 io.c:2067 +msgid "restoring stdout in parent process failed\n" +msgstr "親プロセスが標準出力を復旧できません。\n" + +#: io.c:1893 +msgid "restoring stdin in parent process failed\n" +msgstr "親プロセスが標準入力を復旧できません。\n" + +#: io.c:1928 io.c:2079 io.c:2093 +#, c-format +msgid "close of pipe failed (%s)" +msgstr "パイプを閉じられません (%s)。" + +#: io.c:1973 +msgid "`|&' not supported" +msgstr "`|&' は使用できません。" + +#: io.c:2039 +#, c-format +msgid "cannot open pipe `%s' (%s)" +msgstr "パイプ `%s' が開けません (%s)。" + +#: io.c:2087 +#, c-format +msgid "cannot create child process for `%s' (fork: %s)" +msgstr "`%s' 用の子プロセスを実行できません (fork: %s)。" + +#: io.c:2520 +#, c-format +msgid "data file `%s' is empty" +msgstr "データファイル `%s' は空です。" + +#: io.c:2561 io.c:2569 +msgid "could not allocate more input memory" +msgstr "入力用メモリーをこれ以上確保できません。" + +#: io.c:3127 +msgid "multicharacter value of `RS' is a gawk extension" +msgstr "複数の文字を `RS' に使用するのは gawk 特有の拡張です。" + +#: io.c:3232 +msgid "IPv6 communication is not supported" +msgstr "IPv6 通信はサポートされていません" + +#: main.c:366 +msgid "`-m[fr]' option irrelevant in gawk" +msgstr "gawk ではオプション `-m[fr]' に効果はありません。" + +#: main.c:368 +msgid "-m option usage: `-m[fr] nnn'" +msgstr "-m オプションの使用法: `-m[fr] 数値'" + +#: main.c:391 +msgid "empty argument to `-e/--source' ignored" +msgstr "`-e/--source' への空の引数は無視されました" + +#: main.c:462 +#, c-format +msgid "%s: option `-W %s' unrecognized, ignored\n" +msgstr "%s: オプション `-W %s' は認識できません。無視されました\n" + +#: main.c:515 +#, c-format +msgid "%s: option requires an argument -- %c\n" +msgstr "%s: 引数が必要なオプション -- %c\n" + +#: main.c:536 +msgid "environment variable `POSIXLY_CORRECT' set: turning on `--posix'" +msgstr "" +"環境変数 `POSIXLY_CORRECT' が指定されています。オプション `--posix' を有効に" +"します" + +#: main.c:542 +msgid "`--posix' overrides `--traditional'" +msgstr "オプション `--posix' は `--traditional' を無効にします。" + +#: main.c:553 +msgid "`--posix'/`--traditional' overrides `--non-decimal-data'" +msgstr "" +"オプション `--posix'/`--traditional' は `--non-decimal-data' を無効にします。" + +#: main.c:557 +#, c-format +msgid "running %s setuid root may be a security problem" +msgstr "" +"setuid root で %s を実行すると、セキュリティ上の問題が発生する場合がありま" +"す。" + +#: main.c:562 +msgid "`--posix' overrides `--binary'" +msgstr "`--posix' は `--binary' を上書きします" + +#: main.c:613 +#, c-format +msgid "can't set binary mode on stdin (%s)" +msgstr "標準入力をバイナリモードに設定できません (%s)" + +#: main.c:616 +#, c-format +msgid "can't set binary mode on stdout (%s)" +msgstr "標準出力をバイナリモードに設定できません (%s)" + +#: main.c:618 +#, c-format +msgid "can't set binary mode on stderr (%s)" +msgstr "標準エラーをバイナリモードに設定できません (%s)" + +#: main.c:657 +msgid "no program text at all!" +msgstr "プログラム文が全くありません!" + +#: main.c:734 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] -f progfile [--] file ...\n" +msgstr "" +"使用法: %s [POSIX または GNU 形式のオプション] -f progfile [--] file ...\n" + +#: main.c:736 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] [--] %cprogram%c file ...\n" +msgstr "" +"使用法: %s [POSIX または GNU 形式のオプション] [--] %cprogram%c file ...\n" + +#: main.c:741 +msgid "POSIX options:\t\tGNU long options: (standard)\n" +msgstr "POSIX オプション:\t\tGNU 長い形式のオプション: (標準)\n" + +#: main.c:742 +msgid "\t-f progfile\t\t--file=progfile\n" +msgstr "\t-f progfile\t\t--file=progfile\n" + +#: main.c:743 +msgid "\t-F fs\t\t\t--field-separator=fs\n" +msgstr "\t-F fs\t\t\t--field-separator=fs\n" + +#: main.c:744 +msgid "\t-v var=val\t\t--assign=var=val\n" +msgstr "\t-v var=val\t\t--assign=var=val\n" + +#: main.c:745 +msgid "Short options:\t\tGNU long options: (extensions)\n" +msgstr "短いオプション:\t\tGNU 長い形式のオプション: (拡張)\n" + +#: main.c:746 +msgid "\t-b\t\t\t--characters-as-bytes\n" +msgstr "\t-b\t\t\t--characters-as-bytes\n" + +#: main.c:747 +msgid "\t-c\t\t\t--traditional\n" +msgstr "\t-c\t\t\t--traditional\n" + +#: main.c:748 +msgid "\t-C\t\t\t--copyright\n" +msgstr "\t-C\t\t\t--copyright\n" + +#: main.c:749 +msgid "\t-d[file]\t\t--dump-variables[=file]\n" +msgstr "\t-d[file]\t\t--dump-variables[=file]\n" + +#: main.c:750 +msgid "\t-e 'program-text'\t--source='program-text'\n" +msgstr "\t-e 'program-text'\t--source='program-text'\n" + +#: main.c:751 +msgid "\t-E file\t\t\t--exec=file\n" +msgstr "\t-E file\t\t\t--exec=file\n" + +#: main.c:752 +msgid "\t-g\t\t\t--gen-pot\n" +msgstr "\t-g\t\t\t--gen-pot\n" + +#: main.c:753 +msgid "\t-h\t\t\t--help\n" +msgstr "\t-h\t\t\t--help\n" + +#: main.c:754 +msgid "\t-L [fatal]\t\t--lint[=fatal]\n" +msgstr "\t-L [fatal]\t\t--lint[=fatal]\n" + +#: main.c:755 +msgid "\t-n\t\t\t--non-decimal-data\n" +msgstr "\t-n\t\t\t--non-decimal-data\n" + +#: main.c:756 +msgid "\t-N\t\t\t--use-lc-numeric\n" +msgstr "\t-N\t\t\t--use-lc-numeric\n" + +#: main.c:757 +msgid "\t-O\t\t\t--optimize\n" +msgstr "\t-O\t\t\t--optimize\n" + +#: main.c:758 +msgid "\t-p[file]\t\t--profile[=file]\n" +msgstr "\t-p[file]\t\t--profile[=file]\n" + +#: main.c:759 +msgid "\t-P\t\t\t--posix\n" +msgstr "\t-P\t\t\t--posix\n" + +#: main.c:760 +msgid "\t-r\t\t\t--re-interval\n" +msgstr "\t-r\t\t\t--re-interval\n" + +#: main.c:762 +msgid "\t-R file\t\t\t--command=file\n" +msgstr "\t-R file\t\t\t--command=file\n" + +#: main.c:763 +msgid "\t-S\t\t\t--sandbox\n" +msgstr "\t-S\t\t\t--sandbox\n" + +#: main.c:764 +msgid "\t-t\t\t\t--lint-old\n" +msgstr "\t-t\t\t\t--lint-old\n" + +#: main.c:765 +msgid "\t-V\t\t\t--version\n" +msgstr "\t-V\t\t\t--version\n" + +#: main.c:767 +msgid "\t-W nostalgia\t\t--nostalgia\n" +msgstr "\t-W nostalgia\t\t--nostalgia\n" + +#: main.c:770 +msgid "\t-Y\t\t--parsedebug\n" +msgstr "\t-Y\t\t--parsedebug\n" + +#. TRANSLATORS: --help output 5 (end) +#. TRANSLATORS: the placeholder indicates the bug-reporting address +#. for this application. Please add _another line_ with the +#. address for translation bugs. +#. no-wrap +#: main.c:779 +msgid "" +"\n" +"To report bugs, see node `Bugs' in `gawk.info', which is\n" +"section `Reporting Problems and Bugs' in the printed version.\n" +"\n" +msgstr "" +"\n" +"バグを報告するには、`gawk.info(英文)' の `Bugs' ノードを\n" +"参照してください。 印刷されたマニュアルで対応するセクション\n" +"は、`Reporting Problems and Bugs' です。\n" +"\n" +"翻訳に関するバグはに報告してくださ" +"い。\n" + +#: main.c:783 +msgid "" +"gawk is a pattern scanning and processing language.\n" +"By default it reads standard input and writes standard output.\n" +"\n" +msgstr "" +"gawk は、パターンを検索をして、それを処理する言語です。\n" +"デフォルト設定では、標準入力を読み込み、標準出力に書き出します。\n" +"\n" + +#: main.c:787 +msgid "" +"Examples:\n" +"\tgawk '{ sum += $1 }; END { print sum }' file\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" +msgstr "" +"使用例:\n" +"\tgawk '{ sum += $1 }; END { print sum }' file\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" + +#: main.c:807 +#, c-format +msgid "" +"Copyright (C) 1989, 1991-%d Free Software Foundation.\n" +"\n" +"This program is free software; you can redistribute it and/or modify\n" +"it under the terms of the GNU General Public License as published by\n" +"the Free Software Foundation; either version 3 of the License, or\n" +"(at your option) any later version.\n" +"\n" +msgstr "" +"Copyright (C) 1989, 1991-%d Free Software Foundation.\n" +"\n" +"This program is free software; you can redistribute it and/or modify\n" +"it under the terms of the GNU General Public License as published by\n" +"the Free Software Foundation; either version 3 of the License, or\n" +"(at your option) any later version.\n" +"\n" + +#: main.c:815 +msgid "" +"This program is distributed in the hope that it will be useful,\n" +"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +"GNU General Public License for more details.\n" +"\n" +msgstr "" +"This program is distributed in the hope that it will be useful,\n" +"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +"GNU General Public License for more details.\n" +"\n" + +#: main.c:821 +msgid "" +"You should have received a copy of the GNU General Public License\n" +"along with this program. If not, see http://www.gnu.org/licenses/.\n" +msgstr "" +"You should have received a copy of the GNU General Public License\n" +"along with this program. If not, see http://www.gnu.org/licenses/.\n" + +#: main.c:856 +msgid "-Ft does not set FS to tab in POSIX awk" +msgstr "POSIX awk では -Ft は FS をタブに設定しません" + +#: main.c:1090 +#, c-format +msgid "unknown value for field spec: %d\n" +msgstr "フィールド指定に不明な値があります: %d\n" + +#: main.c:1171 +#, c-format +msgid "" +"%s: `%s' argument to `-v' not in `var=value' form\n" +"\n" +msgstr "" +"%s: オプション `-v' の引数 `%s' が `変数=代入値' の形式になっていません。\n" +"\n" + +#: main.c:1197 +#, c-format +msgid "`%s' is not a legal variable name" +msgstr "`%s' は不正な変数名です" + +#: main.c:1200 +#, c-format +msgid "`%s' is not a variable name, looking for file `%s=%s'" +msgstr "`%s' は変数名ではありません。`%s=%s' のファイルを探します。" + +#: main.c:1204 +#, c-format +msgid "cannot use gawk builtin `%s' as variable name" +msgstr "gawk に組み込みの `%s' は変数名として使用出来ません" + +#: main.c:1209 +#, c-format +msgid "cannot use function `%s' as variable name" +msgstr "関数 `%s' は変数名として使用出来ません" + +#: main.c:1262 +msgid "floating point exception" +msgstr "浮動小数点例外" + +#: main.c:1269 +msgid "fatal error: internal error" +msgstr "致命的エラー: 内部エラー" + +#: main.c:1284 +msgid "fatal error: internal error: segfault" +msgstr "致命的エラー: 内部エラー: セグメンテーション違反" + +#: main.c:1296 +msgid "fatal error: internal error: stack overflow" +msgstr "致命的エラー: 内部エラー: スタックオーバーフロー" + +#: main.c:1346 +#, c-format +msgid "no pre-opened fd %d" +msgstr "fd %d が事前に開いていません。" + +#: main.c:1353 +#, c-format +msgid "could not pre-open /dev/null for fd %d" +msgstr "事前に fd %d 用に /dev/null を開けません。" + +#: msg.c:63 +#, c-format +msgid "cmd. line:" +msgstr "コマンドライン:" + +#: msg.c:107 +msgid "error: " +msgstr "エラー: " + +#: node.c:406 +msgid "backslash at end of string" +msgstr "文字列の終りにバックスラッシュが使われています。" + +#: node.c:517 +#, c-format +msgid "old awk does not support the `\\%c' escape sequence" +msgstr "古い awk は `\\%c' エスケープシーケンスをサポートしません" + +#: node.c:568 +msgid "POSIX does not allow `\\x' escapes" +msgstr "POSIX では `\\x' エスケープは許可されていません" + +#: node.c:574 +msgid "no hex digits in `\\x' escape sequence" +msgstr "`\\x' エスケープシーケンスに十六進数がありません" + +#: node.c:596 +#, c-format +msgid "" +"hex escape \\x%.*s of %d characters probably not interpreted the way you " +"expect" +msgstr "" +"十六進エスケープ \\x%.*s (%d 文字) はおそらく予期したようには解釈されないで" +"しょう" + +#: node.c:611 +#, c-format +msgid "escape sequence `\\%c' treated as plain `%c'" +msgstr "エスケープシーケンス `\\%c' は `%c' と同等に扱われます" + +#: node.c:750 +msgid "" +"Invalid multibyte data detected. There may be a mismatch between your data " +"and your locale." +msgstr "" +"無効なマルチバイトデータが検出されました。データとロケールが一致していないよ" +"うです。" + +#: posix/gawkmisc.c:176 +#, c-format +msgid "%s %s `%s': could not get fd flags: (fcntl F_GETFD: %s)" +msgstr "%s %s `%s': fd フラグを取得できません: (fcntl F_GETFD: %s)" + +#: posix/gawkmisc.c:188 +#, c-format +msgid "%s %s `%s': could not set close-on-exec: (fcntl F_SETFD: %s)" +msgstr "%s %s `%s': close-on-exec を設定できません: (fcntl F_SETFD: %s)" + +#: profile.c:83 +#, c-format +msgid "could not open `%s' for writing: %s" +msgstr "`%s' を書込み用に開けませんでした: %s" + +#: profile.c:85 +msgid "sending profile to standard error" +msgstr "プロファイルを標準エラーに送っています" + +#: profile.c:203 +#, c-format +msgid "" +"\t# %s block(s)\n" +"\n" +msgstr "" +"\t# %s ブロック\n" +"\n" + +#: profile.c:208 +#, c-format +msgid "" +"\t# Rule(s)\n" +"\n" +msgstr "" +"\t# ルール\n" +"\n" + +#: profile.c:279 +#, c-format +msgid "internal error: %s with null vname" +msgstr "内部エラー: %s の vname が無効です。" + +#: profile.c:952 +#, c-format +msgid "\t# gawk profile, created %s\n" +msgstr "\t# gawk プロファイル、作成日時 %s\n" + +#: profile.c:1331 +#, c-format +msgid "" +"\n" +"\t# Functions, listed alphabetically\n" +msgstr "" +"\n" +"\t# 関数一覧(アルファベット順)\n" + +#: profile.c:1370 +#, c-format +msgid "redir2str: unknown redirection type %d" +msgstr "redir2str: 不明なリダイレクト型 %d です" + +#: re.c:573 +#, fuzzy, c-format +msgid "range of the form `[%c-%c]' is locale dependent" +msgstr "`[%c-%c]' 形式の範囲はロケール依存です" + +#: re.c:600 +#, c-format +msgid "regexp component `%.*s' should probably be `[%.*s]'" +msgstr "正規表現の要素 `%.*s' はおそらく `[%.*s]' であるべきです" + +#: regcomp.c:131 +msgid "Success" +msgstr "成功です" + +#: regcomp.c:134 +msgid "No match" +msgstr "一致しません" + +#: regcomp.c:137 +msgid "Invalid regular expression" +msgstr "無効な正規表現です" + +#: regcomp.c:140 +msgid "Invalid collation character" +msgstr "無効な照合文字です" + +#: regcomp.c:143 +msgid "Invalid character class name" +msgstr "無効な文字クラス名です" + +#: regcomp.c:146 +msgid "Trailing backslash" +msgstr "終端のバックスラッシュ" + +#: regcomp.c:149 +msgid "Invalid back reference" +msgstr "無効な前方参照です" + +#: regcomp.c:152 +msgid "Unmatched [ or [^" +msgstr "[ または [^ が不一致です" + +#: regcomp.c:155 +msgid "Unmatched ( or \\(" +msgstr "( または \\( が不一致です" + +#: regcomp.c:158 +msgid "Unmatched \\{" +msgstr "\\{ が不一致です" + +#: regcomp.c:161 +msgid "Invalid content of \\{\\}" +msgstr "\\{\\} の中身が無効です" + +#: regcomp.c:164 +msgid "Invalid range end" +msgstr "無効な範囲終了です" + +#: regcomp.c:167 +msgid "Memory exhausted" +msgstr "メモリを使い果たしました" + +#: regcomp.c:170 +msgid "Invalid preceding regular expression" +msgstr "無効な前方正規表現です" + +#: regcomp.c:173 +msgid "Premature end of regular expression" +msgstr "正規表現が途中で終了しました" + +#: regcomp.c:176 +msgid "Regular expression too big" +msgstr "正規表現が大きすぎます" + +#: regcomp.c:179 +msgid "Unmatched ) or \\)" +msgstr ") または \\) が不一致です" + +#: regcomp.c:700 +msgid "No previous regular expression" +msgstr "以前に正規表現がありません" + +#~ msgid "could not find groups: %s" +#~ msgstr "グループが見つかりません: %s" + +#~ msgid "assignment is not allowed to result of builtin function" +#~ msgstr "組込関数の戻り値への代入は許可されていません" diff --git a/po/nl.gmo b/po/nl.gmo new file mode 100644 index 0000000000000000000000000000000000000000..00f34760b9746516b63e3e43906136ec09da34ec GIT binary patch literal 49531 zcmcJY2b^42b^jmLcmp=gxZ`Kp>siSfH5craWz<%(uq-K(TqRpOyYqH;w6inI6crbW zF$5gCffy4A&44kT&`Sc2lYk+Okbg)6LQNo$kdXWX0si0Lx%a;JW_D(G1^MsC&%b%^ zo!ien=iGDeJNkzwKJwKOe;kp5jPoA!){0&CY2`#so22V+;4dNF{pMP zx6D012VBnmMIOgMst~;lR5>33WAIxbMMsaOa%2&$1Ziq?J*el;0acItK(*(a;91}R znG2VJ%I_JV@;?He3BD0jKYtn|N%Xhi5WH|4#5Z!kYK80fmx5~V2SCw(4pck74Ql)! zzA}pTfv17zf`>r0`*ooD`Q4z#>5suvz^{Oh0e=K)Jbnr)pVL;k@mm9)&HZ*z{ayn# z{;vSljt}|!Z-C1GxYhItxCB)Dc7w-(H~ahB!S8YZPEh>ynl-L|_j&w;$1j49<^5N| z4dC}Zu3&JV&;2ZT3HYDjMc~Q{UB4ut`tw#$d~gq_cK!*d`hN#hdj?3Pbj$f)432?n z|MNh#@6Dj{|3gseegP`qB^SH&>p``542;3sKv*Ms1E}_Y4irE9H>mVWU}Cx`8UY!q z=nyD=xEB=vJP3;J`=G}2L<(1a=X<;cRK1=HD&Kp-Q@}p~VU_4Rpz8nROC4Wa04m>I z;1j{a{`sAt+W&TtE{#41k~I1sQ2Aa2^NO!;0`>fb9zO%Bem?|2!!A{{+QXXRdSOb0w&HJr~sbcY^A_ zKL^#H(dBL&R)Z>cJE(qmCaC^>ImnPl?*qv?`WC2qE_u46-vX-tra|?`-QZc^L*SX< z_dwP6`1Ou{5LEhS`1=~DcH9MO+#dv0&mV)QfoE)R{rNOd?J9wK{xa}v@SUK_`vQ0> z_%jr;YySQysCK;_RKNWVsQx&9 zv&-*ta0&P0{{96X?+4G}`JaJL1^)w7yPia$CxgSF^4krb3qBWAyWR#Wzt4b5|4o1Y zm@RJn&j&T0*MjP==YWzE?*rA}e+?@Ae}e15Q@6T)y20bEpx(a$JP!N}D8Bj}7=u3s z_5LYWxPH3SV;wB;{9aIe{Y7vHeDpTQM=L?5UNj2E;N775^<$vg`Av^cdWPeNjo={9 zZvs{R9pG```@m)3M?tmk8=&~~Nmn}D?6D2frP13!_Yb?;jqiD&_++ccgWyHnzXU{NMGt^X#poB{`QV0YT)8u#_~af?_4*4?c5eHmFc?k-UEZG+19jsE!;LG}NSz^8(P z2OYm}1~o4Zg6gNc{qs+N>esJ>YS$B|-MqLMd;<5+0M+07LFM}_|Ni};@_7(c`tSPZ zr&itbBB=4+1+E8g2Q{t_fEt%a&7f1kvq0s$6x96M4-SE^2A6`L2H*WK@&{F)*VNs5 z=^fx%+2C$a|1Sk&@b%#1!B2bqQ&9PQ4U~NN znZJL+Gu?bz0jge`z?I+(SOi}WJ|27sd>r_9pxXJ*p!(^N4VS(EK7sqoz(H^acqZ5a z)&H*qKMQ^sTn-*>I{E%Ka1-}G2Gu{8wp{sRpz8Zd@G|hd;5zX8pz>YTcKY`U@I>y* z9$TQ&-2t8iz6n&jKH~A~p!oCG4mmzs1B%~o1PkEppy=NTsvUpnpZ^5h!u^uN?tKM3 zo%_2yz8AcZ`-ec~A02V+DS+yyUEsxF6I{o*zY`qi{<}vV-S(SZzqUQT3{?L2`TGY! zL}c_;a2dGn7T51np!(xBFa}=-s=q%8YMj63pZ^D_emUt@SI!zxblXAIZ`R-61*#n% z0W}`q2gQ#k-RAiCBJgzXYv7~7J3-aw72prRPl8VY?|+u#-_Lsdvd8a&;-jB}Yr*56 z?QjJA2=~tgSAmy4$Jw<9!IQavAEH z1vSpU0EfYIZ+G_xz_Yo(1JroG4SXv21^@ngpyt8jpXcV^<)HZYHc<6>CwLk7=b*|x z;SSfYTS3jEY4CjTb)fj`k3i-3Lyu=Z-#xz)RKGVt)#n|c^7}lv1boB`T>Z`im3}*@ zakv>g6MPMLF8I6P8t^Ni`0cU3;nHvNI00VA^A~yiM^Ne3zR=+)cs=*e_xM$Cko!wt zI+qJGdIWAG{R&dre{spRKGnN)bkI67l8i;7Qw-nIsVuKsyz)*D)Ht+3y}ut+J^vOI zKb&}%8;>HmocnE{#^VsEdb|-7UwsY~-+doE1w8vzu3p2S#-{)D{%`)*ME|3z>F{E>fu$!lEs6W}VIzYcsf_ythy`Vy#o zAMsnRJ!`&HRxY25DymG7M%KjraXLDl1&*ST^kpy*x??gak~ya9}V z+tJ+uZsPtkpxXba*SmUO3|`HB72FMe7TgS;^ajT#H-KvAE5K{PPl8VcpZq&cuU-JE zA8!ZOf-eHsfe(TQ!AHC?iZ+5Z@JjIgpyt=l!1dr+Z*n*aUe5iSz^lNof#Qo5Z+7|a z_4sn|LY{vCRJ|Vd7S=rAa!~F6AUFno8{7tNd#lUmE{`7rmHw;X>EM&^b^X5z6d&ye zWAIM!RPcWAOz=VQEbtrPdEg`7=JdicQ2A^HF9OHGOTpKI>%lL9gW!|j?r<0!=6)1Z zd9MS{0Y3+B1pft8Iji2`>c0zo2KV=XJHT&&8s7`=bM3eTR6ZXA3*dLabHNke>FnPN z!Hc4ghH_0w&j`2SO&`tPTp=q~;g^#}g_zk}k-Q$OPJy9hjm`)PlF z2ROw2$HD8sZ+N`yqwfCIpz`|xsPQ`UW3F8rLES$G6rbD+o&i4K@4p5P|GT~K`g761GZpLYFzE~w`>fhU141fK-H0o3?? z09*zB0~muR{+=7>RiOBP92EWAK$Y`x@G|hL;5zV(-*@uv25<@YuLZ@2p9IA(4}lkh zKL_>xqR%+I4tyB*`g>vc;clZxaleV{IPPD>^=SY8P>$|Ip8pZo#kprs=l5UmOzr)9 zF8x)x-oo=|a8`EfakDRv;>kXK|Ide+@Vaz7o8e z>kh7`aIN6kIQSayG!U_3f2VLi!LP@Gzr&?Jt#|de4EzBod9A;na=ngcYr*AQ7jy07 zI>;6N&gcDaaD9^pmxJ%%(q9`~=YHD%U+RDF0pGxNAJ;k1jC1{qfA>~?ALTm4{q_Et z;0CTSu4i&d_961k_tJz`e>Zu2KEL1Sf8PPVmirm5zvDW~KYt4N3a+(WWuET@-@_%@ z`$4W}@%w(RW&GaDbtl&}*Xdl7JiicJ32p*E$Mr(45$+Fw`rE_r^SJhN>F;}7XK+b2 z>2I3nv*2%YeV6NPT-SM8ex`pL{jcBjcr!G=;P+KrzwYUu&hP)^`T*D6T>5)yF0Tf^ zAIr0gz)yj{&o#jHA?{xSZs0nB-?wu;#P8n*F94@N{ap*bi|ZDD|63j}^C%k0*rmDq z_vs;jU*UQp&o8n&_rHUl?jHZ_mE7OPmH6j%p6}!Le}h{*&2NE^@V^D8@%~!y7XR!z z@L@jvo51&Tznbfxxn9Qgk6hPq-NmK9k9pch^ZQX;L)^dGKYJJVSMmE9;Agn>cOF;S zzt{a;{N4|)*A0J{aBby!AJ5;w^{0Bs-}CwX1g=}T9>e`+P=6l=-vmAn{9}894dUOO z%l!xZ@8^PF83^?$g!|4t;2 zOSx|MFJ8{?8@Mjxe$qetGI%!6uHe$&B_5v)j&lFEdg%W?V<0#D+)jcbPccYyjkp5N~VcX7Rw-@gIw0G|eao$KxVzLIM_ zSNMB7Kc2_6J@@QK~YI1#*D?0w1c(56dRqNx^L(QcF1A4H#T}{%P$GVk=|m-|mW$0~w$v!K>Wy_1 zmecll-$bcZs@|v!tCd=7-#T}%v^y+eyO|WLuKOrKC!wH+pxy zp3s73QclL&lX^5}>BpyN)_99tilt_8>}V^o=8fCSR-;s|w8*|xRf_UHb&j>T+@6^& z9x62|rLk(#r0seknj|jJ_mhp%OtF<5X%#58S#LMSlXacXMLVHknsnV?EDG0!2YNke zb(lDy4#XhYLoGWLmY#rIVW%Dozmi9^4B;9zm&ZJ<-G}Us6_jDw-$=!@++RauxRXUW= zuoxayXT!oR<=>jBG|IXw%_Iz?+N8RbV)(f>nTRXn`q)7_%c$$|lELPZc%lT4mE$2- zNh(_&j$0BJjbt)863^7j6=r)Q9$mR&#fp`K6AWELlHN|3FpvsP#{zyB=J@HhKFrI0t8?koy5iBF%vhEXSOSi zMBJG6Pgkbb()h(!!BNwo(#%+8vR!ZcjtdP!?kT$k%N_NE?OG!luTR#Hz~$vJ^Sa(h znDQD6pJlJC)V+fU@kNkjqtI+I0VfdxuxP2O*;XyV(@ZqYw`O~+*{ZbKtpqL?|HjG0 zgyUGTB`kcPNhRZT@ab~TJm~{hlYCo3?cE5^^WFw^ASyJEBAaI5&>+cd28khicAHU$+P4{cf+ zufFt>OPBNiOIH_>Z(AA&(>?Wx*5OhkiMQ0-H53B{ApZ7FX<|72q|7Ho+VrGrO< zJPzN&5XkLDWlUpJVZdtTm54->4@U=hK$eIJiC9J!$;)W!X6uftDizd^Z!Hzb-y^b$r{}cx1=s_!g%q?8R;H147bM7q<+@ zq%b{V2@3Jbq&2>B7L9nANwaO&p^H%sGc)ZPs?Ed@y(&Ixwr8c@l5(`o>zXk%Bt1Kk zG?LnQl0Hri5F{bF#x*2*_Of23MUrkQS?(RWt=3Z4?7wCIZRzuwcC}TJArs3Uh|A~) z?3?n6crRU=#51L%@fhO~&s3T-r50Khy?i)HYOXUajTEVMEmmf!nyg6ko<(%P8_a1m zM!Q;Sz`i`gJb-^gLmSdSaZ<~g-h=q6WTxIYO7f`^YL0H&u>~Wbr8!kgCTTNj&n7~& zqfVWvr+!e@p$ZbPSMfV%;XCWA9rXX6wEx}Qlp?c%aS~s%E9(7b|B*tRG{;M`NwYUa z-3nqpj4oT&CzCwMxMIUN-dvxFK zIo(gs)ngPyv}a0YRmiz#VX4ev0TJz~HyTHmBiy9tr)#LgDK5sr3`BaoWwI#R(;gpZ zq@%r?cCFmDtCQ=IW>mM6@4ID9CQ?kgN&rmJPY4bsGBV|G1v?VXWZ5v$t}Y)y_{7(4 z+k3^%tM|qmc3dA{yJ7e44LkN;zZS~YRGqiUA-GogRG8uwKY-m-IdydmDTVfWr`o37rzVRyXi>fP|d$ci}LgFGb1 zfq5jEj6-;r>6Nswr<$@V_cr*YX`xBpWFAjNSJ#Ydsnw9m-anLkvecd|%{|$tC;M*7 zJ=uRtbhXnUn0xyit3soSHCsnz-kI2I-WccB5%Ioa@kSG1F&5mwVso%mgX3N?436h= zxE__zq_;7C%@maYU~XbM!vVAE=>;VJK*=~=V+LiWepbZWCd4t$_Md9CW`|dSCdemr zYISf@dQaS=iDi;X13Ef5D05fFYN-|7q&G&ScUJ3qEs26kF2x%Ycy)VeteI2a+1s&p zrP^YBm0A{&md2D*Ixo`~!Nx^>meTB;jtFU$X^HkuVqt|9 zX)lV7cdX3n^=WaeS}2VdlixZ?#eBZ07L$>~%Fs-lQC8AguovPwindWHBUyPiR;iU5 zM@irNb#5)4qge@c{!M3=-HTf#G;4~YozY)uG?Hp^h)J&++UjJ~+fimc%`vh@w`?2P zzWLg1oA+L^rys?x4SV~%+O~Da&fO!MHtZScL$KYR&m^T9eT&&4`%RtZIjgxg7~Ik5 z81~$>k=qD*yA#fA(xV#DdVN+>p~=)i`;CgTD>W^tyoq6&jG5S(BpNN#BWQnHZS|?9 zBN;N1rJhEeEtAF8jruRgGVbG^eW@)FxX~ zoqg9mduwz+kM5di)MpskTnil`D$n{7N$=MA(WqW%S}r;lM+|GsW%(?x9tEM_+l^X5 zYByu0bV-zs=&k3u)qN@vqLO@ITGTtQi8HRW=4Fu|m8x)e`6y#+>zy)-3^~D4NmGb0 zcZLS56U$@%w-m81FC12+2{G0`&D0)fHCUg?huNK^(@yjWCS^FXb}`A0Wr{J}RKj7T zuGd^*bnld;J`J}ZHP6pHg!rB6SYx5JQK`vP!F%C^I-N(qv!J!sOSPmKn}E$yFPJbR z^`hBVFeFSfwiWE+>v7N$Y?#^GRiGkfPArYk*In^~V{I=8M_Fa^FZ zaWaY|pSx!@1Td>FXVb_yaI-F}gpui?lQz;qF^d`{3UfMFfez|@O9odgYc9D_Vt2t* zsiZKWrkbQ8ptCZ*@Wqp5)mS*!)Ys=)n@^Bh>;km0{zl z1PeDP^q_r7RI`b#VX-pvrk(YmthNe_k5I!K9UNFHOo>^@v9iKjTw#5cqo2j>HRo?% z8f=MPMBUQc=C>rgEXeL0TZikc#E$kVedXNzm5bL7!3-_rvy?B&wNlf_8j~w9eaoEe zekXT=GfK^crx9(o@LM(V+4m-56my02rlBc$B8^o#5OU(U`oM~*;mw%2dFr)>+nd9+ zQ$dKZ_|o#)de*gsF`jlC3ZCA^H0vbsK=&Akk-LUIG(@jDDru$U>u0VfUzRA%sV=YtTymbHmZIG-x#H{fV?Mg6uS7(yV$`O`3=rwB>F> zFlgiTq91KnJ83G%bQni$GFv&1Vt;9+++l>IYYFS>xvI05G1!OH_L^9lj>?** zilb6mg=l;RzoEq7aFkV=t*>@-N`r3W5@uem#~6IKduwS^qscYRYUP@X2asA%S7v85 zP<6aGG6|Q?wFY|_gL(2!OVAPbGz2YCAHyIu?Z)eDh4i!*b0lFmP>V2Gr_Lo*sY!ay zm~WE?1tQ}C8&}QQ!wu|}RBp~sr1{?~qvcMdDbL(%oOMMjYh^h(v{IXA&JfcCjLfr} zNe_m>w$!5XILj<8+x(^;FN}3%T(CvzT)-H*tz?q%irmt1SlWjz!<1Q>6VCRvDwQjT zD)I^A>5sKzhwe4giDB;lO7jXoOkrUXT&fFXvr;5&yn;41EQu#dtOVF}^WJckq4qwZ|uRO5`A-*Ef&2R7~8 zjo(5hOu{&8#U~DwvbW?_wy#yozRg<#W!addlsfv!{Q%7thX44u|t zT2QStVfw;R`gM13F!mzMj1$^s+bJ}nM*{ru=2XmV;!zC|l}gJ@v&z?qjisiztAi>d z&|<~y6-ajW+G~|2(e?)%)?%+`Xt0dK+$qsGwJNN+#&mtiO*!=>=ZuhJT1hd@+i)M* z5vJbnq+TaYiY!2-lQ8Lez|q3)mNOFe+|)K;7ip$~*f7se&PA9fl_1XOoKWDtQny4X z6M3sc*4uk$?Y0hj72y11on`~(LaNPboh5QSiENQn!%o9kt7{ap!#DCP z*&a?1mCewuEE8u5(SyNSxjbGKsB(;+x0X{b8R$V+t&BBrS=$^-9U``1OIi0A(x>|n zeyWeoR@;-6+JQ>*z}8*c56JXjdy-QPZh4bd$Qq-GKWbe?^Wb%@8r|@+S<#U9APEiN zoP@Y2?J$`X^2dAcne#pzu9Vqt(Ho?qsp2fTmcjM*xah#~mX@^#&Ie`IgOcfjt z6K3mmSq2LkwIPuo2%kl&OT1-nV%V#jB$LAmYD;%HYvr_b8r zm&j2u*MbYds;N0ZKH7nGYpI|edXm|+v>nlO?z%b7xkUU;*nItyHD^oc{%``pnLdoz z=ulz#08M0C*de_Viq)O93?`QOyE^mrmCRM!x5F(qszneJ&4VwlGv5VLdk>nD2OnEU2jq>2^o8rv+-W$sHJHBF zc;^%Lb~jm-(=@5Kt-Ja`^9MeN>4a{YG_hVTH^$}gK`_7b6`eP+@o96aRIVRx#*@|h z7!xP(NLHk0fZ!>^&S_0GO!is&RAjTg)kKkoNsyW~>4B4+g=Ah4Tf_#dpMj~FJ?(^z z`EfL9t4zl>hrm`0Y%~K)OAze@OXxLa-Pnl_Y!EFPl~w`}cVPO)+08m&fKQR#1uSGA0qAH z0Co1|oLw*)+Esqo0}9n8zq~Q1C69By*h2b{m;w^FD$ea9JDVR3mf%|#Tct$m8atC3 zV^!s(ddNfvAjcaOb`)|iou4>YRky58D>>)Ab{2eBW<)x-h0@?45RC}sX*sbHXHKgS zp=)wQr2dnTK|DCwO_JL*3sh0HIaQfx9qTsU+*E1#e%)QQ-@6aF4Z^!_7vPR``Cta$oRxyc`Vnnd0s09Qybz% zoFnO*LMNT=tQHls<0(2Y>+@aOJ`RB=Sq4uTYNGiOAs@3+Ej;m|Z z(ER=>Bx#(Fugmi{f0F6sC=-e?tZ+uft$$+Y2N^|_Qr_&iJ{v;Ic_Em#fC2G|AqtJZ zDfM7z{-7UW4>-=ZGf%i~0m{a)s=azgic~)=sPgKKJ_@KyS@ossR#cd+O~k^yr&l=Gqu^6MN{ZeP>NI`}iFp0C&&0O;AsXHVR_AG)9%xW33 z3a6C%Q+Aow!N(-Ypot!tjGJf4@BP(wP8Hs%#Wq8=UX{qOEdzg$78&UbaBaA`ZwrafJ@N}^=#n(&XPdEN%NXrfzxQWT$p-W--lh>-at6Ufi)yOSl_V3CUa1 z)U-Gx$;!dz%7R=#(+q9}??oxzq%76U<>mr$oZchloOI`(zo?X&nH{V5_^2Fhe2iSL zV`G`)1j-sXgls>Bv-ZXEW^k$$?HvZ(;T${iT*j zjX9|nuP^4NJ=P_X%VBX^XI|Pa;Tv(1)BGf8YxW`A>@GLzxYE*3lAy;+$te&?NTzJm zL|WNG!+p-~)*9YzVjGDmMLNaw#c?k>a}^!X(yKYNl%ZR z4?FthHTXg)vq9@t-*ZzgUU&PnJrwsGPfdT)j&-gl>o&quHLecpmv`32-u6TDneK3} zF^T!N)A<)TLM{?V*0EBa<5X&*nfskS4tYgg9zWf4UP8K|^UGM2>V#X}J2~c!Zy@j>$whOw%S_Gk z?#c!g!SOe9zORzi}ZQUE0tPkfZW1zG!G+Txlq*E(A z(NZEocX=A}>#Qg0q1s;BBP*v?hR-Q#V(NxpZiLUfb9??pDb-5%@_ zahK0seJR)EBzvb>lfvh6+41;Z^j)p)pU4ZQP^+dpw&RLRYtogQNhH&q%h{>XSZ9r% zOUgI1-3M@;@!2JMeHGHV@k<0KKrC^5;IRJZwg|8lgMw(Th+1`>JLq0k%_$ehA`wXN z-*_t%r4=@*WeWKj=#r7Ar`9sT_H45gG~8lTLqhU}iw$RUCNP#lg`0=uMis&1hT)wv#^5Bp12jgwb6D`rI2vs@x3$p zo3ALEP3@Y`RE}uKWz$_=FcWL^a(=jE@=(}GNRr@GpW)juRnVESy`E```Z~+$)RTnw z-XlM{pAzRu;0L8$JIwq#051}pB+hk|^?@xKwDGPc?2pgki%BeMJb5y+^{JJ!6aAEy z{isi)BA+5XHaB!&2`QIgM>++~r%>az)qvMCVZypY()PuCbDZx+vkcg*wS#xRYz`6( zes@5d9{TQvFJNV1ap2@gr@vt_-`8{{Nmbs0E(#KMP2!*iJB6w$)rYW48SoKwUC~R5 z+segjT!^1xcOLn|6{}XPni_E7Uy4^XCoAQmg1!{@*0q0H!cm>ANz^cG&GD%Q`ziYRHA}!&LUrJ(ZC8zC{jhq)s)0@V z)Q)gHdzsB_9^n04X%2|Bw$q1oz3%G0TZ)%tbgD7y-Qox~q-^Tp_>!?oYv8(~3)o;y z*KV%_yi-SH;jCCSC)3Sd0j;x;Tx6^Kb5Z{a5w1cd zEv}ba9qtSLY(scVajp)R2)#fMw2n|$?jf7+Sxl>>RH`-Va-w0~N~v_d#i3BDPSA3W zQZc!VR}Zf8FJ!6e}m9T$vch8-n72!@B3$2V8#b$Ken2N(pz z8bC+k=0-}k^md`(SCDcLsL`Hg*9jTZtZ)Y5D&`B?nUF5_nFA!L^oeQKe8MOToTWG+ z1g;>f3RX3qDBH7eUO2T#%^VDovkG>$WSYGFXf-ph;UU6jai}4#Rp=BdGL8J>J{J>f zPC%_JyMk?Jg*aM#n5s;)DMLmbd340pGWkRgvk#}FLuGNF$WXnN_Fon@ z3f^@AxR^c|aMr156I*p+0;<}+n_Tp*#ZzkZ<^8dd^+tPVhAvdrqH;{bZdpH*Wf^}} zg~);V3Ob_2mP@zPu@GRv@>-gXeU-px`5b%Y6w|f&$XhmV=d@E)*#M{qoDJ;w0kNdm zTWtI|fdC(IG<6a?-aF8z68UFsI68xHCDlp!=t!0e!c#o=NicjA`=5~Y^Fts%f)8Dl!TjzHk3{b5}Xh*ufQH0zvSx} zwk7E7UphqBX7*uHrJ$)P%Mi(*2I*?EDxEZ40=Fm(7tmzyh+TYyT5Tn!j%yv5V7B5-ih6o8GQZ97dp8 z(F3X*3hM%`v0P=;#f);>R_Fe;#-|LKg?vFm67fX}a}2>uqw=A<_yn|f=q_Fmx@*kY z9LEs7%WO0sy$hFtjifQ5)t2eP!Y$hAH6Dxbq|u(F)?S`=ykTBXD})zc@RVlKH@3G) zda{Bw%uG$+!SXd?>&Q7#b3wealF~3U}!9hg*+;)0nvx~y6` zIPG-9Smj{cCXy3t5Y$hlz9Lty6m@B0k}1Zh+Kvrz9|<_+KX*w|Qo0n@noi`WN+0%1 za)`xO9qA_PV=8Hj0~rxMsGOF{ZzfW)<}rJoh<+lli7ZgN*Ufz1*8-t4)9k9VIB}^hr;euwNAy2>i7$ z2`32BY>u~DIQ_2(U?T*HWLeD$&L(1b5#oTkKwz2!t;#`}TGs!@CcWCfTU&0O1E`)R zZibNK*5zY*WCbI0b9-E63D+d2|&-Jp12+eX&ntE^7ov2+54JS-mA zIQEggVa8%Zqzq_^T{E)#%AGrRZQQV7_Z1`CHcKdN9oe(#ifvc!wfk#!5*ch{WCvUK zyEbgtzB%5!b7cF9fg2D_qS3;F#rmrgOsgYp zXB05Msv{U!KIuTT5vfAJjhv2R#Mm3-$S^Z^x;{&1nLMAb!v^qPKqLXd7&*h6&`2Di zBWIg5>MjIa312~(k(<^>L~VK({Svgq0Gr=2=Mbg$;F-mT5UbD1f{^T!NrzR8$?mL1 zlLB)?hj|Ibwn4QrsgT8HHs{O~CnVkS$K}qnQADxG8bdoVY2uq4ff^CntfIl{wA`$7 zns#FdFV;auO_Q;D`!K8+EG80@hm$huM?@rt)hZ9%uL+tjVvbQ0UIshfj254*>90Uw z_LZ}AG_d*#gVPjqNjhFJCF^GAI=jHDW%|U07(?YDXKmSo(roFula)~c=SCJ=jPS4r z>2Dr};9~vW=VORvnXH67|Hc%HWlG2KP7c(3@N69?vjtj+GDhe2h%i>jM;Oxp&h6dY z`SAXRWnoK*G}b$lu4rSuiMCt*xE$2qEIsRWxuF$v45cDI&n-2gf)6_8IaoRJEx+VT z!F}jlAW@l6OjE2v17oGucvSF?aXw+|%Apsr`%>JkLFefNN0yJLrD}<%i?Rc#O=*(2 zN-&HqlsioGf{RNg7lTa#<}|xx=AbcKj*PrkvBjJ7?BgqqNQh-2XYV{U>x@#S#hZ70 zz>OT-vAHYO<*X?$qCys~Y!S2;x6J84trxJ8O5S)glS%WO7-j|cjpky9w|Y#>z%=fP zWY(L-T#&K_I$25co#7I>2Kv>Qc{cD9o7W{OWMRpEiLA9rG|$jwdCyma5c{l)#`Ct9 zhT?f+8HGS|l*ViM1wwZ$G^T^eO}8mC#&`KS5op!MzGX8@BAqEKBNuIyKT$efIf%EO zDX0j(s8t-Qfuph8lj+iIt2;@zMXg9gTDv zRprd40#Sh}yB~>*HKt)_k#TpE`exj_ zD>i|?#U4mtL*<%J;V-mK@R* zQ^9sqHGzCow(emHS$ocN@!0y6?}%i1A?cg5d@+mp#<%1we_34*R?CroWDE2_a;Q?W zig`;;&IWJT$b(&JE|82s2)JNeEH?WLlkd*Ly0xnZB+NaR*Z~!@ZMtZDFQqvJ5#weN zDbho#Uf`sx+%IJ?2z!;5)yNm7v2+az+Jz zn7kEbaABIUBcmVrp;yg(dQ4fV}!{djNj$EWRnH2hPT6O_uc^ar~ zXlX=sWIDK{PB#|9qH+pD>LBMjLS=H6362d-M1N{8XCu3Awz}K;kd=yku9%wdp+G;n z$UbE>TRAwJORA$I%qXA3p*m|!i+ZsDDQk*O+Br(dDKVEj-ZQ$c%EH74K2z?RgTyqM z(h2Zpao%bbaXe}nvzQ{gN^#YgsXG6qA2uHWPPOQKZ*E58ue1~J-|!tR9uw_tg*sR& zhFI$c%~f+A<0rt8ooiv5lq10E*kep}Y=z|(SGnQUL`s)VGQ^z>=wt~Sd~3A{t#X|~ zNg8;GIg8^Cwy9N|yz%kk)NdUIhwH?7#=7_DrhVKYUM#bYdTTYvY%-U-=VDDS)*xo# z_(iKVV8O&;Q!3>Ird-FCTAsi+GPkeDZd*L0lI%QAM?&=qJ{p8Xqo^=&DxtG0t#Tp% zwDHzAb6*8IWh0$etJfmoM4`V$aEMVeUF)A6=rc&&Rp5anSs4WlqxX>1L;$FOpH$F>|B(49i%VAeovh*ltQbtep)e>Rr3L!GlN| zZ9XyQSr*7Rh_#u5*T)+=YJy|?Jil1?bWmp;t`w=n&6^v>`in^v#B`c~lbY$)6FvdH z<|?3PivKB%ePGP(hBDD3ep2|kzqIXOO-kd-Fii%r`g+`S-v2gP3{~RCPa=d zf^ouu1o~16&RMIuO$c)CJS$O}FdHT8UJ%fUy&G>5v7FWEAIU6nb$$joL4FL0Gvm>* zH4A-sRnuWOUbf6dRdM&rmboxw{oY!TJ$?7WdEG=AEJ$wA_82?1o{hFt^}+V^qd=TA z-kIj;?5NB=o~G(UjKnh8s0}E3SeBi+)w6Wl`xTM~((|79EQyc2rxRSA_3EFbdd#H+ zS*`A@$~U6EU_%)D*Y?!h7Mt@CvJ@3jmL#pKsOG$NRvx`;))!&;oXKU82*cRsW{;+K zrZ~O%AYSo7@OmT}BT`AyLgu9xHH@q~Pog88XjI5#Zl(QdwwHJghXra-29%~}h~y`gFIN_mJ}JwsF%e^j zTP!~p2~ah$%K6R3Z0Ni!H!k(wln_xbh%PI9L4!Y}((nZVVMV64v~#T(U%7P;S|If# za41L&-eo4H(fyQbwzT?{vdniB{g`%C@R-v@bTP6z-!*Vf*#9-lET2i&Qf0nmX~pNt zQKnnR0<^;tvY{|Lwo7rUUo`2w$DWfAChaAqC5RLy5Q`*#R;TO?@N#0?1V!n6?FC{o zIT5O_6f#p4wsMD95oO9W9OjdNF!zdn1WPH{DmBvw=F$#+^p??rM6gtQp+8wdz4Hb>L@}BYA=@vvN|4R)+bmPQe?r2 zZog`WJ42Jr`m3`jNza^lz?zTsqANeN(#IpqHEI4Vm>V`n+|dzrY!=jDh!Z%POZulq zW|7&F9TuQYW+40J>RipQe4RQdaz>&BBUGn2HVEu(4jaYH(f%X+5f7s%1h4%+vChU>nvY$VP40ovhqpN9O;qZiR#QPv#nA^my1y7x^+0K znF~;;z77Ej5g{CWN&nI1EI{Ghv^GRqeU#gW9Y4Atg*pFl6dc0wkhUk3f`7y`H-|#) zO>Q6uG~8i;tlI(~^sz(>vX6~XH1vLThf$4iFzH}k+p$C^&m}Cn3Anq9dUS=8WFiAB=mwKAG;7s84(g@w)l4y|CXaaJ4-g&@;2VED2D8Y z+rMhAeV1@F&qp*g3FOaG@XL9XGD<_DwHKgMWQ8<OD-$Z}Mz^^XSOSa4O+@&?pJy;F zpqk9_jA3EtrfSI1ZIyM~-&)=>oI35Tyli1tu-Jwie(~oU(yc91Pr0KkI_4`QMSPc1 zBco*YgvCv|q)Z8P%9S4C6D|xGLW3uf+g$0av+HAh!`SPs4T0|?zB1GLV%Gc?w1x(U zn#;;6~we&o^Dqr+!9WD zu-Aru2x$m6&abLz0D=E({ta(>6)SFPD%vs+B{G@b=TNK|*obg_fkCI)Oa_8xEOCh$!b z#ebdKib!m2aY_#Xrse!3&PghE`pbN)?P4gh-NdKt{A0&`>6~P&Hm=Oo)mFm0S=I)5@>iZkUFn<#U%EH;G?xY)C53c461 zn>rw<+2DpeQgBVMqe|JvR_LGXTRyDTXo>|Z2C+P7jA3d@z!c3E0U7DHq8z!l%^M%f zNx6lRrptJ_x6)&Igk1B-%v7Cj_hrEcYV66V-G@`HLB{1-oJN^32q@w$W+z#ZJlJUI zbSSt0jb>vN6rs_b63o0&`Lyu8B8nsLeW1eh3xkEI{6_|PGFK6+HXi=&4+A)WRj2yc z&E7AlNvsaZXA$Z%hbQF0v2 zL(s;cdDDj15Q$8%ETdl4N~sGs^{GxrU*42*R?h=x28!RzJPVU%}zg0CW$Gz z!^vZ|X`w3$Bs;?s3Ipk6fb*JSYGfa5xdbs`AYEy4Mg@0Y>Z|YzlKH$*AvUDV{$TSk z;tWE1hS=1$m@0g=0PFDHeM6iN8d;iP^~CO(z9=)xC$~u&S?r!ySViP?G8q3lh?>B-5>nAUU*@kAeNCrP&5kGla0oJZF?* ztkvmF@7xa2(l7rRv=$8yyw``5Y|4zu7N=&=E+T=np8tX&JuAmq!UYS`__95r_>#v! ztuT`dljmFvZl$I}0xr^|Kk}i$?4cTZ@ud$y>9|rG#z$uP*2_hq#OvY1P{JV=%VU#$ z2c`{&QiFe@P96b9M!G?x!??~#uV9qFY-)*&4sQ&Kp6+2i-~v*51y`R{!QFb0Vr%TS zsw*;eqM($VA|W_s&m{QYrwCE4G%#BD2DDe^IZA4T-9sDku|zUo%_K1UGz~|YX!l|{ zOY^19*&Eigb_60_(&QE)QorEStoTY%h!FiS&Msv&%7%_g2L0-Sfq$FK|%U$f3s zfNPyj)RQ33iOu}d-CQFw9y)xMDM$1&MFKI8v=gU4sw!`e~r%y9(v zC-?S%oGPBEdrj130WsF|717;Yf!~~6<>F$d%-H37>v|iKdREomRHtV!&&XZwWmXdY zYc=Q6G*TbH0&k&@mFYI@y*6N_+cQ=s)o?+}lIf^BsdGGPmKgtMulsd_Z%bN(ej>_c zoGY(KhSQo!e#@SdWl~U1Q0l7(mRcNswCI@ncV`sbQo_rI!TA=f(z&k}@*yjU12}2B z&Zrm#`u4FgH6qzD0Zc>l$hzG^3Cix)^azz{Ijc)0Rp!RZ?0%iajr2u1mg#J#>ny7! z4y4*-*gQb2P3s7oJ_E^x&Fsj@7{dqA4C&JEs6yb(xxJt%uuv*VL(d?N34Osj1=u&| zpy1cWt5fsd?Z)*%CxaEJhK~P87U;}}Vj$#84;Ut}T8cCC*Zg;`kU;ZQ4MMfcl z^@u7cabu_H*w3u7@HPp=#qJYARk_>BU68<9A2hPHa^WN*lg_uJ-ipLY2hNj)@3DL^ zPPeXO;<~=J?z1JA_a<0Rn-!r(<3=D11Si!BAxdYEES;a>^bE=AKMWd%1+^+e&Dr!} zKEVfW>LkhRLC*P(vmTrik8{zpPcgjf9e=5T>t<8 literal 0 HcmV?d00001 diff --git a/po/nl.po b/po/nl.po new file mode 100644 index 0000000..40930c2 --- /dev/null +++ b/po/nl.po @@ -0,0 +1,2270 @@ +# Dutch translations for GNU gawk. +# Copyright (C) 2012 Free Software Foundation, Inc. +# This file is distributed under the same license as the gawk package. +# +# Als het schone blinkt. +# +# Benno Schulenberg , 2005, 2007, 2010, 2011, 2012. +# Erwin Poeze , 2009. +msgid "" +msgstr "" +"Project-Id-Version: gawk 4.0.0h\n" +"Report-Msgid-Bugs-To: arnold@skeeve.com\n" +"POT-Creation-Date: 2012-03-28 22:03+0200\n" +"PO-Revision-Date: 2012-01-30 20:40+0100\n" +"Last-Translator: Benno Schulenberg \n" +"Language-Team: Dutch \n" +"Language: nl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Lokalize 1.0\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: array.c:140 +#, c-format +msgid "from %s" +msgstr "van %s" + +#: array.c:248 +msgid "attempt to use a scalar value as array" +msgstr "scalaire waarde wordt gebruikt als array" + +#: array.c:251 +#, c-format +msgid "attempt to use function `%s' as an array" +msgstr "functie '%s' wordt gebruikt als array" + +#: array.c:254 +#, c-format +msgid "attempt to use scalar parameter `%s' as an array" +msgstr "scalaire parameter '%s' wordt gebruikt als array" + +#: array.c:257 +#, c-format +msgid "attempt to use scalar `%s' as an array" +msgstr "scalair '%s' wordt gebruikt als array" + +#: array.c:302 array.c:707 builtin.c:84 builtin.c:1385 builtin.c:1427 +#: builtin.c:1440 builtin.c:1859 builtin.c:1871 eval.c:1135 eval.c:1139 +#: eval.c:1495 eval.c:1812 +#, c-format +msgid "attempt to use array `%s' in a scalar context" +msgstr "array '%s' wordt gebruikt in een scalaire context" + +#: array.c:513 +#, c-format +msgid "reference to uninitialized element `%s[\"%.*s\"]'" +msgstr "verwijzing naar ongeïnitialiseerd element '%s[\"%.*s\"]'" + +#: array.c:519 +#, c-format +msgid "subscript of array `%s' is null string" +msgstr "index van array '%s' is lege string" + +#: array.c:723 +#, c-format +msgid "delete: index `%s' not in array `%s'" +msgstr "delete: index '%s' niet in array '%s'" + +#: array.c:734 eval.c:1865 +#, c-format +msgid "attempt to use scalar `%s[\"%.*s\"]' as an array" +msgstr "scalair '%s[\"%.*s\"]' wordt gebruikt als array" + +#: array.c:910 +#, c-format +msgid "%s: empty (null)\n" +msgstr "%s: leeg (nil)\n" + +#: array.c:915 +#, c-format +msgid "%s: empty (zero)\n" +msgstr "%s: leeg (nul)\n" + +#: array.c:919 +#, c-format +msgid "%s: table_size = %d, array_size = %d\n" +msgstr "%s: tabelgrootte = %d, arraygrootte = %d\n" + +#: array.c:954 +#, c-format +msgid "%s: is parameter\n" +msgstr "%s: is een parameter\n" + +#: array.c:958 +#, c-format +msgid "%s: array_ref to %s\n" +msgstr "%s: array-verwijzing naar %s\n" + +#: array.c:963 +msgid "adump: argument not an array" +msgstr "adump: argument is geen array" + +#: array.c:1086 +msgid "asort: second argument not an array" +msgstr "asort: tweede argument is geen array" + +#: array.c:1087 +msgid "asorti: second argument not an array" +msgstr "asorti: tweede argument is geen array" + +#: array.c:1094 +msgid "asort: first argument not an array" +msgstr "asort: eerste argument is geen array" + +#: array.c:1095 +msgid "asorti: first argument not an array" +msgstr "asorti: eerste argument is geen array" + +#: array.c:1102 +msgid "asort: cannot use a subarray of first arg for second arg" +msgstr "" +"asort: een subarray van het eerste argument kan niet als tweede argument " +"gebruikt worden" + +#: array.c:1103 +msgid "asorti: cannot use a subarray of first arg for second arg" +msgstr "" +"asorti: een subarray van het eerste argument kan niet als tweede argument " +"gebruikt worden" + +#: array.c:1108 +msgid "asort: cannot use a subarray of second arg for first arg" +msgstr "" +"asort: een subarray van het tweede argument kan niet als eerste argument " +"gebruikt worden" + +#: array.c:1109 +msgid "asorti: cannot use a subarray of second arg for first arg" +msgstr "" +"asorti: een subarray van het tweede argument kan niet als eerste argument " +"gebruikt worden" + +#: array.c:1655 +#, c-format +msgid "`%s' is invalid as a function name" +msgstr "'%s' is ongeldig als functienaam" + +#: array.c:1659 +#, c-format +msgid "sort comparison function `%s' is not defined" +msgstr "sorteervergelijkingsfunctie '%s' is niet gedefinieerd" + +#: awkgram.y:249 +#, c-format +msgid "%s blocks must have an action part" +msgstr "%s-blokken horen een actiedeel te hebben" + +#: awkgram.y:252 +msgid "each rule must have a pattern or an action part" +msgstr "elke regel hoort een patroon of een actiedeel te hebben" + +#: awkgram.y:323 awkgram.y:334 +msgid "old awk does not support multiple `BEGIN' or `END' rules" +msgstr "oude 'awk' staat meerdere 'BEGIN'- en 'END'-regels niet toe" + +#: awkgram.y:371 +#, c-format +msgid "`%s' is a built-in function, it cannot be redefined" +msgstr "'%s' is een ingebouwde functie en is niet te herdefiniëren" + +#: awkgram.y:432 +msgid "regexp constant `//' looks like a C++ comment, but is not" +msgstr "regexp-constante '//' lijkt op C-commentaar, maar is het niet" + +#: awkgram.y:436 +#, c-format +msgid "regexp constant `/%s/' looks like a C comment, but is not" +msgstr "regexp-constante '/%s/' lijkt op C-commentaar, maar is het niet" + +#: awkgram.y:528 +#, c-format +msgid "duplicate case values in switch body: %s" +msgstr "dubbele 'case'-waarde in 'switch'-opdracht: %s" + +#: awkgram.y:549 +msgid "duplicate `default' detected in switch body" +msgstr "dubbele 'default' in 'switch'-opdracht" + +#: awkgram.y:809 +msgid "`break' is not allowed outside a loop or switch" +msgstr "'break' buiten een lus of 'switch'-opdracht is niet toegestaan" + +#: awkgram.y:818 +msgid "`continue' is not allowed outside a loop" +msgstr "'continue' buiten een lus is niet toegestaan" + +#: awkgram.y:828 +#, c-format +msgid "`next' used in %s action" +msgstr "'next' wordt gebruikt in %s-actie" + +#: awkgram.y:836 +msgid "`nextfile' is a gawk extension" +msgstr "'nextfile' is een gawk-uitbreiding" + +#: awkgram.y:841 +#, c-format +msgid "`nextfile' used in %s action" +msgstr "'nextfile' wordt gebruikt in %s-actie" + +#: awkgram.y:865 +msgid "`return' used outside function context" +msgstr "'return' wordt gebruikt buiten functiecontext" + +#: awkgram.y:925 +msgid "plain `print' in BEGIN or END rule should probably be `print \"\"'" +msgstr "" +"kale 'print' in BEGIN- of END-regel moet vermoedelijk 'print \"\"' zijn" + +#: awkgram.y:995 awkgram.y:999 awkgram.y:1023 +msgid "`delete array' is a gawk extension" +msgstr "'delete array' is een gawk-uitbreiding" + +#: awkgram.y:1019 +msgid "`delete(array)' is a non-portable tawk extension" +msgstr "'delete(array)' is een niet-overdraagbare 'tawk'-uitbreiding" + +#: awkgram.y:1135 +msgid "multistage two-way pipelines don't work" +msgstr "meerfase-tweerichtings-pijplijnen werken niet" + +#: awkgram.y:1238 +msgid "regular expression on right of assignment" +msgstr "reguliere expressie rechts van toewijzing" + +#: awkgram.y:1249 +msgid "regular expression on left of `~' or `!~' operator" +msgstr "reguliere expressie links van operator '~' of '!~'" + +#: awkgram.y:1265 awkgram.y:1419 +msgid "old awk does not support the keyword `in' except after `for'" +msgstr "oude 'awk' kent het sleutelwoord 'in' niet, behalve na 'for'" + +#: awkgram.y:1275 +msgid "regular expression on right of comparison" +msgstr "reguliere expressie rechts van vergelijking" + +#: awkgram.y:1394 +#, c-format +msgid "`getline var' invalid inside `%s' rule" +msgstr "'getline var' is ongeldig binnen een '%s'-regel" + +#: awkgram.y:1397 eval.c:2504 +#, c-format +msgid "`getline' invalid inside `%s' rule" +msgstr "'getline' is ongeldig binnen een '%s'-regel" + +#: awkgram.y:1402 +msgid "non-redirected `getline' undefined inside END action" +msgstr "niet-omgeleide 'getline' is ongedefinieerd binnen een END-actie" + +#: awkgram.y:1421 +msgid "old awk does not support multidimensional arrays" +msgstr "oude 'awk' kent geen meerdimensionale arrays" + +#: awkgram.y:1517 +msgid "call of `length' without parentheses is not portable" +msgstr "aanroep van 'length' zonder haakjes is niet overdraagbaar" + +#: awkgram.y:1580 +msgid "indirect function calls are a gawk extension" +msgstr "indirecte functieaanroepen zijn een gawk-uitbreiding" + +#: awkgram.y:1593 +#, c-format +msgid "can not use special variable `%s' for indirect function call" +msgstr "" +"kan speciale variabele '%s' niet voor indirecte functieaanroep gebruiken" + +#: awkgram.y:1671 +msgid "invalid subscript expression" +msgstr "ongeldige index-expressie" + +#: awkgram.y:1711 +msgid "use of non-array as array" +msgstr "non-array wordt gebruikt als array" + +#: awkgram.y:1975 awkgram.y:1995 msg.c:98 +msgid "warning: " +msgstr "waarschuwing: " + +#: awkgram.y:1993 msg.c:130 +msgid "fatal: " +msgstr "fataal: " + +#: awkgram.y:2043 +msgid "unexpected newline or end of string" +msgstr "onverwacht regeleinde of einde van string" + +#: awkgram.y:2300 awkgram.y:2358 awkgram.y:2542 +#, c-format +msgid "can't open source file `%s' for reading (%s)" +msgstr "kan bronbestand '%s' niet openen om te lezen (%s)" + +#: awkgram.y:2301 awkgram.y:2359 builtin.c:122 +msgid "reason unknown" +msgstr "reden onbekend" + +#: awkgram.y:2317 +#, c-format +msgid "already included source file `%s'" +msgstr "bronbestand '%s' is reeds ingesloten" + +#: awkgram.y:2343 +msgid "@include is a gawk extension" +msgstr "'@include' is een gawk-uitbreiding" + +#: awkgram.y:2349 +msgid "empty filename after @include" +msgstr "lege bestandsnaam na '@include'" + +#: awkgram.y:2494 +msgid "empty program text on command line" +msgstr "lege programmatekst op commandoregel" + +#: awkgram.y:2609 +#, c-format +msgid "can't read sourcefile `%s' (%s)" +msgstr "kan bronbestand '%s' niet lezen (%s)" + +#: awkgram.y:2620 +#, c-format +msgid "source file `%s' is empty" +msgstr "bronbestand '%s' is leeg" + +#: awkgram.y:2797 +msgid "source file does not end in newline" +msgstr "bronbestand eindigt niet met een regeleindeteken (LF)" + +#: awkgram.y:2900 +msgid "unterminated regexp ends with `\\' at end of file" +msgstr "onafgesloten reguliere expressie eindigt met '\\' aan bestandseinde" + +#: awkgram.y:2924 +#, c-format +msgid "%s: %d: tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "%s: %d: regexp-optie '/.../%c' van 'tawk' werkt niet in gawk" + +#: awkgram.y:2928 +#, c-format +msgid "tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "regexp-optie '/.../%c' van 'tawk' werkt niet in gawk" + +#: awkgram.y:2935 +msgid "unterminated regexp" +msgstr "onafgesloten reguliere expressie" + +#: awkgram.y:2939 +msgid "unterminated regexp at end of file" +msgstr "onafgesloten reguliere expressie aan bestandseinde" + +#: awkgram.y:2998 +msgid "use of `\\ #...' line continuation is not portable" +msgstr "gebruik van regelvoortzetting '\\ #...' is niet overdraagbaar" + +#: awkgram.y:3014 +msgid "backslash not last character on line" +msgstr "backslash is niet het laatste teken op de regel" + +#: awkgram.y:3075 +msgid "POSIX does not allow operator `**='" +msgstr "POSIX staat operator '**=' niet toe" + +#: awkgram.y:3077 +msgid "old awk does not support operator `**='" +msgstr "oude 'awk' kent de operator '**=' niet" + +#: awkgram.y:3086 +msgid "POSIX does not allow operator `**'" +msgstr "POSIX staat operator '**' niet toe" + +#: awkgram.y:3088 +msgid "old awk does not support operator `**'" +msgstr "oude 'awk' kent de operator '**' niet" + +#: awkgram.y:3123 +msgid "operator `^=' is not supported in old awk" +msgstr "oude 'awk' kent de operator '^=' niet" + +#: awkgram.y:3131 +msgid "operator `^' is not supported in old awk" +msgstr "oude 'awk' kent de operator '^' niet" + +#: awkgram.y:3224 awkgram.y:3240 +msgid "unterminated string" +msgstr "onafgesloten string" + +#: awkgram.y:3436 +#, c-format +msgid "invalid char '%c' in expression" +msgstr "ongeldig teken '%c' in expressie" + +#: awkgram.y:3483 +#, c-format +msgid "`%s' is a gawk extension" +msgstr "'%s' is een gawk-uitbreiding" + +#: awkgram.y:3488 +#, c-format +msgid "`%s' is a Bell Labs extension" +msgstr "'%s' is een uitbreiding door Bell Labs" + +#: awkgram.y:3493 +#, c-format +msgid "POSIX does not allow `%s'" +msgstr "POSIX staat '%s' niet toe" + +#: awkgram.y:3501 +#, c-format +msgid "`%s' is not supported in old awk" +msgstr "oude 'awk' kent '%s' niet" + +#: awkgram.y:3568 +msgid "`goto' considered harmful!\n" +msgstr "'goto' wordt als schadelijk beschouwd!\n" + +#: awkgram.y:3619 +#, c-format +msgid "%d is invalid as number of arguments for %s" +msgstr "%d is een ongeldig aantal argumenten voor %s" + +#: awkgram.y:3654 +#, c-format +msgid "%s: string literal as last arg of substitute has no effect" +msgstr "%s: een stringwaarde als laatste vervangingsargument heeft geen effect" + +#: awkgram.y:3659 +#, c-format +msgid "%s third parameter is not a changeable object" +msgstr "%s: derde parameter is geen veranderbaar object" + +#: awkgram.y:3732 awkgram.y:3735 +msgid "match: third argument is a gawk extension" +msgstr "match: derde argument is een gawk-uitbreiding" + +#: awkgram.y:3789 awkgram.y:3792 +msgid "close: second argument is a gawk extension" +msgstr "close: tweede argument is een gawk-uitbreiding" + +#: awkgram.y:3804 +msgid "use of dcgettext(_\"...\") is incorrect: remove leading underscore" +msgstr "dcgettext(_\"...\") is onjuist: verwijder het liggende streepje" + +#: awkgram.y:3819 +msgid "use of dcngettext(_\"...\") is incorrect: remove leading underscore" +msgstr "dcngettext(_\"...\") is onjuist: verwijder het liggende streepje" + +#: awkgram.y:3911 +#, c-format +msgid "function `%s': parameter #%d, `%s', duplicates parameter #%d" +msgstr "functie '%s': parameter #%d, '%s', dupliceert parameter #%d" + +#: awkgram.y:3953 +#, c-format +msgid "function `%s': parameter `%s' shadows global variable" +msgstr "functie '%s': parameter '%s' schaduwt een globale variabele" + +#: awkgram.y:4111 +#, c-format +msgid "could not open `%s' for writing (%s)" +msgstr "kan '%s' niet openen om te schrijven (%s)" + +#: awkgram.y:4112 +msgid "sending variable list to standard error" +msgstr "variabelenlijst gaat naar standaardfoutuitvoer" + +#: awkgram.y:4118 +#, c-format +msgid "%s: close failed (%s)" +msgstr "%s: sluiten is mislukt (%s)" + +#: awkgram.y:4170 +msgid "shadow_funcs() called twice!" +msgstr "shadow_funcs() twee keer aangeroepen!" + +#: awkgram.y:4176 +msgid "there were shadowed variables." +msgstr "er waren geschaduwde variabelen." + +#: awkgram.y:4206 +#, c-format +msgid "function `%s': can't use function name as parameter name" +msgstr "functie '%s': kan functienaam niet als parameternaam gebruiken" + +#: awkgram.y:4210 +#, c-format +msgid "function `%s': can't use special variable `%s' as a function parameter" +msgstr "" +"functie '%s': kan speciale variabele '%s' niet als functieparameter gebruiken" + +#: awkgram.y:4226 +#, c-format +msgid "function name `%s' previously defined" +msgstr "functienaam '%s' is al eerder gedefinieerd" + +#: awkgram.y:4394 awkgram.y:4400 +#, c-format +msgid "function `%s' called but never defined" +msgstr "functie '%s' wordt aangeroepen maar is nergens gedefinieerd" + +#: awkgram.y:4403 +#, c-format +msgid "function `%s' defined but never called directly" +msgstr "functie '%s' is gedefinieerd maar wordt nergens direct aangeroepen" + +#: awkgram.y:4435 +#, c-format +msgid "regexp constant for parameter #%d yields boolean value" +msgstr "regexp-constante als parameter #%d levert booleanwaarde op" + +#: awkgram.y:4544 +#, c-format +msgid "" +"function `%s' called with space between name and `(',\n" +"or used as a variable or an array" +msgstr "" +"functie '%s' wordt aangeroepen met een spatie tussen naam en '(',\n" +"of wordt gebruikt als variabele of array" + +#: awkgram.y:4791 eval.c:2056 +msgid "division by zero attempted" +msgstr "deling door nul" + +#: awkgram.y:4800 eval.c:2072 +#, c-format +msgid "division by zero attempted in `%%'" +msgstr "deling door nul in '%%'" + +#: builtin.c:120 +#, c-format +msgid "%s to \"%s\" failed (%s)" +msgstr "%s naar \"%s\" is mislukt (%s)" + +#: builtin.c:121 +msgid "standard output" +msgstr "standaarduitvoer" + +#: builtin.c:135 +msgid "exp: received non-numeric argument" +msgstr "exp: argument is geen getal" + +#: builtin.c:141 +#, c-format +msgid "exp: argument %g is out of range" +msgstr "exp: argument %g ligt buiten toegestane bereik" + +#: builtin.c:200 +#, c-format +msgid "fflush: cannot flush: pipe `%s' opened for reading, not writing" +msgstr "" +"fflush: kan pijp niet leegmaken: '%s' is geopend om te lezen, niet om te " +"schrijven" + +#: builtin.c:203 +#, c-format +msgid "fflush: cannot flush: file `%s' opened for reading, not writing" +msgstr "" +"fflush: kan bestand niet leegmaken: '%s' is geopend om te lezen, niet om te " +"schrijven" + +#: builtin.c:215 +#, c-format +msgid "fflush: `%s' is not an open file, pipe or co-process" +msgstr "fflush: '%s' is geen open bestand, pijp, of co-proces" + +#: builtin.c:333 +msgid "index: received non-string first argument" +msgstr "index: eerste argument is geen string" + +#: builtin.c:335 +msgid "index: received non-string second argument" +msgstr "index: tweede argument is geen string" + +#: builtin.c:457 +msgid "int: received non-numeric argument" +msgstr "int: argument is geen getal" + +#: builtin.c:493 +msgid "length: received array argument" +msgstr "length: argument is een array" + +#: builtin.c:496 +msgid "`length(array)' is a gawk extension" +msgstr "'length(array)' is een gawk-uitbreiding" + +#: builtin.c:504 +msgid "length: received non-string argument" +msgstr "length: argument is geen string" + +#: builtin.c:535 +msgid "log: received non-numeric argument" +msgstr "log: argument is geen getal" + +#: builtin.c:538 +#, c-format +msgid "log: received negative argument %g" +msgstr "log: argument %g is negatief" + +#: builtin.c:694 builtin.c:699 +msgid "fatal: must use `count$' on all formats or none" +msgstr "fataal: 'count$' hoort in alle opmaken gebruikt te worden, of in geen" + +#: builtin.c:762 +#, c-format +msgid "field width is ignored for `%%' specifier" +msgstr "veldbreedte wordt genegeerd voor opmaakaanduiding '%%'" + +#: builtin.c:764 +#, c-format +msgid "precision is ignored for `%%' specifier" +msgstr "veldprecisie wordt genegeerd voor opmaakaanduiding '%%'" + +#: builtin.c:766 +#, c-format +msgid "field width and precision are ignored for `%%' specifier" +msgstr "veldbreedte en -precisie worden genegeerd voor opmaakaanduiding '%%'" + +#: builtin.c:817 +msgid "fatal: `$' is not permitted in awk formats" +msgstr "fataal: '$' is niet toegestaan in awk-opmaak" + +#: builtin.c:826 +msgid "fatal: arg count with `$' must be > 0" +msgstr "fataal: het aantal argumenten met '$' moet > 0 zijn" + +#: builtin.c:830 +#, c-format +msgid "fatal: arg count %ld greater than total number of supplied arguments" +msgstr "fataal: argumentental %ld is groter dan het gegeven aantal argumenten" + +#: builtin.c:834 +msgid "fatal: `$' not permitted after period in format" +msgstr "fataal: '$' is niet toegestaan na een punt in de opmaak" + +#: builtin.c:850 +msgid "fatal: no `$' supplied for positional field width or precision" +msgstr "fataal: geen '$' opgegeven bij positionele veldbreedte of -precisie" + +#: builtin.c:921 +msgid "`l' is meaningless in awk formats; ignored" +msgstr "'l' is betekenisloos in awk-opmaak; genegeerd" + +#: builtin.c:925 +msgid "fatal: `l' is not permitted in POSIX awk formats" +msgstr "fataal: 'l' is niet toegestaan in POSIX awk-opmaak" + +#: builtin.c:938 +msgid "`L' is meaningless in awk formats; ignored" +msgstr "'L' is betekenisloos in awk-opmaak; genegeerd" + +#: builtin.c:942 +msgid "fatal: `L' is not permitted in POSIX awk formats" +msgstr "fataal: 'L' is niet toegestaan in POSIX awk-opmaak" + +#: builtin.c:955 +msgid "`h' is meaningless in awk formats; ignored" +msgstr "'h' is betekenisloos in awk-opmaak; genegeerd" + +#: builtin.c:959 +msgid "fatal: `h' is not permitted in POSIX awk formats" +msgstr "fataal: 'h' is niet toegestaan in POSIX awk-opmaak" + +#: builtin.c:1272 +#, c-format +msgid "[s]printf: value %g is out of range for `%%%c' format" +msgstr "[s]printf: waarde %g ligt buiten toegestaan bereik voor opmaak '%%%c'" + +#: builtin.c:1332 +#, c-format +msgid "ignoring unknown format specifier character `%c': no argument converted" +msgstr "" +"onbekend opmaakteken '%c' wordt genegeerd: geen argument is geconverteerd" + +#: builtin.c:1337 +msgid "fatal: not enough arguments to satisfy format string" +msgstr "fataal: niet genoeg argumenten voor opmaakstring" + +#: builtin.c:1339 +msgid "^ ran out for this one" +msgstr "niet genoeg ^ voor deze" + +#: builtin.c:1346 +msgid "[s]printf: format specifier does not have control letter" +msgstr "[s]printf: opmaakaanduiding mist een stuurletter" + +#: builtin.c:1349 +msgid "too many arguments supplied for format string" +msgstr "te veel argumenten voor opmaakstring" + +#: builtin.c:1423 builtin.c:1434 +msgid "printf: no arguments" +msgstr "printf: geen argumenten" + +#: builtin.c:1475 +msgid "sqrt: received non-numeric argument" +msgstr "sqrt: argument is geen getal" + +#: builtin.c:1479 +#, c-format +msgid "sqrt: called with negative argument %g" +msgstr "sqrt: argument %g is negatief" + +#: builtin.c:1503 +#, c-format +msgid "substr: length %g is not >= 1" +msgstr "substr: lengte %g is niet >= 1" + +#: builtin.c:1505 +#, c-format +msgid "substr: length %g is not >= 0" +msgstr "substr: lengte %g is niet >= 0" + +#: builtin.c:1512 +#, c-format +msgid "substr: non-integer length %g will be truncated" +msgstr "substr: lengte %g is geen integer; wordt afgekapt" + +#: builtin.c:1517 +#, c-format +msgid "substr: length %g too big for string indexing, truncating to %g" +msgstr "" +"substr: lengte %g is te groot voor stringindexering; wordt verkort tot %g" + +#: builtin.c:1529 +#, c-format +msgid "substr: start index %g is invalid, using 1" +msgstr "substr: startindex %g is ongeldig; 1 wordt gebruikt" + +#: builtin.c:1534 +#, c-format +msgid "substr: non-integer start index %g will be truncated" +msgstr "substr: startindex %g is geen integer; wordt afgekapt" + +#: builtin.c:1559 +msgid "substr: source string is zero length" +msgstr "substr: bronstring heeft lengte nul" + +#: builtin.c:1575 +#, c-format +msgid "substr: start index %g is past end of string" +msgstr "substr: startindex %g ligt voorbij het einde van de string" + +#: builtin.c:1583 +#, c-format +msgid "" +"substr: length %g at start index %g exceeds length of first argument (%lu)" +msgstr "" +"substr: lengte %g bij startindex %g is groter dan de lengte van het eerste " +"argument (%lu)" + +#: builtin.c:1657 +msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" +msgstr "strftime: opmaakwaarde in PROCINFO[\"strftime\"] is numeriek" + +#: builtin.c:1680 +msgid "strftime: received non-numeric second argument" +msgstr "strftime: tweede argument is geen getal" + +#: builtin.c:1683 +msgid "strftime: second argument less than 0 or too big for time_t" +msgstr "strftime: tweede argument is kleiner dan nul of te groot voor 'time_t'" + +#: builtin.c:1690 +msgid "strftime: received non-string first argument" +msgstr "strftime: eerste argument is geen string" + +#: builtin.c:1696 +msgid "strftime: received empty format string" +msgstr "strftime: opmaakstring is leeg" + +#: builtin.c:1762 +msgid "mktime: received non-string argument" +msgstr "mktime: argument is geen string" + +#: builtin.c:1779 +msgid "mktime: at least one of the values is out of the default range" +msgstr "mktime: minstens één van waarden valt buiten het standaardbereik" + +#: builtin.c:1814 +msgid "'system' function not allowed in sandbox mode" +msgstr "'system'-functie is niet toegestaan in sandbox-modus" + +#: builtin.c:1819 +msgid "system: received non-string argument" +msgstr "system: argument is geen string" + +#: builtin.c:1874 eval.c:1159 eval.c:1790 eval.c:1803 +#, c-format +msgid "reference to uninitialized variable `%s'" +msgstr "verwijzing naar ongeïnitialiseerde variabele '%s'" + +#: builtin.c:1941 +#, c-format +msgid "reference to uninitialized field `$%d'" +msgstr "verwijzing naar ongeïnitialiseerd veld '$%d'" + +#: builtin.c:2028 +msgid "tolower: received non-string argument" +msgstr "tolower: argument is geen string" + +#: builtin.c:2062 +msgid "toupper: received non-string argument" +msgstr "toupper: argument is geen string" + +#: builtin.c:2098 +msgid "atan2: received non-numeric first argument" +msgstr "atan2: eerste argument is geen getal" + +#: builtin.c:2100 +msgid "atan2: received non-numeric second argument" +msgstr "atan2: tweede argument is geen getal" + +#: builtin.c:2119 +msgid "sin: received non-numeric argument" +msgstr "sin: argument is geen getal" + +#: builtin.c:2135 +msgid "cos: received non-numeric argument" +msgstr "cos: argument is geen getal" + +#: builtin.c:2188 +msgid "srand: received non-numeric argument" +msgstr "srand: argument is geen getal" + +#: builtin.c:2219 +msgid "match: third argument is not an array" +msgstr "match: derde argument is geen array" + +#: builtin.c:2483 +msgid "gensub: third argument of 0 treated as 1" +msgstr "gensub: derde argument is 0; wordt beschouwd als 1" + +#: builtin.c:2776 +msgid "lshift: received non-numeric first argument" +msgstr "lshift: eerste argument is geen getal" + +#: builtin.c:2778 +msgid "lshift: received non-numeric second argument" +msgstr "lshift: tweede argument is geen getal" + +#: builtin.c:2784 +#, c-format +msgid "lshift(%lf, %lf): negative values will give strange results" +msgstr "lshift(%lf, %lf): negatieve waarden geven rare resultaten" + +#: builtin.c:2786 +#, c-format +msgid "lshift(%lf, %lf): fractional values will be truncated" +msgstr "lshift(%lf, %lf): cijfers na de komma worden afgekapt" + +#: builtin.c:2788 +#, c-format +msgid "lshift(%lf, %lf): too large shift value will give strange results" +msgstr "lshift(%lf, %lf): te grote opschuifwaarden geven rare resultaten" + +#: builtin.c:2813 +msgid "rshift: received non-numeric first argument" +msgstr "rshift: eerste argument is geen getal" + +#: builtin.c:2815 +msgid "rshift: received non-numeric second argument" +msgstr "rshift: tweede argument is geen getal" + +#: builtin.c:2821 +#, c-format +msgid "rshift(%lf, %lf): negative values will give strange results" +msgstr "rshift(%lf, %lf): negatieve waarden geven rare resultaten" + +#: builtin.c:2823 +#, c-format +msgid "rshift(%lf, %lf): fractional values will be truncated" +msgstr "rshift(%lf, %lf): cijfers na de komma worden afgekapt" + +#: builtin.c:2825 +#, c-format +msgid "rshift(%lf, %lf): too large shift value will give strange results" +msgstr "rshift(%lf, %lf): te grote opschuifwaarden geven rare resultaten" + +#: builtin.c:2850 +msgid "and: received non-numeric first argument" +msgstr "and: eerste argument is geen getal" + +#: builtin.c:2852 +msgid "and: received non-numeric second argument" +msgstr "and: tweede argument is geen getal" + +#: builtin.c:2858 +#, c-format +msgid "and(%lf, %lf): negative values will give strange results" +msgstr "and(%lf, %lf): negatieve waarden geven rare resultaten" + +#: builtin.c:2860 +#, c-format +msgid "and(%lf, %lf): fractional values will be truncated" +msgstr "and(%lf, %lf): cijfers na de komma worden afgekapt" + +#: builtin.c:2885 +msgid "or: received non-numeric first argument" +msgstr "or: eerste argument is geen getal" + +#: builtin.c:2887 +msgid "or: received non-numeric second argument" +msgstr "or: tweede argument is geen getal" + +#: builtin.c:2893 +#, c-format +msgid "or(%lf, %lf): negative values will give strange results" +msgstr "or(%lf, %lf): negatieve waarden geven rare resultaten" + +#: builtin.c:2895 +#, c-format +msgid "or(%lf, %lf): fractional values will be truncated" +msgstr "or(%lf, %lf): cijfers na de komma worden afgekapt" + +#: builtin.c:2923 +msgid "xor: received non-numeric first argument" +msgstr "xor: eerste argument is geen getal" + +#: builtin.c:2925 +msgid "xor: received non-numeric second argument" +msgstr "xor: tweede argument is geen getal" + +#: builtin.c:2931 +#, c-format +msgid "xor(%lf, %lf): negative values will give strange results" +msgstr "xor(%lf, %lf): negatieve waarden geven rare resultaten" + +#: builtin.c:2933 +#, c-format +msgid "xor(%lf, %lf): fractional values will be truncated" +msgstr "xor(%lf, %lf): cijfers na de komma worden afgekapt" + +#: builtin.c:2957 builtin.c:2963 +msgid "compl: received non-numeric argument" +msgstr "compl: argument is geen getal" + +#: builtin.c:2965 +#, c-format +msgid "compl(%lf): negative value will give strange results" +msgstr "compl(%lf): negatieve waarden geven rare resultaten" + +#: builtin.c:2967 +#, c-format +msgid "compl(%lf): fractional value will be truncated" +msgstr "compl(%lf): cijfers na de komma worden afgekapt" + +#: builtin.c:3136 +#, c-format +msgid "dcgettext: `%s' is not a valid locale category" +msgstr "dcgettext: '%s' is geen geldige taalregio-deelcategorie" + +#: eval.c:412 +#, c-format +msgid "unknown nodetype %d" +msgstr "onbekend knooptype %d" + +#: eval.c:423 eval.c:437 +#, c-format +msgid "unknown opcode %d" +msgstr "onbekende opcode %d" + +#: eval.c:434 +#, c-format +msgid "opcode %s not an operator or keyword" +msgstr "opcode %s is geen operator noch sleutelwoord" + +#: eval.c:488 +msgid "buffer overflow in genflags2str" +msgstr "bufferoverloop in genflags2str()" + +#: eval.c:698 +#, c-format +msgid "" +"\n" +"\t# Function Call Stack:\n" +"\n" +msgstr "" +"\n" +"\t# Functieaanroepen-stack:\n" +"\n" + +#: eval.c:725 +msgid "`IGNORECASE' is a gawk extension" +msgstr "'IGNORECASE' is een gawk-uitbreiding" + +#: eval.c:754 +msgid "`BINMODE' is a gawk extension" +msgstr "'BINMODE' is een gawk-uitbreiding" + +#: eval.c:812 +#, c-format +msgid "BINMODE value `%s' is invalid, treated as 3" +msgstr "BINMODE-waarde '%s' is ongeldig, wordt behandeld als 3" + +#: eval.c:902 +#, c-format +msgid "bad `%sFMT' specification `%s'" +msgstr "onjuiste opgave van '%sFMT': '%s'" + +#: eval.c:980 +msgid "turning off `--lint' due to assignment to `LINT'" +msgstr "'--lint' wordt uitgeschakeld wegens toewijzing aan 'LINT'" + +#: eval.c:1127 eval.c:1777 +#, c-format +msgid "can't use function name `%s' as variable or array" +msgstr "kan functienaam '%s' niet als variabele of array gebruiken" + +#: eval.c:1158 eval.c:1789 eval.c:1802 +#, c-format +msgid "reference to uninitialized argument `%s'" +msgstr "verwijzing naar ongeïnitialiseerd argument '%s'" + +#: eval.c:1177 +msgid "attempt to field reference from non-numeric value" +msgstr "veldverwijzingspoging via een waarde die geen getal is" + +#: eval.c:1179 +msgid "attempt to field reference from null string" +msgstr "veldverwijzingspoging via een lege string" + +#: eval.c:1185 +#, c-format +msgid "attempt to access field %ld" +msgstr "toegangspoging tot veld %ld" + +#: eval.c:1194 +#, c-format +msgid "reference to uninitialized field `$%ld'" +msgstr "verwijzing naar ongeïnitialiseerd veld '$%ld'" + +#: eval.c:1256 +#, c-format +msgid "function `%s' called with more arguments than declared" +msgstr "functie '%s' aangeroepen met meer argumenten dan gedeclareerd" + +#: eval.c:1437 +#, c-format +msgid "unwind_stack: unexpected type `%s'" +msgstr "unwind_stack(): onverwacht type '%s'" + +#: eval.c:1532 +msgid "division by zero attempted in `/='" +msgstr "deling door nul in '/='" + +#: eval.c:1539 +#, c-format +msgid "division by zero attempted in `%%='" +msgstr "deling door nul in '%%='" + +#: eval.c:1876 eval.c:2122 +#, c-format +msgid "attempt to use array `%s[\"%.*s\"]' in a scalar context" +msgstr "array '%s[\"%.*s\"]' wordt gebruikt in een scalaire context" + +#: eval.c:1907 +msgid "assignment used in conditional context" +msgstr "toewijzing wordt gebruikt in een conditionele context" + +#: eval.c:1911 +msgid "statement has no effect" +msgstr "opdracht heeft geen effect" + +#: eval.c:2343 +#, c-format +msgid "for loop: array `%s' changed size from %ld to %ld during loop execution" +msgstr "" +"for: array '%s' veranderde van grootte %ld naar %ld tijdens uitvoer van de " +"lus" + +#: eval.c:2458 +#, c-format +msgid "function called indirectly through `%s' does not exist" +msgstr "indirect (via '%s') aangeroepen functie bestaat niet" + +#: eval.c:2470 +#, c-format +msgid "function `%s' not defined" +msgstr "functie '%s' is niet gedefinieerd" + +#: eval.c:2511 +#, c-format +msgid "non-redirected `getline' invalid inside `%s' rule" +msgstr "niet-omgeleide 'getline' is ongeldig binnen een '%s'-regel" + +#: eval.c:2600 +#, c-format +msgid "error reading input file `%s': %s" +msgstr "fout tijdens lezen van invoerbestand '%s': %s" + +#: eval.c:2614 +#, c-format +msgid "`nextfile' cannot be called from a `%s' rule" +msgstr "'nextfile' kan niet aangeroepen worden in een '%s'-regel" + +#: eval.c:2661 +msgid "`exit' cannot be called in the current context" +msgstr "'exit' kan niet aangeroepen worden in de huidige context" + +#: eval.c:2700 +#, c-format +msgid "`next' cannot be called from a `%s' rule" +msgstr "'next' kan niet aangeroepen worden in een '%s'-regel" + +#: eval.c:2766 +#, c-format +msgid "Sorry, don't know how to interpret `%s'" +msgstr "Kan '%s' niet interpreteren" + +#: ext.c:54 +msgid "extensions are not allowed in sandbox mode" +msgstr "uitbreidingen zijn niet toegestaan in sandbox-modus" + +#: ext.c:60 ext.c:65 +msgid "`extension' is a gawk extension" +msgstr "'extension' is een gawk-uitbreiding" + +#: ext.c:75 +#, c-format +msgid "fatal: extension: cannot open `%s' (%s)\n" +msgstr "fatale fout: extension: kan '%s' niet openen (%s)\n" + +#: ext.c:84 +#, c-format +msgid "" +"fatal: extension: library `%s': does not define " +"`plugin_is_GPL_compatible' (%s)\n" +msgstr "" +"fatale fout: extension: bibliotheek '%s': definieert " +"'plugin_is_GPL_compatible' niet (%s)\n" + +#: ext.c:93 +#, c-format +msgid "fatal: extension: library `%s': cannot call function `%s' (%s)\n" +msgstr "" +"fatale fout: extension: bibliotheek '%s': kan functie '%s' niet aanroepen " +"(%s)\n" + +#: ext.c:127 +msgid "extension: missing function name" +msgstr "extension: ontbrekende functienaam" + +#: ext.c:132 +#, c-format +msgid "extension: illegal character `%c' in function name `%s'" +msgstr "extension: ongeldig teken '%c' in functienaam '%s'" + +#: ext.c:141 +#, c-format +msgid "extension: can't redefine function `%s'" +msgstr "extension: kan functie '%s' niet herdefiniëren" + +#: ext.c:145 +#, c-format +msgid "extension: function `%s' already defined" +msgstr "extension: functie '%s' is al gedefinieerd" + +#: ext.c:150 +#, c-format +msgid "extension: function name `%s' previously defined" +msgstr "extension: functienaam '%s' is al eerder gedefinieerd" + +#: ext.c:152 +#, c-format +msgid "extension: can't use gawk built-in `%s' as function name" +msgstr "extension: kan in gawk ingebouwde '%s' niet als functienaam gebruiken" + +#: ext.c:156 +#, c-format +msgid "make_builtin: negative argument count for function `%s'" +msgstr "make_builtin: negatief aantal argumenten voor functie '%s'" + +#: ext.c:259 +#, c-format +msgid "function `%s' defined to take no more than %d argument(s)" +msgstr "" +"functie '%s' is gedefinieerd om niet meer dan %d argument(en) te accepteren" + +#: ext.c:262 +#, c-format +msgid "function `%s': missing argument #%d" +msgstr "functie '%s': ontbrekend argument #%d" + +#: ext.c:279 +#, c-format +msgid "function `%s': argument #%d: attempt to use scalar as an array" +msgstr "functie '%s': argument #%d: een scalair wordt gebruikt als array" + +#: ext.c:283 +#, c-format +msgid "function `%s': argument #%d: attempt to use array as a scalar" +msgstr "functie '%s': argument #%d: een array wordt gebruikt als scalair" + +#: ext.c:296 +msgid "Operation Not Supported" +msgstr "Actie wordt niet ondersteund" + +#: field.c:328 +msgid "NF set to negative value" +msgstr "NF is op een negatieve waarde gezet" + +#: field.c:951 field.c:958 field.c:962 +msgid "split: fourth argument is a gawk extension" +msgstr "split: vierde argument is een gawk-uitbreiding" + +#: field.c:955 +msgid "split: fourth argument is not an array" +msgstr "split: vierde argument is geen array" + +#: field.c:969 +msgid "split: second argument is not an array" +msgstr "split: tweede argument is geen array" + +#: field.c:973 +msgid "split: cannot use the same array for second and fourth args" +msgstr "" +"split: hetzelfde array kan niet zowel als tweede als als vierde argument " +"gebruikt worden" + +#: field.c:978 +msgid "split: cannot use a subarray of second arg for fourth arg" +msgstr "" +"split: een subarray van het tweede argument kan niet als vierde argument " +"gebruikt worden" + +#: field.c:981 +msgid "split: cannot use a subarray of fourth arg for second arg" +msgstr "" +"split: een subarray van het vierde argument kan niet als tweede argument " +"gebruikt worden" + +#: field.c:1010 +msgid "split: null string for third arg is a gawk extension" +msgstr "split: lege string als derde argument is een gawk-uitbreiding" + +#: field.c:1050 +msgid "patsplit: fourth argument is not an array" +msgstr "patsplit: vierde argument is geen array" + +#: field.c:1055 +msgid "patsplit: second argument is not an array" +msgstr "patsplit: tweede argument is geen array" + +#: field.c:1061 +msgid "patsplit: third argument must be non-null" +msgstr "patsplit: derde argument moet niet-nil zijn" + +#: field.c:1065 +msgid "patsplit: cannot use the same array for second and fourth args" +msgstr "" +"patsplit: hetzelfde array kan niet zowel als tweede als als vierde argument " +"gebruikt worden" + +#: field.c:1070 +msgid "patsplit: cannot use a subarray of second arg for fourth arg" +msgstr "" +"patsplit: een subarray van het tweede argument kan niet als vierde argument " +"gebruikt worden" + +#: field.c:1073 +msgid "patsplit: cannot use a subarray of fourth arg for second arg" +msgstr "" +"patsplit: een subarray van het vierde argument kan niet als tweede argument " +"gebruikt worden" + +#: field.c:1110 +msgid "`FIELDWIDTHS' is a gawk extension" +msgstr "'FIELDWIDTHS' is een gawk-uitbreiding" + +#: field.c:1173 +#, c-format +msgid "invalid FIELDWIDTHS value, near `%s'" +msgstr "ongeldige waarde voor FIELDWIDTHS, nabij '%s'" + +#: field.c:1246 +msgid "null string for `FS' is a gawk extension" +msgstr "een lege string als 'FS' is een gawk-uitbreiding" + +#: field.c:1250 +msgid "old awk does not support regexps as value of `FS'" +msgstr "oude 'awk' staat geen reguliere expressies toe als waarde van 'FS'" + +#: field.c:1369 +msgid "`FPAT' is a gawk extension" +msgstr "'FPAT' is een gawk-uitbreiding" + +#: getopt.c:604 getopt.c:633 +#, fuzzy, c-format +msgid "%s: option '%s' is ambiguous; possibilities:" +msgstr "%s: optie '%s' is niet eenduidig\n" + +#: getopt.c:679 getopt.c:683 +#, c-format +msgid "%s: option '--%s' doesn't allow an argument\n" +msgstr "%s: optie '--%s' staat geen argument toe\n" + +#: getopt.c:692 getopt.c:697 +#, c-format +msgid "%s: option '%c%s' doesn't allow an argument\n" +msgstr "%s: optie '%c%s' staat geen argument toe\n" + +#: getopt.c:740 getopt.c:759 +#, c-format +msgid "%s: option '--%s' requires an argument\n" +msgstr "%s: optie '--%s' vereist een argument\n" + +#: getopt.c:797 getopt.c:800 +#, c-format +msgid "%s: unrecognized option '--%s'\n" +msgstr "%s: onbekende optie '--%s'\n" + +#: getopt.c:808 getopt.c:811 +#, c-format +msgid "%s: unrecognized option '%c%s'\n" +msgstr "%s: onbekende optie '%c%s'\n" + +#: getopt.c:860 getopt.c:863 +#, c-format +msgid "%s: invalid option -- '%c'\n" +msgstr "%s: ongeldige optie -- '%c'\n" + +#: getopt.c:916 getopt.c:933 getopt.c:1143 getopt.c:1161 +#, c-format +msgid "%s: option requires an argument -- '%c'\n" +msgstr "%s: optie vereist een argument -- '%c'\n" + +#: getopt.c:989 getopt.c:1005 +#, c-format +msgid "%s: option '-W %s' is ambiguous\n" +msgstr "%s: optie '-W %s' is niet eenduidig\n" + +#: getopt.c:1029 getopt.c:1047 +#, c-format +msgid "%s: option '-W %s' doesn't allow an argument\n" +msgstr "%s: optie '-W %s' staat geen argument toe\n" + +#: getopt.c:1068 getopt.c:1086 +#, c-format +msgid "%s: option '-W %s' requires an argument\n" +msgstr "%s: optie '-W %s' vereist een argument\n" + +#: io.c:280 +#, c-format +msgid "command line argument `%s' is a directory: skipped" +msgstr "opdrachtregelargument '%s' is een map -- overgeslagen" + +#: io.c:283 io.c:385 +#, c-format +msgid "cannot open file `%s' for reading (%s)" +msgstr "kan bestand '%s' niet openen om te lezen (%s)" + +#: io.c:501 +#, c-format +msgid "close of fd %d (`%s') failed (%s)" +msgstr "sluiten van bestandsdescriptor %d ('%s') is mislukt (%s)" + +#: io.c:578 +msgid "redirection not allowed in sandbox mode" +msgstr "omleiding is niet toegestaan in sandbox-modus" + +#: io.c:612 +#, c-format +msgid "expression in `%s' redirection only has numeric value" +msgstr "expressie in omleiding '%s' heeft alleen een getal als waarde" + +#: io.c:618 +#, c-format +msgid "expression for `%s' redirection has null string value" +msgstr "expressie voor omleiding '%s' heeft een lege string als waarde" + +#: io.c:623 +#, c-format +msgid "filename `%s' for `%s' redirection may be result of logical expression" +msgstr "" +"bestandsnaam '%s' voor omleiding '%s' kan het resultaat zijn van een " +"logische expressie" + +#: io.c:666 +#, c-format +msgid "unnecessary mixing of `>' and `>>' for file `%.*s'" +msgstr "onnodige mix van '>' en '>>' voor bestand '%.*s'" + +#: io.c:719 +#, c-format +msgid "can't open pipe `%s' for output (%s)" +msgstr "kan pijp '%s' niet openen voor uitvoer (%s)" + +#: io.c:729 +#, c-format +msgid "can't open pipe `%s' for input (%s)" +msgstr "kan pijp '%s' niet openen voor invoer (%s)" + +#: io.c:752 +#, c-format +msgid "can't open two way pipe `%s' for input/output (%s)" +msgstr "kan tweerichtings-pijp '%s' niet openen voor in- en uitvoer (%s)" + +#: io.c:834 +#, c-format +msgid "can't redirect from `%s' (%s)" +msgstr "kan niet omleiden van '%s' (%s)" + +#: io.c:837 +#, c-format +msgid "can't redirect to `%s' (%s)" +msgstr "kan niet omleiden naar '%s' (%s)" + +#: io.c:888 +msgid "" +"reached system limit for open files: starting to multiplex file descriptors" +msgstr "" +"systeemgrens voor aantal open bestanden is bereikt: begonnen met multiplexen" + +#: io.c:904 +#, c-format +msgid "close of `%s' failed (%s)." +msgstr "sluiten van '%s' is mislukt (%s)" + +#: io.c:912 +msgid "too many pipes or input files open" +msgstr "te veel pijpen of invoerbestanden geopend" + +#: io.c:934 +msgid "close: second argument must be `to' or `from'" +msgstr "close: tweede argument moet 'to' of 'from' zijn" + +#: io.c:951 +#, c-format +msgid "close: `%.*s' is not an open file, pipe or co-process" +msgstr "close: '%.*s' is geen open bestand, pijp, of co-proces" + +#: io.c:956 +msgid "close of redirection that was never opened" +msgstr "sluiten van een nooit-geopende omleiding" + +#: io.c:1053 +#, c-format +msgid "close: redirection `%s' not opened with `|&', second argument ignored" +msgstr "" +"close: omleiding '%s' is niet geopend met '|&'; tweede argument wordt " +"genegeerd" + +#: io.c:1069 +#, c-format +msgid "failure status (%d) on pipe close of `%s' (%s)" +msgstr "afsluitwaarde %d bij mislukte sluiting van pijp '%s' (%s)" + +#: io.c:1072 +#, c-format +msgid "failure status (%d) on file close of `%s' (%s)" +msgstr "afsluitwaarde %d bij mislukte sluiting van bestand '%s' (%s)" + +#: io.c:1092 +#, c-format +msgid "no explicit close of socket `%s' provided" +msgstr "geen expliciete sluiting van socket '%s' aangegeven" + +#: io.c:1095 +#, c-format +msgid "no explicit close of co-process `%s' provided" +msgstr "geen expliciete sluiting van co-proces '%s' aangegeven" + +#: io.c:1098 +#, c-format +msgid "no explicit close of pipe `%s' provided" +msgstr "geen expliciete sluiting van pijp '%s' aangegeven" + +#: io.c:1101 +#, c-format +msgid "no explicit close of file `%s' provided" +msgstr "geen expliciete sluiting van bestand '%s' aangegeven" + +#: io.c:1129 io.c:1184 main.c:794 main.c:831 +#, c-format +msgid "error writing standard output (%s)" +msgstr "fout tijdens schrijven van standaarduitvoer (%s)" + +#: io.c:1133 io.c:1189 +#, c-format +msgid "error writing standard error (%s)" +msgstr "fout tijdens schrijven van standaardfoutuitvoer (%s)" + +#: io.c:1141 +#, c-format +msgid "pipe flush of `%s' failed (%s)." +msgstr "leegmaken van pijp '%s' is mislukt (%s)" + +#: io.c:1144 +#, c-format +msgid "co-process flush of pipe to `%s' failed (%s)." +msgstr "leegmaken door co-proces van pijp naar '%s' is mislukt (%s)" + +#: io.c:1147 +#, c-format +msgid "file flush of `%s' failed (%s)." +msgstr "leegmaken van bestand '%s' is mislukt (%s)" + +#: io.c:1262 +#, c-format +msgid "local port %s invalid in `/inet'" +msgstr "lokale poort %s is ongeldig in '/inet'" + +#: io.c:1279 +#, c-format +msgid "remote host and port information (%s, %s) invalid" +msgstr "host- en poortinformatie (%s, %s) zijn ongeldig" + +#: io.c:1431 +#, c-format +msgid "no (known) protocol supplied in special filename `%s'" +msgstr "geen (bekend) protocol aangegeven in speciale bestandsnaam '%s'" + +#: io.c:1445 +#, c-format +msgid "special file name `%s' is incomplete" +msgstr "speciale bestandsnaam '%s' is onvolledig" + +#: io.c:1462 +msgid "must supply a remote hostname to `/inet'" +msgstr "'/inet' heeft een gindse hostnaam nodig" + +#: io.c:1480 +msgid "must supply a remote port to `/inet'" +msgstr "'/inet' heeft een gindse poort nodig" + +#: io.c:1526 +msgid "TCP/IP communications are not supported" +msgstr "TCP/IP-communicatie wordt niet ondersteund" + +#: io.c:1693 +#, c-format +msgid "could not open `%s', mode `%s'" +msgstr "kan '%s' niet openen -- modus '%s'" + +#: io.c:1747 +#, c-format +msgid "close of master pty failed (%s)" +msgstr "kan meester-pty van dochterproces niet sluiten (%s)" + +#: io.c:1749 io.c:1917 io.c:2074 +#, c-format +msgid "close of stdout in child failed (%s)" +msgstr "kan standaarduitvoer van dochterproces niet sluiten (%s)" + +#: io.c:1752 +#, c-format +msgid "moving slave pty to stdout in child failed (dup: %s)" +msgstr "" +"kan slaaf-pty niet overzetten naar standaarduitvoer van dochterproces (dup: " +"%s)" + +#: io.c:1754 io.c:1922 +#, c-format +msgid "close of stdin in child failed (%s)" +msgstr "kan standaardinvoer van dochterproces niet sluiten (%s)" + +#: io.c:1757 +#, c-format +msgid "moving slave pty to stdin in child failed (dup: %s)" +msgstr "" +"kan slaaf-pty niet overzetten naar standaardinvoer van dochterproces (dup: " +"%s)" + +#: io.c:1759 io.c:1780 +#, c-format +msgid "close of slave pty failed (%s)" +msgstr "kan slaaf-pty niet sluiten (%s)" + +#: io.c:1858 io.c:1920 io.c:2052 io.c:2077 +#, c-format +msgid "moving pipe to stdout in child failed (dup: %s)" +msgstr "" +"kan pijp niet overzetten naar standaarduitvoer van dochterproces (dup: %s)" + +#: io.c:1865 io.c:1925 +#, c-format +msgid "moving pipe to stdin in child failed (dup: %s)" +msgstr "" +"kan pijp niet overzetten naar standaardinvoer van dochterproces (dup: %s)" + +#: io.c:1885 io.c:2067 +msgid "restoring stdout in parent process failed\n" +msgstr "kan standaarduitvoer van ouderproces niet herstellen\n" + +#: io.c:1893 +msgid "restoring stdin in parent process failed\n" +msgstr "kan standaardinvoer van ouderproces niet herstellen\n" + +#: io.c:1928 io.c:2079 io.c:2093 +#, c-format +msgid "close of pipe failed (%s)" +msgstr "kan pijp niet sluiten (%s)" + +#: io.c:1973 +msgid "`|&' not supported" +msgstr "'|&' wordt niet ondersteund" + +#: io.c:2039 +#, c-format +msgid "cannot open pipe `%s' (%s)" +msgstr "kan pijp '%s' niet openen (%s)" + +#: io.c:2087 +#, c-format +msgid "cannot create child process for `%s' (fork: %s)" +msgstr "kan voor '%s' geen dochterproces starten (fork: %s)" + +#: io.c:2520 +#, c-format +msgid "data file `%s' is empty" +msgstr "databestand '%s' is leeg" + +#: io.c:2561 io.c:2569 +msgid "could not allocate more input memory" +msgstr "kan geen extra invoergeheugen meer toewijzen" + +#: io.c:3127 +msgid "multicharacter value of `RS' is a gawk extension" +msgstr "een 'RS' van meerdere tekens is een gawk-uitbreiding" + +#: io.c:3232 +msgid "IPv6 communication is not supported" +msgstr "IPv6-communicatie wordt niet ondersteund" + +#: main.c:366 +msgid "`-m[fr]' option irrelevant in gawk" +msgstr "optie '-m[fr]' is irrelevant in gawk" + +#: main.c:368 +msgid "-m option usage: `-m[fr] nnn'" +msgstr "gebruikswijze van optie -m: '-m[fr] nnn'" + +#: main.c:391 +msgid "empty argument to `-e/--source' ignored" +msgstr "argument van '-e/--source' is leeg; genegeerd" + +#: main.c:462 +#, c-format +msgid "%s: option `-W %s' unrecognized, ignored\n" +msgstr "%s: optie '-W %s' is onbekend; genegeerd\n" + +#: main.c:515 +#, c-format +msgid "%s: option requires an argument -- %c\n" +msgstr "%s: optie vereist een argument -- %c\n" + +#: main.c:536 +msgid "environment variable `POSIXLY_CORRECT' set: turning on `--posix'" +msgstr "omgevingsvariabele 'POSIXLY_CORRECT' is gezet: '--posix' ingeschakeld" + +#: main.c:542 +msgid "`--posix' overrides `--traditional'" +msgstr "'--posix' overstijgt '--traditional'" + +#: main.c:553 +msgid "`--posix'/`--traditional' overrides `--non-decimal-data'" +msgstr "'--posix'/'--traditional' overstijgen '--non-decimal-data'" + +#: main.c:557 +#, c-format +msgid "running %s setuid root may be a security problem" +msgstr "het uitvoeren van %s als 'setuid root' kan een veiligheidsrisico zijn" + +#: main.c:562 +msgid "`--posix' overrides `--binary'" +msgstr "'--posix' overstijgt '--binary'" + +#: main.c:613 +#, c-format +msgid "can't set binary mode on stdin (%s)" +msgstr "kan standaardinvoer niet in binaire modus zetten (%s)" + +#: main.c:616 +#, c-format +msgid "can't set binary mode on stdout (%s)" +msgstr "kan standaarduitvoer niet in binaire modus zetten (%s)" + +#: main.c:618 +#, c-format +msgid "can't set binary mode on stderr (%s)" +msgstr "kan standaardfoutuitvoer niet in binaire modus zetten (%s)" + +#: main.c:657 +msgid "no program text at all!" +msgstr "helemaal geen programmatekst!" + +#: main.c:734 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] -f progfile [--] file ...\n" +msgstr "Gebruik: %s [opties] -f programmabestand [--] bestand...\n" + +#: main.c:736 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] [--] %cprogram%c file ...\n" +msgstr "" +" of: %s [opties] [--] %cprogrammatekst%c bestand...\n" +"\n" + +#: main.c:741 +msgid "POSIX options:\t\tGNU long options: (standard)\n" +msgstr "\tPOSIX-opties:\t\tEquivalente GNU-opties: (standaard)\n" + +#: main.c:742 +msgid "\t-f progfile\t\t--file=progfile\n" +msgstr "\t-f programmabestand\t--file=programmabestand\n" + +#: main.c:743 +msgid "\t-F fs\t\t\t--field-separator=fs\n" +msgstr "\t-F veldscheidingsteken\t--field-separator=veldscheidingsteken\n" + +#: main.c:744 +msgid "\t-v var=val\t\t--assign=var=val\n" +msgstr "" +"\t-v var=waarde\t\t--assign=var=waarde\n" +"\n" + +#: main.c:745 +msgid "Short options:\t\tGNU long options: (extensions)\n" +msgstr "\tKorte opties:\t\tEquivalente GNU-opties: (uitbreidingen)\n" + +#: main.c:746 +msgid "\t-b\t\t\t--characters-as-bytes\n" +msgstr "\t-b\t\t\t--characters-as-bytes\n" + +#: main.c:747 +msgid "\t-c\t\t\t--traditional\n" +msgstr "\t-c\t\t\t--traditional\n" + +#: main.c:748 +msgid "\t-C\t\t\t--copyright\n" +msgstr "\t-C\t\t\t--copyright\n" + +#: main.c:749 +msgid "\t-d[file]\t\t--dump-variables[=file]\n" +msgstr "\t-d[bestand]\t\t--dump-variables[=bestand]\n" + +#: main.c:750 +msgid "\t-e 'program-text'\t--source='program-text'\n" +msgstr "\t-e 'programmatekst'\t--source='programmatekst'\n" + +#: main.c:751 +msgid "\t-E file\t\t\t--exec=file\n" +msgstr "\t-E bestand\t\t--exec=bestand\n" + +#: main.c:752 +msgid "\t-g\t\t\t--gen-pot\n" +msgstr "\t-g\t\t\t--gen-pot\n" + +#: main.c:753 +msgid "\t-h\t\t\t--help\n" +msgstr "\t-h\t\t\t--help\n" + +#: main.c:754 +msgid "\t-L [fatal]\t\t--lint[=fatal]\n" +msgstr "\t-L [fataal]\t\t--lint[=fataal]\n" + +#: main.c:755 +msgid "\t-n\t\t\t--non-decimal-data\n" +msgstr "\t-n\t\t\t--non-decimal-data\n" + +#: main.c:756 +msgid "\t-N\t\t\t--use-lc-numeric\n" +msgstr "\t-N\t\t\t--use-lc-numeric\n" + +#: main.c:757 +msgid "\t-O\t\t\t--optimize\n" +msgstr "\t-O\t\t\t--optimize\n" + +#: main.c:758 +msgid "\t-p[file]\t\t--profile[=file]\n" +msgstr "\t-p[bestand]\t\t--profile[=bestand]\n" + +#: main.c:759 +msgid "\t-P\t\t\t--posix\n" +msgstr "\t-P\t\t\t--posix\n" + +#: main.c:760 +msgid "\t-r\t\t\t--re-interval\n" +msgstr "\t-r\t\t\t--re-interval\n" + +#: main.c:762 +msgid "\t-R file\t\t\t--command=file\n" +msgstr "\t-R bestand\t\t\t--command=bestand\n" + +#: main.c:763 +msgid "\t-S\t\t\t--sandbox\n" +msgstr "\t-S\t\t\t--sandbox\n" + +#: main.c:764 +msgid "\t-t\t\t\t--lint-old\n" +msgstr "\t-t\t\t\t--lint-old\n" + +#: main.c:765 +msgid "\t-V\t\t\t--version\n" +msgstr "\t-V\t\t\t--version\n" + +#: main.c:767 +msgid "\t-W nostalgia\t\t--nostalgia\n" +msgstr "\t-W nostalgia\t\t\t--nostalgia\n" + +#: main.c:770 +msgid "\t-Y\t\t--parsedebug\n" +msgstr "\t-Y\t\t\t--parsedebug\n" + +#. TRANSLATORS: --help output 5 (end) +#. TRANSLATORS: the placeholder indicates the bug-reporting address +#. for this application. Please add _another line_ with the +#. address for translation bugs. +#. no-wrap +#: main.c:779 +msgid "" +"\n" +"To report bugs, see node `Bugs' in `gawk.info', which is\n" +"section `Reporting Problems and Bugs' in the printed version.\n" +"\n" +msgstr "" +"\n" +"Voor het rapporteren van programmagebreken, zie 'info gawk bugs'\n" +"of de sectie 'Reporting Problems and Bugs' in de gedrukte versie.\n" +"Meld fouten in de vertaling aan .\n" +"\n" + +#: main.c:783 +msgid "" +"gawk is a pattern scanning and processing language.\n" +"By default it reads standard input and writes standard output.\n" +"\n" +msgstr "" +"'gawk' is een patroonherkennings- en bewerkingsprogramma.\n" +"Standaard leest het van standaardinvoer en schrijft naar standaarduitvoer.\n" +"\n" + +#: main.c:787 +msgid "" +"Examples:\n" +"\tgawk '{ sum += $1 }; END { print sum }' file\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" +msgstr "" +"Voorbeelden:\n" +"\tgawk '{ som += $1 }; END { print som }' bestand\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" + +#: main.c:807 +#, c-format +msgid "" +"Copyright (C) 1989, 1991-%d Free Software Foundation.\n" +"\n" +"This program is free software; you can redistribute it and/or modify\n" +"it under the terms of the GNU General Public License as published by\n" +"the Free Software Foundation; either version 3 of the License, or\n" +"(at your option) any later version.\n" +"\n" +msgstr "" +"Copyright (C) 1989, 1991-%d Free Software Foundation.\n" +"\n" +"Dit programma is vrije software; u mag het verder verspreiden en/of\n" +"wijzigen onder de voorwaarden van de GNU General Public License zoals\n" +"uitgegeven door de Free Software Foundation, naar keuze ofwel onder\n" +"versie 3 of onder een nieuwere versie van die licentie.\n" + +#: main.c:815 +msgid "" +"This program is distributed in the hope that it will be useful,\n" +"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +"GNU General Public License for more details.\n" +"\n" +msgstr "" +"Dit programma wordt uitgegeven in de hoop dat het nuttig is,\n" +"maar ZONDER ENIGE GARANTIE; zelfs zonder de impliciete garantie\n" +"van VERKOOPBAARHEID of GESCHIKTHEID VOOR EEN BEPAALD DOEL.\n" +"Zie de GNU General Public License voor meer details.\n" +"\n" + +#: main.c:821 +msgid "" +"You should have received a copy of the GNU General Public License\n" +"along with this program. If not, see http://www.gnu.org/licenses/.\n" +msgstr "" +"Bij dit programma hoort u een kopie van de GNU General Public License\n" +"ontvangen te hebben; is dit niet het geval, dan kunt u deze licentie\n" +"ook vinden op http://www.gnu.org/licenses/.\n" + +#: main.c:856 +msgid "-Ft does not set FS to tab in POSIX awk" +msgstr "-Ft maakt van FS geen tab in POSIX-awk" + +#: main.c:1090 +#, c-format +msgid "unknown value for field spec: %d\n" +msgstr "onbekende waarde voor veldspecificatie: %d\n" + +#: main.c:1171 +#, c-format +msgid "" +"%s: `%s' argument to `-v' not in `var=value' form\n" +"\n" +msgstr "" +"%s: argument '%s' van '-v' is niet van de vorm 'var=waarde'\n" +"\n" + +#: main.c:1197 +#, c-format +msgid "`%s' is not a legal variable name" +msgstr "'%s' is geen geldige variabelenaam" + +#: main.c:1200 +#, c-format +msgid "`%s' is not a variable name, looking for file `%s=%s'" +msgstr "'%s' is geen variabelenaam; zoekend naar bestand '%s=%s'" + +#: main.c:1204 +#, c-format +msgid "cannot use gawk builtin `%s' as variable name" +msgstr "kan in gawk ingebouwde '%s' niet als variabelenaam gebruiken" + +#: main.c:1209 +#, c-format +msgid "cannot use function `%s' as variable name" +msgstr "kan functie '%s' niet als variabelenaam gebruiken" + +#: main.c:1262 +msgid "floating point exception" +msgstr "drijvendekomma-berekeningsfout" + +#: main.c:1269 +msgid "fatal error: internal error" +msgstr "fatale fout: **interne fout**" + +#: main.c:1284 +msgid "fatal error: internal error: segfault" +msgstr "fatale fout: **interne fout**: segmentatiefout" + +#: main.c:1296 +msgid "fatal error: internal error: stack overflow" +msgstr "fatale fout: **interne fout**: stack is vol" + +#: main.c:1346 +#, c-format +msgid "no pre-opened fd %d" +msgstr "geen reeds-geopende bestandsdescriptor %d" + +#: main.c:1353 +#, c-format +msgid "could not pre-open /dev/null for fd %d" +msgstr "kan /dev/null niet openen voor bestandsdescriptor %d" + +#: msg.c:63 +#, c-format +msgid "cmd. line:" +msgstr "commandoregel:" + +#: msg.c:107 +msgid "error: " +msgstr "fout: " + +#: node.c:406 +msgid "backslash at end of string" +msgstr "backslash aan het einde van de string" + +#: node.c:517 +#, c-format +msgid "old awk does not support the `\\%c' escape sequence" +msgstr "oude 'awk' kent de stuurcodereeks '\\%c' niet" + +#: node.c:568 +msgid "POSIX does not allow `\\x' escapes" +msgstr "POSIX staat stuurcode '\\x' niet toe" + +#: node.c:574 +msgid "no hex digits in `\\x' escape sequence" +msgstr "geen hex cijfers in stuurcodereeks '\\x'" + +#: node.c:596 +#, c-format +msgid "" +"hex escape \\x%.*s of %d characters probably not interpreted the way you " +"expect" +msgstr "" +"hexadecimale stuurcode \\x%.*s van %d tekens wordt waarschijnlijk niet " +"afgehandeld zoals u verwacht" + +#: node.c:611 +#, c-format +msgid "escape sequence `\\%c' treated as plain `%c'" +msgstr "stuurcodereeks '\\%c' behandeld als normale '%c'" + +#: node.c:750 +msgid "" +"Invalid multibyte data detected. There may be a mismatch between your data " +"and your locale." +msgstr "" +"Ongeldige multibyte-gegevens gevonden.\n" +"Uw gegevens passen vermoedelijk niet bij uw taalregio." + +#: posix/gawkmisc.c:176 +#, c-format +msgid "%s %s `%s': could not get fd flags: (fcntl F_GETFD: %s)" +msgstr "" +"%s %s '%s': kan bestandsdescriptorvlaggen niet verkrijgen: (fcntl F_GETFD: " +"%s)" + +#: posix/gawkmisc.c:188 +#, c-format +msgid "%s %s `%s': could not set close-on-exec: (fcntl F_SETFD: %s)" +msgstr "%s %s '%s': kan 'close-on-exec' niet activeren: (fcntl F_SETFD: %s)" + +#: profile.c:83 +#, c-format +msgid "could not open `%s' for writing: %s" +msgstr "kan '%s' niet openen om te schrijven: %s" + +#: profile.c:85 +msgid "sending profile to standard error" +msgstr "profiel gaat naar standaardfoutuitvoer" + +#: profile.c:203 +#, c-format +msgid "" +"\t# %s block(s)\n" +"\n" +msgstr "" +"\t# %s-blok(ken)\n" +"\n" + +#: profile.c:208 +#, c-format +msgid "" +"\t# Rule(s)\n" +"\n" +msgstr "" +"\t# Regel(s)\n" +"\n" + +#: profile.c:279 +#, c-format +msgid "internal error: %s with null vname" +msgstr "**interne fout**: %s heeft een lege 'vname'" + +#: profile.c:952 +#, c-format +msgid "\t# gawk profile, created %s\n" +msgstr "\t# gawk-profiel, gemaakt op %s\n" + +#: profile.c:1331 +#, c-format +msgid "" +"\n" +"\t# Functions, listed alphabetically\n" +msgstr "" +"\n" +"\t# Functies, alfabetisch geordend\n" + +#: profile.c:1370 +#, c-format +msgid "redir2str: unknown redirection type %d" +msgstr "redir2str(): onbekend omleidingstype %d" + +#: re.c:573 +#, c-format +msgid "range of the form `[%c-%c]' is locale dependent" +msgstr "" +"de betekenis van een bereik van de vorm '[%c-%c]' is afhankelijk van de " +"taalregio" + +#: re.c:600 +#, c-format +msgid "regexp component `%.*s' should probably be `[%.*s]'" +msgstr "" +"component '%.*s' van reguliere expressie moet vermoedelijk '[%.*s]' zijn" + +#: regcomp.c:131 +msgid "Success" +msgstr "Gelukt" + +#: regcomp.c:134 +msgid "No match" +msgstr "Geen overeenkomsten" + +#: regcomp.c:137 +msgid "Invalid regular expression" +msgstr "Ongeldige reguliere expressie" + +#: regcomp.c:140 +msgid "Invalid collation character" +msgstr "Ongeldig samengesteld teken" + +#: regcomp.c:143 +msgid "Invalid character class name" +msgstr "Ongeldige tekenklassenaam" + +#: regcomp.c:146 +msgid "Trailing backslash" +msgstr "Backslash aan het eind" + +#: regcomp.c:149 +msgid "Invalid back reference" +msgstr "Ongeldige terugverwijzing" + +#: regcomp.c:152 +msgid "Unmatched [ or [^" +msgstr "Ongepaarde [ of [^" + +#: regcomp.c:155 +msgid "Unmatched ( or \\(" +msgstr "Ongepaarde ( of \\(" + +#: regcomp.c:158 +msgid "Unmatched \\{" +msgstr "Ongepaarde \\{" + +#: regcomp.c:161 +msgid "Invalid content of \\{\\}" +msgstr "Ongeldige inhoud van \\{\\}" + +#: regcomp.c:164 +msgid "Invalid range end" +msgstr "Ongeldig bereikeinde" + +#: regcomp.c:167 +msgid "Memory exhausted" +msgstr "Onvoldoende geheugen beschikbaar" + +#: regcomp.c:170 +msgid "Invalid preceding regular expression" +msgstr "Ongeldige voorafgaande reguliere expressie" + +#: regcomp.c:173 +msgid "Premature end of regular expression" +msgstr "Voortijdig einde van reguliere expressie" + +#: regcomp.c:176 +msgid "Regular expression too big" +msgstr "Reguliere expressie is te groot" + +#: regcomp.c:179 +msgid "Unmatched ) or \\)" +msgstr "Ongepaarde ) of \\)" + +#: regcomp.c:700 +msgid "No previous regular expression" +msgstr "Geen eerdere reguliere expressie" + +#~ msgid "could not find groups: %s" +#~ msgstr "kan groepen niet vinden: %s" + +#~ msgid "assignment is not allowed to result of builtin function" +#~ msgstr "" +#~ "toewijzing aan het resultaat van een ingebouwde functie is niet toegestaan" + +#~ msgid "attempt to use array in a scalar context" +#~ msgstr "array wordt gebruikt in een scalaire context" + +#~ msgid "statement may have no effect" +#~ msgstr "opdracht heeft mogelijk geen effect" + +#~ msgid "out of memory" +#~ msgstr "onvoldoende geheugen beschikbaar" + +#~ msgid "attempt to use scalar `%s' as array" +#~ msgstr "scalair '%s' wordt gebruikt als array" + +#~ msgid "attempt to use array `%s' in scalar context" +#~ msgstr "array '%s' wordt gebruikt in een scalaire context" + +#~ msgid "call of `length' without parentheses is deprecated by POSIX" +#~ msgstr "aanroep van 'length' zonder haakjes wordt door POSIX afgeraden" + +#~ msgid "division by zero attempted in `/'" +#~ msgstr "deling door nul in '/'" + +#~ msgid "length: untyped parameter argument will be forced to scalar" +#~ msgstr "length: typeloos parameterargument wordt omgezet naar scalair" + +#~ msgid "length: untyped argument will be forced to scalar" +#~ msgstr "length: typeloos argument wordt omgezet naar scalair" + +#~ msgid "`break' outside a loop is not portable" +#~ msgstr "'break' buiten een lus is niet overdraagbaar" + +#~ msgid "`continue' outside a loop is not portable" +#~ msgstr "'continue' buiten een lus is niet overdraagbaar" + +#~ msgid "`next' cannot be called from a BEGIN rule" +#~ msgstr "'next' kan niet aangeroepen worden in een BEGIN-regel" + +#~ msgid "`nextfile' cannot be called from a BEGIN rule" +#~ msgstr "'nextfile' kan niet aangeroepen worden in een BEGIN-regel" + +#~ msgid "" +#~ "concatenation: side effects in one expression have changed the length of " +#~ "another!" +#~ msgstr "" +#~ "concatenation: neveneffecten in de ene expressie hebben de lengte van een " +#~ "andere veranderd!" + +#~ msgid "illegal type (%s) in tree_eval" +#~ msgstr "ongeldig type (%s) in tree_eval()" + +#~ msgid "\t# -- main --\n" +#~ msgstr "\t# -- hoofd --\n" + +#~ msgid "invalid tree type %s in redirect()" +#~ msgstr "ongeldig boomtype %s in redirect()" + +#~ msgid "/inet/raw client not ready yet, sorry" +#~ msgstr "cliënt van '/inet/raw' is nog niet klaar, sorry" + +#~ msgid "only root may use `/inet/raw'." +#~ msgstr "Alleen root mag '/inet/raw' gebruiken." + +#~ msgid "/inet/raw server not ready yet, sorry" +#~ msgstr "server van '/inet/raw' is nog niet klaar, sorry" + +#~ msgid "file `%s' is a directory" +#~ msgstr "'%s' is een map" + +#~ msgid "use `PROCINFO[\"%s\"]' instead of `%s'" +#~ msgstr "gebruik 'PROCINFO[\"%s\"]' in plaats van '%s'" + +#~ msgid "use `PROCINFO[...]' instead of `/dev/user'" +#~ msgstr "gebruik 'PROCINFO[...]' in plaats van '/dev/user'" + +#~ msgid "\t-m[fr] val\n" +#~ msgstr "\t-m[fr] waarde\n" + +#~ msgid "\t-W compat\t\t--compat\n" +#~ msgstr "\t-W compat\t\t\t--compat\n" + +#~ msgid "\t-W copyleft\t\t--copyleft\n" +#~ msgstr "\t-W copyleft\t\t\t--copyleft\n" + +#~ msgid "\t-W usage\t\t--usage\n" +#~ msgstr "\t-W usage\t\t\t--usage\n" + +#~ msgid "can't convert string to float" +#~ msgstr "kan string niet converteren naar drijvende-komma-getal" + +#~ msgid "# treated internally as `delete'" +#~ msgstr "# wordt intern behandeld als 'delete'" + +#~ msgid "# this is a dynamically loaded extension function" +#~ msgstr "# dit is een dynamisch geladen uitbreidingsfunctie" + +#~ msgid "" +#~ "\t# BEGIN block(s)\n" +#~ "\n" +#~ msgstr "" +#~ "\t# BEGIN-blok(ken)\n" +#~ "\n" + +#~ msgid "unexpected type %s in prec_level" +#~ msgstr "onverwacht type %s in prec_level()" + +#~ msgid "Unknown node type %s in pp_var" +#~ msgstr "onbekend knooptype %s in pp_var()" + +#~ msgid "can't open two way socket `%s' for input/output (%s)" +#~ msgstr "kan tweerichtings-socket '%s' niet openen voor in- en uitvoer (%s)" diff --git a/po/pl.gmo b/po/pl.gmo new file mode 100644 index 0000000000000000000000000000000000000000..549de4f7712ea65e2a140a8df9deec8fa00ad39f GIT binary patch literal 51712 zcmd6w37lkAb^jkm1v)MW8aB~415Nk9bkD-xFfhX~0|Ud%I5RN9uyl3R>+b5Vu4-zT znrc7<#Vz6zC1Ft{DiYVIhzstK(O{x6F)kon>fJ4Bi zfk%Q$_k8e3@I3Hna69-saKgWTnScH^@L4?nIQR_kOW<+f--0UlrydVGIS5qcv7pL5 z15`bifX@aa@I-J9JQchTRDE9rRnEVHG(GqQcr19>fXlxeRQ?MI2AowkCEjR*h0Z#*83aY-3g3kfJ1ghR| zd;Bq|eja*?dwwFglKV3}j)62GcrB=UJ_3f|KY>&oJe9^#M6e2^tHD*Ep1&AWJKhPZ zKi>hL5B5>G@DxzxT?(rF{oo1U{h-GAQy^J_Z-Rr+!l5L-miyJiZroo3s=prumHshM z{rE1Z`G3-?AlM5Y2c87(1J&<)L5=f!LCw=2gU5j101pEn2Q?qR1Xa#)tKIyq1($KZ z71X$wLCyc`LG|NdfB$VzfcWAP;k!Q-v)k<`*(q&uistk+V@V6ANTkr z@M*mNdvF8zeUHOT?(N*qf@gz20nY$eo$kgZ0yUmDfue(ZK=t#>pxXb>p!(BCCgoen z|3YvKRR3QBs()_J^(6;!zofX9Ge1|gN;pFy?%+2=UA zI1N;}JHR8srhon_Q2l=pWJrU@K(YqE0#)uA5U=R^I#ADF;qkMe+V=}k?Kt7wARtSy z!Q+jfo<9tV?!E!4{$GRYM?Z^KbiD&S9=r*J1cJN#^Dlx*{}WJjb;3F~KbL`O*R7!5 zzYEm({W+-d49<7+um)7UTS1M(4WP#Nbs$q7ydR|K;GaOXbNK}>{bo?(Hw|h$?gF0= z{t0*j_&reVJ$$`O-w!JPrT)GQsvmCvHSY&Nwe!c|ao}?|xbZv-RKIedp1&4c2EGea zeSZob3w|Hecs=z(*N-)z>e~UTe{~R24DJRufqw=n{c|?D^4EiX+?V}*3sk=z1T}7d z18O`DzsQw$KDeCwyuW{$$9ID#^872{^S~d0>eo?JdNeo!s=S@xN#L!Z`t=S_<$V@Z z{_ptv!#2D5KNZw`?g2GkF9yXY-VbWLzYZ$@Pr&uyu@}2>y4vGSpx)mH9twUI6kRub8`~gsO{UvY^eCifQN2@@VUN8!V;9a1`^<$v=`5li(UFzuJ zLa?9b*MX}4rQo69`@vJdkAmvow?WbAQI|Qq$YTR!NP~BPD(8Ek+ViZf$VhMm+yTyk zD(6o?NH_Q;sQDYY++hV&`nP-h4ygW}w9V1owV>$h5n^mKD4R+yg!gt^%J`8>s&O6r^cExXZP#04X4$B!dwIc@(gD(R$eh-7Ef&T=a4j%hLM-SUT(d8|m`u`xP{9ggpo*#ol;Hg)+ zbXR%26;%E21Xcf6!K1*RgGYl;zuNJoeo*!80agC1!PVfy;Mw4JLCyQ~_qy^ogKM}i zgKNS2LCxP+LAC3MYg{>JfU5sGQ0ZR*o&`Pvsy~l|s_(dKUH*+8UkqxTJ_#!SuRNZ7 zox9%wYX0WH_250A%KIkxZ16X(cjI{s$dU;z0iOZB5mZ0k1}gm*LDl~_sPR93)V;q9 z)cY!^_xFIBm(PLcfIs!PCgi3E<_k1rX`n(;~yuBYh7yK@` z0bHJUbW{LEzpn!|51#~=f&UJwT}Kog-JT6D=l%*%>Gy-jf)9Wvf}aLY0>2Ha-G@aE zF9cQZO`zKIQBdRZZBTU3H}38)@Hh^tygNXZ_W|&k;MYLW(RaZMz+ZzWgXd2;x{g4# z>y4o5`z)yU{|UnKf|Dj4Kd*Sa15`Qh1~nhw1J$16i>}@spxWC2Rqp-%`IkVA|Ks5E z!2T&m?-zku7gM0d=`R2L*qkt%Ts2Mso?WLmAeAe`nm=j1n&e_fS&^Y`Vh(oHO`-@ zIQ$Bz@%snxNbt~EuZM%`_ge6|;0yfoGN}H%3>5v}1s(@J2p$3ck;kus$8-N3P~`?U zxN?pHwVqak8mCR*DzNC^-wmpq4}(t!zW}PAf92o*095{`Rb4xlfor%w4SYTrdAuFG zlluoit&4MOjvw3rUda9XK+(Z}fJ5NPbvNF-!L8gkLCJ$h!DoXwP)fa}4kka>Ry%yIvtmaF&5IoGZ^Fy#50L5<(1JpLV6=Kj~< zT5#q@x32C7)$UJ$M}hwcE(3o8YTk~y${35vi#ZI62&08Ix*aH40&tC~H1MdVy4<7-a3qJWa_k0zqf+J z;1@u(|0m#j@RXOhah?WM?yEud<9(pk*iaZ!Hux{# zdEm0!-8fzcs=nJmt)~xzD)+mf%6rPo9G(S=9~8k0!8d@%fL{YQgFgV5gJ-_n_4g`J z^tul`8oUow`#%hx3Vt0_`=0y?*RFHGbGWa9XM*nmw}apIc-kx7e7*!6;Q9N&9pKkI z4!p{hyB{3n`P=>dm%wwm|2e4spYhvnzRTbU_pbs~-T_ek|2I(mKH=4_J=;N*_ezf+ z1XpwaO;Ggxv^(5*T>y$suk-h>22bMt-JtsU74UNKDX($kz02dv!Si|kad0d63sB`= z{92cP4(#XtE#OA*0Js4>{B;g51C{>{Q2qH+a5Z@7>s`LHL6vtMsCj=qxB~n#sB}LA z)xH(K%g_#zY$bBzTlt#4AgiJ|E`;tJ)p+%7Et-$4vIf~4OD*~2Tui8{hoWi z7Ze>f!4tuI{QalEQ@H;YsPs>}%k5{*1~qOsgC~F=1vTDZ1Gj^}0@a?acf0l20M+gf zgNK3t3Z4Z%4l3U%_c*?^1JpXX8N2}e40t*i-0S$s8KCZO0oQ{c0@a@%gC~P)-{i*s zDp2X}0M7vb2vq-m2A&BX|7JJ7JHaEk|7~z3_$E-}^%$u3{?g;{eeOO7zJTX%1VscSMJC1v+ zD{m`!Ecd?;ihe#0J_UTn+uVFS8yw~SD)1KY5m4zy-tOq`4p8IsSKtNUuRNajfE(|d zK+W5y!4tt}zQc{vY2ex1Px42F_n!yV|Fi$V)pG}^{(lM7 zIQ6~L(d`A`$=uI^nxEeT`;`t<{XYan-$%d8jmIV6Aoni@mx1pD_5M%%`(J_Qa)0`} z9Y2@_RqrRkbHHDCJpDaRUX;NRp1&Eq2>d#zaX;a`&JKHp$A`dioko;AZYW z3u>GWd&ISClgIs_*4ewkE#SX-JnQ3b9Bu_gM;`;Xf%z z&1W251+L-#R#4;q5cq8HyP(#`FG2P1gwMM6On~awUEqb_UxMqwqyNaY=Y`-4xxXD0 zz5boYCw-2+H}@xlYF`Ds0{kQ>`Z?-RXP>+nRQY#+XMvA_7lDTyaB_Y#sPT%x5%4}x z^ZgC~{D{vx`q%<0-HX7Z!H&K|4Q&2@U@`Y`51TzsJ~alKiqBb6z(^29m@SH zxt{9Z@5`inCeLY7aAxM&1^oUCo~_{eUtIbtalMV_mvWW3-fmCf3m$))XIj_#n{yDn zmS^wfTE_ia@D}h#Tn(;wa(^xO5m0}pd3-CskLUM8{@z~lKginV`;D3Bb$-8tE9Bj) zz$bBim*3y#(i+#_>$y(n`DQMbcyK>gi!1(%`0<;(+alz8w}0{H;LCW{;3aj`Fob8{T;z` z#A5IZt_Qe|_UWF?@8@&nxc^;n6#N}f>-wc!zr{7ovpo2_;Bg@A)c%g)ew<%V2j9Y_ zzjYo@0sozQtyBH|lIvcci7$xfoyoPAYlT;Jir`QRUL>8}BukpWk zf%kE}lj}s%auxsKASS*K@hn>W05*p3j1B;`$e^cW}MXr{!nzCtjz&-*ynp zk> zv%yjBzp01*?_rNu@~)rjE8MREj|D#p-oT~5A389*l75zX{$+3{_!e+K*Pn9z4cFJX z#&~`e*Q@#cI<6OUJ%cOzx09Qrxdur0AK-6*e+fPS4uG4up2lzeodws1%n|E*K_uIG*a6L)SdG-j`-|_Q#;8EanxNhc};r+}3x%~j+2d#>Q{6T|*mI996Urw3~*`ug-> zXQLD)Hxs$$bU0hBj2BDM$}nGza`mV{9#Rf%JpAy(hlcW%*;chUFS)#;v5S;ok9FJy*I`1(u5C`rdW!UU|1!#zrj~ zD&>dDjhU!g%gTLl~O@v>4v=JuR>yr_~t4I9@(uGhlxN|gl@ zu+I2zw7)hm66Pz7Qh_Gc!-=RKju*o5Qf{I)5)O{%%k@&Y`TC1D?cRLR2pLxN$X6p@ zzEojRFlAb5nasP|GTY*=g)@y>J)F$#i|AMgjcTwV;kwGNPZp~M-Q{K?rcr%T+j1fF zT%L$Tm0@LUiovqfm2i1~ZFxAJgT@Nsplc+JEsTV9v5RUn5$z9WDup7ey&8_L8Xg{A z)t?^-3zeu=9;k=SN_AS3qB)_&5gV0c#KL+d939#>U~SOUc}i(S0~*U2jXQaA)oQMF zeKi_adNCwDv>}<-vS?KM|2}3h96b{g2mzwcN2FE?| zsYt?nCjEjOD@_|;Kl$y6hlUP1aW%T3QLILy#$UfTSQ)aeE7gc4uetC=b}LH5+Yb|8Lb7xgYIPRi1WW)D z&6Tv;N;znng{JjZYmC+E#d@P2LFJ;~Fd83s6f3fXgs-pB$Z#EWy3!L*^1!tu+n2cY zZiW|lZ=4AffirWq(S=47^lL=dbIsMyOIEsH1^+FUoHF%s8O-n>gxOf!{q$M#)Y zUKna^49&#tXw-5O5esE#X770Q+OS+M4+QIr<$S3Do6~gKVhRxwQCT7^xNyt1%eP;& z3C3G$zz8*|B=c0hGOT+^&QP5eY>Y*CIJj{|xaOR*&soX;&sj4Bf7@JzneM8L*PFR& z6mG6G$_NH3fc@>B)WUG`NrjIqY0W1+H*8fJVII1LAmH28;+W>9$b^*(t6+)7A6k7p zph(z+SS&LO=Vdl^bMdw-!i%G_P4Ftw&CDXANBRyo#c1G0=x!!F zbzOMUn(*dx!%f>R3U73R!d~1AJ-{S=>Y>deAvsKrScZXcRaDQfnnfZuSu|UA>^l?D zFf-FABif7&F{+}YT4Pq?Eh+?CysQ~RLNc=BQ8g;(qvUa-fWQeUH7vu?)0dSJJrZ|I zl4af@+sbtf%{4b(b93^1rctUFrO1TR2f_mK0sW>h9PVaFqi`nI3dfj_aHd$B$<>jn z$mM1fmEB-k9tlz#TC~huDH=}7o`rQl8?0$0Mx&IgLcTmhJ%E1Wj#eds!l;~fy-VWD zqnS#zMfS-YVvb?jwizX$t~FJTCg?L_&lWG8>}urm%yh7OGY7(|sqeNm+_< zS22J|#tFv3LWZX_i|CP1CfkPbMrmaq%qQHlW%ni9uh<=K*mhO8XT#2&8@BDf>ReLR zCo8;-_Cd8Or^pg7!dGB;5Fd&|WxVh5O*=PULi!CCZrQqJ_f>F=aPyYk+cxdm6>i?X zGu#mF*syc=mW@|z-LNyd9uQutjIjst0#M}%RIT}#^4GkK~VShI#MN#8dj^fq~00Z zt6dvr_7UOUp`mMyfrV&reM>FDa`orEVCc_hO1KJ17K~UIzs`o8tFwi ze_zfhU2{gtRQwEwTgF8(PWPXz*Jnpot!g%#!xQDkaHTr23h5!qQCmen_SUX79y~r` z`XmHXn`P5u%4)K*t$q1Qxn8Z5!ctU65@a(vvD!Z&xhLw;!ZJ>!2_5b4m%1xuHCGR= z(;G{qch>4kISOKtoC`0Epw+Fpv06rar*Fp^#ZsO9Rias-W}*A%%32^$IN~)LFP33? zX&w_!$+}El#5ykGGnW+SWJH`-h34q*1R7SnBkh)=?HxO_N@ZFUs~$??g_O5WTrpd2 zBE_WSuro9jXOx|^HtYjo1wmUa7T~Nr8!MJ`)fV}?zs~HXGig?lI{T)*$j;5JGMY9; z)lTUzR;y7d+Q*_-3vG8Y>h&nop5`f8qno#E+IrEREf?*+WLK{gJ2vd@@oLM(+qUoA zv~k0(O+6B9wdXTYuFTk?c1VBIpn1xwof|9M!RQ$J+_WXP8T5K5lv!g$HKUcvthhpr zrGxYv6=fI8+ERHH!z39iu{}#LT3|$w{cYLHIYogXp*x>{p_J(my+;RQg{Wah#D*lfbC|mXa%D_*@8(b z^$HEESY8$uT&g;Q{8-i(j80nZOPY+*K_rdJ6ZOgVvFlvDWd@+jaE(_hGt6wJhb|!^ z&&Co?@Amn@s9tDUF1Zw!7}A(e@@ZLJDnhE)&a~ccO(*A~Z6{4yNY}>85Gf;_qgVKkrp4Q66aK@#r@VHFGrmC5j-~`TR0`}; z(v5Sb3)3NN<4`cPnZ9!mlbs%<&8p85o!i$engiRHC>cSLE!~qE44B=Q(`lp}xK)=n z!jkEs<2I5)A)6Xyiq~|e0d1-GF7F>crMCQ9vE4;;C7i;Tnp%>ufcD1t%9oxjZN}oI zCbmA;+iZqJBM;FU{f5eqYWhkN*i2K&Hald`EfE!rj{yhQ;2D!)vJ~kf0Pl7%iFD7)UlRG#N6UjL>jnfgVd=GL>y%Yg(+%tZHW? zD6Ops;ltFhM#ly$Ri?~rTP(gr^y;)v;Suv&DB$ z#4Khi>7ItJWD{wwl8KNJ$F&DiOcZbC%&k)|HQd=8rkx^8gw2<>*EX`QC(QA*J5ccH zZBElc5)E|Dfe5){>f?^+Ra+yimTddX^yKSOO4Dj=GsAfFNUZ}6qi<<#ne&C=z!~-> z3gM9Kf>pqZY?3s^3|3(lkxc%XBGUIp$6epV^Dh&b84{XwsElDiWwq-qCI7kU=vo_TH0!++>0AWfY09K&_3WCo5H)El-GX4!@|7V!+pcwzRF25i4IAiq z9?{8c=RAu3rJZt{5|ZpCY^djp&Th(JkEC|i#MX3F+B8iZmCzap@-x^C#Rf-$w9y=W zHENTZbeorWmN!wFT-U5suDe(OY4vn*c2*Nr!HOf5aK(IWu!}O7P2R2v zy2M=-LCe%bF-TOqe1)TsuG(TINqicpO_;P(XA&xw#XV=twn>NLL`DNPuUfOsD*8&o zHy2K%_1~?am5!yU%*<^0SiY3}_> z>k2!}z~V_TsV-8?DkW)P6|}iwOFW)qC%~bbw}z`Ox3Lb#Dg}C#q|N7GXr@=$-aV7Z z<|4{rF|V>a%^uHk)=2-VEOt0N1Ccqab;p)5;Yf8H9g0@PP603qcm5W*bebNM9l3Ea z#PxprQ+MBL14Go=#grnEU0GB!B znl0swAo2qNhYXpG=6n;LOR(^gO%Ezk5u0VZb_AKK+>QiPus_~#)Cp_PW~!7+Eq8dy zW(6mgB$q$avuzgI7yg}qQ`hA92sxq^7t^|p?*nsT>i$mRb;7vFBB|sF zlk5jvTFBi>hQpqe=mwl3%@ko9X8FmO2(wAWh|_eADR5t`SSEyttkrSRTe}zSjt;t2 z;Ot}VbuhcVGn5Xp2G|}RG{BU)gDnsa5Z8@QmzAgz%#jz?TYg=Q9LBuv}3F#h0{^T6OFZI#cQe&c6zP?zy z{^A{5ub1k<@g!aiZhMn7$U38iKWalo_n>v{8r}4ASW%VrAc{MHpMPnOXys zqZ3%Smx`rB*JQRV?L;(LyKar+mx#Ryov(Mc+H4NlAA2A;)rT1y9UNHMM;BQZ=A@TH zusUDMSj94XS9`g>k(p-uez?s>snyYrI6VVY&rM4tIVIlsQ-5mf#j~~}r&wm!A<1Yd zC(605tBDP19^2yD%UvY5x1cF|Y-4L1fUFXcyl_LB@rH9pgUNf%cQ#{pbCWeW$&*;y zI-4I${+JFz2B9-el36cT8sXx65UbzWhAx=d=(IMOD^!}baH3QhW8uU!l2+*nAhwjD z=hP>w#``RP!m>Husv$_@MUbd9iNi@oLo%y~ZDM1spNT1(KJA!|*>SXJODx9*PGG}* z7n*{lEr?En#q?^@Zp`BY9YmW(bHCAVJ<~6}2 zn=-FjU$bAf2yqsOIZ@)w|7(mxzLxRa#L0t&rlUL=?&Jmr6Ot>Qu|V~uQI=~6N|+Z9 z$?9jr2Yd1xehlICF~ZbbcgQgl%19l_b*8m``emR+ZuEaUpVm%vXz? zC}dtbJ8`C|Zd;u+a^8ELEcl^J6UlE2p@Ab1orvqxc48IAocch3tjSc7*iYgD!v2ZQ zB$-3AI8{)pO%})N2YZY+KUY$}-*=lUP*(%a{Je5|LdxKAW{q*Pv49E4m5}Xxrf2O3 zRK9;b(sokg3^L?;Z!KjR#7=DSV0lGYf;-_eMlI$hG;d`agXuU{?wQi;HL*;Xndb8f z98Wp!C`EF&MRybv(CUuu8i@yt9wNz%GufGG5NB`OO?T4QOl6;GB|2Y_?%3US3Rl-6 zS`o}o-qnoSnLf4HF1?PY%aT6*?xUSMoSGCHg~k8SWn#wG^Iqq#2Qd3h*SwMo1LKa!p~gw75!3M-|)*}Og*Ldtn2nDl@N@tH{!cmBG>f}!<;e1trpIN#4~ z!gY(JtRAe`tF+}v>Flst4b&8GzWLyF&ahki9$(}xSP9pJ{MJxl;R>noeUP`@FcBs~|jY*tA z3q3F%x4@R)+pEn_71}9>wnDXE70a+A1Mf%+k8}#S4&2EHYLF=h<(EnUv&I*GiSTQ8Tbv`7HvssO55g7>OSt0G+08$Fwb!2KI&7 zXSQ~GSc6kX8d|}37G*45oJ{fclIYXTzbR4+B*Y`qoQ6o3xRuZV|1E}8nD&C5A!ziZ z{=&eLl9d)t7jI16_Q3H@o!-o%nqk)QXU5&AW3RSw*QycXx8x~nb4Zp|{k2sCG6799 zxkaoOxp1S3R5w?e3B*x)mz?wRoqFn$a%yF^?cT$d3~hXjT&bXGmYpO}g&kjp$e>w@ z#?eF(5-)NxYnjlqyX=>9vVI>zs6?syN>a`+l;oJ*C$$dnJ8BTcql|TuYZ1^Yb3;7Ri;c zG^w*-+79L$;K^xr5~MZfkPS|ks})RX$tOvq$4ZG8h&UumHmJd^Y@^{mXLoxIZ#J=m z#3V(s#Pr2+w{&JIx?Wqa+TaR~v(3U;Z}O4BvVh~N9=(k@Od!unTe8?8#q8SlaIphd zY!jU4F2!1Ohwa%nsr3mthrB39P4hU*YV&5TGq#~RI1ZMR1ZUX66PMtN^L7#3^DH&JleX=1eX>p^JQ3p>uwG@SeeAA3)NXLjy+$Nv-%i$FOc64XxMXcR z<#|S>8j`t}_irS?%we+uY5y1J9cj0xMkbs?R%HUX_jBx zb~0T@>{4!=KWVggJZL-h>5|N;LGF;dWAwU}s^pZSwcDYlre${&gNVTW&5ZA>r8W8Q z*^CI)=j-c1YA};j$auG+{ijFwmQ31*GnFw>+8CNH!wQnu3Qx3^h>%@A4du1B6Y)@L ztmsmd6RY9*>o|K&KMHrpjXI@TbDN#FOvo7`y+`iQ8@m#(ptX>x+I)3i(R z=W?lge7E!+z3!dKGp4vzHRrbDs!LkZQJQfilbtI$snJ}got~eRZ)Q6kaGmnm!FqiY zlC|*!0u;cOa35&uf9{9?T`?9Awc(&%k>5e*wrXCz7#4{@g8jy8nFy`;kXovcUx6+g zW%|_GCfJ#6>OsRTN;OHyzIe5R$W~7u zy#&$fY4>!Ft@jGCAx0qmJAM}LpwlOAM{j+!lT-;L40(L-jQr*+ids#l<}=0pnsVuM z=MR{QHF`cjTsB!K%oCC<7}aO^HcSn4YHYV>TB5$qGCFll!h3I#AH9Ye7s%izrBQCO zzOIKB2~HAb2Fk|3HVry>R~N1cPvnb9G-@n)QnU4`mD3abl9v9cPon~#BXOG>ynZ=3 zm!n5I0nMjSc{^&r>KUhqdN-_e4t&WALW~I`q(YH+%sr4GV{p z{q6RKrF>u0ktGp%i<&6N*s+LXG1$&j)uvjXTFI=47+G`HsjJtJZYykTi0^&N zSen@`jD&kCQ~6?qSKy9HDK{OSH!E20zhXU~^zIOFXm^yG8Bro)AcW`X3ni7H>gv21 znk}uD>RKCioS0?A!69cgX$d3YY^m?^EthXfM`X?L>b{No=#IcWyII#9BVY$zWu}O8 z?aU87d)*bgHxHeirc=%Ae1|rnO-j2S3C|uY*86tgb43uL&1eE_{mXc-a9dk<+PPG# zpX&z8>(;FaFW|(H*Zpf&pTBNxc=E~i^SpJZ>*t^zuRd?h>hPwU?77mcUO}EUu%O&?H|F8h<0Tf25VbhL)!QNh-tH6&J2xWy?YuZ8?Stu*r zDVEXyqfk~!W3(+t30xPq=l_dPR%%SwP*(Or!$v5pdNd8S$1{-)X4UaV>0LN0rc5ED z#KbL{7594i-w0-vwA2wswATjGqHQfXnAO}&F)EjH>)?;|%7J?yeR&$yYThds#A;W) zQVaKBe1f%%` zBpOs2=E;WDTLv+^#X+K!&WGEI=N|GYM$A~;duFvQwTriPaH*TEncPH5x{dY%U2v== zm*|qm%Va7llq+*(7HgTndM@;p^~#6RTBzzc+!j@{h-Xy{qgM>)%(AZ~+E%2|cKhIH zkkgP`s<*Sg_Gxfowjf*R<-kkxjXZH&T5fqOE@Hi0OvW7=FW4G1>b23yg$F(XnTdk2 zi%;|K1F64D3&TYLu6vF+vJtpCU-{r$n9o?K&_^7EOKq@WFI485?9Ui0g3wf3tWiEQ z%GF?Mgji}>94@7WWMLsWh2bJ8wNI<97@k>~%9=Pa2aN-tXlVtgZN+d19jtpuE~}lX zszLR0j7v1*R%;?M!Z<+Js1D9!8cA7cP8@!&HTCG-Y|f@wuEtrPc&sjc!0AJES!E1M zS!~Nc6baGDbB!ZMwYiX)6QxyoQJ52hED*bCs;{_8g2Xc}-tj_%o5S2Nt&drD;6Vqg zoJ3@}Xk8j67rkpv&o16}#mYVei)4yA7|lr(7LY11$33)3B(pu+DA)s=Zx~HuLYwd! z<()Rf6ioHivvsIh)Ai3iRE?$%+#Ak?v!8qDz$0{Nsy5f6T`s2t*A7P2m|&|tidU{@ z7_VGN94}M1T-2|{;&@$FQ3NlB1Cq3uULr9!=!ka?kIT7WTf5k-6ihWx!X{rY!Xl#f zBsqq8u9*v``LGy94uv+_6S#-+(t-`b9f}=wK-RgG_$cWM`L^J#xy1!^Rhd`8%?@;7FLwK&eF~? zQ>a}Lq)POq1D^=TMEz=gxla0t}dp2$f2{?Aq*6n*X zUCM@FtkUuFqV3`K%XV%$aL?B5+pgMpN#E5QcJ1E2Yx|xJ2VOE9?g{fzso~XXsg%S@ zJn#v}3H_<1s?!2w>rl^4^(A~8NwZb4vW)Ix#?3<*x47qJ6_f#K0wyGrmQa?7)x|MmQ+oZ}^ zJ%WUyi8)S7a5kMw2R|#&;<0x^GaRH>J;GsP37MkU66#=%(y1LvM4~Vy2Oi<5f)6?2 zAxjU6CJSw{FTr%g5qHB%)rUdsmc)k@7EL1D)WlXcGFmERI2f_jgSsl|qx}yYX2$k{ zaj`B`S}>R6<0+(aCA=<36{5`gC)3uw~qt&9)=Q4%0S0{JbfYhmIjAgK^6lN^eZLL+I*40?wq(zd~fZJq6QymFA z-m>wZYfR@s32cAAHU4W79}$Hj-T?qdnSM z?^G6Xt>^1()U}?8wtAI(ESke>0JR56(Da8iQga#gb2FQ-R)9YzXJ@txiDR)D+0UZC zmlzZACHM9B0Hkd7G9od#oPwzx2f z05LG_1==&p-q6-87qv}f<(Ac$*_@nBOIlP|rwp-%Xj%+0Y75-fYosYIU0{4X*%r&K z33Gk)b~vZ0ga>YOA6K?7$}|traJr`-ov^TOjV1;bbX!;vt8Kbckb3JQyIJ#=JlUhA zgC&nqclJ5hF#+u(ZX72|NG_gR&k>&s8J@ct9;bpP<1^~=*}@drniVU=`qo*t%&G)p z>oubbmhbZRnpSIqOESM1qe+xFsZRLkNIp2iLBE@kH;mcc6sE*lXSF1}Z+@&eI$%lM z=%T-ygg)>HI;IR%Xe-90EzK0|k(|Vcn%4n9fGs`ie5=EQ8SDe>C!BQ`v!COqtm4WT zg8ptCW;!!z-;m8w!#Y+eG{gsC!%-n@ZGCq9`~A0@B7=e^Pq{B6NDc5BRneO|14l{v|Y4^kk(FM6n^R~CFH!04t9yt~$ppHFy_be0!{d2r&5%2uF#15il z?ycK(ORbLV99X9!EUQG#4CZG=3&%{_6yYY;%UqmJLz8DqlrC?M9#F%j&62>h zW0LJ3+8>lAGjVpnGp}O~?M=rswtduIfKw)z56W*a$5h$3N4E8l35AiiKzSN*#&!;O z^8>eu3@D9AdCoN379X$awGk3{i8~M?)oC8q-I`8)jHOaQqW46Bii^*o9Bb4DXbQ6x z6cMZMZiI~{58R8hIho7|Lsa-|9;4?(zyc>-0%-6gDC#_e|P#_089MqA+APdMx1k7a3 z&}_U9#bIno)RU!_9vzzB71zbML)n$!)s%Q+&suaF#mqQ#WX_&Y8hNN+U5+V-F*l@V znQZ|Dd*o=#z;3$AVX-^iQUt)IWb%Wvq@?M3V7Yp6sx#LKLLjREQ%7YhVY1Lsqqf#@ z7Du2Z>`ct{QX7|&wK27rH#I{{XP8lK6h%J}{Zcy6QC!R_4yHIe%2%Kmi+`v}r*sT~ zZsR*mQ>5f0LiopgcxvOD-dVdjjQ8baSd7X_h@*2PvEI4Zi0vv(+fLsX*^$DU*JV4G zO^va}JAWeh?1QbFj&NqQ^W92XPbRn^@GixoZ5X(jeoHz`wE}OC1U-2R%CUuU7*5SU@|a6*xaG zX_M5JW63)t%az?D#VziwSXzw5R3BYDgGR@T{5fLEpe;6?^fA*RtY+4ZjoA8mCXYOv z3NpD;HW`c8xg5Ipd|A*dq0HC43zYwM3xbg1)3sL4^72?z8(|uoQH3yuy-u8XP_7{XI6+lL?NSBJuQ(^SpCB8pkuSxp?4$tfKW2vVMw(dJ z=adB7hX~pzRf;*foZAR=c?XlXsEvyz;Q(uqG>Y2T^hcbM0ug=yG|mSoz*-byq{6k> z|C0!DlI%9#!Z)_3vx%F=l7t;x2bI!VJ6wsHbNCi=PN_A$fLoDsi;0QV1hWjN*p=I2 zI(i<}#)FhKwnjU9@oXiH@8}9PpE_{{=l9s`Snz?9xj1UvTdiO^FUlzbo!gF4vN0Z= zPQ@{6+-#<)YtgPyi=nYzvd^ zvZCZgRkw)_vI48kUNXlPN0AD2MuIw>)!TY!TC&FGi?fovdkj%}P0jTk_e9T3P-y#k zjoO@Kk_MRUy&OYIvSv?tLLFUW<>p{+e*3cqXgk)l$dpZXjdO5~g*vZ8D;fFn@nX#O z3|1%4A6`*NjVX++{j$q+aYlmt6`)dH8VF{KQyDKN^wpM5hoF*VExEO@v`m?OoGk|n z@(44GmxUS5Wl2t+xd4C3?TE9jwvT)b}gSLZr)s%@Q9N^z6jES`xXC zhP;$=GA(0qSuO~9Y}l~uB7%T_gD`bjl$Ap!wp`Wh+x%lczTF)qqUtiVsT!IIf7z2Q zbZ9f8r6lrXd!{jBQx*wRGwl|18*}kinhw5V^n5U-IR=Hx4q*?L790~-Bu?I2u?2iI z4v{HiKjT`%AqADm9Zl<$PXZiuIvzl+b{jNf*A@KAT2rzS$;YpP`3r-N^lARFCGsi$ zLTe7C$&bEeZc>Nl#rZtx^c+!;8vmI(b~Ez!&T)V+U6E6BV!-t6GIm4o!E7i^F&LxB zgWey-#i#_Y5GUJ>M_h_vMo=a^3wAFYUkDL%sTGg{SF`|PgFBw?|!bVm; zD>kkWJsdUhesv-=>$o7gBl`Ee5^S83e3+S;uP*tLQ7~&`hU=na?*SYA~#OuWE&#a2ED>ym=(uGyz?T{6Y%8cq-fgLO(`t;F|Q@mr*sgDzi zQcGEpGev^N&AE`BE^=oqQc!MChvoH&P|+cEF(3{wo09HwIJT@}k6;lo?H$Gl6qQ6_ zz^P)9LTHj_W}3uO>_8K9D6uf(amoH1FU7fBA;SAnWQ6in~9J3ZX zEl#m$HCQ5i+8CuM*V5zl0gQ}qKi5|1X=l%ysJjkR$b-`0*f^2cUBq+8L8uq zosB?zWRabLMe=t&JZR6K;TT?x)C8r*PpjHJN=_y^x-h?po_2gIEh#5-O@UQsR8X`V zQ|=-~7EKH{=qYV!;xe+~N8Lt}RptIY^=cfqG?^6GYW&K!&~ST}s}`aQJ*wj^w>#5O zc0wTRiQH*JtngBW`OqTCI}AAh?l+-kuIoJ3ArqO)~*X zsSu$W^94Q@%xu&A*9d$iF0WKRq_hoemkpi|UCK0St&6!xvi_uQ zFNnh)Y`MY~0&O4XcqYY}#ZV-bnPQD`JI#TA;xywx=NOE(V;0Yp3~aQ^xTD)vGjrgM zcLvb}vfIabr^E9tV2O5st#e-fb`#~onG-V8M06f%nXJv~cm87rMk?Fhc$((dlx%tB zpwqF5;Cm^5UW-lF#YJUE(>+;oQVa9T1WLut4`MLCR=3v;+H!dxRDD)N!epP^Xiufi zdRYryGXB%JdPRYA)>*J?woDvfWRWf*gJ{e$Wv8s8$!2R~&t=ht7?)-e*wG@arWQ`~ zQ&06q#dqjPvG`of4}Q8dt8SNkOSbLK&zrb}XQx?wrp6}}`q)g`ne(MV$7^$?iDR#( z!?J`06I0^+%!{p-IA?ogRzDMZiGNSRsl;TY|9Qz`3_6G-u68grqlzx8%O_8}$NoIa z4d*YjgdXFts|;kToST|~&Twv!Z@M(E#IMO}Ht(yLbF&29*A?)SxRA5~y@@JI)Y;jS zu54$>o#wq*7%cTrD2e8}q|&`85sO&T30BY2JI>M|#;nBpAM3=z)jZ+en9W-<4+$Pm zJ6zP_(e|P`%fr7#&Z1+%WgP;{fb1t!FU8SVk!ac4&Z2R+&2?;h(DAb=*>|%wkTV4$ zR55GKvnLK%+clF6lxZF@L-Q3%@~Ga#z(FuuFMd~OvLQCUv2HN)vGV6n3cZl9ZTM6U zk35=_9s{FF8KLN;+@GN-f%K}Ncb3E!w?LZI^wvAk1iIf`!JA54GUGO~EX10PeZ+>T z&3zM8%$l$F$8D6Y)a}#Ncy}0Nt+%rP`sNP z9yWp6HfjVNhYS`-jis<|Cui<(Ckc(Ko#Cirx1nBu%WU^(J30o z)E%L6<7thDfNcXC1ec!QzF@o#;{@U8b=@3$wP>>+H6&qniJqI#PT~gKk-9A&?$R`w z_Lw#%$swIYI>vejyRmk~LnfD0C?15;(VlUs3P&1#R)f&)sm2y2-kj$-3BehJg&&LQ zo<6)wEYTV`zrZdP1q+p^&vX@%cPg{pvBvm6lamoJZJ`MBOT z<1SOcP)L$%`_sg6Kd_L#F7j{kicnjOR-2R}_*mN$rvU#ghB5z@}&!L%K2tCIFUI50v@ zk$=5kRYHJ{;@hbZ%5c$w;mJA%&+L?w547XR!OhkLA3323@AyV(2pYvJlXrZmX&McXa`IFCfX@^seQEVs8 zaxRk^TC$d!4n=54YCSQR35!e&$yk&fwUbGR?QX~m@8g7WN1GRS`0HDsq=WPIBlhvU z(8Nm<-Cgo6*$6Q|?|;Jx5l1Y3Li)h`%S_@@cqyYu+-4@^bcIzv(6v1|ZzetVk%hbrIqdp7yoKo|g3oQc6j>nW$n8bWO7}E9;pbsib%I(AW zl!eoR6f&ZMT8 zWO1|wo$j3`jl$fXCh58Jp>SQ!e*d-7K9^M}BGa!kF{s-L@-yjNNog3IfAN zkhjlb$Fno`C==|udnwMi>OYm{OFQ^S(nQ7r$0GUbr|T=`GxG-`$p-EHk3=ApSCjgp z574FMDykF*s-_7-ThWI zR({Pqmy6AN#Q-?b9 zq&u2S=&kIA%Qd0pf>BECGM^qIdoNgU#>PyL@N9f<`kkE|jkH+-;`N%u_*US87U8`$ zlJ1)t4Vf`Aacm2&VIP^MU2uU}v|lUaJEC^;ZB4C#, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2012. +# additional help by Sergey Poznyakoff , 2003. +# +msgid "" +msgstr "" +"Project-Id-Version: gawk 4.0.0h\n" +"Report-Msgid-Bugs-To: arnold@skeeve.com\n" +"POT-Creation-Date: 2012-03-28 22:03+0200\n" +"PO-Revision-Date: 2012-02-04 19:17+0100\n" +"Last-Translator: Wojciech Polak \n" +"Language-Team: Polish \n" +"Language: pl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\n" + +#: array.c:140 +#, c-format +msgid "from %s" +msgstr "od %s" + +#: array.c:248 +msgid "attempt to use a scalar value as array" +msgstr "próba użycia wartości skalarnej jako tablicy" + +#: array.c:251 +#, c-format +msgid "attempt to use function `%s' as an array" +msgstr "próba użycia funkcji `%s' jako tablicy" + +#: array.c:254 +#, c-format +msgid "attempt to use scalar parameter `%s' as an array" +msgstr "próba użycia parametru `%s' skalaru jako tablicy" + +#: array.c:257 +#, c-format +msgid "attempt to use scalar `%s' as an array" +msgstr "próba użycia skalaru `%s' jako tablicy" + +#: array.c:302 array.c:707 builtin.c:84 builtin.c:1385 builtin.c:1427 +#: builtin.c:1440 builtin.c:1859 builtin.c:1871 eval.c:1135 eval.c:1139 +#: eval.c:1495 eval.c:1812 +#, c-format +msgid "attempt to use array `%s' in a scalar context" +msgstr "próba użycia tablicy `%s' w kontekście skalaru" + +#: array.c:513 +#, c-format +msgid "reference to uninitialized element `%s[\"%.*s\"]'" +msgstr "odwołanie do niezainicjowanego elementu `%s[\"%.*s\"]'" + +#: array.c:519 +#, c-format +msgid "subscript of array `%s' is null string" +msgstr "indeks tablicy `%s' jest zerowym łańcuchem" + +#: array.c:723 +#, c-format +msgid "delete: index `%s' not in array `%s'" +msgstr "delete: indeks `%s' nie jest w tablicy `%s'" + +#: array.c:734 eval.c:1865 +#, c-format +msgid "attempt to use scalar `%s[\"%.*s\"]' as an array" +msgstr "próba użycia skalaru `%s[\"%.*s\"]' jako tablicy" + +#: array.c:910 +#, c-format +msgid "%s: empty (null)\n" +msgstr "%s: pusty (null)\n" + +#: array.c:915 +#, c-format +msgid "%s: empty (zero)\n" +msgstr "%s: pusty (zero)\n" + +#: array.c:919 +#, c-format +msgid "%s: table_size = %d, array_size = %d\n" +msgstr "%s: table_size = %d, array_size = %d\n" + +#: array.c:954 +#, c-format +msgid "%s: is parameter\n" +msgstr "%s: jest parametrem\n" + +#: array.c:958 +#, c-format +msgid "%s: array_ref to %s\n" +msgstr "%s: array_ref do %s\n" + +#: array.c:963 +msgid "adump: argument not an array" +msgstr "adump: argument nie jest tablicą" + +#: array.c:1086 +msgid "asort: second argument not an array" +msgstr "asort: drugi argument nie jest tablicą" + +#: array.c:1087 +msgid "asorti: second argument not an array" +msgstr "asorti: drugi argument nie jest tablicą" + +#: array.c:1094 +msgid "asort: first argument not an array" +msgstr "asort: pierwszy argument nie jest tablicą" + +#: array.c:1095 +msgid "asorti: first argument not an array" +msgstr "asorti: pierwszy argument nie jest tablicą" + +#: array.c:1102 +msgid "asort: cannot use a subarray of first arg for second arg" +msgstr "" +"asort: nie można użyć podtablicy pierwszego argumentu dla drugiego argumentu" + +#: array.c:1103 +msgid "asorti: cannot use a subarray of first arg for second arg" +msgstr "" +"asorti: nie można użyć podtablicy pierwszego argumentu dla drugiego argumentu" + +#: array.c:1108 +msgid "asort: cannot use a subarray of second arg for first arg" +msgstr "" +"asort: nie można użyć podtablicy drugiego argumentu dla pierwszego argumentu" + +#: array.c:1109 +msgid "asorti: cannot use a subarray of second arg for first arg" +msgstr "" +"asorti: nie można użyć podtablicy drugiego argumentu dla pierwszego argumentu" + +#: array.c:1655 +#, c-format +msgid "`%s' is invalid as a function name" +msgstr "nieprawidłowa nazwa funkcji `%s'" + +#: array.c:1659 +#, c-format +msgid "sort comparison function `%s' is not defined" +msgstr "funkcja porównująca w sortowaniu `%s' nie została zdefiniowna" + +#: awkgram.y:249 +#, c-format +msgid "%s blocks must have an action part" +msgstr "%s bloków musi posiadać część dotyczącą akcji" + +#: awkgram.y:252 +msgid "each rule must have a pattern or an action part" +msgstr "każda reguła musi posiadać wzorzec lub część dotyczącą akcji" + +#: awkgram.y:323 awkgram.y:334 +msgid "old awk does not support multiple `BEGIN' or `END' rules" +msgstr "stary awk nie wspiera wielokrotnych reguł `BEGIN' lub `END'" + +#: awkgram.y:371 +#, c-format +msgid "`%s' is a built-in function, it cannot be redefined" +msgstr "" +"`%s' jest funkcją wbudowaną, więc nie może zostać ponownie zdefiniowana" + +#: awkgram.y:432 +msgid "regexp constant `//' looks like a C++ comment, but is not" +msgstr "" +"stałe wyrażenie regularne `//' wygląda jak komentarz C++, ale nim nie jest" + +#: awkgram.y:436 +#, c-format +msgid "regexp constant `/%s/' looks like a C comment, but is not" +msgstr "" +"stałe wyrażenie regularne `/%s/' wygląda jak komentarz C, ale nim nie jest" + +#: awkgram.y:528 +#, c-format +msgid "duplicate case values in switch body: %s" +msgstr "powielone wartości case w ciele switch: %s" + +#: awkgram.y:549 +msgid "duplicate `default' detected in switch body" +msgstr "wykryto powielony `default' w ciele switch" + +#: awkgram.y:809 +msgid "`break' is not allowed outside a loop or switch" +msgstr "instrukcja `break' poza pętlą lub switch'em jest niedozwolona" + +#: awkgram.y:818 +msgid "`continue' is not allowed outside a loop" +msgstr "instrukcja `continue' poza pętlą jest niedozwolona" + +#: awkgram.y:828 +#, c-format +msgid "`next' used in %s action" +msgstr "`next' użyty w akcji %s" + +#: awkgram.y:836 +msgid "`nextfile' is a gawk extension" +msgstr "`nextfile' jest rozszerzeniem gawk" + +#: awkgram.y:841 +#, c-format +msgid "`nextfile' used in %s action" +msgstr "`nextfile' użyty w akcji %s" + +#: awkgram.y:865 +msgid "`return' used outside function context" +msgstr "`return' użyty poza kontekstem funkcji" + +#: awkgram.y:925 +msgid "plain `print' in BEGIN or END rule should probably be `print \"\"'" +msgstr "" +"zwykły `print' w regułach BEGIN lub END powinien prawdopodobnie być jako " +"`print \"\"'" + +#: awkgram.y:995 awkgram.y:999 awkgram.y:1023 +msgid "`delete array' is a gawk extension" +msgstr "`delete tablica' jest rozszerzeniem gawk" + +#: awkgram.y:1019 +msgid "`delete(array)' is a non-portable tawk extension" +msgstr "`delete(tablica)' jest nieprzenośnym rozszerzeniem tawk" + +#: awkgram.y:1135 +msgid "multistage two-way pipelines don't work" +msgstr "wieloetapowe dwukierunkowe linie potokowe nie działają" + +#: awkgram.y:1238 +msgid "regular expression on right of assignment" +msgstr "wyrażanie regularne po prawej stronie przypisania" + +#: awkgram.y:1249 +msgid "regular expression on left of `~' or `!~' operator" +msgstr "wyrażenie regularne po lewej stronie operatora `~' lub `!~'" + +#: awkgram.y:1265 awkgram.y:1419 +msgid "old awk does not support the keyword `in' except after `for'" +msgstr "" +"stary awk nie wspiera słowa kluczowego `in', z wyjątkiem po słowie `for'" + +#: awkgram.y:1275 +msgid "regular expression on right of comparison" +msgstr "wyrażenie regularne po prawej stronie porównania" + +#: awkgram.y:1394 +#, c-format +msgid "`getline var' invalid inside `%s' rule" +msgstr "nieprawidłowy `getline var' wewnątrz reguły `%s'" + +#: awkgram.y:1397 eval.c:2504 +#, c-format +msgid "`getline' invalid inside `%s' rule" +msgstr "nieprawidłowy `getline' wewnątrz reguły `%s'" + +#: awkgram.y:1402 +msgid "non-redirected `getline' undefined inside END action" +msgstr "" +"komenda `getline' bez przekierowania nie jest zdefiniowana wewnątrz akcji END" + +#: awkgram.y:1421 +msgid "old awk does not support multidimensional arrays" +msgstr "stary awk nie wspiera wielowymiarowych tablic" + +#: awkgram.y:1517 +msgid "call of `length' without parentheses is not portable" +msgstr "wywołanie `length' bez nawiasów jest nieprzenośne" + +#: awkgram.y:1580 +msgid "indirect function calls are a gawk extension" +msgstr "pośrednie wywołania funkcji są rozszerzeniem gawk" + +#: awkgram.y:1593 +#, c-format +msgid "can not use special variable `%s' for indirect function call" +msgstr "" +"nie można użyć specjalnej zmiennej `%s' do pośredniego wywołania funkcji" + +#: awkgram.y:1671 +msgid "invalid subscript expression" +msgstr "nieprawidłowe wyrażenie indeksowe" + +#: awkgram.y:1711 +msgid "use of non-array as array" +msgstr "użycie nie-tablicy jako tablicy" + +#: awkgram.y:1975 awkgram.y:1995 msg.c:98 +msgid "warning: " +msgstr "ostrzeżenie: " + +#: awkgram.y:1993 msg.c:130 +msgid "fatal: " +msgstr "fatalny błąd: " + +#: awkgram.y:2043 +msgid "unexpected newline or end of string" +msgstr "niespodziewany znak nowego wiersza lub końca łańcucha" + +#: awkgram.y:2300 awkgram.y:2358 awkgram.y:2542 +#, c-format +msgid "can't open source file `%s' for reading (%s)" +msgstr "nie można otworzyć pliku źródłowego `%s' do czytania (%s)" + +#: awkgram.y:2301 awkgram.y:2359 builtin.c:122 +msgid "reason unknown" +msgstr "nieznany powód" + +#: awkgram.y:2317 +#, c-format +msgid "already included source file `%s'" +msgstr "plik źródłowy `%s' jest już załączony" + +#: awkgram.y:2343 +msgid "@include is a gawk extension" +msgstr "@include jest rozszerzeniem gawk" + +#: awkgram.y:2349 +msgid "empty filename after @include" +msgstr "pusta nazwa pliku po @include" + +#: awkgram.y:2494 +msgid "empty program text on command line" +msgstr "pusty tekst programu w linii poleceń" + +#: awkgram.y:2609 +#, c-format +msgid "can't read sourcefile `%s' (%s)" +msgstr "nie można otworzyć pliku źródłowego `%s' (%s)" + +#: awkgram.y:2620 +#, c-format +msgid "source file `%s' is empty" +msgstr "plik źródłowy `%s' jest pusty" + +#: awkgram.y:2797 +msgid "source file does not end in newline" +msgstr "plik źródłowy nie posiada na końcu znaku nowego wiersza" + +#: awkgram.y:2900 +msgid "unterminated regexp ends with `\\' at end of file" +msgstr "" +"niezakończone prawidłowo wyrażenie regularne kończy się znakiem `\\' na " +"końcu pliku" + +#: awkgram.y:2924 +#, c-format +msgid "%s: %d: tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "" +"%s: %d: modyfikator wyrażenia regularnego `/.../%c' tawk nie działa w gawk" + +#: awkgram.y:2928 +#, c-format +msgid "tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "modyfikator wyrażenia regularnego `/.../%c' tawk nie działa w gawk" + +#: awkgram.y:2935 +msgid "unterminated regexp" +msgstr "niezakończone wyrażenie regularne" + +#: awkgram.y:2939 +msgid "unterminated regexp at end of file" +msgstr "niezakończone wyrażenie regularne na końcu pliku" + +#: awkgram.y:2998 +msgid "use of `\\ #...' line continuation is not portable" +msgstr "użycie `\\ #...' kontynuacji linii nie jest przenośne" + +#: awkgram.y:3014 +msgid "backslash not last character on line" +msgstr "backslash nie jest ostatnim znakiem w wierszu" + +#: awkgram.y:3075 +msgid "POSIX does not allow operator `**='" +msgstr "POSIX nie zezwala na operator `**='" + +#: awkgram.y:3077 +msgid "old awk does not support operator `**='" +msgstr "stary awk nie wspiera operatora `**='" + +#: awkgram.y:3086 +msgid "POSIX does not allow operator `**'" +msgstr "POSIX nie zezwala na operator `**'" + +#: awkgram.y:3088 +msgid "old awk does not support operator `**'" +msgstr "stary awk nie wspiera operatora `**'" + +#: awkgram.y:3123 +msgid "operator `^=' is not supported in old awk" +msgstr "operator `^=' nie jest wspierany w starym awk" + +#: awkgram.y:3131 +msgid "operator `^' is not supported in old awk" +msgstr "operator `^' nie jest wspierany w starym awk" + +#: awkgram.y:3224 awkgram.y:3240 +msgid "unterminated string" +msgstr "niezakończony łańcuch" + +#: awkgram.y:3436 +#, c-format +msgid "invalid char '%c' in expression" +msgstr "nieprawidłowy znak '%c' w wyrażeniu" + +#: awkgram.y:3483 +#, c-format +msgid "`%s' is a gawk extension" +msgstr "`%s' jest rozszerzeniem gawk" + +#: awkgram.y:3488 +#, c-format +msgid "`%s' is a Bell Labs extension" +msgstr "`%s' jest rozszerzeniem Bell Labs" + +#: awkgram.y:3493 +#, c-format +msgid "POSIX does not allow `%s'" +msgstr "POSIX nie zezwala na `%s'" + +#: awkgram.y:3501 +#, c-format +msgid "`%s' is not supported in old awk" +msgstr "`%s' nie jest wspierany w starym awk" + +#: awkgram.y:3568 +msgid "`goto' considered harmful!\n" +msgstr "`goto' uważane za szkodliwe!\n" + +#: awkgram.y:3619 +#, c-format +msgid "%d is invalid as number of arguments for %s" +msgstr "%d jest nieprawidłowe jako liczba argumentów dla %s" + +#: awkgram.y:3654 +#, c-format +msgid "%s: string literal as last arg of substitute has no effect" +msgstr "" +"%s: literał łańcuchowy jako ostatni argument podstawienia nie ma żadnego " +"efektu" + +#: awkgram.y:3659 +#, c-format +msgid "%s third parameter is not a changeable object" +msgstr "%s trzeci parametr nie jest zmiennym obiektem" + +#: awkgram.y:3732 awkgram.y:3735 +msgid "match: third argument is a gawk extension" +msgstr "match: trzeci argument jest rozszerzeniem gawk" + +#: awkgram.y:3789 awkgram.y:3792 +msgid "close: second argument is a gawk extension" +msgstr "close: drugi argument jest rozszerzeniem gawk" + +#: awkgram.y:3804 +msgid "use of dcgettext(_\"...\") is incorrect: remove leading underscore" +msgstr "nieprawidłowe użycie dcgettext(_\"...\"): usuń znak podkreślenia" + +#: awkgram.y:3819 +msgid "use of dcngettext(_\"...\") is incorrect: remove leading underscore" +msgstr "nieprawidłowe użycie dcngettext(_\"...\"): usuń znak podkreślenia" + +#: awkgram.y:3911 +#, c-format +msgid "function `%s': parameter #%d, `%s', duplicates parameter #%d" +msgstr "funkcja `%s': parametr #%d, `%s', powiela parametr #%d" + +#: awkgram.y:3953 +#, c-format +msgid "function `%s': parameter `%s' shadows global variable" +msgstr "funkcja `%s': parametr `%s' zasłania globalną zmienną" + +#: awkgram.y:4111 +#, c-format +msgid "could not open `%s' for writing (%s)" +msgstr "nie można otworzyć `%s' do zapisu (%s)" + +#: awkgram.y:4112 +msgid "sending variable list to standard error" +msgstr "wysyłanie listy zmiennych na standardowe wyjście diagnostyczne" + +#: awkgram.y:4118 +#, c-format +msgid "%s: close failed (%s)" +msgstr "%s: zamknięcie nie powiodło się (%s)" + +#: awkgram.y:4170 +msgid "shadow_funcs() called twice!" +msgstr "shadow_funcs() wywołana podwójnie!" + +#: awkgram.y:4176 +msgid "there were shadowed variables." +msgstr "wystąpiły przykryte zmienne." + +#: awkgram.y:4206 +#, c-format +msgid "function `%s': can't use function name as parameter name" +msgstr "funkcja `%s': nie można użyć nazwy funkcji jako nazwy parametru" + +#: awkgram.y:4210 +#, c-format +msgid "function `%s': can't use special variable `%s' as a function parameter" +msgstr "" +"funkcja `%s': nie można użyć specjalnej zmiennej `%s' jako parametru funkcji" + +#: awkgram.y:4226 +#, c-format +msgid "function name `%s' previously defined" +msgstr "nazwa funkcji `%s' została zdefiniowana poprzednio" + +#: awkgram.y:4394 awkgram.y:4400 +#, c-format +msgid "function `%s' called but never defined" +msgstr "funkcja `%s' została wywołana, ale nigdy nie została zdefiniowana" + +#: awkgram.y:4403 +#, c-format +msgid "function `%s' defined but never called directly" +msgstr "" +"funkcja `%s' została zdefiniowana, ale nigdy nie została wywołana " +"bezpośrednio" + +#: awkgram.y:4435 +#, c-format +msgid "regexp constant for parameter #%d yields boolean value" +msgstr "stałe wyrażenie regularne dla parametru #%d daje wartość logiczną" + +#: awkgram.y:4544 +#, c-format +msgid "" +"function `%s' called with space between name and `(',\n" +"or used as a variable or an array" +msgstr "" +"funkcja `%s' została wywołana z białymi znakami pomiędzy jej nazwą a znakiem " +"`(',\n" +"lub użyta jako zmienna lub jako tablica" + +#: awkgram.y:4791 eval.c:2056 +msgid "division by zero attempted" +msgstr "próba dzielenia przez zero" + +#: awkgram.y:4800 eval.c:2072 +#, c-format +msgid "division by zero attempted in `%%'" +msgstr "próba dzielenia przez zero w `%%'" + +#: builtin.c:120 +#, c-format +msgid "%s to \"%s\" failed (%s)" +msgstr "%s do \"%s\" nie powiódł się (%s)" + +#: builtin.c:121 +msgid "standard output" +msgstr "standardowe wyjście" + +#: builtin.c:135 +msgid "exp: received non-numeric argument" +msgstr "exp: otrzymano argument nie będący liczbą" + +#: builtin.c:141 +#, c-format +msgid "exp: argument %g is out of range" +msgstr "exp: argument %g jest poza zasięgiem" + +#: builtin.c:200 +#, c-format +msgid "fflush: cannot flush: pipe `%s' opened for reading, not writing" +msgstr "" +"fflush: nie można opróżnić: potok `%s' otwarty do czytania, a nie do zapisu" + +#: builtin.c:203 +#, c-format +msgid "fflush: cannot flush: file `%s' opened for reading, not writing" +msgstr "" +"fflush: nie można opróżnić: plik `%s' otwarty do czytania, a nie do zapisu" + +#: builtin.c:215 +#, c-format +msgid "fflush: `%s' is not an open file, pipe or co-process" +msgstr "fflush: `%s' nie jest ani otwartym plikiem, ani potokiem, ani procesem" + +#: builtin.c:333 +msgid "index: received non-string first argument" +msgstr "index: otrzymano pierwszy argument, który nie jest łańcuchem" + +#: builtin.c:335 +msgid "index: received non-string second argument" +msgstr "index: otrzymano drugi argument, który nie jest łańcuchem" + +#: builtin.c:457 +msgid "int: received non-numeric argument" +msgstr "int: otrzymano argument, który nie jest liczbą" + +#: builtin.c:493 +msgid "length: received array argument" +msgstr "length: otrzymano argument, który jest tablicą" + +#: builtin.c:496 +msgid "`length(array)' is a gawk extension" +msgstr "`length(tablica)' jest rozszerzeniem gawk" + +#: builtin.c:504 +msgid "length: received non-string argument" +msgstr "length: otrzymano argument, który nie jest łańcuchem" + +#: builtin.c:535 +msgid "log: received non-numeric argument" +msgstr "log: otrzymano argument, który nie jest liczbą" + +#: builtin.c:538 +#, c-format +msgid "log: received negative argument %g" +msgstr "log: otrzymano ujemny argument %g" + +#: builtin.c:694 builtin.c:699 +msgid "fatal: must use `count$' on all formats or none" +msgstr "fatal: należy użyć `count$' we wszystkich formatach lub nic" + +#: builtin.c:762 +#, c-format +msgid "field width is ignored for `%%' specifier" +msgstr "szerokość pola jest ignorowana dla specyfikatora `%%'" + +#: builtin.c:764 +#, c-format +msgid "precision is ignored for `%%' specifier" +msgstr "precyzja jest ignorowana dla specyfikatora `%%'" + +#: builtin.c:766 +#, c-format +msgid "field width and precision are ignored for `%%' specifier" +msgstr "szerokość pola i precyzja są ignorowane dla specyfikatora `%%'" + +#: builtin.c:817 +msgid "fatal: `$' is not permitted in awk formats" +msgstr "fatal: `$' jest niedozwolony w formatach awk" + +#: builtin.c:826 +msgid "fatal: arg count with `$' must be > 0" +msgstr "fatal: argument count z `$' musi być > 0" + +#: builtin.c:830 +#, c-format +msgid "fatal: arg count %ld greater than total number of supplied arguments" +msgstr "" +"fatal: argument count %ld większy niż całkowita suma argumentów dostarczonych" + +#: builtin.c:834 +msgid "fatal: `$' not permitted after period in format" +msgstr "fatal: `$' jest niedozwolony po kropce w formacie" + +#: builtin.c:850 +msgid "fatal: no `$' supplied for positional field width or precision" +msgstr "fatal: brak `$' dla pozycyjnej szerokości pola lub precyzji" + +#: builtin.c:921 +msgid "`l' is meaningless in awk formats; ignored" +msgstr "`l' jest bezsensowny w formatach awk; zignorowany" + +#: builtin.c:925 +msgid "fatal: `l' is not permitted in POSIX awk formats" +msgstr "fatal: `l' jest niedozwolony w formatach POSIX awk" + +#: builtin.c:938 +msgid "`L' is meaningless in awk formats; ignored" +msgstr "`L' jest bezsensowny w formatach awk; zignorowany" + +#: builtin.c:942 +msgid "fatal: `L' is not permitted in POSIX awk formats" +msgstr "fatal: `L' jest niedozwolony w formatach POSIX awk" + +#: builtin.c:955 +msgid "`h' is meaningless in awk formats; ignored" +msgstr "`h' jest bezsensowny w formatach awk; zignorowany" + +#: builtin.c:959 +msgid "fatal: `h' is not permitted in POSIX awk formats" +msgstr "fatal: `h' jest niedozwolony w formatach POSIX awk" + +#: builtin.c:1272 +#, c-format +msgid "[s]printf: value %g is out of range for `%%%c' format" +msgstr "[s]printf: wartość %g jest poza zasięgiem dla formatu `%%%c'" + +#: builtin.c:1332 +#, c-format +msgid "ignoring unknown format specifier character `%c': no argument converted" +msgstr "" +"pominięcie nieznanego formatu specyfikatora znaku `%c': nie skonwertowano " +"argumentu" + +#: builtin.c:1337 +msgid "fatal: not enough arguments to satisfy format string" +msgstr "" +"fatal: brak wystarczającej liczby argumentów, aby zaspokoić łańcuch " +"formatujący" + +#: builtin.c:1339 +msgid "^ ran out for this one" +msgstr "zabrakło ^" + +#: builtin.c:1346 +msgid "[s]printf: format specifier does not have control letter" +msgstr "[s]printf: specyfikator formatu nie posiada kontrolnej litery" + +#: builtin.c:1349 +msgid "too many arguments supplied for format string" +msgstr "zbyt dużo podanych argumentów w łańcuchu formatującym" + +#: builtin.c:1423 builtin.c:1434 +msgid "printf: no arguments" +msgstr "printf: brak argumentów" + +#: builtin.c:1475 +msgid "sqrt: received non-numeric argument" +msgstr "sqrt: otrzymano argument, który nie jest liczbą" + +#: builtin.c:1479 +#, c-format +msgid "sqrt: called with negative argument %g" +msgstr "sqrt: wywołana z ujemnym argumentem %g" + +#: builtin.c:1503 +#, c-format +msgid "substr: length %g is not >= 1" +msgstr "substr: długość %g nie jest >= 1" + +#: builtin.c:1505 +#, c-format +msgid "substr: length %g is not >= 0" +msgstr "substr: długość %g nie jest >= 0" + +#: builtin.c:1512 +#, c-format +msgid "substr: non-integer length %g will be truncated" +msgstr "substr: długość %g, która nie jest liczbą całkowitą, zostanie obcięta" + +#: builtin.c:1517 +#, c-format +msgid "substr: length %g too big for string indexing, truncating to %g" +msgstr "substr: długość %g zbyt duża dla indeksu łańcucha, obcinanie do %g" + +#: builtin.c:1529 +#, c-format +msgid "substr: start index %g is invalid, using 1" +msgstr "substr: początkowy indeks %g jest nieprawidłowy, nastąpi użycie 1" + +#: builtin.c:1534 +#, c-format +msgid "substr: non-integer start index %g will be truncated" +msgstr "" +"substr: początkowy indeks %g, który nie jest liczbą całkowitą, zostanie " +"obcięty" + +#: builtin.c:1559 +msgid "substr: source string is zero length" +msgstr "substr: łańcuch źródłowy ma zerową długość" + +#: builtin.c:1575 +#, c-format +msgid "substr: start index %g is past end of string" +msgstr "substr: początkowy indeks %g leży poza końcem łańcucha" + +#: builtin.c:1583 +#, c-format +msgid "" +"substr: length %g at start index %g exceeds length of first argument (%lu)" +msgstr "" +"substr: długość %g zaczynając od %g przekracza długość pierwszego argumentu " +"(%lu)" + +#: builtin.c:1657 +msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" +msgstr "" +"strftime: wartość formatu w PROCINFO[\"strftime\"] posiada typ numeryczny" + +#: builtin.c:1680 +msgid "strftime: received non-numeric second argument" +msgstr "strftime: otrzymano drugi argument, który nie jest liczbą" + +#: builtin.c:1683 +msgid "strftime: second argument less than 0 or too big for time_t" +msgstr "strftime: drugi argument mniejszy od 0 lub zbyt duży dla time_t" + +#: builtin.c:1690 +msgid "strftime: received non-string first argument" +msgstr "strftime: otrzymano pierwszy argument, który nie jest łańcuchem" + +#: builtin.c:1696 +msgid "strftime: received empty format string" +msgstr "strftime: otrzymano pusty łańcuch formatujący" + +#: builtin.c:1762 +msgid "mktime: received non-string argument" +msgstr "mktime: otrzymano argument, który nie jest łańcuchem" + +#: builtin.c:1779 +msgid "mktime: at least one of the values is out of the default range" +msgstr "mktime: przynajmniej jedna z wartości jest poza domyślnym zakresem" + +#: builtin.c:1814 +msgid "'system' function not allowed in sandbox mode" +msgstr "funkcja 'system' nie jest dozwolona w trybie piaskownicy" + +#: builtin.c:1819 +msgid "system: received non-string argument" +msgstr "system: otrzymano argument, który nie jest łańcuchem" + +#: builtin.c:1874 eval.c:1159 eval.c:1790 eval.c:1803 +#, c-format +msgid "reference to uninitialized variable `%s'" +msgstr "odwołanie do niezainicjowanej zmiennej `%s'" + +#: builtin.c:1941 +#, c-format +msgid "reference to uninitialized field `$%d'" +msgstr "odwołanie do niezainicjowanego pola `$%d'" + +#: builtin.c:2028 +msgid "tolower: received non-string argument" +msgstr "tolower: otrzymano argument, który nie jest łańcuchem" + +#: builtin.c:2062 +msgid "toupper: received non-string argument" +msgstr "toupper: otrzymano argument, który nie jest łańcuchem" + +#: builtin.c:2098 +msgid "atan2: received non-numeric first argument" +msgstr "atan2: otrzymano pierwszy argument, który nie jest liczbą" + +#: builtin.c:2100 +msgid "atan2: received non-numeric second argument" +msgstr "atan2: otrzymano drugi argument, który nie jest liczbą" + +#: builtin.c:2119 +msgid "sin: received non-numeric argument" +msgstr "sin: otrzymano argument, który nie jest liczbą" + +#: builtin.c:2135 +msgid "cos: received non-numeric argument" +msgstr "cos: otrzymano argument, który nie jest liczbą" + +#: builtin.c:2188 +msgid "srand: received non-numeric argument" +msgstr "srand: otrzymano argument, który nie jest liczbą" + +#: builtin.c:2219 +msgid "match: third argument is not an array" +msgstr "match: otrzymano trzeci argument, który nie jest tablicą" + +#: builtin.c:2483 +msgid "gensub: third argument of 0 treated as 1" +msgstr "gensub: trzeci argument 0 potraktowany jako 1" + +#: builtin.c:2776 +msgid "lshift: received non-numeric first argument" +msgstr "lshift: otrzymano pierwszy argument, który nie jest liczbą" + +#: builtin.c:2778 +msgid "lshift: received non-numeric second argument" +msgstr "lshift: otrzymano drugi argument, który nie jest liczbą" + +#: builtin.c:2784 +#, c-format +msgid "lshift(%lf, %lf): negative values will give strange results" +msgstr "lshift(%lf, %lf): ujemne wartości spowodują dziwne wyniki" + +#: builtin.c:2786 +#, c-format +msgid "lshift(%lf, %lf): fractional values will be truncated" +msgstr "lshift(%lf, %lf): ułamkowe wartości zostaną obcięte" + +#: builtin.c:2788 +#, c-format +msgid "lshift(%lf, %lf): too large shift value will give strange results" +msgstr "" +"lshift(%lf, %lf): zbyt duża wartość przesunięcia spowoduje dziwne wyniki" + +#: builtin.c:2813 +msgid "rshift: received non-numeric first argument" +msgstr "rshift: otrzymano pierwszy argument, który nie jest liczbą" + +#: builtin.c:2815 +msgid "rshift: received non-numeric second argument" +msgstr "rshift: otrzymano drugi argument, który nie jest liczbą" + +#: builtin.c:2821 +#, c-format +msgid "rshift(%lf, %lf): negative values will give strange results" +msgstr "rshift(%lf, %lf): ujemne wartości spowodują dziwne wyniki" + +#: builtin.c:2823 +#, c-format +msgid "rshift(%lf, %lf): fractional values will be truncated" +msgstr "rshift(%lf, %lf): ułamkowe wartości zostaną obcięte" + +#: builtin.c:2825 +#, c-format +msgid "rshift(%lf, %lf): too large shift value will give strange results" +msgstr "" +"rshift(%lf, %lf): zbyt duża wartość przesunięcia spowoduje dziwne wyniki" + +#: builtin.c:2850 +msgid "and: received non-numeric first argument" +msgstr "and: otrzymano pierwszy argument, który nie jest liczbą" + +#: builtin.c:2852 +msgid "and: received non-numeric second argument" +msgstr "and: otrzymano drugi argument, który nie jest liczbą" + +#: builtin.c:2858 +#, c-format +msgid "and(%lf, %lf): negative values will give strange results" +msgstr "and(%lf, %lf): ujemne wartości spowodują dziwne wyniki" + +#: builtin.c:2860 +#, c-format +msgid "and(%lf, %lf): fractional values will be truncated" +msgstr "and(%lf, %lf): ułamkowe wartości zostaną obcięte" + +#: builtin.c:2885 +msgid "or: received non-numeric first argument" +msgstr "or: otrzymano pierwszy argument, który nie jest liczbą" + +#: builtin.c:2887 +msgid "or: received non-numeric second argument" +msgstr "or: otrzymano drugi argument, który nie jest liczbą" + +#: builtin.c:2893 +#, c-format +msgid "or(%lf, %lf): negative values will give strange results" +msgstr "or(%lf, %lf): ujemne wartości spowodują dziwne wyniki" + +#: builtin.c:2895 +#, c-format +msgid "or(%lf, %lf): fractional values will be truncated" +msgstr "or(%lf, %lf): ułamkowe wartości zostaną obcięte" + +#: builtin.c:2923 +msgid "xor: received non-numeric first argument" +msgstr "xor: otrzymano pierwszy argument, który nie jest liczbą" + +#: builtin.c:2925 +msgid "xor: received non-numeric second argument" +msgstr "xor: otrzymano drugi argument, który nie jest liczbą" + +#: builtin.c:2931 +#, c-format +msgid "xor(%lf, %lf): negative values will give strange results" +msgstr "xor(%lf, %lf): ujemne wartości spowodują dziwne wyniki" + +#: builtin.c:2933 +#, c-format +msgid "xor(%lf, %lf): fractional values will be truncated" +msgstr "xor(%lf, %lf): ułamkowe wartości zostaną obcięte" + +#: builtin.c:2957 builtin.c:2963 +msgid "compl: received non-numeric argument" +msgstr "compl: otrzymano argument, który nie jest liczbą" + +#: builtin.c:2965 +#, c-format +msgid "compl(%lf): negative value will give strange results" +msgstr "compl(%lf): ujemne wartości spowodują dziwne wyniki" + +#: builtin.c:2967 +#, c-format +msgid "compl(%lf): fractional value will be truncated" +msgstr "compl(%lf): ułamkowe wartości zostaną obcięte" + +#: builtin.c:3136 +#, c-format +msgid "dcgettext: `%s' is not a valid locale category" +msgstr "dcgettext: `%s' nie jest prawidłową kategorią lokalizacji" + +#: eval.c:412 +#, c-format +msgid "unknown nodetype %d" +msgstr "nieznany typ węzła %d" + +#: eval.c:423 eval.c:437 +#, c-format +msgid "unknown opcode %d" +msgstr "nieznany opcode %d" + +#: eval.c:434 +#, c-format +msgid "opcode %s not an operator or keyword" +msgstr "opcode %s nie jest operatorem ani słowem kluczowym" + +#: eval.c:488 +msgid "buffer overflow in genflags2str" +msgstr "przepełnienie bufora w genflags2str" + +#: eval.c:698 +#, c-format +msgid "" +"\n" +"\t# Function Call Stack:\n" +"\n" +msgstr "" +"\n" +"\t# Stos Wywoławczy Funkcji:\n" +"\n" + +#: eval.c:725 +msgid "`IGNORECASE' is a gawk extension" +msgstr "`IGNORECASE' jest rozszerzeniem gawk" + +#: eval.c:754 +msgid "`BINMODE' is a gawk extension" +msgstr "`BINMODE' jest rozszerzeniem gawk" + +#: eval.c:812 +#, c-format +msgid "BINMODE value `%s' is invalid, treated as 3" +msgstr "wartość BINMODE `%s' jest nieprawidłowa, przyjęto ją jako 3" + +#: eval.c:902 +#, c-format +msgid "bad `%sFMT' specification `%s'" +msgstr "zła specyfikacja `%sFMT' `%s'" + +#: eval.c:980 +msgid "turning off `--lint' due to assignment to `LINT'" +msgstr "wyłączenie `--lint' z powodu przypisania do `LINT'" + +#: eval.c:1127 eval.c:1777 +#, c-format +msgid "can't use function name `%s' as variable or array" +msgstr "nie można użyć nazwy funkcji `%s' jako zmiennej lub tablicy" + +#: eval.c:1158 eval.c:1789 eval.c:1802 +#, c-format +msgid "reference to uninitialized argument `%s'" +msgstr "odwołanie do niezainicjowanego argumentu `%s'" + +#: eval.c:1177 +msgid "attempt to field reference from non-numeric value" +msgstr "próba odwołania do pola poprzez nienumeryczną wartość" + +#: eval.c:1179 +msgid "attempt to field reference from null string" +msgstr "próba odwołania z zerowego łańcucha" + +#: eval.c:1185 +#, c-format +msgid "attempt to access field %ld" +msgstr "próba dostępu do pola %ld" + +#: eval.c:1194 +#, c-format +msgid "reference to uninitialized field `$%ld'" +msgstr "odwołanie do niezainicjowanego pola `$%ld'" + +#: eval.c:1256 +#, c-format +msgid "function `%s' called with more arguments than declared" +msgstr "" +"funkcja `%s' została wywołana z większą ilością argumentów niż zostało to " +"zadeklarowane" + +#: eval.c:1437 +#, c-format +msgid "unwind_stack: unexpected type `%s'" +msgstr "unwind_stack: niespodziewany typ `%s'" + +#: eval.c:1532 +msgid "division by zero attempted in `/='" +msgstr "próba dzielenia przez zero w `/='" + +#: eval.c:1539 +#, c-format +msgid "division by zero attempted in `%%='" +msgstr "próba dzielenia przez zero w `%%='" + +#: eval.c:1876 eval.c:2122 +#, c-format +msgid "attempt to use array `%s[\"%.*s\"]' in a scalar context" +msgstr "próba użycia tablicy `%s[\"%.*s\"]' w kontekście skalaru" + +#: eval.c:1907 +msgid "assignment used in conditional context" +msgstr "przypisanie użyte w kontekście warunkowym" + +#: eval.c:1911 +msgid "statement has no effect" +msgstr "instrukcja nie ma żadnego efektu" + +#: eval.c:2343 +#, c-format +msgid "for loop: array `%s' changed size from %ld to %ld during loop execution" +msgstr "" +"pętla for: tablica `%s' zmieniła rozmiar z %ld do %ld podczas wykonywania " +"pętli" + +#: eval.c:2458 +#, c-format +msgid "function called indirectly through `%s' does not exist" +msgstr "pośrednio wywołana funkcja poprzez `%s' nie istnieje" + +#: eval.c:2470 +#, c-format +msgid "function `%s' not defined" +msgstr "funkcja `%s' nie została zdefiniowana" + +#: eval.c:2511 +#, c-format +msgid "non-redirected `getline' invalid inside `%s' rule" +msgstr "" +"komenda `getline' bez przekierowania jest nieprawidłowa wewnątrz reguły `%s'" + +#: eval.c:2600 +#, c-format +msgid "error reading input file `%s': %s" +msgstr "błąd podczas czytania z pliku `%s': %s" + +#: eval.c:2614 +#, c-format +msgid "`nextfile' cannot be called from a `%s' rule" +msgstr "instrukcja `nextfile' nie może być wywołana z wnętrza reguły `%s'" + +#: eval.c:2661 +msgid "`exit' cannot be called in the current context" +msgstr "instrukcja `exit' nie może być wywołana w tym kontekście" + +#: eval.c:2700 +#, c-format +msgid "`next' cannot be called from a `%s' rule" +msgstr "instrukcja `next' nie może być wywołana z wnętrza reguły `%s'" + +#: eval.c:2766 +#, c-format +msgid "Sorry, don't know how to interpret `%s'" +msgstr "Niestety nie wiem jak zinterpretować `%s'" + +#: ext.c:54 +msgid "extensions are not allowed in sandbox mode" +msgstr "rozszerzenia nie są dozwolone w trybie piaskownicy" + +#: ext.c:60 ext.c:65 +msgid "`extension' is a gawk extension" +msgstr "`extension' jest rozszerzeniem gawk" + +#: ext.c:75 +#, c-format +msgid "fatal: extension: cannot open `%s' (%s)\n" +msgstr "fatal: rozszerzenie: nie można otworzyć `%s' (%s)\n" + +#: ext.c:84 +#, c-format +msgid "" +"fatal: extension: library `%s': does not define " +"`plugin_is_GPL_compatible' (%s)\n" +msgstr "" +"fatal: rozszerzenie: biblioteka `%s': nie definiuje " +"`plugin_is_GPL_compatible' (%s)\n" + +#: ext.c:93 +#, c-format +msgid "fatal: extension: library `%s': cannot call function `%s' (%s)\n" +msgstr "" +"fatal: rozszerzenie: biblioteka `%s': nie można wywołać funkcji `%s' (%s)\n" + +#: ext.c:127 +msgid "extension: missing function name" +msgstr "rozszerzenie: brakująca nazwa funkcji" + +#: ext.c:132 +#, c-format +msgid "extension: illegal character `%c' in function name `%s'" +msgstr "rozszerzenie: nieprawidłowy znak `%c' w nazwie funkcji `%s'" + +#: ext.c:141 +#, c-format +msgid "extension: can't redefine function `%s'" +msgstr "rozszerzenie: nie można zredefiniować funkcji `%s'" + +#: ext.c:145 +#, c-format +msgid "extension: function `%s' already defined" +msgstr "rozserzenie: funkcja `%s' została już zdefiniowana" + +#: ext.c:150 +#, c-format +msgid "extension: function name `%s' previously defined" +msgstr "rozserzenie: nazwa funkcji `%s' została zdefiniowana wcześniej" + +#: ext.c:152 +#, c-format +msgid "extension: can't use gawk built-in `%s' as function name" +msgstr "rozszerzenie: nie można użyć wbudowanej w gawk `%s' jako nazwy funkcji" + +#: ext.c:156 +#, c-format +msgid "make_builtin: negative argument count for function `%s'" +msgstr "make_builtin: ujemny licznik argumentów dla funkcji `%s'" + +#: ext.c:259 +#, c-format +msgid "function `%s' defined to take no more than %d argument(s)" +msgstr "funkcja `%s' zdefiniowana aby pobrać nie więcej niż %d argument(ów)" + +#: ext.c:262 +#, c-format +msgid "function `%s': missing argument #%d" +msgstr "funkcja `%s': brakuje #%d argumentu" + +#: ext.c:279 +#, c-format +msgid "function `%s': argument #%d: attempt to use scalar as an array" +msgstr "funkcja `%s': argument #%d: próba użycia skalaru jako tablicy" + +#: ext.c:283 +#, c-format +msgid "function `%s': argument #%d: attempt to use array as a scalar" +msgstr "funkcja `%s': argument #%d: próba użycia tablicy jako skalaru" + +#: ext.c:296 +msgid "Operation Not Supported" +msgstr "Operacja nie jest wspierana" + +#: field.c:328 +msgid "NF set to negative value" +msgstr "NF ustawiony na wartość ujemną" + +#: field.c:951 field.c:958 field.c:962 +msgid "split: fourth argument is a gawk extension" +msgstr "split: czwarty argument jest rozszerzeniem gawk" + +#: field.c:955 +msgid "split: fourth argument is not an array" +msgstr "split: czwarty argument nie jest tablicą" + +#: field.c:969 +msgid "split: second argument is not an array" +msgstr "split: drugi argument nie jest tablicą" + +#: field.c:973 +msgid "split: cannot use the same array for second and fourth args" +msgstr "" +"split: nie można użyć tej samej tablicy dla drugiego i czwartego argumentu" + +#: field.c:978 +msgid "split: cannot use a subarray of second arg for fourth arg" +msgstr "" +"split: nie można użyć podtablicy drugiego argumentu dla czwartego argumentu" + +#: field.c:981 +msgid "split: cannot use a subarray of fourth arg for second arg" +msgstr "" +"split: nie można użyć podtablicy czwartego argumentu dla drugiego argumentu" + +#: field.c:1010 +msgid "split: null string for third arg is a gawk extension" +msgstr "split: zerowy łańcuch dla trzeciego argumentu jest rozszerzeniem gawk" + +#: field.c:1050 +msgid "patsplit: fourth argument is not an array" +msgstr "patsplit: czwarty argument nie jest tablicą" + +#: field.c:1055 +msgid "patsplit: second argument is not an array" +msgstr "patsplit: drugi argument nie jest tablicą" + +#: field.c:1061 +msgid "patsplit: third argument must be non-null" +msgstr "patsplit: trzeci argument nie może być pusty" + +#: field.c:1065 +msgid "patsplit: cannot use the same array for second and fourth args" +msgstr "" +"patsplit: nie można użyć tej samej tablicy dla drugiego i czwartego argumentu" + +#: field.c:1070 +msgid "patsplit: cannot use a subarray of second arg for fourth arg" +msgstr "" +"patsplit: nie można użyć podtablicy drugiego argumentu dla czwartego " +"argumentu" + +#: field.c:1073 +msgid "patsplit: cannot use a subarray of fourth arg for second arg" +msgstr "" +"patsplit: nie można użyć podtablicy czwartego argumentu dla drugiego " +"argumentu" + +#: field.c:1110 +msgid "`FIELDWIDTHS' is a gawk extension" +msgstr "`FIELDWIDTHS' jest rozszerzeniem gawk" + +#: field.c:1173 +#, c-format +msgid "invalid FIELDWIDTHS value, near `%s'" +msgstr "nieprawidłowa wartość FIELDWIDTHS, w pobliżu `%s'" + +#: field.c:1246 +msgid "null string for `FS' is a gawk extension" +msgstr "zerowy łańcuch dla `FS' jest rozszerzeniem gawk" + +#: field.c:1250 +msgid "old awk does not support regexps as value of `FS'" +msgstr "stary awk nie wspiera wyrażeń regularnych jako wartości `FS'" + +#: field.c:1369 +msgid "`FPAT' is a gawk extension" +msgstr "`FPAT' jest rozszerzeniem gawk" + +#: getopt.c:604 getopt.c:633 +#, fuzzy, c-format +msgid "%s: option '%s' is ambiguous; possibilities:" +msgstr "%s: opcja '%s' jest niejednoznaczna\n" + +#: getopt.c:679 getopt.c:683 +#, c-format +msgid "%s: option '--%s' doesn't allow an argument\n" +msgstr "%s: opcja '--%s' nie może mieć argumentów\n" + +#: getopt.c:692 getopt.c:697 +#, c-format +msgid "%s: option '%c%s' doesn't allow an argument\n" +msgstr "%s: opcja '%c%s' nie może mieć argumentów\n" + +#: getopt.c:740 getopt.c:759 +#, c-format +msgid "%s: option '--%s' requires an argument\n" +msgstr "%s: opcja '--%s' wymaga argumentu\n" + +#: getopt.c:797 getopt.c:800 +#, c-format +msgid "%s: unrecognized option '--%s'\n" +msgstr "%s: nieznana opcja '--%s'\n" + +#: getopt.c:808 getopt.c:811 +#, c-format +msgid "%s: unrecognized option '%c%s'\n" +msgstr "%s: nieznana opcja '%c%s'\n" + +#: getopt.c:860 getopt.c:863 +#, c-format +msgid "%s: invalid option -- '%c'\n" +msgstr "%s: błędna opcja -- '%c'\n" + +#: getopt.c:916 getopt.c:933 getopt.c:1143 getopt.c:1161 +#, c-format +msgid "%s: option requires an argument -- '%c'\n" +msgstr "%s: opcja wymaga argumentu -- '%c'\n" + +#: getopt.c:989 getopt.c:1005 +#, c-format +msgid "%s: option '-W %s' is ambiguous\n" +msgstr "%s: opcja '-W %s' jest niejednoznaczna\n" + +#: getopt.c:1029 getopt.c:1047 +#, c-format +msgid "%s: option '-W %s' doesn't allow an argument\n" +msgstr "%s: opcja '-W %s' nie może mieć argumentów\n" + +#: getopt.c:1068 getopt.c:1086 +#, c-format +msgid "%s: option '-W %s' requires an argument\n" +msgstr "%s: opcja '-W %s' wymaga argumentu\n" + +#: io.c:280 +#, c-format +msgid "command line argument `%s' is a directory: skipped" +msgstr "argument linii poleceń `%s' jest katalogiem: pominięto" + +#: io.c:283 io.c:385 +#, c-format +msgid "cannot open file `%s' for reading (%s)" +msgstr "nie można otworzyć pliku `%s' do czytania (%s)" + +#: io.c:501 +#, c-format +msgid "close of fd %d (`%s') failed (%s)" +msgstr "zamknięcie fd %d (`%s') nie powiodło się (%s)" + +#: io.c:578 +msgid "redirection not allowed in sandbox mode" +msgstr "przekierowanie nie jest dozwolone w trybie piaskownicy" + +#: io.c:612 +#, c-format +msgid "expression in `%s' redirection only has numeric value" +msgstr "wyrażenie w przekierowaniu `%s' ma tylko wartość numeryczną" + +#: io.c:618 +#, c-format +msgid "expression for `%s' redirection has null string value" +msgstr "wyrażenie dla przekierowania `%s' ma zerową wartość łańcucha" + +#: io.c:623 +#, c-format +msgid "filename `%s' for `%s' redirection may be result of logical expression" +msgstr "" +"nazwa pliku `%s' dla przekierowania `%s' może być rezultatem logicznego " +"wyrażenia" + +#: io.c:666 +#, c-format +msgid "unnecessary mixing of `>' and `>>' for file `%.*s'" +msgstr "niepotrzebne mieszanie `>' i `>>' dla pliku `%.*s'" + +#: io.c:719 +#, c-format +msgid "can't open pipe `%s' for output (%s)" +msgstr "nie można otworzyć potoku `%s' jako wyjścia (%s)" + +#: io.c:729 +#, c-format +msgid "can't open pipe `%s' for input (%s)" +msgstr "nie można otworzyć potoku `%s' jako wejścia (%s)" + +#: io.c:752 +#, c-format +msgid "can't open two way pipe `%s' for input/output (%s)" +msgstr "" +"nie można otworzyć dwukierunkowego potoku `%s' jako wejścia/wyjścia (%s)" + +#: io.c:834 +#, c-format +msgid "can't redirect from `%s' (%s)" +msgstr "nie można przekierować z `%s' (%s)" + +#: io.c:837 +#, c-format +msgid "can't redirect to `%s' (%s)" +msgstr "nie można przekierować do `%s' (%s)" + +#: io.c:888 +msgid "" +"reached system limit for open files: starting to multiplex file descriptors" +msgstr "" +"osiągnięto systemowy limit otwartych plików: rozpoczęcie multipleksowania " +"deskryptorów plików" + +#: io.c:904 +#, c-format +msgid "close of `%s' failed (%s)." +msgstr "zamknięcie `%s' nie powiodło się (%s)." + +#: io.c:912 +msgid "too many pipes or input files open" +msgstr "zbyt dużo otwartych potoków lub plików wejściowych" + +#: io.c:934 +msgid "close: second argument must be `to' or `from'" +msgstr "close: drugim argumentem musi być `to' lub `from'" + +#: io.c:951 +#, c-format +msgid "close: `%.*s' is not an open file, pipe or co-process" +msgstr "" +"close: `%.*s' nie jest ani otwartym plikiem, ani potokiem, ani procesem" + +#: io.c:956 +msgid "close of redirection that was never opened" +msgstr "zamknięcie przekierowania, które nigdy nie zostało otwarte" + +#: io.c:1053 +#, c-format +msgid "close: redirection `%s' not opened with `|&', second argument ignored" +msgstr "" +"close: przekierowanie `%s' nie zostało otwarte z `|&', drugi argument " +"zignorowany" + +#: io.c:1069 +#, c-format +msgid "failure status (%d) on pipe close of `%s' (%s)" +msgstr "status awarii (%d) podczas zamykania potoku `%s' (%s)" + +#: io.c:1072 +#, c-format +msgid "failure status (%d) on file close of `%s' (%s)" +msgstr "status awarii (%d) podczas zamykania pliku `%s' (%s)" + +#: io.c:1092 +#, c-format +msgid "no explicit close of socket `%s' provided" +msgstr "brak jawnego zamknięcia gniazdka `%s'" + +#: io.c:1095 +#, c-format +msgid "no explicit close of co-process `%s' provided" +msgstr "brak jawnego zamknięcia procesu pomocniczego `%s'" + +#: io.c:1098 +#, c-format +msgid "no explicit close of pipe `%s' provided" +msgstr "brak jawnego zamknięcia potoku `%s'" + +#: io.c:1101 +#, c-format +msgid "no explicit close of file `%s' provided" +msgstr "brak jawnego zamknięcia pliku `%s'" + +#: io.c:1129 io.c:1184 main.c:794 main.c:831 +#, c-format +msgid "error writing standard output (%s)" +msgstr "błąd podczas zapisu na standardowe wyjście (%s)" + +#: io.c:1133 io.c:1189 +#, c-format +msgid "error writing standard error (%s)" +msgstr "błąd podczas zapisu na standardowe wyjście diagnostyczne (%s)" + +#: io.c:1141 +#, c-format +msgid "pipe flush of `%s' failed (%s)." +msgstr "opróżnienie potoku `%s' nie powiodło się (%s)." + +#: io.c:1144 +#, c-format +msgid "co-process flush of pipe to `%s' failed (%s)." +msgstr "" +"opróżnienie potoku do `%s' przez proces pomocniczy nie powiodło się (%s)." + +#: io.c:1147 +#, c-format +msgid "file flush of `%s' failed (%s)." +msgstr "opróżnienie pliku `%s' nie powiodło się (%s)." + +#: io.c:1262 +#, c-format +msgid "local port %s invalid in `/inet'" +msgstr "nieprawidłowy lokalny port %s w `/inet'" + +#: io.c:1279 +#, c-format +msgid "remote host and port information (%s, %s) invalid" +msgstr "informacje o zdalnym hoście i porcie są nieprawidłowe (%s, %s)" + +#: io.c:1431 +#, c-format +msgid "no (known) protocol supplied in special filename `%s'" +msgstr "nie dostarczono (znanego) protokołu w specjalnym pliku `%s'" + +#: io.c:1445 +#, c-format +msgid "special file name `%s' is incomplete" +msgstr "specjalna nazwa pliku `%s' jest niekompletna" + +#: io.c:1462 +msgid "must supply a remote hostname to `/inet'" +msgstr "należy dostarczyć nazwę zdalnego hosta do `/inet'" + +#: io.c:1480 +msgid "must supply a remote port to `/inet'" +msgstr "należy dostarczyć numer zdalnego portu do `/inet'" + +#: io.c:1526 +msgid "TCP/IP communications are not supported" +msgstr "Komunikacja TCP/IP nie jest wspierana" + +#: io.c:1693 +#, c-format +msgid "could not open `%s', mode `%s'" +msgstr "nie można otworzyć `%s', tryb `%s'" + +#: io.c:1747 +#, c-format +msgid "close of master pty failed (%s)" +msgstr "zamknięcie nadrzędnego pty nie powiodło się (%s)" + +#: io.c:1749 io.c:1917 io.c:2074 +#, c-format +msgid "close of stdout in child failed (%s)" +msgstr "" +"zamknięcie standardowego wyjścia w procesie potomnym nie powiodło się (%s)" + +#: io.c:1752 +#, c-format +msgid "moving slave pty to stdout in child failed (dup: %s)" +msgstr "" +"przesunięcie podległego pty na standardowe wyjście w procesie potomnym nie " +"powiodło się (dup: %s)" + +#: io.c:1754 io.c:1922 +#, c-format +msgid "close of stdin in child failed (%s)" +msgstr "" +"zamknięcie standardowego wejścia w procesie potomnym nie powiodło się (%s)" + +#: io.c:1757 +#, c-format +msgid "moving slave pty to stdin in child failed (dup: %s)" +msgstr "" +"przesunięcie podległego pty na standardowe wejście w procesie potomnym nie " +"powiodło się (dup: %s)" + +#: io.c:1759 io.c:1780 +#, c-format +msgid "close of slave pty failed (%s)" +msgstr "zamknięcie podległego pty nie powiodło się (%s)" + +#: io.c:1858 io.c:1920 io.c:2052 io.c:2077 +#, c-format +msgid "moving pipe to stdout in child failed (dup: %s)" +msgstr "" +"przesunięcie potoku na standardowe wyjście w procesie potomnym nie powiodło " +"się (dup: %s)" + +#: io.c:1865 io.c:1925 +#, c-format +msgid "moving pipe to stdin in child failed (dup: %s)" +msgstr "" +"przesunięcie potoku na standardowe wejście w procesie potomnym nie powiodło " +"się (dup: %s)" + +#: io.c:1885 io.c:2067 +msgid "restoring stdout in parent process failed\n" +msgstr "" +"odzyskanie standardowego wyjścia w procesie potomnym nie powiodło się\n" + +#: io.c:1893 +msgid "restoring stdin in parent process failed\n" +msgstr "" +"odzyskanie standardowego wejścia w procesie potomnym nie powiodło się\n" + +#: io.c:1928 io.c:2079 io.c:2093 +#, c-format +msgid "close of pipe failed (%s)" +msgstr "zamknięcie potoku nie powiodło się (%s)" + +#: io.c:1973 +msgid "`|&' not supported" +msgstr "`|&' nie jest wspierany" + +#: io.c:2039 +#, c-format +msgid "cannot open pipe `%s' (%s)" +msgstr "nie można otworzyć potoku `%s' (%s)" + +#: io.c:2087 +#, c-format +msgid "cannot create child process for `%s' (fork: %s)" +msgstr "nie można utworzyć procesu potomnego dla `%s' (fork: %s)" + +#: io.c:2520 +#, c-format +msgid "data file `%s' is empty" +msgstr "plik danych `%s' jest pusty" + +#: io.c:2561 io.c:2569 +msgid "could not allocate more input memory" +msgstr "nie można zarezerwować więcej pamięci wejściowej" + +#: io.c:3127 +msgid "multicharacter value of `RS' is a gawk extension" +msgstr "wieloznakowa wartość `RS' jest rozszerzeniem gawk" + +#: io.c:3232 +msgid "IPv6 communication is not supported" +msgstr "Komunikacja IPv6 nie jest wspierana" + +#: main.c:366 +msgid "`-m[fr]' option irrelevant in gawk" +msgstr "nieistotna opcja `-m[fr]' w gawk" + +#: main.c:368 +msgid "-m option usage: `-m[fr] nnn'" +msgstr "użycie opcji -m: `-m[fr] nnn'" + +#: main.c:391 +msgid "empty argument to `-e/--source' ignored" +msgstr "pusty argument dla opcji `-e/--source' został zignorowany" + +#: main.c:462 +#, c-format +msgid "%s: option `-W %s' unrecognized, ignored\n" +msgstr "%s: opcja `-W %s' nierozpoznana i zignorowana\n" + +#: main.c:515 +#, c-format +msgid "%s: option requires an argument -- %c\n" +msgstr "%s: opcja musi mieć argument -- %c\n" + +#: main.c:536 +msgid "environment variable `POSIXLY_CORRECT' set: turning on `--posix'" +msgstr "" +"zmienna środowiskowa `POSIXLY_CORRECT' ustawiona: `--posix' został włączony" + +#: main.c:542 +msgid "`--posix' overrides `--traditional'" +msgstr "opcja `--posix' zostanie użyta nad `--traditional'" + +#: main.c:553 +msgid "`--posix'/`--traditional' overrides `--non-decimal-data'" +msgstr "`--posix'/`--traditional' użyte nad opcją `--non-decimal-data'" + +#: main.c:557 +#, c-format +msgid "running %s setuid root may be a security problem" +msgstr "" +"uruchamianie %s setuid root może być problemem pod względem bezpieczeństwa" + +#: main.c:562 +msgid "`--posix' overrides `--binary'" +msgstr "opcja `--posix' zostanie użyta nad `--binary'" + +#: main.c:613 +#, c-format +msgid "can't set binary mode on stdin (%s)" +msgstr "nie można ustawić trybu binarnego na standardowym wejściu (%s)" + +#: main.c:616 +#, c-format +msgid "can't set binary mode on stdout (%s)" +msgstr "nie można ustawić trybu binarnego na standardowym wyjściu (%s)" + +#: main.c:618 +#, c-format +msgid "can't set binary mode on stderr (%s)" +msgstr "nie można ustawić trybu binarnego na wyjściu diagnostycznym (%s)" + +#: main.c:657 +msgid "no program text at all!" +msgstr "brak tekstu programu!" + +#: main.c:734 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] -f progfile [--] file ...\n" +msgstr "" +"Użycie: %s [styl opcji POSIX lub GNU] -f plik_z_programem [--] plik ...\n" + +#: main.c:736 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] [--] %cprogram%c file ...\n" +msgstr "Użycie: %s [styl opcji POSIX lub GNU] [--] %cprogram%c plik ...\n" + +#: main.c:741 +msgid "POSIX options:\t\tGNU long options: (standard)\n" +msgstr "Opcje POSIX:\t\tDługie opcje GNU (standard):\n" + +#: main.c:742 +msgid "\t-f progfile\t\t--file=progfile\n" +msgstr "\t-f program\t\t--file=program\n" + +#: main.c:743 +msgid "\t-F fs\t\t\t--field-separator=fs\n" +msgstr "\t-F fs\t\t\t--field-separator=fs\n" + +#: main.c:744 +msgid "\t-v var=val\t\t--assign=var=val\n" +msgstr "\t-v zmienna=wartość\t--assign=zmienna=wartość\n" + +#: main.c:745 +msgid "Short options:\t\tGNU long options: (extensions)\n" +msgstr "Krótkie opcje:\t\tDługie opcje GNU: (rozszerzenia)\n" + +#: main.c:746 +msgid "\t-b\t\t\t--characters-as-bytes\n" +msgstr "\t-b\t\t\t--characters-as-bytes\n" + +#: main.c:747 +msgid "\t-c\t\t\t--traditional\n" +msgstr "\t-c\t\t\t--traditional\n" + +#: main.c:748 +msgid "\t-C\t\t\t--copyright\n" +msgstr "\t-C\t\t\t--copyright\n" + +#: main.c:749 +msgid "\t-d[file]\t\t--dump-variables[=file]\n" +msgstr "\t-d[plik]\t\t--dump-variables[=plik]\n" + +#: main.c:750 +msgid "\t-e 'program-text'\t--source='program-text'\n" +msgstr "\t-e 'tekst-programu'\t--source='tekst-programu'\n" + +#: main.c:751 +msgid "\t-E file\t\t\t--exec=file\n" +msgstr "\t-E plik\t\t\t--exec=plik\n" + +#: main.c:752 +msgid "\t-g\t\t\t--gen-pot\n" +msgstr "\t-g\t\t\t--gen-pot\n" + +#: main.c:753 +msgid "\t-h\t\t\t--help\n" +msgstr "\t-h\t\t\t--help\n" + +#: main.c:754 +msgid "\t-L [fatal]\t\t--lint[=fatal]\n" +msgstr "\t-L [fatal]\t\t--lint[=fatal]\n" + +#: main.c:755 +msgid "\t-n\t\t\t--non-decimal-data\n" +msgstr "\t-n\t\t\t--non-decimal-data\n" + +#: main.c:756 +msgid "\t-N\t\t\t--use-lc-numeric\n" +msgstr "\t-N\t\t\t--use-lc-numeric\n" + +#: main.c:757 +msgid "\t-O\t\t\t--optimize\n" +msgstr "\t-O\t\t\t--optimize\n" + +#: main.c:758 +msgid "\t-p[file]\t\t--profile[=file]\n" +msgstr "\t-p[plik]\t\t--profile[=plik]\n" + +#: main.c:759 +msgid "\t-P\t\t\t--posix\n" +msgstr "\t-P\t\t\t--posix\n" + +#: main.c:760 +msgid "\t-r\t\t\t--re-interval\n" +msgstr "\t-r\t\t\t--re-interval\n" + +#: main.c:762 +msgid "\t-R file\t\t\t--command=file\n" +msgstr "\t-R plik\t\t\t--command=plik\n" + +#: main.c:763 +msgid "\t-S\t\t\t--sandbox\n" +msgstr "\t-S\t\t\t--sandbox\n" + +#: main.c:764 +msgid "\t-t\t\t\t--lint-old\n" +msgstr "\t-t\t\t\t--lint-old\n" + +#: main.c:765 +msgid "\t-V\t\t\t--version\n" +msgstr "\t-V\t\t\t--version\n" + +#: main.c:767 +msgid "\t-W nostalgia\t\t--nostalgia\n" +msgstr "\t-W nostalgia\t\t--nostalgia\n" + +#: main.c:770 +msgid "\t-Y\t\t--parsedebug\n" +msgstr "\t-Y\t\t--parsedebug\n" + +#. TRANSLATORS: --help output 5 (end) +#. TRANSLATORS: the placeholder indicates the bug-reporting address +#. for this application. Please add _another line_ with the +#. address for translation bugs. +#. no-wrap +#: main.c:779 +msgid "" +"\n" +"To report bugs, see node `Bugs' in `gawk.info', which is\n" +"section `Reporting Problems and Bugs' in the printed version.\n" +"\n" +msgstr "" +"\n" +"Aby zgłosić błąd, prosimy zobaczyć węzeł `Bugs' w `gawk.info'\n" +"lub rozdział p.t. `Reporting Problems and Bugs' w wydrukowanej\n" +"dokumentacji.\n" +"\n" + +#: main.c:783 +msgid "" +"gawk is a pattern scanning and processing language.\n" +"By default it reads standard input and writes standard output.\n" +"\n" +msgstr "" +"gawk jest językiem skanowania i przetwarzania wzorców.\n" +"Program domyślnie czyta standardowe wejście i zapisuje standardowe wyjście.\n" +"\n" + +#: main.c:787 +msgid "" +"Examples:\n" +"\tgawk '{ sum += $1 }; END { print sum }' file\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" +msgstr "" +"Przykłady:\n" +"\tgawk '{ suma += $1 }; END { print suma }' plik\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" + +#: main.c:807 +#, c-format +msgid "" +"Copyright (C) 1989, 1991-%d Free Software Foundation.\n" +"\n" +"This program is free software; you can redistribute it and/or modify\n" +"it under the terms of the GNU General Public License as published by\n" +"the Free Software Foundation; either version 3 of the License, or\n" +"(at your option) any later version.\n" +"\n" +msgstr "" +"Copyright (C) 1989, 1991-%d Free Software Foundation.\n" +"\n" +"Ten program jest wolnym oprogramowaniem; możesz go rozprowadzać dalej\n" +"i/lub modyfikować na warunkach Powszechnej Licencji Publicznej GNU,\n" +"wydanej przez Fundację Wolnego Oprogramowania - według wersji 3-ciej\n" +"tej Licencji lub którejś z późniejszych wersji.\n" +"\n" + +#: main.c:815 +msgid "" +"This program is distributed in the hope that it will be useful,\n" +"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +"GNU General Public License for more details.\n" +"\n" +msgstr "" +"Ten program rozpowszechniany jest z nadzieją, iż będzie on\n" +"użyteczny - jednak BEZ JAKIEJKOLWIEK GWARANCJI, nawet domyślnej\n" +"gwarancji PRZYDATNOŚCI HANDLOWEJ albo PRZYDATNOŚCI DO OKREŚLONYCH\n" +"ZASTOSOWAŃ. W celu uzyskania bliższych informacji przeczytaj\n" +"Powszechną Licencję Publiczną GNU.\n" +"\n" + +#: main.c:821 +msgid "" +"You should have received a copy of the GNU General Public License\n" +"along with this program. If not, see http://www.gnu.org/licenses/.\n" +msgstr "" +"Z pewnością wraz z niniejszym programem otrzymałeś też egzemplarz\n" +"Powszechnej Licencji Publicznej GNU (GNU General Public License);\n" +"jeśli zaś nie - odwiedź stronę http://www.gnu.org/licenses/.\n" + +#: main.c:856 +msgid "-Ft does not set FS to tab in POSIX awk" +msgstr "-Ft nie ustawia FS na znak tabulatora w POSIX awk" + +#: main.c:1090 +#, c-format +msgid "unknown value for field spec: %d\n" +msgstr "nieznana wartość dla specyfikacji pola: %d\n" + +#: main.c:1171 +#, c-format +msgid "" +"%s: `%s' argument to `-v' not in `var=value' form\n" +"\n" +msgstr "" +"%s: argument `%s' dla `-v' nie jest zgodny ze składnią `zmienna=wartość'\n" +"\n" + +#: main.c:1197 +#, c-format +msgid "`%s' is not a legal variable name" +msgstr "`%s' nie jest dozwoloną nazwą zmiennej" + +#: main.c:1200 +#, c-format +msgid "`%s' is not a variable name, looking for file `%s=%s'" +msgstr "`%s' nie jest nazwą zmiennej, szukanie pliku `%s=%s'" + +#: main.c:1204 +#, c-format +msgid "cannot use gawk builtin `%s' as variable name" +msgstr "nie można użyć wbudowanej w gawk `%s' jako nazwy zmiennej" + +#: main.c:1209 +#, c-format +msgid "cannot use function `%s' as variable name" +msgstr "nie można użyć funkcji `%s' jako nazwy zmiennej" + +#: main.c:1262 +msgid "floating point exception" +msgstr "wyjątek zmiennopozycyjny" + +#: main.c:1269 +msgid "fatal error: internal error" +msgstr "fatalny błąd: wewnętrzny błąd" + +#: main.c:1284 +msgid "fatal error: internal error: segfault" +msgstr "fatalny błąd: wewnętrzny błąd: błąd segmentacji" + +#: main.c:1296 +msgid "fatal error: internal error: stack overflow" +msgstr "fatalny błąd: wewnętrzny błąd: przepełnienie stosu" + +#: main.c:1346 +#, c-format +msgid "no pre-opened fd %d" +msgstr "brak już otwartego fd %d" + +#: main.c:1353 +#, c-format +msgid "could not pre-open /dev/null for fd %d" +msgstr "nie można otworzyć zawczasu /dev/null dla fd %d" + +#: msg.c:63 +#, c-format +msgid "cmd. line:" +msgstr "linia poleceń:" + +#: msg.c:107 +msgid "error: " +msgstr "błąd: " + +#: node.c:406 +msgid "backslash at end of string" +msgstr "backslash na końcu łańcucha" + +#: node.c:517 +#, c-format +msgid "old awk does not support the `\\%c' escape sequence" +msgstr "stary awk nie wspiera sekwencji ucieczki `\\%c'" + +#: node.c:568 +msgid "POSIX does not allow `\\x' escapes" +msgstr "POSIX nie zezwala na sekwencję ucieczki `\\x'" + +#: node.c:574 +msgid "no hex digits in `\\x' escape sequence" +msgstr "brak liczb szesnastkowych w sekwencji ucieczki `\\x'" + +#: node.c:596 +#, c-format +msgid "" +"hex escape \\x%.*s of %d characters probably not interpreted the way you " +"expect" +msgstr "" +"szesnastkowa sekwencja ucieczki \\x%.*s %d znaków prawdopodobnie nie została " +"zinterpretowana jak tego oczekujesz" + +#: node.c:611 +#, c-format +msgid "escape sequence `\\%c' treated as plain `%c'" +msgstr "sekwencja ucieczki `\\%c' potraktowana jako zwykłe `%c'" + +#: node.c:750 +msgid "" +"Invalid multibyte data detected. There may be a mismatch between your data " +"and your locale." +msgstr "" +"Wykryto nieprawidłowe dane. Możliwe jest niedopasowanie pomiędzy Twoimi " +"danymi a ustawieniami regionalnymi." + +#: posix/gawkmisc.c:176 +#, c-format +msgid "%s %s `%s': could not get fd flags: (fcntl F_GETFD: %s)" +msgstr "%s %s `%s': nie można uzyskać flag fd: (fcntl F_GETFD: %s)" + +#: posix/gawkmisc.c:188 +#, c-format +msgid "%s %s `%s': could not set close-on-exec: (fcntl F_SETFD: %s)" +msgstr "%s %s `%s': nie można ustawić close-on-exec: (fcntl F_SETFD: %s)" + +#: profile.c:83 +#, c-format +msgid "could not open `%s' for writing: %s" +msgstr "nie można otworzyć `%s' do zapisu: %s" + +#: profile.c:85 +msgid "sending profile to standard error" +msgstr "wysyłanie profilu na standardowe wyjście diagnostyczne" + +#: profile.c:203 +#, c-format +msgid "" +"\t# %s block(s)\n" +"\n" +msgstr "" +"\t# %s blok(i)\n" +"\n" + +#: profile.c:208 +#, c-format +msgid "" +"\t# Rule(s)\n" +"\n" +msgstr "" +"\t# Reguła(i)\n" +"\n" + +#: profile.c:279 +#, c-format +msgid "internal error: %s with null vname" +msgstr "wewnętrzny błąd: %s z zerowym vname" + +#: profile.c:952 +#, c-format +msgid "\t# gawk profile, created %s\n" +msgstr "\t# profil programu gawk, utworzony %s\n" + +#: profile.c:1331 +#, c-format +msgid "" +"\n" +"\t# Functions, listed alphabetically\n" +msgstr "" +"\n" +"\t# Funkcje, spis alfabetyczny\n" + +#: profile.c:1370 +#, c-format +msgid "redir2str: unknown redirection type %d" +msgstr "redir2str: nieznany typ przekierowania %d" + +#: re.c:573 +#, c-format +msgid "range of the form `[%c-%c]' is locale dependent" +msgstr "zasięg formy `[%c-%c]' jest zależny od lokalizacji" + +#: re.c:600 +#, c-format +msgid "regexp component `%.*s' should probably be `[%.*s]'" +msgstr "komponent regexp `%.*s' powinien być prawdopodobnie `[%.*s]'" + +#: regcomp.c:131 +msgid "Success" +msgstr "Sukces" + +#: regcomp.c:134 +msgid "No match" +msgstr "Brak dopasowania" + +#: regcomp.c:137 +msgid "Invalid regular expression" +msgstr "Nieprawidłowe wyrażenie regularne" + +#: regcomp.c:140 +msgid "Invalid collation character" +msgstr "Nieprawidłowy znak porównania" + +#: regcomp.c:143 +msgid "Invalid character class name" +msgstr "Nieprawidłowa nazwa klasy znaku" + +#: regcomp.c:146 +msgid "Trailing backslash" +msgstr "Końcowy znak backslash" + +#: regcomp.c:149 +msgid "Invalid back reference" +msgstr "Nieprawidłowe odwołanie wsteczne" + +#: regcomp.c:152 +msgid "Unmatched [ or [^" +msgstr "Niedopasowany znak [ lub [^" + +#: regcomp.c:155 +msgid "Unmatched ( or \\(" +msgstr "Niedopasowany znak ( lub \\(" + +#: regcomp.c:158 +msgid "Unmatched \\{" +msgstr "Niedopasowany znak \\{" + +#: regcomp.c:161 +msgid "Invalid content of \\{\\}" +msgstr "Nieprawidłowa zawartość \\{\\}" + +#: regcomp.c:164 +msgid "Invalid range end" +msgstr "Nieprawidłowy koniec zakresu" + +#: regcomp.c:167 +msgid "Memory exhausted" +msgstr "Pamięć wyczerpana" + +#: regcomp.c:170 +msgid "Invalid preceding regular expression" +msgstr "Nieprawidłowe poprzedzające wyrażenie regularne" + +#: regcomp.c:173 +msgid "Premature end of regular expression" +msgstr "Przedwczesny koniec wyrażenia regularnego" + +#: regcomp.c:176 +msgid "Regular expression too big" +msgstr "Wyrażenie regularne jest zbyt duże" + +#: regcomp.c:179 +msgid "Unmatched ) or \\)" +msgstr "Niedopasowany znak ) lub \\)" + +#: regcomp.c:700 +msgid "No previous regular expression" +msgstr "Brak poprzedniego wyrażenia regularnego" + +#~ msgid "could not find groups: %s" +#~ msgstr "nie można znaleźć grup: %s" + +#~ msgid "assignment is not allowed to result of builtin function" +#~ msgstr "przypisanie do wyniku wbudowanej funkcji nie jest dozwolone" + +#~ msgid "attempt to use array in a scalar context" +#~ msgstr "próba użycia tablicy w kontekście skalaru" + +#~ msgid "statement may have no effect" +#~ msgstr "instrukcja może nie mieć żadnego efektu" + +#~ msgid "out of memory" +#~ msgstr "brak pamięci" + +#~ msgid "attempt to use scalar `%s' as array" +#~ msgstr "próba użycia skalaru `%s' jako tablicy" + +#~ msgid "attempt to use array `%s' in scalar context" +#~ msgstr "próba użycia tablicy `%s' w kontekście skalaru" + +#~ msgid "call of `length' without parentheses is deprecated by POSIX" +#~ msgstr "" +#~ "wywołanie `length' bez podania nawiasów jest niezalecane przez POSIX" + +#~ msgid "division by zero attempted in `/'" +#~ msgstr "próba dzielenia przez zero w `/'" + +#~ msgid "length: untyped parameter argument will be forced to scalar" +#~ msgstr "length: argument bez określonego typu zostanie uznany za skalar" + +#~ msgid "length: untyped argument will be forced to scalar" +#~ msgstr "length: argument bez określonego typu zostanie uznany za skalar" + +#~ msgid "`break' outside a loop is not portable" +#~ msgstr "instrukcja `break' poza pętlą jest nieprzenośna" + +#~ msgid "`continue' outside a loop is not portable" +#~ msgstr "instrukcja `continue' poza pętlą jest nieprzenośna" + +#~ msgid "`next' cannot be called from a BEGIN rule" +#~ msgstr "instrukcja `next' nie może być wywołana z wnętrza reguły BEGIN" + +#~ msgid "`nextfile' cannot be called from a BEGIN rule" +#~ msgstr "instrukcja `nextfile' nie może być wywołana z wnętrza reguły BEGIN" + +#~ msgid "" +#~ "concatenation: side effects in one expression have changed the length of " +#~ "another!" +#~ msgstr "" +#~ "konkatenacja: skutki uboczne w jednym wyrażeniu spowodowały zmianę " +#~ "długości innego wyrażenia!" + +#~ msgid "illegal type (%s) in tree_eval" +#~ msgstr "nieprawidłowy typ (%s) w tree_eval" + +#~ msgid "\t# -- main --\n" +#~ msgstr "\t# -- główne --\n" + +#~ msgid "invalid tree type %s in redirect()" +#~ msgstr "nieprawidłowy typ drzewa %s w funkcji redirect()" + +#~ msgid "/inet/raw client not ready yet, sorry" +#~ msgstr "klient /inet/raw nie jest jeszcze gotowy, przykro mi" + +#~ msgid "only root may use `/inet/raw'." +#~ msgstr "tylko superużytkownik (root) może użyć `/inet/raw'." + +#~ msgid "/inet/raw server not ready yet, sorry" +#~ msgstr "serwer /inet/raw nie jest jeszcze gotowy, przykro mi" + +#~ msgid "file `%s' is a directory" +#~ msgstr "plik `%s' jest katalogiem" + +#~ msgid "use `PROCINFO[\"%s\"]' instead of `%s'" +#~ msgstr "użyj `PROCINFO[\"%s\"]' zamiast `%s'" + +#~ msgid "use `PROCINFO[...]' instead of `/dev/user'" +#~ msgstr "użyj `PROCINFO[...]' zamiast `/dev/user'" + +#~ msgid "\t-m[fr] val\n" +#~ msgstr "\t-m[fr] wartość\n" + +#~ msgid "\t-W compat\t\t--compat\n" +#~ msgstr "\t-W compat\t\t--compat\n" + +#~ msgid "\t-W copyleft\t\t--copyleft\n" +#~ msgstr "\t-W copyleft\t\t--copyleft\n" + +#~ msgid "\t-W usage\t\t--usage\n" +#~ msgstr "\t-W usage\t\t--usage\n" + +#~ msgid "can't convert string to float" +#~ msgstr "nie można zamienić łańcucha do liczby zmiennopozycyjnej" + +#~ msgid "# treated internally as `delete'" +#~ msgstr "# potraktowany wewnętrznie jako `delete'" + +#~ msgid "# this is a dynamically loaded extension function" +#~ msgstr "# to jest dynamicznie ładowana funkcja rozszerzenie" + +#~ msgid "" +#~ "\t# BEGIN block(s)\n" +#~ "\n" +#~ msgstr "" +#~ "\t# blok(i) BEGIN\n" +#~ "\n" + +#~ msgid "unexpected type %s in prec_level" +#~ msgstr "niespodziewany typ %s w prec_level" + +#~ msgid "Unknown node type %s in pp_var" +#~ msgstr "Nieznany typ węzła %s w pp_var" + +#~ msgid "can't open two way socket `%s' for input/output (%s)" +#~ msgstr "" +#~ "nie można otworzyć dwukierunkowego gniazda `%s' jako wejścia/wyjścia (%s)" + +#~ msgid "%s: illegal option -- %c\n" +#~ msgstr "%s: niewłaściwa opcja -- %c\n" + +#~ msgid "function %s called\n" +#~ msgstr "wywołano funkcję %s\n" + +#~ msgid "field %d in FIELDWIDTHS, must be > 0" +#~ msgstr "pole nr %d w FIELDWIDTHS musi być większe od zera" + +#~ msgid "delete: illegal use of variable `%s' as array" +#~ msgstr "delete: nieprawidłowe użycie zmiennej `%s' jako tablicy" + +#~ msgid "" +#~ "\n" +#~ "To report bugs, see node `Bugs' in `gawk.info', which is\n" +#~ msgstr "" +#~ "\n" +#~ "Aby zgłosić błędy, prosimy zobaczyć węzeł `Bugs' w `gawk.info', który " +#~ "jest\n" + +#~ msgid "invalid syntax in name `%s' for variable assignment" +#~ msgstr "błąd składni w nazwie `%s' dla przypisania zmiennej" + +#~ msgid "internal error: Node_var_array with null vname" +#~ msgstr "wewnętrzny błąd: Node_var_array z zerowym vname" + +#~ msgid "or used in other expression context" +#~ msgstr "lub użyty w innym kontekście wyrażenia" + +#~ msgid "`%s' is a function, assignment is not allowed" +#~ msgstr "`%s' jest funkcją, zatem przypisanie nie jest dozwolone" + +#~ msgid "BEGIN blocks must have an action part" +#~ msgstr "Blok BEGIN musi posiadać część dotyczącą akcji" + +#~ msgid "`nextfile' used in BEGIN or END action" +#~ msgstr "`nextfile' użyty w akcji BEGIN lub END" + +#~ msgid "non-redirected `getline' undefined inside BEGIN or END action" +#~ msgstr "" +#~ "komenda `getline' bez przekierowania nie jest zdefiniowana wewnątrz akcji " +#~ "BEGIN lub END" + +#~ msgid "fptr %x not in tokentab\n" +#~ msgstr "brak fptr %x w tokentab\n" + +#~ msgid "gsub third parameter is not a changeable object" +#~ msgstr "trzeci parametr gsub nie jest zmiennym obiektem" + +#~ msgid "Unfinished \\ escape" +#~ msgstr "Niedokończona sekwencja ucieczki \\" + +#~ msgid "unfinished repeat count" +#~ msgstr "niedokończona liczba powtórzeń" + +#~ msgid "malformed repeat count" +#~ msgstr "źle sformatowana liczba powtórzeń" + +#~ msgid "Unbalanced [" +#~ msgstr "[ nie do pary" + +#~ msgid "Unbalanced (" +#~ msgstr "( nie do pary" + +#~ msgid "No regexp syntax bits specified" +#~ msgstr "Nie zostały podane bity składni wyrażenia regularnego" + +#~ msgid "Unbalanced )" +#~ msgstr ") nie do pary" + +#~ msgid "internal error: file `%s', line %d\n" +#~ msgstr "wewnętrzny błąd: plik `%s', linia %d\n" diff --git a/po/quot.sed b/po/quot.sed new file mode 100644 index 0000000..0122c46 --- /dev/null +++ b/po/quot.sed @@ -0,0 +1,6 @@ +s/"\([^"]*\)"/“\1”/g +s/`\([^`']*\)'/‘\1’/g +s/ '\([^`']*\)' / ‘\1’ /g +s/ '\([^`']*\)'$/ ‘\1’/g +s/^'\([^`']*\)' /‘\1’ /g +s/“”/""/g diff --git a/po/remove-potcdate.sin b/po/remove-potcdate.sin new file mode 100644 index 0000000..2436c49 --- /dev/null +++ b/po/remove-potcdate.sin @@ -0,0 +1,19 @@ +# Sed script that remove the POT-Creation-Date line in the header entry +# from a POT file. +# +# The distinction between the first and the following occurrences of the +# pattern is achieved by looking at the hold space. +/^"POT-Creation-Date: .*"$/{ +x +# Test if the hold space is empty. +s/P/P/ +ta +# Yes it was empty. First occurrence. Remove the line. +g +d +bb +:a +# The hold space was nonempty. Following occurrences. Do nothing. +x +:b +} diff --git a/po/stamp-po b/po/stamp-po new file mode 100644 index 0000000..9788f70 --- /dev/null +++ b/po/stamp-po @@ -0,0 +1 @@ +timestamp diff --git a/po/sv.gmo b/po/sv.gmo new file mode 100644 index 0000000000000000000000000000000000000000..d9a408eb2ba232e9600dbdebc903c2fd3e13a622 GIT binary patch literal 48974 zcmeIbd7NBVb?bgDUrD9#6g? ziuB6UL6v(ksP|k8J_Ss`^T6A{Rp7m#-uEY<%K2xIsz*NuPX|vPa`_9O@?Q zn*ddhJ3*=ty%U@VzX+=QjVq$)Qm_hM3BDIBfZqX&;BTyqqNjrE!4Yr=coFzAQ15#P zJPrIRsP}%?<4-}g^P~%1`g!1L?l1N@22zFSwV>Yf2`~nafxJ3;43(pZXc(la(T$+e zUj(Wi_k(KBQScmafWn0rf-3JiP~{&1&jQ~Gs-Hg#k|p{UxB^}{3F4c$U%STj`)fe8 z_hX>wzYMA!-vc%Nj~tGogWwt9`QRL=cE1f&KYtk1IDH9xI`~cSWbntJ#^V>D$~j}L z8^877x!msr)$cV>J9={4cmgj#DZUTSkaSeleC-<}9W#Dn}VsQAGu3r*R{dqemKDY-|JO2z+{r?eE zdj`m)e5?6i432?n|4Tu&@7f^z{^$MDv!?rRj(I=D)&C{>ENG%uuAlg zpz8mW%N<`_1ghM<;HltYpZ+RP?SDT=mquR($r}9%HKa;O!tR5WU5x{|PAi}4OIV4 zgX)jBfaic;0nY+|0II&HY;^R4pz>em?`xpi@di-i{smC={3&<__>4`iKQ9H7ckNW$Qx4H3O1!_ER0M%bF0wpIN0M*}r11kS{m|=l6mq zfu94#S6>EW@TZ`jKlNJIPnUbFgF~d>2a2!13a$Vjv%~SxFv!%4M!^_-3#fkmBT(%; z>ha0fIexeX93=f_Q15>kcoO&kcp>-@sP=sq6rVo%Sq`^&Y=d-Z^gdAK`~Xyap0pDk z366k!!P`KU^A!-*jeY@Y{6=;;tb?L|ug9aH+IRkL$9Fe@;;*|vx-@z}_;m0`AYB!m zw8zzZ4|oChH-Lz&=nn7(@Ii1Gd>ob0eBS_yPY;7k!RYm%>hTLW8gEv(|^nH!){P~`9e_be?O@Fe*vmK zKLv~6sv8~MjUHbN>izeFdjHqKCxib6J`H@_bDdlo1ogffK$ZV$a4q;Ccp3OTP~(2i zL0A4Za2@wGa6R}=P~-P?Q1yD^Ay>}Dpx%EoDEe1`mx7-J)t(=Ndfyp0x%`_wz6ex5 zeFjwiUwXXYW_Q0A)cD;7ZUpZERo=J2r+|;T#r5aYL8eS}E%iIpO#^v+i<>1det}8h{od(qp?*>)hzxMbmQ0-nh=F$&>;?Fxl zjoSm@72x;4O<-Z%@lhER|Go~?ID7^?7yJ>ZdOfl1`1Ufe!2R{0=#PM>gZF{wf&Ude zAN($;dY_y)yav>JZwFPMhd}kqcR}&Nz=XTM+T#SM^6myz-bcYFfZqVcN8bal2LA)R z0K96_@pS^KUT*~TzR!Vr{_h|nFFJq9$@99$yFr!nAyDJ-15oujv*O;n7gT-Qpvrxx zPyZ^Y{{Jy}HaK{zr@t>aJd+pvq~0r-H8rPXpfps@)HQ&j9}l)VTaBsP>#P>-hgn@C@!R1fK|Q z_4pj{OztN^mHSdq<-8fxeEK-3c7F*}{eIw|pY}Xg&U#Sw+zhII&jwZAG^qS{flmV8 z4yv3#0QLMYLGjbSfPV^}+Hn2w_u!S>pWJl(uoXOq`#V9+oBKeu_gmmD@aN!F;I%DR z?pSCfDe28EC2i`_!QEkwj0OOJZ=LANj?m&1Ah;U!9NEzKL6W4KYh;64^Zh7 z;12M$;41K&;M2iJA9i>)coFxPf*Nh61>;nzwHI? zeV_99HIM%cN=`?2IKBP^a5J|zfG-5!25P>X$;~z30Z{b63!VkO54;q77*s#~5>$Oo zdy(sxD?#NS16A+0fid_AP~-kL;0X91{{He8yK-*<&n5i@;2GdMz!>}_sQK_MQ15;8 zOPsvf0IJ`nLGjURK#l(&gXe%h0oA`xd8vEv)u8%60af1Z9^VI^$NgV`qW=kaI(W{@ z+&Ekgp3VIfsP^9l#^8OR`2LHa@_)mp{~Xl#oq4Bg=XId?^-fUbe-u0be%s@^m%H?r zgR0j@LGjtQJg&RT<-ZG5{*QyA`#Z1*p8N_Yr!N6jk8yA%-L9OQ!3(*+8`S$B0yXac0~9}<@)}p} z7H}2!Q{WKzM(}*_(_j(&4tN3hgx9+IU*hprQ1!eQ+y#CER5|Cr&b5Cp_*m}m1TO}E z2ULH32^8J0K;>WcdRP89sQ11KRKI-$TmgO^RK0!)#^CwC7 z^Wh&r_1`bR0(jON-2FyS<&J?W_qRcf*T+Hi*FS-phfjW^d*3jq`MDPq{VPG`|ERzJ zTkz4`Kk`kk9w&oqxW5ckdnUmvz*mFTeo*E83fwBXH#_<}z$>}`Fetk3gPND;{;sRn zCQ##1^>`1cdVa~@9|cvvQ{UqHeFR*|{dQ30Jr7hreZb@2cs%*7PM%!`uIKsf;9Bq_ z;7;%#z#GBhJ+6Ltfl7ZER6C#aHdp>eQ0+PF@iX9M+&}8=uKrhogWOMod%(NFCxZXe z-~R|aiTkU5&$V+KxRLu7n1Bz0&jioB*VSV$sByg;yas&0T)mHg;-{~H zSAoaDtHF!k>E=V*A1J!7fR}^+23`nW^!u(|H-k5D{|b-)0Pf=c zvJbm_F9%n1|A(O3{T)!{KJgD+|6c;CyxYLj!27^8;HSWy;P=5NfR}#6)oVMb@~WWn zy%j8i4})s|kHHn-84tMUo53yI*T8GQk9$1s@$!$lalIW}%k$5G!{CoV_5ax)bNqdS z$2WuPNdIea19;NMT|2gds`o2F)#oAbV(@!l0er?Ey82xW>V6VbKfempczgs@`@avK z2SyJ%`t!j9-0t-FF7P_;kAv!mP5;HUvj%E>-U_Y+zYbmi{yTUsc>X8c{WkD7xt{^g z0Ovuq&UIPz;9|8}7Cw&=lxg82KD!f@Wb6kkLG?e*Gb&JlIt=4`CN|f38epbu1j)hSM&R8q-k9L zCzt-JT<;y5ee7Qf%e6_frd@R3~KVJ0d3HH?4+v}8-@o(!|LuSO41Bu(U4Z5ozr`2d z;Q9lfo`+dz^!I;rJ&EgaTqC5tn+ukSzRvZ(xWeCy!w>L3{O|Lj-Oi3)OXn&Tzz-wcj|zXM*+ z^)jxfa;+h49DFl)2FP@`zo&CQ!LP@G@8Htk29FnlKjL2VQGdVSdK+n1fRbsKaA^+S z$`$@r@%%2Xqa<7fet=7VZE%D8Y5#wX|1BAHFW3EC=Rq^h^)LR}d-*-jHOKvpK27jk zt}(9XaY=_Dip@vTgjRnyd%Tn1@ASW42ELX18Ln@0o#WG=3cjA}3a&Egd%!>7dLqA3 z3DF(={t%aBhUELJxTd+zNWE4a3De+#I;{rtXw>kyaze!%q%uJyX% zZ<_R3@ab>^>+$@43D;Nn{dVvoa0=Al4dCx{J>TE|uE#4qiblF=W$yj~ zCGz)8u2V_B*zVl_ZuNBc__W{Q{sml#Pp^}Hkl+6XZu2z13qH#K7M#KJ8^GuLwBG_B z;q$)>{3!S9xW3QzTCV?#>p5I+;L_h8dD_SD`_Wu0xPOyR`+e?r@%uXPb6onnfUE4E z>;4V=J_K&m4S$z$ZRdJ`^n1DfT#5YM$?qp|-OhC~_gg^y{TJ|E;7h?TSqeTb|LlD3 zKjweG82l>tCxLGSf5WGr=kuJ-{YSXg`t(oubiu>9-xYpOaUJH`$@M?Dy8oU)8JBat z#6Nf)zn{x>CHIp)?XSUeNxPOyf0ucD3OLIBx0LAr9`yJeo(*#S1^4T~)4_+p=W*%p z|2T;L#AA*0KjZg4@Ezb0u0Q4aTdu$18YBHiu2=K>bzCpvdOTPDZyz^L;~IkQU%^L# ze+AwL4uM;_9?Nh2T?*a~eiUqg|BdTxF8O_H;5A?i{70@Lzqf$-zmmT>z_Z`u_j|a$ z!1YL_llDojzvJiG;FH1AxL&|D!~F+9{hh+^4}*KTKFII8z}?`b;CHy*&+lh(ZR84n z@8`!$xpwB#R&hVT{Xc;Dzd>&P*(bb+=Vx)f&ENkazhB7pO0MvCH^29Aa}&6O>x=we z%hlxid#>n|^Wwo~JXWobPp@dM92ii-zIHW9ZzfBJr{md1eWFrLR>$Lwq|{2vMs^wxcnJqO+t$Jg_gq5^2 zJ~&Zom8v(Xz-pz|I=I2zEAMX0*ls4p>Ugo%o=F;&ai#CE^!jY8GE=$D-m=$HX6wz$ z5fSXmDl=Z6nJLxEX?^w^Ws{__y3szz66TUdvr?}q^9^yW-lR&Cm69rz-sstlN}&bK zq@0YkCzUj2`NyYd)_99jilt_8Y`&FP^TzFAt5GUfS`=TZDo6RCI>%aEZqLjX=Sq!A zX{?$wX}cbXCW(jW`^iRWrr1i3w1#+Xv)*ouCmTA`MLVHknsnV?EDAS-1U;U#I!q?D z;%wc9YRVF(lIpA;*X*uVuNBM5cx9$kEtVM&J(G>d6!G>jPBt^z7Y0SBnwJcG? zSgcpeDq}9DbsKoBjw>~rmB|`+mNF0xz;oN$wQ+S#yt!1Z#`{~P@#zt`G5@H!I<8il z;=WRKcB(X%v?}8e&qH;f9ygNNdZQIH8qhV9gwZP}@#r<&55<*QJSs+BQ>jhVhgQdj zrz+!9aiuxXOx#;X_gVHzZ8F~5s51yN%^2Q@)9kIOgzi-%%duyYHPmmgOeqvk%PQ2X z8N;4qNh7XL#HGe0tXgX|nTRXn`q-^>mQmN^!eFxyPn6)Xa=gM-lFF7x z;+DikBbiKȣBh1uSSM~By}Su;F1J`|VhNwYT8iVxQt(;5_w2_=qLucSQ|x9ag| zac;=!prP}e(oTldmow^j@{}5l()=xrWJ2^3NJ_LWSx~cNX0|mSuc)=F)s>FUr`(n_ z>OLh5qT~r(Q!K_qRM}C}A8F^f6i)>SWvo{C%Yy`!G6U27!c^~o9%xV$=MUe_B5Q(j}? zi|kdDx_1yEz6`Q#6q+q2;3Pr-7A;jZ+o~manu(_Q)@+Y8Ta{M3mB8iV-#D3=a2zYP zgoSTuQptD&e7f2*PnzIrl5b0>y&K_0p4*@fL_^JaWYY{B8YG#`ATb1U1TOZvM$;mR zirZSoG{)kZ%G>sfi>ana_wL!h?6FJD(gzHMtDO!wC(T8B%GB;HnU*H8?+0P%NVN)yBBClx*+(xxZ9BA&0e<8k;F zhCpsNDq|X(3IkRv4*5z&5pUhSC4RnB6!zc+@B>29Qx~_5#N;qN zVi|_w;iNS_Jc~v=%%s_|ckU8Y!^}*(hH5i0M6ZgEn(bMsx1=2H@VaIU4N1>VB#opt zo}|gC0fHo?)VPL3&mPvRv`Eq|CCfcSx7AwennTY&^nx^frd@4SWXQy_2jVjN0sE%B zCO$xyCh<&ZJ|1H{;+aZwrqn{KqL&XRNzHYp<&h$_uEokMRg*Po*|Ufac!N2O#%Nbd z4cM17%mes0G_)ZN6eqQ;={<;dB{TKLJlUs8s5!c6_cn}xmgZC~nWW9AJ(~#8?mBg* zp8CPN<|;_QUa#LX3*T8^?WX_tr~U8drWBbCjFb49T~Y5RhmH)zNprk3n>2e<)a^yg zhtUf!>{CddWJ92FeA*m2-EiHuA+T)~cnGg&rFw5zKJ5I*q@I}TjC z=lTQjrrkHjH*DIsZ`1ArH(mi{YpTxEWDc%XITfaO1-XL2gZVHV>JtOIw(i?}E%ckN z*|BrSfg6z+@wOcYc5mIkKi;-yU%V;ayJ_En9hPF4HS%VNW$>RUT;YOVdJ=yvaPCimtC2*HWt$diS9fxs;WbvND%)P$>s*&ZQiB zessOlAeegx9jij4iZxsFGVe_6HE)V@>xlSZv3QdSuow$&V7Vn&uEBAy7zW34CESQg zXwuslzh;U`05CT(o#B94_4E>wf1qTXt}%l$Q$K6s9TVahXZugJTC*d=!-o$aUNc#1 zuc50*vnOGg<}8aIGgi}?ZS@%lM z(tF|_O)QgC8qm?fL7BTUR!gnuW<44=b5g_daVBocG39NLRLqx~YB3o(tPIV>8D%A{1^ZB3N6|JaWh5(UW0hK|F;D*9 zk8^A39L+G)`6r!4b}w#~(X1(6?Tr3PqmfjTIVQboXseS^Z%3K+w7|$3-L_-v&Mi0W z*mB_7{rxERZaUEC(T?rA_w3ucdDH%_eF%11`b<))(YKf#vftEcp0k=)1cN&o9mAfR zHgX$5Z+F6(O?p%#TCdMaDm0loXunZ$cBQ5zl{Ya=lQ9!JvqYn1dIarntF1oObR;W` zWTmH3XUk-4@Hbfm_|D5+N$d2c|{6^O`v0N^4#g`BA9~cbDfGTU+mxS!BowmP(qT2yPy**5!r6iZmg{`lp%N1FZ(@Gx;#Pvvk^tKEtF8N7gPT*|AJ9hMUSbg4Fez zON{QFlGLZ+7Nq9+S%eV3Qypt8v^FX=nJRcMoKUCp=yw*h)_SRyv|tmkS?(n>W~5#; z`wE7PX~9pGFtcCz)_2q0D83%6GWtA{8B|2#%Eflk;QKm4ba~0^IK3EuBb78Y^lf>?lxl&1C zLQOSEML=g|{L7b5mQ`cvQd3`_Yi&M5YLUlSjebGpdo_C`4Q#HdbeSEq=9Y?z#!6)s zx@{LWfj2t+N?%Qh#@hI-@Ihb+O~{o4@9*kB^Z49N07pe>!PbFBm zL7@ljOQxDlYz>ROGjG~i56Wt*!1xF?ywSmdrI#r)3prL+c#A8nuX6OWn7!uw?Ms6# z(Tk{CdfWV#gqH=`U1IBSot4;pueT2`EMKK~?GVh+p?s0@MY&dL8d+m4x8&<*t|$L4QJPg_iy8W( z54AQljK5{I<@OiWM9#4yv|lgPirwp5_SW%2$OZ{Ttbzar00zJ zHfc~GG9IvT)to)tz+Oq^=Hf(}|Gf%Y?L?Z&%ss|gSG0Exmy@|+ZJs$pOcO9N&u%6? z7zW!?i^}6Hv$SmUn|eGj)|GL=7O8UqW9YV$NyaO3OUDsuAGQorW@Sz|+t;d8uFO^B z6UNgYYsU`VYo-&!-2aj06@HkZrAct9E>X;|NZNP>ZERQ)Pn1{*u<7Q#;d+-_SjS`a zGObE!$4dw_v#V_Fo+GlcNJ@Cj8>~+A+q3L7(!K_h9SKiIOwJpfZ6?%-hTMVJ{Uw9U3tXhe?;_~Xr~nAyam8X_u{zB4Ti_Va+wB>qBnJsV6ySgdEdKifP`4`^b(k z^?oMxI%!g52`Zh0N!J687IwFik+A2dwgJ0HGZn;!d46&(!aS)2aYpBa0{4}=WkQ+A zTOEqt*}G`BbZs zhZ96)Gqfu!#92c0V6axMiq{6J9HZy0<&;YXdJtACV+~x^Hpfzjh%MMs);)pz={|&? z>Z7yO_GG1YOQm_s_PslAk?FzqB&QnO@+Pg2HAWME)Vhl1!RuNzy5VKBq9N}=5*olc z32{-{VKOP?kN4g)=Y2R_DYM_ACrCw8#aVVOgX`_dsnjmxI8mL`4y{Ua0t4KbDmWe{ z%+~9&43;u#Lnc2EzKB$pc+1?xuva&$&E)WUBkG+$Tg*Dkev$mqT8<%w0zo{a3j~EF1k=Gr5Bi{KaWldM>lR6(4XF4as zrNFQtOK0myDxQodw(k*X(6vF}4^_F+5!CFwvzpea8S^@6+A+3*a@(E7(XN6{pS8s= zk)vX+1s8%@oXT+O)8q9pX zoUHB2DUsQ;OLA7qc{*Iz)5V5155Bn0a+k>MJ!r}vd~6*ZkT)XI2d+zVr{UbzVESC+ zozK|Y-DFix^Q7Lk?&=54ANU}q6S`^A%zC)m7?;Bb!TiowbkWSlr_HHSxqi4APgd(= zOq{?Y*(*H*1Wy@uPHU=Rvd{9TBAe~4CWw!3gu}A>DpY3uY+CVI^i!T0OiKcw)45W2?okRkicNc5MnQM%m^55NQtw zsIxB@?1ItIuJ?yMpio`P%Nv7Q@;K*t#g?V-C2`$5kGpmdn zjYV8Qu7rH!b1m!Kpz`hOL)*=bGw6_8ytkBT5Du}0&hmz^6n83Tj9cuO(1Mw50;X$Q zxi6*pYl2Rgndb8f4xX~zQB8E*7TZxmK(jmeHPRC>N<@>HWU@WeC}i(gO?UIxOnuI* z674U@cI@ptMXGBOt&A3u_jIFn(`O#r<-eml&k`@vS;dNa}IQT80@tK%Y^;`0S+tAo<+usS1hAy;sL>F`nT)92i{;y#r($Ek~QZ|cluUz{$p%@?O@^3{?* zPuTHhX{~Z)vck6)5>nX_%+x=m`eDbLdlOYRzne6i|cWAY5`FS#2sD0@;k_vC3YPG$k+<|9o@F|jXF@TC70#%*^-t{lAft#<-Zwk0&xX))UI?ZwU_g9kh(hCU zPCXc!Kj=r;1CI0U%oA={g0gXYZy}#Pdslq$8*k-8Ks}dQuW#A9eA|ssvt_?T$Z9##! z@0pu|N-pAi2q$54mUc682cEo|mysTi9vmDm4vy;>2jAV;L4H&{yOCwi9Ym}_#`P(N z`v``8I((5fT+9{cYGo4)Mb|L*1G>mW6_V$OZDvxEGhOQq-i?`o&&n?mxWz2j;fIls zgaUMyx^2_WV>GZX%%|Dh?c)v34$@EyzO$&|>0)P!ub0H1Zv4%VT7-}jk#=YZy7X8H z74Y9;$b{)E*g1km&mSxgEsLzWI9*tny5)hBo!Y&b#WcgM@|lYd**oCyVRI!@6&YL+LpJ%oS$1t|&$>f8GF9B!4Eug^pp(*DnEgn9ttC=p zL9XTNi-mblbcy6jSf18dl(tLwMx5j{KMC5JeaJSu%Z)m&wDglC=EQhIgCTMq)~lPBDFP+>6d!MYm|_)m*WX?QHXKwhr@=!MPFJRef3;Buu1} zl{RJZLrU0ntl`1|uHX|~a9oPH=r-H)PcrWldJcV2OAgzKv%EEL-Z~Q-dI#IVIwZj! zcJ%9O@TGEQgVwFS7v@~P?)G_mDDDNGn*O96>s(LPZG@+4TpiZ0?5vHw?T6;`+~Hnh z67z4T^Dl6OTqKUHW2L;nsnkR>_d9(Y%8I%?e!Azpgmgpam$4|-3Aeg;a?BgwFwfq7 zdp7Uby=~9ILZB(!)Uh+&LhVv+$e&i)A3W&T_31(8%pkYP-PL=&N)=M1c3hCVVH3AeMmN-6eSpRcd1lWo}K{VGyt-8(~bT6wGycfqJ5lHag zcqOQJ>8=_w6KnJ;ez23qUL-h4oa-p-16wp`<6TWS6raZzlUUSv@?>V~Q!8gD`YA2@ zQJ+RdK1X_NZpAGHau%>7or305sBznB!0VYXVcj8V`(nO1&Ud3(0c_UV!Mk6#1PKPe zJD^PueRsnbu(Gf?aB`&6->{tTYr3+eDsM>_1sS_0aZrPuLRFROL)fJZ_z1eL=q1G+ z<>GT(h@TO69{HJT)~;DQHQ>U(6n8ZzE9Ihsz7!ACwSQW}m9w!qop1zr4aU;I-aQA3 zn^~aBxvhxjn_eU z>8iEspxcQUEAqW>4No)6g^_ssac<)4%LEqUv(@;@$vV!a+Qzm|Skp|dB9q$*EFMTo zGb8bSPCXF`A-=LTTWrp4l*w9etg)L8a#rAT1G{$Y+M4yjx;1MDHtRDxLiHSACbMyX z=X2Pc4_DYOAC~n7Ow{6KmtA~$aa~5NDzo4%ZpDa{Q9Tl0HdawwAqA8wTFe)$PRMNF8mIi80n0NlIyH zz$iAY@NJZ8jrwfU$!l282a~dANy9~xD(U0c>V!p;YEHwy1KW;s>bAwUddYco8+<99 zh*Nc>17}xUkbEe_mAD{AULz+!VfDaVrK-J%qhy|I;#6vJQ&=RblnPL3e4snssIVP8 zz}~jRMM7kiec8L4^X%u>rghS7_E>yeL`PdKNo6v(6y%`KwD;kus1Rx)<}eU@1Cu%! zpp$aJ2#F_X?O=#arKnCL@wAi+rmeP^j?NJCV`8kRFOWE|or^KGAVAfE%&I3RQ(8xB zlSMX#EJ#%r;Ho1=m6I3o%rQRPV3~pHj*qn_8PO)^!y^R=;v{eRRylQ@i_Z15)lscG zS}SXD(By+jnmTrCGVKCYse4o}MJH)i=f|fRZk+(Ns9Lf?D3~!UhEP>HN~#_)r_-%R z8Txjs)gWJ7@G-22dex@uIq2tlsN%j7R~0v9b+dQc;1r5;1u=zHl>u~So_GTba>JaM zw%~#b%~5G$XE-k+D;L#0M78RuzL?W`wUo7_#m7wf@K)}ga4$Z%l^=c!Gd5X@i$%I+ z+`m{HVxhqBn!{$UHa6fWBFNN#s?9O+ptYlRY!W|97>lk9iidPU8ALwaI0|PQr}isW zaj8zITnkWTo!^?nOl3o`yQZ$lWxu;V4WES=SH$w`EUrf}>gN#UDs*TcvTQiU@WHl9 zbJdC*hYcnVpR>(y2#>_H%N=)QqJTN0p^->X&@1D9vGy2&C1ea#lW8CK%5hmf&9%bX z7TCiLdanmIxSTbWL^4?w7u>2VV{*?beEeh~ud2tG!bc}v$SaA2z(k68B_6k!SMHQ> zk-137D<^HRFA!F9bh$G@3t8l=LKgYTF|P!1vE4d8Ez%JAs%W#z&40*(1jL=4aI&$? z2b$Ki`RG^oFF*Fx7UWJzo<#*`)C`|!RKhJ&yR;_W(vGK@K_O5LG6R8+cp9G?W>}bL zsnoG_7X%A6Qk}-ESNClvILr2)@vr#!%i>{CW_h4A*EjSPan7{#5MOxhLhvhldAtIq zDie(5SgcpB9MGI*>!0sMkb$09DrD;sTsleh!~$NOK)kEsw2OB&?UqN))^S#4k}}aA zr?LowGkpy4FUeSIhE$xg37h}5X@;@MDTrG3U^+y(;$%BI!O>-pD=a#vj=^{p7w9Uy zCJl6DUpBF}ZXF$;ZV|+13#&~R{EDGtIN5!uPoqPT!R(K)Eexl!V`7p~`k7j;$zF## zNhXi6)>NPtwldHvd^qW}N=8+mnK(vWo7HwJOI%35OO;3Zi)=R$uA~ZV5=jaA1y(CI zzK?e0R35>!SR6{VEm9ZTK5>&eHwy0fey9AGdh@}ox*i-lQeZ$WW=^%4OcPP5nKXKm zhTR%e%!L>BF0F%PgQrPN5g&?*Zo@)J%@d?#2z<2-MXuuz7(MDRnNJIQbYJ(FnEsc1 zY(>w~8a*w$_xpm-DK*fv2j=N|3`^9FV}~i?$(b#{GDo7WUY#yAqn+Lm@v*P^&wx%D zlM^J&5JkHppbG&&7<$PSULmg(O2UMuOrg~SIDO;m4{X{U@BYH}J-g%mdv?XwZr!>6 zK)ijEqF?P;9iw+;gd(U+0Kp>7*0D05S5OqPV}Lj8e|YD0*KFE%?bZWccIBy@7SX(o8| z&04d1bd~|dsWO8mppkroi&kXnM|(J<%gmDqBqo**i~|IvWlLZrr?AoM3?8be5kB6QkDypb%Nz|#maJJpgzXnV65SZV+=8)G+m#q zFuZe%CKF|zdaT<;)RwvohEHnuO7$t(^D zaK@!$wvn<5NI7L?XW)-O}KmnQi5#*v{<*0_C&p+udR<6N(SZHOn$XN`dL@yo8@Z_Us zxn)to2hTF=khXR8bMDx4KZ?DZ4)l4H1<&e3u+!3!fU*Lr$0ajmCOW>$nekDmQR7h&Eo-k%eTM^ZMxN_#w@~3BG~slE#>i_dxkf34U3PHC2e99={&%R z-NNkwcXA#QuU=FLq>TPzR2(ubpqCV!1T|Gg;1f`*FlD7LXMn29r_6`b>eD_2urJ7iUCBL% z%?AowQ0&41HcBF3{eRH@6Df5;P1UJgEp;70sa@&)djQ%61uyIZ337&53c!uJ=J2gY zXLwD*@+6arkq_~;TqZ;>tnbURofV7JrsLCQrkkY{AA_rp^63^#uH_?NQ|4*($Tx>;{wt;F=aOW@zZrSHf8WK3Hk!lIIIh|BnQD5OoC`&^u(w25lo`NfIbt;L8t^_Z1jJ<660LZDaKt+``! zM<<&L>Qfx<_Zmtob!p44lIekpHVGI=H;1jAoo~<6*gWn*W?<$Llv_G2ZuJL zy571NHD0UE*DprQva6Fg$bm33Z2=U9Pm>_u)qKqw3rt5(vi0U(*=`;~QIRwcoVG|FA6?7^kW8f$V@QShKMb;3a>O$o?h(gaAq-l+ zxnbZ#Q=K_14~dLt`N{LPBQ0=WOz@FYC~W}+_6DVPuAO|17tp$$O*jrt(pt!^BMXX` zP>6y91wAmrjc>(l-5V}*URGv8Vqx#*ir_R=x<_i<=<120Aapv%G~_pAg(xi%+4)~t z`75zzmN4-1v?pTSTfY9rQn1!7Oj;lNE3_!eZB64Qs%zyzcr?>FG>>CpwIomD5YLSSvdYdA@ETWEE@T>ScHb9jV<9Kh7#FOxe899YTw$r^ zH$ZH=f$>wsvYxG}ky9E?LC_uj1Et&OnKr0Yth2oN2X3cj@1q!pGMC5ryER zD=bNYOMdY}hDE_n7fkQJ3dZK}8!Na1u#PwkJw8=rAEO!ZfPceF%TdKlbDMXziI~yY za4?BD2w?t)+<^h4^2~7-mN0{xTTIQ|5du0o+pu<9CWTz!G%QmKoTlk+qzsePf_Kbq z41v>RRr@VJ`$80boSS*rb~Bagt;bWv5*NAxrm;$A1M=Xck-F(*-?0%#d^~Td zV5VV6buf&zKG0>nY+@l5sHs)36k*Wu&~d!4d(Q^;A%I#T-74kFE}D)4mnIx9M4S=L z!iyj+orl+PU=2!Dit_@9M|QBAj(n-f?Kj0J4X(18Rm@9p^EgwY#vr#b?$$$DUhkh; zkkjg(`4wEY)DzZYnVdR{&4|lwcx%e%GX5tlhg>Paq@aO83OKJ!T8(o4rGdP|5JRA( z)U5B!sbd>pIPCM8Q%{}S8nqE+GWIGnpRHM%W^=fcEDD}T9`Jf&05|rS_{?tO;5Nx(mWuA4IM%H$-n0is8>-$h2$9iF>kLVz>i$fqbyNMQgW>MJmVT9W%ChHQ^ zI{Mq3g}HNdOrPu(BXQyUa7rZ=$(h@EaZ0xh01McOFAa%(N0GETv*FlweVo1^jj`sv z+nx0ISx<-_Z|jNB2kmSp%Ond34+SsakK{BHN3*c4Fg9@iig-Hxg@LF%8SyAqtsV^hMRtqvKSS}2NUenJ&582XwZ({A1 zWF-0>u!3Kc*gL&WWXnbtPOACRz;4~8$iJ4omJVH}#@ad}xX&TSSdiyj5#Qu952s6l zMUS1Uc{Ld^cy1qSq{B+Is%12&)C;Uvq_a?oN|#N1&3Rdi8N(qv<}92$N0kyz`fvzHmSX?c z5oC@t0UVaq9s&h2VfYXdLyk_;=oVIRQrEG(n_$kjXu;qxz}%DI2JKY&nQHB5SE#)6 zc`c|~)@abRL?m4E1`4vj)?PxSljD0riT#RYy3rkML z7hP>8%mM})$$f{eAaa_X9E?GQY1_23_Vn|@SEO(E#+#keo^G=*?py@HR49%SV2ntKme8DS9GhM< zuv-cRrbJXS4dwf_8J;dK@bD#B}JN> zCJwESGACKUc=?I!&P{3laAcCrWAd0PKqsn_a%Ji)BhPh6h)%~8jDk>RXPR@nG{v-K zhuhqr4WzrrF#??KOxcAc5n>L@kToI0lN>=kb#6xT>M%vAk>73cqzgPiJtvk;B-lcsg>Xe3>Die5+fAX1Lv@cm*w7Jyo_vbG7H_QAP*-DIuc?!1z^4j?@ zqm;OFkq~r?e@v&*Ga=FKE9C0wq)+J5Xuv`hPO=rB5$UNf@kZ~#kb8v z=(#>^>tfb4`dlCKPKJ$ohM&t^C}yXdLdyv=Ni8zs(dqNO1|!?)E?tb+*nu2g9fv@2 z$6C1gFjV-iQnC$pbzN1`v5#vp%Y~+p+W&^`@`V(VLoR)NnG*{d6_%KU4L(P z8h37q68ihT7nWcR4G#HVzaoniv#i=k9?GcF$gVxc$)!ex zJwbX?T?x}<-_S&E#iLf~Tz*N1vsvdbxDy&WO};4~6OPjt1cyTr6{L z;d3I{ax0w^$%ecpaoMN{q{;*v6|7}(3idqT?OKMwvE>$4y!{Iy zE;a8iWg<4ujU)Fbyz(*p{WoiU5Cw1C?7$x!cna*hhbq`ABIhj zSITvve~{cHkk~j4sb@Ul1X9w7`e(pPYT>#H;p}jM`q-f|O6!xabW%>)ZlCSwcI;#3V%#me+|HUIB~+}WYVKvrDc3EY++?vbT)|pE^e?UJ32)EY z&E68o`f5Q{7bE6WRo54!6UY15pK~8b^0?h8 z9pBf#9&HO2d&f}E@O*yjsjv4aMCe1H=G>>LZ6nv97B|v6K1iQwWV4>f_~(-J@ljOc zqYgYg^Qh#RvBb7zbY_7}vOJyRR9Xn`rrx)*h)P5BnHt2w&UebQ=wc+8`&zJ6Bdos) ziRju8qt87`#XC>=_r+(mY|f{p!z%4#8%1541?hn{5!jhf#4(}zv>Z!$-t;Ulx4?V; zlUe>{gFqI-^r4N@lU`larc<&Ub}p|#oW8>H=&FkohA=U>mdt!$uh7NlGZR7oDki)W zgtcEpVg92gH7My?*I0+4RqQ@hOtJg)m6fbqE!hf+-iKU7Wnsm6*T`o3tca}*jU+^2 zY9I%C7O}8^RjU>$BD_AWe(H8Keo8$eTE%1PnK@^H{p6rDp{!bTehw!_W&v-TxO~=N zr>E4sJ2EwTF2939=}`b*MIGmDuqBd1UQuT>`ZJ)*%aEN94QpUH&p8kHI8F|G7w1pY z#*9t1#{437C(|>6qqS2d7l@>$4*&711f4A#$a<86sSSV9gIeaD!2^qAH!FRq>!>-a;Z9~N@LCDmEQ=aBv=)OII#g)2%y_o zkNHy(w!EQ)I{z}d?ceGn%Me3QQ*U|a?K^D>Z)tQ5oe#^m>_R)U`!c(%iY04$0;Wrd zF1VmAbPrwF>F!vJ*gBpZ-pKK!U2B&v8%E>Y?Z3NTlOIe z-KIoCr@)+Rzq1JlKK%aVN5gf5D$L3Z9Ml=Cu;=qEa$l}aA=GZs@EROfSiaTHCDc=IwuGV z9@}?v;>&CTEiXDYpxC7$icGzB90h7y*S4He6$@A44bzVGRs67S^G74JYKZE@n3BHM zKmOEZL@)LXL6UusVm8g9)ZQeJVkjK4k9X3KSvoUI)MzRbW-%Wj(e)*}c&z_y{j(|k zyxyAVf+V`;(c3UaOIvw%l%DBf@-+Jt#cv2Rsm!!r7%-76*ktyV40~lrXU#7YbrmgC z5y6RzaX@9~EmDk)FFQ%mg0j&^ov{@E6NO8+6ulqBy~qWg@tU3~rWW^zvADzzRPXqT f%lhKd0w<, 2001-2002. +# Christer Andersson , 2007. +# Göran Uddeborg , 2011, 2012. +# +# $Revision: 1.7 $ +msgid "" +msgstr "" +"Project-Id-Version: gawk 4.0.0h\n" +"Report-Msgid-Bugs-To: arnold@skeeve.com\n" +"POT-Creation-Date: 2012-03-28 22:03+0200\n" +"PO-Revision-Date: 2012-01-30 12:07+0100\n" +"Last-Translator: Göran Uddeborg \n" +"Language-Team: Swedish \n" +"Language: sv\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=iso-8859-1\n" +"Content-Transfer-Encoding: 8bit\n" + +#: array.c:140 +#, c-format +msgid "from %s" +msgstr "från %s" + +#: array.c:248 +msgid "attempt to use a scalar value as array" +msgstr "försök att använda ett skalärt värde som vektor" + +#: array.c:251 +#, c-format +msgid "attempt to use function `%s' as an array" +msgstr "försök att använda funktionen \"%s\" som vektor" + +#: array.c:254 +#, c-format +msgid "attempt to use scalar parameter `%s' as an array" +msgstr "försök att använda skalärparametern \"%s\" som en vektor" + +#: array.c:257 +#, c-format +msgid "attempt to use scalar `%s' as an array" +msgstr "försök att använda skalären \"%s\" som en vektor" + +#: array.c:302 array.c:707 builtin.c:84 builtin.c:1385 builtin.c:1427 +#: builtin.c:1440 builtin.c:1859 builtin.c:1871 eval.c:1135 eval.c:1139 +#: eval.c:1495 eval.c:1812 +#, c-format +msgid "attempt to use array `%s' in a scalar context" +msgstr "försök att använda vektorn \"%s\" i skalärsammanhang" + +#: array.c:513 +#, c-format +msgid "reference to uninitialized element `%s[\"%.*s\"]'" +msgstr "referens till oinitierat element \"%s[\"%.*s\"]\"" + +#: array.c:519 +#, c-format +msgid "subscript of array `%s' is null string" +msgstr "index i vektorn \"%s\" är en tom sträng" + +#: array.c:723 +#, c-format +msgid "delete: index `%s' not in array `%s'" +msgstr "delete: index \"%s\" finns inte i vektorn \"%s\"" + +#: array.c:734 eval.c:1865 +#, c-format +msgid "attempt to use scalar `%s[\"%.*s\"]' as an array" +msgstr "försök att använda skalären \"%s[\"%.*s\"]\" som en vektor" + +#: array.c:910 +#, c-format +msgid "%s: empty (null)\n" +msgstr "%s: tom (null)\n" + +#: array.c:915 +#, c-format +msgid "%s: empty (zero)\n" +msgstr "%s: tom (noll)\n" + +#: array.c:919 +#, c-format +msgid "%s: table_size = %d, array_size = %d\n" +msgstr "%s: tabellstorlek = %d, vektorstorlek = %d\n" + +#: array.c:954 +#, c-format +msgid "%s: is parameter\n" +msgstr "%s: är en parameter\n" + +#: array.c:958 +#, c-format +msgid "%s: array_ref to %s\n" +msgstr "%s: vektorreferens till %s\n" + +#: array.c:963 +msgid "adump: argument not an array" +msgstr "adump: argumentet är inte en vektor" + +#: array.c:1086 +msgid "asort: second argument not an array" +msgstr "asort: andra argumentet är inte en vektor" + +#: array.c:1087 +msgid "asorti: second argument not an array" +msgstr "asorti: andra argumentet är inte en vektor" + +#: array.c:1094 +msgid "asort: first argument not an array" +msgstr "asort: första argumentet är inte en vektor" + +#: array.c:1095 +msgid "asorti: first argument not an array" +msgstr "asorti: första argumentet är inte en vektor" + +#: array.c:1102 +msgid "asort: cannot use a subarray of first arg for second arg" +msgstr "" +"asort: det går inte att använda en delvektor av första argumentet som andra " +"argument" + +#: array.c:1103 +msgid "asorti: cannot use a subarray of first arg for second arg" +msgstr "" +"asorti: det går inte att använda en delvektor av första argumentet som andra " +"argument" + +#: array.c:1108 +msgid "asort: cannot use a subarray of second arg for first arg" +msgstr "" +"asort: det går inte att använda en delvektor av andra argumentet som första " +"argument" + +#: array.c:1109 +msgid "asorti: cannot use a subarray of second arg for first arg" +msgstr "" +"asorti: det går inte att använda en delvektor av andra argumentet som första " +"argument" + +#: array.c:1655 +#, c-format +msgid "`%s' is invalid as a function name" +msgstr "\"%s\" är ogiltigt som ett funktionsnamn" + +#: array.c:1659 +#, c-format +msgid "sort comparison function `%s' is not defined" +msgstr "jämförelsefunktionen \"%s\" för sortering är inte definierad" + +#: awkgram.y:249 +#, c-format +msgid "%s blocks must have an action part" +msgstr "%s-block måste ha en åtgärdsdel" + +#: awkgram.y:252 +msgid "each rule must have a pattern or an action part" +msgstr "varje regel måste ha ett mönster eller en åtgärdsdel" + +#: awkgram.y:323 awkgram.y:334 +msgid "old awk does not support multiple `BEGIN' or `END' rules" +msgstr "gamla awk stöder inte flera \"BEGIN\"- eller \"END\"-regler" + +#: awkgram.y:371 +#, c-format +msgid "`%s' is a built-in function, it cannot be redefined" +msgstr "\"%s\" är en inbyggd funktion, den kan inte definieras om" + +#: awkgram.y:432 +msgid "regexp constant `//' looks like a C++ comment, but is not" +msgstr "regexp-konstanten \"//\" ser ut som en C++-kommentar men är inte det" + +#: awkgram.y:436 +#, c-format +msgid "regexp constant `/%s/' looks like a C comment, but is not" +msgstr "regexp-konstanten \"/%s/\" ser ut som en C-kommentar men är inte det" + +#: awkgram.y:528 +#, c-format +msgid "duplicate case values in switch body: %s" +msgstr "upprepade case-värden i switch-sats: %s" + +#: awkgram.y:549 +msgid "duplicate `default' detected in switch body" +msgstr "flera \"default\" upptäcktes i switch-sats" + +#: awkgram.y:809 +msgid "`break' is not allowed outside a loop or switch" +msgstr "\"break\" är inte tillåtet utanför en slinga eller switch" + +#: awkgram.y:818 +msgid "`continue' is not allowed outside a loop" +msgstr "\"continue\" är inte tillåtet utanför en slinga" + +#: awkgram.y:828 +#, c-format +msgid "`next' used in %s action" +msgstr "\"next\" använt i %s-åtgärd" + +#: awkgram.y:836 +msgid "`nextfile' is a gawk extension" +msgstr "\"nextfile\" är en gawk-utökning" + +#: awkgram.y:841 +#, c-format +msgid "`nextfile' used in %s action" +msgstr "\"nextfile\" använt i %s-åtgärd" + +#: awkgram.y:865 +msgid "`return' used outside function context" +msgstr "\"return\" använd utanför funktion" + +#: awkgram.y:925 +msgid "plain `print' in BEGIN or END rule should probably be `print \"\"'" +msgstr "" +"ensamt \"print\" i BEGIN eller END-regel bör troligen vara 'print \"\"'" + +#: awkgram.y:995 awkgram.y:999 awkgram.y:1023 +msgid "`delete array' is a gawk extension" +msgstr "\"delete array\" är en gawk-utökning" + +#: awkgram.y:1019 +msgid "`delete(array)' is a non-portable tawk extension" +msgstr "\"delete(array)\" är en icke portabel tawk-utökning" + +#: awkgram.y:1135 +msgid "multistage two-way pipelines don't work" +msgstr "flerstegs dubbelriktade rör fungerar inte" + +#: awkgram.y:1238 +msgid "regular expression on right of assignment" +msgstr "reguljärt uttryck i högerledet av en tilldelning" + +#: awkgram.y:1249 +msgid "regular expression on left of `~' or `!~' operator" +msgstr "reguljärt uttryck på vänster sida om en \"~\"- eller \"!~\"-operator" + +#: awkgram.y:1265 awkgram.y:1419 +msgid "old awk does not support the keyword `in' except after `for'" +msgstr "gamla awk stöder inte operatorn \"**\"" + +#: awkgram.y:1275 +msgid "regular expression on right of comparison" +msgstr "reguljärt uttryck i högerledet av en jämförelse" + +#: awkgram.y:1394 +#, c-format +msgid "`getline var' invalid inside `%s' rule" +msgstr "\"getline var\" är ogiltigt inuti \"%s\"-regel" + +#: awkgram.y:1397 eval.c:2504 +#, c-format +msgid "`getline' invalid inside `%s' rule" +msgstr "\"getline är ogiltigt inuti \"%s\"-regel" + +#: awkgram.y:1402 +msgid "non-redirected `getline' undefined inside END action" +msgstr "icke omdirigerad \"getline\" odefinierad inuti END-åtgärd" + +#: awkgram.y:1421 +msgid "old awk does not support multidimensional arrays" +msgstr "gamla awk stöder inte flerdimensionella vektorer" + +#: awkgram.y:1517 +msgid "call of `length' without parentheses is not portable" +msgstr "anrop av \"length\" utan parenteser är inte portabelt" + +#: awkgram.y:1580 +msgid "indirect function calls are a gawk extension" +msgstr "indirekta funktionsanrop är en gawk-utökning" + +#: awkgram.y:1593 +#, c-format +msgid "can not use special variable `%s' for indirect function call" +msgstr "" +"det går inte att använda specialvariabeln \"%s\" för indirekta fuktionsanrop" + +#: awkgram.y:1671 +msgid "invalid subscript expression" +msgstr "ogiltig indexuttryck" + +#: awkgram.y:1711 +msgid "use of non-array as array" +msgstr "icke-vektor används som vektor" + +#: awkgram.y:1975 awkgram.y:1995 msg.c:98 +msgid "warning: " +msgstr "varning: " + +#: awkgram.y:1993 msg.c:130 +msgid "fatal: " +msgstr "ödesdigert: " + +#: awkgram.y:2043 +msgid "unexpected newline or end of string" +msgstr "oväntat nyradstecken eller slut på strängen" + +#: awkgram.y:2300 awkgram.y:2358 awkgram.y:2542 +#, c-format +msgid "can't open source file `%s' for reading (%s)" +msgstr "kan inte öppna källfilen \"%s\" för läsning (%s)" + +#: awkgram.y:2301 awkgram.y:2359 builtin.c:122 +msgid "reason unknown" +msgstr "okänd anledning" + +#: awkgram.y:2317 +#, c-format +msgid "already included source file `%s'" +msgstr "inkluderade redan källfilen \"%s\"" + +#: awkgram.y:2343 +msgid "@include is a gawk extension" +msgstr "@include är en gawk-utökning" + +#: awkgram.y:2349 +msgid "empty filename after @include" +msgstr "tomt filnamn efter @include" + +#: awkgram.y:2494 +msgid "empty program text on command line" +msgstr "tom programtext på kommandoraden" + +#: awkgram.y:2609 +#, c-format +msgid "can't read sourcefile `%s' (%s)" +msgstr "kan inte läsa källfilen \"%s\" (%s)" + +#: awkgram.y:2620 +#, c-format +msgid "source file `%s' is empty" +msgstr "källfilen \"%s\" är tom" + +#: awkgram.y:2797 +msgid "source file does not end in newline" +msgstr "källfilen slutar inte med en ny rad" + +#: awkgram.y:2900 +msgid "unterminated regexp ends with `\\' at end of file" +msgstr "oavslutat reguljärt uttryck slutar med \"\\\" i slutet av filen" + +#: awkgram.y:2924 +#, c-format +msgid "%s: %d: tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "" +"%s: %d: tawk-modifierare för reguljära uttryck \"/.../%c\" fungerar inte i " +"gawk" + +#: awkgram.y:2928 +#, c-format +msgid "tawk regex modifier `/.../%c' doesn't work in gawk" +msgstr "" +"tawk-modifierare för reguljära uttryck \"/.../%c\" fungerar inte i gawk" + +#: awkgram.y:2935 +msgid "unterminated regexp" +msgstr "oavslutat reguljärt uttryck" + +#: awkgram.y:2939 +msgid "unterminated regexp at end of file" +msgstr "oavslutat reguljärt uttryck i slutet av filen" + +#: awkgram.y:2998 +msgid "use of `\\ #...' line continuation is not portable" +msgstr "Användning av \"\\ #...\" för radfortsättning är inte portabelt" + +#: awkgram.y:3014 +msgid "backslash not last character on line" +msgstr "sista tecknet på raden är inte ett omvänt snedstreck" + +#: awkgram.y:3075 +msgid "POSIX does not allow operator `**='" +msgstr "POSIX tillåter inte operatorn \"**=\"" + +#: awkgram.y:3077 +msgid "old awk does not support operator `**='" +msgstr "gamla awk stöder inte operatorn \"**=\"" + +#: awkgram.y:3086 +msgid "POSIX does not allow operator `**'" +msgstr "POSIX tillåter inte operatorn \"**\"" + +#: awkgram.y:3088 +msgid "old awk does not support operator `**'" +msgstr "gamla awk stöder inte operatorn \"**\"" + +#: awkgram.y:3123 +msgid "operator `^=' is not supported in old awk" +msgstr "operatorn \"^=\" stöds inte i gamla awk" + +#: awkgram.y:3131 +msgid "operator `^' is not supported in old awk" +msgstr "operatorn \"^\" stöds inte i gamla awk" + +#: awkgram.y:3224 awkgram.y:3240 +msgid "unterminated string" +msgstr "oavslutad sträng" + +#: awkgram.y:3436 +#, c-format +msgid "invalid char '%c' in expression" +msgstr "ogiltigt tecken \"%c\" i uttryck" + +#: awkgram.y:3483 +#, c-format +msgid "`%s' is a gawk extension" +msgstr "\"%s\" är en gawk-utökning" + +#: awkgram.y:3488 +#, c-format +msgid "`%s' is a Bell Labs extension" +msgstr "\"%s\" är en Bell Labs-utökning" + +#: awkgram.y:3493 +#, c-format +msgid "POSIX does not allow `%s'" +msgstr "POSIX tillåter inte \"%s\"" + +#: awkgram.y:3501 +#, c-format +msgid "`%s' is not supported in old awk" +msgstr "\"%s\" stöds inte i gamla awk" + +#: awkgram.y:3568 +msgid "`goto' considered harmful!\n" +msgstr "\"goto\" anses skadlig!\n" + +#: awkgram.y:3619 +#, c-format +msgid "%d is invalid as number of arguments for %s" +msgstr "%d är ett ogiltigt antal argument för %s" + +#: awkgram.y:3654 +#, c-format +msgid "%s: string literal as last arg of substitute has no effect" +msgstr "" +"%s: bokstavlig sträng som sista argument till ersättning har ingen effekt" + +#: awkgram.y:3659 +#, c-format +msgid "%s third parameter is not a changeable object" +msgstr "%s: tredje argumentet är inte ett ändringsbart objekt" + +#: awkgram.y:3732 awkgram.y:3735 +msgid "match: third argument is a gawk extension" +msgstr "match: tredje argumentet är en gawk-utökning" + +#: awkgram.y:3789 awkgram.y:3792 +msgid "close: second argument is a gawk extension" +msgstr "close: andra argumentet är en gawk-utökning" + +#: awkgram.y:3804 +msgid "use of dcgettext(_\"...\") is incorrect: remove leading underscore" +msgstr "" +"användandet av dcgettext(_\"...\") är felaktigt: ta bort det inledande " +"understrykningstecknet" + +#: awkgram.y:3819 +msgid "use of dcngettext(_\"...\") is incorrect: remove leading underscore" +msgstr "" +"användandet av dcngettext(_\"...\") är felaktigt: ta bort det inledande " +"understrykningstecknet" + +#: awkgram.y:3911 +#, c-format +msgid "function `%s': parameter #%d, `%s', duplicates parameter #%d" +msgstr "funktionen \"%s\": parameter %d, \"%s\", är samma som parameter %d" + +#: awkgram.y:3953 +#, c-format +msgid "function `%s': parameter `%s' shadows global variable" +msgstr "funktionen \"%s\": parametern \"%s\" överskuggar en global variabel" + +#: awkgram.y:4111 +#, c-format +msgid "could not open `%s' for writing (%s)" +msgstr "kunde inte öppna \"%s\" för skrivning (%s)" + +#: awkgram.y:4112 +msgid "sending variable list to standard error" +msgstr "skickar variabellista till standard fel" + +#: awkgram.y:4118 +#, c-format +msgid "%s: close failed (%s)" +msgstr "%s: misslyckades att stänga (%s)" + +#: awkgram.y:4170 +msgid "shadow_funcs() called twice!" +msgstr "shadow_funcs() anropad två gånger!" + +#: awkgram.y:4176 +msgid "there were shadowed variables." +msgstr "det fanns överskuggade variabler." + +#: awkgram.y:4206 +#, c-format +msgid "function `%s': can't use function name as parameter name" +msgstr "funktionen \"%s\": kan inte använda funktionsnamn som parameternamn" + +#: awkgram.y:4210 +#, c-format +msgid "function `%s': can't use special variable `%s' as a function parameter" +msgstr "" +"funktionen \"%s\": det går inte att använda specialvariabeln \"%s\" som en " +"funktionsparameter" + +#: awkgram.y:4226 +#, c-format +msgid "function name `%s' previously defined" +msgstr "funktionsnamnet \"%s\" är definierat sedan tidigare" + +#: awkgram.y:4394 awkgram.y:4400 +#, c-format +msgid "function `%s' called but never defined" +msgstr "funktionen \"%s\" anropad men aldrig definierad" + +#: awkgram.y:4403 +#, c-format +msgid "function `%s' defined but never called directly" +msgstr "funktionen \"%s\" definierad men aldrig anropad direkt" + +#: awkgram.y:4435 +#, c-format +msgid "regexp constant for parameter #%d yields boolean value" +msgstr "konstant reguljärt uttryck för parameter %d ger ett booleskt värde" + +#: awkgram.y:4544 +#, c-format +msgid "" +"function `%s' called with space between name and `(',\n" +"or used as a variable or an array" +msgstr "" +"funktionen \"%s\" anropad med blanktecken mellan namnet och \"(\",\n" +"eller använd som variabel eller vektor" + +#: awkgram.y:4791 eval.c:2056 +msgid "division by zero attempted" +msgstr "försökte dividera med noll" + +#: awkgram.y:4800 eval.c:2072 +#, c-format +msgid "division by zero attempted in `%%'" +msgstr "försökte dividera med noll i \"%%\"" + +#: builtin.c:120 +#, c-format +msgid "%s to \"%s\" failed (%s)" +msgstr "%s till \"%s\" misslyckades (%s)" + +#: builtin.c:121 +msgid "standard output" +msgstr "standard ut" + +#: builtin.c:135 +msgid "exp: received non-numeric argument" +msgstr "exp: fick ett ickenumeriskt argument" + +#: builtin.c:141 +#, c-format +msgid "exp: argument %g is out of range" +msgstr "exp: argumentet %g är inte inom tillåten gräns" + +#: builtin.c:200 +#, c-format +msgid "fflush: cannot flush: pipe `%s' opened for reading, not writing" +msgstr "" +"fflush: kan inte spola: röret \"%s\" öppnat för läsning, inte skrivning" + +#: builtin.c:203 +#, c-format +msgid "fflush: cannot flush: file `%s' opened for reading, not writing" +msgstr "" +"fflush: kan inte spola: filen \"%s\" öppnad för läsning, inte skrivning" + +#: builtin.c:215 +#, c-format +msgid "fflush: `%s' is not an open file, pipe or co-process" +msgstr "fflush: \"%s\" är inte en öppen fil, rör eller koprocess" + +#: builtin.c:333 +msgid "index: received non-string first argument" +msgstr "index: första argumentet är inte en sträng" + +#: builtin.c:335 +msgid "index: received non-string second argument" +msgstr "index: andra argumentet är inte en sträng" + +#: builtin.c:457 +msgid "int: received non-numeric argument" +msgstr "int: fick ett ickenumeriskt argument" + +#: builtin.c:493 +msgid "length: received array argument" +msgstr "length: fick ett vektorargument" + +#: builtin.c:496 +msgid "`length(array)' is a gawk extension" +msgstr "\"length(array)\" är en gawk-utökning" + +#: builtin.c:504 +msgid "length: received non-string argument" +msgstr "length: fick ett argument som inte är en sträng" + +#: builtin.c:535 +msgid "log: received non-numeric argument" +msgstr "log: fick ett ickenumeriskt argument" + +#: builtin.c:538 +#, c-format +msgid "log: received negative argument %g" +msgstr "log: fick ett negativt argumentet %g" + +#: builtin.c:694 builtin.c:699 +msgid "fatal: must use `count$' on all formats or none" +msgstr "ödesdigert: måste använda \"count$\" på alla eller inga format" + +#: builtin.c:762 +#, c-format +msgid "field width is ignored for `%%' specifier" +msgstr "fältbredd ignoreras för \"%%\"-specificerare" + +#: builtin.c:764 +#, c-format +msgid "precision is ignored for `%%' specifier" +msgstr "precision ignoreras för \"%%\"-specificerare" + +#: builtin.c:766 +#, c-format +msgid "field width and precision are ignored for `%%' specifier" +msgstr "fältbredd och precision ignoreras för \"%%\"-specificerare" + +#: builtin.c:817 +msgid "fatal: `$' is not permitted in awk formats" +msgstr "ödesdigert: \"$\" tillåts inte i awk-format" + +#: builtin.c:826 +msgid "fatal: arg count with `$' must be > 0" +msgstr "ödesdigert: argumentantalet med \"$\" måste vara > 0" + +#: builtin.c:830 +#, c-format +msgid "fatal: arg count %ld greater than total number of supplied arguments" +msgstr "ödesdigert: argumentantalet %ld är större än antalet givna argument" + +#: builtin.c:834 +msgid "fatal: `$' not permitted after period in format" +msgstr "ödesdigert: \"$\" tillåts inte efter en punkt i formatet" + +#: builtin.c:850 +msgid "fatal: no `$' supplied for positional field width or precision" +msgstr "" +"ödesdigert: inget \"$\" bifogat för positionsangiven fältbredd eller " +"precision" + +#: builtin.c:921 +msgid "`l' is meaningless in awk formats; ignored" +msgstr "\"l\" är meningslös i awk-format, ignorerad" + +#: builtin.c:925 +msgid "fatal: `l' is not permitted in POSIX awk formats" +msgstr "ödesdigert: \"l\" tillåts inte i POSIX awk-format" + +#: builtin.c:938 +msgid "`L' is meaningless in awk formats; ignored" +msgstr "\"L\" är meningslös i awk-format, ignorerad" + +#: builtin.c:942 +msgid "fatal: `L' is not permitted in POSIX awk formats" +msgstr "ödesdigert: \"L\" tillåts inte i POSIX awk-format" + +#: builtin.c:955 +msgid "`h' is meaningless in awk formats; ignored" +msgstr "\"h\" är meningslös i awk-format, ignorerad" + +#: builtin.c:959 +msgid "fatal: `h' is not permitted in POSIX awk formats" +msgstr "ödesdigert: \"h\" tillåts inte i POSIX awk-format" + +#: builtin.c:1272 +#, c-format +msgid "[s]printf: value %g is out of range for `%%%c' format" +msgstr "[s]printf: värdet %g är utanför \"%%%c\"-formatets giltiga intervall" + +#: builtin.c:1332 +#, c-format +msgid "ignoring unknown format specifier character `%c': no argument converted" +msgstr "" +"ignorerar okänt formatspecifikationstecken \"%c\": inget argument konverterat" + +#: builtin.c:1337 +msgid "fatal: not enough arguments to satisfy format string" +msgstr "ödesdigert: för få argument för formatsträngen" + +#: builtin.c:1339 +msgid "^ ran out for this one" +msgstr "^ tog slut här" + +#: builtin.c:1346 +msgid "[s]printf: format specifier does not have control letter" +msgstr "[s]printf: formatspecifieraren har ingen kommandobokstav" + +#: builtin.c:1349 +msgid "too many arguments supplied for format string" +msgstr "för många argument för formatsträngen" + +#: builtin.c:1423 builtin.c:1434 +msgid "printf: no arguments" +msgstr "printf: inga argument" + +#: builtin.c:1475 +msgid "sqrt: received non-numeric argument" +msgstr "sqrt: fick ickenumeriskt argument" + +#: builtin.c:1479 +#, c-format +msgid "sqrt: called with negative argument %g" +msgstr "sqrt: anropad med negativt argument %g" + +#: builtin.c:1503 +#, c-format +msgid "substr: length %g is not >= 1" +msgstr "substr: längden %g är inte >= 1" + +#: builtin.c:1505 +#, c-format +msgid "substr: length %g is not >= 0" +msgstr "substr: längden %g är inte >= 0" + +#: builtin.c:1512 +#, c-format +msgid "substr: non-integer length %g will be truncated" +msgstr "substr: längden %g som inte är ett heltal kommer trunkeras" + +#: builtin.c:1517 +#, c-format +msgid "substr: length %g too big for string indexing, truncating to %g" +msgstr "substr: längden %g är för stor för strängindexering, trunkeras till %g" + +#: builtin.c:1529 +#, c-format +msgid "substr: start index %g is invalid, using 1" +msgstr "substr: startindex %g är ogiltigt, använder 1" + +#: builtin.c:1534 +#, c-format +msgid "substr: non-integer start index %g will be truncated" +msgstr "substr: startindex %g som inte är ett heltal kommer trunkeras" + +#: builtin.c:1559 +msgid "substr: source string is zero length" +msgstr "substr: källsträngen är tom" + +#: builtin.c:1575 +#, c-format +msgid "substr: start index %g is past end of string" +msgstr "substr: startindex %g är bortom strängens slut" + +#: builtin.c:1583 +#, c-format +msgid "" +"substr: length %g at start index %g exceeds length of first argument (%lu)" +msgstr "" +"substr: längden %g vid startindex %g överskrider det första argumentets " +"längd (%lu)" + +#: builtin.c:1657 +msgid "strftime: format value in PROCINFO[\"strftime\"] has numeric type" +msgstr "strftime: formatvärde i PROCINFO[\"strftime\"] har numerisk typ" + +#: builtin.c:1680 +msgid "strftime: received non-numeric second argument" +msgstr "strftime: fick ett ickenumeriskt andra argument" + +#: builtin.c:1683 +msgid "strftime: second argument less than 0 or too big for time_t" +msgstr "strftime: andra argimentet mindre än 0 eller för stort för time_t" + +#: builtin.c:1690 +msgid "strftime: received non-string first argument" +msgstr "strftime: fick ett första argument som inte är en sträng" + +#: builtin.c:1696 +msgid "strftime: received empty format string" +msgstr "strftime: fick en tom formatsträng" + +#: builtin.c:1762 +msgid "mktime: received non-string argument" +msgstr "mktime: fick ett argument som inte är en sträng" + +#: builtin.c:1779 +msgid "mktime: at least one of the values is out of the default range" +msgstr "mktime: åtminstone ett av värdena är utanför standardintervallet" + +#: builtin.c:1814 +msgid "'system' function not allowed in sandbox mode" +msgstr "funktionen \"system\" är inte tillåten i sandlådeläge" + +#: builtin.c:1819 +msgid "system: received non-string argument" +msgstr "system: fick ett argument som inte är en sträng" + +#: builtin.c:1874 eval.c:1159 eval.c:1790 eval.c:1803 +#, c-format +msgid "reference to uninitialized variable `%s'" +msgstr "referens till icke initierad variabel \"%s\"" + +#: builtin.c:1941 +#, c-format +msgid "reference to uninitialized field `$%d'" +msgstr "referens till icke initierat fält \"$%d\"" + +#: builtin.c:2028 +msgid "tolower: received non-string argument" +msgstr "tolower: fick ett argument som inte är en sträng" + +#: builtin.c:2062 +msgid "toupper: received non-string argument" +msgstr "toupper: fick ett argument som inte är en sträng" + +#: builtin.c:2098 +msgid "atan2: received non-numeric first argument" +msgstr "atan2: fick ett ickenumeriskt första argument" + +#: builtin.c:2100 +msgid "atan2: received non-numeric second argument" +msgstr "atan2: fick ett ickenumeriskt andra argument" + +#: builtin.c:2119 +msgid "sin: received non-numeric argument" +msgstr "sin: fick ett ickenumeriskt argument" + +#: builtin.c:2135 +msgid "cos: received non-numeric argument" +msgstr "cos: fick ett ickenumeriskt argument" + +#: builtin.c:2188 +msgid "srand: received non-numeric argument" +msgstr "srand: fick ett ickenumeriskt argument" + +#: builtin.c:2219 +msgid "match: third argument is not an array" +msgstr "match: tredje argumentet är inte en vektor" + +#: builtin.c:2483 +msgid "gensub: third argument of 0 treated as 1" +msgstr "gensub: nollan i tredje argumentet behandlad som en etta" + +#: builtin.c:2776 +msgid "lshift: received non-numeric first argument" +msgstr "lshift: fick ett ickenumeriskt första argument" + +#: builtin.c:2778 +msgid "lshift: received non-numeric second argument" +msgstr "lshift: fick ett ickenumeriskt andra argument" + +#: builtin.c:2784 +#, c-format +msgid "lshift(%lf, %lf): negative values will give strange results" +msgstr "lshift(%lf, %lf): negativa värden kommer ge konstiga resultat" + +#: builtin.c:2786 +#, c-format +msgid "lshift(%lf, %lf): fractional values will be truncated" +msgstr "lshift(%lf, %lf): flyttalsvärden kommer trunkeras" + +#: builtin.c:2788 +#, c-format +msgid "lshift(%lf, %lf): too large shift value will give strange results" +msgstr "lshift(%lf, %lf): för stora skiftvärden kommer ge konstiga resultat" + +#: builtin.c:2813 +msgid "rshift: received non-numeric first argument" +msgstr "rshift: fick ett ickenumeriskt första argument" + +#: builtin.c:2815 +msgid "rshift: received non-numeric second argument" +msgstr "rshift: fick ett ickenumeriskt andra argument" + +#: builtin.c:2821 +#, c-format +msgid "rshift(%lf, %lf): negative values will give strange results" +msgstr "rshift(%lf, %lf): negativa värden kommer ge konstiga resultat" + +#: builtin.c:2823 +#, c-format +msgid "rshift(%lf, %lf): fractional values will be truncated" +msgstr "rshift(%lf, %lf): flyttalsvärden kommer trunkeras" + +#: builtin.c:2825 +#, c-format +msgid "rshift(%lf, %lf): too large shift value will give strange results" +msgstr "rshift(%lf, %lf): för stora skiftvärden kommer ge konstiga resultat" + +#: builtin.c:2850 +msgid "and: received non-numeric first argument" +msgstr "and: fick ett ickenumeriskt första argument" + +#: builtin.c:2852 +msgid "and: received non-numeric second argument" +msgstr "and: fick ett ickenumeriskt andra argument" + +#: builtin.c:2858 +#, c-format +msgid "and(%lf, %lf): negative values will give strange results" +msgstr "and(%lf, %lf): negativa värden kommer ge konstiga resultat" + +#: builtin.c:2860 +#, c-format +msgid "and(%lf, %lf): fractional values will be truncated" +msgstr "and(%lf, %lf): flyttalsvärden kommer trunkeras" + +#: builtin.c:2885 +msgid "or: received non-numeric first argument" +msgstr "or: fick ett ickenumeriskt första argument" + +#: builtin.c:2887 +msgid "or: received non-numeric second argument" +msgstr "or: fick ett ickenumeriskt andra argument" + +#: builtin.c:2893 +#, c-format +msgid "or(%lf, %lf): negative values will give strange results" +msgstr "or(%lf, %lf): negativa värden kommer ge konstiga resultat" + +#: builtin.c:2895 +#, c-format +msgid "or(%lf, %lf): fractional values will be truncated" +msgstr "or(%lf, %lf): flyttalsvärden kommer trunkeras" + +#: builtin.c:2923 +msgid "xor: received non-numeric first argument" +msgstr "xor: fick ett ickenumeriskt första argument" + +#: builtin.c:2925 +msgid "xor: received non-numeric second argument" +msgstr "xor: fick ett ickenumeriskt andra argument" + +#: builtin.c:2931 +#, c-format +msgid "xor(%lf, %lf): negative values will give strange results" +msgstr "xor(%lf, %lf): negativa värden kommer ge konstiga resultat" + +#: builtin.c:2933 +#, c-format +msgid "xor(%lf, %lf): fractional values will be truncated" +msgstr "xor(%lf, %lf): flyttalsvärden kommer trunkeras" + +#: builtin.c:2957 builtin.c:2963 +msgid "compl: received non-numeric argument" +msgstr "compl: fick ett ickenumeriskt argument" + +#: builtin.c:2965 +#, c-format +msgid "compl(%lf): negative value will give strange results" +msgstr "compl(%lf): negativa värden kommer ge konstiga resultat" + +#: builtin.c:2967 +#, c-format +msgid "compl(%lf): fractional value will be truncated" +msgstr "compl(%lf): flyttalsvärden kommer trunkeras" + +#: builtin.c:3136 +#, c-format +msgid "dcgettext: `%s' is not a valid locale category" +msgstr "dcgettext: \"%s\" är inte en giltig lokalkategori" + +#: eval.c:412 +#, c-format +msgid "unknown nodetype %d" +msgstr "okänd nodtyp %d" + +#: eval.c:423 eval.c:437 +#, c-format +msgid "unknown opcode %d" +msgstr "okänd op-kod %d" + +#: eval.c:434 +#, c-format +msgid "opcode %s not an operator or keyword" +msgstr "op-kod %s är inte en operator eller ett nyckelord" + +#: eval.c:488 +msgid "buffer overflow in genflags2str" +msgstr "buffertöverflöd i genflags2str" + +#: eval.c:698 +#, c-format +msgid "" +"\n" +"\t# Function Call Stack:\n" +"\n" +msgstr "" +"\n" +"\t# Funktionsanropsstack:\n" +"\n" + +#: eval.c:725 +msgid "`IGNORECASE' is a gawk extension" +msgstr "\"IGNORECASE\" är en gawk-utökning" + +#: eval.c:754 +msgid "`BINMODE' is a gawk extension" +msgstr "\"BINMODE\" är en gawk-utökning" + +#: eval.c:812 +#, c-format +msgid "BINMODE value `%s' is invalid, treated as 3" +msgstr "BINMODE-värde \"%s\" är ogiltigt, behandlas som 3" + +#: eval.c:902 +#, c-format +msgid "bad `%sFMT' specification `%s'" +msgstr "felaktig \"%sFMT\"-specifikation \"%s\"" + +#: eval.c:980 +msgid "turning off `--lint' due to assignment to `LINT'" +msgstr "slår av \"--lint\" på grund av en tilldelning till \"LINT\"" + +#: eval.c:1127 eval.c:1777 +#, c-format +msgid "can't use function name `%s' as variable or array" +msgstr "kan inte använda funktionsnamnet \"%s\" som variabel eller vektor" + +#: eval.c:1158 eval.c:1789 eval.c:1802 +#, c-format +msgid "reference to uninitialized argument `%s'" +msgstr "referens till icke initierat argument \"%s\"" + +#: eval.c:1177 +msgid "attempt to field reference from non-numeric value" +msgstr "försök att fältreferera från ickenumeriskt värde" + +#: eval.c:1179 +msgid "attempt to field reference from null string" +msgstr "försök till fältreferens från en tom sträng" + +#: eval.c:1185 +#, c-format +msgid "attempt to access field %ld" +msgstr "försök att komma åt fält nummer %ld" + +#: eval.c:1194 +#, c-format +msgid "reference to uninitialized field `$%ld'" +msgstr "referens till icke initierat fält \"$%ld\"" + +#: eval.c:1256 +#, c-format +msgid "function `%s' called with more arguments than declared" +msgstr "funktionen \"%s\" anropad med fler argument än vad som deklarerats" + +#: eval.c:1437 +#, c-format +msgid "unwind_stack: unexpected type `%s'" +msgstr "unwind_stack: oväntad typ \"%s\"" + +#: eval.c:1532 +msgid "division by zero attempted in `/='" +msgstr "försökte dividera med noll i \"/=\"" + +#: eval.c:1539 +#, c-format +msgid "division by zero attempted in `%%='" +msgstr "försökte dividera med noll i \"%%=\"" + +#: eval.c:1876 eval.c:2122 +#, c-format +msgid "attempt to use array `%s[\"%.*s\"]' in a scalar context" +msgstr "försök att använda vektorn \"%s[\"%.*s\"]\" i skalärsammanhang" + +#: eval.c:1907 +msgid "assignment used in conditional context" +msgstr "tilldelning använt i jämförelsesammanhang" + +#: eval.c:1911 +msgid "statement has no effect" +msgstr "kommandot har ingen effekt" + +#: eval.c:2343 +#, c-format +msgid "for loop: array `%s' changed size from %ld to %ld during loop execution" +msgstr "" +"forslinga: vektorn \"%s\" ändrade storlek från %ld till %ld under " +"slingexekvering" + +#: eval.c:2458 +#, c-format +msgid "function called indirectly through `%s' does not exist" +msgstr "funktionen anropad indirekt genom \"%s\" finns inte" + +#: eval.c:2470 +#, c-format +msgid "function `%s' not defined" +msgstr "funktionen \"%s\" är inte definierad" + +#: eval.c:2511 +#, c-format +msgid "non-redirected `getline' invalid inside `%s' rule" +msgstr "icke omdirigerad \"getline\" odefinierad inuti \"%s\"-regel" + +#: eval.c:2600 +#, c-format +msgid "error reading input file `%s': %s" +msgstr "fel vid läsning av indatafilen \"%s\": %s" + +#: eval.c:2614 +#, c-format +msgid "`nextfile' cannot be called from a `%s' rule" +msgstr "\"nextfile\" kan inte anropas från en \"%s\"-regel" + +#: eval.c:2661 +msgid "`exit' cannot be called in the current context" +msgstr "\"exit\" kan inte anropas i det aktuella sammanhanget" + +#: eval.c:2700 +#, c-format +msgid "`next' cannot be called from a `%s' rule" +msgstr "\"next\" kan inte anropas från en \"%s\"-regel" + +#: eval.c:2766 +#, c-format +msgid "Sorry, don't know how to interpret `%s'" +msgstr "Tyvärr, vet inte hur \"%s\" skall tolkas" + +#: ext.c:54 +msgid "extensions are not allowed in sandbox mode" +msgstr "utökningar är inte tillåtna i sandlådeläge" + +#: ext.c:60 ext.c:65 +msgid "`extension' is a gawk extension" +msgstr "\"extension\" är en gawk-utökning" + +#: ext.c:75 +#, c-format +msgid "fatal: extension: cannot open `%s' (%s)\n" +msgstr "ödesdigert: extension: kan inte öppna \"%s\" (%s)\n" + +#: ext.c:84 +#, c-format +msgid "" +"fatal: extension: library `%s': does not define " +"`plugin_is_GPL_compatible' (%s)\n" +msgstr "" +"ödesdigert: extension: biblioteket \"%s\": definierar inte " +"\"plugin_is_GPL_compatible\" (%s)\n" + +#: ext.c:93 +#, c-format +msgid "fatal: extension: library `%s': cannot call function `%s' (%s)\n" +msgstr "" +"ödesdigert: extension: bibliotek \"%s\": kan inte anropa funktionen \"%s" +"\" (%s)\n" + +#: ext.c:127 +msgid "extension: missing function name" +msgstr "extension: saknar funktionsnamn" + +#: ext.c:132 +#, c-format +msgid "extension: illegal character `%c' in function name `%s'" +msgstr "extension: ogiltigt tecken \"%c\" i funktionsnamnet \"%s\"" + +#: ext.c:141 +#, c-format +msgid "extension: can't redefine function `%s'" +msgstr "extension: det går inte att definiera om funktionen \"%s\"" + +#: ext.c:145 +#, c-format +msgid "extension: function `%s' already defined" +msgstr "extension: funktionen \"%s\" är redan definierad" + +#: ext.c:150 +#, c-format +msgid "extension: function name `%s' previously defined" +msgstr "extension: funktionsnamnet \"%s\" är definierat sedan tidigare" + +#: ext.c:152 +#, c-format +msgid "extension: can't use gawk built-in `%s' as function name" +msgstr "" +"extension: kan inte använda gawks inbyggda \"%s\" som ett funktionsnamn" + +#: ext.c:156 +#, c-format +msgid "make_builtin: negative argument count for function `%s'" +msgstr "make_builtin: negativt argumentantal för funktionen \"%s\"" + +#: ext.c:259 +#, c-format +msgid "function `%s' defined to take no more than %d argument(s)" +msgstr "funktionen \"%s\" definierades för att ta maximalt %d argument" + +#: ext.c:262 +#, c-format +msgid "function `%s': missing argument #%d" +msgstr "funktionen \"%s\": argument %d saknas" + +#: ext.c:279 +#, c-format +msgid "function `%s': argument #%d: attempt to use scalar as an array" +msgstr "funktionen \"%s\": argument %d: försök att använda skalär som vektor" + +#: ext.c:283 +#, c-format +msgid "function `%s': argument #%d: attempt to use array as a scalar" +msgstr "funktionen \"%s\": argument %d: försök att använda vektor som skalär" + +#: ext.c:296 +msgid "Operation Not Supported" +msgstr "Operationen stöds inte" + +#: field.c:328 +msgid "NF set to negative value" +msgstr "NF satt till ett negativt värde" + +#: field.c:951 field.c:958 field.c:962 +msgid "split: fourth argument is a gawk extension" +msgstr "split: fjärde argumentet är en gawk-utökning" + +#: field.c:955 +msgid "split: fourth argument is not an array" +msgstr "split: fjärde argumentet är inte en vektor" + +#: field.c:969 +msgid "split: second argument is not an array" +msgstr "split: andra argumentet är inte en vektor" + +#: field.c:973 +msgid "split: cannot use the same array for second and fourth args" +msgstr "" +"split: det går inte att använda samma vektor som andra och fjärde argument" + +#: field.c:978 +msgid "split: cannot use a subarray of second arg for fourth arg" +msgstr "" +"split: det går inte att använda en delvektor av andra argumentet som fjärde " +"argument" + +#: field.c:981 +msgid "split: cannot use a subarray of fourth arg for second arg" +msgstr "" +"split: det går inte att använda en delvektor av fjärde argumentet som andra " +"argument" + +#: field.c:1010 +msgid "split: null string for third arg is a gawk extension" +msgstr "split: tom sträng som tredje argument är en gawk-utökning" + +#: field.c:1050 +msgid "patsplit: fourth argument is not an array" +msgstr "patsplit: fjärde argumentet är inte en vektor" + +#: field.c:1055 +msgid "patsplit: second argument is not an array" +msgstr "patsplit: andra argumentet är inte en vektor" + +#: field.c:1061 +msgid "patsplit: third argument must be non-null" +msgstr "patsplit: tredje argumentet får inte vara tomt" + +#: field.c:1065 +msgid "patsplit: cannot use the same array for second and fourth args" +msgstr "" +"patsplit: det går inte att använda samma vektor som andra och fjärde argument" + +#: field.c:1070 +msgid "patsplit: cannot use a subarray of second arg for fourth arg" +msgstr "" +"patsplit: det går inte att använda en delvektor av andra argumentet som " +"fjärde argument" + +#: field.c:1073 +msgid "patsplit: cannot use a subarray of fourth arg for second arg" +msgstr "" +"patsplit: det går inte att använda en delvektor av fjärde argumentet som " +"andra argument" + +#: field.c:1110 +msgid "`FIELDWIDTHS' is a gawk extension" +msgstr "\"FIELDWIDTHS\" är en gawk-utökning" + +#: field.c:1173 +#, c-format +msgid "invalid FIELDWIDTHS value, near `%s'" +msgstr "ogiltigt FIELDWITHS-värde i närheten av \"%s\"" + +#: field.c:1246 +msgid "null string for `FS' is a gawk extension" +msgstr "tom sträng som \"FS\" är en gawk-utökning" + +#: field.c:1250 +msgid "old awk does not support regexps as value of `FS'" +msgstr "gamla awk stöder inte reguljära uttryck som värden på \"FS\"" + +#: field.c:1369 +msgid "`FPAT' is a gawk extension" +msgstr "\"FPAT\" är en gawk-utökning" + +#: getopt.c:604 getopt.c:633 +#, fuzzy, c-format +msgid "%s: option '%s' is ambiguous; possibilities:" +msgstr "%s: flaggan \"%s\" är tvetydig\n" + +#: getopt.c:679 getopt.c:683 +#, c-format +msgid "%s: option '--%s' doesn't allow an argument\n" +msgstr "%s: flaggan \"--%s\" tillåter inte något argument\n" + +#: getopt.c:692 getopt.c:697 +#, c-format +msgid "%s: option '%c%s' doesn't allow an argument\n" +msgstr "%s: flaggan \"%c%s\" tillåter inte något argument\n" + +#: getopt.c:740 getopt.c:759 +#, c-format +msgid "%s: option '--%s' requires an argument\n" +msgstr "%s: flaggan \"%s\" kräver ett argument\n" + +#: getopt.c:797 getopt.c:800 +#, c-format +msgid "%s: unrecognized option '--%s'\n" +msgstr "%s: okänd flagga \"--%s\"\n" + +#: getopt.c:808 getopt.c:811 +#, c-format +msgid "%s: unrecognized option '%c%s'\n" +msgstr "%s: okänd flagga \"%c%s\"\n" + +#: getopt.c:860 getopt.c:863 +#, c-format +msgid "%s: invalid option -- '%c'\n" +msgstr "%s: ogiltig flagga -- \"%c\"\n" + +#: getopt.c:916 getopt.c:933 getopt.c:1143 getopt.c:1161 +#, c-format +msgid "%s: option requires an argument -- '%c'\n" +msgstr "%s: flaggan kräver ett argument -- \"%c\"\n" + +#: getopt.c:989 getopt.c:1005 +#, c-format +msgid "%s: option '-W %s' is ambiguous\n" +msgstr "%s: flaggan \"-W %s\" är tvetydig\n" + +#: getopt.c:1029 getopt.c:1047 +#, c-format +msgid "%s: option '-W %s' doesn't allow an argument\n" +msgstr "%s: flaggan \"-W %s\" tillåter inte något argument\n" + +#: getopt.c:1068 getopt.c:1086 +#, c-format +msgid "%s: option '-W %s' requires an argument\n" +msgstr "%s: flaggan \"-W %s\" kräver ett argument\n" + +#: io.c:280 +#, c-format +msgid "command line argument `%s' is a directory: skipped" +msgstr "kommandoradsargumentet \"%s\" är en katalog: hoppas över" + +#: io.c:283 io.c:385 +#, c-format +msgid "cannot open file `%s' for reading (%s)" +msgstr "kan inte öppna filen \"%s\" för läsning (%s)" + +#: io.c:501 +#, c-format +msgid "close of fd %d (`%s') failed (%s)" +msgstr "stängning av fd %d (\"%s\") misslyckades (%s)" + +#: io.c:578 +msgid "redirection not allowed in sandbox mode" +msgstr "omdirigering är inte tillåten i sandlådeläge" + +#: io.c:612 +#, c-format +msgid "expression in `%s' redirection only has numeric value" +msgstr "uttrycket i \"%s\"-omdirigering har bara numeriskt värde" + +#: io.c:618 +#, c-format +msgid "expression for `%s' redirection has null string value" +msgstr "uttrycket för \"%s\"-omdirigering har en tom sträng som värde" + +#: io.c:623 +#, c-format +msgid "filename `%s' for `%s' redirection may be result of logical expression" +msgstr "" +"filnamnet \"%s\" för \"%s\"-omdirigering kan vara resultatet av ett logiskt " +"uttryck" + +#: io.c:666 +#, c-format +msgid "unnecessary mixing of `>' and `>>' for file `%.*s'" +msgstr "onödig blandning av \">\" och \">>\" för filen \"%.*s\"" + +#: io.c:719 +#, c-format +msgid "can't open pipe `%s' for output (%s)" +msgstr "kan inte öppna röret \"%s\" för utmatning (%s)" + +#: io.c:729 +#, c-format +msgid "can't open pipe `%s' for input (%s)" +msgstr "kan inte öppna röret \"%s\" för inmatning (%s)" + +#: io.c:752 +#, c-format +msgid "can't open two way pipe `%s' for input/output (%s)" +msgstr "kan inte öppna tvåvägsröret \"%s\" för in-/utmatning (%s)" + +#: io.c:834 +#, c-format +msgid "can't redirect from `%s' (%s)" +msgstr "kan inte dirigera om från \"%s\" (%s)" + +#: io.c:837 +#, c-format +msgid "can't redirect to `%s' (%s)" +msgstr "kan inte dirigera om till \"%s\" (%s)" + +#: io.c:888 +msgid "" +"reached system limit for open files: starting to multiplex file descriptors" +msgstr "" +"nådde systembegränsningen för öppna filer: börjar multiplexa fildeskriptorer" + +#: io.c:904 +#, c-format +msgid "close of `%s' failed (%s)." +msgstr "stängning av \"%s\" misslyckades (%s)" + +#: io.c:912 +msgid "too many pipes or input files open" +msgstr "för många rör eller indatafiler öppna" + +#: io.c:934 +msgid "close: second argument must be `to' or `from'" +msgstr "close: andra argumentet måste vara \"to\" eller \"from\"" + +#: io.c:951 +#, c-format +msgid "close: `%.*s' is not an open file, pipe or co-process" +msgstr "close: \"%.*s\" är inte en öppen fil, rör eller koprocess" + +#: io.c:956 +msgid "close of redirection that was never opened" +msgstr "stängning av omdirigering som aldrig öppnades" + +#: io.c:1053 +#, c-format +msgid "close: redirection `%s' not opened with `|&', second argument ignored" +msgstr "" +"close: omdirigeringen \"%s\" öppnades inte med \"|&\", andra argumentet " +"ignorerat" + +#: io.c:1069 +#, c-format +msgid "failure status (%d) on pipe close of `%s' (%s)" +msgstr "felstatus (%d) från rörstängning av \"%s\" (%s)" + +#: io.c:1072 +#, c-format +msgid "failure status (%d) on file close of `%s' (%s)" +msgstr "felstatus (%d) från filstängning av \"%s\" (%s)" + +#: io.c:1092 +#, c-format +msgid "no explicit close of socket `%s' provided" +msgstr "ingen explicit stängning av uttaget \"%s\" tillhandahållen" + +#: io.c:1095 +#, c-format +msgid "no explicit close of co-process `%s' provided" +msgstr "ingen explicit stängning av koprocessen \"%s\" tillhandahållen" + +#: io.c:1098 +#, c-format +msgid "no explicit close of pipe `%s' provided" +msgstr "ingen explicit stängning av röret \"%s\" tillhandahållen" + +#: io.c:1101 +#, c-format +msgid "no explicit close of file `%s' provided" +msgstr "ingen explicit stängning av filen \"%s\" tillhandahållen" + +#: io.c:1129 io.c:1184 main.c:794 main.c:831 +#, c-format +msgid "error writing standard output (%s)" +msgstr "fel vid skrivning till standard ut (%s)" + +#: io.c:1133 io.c:1189 +#, c-format +msgid "error writing standard error (%s)" +msgstr "fel vid skrivning till standard fel (%s)" + +#: io.c:1141 +#, c-format +msgid "pipe flush of `%s' failed (%s)." +msgstr "rörspolning av \"%s\" misslyckades (%s)" + +#: io.c:1144 +#, c-format +msgid "co-process flush of pipe to `%s' failed (%s)." +msgstr "koprocesspolning av röret till \"%s\" misslyckades (%s)" + +#: io.c:1147 +#, c-format +msgid "file flush of `%s' failed (%s)." +msgstr "filspolning av \"%s\" misslyckades (%s)" + +#: io.c:1262 +#, c-format +msgid "local port %s invalid in `/inet'" +msgstr "lokal port %s ogiltig i \"/inet\"" + +#: io.c:1279 +#, c-format +msgid "remote host and port information (%s, %s) invalid" +msgstr "ogiltig information (%s, %s) för fjärrvärd och fjärrport" + +#: io.c:1431 +#, c-format +msgid "no (known) protocol supplied in special filename `%s'" +msgstr "" +"inget (känt) protokoll tillhandahållet i det speciella filnamnet \"%s\"" + +#: io.c:1445 +#, c-format +msgid "special file name `%s' is incomplete" +msgstr "speciellt filnamn \"%s\" är ofullständigt" + +#: io.c:1462 +msgid "must supply a remote hostname to `/inet'" +msgstr "måste tillhandahålla ett fjärrdatornamn till \"/inet\"" + +#: io.c:1480 +msgid "must supply a remote port to `/inet'" +msgstr "måste tillhandahålla en fjärrport till \"/inet\"" + +#: io.c:1526 +msgid "TCP/IP communications are not supported" +msgstr "TCP/IP-kommunikation stöds inte" + +#: io.c:1693 +#, c-format +msgid "could not open `%s', mode `%s'" +msgstr "kunde inte öppna \"%s\", läge \"%s\"" + +#: io.c:1747 +#, c-format +msgid "close of master pty failed (%s)" +msgstr "stängning av huvudpty misslyckades (%s)" + +#: io.c:1749 io.c:1917 io.c:2074 +#, c-format +msgid "close of stdout in child failed (%s)" +msgstr "stängning av standard ut i barnet misslyckades (%s)" + +#: io.c:1752 +#, c-format +msgid "moving slave pty to stdout in child failed (dup: %s)" +msgstr "flyttandet av slavpty till standard ut i barnet misslyckades (dup: %s)" + +#: io.c:1754 io.c:1922 +#, c-format +msgid "close of stdin in child failed (%s)" +msgstr "stängning av standard in i barnet misslyckades (%s)" + +#: io.c:1757 +#, c-format +msgid "moving slave pty to stdin in child failed (dup: %s)" +msgstr "flyttandet av slavpty till standard in i barnet misslyckades (dup: %s)" + +#: io.c:1759 io.c:1780 +#, c-format +msgid "close of slave pty failed (%s)" +msgstr "stängning av slavpty misslyckades (%s)" + +#: io.c:1858 io.c:1920 io.c:2052 io.c:2077 +#, c-format +msgid "moving pipe to stdout in child failed (dup: %s)" +msgstr "flyttande av rör till standard ut i barnet misslyckades (dup: %s)" + +#: io.c:1865 io.c:1925 +#, c-format +msgid "moving pipe to stdin in child failed (dup: %s)" +msgstr "flyttande av rör till standard in i barnet misslyckades (dup: %s)" + +#: io.c:1885 io.c:2067 +msgid "restoring stdout in parent process failed\n" +msgstr "återställande av standard ut i förälderprocessen misslyckades\n" + +#: io.c:1893 +msgid "restoring stdin in parent process failed\n" +msgstr "återställande av standard in i förälderprocessen misslyckades\n" + +#: io.c:1928 io.c:2079 io.c:2093 +#, c-format +msgid "close of pipe failed (%s)" +msgstr "stängning av röret misslyckades (%s)" + +#: io.c:1973 +msgid "`|&' not supported" +msgstr "\"|&\" stöds inte" + +#: io.c:2039 +#, c-format +msgid "cannot open pipe `%s' (%s)" +msgstr "kan inte öppna röret \"%s\" (%s)" + +#: io.c:2087 +#, c-format +msgid "cannot create child process for `%s' (fork: %s)" +msgstr "kan inte skapa barnprocess för \"%s\" (fork: %s)" + +#: io.c:2520 +#, c-format +msgid "data file `%s' is empty" +msgstr "datafilen \"%s\" är tom" + +#: io.c:2561 io.c:2569 +msgid "could not allocate more input memory" +msgstr "kunde inte allokera mer indataminne" + +#: io.c:3127 +msgid "multicharacter value of `RS' is a gawk extension" +msgstr "flerteckensvärdet av \"RS\" är en gawk-utökning" + +#: io.c:3232 +msgid "IPv6 communication is not supported" +msgstr "IPv6-kommunikation stöds inte" + +#: main.c:366 +msgid "`-m[fr]' option irrelevant in gawk" +msgstr "\"-m[fr]\"-flaggan är irrelevant i gawk" + +#: main.c:368 +msgid "-m option usage: `-m[fr] nnn'" +msgstr "-m-flaggans användning: \"-m[fr] nnn\"" + +#: main.c:391 +msgid "empty argument to `-e/--source' ignored" +msgstr "tomt argument till \"-e/--source\" ignorerat" + +#: main.c:462 +#, c-format +msgid "%s: option `-W %s' unrecognized, ignored\n" +msgstr "%s: flaggan \"-W %s\" okänd, ignorerad\n" + +#: main.c:515 +#, c-format +msgid "%s: option requires an argument -- %c\n" +msgstr "%s: flaggan kräver ett argument -- %c\n" + +#: main.c:536 +msgid "environment variable `POSIXLY_CORRECT' set: turning on `--posix'" +msgstr "miljövariabeln \"POSIXLY_CORRECT\" satt: slår på \"--posix\"" + +#: main.c:542 +msgid "`--posix' overrides `--traditional'" +msgstr "\"--posix\" åsidosätter \"--traditional\"" + +#: main.c:553 +msgid "`--posix'/`--traditional' overrides `--non-decimal-data'" +msgstr "\"--posix\"/\"--traditional\" åsidosätter \"--non-decimal-data\"" + +#: main.c:557 +#, c-format +msgid "running %s setuid root may be a security problem" +msgstr "att köra %s setuid root kan vara ett säkerhetsproblem" + +#: main.c:562 +msgid "`--posix' overrides `--binary'" +msgstr "\"--posix\" åsidosätter \"--binary\"" + +#: main.c:613 +#, c-format +msgid "can't set binary mode on stdin (%s)" +msgstr "kan inte sätta binärläge på standard in (%s)" + +#: main.c:616 +#, c-format +msgid "can't set binary mode on stdout (%s)" +msgstr "kan inte sätta binärläge på standard ut (%s)" + +#: main.c:618 +#, c-format +msgid "can't set binary mode on stderr (%s)" +msgstr "kan inte sätta binärläge på standard fel (%s)" + +#: main.c:657 +msgid "no program text at all!" +msgstr "ingen programtext alls!" + +#: main.c:734 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] -f progfile [--] file ...\n" +msgstr "" +"Användning: %s [POSIX- eller GNU-stilsflaggor] -f progfil [--] fil ...\n" + +#: main.c:736 +#, c-format +msgid "Usage: %s [POSIX or GNU style options] [--] %cprogram%c file ...\n" +msgstr "Användning: %s [POSIX- eller GNU-stilsflaggor] %cprogram%c fil ...\n" + +#: main.c:741 +msgid "POSIX options:\t\tGNU long options: (standard)\n" +msgstr "POSIX-flaggor:\t\tGNU långa flaggor: (standard)\n" + +#: main.c:742 +msgid "\t-f progfile\t\t--file=progfile\n" +msgstr "\t-f progfil\t\t--file=progfil\n" + +#: main.c:743 +msgid "\t-F fs\t\t\t--field-separator=fs\n" +msgstr "\t-F fs\t\t\t--field-separator=fs\n" + +#: main.c:744 +msgid "\t-v var=val\t\t--assign=var=val\n" +msgstr "\t-v var=värde\t\t--assign=var=värde\n" + +#: main.c:745 +msgid "Short options:\t\tGNU long options: (extensions)\n" +msgstr "Korta flaggor:\t\tGNU långa flaggor: (utökningar)\n" + +#: main.c:746 +msgid "\t-b\t\t\t--characters-as-bytes\n" +msgstr "\t-b\t\t\t--characters-as-bytes\n" + +#: main.c:747 +msgid "\t-c\t\t\t--traditional\n" +msgstr "\t-c\t\t\t--traditional\n" + +#: main.c:748 +msgid "\t-C\t\t\t--copyright\n" +msgstr "\t-C\t\t\t--copyright\n" + +#: main.c:749 +msgid "\t-d[file]\t\t--dump-variables[=file]\n" +msgstr "\t-d[fil]\t\t\t--dump-variables[=fil]\n" + +#: main.c:750 +msgid "\t-e 'program-text'\t--source='program-text'\n" +msgstr "\t-e 'programtext'\t--source='programtext'\n" + +#: main.c:751 +msgid "\t-E file\t\t\t--exec=file\n" +msgstr "\t-E fil\t\t\t--exec=fil\n" + +#: main.c:752 +msgid "\t-g\t\t\t--gen-pot\n" +msgstr "\t-g\t\t\t--gen-pot\n" + +#: main.c:753 +msgid "\t-h\t\t\t--help\n" +msgstr "\t-h\t\t\t--help\n" + +#: main.c:754 +msgid "\t-L [fatal]\t\t--lint[=fatal]\n" +msgstr "\t-L [fatal]\t\t--lint[=fatal]\n" + +#: main.c:755 +msgid "\t-n\t\t\t--non-decimal-data\n" +msgstr "\t-n\t\t\t--non-decimal-data\n" + +#: main.c:756 +msgid "\t-N\t\t\t--use-lc-numeric\n" +msgstr "\t-N\t\t\t--use-lc-numeric\n" + +#: main.c:757 +msgid "\t-O\t\t\t--optimize\n" +msgstr "\t-O\t\t\t--optimize\n" + +#: main.c:758 +msgid "\t-p[file]\t\t--profile[=file]\n" +msgstr "\t-p[fil]\t\t\t--profile[=fil]\n" + +#: main.c:759 +msgid "\t-P\t\t\t--posix\n" +msgstr "\t-P\t\t\t--posix\n" + +#: main.c:760 +msgid "\t-r\t\t\t--re-interval\n" +msgstr "\t-r\t\t\t--re-interval\n" + +#: main.c:762 +msgid "\t-R file\t\t\t--command=file\n" +msgstr "\t-R file\t\t\t--command=file\n" + +#: main.c:763 +msgid "\t-S\t\t\t--sandbox\n" +msgstr "\t-S\t\t\t--sandbox\n" + +#: main.c:764 +msgid "\t-t\t\t\t--lint-old\n" +msgstr "\t-t\t\t\t--lint-old\n" + +#: main.c:765 +msgid "\t-V\t\t\t--version\n" +msgstr "\t-V\t\t\t--version\n" + +#: main.c:767 +msgid "\t-W nostalgia\t\t--nostalgia\n" +msgstr "\t-W nostalgia\t\t--nostalgia\n" + +#: main.c:770 +msgid "\t-Y\t\t--parsedebug\n" +msgstr "\t-Y\t\t--parsedebug\n" + +#. TRANSLATORS: --help output 5 (end) +#. TRANSLATORS: the placeholder indicates the bug-reporting address +#. for this application. Please add _another line_ with the +#. address for translation bugs. +#. no-wrap +#: main.c:779 +msgid "" +"\n" +"To report bugs, see node `Bugs' in `gawk.info', which is\n" +"section `Reporting Problems and Bugs' in the printed version.\n" +"\n" +msgstr "" +"\n" +"För att rapportera fel, se noden \"Bugs\" i \"gawk.info\",\n" +"vilket är avsnittet \"Reporting Problems and Bugs\" i den utskrivna\n" +"versionen.\n" +"Rapportera synpunkter på översättningen till .\n" +"\n" + +#: main.c:783 +msgid "" +"gawk is a pattern scanning and processing language.\n" +"By default it reads standard input and writes standard output.\n" +"\n" +msgstr "" +"gawk är ett mönsterskannande och -bearbetande språk.\n" +"Normalt läser det från standard in och skriver till standard ut.\n" +"\n" + +#: main.c:787 +msgid "" +"Examples:\n" +"\tgawk '{ sum += $1 }; END { print sum }' file\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" +msgstr "" +"Exempel:\n" +"\tgawk '{ sum += $1 }; END { print sum }' fil\n" +"\tgawk -F: '{ print $1 }' /etc/passwd\n" + +#: main.c:807 +#, c-format +msgid "" +"Copyright (C) 1989, 1991-%d Free Software Foundation.\n" +"\n" +"This program is free software; you can redistribute it and/or modify\n" +"it under the terms of the GNU General Public License as published by\n" +"the Free Software Foundation; either version 3 of the License, or\n" +"(at your option) any later version.\n" +"\n" +msgstr "" +"Copyright © 1989, 1991-%d Free Software Foundation.\n" +"\n" +"Detta program är fri programvara. Du kan distribuera det och/eller\n" +"modifiera det under villkoren i GNU General Public License, publicerad\n" +"av Free Software Foundation, antingen version 3 eller (om du så vill)\n" +"någon senare version.\n" +"\n" + +#: main.c:815 +msgid "" +"This program is distributed in the hope that it will be useful,\n" +"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +"GNU General Public License for more details.\n" +"\n" +msgstr "" +"Detta program distribueras i hopp om att det ska vara användbart,\n" +"men UTAN NÅGON SOM HELST GARANTI, även utan underförstådd garanti\n" +"om SÄLJBARHET eller LÄMPLIGHET FÖR NÅGOT SPECIELLT ÄNDAMÅL. Se GNU\n" +"General Public License för ytterligare information.\n" +"\n" + +#: main.c:821 +msgid "" +"You should have received a copy of the GNU General Public License\n" +"along with this program. If not, see http://www.gnu.org/licenses/.\n" +msgstr "" +"Du bör ha fått en kopia av GNU General Public License tillsammans\n" +"med detta program. Om inte, se http//www.gnu.org/liceences/.\n" + +#: main.c:856 +msgid "-Ft does not set FS to tab in POSIX awk" +msgstr "-Ft sätter inte FS till tab i POSIX-awk" + +#: main.c:1090 +#, c-format +msgid "unknown value for field spec: %d\n" +msgstr "okänt värde till fältspecifikation: %d\n" + +#: main.c:1171 +#, c-format +msgid "" +"%s: `%s' argument to `-v' not in `var=value' form\n" +"\n" +msgstr "%s: Argumentet \"%s\" till \"-v\" är inte på formatet \"var=värde\"\n" + +#: main.c:1197 +#, c-format +msgid "`%s' is not a legal variable name" +msgstr "\"%s\" är inte ett giltigt variabelnamn" + +#: main.c:1200 +#, c-format +msgid "`%s' is not a variable name, looking for file `%s=%s'" +msgstr "\"%s\" är inte ett variabelnamn, letar efter filen \"%s=%s\"" + +#: main.c:1204 +#, c-format +msgid "cannot use gawk builtin `%s' as variable name" +msgstr "kan inte använda gawks inbyggda \"%s\" som ett funktionsnamn" + +#: main.c:1209 +#, c-format +msgid "cannot use function `%s' as variable name" +msgstr "kan inte använda funktionen \"%s\" som variabelnamn" + +#: main.c:1262 +msgid "floating point exception" +msgstr "flyttalsundantag" + +#: main.c:1269 +msgid "fatal error: internal error" +msgstr "ödesdigert fel: internt fel" + +#: main.c:1284 +msgid "fatal error: internal error: segfault" +msgstr "ödesdigert fel: internt fel: segmenteringsfel" + +#: main.c:1296 +msgid "fatal error: internal error: stack overflow" +msgstr "ödesdigert fel: internt fel: stackspill" + +#: main.c:1346 +#, c-format +msgid "no pre-opened fd %d" +msgstr "ingen föröppnad fd %d" + +#: main.c:1353 +#, c-format +msgid "could not pre-open /dev/null for fd %d" +msgstr "kunde inte föröppna /dev/null för fd %d" + +#: msg.c:63 +#, c-format +msgid "cmd. line:" +msgstr "kommandorad:" + +#: msg.c:107 +msgid "error: " +msgstr "fel: " + +#: node.c:406 +msgid "backslash at end of string" +msgstr "omvänt snedstreck i slutet av strängen" + +#: node.c:517 +#, c-format +msgid "old awk does not support the `\\%c' escape sequence" +msgstr "gamla awk stöder inte kontrollsekvensen \"\\%c\"" + +#: node.c:568 +msgid "POSIX does not allow `\\x' escapes" +msgstr "POSIX tillåter inte \"\\x\"-kontrollsekvenser" + +#: node.c:574 +msgid "no hex digits in `\\x' escape sequence" +msgstr "inga hexadecimala siffror i \"\\x\"-kontrollsekvenser" + +#: node.c:596 +#, c-format +msgid "" +"hex escape \\x%.*s of %d characters probably not interpreted the way you " +"expect" +msgstr "" +"hexkod \\x%.*s med %d tecken tolkas förmodligen inte på det sätt du " +"förväntar dig" + +#: node.c:611 +#, c-format +msgid "escape sequence `\\%c' treated as plain `%c'" +msgstr "kontrollsekvensen \"\\%c\" behandlad som bara \"%c\"" + +#: node.c:750 +msgid "" +"Invalid multibyte data detected. There may be a mismatch between your data " +"and your locale." +msgstr "" +"Ogiltig multibytedata upptäckt. Dina data och din lokal stämmer kanske inte " +"överens." + +#: posix/gawkmisc.c:176 +#, c-format +msgid "%s %s `%s': could not get fd flags: (fcntl F_GETFD: %s)" +msgstr "%s %s \"%s\": kunde inte hämta fb-flaggor: (fcntl F_GETFD: %s)" + +#: posix/gawkmisc.c:188 +#, c-format +msgid "%s %s `%s': could not set close-on-exec: (fcntl F_SETFD: %s)" +msgstr "%s %s \"%s\": kunde inte sätta stäng-vid-exec (fcntl F_SETFD: %s)" + +#: profile.c:83 +#, c-format +msgid "could not open `%s' for writing: %s" +msgstr "kunde inte öppna \"%s\" för skrivning: %s" + +#: profile.c:85 +msgid "sending profile to standard error" +msgstr "skickar profilen till standard fel" + +#: profile.c:203 +#, c-format +msgid "" +"\t# %s block(s)\n" +"\n" +msgstr "" +"\t# %s-block\n" +"\n" + +#: profile.c:208 +#, c-format +msgid "" +"\t# Rule(s)\n" +"\n" +msgstr "" +"\t# Regel/regler\n" +"\n" + +#: profile.c:279 +#, c-format +msgid "internal error: %s with null vname" +msgstr "internt fel: %s med null vname" + +#: profile.c:952 +#, c-format +msgid "\t# gawk profile, created %s\n" +msgstr "\t# gawkprofil, skapad %s\n" + +#: profile.c:1331 +#, c-format +msgid "" +"\n" +"\t# Functions, listed alphabetically\n" +msgstr "" +"\n" +"\t# Funktioner, listade alfabetiskt\n" + +#: profile.c:1370 +#, c-format +msgid "redir2str: unknown redirection type %d" +msgstr "redir2str: okänd omdirigeringstyp %d" + +#: re.c:573 +#, c-format +msgid "range of the form `[%c-%c]' is locale dependent" +msgstr "intervall på formen \"[%c-%c]\" är lokalberoende" + +#: re.c:600 +#, c-format +msgid "regexp component `%.*s' should probably be `[%.*s]'" +msgstr "" +"komponenten \"%.*s\" i reguljäruttryck skall förmodligen vara \"[%.*s]\"" + +#: regcomp.c:131 +msgid "Success" +msgstr "Lyckades" + +#: regcomp.c:134 +msgid "No match" +msgstr "Misslyckades" + +#: regcomp.c:137 +msgid "Invalid regular expression" +msgstr "Ogiltigt reguljärt uttryck" + +#: regcomp.c:140 +msgid "Invalid collation character" +msgstr "Ogiltigt kollationeringstecken" + +#: regcomp.c:143 +msgid "Invalid character class name" +msgstr "Ogiltigt teckenklassnamn" + +#: regcomp.c:146 +msgid "Trailing backslash" +msgstr "Eftersläpande omvänt snedstreck" + +#: regcomp.c:149 +msgid "Invalid back reference" +msgstr "Ogiltig bakåtrerefens" + +#: regcomp.c:152 +msgid "Unmatched [ or [^" +msgstr "Obalanserad [ eller [^" + +#: regcomp.c:155 +msgid "Unmatched ( or \\(" +msgstr "Obalanserad ( eller \\(" + +#: regcomp.c:158 +msgid "Unmatched \\{" +msgstr "Obalanserad \\{" + +#: regcomp.c:161 +msgid "Invalid content of \\{\\}" +msgstr "Ogiltigt innehåll i \\{\\}" + +#: regcomp.c:164 +msgid "Invalid range end" +msgstr "Ogiltigt omfångsslut" + +#: regcomp.c:167 +msgid "Memory exhausted" +msgstr "Minnet slut" + +#: regcomp.c:170 +msgid "Invalid preceding regular expression" +msgstr "Ogiltigt föregående reguljärt uttryck" + +#: regcomp.c:173 +msgid "Premature end of regular expression" +msgstr "För tidigt slut på reguljärt uttryck" + +#: regcomp.c:176 +msgid "Regular expression too big" +msgstr "Reguljärt uttryck för stort" + +#: regcomp.c:179 +msgid "Unmatched ) or \\)" +msgstr "Obalanserad ) eller \\)" + +#: regcomp.c:700 +msgid "No previous regular expression" +msgstr "Inget föregående reguljärt uttryck" + +#~ msgid "could not find groups: %s" +#~ msgstr "kunde inte hitta grupper: %s" diff --git a/posix/ChangeLog b/posix/ChangeLog new file mode 100644 index 0000000..d684afe --- /dev/null +++ b/posix/ChangeLog @@ -0,0 +1,9 @@ +2012-03-28 Arnold D. Robbins + + * 4.0.1: Release tar ball made. + +2011-06-23 Arnold D. Robbins + + * ChangeLog.0: Rotated ChangeLog into this file. + * ChangeLog: Created anew for gawk 4.0.0 and on. + * 4.0.0: Release tar ball made. diff --git a/posix/ChangeLog.0 b/posix/ChangeLog.0 new file mode 100644 index 0000000..eae49b3 --- /dev/null +++ b/posix/ChangeLog.0 @@ -0,0 +1,174 @@ +Mon Jun 20 20:19:03 2011 Corinna Vinschen + + * gawkmisc.c: Add include of for Cygwin to + remove a compiler warning. + +Mon May 2 23:38:06 2011 Corinna Vinschen + + * gawkmisc.c (cygwin_premain0): Use the real type for the secondnd + argument. + +Fri Apr 1 11:50:59 2011 Arnold D. Robbins + + * gawkmisc.c (os_iastty): New function. + +Sun Feb 13 20:23:34 2011 Eli Zaretskii + + * gawkmisc.c (files_are_same): Change arguments; call `stat' as + part of the body. + +Tue Feb 1 23:05:51 2011 Corinna Vinschen + + Make values of ctype macros into unsigned char to fix + warnings found on Cygwin / Newlib. + + * gawkmisc.c (optimal_bufsize): Add cast. + +Mon Jan 24 22:21:08 2011 Arnold D. Robbins + + Everything: Move to ANSI headers on the function definitions. + +Mon Jan 24 22:20:43 2011 Corinna Vinschen + + * gawkmisc.c: Update CYGWIN code. + +Wed Nov 24 17:26:24 2010 Arnold D. Robbins + + * gawkmisc.c (os_close_on_exec): After discussion on the Bash + list, change the routine to follow POSIX and use read/modify/write + on the flags value. + +Thu May 6 20:55:14 2010 Arnold D. Robbins + + * Release 3.1.8: Release tar file made. + +Tue Apr 13 22:38:01 2010 Arnold D. Robbins + + * gawkmisc.c: Remove use of ISxxx in favor of standard names. + +Tue Jul 21 22:28:56 2009 Arnold D. Robbins + + * Release 3.1.7: Release tar file made. + +Mon Oct 22 08:49:05 2007 Arnold D. Robbins + + * Release 3.1.6: Release tar file made. + +Sun Apr 2 21:43:02 2006 Corinna Vinschen + + * gawkmisc.c (os_setbinmode): Call `setmode' for Cygwin. + (cygwin_premain0, cygwin_premain2): Change type of `myself' + parameter to `void *'. + +Sun Mar 12 22:45:11 2006 Corinna Vinschen + + * gawkmisc.c (cygwin_premain2): New function. + Fixes CR-LF problem with already open stdin. + +Tue Jul 26 21:46:16 2005 Arnold D. Robbins + + * Release 3.1.5: Release tar file made. + +Mon Aug 2 12:18:15 2004 Arnold D. Robbins + + * Release 3.1.4: Release tar file made. + +Mon Jul 7 11:01:43 2003 Arnold D. Robbins + + * Release 3.1.3: Release tar file made. + +Sun May 25 16:23:43 2003 Corinna Vinschen + + * gawkmisc.c (cygwin_premain0): New function. + +Wed Mar 19 14:10:31 2003 Arnold D. Robbins + + This time for sure. + -- Bullwinkle + + * Release 3.1.2: Release tar file made. + +Tue Feb 4 14:28:06 2003 Arnold D. Robbins + + All relevant files: Copyright year updated to 2003. + +Tue Dec 17 11:05:11 2002 Arnold D. Robbins + + * gawkmisc.c (optimal_bufsize): Stat the file first, so that + stb is always valid for higher level code. + +Thu Nov 28 10:20:05 2002 Arnold D. Robbins + + * gawkmisc.c (optimal_bufsize): Enhance to use AWKBUFSIZE + environment variable for debugging. + +Tue Jun 11 22:18:42 2002 Stepan Kasal + + * gawkmisc.c (DEFBLKSIZE): Add check for st_blksize > 0, + fixes weird bug on some versions of HP-UX. + +Wed May 1 16:41:32 2002 Arnold D. Robbins + + * Release 3.1.1: Release tar file made. + +Tue Sep 25 15:19:53 2001 Arnold D. Robbins + + * gawkmisc.c (os_close_on_exec): If fd <= 2, return. + +Sun Jun 3 13:04:44 2001 Arnold D. Robbins + + * Release 3.1.0: Release tar file made. And there was + rejoicing. + +Sun Jan 28 15:50:02 2001 Eli Zaretskii + + * gawkmisc.c (os_restore_mode): New function. + +Sun Dec 3 16:53:37 2000 Arnold D. Robbins + + * gawkmisc.c (os_setbinmode): New function. + +Tue Nov 14 16:13:08 2000 Arnold D. Robbins + + * gawkmisc.c: Remove all includes. Done by ../gawkmisc.c. + +Tue Nov 7 14:09:14 2000 Arnold D. Robbins + + * gawkmisc.c (os_is_setuid): new function. + +Mon Aug 7 15:23:00 2000 Arnold D. Robbins + + * Release 3.0.6: Release tar file made. + +Sun Jun 25 15:08:19 2000 Arnold D. Robbins + + * Release 3.0.5: Release tar file made. + +Wed Jun 30 16:14:36 1999 Arnold D. Robbins + + * Release 3.0.4: Release tar file made. This time for sure. + +Wed Jul 30 19:53:52 1997 Arnold D. Robbins + + * Close-on-exec changes: + gawkmisc.c: (os_close_on_exec, os_isdir): new functions. + +Thu May 15 12:49:08 1997 Arnold D. Robbins + + * Release 3.0.3: Release tar file made. + +Fri Apr 18 07:55:47 1997 Arnold D. Robbins + + * BETA Release 3.0.34: Release tar file made. + +Wed Dec 25 11:25:22 1996 Arnold D. Robbins + + * Release 3.0.2: Release tar file made. + +Tue Dec 10 23:09:26 1996 Arnold D. Robbins + + * Release 3.0.1: Release tar file made. + +Wed Jan 10 22:58:55 1996 Arnold D. Robbins + + * ChangeLog created. diff --git a/posix/gawkmisc.c b/posix/gawkmisc.c new file mode 100644 index 0000000..acc3c9d --- /dev/null +++ b/posix/gawkmisc.c @@ -0,0 +1,276 @@ +/* gawkmisc.c --- miscellaneous gawk routines that are OS specific. + + Copyright (C) 1986, 1988, 1989, 1991 - 1998, 2001 - 2004, 2011 + the Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifdef __CYGWIN__ +#include +#include +#include +#include +#endif + +char quote = '\''; +char *defpath = DEFPATH; +char envsep = ':'; + +#ifndef INVALID_HANDLE +/* FIXME: is this value for INVALID_HANDLE correct? */ +#define INVALID_HANDLE -1 +#endif + +/* gawk_name --- pull out the "gawk" part from how the OS called us */ + +char * +gawk_name(const char *filespec) +{ + char *p; + + /* "path/name" -> "name" */ + p = strrchr(filespec, '/'); + return (p == NULL ? (char *) filespec : p + 1); +} + +/* os_arg_fixup --- fixup the command line */ + +void +os_arg_fixup(int *argcp, char ***argvp) +{ + /* no-op */ + return; +} + +/* os_devopen --- open special per-OS devices */ + +int +os_devopen(const char *name, int flag) +{ + /* no-op */ + return INVALID_HANDLE; +} + +/* optimal_bufsize --- determine optimal buffer size */ + +/* + * Enhance this for debugging purposes, as follows: + * + * Always stat the file, stat buffer is used by higher-level code. + * + * if (AWKBUFSIZE == "exact") + * return the file size + * else if (AWKBUFSIZE == a number) + * always return that number + * else + * if the size is < default_blocksize + * return the size + * else + * return default_blocksize + * end if + * endif + * + * Hair comes in an effort to only deal with AWKBUFSIZE + * once, the first time this routine is called, instead of + * every time. Performance, dontyaknow. + */ + +size_t +optimal_bufsize(int fd, struct stat *stb) +{ + char *val; + static size_t env_val = 0; + static short first = TRUE; + static short exact = FALSE; + + /* force all members to zero in case OS doesn't use all of them. */ + memset(stb, '\0', sizeof(struct stat)); + + /* always stat, in case stb is used by higher level code. */ + if (fstat(fd, stb) == -1) + fatal("can't stat fd %d (%s)", fd, strerror(errno)); + + if (first) { + first = FALSE; + + if ((val = getenv("AWKBUFSIZE")) != NULL) { + if (strcmp(val, "exact") == 0) + exact = TRUE; + else if (isdigit((unsigned char) *val)) { + for (; *val && isdigit((unsigned char) *val); val++) + env_val = (env_val * 10) + *val - '0'; + + return env_val; + } + } + } else if (! exact && env_val > 0) + return env_val; + /* else + fall through */ + + /* + * System V.n, n < 4, doesn't have the file system block size in the + * stat structure. So we have to make some sort of reasonable + * guess. We use stdio's BUFSIZ, since that is what it was + * meant for in the first place. + */ +#ifdef HAVE_ST_BLKSIZE +#define DEFBLKSIZE (stb->st_blksize > 0 ? stb->st_blksize : BUFSIZ) +#else +#define DEFBLKSIZE BUFSIZ +#endif + + if (S_ISREG(stb->st_mode) /* regular file */ + && 0 < stb->st_size /* non-zero size */ + && (stb->st_size < DEFBLKSIZE /* small file */ + || exact)) /* or debugging */ + return stb->st_size; /* use file size */ + + return DEFBLKSIZE; +} + +/* ispath --- return true if path has directory components */ + +int +ispath(const char *file) +{ + return (strchr(file, '/') != NULL); +} + +/* isdirpunct --- return true if char is a directory separator */ + +int +isdirpunct(int c) +{ + return (c == '/'); +} + +/* os_close_on_exec --- set close on exec flag, print warning if fails */ + +void +os_close_on_exec(int fd, const char *name, const char *what, const char *dir) +{ + int curflags = 0; + + if (fd <= 2) /* sanity */ + return; + + /* + * Per POSIX, use Read/Modify/Write - get the flags, + * add FD_CLOEXEC, set the flags back. + */ + + if ((curflags = fcntl(fd, F_GETFD)) < 0) { + warning(_("%s %s `%s': could not get fd flags: (fcntl F_GETFD: %s)"), + what, dir, name, strerror(errno)); + return; + } + +#ifndef FD_CLOEXEC +#define FD_CLOEXEC 1 +#endif + + curflags |= FD_CLOEXEC; + + if (fcntl(fd, F_SETFD, curflags) < 0) + warning(_("%s %s `%s': could not set close-on-exec: (fcntl F_SETFD: %s)"), + what, dir, name, strerror(errno)); +} + +/* os_isdir --- is this an fd on a directory? */ + +#if ! defined(S_ISDIR) && defined(S_IFDIR) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif + +int +os_isdir(int fd) +{ + struct stat sbuf; + + return (fstat(fd, &sbuf) == 0 && S_ISDIR(sbuf.st_mode)); +} + +/* os_is_setuid --- true if running setuid root */ + +int +os_is_setuid() +{ + long uid, euid; + + uid = getuid(); + euid = geteuid(); + + return (euid == 0 && euid != uid); +} + +/* os_setbinmode --- set binary mode on file */ + +int +os_setbinmode(int fd, int mode) +{ +#ifdef __CYGWIN__ + setmode (fd, mode); +#endif + return 0; +} + +/* os_restore_mode --- restore the original mode of the console device */ + +void +os_restore_mode(int fd) +{ + /* no-op */ + return; +} + +/* os_isatty --- return true if fd is a tty */ + +int +os_isatty(int fd) +{ + return isatty(fd); +} + +/* files_are_same --- return true if files are identical */ + +int +files_are_same(char *path, SRCFILE *src) +{ + struct stat st; + + return (stat(path, & st) == 0 + && st.st_dev == src->sbuf.st_dev + && st.st_ino == src->sbuf.st_ino); +} + +#ifdef __CYGWIN__ +void +cygwin_premain0(int argc, char **argv, struct per_process *myself) +{ + static struct __cygwin_perfile pf[] = { + { "", O_RDONLY | O_TEXT }, + /*{ "", O_WRONLY | O_BINARY },*/ + { NULL, 0 } + }; + cygwin_internal(CW_PERFILE, pf); +} + +void +cygwin_premain2(int argc, char **argv, struct per_process *myself) +{ + setmode(fileno (stdin), O_TEXT); +} +#endif diff --git a/profile.c b/profile.c new file mode 100644 index 0000000..eb78837 --- /dev/null +++ b/profile.c @@ -0,0 +1,1374 @@ +/* + * profile.c - gawk bytecode pretty-printer with counts + */ + +/* + * Copyright (C) 1999-2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "awk.h" + +static void pprint(INSTRUCTION *startp, INSTRUCTION *endp, int in_for_header); +static void pp_parenthesize(NODE *n); +static void parenthesize(int type, NODE *left, NODE *right); +static char *pp_list(int nargs, const char *paren, const char *delim); +static char *pp_concat(const char *s1, const char *s2, const char *s3); +static int is_binary(int type); +static int prec_level(int type); +static void pp_push(int type, char *s, int flag); +static NODE *pp_pop(void); +static void pp_free(NODE *n); +const char *redir2str(int redirtype); + +#define pp_str hname +#define pp_len hlength + +#define DONT_FREE 1 +#define CAN_FREE 2 + +#ifdef PROFILING +static RETSIGTYPE dump_and_exit(int signum) ATTRIBUTE_NORETURN; +static RETSIGTYPE just_dump(int signum); +#endif + +/* pretty printing related functions and variables */ + +static NODE *pp_stack = NULL; +static char **fparms; /* function parameter names */ +static FILE *prof_fp; /* where to send the profile */ + +static long indent_level = 0; + + +#define SPACEOVER 0 + +/* init_profiling --- do needed initializations, see also main.c */ + +void +init_profiling(int *flag ATTRIBUTE_UNUSED, const char *def_file ATTRIBUTE_UNUSED) +{ +#ifdef PROFILING + if (*flag == FALSE) { + *flag = TRUE; + set_prof_file(def_file); + } +#endif +} + +/* set_prof_file --- set the output file for profiling */ + +void +set_prof_file(const char *file) +{ + assert(file != NULL); + prof_fp = fopen(file, "w"); + if (prof_fp == NULL) { + warning(_("could not open `%s' for writing: %s"), + file, strerror(errno)); + warning(_("sending profile to standard error")); + prof_fp = stderr; + } +} + +/* init_profiling_signals --- set up signal handling for pgawk */ + +void +init_profiling_signals() +{ +#ifdef PROFILING +#ifdef __DJGPP__ + signal(SIGINT, dump_and_exit); + signal(SIGQUIT, just_dump); +#else /* !__DJGPP__ */ +#ifdef SIGHUP + signal(SIGHUP, dump_and_exit); +#endif +#ifdef SIGUSR1 + signal(SIGUSR1, just_dump); +#endif +#endif /* !__DJGPP__ */ +#endif /* PROFILING */ +} + +/* indent --- print out enough tabs */ + +static void +indent(long count) +{ + int i; + + if (count == 0) + fprintf(prof_fp, "\t"); + else + fprintf(prof_fp, "%6ld ", count); + + assert(indent_level >= 0); + for (i = 0; i < indent_level; i++) + fprintf(prof_fp, "\t"); +} + +/* indent_in --- increase the level, with error checking */ + +static void +indent_in(void) +{ + assert(indent_level >= 0); + indent_level++; +} + +/* indent_out --- decrease the level, with error checking */ + +static void +indent_out(void) +{ + indent_level--; + assert(indent_level >= 0); +} + +static void +pp_push(int type, char *s, int flag) +{ + NODE *n; + getnode(n); + n->pp_str = s; + n->pp_len = strlen(s); + n->flags = flag; + n->type = type; + n->hnext = pp_stack; + pp_stack = n; +} + +static NODE * +pp_pop() +{ + NODE *n; + n = pp_stack; + pp_stack = n->hnext; + return n; +} + +static void +pp_free(NODE *n) +{ + if ((n->flags & CAN_FREE) != 0) + efree(n->pp_str); + freenode(n); +} + +/* + * pprint --- pretty print a program segment + */ + +static void +pprint(INSTRUCTION *startp, INSTRUCTION *endp, int in_for_header) +{ + INSTRUCTION *pc; + NODE *t1; + char *str; + NODE *t2; + INSTRUCTION *ip; + NODE *m; + char *tmp; + int rule; + static int rule_count[MAXRULE]; + + for (pc = startp; pc != endp; pc = pc->nexti) { + if (pc->source_line > 0) + sourceline = pc->source_line; + + switch (pc->opcode) { + case Op_rule: + source = pc->source_file; + rule = pc->in_rule; + + if (rule != Rule) { + if (! rule_count[rule]++) + fprintf(prof_fp, _("\t# %s block(s)\n\n"), ruletab[rule]); + fprintf(prof_fp, "\t%s {\n", ruletab[rule]); + ip = (pc + 1)->firsti; + } else { + if (! rule_count[rule]++) + fprintf(prof_fp, _("\t# Rule(s)\n\n")); + ip = pc->nexti; + indent(ip->exec_count); + if (ip != (pc + 1)->firsti) { /* non-empty pattern */ + pprint(ip->nexti, (pc + 1)->firsti, FALSE); + t1 = pp_pop(); + fprintf(prof_fp, "%s {", t1->pp_str); + pp_free(t1); + ip = (pc + 1)->firsti; +#ifdef PROFILING + if (ip->exec_count > 0) + fprintf(prof_fp, " # %ld", ip->exec_count); +#endif + fprintf(prof_fp, "\n"); + } else { + fprintf(prof_fp, "{\n"); + ip = (pc + 1)->firsti; + } + ip = ip->nexti; + } + indent_in(); + pprint(ip, (pc + 1)->lasti, FALSE); + indent_out(); + fprintf(prof_fp, "\t}\n\n"); + pc = (pc + 1)->lasti; + break; + + case Op_atexit: + break; + + case Op_stop: + memset(rule_count, 0, MAXRULE * sizeof(int)); + break; + + case Op_push_i: + m = pc->memory; + if (m == Nnull_string) /* optional return or exit value; don't print 0 or "" */ + pp_push(pc->opcode, m->stptr, DONT_FREE); + else if ((m->flags & NUMBER) != 0) + pp_push(pc->opcode, pp_number(m->numbr), CAN_FREE); + else { + str = pp_string(m->stptr, m->stlen, '"'); + if ((m->flags & INTLSTR) != 0) { + char *tmp = str; + str = pp_concat("_", tmp, ""); + efree(tmp); + } + pp_push(pc->opcode, str, CAN_FREE); + } + break; + + case Op_store_var: + case Op_store_sub: + case Op_assign_concat: + case Op_push_lhs: + case Op_push_param: + case Op_push_array: + case Op_push: + case Op_push_arg: + m = pc->memory; + switch (m->type) { + case Node_param_list: + pp_push(pc->opcode, fparms[m->param_cnt], DONT_FREE); + break; + + case Node_var: + case Node_var_new: + case Node_var_array: + if (m->vname != NULL) + pp_push(pc->opcode, m->vname, DONT_FREE); + else + fatal(_("internal error: %s with null vname"), + nodetype2str(m->type)); + break; + + default: + cant_happen(); + } + + switch (pc->opcode) { + case Op_store_var: + t2 = pp_pop(); /* l.h.s. */ + t1 = pp_pop(); /* r.h.s. */ + fprintf(prof_fp, "%s%s%s", t2->pp_str, op2str(pc->opcode), t1->pp_str); + goto cleanup; + + case Op_store_sub: + t1 = pp_pop(); /* array */ + tmp = pp_list(pc->expr_count, op2str(Op_subscript), ", "); /*subscript*/ + t2 = pp_pop(); /* r.h.s. */ + fprintf(prof_fp, "%s%s%s%s", t1->pp_str, tmp, + op2str(pc->opcode), t2->pp_str); + efree(tmp); + goto cleanup; + + case Op_assign_concat: + t2 = pp_pop(); /* l.h.s. */ + t1 = pp_pop(); + tmp = pp_concat(t2->pp_str, op2str(Op_concat), t1->pp_str); + fprintf(prof_fp, "%s%s%s", t2->pp_str, op2str(Op_assign), tmp); + efree(tmp); +cleanup: + pp_free(t2); + pp_free(t1); + if (! in_for_header) + fprintf(prof_fp, "\n"); + break; + + default: + break; + } + break; + + case Op_sub_array: + case Op_subscript_lhs: + case Op_subscript: + tmp = pp_list(pc->sub_count, op2str(pc->opcode), ", "); + t1 = pp_pop(); + str = pp_concat(t1->pp_str, tmp, ""); + efree(tmp); + pp_free(t1); + pp_push(pc->opcode, str, CAN_FREE); + break; + + case Op_and: + case Op_or: + pprint(pc->nexti, pc->target_jmp, in_for_header); + t2 = pp_pop(); + t1 = pp_pop(); + parenthesize(pc->opcode, t1, t2); + str = pp_concat(t1->pp_str, op2str(pc->opcode), t2->pp_str); + pp_free(t1); + pp_free(t2); + pp_push(pc->opcode, str, CAN_FREE); + pc = pc->target_jmp; + break; + + case Op_plus_i: + case Op_minus_i: + case Op_times_i: + case Op_exp_i: + case Op_quotient_i: + case Op_mod_i: + m = pc->memory; + t1 = pp_pop(); + if (prec_level(pc->opcode) > prec_level(t1->type) + && is_binary(t1->type)) /* (a - b) * 1 */ + pp_parenthesize(t1); + if ((m->flags & NUMBER) != 0) + tmp = pp_number(m->numbr); + else + tmp = pp_string(m->stptr, m->stlen, '"'); + str = pp_concat(t1->pp_str, op2str(pc->opcode), tmp); + efree(tmp); + pp_free(t1); + pp_push(pc->opcode, str, CAN_FREE); + break; + + case Op_plus: + case Op_minus: + case Op_times: + case Op_exp: + case Op_quotient: + case Op_mod: + case Op_equal: + case Op_notequal: + case Op_less: + case Op_greater: + case Op_leq: + case Op_geq: + t2 = pp_pop(); + t1 = pp_pop(); + parenthesize(pc->opcode, t1, t2); + str = pp_concat(t1->pp_str, op2str(pc->opcode), t2->pp_str); + pp_free(t1); + pp_free(t2); + pp_push(pc->opcode, str, CAN_FREE); + break; + + case Op_preincrement: + case Op_predecrement: + case Op_postincrement: + case Op_postdecrement: + t1 = pp_pop(); + if (pc->opcode == Op_preincrement || pc->opcode == Op_predecrement) + str = pp_concat(op2str(pc->opcode), t1->pp_str, ""); + else + str = pp_concat(t1->pp_str, op2str(pc->opcode), ""); + pp_free(t1); + pp_push(pc->opcode, str, CAN_FREE); + break; + + case Op_field_spec: + case Op_field_spec_lhs: + case Op_unary_minus: + case Op_not: + t1 = pp_pop(); + if (is_binary(t1->type)) + pp_parenthesize(t1); + + /* optypes table (eval.c) includes space after ! */ + str = pp_concat(op2str(pc->opcode), t1->pp_str, ""); + pp_free(t1); + pp_push(pc->opcode, str, CAN_FREE); + break; + + case Op_assign: + case Op_assign_plus: + case Op_assign_minus: + case Op_assign_times: + case Op_assign_quotient: + case Op_assign_mod: + case Op_assign_exp: + t2 = pp_pop(); /* l.h.s. */ + t1 = pp_pop(); + str = pp_concat(t2->pp_str, op2str(pc->opcode), t1->pp_str); + pp_free(t2); + pp_free(t1); + pp_push(pc->opcode, str, CAN_FREE); + break; + + case Op_store_field: + t1 = pp_pop(); /* field num */ + if (is_binary(t1->type)) + pp_parenthesize(t1); + t2 = pp_pop(); /* r.h.s. */ + fprintf(prof_fp, "$%s%s%s", t1->pp_str, op2str(pc->opcode), t2->pp_str); + pp_free(t2); + pp_free(t1); + if (! in_for_header) + fprintf(prof_fp, "\n"); + break; + + case Op_concat: + str = pp_list(pc->expr_count, NULL, + (pc->concat_flag & CSUBSEP) ? ", " : op2str(Op_concat)); + pp_push(Op_concat, str, CAN_FREE); + break; + + case Op_K_delete: + { + char *array; + t1 = pp_pop(); + array = t1->pp_str; + if (pc->expr_count > 0) { + char *sub; + sub = pp_list(pc->expr_count, NULL, ", "); + fprintf(prof_fp, "%s %s[%s]", op2str(Op_K_delete), array, sub); + efree(sub); + } else + fprintf(prof_fp, "%s %s", op2str(Op_K_delete), array); + if (! in_for_header) + fprintf(prof_fp, "\n"); + pp_free(t1); + } + break; + + case Op_K_delete_loop: + /* Efficency hack not in effect because of exec_count instruction */ + cant_happen(); + break; + + case Op_in_array: + { + char *array, *sub; + t1 = pp_pop(); + array = t1->pp_str; + if (pc->expr_count > 1) { + sub = pp_list(pc->expr_count, "()", ", "); + str = pp_concat(sub, op2str(Op_in_array), array); + efree(sub); + } else { + t2 = pp_pop(); + sub = t2->pp_str; + str = pp_concat(sub, op2str(Op_in_array), array); + pp_free(t2); + } + pp_free(t1); + pp_push(Op_in_array, str, CAN_FREE); + } + break; + + case Op_var_update: + case Op_var_assign: + case Op_field_assign: + case Op_arrayfor_init: + case Op_arrayfor_incr: + case Op_arrayfor_final: + case Op_newfile: + case Op_get_record: + case Op_lint: + case Op_jmp: + case Op_jmp_false: + case Op_jmp_true: + case Op_no_op: + case Op_and_final: + case Op_or_final: + case Op_cond_pair: + case Op_after_beginfile: + case Op_after_endfile: + break; + + case Op_sub_builtin: + { + const char *fname = "sub"; + if (pc->sub_flags & GSUB) + fname = "gsub"; + else if (pc->sub_flags & GENSUB) + fname = "gensub"; + tmp = pp_list(pc->expr_count, "()", ", "); + str = pp_concat(fname, tmp, ""); + efree(tmp); + pp_push(Op_sub_builtin, str, CAN_FREE); + } + break; + + case Op_builtin: + { + static char *ext_func = "extension_function()"; + const char *fname = getfname(pc->builtin); + if (fname != NULL) { + if (pc->expr_count > 0) { + tmp = pp_list(pc->expr_count, "()", ", "); + str = pp_concat(fname, tmp, ""); + efree(tmp); + } else + str = pp_concat(fname, "()", ""); + pp_push(Op_builtin, str, CAN_FREE); + } else + pp_push(Op_builtin, ext_func, DONT_FREE); + } + break; + + case Op_K_print: + case Op_K_printf: + case Op_K_print_rec: + if (pc->opcode == Op_K_print_rec) + tmp = pp_concat(" ", op2str(Op_field_spec), "0"); + else if (pc->redir_type != 0) + tmp = pp_list(pc->expr_count, "()", ", "); + else { + tmp = pp_list(pc->expr_count, " ", ", "); + tmp[strlen(tmp) - 1] = '\0'; /* remove trailing space */ + } + + if (pc->redir_type != 0) { + t1 = pp_pop(); + if (is_binary(t1->type)) + pp_parenthesize(t1); + fprintf(prof_fp, "%s%s%s%s", op2str(pc->opcode), + tmp, redir2str(pc->redir_type), t1->pp_str); + pp_free(t1); + } else + fprintf(prof_fp, "%s%s", op2str(pc->opcode), tmp); + efree(tmp); + if (! in_for_header) + fprintf(prof_fp, "\n"); + break; + + case Op_push_re: + if (pc->memory->type != Node_regex) + break; + /* else + fall through */ + case Op_match_rec: + { + NODE *re = pc->memory->re_exp; + str = pp_string(re->stptr, re->stlen, '/'); + pp_push(pc->opcode, str, CAN_FREE); + } + break; + + case Op_nomatch: + case Op_match: + { + char *restr, *txt; + t1 = pp_pop(); + if (is_binary(t1->type)) + pp_parenthesize(t1); + txt = t1->pp_str; + m = pc->memory; + if (m->type == Node_dynregex) { + restr = txt; + t2 = pp_pop(); + if (is_binary(t2->type)) + pp_parenthesize(t2); + txt = t2->pp_str; + str = pp_concat(txt, op2str(pc->opcode), restr); + pp_free(t2); + } else { + NODE *re = m->re_exp; + restr = pp_string(re->stptr, re->stlen, '/'); + str = pp_concat(txt, op2str(pc->opcode), restr); + efree(restr); + } + pp_free(t1); + pp_push(pc->opcode, str, CAN_FREE); + } + break; + + case Op_K_getline: + case Op_K_getline_redir: + if (pc->into_var) { + t1 = pp_pop(); + tmp = pp_concat(op2str(Op_K_getline), " ", t1->pp_str); + pp_free(t1); + } else + tmp = pp_concat(op2str(Op_K_getline), "", ""); + + if (pc->redir_type != 0) { + int before = (pc->redir_type == redirect_pipein + || pc->redir_type == redirect_twoway); + + t2 = pp_pop(); + if (is_binary(t2->type)) + pp_parenthesize(t2); + if (before) + str = pp_concat(t2->pp_str, redir2str(pc->redir_type), tmp); + else + str = pp_concat(tmp, redir2str(pc->redir_type), t2->pp_str); + efree(tmp); + pp_free(t2); + } else + str = tmp; + pp_push(pc->opcode, str, CAN_FREE); + break; + + case Op_indirect_func_call: + case Op_func_call: + { + char *fname = pc->func_name; + char *pre; + int pcount; + + if (pc->opcode == Op_indirect_func_call) + pre = "@"; + else + pre = ""; + pcount = (pc + 1)->expr_count; + if (pcount > 0) { + tmp = pp_list(pcount, "()", ", "); + str = pp_concat(pre, fname, tmp); + efree(tmp); + } else + str = pp_concat(pre, fname, "()"); + if (pc->opcode == Op_indirect_func_call) { + t1 = pp_pop(); /* indirect var */ + pp_free(t1); + } + pp_push(pc->opcode, str, CAN_FREE); + } + break; + + case Op_K_continue: + case Op_K_break: + case Op_K_nextfile: + case Op_K_next: + fprintf(prof_fp, "%s\n", op2str(pc->opcode)); + break; + + case Op_K_return: + case Op_K_exit: + t1 = pp_pop(); + if (is_binary(t1->type)) + pp_parenthesize(t1); + if (pc->source_line > 0) /* don't print implicit 'return' at end of function */ + fprintf(prof_fp, "%s %s\n", op2str(pc->opcode), t1->pp_str); + pp_free(t1); + break; + + case Op_pop: + t1 = pp_pop(); + fprintf(prof_fp, "%s", t1->pp_str); + if (! in_for_header) + fprintf(prof_fp, "\n"); + pp_free(t1); + break; + + case Op_line_range: + ip = pc + 1; + pprint(pc->nexti, ip->condpair_left, FALSE); + pprint(ip->condpair_left->nexti, ip->condpair_right, FALSE); + t2 = pp_pop(); + t1 = pp_pop(); + str = pp_concat(t1->pp_str, ", ", t2->pp_str); + pp_free(t1); + pp_free(t2); + pp_push(Op_line_range, str, CAN_FREE); + pc = ip->condpair_right; + break; + + case Op_K_while: + ip = pc + 1; + indent(ip->while_body->exec_count); + fprintf(prof_fp, "%s (", op2str(pc->opcode)); + pprint(pc->nexti, ip->while_body, FALSE); + t1 = pp_pop(); + fprintf(prof_fp, "%s) {\n", t1->pp_str); + pp_free(t1); + indent_in(); + pprint(ip->while_body->nexti, pc->target_break, FALSE); + indent_out(); + indent(SPACEOVER); + fprintf(prof_fp, "}\n"); + pc = pc->target_break; + break; + + case Op_K_do: + ip = pc + 1; + indent(pc->nexti->exec_count); + fprintf(prof_fp, "%s {\n", op2str(pc->opcode)); + indent_in(); + pprint(pc->nexti->nexti, ip->doloop_cond, FALSE); + indent_out(); + pprint(ip->doloop_cond, pc->target_break, FALSE); + indent(SPACEOVER); + t1 = pp_pop(); + fprintf(prof_fp, "} %s (%s)\n", op2str(Op_K_while), t1->pp_str); + pp_free(t1); + pc = pc->target_break; + break; + + case Op_K_for: + ip = pc + 1; + indent(ip->forloop_body->exec_count); + fprintf(prof_fp, "%s (", op2str(pc->opcode)); + pprint(pc->nexti, ip->forloop_cond, TRUE); + fprintf(prof_fp, "; "); + + if (ip->forloop_cond->opcode == Op_no_op && + ip->forloop_cond->nexti == ip->forloop_body) + fprintf(prof_fp, "; "); + else { + pprint(ip->forloop_cond, ip->forloop_body, TRUE); + t1 = pp_pop(); + fprintf(prof_fp, "%s; ", t1->pp_str); + pp_free(t1); + } + + pprint(pc->target_continue, pc->target_break, TRUE); + fprintf(prof_fp, ") {\n"); + indent_in(); + pprint(ip->forloop_body->nexti, pc->target_continue, FALSE); + indent_out(); + indent(SPACEOVER); + fprintf(prof_fp, "}\n"); + pc = pc->target_break; + break; + + case Op_K_arrayfor: + { + char *array, *item; + + ip = pc + 1; + t1 = pp_pop(); + array = t1->pp_str; + m = ip->forloop_cond->array_var; + if (m->type == Node_param_list) + item = fparms[m->param_cnt]; + else + item = m->vname; + indent(ip->forloop_body->exec_count); + fprintf(prof_fp, "%s (%s%s%s) {\n", op2str(Op_K_arrayfor), + item, op2str(Op_in_array), array); + indent_in(); + pp_free(t1); + pprint(ip->forloop_body->nexti, pc->target_break, FALSE); + indent_out(); + indent(SPACEOVER); + fprintf(prof_fp, "}\n"); + pc = pc->target_break; + } + break; + + case Op_K_switch: + ip = pc + 1; + fprintf(prof_fp, "%s (", op2str(pc->opcode)); + pprint(pc->nexti, ip->switch_start, FALSE); + t1 = pp_pop(); + fprintf(prof_fp, "%s) {\n", t1->pp_str); + pp_free(t1); + pprint(ip->switch_start, ip->switch_end, FALSE); + indent(SPACEOVER); + fprintf(prof_fp, "}\n"); + pc = pc->target_break; + break; + + case Op_K_case: + case Op_K_default: + indent(pc->stmt_start->exec_count); + if (pc->opcode == Op_K_case) { + t1 = pp_pop(); + fprintf(prof_fp, "%s %s:\n", op2str(pc->opcode), t1->pp_str); + pp_free(t1); + } else + fprintf(prof_fp, "%s:\n", op2str(pc->opcode)); + indent_in(); + pprint(pc->stmt_start->nexti, pc->stmt_end->nexti, FALSE); + indent_out(); + break; + + case Op_K_if: + fprintf(prof_fp, "%s (", op2str(pc->opcode)); + pprint(pc->nexti, pc->branch_if, FALSE); + t1 = pp_pop(); + fprintf(prof_fp, "%s) {", t1->pp_str); + pp_free(t1); + + ip = pc->branch_if; + if (ip->exec_count > 0) + fprintf(prof_fp, " # %ld", ip->exec_count); + fprintf(prof_fp, "\n"); + indent_in(); + pprint(ip->nexti, pc->branch_else, FALSE); + indent_out(); + pc = pc->branch_else; + if (pc->nexti->opcode == Op_no_op) { + indent(SPACEOVER); + fprintf(prof_fp, "}\n"); + } + break; + + case Op_K_else: + fprintf(prof_fp, "} %s {\n", op2str(pc->opcode)); + indent_in(); + pprint(pc->nexti, pc->branch_end, FALSE); + indent_out(); + indent(SPACEOVER); + fprintf(prof_fp, "}\n"); + pc = pc->branch_end; + break; + + case Op_cond_exp: + { + NODE *f, *t, *cond; + size_t len; + + pprint(pc->nexti, pc->branch_if, FALSE); + ip = pc->branch_if; + pprint(ip->nexti, pc->branch_else, FALSE); + ip = pc->branch_else->nexti; + + pc = ip->nexti; + assert(pc->opcode == Op_cond_exp); + pprint(pc->nexti, pc->branch_end, FALSE); + + f = pp_pop(); + t = pp_pop(); + cond = pp_pop(); + + len = f->pp_len + t->pp_len + cond->pp_len + 12; + emalloc(str, char *, len, "pprint"); + sprintf(str, "(%s ? %s : %s)", cond->pp_str, t->pp_str, f->pp_str); + + pp_free(cond); + pp_free(t); + pp_free(f); + pp_push(Op_cond_exp, str, CAN_FREE); + pc = pc->branch_end; + } + break; + + case Op_exec_count: + if (! in_for_header) + indent(pc->exec_count); + break; + + default: + cant_happen(); + } + + if (pc == endp) + break; + } +} + +/* pp_string_fp --- printy print a string to the fp */ + +/* + * This routine concentrates string pretty printing in one place, + * so that it can be called from multiple places within gawk. + */ + +void +pp_string_fp(Func_print print_func, FILE *fp, const char *in_str, + size_t len, int delim, int breaklines) +{ + char *s = pp_string(in_str, len, delim); + int count; + size_t slen; + const char *str = (const char *) s; +#define BREAKPOINT 70 /* arbitrary */ + + slen = strlen(str); + for (count = 0; slen > 0; slen--, str++) { + if (++count >= BREAKPOINT && breaklines) { + print_func(fp, "%c\n%c", delim, delim); + count = 0; + } else + print_func(fp, "%c", *str); + } + efree(s); +} + +#ifdef PROFILING +/* just_dump --- dump the profile and function stack and keep going */ + +static RETSIGTYPE +just_dump(int signum) +{ + extern INSTRUCTION *code_block; + + dump_prog(code_block); + dump_funcs(); + dump_fcall_stack(prof_fp); + fflush(prof_fp); + signal(signum, just_dump); /* for OLD Unix systems ... */ +} + +/* dump_and_exit --- dump the profile, the function stack, and exit */ + +static RETSIGTYPE +dump_and_exit(int signum) +{ + just_dump(signum); + exit(EXIT_FAILURE); +} + +#endif + +/* dump_prog --- dump the program */ + +/* + * XXX: I am not sure it is right to have the strings in the dump + * be translated, but I'll leave it alone for now. + */ + +void +dump_prog(INSTRUCTION *code) +{ + time_t now; + + (void) time(& now); + /* \n on purpose, with \n in ctime() output */ + fprintf(prof_fp, _("\t# gawk profile, created %s\n"), ctime(& now)); + pprint(code, NULL, FALSE); +} + +/* prec_level --- return the precedence of an operator, for paren tests */ + +static int +prec_level(int type) +{ + switch (type) { + case Op_push_lhs: + case Op_push_param: + case Op_push_array: + case Op_push: + case Op_push_i: + case Op_push_re: + case Op_match_rec: + case Op_subscript: + case Op_subscript_lhs: + case Op_func_call: + case Op_K_delete_loop: + case Op_builtin: + return 15; + + case Op_field_spec: + case Op_field_spec_lhs: + return 14; + + case Op_exp: + case Op_exp_i: + return 13; + + case Op_preincrement: + case Op_predecrement: + case Op_postincrement: + case Op_postdecrement: + return 12; + + case Op_unary_minus: + case Op_not: + return 11; + + case Op_times: + case Op_times_i: + case Op_quotient: + case Op_quotient_i: + case Op_mod: + case Op_mod_i: + return 10; + + case Op_plus: + case Op_plus_i: + case Op_minus: + case Op_minus_i: + return 9; + + case Op_concat: + case Op_assign_concat: + return 8; + + case Op_equal: + case Op_notequal: + case Op_greater: + case Op_leq: + case Op_geq: + case Op_match: + case Op_nomatch: + return 7; + + case Op_K_getline: + case Op_K_getline_redir: + return 6; + + case Op_less: + return 5; + + case Op_in_array: + return 5; + + case Op_and: + return 4; + + case Op_or: + return 3; + + case Op_cond_exp: + return 2; + + case Op_assign: + case Op_assign_times: + case Op_assign_quotient: + case Op_assign_mod: + case Op_assign_plus: + case Op_assign_minus: + case Op_assign_exp: + return 1; + + default: + return 0; + } +} + +static int +is_binary(int type) +{ + switch (type) { + case Op_geq: + case Op_leq: + case Op_greater: + case Op_less: + case Op_notequal: + case Op_equal: + case Op_exp: + case Op_times: + case Op_quotient: + case Op_mod: + case Op_plus: + case Op_minus: + case Op_exp_i: + case Op_times_i: + case Op_quotient_i: + case Op_mod_i: + case Op_plus_i: + case Op_minus_i: + case Op_concat: + case Op_assign_concat: + case Op_match: + case Op_nomatch: + case Op_assign: + case Op_assign_times: + case Op_assign_quotient: + case Op_assign_mod: + case Op_assign_plus: + case Op_assign_minus: + case Op_assign_exp: + case Op_cond_exp: + case Op_and: + case Op_or: + case Op_in_array: + case Op_K_getline_redir: /* sometimes */ + case Op_K_getline: + return TRUE; + + default: + return FALSE; + } +} + +/* parenthesize --- parenthesize an expression in stack */ + +static void +pp_parenthesize(NODE *sp) +{ + char *p = sp->pp_str; + size_t len = sp->pp_len; + + emalloc(p, char *, len + 3, "pp_parenthesize"); + *p = '('; + memcpy(p + 1, sp->pp_str, len); + p[len + 1] = ')'; + p[len + 2] = '\0'; + if ((sp->flags & CAN_FREE) != 0) + efree(sp->pp_str); + sp->pp_str = p; + sp->pp_len += 2; + sp->flags |= CAN_FREE; +} + +static void +parenthesize(int type, NODE *left, NODE *right) +{ + int rprec = prec_level(right->type); + int lprec = prec_level(left->type); + int prec = prec_level(type); + + if (prec > lprec) { + if (is_binary(left->type)) /* (a - b) * c */ + pp_parenthesize(left); + if (prec >= rprec && is_binary(right->type)) /* (a - b) * (c - d) */ + pp_parenthesize(right); + } else { + if (prec >= rprec && is_binary(right->type)) /* a - b - (c - d) */ + pp_parenthesize(right); + } +} + +/* pp_string --- pretty format a string or regex constant */ + +char * +pp_string(const char *in_str, size_t len, int delim) +{ + static char str_escapes[] = "\a\b\f\n\r\t\v\\"; + static char str_printables[] = "abfnrtv\\"; + static char re_escapes[] = "\a\b\f\n\r\t\v"; + static char re_printables[] = "abfnrtv"; + char *escapes; + char *printables; + char *cp; + int i; + const unsigned char *str = (const unsigned char *) in_str; + size_t ofre, osiz; + char *obuf, *obufout; + + assert(delim == '"' || delim == '/'); + + if (delim == '/') { + escapes = re_escapes; + printables = re_printables; + } else { + escapes = str_escapes; + printables = str_printables; + } + +/* make space for something l big in the buffer */ +#define chksize(l) if ((l) > ofre) { \ + long olen = obufout - obuf; \ + erealloc(obuf, char *, osiz * 2, "pp_string"); \ + obufout = obuf + olen; \ + ofre += osiz; \ + osiz *= 2; \ +} ofre -= (l) + + osiz = len + 3 + 2; /* initial size; 3 for delim + terminating null */ + emalloc(obuf, char *, osiz, "pp_string"); + obufout = obuf; + ofre = osiz - 1; + + *obufout++ = delim; + for (; len > 0; len--, str++) { + chksize(2); /* make space for 2 chars */ + if (delim != '/' && *str == delim) { + *obufout++ = '\\'; + *obufout++ = delim; + } else if ((cp = strchr(escapes, *str)) != NULL) { + i = cp - escapes; + *obufout++ = '\\'; + *obufout++ = printables[i]; + /* NB: Deliberate use of lower-case versions. */ + } else if (isascii(*str) && isprint(*str)) { + *obufout++ = *str; + ofre += 1; + } else { + size_t len; + + chksize(8); /* total available space is 10 */ + + sprintf(obufout, "\\%03o", *str & 0xff); + len = strlen(obufout); + ofre += (10 - len); /* adjust free space count */ + obufout += len; + } + } + chksize(1); + *obufout++ = delim; + *obufout = '\0'; + return obuf; +#undef chksize +} + +/* pp_number --- pretty format a number */ + +char * +pp_number(AWKNUM d) +{ +#define PP_PRECISION 6 + char *str; + + emalloc(str, char *, PP_PRECISION + 10, "pp_number"); + sprintf(str, "%0.*g", PP_PRECISION, d); + return str; +#undef PP_PRECISION +} + +/* pp_node --- pretty format a node */ + +char * +pp_node(NODE *n) +{ + if ((n->flags & NUMBER) != 0) + return pp_number(n->numbr); + return pp_string(n->stptr, n->stlen, '"'); +} + +static NODE **pp_args = NULL; +static int npp_args; + +static char * +pp_list(int nargs, const char *paren, const char *delim) +{ + NODE *r; + char *str, *s; + size_t len; + size_t delimlen; + int i; + + if (pp_args == NULL) { + npp_args = nargs; + emalloc(pp_args, NODE **, (nargs + 2) * sizeof(NODE *), "pp_list"); + } else if (nargs > npp_args) { + npp_args = nargs; + erealloc(pp_args, NODE **, (nargs + 2) * sizeof(NODE *), "pp_list"); + } + + delimlen = strlen(delim); + len = -delimlen; + for (i = 1; i <= nargs; i++) { + r = pp_args[i] = pp_pop(); + len += r->pp_len + delimlen; + } + if (paren != NULL) { + assert(strlen(paren) == 2); + len += 2; + } + + emalloc(str, char *, len + 1, "pp_list"); + s = str; + if (paren != NULL) + *s++ = paren[0]; + r = pp_args[nargs]; + memcpy(s, r->pp_str, r->pp_len); + s += r->pp_len; + pp_free(r); + for (i = nargs - 1; i > 0; i--) { + if (delimlen > 0) { + memcpy(s, delim, delimlen); + s += delimlen; + } + r = pp_args[i]; + memcpy(s, r->pp_str, r->pp_len); + s += r->pp_len; + pp_free(r); + } + if (paren != NULL) + *s++ = paren[1]; + *s = '\0'; + return str; +} + +static char * +pp_concat(const char *s1, const char *s2, const char *s3) +{ + size_t len1, len2, len3, l; + char *str, *s; + + len1 = strlen(s1); + len2 = strlen(s2); + len3 = strlen(s3); + l = len1 + len2 + len3 + 2; + emalloc(str, char *, l, "pp_concat"); + s = str; + if (len1 > 0) { + memcpy(s, s1, len1); + s += len1; + } + if (len2 > 0) { + memcpy(s, s2, len2); + s += len2; + } + if (len3 > 0) { + memcpy(s, s3, len3); + s += len3; + } + *s = '\0'; + return str; +} + +/* pp_func --- pretty print a function */ + +int +pp_func(INSTRUCTION *pc, void *data ATTRIBUTE_UNUSED) +{ + int j; + char **pnames; + NODE *f; + static int first = TRUE; + int pcount; + + if (first) { + first = FALSE; + fprintf(prof_fp, _("\n\t# Functions, listed alphabetically\n")); + } + + f = pc->func_body; + fprintf(prof_fp, "\n"); + indent(pc->nexti->exec_count); + fprintf(prof_fp, "%s %s(", op2str(Op_K_function), f->lnode->param); + pnames = f->parmlist; + fparms = pnames; + pcount = f->lnode->param_cnt; + for (j = 0; j < pcount; j++) { + fprintf(prof_fp, "%s", pnames[j]); + if (j < pcount - 1) + fprintf(prof_fp, ", "); + } + fprintf(prof_fp, ")\n\t{\n"); + indent_in(); + pprint(pc->nexti->nexti, NULL, FALSE); /* function body */ + indent_out(); + fprintf(prof_fp, "\t}\n"); + return 0; +} + +/* redir2str --- convert a redirection type into a printable value */ + +const char * +redir2str(int redirtype) +{ + static const char *const redirtab[] = { + "", + " > ", /* redirect_output */ + " >> ", /* redirect_append */ + " | ", /* redirect_pipe */ + " | ", /* redirect_pipein */ + " < ", /* redirect_input */ + " |& ", /* redirect_twoway */ + }; + + if (redirtype < 0 || redirtype > redirect_twoway) + fatal(_("redir2str: unknown redirection type %d"), redirtype); + return redirtab[redirtype]; +} + + diff --git a/profile_p.c b/profile_p.c new file mode 100644 index 0000000..97edd36 --- /dev/null +++ b/profile_p.c @@ -0,0 +1,27 @@ +/* + * profile_p.c - compile profile.c with profiling turned on. + */ + +/* + * Copyright (C) 2001 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define PROFILING 1 +#include "profile.c" diff --git a/protos.h b/protos.h new file mode 100644 index 0000000..0afe4bb --- /dev/null +++ b/protos.h @@ -0,0 +1,148 @@ +/* + * protos.h -- function prototypes for when the headers don't have them. + */ + +/* + * Copyright (C) 1991 - 2002, 2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef STDC_HEADERS + +#define aptr_t void * /* arbitrary pointer type */ +extern aptr_t malloc(MALLOC_ARG_T); +extern aptr_t realloc(aptr_t, MALLOC_ARG_T); +extern aptr_t calloc(MALLOC_ARG_T, MALLOC_ARG_T); + +extern void free(aptr_t); +extern char *getenv(const char *); + +#if ! defined(HAVE_STRING_H) && ! defined(HAVE_STRINGS_H) +extern char *strcpy(char *, const char *); +extern char *strcat(char *, const char *); +extern char *strncpy(char *, const char *, size_t); +extern int strcmp(const char *, const char *); +extern int strncmp(const char *, const char *, size_t); +extern char *strchr(const char *, int); +extern char *strrchr(const char *, int); +extern char *strstr(const char *s1, const char *s2); +extern size_t strlen(const char *); +extern long strtol(const char *, char **, int); + +extern aptr_t memset(aptr_t, int, size_t); +extern aptr_t memcpy(aptr_t, const aptr_t, size_t); +extern aptr_t memmove(aptr_t, const aptr_t, size_t); +extern aptr_t memchr(const aptr_t, int, size_t); +extern int memcmp(const aptr_t, const aptr_t, size_t); +#endif /* ! defined(HAVE_STRING_H) && ! defined(HAVE_STRINGS_H) */ + +#ifndef VMS +extern char *strerror(int); +#else +extern char *strerror(int,...); +#endif + +#if ! defined(__GNU_LIBRARY__) +extern size_t strftime(char *, size_t, const char *, const struct tm *); +#endif +extern time_t time(time_t *); + +extern FILE *fdopen(int, const char *); +extern int fprintf(FILE *, const char *, ...); +#if ! defined(__GNU_LIBRARY__) +extern size_t fwrite(const aptr_t, size_t, size_t, FILE *); +#endif +extern int fputs(const char *, FILE *); +extern int unlink(const char *); +extern int fflush(FILE *); +extern int fclose(FILE *); +extern FILE *popen(const char *, const char *); +extern int pclose(FILE *); +extern void abort(); +extern int isatty(int); +extern void exit(int); +extern int system(const char *); +extern int sscanf(const char *, const char *, ...); +#ifndef toupper +extern int toupper(int); +#endif +#ifndef tolower +extern int tolower(int); +#endif + +extern double pow(double x, double y); +extern double atof(const char *); +extern double strtod(const char *, char **); +extern int fstat(int, struct stat *); +extern int stat(const char *, struct stat *); +extern off_t lseek(int, off_t, int); +extern int close(int); +extern int creat(const char *, mode_t); +extern int open(const char *, int, ...); +extern int pipe(int *); +extern int dup(int); +extern int dup2(int,int); +extern int fork(); +extern int execl(const char *, const char *, ...); +#ifndef HAVE_SYS_WAIT_H +extern int wait(int *); +#endif +extern void _exit(int); + +#undef aptr_t + +#endif /* STDC_HEADERS */ + + +/* prototypes for missing functions defined in missing_d/ */ + +#ifndef HAVE_STRNCASECMP +extern int strcasecmp(const char *s1, const char *s2); +extern int strncasecmp(const char *s1, const char *s2, register size_t n); +#endif + +#ifndef HAVE_STRTOUL +extern unsigned long int strtoul(const char *, char **endptr, int base); +#endif + +#ifndef HAVE_TZSET +extern void tzset(); +#endif + +#ifndef HAVE_MKTIME +extern time_t mktime(struct tm *tp); +#endif + +#ifndef HAVE_SNPRINTF +extern int snprintf(char *restrict buf, size_t len, const char *restrict fmt, ...); +#endif + +#ifndef HAVE_USLEEP +extern int usleep(unsigned int); +#endif + +#ifndef HAVE_SETENV +extern int setenv(const char *, const char *, int); +extern int unsetenv(const char *); +#endif + +#if !defined(HAVE_STRCOLL) +extern int strcoll(const char *, const char *); +#endif + diff --git a/random.c b/random.c new file mode 100644 index 0000000..cba1b6b --- /dev/null +++ b/random.c @@ -0,0 +1,542 @@ +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Per the statement at http://opensource.org/licenses/bsd-license.php, + * + * The advertising clause in the license appearing on BSD Unix files was + * officially rescinded by the Director of the Office of Technology + * Licensing of the University of California on July 22 1999. He states + * that clause 3 is "hereby deleted in its entirety." + * + * I removed the advertising clause in the above copyright. + * The above web site points to + * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change. + * + * Arnold Robbins + * 15 September 2007 + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static const char sccsid[] = "@(#)random.c 8.2 (Berkeley) 5/19/95"; +#endif /* LIBC_SCCS and not lint */ + +#ifdef HAVE_CONFIG_H /* gawk addition */ +#include +#endif + +#ifdef HAVE_FCNTL_H +#include +#endif +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif + +#include "random.h" /* gawk addition */ + +#ifdef HAVE_SYS_TIME_H /* gawk addition */ +#include +#endif + +#if 0 +#include +__FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/stdlib/random.c,v 1.24 2004/01/20 03:02:18 das Exp $"); + +#include "namespace.h" +#include /* for srandomdev() */ +#include /* for srandomdev() */ +#include +#include +#include +#include /* for srandomdev() */ +#include "un-namespace.h" +#endif + +/* + * random.c: + * + * An improved random number generation package. In addition to the standard + * rand()/srand() like interface, this package also has a special state info + * interface. The initstate() routine is called with a seed, an array of + * bytes, and a count of how many bytes are being passed in; this array is + * then initialized to contain information for random number generation with + * that much state information. Good sizes for the amount of state + * information are 32, 64, 128, and 256 bytes. The state can be switched by + * calling the setstate() routine with the same array as was initiallized + * with initstate(). By default, the package runs with 128 bytes of state + * information and generates far better random numbers than a linear + * congruential generator. If the amount of state information is less than + * 32 bytes, a simple linear congruential R.N.G. is used. + * + * Internally, the state information is treated as an array of uint32_t's; the + * zeroeth element of the array is the type of R.N.G. being used (small + * integer); the remainder of the array is the state information for the + * R.N.G. Thus, 32 bytes of state information will give 7 ints worth of + * state information, which will allow a degree seven polynomial. (Note: + * the zeroeth word of state information also has some other information + * stored in it -- see setstate() for details). + * + * The random number generation technique is a linear feedback shift register + * approach, employing trinomials (since there are fewer terms to sum up that + * way). In this approach, the least significant bit of all the numbers in + * the state table will act as a linear feedback shift register, and will + * have period 2^deg - 1 (where deg is the degree of the polynomial being + * used, assuming that the polynomial is irreducible and primitive). The + * higher order bits will have longer periods, since their values are also + * influenced by pseudo-random carries out of the lower bits. The total + * period of the generator is approximately deg*(2**deg - 1); thus doubling + * the amount of state information has a vast influence on the period of the + * generator. Note: the deg*(2**deg - 1) is an approximation only good for + * large deg, when the period of the shift is the dominant factor. + * With deg equal to seven, the period is actually much longer than the + * 7*(2**7 - 1) predicted by this formula. + * + * Modified 28 December 1994 by Jacob S. Rosenberg. + * The following changes have been made: + * All references to the type u_int have been changed to unsigned long. + * All references to type int have been changed to type long. Other + * cleanups have been made as well. A warning for both initstate and + * setstate has been inserted to the effect that on Sparc platforms + * the 'arg_state' variable must be forced to begin on word boundaries. + * This can be easily done by casting a long integer array to char *. + * The overall logic has been left STRICTLY alone. This software was + * tested on both a VAX and Sun SpacsStation with exactly the same + * results. The new version and the original give IDENTICAL results. + * The new version is somewhat faster than the original. As the + * documentation says: "By default, the package runs with 128 bytes of + * state information and generates far better random numbers than a linear + * congruential generator. If the amount of state information is less than + * 32 bytes, a simple linear congruential R.N.G. is used." For a buffer of + * 128 bytes, this new version runs about 19 percent faster and for a 16 + * byte buffer it is about 5 percent faster. + */ + +/* + * For each of the currently supported random number generators, we have a + * break value on the amount of state information (you need at least this + * many bytes of state info to support this random number generator), a degree + * for the polynomial (actually a trinomial) that the R.N.G. is based on, and + * the separation between the two lower order coefficients of the trinomial. + */ +#define TYPE_0 0 /* linear congruential */ +#define BREAK_0 8 +#define DEG_0 0 +#define SEP_0 0 + +#define TYPE_1 1 /* x**7 + x**3 + 1 */ +#define BREAK_1 32 +#define DEG_1 7 +#define SEP_1 3 + +#define TYPE_2 2 /* x**15 + x + 1 */ +#define BREAK_2 64 +#define DEG_2 15 +#define SEP_2 1 + +#define TYPE_3 3 /* x**31 + x**3 + 1 */ +#define BREAK_3 128 +#define DEG_3 31 +#define SEP_3 3 + +#define TYPE_4 4 /* x**63 + x + 1 */ +#define BREAK_4 256 +#define DEG_4 63 +#define SEP_4 1 + +/* + * Array versions of the above information to make code run faster -- + * relies on fact that TYPE_i == i. + */ +#define MAX_TYPES 5 /* max number of types above */ + +#ifdef USE_WEAK_SEEDING +#define NSHUFF 0 +#else /* !USE_WEAK_SEEDING */ +#define NSHUFF 50 /* to drop some "seed -> 1st value" linearity */ +#endif /* !USE_WEAK_SEEDING */ + +static const int degrees[MAX_TYPES] = { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 }; +static const int seps [MAX_TYPES] = { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 }; + +/* + * Initially, everything is set up as if from: + * + * initstate(1, randtbl, 128); + * + * Note that this initialization takes advantage of the fact that srandom() + * advances the front and rear pointers 10*rand_deg times, and hence the + * rear pointer which starts at 0 will also end up at zero; thus the zeroeth + * element of the state information, which contains info about the current + * position of the rear pointer is just + * + * MAX_TYPES * (rptr - state) + TYPE_3 == TYPE_3. + */ + +static uint32_t randtbl[DEG_3 + 1] = { + TYPE_3, +#ifdef USE_WEAK_SEEDING +/* Historic implementation compatibility */ +/* The random sequences do not vary much with the seed */ + 0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342, 0xde3b81e0, 0xdf0a6fb5, + 0xf103bc02, 0x48f340fb, 0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd, + 0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86, 0xda672e2a, 0x1588ca88, + 0xe369735d, 0x904f35f7, 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc, + 0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b, 0xf5ad9d0e, 0x8999220b, + 0x27fb47b9, +#else /* !USE_WEAK_SEEDING */ + 0x991539b1, 0x16a5bce3, 0x6774a4cd, 0x3e01511e, 0x4e508aaa, 0x61048c05, + 0xf5500617, 0x846b7115, 0x6a19892c, 0x896a97af, 0xdb48f936, 0x14898454, + 0x37ffd106, 0xb58bff9c, 0x59e17104, 0xcf918a49, 0x09378c83, 0x52c7a471, + 0x8d293ea9, 0x1f4fc301, 0xc3db71be, 0x39b44e1c, 0xf8a44ef9, 0x4c8b80b1, + 0x19edc328, 0x87bf4bdd, 0xc9b240e5, 0xe9ee4b1b, 0x4382aee7, 0x535b6b41, + 0xf3bec5da +#endif /* !USE_WEAK_SEEDING */ +}; + +/* + * fptr and rptr are two pointers into the state info, a front and a rear + * pointer. These two pointers are always rand_sep places aparts, as they + * cycle cyclically through the state information. (Yes, this does mean we + * could get away with just one pointer, but the code for random() is more + * efficient this way). The pointers are left positioned as they would be + * from the call + * + * initstate(1, randtbl, 128); + * + * (The position of the rear pointer, rptr, is really 0 (as explained above + * in the initialization of randtbl) because the state table pointer is set + * to point to randtbl[1] (as explained below). + */ +static uint32_t *fptr = &randtbl[SEP_3 + 1]; +static uint32_t *rptr = &randtbl[1]; + +/* + * The following things are the pointer to the state information table, the + * type of the current generator, the degree of the current polynomial being + * used, and the separation between the two pointers. Note that for efficiency + * of random(), we remember the first location of the state information, not + * the zeroeth. Hence it is valid to access state[-1], which is used to + * store the type of the R.N.G. Also, we remember the last location, since + * this is more efficient than indexing every time to find the address of + * the last element to see if the front and rear pointers have wrapped. + */ +static uint32_t *state = &randtbl[1]; +static int rand_type = TYPE_3; +static int rand_deg = DEG_3; +static int rand_sep = SEP_3; +static uint32_t *end_ptr = &randtbl[DEG_3 + 1]; + +static inline uint32_t good_rand(int32_t); + +static inline uint32_t good_rand (x) + int32_t x; +{ +#ifdef USE_WEAK_SEEDING +/* + * Historic implementation compatibility. + * The random sequences do not vary much with the seed, + * even with overflowing. + */ + return (1103515245 * x + 12345); +#else /* !USE_WEAK_SEEDING */ +/* + * Compute x = (7^5 * x) mod (2^31 - 1) + * wihout overflowing 31 bits: + * (2^31 - 1) = 127773 * (7^5) + 2836 + * From "Random number generators: good ones are hard to find", + * Park and Miller, Communications of the ACM, vol. 31, no. 10, + * October 1988, p. 1195. + */ + int32_t hi, lo; + + /* Can't be initialized with 0, so use another value. */ + if (x == 0) + x = 123459876; + hi = x / 127773; + lo = x % 127773; + x = 16807 * lo - 2836 * hi; + if (x < 0) + x += 0x7fffffff; + return (x); +#endif /* !USE_WEAK_SEEDING */ +} + +/* + * srandom: + * + * Initialize the random number generator based on the given seed. If the + * type is the trivial no-state-information type, just remember the seed. + * Otherwise, initializes state[] based on the given "seed" via a linear + * congruential generator. Then, the pointers are set to known locations + * that are exactly rand_sep places apart. Lastly, it cycles the state + * information a given number of times to get rid of any initial dependencies + * introduced by the L.C.R.N.G. Note that the initialization of randtbl[] + * for default usage relies on values produced by this routine. + */ +void +srandom(x) + unsigned long x; +{ + int i, lim; + + state[0] = (uint32_t)x; + if (rand_type == TYPE_0) + lim = NSHUFF; + else { + for (i = 1; i < rand_deg; i++) + state[i] = good_rand(state[i - 1]); + fptr = &state[rand_sep]; + rptr = &state[0]; + lim = 10 * rand_deg; + } + for (i = 0; i < lim; i++) + (void)random(); +} + +#if 0 /* gawk doesn't use this */ +/* + * srandomdev: + * + * Many programs choose the seed value in a totally predictable manner. + * This often causes problems. We seed the generator using the much more + * secure random(4) interface. Note that this particular seeding + * procedure can generate states which are impossible to reproduce by + * calling srandom() with any value, since the succeeding terms in the + * state buffer are no longer derived from the LC algorithm applied to + * a fixed seed. + */ +void +srandomdev() +{ + int fd, done; + size_t len; + + if (rand_type == TYPE_0) + len = sizeof state[0]; + else + len = rand_deg * sizeof state[0]; + + done = 0; + fd = open("/dev/random", O_RDONLY, 0); + if (fd >= 0) { + if (read(fd, (void *) state, len) == (ssize_t) len) + done = 1; + close(fd); + } + + if (!done) { + struct timeval tv; + unsigned long junk; + + gettimeofday(&tv, NULL); + srandom((getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ junk); + return; + } + + if (rand_type != TYPE_0) { + fptr = &state[rand_sep]; + rptr = &state[0]; + } +} +#endif + +/* + * initstate: + * + * Initialize the state information in the given array of n bytes for future + * random number generation. Based on the number of bytes we are given, and + * the break values for the different R.N.G.'s, we choose the best (largest) + * one we can and set things up for it. srandom() is then called to + * initialize the state information. + * + * Note that on return from srandom(), we set state[-1] to be the type + * multiplexed with the current value of the rear pointer; this is so + * successive calls to initstate() won't lose this information and will be + * able to restart with setstate(). + * + * Note: the first thing we do is save the current state, if any, just like + * setstate() so that it doesn't matter when initstate is called. + * + * Returns a pointer to the old state. + * + * Note: The Sparc platform requires that arg_state begin on an int + * word boundary; otherwise a bus error will occur. Even so, lint will + * complain about mis-alignment, but you should disregard these messages. + */ +char * +initstate(seed, arg_state, n) + unsigned long seed; /* seed for R.N.G. */ + char *arg_state; /* pointer to state array */ + long n; /* # bytes of state info */ +{ + char *ostate = (char *)(&state[-1]); + uint32_t *int_arg_state = (uint32_t *)arg_state; + + if (rand_type == TYPE_0) + state[-1] = rand_type; + else + state[-1] = MAX_TYPES * (rptr - state) + rand_type; + if (n < BREAK_0) { + (void)fprintf(stderr, + "random: not enough state (%ld bytes); ignored.\n", n); + return(0); + } + if (n < BREAK_1) { + rand_type = TYPE_0; + rand_deg = DEG_0; + rand_sep = SEP_0; + } else if (n < BREAK_2) { + rand_type = TYPE_1; + rand_deg = DEG_1; + rand_sep = SEP_1; + } else if (n < BREAK_3) { + rand_type = TYPE_2; + rand_deg = DEG_2; + rand_sep = SEP_2; + } else if (n < BREAK_4) { + rand_type = TYPE_3; + rand_deg = DEG_3; + rand_sep = SEP_3; + } else { + rand_type = TYPE_4; + rand_deg = DEG_4; + rand_sep = SEP_4; + } + state = int_arg_state + 1; /* first location */ + end_ptr = &state[rand_deg]; /* must set end_ptr before srandom */ + srandom(seed); + if (rand_type == TYPE_0) + int_arg_state[0] = rand_type; + else + int_arg_state[0] = MAX_TYPES * (rptr - state) + rand_type; + return(ostate); +} + +/* + * setstate: + * + * Restore the state from the given state array. + * + * Note: it is important that we also remember the locations of the pointers + * in the current state information, and restore the locations of the pointers + * from the old state information. This is done by multiplexing the pointer + * location into the zeroeth word of the state information. + * + * Note that due to the order in which things are done, it is OK to call + * setstate() with the same state as the current state. + * + * Returns a pointer to the old state information. + * + * Note: The Sparc platform requires that arg_state begin on an int + * word boundary; otherwise a bus error will occur. Even so, lint will + * complain about mis-alignment, but you should disregard these messages. + */ +char * +setstate(arg_state) + char *arg_state; /* pointer to state array */ +{ + uint32_t *new_state = (uint32_t *)arg_state; + uint32_t type = new_state[0] % MAX_TYPES; + uint32_t rear = new_state[0] / MAX_TYPES; + char *ostate = (char *)(&state[-1]); + + if (rand_type == TYPE_0) + state[-1] = rand_type; + else + state[-1] = MAX_TYPES * (rptr - state) + rand_type; + switch(type) { + case TYPE_0: + case TYPE_1: + case TYPE_2: + case TYPE_3: + case TYPE_4: + rand_type = type; + rand_deg = degrees[type]; + rand_sep = seps[type]; + break; + default: + (void)fprintf(stderr, + "random: state info corrupted; not changed.\n"); + } + state = new_state + 1; + if (rand_type != TYPE_0) { + rptr = &state[rear]; + fptr = &state[(rear + rand_sep) % rand_deg]; + } + end_ptr = &state[rand_deg]; /* set end_ptr too */ + return(ostate); +} + +/* + * random: + * + * If we are using the trivial TYPE_0 R.N.G., just do the old linear + * congruential bit. Otherwise, we do our fancy trinomial stuff, which is + * the same in all the other cases due to all the global variables that have + * been set up. The basic operation is to add the number at the rear pointer + * into the one at the front pointer. Then both pointers are advanced to + * the next location cyclically in the table. The value returned is the sum + * generated, reduced to 31 bits by throwing away the "least random" low bit. + * + * Note: the code takes advantage of the fact that both the front and + * rear pointers can't wrap on the same call by not testing the rear + * pointer if the front one has wrapped. + * + * Returns a 31-bit random number. + */ +long +random() +{ + uint32_t i; + uint32_t *f, *r; + + if (rand_type == TYPE_0) { + i = state[0]; + state[0] = i = (good_rand(i)) & 0x7fffffff; + } else { + /* + * Use local variables rather than static variables for speed. + */ + f = fptr; r = rptr; + *f += *r; + i = (*f >> 1) & 0x7fffffff; /* chucking least random bit */ + if (++f >= end_ptr) { + f = state; + ++r; + } + else if (++r >= end_ptr) { + r = state; + } + + fptr = f; rptr = r; + } + return((long)i); +} diff --git a/random.h b/random.h new file mode 100644 index 0000000..626cbcd --- /dev/null +++ b/random.h @@ -0,0 +1,50 @@ +/* + * random.h - redefine name of random lib routines to avoid conflicts + */ + +/* + * Copyright (C) 1996, 2001, 2004, 2005 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#define initstate gawk_initstate +#define setstate gawk_setstate +#define random gawk_random +#define srandom gawk_srandom + +#if SIZEOF_UNSIGNED_INT == 4 +typedef unsigned int gawk_uint32_t; +typedef int gawk_int32_t; +#else +#if SIZEOF_UNSIGNED_LONG == 4 +typedef unsigned long gawk_uint32_t; +typedef long gawk_int32_t; +#endif +#endif +#define uint32_t gawk_uint32_t +#define int32_t gawk_int32_t + +#ifdef __STDC__ +#undef __P +#define __P(s) s +#else +#define __P(s) () +#endif + +extern long random __P((void)); diff --git a/re.c b/re.c new file mode 100644 index 0000000..1144ec7 --- /dev/null +++ b/re.c @@ -0,0 +1,611 @@ +/* + * re.c - compile regular expressions. + */ + +/* + * Copyright (C) 1991-2012 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "awk.h" + +static reg_syntax_t syn; +static void check_bracket_exp(char *s, size_t len); + +/* make_regexp --- generate compiled regular expressions */ + +Regexp * +make_regexp(const char *s, size_t len, int ignorecase, int dfa, int canfatal) +{ + Regexp *rp; + const char *rerr; + const char *src = s; + static char *buf = NULL; + static size_t buflen; + const char *end = s + len; + char *dest; + int c, c2; + static short first = TRUE; + static short no_dfa = FALSE; + int has_anchor = FALSE; + int may_have_range = 0; + reg_syntax_t dfa_syn; + + /* + * The number of bytes in the current multibyte character. + * It is 0, when the current character is a singlebyte character. + */ + size_t is_multibyte = 0; +#if MBS_SUPPORT + mbstate_t mbs; + + if (gawk_mb_cur_max > 1) + memset(&mbs, 0, sizeof(mbstate_t)); /* Initialize. */ +#endif + + if (first) { + first = FALSE; + /* for debugging and testing */ + no_dfa = (getenv("GAWK_NO_DFA") != NULL); + } + + /* always check */ + check_bracket_exp((char *) s, len); + + /* Handle escaped characters first. */ + + /* + * Build a copy of the string (in buf) with the + * escaped characters translated, and generate the regex + * from that. + */ + if (buf == NULL) { + emalloc(buf, char *, len + 2, "make_regexp"); + buflen = len; + } else if (len > buflen) { + erealloc(buf, char *, len + 2, "make_regexp"); + buflen = len; + } + dest = buf; + + while (src < end) { +#if MBS_SUPPORT + if (gawk_mb_cur_max > 1 && ! is_multibyte) { + /* The previous byte is a singlebyte character, or last byte + of a multibyte character. We check the next character. */ + is_multibyte = mbrlen(src, end - src, &mbs); + if ( (is_multibyte == 1) + || (is_multibyte == (size_t) -1) + || (is_multibyte == (size_t) -2 + || (is_multibyte == 0))) { + /* We treat it as a singlebyte character. */ + is_multibyte = 0; + } + } +#endif + + /* We skip multibyte character, since it must not be a special + character. */ + if ((gawk_mb_cur_max == 1 || ! is_multibyte) && + (*src == '\\')) { + c = *++src; + switch (c) { + case 'a': + case 'b': + case 'f': + case 'n': + case 'r': + case 't': + case 'v': + case 'x': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + c2 = parse_escape(&src); + if (c2 < 0) + cant_happen(); + /* + * Unix awk treats octal (and hex?) chars + * literally in re's, so escape regexp + * metacharacters. + */ + if (do_traditional + && ! do_posix + && (isdigit(c) || c == 'x') + && strchr("()|*+?.^$\\[]", c2) != NULL) + *dest++ = '\\'; + *dest++ = (char) c2; + break; + case '8': + case '9': /* a\9b not valid */ + *dest++ = c; + src++; + break; + case 'y': /* normally \b */ + /* gnu regex op */ + if (! do_traditional) { + *dest++ = '\\'; + *dest++ = 'b'; + src++; + break; + } + /* else, fall through */ + default: + *dest++ = '\\'; + *dest++ = (char) c; + src++; + break; + } /* switch */ + } else { + c = *src; + if (c == '^' || c == '$') + has_anchor = TRUE; + if (c == '[' || c == '-' || c == ']') + may_have_range++; + + *dest++ = *src++; /* not '\\' */ + } + if (gawk_mb_cur_max > 1 && is_multibyte) + is_multibyte--; + } /* while */ + + *dest = '\0'; + len = dest - buf; + + emalloc(rp, Regexp *, sizeof(*rp), "make_regexp"); + memset((char *) rp, 0, sizeof(*rp)); + rp->dfareg = NULL; + rp->pat.allocated = 0; /* regex will allocate the buffer */ + emalloc(rp->pat.fastmap, char *, 256, "make_regexp"); + + /* + * Lo these many years ago, had I known what a P.I.T.A. IGNORECASE + * was going to turn out to be, I wouldn't have bothered with it. + * + * In the case where we have a multibyte character set, we have no + * choice but to use RE_ICASE, since the casetable is for single-byte + * character sets only. + * + * On the other hand, if we do have a single-byte character set, + * using the casetable should give a performance improvement, since + * it's computed only once, not each time a regex is compiled. We + * also think it's probably better for portability. See the + * discussion by the definition of casetable[] in eval.c. + */ + + ignorecase = !! ignorecase; /* force to 1 or 0 */ + if (ignorecase) { + if (gawk_mb_cur_max > 1) { + syn |= RE_ICASE; + rp->pat.translate = NULL; + } else { + syn &= ~RE_ICASE; + rp->pat.translate = (RE_TRANSLATE_TYPE) casetable; + } + } else { + rp->pat.translate = NULL; + syn &= ~RE_ICASE; + } + + dfa_syn = syn; + if (ignorecase) + dfa_syn |= RE_ICASE; + dfasyntax(dfa_syn, ignorecase, '\n'); + re_set_syntax(syn); + + if ((rerr = re_compile_pattern(buf, len, &(rp->pat))) != NULL) { + refree(rp); + if (! canfatal) { + /* rerr already gettextized inside regex routines */ + error("%s: /%s/", rerr, buf); + return NULL; + } + fatal("%s: /%s/", rerr, buf); + } + + /* gack. this must be done *after* re_compile_pattern */ + rp->pat.newline_anchor = FALSE; /* don't get \n in middle of string */ + if (dfa && ! no_dfa) { + rp->dfa = TRUE; + rp->dfareg = dfaalloc(); + dfacomp(buf, len, rp->dfareg, TRUE); + } else + rp->dfa = FALSE; + rp->has_anchor = has_anchor; + + return rp; +} + +/* research --- do a regexp search. use dfa if possible */ + +int +research(Regexp *rp, char *str, int start, + size_t len, int flags) +{ + const char *ret = str; + int try_backref; + int need_start; + int no_bol; + int res; + + need_start = ((flags & RE_NEED_START) != 0); + no_bol = ((flags & RE_NO_BOL) != 0); + + if (no_bol) + rp->pat.not_bol = 1; + + /* + * Always do dfa search if can; if it fails, then even if + * need_start is true, we won't bother with the regex search. + * + * The dfa matcher doesn't have a no_bol flag, so don't bother + * trying it in that case. + * + * 7/2008: Skip the dfa matcher if need_start. The dfa matcher + * has bugs in certain multibyte cases and it's too difficult + * to try to special case things. + */ + if (rp->dfa && ! no_bol && ! need_start) { + char save; + int count = 0; + /* + * dfa likes to stick a '\n' right after the matched + * text. So we just save and restore the character. + */ + save = str[start+len]; + ret = dfaexec(rp->dfareg, str+start, str+start+len, TRUE, + &count, &try_backref); + str[start+len] = save; + } + + if (ret) { + if (need_start || rp->dfa == FALSE || try_backref) { + /* + * Passing NULL as last arg speeds up search for cases + * where we don't need the start/end info. + */ + res = re_search(&(rp->pat), str, start+len, + start, len, need_start ? &(rp->regs) : NULL); + } else + res = 1; + } else + res = -1; + + rp->pat.not_bol = 0; + return res; +} + +/* refree --- free up the dynamic memory used by a compiled regexp */ + +void +refree(Regexp *rp) +{ + if (rp == NULL) + return; + rp->pat.translate = NULL; + regfree(& rp->pat); + if (rp->regs.start) + free(rp->regs.start); + if (rp->regs.end) + free(rp->regs.end); + if (rp->dfa) { + dfafree(rp->dfareg); + free(rp->dfareg); + } + efree(rp); +} + +/* dfaerror --- print an error message for the dfa routines */ + +void +dfaerror(const char *s) +{ + fatal("%s", s); + exit(EXIT_FATAL); /* for DJGPP */ +} + +/* re_update --- recompile a dynamic regexp */ + +Regexp * +re_update(NODE *t) +{ + NODE *t1; + + if ((t->re_flags & CASE) == IGNORECASE) { + /* regex was compiled with settings matching IGNORECASE */ + if ((t->re_flags & CONSTANT) != 0) { + /* it's a constant, so just return it as is */ + assert(t->type == Node_regex); + return t->re_reg; + } + t1 = t->re_exp; + if (t->re_text != NULL) { + /* if contents haven't changed, just return it */ + if (cmp_nodes(t->re_text, t1) == 0) + return t->re_reg; + /* things changed, fall through to recompile */ + unref(t->re_text); + } + /* get fresh copy of the text of the regexp */ + t->re_text = dupnode(t1); + } + /* was compiled with different IGNORECASE or text changed */ + + /* free old */ + if (t->re_reg != NULL) + refree(t->re_reg); + if (t->re_cnt > 0) + t->re_cnt++; + if (t->re_cnt > 10) + t->re_cnt = 0; + if (t->re_text == NULL || (t->re_flags & CASE) != IGNORECASE) { + /* reset regexp text if needed */ + t1 = t->re_exp; + unref(t->re_text); + t->re_text = dupnode(t1); + } + /* compile it */ + t->re_reg = make_regexp(t->re_text->stptr, t->re_text->stlen, + IGNORECASE, t->re_cnt, TRUE); + + /* clear case flag */ + t->re_flags &= ~CASE; + /* set current value of case flag */ + t->re_flags |= IGNORECASE; + return t->re_reg; +} + +/* resetup --- choose what kind of regexps we match */ + +void +resetup() +{ + if (do_posix) + syn = RE_SYNTAX_POSIX_AWK; /* strict POSIX re's */ + else if (do_traditional) + syn = RE_SYNTAX_AWK; /* traditional Unix awk re's */ + else + syn = RE_SYNTAX_GNU_AWK; /* POSIX re's + GNU ops */ + + /* + * Interval expressions are now on by default, as POSIX is + * wide-spread enough that people want it. The do_intervals + * variable remains for use with --traditional. + */ + if (do_intervals) + syn |= RE_INTERVALS | RE_INVALID_INTERVAL_ORD; + + (void) re_set_syntax(syn); + dfasyntax(syn, FALSE, '\n'); +} + +/* avoid_dfa --- return true if we should not use the DFA matcher */ + +int +avoid_dfa(NODE *re, char *str, size_t len) +{ + char *end; + + if (! re->re_reg->has_anchor) + return FALSE; + + for (end = str + len; str < end; str++) + if (*str == '\n') + return TRUE; + + return FALSE; +} + +/* reisstring --- return TRUE if the RE match is a simple string match */ + +int +reisstring(const char *text, size_t len, Regexp *re, const char *buf) +{ + static char metas[] = ".*+(){}[]|?^$\\"; + int i; + int res; + const char *matched; + + /* simple checking for has meta characters in re */ + for (i = 0; i < len; i++) { + if (strchr(metas, text[i]) != NULL) { + return FALSE; /* give up early, can't be string match */ + } + } + + /* make accessable to gdb */ + matched = &buf[RESTART(re, buf)]; + + res = (memcmp(text, matched, len) == 0); + + return res; +} + +/* remaybelong --- return TRUE if the RE contains * ? | + */ + +int +remaybelong(const char *text, size_t len) +{ + while (len--) { + if (strchr("*+|?", *text++) != NULL) { + return TRUE; + } + } + + return FALSE; +} + +/* reflags2str --- make a regex flags value readable */ + +const char * +reflags2str(int flagval) +{ + static const struct flagtab values[] = { + { RE_BACKSLASH_ESCAPE_IN_LISTS, "RE_BACKSLASH_ESCAPE_IN_LISTS" }, + { RE_BK_PLUS_QM, "RE_BK_PLUS_QM" }, + { RE_CHAR_CLASSES, "RE_CHAR_CLASSES" }, + { RE_CONTEXT_INDEP_ANCHORS, "RE_CONTEXT_INDEP_ANCHORS" }, + { RE_CONTEXT_INDEP_OPS, "RE_CONTEXT_INDEP_OPS" }, + { RE_CONTEXT_INVALID_OPS, "RE_CONTEXT_INVALID_OPS" }, + { RE_DOT_NEWLINE, "RE_DOT_NEWLINE" }, + { RE_DOT_NOT_NULL, "RE_DOT_NOT_NULL" }, + { RE_HAT_LISTS_NOT_NEWLINE, "RE_HAT_LISTS_NOT_NEWLINE" }, + { RE_INTERVALS, "RE_INTERVALS" }, + { RE_LIMITED_OPS, "RE_LIMITED_OPS" }, + { RE_NEWLINE_ALT, "RE_NEWLINE_ALT" }, + { RE_NO_BK_BRACES, "RE_NO_BK_BRACES" }, + { RE_NO_BK_PARENS, "RE_NO_BK_PARENS" }, + { RE_NO_BK_REFS, "RE_NO_BK_REFS" }, + { RE_NO_BK_VBAR, "RE_NO_BK_VBAR" }, + { RE_NO_EMPTY_RANGES, "RE_NO_EMPTY_RANGES" }, + { RE_UNMATCHED_RIGHT_PAREN_ORD, "RE_UNMATCHED_RIGHT_PAREN_ORD" }, + { RE_NO_POSIX_BACKTRACKING, "RE_NO_POSIX_BACKTRACKING" }, + { RE_NO_GNU_OPS, "RE_NO_GNU_OPS" }, + { RE_INVALID_INTERVAL_ORD, "RE_INVALID_INTERVAL_ORD" }, + { RE_ICASE, "RE_ICASE" }, + { RE_CARET_ANCHORS_HERE, "RE_CARET_ANCHORS_HERE" }, + { RE_CONTEXT_INVALID_DUP, "RE_CONTEXT_INVALID_DUP" }, + { RE_NO_SUB, "RE_NO_SUB" }, + { 0, NULL }, + }; + + if (flagval == RE_SYNTAX_EMACS) /* == 0 */ + return "RE_SYNTAX_EMACS"; + + return genflags2str(flagval, values); +} + +/* + * dfawarn() is called by the dfa routines whenever a regex is compiled + * must supply a dfawarn. + */ + +void +dfawarn(const char *dfa_warning) +{ + /* + * This routine does nothing, since gawk does its own + * (better) check for bad [[:foo:]] syntax. + */ +} + +/* check_bracket_exp --- look for /[:space:]/ that should be /[[:space:]]/ */ + +static void +check_bracket_exp(char *s, size_t length) +{ + static struct reclass { + const char *name; + size_t len; + short warned; + } classes[] = { + /* + * Ordered by what we hope is frequency, + * since it's linear searched. + */ + { "[:alpha:]", 9, FALSE }, + { "[:digit:]", 9, FALSE }, + { "[:alnum:]", 9, FALSE }, + { "[:upper:]", 9, FALSE }, + { "[:lower:]", 9, FALSE }, + { "[:space:]", 9, FALSE }, + { "[:xdigit:]", 10, FALSE }, + { "[:punct:]", 9, FALSE }, + { "[:print:]", 9, FALSE }, + { "[:graph:]", 9, FALSE }, + { "[:cntrl:]", 9, FALSE }, + { "[:blank:]", 9, FALSE }, + { NULL, 0 } + }; + int i; + int found = FALSE; + char save; + char *sp, *sp2, *end; + int len; + int count = 0; + + if (length == 0) + return; + + end = s + length; + save = s[length]; + s[length] = '\0'; + sp = s; + +again: + sp = sp2 = memchr(sp, '[', (end - sp)); + if (sp == NULL) + goto done; + + for (count++, sp++; *sp != '\0'; sp++) { + static short range_warned = FALSE; + + if (*sp == '[') + count++; + else if (*sp == ']') + count--; + if (*sp == '-' && do_lint && ! range_warned && count == 1 + && sp[-1] != '[' && sp[1] != ']' + && ! isdigit((unsigned char) sp[-1]) && ! isdigit((unsigned char) sp[1]) + && ! (sp[-2] == '[' && sp[-1] == '^')) { + range_warned = TRUE; + warning(_("range of the form `[%c-%c]' is locale dependent"), + sp[-1], sp[1]); + } + if (count == 0) { + sp++; /* skip past ']' */ + break; + } + } + + if (count > 0) { /* bad regex, give up */ + goto done; + } + + /* sp2 has start */ + + for (i = 0; classes[i].name != NULL; i++) { + if (classes[i].warned) + continue; + len = classes[i].len; + if ( len == (sp - sp2) + && memcmp(sp2, classes[i].name, len) == 0) { + found = TRUE; + break; + } + } + + if (found && ! classes[i].warned) { + warning(_("regexp component `%.*s' should probably be `[%.*s]'"), + len, sp2, len, sp2); + classes[i].warned = TRUE; + } + + if (sp < end) { + found = FALSE; + goto again; + } +done: + s[length] = save; +} diff --git a/regcomp.c b/regcomp.c new file mode 100644 index 0000000..f83e454 --- /dev/null +++ b/regcomp.c @@ -0,0 +1,3932 @@ +/* Extended regular expression matching and search library. + Copyright (C) 2002-2007,2009,2010,2011,2012 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Isamu Hasegawa . + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern, + size_t length, reg_syntax_t syntax); +static void re_compile_fastmap_iter (regex_t *bufp, + const re_dfastate_t *init_state, + char *fastmap); +static reg_errcode_t init_dfa (re_dfa_t *dfa, size_t pat_len); +#ifdef RE_ENABLE_I18N +static void free_charset (re_charset_t *cset); +#endif /* RE_ENABLE_I18N */ +static void free_workarea_compile (regex_t *preg); +static reg_errcode_t create_initial_state (re_dfa_t *dfa); +#ifdef RE_ENABLE_I18N +static void optimize_utf8 (re_dfa_t *dfa); +#endif +static reg_errcode_t analyze (regex_t *preg); +static reg_errcode_t preorder (bin_tree_t *root, + reg_errcode_t (fn (void *, bin_tree_t *)), + void *extra); +static reg_errcode_t postorder (bin_tree_t *root, + reg_errcode_t (fn (void *, bin_tree_t *)), + void *extra); +static reg_errcode_t optimize_subexps (void *extra, bin_tree_t *node); +static reg_errcode_t lower_subexps (void *extra, bin_tree_t *node); +static bin_tree_t *lower_subexp (reg_errcode_t *err, regex_t *preg, + bin_tree_t *node); +static reg_errcode_t calc_first (void *extra, bin_tree_t *node); +static reg_errcode_t calc_next (void *extra, bin_tree_t *node); +static reg_errcode_t link_nfa_nodes (void *extra, bin_tree_t *node); +static int duplicate_node (re_dfa_t *dfa, int org_idx, unsigned int constraint); +static int search_duplicated_node (const re_dfa_t *dfa, int org_node, + unsigned int constraint); +static reg_errcode_t calc_eclosure (re_dfa_t *dfa); +static reg_errcode_t calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, + int node, int root); +static reg_errcode_t calc_inveclosure (re_dfa_t *dfa); +static int fetch_number (re_string_t *input, re_token_t *token, + reg_syntax_t syntax); +static int peek_token (re_token_t *token, re_string_t *input, + reg_syntax_t syntax) internal_function; +static bin_tree_t *parse (re_string_t *regexp, regex_t *preg, + reg_syntax_t syntax, reg_errcode_t *err); +static bin_tree_t *parse_reg_exp (re_string_t *regexp, regex_t *preg, + re_token_t *token, reg_syntax_t syntax, + int nest, reg_errcode_t *err); +static bin_tree_t *parse_branch (re_string_t *regexp, regex_t *preg, + re_token_t *token, reg_syntax_t syntax, + int nest, reg_errcode_t *err); +static bin_tree_t *parse_expression (re_string_t *regexp, regex_t *preg, + re_token_t *token, reg_syntax_t syntax, + int nest, reg_errcode_t *err); +static bin_tree_t *parse_sub_exp (re_string_t *regexp, regex_t *preg, + re_token_t *token, reg_syntax_t syntax, + int nest, reg_errcode_t *err); +static bin_tree_t *parse_dup_op (bin_tree_t *dup_elem, re_string_t *regexp, + re_dfa_t *dfa, re_token_t *token, + reg_syntax_t syntax, reg_errcode_t *err); +static bin_tree_t *parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, + re_token_t *token, reg_syntax_t syntax, + reg_errcode_t *err); +static reg_errcode_t parse_bracket_element (bracket_elem_t *elem, + re_string_t *regexp, + re_token_t *token, int token_len, + re_dfa_t *dfa, + reg_syntax_t syntax, + int accept_hyphen); +static reg_errcode_t parse_bracket_symbol (bracket_elem_t *elem, + re_string_t *regexp, + re_token_t *token); +#ifdef RE_ENABLE_I18N +static reg_errcode_t build_equiv_class (bitset_t sbcset, + re_charset_t *mbcset, + int *equiv_class_alloc, + const unsigned char *name); +static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans, + bitset_t sbcset, + re_charset_t *mbcset, + int *char_class_alloc, + const char *class_name, + reg_syntax_t syntax); +#else /* not RE_ENABLE_I18N */ +static reg_errcode_t build_equiv_class (bitset_t sbcset, + const unsigned char *name); +static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans, + bitset_t sbcset, + const char *class_name, + reg_syntax_t syntax); +#endif /* not RE_ENABLE_I18N */ +static bin_tree_t *build_charclass_op (re_dfa_t *dfa, + RE_TRANSLATE_TYPE trans, + const char *class_name, + const char *extra, + int non_match, reg_errcode_t *err); +static bin_tree_t *create_tree (re_dfa_t *dfa, + bin_tree_t *left, bin_tree_t *right, + re_token_type_t type); +static bin_tree_t *create_token_tree (re_dfa_t *dfa, + bin_tree_t *left, bin_tree_t *right, + const re_token_t *token); +static bin_tree_t *duplicate_tree (const bin_tree_t *src, re_dfa_t *dfa); +static void free_token (re_token_t *node); +static reg_errcode_t free_tree (void *extra, bin_tree_t *node); +static reg_errcode_t mark_opt_subexp (void *extra, bin_tree_t *node); + +/* This table gives an error message for each of the error codes listed + in regex.h. Obviously the order here has to be same as there. + POSIX doesn't require that we do anything for REG_NOERROR, + but why not be nice? */ + +const char __re_error_msgid[] attribute_hidden = + { +#define REG_NOERROR_IDX 0 + gettext_noop ("Success") /* REG_NOERROR */ + "\0" +#define REG_NOMATCH_IDX (REG_NOERROR_IDX + sizeof "Success") + gettext_noop ("No match") /* REG_NOMATCH */ + "\0" +#define REG_BADPAT_IDX (REG_NOMATCH_IDX + sizeof "No match") + gettext_noop ("Invalid regular expression") /* REG_BADPAT */ + "\0" +#define REG_ECOLLATE_IDX (REG_BADPAT_IDX + sizeof "Invalid regular expression") + gettext_noop ("Invalid collation character") /* REG_ECOLLATE */ + "\0" +#define REG_ECTYPE_IDX (REG_ECOLLATE_IDX + sizeof "Invalid collation character") + gettext_noop ("Invalid character class name") /* REG_ECTYPE */ + "\0" +#define REG_EESCAPE_IDX (REG_ECTYPE_IDX + sizeof "Invalid character class name") + gettext_noop ("Trailing backslash") /* REG_EESCAPE */ + "\0" +#define REG_ESUBREG_IDX (REG_EESCAPE_IDX + sizeof "Trailing backslash") + gettext_noop ("Invalid back reference") /* REG_ESUBREG */ + "\0" +#define REG_EBRACK_IDX (REG_ESUBREG_IDX + sizeof "Invalid back reference") + gettext_noop ("Unmatched [ or [^") /* REG_EBRACK */ + "\0" +#define REG_EPAREN_IDX (REG_EBRACK_IDX + sizeof "Unmatched [ or [^") + gettext_noop ("Unmatched ( or \\(") /* REG_EPAREN */ + "\0" +#define REG_EBRACE_IDX (REG_EPAREN_IDX + sizeof "Unmatched ( or \\(") + gettext_noop ("Unmatched \\{") /* REG_EBRACE */ + "\0" +#define REG_BADBR_IDX (REG_EBRACE_IDX + sizeof "Unmatched \\{") + gettext_noop ("Invalid content of \\{\\}") /* REG_BADBR */ + "\0" +#define REG_ERANGE_IDX (REG_BADBR_IDX + sizeof "Invalid content of \\{\\}") + gettext_noop ("Invalid range end") /* REG_ERANGE */ + "\0" +#define REG_ESPACE_IDX (REG_ERANGE_IDX + sizeof "Invalid range end") + gettext_noop ("Memory exhausted") /* REG_ESPACE */ + "\0" +#define REG_BADRPT_IDX (REG_ESPACE_IDX + sizeof "Memory exhausted") + gettext_noop ("Invalid preceding regular expression") /* REG_BADRPT */ + "\0" +#define REG_EEND_IDX (REG_BADRPT_IDX + sizeof "Invalid preceding regular expression") + gettext_noop ("Premature end of regular expression") /* REG_EEND */ + "\0" +#define REG_ESIZE_IDX (REG_EEND_IDX + sizeof "Premature end of regular expression") + gettext_noop ("Regular expression too big") /* REG_ESIZE */ + "\0" +#define REG_ERPAREN_IDX (REG_ESIZE_IDX + sizeof "Regular expression too big") + gettext_noop ("Unmatched ) or \\)") /* REG_ERPAREN */ + }; + +const size_t __re_error_msgid_idx[] attribute_hidden = + { + REG_NOERROR_IDX, + REG_NOMATCH_IDX, + REG_BADPAT_IDX, + REG_ECOLLATE_IDX, + REG_ECTYPE_IDX, + REG_EESCAPE_IDX, + REG_ESUBREG_IDX, + REG_EBRACK_IDX, + REG_EPAREN_IDX, + REG_EBRACE_IDX, + REG_BADBR_IDX, + REG_ERANGE_IDX, + REG_ESPACE_IDX, + REG_BADRPT_IDX, + REG_EEND_IDX, + REG_ESIZE_IDX, + REG_ERPAREN_IDX + }; + +/* Entry points for GNU code. */ + + +#ifdef ZOS_USS + +/* For ZOS USS we must define btowc */ + +wchar_t +btowc (int c) +{ + wchar_t wtmp[2]; + char tmp[2]; + mbstate_t mbs; + + memset(& mbs, 0, sizeof(mbs)); + tmp[0] = c; + tmp[1] = 0; + + mbrtowc (wtmp, tmp, 1, & mbs); + return wtmp[0]; +} +#endif + +/* re_compile_pattern is the GNU regular expression compiler: it + compiles PATTERN (of length LENGTH) and puts the result in BUFP. + Returns 0 if the pattern was valid, otherwise an error string. + + Assumes the `allocated' (and perhaps `buffer') and `translate' fields + are set in BUFP on entry. */ + +const char * +re_compile_pattern (pattern, length, bufp) + const char *pattern; + size_t length; + struct re_pattern_buffer *bufp; +{ + reg_errcode_t ret; + + /* And GNU code determines whether or not to get register information + by passing null for the REGS argument to re_match, etc., not by + setting no_sub, unless RE_NO_SUB is set. */ + bufp->no_sub = !!(re_syntax_options & RE_NO_SUB); + + /* Match anchors at newline. */ + bufp->newline_anchor = 1; + + ret = re_compile_internal (bufp, pattern, length, re_syntax_options); + + if (!ret) + return NULL; + return gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]); +} +#ifdef _LIBC +weak_alias (__re_compile_pattern, re_compile_pattern) +#endif + +/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can + also be assigned to arbitrarily: each pattern buffer stores its own + syntax, so it can be changed between regex compilations. */ +/* This has no initializer because initialized variables in Emacs + become read-only after dumping. */ +reg_syntax_t re_syntax_options; + + +/* Specify the precise syntax of regexps for compilation. This provides + for compatibility for various utilities which historically have + different, incompatible syntaxes. + + The argument SYNTAX is a bit mask comprised of the various bits + defined in regex.h. We return the old syntax. */ + +reg_syntax_t +re_set_syntax (syntax) + reg_syntax_t syntax; +{ + reg_syntax_t ret = re_syntax_options; + + re_syntax_options = syntax; + return ret; +} +#ifdef _LIBC +weak_alias (__re_set_syntax, re_set_syntax) +#endif + +int +re_compile_fastmap (bufp) + struct re_pattern_buffer *bufp; +{ + re_dfa_t *dfa = (re_dfa_t *) bufp->buffer; + char *fastmap = bufp->fastmap; + + memset (fastmap, '\0', sizeof (char) * SBC_MAX); + re_compile_fastmap_iter (bufp, dfa->init_state, fastmap); + if (dfa->init_state != dfa->init_state_word) + re_compile_fastmap_iter (bufp, dfa->init_state_word, fastmap); + if (dfa->init_state != dfa->init_state_nl) + re_compile_fastmap_iter (bufp, dfa->init_state_nl, fastmap); + if (dfa->init_state != dfa->init_state_begbuf) + re_compile_fastmap_iter (bufp, dfa->init_state_begbuf, fastmap); + bufp->fastmap_accurate = 1; + return 0; +} +#ifdef _LIBC +weak_alias (__re_compile_fastmap, re_compile_fastmap) +#endif + +static inline void +__attribute ((always_inline)) +re_set_fastmap (char *fastmap, int icase, int ch) +{ + fastmap[ch] = 1; + if (icase) + fastmap[tolower (ch)] = 1; +} + +/* Helper function for re_compile_fastmap. + Compile fastmap for the initial_state INIT_STATE. */ + +static void +re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state, + char *fastmap) +{ + volatile re_dfa_t *dfa = (re_dfa_t *) bufp->buffer; + int node_cnt; + int icase = (dfa->mb_cur_max == 1 && (bufp->syntax & RE_ICASE)); + for (node_cnt = 0; node_cnt < init_state->nodes.nelem; ++node_cnt) + { + int node = init_state->nodes.elems[node_cnt]; + re_token_type_t type = dfa->nodes[node].type; + + if (type == CHARACTER) + { + re_set_fastmap (fastmap, icase, dfa->nodes[node].opr.c); +#ifdef RE_ENABLE_I18N + if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1) + { + unsigned char *buf = re_malloc (unsigned char, dfa->mb_cur_max), *p; + wchar_t wc; + mbstate_t state; + + p = buf; + *p++ = dfa->nodes[node].opr.c; + while (++node < dfa->nodes_len + && dfa->nodes[node].type == CHARACTER + && dfa->nodes[node].mb_partial) + *p++ = dfa->nodes[node].opr.c; + memset (&state, '\0', sizeof (state)); + if (__mbrtowc (&wc, (const char *) buf, p - buf, + &state) == p - buf + && (__wcrtomb ((char *) buf, towlower (wc), &state) + != (size_t) -1)) + re_set_fastmap (fastmap, 0, buf[0]); + re_free (buf); + } +#endif + } + else if (type == SIMPLE_BRACKET) + { + int i, ch; + for (i = 0, ch = 0; i < BITSET_WORDS; ++i) + { + int j; + bitset_word_t w = dfa->nodes[node].opr.sbcset[i]; + for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch) + if (w & ((bitset_word_t) 1 << j)) + re_set_fastmap (fastmap, icase, ch); + } + } +#ifdef RE_ENABLE_I18N + else if (type == COMPLEX_BRACKET) + { + re_charset_t *cset = dfa->nodes[node].opr.mbcset; + int i; + +# ifdef _LIBC + /* See if we have to try all bytes which start multiple collation + elements. + e.g. In da_DK, we want to catch 'a' since "aa" is a valid + collation element, and don't catch 'b' since 'b' is + the only collation element which starts from 'b' (and + it is caught by SIMPLE_BRACKET). */ + if (_NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES) != 0 + && (cset->ncoll_syms || cset->nranges)) + { + const int32_t *table = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); + for (i = 0; i < SBC_MAX; ++i) + if (table[i] < 0) + re_set_fastmap (fastmap, icase, i); + } +# endif /* _LIBC */ + + /* See if we have to start the match at all multibyte characters, + i.e. where we would not find an invalid sequence. This only + applies to multibyte character sets; for single byte character + sets, the SIMPLE_BRACKET again suffices. */ + if (dfa->mb_cur_max > 1 + && (cset->nchar_classes || cset->non_match || cset->nranges +# ifdef _LIBC + || cset->nequiv_classes +# endif /* _LIBC */ + )) + { + unsigned char c = 0; + do + { + mbstate_t mbs; + memset (&mbs, 0, sizeof (mbs)); + if (__mbrtowc (NULL, (char *) &c, 1, &mbs) == (size_t) -2) + re_set_fastmap (fastmap, false, (int) c); + } + while (++c != 0); + } + + else + { + /* ... Else catch all bytes which can start the mbchars. */ + for (i = 0; i < cset->nmbchars; ++i) + { + char buf[256]; + mbstate_t state; + memset (&state, '\0', sizeof (state)); + if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1) + re_set_fastmap (fastmap, icase, *(unsigned char *) buf); + if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1) + { + if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state) + != (size_t) -1) + re_set_fastmap (fastmap, false, *(unsigned char *) buf); + } + } + } + } +#endif /* RE_ENABLE_I18N */ + else if (type == OP_PERIOD +#ifdef RE_ENABLE_I18N + || type == OP_UTF8_PERIOD +#endif /* RE_ENABLE_I18N */ + || type == END_OF_RE) + { + memset (fastmap, '\1', sizeof (char) * SBC_MAX); + if (type == END_OF_RE) + bufp->can_be_null = 1; + return; + } + } +} + +/* Entry point for POSIX code. */ +/* regcomp takes a regular expression as a string and compiles it. + + PREG is a regex_t *. We do not expect any fields to be initialized, + since POSIX says we shouldn't. Thus, we set + + `buffer' to the compiled pattern; + `used' to the length of the compiled pattern; + `syntax' to RE_SYNTAX_POSIX_EXTENDED if the + REG_EXTENDED bit in CFLAGS is set; otherwise, to + RE_SYNTAX_POSIX_BASIC; + `newline_anchor' to REG_NEWLINE being set in CFLAGS; + `fastmap' to an allocated space for the fastmap; + `fastmap_accurate' to zero; + `re_nsub' to the number of subexpressions in PATTERN. + + PATTERN is the address of the pattern string. + + CFLAGS is a series of bits which affect compilation. + + If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we + use POSIX basic syntax. + + If REG_NEWLINE is set, then . and [^...] don't match newline. + Also, regexec will try a match beginning after every newline. + + If REG_ICASE is set, then we considers upper- and lowercase + versions of letters to be equivalent when matching. + + If REG_NOSUB is set, then when PREG is passed to regexec, that + routine will report only success or failure, and nothing about the + registers. + + It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for + the return codes and their meanings.) */ + +int +regcomp (preg, pattern, cflags) + regex_t *__restrict preg; + const char *__restrict pattern; + int cflags; +{ + reg_errcode_t ret; + reg_syntax_t syntax = ((cflags & REG_EXTENDED) ? RE_SYNTAX_POSIX_EXTENDED + : RE_SYNTAX_POSIX_BASIC); + + preg->buffer = NULL; + preg->allocated = 0; + preg->used = 0; + + /* Try to allocate space for the fastmap. */ + preg->fastmap = re_malloc (char, SBC_MAX); + if (BE (preg->fastmap == NULL, 0)) + return REG_ESPACE; + + syntax |= (cflags & REG_ICASE) ? RE_ICASE : 0; + + /* If REG_NEWLINE is set, newlines are treated differently. */ + if (cflags & REG_NEWLINE) + { /* REG_NEWLINE implies neither . nor [^...] match newline. */ + syntax &= ~RE_DOT_NEWLINE; + syntax |= RE_HAT_LISTS_NOT_NEWLINE; + /* It also changes the matching behavior. */ + preg->newline_anchor = 1; + } + else + preg->newline_anchor = 0; + preg->no_sub = !!(cflags & REG_NOSUB); + preg->translate = NULL; + + ret = re_compile_internal (preg, pattern, strlen (pattern), syntax); + + /* POSIX doesn't distinguish between an unmatched open-group and an + unmatched close-group: both are REG_EPAREN. */ + if (ret == REG_ERPAREN) + ret = REG_EPAREN; + + /* We have already checked preg->fastmap != NULL. */ + if (BE (ret == REG_NOERROR, 1)) + /* Compute the fastmap now, since regexec cannot modify the pattern + buffer. This function never fails in this implementation. */ + (void) re_compile_fastmap (preg); + else + { + /* Some error occurred while compiling the expression. */ + re_free (preg->fastmap); + preg->fastmap = NULL; + } + + return (int) ret; +} +#ifdef _LIBC +weak_alias (__regcomp, regcomp) +#endif + +/* Returns a message corresponding to an error code, ERRCODE, returned + from either regcomp or regexec. We don't use PREG here. */ + +size_t +regerror (errcode, preg, errbuf, errbuf_size) + int errcode; + const regex_t *__restrict preg; + char *__restrict errbuf; + size_t errbuf_size; +{ + const char *msg; + size_t msg_size; + + if (BE (errcode < 0 + || errcode >= (int) (sizeof (__re_error_msgid_idx) + / sizeof (__re_error_msgid_idx[0])), 0)) + /* Only error codes returned by the rest of the code should be passed + to this routine. If we are given anything else, or if other regex + code generates an invalid error code, then the program has a bug. + Dump core so we can fix it. */ + abort (); + + msg = gettext (__re_error_msgid + __re_error_msgid_idx[errcode]); + + msg_size = strlen (msg) + 1; /* Includes the null. */ + + if (BE (errbuf_size != 0, 1)) + { + if (BE (msg_size > errbuf_size, 0)) + { + memcpy (errbuf, msg, errbuf_size - 1); + errbuf[errbuf_size - 1] = 0; + } + else + memcpy (errbuf, msg, msg_size); + } + + return msg_size; +} +#ifdef _LIBC +weak_alias (__regerror, regerror) +#endif + + +#ifdef RE_ENABLE_I18N +/* This static array is used for the map to single-byte characters when + UTF-8 is used. Otherwise we would allocate memory just to initialize + it the same all the time. UTF-8 is the preferred encoding so this is + a worthwhile optimization. */ +#if __GNUC__ >= 3 +static const bitset_t utf8_sb_map = { + /* Set the first 128 bits. */ + [0 ... 0x80 / BITSET_WORD_BITS - 1] = BITSET_WORD_MAX +}; +#else /* ! (__GNUC__ >= 3) */ +static bitset_t utf8_sb_map; +#endif /* __GNUC__ >= 3 */ +#endif /* RE_ENABLE_I18N */ + + +static void +free_dfa_content (re_dfa_t *dfa) +{ + int i, j; + + if (dfa->nodes) + for (i = 0; i < dfa->nodes_len; ++i) + free_token (dfa->nodes + i); + re_free (dfa->nexts); + for (i = 0; i < dfa->nodes_len; ++i) + { + if (dfa->eclosures != NULL) + re_node_set_free (dfa->eclosures + i); + if (dfa->inveclosures != NULL) + re_node_set_free (dfa->inveclosures + i); + if (dfa->edests != NULL) + re_node_set_free (dfa->edests + i); + } + re_free (dfa->edests); + re_free (dfa->eclosures); + re_free (dfa->inveclosures); + re_free (dfa->nodes); + + if (dfa->state_table) + for (i = 0; i <= dfa->state_hash_mask; ++i) + { + struct re_state_table_entry *entry = dfa->state_table + i; + for (j = 0; j < entry->num; ++j) + { + re_dfastate_t *state = entry->array[j]; + free_state (state); + } + re_free (entry->array); + } + re_free (dfa->state_table); +#ifdef RE_ENABLE_I18N + if (dfa->sb_char != utf8_sb_map) + re_free (dfa->sb_char); +#endif + re_free (dfa->subexp_map); +#ifdef DEBUG + re_free (dfa->re_str); +#endif + + re_free (dfa); +} + + +/* Free dynamically allocated space used by PREG. */ + +void +regfree (preg) + regex_t *preg; +{ + re_dfa_t *dfa = (re_dfa_t *) preg->buffer; + if (BE (dfa != NULL, 1)) + free_dfa_content (dfa); + preg->buffer = NULL; + preg->allocated = 0; + + re_free (preg->fastmap); + preg->fastmap = NULL; + + re_free (preg->translate); + preg->translate = NULL; +} +#ifdef _LIBC +weak_alias (__regfree, regfree) +#endif + +/* Entry points compatible with 4.2 BSD regex library. We don't define + them unless specifically requested. */ + +#if defined _REGEX_RE_COMP || defined _LIBC + +/* BSD has one and only one pattern buffer. */ +static struct re_pattern_buffer re_comp_buf; + +char * +# ifdef _LIBC +/* Make these definitions weak in libc, so POSIX programs can redefine + these names if they don't use our functions, and still use + regcomp/regexec above without link errors. */ +weak_function +# endif +re_comp (s) + const char *s; +{ + reg_errcode_t ret; + char *fastmap; + + if (!s) + { + if (!re_comp_buf.buffer) + return gettext ("No previous regular expression"); + return 0; + } + + if (re_comp_buf.buffer) + { + fastmap = re_comp_buf.fastmap; + re_comp_buf.fastmap = NULL; + __regfree (&re_comp_buf); + memset (&re_comp_buf, '\0', sizeof (re_comp_buf)); + re_comp_buf.fastmap = fastmap; + } + + if (re_comp_buf.fastmap == NULL) + { + re_comp_buf.fastmap = (char *) malloc (SBC_MAX); + if (re_comp_buf.fastmap == NULL) + return (char *) gettext (__re_error_msgid + + __re_error_msgid_idx[(int) REG_ESPACE]); + } + + /* Since `re_exec' always passes NULL for the `regs' argument, we + don't need to initialize the pattern buffer fields which affect it. */ + + /* Match anchors at newlines. */ + re_comp_buf.newline_anchor = 1; + + ret = re_compile_internal (&re_comp_buf, s, strlen (s), re_syntax_options); + + if (!ret) + return NULL; + + /* Yes, we're discarding `const' here if !HAVE_LIBINTL. */ + return (char *) gettext (__re_error_msgid + __re_error_msgid_idx[(int) ret]); +} + +#ifdef _LIBC +libc_freeres_fn (free_mem) +{ + __regfree (&re_comp_buf); +} +#endif + +#endif /* _REGEX_RE_COMP */ + +/* Internal entry point. + Compile the regular expression PATTERN, whose length is LENGTH. + SYNTAX indicate regular expression's syntax. */ + +static reg_errcode_t +re_compile_internal (regex_t *preg, const char * pattern, size_t length, + reg_syntax_t syntax) +{ + reg_errcode_t err = REG_NOERROR; + re_dfa_t *dfa; + re_string_t regexp; + + /* Initialize the pattern buffer. */ + preg->fastmap_accurate = 0; + preg->syntax = syntax; + preg->not_bol = preg->not_eol = 0; + preg->used = 0; + preg->re_nsub = 0; + preg->can_be_null = 0; + preg->regs_allocated = REGS_UNALLOCATED; + + /* Initialize the dfa. */ + dfa = (re_dfa_t *) preg->buffer; + if (BE (preg->allocated < sizeof (re_dfa_t), 0)) + { + /* If zero allocated, but buffer is non-null, try to realloc + enough space. This loses if buffer's address is bogus, but + that is the user's responsibility. If ->buffer is NULL this + is a simple allocation. */ + dfa = re_realloc (preg->buffer, re_dfa_t, 1); + if (dfa == NULL) + return REG_ESPACE; + preg->allocated = sizeof (re_dfa_t); + preg->buffer = (unsigned char *) dfa; + } + preg->used = sizeof (re_dfa_t); + + err = init_dfa (dfa, length); + if (BE (err != REG_NOERROR, 0)) + { + free_dfa_content (dfa); + preg->buffer = NULL; + preg->allocated = 0; + return err; + } +#ifdef DEBUG + /* Note: length+1 will not overflow since it is checked in init_dfa. */ + dfa->re_str = re_malloc (char, length + 1); + strncpy (dfa->re_str, pattern, length + 1); +#endif + + __libc_lock_init (dfa->lock); + + err = re_string_construct (®exp, pattern, length, preg->translate, + syntax & RE_ICASE, dfa); + if (BE (err != REG_NOERROR, 0)) + { + re_compile_internal_free_return: + free_workarea_compile (preg); + re_string_destruct (®exp); + free_dfa_content (dfa); + preg->buffer = NULL; + preg->allocated = 0; + return err; + } + + /* Parse the regular expression, and build a structure tree. */ + preg->re_nsub = 0; + dfa->str_tree = parse (®exp, preg, syntax, &err); + if (BE (dfa->str_tree == NULL, 0)) + goto re_compile_internal_free_return; + + /* Analyze the tree and create the nfa. */ + err = analyze (preg); + if (BE (err != REG_NOERROR, 0)) + goto re_compile_internal_free_return; + +#ifdef RE_ENABLE_I18N + /* If possible, do searching in single byte encoding to speed things up. */ + if (dfa->is_utf8 && !(syntax & RE_ICASE) && preg->translate == NULL) + optimize_utf8 (dfa); +#endif + + /* Then create the initial state of the dfa. */ + err = create_initial_state (dfa); + + /* Release work areas. */ + free_workarea_compile (preg); + re_string_destruct (®exp); + + if (BE (err != REG_NOERROR, 0)) + { + free_dfa_content (dfa); + preg->buffer = NULL; + preg->allocated = 0; + } + + return err; +} + +/* Initialize DFA. We use the length of the regular expression PAT_LEN + as the initial length of some arrays. */ + +static reg_errcode_t +init_dfa (re_dfa_t *dfa, size_t pat_len) +{ + unsigned int table_size; +#ifndef _LIBC + char *codeset_name; +#endif + + memset (dfa, '\0', sizeof (re_dfa_t)); + + /* Force allocation of str_tree_storage the first time. */ + dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE; + + /* Avoid overflows. */ + if (pat_len == SIZE_MAX) + return REG_ESPACE; + + dfa->nodes_alloc = pat_len + 1; + dfa->nodes = re_malloc (re_token_t, dfa->nodes_alloc); + + /* table_size = 2 ^ ceil(log pat_len) */ + for (table_size = 1; ; table_size <<= 1) + if (table_size > pat_len) + break; + + dfa->state_table = calloc (sizeof (struct re_state_table_entry), table_size); + dfa->state_hash_mask = table_size - 1; + + dfa->mb_cur_max = MB_CUR_MAX; +#ifdef _LIBC + if (dfa->mb_cur_max == 6 + && strcmp (_NL_CURRENT (LC_CTYPE, _NL_CTYPE_CODESET_NAME), "UTF-8") == 0) + dfa->is_utf8 = 1; + dfa->map_notascii = (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_TO_NONASCII) + != 0); +#else +# ifdef HAVE_LANGINFO_CODESET + codeset_name = nl_langinfo (CODESET); +# else + codeset_name = getenv ("LC_ALL"); + if (codeset_name == NULL || codeset_name[0] == '\0') + codeset_name = getenv ("LC_CTYPE"); + if (codeset_name == NULL || codeset_name[0] == '\0') + codeset_name = getenv ("LANG"); + if (codeset_name == NULL) + codeset_name = ""; + else if (strchr (codeset_name, '.') != NULL) + codeset_name = strchr (codeset_name, '.') + 1; +# endif + + /* strcasecmp isn't a standard interface. brute force check */ +#if 0 + if (strcasecmp (codeset_name, "UTF-8") == 0 + || strcasecmp (codeset_name, "UTF8") == 0) + dfa->is_utf8 = 1; +#else + if ( (codeset_name[0] == 'U' || codeset_name[0] == 'u') + && (codeset_name[1] == 'T' || codeset_name[1] == 't') + && (codeset_name[2] == 'F' || codeset_name[2] == 'f') + && (codeset_name[3] == '-' + ? codeset_name[4] == '8' && codeset_name[5] == '\0' + : codeset_name[3] == '8' && codeset_name[4] == '\0')) + dfa->is_utf8 = 1; +#endif + + /* We check exhaustively in the loop below if this charset is a + superset of ASCII. */ + dfa->map_notascii = 0; +#endif + +#ifdef RE_ENABLE_I18N + if (dfa->mb_cur_max > 1) + { + if (dfa->is_utf8) + { +#if !defined(__GNUC__) || __GNUC__ < 3 + static short utf8_sb_map_inited = 0; + + if (! utf8_sb_map_inited) + { + int i; + + utf8_sb_map_inited = 0; + for (i = 0; i <= 0x80 / BITSET_WORD_BITS - 1; i++) + utf8_sb_map[i] = BITSET_WORD_MAX; + } +#endif + dfa->sb_char = (re_bitset_ptr_t) utf8_sb_map; + } + else + { + int i, j, ch; + + dfa->sb_char = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); + if (BE (dfa->sb_char == NULL, 0)) + return REG_ESPACE; + + /* Set the bits corresponding to single byte chars. */ + for (i = 0, ch = 0; i < BITSET_WORDS; ++i) + for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch) + { + wint_t wch = __btowc (ch); + if (wch != WEOF) + dfa->sb_char[i] |= (bitset_word_t) 1 << j; +# ifndef _LIBC + if (isascii (ch) && wch != ch) + dfa->map_notascii = 1; +# endif + } + } + } +#endif + + if (BE (dfa->nodes == NULL || dfa->state_table == NULL, 0)) + return REG_ESPACE; + return REG_NOERROR; +} + +/* Initialize WORD_CHAR table, which indicate which character is + "word". In this case "word" means that it is the word construction + character used by some operators like "\<", "\>", etc. */ + +static void +internal_function +init_word_char (re_dfa_t *dfa) +{ + int i, j, ch; + dfa->word_ops_used = 1; +#ifndef GAWK + if (BE (dfa->map_notascii == 0, 1)) + { + if (sizeof (dfa->word_char[0]) == 8) + { + dfa->word_char[0] = UINT64_C (0x03ff000000000000); + dfa->word_char[1] = UINT64_C (0x07fffffe87fffffe); + i = 2; + } + else if (sizeof (dfa->word_char[0]) == 4) + { + dfa->word_char[0] = UINT32_C (0x00000000); + dfa->word_char[1] = UINT32_C (0x03ff0000); + dfa->word_char[2] = UINT32_C (0x87fffffe); + dfa->word_char[3] = UINT32_C (0x07fffffe); + i = 4; + } + else + abort (); + ch = 128; + + if (BE (dfa->is_utf8, 1)) + { + memset (&dfa->word_char[i], '\0', (SBC_MAX - ch) / 8); + return; + } + } +#endif + + for (i = 0, ch = 0; i < BITSET_WORDS; ++i) + for (j = 0; j < BITSET_WORD_BITS; ++j, ++ch) + if (isalnum (ch) || ch == '_') + dfa->word_char[i] |= (bitset_word_t) 1 << j; +} + +/* Free the work area which are only used while compiling. */ + +static void +free_workarea_compile (regex_t *preg) +{ + re_dfa_t *dfa = (re_dfa_t *) preg->buffer; + bin_tree_storage_t *storage, *next; + for (storage = dfa->str_tree_storage; storage; storage = next) + { + next = storage->next; + re_free (storage); + } + dfa->str_tree_storage = NULL; + dfa->str_tree_storage_idx = BIN_TREE_STORAGE_SIZE; + dfa->str_tree = NULL; + re_free (dfa->org_indices); + dfa->org_indices = NULL; +} + +/* Create initial states for all contexts. */ + +static reg_errcode_t +create_initial_state (re_dfa_t *dfa) +{ + int first, i; + reg_errcode_t err; + re_node_set init_nodes; + + /* Initial states have the epsilon closure of the node which is + the first node of the regular expression. */ + first = dfa->str_tree->first->node_idx; + dfa->init_node = first; + err = re_node_set_init_copy (&init_nodes, dfa->eclosures + first); + if (BE (err != REG_NOERROR, 0)) + return err; + + /* The back-references which are in initial states can epsilon transit, + since in this case all of the subexpressions can be null. + Then we add epsilon closures of the nodes which are the next nodes of + the back-references. */ + if (dfa->nbackref > 0) + for (i = 0; i < init_nodes.nelem; ++i) + { + int node_idx = init_nodes.elems[i]; + re_token_type_t type = dfa->nodes[node_idx].type; + + int clexp_idx; + if (type != OP_BACK_REF) + continue; + for (clexp_idx = 0; clexp_idx < init_nodes.nelem; ++clexp_idx) + { + re_token_t *clexp_node; + clexp_node = dfa->nodes + init_nodes.elems[clexp_idx]; + if (clexp_node->type == OP_CLOSE_SUBEXP + && clexp_node->opr.idx == dfa->nodes[node_idx].opr.idx) + break; + } + if (clexp_idx == init_nodes.nelem) + continue; + + if (type == OP_BACK_REF) + { + int dest_idx = dfa->edests[node_idx].elems[0]; + if (!re_node_set_contains (&init_nodes, dest_idx)) + { + reg_errcode_t err = re_node_set_merge (&init_nodes, + dfa->eclosures + + dest_idx); + if (err != REG_NOERROR) + return err; + i = 0; + } + } + } + + /* It must be the first time to invoke acquire_state. */ + dfa->init_state = re_acquire_state_context (&err, dfa, &init_nodes, 0); + /* We don't check ERR here, since the initial state must not be NULL. */ + if (BE (dfa->init_state == NULL, 0)) + return err; + if (dfa->init_state->has_constraint) + { + dfa->init_state_word = re_acquire_state_context (&err, dfa, &init_nodes, + CONTEXT_WORD); + dfa->init_state_nl = re_acquire_state_context (&err, dfa, &init_nodes, + CONTEXT_NEWLINE); + dfa->init_state_begbuf = re_acquire_state_context (&err, dfa, + &init_nodes, + CONTEXT_NEWLINE + | CONTEXT_BEGBUF); + if (BE (dfa->init_state_word == NULL || dfa->init_state_nl == NULL + || dfa->init_state_begbuf == NULL, 0)) + return err; + } + else + dfa->init_state_word = dfa->init_state_nl + = dfa->init_state_begbuf = dfa->init_state; + + re_node_set_free (&init_nodes); + return REG_NOERROR; +} + +#ifdef RE_ENABLE_I18N +/* If it is possible to do searching in single byte encoding instead of UTF-8 + to speed things up, set dfa->mb_cur_max to 1, clear is_utf8 and change + DFA nodes where needed. */ + +static void +optimize_utf8 (re_dfa_t *dfa) +{ + int node, i, mb_chars = 0, has_period = 0; + + for (node = 0; node < dfa->nodes_len; ++node) + switch (dfa->nodes[node].type) + { + case CHARACTER: + if (dfa->nodes[node].opr.c >= 0x80) + mb_chars = 1; + break; + case ANCHOR: + switch (dfa->nodes[node].opr.ctx_type) + { + case LINE_FIRST: + case LINE_LAST: + case BUF_FIRST: + case BUF_LAST: + break; + default: + /* Word anchors etc. cannot be handled. It's okay to test + opr.ctx_type since constraints (for all DFA nodes) are + created by ORing one or more opr.ctx_type values. */ + return; + } + break; + case OP_PERIOD: + has_period = 1; + break; + case OP_BACK_REF: + case OP_ALT: + case END_OF_RE: + case OP_DUP_ASTERISK: + case OP_OPEN_SUBEXP: + case OP_CLOSE_SUBEXP: + break; + case COMPLEX_BRACKET: + return; + case SIMPLE_BRACKET: + /* Just double check. The non-ASCII range starts at 0x80. */ + assert (0x80 % BITSET_WORD_BITS == 0); + for (i = 0x80 / BITSET_WORD_BITS; i < BITSET_WORDS; ++i) + if (dfa->nodes[node].opr.sbcset[i]) + return; + break; + default: + abort (); + } + + if (mb_chars || has_period) + for (node = 0; node < dfa->nodes_len; ++node) + { + if (dfa->nodes[node].type == CHARACTER + && dfa->nodes[node].opr.c >= 0x80) + dfa->nodes[node].mb_partial = 0; + else if (dfa->nodes[node].type == OP_PERIOD) + dfa->nodes[node].type = OP_UTF8_PERIOD; + } + + /* The search can be in single byte locale. */ + dfa->mb_cur_max = 1; + dfa->is_utf8 = 0; + dfa->has_mb_node = dfa->nbackref > 0 || has_period; +} +#endif + +/* Analyze the structure tree, and calculate "first", "next", "edest", + "eclosure", and "inveclosure". */ + +static reg_errcode_t +analyze (regex_t *preg) +{ + re_dfa_t *dfa = (re_dfa_t *) preg->buffer; + reg_errcode_t ret; + + /* Allocate arrays. */ + dfa->nexts = re_malloc (int, dfa->nodes_alloc); + dfa->org_indices = re_malloc (int, dfa->nodes_alloc); + dfa->edests = re_malloc (re_node_set, dfa->nodes_alloc); + dfa->eclosures = re_malloc (re_node_set, dfa->nodes_alloc); + if (BE (dfa->nexts == NULL || dfa->org_indices == NULL || dfa->edests == NULL + || dfa->eclosures == NULL, 0)) + return REG_ESPACE; + + dfa->subexp_map = re_malloc (int, preg->re_nsub); + if (dfa->subexp_map != NULL) + { + int i; + for (i = 0; i < preg->re_nsub; i++) + dfa->subexp_map[i] = i; + preorder (dfa->str_tree, optimize_subexps, dfa); + for (i = 0; i < preg->re_nsub; i++) + if (dfa->subexp_map[i] != i) + break; + if (i == preg->re_nsub) + { + free (dfa->subexp_map); + dfa->subexp_map = NULL; + } + } + + ret = postorder (dfa->str_tree, lower_subexps, preg); + if (BE (ret != REG_NOERROR, 0)) + return ret; + ret = postorder (dfa->str_tree, calc_first, dfa); + if (BE (ret != REG_NOERROR, 0)) + return ret; + preorder (dfa->str_tree, calc_next, dfa); + ret = preorder (dfa->str_tree, link_nfa_nodes, dfa); + if (BE (ret != REG_NOERROR, 0)) + return ret; + ret = calc_eclosure (dfa); + if (BE (ret != REG_NOERROR, 0)) + return ret; + + /* We only need this during the prune_impossible_nodes pass in regexec.c; + skip it if p_i_n will not run, as calc_inveclosure can be quadratic. */ + if ((!preg->no_sub && preg->re_nsub > 0 && dfa->has_plural_match) + || dfa->nbackref) + { + dfa->inveclosures = re_malloc (re_node_set, dfa->nodes_len); + if (BE (dfa->inveclosures == NULL, 0)) + return REG_ESPACE; + ret = calc_inveclosure (dfa); + } + + return ret; +} + +/* Our parse trees are very unbalanced, so we cannot use a stack to + implement parse tree visits. Instead, we use parent pointers and + some hairy code in these two functions. */ +static reg_errcode_t +postorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)), + void *extra) +{ + bin_tree_t *node, *prev; + + for (node = root; ; ) + { + /* Descend down the tree, preferably to the left (or to the right + if that's the only child). */ + while (node->left || node->right) + if (node->left) + node = node->left; + else + node = node->right; + + do + { + reg_errcode_t err = fn (extra, node); + if (BE (err != REG_NOERROR, 0)) + return err; + if (node->parent == NULL) + return REG_NOERROR; + prev = node; + node = node->parent; + } + /* Go up while we have a node that is reached from the right. */ + while (node->right == prev || node->right == NULL); + node = node->right; + } +} + +static reg_errcode_t +preorder (bin_tree_t *root, reg_errcode_t (fn (void *, bin_tree_t *)), + void *extra) +{ + bin_tree_t *node; + + for (node = root; ; ) + { + reg_errcode_t err = fn (extra, node); + if (BE (err != REG_NOERROR, 0)) + return err; + + /* Go to the left node, or up and to the right. */ + if (node->left) + node = node->left; + else + { + bin_tree_t *prev = NULL; + while (node->right == prev || node->right == NULL) + { + prev = node; + node = node->parent; + if (!node) + return REG_NOERROR; + } + node = node->right; + } + } +} + +/* Optimization pass: if a SUBEXP is entirely contained, strip it and tell + re_search_internal to map the inner one's opr.idx to this one's. Adjust + backreferences as well. Requires a preorder visit. */ +static reg_errcode_t +optimize_subexps (void *extra, bin_tree_t *node) +{ + re_dfa_t *dfa = (re_dfa_t *) extra; + + if (node->token.type == OP_BACK_REF && dfa->subexp_map) + { + int idx = node->token.opr.idx; + node->token.opr.idx = dfa->subexp_map[idx]; + dfa->used_bkref_map |= 1 << node->token.opr.idx; + } + + else if (node->token.type == SUBEXP + && node->left && node->left->token.type == SUBEXP) + { + int other_idx = node->left->token.opr.idx; + + node->left = node->left->left; + if (node->left) + node->left->parent = node; + + dfa->subexp_map[other_idx] = dfa->subexp_map[node->token.opr.idx]; + if (other_idx < BITSET_WORD_BITS) + dfa->used_bkref_map &= ~((bitset_word_t) 1 << other_idx); + } + + return REG_NOERROR; +} + +/* Lowering pass: Turn each SUBEXP node into the appropriate concatenation + of OP_OPEN_SUBEXP, the body of the SUBEXP (if any) and OP_CLOSE_SUBEXP. */ +static reg_errcode_t +lower_subexps (void *extra, bin_tree_t *node) +{ + regex_t *preg = (regex_t *) extra; + reg_errcode_t err = REG_NOERROR; + + if (node->left && node->left->token.type == SUBEXP) + { + node->left = lower_subexp (&err, preg, node->left); + if (node->left) + node->left->parent = node; + } + if (node->right && node->right->token.type == SUBEXP) + { + node->right = lower_subexp (&err, preg, node->right); + if (node->right) + node->right->parent = node; + } + + return err; +} + +static bin_tree_t * +lower_subexp (reg_errcode_t *err, regex_t *preg, bin_tree_t *node) +{ + re_dfa_t *dfa = (re_dfa_t *) preg->buffer; + bin_tree_t *body = node->left; + bin_tree_t *op, *cls, *tree1, *tree; + + if (preg->no_sub + /* We do not optimize empty subexpressions, because otherwise we may + have bad CONCAT nodes with NULL children. This is obviously not + very common, so we do not lose much. An example that triggers + this case is the sed "script" /\(\)/x. */ + && node->left != NULL + && (node->token.opr.idx >= BITSET_WORD_BITS + || !(dfa->used_bkref_map + & ((bitset_word_t) 1 << node->token.opr.idx)))) + return node->left; + + /* Convert the SUBEXP node to the concatenation of an + OP_OPEN_SUBEXP, the contents, and an OP_CLOSE_SUBEXP. */ + op = create_tree (dfa, NULL, NULL, OP_OPEN_SUBEXP); + cls = create_tree (dfa, NULL, NULL, OP_CLOSE_SUBEXP); + tree1 = body ? create_tree (dfa, body, cls, CONCAT) : cls; + tree = create_tree (dfa, op, tree1, CONCAT); + if (BE (tree == NULL || tree1 == NULL || op == NULL || cls == NULL, 0)) + { + *err = REG_ESPACE; + return NULL; + } + + op->token.opr.idx = cls->token.opr.idx = node->token.opr.idx; + op->token.opt_subexp = cls->token.opt_subexp = node->token.opt_subexp; + return tree; +} + +/* Pass 1 in building the NFA: compute FIRST and create unlinked automaton + nodes. Requires a postorder visit. */ +static reg_errcode_t +calc_first (void *extra, bin_tree_t *node) +{ + re_dfa_t *dfa = (re_dfa_t *) extra; + if (node->token.type == CONCAT) + { + node->first = node->left->first; + node->node_idx = node->left->node_idx; + } + else + { + node->first = node; + node->node_idx = re_dfa_add_node (dfa, node->token); + if (BE (node->node_idx == -1, 0)) + return REG_ESPACE; + if (node->token.type == ANCHOR) + dfa->nodes[node->node_idx].constraint = node->token.opr.ctx_type; + } + return REG_NOERROR; +} + +/* Pass 2: compute NEXT on the tree. Preorder visit. */ +static reg_errcode_t +calc_next (void *extra, bin_tree_t *node) +{ + switch (node->token.type) + { + case OP_DUP_ASTERISK: + node->left->next = node; + break; + case CONCAT: + node->left->next = node->right->first; + node->right->next = node->next; + break; + default: + if (node->left) + node->left->next = node->next; + if (node->right) + node->right->next = node->next; + break; + } + return REG_NOERROR; +} + +/* Pass 3: link all DFA nodes to their NEXT node (any order will do). */ +static reg_errcode_t +link_nfa_nodes (void *extra, bin_tree_t *node) +{ + re_dfa_t *dfa = (re_dfa_t *) extra; + int idx = node->node_idx; + reg_errcode_t err = REG_NOERROR; + + switch (node->token.type) + { + case CONCAT: + break; + + case END_OF_RE: + assert (node->next == NULL); + break; + + case OP_DUP_ASTERISK: + case OP_ALT: + { + int left, right; + dfa->has_plural_match = 1; + if (node->left != NULL) + left = node->left->first->node_idx; + else + left = node->next->node_idx; + if (node->right != NULL) + right = node->right->first->node_idx; + else + right = node->next->node_idx; + assert (left > -1); + assert (right > -1); + err = re_node_set_init_2 (dfa->edests + idx, left, right); + } + break; + + case ANCHOR: + case OP_OPEN_SUBEXP: + case OP_CLOSE_SUBEXP: + err = re_node_set_init_1 (dfa->edests + idx, node->next->node_idx); + break; + + case OP_BACK_REF: + dfa->nexts[idx] = node->next->node_idx; + if (node->token.type == OP_BACK_REF) + err = re_node_set_init_1 (dfa->edests + idx, dfa->nexts[idx]); + break; + + default: + assert (!IS_EPSILON_NODE (node->token.type)); + dfa->nexts[idx] = node->next->node_idx; + break; + } + + return err; +} + +/* Duplicate the epsilon closure of the node ROOT_NODE. + Note that duplicated nodes have constraint INIT_CONSTRAINT in addition + to their own constraint. */ + +static reg_errcode_t +internal_function +duplicate_node_closure (re_dfa_t *dfa, int top_org_node, int top_clone_node, + int root_node, unsigned int init_constraint) +{ + int org_node, clone_node, ret; + unsigned int constraint = init_constraint; + for (org_node = top_org_node, clone_node = top_clone_node;;) + { + int org_dest, clone_dest; + if (dfa->nodes[org_node].type == OP_BACK_REF) + { + /* If the back reference epsilon-transit, its destination must + also have the constraint. Then duplicate the epsilon closure + of the destination of the back reference, and store it in + edests of the back reference. */ + org_dest = dfa->nexts[org_node]; + re_node_set_empty (dfa->edests + clone_node); + clone_dest = duplicate_node (dfa, org_dest, constraint); + if (BE (clone_dest == -1, 0)) + return REG_ESPACE; + dfa->nexts[clone_node] = dfa->nexts[org_node]; + ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); + if (BE (ret < 0, 0)) + return REG_ESPACE; + } + else if (dfa->edests[org_node].nelem == 0) + { + /* In case of the node can't epsilon-transit, don't duplicate the + destination and store the original destination as the + destination of the node. */ + dfa->nexts[clone_node] = dfa->nexts[org_node]; + break; + } + else if (dfa->edests[org_node].nelem == 1) + { + /* In case of the node can epsilon-transit, and it has only one + destination. */ + org_dest = dfa->edests[org_node].elems[0]; + re_node_set_empty (dfa->edests + clone_node); + /* If the node is root_node itself, it means the epsilon clsoure + has a loop. Then tie it to the destination of the root_node. */ + if (org_node == root_node && clone_node != org_node) + { + ret = re_node_set_insert (dfa->edests + clone_node, org_dest); + if (BE (ret < 0, 0)) + return REG_ESPACE; + break; + } + /* In case of the node has another constraint, add it. */ + constraint |= dfa->nodes[org_node].constraint; + clone_dest = duplicate_node (dfa, org_dest, constraint); + if (BE (clone_dest == -1, 0)) + return REG_ESPACE; + ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); + if (BE (ret < 0, 0)) + return REG_ESPACE; + } + else /* dfa->edests[org_node].nelem == 2 */ + { + /* In case of the node can epsilon-transit, and it has two + destinations. In the bin_tree_t and DFA, that's '|' and '*'. */ + org_dest = dfa->edests[org_node].elems[0]; + re_node_set_empty (dfa->edests + clone_node); + /* Search for a duplicated node which satisfies the constraint. */ + clone_dest = search_duplicated_node (dfa, org_dest, constraint); + if (clone_dest == -1) + { + /* There is no such duplicated node, create a new one. */ + reg_errcode_t err; + clone_dest = duplicate_node (dfa, org_dest, constraint); + if (BE (clone_dest == -1, 0)) + return REG_ESPACE; + ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); + if (BE (ret < 0, 0)) + return REG_ESPACE; + err = duplicate_node_closure (dfa, org_dest, clone_dest, + root_node, constraint); + if (BE (err != REG_NOERROR, 0)) + return err; + } + else + { + /* There is a duplicated node which satisfies the constraint, + use it to avoid infinite loop. */ + ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); + if (BE (ret < 0, 0)) + return REG_ESPACE; + } + + org_dest = dfa->edests[org_node].elems[1]; + clone_dest = duplicate_node (dfa, org_dest, constraint); + if (BE (clone_dest == -1, 0)) + return REG_ESPACE; + ret = re_node_set_insert (dfa->edests + clone_node, clone_dest); + if (BE (ret < 0, 0)) + return REG_ESPACE; + } + org_node = org_dest; + clone_node = clone_dest; + } + return REG_NOERROR; +} + +/* Search for a node which is duplicated from the node ORG_NODE, and + satisfies the constraint CONSTRAINT. */ + +static int +search_duplicated_node (const re_dfa_t *dfa, int org_node, + unsigned int constraint) +{ + int idx; + for (idx = dfa->nodes_len - 1; dfa->nodes[idx].duplicated && idx > 0; --idx) + { + if (org_node == dfa->org_indices[idx] + && constraint == dfa->nodes[idx].constraint) + return idx; /* Found. */ + } + return -1; /* Not found. */ +} + +/* Duplicate the node whose index is ORG_IDX and set the constraint CONSTRAINT. + Return the index of the new node, or -1 if insufficient storage is + available. */ + +static int +duplicate_node (re_dfa_t *dfa, int org_idx, unsigned int constraint) +{ + int dup_idx = re_dfa_add_node (dfa, dfa->nodes[org_idx]); + if (BE (dup_idx != -1, 1)) + { + dfa->nodes[dup_idx].constraint = constraint; + dfa->nodes[dup_idx].constraint |= dfa->nodes[org_idx].constraint; + dfa->nodes[dup_idx].duplicated = 1; + + /* Store the index of the original node. */ + dfa->org_indices[dup_idx] = org_idx; + } + return dup_idx; +} + +static reg_errcode_t +calc_inveclosure (re_dfa_t *dfa) +{ + int src, idx, ret; + for (idx = 0; idx < dfa->nodes_len; ++idx) + re_node_set_init_empty (dfa->inveclosures + idx); + + for (src = 0; src < dfa->nodes_len; ++src) + { + int *elems = dfa->eclosures[src].elems; + for (idx = 0; idx < dfa->eclosures[src].nelem; ++idx) + { + ret = re_node_set_insert_last (dfa->inveclosures + elems[idx], src); + if (BE (ret == -1, 0)) + return REG_ESPACE; + } + } + + return REG_NOERROR; +} + +/* Calculate "eclosure" for all the node in DFA. */ + +static reg_errcode_t +calc_eclosure (re_dfa_t *dfa) +{ + int node_idx, incomplete; +#ifdef DEBUG + assert (dfa->nodes_len > 0); +#endif + incomplete = 0; + /* For each nodes, calculate epsilon closure. */ + for (node_idx = 0; ; ++node_idx) + { + reg_errcode_t err; + re_node_set eclosure_elem; + if (node_idx == dfa->nodes_len) + { + if (!incomplete) + break; + incomplete = 0; + node_idx = 0; + } + +#ifdef DEBUG + assert (dfa->eclosures[node_idx].nelem != -1); +#endif + + /* If we have already calculated, skip it. */ + if (dfa->eclosures[node_idx].nelem != 0) + continue; + /* Calculate epsilon closure of `node_idx'. */ + err = calc_eclosure_iter (&eclosure_elem, dfa, node_idx, 1); + if (BE (err != REG_NOERROR, 0)) + return err; + + if (dfa->eclosures[node_idx].nelem == 0) + { + incomplete = 1; + re_node_set_free (&eclosure_elem); + } + } + return REG_NOERROR; +} + +/* Calculate epsilon closure of NODE. */ + +static reg_errcode_t +calc_eclosure_iter (re_node_set *new_set, re_dfa_t *dfa, int node, int root) +{ + reg_errcode_t err; + int i; + re_node_set eclosure; + int ret; + int incomplete = 0; + err = re_node_set_alloc (&eclosure, dfa->edests[node].nelem + 1); + if (BE (err != REG_NOERROR, 0)) + return err; + + /* This indicates that we are calculating this node now. + We reference this value to avoid infinite loop. */ + dfa->eclosures[node].nelem = -1; + + /* If the current node has constraints, duplicate all nodes + since they must inherit the constraints. */ + if (dfa->nodes[node].constraint + && dfa->edests[node].nelem + && !dfa->nodes[dfa->edests[node].elems[0]].duplicated) + { + err = duplicate_node_closure (dfa, node, node, node, + dfa->nodes[node].constraint); + if (BE (err != REG_NOERROR, 0)) + return err; + } + + /* Expand each epsilon destination nodes. */ + if (IS_EPSILON_NODE(dfa->nodes[node].type)) + for (i = 0; i < dfa->edests[node].nelem; ++i) + { + re_node_set eclosure_elem; + int edest = dfa->edests[node].elems[i]; + /* If calculating the epsilon closure of `edest' is in progress, + return intermediate result. */ + if (dfa->eclosures[edest].nelem == -1) + { + incomplete = 1; + continue; + } + /* If we haven't calculated the epsilon closure of `edest' yet, + calculate now. Otherwise use calculated epsilon closure. */ + if (dfa->eclosures[edest].nelem == 0) + { + err = calc_eclosure_iter (&eclosure_elem, dfa, edest, 0); + if (BE (err != REG_NOERROR, 0)) + return err; + } + else + eclosure_elem = dfa->eclosures[edest]; + /* Merge the epsilon closure of `edest'. */ + err = re_node_set_merge (&eclosure, &eclosure_elem); + if (BE (err != REG_NOERROR, 0)) + return err; + /* If the epsilon closure of `edest' is incomplete, + the epsilon closure of this node is also incomplete. */ + if (dfa->eclosures[edest].nelem == 0) + { + incomplete = 1; + re_node_set_free (&eclosure_elem); + } + } + + /* An epsilon closure includes itself. */ + ret = re_node_set_insert (&eclosure, node); + if (BE (ret < 0, 0)) + return REG_ESPACE; + if (incomplete && !root) + dfa->eclosures[node].nelem = 0; + else + dfa->eclosures[node] = eclosure; + *new_set = eclosure; + return REG_NOERROR; +} + +/* Functions for token which are used in the parser. */ + +/* Fetch a token from INPUT. + We must not use this function inside bracket expressions. */ + +static void +internal_function +fetch_token (re_token_t *result, re_string_t *input, reg_syntax_t syntax) +{ + re_string_skip_bytes (input, peek_token (result, input, syntax)); +} + +/* Peek a token from INPUT, and return the length of the token. + We must not use this function inside bracket expressions. */ + +static int +internal_function +peek_token (re_token_t *token, re_string_t *input, reg_syntax_t syntax) +{ + unsigned char c; + + if (re_string_eoi (input)) + { + token->type = END_OF_RE; + return 0; + } + + c = re_string_peek_byte (input, 0); + token->opr.c = c; + + token->word_char = 0; +#ifdef RE_ENABLE_I18N + token->mb_partial = 0; + if (input->mb_cur_max > 1 && + !re_string_first_byte (input, re_string_cur_idx (input))) + { + token->type = CHARACTER; + token->mb_partial = 1; + return 1; + } +#endif + if (c == '\\') + { + unsigned char c2; + if (re_string_cur_idx (input) + 1 >= re_string_length (input)) + { + token->type = BACK_SLASH; + return 1; + } + + c2 = re_string_peek_byte_case (input, 1); + token->opr.c = c2; + token->type = CHARACTER; +#ifdef RE_ENABLE_I18N + if (input->mb_cur_max > 1) + { + wint_t wc = re_string_wchar_at (input, + re_string_cur_idx (input) + 1); + token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; + } + else +#endif + token->word_char = IS_WORD_CHAR (c2) != 0; + + switch (c2) + { + case '|': + if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_NO_BK_VBAR)) + token->type = OP_ALT; + break; + case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': + if (!(syntax & RE_NO_BK_REFS)) + { + token->type = OP_BACK_REF; + token->opr.idx = c2 - '1'; + } + break; + case '<': + if (!(syntax & RE_NO_GNU_OPS)) + { + token->type = ANCHOR; + token->opr.ctx_type = WORD_FIRST; + } + break; + case '>': + if (!(syntax & RE_NO_GNU_OPS)) + { + token->type = ANCHOR; + token->opr.ctx_type = WORD_LAST; + } + break; + case 'b': + if (!(syntax & RE_NO_GNU_OPS)) + { + token->type = ANCHOR; + token->opr.ctx_type = WORD_DELIM; + } + break; + case 'B': + if (!(syntax & RE_NO_GNU_OPS)) + { + token->type = ANCHOR; + token->opr.ctx_type = NOT_WORD_DELIM; + } + break; + case 'w': + if (!(syntax & RE_NO_GNU_OPS)) + token->type = OP_WORD; + break; + case 'W': + if (!(syntax & RE_NO_GNU_OPS)) + token->type = OP_NOTWORD; + break; + case 's': + if (!(syntax & RE_NO_GNU_OPS)) + token->type = OP_SPACE; + break; + case 'S': + if (!(syntax & RE_NO_GNU_OPS)) + token->type = OP_NOTSPACE; + break; + case '`': + if (!(syntax & RE_NO_GNU_OPS)) + { + token->type = ANCHOR; + token->opr.ctx_type = BUF_FIRST; + } + break; + case '\'': + if (!(syntax & RE_NO_GNU_OPS)) + { + token->type = ANCHOR; + token->opr.ctx_type = BUF_LAST; + } + break; + case '(': + if (!(syntax & RE_NO_BK_PARENS)) + token->type = OP_OPEN_SUBEXP; + break; + case ')': + if (!(syntax & RE_NO_BK_PARENS)) + token->type = OP_CLOSE_SUBEXP; + break; + case '+': + if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM)) + token->type = OP_DUP_PLUS; + break; + case '?': + if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_BK_PLUS_QM)) + token->type = OP_DUP_QUESTION; + break; + case '{': + if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES))) + token->type = OP_OPEN_DUP_NUM; + break; + case '}': + if ((syntax & RE_INTERVALS) && (!(syntax & RE_NO_BK_BRACES))) + token->type = OP_CLOSE_DUP_NUM; + break; + default: + break; + } + return 2; + } + + token->type = CHARACTER; +#ifdef RE_ENABLE_I18N + if (input->mb_cur_max > 1) + { + wint_t wc = re_string_wchar_at (input, re_string_cur_idx (input)); + token->word_char = IS_WIDE_WORD_CHAR (wc) != 0; + } + else +#endif + token->word_char = IS_WORD_CHAR (token->opr.c); + + switch (c) + { + case '\n': + if (syntax & RE_NEWLINE_ALT) + token->type = OP_ALT; + break; + case '|': + if (!(syntax & RE_LIMITED_OPS) && (syntax & RE_NO_BK_VBAR)) + token->type = OP_ALT; + break; + case '*': + token->type = OP_DUP_ASTERISK; + break; + case '+': + if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM)) + token->type = OP_DUP_PLUS; + break; + case '?': + if (!(syntax & RE_LIMITED_OPS) && !(syntax & RE_BK_PLUS_QM)) + token->type = OP_DUP_QUESTION; + break; + case '{': + if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) + token->type = OP_OPEN_DUP_NUM; + break; + case '}': + if ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES)) + token->type = OP_CLOSE_DUP_NUM; + break; + case '(': + if (syntax & RE_NO_BK_PARENS) + token->type = OP_OPEN_SUBEXP; + break; + case ')': + if (syntax & RE_NO_BK_PARENS) + token->type = OP_CLOSE_SUBEXP; + break; + case '[': + token->type = OP_OPEN_BRACKET; + break; + case '.': + token->type = OP_PERIOD; + break; + case '^': + if (!(syntax & (RE_CONTEXT_INDEP_ANCHORS | RE_CARET_ANCHORS_HERE)) && + re_string_cur_idx (input) != 0) + { + char prev = re_string_peek_byte (input, -1); + if (!(syntax & RE_NEWLINE_ALT) || prev != '\n') + break; + } + token->type = ANCHOR; + token->opr.ctx_type = LINE_FIRST; + break; + case '$': + if (!(syntax & RE_CONTEXT_INDEP_ANCHORS) && + re_string_cur_idx (input) + 1 != re_string_length (input)) + { + re_token_t next; + re_string_skip_bytes (input, 1); + peek_token (&next, input, syntax); + re_string_skip_bytes (input, -1); + if (next.type != OP_ALT && next.type != OP_CLOSE_SUBEXP) + break; + } + token->type = ANCHOR; + token->opr.ctx_type = LINE_LAST; + break; + default: + break; + } + return 1; +} + +/* Peek a token from INPUT, and return the length of the token. + We must not use this function out of bracket expressions. */ + +static int +internal_function +peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax) +{ + unsigned char c; + if (re_string_eoi (input)) + { + token->type = END_OF_RE; + return 0; + } + c = re_string_peek_byte (input, 0); + token->opr.c = c; + +#ifdef RE_ENABLE_I18N + if (input->mb_cur_max > 1 && + !re_string_first_byte (input, re_string_cur_idx (input))) + { + token->type = CHARACTER; + return 1; + } +#endif /* RE_ENABLE_I18N */ + + if (c == '\\' && (syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) + && re_string_cur_idx (input) + 1 < re_string_length (input)) + { + /* In this case, '\' escape a character. */ + unsigned char c2; + re_string_skip_bytes (input, 1); + c2 = re_string_peek_byte (input, 0); + token->opr.c = c2; + token->type = CHARACTER; + return 1; + } + if (c == '[') /* '[' is a special char in a bracket exps. */ + { + unsigned char c2; + int token_len; + if (re_string_cur_idx (input) + 1 < re_string_length (input)) + c2 = re_string_peek_byte (input, 1); + else + c2 = 0; + token->opr.c = c2; + token_len = 2; + switch (c2) + { + case '.': + token->type = OP_OPEN_COLL_ELEM; + break; + case '=': + token->type = OP_OPEN_EQUIV_CLASS; + break; + case ':': + if (syntax & RE_CHAR_CLASSES) + { + token->type = OP_OPEN_CHAR_CLASS; + break; + } + /* else fall through. */ + default: + token->type = CHARACTER; + token->opr.c = c; + token_len = 1; + break; + } + return token_len; + } + switch (c) + { + case '-': + token->type = OP_CHARSET_RANGE; + break; + case ']': + token->type = OP_CLOSE_BRACKET; + break; + case '^': + token->type = OP_NON_MATCH_LIST; + break; + default: + token->type = CHARACTER; + } + return 1; +} + +/* Functions for parser. */ + +/* Entry point of the parser. + Parse the regular expression REGEXP and return the structure tree. + If an error is occured, ERR is set by error code, and return NULL. + This function build the following tree, from regular expression : + CAT + / \ + / \ + EOR + + CAT means concatenation. + EOR means end of regular expression. */ + +static bin_tree_t * +parse (re_string_t *regexp, regex_t *preg, reg_syntax_t syntax, + reg_errcode_t *err) +{ + re_dfa_t *dfa = (re_dfa_t *) preg->buffer; + bin_tree_t *tree, *eor, *root; + re_token_t current_token; + dfa->syntax = syntax; + fetch_token (¤t_token, regexp, syntax | RE_CARET_ANCHORS_HERE); + tree = parse_reg_exp (regexp, preg, ¤t_token, syntax, 0, err); + if (BE (*err != REG_NOERROR && tree == NULL, 0)) + return NULL; + eor = create_tree (dfa, NULL, NULL, END_OF_RE); + if (tree != NULL) + root = create_tree (dfa, tree, eor, CONCAT); + else + root = eor; + if (BE (eor == NULL || root == NULL, 0)) + { + *err = REG_ESPACE; + return NULL; + } + return root; +} + +/* This function build the following tree, from regular expression + |: + ALT + / \ + / \ + + + ALT means alternative, which represents the operator `|'. */ + +static bin_tree_t * +parse_reg_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, + reg_syntax_t syntax, int nest, reg_errcode_t *err) +{ + re_dfa_t *dfa = (re_dfa_t *) preg->buffer; + bin_tree_t *tree, *branch = NULL; + tree = parse_branch (regexp, preg, token, syntax, nest, err); + if (BE (*err != REG_NOERROR && tree == NULL, 0)) + return NULL; + + while (token->type == OP_ALT) + { + fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE); + if (token->type != OP_ALT && token->type != END_OF_RE + && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) + { + branch = parse_branch (regexp, preg, token, syntax, nest, err); + if (BE (*err != REG_NOERROR && branch == NULL, 0)) + return NULL; + } + else + branch = NULL; + tree = create_tree (dfa, tree, branch, OP_ALT); + if (BE (tree == NULL, 0)) + { + *err = REG_ESPACE; + return NULL; + } + } + return tree; +} + +/* This function build the following tree, from regular expression + : + CAT + / \ + / \ + + + CAT means concatenation. */ + +static bin_tree_t * +parse_branch (re_string_t *regexp, regex_t *preg, re_token_t *token, + reg_syntax_t syntax, int nest, reg_errcode_t *err) +{ + bin_tree_t *tree, *exp; + re_dfa_t *dfa = (re_dfa_t *) preg->buffer; + tree = parse_expression (regexp, preg, token, syntax, nest, err); + if (BE (*err != REG_NOERROR && tree == NULL, 0)) + return NULL; + + while (token->type != OP_ALT && token->type != END_OF_RE + && (nest == 0 || token->type != OP_CLOSE_SUBEXP)) + { + exp = parse_expression (regexp, preg, token, syntax, nest, err); + if (BE (*err != REG_NOERROR && exp == NULL, 0)) + { + if (tree != NULL) + postorder (tree, free_tree, NULL); + return NULL; + } + if (tree != NULL && exp != NULL) + { + bin_tree_t *newtree = create_tree (dfa, tree, exp, CONCAT); + if (newtree == NULL) + { + postorder (exp, free_tree, NULL); + postorder (tree, free_tree, NULL); + *err = REG_ESPACE; + return NULL; + } + tree = newtree; + } + else if (tree == NULL) + tree = exp; + /* Otherwise exp == NULL, we don't need to create new tree. */ + } + return tree; +} + +/* This function build the following tree, from regular expression a*: + * + | + a +*/ + +static bin_tree_t * +parse_expression (re_string_t *regexp, regex_t *preg, re_token_t *token, + reg_syntax_t syntax, int nest, reg_errcode_t *err) +{ + re_dfa_t *dfa = (re_dfa_t *) preg->buffer; + bin_tree_t *tree; + switch (token->type) + { + case CHARACTER: + tree = create_token_tree (dfa, NULL, NULL, token); + if (BE (tree == NULL, 0)) + { + *err = REG_ESPACE; + return NULL; + } +#ifdef RE_ENABLE_I18N + if (dfa->mb_cur_max > 1) + { + while (!re_string_eoi (regexp) + && !re_string_first_byte (regexp, re_string_cur_idx (regexp))) + { + bin_tree_t *mbc_remain; + fetch_token (token, regexp, syntax); + mbc_remain = create_token_tree (dfa, NULL, NULL, token); + tree = create_tree (dfa, tree, mbc_remain, CONCAT); + if (BE (mbc_remain == NULL || tree == NULL, 0)) + { + *err = REG_ESPACE; + return NULL; + } + } + } +#endif + break; + case OP_OPEN_SUBEXP: + tree = parse_sub_exp (regexp, preg, token, syntax, nest + 1, err); + if (BE (*err != REG_NOERROR && tree == NULL, 0)) + return NULL; + break; + case OP_OPEN_BRACKET: + tree = parse_bracket_exp (regexp, dfa, token, syntax, err); + if (BE (*err != REG_NOERROR && tree == NULL, 0)) + return NULL; + break; + case OP_BACK_REF: + if (!BE (dfa->completed_bkref_map & (1 << token->opr.idx), 1)) + { + *err = REG_ESUBREG; + return NULL; + } + dfa->used_bkref_map |= 1 << token->opr.idx; + tree = create_token_tree (dfa, NULL, NULL, token); + if (BE (tree == NULL, 0)) + { + *err = REG_ESPACE; + return NULL; + } + ++dfa->nbackref; + dfa->has_mb_node = 1; + break; + case OP_OPEN_DUP_NUM: + if (syntax & RE_CONTEXT_INVALID_DUP) + { + *err = REG_BADRPT; + return NULL; + } + /* FALLTHROUGH */ + case OP_DUP_ASTERISK: + case OP_DUP_PLUS: + case OP_DUP_QUESTION: + if (syntax & RE_CONTEXT_INVALID_OPS) + { + *err = REG_BADRPT; + return NULL; + } + else if (syntax & RE_CONTEXT_INDEP_OPS) + { + fetch_token (token, regexp, syntax); + return parse_expression (regexp, preg, token, syntax, nest, err); + } + /* else fall through */ + case OP_CLOSE_SUBEXP: + if ((token->type == OP_CLOSE_SUBEXP) && + !(syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)) + { + *err = REG_ERPAREN; + return NULL; + } + /* else fall through */ + case OP_CLOSE_DUP_NUM: + /* We treat it as a normal character. */ + + /* Then we can these characters as normal characters. */ + token->type = CHARACTER; + /* mb_partial and word_char bits should be initialized already + by peek_token. */ + tree = create_token_tree (dfa, NULL, NULL, token); + if (BE (tree == NULL, 0)) + { + *err = REG_ESPACE; + return NULL; + } + break; + case ANCHOR: + if ((token->opr.ctx_type + & (WORD_DELIM | NOT_WORD_DELIM | WORD_FIRST | WORD_LAST)) + && dfa->word_ops_used == 0) + init_word_char (dfa); + if (token->opr.ctx_type == WORD_DELIM + || token->opr.ctx_type == NOT_WORD_DELIM) + { + bin_tree_t *tree_first, *tree_last; + if (token->opr.ctx_type == WORD_DELIM) + { + token->opr.ctx_type = WORD_FIRST; + tree_first = create_token_tree (dfa, NULL, NULL, token); + token->opr.ctx_type = WORD_LAST; + } + else + { + token->opr.ctx_type = INSIDE_WORD; + tree_first = create_token_tree (dfa, NULL, NULL, token); + token->opr.ctx_type = INSIDE_NOTWORD; + } + tree_last = create_token_tree (dfa, NULL, NULL, token); + tree = create_tree (dfa, tree_first, tree_last, OP_ALT); + if (BE (tree_first == NULL || tree_last == NULL || tree == NULL, 0)) + { + *err = REG_ESPACE; + return NULL; + } + } + else + { + tree = create_token_tree (dfa, NULL, NULL, token); + if (BE (tree == NULL, 0)) + { + *err = REG_ESPACE; + return NULL; + } + } + /* We must return here, since ANCHORs can't be followed + by repetition operators. + eg. RE"^*" is invalid or "", + it must not be "". */ + fetch_token (token, regexp, syntax); + return tree; + case OP_PERIOD: + tree = create_token_tree (dfa, NULL, NULL, token); + if (BE (tree == NULL, 0)) + { + *err = REG_ESPACE; + return NULL; + } + if (dfa->mb_cur_max > 1) + dfa->has_mb_node = 1; + break; + case OP_WORD: + case OP_NOTWORD: + tree = build_charclass_op (dfa, regexp->trans, + "alnum", + "_", + token->type == OP_NOTWORD, err); + if (BE (*err != REG_NOERROR && tree == NULL, 0)) + return NULL; + break; + case OP_SPACE: + case OP_NOTSPACE: + tree = build_charclass_op (dfa, regexp->trans, + "space", + "", + token->type == OP_NOTSPACE, err); + if (BE (*err != REG_NOERROR && tree == NULL, 0)) + return NULL; + break; + case OP_ALT: + case END_OF_RE: + return NULL; + case BACK_SLASH: + *err = REG_EESCAPE; + return NULL; + default: + /* Must not happen? */ +#ifdef DEBUG + assert (0); +#endif + return NULL; + } + fetch_token (token, regexp, syntax); + + while (token->type == OP_DUP_ASTERISK || token->type == OP_DUP_PLUS + || token->type == OP_DUP_QUESTION || token->type == OP_OPEN_DUP_NUM) + { + tree = parse_dup_op (tree, regexp, dfa, token, syntax, err); + if (BE (*err != REG_NOERROR && tree == NULL, 0)) + return NULL; + /* In BRE consecutive duplications are not allowed. */ + if ((syntax & RE_CONTEXT_INVALID_DUP) + && (token->type == OP_DUP_ASTERISK + || token->type == OP_OPEN_DUP_NUM)) + { + *err = REG_BADRPT; + return NULL; + } + } + + return tree; +} + +/* This function build the following tree, from regular expression + (): + SUBEXP + | + +*/ + +static bin_tree_t * +parse_sub_exp (re_string_t *regexp, regex_t *preg, re_token_t *token, + reg_syntax_t syntax, int nest, reg_errcode_t *err) +{ + re_dfa_t *dfa = (re_dfa_t *) preg->buffer; + bin_tree_t *tree; + size_t cur_nsub; + cur_nsub = preg->re_nsub++; + + fetch_token (token, regexp, syntax | RE_CARET_ANCHORS_HERE); + + /* The subexpression may be a null string. */ + if (token->type == OP_CLOSE_SUBEXP) + tree = NULL; + else + { + tree = parse_reg_exp (regexp, preg, token, syntax, nest, err); + if (BE (*err == REG_NOERROR && token->type != OP_CLOSE_SUBEXP, 0)) + { + if (tree != NULL) + postorder (tree, free_tree, NULL); + *err = REG_EPAREN; + } + if (BE (*err != REG_NOERROR, 0)) + return NULL; + } + + if (cur_nsub <= '9' - '1') + dfa->completed_bkref_map |= 1 << cur_nsub; + + tree = create_tree (dfa, tree, NULL, SUBEXP); + if (BE (tree == NULL, 0)) + { + *err = REG_ESPACE; + return NULL; + } + tree->token.opr.idx = cur_nsub; + return tree; +} + +/* This function parse repetition operators like "*", "+", "{1,3}" etc. */ + +static bin_tree_t * +parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, + re_token_t *token, reg_syntax_t syntax, reg_errcode_t *err) +{ + bin_tree_t *tree = NULL, *old_tree = NULL; + int i, start, end, start_idx = re_string_cur_idx (regexp); +#ifndef RE_TOKEN_INIT_BUG + re_token_t start_token = *token; +#else + re_token_t start_token; + + memcpy ((void *) &start_token, (void *) token, sizeof start_token); +#endif + + if (token->type == OP_OPEN_DUP_NUM) + { + end = 0; + start = fetch_number (regexp, token, syntax); + if (start == -1) + { + if (token->type == CHARACTER && token->opr.c == ',') + start = 0; /* We treat "{,m}" as "{0,m}". */ + else + { + *err = REG_BADBR; /* {} is invalid. */ + return NULL; + } + } + if (BE (start != -2, 1)) + { + /* We treat "{n}" as "{n,n}". */ + end = ((token->type == OP_CLOSE_DUP_NUM) ? start + : ((token->type == CHARACTER && token->opr.c == ',') + ? fetch_number (regexp, token, syntax) : -2)); + } + if (BE (start == -2 || end == -2, 0)) + { + /* Invalid sequence. */ + if (BE (!(syntax & RE_INVALID_INTERVAL_ORD), 0)) + { + if (token->type == END_OF_RE) + *err = REG_EBRACE; + else + *err = REG_BADBR; + + return NULL; + } + + /* If the syntax bit is set, rollback. */ + re_string_set_index (regexp, start_idx); + *token = start_token; + token->type = CHARACTER; + /* mb_partial and word_char bits should be already initialized by + peek_token. */ + return elem; + } + + if (BE ((end != -1 && start > end) || token->type != OP_CLOSE_DUP_NUM, 0)) + { + /* First number greater than second. */ + *err = REG_BADBR; + return NULL; + } + } + else + { + start = (token->type == OP_DUP_PLUS) ? 1 : 0; + end = (token->type == OP_DUP_QUESTION) ? 1 : -1; + } + + fetch_token (token, regexp, syntax); + + if (BE (elem == NULL, 0)) + return NULL; + if (BE (start == 0 && end == 0, 0)) + { + postorder (elem, free_tree, NULL); + return NULL; + } + + /* Extract "{n,m}" to "...{0,}". */ + if (BE (start > 0, 0)) + { + tree = elem; + for (i = 2; i <= start; ++i) + { + elem = duplicate_tree (elem, dfa); + tree = create_tree (dfa, tree, elem, CONCAT); + if (BE (elem == NULL || tree == NULL, 0)) + goto parse_dup_op_espace; + } + + if (start == end) + return tree; + + /* Duplicate ELEM before it is marked optional. */ + elem = duplicate_tree (elem, dfa); + old_tree = tree; + } + else + old_tree = NULL; + + if (elem->token.type == SUBEXP) + postorder (elem, mark_opt_subexp, (void *) (long) elem->token.opr.idx); + + tree = create_tree (dfa, elem, NULL, (end == -1 ? OP_DUP_ASTERISK : OP_ALT)); + if (BE (tree == NULL, 0)) + goto parse_dup_op_espace; + + /* This loop is actually executed only when end != -1, + to rewrite {0,n} as ((...?)?)?... We have + already created the start+1-th copy. */ + for (i = start + 2; i <= end; ++i) + { + elem = duplicate_tree (elem, dfa); + tree = create_tree (dfa, tree, elem, CONCAT); + if (BE (elem == NULL || tree == NULL, 0)) + goto parse_dup_op_espace; + + tree = create_tree (dfa, tree, NULL, OP_ALT); + if (BE (tree == NULL, 0)) + goto parse_dup_op_espace; + } + + if (old_tree) + tree = create_tree (dfa, old_tree, tree, CONCAT); + + return tree; + + parse_dup_op_espace: + *err = REG_ESPACE; + return NULL; +} + +/* Size of the names for collating symbol/equivalence_class/character_class. + I'm not sure, but maybe enough. */ +#define BRACKET_NAME_BUF_SIZE 32 + +#ifndef _LIBC + /* Local function for parse_bracket_exp only used in case of NOT _LIBC. + Build the range expression which starts from START_ELEM, and ends + at END_ELEM. The result are written to MBCSET and SBCSET. + RANGE_ALLOC is the allocated size of mbcset->range_starts, and + mbcset->range_ends, is a pointer argument sinse we may + update it. */ + +static reg_errcode_t +internal_function +# ifdef RE_ENABLE_I18N +build_range_exp (reg_syntax_t syntax, bitset_t sbcset, re_charset_t *mbcset, + int *range_alloc, bracket_elem_t *start_elem, + bracket_elem_t *end_elem) +# else /* not RE_ENABLE_I18N */ +build_range_exp (reg_syntax_t syntax, bitset_t sbcset, + bracket_elem_t *start_elem, bracket_elem_t *end_elem) +# endif /* not RE_ENABLE_I18N */ +{ + unsigned int start_ch, end_ch; + + /* Equivalence Classes and Character Classes can't be a range start/end. */ + if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS + || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, + 0)) + return REG_ERANGE; + + /* We can handle no multi character collating elements without libc + support. */ + if (BE ((start_elem->type == COLL_SYM + && strlen ((char *) start_elem->opr.name) > 1) + || (end_elem->type == COLL_SYM + && strlen ((char *) end_elem->opr.name) > 1), 0)) + return REG_ECOLLATE; + +# ifdef RE_ENABLE_I18N + { + wchar_t wc; + wint_t start_wc; + wint_t end_wc; + + start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch + : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0] + : 0)); + end_ch = ((end_elem->type == SB_CHAR) ? end_elem->opr.ch + : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0] + : 0)); +#ifdef GAWK + /* + * Fedora Core 2, maybe others, have broken `btowc' that returns -1 + * for any value > 127. Sigh. Note that `start_ch' and `end_ch' are + * unsigned, so we don't have sign extension problems. + */ + start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM) + ? start_ch : start_elem->opr.wch); + end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM) + ? end_ch : end_elem->opr.wch); +#else + start_wc = ((start_elem->type == SB_CHAR || start_elem->type == COLL_SYM) + ? __btowc (start_ch) : start_elem->opr.wch); + end_wc = ((end_elem->type == SB_CHAR || end_elem->type == COLL_SYM) + ? __btowc (end_ch) : end_elem->opr.wch); +#endif + if (start_wc == WEOF || end_wc == WEOF) + return REG_ECOLLATE; + else if ((syntax & RE_NO_EMPTY_RANGES) && start_wc > end_wc) + return REG_ERANGE; + + /* Got valid collation sequence values, add them as a new entry. + However, for !_LIBC we have no collation elements: if the + character set is single byte, the single byte character set + that we build below suffices. parse_bracket_exp passes + no MBCSET if dfa->mb_cur_max == 1. */ + if (mbcset) + { + /* Check the space of the arrays. */ + if (BE (*range_alloc == mbcset->nranges, 0)) + { + /* There is not enough space, need realloc. */ + wchar_t *new_array_start, *new_array_end; + int new_nranges; + + /* +1 in case of mbcset->nranges is 0. */ + new_nranges = 2 * mbcset->nranges + 1; + /* Use realloc since mbcset->range_starts and mbcset->range_ends + are NULL if *range_alloc == 0. */ + new_array_start = re_realloc (mbcset->range_starts, wchar_t, + new_nranges); + new_array_end = re_realloc (mbcset->range_ends, wchar_t, + new_nranges); + + if (BE (new_array_start == NULL || new_array_end == NULL, 0)) + return REG_ESPACE; + + mbcset->range_starts = new_array_start; + mbcset->range_ends = new_array_end; + *range_alloc = new_nranges; + } + + mbcset->range_starts[mbcset->nranges] = start_wc; + mbcset->range_ends[mbcset->nranges++] = end_wc; + } + + /* Build the table for single byte characters. */ + for (wc = 0; wc < SBC_MAX; ++wc) + { + if (start_wc <= wc && wc <= end_wc) + bitset_set (sbcset, wc); + } + } +# else /* not RE_ENABLE_I18N */ + { + unsigned int ch; + start_ch = ((start_elem->type == SB_CHAR ) ? start_elem->opr.ch + : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0] + : 0)); + end_ch = ((end_elem->type == SB_CHAR ) ? end_elem->opr.ch + : ((end_elem->type == COLL_SYM) ? end_elem->opr.name[0] + : 0)); + if (start_ch > end_ch) + return REG_ERANGE; + /* Build the table for single byte characters. */ + for (ch = 0; ch < SBC_MAX; ++ch) + if (start_ch <= ch && ch <= end_ch) + bitset_set (sbcset, ch); + } +# endif /* not RE_ENABLE_I18N */ + return REG_NOERROR; +} +#endif /* not _LIBC */ + +#ifndef _LIBC +/* Helper function for parse_bracket_exp only used in case of NOT _LIBC.. + Build the collating element which is represented by NAME. + The result are written to MBCSET and SBCSET. + COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a + pointer argument since we may update it. */ + +static reg_errcode_t +internal_function +# ifdef RE_ENABLE_I18N +build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset, + int *coll_sym_alloc, const unsigned char *name) +# else /* not RE_ENABLE_I18N */ +build_collating_symbol (bitset_t sbcset, const unsigned char *name) +# endif /* not RE_ENABLE_I18N */ +{ + size_t name_len = strlen ((const char *) name); + if (BE (name_len != 1, 0)) + return REG_ECOLLATE; + else + { + bitset_set (sbcset, name[0]); + return REG_NOERROR; + } +} +#endif /* not _LIBC */ + +/* This function parse bracket expression like "[abc]", "[a-c]", + "[[.a-a.]]" etc. */ + +static bin_tree_t * +parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, + reg_syntax_t syntax, reg_errcode_t *err) +{ +#ifdef _LIBC + const unsigned char *collseqmb; + const char *collseqwc; + uint32_t nrules; + int32_t table_size; + const int32_t *symb_table; + const unsigned char *extra; + + /* Local function for parse_bracket_exp used in _LIBC environement. + Seek the collating symbol entry correspondings to NAME. + Return the index of the symbol in the SYMB_TABLE. */ + + auto inline int32_t + __attribute ((always_inline)) + seek_collating_symbol_entry (name, name_len) + const unsigned char *name; + size_t name_len; + { + int32_t hash = elem_hash ((const char *) name, name_len); + int32_t elem = hash % table_size; + if (symb_table[2 * elem] != 0) + { + int32_t second = hash % (table_size - 2) + 1; + + do + { + /* First compare the hashing value. */ + if (symb_table[2 * elem] == hash + /* Compare the length of the name. */ + && name_len == extra[symb_table[2 * elem + 1]] + /* Compare the name. */ + && memcmp (name, &extra[symb_table[2 * elem + 1] + 1], + name_len) == 0) + { + /* Yep, this is the entry. */ + break; + } + + /* Next entry. */ + elem += second; + } + while (symb_table[2 * elem] != 0); + } + return elem; + } + + /* Local function for parse_bracket_exp used in _LIBC environment. + Look up the collation sequence value of BR_ELEM. + Return the value if succeeded, UINT_MAX otherwise. */ + + auto inline unsigned int + __attribute ((always_inline)) + lookup_collation_sequence_value (br_elem) + bracket_elem_t *br_elem; + { + if (br_elem->type == SB_CHAR) + { + /* + if (MB_CUR_MAX == 1) + */ + if (nrules == 0) + return collseqmb[br_elem->opr.ch]; + else + { + wint_t wc = __btowc (br_elem->opr.ch); + return __collseq_table_lookup (collseqwc, wc); + } + } + else if (br_elem->type == MB_CHAR) + { + if (nrules != 0) + return __collseq_table_lookup (collseqwc, br_elem->opr.wch); + } + else if (br_elem->type == COLL_SYM) + { + size_t sym_name_len = strlen ((char *) br_elem->opr.name); + if (nrules != 0) + { + int32_t elem, idx; + elem = seek_collating_symbol_entry (br_elem->opr.name, + sym_name_len); + if (symb_table[2 * elem] != 0) + { + /* We found the entry. */ + idx = symb_table[2 * elem + 1]; + /* Skip the name of collating element name. */ + idx += 1 + extra[idx]; + /* Skip the byte sequence of the collating element. */ + idx += 1 + extra[idx]; + /* Adjust for the alignment. */ + idx = (idx + 3) & ~3; + /* Skip the multibyte collation sequence value. */ + idx += sizeof (unsigned int); + /* Skip the wide char sequence of the collating element. */ + idx += sizeof (unsigned int) * + (1 + *(unsigned int *) (extra + idx)); + /* Return the collation sequence value. */ + return *(unsigned int *) (extra + idx); + } + else if (symb_table[2 * elem] == 0 && sym_name_len == 1) + { + /* No valid character. Match it as a single byte + character. */ + return collseqmb[br_elem->opr.name[0]]; + } + } + else if (sym_name_len == 1) + return collseqmb[br_elem->opr.name[0]]; + } + return UINT_MAX; + } + + /* Local function for parse_bracket_exp used in _LIBC environement. + Build the range expression which starts from START_ELEM, and ends + at END_ELEM. The result are written to MBCSET and SBCSET. + RANGE_ALLOC is the allocated size of mbcset->range_starts, and + mbcset->range_ends, is a pointer argument sinse we may + update it. */ + + auto inline reg_errcode_t + __attribute ((always_inline)) + build_range_exp (sbcset, mbcset, range_alloc, start_elem, end_elem) + re_charset_t *mbcset; + int *range_alloc; + bitset_t sbcset; + bracket_elem_t *start_elem, *end_elem; + { + unsigned int ch; + uint32_t start_collseq; + uint32_t end_collseq; + + /* Equivalence Classes and Character Classes can't be a range + start/end. */ + if (BE (start_elem->type == EQUIV_CLASS || start_elem->type == CHAR_CLASS + || end_elem->type == EQUIV_CLASS || end_elem->type == CHAR_CLASS, + 0)) + return REG_ERANGE; + + start_collseq = lookup_collation_sequence_value (start_elem); + end_collseq = lookup_collation_sequence_value (end_elem); + /* Check start/end collation sequence values. */ + if (BE (start_collseq == UINT_MAX || end_collseq == UINT_MAX, 0)) + return REG_ECOLLATE; + if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_collseq > end_collseq, 0)) + return REG_ERANGE; + + /* Got valid collation sequence values, add them as a new entry. + However, if we have no collation elements, and the character set + is single byte, the single byte character set that we + build below suffices. */ + if (nrules > 0 || dfa->mb_cur_max > 1) + { + /* Check the space of the arrays. */ + if (BE (*range_alloc == mbcset->nranges, 0)) + { + /* There is not enough space, need realloc. */ + uint32_t *new_array_start; + uint32_t *new_array_end; + int new_nranges; + + /* +1 in case of mbcset->nranges is 0. */ + new_nranges = 2 * mbcset->nranges + 1; + new_array_start = re_realloc (mbcset->range_starts, uint32_t, + new_nranges); + new_array_end = re_realloc (mbcset->range_ends, uint32_t, + new_nranges); + + if (BE (new_array_start == NULL || new_array_end == NULL, 0)) + return REG_ESPACE; + + mbcset->range_starts = new_array_start; + mbcset->range_ends = new_array_end; + *range_alloc = new_nranges; + } + + mbcset->range_starts[mbcset->nranges] = start_collseq; + mbcset->range_ends[mbcset->nranges++] = end_collseq; + } + + /* Build the table for single byte characters. */ + for (ch = 0; ch < SBC_MAX; ch++) + { + uint32_t ch_collseq; + /* + if (MB_CUR_MAX == 1) + */ + if (nrules == 0) + ch_collseq = collseqmb[ch]; + else + ch_collseq = __collseq_table_lookup (collseqwc, __btowc (ch)); + if (start_collseq <= ch_collseq && ch_collseq <= end_collseq) + bitset_set (sbcset, ch); + } + return REG_NOERROR; + } + + /* Local function for parse_bracket_exp used in _LIBC environement. + Build the collating element which is represented by NAME. + The result are written to MBCSET and SBCSET. + COLL_SYM_ALLOC is the allocated size of mbcset->coll_sym, is a + pointer argument sinse we may update it. */ + + auto inline reg_errcode_t + __attribute ((always_inline)) + build_collating_symbol (sbcset, mbcset, coll_sym_alloc, name) + re_charset_t *mbcset; + int *coll_sym_alloc; + bitset_t sbcset; + const unsigned char *name; + { + int32_t elem, idx; + size_t name_len = strlen ((const char *) name); + if (nrules != 0) + { + elem = seek_collating_symbol_entry (name, name_len); + if (symb_table[2 * elem] != 0) + { + /* We found the entry. */ + idx = symb_table[2 * elem + 1]; + /* Skip the name of collating element name. */ + idx += 1 + extra[idx]; + } + else if (symb_table[2 * elem] == 0 && name_len == 1) + { + /* No valid character, treat it as a normal + character. */ + bitset_set (sbcset, name[0]); + return REG_NOERROR; + } + else + return REG_ECOLLATE; + + /* Got valid collation sequence, add it as a new entry. */ + /* Check the space of the arrays. */ + if (BE (*coll_sym_alloc == mbcset->ncoll_syms, 0)) + { + /* Not enough, realloc it. */ + /* +1 in case of mbcset->ncoll_syms is 0. */ + int new_coll_sym_alloc = 2 * mbcset->ncoll_syms + 1; + /* Use realloc since mbcset->coll_syms is NULL + if *alloc == 0. */ + int32_t *new_coll_syms = re_realloc (mbcset->coll_syms, int32_t, + new_coll_sym_alloc); + if (BE (new_coll_syms == NULL, 0)) + return REG_ESPACE; + mbcset->coll_syms = new_coll_syms; + *coll_sym_alloc = new_coll_sym_alloc; + } + mbcset->coll_syms[mbcset->ncoll_syms++] = idx; + return REG_NOERROR; + } + else + { + if (BE (name_len != 1, 0)) + return REG_ECOLLATE; + else + { + bitset_set (sbcset, name[0]); + return REG_NOERROR; + } + } + } +#endif + + re_token_t br_token; + re_bitset_ptr_t sbcset; +#ifdef RE_ENABLE_I18N + re_charset_t *mbcset; + int coll_sym_alloc = 0, range_alloc = 0, mbchar_alloc = 0; + int equiv_class_alloc = 0, char_class_alloc = 0; +#endif /* not RE_ENABLE_I18N */ + int non_match = 0; + bin_tree_t *work_tree; + int token_len; + int first_round = 1; +#ifdef _LIBC + collseqmb = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB); + nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); + if (nrules) + { + /* + if (MB_CUR_MAX > 1) + */ + collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC); + table_size = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_SYMB_HASH_SIZEMB); + symb_table = (const int32_t *) _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_SYMB_TABLEMB); + extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_SYMB_EXTRAMB); + } +#endif + sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); +#ifdef RE_ENABLE_I18N + mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); +#endif /* RE_ENABLE_I18N */ +#ifdef RE_ENABLE_I18N + if (BE (sbcset == NULL || mbcset == NULL, 0)) +#else + if (BE (sbcset == NULL, 0)) +#endif /* RE_ENABLE_I18N */ + { + re_free (sbcset); +#ifdef RE_ENABLE_I18N + re_free (mbcset); +#endif + *err = REG_ESPACE; + return NULL; + } + + token_len = peek_token_bracket (token, regexp, syntax); + if (BE (token->type == END_OF_RE, 0)) + { + *err = REG_BADPAT; + goto parse_bracket_exp_free_return; + } + if (token->type == OP_NON_MATCH_LIST) + { +#ifdef RE_ENABLE_I18N + mbcset->non_match = 1; +#endif /* not RE_ENABLE_I18N */ + non_match = 1; + if (syntax & RE_HAT_LISTS_NOT_NEWLINE) + bitset_set (sbcset, '\n'); + re_string_skip_bytes (regexp, token_len); /* Skip a token. */ + token_len = peek_token_bracket (token, regexp, syntax); + if (BE (token->type == END_OF_RE, 0)) + { + *err = REG_BADPAT; + goto parse_bracket_exp_free_return; + } + } + + /* We treat the first ']' as a normal character. */ + if (token->type == OP_CLOSE_BRACKET) + token->type = CHARACTER; + + while (1) + { + bracket_elem_t start_elem, end_elem; + unsigned char start_name_buf[BRACKET_NAME_BUF_SIZE]; + unsigned char end_name_buf[BRACKET_NAME_BUF_SIZE]; + reg_errcode_t ret; + int token_len2 = 0, is_range_exp = 0; + re_token_t token2; + + start_elem.opr.name = start_name_buf; + ret = parse_bracket_element (&start_elem, regexp, token, token_len, dfa, + syntax, first_round); + if (BE (ret != REG_NOERROR, 0)) + { + *err = ret; + goto parse_bracket_exp_free_return; + } + first_round = 0; + + /* Get information about the next token. We need it in any case. */ + token_len = peek_token_bracket (token, regexp, syntax); + + /* Do not check for ranges if we know they are not allowed. */ + if (start_elem.type != CHAR_CLASS && start_elem.type != EQUIV_CLASS) + { + if (BE (token->type == END_OF_RE, 0)) + { + *err = REG_EBRACK; + goto parse_bracket_exp_free_return; + } + if (token->type == OP_CHARSET_RANGE) + { + re_string_skip_bytes (regexp, token_len); /* Skip '-'. */ + token_len2 = peek_token_bracket (&token2, regexp, syntax); + if (BE (token2.type == END_OF_RE, 0)) + { + *err = REG_EBRACK; + goto parse_bracket_exp_free_return; + } + if (token2.type == OP_CLOSE_BRACKET) + { + /* We treat the last '-' as a normal character. */ + re_string_skip_bytes (regexp, -token_len); + token->type = CHARACTER; + } + else + is_range_exp = 1; + } + } + + if (is_range_exp == 1) + { + end_elem.opr.name = end_name_buf; + ret = parse_bracket_element (&end_elem, regexp, &token2, token_len2, + dfa, syntax, 1); + if (BE (ret != REG_NOERROR, 0)) + { + *err = ret; + goto parse_bracket_exp_free_return; + } + + token_len = peek_token_bracket (token, regexp, syntax); + +#ifdef _LIBC + *err = build_range_exp (syntax, sbcset, mbcset, &range_alloc, + &start_elem, &end_elem); +#else +# ifdef RE_ENABLE_I18N + *err = build_range_exp (syntax, sbcset, + dfa->mb_cur_max > 1 ? mbcset : NULL, + &range_alloc, &start_elem, &end_elem); +# else + *err = build_range_exp (syntax, sbcset, &start_elem, &end_elem); +# endif +#endif /* RE_ENABLE_I18N */ + if (BE (*err != REG_NOERROR, 0)) + goto parse_bracket_exp_free_return; + } + else + { + switch (start_elem.type) + { + case SB_CHAR: + bitset_set (sbcset, start_elem.opr.ch); + break; +#ifdef RE_ENABLE_I18N + case MB_CHAR: + /* Check whether the array has enough space. */ + if (BE (mbchar_alloc == mbcset->nmbchars, 0)) + { + wchar_t *new_mbchars; + /* Not enough, realloc it. */ + /* +1 in case of mbcset->nmbchars is 0. */ + mbchar_alloc = 2 * mbcset->nmbchars + 1; + /* Use realloc since array is NULL if *alloc == 0. */ + new_mbchars = re_realloc (mbcset->mbchars, wchar_t, + mbchar_alloc); + if (BE (new_mbchars == NULL, 0)) + goto parse_bracket_exp_espace; + mbcset->mbchars = new_mbchars; + } + mbcset->mbchars[mbcset->nmbchars++] = start_elem.opr.wch; + break; +#endif /* RE_ENABLE_I18N */ + case EQUIV_CLASS: + *err = build_equiv_class (sbcset, +#ifdef RE_ENABLE_I18N + mbcset, &equiv_class_alloc, +#endif /* RE_ENABLE_I18N */ + start_elem.opr.name); + if (BE (*err != REG_NOERROR, 0)) + goto parse_bracket_exp_free_return; + break; + case COLL_SYM: + *err = build_collating_symbol (sbcset, +#ifdef RE_ENABLE_I18N + mbcset, &coll_sym_alloc, +#endif /* RE_ENABLE_I18N */ + start_elem.opr.name); + if (BE (*err != REG_NOERROR, 0)) + goto parse_bracket_exp_free_return; + break; + case CHAR_CLASS: + *err = build_charclass (regexp->trans, sbcset, +#ifdef RE_ENABLE_I18N + mbcset, &char_class_alloc, +#endif /* RE_ENABLE_I18N */ + (const char *) start_elem.opr.name, syntax); + if (BE (*err != REG_NOERROR, 0)) + goto parse_bracket_exp_free_return; + break; + default: + assert (0); + break; + } + } + if (BE (token->type == END_OF_RE, 0)) + { + *err = REG_EBRACK; + goto parse_bracket_exp_free_return; + } + if (token->type == OP_CLOSE_BRACKET) + break; + } + + re_string_skip_bytes (regexp, token_len); /* Skip a token. */ + + /* If it is non-matching list. */ + if (non_match) + bitset_not (sbcset); + +#ifdef RE_ENABLE_I18N + /* Ensure only single byte characters are set. */ + if (dfa->mb_cur_max > 1) + bitset_mask (sbcset, dfa->sb_char); + + if (mbcset->nmbchars || mbcset->ncoll_syms || mbcset->nequiv_classes + || mbcset->nranges || (dfa->mb_cur_max > 1 && (mbcset->nchar_classes + || mbcset->non_match))) + { + bin_tree_t *mbc_tree; + int sbc_idx; + /* Build a tree for complex bracket. */ + dfa->has_mb_node = 1; + br_token.type = COMPLEX_BRACKET; + br_token.opr.mbcset = mbcset; + mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); + if (BE (mbc_tree == NULL, 0)) + goto parse_bracket_exp_espace; + for (sbc_idx = 0; sbc_idx < BITSET_WORDS; ++sbc_idx) + if (sbcset[sbc_idx]) + break; + /* If there are no bits set in sbcset, there is no point + of having both SIMPLE_BRACKET and COMPLEX_BRACKET. */ + if (sbc_idx < BITSET_WORDS) + { + /* Build a tree for simple bracket. */ + br_token.type = SIMPLE_BRACKET; + br_token.opr.sbcset = sbcset; + work_tree = create_token_tree (dfa, NULL, NULL, &br_token); + if (BE (work_tree == NULL, 0)) + goto parse_bracket_exp_espace; + + /* Then join them by ALT node. */ + work_tree = create_tree (dfa, work_tree, mbc_tree, OP_ALT); + if (BE (work_tree == NULL, 0)) + goto parse_bracket_exp_espace; + } + else + { + re_free (sbcset); + work_tree = mbc_tree; + } + } + else +#endif /* not RE_ENABLE_I18N */ + { +#ifdef RE_ENABLE_I18N + free_charset (mbcset); +#endif + /* Build a tree for simple bracket. */ + br_token.type = SIMPLE_BRACKET; + br_token.opr.sbcset = sbcset; + work_tree = create_token_tree (dfa, NULL, NULL, &br_token); + if (BE (work_tree == NULL, 0)) + goto parse_bracket_exp_espace; + } + return work_tree; + + parse_bracket_exp_espace: + *err = REG_ESPACE; + parse_bracket_exp_free_return: + re_free (sbcset); +#ifdef RE_ENABLE_I18N + free_charset (mbcset); +#endif /* RE_ENABLE_I18N */ + return NULL; +} + +/* Parse an element in the bracket expression. */ + +static reg_errcode_t +parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp, + re_token_t *token, int token_len, re_dfa_t *dfa, + reg_syntax_t syntax, int accept_hyphen) +{ +#ifdef RE_ENABLE_I18N + int cur_char_size; + cur_char_size = re_string_char_size_at (regexp, re_string_cur_idx (regexp)); + if (cur_char_size > 1) + { + elem->type = MB_CHAR; + elem->opr.wch = re_string_wchar_at (regexp, re_string_cur_idx (regexp)); + re_string_skip_bytes (regexp, cur_char_size); + return REG_NOERROR; + } +#endif /* RE_ENABLE_I18N */ + re_string_skip_bytes (regexp, token_len); /* Skip a token. */ + if (token->type == OP_OPEN_COLL_ELEM || token->type == OP_OPEN_CHAR_CLASS + || token->type == OP_OPEN_EQUIV_CLASS) + return parse_bracket_symbol (elem, regexp, token); + if (BE (token->type == OP_CHARSET_RANGE, 0) && !accept_hyphen) + { + /* A '-' must only appear as anything but a range indicator before + the closing bracket. Everything else is an error. */ + re_token_t token2; + (void) peek_token_bracket (&token2, regexp, syntax); + if (token2.type != OP_CLOSE_BRACKET) + /* The actual error value is not standardized since this whole + case is undefined. But ERANGE makes good sense. */ + return REG_ERANGE; + } + elem->type = SB_CHAR; + elem->opr.ch = token->opr.c; + return REG_NOERROR; +} + +/* Parse a bracket symbol in the bracket expression. Bracket symbols are + such as [::], [..], and + [==]. */ + +static reg_errcode_t +parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp, + re_token_t *token) +{ + unsigned char ch, delim = token->opr.c; + int i = 0; + if (re_string_eoi(regexp)) + return REG_EBRACK; + for (;; ++i) + { + if (i >= BRACKET_NAME_BUF_SIZE) + return REG_EBRACK; + if (token->type == OP_OPEN_CHAR_CLASS) + ch = re_string_fetch_byte_case (regexp); + else + ch = re_string_fetch_byte (regexp); + if (re_string_eoi(regexp)) + return REG_EBRACK; + if (ch == delim && re_string_peek_byte (regexp, 0) == ']') + break; + elem->opr.name[i] = ch; + } + re_string_skip_bytes (regexp, 1); + elem->opr.name[i] = '\0'; + switch (token->type) + { + case OP_OPEN_COLL_ELEM: + elem->type = COLL_SYM; + break; + case OP_OPEN_EQUIV_CLASS: + elem->type = EQUIV_CLASS; + break; + case OP_OPEN_CHAR_CLASS: + elem->type = CHAR_CLASS; + break; + default: + break; + } + return REG_NOERROR; +} + + /* Helper function for parse_bracket_exp. + Build the equivalence class which is represented by NAME. + The result are written to MBCSET and SBCSET. + EQUIV_CLASS_ALLOC is the allocated size of mbcset->equiv_classes, + is a pointer argument sinse we may update it. */ + +static reg_errcode_t +#ifdef RE_ENABLE_I18N +build_equiv_class (bitset_t sbcset, re_charset_t *mbcset, + int *equiv_class_alloc, const unsigned char *name) +#else /* not RE_ENABLE_I18N */ +build_equiv_class (bitset_t sbcset, const unsigned char *name) +#endif /* not RE_ENABLE_I18N */ +{ +#ifdef _LIBC + uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); + if (nrules != 0) + { + const int32_t *table, *indirect; + const unsigned char *weights, *extra, *cp; + unsigned char char_buf[2]; + int32_t idx1, idx2; + unsigned int ch; + size_t len; + /* This #include defines a local function! */ +# include + /* Calculate the index for equivalence class. */ + cp = name; + table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); + weights = (const unsigned char *) _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_WEIGHTMB); + extra = (const unsigned char *) _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_EXTRAMB); + indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_INDIRECTMB); + idx1 = findidx (&cp, -1); + if (BE (idx1 == 0 || *cp != '\0', 0)) + /* This isn't a valid character. */ + return REG_ECOLLATE; + + /* Build single byte matcing table for this equivalence class. */ + char_buf[1] = (unsigned char) '\0'; + len = weights[idx1 & 0xffffff]; + for (ch = 0; ch < SBC_MAX; ++ch) + { + char_buf[0] = ch; + cp = char_buf; + idx2 = findidx (&cp, 1); +/* + idx2 = table[ch]; +*/ + if (idx2 == 0) + /* This isn't a valid character. */ + continue; + /* Compare only if the length matches and the collation rule + index is the same. */ + if (len == weights[idx2 & 0xffffff] && (idx1 >> 24) == (idx2 >> 24)) + { + int cnt = 0; + + while (cnt <= len && + weights[(idx1 & 0xffffff) + 1 + cnt] + == weights[(idx2 & 0xffffff) + 1 + cnt]) + ++cnt; + + if (cnt > len) + bitset_set (sbcset, ch); + } + } + /* Check whether the array has enough space. */ + if (BE (*equiv_class_alloc == mbcset->nequiv_classes, 0)) + { + /* Not enough, realloc it. */ + /* +1 in case of mbcset->nequiv_classes is 0. */ + int new_equiv_class_alloc = 2 * mbcset->nequiv_classes + 1; + /* Use realloc since the array is NULL if *alloc == 0. */ + int32_t *new_equiv_classes = re_realloc (mbcset->equiv_classes, + int32_t, + new_equiv_class_alloc); + if (BE (new_equiv_classes == NULL, 0)) + return REG_ESPACE; + mbcset->equiv_classes = new_equiv_classes; + *equiv_class_alloc = new_equiv_class_alloc; + } + mbcset->equiv_classes[mbcset->nequiv_classes++] = idx1; + } + else +#endif /* _LIBC */ + { + if (BE (strlen ((const char *) name) != 1, 0)) + return REG_ECOLLATE; + bitset_set (sbcset, *name); + } + return REG_NOERROR; +} + + /* Helper function for parse_bracket_exp. + Build the character class which is represented by NAME. + The result are written to MBCSET and SBCSET. + CHAR_CLASS_ALLOC is the allocated size of mbcset->char_classes, + is a pointer argument sinse we may update it. */ + +static reg_errcode_t +#ifdef RE_ENABLE_I18N +build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, + re_charset_t *mbcset, int *char_class_alloc, + const char *class_name, reg_syntax_t syntax) +#else /* not RE_ENABLE_I18N */ +build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset, + const char *class_name, reg_syntax_t syntax) +#endif /* not RE_ENABLE_I18N */ +{ + int i; + + /* In case of REG_ICASE "upper" and "lower" match the both of + upper and lower cases. */ + if ((syntax & RE_ICASE) + && (strcmp (class_name, "upper") == 0 || strcmp (class_name, "lower") == 0)) + class_name = "alpha"; + +#ifdef RE_ENABLE_I18N + /* Check the space of the arrays. */ + if (BE (*char_class_alloc == mbcset->nchar_classes, 0)) + { + /* Not enough, realloc it. */ + /* +1 in case of mbcset->nchar_classes is 0. */ + int new_char_class_alloc = 2 * mbcset->nchar_classes + 1; + /* Use realloc since array is NULL if *alloc == 0. */ + wctype_t *new_char_classes = re_realloc (mbcset->char_classes, wctype_t, + new_char_class_alloc); + if (BE (new_char_classes == NULL, 0)) + return REG_ESPACE; + mbcset->char_classes = new_char_classes; + *char_class_alloc = new_char_class_alloc; + } + mbcset->char_classes[mbcset->nchar_classes++] = __wctype (class_name); +#endif /* RE_ENABLE_I18N */ + +#define BUILD_CHARCLASS_LOOP(ctype_func) \ + do { \ + if (BE (trans != NULL, 0)) \ + { \ + for (i = 0; i < SBC_MAX; ++i) \ + if (ctype_func (i)) \ + bitset_set (sbcset, trans[i]); \ + } \ + else \ + { \ + for (i = 0; i < SBC_MAX; ++i) \ + if (ctype_func (i)) \ + bitset_set (sbcset, i); \ + } \ + } while (0) + + if (strcmp (class_name, "alnum") == 0) + BUILD_CHARCLASS_LOOP (isalnum); + else if (strcmp (class_name, "cntrl") == 0) + BUILD_CHARCLASS_LOOP (iscntrl); + else if (strcmp (class_name, "lower") == 0) + BUILD_CHARCLASS_LOOP (islower); + else if (strcmp (class_name, "space") == 0) + BUILD_CHARCLASS_LOOP (isspace); + else if (strcmp (class_name, "alpha") == 0) + BUILD_CHARCLASS_LOOP (isalpha); + else if (strcmp (class_name, "digit") == 0) + BUILD_CHARCLASS_LOOP (isdigit); + else if (strcmp (class_name, "print") == 0) + BUILD_CHARCLASS_LOOP (isprint); + else if (strcmp (class_name, "upper") == 0) + BUILD_CHARCLASS_LOOP (isupper); + else if (strcmp (class_name, "blank") == 0) +#ifndef GAWK + BUILD_CHARCLASS_LOOP (isblank); +#else + /* see comments above */ + BUILD_CHARCLASS_LOOP (is_blank); +#endif + else if (strcmp (class_name, "graph") == 0) + BUILD_CHARCLASS_LOOP (isgraph); + else if (strcmp (class_name, "punct") == 0) + BUILD_CHARCLASS_LOOP (ispunct); + else if (strcmp (class_name, "xdigit") == 0) + BUILD_CHARCLASS_LOOP (isxdigit); + else + return REG_ECTYPE; + + return REG_NOERROR; +} + +static bin_tree_t * +build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, + const char *class_name, + const char *extra, int non_match, + reg_errcode_t *err) +{ + re_bitset_ptr_t sbcset; +#ifdef RE_ENABLE_I18N + re_charset_t *mbcset; + int alloc = 0; +#endif /* not RE_ENABLE_I18N */ + reg_errcode_t ret; + re_token_t br_token; + bin_tree_t *tree; + + sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1); +#ifdef RE_ENABLE_I18N + mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1); +#endif /* RE_ENABLE_I18N */ + +#ifdef RE_ENABLE_I18N + if (BE (sbcset == NULL || mbcset == NULL, 0)) +#else /* not RE_ENABLE_I18N */ + if (BE (sbcset == NULL, 0)) +#endif /* not RE_ENABLE_I18N */ + { + *err = REG_ESPACE; + return NULL; + } + + if (non_match) + { +#ifdef RE_ENABLE_I18N + mbcset->non_match = 1; +#endif /* not RE_ENABLE_I18N */ + } + + /* We don't care the syntax in this case. */ + ret = build_charclass (trans, sbcset, +#ifdef RE_ENABLE_I18N + mbcset, &alloc, +#endif /* RE_ENABLE_I18N */ + class_name, 0); + + if (BE (ret != REG_NOERROR, 0)) + { + re_free (sbcset); +#ifdef RE_ENABLE_I18N + free_charset (mbcset); +#endif /* RE_ENABLE_I18N */ + *err = ret; + return NULL; + } + /* \w match '_' also. */ + for (; *extra; extra++) + bitset_set (sbcset, *extra); + + /* If it is non-matching list. */ + if (non_match) + bitset_not (sbcset); + +#ifdef RE_ENABLE_I18N + /* Ensure only single byte characters are set. */ + if (dfa->mb_cur_max > 1) + bitset_mask (sbcset, dfa->sb_char); +#endif + + /* Build a tree for simple bracket. */ + br_token.type = SIMPLE_BRACKET; + br_token.opr.sbcset = sbcset; + tree = create_token_tree (dfa, NULL, NULL, &br_token); + if (BE (tree == NULL, 0)) + goto build_word_op_espace; + +#ifdef RE_ENABLE_I18N + if (dfa->mb_cur_max > 1) + { + bin_tree_t *mbc_tree; + /* Build a tree for complex bracket. */ + br_token.type = COMPLEX_BRACKET; + br_token.opr.mbcset = mbcset; + dfa->has_mb_node = 1; + mbc_tree = create_token_tree (dfa, NULL, NULL, &br_token); + if (BE (mbc_tree == NULL, 0)) + goto build_word_op_espace; + /* Then join them by ALT node. */ + tree = create_tree (dfa, tree, mbc_tree, OP_ALT); + if (BE (mbc_tree != NULL, 1)) + return tree; + } + else + { + free_charset (mbcset); + return tree; + } +#else /* not RE_ENABLE_I18N */ + return tree; +#endif /* not RE_ENABLE_I18N */ + + build_word_op_espace: + re_free (sbcset); +#ifdef RE_ENABLE_I18N + free_charset (mbcset); +#endif /* RE_ENABLE_I18N */ + *err = REG_ESPACE; + return NULL; +} + +/* This is intended for the expressions like "a{1,3}". + Fetch a number from `input', and return the number. + Return -1, if the number field is empty like "{,1}". + Return -2, If an error is occured. */ + +static int +fetch_number (re_string_t *input, re_token_t *token, reg_syntax_t syntax) +{ + int num = -1; + unsigned char c; + while (1) + { + fetch_token (token, input, syntax); + c = token->opr.c; + if (BE (token->type == END_OF_RE, 0)) + return -2; + if (token->type == OP_CLOSE_DUP_NUM || c == ',') + break; + num = ((token->type != CHARACTER || c < '0' || '9' < c || num == -2) + ? -2 : ((num == -1) ? c - '0' : num * 10 + c - '0')); + num = (num > RE_DUP_MAX) ? -2 : num; + } + return num; +} + +#ifdef RE_ENABLE_I18N +static void +free_charset (re_charset_t *cset) +{ + re_free (cset->mbchars); +# ifdef _LIBC + re_free (cset->coll_syms); + re_free (cset->equiv_classes); + re_free (cset->range_starts); + re_free (cset->range_ends); +# endif + re_free (cset->char_classes); + re_free (cset); +} +#endif /* RE_ENABLE_I18N */ + +/* Functions for binary tree operation. */ + +/* Create a tree node. */ + +static bin_tree_t * +create_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, + re_token_type_t type) +{ + re_token_t t; + t.type = type; + return create_token_tree (dfa, left, right, &t); +} + +static bin_tree_t * +create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, + const re_token_t *token) +{ + bin_tree_t *tree; + if (BE (dfa->str_tree_storage_idx == BIN_TREE_STORAGE_SIZE, 0)) + { + bin_tree_storage_t *storage = re_malloc (bin_tree_storage_t, 1); + + if (storage == NULL) + return NULL; + storage->next = dfa->str_tree_storage; + dfa->str_tree_storage = storage; + dfa->str_tree_storage_idx = 0; + } + tree = &dfa->str_tree_storage->data[dfa->str_tree_storage_idx++]; + + tree->parent = NULL; + tree->left = left; + tree->right = right; + tree->token = *token; + tree->token.duplicated = 0; + tree->token.opt_subexp = 0; + tree->first = NULL; + tree->next = NULL; + tree->node_idx = -1; + + if (left != NULL) + left->parent = tree; + if (right != NULL) + right->parent = tree; + return tree; +} + +/* Mark the tree SRC as an optional subexpression. + To be called from preorder or postorder. */ + +static reg_errcode_t +mark_opt_subexp (void *extra, bin_tree_t *node) +{ + int idx = (int) (long) extra; + if (node->token.type == SUBEXP && node->token.opr.idx == idx) + node->token.opt_subexp = 1; + + return REG_NOERROR; +} + +/* Free the allocated memory inside NODE. */ + +static void +free_token (re_token_t *node) +{ +#ifdef RE_ENABLE_I18N + if (node->type == COMPLEX_BRACKET && node->duplicated == 0) + free_charset (node->opr.mbcset); + else +#endif /* RE_ENABLE_I18N */ + if (node->type == SIMPLE_BRACKET && node->duplicated == 0) + re_free (node->opr.sbcset); +} + +/* Worker function for tree walking. Free the allocated memory inside NODE + and its children. */ + +static reg_errcode_t +free_tree (void *extra, bin_tree_t *node) +{ + free_token (&node->token); + return REG_NOERROR; +} + + +/* Duplicate the node SRC, and return new node. This is a preorder + visit similar to the one implemented by the generic visitor, but + we need more infrastructure to maintain two parallel trees --- so, + it's easier to duplicate. */ + +static bin_tree_t * +duplicate_tree (const bin_tree_t *root, re_dfa_t *dfa) +{ + const bin_tree_t *node; + bin_tree_t *dup_root; + bin_tree_t **p_new = &dup_root, *dup_node = root->parent; + + for (node = root; ; ) + { + /* Create a new tree and link it back to the current parent. */ + *p_new = create_token_tree (dfa, NULL, NULL, &node->token); + if (*p_new == NULL) + return NULL; + (*p_new)->parent = dup_node; + (*p_new)->token.duplicated = 1; + dup_node = *p_new; + + /* Go to the left node, or up and to the right. */ + if (node->left) + { + node = node->left; + p_new = &dup_node->left; + } + else + { + const bin_tree_t *prev = NULL; + while (node->right == prev || node->right == NULL) + { + prev = node; + node = node->parent; + dup_node = dup_node->parent; + if (!node) + return dup_root; + } + node = node->right; + p_new = &dup_node->right; + } + } +} diff --git a/regex.c b/regex.c new file mode 100644 index 0000000..6ca36d3 --- /dev/null +++ b/regex.c @@ -0,0 +1,82 @@ +/* Extended regular expression matching and search library. + Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Isamu Hasegawa . + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +/* Make sure noone compiles this code with a C++ compiler. */ +#ifdef __cplusplus +# error "This is C code, use a C compiler" +#endif + +#ifdef _LIBC +/* We have to keep the namespace clean. */ +# define regfree(preg) __regfree (preg) +# define regexec(pr, st, nm, pm, ef) __regexec (pr, st, nm, pm, ef) +# define regcomp(preg, pattern, cflags) __regcomp (preg, pattern, cflags) +# define regerror(errcode, preg, errbuf, errbuf_size) \ + __regerror(errcode, preg, errbuf, errbuf_size) +# define re_set_registers(bu, re, nu, st, en) \ + __re_set_registers (bu, re, nu, st, en) +# define re_match_2(bufp, string1, size1, string2, size2, pos, regs, stop) \ + __re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) +# define re_match(bufp, string, size, pos, regs) \ + __re_match (bufp, string, size, pos, regs) +# define re_search(bufp, string, size, startpos, range, regs) \ + __re_search (bufp, string, size, startpos, range, regs) +# define re_compile_pattern(pattern, length, bufp) \ + __re_compile_pattern (pattern, length, bufp) +# define re_set_syntax(syntax) __re_set_syntax (syntax) +# define re_search_2(bufp, st1, s1, st2, s2, startpos, range, regs, stop) \ + __re_search_2 (bufp, st1, s1, st2, s2, startpos, range, regs, stop) +# define re_compile_fastmap(bufp) __re_compile_fastmap (bufp) + +# include "../locale/localeinfo.h" +#endif + +/* On some systems, limits.h sets RE_DUP_MAX to a lower value than + GNU regex allows. Include it before , which correctly + #undefs RE_DUP_MAX and sets it to the right value. */ +#include + +#ifdef GAWK +#undef alloca +#define alloca alloca_is_bad_you_should_never_use_it +#endif +#include +#include "regex_internal.h" + +#include "regex_internal.c" +#ifdef GAWK +#define bool int +#define true (1) +#define false (0) +#endif +#include "regcomp.c" +#include "regexec.c" + +/* Binary backward compatibility. */ +#if _LIBC +# include +# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3) +link_warning (re_max_failures, "the 're_max_failures' variable is obsolete and will go away.") +int re_max_failures = 2000; +# endif +#endif diff --git a/regex.h b/regex.h new file mode 100644 index 0000000..ca619ae --- /dev/null +++ b/regex.h @@ -0,0 +1,592 @@ +/* Definitions for data structures and routines for the regular + expression library. + Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005,2006,2008,2011 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _REGEX_H +#define _REGEX_H 1 + +#ifdef HAVE_STDDEF_H +#include +#endif + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifndef _LIBC +#define __USE_GNU 1 +#endif + +/* Allow the use in C++ code. */ +#ifdef __cplusplus +extern "C" { +#endif + +/* The following two types have to be signed and unsigned integer type + wide enough to hold a value of a pointer. For most ANSI compilers + ptrdiff_t and size_t should be likely OK. Still size of these two + types is 2 for Microsoft C. Ugh... */ +typedef long int s_reg_t; +typedef unsigned long int active_reg_t; + +/* The following bits are used to determine the regexp syntax we + recognize. The set/not-set meanings are chosen so that Emacs syntax + remains the value 0. The bits are given in alphabetical order, and + the definitions shifted by one from the previous bit; thus, when we + add or remove a bit, only one other definition need change. */ +typedef unsigned long int reg_syntax_t; + +#ifdef __USE_GNU +/* If this bit is not set, then \ inside a bracket expression is literal. + If set, then such a \ quotes the following character. */ +# define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1) + +/* If this bit is not set, then + and ? are operators, and \+ and \? are + literals. + If set, then \+ and \? are operators and + and ? are literals. */ +# define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) + +/* If this bit is set, then character classes are supported. They are: + [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:], + [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:]. + If not set, then character classes are not supported. */ +# define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1) + +/* If this bit is set, then ^ and $ are always anchors (outside bracket + expressions, of course). + If this bit is not set, then it depends: + ^ is an anchor if it is at the beginning of a regular + expression or after an open-group or an alternation operator; + $ is an anchor if it is at the end of a regular expression, or + before a close-group or an alternation operator. + + This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because + POSIX draft 11.2 says that * etc. in leading positions is undefined. + We already implemented a previous draft which made those constructs + invalid, though, so we haven't changed the code back. */ +# define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) + +/* If this bit is set, then special characters are always special + regardless of where they are in the pattern. + If this bit is not set, then special characters are special only in + some contexts; otherwise they are ordinary. Specifically, + * + ? and intervals are only special when not after the beginning, + open-group, or alternation operator. */ +# define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) + +/* If this bit is set, then *, +, ?, and { cannot be first in an re or + immediately after an alternation or begin-group operator. */ +# define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) + +/* If this bit is set, then . matches newline. + If not set, then it doesn't. */ +# define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) + +/* If this bit is set, then . doesn't match NUL. + If not set, then it does. */ +# define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) + +/* If this bit is set, nonmatching lists [^...] do not match newline. + If not set, they do. */ +# define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) + +/* If this bit is set, either \{...\} or {...} defines an + interval, depending on RE_NO_BK_BRACES. + If not set, \{, \}, {, and } are literals. */ +# define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) + +/* If this bit is set, +, ? and | aren't recognized as operators. + If not set, they are. */ +# define RE_LIMITED_OPS (RE_INTERVALS << 1) + +/* If this bit is set, newline is an alternation operator. + If not set, newline is literal. */ +# define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) + +/* If this bit is set, then `{...}' defines an interval, and \{ and \} + are literals. + If not set, then `\{...\}' defines an interval. */ +# define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) + +/* If this bit is set, (...) defines a group, and \( and \) are literals. + If not set, \(...\) defines a group, and ( and ) are literals. */ +# define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) + +/* If this bit is set, then \ matches . + If not set, then \ is a back-reference. */ +# define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) + +/* If this bit is set, then | is an alternation operator, and \| is literal. + If not set, then \| is an alternation operator, and | is literal. */ +# define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) + +/* If this bit is set, then an ending range point collating higher + than the starting range point, as in [z-a], is invalid. + If not set, then when ending range point collates higher than the + starting range point, the range is ignored. */ +# define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) + +/* If this bit is set, then an unmatched ) is ordinary. + If not set, then an unmatched ) is invalid. */ +# define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) + +/* If this bit is set, succeed as soon as we match the whole pattern, + without further backtracking. */ +# define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1) + +/* If this bit is set, do not process the GNU regex operators. + If not set, then the GNU regex operators are recognized. */ +# define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1) + +/* If this bit is set, turn on internal regex debugging. + If not set, and debugging was on, turn it off. + This only works if regex.c is compiled -DDEBUG. + We define this bit always, so that all that's needed to turn on + debugging is to recompile regex.c; the calling code can always have + this bit set, and it won't affect anything in the normal case. */ +# define RE_DEBUG (RE_NO_GNU_OPS << 1) + +/* If this bit is set, a syntactically invalid interval is treated as + a string of ordinary characters. For example, the ERE 'a{1' is + treated as 'a\{1'. */ +# define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1) + +/* If this bit is set, then ignore case when matching. + If not set, then case is significant. */ +# define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1) + +/* This bit is used internally like RE_CONTEXT_INDEP_ANCHORS but only + for ^, because it is difficult to scan the regex backwards to find + whether ^ should be special. */ +# define RE_CARET_ANCHORS_HERE (RE_ICASE << 1) + +/* If this bit is set, then \{ cannot be first in an bre or + immediately after an alternation or begin-group operator. */ +# define RE_CONTEXT_INVALID_DUP (RE_CARET_ANCHORS_HERE << 1) + +/* If this bit is set, then no_sub will be set to 1 during + re_compile_pattern. */ +# define RE_NO_SUB (RE_CONTEXT_INVALID_DUP << 1) +#endif + +/* This global variable defines the particular regexp syntax to use (for + some interfaces). When a regexp is compiled, the syntax used is + stored in the pattern buffer, so changing this does not affect + already-compiled regexps. */ +extern reg_syntax_t re_syntax_options; + +#ifdef __USE_GNU +/* Define combinations of the above bits for the standard possibilities. + (The [[[ comments delimit what gets put into the Texinfo file, so + don't delete them!) */ +/* [[[begin syntaxes]]] */ +#define RE_SYNTAX_EMACS 0 + +#define RE_SYNTAX_AWK \ + (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ + | RE_NO_BK_PARENS | RE_NO_BK_REFS \ + | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ + | RE_DOT_NEWLINE | RE_CONTEXT_INDEP_ANCHORS \ + | RE_CHAR_CLASSES \ + | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS) + +#define RE_SYNTAX_GNU_AWK \ + ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \ + | RE_INVALID_INTERVAL_ORD) \ + & ~(RE_DOT_NOT_NULL | RE_CONTEXT_INDEP_OPS \ + | RE_CONTEXT_INVALID_OPS )) + +#define RE_SYNTAX_POSIX_AWK \ + (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS \ + | RE_INTERVALS | RE_NO_GNU_OPS \ + | RE_INVALID_INTERVAL_ORD) + +#define RE_SYNTAX_GREP \ + (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ + | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ + | RE_NEWLINE_ALT) + +#define RE_SYNTAX_EGREP \ + (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ + | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ + | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ + | RE_NO_BK_VBAR) + +#define RE_SYNTAX_POSIX_EGREP \ + (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \ + | RE_INVALID_INTERVAL_ORD) + +/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ +#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC + +#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC + +/* Syntax bits common to both basic and extended POSIX regex syntax. */ +#define _RE_SYNTAX_POSIX_COMMON \ + (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ + | RE_INTERVALS | RE_NO_EMPTY_RANGES) + +#define RE_SYNTAX_POSIX_BASIC \ + (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM | RE_CONTEXT_INVALID_DUP) + +/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes + RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this + isn't minimal, since other operators, such as \`, aren't disabled. */ +#define RE_SYNTAX_POSIX_MINIMAL_BASIC \ + (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) + +#define RE_SYNTAX_POSIX_EXTENDED \ + (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ + | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ + | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ + | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD) + +/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is + removed and RE_NO_BK_REFS is added. */ +#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ + (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ + | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ + | RE_NO_BK_PARENS | RE_NO_BK_REFS \ + | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) +/* [[[end syntaxes]]] */ + +/* Maximum number of duplicates an interval can allow. Some systems + (erroneously) define this in other header files, but we want our + value, so remove any previous define. */ +# ifdef RE_DUP_MAX +# undef RE_DUP_MAX +# endif +/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows. */ +# define RE_DUP_MAX (0x7fff) +#endif + + +/* POSIX `cflags' bits (i.e., information for `regcomp'). */ + +/* If this bit is set, then use extended regular expression syntax. + If not set, then use basic regular expression syntax. */ +#define REG_EXTENDED 1 + +/* If this bit is set, then ignore case when matching. + If not set, then case is significant. */ +#define REG_ICASE (REG_EXTENDED << 1) + +/* If this bit is set, then anchors do not match at newline + characters in the string. + If not set, then anchors do match at newlines. */ +#define REG_NEWLINE (REG_ICASE << 1) + +/* If this bit is set, then report only success or fail in regexec. + If not set, then returns differ between not matching and errors. */ +#define REG_NOSUB (REG_NEWLINE << 1) + + +/* POSIX `eflags' bits (i.e., information for regexec). */ + +/* If this bit is set, then the beginning-of-line operator doesn't match + the beginning of the string (presumably because it's not the + beginning of a line). + If not set, then the beginning-of-line operator does match the + beginning of the string. */ +#define REG_NOTBOL 1 + +/* Like REG_NOTBOL, except for the end-of-line. */ +#define REG_NOTEOL (1 << 1) + +/* Use PMATCH[0] to delimit the start and end of the search in the + buffer. */ +#define REG_STARTEND (1 << 2) + + +/* If any error codes are removed, changed, or added, update the + `re_error_msg' table in regex.c. */ +typedef enum +{ +#if defined _XOPEN_SOURCE || defined __USE_XOPEN2K + REG_ENOSYS = -1, /* This will never happen for this implementation. */ +#endif + + REG_NOERROR = 0, /* Success. */ + REG_NOMATCH, /* Didn't find a match (for regexec). */ + + /* POSIX regcomp return error codes. (In the order listed in the + standard.) */ + REG_BADPAT, /* Invalid pattern. */ + REG_ECOLLATE, /* Inalid collating element. */ + REG_ECTYPE, /* Invalid character class name. */ + REG_EESCAPE, /* Trailing backslash. */ + REG_ESUBREG, /* Invalid back reference. */ + REG_EBRACK, /* Unmatched left bracket. */ + REG_EPAREN, /* Parenthesis imbalance. */ + REG_EBRACE, /* Unmatched \{. */ + REG_BADBR, /* Invalid contents of \{\}. */ + REG_ERANGE, /* Invalid range end. */ + REG_ESPACE, /* Ran out of memory. */ + REG_BADRPT, /* No preceding re for repetition op. */ + + /* Error codes we've added. */ + REG_EEND, /* Premature end. */ + REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ + REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ +} reg_errcode_t; + +/* This data structure represents a compiled pattern. Before calling + the pattern compiler, the fields `buffer', `allocated', `fastmap', + and `translate' can be set. After the pattern has been compiled, + the fields `re_nsub', `not_bol' and `not_eol' are available. All + other fields are private to the regex routines. */ + +#ifndef RE_TRANSLATE_TYPE +# define __RE_TRANSLATE_TYPE unsigned char * +# ifdef __USE_GNU +# define RE_TRANSLATE_TYPE __RE_TRANSLATE_TYPE +# endif +#endif + +#ifdef __USE_GNU +# define __REPB_PREFIX(name) name +#else +# define __REPB_PREFIX(name) __##name +#endif + +struct re_pattern_buffer +{ + /* Space that holds the compiled pattern. It is declared as + `unsigned char *' because its elements are sometimes used as + array indexes. */ + unsigned char *__REPB_PREFIX(buffer); + + /* Number of bytes to which `buffer' points. */ + unsigned long int __REPB_PREFIX(allocated); + + /* Number of bytes actually used in `buffer'. */ + unsigned long int __REPB_PREFIX(used); + + /* Syntax setting with which the pattern was compiled. */ + reg_syntax_t __REPB_PREFIX(syntax); + + /* Pointer to a fastmap, if any, otherwise zero. re_search uses the + fastmap, if there is one, to skip over impossible starting points + for matches. */ + char *__REPB_PREFIX(fastmap); + + /* Either a translate table to apply to all characters before + comparing them, or zero for no translation. The translation is + applied to a pattern when it is compiled and to a string when it + is matched. */ + __RE_TRANSLATE_TYPE __REPB_PREFIX(translate); + + /* Number of subexpressions found by the compiler. */ + size_t re_nsub; + + /* Zero if this pattern cannot match the empty string, one else. + Well, in truth it's used only in `re_search_2', to see whether or + not we should use the fastmap, so we don't set this absolutely + perfectly; see `re_compile_fastmap' (the `duplicate' case). */ + unsigned __REPB_PREFIX(can_be_null) : 1; + + /* If REGS_UNALLOCATED, allocate space in the `regs' structure + for `max (RE_NREGS, re_nsub + 1)' groups. + If REGS_REALLOCATE, reallocate space if necessary. + If REGS_FIXED, use what's there. */ +#ifdef __USE_GNU +# define REGS_UNALLOCATED 0 +# define REGS_REALLOCATE 1 +# define REGS_FIXED 2 +#endif + unsigned __REPB_PREFIX(regs_allocated) : 2; + + /* Set to zero when `regex_compile' compiles a pattern; set to one + by `re_compile_fastmap' if it updates the fastmap. */ + unsigned __REPB_PREFIX(fastmap_accurate) : 1; + + /* If set, `re_match_2' does not return information about + subexpressions. */ + unsigned __REPB_PREFIX(no_sub) : 1; + + /* If set, a beginning-of-line anchor doesn't match at the beginning + of the string. */ + unsigned __REPB_PREFIX(not_bol) : 1; + + /* Similarly for an end-of-line anchor. */ + unsigned __REPB_PREFIX(not_eol) : 1; + + /* If true, an anchor at a newline matches. */ + unsigned __REPB_PREFIX(newline_anchor) : 1; +}; + +typedef struct re_pattern_buffer regex_t; + +/* Type for byte offsets within the string. POSIX mandates this. */ +typedef int regoff_t; + + +#ifdef __USE_GNU +/* This is the structure we store register match data in. See + regex.texinfo for a full description of what registers match. */ +struct re_registers +{ + unsigned num_regs; + regoff_t *start; + regoff_t *end; +}; + + +/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer, + `re_match_2' returns information about at least this many registers + the first time a `regs' structure is passed. */ +# ifndef RE_NREGS +# define RE_NREGS 30 +# endif +#endif + + +/* POSIX specification for registers. Aside from the different names than + `re_registers', POSIX uses an array of structures, instead of a + structure of arrays. */ +typedef struct +{ + regoff_t rm_so; /* Byte offset from string's start to substring's start. */ + regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ +} regmatch_t; + +/* Declarations for routines. */ + +#ifdef __USE_GNU +/* Sets the current default syntax to SYNTAX, and return the old syntax. + You can also simply assign to the `re_syntax_options' variable. */ +extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); + +/* Compile the regular expression PATTERN, with length LENGTH + and syntax given by the global `re_syntax_options', into the buffer + BUFFER. Return NULL if successful, and an error string if not. + + To free the allocated storage, you must call `regfree' on BUFFER. + Note that the translate table must either have been initialised by + `regcomp', with a malloc'ed value, or set to NULL before calling + `regfree'. */ +extern const char *re_compile_pattern (const char *__pattern, size_t __length, + struct re_pattern_buffer *__buffer); + + +/* Compile a fastmap for the compiled pattern in BUFFER; used to + accelerate searches. Return 0 if successful and -2 if was an + internal error. */ +extern int re_compile_fastmap (struct re_pattern_buffer *__buffer); + + +/* Search in the string STRING (with length LENGTH) for the pattern + compiled into BUFFER. Start searching at position START, for RANGE + characters. Return the starting position of the match, -1 for no + match, or -2 for an internal error. Also return register + information in REGS (if REGS and BUFFER->no_sub are nonzero). */ +extern int re_search (struct re_pattern_buffer *__buffer, const char *__cstring, + int __length, int __start, int __range, + struct re_registers *__regs); + + +/* Like `re_search', but search in the concatenation of STRING1 and + STRING2. Also, stop searching at index START + STOP. */ +extern int re_search_2 (struct re_pattern_buffer *__buffer, + const char *__string1, int __length1, + const char *__string2, int __length2, int __start, + int __range, struct re_registers *__regs, int __stop); + + +/* Like `re_search', but return how many characters in STRING the regexp + in BUFFER matched, starting at position START. */ +extern int re_match (struct re_pattern_buffer *__buffer, const char *__cstring, + int __length, int __start, struct re_registers *__regs); + + +/* Relates to `re_match' as `re_search_2' relates to `re_search'. */ +extern int re_match_2 (struct re_pattern_buffer *__buffer, + const char *__string1, int __length1, + const char *__string2, int __length2, int __start, + struct re_registers *__regs, int __stop); + + +/* Set REGS to hold NUM_REGS registers, storing them in STARTS and + ENDS. Subsequent matches using BUFFER and REGS will use this memory + for recording register information. STARTS and ENDS must be + allocated with malloc, and must each be at least `NUM_REGS * sizeof + (regoff_t)' bytes long. + + If NUM_REGS == 0, then subsequent matches should allocate their own + register data. + + Unless this function is called, the first search or match using + PATTERN_BUFFER will allocate its own register data, without + freeing the old data. */ +extern void re_set_registers (struct re_pattern_buffer *__buffer, + struct re_registers *__regs, + unsigned int __num_regs, + regoff_t *__starts, regoff_t *__ends); +#endif /* Use GNU */ + +#if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_BSD) +# ifndef _CRAY +/* 4.2 bsd compatibility. */ +extern char *re_comp (const char *); +extern int re_exec (const char *); +# endif +#endif + +/* GCC 2.95 and later have "__restrict"; C99 compilers have + "restrict", and "configure" may have defined "restrict". */ +#ifndef __restrict +# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__)) +# if defined restrict || 199901L <= __STDC_VERSION__ +# define __restrict restrict +# else +# define __restrict +# endif +# endif +#endif +/* gcc 3.1 and up support the [restrict] syntax. */ +#ifndef __restrict_arr +# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) \ + && !defined __GNUG__ +# define __restrict_arr __restrict +# else +# define __restrict_arr +# endif +#endif + +/* POSIX compatibility. */ +extern int regcomp (regex_t *__restrict __preg, + const char *__restrict __pattern, + int __cflags); + +extern int regexec (const regex_t *__restrict __preg, + const char *__restrict __cstring, size_t __nmatch, + regmatch_t __pmatch[__restrict_arr], + int __eflags); + +extern size_t regerror (int __errcode, const regex_t *__restrict __preg, + char *__restrict __errbuf, size_t __errbuf_size); + +extern void regfree (regex_t *__preg); + + +#ifdef __cplusplus +} +#endif /* C++ */ + +#endif /* regex.h */ diff --git a/regex_internal.c b/regex_internal.c new file mode 100644 index 0000000..8099161 --- /dev/null +++ b/regex_internal.c @@ -0,0 +1,1750 @@ +/* Extended regular expression matching and search library. + Copyright (C) 2002-2006, 2010, 2011 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Isamu Hasegawa . + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +static void re_string_construct_common (const char *str, int len, + re_string_t *pstr, + RE_TRANSLATE_TYPE trans, int icase, + const re_dfa_t *dfa) internal_function; +static re_dfastate_t *create_ci_newstate (const re_dfa_t *dfa, + const re_node_set *nodes, + unsigned int hash) internal_function; +static re_dfastate_t *create_cd_newstate (const re_dfa_t *dfa, + const re_node_set *nodes, + unsigned int context, + unsigned int hash) internal_function; + +#ifdef GAWK +#undef MAX /* safety */ +static int +MAX(size_t a, size_t b) +{ + return (a > b ? a : b); +} +#endif + +/* Functions for string operation. */ + +/* This function allocate the buffers. It is necessary to call + re_string_reconstruct before using the object. */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +re_string_allocate (re_string_t *pstr, const char *str, int len, int init_len, + RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa) +{ + reg_errcode_t ret; + int init_buf_len; + + /* Ensure at least one character fits into the buffers. */ + if (init_len < dfa->mb_cur_max) + init_len = dfa->mb_cur_max; + init_buf_len = (len + 1 < init_len) ? len + 1: init_len; + re_string_construct_common (str, len, pstr, trans, icase, dfa); + + ret = re_string_realloc_buffers (pstr, init_buf_len); + if (BE (ret != REG_NOERROR, 0)) + return ret; + + pstr->word_char = dfa->word_char; + pstr->word_ops_used = dfa->word_ops_used; + pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str; + pstr->valid_len = (pstr->mbs_allocated || dfa->mb_cur_max > 1) ? 0 : len; + pstr->valid_raw_len = pstr->valid_len; + return REG_NOERROR; +} + +/* This function allocate the buffers, and initialize them. */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +re_string_construct (re_string_t *pstr, const char *str, int len, + RE_TRANSLATE_TYPE trans, int icase, const re_dfa_t *dfa) +{ + reg_errcode_t ret; + memset (pstr, '\0', sizeof (re_string_t)); + re_string_construct_common (str, len, pstr, trans, icase, dfa); + + if (len > 0) + { + ret = re_string_realloc_buffers (pstr, len + 1); + if (BE (ret != REG_NOERROR, 0)) + return ret; + } + pstr->mbs = pstr->mbs_allocated ? pstr->mbs : (unsigned char *) str; + + if (icase) + { +#ifdef RE_ENABLE_I18N + if (dfa->mb_cur_max > 1) + { + while (1) + { + ret = build_wcs_upper_buffer (pstr); + if (BE (ret != REG_NOERROR, 0)) + return ret; + if (pstr->valid_raw_len >= len) + break; + if (pstr->bufs_len > pstr->valid_len + dfa->mb_cur_max) + break; + ret = re_string_realloc_buffers (pstr, pstr->bufs_len * 2); + if (BE (ret != REG_NOERROR, 0)) + return ret; + } + } + else +#endif /* RE_ENABLE_I18N */ + build_upper_buffer (pstr); + } + else + { +#ifdef RE_ENABLE_I18N + if (dfa->mb_cur_max > 1) + build_wcs_buffer (pstr); + else +#endif /* RE_ENABLE_I18N */ + { + if (trans != NULL) + re_string_translate_buffer (pstr); + else + { + pstr->valid_len = pstr->bufs_len; + pstr->valid_raw_len = pstr->bufs_len; + } + } + } + + return REG_NOERROR; +} + +/* Helper functions for re_string_allocate, and re_string_construct. */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +re_string_realloc_buffers (re_string_t *pstr, int new_buf_len) +{ +#ifdef RE_ENABLE_I18N + if (pstr->mb_cur_max > 1) + { + wint_t *new_wcs; + + /* Avoid overflow in realloc. */ + const size_t max_object_size = MAX (sizeof (wint_t), sizeof (int)); + if (BE (SIZE_MAX / max_object_size < new_buf_len, 0)) + return REG_ESPACE; + + new_wcs = re_realloc (pstr->wcs, wint_t, new_buf_len); + if (BE (new_wcs == NULL, 0)) + return REG_ESPACE; + pstr->wcs = new_wcs; + if (pstr->offsets != NULL) + { + int *new_offsets = re_realloc (pstr->offsets, int, new_buf_len); + if (BE (new_offsets == NULL, 0)) + return REG_ESPACE; + pstr->offsets = new_offsets; + } + } +#endif /* RE_ENABLE_I18N */ + if (pstr->mbs_allocated) + { + unsigned char *new_mbs = re_realloc (pstr->mbs, unsigned char, + new_buf_len); + if (BE (new_mbs == NULL, 0)) + return REG_ESPACE; + pstr->mbs = new_mbs; + } + pstr->bufs_len = new_buf_len; + return REG_NOERROR; +} + + +static void +internal_function +re_string_construct_common (const char *str, int len, re_string_t *pstr, + RE_TRANSLATE_TYPE trans, int icase, + const re_dfa_t *dfa) +{ + pstr->raw_mbs = (const unsigned char *) str; + pstr->len = len; + pstr->raw_len = len; + pstr->trans = trans; + pstr->icase = icase ? 1 : 0; + pstr->mbs_allocated = (trans != NULL || icase); + pstr->mb_cur_max = dfa->mb_cur_max; + pstr->is_utf8 = dfa->is_utf8; + pstr->map_notascii = dfa->map_notascii; + pstr->stop = pstr->len; + pstr->raw_stop = pstr->stop; +} + +#ifdef RE_ENABLE_I18N + +/* Build wide character buffer PSTR->WCS. + If the byte sequence of the string are: + (0), (1), (0), (1), + Then wide character buffer will be: + , WEOF , , WEOF , + We use WEOF for padding, they indicate that the position isn't + a first byte of a multibyte character. + + Note that this function assumes PSTR->VALID_LEN elements are already + built and starts from PSTR->VALID_LEN. */ + +static void +internal_function +build_wcs_buffer (re_string_t *pstr) +{ +#ifdef _LIBC + unsigned char buf[MB_LEN_MAX]; + assert (MB_LEN_MAX >= pstr->mb_cur_max); +#else + unsigned char buf[64]; +#endif + mbstate_t prev_st; + int byte_idx, end_idx, remain_len; + size_t mbclen; + + /* Build the buffers from pstr->valid_len to either pstr->len or + pstr->bufs_len. */ + end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; + for (byte_idx = pstr->valid_len; byte_idx < end_idx;) + { + wchar_t wc; + const char *p; + + remain_len = end_idx - byte_idx; + prev_st = pstr->cur_state; + /* Apply the translation if we need. */ + if (BE (pstr->trans != NULL, 0)) + { + int i, ch; + + for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i) + { + ch = pstr->raw_mbs [pstr->raw_mbs_idx + byte_idx + i]; + buf[i] = pstr->mbs[byte_idx + i] = pstr->trans[ch]; + } + p = (const char *) buf; + } + else + p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx; + mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state); + if (BE (mbclen == (size_t) -1 || mbclen == 0 + || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len), 0)) + { + /* We treat these cases as a singlebyte character. */ + mbclen = 1; + wc = (wchar_t) pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]; + if (BE (pstr->trans != NULL, 0)) + wc = pstr->trans[wc]; + pstr->cur_state = prev_st; + } + else if (BE (mbclen == (size_t) -2, 0)) + { + /* The buffer doesn't have enough space, finish to build. */ + pstr->cur_state = prev_st; + break; + } + + /* Write wide character and padding. */ + pstr->wcs[byte_idx++] = wc; + /* Write paddings. */ + for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;) + pstr->wcs[byte_idx++] = WEOF; + } + pstr->valid_len = byte_idx; + pstr->valid_raw_len = byte_idx; +} + +/* Build wide character buffer PSTR->WCS like build_wcs_buffer, + but for REG_ICASE. */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +build_wcs_upper_buffer (re_string_t *pstr) +{ + mbstate_t prev_st; + int src_idx, byte_idx, end_idx, remain_len; + size_t mbclen; +#ifdef _LIBC + char buf[MB_LEN_MAX]; + assert (MB_LEN_MAX >= pstr->mb_cur_max); +#else + char buf[64]; +#endif + + byte_idx = pstr->valid_len; + end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; + + /* The following optimization assumes that ASCII characters can be + mapped to wide characters with a simple cast. */ + if (! pstr->map_notascii && pstr->trans == NULL && !pstr->offsets_needed) + { + while (byte_idx < end_idx) + { + wchar_t wc; + + if (isascii (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]) + && mbsinit (&pstr->cur_state)) + { + /* In case of a singlebyte character. */ + pstr->mbs[byte_idx] + = toupper (pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]); + /* The next step uses the assumption that wchar_t is encoded + ASCII-safe: all ASCII values can be converted like this. */ + pstr->wcs[byte_idx] = (wchar_t) pstr->mbs[byte_idx]; + ++byte_idx; + continue; + } + + remain_len = end_idx - byte_idx; + prev_st = pstr->cur_state; + mbclen = __mbrtowc (&wc, + ((const char *) pstr->raw_mbs + pstr->raw_mbs_idx + + byte_idx), remain_len, &pstr->cur_state); + if (BE (mbclen + 2 > 2, 1)) + { + wchar_t wcu = wc; + if (iswlower (wc)) + { + size_t mbcdlen; + + wcu = towupper (wc); + mbcdlen = wcrtomb (buf, wcu, &prev_st); + if (BE (mbclen == mbcdlen, 1)) + memcpy (pstr->mbs + byte_idx, buf, mbclen); + else + { + src_idx = byte_idx; + goto offsets_needed; + } + } + else + memcpy (pstr->mbs + byte_idx, + pstr->raw_mbs + pstr->raw_mbs_idx + byte_idx, mbclen); + pstr->wcs[byte_idx++] = wcu; + /* Write paddings. */ + for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;) + pstr->wcs[byte_idx++] = WEOF; + } + else if (mbclen == (size_t) -1 || mbclen == 0 + || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len)) + { + /* It is an invalid character, an incomplete character + at the end of the string, or '\0'. Just use the byte. */ + int ch = pstr->raw_mbs[pstr->raw_mbs_idx + byte_idx]; + pstr->mbs[byte_idx] = ch; + /* And also cast it to wide char. */ + pstr->wcs[byte_idx++] = (wchar_t) ch; + if (BE (mbclen == (size_t) -1, 0)) + pstr->cur_state = prev_st; + } + else + { + /* The buffer doesn't have enough space, finish to build. */ + pstr->cur_state = prev_st; + break; + } + } + pstr->valid_len = byte_idx; + pstr->valid_raw_len = byte_idx; + return REG_NOERROR; + } + else + for (src_idx = pstr->valid_raw_len; byte_idx < end_idx;) + { + wchar_t wc; + const char *p; + offsets_needed: + remain_len = end_idx - byte_idx; + prev_st = pstr->cur_state; + if (BE (pstr->trans != NULL, 0)) + { + int i, ch; + + for (i = 0; i < pstr->mb_cur_max && i < remain_len; ++i) + { + ch = pstr->raw_mbs [pstr->raw_mbs_idx + src_idx + i]; + buf[i] = pstr->trans[ch]; + } + p = (const char *) buf; + } + else + p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx; + mbclen = __mbrtowc (&wc, p, remain_len, &pstr->cur_state); + if (BE (mbclen + 2 > 2, 1)) + { + wchar_t wcu = wc; + if (iswlower (wc)) + { + size_t mbcdlen; + + wcu = towupper (wc); + mbcdlen = wcrtomb ((char *) buf, wcu, &prev_st); + if (BE (mbclen == mbcdlen, 1)) + memcpy (pstr->mbs + byte_idx, buf, mbclen); + else if (mbcdlen != (size_t) -1) + { + size_t i; + + if (byte_idx + mbcdlen > pstr->bufs_len) + { + pstr->cur_state = prev_st; + break; + } + + if (pstr->offsets == NULL) + { + pstr->offsets = re_malloc (int, pstr->bufs_len); + + if (pstr->offsets == NULL) + return REG_ESPACE; + } + if (!pstr->offsets_needed) + { + for (i = 0; i < (size_t) byte_idx; ++i) + pstr->offsets[i] = i; + pstr->offsets_needed = 1; + } + + memcpy (pstr->mbs + byte_idx, buf, mbcdlen); + pstr->wcs[byte_idx] = wcu; + pstr->offsets[byte_idx] = src_idx; + for (i = 1; i < mbcdlen; ++i) + { + pstr->offsets[byte_idx + i] + = src_idx + (i < mbclen ? i : mbclen - 1); + pstr->wcs[byte_idx + i] = WEOF; + } + pstr->len += mbcdlen - mbclen; + if (pstr->raw_stop > src_idx) + pstr->stop += mbcdlen - mbclen; + end_idx = (pstr->bufs_len > pstr->len) + ? pstr->len : pstr->bufs_len; + byte_idx += mbcdlen; + src_idx += mbclen; + continue; + } + else + memcpy (pstr->mbs + byte_idx, p, mbclen); + } + else + memcpy (pstr->mbs + byte_idx, p, mbclen); + + if (BE (pstr->offsets_needed != 0, 0)) + { + size_t i; + for (i = 0; i < mbclen; ++i) + pstr->offsets[byte_idx + i] = src_idx + i; + } + src_idx += mbclen; + + pstr->wcs[byte_idx++] = wcu; + /* Write paddings. */ + for (remain_len = byte_idx + mbclen - 1; byte_idx < remain_len ;) + pstr->wcs[byte_idx++] = WEOF; + } + else if (mbclen == (size_t) -1 || mbclen == 0 + || (mbclen == (size_t) -2 && pstr->bufs_len >= pstr->len)) + { + /* It is an invalid character or '\0'. Just use the byte. */ + int ch = pstr->raw_mbs[pstr->raw_mbs_idx + src_idx]; + + if (BE (pstr->trans != NULL, 0)) + ch = pstr->trans [ch]; + pstr->mbs[byte_idx] = ch; + + if (BE (pstr->offsets_needed != 0, 0)) + pstr->offsets[byte_idx] = src_idx; + ++src_idx; + + /* And also cast it to wide char. */ + pstr->wcs[byte_idx++] = (wchar_t) ch; + if (BE (mbclen == (size_t) -1, 0)) + pstr->cur_state = prev_st; + } + else + { + /* The buffer doesn't have enough space, finish to build. */ + pstr->cur_state = prev_st; + break; + } + } + pstr->valid_len = byte_idx; + pstr->valid_raw_len = src_idx; + return REG_NOERROR; +} + +/* Skip characters until the index becomes greater than NEW_RAW_IDX. + Return the index. */ + +static int +internal_function +re_string_skip_chars (re_string_t *pstr, int new_raw_idx, wint_t *last_wc) +{ + mbstate_t prev_st; + int rawbuf_idx; + size_t mbclen; + wint_t wc = WEOF; + + /* Skip the characters which are not necessary to check. */ + for (rawbuf_idx = pstr->raw_mbs_idx + pstr->valid_raw_len; + rawbuf_idx < new_raw_idx;) + { + wchar_t wc2; + int remain_len = pstr->raw_len - rawbuf_idx; + prev_st = pstr->cur_state; + mbclen = __mbrtowc (&wc2, (const char *) pstr->raw_mbs + rawbuf_idx, + remain_len, &pstr->cur_state); + if (BE ((ssize_t) mbclen <= 0, 0)) + { + /* We treat these cases as a single byte character. */ + if (mbclen == 0 || remain_len == 0) + wc = L'\0'; + else + wc = *(unsigned char *) (pstr->raw_mbs + rawbuf_idx); + mbclen = 1; + pstr->cur_state = prev_st; + } + else + wc = (wint_t) wc2; + /* Then proceed the next character. */ + rawbuf_idx += mbclen; + } + *last_wc = (wint_t) wc; + return rawbuf_idx; +} +#endif /* RE_ENABLE_I18N */ + +/* Build the buffer PSTR->MBS, and apply the translation if we need. + This function is used in case of REG_ICASE. */ + +static void +internal_function +build_upper_buffer (re_string_t *pstr) +{ + int char_idx, end_idx; + end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; + + for (char_idx = pstr->valid_len; char_idx < end_idx; ++char_idx) + { + int ch = pstr->raw_mbs[pstr->raw_mbs_idx + char_idx]; + if (BE (pstr->trans != NULL, 0)) + ch = pstr->trans[ch]; + if (islower (ch)) + pstr->mbs[char_idx] = toupper (ch); + else + pstr->mbs[char_idx] = ch; + } + pstr->valid_len = char_idx; + pstr->valid_raw_len = char_idx; +} + +/* Apply TRANS to the buffer in PSTR. */ + +static void +internal_function +re_string_translate_buffer (re_string_t *pstr) +{ + int buf_idx, end_idx; + end_idx = (pstr->bufs_len > pstr->len) ? pstr->len : pstr->bufs_len; + + for (buf_idx = pstr->valid_len; buf_idx < end_idx; ++buf_idx) + { + int ch = pstr->raw_mbs[pstr->raw_mbs_idx + buf_idx]; + pstr->mbs[buf_idx] = pstr->trans[ch]; + } + + pstr->valid_len = buf_idx; + pstr->valid_raw_len = buf_idx; +} + +/* This function re-construct the buffers. + Concretely, convert to wide character in case of pstr->mb_cur_max > 1, + convert to upper case in case of REG_ICASE, apply translation. */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +re_string_reconstruct (re_string_t *pstr, int idx, int eflags) +{ + int offset = idx - pstr->raw_mbs_idx; + if (BE (offset < 0, 0)) + { + /* Reset buffer. */ +#ifdef RE_ENABLE_I18N + if (pstr->mb_cur_max > 1) + memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); +#endif /* RE_ENABLE_I18N */ + pstr->len = pstr->raw_len; + pstr->stop = pstr->raw_stop; + pstr->valid_len = 0; + pstr->raw_mbs_idx = 0; + pstr->valid_raw_len = 0; + pstr->offsets_needed = 0; + pstr->tip_context = ((eflags & REG_NOTBOL) ? CONTEXT_BEGBUF + : CONTEXT_NEWLINE | CONTEXT_BEGBUF); + if (!pstr->mbs_allocated) + pstr->mbs = (unsigned char *) pstr->raw_mbs; + offset = idx; + } + + if (BE (offset != 0, 1)) + { + /* Should the already checked characters be kept? */ + if (BE (offset < pstr->valid_raw_len, 1)) + { + /* Yes, move them to the front of the buffer. */ +#ifdef RE_ENABLE_I18N + if (BE (pstr->offsets_needed, 0)) + { + int low = 0, high = pstr->valid_len, mid; + do + { + mid = (high + low) / 2; + if (pstr->offsets[mid] > offset) + high = mid; + else if (pstr->offsets[mid] < offset) + low = mid + 1; + else + break; + } + while (low < high); + if (pstr->offsets[mid] < offset) + ++mid; + pstr->tip_context = re_string_context_at (pstr, mid - 1, + eflags); + /* This can be quite complicated, so handle specially + only the common and easy case where the character with + different length representation of lower and upper + case is present at or after offset. */ + if (pstr->valid_len > offset + && mid == offset && pstr->offsets[mid] == offset) + { + memmove (pstr->wcs, pstr->wcs + offset, + (pstr->valid_len - offset) * sizeof (wint_t)); + memmove (pstr->mbs, pstr->mbs + offset, pstr->valid_len - offset); + pstr->valid_len -= offset; + pstr->valid_raw_len -= offset; + for (low = 0; low < pstr->valid_len; low++) + pstr->offsets[low] = pstr->offsets[low + offset] - offset; + } + else + { + /* Otherwise, just find out how long the partial multibyte + character at offset is and fill it with WEOF/255. */ + pstr->len = pstr->raw_len - idx + offset; + pstr->stop = pstr->raw_stop - idx + offset; + pstr->offsets_needed = 0; + while (mid > 0 && pstr->offsets[mid - 1] == offset) + --mid; + while (mid < pstr->valid_len) + if (pstr->wcs[mid] != WEOF) + break; + else + ++mid; + if (mid == pstr->valid_len) + pstr->valid_len = 0; + else + { + pstr->valid_len = pstr->offsets[mid] - offset; + if (pstr->valid_len) + { + for (low = 0; low < pstr->valid_len; ++low) + pstr->wcs[low] = WEOF; + memset (pstr->mbs, 255, pstr->valid_len); + } + } + pstr->valid_raw_len = pstr->valid_len; + } + } + else +#endif + { + pstr->tip_context = re_string_context_at (pstr, offset - 1, + eflags); +#ifdef RE_ENABLE_I18N + if (pstr->mb_cur_max > 1) + memmove (pstr->wcs, pstr->wcs + offset, + (pstr->valid_len - offset) * sizeof (wint_t)); +#endif /* RE_ENABLE_I18N */ + if (BE (pstr->mbs_allocated, 0)) + memmove (pstr->mbs, pstr->mbs + offset, + pstr->valid_len - offset); + pstr->valid_len -= offset; + pstr->valid_raw_len -= offset; +#if DEBUG + assert (pstr->valid_len > 0); +#endif + } + } + else + { +#ifdef RE_ENABLE_I18N + /* No, skip all characters until IDX. */ + int prev_valid_len = pstr->valid_len; + + if (BE (pstr->offsets_needed, 0)) + { + pstr->len = pstr->raw_len - idx + offset; + pstr->stop = pstr->raw_stop - idx + offset; + pstr->offsets_needed = 0; + } +#endif + pstr->valid_len = 0; +#ifdef RE_ENABLE_I18N + if (pstr->mb_cur_max > 1) + { + int wcs_idx; + wint_t wc = WEOF; + + if (pstr->is_utf8) + { + const unsigned char *raw, *p, *end; + + /* Special case UTF-8. Multi-byte chars start with any + byte other than 0x80 - 0xbf. */ + raw = pstr->raw_mbs + pstr->raw_mbs_idx; + end = raw + (offset - pstr->mb_cur_max); + if (end < pstr->raw_mbs) + end = pstr->raw_mbs; + p = raw + offset - 1; +#ifdef _LIBC + /* We know the wchar_t encoding is UCS4, so for the simple + case, ASCII characters, skip the conversion step. */ + if (isascii (*p) && BE (pstr->trans == NULL, 1)) + { + memset (&pstr->cur_state, '\0', sizeof (mbstate_t)); + /* pstr->valid_len = 0; */ + wc = (wchar_t) *p; + } + else +#endif + for (; p >= end; --p) + if ((*p & 0xc0) != 0x80) + { + mbstate_t cur_state; + wchar_t wc2; + int mlen = raw + pstr->len - p; + unsigned char buf[6]; + size_t mbclen; + + const unsigned char *pp = p; + if (BE (pstr->trans != NULL, 0)) + { + int i = mlen < 6 ? mlen : 6; + while (--i >= 0) + buf[i] = pstr->trans[p[i]]; + pp = buf; + } + /* XXX Don't use mbrtowc, we know which conversion + to use (UTF-8 -> UCS4). */ + memset (&cur_state, 0, sizeof (cur_state)); + mbclen = __mbrtowc (&wc2, (const char *) pp, mlen, + &cur_state); + if (raw + offset - p <= mbclen + && mbclen < (size_t) -2) + { + memset (&pstr->cur_state, '\0', + sizeof (mbstate_t)); + pstr->valid_len = mbclen - (raw + offset - p); + wc = wc2; + } + break; + } + } + + if (wc == WEOF) + pstr->valid_len = re_string_skip_chars (pstr, idx, &wc) - idx; + if (wc == WEOF) + pstr->tip_context + = re_string_context_at (pstr, prev_valid_len - 1, eflags); + else + pstr->tip_context = ((BE (pstr->word_ops_used != 0, 0) + && IS_WIDE_WORD_CHAR (wc)) + ? CONTEXT_WORD + : ((IS_WIDE_NEWLINE (wc) + && pstr->newline_anchor) + ? CONTEXT_NEWLINE : 0)); + if (BE (pstr->valid_len, 0)) + { + for (wcs_idx = 0; wcs_idx < pstr->valid_len; ++wcs_idx) + pstr->wcs[wcs_idx] = WEOF; + if (pstr->mbs_allocated) + memset (pstr->mbs, 255, pstr->valid_len); + } + pstr->valid_raw_len = pstr->valid_len; + } + else +#endif /* RE_ENABLE_I18N */ + { + int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1]; + pstr->valid_raw_len = 0; + if (pstr->trans) + c = pstr->trans[c]; + pstr->tip_context = (bitset_contain (pstr->word_char, c) + ? CONTEXT_WORD + : ((IS_NEWLINE (c) && pstr->newline_anchor) + ? CONTEXT_NEWLINE : 0)); + } + } + if (!BE (pstr->mbs_allocated, 0)) + pstr->mbs += offset; + } + pstr->raw_mbs_idx = idx; + pstr->len -= offset; + pstr->stop -= offset; + + /* Then build the buffers. */ +#ifdef RE_ENABLE_I18N + if (pstr->mb_cur_max > 1) + { + if (pstr->icase) + { + reg_errcode_t ret = build_wcs_upper_buffer (pstr); + if (BE (ret != REG_NOERROR, 0)) + return ret; + } + else + build_wcs_buffer (pstr); + } + else +#endif /* RE_ENABLE_I18N */ + if (BE (pstr->mbs_allocated, 0)) + { + if (pstr->icase) + build_upper_buffer (pstr); + else if (pstr->trans != NULL) + re_string_translate_buffer (pstr); + } + else + pstr->valid_len = pstr->len; + + pstr->cur_idx = 0; + return REG_NOERROR; +} + +static unsigned char +internal_function __attribute ((pure)) +re_string_peek_byte_case (const re_string_t *pstr, int idx) +{ + int ch, off; + + /* Handle the common (easiest) cases first. */ + if (BE (!pstr->mbs_allocated, 1)) + return re_string_peek_byte (pstr, idx); + +#ifdef RE_ENABLE_I18N + if (pstr->mb_cur_max > 1 + && ! re_string_is_single_byte_char (pstr, pstr->cur_idx + idx)) + return re_string_peek_byte (pstr, idx); +#endif + + off = pstr->cur_idx + idx; +#ifdef RE_ENABLE_I18N + if (pstr->offsets_needed) + off = pstr->offsets[off]; +#endif + + ch = pstr->raw_mbs[pstr->raw_mbs_idx + off]; + +#ifdef RE_ENABLE_I18N + /* Ensure that e.g. for tr_TR.UTF-8 BACKSLASH DOTLESS SMALL LETTER I + this function returns CAPITAL LETTER I instead of first byte of + DOTLESS SMALL LETTER I. The latter would confuse the parser, + since peek_byte_case doesn't advance cur_idx in any way. */ + if (pstr->offsets_needed && !isascii (ch)) + return re_string_peek_byte (pstr, idx); +#endif + + return ch; +} + +static unsigned char +internal_function +re_string_fetch_byte_case (re_string_t *pstr) +{ + if (BE (!pstr->mbs_allocated, 1)) + return re_string_fetch_byte (pstr); + +#ifdef RE_ENABLE_I18N + if (pstr->offsets_needed) + { + int off, ch; + + /* For tr_TR.UTF-8 [[:islower:]] there is + [[: CAPITAL LETTER I WITH DOT lower:]] in mbs. Skip + in that case the whole multi-byte character and return + the original letter. On the other side, with + [[: DOTLESS SMALL LETTER I return [[:I, as doing + anything else would complicate things too much. */ + + if (!re_string_first_byte (pstr, pstr->cur_idx)) + return re_string_fetch_byte (pstr); + + off = pstr->offsets[pstr->cur_idx]; + ch = pstr->raw_mbs[pstr->raw_mbs_idx + off]; + + if (! isascii (ch)) + return re_string_fetch_byte (pstr); + + re_string_skip_bytes (pstr, + re_string_char_size_at (pstr, pstr->cur_idx)); + return ch; + } +#endif + + return pstr->raw_mbs[pstr->raw_mbs_idx + pstr->cur_idx++]; +} + +static void +internal_function +re_string_destruct (re_string_t *pstr) +{ +#ifdef RE_ENABLE_I18N + re_free (pstr->wcs); + re_free (pstr->offsets); +#endif /* RE_ENABLE_I18N */ + if (pstr->mbs_allocated) + re_free (pstr->mbs); +} + +/* Return the context at IDX in INPUT. */ + +static unsigned int +internal_function +re_string_context_at (const re_string_t *input, int idx, int eflags) +{ + int c; + if (BE (idx < 0, 0)) + /* In this case, we use the value stored in input->tip_context, + since we can't know the character in input->mbs[-1] here. */ + return input->tip_context; + if (BE (idx == input->len, 0)) + return ((eflags & REG_NOTEOL) ? CONTEXT_ENDBUF + : CONTEXT_NEWLINE | CONTEXT_ENDBUF); +#ifdef RE_ENABLE_I18N + if (input->mb_cur_max > 1) + { + wint_t wc; + int wc_idx = idx; + while(input->wcs[wc_idx] == WEOF) + { +#ifdef DEBUG + /* It must not happen. */ + assert (wc_idx >= 0); +#endif + --wc_idx; + if (wc_idx < 0) + return input->tip_context; + } + wc = input->wcs[wc_idx]; + if (BE (input->word_ops_used != 0, 0) && IS_WIDE_WORD_CHAR (wc)) + return CONTEXT_WORD; + return (IS_WIDE_NEWLINE (wc) && input->newline_anchor + ? CONTEXT_NEWLINE : 0); + } + else +#endif + { + c = re_string_byte_at (input, idx); + if (bitset_contain (input->word_char, c)) + return CONTEXT_WORD; + return IS_NEWLINE (c) && input->newline_anchor ? CONTEXT_NEWLINE : 0; + } +} + +/* Functions for set operation. */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +re_node_set_alloc (re_node_set *set, int size) +{ + /* + * ADR: valgrind says size can be 0, which then doesn't + * free the block of size 0. Harumph. This seems + * to work ok, though. + */ + if (size == 0) + { + memset(set, 0, sizeof(*set)); + return REG_NOERROR; + } + set->alloc = size; + set->nelem = 0; + set->elems = re_malloc (int, size); + if (BE (set->elems == NULL, 0)) + return REG_ESPACE; + return REG_NOERROR; +} + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +re_node_set_init_1 (re_node_set *set, int elem) +{ + set->alloc = 1; + set->nelem = 1; + set->elems = re_malloc (int, 1); + if (BE (set->elems == NULL, 0)) + { + set->alloc = set->nelem = 0; + return REG_ESPACE; + } + set->elems[0] = elem; + return REG_NOERROR; +} + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +re_node_set_init_2 (re_node_set *set, int elem1, int elem2) +{ + set->alloc = 2; + set->elems = re_malloc (int, 2); + if (BE (set->elems == NULL, 0)) + return REG_ESPACE; + if (elem1 == elem2) + { + set->nelem = 1; + set->elems[0] = elem1; + } + else + { + set->nelem = 2; + if (elem1 < elem2) + { + set->elems[0] = elem1; + set->elems[1] = elem2; + } + else + { + set->elems[0] = elem2; + set->elems[1] = elem1; + } + } + return REG_NOERROR; +} + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +re_node_set_init_copy (re_node_set *dest, const re_node_set *src) +{ + dest->nelem = src->nelem; + if (src->nelem > 0) + { + dest->alloc = dest->nelem; + dest->elems = re_malloc (int, dest->alloc); + if (BE (dest->elems == NULL, 0)) + { + dest->alloc = dest->nelem = 0; + return REG_ESPACE; + } + memcpy (dest->elems, src->elems, src->nelem * sizeof (int)); + } + else + re_node_set_init_empty (dest); + return REG_NOERROR; +} + +/* Calculate the intersection of the sets SRC1 and SRC2. And merge it to + DEST. Return value indicate the error code or REG_NOERROR if succeeded. + Note: We assume dest->elems is NULL, when dest->alloc is 0. */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +re_node_set_add_intersect (re_node_set *dest, const re_node_set *src1, + const re_node_set *src2) +{ + int i1, i2, is, id, delta, sbase; + if (src1->nelem == 0 || src2->nelem == 0) + return REG_NOERROR; + + /* We need dest->nelem + 2 * elems_in_intersection; this is a + conservative estimate. */ + if (src1->nelem + src2->nelem + dest->nelem > dest->alloc) + { + int new_alloc = src1->nelem + src2->nelem + dest->alloc; + int *new_elems = re_realloc (dest->elems, int, new_alloc); + if (BE (new_elems == NULL, 0)) + return REG_ESPACE; + dest->elems = new_elems; + dest->alloc = new_alloc; + } + + /* Find the items in the intersection of SRC1 and SRC2, and copy + into the top of DEST those that are not already in DEST itself. */ + sbase = dest->nelem + src1->nelem + src2->nelem; + i1 = src1->nelem - 1; + i2 = src2->nelem - 1; + id = dest->nelem - 1; + for (;;) + { + if (src1->elems[i1] == src2->elems[i2]) + { + /* Try to find the item in DEST. Maybe we could binary search? */ + while (id >= 0 && dest->elems[id] > src1->elems[i1]) + --id; + + if (id < 0 || dest->elems[id] != src1->elems[i1]) + dest->elems[--sbase] = src1->elems[i1]; + + if (--i1 < 0 || --i2 < 0) + break; + } + + /* Lower the highest of the two items. */ + else if (src1->elems[i1] < src2->elems[i2]) + { + if (--i2 < 0) + break; + } + else + { + if (--i1 < 0) + break; + } + } + + id = dest->nelem - 1; + is = dest->nelem + src1->nelem + src2->nelem - 1; + delta = is - sbase + 1; + + /* Now copy. When DELTA becomes zero, the remaining + DEST elements are already in place; this is more or + less the same loop that is in re_node_set_merge. */ + dest->nelem += delta; + if (delta > 0 && id >= 0) + for (;;) + { + if (dest->elems[is] > dest->elems[id]) + { + /* Copy from the top. */ + dest->elems[id + delta--] = dest->elems[is--]; + if (delta == 0) + break; + } + else + { + /* Slide from the bottom. */ + dest->elems[id + delta] = dest->elems[id]; + if (--id < 0) + break; + } + } + + /* Copy remaining SRC elements. */ + memcpy (dest->elems, dest->elems + sbase, delta * sizeof (int)); + + return REG_NOERROR; +} + +/* Calculate the union set of the sets SRC1 and SRC2. And store it to + DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +re_node_set_init_union (re_node_set *dest, const re_node_set *src1, + const re_node_set *src2) +{ + int i1, i2, id; + if (src1 != NULL && src1->nelem > 0 && src2 != NULL && src2->nelem > 0) + { + dest->alloc = src1->nelem + src2->nelem; + dest->elems = re_malloc (int, dest->alloc); + if (BE (dest->elems == NULL, 0)) + return REG_ESPACE; + } + else + { + if (src1 != NULL && src1->nelem > 0) + return re_node_set_init_copy (dest, src1); + else if (src2 != NULL && src2->nelem > 0) + return re_node_set_init_copy (dest, src2); + else + re_node_set_init_empty (dest); + return REG_NOERROR; + } + for (i1 = i2 = id = 0 ; i1 < src1->nelem && i2 < src2->nelem ;) + { + if (src1->elems[i1] > src2->elems[i2]) + { + dest->elems[id++] = src2->elems[i2++]; + continue; + } + if (src1->elems[i1] == src2->elems[i2]) + ++i2; + dest->elems[id++] = src1->elems[i1++]; + } + if (i1 < src1->nelem) + { + memcpy (dest->elems + id, src1->elems + i1, + (src1->nelem - i1) * sizeof (int)); + id += src1->nelem - i1; + } + else if (i2 < src2->nelem) + { + memcpy (dest->elems + id, src2->elems + i2, + (src2->nelem - i2) * sizeof (int)); + id += src2->nelem - i2; + } + dest->nelem = id; + return REG_NOERROR; +} + +/* Calculate the union set of the sets DEST and SRC. And store it to + DEST. Return value indicate the error code or REG_NOERROR if succeeded. */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +re_node_set_merge (re_node_set *dest, const re_node_set *src) +{ + int is, id, sbase, delta; + if (src == NULL || src->nelem == 0) + return REG_NOERROR; + if (dest->alloc < 2 * src->nelem + dest->nelem) + { + int new_alloc = 2 * (src->nelem + dest->alloc); + int *new_buffer = re_realloc (dest->elems, int, new_alloc); + if (BE (new_buffer == NULL, 0)) + return REG_ESPACE; + dest->elems = new_buffer; + dest->alloc = new_alloc; + } + + if (BE (dest->nelem == 0, 0)) + { + dest->nelem = src->nelem; + memcpy (dest->elems, src->elems, src->nelem * sizeof (int)); + return REG_NOERROR; + } + + /* Copy into the top of DEST the items of SRC that are not + found in DEST. Maybe we could binary search in DEST? */ + for (sbase = dest->nelem + 2 * src->nelem, + is = src->nelem - 1, id = dest->nelem - 1; is >= 0 && id >= 0; ) + { + if (dest->elems[id] == src->elems[is]) + is--, id--; + else if (dest->elems[id] < src->elems[is]) + dest->elems[--sbase] = src->elems[is--]; + else /* if (dest->elems[id] > src->elems[is]) */ + --id; + } + + if (is >= 0) + { + /* If DEST is exhausted, the remaining items of SRC must be unique. */ + sbase -= is + 1; + memcpy (dest->elems + sbase, src->elems, (is + 1) * sizeof (int)); + } + + id = dest->nelem - 1; + is = dest->nelem + 2 * src->nelem - 1; + delta = is - sbase + 1; + if (delta == 0) + return REG_NOERROR; + + /* Now copy. When DELTA becomes zero, the remaining + DEST elements are already in place. */ + dest->nelem += delta; + for (;;) + { + if (dest->elems[is] > dest->elems[id]) + { + /* Copy from the top. */ + dest->elems[id + delta--] = dest->elems[is--]; + if (delta == 0) + break; + } + else + { + /* Slide from the bottom. */ + dest->elems[id + delta] = dest->elems[id]; + if (--id < 0) + { + /* Copy remaining SRC elements. */ + memcpy (dest->elems, dest->elems + sbase, + delta * sizeof (int)); + break; + } + } + } + + return REG_NOERROR; +} + +/* Insert the new element ELEM to the re_node_set* SET. + SET should not already have ELEM. + return -1 if an error is occured, return 1 otherwise. */ + +static int +internal_function __attribute_warn_unused_result__ +re_node_set_insert (re_node_set *set, int elem) +{ + int idx; + /* In case the set is empty. */ + if (set->alloc == 0) + { + if (BE (re_node_set_init_1 (set, elem) == REG_NOERROR, 1)) + return 1; + else + return -1; + } + + if (BE (set->nelem, 0) == 0) + { + /* We already guaranteed above that set->alloc != 0. */ + set->elems[0] = elem; + ++set->nelem; + return 1; + } + + /* Realloc if we need. */ + if (set->alloc == set->nelem) + { + int *new_elems; + set->alloc = set->alloc * 2; + new_elems = re_realloc (set->elems, int, set->alloc); + if (BE (new_elems == NULL, 0)) + return -1; + set->elems = new_elems; + } + + /* Move the elements which follows the new element. Test the + first element separately to skip a check in the inner loop. */ + if (elem < set->elems[0]) + { + idx = 0; + for (idx = set->nelem; idx > 0; idx--) + set->elems[idx] = set->elems[idx - 1]; + } + else + { + for (idx = set->nelem; set->elems[idx - 1] > elem; idx--) + set->elems[idx] = set->elems[idx - 1]; + } + + /* Insert the new element. */ + set->elems[idx] = elem; + ++set->nelem; + return 1; +} + +/* Insert the new element ELEM to the re_node_set* SET. + SET should not already have any element greater than or equal to ELEM. + Return -1 if an error is occured, return 1 otherwise. */ + +static int +internal_function __attribute_warn_unused_result__ +re_node_set_insert_last (re_node_set *set, int elem) +{ + /* Realloc if we need. */ + if (set->alloc == set->nelem) + { + int *new_elems; + set->alloc = (set->alloc + 1) * 2; + new_elems = re_realloc (set->elems, int, set->alloc); + if (BE (new_elems == NULL, 0)) + return -1; + set->elems = new_elems; + } + + /* Insert the new element. */ + set->elems[set->nelem++] = elem; + return 1; +} + +/* Compare two node sets SET1 and SET2. + return 1 if SET1 and SET2 are equivalent, return 0 otherwise. */ + +static int +internal_function __attribute ((pure)) +re_node_set_compare (const re_node_set *set1, const re_node_set *set2) +{ + int i; + if (set1 == NULL || set2 == NULL || set1->nelem != set2->nelem) + return 0; + for (i = set1->nelem ; --i >= 0 ; ) + if (set1->elems[i] != set2->elems[i]) + return 0; + return 1; +} + +/* Return (idx + 1) if SET contains the element ELEM, return 0 otherwise. */ + +static int +internal_function __attribute ((pure)) +re_node_set_contains (const re_node_set *set, int elem) +{ + unsigned int idx, right, mid; + if (set->nelem <= 0) + return 0; + + /* Binary search the element. */ + idx = 0; + right = set->nelem - 1; + while (idx < right) + { + mid = (idx + right) / 2; + if (set->elems[mid] < elem) + idx = mid + 1; + else + right = mid; + } + return set->elems[idx] == elem ? idx + 1 : 0; +} + +static void +internal_function +re_node_set_remove_at (re_node_set *set, int idx) +{ + if (idx < 0 || idx >= set->nelem) + return; + --set->nelem; + for (; idx < set->nelem; idx++) + set->elems[idx] = set->elems[idx + 1]; +} + + +/* Add the token TOKEN to dfa->nodes, and return the index of the token. + Or return -1, if an error will be occured. */ + +static int +internal_function +re_dfa_add_node (re_dfa_t *dfa, re_token_t token) +{ + if (BE (dfa->nodes_len >= dfa->nodes_alloc, 0)) + { + size_t new_nodes_alloc = dfa->nodes_alloc * 2; + int *new_nexts, *new_indices; + re_node_set *new_edests, *new_eclosures; + re_token_t *new_nodes; + + /* Avoid overflows in realloc. */ + const size_t max_object_size = MAX (sizeof (re_token_t), + MAX (sizeof (re_node_set), + sizeof (int))); + if (BE (SIZE_MAX / max_object_size < new_nodes_alloc, 0)) + return -1; + + new_nodes = re_realloc (dfa->nodes, re_token_t, new_nodes_alloc); + if (BE (new_nodes == NULL, 0)) + return -1; + dfa->nodes = new_nodes; + new_nexts = re_realloc (dfa->nexts, int, new_nodes_alloc); + new_indices = re_realloc (dfa->org_indices, int, new_nodes_alloc); + new_edests = re_realloc (dfa->edests, re_node_set, new_nodes_alloc); + new_eclosures = re_realloc (dfa->eclosures, re_node_set, new_nodes_alloc); + if (BE (new_nexts == NULL || new_indices == NULL + || new_edests == NULL || new_eclosures == NULL, 0)) + return -1; + dfa->nexts = new_nexts; + dfa->org_indices = new_indices; + dfa->edests = new_edests; + dfa->eclosures = new_eclosures; + dfa->nodes_alloc = new_nodes_alloc; + } + dfa->nodes[dfa->nodes_len] = token; + dfa->nodes[dfa->nodes_len].constraint = 0; +#ifdef RE_ENABLE_I18N + dfa->nodes[dfa->nodes_len].accept_mb = + (token.type == OP_PERIOD && dfa->mb_cur_max > 1) || token.type == COMPLEX_BRACKET; +#endif + dfa->nexts[dfa->nodes_len] = -1; + re_node_set_init_empty (dfa->edests + dfa->nodes_len); + re_node_set_init_empty (dfa->eclosures + dfa->nodes_len); + return dfa->nodes_len++; +} + +static inline unsigned int +internal_function +calc_state_hash (const re_node_set *nodes, unsigned int context) +{ + unsigned int hash = nodes->nelem + context; + int i; + for (i = 0 ; i < nodes->nelem ; i++) + hash += nodes->elems[i]; + return hash; +} + +/* Search for the state whose node_set is equivalent to NODES. + Return the pointer to the state, if we found it in the DFA. + Otherwise create the new one and return it. In case of an error + return NULL and set the error code in ERR. + Note: - We assume NULL as the invalid state, then it is possible that + return value is NULL and ERR is REG_NOERROR. + - We never return non-NULL value in case of any errors, it is for + optimization. */ + +static re_dfastate_t * +internal_function __attribute_warn_unused_result__ +re_acquire_state (reg_errcode_t *err, const re_dfa_t *dfa, + const re_node_set *nodes) +{ + unsigned int hash; + re_dfastate_t *new_state; + struct re_state_table_entry *spot; + int i; + if (BE (nodes->nelem == 0, 0)) + { + *err = REG_NOERROR; + return NULL; + } + hash = calc_state_hash (nodes, 0); + spot = dfa->state_table + (hash & dfa->state_hash_mask); + + for (i = 0 ; i < spot->num ; i++) + { + re_dfastate_t *state = spot->array[i]; + if (hash != state->hash) + continue; + if (re_node_set_compare (&state->nodes, nodes)) + return state; + } + + /* There are no appropriate state in the dfa, create the new one. */ + new_state = create_ci_newstate (dfa, nodes, hash); + if (BE (new_state == NULL, 0)) + *err = REG_ESPACE; + + return new_state; +} + +/* Search for the state whose node_set is equivalent to NODES and + whose context is equivalent to CONTEXT. + Return the pointer to the state, if we found it in the DFA. + Otherwise create the new one and return it. In case of an error + return NULL and set the error code in ERR. + Note: - We assume NULL as the invalid state, then it is possible that + return value is NULL and ERR is REG_NOERROR. + - We never return non-NULL value in case of any errors, it is for + optimization. */ + +static re_dfastate_t * +internal_function __attribute_warn_unused_result__ +re_acquire_state_context (reg_errcode_t *err, const re_dfa_t *dfa, + const re_node_set *nodes, unsigned int context) +{ + unsigned int hash; + re_dfastate_t *new_state; + struct re_state_table_entry *spot; + int i; + if (nodes->nelem == 0) + { + *err = REG_NOERROR; + return NULL; + } + hash = calc_state_hash (nodes, context); + spot = dfa->state_table + (hash & dfa->state_hash_mask); + + for (i = 0 ; i < spot->num ; i++) + { + re_dfastate_t *state = spot->array[i]; + if (state->hash == hash + && state->context == context + && re_node_set_compare (state->entrance_nodes, nodes)) + return state; + } + /* There are no appropriate state in `dfa', create the new one. */ + new_state = create_cd_newstate (dfa, nodes, context, hash); + if (BE (new_state == NULL, 0)) + *err = REG_ESPACE; + + return new_state; +} + +/* Finish initialization of the new state NEWSTATE, and using its hash value + HASH put in the appropriate bucket of DFA's state table. Return value + indicates the error code if failed. */ + +static reg_errcode_t +__attribute_warn_unused_result__ +register_state (const re_dfa_t *dfa, re_dfastate_t *newstate, + unsigned int hash) +{ + struct re_state_table_entry *spot; + reg_errcode_t err; + int i; + + newstate->hash = hash; + err = re_node_set_alloc (&newstate->non_eps_nodes, newstate->nodes.nelem); + if (BE (err != REG_NOERROR, 0)) + return REG_ESPACE; + for (i = 0; i < newstate->nodes.nelem; i++) + { + int elem = newstate->nodes.elems[i]; + if (!IS_EPSILON_NODE (dfa->nodes[elem].type)) + if (re_node_set_insert_last (&newstate->non_eps_nodes, elem) < 0) + return REG_ESPACE; + } + + spot = dfa->state_table + (hash & dfa->state_hash_mask); + if (BE (spot->alloc <= spot->num, 0)) + { + int new_alloc = 2 * spot->num + 2; + re_dfastate_t **new_array = re_realloc (spot->array, re_dfastate_t *, + new_alloc); + if (BE (new_array == NULL, 0)) + return REG_ESPACE; + spot->array = new_array; + spot->alloc = new_alloc; + } + spot->array[spot->num++] = newstate; + return REG_NOERROR; +} + +static void +free_state (re_dfastate_t *state) +{ + re_node_set_free (&state->non_eps_nodes); + re_node_set_free (&state->inveclosure); + if (state->entrance_nodes != &state->nodes) + { + re_node_set_free (state->entrance_nodes); + re_free (state->entrance_nodes); + } + re_node_set_free (&state->nodes); + re_free (state->word_trtable); + re_free (state->trtable); + re_free (state); +} + +/* Create the new state which is independ of contexts. + Return the new state if succeeded, otherwise return NULL. */ + +static re_dfastate_t * +internal_function __attribute_warn_unused_result__ +create_ci_newstate (const re_dfa_t *dfa, const re_node_set *nodes, + unsigned int hash) +{ + int i; + reg_errcode_t err; + re_dfastate_t *newstate; + + newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); + if (BE (newstate == NULL, 0)) + return NULL; + err = re_node_set_init_copy (&newstate->nodes, nodes); + if (BE (err != REG_NOERROR, 0)) + { + re_free (newstate); + return NULL; + } + + newstate->entrance_nodes = &newstate->nodes; + for (i = 0 ; i < nodes->nelem ; i++) + { + re_token_t *node = dfa->nodes + nodes->elems[i]; + re_token_type_t type = node->type; + if (type == CHARACTER && !node->constraint) + continue; +#ifdef RE_ENABLE_I18N + newstate->accept_mb |= node->accept_mb; +#endif /* RE_ENABLE_I18N */ + + /* If the state has the halt node, the state is a halt state. */ + if (type == END_OF_RE) + newstate->halt = 1; + else if (type == OP_BACK_REF) + newstate->has_backref = 1; + else if (type == ANCHOR || node->constraint) + newstate->has_constraint = 1; + } + err = register_state (dfa, newstate, hash); + if (BE (err != REG_NOERROR, 0)) + { + free_state (newstate); + newstate = NULL; + } + return newstate; +} + +/* Create the new state which is depend on the context CONTEXT. + Return the new state if succeeded, otherwise return NULL. */ + +static re_dfastate_t * +internal_function __attribute_warn_unused_result__ +create_cd_newstate (const re_dfa_t *dfa, const re_node_set *nodes, + unsigned int context, unsigned int hash) +{ + int i, nctx_nodes = 0; + reg_errcode_t err; + re_dfastate_t *newstate; + + newstate = (re_dfastate_t *) calloc (sizeof (re_dfastate_t), 1); + if (BE (newstate == NULL, 0)) + return NULL; + err = re_node_set_init_copy (&newstate->nodes, nodes); + if (BE (err != REG_NOERROR, 0)) + { + re_free (newstate); + return NULL; + } + + newstate->context = context; + newstate->entrance_nodes = &newstate->nodes; + + for (i = 0 ; i < nodes->nelem ; i++) + { + re_token_t *node = dfa->nodes + nodes->elems[i]; + re_token_type_t type = node->type; + unsigned int constraint = node->constraint; + + if (type == CHARACTER && !constraint) + continue; +#ifdef RE_ENABLE_I18N + newstate->accept_mb |= node->accept_mb; +#endif /* RE_ENABLE_I18N */ + + /* If the state has the halt node, the state is a halt state. */ + if (type == END_OF_RE) + newstate->halt = 1; + else if (type == OP_BACK_REF) + newstate->has_backref = 1; + + if (constraint) + { + if (newstate->entrance_nodes == &newstate->nodes) + { + newstate->entrance_nodes = re_malloc (re_node_set, 1); + if (BE (newstate->entrance_nodes == NULL, 0)) + { + free_state (newstate); + return NULL; + } + if (re_node_set_init_copy (newstate->entrance_nodes, nodes) + != REG_NOERROR) + return NULL; + nctx_nodes = 0; + newstate->has_constraint = 1; + } + + if (NOT_SATISFY_PREV_CONSTRAINT (constraint,context)) + { + re_node_set_remove_at (&newstate->nodes, i - nctx_nodes); + ++nctx_nodes; + } + } + } + err = register_state (dfa, newstate, hash); + if (BE (err != REG_NOERROR, 0)) + { + free_state (newstate); + newstate = NULL; + } + return newstate; +} diff --git a/regex_internal.h b/regex_internal.h new file mode 100644 index 0000000..f38a13b --- /dev/null +++ b/regex_internal.h @@ -0,0 +1,806 @@ +/* Extended regular expression matching and search library. + Copyright (C) 2002-2005, 2007, 2008, 2010, 2011 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Isamu Hasegawa . + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _REGEX_INTERNAL_H +#define _REGEX_INTERNAL_H 1 + +#include +#include +#include +#include +#include + +#include "mbsupport.h" /* gawk */ + +#if defined HAVE_LANGINFO_H || defined HAVE_LANGINFO_CODESET || defined _LIBC +# include +#endif +#if defined HAVE_LOCALE_H || defined _LIBC +# include +#endif +#if MBS_SUPPORT && (defined HAVE_WCHAR_H || defined _LIBC) +# include +#endif /* HAVE_WCHAR_H || _LIBC */ +#if MBS_SUPPORT && (defined HAVE_WCTYPE_H || defined _LIBC) +# include +#endif /* HAVE_WCTYPE_H || _LIBC */ +#if defined HAVE_STDBOOL_H || defined _LIBC +# include +#endif /* HAVE_STDBOOL_H || _LIBC */ +#if !defined(ZOS_USS) +#if defined HAVE_STDINT_H || defined _LIBC +# include +#endif /* HAVE_STDINT_H || _LIBC */ +#endif /* !ZOS_USS */ +#if defined _LIBC +# include +#else +# define __libc_lock_define(CLASS,NAME) +# define __libc_lock_init(NAME) do { } while (0) +# define __libc_lock_lock(NAME) do { } while (0) +# define __libc_lock_unlock(NAME) do { } while (0) +#endif + +#ifndef GAWK +/* In case that the system doesn't have isblank(). */ +#if !defined _LIBC && !defined HAVE_ISBLANK && !defined isblank +# define isblank(ch) ((ch) == ' ' || (ch) == '\t') +#endif +#else /* GAWK */ +/* + * This is a freaking mess. On glibc systems you have to define + * a magic constant to get isblank() out of , since it's + * a C99 function. To heck with all that and borrow a page from + * dfa.c's book. + */ + +static int +is_blank (int c) +{ + return (c == ' ' || c == '\t'); +} +#endif /* GAWK */ + +#ifdef _LIBC +# ifndef _RE_DEFINE_LOCALE_FUNCTIONS +# define _RE_DEFINE_LOCALE_FUNCTIONS 1 +# include +# include +# include +# endif +#endif + +/* This is for other GNU distributions with internationalized messages. */ +#if (HAVE_LIBINTL_H && ENABLE_NLS) || defined _LIBC +# include +# ifdef _LIBC +# undef gettext +# define gettext(msgid) \ + INTUSE(__dcgettext) (_libc_intl_domainname, msgid, LC_MESSAGES) +# endif +#else +# define gettext(msgid) (msgid) +#endif + +#ifndef gettext_noop +/* This define is so xgettext can find the internationalizable + strings. */ +# define gettext_noop(String) String +#endif + +/* For loser systems without the definition. */ +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif + +#if MBS_SUPPORT || _LIBC +# define RE_ENABLE_I18N +#endif + +#if __GNUC__ >= 3 +# define BE(expr, val) __builtin_expect (expr, val) +#else +# define BE(expr, val) (expr) +# ifdef inline +# undef inline +# endif +# define inline +#endif + +/* Number of single byte character. */ +#define SBC_MAX 256 + +#define COLL_ELEM_LEN_MAX 8 + +/* The character which represents newline. */ +#define NEWLINE_CHAR '\n' +#define WIDE_NEWLINE_CHAR L'\n' + +/* Rename to standard API for using out of glibc. */ +#ifndef _LIBC +# ifdef __wctype +# undef __wctype +# endif +# define __wctype wctype +# ifdef __iswctype +# undef __iswctype +# endif +# define __iswctype iswctype +# define __btowc btowc +# define __mbrtowc mbrtowc +#undef __mempcpy /* GAWK */ +# define __mempcpy mempcpy +# define __wcrtomb wcrtomb +# define __regfree regfree +# define attribute_hidden +#endif /* not _LIBC */ + +#ifdef __GNUC__ +# define __attribute(arg) __attribute__ (arg) +#else +# define __attribute(arg) +#endif + +#ifdef GAWK +/* + * Instead of trying to figure out which GCC version introduced + * this symbol, just define it out and be done. + */ +# undef __attribute_warn_unused_result__ +# define __attribute_warn_unused_result__ +#endif + +extern const char __re_error_msgid[] attribute_hidden; +extern const size_t __re_error_msgid_idx[] attribute_hidden; + +/* An integer used to represent a set of bits. It must be unsigned, + and must be at least as wide as unsigned int. */ +typedef unsigned long int bitset_word_t; +/* All bits set in a bitset_word_t. */ +#define BITSET_WORD_MAX ULONG_MAX +/* Number of bits in a bitset_word_t. */ +#define BITSET_WORD_BITS (sizeof (bitset_word_t) * CHAR_BIT) +/* Number of bitset_word_t in a bit_set. */ +#define BITSET_WORDS (SBC_MAX / BITSET_WORD_BITS) +typedef bitset_word_t bitset_t[BITSET_WORDS]; +typedef bitset_word_t *re_bitset_ptr_t; +typedef const bitset_word_t *re_const_bitset_ptr_t; + +#define bitset_set(set,i) \ + (set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS) +#define bitset_clear(set,i) \ + (set[i / BITSET_WORD_BITS] &= ~((bitset_word_t) 1 << i % BITSET_WORD_BITS)) +#define bitset_contain(set,i) \ + (set[i / BITSET_WORD_BITS] & ((bitset_word_t) 1 << i % BITSET_WORD_BITS)) +#define bitset_empty(set) memset (set, '\0', sizeof (bitset_t)) +#define bitset_set_all(set) memset (set, '\xff', sizeof (bitset_t)) +#define bitset_copy(dest,src) memcpy (dest, src, sizeof (bitset_t)) + +#define PREV_WORD_CONSTRAINT 0x0001 +#define PREV_NOTWORD_CONSTRAINT 0x0002 +#define NEXT_WORD_CONSTRAINT 0x0004 +#define NEXT_NOTWORD_CONSTRAINT 0x0008 +#define PREV_NEWLINE_CONSTRAINT 0x0010 +#define NEXT_NEWLINE_CONSTRAINT 0x0020 +#define PREV_BEGBUF_CONSTRAINT 0x0040 +#define NEXT_ENDBUF_CONSTRAINT 0x0080 +#define WORD_DELIM_CONSTRAINT 0x0100 +#define NOT_WORD_DELIM_CONSTRAINT 0x0200 + +typedef enum +{ + INSIDE_WORD = PREV_WORD_CONSTRAINT | NEXT_WORD_CONSTRAINT, + WORD_FIRST = PREV_NOTWORD_CONSTRAINT | NEXT_WORD_CONSTRAINT, + WORD_LAST = PREV_WORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT, + INSIDE_NOTWORD = PREV_NOTWORD_CONSTRAINT | NEXT_NOTWORD_CONSTRAINT, + LINE_FIRST = PREV_NEWLINE_CONSTRAINT, + LINE_LAST = NEXT_NEWLINE_CONSTRAINT, + BUF_FIRST = PREV_BEGBUF_CONSTRAINT, + BUF_LAST = NEXT_ENDBUF_CONSTRAINT, + WORD_DELIM = WORD_DELIM_CONSTRAINT, + NOT_WORD_DELIM = NOT_WORD_DELIM_CONSTRAINT +} re_context_type; + +typedef struct +{ + int alloc; + int nelem; + int *elems; +} re_node_set; + +typedef enum +{ + NON_TYPE = 0, + + /* Node type, These are used by token, node, tree. */ + CHARACTER = 1, + END_OF_RE = 2, + SIMPLE_BRACKET = 3, + OP_BACK_REF = 4, + OP_PERIOD = 5, +#ifdef RE_ENABLE_I18N + COMPLEX_BRACKET = 6, + OP_UTF8_PERIOD = 7, +#endif /* RE_ENABLE_I18N */ + + /* We define EPSILON_BIT as a macro so that OP_OPEN_SUBEXP is used + when the debugger shows values of this enum type. */ +#define EPSILON_BIT 8 + OP_OPEN_SUBEXP = EPSILON_BIT | 0, + OP_CLOSE_SUBEXP = EPSILON_BIT | 1, + OP_ALT = EPSILON_BIT | 2, + OP_DUP_ASTERISK = EPSILON_BIT | 3, + ANCHOR = EPSILON_BIT | 4, + + /* Tree type, these are used only by tree. */ + CONCAT = 16, + SUBEXP = 17, + + /* Token type, these are used only by token. */ + OP_DUP_PLUS = 18, + OP_DUP_QUESTION, + OP_OPEN_BRACKET, + OP_CLOSE_BRACKET, + OP_CHARSET_RANGE, + OP_OPEN_DUP_NUM, + OP_CLOSE_DUP_NUM, + OP_NON_MATCH_LIST, + OP_OPEN_COLL_ELEM, + OP_CLOSE_COLL_ELEM, + OP_OPEN_EQUIV_CLASS, + OP_CLOSE_EQUIV_CLASS, + OP_OPEN_CHAR_CLASS, + OP_CLOSE_CHAR_CLASS, + OP_WORD, + OP_NOTWORD, + OP_SPACE, + OP_NOTSPACE, + BACK_SLASH + +} re_token_type_t; + +#ifdef RE_ENABLE_I18N +typedef struct +{ + /* Multibyte characters. */ + wchar_t *mbchars; + + /* Collating symbols. */ +# ifdef _LIBC + int32_t *coll_syms; +# endif + + /* Equivalence classes. */ +# ifdef _LIBC + int32_t *equiv_classes; +# endif + + /* Range expressions. */ +# ifdef _LIBC + uint32_t *range_starts; + uint32_t *range_ends; +# else /* not _LIBC */ + wchar_t *range_starts; + wchar_t *range_ends; +# endif /* not _LIBC */ + + /* Character classes. */ + wctype_t *char_classes; + + /* If this character set is the non-matching list. */ + unsigned int non_match : 1; + + /* # of multibyte characters. */ + int nmbchars; + + /* # of collating symbols. */ + int ncoll_syms; + + /* # of equivalence classes. */ + int nequiv_classes; + + /* # of range expressions. */ + int nranges; + + /* # of character classes. */ + int nchar_classes; +} re_charset_t; +#endif /* RE_ENABLE_I18N */ + +typedef struct +{ + union + { + unsigned char c; /* for CHARACTER */ + re_bitset_ptr_t sbcset; /* for SIMPLE_BRACKET */ +#ifdef RE_ENABLE_I18N + re_charset_t *mbcset; /* for COMPLEX_BRACKET */ +#endif /* RE_ENABLE_I18N */ + int idx; /* for BACK_REF */ + re_context_type ctx_type; /* for ANCHOR */ + } opr; +#if __GNUC__ >= 2 + re_token_type_t type : 8; +#else + re_token_type_t type; +#endif + unsigned int constraint : 10; /* context constraint */ + unsigned int duplicated : 1; + unsigned int opt_subexp : 1; +#ifdef RE_ENABLE_I18N + unsigned int accept_mb : 1; + /* These 2 bits can be moved into the union if needed (e.g. if running out + of bits; move opr.c to opr.c.c and move the flags to opr.c.flags). */ + unsigned int mb_partial : 1; +#endif + unsigned int word_char : 1; +} re_token_t; + +#define IS_EPSILON_NODE(type) ((type) & EPSILON_BIT) + +struct re_string_t +{ + /* Indicate the raw buffer which is the original string passed as an + argument of regexec(), re_search(), etc.. */ + const unsigned char *raw_mbs; + /* Store the multibyte string. In case of "case insensitive mode" like + REG_ICASE, upper cases of the string are stored, otherwise MBS points + the same address that RAW_MBS points. */ + unsigned char *mbs; +#ifdef RE_ENABLE_I18N + /* Store the wide character string which is corresponding to MBS. */ + wint_t *wcs; + int *offsets; + mbstate_t cur_state; +#endif + /* Index in RAW_MBS. Each character mbs[i] corresponds to + raw_mbs[raw_mbs_idx + i]. */ + int raw_mbs_idx; + /* The length of the valid characters in the buffers. */ + int valid_len; + /* The corresponding number of bytes in raw_mbs array. */ + int valid_raw_len; + /* The length of the buffers MBS and WCS. */ + int bufs_len; + /* The index in MBS, which is updated by re_string_fetch_byte. */ + int cur_idx; + /* length of RAW_MBS array. */ + int raw_len; + /* This is RAW_LEN - RAW_MBS_IDX + VALID_LEN - VALID_RAW_LEN. */ + int len; + /* End of the buffer may be shorter than its length in the cases such + as re_match_2, re_search_2. Then, we use STOP for end of the buffer + instead of LEN. */ + int raw_stop; + /* This is RAW_STOP - RAW_MBS_IDX adjusted through OFFSETS. */ + int stop; + + /* The context of mbs[0]. We store the context independently, since + the context of mbs[0] may be different from raw_mbs[0], which is + the beginning of the input string. */ + unsigned int tip_context; + /* The translation passed as a part of an argument of re_compile_pattern. */ + RE_TRANSLATE_TYPE trans; + /* Copy of re_dfa_t's word_char. */ + re_const_bitset_ptr_t word_char; + /* 1 if REG_ICASE. */ + unsigned char icase; + unsigned char is_utf8; + unsigned char map_notascii; + unsigned char mbs_allocated; + unsigned char offsets_needed; + unsigned char newline_anchor; + unsigned char word_ops_used; + int mb_cur_max; +}; +typedef struct re_string_t re_string_t; + + +struct re_dfa_t; +typedef struct re_dfa_t re_dfa_t; + +#ifndef _LIBC +# ifdef __i386__ +# define internal_function __attribute ((regparm (3), stdcall)) +# else +# define internal_function +# endif +#endif + +#ifndef NOT_IN_libc +static reg_errcode_t re_string_realloc_buffers (re_string_t *pstr, + int new_buf_len) + internal_function; +# ifdef RE_ENABLE_I18N +static void build_wcs_buffer (re_string_t *pstr) internal_function; +static reg_errcode_t build_wcs_upper_buffer (re_string_t *pstr) + internal_function; +# endif /* RE_ENABLE_I18N */ +static void build_upper_buffer (re_string_t *pstr) internal_function; +static void re_string_translate_buffer (re_string_t *pstr) internal_function; +static unsigned int re_string_context_at (const re_string_t *input, int idx, + int eflags) + internal_function __attribute ((pure)); +#endif +#define re_string_peek_byte(pstr, offset) \ + ((pstr)->mbs[(pstr)->cur_idx + offset]) +#define re_string_fetch_byte(pstr) \ + ((pstr)->mbs[(pstr)->cur_idx++]) +#define re_string_first_byte(pstr, idx) \ + ((idx) == (pstr)->valid_len || (pstr)->wcs[idx] != WEOF) +#define re_string_is_single_byte_char(pstr, idx) \ + ((pstr)->wcs[idx] != WEOF && ((pstr)->valid_len == (idx) + 1 \ + || (pstr)->wcs[(idx) + 1] != WEOF)) +#define re_string_eoi(pstr) ((pstr)->stop <= (pstr)->cur_idx) +#define re_string_cur_idx(pstr) ((pstr)->cur_idx) +#define re_string_get_buffer(pstr) ((pstr)->mbs) +#define re_string_length(pstr) ((pstr)->len) +#define re_string_byte_at(pstr,idx) ((pstr)->mbs[idx]) +#define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx)) +#define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx)) + +#ifndef _LIBC +# if HAVE_ALLOCA +# include +/* The OS usually guarantees only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + allocate anything larger than 4096 bytes. Also care for the possibility + of a few compiler-allocated temporary stack slots. */ +# define __libc_use_alloca(n) ((n) < 4032) +# else +/* alloca is implemented with malloc, so just use malloc. */ +# define __libc_use_alloca(n) 0 +# endif +#endif + +#define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t))) +#define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t))) +#define re_free(p) free (p) + +struct bin_tree_t +{ + struct bin_tree_t *parent; + struct bin_tree_t *left; + struct bin_tree_t *right; + struct bin_tree_t *first; + struct bin_tree_t *next; + + re_token_t token; + + /* `node_idx' is the index in dfa->nodes, if `type' == 0. + Otherwise `type' indicate the type of this node. */ + int node_idx; +}; +typedef struct bin_tree_t bin_tree_t; + +#define BIN_TREE_STORAGE_SIZE \ + ((1024 - sizeof (void *)) / sizeof (bin_tree_t)) + +struct bin_tree_storage_t +{ + struct bin_tree_storage_t *next; + bin_tree_t data[BIN_TREE_STORAGE_SIZE]; +}; +typedef struct bin_tree_storage_t bin_tree_storage_t; + +#define CONTEXT_WORD 1 +#define CONTEXT_NEWLINE (CONTEXT_WORD << 1) +#define CONTEXT_BEGBUF (CONTEXT_NEWLINE << 1) +#define CONTEXT_ENDBUF (CONTEXT_BEGBUF << 1) + +#define IS_WORD_CONTEXT(c) ((c) & CONTEXT_WORD) +#define IS_NEWLINE_CONTEXT(c) ((c) & CONTEXT_NEWLINE) +#define IS_BEGBUF_CONTEXT(c) ((c) & CONTEXT_BEGBUF) +#define IS_ENDBUF_CONTEXT(c) ((c) & CONTEXT_ENDBUF) +#define IS_ORDINARY_CONTEXT(c) ((c) == 0) + +#define IS_WORD_CHAR(ch) (isalnum (ch) || (ch) == '_') +#define IS_NEWLINE(ch) ((ch) == NEWLINE_CHAR) +#define IS_WIDE_WORD_CHAR(ch) (iswalnum (ch) || (ch) == L'_') +#define IS_WIDE_NEWLINE(ch) ((ch) == WIDE_NEWLINE_CHAR) + +#define NOT_SATISFY_PREV_CONSTRAINT(constraint,context) \ + ((((constraint) & PREV_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \ + || ((constraint & PREV_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \ + || ((constraint & PREV_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context))\ + || ((constraint & PREV_BEGBUF_CONSTRAINT) && !IS_BEGBUF_CONTEXT (context))) + +#define NOT_SATISFY_NEXT_CONSTRAINT(constraint,context) \ + ((((constraint) & NEXT_WORD_CONSTRAINT) && !IS_WORD_CONTEXT (context)) \ + || (((constraint) & NEXT_NOTWORD_CONSTRAINT) && IS_WORD_CONTEXT (context)) \ + || (((constraint) & NEXT_NEWLINE_CONSTRAINT) && !IS_NEWLINE_CONTEXT (context)) \ + || (((constraint) & NEXT_ENDBUF_CONSTRAINT) && !IS_ENDBUF_CONTEXT (context))) + +struct re_dfastate_t +{ + unsigned int hash; + re_node_set nodes; + re_node_set non_eps_nodes; + re_node_set inveclosure; + re_node_set *entrance_nodes; + struct re_dfastate_t **trtable, **word_trtable; + unsigned int context : 4; + unsigned int halt : 1; + /* If this state can accept `multi byte'. + Note that we refer to multibyte characters, and multi character + collating elements as `multi byte'. */ + unsigned int accept_mb : 1; + /* If this state has backreference node(s). */ + unsigned int has_backref : 1; + unsigned int has_constraint : 1; +}; +typedef struct re_dfastate_t re_dfastate_t; + +struct re_state_table_entry +{ + int num; + int alloc; + re_dfastate_t **array; +}; + +/* Array type used in re_sub_match_last_t and re_sub_match_top_t. */ + +typedef struct +{ + int next_idx; + int alloc; + re_dfastate_t **array; +} state_array_t; + +/* Store information about the node NODE whose type is OP_CLOSE_SUBEXP. */ + +typedef struct +{ + int node; + int str_idx; /* The position NODE match at. */ + state_array_t path; +} re_sub_match_last_t; + +/* Store information about the node NODE whose type is OP_OPEN_SUBEXP. + And information about the node, whose type is OP_CLOSE_SUBEXP, + corresponding to NODE is stored in LASTS. */ + +typedef struct +{ + int str_idx; + int node; + state_array_t *path; + int alasts; /* Allocation size of LASTS. */ + int nlasts; /* The number of LASTS. */ + re_sub_match_last_t **lasts; +} re_sub_match_top_t; + +struct re_backref_cache_entry +{ + int node; + int str_idx; + int subexp_from; + int subexp_to; + char more; + char unused; + unsigned short int eps_reachable_subexps_map; +}; + +typedef struct +{ + /* The string object corresponding to the input string. */ + re_string_t input; +#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) + const re_dfa_t *const dfa; +#else + const re_dfa_t *dfa; +#endif + /* EFLAGS of the argument of regexec. */ + int eflags; + /* Where the matching ends. */ + int match_last; + int last_node; + /* The state log used by the matcher. */ + re_dfastate_t **state_log; + int state_log_top; + /* Back reference cache. */ + int nbkref_ents; + int abkref_ents; + struct re_backref_cache_entry *bkref_ents; + int max_mb_elem_len; + int nsub_tops; + int asub_tops; + re_sub_match_top_t **sub_tops; +} re_match_context_t; + +typedef struct +{ + re_dfastate_t **sifted_states; + re_dfastate_t **limited_states; + int last_node; + int last_str_idx; + re_node_set limits; +} re_sift_context_t; + +struct re_fail_stack_ent_t +{ + int idx; + int node; + regmatch_t *regs; + re_node_set eps_via_nodes; +}; + +struct re_fail_stack_t +{ + int num; + int alloc; + struct re_fail_stack_ent_t *stack; +}; + +struct re_dfa_t +{ + re_token_t *nodes; + size_t nodes_alloc; + size_t nodes_len; + int *nexts; + int *org_indices; + re_node_set *edests; + re_node_set *eclosures; + re_node_set *inveclosures; + struct re_state_table_entry *state_table; + re_dfastate_t *init_state; + re_dfastate_t *init_state_word; + re_dfastate_t *init_state_nl; + re_dfastate_t *init_state_begbuf; + bin_tree_t *str_tree; + bin_tree_storage_t *str_tree_storage; + re_bitset_ptr_t sb_char; + int str_tree_storage_idx; + + /* number of subexpressions `re_nsub' is in regex_t. */ + unsigned int state_hash_mask; + int init_node; + int nbackref; /* The number of backreference in this dfa. */ + + /* Bitmap expressing which backreference is used. */ + bitset_word_t used_bkref_map; + bitset_word_t completed_bkref_map; + + unsigned int has_plural_match : 1; + /* If this dfa has "multibyte node", which is a backreference or + a node which can accept multibyte character or multi character + collating element. */ + unsigned int has_mb_node : 1; + unsigned int is_utf8 : 1; + unsigned int map_notascii : 1; + unsigned int word_ops_used : 1; + int mb_cur_max; + bitset_t word_char; + reg_syntax_t syntax; + int *subexp_map; +#ifdef DEBUG + char* re_str; +#endif +#if defined _LIBC + __libc_lock_define (, lock) +#endif +}; + +#define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set)) +#define re_node_set_remove(set,id) \ + (re_node_set_remove_at (set, re_node_set_contains (set, id) - 1)) +#define re_node_set_empty(p) ((p)->nelem = 0) +#define re_node_set_free(set) re_free ((set)->elems) + + +typedef enum +{ + SB_CHAR, + MB_CHAR, + EQUIV_CLASS, + COLL_SYM, + CHAR_CLASS +} bracket_elem_type; + +typedef struct +{ + bracket_elem_type type; + union + { + unsigned char ch; + unsigned char *name; + wchar_t wch; + } opr; +} bracket_elem_t; + + +/* Inline functions for bitset operation. */ +static inline void +bitset_not (bitset_t set) +{ + int bitset_i; + for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i) + set[bitset_i] = ~set[bitset_i]; +} + +static inline void +bitset_merge (bitset_t dest, const bitset_t src) +{ + int bitset_i; + for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i) + dest[bitset_i] |= src[bitset_i]; +} + +static inline void +bitset_mask (bitset_t dest, const bitset_t src) +{ + int bitset_i; + for (bitset_i = 0; bitset_i < BITSET_WORDS; ++bitset_i) + dest[bitset_i] &= src[bitset_i]; +} + +#ifdef RE_ENABLE_I18N +/* Inline functions for re_string. */ +static inline int +internal_function __attribute ((pure)) +re_string_char_size_at (const re_string_t *pstr, int idx) +{ + int byte_idx; + if (pstr->mb_cur_max == 1) + return 1; + for (byte_idx = 1; idx + byte_idx < pstr->valid_len; ++byte_idx) + if (pstr->wcs[idx + byte_idx] != WEOF) + break; + return byte_idx; +} + +static inline wint_t +internal_function __attribute ((pure)) +re_string_wchar_at (const re_string_t *pstr, int idx) +{ + if (pstr->mb_cur_max == 1) + return (wint_t) pstr->mbs[idx]; + return (wint_t) pstr->wcs[idx]; +} + +# ifndef NOT_IN_libc +static int +internal_function __attribute ((pure)) +re_string_elem_size_at (const re_string_t *pstr, int idx) +{ +# ifdef _LIBC + const unsigned char *p, *extra; + const int32_t *table, *indirect; +# include + uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); + + if (nrules != 0) + { + table = (const int32_t *) _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); + extra = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); + indirect = (const int32_t *) _NL_CURRENT (LC_COLLATE, + _NL_COLLATE_INDIRECTMB); + p = pstr->mbs + idx; + findidx (&p, pstr->len - idx); + return p - pstr->mbs - idx; + } + else +# endif /* _LIBC */ + return 1; +} +# endif +#endif /* RE_ENABLE_I18N */ + +#endif /* _REGEX_INTERNAL_H */ diff --git a/regexec.c b/regexec.c new file mode 100644 index 0000000..ea4a02f --- /dev/null +++ b/regexec.c @@ -0,0 +1,4390 @@ +/* Extended regular expression matching and search library. + Copyright (C) 2002-2005,2007,2009,2010,2011 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Isamu Hasegawa . + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags, + int n) internal_function; +static void match_ctx_clean (re_match_context_t *mctx) internal_function; +static void match_ctx_free (re_match_context_t *cache) internal_function; +static reg_errcode_t match_ctx_add_entry (re_match_context_t *cache, int node, + int str_idx, int from, int to) + internal_function; +static int search_cur_bkref_entry (const re_match_context_t *mctx, int str_idx) + internal_function; +static reg_errcode_t match_ctx_add_subtop (re_match_context_t *mctx, int node, + int str_idx) internal_function; +static re_sub_match_last_t * match_ctx_add_sublast (re_sub_match_top_t *subtop, + int node, int str_idx) + internal_function; +static void sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts, + re_dfastate_t **limited_sts, int last_node, + int last_str_idx) + internal_function; +static reg_errcode_t re_search_internal (const regex_t *preg, + const char *string, int length, + int start, int range, int stop, + size_t nmatch, regmatch_t pmatch[], + int eflags) internal_function; +static int re_search_2_stub (struct re_pattern_buffer *bufp, + const char *string1, int length1, + const char *string2, int length2, + int start, int range, struct re_registers *regs, + int stop, int ret_len) internal_function; +static int re_search_stub (struct re_pattern_buffer *bufp, + const char *string, int length, int start, + int range, int stop, struct re_registers *regs, + int ret_len) internal_function; +static unsigned re_copy_regs (struct re_registers *regs, regmatch_t *pmatch, + int nregs, int regs_allocated) internal_function; +static reg_errcode_t prune_impossible_nodes (re_match_context_t *mctx) + internal_function; +static int check_matching (re_match_context_t *mctx, int fl_longest_match, + int *p_match_first) internal_function; +static int check_halt_state_context (const re_match_context_t *mctx, + const re_dfastate_t *state, int idx) + internal_function; +static void update_regs (const re_dfa_t *dfa, regmatch_t *pmatch, + regmatch_t *prev_idx_match, int cur_node, + int cur_idx, int nmatch) internal_function; +static reg_errcode_t push_fail_stack (struct re_fail_stack_t *fs, + int str_idx, int dest_node, int nregs, + regmatch_t *regs, + re_node_set *eps_via_nodes) + internal_function; +static reg_errcode_t set_regs (const regex_t *preg, + const re_match_context_t *mctx, + size_t nmatch, regmatch_t *pmatch, + int fl_backtrack) internal_function; +static reg_errcode_t free_fail_stack_return (struct re_fail_stack_t *fs) + internal_function; + +#ifdef RE_ENABLE_I18N +static int sift_states_iter_mb (const re_match_context_t *mctx, + re_sift_context_t *sctx, + int node_idx, int str_idx, int max_str_idx) + internal_function; +#endif /* RE_ENABLE_I18N */ +static reg_errcode_t sift_states_backward (const re_match_context_t *mctx, + re_sift_context_t *sctx) + internal_function; +static reg_errcode_t build_sifted_states (const re_match_context_t *mctx, + re_sift_context_t *sctx, int str_idx, + re_node_set *cur_dest) + internal_function; +static reg_errcode_t update_cur_sifted_state (const re_match_context_t *mctx, + re_sift_context_t *sctx, + int str_idx, + re_node_set *dest_nodes) + internal_function; +static reg_errcode_t add_epsilon_src_nodes (const re_dfa_t *dfa, + re_node_set *dest_nodes, + const re_node_set *candidates) + internal_function; +static int check_dst_limits (const re_match_context_t *mctx, + re_node_set *limits, + int dst_node, int dst_idx, int src_node, + int src_idx) internal_function; +static int check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, + int boundaries, int subexp_idx, + int from_node, int bkref_idx) + internal_function; +static int check_dst_limits_calc_pos (const re_match_context_t *mctx, + int limit, int subexp_idx, + int node, int str_idx, + int bkref_idx) internal_function; +static reg_errcode_t check_subexp_limits (const re_dfa_t *dfa, + re_node_set *dest_nodes, + const re_node_set *candidates, + re_node_set *limits, + struct re_backref_cache_entry *bkref_ents, + int str_idx) internal_function; +static reg_errcode_t sift_states_bkref (const re_match_context_t *mctx, + re_sift_context_t *sctx, + int str_idx, const re_node_set *candidates) + internal_function; +static reg_errcode_t merge_state_array (const re_dfa_t *dfa, + re_dfastate_t **dst, + re_dfastate_t **src, int num) + internal_function; +static re_dfastate_t *find_recover_state (reg_errcode_t *err, + re_match_context_t *mctx) internal_function; +static re_dfastate_t *transit_state (reg_errcode_t *err, + re_match_context_t *mctx, + re_dfastate_t *state) internal_function; +static re_dfastate_t *merge_state_with_log (reg_errcode_t *err, + re_match_context_t *mctx, + re_dfastate_t *next_state) + internal_function; +static reg_errcode_t check_subexp_matching_top (re_match_context_t *mctx, + re_node_set *cur_nodes, + int str_idx) internal_function; +#if 0 +static re_dfastate_t *transit_state_sb (reg_errcode_t *err, + re_match_context_t *mctx, + re_dfastate_t *pstate) + internal_function; +#endif +#ifdef RE_ENABLE_I18N +static reg_errcode_t transit_state_mb (re_match_context_t *mctx, + re_dfastate_t *pstate) + internal_function; +#endif /* RE_ENABLE_I18N */ +static reg_errcode_t transit_state_bkref (re_match_context_t *mctx, + const re_node_set *nodes) + internal_function; +static reg_errcode_t get_subexp (re_match_context_t *mctx, + int bkref_node, int bkref_str_idx) + internal_function; +static reg_errcode_t get_subexp_sub (re_match_context_t *mctx, + const re_sub_match_top_t *sub_top, + re_sub_match_last_t *sub_last, + int bkref_node, int bkref_str) + internal_function; +static int find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes, + int subexp_idx, int type) internal_function; +static reg_errcode_t check_arrival (re_match_context_t *mctx, + state_array_t *path, int top_node, + int top_str, int last_node, int last_str, + int type) internal_function; +static reg_errcode_t check_arrival_add_next_nodes (re_match_context_t *mctx, + int str_idx, + re_node_set *cur_nodes, + re_node_set *next_nodes) + internal_function; +static reg_errcode_t check_arrival_expand_ecl (const re_dfa_t *dfa, + re_node_set *cur_nodes, + int ex_subexp, int type) + internal_function; +static reg_errcode_t check_arrival_expand_ecl_sub (const re_dfa_t *dfa, + re_node_set *dst_nodes, + int target, int ex_subexp, + int type) internal_function; +static reg_errcode_t expand_bkref_cache (re_match_context_t *mctx, + re_node_set *cur_nodes, int cur_str, + int subexp_num, int type) + internal_function; +static int build_trtable (const re_dfa_t *dfa, + re_dfastate_t *state) internal_function; +#ifdef RE_ENABLE_I18N +static int check_node_accept_bytes (const re_dfa_t *dfa, int node_idx, + const re_string_t *input, int idx) + internal_function; +# ifdef _LIBC +static unsigned int find_collation_sequence_value (const unsigned char *mbs, + size_t name_len) + internal_function; +# endif /* _LIBC */ +#endif /* RE_ENABLE_I18N */ +static int group_nodes_into_DFAstates (const re_dfa_t *dfa, + const re_dfastate_t *state, + re_node_set *states_node, + bitset_t *states_ch) internal_function; +static int check_node_accept (const re_match_context_t *mctx, + const re_token_t *node, int idx) + internal_function; +static reg_errcode_t extend_buffers (re_match_context_t *mctx) + internal_function; + +#ifdef GAWK +#undef MIN /* safety */ +static int +MIN(size_t a, size_t b) +{ + return (a < b ? a : b); +} +#endif + +/* Entry point for POSIX code. */ + +/* regexec searches for a given pattern, specified by PREG, in the + string STRING. + + If NMATCH is zero or REG_NOSUB was set in the cflags argument to + `regcomp', we ignore PMATCH. Otherwise, we assume PMATCH has at + least NMATCH elements, and we set them to the offsets of the + corresponding matched substrings. + + EFLAGS specifies `execution flags' which affect matching: if + REG_NOTBOL is set, then ^ does not match at the beginning of the + string; if REG_NOTEOL is set, then $ does not match at the end. + + We return 0 if we find a match and REG_NOMATCH if not. */ + +int +regexec (preg, string, nmatch, pmatch, eflags) + const regex_t *__restrict preg; + const char *__restrict string; + size_t nmatch; + regmatch_t pmatch[]; + int eflags; +{ + reg_errcode_t err; + int start, length; + + if (eflags & ~(REG_NOTBOL | REG_NOTEOL | REG_STARTEND)) + return REG_BADPAT; + + if (eflags & REG_STARTEND) + { + start = pmatch[0].rm_so; + length = pmatch[0].rm_eo; + } + else + { + start = 0; + length = strlen (string); + } + + __libc_lock_lock (dfa->lock); + if (preg->no_sub) + err = re_search_internal (preg, string, length, start, length - start, + length, 0, NULL, eflags); + else + err = re_search_internal (preg, string, length, start, length - start, + length, nmatch, pmatch, eflags); + __libc_lock_unlock (dfa->lock); + return err != REG_NOERROR; +} + +#ifdef _LIBC +# include +versioned_symbol (libc, __regexec, regexec, GLIBC_2_3_4); + +# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3_4) +__typeof__ (__regexec) __compat_regexec; + +int +attribute_compat_text_section +__compat_regexec (const regex_t *__restrict preg, + const char *__restrict string, size_t nmatch, + regmatch_t pmatch[], int eflags) +{ + return regexec (preg, string, nmatch, pmatch, + eflags & (REG_NOTBOL | REG_NOTEOL)); +} +compat_symbol (libc, __compat_regexec, regexec, GLIBC_2_0); +# endif +#endif + +/* Entry points for GNU code. */ + +/* re_match, re_search, re_match_2, re_search_2 + + The former two functions operate on STRING with length LENGTH, + while the later two operate on concatenation of STRING1 and STRING2 + with lengths LENGTH1 and LENGTH2, respectively. + + re_match() matches the compiled pattern in BUFP against the string, + starting at index START. + + re_search() first tries matching at index START, then it tries to match + starting from index START + 1, and so on. The last start position tried + is START + RANGE. (Thus RANGE = 0 forces re_search to operate the same + way as re_match().) + + The parameter STOP of re_{match,search}_2 specifies that no match exceeding + the first STOP characters of the concatenation of the strings should be + concerned. + + If REGS is not NULL, and BUFP->no_sub is not set, the offsets of the match + and all groups is stroed in REGS. (For the "_2" variants, the offsets are + computed relative to the concatenation, not relative to the individual + strings.) + + On success, re_match* functions return the length of the match, re_search* + return the position of the start of the match. Return value -1 means no + match was found and -2 indicates an internal error. */ + +int +re_match (bufp, string, length, start, regs) + struct re_pattern_buffer *bufp; + const char *string; + int length, start; + struct re_registers *regs; +{ + return re_search_stub (bufp, string, length, start, 0, length, regs, 1); +} +#ifdef _LIBC +weak_alias (__re_match, re_match) +#endif + +int +re_search (bufp, string, length, start, range, regs) + struct re_pattern_buffer *bufp; + const char *string; + int length, start, range; + struct re_registers *regs; +{ + return re_search_stub (bufp, string, length, start, range, length, regs, 0); +} +#ifdef _LIBC +weak_alias (__re_search, re_search) +#endif + +int +re_match_2 (bufp, string1, length1, string2, length2, start, regs, stop) + struct re_pattern_buffer *bufp; + const char *string1, *string2; + int length1, length2, start, stop; + struct re_registers *regs; +{ + return re_search_2_stub (bufp, string1, length1, string2, length2, + start, 0, regs, stop, 1); +} +#ifdef _LIBC +weak_alias (__re_match_2, re_match_2) +#endif + +int +re_search_2 (bufp, string1, length1, string2, length2, start, range, regs, stop) + struct re_pattern_buffer *bufp; + const char *string1, *string2; + int length1, length2, start, range, stop; + struct re_registers *regs; +{ + return re_search_2_stub (bufp, string1, length1, string2, length2, + start, range, regs, stop, 0); +} +#ifdef _LIBC +weak_alias (__re_search_2, re_search_2) +#endif + +static int +re_search_2_stub (bufp, string1, length1, string2, length2, start, range, regs, + stop, ret_len) + struct re_pattern_buffer *bufp; + const char *string1, *string2; + int length1, length2, start, range, stop, ret_len; + struct re_registers *regs; +{ + const char *str; + int rval; + int len = length1 + length2; + int free_str = 0; + + if (BE (length1 < 0 || length2 < 0 || stop < 0 || len < length1, 0)) + return -2; + + /* Concatenate the strings. */ + if (length2 > 0) + if (length1 > 0) + { + char *s = re_malloc (char, len); + + if (BE (s == NULL, 0)) + return -2; +#ifdef _LIBC + memcpy (__mempcpy (s, string1, length1), string2, length2); +#else + memcpy (s, string1, length1); + memcpy (s + length1, string2, length2); +#endif + str = s; + free_str = 1; + } + else + str = string2; + else + str = string1; + + rval = re_search_stub (bufp, str, len, start, range, stop, regs, ret_len); + if (free_str) + re_free ((char *) str); + return rval; +} + +/* The parameters have the same meaning as those of re_search. + Additional parameters: + If RET_LEN is nonzero the length of the match is returned (re_match style); + otherwise the position of the match is returned. */ + +static int +re_search_stub (bufp, string, length, start, range, stop, regs, ret_len) + struct re_pattern_buffer *bufp; + const char *string; + int length, start, range, stop, ret_len; + struct re_registers *regs; +{ + reg_errcode_t result; + regmatch_t *pmatch; + int nregs, rval; + int eflags = 0; + + /* Check for out-of-range. */ + if (BE (start < 0 || start > length, 0)) + return -1; + if (BE (start + range > length, 0)) + range = length - start; + else if (BE (start + range < 0, 0)) + range = -start; + + __libc_lock_lock (dfa->lock); + + eflags |= (bufp->not_bol) ? REG_NOTBOL : 0; + eflags |= (bufp->not_eol) ? REG_NOTEOL : 0; + + /* Compile fastmap if we haven't yet. */ + if (range > 0 && bufp->fastmap != NULL && !bufp->fastmap_accurate) + re_compile_fastmap (bufp); + + if (BE (bufp->no_sub, 0)) + regs = NULL; + + /* We need at least 1 register. */ + if (regs == NULL) + nregs = 1; + else if (BE (bufp->regs_allocated == REGS_FIXED && + regs->num_regs < bufp->re_nsub + 1, 0)) + { + nregs = regs->num_regs; + if (BE (nregs < 1, 0)) + { + /* Nothing can be copied to regs. */ + regs = NULL; + nregs = 1; + } + } + else + nregs = bufp->re_nsub + 1; + pmatch = re_malloc (regmatch_t, nregs); + if (BE (pmatch == NULL, 0)) + { + rval = -2; + goto out; + } + + result = re_search_internal (bufp, string, length, start, range, stop, + nregs, pmatch, eflags); + + rval = 0; + + /* I hope we needn't fill ther regs with -1's when no match was found. */ + if (result != REG_NOERROR) + rval = -1; + else if (regs != NULL) + { + /* If caller wants register contents data back, copy them. */ + bufp->regs_allocated = re_copy_regs (regs, pmatch, nregs, + bufp->regs_allocated); + if (BE (bufp->regs_allocated == REGS_UNALLOCATED, 0)) + rval = -2; + } + + if (BE (rval == 0, 1)) + { + if (ret_len) + { + assert (pmatch[0].rm_so == start); + rval = pmatch[0].rm_eo - start; + } + else + rval = pmatch[0].rm_so; + } + re_free (pmatch); + out: + __libc_lock_unlock (dfa->lock); + return rval; +} + +static unsigned +re_copy_regs (regs, pmatch, nregs, regs_allocated) + struct re_registers *regs; + regmatch_t *pmatch; + int nregs, regs_allocated; +{ + int rval = REGS_REALLOCATE; + int i; + int need_regs = nregs + 1; + /* We need one extra element beyond `num_regs' for the `-1' marker GNU code + uses. */ + + /* Have the register data arrays been allocated? */ + if (regs_allocated == REGS_UNALLOCATED) + { /* No. So allocate them with malloc. */ + regs->start = re_malloc (regoff_t, need_regs); + if (BE (regs->start == NULL, 0)) + return REGS_UNALLOCATED; + regs->end = re_malloc (regoff_t, need_regs); + if (BE (regs->end == NULL, 0)) + { + re_free (regs->start); + return REGS_UNALLOCATED; + } + regs->num_regs = need_regs; + } + else if (regs_allocated == REGS_REALLOCATE) + { /* Yes. If we need more elements than were already + allocated, reallocate them. If we need fewer, just + leave it alone. */ + if (BE (need_regs > regs->num_regs, 0)) + { + regoff_t *new_start = re_realloc (regs->start, regoff_t, need_regs); + regoff_t *new_end; + if (BE (new_start == NULL, 0)) + return REGS_UNALLOCATED; + new_end = re_realloc (regs->end, regoff_t, need_regs); + if (BE (new_end == NULL, 0)) + { + re_free (new_start); + return REGS_UNALLOCATED; + } + regs->start = new_start; + regs->end = new_end; + regs->num_regs = need_regs; + } + } + else + { + assert (regs_allocated == REGS_FIXED); + /* This function may not be called with REGS_FIXED and nregs too big. */ + assert (regs->num_regs >= nregs); + rval = REGS_FIXED; + } + + /* Copy the regs. */ + for (i = 0; i < nregs; ++i) + { + regs->start[i] = pmatch[i].rm_so; + regs->end[i] = pmatch[i].rm_eo; + } + for ( ; i < regs->num_regs; ++i) + regs->start[i] = regs->end[i] = -1; + + return rval; +} + +/* Set REGS to hold NUM_REGS registers, storing them in STARTS and + ENDS. Subsequent matches using PATTERN_BUFFER and REGS will use + this memory for recording register information. STARTS and ENDS + must be allocated using the malloc library routine, and must each + be at least NUM_REGS * sizeof (regoff_t) bytes long. + + If NUM_REGS == 0, then subsequent matches should allocate their own + register data. + + Unless this function is called, the first search or match using + PATTERN_BUFFER will allocate its own register data, without + freeing the old data. */ + +void +re_set_registers (bufp, regs, num_regs, starts, ends) + struct re_pattern_buffer *bufp; + struct re_registers *regs; + unsigned num_regs; + regoff_t *starts, *ends; +{ + if (num_regs) + { + bufp->regs_allocated = REGS_REALLOCATE; + regs->num_regs = num_regs; + regs->start = starts; + regs->end = ends; + } + else + { + bufp->regs_allocated = REGS_UNALLOCATED; + regs->num_regs = 0; + regs->start = regs->end = (regoff_t *) 0; + } +} +#ifdef _LIBC +weak_alias (__re_set_registers, re_set_registers) +#endif + +/* Entry points compatible with 4.2 BSD regex library. We don't define + them unless specifically requested. */ + +#if defined _REGEX_RE_COMP || defined _LIBC +int +# ifdef _LIBC +weak_function +# endif +re_exec (s) + const char *s; +{ + return 0 == regexec (&re_comp_buf, s, 0, NULL, 0); +} +#endif /* _REGEX_RE_COMP */ + +/* Internal entry point. */ + +/* Searches for a compiled pattern PREG in the string STRING, whose + length is LENGTH. NMATCH, PMATCH, and EFLAGS have the same + mingings with regexec. START, and RANGE have the same meanings + with re_search. + Return REG_NOERROR if we find a match, and REG_NOMATCH if not, + otherwise return the error code. + Note: We assume front end functions already check ranges. + (START + RANGE >= 0 && START + RANGE <= LENGTH) */ + +static reg_errcode_t +__attribute_warn_unused_result__ +re_search_internal (preg, string, length, start, range, stop, nmatch, pmatch, + eflags) + const regex_t *preg; + const char *string; + int length, start, range, stop, eflags; + size_t nmatch; + regmatch_t pmatch[]; +{ + reg_errcode_t err; + const re_dfa_t *dfa = (const re_dfa_t *) preg->buffer; + int left_lim, right_lim, incr; + int fl_longest_match, match_first, match_kind, match_last = -1; + int extra_nmatch; + int sb, ch; +#if defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) + re_match_context_t mctx = { .dfa = dfa }; +#else + re_match_context_t mctx; +#endif + char *fastmap = (preg->fastmap != NULL && preg->fastmap_accurate + && range && !preg->can_be_null) ? preg->fastmap : NULL; + RE_TRANSLATE_TYPE t = preg->translate; + +#if !(defined _LIBC || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)) + memset (&mctx, '\0', sizeof (re_match_context_t)); + mctx.dfa = dfa; +#endif + + extra_nmatch = (nmatch > preg->re_nsub) ? nmatch - (preg->re_nsub + 1) : 0; + nmatch -= extra_nmatch; + + /* Check if the DFA haven't been compiled. */ + if (BE (preg->used == 0 || dfa->init_state == NULL + || dfa->init_state_word == NULL || dfa->init_state_nl == NULL + || dfa->init_state_begbuf == NULL, 0)) + return REG_NOMATCH; + +#ifdef DEBUG + /* We assume front-end functions already check them. */ + assert (start + range >= 0 && start + range <= length); +#endif + + /* If initial states with non-begbuf contexts have no elements, + the regex must be anchored. If preg->newline_anchor is set, + we'll never use init_state_nl, so do not check it. */ + if (dfa->init_state->nodes.nelem == 0 + && dfa->init_state_word->nodes.nelem == 0 + && (dfa->init_state_nl->nodes.nelem == 0 + || !preg->newline_anchor)) + { + if (start != 0 && start + range != 0) + return REG_NOMATCH; + start = range = 0; + } + + /* We must check the longest matching, if nmatch > 0. */ + fl_longest_match = (nmatch != 0 || dfa->nbackref); + + err = re_string_allocate (&mctx.input, string, length, dfa->nodes_len + 1, + preg->translate, preg->syntax & RE_ICASE, dfa); + if (BE (err != REG_NOERROR, 0)) + goto free_return; + mctx.input.stop = stop; + mctx.input.raw_stop = stop; + mctx.input.newline_anchor = preg->newline_anchor; + + err = match_ctx_init (&mctx, eflags, dfa->nbackref * 2); + if (BE (err != REG_NOERROR, 0)) + goto free_return; + + /* We will log all the DFA states through which the dfa pass, + if nmatch > 1, or this dfa has "multibyte node", which is a + back-reference or a node which can accept multibyte character or + multi character collating element. */ + if (nmatch > 1 || dfa->has_mb_node) + { + /* Avoid overflow. */ + if (BE (SIZE_MAX / sizeof (re_dfastate_t *) <= mctx.input.bufs_len, 0)) + { + err = REG_ESPACE; + goto free_return; + } + + mctx.state_log = re_malloc (re_dfastate_t *, mctx.input.bufs_len + 1); + if (BE (mctx.state_log == NULL, 0)) + { + err = REG_ESPACE; + goto free_return; + } + } + else + mctx.state_log = NULL; + + match_first = start; + mctx.input.tip_context = (eflags & REG_NOTBOL) ? CONTEXT_BEGBUF + : CONTEXT_NEWLINE | CONTEXT_BEGBUF; + + /* Check incrementally whether of not the input string match. */ + incr = (range < 0) ? -1 : 1; + left_lim = (range < 0) ? start + range : start; + right_lim = (range < 0) ? start : start + range; + sb = dfa->mb_cur_max == 1; + match_kind = + (fastmap + ? ((sb || !(preg->syntax & RE_ICASE || t) ? 4 : 0) + | (range >= 0 ? 2 : 0) + | (t != NULL ? 1 : 0)) + : 8); + + for (;; match_first += incr) + { + err = REG_NOMATCH; + if (match_first < left_lim || right_lim < match_first) + goto free_return; + + /* Advance as rapidly as possible through the string, until we + find a plausible place to start matching. This may be done + with varying efficiency, so there are various possibilities: + only the most common of them are specialized, in order to + save on code size. We use a switch statement for speed. */ + switch (match_kind) + { + case 8: + /* No fastmap. */ + break; + + case 7: + /* Fastmap with single-byte translation, match forward. */ + while (BE (match_first < right_lim, 1) + && !fastmap[t[(unsigned char) string[match_first]]]) + ++match_first; + goto forward_match_found_start_or_reached_end; + + case 6: + /* Fastmap without translation, match forward. */ + while (BE (match_first < right_lim, 1) + && !fastmap[(unsigned char) string[match_first]]) + ++match_first; + + forward_match_found_start_or_reached_end: + if (BE (match_first == right_lim, 0)) + { + ch = match_first >= length + ? 0 : (unsigned char) string[match_first]; + if (!fastmap[t ? t[ch] : ch]) + goto free_return; + } + break; + + case 4: + case 5: + /* Fastmap without multi-byte translation, match backwards. */ + while (match_first >= left_lim) + { + ch = match_first >= length + ? 0 : (unsigned char) string[match_first]; + if (fastmap[t ? t[ch] : ch]) + break; + --match_first; + } + if (match_first < left_lim) + goto free_return; + break; + + default: + /* In this case, we can't determine easily the current byte, + since it might be a component byte of a multibyte + character. Then we use the constructed buffer instead. */ + for (;;) + { + /* If MATCH_FIRST is out of the valid range, reconstruct the + buffers. */ + unsigned int offset = match_first - mctx.input.raw_mbs_idx; + if (BE (offset >= (unsigned int) mctx.input.valid_raw_len, 0)) + { + err = re_string_reconstruct (&mctx.input, match_first, + eflags); + if (BE (err != REG_NOERROR, 0)) + goto free_return; + + offset = match_first - mctx.input.raw_mbs_idx; + } + /* If MATCH_FIRST is out of the buffer, leave it as '\0'. + Note that MATCH_FIRST must not be smaller than 0. */ + ch = (match_first >= length + ? 0 : re_string_byte_at (&mctx.input, offset)); + if (fastmap[ch]) + break; + match_first += incr; + if (match_first < left_lim || match_first > right_lim) + { + err = REG_NOMATCH; + goto free_return; + } + } + break; + } + + /* Reconstruct the buffers so that the matcher can assume that + the matching starts from the beginning of the buffer. */ + err = re_string_reconstruct (&mctx.input, match_first, eflags); + if (BE (err != REG_NOERROR, 0)) + goto free_return; + +#ifdef RE_ENABLE_I18N + /* Don't consider this char as a possible match start if it part, + yet isn't the head, of a multibyte character. */ + if (!sb && !re_string_first_byte (&mctx.input, 0)) + continue; +#endif + + /* It seems to be appropriate one, then use the matcher. */ + /* We assume that the matching starts from 0. */ + mctx.state_log_top = mctx.nbkref_ents = mctx.max_mb_elem_len = 0; + match_last = check_matching (&mctx, fl_longest_match, + range >= 0 ? &match_first : NULL); + if (match_last != -1) + { + if (BE (match_last == -2, 0)) + { + err = REG_ESPACE; + goto free_return; + } + else + { + mctx.match_last = match_last; + if ((!preg->no_sub && nmatch > 1) || dfa->nbackref) + { + re_dfastate_t *pstate = mctx.state_log[match_last]; + mctx.last_node = check_halt_state_context (&mctx, pstate, + match_last); + } + if ((!preg->no_sub && nmatch > 1 && dfa->has_plural_match) + || dfa->nbackref) + { + err = prune_impossible_nodes (&mctx); + if (err == REG_NOERROR) + break; + if (BE (err != REG_NOMATCH, 0)) + goto free_return; + match_last = -1; + } + else + break; /* We found a match. */ + } + } + + match_ctx_clean (&mctx); + } + +#ifdef DEBUG + assert (match_last != -1); + assert (err == REG_NOERROR); +#endif + + /* Set pmatch[] if we need. */ + if (nmatch > 0) + { + int reg_idx; + + /* Initialize registers. */ + for (reg_idx = 1; reg_idx < nmatch; ++reg_idx) + pmatch[reg_idx].rm_so = pmatch[reg_idx].rm_eo = -1; + + /* Set the points where matching start/end. */ + pmatch[0].rm_so = 0; + pmatch[0].rm_eo = mctx.match_last; + + if (!preg->no_sub && nmatch > 1) + { + err = set_regs (preg, &mctx, nmatch, pmatch, + dfa->has_plural_match && dfa->nbackref > 0); + if (BE (err != REG_NOERROR, 0)) + goto free_return; + } + + /* At last, add the offset to the each registers, since we slided + the buffers so that we could assume that the matching starts + from 0. */ + for (reg_idx = 0; reg_idx < nmatch; ++reg_idx) + if (pmatch[reg_idx].rm_so != -1) + { +#ifdef RE_ENABLE_I18N + if (BE (mctx.input.offsets_needed != 0, 0)) + { + pmatch[reg_idx].rm_so = + (pmatch[reg_idx].rm_so == mctx.input.valid_len + ? mctx.input.valid_raw_len + : mctx.input.offsets[pmatch[reg_idx].rm_so]); + pmatch[reg_idx].rm_eo = + (pmatch[reg_idx].rm_eo == mctx.input.valid_len + ? mctx.input.valid_raw_len + : mctx.input.offsets[pmatch[reg_idx].rm_eo]); + } +#else + assert (mctx.input.offsets_needed == 0); +#endif + pmatch[reg_idx].rm_so += match_first; + pmatch[reg_idx].rm_eo += match_first; + } + for (reg_idx = 0; reg_idx < extra_nmatch; ++reg_idx) + { + pmatch[nmatch + reg_idx].rm_so = -1; + pmatch[nmatch + reg_idx].rm_eo = -1; + } + + if (dfa->subexp_map) + for (reg_idx = 0; reg_idx + 1 < nmatch; reg_idx++) + if (dfa->subexp_map[reg_idx] != reg_idx) + { + pmatch[reg_idx + 1].rm_so + = pmatch[dfa->subexp_map[reg_idx] + 1].rm_so; + pmatch[reg_idx + 1].rm_eo + = pmatch[dfa->subexp_map[reg_idx] + 1].rm_eo; + } + } + + free_return: + re_free (mctx.state_log); + if (dfa->nbackref) + match_ctx_free (&mctx); + re_string_destruct (&mctx.input); + return err; +} + +static reg_errcode_t +__attribute_warn_unused_result__ +prune_impossible_nodes (mctx) + re_match_context_t *mctx; +{ + const re_dfa_t *const dfa = mctx->dfa; + int halt_node, match_last; + reg_errcode_t ret; + re_dfastate_t **sifted_states; + re_dfastate_t **lim_states = NULL; + re_sift_context_t sctx; +#ifdef DEBUG + assert (mctx->state_log != NULL); +#endif + match_last = mctx->match_last; + halt_node = mctx->last_node; + + /* Avoid overflow. */ + if (BE (SIZE_MAX / sizeof (re_dfastate_t *) <= match_last, 0)) + return REG_ESPACE; + + sifted_states = re_malloc (re_dfastate_t *, match_last + 1); + if (BE (sifted_states == NULL, 0)) + { + ret = REG_ESPACE; + goto free_return; + } + if (dfa->nbackref) + { + lim_states = re_malloc (re_dfastate_t *, match_last + 1); + if (BE (lim_states == NULL, 0)) + { + ret = REG_ESPACE; + goto free_return; + } + while (1) + { + memset (lim_states, '\0', + sizeof (re_dfastate_t *) * (match_last + 1)); + sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, + match_last); + ret = sift_states_backward (mctx, &sctx); + re_node_set_free (&sctx.limits); + if (BE (ret != REG_NOERROR, 0)) + goto free_return; + if (sifted_states[0] != NULL || lim_states[0] != NULL) + break; + do + { + --match_last; + if (match_last < 0) + { + ret = REG_NOMATCH; + goto free_return; + } + } while (mctx->state_log[match_last] == NULL + || !mctx->state_log[match_last]->halt); + halt_node = check_halt_state_context (mctx, + mctx->state_log[match_last], + match_last); + } + ret = merge_state_array (dfa, sifted_states, lim_states, + match_last + 1); + re_free (lim_states); + lim_states = NULL; + if (BE (ret != REG_NOERROR, 0)) + goto free_return; + } + else + { + sift_ctx_init (&sctx, sifted_states, lim_states, halt_node, match_last); + ret = sift_states_backward (mctx, &sctx); + re_node_set_free (&sctx.limits); + if (BE (ret != REG_NOERROR, 0)) + goto free_return; + if (sifted_states[0] == NULL) + { + ret = REG_NOMATCH; + goto free_return; + } + } + re_free (mctx->state_log); + mctx->state_log = sifted_states; + sifted_states = NULL; + mctx->last_node = halt_node; + mctx->match_last = match_last; + ret = REG_NOERROR; + free_return: + re_free (sifted_states); + re_free (lim_states); + return ret; +} + +/* Acquire an initial state and return it. + We must select appropriate initial state depending on the context, + since initial states may have constraints like "\<", "^", etc.. */ + +static inline re_dfastate_t * +__attribute ((always_inline)) internal_function +acquire_init_state_context (reg_errcode_t *err, const re_match_context_t *mctx, + int idx) +{ + const re_dfa_t *const dfa = mctx->dfa; + if (dfa->init_state->has_constraint) + { + unsigned int context; + context = re_string_context_at (&mctx->input, idx - 1, mctx->eflags); + if (IS_WORD_CONTEXT (context)) + return dfa->init_state_word; + else if (IS_ORDINARY_CONTEXT (context)) + return dfa->init_state; + else if (IS_BEGBUF_CONTEXT (context) && IS_NEWLINE_CONTEXT (context)) + return dfa->init_state_begbuf; + else if (IS_NEWLINE_CONTEXT (context)) + return dfa->init_state_nl; + else if (IS_BEGBUF_CONTEXT (context)) + { + /* It is relatively rare case, then calculate on demand. */ + return re_acquire_state_context (err, dfa, + dfa->init_state->entrance_nodes, + context); + } + else + /* Must not happen? */ + return dfa->init_state; + } + else + return dfa->init_state; +} + +/* Check whether the regular expression match input string INPUT or not, + and return the index where the matching end, return -1 if not match, + or return -2 in case of an error. + FL_LONGEST_MATCH means we want the POSIX longest matching. + If P_MATCH_FIRST is not NULL, and the match fails, it is set to the + next place where we may want to try matching. + Note that the matcher assume that the maching starts from the current + index of the buffer. */ + +static int +internal_function __attribute_warn_unused_result__ +check_matching (re_match_context_t *mctx, int fl_longest_match, + int *p_match_first) +{ + const re_dfa_t *const dfa = mctx->dfa; + reg_errcode_t err; + int match = 0; + int match_last = -1; + int cur_str_idx = re_string_cur_idx (&mctx->input); + re_dfastate_t *cur_state; + int at_init_state = p_match_first != NULL; + int next_start_idx = cur_str_idx; + + err = REG_NOERROR; + cur_state = acquire_init_state_context (&err, mctx, cur_str_idx); + /* An initial state must not be NULL (invalid). */ + if (BE (cur_state == NULL, 0)) + { + assert (err == REG_ESPACE); + return -2; + } + + if (mctx->state_log != NULL) + { + mctx->state_log[cur_str_idx] = cur_state; + + /* Check OP_OPEN_SUBEXP in the initial state in case that we use them + later. E.g. Processing back references. */ + if (BE (dfa->nbackref, 0)) + { + at_init_state = 0; + err = check_subexp_matching_top (mctx, &cur_state->nodes, 0); + if (BE (err != REG_NOERROR, 0)) + return err; + + if (cur_state->has_backref) + { + err = transit_state_bkref (mctx, &cur_state->nodes); + if (BE (err != REG_NOERROR, 0)) + return err; + } + } + } + + /* If the RE accepts NULL string. */ + if (BE (cur_state->halt, 0)) + { + if (!cur_state->has_constraint + || check_halt_state_context (mctx, cur_state, cur_str_idx)) + { + if (!fl_longest_match) + return cur_str_idx; + else + { + match_last = cur_str_idx; + match = 1; + } + } + } + + while (!re_string_eoi (&mctx->input)) + { + re_dfastate_t *old_state = cur_state; + int next_char_idx = re_string_cur_idx (&mctx->input) + 1; + + if ((BE (next_char_idx >= mctx->input.bufs_len, 0) + && mctx->input.bufs_len < mctx->input.len) + || (BE (next_char_idx >= mctx->input.valid_len, 0) + && mctx->input.valid_len < mctx->input.len)) + { + err = extend_buffers (mctx); + if (BE (err != REG_NOERROR, 0)) + { + assert (err == REG_ESPACE); + return -2; + } + } + + cur_state = transit_state (&err, mctx, cur_state); + if (mctx->state_log != NULL) + cur_state = merge_state_with_log (&err, mctx, cur_state); + + if (cur_state == NULL) + { + /* Reached the invalid state or an error. Try to recover a valid + state using the state log, if available and if we have not + already found a valid (even if not the longest) match. */ + if (BE (err != REG_NOERROR, 0)) + return -2; + + if (mctx->state_log == NULL + || (match && !fl_longest_match) + || (cur_state = find_recover_state (&err, mctx)) == NULL) + break; + } + + if (BE (at_init_state, 0)) + { + if (old_state == cur_state) + next_start_idx = next_char_idx; + else + at_init_state = 0; + } + + if (cur_state->halt) + { + /* Reached a halt state. + Check the halt state can satisfy the current context. */ + if (!cur_state->has_constraint + || check_halt_state_context (mctx, cur_state, + re_string_cur_idx (&mctx->input))) + { + /* We found an appropriate halt state. */ + match_last = re_string_cur_idx (&mctx->input); + match = 1; + + /* We found a match, do not modify match_first below. */ + p_match_first = NULL; + if (!fl_longest_match) + break; + } + } + } + + if (p_match_first) + *p_match_first += next_start_idx; + + return match_last; +} + +/* Check NODE match the current context. */ + +static int +internal_function +check_halt_node_context (const re_dfa_t *dfa, int node, unsigned int context) +{ + re_token_type_t type = dfa->nodes[node].type; + unsigned int constraint = dfa->nodes[node].constraint; + if (type != END_OF_RE) + return 0; + if (!constraint) + return 1; + if (NOT_SATISFY_NEXT_CONSTRAINT (constraint, context)) + return 0; + return 1; +} + +/* Check the halt state STATE match the current context. + Return 0 if not match, if the node, STATE has, is a halt node and + match the context, return the node. */ + +static int +internal_function +check_halt_state_context (const re_match_context_t *mctx, + const re_dfastate_t *state, int idx) +{ + int i; + unsigned int context; +#ifdef DEBUG + assert (state->halt); +#endif + context = re_string_context_at (&mctx->input, idx, mctx->eflags); + for (i = 0; i < state->nodes.nelem; ++i) + if (check_halt_node_context (mctx->dfa, state->nodes.elems[i], context)) + return state->nodes.elems[i]; + return 0; +} + +/* Compute the next node to which "NFA" transit from NODE("NFA" is a NFA + corresponding to the DFA). + Return the destination node, and update EPS_VIA_NODES, return -1 in case + of errors. */ + +static int +internal_function +proceed_next_node (const re_match_context_t *mctx, int nregs, regmatch_t *regs, + int *pidx, int node, re_node_set *eps_via_nodes, + struct re_fail_stack_t *fs) +{ + const re_dfa_t *const dfa = mctx->dfa; + int i, err; + if (IS_EPSILON_NODE (dfa->nodes[node].type)) + { + re_node_set *cur_nodes = &mctx->state_log[*pidx]->nodes; + re_node_set *edests = &dfa->edests[node]; + int dest_node; + err = re_node_set_insert (eps_via_nodes, node); + if (BE (err < 0, 0)) + return -2; + /* Pick up a valid destination, or return -1 if none is found. */ + for (dest_node = -1, i = 0; i < edests->nelem; ++i) + { + int candidate = edests->elems[i]; + if (!re_node_set_contains (cur_nodes, candidate)) + continue; + if (dest_node == -1) + dest_node = candidate; + + else + { + /* In order to avoid infinite loop like "(a*)*", return the second + epsilon-transition if the first was already considered. */ + if (re_node_set_contains (eps_via_nodes, dest_node)) + return candidate; + + /* Otherwise, push the second epsilon-transition on the fail stack. */ + else if (fs != NULL + && push_fail_stack (fs, *pidx, candidate, nregs, regs, + eps_via_nodes)) + return -2; + + /* We know we are going to exit. */ + break; + } + } + return dest_node; + } + else + { + int naccepted = 0; + re_token_type_t type = dfa->nodes[node].type; + +#ifdef RE_ENABLE_I18N + if (dfa->nodes[node].accept_mb) + naccepted = check_node_accept_bytes (dfa, node, &mctx->input, *pidx); + else +#endif /* RE_ENABLE_I18N */ + if (type == OP_BACK_REF) + { + int subexp_idx = dfa->nodes[node].opr.idx + 1; + naccepted = regs[subexp_idx].rm_eo - regs[subexp_idx].rm_so; + if (fs != NULL) + { + if (regs[subexp_idx].rm_so == -1 || regs[subexp_idx].rm_eo == -1) + return -1; + else if (naccepted) + { + char *buf = (char *) re_string_get_buffer (&mctx->input); + if (memcmp (buf + regs[subexp_idx].rm_so, buf + *pidx, + naccepted) != 0) + return -1; + } + } + + if (naccepted == 0) + { + int dest_node; + err = re_node_set_insert (eps_via_nodes, node); + if (BE (err < 0, 0)) + return -2; + dest_node = dfa->edests[node].elems[0]; + if (re_node_set_contains (&mctx->state_log[*pidx]->nodes, + dest_node)) + return dest_node; + } + } + + if (naccepted != 0 + || check_node_accept (mctx, dfa->nodes + node, *pidx)) + { + int dest_node = dfa->nexts[node]; + *pidx = (naccepted == 0) ? *pidx + 1 : *pidx + naccepted; + if (fs && (*pidx > mctx->match_last || mctx->state_log[*pidx] == NULL + || !re_node_set_contains (&mctx->state_log[*pidx]->nodes, + dest_node))) + return -1; + re_node_set_empty (eps_via_nodes); + return dest_node; + } + } + return -1; +} + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +push_fail_stack (struct re_fail_stack_t *fs, int str_idx, int dest_node, + int nregs, regmatch_t *regs, re_node_set *eps_via_nodes) +{ + reg_errcode_t err; + int num = fs->num++; + if (fs->num == fs->alloc) + { + struct re_fail_stack_ent_t *new_array; + new_array = realloc (fs->stack, (sizeof (struct re_fail_stack_ent_t) + * fs->alloc * 2)); + if (new_array == NULL) + return REG_ESPACE; + fs->alloc *= 2; + fs->stack = new_array; + } + fs->stack[num].idx = str_idx; + fs->stack[num].node = dest_node; + fs->stack[num].regs = re_malloc (regmatch_t, nregs); + if (fs->stack[num].regs == NULL) + return REG_ESPACE; + memcpy (fs->stack[num].regs, regs, sizeof (regmatch_t) * nregs); + err = re_node_set_init_copy (&fs->stack[num].eps_via_nodes, eps_via_nodes); + return err; +} + +static int +internal_function +pop_fail_stack (struct re_fail_stack_t *fs, int *pidx, int nregs, + regmatch_t *regs, re_node_set *eps_via_nodes) +{ + int num = --fs->num; + assert (num >= 0); + *pidx = fs->stack[num].idx; + memcpy (regs, fs->stack[num].regs, sizeof (regmatch_t) * nregs); + re_node_set_free (eps_via_nodes); + re_free (fs->stack[num].regs); + *eps_via_nodes = fs->stack[num].eps_via_nodes; + return fs->stack[num].node; +} + +/* Set the positions where the subexpressions are starts/ends to registers + PMATCH. + Note: We assume that pmatch[0] is already set, and + pmatch[i].rm_so == pmatch[i].rm_eo == -1 for 0 < i < nmatch. */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +set_regs (const regex_t *preg, const re_match_context_t *mctx, size_t nmatch, + regmatch_t *pmatch, int fl_backtrack) +{ + const re_dfa_t *dfa = (const re_dfa_t *) preg->buffer; + int idx, cur_node; + re_node_set eps_via_nodes; + struct re_fail_stack_t *fs; + struct re_fail_stack_t fs_body = { 0, 2, NULL }; + regmatch_t *prev_idx_match; + int prev_idx_match_malloced = 0; + +#ifdef DEBUG + assert (nmatch > 1); + assert (mctx->state_log != NULL); +#endif + if (fl_backtrack) + { + fs = &fs_body; + fs->stack = re_malloc (struct re_fail_stack_ent_t, fs->alloc); + if (fs->stack == NULL) + return REG_ESPACE; + } + else + fs = NULL; + + cur_node = dfa->init_node; + re_node_set_init_empty (&eps_via_nodes); + +#ifdef HAVE_ALLOCA + if (__libc_use_alloca (nmatch * sizeof (regmatch_t))) + prev_idx_match = (regmatch_t *) alloca (nmatch * sizeof (regmatch_t)); + else +#endif + { + prev_idx_match = re_malloc (regmatch_t, nmatch); + if (prev_idx_match == NULL) + { + free_fail_stack_return (fs); + return REG_ESPACE; + } + prev_idx_match_malloced = 1; + } + memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch); + + for (idx = pmatch[0].rm_so; idx <= pmatch[0].rm_eo ;) + { + update_regs (dfa, pmatch, prev_idx_match, cur_node, idx, nmatch); + + if (idx == pmatch[0].rm_eo && cur_node == mctx->last_node) + { + int reg_idx; + if (fs) + { + for (reg_idx = 0; reg_idx < nmatch; ++reg_idx) + if (pmatch[reg_idx].rm_so > -1 && pmatch[reg_idx].rm_eo == -1) + break; + if (reg_idx == nmatch) + { + re_node_set_free (&eps_via_nodes); + if (prev_idx_match_malloced) + re_free (prev_idx_match); + return free_fail_stack_return (fs); + } + cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch, + &eps_via_nodes); + } + else + { + re_node_set_free (&eps_via_nodes); + if (prev_idx_match_malloced) + re_free (prev_idx_match); + return REG_NOERROR; + } + } + + /* Proceed to next node. */ + cur_node = proceed_next_node (mctx, nmatch, pmatch, &idx, cur_node, + &eps_via_nodes, fs); + + if (BE (cur_node < 0, 0)) + { + if (BE (cur_node == -2, 0)) + { + re_node_set_free (&eps_via_nodes); + if (prev_idx_match_malloced) + re_free (prev_idx_match); + free_fail_stack_return (fs); + return REG_ESPACE; + } + if (fs) + cur_node = pop_fail_stack (fs, &idx, nmatch, pmatch, + &eps_via_nodes); + else + { + re_node_set_free (&eps_via_nodes); + if (prev_idx_match_malloced) + re_free (prev_idx_match); + return REG_NOMATCH; + } + } + } + re_node_set_free (&eps_via_nodes); + if (prev_idx_match_malloced) + re_free (prev_idx_match); + return free_fail_stack_return (fs); +} + +static reg_errcode_t +internal_function +free_fail_stack_return (struct re_fail_stack_t *fs) +{ + if (fs) + { + int fs_idx; + for (fs_idx = 0; fs_idx < fs->num; ++fs_idx) + { + re_node_set_free (&fs->stack[fs_idx].eps_via_nodes); + re_free (fs->stack[fs_idx].regs); + } + re_free (fs->stack); + } + return REG_NOERROR; +} + +static void +internal_function +update_regs (const re_dfa_t *dfa, regmatch_t *pmatch, + regmatch_t *prev_idx_match, int cur_node, int cur_idx, int nmatch) +{ + int type = dfa->nodes[cur_node].type; + if (type == OP_OPEN_SUBEXP) + { + int reg_num = dfa->nodes[cur_node].opr.idx + 1; + + /* We are at the first node of this sub expression. */ + if (reg_num < nmatch) + { + pmatch[reg_num].rm_so = cur_idx; + pmatch[reg_num].rm_eo = -1; + } + } + else if (type == OP_CLOSE_SUBEXP) + { + int reg_num = dfa->nodes[cur_node].opr.idx + 1; + if (reg_num < nmatch) + { + /* We are at the last node of this sub expression. */ + if (pmatch[reg_num].rm_so < cur_idx) + { + pmatch[reg_num].rm_eo = cur_idx; + /* This is a non-empty match or we are not inside an optional + subexpression. Accept this right away. */ + memcpy (prev_idx_match, pmatch, sizeof (regmatch_t) * nmatch); + } + else + { + if (dfa->nodes[cur_node].opt_subexp + && prev_idx_match[reg_num].rm_so != -1) + /* We transited through an empty match for an optional + subexpression, like (a?)*, and this is not the subexp's + first match. Copy back the old content of the registers + so that matches of an inner subexpression are undone as + well, like in ((a?))*. */ + memcpy (pmatch, prev_idx_match, sizeof (regmatch_t) * nmatch); + else + /* We completed a subexpression, but it may be part of + an optional one, so do not update PREV_IDX_MATCH. */ + pmatch[reg_num].rm_eo = cur_idx; + } + } + } +} + +/* This function checks the STATE_LOG from the SCTX->last_str_idx to 0 + and sift the nodes in each states according to the following rules. + Updated state_log will be wrote to STATE_LOG. + + Rules: We throw away the Node `a' in the STATE_LOG[STR_IDX] if... + 1. When STR_IDX == MATCH_LAST(the last index in the state_log): + If `a' isn't the LAST_NODE and `a' can't epsilon transit to + the LAST_NODE, we throw away the node `a'. + 2. When 0 <= STR_IDX < MATCH_LAST and `a' accepts + string `s' and transit to `b': + i. If 'b' isn't in the STATE_LOG[STR_IDX+strlen('s')], we throw + away the node `a'. + ii. If 'b' is in the STATE_LOG[STR_IDX+strlen('s')] but 'b' is + thrown away, we throw away the node `a'. + 3. When 0 <= STR_IDX < MATCH_LAST and 'a' epsilon transit to 'b': + i. If 'b' isn't in the STATE_LOG[STR_IDX], we throw away the + node `a'. + ii. If 'b' is in the STATE_LOG[STR_IDX] but 'b' is thrown away, + we throw away the node `a'. */ + +#define STATE_NODE_CONTAINS(state,node) \ + ((state) != NULL && re_node_set_contains (&(state)->nodes, node)) + +static reg_errcode_t +internal_function +sift_states_backward (const re_match_context_t *mctx, re_sift_context_t *sctx) +{ + reg_errcode_t err; + int null_cnt = 0; + int str_idx = sctx->last_str_idx; + re_node_set cur_dest; + +#ifdef DEBUG + assert (mctx->state_log != NULL && mctx->state_log[str_idx] != NULL); +#endif + + /* Build sifted state_log[str_idx]. It has the nodes which can epsilon + transit to the last_node and the last_node itself. */ + err = re_node_set_init_1 (&cur_dest, sctx->last_node); + if (BE (err != REG_NOERROR, 0)) + return err; + err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest); + if (BE (err != REG_NOERROR, 0)) + goto free_return; + + /* Then check each states in the state_log. */ + while (str_idx > 0) + { + /* Update counters. */ + null_cnt = (sctx->sifted_states[str_idx] == NULL) ? null_cnt + 1 : 0; + if (null_cnt > mctx->max_mb_elem_len) + { + memset (sctx->sifted_states, '\0', + sizeof (re_dfastate_t *) * str_idx); + re_node_set_free (&cur_dest); + return REG_NOERROR; + } + re_node_set_empty (&cur_dest); + --str_idx; + + if (mctx->state_log[str_idx]) + { + err = build_sifted_states (mctx, sctx, str_idx, &cur_dest); + if (BE (err != REG_NOERROR, 0)) + goto free_return; + } + + /* Add all the nodes which satisfy the following conditions: + - It can epsilon transit to a node in CUR_DEST. + - It is in CUR_SRC. + And update state_log. */ + err = update_cur_sifted_state (mctx, sctx, str_idx, &cur_dest); + if (BE (err != REG_NOERROR, 0)) + goto free_return; + } + err = REG_NOERROR; + free_return: + re_node_set_free (&cur_dest); + return err; +} + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +build_sifted_states (const re_match_context_t *mctx, re_sift_context_t *sctx, + int str_idx, re_node_set *cur_dest) +{ + const re_dfa_t *const dfa = mctx->dfa; + const re_node_set *cur_src = &mctx->state_log[str_idx]->non_eps_nodes; + int i; + + /* Then build the next sifted state. + We build the next sifted state on `cur_dest', and update + `sifted_states[str_idx]' with `cur_dest'. + Note: + `cur_dest' is the sifted state from `state_log[str_idx + 1]'. + `cur_src' points the node_set of the old `state_log[str_idx]' + (with the epsilon nodes pre-filtered out). */ + for (i = 0; i < cur_src->nelem; i++) + { + int prev_node = cur_src->elems[i]; + int naccepted = 0; + int ret; + +#ifdef DEBUG + re_token_type_t type = dfa->nodes[prev_node].type; + assert (!IS_EPSILON_NODE (type)); +#endif +#ifdef RE_ENABLE_I18N + /* If the node may accept `multi byte'. */ + if (dfa->nodes[prev_node].accept_mb) + naccepted = sift_states_iter_mb (mctx, sctx, prev_node, + str_idx, sctx->last_str_idx); +#endif /* RE_ENABLE_I18N */ + + /* We don't check backreferences here. + See update_cur_sifted_state(). */ + if (!naccepted + && check_node_accept (mctx, dfa->nodes + prev_node, str_idx) + && STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + 1], + dfa->nexts[prev_node])) + naccepted = 1; + + if (naccepted == 0) + continue; + + if (sctx->limits.nelem) + { + int to_idx = str_idx + naccepted; + if (check_dst_limits (mctx, &sctx->limits, + dfa->nexts[prev_node], to_idx, + prev_node, str_idx)) + continue; + } + ret = re_node_set_insert (cur_dest, prev_node); + if (BE (ret == -1, 0)) + return REG_ESPACE; + } + + return REG_NOERROR; +} + +/* Helper functions. */ + +static reg_errcode_t +internal_function +clean_state_log_if_needed (re_match_context_t *mctx, int next_state_log_idx) +{ + int top = mctx->state_log_top; + + if ((next_state_log_idx >= mctx->input.bufs_len + && mctx->input.bufs_len < mctx->input.len) + || (next_state_log_idx >= mctx->input.valid_len + && mctx->input.valid_len < mctx->input.len)) + { + reg_errcode_t err; + err = extend_buffers (mctx); + if (BE (err != REG_NOERROR, 0)) + return err; + } + + if (top < next_state_log_idx) + { + memset (mctx->state_log + top + 1, '\0', + sizeof (re_dfastate_t *) * (next_state_log_idx - top)); + mctx->state_log_top = next_state_log_idx; + } + return REG_NOERROR; +} + +static reg_errcode_t +internal_function +merge_state_array (const re_dfa_t *dfa, re_dfastate_t **dst, + re_dfastate_t **src, int num) +{ + int st_idx; + reg_errcode_t err; + for (st_idx = 0; st_idx < num; ++st_idx) + { + if (dst[st_idx] == NULL) + dst[st_idx] = src[st_idx]; + else if (src[st_idx] != NULL) + { + re_node_set merged_set; + err = re_node_set_init_union (&merged_set, &dst[st_idx]->nodes, + &src[st_idx]->nodes); + if (BE (err != REG_NOERROR, 0)) + return err; + dst[st_idx] = re_acquire_state (&err, dfa, &merged_set); + re_node_set_free (&merged_set); + if (BE (err != REG_NOERROR, 0)) + return err; + } + } + return REG_NOERROR; +} + +static reg_errcode_t +internal_function +update_cur_sifted_state (const re_match_context_t *mctx, + re_sift_context_t *sctx, int str_idx, + re_node_set *dest_nodes) +{ + const re_dfa_t *const dfa = mctx->dfa; + reg_errcode_t err = REG_NOERROR; + const re_node_set *candidates; + candidates = ((mctx->state_log[str_idx] == NULL) ? NULL + : &mctx->state_log[str_idx]->nodes); + + if (dest_nodes->nelem == 0) + sctx->sifted_states[str_idx] = NULL; + else + { + if (candidates) + { + /* At first, add the nodes which can epsilon transit to a node in + DEST_NODE. */ + err = add_epsilon_src_nodes (dfa, dest_nodes, candidates); + if (BE (err != REG_NOERROR, 0)) + return err; + + /* Then, check the limitations in the current sift_context. */ + if (sctx->limits.nelem) + { + err = check_subexp_limits (dfa, dest_nodes, candidates, &sctx->limits, + mctx->bkref_ents, str_idx); + if (BE (err != REG_NOERROR, 0)) + return err; + } + } + + sctx->sifted_states[str_idx] = re_acquire_state (&err, dfa, dest_nodes); + if (BE (err != REG_NOERROR, 0)) + return err; + } + + if (candidates && mctx->state_log[str_idx]->has_backref) + { + err = sift_states_bkref (mctx, sctx, str_idx, candidates); + if (BE (err != REG_NOERROR, 0)) + return err; + } + return REG_NOERROR; +} + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +add_epsilon_src_nodes (const re_dfa_t *dfa, re_node_set *dest_nodes, + const re_node_set *candidates) +{ + reg_errcode_t err = REG_NOERROR; + int i; + + re_dfastate_t *state = re_acquire_state (&err, dfa, dest_nodes); + if (BE (err != REG_NOERROR, 0)) + return err; + + if (!state->inveclosure.alloc) + { + err = re_node_set_alloc (&state->inveclosure, dest_nodes->nelem); + if (BE (err != REG_NOERROR, 0)) + return REG_ESPACE; + for (i = 0; i < dest_nodes->nelem; i++) + { + err = re_node_set_merge (&state->inveclosure, + dfa->inveclosures + dest_nodes->elems[i]); + if (BE (err != REG_NOERROR, 0)) + return REG_ESPACE; + } + } + return re_node_set_add_intersect (dest_nodes, candidates, + &state->inveclosure); +} + +static reg_errcode_t +internal_function +sub_epsilon_src_nodes (const re_dfa_t *dfa, int node, re_node_set *dest_nodes, + const re_node_set *candidates) +{ + int ecl_idx; + reg_errcode_t err; + re_node_set *inv_eclosure = dfa->inveclosures + node; + re_node_set except_nodes; + re_node_set_init_empty (&except_nodes); + for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx) + { + int cur_node = inv_eclosure->elems[ecl_idx]; + if (cur_node == node) + continue; + if (IS_EPSILON_NODE (dfa->nodes[cur_node].type)) + { + int edst1 = dfa->edests[cur_node].elems[0]; + int edst2 = ((dfa->edests[cur_node].nelem > 1) + ? dfa->edests[cur_node].elems[1] : -1); + if ((!re_node_set_contains (inv_eclosure, edst1) + && re_node_set_contains (dest_nodes, edst1)) + || (edst2 > 0 + && !re_node_set_contains (inv_eclosure, edst2) + && re_node_set_contains (dest_nodes, edst2))) + { + err = re_node_set_add_intersect (&except_nodes, candidates, + dfa->inveclosures + cur_node); + if (BE (err != REG_NOERROR, 0)) + { + re_node_set_free (&except_nodes); + return err; + } + } + } + } + for (ecl_idx = 0; ecl_idx < inv_eclosure->nelem; ++ecl_idx) + { + int cur_node = inv_eclosure->elems[ecl_idx]; + if (!re_node_set_contains (&except_nodes, cur_node)) + { + int idx = re_node_set_contains (dest_nodes, cur_node) - 1; + re_node_set_remove_at (dest_nodes, idx); + } + } + re_node_set_free (&except_nodes); + return REG_NOERROR; +} + +static int +internal_function +check_dst_limits (const re_match_context_t *mctx, re_node_set *limits, + int dst_node, int dst_idx, int src_node, int src_idx) +{ + const re_dfa_t *const dfa = mctx->dfa; + int lim_idx, src_pos, dst_pos; + + int dst_bkref_idx = search_cur_bkref_entry (mctx, dst_idx); + int src_bkref_idx = search_cur_bkref_entry (mctx, src_idx); + for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx) + { + int subexp_idx; + struct re_backref_cache_entry *ent; + ent = mctx->bkref_ents + limits->elems[lim_idx]; + subexp_idx = dfa->nodes[ent->node].opr.idx; + + dst_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx], + subexp_idx, dst_node, dst_idx, + dst_bkref_idx); + src_pos = check_dst_limits_calc_pos (mctx, limits->elems[lim_idx], + subexp_idx, src_node, src_idx, + src_bkref_idx); + + /* In case of: + ( ) + ( ) + ( ) */ + if (src_pos == dst_pos) + continue; /* This is unrelated limitation. */ + else + return 1; + } + return 0; +} + +static int +internal_function +check_dst_limits_calc_pos_1 (const re_match_context_t *mctx, int boundaries, + int subexp_idx, int from_node, int bkref_idx) +{ + const re_dfa_t *const dfa = mctx->dfa; + const re_node_set *eclosures = dfa->eclosures + from_node; + int node_idx; + + /* Else, we are on the boundary: examine the nodes on the epsilon + closure. */ + for (node_idx = 0; node_idx < eclosures->nelem; ++node_idx) + { + int node = eclosures->elems[node_idx]; + switch (dfa->nodes[node].type) + { + case OP_BACK_REF: + if (bkref_idx != -1) + { + struct re_backref_cache_entry *ent = mctx->bkref_ents + bkref_idx; + do + { + int dst, cpos; + + if (ent->node != node) + continue; + + if (subexp_idx < BITSET_WORD_BITS + && !(ent->eps_reachable_subexps_map + & ((bitset_word_t) 1 << subexp_idx))) + continue; + + /* Recurse trying to reach the OP_OPEN_SUBEXP and + OP_CLOSE_SUBEXP cases below. But, if the + destination node is the same node as the source + node, don't recurse because it would cause an + infinite loop: a regex that exhibits this behavior + is ()\1*\1* */ + dst = dfa->edests[node].elems[0]; + if (dst == from_node) + { + if (boundaries & 1) + return -1; + else /* if (boundaries & 2) */ + return 0; + } + + cpos = + check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx, + dst, bkref_idx); + if (cpos == -1 /* && (boundaries & 1) */) + return -1; + if (cpos == 0 && (boundaries & 2)) + return 0; + + if (subexp_idx < BITSET_WORD_BITS) + ent->eps_reachable_subexps_map + &= ~((bitset_word_t) 1 << subexp_idx); + } + while (ent++->more); + } + break; + + case OP_OPEN_SUBEXP: + if ((boundaries & 1) && subexp_idx == dfa->nodes[node].opr.idx) + return -1; + break; + + case OP_CLOSE_SUBEXP: + if ((boundaries & 2) && subexp_idx == dfa->nodes[node].opr.idx) + return 0; + break; + + default: + break; + } + } + + return (boundaries & 2) ? 1 : 0; +} + +static int +internal_function +check_dst_limits_calc_pos (const re_match_context_t *mctx, int limit, + int subexp_idx, int from_node, int str_idx, + int bkref_idx) +{ + struct re_backref_cache_entry *lim = mctx->bkref_ents + limit; + int boundaries; + + /* If we are outside the range of the subexpression, return -1 or 1. */ + if (str_idx < lim->subexp_from) + return -1; + + if (lim->subexp_to < str_idx) + return 1; + + /* If we are within the subexpression, return 0. */ + boundaries = (str_idx == lim->subexp_from); + boundaries |= (str_idx == lim->subexp_to) << 1; + if (boundaries == 0) + return 0; + + /* Else, examine epsilon closure. */ + return check_dst_limits_calc_pos_1 (mctx, boundaries, subexp_idx, + from_node, bkref_idx); +} + +/* Check the limitations of sub expressions LIMITS, and remove the nodes + which are against limitations from DEST_NODES. */ + +static reg_errcode_t +internal_function +check_subexp_limits (const re_dfa_t *dfa, re_node_set *dest_nodes, + const re_node_set *candidates, re_node_set *limits, + struct re_backref_cache_entry *bkref_ents, int str_idx) +{ + reg_errcode_t err; + int node_idx, lim_idx; + + for (lim_idx = 0; lim_idx < limits->nelem; ++lim_idx) + { + int subexp_idx; + struct re_backref_cache_entry *ent; + ent = bkref_ents + limits->elems[lim_idx]; + + if (str_idx <= ent->subexp_from || ent->str_idx < str_idx) + continue; /* This is unrelated limitation. */ + + subexp_idx = dfa->nodes[ent->node].opr.idx; + if (ent->subexp_to == str_idx) + { + int ops_node = -1; + int cls_node = -1; + for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) + { + int node = dest_nodes->elems[node_idx]; + re_token_type_t type = dfa->nodes[node].type; + if (type == OP_OPEN_SUBEXP + && subexp_idx == dfa->nodes[node].opr.idx) + ops_node = node; + else if (type == OP_CLOSE_SUBEXP + && subexp_idx == dfa->nodes[node].opr.idx) + cls_node = node; + } + + /* Check the limitation of the open subexpression. */ + /* Note that (ent->subexp_to = str_idx != ent->subexp_from). */ + if (ops_node >= 0) + { + err = sub_epsilon_src_nodes (dfa, ops_node, dest_nodes, + candidates); + if (BE (err != REG_NOERROR, 0)) + return err; + } + + /* Check the limitation of the close subexpression. */ + if (cls_node >= 0) + for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) + { + int node = dest_nodes->elems[node_idx]; + if (!re_node_set_contains (dfa->inveclosures + node, + cls_node) + && !re_node_set_contains (dfa->eclosures + node, + cls_node)) + { + /* It is against this limitation. + Remove it form the current sifted state. */ + err = sub_epsilon_src_nodes (dfa, node, dest_nodes, + candidates); + if (BE (err != REG_NOERROR, 0)) + return err; + --node_idx; + } + } + } + else /* (ent->subexp_to != str_idx) */ + { + for (node_idx = 0; node_idx < dest_nodes->nelem; ++node_idx) + { + int node = dest_nodes->elems[node_idx]; + re_token_type_t type = dfa->nodes[node].type; + if (type == OP_CLOSE_SUBEXP || type == OP_OPEN_SUBEXP) + { + if (subexp_idx != dfa->nodes[node].opr.idx) + continue; + /* It is against this limitation. + Remove it form the current sifted state. */ + err = sub_epsilon_src_nodes (dfa, node, dest_nodes, + candidates); + if (BE (err != REG_NOERROR, 0)) + return err; + } + } + } + } + return REG_NOERROR; +} + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +sift_states_bkref (const re_match_context_t *mctx, re_sift_context_t *sctx, + int str_idx, const re_node_set *candidates) +{ + const re_dfa_t *const dfa = mctx->dfa; + reg_errcode_t err; + int node_idx, node; + re_sift_context_t local_sctx; + int first_idx = search_cur_bkref_entry (mctx, str_idx); + + if (first_idx == -1) + return REG_NOERROR; + + local_sctx.sifted_states = NULL; /* Mark that it hasn't been initialized. */ + + for (node_idx = 0; node_idx < candidates->nelem; ++node_idx) + { + int enabled_idx; + re_token_type_t type; + struct re_backref_cache_entry *entry; + node = candidates->elems[node_idx]; + type = dfa->nodes[node].type; + /* Avoid infinite loop for the REs like "()\1+". */ + if (node == sctx->last_node && str_idx == sctx->last_str_idx) + continue; + if (type != OP_BACK_REF) + continue; + + entry = mctx->bkref_ents + first_idx; + enabled_idx = first_idx; + do + { + int subexp_len; + int to_idx; + int dst_node; + int ret; + re_dfastate_t *cur_state; + + if (entry->node != node) + continue; + subexp_len = entry->subexp_to - entry->subexp_from; + to_idx = str_idx + subexp_len; + dst_node = (subexp_len ? dfa->nexts[node] + : dfa->edests[node].elems[0]); + + if (to_idx > sctx->last_str_idx + || sctx->sifted_states[to_idx] == NULL + || !STATE_NODE_CONTAINS (sctx->sifted_states[to_idx], dst_node) + || check_dst_limits (mctx, &sctx->limits, node, + str_idx, dst_node, to_idx)) + continue; + + if (local_sctx.sifted_states == NULL) + { + local_sctx = *sctx; + err = re_node_set_init_copy (&local_sctx.limits, &sctx->limits); + if (BE (err != REG_NOERROR, 0)) + goto free_return; + } + local_sctx.last_node = node; + local_sctx.last_str_idx = str_idx; + ret = re_node_set_insert (&local_sctx.limits, enabled_idx); + if (BE (ret < 0, 0)) + { + err = REG_ESPACE; + goto free_return; + } + cur_state = local_sctx.sifted_states[str_idx]; + err = sift_states_backward (mctx, &local_sctx); + if (BE (err != REG_NOERROR, 0)) + goto free_return; + if (sctx->limited_states != NULL) + { + err = merge_state_array (dfa, sctx->limited_states, + local_sctx.sifted_states, + str_idx + 1); + if (BE (err != REG_NOERROR, 0)) + goto free_return; + } + local_sctx.sifted_states[str_idx] = cur_state; + re_node_set_remove (&local_sctx.limits, enabled_idx); + + /* mctx->bkref_ents may have changed, reload the pointer. */ + entry = mctx->bkref_ents + enabled_idx; + } + while (enabled_idx++, entry++->more); + } + err = REG_NOERROR; + free_return: + if (local_sctx.sifted_states != NULL) + { + re_node_set_free (&local_sctx.limits); + } + + return err; +} + + +#ifdef RE_ENABLE_I18N +static int +internal_function +sift_states_iter_mb (const re_match_context_t *mctx, re_sift_context_t *sctx, + int node_idx, int str_idx, int max_str_idx) +{ + const re_dfa_t *const dfa = mctx->dfa; + int naccepted; + /* Check the node can accept `multi byte'. */ + naccepted = check_node_accept_bytes (dfa, node_idx, &mctx->input, str_idx); + if (naccepted > 0 && str_idx + naccepted <= max_str_idx && + !STATE_NODE_CONTAINS (sctx->sifted_states[str_idx + naccepted], + dfa->nexts[node_idx])) + /* The node can't accept the `multi byte', or the + destination was already thrown away, then the node + could't accept the current input `multi byte'. */ + naccepted = 0; + /* Otherwise, it is sure that the node could accept + `naccepted' bytes input. */ + return naccepted; +} +#endif /* RE_ENABLE_I18N */ + + +/* Functions for state transition. */ + +/* Return the next state to which the current state STATE will transit by + accepting the current input byte, and update STATE_LOG if necessary. + If STATE can accept a multibyte char/collating element/back reference + update the destination of STATE_LOG. */ + +static re_dfastate_t * +internal_function __attribute_warn_unused_result__ +transit_state (reg_errcode_t *err, re_match_context_t *mctx, + re_dfastate_t *state) +{ + re_dfastate_t **trtable; + unsigned char ch; + +#ifdef RE_ENABLE_I18N + /* If the current state can accept multibyte. */ + if (BE (state->accept_mb, 0)) + { + *err = transit_state_mb (mctx, state); + if (BE (*err != REG_NOERROR, 0)) + return NULL; + } +#endif /* RE_ENABLE_I18N */ + + /* Then decide the next state with the single byte. */ +#if 0 + if (0) + /* don't use transition table */ + return transit_state_sb (err, mctx, state); +#endif + + /* Use transition table */ + ch = re_string_fetch_byte (&mctx->input); + for (;;) + { + trtable = state->trtable; + if (BE (trtable != NULL, 1)) + return trtable[ch]; + + trtable = state->word_trtable; + if (BE (trtable != NULL, 1)) + { + unsigned int context; + context + = re_string_context_at (&mctx->input, + re_string_cur_idx (&mctx->input) - 1, + mctx->eflags); + if (IS_WORD_CONTEXT (context)) + return trtable[ch + SBC_MAX]; + else + return trtable[ch]; + } + + if (!build_trtable (mctx->dfa, state)) + { + *err = REG_ESPACE; + return NULL; + } + + /* Retry, we now have a transition table. */ + } +} + +/* Update the state_log if we need */ +re_dfastate_t * +internal_function +merge_state_with_log (reg_errcode_t *err, re_match_context_t *mctx, + re_dfastate_t *next_state) +{ + const re_dfa_t *const dfa = mctx->dfa; + int cur_idx = re_string_cur_idx (&mctx->input); + + if (cur_idx > mctx->state_log_top) + { + mctx->state_log[cur_idx] = next_state; + mctx->state_log_top = cur_idx; + } + else if (mctx->state_log[cur_idx] == 0) + { + mctx->state_log[cur_idx] = next_state; + } + else + { + re_dfastate_t *pstate; + unsigned int context; + re_node_set next_nodes, *log_nodes, *table_nodes = NULL; + /* If (state_log[cur_idx] != 0), it implies that cur_idx is + the destination of a multibyte char/collating element/ + back reference. Then the next state is the union set of + these destinations and the results of the transition table. */ + pstate = mctx->state_log[cur_idx]; + log_nodes = pstate->entrance_nodes; + if (next_state != NULL) + { + table_nodes = next_state->entrance_nodes; + *err = re_node_set_init_union (&next_nodes, table_nodes, + log_nodes); + if (BE (*err != REG_NOERROR, 0)) + return NULL; + } + else + next_nodes = *log_nodes; + /* Note: We already add the nodes of the initial state, + then we don't need to add them here. */ + + context = re_string_context_at (&mctx->input, + re_string_cur_idx (&mctx->input) - 1, + mctx->eflags); + next_state = mctx->state_log[cur_idx] + = re_acquire_state_context (err, dfa, &next_nodes, context); + /* We don't need to check errors here, since the return value of + this function is next_state and ERR is already set. */ + + if (table_nodes != NULL) + re_node_set_free (&next_nodes); + } + + if (BE (dfa->nbackref, 0) && next_state != NULL) + { + /* Check OP_OPEN_SUBEXP in the current state in case that we use them + later. We must check them here, since the back references in the + next state might use them. */ + *err = check_subexp_matching_top (mctx, &next_state->nodes, + cur_idx); + if (BE (*err != REG_NOERROR, 0)) + return NULL; + + /* If the next state has back references. */ + if (next_state->has_backref) + { + *err = transit_state_bkref (mctx, &next_state->nodes); + if (BE (*err != REG_NOERROR, 0)) + return NULL; + next_state = mctx->state_log[cur_idx]; + } + } + + return next_state; +} + +/* Skip bytes in the input that correspond to part of a + multi-byte match, then look in the log for a state + from which to restart matching. */ +re_dfastate_t * +internal_function +find_recover_state (reg_errcode_t *err, re_match_context_t *mctx) +{ + re_dfastate_t *cur_state; + do + { + int max = mctx->state_log_top; + int cur_str_idx = re_string_cur_idx (&mctx->input); + + do + { + if (++cur_str_idx > max) + return NULL; + re_string_skip_bytes (&mctx->input, 1); + } + while (mctx->state_log[cur_str_idx] == NULL); + + cur_state = merge_state_with_log (err, mctx, NULL); + } + while (*err == REG_NOERROR && cur_state == NULL); + return cur_state; +} + +/* Helper functions for transit_state. */ + +/* From the node set CUR_NODES, pick up the nodes whose types are + OP_OPEN_SUBEXP and which have corresponding back references in the regular + expression. And register them to use them later for evaluating the + correspoding back references. */ + +static reg_errcode_t +internal_function +check_subexp_matching_top (re_match_context_t *mctx, re_node_set *cur_nodes, + int str_idx) +{ + const re_dfa_t *const dfa = mctx->dfa; + int node_idx; + reg_errcode_t err; + + /* TODO: This isn't efficient. + Because there might be more than one nodes whose types are + OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all + nodes. + E.g. RE: (a){2} */ + for (node_idx = 0; node_idx < cur_nodes->nelem; ++node_idx) + { + int node = cur_nodes->elems[node_idx]; + if (dfa->nodes[node].type == OP_OPEN_SUBEXP + && dfa->nodes[node].opr.idx < BITSET_WORD_BITS + && (dfa->used_bkref_map + & ((bitset_word_t) 1 << dfa->nodes[node].opr.idx))) + { + err = match_ctx_add_subtop (mctx, node, str_idx); + if (BE (err != REG_NOERROR, 0)) + return err; + } + } + return REG_NOERROR; +} + +#if 0 +/* Return the next state to which the current state STATE will transit by + accepting the current input byte. */ + +static re_dfastate_t * +transit_state_sb (reg_errcode_t *err, re_match_context_t *mctx, + re_dfastate_t *state) +{ + const re_dfa_t *const dfa = mctx->dfa; + re_node_set next_nodes; + re_dfastate_t *next_state; + int node_cnt, cur_str_idx = re_string_cur_idx (&mctx->input); + unsigned int context; + + *err = re_node_set_alloc (&next_nodes, state->nodes.nelem + 1); + if (BE (*err != REG_NOERROR, 0)) + return NULL; + for (node_cnt = 0; node_cnt < state->nodes.nelem; ++node_cnt) + { + int cur_node = state->nodes.elems[node_cnt]; + if (check_node_accept (mctx, dfa->nodes + cur_node, cur_str_idx)) + { + *err = re_node_set_merge (&next_nodes, + dfa->eclosures + dfa->nexts[cur_node]); + if (BE (*err != REG_NOERROR, 0)) + { + re_node_set_free (&next_nodes); + return NULL; + } + } + } + context = re_string_context_at (&mctx->input, cur_str_idx, mctx->eflags); + next_state = re_acquire_state_context (err, dfa, &next_nodes, context); + /* We don't need to check errors here, since the return value of + this function is next_state and ERR is already set. */ + + re_node_set_free (&next_nodes); + re_string_skip_bytes (&mctx->input, 1); + return next_state; +} +#endif + +#ifdef RE_ENABLE_I18N +static reg_errcode_t +internal_function +transit_state_mb (re_match_context_t *mctx, re_dfastate_t *pstate) +{ + const re_dfa_t *const dfa = mctx->dfa; + reg_errcode_t err; + int i; + + for (i = 0; i < pstate->nodes.nelem; ++i) + { + re_node_set dest_nodes, *new_nodes; + int cur_node_idx = pstate->nodes.elems[i]; + int naccepted, dest_idx; + unsigned int context; + re_dfastate_t *dest_state; + + if (!dfa->nodes[cur_node_idx].accept_mb) + continue; + + if (dfa->nodes[cur_node_idx].constraint) + { + context = re_string_context_at (&mctx->input, + re_string_cur_idx (&mctx->input), + mctx->eflags); + if (NOT_SATISFY_NEXT_CONSTRAINT (dfa->nodes[cur_node_idx].constraint, + context)) + continue; + } + + /* How many bytes the node can accept? */ + naccepted = check_node_accept_bytes (dfa, cur_node_idx, &mctx->input, + re_string_cur_idx (&mctx->input)); + if (naccepted == 0) + continue; + + /* The node can accepts `naccepted' bytes. */ + dest_idx = re_string_cur_idx (&mctx->input) + naccepted; + mctx->max_mb_elem_len = ((mctx->max_mb_elem_len < naccepted) ? naccepted + : mctx->max_mb_elem_len); + err = clean_state_log_if_needed (mctx, dest_idx); + if (BE (err != REG_NOERROR, 0)) + return err; +#ifdef DEBUG + assert (dfa->nexts[cur_node_idx] != -1); +#endif + new_nodes = dfa->eclosures + dfa->nexts[cur_node_idx]; + + dest_state = mctx->state_log[dest_idx]; + if (dest_state == NULL) + dest_nodes = *new_nodes; + else + { + err = re_node_set_init_union (&dest_nodes, + dest_state->entrance_nodes, new_nodes); + if (BE (err != REG_NOERROR, 0)) + return err; + } + context = re_string_context_at (&mctx->input, dest_idx - 1, + mctx->eflags); + mctx->state_log[dest_idx] + = re_acquire_state_context (&err, dfa, &dest_nodes, context); + if (dest_state != NULL) + re_node_set_free (&dest_nodes); + if (BE (mctx->state_log[dest_idx] == NULL && err != REG_NOERROR, 0)) + return err; + } + return REG_NOERROR; +} +#endif /* RE_ENABLE_I18N */ + +static reg_errcode_t +internal_function +transit_state_bkref (re_match_context_t *mctx, const re_node_set *nodes) +{ + const re_dfa_t *const dfa = mctx->dfa; + reg_errcode_t err; + int i; + int cur_str_idx = re_string_cur_idx (&mctx->input); + + for (i = 0; i < nodes->nelem; ++i) + { + int dest_str_idx, prev_nelem, bkc_idx; + int node_idx = nodes->elems[i]; + unsigned int context; + const re_token_t *node = dfa->nodes + node_idx; + re_node_set *new_dest_nodes; + + /* Check whether `node' is a backreference or not. */ + if (node->type != OP_BACK_REF) + continue; + + if (node->constraint) + { + context = re_string_context_at (&mctx->input, cur_str_idx, + mctx->eflags); + if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context)) + continue; + } + + /* `node' is a backreference. + Check the substring which the substring matched. */ + bkc_idx = mctx->nbkref_ents; + err = get_subexp (mctx, node_idx, cur_str_idx); + if (BE (err != REG_NOERROR, 0)) + goto free_return; + + /* And add the epsilon closures (which is `new_dest_nodes') of + the backreference to appropriate state_log. */ +#ifdef DEBUG + assert (dfa->nexts[node_idx] != -1); +#endif + for (; bkc_idx < mctx->nbkref_ents; ++bkc_idx) + { + int subexp_len; + re_dfastate_t *dest_state; + struct re_backref_cache_entry *bkref_ent; + bkref_ent = mctx->bkref_ents + bkc_idx; + if (bkref_ent->node != node_idx || bkref_ent->str_idx != cur_str_idx) + continue; + subexp_len = bkref_ent->subexp_to - bkref_ent->subexp_from; + new_dest_nodes = (subexp_len == 0 + ? dfa->eclosures + dfa->edests[node_idx].elems[0] + : dfa->eclosures + dfa->nexts[node_idx]); + dest_str_idx = (cur_str_idx + bkref_ent->subexp_to + - bkref_ent->subexp_from); + context = re_string_context_at (&mctx->input, dest_str_idx - 1, + mctx->eflags); + dest_state = mctx->state_log[dest_str_idx]; + prev_nelem = ((mctx->state_log[cur_str_idx] == NULL) ? 0 + : mctx->state_log[cur_str_idx]->nodes.nelem); + /* Add `new_dest_node' to state_log. */ + if (dest_state == NULL) + { + mctx->state_log[dest_str_idx] + = re_acquire_state_context (&err, dfa, new_dest_nodes, + context); + if (BE (mctx->state_log[dest_str_idx] == NULL + && err != REG_NOERROR, 0)) + goto free_return; + } + else + { + re_node_set dest_nodes; + err = re_node_set_init_union (&dest_nodes, + dest_state->entrance_nodes, + new_dest_nodes); + if (BE (err != REG_NOERROR, 0)) + { + re_node_set_free (&dest_nodes); + goto free_return; + } + mctx->state_log[dest_str_idx] + = re_acquire_state_context (&err, dfa, &dest_nodes, context); + re_node_set_free (&dest_nodes); + if (BE (mctx->state_log[dest_str_idx] == NULL + && err != REG_NOERROR, 0)) + goto free_return; + } + /* We need to check recursively if the backreference can epsilon + transit. */ + if (subexp_len == 0 + && mctx->state_log[cur_str_idx]->nodes.nelem > prev_nelem) + { + err = check_subexp_matching_top (mctx, new_dest_nodes, + cur_str_idx); + if (BE (err != REG_NOERROR, 0)) + goto free_return; + err = transit_state_bkref (mctx, new_dest_nodes); + if (BE (err != REG_NOERROR, 0)) + goto free_return; + } + } + } + err = REG_NOERROR; + free_return: + return err; +} + +/* Enumerate all the candidates which the backreference BKREF_NODE can match + at BKREF_STR_IDX, and register them by match_ctx_add_entry(). + Note that we might collect inappropriate candidates here. + However, the cost of checking them strictly here is too high, then we + delay these checking for prune_impossible_nodes(). */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +get_subexp (re_match_context_t *mctx, int bkref_node, int bkref_str_idx) +{ + const re_dfa_t *const dfa = mctx->dfa; + int subexp_num, sub_top_idx; + const char *buf = (const char *) re_string_get_buffer (&mctx->input); + /* Return if we have already checked BKREF_NODE at BKREF_STR_IDX. */ + int cache_idx = search_cur_bkref_entry (mctx, bkref_str_idx); + if (cache_idx != -1) + { + const struct re_backref_cache_entry *entry + = mctx->bkref_ents + cache_idx; + do + if (entry->node == bkref_node) + return REG_NOERROR; /* We already checked it. */ + while (entry++->more); + } + + subexp_num = dfa->nodes[bkref_node].opr.idx; + + /* For each sub expression */ + for (sub_top_idx = 0; sub_top_idx < mctx->nsub_tops; ++sub_top_idx) + { + reg_errcode_t err; + re_sub_match_top_t *sub_top = mctx->sub_tops[sub_top_idx]; + re_sub_match_last_t *sub_last; + int sub_last_idx, sl_str, bkref_str_off; + + if (dfa->nodes[sub_top->node].opr.idx != subexp_num) + continue; /* It isn't related. */ + + sl_str = sub_top->str_idx; + bkref_str_off = bkref_str_idx; + /* At first, check the last node of sub expressions we already + evaluated. */ + for (sub_last_idx = 0; sub_last_idx < sub_top->nlasts; ++sub_last_idx) + { + int sl_str_diff; + sub_last = sub_top->lasts[sub_last_idx]; + sl_str_diff = sub_last->str_idx - sl_str; + /* The matched string by the sub expression match with the substring + at the back reference? */ + if (sl_str_diff > 0) + { + if (BE (bkref_str_off + sl_str_diff > mctx->input.valid_len, 0)) + { + /* Not enough chars for a successful match. */ + if (bkref_str_off + sl_str_diff > mctx->input.len) + break; + + err = clean_state_log_if_needed (mctx, + bkref_str_off + + sl_str_diff); + if (BE (err != REG_NOERROR, 0)) + return err; + buf = (const char *) re_string_get_buffer (&mctx->input); + } + if (memcmp (buf + bkref_str_off, buf + sl_str, sl_str_diff) != 0) + /* We don't need to search this sub expression any more. */ + break; + } + bkref_str_off += sl_str_diff; + sl_str += sl_str_diff; + err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node, + bkref_str_idx); + + /* Reload buf, since the preceding call might have reallocated + the buffer. */ + buf = (const char *) re_string_get_buffer (&mctx->input); + + if (err == REG_NOMATCH) + continue; + if (BE (err != REG_NOERROR, 0)) + return err; + } + + if (sub_last_idx < sub_top->nlasts) + continue; + if (sub_last_idx > 0) + ++sl_str; + /* Then, search for the other last nodes of the sub expression. */ + for (; sl_str <= bkref_str_idx; ++sl_str) + { + int cls_node, sl_str_off; + const re_node_set *nodes; + sl_str_off = sl_str - sub_top->str_idx; + /* The matched string by the sub expression match with the substring + at the back reference? */ + if (sl_str_off > 0) + { + if (BE (bkref_str_off >= mctx->input.valid_len, 0)) + { + /* If we are at the end of the input, we cannot match. */ + if (bkref_str_off >= mctx->input.len) + break; + + err = extend_buffers (mctx); + if (BE (err != REG_NOERROR, 0)) + return err; + + buf = (const char *) re_string_get_buffer (&mctx->input); + } + if (buf [bkref_str_off++] != buf[sl_str - 1]) + break; /* We don't need to search this sub expression + any more. */ + } + if (mctx->state_log[sl_str] == NULL) + continue; + /* Does this state have a ')' of the sub expression? */ + nodes = &mctx->state_log[sl_str]->nodes; + cls_node = find_subexp_node (dfa, nodes, subexp_num, + OP_CLOSE_SUBEXP); + if (cls_node == -1) + continue; /* No. */ + if (sub_top->path == NULL) + { + sub_top->path = calloc (sizeof (state_array_t), + sl_str - sub_top->str_idx + 1); + if (sub_top->path == NULL) + return REG_ESPACE; + } + /* Can the OP_OPEN_SUBEXP node arrive the OP_CLOSE_SUBEXP node + in the current context? */ + err = check_arrival (mctx, sub_top->path, sub_top->node, + sub_top->str_idx, cls_node, sl_str, + OP_CLOSE_SUBEXP); + if (err == REG_NOMATCH) + continue; + if (BE (err != REG_NOERROR, 0)) + return err; + sub_last = match_ctx_add_sublast (sub_top, cls_node, sl_str); + if (BE (sub_last == NULL, 0)) + return REG_ESPACE; + err = get_subexp_sub (mctx, sub_top, sub_last, bkref_node, + bkref_str_idx); + if (err == REG_NOMATCH) + continue; + } + } + return REG_NOERROR; +} + +/* Helper functions for get_subexp(). */ + +/* Check SUB_LAST can arrive to the back reference BKREF_NODE at BKREF_STR. + If it can arrive, register the sub expression expressed with SUB_TOP + and SUB_LAST. */ + +static reg_errcode_t +internal_function +get_subexp_sub (re_match_context_t *mctx, const re_sub_match_top_t *sub_top, + re_sub_match_last_t *sub_last, int bkref_node, int bkref_str) +{ + reg_errcode_t err; + int to_idx; + /* Can the subexpression arrive the back reference? */ + err = check_arrival (mctx, &sub_last->path, sub_last->node, + sub_last->str_idx, bkref_node, bkref_str, + OP_OPEN_SUBEXP); + if (err != REG_NOERROR) + return err; + err = match_ctx_add_entry (mctx, bkref_node, bkref_str, sub_top->str_idx, + sub_last->str_idx); + if (BE (err != REG_NOERROR, 0)) + return err; + to_idx = bkref_str + sub_last->str_idx - sub_top->str_idx; + return clean_state_log_if_needed (mctx, to_idx); +} + +/* Find the first node which is '(' or ')' and whose index is SUBEXP_IDX. + Search '(' if FL_OPEN, or search ')' otherwise. + TODO: This function isn't efficient... + Because there might be more than one nodes whose types are + OP_OPEN_SUBEXP and whose index is SUBEXP_IDX, we must check all + nodes. + E.g. RE: (a){2} */ + +static int +internal_function +find_subexp_node (const re_dfa_t *dfa, const re_node_set *nodes, + int subexp_idx, int type) +{ + int cls_idx; + for (cls_idx = 0; cls_idx < nodes->nelem; ++cls_idx) + { + int cls_node = nodes->elems[cls_idx]; + const re_token_t *node = dfa->nodes + cls_node; + if (node->type == type + && node->opr.idx == subexp_idx) + return cls_node; + } + return -1; +} + +/* Check whether the node TOP_NODE at TOP_STR can arrive to the node + LAST_NODE at LAST_STR. We record the path onto PATH since it will be + heavily reused. + Return REG_NOERROR if it can arrive, or REG_NOMATCH otherwise. */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +check_arrival (re_match_context_t *mctx, state_array_t *path, int top_node, + int top_str, int last_node, int last_str, int type) +{ + const re_dfa_t *const dfa = mctx->dfa; + reg_errcode_t err = REG_NOERROR; + int subexp_num, backup_cur_idx, str_idx, null_cnt; + re_dfastate_t *cur_state = NULL; + re_node_set *cur_nodes, next_nodes; + re_dfastate_t **backup_state_log; + unsigned int context; + + subexp_num = dfa->nodes[top_node].opr.idx; + /* Extend the buffer if we need. */ + if (BE (path->alloc < last_str + mctx->max_mb_elem_len + 1, 0)) + { + re_dfastate_t **new_array; + int old_alloc = path->alloc; + path->alloc += last_str + mctx->max_mb_elem_len + 1; + new_array = re_realloc (path->array, re_dfastate_t *, path->alloc); + if (BE (new_array == NULL, 0)) + { + path->alloc = old_alloc; + return REG_ESPACE; + } + path->array = new_array; + memset (new_array + old_alloc, '\0', + sizeof (re_dfastate_t *) * (path->alloc - old_alloc)); + } + + str_idx = path->next_idx ? path->next_idx : top_str; + + /* Temporary modify MCTX. */ + backup_state_log = mctx->state_log; + backup_cur_idx = mctx->input.cur_idx; + mctx->state_log = path->array; + mctx->input.cur_idx = str_idx; + + /* Setup initial node set. */ + context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags); + if (str_idx == top_str) + { + err = re_node_set_init_1 (&next_nodes, top_node); + if (BE (err != REG_NOERROR, 0)) + return err; + err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type); + if (BE (err != REG_NOERROR, 0)) + { + re_node_set_free (&next_nodes); + return err; + } + } + else + { + cur_state = mctx->state_log[str_idx]; + if (cur_state && cur_state->has_backref) + { + err = re_node_set_init_copy (&next_nodes, &cur_state->nodes); + if (BE (err != REG_NOERROR, 0)) + return err; + } + else + re_node_set_init_empty (&next_nodes); + } + if (str_idx == top_str || (cur_state && cur_state->has_backref)) + { + if (next_nodes.nelem) + { + err = expand_bkref_cache (mctx, &next_nodes, str_idx, + subexp_num, type); + if (BE (err != REG_NOERROR, 0)) + { + re_node_set_free (&next_nodes); + return err; + } + } + cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context); + if (BE (cur_state == NULL && err != REG_NOERROR, 0)) + { + re_node_set_free (&next_nodes); + return err; + } + mctx->state_log[str_idx] = cur_state; + } + + for (null_cnt = 0; str_idx < last_str && null_cnt <= mctx->max_mb_elem_len;) + { + re_node_set_empty (&next_nodes); + if (mctx->state_log[str_idx + 1]) + { + err = re_node_set_merge (&next_nodes, + &mctx->state_log[str_idx + 1]->nodes); + if (BE (err != REG_NOERROR, 0)) + { + re_node_set_free (&next_nodes); + return err; + } + } + if (cur_state) + { + err = check_arrival_add_next_nodes (mctx, str_idx, + &cur_state->non_eps_nodes, + &next_nodes); + if (BE (err != REG_NOERROR, 0)) + { + re_node_set_free (&next_nodes); + return err; + } + } + ++str_idx; + if (next_nodes.nelem) + { + err = check_arrival_expand_ecl (dfa, &next_nodes, subexp_num, type); + if (BE (err != REG_NOERROR, 0)) + { + re_node_set_free (&next_nodes); + return err; + } + err = expand_bkref_cache (mctx, &next_nodes, str_idx, + subexp_num, type); + if (BE (err != REG_NOERROR, 0)) + { + re_node_set_free (&next_nodes); + return err; + } + } + context = re_string_context_at (&mctx->input, str_idx - 1, mctx->eflags); + cur_state = re_acquire_state_context (&err, dfa, &next_nodes, context); + if (BE (cur_state == NULL && err != REG_NOERROR, 0)) + { + re_node_set_free (&next_nodes); + return err; + } + mctx->state_log[str_idx] = cur_state; + null_cnt = cur_state == NULL ? null_cnt + 1 : 0; + } + re_node_set_free (&next_nodes); + cur_nodes = (mctx->state_log[last_str] == NULL ? NULL + : &mctx->state_log[last_str]->nodes); + path->next_idx = str_idx; + + /* Fix MCTX. */ + mctx->state_log = backup_state_log; + mctx->input.cur_idx = backup_cur_idx; + + /* Then check the current node set has the node LAST_NODE. */ + if (cur_nodes != NULL && re_node_set_contains (cur_nodes, last_node)) + return REG_NOERROR; + + return REG_NOMATCH; +} + +/* Helper functions for check_arrival. */ + +/* Calculate the destination nodes of CUR_NODES at STR_IDX, and append them + to NEXT_NODES. + TODO: This function is similar to the functions transit_state*(), + however this function has many additional works. + Can't we unify them? */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +check_arrival_add_next_nodes (re_match_context_t *mctx, int str_idx, + re_node_set *cur_nodes, re_node_set *next_nodes) +{ + const re_dfa_t *const dfa = mctx->dfa; + int result; + int cur_idx; +#ifdef RE_ENABLE_I18N + reg_errcode_t err = REG_NOERROR; +#endif + re_node_set union_set; + re_node_set_init_empty (&union_set); + for (cur_idx = 0; cur_idx < cur_nodes->nelem; ++cur_idx) + { + int naccepted = 0; + int cur_node = cur_nodes->elems[cur_idx]; +#ifdef DEBUG + re_token_type_t type = dfa->nodes[cur_node].type; + assert (!IS_EPSILON_NODE (type)); +#endif +#ifdef RE_ENABLE_I18N + /* If the node may accept `multi byte'. */ + if (dfa->nodes[cur_node].accept_mb) + { + naccepted = check_node_accept_bytes (dfa, cur_node, &mctx->input, + str_idx); + if (naccepted > 1) + { + re_dfastate_t *dest_state; + int next_node = dfa->nexts[cur_node]; + int next_idx = str_idx + naccepted; + dest_state = mctx->state_log[next_idx]; + re_node_set_empty (&union_set); + if (dest_state) + { + err = re_node_set_merge (&union_set, &dest_state->nodes); + if (BE (err != REG_NOERROR, 0)) + { + re_node_set_free (&union_set); + return err; + } + } + result = re_node_set_insert (&union_set, next_node); + if (BE (result < 0, 0)) + { + re_node_set_free (&union_set); + return REG_ESPACE; + } + mctx->state_log[next_idx] = re_acquire_state (&err, dfa, + &union_set); + if (BE (mctx->state_log[next_idx] == NULL + && err != REG_NOERROR, 0)) + { + re_node_set_free (&union_set); + return err; + } + } + } +#endif /* RE_ENABLE_I18N */ + if (naccepted + || check_node_accept (mctx, dfa->nodes + cur_node, str_idx)) + { + result = re_node_set_insert (next_nodes, dfa->nexts[cur_node]); + if (BE (result < 0, 0)) + { + re_node_set_free (&union_set); + return REG_ESPACE; + } + } + } + re_node_set_free (&union_set); + return REG_NOERROR; +} + +/* For all the nodes in CUR_NODES, add the epsilon closures of them to + CUR_NODES, however exclude the nodes which are: + - inside the sub expression whose number is EX_SUBEXP, if FL_OPEN. + - out of the sub expression whose number is EX_SUBEXP, if !FL_OPEN. +*/ + +static reg_errcode_t +internal_function +check_arrival_expand_ecl (const re_dfa_t *dfa, re_node_set *cur_nodes, + int ex_subexp, int type) +{ + reg_errcode_t err; + int idx, outside_node; + re_node_set new_nodes; +#ifdef DEBUG + assert (cur_nodes->nelem); +#endif + err = re_node_set_alloc (&new_nodes, cur_nodes->nelem); + if (BE (err != REG_NOERROR, 0)) + return err; + /* Create a new node set NEW_NODES with the nodes which are epsilon + closures of the node in CUR_NODES. */ + + for (idx = 0; idx < cur_nodes->nelem; ++idx) + { + int cur_node = cur_nodes->elems[idx]; + const re_node_set *eclosure = dfa->eclosures + cur_node; + outside_node = find_subexp_node (dfa, eclosure, ex_subexp, type); + if (outside_node == -1) + { + /* There are no problematic nodes, just merge them. */ + err = re_node_set_merge (&new_nodes, eclosure); + if (BE (err != REG_NOERROR, 0)) + { + re_node_set_free (&new_nodes); + return err; + } + } + else + { + /* There are problematic nodes, re-calculate incrementally. */ + err = check_arrival_expand_ecl_sub (dfa, &new_nodes, cur_node, + ex_subexp, type); + if (BE (err != REG_NOERROR, 0)) + { + re_node_set_free (&new_nodes); + return err; + } + } + } + re_node_set_free (cur_nodes); + *cur_nodes = new_nodes; + return REG_NOERROR; +} + +/* Helper function for check_arrival_expand_ecl. + Check incrementally the epsilon closure of TARGET, and if it isn't + problematic append it to DST_NODES. */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +check_arrival_expand_ecl_sub (const re_dfa_t *dfa, re_node_set *dst_nodes, + int target, int ex_subexp, int type) +{ + int cur_node; + for (cur_node = target; !re_node_set_contains (dst_nodes, cur_node);) + { + int err; + + if (dfa->nodes[cur_node].type == type + && dfa->nodes[cur_node].opr.idx == ex_subexp) + { + if (type == OP_CLOSE_SUBEXP) + { + err = re_node_set_insert (dst_nodes, cur_node); + if (BE (err == -1, 0)) + return REG_ESPACE; + } + break; + } + err = re_node_set_insert (dst_nodes, cur_node); + if (BE (err == -1, 0)) + return REG_ESPACE; + if (dfa->edests[cur_node].nelem == 0) + break; + if (dfa->edests[cur_node].nelem == 2) + { + err = check_arrival_expand_ecl_sub (dfa, dst_nodes, + dfa->edests[cur_node].elems[1], + ex_subexp, type); + if (BE (err != REG_NOERROR, 0)) + return err; + } + cur_node = dfa->edests[cur_node].elems[0]; + } + return REG_NOERROR; +} + + +/* For all the back references in the current state, calculate the + destination of the back references by the appropriate entry + in MCTX->BKREF_ENTS. */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +expand_bkref_cache (re_match_context_t *mctx, re_node_set *cur_nodes, + int cur_str, int subexp_num, int type) +{ + const re_dfa_t *const dfa = mctx->dfa; + reg_errcode_t err; + int cache_idx_start = search_cur_bkref_entry (mctx, cur_str); + struct re_backref_cache_entry *ent; + + if (cache_idx_start == -1) + return REG_NOERROR; + + restart: + ent = mctx->bkref_ents + cache_idx_start; + do + { + int to_idx, next_node; + + /* Is this entry ENT is appropriate? */ + if (!re_node_set_contains (cur_nodes, ent->node)) + continue; /* No. */ + + to_idx = cur_str + ent->subexp_to - ent->subexp_from; + /* Calculate the destination of the back reference, and append it + to MCTX->STATE_LOG. */ + if (to_idx == cur_str) + { + /* The backreference did epsilon transit, we must re-check all the + node in the current state. */ + re_node_set new_dests; + reg_errcode_t err2, err3; + next_node = dfa->edests[ent->node].elems[0]; + if (re_node_set_contains (cur_nodes, next_node)) + continue; + err = re_node_set_init_1 (&new_dests, next_node); + err2 = check_arrival_expand_ecl (dfa, &new_dests, subexp_num, type); + err3 = re_node_set_merge (cur_nodes, &new_dests); + re_node_set_free (&new_dests); + if (BE (err != REG_NOERROR || err2 != REG_NOERROR + || err3 != REG_NOERROR, 0)) + { + err = (err != REG_NOERROR ? err + : (err2 != REG_NOERROR ? err2 : err3)); + return err; + } + /* TODO: It is still inefficient... */ + goto restart; + } + else + { + re_node_set union_set; + next_node = dfa->nexts[ent->node]; + if (mctx->state_log[to_idx]) + { + int ret; + if (re_node_set_contains (&mctx->state_log[to_idx]->nodes, + next_node)) + continue; + err = re_node_set_init_copy (&union_set, + &mctx->state_log[to_idx]->nodes); + ret = re_node_set_insert (&union_set, next_node); + if (BE (err != REG_NOERROR || ret < 0, 0)) + { + re_node_set_free (&union_set); + err = err != REG_NOERROR ? err : REG_ESPACE; + return err; + } + } + else + { + err = re_node_set_init_1 (&union_set, next_node); + if (BE (err != REG_NOERROR, 0)) + return err; + } + mctx->state_log[to_idx] = re_acquire_state (&err, dfa, &union_set); + re_node_set_free (&union_set); + if (BE (mctx->state_log[to_idx] == NULL + && err != REG_NOERROR, 0)) + return err; + } + } + while (ent++->more); + return REG_NOERROR; +} + +/* Build transition table for the state. + Return 1 if succeeded, otherwise return NULL. */ + +static int +internal_function +build_trtable (const re_dfa_t *dfa, re_dfastate_t *state) +{ + reg_errcode_t err; + int i, j, ch, need_word_trtable = 0; + bitset_word_t elem, mask; + bool dests_node_malloced = false; + bool dest_states_malloced = false; + int ndests; /* Number of the destination states from `state'. */ + re_dfastate_t **trtable; + re_dfastate_t **dest_states = NULL, **dest_states_word, **dest_states_nl; + re_node_set follows, *dests_node; + bitset_t *dests_ch; + bitset_t acceptable; + + struct dests_alloc + { + re_node_set dests_node[SBC_MAX]; + bitset_t dests_ch[SBC_MAX]; + } *dests_alloc; + + /* We build DFA states which corresponds to the destination nodes + from `state'. `dests_node[i]' represents the nodes which i-th + destination state contains, and `dests_ch[i]' represents the + characters which i-th destination state accepts. */ +#ifdef HAVE_ALLOCA + if (__libc_use_alloca (sizeof (struct dests_alloc))) + dests_alloc = (struct dests_alloc *) alloca (sizeof (struct dests_alloc)); + else +#endif + { + dests_alloc = re_malloc (struct dests_alloc, 1); + if (BE (dests_alloc == NULL, 0)) + return 0; + dests_node_malloced = true; + } + dests_node = dests_alloc->dests_node; + dests_ch = dests_alloc->dests_ch; + + /* Initialize transiton table. */ + state->word_trtable = state->trtable = NULL; + + /* At first, group all nodes belonging to `state' into several + destinations. */ + ndests = group_nodes_into_DFAstates (dfa, state, dests_node, dests_ch); + if (BE (ndests <= 0, 0)) + { + if (dests_node_malloced) + free (dests_alloc); + /* Return 0 in case of an error, 1 otherwise. */ + if (ndests == 0) + { + state->trtable = (re_dfastate_t **) + calloc (sizeof (re_dfastate_t *), SBC_MAX); + if (BE (state->trtable == NULL, 0)) + return 0; + return 1; + } + return 0; + } + + err = re_node_set_alloc (&follows, ndests + 1); + if (BE (err != REG_NOERROR, 0)) + goto out_free; + + /* Avoid arithmetic overflow in size calculation. */ + if (BE ((((SIZE_MAX - (sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX) + / (3 * sizeof (re_dfastate_t *))) + < ndests), + 0)) + goto out_free; + +#ifdef HAVE_ALLOCA + if (__libc_use_alloca ((sizeof (re_node_set) + sizeof (bitset_t)) * SBC_MAX + + ndests * 3 * sizeof (re_dfastate_t *))) + dest_states = (re_dfastate_t **) + alloca (ndests * 3 * sizeof (re_dfastate_t *)); + else +#endif + { + dest_states = (re_dfastate_t **) + malloc (ndests * 3 * sizeof (re_dfastate_t *)); + if (BE (dest_states == NULL, 0)) + { +out_free: + if (dest_states_malloced) + free (dest_states); + re_node_set_free (&follows); + for (i = 0; i < ndests; ++i) + re_node_set_free (dests_node + i); + if (dests_node_malloced) + free (dests_alloc); + return 0; + } + dest_states_malloced = true; + } + dest_states_word = dest_states + ndests; + dest_states_nl = dest_states_word + ndests; + bitset_empty (acceptable); + + /* Then build the states for all destinations. */ + for (i = 0; i < ndests; ++i) + { + int next_node; + re_node_set_empty (&follows); + /* Merge the follows of this destination states. */ + for (j = 0; j < dests_node[i].nelem; ++j) + { + next_node = dfa->nexts[dests_node[i].elems[j]]; + if (next_node != -1) + { + err = re_node_set_merge (&follows, dfa->eclosures + next_node); + if (BE (err != REG_NOERROR, 0)) + goto out_free; + } + } + dest_states[i] = re_acquire_state_context (&err, dfa, &follows, 0); + if (BE (dest_states[i] == NULL && err != REG_NOERROR, 0)) + goto out_free; + /* If the new state has context constraint, + build appropriate states for these contexts. */ + if (dest_states[i]->has_constraint) + { + dest_states_word[i] = re_acquire_state_context (&err, dfa, &follows, + CONTEXT_WORD); + if (BE (dest_states_word[i] == NULL && err != REG_NOERROR, 0)) + goto out_free; + + if (dest_states[i] != dest_states_word[i] && dfa->mb_cur_max > 1) + need_word_trtable = 1; + + dest_states_nl[i] = re_acquire_state_context (&err, dfa, &follows, + CONTEXT_NEWLINE); + if (BE (dest_states_nl[i] == NULL && err != REG_NOERROR, 0)) + goto out_free; + } + else + { + dest_states_word[i] = dest_states[i]; + dest_states_nl[i] = dest_states[i]; + } + bitset_merge (acceptable, dests_ch[i]); + } + + if (!BE (need_word_trtable, 0)) + { + /* We don't care about whether the following character is a word + character, or we are in a single-byte character set so we can + discern by looking at the character code: allocate a + 256-entry transition table. */ + trtable = state->trtable = + (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), SBC_MAX); + if (BE (trtable == NULL, 0)) + goto out_free; + + /* For all characters ch...: */ + for (i = 0; i < BITSET_WORDS; ++i) + for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1; + elem; + mask <<= 1, elem >>= 1, ++ch) + if (BE (elem & 1, 0)) + { + /* There must be exactly one destination which accepts + character ch. See group_nodes_into_DFAstates. */ + for (j = 0; (dests_ch[j][i] & mask) == 0; ++j) + ; + + /* j-th destination accepts the word character ch. */ + if (dfa->word_char[i] & mask) + trtable[ch] = dest_states_word[j]; + else + trtable[ch] = dest_states[j]; + } + } + else + { + /* We care about whether the following character is a word + character, and we are in a multi-byte character set: discern + by looking at the character code: build two 256-entry + transition tables, one starting at trtable[0] and one + starting at trtable[SBC_MAX]. */ + trtable = state->word_trtable = + (re_dfastate_t **) calloc (sizeof (re_dfastate_t *), 2 * SBC_MAX); + if (BE (trtable == NULL, 0)) + goto out_free; + + /* For all characters ch...: */ + for (i = 0; i < BITSET_WORDS; ++i) + for (ch = i * BITSET_WORD_BITS, elem = acceptable[i], mask = 1; + elem; + mask <<= 1, elem >>= 1, ++ch) + if (BE (elem & 1, 0)) + { + /* There must be exactly one destination which accepts + character ch. See group_nodes_into_DFAstates. */ + for (j = 0; (dests_ch[j][i] & mask) == 0; ++j) + ; + + /* j-th destination accepts the word character ch. */ + trtable[ch] = dest_states[j]; + trtable[ch + SBC_MAX] = dest_states_word[j]; + } + } + + /* new line */ + if (bitset_contain (acceptable, NEWLINE_CHAR)) + { + /* The current state accepts newline character. */ + for (j = 0; j < ndests; ++j) + if (bitset_contain (dests_ch[j], NEWLINE_CHAR)) + { + /* k-th destination accepts newline character. */ + trtable[NEWLINE_CHAR] = dest_states_nl[j]; + if (need_word_trtable) + trtable[NEWLINE_CHAR + SBC_MAX] = dest_states_nl[j]; + /* There must be only one destination which accepts + newline. See group_nodes_into_DFAstates. */ + break; + } + } + + if (dest_states_malloced) + free (dest_states); + + re_node_set_free (&follows); + for (i = 0; i < ndests; ++i) + re_node_set_free (dests_node + i); + + if (dests_node_malloced) + free (dests_alloc); + + return 1; +} + +/* Group all nodes belonging to STATE into several destinations. + Then for all destinations, set the nodes belonging to the destination + to DESTS_NODE[i] and set the characters accepted by the destination + to DEST_CH[i]. This function return the number of destinations. */ + +static int +internal_function +group_nodes_into_DFAstates (const re_dfa_t *dfa, const re_dfastate_t *state, + re_node_set *dests_node, bitset_t *dests_ch) +{ + reg_errcode_t err; + int result; + int i, j, k; + int ndests; /* Number of the destinations from `state'. */ + bitset_t accepts; /* Characters a node can accept. */ + const re_node_set *cur_nodes = &state->nodes; + bitset_empty (accepts); + ndests = 0; + + /* For all the nodes belonging to `state', */ + for (i = 0; i < cur_nodes->nelem; ++i) + { + re_token_t *node = &dfa->nodes[cur_nodes->elems[i]]; + re_token_type_t type = node->type; + unsigned int constraint = node->constraint; + + /* Enumerate all single byte character this node can accept. */ + if (type == CHARACTER) + bitset_set (accepts, node->opr.c); + else if (type == SIMPLE_BRACKET) + { + bitset_merge (accepts, node->opr.sbcset); + } + else if (type == OP_PERIOD) + { +#ifdef RE_ENABLE_I18N + if (dfa->mb_cur_max > 1) + bitset_merge (accepts, dfa->sb_char); + else +#endif + bitset_set_all (accepts); + if (!(dfa->syntax & RE_DOT_NEWLINE)) + bitset_clear (accepts, '\n'); + if (dfa->syntax & RE_DOT_NOT_NULL) + bitset_clear (accepts, '\0'); + } +#ifdef RE_ENABLE_I18N + else if (type == OP_UTF8_PERIOD) + { + memset (accepts, '\xff', sizeof (bitset_t) / 2); + if (!(dfa->syntax & RE_DOT_NEWLINE)) + bitset_clear (accepts, '\n'); + if (dfa->syntax & RE_DOT_NOT_NULL) + bitset_clear (accepts, '\0'); + } +#endif + else + continue; + + /* Check the `accepts' and sift the characters which are not + match it the context. */ + if (constraint) + { + if (constraint & NEXT_NEWLINE_CONSTRAINT) + { + bool accepts_newline = bitset_contain (accepts, NEWLINE_CHAR); + bitset_empty (accepts); + if (accepts_newline) + bitset_set (accepts, NEWLINE_CHAR); + else + continue; + } + if (constraint & NEXT_ENDBUF_CONSTRAINT) + { + bitset_empty (accepts); + continue; + } + + if (constraint & NEXT_WORD_CONSTRAINT) + { + bitset_word_t any_set = 0; + if (type == CHARACTER && !node->word_char) + { + bitset_empty (accepts); + continue; + } +#ifdef RE_ENABLE_I18N + if (dfa->mb_cur_max > 1) + for (j = 0; j < BITSET_WORDS; ++j) + any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j])); + else +#endif + for (j = 0; j < BITSET_WORDS; ++j) + any_set |= (accepts[j] &= dfa->word_char[j]); + if (!any_set) + continue; + } + if (constraint & NEXT_NOTWORD_CONSTRAINT) + { + bitset_word_t any_set = 0; + if (type == CHARACTER && node->word_char) + { + bitset_empty (accepts); + continue; + } +#ifdef RE_ENABLE_I18N + if (dfa->mb_cur_max > 1) + for (j = 0; j < BITSET_WORDS; ++j) + any_set |= (accepts[j] &= ~(dfa->word_char[j] & dfa->sb_char[j])); + else +#endif + for (j = 0; j < BITSET_WORDS; ++j) + any_set |= (accepts[j] &= ~dfa->word_char[j]); + if (!any_set) + continue; + } + } + + /* Then divide `accepts' into DFA states, or create a new + state. Above, we make sure that accepts is not empty. */ + for (j = 0; j < ndests; ++j) + { + bitset_t intersec; /* Intersection sets, see below. */ + bitset_t remains; + /* Flags, see below. */ + bitset_word_t has_intersec, not_subset, not_consumed; + + /* Optimization, skip if this state doesn't accept the character. */ + if (type == CHARACTER && !bitset_contain (dests_ch[j], node->opr.c)) + continue; + + /* Enumerate the intersection set of this state and `accepts'. */ + has_intersec = 0; + for (k = 0; k < BITSET_WORDS; ++k) + has_intersec |= intersec[k] = accepts[k] & dests_ch[j][k]; + /* And skip if the intersection set is empty. */ + if (!has_intersec) + continue; + + /* Then check if this state is a subset of `accepts'. */ + not_subset = not_consumed = 0; + for (k = 0; k < BITSET_WORDS; ++k) + { + not_subset |= remains[k] = ~accepts[k] & dests_ch[j][k]; + not_consumed |= accepts[k] = accepts[k] & ~dests_ch[j][k]; + } + + /* If this state isn't a subset of `accepts', create a + new group state, which has the `remains'. */ + if (not_subset) + { + bitset_copy (dests_ch[ndests], remains); + bitset_copy (dests_ch[j], intersec); + err = re_node_set_init_copy (dests_node + ndests, &dests_node[j]); + if (BE (err != REG_NOERROR, 0)) + goto error_return; + ++ndests; + } + + /* Put the position in the current group. */ + result = re_node_set_insert (&dests_node[j], cur_nodes->elems[i]); + if (BE (result < 0, 0)) + goto error_return; + + /* If all characters are consumed, go to next node. */ + if (!not_consumed) + break; + } + /* Some characters remain, create a new group. */ + if (j == ndests) + { + bitset_copy (dests_ch[ndests], accepts); + err = re_node_set_init_1 (dests_node + ndests, cur_nodes->elems[i]); + if (BE (err != REG_NOERROR, 0)) + goto error_return; + ++ndests; + bitset_empty (accepts); + } + } + return ndests; + error_return: + for (j = 0; j < ndests; ++j) + re_node_set_free (dests_node + j); + return -1; +} + +#ifdef RE_ENABLE_I18N +/* Check how many bytes the node `dfa->nodes[node_idx]' accepts. + Return the number of the bytes the node accepts. + STR_IDX is the current index of the input string. + + This function handles the nodes which can accept one character, or + one collating element like '.', '[a-z]', opposite to the other nodes + can only accept one byte. */ + +static int +internal_function +check_node_accept_bytes (const re_dfa_t *dfa, int node_idx, + const re_string_t *input, int str_idx) +{ + const re_token_t *node = dfa->nodes + node_idx; + int char_len, elem_len; + int i; + wint_t wc; + + if (BE (node->type == OP_UTF8_PERIOD, 0)) + { + unsigned char c = re_string_byte_at (input, str_idx), d; + if (BE (c < 0xc2, 1)) + return 0; + + if (str_idx + 2 > input->len) + return 0; + + d = re_string_byte_at (input, str_idx + 1); + if (c < 0xe0) + return (d < 0x80 || d > 0xbf) ? 0 : 2; + else if (c < 0xf0) + { + char_len = 3; + if (c == 0xe0 && d < 0xa0) + return 0; + } + else if (c < 0xf8) + { + char_len = 4; + if (c == 0xf0 && d < 0x90) + return 0; + } + else if (c < 0xfc) + { + char_len = 5; + if (c == 0xf8 && d < 0x88) + return 0; + } + else if (c < 0xfe) + { + char_len = 6; + if (c == 0xfc && d < 0x84) + return 0; + } + else + return 0; + + if (str_idx + char_len > input->len) + return 0; + + for (i = 1; i < char_len; ++i) + { + d = re_string_byte_at (input, str_idx + i); + if (d < 0x80 || d > 0xbf) + return 0; + } + return char_len; + } + + char_len = re_string_char_size_at (input, str_idx); + if (node->type == OP_PERIOD) + { + if (char_len <= 1) + return 0; + /* FIXME: I don't think this if is needed, as both '\n' + and '\0' are char_len == 1. */ + /* '.' accepts any one character except the following two cases. */ + if ((!(dfa->syntax & RE_DOT_NEWLINE) && + re_string_byte_at (input, str_idx) == '\n') || + ((dfa->syntax & RE_DOT_NOT_NULL) && + re_string_byte_at (input, str_idx) == '\0')) + return 0; + return char_len; + } + + elem_len = re_string_elem_size_at (input, str_idx); + wc = __btowc(*(input->mbs+str_idx)); + if (((elem_len <= 1 && char_len <= 1) || char_len == 0) && (wc != WEOF && wc < SBC_MAX)) + return 0; + + if (node->type == COMPLEX_BRACKET) + { + const re_charset_t *cset = node->opr.mbcset; +# ifdef _LIBC + const unsigned char *pin + = ((const unsigned char *) re_string_get_buffer (input) + str_idx); + int j; + uint32_t nrules; +# endif /* _LIBC */ + int match_len = 0; + wchar_t wc = ((cset->nranges || cset->nchar_classes || cset->nmbchars) + ? re_string_wchar_at (input, str_idx) : 0); + + /* match with multibyte character? */ + for (i = 0; i < cset->nmbchars; ++i) + if (wc == cset->mbchars[i]) + { + match_len = char_len; + goto check_node_accept_bytes_match; + } + /* match with character_class? */ + for (i = 0; i < cset->nchar_classes; ++i) + { + wctype_t wt = cset->char_classes[i]; + if (__iswctype (wc, wt)) + { + match_len = char_len; + goto check_node_accept_bytes_match; + } + } + +# ifdef _LIBC + nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); + if (nrules != 0) + { + unsigned int in_collseq = 0; + const int32_t *table, *indirect; + const unsigned char *weights, *extra; + const char *collseqwc; + /* This #include defines a local function! */ +# include + + /* match with collating_symbol? */ + if (cset->ncoll_syms) + extra = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB); + for (i = 0; i < cset->ncoll_syms; ++i) + { + const unsigned char *coll_sym = extra + cset->coll_syms[i]; + /* Compare the length of input collating element and + the length of current collating element. */ + if (*coll_sym != elem_len) + continue; + /* Compare each bytes. */ + for (j = 0; j < *coll_sym; j++) + if (pin[j] != coll_sym[1 + j]) + break; + if (j == *coll_sym) + { + /* Match if every bytes is equal. */ + match_len = j; + goto check_node_accept_bytes_match; + } + } + + if (cset->nranges) + { + if (elem_len <= char_len) + { + collseqwc = _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQWC); + in_collseq = __collseq_table_lookup (collseqwc, wc); + } + else + in_collseq = find_collation_sequence_value (pin, elem_len); + } + /* match with range expression? */ + for (i = 0; i < cset->nranges; ++i) + if (cset->range_starts[i] <= in_collseq + && in_collseq <= cset->range_ends[i]) + { + match_len = elem_len; + goto check_node_accept_bytes_match; + } + + /* match with equivalence_class? */ + if (cset->nequiv_classes) + { + const unsigned char *cp = pin; + int32_t idx; + table = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_TABLEMB); + weights = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_WEIGHTMB); + extra = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_EXTRAMB); + indirect = (const int32_t *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_INDIRECTMB); + idx = findidx (&cp, elem_len); + if (idx > 0) + for (i = 0; i < cset->nequiv_classes; ++i) + { + int32_t equiv_class_idx = cset->equiv_classes[i]; + size_t weight_len = weights[idx & 0xffffff]; + if (weight_len == weights[equiv_class_idx & 0xffffff] + && (idx >> 24) == (equiv_class_idx >> 24)) + { + int cnt = 0; + + idx &= 0xffffff; + equiv_class_idx &= 0xffffff; + + while (cnt <= weight_len + && (weights[equiv_class_idx + 1 + cnt] + == weights[idx + 1 + cnt])) + ++cnt; + if (cnt > weight_len) + { + match_len = elem_len; + goto check_node_accept_bytes_match; + } + } + } + } + } + else +# endif /* _LIBC */ + { + /* match with range expression? */ + for (i = 0; i < cset->nranges; ++i) + { + if (cset->range_starts[i] <= wc + && wc <= cset->range_ends[i]) + { + match_len = char_len; + goto check_node_accept_bytes_match; + } + } + } + check_node_accept_bytes_match: + if (!cset->non_match) + return match_len; + else + { + if (match_len > 0) + return 0; + else + return (elem_len > char_len) ? elem_len : char_len; + } + } + return 0; +} + +# ifdef _LIBC +static unsigned int +internal_function +find_collation_sequence_value (const unsigned char *mbs, size_t mbs_len) +{ + uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES); + if (nrules == 0) + { + if (mbs_len == 1) + { + /* No valid character. Match it as a single byte character. */ + const unsigned char *collseq = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_COLLSEQMB); + return collseq[mbs[0]]; + } + return UINT_MAX; + } + else + { + int32_t idx; + const unsigned char *extra = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB); + int32_t extrasize = (const unsigned char *) + _NL_CURRENT (LC_COLLATE, _NL_COLLATE_SYMB_EXTRAMB + 1) - extra; + + for (idx = 0; idx < extrasize;) + { + int mbs_cnt, found = 0; + int32_t elem_mbs_len; + /* Skip the name of collating element name. */ + idx = idx + extra[idx] + 1; + elem_mbs_len = extra[idx++]; + if (mbs_len == elem_mbs_len) + { + for (mbs_cnt = 0; mbs_cnt < elem_mbs_len; ++mbs_cnt) + if (extra[idx + mbs_cnt] != mbs[mbs_cnt]) + break; + if (mbs_cnt == elem_mbs_len) + /* Found the entry. */ + found = 1; + } + /* Skip the byte sequence of the collating element. */ + idx += elem_mbs_len; + /* Adjust for the alignment. */ + idx = (idx + 3) & ~3; + /* Skip the collation sequence value. */ + idx += sizeof (uint32_t); + /* Skip the wide char sequence of the collating element. */ + idx = idx + sizeof (uint32_t) * (*(int32_t *) (extra + idx) + 1); + /* If we found the entry, return the sequence value. */ + if (found) + return *(uint32_t *) (extra + idx); + /* Skip the collation sequence value. */ + idx += sizeof (uint32_t); + } + return UINT_MAX; + } +} +# endif /* _LIBC */ +#endif /* RE_ENABLE_I18N */ + +/* Check whether the node accepts the byte which is IDX-th + byte of the INPUT. */ + +static int +internal_function +check_node_accept (const re_match_context_t *mctx, const re_token_t *node, + int idx) +{ + unsigned char ch; + ch = re_string_byte_at (&mctx->input, idx); + switch (node->type) + { + case CHARACTER: + if (node->opr.c != ch) + return 0; + break; + + case SIMPLE_BRACKET: + if (!bitset_contain (node->opr.sbcset, ch)) + return 0; + break; + +#ifdef RE_ENABLE_I18N + case OP_UTF8_PERIOD: + if (ch >= 0x80) + return 0; + /* FALLTHROUGH */ +#endif + case OP_PERIOD: + if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE)) + || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL))) + return 0; + break; + + default: + return 0; + } + + if (node->constraint) + { + /* The node has constraints. Check whether the current context + satisfies the constraints. */ + unsigned int context = re_string_context_at (&mctx->input, idx, + mctx->eflags); + if (NOT_SATISFY_NEXT_CONSTRAINT (node->constraint, context)) + return 0; + } + + return 1; +} + +/* Extend the buffers, if the buffers have run out. */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +extend_buffers (re_match_context_t *mctx) +{ + reg_errcode_t ret; + re_string_t *pstr = &mctx->input; + + /* Avoid overflow. */ + if (BE (INT_MAX / 2 / sizeof (re_dfastate_t *) <= pstr->bufs_len, 0)) + return REG_ESPACE; + + /* Double the lengthes of the buffers. */ + ret = re_string_realloc_buffers (pstr, MIN (pstr->len, pstr->bufs_len * 2)); + if (BE (ret != REG_NOERROR, 0)) + return ret; + + if (mctx->state_log != NULL) + { + /* And double the length of state_log. */ + /* XXX We have no indication of the size of this buffer. If this + allocation fail we have no indication that the state_log array + does not have the right size. */ + re_dfastate_t **new_array = re_realloc (mctx->state_log, re_dfastate_t *, + pstr->bufs_len + 1); + if (BE (new_array == NULL, 0)) + return REG_ESPACE; + mctx->state_log = new_array; + } + + /* Then reconstruct the buffers. */ + if (pstr->icase) + { +#ifdef RE_ENABLE_I18N + if (pstr->mb_cur_max > 1) + { + ret = build_wcs_upper_buffer (pstr); + if (BE (ret != REG_NOERROR, 0)) + return ret; + } + else +#endif /* RE_ENABLE_I18N */ + build_upper_buffer (pstr); + } + else + { +#ifdef RE_ENABLE_I18N + if (pstr->mb_cur_max > 1) + build_wcs_buffer (pstr); + else +#endif /* RE_ENABLE_I18N */ + { + if (pstr->trans != NULL) + re_string_translate_buffer (pstr); + } + } + return REG_NOERROR; +} + + +/* Functions for matching context. */ + +/* Initialize MCTX. */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +match_ctx_init (re_match_context_t *mctx, int eflags, int n) +{ + mctx->eflags = eflags; + mctx->match_last = -1; + if (n > 0) + { + mctx->bkref_ents = re_malloc (struct re_backref_cache_entry, n); + mctx->sub_tops = re_malloc (re_sub_match_top_t *, n); + if (BE (mctx->bkref_ents == NULL || mctx->sub_tops == NULL, 0)) + return REG_ESPACE; + } + /* Already zero-ed by the caller. + else + mctx->bkref_ents = NULL; + mctx->nbkref_ents = 0; + mctx->nsub_tops = 0; */ + mctx->abkref_ents = n; + mctx->max_mb_elem_len = 1; + mctx->asub_tops = n; + return REG_NOERROR; +} + +/* Clean the entries which depend on the current input in MCTX. + This function must be invoked when the matcher changes the start index + of the input, or changes the input string. */ + +static void +internal_function +match_ctx_clean (re_match_context_t *mctx) +{ + int st_idx; + for (st_idx = 0; st_idx < mctx->nsub_tops; ++st_idx) + { + int sl_idx; + re_sub_match_top_t *top = mctx->sub_tops[st_idx]; + for (sl_idx = 0; sl_idx < top->nlasts; ++sl_idx) + { + re_sub_match_last_t *last = top->lasts[sl_idx]; + re_free (last->path.array); + re_free (last); + } + re_free (top->lasts); + if (top->path) + { + re_free (top->path->array); + re_free (top->path); + } + free (top); + } + + mctx->nsub_tops = 0; + mctx->nbkref_ents = 0; +} + +/* Free all the memory associated with MCTX. */ + +static void +internal_function +match_ctx_free (re_match_context_t *mctx) +{ + /* First, free all the memory associated with MCTX->SUB_TOPS. */ + match_ctx_clean (mctx); + re_free (mctx->sub_tops); + re_free (mctx->bkref_ents); +} + +/* Add a new backreference entry to MCTX. + Note that we assume that caller never call this function with duplicate + entry, and call with STR_IDX which isn't smaller than any existing entry. +*/ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +match_ctx_add_entry (re_match_context_t *mctx, int node, int str_idx, int from, + int to) +{ + if (mctx->nbkref_ents >= mctx->abkref_ents) + { + struct re_backref_cache_entry* new_entry; + new_entry = re_realloc (mctx->bkref_ents, struct re_backref_cache_entry, + mctx->abkref_ents * 2); + if (BE (new_entry == NULL, 0)) + { + re_free (mctx->bkref_ents); + return REG_ESPACE; + } + mctx->bkref_ents = new_entry; + memset (mctx->bkref_ents + mctx->nbkref_ents, '\0', + sizeof (struct re_backref_cache_entry) * mctx->abkref_ents); + mctx->abkref_ents *= 2; + } + if (mctx->nbkref_ents > 0 + && mctx->bkref_ents[mctx->nbkref_ents - 1].str_idx == str_idx) + mctx->bkref_ents[mctx->nbkref_ents - 1].more = 1; + + mctx->bkref_ents[mctx->nbkref_ents].node = node; + mctx->bkref_ents[mctx->nbkref_ents].str_idx = str_idx; + mctx->bkref_ents[mctx->nbkref_ents].subexp_from = from; + mctx->bkref_ents[mctx->nbkref_ents].subexp_to = to; + + /* This is a cache that saves negative results of check_dst_limits_calc_pos. + If bit N is clear, means that this entry won't epsilon-transition to + an OP_OPEN_SUBEXP or OP_CLOSE_SUBEXP for the N+1-th subexpression. If + it is set, check_dst_limits_calc_pos_1 will recurse and try to find one + such node. + + A backreference does not epsilon-transition unless it is empty, so set + to all zeros if FROM != TO. */ + mctx->bkref_ents[mctx->nbkref_ents].eps_reachable_subexps_map + = (from == to ? ~0 : 0); + + mctx->bkref_ents[mctx->nbkref_ents++].more = 0; + if (mctx->max_mb_elem_len < to - from) + mctx->max_mb_elem_len = to - from; + return REG_NOERROR; +} + +/* Search for the first entry which has the same str_idx, or -1 if none is + found. Note that MCTX->BKREF_ENTS is already sorted by MCTX->STR_IDX. */ + +static int +internal_function +search_cur_bkref_entry (const re_match_context_t *mctx, int str_idx) +{ + int left, right, mid, last; + last = right = mctx->nbkref_ents; + for (left = 0; left < right;) + { + mid = (left + right) / 2; + if (mctx->bkref_ents[mid].str_idx < str_idx) + left = mid + 1; + else + right = mid; + } + if (left < last && mctx->bkref_ents[left].str_idx == str_idx) + return left; + else + return -1; +} + +/* Register the node NODE, whose type is OP_OPEN_SUBEXP, and which matches + at STR_IDX. */ + +static reg_errcode_t +internal_function __attribute_warn_unused_result__ +match_ctx_add_subtop (re_match_context_t *mctx, int node, int str_idx) +{ +#ifdef DEBUG + assert (mctx->sub_tops != NULL); + assert (mctx->asub_tops > 0); +#endif + if (BE (mctx->nsub_tops == mctx->asub_tops, 0)) + { + int new_asub_tops = mctx->asub_tops * 2; + re_sub_match_top_t **new_array = re_realloc (mctx->sub_tops, + re_sub_match_top_t *, + new_asub_tops); + if (BE (new_array == NULL, 0)) + return REG_ESPACE; + mctx->sub_tops = new_array; + mctx->asub_tops = new_asub_tops; + } + mctx->sub_tops[mctx->nsub_tops] = calloc (1, sizeof (re_sub_match_top_t)); + if (BE (mctx->sub_tops[mctx->nsub_tops] == NULL, 0)) + return REG_ESPACE; + mctx->sub_tops[mctx->nsub_tops]->node = node; + mctx->sub_tops[mctx->nsub_tops++]->str_idx = str_idx; + return REG_NOERROR; +} + +/* Register the node NODE, whose type is OP_CLOSE_SUBEXP, and which matches + at STR_IDX, whose corresponding OP_OPEN_SUBEXP is SUB_TOP. */ + +static re_sub_match_last_t * +internal_function +match_ctx_add_sublast (re_sub_match_top_t *subtop, int node, int str_idx) +{ + re_sub_match_last_t *new_entry; + if (BE (subtop->nlasts == subtop->alasts, 0)) + { + int new_alasts = 2 * subtop->alasts + 1; + re_sub_match_last_t **new_array = re_realloc (subtop->lasts, + re_sub_match_last_t *, + new_alasts); + if (BE (new_array == NULL, 0)) + return NULL; + subtop->lasts = new_array; + subtop->alasts = new_alasts; + } + new_entry = calloc (1, sizeof (re_sub_match_last_t)); + if (BE (new_entry != NULL, 1)) + { + subtop->lasts[subtop->nlasts] = new_entry; + new_entry->node = node; + new_entry->str_idx = str_idx; + ++subtop->nlasts; + } + return new_entry; +} + +static void +internal_function +sift_ctx_init (re_sift_context_t *sctx, re_dfastate_t **sifted_sts, + re_dfastate_t **limited_sts, int last_node, int last_str_idx) +{ + sctx->sifted_states = sifted_sts; + sctx->limited_states = limited_sts; + sctx->last_node = last_node; + sctx->last_str_idx = last_str_idx; + re_node_set_init_empty (&sctx->limits); +} diff --git a/replace.c b/replace.c new file mode 100644 index 0000000..d1c05ad --- /dev/null +++ b/replace.c @@ -0,0 +1,117 @@ +/* + * replace.c -- Get replacement versions of functions. + */ + +/* + * Copyright (C) 1989, 1991-2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* + * Do all necessary includes here, so that we don't have to worry about + * overlapping includes in the files in missing.d. + */ +#include "config.h" +#include "awk.h" + + +#ifndef HAVE_SYSTEM +#include "missing_d/system.c" +#endif /* HAVE_SYSTEM */ + +#ifndef HAVE_MEMCMP +#include "missing_d/memcmp.c" +#endif /* HAVE_MEMCMP */ + +#ifndef HAVE_MEMCPY +#include "missing_d/memcpy.c" +#endif /* HAVE_MEMCPY */ + +#ifndef HAVE_MEMSET +#include "missing_d/memset.c" +#endif /* HAVE_MEMSET */ + +#ifndef HAVE_MEMMOVE +#include "missing_d/memmove.c" +#endif /* HAVE_MEMMOVE */ + +#ifndef HAVE_STRNCASECMP +#include "missing_d/strncasecmp.c" +#endif /* HAVE_STRCASE */ + +#ifndef HAVE_STRERROR +#include "missing_d/strerror.c" +#endif /* HAVE_STRERROR */ + +#ifndef HAVE_STRFTIME +# ifdef __MINGW32__ +/* Need to use underlying_strftime in replacement strftime. */ +# define HAVE_STRFTIME 1 +# endif +#include "missing_d/strftime.c" +# ifdef __MINGW32__ +# undef HAVE_STRFTIME +# endif +#endif /* HAVE_STRFTIME */ + +#ifndef HAVE_STRCHR +#include "missing_d/strchr.c" +#endif /* HAVE_STRCHR */ + +#if !defined(HAVE_STRTOD) +#include "missing_d/strtod.c" +#endif /* HAVE_STRTOD */ + +#ifndef HAVE_STRTOUL +#include "missing_d/strtoul.c" +#endif /* HAVE_STRTOUL */ + +#ifndef HAVE_TZSET +#include "missing_d/tzset.c" +#endif /* HAVE_TZSET */ + +#ifndef HAVE_MKTIME +/* mktime.c defines main() if DEBUG is set */ +#undef DEBUG +#include "missing_d/mktime.c" +#endif /* HAVE_MKTIME */ + +#ifndef HAVE_SNPRINTF +#include "missing_d/snprintf.c" +#endif + +#if defined(HAVE_SOCKETS) && ! defined(HAVE_GETADDRINFO) +#include "missing_d/getaddrinfo.c" +#endif + +#ifndef HAVE_USLEEP +#include "missing_d/usleep.c" +#endif + +#ifndef HAVE_SETENV +#include "missing_d/setenv.c" +#endif + +#ifndef HAVE_STRCOLL +#include "missing_d/strcoll.c" +#endif + +#if ! MBS_SUPPORT +#include "missing_d/wcmisc.c" +#endif diff --git a/test/ChangeLog b/test/ChangeLog new file mode 100644 index 0000000..535cb9e --- /dev/null +++ b/test/ChangeLog @@ -0,0 +1,92 @@ +2012-03-28 Arnold D. Robbins + + * 4.0.1: Release tar ball made. + +2012-03-20 Arnold D. Robbins + + * Makefile.am (printfbad3): New test. + * printfbad3.awk, printfbad3.ok: New files. + +2012-02-22 Arnold D. Robbins + + * Makefile.am (beginfile2, next): Set LC_ALL=C so that error + messages will be in English for comparison with .ok files. + Thanks to Jeroen Schot . + +2011-12-26 Arnold D. Robbins + + * Makefile.am (rri1): New test. + * rri1.awk, rri1.in, rri1.ok: New files. + +2011-12-06 Arnold D. Robbins + + * Makefile.am: Rationalize the $(CMP) lines wherever possible. + +2011-10-24 Arnold D. Robbins + + * beginfile2.sh: Use `...` instead of $(...) for broken systems + where /bin/sh doesn't support $(...). Thanks to Nelson Beebe for + the report. + +2011-10-21 John Haque + + * beginfile2.in, beginfile2.sh, beginfile2.ok: Adjust input file names. + +2011-10-21 Corinna Vinschen + + * Makefile.am (beginfile2): Adjust for running out of srcdir. + * beginfile2.sh: Same. + +2011-10-02 Arnold D. Robbins + + * Makefile.am (rtlen, rtlen01, rtlenmb): New tests. + * rtlen.ok, rtlen.sh, rtlen01.ok, rtlen01.sh: New files. + Thanks to Rogier as forwarded by + Jeroen Schot . + +2011-08-10 Arnold D. Robbins + + * Makefile.am (beginfile2, fpat3, fwtest3): New tests. + * beginfile2.awk, beginfile2.in, beginfile2.ok: New files. + * fpat3.awk, fpat3.in, fpat3.ok: New files. + * fwtest3.awk, fwtest3.in, fwtest3.ok: New files. + +2011-08-09 Arnold D. Robbins + + * pty1.awk, pty1.ok: New files. + * Makefile.am (pty1): New test. + (profile1, profile2, profile3): Use unique names for the profile + files to avoid problems with parallel 'make check' + +2011-07-29 Arnold D. Robbins + + * Makefile.am (next): Redirect output to output file! + +2011-07-28 Arnold D. Robbins + + * sortu.awk, sortu.ok: Modified to make numeric comparison do + a stable sort. Thanks to Peter Fales . + * backgsub.ok: Update for change in code. + * Makefile.am (posix2008sub): Add --posix to invocation. + +2011-07-26 Arnold D. Robbins + + * Makefile.am (getline4, gsubtst8): New tests. + * getline4.awk, getline4.in, getline4.ok: New files. + * gsubtst8.awk, gsubtst8.in, gsubtst8.ok: New files. + +2011-07-15 Arnold D. Robbins + + * Makefile.am (gsubtst7): New test. + * gsubtst7.awk, gsubtst7.in, gsubtst7.ok: New files. + +2011-06-24 Arnold D. Robbins + + * Makefile.am (EXTRA_DIST): Add ChangeLog.0. + * 4.0.0: Remake the tar ball. + +2011-06-23 Arnold D. Robbins + + * ChangeLog.0: Rotated ChangeLog into this file. + * ChangeLog: Created anew for gawk 4.0.0 and on. + * 4.0.0: Release tar ball made. diff --git a/test/ChangeLog.0 b/test/ChangeLog.0 new file mode 100644 index 0000000..3d5b4de --- /dev/null +++ b/test/ChangeLog.0 @@ -0,0 +1,1785 @@ +Mon Jun 20 20:35:04 2011 Arnold D. Robbins + + * dfastress.awk, dfastress.ok: New files. + * Makefile.am (dfastress): New test. + +Sun Jun 5 21:45:27 2011 Arnold D. Robbins + + * fpat1.ok, fpat1.in: Updated to test things better. + +Tue May 31 22:50:28 2011 Arnold D. Robbins + + * regrange.awk, regrange.ok: New files. + * Makefile.am (regrange): New test. + +Thu May 26 22:08:27 2011 Arnold D. Robbins + + * fpat2.awk, fpat2.ok: New files. Thanks to Pat Rankin for the cases. + * Makefile.am (fpat2): New test. + +Mon May 23 14:03:15 2011 Arnold D. Robbins + + * fpatnull.awk, fpatnull.in, fpatnull.ok: New files. + * Makefile.am (fpatnull): New test. + +Sun May 22 11:58:58 2011 Arnold D. Robbins + + * dumpvars.ok: Updated. + +Thu May 19 16:56:31 2011 Arnold D. Robbins + + * badargs.ok: Updated. + +Sat May 14 22:28:56 2011 Arnold D. Robbins + + * delargv.awk, delargv.ok: New files. + * Makefile.am (delargv): New test. + +Mon May 9 15:06:17 2011 Arnold D. Robbins + + * Makefile.am: Put next and exit tests into gawk specific tests + since they use BEGINFILE and ENDFILE. Thanks to Pat Rankin. + +Sun May 8 20:32:59 2011 Arnold D. Robbins + + * arraysort.ok, sort1.ok: Updated. + +Wed May 4 23:37:27 2011 Arnold D. Robbins + + Revise tests for array sorting. + + * arraysort.awk, arraysort.ok, sort1.awk, sort1.ok, + sortfor.awk: Revised. + +Wed May 4 23:07:39 2011 Arnold D. Robbins + + * nastyparm.awk, nastyparm.ok: New files from John Haque. + * Makefile.am (nastyparm): New test. + +Wed May 4 23:03:06 2011 Arnold D. Robbins + + * delsub.awk, delsub.ok: New files. + * Makefile.am (delsub): New test. + +Fri Apr 22 16:07:01 2011 John Haque + + * sortu.awk, sortu.ok: New files. + +Fri Apr 22 09:19:06 2011 Arnold D. Robbins + + * arraysort.ok: Updated. + +Mon Apr 18 10:22:28 2011 John Haque + + * arraysort.awk, arraysort.ok, sort1.awk, sort1.ok: Updated. + +Fri Apr 15 13:49:36 2011 Arnold D. Robbins + + * ofmta.awk, ofmta.ok: New files from John Haque. + * Makefile.am (ofmta): New test. + +Thu Apr 7 21:44:06 2011 Arnold D. Robbins + + * arraysort.awk, arraysort.ok: Added more test cases. + +Fri Apr 1 11:56:54 2011 Arnold D. Robbins + + * arraysort.awk, arraysort.ok: New files from John Haque, + edited somewhat. + * Makefile.am (arraysort): New test. + +Wed Mar 30 22:00:59 2011 Arnold D. Robbins + + * next.sh, exit.sh: New files from John Haque, edited somewhat. + * Makefile.am (next, exit): New tests. + +Mon Feb 21 20:32:36 2011 Arnold D. Robbins + + * Makefile.am (GAWK_EXT_TESTS): Include profile3. Thanks to + Scott Deifik for pointing out the omission. + +Tue Feb 15 17:11:26 2011 Pat Rankin + + * sortfor.awk: New values for PROCINFO["sorted_in"]. + * sortfor.ok: Sync with updated sortfor.awk. + +Wed Feb 16 21:09:50 2011 Arnold D. Robbins + + * Makefile.am (lintwarn): New test. + * lintwarn.awk, lintwarn.ok: New files from John Haque. + * funsmnam.ok, noeffect.ok, paramdup.ok, paramres.ok: Adjust + after fixes to lint warnings. + +Mon Feb 14 21:31:10 2011 Arnold D. Robbins + + * Makefile.am (profile2): Add -v sortcmd=sort to pgawk invocation. + (profile1): Remove awkprof.out. Thanks to Pat Rankin for noticing. + +Sun Feb 13 20:27:35 2011 Pat Rankin + + * xref.awk: Allow sortcmd to be preset via -v option. + * profile2.ok: Sync with updated xref.awk. + +Sun Feb 13 19:55:15 2011 Arnold D. Robbins + + * Makefile.am (profile3): New test. + * profile3.awk, profile3.ok: New files. + +Fri Feb 11 10:29:48 2011 Arnold D. Robbins + + * Makefile.am (manyfiles): Bump limit up above 1024, which is + what most modern systems have for number of open file descriptors. + +Tue Feb 8 22:49:17 2011 Arnold D. Robbins + + * aryprm4.ok, scalar.ok, sclforin.ok, sclifin.ok: Fixed to match + output message changes. + +Mon Feb 7 21:39:39 2011 Arnold D. Robbins + + * Makefile.am (negrange): New test. + * negrange.awk, negrange.ok: New files. + +Tue Feb 1 23:21:39 2011 Arnold D. Robbins + + * xref.awk: Change sort command to just "sort"; avoids + problems for Windows and is good enough for the test. + * profile2.ok: Update. + +Tue Feb 1 10:20:47 2011 Arnold D. Robbins + + * sortfor.awk: Change magic string to match code. + +Thu Jan 27 22:56:19 2011 Arnold D. Robbins + + * Makefile.am (sortfor): New test. + * sortfor.awk, sortfor.in, sortfor.ok: New files. + +Thu Jan 27 22:03:22 2011 John Haque + + * xref.awk, profile2.ok: Fixed to be character set independent. + +Sun Dec 26 13:54:21 2010 Arnold D. Robbins + + * Makefile.am (EXTRA_DIST): Include profile2.ok in the list. Oops. + +Mon Dec 13 13:54:56 2010 Arnold D. Robbins + + * localenl.sh: Use --posix option. + +Sun Dec 12 13:58:36 2010 Arnold D. Robbins + + * gsubtst5.ok: Adjust contents. + +Tue Dec 7 22:31:51 2010 Arnold D. Robbins + + * Makefile.am (profile1, profile2): New tests. + * dtdgport.awk, xref.original, xref.awk, profile2.ok: New files. + * Gentests: Use POSIX character classes instead of ranges. + +Mon Dec 6 19:47:09 2010 Arnold D. Robbins + + * Makefile.am (whiny): Removed test. + * whiny.awk, whiny.in, whiny.ok: Removed. + +Wed Dec 1 08:11:46 2010 Corinna Vinschen + + * Makefile.am (beginfile1): Refer to Makefile instead of + $(srcdir)/Makefile for building out of the source directory. + +Tue Nov 30 13:51:35 2010 Arnold D. Robbins + + * badargs.ok: Updated. + +Mon Nov 29 21:52:49 2010 Arnold D. Robbins + + * funstack.awk, gsubtst5.ok, igncfs.awk, longwrds.awk, + ofmtbig.awk, subamp.awk: Fix regexes to remove ranges. + +Fri Nov 12 11:58:40 2010 Arnold D. Robbins + + * Makefile.am (dumpvars): New test. + * dumpvars.in, dumpvars.ok: New files. + +Thu Nov 11 16:29:06 2010 Arnold D. Robbins + + * backgsub.ok: Updated to match change in code. + * posix2008sub.awk, posix2008.ok: New files, renamed from ... + * psx96sub.awk, psx96sub.ok: Removed. + * Makefile.am (posix2008sub): Renamed from `psx96sub'. + +Tue Nov 2 12:14:50 2010 Arnold D. Robbins + + * badargs.ok: Updated. + +Mon Nov 1 21:44:48 2010 Arnold D. Robbins + + New tests for arrays of arrays, courtesy of John Haque + . + + * Makefile.am (aadelete1, aadelete2, aarray1, + aasort, aasorti): New tests. + * aadelete1.awk, aadelete1.ok, aadelete2.awk, aadelete2.ok, + aarray1.awk, aarray1.ok, aasort.awk, aasort.ok, + aasorti.awk, aasorti.ok: New files. + + Unrelated: + * badargs.ok: Updated. + +Tue Oct 26 20:49:41 2010 Arnold D. Robbins + + * Makefile.am (switch2): Made into a test. + * switch2.ok: New file. + +Tue Oct 19 08:26:03 2010 Arnold D. Robbins + + * Makefile.am (gsubtst6, mbstr1, mbprintf3, printfbad2): + Re-enable these tests that got lost during the merge. Thanks + to Scott Deifik for noticing. + +Fri Oct 15 14:20:22 2010 Arnold D. Robbins + + * Makefile.am (beginfile1, range1): New tests. + * beginfile1.awk, beginfile1.in, beginfile1.ok: New files. + * range1.awk, range1.in, range1.ok: New files. + +Sun Jun 27 22:01:38 2010 Arnold D. Robbins + + * badargs.ok: Updated with new usage message. + +Tue Jun 22 20:55:47 2010 Arnold D. Robbins + + * Makefile.am (fpat1, patsplit): New tests. + * fpat1.awk, fpat1.in, fpat1.ok, patsplit.awk, patsplit.ok: new files. + +Fri Jan 16 11:36:02 2009 Arnold D. Robbins + + * badargs.ok, funstack.awk, gsubtst4.ok: Adjust to change in + --gen-po option, removal of -r, and enabling interval expressions. + +Fri Jan 16 11:36:02 2009 Arnold D. Robbins + + * Makefile.am (indirectcall): New test. + * indirectcall.awk, indirectcall.in, indirectcall.ok: New files. + +Tue Dec 30 22:27:08 2008 Arnold D. Robbins + + * badargs.ok: Updated. + +Tue Dec 9 06:58:00 2008 Steffen Schuler + + * Makefile.am (splitarg4): New test. + * splitarg4.awk, splitarg4.in, splitarg4.ok: New files. + +Wed Dec 26 22:01:52 2001 Arnold D. Robbins + + * pid.awk: Fix to use PROCINFO now that /dev/pid, /dev/ppid gone. + +Thu May 6 20:55:14 2010 Arnold D. Robbins + + * Release 3.1.8: Release tar file made. + +Wed Apr 21 22:23:30 2010 Arnold D. Robbins + + * Makefile.am (EXTRA_DIST): Add Gentests.vms so it'll be + in the dist. + * localenl.sh, localenl.ok: Remove UNKNOWN locale per + request from Nelson Beebe. + * lc_num1.awk, lc_num1.ok: Revised to not fail on systems + where the quote flag isn't supported. Also per Nelson Beebe. + +Thu Feb 18 22:50:54 2010 Arnold D. Robbins + + * Makefile.am (fcall_exit2): New test. + * fcall_exit2.awk, fcall_exit2.in, fcall_exit2.ok: New files. + +Wed Feb 17 23:25:27 2010 Arnold D. Robbins + + * Makefile.am (fcall_exit): New test. + * fcall_exit.awk, fcall_exit.ok: New files. + +Fri Feb 5 13:02:10 2010 Arnold D. Robbins + + * Makefile.am (forref): New test. + * forref.awk, forref.ok: New files. + +Tue Oct 6 19:49:22 2009 Arnold D. Robbins + + * Makefile.am (uninit5): New test. + * uninit5.awk, uninit5.ok: New files. + +Tue Aug 4 06:04:04 2009 Arnold D. Robbins + + * hsprint.ok: Updated. + +Tue Jul 21 22:28:56 2009 Arnold D. Robbins + + * Release 3.1.7: Release tar file made. + +Fri Jul 3 13:04:55 2009 Arnold D. Robbins + + * Makefile.am (charset-tests): Moved tests that can fail based on + character set and locale issues into a separate section. + +Wed Jun 24 22:30:31 2009 Arnold D. Robbins + + * lintold.awk: Changed to avoid floating point problems on VMS. + +Wed Jun 24 05:39:00 2009 Arnold D. Robbins + + * printfbad2.awk, printfbad2.ok: Adjusted for systems where sed + will add a final newline if the input didn't contain one. + +Mon Jun 22 00:44:50 2009 Pat Rankin + + * getlndir.awk (SRCDIR): Allow caller to override "." as directory. + * intformat.awk (HUGEVAL): Allow caller to override the largest + value, and restructure 10^x and 2^y loops to use it without + overflowing on non-IEEE floating pointing hosts. + +Tue Jun 23 05:26:52 2009 Arnold D. Robbins + + * Makefile.am (MACHINE_TESTS): Move fmtspcl to here per Pat Rankin. + +Fri Jun 19 14:26:55 2009 Arnold D. Robbins + + * Makefile.am (GAWK_EXT_TESTS): Fixed sorting of tests. + Removed ovrflow1 test since double1 is a superset; thanks + to Pat Rankin. + * (ovrflow1.awk, ovrflow1.ok): Removed. + +Thu Jun 18 05:46:32 2009 Arnold D. Robbins + + * Makefile.am (localenl): Per Michal Jaegermann, send stderr output + to /dev/null. + * (machine-tests): Moved several tests to new section for tests + whose output can vary by hardware. + +Thu Jun 11 04:50:44 2009 Arnold D. Robbins + + * Makefile.am (lc_num1): Don't need --posix, changed command line + so that AWKPATH influences again. Thanks to Corinna Vinschen + for making me fix this. + +Wed Jun 10 08:28:13 2009 Arnold D. Robbins + + * Makefile.am (lc_num1, printfbad2): Fix so building outside the + source directory works. + +Thu May 21 21:10:53 2009 Arnold D. Robbins + + * badargs.ok: Updated. + +Fri May 15 14:38:16 2009 Arnold D. Robbins + + * Makefile.am (paramres): New test. + * paramres.awk, paramres.ok: New files. + +Fri Mar 27 10:57:49 2009 Arnold D. Robbins + + * Makefile.am (printfbad2): New test. + * printfbad2.awk, printfbad2.in, printfbad2.ok: New files. + +Tue Feb 3 22:08:27 2009 Arnold D. Robbins + + * Makefile.am (uparrfs): New test. + * uparrfs.awk, uparrfs.in, uparrfs.ok: New files. + +Mon Jan 5 22:53:26 2009 Arnold D. Robbins + + * Makefile.am (getlndir): New test. + * getlndir.awk, getlndir.ok: New files. + +Mon Dec 29 22:46:10 2008 Arnold D. Robbins + + * Makefile.am (mbprintf3): New test. + * mbprintf3.awk, mbprintf3.in, mbprintf3.ok: New files. + +Thu Dec 18 20:57:39 2008 Stepan Kasal + + * lc_num1.awk, lc_num1.ok: Test that the quote modifier in + printf is not sticky. + * Makefile.am: Add it. + * Gentests: Allow _ in test names. + +Thu Dec 11 21:36:11 2008 Arnold D. Robbins + + * Makefile.am (mbstr1): New test. + * mbstr1.awk, mbstr1.ok: New files. + +Thu Dec 4 22:44:39 2008 Arnold D. Robbins + + * Makefile.am (closebad): New test. + * closebad.awk, closebad.ok: New files. + +Thu Jul 31 21:44:21 2008 Arnold D. Robbins + + * Makefile.am (match3, gsubtst6): New tests. + * match3.awk, match3.in, match3.ok: New files. + * gsubtst6.awk, gsubtst6.ok: New files. + +Fri May 2 12:43:51 2008 Steffen Schuler + + * Makefile.am (mbfw1): Add code for test to use a UTF locale. + +Wed Apr 23 22:13:47 2008 Arnold D. Robbins + + * Makefile.am (funlen, mbfw1, mbprintf1, mbprintf2): New tests. + * funlen.awk, funlen.in, funlen.ok: New files. + * mbfw1.awk, mbfw1.in, mbfw1.ok: New files. + * mbprintf1.awk, mbprintf1.in, mbprintf1.ok: New files. + * mbprintf2.awk, mbprintf2.ok: New files. + +Mon Oct 22 08:49:05 2007 Arnold D. Robbins + + * Release 3.1.6: Release tar file made. + +Wed Sep 26 14:32:28 2007 Arnold D. Robbins + + * Makefile.am (localenl): New test. + (regtest): Fixed invocation of shell script. + * localenl.sh, localenl.ok: New files. + * reg/func2.good: Revised to match current gawk output. + +Wed Sep 26 14:49:04 2007 Eli Zaretskii + + * exitval2.w32: New file, a Windows version for exitval2.awk. + +Tue May 29 13:22:33 2007 Arnold D. Robbins + + * badargs.ok: Updated. + +Thu May 17 21:10:51 2007 Pat Rankin + + * icasers.awk: Modify pattern to work on VMS too, doesn't + break Unix/Linux. + +Tue May 15 22:05:24 2007 Pat Rankin + + Steps towards generating VMS .mms file to run test suite. + + * Makefile.am (FAIL_CODE1): New macro, list of programs + that exit 1. + * Gentests: Add VMS code. + * Gentests.vms: New file. + +Wed May 2 19:30:54 2007 Stepan Kasal + + Revert precedence of concatenation and | getline. + From mail dated 2005-10-31. + + * parsefld.awk, parsefld.in, parsefld.ok: New files. + * Makefile.am (parsefld): New basic test, check for $/regex/ and + for /re1/+/re2/. + * getline.awk, getline.ok: Add precedence check "echo " "date"|getline + +Sun Apr 29 22:43:28 2007 Arnold D. Robbins + + * hsprint.awk: Add extra "%" to format string. Thanks to Nelson Beebe. + * hsprint.ok: Revised. + +Tue Apr 24 23:15:01 2007 Andrew J. Schorr + + * fmtspcl.tok: Provide correct version. + +Tue Apr 17 22:23:41 2007 Arnold D. Robbins + + * double2.awk, double2.ok: Limit to 2^63 for portability across + different platforms. Sigh. + +Thu Apr 12 20:00:27 2007 Andrew J. Schorr + + * Makefile.am, Makefile.in (fmtspcl): Use fmtspcl.tok to build + a fmtspcl.ok file suitable for the given platform. + (diffout): Handle case where the .ok file is in the build directory. + +Mon Mar 26 08:24:04 2007 Arnold D. Robbins + + * Makefile.am (fmtspcl.ok): Don't remove for cleaning, add + to EXTRA_DIST. + +Fri Mar 9 11:38:34 2007 Arnold D. Robbins + + * Makefile.am (fmtspcl.tok): Removed use of and reference + to this file. + +Tue Feb 6 08:21:02 2007 Arnold D. Robbins + + * Makefile.am (double1, double2, zero2): New tests. + * double1.awk, double1.ok, double2.awk, double2.ok, + zero2.awk, zero2.ok: New files. + +Sun Feb 4 16:32:45 2007 Arnold D. Robbins + + * Makefile.am (parse1): New test. + * parse1.awk, parse1.in, parse1.ok: New files. + +Thu Feb 1 17:41:48 2007 Andrew J. Schorr + + * Makefile.am (fmtspcl): New test. + (CLEANFILES): Add fmtpspcl.ok to list. + * fmtspcl.awk, fmtspcl.tok: New files. + +Mon Jan 29 15:31:35 2007 Andrew J. Schorr + + * Makefile.am (diffout): Make it work if no problems. + (valgrind-scan): New target to show problems. + +Mon Jan 29 12:51:16 2007 Arnold D. Robbins + + * Makefile.am (reint2): New test. + * reint2.awk, reint2.in, reint2.ok: New files. + +Fri Jan 26 20:01:38 2007 Andrew J. Schorr + + * Makefile.am (intformat): New test. + * intformat.awk, intformat.ok: New files. + +Tue Jan 23 08:10:48 2007 Arnold D. Robbins + + * Makefile.am (fwtest2): New test. + * fwtest2.awk, fwtest2.in, fwtest2.ok: New files. + +Sun Jan 21 13:09:33 2007 Arnold D. Robbins + + * Makefile.am (synerr2, wideidx2): New test. + * synerr2.awk, synerr2.ok, wideidx2.awk, wideidx2.ok: New files. + +Fri Jan 19 15:11:12 2007 Arnold D. Robbins + + * Makefile.am (strnum1, widesub4): New test. + * strnum1.awk, strnum1.ok, widesub4.awk, widesub4.ok: New files. + +Thu Jan 18 13:37:00 2007 Andrew J. Schorr + + * Makeilfe.am (devfd, wideidx, widesub, widesub2, widesub3): New + tests. + * devfd.in4, devfd.in5, devfd.ok, wideidx.awk, wideidx.in, wideidx.ok, + widesub.awk, widesub.ok, widesub2.awk, widesub2.ok, widesub3.awk, + widesub3.in, widesub3.ok: New files. + +Tue Jan 16 12:16:39 2007 Andrew J. Schorr + + * Makefile.am: In pid test, no further need to remove _pid.in, + since the test no longer creates that file. + * pid.awk: Do not read correct values from stdin (they are now passed + as command-line variables with -v). Make sure to produce output + if the comparisons are successful. + * pid.ok: No longer empty, should contain 3 lines if all goes well. + * pid.sh: Do not create _pid.in; instead, pass values in with -v. + +Sun Jan 14 18:03:12 2007 Arnold D. Robbins + + * fnarray.ok: Updated. + +2007-01-13 Eli Zaretskii + + * pipeio2.awk: Don't use empty lines, because Windows ECHO does + something different when invoked without arguments. + + * pipeio2.ok: Update. + + * Makefile.am (EXTRA_DIST): Add exitval2.w32. + + * exitval2.w32: New file. + +Sat Jan 13 21:25:11 2007 Ralf Wildenhues + + * lintold.awk, lintold.in, lintold.ok: New `--lint-old' test. + * Gentests, Makefile.am: Adjust. + +Sat Jan 13 21:17:51 2007 Ralf Wildenhues + + * Makefile.am (Maketests): Allow rebuilding from a VPATH build. + +Fri Jan 12 14:04:24 2007 Arnold D. Robbins + + * Makefile.am (mtchi18n): new test. + * mtchi18n.awk, mtchi18n.in, mtchi18n.ok: new files. + +Wed Sep 6 02:09:26 2006 Arnold D. Robbins + + * Makefile.am (mixed1): new test. + * mixed1.ok: new file. + +Tue Jun 20 05:37:53 2006 Arnold D. Robbins + + * Makefile.am (devfd1, devfd2): new tests. + * devfd.in1, devfd.in2, devfd1.awk, devfd1.ok, devfd2.ok: new files. + +Sun Mar 12 23:48:31 2006 Arnold D. Robbins + + * Makefile.am (concat4): new test. + * concat4.awk, concat4.in, concat4.ok: new files. + +Sun Mar 12 23:33:26 2006 Arnold D. Robbins + + * Makefile.am (subi18n): new test (from + KIMURA Koichi ). + * subi18n.awk, subi18n.ok: New files. + +Mon Dec 19 05:41:56 2005 Arnold D. Robbins + + * Makefile.am (ovrflow1): new test. + * ovrflow1.awk, ovrflow1.ok: new files. + +Wed Dec 14 19:01:08 2005 Arnold D. Robbins + + * Makefile.am (binmode1): new test. + * binmode1.ok: new file. + +Fri Oct 7 12:28:41 2005 Arnold D. Robbins + + * Makefile.am (fwtest): new test. + * fwtest.awk, fwtest.in, fwtest.ok: new files. + +Fri Aug 12 14:40:47 2005 Arnold D. Robbins + + * Makefile.am (nofile): New test. + * nofile.ok: New file. + +Tue Jul 26 21:46:16 2005 Arnold D. Robbins + + * Release 3.1.5: Release tar file made. + +Sun Jul 10 18:31:45 2005 Scott Deifik + + * regtest.sh: Changed to use diff instead of cmp for djgpp. + This addresses DOS vs. UNIX end-of-line issues. + +Thu Jun 9 23:40:14 2005 Arnold D. Robbins + + * Makefile.am (Maketests): Don't use $< in rule, it breaks + on some non-GNU versions of make. Sigh. + +Wed Apr 27 22:22:05 2005 Arnold D. Robbins + + * Makefile.am (longdbl): new test. + * longdbl.awk, longdbl.in, longdbl.ok: new files. + +Wed Feb 2 16:44:41 2005 Arnold D. Robbins + + * Makefile.am (exitval2): new test. + * exitval2.awk, exitval2.ok: new files. + +Mon Jan 31 10:00:52 2005 Arnold D. Robbins + + * Makefile.am (gnuops3): new test. + * gnuops3.awk, gnuops3.ok: new files. + +Wed Jan 19 18:04:40 2005 Arnold D. Robbins + + * Makefile.am (hex): new test. + * hex.awk, hex.ok: new files. + +Sun Jan 9 11:53:09 2005 Arnold D. Robbins + + * Makefile.am (strftime, igncras2, subamp): Use `GAWKLOCALE', + not `GAWK_LOCALE'. Grrr! + +Mon Jan 3 12:20:08 2005 William J. Poser + + * Makefile.am (wjposer1): new test. + * wjposer1.awk, wjposer1.in, wjposer1.ok: new files. + +Mon Jan 3 11:55:48 2005 Arnold D. Robbins + + * Makefile.am (rsstart1, rsstart2, rsstart3): new tests. + * rsstart1.in, rsstart1.awk, rsstart1.ok, rsstart2.awk, + rsstart2.ok, rsstart3.ok: new files. + +Sun Dec 19 17:31:48 2004 Arnold D. Robbins + + * Makefile.am (gensub2): new test. + * gensub2.awk, gensub2.ok: new files. + + Thanks to "John H. DuBois III" . + +Thu Dec 9 15:22:58 2004 Arnold D. Robbins + + * Makefile.am (fsspcoln): new test. + * fsspcoln.awk, fsspcoln.in, fsspcoln.ok: new files. + +Mon Nov 29 18:41:33 2004 Arnold D. Robbins + + * Makefile.am (iobug1): new test. + * iobug1.awk, iobug1.ok: new files. + +Tue Sep 28 18:39:53 2004 Arnold D. Robbins + + * nondec.awk, nondec.ok: Add 00.34 as value to print, it should + not be treated as octal. + +Mon Aug 2 12:18:15 2004 Arnold D. Robbins + + * Release 3.1.4: Release tar file made. + +Wed Jul 14 16:04:46 2004 Arnold D. Robbins + + * Makefile.am (rstest6): new test. + * rstest6.awk, rstest6.in, rstest6.ok: new files. + +Tue Jul 13 10:53:32 2004 Arnold D. Robbins + + * strftlng: Use `$(CMP) ... >/dev/null 2>&1' instead of `-s' + for OS/2 and other systems that use `CMP = diff -a'. + +Mon Jun 14 18:44:39 2004 Pat Rankin + + * longwrds.awk: allow caller the means to override SORT command. + +Tue Jun 8 14:12:52 2004 Arnold D. Robbins + + * Makefile.am (fordel, printfbad1): new tests. + * fordel.awk, fordel.ok: new files. + * printfbad1.awk, printfbad1.ok: new files. + +Mon Apr 19 20:29:52 2004 Arnold D. Robbins + + * Makefile.am (manglprm): new test. + * manglprm.awk, manglprm.in, manglprm.ok: new files. + +Mon Feb 23 18:39:24 2004 Arnold D. Robbins + + * inftest.awk: Add loop limit per Nelson H.F. Beebe. + * Makefile.am (strftime): Use LC_ALL=C for `date' invocation. + +Thu Feb 12 02:08:15 2004 Stepan Kasal + + * Makefile.am (diffout): Use $(srcdir), when we are not building + in the source tree. + +Wed Feb 11 10:23:39 2004 Arnold D. Robbins + + * Makefile.am (strcat1): new test. + * strcat1.awk, strcat1.ok: new files. + +Fri Feb 6 12:09:55 2004 Arnold D. Robbins + + * Makefile.am (CLEANFILES): Added. + +Thu Feb 5 15:34:14 2004 Arnold D. Robbins + + * Makefile.am (exitval1): new test. + * exitval1.awk, exitval1.ok: new files. + +Mon Feb 2 10:29:19 2004 Arnold D. Robbins + + * Makefile.am (subamp): new test. + * subamp.awk, subamp.in, subamp.ok: new files. + + * subamp, ignrcas2, strftime: Set GAWK_LOCALE, not LC_ALL. + +Wed Jan 14 15:28:34 2004 Arnold D. Robbins + + * Makefile.am (backw): new test. + * backw.awk, backw.in, backw.ok: new files. + +Mon Dec 1 10:29:22 2003 Arnold D. Robbins + + * Makefile.am (concat3): new test. + * concat3.awk, concat3.ok: new files. + +Sun Nov 2 16:05:21 2003 Arnold D. Robbins + + * Makefile.am (concat2): new test. + * concat2.awk, concat2.ok: new files. + +Wed Oct 29 13:35:37 2003 Arnold D. Robbins + + * Makefile.am (subsepnm): new test. + * subsepnm.awk, subsepnm.ok: new files. + +Mon Sep 15 16:05:37 2003 Arnold D. Robbins + + * Makefile.am (ignrcas2): new test. + * ignrcas2.awk, ignrcas2.ok: new files. + +Tue Sep 9 16:03:34 2003 Arnold D. Robbins + + * Makefile.am (unterm): new test. + * unterm.awk, unterm.ok: new files. + +Mon Jul 7 11:01:43 2003 Arnold D. Robbins + + * Release 3.1.3: Release tar file made. + +Fri Jul 4 11:12:07 2003 Arnold D. Robbins + + * Makefile.am (poundbang2): Removed. + (poundbang): Added env var settings. + +Thu Jun 26 15:44:33 2003 Arnold D. Robbins + + * Makefile.am (match2, whiny): new tests. + * match2.awk, match2.ok: new files. + * whiny.awk, whiny.ok: new files. + +Thu Jun 26 14:51:40 2003 Arnold D. Robbins + + * Makefile.am: Use double quotes for sed invocation to make + life easier (eventually) for DOS version of Makefile. + * pipeio2.awk, pipio2.ok: Ditto. + +Wed Jun 18 12:32:14 2003 Arnold D. Robbins + + * Makefile.am (AWK): Use LC_ALL=$${GAWKLOCALE:-C} and + same for LANG when running awk. Provides sane locale for + tests with ability to override it if need be. + (all tests): Removed explicit setting of LC_ALL and LANG. + * Gentests: Ditto. + +Wed May 28 08:02:33 CEST 2003 Stepan Kasal + + * Makefile.am (uninit4): new test. + * uninit4.awk, uninit4.ok: new files. + +Wed May 28 06:30:23 2003 Stepan Kasal + + * Makefile.am (aryprm4 aryprm5 aryprm6 aryprm7 aryprm8 scalar uninit3): + new tests. + * aryprm4.awk aryprm4.ok aryprm5.awk aryprm5.ok aryprm6.awk aryprm6.ok: + aryprm7.awk aryprm7.ok aryprm8.awk aryprm8.ok scalar.awk scalar.ok: + uninit3.awk uninit3.ok: new files. + +Tue May 27 14:27:50 2003 Stepan Kasal + + * Makefile.am (aryprm1, aryprm2, aryprm3, sortempty): New tests. + * aryprm1.awk, aryprm1.ok, aryprm2.awk, aryprm2.ok: New files. + * aryprm3.awk, aryprm3.ok, sortempty.awk, sortempty.ok: dtto + * prmarscl.ok: The actual error message has changed. + +Tue May 27 08:23:51 2003 Stepan Kasal + + * arrayref3.ok, arrayref4.ok, fnaryscl.ok: Error messages reformatted. + +Sun Jun 8 17:18:06 2003 Arnold D. Robbins + + * Makefile.am (fmttest, strtonum, nested, gsubtst5, delarpm2): New tests. + * fmttest.awk, fmttest.ok: New files. From Nelson Beebe, + . + * strtonum.awk, strtonum.ok: New files. + * nested.awk, nested.in, nested.ok: New files. + * gsubtst5.awk, gsubtst5.in, gsubtst5.ok: New files. + * delarpm2.awk, delarpm2.ok: New files. (Also from Nelson Beebe.) + + * switch2.awk: Currently unused test for switch code. + +Wed May 14 16:49:53 2003 Arnold D. Robbins + + * Gentests: Add LC_ALL=C LANG=C to generated tests. + * Makefile.am: All other manual tests: ditto. + +Sun May 11 15:27:55 2003 Stepan Kasal + + * Makefile.am (rsnulbig, rsnulbig2): New tests. + * rsnulbig.ok, rsnulbig2.ok: New files. + +Sun May 11 15:00:20 2003 Arnold D. Robbins + + * Makefile.am (arrayprm2, arrayprm3, arryref2, arryref3, arryref4, + arryref5, rstest3, rstest4, rstest5): New tests. + * arrayprm2.awk, arrayprm2.ok, arrayprm3.awk, arrayprm3.ok, arryref2.ok, + arryref3.ok, arryref4.ok, arryref5.ok, rstest3.awk, rstest3.ok, rstest4.awk, + rstest4.ok, rstest5.awk, rstest5.ok: New files. + +Sun May 11 12:20:59 2003 Arnold D. Robbins + + * strftime.awk: Remove seconds from input and strftime output, + to decrease chance of failing on second boundary. + * Makefile.am (strftime): Tweak message appropriately. + +Tue Mar 25 08:35:42 2003 Arnold D. Robbins + + * Makefile.am (fnarray2): New test. + * fnarray2.awk, fnarray2.ok: New files. + +Wed Mar 19 14:10:31 2003 Arnold D. Robbins + + This time for sure. + -- Bullwinkle + + * Release 3.1.2: Release tar file made. + +Wed Mar 19 14:00:00 2003 Arnold D. Robbins + + * Makefile.am (synerr1): New test. + * synerr1.awk, synerr1.ok: New files. + +Tue Mar 4 10:32:23 2003 Arnold D. Robbins + + * Makefile.am (clean): Remove `core*' for modern Linux which + drops core in `core.PID' files. + +2003-02-17 Jim Meyering + + * Makefile.am (check): Don't depend on the pass-fail rule that + reports any failures. Otherwise, for `make -j' that rule's commands + could run before all tests had completed, resulting in spurious + failures or potentially, even unreported failures. Instead, just + `$(MAKE) pass-fail'. + +Sun Feb 9 11:48:32 2003 Arnold D. Robbins + + * Makefile.am: Moved `space' into UNIX_TESTS. Breaks in + MS environments. + +Tue Feb 4 14:28:06 2003 Arnold D. Robbins + + All relevant files: Copyright year updated to 2003. + +Tue Feb 4 12:22:41 2003 Arnold D. Robbins + + * Makefile.am (fnmisc): New test case. + * fnmisc.awk, fnmisc.ok: New files. + +Sun Feb 2 15:33:33 2003 Stepan Kasal + + * getline3.awk, getline3.ok: Renamed from getline2.awk, getline2.ok + * Makefile.am (getline, getline2): getline renamed to getline2, + new test under the name getline. + * getline.awk, getline.ok, getline2.awk, getline2.ok: + rename getline.* getline2.*; new files getline.* . + * getline.awk, getline.ok: add tests for ``cmd | getline '' + * Makefile.am (printf0): New test. + * printf0.awk, printf0.ok: New files. + * fnarray.ok: The error message has changed. + +Thu Jan 30 15:32:56 2003 Stepan Kasal + + * Makefile.am (splitarr, getline2, inputred, prec): New tests. + * splitarr.awk, splitarr.ok: New files. + * getline2.awk, getline2.ok: New files. + * inputred.awk, inputred.ok: New files. + * prec.awk, prec.ok: New files. + * noeffect.awk: add second no-effect command; two error messages + should be generated. Add some empty statements, to check that --lint + doesn't abort on them. + +Tue Jan 28 18:34:22 2003 Arnold D. Robbins + + * arrymem1.awk: Enhanced test. + * arrayme1.ok: Updated for new output + +Mon Jan 27 14:07:16 2003 Stepan Kasal + + * nfldstr.awk: Add tests for automatic number conversion. + +Mon Jan 27 12:25:41 2003 Arnold D. Robbins + + * Makefile.am (asort, asorti, match1): New tests. + * match1.awk, match1.in: New files. + * asort.awk, asort.in: New files. + * asorti.awk, asorti.in: New files. + +Mon Jan 27 12:10:16 2003 Stepan Kasal + + * strtod.awk, strtod.in, strtod.ok: Added test for 0e0 and similar. + +Sun Jan 26 16:49:41 2003 Arnold D. Robbins + + * Makefile.am (zeroe0): New test. + * zeroe0.awk, zeroe0.in: New files. + +Thu Jan 2 11:09:12 2003 Arnold D. Robbins + + * parseme.ok, noparms.ok: Revised for bison 1.875. + +Tue Dec 31 16:54:44 2002 Arnold D. Robbins + + * Makefile.am: (poundbang): Fix code. + (efence): New target to remove _* files run with Electric Fence + but that are otherwise OK. + +Thu Dec 26 16:44:37 2002 Arnold D. Robbins + + * Makefile.am (poundbang): Add code to handle systems with limits on + paths for #! files. + +Mon Dec 9 14:20:44 2002 Stepan Kasal + + * Makefile.am (space): New test: ``gawk -f " " file'' should try + to include file ` '. + +Sun Nov 17 21:47:11 2002 Arnold D. Robbins + + * Makefile.am (manyfiles): Reference $(srcdir)/$@.ok so can build + and test in a different directory. + +Sun Nov 3 14:47:59 2002 Arnold D. Robbins + + Move tests with inline input and/or programs into separate files so can let + Gentests do more work. Per Nelson Beebe, just print the name of each test. + + * Makefile.am (fstabplus, longwrds, fieldwdth, ignrcase, posix, rs, fsbs): + removed targets so will be generated by Gentests. + (negexp, resplit, childin, back89, nfldstr, nondec): ditto. + * Gentests: print name of test, make cmp not echo by prefixing with @. + * fstabplus.in: new file. + * fieldwdth.awk, fieldwdth.in: new files. + * ignrcase.awk, ignrcase.in: new files. + * longwrds.awk: send output to sort instead of letting makefile do it. + * longwrds.in: renamed from manpage. + * posix.in: new file. + * manyfiles.ok: new file. + * rs.awk: new file. + * fsbs.awk: new file. + * negexp.awk: new file. + * resplit.awk, resplit.in: new files. + * childin.awk, childin.in: new files. + * back89.awk: new file. + * nfldstr.awk, nfldstr.in: new files. + +Sun Nov 3 14:37:39 2002 Arnold D. Robbins + + * Makefile.am (uninit2): new test case, requires lint. + * uninit2.awk, uninit2.ok: new files. + +Fri Nov 1 11:34:45 2002 Arnold D. Robbins + + * Makefile.am (nondec): Always run this test. + +Tue Oct 29 10:40:47 2002 Arnold D. Robbins + + * Makefile.am (EXTRA_DIST): Added Gentests to list of files + to distribute. + +Mon Oct 28 15:36:42 2002 Arnold D. Robbins + + * Makefile.am (icasers, icasefs, rstest1, rstest2): new test cases. + (argarray): Remove argarray.in if not in srcdir. + * icasers.awk, icasers.in, icasers.ok: new files. + * icasefs.awk, icasefs.ok: new files. + * rstest1.awk, rstest1.ok: new files. + * rstest2.awk, rstest2.ok: new files. + +Mon Oct 28 12:25:25 2002 Stepan Kasal + + * Makefile.am (uninitialized): New test. + * uninitialized.awk, uninitialized.ok: New files. + +Mon Oct 28 11:24:16 2002 Stepan Kasal + + * Gentests: new script + * Maketests: new file, generated automatically by Gentests + * Makefile.am: new rules and variables to make use of Gentests; + Most targets removed, Gentests will take care + +Sun Oct 13 16:58:07 2002 Stepan Kasal + + * Makefile.am (nfneg): new test case. + * nfneg.awk, nfneg.ok: new files. + +Mon Oct 7 09:38:07 2002 Arnold D. Robbins + + * Makefile.am (noloop1, noloop2): new test cases. + * noloop.awk, noloop1.in, noloop1.ok, noloop2.in, noloop2.ok: + new files. + +Tue Oct 1 18:28:40 2002 Arnold D. Robbins + + * Makefile.am (poundbang): Rewrote rule to avoid problems + with hardcoding of /tmp pathname. + (poundbang.awk): Changed the way it works. + (poundbang.ok): Removed. + +Thu Sep 5 13:31:28 2002 Arnold D. Robbins + + * Makefile.am (rebuf): new test case. + * rebuf.awk, rebuf.in, rebuf.ok: new files. + +Wed Aug 21 15:31:57 2002 Andreas Buening + + * Makefile.am (AWKPROG): Add $(EXEEXT) macro. + (PATH_SEPERATOR): Removed. + (poundbag): Added $(EXEEXT) and use of ${TMPDIR-/tmp}. + +Wed Aug 7 13:47:09 2002 Arnold D. Robbins + + * Makefile.am (nulrsend): new test case. + * nulrsend.awk, nulrsend.in, nulrsend.ok: new files. + +Sun Aug 4 00:25:23 2002 Arnold D. Robbins + + * Makefile.am (gsubtst3, gsubtst4): new test cases. + * gsubtst3.awk, gsubtst3.ok, gsubtst4.awk, gsubtst4.ok: new files. + +Thu May 9 22:31:36 2002 Arnold D. Robbins + + * Makefile.am (gsubtst2): new test case. + * gsubtest.awk, gsubtest.ok: Added new test. + * gsubtst2.awk, gsubtst2.ok: new files. + +Sun May 5 12:38:55 2002 Arnold D. Robbins + + * Makefile.am: Minor mods to use LC_ALL=C so that checks will + use the English messages, not any translations. + (manyfiles): Fixed (hopefully) to leave a file around if the + test fails, so that we don't get a spurious "ALL TESTS PASSED" + message. + +Wed May 1 16:41:32 2002 Arnold D. Robbins + + * Release 3.1.1: Release tar file made. + +Tue Apr 16 17:07:25 2002 Arnold D. Robbins + + * Makefile.am (pass-fail): New target that prints an + `all passed' or `x tests failed' message, for use in + grep-ing build logs. + (check): Add pass-fail as last dependency. + + Thanks to Nelson Beebe for the thought, beebe@math.utah.edu. + +Sun Mar 10 17:00:51 2002 Scott Deifik + + * Makefile.am (strftime): Add TZ=GMT0 into environment, to + regularize things, esp. for some DJGPP systems. + +Mon Feb 18 14:55:19 2002 Arnold D. Robbins + + * Makefile.am (longsub): new test case. + * longsub.awk, longsub.in, longsub.ok: new files. + +Wed Jan 23 15:03:36 2002 Andreas Buening + + * Makefile.am (PATH_SEPARATOR): Added. + (awkpath): Make use of PATH_SEPARATOR. + +Wed Jan 23 14:50:38 2002 Arnold D. Robbins + + * Makefile.am (concat1): new test case. + * concat1.awk, concat1.in, concat1.ok: new files. + +Mon Jan 7 22:21:25 2002 Arnold D. Robbins + + * Makefile.am (forsimp): new test case. + * forsimp.awk, forsimp.ok: new files. + +Wed Dec 26 22:01:52 2001 Arnold D. Robbins + + * Makefile.am (inftest): Add sed to fix case issues between + different libc versions. Ugh. + +Wed Dec 19 16:01:58 2001 Peter J. Farley III + + * Makefile.am (manyfiles): Also delete \15 in tr. + +Tue Dec 18 20:56:07 2001 Andreas Buening + + * Makefile.am (nors): Add \15 to list of chars to delete so + test will run on OS/2 also. + +Thu Oct 4 18:34:49 2001 Arnold D. Robbins + + * Makefile.am (membug1): new test case. + * membug1.awk, membug1.in, membug1.ok: new files. + +Thu Aug 23 14:04:10 2001 Arnold D. Robbins + + * Makefile.am (minusstr): new test case. + * minusstr.awk, minusstr.ok: new files. + +Sat Aug 4 23:42:37 2001 Arnold D. Robbins + + * Makefile.am (arrymem1): new test case. + (compare2): new test case. + (regtest): Make test work, use regtest.sh, not .awk. + * arrymem1.awk, arrymem1.ok: new files. + * compare2.awk, compare2.ok: new files. + +Mon Jul 23 17:32:03 2001 Arnold D. Robbins + + * Makefile.am (onlynl): new test case. + * onlynl.awk, onlynl.in, onlynl.ok: new files. + +Wed Jun 13 18:12:43 2001 Arnold D. Robbins + + * Makefile.am (ofmtfidl): new test case. + * ofmtfidl.awk, ofmtfidl.in, ofmtfidl.ok: new files. + +Sun Jun 3 13:04:44 2001 Arnold D. Robbins + + * Release 3.1.0: Release tar file made. And there was + rejoicing. + +Sun May 6 13:30:20 2001 Arnold Robbins + + * inftest.awk: Changed test to use < so that it will + work for MSC and DJGPP combination, per Scott Deifik. + +Tue Mar 20 11:09:51 2001 Arnold Robbins + + * Makefile.am (funsemnl): new test case. + * funsemnl.awk, funsemnl.ok: new files. + +Wed Mar 7 11:31:41 2001 Arnold Robbins + + * Makefile.am (leadnl): new test case. + * leadnl.awk, leadnl.in, leadnl.ok: new files. + +Tue Feb 6 18:08:15 2001 Arnold Robbins + + * Makefile.am (rebt8b1, rebt8b2): new test case. + * rebt8b1.awk, rebt8b1.ok: new files. + * rebt8b2.awk, rebt8b2.ok: new files. + +Sun Dec 3 15:36:41 2000 Arnold Robbins + + * Makefile.am (gnuops2): New test case. + * gnuops2.awk, gnuops2.ok: New files, based on bug report from + Servatius.Brandt@fujitsu-siemens.com. + +Mon Nov 27 15:52:46 2000 Arnold Robbins + + * regx8bit.awk, regx8bit.ok: Updated to what should + work on all systems. + +Wed Nov 22 13:27:59 2000 Arnold Robbins + + * Makefile.am (poundbang): Added some smarts for /tmp mounted + noexec. Hopefully it'll even work. + +Tue Nov 14 17:45:02 2000 Arnold Robbins + + * Makefile.am: Added - to all cmp calls for consistency. + +Sun Nov 12 17:50:18 2000 Arnold Robbins + + * Makefile.am (addcomma): new test case. + * addcomma.awk, addcomma.in, addcomma.ok: new files. + +Tue Nov 7 16:03:06 2000 Arnold Robbins + + * Makefile.am (regx8bit, psx96sub): new test cases. + * regx8bit.awk, regx8bit.ok, psx96sub.awk, psx96sub.ok: new files. + +Sun Oct 22 12:09:43 2000 Arnold Robbins + + * Makefile.am (shadow): new test case. + * shadow.awk, shadow.ok: new files. + +Tue Oct 17 10:51:09 2000 Arnold Robbins + + * Makefile.am (arynasty): new test case. + * arynasty.awk, arynasty.ok: new files. + +Mon Oct 2 10:17:13 2000 Arnold Robbins + + * Makefile.am (clsflnam): Add redirect of stderr. + * clsflnam.awk, clsflnam.ok: modified to reflect changed + semantics of close() for a non-open file. See ../ChangeLog. + +Sun Sep 24 16:46:29 2000 Arnold Robbins + + * Makefile.am (nasty2): new test case. + * nasty2.awk, nasty2.ok: new files. + +Wed Sep 13 11:09:49 2000 Arnold Robbins + + * Makefile.am (check): Added calls to new targets that + print messages. + (clos1way, basic-msg-start, basic-msg-end, unix-msg-start, + unix-msg-end, extend-msg-start, extend-msg-end): new targets. + * clos1way.awk, clos1way.ok: new files. + +Tue Sep 12 16:29:54 2000 Arnold Robbins + + * Makefile.am (leaddig): new test case. + * leaddig.awk, leaddig.ok: new files. + +Wed Sep 6 14:09:15 2000 Arnold Robbins + + * Makefile.am (strtod): new test case. + * strtod.awk, strtod.in, strtod.ok: new files. + +Mon Sep 4 09:33:28 2000 Arnold D. Robbins + + * Makefile.in (octsub): new test case. + * octsub.awk, octsub.ok: new files. + +Sun Aug 13 12:37:16 2000 Arnold Robbins + + * Makefile.am (sort1, diffout): new test cases. + * sort1.awk, sort1.ok: new files. + +2000-02-15 Arnold Robbins + + * MOVED TO AUTOMAKE AND GETTEXT. + Just about every file touched. Work done by Arno Peters. + +Wed May 19 15:41:41 1999 Arnold D. Robbins + + * Makefile.in (datanonl,regeq,redfilnm): new test cases. + * datanonl.awk, datanonl.in, datanonl.ok: new files. + * regeq.awk, regeq.in, regeq.ok: new files. + * redfilnm.awk, redfilnm.in, redfilnm.ok: new files. + +Mon May 10 17:11:30 1999 Arnold D. Robbins + + * Makefile.in (rsnul1nl): new test case. + * rsnul1nl.awk, rsnul1nl.in, rsnul1nl.ok: new files. + +Sun Apr 25 13:02:35 1999 Arnold D. Robbins + + * Makefile.in (inetechu,inetecht,inetdayu,inetdayt,inet): new + tests, courtesy of Juergen Khars. + (paramtyp): new test for bug from Juergen. + * paramtyp.awk, paramtyp.in: new files. + +Sun Oct 25 23:11:46 1998 Arnold D. Robbins + + * Makefile.in (ofmtbig,procinfs): new test cases. + * procinfs.awk, procinfs.ok: new files. + * ofmtbig.awk, ofmtbig.in, ofmtbig.ok: new files. + +Tue Oct 20 22:07:10 1998 Arnold D. Robbins + + * Makefile.in (lint): new test case. + * lint.awk, lint.ok: new files. + * badargs.ok: updated output corresponding to change made to + main.c (see main ChangeLog). + +Tue May 26 20:39:07 1998 Arnold D. Robbins + + * pipeio2.awk: change "\'" to "'" to avoid new warning. + +Mon Mar 23 21:53:36 1998 Arnold D. Robbins + + * Makefile.in (fnasgnm): new test case. + * fnasgnm.awk, fnasgnm.in, fnasgnm.ok: new files. + +Fri Mar 20 11:01:38 1998 Arnold D. Robbins + + * Makefile.in (fnaryscl): new test case. + * fnaryscl.awk, fnaryscl.ok: new files. + +Mon Mar 16 15:23:22 1998 Arnold D. Robbins + + * Makefile.in (splitdef): new test case. + * splitdef.awk, splitdef.ok: new files. + +Fri Sep 26 01:10:14 1997 Arnold D. Robbins + + * Makefile.in (parseme): new test case. + * parseme.awk, parseme.ok: new files. + +Sun Sep 14 23:25:10 1997 Arnold D. Robbins + + * Makefile.in (ofmts): new test case. + * ofmts.awk, ofmts.in, ofmts.ok: new files. + +Sun Aug 17 07:17:35 1997 Arnold D. Robbins + + * Makefile.in (fsfwfs): new test case. + * fsfwfs.awk, fsfwfs.in, fsfwfs.ok: new files. + +Sun Jul 27 23:08:53 1997 Arnold D. Robbins + + * Makefile.in (hsprint): new test case. + * hsprint.awk, hsprint.ok, printfloat.awk: new files. + +Thu Jul 17 20:07:31 1997 Arnold D. Robbins + + * Makefile.in (ofmt): new test case. + * ofmt.awk, ofmt.in, ofmt.ok: new files. + +Sun Jun 22 16:17:35 1997 Arnold D. Robbins + + * Makefile.in (nlinstr): new test case. + * nlinstr.awk, nlinstr.in, nlinstr.ok: new files. + +Wed Jun 4 13:18:21 1997 Arnold D. Robbins + + * pid.sh: send errors to /dev/null to toss warning about + using PROCINFO["pid"] etc. This test explicitly tests + the special files. It'll need changing in 3.2. + +Thu Apr 24 23:24:59 1997 Arnold D. Robbins + + * Makefile.in (messages): remove special case if /dev/fd exists. + Finally. + +Mon Aug 7 15:23:00 2000 Arnold D. Robbins + + * Release 3.0.6: Release tar file made. + +Thu Aug 3 17:51:56 2000 Arnold D. Robbins + + * Makefile.in (nlstrina): new test case. + * nlstrina.awk, nlstrina.ok: new files. + +Tue Jul 11 14:22:55 2000 Arnold D. Robbins + + * Makefile.in (fnparydl): new test case. + * fnparydl.awk, fnparydl.ok: new files. + +Fri Jun 30 22:00:03 2000 Arnold D. Robbins + + * Makefile.in (arysubnm): new test case. + * arysubnm.awk, arysubnm.ok: new files. + +Sun Jun 25 15:08:19 2000 Arnold D. Robbins + + * Release 3.0.5: Release tar file made. + +Wed Jun 14 13:17:59 2000 Arnold D. Robbins + + * Makefile.in (getlnbuf): new test case. + * getlnbuf.awk, gtlnbufv.awk, getlnbuf.in, getlnbuf.ok: new files. + +Mon Jun 5 15:51:39 2000 Arnold D. Robbins + + * pipeio2.awk: Change use of tr to sed, fixes problems + on SCO OS5. + * pipeio2.ok: Updated to reflect use of sed. + +Tue May 2 13:28:04 2000 Arnold D. Robbins + + * Makefile.in (strftime): moved test code into a separate + file for the PC guys. + * strftime.awk: new file. + +Mon Apr 10 15:58:13 2000 Arnold D. Robbins + + * Makefile.in (longwrds): Add setting LC_ALL=C to sort + call to preserve traditional output. (Theme from the + Twilight Zone plays eerily in the background...) + +Sun Apr 2 17:51:40 2000 Arnold D. Robbins + + * Makefile.in (igncdym): new test case. + * igncdym.awk, igncdym.in, igncdym.ok: new files. + +Wed Mar 8 13:43:44 2000 Arnold D. Robbins + + * Makefile.in (arynocls): new test case. + * arynocls.awk, arynocls.in, arynocls.ok: new files. + +Sun Feb 6 11:45:15 2000 Arnold D. Robbins + + * Makefile.in (opasnidx): new test case. + * opasnidx.awk, opasnidx.ok: new files. + +Tue Feb 1 18:40:45 2000 Arnold D. Robbins + + * Makefile.in (opasnslf): new test case. + * opasnslf.awk, opasnslf.ok: new files. + +Thu Jan 27 18:09:18 2000 Arnold D. Robbins + + * Makefile.in (subslash): new test case. + * subslash.awk, subslash.ok: new files. + +Fri Nov 26 11:03:07 1999 Arnold D. Robbins + + * Makefile.in (numindex): new test case. + * numindex.awk, numindex.in, numindex.ok: new files. + +Sun Oct 24 08:46:16 1999 Arnold D. Robbins + + * Makefile.in (strftime): Add tweak for $NF that should + hopefully avoid cygwin problems with lack of timezone. + +Thu Jul 29 19:25:02 1999 Arnold D. Robbins + + * Makefile.in (fsmnam, fnamedat): new test cases. + * fsmnam.awk, fsmnam.ok: new files. + * fnamedat.awk, fnamedat.in, fnamedat.ok: new files. + +Wed Jun 30 16:14:36 1999 Arnold D. Robbins + + * Release 3.0.4: Release tar file made. This time for sure. + +Tue May 25 16:37:50 1999 Arnold D. Robbins + + * Makefile.in (printf1): new test case. + * printf1.awk, printf1.ok: new files. + +Wed May 19 15:32:09 1999 Arnold D. Robbins + + * reg/*: moved exp and log tests to new `Obsolete' directory; they + would only succeed under SunOS 4.x. + +Mon May 3 11:53:33 1999 Arnold D. Robbins + + * Makefile.in (gawk.extensions): removed `nondec' until the + associated features get documented in 3.1. + +Tue Nov 3 16:46:39 1998 Arnold D. Robbins + + * Makefile.in (getnr2tm, getnr2tb): new test cases. + * getnr2tm.awk, getnr2tm.in, getnr2tm.ok: new files. + * getnr2tb.awk, getnr2tb.in, getnr2tb.ok: new files. + +Sun Nov 1 13:20:08 1998 Arnold D. Robbins + + * Makefile.in (zeroflag): new test case. + * zeroflag.awk, zeroflag.ok: new files + +Wed Oct 28 18:44:19 1998 Arnold D. Robbins + + * Makefile.in (nasty): new test case. + * nasty.awk, nasty.ok: new files + +Sun Nov 16 20:08:59 1997 Arnold D. Robbins + + * gsubtest.awk, gsubtest.ok: fix for count of matches in gsub + from Geert.Debyser@esat.kuleuven.ac.be. + +Sun Nov 16 19:54:50 1997 Arnold D. Robbins + + * Makefile.in (strftime): fix a typo (LANC -> LANG). + +Thu May 15 12:49:08 1997 Arnold D. Robbins + + * Release 3.0.3: Release tar file made. + +Tue May 13 12:53:46 1997 Arnold D. Robbins + + * Makefile.in (messages): more testing for OK failure on Linux. + +Sun May 11 14:57:11 1997 Arnold D. Robbins + + * Makefile.in (nondec): new test case. + * nondec.awk, nondec.ok: new files. + +Sun May 11 07:07:05 1997 Arnold D. Robbins + + * Makefile.in (prdupval): new test case. + * prdupval.awk, prdupval.in, prdupval.ok: new files. + +Wed May 7 21:54:34 1997 Arnold D. Robbins + + * Makefile.in (delarprm): new test case. + * delarprm.awk, delarprm.ok: new files. + +Wed May 7 17:54:00 1997 Arnold D. Robbins + + * Makefile.in (pid): several fixes from ghazi@caip.rutgers.edu. + +Tue May 6 20:28:30 1997 Arnold D. Robbins + + * Makefile.in (strftime): Use the right locale stuff. + (clobber): don't need an input file. + +Thu Apr 24 22:24:42 1997 Arnold D. Robbins + + * Makefile.in (pid): new test case, from jco@convex.com. + (specfile): removed test case, pid does it better. + * pid.awk, pid.ok, pid.sh: new files. + * specfile.awk: removed. + +Wed Apr 23 23:37:10 1997 Arnold D. Robbins + + * Makefile.in (pipeio2): new test case. + * pipeio2.awk, pipeio2.ok, pipeio2.in: new files. + +Sun Apr 20 12:22:52 1997 Arnold D. Robbins + + * Makefile.in (clobber): new test case. + * clobber.awk, clobber.ok: new files. + +Fri Apr 18 07:55:47 1997 Arnold D. Robbins + + * BETA Release 3.0.34: Release tar file made. + +Tue Apr 15 05:57:29 1997 Arnold D. Robbins + + * Makefile.in (strftlng): More wizardry for bizarre Unix systems. + (nlfldsep): use program and input file, not shell script + (basic, unix-tests, gawk.extensions): moved specfile, pipeio1 + and strftlng into unix-tests per Pat Rankin. + * nlfldsep.awk, nlfldsep.in: new files. + * nlfldsep.sh: removed. + +Wed Apr 9 23:32:47 1997 Arnold D. Robbins + + * Makefile.in (funstack): new test case. + * funstack.awk, funstack.in, funstack.ok: new files. + * substr.awk: added many more tests. + * substr.ok: updated + +Wed Mar 19 20:10:21 1997 Arnold D. Robbins + + * Makefile.in (pipeio1): new test case. + * pipeio1.awk, pipeio1.ok: new files. + +Tue Mar 18 06:38:36 1997 Arnold D. Robbins + + * Makefile.in (noparm): new test case. + * noparm.awk, noparm.ok: new files. + +Fri Feb 21 06:30:18 1997 Arnold D. Robbins + + * Makefile.in (reint): new test case. + * reint.awk, reint.in, reint.ok: new files. + +Wed Feb 5 18:17:51 1997 Arnold D. Robbins + + * Makefile.in (fnarydel): new test case. + * fnarydel.awk, fnarydel.ok: new files. + +Sun Jan 19 17:06:18 1997 Arnold D. Robbins + + * Makefile.in (nors): new test case. + * nors.ok: new file. + +Sun Jan 19 17:06:18 1997 Arnold D. Robbins + + * Makefile.in (specfile, strftlng, nfldstr): new test cases. + * specfile.awk, strftlng.awk, strftlng.ok, nfldstr.ok: new files. + +Fri Dec 27 11:27:13 1996 Arnold D. Robbins + + * Makefile.in (intest): new test case. + * intest.awk, intest.ok: new files. + +Wed Dec 25 11:25:22 1996 Arnold D. Robbins + + * Release 3.0.2: Release tar file made. + +Tue Dec 10 23:09:26 1996 Arnold D. Robbins + + * Release 3.0.1: Release tar file made. + +Thu Nov 7 09:12:20 1996 Arnold D. Robbins + + * Makefile.in (splitvar): new test case. + * splitvar.awk, splitvar.in, splitvar.ok: new files. + +Sun Nov 3 10:55:50 1996 Arnold D. Robbins + + * Makefile.in (nlfldsep): new test case. + * nlfldsep.sh, nlfldsep.ok: new files. + +Fri Oct 25 10:29:56 1996 Arnold D. Robbins + + * rand.awk: call srand with fixed seed. + * rand.ok: new file. + * Makefile.in (rand): changed to compare output with rand.ok. + +Sat Oct 19 21:52:04 1996 Arnold D. Robbins + + * Makefile.in (tradanch): new test case. + * tradanch.awk, tradanch.in, tradanch.ok: new files. + +Thu Oct 17 21:22:05 1996 Arnold D. Robbins + + * tweakfld.awk: move `rm' out into Makefile.in. + * eofsplit.awk: fixed buggy code so won't loop forever. + * Makefile.in (all): add unix-tests. + (unix-tests): new target, has pound-bang, fflush, getlnhd. + (basic): removed fflush, getlnhd. + (tweakfld): added rm from tweakfld.awk. + +Sun Oct 6 22:00:35 1996 Arnold D. Robbins + + * Makefile.in (back89): new test case. + * back89.in, back89.ok: new files. + +Sun Oct 6 20:45:54 1996 Arnold D. Robbins + + * Makefile.in (splitwht): new test case. + * splitwht.awk, splitwht.ok: new files. + +Sun Sep 29 23:14:20 1996 Arnold D. Robbins + + * Makefile.in (gsubtest): new test case. + * gsubtest.awk, gsubtest.ok: new files. + +Fri Sep 20 11:58:40 1996 Arnold D. Robbins + + * Makefile.in (prtoeval): new test case. + * prtoeval.awk, prtoeval.ok: new files. + +Tue Sep 10 06:26:44 1996 Arnold D. Robbins + + * Makefile.in (gsubasgn): new test case. + * gsubasgn.awk, gsubasgn.ok: new files. + +Wed Aug 28 22:06:33 1996 Arnold D. Robbins + + * badargs.ok: updated output corresponding to change made to + main.c (see main ChangeLog). + +Thu Aug 1 07:20:28 1996 Arnold D. Robbins + + * Makefile.in (clean): remove out[123] files from `messages' test. + Thanks to Pat Rankin (rankin@eql.caltech.edu). + +Sat Jul 27 23:56:57 1996 Arnold D. Robbins + + * Makefile.in (prt1eval): new test case. + * prt1eval.awk, prt1eval.ok: new files. + +Mon Jul 22 22:06:10 1996 Arnold D. Robbins + + * Makefile.in (eofsplit): new test case. + * eofsplit.awk, eofsplit.ok: new files. + +Sun Jul 14 07:07:45 1996 Arnold D. Robbins + + * Makefile.in (fldchgnf): new test case. + * fldchgnf.awk, fldchgnf.ok: new files. + +Tue May 21 23:23:22 1996 Arnold D. Robbins + + * Makefile.in (substr): new test case. + * substr.awk, substr.ok: new files. + +Tue May 14 15:05:23 1996 Arnold D. Robbins + + * Makefile.in (dynlj): new test case. + * dynlj.awk, dynlj.ok: new files. + +Sun May 12 20:45:34 1996 Arnold D. Robbins + + * Makefile.in (fnarray): new test case. + * fnarray.awk, fnarray.ok: new files. + +Fri Mar 15 06:46:48 1996 Arnold D. Robbins + + * Makefile.in (clean): added `*~' to list of files to be removed. + * tweakfld.awk (END): added to do clean up action. + +Thu Mar 14 16:41:32 1996 Arnold D. Robbins + + * Makefile.in (mmap8k): new test case. + * mmap8k.in, mmap8k.ok: new files. + +Sun Mar 10 22:58:35 1996 Arnold D. Robbins + + * Makefile.in (clsflnam): new test case. + * clsflnam.in, clsflnam.awk, clsflnam.ok: new files. + * tweakfld.awk: changed to have a fixed date. + +Thu Mar 7 09:56:09 1996 Arnold D. Robbins + + * Makefile.in (tweakfld): new test case. + * tweakfld.in, tweakfld.awk, tweakfld.ok: new files. + +Sun Mar 3 06:51:26 1996 Arnold D. Robbins + + * Makefile.in (getlnhd, backgsub) : new test cases. + * getlnhd.awk, getlnhd.ok: new files. + * backgsub.in, backgsub.awk, backgsub.ok: new files. + +Mon Feb 26 22:30:02 1996 Arnold D. Robbins + + * Makefile.in (sprintfc): new test case. + * sprintfc.in, sprintfc.awk, sprintfc.ok: new files. + * gensub.awk: updated for case of no match of regex. + +Wed Jan 24 10:06:16 1996 Arnold D. Robbins + + * Makefile.in (distclean, maintainer-clean): new targets. + (reindops): added test from Rick Adams (rick@uunet.uu.net). + (arrayparm, paramdup, defref, strftime, prmarscl, sclforin, + sclifin): Fix from Larry Schwimmer (schwim@cyclone.stanford.edu) + so that tests that are supposed to fail use `... || exit 0' to + cause a clean `make clean'. + +Wed Jan 10 22:58:55 1996 Arnold D. Robbins + + * ChangeLog created. diff --git a/test/Gentests b/test/Gentests new file mode 100755 index 0000000..fc779f0 --- /dev/null +++ b/test/Gentests @@ -0,0 +1,113 @@ +#!/usr/bin/gawk -f + +# This program should generate Maketests + +BEGIN { + if (VMSTESTS) vmsargvfixup() + + # read the list of files + for (i = 2; i < ARGC; i++) + files[ARGV[i]] + + # throw it away + ARGC = 2 + + ntests = 0 +} + +# process the file Makefile.am: + +/^[[:upper:]_]*_TESTS *=/,/[^\\]$/ { + gsub(/(^[[:upper:]_]*_TESTS *=|\\$)/,"") + for (i = 1; i <= NF; i++) + tests[++ntests] = $i + next +} + +/^NEED_LINT *=/,/[^\\]$/ { + gsub(/(^NEED_LINT *=|\\$)/,"") + for (i = 1; i <= NF; i++) + lint[$i] + next +} + +/^NEED_LINT_OLD *=/,/[^\\]$/ { + gsub(/(^NEED_LINT_OLD *=|\\$)/,"") + for (i = 1; i <= NF; i++) + lint_old[$i] + next +} + +/^GENTESTS_UNUSED *=/,/[^\\]$/ { + gsub(/(^GENTESTS_UNUSED *=|\\$)/,"") + for (i = 1; i <= NF; i++) + unused[$i] + next +} + +/^[[:alpha:]_][[:alnum:]_]*:/ { + # remember all targets from Makefile.am + sub(/:.*/,"") + targets[$0] +} + +# Now write the output file: +END { + # this line tells automake to keep the comment with the rules: + print "Gt-dummy:" + print "# file Maketests, generated from Makefile.am by the Gentests program" + + for (i = 1; i <= ntests; i++) { + x = tests[i] + if (!(x in targets)) + generate(x) + } + + print "# end of file Maketests" +} + +function generate(x, s) +{ + if (!(x".awk" in files)) + printf "WARNING: file `%s.awk' not found.\n", x > "/dev/stderr" + else + delete files[x".awk"] + + if (VMSTESTS) return vmsgenerate(x) + + print x ":" + + s = "" + if (x in lint) { + s = s " --lint" + delete lint[x] + } + if (x in lint_old) { + s = s " --lint-old" + delete lint_old[x] + } + if (x".in" in files) { + s = s " < $(srcdir)/$@.in" + delete files[x".in"] + } + + printf "\t@echo %s\n", x + printf "\t@AWKPATH=$(srcdir) $(AWK) -f $@.awk %s >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@\n", s + printf "\t@-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@\n\n" +} + +END { + for (x in lint) + if (!(x in targets)) + printf "WARNING: --lint target `%s' is missing.\n", x > "/dev/stderr" + for (x in lint_old) + if (!(x in targets)) + printf "WARNING: --lint-old target `%s' is missing.\n", x > "/dev/stderr" + for (x in files) + if (!(x in unused) && \ + !(gensub(/\.(awk|in)$/,"","",x) in targets)) + printf "WARNING: unused file `%s'.\n", x > "/dev/stderr" +} + +# VMSTESTS: generate test template in vms format +# gawk -v "VMSTESTS=1" -f Gentests -f Gentests.vms Makefile.am *.awk *.in >Maketests.vms diff --git a/test/Gentests.vms b/test/Gentests.vms new file mode 100644 index 0000000..cac7abd --- /dev/null +++ b/test/Gentests.vms @@ -0,0 +1,102 @@ +# Gentests.vms - supplements Gentests to generate tests in vms format +# gawk -v "VMSTESTS=1" -f Gentests -f Gentests.vms Makefile.am *.awk *.in >Maketests.vms + +/^FAIL_CODE1 *=/,/[^\\]$/ { + gsub(/(^FAIL_CODE1 *=|\\$)/,"") + for (i = 1; i <= NF; i++) + fail_code1[$i] + next +} + +END { + if (VMSTESTS) vmsepilog() +} + +# wildcard expansion done by gawk's vms_arg_fixup() to simulate shell +# globbing produces full filenames: device:[directory]name.type;# +# and by default also forces the value into upper case +function vmsargvfixup( i, f) +{ + # we're forcing lowercase below; need to override for some files + vmscasefixup["makefile.in"] = "Makefile.in" + + for (i = 2; i < ARGC; i++) { + f = ARGV[i] + sub(/^.+[]>]/, "", f) # strip dev+dir prefix + sub(/\;[0-9]+$/, "", f) # strip version suffix + f = tolower(f) + if (f in vmscasefixup) f = vmscasefixup[f] + ARGV[i] = f + } + + vmsprolog() # insert some stuff into the output file +} + +# output sufficient for the simplest tests in vms/vmstest.com +function vmsgenerate(x, s, o) +{ + # generate a gosub-style subroutine; start with its label + printf "$" x ":" + + s = "" + if (x in lint) { + s = s " --lint" + delete lint[x] + } + if (x in lint_old) { + s = s " --lint-old" + delete lint_old[x] + } + if (x".in" in files) { + s = s " <" x ".in" + delete files[x".in"] + } + + o = "_" x ".tmp" + print "\techo \"" x "\"" + print "$\tAWKPATH_srcdir" + print "$\tgawk -f " x ".awk" s " >" o " 2>&1" + print "$\tif .not.$status then call exit_code \"" o "\" " \ + ((x in fail_code1) ? "1" : "2") + print "$\tcmp " x ".ok " o + print "$\tif $status" + print "$\tthen\trm " o ";" + print "$\telse\techo \"test \"\"" x "\"\" failed\"" + print "$\tendif" + print "$\treturn" + + return +} + +# prolog for Maketests.vms +function vmsprolog() +{ + print "$" + print "$\techo\t= \"write sys$output\"" + print "$\tcmp\t= \"diff/Output=_NL:/Maximum=1\"" + print "$\trm\t= \"delete/noConfirm/noLog\"" + print "$\tgawk\t= \"$sys$disk:[-]gawk.exe\"" + print "$\tAWKPATH_srcdir = \"define/User AWKPATH sys$disk:[]\"" + print "$" + + print "$\tset noOn" + print "$ gosub 'p1'" + print "$\tset On" + print "$ exit" + print "$" +} + +# epilog for Maketests.vms +function vmsepilog() +{ + print "$" + print "$! add a fake \"EXIT CODE\" record to the end of temporary output file" + print "$! to simulate the ``|| echo EXIT CODE $$? >>_$@'' shell script usage" + print "$exit_code: subroutine" + print "$\tif f$trnlnm(\"FTMP\").nes.\"\" then close/noLog ftmp" + print "$\topen/Append ftmp 'p1'" + print "$\twrite ftmp \"EXIT CODE: \",p2" + print "$\tclose ftmp" + print "$ endsubroutine !exit_code" + print "$" +} diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 0000000..911d8dc --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1,1511 @@ +# +# test/Makefile.am --- automake input file for gawk +# +# Copyright (C) 1988-2012 the Free Software Foundation, Inc. +# +# This file is part of GAWK, the GNU implementation of the +# AWK Programming Language. +# +# GAWK is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# + +## process this file with automake to produce Makefile.in + +EXTRA_DIST = \ + reg \ + lib \ + ChangeLog.0 \ + Gentests \ + Gentests.vms \ + Maketests \ + README \ + aadelete1.awk \ + aadelete1.ok \ + aadelete2.awk \ + aadelete2.ok \ + aarray1.awk \ + aarray1.ok \ + aasort.awk \ + aasort.ok \ + aasorti.awk \ + aasorti.ok \ + addcomma.awk \ + addcomma.in \ + addcomma.ok \ + anchgsub.awk \ + anchgsub.in \ + anchgsub.ok \ + arraysort.awk \ + arraysort.ok \ + argarray.awk \ + argarray.in \ + argarray.ok \ + argtest.awk \ + argtest.ok \ + arrayparm.awk \ + arrayparm.ok \ + arrayprm2.awk \ + arrayprm2.ok \ + arrayprm3.awk \ + arrayprm3.ok \ + arrayref.awk \ + arrayref.ok \ + arrymem1.awk \ + arrymem1.ok \ + arryref2.awk \ + arryref2.ok \ + arryref3.awk \ + arryref3.ok \ + arryref4.awk \ + arryref4.ok \ + arryref5.awk \ + arryref5.ok \ + arynasty.awk \ + arynasty.ok \ + arynocls.awk \ + arynocls.in \ + arynocls.ok \ + aryprm1.awk \ + aryprm1.ok \ + aryprm2.awk \ + aryprm2.ok \ + aryprm3.awk \ + aryprm3.ok \ + aryprm4.awk \ + aryprm4.ok \ + aryprm5.awk \ + aryprm5.ok \ + aryprm6.awk \ + aryprm6.ok \ + aryprm7.awk \ + aryprm7.ok \ + aryprm8.awk \ + aryprm8.ok \ + arysubnm.awk \ + arysubnm.ok \ + asgext.awk \ + asgext.in \ + asgext.ok \ + asort.awk \ + asort.ok \ + asorti.awk \ + asorti.ok \ + awkpath.ok \ + back89.awk \ + back89.in \ + back89.ok \ + backgsub.awk \ + backgsub.in \ + backgsub.ok \ + backw.awk \ + backw.in \ + backw.ok \ + badargs.ok \ + beginfile1.awk \ + beginfile1.ok \ + beginfile2.in \ + beginfile2.ok \ + beginfile2.sh \ + binmode1.ok \ + childin.awk \ + childin.in \ + childin.ok \ + clobber.awk \ + clobber.ok \ + clos1way.awk \ + clos1way.ok \ + closebad.awk \ + closebad.ok \ + clsflnam.awk \ + clsflnam.in \ + clsflnam.ok \ + compare.awk \ + compare.in \ + compare.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 \ + convfmt.awk \ + convfmt.ok \ + datanonl.awk \ + datanonl.in \ + datanonl.ok \ + defref.awk \ + defref.ok \ + delargv.awk \ + delargv.ok \ + delarprm.awk \ + delarprm.ok \ + delarpm2.awk \ + delarpm2.ok \ + delfunc.awk \ + delfunc.ok \ + delsub.awk \ + delsub.ok \ + devfd.in1 \ + devfd.in2 \ + devfd.in4 \ + devfd.in5 \ + devfd.ok \ + devfd1.awk \ + devfd1.ok \ + devfd2.ok \ + dfastress.awk \ + dfastress.ok \ + double1.awk \ + double1.ok \ + double2.awk \ + double2.ok \ + dtdgport.awk \ + dumpvars.in \ + dumpvars.ok \ + dynlj.awk \ + dynlj.ok \ + eofsplit.awk \ + eofsplit.ok \ + exit.ok \ + exit.sh \ + exitval1.awk \ + exitval1.ok \ + exitval2.awk \ + exitval2.ok \ + exitval2.w32 \ + fcall_exit.awk \ + fcall_exit.ok \ + fcall_exit2.awk \ + fcall_exit2.ok \ + fcall_exit2.in \ + fflush.ok \ + fflush.sh \ + fieldwdth.awk \ + fieldwdth.in \ + fieldwdth.ok \ + fldchg.awk \ + fldchg.in \ + fldchg.ok \ + fldchgnf.awk \ + fldchgnf.in \ + fldchgnf.ok \ + fmtspcl.awk \ + fmtspcl.tok \ + fmttest.awk \ + fmttest.ok \ + fnamedat.awk \ + fnamedat.in \ + fnamedat.ok \ + fnarray.awk \ + fnarray.ok \ + fnarray2.awk \ + fnarray2.ok \ + fnarydel.awk \ + fnarydel.ok \ + fnaryscl.awk \ + fnaryscl.ok \ + fnasgnm.awk \ + fnasgnm.in \ + fnasgnm.ok \ + fnmisc.awk \ + fnmisc.ok \ + fnparydl.awk \ + fnparydl.ok \ + fpat1.awk \ + fpat1.in \ + fpat1.ok \ + fpat2.awk \ + fpat2.ok \ + fpat3.awk \ + fpat3.in \ + fpat3.ok \ + fpatnull.awk \ + fpatnull.in \ + fpatnull.ok \ + fordel.awk \ + fordel.ok \ + forref.awk \ + forref.ok \ + forsimp.awk \ + forsimp.ok \ + fsbs.awk \ + fsbs.in \ + fsbs.ok \ + fsfwfs.awk \ + fsfwfs.in \ + fsfwfs.ok \ + fsrs.awk \ + fsrs.in \ + fsrs.ok \ + fsspcoln.awk \ + fsspcoln.in \ + fsspcoln.ok \ + fstabplus.awk \ + fstabplus.in \ + fstabplus.ok \ + funlen.awk \ + funlen.in \ + funlen.ok \ + funsemnl.awk \ + funsemnl.ok \ + funsmnam.awk \ + funsmnam.ok \ + funstack.awk \ + funstack.in \ + funstack.ok \ + fwtest.awk \ + fwtest.in \ + fwtest.ok \ + fwtest2.awk \ + fwtest2.in \ + fwtest2.ok \ + fwtest3.awk \ + fwtest3.in \ + fwtest3.ok \ + gensub.awk \ + gensub.in \ + gensub.ok \ + gensub2.awk \ + gensub2.ok \ + getline.awk \ + getline.in \ + getline.ok \ + getline2.awk \ + getline2.ok \ + getline3.awk \ + getline3.ok \ + getline4.awk \ + getline4.in \ + getline4.ok \ + getlnbuf.awk \ + getlnbuf.in \ + getlnbuf.ok \ + getlndir.awk \ + getlndir.ok \ + getlnhd.awk \ + getlnhd.ok \ + getnr2tb.awk \ + getnr2tb.in \ + getnr2tb.ok \ + getnr2tm.awk \ + getnr2tm.in \ + getnr2tm.ok \ + gnuops2.awk \ + gnuops2.ok \ + gnuops3.awk \ + gnuops3.ok \ + gnureops.awk \ + gnureops.ok \ + gsubasgn.awk \ + gsubasgn.ok \ + gsubtest.awk \ + gsubtest.ok \ + gsubtst2.awk \ + gsubtst2.ok \ + gsubtst3.awk \ + gsubtst3.in \ + gsubtst3.ok \ + gsubtst4.awk \ + gsubtst4.ok \ + gsubtst5.awk \ + gsubtst5.in \ + gsubtst5.ok \ + gsubtst6.awk \ + gsubtst6.ok \ + gsubtst7.awk \ + gsubtst7.in \ + gsubtst7.ok \ + gsubtst8.awk \ + gsubtst8.in \ + gsubtst8.ok \ + gtlnbufv.awk \ + hex.awk \ + hex.ok \ + hsprint.awk \ + hsprint.ok \ + icasefs.awk \ + icasefs.ok \ + icasers.awk \ + icasers.in \ + icasers.ok \ + igncdym.awk \ + igncdym.in \ + igncdym.ok \ + igncfs.awk \ + igncfs.in \ + igncfs.ok \ + ignrcase.awk \ + ignrcase.in \ + ignrcase.ok \ + ignrcas2.awk \ + ignrcas2.ok \ + indirectcall.awk \ + indirectcall.in \ + indirectcall.ok \ + inftest.awk \ + inftest.ok \ + inputred.awk \ + inputred.ok \ + intest.awk \ + intest.ok \ + intformat.awk \ + intformat.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 \ + lint.awk \ + lint.ok \ + lintold.awk \ + lintold.in \ + lintold.ok \ + lintwarn.awk \ + lintwarn.ok \ + litoct.awk \ + litoct.ok \ + localenl.ok \ + localenl.sh \ + longdbl.awk \ + longdbl.in \ + longdbl.ok \ + longsub.awk \ + longsub.in \ + longsub.ok \ + longwrds.awk \ + longwrds.ok \ + longwrds.in \ + manglprm.awk \ + manglprm.in \ + manglprm.ok \ + manyfiles.awk \ + manyfiles.ok \ + match1.awk \ + match1.ok \ + match2.awk \ + match2.ok \ + match3.awk \ + match3.in \ + match3.ok \ + math.awk \ + math.ok \ + mbfw1.awk \ + mbfw1.in \ + mbfw1.ok \ + mbprintf1.awk \ + mbprintf1.in \ + mbprintf1.ok \ + mbprintf2.awk \ + mbprintf2.ok \ + mbprintf3.awk \ + mbprintf3.in \ + mbprintf3.ok \ + mbstr1.awk \ + mbstr1.ok \ + membug1.awk \ + membug1.in \ + membug1.ok \ + messages.awk \ + minusstr.awk \ + minusstr.ok \ + mixed1.ok \ + mmap8k.in \ + mtchi18n.awk \ + mtchi18n.in \ + mtchi18n.ok \ + nasty.awk \ + nasty.ok \ + nasty2.awk \ + nasty2.ok \ + nastyparm.awk \ + nastyparm.ok \ + negexp.awk \ + negexp.ok \ + negrange.awk \ + negrange.ok \ + nested.awk \ + nested.in \ + nested.ok \ + next.ok \ + next.sh \ + nfldstr.awk \ + nfldstr.in \ + nfldstr.ok \ + nfneg.awk \ + nfneg.ok \ + nfset.awk \ + nfset.in \ + nfset.ok \ + nlfldsep.awk \ + nlfldsep.in \ + nlfldsep.ok \ + nlinstr.awk \ + nlinstr.in \ + nlinstr.ok \ + nlstrina.awk \ + nlstrina.ok \ + noeffect.awk \ + noeffect.ok \ + nofile.ok \ + nofmtch.awk \ + nofmtch.ok \ + noloop1.awk \ + noloop1.in \ + noloop1.ok \ + noloop2.awk \ + noloop2.in \ + noloop2.ok \ + nondec.awk \ + nondec.ok \ + nondec2.awk \ + nondec2.ok \ + nonl.awk \ + nonl.ok \ + noparms.awk \ + noparms.ok \ + nors.in \ + nors.ok \ + nulrsend.awk \ + nulrsend.in \ + nulrsend.ok \ + numindex.awk \ + numindex.in \ + numindex.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 \ + onlynl.awk \ + onlynl.in \ + onlynl.ok \ + opasnidx.awk \ + opasnidx.ok \ + opasnslf.awk \ + opasnslf.ok \ + out1.ok \ + out2.ok \ + out3.ok \ + paramdup.awk \ + paramdup.ok \ + paramres.awk \ + paramres.ok \ + paramtyp.awk \ + paramtyp.ok \ + parse1.awk \ + parse1.in \ + parse1.ok \ + parsefld.awk \ + parsefld.in \ + parsefld.ok \ + parseme.awk \ + parseme.ok \ + patsplit.awk \ + patsplit.ok \ + pcntplus.awk \ + pcntplus.ok \ + pid.awk \ + pid.ok \ + pid.sh \ + pipeio1.awk \ + pipeio1.ok \ + pipeio2.awk \ + pipeio2.in \ + pipeio2.ok \ + posix.awk \ + posix.in \ + posix.ok \ + posix2008sub.awk \ + posix2008sub.ok \ + poundbang.awk \ + prdupval.awk \ + prdupval.in \ + prdupval.ok \ + profile2.ok \ + profile3.awk \ + profile3.ok \ + prec.awk \ + prec.ok \ + printf0.awk \ + printf0.ok \ + printf1.awk \ + printf1.ok \ + printfbad1.awk \ + printfbad1.ok \ + printfbad2.awk \ + printfbad2.in \ + printfbad2.ok \ + printfbad3.awk \ + printfbad3.ok \ + printfloat.awk \ + printlang.awk \ + prmarscl.awk \ + prmarscl.ok \ + prmreuse.awk \ + prmreuse.ok \ + procinfs.awk \ + procinfs.ok \ + prt1eval.awk \ + prt1eval.ok \ + prtoeval.awk \ + prtoeval.ok \ + pty1.awk \ + pty1.ok \ + rand.awk \ + rand.ok \ + range1.awk \ + range1.in \ + range1.ok \ + rebt8b1.awk \ + rebt8b1.ok \ + rebt8b2.awk \ + rebt8b2.ok \ + redfilnm.awk \ + redfilnm.in \ + redfilnm.ok \ + regeq.awk \ + regeq.in \ + regeq.ok \ + regrange.awk \ + regrange.ok \ + regtest.sh \ + regx8bit.awk \ + regx8bit.ok \ + rebuf.awk \ + rebuf.in \ + rebuf.ok \ + reindops.awk \ + reindops.in \ + reindops.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 \ + rsnulbig.ok \ + rsnulbig2.ok \ + rsstart1.awk \ + rsstart1.in \ + rsstart1.ok \ + rsstart2.awk \ + rsstart2.ok \ + rsstart3.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 \ + rtlen.ok \ + rtlen.sh \ + rtlen01.ok \ + rtlen01.sh \ + scalar.awk \ + scalar.ok \ + sclforin.awk \ + sclforin.ok \ + sclifin.awk \ + sclifin.ok \ + shadow.awk \ + shadow.ok \ + sort1.awk \ + sort1.ok \ + sortempty.awk \ + sortempty.ok \ + sortfor.awk \ + sortfor.in \ + sortfor.ok \ + sortu.awk \ + sortu.ok \ + space.ok \ + splitarg4.awk \ + splitarg4.in \ + splitarg4.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 \ + strtod.awk \ + strtod.in \ + strtod.ok \ + strnum1.awk \ + strnum1.ok \ + strtonum.awk \ + strtonum.ok \ + strftime.awk \ + strftlng.awk \ + strftlng.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 \ + switch2.awk \ + switch2.ok \ + synerr1.awk \ + synerr1.ok \ + synerr2.awk \ + synerr2.ok \ + tradanch.awk \ + tradanch.in \ + tradanch.ok \ + tweakfld.awk \ + tweakfld.in \ + tweakfld.ok \ + uninit2.awk \ + uninit2.ok \ + uninit3.awk \ + uninit3.ok \ + uninit4.awk \ + uninit4.ok \ + uninit5.awk \ + uninit5.ok \ + uninitialized.awk \ + uninitialized.ok \ + unterm.awk \ + unterm.ok \ + uparrfs.awk \ + uparrfs.in \ + uparrfs.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 \ + widesub4.awk \ + widesub4.ok \ + wjposer1.awk \ + wjposer1.in \ + wjposer1.ok \ + xref.awk \ + xref.original \ + zero2.awk \ + zero2.ok \ + zeroe0.awk \ + zeroe0.ok \ + zeroflag.awk \ + zeroflag.ok + +TESTS_WE_ARE_NOT_DOING_YET_FIXME_ONE_DAY = longdbl + +# Get rid of core files when cleaning and generated .ok file +CLEANFILES = core core.* fmtspcl.ok + +# try to keep these sorted. each letter starts a new line +BASIC_TESTS = \ + addcomma anchgsub argarray arrayparm arrayprm2 arrayprm3 \ + arrayref arrymem1 arryref2 arryref3 arryref4 arryref5 arynasty \ + arynocls aryprm1 aryprm2 aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 \ + aryprm8 arysubnm asgext awkpath \ + back89 backgsub \ + childin clobber closebad clsflnam compare compare2 concat1 concat2 \ + concat3 concat4 convfmt \ + datanonl defref delargv delarpm2 delarprm delfunc dfastress dynlj \ + eofsplit exitval1 exitval2 \ + fcall_exit fcall_exit2 fldchg fldchgnf fnamedat fnarray fnarray2 \ + fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fsrs fsspcoln \ + fstabplus funsemnl funsmnam funstack \ + getline getline2 getline3 getline4 getlnbuf getnr2tb getnr2tm \ + gsubasgn gsubtest gsubtst2 gsubtst3 gsubtst4 gsubtst5 gsubtst6 \ + gsubtst7 gsubtst8 \ + hex hsprint \ + inputred intest intprec iobug1 \ + leaddig leadnl litoct longsub longwrds \ + manglprm math membug1 messages minusstr mmap8k mtchi18n \ + nasty nasty2 negexp negrange nested nfldstr nfneg nfset nlfldsep \ + nlinstr nlstrina noeffect nofile nofmtch noloop1 noloop2 nonl \ + noparms nors nulrsend numindex numsubstr \ + octsub ofmt ofmta ofmtbig ofmtfidl ofmts onlynl opasnidx opasnslf \ + paramdup paramres paramtyp parse1 parsefld parseme pcntplus \ + posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \ + prt1eval prtoeval \ + rand range1 rebt8b1 redfilnm regeq regrange reindops reparse \ + resplit rri1 rs rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \ + rstest3 rstest4 rstest5 rswhite \ + scalar sclforin sclifin sortempty splitargv splitarr splitdef \ + splitvar splitwht strcat1 strnum1 strtod subamp subi18n \ + subsepnm subslash substr swaplns synerr1 synerr2 tradanch tweakfld \ + uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs \ + wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \ + zero2 zeroe0 zeroflag + +UNIX_TESTS = \ + fflush getlnhd localenl pid pipeio1 pipeio2 poundbang rtlen rtlen01 \ + space strftlng + +GAWK_EXT_TESTS = \ + aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \ + backw badargs beginfile1 beginfile2 binmode1 \ + clos1way delsub devfd devfd1 devfd2 dumpvars exit \ + fieldwdth fpat1 fpat2 fpat3 fpatnull fsfwfs funlen \ + fwtest fwtest2 fwtest3 \ + gensub gensub2 getlndir gnuops2 gnuops3 gnureops \ + icasefs icasers igncdym igncfs ignrcas2 ignrcase indirectcall \ + lint lintold lintwarn \ + manyfiles match1 match2 match3 mbstr1 \ + nastyparm next nondec nondec2 \ + patsplit posix printfbad1 printfbad2 printfbad3 procinfs \ + profile1 profile2 profile3 pty1 \ + rebuf regx8bit reint reint2 rsstart1 \ + rsstart2 rsstart3 rstest6 shadow sortfor sortu splitarg4 strftime \ + strtonum switch2 + +EXTRA_TESTS = inftest regtest + +INET_TESTS = inetdayu inetdayt inetechu inetecht + +MACHINE_TESTS = double1 double2 fmtspcl intformat + +LOCALE_CHARSET_TESTS = \ + asort asorti fmttest fnarydel fnparydl lc_num1 mbfw1 \ + mbprintf1 mbprintf2 mbprintf3 rebt8b2 rtlenmb sort1 sprintfc + +# List of the tests which should be run with --lint option: +NEED_LINT = \ + defref fmtspcl lintwarn noeffect nofmtch shadow \ + uninit2 uninit3 uninit4 uninit5 uninitialized + +# List of the tests which should be run with --lint-old option: +NEED_LINT_OLD = lintold + +# List of the tests which fail with EXIT CODE 1 +FAIL_CODE1 = \ + fnarray2 fnmisc gsubasgn mixed1 noparms paramdup synerr1 synerr2 unterm + +# List of the files that appear in manual tests or are for reserve testing: +GENTESTS_UNUSED = Makefile.in gtlnbufv.awk printfloat.awk + +CMP = cmp +AWKPROG = ../gawk$(EXEEXT) +PGAWKPROG = ../pgawk$(EXEEXT) + +# This business forces the locale to be C for running the tests, +# unless we override it to something else for testing. +# +# This can also be done in individual tests where we wish to +# check things specifically not in the C locale. +AWK = LC_ALL=$${GAWKLOCALE:-C} LANG=$${GAWKLOCALE:-C} $(AWKPROG) +PGAWK = LC_ALL=$${GAWKLOCALE:-C} LANG=$${GAWKLOCALE:-C} $(PGAWKPROG) + +# Message stuff is to make it a little easier to follow. +# Make the pass-fail last and dependent on others to avoid +# spurious errors if `make -j' in effect. +check: msg \ + printlang \ + basic-msg-start basic basic-msg-end \ + unix-msg-start unix-tests unix-msg-end \ + extend-msg-start gawk-extensions extend-msg-end \ + machine-msg-start machine-tests machine-msg-end \ + charset-msg-start charset-tests charset-msg-end + @$(MAKE) pass-fail + +basic: $(BASIC_TESTS) + +unix-tests: $(UNIX_TESTS) + +gawk-extensions: $(GAWK_EXT_TESTS) + +charset-tests: $(LOCALE_CHARSET_TESTS) + +extra: $(EXTRA_TESTS) inet + +inet: inetmesg $(INET_TESTS) + +machine-tests: $(MACHINE_TESTS) + +msg:: + @echo '' + @echo 'Any output from "cmp" is bad news, although some differences' + @echo 'in floating point values are probably benign -- in particular,' + @echo 'some systems may omit a leading zero and the floating point' + @echo 'precision may lead to slightly different output in a few cases.' + +printlang:: + @$(AWK) -f $(srcdir)/printlang.awk + +basic-msg-start: + @echo "======== Starting basic tests ========" + +basic-msg-end: + @echo "======== Done with basic tests ========" + +unix-msg-start: + @echo "======== Starting Unix tests ========" + +unix-msg-end: + @echo "======== Done with Unix tests ========" + +extend-msg-start: + @echo "======== Starting gawk extension tests ========" + +extend-msg-end: + @echo "======== Done with gawk extension tests ========" + +machine-msg-start: + @echo "======== Starting machine-specific tests ========" + +machine-msg-end: + @echo "======== Done with machine-specific tests ========" + +charset-msg-start: + @echo "======== Starting tests that can vary based on character set or locale support ========" + +charset-msg-end: + @echo "======== Done with tests that can vary based on character set or locale support ========" + + +lc_num1: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + + +# This test is a PITA because increasingly, /tmp is getting +# mounted noexec. So, we'll test it locally. Sigh. +# +# More PITA; some systems have medium short limits on #! paths, +# so this can still fail +poundbang:: + @echo $@ + @sed "s;/tmp/gawk;`pwd`/$(AWKPROG);" < $(srcdir)/poundbang.awk > ./_pbd.awk + @chmod +x ./_pbd.awk + @if ./_pbd.awk $(srcdir)/poundbang.awk > _`basename $@` ; \ + then : ; \ + else \ + sed "s;/tmp/gawk;../$(AWKPROG);" < $(srcdir)/poundbang.awk > ./_pbd.awk ; \ + chmod +x ./_pbd.awk ; \ + LC_ALL=$${GAWKLOCALE:-C} LANG=$${GAWKLOCALE:-C} ./_pbd.awk $(srcdir)/poundbang.awk > _`basename $@`; \ + fi + @-$(CMP) $(srcdir)/poundbang.awk _`basename $@` && rm -f _`basename $@` _pbd.awk + +messages:: + @echo $@ + @$(AWK) -f $(srcdir)/messages.awk >out2 2>out3 + @-$(CMP) $(srcdir)/out1.ok out1 && $(CMP) $(srcdir)/out2.ok out2 && $(CMP) $(srcdir)/out3.ok out3 && rm -f out1 out2 out3 + +argarray:: + @echo $@ + @case $(srcdir) in \ + .) : ;; \ + *) cp $(srcdir)/argarray.in . ;; \ + esac + @TEST=test echo just a test | $(AWK) -f $(srcdir)/argarray.awk ./argarray.in - >_$@ + @case $(srcdir) in \ + .) : ;; \ + *) rm -f ./argarray.in ;; \ + esac + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +regtest:: + @echo 'Some of the output from regtest is very system specific, do not' + @echo 'be distressed if your output differs from that distributed.' + @echo 'Manual inspection is called for.' + AWK=$(AWKPROG) $(srcdir)/regtest.sh + +manyfiles:: + @echo manyfiles + @rm -rf junk + @mkdir junk + @$(AWK) 'BEGIN { for (i = 1; i <= 1030; i++) print i, i}' >_$@ + @$(AWK) -f $(srcdir)/manyfiles.awk _$@ _$@ + @wc -l junk/* | $(AWK) '$$1 != 2' | wc -l | sed "s/ *//g" > _$@ + @rm -rf junk + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +compare:: + @echo $@ + @$(AWK) -f $(srcdir)/compare.awk 0 1 $(srcdir)/compare.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +inftest:: + @echo $@ + @echo This test is very machine specific... + @$(AWK) -f $(srcdir)/inftest.awk | sed "s/inf/Inf/g" >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getline2:: + @echo $@ + @$(AWK) -f $(srcdir)/getline2.awk $(srcdir)/getline2.awk $(srcdir)/getline2.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +awkpath:: + @echo $@ + @AWKPATH="$(srcdir)$(PATH_SEPARATOR)$(srcdir)/lib" $(AWK) -f awkpath.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +argtest:: + @echo $@ + @$(AWK) -f $(srcdir)/argtest.awk -x -y abc >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +badargs:: + @echo $@ + @-$(AWK) -f 2>&1 | grep -v patchlevel >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nonl:: + @echo $@ + @-AWKPATH=$(srcdir) $(AWK) --lint -f nonl.awk /dev/null >_$@ 2>&1 + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +strftime:: + @echo This test could fail on slow machines or on a minute boundary, + @echo so if it does, double check the actual results: + @echo $@ + @GAWKLOCALE=C; export GAWKLOCALE; \ + TZ=GMT0; export TZ; \ + (LC_ALL=C date) | $(AWK) -v OUTPUT=_$@ -f $(srcdir)/strftime.awk + @-$(CMP) strftime.ok _$@ && rm -f _$@ strftime.ok || exit 0 + +litoct:: + @echo $@ + @echo ab | $(AWK) --traditional -f $(srcdir)/litoct.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +devfd:: + @echo $@ + @$(AWK) 1 /dev/fd/4 /dev/fd/5 4<$(srcdir)/devfd.in4 5<$(srcdir)/devfd.in5 >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fflush:: + @echo $@ + @$(srcdir)/fflush.sh >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +tweakfld:: + @echo $@ + @$(AWK) -f $(srcdir)/tweakfld.awk $(srcdir)/tweakfld.in >_$@ + @rm -f errors.cleanup + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mmap8k:: + @echo $@ + @$(AWK) '{ print }' $(srcdir)/mmap8k.in >_$@ + @-$(CMP) $(srcdir)/mmap8k.in _$@ && rm -f _$@ + +tradanch:: + @echo $@ + @$(AWK) --traditional -f $(srcdir)/tradanch.awk $(srcdir)/tradanch.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +# AIX /bin/sh exec's the last command in a list, therefore issue a ":" +# command so that pid.sh is fork'ed as a child before being exec'ed. +pid:: + @echo pid + @AWKPATH=$(srcdir) AWK=$(AWKPROG) $(SHELL) $(srcdir)/pid.sh $$$$ > _`basename $@` ; : + @-$(CMP) $(srcdir)/pid.ok _`basename $@` && rm -f _`basename $@` + +strftlng:: + @echo $@ + @TZ=UTC; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@ + @if $(CMP) $(srcdir)/strftlng.ok _$@ >/dev/null 2>&1 ; then : ; else \ + TZ=UTC0; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@ ; \ + fi + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nors:: + @echo $@ + @echo A B C D E | tr -d '\12\15' | $(AWK) '{ print $$NF }' - $(srcdir)/nors.in > _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fmtspcl.ok: fmtspcl.tok Makefile + @$(AWK) -v "sd=$(srcdir)" 'BEGIN {pnan = sprintf("%g",sqrt(-1)); nnan = sprintf("%g",-sqrt(-1)); pinf = sprintf("%g",-log(0)); ninf = sprintf("%g",log(0))} {sub(/positive_nan/,pnan); sub(/negative_nan/,nnan); sub(/positive_infinity/,pinf); sub(/negative_infinity/,ninf); sub(/fmtspcl/,(sd"/fmtspcl")); print}' < $(srcdir)/fmtspcl.tok > $@ 2>/dev/null + +fmtspcl: fmtspcl.ok + @echo fmtspcl + @$(AWK) -f $(srcdir)/fmtspcl.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $@.ok _$@ && rm -f _$@ + +reint:: + @echo $@ + @$(AWK) --re-interval -f $(srcdir)/reint.awk $(srcdir)/reint.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +pipeio1:: + @echo $@ + @$(AWK) -f $(srcdir)/pipeio1.awk >_$@ + @rm -f test1 test2 + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +pipeio2:: + @echo $@ + @$(AWK) -v SRCDIR=$(srcdir) -f $(srcdir)/pipeio2.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +clobber:: + @echo $@ + @$(AWK) -f $(srcdir)/clobber.awk >_$@ + @-$(CMP) $(srcdir)/clobber.ok seq && $(CMP) $(srcdir)/clobber.ok _$@ && rm -f _$@ + @rm -f seq + +arynocls:: + @echo $@ + @-AWKPATH=$(srcdir) $(AWK) -v INPUT=$(srcdir)/arynocls.in -f arynocls.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getlnbuf:: + @echo $@ + @-AWKPATH=$(srcdir) $(AWK) -f getlnbuf.awk $(srcdir)/getlnbuf.in > _$@ + @-AWKPATH=$(srcdir) $(AWK) -f gtlnbufv.awk $(srcdir)/getlnbuf.in > _2$@ + @-$(CMP) $(srcdir)/getlnbuf.ok _$@ && $(CMP) $(srcdir)/getlnbuf.ok _2$@ && rm -f _$@ _2$@ + +inetmesg:: + @echo These tests only work if your system supports the services + @echo "'discard'" at port 9 and "'daytimed'" at port 13. Check your + @echo file /etc/services and do "'netstat -a'". + +inetechu:: + @echo This test is for establishing UDP connections + @$(AWK) 'BEGIN {print "" |& "/inet/udp/0/127.0.0.1/9"}' + +inetecht:: + @echo This test is for establishing TCP connections + @$(AWK) 'BEGIN {print "" |& "/inet/tcp/0/127.0.0.1/9"}' + +inetdayu:: + @echo This test is for bidirectional UDP transmission + @$(AWK) 'BEGIN { print "" |& "/inet/udp/0/127.0.0.1/13"; \ + "/inet/udp/0/127.0.0.1/13" |& getline; print $0}' + +inetdayt:: + @echo This test is for bidirectional TCP transmission + @$(AWK) 'BEGIN { print "" |& "/inet/tcp/0/127.0.0.1/13"; \ + "/inet/tcp/0/127.0.0.1/13" |& getline; print $0}' + +redfilnm:: + @echo $@ + @$(AWK) -f $(srcdir)/redfilnm.awk srcdir=$(srcdir) $(srcdir)/redfilnm.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +leaddig:: + @echo $@ + @$(AWK) -v x=2E -f $(srcdir)/leaddig.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst3:: + @echo $@ + @$(AWK) --re-interval -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +space:: + @echo $@ + @$(AWK) -f ' ' $(srcdir)/space.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +printf0:: + @echo $@ + @$(AWK) --posix -f $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsnulbig:: + @echo $@ + @ : Suppose that block size for pipe is at most 128kB: + @$(AWK) 'BEGIN { for (i = 1; i <= 128*64+1; i++) print "abcdefgh123456\n" }' 2>&1 | \ + $(AWK) 'BEGIN { RS = ""; ORS = "\n\n" }; { print }' 2>&1 | \ + $(AWK) '/^[^a]/; END{ print NR }' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsnulbig2:: + @echo $@ + @$(AWK) 'BEGIN { ORS = ""; n = "\n"; for (i = 1; i <= 10; i++) n = (n n); \ + for (i = 1; i <= 128; i++) print n; print "abc\n" }' 2>&1 | \ + $(AWK) 'BEGIN { RS = ""; ORS = "\n\n" };{ print }' 2>&1 | \ + $(AWK) '/^[^a]/; END { print NR }' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +wideidx:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +wideidx2:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +widesub:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +widesub2:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +widesub3:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +widesub4:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ignrcas2:: + @echo $@ + @GAWKLOCALE=en_US ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +subamp:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +# This test makes sure gawk exits with a zero code. +# Thus, unconditionally generate the exit code. +exitval1:: + @echo $@ + @$(AWK) -f $(srcdir)/exitval1.awk >_$@ 2>&1; echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fsspcoln:: + @echo $@ + @$(AWK) -f $(srcdir)/$@.awk 'FS=[ :]+' $(srcdir)/$@.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsstart1:: + @echo $@ + @$(AWK) -f $(srcdir)/$@.awk $(srcdir)/rsstart1.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsstart2:: + @echo $@ + @$(AWK) -f $(srcdir)/$@.awk $(srcdir)/rsstart1.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsstart3:: + @echo $@ + @head $(srcdir)/rsstart1.in | $(AWK) -f $(srcdir)/rsstart2.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rtlen:: + @echo $@ + @$(srcdir)/$@.sh >_$@ || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rtlen01:: + @echo $@ + @$(srcdir)/$@.sh >_$@ || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rtlenmb:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ + $(srcdir)/rtlen.sh >_$@ || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/rtlen.ok _$@ && rm -f _$@ + +nondec2:: + @echo $@ + @$(AWK) --non-decimal-data -v a=0x1 -f $(srcdir)/$@.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nofile:: + @echo $@ + @$(AWK) '{}' no/such/file >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +binmode1:: + @echo $@ + @$(AWK) -v BINMODE=3 'BEGIN { print BINMODE }' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +subi18n:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; $(AWK) -f $(srcdir)/$@.awk > _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +concat4:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in > _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +devfd1:: + @echo $@ + @$(AWK) -f $(srcdir)/$@.awk 4< $(srcdir)/devfd.in1 5< $(srcdir)/devfd.in2 >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +# The program text is the '1' which will print each record. How compact can you get? +devfd2:: + @echo $@ + @$(AWK) 1 /dev/fd/4 /dev/fd/5 4< $(srcdir)/devfd.in1 5< $(srcdir)/devfd.in2 >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mixed1:: + @echo $@ + @$(AWK) -f /dev/null --source 'BEGIN {return junk}' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mtchi18n:: + @echo $@ + @GAWKLOCALE=ru_RU.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +reint2:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) --re-interval -f $@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +localenl:: + @echo $@ + @$(srcdir)/$@.sh >_$@ 2>/dev/null + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mbprintf1:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mbprintf2:: + @echo $@ + @GAWKLOCALE=ja_JP.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mbprintf3:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mbfw1:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst6:: + @echo $@ + @GAWKLOCALE=C ; $(AWK) -f $(srcdir)/$@.awk > _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mbstr1:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +printfbad2: printfbad2.ok + @echo $@ + @$(AWK) --lint -f $(srcdir)/$@.awk $(srcdir)/$@.in 2>&1 | sed 's;\$(srcdir)/;;g' >_$@ || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +beginfile1:: + @echo $@ + @AWKPATH=$(srcdir) $(AWK) -f $@.awk $(srcdir)/$@.awk . ./no/such/file Makefile >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +beginfile2: + @echo $@ + @-( cd $(srcdir) && LC_ALL=C AWK="$(abs_builddir)/$(AWKPROG)" $(srcdir)/$@.sh $(srcdir)/$@.in ) > _$@ 2>&1 + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +dumpvars:: + @echo $@ + @AWKPATH=$(srcdir) $(AWK) --dump-variables 1 < $(srcdir)/$@.in >/dev/null 2>&1 || echo EXIT CODE: $$? >>_$@ + @mv awkvars.out _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +profile1: + @echo $@ + @$(AWK) --profile=ap-$@.out -f $(srcdir)/xref.awk $(srcdir)/dtdgport.awk > _$@.out1 + @$(AWK) -f ap-$@.out $(srcdir)/dtdgport.awk > _$@.out2 ; rm ap-$@.out + @cmp _$@.out1 _$@.out2 && rm _$@.out[12] || echo EXIT CODE: $$? >>_$@ + +profile2: + @echo $@ + @$(PGAWK) --profile=ap-$@.out -v sortcmd=sort -f $(srcdir)/xref.awk $(srcdir)/dtdgport.awk > /dev/null + @sed 1,2d < ap-$@.out > _$@; rm ap-$@.out + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +profile3: + @echo $@ + @$(PGAWK) --profile=ap-$@.out -f $(srcdir)/$@.awk > /dev/null + @sed 1,2d < ap-$@.out > _$@; rm ap-$@.out + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +posix2008sub: + @echo $@ + @$(AWK) --posix -f $(srcdir)/$@.awk > _$@ 2>&1 + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +next: + @echo $@ + @-AWK="$(AWKPROG)" $(srcdir)/$@.sh > _$@ 2>&1 + @-LC_ALL=C $(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +exit: + @echo $@ + @-AWK="$(AWKPROG)" $(srcdir)/$@.sh > _$@ 2>&1 + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rri1:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +# Targets generated for other tests: +include Maketests + +$(srcdir)/Maketests: $(srcdir)/Makefile.am $(srcdir)/Gentests + files=`cd "$(srcdir)" && echo *.awk *.in`; \ + $(AWK) -f $(srcdir)/Gentests "$(srcdir)/Makefile.am" $$files > $(srcdir)/Maketests + +clean: + rm -fr _* core core.* fmtspcl.ok junk out1 out2 out3 strftime.ok test1 test2 seq *~ + +# An attempt to print something that can be grepped for in build logs +pass-fail: + @COUNT=`ls _* 2>/dev/null | wc -l` ; \ + if test $$COUNT = 0 ; \ + then echo ALL TESTS PASSED ; \ + else echo $$COUNT TESTS FAILED ; \ + fi + +# This target for my convenience to look at all the results +diffout: + for i in _* ; \ + do \ + if [ "$$i" != "_*" ]; then \ + echo ============== $$i ============= ; \ + if [ -r $${i#_}.ok ]; then \ + diff -c $${i#_}.ok $$i ; \ + else \ + diff -c $(srcdir)/$${i#_}.ok $$i ; \ + fi ; \ + fi ; \ + done | more + +# convenient way to scan valgrind results for errors +valgrind-scan: + @echo "Scanning valgrind log files for problems:" + @$(AWK) '\ + function show() {if (cmd) {printf "%s: %s\n",FILENAME,cmd; cmd = ""}; \ + printf "\t%s\n",$$0}; \ + {$$1 = ""}; \ + /Prog and args are:/ {incmd = 1; cmd = ""; next}; \ + incmd {if (NF == 1) incmd = 0; else {cmd = (cmd $$0); next}}; \ + /ERROR SUMMARY:/ && !/: 0 errors from 0 contexts/ {show()}; \ + /definitely lost:/ && !/: 0 bytes in 0 blocks/ {show()}; \ + /possibly lost:/ && !/: 0 bytes in 0 blocks/ {show()}; \ + / suppressed:/ && !/: 0 bytes in 0 blocks/ {show()}; \ + ' log.[0-9]* + +# This target is for testing with electric fence. +efence: + for i in $$(ls _* | sed 's;_\(.*\);\1;') ; \ + do \ + bad=$$(wc -l < _$$i) \ + ok=$$(wc -l < $$i.ok) ; \ + if (( $$bad == $$ok + 2 )) ; \ + then \ + rm _$$i ; \ + fi ; \ + done diff --git a/test/Makefile.in b/test/Makefile.in new file mode 100644 index 0000000..364d61d --- /dev/null +++ b/test/Makefile.in @@ -0,0 +1,3062 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# +# test/Makefile.am --- automake input file for gawk +# +# Copyright (C) 1988-2012 the Free Software Foundation, Inc. +# +# This file is part of GAWK, the GNU implementation of the +# AWK Programming Language. +# +# GAWK is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/Maketests ChangeLog +subdir = test +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/arch.m4 \ + $(top_srcdir)/m4/codeset.m4 $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \ + $(top_srcdir)/m4/intmax_t.m4 $(top_srcdir)/m4/inttypes_h.m4 \ + $(top_srcdir)/m4/isc-posix.m4 $(top_srcdir)/m4/lcmessage.m4 \ + $(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \ + $(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/libsigsegv.m4 \ + $(top_srcdir)/m4/longlong.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/m4/readline.m4 $(top_srcdir)/m4/socket.m4 \ + $(top_srcdir)/m4/stdint_h.m4 $(top_srcdir)/m4/uintmax_t.m4 \ + $(top_srcdir)/m4/ulonglong.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ + +# This business forces the locale to be C for running the tests, +# unless we override it to something else for testing. +# +# This can also be done in individual tests where we wish to +# check things specifically not in the C locale. +AWK = LC_ALL=$${GAWKLOCALE:-C} LANG=$${GAWKLOCALE:-C} $(AWKPROG) +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ +GMSGFMT = @GMSGFMT@ +GMSGFMT_015 = @GMSGFMT_015@ +GREP = @GREP@ +HAVE_LIBSIGSEGV = @HAVE_LIBSIGSEGV@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INTLLIBS = @INTLLIBS@ +INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +LDFLAGS = @LDFLAGS@ +LIBICONV = @LIBICONV@ +LIBINTL = @LIBINTL@ +LIBOBJS = @LIBOBJS@ +LIBREADLINE = @LIBREADLINE@ +LIBS = @LIBS@ +LIBSIGSEGV = @LIBSIGSEGV@ +LIBSIGSEGV_PREFIX = @LIBSIGSEGV_PREFIX@ +LN_S = @LN_S@ +LTLIBICONV = @LTLIBICONV@ +LTLIBINTL = @LTLIBINTL@ +LTLIBOBJS = @LTLIBOBJS@ +LTLIBSIGSEGV = @LTLIBSIGSEGV@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +MSGFMT = @MSGFMT@ +MSGFMT_015 = @MSGFMT_015@ +MSGMERGE = @MSGMERGE@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +POSUB = @POSUB@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SOCKET_LIBS = @SOCKET_LIBS@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +XGETTEXT_015 = @XGETTEXT_015@ +XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ +YACC = @YACC@ +YFLAGS = @YFLAGS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +EXTRA_DIST = \ + reg \ + lib \ + ChangeLog.0 \ + Gentests \ + Gentests.vms \ + Maketests \ + README \ + aadelete1.awk \ + aadelete1.ok \ + aadelete2.awk \ + aadelete2.ok \ + aarray1.awk \ + aarray1.ok \ + aasort.awk \ + aasort.ok \ + aasorti.awk \ + aasorti.ok \ + addcomma.awk \ + addcomma.in \ + addcomma.ok \ + anchgsub.awk \ + anchgsub.in \ + anchgsub.ok \ + arraysort.awk \ + arraysort.ok \ + argarray.awk \ + argarray.in \ + argarray.ok \ + argtest.awk \ + argtest.ok \ + arrayparm.awk \ + arrayparm.ok \ + arrayprm2.awk \ + arrayprm2.ok \ + arrayprm3.awk \ + arrayprm3.ok \ + arrayref.awk \ + arrayref.ok \ + arrymem1.awk \ + arrymem1.ok \ + arryref2.awk \ + arryref2.ok \ + arryref3.awk \ + arryref3.ok \ + arryref4.awk \ + arryref4.ok \ + arryref5.awk \ + arryref5.ok \ + arynasty.awk \ + arynasty.ok \ + arynocls.awk \ + arynocls.in \ + arynocls.ok \ + aryprm1.awk \ + aryprm1.ok \ + aryprm2.awk \ + aryprm2.ok \ + aryprm3.awk \ + aryprm3.ok \ + aryprm4.awk \ + aryprm4.ok \ + aryprm5.awk \ + aryprm5.ok \ + aryprm6.awk \ + aryprm6.ok \ + aryprm7.awk \ + aryprm7.ok \ + aryprm8.awk \ + aryprm8.ok \ + arysubnm.awk \ + arysubnm.ok \ + asgext.awk \ + asgext.in \ + asgext.ok \ + asort.awk \ + asort.ok \ + asorti.awk \ + asorti.ok \ + awkpath.ok \ + back89.awk \ + back89.in \ + back89.ok \ + backgsub.awk \ + backgsub.in \ + backgsub.ok \ + backw.awk \ + backw.in \ + backw.ok \ + badargs.ok \ + beginfile1.awk \ + beginfile1.ok \ + beginfile2.in \ + beginfile2.ok \ + beginfile2.sh \ + binmode1.ok \ + childin.awk \ + childin.in \ + childin.ok \ + clobber.awk \ + clobber.ok \ + clos1way.awk \ + clos1way.ok \ + closebad.awk \ + closebad.ok \ + clsflnam.awk \ + clsflnam.in \ + clsflnam.ok \ + compare.awk \ + compare.in \ + compare.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 \ + convfmt.awk \ + convfmt.ok \ + datanonl.awk \ + datanonl.in \ + datanonl.ok \ + defref.awk \ + defref.ok \ + delargv.awk \ + delargv.ok \ + delarprm.awk \ + delarprm.ok \ + delarpm2.awk \ + delarpm2.ok \ + delfunc.awk \ + delfunc.ok \ + delsub.awk \ + delsub.ok \ + devfd.in1 \ + devfd.in2 \ + devfd.in4 \ + devfd.in5 \ + devfd.ok \ + devfd1.awk \ + devfd1.ok \ + devfd2.ok \ + dfastress.awk \ + dfastress.ok \ + double1.awk \ + double1.ok \ + double2.awk \ + double2.ok \ + dtdgport.awk \ + dumpvars.in \ + dumpvars.ok \ + dynlj.awk \ + dynlj.ok \ + eofsplit.awk \ + eofsplit.ok \ + exit.ok \ + exit.sh \ + exitval1.awk \ + exitval1.ok \ + exitval2.awk \ + exitval2.ok \ + exitval2.w32 \ + fcall_exit.awk \ + fcall_exit.ok \ + fcall_exit2.awk \ + fcall_exit2.ok \ + fcall_exit2.in \ + fflush.ok \ + fflush.sh \ + fieldwdth.awk \ + fieldwdth.in \ + fieldwdth.ok \ + fldchg.awk \ + fldchg.in \ + fldchg.ok \ + fldchgnf.awk \ + fldchgnf.in \ + fldchgnf.ok \ + fmtspcl.awk \ + fmtspcl.tok \ + fmttest.awk \ + fmttest.ok \ + fnamedat.awk \ + fnamedat.in \ + fnamedat.ok \ + fnarray.awk \ + fnarray.ok \ + fnarray2.awk \ + fnarray2.ok \ + fnarydel.awk \ + fnarydel.ok \ + fnaryscl.awk \ + fnaryscl.ok \ + fnasgnm.awk \ + fnasgnm.in \ + fnasgnm.ok \ + fnmisc.awk \ + fnmisc.ok \ + fnparydl.awk \ + fnparydl.ok \ + fpat1.awk \ + fpat1.in \ + fpat1.ok \ + fpat2.awk \ + fpat2.ok \ + fpat3.awk \ + fpat3.in \ + fpat3.ok \ + fpatnull.awk \ + fpatnull.in \ + fpatnull.ok \ + fordel.awk \ + fordel.ok \ + forref.awk \ + forref.ok \ + forsimp.awk \ + forsimp.ok \ + fsbs.awk \ + fsbs.in \ + fsbs.ok \ + fsfwfs.awk \ + fsfwfs.in \ + fsfwfs.ok \ + fsrs.awk \ + fsrs.in \ + fsrs.ok \ + fsspcoln.awk \ + fsspcoln.in \ + fsspcoln.ok \ + fstabplus.awk \ + fstabplus.in \ + fstabplus.ok \ + funlen.awk \ + funlen.in \ + funlen.ok \ + funsemnl.awk \ + funsemnl.ok \ + funsmnam.awk \ + funsmnam.ok \ + funstack.awk \ + funstack.in \ + funstack.ok \ + fwtest.awk \ + fwtest.in \ + fwtest.ok \ + fwtest2.awk \ + fwtest2.in \ + fwtest2.ok \ + fwtest3.awk \ + fwtest3.in \ + fwtest3.ok \ + gensub.awk \ + gensub.in \ + gensub.ok \ + gensub2.awk \ + gensub2.ok \ + getline.awk \ + getline.in \ + getline.ok \ + getline2.awk \ + getline2.ok \ + getline3.awk \ + getline3.ok \ + getline4.awk \ + getline4.in \ + getline4.ok \ + getlnbuf.awk \ + getlnbuf.in \ + getlnbuf.ok \ + getlndir.awk \ + getlndir.ok \ + getlnhd.awk \ + getlnhd.ok \ + getnr2tb.awk \ + getnr2tb.in \ + getnr2tb.ok \ + getnr2tm.awk \ + getnr2tm.in \ + getnr2tm.ok \ + gnuops2.awk \ + gnuops2.ok \ + gnuops3.awk \ + gnuops3.ok \ + gnureops.awk \ + gnureops.ok \ + gsubasgn.awk \ + gsubasgn.ok \ + gsubtest.awk \ + gsubtest.ok \ + gsubtst2.awk \ + gsubtst2.ok \ + gsubtst3.awk \ + gsubtst3.in \ + gsubtst3.ok \ + gsubtst4.awk \ + gsubtst4.ok \ + gsubtst5.awk \ + gsubtst5.in \ + gsubtst5.ok \ + gsubtst6.awk \ + gsubtst6.ok \ + gsubtst7.awk \ + gsubtst7.in \ + gsubtst7.ok \ + gsubtst8.awk \ + gsubtst8.in \ + gsubtst8.ok \ + gtlnbufv.awk \ + hex.awk \ + hex.ok \ + hsprint.awk \ + hsprint.ok \ + icasefs.awk \ + icasefs.ok \ + icasers.awk \ + icasers.in \ + icasers.ok \ + igncdym.awk \ + igncdym.in \ + igncdym.ok \ + igncfs.awk \ + igncfs.in \ + igncfs.ok \ + ignrcase.awk \ + ignrcase.in \ + ignrcase.ok \ + ignrcas2.awk \ + ignrcas2.ok \ + indirectcall.awk \ + indirectcall.in \ + indirectcall.ok \ + inftest.awk \ + inftest.ok \ + inputred.awk \ + inputred.ok \ + intest.awk \ + intest.ok \ + intformat.awk \ + intformat.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 \ + lint.awk \ + lint.ok \ + lintold.awk \ + lintold.in \ + lintold.ok \ + lintwarn.awk \ + lintwarn.ok \ + litoct.awk \ + litoct.ok \ + localenl.ok \ + localenl.sh \ + longdbl.awk \ + longdbl.in \ + longdbl.ok \ + longsub.awk \ + longsub.in \ + longsub.ok \ + longwrds.awk \ + longwrds.ok \ + longwrds.in \ + manglprm.awk \ + manglprm.in \ + manglprm.ok \ + manyfiles.awk \ + manyfiles.ok \ + match1.awk \ + match1.ok \ + match2.awk \ + match2.ok \ + match3.awk \ + match3.in \ + match3.ok \ + math.awk \ + math.ok \ + mbfw1.awk \ + mbfw1.in \ + mbfw1.ok \ + mbprintf1.awk \ + mbprintf1.in \ + mbprintf1.ok \ + mbprintf2.awk \ + mbprintf2.ok \ + mbprintf3.awk \ + mbprintf3.in \ + mbprintf3.ok \ + mbstr1.awk \ + mbstr1.ok \ + membug1.awk \ + membug1.in \ + membug1.ok \ + messages.awk \ + minusstr.awk \ + minusstr.ok \ + mixed1.ok \ + mmap8k.in \ + mtchi18n.awk \ + mtchi18n.in \ + mtchi18n.ok \ + nasty.awk \ + nasty.ok \ + nasty2.awk \ + nasty2.ok \ + nastyparm.awk \ + nastyparm.ok \ + negexp.awk \ + negexp.ok \ + negrange.awk \ + negrange.ok \ + nested.awk \ + nested.in \ + nested.ok \ + next.ok \ + next.sh \ + nfldstr.awk \ + nfldstr.in \ + nfldstr.ok \ + nfneg.awk \ + nfneg.ok \ + nfset.awk \ + nfset.in \ + nfset.ok \ + nlfldsep.awk \ + nlfldsep.in \ + nlfldsep.ok \ + nlinstr.awk \ + nlinstr.in \ + nlinstr.ok \ + nlstrina.awk \ + nlstrina.ok \ + noeffect.awk \ + noeffect.ok \ + nofile.ok \ + nofmtch.awk \ + nofmtch.ok \ + noloop1.awk \ + noloop1.in \ + noloop1.ok \ + noloop2.awk \ + noloop2.in \ + noloop2.ok \ + nondec.awk \ + nondec.ok \ + nondec2.awk \ + nondec2.ok \ + nonl.awk \ + nonl.ok \ + noparms.awk \ + noparms.ok \ + nors.in \ + nors.ok \ + nulrsend.awk \ + nulrsend.in \ + nulrsend.ok \ + numindex.awk \ + numindex.in \ + numindex.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 \ + onlynl.awk \ + onlynl.in \ + onlynl.ok \ + opasnidx.awk \ + opasnidx.ok \ + opasnslf.awk \ + opasnslf.ok \ + out1.ok \ + out2.ok \ + out3.ok \ + paramdup.awk \ + paramdup.ok \ + paramres.awk \ + paramres.ok \ + paramtyp.awk \ + paramtyp.ok \ + parse1.awk \ + parse1.in \ + parse1.ok \ + parsefld.awk \ + parsefld.in \ + parsefld.ok \ + parseme.awk \ + parseme.ok \ + patsplit.awk \ + patsplit.ok \ + pcntplus.awk \ + pcntplus.ok \ + pid.awk \ + pid.ok \ + pid.sh \ + pipeio1.awk \ + pipeio1.ok \ + pipeio2.awk \ + pipeio2.in \ + pipeio2.ok \ + posix.awk \ + posix.in \ + posix.ok \ + posix2008sub.awk \ + posix2008sub.ok \ + poundbang.awk \ + prdupval.awk \ + prdupval.in \ + prdupval.ok \ + profile2.ok \ + profile3.awk \ + profile3.ok \ + prec.awk \ + prec.ok \ + printf0.awk \ + printf0.ok \ + printf1.awk \ + printf1.ok \ + printfbad1.awk \ + printfbad1.ok \ + printfbad2.awk \ + printfbad2.in \ + printfbad2.ok \ + printfbad3.awk \ + printfbad3.ok \ + printfloat.awk \ + printlang.awk \ + prmarscl.awk \ + prmarscl.ok \ + prmreuse.awk \ + prmreuse.ok \ + procinfs.awk \ + procinfs.ok \ + prt1eval.awk \ + prt1eval.ok \ + prtoeval.awk \ + prtoeval.ok \ + pty1.awk \ + pty1.ok \ + rand.awk \ + rand.ok \ + range1.awk \ + range1.in \ + range1.ok \ + rebt8b1.awk \ + rebt8b1.ok \ + rebt8b2.awk \ + rebt8b2.ok \ + redfilnm.awk \ + redfilnm.in \ + redfilnm.ok \ + regeq.awk \ + regeq.in \ + regeq.ok \ + regrange.awk \ + regrange.ok \ + regtest.sh \ + regx8bit.awk \ + regx8bit.ok \ + rebuf.awk \ + rebuf.in \ + rebuf.ok \ + reindops.awk \ + reindops.in \ + reindops.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 \ + rsnulbig.ok \ + rsnulbig2.ok \ + rsstart1.awk \ + rsstart1.in \ + rsstart1.ok \ + rsstart2.awk \ + rsstart2.ok \ + rsstart3.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 \ + rtlen.ok \ + rtlen.sh \ + rtlen01.ok \ + rtlen01.sh \ + scalar.awk \ + scalar.ok \ + sclforin.awk \ + sclforin.ok \ + sclifin.awk \ + sclifin.ok \ + shadow.awk \ + shadow.ok \ + sort1.awk \ + sort1.ok \ + sortempty.awk \ + sortempty.ok \ + sortfor.awk \ + sortfor.in \ + sortfor.ok \ + sortu.awk \ + sortu.ok \ + space.ok \ + splitarg4.awk \ + splitarg4.in \ + splitarg4.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 \ + strtod.awk \ + strtod.in \ + strtod.ok \ + strnum1.awk \ + strnum1.ok \ + strtonum.awk \ + strtonum.ok \ + strftime.awk \ + strftlng.awk \ + strftlng.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 \ + switch2.awk \ + switch2.ok \ + synerr1.awk \ + synerr1.ok \ + synerr2.awk \ + synerr2.ok \ + tradanch.awk \ + tradanch.in \ + tradanch.ok \ + tweakfld.awk \ + tweakfld.in \ + tweakfld.ok \ + uninit2.awk \ + uninit2.ok \ + uninit3.awk \ + uninit3.ok \ + uninit4.awk \ + uninit4.ok \ + uninit5.awk \ + uninit5.ok \ + uninitialized.awk \ + uninitialized.ok \ + unterm.awk \ + unterm.ok \ + uparrfs.awk \ + uparrfs.in \ + uparrfs.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 \ + widesub4.awk \ + widesub4.ok \ + wjposer1.awk \ + wjposer1.in \ + wjposer1.ok \ + xref.awk \ + xref.original \ + zero2.awk \ + zero2.ok \ + zeroe0.awk \ + zeroe0.ok \ + zeroflag.awk \ + zeroflag.ok + +TESTS_WE_ARE_NOT_DOING_YET_FIXME_ONE_DAY = longdbl + +# Get rid of core files when cleaning and generated .ok file +CLEANFILES = core core.* fmtspcl.ok + +# try to keep these sorted. each letter starts a new line +BASIC_TESTS = \ + addcomma anchgsub argarray arrayparm arrayprm2 arrayprm3 \ + arrayref arrymem1 arryref2 arryref3 arryref4 arryref5 arynasty \ + arynocls aryprm1 aryprm2 aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 \ + aryprm8 arysubnm asgext awkpath \ + back89 backgsub \ + childin clobber closebad clsflnam compare compare2 concat1 concat2 \ + concat3 concat4 convfmt \ + datanonl defref delargv delarpm2 delarprm delfunc dfastress dynlj \ + eofsplit exitval1 exitval2 \ + fcall_exit fcall_exit2 fldchg fldchgnf fnamedat fnarray fnarray2 \ + fnaryscl fnasgnm fnmisc fordel forref forsimp fsbs fsrs fsspcoln \ + fstabplus funsemnl funsmnam funstack \ + getline getline2 getline3 getline4 getlnbuf getnr2tb getnr2tm \ + gsubasgn gsubtest gsubtst2 gsubtst3 gsubtst4 gsubtst5 gsubtst6 \ + gsubtst7 gsubtst8 \ + hex hsprint \ + inputred intest intprec iobug1 \ + leaddig leadnl litoct longsub longwrds \ + manglprm math membug1 messages minusstr mmap8k mtchi18n \ + nasty nasty2 negexp negrange nested nfldstr nfneg nfset nlfldsep \ + nlinstr nlstrina noeffect nofile nofmtch noloop1 noloop2 nonl \ + noparms nors nulrsend numindex numsubstr \ + octsub ofmt ofmta ofmtbig ofmtfidl ofmts onlynl opasnidx opasnslf \ + paramdup paramres paramtyp parse1 parsefld parseme pcntplus \ + posix2008sub prdupval prec printf0 printf1 prmarscl prmreuse \ + prt1eval prtoeval \ + rand range1 rebt8b1 redfilnm regeq regrange reindops reparse \ + resplit rri1 rs rsnul1nl rsnulbig rsnulbig2 rstest1 rstest2 \ + rstest3 rstest4 rstest5 rswhite \ + scalar sclforin sclifin sortempty splitargv splitarr splitdef \ + splitvar splitwht strcat1 strnum1 strtod subamp subi18n \ + subsepnm subslash substr swaplns synerr1 synerr2 tradanch tweakfld \ + uninit2 uninit3 uninit4 uninit5 uninitialized unterm uparrfs \ + wideidx wideidx2 widesub widesub2 widesub3 widesub4 wjposer1 \ + zero2 zeroe0 zeroflag + +UNIX_TESTS = \ + fflush getlnhd localenl pid pipeio1 pipeio2 poundbang rtlen rtlen01 \ + space strftlng + +GAWK_EXT_TESTS = \ + aadelete1 aadelete2 aarray1 aasort aasorti argtest arraysort \ + backw badargs beginfile1 beginfile2 binmode1 \ + clos1way delsub devfd devfd1 devfd2 dumpvars exit \ + fieldwdth fpat1 fpat2 fpat3 fpatnull fsfwfs funlen \ + fwtest fwtest2 fwtest3 \ + gensub gensub2 getlndir gnuops2 gnuops3 gnureops \ + icasefs icasers igncdym igncfs ignrcas2 ignrcase indirectcall \ + lint lintold lintwarn \ + manyfiles match1 match2 match3 mbstr1 \ + nastyparm next nondec nondec2 \ + patsplit posix printfbad1 printfbad2 printfbad3 procinfs \ + profile1 profile2 profile3 pty1 \ + rebuf regx8bit reint reint2 rsstart1 \ + rsstart2 rsstart3 rstest6 shadow sortfor sortu splitarg4 strftime \ + strtonum switch2 + +EXTRA_TESTS = inftest regtest +INET_TESTS = inetdayu inetdayt inetechu inetecht +MACHINE_TESTS = double1 double2 fmtspcl intformat +LOCALE_CHARSET_TESTS = \ + asort asorti fmttest fnarydel fnparydl lc_num1 mbfw1 \ + mbprintf1 mbprintf2 mbprintf3 rebt8b2 rtlenmb sort1 sprintfc + + +# List of the tests which should be run with --lint option: +NEED_LINT = \ + defref fmtspcl lintwarn noeffect nofmtch shadow \ + uninit2 uninit3 uninit4 uninit5 uninitialized + + +# List of the tests which should be run with --lint-old option: +NEED_LINT_OLD = lintold + +# List of the tests which fail with EXIT CODE 1 +FAIL_CODE1 = \ + fnarray2 fnmisc gsubasgn mixed1 noparms paramdup synerr1 synerr2 unterm + + +# List of the files that appear in manual tests or are for reserve testing: +GENTESTS_UNUSED = Makefile.in gtlnbufv.awk printfloat.awk +CMP = cmp +AWKPROG = ../gawk$(EXEEXT) +PGAWKPROG = ../pgawk$(EXEEXT) +PGAWK = LC_ALL=$${GAWKLOCALE:-C} LANG=$${GAWKLOCALE:-C} $(PGAWKPROG) +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/Maketests $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu test/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean-am: clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am + + +# Message stuff is to make it a little easier to follow. +# Make the pass-fail last and dependent on others to avoid +# spurious errors if `make -j' in effect. +check: msg \ + printlang \ + basic-msg-start basic basic-msg-end \ + unix-msg-start unix-tests unix-msg-end \ + extend-msg-start gawk-extensions extend-msg-end \ + machine-msg-start machine-tests machine-msg-end \ + charset-msg-start charset-tests charset-msg-end + @$(MAKE) pass-fail + +basic: $(BASIC_TESTS) + +unix-tests: $(UNIX_TESTS) + +gawk-extensions: $(GAWK_EXT_TESTS) + +charset-tests: $(LOCALE_CHARSET_TESTS) + +extra: $(EXTRA_TESTS) inet + +inet: inetmesg $(INET_TESTS) + +machine-tests: $(MACHINE_TESTS) + +msg:: + @echo '' + @echo 'Any output from "cmp" is bad news, although some differences' + @echo 'in floating point values are probably benign -- in particular,' + @echo 'some systems may omit a leading zero and the floating point' + @echo 'precision may lead to slightly different output in a few cases.' + +printlang:: + @$(AWK) -f $(srcdir)/printlang.awk + +basic-msg-start: + @echo "======== Starting basic tests ========" + +basic-msg-end: + @echo "======== Done with basic tests ========" + +unix-msg-start: + @echo "======== Starting Unix tests ========" + +unix-msg-end: + @echo "======== Done with Unix tests ========" + +extend-msg-start: + @echo "======== Starting gawk extension tests ========" + +extend-msg-end: + @echo "======== Done with gawk extension tests ========" + +machine-msg-start: + @echo "======== Starting machine-specific tests ========" + +machine-msg-end: + @echo "======== Done with machine-specific tests ========" + +charset-msg-start: + @echo "======== Starting tests that can vary based on character set or locale support ========" + +charset-msg-end: + @echo "======== Done with tests that can vary based on character set or locale support ========" + +lc_num1: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +# This test is a PITA because increasingly, /tmp is getting +# mounted noexec. So, we'll test it locally. Sigh. +# +# More PITA; some systems have medium short limits on #! paths, +# so this can still fail +poundbang:: + @echo $@ + @sed "s;/tmp/gawk;`pwd`/$(AWKPROG);" < $(srcdir)/poundbang.awk > ./_pbd.awk + @chmod +x ./_pbd.awk + @if ./_pbd.awk $(srcdir)/poundbang.awk > _`basename $@` ; \ + then : ; \ + else \ + sed "s;/tmp/gawk;../$(AWKPROG);" < $(srcdir)/poundbang.awk > ./_pbd.awk ; \ + chmod +x ./_pbd.awk ; \ + LC_ALL=$${GAWKLOCALE:-C} LANG=$${GAWKLOCALE:-C} ./_pbd.awk $(srcdir)/poundbang.awk > _`basename $@`; \ + fi + @-$(CMP) $(srcdir)/poundbang.awk _`basename $@` && rm -f _`basename $@` _pbd.awk + +messages:: + @echo $@ + @$(AWK) -f $(srcdir)/messages.awk >out2 2>out3 + @-$(CMP) $(srcdir)/out1.ok out1 && $(CMP) $(srcdir)/out2.ok out2 && $(CMP) $(srcdir)/out3.ok out3 && rm -f out1 out2 out3 + +argarray:: + @echo $@ + @case $(srcdir) in \ + .) : ;; \ + *) cp $(srcdir)/argarray.in . ;; \ + esac + @TEST=test echo just a test | $(AWK) -f $(srcdir)/argarray.awk ./argarray.in - >_$@ + @case $(srcdir) in \ + .) : ;; \ + *) rm -f ./argarray.in ;; \ + esac + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +regtest:: + @echo 'Some of the output from regtest is very system specific, do not' + @echo 'be distressed if your output differs from that distributed.' + @echo 'Manual inspection is called for.' + AWK=$(AWKPROG) $(srcdir)/regtest.sh + +manyfiles:: + @echo manyfiles + @rm -rf junk + @mkdir junk + @$(AWK) 'BEGIN { for (i = 1; i <= 1030; i++) print i, i}' >_$@ + @$(AWK) -f $(srcdir)/manyfiles.awk _$@ _$@ + @wc -l junk/* | $(AWK) '$$1 != 2' | wc -l | sed "s/ *//g" > _$@ + @rm -rf junk + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +compare:: + @echo $@ + @$(AWK) -f $(srcdir)/compare.awk 0 1 $(srcdir)/compare.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +inftest:: + @echo $@ + @echo This test is very machine specific... + @$(AWK) -f $(srcdir)/inftest.awk | sed "s/inf/Inf/g" >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getline2:: + @echo $@ + @$(AWK) -f $(srcdir)/getline2.awk $(srcdir)/getline2.awk $(srcdir)/getline2.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +awkpath:: + @echo $@ + @AWKPATH="$(srcdir)$(PATH_SEPARATOR)$(srcdir)/lib" $(AWK) -f awkpath.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +argtest:: + @echo $@ + @$(AWK) -f $(srcdir)/argtest.awk -x -y abc >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +badargs:: + @echo $@ + @-$(AWK) -f 2>&1 | grep -v patchlevel >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nonl:: + @echo $@ + @-AWKPATH=$(srcdir) $(AWK) --lint -f nonl.awk /dev/null >_$@ 2>&1 + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +strftime:: + @echo This test could fail on slow machines or on a minute boundary, + @echo so if it does, double check the actual results: + @echo $@ + @GAWKLOCALE=C; export GAWKLOCALE; \ + TZ=GMT0; export TZ; \ + (LC_ALL=C date) | $(AWK) -v OUTPUT=_$@ -f $(srcdir)/strftime.awk + @-$(CMP) strftime.ok _$@ && rm -f _$@ strftime.ok || exit 0 + +litoct:: + @echo $@ + @echo ab | $(AWK) --traditional -f $(srcdir)/litoct.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +devfd:: + @echo $@ + @$(AWK) 1 /dev/fd/4 /dev/fd/5 4<$(srcdir)/devfd.in4 5<$(srcdir)/devfd.in5 >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fflush:: + @echo $@ + @$(srcdir)/fflush.sh >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +tweakfld:: + @echo $@ + @$(AWK) -f $(srcdir)/tweakfld.awk $(srcdir)/tweakfld.in >_$@ + @rm -f errors.cleanup + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mmap8k:: + @echo $@ + @$(AWK) '{ print }' $(srcdir)/mmap8k.in >_$@ + @-$(CMP) $(srcdir)/mmap8k.in _$@ && rm -f _$@ + +tradanch:: + @echo $@ + @$(AWK) --traditional -f $(srcdir)/tradanch.awk $(srcdir)/tradanch.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +# AIX /bin/sh exec's the last command in a list, therefore issue a ":" +# command so that pid.sh is fork'ed as a child before being exec'ed. +pid:: + @echo pid + @AWKPATH=$(srcdir) AWK=$(AWKPROG) $(SHELL) $(srcdir)/pid.sh $$$$ > _`basename $@` ; : + @-$(CMP) $(srcdir)/pid.ok _`basename $@` && rm -f _`basename $@` + +strftlng:: + @echo $@ + @TZ=UTC; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@ + @if $(CMP) $(srcdir)/strftlng.ok _$@ >/dev/null 2>&1 ; then : ; else \ + TZ=UTC0; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@ ; \ + fi + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nors:: + @echo $@ + @echo A B C D E | tr -d '\12\15' | $(AWK) '{ print $$NF }' - $(srcdir)/nors.in > _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fmtspcl.ok: fmtspcl.tok Makefile + @$(AWK) -v "sd=$(srcdir)" 'BEGIN {pnan = sprintf("%g",sqrt(-1)); nnan = sprintf("%g",-sqrt(-1)); pinf = sprintf("%g",-log(0)); ninf = sprintf("%g",log(0))} {sub(/positive_nan/,pnan); sub(/negative_nan/,nnan); sub(/positive_infinity/,pinf); sub(/negative_infinity/,ninf); sub(/fmtspcl/,(sd"/fmtspcl")); print}' < $(srcdir)/fmtspcl.tok > $@ 2>/dev/null + +fmtspcl: fmtspcl.ok + @echo fmtspcl + @$(AWK) -f $(srcdir)/fmtspcl.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $@.ok _$@ && rm -f _$@ + +reint:: + @echo $@ + @$(AWK) --re-interval -f $(srcdir)/reint.awk $(srcdir)/reint.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +pipeio1:: + @echo $@ + @$(AWK) -f $(srcdir)/pipeio1.awk >_$@ + @rm -f test1 test2 + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +pipeio2:: + @echo $@ + @$(AWK) -v SRCDIR=$(srcdir) -f $(srcdir)/pipeio2.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +clobber:: + @echo $@ + @$(AWK) -f $(srcdir)/clobber.awk >_$@ + @-$(CMP) $(srcdir)/clobber.ok seq && $(CMP) $(srcdir)/clobber.ok _$@ && rm -f _$@ + @rm -f seq + +arynocls:: + @echo $@ + @-AWKPATH=$(srcdir) $(AWK) -v INPUT=$(srcdir)/arynocls.in -f arynocls.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getlnbuf:: + @echo $@ + @-AWKPATH=$(srcdir) $(AWK) -f getlnbuf.awk $(srcdir)/getlnbuf.in > _$@ + @-AWKPATH=$(srcdir) $(AWK) -f gtlnbufv.awk $(srcdir)/getlnbuf.in > _2$@ + @-$(CMP) $(srcdir)/getlnbuf.ok _$@ && $(CMP) $(srcdir)/getlnbuf.ok _2$@ && rm -f _$@ _2$@ + +inetmesg:: + @echo These tests only work if your system supports the services + @echo "'discard'" at port 9 and "'daytimed'" at port 13. Check your + @echo file /etc/services and do "'netstat -a'". + +inetechu:: + @echo This test is for establishing UDP connections + @$(AWK) 'BEGIN {print "" |& "/inet/udp/0/127.0.0.1/9"}' + +inetecht:: + @echo This test is for establishing TCP connections + @$(AWK) 'BEGIN {print "" |& "/inet/tcp/0/127.0.0.1/9"}' + +inetdayu:: + @echo This test is for bidirectional UDP transmission + @$(AWK) 'BEGIN { print "" |& "/inet/udp/0/127.0.0.1/13"; \ + "/inet/udp/0/127.0.0.1/13" |& getline; print $0}' + +inetdayt:: + @echo This test is for bidirectional TCP transmission + @$(AWK) 'BEGIN { print "" |& "/inet/tcp/0/127.0.0.1/13"; \ + "/inet/tcp/0/127.0.0.1/13" |& getline; print $0}' + +redfilnm:: + @echo $@ + @$(AWK) -f $(srcdir)/redfilnm.awk srcdir=$(srcdir) $(srcdir)/redfilnm.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +leaddig:: + @echo $@ + @$(AWK) -v x=2E -f $(srcdir)/leaddig.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst3:: + @echo $@ + @$(AWK) --re-interval -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +space:: + @echo $@ + @$(AWK) -f ' ' $(srcdir)/space.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +printf0:: + @echo $@ + @$(AWK) --posix -f $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsnulbig:: + @echo $@ + @ : Suppose that block size for pipe is at most 128kB: + @$(AWK) 'BEGIN { for (i = 1; i <= 128*64+1; i++) print "abcdefgh123456\n" }' 2>&1 | \ + $(AWK) 'BEGIN { RS = ""; ORS = "\n\n" }; { print }' 2>&1 | \ + $(AWK) '/^[^a]/; END{ print NR }' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsnulbig2:: + @echo $@ + @$(AWK) 'BEGIN { ORS = ""; n = "\n"; for (i = 1; i <= 10; i++) n = (n n); \ + for (i = 1; i <= 128; i++) print n; print "abc\n" }' 2>&1 | \ + $(AWK) 'BEGIN { RS = ""; ORS = "\n\n" };{ print }' 2>&1 | \ + $(AWK) '/^[^a]/; END { print NR }' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +wideidx:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +wideidx2:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +widesub:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +widesub2:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +widesub3:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +widesub4:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ignrcas2:: + @echo $@ + @GAWKLOCALE=en_US ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +subamp:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +# This test makes sure gawk exits with a zero code. +# Thus, unconditionally generate the exit code. +exitval1:: + @echo $@ + @$(AWK) -f $(srcdir)/exitval1.awk >_$@ 2>&1; echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fsspcoln:: + @echo $@ + @$(AWK) -f $(srcdir)/$@.awk 'FS=[ :]+' $(srcdir)/$@.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsstart1:: + @echo $@ + @$(AWK) -f $(srcdir)/$@.awk $(srcdir)/rsstart1.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsstart2:: + @echo $@ + @$(AWK) -f $(srcdir)/$@.awk $(srcdir)/rsstart1.in >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsstart3:: + @echo $@ + @head $(srcdir)/rsstart1.in | $(AWK) -f $(srcdir)/rsstart2.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rtlen:: + @echo $@ + @$(srcdir)/$@.sh >_$@ || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rtlen01:: + @echo $@ + @$(srcdir)/$@.sh >_$@ || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rtlenmb:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ + $(srcdir)/rtlen.sh >_$@ || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/rtlen.ok _$@ && rm -f _$@ + +nondec2:: + @echo $@ + @$(AWK) --non-decimal-data -v a=0x1 -f $(srcdir)/$@.awk >_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nofile:: + @echo $@ + @$(AWK) '{}' no/such/file >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +binmode1:: + @echo $@ + @$(AWK) -v BINMODE=3 'BEGIN { print BINMODE }' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +subi18n:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; $(AWK) -f $(srcdir)/$@.awk > _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +concat4:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in > _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +devfd1:: + @echo $@ + @$(AWK) -f $(srcdir)/$@.awk 4< $(srcdir)/devfd.in1 5< $(srcdir)/devfd.in2 >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +# The program text is the '1' which will print each record. How compact can you get? +devfd2:: + @echo $@ + @$(AWK) 1 /dev/fd/4 /dev/fd/5 4< $(srcdir)/devfd.in1 5< $(srcdir)/devfd.in2 >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mixed1:: + @echo $@ + @$(AWK) -f /dev/null --source 'BEGIN {return junk}' >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mtchi18n:: + @echo $@ + @GAWKLOCALE=ru_RU.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +reint2:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) --re-interval -f $@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +localenl:: + @echo $@ + @$(srcdir)/$@.sh >_$@ 2>/dev/null + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mbprintf1:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mbprintf2:: + @echo $@ + @GAWKLOCALE=ja_JP.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mbprintf3:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mbfw1:: + @echo $@ + @GAWKLOCALE=en_US.UTF-8 ; export GAWKLOCALE ; \ + $(AWK) -f $(srcdir)/$@.awk $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >> _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst6:: + @echo $@ + @GAWKLOCALE=C ; $(AWK) -f $(srcdir)/$@.awk > _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +mbstr1:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +printfbad2: printfbad2.ok + @echo $@ + @$(AWK) --lint -f $(srcdir)/$@.awk $(srcdir)/$@.in 2>&1 | sed 's;\$(srcdir)/;;g' >_$@ || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +beginfile1:: + @echo $@ + @AWKPATH=$(srcdir) $(AWK) -f $@.awk $(srcdir)/$@.awk . ./no/such/file Makefile >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +beginfile2: + @echo $@ + @-( cd $(srcdir) && LC_ALL=C AWK="$(abs_builddir)/$(AWKPROG)" $(srcdir)/$@.sh $(srcdir)/$@.in ) > _$@ 2>&1 + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +dumpvars:: + @echo $@ + @AWKPATH=$(srcdir) $(AWK) --dump-variables 1 < $(srcdir)/$@.in >/dev/null 2>&1 || echo EXIT CODE: $$? >>_$@ + @mv awkvars.out _$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +profile1: + @echo $@ + @$(AWK) --profile=ap-$@.out -f $(srcdir)/xref.awk $(srcdir)/dtdgport.awk > _$@.out1 + @$(AWK) -f ap-$@.out $(srcdir)/dtdgport.awk > _$@.out2 ; rm ap-$@.out + @cmp _$@.out1 _$@.out2 && rm _$@.out[12] || echo EXIT CODE: $$? >>_$@ + +profile2: + @echo $@ + @$(PGAWK) --profile=ap-$@.out -v sortcmd=sort -f $(srcdir)/xref.awk $(srcdir)/dtdgport.awk > /dev/null + @sed 1,2d < ap-$@.out > _$@; rm ap-$@.out + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +profile3: + @echo $@ + @$(PGAWK) --profile=ap-$@.out -f $(srcdir)/$@.awk > /dev/null + @sed 1,2d < ap-$@.out > _$@; rm ap-$@.out + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +posix2008sub: + @echo $@ + @$(AWK) --posix -f $(srcdir)/$@.awk > _$@ 2>&1 + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +next: + @echo $@ + @-AWK="$(AWKPROG)" $(srcdir)/$@.sh > _$@ 2>&1 + @-LC_ALL=C $(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +exit: + @echo $@ + @-AWK="$(AWKPROG)" $(srcdir)/$@.sh > _$@ 2>&1 + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rri1:: + @echo $@ + @[ -z "$$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8; \ + AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ +Gt-dummy: +# file Maketests, generated from Makefile.am by the Gentests program +addcomma: + @echo addcomma + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +anchgsub: + @echo anchgsub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arrayparm: + @echo arrayparm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arrayprm2: + @echo arrayprm2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arrayprm3: + @echo arrayprm3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arrayref: + @echo arrayref + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arrymem1: + @echo arrymem1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arryref2: + @echo arryref2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arryref3: + @echo arryref3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arryref4: + @echo arryref4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arryref5: + @echo arryref5 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arynasty: + @echo arynasty + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm1: + @echo aryprm1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm2: + @echo aryprm2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm3: + @echo aryprm3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm4: + @echo aryprm4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm5: + @echo aryprm5 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm6: + @echo aryprm6 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm7: + @echo aryprm7 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm8: + @echo aryprm8 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arysubnm: + @echo arysubnm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +asgext: + @echo asgext + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +back89: + @echo back89 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +backgsub: + @echo backgsub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +childin: + @echo childin + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +closebad: + @echo closebad + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +clsflnam: + @echo clsflnam + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +compare2: + @echo compare2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +concat1: + @echo concat1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +concat2: + @echo concat2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +concat3: + @echo concat3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +convfmt: + @echo convfmt + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +datanonl: + @echo datanonl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +defref: + @echo defref + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +delargv: + @echo delargv + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +delarpm2: + @echo delarpm2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +delarprm: + @echo delarprm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +delfunc: + @echo delfunc + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +dfastress: + @echo dfastress + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +dynlj: + @echo dynlj + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +eofsplit: + @echo eofsplit + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +exitval2: + @echo exitval2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fcall_exit: + @echo fcall_exit + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fcall_exit2: + @echo fcall_exit2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fldchg: + @echo fldchg + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fldchgnf: + @echo fldchgnf + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnamedat: + @echo fnamedat + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnarray: + @echo fnarray + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnarray2: + @echo fnarray2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnaryscl: + @echo fnaryscl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnasgnm: + @echo fnasgnm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnmisc: + @echo fnmisc + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fordel: + @echo fordel + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +forref: + @echo forref + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +forsimp: + @echo forsimp + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fsbs: + @echo fsbs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fsrs: + @echo fsrs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fstabplus: + @echo fstabplus + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +funsemnl: + @echo funsemnl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +funsmnam: + @echo funsmnam + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +funstack: + @echo funstack + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getline: + @echo getline + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getline3: + @echo getline3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getline4: + @echo getline4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getnr2tb: + @echo getnr2tb + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getnr2tm: + @echo getnr2tm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubasgn: + @echo gsubasgn + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtest: + @echo gsubtest + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst2: + @echo gsubtst2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst4: + @echo gsubtst4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst5: + @echo gsubtst5 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst7: + @echo gsubtst7 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst8: + @echo gsubtst8 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +hex: + @echo hex + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +hsprint: + @echo hsprint + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +inputred: + @echo inputred + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +intest: + @echo intest + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +intprec: + @echo intprec + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +iobug1: + @echo iobug1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +leadnl: + @echo leadnl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +longsub: + @echo longsub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +longwrds: + @echo longwrds + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +manglprm: + @echo manglprm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +math: + @echo math + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +membug1: + @echo membug1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +minusstr: + @echo minusstr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nasty: + @echo nasty + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nasty2: + @echo nasty2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +negexp: + @echo negexp + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +negrange: + @echo negrange + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nested: + @echo nested + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nfldstr: + @echo nfldstr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nfneg: + @echo nfneg + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nfset: + @echo nfset + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nlfldsep: + @echo nlfldsep + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nlinstr: + @echo nlinstr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nlstrina: + @echo nlstrina + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +noeffect: + @echo noeffect + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nofmtch: + @echo nofmtch + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +noloop1: + @echo noloop1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +noloop2: + @echo noloop2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +noparms: + @echo noparms + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nulrsend: + @echo nulrsend + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +numindex: + @echo numindex + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +numsubstr: + @echo numsubstr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +octsub: + @echo octsub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ofmt: + @echo ofmt + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ofmta: + @echo ofmta + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ofmtbig: + @echo ofmtbig + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ofmtfidl: + @echo ofmtfidl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ofmts: + @echo ofmts + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +onlynl: + @echo onlynl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +opasnidx: + @echo opasnidx + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +opasnslf: + @echo opasnslf + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +paramdup: + @echo paramdup + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +paramres: + @echo paramres + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +paramtyp: + @echo paramtyp + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +parse1: + @echo parse1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +parsefld: + @echo parsefld + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +parseme: + @echo parseme + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +pcntplus: + @echo pcntplus + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prdupval: + @echo prdupval + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prec: + @echo prec + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +printf1: + @echo printf1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prmarscl: + @echo prmarscl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prmreuse: + @echo prmreuse + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prt1eval: + @echo prt1eval + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prtoeval: + @echo prtoeval + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rand: + @echo rand + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +range1: + @echo range1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rebt8b1: + @echo rebt8b1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +regeq: + @echo regeq + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +regrange: + @echo regrange + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +reindops: + @echo reindops + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +reparse: + @echo reparse + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +resplit: + @echo resplit + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rs: + @echo rs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsnul1nl: + @echo rsnul1nl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest1: + @echo rstest1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest2: + @echo rstest2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest3: + @echo rstest3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest4: + @echo rstest4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest5: + @echo rstest5 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rswhite: + @echo rswhite + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +scalar: + @echo scalar + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sclforin: + @echo sclforin + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sclifin: + @echo sclifin + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sortempty: + @echo sortempty + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitargv: + @echo splitargv + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitarr: + @echo splitarr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitdef: + @echo splitdef + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitvar: + @echo splitvar + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitwht: + @echo splitwht + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +strcat1: + @echo strcat1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +strnum1: + @echo strnum1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +strtod: + @echo strtod + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +subsepnm: + @echo subsepnm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +subslash: + @echo subslash + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +substr: + @echo substr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +swaplns: + @echo swaplns + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +synerr1: + @echo synerr1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +synerr2: + @echo synerr2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uninit2: + @echo uninit2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uninit3: + @echo uninit3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uninit4: + @echo uninit4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uninit5: + @echo uninit5 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uninitialized: + @echo uninitialized + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +unterm: + @echo unterm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uparrfs: + @echo uparrfs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +wjposer1: + @echo wjposer1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +zero2: + @echo zero2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +zeroe0: + @echo zeroe0 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +zeroflag: + @echo zeroflag + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getlnhd: + @echo getlnhd + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aadelete1: + @echo aadelete1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aadelete2: + @echo aadelete2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aarray1: + @echo aarray1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aasort: + @echo aasort + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aasorti: + @echo aasorti + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arraysort: + @echo arraysort + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +backw: + @echo backw + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +clos1way: + @echo clos1way + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +delsub: + @echo delsub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fieldwdth: + @echo fieldwdth + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fpat1: + @echo fpat1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fpat2: + @echo fpat2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fpat3: + @echo fpat3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fpatnull: + @echo fpatnull + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fsfwfs: + @echo fsfwfs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +funlen: + @echo funlen + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fwtest: + @echo fwtest + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fwtest2: + @echo fwtest2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fwtest3: + @echo fwtest3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gensub: + @echo gensub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gensub2: + @echo gensub2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getlndir: + @echo getlndir + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gnuops2: + @echo gnuops2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gnuops3: + @echo gnuops3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gnureops: + @echo gnureops + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +icasefs: + @echo icasefs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +icasers: + @echo icasers + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +igncdym: + @echo igncdym + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +igncfs: + @echo igncfs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ignrcase: + @echo ignrcase + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +indirectcall: + @echo indirectcall + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +lint: + @echo lint + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +lintold: + @echo lintold + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint-old < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +lintwarn: + @echo lintwarn + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +match1: + @echo match1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +match2: + @echo match2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +match3: + @echo match3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nastyparm: + @echo nastyparm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nondec: + @echo nondec + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +patsplit: + @echo patsplit + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +posix: + @echo posix + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +printfbad1: + @echo printfbad1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +printfbad3: + @echo printfbad3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +procinfs: + @echo procinfs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +pty1: + @echo pty1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rebuf: + @echo rebuf + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +regx8bit: + @echo regx8bit + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest6: + @echo rstest6 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +shadow: + @echo shadow + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sortfor: + @echo sortfor + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sortu: + @echo sortu + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitarg4: + @echo splitarg4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +strtonum: + @echo strtonum + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +switch2: + @echo switch2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +double1: + @echo double1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +double2: + @echo double2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +intformat: + @echo intformat + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +asort: + @echo asort + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +asorti: + @echo asorti + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fmttest: + @echo fmttest + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnarydel: + @echo fnarydel + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnparydl: + @echo fnparydl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rebt8b2: + @echo rebt8b2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sort1: + @echo sort1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sprintfc: + @echo sprintfc + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +# end of file Maketests + +# Targets generated for other tests: + +$(srcdir)/Maketests: $(srcdir)/Makefile.am $(srcdir)/Gentests + files=`cd "$(srcdir)" && echo *.awk *.in`; \ + $(AWK) -f $(srcdir)/Gentests "$(srcdir)/Makefile.am" $$files > $(srcdir)/Maketests + +clean: + rm -fr _* core core.* fmtspcl.ok junk out1 out2 out3 strftime.ok test1 test2 seq *~ + +# An attempt to print something that can be grepped for in build logs +pass-fail: + @COUNT=`ls _* 2>/dev/null | wc -l` ; \ + if test $$COUNT = 0 ; \ + then echo ALL TESTS PASSED ; \ + else echo $$COUNT TESTS FAILED ; \ + fi + +# This target for my convenience to look at all the results +diffout: + for i in _* ; \ + do \ + if [ "$$i" != "_*" ]; then \ + echo ============== $$i ============= ; \ + if [ -r $${i#_}.ok ]; then \ + diff -c $${i#_}.ok $$i ; \ + else \ + diff -c $(srcdir)/$${i#_}.ok $$i ; \ + fi ; \ + fi ; \ + done | more + +# convenient way to scan valgrind results for errors +valgrind-scan: + @echo "Scanning valgrind log files for problems:" + @$(AWK) '\ + function show() {if (cmd) {printf "%s: %s\n",FILENAME,cmd; cmd = ""}; \ + printf "\t%s\n",$$0}; \ + {$$1 = ""}; \ + /Prog and args are:/ {incmd = 1; cmd = ""; next}; \ + incmd {if (NF == 1) incmd = 0; else {cmd = (cmd $$0); next}}; \ + /ERROR SUMMARY:/ && !/: 0 errors from 0 contexts/ {show()}; \ + /definitely lost:/ && !/: 0 bytes in 0 blocks/ {show()}; \ + /possibly lost:/ && !/: 0 bytes in 0 blocks/ {show()}; \ + / suppressed:/ && !/: 0 bytes in 0 blocks/ {show()}; \ + ' log.[0-9]* + +# This target is for testing with electric fence. +efence: + for i in $$(ls _* | sed 's;_\(.*\);\1;') ; \ + do \ + bad=$$(wc -l < _$$i) \ + ok=$$(wc -l < $$i.ok) ; \ + if (( $$bad == $$ok + 2 )) ; \ + then \ + rm _$$i ; \ + fi ; \ + done + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/test/Maketests b/test/Maketests new file mode 100644 index 0000000..34a0aaa --- /dev/null +++ b/test/Maketests @@ -0,0 +1,1198 @@ +Gt-dummy: +# file Maketests, generated from Makefile.am by the Gentests program +addcomma: + @echo addcomma + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +anchgsub: + @echo anchgsub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arrayparm: + @echo arrayparm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arrayprm2: + @echo arrayprm2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arrayprm3: + @echo arrayprm3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arrayref: + @echo arrayref + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arrymem1: + @echo arrymem1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arryref2: + @echo arryref2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arryref3: + @echo arryref3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arryref4: + @echo arryref4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arryref5: + @echo arryref5 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arynasty: + @echo arynasty + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm1: + @echo aryprm1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm2: + @echo aryprm2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm3: + @echo aryprm3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm4: + @echo aryprm4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm5: + @echo aryprm5 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm6: + @echo aryprm6 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm7: + @echo aryprm7 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aryprm8: + @echo aryprm8 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arysubnm: + @echo arysubnm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +asgext: + @echo asgext + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +back89: + @echo back89 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +backgsub: + @echo backgsub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +childin: + @echo childin + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +closebad: + @echo closebad + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +clsflnam: + @echo clsflnam + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +compare2: + @echo compare2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +concat1: + @echo concat1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +concat2: + @echo concat2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +concat3: + @echo concat3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +convfmt: + @echo convfmt + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +datanonl: + @echo datanonl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +defref: + @echo defref + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +delargv: + @echo delargv + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +delarpm2: + @echo delarpm2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +delarprm: + @echo delarprm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +delfunc: + @echo delfunc + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +dfastress: + @echo dfastress + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +dynlj: + @echo dynlj + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +eofsplit: + @echo eofsplit + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +exitval2: + @echo exitval2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fcall_exit: + @echo fcall_exit + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fcall_exit2: + @echo fcall_exit2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fldchg: + @echo fldchg + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fldchgnf: + @echo fldchgnf + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnamedat: + @echo fnamedat + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnarray: + @echo fnarray + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnarray2: + @echo fnarray2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnaryscl: + @echo fnaryscl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnasgnm: + @echo fnasgnm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnmisc: + @echo fnmisc + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fordel: + @echo fordel + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +forref: + @echo forref + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +forsimp: + @echo forsimp + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fsbs: + @echo fsbs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fsrs: + @echo fsrs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fstabplus: + @echo fstabplus + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +funsemnl: + @echo funsemnl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +funsmnam: + @echo funsmnam + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +funstack: + @echo funstack + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getline: + @echo getline + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getline3: + @echo getline3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getline4: + @echo getline4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getnr2tb: + @echo getnr2tb + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getnr2tm: + @echo getnr2tm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubasgn: + @echo gsubasgn + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtest: + @echo gsubtest + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst2: + @echo gsubtst2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst4: + @echo gsubtst4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst5: + @echo gsubtst5 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst7: + @echo gsubtst7 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gsubtst8: + @echo gsubtst8 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +hex: + @echo hex + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +hsprint: + @echo hsprint + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +inputred: + @echo inputred + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +intest: + @echo intest + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +intprec: + @echo intprec + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +iobug1: + @echo iobug1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +leadnl: + @echo leadnl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +longsub: + @echo longsub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +longwrds: + @echo longwrds + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +manglprm: + @echo manglprm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +math: + @echo math + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +membug1: + @echo membug1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +minusstr: + @echo minusstr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nasty: + @echo nasty + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nasty2: + @echo nasty2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +negexp: + @echo negexp + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +negrange: + @echo negrange + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nested: + @echo nested + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nfldstr: + @echo nfldstr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nfneg: + @echo nfneg + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nfset: + @echo nfset + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nlfldsep: + @echo nlfldsep + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nlinstr: + @echo nlinstr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nlstrina: + @echo nlstrina + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +noeffect: + @echo noeffect + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nofmtch: + @echo nofmtch + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +noloop1: + @echo noloop1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +noloop2: + @echo noloop2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +noparms: + @echo noparms + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nulrsend: + @echo nulrsend + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +numindex: + @echo numindex + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +numsubstr: + @echo numsubstr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +octsub: + @echo octsub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ofmt: + @echo ofmt + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ofmta: + @echo ofmta + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ofmtbig: + @echo ofmtbig + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ofmtfidl: + @echo ofmtfidl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ofmts: + @echo ofmts + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +onlynl: + @echo onlynl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +opasnidx: + @echo opasnidx + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +opasnslf: + @echo opasnslf + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +paramdup: + @echo paramdup + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +paramres: + @echo paramres + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +paramtyp: + @echo paramtyp + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +parse1: + @echo parse1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +parsefld: + @echo parsefld + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +parseme: + @echo parseme + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +pcntplus: + @echo pcntplus + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prdupval: + @echo prdupval + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prec: + @echo prec + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +printf1: + @echo printf1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prmarscl: + @echo prmarscl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prmreuse: + @echo prmreuse + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prt1eval: + @echo prt1eval + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +prtoeval: + @echo prtoeval + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rand: + @echo rand + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +range1: + @echo range1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rebt8b1: + @echo rebt8b1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +regeq: + @echo regeq + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +regrange: + @echo regrange + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +reindops: + @echo reindops + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +reparse: + @echo reparse + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +resplit: + @echo resplit + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rs: + @echo rs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rsnul1nl: + @echo rsnul1nl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest1: + @echo rstest1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest2: + @echo rstest2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest3: + @echo rstest3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest4: + @echo rstest4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest5: + @echo rstest5 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rswhite: + @echo rswhite + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +scalar: + @echo scalar + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sclforin: + @echo sclforin + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sclifin: + @echo sclifin + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sortempty: + @echo sortempty + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitargv: + @echo splitargv + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitarr: + @echo splitarr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitdef: + @echo splitdef + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitvar: + @echo splitvar + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitwht: + @echo splitwht + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +strcat1: + @echo strcat1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +strnum1: + @echo strnum1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +strtod: + @echo strtod + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +subsepnm: + @echo subsepnm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +subslash: + @echo subslash + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +substr: + @echo substr + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +swaplns: + @echo swaplns + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +synerr1: + @echo synerr1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +synerr2: + @echo synerr2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uninit2: + @echo uninit2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uninit3: + @echo uninit3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uninit4: + @echo uninit4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uninit5: + @echo uninit5 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uninitialized: + @echo uninitialized + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +unterm: + @echo unterm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +uparrfs: + @echo uparrfs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +wjposer1: + @echo wjposer1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +zero2: + @echo zero2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +zeroe0: + @echo zeroe0 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +zeroflag: + @echo zeroflag + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getlnhd: + @echo getlnhd + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aadelete1: + @echo aadelete1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aadelete2: + @echo aadelete2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aarray1: + @echo aarray1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aasort: + @echo aasort + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +aasorti: + @echo aasorti + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +arraysort: + @echo arraysort + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +backw: + @echo backw + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +clos1way: + @echo clos1way + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +delsub: + @echo delsub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fieldwdth: + @echo fieldwdth + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fpat1: + @echo fpat1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fpat2: + @echo fpat2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fpat3: + @echo fpat3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fpatnull: + @echo fpatnull + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fsfwfs: + @echo fsfwfs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +funlen: + @echo funlen + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fwtest: + @echo fwtest + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fwtest2: + @echo fwtest2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fwtest3: + @echo fwtest3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gensub: + @echo gensub + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gensub2: + @echo gensub2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +getlndir: + @echo getlndir + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gnuops2: + @echo gnuops2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gnuops3: + @echo gnuops3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +gnureops: + @echo gnureops + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +icasefs: + @echo icasefs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +icasers: + @echo icasers + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +igncdym: + @echo igncdym + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +igncfs: + @echo igncfs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +ignrcase: + @echo ignrcase + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +indirectcall: + @echo indirectcall + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +lint: + @echo lint + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +lintold: + @echo lintold + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint-old < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +lintwarn: + @echo lintwarn + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +match1: + @echo match1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +match2: + @echo match2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +match3: + @echo match3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nastyparm: + @echo nastyparm + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +nondec: + @echo nondec + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +patsplit: + @echo patsplit + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +posix: + @echo posix + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +printfbad1: + @echo printfbad1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +printfbad3: + @echo printfbad3 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +procinfs: + @echo procinfs + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +pty1: + @echo pty1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rebuf: + @echo rebuf + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +regx8bit: + @echo regx8bit + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rstest6: + @echo rstest6 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +shadow: + @echo shadow + @AWKPATH=$(srcdir) $(AWK) -f $@.awk --lint >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sortfor: + @echo sortfor + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sortu: + @echo sortu + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +splitarg4: + @echo splitarg4 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +strtonum: + @echo strtonum + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +switch2: + @echo switch2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +double1: + @echo double1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +double2: + @echo double2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +intformat: + @echo intformat + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +asort: + @echo asort + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +asorti: + @echo asorti + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fmttest: + @echo fmttest + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnarydel: + @echo fnarydel + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +fnparydl: + @echo fnparydl + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +rebt8b2: + @echo rebt8b2 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sort1: + @echo sort1 + @AWKPATH=$(srcdir) $(AWK) -f $@.awk >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +sprintfc: + @echo sprintfc + @AWKPATH=$(srcdir) $(AWK) -f $@.awk < $(srcdir)/$@.in >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@ + @-$(CMP) $(srcdir)/$@.ok _$@ && rm -f _$@ + +# end of file Maketests diff --git a/test/README b/test/README new file mode 100644 index 0000000..2343be2 --- /dev/null +++ b/test/README @@ -0,0 +1,18 @@ +Mon Jan 22 13:08:58 EST 1996 + +This directory contains the tests for gawk. The tests use the +following conventions. + +Given some aspect of gawk named `foo', there will be one or more +of the following files: + +foo.awk --- actual code for the test if not inline in the Makefile +foo.in --- the data for the test, if it needs data +foo.ok --- the expected results +_foo --- the actual results; generated at run time + +The _foo file will be left around if a test fails, allowing you to +compare actual and expected results, in case they differ. + +If they do differ (other than strftime.ok and _strftime!), send in a +bug report. See the manual for the bug report procedure. diff --git a/test/aadelete1.awk b/test/aadelete1.awk new file mode 100644 index 0000000..2484a05 --- /dev/null +++ b/test/aadelete1.awk @@ -0,0 +1,19 @@ +BEGIN { + a[1][1] = 11 + a[1][2] = 12 + a[2] = 2 + delete a[1][1] + f(a, a[1]) + print a[1][1] + print length(a), length(a[1]) + delete a + print length(a), length(a[1]), length(a) + a[1][1] = 11 +} + +function f(c, b) { + delete b + b[1] = 1 + print c[1][1], b[1] + delete c[2] +} diff --git a/test/aadelete1.ok b/test/aadelete1.ok new file mode 100644 index 0000000..d4b678b --- /dev/null +++ b/test/aadelete1.ok @@ -0,0 +1,6 @@ +1 1 +1 +1 1 +0 0 1 +gawk: aadelete1.awk:11: fatal: attempt to use scalar `a["1"]' as an array +EXIT CODE: 2 diff --git a/test/aadelete2.awk b/test/aadelete2.awk new file mode 100644 index 0000000..54bd49a --- /dev/null +++ b/test/aadelete2.awk @@ -0,0 +1,10 @@ +BEGIN { + a[1][1]=1; + b[1][1]=11; +# delete b[a[1]][1]; + f(b, a) +} + +function f(arr, s) { + delete arr[s[1]][1] +} diff --git a/test/aadelete2.ok b/test/aadelete2.ok new file mode 100644 index 0000000..65a21ef --- /dev/null +++ b/test/aadelete2.ok @@ -0,0 +1,2 @@ +gawk: aadelete2.awk:9: fatal: attempt to use array `a["1"]' in a scalar context +EXIT CODE: 2 diff --git a/test/aarray1.awk b/test/aarray1.awk new file mode 100644 index 0000000..a3c4f93 --- /dev/null +++ b/test/aarray1.awk @@ -0,0 +1,28 @@ +BEGIN { + a[1][1] = 10; + a[1][2] = 20; + a[1][3] = 30; + a[2] = "hello world! we have multi-dimensional array" + a[3, "X"] = "Y" + print length(a), length(a[1]) + delete a[2] + delete a[3, "X"] + a[2][1] = 100; + a[2][2] = 200; + a[2][3] = 300; + for (i in a) { + sum[i] = 0 + for (j in a[i]) + sum[i] += a[i][j] + } + print sum[1], sum[2] + f(a[1]) + print a[1][1] +} + +function f(x, i) +{ + for (i=1;i<=length(x);i++) + print x[i] + x[1] = 1001 +} diff --git a/test/aarray1.ok b/test/aarray1.ok new file mode 100644 index 0000000..a335498 --- /dev/null +++ b/test/aarray1.ok @@ -0,0 +1,6 @@ +3 3 +60 600 +10 +20 +30 +1001 diff --git a/test/aasort.awk b/test/aasort.awk new file mode 100644 index 0000000..a072a82 --- /dev/null +++ b/test/aasort.awk @@ -0,0 +1,34 @@ +function init(b, a, i) +{ + a[1] = "aardvark" + a[2] = "animal" + a[3] = "zebra" + a[4] = "zoo" + a[5] = "Iguana" + a[6] = "Alligator" + a[7] = "Nouns" + a[8] = "people" + for (i in a) + b[IGNORECASE][i] = a[i] +} + +BEGIN { + + for (IGNORECASE = 0; IGNORECASE < 2; IGNORECASE++) { + init(b) + + n = asort(b[IGNORECASE]) + + for (i = 1; i <= n; i++) + printf("b[%d][%d] = \"%s\"\n", IGNORECASE, i, b[IGNORECASE][i]) + + print "============" + } + + IGNORECASE = 1 + init(b) + b[2][1] = "" + n = asort(b[1], b[2]) + for (i = 1; i <= n; i++) + printf("b[2][%d] = \"%s\"\n", i, b[2][i]) +} diff --git a/test/aasort.ok b/test/aasort.ok new file mode 100644 index 0000000..ed5f6f2 --- /dev/null +++ b/test/aasort.ok @@ -0,0 +1,26 @@ +b[0][1] = "Alligator" +b[0][2] = "Iguana" +b[0][3] = "Nouns" +b[0][4] = "aardvark" +b[0][5] = "animal" +b[0][6] = "people" +b[0][7] = "zebra" +b[0][8] = "zoo" +============ +b[1][1] = "aardvark" +b[1][2] = "Alligator" +b[1][3] = "animal" +b[1][4] = "Iguana" +b[1][5] = "Nouns" +b[1][6] = "people" +b[1][7] = "zebra" +b[1][8] = "zoo" +============ +b[2][1] = "aardvark" +b[2][2] = "Alligator" +b[2][3] = "animal" +b[2][4] = "Iguana" +b[2][5] = "Nouns" +b[2][6] = "people" +b[2][7] = "zebra" +b[2][8] = "zoo" diff --git a/test/aasorti.awk b/test/aasorti.awk new file mode 100644 index 0000000..0416437 --- /dev/null +++ b/test/aasorti.awk @@ -0,0 +1,35 @@ +function init(b, a, i) +{ + delete a + + a["aardvark"] = 1 + a["animal"] = 2 + a["zebra"] = 3 + a["zoo"] = 4 + a["Iguana"] = 5 + a["Alligator"] = 6 + a["Nouns"] = 7 + a["people"] = 8 + for (i in a) + b[IGNORECASE][i] = a[i] +} + +BEGIN { + + for (IGNORECASE = 0; IGNORECASE < 2; IGNORECASE++) { + init(b) + + n = asorti(b[IGNORECASE]) + + for (i = 1; i <= n; i++) + printf("b[%d][%d] = \"%s\"\n", IGNORECASE, i, b[IGNORECASE][i]) + + print "============" + + } + + n = asorti(b) + for (i = 1; i <= n; i++) + printf("b[%d] = \"%s\"\n", i, b[i]) + +} diff --git a/test/aasorti.ok b/test/aasorti.ok new file mode 100644 index 0000000..7a91424 --- /dev/null +++ b/test/aasorti.ok @@ -0,0 +1,20 @@ +b[0][1] = "Alligator" +b[0][2] = "Iguana" +b[0][3] = "Nouns" +b[0][4] = "aardvark" +b[0][5] = "animal" +b[0][6] = "people" +b[0][7] = "zebra" +b[0][8] = "zoo" +============ +b[1][1] = "aardvark" +b[1][2] = "Alligator" +b[1][3] = "animal" +b[1][4] = "Iguana" +b[1][5] = "Nouns" +b[1][6] = "people" +b[1][7] = "zebra" +b[1][8] = "zoo" +============ +b[1] = "0" +b[2] = "1" diff --git a/test/addcomma.awk b/test/addcomma.awk new file mode 100644 index 0000000..8f52f36 --- /dev/null +++ b/test/addcomma.awk @@ -0,0 +1,15 @@ +# addcomma - put commas in numbers +# input: a number per line +# output: the input number followed by +# the number with commas and two decimal places + +{ printf("%-12s %20s\n", $0, addcomma($0)) } + +function addcomma(x, num) { + if (x < 0) + return "-" addcomma(-x) + num = sprintf("%.2f", x) # num is dddddd.dd + while (num ~ /[0-9][0-9][0-9][0-9]/) + sub(/[0-9][0-9][0-9][,.]/, ",&", num) + return num +} diff --git a/test/addcomma.in b/test/addcomma.in new file mode 100644 index 0000000..be70ac9 --- /dev/null +++ b/test/addcomma.in @@ -0,0 +1,7 @@ +0 +-1 +-12.34 +12345 +-1234567.89 +-123. +-123456 diff --git a/test/addcomma.ok b/test/addcomma.ok new file mode 100644 index 0000000..57c5886 --- /dev/null +++ b/test/addcomma.ok @@ -0,0 +1,7 @@ +0 0.00 +-1 -1.00 +-12.34 -12.34 +12345 12,345.00 +-1234567.89 -1,234,567.89 +-123. -123.00 +-123456 -123,456.00 diff --git a/test/anchgsub.awk b/test/anchgsub.awk new file mode 100644 index 0000000..52e8aa4 --- /dev/null +++ b/test/anchgsub.awk @@ -0,0 +1 @@ +{ gsub(/^[ ]*/, "", $0) ; print } diff --git a/test/anchgsub.in b/test/anchgsub.in new file mode 100644 index 0000000..b829d84 --- /dev/null +++ b/test/anchgsub.in @@ -0,0 +1 @@ + This is a test, this is only a test. diff --git a/test/anchgsub.ok b/test/anchgsub.ok new file mode 100644 index 0000000..c33dfb9 --- /dev/null +++ b/test/anchgsub.ok @@ -0,0 +1 @@ +This is a test, this is only a test. diff --git a/test/argarray.awk b/test/argarray.awk new file mode 100644 index 0000000..1960f9b --- /dev/null +++ b/test/argarray.awk @@ -0,0 +1,14 @@ +BEGIN { + argn = " argument" (ARGC > 1 ? "s" : "") + are = ARGC > 1 ? "are" : "is" + print "here we have " ARGC argn + print "which " are + for (x = 0; x < ARGC; x++) + print "\t", ARGV[x] + print "Environment variable TEST=" ENVIRON["TEST"] + print "and the current input file is called \"" FILENAME "\"" +} + +FNR == 1 { + print "in main loop, this input file is known as \"" FILENAME "\"" +} diff --git a/test/argarray.in b/test/argarray.in new file mode 100644 index 0000000..bc93338 --- /dev/null +++ b/test/argarray.in @@ -0,0 +1 @@ +this is a simple test file diff --git a/test/argarray.ok b/test/argarray.ok new file mode 100644 index 0000000..18eb841 --- /dev/null +++ b/test/argarray.ok @@ -0,0 +1,9 @@ +here we have 3 arguments +which are + gawk + ./argarray.in + - +Environment variable TEST= +and the current input file is called "" +in main loop, this input file is known as "./argarray.in" +in main loop, this input file is known as "-" diff --git a/test/argtest.awk b/test/argtest.awk new file mode 100644 index 0000000..e7a1145 --- /dev/null +++ b/test/argtest.awk @@ -0,0 +1,4 @@ +BEGIN { + for (i = 0; i < ARGC; i++) + printf("ARGV[%d] = %s\n", i, ARGV[i]) +} diff --git a/test/argtest.ok b/test/argtest.ok new file mode 100644 index 0000000..591bc64 --- /dev/null +++ b/test/argtest.ok @@ -0,0 +1,4 @@ +ARGV[0] = gawk +ARGV[1] = -x +ARGV[2] = -y +ARGV[3] = abc diff --git a/test/arrayparm.awk b/test/arrayparm.awk new file mode 100644 index 0000000..d6f34d9 --- /dev/null +++ b/test/arrayparm.awk @@ -0,0 +1,21 @@ +# +# Test program from: +# +# Date: Tue, 21 Feb 95 16:09:29 EST +# From: emory!blackhawk.com!aaron (Aaron Sosnick) +# +BEGIN { + foo[1]=1; + foo[2]=2; + bug1(foo); +} +function bug1(i) { + for (i in foo) { + bug2(i); + delete foo[i]; + print i,1,bot[1]; + } +} +function bug2(arg) { + bot[arg]=arg; +} diff --git a/test/arrayparm.ok b/test/arrayparm.ok new file mode 100644 index 0000000..5fe09aa --- /dev/null +++ b/test/arrayparm.ok @@ -0,0 +1,2 @@ +gawk: arrayparm.awk:13: fatal: attempt to use array `i (from foo)' in a scalar context +EXIT CODE: 2 diff --git a/test/arrayprm2.awk b/test/arrayprm2.awk new file mode 100644 index 0000000..35a92cc --- /dev/null +++ b/test/arrayprm2.awk @@ -0,0 +1,67 @@ +# From spcecdt@armory.com Wed Apr 30 11:08:48 2003 +# Return-Path: +# Received: from localhost (skeeve [127.0.0.1]) +# by skeeve.com (8.12.5/8.12.5) with ESMTP id h3U7uZWr015489 +# for ; Wed, 30 Apr 2003 11:08:48 +0300 +# Received: from actcom.co.il [192.114.47.1] +# by localhost with POP3 (fetchmail-5.9.0) +# for arnold@localhost (single-drop); Wed, 30 Apr 2003 11:08:48 +0300 (IDT) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Wed Apr 30 11:05:01 2003) +# X-From_: spcecdt@armory.com Wed Apr 30 04:06:46 2003 +# Received: from smtp1.actcom.net.il by actcom.co.il with ESMTP +# (8.11.6/actcom-0.2) id h3U16iv04111 for ; +# Wed, 30 Apr 2003 04:06:45 +0300 (EET DST) +# (rfc931-sender: mail.actcom.co.il [192.114.47.13]) +# Received: from f7.net (consort.superb.net [209.61.216.22]) +# by smtp1.actcom.net.il (8.12.8/8.12.8) with ESMTP id h3U16nEv009589 +# for ; Wed, 30 Apr 2003 04:06:50 +0300 +# Received: from fencepost.gnu.org (fencepost.gnu.org [199.232.76.164]) +# by f7.net (8.11.7/8.11.6) with ESMTP id h3U16gj29182 +# for ; Tue, 29 Apr 2003 21:06:42 -0400 +# Received: from monty-python.gnu.org ([199.232.76.173]) +# by fencepost.gnu.org with esmtp (Exim 4.10) +# id 19Ag3W-00029w-00 +# for bug-gawk@gnu.org; Tue, 29 Apr 2003 21:06:42 -0400 +# Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) +# id 19Ag1V-0001AN-00 +# for bug-gawk@gnu.org; Tue, 29 Apr 2003 21:04:39 -0400 +# Received: from deepthought.armory.com ([192.122.209.42] helo=armory.com) +# by monty-python.gnu.org with smtp (Exim 4.10.13) +# id 19Ag1V-0001A3-00 +# for bug-gawk@gnu.org; Tue, 29 Apr 2003 21:04:37 -0400 +# Date: Tue, 29 Apr 2003 18:04:35 -0700 +# From: "John H. DuBois III" +# To: bug-gawk@gnu.org +# Subject: gawk 3.1.2a bug +# Message-ID: <20030430010434.GA4278@armory.com> +# Mime-Version: 1.0 +# Content-Type: text/plain; charset=us-ascii +# Content-Disposition: inline +# User-Agent: Mutt/1.3.28i +# X-Www: http://www.armory.com./~spcecdt/ +# Sender: spcecdt@armory.com +# X-Spam-Status: No, hits=-7.2 required=5.0 +# tests=SIGNATURE_SHORT_DENSE,SPAM_PHRASE_00_01,USER_AGENT, +# USER_AGENT_MUTT +# version=2.41 +# X-Spam-Level: +# X-SpamBouncer: 1.4 (10/07/01) +# X-SBClass: OK +# Status: RO +# +# gawk-3.1.2a 'BEGIN {foo(bar)};function foo(baz){split("x",baz)}' +# gawk-3.1.2a: cmd. line:1: fatal: split: second argument is not an array +# +# John +# -- +# John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/ +# +BEGIN { + foo(bar) +} + +function foo(baz) +{ + split("x", baz) +} diff --git a/test/arrayprm2.ok b/test/arrayprm2.ok new file mode 100644 index 0000000..e69de29 diff --git a/test/arrayprm3.awk b/test/arrayprm3.awk new file mode 100644 index 0000000..a41e587 --- /dev/null +++ b/test/arrayprm3.awk @@ -0,0 +1,56 @@ +# From spcecdt@armory.com Fri May 2 13:24:46 2003 +# Return-Path: +# Received: from localhost (skeeve [127.0.0.1]) +# by skeeve.com (8.12.5/8.12.5) with ESMTP id h42AChum021950 +# for ; Fri, 2 May 2003 13:24:46 +0300 +# Received: from actcom.co.il [192.114.47.1] +# by localhost with POP3 (fetchmail-5.9.0) +# for arnold@localhost (single-drop); Fri, 02 May 2003 13:24:46 +0300 (IDT) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Fri May 2 13:23:37 2003) +# X-From_: spcecdt@armory.com Fri May 2 00:43:51 2003 +# Received: from smtp1.actcom.net.il by actcom.co.il with ESMTP +# (8.11.6/actcom-0.2) id h41Lhm500217 for ; +# Fri, 2 May 2003 00:43:49 +0300 (EET DST) +# (rfc931-sender: lmail.actcom.co.il [192.114.47.13]) +# Received: from f7.net (consort.superb.net [209.61.216.22]) +# by smtp1.actcom.net.il (8.12.8/8.12.8) with ESMTP id h41LiGcO022817 +# for ; Fri, 2 May 2003 00:44:18 +0300 +# Received: from armory.com (deepthought.armory.com [192.122.209.42]) +# by f7.net (8.11.7/8.11.6) with SMTP id h41Lhj106516 +# for ; Thu, 1 May 2003 17:43:46 -0400 +# Date: Thu, 1 May 2003 14:43:45 -0700 +# From: "John H. DuBois III" +# To: Aharon Robbins +# Subject: Re: gawk 3.1.2a bug +# Message-ID: <20030501214345.GA24615@armory.com> +# References: <200305011738.h41Hcg76017565@localhost.localdomain> +# Mime-Version: 1.0 +# Content-Type: text/plain; charset=us-ascii +# Content-Disposition: inline +# In-Reply-To: <200305011738.h41Hcg76017565@localhost.localdomain> +# User-Agent: Mutt/1.3.28i +# X-Www: http://www.armory.com./~spcecdt/ +# Sender: spcecdt@armory.com +# X-SpamBouncer: 1.4 (10/07/01) +# X-SBClass: OK +# Status: RO +# +# On Thu, May 01, 2003 at 08:38:42PM +0300, Aharon Robbins wrote: +# > > That worked, thanks. +# > +# > Great. Your report motivated me to find everywhere such additional +# > code ought to be needed. I think I did so. --Arnold +# +# Here's another one (perhaps fixed by your additional work): +# +BEGIN { foo(a) } +function foo(a) { bar(a); print "" in a } +function bar(a) { a[""]; } +# +# Prints 1 with gawk-3.1.1; 0 with 3.1.2a. +# +# John +# -- +# John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/ +# diff --git a/test/arrayprm3.ok b/test/arrayprm3.ok new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/test/arrayprm3.ok @@ -0,0 +1 @@ +1 diff --git a/test/arrayref.awk b/test/arrayref.awk new file mode 100644 index 0000000..144d41a --- /dev/null +++ b/test/arrayref.awk @@ -0,0 +1,13 @@ + BEGIN { # foo[10] = 0 # put this line in and it will work + test(foo); print foo[1] + test2(foo2); print foo2[1] + } + + function test(foo) + { + test2(foo) + } + function test2(bar) + { + bar[1] = 1 + } diff --git a/test/arrayref.ok b/test/arrayref.ok new file mode 100644 index 0000000..6ed281c --- /dev/null +++ b/test/arrayref.ok @@ -0,0 +1,2 @@ +1 +1 diff --git a/test/arraysort.awk b/test/arraysort.awk new file mode 100644 index 0000000..b053a1d --- /dev/null +++ b/test/arraysort.awk @@ -0,0 +1,90 @@ +# From: j.eh@mchsi.com +# March and April 2010 + +BEGIN { + print "--- test1 ---" + a[1] = b[3] = 5 + a[2] = b[2] = "3D" + a[3] = b[1] = 10 + asort(a) + asort(b) + for (i = 1; i <= 3; ++i) + printf(" %2s %-2s\n", (a[i] ""), (b[i] "")) + + delete a + delete b +} + +BEGIN { + print "--- test2 ---" + a[100] = a[1] = a["x"] = a["y"] = 1 + PROCINFO["sorted_in"] = "@ind_num_asc" + for (i in a) + print i, a[i] + delete a +} + +BEGIN { + print "--- test3 ---" + a[100] = a[1] = a["x"] = 1 + PROCINFO["sorted_in"] = "@ind_num_asc" + for (i in a) + print i, a[i] + delete a +} + +BEGIN { + print "--- test4 ---" + a[0] = a[100] = a[1] = a["x"] = 1 + PROCINFO["sorted_in"] = "@ind_num_asc" + for (i in a) + print i, a[i] + delete a +} + +BEGIN { + print "--- test5 ---" + a[""] = a["y"] = a[0] = 1 + PROCINFO["sorted_in"] = "@ind_num_asc" + for (i in a) + print i, a[i] + delete a +} + +BEGIN { + print "--- test6 ---" + a[2] = a[1] = a[4] = a["3 "] = 1 + PROCINFO["sorted_in"] = "@ind_num_asc" + for (i in a) + print "\""i"\"" + delete a +} + + +BEGIN { + print "--- test7 ---" + n = split(" 4 \n 3\n3D\nD3\n3\n0\n2\n4\n1\n5", a, "\n") + for (i = 1; i <= n; i++) + b[a[i]] = a[i] + print "--unsorted--" + PROCINFO["sorted_in"] = "@unsorted" + for (i in b) + print "|"i"|"b[i]"|" + + print "--asc ind str--" + PROCINFO["sorted_in"] = "@ind_str_asc" + for (i in b) + print "|"i"|"b[i]"|" + print "--asc val str--" + PROCINFO["sorted_in"] = "@val_str_asc" + for (i in b) + print "|"i"|"b[i]"|" + print "--asc ind num--" + PROCINFO["sorted_in"] = "@ind_num_asc" + for (i in b) + print "|"i"|"b[i]"|" + print "--asc val num--" + PROCINFO["sorted_in"] = "@val_num_asc" + for (i in b) + print "|"i"|"b[i]"|" +} diff --git a/test/arraysort.ok b/test/arraysort.ok new file mode 100644 index 0000000..d2d8ca7 --- /dev/null +++ b/test/arraysort.ok @@ -0,0 +1,83 @@ +--- test1 --- + 5 5 + 10 10 + 3D 3D +--- test2 --- +x 1 +y 1 +1 1 +100 1 +--- test3 --- +x 1 +1 1 +100 1 +--- test4 --- +0 1 +x 1 +1 1 +100 1 +--- test5 --- + 1 +0 1 +y 1 +--- test6 --- +"1" +"2" +"3 " +"4" +--- test7 --- +--unsorted-- +|4|4| +|5|5| +|D3|D3| +|3D|3D| +| 3| 3| +|0|0| +|1|1| +| 4 | 4 | +|2|2| +|3|3| +--asc ind str-- +| 3| 3| +| 4 | 4 | +|0|0| +|1|1| +|2|2| +|3|3| +|3D|3D| +|4|4| +|5|5| +|D3|D3| +--asc val str-- +| 3| 3| +| 4 | 4 | +|0|0| +|1|1| +|2|2| +|3|3| +|3D|3D| +|4|4| +|5|5| +|D3|D3| +--asc ind num-- +|0|0| +|D3|D3| +|1|1| +|2|2| +| 3| 3| +|3|3| +|3D|3D| +| 4 | 4 | +|4|4| +|5|5| +--asc val num-- +|0|0| +|D3|D3| +|1|1| +|2|2| +| 3| 3| +|3|3| +|3D|3D| +| 4 | 4 | +|4|4| +|5|5| diff --git a/test/arrymem1.awk b/test/arrymem1.awk new file mode 100644 index 0000000..0a4ae89 --- /dev/null +++ b/test/arrymem1.awk @@ -0,0 +1,81 @@ +# From spcecdt@armory.com Thu Jun 14 13:24:32 2001 +# Received: from mail.actcom.co.il [192.114.47.13] +# by localhost with POP3 (fetchmail-5.5.0) +# for arnold@localhost (single-drop); Thu, 14 Jun 2001 13:24:32 +0300 (IDT) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Thu Jun 14 13:25:13 2001) +# X-From_: spcecdt@armory.com Thu Jun 14 06:34:47 2001 +# Received: from lmail.actcom.co.il by actcom.co.il with ESMTP +# (8.9.1a/actcom-0.2) id GAA29661 for ; +# Thu, 14 Jun 2001 06:34:46 +0300 (EET DST) +# (rfc931-sender: lmail.actcom.co.il [192.114.47.13]) +# Received: from billohost.com (www.billohost.com [209.196.35.10]) +# by lmail.actcom.co.il (8.11.2/8.11.2) with ESMTP id f5E3YiO27337 +# for ; Thu, 14 Jun 2001 06:34:45 +0300 +# Received: from fencepost.gnu.org (we-refuse-to-spy-on-our-users@fencepost.gnu.org [199.232.76.164]) +# by billohost.com (8.9.3/8.9.3) with ESMTP id XAA02681 +# for ; Wed, 13 Jun 2001 23:33:57 -0400 +# Received: from deepthought.armory.com ([192.122.209.42]) +# by fencepost.gnu.org with smtp (Exim 3.16 #1 (Debian)) +# id 15ANu2-00005C-00 +# for ; Wed, 13 Jun 2001 23:34:38 -0400 +# Date: Wed, 13 Jun 2001 20:32:42 -0700 +# From: "John H. DuBois III" +# To: bug-gawk@gnu.org +# Subject: gawk 3.1.0 bug +# Message-ID: <20010613203242.A29975@armory.com> +# Mime-Version: 1.0 +# Content-Type: text/plain; charset=us-ascii +# X-Mailer: Mutt 1.0.1i +# X-Www: http://www.armory.com./~spcecdt/ +# Sender: spcecdt@armory.com +# Status: RO +# +# Under SCO OpenServer 5.0.6a using gawk 3.1.0 compiled with gcc 2.95.2, this +# program: + + BEGIN { + f1(Procs,b) + print "test" + } + + function f1(Procs,a) { + # a[""] + a[""] = "a" # ADR: Give it a value so can trace it + f2() + } + + function f2() { + # b[""] + b[""] = "b" # ADR: Give it a value so can trace it + } + + # ADR: 1/28/2003: Added this: + BEGIN { for (i in b) printf("b[\"%s\"] = \"%s\"\n", i, b[i]) } + # END ADR added. + +# gives: +# +# gawk: ./gtest:5: fatal error: internal error +# +# and dumps core. +# +# gdb gives me this stack backtrace: +# +# #0 0x80019943 in kill () from /usr/lib/libc.so.1 +# #1 0x8003e754 in abort () from /usr/lib/libc.so.1 +# #2 0x8062a87 in catchsig (sig=0, code=0) at main.c:947 +# #3 0x80053a0c in _sigreturn () from /usr/lib/libc.so.1 +# #4 0x80023d36 in cleanfree () from /usr/lib/libc.so.1 +# #5 0x80023156 in _real_malloc () from /usr/lib/libc.so.1 +# #6 0x80023019 in malloc () from /usr/lib/libc.so.1 +# #7 0x8053b95 in do_print (tree=0x0) at builtin.c:1336 +# #8 0x806b47c in interpret (tree=0x8084ee4) at eval.c:606 +# #9 0x806ad8d in interpret (tree=0x8084f0c) at eval.c:384 +# #10 0x806ad21 in interpret (tree=0x8084f5c) at eval.c:367 +# #11 0x8061d5b in main (argc=4, argv=0x80478ac) at main.c:506 +# +# John +# -- +# John DuBois spcecdt@armory.com. KC6QKZ/AE http://www.armory.com./~spcecdt/ +# diff --git a/test/arrymem1.ok b/test/arrymem1.ok new file mode 100644 index 0000000..e37775b --- /dev/null +++ b/test/arrymem1.ok @@ -0,0 +1,2 @@ +test +b[""] = "b" diff --git a/test/arryref2.awk b/test/arryref2.awk new file mode 100644 index 0000000..202a040 --- /dev/null +++ b/test/arryref2.awk @@ -0,0 +1,18 @@ +BEGIN { + foo(a) + + for (i in a) + print i, a[i] +} + +function foo(b) +{ + bar(b) + b[2] = "local" +} + +function bar(c) +{ + a[3] = "global" + c[1] = "local2" +} diff --git a/test/arryref2.ok b/test/arryref2.ok new file mode 100644 index 0000000..71aa9ed --- /dev/null +++ b/test/arryref2.ok @@ -0,0 +1,3 @@ +1 local2 +2 local +3 global diff --git a/test/arryref3.awk b/test/arryref3.awk new file mode 100644 index 0000000..e234ee5 --- /dev/null +++ b/test/arryref3.awk @@ -0,0 +1,18 @@ +BEGIN { + foo(a) + + for (i in a) + print i, a[i] +} + +function foo(b) +{ + a[1] = "global" + b[2] = "local" + bar(b) +} + +function bar(c) +{ + c = 12 +} diff --git a/test/arryref3.ok b/test/arryref3.ok new file mode 100644 index 0000000..eec04b6 --- /dev/null +++ b/test/arryref3.ok @@ -0,0 +1,2 @@ +gawk: arryref3.awk:17: fatal: attempt to use array `c (from b, from a)' in a scalar context +EXIT CODE: 2 diff --git a/test/arryref4.awk b/test/arryref4.awk new file mode 100644 index 0000000..072eade --- /dev/null +++ b/test/arryref4.awk @@ -0,0 +1,17 @@ +BEGIN { + foo(a) + + print a +} + +function foo(b) +{ + a = "global" + b[2] = "local" +# bar(b) +} + +function bar(c) +{ + c = 12 +} diff --git a/test/arryref4.ok b/test/arryref4.ok new file mode 100644 index 0000000..11cebfb --- /dev/null +++ b/test/arryref4.ok @@ -0,0 +1,2 @@ +gawk: arryref4.awk:10: fatal: attempt to use scalar parameter `b' as an array +EXIT CODE: 2 diff --git a/test/arryref5.awk b/test/arryref5.awk new file mode 100644 index 0000000..babff9c --- /dev/null +++ b/test/arryref5.awk @@ -0,0 +1,17 @@ +BEGIN { + foo(a) + + print a +} + +function foo(b) +{ + b[2] = "local" + a = "global" +# bar(b) +} + +function bar(c) +{ + c = 12 +} diff --git a/test/arryref5.ok b/test/arryref5.ok new file mode 100644 index 0000000..7b542fb --- /dev/null +++ b/test/arryref5.ok @@ -0,0 +1,2 @@ +gawk: arryref5.awk:10: fatal: attempt to use array `a' in a scalar context +EXIT CODE: 2 diff --git a/test/arynasty.awk b/test/arynasty.awk new file mode 100644 index 0000000..ec17093 --- /dev/null +++ b/test/arynasty.awk @@ -0,0 +1,16 @@ +BEGIN { + a = 12.153 +#print "-- stroring test[a]" > "/dev/stderr" ; fflush("/dev/stderr") + test[a] = "hi" +#print "-- setting CONVFMT" > "/dev/stderr" ; fflush("/dev/stderr") + CONVFMT = "%.0f" +#print "-- setting a" > "/dev/stderr" ; fflush("/dev/stderr") + a = 5 +#stopme() +#print "-- starting loop" > "/dev/stderr" ; fflush("/dev/stderr") + for (i in test) { +#print("-- i =", i) > "/dev/stderr" ; fflush("/dev/stderr"); +#printf("-- i = <%s>\n", i) > "/dev/stderr" ; fflush("/dev/stderr"); + printf ("test[%s] = %s\n", i, test[i]) + } +} diff --git a/test/arynasty.ok b/test/arynasty.ok new file mode 100644 index 0000000..125ed80 --- /dev/null +++ b/test/arynasty.ok @@ -0,0 +1 @@ +test[12.153] = hi diff --git a/test/arynocls.awk b/test/arynocls.awk new file mode 100644 index 0000000..724c9ac --- /dev/null +++ b/test/arynocls.awk @@ -0,0 +1,95 @@ +#To: bug-gnu-utils@gnu.org +#From: Kristján Jónasson +#Subject: Gawk bug +#Cc: arnold@gnu.org +# +#Hi! +# +#The following seems to be a bug in gawk. I have tried as I could to +#minimize the bug-causing program, so of course it does not seem to do +#anything useful in its present form. The error message received is: +# +#gawk: test.awk:15: fatal error: internal error +#Aborted +# +#Note that there is an attached file that the program reads, called "a". I +#played with the program a fair bit and my feeling is that the error is +#related with the delete statement, and not the reading of the file and the +#close statement. At one point I was able to remove the file reading and +#still obtain the error. If, for example, I remove the close statement and +#make two copies of the file instead, (reading one copy in sub1 and the +#other in sub2), the error still occurs. +# +#The operating system is Red Hat Linux, version 6.0, the gawk is version +#3.0.4, and the gawk was obtained from an rpm file gawk-3.0.4-1.i386.rpm. +# +#The program is: +# + +# Wed Mar 8 13:41:34 IST 2000 +# ADR: modified to use INPUT, so can set it from command line. +# When run, no output is produced, but it shouldn't core +# dump, either. +# +# The program bug is to not close the file in sub2. + +function sub1(x) { +# while (getline < "a" == 1) i++ + while (getline < INPUT == 1) i++ +# close("a") + close(INPUT) +} + +function sub2(x) { + i=0 + delete y +# while (getline < "a" == 1) z[++i] = $1 + while (getline < INPUT == 1) z[++i] = $1 + for(i in z) y[i] = x[i] + z[i] +} + +function sub3(x, y, z) { + sub2(x) + for(i=1; i<=4; i++) z[i] = y[i] +} + +BEGIN { + sub1(x) + sub2(x) + sub3(x, y, z) +} +# +#And the data file is: +# +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# 32.440 3.830 3.383700000000000 10.08 298 865 +# +# diff --git a/test/arynocls.in b/test/arynocls.in new file mode 100644 index 0000000..8f4712c --- /dev/null +++ b/test/arynocls.in @@ -0,0 +1,30 @@ + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 + 32.440 3.830 3.383700000000000 10.08 298 865 diff --git a/test/arynocls.ok b/test/arynocls.ok new file mode 100644 index 0000000..e69de29 diff --git a/test/aryprm1.awk b/test/aryprm1.awk new file mode 100644 index 0000000..e5bb991 --- /dev/null +++ b/test/aryprm1.awk @@ -0,0 +1,9 @@ +function f(a) { + if (3 in a) + print 7 + a = 5 +} + +BEGIN { + f(arr) +} diff --git a/test/aryprm1.ok b/test/aryprm1.ok new file mode 100644 index 0000000..99ffd8f --- /dev/null +++ b/test/aryprm1.ok @@ -0,0 +1,2 @@ +gawk: aryprm1.awk:4: fatal: attempt to use array `a (from arr)' in a scalar context +EXIT CODE: 2 diff --git a/test/aryprm2.awk b/test/aryprm2.awk new file mode 100644 index 0000000..00dd763 --- /dev/null +++ b/test/aryprm2.awk @@ -0,0 +1,8 @@ +function f(a) { + delete a + a *= 5 +} + +BEGIN { + f(arr) +} diff --git a/test/aryprm2.ok b/test/aryprm2.ok new file mode 100644 index 0000000..c8585c9 --- /dev/null +++ b/test/aryprm2.ok @@ -0,0 +1,2 @@ +gawk: aryprm2.awk:3: fatal: attempt to use array `a (from arr)' in a scalar context +EXIT CODE: 2 diff --git a/test/aryprm3.awk b/test/aryprm3.awk new file mode 100644 index 0000000..c38ab58 --- /dev/null +++ b/test/aryprm3.awk @@ -0,0 +1,10 @@ +function f(a, i) { + for (i in a) + delete a[i] + if (a == 0) + print 7 +} + +BEGIN { + f(arr) +} diff --git a/test/aryprm3.ok b/test/aryprm3.ok new file mode 100644 index 0000000..a855dea --- /dev/null +++ b/test/aryprm3.ok @@ -0,0 +1,2 @@ +gawk: aryprm3.awk:4: fatal: attempt to use array `a (from arr)' in a scalar context +EXIT CODE: 2 diff --git a/test/aryprm4.awk b/test/aryprm4.awk new file mode 100644 index 0000000..09427f6 --- /dev/null +++ b/test/aryprm4.awk @@ -0,0 +1,7 @@ +function f(x){ + x = 1 +} +BEGIN { + f(a) + a[1] +} diff --git a/test/aryprm4.ok b/test/aryprm4.ok new file mode 100644 index 0000000..31c49c6 --- /dev/null +++ b/test/aryprm4.ok @@ -0,0 +1,2 @@ +gawk: aryprm4.awk:6: fatal: attempt to use scalar `a' as an array +EXIT CODE: 2 diff --git a/test/aryprm5.awk b/test/aryprm5.awk new file mode 100644 index 0000000..a4aac36 --- /dev/null +++ b/test/aryprm5.awk @@ -0,0 +1,6 @@ +function f(x){ + x[1] = x +} +BEGIN { + f(a) +} diff --git a/test/aryprm5.ok b/test/aryprm5.ok new file mode 100644 index 0000000..1ce4119 --- /dev/null +++ b/test/aryprm5.ok @@ -0,0 +1,2 @@ +gawk: aryprm5.awk:2: fatal: attempt to use scalar parameter `x' as an array +EXIT CODE: 2 diff --git a/test/aryprm6.awk b/test/aryprm6.awk new file mode 100644 index 0000000..b12b278 --- /dev/null +++ b/test/aryprm6.awk @@ -0,0 +1,7 @@ +function f(x){ + a + x[1] = 3 +} +BEGIN { + f(a) +} diff --git a/test/aryprm6.ok b/test/aryprm6.ok new file mode 100644 index 0000000..8561ddf --- /dev/null +++ b/test/aryprm6.ok @@ -0,0 +1,2 @@ +gawk: aryprm6.awk:3: fatal: attempt to use scalar parameter `x' as an array +EXIT CODE: 2 diff --git a/test/aryprm7.awk b/test/aryprm7.awk new file mode 100644 index 0000000..b442b4d --- /dev/null +++ b/test/aryprm7.awk @@ -0,0 +1,6 @@ +function f(x, y){ + y[1] = x +} +BEGIN { + f(a, a) +} diff --git a/test/aryprm7.ok b/test/aryprm7.ok new file mode 100644 index 0000000..00e2896 --- /dev/null +++ b/test/aryprm7.ok @@ -0,0 +1,2 @@ +gawk: aryprm7.awk:2: fatal: attempt to use scalar parameter `y' as an array +EXIT CODE: 2 diff --git a/test/aryprm8.awk b/test/aryprm8.awk new file mode 100644 index 0000000..b294abb --- /dev/null +++ b/test/aryprm8.awk @@ -0,0 +1,22 @@ +BEGIN { + f(0, a) # nothing + f(1, a) +} +function f(i, a) { + if (i == 0) return + g(a, a) + pr(a) +} +function g(x, y) { + h(y, x, y) +} +function h(b, c, d) { + b[1] = 1 + c[1] = 2 # rewrite + print b[1], d[1] + c[2] = 1 + b[2] = 2 # should rewrite +} +function pr(x) { + print x[1], x[2] +} diff --git a/test/aryprm8.ok b/test/aryprm8.ok new file mode 100644 index 0000000..fad54c2 --- /dev/null +++ b/test/aryprm8.ok @@ -0,0 +1,2 @@ +2 2 +2 2 diff --git a/test/arysubnm.awk b/test/arysubnm.awk new file mode 100644 index 0000000..961b54a --- /dev/null +++ b/test/arysubnm.awk @@ -0,0 +1 @@ +BEGIN { n = 11 ; foo[n] = n; print (2 <= n) } diff --git a/test/arysubnm.ok b/test/arysubnm.ok new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/test/arysubnm.ok @@ -0,0 +1 @@ +1 diff --git a/test/asgext.awk b/test/asgext.awk new file mode 100644 index 0000000..c7f1775 --- /dev/null +++ b/test/asgext.awk @@ -0,0 +1 @@ +{ print $3; $4 = "a"; print } diff --git a/test/asgext.in b/test/asgext.in new file mode 100644 index 0000000..3743b5b --- /dev/null +++ b/test/asgext.in @@ -0,0 +1,3 @@ +1 2 3 +1 +1 2 3 4 diff --git a/test/asgext.ok b/test/asgext.ok new file mode 100644 index 0000000..2c0df70 --- /dev/null +++ b/test/asgext.ok @@ -0,0 +1,6 @@ +3 +1 2 3 a + +1 a +3 +1 2 3 a diff --git a/test/asort.awk b/test/asort.awk new file mode 100644 index 0000000..8a42e26 --- /dev/null +++ b/test/asort.awk @@ -0,0 +1,25 @@ +function init(a) +{ + a[1] = "aardvark" + a[2] = "animal" + a[3] = "zebra" + a[4] = "zoo" + a[5] = "Iguana" + a[6] = "Alligator" + a[7] = "Nouns" + a[8] = "people" +} + +BEGIN { + + for (IGNORECASE = 0; IGNORECASE < 2; IGNORECASE++) { + init(a) + + n = asort(a) + + for (i = 1; i <= n; i++) + printf("a[%d] = \"%s\"\n", i, a[i]) + + print "============" + } +} diff --git a/test/asort.ok b/test/asort.ok new file mode 100644 index 0000000..1d0ddd0 --- /dev/null +++ b/test/asort.ok @@ -0,0 +1,18 @@ +a[1] = "Alligator" +a[2] = "Iguana" +a[3] = "Nouns" +a[4] = "aardvark" +a[5] = "animal" +a[6] = "people" +a[7] = "zebra" +a[8] = "zoo" +============ +a[1] = "aardvark" +a[2] = "Alligator" +a[3] = "animal" +a[4] = "Iguana" +a[5] = "Nouns" +a[6] = "people" +a[7] = "zebra" +a[8] = "zoo" +============ diff --git a/test/asorti.awk b/test/asorti.awk new file mode 100644 index 0000000..3314c9f --- /dev/null +++ b/test/asorti.awk @@ -0,0 +1,27 @@ +function init(a) +{ + delete a + + a["aardvark"] = 1 + a["animal"] = 2 + a["zebra"] = 3 + a["zoo"] = 4 + a["Iguana"] = 5 + a["Alligator"] = 6 + a["Nouns"] = 7 + a["people"] = 8 +} + +BEGIN { + + for (IGNORECASE = 0; IGNORECASE < 2; IGNORECASE++) { + init(a) + + n = asorti(a) + + for (i = 1; i <= n; i++) + printf("a[%d] = \"%s\"\n", i, a[i]) + + print "============" + } +} diff --git a/test/asorti.ok b/test/asorti.ok new file mode 100644 index 0000000..1d0ddd0 --- /dev/null +++ b/test/asorti.ok @@ -0,0 +1,18 @@ +a[1] = "Alligator" +a[2] = "Iguana" +a[3] = "Nouns" +a[4] = "aardvark" +a[5] = "animal" +a[6] = "people" +a[7] = "zebra" +a[8] = "zoo" +============ +a[1] = "aardvark" +a[2] = "Alligator" +a[3] = "animal" +a[4] = "Iguana" +a[5] = "Nouns" +a[6] = "people" +a[7] = "zebra" +a[8] = "zoo" +============ diff --git a/test/awkpath.ok b/test/awkpath.ok new file mode 100644 index 0000000..6cffe1b --- /dev/null +++ b/test/awkpath.ok @@ -0,0 +1 @@ +Found it. diff --git a/test/back89.awk b/test/back89.awk new file mode 100644 index 0000000..0da3362 --- /dev/null +++ b/test/back89.awk @@ -0,0 +1 @@ +/a\8b/ diff --git a/test/back89.in b/test/back89.in new file mode 100644 index 0000000..b0a88f2 --- /dev/null +++ b/test/back89.in @@ -0,0 +1,2 @@ +a8b +a\8b diff --git a/test/back89.ok b/test/back89.ok new file mode 100644 index 0000000..e9ea4d5 --- /dev/null +++ b/test/back89.ok @@ -0,0 +1 @@ +a8b diff --git a/test/backgsub.awk b/test/backgsub.awk new file mode 100644 index 0000000..bec7354 --- /dev/null +++ b/test/backgsub.awk @@ -0,0 +1,4 @@ +{ + gsub( "\\\\", "\\\\") + print +} diff --git a/test/backgsub.in b/test/backgsub.in new file mode 100644 index 0000000..2d3f17f --- /dev/null +++ b/test/backgsub.in @@ -0,0 +1 @@ +\x\y\z diff --git a/test/backgsub.ok b/test/backgsub.ok new file mode 100644 index 0000000..e2e265f --- /dev/null +++ b/test/backgsub.ok @@ -0,0 +1 @@ +\\x\\y\\z diff --git a/test/backw.awk b/test/backw.awk new file mode 100644 index 0000000..078a5d8 --- /dev/null +++ b/test/backw.awk @@ -0,0 +1 @@ +/\w+/ diff --git a/test/backw.in b/test/backw.in new file mode 100644 index 0000000..ec09f60 --- /dev/null +++ b/test/backw.in @@ -0,0 +1,3 @@ +123 +abc +456 diff --git a/test/backw.ok b/test/backw.ok new file mode 100644 index 0000000..ec09f60 --- /dev/null +++ b/test/backw.ok @@ -0,0 +1,3 @@ +123 +abc +456 diff --git a/test/badargs.ok b/test/badargs.ok new file mode 100644 index 0000000..66e67b0 --- /dev/null +++ b/test/badargs.ok @@ -0,0 +1,36 @@ +gawk: option requires an argument -- f +Usage: gawk [POSIX or GNU style options] -f progfile [--] file ... +Usage: gawk [POSIX or GNU style options] [--] 'program' file ... +POSIX options: GNU long options: (standard) + -f progfile --file=progfile + -F fs --field-separator=fs + -v var=val --assign=var=val +Short options: GNU long options: (extensions) + -b --characters-as-bytes + -c --traditional + -C --copyright + -d[file] --dump-variables[=file] + -e 'program-text' --source='program-text' + -E file --exec=file + -g --gen-pot + -h --help + -L [fatal] --lint[=fatal] + -n --non-decimal-data + -N --use-lc-numeric + -O --optimize + -p[file] --profile[=file] + -P --posix + -r --re-interval + -S --sandbox + -t --lint-old + -V --version + +To report bugs, see node `Bugs' in `gawk.info', which is +section `Reporting Problems and Bugs' in the printed version. + +gawk is a pattern scanning and processing language. +By default it reads standard input and writes standard output. + +Examples: + gawk '{ sum += $1 }; END { print sum }' file + gawk -F: '{ print $1 }' /etc/passwd diff --git a/test/beginfile1.awk b/test/beginfile1.awk new file mode 100644 index 0000000..0cd148b --- /dev/null +++ b/test/beginfile1.awk @@ -0,0 +1,19 @@ +BEGINFILE { + print "In BEGINFILE:" + filename = FILENAME + gsub(/.*[/]/, "", filename) + printf "\tFILENAME = %s, FNR = %d, ERRNO = \"%s\"\n", filename, FNR, ERRNO + + if (ERRNO != "") + nextfile +} + +FNR == 1 { print "processing", filename } +FNR > 1 { nextfile } + +ENDFILE { + print "In ENDFILE:" + filename = FILENAME + gsub(/.*[/]/, "", filename) + printf "\tFILENAME = %s, FNR = %d, ERRNO = \"%s\"\n", filename, FNR, ERRNO +} diff --git a/test/beginfile1.ok b/test/beginfile1.ok new file mode 100644 index 0000000..1318c7d --- /dev/null +++ b/test/beginfile1.ok @@ -0,0 +1,14 @@ +In BEGINFILE: + FILENAME = beginfile1.awk, FNR = 0, ERRNO = "" +processing beginfile1.awk +In ENDFILE: + FILENAME = beginfile1.awk, FNR = 2, ERRNO = "" +In BEGINFILE: + FILENAME = ., FNR = 0, ERRNO = "Is a directory" +In BEGINFILE: + FILENAME = file, FNR = 0, ERRNO = "No such file or directory" +In BEGINFILE: + FILENAME = Makefile, FNR = 0, ERRNO = "" +processing Makefile +In ENDFILE: + FILENAME = Makefile, FNR = 2, ERRNO = "" diff --git a/test/beginfile2.in b/test/beginfile2.in new file mode 100644 index 0000000..34043e7 --- /dev/null +++ b/test/beginfile2.in @@ -0,0 +1,242 @@ +#TEST1# +BEGINFILE { + print "In BEGINFILE:", FILENAME +} +BEGIN { + count = 0 + print "In BEGIN" + while (getline > 0) + count++; + print count == NR +} + +#TEST2# +BEGINFILE { + print "In BEGINFILE:", FILENAME + nextfile +} +ENDFILE{ + print "In ENDFILE:", FILENAME +} + + +#TEST3# +BEGINFILE { + print "In BEGINFILE:", FILENAME +} +END { + print "executing END rule" + ARGV[ARGC++] = src; + count = 0 + while (getline> 0) + count++; + print count == FNR + print "Done executing END rule" +} +ENDFILE { + print "In ENDFILE:", FILENAME +} + +#TEST4# +BEGINFILE { + print "In BEGINFILE:", FILENAME + nextfile +} +END { + print "executing END rule" + ARGV[ARGC++] = src; + getline + print $0 + print "Done executing END rule" +} +ENDFILE { + print "ENDFILE:", FILENAME +} + + +#TEST5# +BEGIN { + getline + count++ + print NR, count +} +{ + count++ +} +END { + print NR == count +} + +#TEST6# +BEGINFILE { + print "In BEGINFILE:", FILENAME + count = 0 +} +BEGIN { + getline + count++ + print FNR, count +} +{ + count++ +} +ENDFILE { + print "In ENDFILE:", FILENAME + print count == FNR +} + +#TEST7# +BEGINFILE { + print "In BEGINFILE:", FILENAME + count = 0 + if (ARGIND == 1) + nextfile +} +BEGIN { + getline + print "In BEGIN:", FILENAME +} +{ count++ } +ENDFILE { + print "In ENDFILE:", FILENAME + print (FNR - count) +} + +#TEST8# +function f(a, b) { + getline + print FILENAME + print a, b +} +function g(x, y) { + return x +} +BEGINFILE { nextfile } +BEGIN { g(3, f(1, 2)) } + +#TEST9# +function f(a, b) { + b = b ":" a; + if (skip || ERRNO != "") { + print "Skipping:", b + nextfile + } + return b +} +BEGINFILE { print "In BEGINFILE:", f(FILENAME, ++i)} +FNR == 1 { print "In Rule:", FILENAME } +ENDFILE { print "In ENDFILE:", FILENAME } + +#TEST10# +function f() { + nextfile +} +function g( cnt) { + cnt = 0 + while (getline > 0) + cnt++; + return cnt +} +BEGINFILE { if (ARGIND == 1) f(); } +BEGIN { + print g(), NR +} + +#TEST11# +function f(a, b) { + print a + nextfile + print b +} +function g(x, y) { + print x + getline + return y +} +BEGINFILE { ARGIND == 1 ? g(3, f(FILENAME, 2)) : f(3, g(FILENAME, 2)) } + +#TEST12# +BEGINFILE { + print "In BEGINFILE:", FILENAME +} +function g() { + nextfile +} +function f( cnt) { + print cnt + 0 + while (getline > 0) { + if (++cnt == 2) { + g() + print "shouldn't see this line" + } + } +} +{ + print FNR + f() +} +ENDFILE { + print "In ENDFILE:", FILENAME +} + +#TEST13# +# exit in BEGINFILE +BEGINFILE { + print "In BEGINFILE:", FILENAME + exit(0) +} +ENDFILE { + print "In ENDFILE:", FILENAME +} +END { + print "In END:", FILENAME + while (getline > 0) + ; + print "shouldn't see this line" +} + +#TEST14# +# exit in ENDFILE +BEGINFILE { + print "In BEGINFILE:", FILENAME +} +ENDFILE { + print "In ENDFILE:", FILENAME + exit(0) +} +END { + print "In END:", FILENAME + while (getline > 0) + ; + print "shouldn't see this line" +} + +#TEST15# +BEGINFILE { + print "BEGINFILE:", FILENAME +} +{ nextfile } +END { + print NR +} + +#TEST16# +BEGINFILE { + print "In BEGINFILE:", FILENAME +} +BEGIN { + getline + print "In BEGIN:", FILENAME +} +{ + if (NR == FNR) { + print "In Rule:", FILENAME + nextfile + } + exit(0) +} + +ENDFILE { + print "In ENDFILE: ", FILENAME +} + diff --git a/test/beginfile2.ok b/test/beginfile2.ok new file mode 100644 index 0000000..2d872ea --- /dev/null +++ b/test/beginfile2.ok @@ -0,0 +1,93 @@ +--Test 1a-- +In BEGIN +In BEGINFILE: beginfile2.in +1 +--Test 1b-- +In BEGIN +In BEGINFILE: beginfile2.in +In BEGINFILE: /file/does/not/exist +gawk: cmd. line:3: fatal: cannot open file `/file/does/not/exist' for reading (No such file or directory) +--Test 2-- +In BEGINFILE: beginfile2.in +In ENDFILE: beginfile2.in +In BEGINFILE: /file/does/not/exist +--Test 3-- +In BEGINFILE: beginfile2.in +In ENDFILE: beginfile2.in +executing END rule +In BEGINFILE: beginfile2.sh +In ENDFILE: beginfile2.sh +1 +Done executing END rule +--Test 4-- +In BEGINFILE: beginfile2.in +ENDFILE: beginfile2.in +executing END rule +In BEGINFILE: beginfile2.sh +ENDFILE: beginfile2.sh + +Done executing END rule +--Test 5-- +1 1 +1 +--Test 6-- +In BEGINFILE: beginfile2.in +1 1 +In ENDFILE: beginfile2.in +1 +--Test 7-- +In BEGINFILE: beginfile2.in +In ENDFILE: beginfile2.in +0 +In BEGINFILE: beginfile2.sh +In BEGIN: beginfile2.sh +In ENDFILE: beginfile2.sh +1 +--Test 8-- +beginfile2.in +1 2 +--Test 9a-- +Skipping: 1:/file/does/not/exist +In BEGINFILE: 2:beginfile2.in +In Rule: beginfile2.in +In ENDFILE: beginfile2.in +--Test 9b-- +Skipping: 1:/file/does/not/exist +Skipping: 2:beginfile2.in +In ENDFILE: beginfile2.in +--Test 10-- +82 82 +--Test 11-- +beginfile2.in +beginfile2.sh +gawk: cmd. line:9: fatal: non-redirected `getline' invalid inside `BEGINFILE' rule +--Test 12-- +In BEGINFILE: beginfile2.in +1 +0 +In ENDFILE: beginfile2.in +In BEGINFILE: beginfile2.sh +1 +0 +In ENDFILE: beginfile2.sh +--Test 13-- +In BEGINFILE: beginfile2.in +In END: beginfile2.in +In ENDFILE: beginfile2.in +In BEGINFILE: beginfile2.sh +--Test 14-- +In BEGINFILE: beginfile2.in +In ENDFILE: beginfile2.in +In END: beginfile2.in +In BEGINFILE: beginfile2.sh +In ENDFILE: beginfile2.sh +--Test 15-- +BEGINFILE: beginfile2.in +BEGINFILE: beginfile2.sh +2 +--Test 16-- +In BEGINFILE: beginfile2.in +In BEGIN: beginfile2.in +In Rule: beginfile2.in +In ENDFILE: beginfile2.in +In BEGINFILE: beginfile2.sh diff --git a/test/beginfile2.sh b/test/beginfile2.sh new file mode 100755 index 0000000..6916120 --- /dev/null +++ b/test/beginfile2.sh @@ -0,0 +1,82 @@ +#!/bin/sh + +# beginfile2.sh --- test BEGINFILE/ENDFILE/getline/nextfile/exit combinations + +#AWK="../gawk" +AWKPROG="beginfile2.in" +SCRIPT=`basename $0` + +if [ "$AWK" = "" ] +then + echo $0: You must set AWK >&2 + exit 1 +fi + +echo "--Test 1a--" +prog=`$AWK '/#TEST1#/, /#TEST2#/' $AWKPROG` +$AWK "$prog" $AWKPROG +echo "--Test 1b--" +$AWK "$prog" $AWKPROG /file/does/not/exist + +echo "--Test 2--" +prog=`$AWK '/#TEST2#/, /#TEST3#/' $AWKPROG` +$AWK "$prog" $AWKPROG /file/does/not/exist + +echo "--Test 3--" +prog=`$AWK '/#TEST3#/, /#TEST4#/' $AWKPROG` +$AWK -vsrc=$SCRIPT "$prog" $AWKPROG + +echo "--Test 4--" +prog=`$AWK '/#TEST4#/, /#TEST5#/' $AWKPROG` +$AWK -vsrc=$SCRIPT "$prog" $AWKPROG + +echo "--Test 5--" +prog=`$AWK '/#TEST5#/, /#TEST6#/' $AWKPROG` +$AWK "$prog" $AWKPROG + +echo "--Test 6--" +prog=`$AWK '/#TEST6#/, /#TEST7#/' $AWKPROG` +$AWK "$prog" $AWKPROG + +echo "--Test 7--" +prog=`$AWK '/#TEST7#/, /#TEST8#/' $AWKPROG` +$AWK "$prog" $AWKPROG $SCRIPT + +echo "--Test 8--" +prog=`$AWK '/#TEST8#/, /#TEST9#/' $AWKPROG` +$AWK "$prog" $AWKPROG + +echo "--Test 9a--" +prog=`$AWK '/#TEST9#/, /#TEST10#/' $AWKPROG` +$AWK "$prog" /file/does/not/exist $AWKPROG +echo "--Test 9b--" +$AWK -vskip=1 "$prog" /file/does/not/exist $AWKPROG + +echo "--Test 10--" +prog=`$AWK '/#TEST10#/, /#TEST11#/' $AWKPROG` +$AWK "$prog" $AWKPROG $SCRIPT + +echo "--Test 11--" +prog=`$AWK '/#TEST11#/, /#TEST12#/' $AWKPROG` +$AWK "$prog" $AWKPROG $SCRIPT + +echo "--Test 12--" +prog=`$AWK '/#TEST12#/, /#TEST13#/' $AWKPROG` +$AWK "$prog" $AWKPROG $SCRIPT + +echo "--Test 13--" +prog=`$AWK '/#TEST13#/, /#TEST14#/' $AWKPROG` +$AWK "$prog" $AWKPROG $SCRIPT + +echo "--Test 14--" +prog=`$AWK '/#TEST14#/, /#TEST15#/' $AWKPROG` +$AWK "$prog" $AWKPROG $SCRIPT + +echo "--Test 15--" +prog=`$AWK '/#TEST15#/, /#TEST16#/' $AWKPROG` +$AWK "$prog" $AWKPROG $SCRIPT + +echo "--Test 16--" +prog=`$AWK '/#TEST16#/, /#TEST17#/' $AWKPROG` +$AWK "$prog" $AWKPROG $SCRIPT + diff --git a/test/binmode1.ok b/test/binmode1.ok new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/test/binmode1.ok @@ -0,0 +1 @@ +3 diff --git a/test/childin.awk b/test/childin.awk new file mode 100644 index 0000000..041c6ec --- /dev/null +++ b/test/childin.awk @@ -0,0 +1 @@ +BEGIN { "cat" | getline; print; close("cat") } diff --git a/test/childin.in b/test/childin.in new file mode 100644 index 0000000..45b983b --- /dev/null +++ b/test/childin.in @@ -0,0 +1 @@ +hi diff --git a/test/childin.ok b/test/childin.ok new file mode 100644 index 0000000..45b983b --- /dev/null +++ b/test/childin.ok @@ -0,0 +1 @@ +hi diff --git a/test/clobber.awk b/test/clobber.awk new file mode 100644 index 0000000..6526de0 --- /dev/null +++ b/test/clobber.awk @@ -0,0 +1,98 @@ +BEGIN { + print "000800" > "seq" + close("seq") + ARGV[1] = "seq" + ARGC = 2 +} + +{ printf "%06d", $1 + 1 >"seq"; + printf "%06d", $1 + 1 } +# Date: Mon, 20 Jan 1997 15:14:06 -0600 (CST) +# From: Dave Bodenstab +# To: bug-gnu-utils@prep.ai.mit.edu +# Subject: GNU awk 3.0.2 core dump +# Cc: arnold@gnu.ai.mit.edu +# +# The following program produces a core file on my FreeBSD system: +# +# bash$ echo 000800 >/tmp/seq +# bash$ gawk '{ printf "%06d", $1 + 1 >"/tmp/seq"; +# printf "%06d", $1 + 1 }' /tmp/seq +# +# This fragment comes from mgetty+sendfax. +# +# Here is the trace: +# +# Script started on Mon Jan 20 15:09:04 1997 +# bash$ gawk --version +# GNU Awk 3.0.2 +# Copyright (C) 1989, 1991-1996 Free Software Foundation. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# bash$ gdb gawk +# GDB is free software and you are welcome to distribute copies of it +# under certain conditions; type "show copying" to see the conditions. +# There is absolutely no warranty for GDB; type "show warranty" for details. +# GDB 4.13 (i386-unknown-freebsd), +# Copyright 1994 Free Software Foundation, Inc... +# (gdb) shell echo 000800 >/tmp/seq +# (gdb) r '{ printf "%06d", $1 + 1 >"/tmp/seq"; printf "%06d", $1 + 1 }(gdb) r '{ printf "%06d", $1 + 1 >"/tmp/seq"; printf "%06d", $1 + 1 }' /tmp/seq +# Starting program: /scratch/archive/src/cmd/gnuawk-3.0.2/gawk '{ printf "%06d", $1 + 1 >"/tmp/seq"; printf "%06d", $1 + 1 }' /tmp/seq +# +# Program received signal SIGBUS, Bus error. +# 0xd86f in def_parse_field (up_to=1, buf=0x37704, len=6, fs=0x3b240, rp=0x0, +# set=0xce6c , n=0x0) at field.c:391 +# 391 sav = *end; +# (gdb) bt +# #0 0xd86f in def_parse_field (up_to=1, buf=0x37704, len=6, fs=0x3b240, +# rp=0x0, set=0xce6c , n=0x0) at field.c:391 +# #1 0xddb1 in get_field (requested=1, assign=0x0) at field.c:669 +# #2 0xc25d in r_get_lhs (ptr=0x3b9b4, assign=0x0) at eval.c:1339 +# #3 0x9ab0 in r_tree_eval (tree=0x3b9b4, iscond=0) at eval.c:604 +# #4 0xa5f1 in r_tree_eval (tree=0x3b9fc, iscond=0) at eval.c:745 +# #5 0x4661 in format_tree (fmt_string=0x3e040 "%06d", n0=0, carg=0x3ba20) +# at builtin.c:620 +# #6 0x5beb in do_sprintf (tree=0x3b96c) at builtin.c:809 +# #7 0x5cd5 in do_printf (tree=0x3ba8c) at builtin.c:844 +# #8 0x9271 in interpret (tree=0x3ba8c) at eval.c:465 +# #9 0x8ca3 in interpret (tree=0x3bbd0) at eval.c:308 +# #10 0x8c34 in interpret (tree=0x3bc18) at eval.c:292 +# #11 0xf069 in do_input () at io.c:312 +# #12 0x12ba9 in main (argc=3, argv=0xefbfd538) at main.c:393 +# (gdb) l +# 386 *buf += len; +# 387 return nf; +# 388 } +# 389 +# 390 /* before doing anything save the char at *end */ +# 391 sav = *end; +# 392 /* because it will be destroyed now: */ +# 393 +# 394 *end = ' '; /* sentinel character */ +# 395 for (; nf < up_to; scan++) { +# (gdb) print end +# $1 = 0x804d006 +# (gdb) print buf +# $2 = (char **) 0x37704 +# (gdb) print *buf +# $3 = 0x804d000 +# (gdb) q +# The program is running. Quit anyway (and kill it)? (y or n) y +# bash$ exit +# +# Script done on Mon Jan 20 15:11:07 1997 +# +# Dave Bodenstab +# imdave@synet.net diff --git a/test/clobber.ok b/test/clobber.ok new file mode 100644 index 0000000..7105708 --- /dev/null +++ b/test/clobber.ok @@ -0,0 +1 @@ +000801 \ No newline at end of file diff --git a/test/clos1way.awk b/test/clos1way.awk new file mode 100644 index 0000000..5bc4068 --- /dev/null +++ b/test/clos1way.awk @@ -0,0 +1,21 @@ +BEGIN { + command = "LC_ALL=C sort" + + n = split("abcdefghijklmnopqrstuvwxyz", a, "") + for (i = n; i > 0; i--) { +# print "printing", a[i] > "/dev/stderr" + print a[i] |& command + } + + close(command, "to") + +# print "starting read loop" > "/dev/stderr" + do { + if (line) + print "got", line +# stopme(); + } while ((command |& getline line) > 0) + +# print "doing final close" > "/dev/stderr" + close(command) +} diff --git a/test/clos1way.ok b/test/clos1way.ok new file mode 100644 index 0000000..09d732a --- /dev/null +++ b/test/clos1way.ok @@ -0,0 +1,26 @@ +got a +got b +got c +got d +got e +got f +got g +got h +got i +got j +got k +got l +got m +got n +got o +got p +got q +got r +got s +got t +got u +got v +got w +got x +got y +got z diff --git a/test/closebad.awk b/test/closebad.awk new file mode 100644 index 0000000..83133ae --- /dev/null +++ b/test/closebad.awk @@ -0,0 +1,7 @@ +BEGIN { + f = "/no/such/file/1" + print (getline junk < f) + print close(f) + f = "/no/such/file/2" + print close(f) +} diff --git a/test/closebad.ok b/test/closebad.ok new file mode 100644 index 0000000..64861d8 --- /dev/null +++ b/test/closebad.ok @@ -0,0 +1,3 @@ +-1 +-1 +-1 diff --git a/test/clsflnam.awk b/test/clsflnam.awk new file mode 100644 index 0000000..0ba601f --- /dev/null +++ b/test/clsflnam.awk @@ -0,0 +1,12 @@ +#! /usr/bin/awk -f +BEGIN { + getline +# print ("FILENAME =", FILENAME) > "/dev/stderr" + #Rewind the file + if (close(FILENAME)) { + print "Error `" ERRNO "' closing input file" > "/dev/stderr"; + exit; + } +} +{ print "Analysing ", $0 } + diff --git a/test/clsflnam.in b/test/clsflnam.in new file mode 100644 index 0000000..a92d664 --- /dev/null +++ b/test/clsflnam.in @@ -0,0 +1,3 @@ +line 1 +line 2 +line 3 diff --git a/test/clsflnam.ok b/test/clsflnam.ok new file mode 100644 index 0000000..9addfc7 --- /dev/null +++ b/test/clsflnam.ok @@ -0,0 +1 @@ +Error `close of redirection that was never opened' closing input file diff --git a/test/compare.awk b/test/compare.awk new file mode 100644 index 0000000..39a88f3 --- /dev/null +++ b/test/compare.awk @@ -0,0 +1,13 @@ +BEGIN { + if (ARGV[1]) print 1 + ARGV[1] = "" + if (ARGV[2]) print 2 + ARGV[2] = "" + if ("0") print "zero" + if ("") print "null" + if (0) print 0 +} +{ + if ($0) print $0 + if ($1) print $1 +} diff --git a/test/compare.in b/test/compare.in new file mode 100644 index 0000000..1ab098b --- /dev/null +++ b/test/compare.in @@ -0,0 +1,4 @@ +0 +1 +0 1 + diff --git a/test/compare.ok b/test/compare.ok new file mode 100644 index 0000000..8241359 --- /dev/null +++ b/test/compare.ok @@ -0,0 +1,5 @@ +2 +zero +1 +1 +0 1 diff --git a/test/compare2.awk b/test/compare2.awk new file mode 100644 index 0000000..f2c2786 --- /dev/null +++ b/test/compare2.awk @@ -0,0 +1,165 @@ +# From beebe@math.utah.edu Thu Aug 2 15:35:07 2001 +# Received: from mail.actcom.co.il [192.114.47.13] +# by localhost with POP3 (fetchmail-5.7.4) +# for arnold@localhost (single-drop); Thu, 02 Aug 2001 15:35:07 +0300 (IDT) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Thu Aug 2 16:02:36 2001) +# X-From_: beebe@sunshine.math.utah.edu Thu Aug 2 15:41:13 2001 +# Received: from lmail.actcom.co.il by actcom.co.il with ESMTP +# (8.9.1a/actcom-0.2) id PAA01349 for ; +# Thu, 2 Aug 2001 15:41:06 +0300 (EET DST) +# (rfc931-sender: mail.actcom.co.il [192.114.47.13]) +# Received: from billohost.com (www.billohost.com [209.196.35.10]) +# by lmail.actcom.co.il (8.11.2/8.11.2) with ESMTP id f72Cf3I21032 +# for ; Thu, 2 Aug 2001 15:41:05 +0300 +# Received: from fencepost.gnu.org (we-refuse-to-spy-on-our-users@fencepost.gnu.org [199.232.76.164]) +# by billohost.com (8.9.3/8.9.3) with ESMTP id IAA28585 +# for ; Thu, 2 Aug 2001 08:34:38 -0400 +# Received: from sunshine.math.utah.edu ([128.110.198.2]) +# by fencepost.gnu.org with esmtp (Exim 3.22 #1 (Debian)) +# id 15SHjG-00036x-00 +# for ; Thu, 02 Aug 2001 08:37:30 -0400 +# Received: from suncore.math.utah.edu (IDENT:GsUbUdUYCtFLRE4HvnnvhN4JsjooYcfR@suncore0.math.utah.edu [128.110.198.5]) +# by sunshine.math.utah.edu (8.9.3/8.9.3) with ESMTP id GAA00190; +# Thu, 2 Aug 2001 06:37:04 -0600 (MDT) +# Received: (from beebe@localhost) +# by suncore.math.utah.edu (8.9.3/8.9.3) id GAA20469; +# Thu, 2 Aug 2001 06:37:03 -0600 (MDT) +# Date: Thu, 2 Aug 2001 06:37:03 -0600 (MDT) +# From: "Nelson H. F. Beebe" +# To: arnold@gnu.org +# Cc: beebe@math.utah.edu +# X-US-Mail: "Center for Scientific Computing, Department of Mathematics, 322 +# INSCC, University of Utah, 155 S 1400 E RM 233, Salt Lake City, UT +# 84112-0090, USA" +# X-Telephone: +1 801 581 5254 +# X-FAX: +1 801 585 1640, +1 801 581 4148 +# X-URL: http://www.math.utah.edu/~beebe +# Subject: awk implementations: a bug, or new dark corner? +# Message-ID: +# Status: RO +# +# Consider the following program: +# +# % cat bug.awk +BEGIN { + split("00/00/00",mdy,"/") + if ((mdy[1] == 0) && (mdy[2] == 0) && (mdy[3] == 0)) + { + print "OK: zero strings compare equal to number zero" + exit(0) + } + else + { + print "ERROR: zero strings compare unequal to number zero" + exit(1) + } +} +# +# Here are the awk implementation versions (on Sun Solaris 2.7): +# +# % awk -V +# awk version 19990416 +# +# % mawk -W version +# mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan +# +# % nawk -V +# awk version 20001115 +# +# % gawk --version +# GNU Awk 3.1.10 +# ... +# +# Here's what they say about the test program: +# +# foreach f (awk mawk nawk gawk gawk-*) +# echo ======== $f +# $f -f ~/bug.awk +# end +# +# ======== awk +# OK: zero strings compare equal to number zero +# ======== mawk +# OK: zero strings compare equal to number zero +# ======== nawk +# OK: zero strings compare equal to number zero +# ======== gawk +# ERROR: zero strings compare unequal to number zero +# ======== gawk-3.0.0 +# OK: zero strings compare equal to number zero +# ======== gawk-3.0.1 +# OK: zero strings compare equal to number zero +# ======== gawk-3.0.3 +# OK: zero strings compare equal to number zero +# ======== gawk-3.0.4 +# OK: zero strings compare equal to number zero +# ======== gawk-3.0.5 +# OK: zero strings compare equal to number zero +# ======== gawk-3.0.6 +# OK: zero strings compare equal to number zero +# ======== gawk-3.0.60 +# OK: zero strings compare equal to number zero +# ======== gawk-3.0.90 +# ERROR: zero strings compare unequal to number zero +# ======== gawk-3.0.91 +# ERROR: zero strings compare unequal to number zero +# ======== gawk-3.0.92 +# ERROR: zero strings compare unequal to number zero +# ======== gawk-3.0.93 +# ERROR: zero strings compare unequal to number zero +# ======== gawk-3.0.94 +# ERROR: zero strings compare unequal to number zero +# ======== gawk-3.0.95 +# ERROR: zero strings compare unequal to number zero +# ======== gawk-3.0.96 +# ERROR: zero strings compare unequal to number zero +# ======== gawk-3.0.97 +# ERROR: zero strings compare unequal to number zero +# ======== gawk-3.1.0 +# ERROR: zero strings compare unequal to number zero +# ======== gawk-3.1.10 +# ERROR: zero strings compare unequal to number zero +# +# Identical results were obtained on Apple Rhapsody, Apple Darwin, +# Compaq/DEC Alpha OSF/1, Intel x86 GNU/Linux, SGI IRIX 6.5, DEC Alpha +# GNU/Linux, and Sun SPARC GNU/Linux, so it definitely is not a C +# compiler problem. +# +# However, the gray awk book, p. 44, says: +# +# In a comparison expression like: +# x == y +# if both operands have a numeric type, the comparison is numeric; +# otherwise, any numeric operand is converted to a string and the +# comparison is made on the string values. +# +# and the new green gawk book, p. 95, says: +# +# When comparing operands of mixed types, numeric operands are +# converted to strings using the value of `CONVFMT' +# +# This suggests that the OK response in bug.awk is wrong, and the ERROR +# response is correct. Only recent gawk releases do the right thing, +# and it is awk, mawk, and nawk that have a bug. +# +# If I change the test program from "00/00/00" to "0/0/0", all versions +# tested produce the OK response. +# +# Comments? +# +# After reading the two book excerpts, I changed my code to read +# +# if (((0 + mdy[1]) == 0) && ((0 + mdy[2]) == 0) && ((0 + mdy[3]) == 0)) +# +# and output from all implementations now agrees. +# +# ------------------------------------------------------------------------------- +# - Nelson H. F. Beebe Tel: +1 801 581 5254 - +# - Center for Scientific Computing FAX: +1 801 585 1640, +1 801 581 4148 - +# - University of Utah Internet e-mail: beebe@math.utah.edu - +# - Department of Mathematics, 322 INSCC beebe@acm.org beebe@computer.org - +# - 155 S 1400 E RM 233 beebe@ieee.org - +# - Salt Lake City, UT 84112-0090, USA URL: http://www.math.utah.edu/~beebe - +# ------------------------------------------------------------------------------- +# diff --git a/test/compare2.ok b/test/compare2.ok new file mode 100644 index 0000000..fd1043a --- /dev/null +++ b/test/compare2.ok @@ -0,0 +1 @@ +OK: zero strings compare equal to number zero diff --git a/test/concat1.awk b/test/concat1.awk new file mode 100644 index 0000000..4ccb117 --- /dev/null +++ b/test/concat1.awk @@ -0,0 +1,78 @@ +#From deep@cicada-semi.com Wed Jan 23 13:15:52 2002 +#X-From_: deep@cicada-semi.com Wed Jan 23 01:24:54 2002 +#From: "Mandeep Chadha" +#To: +#Subject: gawk version 3.1.0 will not print a ";" +#Date: Tue, 22 Jan 2002 17:23:57 -0600 +#Message-ID: +#MIME-Version: 1.0 +#Content-Type: text/plain; +# charset="iso-8859-1" +#Content-Transfer-Encoding: 7bit +#X-Priority: 3 (Normal) +#X-MSMail-Priority: Normal +#X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) +#Importance: Normal +#X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 +# +# +#The file "tmp" contains the following lines: +# +#A +#B +#C +#D +# +#and when I run the command: +# +# gawk '{print "Input = "$_" ; "}' tmp +{print "Input = "$_" ; "} +# +#I get the following output: +# +#Input = A +#Input = B +#Input = C +#Input = D +# +#while I expect the following output: +# +#Input = A ; +#Input = B ; +#Input = C ; +#Input = D ; +# +#Running gawk --version produces the following output: +# +#GNU Awk 3.1.0 +#Copyright (C) 1989, 1991-2001 Free Software Foundation. +# +#This program is free software; you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation; either version 2 of the License, or +#(at your option) any later version. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +#along with this program; if not, write to the Free Software +#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +#I am running this on a i686 machine that is running RedHat 7.2 (out of the box). +# +#Thanks, +# +#Mandeep Chadha +# +#---------------------------------------- +#Mandeep Chadha +#Cicada Semiconductor Corp. +#811 Barton Springs Road, Suite 550 +#Austin, TX 78704 +#Ph: (512) 327-3500 x111 +#E-mail: deep@cicada-semi.com +#URL: http://www.cicada-semi.com +#---------------------------------------- diff --git a/test/concat1.in b/test/concat1.in new file mode 100644 index 0000000..8422d40 --- /dev/null +++ b/test/concat1.in @@ -0,0 +1,4 @@ +A +B +C +D diff --git a/test/concat1.ok b/test/concat1.ok new file mode 100644 index 0000000..b0aad60 --- /dev/null +++ b/test/concat1.ok @@ -0,0 +1,4 @@ +Input = A ; +Input = B ; +Input = C ; +Input = D ; diff --git a/test/concat2.awk b/test/concat2.awk new file mode 100644 index 0000000..a94b29b --- /dev/null +++ b/test/concat2.awk @@ -0,0 +1,8 @@ +function f(s, x) { + x = 1 + s = 3 + s = s x + print s +} + +BEGIN { for (i = 1; i <=12; i++) f() } diff --git a/test/concat2.ok b/test/concat2.ok new file mode 100644 index 0000000..b7b86e5 --- /dev/null +++ b/test/concat2.ok @@ -0,0 +1,12 @@ +31 +31 +31 +31 +31 +31 +31 +31 +31 +31 +31 +31 diff --git a/test/concat3.awk b/test/concat3.awk new file mode 100644 index 0000000..554c9a9 --- /dev/null +++ b/test/concat3.awk @@ -0,0 +1 @@ +BEGIN { a; a = a (b "c"); print a; print b } diff --git a/test/concat3.ok b/test/concat3.ok new file mode 100644 index 0000000..8802331 --- /dev/null +++ b/test/concat3.ok @@ -0,0 +1,2 @@ +c + diff --git a/test/concat4.awk b/test/concat4.awk new file mode 100644 index 0000000..91820d8 --- /dev/null +++ b/test/concat4.awk @@ -0,0 +1,9 @@ +{ + a = $0 + print a + print index(a,"b") + getline + a = a $0 + print a + print index(a,"b") +} diff --git a/test/concat4.in b/test/concat4.in new file mode 100644 index 0000000..3bd1f0e --- /dev/null +++ b/test/concat4.in @@ -0,0 +1,2 @@ +foo +bar diff --git a/test/concat4.ok b/test/concat4.ok new file mode 100644 index 0000000..38db1f8 --- /dev/null +++ b/test/concat4.ok @@ -0,0 +1,4 @@ +foo +0 +foobar +4 diff --git a/test/convfmt.awk b/test/convfmt.awk new file mode 100644 index 0000000..90fd204 --- /dev/null +++ b/test/convfmt.awk @@ -0,0 +1,10 @@ +BEGIN { + CONVFMT = "%2.2f" + a = 123.456 + b = a "" # give `a' string value also + printf "a = %s\n", a + CONVFMT = "%.6g" + printf "a = %s\n", a + a += 0 # make `a' numeric only again + printf "a = %s\n", a # use `a' as string +} diff --git a/test/convfmt.ok b/test/convfmt.ok new file mode 100644 index 0000000..a7b66f7 --- /dev/null +++ b/test/convfmt.ok @@ -0,0 +1,3 @@ +a = 123.46 +a = 123.456 +a = 123.456 diff --git a/test/datanonl.awk b/test/datanonl.awk new file mode 100644 index 0000000..29e668e --- /dev/null +++ b/test/datanonl.awk @@ -0,0 +1,3 @@ +# example program from alex@bofh.torun.pl +BEGIN { IGNORECASE=1 } +/\w+@([[:alnum:]]+\.)+[[:alnum:]]+[[:blank:]]+/ {print $0} diff --git a/test/datanonl.in b/test/datanonl.in new file mode 100644 index 0000000..5340d7b --- /dev/null +++ b/test/datanonl.in @@ -0,0 +1 @@ +bleble@foo1.bh.pl deny \ No newline at end of file diff --git a/test/datanonl.ok b/test/datanonl.ok new file mode 100644 index 0000000..7b0fcaf --- /dev/null +++ b/test/datanonl.ok @@ -0,0 +1 @@ +bleble@foo1.bh.pl deny diff --git a/test/defref.awk b/test/defref.awk new file mode 100644 index 0000000..b4e8f10 --- /dev/null +++ b/test/defref.awk @@ -0,0 +1 @@ +BEGIN { foo() } diff --git a/test/defref.ok b/test/defref.ok new file mode 100644 index 0000000..962b3fd --- /dev/null +++ b/test/defref.ok @@ -0,0 +1,3 @@ +gawk: warning: function `foo' called but never defined +gawk: defref.awk:1: fatal: function `foo' not defined +EXIT CODE: 2 diff --git a/test/delargv.awk b/test/delargv.awk new file mode 100644 index 0000000..6c193a1 --- /dev/null +++ b/test/delargv.awk @@ -0,0 +1,12 @@ +BEGIN { + ARGV[1] = "/dev/null" + ARGV[2] = "/dev/null" + ARGV[3] = "/dev/null" + ARGC = 4 + delete ARGV[2] +} + +END { + for (i in ARGV) + printf("length of ARGV[%d] is %d\n", i, length(ARGV[i])) +} diff --git a/test/delargv.ok b/test/delargv.ok new file mode 100644 index 0000000..9cb5383 --- /dev/null +++ b/test/delargv.ok @@ -0,0 +1,3 @@ +length of ARGV[0] is 4 +length of ARGV[1] is 9 +length of ARGV[3] is 9 diff --git a/test/delarpm2.awk b/test/delarpm2.awk new file mode 100644 index 0000000..ad0ed3d --- /dev/null +++ b/test/delarpm2.awk @@ -0,0 +1,95 @@ +# From beebe@math.utah.edu Sat May 17 21:31:27 2003 +# Return-Path: +# Received: from localhost (aahz [127.0.0.1]) +# by skeeve.com (8.12.5/8.12.5) with ESMTP id h4HIQmCw001380 +# for ; Sat, 17 May 2003 21:31:27 +0300 +# Received: from actcom.co.il [192.114.47.1] +# by localhost with POP3 (fetchmail-5.9.0) +# for arnold@localhost (single-drop); Sat, 17 May 2003 21:31:27 +0300 (IDT) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Sat May 17 21:34:07 2003) +# X-From_: beebe@sunshine.math.utah.edu Fri May 16 20:38:45 2003 +# Received: from smtp1.actcom.net.il by actcom.co.il with ESMTP +# (8.11.6/actcom-0.2) id h4GHcd226764 for ; +# Fri, 16 May 2003 20:38:40 +0300 (EET DST) +# (rfc931-sender: mail.actcom.co.il [192.114.47.13]) +# Received: from f7.net (consort.superb.net [209.61.216.22]) +# by smtp1.actcom.net.il (8.12.8/8.12.8) with ESMTP id h4GHgBc2023067 +# for ; Fri, 16 May 2003 20:42:13 +0300 +# Received: from sunshine.math.utah.edu (sunshine.math.utah.edu [128.110.198.2]) +# by f7.net (8.11.7/8.11.6) with ESMTP id h4GHcbf09202 +# for ; Fri, 16 May 2003 13:38:37 -0400 +# Received: from suncore.math.utah.edu (IDENT:r8KQWmkF4jVMLBhxpojXGNCAnBZB38ET@suncore.math.utah.edu [128.110.198.5]) +# by sunshine.math.utah.edu (8.9.3p2/8.9.3) with ESMTP id LAA09111; +# Fri, 16 May 2003 11:38:34 -0600 (MDT) +# Received: (from beebe@localhost) +# by suncore.math.utah.edu (8.9.3p2/8.9.3) id LAA01743; +# Fri, 16 May 2003 11:38:34 -0600 (MDT) +# Date: Fri, 16 May 2003 11:38:34 -0600 (MDT) +# From: "Nelson H. F. Beebe" +# To: "Arnold Robbins" +# Cc: beebe@math.utah.edu +# X-US-Mail: "Center for Scientific Computing, Department of Mathematics, 110 +# LCB, University of Utah, 155 S 1400 E RM 233, Salt Lake City, UT +# 84112-0090, USA" +# X-Telephone: +1 801 581 5254 +# X-FAX: +1 801 585 1640, +1 801 581 4148 +# X-URL: http://www.math.utah.edu/~beebe +# Subject: gawk-3.1.2[ab]: bug in delete +# Message-ID: +# +# I discovered yesterday that one of my tools got broken by the upgrade +# to gawk-3.1.2a and gawk-3.1.2b. For now, I've temporarily reset +# /usr/local/bin/gawk on the Sun Solaris and Intel GNU/Linux systems +# back to be gawk-3.1.2. +# +# This morning, I isolated the problem to the following small test case: +# +# % cat bug.awk + BEGIN { + clear_array(table) + foo(table) + for (key in table) + print key, table[k] + clear_array(table) + exit(0) + } + + function clear_array(array, key) + { + for (key in array) + delete array[key] + } + + function foo(a) + { + a[1] = "one" + a[2] = "two" + } +# +# With nawk, mawk, and also gawk-3.1.2 or earlier, I get this: +# +# % mawk -f bug.awk +# 1 +# 2 +# +# However, with the two most recent gawk releases, I get: +# +# % gawk-3.1.2b -f bug.awk +# gawk-3.1.2b: bug.awk:12: fatal: delete: illegal use of variable `table' as +# array +# +# If the first clear_array() statement is commented out, it runs. +# However, the problem is that in a large program, it may not be easy to +# identify places where it is safe to invoke delete, so I believe the +# old behavior is more desirable. +# +# ------------------------------------------------------------------------------- +# - Nelson H. F. Beebe Tel: +1 801 581 5254 - +# - Center for Scientific Computing FAX: +1 801 581 4148 - +# - University of Utah Internet e-mail: beebe@math.utah.edu - +# - Department of Mathematics, 110 LCB beebe@acm.org beebe@computer.org - +# - 155 S 1400 E RM 233 beebe@ieee.org - +# - Salt Lake City, UT 84112-0090, USA URL: http://www.math.utah.edu/~beebe - +# ------------------------------------------------------------------------------- +# diff --git a/test/delarpm2.ok b/test/delarpm2.ok new file mode 100644 index 0000000..bea5b8a --- /dev/null +++ b/test/delarpm2.ok @@ -0,0 +1,2 @@ +1 +2 diff --git a/test/delarprm.awk b/test/delarprm.awk new file mode 100644 index 0000000..d59de31 --- /dev/null +++ b/test/delarprm.awk @@ -0,0 +1,50 @@ +# From dragon!unagi.cis.upenn.edu!sjanet Tue Mar 25 17:12:20 1997 +# Return-Path: +# Received: by skeeve.atl.ga.us (/\==/\ Smail3.1.22.1 #22.1) +# id ; Tue, 25 Mar 97 17:12 EST +# Received: by vecnet.com (DECUS UUCP /2.0/2.0/2.0/); +# Tue, 25 Mar 97 16:58:36 EDT +# Received: from gnu-life.ai.mit.edu by antaries.vec.net (MX V4.2 VAX) with SMTP; +# Tue, 25 Mar 1997 16:58:26 EST +# Received: from linc.cis.upenn.edu by gnu-life.ai.mit.edu (8.8.5/8.6.12GNU) with +# ESMTP id QAA24350 for ; Tue, 25 Mar +# 1997 16:56:59 -0500 (EST) +# Received: from unagi.cis.upenn.edu (UNAGI.CIS.UPENN.EDU [158.130.8.153]) by +# linc.cis.upenn.edu (8.8.5/8.8.5) with ESMTP id QAA09424; Tue, 25 Mar +# 1997 16:56:54 -0500 (EST) +# Received: (from sjanet@localhost) by unagi.cis.upenn.edu (8.8.5/8.8.5) id +# QAA03969; Tue, 25 Mar 1997 16:56:50 -0500 (EST) +# Date: Tue, 25 Mar 1997 16:56:50 -0500 (EST) +# From: Stan Janet +# Message-ID: <199703252156.QAA03969@unagi.cis.upenn.edu> +# To: bug-gnu-utils@prep.ai.mit.edu +# CC: arnold@gnu.ai.mit.edu +# Subject: GNU awk 3.0.2 bug: fatal error deleting local array inside function +# Status: ORf +# +# Version: GNU Awk 3.0.2 +# Platforms: SunOS 4.1.1 (compiled with Sun cc) +# IRIX 5.3 (compiled with SGI cc) +# Problem: Deleting local array inside function causes fatal internal error (and +# core dump. The error does not occur when the variable "x", unused in +# the example, is removed or when the function is declared foo(x,p). +# When the function is declared foo(p,x), adding a dummy line that uses +# "x", e.g. "x=1" does not prevent the error. If "p" is not deleted, +# there is no error. If "p[1]" is used to delete the lone element, there +# is no error. +# +# ==== The program x.gawk ==== + +function foo(p,x) { + p[1]="bar" + delete p + return 0 +} + +BEGIN { + foo() +} + +# ==== The output for "gawk -f x.gawk" (SunOS) ==== +# +# gawk: x.gawk:4: fatal error: internal error diff --git a/test/delarprm.ok b/test/delarprm.ok new file mode 100644 index 0000000..e69de29 diff --git a/test/delfunc.awk b/test/delfunc.awk new file mode 100644 index 0000000..365a76b --- /dev/null +++ b/test/delfunc.awk @@ -0,0 +1,7 @@ +# from Stepan Kasal, 9 July 2003 +function f() +{ + delete f +} + +BEGIN { f() } diff --git a/test/delfunc.ok b/test/delfunc.ok new file mode 100644 index 0000000..d12f0bc --- /dev/null +++ b/test/delfunc.ok @@ -0,0 +1,2 @@ +gawk: delfunc.awk:4: fatal: attempt to use function `f' as an array +EXIT CODE: 2 diff --git a/test/delsub.awk b/test/delsub.awk new file mode 100644 index 0000000..0c3ffb0 --- /dev/null +++ b/test/delsub.awk @@ -0,0 +1,2 @@ +function f(c, d, x) { delete c; x = d[0] } +BEGIN { a[0][0] = 1; f(a, a[0]); print "still here" } diff --git a/test/delsub.ok b/test/delsub.ok new file mode 100644 index 0000000..ae3eb5b --- /dev/null +++ b/test/delsub.ok @@ -0,0 +1 @@ +still here diff --git a/test/devfd.in1 b/test/devfd.in1 new file mode 100644 index 0000000..0e50e69 --- /dev/null +++ b/test/devfd.in1 @@ -0,0 +1,20 @@ +this is file f1, line 1 +this is file f1, line 2 +this is file f1, line 3 +this is file f1, line 4 +this is file f1, line 5 +this is file f1, line 6 +this is file f1, line 7 +this is file f1, line 8 +this is file f1, line 9 +this is file f1, line 10 +this is file f1, line 11 +this is file f1, line 12 +this is file f1, line 13 +this is file f1, line 14 +this is file f1, line 15 +this is file f1, line 16 +this is file f1, line 17 +this is file f1, line 18 +this is file f1, line 19 +this is file f1, line 20 diff --git a/test/devfd.in2 b/test/devfd.in2 new file mode 100644 index 0000000..d3299a9 --- /dev/null +++ b/test/devfd.in2 @@ -0,0 +1,20 @@ +this is file f2, line 1 +this is file f2, line 2 +this is file f2, line 3 +this is file f2, line 4 +this is file f2, line 5 +this is file f2, line 6 +this is file f2, line 7 +this is file f2, line 8 +this is file f2, line 9 +this is file f2, line 10 +this is file f2, line 11 +this is file f2, line 12 +this is file f2, line 13 +this is file f2, line 14 +this is file f2, line 15 +this is file f2, line 16 +this is file f2, line 17 +this is file f2, line 18 +this is file f2, line 19 +this is file f2, line 20 diff --git a/test/devfd.in4 b/test/devfd.in4 new file mode 100644 index 0000000..57da1f8 --- /dev/null +++ b/test/devfd.in4 @@ -0,0 +1 @@ +file on fd 4 diff --git a/test/devfd.in5 b/test/devfd.in5 new file mode 100644 index 0000000..4469cb4 --- /dev/null +++ b/test/devfd.in5 @@ -0,0 +1 @@ +file on fd 5 diff --git a/test/devfd.ok b/test/devfd.ok new file mode 100644 index 0000000..14f8f2e --- /dev/null +++ b/test/devfd.ok @@ -0,0 +1,2 @@ +file on fd 4 +file on fd 5 diff --git a/test/devfd1.awk b/test/devfd1.awk new file mode 100644 index 0000000..6795704 --- /dev/null +++ b/test/devfd1.awk @@ -0,0 +1,11 @@ +BEGIN { + while (1) { + if ((getline l1 < "/dev/fd/4") <= 0) + break + print l1 + + if ((getline l2 < "/dev/fd/5") <= 0) + break + print l2 + } +} diff --git a/test/devfd1.ok b/test/devfd1.ok new file mode 100644 index 0000000..359d7d3 --- /dev/null +++ b/test/devfd1.ok @@ -0,0 +1,40 @@ +this is file f1, line 1 +this is file f2, line 1 +this is file f1, line 2 +this is file f2, line 2 +this is file f1, line 3 +this is file f2, line 3 +this is file f1, line 4 +this is file f2, line 4 +this is file f1, line 5 +this is file f2, line 5 +this is file f1, line 6 +this is file f2, line 6 +this is file f1, line 7 +this is file f2, line 7 +this is file f1, line 8 +this is file f2, line 8 +this is file f1, line 9 +this is file f2, line 9 +this is file f1, line 10 +this is file f2, line 10 +this is file f1, line 11 +this is file f2, line 11 +this is file f1, line 12 +this is file f2, line 12 +this is file f1, line 13 +this is file f2, line 13 +this is file f1, line 14 +this is file f2, line 14 +this is file f1, line 15 +this is file f2, line 15 +this is file f1, line 16 +this is file f2, line 16 +this is file f1, line 17 +this is file f2, line 17 +this is file f1, line 18 +this is file f2, line 18 +this is file f1, line 19 +this is file f2, line 19 +this is file f1, line 20 +this is file f2, line 20 diff --git a/test/devfd2.ok b/test/devfd2.ok new file mode 100644 index 0000000..be928c1 --- /dev/null +++ b/test/devfd2.ok @@ -0,0 +1,40 @@ +this is file f1, line 1 +this is file f1, line 2 +this is file f1, line 3 +this is file f1, line 4 +this is file f1, line 5 +this is file f1, line 6 +this is file f1, line 7 +this is file f1, line 8 +this is file f1, line 9 +this is file f1, line 10 +this is file f1, line 11 +this is file f1, line 12 +this is file f1, line 13 +this is file f1, line 14 +this is file f1, line 15 +this is file f1, line 16 +this is file f1, line 17 +this is file f1, line 18 +this is file f1, line 19 +this is file f1, line 20 +this is file f2, line 1 +this is file f2, line 2 +this is file f2, line 3 +this is file f2, line 4 +this is file f2, line 5 +this is file f2, line 6 +this is file f2, line 7 +this is file f2, line 8 +this is file f2, line 9 +this is file f2, line 10 +this is file f2, line 11 +this is file f2, line 12 +this is file f2, line 13 +this is file f2, line 14 +this is file f2, line 15 +this is file f2, line 16 +this is file f2, line 17 +this is file f2, line 18 +this is file f2, line 19 +this is file f2, line 20 diff --git a/test/dfastress.awk b/test/dfastress.awk new file mode 100644 index 0000000..40dd3ee --- /dev/null +++ b/test/dfastress.awk @@ -0,0 +1 @@ +BEGIN { print "a" ~ /(^| )*(a|b)*(c|d)( |$)/ } diff --git a/test/dfastress.ok b/test/dfastress.ok new file mode 100644 index 0000000..573541a --- /dev/null +++ b/test/dfastress.ok @@ -0,0 +1 @@ +0 diff --git a/test/double1.awk b/test/double1.awk new file mode 100644 index 0000000..70a6fb6 --- /dev/null +++ b/test/double1.awk @@ -0,0 +1,4 @@ +BEGIN { + print 9223372036854775808 + printf("%d\n", 9223372036854775808) +} diff --git a/test/double1.ok b/test/double1.ok new file mode 100644 index 0000000..e07477e --- /dev/null +++ b/test/double1.ok @@ -0,0 +1,2 @@ +9223372036854775808 +9223372036854775808 diff --git a/test/double2.awk b/test/double2.awk new file mode 100644 index 0000000..e826eec --- /dev/null +++ b/test/double2.awk @@ -0,0 +1,46 @@ +# Date: Mon, 19 Dec 2005 18:14:13 -0800 +# From: David Ellsworth +# Subject: Re: gawk number to string bug +# To: eggert@CS.UCLA.EDU, eliz@gnu.org +# Cc: arnold@skeeve.com, aschorr@telemetry-investments.com, +# bug-gnu-utils@gnu.org, ellswort@nas.nasa.gov +# Message-id: <200512200214.jBK2EDuu020216@ece03.nas.nasa.gov> +# +# Since you are taking my bug report seriously (which is really great), +# let me add some more fuel to the fire. Consider this program: +# +# BEGIN { x=2**60; for(i=60;i<=65;i++) { printf "2^%d= %s %d %g\n",i,x,x,x; x*=2}} +# +# which prints out powers of two around 2^63. On an Opteron (as well as +# an Itanium), you get +# +# 2^60= 1152921504606846976 1152921504606846976 1.15292e+18 +# 2^61= 2305843009213693952 2305843009213693952 2.30584e+18 +# 2^62= 4611686018427387904 4611686018427387904 4.61169e+18 +# 2^63= -9223372036854775808 9223372036854775808 9.22337e+18 +# 2^64= 1.84467e+19 0 1.84467e+19 +# 2^65= 3.68935e+19 3.68935e+19 3.68935e+19 +# +# On a Xeon, you get +# +# 2^60= 1.15292e+18 1152921504606846976 1.15292e+18 +# 2^61= 2.30584e+18 2305843009213693952 2.30584e+18 +# 2^62= 4.61169e+18 4611686018427387904 4.61169e+18 +# 2^63= 9.22337e+18 9223372036854775808 9.22337e+18 +# 2^64= 1.84467e+19 0 1.84467e+19 +# 2^65= 3.68935e+19 3.68935e+19 3.68935e+19 +# +# The 2^64 value for %d is probably also a bug since the outputs +# for 2^63 and 2^65 are reasonable. +# +# - David +# + +BEGIN { + x = 2 ^ 60 +# for (i = 60; i <= 65; i++) { + for (i = 60; i <= 63; i++) { + printf "2^%d= %s %d %g %o\n", i, x, x, x, x + x *= 2 + } +} diff --git a/test/double2.ok b/test/double2.ok new file mode 100644 index 0000000..f7224e2 --- /dev/null +++ b/test/double2.ok @@ -0,0 +1,4 @@ +2^60= 1152921504606846976 1152921504606846976 1.15292e+18 100000000000000000000 +2^61= 2305843009213693952 2305843009213693952 2.30584e+18 200000000000000000000 +2^62= 4611686018427387904 4611686018427387904 4.61169e+18 400000000000000000000 +2^63= 9223372036854775808 9223372036854775808 9.22337e+18 1000000000000000000000 diff --git a/test/dtdgport.awk b/test/dtdgport.awk new file mode 100644 index 0000000..42b9545 --- /dev/null +++ b/test/dtdgport.awk @@ -0,0 +1,325 @@ +# dtdgport.awk +# Reads an XML document from standard input and +# prints a DTD for this document to standard output. +# http://saxon.sourceforge.net/dtdgen.html +# JK 2004-10-09 +# JK 2006-03-05 +# JK 2007-08-05 Converted for portability from the original dtd_generator.awk + +# The program makes an internal list of all the elements +# and attributes that appear in your document, noting how +# they are nested, and noting which elements contain +# character data. + +BEGIN { + while (getXMLEVENT(ARGV[1])) { + # Remember each element. + if ( XMLEVENT == "STARTELEM" ) { + # Remember the parent names of each child node. + name[XMLDEPTH] = XMLSTARTELEM + if (XMLDEPTH>1) + child[name[XMLDEPTH-1], XMLSTARTELEM] ++ + # Count how often the element occurs. + elem[XMLSTARTELEM] ++ + # Remember all the attributes with the element. + for (a in XMLATTR) + attr[XMLSTARTELEM,a] ++ + } + } +} + +END { print_elem(1, name[1]) } # name[1] is the root + +# Print one element (including sub-elements) but only once. +function print_elem(depth, element, c, atn, chl, n, i, myChildren) { + if (already_printed[element]++) + return + indent=sprintf("%*s", 2*depth-2, "") + myChildren="" + for (c in child) { + split(c, chl, SUBSEP) + if (element == chl[1]) { + if (myChildren=="") + myChildren = chl[2] + else + myChildren = myChildren " | " chl[2] + } + } + # If an element has no child nodes, declare it as such. + if (myChildren=="") + print indent "" + else + print indent "" + # After the element name itself, list its attributes. + for (a in attr) { + split(a, atn, SUBSEP) + # Treat only those attributes that belong to the current element. + if (element == atn[1]) { + # If an attribute occured each time with its element, notice this. + if (attr[element, atn[2]] == elem[element]) + print indent "" + else + print indent "" + } + } + # Now go through the child nodes of this elements and print them. + gsub(/[\|]/, " ", myChildren) + n=split(myChildren, chl) + for(i=1; i<=n; i++) { + print_elem(depth+1, chl[i]) + split(myChildren, chl) + } +} + +## +# getXMLEVENT( file ): # read next xml-data into XMLEVENT,XMLNAME,XMLATTR +# # referenced entities are not resolved +# Parameters: +# file -- path to xml file +# External variables: +# XMLEVENT -- type of item read, e.g. "STARTELEM"(tag), "ENDELEM"(end tag), +# "COMMENT"(comment), "CHARDATA"(data) +# XMLNAME -- value of item, e.g. tagname if type is "STARTELEM" or "ENDELEM" +# XMLATTR -- Map of attributes, only set if XMLEVENT=="STARTELEM" +# XMLPATH -- Path to current tag, e.g. /TopLevelTag/SubTag1/SubTag2 +# XMLROW -- current line number in input file +# XMLERROR -- error text, set on parse error +# Returns: +# 1 on successful read: XMLEVENT, XMLNAME, XMLATTR are set accordingly +# "" at end of file or parse error, XMLERROR is set on error +# Private Data: +# _XMLIO -- buffer, XMLROW, XMLPATH for open files +## + +function getXMLEVENT( file ,end,p,q,tag,att,accu,mline,mode,S0,ex,dtd) { + XMLEVENT=XMLNAME=XMLERROR=XMLSTARTELEM=XMLENDELEM = "" + split("", XMLATTR) + S0 = _XMLIO[file,"S0"] + XMLROW = _XMLIO[file,"line"]; + XMLPATH = _XMLIO[file,"path"]; + XMLDEPTH=_XMLIO[file,"depth"]+0; + dtd = _XMLIO[file,"dtd"]; + while (!XMLEVENT) { + if (S0 == "") { + if (1 != (getline S0 < file)) + break; + XMLROW ++; + S0 = S0 RS; + } + if (mode == "") { + mline = XMLROW + accu="" + p = substr(S0,1,1) + if (p != "<" && !(dtd && p=="]")) + mode="CHARDATA" + else if (p == "]") { + S0 = substr(S0,2) + mode="ENDDOCT" + end=">" + dtd=0 + } else if ( substr(S0,1,4) == "" + } else if ( substr(S0,1,9) == "" + } else if (substr(S0,1,9) == "" + } else if ( substr(S0,1,2) == "" + } else if (substr(S0,1,2) == "" + } else if ( substr(S0,1,2)==""; + tag = S0 + sub(/[ \n\r\t>].*$/,"",tag) + S0 = substr(S0,length(tag)+1) + ex = XMLPATH + sub(/\/[^\/]*$/,"",XMLPATH) + ex = substr(ex, length(XMLPATH)+2) + if (tag != ex) { + XMLERROR = "unexpected close tag <" ex ">.." + break + } + } else { + S0 = substr(S0,2) + mode = "STARTELEM" + tag = S0 + sub(/[ \n\r\t\/>].*$/,"",tag) + S0 = substr(S0, length(tag)+1) + if (tag !~ /^[A-Za-z:_][0-9A-Za-z:_.-]*$/ ) { # /^[[:alpha:]:_][[:alnum:]:_.-]*$/ + XMLERROR = "invalid tag name '" tag "'" + break + } + XMLPATH = XMLPATH "/" tag; + } + } else if (mode == "CHARDATA") { # terminated by "<" or EOF + p = index(S0, "<") + if (dtd && (q=index(S0,"]")) && (!p || q" ) { + S0 = substr(S0, 3) + mode = "" + XMLEVENT = "STARTELEM" + XMLNAME = XMLSTARTELEM = tag + XMLDEPTH ++ + S0 = "" S0 + } else if (substr(S0, 1, 1) == ">" ) { + S0 = substr(S0, 2) + mode = "" + XMLEVENT = "STARTELEM" + XMLNAME = XMLSTARTELEM = tag + XMLDEPTH ++ + } else { + att = S0 + sub(/[= \n\r\t\/>].*$/,"",att) + S0 = substr(S0, length(att) + 1) + mode = "ATTR" + if (att !~ /^[A-Za-z:_][0-9A-Za-z:_.-]*$/ ) { # /^[[:alpha:]:_][[:alnum:]:_.-]*$/ + XMLERROR = "invalid attribute name '" att "'" + break + } + } + } else if (mode == "ATTR") { + sub(/^[ \n\r\t]*/, "", S0) + if (S0 == "") + continue + if (substr(S0,1,1) == "=" ) { + S0 = substr(S0,2) + mode = "EQ" + } else { + XMLATTR[att] = att + mode = "STARTELEM" + } + } else if (mode == "EQ") { + sub(/^[ \n\r\t]*/,"",S0) + if (S0 == "") + continue + end = substr(S0,1,1) + if (end == "\"" || end == "'") { + S0 = substr(S0,2) + accu = "" + mode = "VALUE" + } else { + accu = S0 + sub(/[ \n\r\t\/>].*$/,"", accu) + S0 = substr(S0, length(accu)+1) + XMLATTR[att] = unescapeXML(accu) + mode = "STARTELEM" + } + } else if (mode == "VALUE") { # terminated by end + if (p = index(S0, end)) { + XMLATTR[att] = accu unescapeXML(substr(S0,1,p-1)) + S0 = substr(S0, p+length(end)) + mode = "STARTELEM" + } else { + accu = accu unescapeXML(S0) + S0="" + } + } else if (mode == "STARTDOCT") { # terminated by "[" or ">" + if ((q = index(S0, "[")) && (!(p = index(S0,end)) || q

", text ) + gsub( "<", "<", text ) + gsub( "&", "\\&", text) + return text +} + +# close xml file +function closeXMLEVENT(file) { + close(file); + delete _XMLIO[file,"S0"] + delete _XMLIO[file,"line"] + delete _XMLIO[file,"path"]; + delete _XMLIO[file,"depth"]; + delete _XMLIO[file,"dtd"] + delete _XMLIO[file,"open"] + delete _XMLIO[file,"IND"] +} diff --git a/test/dumpvars.in b/test/dumpvars.in new file mode 100644 index 0000000..b1e6722 --- /dev/null +++ b/test/dumpvars.in @@ -0,0 +1,3 @@ +A +B +C diff --git a/test/dumpvars.ok b/test/dumpvars.ok new file mode 100644 index 0000000..01d5fb7 --- /dev/null +++ b/test/dumpvars.ok @@ -0,0 +1,24 @@ +ARGC: 1 +ARGIND: 0 +ARGV: array, 1 elements +BINMODE: 0 +CONVFMT: "%.6g" +ERRNO: "" +FIELDWIDTHS: "" +FILENAME: "-" +FNR: 3 +FPAT: "[^[:space:]]+" +FS: " " +IGNORECASE: 0 +LINT: 0 +NF: 1 +NR: 3 +OFMT: "%.6g" +OFS: " " +ORS: "\n" +RLENGTH: 0 +RS: "\n" +RSTART: 0 +RT: "\n" +SUBSEP: "\034" +TEXTDOMAIN: "messages" diff --git a/test/dynlj.awk b/test/dynlj.awk new file mode 100644 index 0000000..ec6851b --- /dev/null +++ b/test/dynlj.awk @@ -0,0 +1 @@ +BEGIN { printf "%*sworld\n", -20, "hello" } diff --git a/test/dynlj.ok b/test/dynlj.ok new file mode 100644 index 0000000..c8f3fe9 --- /dev/null +++ b/test/dynlj.ok @@ -0,0 +1 @@ +hello world diff --git a/test/eofsplit.awk b/test/eofsplit.awk new file mode 100644 index 0000000..22042b4 --- /dev/null +++ b/test/eofsplit.awk @@ -0,0 +1,68 @@ +# Date: Sat, 30 Mar 1996 12:47:17 -0800 (PST) +# From: Charles Howes +# To: bug-gnu-utils@prep.ai.mit.edu, arnold@gnu.ai.mit.edu +# Subject: Bug in Gawk 3.0.0, sample code: +# +#!/usr/local/bin/gawk -f +# +# Hello! This is a bug report from chowes@direct.ca +# +# uname -a +# SunOS hostname 5.5 Generic sun4m +# +# Gnu Awk (gawk) 3.0, patchlevel 0: +BEGIN{ +FS=":" +while ((getline < "/etc/passwd") > 0) { + r=$3 + z=0 + n[0]=1 + } +FS=" " +} +#gawk: fp.new:16: fatal error: internal error +#Abort + +# #!/usr/local/bin/gawk -f +# # Gnu Awk (gawk) 2.15, patchlevel 6 +# +# BEGIN{ +# f="/etc/passwd" +# while (getline < f) n[0]=1 +# FS=" " +# } +# #gawk: /staff/chowes/bin/fp:7: fatal error: internal error +# #Abort + +# These examples are not perfect coding style because I took a real +# piece of code and tried to strip away anything that didn't make the error +# message go away. +# +# The interesting part of the 'truss' is: +# +# fstat(3, 0xEFFFF278) = 0 +# lseek(3, 0, SEEK_SET) = 0 +# read(3, " r o o t : x : 0 : 1 : S".., 2291) = 2291 +# brk(0x00050020) = 0 +# brk(0x00052020) = 0 +# read(3, 0x0004F4B8, 2291) = 0 +# close(3) = 0 +# Incurred fault #6, FLTBOUNDS %pc = 0x0001B810 +# siginfo: SIGSEGV SEGV_MAPERR addr=0x00053000 +# Received signal #11, SIGSEGV [caught] +# siginfo: SIGSEGV SEGV_MAPERR addr=0x00053000 +# write(2, " g a w k", 4) = 4 +# write(2, " : ", 2) = 2 +# +# -- +# Charles Howes -- chowes@direct.ca Voice: (604) 691-1607 +# System Administrator Fax: (604) 691-1605 +# Internet Direct - 1050 - 555 West Hastings St - Vancouver, BC V6B 4N6 +# +# A sysadmin's life is a sorry one. The only advantage he has over Emergency +# Room doctors is that malpractice suits are rare. On the other hand, ER +# doctors never have to deal with patients installing new versions of their +# own innards! -Michael O'Brien +# +# "I think I know what may have gone wrong in the original s/w. +# It's a bug in the way it was written." - Vagueness**n diff --git a/test/eofsplit.ok b/test/eofsplit.ok new file mode 100644 index 0000000..e69de29 diff --git a/test/exit.ok b/test/exit.ok new file mode 100644 index 0000000..724b449 --- /dev/null +++ b/test/exit.ok @@ -0,0 +1,25 @@ +1 +3 +-- 1 +2 +-- 2 +2 +-- 3 +2 +2 +-- 4 +0 +-- 5 +1 null +-- 6 +1 null +-- 7 +0 exit.sh +-- 8 +1 +0 exit.sh +-- 9 +0 null +-- 10 +1 null +-- 11 diff --git a/test/exit.sh b/test/exit.sh new file mode 100755 index 0000000..9510dcd --- /dev/null +++ b/test/exit.sh @@ -0,0 +1,57 @@ +#!/bin/sh + +# exit.sh --- test exit invoked in various ways + +if [ "$AWK" = "" ] +then + echo $0: You must set AWK >&2 + exit 1 +fi + +# Use awk to print the string instead of echo or printf. + +x='BEGIN{print 1; exit; print 2}; NR>1{print}; END{print 3; exit; print 4}' +$AWK 'BEGIN { print "a\nb" }' | $AWK "$x" +echo "-- 1" + +x='function f(){ exit}; END{print NR;f();print NR}' +$AWK 'BEGIN { print "a\nb" }' | $AWK "$x" +echo "-- 2" + +x='function f(){ exit}; NR>1 {f()}; END{print NR; f();print NR}' +$AWK 'BEGIN { print "a\nb" }' | $AWK "$x" +echo "-- 3" + +x='function f(){ exit}; NR>1{ f()}; END{print NR;print NR}' +$AWK 'BEGIN { print "a\nb" }' | $AWK "$x" +echo "-- 4" + +x='function f(){ exit}; BEGINFILE {f()}; NR>1{ f()}; END{print NR}' +$AWK 'BEGIN { print "a\nb" }' | $AWK "$x" +echo "-- 5" + +y='function strip(f) { sub(/.*\//, "", f); return f };' + +x='BEGINFILE{if(++i==1) exit;}; END{print i, strip(FILENAME)}' +$AWK "$y$x" /dev/null $0 +echo "-- 6" + +x='BEGINFILE{if(++i==1) exit;}; ENDFILE{print i++}; END{print i, strip(FILENAME)}' +$AWK "$y$x" /dev/null $0 +echo "-- 7" + +x='function f(){ exit}; BEGINFILE{i++ && f()}; END{print NR,strip(FILENAME)}' +$AWK "$y$x" /dev/null $0 +echo "-- 8" + +x='function f(){ exit}; BEGINFILE{i++ && f()}; ENDFILE{ print i}; END{print NR,strip(FILENAME)}' +$AWK "$y$x" /dev/null $0 +echo "-- 9" + +x='function f(){ exit}; BEGINFILE{i++}; ENDFILE{ f(); print i}; END{print NR,strip(FILENAME)}' +$AWK "$y$x" /dev/null $0 +echo "-- 10" + +x='function f(){ exit}; BEGINFILE{i++}; ENDFILE{ i>1 && f(); print i, strip(FILENAME)}' +$AWK "$y$x" /dev/null $0 +echo "-- 11" diff --git a/test/exitval1.awk b/test/exitval1.awk new file mode 100644 index 0000000..550200d --- /dev/null +++ b/test/exitval1.awk @@ -0,0 +1,3 @@ +# This should exit 0, even though child exits 1 +BEGIN { "exit 1" | getline junk ; exit 12 } +END { exit 0 } diff --git a/test/exitval1.ok b/test/exitval1.ok new file mode 100644 index 0000000..eca5994 --- /dev/null +++ b/test/exitval1.ok @@ -0,0 +1 @@ +EXIT CODE: 0 diff --git a/test/exitval2.awk b/test/exitval2.awk new file mode 100644 index 0000000..ed05e76 --- /dev/null +++ b/test/exitval2.awk @@ -0,0 +1,3 @@ +BEGIN { print "foo" | "read x ; echo $x ; exit 12" } +# this should still exit 0, as pointed out by kenny mccormack in +# comp.lang.awk on 2 feb 2005 diff --git a/test/exitval2.ok b/test/exitval2.ok new file mode 100644 index 0000000..257cc56 --- /dev/null +++ b/test/exitval2.ok @@ -0,0 +1 @@ +foo diff --git a/test/exitval2.w32 b/test/exitval2.w32 new file mode 100644 index 0000000..7f00366 --- /dev/null +++ b/test/exitval2.w32 @@ -0,0 +1,3 @@ +BEGIN { print "foo" | "sh -c \"read x ; echo $x ; exit 12\"" } +# this should still exit 0, as pointed out by kenny mccormack in +# comp.lang.awk on 2 feb 2005 diff --git a/test/fcall_exit.awk b/test/fcall_exit.awk new file mode 100644 index 0000000..931b607 --- /dev/null +++ b/test/fcall_exit.awk @@ -0,0 +1,24 @@ +#!/bin/awk -f + +function crash () { + exit 1 +} + +function true (a,b,c) { + return 0 +} + +BEGIN { + if (ARGV[1] == 1) { + print "true(1, 1, crash()) => crash properly." + true(1, 1, crash()) + } else if (ARGV[1] == 2) { + print "true(1, crash(), 1) => do not crash properly." + true(1, crash(),1) + } else { + print "true(1, crash()) => do not crash properly." + true(1, crash()) + } +} + +# FdF diff --git a/test/fcall_exit.ok b/test/fcall_exit.ok new file mode 100644 index 0000000..b289c6d --- /dev/null +++ b/test/fcall_exit.ok @@ -0,0 +1,2 @@ +true(1, crash()) => do not crash properly. +EXIT CODE: 1 diff --git a/test/fcall_exit2.awk b/test/fcall_exit2.awk new file mode 100644 index 0000000..cbf2082 --- /dev/null +++ b/test/fcall_exit2.awk @@ -0,0 +1,25 @@ +#!/bin/awk -f + +function crash () { + exit 1 +} + +function true (a,b,c) { + return 1 +} + +BEGIN { + if (ARGV[2] == 1) { + print " true(1, crash()) => crash properly." + true(1, crash()) + # ADR: Added: + delete ARGV[2] + } +} + +{ + print " true(1, crash()) => do not crash properly." + true(1, crash()) +} + +# FdF diff --git a/test/fcall_exit2.in b/test/fcall_exit2.in new file mode 100644 index 0000000..f7050c9 --- /dev/null +++ b/test/fcall_exit2.in @@ -0,0 +1 @@ +dummy input line diff --git a/test/fcall_exit2.ok b/test/fcall_exit2.ok new file mode 100644 index 0000000..6cc3da2 --- /dev/null +++ b/test/fcall_exit2.ok @@ -0,0 +1,2 @@ + true(1, crash()) => do not crash properly. +EXIT CODE: 1 diff --git a/test/fflush.ok b/test/fflush.ok new file mode 100644 index 0000000..4cf0df6 --- /dev/null +++ b/test/fflush.ok @@ -0,0 +1,16 @@ +1st +2nd +1st +2nd +1st +2nd +1st +2nd +1st +2nd +1st +2nd +1st +2nd +1st +2nd diff --git a/test/fflush.sh b/test/fflush.sh new file mode 100755 index 0000000..42d624c --- /dev/null +++ b/test/fflush.sh @@ -0,0 +1,16 @@ +#! /bin/sh +../gawk 'BEGIN{print "1st";fflush("/dev/stdout");print "2nd"|"cat"}' + +../gawk 'BEGIN{print "1st";fflush("/dev/stdout");print "2nd"|"cat"}'|cat + +../gawk 'BEGIN{print "1st";fflush("/dev/stdout");close("/dev/stdout");print "2nd"|"cat"}'|cat + +../gawk 'BEGIN{print "1st";fflush("/dev/stdout");print "2nd"|"cat";close("cat")}'|cat + +../gawk 'BEGIN{print "1st";fflush("/dev/stdout");print "2nd"|"cat";close("cat")}'|cat + +../gawk 'BEGIN{print "1st";fflush("/dev/stdout");print "2nd"|"cat";close("cat")}'|cat + +../gawk 'BEGIN{print "1st";fflush("/dev/stdout");print "2nd"|"sort"}'|cat + +../gawk 'BEGIN{print "1st";fflush("/dev/stdout");print "2nd"|"sort";close("sort")}'|cat diff --git a/test/fieldwdth.awk b/test/fieldwdth.awk new file mode 100644 index 0000000..f2eeb6c --- /dev/null +++ b/test/fieldwdth.awk @@ -0,0 +1,2 @@ +BEGIN { FIELDWIDTHS = "2 3 4" } +{ print $2 } diff --git a/test/fieldwdth.in b/test/fieldwdth.in new file mode 100644 index 0000000..28d1445 --- /dev/null +++ b/test/fieldwdth.in @@ -0,0 +1 @@ +123456789 diff --git a/test/fieldwdth.ok b/test/fieldwdth.ok new file mode 100644 index 0000000..51b4008 --- /dev/null +++ b/test/fieldwdth.ok @@ -0,0 +1 @@ +345 diff --git a/test/fldchg.awk b/test/fldchg.awk new file mode 100644 index 0000000..a8018f7 --- /dev/null +++ b/test/fldchg.awk @@ -0,0 +1,8 @@ +{ +# print "0:", $0 + gsub("aa", "+") + print "1:", $0 + $3 = "<" $3 ">" + print "2:", $0 + print "2a:" "%" $1 "%" $2 "%" $3 "%" $4 "%" $5 +} diff --git a/test/fldchg.in b/test/fldchg.in new file mode 100644 index 0000000..f500c36 --- /dev/null +++ b/test/fldchg.in @@ -0,0 +1 @@ +aa aab c d e f diff --git a/test/fldchg.ok b/test/fldchg.ok new file mode 100644 index 0000000..cc5032a --- /dev/null +++ b/test/fldchg.ok @@ -0,0 +1,3 @@ +1: + +b c d e f +2: + +b d e f +2a:%+%+b%%d%e diff --git a/test/fldchgnf.awk b/test/fldchgnf.awk new file mode 100644 index 0000000..fbb8f11 --- /dev/null +++ b/test/fldchgnf.awk @@ -0,0 +1 @@ +{ OFS = ":"; $2 = ""; print $0; print NF } diff --git a/test/fldchgnf.in b/test/fldchgnf.in new file mode 100644 index 0000000..8e13e46 --- /dev/null +++ b/test/fldchgnf.in @@ -0,0 +1 @@ +a b c d diff --git a/test/fldchgnf.ok b/test/fldchgnf.ok new file mode 100644 index 0000000..10b38ed --- /dev/null +++ b/test/fldchgnf.ok @@ -0,0 +1,2 @@ +a::c:d +4 diff --git a/test/fmtspcl.awk b/test/fmtspcl.awk new file mode 100644 index 0000000..6f037a3 --- /dev/null +++ b/test/fmtspcl.awk @@ -0,0 +1,26 @@ +function display(x,str, i,res) { + for (i = 0; i < n; i++) { + if ((res = sprintf(formats[i],x)) != str) + printf "sprintf(%s,%s) = %s (!= %s)\n", + formats[i],x,res,str + } +} + +BEGIN { + nan = sqrt(-1) + nan_str = sprintf("%f",nan) + nnan_str = sprintf("%f",-nan) + inf = -log(0) + inf_str = sprintf("%f",inf) + + n = 0 + formats[n++] = "%f" + formats[n++] = "%s" + formats[n++] = "%g" + formats[n++] = "%x" + formats[n++] = "%d" + display(nan,nan_str) + display(-nan,nnan_str) + display(inf,inf) + display(-inf,"-"inf_str) +} diff --git a/test/fmtspcl.tok b/test/fmtspcl.tok new file mode 100644 index 0000000..ba823b8 --- /dev/null +++ b/test/fmtspcl.tok @@ -0,0 +1,9 @@ +gawk: fmtspcl.awk:10: warning: sqrt: called with negative argument -1 +gawk: fmtspcl.awk:3: warning: [s]printf: value positive_nan is out of range for `%x' format +gawk: fmtspcl.awk:3: warning: [s]printf: value positive_nan is out of range for `%d' format +gawk: fmtspcl.awk:3: warning: [s]printf: value negative_nan is out of range for `%x' format +gawk: fmtspcl.awk:3: warning: [s]printf: value negative_nan is out of range for `%d' format +gawk: fmtspcl.awk:3: warning: [s]printf: value positive_infinity is out of range for `%x' format +gawk: fmtspcl.awk:3: warning: [s]printf: value positive_infinity is out of range for `%d' format +gawk: fmtspcl.awk:3: warning: [s]printf: value negative_infinity is out of range for `%x' format +gawk: fmtspcl.awk:3: warning: [s]printf: value negative_infinity is out of range for `%d' format diff --git a/test/fmttest.awk b/test/fmttest.awk new file mode 100644 index 0000000..e8db0fb --- /dev/null +++ b/test/fmttest.awk @@ -0,0 +1,164 @@ +### /u/sy/beebe/xml/shbook/fmttest.awk, Sat May 31 09:13:52 2003 +### Edit by Nelson H. F. Beebe +### ==================================================================== +### Test the degree of support for printf format items in awk +### implementations. +### +### Usage: +### awk -f fmttest.awk +### [31-May-2003] +### ==================================================================== + +BEGIN { + ## ----------------------------------------------------------------- + print "\n\nFormat item: c\n" + + printf("ABC with %%c : %c\n", "ABC") + printf("123 with %%c : %c\n", 123) + + printf("ABC with %%.15c : %.15c\n", "ABC") + printf("123 with %%.15c : %.15c\n", 123) + + printf("ABC with %%15c : %15c\n", "ABC") + printf("123 with %%15c : %15c\n", 123) + + printf("ABC with %%-15c : %-15c\n", "ABC") + printf("123 with %%-15c : %-15c\n", 123) + + ## ----------------------------------------------------------------- + print "\n\nFormat item: d\n" + + printf("ABC with %%d : %d\n", "ABC") + printf("123 with %%d : %d\n", 123) + + printf("ABC with %%.15d : %.15d\n", "ABC") + printf("123 with %%.15d : %.15d\n", 123) + + printf("ABC with %%15d : %15d\n", "ABC") + printf("123 with %%15d : %15d\n", 123) + + printf("ABC with %%-15d : %-15d\n", "ABC") + printf("123 with %%-15d : %-15d\n", 123) + + ## ----------------------------------------------------------------- + print "\n\nFormat item: e\n" + + printf("ABC with %%e : %e\n", "ABC") + printf("123 with %%e : %e\n", 123) + + printf("ABC with %%.25e : %.25e\n", "ABC") + printf("123 with %%.25e : %.25e\n", 123) + + printf("ABC with %%25e : %25e\n", "ABC") + printf("123 with %%25e : %25e\n", 123) + + printf("ABC with %%-25e : %-25e\n", "ABC") + printf("123 with %%-25e : %-25e\n", 123) + + ## ----------------------------------------------------------------- + print "\n\nFormat item: f\n" + + printf("ABC with %%f : %f\n", "ABC") + printf("123 with %%f : %f\n", 123) + + printf("ABC with %%.25f : %.25f\n", "ABC") + printf("123 with %%.25f : %.25f\n", 123) + + printf("ABC with %%25f : %25f\n", "ABC") + printf("123 with %%25f : %25f\n", 123) + + printf("ABC with %%-25f : %-25f\n", "ABC") + printf("123 with %%-25f : %-25f\n", 123) + + ## ----------------------------------------------------------------- + print "\n\nFormat item: g\n" + + printf("ABC with %%g : %g\n", "ABC") + printf("123 with %%g : %g\n", 123) + + printf("ABC with %%.25g : %.25g\n", "ABC") + printf("123 with %%.25g : %.25g\n", 123) + + printf("ABC with %%25g : %25g\n", "ABC") + printf("123 with %%25g : %25g\n", 123) + + printf("ABC with %%-25g : %-25g\n", "ABC") + printf("123 with %%-25g : %-25g\n", 123) + + ## ----------------------------------------------------------------- + print "\n\nFormat item: o\n" + + printf("ABC with %%o : %o\n", "ABC") + printf("123 with %%o : %o\n", 123) + + printf("ABC with %%.15o : %.15o\n", "ABC") + printf("123 with %%.15o : %.15o\n", 123) + + printf("ABC with %%15o : %15o\n", "ABC") + printf("123 with %%15o : %15o\n", 123) + + printf("ABC with %%-15o : %-15o\n", "ABC") + printf("123 with %%-15o : %-15o\n", 123) + + ## ----------------------------------------------------------------- + print "\n\nFormat item: s\n" + + printf("ABC with %%s : %s\n", "ABC") + printf("123 with %%s : %s\n", 123) + + printf("ABC with %%.15s : %.15s\n", "ABC") + printf("123 with %%.15s : %.15s\n", 123) + + printf("ABC with %%15s : %15s\n", "ABC") + printf("123 with %%15s : %15s\n", 123) + + printf("ABC with %%-15s : %-15s\n", "ABC") + printf("123 with %%-15s : %-15s\n", 123) + + ## ----------------------------------------------------------------- + print "\n\nFormat item: u\n" + + printf("ABC with %%u : %u\n", "ABC") + printf("123 with %%u : %u\n", 123) + + printf("ABC with %%.15u : %.15u\n", "ABC") + printf("123 with %%.15u : %.15u\n", 123) + + printf("ABC with %%15u : %15u\n", "ABC") + printf("123 with %%15u : %15u\n", 123) + + printf("ABC with %%-15u : %-15u\n", "ABC") + printf("123 with %%-15u : %-15u\n", 123) + + ## ----------------------------------------------------------------- + print "\n\nFormat item: x\n" + + printf("ABC with %%x : %x\n", "ABC") + printf("123 with %%x : %x\n", 123) + + printf("ABC with %%.15x : %.15x\n", "ABC") + printf("123 with %%.15x : %.15x\n", 123) + + printf("ABC with %%15x : %15x\n", "ABC") + printf("123 with %%15x : %15x\n", 123) + + printf("ABC with %%-15x : %-15x\n", "ABC") + printf("123 with %%-15x : %-15x\n", 123) + + ## ----------------------------------------------------------------- + print "\n\nFormat item: X\n" + + printf("ABC with %%X : %X\n", "ABC") + printf("123 with %%X : %X\n", 123) + + printf("ABC with %%.15X : %.15X\n", "ABC") + printf("123 with %%.15X : %.15X\n", 123) + + printf("ABC with %%15X : %15X\n", "ABC") + printf("123 with %%15X : %15X\n", 123) + + printf("ABC with %%-15X : %-15X\n", "ABC") + printf("123 with %%-15X : %-15X\n", 123) + + exit(0) +} diff --git a/test/fmttest.ok b/test/fmttest.ok new file mode 100644 index 0000000..753567a --- /dev/null +++ b/test/fmttest.ok @@ -0,0 +1,120 @@ + + +Format item: c + +ABC with %c : A +123 with %c : { +ABC with %.15c : A +123 with %.15c : { +ABC with %15c : A +123 with %15c : { +ABC with %-15c : A +123 with %-15c : { + + +Format item: d + +ABC with %d : 0 +123 with %d : 123 +ABC with %.15d : 000000000000000 +123 with %.15d : 000000000000123 +ABC with %15d : 0 +123 with %15d : 123 +ABC with %-15d : 0 +123 with %-15d : 123 + + +Format item: e + +ABC with %e : 0.000000e+00 +123 with %e : 1.230000e+02 +ABC with %.25e : 0.0000000000000000000000000e+00 +123 with %.25e : 1.2300000000000000000000000e+02 +ABC with %25e : 0.000000e+00 +123 with %25e : 1.230000e+02 +ABC with %-25e : 0.000000e+00 +123 with %-25e : 1.230000e+02 + + +Format item: f + +ABC with %f : 0.000000 +123 with %f : 123.000000 +ABC with %.25f : 0.0000000000000000000000000 +123 with %.25f : 123.0000000000000000000000000 +ABC with %25f : 0.000000 +123 with %25f : 123.000000 +ABC with %-25f : 0.000000 +123 with %-25f : 123.000000 + + +Format item: g + +ABC with %g : 0 +123 with %g : 123 +ABC with %.25g : 0 +123 with %.25g : 123 +ABC with %25g : 0 +123 with %25g : 123 +ABC with %-25g : 0 +123 with %-25g : 123 + + +Format item: o + +ABC with %o : 0 +123 with %o : 173 +ABC with %.15o : 000000000000000 +123 with %.15o : 000000000000173 +ABC with %15o : 0 +123 with %15o : 173 +ABC with %-15o : 0 +123 with %-15o : 173 + + +Format item: s + +ABC with %s : ABC +123 with %s : 123 +ABC with %.15s : ABC +123 with %.15s : 123 +ABC with %15s : ABC +123 with %15s : 123 +ABC with %-15s : ABC +123 with %-15s : 123 + + +Format item: u + +ABC with %u : 0 +123 with %u : 123 +ABC with %.15u : 000000000000000 +123 with %.15u : 000000000000123 +ABC with %15u : 0 +123 with %15u : 123 +ABC with %-15u : 0 +123 with %-15u : 123 + + +Format item: x + +ABC with %x : 0 +123 with %x : 7b +ABC with %.15x : 000000000000000 +123 with %.15x : 00000000000007b +ABC with %15x : 0 +123 with %15x : 7b +ABC with %-15x : 0 +123 with %-15x : 7b + + +Format item: X + +ABC with %X : 0 +123 with %X : 7B +ABC with %.15X : 000000000000000 +123 with %.15X : 00000000000007B +ABC with %15X : 0 +123 with %15X : 7B +ABC with %-15X : 0 +123 with %-15X : 7B diff --git a/test/fnamedat.awk b/test/fnamedat.awk new file mode 100644 index 0000000..33a0704 --- /dev/null +++ b/test/fnamedat.awk @@ -0,0 +1 @@ +function foo() { print foo } {foo()} diff --git a/test/fnamedat.in b/test/fnamedat.in new file mode 100644 index 0000000..257cc56 --- /dev/null +++ b/test/fnamedat.in @@ -0,0 +1 @@ +foo diff --git a/test/fnamedat.ok b/test/fnamedat.ok new file mode 100644 index 0000000..d32acff --- /dev/null +++ b/test/fnamedat.ok @@ -0,0 +1,2 @@ +gawk: fnamedat.awk:1: (FILENAME=- FNR=1) fatal: can't use function name `foo' as variable or array +EXIT CODE: 2 diff --git a/test/fnarray.awk b/test/fnarray.awk new file mode 100644 index 0000000..92a18b9 --- /dev/null +++ b/test/fnarray.awk @@ -0,0 +1,7 @@ +function foo(N) { + return 0 +} +BEGIN { + Num = foo[c] +} + diff --git a/test/fnarray.ok b/test/fnarray.ok new file mode 100644 index 0000000..04260b0 --- /dev/null +++ b/test/fnarray.ok @@ -0,0 +1,5 @@ +gawk: fnarray.awk:5: Num = foo[c] +gawk: fnarray.awk:5: ^ use of non-array as array +gawk: fnarray.awk:5: error: function `foo' called with space between name and `(', +or used as a variable or an array +EXIT CODE: 1 diff --git a/test/fnarray2.awk b/test/fnarray2.awk new file mode 100644 index 0000000..1723fbf --- /dev/null +++ b/test/fnarray2.awk @@ -0,0 +1,5 @@ +function pile(c, r) +{ + r = ++pile[c] +} +{ pile($1) } diff --git a/test/fnarray2.ok b/test/fnarray2.ok new file mode 100644 index 0000000..243e4cc --- /dev/null +++ b/test/fnarray2.ok @@ -0,0 +1,3 @@ +gawk: fnarray2.awk:3: r = ++pile[c] +gawk: fnarray2.awk:3: ^ use of non-array as array +EXIT CODE: 1 diff --git a/test/fnarydel.awk b/test/fnarydel.awk new file mode 100644 index 0000000..8a1264c --- /dev/null +++ b/test/fnarydel.awk @@ -0,0 +1,60 @@ +#!/usr/local/bin/gawk -f +BEGIN { + process() +} + +function process(aa,a) { + delete aa +} + +BEGIN { + for (i = 1; i < 10; i++) + a[i] = i; + + print "first loop" + for (i in a) + print a[i] + + delete a + + print "second loop" + for (i in a) + print a[i] + + for (i = 1; i < 10; i++) + a[i] = i; + + print "third loop" + for (i in a) + print a[i] + + print "call func" + delit(a) + + print "fourth loop" + for (i in a) + print a[i] + + stressit() +} + +function delit(arr) +{ + delete arr +} + +function stressit( array, i) +{ + delete array + array[4] = 4 + array[5] = 5 + delete array[5] + print "You should just see: 4 4" + for (i in array) + print i, array[i] + delete array + print "You should see nothing between this line" + for (i in array) + print i, array[i] + print "And this one" +} diff --git a/test/fnarydel.ok b/test/fnarydel.ok new file mode 100644 index 0000000..7f3e453 --- /dev/null +++ b/test/fnarydel.ok @@ -0,0 +1,27 @@ +first loop +4 +5 +6 +7 +8 +9 +1 +2 +3 +second loop +third loop +4 +5 +6 +7 +8 +9 +1 +2 +3 +call func +fourth loop +You should just see: 4 4 +4 4 +You should see nothing between this line +And this one diff --git a/test/fnaryscl.awk b/test/fnaryscl.awk new file mode 100644 index 0000000..b88778e --- /dev/null +++ b/test/fnaryscl.awk @@ -0,0 +1,10 @@ +BEGIN { + foo[1] = 4 + f1(foo) +} + +function f1(a) { f2(a) } + +function f2(b) { f3(b) } + +function f3(c) { c = 6 } diff --git a/test/fnaryscl.ok b/test/fnaryscl.ok new file mode 100644 index 0000000..ac84077 --- /dev/null +++ b/test/fnaryscl.ok @@ -0,0 +1,2 @@ +gawk: fnaryscl.awk:10: fatal: attempt to use array `c (from b, from a, from foo)' in a scalar context +EXIT CODE: 2 diff --git a/test/fnasgnm.awk b/test/fnasgnm.awk new file mode 100644 index 0000000..a18a848 --- /dev/null +++ b/test/fnasgnm.awk @@ -0,0 +1,14 @@ +# AFP_Bug1.awk - illustrate a problem with `gawk' (GNU Awk 3.0.3 on OS/2) +# Arthur Pool .. pool@commerce.uq.edu.au +# $Id: fnasgnm.awk,v 1.1.1.1 2008/11/16 19:21:15 arnold Exp $ + +# Assignment to a variable with the same name as a function from within +# that function causes an ABEND. +# +# Yes, I do realise that it's not a smart thing to do, but an error +# message would be a kinder response than a core dump (and would make +# debugging a whole lot easier). + +{ShowMe()} + +function ShowMe() {ShowMe = 1} diff --git a/test/fnasgnm.in b/test/fnasgnm.in new file mode 100644 index 0000000..a941931 --- /dev/null +++ b/test/fnasgnm.in @@ -0,0 +1 @@ +junk diff --git a/test/fnasgnm.ok b/test/fnasgnm.ok new file mode 100644 index 0000000..0db5c6d --- /dev/null +++ b/test/fnasgnm.ok @@ -0,0 +1,2 @@ +gawk: fnasgnm.awk:14: (FILENAME=- FNR=1) fatal: can't use function name `ShowMe' as variable or array +EXIT CODE: 2 diff --git a/test/fnmisc.awk b/test/fnmisc.awk new file mode 100644 index 0000000..4dcc94e --- /dev/null +++ b/test/fnmisc.awk @@ -0,0 +1,13 @@ +# Tue Feb 4 12:20:10 IST 2003 + +# Misc functions tests, in case we start mucking around in the grammar again. + +# Empty body shouldn't hurt anything: +function f() {} +BEGIN { f() } + +# Using a built-in function name should manage the symbol table +# correctly: +function split(x) { return x } + +function x(a) { return a } diff --git a/test/fnmisc.ok b/test/fnmisc.ok new file mode 100644 index 0000000..a265e40 --- /dev/null +++ b/test/fnmisc.ok @@ -0,0 +1,3 @@ +gawk: fnmisc.awk:11: function split(x) { return x } +gawk: fnmisc.awk:11: ^ `split' is a built-in function, it cannot be redefined +EXIT CODE: 1 diff --git a/test/fnparydl.awk b/test/fnparydl.awk new file mode 100644 index 0000000..ef3a822 --- /dev/null +++ b/test/fnparydl.awk @@ -0,0 +1,31 @@ +# fnparydl.awk --- check that deleting works with arrays +# that are parameters. +# +# Tue Jul 11 14:20:58 EDT 2000 + +function delit(a, k) +{ + print "BEFORE LOOP" + for (k in a) { + print "DELETING KEY", k + delete a[k] + } + print "AFTER LOOP" +} + +BEGIN { + for (i = 1 ; i <= 7; i++) { + q[i] = sprintf("element %d", i) + x[i] = i + y[i] = q[i] + } +# adump(q) + delit(q) +# for (i in q) +# delete q[i] + j = 0; + for (i in q) + j++ + print j, "elements still in q[]" +# adump(q) +} diff --git a/test/fnparydl.ok b/test/fnparydl.ok new file mode 100644 index 0000000..26a5c39 --- /dev/null +++ b/test/fnparydl.ok @@ -0,0 +1,10 @@ +BEFORE LOOP +DELETING KEY 4 +DELETING KEY 5 +DELETING KEY 6 +DELETING KEY 7 +DELETING KEY 1 +DELETING KEY 2 +DELETING KEY 3 +AFTER LOOP +0 elements still in q[] diff --git a/test/fordel.awk b/test/fordel.awk new file mode 100644 index 0000000..58ede20 --- /dev/null +++ b/test/fordel.awk @@ -0,0 +1,65 @@ +#Date: Mon, 7 Jun 2004 10:40:28 -0500 +#From: mary1john8@earthlink.net +#To: arnold@skeeve.com +#Subject: gawk internal errors +#Message-ID: <20040607154028.GA2457@apollo> +# +#Hello, +# +# gawk-3.1.3i internal errors: +# +#[1] +# +#$> ./gawk 'BEGIN { for (i in a) delete a; }' +BEGIN { for (i in a) delete a; } +#gawk: fatal error: internal error +#Aborted +# +#------------------------------------------------------------------ +#--- awkgram.y.orig 2004-06-07 09:42:14.000000000 -0500 +#+++ awkgram.y 2004-06-07 09:45:58.000000000 -0500 +#@@ -387,7 +387,7 @@ +# * Check that the body is a `delete a[i]' statement, +# * and that both the loop var and array names match. +# */ +#- if ($8 != NULL && $8->type == Node_K_delete) { +#+ if ($8 != NULL && $8->type == Node_K_delete && $8->rnode != NULL) { +# NODE *arr, *sub; +# +# assert($8->rnode->type == Node_expression_list); +#------------------------------------------------------------------ +# +# +#[2] +# +#$> ./gawk 'BEGIN { printf("%3$*10$.*1$s\n", 20, 10, "hello"); }' +#gawk: fatal error: internal error +#Aborted +# +#------------------------------------------------------------------ +#--- builtin.c.orig 2004-06-07 10:04:20.000000000 -0500 +#+++ builtin.c 2004-06-07 10:06:08.000000000 -0500 +#@@ -780,7 +780,10 @@ +# s1++; +# n0--; +# } +#- +#+ if (val >= num_args) { +#+ toofew = TRUE; +#+ break; +#+ } +# arg = the_args[val]; +# } else { +# parse_next_arg(); +#------------------------------------------------------------------ +# +# +# Finally, a test for the rewritten get_src_buf(): +# +#$> AWKBUFSIZE=2 make check +# +#I get 3 failed tests. Not sure this is of any interest. +# +# +#Thanks, +#John diff --git a/test/fordel.ok b/test/fordel.ok new file mode 100644 index 0000000..e69de29 diff --git a/test/forref.awk b/test/forref.awk new file mode 100644 index 0000000..5f9ad35 --- /dev/null +++ b/test/forref.awk @@ -0,0 +1,11 @@ +BEGIN { + names[1] = "s" + names[2] = "m" + for (i in names) { + x[names[i]] = i + print i, names[i], x[names[i]] + } + print x["s"] +# adump(x) +# adump(names) +} diff --git a/test/forref.ok b/test/forref.ok new file mode 100644 index 0000000..e8088d0 --- /dev/null +++ b/test/forref.ok @@ -0,0 +1,3 @@ +1 s 1 +2 m 2 +1 diff --git a/test/forsimp.awk b/test/forsimp.awk new file mode 100644 index 0000000..880548b --- /dev/null +++ b/test/forsimp.awk @@ -0,0 +1 @@ +BEGIN { for (print 9; 0;); } diff --git a/test/forsimp.ok b/test/forsimp.ok new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/test/forsimp.ok @@ -0,0 +1 @@ +9 diff --git a/test/fpat1.awk b/test/fpat1.awk new file mode 100644 index 0000000..60c6bca --- /dev/null +++ b/test/fpat1.awk @@ -0,0 +1,22 @@ +BEGIN { +# if (t == 0) + FPAT = "([^,]+)|(\"[^\"]+\")" +# else +# FPAT = "([^,]*)|(\"[^\"]+\")" +} +FNR == 1 { + # This part was added later + print $1 + print $1, $3 + for (i = 1; i <= NF; i++) + print i, $i + + # Reset for original part of test + FPAT = "([^,]*)|(\"[^\"]+\")" + $0 = $0 +} +{ + print "NF =", NF + for (i = 1; i <= NF; i++) + printf("$%d = <%s>\n", i, $i) +} diff --git a/test/fpat1.in b/test/fpat1.in new file mode 100644 index 0000000..03f2a3f --- /dev/null +++ b/test/fpat1.in @@ -0,0 +1,2 @@ +Robbins,Arnold,"1234 A Pretty Place, NE",Sometown,NY,12345-6789,USA +Smith,,"1234 A Pretty Place, NE",Sometown,NY,12345-6789,USA diff --git a/test/fpat1.ok b/test/fpat1.ok new file mode 100644 index 0000000..c5888e3 --- /dev/null +++ b/test/fpat1.ok @@ -0,0 +1,25 @@ +Robbins +Robbins "1234 A Pretty Place, NE" +1 Robbins +2 Arnold +3 "1234 A Pretty Place, NE" +4 Sometown +5 NY +6 12345-6789 +7 USA +NF = 7 +$1 = +$2 = +$3 = <"1234 A Pretty Place, NE"> +$4 = +$5 = +$6 = <12345-6789> +$7 = +NF = 7 +$1 = +$2 = <> +$3 = <"1234 A Pretty Place, NE"> +$4 = +$5 = +$6 = <12345-6789> +$7 = diff --git a/test/fpat2.awk b/test/fpat2.awk new file mode 100644 index 0000000..aa9e6be --- /dev/null +++ b/test/fpat2.awk @@ -0,0 +1,11 @@ +BEGIN { + FPAT = " " + $0 = "" + print NF + + $0 = "abc" + print NF + + $0 = "a b c" + print NF +} diff --git a/test/fpat2.ok b/test/fpat2.ok new file mode 100644 index 0000000..67bbf9c --- /dev/null +++ b/test/fpat2.ok @@ -0,0 +1,3 @@ +0 +0 +2 diff --git a/test/fpat3.awk b/test/fpat3.awk new file mode 100644 index 0000000..801bb58 --- /dev/null +++ b/test/fpat3.awk @@ -0,0 +1,10 @@ +BEGIN { + FPAT = "[^,]*" + +} + +{ + if (x) NF + for (i = 1; i <= 4; ++i) + print i, $i +} diff --git a/test/fpat3.in b/test/fpat3.in new file mode 100644 index 0000000..28416a4 --- /dev/null +++ b/test/fpat3.in @@ -0,0 +1 @@ +a,b,,c diff --git a/test/fpat3.ok b/test/fpat3.ok new file mode 100644 index 0000000..543bb42 --- /dev/null +++ b/test/fpat3.ok @@ -0,0 +1,4 @@ +1 a +2 b +3 +4 c diff --git a/test/fpatnull.awk b/test/fpatnull.awk new file mode 100644 index 0000000..1d00adf --- /dev/null +++ b/test/fpatnull.awk @@ -0,0 +1,2 @@ +BEGIN { FPAT = "" } +{ print NF } diff --git a/test/fpatnull.in b/test/fpatnull.in new file mode 100644 index 0000000..4b5fa63 --- /dev/null +++ b/test/fpatnull.in @@ -0,0 +1 @@ +hello, world diff --git a/test/fpatnull.ok b/test/fpatnull.ok new file mode 100644 index 0000000..b1bd38b --- /dev/null +++ b/test/fpatnull.ok @@ -0,0 +1 @@ +13 diff --git a/test/fsbs.awk b/test/fsbs.awk new file mode 100644 index 0000000..1c6f9d6 --- /dev/null +++ b/test/fsbs.awk @@ -0,0 +1,2 @@ +BEGIN { FS = "\\" } +{ print $1, $2} diff --git a/test/fsbs.in b/test/fsbs.in new file mode 100644 index 0000000..0a102c3 --- /dev/null +++ b/test/fsbs.in @@ -0,0 +1 @@ +1\2 diff --git a/test/fsbs.ok b/test/fsbs.ok new file mode 100644 index 0000000..8d04f96 --- /dev/null +++ b/test/fsbs.ok @@ -0,0 +1 @@ +1 2 diff --git a/test/fsfwfs.awk b/test/fsfwfs.awk new file mode 100644 index 0000000..beed10a --- /dev/null +++ b/test/fsfwfs.awk @@ -0,0 +1 @@ +BEGIN{FIELDWIDTHS="6 6 6 5";OFS=",";FS=FS}{print $1,$2,$3,$4} diff --git a/test/fsfwfs.in b/test/fsfwfs.in new file mode 100644 index 0000000..fc10928 --- /dev/null +++ b/test/fsfwfs.in @@ -0,0 +1,16 @@ +00000113000 00000000000 +00000275000 00000000000 +00000321334 00000000000 +00000048709 00000010000 +00000117000 00000100000 +00000152000 00000138000 +00000000000 00000150000 +00000189425 00000000000 +00000146128 00000000000 +00000146128 00000000000 +00000146128 00000000000 +00000000000 00000050000 +00000000000 00000050000 +00000000000 00000000000 +00000158014 00000000000 +00000113656 00000000000 diff --git a/test/fsfwfs.ok b/test/fsfwfs.ok new file mode 100644 index 0000000..36bea48 --- /dev/null +++ b/test/fsfwfs.ok @@ -0,0 +1,16 @@ +00000113000,00000000000,, +00000275000,00000000000,, +00000321334,00000000000,, +00000048709,00000010000,, +00000117000,00000100000,, +00000152000,00000138000,, +00000000000,00000150000,, +00000189425,00000000000,, +00000146128,00000000000,, +00000146128,00000000000,, +00000146128,00000000000,, +00000000000,00000050000,, +00000000000,00000050000,, +00000000000,00000000000,, +00000158014,00000000000,, +00000113656,00000000000,, diff --git a/test/fsrs.awk b/test/fsrs.awk new file mode 100644 index 0000000..a001489 --- /dev/null +++ b/test/fsrs.awk @@ -0,0 +1,8 @@ +BEGIN { + RS=""; FS="\n"; + ORS=""; OFS="\n"; + } +{ + split ($2,f," ") + print $0; +} diff --git a/test/fsrs.in b/test/fsrs.in new file mode 100644 index 0000000..4b49d81 --- /dev/null +++ b/test/fsrs.in @@ -0,0 +1,7 @@ +a b +c d +e f + +1 2 +3 4 +5 6 diff --git a/test/fsrs.ok b/test/fsrs.ok new file mode 100644 index 0000000..7dafd65 --- /dev/null +++ b/test/fsrs.ok @@ -0,0 +1,5 @@ +a b +c d +e f1 2 +3 4 +5 6 \ No newline at end of file diff --git a/test/fsspcoln.awk b/test/fsspcoln.awk new file mode 100644 index 0000000..8087c2e --- /dev/null +++ b/test/fsspcoln.awk @@ -0,0 +1,41 @@ +# Date: Wed, 08 Dec 2004 12:59:42 +0600 +# From: Alexander Sashnov +# Subject: addon to gawk test suite +# Sender: asashnov@sashnov.plesk.ru +# To: "Arnold D. Robbins" +# Message-id: +# +# +# Hello, Arnold. +# +# I'm hit bug on SuSE 9.1 with awk: +# +# vsuse91:~ # echo "a:b:c" | awk '{ print $2 }' 'FS=[ :]' +# b +# vsuse91:~ # echo "a:b:c" | awk '{ print $2 }' 'FS=[ :]+' +# awk: cmd. line:2: fatal: Trailing backslash: /[ :]+/ +# +# vsuse91:~ # awk --version +# GNU Awk 3.1.3 +# +# +# +# But on my Debian machine all OK: +# +# asashnov@sashnov:~$ echo "a:b:c" | awk '{ print $2 }' 'FS=[ :]' +# b +# asashnov@sashnov:~$ echo "a:b:c" | awk '{ print $2 }' 'FS=[ :]+' +# b +# asashnov@sashnov:~$ awk --version +# GNU Awk 3.1.4 +# +# +# Need add test for this sample to gawk test suite for avoid this problems in future. +# -- +# Alexander Sashnov +# Plesk QA Engineer +# SWsoft, Inc. +# E-mail: asashnov@sw-soft.com +# ICQ UIN: 79404252 + +{ print $2 } diff --git a/test/fsspcoln.in b/test/fsspcoln.in new file mode 100644 index 0000000..af0abb2 --- /dev/null +++ b/test/fsspcoln.in @@ -0,0 +1 @@ +a:b:c diff --git a/test/fsspcoln.ok b/test/fsspcoln.ok new file mode 100644 index 0000000..6178079 --- /dev/null +++ b/test/fsspcoln.ok @@ -0,0 +1 @@ +b diff --git a/test/fstabplus.awk b/test/fstabplus.awk new file mode 100644 index 0000000..748a44f --- /dev/null +++ b/test/fstabplus.awk @@ -0,0 +1,2 @@ +BEGIN { FS = "\t+" } + { print $1, $2 } diff --git a/test/fstabplus.in b/test/fstabplus.in new file mode 100644 index 0000000..c35ba0a --- /dev/null +++ b/test/fstabplus.in @@ -0,0 +1 @@ +1 2 diff --git a/test/fstabplus.ok b/test/fstabplus.ok new file mode 100644 index 0000000..8d04f96 --- /dev/null +++ b/test/fstabplus.ok @@ -0,0 +1 @@ +1 2 diff --git a/test/funlen.awk b/test/funlen.awk new file mode 100644 index 0000000..e881fcb --- /dev/null +++ b/test/funlen.awk @@ -0,0 +1,69 @@ +# Date: Sat, 15 Mar 2008 16:21:19 +0100 +# From: Hermann Peifer +# Subject: [Fwd: Gawk length(array) bug] +# To: bug-gawk@gnu.org +# Cc: Aharon Robbins +# Message-id: <47DBE96F.1060406@gmx.net> +# +# See below. Regards, Hermann +# +# -------- Original Message -------- +# Subject: Re: Gawk length(array) question +# Date: Sat, 15 Mar 2008 08:02:03 -0500 +# From: Ed Morton +# Newsgroups: comp.lang.awk +# References: <47DBAE29.4050709@gmx.eu> +# +# On 3/15/2008 6:08 AM, Hermann Peifer wrote: +# > Hi All, +# > +# > The Gawk man page says: +# > > Starting with version 3.1.5, as a non-standard extension, +# > > with an array argument, length() returns the number +# > > of elements in the array. +# > +# > It looks like Gawk's length(array) extension does not work inside +# > functions. Is this a bug or feature or am I missing something? See the +# > example below. I am using GNU Awk 3.1.6 +# > +# > $ cat testdata +# > CD NAME +# > AT Austria +# > BG Bulgaria +# > CH Switzerland +# > DE Germany +# > EE Estonia +# > FR France +# > GR Greece +# > +# > $ cat test.awk +# > +# Populate array +NR > 1 { array[$1] = $2 } + +# Print array length and call function A +END { print "array:",length(array) ; A(array) } + +function A(array_A) { print "array_A:", length(array_A) } +# > +# > $ gawk -f test.awk testdata +# > array: 7 +# > gawk: test.awk:8: (FILENAME=data FNR=8) fatal: attempt to use array +# > `array_A (from array)' in a scalar context +# > +# > BTW, there is no such error if I have asort(array_A) or asorti(array_A) +# > inside the function. +# > +# > Hermann +# +# I get the same result with gawk 3.1.6 for cygwin. Obviously you can work +# around +# it since asort() returns the number of elements in an array just like +# length() +# is supposed to (or "for (i in array) lgth++" if you don't want to be +# gawk-specific) but it does seem like a bug. Anyone know if there's a list of +# known gawk bugs on-line somewhere? +# +# Ed. +# +# diff --git a/test/funlen.in b/test/funlen.in new file mode 100644 index 0000000..d0e0b04 --- /dev/null +++ b/test/funlen.in @@ -0,0 +1,8 @@ +CD NAME +AT Austria +BG Bulgaria +CH Switzerland +DE Germany +EE Estonia +FR France +GR Greece diff --git a/test/funlen.ok b/test/funlen.ok new file mode 100644 index 0000000..2e2ba9d --- /dev/null +++ b/test/funlen.ok @@ -0,0 +1,2 @@ +array: 7 +array_A: 7 diff --git a/test/funsemnl.awk b/test/funsemnl.awk new file mode 100644 index 0000000..6b39dca --- /dev/null +++ b/test/funsemnl.awk @@ -0,0 +1,3 @@ +# make sure that ; + \n at end after function works +function foo() { print "foo" } ; +BEGIN { foo() } diff --git a/test/funsemnl.ok b/test/funsemnl.ok new file mode 100644 index 0000000..257cc56 --- /dev/null +++ b/test/funsemnl.ok @@ -0,0 +1 @@ +foo diff --git a/test/funsmnam.awk b/test/funsmnam.awk new file mode 100644 index 0000000..1e8ca50 --- /dev/null +++ b/test/funsmnam.awk @@ -0,0 +1,6 @@ +function foo( \ + foo) +{ + print foo +} +{ foo() } diff --git a/test/funsmnam.ok b/test/funsmnam.ok new file mode 100644 index 0000000..e4f2174 --- /dev/null +++ b/test/funsmnam.ok @@ -0,0 +1,2 @@ +gawk: funsmnam.awk:1: error: function `foo': can't use function name as parameter name +EXIT CODE: 1 diff --git a/test/funstack.awk b/test/funstack.awk new file mode 100644 index 0000000..9545690 --- /dev/null +++ b/test/funstack.awk @@ -0,0 +1,981 @@ +### ==================================================================== +### @Awk-file{ +### author = "Nelson H. F. Beebe", +### version = "1.00", +### date = "09 October 1996", +### time = "15:57:06 MDT", +### filename = "journal-toc.awk", +### address = "Center for Scientific Computing +### Department of Mathematics +### University of Utah +### Salt Lake City, UT 84112 +### USA", +### telephone = "+1 801 581 5254", +### FAX = "+1 801 581 4148", +### URL = "http://www.math.utah.edu/~beebe", +### checksum = "25092 977 3357 26493", +### email = "beebe@math.utah.edu (Internet)", +### codetable = "ISO/ASCII", +### keywords = "BibTeX, bibliography, HTML, journal table of +### contents", +### supported = "yes", +### docstring = "Create a journal cover table of contents from +### Article{...} entries in a journal BibTeX +### .bib file for checking the bibliography +### database against the actual journal covers. +### The output can be either plain text, or HTML. +### +### Usage: +### bibclean -max-width 0 BibTeX-file(s) | \ +### bibsort -byvolume | \ +### awk -f journal-toc.awk \ +### [-v HTML=nnn] [-v INDENT=nnn] \ +### [-v BIBFILEURL=url] >foo.toc +### +### or if the bibliography is already sorted +### by volume, +### +### bibclean -max-width 0 BibTeX-file(s) | \ +### awk -f journal-toc.awk \ +### [-v HTML=nnn] [-v INDENT=nnn] \ +### [-v BIBFILEURL=url] >foo.toc +### +### A non-zero value of the command-line option, +### HTML=nnn, results in HTML output instead of +### the default plain ASCII text (corresponding +### to HTML=0). The +### +### The INDENT=nnn command-line option specifies +### the number of blanks to indent each logical +### level of HTML. The default is INDENT=4. +### INDENT=0 suppresses indentation. The INDENT +### option has no effect when the default HTML=0 +### (plain text output) option is in effect. +### +### When HTML output is selected, the +### BIBFILEURL=url command-line option provides a +### way to request hypertext links from table of +### contents page numbers to the complete BibTeX +### entry for the article. These links are +### created by appending a sharp (#) and the +### citation label to the BIBFILEURL value, which +### conforms with the practice of +### bibtex-to-html.awk. +### +### The HTML output form may be useful as a more +### compact representation of journal article +### bibliography data than the original BibTeX +### file provides. Of course, the +### table-of-contents format provides less +### information, and is considerably more +### troublesome for a computer program to parse. +### +### When URL key values are provided, they will +### be used to create hypertext links around +### article titles. This supports journals that +### provide article contents on the World-Wide +### Web. +### +### For parsing simplicity, this program requires +### that BibTeX +### +### key = "value" +### +### and +### +### @String{name = "value"} +### +### specifications be entirely contained on +### single lines, which is readily provided by +### the `bibclean -max-width 0' filter. It also +### requires that bibliography entries begin and +### end at the start of a line, and that +### quotation marks, rather than balanced braces, +### delimit string values. This is a +### conventional format that again can be +### guaranteed by bibclean. +### +### This program requires `new' awk, as described +### in the book +### +### Alfred V. Aho, Brian W. Kernighan, and +### Peter J. Weinberger, +### ``The AWK Programming Language'', +### Addison-Wesley (1988), ISBN +### 0-201-07981-X, +### +### such as provided by programs named (GNU) +### gawk, nawk, and recent AT&T awk. +### +### The checksum field above contains a CRC-16 +### checksum as the first value, followed by the +### equivalent of the standard UNIX wc (word +### count) utility output of lines, words, and +### characters. This is produced by Robert +### Solovay's checksum utility.", +### } +### ==================================================================== + +BEGIN { initialize() } + +/^ *@ *[Ss][Tt][Rr][Ii][Nn][Gg] *\{/ { do_String(); next } + +/^ *@ *[Pp][Rr][Ee][Aa][Mm][Bb][Ll][Ee]/ { next } + +/^ *@ *[Aa][Rr][Tt][Ii][Cc][Ll][Ee]/ { do_Article(); next } + +/^ *@/ { do_Other(); next } + +/^ *author *= *\"/ { do_author(); next } + +/^ *journal *= */ { do_journal(); next } + +/^ *volume *= *\"/ { do_volume(); next } + +/^ *number *= *\"/ { do_number(); next } + +/^ *year *= *\"/ { do_year(); next } + +/^ *month *= */ { do_month(); next } + +/^ *title *= *\"/ { do_title(); next } + +/^ *pages *= *\"/ { do_pages(); next } + +/^ *URL *= *\"/ { do_URL(); next } + +/^ *} *$/ { if (In_Article) do_end_entry(); next } + +END { terminate() } + + +######################################################################## +# NB: The programming conventions for variables in this program are: # +# UPPERCASE global constants and user options # +# Initialuppercase global variables # +# lowercase local variables # +# Any deviation is an error! # +######################################################################## + + +function do_Article() +{ + In_Article = 1 + + Citation_label = $0 + sub(/^[^\{]*\{/,"",Citation_label) + sub(/ *, *$/,"",Citation_label) + + Author = "" + Title = "" + Journal = "" + Volume = "" + Number = "" + Month = "" + Year = "" + Pages = "" + Url = "" +} + + +function do_author() +{ + Author = TeX_to_HTML(get_value($0)) +} + + +function do_end_entry( k,n,parts) +{ + n = split(Author,parts," and ") + if (Last_number != Number) + do_new_issue() + for (k = 1; k < n; ++k) + print_toc_line(parts[k] " and", "", "") + Title_prefix = html_begin_title() + Title_suffix = html_end_title() + if (html_length(Title) <= (MAX_TITLE_CHARS + MIN_LEADERS)) # complete title fits on line + print_toc_line(parts[n], Title, html_begin_pages() Pages html_end_pages()) + else # need to split long title over multiple lines + do_long_title(parts[n], Title, html_begin_pages() Pages html_end_pages()) +} + + +function do_journal() +{ + if ($0 ~ /[=] *"/) # have journal = "quoted journal name", + Journal = get_value($0) + else # have journal = journal-abbreviation, + { + Journal = get_abbrev($0) + if (Journal in String) # replace abbrev by its expansion + Journal = String[Journal] + } + gsub(/\\-/,"",Journal) # remove discretionary hyphens +} + + +function do_long_title(author,title,pages, last_title,n) +{ + title = trim(title) # discard leading and trailing space + while (length(title) > 0) + { + n = html_breakpoint(title,MAX_TITLE_CHARS+MIN_LEADERS) + last_title = substr(title,1,n) + title = substr(title,n+1) + sub(/^ +/,"",title) # discard any leading space + print_toc_line(author, last_title, (length(title) == 0) ? pages : "") + author = "" + } +} + + +function do_month( k,n,parts) +{ + Month = ($0 ~ /[=] *"/) ? get_value($0) : get_abbrev($0) + gsub(/[\"]/,"",Month) + gsub(/ *# *\\slash *# */," / ",Month) + gsub(/ *# *-+ *# */," / ",Month) + n = split(Month,parts," */ *") + Month = "" + for (k = 1; k <= n; ++k) + Month = Month ((k > 1) ? " / " : "") \ + ((parts[k] in Month_expansion) ? Month_expansion[parts[k]] : parts[k]) +} + + +function do_new_issue() +{ + Last_number = Number + if (HTML) + { + if (Last_volume != Volume) + { + Last_volume = Volume + print_line(prefix(2) "
") + } + html_end_toc() + html_begin_issue() + print_line(prefix(2) Journal "
") + } + else + { + print_line("") + print_line(Journal) + } + + print_line(strip_html(vol_no_month_year())) + + if (HTML) + { + html_end_issue() + html_toc_entry() + html_begin_toc() + } + else + print_line("") +} + + +function do_number() +{ + Number = get_value($0) +} + + +function do_Other() +{ + In_Article = 0 +} + + +function do_pages() +{ + Pages = get_value($0) + sub(/--[?][?]/,"",Pages) +} + + +function do_String() +{ + sub(/^[^\{]*\{/,"",$0) # discard up to and including open brace + sub(/\} *$/,"",$0) # discard from optional whitespace and trailing brace to end of line + String[get_key($0)] = get_value($0) +} + + +function do_title() +{ + Title = TeX_to_HTML(get_value($0)) +} + + +function do_URL( parts) +{ + Url = get_value($0) + split(Url,parts,"[,;]") # in case we have multiple URLs + Url = trim(parts[1]) +} + + +function do_volume() +{ + Volume = get_value($0) +} + + +function do_year() +{ + Year = get_value($0) +} + + +function get_abbrev(s) +{ # return abbrev from ``key = abbrev,'' + sub(/^[^=]*= */,"",s) # discard text up to start of non-blank value + sub(/ *,? *$/,"",s) # discard trailing optional whitspace, quote, + # optional comma, and optional space + return (s) +} + + +function get_key(s) +{ # return kay from ``key = "value",'' + sub(/^ */,"",s) # discard leading space + sub(/ *=.*$/,"",s) # discard everthing after key + + return (s) +} + + +function get_value(s) +{ # return value from ``key = "value",'' + sub(/^[^\"]*\" */,"",s) # discard text up to start of non-blank value + sub(/ *\",? *$/,"",s) # discard trailing optional whitspace, quote, + # optional comma, and optional space + return (s) +} + + +function html_accents(s) +{ + if (index(s,"\\") > 0) # important optimization + { + # Convert common lower-case accented letters according to the + # table on p. 169 of in Peter Flynn's ``The World Wide Web + # Handbook'', International Thomson Computer Press, 1995, ISBN + # 1-85032-205-8. The official table of ISO Latin 1 SGML + # entities used in HTML can be found in the file + # /usr/local/lib/html-check/lib/ISOlat1.sgml (your path + # may differ). + + gsub(/{\\\a}/, "\\à", s) + gsub(/{\\'a}/, "\\á", s) + gsub(/{\\[\^]a}/,"\\â", s) + gsub(/{\\~a}/, "\\ã", s) + gsub(/{\\\"a}/, "\\ä", s) + gsub(/{\\aa}/, "\\å", s) + gsub(/{\\ae}/, "\\æ", s) + + gsub(/\{\\c\{c\}\}/,"\\ç", s) + + gsub(/\{\\\e\}/, "\\è", s) + gsub(/\{\\'e\}/, "\\é", s) + gsub(/\{\\[\^]e\}/,"\\ê", s) + gsub(/\{\\\"e\}/, "\\ë", s) + + gsub(/\{\\\i\}/, "\\ì", s) + gsub(/\{\\'i\}/, "\\í", s) + gsub(/\{\\[\^]i\}/,"\\î", s) + gsub(/\{\\\"i\}/, "\\ï", s) + + # ignore eth and thorn + + gsub(/\{\\~n\}/, "\\ñ", s) + + gsub(/\{\\\o\}/, "\\ò", s) + gsub(/\{\\'o\}/, "\\ó", s) + gsub(/\{\\[\^]o\}/, "\\ô", s) + gsub(/\{\\~o\}/, "\\õ", s) + gsub(/\{\\\"o\}/, "\\ö", s) + gsub(/\{\\o\}/, "\\ø", s) + + gsub(/\{\\\u\}/, "\\ù", s) + gsub(/\{\\'u\}/, "\\ú", s) + gsub(/\{\\[\^]u\}/,"\\û", s) + gsub(/\{\\\"u\}/, "\\ü", s) + + gsub(/\{\\'y\}/, "\\ý", s) + gsub(/\{\\\"y\}/, "\\ÿ", s) + + # Now do the same for upper-case accents + + gsub(/\{\\\A\}/, "\\À", s) + gsub(/\{\\'A\}/, "\\Á", s) + gsub(/\{\\[\^]A\}/, "\\Â", s) + gsub(/\{\\~A\}/, "\\Ã", s) + gsub(/\{\\\"A\}/, "\\Ä", s) + gsub(/\{\\AA\}/, "\\Å", s) + gsub(/\{\\AE\}/, "\\Æ", s) + + gsub(/\{\\c\{C\}\}/,"\\Ç", s) + + gsub(/\{\\\e\}/, "\\È", s) + gsub(/\{\\'E\}/, "\\É", s) + gsub(/\{\\[\^]E\}/, "\\Ê", s) + gsub(/\{\\\"E\}/, "\\Ë", s) + + gsub(/\{\\\I\}/, "\\Ì", s) + gsub(/\{\\'I\}/, "\\Í", s) + gsub(/\{\\[\^]I\}/, "\\Î", s) + gsub(/\{\\\"I\}/, "\\Ï", s) + + # ignore eth and thorn + + gsub(/\{\\~N\}/, "\\Ñ", s) + + gsub(/\{\\\O\}/, "\\Ò", s) + gsub(/\{\\'O\}/, "\\Ó", s) + gsub(/\{\\[\^]O\}/, "\\Ô", s) + gsub(/\{\\~O\}/, "\\Õ", s) + gsub(/\{\\\"O\}/, "\\Ö", s) + gsub(/\{\\O\}/, "\\Ø", s) + + gsub(/\{\\\U\}/, "\\Ù", s) + gsub(/\{\\'U\}/, "\\Ú", s) + gsub(/\{\\[\^]U\}/, "\\Û", s) + gsub(/\{\\\"U\}/, "\\Ü", s) + + gsub(/\{\\'Y\}/, "\\Ý", s) + + gsub(/\{\\ss\}/, "\\ß", s) + + # Others not mentioned in Flynn's book + gsub(/\{\\'\\i\}/,"\\í", s) + gsub(/\{\\'\\j\}/,"j", s) + } + return (s) +} + + +function html_begin_issue() +{ + print_line("") + print_line(prefix(2) "


") + print_line("") + print_line(prefix(2) "
") +} + + +function html_end_pages() +{ + return ((HTML && (BIBFILEURL != "")) ? "" : "") +} + + +function html_end_pre() +{ + if (In_PRE) + { + print_line("") + In_PRE = 0 + } +} + + +function html_end_title() +{ + return ((HTML && (Url != "")) ? "" : "") +} + + +function html_end_toc() +{ + html_end_pre() +} + + +function html_fonts(s, arg,control_word,k,level,n,open_brace) +{ + open_brace = index(s,"{") + if (open_brace > 0) # important optimization + { + level = 1 + for (k = open_brace + 1; (level != 0) && (k <= length(s)); ++k) + { + if (substr(s,k,1) == "{") + level++ + else if (substr(s,k,1) == "}") + level-- + } + + # {...} is now found at open_brace ... (k-1) + for (control_word in Font_decl_map) # look for {\xxx ...} + { + if (substr(s,open_brace+1,length(control_word)+1) ~ \ + ("\\" control_word "[^A-Za-z]")) + { + n = open_brace + 1 + length(control_word) + arg = trim(substr(s,n,k - n)) + if (Font_decl_map[control_word] == "toupper") # arg -> ARG + arg = toupper(arg) + else if (Font_decl_map[control_word] != "") # arg -> arg + arg = "<" Font_decl_map[control_word] ">" arg "" + return (substr(s,1,open_brace-1) arg html_fonts(substr(s,k))) + } + } + for (control_word in Font_cmd_map) # look for \xxx{...} + { + if (substr(s,open_brace - length(control_word),length(control_word)) ~ \ + ("\\" control_word)) + { + n = open_brace + 1 + arg = trim(substr(s,n,k - n)) + if (Font_cmd_map[control_word] == "toupper") # arg -> ARG + arg = toupper(arg) + else if (Font_cmd_map[control_word] != "") # arg -> arg + arg = "<" Font_cmd_map[control_word] ">" arg "" + n = open_brace - length(control_word) - 1 + return (substr(s,1,n) arg html_fonts(substr(s,k))) + } + } + } + return (s) +} + + +function html_header() +{ + USER = ENVIRON["USER"] + if (USER == "") + USER = ENVIRON["LOGNAME"] + if (USER == "") + USER = "????" + "hostname" | getline HOSTNAME + "date" | getline DATE + ("ypcat passwd | grep '^" USER ":' | awk -F: '{print $5}'") | getline PERSONAL_NAME + if (PERSONAL_NAME == "") + ("grep '^" USER ":' /etc/passwd | awk -F: '{print $5}'") | getline PERSONAL_NAME + + + print "" + print "" + print "" + print "" + print "" + print "" + print "" + print "" + print "" + print prefix(1) "" + print prefix(2) "" + print prefix(3) Journal + print prefix(2) "" + print prefix(2) "" + print prefix(1) "" + print "" + print prefix(1) "" +} + + +function html_label( label) +{ + label = Volume "(" Number "):" Month ":" Year + # gsub(/[^A-Za-z0-9():,;.\/\-]/,"",label) + gsub(/[^[:alnum:]():,;.\/\-]/,"",label) + return (label) +} + + +function html_length(s) +{ # Return visible length of s, ignoring any HTML markup + if (HTML) + { + gsub(/<\/?[^>]*>/,"",s) # remove SGML tags + # gsub(/&[A-Za-z0-9]+;/,"",s) # remove SGML entities + gsub(/&[[:alnum:]]+;/,"",s) # remove SGML entities + } + return (length(s)) +} + + +function html_toc() +{ + print prefix(2) "

" + print prefix(3) "Table of contents for issues of " Journal + print prefix(2) "

" + print HTML_TOC +} + + +function html_toc_entry() +{ + HTML_TOC = HTML_TOC " " + HTML_TOC = HTML_TOC vol_no_month_year() + HTML_TOC = HTML_TOC "
" "\n" +} + + +function html_trailer() +{ + html_end_pre() + print prefix(1) "" + print "" +} + + +function initialize() +{ + # NB: Update these when the program changes + VERSION_DATE = "[09-Oct-1996]" + VERSION_NUMBER = "1.00" + + HTML = (HTML == "") ? 0 : (0 + HTML) + + if (INDENT == "") + INDENT = 4 + + if (HTML == 0) + INDENT = 0 # indentation suppressed in ASCII mode + + LEADERS = " . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ." + + MAX_TITLE_CHARS = 36 # 36 produces a 79-char output line when there is + # just an initial page number. If this is + # increased, the LEADERS string may need to be + # lengthened. + + MIN_LEADERS = 4 # Minimum number of characters from LEADERS + # required when leaders are used. The total + # number of characters that can appear in a + # title line is MAX_TITLE_CHARS + MIN_LEADERS. + # Leaders are omitted when the title length is + # between MAX_TITLE_CHARS and this sum. + + MIN_LEADERS_SPACE = " " # must be at least MIN_LEADERS characters long + + Month_expansion["jan"] = "January" + Month_expansion["feb"] = "February" + Month_expansion["mar"] = "March" + Month_expansion["apr"] = "April" + Month_expansion["may"] = "May" + Month_expansion["jun"] = "June" + Month_expansion["jul"] = "July" + Month_expansion["aug"] = "August" + Month_expansion["sep"] = "September" + Month_expansion["oct"] = "October" + Month_expansion["nov"] = "November" + Month_expansion["dec"] = "December" + + Font_cmd_map["\\emph"] = "EM" + Font_cmd_map["\\textbf"] = "B" + Font_cmd_map["\\textit"] = "I" + Font_cmd_map["\\textmd"] = "" + Font_cmd_map["\\textrm"] = "" + Font_cmd_map["\\textsc"] = "toupper" + Font_cmd_map["\\textsl"] = "I" + Font_cmd_map["\\texttt"] = "t" + Font_cmd_map["\\textup"] = "" + + Font_decl_map["\\bf"] = "B" + Font_decl_map["\\em"] = "EM" + Font_decl_map["\\it"] = "I" + Font_decl_map["\\rm"] = "" + Font_decl_map["\\sc"] = "toupper" + Font_decl_map["\\sf"] = "" + Font_decl_map["\\tt"] = "TT" + Font_decl_map["\\itshape"] = "I" + Font_decl_map["\\upshape"] = "" + Font_decl_map["\\slshape"] = "I" + Font_decl_map["\\scshape"] = "toupper" + Font_decl_map["\\mdseries"] = "" + Font_decl_map["\\bfseries"] = "B" + Font_decl_map["\\rmfamily"] = "" + Font_decl_map["\\sffamily"] = "" + Font_decl_map["\\ttfamily"] = "TT" +} + +function min(a,b) +{ + return (a < b) ? a : b +} + + +function prefix(level) +{ + # Return a prefix of up to 60 blanks + + if (In_PRE) + return ("") + else + return (substr(" ", \ + 1, INDENT * level)) +} + + +function print_line(line) +{ + if (HTML) # must buffer in memory so that we can accumulate TOC + Body[++BodyLines] = line + else + print line +} + + +function print_toc_line(author,title,pages, extra,leaders,n,t) +{ + # When we have a multiline title, the hypertext link goes only + # on the first line. A multiline hypertext link looks awful + # because of long underlines under the leading indentation. + + if (pages == "") # then no leaders needed in title lines other than last one + t = sprintf("%31s %s%s%s", author, Title_prefix, title, Title_suffix) + else # last title line, with page number + { + n = html_length(title) # potentially expensive + extra = n % 2 # extra space for aligned leader dots + if (n <= MAX_TITLE_CHARS) # then need leaders + leaders = substr(LEADERS, 1, MAX_TITLE_CHARS + MIN_LEADERS - extra - \ + min(MAX_TITLE_CHARS,n)) + else # title (almost) fills line, so no leaders + leaders = substr(MIN_LEADERS_SPACE,1, \ + (MAX_TITLE_CHARS + MIN_LEADERS - extra - n)) + t = sprintf("%31s %s%s%s%s%s %4s", \ + author, Title_prefix, title, Title_suffix, \ + (extra ? " " : ""), leaders, pages) + } + + Title_prefix = "" # forget any hypertext + Title_suffix = "" # link material + + # Efficency note: an earlier version accumulated the body in a + # single scalar like this: "Body = Body t". Profiling revealed + # this statement as the major hot spot, and the change to array + # storage made the program more than twice as fast. This + # suggests that awk might benefit from an optimization of + # "s = s t" that uses realloc() instead of malloc(). + if (HTML) + Body[++BodyLines] = t + else + print t +} + + +function protect_SGML_characters(s) +{ + gsub(/&/,"\\&",s) # NB: this one MUST be first + gsub(//,"\\>",s) + gsub(/\"/,"\\"",s) + return (s) +} + + +function strip_braces(s, k) +{ # strip non-backslashed braces from s and return the result + + return (strip_char(strip_char(s,"{"),"}")) +} + + +function strip_char(s,c, k) +{ # strip non-backslashed instances of c from s, and return the result + k = index(s,c) + if (k > 0) # then found the character + { + if (substr(s,k-1,1) != "\\") # then not backslashed char + s = substr(s,1,k-1) strip_char(substr(s,k+1),c) # so remove it (recursively) + else # preserve backslashed char + s = substr(s,1,k) strip_char(s,k+1,c) + } + return (s) +} + + +function strip_html(s) +{ + gsub(/<\/?[^>]*>/,"",s) + return (s) +} + + +function terminate() +{ + if (HTML) + { + html_end_pre() + + HTML = 0 # NB: stop line buffering + html_header() + html_toc() + html_body() + html_trailer() + } +} + + +function TeX_to_HTML(s, k,n,parts) +{ + # First convert the four SGML reserved characters to SGML entities + if (HTML) + { + gsub(/>/, "\\>", s) + gsub(/ 1) ? "$" : "") \ + ((k % 2) ? strip_braces(TeX_to_HTML_nonmath(parts[k])) : \ + TeX_to_HTML_math(parts[k])) + + gsub(/[$][$][$]/,"$$",s) # restore display math + + return (s) +} + + +function TeX_to_HTML_math(s) +{ + # Mostly a dummy for now, but HTML 3 could support some math translation + + gsub(/\\&/,"\\&",s) # reduce TeX ampersands to SGML entities + + return (s) +} + + +function TeX_to_HTML_nonmath(s) +{ + if (index(s,"\\") > 0) # important optimization + { + gsub(/\\slash +/,"/",s) # replace TeX slashes with conventional ones + gsub(/ *\\emdash +/," --- ",s) # replace BibNet emdashes with conventional ones + gsub(/\\%/,"%",s) # reduce TeX percents to conventional ones + gsub(/\\[$]/,"$",s) # reduce TeX dollars to conventional ones + gsub(/\\#/,"#",s) # reduce TeX sharps to conventional ones + + if (HTML) # translate TeX markup to HTML + { + gsub(/\\&/,"\\&",s) # reduce TeX ampersands to SGML entities + s = html_accents(s) + s = html_fonts(s) + } + else # plain ASCII text output: discard all TeX markup + { + gsub(/\\\&/, "\\&", s) # reduce TeX ampersands to conventional ones + + #gsub(/\\[a-z][a-z] +/,"",s) # remove TeX font changes + gsub(/\\[[:lower:]][[:lower:]] +/,"",s) # remove TeX font changes + #gsub(/\\[^A-Za-z]/,"",s) # remove remaining TeX control symbols + gsub(/\\[^[:alpha:]]/,"",s) # remove remaining TeX control symbols + } + } + return (s) +} + + +function trim(s) +{ + gsub(/^[ \t]+/,"",s) + gsub(/[ \t]+$/,"",s) + return (s) +} + + +function vol_no_month_year() +{ + return ("Volume " wrap(Volume) ", Number " wrap(Number) ", " wrap(Month) ", " wrap(Year)) +} + + +function wrap(value) +{ + return (HTML ? ("" value "") : value) +} diff --git a/test/funstack.in b/test/funstack.in new file mode 100644 index 0000000..7a29a25 --- /dev/null +++ b/test/funstack.in @@ -0,0 +1,206 @@ +%%% ==================================================================== +%%% BibTeX-file{ +%%% author = "Nelson H. F. Beebe", +%%% version = "2.09", +%%% date = "26 March 1997", +%%% time = "08:21:19 MST", +%%% filename = "cacm1970.bib", +%%% address = "Center for Scientific Computing +%%% Department of Mathematics +%%% University of Utah +%%% Salt Lake City, UT 84112 +%%% USA", +%%% telephone = "+1 801 581 5254", +%%% FAX = "+1 801 581 4148", +%%% checksum = "50673 40670 196033 1787829", +%%% email = "beebe at math.utah.edu (Internet)", +%%% codetable = "ISO/ASCII", +%%% keywords = "bibliography, CACM, Communications of the +%%% ACM", +%%% supported = "yes", +%%% docstring = "This is a bibliography of the journal +%%% Communications of the ACM, covering +%%% (incompletely) 1970 -- 1979. +%%% +%%% At version 2.09, the year coverage looked +%%% like this: +%%% +%%% 1961 ( 1) 1972 (168) 1983 ( 0) +%%% 1962 ( 1) 1973 (158) 1984 ( 0) +%%% 1963 ( 2) 1974 (127) 1985 ( 2) +%%% 1964 ( 2) 1975 (107) 1986 ( 0) +%%% 1965 ( 1) 1976 ( 97) 1987 ( 0) +%%% 1966 ( 2) 1977 (117) 1988 ( 0) +%%% 1967 ( 1) 1978 (118) 1989 ( 0) +%%% 1968 ( 1) 1979 ( 78) 1990 ( 2) +%%% 1969 ( 3) 1980 ( 1) 1991 ( 4) +%%% 1970 (157) 1981 ( 2) 1992 ( 1) +%%% 1971 (104) 1982 ( 1) +%%% +%%% Article: 1252 +%%% Book: 2 +%%% InProceedings: 1 +%%% Manual: 1 +%%% MastersThesis: 1 +%%% PhdThesis: 1 +%%% +%%% Total entries: 1258 +%%% +%%% The size of the original cacm.bib file +%%% covering 1958--1996 became too large (about +%%% 4000 entries) for BibTeX and TeX to handle, +%%% so at version 1.44, it was split into +%%% cacm1950.bib, cacm1960.bib, cacm1970.bib, +%%% cacm1980.bib, and cacm1990.bib, each covering +%%% the decade starting with the year embedded in +%%% the filename. Version numbers for these +%%% files begin at 2.00. +%%% +%%% Volumes from the 1990s average more than 200 +%%% articles yearly, so a complete bibliography +%%% for this journal could contain more than 6000 +%%% entries from 1958 to 2000. +%%% +%%% These bibliographies also include ACM +%%% Algorithms 1--492. For Algorithms 493--686, +%%% including Algorithm 568, published in ACM +%%% Transactions on Programming Languages and +%%% Systems (TOPLAS), see the companion +%%% bibliographies, toms.bib and toplas.bib. +%%% +%%% All published Remarks and Corrigenda are +%%% cross-referenced in both directions, so +%%% that citing a paper will automatically +%%% generate citations for those Remarks and +%%% Corrigenda. Cross-referenced entries are +%%% duplicated in cacm19*.bib and toms.bib, so +%%% that each is completely self-contained. +%%% +%%% Source code for ACM Algorithms from 380 +%%% onwards, with some omissions, is available +%%% via the Netlib service at +%%% http://netlib.ornl.gov/, and +%%% ftp://netlib.bell-labs.com/netlib/toms. +%%% +%%% There is a World Wide Web search facility +%%% for articles published in this journal from +%%% 1959 to 1979 at +%%% http://ciir.cs.umass.edu/cgi-bin/web_query_form/public/cacm2.1. +%%% +%%% The initial draft of entries for 1981 -- +%%% 1990 was extracted from the ACM Computing +%%% Archive CD ROM for the 1980s, with manual +%%% corrections and additions. Additions were +%%% then made from all of the bibliographies in +%%% the TeX User Group collection, from +%%% bibliographies in the author's personal +%%% files, from the Compendex database +%%% (1970--1979), from the IEEE INSPEC database +%%% (1970--1979), from tables of contents +%%% information at http://www.acm.org/pubs/cacm/, +%%% from Zentralblatt fur Mathematik Mathematics +%%% Abstracts at +%%% http://www.emis.de/cgi-bin/MATH/, from +%%% bibliographies at Internet host +%%% netlib.bell-labs.com, and from the computer +%%% science bibliography collection on +%%% ftp.ira.uka.de in /pub/bibliography to which +%%% many people of have contributed. The +%%% snapshot of this collection was taken on +%%% 5-May-1994, and it consists of 441 BibTeX +%%% files, 2,672,675 lines, 205,289 entries, and +%%% 6,375 String{} abbreviations, occupying +%%% 94.8MB of disk space. +%%% +%%% Numerous errors in the sources noted above +%%% have been corrected. Spelling has been +%%% verified with the UNIX spell and GNU ispell +%%% programs using the exception dictionary +%%% stored in the companion file with extension +%%% .sok. +%%% +%%% BibTeX citation tags are uniformly chosen +%%% as name:year:abbrev, where name is the +%%% family name of the first author or editor, +%%% year is a 4-digit number, and abbrev is a +%%% 3-letter condensation of important title +%%% words. Citation tags were automatically +%%% generated by software developed for the +%%% BibNet Project. +%%% +%%% In this bibliography, entries are sorted in +%%% publication order within each journal, +%%% using bibsort -byvolume. +%%% +%%% The checksum field above contains a CRC-16 +%%% checksum as the first value, followed by the +%%% equivalent of the standard UNIX wc (word +%%% count) utility output of lines, words, and +%%% characters. This is produced by Robert +%%% Solovay's checksum utility.", +%%% } +%%% ==================================================================== + +@Preamble{"\input bibnames.sty " # "\input path.sty " # "\def \TM {${}^{\sc TM}$} " # "\hyphenation{ al-pha-mer-ic Balz-er Blom-quist Bo-ta-fo-go Bran-din Brans-comb Bu-tera Chris-tina Christ-o-fi-des Col-lins Cor-dell data-base econ-omies Fletch-er + flow-chart flow-charts Fry-styk ge-dank-en Gar-fink-el Ge-ha-ni Glush-ko Goud-reau Gua-dan-go Hari-di Haw-thorn Hem-men-ding-er Hor-o-witz Hour-vitz Hirsch-berg Ike-da Ka-chi-tvi-chyan-u-kul Kat-ze-nel-son Kitz-miller Ko-ba-yashi Le-Me-tay-er Ken-ne-dy + Law-rence Mac-kay Mai-net-ti Mar-sa-glia Max-well Mer-ner Mo-ran-di Na-ray-an New-ell Nich-ols para-digm pat-ent-ed Phi-lo-kyp-rou Prep-a-ra-ta pseu-do-chain-ing QUIK-SCRIPT Rad-e-mach-er re-eval-u-a-tion re-wind Ros-witha Scheu-er-mann Schwach-heim + Schob-bens Schon-berg Sho-sha-ni Si-tha-ra-ma Skwa-rec-ki Streck-er Strin-gi-ni Tes-ler Te-zu-ka Teu-ho-la Till-quist Town-send Tsi-chri-tzis Tur-ski Vuille-min Wald-ing-er Za-bo-row-ski Za-mora }"} + +%======================================================================= +% Acknowledgement abbreviations: + +@String{ack-nhfb = "Nelson H. F. Beebe, Center for Scientific Computing, Department of Mathematics, University of Utah, Salt Lake City, UT 84112, USA, Tel: +1 801 581 5254, FAX: +1 801 581 4148, e-mail: \path|beebe@math.utah.edu|"} + +@String{ack-nj = "Norbert Juffa, 2445 Mission College Blvd. Santa Clara, CA 95054 USA email: \path=norbert@iit.com="} + +%======================================================================= +% Journal abbreviations: + +@String{j-CACM = "Communications of the ACM"} + +@String{j-COMP-SURV = "Computing Surveys"} + +@String{j-J-ACM = "Journal of the ACM"} + +@String{j-MANAGEMENT-SCIENCE = "Management Science"} + +@String{j-SIAM-J-COMPUT = "SIAM Journal of Computing"} + +@String{j-SPE = "Software --- Practice and Experience"} + +@String{j-TOMS = "ACM Transactions on Mathematical Software"} + +%======================================================================= +% Publisher abbreviations: + +@String{pub-ANSI = "American National Standards Institute"} + +@String{pub-ANSI:adr = "1430 Broadway, New York, NY 10018, USA"} + +@String{pub-AW = "Ad{\-d}i{\-s}on-Wes{\-l}ey"} + +@String{pub-AW:adr = "Reading, MA, USA"} + +@String{pub-SUCSLI = "Stanford University Center for the Study of Language and Information"} + +@String{pub-SUCSLI:adr = "Stanford, CA, USA"} + +@String{pub-SV = "Spring{\-}er-Ver{\-}lag"} + +@String{pub-SV:adr = "Berlin, Germany~/ Heidelberg, Germany~/ London, UK~/ etc."} +@MastersThesis{Dittmer:1976:IEP, + author = "Ingo Dittmer", + title = "{Implementation eines Einschrittcompilers f{\"u}r die Progammiersprache PASCAL auf der Rechenanlage IBM\slash 360 der Universit{\"a}t M{\"u}nster}. ({English} title: Implementation of a One-Step Compiler for the Programming Language + {PASCAL} on the {IBM}\slash 360 of the {University of Muenster})", + type = "Diplomearbeit", + school = "Universit{\"a}t M{\"u}nster", + address = "M{\"u}nster, Germany", + pages = "??", + month = "??", + year = "1976", + bibdate = "Sat Feb 17 13:24:29 1996", + note = "Diplomearbeit M{\"u}nster 1976 und doert angegebene Literatur (English: Muenster diploma work 1976 and the literature cited therein). The hashing method was rediscovered fourteen years later by Pearson \cite{Pearson:1990:FHV}, and then + commented on by several authors \cite{Dittmer:1991:NFH,Savoy:1991:NFH,Litsios:1991:NFH,Pearson:1991:NFH}.", + acknowledgement = ack-nhfb, + xxnote = "Cannot find in Dissertation Abstracts, European.", +} diff --git a/test/funstack.ok b/test/funstack.ok new file mode 100644 index 0000000..e69de29 diff --git a/test/fwtest.awk b/test/fwtest.awk new file mode 100644 index 0000000..730aeda --- /dev/null +++ b/test/fwtest.awk @@ -0,0 +1,2 @@ +BEGIN { FIELDWIDTHS = "1 1 1" } +{ print NF, $1, $2, $3 } diff --git a/test/fwtest.in b/test/fwtest.in new file mode 100644 index 0000000..8baef1b --- /dev/null +++ b/test/fwtest.in @@ -0,0 +1 @@ +abc diff --git a/test/fwtest.ok b/test/fwtest.ok new file mode 100644 index 0000000..f2e4bc6 --- /dev/null +++ b/test/fwtest.ok @@ -0,0 +1 @@ +3 a b c diff --git a/test/fwtest2.awk b/test/fwtest2.awk new file mode 100644 index 0000000..f9df583 --- /dev/null +++ b/test/fwtest2.awk @@ -0,0 +1,59 @@ +# Date: Fri, 24 Mar 2006 15:17:24 +0100 +# From: =?UTF-8?Q?Ram=C3=B3n_Garc=C3=ADa?= +# Subject: Re: Bug when parsing FIELDWIDTHS +# In-reply-to: <200603241144.k2OBiFOX030158@skeeve.com> +# To: Aharon Robbins +# Message-id: +# MIME-version: 1.0 +# Content-type: multipart/mixed; boundary="----=_Part_9022_17179442.1143209844259" +# DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; +# h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; +# b=QVst9uUwAllKuDwXhuHbNjpRJStt3nEGc7p+BMG+HNk/qyHmnG/TYXSvIVKgZFja1thLhYbPYncw2MyEHtKyZuiTJCYqvpjWeST9qQNfxVMeu8FahqAky7n8ldsjOK6ncbCoE3hZe/g/Z9ZsVFC9LORXvM5uo7y1MGkUhgxO4qU= +# +# ------=_Part_9022_17179442.1143209844259 +# Content-Type: text/plain; charset=UTF-8 +# Content-Transfer-Encoding: base64 +# Content-Disposition: inline +# +# DQpTdXJlLiBIZXJlIGl0IGlzLg0KDQojIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMj +# IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjDQpUaGlz +# IE1haWwgV2FzIFNjYW5uZWQgYnkgMDEyLm5ldCBBbnRpVmlydXMgU2VydmljZTItIFBvd2VyZWQg +# YnkgVHJlbmRNaWNybyBJbnRlcnNjYW4NCg== +# ------=_Part_9022_17179442.1143209844259 +# Content-Type: application/octet-stream; name=bug_data +# Content-Transfer-Encoding: 7bit +# X-Attachment-Id: f_el6ll617 +# Content-Disposition: attachment; filename="bug_data" +# +# 0.4867373206 1.3206333033 -0.2333178127 +# 0.5668176165 1.3711756314 -0.2193558040 +# 0.4325251781 1.3399488722 -0.1568307497 +# 0.4900487563 1.3295759570 -0.2217392402 +# -0.6790064191 1.2536623801 -0.2955415433 +# -0.6311440220 1.2966579993 -0.2246692210 +# -0.7209390351 1.1783407099 -0.2539408209 +# -0.6782473356 1.2495242556 -0.2811436366 +# -0.7062054082 1.1223820964 -1.1619805834 +# -0.6491590119 1.1248946162 -1.0851579675 +# -0.7948856821 1.1208852325 -1.1259821556 +# -0.7102549262 1.1225121126 -1.1475381286 +# +# ------=_Part_9022_17179442.1143209844259 +# Content-Type: application/octet-stream; name=bug.awk +# Content-Transfer-Encoding: 7bit +# X-Attachment-Id: f_el6llnjj +# Content-Disposition: attachment; filename="bug.awk" +# +#!/usr/bin/awk -f +BEGIN { + FIELDWIDTHS = "15 15 15"; +} +{ + x = $1; + y = $2; + z = $3; + print "x y z", x, y, z +} +# +# ------=_Part_9022_17179442.1143209844259-- +# diff --git a/test/fwtest2.in b/test/fwtest2.in new file mode 100644 index 0000000..93f4f00 --- /dev/null +++ b/test/fwtest2.in @@ -0,0 +1,12 @@ + 0.4867373206 1.3206333033 -0.2333178127 + 0.5668176165 1.3711756314 -0.2193558040 + 0.4325251781 1.3399488722 -0.1568307497 + 0.4900487563 1.3295759570 -0.2217392402 + -0.6790064191 1.2536623801 -0.2955415433 + -0.6311440220 1.2966579993 -0.2246692210 + -0.7209390351 1.1783407099 -0.2539408209 + -0.6782473356 1.2495242556 -0.2811436366 + -0.7062054082 1.1223820964 -1.1619805834 + -0.6491590119 1.1248946162 -1.0851579675 + -0.7948856821 1.1208852325 -1.1259821556 + -0.7102549262 1.1225121126 -1.1475381286 diff --git a/test/fwtest2.ok b/test/fwtest2.ok new file mode 100644 index 0000000..a53d2df --- /dev/null +++ b/test/fwtest2.ok @@ -0,0 +1,12 @@ +x y z 0.4867373206 1.3206333033 -0.2333178127 +x y z 0.5668176165 1.3711756314 -0.2193558040 +x y z 0.4325251781 1.3399488722 -0.1568307497 +x y z 0.4900487563 1.3295759570 -0.2217392402 +x y z -0.6790064191 1.2536623801 -0.2955415433 +x y z -0.6311440220 1.2966579993 -0.2246692210 +x y z -0.7209390351 1.1783407099 -0.2539408209 +x y z -0.6782473356 1.2495242556 -0.2811436366 +x y z -0.7062054082 1.1223820964 -1.1619805834 +x y z -0.6491590119 1.1248946162 -1.0851579675 +x y z -0.7948856821 1.1208852325 -1.1259821556 +x y z -0.7102549262 1.1225121126 -1.1475381286 diff --git a/test/fwtest3.awk b/test/fwtest3.awk new file mode 100644 index 0000000..d1384ea --- /dev/null +++ b/test/fwtest3.awk @@ -0,0 +1 @@ +BEGIN { FIELDWIDTHS="5" } { print $1 } diff --git a/test/fwtest3.in b/test/fwtest3.in new file mode 100644 index 0000000..a32a434 --- /dev/null +++ b/test/fwtest3.in @@ -0,0 +1 @@ +1234567890 diff --git a/test/fwtest3.ok b/test/fwtest3.ok new file mode 100644 index 0000000..e56e15b --- /dev/null +++ b/test/fwtest3.ok @@ -0,0 +1 @@ +12345 diff --git a/test/gensub.awk b/test/gensub.awk new file mode 100644 index 0000000..f91d84d --- /dev/null +++ b/test/gensub.awk @@ -0,0 +1,7 @@ +BEGIN { a = "this is a test of gawk" + b = gensub(/(this).*(test).*(gawk)/, "3 = <\\3>, 2 = <\\2>, 1 = <\\1>", 1, a) + print b +} +NR == 1 { print gensub(/b/, "BB", 2) } +NR == 2 { print gensub(/c/, "CC", "global") } +END { print gensub(/foo/, "bar", 1, "DON'T PANIC") } diff --git a/test/gensub.in b/test/gensub.in new file mode 100644 index 0000000..96c9faf --- /dev/null +++ b/test/gensub.in @@ -0,0 +1,2 @@ +a b c a b c a b c +a b c a b c a b c diff --git a/test/gensub.ok b/test/gensub.ok new file mode 100644 index 0000000..b9ea3de --- /dev/null +++ b/test/gensub.ok @@ -0,0 +1,4 @@ +3 = , 2 = , 1 = +a b c a BB c a b c +a b CC a b CC a b CC +DON'T PANIC diff --git a/test/gensub2.awk b/test/gensub2.awk new file mode 100644 index 0000000..53554da --- /dev/null +++ b/test/gensub2.awk @@ -0,0 +1,5 @@ +BEGIN { + print gensub("x","y",2,"xx") + print gensub("x","y","2","xx") + print gensub("x","y","a","xx") +} diff --git a/test/gensub2.ok b/test/gensub2.ok new file mode 100644 index 0000000..8982414 --- /dev/null +++ b/test/gensub2.ok @@ -0,0 +1,3 @@ +xy +xy +yx diff --git a/test/getline.awk b/test/getline.awk new file mode 100644 index 0000000..4601ca1 --- /dev/null +++ b/test/getline.awk @@ -0,0 +1,33 @@ +BEGIN { + x = y = "s" + a = (getline x y) + print a, x + a = (getline x + 1) + print a, x + a = (getline x - 2) + print a, x + + cmd = "echo A" + a = (cmd | getline x y) + close(cmd) + print a, x + + cmd = "echo B" + a = (cmd | getline x + 1) + close(cmd) + print a, x + + cmd = "echo C" + a = (cmd | getline x - 2) + close(cmd) + print a, x + + cmd = "echo D" + a = cmd | getline x + close(cmd) + print a, x + + # Concatenation has higher precedence than IO. + "echo " "date" | getline + print +} diff --git a/test/getline.in b/test/getline.in new file mode 100644 index 0000000..b1e6722 --- /dev/null +++ b/test/getline.in @@ -0,0 +1,3 @@ +A +B +C diff --git a/test/getline.ok b/test/getline.ok new file mode 100644 index 0000000..a033cb6 --- /dev/null +++ b/test/getline.ok @@ -0,0 +1,8 @@ +1s A +2 B +-1 C +1s A +2 B +-1 C +1 D +date diff --git a/test/getline2.awk b/test/getline2.awk new file mode 100644 index 0000000..f4e413f --- /dev/null +++ b/test/getline2.awk @@ -0,0 +1 @@ +BEGIN { while( getline > 0) { print } } diff --git a/test/getline2.ok b/test/getline2.ok new file mode 100644 index 0000000..9b7f2b9 --- /dev/null +++ b/test/getline2.ok @@ -0,0 +1,2 @@ +BEGIN { while( getline > 0) { print } } +BEGIN { while( getline > 0) { print } } diff --git a/test/getline3.awk b/test/getline3.awk new file mode 100644 index 0000000..03e1239 --- /dev/null +++ b/test/getline3.awk @@ -0,0 +1,7 @@ +BEGIN { + cmd = "echo 3" + y = 7 + cmd | getline x y + close(cmd) + print (cmd | getline x y) +} diff --git a/test/getline3.ok b/test/getline3.ok new file mode 100644 index 0000000..98d9bcb --- /dev/null +++ b/test/getline3.ok @@ -0,0 +1 @@ +17 diff --git a/test/getline4.awk b/test/getline4.awk new file mode 100644 index 0000000..275faaa --- /dev/null +++ b/test/getline4.awk @@ -0,0 +1 @@ +END { getline $2; print} diff --git a/test/getline4.in b/test/getline4.in new file mode 100644 index 0000000..42771a3 --- /dev/null +++ b/test/getline4.in @@ -0,0 +1 @@ + aaa bbb diff --git a/test/getline4.ok b/test/getline4.ok new file mode 100644 index 0000000..42771a3 --- /dev/null +++ b/test/getline4.ok @@ -0,0 +1 @@ + aaa bbb diff --git a/test/getlnbuf.awk b/test/getlnbuf.awk new file mode 100644 index 0000000..8a4483e --- /dev/null +++ b/test/getlnbuf.awk @@ -0,0 +1,18 @@ +#Date: Tue, 21 Dec 1999 16:11:07 +0100 +#From: Daniel Schnell +#To: bug-gnu-utils@gnu.org +#CC: arnold@gnu.org +#Subject: BUG in gawk (version 3.0.4 linux, windows): Text mangeling in between + +# search for "@K@CODE" segment + +$0 ~ /@K@CODE/ { + # get next record + getline temp + printf ("@K@CODE\n") + printf ("%s\n",temp) + } + +$0 !~ /@K@CODE/ { + printf ("%s\n", $0) + } diff --git a/test/getlnbuf.in b/test/getlnbuf.in new file mode 100644 index 0000000..062b377 --- /dev/null +++ b/test/getlnbuf.in @@ -0,0 +1,1708 @@ +EXTRA_INFO.TYP3.EC := EC; +EXTRA_INFO.TYP3.TEXT:= 'CONNECT_SERVICE TO OAM FAILED'; + +G9PXYA1S!G9TE500_EHP_P( +'G9IBSA1C003', /*@@ID*/ +G9PXYA1S!G9TE102_ERR_CLASS_SWERR, /*@@CLASS*/ +ADDR(EXTRA_INFO.ERROR_HANDLER), /* EXTRA-INFO ADDR */ +G9PXYA1S!G9TE100_GB_LM, /* USER-ID */ +NULL /* OPTIONAL-SWET-INFO ADDR */ +); +/***@@@ END OF ERROR ***/ + +@K@FREEZE +917596041 +@K@NAME +T_ERR4_1 +@K@INSCRIPT +ERROR_HANDLING: +DB_OVERFLOW +MP/NSEI +@K@CODE +/***@@@ ERROR ***/ +/*@@ERRORTEXT +*@ DB-OVERFLOW +*@ +*@ +*@@DESCRIPTION +*@ THE INSTANCE-CREATION WAS NOT POSSIBLE +*@ BECAUSE THE DATABASE WOULD OVERFLOW +*@ +*@@EXTRA INFO +*@ (EXTRA_INFO_4_STRUCT) +*@ NSEI +*@ NSVCI +*@ TEXT +*@ +*/ + +EXTRA_INFO.TYP4.NSEI := EVD_PTR->.KEYS.INT_ARR(0); +EXTRA_INFO.TYP4.NSVCI:= EVD_PTR->.KEYS.INT_ARR(1); +EXTRA_INFO.TYP4.TEXT := 'NSVC-HAND.: MP/NSEI-OVERFLOW'; + +G9PXYA1S!G9TE500_EHP_P( +'G9IBSA1C004', /*@@ID*/ +G9PXYA1S!G9TE102_ERR_CLASS_ESC_MAX_ANY, /*@@CLASS*/ +ADDR(EXTRA_INFO.ERROR_HANDLER), /* EXTRA-INFO ADDR */ +G9PXYA1S!G9TE100_GB_LM, /* USER-ID */ +NULL /* OPTIONAL-SWET-INFO ADDR */ +); +/***@@@ END OF ERROR ***/ + +@K@FREEZE +920903219 +@K@NAME +T_ERR4_2 +@K@INSCRIPT +ERROR_HANDLING: +DB_OVERFLOW +MP/NSVCI +@K@CODE +/***@@@ ERROR ***/ +/*@@ERRORTEXT +*@ DB-OVERFLOW +*@ +*@ +*@@DESCRIPTION +*@ THE INSTANCE-CREATION WAS NOT POSSIBLE +*@ BECAUSE THE DATABASE WOULD OVERFLOW +*@ +*@@EXTRA INFO +*@ (EXTRA_INFO_4_STRUCT) +*@ NSEI +*@ NSVCI +*@ TEXT +*@ +*/ + +EXTRA_INFO.TYP4.NSEI := EVD_PTR->.KEYS.INT_ARR(0); +EXTRA_INFO.TYP4.NSVCI:= EVD_PTR->.KEYS.INT_ARR(1); +EXTRA_INFO.TYP4.TEXT := 'NSVC-HAND.: MP/NSVCI-OVERFLOW'; + +G9PXYA1S!G9TE500_EHP_P( +'G9IBSA1C004', /*@@ID*/ +G9PXYA1S!G9TE102_ERR_CLASS_ESC_MAX_ANY, /*@@CLASS*/ +ADDR(EXTRA_INFO.ERROR_HANDLER), /* EXTRA-INFO ADDR */ +G9PXYA1S!G9TE100_GB_LM, /* USER-ID */ +NULL /* OPTIONAL-SWET-INFO ADDR */ +); +/***@@@ END OF ERROR ***/ + +@K@FREEZE +920903222 +@K@NAME +T_ERR4_3 +@K@INSCRIPT +ERROR_HANDLING: +DB_OVERFLOW +NSEI/NSVCI +@K@CODE +/***@@@ ERROR ***/ +/*@@ERRORTEXT +*@ DB-OVERFLOW +*@ +*@ +*@@DESCRIPTION +*@ THE INSTANCE-CREATION WAS NOT POSSIBLE +*@ BECAUSE THE DATABASE WOULD OVERFLOW +*@ +*@@EXTRA INFO +*@ (EXTRA_INFO_4_STRUCT) +*@ NSEI +*@ NSVCI +*@ TEXT +*@ +*/ + +EXTRA_INFO.TYP4.NSEI := EVD_PTR->.KEYS.INT_ARR(0); +EXTRA_INFO.TYP4.NSVCI:= EVD_PTR->.KEYS.INT_ARR(1); +EXTRA_INFO.TYP4.TEXT := 'NSVC-HAND.: NSEI/NSVC-OVERFLOW'; + +G9PXYA1S!G9TE500_EHP_P( +'G9IBSA1C004', /*@@ID*/ +G9PXYA1S!G9TE102_ERR_CLASS_ESC_MAX_ANY, /*@@CLASS*/ +ADDR(EXTRA_INFO.ERROR_HANDLER), /* EXTRA-INFO ADDR */ +G9PXYA1S!G9TE100_GB_LM, /* USER-ID */ +NULL /* OPTIONAL-SWET-INFO ADDR */ +); +/***@@@ END OF ERROR ***/ + +@K@FREEZE +920903226 +@K@NAME +TR_RESET +@K@INSCRIPT +RESTART_ +TNS_RESET_ +TIMER +@K@CODE +/* TIMER EVENT DESCRIPTOR STILL THERE */ + +/* INITIALIZATION OF THE TIMER-EVENT-DESCRIPTOR STILL VALID */ +NSVCI_CON_PTR->.TIM_EVD_PTR->.TIMER:= TNS_RESET_MAP; + +/* START TIMER */ +G9PX508_START_TIMER_P +( +NSVCI_CON_PTR->.TIM_EVD_PTR +); + +@K@FREEZE +924684867 +@K@NAME +TX_AUDIT +@K@INSCRIPT +FOR +AUDIT + +@K@NAME +M_BLKOACKM +@K@INSCRIPT +NS_ +BLOCK_ACK +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9IBDF4_NS_LM_M) + G9IBD44_NS_PDU_DATA_OFFSET_C), +TX_EVD_PTR +); + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9IBD40_NS_LM_PDU_C; +TX_EVD_PTR->.EVENT_DESTINATION:= GBDL_HANDLE; + +IF +/* 'OTHER' ALIVE NSVC TO THIS NSEI EXISTING? */ +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR /= NULL +THEN +/* USE THIS 'OTHER' FOR TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(0):= + +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSEI; +/* NSEI TO BE USED FOR TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(1):= + +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; +/* NSVCI TO BE USED FOR TRANSPORT */ +ELSE +/* USE AFFECTED NSVC AGAIN FOR TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(0):= + NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSEI; /* NSEI TO BE USED FOR +TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(1):= + NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; /* NSVCI TO BE USED FOR +TRANSPORT */ +FI; + + +/* POINTER TO PDU IN POOL-ELEMENT */ +NS_PDU_PTR:= NS_PDU_REF_M (INT(TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT) + + G9IBD44_NS_PDU_DATA_OFFSET_C); +/* OFFSET OF THE PDU IN POOL-ELEMENT */ +TX_EVD_PTR->.BOUND.DATA_OFFSET:= G9IBD44_NS_PDU_DATA_OFFSET_C; +/* LENGTH OF THE PDU IN POOL-ELEMENT */ +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(NS_PDU_PTR->.G9IBDF4_PDU_TYPE) + +SIZE(NS_PDU_PTR->.D3); + +/* NOW THE POOL-ELEMENT */ +NS_PDU_PTR->.G9IBDF4_PDU_TYPE:= G9IBDR2_NS_BLOCK_ACK_C; /* PDU-TYPE */ + +NS_PDU_PTR->.D3.NSVCI_TLV.NSVCI_VAL := + NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; /* NSVC TO BE BLOCKED */ + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +938805885 +@K@NAME +T_RCTRUE +@K@INSCRIPT +RC += +TRUE +@K@CODE +RC:= TRUE; + +@K@FREEZE +922176328 +@K@NAME +M_AC_SBVCN +@K@INSCRIPT +G9IBME0_ +ACT_ +SIGN_BVC_C +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB512_GET_MSG_LESS_EV_DESCR_P +( +SID_GBNSVC, +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +TX_EVD_PTR->.EVENT_CMD:= G9IBME0_ACT_SIGN_BVC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= GBBVC_HANDLE; +TX_EVD_PTR->.KEYS.INT_ARR(0):= EVD_PTR->.KEYS.INT_ARR(0); +TX_EVD_PTR->.KEYS.INT_ARR(1):= SIGN_BVCI; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +938788211 +@K@NAME +T_RC_EOD +@K@INSCRIPT +RC += +END OF DATA + +@K@CODE +RC:= G9IBSM4_RC_END_OF_DATA; + +@K@FREEZE +921083785 +@K@NAME +T_RC_EMP +@K@INSCRIPT +RC += +EMPTY + +@K@CODE +RC:= G9IBSM4_RC_EMPTY; + +@K@FREEZE +921083757 +@K@NAME +T_RC_ERR +@K@INSCRIPT +RC += +ERROR + +@K@CODE +RC:= G9IBSM4_RC_ERROR; + +@K@FREEZE +921083731 +@K@NAME +S_UNUSED +@K@INSCRIPT +G9IBSM0_ +UNUSED +@K@CODE + + +@K@FREEZE +919416670 +@K@NAME +TA_UNBLOCK +@K@INSCRIPT +START_ +TNS_UNBLOCK_ +TIMER +@K@CODE +/* GET TIMER-EVENT DESCRIPTOR */ +G9PB513_GET_TIMER_EV_DESCR_P +( +SID_GBNSVC, +NSVCI_CON_PTR->.TIM_EVD_PTR +); + +/* INITIALIZATION OF THE TIMER-EVENT-DESCRIPTOR */ +NSVCI_CON_PTR->.TIM_EVD_PTR->.EVENT_CMD:= G9IBSE4_TO_TNS_C; +NSVCI_CON_PTR->.TIM_EVD_PTR->.EVENT_DESTINATION:= GBNSVC_HANDLE; +NSVCI_CON_PTR->.TIM_EVD_PTR->.KEYS.INT_ARR(0):= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSEI; +NSVCI_CON_PTR->.TIM_EVD_PTR->.KEYS.INT_ARR(1):= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; +NSVCI_CON_PTR->.TIM_EVD_PTR->.TIMER:= TNS_UNBLOCK_MAP; + +/* START TIMER */ +G9PX508_START_TIMER_P +( +NSVCI_CON_PTR->.TIM_EVD_PTR +); + +@K@FREEZE +924686210 +@K@NAME +M_BLK_ACKM +@K@INSCRIPT +NS_ +BLOCK_ACK +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9IBDF4_NS_LM_M) + G9IBD44_NS_PDU_DATA_OFFSET_C), +TX_EVD_PTR +); + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9IBD40_NS_LM_PDU_C; +TX_EVD_PTR->.EVENT_DESTINATION:= GBDL_HANDLE; +TX_EVD_PTR->.KEYS.INT_ARR(0):= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSEI; /* NSEI TO BE USED FOR +TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(1):= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; /* NSVCI TO BE USED FOR +TRANSPORT */ +/* POINTER TO PDU IN POOL-ELEMENT */ +NS_PDU_PTR:= NS_PDU_REF_M (INT(TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT) + + G9IBD44_NS_PDU_DATA_OFFSET_C); +/* OFFSET OF THE PDU IN POOL-ELEMENT */ +TX_EVD_PTR->.BOUND.DATA_OFFSET:= G9IBD44_NS_PDU_DATA_OFFSET_C; +/* LENGTH OF THE PDU IN POOL-ELEMENT */ +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(NS_PDU_PTR->.G9IBDF4_PDU_TYPE) + +SIZE(NS_PDU_PTR->.D3); + +/* NOW THE POOL-ELEMENT */ +NS_PDU_PTR->.G9IBDF4_PDU_TYPE:= G9IBDR2_NS_BLOCK_ACK_C; /* PDU-TYPE */ + +NS_PDU_PTR->.D3.NSVCI_TLV.NSVCI_VAL := + NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; /* NSVC TO BE BLOCKED */ + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +926348442 +@K@NAME +TA_NXTALIV +@K@INSCRIPT +DEFINE +NEW 'NEXT_ +ALIVE' +@K@CODE +IF +/* ALIVE NSVC TO THE NSEI EXISTING? */ +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR /= NULL + +THEN +/* TAKE NEXT ELEMENT IN THE LINKED LIST AS THE NEXT ALIVE NSVC */ +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR:= + +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR->.NEXT_ALV_NSVCI_CON_PTR; + +FI; + +@K@FREEZE +938801086 +@K@NAME +M_DE_CBVCN +@K@INSCRIPT +G9IBME2_ +DEACT_ +CELL_BVC_C + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB512_GET_MSG_LESS_EV_DESCR_P +( +SID_GBNSVC, +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +TX_EVD_PTR->.EVENT_CMD:= G9IBME2_DEACT_CELL_BVC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= GBBVC_HANDLE; +TX_EVD_PTR->.KEYS.INT_ARR(0):= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSEI; +TX_EVD_PTR->.KEYS.INT_ARR(1):= EVD_PTR->.ADD_DATA(3); + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +933318270 +@K@NAME +TA_NXTRESP +@K@INSCRIPT +DEFINE +NEW 'NEXT_ +RESPONSIBLE' +@K@CODE +NSEI_CON_PTR->.NEXT_RESP_NSVCI_CON_PTR:= + NSEI_CON_PTR->.NEXT_RESP_NSVCI_CON_PTR->.NEXT_LSP_NSVCI_CON_PTR; + + +@K@FREEZE +938005006 +@K@NAME +TA_NXTSUBS +@K@INSCRIPT +DEFINE +NEW 'NEXT_ +SUBSTITUTE' +@K@CODE +NSEI_CON_PTR->.NEXT_SUBS_NSVCI_CON_PTR:= + NSEI_CON_PTR->.NEXT_SUBS_NSVCI_CON_PTR->.NEXT_UBL_NSVCI_CON_PTR; + +@K@NAME +M_BLK_O__M +@K@INSCRIPT +NS_ +BLOCK +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9IBDF4_NS_LM_M) + G9IBD44_NS_PDU_DATA_OFFSET_C), +TX_EVD_PTR +); + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9IBD40_NS_LM_PDU_C; +TX_EVD_PTR->.EVENT_DESTINATION:= GBDL_HANDLE; + +IF +/* 'OTHER' ALIVE NSVC TO THIS NSEI EXISTING? */ +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR /= NULL +THEN +/* USE THIS 'OTHER' FOR TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(0):= + +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSEI; +/* NSEI TO BE USED FOR TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(1):= + +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; +/* NSVCI TO BE USED FOR TRANSPORT */ +ELSE +/* USE AFFECTED NSVC AGAIN FOR TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(0):= + NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSEI; /* NSEI TO BE USED FOR +TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(1):= + NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; /* NSVCI TO BE USED FOR +TRANSPORT */ +FI; + + +/* POINTER TO PDU IN POOL-ELEMENT */ +NS_PDU_PTR:= NS_PDU_REF_M (INT(TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT) + + G9IBD44_NS_PDU_DATA_OFFSET_C); +/* OFFSET OF THE PDU IN POOL-ELEMENT */ +TX_EVD_PTR->.BOUND.DATA_OFFSET:= G9IBD44_NS_PDU_DATA_OFFSET_C; +/* LENGTH OF THE PDU IN POOL-ELEMENT */ +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(NS_PDU_PTR->.G9IBDF4_PDU_TYPE) + +SIZE(NS_PDU_PTR->.D2); + + +/* NOW THE POOL-ELEMENT */ +NS_PDU_PTR->.G9IBDF4_PDU_TYPE:= G9IBDR1_NS_BLOCK_C; /* PDU-TYPE */ + +NS_PDU_PTR->.D2.CAUSE_TLV.CAUSE_VAL:= + G9IBBA2_NS_TRANSIT_NETWORK_FAILURE; /* CAUSE FOR BLOCK */ +NS_PDU_PTR->.D2.NSVCI_TLV.NSVCI_VAL := + NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; /* NSVC TO BE BLOCKED */ + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@TEXT +GSM 8.16 CHAP. 7.2: +THE NS-BLOCK-PDU MAY BE SENT IN ANY ALIVE +(BLOCKED OR UNBLOCKED) NS-VC... +@K@FREEZE +938803215 +@K@NAME +M_DE_SBVCN +@K@INSCRIPT +G9IBME1_ +DEACT_ +SIGN_BVC_C +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB512_GET_MSG_LESS_EV_DESCR_P +( +SID_GBNSVC, +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +TX_EVD_PTR->.EVENT_CMD:= G9IBME1_DEACT_SIGN_BVC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= GBBVC_HANDLE; +TX_EVD_PTR->.KEYS.INT_ARR(0):= EVD_PTR->.KEYS.INT_ARR(0); +TX_EVD_PTR->.KEYS.INT_ARR(1):= SIGN_BVCI; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +938788201 +@K@NAME +M_OAME401M +@K@INSCRIPT +ERROR_MESSAGE: +ERRONOUS_PDU +RESET_PDU + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSE */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSE; +OAM_MSG_PTR->.HANDLED_OBJECT.NSE_ID:= EVD_PTR->.KEYS.INT_ARR(0); /* +USED NSEI (FROM ECI) */ + +/* ERROR-CAUSE = ERRONEOUS_PDU */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ERRONEOUS_PDU; +/* ADDITIONAL_PDU_INFO */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_PDU_TYPE:= + G9OC124_RESET_PDU; +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSEI:= + EVD_PTR->.ADD_DATA(0); /* AFFECTED NSEI (FROM PDU) */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSVC:= + EVD_PTR->.ADD_DATA(1); /* AFFECTED NSVCI (FROM PDU) */ + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +935766108 +@K@NAME +M_OAME402M +@K@INSCRIPT +ERROR_MESSAGE: +ERRONOUS_PDU +RESET_PDU + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= EVD_PTR->.KEYS.INT_ARR(1); /* +USED NSVCI (FROM ECI) */ + +/* ERROR-CAUSE = ERRONEOUS_PDU */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ERRONEOUS_PDU; +/* ADDITIONAL_PDU_INFO */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_PDU_TYPE:= + G9OC124_RESET_PDU; +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSEI:= + EVD_PTR->.ADD_DATA(0); /* NSEI FROM PDU */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSVC:= + EVD_PTR->.ADD_DATA(1); /* NSVCI FROM PDU */ + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +935766407 +@K@NAME +M_OAME411M +@K@INSCRIPT +ERROR_MESSAGE: +ERRONOUS_PDU +RESET_ACK_PDU + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSE */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSE; +OAM_MSG_PTR->.HANDLED_OBJECT.NSE_ID:= EVD_PTR->.KEYS.INT_ARR(0); /* +USED NSEI (FROM ECI) */ + +/* ERROR-CAUSE = ERRONEOUS_PDU */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ERRONEOUS_PDU; +/* ADDITIONAL_PDU_INFO */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_PDU_TYPE:= + G9OC124_RESET_ACK_PDU; +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSEI:= + EVD_PTR->.ADD_DATA(0); /* NSEI FROM PDU */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSVC:= + EVD_PTR->.ADD_DATA(1); /* NSVCI FROM PDU */ + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +935767332 +@K@NAME +M_OAME412M +@K@INSCRIPT +ERROR_MESSAGE: +ERRONOUS_PDU +RESET_ACK_PDU + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= EVD_PTR->.KEYS.INT_ARR(1); /* +USED NSVCI (FROM ECI) */ + +/* ERROR-CAUSE = ERRONEOUS_PDU */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ERRONEOUS_PDU; +/* ADDITIONAL_PDU_INFO */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_PDU_TYPE:= + G9OC124_RESET_ACK_PDU; +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSEI:= + EVD_PTR->.ADD_DATA(0); /* NSEI FROM PDU */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSVC:= + EVD_PTR->.ADD_DATA(1); /* NSVCI FROM PDU */ + + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +935767189 +@K@NAME +C_CON +@K@INSCRIPT +RC_DB +@K@CODE +RC_DB + +@K@FREEZE +922176673 +@K@NAME +M_BLK____M +@K@INSCRIPT +NS_ +BLOCK +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9IBDF4_NS_LM_M) + G9IBD44_NS_PDU_DATA_OFFSET_C), +TX_EVD_PTR +); + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9IBD40_NS_LM_PDU_C; +TX_EVD_PTR->.EVENT_DESTINATION:= GBDL_HANDLE; +TX_EVD_PTR->.KEYS.INT_ARR(0):= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSEI; /* NSEI TO BE USED FOR +TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(1):= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; /* NSVCI TO BE USED FOR +TRANSPORT */ +/* POINTER TO PDU IN POOL-ELEMENT */ +NS_PDU_PTR:= NS_PDU_REF_M (INT(TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT) + + G9IBD44_NS_PDU_DATA_OFFSET_C); +/* OFFSET OF THE PDU IN POOL-ELEMENT */ +TX_EVD_PTR->.BOUND.DATA_OFFSET:= G9IBD44_NS_PDU_DATA_OFFSET_C; +/* LENGTH OF THE PDU IN POOL-ELEMENT */ +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(NS_PDU_PTR->.G9IBDF4_PDU_TYPE) + +SIZE(NS_PDU_PTR->.D2); + + +/* NOW THE POOL-ELEMENT */ +NS_PDU_PTR->.G9IBDF4_PDU_TYPE:= G9IBDR1_NS_BLOCK_C; /* PDU-TYPE */ + +NS_PDU_PTR->.D2.CAUSE_TLV.CAUSE_VAL:= + G9IBBA2_NS_OAM_INTERVENTION; /* CAUSE FOR BLOCK */ +NS_PDU_PTR->.D2.NSVCI_TLV.NSVCI_VAL := + NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; /* NSVC TO BE BLOCKED */ + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@TEXT +GSM 8.16 CHAP. 7.2: +THE NS-BLOCK-PDU MAY BE SENT IN ANY ALIVE +(BLOCKED OR UNBLOCKED) NS-VC... +@K@FREEZE +926348613 +@K@NAME +S_BLOCKED +@K@INSCRIPT +G9IBSM0_ +BLOCKED +@K@CODE + + +@K@FREEZE +922176496 +@K@NAME +D_CON +@K@INSCRIPT +CONTEXT +GOT +@K@CODE +RC_DB = G9IBSR0_RC_OK + +@K@FREEZE +921772339 +@K@NAME +M_OAME901M +@K@INSCRIPT +ERROR_MESSAGE: +OPERATIONAL_STATE_CHANGE +UBL->BLK +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = OPERATIONAL_STATE_CHANGE */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_OPERATIONAL_STATE_CHANGE; +/* ADDITIONAL_OPERATIONAL_STATE_INFO */ +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.OPER_STATE_OLD:= + G9OC101_UNBLOCKED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.ADMIN_STATE_OLD:= + G9OC102_ENABLED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.ADMIN_STATE_NEW:= + G9OC102_ENABLED; + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +925970975 +@K@NAME +M_OAME902M +@K@INSCRIPT +ERROR_MESSAGE: +OPERATIONAL_STATE_CHANGE +UBL->BLK + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = OPERATIONAL_STATE_CHANGE */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_OPERATIONAL_STATE_CHANGE; +/* ADDITIONAL_OPERATIONAL_STATE_INFO */ +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.OPER_STATE_OLD:= + G9OC101_UNBLOCKED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.ADMIN_STATE_OLD:= + G9OC102_ENABLED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.ADMIN_STATE_NEW:= + G9OC102_DISABLED; + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +925970987 +@K@NAME +M_OAME10SM +@K@INSCRIPT +ERROR_MESSAGE: +ALARM_BEGIN_NS_ALIVE_TEST +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = ALARM_BEGIN_NS_ALIVE_TEST*/ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ALARM_BEGIN_NS_ALIVE_TEST; +/* ADDITIONAL_ALARM_INFO */ +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.ADMINISTRATIVE_STATE_CHANGED:= + TRUE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_OLD:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_OLD:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_NEW:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.CONFIGURATION_OF_NSVC:= + TRUE; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@NAME +M_OAME911M +@K@INSCRIPT +ERROR_MESSAGE: +OPERATIONAL_STATE_CHANGE +BLK->UBL +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = OPERATIONAL_STATE_CHANGE */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_OPERATIONAL_STATE_CHANGE; +/* ADDITIONAL_OPERATIONAL_STATE_INFO */ +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.OPER_STATE_OLD:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.OPER_STATE_NEW:= + G9OC101_UNBLOCKED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.ADMIN_STATE_OLD:= + G9OC102_ENABLED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.ADMIN_STATE_NEW:= + G9OC102_ENABLED; + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +925970996 +@K@NAME +M_OAME20SM +@K@INSCRIPT +ERROR_MESSAGE: +ALARM_END_NS_ALIVE_TEST +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = ALARM_END_NS_ALIVE_TEST */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ALARM_END_NS_ALIVE_TEST; +/* ADDITIONAL_ALARM_INFO */ +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.ADMINISTRATIVE_STATE_CHANGED:= + TRUE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_OLD:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_OLD:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_NEW:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.CONFIGURATION_OF_NSVC:= + TRUE; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@NAME +M_OAME10_M +@K@INSCRIPT +ERROR_MESSAGE: +ALARM_BEGIN_NS_ALIVE_TEST +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = ALARM_BEGIN_NS_ALIVE_TEST*/ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ALARM_BEGIN_NS_ALIVE_TEST; +/* ADDITIONAL_ALARM_INFO */ +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.ADMINISTRATIVE_STATE_CHANGED:= + TRUE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_OLD:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_OLD:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_NEW:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.CONFIGURATION_OF_NSVC:= + TRUE; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +922443813 +@K@NAME +D_SEM +@K@INSCRIPT +CALL_SEM += +TRUE +@K@CODE +CALL_SEM = TRUE + +@K@FREEZE +922176624 +@K@NAME +D_N_0 +@K@INSCRIPT +N = 0 + +@K@CODE +NSVCI_CON_PTR->.N = 0 + +@K@FREEZE +921511000 +@K@NAME +M_OAME12_M +@K@INSCRIPT +ERROR_MESSAGE: +ALARM_BEGIN_NS_ALIVE_TEST +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = ALARM_BEGIN_NS_ALIVE_TEST*/ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ALARM_BEGIN_NS_ALIVE_TEST; +/* ADDITIONAL_ALARM_INFO */ +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.ADMINISTRATIVE_STATE_CHANGED:= + FALSE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_OLD:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_OLD:= + G9OC103_ALIVE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_NEW:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.CONFIGURATION_OF_NSVC:= + TRUE; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +922443829 +@K@NAME +M_OAME21_M +@K@INSCRIPT +ERROR_MESSAGE: +ALARM_END_NS_ALIVE_TEST +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = ALARM_END_NS_ALIVE_TEST */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ALARM_END_NS_ALIVE_TEST; +/* ADDITIONAL_ALARM_INFO */ +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.ADMINISTRATIVE_STATE_CHANGED:= + TRUE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_OLD:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_OLD:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_NEW:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.CONFIGURATION_OF_NSVC:= + FALSE; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +922443856 +@K@NAME +M_OAME13_M +@K@INSCRIPT +ERROR_MESSAGE: +ALARM_BEGIN_NS_ALIVE_TEST +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = ALARM_BEGIN_NS_ALIVE_TEST*/ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ALARM_BEGIN_NS_ALIVE_TEST; +/* ADDITIONAL_ALARM_INFO */ +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.ADMINISTRATIVE_STATE_CHANGED:= + FALSE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_OLD:= + G9OC101_UNBLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_OLD:= + G9OC103_ALIVE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_NEW:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.CONFIGURATION_OF_NSVC:= + TRUE; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +922443838 +@K@NAME +M_OAME22_M +@K@INSCRIPT +ERROR_MESSAGE: +ALARM_END_NS_ALIVE_TEST +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = ALARM_END_NS_ALIVE_TEST */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ALARM_END_NS_ALIVE_TEST; +/* ADDITIONAL_ALARM_INFO */ +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.ADMINISTRATIVE_STATE_CHANGED:= + FALSE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_OLD:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_OLD:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_NEW:= + G9OC103_ALIVE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.CONFIGURATION_OF_NSVC:= + TRUE; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +922443864 +@K@NAME +M_OAME30_M +@K@INSCRIPT +ERROR_MESSAGE: +NO_ANSWER_FORM_BSS +RESET_PROCEDURE + + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = NO_ANSWER_FROM_BSS */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_NO_ANSWER_FROM_BSS; +/* INITIATED_PROCEDURE */ +OAM_MSG_PTR->.INITIATED_PROCEDURE:= + G9OC123_RESET_PROCEDURE; + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +922175973 +@K@NAME +M_OAME31_M +@K@INSCRIPT +ERROR_MESSAGE: +NO_ANSWER_FROM_BSS +BLOCK_PROCEDURE + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = NO_ANSWER_FROM_BSS */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_NO_ANSWER_FROM_BSS; +/* INITIATED_PROCEDURE */ +OAM_MSG_PTR->.INITIATED_PROCEDURE:= + G9OC123_BLOCK_PROCEDURE; + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +922175976 +@K@NAME +M_OAME32_M +@K@INSCRIPT +ERROR_MESSAGE: +NO_ANSWER_FROM_BSS +UNBLOCK_PROCEDURE + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = NO_ANSWER_FROM_BSS */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_NO_ANSWER_FROM_BSS; +/* INITIATED_PROCEDURE */ +OAM_MSG_PTR->.INITIATED_PROCEDURE:= + G9OC123_UNBLOCK_PROCEDURE; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +922175980 +@K@NAME +M_OAME42_M +@K@INSCRIPT +ERROR_MESSAGE: +ERRONOUS_PDU +BLOCK_PDU +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= EVD_PTR->.ADD_DATA(1); /* +USED NSVCI (FROM ECI) */ + +/* ERROR-CAUSE = ERRONEOUS_PDU */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ERRONEOUS_PDU; +/* ADDITIONAL_PDU_INFO */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_PDU_TYPE:= + G9OC124_BLOCK_PDU; +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSEI:= + EVD_PTR->.KEYS.INT_ARR(0); /* AFFECTED NSEI (FROM PDU) */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSVC:= + EVD_PTR->.KEYS.INT_ARR(1); /* AFFECTED NSVCI (FROM PDU) */ + + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +934296141 +@K@NAME +M_OAME50_M +@K@INSCRIPT +ERROR_MESSAGE: +STATUS_PDU_CONTAINS_ERROR_INFO +RECEIVED +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR-CAUSE = STATUS_PDU_CONTAINS_ERROR_INFO */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_STATUS_PDU_CONTAINS_ERROR_INFO; +/* ADDITIONAL_STATUS_PDU_INFO */ +INT_CAUSE_PTR.INT_PTR:= ADDR(EVD_PTR->.ADD_DATA(2)); +OAM_MSG_PTR->.ADDITIONAL_STATUS_PDU_INFO:= + INT_CAUSE_PTR.CAUSE_PTR->; /* CAUSE */ + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@TEXT +NICHT OK + +@K@FREEZE +934298924 +@K@NAME +M_OAME43_M +@K@INSCRIPT +ERROR_MESSAGE: +ERRONOUS_PDU +BLOCK_ACK_PDU +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= EVD_PTR->.ADD_DATA(1); /* +USED NSVCI (FROM ECI) */ + +/* ERROR-CAUSE = ERRONEOUS_PDU */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ERRONEOUS_PDU; +/* ADDITIONAL_PDU_INFO */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_PDU_TYPE:= + G9OC124_BLOCK_ACK_PDU; +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSEI:= + EVD_PTR->.KEYS.INT_ARR(0); /* AFFECTED NSEI (FROM PDU) */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSVC:= + EVD_PTR->.KEYS.INT_ARR(1); /* AFFECTED NSVCI (FROM PDU) */ + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +934297710 diff --git a/test/getlnbuf.ok b/test/getlnbuf.ok new file mode 100644 index 0000000..062b377 --- /dev/null +++ b/test/getlnbuf.ok @@ -0,0 +1,1708 @@ +EXTRA_INFO.TYP3.EC := EC; +EXTRA_INFO.TYP3.TEXT:= 'CONNECT_SERVICE TO OAM FAILED'; + +G9PXYA1S!G9TE500_EHP_P( +'G9IBSA1C003', /*@@ID*/ +G9PXYA1S!G9TE102_ERR_CLASS_SWERR, /*@@CLASS*/ +ADDR(EXTRA_INFO.ERROR_HANDLER), /* EXTRA-INFO ADDR */ +G9PXYA1S!G9TE100_GB_LM, /* USER-ID */ +NULL /* OPTIONAL-SWET-INFO ADDR */ +); +/***@@@ END OF ERROR ***/ + +@K@FREEZE +917596041 +@K@NAME +T_ERR4_1 +@K@INSCRIPT +ERROR_HANDLING: +DB_OVERFLOW +MP/NSEI +@K@CODE +/***@@@ ERROR ***/ +/*@@ERRORTEXT +*@ DB-OVERFLOW +*@ +*@ +*@@DESCRIPTION +*@ THE INSTANCE-CREATION WAS NOT POSSIBLE +*@ BECAUSE THE DATABASE WOULD OVERFLOW +*@ +*@@EXTRA INFO +*@ (EXTRA_INFO_4_STRUCT) +*@ NSEI +*@ NSVCI +*@ TEXT +*@ +*/ + +EXTRA_INFO.TYP4.NSEI := EVD_PTR->.KEYS.INT_ARR(0); +EXTRA_INFO.TYP4.NSVCI:= EVD_PTR->.KEYS.INT_ARR(1); +EXTRA_INFO.TYP4.TEXT := 'NSVC-HAND.: MP/NSEI-OVERFLOW'; + +G9PXYA1S!G9TE500_EHP_P( +'G9IBSA1C004', /*@@ID*/ +G9PXYA1S!G9TE102_ERR_CLASS_ESC_MAX_ANY, /*@@CLASS*/ +ADDR(EXTRA_INFO.ERROR_HANDLER), /* EXTRA-INFO ADDR */ +G9PXYA1S!G9TE100_GB_LM, /* USER-ID */ +NULL /* OPTIONAL-SWET-INFO ADDR */ +); +/***@@@ END OF ERROR ***/ + +@K@FREEZE +920903219 +@K@NAME +T_ERR4_2 +@K@INSCRIPT +ERROR_HANDLING: +DB_OVERFLOW +MP/NSVCI +@K@CODE +/***@@@ ERROR ***/ +/*@@ERRORTEXT +*@ DB-OVERFLOW +*@ +*@ +*@@DESCRIPTION +*@ THE INSTANCE-CREATION WAS NOT POSSIBLE +*@ BECAUSE THE DATABASE WOULD OVERFLOW +*@ +*@@EXTRA INFO +*@ (EXTRA_INFO_4_STRUCT) +*@ NSEI +*@ NSVCI +*@ TEXT +*@ +*/ + +EXTRA_INFO.TYP4.NSEI := EVD_PTR->.KEYS.INT_ARR(0); +EXTRA_INFO.TYP4.NSVCI:= EVD_PTR->.KEYS.INT_ARR(1); +EXTRA_INFO.TYP4.TEXT := 'NSVC-HAND.: MP/NSVCI-OVERFLOW'; + +G9PXYA1S!G9TE500_EHP_P( +'G9IBSA1C004', /*@@ID*/ +G9PXYA1S!G9TE102_ERR_CLASS_ESC_MAX_ANY, /*@@CLASS*/ +ADDR(EXTRA_INFO.ERROR_HANDLER), /* EXTRA-INFO ADDR */ +G9PXYA1S!G9TE100_GB_LM, /* USER-ID */ +NULL /* OPTIONAL-SWET-INFO ADDR */ +); +/***@@@ END OF ERROR ***/ + +@K@FREEZE +920903222 +@K@NAME +T_ERR4_3 +@K@INSCRIPT +ERROR_HANDLING: +DB_OVERFLOW +NSEI/NSVCI +@K@CODE +/***@@@ ERROR ***/ +/*@@ERRORTEXT +*@ DB-OVERFLOW +*@ +*@ +*@@DESCRIPTION +*@ THE INSTANCE-CREATION WAS NOT POSSIBLE +*@ BECAUSE THE DATABASE WOULD OVERFLOW +*@ +*@@EXTRA INFO +*@ (EXTRA_INFO_4_STRUCT) +*@ NSEI +*@ NSVCI +*@ TEXT +*@ +*/ + +EXTRA_INFO.TYP4.NSEI := EVD_PTR->.KEYS.INT_ARR(0); +EXTRA_INFO.TYP4.NSVCI:= EVD_PTR->.KEYS.INT_ARR(1); +EXTRA_INFO.TYP4.TEXT := 'NSVC-HAND.: NSEI/NSVC-OVERFLOW'; + +G9PXYA1S!G9TE500_EHP_P( +'G9IBSA1C004', /*@@ID*/ +G9PXYA1S!G9TE102_ERR_CLASS_ESC_MAX_ANY, /*@@CLASS*/ +ADDR(EXTRA_INFO.ERROR_HANDLER), /* EXTRA-INFO ADDR */ +G9PXYA1S!G9TE100_GB_LM, /* USER-ID */ +NULL /* OPTIONAL-SWET-INFO ADDR */ +); +/***@@@ END OF ERROR ***/ + +@K@FREEZE +920903226 +@K@NAME +TR_RESET +@K@INSCRIPT +RESTART_ +TNS_RESET_ +TIMER +@K@CODE +/* TIMER EVENT DESCRIPTOR STILL THERE */ + +/* INITIALIZATION OF THE TIMER-EVENT-DESCRIPTOR STILL VALID */ +NSVCI_CON_PTR->.TIM_EVD_PTR->.TIMER:= TNS_RESET_MAP; + +/* START TIMER */ +G9PX508_START_TIMER_P +( +NSVCI_CON_PTR->.TIM_EVD_PTR +); + +@K@FREEZE +924684867 +@K@NAME +TX_AUDIT +@K@INSCRIPT +FOR +AUDIT + +@K@NAME +M_BLKOACKM +@K@INSCRIPT +NS_ +BLOCK_ACK +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9IBDF4_NS_LM_M) + G9IBD44_NS_PDU_DATA_OFFSET_C), +TX_EVD_PTR +); + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9IBD40_NS_LM_PDU_C; +TX_EVD_PTR->.EVENT_DESTINATION:= GBDL_HANDLE; + +IF +/* 'OTHER' ALIVE NSVC TO THIS NSEI EXISTING? */ +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR /= NULL +THEN +/* USE THIS 'OTHER' FOR TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(0):= + +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSEI; +/* NSEI TO BE USED FOR TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(1):= + +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; +/* NSVCI TO BE USED FOR TRANSPORT */ +ELSE +/* USE AFFECTED NSVC AGAIN FOR TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(0):= + NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSEI; /* NSEI TO BE USED FOR +TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(1):= + NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; /* NSVCI TO BE USED FOR +TRANSPORT */ +FI; + + +/* POINTER TO PDU IN POOL-ELEMENT */ +NS_PDU_PTR:= NS_PDU_REF_M (INT(TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT) + + G9IBD44_NS_PDU_DATA_OFFSET_C); +/* OFFSET OF THE PDU IN POOL-ELEMENT */ +TX_EVD_PTR->.BOUND.DATA_OFFSET:= G9IBD44_NS_PDU_DATA_OFFSET_C; +/* LENGTH OF THE PDU IN POOL-ELEMENT */ +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(NS_PDU_PTR->.G9IBDF4_PDU_TYPE) + +SIZE(NS_PDU_PTR->.D3); + +/* NOW THE POOL-ELEMENT */ +NS_PDU_PTR->.G9IBDF4_PDU_TYPE:= G9IBDR2_NS_BLOCK_ACK_C; /* PDU-TYPE */ + +NS_PDU_PTR->.D3.NSVCI_TLV.NSVCI_VAL := + NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; /* NSVC TO BE BLOCKED */ + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +938805885 +@K@NAME +T_RCTRUE +@K@INSCRIPT +RC += +TRUE +@K@CODE +RC:= TRUE; + +@K@FREEZE +922176328 +@K@NAME +M_AC_SBVCN +@K@INSCRIPT +G9IBME0_ +ACT_ +SIGN_BVC_C +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB512_GET_MSG_LESS_EV_DESCR_P +( +SID_GBNSVC, +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +TX_EVD_PTR->.EVENT_CMD:= G9IBME0_ACT_SIGN_BVC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= GBBVC_HANDLE; +TX_EVD_PTR->.KEYS.INT_ARR(0):= EVD_PTR->.KEYS.INT_ARR(0); +TX_EVD_PTR->.KEYS.INT_ARR(1):= SIGN_BVCI; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +938788211 +@K@NAME +T_RC_EOD +@K@INSCRIPT +RC += +END OF DATA + +@K@CODE +RC:= G9IBSM4_RC_END_OF_DATA; + +@K@FREEZE +921083785 +@K@NAME +T_RC_EMP +@K@INSCRIPT +RC += +EMPTY + +@K@CODE +RC:= G9IBSM4_RC_EMPTY; + +@K@FREEZE +921083757 +@K@NAME +T_RC_ERR +@K@INSCRIPT +RC += +ERROR + +@K@CODE +RC:= G9IBSM4_RC_ERROR; + +@K@FREEZE +921083731 +@K@NAME +S_UNUSED +@K@INSCRIPT +G9IBSM0_ +UNUSED +@K@CODE + + +@K@FREEZE +919416670 +@K@NAME +TA_UNBLOCK +@K@INSCRIPT +START_ +TNS_UNBLOCK_ +TIMER +@K@CODE +/* GET TIMER-EVENT DESCRIPTOR */ +G9PB513_GET_TIMER_EV_DESCR_P +( +SID_GBNSVC, +NSVCI_CON_PTR->.TIM_EVD_PTR +); + +/* INITIALIZATION OF THE TIMER-EVENT-DESCRIPTOR */ +NSVCI_CON_PTR->.TIM_EVD_PTR->.EVENT_CMD:= G9IBSE4_TO_TNS_C; +NSVCI_CON_PTR->.TIM_EVD_PTR->.EVENT_DESTINATION:= GBNSVC_HANDLE; +NSVCI_CON_PTR->.TIM_EVD_PTR->.KEYS.INT_ARR(0):= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSEI; +NSVCI_CON_PTR->.TIM_EVD_PTR->.KEYS.INT_ARR(1):= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; +NSVCI_CON_PTR->.TIM_EVD_PTR->.TIMER:= TNS_UNBLOCK_MAP; + +/* START TIMER */ +G9PX508_START_TIMER_P +( +NSVCI_CON_PTR->.TIM_EVD_PTR +); + +@K@FREEZE +924686210 +@K@NAME +M_BLK_ACKM +@K@INSCRIPT +NS_ +BLOCK_ACK +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9IBDF4_NS_LM_M) + G9IBD44_NS_PDU_DATA_OFFSET_C), +TX_EVD_PTR +); + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9IBD40_NS_LM_PDU_C; +TX_EVD_PTR->.EVENT_DESTINATION:= GBDL_HANDLE; +TX_EVD_PTR->.KEYS.INT_ARR(0):= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSEI; /* NSEI TO BE USED FOR +TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(1):= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; /* NSVCI TO BE USED FOR +TRANSPORT */ +/* POINTER TO PDU IN POOL-ELEMENT */ +NS_PDU_PTR:= NS_PDU_REF_M (INT(TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT) + + G9IBD44_NS_PDU_DATA_OFFSET_C); +/* OFFSET OF THE PDU IN POOL-ELEMENT */ +TX_EVD_PTR->.BOUND.DATA_OFFSET:= G9IBD44_NS_PDU_DATA_OFFSET_C; +/* LENGTH OF THE PDU IN POOL-ELEMENT */ +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(NS_PDU_PTR->.G9IBDF4_PDU_TYPE) + +SIZE(NS_PDU_PTR->.D3); + +/* NOW THE POOL-ELEMENT */ +NS_PDU_PTR->.G9IBDF4_PDU_TYPE:= G9IBDR2_NS_BLOCK_ACK_C; /* PDU-TYPE */ + +NS_PDU_PTR->.D3.NSVCI_TLV.NSVCI_VAL := + NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; /* NSVC TO BE BLOCKED */ + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +926348442 +@K@NAME +TA_NXTALIV +@K@INSCRIPT +DEFINE +NEW 'NEXT_ +ALIVE' +@K@CODE +IF +/* ALIVE NSVC TO THE NSEI EXISTING? */ +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR /= NULL + +THEN +/* TAKE NEXT ELEMENT IN THE LINKED LIST AS THE NEXT ALIVE NSVC */ +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR:= + +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR->.NEXT_ALV_NSVCI_CON_PTR; + +FI; + +@K@FREEZE +938801086 +@K@NAME +M_DE_CBVCN +@K@INSCRIPT +G9IBME2_ +DEACT_ +CELL_BVC_C + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB512_GET_MSG_LESS_EV_DESCR_P +( +SID_GBNSVC, +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +TX_EVD_PTR->.EVENT_CMD:= G9IBME2_DEACT_CELL_BVC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= GBBVC_HANDLE; +TX_EVD_PTR->.KEYS.INT_ARR(0):= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSEI; +TX_EVD_PTR->.KEYS.INT_ARR(1):= EVD_PTR->.ADD_DATA(3); + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +933318270 +@K@NAME +TA_NXTRESP +@K@INSCRIPT +DEFINE +NEW 'NEXT_ +RESPONSIBLE' +@K@CODE +NSEI_CON_PTR->.NEXT_RESP_NSVCI_CON_PTR:= + NSEI_CON_PTR->.NEXT_RESP_NSVCI_CON_PTR->.NEXT_LSP_NSVCI_CON_PTR; + + +@K@FREEZE +938005006 +@K@NAME +TA_NXTSUBS +@K@INSCRIPT +DEFINE +NEW 'NEXT_ +SUBSTITUTE' +@K@CODE +NSEI_CON_PTR->.NEXT_SUBS_NSVCI_CON_PTR:= + NSEI_CON_PTR->.NEXT_SUBS_NSVCI_CON_PTR->.NEXT_UBL_NSVCI_CON_PTR; + +@K@NAME +M_BLK_O__M +@K@INSCRIPT +NS_ +BLOCK +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9IBDF4_NS_LM_M) + G9IBD44_NS_PDU_DATA_OFFSET_C), +TX_EVD_PTR +); + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9IBD40_NS_LM_PDU_C; +TX_EVD_PTR->.EVENT_DESTINATION:= GBDL_HANDLE; + +IF +/* 'OTHER' ALIVE NSVC TO THIS NSEI EXISTING? */ +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR /= NULL +THEN +/* USE THIS 'OTHER' FOR TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(0):= + +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSEI; +/* NSEI TO BE USED FOR TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(1):= + +NSVCI_CON_PTR->.OWN_NSEI_CON_PTR->.NEXT_ALIV_NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; +/* NSVCI TO BE USED FOR TRANSPORT */ +ELSE +/* USE AFFECTED NSVC AGAIN FOR TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(0):= + NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSEI; /* NSEI TO BE USED FOR +TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(1):= + NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; /* NSVCI TO BE USED FOR +TRANSPORT */ +FI; + + +/* POINTER TO PDU IN POOL-ELEMENT */ +NS_PDU_PTR:= NS_PDU_REF_M (INT(TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT) + + G9IBD44_NS_PDU_DATA_OFFSET_C); +/* OFFSET OF THE PDU IN POOL-ELEMENT */ +TX_EVD_PTR->.BOUND.DATA_OFFSET:= G9IBD44_NS_PDU_DATA_OFFSET_C; +/* LENGTH OF THE PDU IN POOL-ELEMENT */ +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(NS_PDU_PTR->.G9IBDF4_PDU_TYPE) + +SIZE(NS_PDU_PTR->.D2); + + +/* NOW THE POOL-ELEMENT */ +NS_PDU_PTR->.G9IBDF4_PDU_TYPE:= G9IBDR1_NS_BLOCK_C; /* PDU-TYPE */ + +NS_PDU_PTR->.D2.CAUSE_TLV.CAUSE_VAL:= + G9IBBA2_NS_TRANSIT_NETWORK_FAILURE; /* CAUSE FOR BLOCK */ +NS_PDU_PTR->.D2.NSVCI_TLV.NSVCI_VAL := + NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; /* NSVC TO BE BLOCKED */ + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@TEXT +GSM 8.16 CHAP. 7.2: +THE NS-BLOCK-PDU MAY BE SENT IN ANY ALIVE +(BLOCKED OR UNBLOCKED) NS-VC... +@K@FREEZE +938803215 +@K@NAME +M_DE_SBVCN +@K@INSCRIPT +G9IBME1_ +DEACT_ +SIGN_BVC_C +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB512_GET_MSG_LESS_EV_DESCR_P +( +SID_GBNSVC, +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +TX_EVD_PTR->.EVENT_CMD:= G9IBME1_DEACT_SIGN_BVC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= GBBVC_HANDLE; +TX_EVD_PTR->.KEYS.INT_ARR(0):= EVD_PTR->.KEYS.INT_ARR(0); +TX_EVD_PTR->.KEYS.INT_ARR(1):= SIGN_BVCI; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +938788201 +@K@NAME +M_OAME401M +@K@INSCRIPT +ERROR_MESSAGE: +ERRONOUS_PDU +RESET_PDU + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSE */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSE; +OAM_MSG_PTR->.HANDLED_OBJECT.NSE_ID:= EVD_PTR->.KEYS.INT_ARR(0); /* +USED NSEI (FROM ECI) */ + +/* ERROR-CAUSE = ERRONEOUS_PDU */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ERRONEOUS_PDU; +/* ADDITIONAL_PDU_INFO */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_PDU_TYPE:= + G9OC124_RESET_PDU; +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSEI:= + EVD_PTR->.ADD_DATA(0); /* AFFECTED NSEI (FROM PDU) */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSVC:= + EVD_PTR->.ADD_DATA(1); /* AFFECTED NSVCI (FROM PDU) */ + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +935766108 +@K@NAME +M_OAME402M +@K@INSCRIPT +ERROR_MESSAGE: +ERRONOUS_PDU +RESET_PDU + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= EVD_PTR->.KEYS.INT_ARR(1); /* +USED NSVCI (FROM ECI) */ + +/* ERROR-CAUSE = ERRONEOUS_PDU */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ERRONEOUS_PDU; +/* ADDITIONAL_PDU_INFO */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_PDU_TYPE:= + G9OC124_RESET_PDU; +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSEI:= + EVD_PTR->.ADD_DATA(0); /* NSEI FROM PDU */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSVC:= + EVD_PTR->.ADD_DATA(1); /* NSVCI FROM PDU */ + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +935766407 +@K@NAME +M_OAME411M +@K@INSCRIPT +ERROR_MESSAGE: +ERRONOUS_PDU +RESET_ACK_PDU + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSE */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSE; +OAM_MSG_PTR->.HANDLED_OBJECT.NSE_ID:= EVD_PTR->.KEYS.INT_ARR(0); /* +USED NSEI (FROM ECI) */ + +/* ERROR-CAUSE = ERRONEOUS_PDU */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ERRONEOUS_PDU; +/* ADDITIONAL_PDU_INFO */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_PDU_TYPE:= + G9OC124_RESET_ACK_PDU; +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSEI:= + EVD_PTR->.ADD_DATA(0); /* NSEI FROM PDU */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSVC:= + EVD_PTR->.ADD_DATA(1); /* NSVCI FROM PDU */ + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +935767332 +@K@NAME +M_OAME412M +@K@INSCRIPT +ERROR_MESSAGE: +ERRONOUS_PDU +RESET_ACK_PDU + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= EVD_PTR->.KEYS.INT_ARR(1); /* +USED NSVCI (FROM ECI) */ + +/* ERROR-CAUSE = ERRONEOUS_PDU */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ERRONEOUS_PDU; +/* ADDITIONAL_PDU_INFO */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_PDU_TYPE:= + G9OC124_RESET_ACK_PDU; +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSEI:= + EVD_PTR->.ADD_DATA(0); /* NSEI FROM PDU */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSVC:= + EVD_PTR->.ADD_DATA(1); /* NSVCI FROM PDU */ + + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +935767189 +@K@NAME +C_CON +@K@INSCRIPT +RC_DB +@K@CODE +RC_DB + +@K@FREEZE +922176673 +@K@NAME +M_BLK____M +@K@INSCRIPT +NS_ +BLOCK +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9IBDF4_NS_LM_M) + G9IBD44_NS_PDU_DATA_OFFSET_C), +TX_EVD_PTR +); + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9IBD40_NS_LM_PDU_C; +TX_EVD_PTR->.EVENT_DESTINATION:= GBDL_HANDLE; +TX_EVD_PTR->.KEYS.INT_ARR(0):= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSEI; /* NSEI TO BE USED FOR +TRANSPORT */ +TX_EVD_PTR->.KEYS.INT_ARR(1):= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; /* NSVCI TO BE USED FOR +TRANSPORT */ +/* POINTER TO PDU IN POOL-ELEMENT */ +NS_PDU_PTR:= NS_PDU_REF_M (INT(TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT) + + G9IBD44_NS_PDU_DATA_OFFSET_C); +/* OFFSET OF THE PDU IN POOL-ELEMENT */ +TX_EVD_PTR->.BOUND.DATA_OFFSET:= G9IBD44_NS_PDU_DATA_OFFSET_C; +/* LENGTH OF THE PDU IN POOL-ELEMENT */ +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(NS_PDU_PTR->.G9IBDF4_PDU_TYPE) + +SIZE(NS_PDU_PTR->.D2); + + +/* NOW THE POOL-ELEMENT */ +NS_PDU_PTR->.G9IBDF4_PDU_TYPE:= G9IBDR1_NS_BLOCK_C; /* PDU-TYPE */ + +NS_PDU_PTR->.D2.CAUSE_TLV.CAUSE_VAL:= + G9IBBA2_NS_OAM_INTERVENTION; /* CAUSE FOR BLOCK */ +NS_PDU_PTR->.D2.NSVCI_TLV.NSVCI_VAL := + NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; /* NSVC TO BE BLOCKED */ + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@TEXT +GSM 8.16 CHAP. 7.2: +THE NS-BLOCK-PDU MAY BE SENT IN ANY ALIVE +(BLOCKED OR UNBLOCKED) NS-VC... +@K@FREEZE +926348613 +@K@NAME +S_BLOCKED +@K@INSCRIPT +G9IBSM0_ +BLOCKED +@K@CODE + + +@K@FREEZE +922176496 +@K@NAME +D_CON +@K@INSCRIPT +CONTEXT +GOT +@K@CODE +RC_DB = G9IBSR0_RC_OK + +@K@FREEZE +921772339 +@K@NAME +M_OAME901M +@K@INSCRIPT +ERROR_MESSAGE: +OPERATIONAL_STATE_CHANGE +UBL->BLK +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = OPERATIONAL_STATE_CHANGE */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_OPERATIONAL_STATE_CHANGE; +/* ADDITIONAL_OPERATIONAL_STATE_INFO */ +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.OPER_STATE_OLD:= + G9OC101_UNBLOCKED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.ADMIN_STATE_OLD:= + G9OC102_ENABLED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.ADMIN_STATE_NEW:= + G9OC102_ENABLED; + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +925970975 +@K@NAME +M_OAME902M +@K@INSCRIPT +ERROR_MESSAGE: +OPERATIONAL_STATE_CHANGE +UBL->BLK + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = OPERATIONAL_STATE_CHANGE */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_OPERATIONAL_STATE_CHANGE; +/* ADDITIONAL_OPERATIONAL_STATE_INFO */ +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.OPER_STATE_OLD:= + G9OC101_UNBLOCKED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.ADMIN_STATE_OLD:= + G9OC102_ENABLED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.ADMIN_STATE_NEW:= + G9OC102_DISABLED; + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +925970987 +@K@NAME +M_OAME10SM +@K@INSCRIPT +ERROR_MESSAGE: +ALARM_BEGIN_NS_ALIVE_TEST +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = ALARM_BEGIN_NS_ALIVE_TEST*/ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ALARM_BEGIN_NS_ALIVE_TEST; +/* ADDITIONAL_ALARM_INFO */ +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.ADMINISTRATIVE_STATE_CHANGED:= + TRUE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_OLD:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_OLD:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_NEW:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.CONFIGURATION_OF_NSVC:= + TRUE; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@NAME +M_OAME911M +@K@INSCRIPT +ERROR_MESSAGE: +OPERATIONAL_STATE_CHANGE +BLK->UBL +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = OPERATIONAL_STATE_CHANGE */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_OPERATIONAL_STATE_CHANGE; +/* ADDITIONAL_OPERATIONAL_STATE_INFO */ +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.OPER_STATE_OLD:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.OPER_STATE_NEW:= + G9OC101_UNBLOCKED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.ADMIN_STATE_OLD:= + G9OC102_ENABLED; +OAM_MSG_PTR->.ADDITIONAL_OPERATIONAL_STATE_INFO.ADMIN_STATE_NEW:= + G9OC102_ENABLED; + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +925970996 +@K@NAME +M_OAME20SM +@K@INSCRIPT +ERROR_MESSAGE: +ALARM_END_NS_ALIVE_TEST +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = ALARM_END_NS_ALIVE_TEST */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ALARM_END_NS_ALIVE_TEST; +/* ADDITIONAL_ALARM_INFO */ +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.ADMINISTRATIVE_STATE_CHANGED:= + TRUE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_OLD:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_OLD:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_NEW:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.CONFIGURATION_OF_NSVC:= + TRUE; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@NAME +M_OAME10_M +@K@INSCRIPT +ERROR_MESSAGE: +ALARM_BEGIN_NS_ALIVE_TEST +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = ALARM_BEGIN_NS_ALIVE_TEST*/ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ALARM_BEGIN_NS_ALIVE_TEST; +/* ADDITIONAL_ALARM_INFO */ +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.ADMINISTRATIVE_STATE_CHANGED:= + TRUE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_OLD:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_OLD:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_NEW:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.CONFIGURATION_OF_NSVC:= + TRUE; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +922443813 +@K@NAME +D_SEM +@K@INSCRIPT +CALL_SEM += +TRUE +@K@CODE +CALL_SEM = TRUE + +@K@FREEZE +922176624 +@K@NAME +D_N_0 +@K@INSCRIPT +N = 0 + +@K@CODE +NSVCI_CON_PTR->.N = 0 + +@K@FREEZE +921511000 +@K@NAME +M_OAME12_M +@K@INSCRIPT +ERROR_MESSAGE: +ALARM_BEGIN_NS_ALIVE_TEST +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = ALARM_BEGIN_NS_ALIVE_TEST*/ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ALARM_BEGIN_NS_ALIVE_TEST; +/* ADDITIONAL_ALARM_INFO */ +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.ADMINISTRATIVE_STATE_CHANGED:= + FALSE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_OLD:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_OLD:= + G9OC103_ALIVE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_NEW:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.CONFIGURATION_OF_NSVC:= + TRUE; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +922443829 +@K@NAME +M_OAME21_M +@K@INSCRIPT +ERROR_MESSAGE: +ALARM_END_NS_ALIVE_TEST +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = ALARM_END_NS_ALIVE_TEST */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ALARM_END_NS_ALIVE_TEST; +/* ADDITIONAL_ALARM_INFO */ +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.ADMINISTRATIVE_STATE_CHANGED:= + TRUE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_OLD:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_OLD:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_NEW:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.CONFIGURATION_OF_NSVC:= + FALSE; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +922443856 +@K@NAME +M_OAME13_M +@K@INSCRIPT +ERROR_MESSAGE: +ALARM_BEGIN_NS_ALIVE_TEST +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = ALARM_BEGIN_NS_ALIVE_TEST*/ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ALARM_BEGIN_NS_ALIVE_TEST; +/* ADDITIONAL_ALARM_INFO */ +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.ADMINISTRATIVE_STATE_CHANGED:= + FALSE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_OLD:= + G9OC101_UNBLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_OLD:= + G9OC103_ALIVE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_NEW:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.CONFIGURATION_OF_NSVC:= + TRUE; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +922443838 +@K@NAME +M_OAME22_M +@K@INSCRIPT +ERROR_MESSAGE: +ALARM_END_NS_ALIVE_TEST +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = ALARM_END_NS_ALIVE_TEST */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ALARM_END_NS_ALIVE_TEST; +/* ADDITIONAL_ALARM_INFO */ +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.ADMINISTRATIVE_STATE_CHANGED:= + FALSE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_OLD:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.OPER_STATE_NEW:= + G9OC101_BLOCKED; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_OLD:= + G9OC103_DEAD; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.AVAIL_STATE_NEW:= + G9OC103_ALIVE; +OAM_MSG_PTR->.ADDITIONAL_ALARM_INFO.CONFIGURATION_OF_NSVC:= + TRUE; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +922443864 +@K@NAME +M_OAME30_M +@K@INSCRIPT +ERROR_MESSAGE: +NO_ANSWER_FORM_BSS +RESET_PROCEDURE + + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = NO_ANSWER_FROM_BSS */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_NO_ANSWER_FROM_BSS; +/* INITIATED_PROCEDURE */ +OAM_MSG_PTR->.INITIATED_PROCEDURE:= + G9OC123_RESET_PROCEDURE; + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +922175973 +@K@NAME +M_OAME31_M +@K@INSCRIPT +ERROR_MESSAGE: +NO_ANSWER_FROM_BSS +BLOCK_PROCEDURE + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = NO_ANSWER_FROM_BSS */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_NO_ANSWER_FROM_BSS; +/* INITIATED_PROCEDURE */ +OAM_MSG_PTR->.INITIATED_PROCEDURE:= + G9OC123_BLOCK_PROCEDURE; + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +922175976 +@K@NAME +M_OAME32_M +@K@INSCRIPT +ERROR_MESSAGE: +NO_ANSWER_FROM_BSS +UNBLOCK_PROCEDURE + +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR_CAUSE = NO_ANSWER_FROM_BSS */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_NO_ANSWER_FROM_BSS; +/* INITIATED_PROCEDURE */ +OAM_MSG_PTR->.INITIATED_PROCEDURE:= + G9OC123_UNBLOCK_PROCEDURE; + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +922175980 +@K@NAME +M_OAME42_M +@K@INSCRIPT +ERROR_MESSAGE: +ERRONOUS_PDU +BLOCK_PDU +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= EVD_PTR->.ADD_DATA(1); /* +USED NSVCI (FROM ECI) */ + +/* ERROR-CAUSE = ERRONEOUS_PDU */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ERRONEOUS_PDU; +/* ADDITIONAL_PDU_INFO */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_PDU_TYPE:= + G9OC124_BLOCK_PDU; +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSEI:= + EVD_PTR->.KEYS.INT_ARR(0); /* AFFECTED NSEI (FROM PDU) */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSVC:= + EVD_PTR->.KEYS.INT_ARR(1); /* AFFECTED NSVCI (FROM PDU) */ + + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +934296141 +@K@NAME +M_OAME50_M +@K@INSCRIPT +ERROR_MESSAGE: +STATUS_PDU_CONTAINS_ERROR_INFO +RECEIVED +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= +NSVCI_CON_PTR->.DBMS.NSVC_INSTANCE.NSVCI; + +/* ERROR-CAUSE = STATUS_PDU_CONTAINS_ERROR_INFO */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_STATUS_PDU_CONTAINS_ERROR_INFO; +/* ADDITIONAL_STATUS_PDU_INFO */ +INT_CAUSE_PTR.INT_PTR:= ADDR(EVD_PTR->.ADD_DATA(2)); +OAM_MSG_PTR->.ADDITIONAL_STATUS_PDU_INFO:= + INT_CAUSE_PTR.CAUSE_PTR->; /* CAUSE */ + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@TEXT +NICHT OK + +@K@FREEZE +934298924 +@K@NAME +M_OAME43_M +@K@INSCRIPT +ERROR_MESSAGE: +ERRONOUS_PDU +BLOCK_ACK_PDU +@K@CODE +/* GETTING THE EVENT DESCRIPTOR */ +G9PB511_GET_MSG_BOUND_EV_DESCR_P +( +SID_GBNSVC, +(SIZE(G9OC109_REPORTED_EVENT_STR_M)), +TX_EVD_PTR +); + + +/* COMPOSING THE EVENT */ +/* FIRST THE DESCRIPTOR */ +TX_EVD_PTR->.EVENT_CMD:= G9PX040_SEND_MBC_C; +TX_EVD_PTR->.EVENT_DESTINATION:= RXTX_HANDLE; +TX_EVD_PTR->.KEYS.UBI_INDEX:= OAM_UBI_INDEX; +TX_EVD_PTR->.BOUND.DATA_OFFSET:= 0; +TX_EVD_PTR->.BOUND.DATA_LENGTH:= SIZE(G9OC109_REPORTED_EVENT_STR_M); + +/* NOW THE POOL-ELEMENT */ +/* INITIALIZATION OF THE POINTER WITH THE POOL-ELEMENT-START */ +OAM_MSG_PTR:= OAM_MSG_PTR_M (TX_EVD_PTR->.BOUND.PTR_TO_POOL_ELEMENT); + +/* COMPOSING THE MESSAGE */ +/* HANDLED OBJECT = AFFECTED INSTANCE, TYPE NSVC */ +OAM_MSG_PTR->.HANDLED_OBJECT.OBJECT_TYPE:= G9OC104_NSVC; +OAM_MSG_PTR->.HANDLED_OBJECT.NSVC_ID:= EVD_PTR->.ADD_DATA(1); /* +USED NSVCI (FROM ECI) */ + +/* ERROR-CAUSE = ERRONEOUS_PDU */ +OAM_MSG_PTR->.ERROR_CAUSE:= G9OC108_ERRONEOUS_PDU; +/* ADDITIONAL_PDU_INFO */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_PDU_TYPE:= + G9OC124_BLOCK_ACK_PDU; +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSEI:= + EVD_PTR->.KEYS.INT_ARR(0); /* AFFECTED NSEI (FROM PDU) */ +OAM_MSG_PTR->.ADDITIONAL_PDU_INFO.G9OC120_REPORTED_NSVC:= + EVD_PTR->.KEYS.INT_ARR(1); /* AFFECTED NSVCI (FROM PDU) */ + + + +/* SENDING */ +G9PX503_POST_EVENT_P(TX_EVD_PTR); + +@K@FREEZE +934297710 diff --git a/test/getlndir.awk b/test/getlndir.awk new file mode 100644 index 0000000..250c5ab --- /dev/null +++ b/test/getlndir.awk @@ -0,0 +1,7 @@ +BEGIN { + if (!SRCDIR) SRCDIR = "." + OFS = ", " + x = 4 + ret = (getline x < SRCDIR) + print x, ret, ERRNO +} diff --git a/test/getlndir.ok b/test/getlndir.ok new file mode 100644 index 0000000..a9bafa0 --- /dev/null +++ b/test/getlndir.ok @@ -0,0 +1 @@ +4, -1, Is a directory diff --git a/test/getlnhd.awk b/test/getlnhd.awk new file mode 100644 index 0000000..f0f801b --- /dev/null +++ b/test/getlnhd.awk @@ -0,0 +1,10 @@ +BEGIN { pipe = "cat < 0) + print + + exit 0 +} diff --git a/test/getlnhd.ok b/test/getlnhd.ok new file mode 100644 index 0000000..d8cb453 --- /dev/null +++ b/test/getlnhd.ok @@ -0,0 +1,2 @@ +select * from user + where Name = 'O\'Donell' diff --git a/test/getnr2tb.awk b/test/getnr2tb.awk new file mode 100644 index 0000000..204acf4 --- /dev/null +++ b/test/getnr2tb.awk @@ -0,0 +1,111 @@ +#From vp@dmat.uevora.pt Thu Jun 18 09:10 EDT 1998 +#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 JAA23649 for ; Thu, 18 Jun 1998 09:10:54 -0400 (EDT) +#Received: from khromeleque.dmat.uevora.pt by mescaline.gnu.org (8.8.5/8.6.12GNU) with ESMTP id JAA21732 for ; Thu, 18 Jun 1998 09:11:19 -0400 +#Received: from khromeleque.dmat.uevora.pt (vp@localhost [127.0.0.1]) +# by khromeleque.dmat.uevora.pt (8.8.8/8.8.8/Debian/GNU) with ESMTP id OAA11817 +# for ; Thu, 18 Jun 1998 14:13:57 +0100 +#Message-Id: <199806181313.OAA11817@khromeleque.dmat.uevora.pt> +#To: arnold@gnu.org +#Subject: concatenation bug in gawk 3.0.3 +#Date: Thu, 18 Jun 1998 14:13:57 +0200 +#From: Vasco Pedro +#Content-Type: text +#Content-Length: 2285 +#Status: RO +# +#Hi, +# +#The gawk program '{print NR " " 10/NR}' will print: +# +#1 10 +#5 5 +#3 3.33333 +#2 2.5 +#2 2 +#1 1.66667 +# +#instead of the correct: +# +#1 10 +#2 5 +#3 3.33333 +#4 2.5 +#5 2 +#6 1.66667 +# +#You'll notice, on the incorrect output, that the first column is +#the first digit of the second. +# +#I think the problem comes from the way builtin variables are handled. +#Since the items to be concatenated are processed in reverse order and +#the return value of tree_eval(``NR'') is a pointer to the value part +#of `NR_node', the `unref()' of `NR_node' due to its second occurrence +#will leave a dangling pointer in `strlist'. The reason that it doesn't +#reuse the freed space with objects of the same type. (Using Electric +#Fence with EF_PROTECT_FREE set confirms that freed space is being +#accessed.) +# +#The enclosed patch (hack would be a better word to describe it) is +#all I could come up with. With it installed, things seem to work ok, +#but I doubt this is the correct way to do it. (If I treated the +#case for `Node_field_spec' as the I did others, `make check' would +#fail in several places.) +# +#Regards, +#vasco +# +#*** eval.c~ Tue May 6 21:39:55 1997 +#--- eval.c Thu Jun 18 13:39:25 1998 +#*************** +#*** 685,697 **** +# return func_call(tree->rnode, tree->lnode); +# +# /* unary operations */ +# case Node_NR: +# case Node_FNR: +# case Node_NF: +# case Node_FIELDWIDTHS: +# case Node_FS: +# case Node_RS: +#- case Node_field_spec: +# case Node_subscript: +# case Node_IGNORECASE: +# case Node_OFS: +#--- 685,700 ---- +# return func_call(tree->rnode, tree->lnode); +# +# /* unary operations */ +#+ case Node_field_spec: +#+ lhs = get_lhs(tree, (Func_ptr *) NULL); +#+ return *lhs; +#+ +# case Node_NR: +# case Node_FNR: +# case Node_NF: +# case Node_FIELDWIDTHS: +# case Node_FS: +# case Node_RS: +# case Node_subscript: +# case Node_IGNORECASE: +# case Node_OFS: +#*************** +#*** 699,705 **** +# case Node_OFMT: +# case Node_CONVFMT: +# lhs = get_lhs(tree, (Func_ptr *) NULL); +#! return *lhs; +# +# case Node_var_array: +# fatal("attempt to use array `%s' in a scalar context", +#--- 702,710 ---- +# case Node_OFMT: +# case Node_CONVFMT: +# lhs = get_lhs(tree, (Func_ptr *) NULL); +#! r = dupnode(*lhs); +#! r->flags |= TEMP; +#! return r; +# +# case Node_var_array: +# fatal("attempt to use array `%s' in a scalar context", +# +{ print NR " " 10/NR } diff --git a/test/getnr2tb.in b/test/getnr2tb.in new file mode 100644 index 0000000..f985857 --- /dev/null +++ b/test/getnr2tb.in @@ -0,0 +1,6 @@ +line 1 +line 2 +line 3 +line 4 +line 5 +line 6 diff --git a/test/getnr2tb.ok b/test/getnr2tb.ok new file mode 100644 index 0000000..7b40e8d --- /dev/null +++ b/test/getnr2tb.ok @@ -0,0 +1,6 @@ +1 10 +2 5 +3 3.33333 +4 2.5 +5 2 +6 1.66667 diff --git a/test/getnr2tm.awk b/test/getnr2tm.awk new file mode 100644 index 0000000..dfe377a --- /dev/null +++ b/test/getnr2tm.awk @@ -0,0 +1,75 @@ +#From dhw@gamgee.acad.emich.edu Sat Oct 31 22:54:07 1998 +#Return-Path: +#Received: from cssun.mathcs.emory.edu (cssun.mathcs.emory.edu [170.140.150.1]) +# by amx.netvision.net.il (8.9.0.Beta5/8.8.6) with ESMTP id HAA08891 +# for ; Sat, 31 Oct 1998 07:14:07 +0200 (IST) +#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 AAA14947 for ; Sat, 31 Oct 1998 00:14:32 -0500 (EST) +#Received: from gamgee.acad.emich.edu (gamgee.acad.emich.edu [164.76.102.76]) +# by mescaline.gnu.org (8.9.1a/8.9.1) with SMTP id AAA20645 +# for ; Sat, 31 Oct 1998 00:17:54 -0500 +#Received: by gamgee.acad.emich.edu (Smail3.1.29.1 #57) +# id m0zZUKY-000IDSC; Sat, 31 Oct 98 00:16 CST +#Message-Id: +#Date: Sat, 31 Oct 98 00:16 CST +#From: dhw@gamgee.acad.emich.edu (David H. West) +#To: bug-gnu-utils@gnu.org +#Subject: gawk 3.0.3 bug report +#Cc: arnold@gnu.org +#X-UIDL: 7474b825cff989adf38f13883d84fdd7 +#Status: RO +# +#gawk version: 3.03 +#System used: Linux, kernel 2.0.28, libc 5.4.33, AMD K5PR133 (i586 clone) +#Remark: There seems to be at least one bug shown by the demo below. +# There may also be a Dark Corner involving the value of NR in an +# END block, a topic on which the info file is silent. In gawk +# 3.0.3, NR often seems to have the least-surprise value in an +# END block, but sometimes it doesn't - see example below. +#Problem descr: the log below shows a case where: +# a) (this may be a red herring) the output of the gawk script +# is different depending on whether its input file is named on +# the command line or catted to stdin, without any use of the +# legitimate means which could produce this effect. +# b) NR is clearly getting clobbered; I have tried to simplify +# the 19-line script "awkerr1" below, but seemingly unrelated +# changes, like shortening constant strings which appear only in +# print statements, or removing unexecuted or irrelevant code, +# cause the clobbering to go away. Some previous (larger) +# versions of this code would clobber NR also when reading from +# stdin, but I thought you'd prefer a shorter example :-). +#Reproduce-By: using the gawk script "awkerr1", the contents of +# which appear in the transcript below as the output of the +# command "cat awkerr1". Comments following # were added +# to the transcript later as explanation. +#---------------------------------------------- Script started on Fri +#Oct 30 20:04:16 1998 chipmunk:/ram0# ls -l a1 awkerr1 -rw-r--r-- 1 +#root root 2 Oct 30 18:42 a1 -rwxr-xr-x 1 root root +#389 Oct 30 19:54 awkerr1 chipmunk:/ram0# cat a1 #a1 contains +#one printable char and a newline a chipmunk:/ram0# od -c xc a1 +#0000000 0a61 +# a \n +#0000002 chipmunk:/ram0# cat a1 | awkerr1 #no surprises here +#1 lines in 1 sec: 1 lines/sec; nlines=1 chipmunk:/ram0# awkerr1 a1 È +#lines in 1 sec: 1 lines/sec; nlines=1 #?! first char is an uppercase +#E-grave chipmunk:/ram0# awkerr1 a1 | od -N1 -xc 0000000 00c8 +# 310 \0 +#0000001 chipmunk:/ram0# cat awkerr1 #the apparent ^M's are not +#actually in the file +#!/usr/bin/awk -f +function process(w) { + if(w in ws) { + printf " : found\n"; lc[p " " w]++; rc[w " " n]++; } + } +BEGIN {IGNORECASE=1; + } +/^/ {if(NR % 10 ==0)print "processing line " NR; + process($1); nlines++; + } +END {p=w; w=n; n=""; + if(w)process(w); t=1; print NR " lines in " t " sec: " NR+0 " lines/sec; nlines=" nlines; + } +#chipmunk:/ram0# exit Script done on Fri Oct 30 20:07:31 1998 +#--------------------------------------------- +# +#-David West dhw@gamgee.acad.emich.edu +# diff --git a/test/getnr2tm.in b/test/getnr2tm.in new file mode 100644 index 0000000..7898192 --- /dev/null +++ b/test/getnr2tm.in @@ -0,0 +1 @@ +a diff --git a/test/getnr2tm.ok b/test/getnr2tm.ok new file mode 100644 index 0000000..d63fca0 --- /dev/null +++ b/test/getnr2tm.ok @@ -0,0 +1 @@ +1 lines in 1 sec: 1 lines/sec; nlines=1 diff --git a/test/gnuops2.awk b/test/gnuops2.awk new file mode 100644 index 0000000..1b0d4d7 --- /dev/null +++ b/test/gnuops2.awk @@ -0,0 +1,72 @@ +# From Servatius.Brandt@fujitsu-siemens.com Fri Dec 1 13:44:48 2000 +# Received: from mail.actcom.co.il +# by localhost with POP3 (fetchmail-5.1.0) +# for arnold@localhost (single-drop); Fri, 01 Dec 2000 13:44:48 +0200 (IST) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Fri Dec 1 13:44:10 2000) +# X-From_: Servatius.Brandt@fujitsu-siemens.com Fri Dec 1 13:11:23 2000 +# Received: from lmail.actcom.co.il by actcom.co.il with ESMTP +# (8.9.1a/actcom-0.2) id NAA11033 for ; +# Fri, 1 Dec 2000 13:11:21 +0200 (EET) +# (rfc931-sender: lmail.actcom.co.il [192.114.47.13]) +# Received: from billohost.com (10-209.196.35.dellhost.com [209.196.35.10] (may be forged)) +# by lmail.actcom.co.il (8.9.3/8.9.1) with ESMTP id NAA30286 +# for ; Fri, 1 Dec 2000 13:12:25 +0200 +# Received: from fencepost.gnu.org (we-refuse-to-spy-on-our-users@fencepost.gnu.org [199.232.76.164]) +# by billohost.com (8.9.3/8.9.3) with ESMTP id GAA26074 +# for ; Fri, 1 Dec 2000 06:09:08 -0500 +# Received: from energy.pdb.sbs.de ([192.109.2.19]) +# by fencepost.gnu.org with esmtp (Exim 3.16 #1 (Debian)) +# id 141o5z-0000RJ-00; Fri, 01 Dec 2000 06:11:16 -0500 +# Received: from trulli.pdb.fsc.net ([172.25.96.20]) +# by energy.pdb.sbs.de (8.9.3/8.9.3) with ESMTP id MAA32687; +# Fri, 1 Dec 2000 12:11:13 +0100 +# Received: from pdbrd02e.pdb.fsc.net (pdbrd02e.pdb.fsc.net [172.25.96.15]) +# by trulli.pdb.fsc.net (8.9.3/8.9.3) with ESMTP id MAA27384; +# Fri, 1 Dec 2000 12:11:13 +0100 +# Received: from Fujitsu-Siemens.com (pgtd1181.mch.fsc.net [172.25.126.152]) by pdbrd02e.pdb.fsc.net with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) +# id XC2QLXS2; Fri, 1 Dec 2000 12:11:13 +0100 +# Message-ID: <3A2786CF.1000903@Fujitsu-Siemens.com> +# Date: Fri, 01 Dec 2000 12:09:03 +0100 +# From: Servatius Brandt +# Organization: Fujitsu Siemens Computers +# User-Agent: Mozilla/5.0 (Windows; U; Win95; en-US; m18) Gecko/20001108 Netscape6/6.0 +# X-Accept-Language: de, en +# MIME-Version: 1.0 +# To: bug-gnu-utils@gnu.org +# CC: arnold@gnu.org +# Subject: Bug Report: \y, \B, \<, \> do not work with _ +# Content-Type: text/plain; charset=us-ascii; format=flowed +# Content-Transfer-Encoding: 7bit +# Status: R +# +# Hello, +# +# The \y, \B, \<, \> patterns do not regard _ as +# word-constituent (unlike \w and \W, which do). +# +# Operating system: ReliantUNIX-Y 5.44 C2001 RM600 R10000 +# Version of gawk: 3.0.6 +# C-Compiler: Fujitsu Siemens Computers CDS++ V2.0C0004 +# +# Test program: +# +#!/usr/local/bin/gawk -f + +BEGIN { + print match("X _abc Y", /\<_abc/) # bug + print match("X _abc Y", /\y_abc/) # bug + print match("X abc_ Y", /abc_\>/) # bug + print match("X abc_ Y", /abc_\y/) # bug + print match("X abc_def Y", /abc_\Bdef/) # bug + + print match("X a_c Y", /a\wc/) # ok! + print match("X a.c Y", /a\Wc/) # ok! + exit +} +# +# +# Regards, +# Servatius Brandt +# +# diff --git a/test/gnuops2.ok b/test/gnuops2.ok new file mode 100644 index 0000000..aa0ecae --- /dev/null +++ b/test/gnuops2.ok @@ -0,0 +1,7 @@ +3 +3 +3 +3 +3 +3 +3 diff --git a/test/gnuops3.awk b/test/gnuops3.awk new file mode 100644 index 0000000..bcd40aa --- /dev/null +++ b/test/gnuops3.awk @@ -0,0 +1,14 @@ +# Mon Jan 31 09:57:30 IST 2005 +# test both dfa and regex matchers on \B +# tests from Stepan Kasal, kasal@ucw.cz +BEGIN { + + print (" " ~ / \B /) # test dfa matcher + print ("a b" ~ /\B/) + print (" b" ~ /\B/) + print ("a " ~ /\B/) + + a = " " + gsub(/\B/, "x", a) # test regex matcher + print a +} diff --git a/test/gnuops3.ok b/test/gnuops3.ok new file mode 100644 index 0000000..27db307 --- /dev/null +++ b/test/gnuops3.ok @@ -0,0 +1,5 @@ +1 +0 +1 +1 +x x x diff --git a/test/gnureops.awk b/test/gnureops.awk new file mode 100644 index 0000000..15b9b84 --- /dev/null +++ b/test/gnureops.awk @@ -0,0 +1,45 @@ +# test the gnu regexp ops + +BEGIN { + if ("a rat is here" ~ /\yrat/) print "test 1 ok (\\y)" + else print "test 1 failed (\\y)" + if ("a rat is here" ~ /rat\y/) print "test 2 ok (\\y)" + else print "test 2 failed (\\y)" + if ("what a brat" !~ /\yrat/) print "test 3 ok (\\y)" + else print "test 3 failed (\\y)" + + if ("in the crate" ~ /\Brat/) print "test 4 ok (\\B)" + else print "test 4 failed (\\B)" + if ("a rat" !~ /\Brat/) print "test 5 ok (\\B)" + else print "test 5 failed (\\B)" + + if ("a word" ~ /\/) print "test 8 ok (\\>)" + else print "test 8 failed (\\\\>)" + if ("wordy" !~ /word\>/) print "test 9 ok (\\>)" + else print "test 9 failed (\\>)" + + if ("a" ~ /\w/) print "test 10 ok (\\w)" + else print "test 10 failed (\\\\w)" + if ("+" !~ /\w/) print "test 11 ok (\\w)" + else print "test 11 failed (\\w)" + + if ("a" !~ /\W/) print "test 12 ok (\\W)" + else print "test 12 failed (\\W)" + if ("+" ~ /\W/) print "test 13 ok (\\W)" + else print "test 13 failed (\\W)" + + if ("a" ~ /\`a/) print "test 14 ok (\\`)" + else print "test 14 failed (\\`)" + if ("b" !~ /\`a/) print "test 15 ok (\\`)" + else print "test 15 failed (\\`)" + + if ("a" ~ /a\'/) print "test 16 ok (\\')" + else print "test 16 failed (\\')" + if ("b" !~ /a\'/) print "test 17 ok (\\')" + else print "test 17 failed (\\')" +} diff --git a/test/gnureops.ok b/test/gnureops.ok new file mode 100644 index 0000000..0fb5f50 --- /dev/null +++ b/test/gnureops.ok @@ -0,0 +1,17 @@ +test 1 ok (\y) +test 2 ok (\y) +test 3 ok (\y) +test 4 ok (\B) +test 5 ok (\B) +test 6 ok (\<) +test 7 ok (\<) +test 8 ok (\>) +test 9 ok (\>) +test 10 ok (\w) +test 11 ok (\w) +test 12 ok (\W) +test 13 ok (\W) +test 14 ok (\`) +test 15 ok (\`) +test 16 ok (\') +test 17 ok (\') diff --git a/test/gsubasgn.awk b/test/gsubasgn.awk new file mode 100644 index 0000000..f0b7701 --- /dev/null +++ b/test/gsubasgn.awk @@ -0,0 +1,13 @@ +# tests for assigning to a function within that function + +#1 - should be bad +function test1 (r) { gsub(r, "x", test1) } +BEGIN { test1("") } + +#2 - should be bad +function test2 () { gsub(/a/, "x", test2) } +BEGIN { test2() } + +#3 - should be ok +function test3 (r) { gsub(/a/, "x", r) } +BEGIN { test3("") } diff --git a/test/gsubasgn.ok b/test/gsubasgn.ok new file mode 100644 index 0000000..8817c36 --- /dev/null +++ b/test/gsubasgn.ok @@ -0,0 +1,5 @@ +gawk: gsubasgn.awk:4: function test1 (r) { gsub(r, "x", test1) } +gawk: gsubasgn.awk:4: ^ gsub third parameter is not a changeable object +gawk: gsubasgn.awk:8: function test2 () { gsub(/a/, "x", test2) } +gawk: gsubasgn.awk:8: ^ gsub third parameter is not a changeable object +EXIT CODE: 1 diff --git a/test/gsubtest.awk b/test/gsubtest.awk new file mode 100644 index 0000000..1d6fd1c --- /dev/null +++ b/test/gsubtest.awk @@ -0,0 +1,9 @@ +BEGIN { + str = "abc"; print gsub("b+", "FOO", str), str + str = "abc"; print gsub("x*", "X", str), str + str = "abc"; print gsub("b*", "X", str), str + str = "abc"; print gsub("c", "X", str), str + str = "abc"; print gsub("c+", "X", str), str + str = "abc"; print gsub("x*$", "X", str), str + str = "abc"; print gsub("b|$", "X", str), str +} diff --git a/test/gsubtest.ok b/test/gsubtest.ok new file mode 100644 index 0000000..f909d0d --- /dev/null +++ b/test/gsubtest.ok @@ -0,0 +1,7 @@ +1 aFOOc +4 XaXbXcX +3 XaXcX +1 abX +1 abX +1 abcX +2 aXcX diff --git a/test/gsubtst2.awk b/test/gsubtst2.awk new file mode 100644 index 0000000..fafbf96 --- /dev/null +++ b/test/gsubtst2.awk @@ -0,0 +1,241 @@ +#From arnold Thu May 9 17:27:03 2002 +#Return-Path: +#Received: (from arnold@localhost) +# by skeeve.com (8.11.6/8.11.6) id g49ER3K27925 +# for arnold; Thu, 9 May 2002 17:27:03 +0300 +#Date: Thu, 9 May 2002 17:27:03 +0300 +#From: Aharon Robbins +#Message-Id: <200205091427.g49ER3K27925@skeeve.com> +#To: arnold@skeeve.com +#Subject: fixme +#X-SpamBouncer: 1.4 (10/07/01) +#X-SBRule: Pattern Match (Other Patterns) (Score: 4850) +#X-SBRule: Pattern Match (Spam Phone #) (Score: 0) +#X-SBClass: Blocked +#Status: O +# +#Path: ord-read.news.verio.net!dfw-artgen!iad-peer.news.verio.net!news.verio.net!fu-berlin.de!uni-berlin.de!host213-120-137-48.in-addr.btopenworld.COM!not-for-mail +#From: laura@madonnaweb.com (laura fairhead) +#Newsgroups: comp.lang.awk +#Subject: bug in gawk3.1.0 regex code +#Date: Wed, 08 May 2002 23:31:40 GMT +#Organization: that'll be the daewooo :) +#Lines: 211 +#Message-ID: <3cd9b0f7.29675926@NEWS.CIS.DFN.DE> +#Reply-To: laura@madonnaweb.com +#NNTP-Posting-Host: host213-120-137-48.in-addr.btopenworld.com (213.120.137.48) +#X-Trace: fu-berlin.de 1020900891 18168286 213.120.137.48 (16 [53286]) +#X-Newsreader: Forte Free Agent 1.21/32.243 +#Xref: dfw-artgen comp.lang.awk:13059 +# +# +#I believe I've just found a bug in gawk3.1.0 implementation of +#extended regular expressions. It seems to be down to the alternation +#operator; when using an end anchor '$' as a subexpression in an +#alternation and the entire matched RE is a nul-string it fails +#to match the end of string, for example; +# +#gsub(/$|2/,"x") +#print +# +#input = 12345 +#expected output = 1x345x +#actual output = 1x345 +# +#The start anchor '^' always works as expected; +# +#gsub(/^|2/,"x") +#print +# +#input = 12345 +#expected output = x1x345 +#actual output = x1x345 +# +#This was with POSIX compliance enabled althought that doesn't +#effect the result. +# +#I checked on gawk3.0.6 and got exactly the same results however +#gawk2.15.6 gives the expected results. +# +#I'm about to post a bug report about this into gnu.utils.bug +#but I thought I'd post it here first in case anyone has +#any input/comments/whatever .... +# +#Complete test results were as follows; +# +#input 12345 +#output gsub(/regex/,"x",input) +# +#regex output +#(^) x12345 +#($) 12345x +#(^)|($) x12345x +#($)|(^) x12345x +#(2) 1x345 +#(^)|2 x1x345 +#2|(^) x1x345 +#($)|2 1x345 +#2|($) 1x345 +#(2)|(^) x1x345 +#(^)|(2) x1x345 +#(2)|($) 1x345 +#($)|(2) 1x345 +#.((2)|(^)) x345 +#.((^)|(2)) x345 +#.((2)|($)) x34x +#.(($)|(2)) x34x +#x{0}((2)|(^)) x1x345 +#x{0}((^)|(2)) x1x345 +#x{0}((2)|($)) 1x345 +#x{0}(($)|(2)) 1x345 +#x*((2)|(^)) x1x345 +#x*((^)|(2)) x1x345 +#x*((2)|($)) 1x345 +#x*(($)|(2)) 1x345 +# +#Here's the test program I used, a few of the cases use ERE {n[,[m]]} +#operators so that will have to be commented out or have a check +#added or something (should have put a conditional in I know... ;-) +# +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +BEGIN{ + +TESTSTR="12345" + +print "input "TESTSTR +print "output gsub(/regex/,\"x\",input)" +print "" + +print "regex output" +$0=TESTSTR +gsub(/(^)/,"x") +print "(^) "$0 + +$0=TESTSTR +gsub(/($)/,"x") +print "($) "$0 + +$0=TESTSTR +gsub(/(^)|($)/,"x") +print "(^)|($) "$0 + +$0=TESTSTR +gsub(/($)|(^)/,"x") +print "($)|(^) "$0 + +$0=TESTSTR +gsub(/2/,"x") +print "(2) "$0 + +$0=TESTSTR +gsub(/(^)|2/,"x") +print "(^)|2 "$0 + +$0=TESTSTR +gsub(/2|(^)/,"x") +print "2|(^) "$0 + +$0=TESTSTR +gsub(/($)|2/,"x") +print "($)|2 "$0 + +$0=TESTSTR +gsub(/2|($)/,"x") +print "2|($) "$0 + +$0=TESTSTR +gsub(/(2)|(^)/,"x") +print "(2)|(^) "$0 + +$0=TESTSTR +gsub(/(^)|(2)/,"x") +print "(^)|(2) "$0 + +$0=TESTSTR +gsub(/(2)|($)/,"x") +print "(2)|($) "$0 + +$0=TESTSTR +gsub(/($)|(2)/,"x") +print "($)|(2) "$0 + +$0=TESTSTR +gsub(/.((2)|(^))/,"x") +print ".((2)|(^)) "$0 + +$0=TESTSTR +gsub(/.((^)|(2))/,"x") +print ".((^)|(2)) "$0 + +$0=TESTSTR +gsub(/.((2)|($))/,"x") +print ".((2)|($)) "$0 + +$0=TESTSTR +gsub(/.(($)|(2))/,"x") +print ".(($)|(2)) "$0 + +# $0=TESTSTR +# gsub(/x{0}((2)|(^))/,"x") +# print "x{0}((2)|(^)) "$0 +# +# $0=TESTSTR +# gsub(/x{0}((^)|(2))/,"x") +# print "x{0}((^)|(2)) "$0 +# +# $0=TESTSTR +# gsub(/x{0}((2)|($))/,"x") +# print "x{0}((2)|($)) "$0 +# +# $0=TESTSTR +# gsub(/x{0}(($)|(2))/,"x") +# print "x{0}(($)|(2)) "$0 + +$0=TESTSTR +gsub(/x*((2)|(^))/,"x") +print "x*((2)|(^)) "$0 + +$0=TESTSTR +gsub(/x*((^)|(2))/,"x") +print "x*((^)|(2)) "$0 + +$0=TESTSTR +gsub(/x*((2)|($))/,"x") +print "x*((2)|($)) "$0 + +$0=TESTSTR +gsub(/x*(($)|(2))/,"x") +print "x*(($)|(2)) "$0 + +# $0=TESTSTR +# gsub(/x{0}^/,"x") +# print "x{0}^ "$0 +# +# $0=TESTSTR +# gsub(/x{0}$/,"x") +# print "x{0}$ "$0 +# +# $0=TESTSTR +# gsub(/(x{0}^)|2/,"x") +# print "(x{0}^)|2 "$0 +# +# $0=TESTSTR +# gsub(/(x{0}$)|2/,"x") +# print "(x{0}$)|2 "$0 + + +} +# +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +#byefrom +# +#-- +#laura fairhead # laura@madonnaweb.com http://lf.8k.com +# # if you are bored crack my sig. +#1F8B0808CABB793C0000666667002D8E410E83300C04EF91F2877D00CA138A7A +#EAA98F30C494480157B623C4EF1B508FDED1CEFA9152A23DE35D661593C5318E +#630C313CD701BE92E390563326EE17A3CA818F5266E4C2461547F1F5267659CA +#8EE2092F76C329ED02CA430C5373CC62FF94BAC6210B36D9F9BC4AB53378D978 +#80F2978A1A6E5D6F5133B67B6113178DC1059526698AFE5C17A5187E7D930492 diff --git a/test/gsubtst2.ok b/test/gsubtst2.ok new file mode 100644 index 0000000..a038528 --- /dev/null +++ b/test/gsubtst2.ok @@ -0,0 +1,25 @@ +input 12345 +output gsub(/regex/,"x",input) + +regex output +(^) x12345 +($) 12345x +(^)|($) x12345x +($)|(^) x12345x +(2) 1x345 +(^)|2 x1x345 +2|(^) x1x345 +($)|2 1x345x +2|($) 1x345x +(2)|(^) x1x345 +(^)|(2) x1x345 +(2)|($) 1x345x +($)|(2) 1x345x +.((2)|(^)) x345 +.((^)|(2)) x345 +.((2)|($)) x34x +.(($)|(2)) x34x +x*((2)|(^)) x1x345 +x*((^)|(2)) x1x345 +x*((2)|($)) 1x345x +x*(($)|(2)) 1x345x diff --git a/test/gsubtst3.awk b/test/gsubtst3.awk new file mode 100644 index 0000000..1c4f4ea --- /dev/null +++ b/test/gsubtst3.awk @@ -0,0 +1,290 @@ +# From laura_fairhead@talk21.com Fri May 10 11:24:41 2002 +# Return-Path: +# Received: from localhost (aahz [127.0.0.1]) +# by skeeve.com (8.11.2/8.11.2) with ESMTP id g4A8OdU01822 +# for ; Fri, 10 May 2002 11:24:40 +0300 +# Received: from actcom.co.il [192.114.47.1] +# by localhost with POP3 (fetchmail-5.7.4) +# for arnold@localhost (single-drop); Fri, 10 May 2002 11:24:40 +0300 (IDT) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Fri May 10 11:30:42 2002) +# X-From_: laura_fairhead@talk21.com Fri May 10 05:39:57 2002 +# Received: from lmail.actcom.co.il by actcom.co.il with ESMTP +# (8.11.6/actcom-0.2) id g4A2dpw26380 for ; +# Fri, 10 May 2002 05:39:52 +0300 (EET DST) +# (rfc931-sender: mail.actcom.co.il [192.114.47.13]) +# Received: from f7.net (consort.superb.net [209.61.216.22]) +# by lmail.actcom.co.il (8.11.6/8.11.6) with ESMTP id g4A2dxl10851 +# for ; Fri, 10 May 2002 05:39:59 +0300 +# Received: from fencepost.gnu.org (fencepost.gnu.org [199.232.76.164]) +# by f7.net (8.11.6/8.11.6) with ESMTP id g4A2dwN11097 +# for ; Thu, 9 May 2002 22:39:58 -0400 +# Received: from [194.73.242.6] (helo=wmpmta04-app.mail-store.com) +# by fencepost.gnu.org with smtp (Exim 3.34 #1 (Debian)) +# id 1760K4-0001QX-00 +# for ; Thu, 09 May 2002 22:39:56 -0400 +# Received: from wmpmtavirtual ([10.216.84.15]) +# by wmpmta04-app.mail-store.com +# (InterMail vM.5.01.02.00 201-253-122-103-101-20001108) with SMTP +# id <20020510023921.EEW24107.wmpmta04-app.mail-store.com@wmpmtavirtual> +# for ; Fri, 10 May 2002 03:39:21 +0100 +# Received: from 213.1.102.243 by t21web05-lrs ([10.216.84.15]); Fri, 10 May 02 03:38:42 GMT+01:00 +# X-Mailer: talk21 v1.24 - http://talk21.btopenworld.com +# From: laura_fairhead@talk21.com +# To: bug-gawk@gnu.org +# X-Talk21Ref: none +# Date: Fri, 10 May 2002 03:38:42 GMT+01:00 +# Subject: bug in gawk 3.1.0 regex code +# Mime-Version: 1.0 +# Content-type: multipart/mixed; boundary="--GgOuLpDpIyE--1020998322088--" +# Message-Id: <20020510023921.EEW24107.wmpmta04-app.mail-store.com@wmpmtavirtual> +# X-SpamBouncer: 1.4 (10/07/01) +# X-SBClass: OK +# Status: RO +# +# Multipart Message Boundary - attachment/bodypart follows: +# +# +# ----GgOuLpDpIyE--1020998322088-- +# Content-Type: text/plain +# Content-Transfer-Encoding: 7bit +# +# +# I believe I've just found a bug in gawk3.1.0 implementation of +# extended regular expressions. It seems to be down to the alternation +# operator; when using an end anchor '$' as a subexpression in an +# alternation and the entire matched RE is a nul-string it fails +# to match the end of string, for example; +# +# gsub(/$|2/,"x") +# print +# +# input = 12345 +# expected output = 1x345x +# actual output = 1x345 +# +# The start anchor '^' always works as expected; +# +# gsub(/^|2/,"x") +# print +# +# input = 12345 +# expected output = x1x345 +# actual output = x1x345 +# +# This was with POSIX compliance enabled althought that doesn't +# effect the result. +# +# I checked on gawk3.0.6 and got exactly the same results however +# gawk2.15.6 gives the expected results. +# +# All the follow platforms produced the same results; +# +# gawk3.0.6 / Win98 / i386 +# gawk3.1.0 / Win98 / i386 +# gawk3.0.5 / Linux2.2.16 / i386 +# +# Complete test results were as follows; +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# regex input expected actual bug? +# ------------------------------------------------------------- +# (^) 12345 x12345 x12345 +# ($) 12345 12345x 12345x +# (^)|($) 12345 x12345x x12345x +# ($)|(^) 12345 x12345x x12345x +# 2 12345 1x345 1x345 +# (^)|2 12345 x1x345 x1x345 +# 2|(^) 12345 x1x345 x1x345 +# ($)|2 12345 1x345x 1x345 **BUG** +# 2|($) 12345 1x345x 1x345 **BUG** +# (2)|(^) 12345 x1x345 x1x345 +# (^)|(2) 12345 x1x345 x1x345 +# (2)|($) 12345 1x345x 1x345 **BUG** +# ($)|(2) 12345 1x345x 1x345 **BUG** +# ((2)|(^)). 12345 xx45 xx45 +# ((^)|(2)). 12345 xx45 xx45 +# .((2)|($)) 12345 x34x x34x +# .(($)|(2)) 12345 x34x x34x +# (^)|6 12345 x12345 x12345 +# 6|(^) 12345 x12345 x12345 +# ($)|6 12345 12345x 12345x +# 6|($) 12345 12345x 12345x +# 2|6|(^) 12345 x1x345 x1x345 +# 2|(^)|6 12345 x1x345 x1x345 +# 6|2|(^) 12345 x1x345 x1x345 +# 6|(^)|2 12345 x1x345 x1x345 +# (^)|6|2 12345 x1x345 x1x345 +# (^)|2|6 12345 x1x345 x1x345 +# 2|6|($) 12345 1x345x 1x345 **BUG** +# 2|($)|6 12345 1x345x 1x345 **BUG** +# 6|2|($) 12345 1x345x 1x345 **BUG** +# 6|($)|2 12345 1x345x 1x345 **BUG** +# ($)|6|2 12345 1x345x 1x345 **BUG** +# ($)|2|6 12345 1x345x 1x345 **BUG** +# 2|4|(^) 12345 x1x3x5 x1x3x5 +# 2|(^)|4 12345 x1x3x5 x1x3x5 +# 4|2|(^) 12345 x1x3x5 x1x3x5 +# 4|(^)|2 12345 x1x3x5 x1x3x5 +# (^)|4|2 12345 x1x3x5 x1x3x5 +# (^)|2|4 12345 x1x3x5 x1x3x5 +# 2|4|($) 12345 1x3x5x 1x3x5 **BUG** +# 2|($)|4 12345 1x3x5x 1x3x5 **BUG** +# 4|2|($) 12345 1x3x5x 1x3x5 **BUG** +# 4|($)|2 12345 1x3x5x 1x3x5 **BUG** +# ($)|4|2 12345 1x3x5x 1x3x5 **BUG** +# ($)|2|4 12345 1x3x5x 1x3x5 **BUG** +# x{0}((2)|(^)) 12345 x1x345 x1x345 +# x{0}((^)|(2)) 12345 x1x345 x1x345 +# x{0}((2)|($)) 12345 1x345x 1x345 **BUG** +# x{0}(($)|(2)) 12345 1x345x 1x345 **BUG** +# x*((2)|(^)) 12345 x1x345 x1x345 +# x*((^)|(2)) 12345 x1x345 x1x345 +# x*((2)|($)) 12345 1x345x 1x345 **BUG** +# x*(($)|(2)) 12345 1x345x 1x345 **BUG** +# x{0}^ 12345 x12345 x12345 +# x{0}$ 12345 12345x 12345x +# (x{0}^)|2 12345 x1x345 x1x345 +# (x{0}$)|2 12345 1x345x 1x345 **BUG** +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# +# Here's the test program I used, a few of the cases use ERE {n[,[m]]} +# operators so need '-W posix', (although the same results minus +# those tests came out without POSIX compliance enabled) +# +# [ Invocation was 'gawk -W posix -f tregex.awk' ] +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# tregex.awk +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +BEGIN{ +print _=sprintf("%-20s%-10s%-10s%-10s%-10s\n","regex","input","expected","actual","bug?") +OFS="-" +$(length(_)+1)="" +print $0 + +while(getline +# +# +# byefrom +# +# Laura Fairhead +# +# +# +# +# -------------------- +# talk21 your FREE portable and private address on the net at http://www.talk21.com +# ----GgOuLpDpIyE--1020998322088-- +# Content-Type: : application/zip;; Name="COPY.ZIP" +# Content-Transfer-Encoding: base64 +# Content-Disposition: attachment; filename="COPY.ZIP" +# +# UEsDBBQAAAAIALoaqiyj8d/bjwMAAKsaAAADAAAARklMrVjfa+JAEH4P5H8ISwrRU9EYfbheKBR6 +# xRcLvevbYbFtzsqJlBrpQr3722+zMWZ31pk1MaG0Q/m+nR87O9kvruM6/5p4XOc9WSTc05/l +# +m2bSivhb8lzmrx43vw53c5X2f+etourHOc63XMe1wlmLQ8+g3AYjaTFD2ZplY9g+xRbWly3 +# NPastYMrQN9cs4DvHYz+dHbomY8SOTctGDlcQfXND1Uz6cK3EXcVdpY37ltSuB55u339cNtu +# F76NPTudHYR0zS2RZ/sd1maHVLdYI/cp31b2PvFW72jkvIi2tLTI94nXY/eCfeZK8Ap7GO1b +# u7QAO8+8FjsLfFx7OowtfW6dLYRv22wZ031uYYc7M/aK5xvEfjp7vDPnQxW2OZuqndDxWeyw +# dt6y5rXPt5xrqG8bW9a8tm8ZN1q1UyYTXvNT2HjN7VWLLL3GR7pl9nlUkx1Z+5xm2/qcYsu4 +# z2KHtfOWNad6jR92jGN9jvm2sSNbn1vYlj4n2TLus9h4zW1s/tn/e3iHV55MOXumvUarsvVX +# +OknNGfrr/AK7DbMulLkbZh1VTa8uFSLHF5cqlVt5tW9eWRsH2VbVY10rp+TCu9Q6Rxj2/Ju +# SJE2KG5TqW57848/jS15fXM7mX66ztv7cp16j/FGGr8DdtEN+5uL7sD49WvNOkwGIv5KaS3+ +# FsJamLmyFkYmrFnLde6+/4hZl7mOH6yS9SJ9DR5bXwatmLHCrd/PivTxulwlwSJJV8t14n1j +# abIRCfde5mm2iojx/ib2B5eTaeyHl3cPP2N/KNbsx5Op6yw226fg/qbDeIbNc/DoHAR6Mu2I +# dTp+X/zEsTCvGPvK9j0govsrfxqqdJN9cKhMY0vilwdPOebmRwqIy4+x+Tni+Hrc/PKAAnGZ +# 7pXH2fyaYK6X4+B9CcPBt/RRt9z8FoDhoOpH/QJ9j+KAkkf9As2O4oA6N/xy6RWo8OMoqLYN +# 1DDipqo+joIqEGtQqDWJRibXK9oO6igMB1Uu2XeKZwwHlSuO0zue6idVGVE4VQPheeiVIc8F +# sV6Bg6oRx+knkup3Kl8VR+Vb5qGru2N14SNTx2E4qNhwnH1/+chUYRROvfvjeejK6khdeLm/ +# +HoFDqolHGfdX17sG5WviqPyLXBQ1WB9D/ULjSvHH9ZXUJOgOKA+UL9AZ1A4dThTftXxTOWh +# qgRs7kI9gF4gwM0fnVfgjo/F19A96T9QSwECFAAUAAAACAC6Gqoso/Hf248DAACrGgAAAwAA +# AAAAAAABACAAAAAAAAAARklMUEsFBgAAAAABAAEAMQAAALADAAAAAA== +# ----GgOuLpDpIyE--1020998322088---- +# +# +# diff --git a/test/gsubtst3.in b/test/gsubtst3.in new file mode 100644 index 0000000..2dcf75a --- /dev/null +++ b/test/gsubtst3.in @@ -0,0 +1,57 @@ +(^) 12345 x12345 +($) 12345 12345x +(^)|($) 12345 x12345x +($)|(^) 12345 x12345x +2 12345 1x345 +(^)|2 12345 x1x345 +2|(^) 12345 x1x345 +($)|2 12345 1x345x +2|($) 12345 1x345x +(2)|(^) 12345 x1x345 +(^)|(2) 12345 x1x345 +(2)|($) 12345 1x345x +($)|(2) 12345 1x345x +((2)|(^)). 12345 xx45 +((^)|(2)). 12345 xx45 +.((2)|($)) 12345 x34x +.(($)|(2)) 12345 x34x +(^)|6 12345 x12345 +6|(^) 12345 x12345 +($)|6 12345 12345x +6|($) 12345 12345x +2|6|(^) 12345 x1x345 +2|(^)|6 12345 x1x345 +6|2|(^) 12345 x1x345 +6|(^)|2 12345 x1x345 +(^)|6|2 12345 x1x345 +(^)|2|6 12345 x1x345 +2|6|($) 12345 1x345x +2|($)|6 12345 1x345x +6|2|($) 12345 1x345x +6|($)|2 12345 1x345x +($)|6|2 12345 1x345x +($)|2|6 12345 1x345x +2|4|(^) 12345 x1x3x5 +2|(^)|4 12345 x1x3x5 +4|2|(^) 12345 x1x3x5 +4|(^)|2 12345 x1x3x5 +(^)|4|2 12345 x1x3x5 +(^)|2|4 12345 x1x3x5 +2|4|($) 12345 1x3x5x +2|($)|4 12345 1x3x5x +4|2|($) 12345 1x3x5x +4|($)|2 12345 1x3x5x +($)|4|2 12345 1x3x5x +($)|2|4 12345 1x3x5x +x{0}((2)|(^)) 12345 x1x345 +x{0}((^)|(2)) 12345 x1x345 +x{0}((2)|($)) 12345 1x345x +x{0}(($)|(2)) 12345 1x345x +x*((2)|(^)) 12345 x1x345 +x*((^)|(2)) 12345 x1x345 +x*((2)|($)) 12345 1x345x +x*(($)|(2)) 12345 1x345x +x{0}^ 12345 x12345 +x{0}$ 12345 12345x +(x{0}^)|2 12345 x1x345 +(x{0}$)|2 12345 1x345x diff --git a/test/gsubtst3.ok b/test/gsubtst3.ok new file mode 100644 index 0000000..190a20a --- /dev/null +++ b/test/gsubtst3.ok @@ -0,0 +1,60 @@ +regex input expected actual bug? + +------------------------------------------------------------- +(^) 12345 x12345 x12345 +($) 12345 12345x 12345x +(^)|($) 12345 x12345x x12345x +($)|(^) 12345 x12345x x12345x +2 12345 1x345 1x345 +(^)|2 12345 x1x345 x1x345 +2|(^) 12345 x1x345 x1x345 +($)|2 12345 1x345x 1x345x +2|($) 12345 1x345x 1x345x +(2)|(^) 12345 x1x345 x1x345 +(^)|(2) 12345 x1x345 x1x345 +(2)|($) 12345 1x345x 1x345x +($)|(2) 12345 1x345x 1x345x +((2)|(^)). 12345 xx45 xx45 +((^)|(2)). 12345 xx45 xx45 +.((2)|($)) 12345 x34x x34x +.(($)|(2)) 12345 x34x x34x +(^)|6 12345 x12345 x12345 +6|(^) 12345 x12345 x12345 +($)|6 12345 12345x 12345x +6|($) 12345 12345x 12345x +2|6|(^) 12345 x1x345 x1x345 +2|(^)|6 12345 x1x345 x1x345 +6|2|(^) 12345 x1x345 x1x345 +6|(^)|2 12345 x1x345 x1x345 +(^)|6|2 12345 x1x345 x1x345 +(^)|2|6 12345 x1x345 x1x345 +2|6|($) 12345 1x345x 1x345x +2|($)|6 12345 1x345x 1x345x +6|2|($) 12345 1x345x 1x345x +6|($)|2 12345 1x345x 1x345x +($)|6|2 12345 1x345x 1x345x +($)|2|6 12345 1x345x 1x345x +2|4|(^) 12345 x1x3x5 x1x3x5 +2|(^)|4 12345 x1x3x5 x1x3x5 +4|2|(^) 12345 x1x3x5 x1x3x5 +4|(^)|2 12345 x1x3x5 x1x3x5 +(^)|4|2 12345 x1x3x5 x1x3x5 +(^)|2|4 12345 x1x3x5 x1x3x5 +2|4|($) 12345 1x3x5x 1x3x5x +2|($)|4 12345 1x3x5x 1x3x5x +4|2|($) 12345 1x3x5x 1x3x5x +4|($)|2 12345 1x3x5x 1x3x5x +($)|4|2 12345 1x3x5x 1x3x5x +($)|2|4 12345 1x3x5x 1x3x5x +x{0}((2)|(^)) 12345 x1x345 x1x345 +x{0}((^)|(2)) 12345 x1x345 x1x345 +x{0}((2)|($)) 12345 1x345x 1x345x +x{0}(($)|(2)) 12345 1x345x 1x345x +x*((2)|(^)) 12345 x1x345 x1x345 +x*((^)|(2)) 12345 x1x345 x1x345 +x*((2)|($)) 12345 1x345x 1x345x +x*(($)|(2)) 12345 1x345x 1x345x +x{0}^ 12345 x12345 x12345 +x{0}$ 12345 12345x 12345x +(x{0}^)|2 12345 x1x345 x1x345 +(x{0}$)|2 12345 1x345x 1x345x diff --git a/test/gsubtst4.awk b/test/gsubtst4.awk new file mode 100644 index 0000000..48b8413 --- /dev/null +++ b/test/gsubtst4.awk @@ -0,0 +1,242 @@ +# From arnold Thu May 9 17:27:03 2002 +# Return-Path: +# Received: (from arnold@localhost) +# by skeeve.com (8.11.6/8.11.6) id g49ER3K27925 +# for arnold; Thu, 9 May 2002 17:27:03 +0300 +# Date: Thu, 9 May 2002 17:27:03 +0300 +# From: Aharon Robbins +# Message-Id: <200205091427.g49ER3K27925@skeeve.com> +# To: arnold@skeeve.com +# Subject: fixme +# X-SpamBouncer: 1.4 (10/07/01) +# X-SBRule: Pattern Match (Other Patterns) (Score: 4850) +# X-SBRule: Pattern Match (Spam Phone #) (Score: 0) +# X-SBClass: Blocked +# Status: RO +# +# Path: ord-read.news.verio.net!dfw-artgen!iad-peer.news.verio.net!news.verio.net!fu-berlin.de!uni-berlin.de!host213-120-137-48.in-addr.btopenworld.COM!not-for-mail +# From: laura@madonnaweb.com (laura fairhead) +# Newsgroups: comp.lang.awk +# Subject: bug in gawk3.1.0 regex code +# Date: Wed, 08 May 2002 23:31:40 GMT +# Organization: that'll be the daewooo :) +# Lines: 211 +# Message-ID: <3cd9b0f7.29675926@NEWS.CIS.DFN.DE> +# Reply-To: laura@madonnaweb.com +# NNTP-Posting-Host: host213-120-137-48.in-addr.btopenworld.com (213.120.137.48) +# X-Trace: fu-berlin.de 1020900891 18168286 213.120.137.48 (16 [53286]) +# X-Newsreader: Forte Free Agent 1.21/32.243 +# Xref: dfw-artgen comp.lang.awk:13059 +# +# +# I believe I've just found a bug in gawk3.1.0 implementation of +# extended regular expressions. It seems to be down to the alternation +# operator; when using an end anchor '$' as a subexpression in an +# alternation and the entire matched RE is a nul-string it fails +# to match the end of string, for example; +# +# gsub(/$|2/,"x") +# print +# +# input = 12345 +# expected output = 1x345x +# actual output = 1x345 +# +# The start anchor '^' always works as expected; +# +# gsub(/^|2/,"x") +# print +# +# input = 12345 +# expected output = x1x345 +# actual output = x1x345 +# +# This was with POSIX compliance enabled althought that doesn't +# effect the result. +# +# I checked on gawk3.0.6 and got exactly the same results however +# gawk2.15.6 gives the expected results. +# +# I'm about to post a bug report about this into gnu.utils.bug +# but I thought I'd post it here first in case anyone has +# any input/comments/whatever .... +# +# Complete test results were as follows; +# +# input 12345 +# output gsub(/regex/,"x",input) +# +# regex output +# (^) x12345 +# ($) 12345x +# (^)|($) x12345x +# ($)|(^) x12345x +# (2) 1x345 +# (^)|2 x1x345 +# 2|(^) x1x345 +# ($)|2 1x345 +# 2|($) 1x345 +# (2)|(^) x1x345 +# (^)|(2) x1x345 +# (2)|($) 1x345 +# ($)|(2) 1x345 +# .((2)|(^)) x345 +# .((^)|(2)) x345 +# .((2)|($)) x34x +# .(($)|(2)) x34x +# x{0}((2)|(^)) x1x345 +# x{0}((^)|(2)) x1x345 +# x{0}((2)|($)) 1x345 +# x{0}(($)|(2)) 1x345 +# x*((2)|(^)) x1x345 +# x*((^)|(2)) x1x345 +# x*((2)|($)) 1x345 +# x*(($)|(2)) 1x345 +# +# Here's the test program I used, a few of the cases use ERE {n[,[m]]} +# operators so that will have to be commented out or have a check +# added or something (should have put a conditional in I know... ;-) +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +BEGIN{ + +TESTSTR="12345" + +print "input "TESTSTR +print "output gsub(/regex/,\"x\",input)" +print "" + +print "regex output" +$0=TESTSTR +gsub(/(^)/,"x") +print "(^) "$0 + +$0=TESTSTR +gsub(/($)/,"x") +print "($) "$0 + +$0=TESTSTR +gsub(/(^)|($)/,"x") +print "(^)|($) "$0 + +$0=TESTSTR +gsub(/($)|(^)/,"x") +print "($)|(^) "$0 + +$0=TESTSTR +gsub(/2/,"x") +print "(2) "$0 + +$0=TESTSTR +gsub(/(^)|2/,"x") +print "(^)|2 "$0 + +$0=TESTSTR +gsub(/2|(^)/,"x") +print "2|(^) "$0 + +$0=TESTSTR +gsub(/($)|2/,"x") +print "($)|2 "$0 + +$0=TESTSTR +gsub(/2|($)/,"x") +print "2|($) "$0 + +$0=TESTSTR +gsub(/(2)|(^)/,"x") +print "(2)|(^) "$0 + +$0=TESTSTR +gsub(/(^)|(2)/,"x") +print "(^)|(2) "$0 + +$0=TESTSTR +gsub(/(2)|($)/,"x") +print "(2)|($) "$0 + +$0=TESTSTR +gsub(/($)|(2)/,"x") +print "($)|(2) "$0 + +$0=TESTSTR +gsub(/.((2)|(^))/,"x") +print ".((2)|(^)) "$0 + +$0=TESTSTR +gsub(/.((^)|(2))/,"x") +print ".((^)|(2)) "$0 + +$0=TESTSTR +gsub(/.((2)|($))/,"x") +print ".((2)|($)) "$0 + +$0=TESTSTR +gsub(/.(($)|(2))/,"x") +print ".(($)|(2)) "$0 + +$0=TESTSTR +gsub(/x{0}((2)|(^))/,"x") +print "x{0}((2)|(^)) "$0 + +$0=TESTSTR +gsub(/x{0}((^)|(2))/,"x") +print "x{0}((^)|(2)) "$0 + +$0=TESTSTR +gsub(/x{0}((2)|($))/,"x") +print "x{0}((2)|($)) "$0 + +$0=TESTSTR +gsub(/x{0}(($)|(2))/,"x") +print "x{0}(($)|(2)) "$0 + +$0=TESTSTR +gsub(/x*((2)|(^))/,"x") +print "x*((2)|(^)) "$0 + +$0=TESTSTR +gsub(/x*((^)|(2))/,"x") +print "x*((^)|(2)) "$0 + +$0=TESTSTR +gsub(/x*((2)|($))/,"x") +print "x*((2)|($)) "$0 + +$0=TESTSTR +gsub(/x*(($)|(2))/,"x") +print "x*(($)|(2)) "$0 + +$0=TESTSTR +gsub(/x{0}^/,"x") +print "x{0}^ "$0 + +$0=TESTSTR +gsub(/x{0}$/,"x") +print "x{0}$ "$0 + +$0=TESTSTR +gsub(/(x{0}^)|2/,"x") +print "(x{0}^)|2 "$0 + +$0=TESTSTR +gsub(/(x{0}$)|2/,"x") +print "(x{0}$)|2 "$0 + + +} +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# byefrom +# +# -- +# laura fairhead # laura@madonnaweb.com http://lf.8k.com +# # if you are bored crack my sig. +# 1F8B0808CABB793C0000666667002D8E410E83300C04EF91F2877D00CA138A7A +# EAA98F30C494480157B623C4EF1B508FDED1CEFA9152A23DE35D661593C5318E +# 630C313CD701BE92E390563326EE17A3CA818F5266E4C2461547F1F5267659CA +# 8EE2092F76C329ED02CA430C5373CC62FF94BAC6210B36D9F9BC4AB53378D978 +# 80F2978A1A6E5D6F5133B67B6113178DC1059526698AFE5C17A5187E7D930492 +# diff --git a/test/gsubtst4.ok b/test/gsubtst4.ok new file mode 100644 index 0000000..71bf8dc --- /dev/null +++ b/test/gsubtst4.ok @@ -0,0 +1,33 @@ +input 12345 +output gsub(/regex/,"x",input) + +regex output +(^) x12345 +($) 12345x +(^)|($) x12345x +($)|(^) x12345x +(2) 1x345 +(^)|2 x1x345 +2|(^) x1x345 +($)|2 1x345x +2|($) 1x345x +(2)|(^) x1x345 +(^)|(2) x1x345 +(2)|($) 1x345x +($)|(2) 1x345x +.((2)|(^)) x345 +.((^)|(2)) x345 +.((2)|($)) x34x +.(($)|(2)) x34x +x{0}((2)|(^)) x1x345 +x{0}((^)|(2)) x1x345 +x{0}((2)|($)) 1x345x +x{0}(($)|(2)) 1x345x +x*((2)|(^)) x1x345 +x*((^)|(2)) x1x345 +x*((2)|($)) 1x345x +x*(($)|(2)) 1x345x +x{0}^ x12345 +x{0}$ 12345x +(x{0}^)|2 x1x345 +(x{0}$)|2 1x345x diff --git a/test/gsubtst5.awk b/test/gsubtst5.awk new file mode 100644 index 0000000..4bef854 --- /dev/null +++ b/test/gsubtst5.awk @@ -0,0 +1,97 @@ +# From jose@monkey.org Thu Jun 5 11:48:35 2003 +# Return-Path: +# Received: from localhost (skeeve [127.0.0.1]) +# by skeeve.com (8.12.5/8.12.5) with ESMTP id h558eVvA012655 +# for ; Thu, 5 Jun 2003 11:48:35 +0300 +# Received: from actcom.co.il [192.114.47.1] +# by localhost with POP3 (fetchmail-5.9.0) +# for arnold@localhost (single-drop); Thu, 05 Jun 2003 11:48:35 +0300 (IDT) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Thu Jun 5 11:47:59 2003) +# X-From_: jose@monkey.org Thu Jun 5 07:14:45 2003 +# Received: from smtp1.actcom.net.il by actcom.co.il with ESMTP +# (8.11.6/actcom-0.2) id h554EdY08108 for ; +# Thu, 5 Jun 2003 07:14:41 +0300 (EET DST) +# (rfc931-sender: smtp.actcom.co.il [192.114.47.13]) +# Received: from f7.net (consort.superb.net [209.61.216.22]) +# by smtp1.actcom.net.il (8.12.8/8.12.8) with ESMTP id h554G3To008304 +# for ; Thu, 5 Jun 2003 07:16:05 +0300 +# Received: from fencepost.gnu.org (fencepost.gnu.org [199.232.76.164]) +# by f7.net (8.11.7/8.11.6) with ESMTP id h554Ean08172 +# for ; Thu, 5 Jun 2003 00:14:36 -0400 +# Received: from monty-python.gnu.org ([199.232.76.173]) +# by fencepost.gnu.org with esmtp (Exim 4.20) +# id 19Nm96-0001xE-1i +# for arnold@gnu.ai.mit.edu; Thu, 05 Jun 2003 00:14:36 -0400 +# Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) +# id 19Nm8x-0005ge-Dz +# for arnold@gnu.ai.mit.edu; Thu, 05 Jun 2003 00:14:28 -0400 +# Received: from naughty.monkey.org ([66.93.9.164]) +# by monty-python.gnu.org with esmtp (Exim 4.20) +# id 19Nm8w-0005VM-Ko +# for arnold@gnu.ai.mit.edu; Thu, 05 Jun 2003 00:14:26 -0400 +# Received: by naughty.monkey.org (Postfix, from userid 1203) +# id C15511BA97B; Thu, 5 Jun 2003 00:14:19 -0400 (EDT) +# Received: from localhost (localhost [127.0.0.1]) +# by naughty.monkey.org (Postfix) with ESMTP +# id BF9821BA969; Thu, 5 Jun 2003 00:14:19 -0400 (EDT) +# Date: Thu, 5 Jun 2003 00:14:19 -0400 (EDT) +# From: Jose Nazario +# To: bug-gnu-utils@prep.ai.mit.edu, arnold@gnu.ai.mit.edu, +# netbsd-bugs@netbsd.org +# Subject: bug in gawk/gsub() (not present in nawk) +# Message-ID: +# MIME-Version: 1.0 +# Content-Type: TEXT/PLAIN; charset=US-ASCII +# X-Spam-Status: No, hits=-1.2 required=5.0 +# tests=SPAM_PHRASE_00_01,USER_AGENT_PINE +# version=2.41 +# X-Spam-Level: +# X-SpamBouncer: 1.4 (10/07/01) +# X-SBClass: OK +# Status: R +# +# while playing with some tools in data massaging, i had to migrate from an +# openbsd/nawk system to a netbsd/gawk system. i found the folllowing +# behavior, which seems to be a bug. +# +# the following gsub() pattern has a strange effect under gawk which is not +# visible in nawk (at least as compiled on openbsd). the intention is to +# take a string like "This Is a Title: My Title?" and turn it into a +# normalized string: "ThisIsaTitleMyTitle". to do this, i wrote the +# following gross gsub line in an awk script: +# +# gsub(/[\ \"-\/\\:;\[\]\@\?\.\,\$]/, "", $2) +# print $2 +# +# in gawk, as found in netbsd-macppc/1.5.2, this will drop the first letter +# of every word. the resulting string will be "hissitleyitle", while in nawk +# as built on openbsd-3.3 this will get it correct. +# +# any insights? the inconsistency with this relatively naive pattern seems a +# bit odd. (i would up installing nawk built from openbsd sources.) +# +# thanks. sorry i didn't send a better bug report, netbsd folks, i'm not +# much of a netbsd user, and i dont have send-pr set up. yes, this is a +# slightly older version of netbsd and gawk: +# +# $ uname -a +# NetBSD entropy 1.5.2 NetBSD 1.5.2 (GENERIC) #0: Sun Feb 10 02:00:04 EST +# 2002 jose@entropy:/usr/src/sys/arch/macppc/compile/GENERIC macppc +# $ awk --version +# GNU Awk 3.0.3 +# Copyright (C) 1989, 1991-1997 Free Software Foundation. +# +# +# +# thanks. +# +# ___________________________ +# jose nazario, ph.d. jose@monkey.org +# http://monkey.org/~jose/ +# +# +{ + gsub(/[\ \"-\/\\:;\[\]\@\?\.\,\$]/, "") + print +} diff --git a/test/gsubtst5.in b/test/gsubtst5.in new file mode 100644 index 0000000..5d1f1a9 --- /dev/null +++ b/test/gsubtst5.in @@ -0,0 +1 @@ +This Is a Title: My Title? diff --git a/test/gsubtst5.ok b/test/gsubtst5.ok new file mode 100644 index 0000000..b038c8a --- /dev/null +++ b/test/gsubtst5.ok @@ -0,0 +1 @@ +ThisIsaTitleMyTitle diff --git a/test/gsubtst6.awk b/test/gsubtst6.awk new file mode 100644 index 0000000..2b1df51 --- /dev/null +++ b/test/gsubtst6.awk @@ -0,0 +1,24 @@ +# From: "T. X. G." +# Subject: Bug in regular expression \B using DFA +# Date: Wed, 16 Jul 2008 05:23:09 -0700 (PDT) +# To: bug-gawk@gnu.org +# +# ~ gawk --version +# GNU Awk 3.1.6 +# Copyright (C) 1989, 1991-2007 Free Software Foundation. +# +# ...... +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~ LC_ALL=C gawk 'BEGIN{x="abcd";gsub(/\B/,":",x);print x}' +# a:b:cd +# +# ~ LC_ALL=en_US.UTF-8 gawk 'BEGIN{x="abcd";gsub(/\B/,":",x);print x}' +# a:b:c:d +# +# ~ GAWK_NO_DFA=1 gawk 'BEGIN{x="abcd";gsub(/\B/,":",x);print x}' +# a:b:c:d + +BEGIN { x = "abcd"; gsub(/\B/,":",x); print x } diff --git a/test/gsubtst6.ok b/test/gsubtst6.ok new file mode 100644 index 0000000..5b6bb79 --- /dev/null +++ b/test/gsubtst6.ok @@ -0,0 +1 @@ +a:b:c:d diff --git a/test/gsubtst7.awk b/test/gsubtst7.awk new file mode 100644 index 0000000..e649f46 --- /dev/null +++ b/test/gsubtst7.awk @@ -0,0 +1,92 @@ +# From bug-gawk-bounces+arnold=skeeve.com@gnu.org Tue Jul 12 08:18:24 2011 +# Return-Path: +# Received: from localhost (localhost [127.0.0.1]) +# by skeeve.com (8.14.3/8.14.3) with ESMTP id p6C5HArm002260 +# for ; Tue, 12 Jul 2011 08:18:23 +0300 +# X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on sls-af11p1 +# X-Spam-Level: +# X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DNS_FROM_OPENWHOIS, +# RCVD_IN_DNSWL_MED autolearn=ham version=3.2.5 +# X-Envelope-From: bug-gawk-bounces+arnold=skeeve.com@gnu.org +# Received: from server1.f7.net [66.148.120.132] +# by localhost with IMAP (fetchmail-6.3.11) +# for (single-drop); Tue, 12 Jul 2011 08:18:23 +0300 (IDT) +# Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) +# by freefriends.org (8.14.4/8.14.4) with ESMTP id p6BIYi4t032040; +# Mon, 11 Jul 2011 14:34:48 -0400 +# Received: from localhost ([::1]:38787 helo=lists.gnu.org) +# by lists.gnu.org with esmtp (Exim 4.71) +# (envelope-from ) +# id 1QgLJb-0004tM-Eg +# for arnold@skeeve.com; Mon, 11 Jul 2011 14:34:43 -0400 +# Received: from eggs.gnu.org ([140.186.70.92]:54022) +# by lists.gnu.org with esmtp (Exim 4.71) +# (envelope-from ) id 1QgD0R-0004Vi-HZ +# for bug-gawk@gnu.org; Mon, 11 Jul 2011 05:42:24 -0400 +# Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) +# (envelope-from ) id 1QgD0Q-0000SE-8u +# for bug-gawk@gnu.org; Mon, 11 Jul 2011 05:42:23 -0400 +# Received: from moat.camk.edu.pl ([148.81.175.50]:34696) +# by eggs.gnu.org with esmtp (Exim 4.71) +# (envelope-from ) id 1QgD0P-0000Px-V3 +# for bug-gawk@gnu.org; Mon, 11 Jul 2011 05:42:22 -0400 +# Received: from localhost (localhost.localdomain [127.0.0.1]) +# by moat.camk.edu.pl (Postfix) with ESMTP id 72C1D5F004C +# for ; Mon, 11 Jul 2011 11:42:13 +0200 (CEST) +# X-Virus-Scanned: amavisd-new at camk.edu.pl +# Received: from moat.camk.edu.pl ([127.0.0.1]) +# by localhost (liam.camk.edu.pl [127.0.0.1]) (amavisd-new, port 10024) +# with LMTP id oh+-Yw+zHhK6 for ; +# Mon, 11 Jul 2011 11:42:07 +0200 (CEST) +# Received: from gatekeeper.camk.edu.pl (gatekeeper.camk.edu.pl [192.168.1.23]) +# by moat.camk.edu.pl (Postfix) with ESMTP id 89AA55F0046 +# for ; Mon, 11 Jul 2011 11:42:07 +0200 (CEST) +# Received: by gatekeeper.camk.edu.pl (Postfix, from userid 1293) +# id 796C8809FB; Mon, 11 Jul 2011 11:42:07 +0200 (CEST) +# Date: Mon, 11 Jul 2011 11:42:07 +0200 +# From: Kacper Kornet +# To: bug-gawk@gnu.org +# Message-ID: <20110711094207.GA2616@camk.edu.pl> +# MIME-Version: 1.0 +# Content-Type: text/plain; charset=iso-8859-2 +# Content-Disposition: inline +# User-Agent: Mutt/1.5.20 (2009-06-14) +# X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) +# X-Received-From: 148.81.175.50 +# X-Mailman-Approved-At: Mon, 11 Jul 2011 14:34:26 -0400 +# Subject: [bug-gawk] Change in behavior of gsub inside loop +# X-BeenThere: bug-gawk@gnu.org +# X-Mailman-Version: 2.1.14 +# Precedence: list +# List-Id: "Bug reports and all discussion about gawk." +# List-Unsubscribe: , +# +# List-Archive: +# List-Post: +# List-Help: +# List-Subscribe: , +# +# Errors-To: bug-gawk-bounces+arnold=skeeve.com@gnu.org +# Sender: bug-gawk-bounces+arnold=skeeve.com@gnu.org +# Status: R +# +# Hi, +# +# I have observed the following changed behavior between gawk-3.8.1 and +# gakw-4.0.0. While in the former +# +# echo -ne ' aaa' | gawk '{for (c = 1; c <= NF; c++) {gsub("foo", "bar", $c); print}}' +# +# prints: +# +# aaa +# +# the gawk-4.0.0 does not preserve the leading spaces and prints: +# +# aaa +# +# Best regards, +# -- +# Kacper +# +{for (c = 1; c <= NF; c++) {gsub("foo", "bar", $c); print}} diff --git a/test/gsubtst7.in b/test/gsubtst7.in new file mode 100644 index 0000000..88069bf --- /dev/null +++ b/test/gsubtst7.in @@ -0,0 +1 @@ + aaa \ No newline at end of file diff --git a/test/gsubtst7.ok b/test/gsubtst7.ok new file mode 100644 index 0000000..88f42c8 --- /dev/null +++ b/test/gsubtst7.ok @@ -0,0 +1 @@ + aaa diff --git a/test/gsubtst8.awk b/test/gsubtst8.awk new file mode 100644 index 0000000..818b0ea --- /dev/null +++ b/test/gsubtst8.awk @@ -0,0 +1,5 @@ +{ + OFS = " " $2 " " + gsub("foo", "_", OFS) + print $1, $2 +} diff --git a/test/gsubtst8.in b/test/gsubtst8.in new file mode 100644 index 0000000..f2b45c7 --- /dev/null +++ b/test/gsubtst8.in @@ -0,0 +1,2 @@ +a bar b +c foo d diff --git a/test/gsubtst8.ok b/test/gsubtst8.ok new file mode 100644 index 0000000..d3b28cc --- /dev/null +++ b/test/gsubtst8.ok @@ -0,0 +1,2 @@ +a bar bar +c _ foo diff --git a/test/gtlnbufv.awk b/test/gtlnbufv.awk new file mode 100644 index 0000000..ce7d243 --- /dev/null +++ b/test/gtlnbufv.awk @@ -0,0 +1,2 @@ +/@K@CODE/ { print ; getline temp ; print temp ;next } +{print} diff --git a/test/hex.awk b/test/hex.awk new file mode 100644 index 0000000..f9d1ad5 --- /dev/null +++ b/test/hex.awk @@ -0,0 +1,22 @@ +# Test program from Paul Eggert, eggert@cs.ucla.edu, Jan. 14, 2005 + +BEGIN { + e = "1(e)" + ex = "3e2(ex)" + x = "6e5(x)" + + print e+0, x+0 + print 0x + print 0e+x + print 0ex + print 010e2 + print 0e9.3 +} + +# Expected results: +# 1 600000 +# 06e5(x) +# 0600001 +# 03e2(ex) +# 1000 +# 00.3 diff --git a/test/hex.ok b/test/hex.ok new file mode 100644 index 0000000..59714c3 --- /dev/null +++ b/test/hex.ok @@ -0,0 +1,6 @@ +1 600000 +06e5(x) +0600001 +03e2(ex) +1000 +00.3 diff --git a/test/hsprint.awk b/test/hsprint.awk new file mode 100644 index 0000000..facc109 --- /dev/null +++ b/test/hsprint.awk @@ -0,0 +1,71 @@ +# Test which attempts to repeat examples of formatted output +# from "C a reference manual" by Harbison and Steele. +# +# In the second series of outputs formats of a type "%5%" are skipped +# since my old copy of H&S explicitely requires padding ("...%05% will +# print 0000%..."), whereas Standard says "...the complete conversion +# specification shall be %%". +# +# Michal Jaegermann - michal@phys.ualberta.ca + + +BEGIN { + zero = "0"; + alt = "#"; + spc = " "; + plus = "+"; + just = "-"; + value[0] = 45; + value[1] = 45; + value[2] = 45; + value[3] = 12.678; + value[4] = 12.678; + value[5] = 12.678; + value[6] = "zap"; + value[7] = "*"; + value[8] = -3.4567; + value[9] = -3.4567; + value[10]= -3.4567; + value[11]= -3.4567; + oper[0] = "5d"; + oper[1] = "5o"; + oper[2] = "5x"; + oper[3] = "7.2f"; + oper[4] = "10.2e"; + oper[5] = "10.4g"; + oper[6] = "5s"; + oper[7] = "5c"; + oper[8] = "7.1G"; + oper[9] = "7.2f"; + oper[10] = "10.2e"; + oper[11] = "10.4g"; + + + for (r = 0; r < 12; r += 6) { + for (j = 2; j > 0; --j) { + for (p = 2; p > 0; --p) { + for (s = 2; s > 0; --s) { + for (a = 2; a > 0; --a) { + for (z = 2; z > 0; --z) { + fmt = "%" substr(just,j,1) substr(plus,p,1) \ + substr(spc,s,1) substr(alt,a,1) substr(zero,z,1); + fstr = sprintf(\ + "%6s|%s%s|%s%s|%s%s|%s%s|%s%s|%s%s|\n", + "%" fmt, + fmt, oper[r], + fmt, oper[r+1], + fmt, oper[r+2], + fmt, oper[r+3], + fmt, oper[r+4], + fmt, oper[r+5]); + printf(fstr, value[r], value[r+1], + value[r+2], value[r+3], + value[r+4], value[r+5]); + } + } + } + } + } + print ""; + } +} diff --git a/test/hsprint.ok b/test/hsprint.ok new file mode 100644 index 0000000..f0a9e9c --- /dev/null +++ b/test/hsprint.ok @@ -0,0 +1,66 @@ + %| 45| 55| 2d| 12.68| 1.27e+01| 12.68| + %0|00045|00055|0002d|0012.68|001.27e+01|0000012.68| + %#| 45| 055| 0x2d| 12.68| 1.27e+01| 12.68| + %#0|00045|00055|0x02d|0012.68|001.27e+01|0000012.68| + % | 45| 55| 2d| 12.68| 1.27e+01| 12.68| + % 0| 0045|00055|0002d| 012.68| 01.27e+01| 000012.68| + % #| 45| 055| 0x2d| 12.68| 1.27e+01| 12.68| + % #0| 0045|00055|0x02d| 012.68| 01.27e+01| 000012.68| + %+| +45| 55| 2d| +12.68| +1.27e+01| +12.68| + %+0|+0045|00055|0002d|+012.68|+01.27e+01|+000012.68| + %+#| +45| 055| 0x2d| +12.68| +1.27e+01| +12.68| + %+#0|+0045|00055|0x02d|+012.68|+01.27e+01|+000012.68| + %+ | +45| 55| 2d| +12.68| +1.27e+01| +12.68| + %+ 0|+0045|00055|0002d|+012.68|+01.27e+01|+000012.68| + %+ #| +45| 055| 0x2d| +12.68| +1.27e+01| +12.68| +%+ #0|+0045|00055|0x02d|+012.68|+01.27e+01|+000012.68| + %-|45 |55 |2d |12.68 |1.27e+01 |12.68 | + %-0|45 |55 |2d |12.68 |1.27e+01 |12.68 | + %-#|45 |055 |0x2d |12.68 |1.27e+01 |12.68 | + %-#0|45 |055 |0x2d |12.68 |1.27e+01 |12.68 | + %- | 45 |55 |2d | 12.68 | 1.27e+01 | 12.68 | + %- 0| 45 |55 |2d | 12.68 | 1.27e+01 | 12.68 | + %- #| 45 |055 |0x2d | 12.68 | 1.27e+01 | 12.68 | +%- #0| 45 |055 |0x2d | 12.68 | 1.27e+01 | 12.68 | + %-+|+45 |55 |2d |+12.68 |+1.27e+01 |+12.68 | + %-+0|+45 |55 |2d |+12.68 |+1.27e+01 |+12.68 | + %-+#|+45 |055 |0x2d |+12.68 |+1.27e+01 |+12.68 | +%-+#0|+45 |055 |0x2d |+12.68 |+1.27e+01 |+12.68 | + %-+ |+45 |55 |2d |+12.68 |+1.27e+01 |+12.68 | +%-+ 0|+45 |55 |2d |+12.68 |+1.27e+01 |+12.68 | +%-+ #|+45 |055 |0x2d |+12.68 |+1.27e+01 |+12.68 | +%-+ #0|+45 |055 |0x2d |+12.68 |+1.27e+01 |+12.68 | + + %| zap| *| -3| -3.46| -3.46e+00| -3.457| + %0| zap| *|-000003|-003.46|-03.46e+00|-00003.457| + %#| zap| *| -3.| -3.46| -3.46e+00| -3.457| + %#0| zap| *|-00003.|-003.46|-03.46e+00|-00003.457| + % | zap| *| -3| -3.46| -3.46e+00| -3.457| + % 0| zap| *|-000003|-003.46|-03.46e+00|-00003.457| + % #| zap| *| -3.| -3.46| -3.46e+00| -3.457| + % #0| zap| *|-00003.|-003.46|-03.46e+00|-00003.457| + %+| zap| *| -3| -3.46| -3.46e+00| -3.457| + %+0| zap| *|-000003|-003.46|-03.46e+00|-00003.457| + %+#| zap| *| -3.| -3.46| -3.46e+00| -3.457| + %+#0| zap| *|-00003.|-003.46|-03.46e+00|-00003.457| + %+ | zap| *| -3| -3.46| -3.46e+00| -3.457| + %+ 0| zap| *|-000003|-003.46|-03.46e+00|-00003.457| + %+ #| zap| *| -3.| -3.46| -3.46e+00| -3.457| +%+ #0| zap| *|-00003.|-003.46|-03.46e+00|-00003.457| + %-|zap |* |-3 |-3.46 |-3.46e+00 |-3.457 | + %-0|zap |* |-3 |-3.46 |-3.46e+00 |-3.457 | + %-#|zap |* |-3. |-3.46 |-3.46e+00 |-3.457 | + %-#0|zap |* |-3. |-3.46 |-3.46e+00 |-3.457 | + %- |zap |* |-3 |-3.46 |-3.46e+00 |-3.457 | + %- 0|zap |* |-3 |-3.46 |-3.46e+00 |-3.457 | + %- #|zap |* |-3. |-3.46 |-3.46e+00 |-3.457 | +%- #0|zap |* |-3. |-3.46 |-3.46e+00 |-3.457 | + %-+|zap |* |-3 |-3.46 |-3.46e+00 |-3.457 | + %-+0|zap |* |-3 |-3.46 |-3.46e+00 |-3.457 | + %-+#|zap |* |-3. |-3.46 |-3.46e+00 |-3.457 | +%-+#0|zap |* |-3. |-3.46 |-3.46e+00 |-3.457 | + %-+ |zap |* |-3 |-3.46 |-3.46e+00 |-3.457 | +%-+ 0|zap |* |-3 |-3.46 |-3.46e+00 |-3.457 | +%-+ #|zap |* |-3. |-3.46 |-3.46e+00 |-3.457 | +%-+ #0|zap |* |-3. |-3.46 |-3.46e+00 |-3.457 | + diff --git a/test/icasefs.awk b/test/icasefs.awk new file mode 100644 index 0000000..86481d8 --- /dev/null +++ b/test/icasefs.awk @@ -0,0 +1,43 @@ +BEGIN { + # 1. Should print aCa + IGNORECASE = 1 + FS = "[c]" + IGNORECASE = 0 + $0 = "aCa" + print $1 + + # 2. Should print a + IGNORECASE = 1 + FS = "[c]" + $0 = "aCa" + print $1 + + # 3. Should print a + IGNORECASE = 1 + FS = "C" + IGNORECASE = 0 + $0 = "aCa" + print $1 + + # 4. Should print aCa + IGNORECASE = 1 + FS = "c" + $0 = "aCa" + print $1 + + # 5. Should print aCa + FS = "xy" + IGNORECASE = 0 + FS = "c" + IGNORECASE = 1 + $0 = "aCa" + print $1 + + # 6. Should print aCa + FS = "xy" + IGNORECASE = 0 + FS = "c" + IGNORECASE = 1 + split("aCa",a) + print a[1] +} diff --git a/test/icasefs.ok b/test/icasefs.ok new file mode 100644 index 0000000..658fac7 --- /dev/null +++ b/test/icasefs.ok @@ -0,0 +1,6 @@ +aCa +a +a +aCa +aCa +aCa diff --git a/test/icasers.awk b/test/icasers.awk new file mode 100644 index 0000000..8fdc826 --- /dev/null +++ b/test/icasers.awk @@ -0,0 +1,2 @@ +BEGIN { RS = "[[:upper:]\\n]+" } +{ print ; IGNORECASE = ! IGNORECASE } diff --git a/test/icasers.in b/test/icasers.in new file mode 100644 index 0000000..b347699 --- /dev/null +++ b/test/icasers.in @@ -0,0 +1 @@ +1111AAAA2222bbbb \ No newline at end of file diff --git a/test/icasers.ok b/test/icasers.ok new file mode 100644 index 0000000..4f142ee --- /dev/null +++ b/test/icasers.ok @@ -0,0 +1,2 @@ +1111 +2222 diff --git a/test/igncdym.awk b/test/igncdym.awk new file mode 100644 index 0000000..3119c3e --- /dev/null +++ b/test/igncdym.awk @@ -0,0 +1,56 @@ +#From Jeffrey.B.Woodward@Hitchcock.ORG Mon Feb 21 09:33:32 2000 +#Message-id: <12901034@mailbox2.Hitchcock.ORG> +#Date: 20 Feb 2000 18:14:11 EST +#From: Jeffrey.B.Woodward@Hitchcock.ORG (Jeffrey B. Woodward) +#Subject: gawk 3.0.4 bug +#To: bug-gnu-utils@gnu.org +#Cc: arnold@gnu.org +# +#O/S: Digital UNIX 4.0D +# +#C Compiler: DEC C +# +#gawk version: 3.0.4 +# +#Sample Program: +#gawk ' + BEGIN { + pattern[1] = "bar" ; ignore[1] = 1 + pattern[2] = "foo" ; ignore[2] = 0 + } + + { + for (i = 1 ; i <= 2 ; i++) { + IGNORECASE = ignore[i] + print match($0, pattern[i]) " " pattern[i] ":" $0 + } + } +#' << -EOF- +#This is foo +#This is bar +#-EOF- +# +#Program Output: +#0 bar:This is foo +#0 foo:This is foo +#9 bar:This is bar +#9 foo:This is bar +# +# +#**Expected** Output: +#0 bar:This is foo +#9 foo:This is foo +#9 bar:This is bar +#0 foo:This is bar +# +# +#This problem appears to be directly related to IGNORECASE. If +#IGNORECASE remains constant, the program behaves as expected; +#however, switching IGNORECASE seems to causes problems - it is +#almost as though the pattern stored in the variable is treated +#as a constant and the regexp() is not recompiled(?) - just a +#guess... +# +# +#Thanks, +#-Jeff Woodward diff --git a/test/igncdym.in b/test/igncdym.in new file mode 100644 index 0000000..43e361a --- /dev/null +++ b/test/igncdym.in @@ -0,0 +1,2 @@ +This is foo +This is bar diff --git a/test/igncdym.ok b/test/igncdym.ok new file mode 100644 index 0000000..e715a6d --- /dev/null +++ b/test/igncdym.ok @@ -0,0 +1,4 @@ +0 bar:This is foo +9 foo:This is foo +9 bar:This is bar +0 foo:This is bar diff --git a/test/igncfs.awk b/test/igncfs.awk new file mode 100644 index 0000000..5e3c6b6 --- /dev/null +++ b/test/igncfs.awk @@ -0,0 +1,8 @@ +BEGIN { + IGNORECASE=1 + FS="[^[:lower:]]+" +} +{ + for (i=1; i +# To: bug-gawk@gnu.org +# Subject: Internal error in gawk-3.1.3 with character class + +BEGIN { + IGNORECASE = 1 + if ("a" ~ /[[:alnum:]]/) + print "OK" + else + print "NOT OK" +} diff --git a/test/ignrcas2.ok b/test/ignrcas2.ok new file mode 100644 index 0000000..d86bac9 --- /dev/null +++ b/test/ignrcas2.ok @@ -0,0 +1 @@ +OK diff --git a/test/ignrcase.awk b/test/ignrcase.awk new file mode 100644 index 0000000..61d7a83 --- /dev/null +++ b/test/ignrcase.awk @@ -0,0 +1,2 @@ +BEGIN { IGNORECASE = 1 } +{ sub(/y/, ""); print } diff --git a/test/ignrcase.in b/test/ignrcase.in new file mode 100644 index 0000000..aba8e51 --- /dev/null +++ b/test/ignrcase.in @@ -0,0 +1 @@ +xYz diff --git a/test/ignrcase.ok b/test/ignrcase.ok new file mode 100644 index 0000000..d66e95c --- /dev/null +++ b/test/ignrcase.ok @@ -0,0 +1 @@ +xz diff --git a/test/indirectcall.awk b/test/indirectcall.awk new file mode 100644 index 0000000..5cfdd23 --- /dev/null +++ b/test/indirectcall.awk @@ -0,0 +1,130 @@ +# funcptrdemo.awk --- Demonstrate function pointers +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# January 2009 + +# average --- return the average of the values in fields $first - $last + +function average(first, last, sum, i) +{ + sum = 0; + for (i = first; i <= last; i++) + sum += $i + + return sum / (last - first + 1) +} + +# sum --- return the average of the values in fields $first - $last + +function sum(first, last, ret, i) +{ + ret = 0; + for (i = first; i <= last; i++) + ret += $i + + return ret +} + +# For each record, print the class name and the requested statistics + +{ + class_name = $1 + gsub(/_/, " ", class_name) # Replace _ with spaces + + # find start + for (i = 1; i <= NF; i++) { + if ($i == "data:") { + start = i + 1 + break + } + } + + printf("%s:\n", class_name) + for (i = 2; $i != "data:"; i++) { + the_function = $i + printf("\t%s: <%s>\n", $i, @the_function(start, NF) "") + } + print "" +} + +# do_sort --- sort the data in ascending order and print it + +function do_sort(first, last, compare, data, i, retval) +{ + delete data + for (i = 1; first <= last; first++) { + data[i] = $first + i++ + } + + quicksort(data, 1, i-1, compare) + + retval = data[1] + for (i = 2; i in data; i++) + retval = retval " " data[i] + + return retval +} + +# sort --- sort the data in ascending order and print it + +function sort(first, last) +{ + return do_sort(first, last, "num_lt") +} + +# rsort --- sort the data in descending order and print it + +function rsort(first, last) +{ + return do_sort(first, last, "num_ge") +} + +# num_lt --- do a numeric less than comparison + +function num_lt(left, right) +{ + return ((left + 0) < (right + 0)) +} + +# num_ge --- do a numeric greater than or equal to comparison + +function num_ge(left, right) +{ + return ((left + 0) >= (right + 0)) +} + +# quicksort.awk --- Quicksort algorithm, with user-supplied +# comparison function +# +# Arnold Robbins, arnold@skeeve.com, Public Domain +# January 2009 + +# quicksort --- C.A.R. Hoare's quick sort algorithm. See Wikipedia +# or almost any algorithms or computer science text +# +# Adapted from K&R-II, page 110 + +function quicksort(data, left, right, less_than, i, last) +{ + if (left >= right) # do nothing if array contains fewer + return # than two elements + + quicksort_swap(data, left, int((left + right) / 2)) + last = left + for (i = left + 1; i <= right; i++) + if (@less_than(data[i], data[left])) + quicksort_swap(data, ++last, i) + quicksort_swap(data, left, last) + quicksort(data, left, last - 1, less_than) + quicksort(data, last + 1, right, less_than) +} + +# quicksort_swap --- helper function for quicksort, should really be inline + +function quicksort_swap(data, i, j, temp) +{ + temp = data[i] + data[i] = data[j] + data[j] = temp +} diff --git a/test/indirectcall.in b/test/indirectcall.in new file mode 100644 index 0000000..f5de0e2 --- /dev/null +++ b/test/indirectcall.in @@ -0,0 +1,3 @@ +Biology_101 sum average sort rsort data: 87.0 92.4 78.5 94.9 +Chemistry_305 sum average sort rsort data: 75.2 98.3 94.7 88.2 +English_401 sum average sort rsort data: 100.0 95.6 87.1 93.4 diff --git a/test/indirectcall.ok b/test/indirectcall.ok new file mode 100644 index 0000000..d3f281c --- /dev/null +++ b/test/indirectcall.ok @@ -0,0 +1,18 @@ +Biology 101: + sum: <352.8> + average: <88.2> + sort: <78.5 87.0 92.4 94.9> + rsort: <94.9 92.4 87.0 78.5> + +Chemistry 305: + sum: <356.4> + average: <89.1> + sort: <75.2 88.2 94.7 98.3> + rsort: <98.3 94.7 88.2 75.2> + +English 401: + sum: <376.1> + average: <94.025> + sort: <87.1 93.4 95.6 100.0> + rsort: <100.0 95.6 93.4 87.1> + diff --git a/test/inftest.awk b/test/inftest.awk new file mode 100644 index 0000000..a822617 --- /dev/null +++ b/test/inftest.awk @@ -0,0 +1,8 @@ +BEGIN { + k = 0 + x = 100 + # Added k limit test after finding some systems that didn't terminate + # the loop correctly, sigh... + do { k++; y = x ; x *= 1000; print x,y } while ( y < x && k < 1700) + print "loop terminated" +} diff --git a/test/inftest.ok b/test/inftest.ok new file mode 100644 index 0000000..9086ca7 --- /dev/null +++ b/test/inftest.ok @@ -0,0 +1,105 @@ +100000 100 +100000000 100000 +100000000000 100000000 +100000000000000 100000000000 +100000000000000000 100000000000000 +100000000000000000000 100000000000000000 +99999999999999991611392 100000000000000000000 +99999999999999987584860160 99999999999999991611392 +99999999999999991433150857216 99999999999999987584860160 +99999999999999987351763694911488 99999999999999991433150857216 +99999999999999978416622034208423936 99999999999999987351763694911488 +99999999999999978859343891977453174784 99999999999999978416622034208423936 +99999999999999981277195531206711524196352 99999999999999978859343891977453174784 +99999999999999989014320776740338242315878400 99999999999999981277195531206711524196352 +99999999999999984102174700855949311516153479168 99999999999999989014320776740338242315878400 +99999999999999986860582406952576489172979654066176 99999999999999984102174700855949311516153479168 +99999999999999978054446934877508831185257879708893184 99999999999999986860582406952576489172979654066176 +99999999999999987412212025203316576428059584082518999040 99999999999999978054446934877508831185257879708893184 +99999999999999986018415450295152630082077192041996404916224 99999999999999987412212025203316576428059584082518999040 +99999999999999980666236602647803076113504806606389643480924160 99999999999999986018415450295152630082077192041996404916224 +99999999999999975825012428989187159563798798233702140870647611392 99999999999999980666236602647803076113504806606389643480924160 +99999999999999971335279399108653394842078992129280704487622839369728 99999999999999975825012428989187159563798798233702140870647611392 +99999999999999967408259575639813195298814735056613421464603838774247424 99999999999999971335279399108653394842078992129280704487622839369728 +99999999999999970056411870256069142542038397972347690757785041907511984128 99999999999999967408259575639813195298814735056613421464603838774247424 +99999999999999972567252564410741448076354167255414257198727219693125789286400 99999999999999970056411870256069142542038397972347690757785041907511984128 +99999999999999973698536947569070602057895480263592729374358127316211945338568704 99999999999999972567252564410741448076354167255414257198727219693125789286400 +99999999999999976120719655945885896110010116988012672708945321528841504187721187328 99999999999999973698536947569070602057895480263592729374358127316211945338568704 +99999999999999973856084135905232153357980849678363696123425190035433415775017926393856 99999999999999976120719655945885896110010116988012672708945321528841504187721187328 +99999999999999971205813538737655658983034598563985922382199344722004978592608624454926336 99999999999999973856084135905232153357980849678363696123425190035433415775017926393856 +99999999999999975389707388132869751436283080323216967861681212523470671424572109115849965568 99999999999999971205813538737655658983034598563985922382199344722004978592608624454926336 +99999999999999972379113067962648670423437470097331363676661611216816006398674924910108594929664 99999999999999975389707388132869751436283080323216967861681212523470671424572109115849965568 +99999999999999969414835583487354067580020253874920922632950003776417566988560774307532476147302400 99999999999999972379113067962648670423437470097331363676661611216816006398674924910108594929664 +99999999999999966622249050912868528133293762816112494334490172638967005189080435307857566164815183872 99999999999999969414835583487354067580020253874920922632950003776417566988560774307532476147302400 +99999999999999968362880378347121775677131631329985434686086700429684016230704354433915805708681998237696 99999999999999966622249050912868528133293762816112494334490172638967005189080435307857566164815183872 +99999999999999964288808425678149603140240254511229112583149913097811514958423455725153206182008585870901248 99999999999999968362880378347121775677131631329985434686086700429684016230704354433915805708681998237696 +99999999999999968982139315152805545902739120606436395645733092104128636424091051037647720836736356917448802304 99999999999999964288808425678149603140240254511229112583149913097811514958423455725153206182008585870901248 +99999999999999967380149038212122984106472840979272309693704700336639058963809845170982926501255944400227237101568 99999999999999968982139315152805545902739120606436395645733092104128636424091051037647720836736356917448802304 +99999999999999966559930016418493512466784505810164297686266163751684395304145867767250551801489973191409795717922816 99999999999999967380149038212122984106472840979272309693704700336639058963809845170982926501255944400227237101568 +99999999999999958580839372410066012355896381285081556877904079853245427222934695583742010722166605272033725937822466048 99999999999999966559930016418493512466784505810164297686266163751684395304145867767250551801489973191409795717922816 +99999999999999964744616902883383199809977537409440210268672488243000947267704701436097240209969526960208587421285248663552 99999999999999958580839372410066012355896381285081556877904079853245427222934695583742010722166605272033725937822466048 +99999999999999973698435499708622381138622312668787627138462205955970454339251530402644148459414217665561018763215928972804096 99999999999999964744616902883383199809977537409440210268672488243000947267704701436097240209969526960208587421285248663552 +99999999999999969038927015485337257005892808638742964825108028921863830855986242882741442632031065833582205967834822157445103616 99999999999999973698435499708622381138622312668787627138462205955970454339251530402644148459414217665561018763215928972804096 +99999999999999971501552402759992207773332814897718827642591733325954247602754580648099053350606729046973846898142049707859353010176 99999999999999969038927015485337257005892808638742964825108028921863830855986242882741442632031065833582205967834822157445103616 +99999999999999971974376477116725958320681296099442193303548604571539607618134101499047714608573256383945041956761037397538888893857792 99999999999999971501552402759992207773332814897718827642591733325954247602754580648099053350606729046973846898142049707859353010176 +99999999999999961968158199529955173403994504587771180275938657358298495399329094904038179293313627194069297996226940583414097499461255168 99999999999999971974376477116725958320681296099442193303548604571539607618134101499047714608573256383945041956761037397538888893857792 +99999999999999963620798121505576670783782774669698779846950364769001543610951083090052657384091991757042324095515152702392127562019650928640 99999999999999961968158199529955173403994504587771180275938657358298495399329094904038179293313627194069297996226940583414097499461255168 +99999999999999959051579265227378354828144165547185352553017196119889755915458610153359828358707969413334501536203103835841670045058198329622528 99999999999999963620798121505576670783782774669698779846950364769001543610951083090052657384091991757042324095515152702392127562019650928640 +99999999999999949000651624039424488856392748028506927595932797882554670922470130425357587563315085893427279408697133232798530309970250449591205888 99999999999999959051579265227378354828144165547185352553017196119889755915458610153359828358707969413334501536203103835841670045058198329622528 +99999999999999948113397321920763733791300209102720142496272933762293366867916664628678769065514886520635469455372468241633342802321107464319475384320 99999999999999949000651624039424488856392748028506927595932797882554670922470130425357587563315085893427279408697133232798530309970250449591205888 +99999999999999946478010192255648230055321641354709940200579872215827731234563716472240370810369559036705605349404445729917669188222207113866621719937024 99999999999999948113397321920763733791300209102720142496272933762293366867916664628678769065514886520635469455372468241633342802321107464319475384320 +99999999999999941174994859794900356607455139003828857556412504641155163420811223250296124735018310448815699341785471398594311548904172910798168237564493824 99999999999999946478010192255648230055321641354709940200579872215827731234563716472240370810369559036705605349404445729917669188222207113866621719937024 +99999999999999946510014354963832392659989467263634555857239408609611720064878292922562279944578696396604449694432883048689164539589319460636017298848184532992 99999999999999941174994859794900356607455139003828857556412504641155163420811223250296124735018310448815699341785471398594311548904172910798168237564493824 +99999999999999941339618318502970259434219055418702861961123734820753251454399578543040337524341888072347466495524305815225809869759600290050307580026961994448896 99999999999999946510014354963832392659989467263634555857239408609611720064878292922562279944578696396604449694432883048689164539589319460636017298848184532992 +99999999999999936244924684387270937819452376396255450979411565991520333252255420434433659770484396036007906295905408882388258279623991724679211271428480374583328768 99999999999999941339618318502970259434219055418702861961123734820753251454399578543040337524341888072347466495524305815225809869759600290050307580026961994448896 +99999999999999938393087270819114040015608114939367394621582908707281601350665380747521463661052072678153904384780012012657644738335288324478035879665769565830174998528 99999999999999936244924684387270937819452376396255450979411565991520333252255420434433659770484396036007906295905408882388258279623991724679211271428480374583328768 +99999999999999936402865781218259783047588779268187110073864544713098209344824228945072115447009943309125688250630284464918540788778765150873943899767450589406430224187392 99999999999999938393087270819114040015608114939367394621582908707281601350665380747521463661052072678153904384780012012657644738335288324478035879665769565830174998528 +99999999999999932755942024273873371963453979756196963399477041511967210604015516252752299267005165619015879149232552133229875362054559318652887774917983563976477694532517888 99999999999999936402865781218259783047588779268187110073864544713098209344824228945072115447009943309125688250630284464918540788778765150873943899767450589406430224187392 +99999999999999930449370010469988507729535311264848842396946780663816593047475793966409789645392732105835839886983821660858314734516991018179899807013191242951604188717858684928 99999999999999932755942024273873371963453979756196963399477041511967210604015516252752299267005165619015879149232552133229875362054559318652887774917983563976477694532517888 +99999999999999926062929060790372034489260266271016529998992090319447875774239110669868148490692058544771170935690235939685426866834118273051840402906249046168301887374323926171648 99999999999999930449370010469988507729535311264848842396946780663816593047475793966409789645392732105835839886983821660858314734516991018179899807013191242951604188717858684928 +99999999999999932742916262928110023686347842483162394048718371574133692602240984883924588271717248394482781662747380635887994975485943351991473842104185224408145227922919218275680256 99999999999999926062929060790372034489260266271016529998992090319447875774239110669868148490692058544771170935690235939685426866834118273051840402906249046168301887374323926171648 +99999999999999937578305619730709881245839649374381910536023685232697991459255307073630546336657965129832648296622676548394350483652119629822535399195325784877482862571061024201468018688 99999999999999932742916262928110023686347842483162394048718371574133692602240984883924588271717248394482781662747380635887994975485943351991473842104185224408145227922919218275680256 +99999999999999940476708761993653639767353567573372418760219182512524240452181745662269903053828283531977973233064610020242062507278752512846344394977566526684664367671371585724203629805568 99999999999999937578305619730709881245839649374381910536023685232697991459255307073630546336657965129832648296622676548394350483652119629822535399195325784877482862571061024201468018688 +99999999999999943939334382617117116614388861848433079252058069929489999249064530962831054545274423916407588090467239874609462471504703263765454875272083466230310539097875936556698439887355904 99999999999999940476708761993653639767353567573372418760219182512524240452181745662269903053828283531977973233064610020242062507278752512846344394977566526684664367671371585724203629805568 +99999999999999945838831865930559938199048223279323498721866831026796929789068801756281743363439163784437548240813825394719579023308653389983938338747932758781065010280415466156238449989365268480 99999999999999943939334382617117116614388861848433079252058069929489999249064530962831054545274423916407588090467239874609462471504703263765454875272083466230310539097875936556698439887355904 +99999999999999945320142419820435818384997240317928354845311051996492317289611635544950141936825645484474167122425851108694843196896054742184544454321460845295205656016170005273590724564176578019328 99999999999999945838831865930559938199048223279323498721866831026796929789068801756281743363439163784437548240813825394719579023308653389983938338747932758781065010280415466156238449989365268480 +99999999999999945984064910841394691746982498508514139007302449155282221288916808295454591762890948908427294953962458194806505054704181011367768626387344894557105629474404195203379813108418101808988160 99999999999999945320142419820435818384997240317928354845311051996492317289611635544950141936825645484474167122425851108694843196896054742184544454321460845295205656016170005273590724564176578019328 +99999999999999946663921541646856578069655402895673981989181639845883082984205305191971148384781819614555297853455943850984846797099702311011390178582810161001291202295636005691483839777721422169600163840 99999999999999945984064910841394691746982498508514139007302449155282221288916808295454591762890948908427294953962458194806505054704181011367768626387344894557105629474404195203379813108418101808988160 +99999999999999950423256767348738624679507494994913049741780812688629607814472577630949099881189578271160702686495122135388605295849976889520759913602854898331059745767919424966503865648301062435640300273664 99999999999999946663921541646856578069655402895673981989181639845883082984205305191971148384781819614555297853455943850984846797099702311011390178582810161001291202295636005691483839777721422169600163840 +99999999999999952561900806859142633417556685166924608285481675461392075273469070396234334510257103195807332991512965781627187908472355316406090251747591460011994739387707325709626369254675257786987577889259520 99999999999999950423256767348738624679507494994913049741780812688629607814472577630949099881189578271160702686495122135388605295849976889520759913602854898331059745767919424966503865648301062435640300273664 +99999999999999953583887505206514362393179124843789865061564861085069499723208194405671971965000837773131802726604159332043065252957502554000360109335689571620590875005483303878073176311374606605551396952498765824 99999999999999952561900806859142633417556685166924608285481675461392075273469070396234334510257103195807332991512965781627187908472355316406090251747591460011994739387707325709626369254675257786987577889259520 +99999999999999952387871071940561618997707835439092695988754367280903005281456350993484382532249312964925794716623151108470655652097170243947180298855446753006645226008223187712942284395877311531026424700205065568256 99999999999999953583887505206514362393179124843789865061564861085069499723208194405671971965000837773131802726604159332043065252957502554000360109335689571620590875005483303878073176311374606605551396952498765824 +99999999999999949479159106237764547059921659606869180803679246349170090799115867815044165031797604631368783236349339108742555502804842065897846999767496218137529407646886585199343955257387889909781692182626786546286592 99999999999999952387871071940561618997707835439092695988754367280903005281456350993484382532249312964925794716623151108470655652097170243947180298855446753006645226008223187712942284395877311531026424700205065568256 +99999999999999944462702596124645891625322848571590225772913900944379346496098343983932109923650153122211091016053956392579903624277946816512554707950971843053782716275082490927470794772649923189521302964942310388818509824 99999999999999949479159106237764547059921659606869180803679246349170090799115867815044165031797604631368783236349339108742555502804842065897846999767496218137529407646886585199343955257387889909781692182626786546286592 +99999999999999935312685921678317464112614617243241411796797910926041028887394380515983721406389201569507460406235178318299226597844889881633781567677631382901028751212911822975574150048487871891766353031885825877596727934976 99999999999999944462702596124645891625322848571590225772913900944379346496098343983932109923650153122211091016053956392579903624277946816512554707950971843053782716275082490927470794772649923189521302964942310388818509824 +99999999999999925121172612428343793833196719162992122293014542956141676109475130820315172455795108724278546368407554066019724438999593062658631582946511398090887633074892676187328287237126462895417822131010561164466052696899584 99999999999999935312685921678317464112614617243241411796797910926041028887394380515983721406389201569507460406235178318299226597844889881633781567677631382901028751212911822975574150048487871891766353031885825877596727934976 +99999999999999923774577821631960175979503309145679183912127553433409168077915219634719740955742418263179913081344910551912084411817969328125656926899457609130167051788011178598791027428244645758351900112623945543014980252539551744 99999999999999925121172612428343793833196719162992122293014542956141676109475130820315172455795108724278546368407554066019724438999593062658631582946511398090887633074892676187328287237126462895417822131010561164466052696899584 +99999999999999931186235550175255608646231837880969596760529543766528892283620970800236995932032426561066790693337700453560535121425626362995149433782441663569973131191006941326100105416330167280762734901823877923481682986297169281024 99999999999999923774577821631960175979503309145679183912127553433409168077915219634719740955742418263179913081344910551912084411817969328125656926899457609130167051788011178598791027428244645758351900112623945543014980252539551744 +99999999999999926244211122435874988985291364022870835895660198026268224087667591790522792799935051725787428951685205754489270499428632351279379918495257505223505226338851255072206945321576956278656608039592704406906303898336741140987904 99999999999999931186235550175255608646231837880969596760529543766528892283620970800236995932032426561066790693337700453560535121425626362995149433782441663569973131191006941326100105416330167280762734901823877923481682986297169281024 +99999999999999929678212096225067465275407716143698317730906554837786494102684339719558490519152427611330116881884882071101074945341972190277308907403380897537393781938977720492054992564559758894977208190720194118995253024599530065721556992 99999999999999926244211122435874988985291364022870835895660198026268224087667591790522792799935051725787428951685205754489270499428632351279379918495257505223505226338851255072206945321576956278656608039592704406906303898336741140987904 +99999999999999934027464697975758399456742447587676871566873309064753633557492919833469807883112792522366919110954619485992994007787162184258685917355227282413257687305369471221698329872724925324405572508442926352243067328514674943868432023552 99999999999999929678212096225067465275407716143698317730906554837786494102684339719558490519152427611330116881884882071101074945341972190277308907403380897537393781938977720492054992564559758894977208190720194118995253024599530065721556992 +99999999999999931658510089362616103392015444928828978413665885485809829939554629388445771191253529932525597045759188042988033837604250187536914609806987549374489262254739070824275575934660494247950974071555650923069789750211957733643751155302400 99999999999999934027464697975758399456742447587676871566873309064753633557492919833469807883112792522366919110954619485992994007787162184258685917355227282413257687305369471221698329872724925324405572508442926352243067328514674943868432023552 +99999999999999930008959616293112859796224738437420013453224492299319680604311838985766633961978088205967287665322305220594819971902484905979610812934997258464934032523484110419542163912507469600794108087982303296227853106888209685820101373122838528 99999999999999931658510089362616103392015444928828978413665885485809829939554629388445771191253529932525597045759188042988033837604250187536914609806987549374489262254739070824275575934660494247950974071555650923069789750211957733643751155302400 +99999999999999928518542247684432282053204429513417560406613915867290933910821882480757719383056277328324015189821686388126598502656654628054893970584775442678418248483950216783265386932491560272539433881647796263975373880920399684962968393459422986240 99999999999999930008959616293112859796224738437420013453224492299319680604311838985766633961978088205967287665322305220594819971902484905979610812934997258464934032523484110419542163912507469600794108087982303296227853106888209685820101373122838528 +99999999999999928518542247684432282053204429513417560406613915867290933910821882480757719383056277328324015189821686388126598502656654628054893970584775442678418248483950216783265386932491560272539433881647796263975373880920399684962968393459422986240000 99999999999999928518542247684432282053204429513417560406613915867290933910821882480757719383056277328324015189821686388126598502656654628054893970584775442678418248483950216783265386932491560272539433881647796263975373880920399684962968393459422986240 +99999999999999922996592795455802961330827165322375947146110930199429488582670882113664381815329718099637973843065789366637766292469752383803230100767176235502514017647481584860713016397448254045302728360926807035301219893389307418875317674924228479494914048 99999999999999928518542247684432282053204429513417560406613915867290933910821882480757719383056277328324015189821686388126598502656654628054893970584775442678418248483950216783265386932491560272539433881647796263975373880920399684962968393459422986240000 +99999999999999924596916259346967987109991595095477818460852927555247447077772756937033318891561415264781702052238819144940944834893730090816542497755823854789719470206880795923550835480811748076441516979762172970252823766002091894481097203918579189374244618240 99999999999999922996592795455802961330827165322375947146110930199429488582670882113664381815329718099637973843065789366637766292469752383803230100767176235502514017647481584860713016397448254045302728360926807035301219893389307418875317674924228479494914048 +99999999999999917714245105843845444238961215527321290310410545327345571182038613696688194314104132096931555770227452674414634559636686768493688540787048173759306259839416668984497943167082032947319814887875031157212965830669028421795760605619675656325219701751808 99999999999999924596916259346967987109991595095477818460852927555247447077772756937033318891561415264781702052238819144940944834893730090816542497755823854789719470206880795923550835480811748076441516979762172970252823766002091894481097203918579189374244618240 +99999999999999917154891513686131358215156841822734601038501577120887513966385299198425225459555222734718972453340179716809956645203098485790624854125458785078739344965108473271355866839363046574921352749613726933677028169892754057031491980488082226337743391078481920 99999999999999917714245105843845444238961215527321290310410545327345571182038613696688194314104132096931555770227452674414634559636686768493688540787048173759306259839416668984497943167082032947319814887875031157212965830669028421795760605619675656325219701751808 +99999999999999916696669050990531978944456298883937185186953750366157073495322103961448201373908756185194424200146125709940204497699102964600275082012284757871618928300075199343149877911695652938652532565950066513756388038184830097416603122780280888492002797374893195264 99999999999999917154891513686131358215156841822734601038501577120887513966385299198425225459555222734718972453340179716809956645203098485790624854125458785078739344965108473271355866839363046574921352749613726933677028169892754057031491980488082226337743391078481920 +99999999999999916462059150090385096757857620899272908270961263067735087974137748000115965042057765311837855494510770058422891398177057257750815998690339655941573274967578163091908411580729947396882896631914272378757020290750373030093780027633886603514983613398655768199168 99999999999999916696669050990531978944456298883937185186953750366157073495322103961448201373908756185194424200146125709940204497699102964600275082012284757871618928300075199343149877911695652938652532565950066513756388038184830097416603122780280888492002797374893195264 +99999999999999919104705073829639577707705129718531323452700639997160332884758333548562275084027326509326245394787416117113906151193380099703123113228729284081607514104824779425892288332727654619376075792893457515389898597852097436418059371362871829496127701706994146657435648 99999999999999916462059150090385096757857620899272908270961263067735087974137748000115965042057765311837855494510770058422891398177057257750815998690339655941573274967578163091908411580729947396882896631914272378757020290750373030093780027633886603514983613398655768199168 +99999999999999917628667205152005074893535757519847350463918209828579541545589890129502808820585418873201821072305623991241397547326808505070852666708377840873210208172166305720801657535975480694376249177888356289983316387049097913467480072465518626911750494564591328725835972608 99999999999999919104705073829639577707705129718531323452700639997160332884758333548562275084027326509326245394787416117113906151193380099703123113228729284081607514104824779425892288332727654619376075792893457515389898597852097436418059371362871829496127701706994146657435648 +99999999999999922666876463571664177832567214624688644932295571470668642649951510333225786999800463604506522759710141114219560248524706214749002457497844100357873012422307229300844343988889567691708990690439101806037783666590002951805457412701817558399758028277326280599029531279360 99999999999999917628667205152005074893535757519847350463918209828579541545589890129502808820585418873201821072305623991241397547326808505070852666708377840873210208172166305720801657535975480694376249177888356289983316387049097913467480072465518626911750494564591328725835972608 +99999999999999925375417760898072911572590525964251324838495241089455743403656317354747260068946471652055930386858809519532620516688696023471975785026261161456827735987182989817475292225976180861475072527586382595468665276071193500415954030812851863967710878401292590726058388421083136 99999999999999922666876463571664177832567214624688644932295571470668642649951510333225786999800463604506522759710141114219560248524706214749002457497844100357873012422307229300844343988889567691708990690439101806037783666590002951805457412701817558399758028277326280599029531279360 +99999999999999922998092370787579302987061493839926595503682273926908893827833126734714698563684604017178278892401463993497843047031616968501411767264176243829402332903954893729735214230453302102183242983667397856859617189120845681749826713430824039194924833949628446523134774381262143488 99999999999999925375417760898072911572590525964251324838495241089455743403656317354747260068946471652055930386858809519532620516688696023471975785026261161456827735987182989817475292225976180861475072527586382595468665276071193500415954030812851863967710878401292590726058388421083136 +99999999999999919617007371519321726332086870374220313783059387295731152208884588964001722200645503380907841211395461467581715090185993423654387386446988805425952870741141601516060436636820763422301529854538175117504526576569239895202445639820828910629184681840594996990087856635738954137600 99999999999999922998092370787579302987061493839926595503682273926908893827833126734714698563684604017178278892401463993497843047031616968501411767264176243829402332903954893729735214230453302102183242983667397856859617189120845681749826713430824039194924833949628446523134774381262143488 +99999999999999921555856753499711351089115518454394923972933375405513716362854438463239371366266645249770760995191543556043059505759547789211465047382796770104026930323785255803070101100113406402892899431306036605160309737430832717440175842671744517153922714665999138290318281147731771838693376 99999999999999919617007371519321726332086870374220313783059387295731152208884588964001722200645503380907841211395461467581715090185993423654387386446988805425952870741141601516060436636820763422301529854538175117504526576569239895202445639820828910629184681840594996990087856635738954137600 +99999999999999925526620287795549302591510189722592525641795303054348407750184690237678076857458743797202020712405919673211892868854187129872360096979331481764722604349039459782865893920936739227144024324526616931879353650875374817383047298110419679316586205892426819673190190548293062490532610048 99999999999999921555856753499711351089115518454394923972933375405513716362854438463239371366266645249770760995191543556043059505759547789211465047382796770104026930323785255803070101100113406402892899431306036605160309737430832717440175842671744517153922714665999138290318281147731771838693376 +99999999999999930899630601631288884967321950615787908928575328581457293010297853781604279487826109145954719575470858327758062813887390534835216941233385308743309664972926291225241001006485111871616403608610236482548322786324903784620029930384009841602978861449101533681556294240023997498278499319808 99999999999999925526620287795549302591510189722592525641795303054348407750184690237678076857458743797202020712405919673211892868854187129872360096979331481764722604349039459782865893920936739227144024324526616931879353650875374817383047298110419679316586205892426819673190190548293062490532610048 +99999999999999931494437365022402110086546949875748132981079409245215076632606597507980542351987858564022045373933398563677552329964579755017051039451347591859641897413884141538429337185469061448690967542329331230644001099265478667047129413135161876865818437588564766886374336421681562627784638845681664 99999999999999930899630601631288884967321950615787908928575328581457293010297853781604279487826109145954719575470858327758062813887390534835216941233385308743309664972926291225241001006485111871616403608610236482548322786324903784620029930384009841602978861449101533681556294240023997498278499319808 +99999999999999935453471182153651736480108544950043384274546570143186884422693595750740947975848462690678165888500066373957674548974351204547338797190104548281949236540899593223010902792786229833699265085163625873968835950197945084481903570326829823575278656372832047097643225182794316129777503529896771584 99999999999999931494437365022402110086546949875748132981079409245215076632606597507980542351987858564022045373933398563677552329964579755017051039451347591859641897413884141538429337185469061448690967542329331230644001099265478667047129413135161876865818437588564766886374336421681562627784638845681664 +99999999999999941222697076902451192049310918572154864313272869839431340328494218420806572909572715350322284890650139835338184957968282769155167357390336223856117715957990417585527301167018263517206741135275385698826195289895225377703777542160595791457125916730459689891664596620526624002220028805109925281792 99999999999999935453471182153651736480108544950043384274546570143186884422693595750740947975848462690678165888500066373957674548974351204547338797190104548281949236540899593223010902792786229833699265085163625873968835950197945084481903570326829823575278656372832047097643225182794316129777503529896771584 +Inf 99999999999999941222697076902451192049310918572154864313272869839431340328494218420806572909572715350322284890650139835338184957968282769155167357390336223856117715957990417585527301167018263517206741135275385698826195289895225377703777542160595791457125916730459689891664596620526624002220028805109925281792 +Inf Inf +loop terminated diff --git a/test/inputred.awk b/test/inputred.awk new file mode 100644 index 0000000..6524df6 --- /dev/null +++ b/test/inputred.awk @@ -0,0 +1 @@ +BEGIN { print getline < "file" ".txt" } diff --git a/test/inputred.ok b/test/inputred.ok new file mode 100644 index 0000000..7de4d5d --- /dev/null +++ b/test/inputred.ok @@ -0,0 +1 @@ +-1.txt diff --git a/test/intest.awk b/test/intest.awk new file mode 100644 index 0000000..f030d07 --- /dev/null +++ b/test/intest.awk @@ -0,0 +1,4 @@ +BEGIN { + bool = ((b = 1) in c); + print bool, b # gawk-3.0.1 prints "0 "; should print "0 1" +} diff --git a/test/intest.ok b/test/intest.ok new file mode 100644 index 0000000..6e8183b --- /dev/null +++ b/test/intest.ok @@ -0,0 +1 @@ +0 1 diff --git a/test/intformat.awk b/test/intformat.awk new file mode 100644 index 0000000..2f23529 --- /dev/null +++ b/test/intformat.awk @@ -0,0 +1,88 @@ +function abs(x) { + return (x+0 >= 0) ? x : -x +} + +function check(x,what, f,res) { + for (f in formats) { + res = sprintf(f,x) + if (formats[f] == "non-decimal") { + if ((x >= 0) && (res !~ /e+/)) { + if (abs(strtonum(res)-x) > 1e-5*abs(x)) + printf "(sprintf(%s,%s) = %s)-%g = %g\n", + f,what,res,x,strtonum(res)-x + } + } + else if (abs(res-x) > 1e-5*abs(x)) + printf "(sprintf(%s,%s) = %s)-%g = %g\n", + f,what,res,x,res-x + } +} + +function check_cons(fmt,base,rot,mexp, i,j,dig,res,s) { + # first off, check that zero formats properly + if ((s = sprintf(fmt,0)) != "0") + printf "(sprintf(%s,0) = %s) != 0\n",fmt,s + + res = "1" + dig = 1 + j = 0 + for (i = 0; i <= mexp; i++) { + s = sprintf(fmt,base^i) + if (s ~ /e+/) + return + if (s != res) + printf "(sprintf(%s,%d^%d) = %s) != %s\n", + fmt,base,i,s,res + if (++j == rot) { + dig = 1 + res = ("10"substr(res,2)) + j = 0 + } + else { + dig *= 2 + res = (dig substr(res,2)) + } + } +} + +BEGIN { + # this doesn't necessarily have to be exact since we're checking + # magnitude rather than precision + if (!HUGEVAL) HUGEVAL = 1.7976931348623157e+308 + + formats["%s"] = "" + formats["%d"] = "" + formats["%.0f"] = "" + formats["0%o"] = "non-decimal" + formats["0x%x"] = "non-decimal" + + check(0,"0") + limit = HUGEVAL / 10 + value = 1 + for (i = 0; ; i++) { + check(10^i,"10^"i) + check(-10^i,"-10^"i) + #[probably should test value against 10^i here] + if (value >= limit) break + value *= 10 + } + limit = HUGEVAL / 2 + value = 1 + for (i = 0; ; i++) { + check(2^i,"2^"i) + check(-2^i,"-2^"i) + #[probably should test value against 2^i here] + if (value >= limit) break + value *= 2 + } + + check_cons("%d",10,1,9) + check_cons("%x",2,4,31) + check_cons("%o",2,3,31) + + # make sure basic %d and %x are working properly + printf "%d %d %x\n",3.7,-3.7,23.7 + + # check another problem in gawk 3.1.5: precision over 30 crashes + printf "%.55d\n",1 +} diff --git a/test/intformat.ok b/test/intformat.ok new file mode 100644 index 0000000..868f9f1 --- /dev/null +++ b/test/intformat.ok @@ -0,0 +1,2 @@ +3 -3 17 +0000000000000000000000000000000000000000000000000000001 diff --git a/test/intprec.awk b/test/intprec.awk new file mode 100644 index 0000000..978e9ea --- /dev/null +++ b/test/intprec.awk @@ -0,0 +1 @@ +BEGIN { printf "%.10d:%.10x\n", 5, 14 } diff --git a/test/intprec.ok b/test/intprec.ok new file mode 100644 index 0000000..8783fac --- /dev/null +++ b/test/intprec.ok @@ -0,0 +1 @@ +0000000005:000000000e diff --git a/test/iobug1.awk b/test/iobug1.awk new file mode 100644 index 0000000..5606d02 --- /dev/null +++ b/test/iobug1.awk @@ -0,0 +1,53 @@ +# From arnold@f7.net Fri Nov 26 11:53:12 2004 +# X-Envelope-From: james@nocrew.org +# X-Envelope-To: +# To: bug-gawk@gnu.org +# Subject: gawk 3.1.4: reproducible hang, regression from 3.1.3 +# From: James Troup +# Date: Fri, 26 Nov 2004 03:14:05 +0000 +# Message-ID: <877jo9qp36.fsf@shiri.gloaming.local> +# User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) +# MIME-Version: 1.0 +# Content-Type: text/plain; charset=us-ascii +# +# +# Hi, +# +# A Debian user reported[0] gawk 3.1.4 broke a (relatively) complex +# program that makes extensive use of awk, called 'apt-move'. I finally +# managed to reduced the problem down to a 3 line test case, enclosed +# below[1]. +# +# I believe the problem comes from the following code, introduced in +# 3.1.4: +# +# [io.c, line 560] +# | for (rp = red_head; rp != NULL; rp = rp->next) { +# | if ((rp->flag & RED_EOF) && tree->type == Node_redirect_pipein) { +# | if (rp->pid != -1) +# | wait_any(0); +# | } +# +# The problem is that, if we have an existing redirect which is a simple +# file redirect[b] and it's hit EOF and we try to create a new '|' +# redirect[c], this new code will try to wait(2) and if there are any +# other redirects which _did_ spawn a child (like [a]) the wait() will +# hang indefinitely waiting for it to exit. +# +# Hope that makes sense :) +# +# -- +# James +# +# [0] http://bugs.debian.org/263964 +# +# [1] +# ================================================================================ +#!/usr/bin/gawk -f + +BEGIN { + printf "" | "cat" # [a] + getline line < "/dev/null" # [b] + "true" | getline line # [c] +} +# ================================================================================ diff --git a/test/iobug1.ok b/test/iobug1.ok new file mode 100644 index 0000000..e69de29 diff --git a/test/lc_num1.awk b/test/lc_num1.awk new file mode 100644 index 0000000..c9b98ec --- /dev/null +++ b/test/lc_num1.awk @@ -0,0 +1,19 @@ +# Bug reported by Ulrich Drepper. +# BEGIN { +# printf("%'d %d\n", 1000000, 1000000) +# } + +# April 2010: +# This needs to be a smarter test so that systems without the %'d flag +# don't generate a needless failure. + +BEGIN { + s = sprintf("%'d", 1234) + if (s == "1,234" || s == "1234") + print "ok, or at least the quote flag isn't supported" + else { + command = "od -c" + print("fail:", s) | command + close(command) + } +} diff --git a/test/lc_num1.ok b/test/lc_num1.ok new file mode 100644 index 0000000..36a9eae --- /dev/null +++ b/test/lc_num1.ok @@ -0,0 +1 @@ +ok, or at least the quote flag isn't supported diff --git a/test/leaddig.awk b/test/leaddig.awk new file mode 100644 index 0000000..6c001ba --- /dev/null +++ b/test/leaddig.awk @@ -0,0 +1,7 @@ +# check that values with leading digits get converted the +# right way, based on a note in comp.lang.awk. +# +# run with gawk -v x=2E -f leaddig.awk +BEGIN { + print "x =", x, (x == 2), (x == 2E0), (x == 2E), (x == 2D) +} diff --git a/test/leaddig.ok b/test/leaddig.ok new file mode 100644 index 0000000..7a9d866 --- /dev/null +++ b/test/leaddig.ok @@ -0,0 +1 @@ +x = 2E 0 0 0 0 diff --git a/test/leadnl.awk b/test/leadnl.awk new file mode 100644 index 0000000..0b7d0a9 --- /dev/null +++ b/test/leadnl.awk @@ -0,0 +1,10 @@ +BEGIN { + RS = ""; FS = "\n" +} + +{ + print "Name is: ", $1 + print "Address is: ", $2 + print "City and State are: ", $3 + print "" +} diff --git a/test/leadnl.in b/test/leadnl.in new file mode 100644 index 0000000..67c0239 --- /dev/null +++ b/test/leadnl.in @@ -0,0 +1,9 @@ + +Jane Doe +123 Main Street +Anywhere, SE 12345-6789 + +John Smith +456 Tree-lined Avenue +Smallville, MW 98765-4321 + diff --git a/test/leadnl.ok b/test/leadnl.ok new file mode 100644 index 0000000..19cb299 --- /dev/null +++ b/test/leadnl.ok @@ -0,0 +1,8 @@ +Name is: Jane Doe +Address is: 123 Main Street +City and State are: Anywhere, SE 12345-6789 + +Name is: John Smith +Address is: 456 Tree-lined Avenue +City and State are: Smallville, MW 98765-4321 + diff --git a/test/lib/awkpath.awk b/test/lib/awkpath.awk new file mode 100644 index 0000000..6663ca4 --- /dev/null +++ b/test/lib/awkpath.awk @@ -0,0 +1 @@ +BEGIN { print "Found it." } diff --git a/test/lint.awk b/test/lint.awk new file mode 100644 index 0000000..ea7b8e3 --- /dev/null +++ b/test/lint.awk @@ -0,0 +1,14 @@ +# lint.awk --- test lint variable + +BEGIN { + a[1] = 1 + LINT = 1 + delete a[2] + LINT = "" + delete a[3] + LINT = "true" + delete a[4] + LINT = 0 + delete a[5] + print "done" +} diff --git a/test/lint.ok b/test/lint.ok new file mode 100644 index 0000000..fb6e3df --- /dev/null +++ b/test/lint.ok @@ -0,0 +1,5 @@ +gawk: lint.awk:6: warning: delete: index `2' not in array `a' +gawk: lint.awk:7: warning: turning off `--lint' due to assignment to `LINT' +gawk: lint.awk:10: warning: delete: index `4' not in array `a' +gawk: lint.awk:11: warning: turning off `--lint' due to assignment to `LINT' +done diff --git a/test/lintold.awk b/test/lintold.awk new file mode 100644 index 0000000..698187a --- /dev/null +++ b/test/lintold.awk @@ -0,0 +1,21 @@ +# lintold.awk --- test --lint-old + +BEGIN { + a[1] = 1 + for (i in a) + print a[i] + delete a[1] + if (2 in a) + a[2] **= 2; + if ((2,3) in a) + a[2,3] ^= 2 ** 3 ^ 5; +} +BEGIN { + FS = "ab" + foo = "\b\f\r" +} +END { +} +END { + print "done" +} diff --git a/test/lintold.in b/test/lintold.in new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/test/lintold.in @@ -0,0 +1 @@ + diff --git a/test/lintold.ok b/test/lintold.ok new file mode 100644 index 0000000..e3867e4 --- /dev/null +++ b/test/lintold.ok @@ -0,0 +1,16 @@ +gawk: lintold.awk:7: warning: `delete' is not supported in old awk +gawk: lintold.awk:8: warning: old awk does not support the keyword `in' except after `for' +gawk: lintold.awk:9: warning: old awk does not support operator `**=' +gawk: lintold.awk:10: warning: old awk does not support the keyword `in' except after `for' +gawk: lintold.awk:10: warning: old awk does not support multidimensional arrays +gawk: lintold.awk:11: warning: operator `^=' is not supported in old awk +gawk: lintold.awk:11: warning: old awk does not support operator `**' +gawk: lintold.awk:11: warning: operator `^' is not supported in old awk +gawk: lintold.awk:13: warning: old awk does not support multiple `BEGIN' or `END' rules +gawk: lintold.awk:15: warning: old awk does not support the `\b' escape sequence +gawk: lintold.awk:15: warning: old awk does not support the `\f' escape sequence +gawk: lintold.awk:15: warning: old awk does not support the `\r' escape sequence +gawk: lintold.awk:19: warning: old awk does not support multiple `BEGIN' or `END' rules +1 +gawk: lintold.awk:14: warning: old awk does not support regexps as value of `FS' +done diff --git a/test/lintwarn.awk b/test/lintwarn.awk new file mode 100644 index 0000000..cea76bb --- /dev/null +++ b/test/lintwarn.awk @@ -0,0 +1,38 @@ +# gawk --lint -f lintwarn.awk +BEGINFILE { + getline var + getline +} + +BEGIN { + PROCINFO["sorted_in"] + print + nextfile + delete a + delete(a) + y = /a/ + y == /a/ + /b/ ~ x + length + switch(s) { + case 1: + default: + case 1: + default: + } + break + continue + next + a[] + f(/pqr/) + // + /* */ +} +END { + getline +} +function zz(aa, aa) +{ + return aa +} +@include "" diff --git a/test/lintwarn.ok b/test/lintwarn.ok new file mode 100644 index 0000000..169b002 --- /dev/null +++ b/test/lintwarn.ok @@ -0,0 +1,39 @@ +gawk: lintwarn.awk:2: warning: `BEGINFILE' is a gawk extension +gawk: lintwarn.awk:3: error: `getline var' invalid inside `BEGINFILE' rule +gawk: lintwarn.awk:4: error: `getline' invalid inside `BEGINFILE' rule +gawk: lintwarn.awk:8: warning: statement may have no effect +gawk: lintwarn.awk:9: warning: plain `print' in BEGIN or END rule should probably be `print ""' +gawk: lintwarn.awk:10: warning: `nextfile' is a gawk extension +gawk: lintwarn.awk:10: error: `nextfile' used in BEGIN action +gawk: lintwarn.awk:11: warning: `delete array' is a gawk extension +gawk: lintwarn.awk:12: warning: `delete(array)' is a non-portable tawk extension +gawk: lintwarn.awk:13: warning: regular expression on right of assignment +gawk: lintwarn.awk:14: warning: regular expression on right of comparison +gawk: lintwarn.awk:14: warning: statement may have no effect +gawk: lintwarn.awk:15: warning: regular expression on left of `~' or `!~' operator +gawk: lintwarn.awk:15: warning: statement may have no effect +gawk: lintwarn.awk:16: warning: call of `length' without parentheses is not portable +gawk: lintwarn.awk:17: warning: `switch' is a gawk extension +gawk: lintwarn.awk:18: warning: `case' is a gawk extension +gawk: lintwarn.awk:19: warning: `default' is a gawk extension +gawk: lintwarn.awk:19: error: duplicate `default' detected in switch body +gawk: lintwarn.awk:18: error: duplicate case values in switch body: 1 +gawk: lintwarn.awk:23: error: `break' is not allowed outside a loop or switch +gawk: lintwarn.awk:24: error: `continue' is not allowed outside a loop +gawk: lintwarn.awk:25: error: `next' used in BEGIN action +gawk: lintwarn.awk:26: a[] +gawk: lintwarn.awk:26: ^ syntax error +gawk: lintwarn.awk:26: error: invalid subscript expression +gawk: lintwarn.awk:26: warning: statement may have no effect +gawk: lintwarn.awk:27: warning: regexp constant for parameter #1 yields boolean value +gawk: lintwarn.awk:28: warning: regexp constant `//' looks like a C++ comment, but is not +gawk: lintwarn.awk:28: warning: statement may have no effect +gawk: lintwarn.awk:29: warning: regexp constant `/* */' looks like a C comment, but is not +gawk: lintwarn.awk:29: warning: statement may have no effect +gawk: lintwarn.awk:32: warning: non-redirected `getline' undefined inside END action +gawk: lintwarn.awk:34: error: function `zz': parameter #2, `aa', duplicates parameter #1 +gawk: lintwarn.awk:38: warning: `include' is a gawk extension +gawk: lintwarn.awk:38: warning: empty filename after @include +gawk: warning: function `f' called but never defined +gawk: warning: function `zz' defined but never called directly +EXIT CODE: 1 diff --git a/test/litoct.awk b/test/litoct.awk new file mode 100644 index 0000000..5cfc128 --- /dev/null +++ b/test/litoct.awk @@ -0,0 +1 @@ +{ if (/a\52b/) print "match" ; else print "no match" } diff --git a/test/litoct.ok b/test/litoct.ok new file mode 100644 index 0000000..4c0be97 --- /dev/null +++ b/test/litoct.ok @@ -0,0 +1 @@ +no match diff --git a/test/localenl.ok b/test/localenl.ok new file mode 100644 index 0000000..47a0748 --- /dev/null +++ b/test/localenl.ok @@ -0,0 +1,4 @@ +LC_ALL=C passed +LC_ALL=POSIX passed +LC_ALL=en_US.ISO-8859-1 passed +LC_ALL=en_US.UTF-8 passed diff --git a/test/localenl.sh b/test/localenl.sh new file mode 100755 index 0000000..ca3ee64 --- /dev/null +++ b/test/localenl.sh @@ -0,0 +1,75 @@ +#! /bin/sh +# From arnold@f7.net Sun Apr 22 20:15:25 2007 +# Date: Thu, 19 Apr 2007 17:09:02 +0300 +# From: Pekka Pessi +# X-Face: #V(jdpv[lI!TNUU=2*oh:="#suS*ponXW"yr6G;~L}uZ\JfD\"IG#G{j`hZI;=DmT\H +# pfDMyJ`i=:M;BM3R.`[>P^ER8+]i +# Subject: UTF-8 locale and \n in regexps +# To: bug-gawk@gnu.org +# Cc: Pekka.Pessi@nokia.com +# Message-id: +# MIME-version: 1.0 +# Content-type: multipart/mixed; boundary="=-=-=" +# +# --=-=-= +# +# Hello, +# +# It looks like regexp with \n in [^] behaves badly if locale has +# an UTF-8 ctype. +# +# It looks like if there is \n and an range without \n, like /\n[^x\n]foo/, +# and first \n ends an even-numbered line within the string, regexp +# does not match. +# +# Please see the attached script for an demonstration. +# +# --Pekka Pessi +# +# +# --=-=-= +# Content-Disposition: inline; filename=gawk-test +# +#! /bin/sh + +AWK=${AWK:-../gawk} + +# April 2010: Remove UNKNOWN, causes spurious failures on some systems +for LC_ALL in C POSIX en_US.ISO-8859-1 en_US.UTF-8 #UNKNOWN +do +export LC_ALL +cat < +# Received: from localhost (skeeve [127.0.0.1]) +# by skeeve.com (8.12.11/8.12.11) with ESMTP id j3R6mZVm015791 +# for ; Wed, 27 Apr 2005 09:48:37 +0300 +# Received: from pop.012.net.il [84.95.5.221] +# by localhost with POP3 (fetchmail-6.2.5) +# for arnold@localhost (single-drop); Wed, 27 Apr 2005 09:48:37 +0300 (IDT) +# Received: from mtain3.012.net.il ([10.220.5.7]) +# by i_mss3.012.net.il (HyperSendmail v2004.12) +# with ESMTP id <0IFK00L1DIZ02530@i_mss3.012.net.il> for arobbins@012.net.il; +# Tue, 26 Apr 2005 22:18:36 +0300 (IDT) +# Received: from VScan3 ([10.220.20.3]) +# by i_mtain3.012.net.il (HyperSendmail v2004.12) +# with ESMTP id <0IFK007U1IZ0U980@i_mtain3.012.net.il> for arobbins@012.net.il +# (ORCPT arobbins@012.net.il); Tue, 26 Apr 2005 22:18:36 +0300 (IDT) +# Received: from i_mtain1.012.net.il ([10.220.5.1]) +# by VScan3 with InterScan Messaging Security Suite; Tue, +# 26 Apr 2005 22:15:22 +0300 +# Received: from f7.net ([209.61.216.22]) +# by i_mtain1.012.net.il (HyperSendmail v2004.12) +# with ESMTP id <0IFK009SIIYRN7G0@i_mtain1.012.net.il> for arobbins@012.net.il; +# Tue, 26 Apr 2005 22:18:33 +0300 (IDT) +# Received: (from arnold@localhost) by f7.net (8.11.7-20030920/8.11.7) +# id j3QJFAg18376 for arobbins@012.net.il; Tue, 26 Apr 2005 15:15:10 -0400 +# Received: from fencepost.gnu.org (fencepost.gnu.org [199.232.76.164]) +# by f7.net (8.11.7-20030920/8.11.7) with ESMTP id j3QJF5J18304 for +# ; Tue, 26 Apr 2005 15:15:06 -0400 +# Received: from monty-python.gnu.org ([199.232.76.173]) +# by fencepost.gnu.org with esmtp (Exim 4.34) +# id 1DQVVh-0004gD-CH for bug-gawk@gnu.org; Tue, 26 Apr 2005 15:14:17 -0400 +# Received: from Debian-exim by monty-python.gnu.org with spam-scanned +# (Exim 4.34) id 1DQVYa-0002PR-2b for bug-gawk@gnu.org; Tue, +# 26 Apr 2005 15:17:56 -0400 +# Received: from [129.183.4.8] (helo=ecfrec.frec.bull.fr) +# by monty-python.gnu.org with esmtp (Exim 4.34) +# id 1DQVYZ-0002Lr-EF for bug-gawk@gnu.org; Tue, 26 Apr 2005 15:17:15 -0400 +# Received: from localhost (localhost [127.0.0.1]) +# by ecfrec.frec.bull.fr (Postfix) with ESMTP id 5782819D907 for +# ; Tue, 26 Apr 2005 21:12:53 +0200 (CEST) +# Received: from ecfrec.frec.bull.fr ([127.0.0.1]) +# by localhost (ecfrec.frec.bull.fr [127.0.0.1]) (amavisd-new, port 10024) +# with ESMTP id 06763-10 for ; Tue, +# 26 Apr 2005 21:12:51 +0200 (CEST) +# Received: from ecn002.frec.bull.fr (ecn002.frec.bull.fr [129.183.4.6]) +# by ecfrec.frec.bull.fr (Postfix) with ESMTP id 4488B19D906 for +# ; Tue, 26 Apr 2005 21:12:51 +0200 (CEST) +# Received: from daphne ([129.183.192.6]) +# by ecn002.frec.bull.fr (Lotus Domino Release 5.0.12) +# with ESMTP id 2005042621231613:3312 ; Tue, 26 Apr 2005 21:23:16 +0200 +# Date: Tue, 26 Apr 2005 21:12:49 +0200 (CEST) +# From: Jean-Marc Saffroy +# Subject: GNU awk unable to handle 64-bit ints on IA64 +# X-X-Sender: saffroyj@daphne.frec.bull.fr +# To: bug-gawk@gnu.org +# Message-id: +# MIME-version: 1.0 +# Content-type: TEXT/PLAIN; charset=US-ASCII; format=flowed +# X-MIMETrack: Itemize by SMTP Server on ECN002/FR/BULL(Release 5.0.12 |February +# 13, 2003) at 26/04/2005 21:23:16, +# Serialize by Router on ECN002/FR/BULL(Release 5.0.12 |February 13, +# 2003) at 26/04/2005 21:23:16, Serialize complete at 26/04/2005 21:23:16 +# X-Virus-Scanned: by amavisd-new at frec.bull.fr +# Original-recipient: rfc822;arobbins@012.net.il +# X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on skeeve.com +# X-Spam-Level: +# X-Spam-Status: No, hits=-4.9 required=5.0 tests=BAYES_00 autolearn=ham +# version=2.63 +# Status: RO +# +# +# Hello, +# +# I have rounding problems when manipulating 64-bit ints (actually they are +# addresses) on Linux/IA64: +# +# $ echo 0xa000000100000813|./gawk '{printf("0x%lx\n",strtonum($1));}' +# 0xa000000100000800 +# $ echo 0xffffffffffffffff|./gawk '{printf("0x%lx\n",strtonum($1));}' +# 0x8000000000000000 +# $ ./gawk --version|head -1 +# GNU Awk 3.1.4 +# +# The problem seems to be that AWKNUM is defined to be a double, which has a +# 53-bit mantissa. On IA64 with gcc 3.2.3 (maybe other compilers as well) +# there is a long double type with a larger mantissa: +# +# $ grep define.*LDBL_MANT_DIG /usr/lib/gcc-lib/ia64-redhat-linux/3.2.3/include/float.h +# #define LDBL_MANT_DIG 64 +# +# So I changed AWKNUM to be a long double; this does not seem to be +# sufficient, because of some dubious casts to double (there may be others +# left, I didn't check), see patch below. Now it's much nicer: +# +# $ echo 0xa000000100000813|./gawk '{printf("0x%lx\n",strtonum($1));}' +# 0xa000000100000813 +# $ echo 0xffffffffffffffff|./gawk '{printf("0x%lx\n",strtonum($1));}' +# 0xffffffffffffffff +# +# Maybe the gawk configure script should set AWKNUM to be a long double on +# Linux/IA64? +# +# +# Regards, +# +# -- +# Jean-Marc Saffroy - jean-marc.saffroy@ext.bull.net +# +# +# diff -ru gawk-3.1.4/awk.h gawk/awk.h +# --- gawk-3.1.4/awk.h 2004-07-26 16:11:05.000000000 +0200 +# +++ gawk/awk.h 2005-04-26 19:19:10.545419273 +0200 +# @@ -273,7 +273,7 @@ +# /* ------------------ Constants, Structures, Typedefs ------------------ */ +# +# #ifndef AWKNUM +# -#define AWKNUM double +# +#define AWKNUM long double +# #endif +# +# #ifndef TRUE +# diff -ru gawk-3.1.4/builtin.c gawk/builtin.c +# --- gawk-3.1.4/builtin.c 2004-07-13 09:55:28.000000000 +0200 +# +++ gawk/builtin.c 2005-04-26 20:53:41.211365432 +0200 +# @@ -578,7 +578,7 @@ +# char *cend = &cpbuf[30];/* chars, we lose, but seems unlikely */ +# char *cp; +# const char *fill; +# - double tmpval; +# + AWKNUM tmpval; +# char signchar = FALSE; +# size_t len; +# int zero_flag = FALSE; +# @@ -2773,16 +2773,16 @@ +# do_strtonum(NODE *tree) +# { +# NODE *tmp; +# - double d; +# + AWKNUM d; +# +# tmp = tree_eval(tree->lnode); +# +# if ((tmp->flags & (NUMBER|NUMCUR)) != 0) +# - d = (double) force_number(tmp); +# + d = (AWKNUM) force_number(tmp); +# else if (isnondecimal(tmp->stptr)) +# d = nondec2awknum(tmp->stptr, tmp->stlen); +# else +# - d = (double) force_number(tmp); +# + d = (AWKNUM) force_number(tmp); +# +# free_temp(tmp); +# return tmp_number((AWKNUM) d); +# +# +# ##################################################################################### +# This Mail Was Scanned by 012.net Anti Virus Service - Powered by TrendMicro Interscan +# +{ printf("0x%lx\n",strtonum($1)); } diff --git a/test/longdbl.in b/test/longdbl.in new file mode 100644 index 0000000..d50f0c4 --- /dev/null +++ b/test/longdbl.in @@ -0,0 +1,2 @@ +0xa000000100000813 +0xffffffffffffffff diff --git a/test/longdbl.ok b/test/longdbl.ok new file mode 100644 index 0000000..d50f0c4 --- /dev/null +++ b/test/longdbl.ok @@ -0,0 +1,2 @@ +0xa000000100000813 +0xffffffffffffffff diff --git a/test/longsub.awk b/test/longsub.awk new file mode 100644 index 0000000..07a4a85 --- /dev/null +++ b/test/longsub.awk @@ -0,0 +1 @@ +{sub( "^.*AA", "BB"); print} diff --git a/test/longsub.in b/test/longsub.in new file mode 100644 index 0000000..ab95ee1 --- /dev/null +++ b/test/longsub.in @@ -0,0 +1 @@ +AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/test/longsub.ok b/test/longsub.ok new file mode 100644 index 0000000..a85633e --- /dev/null +++ b/test/longsub.ok @@ -0,0 +1 @@ +BB000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 diff --git a/test/longwrds.awk b/test/longwrds.awk new file mode 100644 index 0000000..77654bb --- /dev/null +++ b/test/longwrds.awk @@ -0,0 +1,27 @@ +# From Gawk Manual modified by bug fix and removal of punctuation + +# Invoker can customize sort command if necessary. +BEGIN { + if (!SORT) SORT = "LC_ALL=C sort" +} + +# Record every word which is used at least once +{ + for (i = 1; i <= NF; i++) { + tmp = tolower($i) + if (0 != (pos = match(tmp, /([[:lower:]]|-)+/))) + used[substr(tmp, pos, RLENGTH)] = 1 + } +} + +#Find a number of distinct words longer than 10 characters +END { + num_long_words = 0 + for (x in used) + if (length(x) > 10) { + ++num_long_words + print x | SORT + } + print(num_long_words, "long words") | SORT + close(SORT) +} diff --git a/test/longwrds.in b/test/longwrds.in new file mode 100644 index 0000000..09c3948 --- /dev/null +++ b/test/longwrds.in @@ -0,0 +1,200 @@ +.ds PX \s-1POSIX\s+1 +.ds UX \s-1UNIX\s+1 +.ds AN \s-1ANSI\s+1 +.TH GAWK 1 "May 28 1991" "Free Software Foundation" "Utility Commands" +.SH NAME +gawk \- pattern scanning and processing language +.SH SYNOPSIS +.B gawk +[ +.B \-W +.I gawk-options +] [ +.BI \-F\^ fs +] [ +.B \-v +.IR var = val +] +.B \-f +.I program-file +[ +.B \-\^\- +] file .\^.\^. +.br +.B gawk +[ +.B \-W +.I gawk-options +] [ +.BI \-F\^ fs +] [ +.B \-v +.IR var = val +] [ +.B \-\^\- +] +.I program-text +file .\^.\^. +.SH DESCRIPTION +.I Gawk +is the GNU Project's implementation of the AWK programming language. +It conforms to the definition of the language in +the \*(PX 1003.2 Command Language And Utilities Standard +(draft 11). +This version in turn is based on the description in +.IR "The AWK Programming Language" , +by Aho, Kernighan, and Weinberger, +with the additional features defined in the System V Release 4 version +of \*(UX +.IR awk . +.I Gawk +also provides some GNU-specific extensions. +.PP +The command line consists of options to +.I gawk +itself, the AWK program text (if not supplied via the +.B \-f +option), and values to be made +available in the +.B ARGC +and +.B ARGV +pre-defined AWK variables. +.SH OPTIONS +.PP +.I Gawk +accepts the following options, which should be available on any implementation +of the AWK language. +.TP +.BI \-F fs +Use +.I fs +for the input field separator (the value of the +.B FS +predefined +variable). +.TP +\fB\-v\fI var\fR\^=\^\fIval\fR +Assign the value +.IR val , +to the variable +.IR var , +before execution of the program begins. +Such variable values are available to the +.B BEGIN +block of an AWK program. +.TP +.BI \-f " program-file" +Read the AWK program source from the file +.IR program-file , +instead of from the first command line argument. +Multiple +.B \-f +options may be used. +.TP +.B \-\^\- +Signal the end of options. This is useful to allow further arguments to the +AWK program itself to start with a ``\-''. +This is mainly for consistency with the argument parsing convention used +by most other \*(PX programs. +.PP +Following the \*(PX standard, +.IR gawk -specific +options are supplied via arguments to the +.B \-W +option. Multiple +.B \-W +options may be supplied, or multiple arguments may be supplied together +if they are separated by commas, or enclosed in quotes and separated +by white space. +Case is ignored in arguments to the +.B \-W +option. +.PP +The +.B \-W +option accepts the following arguments: +.TP \w'\fBcopyright\fR'u+1n +.B compat +Run in +.I compatibility +mode. In compatibility mode, +.I gawk +behaves identically to \*(UX +.IR awk ; +none of the GNU-specific extensions are recognized. +.TP +.PD 0 +.B copyleft +.TP +.PD +.B copyright +Print the short version of the GNU copyright information message on +the error output. +.TP +.B lint +Provide warnings about constructs that are +dubious or non-portable to other AWK implementations. +.TP +.B posix +This turns on +.I compatibility +mode, with the following additional restrictions: +.RS +.TP \w'\(bu'u+1n +\(bu +.B \ex +escape sequences are not recognized. +.TP +\(bu +The synonym +.B func +for the keyword +.B function +is not recognized. +.TP +\(bu +The operators +.B ** +and +.B **= +cannot be used in place of +.B ^ +and +.BR ^= . +.RE +.TP +.B version +Print version information for this particular copy of +.I gawk +on the error output. +This is useful mainly for knowing if the current copy of +.I gawk +on your system +is up to date with respect to whatever the Free Software Foundation +is distributing. +.PP +Any other options are flagged as illegal, but are otherwise ignored. +.SH AWK PROGRAM EXECUTION +.PP +An AWK program consists of a sequence of pattern-action statements +and optional function definitions. +.RS +.PP +\fIpattern\fB { \fIaction statements\fB }\fR +.br +\fBfunction \fIname\fB(\fIparameter list\fB) { \fIstatements\fB }\fR +.RE +.PP +.I Gawk +first reads the program source from the +.IR program-file (s) +if specified, or from the first non-option argument on the command line. +The +.B \-f +option may be used multiple times on the command line. +.I Gawk +will read the program text as if all the +.IR program-file s +had been concatenated together. This is useful for building libraries +of AWK functions, without having to include them in each new AWK diff --git a/test/longwrds.ok b/test/longwrds.ok new file mode 100644 index 0000000..01faa84 --- /dev/null +++ b/test/longwrds.ok @@ -0,0 +1,21 @@ +20 long words +compatibility +concatenated +consistency +definitions +description +distributing +fistatements +gawk-options +gnu-specific +identically +implementation +implementations +information +non-portable +pattern-action +pre-defined +program-file +program-text +programming +restrictions diff --git a/test/manglprm.awk b/test/manglprm.awk new file mode 100644 index 0000000..3a4306c --- /dev/null +++ b/test/manglprm.awk @@ -0,0 +1,41 @@ +# From beebe@sunshine.math.utah.edu Thu Jul 10 00:36:16 2003 +# Date: Wed, 9 Jul 2003 06:42:54 -0600 (MDT) +# From: "Nelson H. F. Beebe" +# To: "Arnold Robbins" +# Cc: beebe@math.utah.edu +# X-US-Mail: "Center for Scientific Computing, Department of Mathematics, 110 +# LCB, University of Utah, 155 S 1400 E RM 233, Salt Lake City, UT +# 84112-0090, USA" +# X-Telephone: +1 801 581 5254 +# X-FAX: +1 801 585 1640, +1 801 581 4148 +# X-URL: http://www.math.utah.edu/~beebe +# Subject: gawk-3.1.3 (and earlier): reproducible core dump +# X-SpamBouncer: 1.4 (10/07/01) +# X-SBClass: OK +# +# I have a reproducible core dump in gawk-3.1.3, and recent gawk +# versions. +# +# Consider the following test program, reduced from a much larger one: +# +# % cat gawk-dump.awk + + { process($0) } + + function out_debug(s) + { + print s + } + + function process(s, n,parts) + { + out_debug("Buffer = [" protect(Buffer) "]") + Buffer = Buffer s + n = split(Buffer,parts,"\n") + } + + function protect(s) + { + gsub("\n", "\\n", s) + return (s) + } diff --git a/test/manglprm.in b/test/manglprm.in new file mode 100644 index 0000000..73709ba --- /dev/null +++ b/test/manglprm.in @@ -0,0 +1 @@ +Testing diff --git a/test/manglprm.ok b/test/manglprm.ok new file mode 100644 index 0000000..b13c456 --- /dev/null +++ b/test/manglprm.ok @@ -0,0 +1 @@ +Buffer = [] diff --git a/test/manyfiles.awk b/test/manyfiles.awk new file mode 100644 index 0000000..8651a3a --- /dev/null +++ b/test/manyfiles.awk @@ -0,0 +1 @@ +{ print $2 > ("junk/" $1) } diff --git a/test/manyfiles.ok b/test/manyfiles.ok new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/test/manyfiles.ok @@ -0,0 +1 @@ +1 diff --git a/test/match1.awk b/test/match1.awk new file mode 100644 index 0000000..6d4791b --- /dev/null +++ b/test/match1.awk @@ -0,0 +1,9 @@ +BEGIN { + data = "foooobazbarrrrr" + match(data, /(fo+).+(bar*)/, arr) + for (i = 0; i in arr; i++) { + printf("arr[%d] = \"%s\"\n", i, arr[i]) + printf("arr[%d, \"start\"] = %s, arr[%d, \"length\"] = %s\n", + i, arr[i, "start"], i, arr[i, "length"]) + } +} diff --git a/test/match1.ok b/test/match1.ok new file mode 100644 index 0000000..4490db2 --- /dev/null +++ b/test/match1.ok @@ -0,0 +1,6 @@ +arr[0] = "foooobazbarrrrr" +arr[0, "start"] = 1, arr[0, "length"] = 15 +arr[1] = "foooo" +arr[1, "start"] = 1, arr[1, "length"] = 5 +arr[2] = "barrrrr" +arr[2, "start"] = 9, arr[2, "length"] = 7 diff --git a/test/match2.awk b/test/match2.awk new file mode 100644 index 0000000..b4d9544 --- /dev/null +++ b/test/match2.awk @@ -0,0 +1,6 @@ +function f(a, b, c) +{ + print match("foo", "bar", f) +} + +BEGIN { f(1, 2, 3) } diff --git a/test/match2.ok b/test/match2.ok new file mode 100644 index 0000000..a4a91e8 --- /dev/null +++ b/test/match2.ok @@ -0,0 +1,2 @@ +gawk: match2.awk:3: fatal: match: third argument is not an array +EXIT CODE: 2 diff --git a/test/match3.awk b/test/match3.awk new file mode 100644 index 0000000..f3b6b83 --- /dev/null +++ b/test/match3.awk @@ -0,0 +1,46 @@ +# Date: Mon, 28 Jul 2008 17:25:32 +0200 +# From: Dirk Zimoch +# Subject: match() prevents numeric strings from beeing treated numerically +# To: bug-gawk@gnu.org +# Message-id: <488DE4EC.6020400@psi.ch> +# +# In gawk version 3.1.5, numeric user input that is parsed with match() is not +# recognized as "numeric string" any more. I.e. mixed string-numeric comparison +# does not work any more. In version 3.1.1, it worked. (Even though the +# documentation never explicitly mentioned this behavior for match(), as it does +# for split(). But is says that "user input" should be treated that way.) +# +# awk 'BEGIN{match(".5",/.*/,a);print a[0]==.5?"OK":"FAULT"}' +# +# Version 3.1.1 prints OK, version 3.1.5 prints FAULT. +# +# awk '{match($0,/.*/,a);print a[0]==a[0]+0?"OK":"FAULT"}' << EOF +# 5 +# 5.0 +# 0.5 +# .5 +# EOF +# +# Version 3.1.1 prints +# OK +# OK +# OK +# OK +# +# Version 3.1.5 prints +# OK +# FAULT +# OK +# FAULT +# +# +# -- +# Dr. Dirk Zimoch +# Paul Scherrer Institut, WBGB/006 +# 5232 Villigen PSI, Switzerland +# Phone +41 56 310 5182 +# +{ + match($0,/.*/,a) + print a[0] == a[0]+0 ? "OK" : "FAULT" +} diff --git a/test/match3.in b/test/match3.in new file mode 100644 index 0000000..a45babd --- /dev/null +++ b/test/match3.in @@ -0,0 +1,4 @@ +5 +5.0 +0.5 +.5 diff --git a/test/match3.ok b/test/match3.ok new file mode 100644 index 0000000..b462a5a --- /dev/null +++ b/test/match3.ok @@ -0,0 +1,4 @@ +OK +OK +OK +OK diff --git a/test/math.awk b/test/math.awk new file mode 100644 index 0000000..90a01dd --- /dev/null +++ b/test/math.awk @@ -0,0 +1,10 @@ +BEGIN { + pi = 3.1415927 + printf "cos(%f) = %f\n", pi/4, cos(pi/4) + printf "sin(%f) = %f\n", pi/4, sin(pi/4) + e = exp(1) + printf "e = %f\n", e + printf "log(e) = %f\n", log(e) + printf "sqrt(pi ^ 2) = %f\n", sqrt(pi ^ 2) + printf "atan2(1, 1) = %f\n", atan2(1, 1) +} diff --git a/test/math.ok b/test/math.ok new file mode 100644 index 0000000..a396a5b --- /dev/null +++ b/test/math.ok @@ -0,0 +1,6 @@ +cos(0.785398) = 0.707107 +sin(0.785398) = 0.707107 +e = 2.718282 +log(e) = 1.000000 +sqrt(pi ^ 2) = 3.141593 +atan2(1, 1) = 0.785398 diff --git a/test/mbfw1.awk b/test/mbfw1.awk new file mode 100644 index 0000000..25d8e5c --- /dev/null +++ b/test/mbfw1.awk @@ -0,0 +1,40 @@ +# Date: Sun, 16 Mar 2008 18:51:14 +0100 +# From: Hermann Peifer +# Subject: [Fwd: Gawk FIELDWIDTHS and multibyte characters] +# To: bug-gawk@gnu.org +# Message-id: <47DD5E12.2010403@gmx.eu> +# +# See below. Regards, Hermann +# +# --- Original Message --- +# +# Newsgroups: comp.lang.awk +# From: Hermann Peifer +# Date: Sun, 16 Mar 2008 01:23:38 -0700 (PDT) +# Subject: Gawk FIELDWIDTHS and multibyte characters +# +# Hi, +# +# It looks to me that Gawk's FIELDWIDTHS extension is not aware of +# multibyte characters, see my example below. +# +# $ cat testdata +# CDRegion Commune Site +# SEVästsverige Hallands län Kungsbacka +# SESmÃ¥land med öarna Västra Götalands länGöteborg +# SEKronoberg Alvesta Stenungsund +# +# $ file testdata +# testdata: UTF-8 Unicode text +# +# $ awk 'BEGIN{FIELDWIDTHS = "2 20 20 20"}{print $4}' testdata +# Site +# Kungsbacka +# länGöteborg +# Stenungsund +# +# Can someone confirm? +# +# Hermann +BEGIN { FIELDWIDTHS = "2 20 20 20" } +{ print $4 } diff --git a/test/mbfw1.in b/test/mbfw1.in new file mode 100644 index 0000000..58ba36a --- /dev/null +++ b/test/mbfw1.in @@ -0,0 +1,4 @@ +CDRegion Commune Site +SEVästsverige Hallands län Kungsbacka +SESmÃ¥land med öarna Västra Götalands länGöteborg +SEKronoberg Alvesta Stenungsund diff --git a/test/mbfw1.ok b/test/mbfw1.ok new file mode 100644 index 0000000..c0a80f1 --- /dev/null +++ b/test/mbfw1.ok @@ -0,0 +1,4 @@ +Site +Kungsbacka +Göteborg +Stenungsund diff --git a/test/mbprintf1.awk b/test/mbprintf1.awk new file mode 100644 index 0000000..974c109 --- /dev/null +++ b/test/mbprintf1.awk @@ -0,0 +1 @@ +{ printf "%-7s|\n", $0 } diff --git a/test/mbprintf1.in b/test/mbprintf1.in new file mode 100644 index 0000000..8ee09e6 --- /dev/null +++ b/test/mbprintf1.in @@ -0,0 +1,2 @@ +AAA +ÅÃÆ diff --git a/test/mbprintf1.ok b/test/mbprintf1.ok new file mode 100644 index 0000000..40935cc --- /dev/null +++ b/test/mbprintf1.ok @@ -0,0 +1,2 @@ +AAA | +ÅÃÆ | diff --git a/test/mbprintf2.awk b/test/mbprintf2.awk new file mode 100644 index 0000000..46c6813 --- /dev/null +++ b/test/mbprintf2.awk @@ -0,0 +1,4 @@ +BEGIN { + printf "%c\n", 65 + printf "%c\n", "AA" +} diff --git a/test/mbprintf2.ok b/test/mbprintf2.ok new file mode 100644 index 0000000..67aa866 --- /dev/null +++ b/test/mbprintf2.ok @@ -0,0 +1,2 @@ +A +A diff --git a/test/mbprintf3.awk b/test/mbprintf3.awk new file mode 100644 index 0000000..1f99bd8 --- /dev/null +++ b/test/mbprintf3.awk @@ -0,0 +1 @@ +FNR == 1 { print $0; printf "%s\n", $0 } diff --git a/test/mbprintf3.in b/test/mbprintf3.in new file mode 100644 index 0000000..10971bc --- /dev/null +++ b/test/mbprintf3.in @@ -0,0 +1 @@ +COMPONENT suspended particulates <10 µm (air), day diff --git a/test/mbprintf3.ok b/test/mbprintf3.ok new file mode 100644 index 0000000..0131780 --- /dev/null +++ b/test/mbprintf3.ok @@ -0,0 +1,2 @@ +COMPONENT suspended particulates <10 µm (air), day +COMPONENT suspended particulates <10 µm (air), day diff --git a/test/mbstr1.awk b/test/mbstr1.awk new file mode 100644 index 0000000..2abcff2 --- /dev/null +++ b/test/mbstr1.awk @@ -0,0 +1,4 @@ +BEGIN { + print length("\x81\x82\x83\x84") + print index("\x81\x82\x83\x84", "\x81\x82") +} diff --git a/test/mbstr1.ok b/test/mbstr1.ok new file mode 100644 index 0000000..dcb4347 --- /dev/null +++ b/test/mbstr1.ok @@ -0,0 +1,2 @@ +4 +1 diff --git a/test/membug1.awk b/test/membug1.awk new file mode 100644 index 0000000..cb76958 --- /dev/null +++ b/test/membug1.awk @@ -0,0 +1 @@ +{ one != one = $1 } diff --git a/test/membug1.in b/test/membug1.in new file mode 100644 index 0000000..af7e09d --- /dev/null +++ b/test/membug1.in @@ -0,0 +1,2 @@ +yes +yes diff --git a/test/membug1.ok b/test/membug1.ok new file mode 100644 index 0000000..e69de29 diff --git a/test/messages.awk b/test/messages.awk new file mode 100644 index 0000000..555f6e3 --- /dev/null +++ b/test/messages.awk @@ -0,0 +1,9 @@ +# This is a demo of different ways of printing with gawk. Try it +# with and without -c (compatibility) flag, redirecting output +# from gawk to a file or not. Some results can be quite unexpected. +BEGIN { + print "Goes to a file out1" > "out1" + print "Normal print statement" + print "This printed on stdout" > "/dev/stdout" + print "You blew it!" > "/dev/stderr" +} diff --git a/test/minusstr.awk b/test/minusstr.awk new file mode 100644 index 0000000..d427719 --- /dev/null +++ b/test/minusstr.awk @@ -0,0 +1 @@ +BEGIN { print-"6" } diff --git a/test/minusstr.ok b/test/minusstr.ok new file mode 100644 index 0000000..3cfb5ef --- /dev/null +++ b/test/minusstr.ok @@ -0,0 +1 @@ +-6 diff --git a/test/mixed1.ok b/test/mixed1.ok new file mode 100644 index 0000000..91608fa --- /dev/null +++ b/test/mixed1.ok @@ -0,0 +1,3 @@ +gawk: BEGIN {return junk} +gawk: ^ `return' used outside function context +EXIT CODE: 1 diff --git a/test/mmap8k.in b/test/mmap8k.in new file mode 100644 index 0000000..0500ddf --- /dev/null +++ b/test/mmap8k.in @@ -0,0 +1,143 @@ +XXXXXXXX.com ALTERNET 9305 930528 1500.00 startup +XXXXXXXX.com ALTERNET 9305 930624 94.38 Line-9305 +XXXXXXXX.com ALTERNET 9306 930624 104.49 Line-9306 +XXXXXXXX.com ALTERNET 9306 930624 649.16 Line-install +XXXXXXXX.com ALTERNET 9306 930624 166.67 TCP-slip +XXXXXXXX.com ALTERNET 9307 930624 104.49 Line-9307 +XXXXXXXX.com ALTERNET 9307 930624 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9308 930701 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9308 930701 104.49 line-9308 +XXXXXXXX.com PAYMENT 9307 930731 1500.00 1870 +XXXXXXXX.com ALTERNET 9309 930801 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9309 930801 104.49 line-9309 +XXXXXXXX.com INTEREST 9307 930801 22.50 +XXXXXXXX.com CREDADJ 9308 930805 22.50 waive interest +XXXXXXXX.com PAYMENT 9308 930820 1723.68 1982 +XXXXXXXX.com ALTERNET 9310 930901 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9310 930901 104.49 line-9310 +XXXXXXXX.com PAYMENT 9310 931001 708.98 2313 +XXXXXXXX.com ALTERNET 9311 931001 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9311 931001 104.49 line-9311 +XXXXXXXX.com INTEREST 9309 931001 5.32 +XXXXXXXX.com CREDADJ 9310 931007 5.32 waive int-9309 +XXXXXXXX.com ALTERNET 9312 931101 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9312 931101 104.49 line-9312 +XXXXXXXX.com PAYMENT 9311 931120 354.49 002701 +XXXXXXXX.com ALTERNET 9401 931201 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9401 931201 104.49 line-9401 +XXXXXXXX.com PAYMENT 9312 931218 354.49 2884 +XXXXXXXX.com ALTERNET 9402 940101 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9402 940101 104.49 line-9402 +XXXXXXXX.com INTEREST 9312 940101 5.32 +XXXXXXXX.com PAYMENT 9401 940122 354.49 3084 +XXXXXXXX.com ALTERNET 9403 940201 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9403 940201 104.49 line-9403 +XXXXXXXX.com INTEREST 9401 940201 5.40 +XXXXXXXX.com PAYMENT 9402 940207 354.49 3140 +XXXXXXXX.com CREDADJ 9402 940211 5.32 interest-9402 +XXXXXXXX.com CREDADJ 9402 940211 5.40 interest-9403 +XXXXXXXX.com ALTERNET 9404 940301 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9404 940301 104.49 line-9404 +XXXXXXXX.com INTEREST 9402 940301 5.32 +XXXXXXXX.com PAYMENT 9403 940310 354.49 003307 +XXXXXXXX.com PAYMENT 9403 940324 354.49 3446 +XXXXXXXX.com ALTERNET 9405 940401 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9405 940401 104.49 line-9405 +XXXXXXXX.com ALTERNET 9406 940501 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9406 940501 104.49 line-9406 +XXXXXXXX.com INTEREST 9404 940501 5.40 +XXXXXXXX.com PAYMENT 9405 940509 359.81 003819 +XXXXXXXX.com ALTERNET 9407 940601 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9407 940601 104.49 line-9407 +XXXXXXXX.com INTEREST 9405 940601 5.40 +XXXXXXXX.com PAYMENT 9406 940603 354.49 004025 +XXXXXXXX.com ALTERNET 9408 940701 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9408 940701 104.49 line-9408 +XXXXXXXX.com INTEREST 9406 940701 5.48 +XXXXXXXX.com PAYMENT 9407 940725 354.49 004350 +XXXXXXXX.com ALTERNET 9409 940801 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9409 940801 104.49 line-9409 +XXXXXXXX.com INTEREST 9407 940801 5.56 +XXXXXXXX.com PAYMENT 9408 940808 354.49 004454 +XXXXXXXX.com ALTERNET 9409 940811 0.00 startup +XXXXXXXX.com EQUIPMENT 9408 940831 399.00 ATL6402-1 +XXXXXXXX.com EQUIPMENT 9408 940831 2295.00 NBClassicPac-1 +XXXXXXXX.com EQUIPMENT 9408 940831 1060.00 Syn35-1+ship +XXXXXXXX.com ALTERNET 9410 940901 250.00 TCP-slip +XXXXXXXX.com ALTERNET 9410 940901 104.49 line-9410 +XXXXXXXX.com INTEREST 9408 940901 5.64 +XXXXXXXX.com PAYMENT 9409 940906 354.49 004677 +XXXXXXXX.com CREDADJ 9409 940921 124.95 TCP-slip-9409 +XXXXXXXX.com CREDADJ 9409 940921 52.20 line-9409 +XXXXXXXX.com CREDADJ 9410 940921 250.00 TCP-slip-9410 +XXXXXXXX.com CREDADJ 9410 940921 104.49 line-9410 +XXXXXXXX.com ALTERNET 9409 940921 397.50 TCP-56k-local recon +XXXXXXXX.com ALTERNET 9409 940921 87.45 line-9409 recon +XXXXXXXX.com ALTERNET 9410 940921 795.00 TCP-56k-local recon +XXXXXXXX.com ALTERNET 9410 940921 174.90 line-9410 recon +XXXXXXXX.com ALTERNET 9411 941001 795.00 TCP-56k-local +XXXXXXXX.com ALTERNET 9411 941001 174.90 line-9411 +XXXXXXXX.com INTEREST 9409 941001 54.06 +XXXXXXXX.com PAYMENT 9410 941017 354.49 5026 +XXXXXXXX.com ALTERNET 9412 941101 795.00 TCP-56k-local +XXXXXXXX.com ALTERNET 9412 941101 174.90 line-9412 +XXXXXXXX.com INTEREST 9410 941101 85.93 +XXXXXXXX.com PAYMENT 9411 941114 969.90 005274 +XXXXXXXX.com ALTERNET 9501 941201 795.00 TCP-56k-local +XXXXXXXX.com ALTERNET 9501 941201 174.90 line-9501 +XXXXXXXX.com INTEREST 9411 941201 87.22 +XXXXXXXX.com PAYMENT 9412 941219 4723.90 5590 +XXXXXXXX.com ALTERNET 9502 950101 795.00 TCP-56k-local +XXXXXXXX.com ALTERNET 9502 950101 174.90 line-9502 +XXXXXXXX.com INTEREST 9412 950101 32.22 +XXXXXXXX.com PAYMENT 9501 950103 1893.11 5766 +XXXXXXXX.com ALTERNET 9503 950201 795.00 TCP-56k-local-old +XXXXXXXX.com ALTERNET 9503 950201 174.90 line-9503 +XXXXXXXX.com INTEREST 9501 950201 18.85 +XXXXXXXX.com PAYMENT 9502 950207 969.90 6044 +XXXXXXXX.com ALTERNET 9504 950301 795.00 TCP-56k-local-old +XXXXXXXX.com ALTERNET 9504 950301 174.90 line-9504 +XXXXXXXX.com INTEREST 9502 950301 19.13 +XXXXXXXX.com PAYMENT 9503 950307 969.90 6408 +XXXXXXXX.com ALTERNET 9504 950316 3000.00 startup TCP-bt1-128k%5 +XXXXXXXX.com PAYMENT 9503 950327 969.90 6594 +XXXXXXXX.com ALTERNET 9505 950401 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9505 950401 556.60 line-9505 +XXXXXXXX.com EQUIPMENT 9504 950410 1595.00 cisco2501-1 +XXXXXXXX.com CREDADJ 9504 950417 503.50 TCP-56k-local +XXXXXXXX.com CREDADJ 9504 950417 116.60 line-9504 +XXXXXXXX.com ALTERNET 9504 950417 448.80 line-install +XXXXXXXX.com ALTERNET 9504 950417 752.02 TCP-bt1-128k%5 recon +XXXXXXXX.com ALTERNET 9504 950417 371.00 line-9504 recon +XXXXXXXX.com PAYMENT 9504 950424 3000.00 6841 +XXXXXXXX.com ALTERNET 9506 950501 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9506 950501 556.60 line-9506 +XXXXXXXX.com PAYMENT 9505 950505 2049.86 6985 +XXXXXXXX.com PAYMENT 9505 950531 3924.22 7179 +XXXXXXXX.com ALTERNET 9507 950601 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9507 950601 556.60 line-9507 +XXXXXXXX.com PAYMENT 9506 950607 1744.10 7232 +XXXXXXXX.com ALTERNET 9508 950701 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9508 950701 556.60 line-9508 +XXXXXXXX.com PAYMENT 9507 950705 1744.10 7641 +XXXXXXXX.com ALTERNET 9509 950801 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9509 950801 556.60 line-9509 +XXXXXXXX.com PAYMENT 9508 950803 1744.10 7914 +XXXXXXXX.com ALTERNET 9510 950901 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9510 950901 556.60 line-9510 +XXXXXXXX.com PAYMENT 9509 950905 1744.10 8203 +XXXXXXXX.com ALTERNET 9511 951001 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9511 951001 556.60 line-9511 +XXXXXXXX.com PAYMENT 9510 951003 1744.10 8508 +XXXXXXXX.com ALTERNET 9512 951101 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9512 951101 556.60 line-9512 +XXXXXXXX.com PAYMENT 9511 951103 2129.83 8837 +XXXXXXXX.com ALTERNET 9601 951201 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9601 951201 556.60 line-9601 +XXXXXXXX.com PAYMENT 9512 951204 2129.83 9131 +XXXXXXXX.com ALTERNET 9602 960101 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9602 960101 556.60 line-9602 +XXXXXXXX.com PAYMENT 9601 960103 1744.10 9456 +XXXXXXXX.com ALTERNET 9603 960201 1187.50 TCP-bt1-128k%5.00 +XXXXXXXX.com ALTERNET 9603 960201 556.60 line-9603 +XXXXXXXX.com PAYMENT 9602 960205 1358.37 9834 diff --git a/test/mtchi18n.awk b/test/mtchi18n.awk new file mode 100644 index 0000000..aac6545 --- /dev/null +++ b/test/mtchi18n.awk @@ -0,0 +1 @@ +{print match(""," *")} diff --git a/test/mtchi18n.in b/test/mtchi18n.in new file mode 100644 index 0000000..139597f --- /dev/null +++ b/test/mtchi18n.in @@ -0,0 +1,2 @@ + + diff --git a/test/mtchi18n.ok b/test/mtchi18n.ok new file mode 100644 index 0000000..6ed281c --- /dev/null +++ b/test/mtchi18n.ok @@ -0,0 +1,2 @@ +1 +1 diff --git a/test/nasty.awk b/test/nasty.awk new file mode 100644 index 0000000..b9c20c8 --- /dev/null +++ b/test/nasty.awk @@ -0,0 +1,92 @@ +#From hankedr@manatee.dms.auburn.edu Tue Oct 13 22:15:59 1998 +#Return-Path: +#Received: from cssun.mathcs.emory.edu (cssun.mathcs.emory.edu [170.140.150.1]) +# by dmx.netvision.net.il (8.9.0.Beta5/8.8.6) with ESMTP id PAA03924 +# for ; Tue, 13 Oct 1998 15:32:13 +0200 (IST) +#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) +#Received: from manatee.dms.auburn.edu (manatee.dms.auburn.edu [131.204.53.104]) +# by mescaline.gnu.org (8.9.1a/8.9.1) with ESMTP id KAA03250 +# for ; Tue, 13 Oct 1998 10:25:32 -0400 +#Received: (from hankedr@localhost) +# by manatee.dms.auburn.edu (8.9.1a/8.9.1) id JAA13348; +# Tue, 13 Oct 1998 09:22:29 -0500 (CDT) +#Date: Tue, 13 Oct 1998 09:22:29 -0500 (CDT) +#Message-Id: <199810131422.JAA13348@manatee.dms.auburn.edu> +#From: Darrel Hankerson +#To: arnold@gnu.org +#In-reply-to: <199810131313.QAA31784@alpha.netvision.net.il> (message from +# Aharon Robbins on Tue, 13 Oct 1998 16:10:36 +0200) +#Subject: Re: full text of bug report? +#Mime-Version: 1.0 +#Content-Type: text/plain; charset=US-ASCII +#X-UIDL: bf3fce492dad4ab030c561e7b2f27d0a +#Status: RO +# +# Do you have the full text of the a = a "\n" f() bug report? +# I can't find it.... I'm not sure there really is a bug. +# +#Yes, see below. +# +#His example has unnecessary fragments (in particular, the use of +#gensub is irrelevant). As I wrote to you earlier, the interesting +#question for me is: +# +# Is the concatenation result undefined? If the result is defined or +# implementation-dependent, then gawk has a bug. +# +# +#=== Original report ===================================================== +#From: Attila Torcsvari +#To: "'bug-gnu-utils@prep.ai.mit.edu'" +#Subject: gawk 3.0.3 bug +#Date: Thu, 17 Sep 1998 18:12:13 +0200 +#MIME-Version: 1.0 +#Content-Transfer-Encoding: 7bit +#Resent-From: bug-gnu-utils@gnu.org +#X-Mailing-List: archive/latest/3396 +#X-Loop: bug-gnu-utils@gnu.org +#Precedence: list +#Resent-Sender: bug-gnu-utils-request@gnu.org +#Content-Transfer-Encoding: 7bit +#Content-Type: text/plain; charset="us-ascii" +#Content-Length: 618 +# +#Bug-gnuers, +#please pass it to the responsible. +# +#The following generates something interesting: +# +BEGIN{ +a="aaaaa" +a=a a #10 +a=a a #20 +a=a a #40 +a=a a #80 +a=a a #160 +a=a a # i.e. a is long enough + +a=a"\n"f() # this causes the trouble +print a # guess the result +} + +function f() +{ +#print "a before: ", a +#a=gensub("a","123,","g",a) # 'a' will be just a bit longer (4 times, but still should fit: 4*160=640) +gsub(/a/, "123", a) +#print "a after: ", a +return "X" +} +# +#Possible reason: +#during f the a is modified, +#it can be even freed, because gensub modifies its size +#the printout contains trash. +# +#Used version: VC compiled WinNT 32 bit Intel. +# +#Regards, +# +#Attila Torcsvari +#Arcanum Development +# diff --git a/test/nasty.ok b/test/nasty.ok new file mode 100644 index 0000000..0ee1a73 --- /dev/null +++ b/test/nasty.ok @@ -0,0 +1,2 @@ +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +X diff --git a/test/nasty2.awk b/test/nasty2.awk new file mode 100644 index 0000000..cb0bd6d --- /dev/null +++ b/test/nasty2.awk @@ -0,0 +1,20 @@ +# Based on nasty.awk, test same thing for printf +# +BEGIN { +a="aaaaa" +a=a a #10 +a=a a #20 +a=a a #40 +a=a a #80 +a=a a #160 +a=a a # i.e. a is long enough + +printf("a = %s, f() = %s\n", a, f()) +print a +} + +function f() +{ +gsub(/a/, "123", a) +return "X" +} diff --git a/test/nasty2.ok b/test/nasty2.ok new file mode 100644 index 0000000..9b62bf0 --- /dev/null +++ b/test/nasty2.ok @@ -0,0 +1,2 @@ +a = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, f() = X +123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123123 diff --git a/test/nastyparm.awk b/test/nastyparm.awk new file mode 100644 index 0000000..a1f1c82 --- /dev/null +++ b/test/nastyparm.awk @@ -0,0 +1,41 @@ +function biz(baz, bar) +{ + print baz, bar +} + +function buz(baz, bar) +{ + print length(baz), bar +} + +function buz2(baz, baz1, bar, baz2) +{ + print length(baz), length(baz1), bar, length(baz2) + baz2[0] = "baz2" +# baz[0] = "baz" # fatal +} + +function buz3(baz) +{ + buz2(baz, baz, split("abc", baz, ""), baz) +} + + +BEGIN { + biz(foo, foo != "") + + biz(fy, fy = "fy") + + biz(fi = 10, fi = 20) + print fi + + buz(a, split("abc", a, "")) + + buz2(c, c, split("abc", c, ""), c) + print c[0], length(c) + + buz3(d) + print d[0], length(d) + + biz(b, split("abc", b, "")) +} diff --git a/test/nastyparm.ok b/test/nastyparm.ok new file mode 100644 index 0000000..c68a1c5 --- /dev/null +++ b/test/nastyparm.ok @@ -0,0 +1,11 @@ + 0 + fy +10 20 +20 +3 3 +3 3 3 3 +baz2 4 +3 3 3 3 +baz2 4 +gawk: nastyparm.awk:3: fatal: attempt to use array `baz (from b)' in a scalar context +EXIT CODE: 2 diff --git a/test/negexp.awk b/test/negexp.awk new file mode 100644 index 0000000..3b3a3c0 --- /dev/null +++ b/test/negexp.awk @@ -0,0 +1 @@ +BEGIN { a = -2; print 10^a } diff --git a/test/negexp.ok b/test/negexp.ok new file mode 100644 index 0000000..6e6566c --- /dev/null +++ b/test/negexp.ok @@ -0,0 +1 @@ +0.01 diff --git a/test/negrange.awk b/test/negrange.awk new file mode 100644 index 0000000..d70f730 --- /dev/null +++ b/test/negrange.awk @@ -0,0 +1,7 @@ +BEGIN { + s = "Volume 8, Numbers 1-2 / January 1971" + n = split(s, parts, "[^-A-Za-z0-9]+") + print "n =", n + for (i = 1; i <= n; i++) + printf("s[%d] = \"%s\"\n", i, parts[i]) +} diff --git a/test/negrange.ok b/test/negrange.ok new file mode 100644 index 0000000..57f4c8e --- /dev/null +++ b/test/negrange.ok @@ -0,0 +1,7 @@ +n = 6 +s[1] = "Volume" +s[2] = "8" +s[3] = "Numbers" +s[4] = "1-2" +s[5] = "January" +s[6] = "1971" diff --git a/test/nested.awk b/test/nested.awk new file mode 100644 index 0000000..5284b55 --- /dev/null +++ b/test/nested.awk @@ -0,0 +1,123 @@ +# From james@ruari-quinn.demon.co.uk Thu Jun 5 11:43:58 2003 +# Return-Path: +# Received: from localhost (skeeve [127.0.0.1]) +# by skeeve.com (8.12.5/8.12.5) with ESMTP id h558eVui012655 +# for ; Thu, 5 Jun 2003 11:43:58 +0300 +# Received: from actcom.co.il [192.114.47.1] +# by localhost with POP3 (fetchmail-5.9.0) +# for arnold@localhost (single-drop); Thu, 05 Jun 2003 11:43:58 +0300 (IDT) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Thu Jun 5 11:43:29 2003) +# X-From_: james@ruari-quinn.demon.co.uk Wed Jun 4 20:09:54 2003 +# Received: from smtp1.actcom.net.il by actcom.co.il with ESMTP +# (8.11.6/actcom-0.2) id h54H9oY05088 for ; +# Wed, 4 Jun 2003 20:09:52 +0300 (EET DST) +# (rfc931-sender: smtp.actcom.co.il [192.114.47.13]) +# Received: from f7.net (consort.superb.net [209.61.216.22]) +# by smtp1.actcom.net.il (8.12.8/8.12.8) with ESMTP id h54HB8To002721 +# for ; Wed, 4 Jun 2003 20:11:09 +0300 +# Received: from fencepost.gnu.org (fencepost.gnu.org [199.232.76.164]) +# by f7.net (8.11.7/8.11.6) with ESMTP id h54H9li15411 +# for ; Wed, 4 Jun 2003 13:09:47 -0400 +# Received: from monty-python.gnu.org ([199.232.76.173]) +# by fencepost.gnu.org with esmtp (Exim 4.20) +# id 19Nbli-0001kD-BL +# for bug-gawk@gnu.org; Wed, 04 Jun 2003 13:09:46 -0400 +# Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.20) +# id 19NbZ5-0004V2-71 +# for bug-gawk@gnu.org; Wed, 04 Jun 2003 12:56:43 -0400 +# Received: from cicero.e-mis.co.uk ([212.240.194.162]) +# by monty-python.gnu.org with esmtp (Exim 4.20) +# id 19NbYK-0003c7-AP +# for bug-gawk@gnu.org; Wed, 04 Jun 2003 12:55:56 -0400 +# Received: from [10.139.58.254] (helo=tacitus) +# by cicero.e-mis.co.uk with esmtp (Exim 3.35 #1 (Debian)) +# id 19NbWO-0007Qv-00 +# for ; Wed, 04 Jun 2003 17:53:56 +0100 +# Received: from james by tacitus with local (Exim 3.36 #1 (Debian)) +# id 19NbWO-0000cK-00 +# for ; Wed, 04 Jun 2003 17:53:56 +0100 +# To: bug-gawk@gnu.org +# Subject: 3.1.0 regression +# Mail-Copies-To: never +# From: James Troup +# User-Agent: Gnus/5.090017 (Oort Gnus v0.17) Emacs/20.7 (gnu/linux) +# Date: Wed, 04 Jun 2003 17:53:56 +0100 +# Message-ID: <874r35wzq3.fsf@nocrew.org> +# MIME-Version: 1.0 +# Content-Type: text/plain; charset=us-ascii +# Sender: James Troup +# X-Spam-Status: No, hits=-3.9 required=5.0 +# tests=EMAIL_ATTRIBUTION,SIGNATURE_SHORT_DENSE,SPAM_PHRASE_00_01, +# USER_AGENT +# version=2.41 +# X-Spam-Level: +# X-SpamBouncer: 1.4 (10/07/01) +# X-SBClass: OK +# Status: R +# +# Hi Aharon, +# +# This bug report comes from the Debian bug tracking system. You can +# view the full log at: +# +# http://bugs.debian.org/188345 +# +# Like my other bug, this is a regression from 3.1.0 and I've reproduced +# this problem with 3.1.2d. +# +# "Nikita V. Youshchenko" writes: +# +# | Package: gawk +# | Version: 1:3.1.2-2 +# | Severity: normal +# | Tags: sid +# | +# | After upgrading gawk from woody to sid, I found one of my scripts not +# | working. I explored this a little and found minimal script to reproduce +# | the problem. +# | +# | File bug.awk is the following: +# | +BEGIN { + WI_total = 0 +} +{ + WI_total++ + { + split ( $1, sws, "_" ) + a = sws[1] + } + print(sws[1]) + print(a) +} +# | +# | The second print should output the same what first print poutputs, but +# | with gawk 3.1.2-2 it outputs nothing: +# | > echo a_b | gawk -f bug.awk +# | a +# | +# | > +# | +# | With gawk from stable I get what expexted: +# | > echo a_b | gawk -f bug.awk +# | a +# | a +# | > +# | +# | If I remove "WI_total++" line, bug disapperas +# | +# | -- System Information: +# | Debian Release: 3.0 +# | Architecture: i386 +# | Kernel: Linux zigzag 2.4.19 16:49:13 MSK 2003 i686 +# | Locale: LANG=ru_RU.KOI8-R, LC_CTYPE=ru_RU.KOI8-R +# | +# | Versions of packages gawk depends on: +# | ii libc6 2.3.1-16 GNU C Library: Shared libraries an +# | +# | -- no debconf information +# +# -- +# James +# diff --git a/test/nested.in b/test/nested.in new file mode 100644 index 0000000..31b658b --- /dev/null +++ b/test/nested.in @@ -0,0 +1 @@ +a_b diff --git a/test/nested.ok b/test/nested.ok new file mode 100644 index 0000000..7e8a165 --- /dev/null +++ b/test/nested.ok @@ -0,0 +1,2 @@ +a +a diff --git a/test/next.ok b/test/next.ok new file mode 100644 index 0000000..0229bd0 --- /dev/null +++ b/test/next.ok @@ -0,0 +1,4 @@ +gawk: cmd. line:1: fatal: `next' cannot be called from a `BEGIN' rule +gawk: cmd. line:1: fatal: `next' cannot be called from a `END' rule +gawk: cmd. line:1: fatal: `next' cannot be called from a `BEGINFILE' rule +gawk: cmd. line:1: fatal: `next' cannot be called from a `ENDFILE' rule diff --git a/test/next.sh b/test/next.sh new file mode 100755 index 0000000..77354a2 --- /dev/null +++ b/test/next.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# next.sh --- test next invoked in various ways + +if [ "$AWK" = "" ] +then + echo $0: You must set AWK >&2 + exit 1 +fi + +# non-fatal +$AWK '{next}' /dev/null +$AWK 'function f() { next}; {f()}' /dev/null +# fatal +$AWK 'function f() { next}; BEGIN{f()}' +$AWK 'function f() { next}; {f()}; END{f()}' /dev/null +$AWK 'function f() { next}; BEGINFILE{f()}' +$AWK 'function f() { next}; {f()}; ENDFILE{f()}' /dev/null + +exit 0 # for make diff --git a/test/nfldstr.awk b/test/nfldstr.awk new file mode 100644 index 0000000..09b4a2b --- /dev/null +++ b/test/nfldstr.awk @@ -0,0 +1,13 @@ +$1 == 0 { + print "bug" +} +{ + $0 = "0" + if (!$0) + print "another bug" + $0 = a = "0" + if (!$0) + print "yet another bug" + if ($1) + print "a buggie" +} diff --git a/test/nfldstr.in b/test/nfldstr.in new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/test/nfldstr.in @@ -0,0 +1 @@ + diff --git a/test/nfldstr.ok b/test/nfldstr.ok new file mode 100644 index 0000000..e69de29 diff --git a/test/nfneg.awk b/test/nfneg.awk new file mode 100644 index 0000000..6d54ee0 --- /dev/null +++ b/test/nfneg.awk @@ -0,0 +1 @@ +BEGIN { NF -= 2 ; print } diff --git a/test/nfneg.ok b/test/nfneg.ok new file mode 100644 index 0000000..bcdb037 --- /dev/null +++ b/test/nfneg.ok @@ -0,0 +1,2 @@ +gawk: nfneg.awk:1: fatal: NF set to negative value +EXIT CODE: 2 diff --git a/test/nfset.awk b/test/nfset.awk new file mode 100644 index 0000000..09ebd08 --- /dev/null +++ b/test/nfset.awk @@ -0,0 +1 @@ +{ NF = 5 ; print } diff --git a/test/nfset.in b/test/nfset.in new file mode 100644 index 0000000..43329b5 --- /dev/null +++ b/test/nfset.in @@ -0,0 +1,5 @@ +1 2 +1 2 3 4 +1 2 3 4 5 +1 2 3 4 5 6 7 8 +1 diff --git a/test/nfset.ok b/test/nfset.ok new file mode 100644 index 0000000..3ba48ae --- /dev/null +++ b/test/nfset.ok @@ -0,0 +1,5 @@ +1 2 +1 2 3 4 +1 2 3 4 5 +1 2 3 4 5 +1 diff --git a/test/nlfldsep.awk b/test/nlfldsep.awk new file mode 100644 index 0000000..4fac81d --- /dev/null +++ b/test/nlfldsep.awk @@ -0,0 +1,2 @@ +BEGIN { RS = "A" } +{print NF; for (i = 1; i <= NF; i++) print $i ; print ""} diff --git a/test/nlfldsep.in b/test/nlfldsep.in new file mode 100644 index 0000000..7b2317f --- /dev/null +++ b/test/nlfldsep.in @@ -0,0 +1,5 @@ +some stuff +more stuffA +junk +stuffA +final diff --git a/test/nlfldsep.ok b/test/nlfldsep.ok new file mode 100644 index 0000000..6684916 --- /dev/null +++ b/test/nlfldsep.ok @@ -0,0 +1,13 @@ +4 +some +stuff +more +stuff + +2 +junk +stuff + +1 +final + diff --git a/test/nlinstr.awk b/test/nlinstr.awk new file mode 100644 index 0000000..f403715 --- /dev/null +++ b/test/nlinstr.awk @@ -0,0 +1,8 @@ +BEGIN { RS = "" } + +{ + if (/^@/) + print "not ok" + else + print "ok" +} diff --git a/test/nlinstr.in b/test/nlinstr.in new file mode 100644 index 0000000..65aaaf9 --- /dev/null +++ b/test/nlinstr.in @@ -0,0 +1,2 @@ +line 1 +@line 2 diff --git a/test/nlinstr.ok b/test/nlinstr.ok new file mode 100644 index 0000000..9766475 --- /dev/null +++ b/test/nlinstr.ok @@ -0,0 +1 @@ +ok diff --git a/test/nlstrina.awk b/test/nlstrina.awk new file mode 100644 index 0000000..41dbd5f --- /dev/null +++ b/test/nlstrina.awk @@ -0,0 +1,77 @@ +# From E.Ab@chem.rug.nl Wed Aug 2 13:16:53 2000 +# Received: from mail.actcom.co.il +# by localhost with POP3 (fetchmail-5.1.2) +# for arnold@localhost (single-drop); Wed, 02 Aug 2000 13:16:53 -0400 (EDT) +# Received: from lmail.actcom.co.il by actcom.co.il with ESMTP +# (8.9.1a/actcom-0.2) id MAA21699 for ; +# Wed, 2 Aug 2000 12:20:38 +0300 (EET DST) +# (rfc931-sender: lmail.actcom.co.il [192.114.47.13]) +# Received: from freefriends.org (freefriends.org [63.85.55.109]) +# by lmail.actcom.co.il (8.9.3/8.9.1) with ESMTP id LAA22723 +# for ; Wed, 2 Aug 2000 11:23:22 +0300 +# Received: from mescaline.gnu.org (mescaline.gnu.org [158.121.106.21]) +# by freefriends.org (8.9.3/8.9.3) with ESMTP id FAA23582 +# for ; Wed, 2 Aug 2000 05:18:59 -0400 +# Received: from dep.chem.rug.nl (dep.chem.rug.nl [129.125.7.81]) +# by mescaline.gnu.org (8.9.1a/8.9.1) with ESMTP id FAA30670; +# Wed, 2 Aug 2000 05:20:24 -0400 +# Received: from rugmd34.chem.rug.nl (rugmd34.chem.rug.nl [129.125.42.34]) +# by dep.chem.rug.nl (8.9.3/8.9.3/Debian 8.9.3-21) with ESMTP id LAA17089; +# Wed, 2 Aug 2000 11:20:23 +0200 +# 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) +# Sender: E.Ab@chem.rug.nl +# Message-ID: <3987E7D5.2BDC5FD3@chem.rug.nl> +# Date: Wed, 02 Aug 2000 11:20:21 +0200 +# From: Eiso AB +# X-Mailer: Mozilla 4.72C-SGI [en] (X11; I; IRIX 6.5 IP32) +# X-Accept-Language: en +# MIME-Version: 1.0 +# To: bug-gnu-utils@gnu.org, arnold@gnu.org +# Subject: bug? [GNU Awk 3.0.5] +# +# Content-Type: text/plain; charset=us-ascii +# Content-Transfer-Encoding: 7bit +# X-UIDL: \f8"!(8G!!ZL$#!h>X!! +# Status: R +# +# hi Arnold, +# +# +# Please try the script beneath... +# I'm not sure if this is a bug or not, but I would expect +# the empty string as an array index just to be treated +# like any other string +# +# so if ("" in ta) would be true, and for ( i in ta ) should loop only once. +# +BEGIN { + v="" + ta[v]++ + if ( v in ta) print "a",v,++ta[v],ta[v] + print "b",v,++ta[v],ta[v] + for( i in ta) print "c",++c,i,ta[i] +} +# +# goodluck, Eiso +# +# -- +# _________ +# _______________________________/ Eiso AB \_________________________ +# +# o +# +# o Dept. of Biochemistry +# University of Groningen +# The Netherlands +# o +# . . +# o ^ mailto:eiso@chem.rug.nl +# | - _ mailto:eiso@dds.nl +# \__|__/ http://md.chem.rug.nl/~eiso +# | tel 4326 +# | +# / \ +# / \ +# | | +# ________ ._| |_. ________________________________________________ +# diff --git a/test/nlstrina.ok b/test/nlstrina.ok new file mode 100644 index 0000000..690f1a2 --- /dev/null +++ b/test/nlstrina.ok @@ -0,0 +1,3 @@ +a 2 2 +b 3 3 +c 1 3 diff --git a/test/noeffect.awk b/test/noeffect.awk new file mode 100644 index 0000000..b67a5c5 --- /dev/null +++ b/test/noeffect.awk @@ -0,0 +1,5 @@ +BEGIN { + s == "hello, world"; + s + 1 + ;; +} diff --git a/test/noeffect.ok b/test/noeffect.ok new file mode 100644 index 0000000..e9bed99 --- /dev/null +++ b/test/noeffect.ok @@ -0,0 +1,4 @@ +gawk: noeffect.awk:2: warning: statement may have no effect +gawk: noeffect.awk:3: warning: statement may have no effect +gawk: noeffect.awk:2: warning: reference to uninitialized variable `s' +gawk: noeffect.awk:3: warning: reference to uninitialized variable `s' diff --git a/test/nofile.ok b/test/nofile.ok new file mode 100644 index 0000000..eff8c04 --- /dev/null +++ b/test/nofile.ok @@ -0,0 +1,2 @@ +gawk: fatal: cannot open file `no/such/file' for reading (No such file or directory) +EXIT CODE: 2 diff --git a/test/nofmtch.awk b/test/nofmtch.awk new file mode 100644 index 0000000..2ea2249 --- /dev/null +++ b/test/nofmtch.awk @@ -0,0 +1 @@ +BEGIN { printf "%3\n" } diff --git a/test/nofmtch.ok b/test/nofmtch.ok new file mode 100644 index 0000000..297d159 --- /dev/null +++ b/test/nofmtch.ok @@ -0,0 +1,2 @@ +gawk: nofmtch.awk:1: warning: [s]printf: format specifier does not have control letter +%3 diff --git a/test/noloop1.awk b/test/noloop1.awk new file mode 100644 index 0000000..ae461e3 --- /dev/null +++ b/test/noloop1.awk @@ -0,0 +1,70 @@ +# From jhart@avcnet.bates.edu Sun Oct 6 16:05:21 2002 +# Return-Path: +# Received: from localhost (skeeve [127.0.0.1]) +# by skeeve.com (8.11.6/8.11.6) with ESMTP id g96D5Jf28053 +# for ; Sun, 6 Oct 2002 16:05:21 +0300 +# Received: from actcom.co.il [192.114.47.1] +# by localhost with POP3 (fetchmail-5.9.0) +# for arnold@localhost (single-drop); Sun, 06 Oct 2002 16:05:21 +0300 (IDT) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Sun Oct 6 16:06:39 2002) +# X-From_: jhart@avcnet.bates.edu Sun Oct 6 15:31:59 2002 +# Received: from lmail.actcom.co.il by actcom.co.il with ESMTP +# (8.11.6/actcom-0.2) id g96CVrS27315 for ; +# Sun, 6 Oct 2002 15:31:54 +0300 (EET DST) +# (rfc931-sender: mail.actcom.co.il [192.114.47.13]) +# Received: from f7.net (consort.superb.net [209.61.216.22]) +# by lmail.actcom.co.il (8.11.6/8.11.6) with ESMTP id g96CVqY01629 +# for ; Sun, 6 Oct 2002 15:31:52 +0300 +# Received: from fencepost.gnu.org (fencepost.gnu.org [199.232.76.164]) +# by f7.net (8.11.6/8.11.6) with ESMTP id g96CVp418974 +# for ; Sun, 6 Oct 2002 08:31:51 -0400 +# Received: from monty-python.gnu.org ([199.232.76.173]) +# by fencepost.gnu.org with esmtp (Exim 4.10) +# id 17yAZa-00055o-00 +# for bug-gawk@gnu.org; Sun, 06 Oct 2002 08:31:50 -0400 +# Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) +# id 17yAZE-0007eB-00 +# for bug-gawk@gnu.org; Sun, 06 Oct 2002 08:31:29 -0400 +# Received: from avcnet.bates.edu ([134.181.128.62]) +# by monty-python.gnu.org with esmtp (Exim 4.10) +# id 17yAZ9-0007X3-00 +# for bug-gawk@gnu.org; Sun, 06 Oct 2002 08:31:23 -0400 +# Received: from a5514a.bates.edu (www.bates.edu [134.181.128.62]) +# by avcnet.bates.edu (8.9.3/8.9.3) with ESMTP id IAA05400 +# for ; Sun, 6 Oct 2002 08:31:20 -0400 +# Date: Sun, 6 Oct 2002 08:36:54 -0400 +# Mime-Version: 1.0 (Apple Message framework v482) +# Content-Type: text/plain; charset=US-ASCII; format=flowed +# Subject: Infinite loop in sub/gsub +# From: jhart@avcnet.bates.edu +# To: bug-gawk@gnu.org +# Content-Transfer-Encoding: 7bit +# Message-Id: <4BC4A4F0-D928-11D6-8E78-00039384A9CC@mail.avcnet.org> +# X-Mailer: Apple Mail (2.482) +# X-Spam-Status: No, hits=0.3 required=5.0 +# tests=NO_REAL_NAME,SPAM_PHRASE_00_01,USER_AGENT_APPLEMAIL +# version=2.41 +# X-Spam-Level: +# X-SpamBouncer: 1.4 (10/07/01) +# X-SBClass: OK +# Status: RO +# +# This command line: +# +# echo "''Italics with an apostrophe'' embedded''"|gawk -f test.awk +# +# where test.awk contains this instruction: +# +/''/ { sub(/''(.?[^']+)*''/, "&"); } +# +# puts gawk 3.11 into an infinite loop. Whereas, this command works: +# +# echo "''Italics with an apostrophe' embedded''"|gawk -f test.awk +# +# +# +# Platform: Mac OS X 10.1.5/Darwin Kernel Version 5.5: Thu May 30 14:51:26 +# PDT 2002; root:xnu/xnu-201.42.3.obj~1/RELEASE_PPC +# +# diff --git a/test/noloop1.in b/test/noloop1.in new file mode 100644 index 0000000..da2c2f2 --- /dev/null +++ b/test/noloop1.in @@ -0,0 +1 @@ +''Italics with an apostrophe'' embedded'' diff --git a/test/noloop1.ok b/test/noloop1.ok new file mode 100644 index 0000000..e69de29 diff --git a/test/noloop2.awk b/test/noloop2.awk new file mode 100644 index 0000000..ae461e3 --- /dev/null +++ b/test/noloop2.awk @@ -0,0 +1,70 @@ +# From jhart@avcnet.bates.edu Sun Oct 6 16:05:21 2002 +# Return-Path: +# Received: from localhost (skeeve [127.0.0.1]) +# by skeeve.com (8.11.6/8.11.6) with ESMTP id g96D5Jf28053 +# for ; Sun, 6 Oct 2002 16:05:21 +0300 +# Received: from actcom.co.il [192.114.47.1] +# by localhost with POP3 (fetchmail-5.9.0) +# for arnold@localhost (single-drop); Sun, 06 Oct 2002 16:05:21 +0300 (IDT) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Sun Oct 6 16:06:39 2002) +# X-From_: jhart@avcnet.bates.edu Sun Oct 6 15:31:59 2002 +# Received: from lmail.actcom.co.il by actcom.co.il with ESMTP +# (8.11.6/actcom-0.2) id g96CVrS27315 for ; +# Sun, 6 Oct 2002 15:31:54 +0300 (EET DST) +# (rfc931-sender: mail.actcom.co.il [192.114.47.13]) +# Received: from f7.net (consort.superb.net [209.61.216.22]) +# by lmail.actcom.co.il (8.11.6/8.11.6) with ESMTP id g96CVqY01629 +# for ; Sun, 6 Oct 2002 15:31:52 +0300 +# Received: from fencepost.gnu.org (fencepost.gnu.org [199.232.76.164]) +# by f7.net (8.11.6/8.11.6) with ESMTP id g96CVp418974 +# for ; Sun, 6 Oct 2002 08:31:51 -0400 +# Received: from monty-python.gnu.org ([199.232.76.173]) +# by fencepost.gnu.org with esmtp (Exim 4.10) +# id 17yAZa-00055o-00 +# for bug-gawk@gnu.org; Sun, 06 Oct 2002 08:31:50 -0400 +# Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) +# id 17yAZE-0007eB-00 +# for bug-gawk@gnu.org; Sun, 06 Oct 2002 08:31:29 -0400 +# Received: from avcnet.bates.edu ([134.181.128.62]) +# by monty-python.gnu.org with esmtp (Exim 4.10) +# id 17yAZ9-0007X3-00 +# for bug-gawk@gnu.org; Sun, 06 Oct 2002 08:31:23 -0400 +# Received: from a5514a.bates.edu (www.bates.edu [134.181.128.62]) +# by avcnet.bates.edu (8.9.3/8.9.3) with ESMTP id IAA05400 +# for ; Sun, 6 Oct 2002 08:31:20 -0400 +# Date: Sun, 6 Oct 2002 08:36:54 -0400 +# Mime-Version: 1.0 (Apple Message framework v482) +# Content-Type: text/plain; charset=US-ASCII; format=flowed +# Subject: Infinite loop in sub/gsub +# From: jhart@avcnet.bates.edu +# To: bug-gawk@gnu.org +# Content-Transfer-Encoding: 7bit +# Message-Id: <4BC4A4F0-D928-11D6-8E78-00039384A9CC@mail.avcnet.org> +# X-Mailer: Apple Mail (2.482) +# X-Spam-Status: No, hits=0.3 required=5.0 +# tests=NO_REAL_NAME,SPAM_PHRASE_00_01,USER_AGENT_APPLEMAIL +# version=2.41 +# X-Spam-Level: +# X-SpamBouncer: 1.4 (10/07/01) +# X-SBClass: OK +# Status: RO +# +# This command line: +# +# echo "''Italics with an apostrophe'' embedded''"|gawk -f test.awk +# +# where test.awk contains this instruction: +# +/''/ { sub(/''(.?[^']+)*''/, "&"); } +# +# puts gawk 3.11 into an infinite loop. Whereas, this command works: +# +# echo "''Italics with an apostrophe' embedded''"|gawk -f test.awk +# +# +# +# Platform: Mac OS X 10.1.5/Darwin Kernel Version 5.5: Thu May 30 14:51:26 +# PDT 2002; root:xnu/xnu-201.42.3.obj~1/RELEASE_PPC +# +# diff --git a/test/noloop2.in b/test/noloop2.in new file mode 100644 index 0000000..b5cb226 --- /dev/null +++ b/test/noloop2.in @@ -0,0 +1 @@ +''Italics with an apostrophe' embedded'' diff --git a/test/noloop2.ok b/test/noloop2.ok new file mode 100644 index 0000000..e69de29 diff --git a/test/nondec.awk b/test/nondec.awk new file mode 100644 index 0000000..a070c91 --- /dev/null +++ b/test/nondec.awk @@ -0,0 +1 @@ +BEGIN { print 0x81c3e8, 0x744018, 00.34 } diff --git a/test/nondec.ok b/test/nondec.ok new file mode 100644 index 0000000..8f0404a --- /dev/null +++ b/test/nondec.ok @@ -0,0 +1 @@ +8504296 7618584 0.34 diff --git a/test/nondec2.awk b/test/nondec2.awk new file mode 100644 index 0000000..681d283 --- /dev/null +++ b/test/nondec2.awk @@ -0,0 +1,104 @@ +# From arnold@f7.net Wed Jun 15 08:25:21 2005 +# Return-Path: +# Received: from localhost (skeeve [127.0.0.1]) +# by skeeve.com (8.12.11/8.12.11) with ESMTP id j5F5P3VC014658 +# for ; Wed, 15 Jun 2005 08:25:21 +0300 +# Received: from pop.012.net.il [84.95.5.221] +# by localhost with POP3 (fetchmail-6.2.5) +# for arnold@localhost (single-drop); Wed, 15 Jun 2005 08:25:21 +0300 (IDT) +# Received: from mtain2.012.net.il ([10.220.5.4]) +# by i_mss3.012.net.il (HyperSendmail v2004.12) +# with ESMTP id <0II300LQOPS7DA10@i_mss3.012.net.il> for arobbins@012.net.il; +# Wed, 15 Jun 2005 04:07:19 +0300 (IDT) +# Received: from VSCAN1 ([10.220.20.1]) +# by i_mtain2.012.net.il (HyperSendmail v2004.12) +# with ESMTP id <0II300ETQPS7IEZ4@i_mtain2.012.net.il> for arobbins@012.net.il +# (ORCPT arobbins@012.net.il); Wed, 15 Jun 2005 04:07:19 +0300 (IDT) +# Received: from i_mtain2.012.net.il ([10.220.5.4]) +# by VSCAN1 with InterScan Messaging Security Suite; Wed, +# 15 Jun 2005 04:03:15 +0300 +# Received: from f7.net ([209.61.216.22]) +# by i_mtain2.012.net.il (HyperSendmail v2004.12) +# with ESMTP id <0II300H7VPS5P1O2@i_mtain2.012.net.il> for arobbins@012.net.il; +# Wed, 15 Jun 2005 04:07:18 +0300 (IDT) +# Received: (from arnold@localhost) by f7.net (8.11.7-20030920/8.11.7) +# id j5F13DT21530 for arobbins@012.net.il; Tue, 14 Jun 2005 21:03:14 -0400 +# Received: from fencepost.gnu.org (fencepost.gnu.org [199.232.76.164]) +# by f7.net (8.11.7-20030920/8.11.7) with ESMTP id j5F136p21454 for +# ; Tue, 14 Jun 2005 21:03:06 -0400 +# Received: from monty-python.gnu.org ([199.232.76.173]) +# by fencepost.gnu.org with esmtp (Exim 4.34) +# id 1DiMJ6-0002fe-Av for bug-gawk@gnu.org; Tue, 14 Jun 2005 21:03:04 -0400 +# Received: from Debian-exim by monty-python.gnu.org with spam-scanned +# (Exim 4.34) id 1DiMIp-0003lM-I4 for bug-gawk@gnu.org; Tue, +# 14 Jun 2005 21:02:47 -0400 +# Received: from [66.187.233.31] (helo=mx1.redhat.com) +# by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) +# (Exim 4.34) id 1DiMIp-0003l4-8g for bug-gawk@gnu.org; Tue, +# 14 Jun 2005 21:02:47 -0400 +# Received: from int-mx1.corp.redhat.com +# (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) +# with ESMTP id j5F11EGn027669 for ; Tue, +# 14 Jun 2005 21:01:14 -0400 +# Received: from lacrosse.corp.redhat.com +# (lacrosse.corp.redhat.com [172.16.52.154]) by int-mx1.corp.redhat.com +# (8.11.6/8.11.6) with ESMTP id j5F11Eu01536 for ; Tue, +# 14 Jun 2005 21:01:14 -0400 +# Received: from [192.168.7.71] (vpn50-10.rdu.redhat.com [172.16.50.10]) +# by lacrosse.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j5F118s03225 for +# ; Tue, 14 Jun 2005 21:01:09 -0400 +# Date: Tue, 14 Jun 2005 17:57:55 -0700 +# From: Ulrich Drepper +# Subject: non-decimal variable parameters cause crashes +# To: bug-gawk@gnu.org +# Message-id: <42AF7D13.5010901@redhat.com> +# Organization: Red Hat, Inc. +# MIME-version: 1.0 +# Content-type: multipart/signed; micalg=pgp-sha1; +# protocol="application/pgp-signature"; +# boundary=------------enig9DEC74140126C224E7DE3E54 +# X-Accept-Language: en-us, en +# X-Enigmail-Version: 0.91.0.0 +# User-Agent: Mozilla Thunderbird 1.0.2-6 (X11/20050513) +# Original-recipient: rfc822;arobbins@012.net.il +# X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on skeeve.com +# X-Spam-Level: +# X-Spam-Status: No, hits=-4.3 required=5.0 tests=AWL,BAYES_00 autolearn=ham +# version=2.63 +# Status: R +# +# This is an OpenPGP/MIME signed message (RFC 2440 and 3156) +# --------------enig9DEC74140126C224E7DE3E54 +# Content-Type: text/plain; charset=UTF-8 +# Content-Transfer-Encoding: quoted-printable +# +# Running +# +# gawk --non-decimal-data -v a=3D0x1 'BEGIN { print a+0 }' +# +# currently crashes. More details including a patch at +# +# https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=3D160421 +# +# --=20 +# =E2=9E=A7 Ulrich Drepper =E2=9E=A7 Red Hat, Inc. =E2=9E=A7 444 Castro St = +# =E2=9E=A7 Mountain View, CA =E2=9D=96 +# +# +# --------------enig9DEC74140126C224E7DE3E54 +# Content-Type: application/pgp-signature; name="signature.asc" +# Content-Description: OpenPGP digital signature +# Content-Disposition: attachment; filename="signature.asc" +# +# -----BEGIN PGP SIGNATURE----- +# Version: GnuPG v1.4.1 (GNU/Linux) +# Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org +# +# iD8DBQFCr30T2ijCOnn/RHQRAp9LAKC+w/vhXW73ps1Pxcy+VGPrT1Su+ACguPnV +# VstZcFJgJ5GZ1YvDExsOZZI= +# =xmXh +# -----END PGP SIGNATURE----- +# +# --------------enig9DEC74140126C224E7DE3E54-- +# +BEGIN { print a+0 } diff --git a/test/nondec2.ok b/test/nondec2.ok new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/test/nondec2.ok @@ -0,0 +1 @@ +1 diff --git a/test/nonl.awk b/test/nonl.awk new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/test/nonl.awk @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/test/nonl.ok b/test/nonl.ok new file mode 100644 index 0000000..24bd9b7 --- /dev/null +++ b/test/nonl.ok @@ -0,0 +1 @@ +gawk: nonl.awk:1: warning: source file does not end in newline diff --git a/test/noparms.awk b/test/noparms.awk new file mode 100644 index 0000000..2c7ccc7 --- /dev/null +++ b/test/noparms.awk @@ -0,0 +1 @@ +function x(a, b, c , ,) {} diff --git a/test/noparms.ok b/test/noparms.ok new file mode 100644 index 0000000..504c4e4 --- /dev/null +++ b/test/noparms.ok @@ -0,0 +1,5 @@ +gawk: noparms.awk:1: function x(a, b, c , ,) {} +gawk: noparms.awk:1: ^ syntax error +gawk: noparms.awk:1: function x(a, b, c , ,) {} +gawk: noparms.awk:1: ^ syntax error +EXIT CODE: 1 diff --git a/test/nors.in b/test/nors.in new file mode 100644 index 0000000..f90d9ec --- /dev/null +++ b/test/nors.in @@ -0,0 +1 @@ +A B C D E \ No newline at end of file diff --git a/test/nors.ok b/test/nors.ok new file mode 100644 index 0000000..54d5aab --- /dev/null +++ b/test/nors.ok @@ -0,0 +1,2 @@ +E +E diff --git a/test/nulrsend.awk b/test/nulrsend.awk new file mode 100644 index 0000000..6b8cb8c --- /dev/null +++ b/test/nulrsend.awk @@ -0,0 +1,112 @@ +# From murata@nips.ac.jp Tue Aug 6 08:02:14 2002 +# Return-Path: +# Received: from localhost (aahz [127.0.0.1]) +# by skeeve.com (8.11.2/8.11.2) with ESMTP id g7652Ej01784 +# for ; Tue, 6 Aug 2002 08:02:14 +0300 +# Received: from actcom.co.il [192.114.47.1] +# by localhost with POP3 (fetchmail-5.7.4) +# for arnold@localhost (single-drop); Mon, 05 Aug 2002 22:02:14 -0700 (PDT) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Tue Aug 6 08:13:06 2002) +# X-From_: murata@nips.ac.jp Tue Aug 6 07:26:32 2002 +# Received: from lmail.actcom.co.il by actcom.co.il with ESMTP +# (8.11.6/actcom-0.2) id g764QTu27770 for ; +# Tue, 6 Aug 2002 07:26:30 +0300 (EET DST) +# (rfc931-sender: mail.actcom.co.il [192.114.47.13]) +# Received: from f7.net (consort.superb.net [209.61.216.22]) +# by lmail.actcom.co.il (8.11.6/8.11.6) with ESMTP id g764QRi04673 +# for ; Tue, 6 Aug 2002 07:26:28 +0300 +# Received: from fencepost.gnu.org (fencepost.gnu.org [199.232.76.164]) +# by f7.net (8.11.6/8.11.6) with ESMTP id g764QQ920486 +# for ; Tue, 6 Aug 2002 00:26:26 -0400 +# Received: from ccms.nips.ac.jp ([133.48.72.2]) +# by fencepost.gnu.org with smtp (Exim 3.35 #1 (Debian)) +# id 17bvvL-00011b-00 +# for ; Tue, 06 Aug 2002 00:26:23 -0400 +# Received: (from murata@localhost) +# by ccms.nips.ac.jp (8.9.3+3.2W/3.7W) id NAA01026; +# Tue, 6 Aug 2002 13:26:21 +0900 +# Date: Tue, 6 Aug 2002 13:26:21 +0900 +# Message-Id: <200208060426.NAA01026@ccms.nips.ac.jp> +# To: bug-gawk@gnu.org +# Cc: murata@nips.ac.jp +# Subject: Bug Report (gawk) +# From: murata@nips.ac.jp (MURATA Yasuhisa) +# Mime-Version: 1.0 +# Content-Type: text/plain; charset=US-ASCII +# X-Mailer: mnews [version 1.21PL5] 1999-04/04(Sun) +# +# Hello, I report a bug. +# +# +# == PROGRAM (filename: atest.awk) == +BEGIN { + RS="" +} + +NR==1 { + print 1 + RS="\n" + next +} + +NR==2 { + print 2 + RS="" + next +} + +NR==3 { + print 3 + RS="\n" + next +} +# ==== +# +# == DATA (filename: atest.txt) == +# 1111 +# +# 2222 +# +# ==== +# note: last line is "\n". +# +# +# == RUN (gawk) == +# > gawk -f atest.awk atest.txt +# 1 +# 2 +# (no stop!) +# ==== +# +# == RUN (nawk) == +# > nawk -f atest.awk atest.txt +# 1 +# 2 +# 3 +# ==== +# +# == VERSION == +# > gawk --version +# GNU Awk 3.1.1 +# Copyright (C) 1989, 1991-2002 Free Software Foundation. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# == +# +# -- +# MURATA Yasuhisa, Technical Staff +# National Institute for Physiological Sciences +# E-mail: murata@nips.ac.jp diff --git a/test/nulrsend.in b/test/nulrsend.in new file mode 100644 index 0000000..af3eba1 --- /dev/null +++ b/test/nulrsend.in @@ -0,0 +1,4 @@ +1111 + +2222 + diff --git a/test/nulrsend.ok b/test/nulrsend.ok new file mode 100644 index 0000000..1191247 --- /dev/null +++ b/test/nulrsend.ok @@ -0,0 +1,2 @@ +1 +2 diff --git a/test/numindex.awk b/test/numindex.awk new file mode 100644 index 0000000..1762e45 --- /dev/null +++ b/test/numindex.awk @@ -0,0 +1,55 @@ +#To: bug-gnu-utils@gnu.org +#cc: arnold@gnu.org +#Subject: Possible bug in GNU Awk 3.0.4 +#Date: Wed, 24 Nov 1999 21:47:24 +0000 +#From: Daniel Elphick +#Message-Id: +# +#This is a multipart MIME message. +# +#--==_Exmh_-11192982200 +#Content-Type: text/plain; charset=us-ascii +# +# +#When I use the attached awk script unique on the attached data file, it +#reports that all 4 lines of the data are the same. Using mawk it correctly +#reports that there are no repeats. +# +#I don't know if there are limits on the size of associative array keys for the +#purposes of reliable indexing but if there is then it is not (obviously) +#documented. +# +# +#--==_Exmh_-11192982200 +#Content-Type: text/plain ; name="data"; charset=us-ascii +#Content-Description: data +#Content-Disposition: attachment; filename="data" +# +#322322111111112232231111 +#322322111111112213223111 +#322322111111112211132231 +#322322111111112211113223 +# +#--==_Exmh_-11192982200 +#Content-Type: text/plain ; name="unique"; charset=us-ascii +#Content-Description: unique +#Content-Disposition: attachment; filename="unique" +# +{ + if($0 in a) + { + printf("line %d has been seen before at line %d\n", NR, a[$0]) + repeat_count += 1 + } + else + { + a[$0] = NR + } + count += 1 +} +END { +# printf("%d %f%%\n", repeat_count, (float)repeat_count / count * 100) + printf("%d %f%%\n", repeat_count, repeat_count / count * 100) +} +# +#--==_Exmh_-11192982200-- diff --git a/test/numindex.in b/test/numindex.in new file mode 100644 index 0000000..3852058 --- /dev/null +++ b/test/numindex.in @@ -0,0 +1,4 @@ +322322111111112232231111 +322322111111112213223111 +322322111111112211132231 +322322111111112211113223 diff --git a/test/numindex.ok b/test/numindex.ok new file mode 100644 index 0000000..8e086f6 --- /dev/null +++ b/test/numindex.ok @@ -0,0 +1 @@ +0 0.000000% diff --git a/test/numsubstr.awk b/test/numsubstr.awk new file mode 100644 index 0000000..7a30993 --- /dev/null +++ b/test/numsubstr.awk @@ -0,0 +1 @@ +{ print substr(1000+$1, 2) } diff --git a/test/numsubstr.in b/test/numsubstr.in new file mode 100644 index 0000000..ac65c36 --- /dev/null +++ b/test/numsubstr.in @@ -0,0 +1,3 @@ +5000 +10000 +5000 diff --git a/test/numsubstr.ok b/test/numsubstr.ok new file mode 100644 index 0000000..86ec13c --- /dev/null +++ b/test/numsubstr.ok @@ -0,0 +1,3 @@ +000 +1000 +000 diff --git a/test/octsub.awk b/test/octsub.awk new file mode 100644 index 0000000..65e9689 --- /dev/null +++ b/test/octsub.awk @@ -0,0 +1 @@ +BEGIN{ ++x[03]; print "/" x[0] "/" x[3] "/"} diff --git a/test/octsub.ok b/test/octsub.ok new file mode 100644 index 0000000..95cbdc7 --- /dev/null +++ b/test/octsub.ok @@ -0,0 +1 @@ +//1/ diff --git a/test/ofmt.awk b/test/ofmt.awk new file mode 100644 index 0000000..a7b63d6 --- /dev/null +++ b/test/ofmt.awk @@ -0,0 +1,53 @@ +# From dragon!knorke.saar.de!florian Wed Jul 16 10:47:27 1997 +# Return-Path: +# Message-ID: <19970716164451.63610@knorke.saar.de> +# Date: Wed, 16 Jul 1997 16:44:51 +0200 +# From: Florian La Roche +# To: bug-gnu-utils@prep.ai.mit.edu +# CC: arnold@gnu.ai.mit.edu +# Subject: bug in gawk 3.0.3 +# MIME-Version: 1.0 +# Content-Type: text/plain; charset=us-ascii +# X-Mailer: Mutt 0.76 +# Status: R +# Content-Length: 1725 +# X-Lines: 177 +# X-Display-Position: 0 +# +# I have a problem with gawk 3.0.3 on linux with libc 5.4.33. +# The memory is corrupted, if I use OFMT = "%.12g". +# With OFMT = "%.6g" evrything works fine, but I don't have enough +# digits for the computation. +# +# Thanks a lot, +# Florian La Roche +# +# Here is the sample awk-Script together with sample data: +# +BEGIN { + OFMT = "%.12g" + big = 99999999999 + lowest = big + small = 0 + highest = small + dir = "" + } +$0 ~ /^[0-9]+$/ { + # some old awks do not think $0 is numeric, so use $1 + if ($1 < lowest) + lowest = $1 + if ($1 > highest) + highest = $1 + next +} +$0 ~ /\/\.:$/ { + if (dir != "") { + if (highest != small) + print dir, highest, lowest + else + print dir, "-", "-" + } + dir = substr($0, 1, length($0)-3) # trim off /.: + lowest = big + highest = small +} diff --git a/test/ofmt.in b/test/ofmt.in new file mode 100644 index 0000000..6fffdfe --- /dev/null +++ b/test/ofmt.in @@ -0,0 +1,136 @@ +alt/binaries/warez/crypto/.: +.. +... + +alt/fan/douglas-adams/.: +.. +... +7478 +7479 +7480 +7481 +7482 +7483 +7484 +7485 +7486 +7490 +7488 +7489 +7491 +7407 +7408 +7409 +7410 +7411 +7412 +7413 +7414 +7415 +7416 +7417 +7418 +7419 +7420 +7421 +7422 +7423 +7424 +7425 +7426 +7427 +7428 +7429 +7430 +7431 +7432 +7433 +7434 +7435 +7436 +7437 +7438 +7439 +7440 +7441 +7442 +7443 +7444 +7445 +7446 +7447 +7455 +7449 +7450 +7451 +7452 +7453 +7454 +7456 +7457 +7458 +7459 +7460 +7461 +7462 +7463 +7464 +7465 +7466 +7467 +7468 +7469 +7470 +7471 +7472 +7473 +7475 +7477 + +alt/os/linux/.: +.. +... + + +alt/security/.: +.. +... +pgp +ripem +keydist +index +9617 +9618 +9619 +9620 +9625 +9621 +9626 +9622 +9623 +9624 +9627 +9628 +9629 +9630 +9631 +9632 +9633 +9634 +9636 +9637 +9638 +9639 +9640 +9641 + +alt/security/index/.: +.. +... + +alt/security/keydist/.: +.. +... +253 + +/.: diff --git a/test/ofmt.ok b/test/ofmt.ok new file mode 100644 index 0000000..389c1ef --- /dev/null +++ b/test/ofmt.ok @@ -0,0 +1,6 @@ +alt/binaries/warez/crypto - - +alt/fan/douglas-adams 7491 7407 +alt/os/linux - - +alt/security 9641 9617 +alt/security/index - - +alt/security/keydist 253 253 diff --git a/test/ofmta.awk b/test/ofmta.awk new file mode 100644 index 0000000..8f3bc6e --- /dev/null +++ b/test/ofmta.awk @@ -0,0 +1,30 @@ +# Date: Thu, 14 Apr 2011 08:18:55 -0500 +# From: j.eh@mchsi.com +# To: arnold@skeeve.com +# Subject: CONVFMT test for the test suite +# Message-ID: <20110414131855.GA1801@apollo> +# +# Hi, +# +# Please consider adding this to the test suite. 3.1.8 segfaults +# with this. +# +# Thanks, +# +# John +# +# +BEGIN { + i=1.2345 + i=3+i + a[i]="hi" + OFMT="%.1f" + print i + for (x in a) print x, a[x] + print a[i] + print "--------" + CONVFMT=OFMT="%.3f" + print i + for (x in a) print x, a[x] + print a[i] +} diff --git a/test/ofmta.ok b/test/ofmta.ok new file mode 100644 index 0000000..f050dc0 --- /dev/null +++ b/test/ofmta.ok @@ -0,0 +1,7 @@ +4.2 +4.2345 hi +hi +-------- +4.234 +4.2345 hi + diff --git a/test/ofmtbig.awk b/test/ofmtbig.awk new file mode 100644 index 0000000..df4f9bb --- /dev/null +++ b/test/ofmtbig.awk @@ -0,0 +1,126 @@ +# +# [USEMAP] +# +# Problem Report gnu/7821 +# +# awk in free(): warning: chunk is already free. +# +# Confidential +# no +# +# Severity +# serious +# +# Priority +# medium +# +# Responsible +# freebsd-bugs@freebsd.org +# +# State +# suspended +# +# Class +# sw-bug +# +# Submitter-Id +# current-users +# +# Arrival-Date +# Thu Sep 3 10:30:00 PDT 1998 +# +# Last-Modified +# Thu Sep 17 02:04:26 PDT 1998 +# +# Originator +# Alexander Litvin archer@lucky.net +# +# Organization +# +# +#Lucky Net ltd. +# +# Release +# FreeBSD 3.0-CURRENT i386 +# +# Environment +# +# +#FreeBSD grape.carrier.kiev.ua 3.0-CURRENT FreeBSD 3.0-CURRENT #121: Thu Sep 3 +#1 +#1:21:44 EEST 1998 archer@grape.carrier.kiev.ua:/usr/src/sys/compile/GRAPE +#i +#386 +# +# Description +# +# +#The problem first appeared when GNU awk in 3.0-CURRENT was apgraded to +#3.0.3. I run C-News, which uses awk extensively. After awk apgrade C-News +#expire stopped to work. It appeared that some GNU awk 3.0.3 programms when +#given absolutely legitimate input fail, giving out a number of messages: +# +#awk in free(): warning: chunk is already free. +# +# How-To-Repeat +# +# +#Run the following awk program (it is cut out of C-News expire scripts). +#I was not able to cut it down more -- omitting some portions of the +#code (e.g. OFMT line), make error go away in this case, though it +#certainly does not fix awk. +# +#----------------cut-here---------------- +#!/usr/bin/awk -f +BEGIN { + OFMT = "%.12g" + big = 99999999999 + lowest = big + small = 0 + highest = small +} + +$0 ~ /^[0-9]+$/ { + if ($1 < lowest) + lowest = $1 + if ($1 > highest) + highest = $1 + next +} + +# $0 ~ /^[a-z]+/ { +$0 ~ /^[[:lower:]]+/ { + print dir, highest, lowest + dir = $0 + lowest = big + highest = small +} +#----------------cut-here---------------- +# +#To get the error, just give this script the following input: +#----------------cut-here---------------- +#a +#1 +#b +#----------------cut-here---------------- +# +# Fix +# +# +#I was not able to track the error in awk sources. As a workaround, +#I just reverted to GNU awk 2.15.5. +# +# Audit-Trail +# +# +#State-Changed-From-To: open-suspended +#State-Changed-By: phk +#State-Changed-When: Thu Sep 17 02:04:08 PDT 1998 +#State-Changed-Why: +#reported to GNU maintainer. +# +# Submit Followup +# _________________________________________________________________ +# +# +# www@freebsd.org diff --git a/test/ofmtbig.in b/test/ofmtbig.in new file mode 100644 index 0000000..f1e80ce --- /dev/null +++ b/test/ofmtbig.in @@ -0,0 +1,3 @@ +a +1 +b diff --git a/test/ofmtbig.ok b/test/ofmtbig.ok new file mode 100644 index 0000000..0fe9251 --- /dev/null +++ b/test/ofmtbig.ok @@ -0,0 +1,2 @@ + 0 99999999999 +a 1 1 diff --git a/test/ofmtfidl.awk b/test/ofmtfidl.awk new file mode 100644 index 0000000..181e071 --- /dev/null +++ b/test/ofmtfidl.awk @@ -0,0 +1,85 @@ +# From djones@zoonami.com Wed Jun 13 17:46:27 2001 +# Received: from mail.actcom.co.il [192.114.47.13] +# by localhost with POP3 (fetchmail-5.5.0) +# for arnold@localhost (single-drop); Wed, 13 Jun 2001 17:46:27 +0300 (IDT) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Wed Jun 13 17:47:09 2001) +# X-From_: djones@zoonami.com Wed Jun 13 17:45:40 2001 +# Received: from lmail.actcom.co.il by actcom.co.il with ESMTP +# (8.9.1a/actcom-0.2) id RAA07057 for ; +# Wed, 13 Jun 2001 17:45:34 +0300 (EET DST) +# (rfc931-sender: mail.actcom.co.il [192.114.47.13]) +# Received: from billohost.com (www.billohost.com [209.196.35.10]) +# by lmail.actcom.co.il (8.11.2/8.11.2) with ESMTP id f5DEjSO24028 +# for ; Wed, 13 Jun 2001 17:45:33 +0300 +# Received: from fencepost.gnu.org (fencepost.gnu.org [199.232.76.164]) +# by billohost.com (8.9.3/8.9.3) with ESMTP id KAA24625 +# for ; Wed, 13 Jun 2001 10:44:43 -0400 +# Received: from topcat.zoonami.com ([193.112.141.198]) +# by fencepost.gnu.org with esmtp (Exim 3.16 #1 (Debian)) +# id 15ABtZ-0000FQ-00 +# for ; Wed, 13 Jun 2001 10:45:21 -0400 +# Received: from topcat.zoonami.com (localhost [127.0.0.1]) +# by topcat.zoonami.com (8.9.3/8.9.3) with ESMTP id OAA28329; +# Wed, 13 Jun 2001 14:45:54 GMT +# (envelope-from djones@topcat.zoonami.com) +# Message-Id: <200106131445.OAA28329@topcat.zoonami.com> +# To: bug-gawk@gnu.org +# cc: David Jones +# Subject: 3.1.0 core dumps. Fiddling with OFMT? +# Date: Wed, 13 Jun 2001 14:45:54 +0000 +# From: David Jones +# Status: R +# +# The following program causes gawk to dump core: +# +# jot 10|./gawk '{OFMT="%."NR"f";print NR}' +# +# 'jot 10', if you didn't know, produces the numbers 1 to 10 each on its +# own line (ie it's like awk 'BEGIN{for(i=1;i<=10;++i)print i}') +# +# Here's an example run: +# +# -- run being +# 1 +# 2 +# 3 +# 4 +# gawk: cmd. line:1: (FILENAME=- FNR=5) fatal error: internal error +# Abort trap - core dumped +# -- run end +# +# Ah. print NR appears to be not interesting. The following program also +# has the same problem: +# +# jot 10|./gawk '{OFMT="%."NR"f"}' +# +# Cheers, +# djones +# (version info follows) +# +# I'm running on FreeBSD 4.1, here's the output of uname -a +# +# 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 +# +# And ./gnu --version +# +# GNU Awk 3.1.0 +# Copyright (C) 1989, 1991-2001 Free Software Foundation. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# +{ OFMT="%."NR"f"; print NR } diff --git a/test/ofmtfidl.in b/test/ofmtfidl.in new file mode 100644 index 0000000..f00c965 --- /dev/null +++ b/test/ofmtfidl.in @@ -0,0 +1,10 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 diff --git a/test/ofmtfidl.ok b/test/ofmtfidl.ok new file mode 100644 index 0000000..f00c965 --- /dev/null +++ b/test/ofmtfidl.ok @@ -0,0 +1,10 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 diff --git a/test/ofmts.awk b/test/ofmts.awk new file mode 100644 index 0000000..6ee3705 --- /dev/null +++ b/test/ofmts.awk @@ -0,0 +1,2 @@ +BEGIN { OFMT= "%s" } +{ $1 + $2; print $1, $2 } diff --git a/test/ofmts.in b/test/ofmts.in new file mode 100644 index 0000000..50c37ec --- /dev/null +++ b/test/ofmts.in @@ -0,0 +1 @@ +1.2 2.2 diff --git a/test/ofmts.ok b/test/ofmts.ok new file mode 100644 index 0000000..50c37ec --- /dev/null +++ b/test/ofmts.ok @@ -0,0 +1 @@ +1.2 2.2 diff --git a/test/onlynl.awk b/test/onlynl.awk new file mode 100644 index 0000000..97a8d94 --- /dev/null +++ b/test/onlynl.awk @@ -0,0 +1,2 @@ +BEGIN { RS = "" } +{ print "got", $0 } diff --git a/test/onlynl.in b/test/onlynl.in new file mode 100644 index 0000000..fd40910 --- /dev/null +++ b/test/onlynl.in @@ -0,0 +1,4 @@ + + + + diff --git a/test/onlynl.ok b/test/onlynl.ok new file mode 100644 index 0000000..e69de29 diff --git a/test/opasnidx.awk b/test/opasnidx.awk new file mode 100644 index 0000000..e398860 --- /dev/null +++ b/test/opasnidx.awk @@ -0,0 +1 @@ +BEGIN { b = 1; a[b] = 2; a[b++] += 1; print b,a[1] } diff --git a/test/opasnidx.ok b/test/opasnidx.ok new file mode 100644 index 0000000..654d526 --- /dev/null +++ b/test/opasnidx.ok @@ -0,0 +1 @@ +2 3 diff --git a/test/opasnslf.awk b/test/opasnslf.awk new file mode 100644 index 0000000..46cd2b8 --- /dev/null +++ b/test/opasnslf.awk @@ -0,0 +1,6 @@ +BEGIN { + print b += b += 1 + b = 6 + print b += b++ + print b +} diff --git a/test/opasnslf.ok b/test/opasnslf.ok new file mode 100644 index 0000000..2fa9fd5 --- /dev/null +++ b/test/opasnslf.ok @@ -0,0 +1,3 @@ +2 +13 +13 diff --git a/test/out1.ok b/test/out1.ok new file mode 100644 index 0000000..f54b2b4 --- /dev/null +++ b/test/out1.ok @@ -0,0 +1 @@ +Goes to a file out1 diff --git a/test/out2.ok b/test/out2.ok new file mode 100644 index 0000000..66b7d2f --- /dev/null +++ b/test/out2.ok @@ -0,0 +1,2 @@ +Normal print statement +This printed on stdout diff --git a/test/out3.ok b/test/out3.ok new file mode 100644 index 0000000..7eb822f --- /dev/null +++ b/test/out3.ok @@ -0,0 +1 @@ +You blew it! diff --git a/test/paramdup.awk b/test/paramdup.awk new file mode 100644 index 0000000..1f1cc7a --- /dev/null +++ b/test/paramdup.awk @@ -0,0 +1,8 @@ +BEGIN { foo(0, 1, 2) } + +function foo(a, b, c, b, a) +{ + print "a =", a + print "b =", b + print "c =", c +} diff --git a/test/paramdup.ok b/test/paramdup.ok new file mode 100644 index 0000000..cd71822 --- /dev/null +++ b/test/paramdup.ok @@ -0,0 +1,3 @@ +gawk: paramdup.awk:3: error: function `foo': parameter #4, `b', duplicates parameter #2 +gawk: paramdup.awk:3: error: function `foo': parameter #5, `a', duplicates parameter #1 +EXIT CODE: 1 diff --git a/test/paramres.awk b/test/paramres.awk new file mode 100644 index 0000000..e2f1892 --- /dev/null +++ b/test/paramres.awk @@ -0,0 +1,6 @@ +BEGIN { foo() } + +function foo(a, FS, q) +{ + print "a =", a +} diff --git a/test/paramres.ok b/test/paramres.ok new file mode 100644 index 0000000..0687f92 --- /dev/null +++ b/test/paramres.ok @@ -0,0 +1,2 @@ +gawk: paramres.awk:3: error: function `foo': can't use special variable `FS' as a function parameter +EXIT CODE: 1 diff --git a/test/paramtyp.awk b/test/paramtyp.awk new file mode 100644 index 0000000..58848bb --- /dev/null +++ b/test/paramtyp.awk @@ -0,0 +1,20 @@ +# Sun Apr 25 13:28:58 IDT 1999 +# from Juegen Khars. This program should not core dump. + function ReadPGM(f, d) { +print "ReadPGM" + d[1] = 1 + } + + function WritePGM(f, d) { +print "WritePGM" + d[1] = 0 + } + + BEGIN { +print "before ReadPGM" + ReadPGM("", d) +print "after ReadPGM" +print "before WritePGM" + WritePGM("", d) +print "after WritePGM" + } diff --git a/test/paramtyp.ok b/test/paramtyp.ok new file mode 100644 index 0000000..793f857 --- /dev/null +++ b/test/paramtyp.ok @@ -0,0 +1,6 @@ +before ReadPGM +ReadPGM +after ReadPGM +before WritePGM +WritePGM +after WritePGM diff --git a/test/parse1.awk b/test/parse1.awk new file mode 100644 index 0000000..84906c4 --- /dev/null +++ b/test/parse1.awk @@ -0,0 +1,35 @@ +# Date: Fri, 06 Jan 2006 14:02:17 -0800 +# From: Paul Eggert +# Subject: gawk misparses $expr++ if expr ends in ++ +# To: bug-gawk@gnu.org +# Message-id: <87irsxypzq.fsf@penguin.cs.ucla.edu> +# +# Here's an example of the problem: +# +# $ gawk 'BEGIN{a=3}{print $$a++++}' +# gawk: {print $$a++++} +# gawk: ^ syntax error +# +# But it's not a syntax error, as the expression conforms to the POSIX +# spec: it should be treated like '$($a++)++'. +# +# Mawk, Solaris awk (old awk), and Solaris nawk all accept the +# expression. For example: +# +# $ echo '3 4 5 6 7 8 9' | nawk 'BEGIN{a=3}{print $$a++++}' +# 7 +# +# This is with gawk 3.1.5 on Solaris 8 (sparc). +# +# +# ##################################################################################### +# This Mail Was Scanned by 012.net AntiVirus Service1- Powered by TrendMicro Interscan +# +BEGIN { a = 3 } + +{ + print "in:", $0 + print "a =", a + print $$a++++ + print "out:", $0 +} diff --git a/test/parse1.in b/test/parse1.in new file mode 100644 index 0000000..4a001d7 --- /dev/null +++ b/test/parse1.in @@ -0,0 +1 @@ +3 4 5 6 7 8 9 diff --git a/test/parse1.ok b/test/parse1.ok new file mode 100644 index 0000000..a452e60 --- /dev/null +++ b/test/parse1.ok @@ -0,0 +1,4 @@ +in: 3 4 5 6 7 8 9 +a = 3 +7 +out: 3 4 6 6 8 8 9 diff --git a/test/parsefld.awk b/test/parsefld.awk new file mode 100644 index 0000000..0dd2f91 --- /dev/null +++ b/test/parsefld.awk @@ -0,0 +1,2 @@ +{ print $/= b/ c /= d/ } +{ print /a/ + /b/ + !/c/} diff --git a/test/parsefld.in b/test/parsefld.in new file mode 100644 index 0000000..959d682 --- /dev/null +++ b/test/parsefld.in @@ -0,0 +1 @@ +a = b diff --git a/test/parsefld.ok b/test/parsefld.ok new file mode 100644 index 0000000..8d0316f --- /dev/null +++ b/test/parsefld.ok @@ -0,0 +1,2 @@ +a0 +3 diff --git a/test/parseme.awk b/test/parseme.awk new file mode 100644 index 0000000..4d6ba94 --- /dev/null +++ b/test/parseme.awk @@ -0,0 +1 @@ +BEGIN { toupper(substr*line,1,12)) } diff --git a/test/parseme.ok b/test/parseme.ok new file mode 100644 index 0000000..b13fcac --- /dev/null +++ b/test/parseme.ok @@ -0,0 +1,5 @@ +gawk: parseme.awk:1: BEGIN { toupper(substr*line,1,12)) } +gawk: parseme.awk:1: ^ syntax error +gawk: parseme.awk:1: BEGIN { toupper(substr*line,1,12)) } +gawk: parseme.awk:1: ^ 2 is invalid as number of arguments for toupper +EXIT CODE: 1 diff --git a/test/patsplit.awk b/test/patsplit.awk new file mode 100644 index 0000000..af2813a --- /dev/null +++ b/test/patsplit.awk @@ -0,0 +1,26 @@ +BEGIN { + FALSE = 0 + TRUE = 1 + + fpat[1] = "([^,]*)|(\"[^\"]+\")" + fpat[2] = fpat[1] + fpat[3] = fpat[1] + fpat[4] = "aa+" + fpat[5] = fpat[4] + + data[1] = "Robbins,,Arnold," + data[2] = "Smith,,\"1234 A Pretty Place, NE\",Sometown,NY,12345-6789,USA" + data[3] = "Robbins,Arnold,\"1234 A Pretty Place, NE\",Sometown,NY,12345-6789,USA" + data[4] = "bbbaaacccdddaaaaaqqqq" + data[5] = "bbbaaacccdddaaaaaqqqqa" # should get trailing qqqa + + for (j = 1; j in data; j++) { + printf("Splitting: <%s>\n", data[j]) + n = patsplit(data[j], fields, fpat[j], seps) + print "n =", n + for (i = 1; i <= n; i++) + printf("fields[%d] = <%s>\n", i, fields[i]) + for (i = 0; i in seps; i++) + printf("seps[%s] = <%s>\n", i, seps[i]) + } +} diff --git a/test/patsplit.ok b/test/patsplit.ok new file mode 100644 index 0000000..cda8319 --- /dev/null +++ b/test/patsplit.ok @@ -0,0 +1,56 @@ +Splitting: +n = 4 +fields[1] = +fields[2] = <> +fields[3] = +fields[4] = <> +seps[0] = <> +seps[1] = <,> +seps[2] = <,> +seps[3] = <,> +Splitting: +n = 7 +fields[1] = +fields[2] = <> +fields[3] = <"1234 A Pretty Place, NE"> +fields[4] = +fields[5] = +fields[6] = <12345-6789> +fields[7] = +seps[0] = <> +seps[1] = <,> +seps[2] = <,> +seps[3] = <,> +seps[4] = <,> +seps[5] = <,> +seps[6] = <,> +Splitting: +n = 7 +fields[1] = +fields[2] = +fields[3] = <"1234 A Pretty Place, NE"> +fields[4] = +fields[5] = +fields[6] = <12345-6789> +fields[7] = +seps[0] = <> +seps[1] = <,> +seps[2] = <,> +seps[3] = <,> +seps[4] = <,> +seps[5] = <,> +seps[6] = <,> +Splitting: +n = 2 +fields[1] = +fields[2] = +seps[0] = +seps[1] = +seps[2] = +Splitting: +n = 2 +fields[1] = +fields[2] = +seps[0] = +seps[1] = +seps[2] = diff --git a/test/pcntplus.awk b/test/pcntplus.awk new file mode 100644 index 0000000..13999ac --- /dev/null +++ b/test/pcntplus.awk @@ -0,0 +1 @@ +BEGIN { printf "%+d %d\n", 3, 4 } diff --git a/test/pcntplus.ok b/test/pcntplus.ok new file mode 100644 index 0000000..b790269 --- /dev/null +++ b/test/pcntplus.ok @@ -0,0 +1 @@ ++3 4 diff --git a/test/pid.awk b/test/pid.awk new file mode 100644 index 0000000..35cc03d --- /dev/null +++ b/test/pid.awk @@ -0,0 +1,49 @@ +# From: John C. Oppenheimer +# Subject: gawk-3.0.2 pid test +# To: arnold@skeeve.atl.ga.us +# Date: Mon, 10 Feb 1997 08:31:55 -0600 (CST) +# +# Thanks for the very quick reply. +# +# This all started when I was looking for how to do the equivalent of +# "nextfile." I was after documentation and found our gawk down a few +# revs. +# +# Looks like the nextfile functionality was added somewhere around +# 2.15.5. There wasn't a way to do it, until now! Thanks for the +# functionality! +# +# Saw the /dev/xxx capability and just tried it. +# +# Anyway, I wrote a pid test. I hope that it is portable. Wanted to +# make a user test, but looks like id(1) is not very portable. But a +# little test is better than none. +# +# John +# +# pid.ok is a zero length file +# +# ================== pid.awk ============ +BEGIN { +# getline pid <"/dev/pid" +# getline ppid <"/dev/ppid" +# 12/2001: switch to PROCINFO. ADR + pid = PROCINFO["pid"] + ppid = PROCINFO["ppid"] + + if (pid != ok_pid) + printf "Bad pid %d, wanted %d\n", pid, ok_pid + else + print "PID ok" + + if (ppid != ok_ppid) + printf "Bad ppid %d, wanted %d\n", ppid, ok_ppid + else + print "PPID ok" + + # ADR --- added +# close("/dev/pid") +# close("/dev/ppid") + + print "All Done." +} diff --git a/test/pid.ok b/test/pid.ok new file mode 100644 index 0000000..a700d10 --- /dev/null +++ b/test/pid.ok @@ -0,0 +1,3 @@ +PID ok +PPID ok +All Done. diff --git a/test/pid.sh b/test/pid.sh new file mode 100755 index 0000000..da49afd --- /dev/null +++ b/test/pid.sh @@ -0,0 +1,3 @@ +#! /bin/sh +AWK=${AWK-../gawk} +exec $AWK -v "ok_pid=$$" -v "ok_ppid=$1" -f pid.awk 2>/dev/null diff --git a/test/pipeio1.awk b/test/pipeio1.awk new file mode 100644 index 0000000..66f50ad --- /dev/null +++ b/test/pipeio1.awk @@ -0,0 +1,31 @@ +# From dragon!gamgee.acad.emich.edu!dhw Tue Mar 18 01:12:15 1997 +# Return-Path: +# Message-ID: +# Date: Mon, 17 Mar 97 20:48 CST +# From: dhw@gamgee.acad.emich.edu (David H. West) +# To: arnold@gnu.ai.mit.edu +# Subject: gawk 3.0.2 bug report (cc of msg to bug-gnu-utils) +# Status: OR +# Content-Length: 869 +# X-Lines: 20 +# X-Display-Position: 2 +# +# Nature of bug: operation on a pipe side-effects a different pipe. +# Observed-With: gawk 3.0.2, Linux kernel 2.0.28 +# Reproduce-By: running the following script, without and with the "close" +# statement uncommented. +# -----------------cut here-------------------------- +BEGIN {FILE1="test1"; FILE2="test2"; + print "1\n" > FILE1; close(FILE1); + print "2\n" > FILE2; close(FILE2); + cmd1="cat " FILE1; cmd2="cat " FILE2; + #end of preparing commands which give easily-predictable output + + while( (cmd1 | getline)==1) { #terminates as file has only 1 line + #and we never close cmd1 + cmd2 | getline L; + #BUG: uncommenting the following line causes an infinite loop + close(cmd2); + print $0,L; + } + } diff --git a/test/pipeio1.ok b/test/pipeio1.ok new file mode 100644 index 0000000..706b09e --- /dev/null +++ b/test/pipeio1.ok @@ -0,0 +1,2 @@ +1 2 + 2 diff --git a/test/pipeio2.awk b/test/pipeio2.awk new file mode 100644 index 0000000..a4cd3bf --- /dev/null +++ b/test/pipeio2.awk @@ -0,0 +1,72 @@ +# From: megaadm@rina.quantum.de +# Subject: Bug report - closing down pipes which read from shell com +# To: bug-gnu-utils@prep.ai.mit.edu +# Date: Thu, 27 Feb 1997 23:19:16 +0100 (CET) +# CC: arnold@gnu.ai.mit.edu +# +# Hello people, +# +# i think i found a bug or something mysterious behaviour in +# gawk Version 3.0 patchlevel 0. +# +# I am running on linux 2.0.25 under bash. +# +# Could you please have a look at the following awk program +# an let me please know, if this is what i expect it to, +# namely a bug. +# +# ----------- cut here -------------------------------------------- +BEGIN { + # OS is linux 2.0.25 + # shell is bash + # Gnu Awk (gawk) 3.0, patchlevel 0 + # The command i typed on the shell was "gawk -f -" + + #com = "cal 01 1997" + com = ("cat " SRCDIR "/pipeio2.in") + + # Don't use empty lines, because Windows ECHO does + # something different when invoked without arguments + while ((com | getline fnam) > 0 && fnam != "") { + +# com_tr = "echo " fnam " | tr [0-9]. ..........." +# com_tr = "echo " fnam " | sed 's/[0-9]/./g'" + com_tr = "echo " fnam " | sed \"s/[0-9]/./g\"" + # print "\'" com_tr "\'" + print "'" com_tr "'" + + com_tr | getline nam + print nam + + # please run that program and take a look at the + # output. I think this is what was expected. + + # Then comment in the following 4 lines and see + # what happens. I expect the first pipe "com | getline" + # not to be close, but i think this is exactly what happens + # So, is this ok ? + + if (close(com_tr) < 0) { + print ERRNO + break + } + } + + close(com) + } +# ----------- cut here -------------------------------------------- +# +# There is another thing i do not understand. +# Why doesn't the awk - command "close" reports an +# error, if i would say close("abc") which i had never +# openend ? +# +# Regards, +# Ulrich Gvbel +# -- +# /********************************************************\ +# * Ulrich Gvbel, goebel@quantum.de * +# * Quantum Gesellschaft f|r Software mbH, Dortmund * +# * phone : +49-231-9749-201 fax: +49-231-9749-3 * +# * private: +49-231-803994 fax: +49-231-803994 * +# \********************************************************/ diff --git a/test/pipeio2.in b/test/pipeio2.in new file mode 100644 index 0000000..2652b0e --- /dev/null +++ b/test/pipeio2.in @@ -0,0 +1,8 @@ + January 1997 + S M Tu W Th F S + 1 2 3 4 + 5 6 7 8 9 10 11 +12 13 14 15 16 17 18 +19 20 21 22 23 24 25 +26 27 28 29 30 31 + diff --git a/test/pipeio2.ok b/test/pipeio2.ok new file mode 100644 index 0000000..4514fbb --- /dev/null +++ b/test/pipeio2.ok @@ -0,0 +1,14 @@ +'echo January 1997 | sed "s/[0-9]/./g"' +January .... +'echo S M Tu W Th F S | sed "s/[0-9]/./g"' +S M Tu W Th F S +'echo 1 2 3 4 | sed "s/[0-9]/./g"' +. . . . +'echo 5 6 7 8 9 10 11 | sed "s/[0-9]/./g"' +. . . . . .. .. +'echo 12 13 14 15 16 17 18 | sed "s/[0-9]/./g"' +.. .. .. .. .. .. .. +'echo 19 20 21 22 23 24 25 | sed "s/[0-9]/./g"' +.. .. .. .. .. .. .. +'echo 26 27 28 29 30 31 | sed "s/[0-9]/./g"' +.. .. .. .. .. .. diff --git a/test/posix.awk b/test/posix.awk new file mode 100644 index 0000000..79474f3 --- /dev/null +++ b/test/posix.awk @@ -0,0 +1,69 @@ +BEGIN { + a = "+2"; b = 2; c = "+2a"; d = "+2 "; e = " 2" + + printf "Test #1: " + if (b == a) print "\"" a "\"" " compares as a number" + else print "\"" a "\"" " compares as a string" + + printf "Test #2: " + if (b == c) print "\"" c "\"" " compares as a number" + else print "\"" c "\"" " compares as a string" + + printf "Test #3: " + if (b == d) print "\"" d "\"" " compares as a number" + else print "\"" d "\"" " compares as a string" + + printf "Test #4: " + if (b == e) print "\"" e "\"" " compares as a number" + else print "\"" e "\"" " compares as a string" + + f = a + b + c + d + e + print "after addition" + + printf "Test #5: " + if (b == a) print "\"" a "\"" " compares as a number" + else print "\"" a "\"" " compares as a string" + + printf "Test #6: " + if (b == c) print "\"" c "\"" " compares as a number" + else print "\"" c "\"" " compares as a string" + + printf "Test #7: " + if (b == d) print "\"" d "\"" " compares as a number" + else print "\"" d "\"" " compares as a string" + + printf "Test #8: " + if (b == e) print "\"" e "\"" " compares as a number" + else print "\"" e "\"" " compares as a string" + + printf "Test #9: " + if ("3e5" > "5") print "\"3e5\" > \"5\"" + else print "\"3e5\" <= \"5\"" + + printf "Test #10: " + x = 32.14 + y[x] = "test" + OFMT = "%e" + print y[x] + + printf "Test #11: " + x = x + 0 + print y[x] + + printf "Test #12: " + OFMT="%f" + CONVFMT="%e" + print 1.5, 1.5 "" + + printf "Test #13: " + if ( 1000000 "" == 1000001 "") print "match" + else print "nomatch" +} +{ + printf "Test #14: " + FS = ":" + print $1 + FS = "," + printf "Test #15: " + print $2 +} diff --git a/test/posix.in b/test/posix.in new file mode 100644 index 0000000..c16777b --- /dev/null +++ b/test/posix.in @@ -0,0 +1 @@ +1:2,3 4 diff --git a/test/posix.ok b/test/posix.ok new file mode 100644 index 0000000..100b150 --- /dev/null +++ b/test/posix.ok @@ -0,0 +1,16 @@ +Test #1: "+2" compares as a string +Test #2: "+2a" compares as a string +Test #3: "+2 " compares as a string +Test #4: " 2" compares as a string +after addition +Test #5: "+2" compares as a string +Test #6: "+2a" compares as a string +Test #7: "+2 " compares as a string +Test #8: " 2" compares as a string +Test #9: "3e5" <= "5" +Test #10: test +Test #11: test +Test #12: 1.500000 1.500000e+00 +Test #13: nomatch +Test #14: 1:2,3 +Test #15: 4 diff --git a/test/posix2008sub.awk b/test/posix2008sub.awk new file mode 100644 index 0000000..3c7c9b7 --- /dev/null +++ b/test/posix2008sub.awk @@ -0,0 +1,7 @@ +BEGIN { + text = "here is some text" + repl = "" + printf "orig = \"%s\", repl = \"%s\"\n", text, repl + sub(/some/, repl, text) + printf "result is \"%s\"\n", text +} diff --git a/test/posix2008sub.ok b/test/posix2008sub.ok new file mode 100644 index 0000000..4d4406a --- /dev/null +++ b/test/posix2008sub.ok @@ -0,0 +1,2 @@ +orig = "here is some text", repl = "" +result is "here is text" diff --git a/test/poundbang.awk b/test/poundbang.awk new file mode 100755 index 0000000..a6440ff --- /dev/null +++ b/test/poundbang.awk @@ -0,0 +1,2 @@ +#! /tmp/gawk -f +{ print } diff --git a/test/prdupval.awk b/test/prdupval.awk new file mode 100644 index 0000000..32c67dc --- /dev/null +++ b/test/prdupval.awk @@ -0,0 +1 @@ +{ print NF, $NF, "abc" $NF } diff --git a/test/prdupval.in b/test/prdupval.in new file mode 100644 index 0000000..5626abf --- /dev/null +++ b/test/prdupval.in @@ -0,0 +1 @@ +one diff --git a/test/prdupval.ok b/test/prdupval.ok new file mode 100644 index 0000000..6253616 --- /dev/null +++ b/test/prdupval.ok @@ -0,0 +1 @@ +1 one abcone diff --git a/test/prec.awk b/test/prec.awk new file mode 100644 index 0000000..8b37734 --- /dev/null +++ b/test/prec.awk @@ -0,0 +1,7 @@ +# check the precedence of operators: +BEGIN { + $1 = i = 1 + $+i++ + $- -i++ + print +} diff --git a/test/prec.ok b/test/prec.ok new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/test/prec.ok @@ -0,0 +1 @@ +1 diff --git a/test/printf0.awk b/test/printf0.awk new file mode 100644 index 0000000..ac8ad3c --- /dev/null +++ b/test/printf0.awk @@ -0,0 +1,5 @@ +BEGIN { + # bwk accepts this silently: + printf + print "X" +} diff --git a/test/printf0.ok b/test/printf0.ok new file mode 100644 index 0000000..62d8fe9 --- /dev/null +++ b/test/printf0.ok @@ -0,0 +1 @@ +X diff --git a/test/printf1.awk b/test/printf1.awk new file mode 100644 index 0000000..1cd7b99 --- /dev/null +++ b/test/printf1.awk @@ -0,0 +1,19 @@ +# Tue May 25 16:36:16 IDT 1999 +# +# Test cases based on email from Andreas Schwab, schwab@gnu.org + +BEGIN { + fmt[1] = "%8.5d"; data[1] = 100 + fmt[2] = "%#o"; data[2] = 0 + fmt[3] = "%#.1o"; data[3] = 0 + fmt[4] = "%#.0o"; data[4] = 0 + fmt[5] = "%#x"; data[5] = 0 + fmt[6] = "%.0d"; data[6] = 0 + fmt[7] = "%5.0d"; data[7] = 0 + + for (i = 1; i <= 7; i++) { + format = "%s, %d --- |" fmt[i] "|\n" + printf(format, fmt[i], data[i], data[i]) + } + +} diff --git a/test/printf1.ok b/test/printf1.ok new file mode 100644 index 0000000..32b3a7d --- /dev/null +++ b/test/printf1.ok @@ -0,0 +1,7 @@ +%8.5d, 100 --- | 00100| +%#o, 0 --- |0| +%#.1o, 0 --- |0| +%#.0o, 0 --- |0| +%#x, 0 --- |0| +%.0d, 0 --- || +%5.0d, 0 --- | | diff --git a/test/printfbad1.awk b/test/printfbad1.awk new file mode 100644 index 0000000..1b478df --- /dev/null +++ b/test/printfbad1.awk @@ -0,0 +1,65 @@ +#Date: Mon, 7 Jun 2004 10:40:28 -0500 +#From: mary1john8@earthlink.net +#To: arnold@skeeve.com +#Subject: gawk internal errors +#Message-ID: <20040607154028.GA2457@apollo> +# +#Hello, +# +# gawk-3.1.3i internal errors: +# +#[1] +# +#$> ./gawk 'BEGIN { for (i in a) delete a; }' +#gawk: fatal error: internal error +#Aborted +# +#------------------------------------------------------------------ +#--- awkgram.y.orig 2004-06-07 09:42:14.000000000 -0500 +#+++ awkgram.y 2004-06-07 09:45:58.000000000 -0500 +#@@ -387,7 +387,7 @@ +# * Check that the body is a `delete a[i]' statement, +# * and that both the loop var and array names match. +# */ +#- if ($8 != NULL && $8->type == Node_K_delete) { +#+ if ($8 != NULL && $8->type == Node_K_delete && $8->rnode != NULL) { +# NODE *arr, *sub; +# +# assert($8->rnode->type == Node_expression_list); +#------------------------------------------------------------------ +# +# +#[2] +# +#$> ./gawk 'BEGIN { printf("%3$*10$.*1$s\n", 20, 10, "hello"); }' +BEGIN { printf("%3$*10$.*1$s\n", 20, 10, "hello"); } +#gawk: fatal error: internal error +#Aborted +# +#------------------------------------------------------------------ +#--- builtin.c.orig 2004-06-07 10:04:20.000000000 -0500 +#+++ builtin.c 2004-06-07 10:06:08.000000000 -0500 +#@@ -780,7 +780,10 @@ +# s1++; +# n0--; +# } +#- +#+ if (val >= num_args) { +#+ toofew = TRUE; +#+ break; +#+ } +# arg = the_args[val]; +# } else { +# parse_next_arg(); +#------------------------------------------------------------------ +# +# +# Finally, a test for the rewritten get_src_buf(): +# +#$> AWKBUFSIZE=2 make check +# +#I get 3 failed tests. Not sure this is of any interest. +# +# +#Thanks, +#John diff --git a/test/printfbad1.ok b/test/printfbad1.ok new file mode 100644 index 0000000..d02140a --- /dev/null +++ b/test/printfbad1.ok @@ -0,0 +1,5 @@ +gawk: printfbad1.awk:35: fatal: not enough arguments to satisfy format string + `%3$*10$.*1$s +' + ^ ran out for this one +EXIT CODE: 2 diff --git a/test/printfbad2.awk b/test/printfbad2.awk new file mode 100644 index 0000000..d3bb368 --- /dev/null +++ b/test/printfbad2.awk @@ -0,0 +1,2 @@ +BEGIN { FS = "a" } +{ printf ($2 "\n") } diff --git a/test/printfbad2.in b/test/printfbad2.in new file mode 100644 index 0000000..1faae6d --- /dev/null +++ b/test/printfbad2.in @@ -0,0 +1 @@ +a%28b%29%c diff --git a/test/printfbad2.ok b/test/printfbad2.ok new file mode 100644 index 0000000..67d1660 --- /dev/null +++ b/test/printfbad2.ok @@ -0,0 +1,3 @@ +gawk: printfbad2.awk:2: (FILENAME=printfbad2.in FNR=1) warning: ignoring unknown format specifier character `b': no argument converted +gawk: printfbad2.awk:2: (FILENAME=printfbad2.in FNR=1) warning: field width is ignored for `%%' specifier +%28b%c diff --git a/test/printfbad3.awk b/test/printfbad3.awk new file mode 100644 index 0000000..1cabdd7 --- /dev/null +++ b/test/printfbad3.awk @@ -0,0 +1,22 @@ +# Date: Wed, 14 Mar 2012 08:10:48 -0500 +# From: John Haque +# To: arnold@skeeve.com +# Subject: gawk printf format bug +# +# Hi. +# +# I think this is a bug: +# +# $ gawk 'BEGIN { printf("%.0x%#x%#x\n", 0, 167, 167)}' +# 570xa7 +# +# It should print 0xa70xa7. +# +# The solution is to initialize base to 0 in the beginning +# of the while loop along with other stuff (format_tree). +# +# Thanks. +# +# John + +BEGIN { printf(">>%.0x<< >>%#x<< >>%#x<<\n", 0, 167, 167) } diff --git a/test/printfbad3.ok b/test/printfbad3.ok new file mode 100644 index 0000000..a87b019 --- /dev/null +++ b/test/printfbad3.ok @@ -0,0 +1 @@ +>><< >>0xa7<< >>0xa7<< diff --git a/test/printfloat.awk b/test/printfloat.awk new file mode 100644 index 0000000..1cb4066 --- /dev/null +++ b/test/printfloat.awk @@ -0,0 +1,62 @@ +# Test program for checking sprintf operation with various floating +# point formats +# +# Watch out - full output of this program will have 3000 * tot lines, +# which will take a chunk of space if you will write it to your disk. +# --mj + +BEGIN { + just = "-" + plus = "+ " + alt = "#" + zero = "0" + spec = "feEgG" + fw[1] = "" + fw[2] = "1" + fw[3] = "5" + fw[4] = "10" + fw[5] = "15" + prec[1] = ".-1" + prec[2] = "" + prec[3] = ".2" + prec[4] = ".5" + prec[5] = ".10" + + num = 123.6 + factor = 1.0e-12 + tot = 8 + data[1] = 0 + data[2] = 1 + for (i = 3; i <= tot; i++) { + data[i] = num * factor + factor *= 1000 + } + + for (j = 1; j <= 2; j++) { + for (p = 1; p <= 3; p++) { + for (a = 1; a <= 2; a++) { + for (z = 1; z <= 2; z++) { + for (s = 1; s <= 5; s++) { + for (w = 1; w <= 5; w++) { + for (r = 1; r <= 5; r++) { + frmt = "|%" substr(just, j, 1) + frmt = frmt substr(plus, p, 1) + frmt = frmt substr(alt, a, 1) + frmt = frmt substr(zero, z, 1) + frmt = frmt fw[w] prec[r] + frmt = frmt substr(spec, s, 1) "|" + for (i = 1; i <= tot; i++) { + result = sprintf(frmt, data[i]) +# "normalize" if you must +# sub(/\|\./, "|0.", result) + printf("%-16s %-25s\t%g\n", frmt, + result,data[i]) + } + } + } + } + } + } + } + } +} diff --git a/test/printlang.awk b/test/printlang.awk new file mode 100644 index 0000000..03e06c0 --- /dev/null +++ b/test/printlang.awk @@ -0,0 +1,4 @@ +BEGIN { + printf "\nLocale environment:\n\tLC_ALL=\"%s\" LANG=\"%s\"\n\n", + ENVIRON["LC_ALL"], ENVIRON["LANG"] +} diff --git a/test/prmarscl.awk b/test/prmarscl.awk new file mode 100644 index 0000000..3caf3d9 --- /dev/null +++ b/test/prmarscl.awk @@ -0,0 +1,6 @@ +function test(a) +{ + print a[1] +} + +BEGIN { j = 4; test(j) } diff --git a/test/prmarscl.ok b/test/prmarscl.ok new file mode 100644 index 0000000..a0f7ab8 --- /dev/null +++ b/test/prmarscl.ok @@ -0,0 +1,2 @@ +gawk: prmarscl.awk:3: fatal: attempt to use scalar parameter `a' as an array +EXIT CODE: 2 diff --git a/test/prmreuse.awk b/test/prmreuse.awk new file mode 100644 index 0000000..c1ffa17 --- /dev/null +++ b/test/prmreuse.awk @@ -0,0 +1,14 @@ +# from Pat Rankin, rankin@eql.caltech.edu, now rankin@pactechdata.com + +BEGIN { dummy(1); legit(); exit } + +function dummy(arg) +{ + return arg +} + +function legit( scratch) +{ + split("1 2 3", scratch) + return "" +} diff --git a/test/prmreuse.ok b/test/prmreuse.ok new file mode 100644 index 0000000..e69de29 diff --git a/test/procinfs.awk b/test/procinfs.awk new file mode 100644 index 0000000..53cfa97 --- /dev/null +++ b/test/procinfs.awk @@ -0,0 +1,7 @@ +BEGIN { + printf "Initially, PROCINFO[\"FS\"] = %s\n", PROCINFO["FS"] + FIELDWIDTHS = "3 4 5 6" + printf "After assign to FIELDWIDTHS, PROCINFO[\"FS\"] = %s\n", PROCINFO["FS"] + FS = FS + printf "After assign to FS, PROCINFO[\"FS\"] = %s\n", PROCINFO["FS"] +} diff --git a/test/procinfs.ok b/test/procinfs.ok new file mode 100644 index 0000000..23aaeff --- /dev/null +++ b/test/procinfs.ok @@ -0,0 +1,3 @@ +Initially, PROCINFO["FS"] = FS +After assign to FIELDWIDTHS, PROCINFO["FS"] = FIELDWIDTHS +After assign to FS, PROCINFO["FS"] = FS diff --git a/test/profile2.ok b/test/profile2.ok new file mode 100644 index 0000000..fe76a2c --- /dev/null +++ b/test/profile2.ok @@ -0,0 +1,170 @@ + # BEGIN block(s) + + BEGIN { + 1 if (sortcmd == "") { + sortcmd = "sort" + } + 1 asplit("BEGIN:END:atan2:break:close:continue:cos:delete:" "do:else:exit:exp:for:getline:gsub:if:in:index:int:" "length:log:match:next:print:printf:rand:return:sin:" "split:sprintf:sqrt:srand:sub:substr:system:while", keywords, ":") + 1 split("00:00:00:00:00:00:00:00:00:00:" "20:10:10:12:12:11:07:00:00:00:" "08:08:08:08:08:33:08:00:00:00:" "08:44:08:36:08:08:08:00:00:00:" "08:44:45:42:42:41:08", machine, ":") + 1 state = 1 + 571 for (; ; ) { + 571 symb = lex() + 571 nextstate = substr(machine[state symb], 1, 1) + 571 act = substr(machine[state symb], 2, 1) + 571 if (act == "0") { # 12 + 559 } else { + 559 if (act == "1") { # 8 + 8 if (! inarray(tok, names)) { # 3 + 3 names[++nnames] = tok + } + 8 lines[tok, ++xnames[tok]] = NR + 551 } else { + 551 if (act == "2") { # 426 + 426 if (tok in local) { # 309 + 309 tok = tok "(" funcname ")" + 309 if (! inarray(tok, names)) { # 22 + 22 names[++nnames] = tok + } + 309 lines[tok, ++xnames[tok]] = NR + 117 } else { + 117 tok = tok "()" + 117 if (! inarray(tok, names)) { # 22 + 22 names[++nnames] = tok + } + 117 lines[tok, ++xnames[tok]] = NR + } + 125 } else { + 125 if (act == "3") { # 4 + 4 funcname = tok + 4 flines[tok] = NR + 121 } else { + 121 if (act == "4") { # 49 + 49 braces++ + 72 } else { + 72 if (act == "5") { # 49 + 49 braces-- + 49 if (braces == 0) { # 4 + 22 for (temp in local) { + 22 delete local[temp] + } + 4 funcname = "" + 4 nextstate = 1 + } + 23 } else { + 23 if (act == "6") { # 22 + 22 local[tok] = 1 + 1 } else { + 1 if (act == "7") { # 1 + 1 break + } else { + if (act == "8") { + print("error: xref.awk: line " NR ": aborting") > "/dev/con" + exit 1 + } + } + } + } + } + } + } + } + } + 570 state = nextstate + } + 47 for (i = 1; i <= nnames; i++) { + 47 printf("%d ", xnames[names[i]]) | sortcmd + 47 if (index(names[i], "(") == 0) { # 3 + 3 printf("%s(%d)", names[i], flines[names[i]]) | sortcmd + 44 } else { + 44 printf("%s", names[i]) | sortcmd + } + 434 for (j = 1; j <= xnames[names[i]]; j++) { + 434 if (lines[names[i], j] != lines[names[i], j - 1]) { # 390 + 390 printf(" %d", lines[names[i], j]) | sortcmd + } + } + 47 printf("\n") | sortcmd + } + 1 close(sortcmd) + } + + + # Functions, listed alphabetically + + 1 function asplit(str, arr, fs, n) + { + 1 n = split(str, temp_asplit, fs) + 36 for (i = 1; i <= n; i++) { + 36 arr[temp_asplit[i]]++ + } + } + + 434 function inarray(val, arr, j, tmp) + { + 16297 for (j in arr) { + 16297 tmp[arr[j]]++ + } + 434 return (val in tmp) + } + + 571 function lex() + { + 1702 for (; ; ) { + 1702 if (tok == "(eof)") { + return 7 + } + 326 while (length(line) == 0) { + 326 if ((getline line) == 0) { # 1 + 1 tok = "(eof)" + 1 return 7 + } + } + 1701 sub(/^[ \t]+/, "", line) + 1701 sub(/^"([^"]|\\")*"/, "", line) + 1701 sub(/^\/([^\/]|\\\/)+\//, "", line) + 1701 sub(/^#.*/, "", line) + 1701 if (line ~ /^function/) { # 4 + 4 tok = "function" + 4 line = substr(line, 9) + 4 return 1 + 1697 } else { + 1697 if (line ~ /^{/) { # 53 + 53 tok = "{" + 53 line = substr(line, 2) + 53 return 2 + 1644 } else { + 1644 if (line ~ /^}/) { # 53 + 53 tok = "}" + 53 line = substr(line, 2) + 53 return 3 + 1591 } else { + 1591 if (match(line, /^[[:alpha:]_][[:alnum:]]*\[/)) { # 43 + 43 tok = substr(line, 1, RLENGTH - 1) + 43 line = substr(line, RLENGTH + 1) + 43 return 5 + 1548 } else { + 1548 if (match(line, /^[[:alpha:]_][[:alnum:]]*\(/)) { # 87 + 87 tok = substr(line, 1, RLENGTH - 1) + 87 line = substr(line, RLENGTH + 1) + 87 if (! (tok in keywords)) { # 12 + 12 return 6 + } + 1461 } else { + 1461 if (match(line, /^[[:alpha:]_][[:alnum:]]*/)) { # 525 + 525 tok = substr(line, 1, RLENGTH) + 525 line = substr(line, RLENGTH + 1) + 525 if (! (tok in keywords)) { # 405 + 405 return 4 + } + 936 } else { + 936 match(line, /^[^[:alpha:]_{}]/) + 936 tok = substr(line, 1, RLENGTH) + 936 line = substr(line, RLENGTH + 1) + } + } + } + } + } + } + } + } diff --git a/test/profile3.awk b/test/profile3.awk new file mode 100644 index 0000000..e519374 --- /dev/null +++ b/test/profile3.awk @@ -0,0 +1,9 @@ +BEGIN { + the_func = "p" + print @the_func("Hello") +} + +function p(str) +{ + print "! " str " !" +} diff --git a/test/profile3.ok b/test/profile3.ok new file mode 100644 index 0000000..50172c4 --- /dev/null +++ b/test/profile3.ok @@ -0,0 +1,14 @@ + # BEGIN block(s) + + BEGIN { + 1 the_func = "p" + 1 print @the_func("Hello") + } + + + # Functions, listed alphabetically + + 1 function p(str) + { + 1 print "! " str " !" + } diff --git a/test/prt1eval.awk b/test/prt1eval.awk new file mode 100644 index 0000000..4ecd368 --- /dev/null +++ b/test/prt1eval.awk @@ -0,0 +1,6 @@ +function tst () { + sum += 1 + return sum +} + +BEGIN { OFMT = "%.0f" ; print tst() } diff --git a/test/prt1eval.ok b/test/prt1eval.ok new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/test/prt1eval.ok @@ -0,0 +1 @@ +1 diff --git a/test/prtoeval.awk b/test/prtoeval.awk new file mode 100644 index 0000000..77880d8 --- /dev/null +++ b/test/prtoeval.awk @@ -0,0 +1,4 @@ +function returns_a_str() { print "" ; return "'A STRING'" } +BEGIN { + print "partial line:", returns_a_str() +} diff --git a/test/prtoeval.ok b/test/prtoeval.ok new file mode 100644 index 0000000..13e122b --- /dev/null +++ b/test/prtoeval.ok @@ -0,0 +1,2 @@ + +partial line: 'A STRING' diff --git a/test/pty1.awk b/test/pty1.awk new file mode 100644 index 0000000..77178d6 --- /dev/null +++ b/test/pty1.awk @@ -0,0 +1,54 @@ +# Message-ID: <1312419482.36133.YahooMailNeo@web110416.mail.gq1.yahoo.com> +# Date: Wed, 3 Aug 2011 17:58:02 -0700 (PDT) +# From: "T. X. G." +# To: "bug-gawk@gnu.org" +# Subject: [bug-gawk] two bugs in gawk 4.0.0 with FPAT and pty +# +# $ gawk --version +# GNU Awk 4.0.0 +# Copyright (C) 1989, 1991-2011 Free Software Foundation. +# +# # bug due to trying to make field splitting more efficient by not parse all fields +# $ echo a,b,,c |gawk '{for(i=1;i<=4;++i)print i, $i}' FPAT='[^,]*' +# 1 a +# 2 +# 3 b +# 4 +# +# # work around +# $ echo a,b,,c |gawk '{NF;for(i=1;i<=4;++i)print i, $i}' FPAT='[^,]*' +# 1 a +# 2 b +# 3 +# 4 c +# +# This bug, as you commented in function fpat_parse_field, is subtle. The null matches of previous call should be remembered across calls. You could make the auto variable non_empty static, but then any calls to patsplit between references of fields will cause it to be wrong. I guess you can either forgo the field splitting optimization by always parse all field in the case of FPAT or make a separate function for splitting $0 only (or pass an extra arg to it?) I am sure you will find the best fix. +# +# +# The next bug is with pty: +# +# $ gawk 'BEGIN{ +# c = "echo 123 > /dev/tty; read x < /dev/tty; echo \"x is $x\"" +# PROCINFO[c, "pty"] = 1 +# c |& getline;print +# print "abc" |& c +# c |& getline;print +# }' +# 123 +# ^C +# +# Adding a call to setsid() in the function two_way_open right after fork in the child process seems to fix it. +# +# One request for feature: +# Currently the format for mktime is not configurable. Could you please make it configurable just like strftime through PROCINFO["mktime"]? In fact I have already done it myself. But I don't think you would like my style. It should be pretty simple for you to implement. +# +# Thank you, Arnold. Again as I have said before, I enjoy your writings and appreciate your contributions to the FSF. +# W. G. +# +BEGIN { + c = "echo 123 > /dev/tty; read x < /dev/tty; echo \"x is $x\"" + PROCINFO[c, "pty"] = 1 + c |& getline; print + print "abc" |& c + c |& getline; print +} diff --git a/test/pty1.ok b/test/pty1.ok new file mode 100644 index 0000000..f06833f --- /dev/null +++ b/test/pty1.ok @@ -0,0 +1,2 @@ +123 +x is abc diff --git a/test/rand.awk b/test/rand.awk new file mode 100644 index 0000000..6378f3d --- /dev/null +++ b/test/rand.awk @@ -0,0 +1,6 @@ +BEGIN { + srand(2) + for (i = 0; i < 19; i++) + printf "%3d ", (1 + int(100 * rand())) + print "" +} diff --git a/test/rand.ok b/test/rand.ok new file mode 100644 index 0000000..60432b9 --- /dev/null +++ b/test/rand.ok @@ -0,0 +1 @@ + 62 67 88 6 35 77 3 68 30 96 90 26 35 8 88 93 49 53 37 diff --git a/test/range1.awk b/test/range1.awk new file mode 100755 index 0000000..aca5db5 --- /dev/null +++ b/test/range1.awk @@ -0,0 +1 @@ +/foo/,/bar/ { print } diff --git a/test/range1.in b/test/range1.in new file mode 100644 index 0000000..c496019 --- /dev/null +++ b/test/range1.in @@ -0,0 +1,2 @@ +foobar +junk diff --git a/test/range1.ok b/test/range1.ok new file mode 100644 index 0000000..323fae0 --- /dev/null +++ b/test/range1.ok @@ -0,0 +1 @@ +foobar diff --git a/test/rebt8b1.awk b/test/rebt8b1.awk new file mode 100644 index 0000000..8fa43fb --- /dev/null +++ b/test/rebt8b1.awk @@ -0,0 +1,138 @@ +# From hankedr@dms.auburn.edu Sun Jan 28 12:25:43 2001 +# Received: from mail.actcom.co.il [192.114.47.13] +# by localhost with POP3 (fetchmail-5.5.0) +# for arnold@localhost (single-drop); Sun, 28 Jan 2001 12:25:43 +0200 (IST) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Sun Jan 28 12:27:08 2001) +# X-From_: hankedr@dms.auburn.edu Sat Jan 27 15:15:57 2001 +# Received: from lmail.actcom.co.il by actcom.co.il with ESMTP +# (8.9.1a/actcom-0.2) id PAA23801 for ; +# Sat, 27 Jan 2001 15:15:55 +0200 (EET) +# (rfc931-sender: lmail.actcom.co.il [192.114.47.13]) +# Received: from billohost.com (www.billohost.com [209.196.35.10]) +# by lmail.actcom.co.il (8.9.3/8.9.1) with ESMTP id PAA15998 +# for ; Sat, 27 Jan 2001 15:16:27 +0200 +# Received: from yak.dms.auburn.edu (yak.dms.auburn.edu [131.204.53.2]) +# by billohost.com (8.9.3/8.9.3) with ESMTP id IAA00467 +# for ; Sat, 27 Jan 2001 08:15:52 -0500 +# Received: (from hankedr@localhost) +# by yak.dms.auburn.edu (8.9.3/8.9.3/Debian/GNU) id HAA24441; +# Sat, 27 Jan 2001 07:15:44 -0600 +# Date: Sat, 27 Jan 2001 07:15:44 -0600 +# Message-Id: <200101271315.HAA24441@yak.dms.auburn.edu> +# From: Darrel Hankerson +# To: arnold@skeeve.com +# Subject: [stolfi@ic.unicamp.br: Bug in [...]* matching with acute-u] +# Mime-Version: 1.0 (generated by tm-edit 7.106) +# Content-Type: message/rfc822 +# Status: R +# +# From: Jorge Stolfi +# To: bug-gnu-utils@gnu.org +# Subject: Bug in [...]* matching with acute-u +# MIME-Version: 1.0 +# Reply-To: stolfi@ic.unicamp.br +# X-MIME-Autoconverted: from 8bit to quoted-printable by grande.dcc.unicamp.br id GAA10716 +# Sender: bug-gnu-utils-admin@gnu.org +# Errors-To: bug-gnu-utils-admin@gnu.org +# X-BeenThere: bug-gnu-utils@gnu.org +# X-Mailman-Version: 2.0 +# Precedence: bulk +# List-Help: +# List-Post: +# List-Subscribe: , +# +# List-Id: Bug reports for the GNU utilities +# List-Unsubscribe: , +# +# List-Archive: +# Date: Sat, 27 Jan 2001 06:46:11 -0200 (EDT) +# Content-Transfer-Encoding: 8bit +# X-MIME-Autoconverted: from quoted-printable to 8bit by manatee.dms.auburn.edu id CAA14936 +# Content-Type: text/plain; charset=iso-8859-1 +# +# ; +# Sun, 28 Jan 2001 18:46:00 +0200 (EET) +# (rfc931-sender: lmail.actcom.co.il [192.114.47.13]) +#Received: from billohost.com (www.billohost.com [209.196.35.10]) +# by lmail.actcom.co.il (8.9.3/8.9.1) with ESMTP id SAA18523 +# for ; Sun, 28 Jan 2001 18:46:35 +0200 +#Received: from grande.dcc.unicamp.br (grande.dcc.unicamp.br [143.106.7.8]) +# by billohost.com (8.9.3/8.9.3) with ESMTP id LAA20063 +# for ; Sun, 28 Jan 2001 11:45:54 -0500 +#Received: from amazonas.dcc.unicamp.br (amazonas.dcc.unicamp.br [143.106.7.11]) +# by grande.dcc.unicamp.br (8.9.3/8.9.3) with ESMTP id OAA29726; +# Sun, 28 Jan 2001 14:45:47 -0200 (EDT) +#Received: from coruja.dcc.unicamp.br (coruja.dcc.unicamp.br [143.106.24.80]) +# by amazonas.dcc.unicamp.br (8.8.5/8.8.5) with ESMTP id OAA06542; +# Sun, 28 Jan 2001 14:45:45 -0200 (EDT) +#Received: (from stolfi@localhost) +# by coruja.dcc.unicamp.br (8.11.0/8.11.0) id f0SGjib16703; +# Sun, 28 Jan 2001 14:45:44 -0200 (EDT) +#Date: Sun, 28 Jan 2001 14:45:44 -0200 (EDT) +#Message-Id: <200101281645.f0SGjib16703@coruja.dcc.unicamp.br> +#From: Jorge Stolfi +#To: Michal Jaegermann +#Cc: Aharon Robbins , oliva@ic.unicamp.br, +# celio@ic.unicamp.br, ducatte@ic.unicamp.br, machado@ic.unicamp.br +#Subject: Re: a regex.c problem +#MIME-Version: 1.0 +#Content-Transfer-Encoding: 8bit +#Content-Type: text/plain; charset=iso-8859-1 +#In-Reply-To: <20010128090314.A5820@ellpspace.math.ualberta.ca> +#References: <200101281207.f0SC7Un08435@skeeve.com> +# <20010128090314.A5820@ellpspace.math.ualberta.ca> +#Reply-To: stolfi@ic.unicamp.br +#Status: RO +# +# +# > [Michal] Are there any other examples of "certain characters" +# > which would throw this regex engine off? +# +#I now tested [anX]*n for X ranging trough all characters from \000 and +#\377, and got that unexpected result only for the following ones: +# +# \370 | =F8 | ø | Small o, slash +# \371 | =F9 | ù | Small u, grave accent +# \372 | =FA | ú | Small u, acute accent +# \373 | =FB | û | Small u, circumflex accent +# \374 | =FC | ü | Small u, dieresis or umlaut mark +# \375 | =FD | ý | Small y, acute accent +# \376 | =FE | þ | Small thorn, Icelandic +# \377 | =FF | ÿ | Small y, dieresis or umlaut mark +# +#I have also tried those offending REs from inside emacs (20.7.1), with +#query-replace-regexp, and it seems to be working fine. So presumably +#the bug lies in gawk itself, or in the RE parsing code, rather than in +#the matching engine? +# +#Could it be an underdimensioned table somewhere? +# +#Thanks for the help, and all the best +# +#--stolfi +# +# ---------------------------------------------------------------------- + #! /usr/bin/gawk -f + + BEGIN { + for (c = 0; c < 256; c++) + { do_test(c); } + } + + function do_test(char, pat,s,t) + { + if (char == 92) { printf "(error for \\%03o)\n", char; return; } + pat = sprintf("[an\\%03o]*n", char); + s = "bananas and ananases in canaan"; + t = s; gsub(pat, "AN", t); printf "%-8s %s\n", pat, t; +# ADR: Added: + if (s ~ pat) printf "\tmatch\n" ; else printf "\tno-match\n" + } + +# ---------------------------------------------------------------------- diff --git a/test/rebt8b2.ok b/test/rebt8b2.ok new file mode 100644 index 0000000..661109c --- /dev/null +++ b/test/rebt8b2.ok @@ -0,0 +1,511 @@ +[an\000]*n bANas ANd ANases iAN cAN + match +[an\001]*n bANas ANd ANases iAN cAN + match +[an\002]*n bANas ANd ANases iAN cAN + match +[an\003]*n bANas ANd ANases iAN cAN + match +[an\004]*n bANas ANd ANases iAN cAN + match +[an\005]*n bANas ANd ANases iAN cAN + match +[an\006]*n bANas ANd ANases iAN cAN + match +[an\007]*n bANas ANd ANases iAN cAN + match +[an\010]*n bANas ANd ANases iAN cAN + match +[an\011]*n bANas ANd ANases iAN cAN + match +[an\012]*n bANas ANd ANases iAN cAN + match +[an\013]*n bANas ANd ANases iAN cAN + match +[an\014]*n bANas ANd ANases iAN cAN + match +[an\015]*n bANas ANd ANases iAN cAN + match +[an\016]*n bANas ANd ANases iAN cAN + match +[an\017]*n bANas ANd ANases iAN cAN + match +[an\020]*n bANas ANd ANases iAN cAN + match +[an\021]*n bANas ANd ANases iAN cAN + match +[an\022]*n bANas ANd ANases iAN cAN + match +[an\023]*n bANas ANd ANases iAN cAN + match +[an\024]*n bANas ANd ANases iAN cAN + match +[an\025]*n bANas ANd ANases iAN cAN + match +[an\026]*n bANas ANd ANases iAN cAN + match +[an\027]*n bANas ANd ANases iAN cAN + match +[an\030]*n bANas ANd ANases iAN cAN + match +[an\031]*n bANas ANd ANases iAN cAN + match +[an\032]*n bANas ANd ANases iAN cAN + match +[an\033]*n bANas ANd ANases iAN cAN + match +[an\034]*n bANas ANd ANases iAN cAN + match +[an\035]*n bANas ANd ANases iAN cAN + match +[an\036]*n bANas ANd ANases iAN cAN + match +[an\037]*n bANas ANd ANases iAN cAN + match +[an\040]*n bANasANdANases iAN cAN + match +[an\041]*n bANas ANd ANases iAN cAN + match +[an\042]*n bANas ANd ANases iAN cAN + match +[an\043]*n bANas ANd ANases iAN cAN + match +[an\044]*n bANas ANd ANases iAN cAN + match +[an\045]*n bANas ANd ANases iAN cAN + match +[an\046]*n bANas ANd ANases iAN cAN + match +[an\047]*n bANas ANd ANases iAN cAN + match +[an\050]*n bANas ANd ANases iAN cAN + match +[an\051]*n bANas ANd ANases iAN cAN + match +[an\052]*n bANas ANd ANases iAN cAN + match +[an\053]*n bANas ANd ANases iAN cAN + match +[an\054]*n bANas ANd ANases iAN cAN + match +[an\055]*n bANas ANd ANases iAN cAN + match +[an\056]*n bANas ANd ANases iAN cAN + match +[an\057]*n bANas ANd ANases iAN cAN + match +[an\060]*n bANas ANd ANases iAN cAN + match +[an\061]*n bANas ANd ANases iAN cAN + match +[an\062]*n bANas ANd ANases iAN cAN + match +[an\063]*n bANas ANd ANases iAN cAN + match +[an\064]*n bANas ANd ANases iAN cAN + match +[an\065]*n bANas ANd ANases iAN cAN + match +[an\066]*n bANas ANd ANases iAN cAN + match +[an\067]*n bANas ANd ANases iAN cAN + match +[an\070]*n bANas ANd ANases iAN cAN + match +[an\071]*n bANas ANd ANases iAN cAN + match +[an\072]*n bANas ANd ANases iAN cAN + match +[an\073]*n bANas ANd ANases iAN cAN + match +[an\074]*n bANas ANd ANases iAN cAN + match +[an\075]*n bANas ANd ANases iAN cAN + match +[an\076]*n bANas ANd ANases iAN cAN + match +[an\077]*n bANas ANd ANases iAN cAN + match +[an\100]*n bANas ANd ANases iAN cAN + match +[an\101]*n bANas ANd ANases iAN cAN + match +[an\102]*n bANas ANd ANases iAN cAN + match +[an\103]*n bANas ANd ANases iAN cAN + match +[an\104]*n bANas ANd ANases iAN cAN + match +[an\105]*n bANas ANd ANases iAN cAN + match +[an\106]*n bANas ANd ANases iAN cAN + match +[an\107]*n bANas ANd ANases iAN cAN + match +[an\110]*n bANas ANd ANases iAN cAN + match +[an\111]*n bANas ANd ANases iAN cAN + match +[an\112]*n bANas ANd ANases iAN cAN + match +[an\113]*n bANas ANd ANases iAN cAN + match +[an\114]*n bANas ANd ANases iAN cAN + match +[an\115]*n bANas ANd ANases iAN cAN + match +[an\116]*n bANas ANd ANases iAN cAN + match +[an\117]*n bANas ANd ANases iAN cAN + match +[an\120]*n bANas ANd ANases iAN cAN + match +[an\121]*n bANas ANd ANases iAN cAN + match +[an\122]*n bANas ANd ANases iAN cAN + match +[an\123]*n bANas ANd ANases iAN cAN + match +[an\124]*n bANas ANd ANases iAN cAN + match +[an\125]*n bANas ANd ANases iAN cAN + match +[an\126]*n bANas ANd ANases iAN cAN + match +[an\127]*n bANas ANd ANases iAN cAN + match +[an\130]*n bANas ANd ANases iAN cAN + match +[an\131]*n bANas ANd ANases iAN cAN + match +[an\132]*n bANas ANd ANases iAN cAN + match +[an\133]*n bANas ANd ANases iAN cAN + match +(error for \134) +[an\135]*n bANANas ANd ANANases in cANaAN + match +[an\136]*n bANas ANd ANases iAN cAN + match +[an\137]*n bANas ANd ANases iAN cAN + match +[an\140]*n bANas ANd ANases iAN cAN + match +[an\141]*n bANas ANd ANases iAN cAN + match +[an\142]*n ANas ANd ANases iAN cAN + match +[an\143]*n bANas ANd ANases iAN AN + match +[an\144]*n bANas ANd ANases iAN cAN + match +[an\145]*n bANas ANd ANases iAN cAN + match +[an\146]*n bANas ANd ANases iAN cAN + match +[an\147]*n bANas ANd ANases iAN cAN + match +[an\150]*n bANas ANd ANases iAN cAN + match +[an\151]*n bANas ANd ANases AN cAN + match +[an\152]*n bANas ANd ANases iAN cAN + match +[an\153]*n bANas ANd ANases iAN cAN + match +[an\154]*n bANas ANd ANases iAN cAN + match +[an\155]*n bANas ANd ANases iAN cAN + match +[an\156]*n bANas ANd ANases iAN cAN + match +[an\157]*n bANas ANd ANases iAN cAN + match +[an\160]*n bANas ANd ANases iAN cAN + match +[an\161]*n bANas ANd ANases iAN cAN + match +[an\162]*n bANas ANd ANases iAN cAN + match +[an\163]*n bANas ANd ANases iAN cAN + match +[an\164]*n bANas ANd ANases iAN cAN + match +[an\165]*n bANas ANd ANases iAN cAN + match +[an\166]*n bANas ANd ANases iAN cAN + match +[an\167]*n bANas ANd ANases iAN cAN + match +[an\170]*n bANas ANd ANases iAN cAN + match +[an\171]*n bANas ANd ANases iAN cAN + match +[an\172]*n bANas ANd ANases iAN cAN + match +[an\173]*n bANas ANd ANases iAN cAN + match +[an\174]*n bANas ANd ANases iAN cAN + match +[an\175]*n bANas ANd ANases iAN cAN + match +[an\176]*n bANas ANd ANases iAN cAN + match +[an\177]*n bANas ANd ANases iAN cAN + match +[an\200]*n bANas ANd ANases iAN cAN + match +[an\201]*n bANas ANd ANases iAN cAN + match +[an\202]*n bANas ANd ANases iAN cAN + match +[an\203]*n bANas ANd ANases iAN cAN + match +[an\204]*n bANas ANd ANases iAN cAN + match +[an\205]*n bANas ANd ANases iAN cAN + match +[an\206]*n bANas ANd ANases iAN cAN + match +[an\207]*n bANas ANd ANases iAN cAN + match +[an\210]*n bANas ANd ANases iAN cAN + match +[an\211]*n bANas ANd ANases iAN cAN + match +[an\212]*n bANas ANd ANases iAN cAN + match +[an\213]*n bANas ANd ANases iAN cAN + match +[an\214]*n bANas ANd ANases iAN cAN + match +[an\215]*n bANas ANd ANases iAN cAN + match +[an\216]*n bANas ANd ANases iAN cAN + match +[an\217]*n bANas ANd ANases iAN cAN + match +[an\220]*n bANas ANd ANases iAN cAN + match +[an\221]*n bANas ANd ANases iAN cAN + match +[an\222]*n bANas ANd ANases iAN cAN + match +[an\223]*n bANas ANd ANases iAN cAN + match +[an\224]*n bANas ANd ANases iAN cAN + match +[an\225]*n bANas ANd ANases iAN cAN + match +[an\226]*n bANas ANd ANases iAN cAN + match +[an\227]*n bANas ANd ANases iAN cAN + match +[an\230]*n bANas ANd ANases iAN cAN + match +[an\231]*n bANas ANd ANases iAN cAN + match +[an\232]*n bANas ANd ANases iAN cAN + match +[an\233]*n bANas ANd ANases iAN cAN + match +[an\234]*n bANas ANd ANases iAN cAN + match +[an\235]*n bANas ANd ANases iAN cAN + match +[an\236]*n bANas ANd ANases iAN cAN + match +[an\237]*n bANas ANd ANases iAN cAN + match +[an\240]*n bANas ANd ANases iAN cAN + match +[an\241]*n bANas ANd ANases iAN cAN + match +[an\242]*n bANas ANd ANases iAN cAN + match +[an\243]*n bANas ANd ANases iAN cAN + match +[an\244]*n bANas ANd ANases iAN cAN + match +[an\245]*n bANas ANd ANases iAN cAN + match +[an\246]*n bANas ANd ANases iAN cAN + match +[an\247]*n bANas ANd ANases iAN cAN + match +[an\250]*n bANas ANd ANases iAN cAN + match +[an\251]*n bANas ANd ANases iAN cAN + match +[an\252]*n bANas ANd ANases iAN cAN + match +[an\253]*n bANas ANd ANases iAN cAN + match +[an\254]*n bANas ANd ANases iAN cAN + match +[an\255]*n bANas ANd ANases iAN cAN + match +[an\256]*n bANas ANd ANases iAN cAN + match +[an\257]*n bANas ANd ANases iAN cAN + match +[an\260]*n bANas ANd ANases iAN cAN + match +[an\261]*n bANas ANd ANases iAN cAN + match +[an\262]*n bANas ANd ANases iAN cAN + match +[an\263]*n bANas ANd ANases iAN cAN + match +[an\264]*n bANas ANd ANases iAN cAN + match +[an\265]*n bANas ANd ANases iAN cAN + match +[an\266]*n bANas ANd ANases iAN cAN + match +[an\267]*n bANas ANd ANases iAN cAN + match +[an\270]*n bANas ANd ANases iAN cAN + match +[an\271]*n bANas ANd ANases iAN cAN + match +[an\272]*n bANas ANd ANases iAN cAN + match +[an\273]*n bANas ANd ANases iAN cAN + match +[an\274]*n bANas ANd ANases iAN cAN + match +[an\275]*n bANas ANd ANases iAN cAN + match +[an\276]*n bANas ANd ANases iAN cAN + match +[an\277]*n bANas ANd ANases iAN cAN + match +[an\300]*n bANas ANd ANases iAN cAN + match +[an\301]*n bANas ANd ANases iAN cAN + match +[an\302]*n bANas ANd ANases iAN cAN + match +[an\303]*n bANas ANd ANases iAN cAN + match +[an\304]*n bANas ANd ANases iAN cAN + match +[an\305]*n bANas ANd ANases iAN cAN + match +[an\306]*n bANas ANd ANases iAN cAN + match +[an\307]*n bANas ANd ANases iAN cAN + match +[an\310]*n bANas ANd ANases iAN cAN + match +[an\311]*n bANas ANd ANases iAN cAN + match +[an\312]*n bANas ANd ANases iAN cAN + match +[an\313]*n bANas ANd ANases iAN cAN + match +[an\314]*n bANas ANd ANases iAN cAN + match +[an\315]*n bANas ANd ANases iAN cAN + match +[an\316]*n bANas ANd ANases iAN cAN + match +[an\317]*n bANas ANd ANases iAN cAN + match +[an\320]*n bANas ANd ANases iAN cAN + match +[an\321]*n bANas ANd ANases iAN cAN + match +[an\322]*n bANas ANd ANases iAN cAN + match +[an\323]*n bANas ANd ANases iAN cAN + match +[an\324]*n bANas ANd ANases iAN cAN + match +[an\325]*n bANas ANd ANases iAN cAN + match +[an\326]*n bANas ANd ANases iAN cAN + match +[an\327]*n bANas ANd ANases iAN cAN + match +[an\330]*n bANas ANd ANases iAN cAN + match +[an\331]*n bANas ANd ANases iAN cAN + match +[an\332]*n bANas ANd ANases iAN cAN + match +[an\333]*n bANas ANd ANases iAN cAN + match +[an\334]*n bANas ANd ANases iAN cAN + match +[an\335]*n bANas ANd ANases iAN cAN + match +[an\336]*n bANas ANd ANases iAN cAN + match +[an\337]*n bANas ANd ANases iAN cAN + match +[an\340]*n bANas ANd ANases iAN cAN + match +[an\341]*n bANas ANd ANases iAN cAN + match +[an\342]*n bANas ANd ANases iAN cAN + match +[an\343]*n bANas ANd ANases iAN cAN + match +[an\344]*n bANas ANd ANases iAN cAN + match +[an\345]*n bANas ANd ANases iAN cAN + match +[an\346]*n bANas ANd ANases iAN cAN + match +[an\347]*n bANas ANd ANases iAN cAN + match +[an\350]*n bANas ANd ANases iAN cAN + match +[an\351]*n bANas ANd ANases iAN cAN + match +[an\352]*n bANas ANd ANases iAN cAN + match +[an\353]*n bANas ANd ANases iAN cAN + match +[an\354]*n bANas ANd ANases iAN cAN + match +[an\355]*n bANas ANd ANases iAN cAN + match +[an\356]*n bANas ANd ANases iAN cAN + match +[an\357]*n bANas ANd ANases iAN cAN + match +[an\360]*n bANas ANd ANases iAN cAN + match +[an\361]*n bANas ANd ANases iAN cAN + match +[an\362]*n bANas ANd ANases iAN cAN + match +[an\363]*n bANas ANd ANases iAN cAN + match +[an\364]*n bANas ANd ANases iAN cAN + match +[an\365]*n bANas ANd ANases iAN cAN + match +[an\366]*n bANas ANd ANases iAN cAN + match +[an\367]*n bANas ANd ANases iAN cAN + match +[an\370]*n bANas ANd ANases iAN cAN + match +[an\371]*n bANas ANd ANases iAN cAN + match +[an\372]*n bANas ANd ANases iAN cAN + match +[an\373]*n bANas ANd ANases iAN cAN + match +[an\374]*n bANas ANd ANases iAN cAN + match +[an\375]*n bANas ANd ANases iAN cAN + match +[an\376]*n bANas ANd ANases iAN cAN + match +[an\377]*n bANas ANd ANases iAN cAN + match diff --git a/test/rebuf.awk b/test/rebuf.awk new file mode 100644 index 0000000..69b5f05 --- /dev/null +++ b/test/rebuf.awk @@ -0,0 +1,73 @@ +# From lole@epost.de Wed Sep 4 09:54:19 IDT 2002 +# Article: 14288 of comp.lang.awk +# 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 +# From: LorenzAtWork +# Newsgroups: comp.lang.awk +# Subject: bug in gawk 3.1.1? +# Date: Wed, 28 Aug 2002 10:34:50 +0200 +# Lines: 45 +# Message-ID: <7g1pmukv07c56ep3qav3uebnipdaohqh2l@4ax.com> +# Reply-To: lole@epost.de +# NNTP-Posting-Host: 213.70.124.113 +# Mime-Version: 1.0 +# Content-Type: text/plain; charset=us-ascii +# Content-Transfer-Encoding: 7bit +# X-Trace: fu-berlin.de 1030523788 53278293 213.70.124.113 (16 [68559]) +# X-Newsreader: Forte Agent 1.91/32.564 +# Xref: dfw-artgen comp.lang.awk:14288 +# +# hello all, +# +# I'm using the following script +# +BEGIN { + RS="ti1\n(dwv,)?" + s = 0 + i = 0 +} +{ + if ($1 != "") + s = $1 + print ++i, s +} +# +# to extract values from a file of the form +# +# ti1 +# dwv,98.22 +# ti1 +# dwv,103.08 +# ti1 +# ti1 +# dwv,196.25 +# ti1 +# dwv,210.62 +# ti1 +# dwv,223.53 +# +# The desired result for this example looks like +# +# 1 0 +# 2 98.22 +# 3 103.08 +# 4 103.08 +# 5 196.25 +# 6 210.62 +# 7 223.53 +# +# The script work fine the most time, but when run on the attached file +# (sorry for the size, but the error would not appear with less data) I +# get some (three with the attached file) lines that look like +# +# 1262 dwv,212.97 +# 1277 dwv,174.33 +# 1279 dwv,151.79 +# +# I can't think of a other reason for this than a bug in gawk! +# +# I'm running gawk 3.1.1 on winnt 4.0 +# +# best regards +# Lorenz +# +# diff --git a/test/rebuf.in b/test/rebuf.in new file mode 100644 index 0000000..46d2210 --- /dev/null +++ b/test/rebuf.in @@ -0,0 +1,2350 @@ +ti1 +dwv,214.59 +ti1 +dwv,230.31 +ti1 +dwv,242.64 +ti1 +dwv,253.94 +ti1 +dwv,264.33 +ti1 +dwv,270.94 +ti1 +dwv,273.52 +ti1 +dwv,270.08 +ti1 +dwv,263.19 +ti1 +dwv,254.45 +ti1 +dwv,244.91 +ti1 +dwv,234.55 +ti1 +dwv,222.49 +ti1 +dwv,209.94 +ti1 +dwv,197.17 +ti1 +dwv,182.89 +ti1 +dwv,169.76 +ti1 +dwv,158.59 +ti1 +dwv,145.37 +ti1 +dwv,135.46 +ti1 +dwv,124.77 +ti1 +dwv,115.98 +ti1 +dwv,108.77 +ti1 +dwv,101.12 +ti1 +dwv,94.45 +ti1 +dwv,89.08 +ti1 +dwv,84.63 +ti1 +dwv,81.05 +ti1 +dwv,78.93 +ti1 +dwv,76.65 +ti1 +dwv,75.59 +ti1 +ti1 +ti1 +dwv,77.47 +ti1 +dwv,80.17 +ti1 +dwv,83.90 +ti1 +dwv,88.56 +ti1 +dwv,95.69 +ti1 +dwv,97.48 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,203.08 +ti1 +dwv,218.22 +ti1 +dwv,229.37 +ti1 +dwv,238.49 +ti1 +dwv,247.43 +ti1 +dwv,255.22 +ti1 +dwv,261.31 +ti1 +dwv,262.36 +ti1 +dwv,260.66 +ti1 +dwv,256.33 +ti1 +dwv,249.34 +ti1 +dwv,240.03 +ti1 +dwv,228.55 +ti1 +dwv,215.42 +ti1 +dwv,203.37 +ti1 +dwv,190.01 +ti1 +dwv,177.81 +ti1 +dwv,165.44 +ti1 +dwv,152.92 +ti1 +dwv,142.03 +ti1 +dwv,132.91 +ti1 +dwv,124.48 +ti1 +dwv,116.45 +ti1 +dwv,109.06 +ti1 +dwv,103.27 +ti1 +dwv,98.87 +ti1 +dwv,94.95 +ti1 +dwv,92.56 +ti1 +dwv,90.47 +ti1 +dwv,89.48 +ti1 +ti1 +dwv,90.53 +ti1 +dwv,93.07 +ti1 +dwv,97.12 +ti1 +dwv,101.82 +ti1 +dwv,108.18 +ti1 +dwv,109.73 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,202.97 +ti1 +dwv,217.38 +ti1 +dwv,231.73 +ti1 +dwv,243.11 +ti1 +dwv,255.37 +ti1 +dwv,264.12 +ti1 +dwv,269.64 +ti1 +dwv,270.98 +ti1 +dwv,269.65 +ti1 +dwv,264.55 +ti1 +dwv,257.16 +ti1 +dwv,246.01 +ti1 +dwv,232.88 +ti1 +dwv,219.85 +ti1 +dwv,208.79 +ti1 +dwv,197.00 +ti1 +dwv,183.93 +ti1 +dwv,172.00 +ti1 +dwv,160.55 +ti1 +dwv,150.59 +ti1 +dwv,141.47 +ti1 +dwv,133.02 +ti1 +dwv,126.21 +ti1 +dwv,120.64 +ti1 +dwv,115.79 +ti1 +dwv,111.62 +ti1 +dwv,108.41 +ti1 +dwv,106.41 +ti1 +ti1 +ti1 +dwv,109.08 +ti1 +dwv,113.23 +ti1 +dwv,118.57 +ti1 +dwv,122.57 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,208.07 +ti1 +dwv,224.14 +ti1 +dwv,236.28 +ti1 +dwv,248.12 +ti1 +dwv,258.97 +ti1 +dwv,267.74 +ti1 +dwv,272.47 +ti1 +dwv,271.52 +ti1 +dwv,266.80 +ti1 +dwv,258.61 +ti1 +dwv,249.30 +ti1 +dwv,239.19 +ti1 +dwv,228.28 +ti1 +dwv,215.79 +ti1 +dwv,203.86 +ti1 +dwv,190.08 +ti1 +dwv,177.40 +ti1 +dwv,163.81 +ti1 +dwv,152.60 +ti1 +dwv,141.33 +ti1 +dwv,130.98 +ti1 +dwv,121.98 +ti1 +dwv,114.08 +ti1 +dwv,106.61 +ti1 +dwv,99.75 +ti1 +dwv,93.10 +ti1 +dwv,86.57 +ti1 +dwv,80.62 +ti1 +dwv,76.05 +ti1 +dwv,71.52 +ti1 +dwv,68.85 +ti1 +dwv,67.46 +ti1 +dwv,66.86 +ti1 +dwv,67.51 +ti1 +dwv,69.75 +ti1 +dwv,72.85 +ti1 +dwv,76.23 +ti1 +dwv,82.85 +ti1 +dwv,89.33 +ti1 +dwv,93.39 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,188.37 +ti1 +dwv,204.42 +ti1 +dwv,217.16 +ti1 +dwv,228.89 +ti1 +dwv,238.83 +ti1 +dwv,247.70 +ti1 +dwv,253.59 +ti1 +dwv,257.17 +ti1 +ti1 +dwv,254.00 +ti1 +dwv,248.24 +ti1 +dwv,240.14 +ti1 +dwv,229.42 +ti1 +dwv,218.97 +ti1 +dwv,205.09 +ti1 +dwv,192.61 +ti1 +dwv,179.74 +ti1 +dwv,166.76 +ti1 +dwv,155.36 +ti1 +dwv,143.58 +ti1 +dwv,131.40 +ti1 +dwv,121.84 +ti1 +dwv,112.46 +ti1 +dwv,105.41 +ti1 +dwv,97.15 +ti1 +dwv,90.09 +ti1 +dwv,84.79 +ti1 +dwv,80.52 +ti1 +dwv,75.58 +ti1 +dwv,72.59 +ti1 +dwv,69.39 +ti1 +dwv,67.51 +ti1 +dwv,66.42 +ti1 +ti1 +ti1 +dwv,67.82 +ti1 +dwv,69.76 +ti1 +dwv,73.19 +ti1 +dwv,77.35 +ti1 +dwv,82.36 +ti1 +dwv,87.82 +ti1 +dwv,93.30 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,190.58 +ti1 +dwv,203.43 +ti1 +dwv,216.48 +ti1 +dwv,228.89 +ti1 +dwv,241.91 +ti1 +dwv,251.60 +ti1 +dwv,257.78 +ti1 +dwv,262.18 +ti1 +dwv,263.13 +ti1 +dwv,260.91 +ti1 +dwv,255.34 +ti1 +dwv,247.17 +ti1 +dwv,236.85 +ti1 +dwv,225.24 +ti1 +dwv,213.39 +ti1 +dwv,201.46 +ti1 +dwv,187.77 +ti1 +dwv,175.31 +ti1 +dwv,162.95 +ti1 +dwv,152.55 +ti1 +dwv,142.56 +ti1 +dwv,132.94 +ti1 +dwv,125.00 +ti1 +dwv,117.69 +ti1 +dwv,110.96 +ti1 +dwv,105.02 +ti1 +dwv,101.78 +ti1 +dwv,98.48 +ti1 +dwv,97.06 +ti1 +dwv,96.50 +ti1 +ti1 +dwv,98.48 +ti1 +dwv,101.18 +ti1 +dwv,104.56 +ti1 +dwv,109.67 +ti1 +dwv,115.86 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,200.02 +ti1 +dwv,217.51 +ti1 +dwv,233.21 +ti1 +dwv,245.72 +ti1 +dwv,258.21 +ti1 +dwv,267.24 +ti1 +dwv,273.79 +ti1 +dwv,273.20 +ti1 +dwv,270.38 +ti1 +dwv,260.76 +ti1 +dwv,250.05 +ti1 +dwv,241.32 +ti1 +dwv,231.14 +ti1 +dwv,219.83 +ti1 +dwv,206.13 +ti1 +dwv,193.24 +ti1 +dwv,180.73 +ti1 +dwv,167.82 +ti1 +dwv,156.94 +ti1 +dwv,144.13 +ti1 +dwv,134.40 +ti1 +dwv,125.23 +ti1 +dwv,116.13 +ti1 +dwv,107.34 +ti1 +dwv,99.71 +ti1 +dwv,94.11 +ti1 +dwv,88.91 +ti1 +dwv,84.51 +ti1 +dwv,81.50 +ti1 +dwv,78.66 +ti1 +dwv,76.57 +ti1 +dwv,75.82 +ti1 +ti1 +dwv,76.88 +ti1 +dwv,79.03 +ti1 +dwv,82.12 +ti1 +dwv,85.73 +ti1 +dwv,91.05 +ti1 +dwv,96.31 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,184.18 +ti1 +dwv,201.10 +ti1 +dwv,214.21 +ti1 +dwv,226.18 +ti1 +dwv,237.72 +ti1 +dwv,247.57 +ti1 +dwv,254.36 +ti1 +dwv,258.34 +ti1 +dwv,259.80 +ti1 +dwv,257.76 +ti1 +dwv,253.17 +ti1 +dwv,246.51 +ti1 +dwv,237.92 +ti1 +dwv,227.09 +ti1 +dwv,214.13 +ti1 +dwv,202.20 +ti1 +dwv,189.21 +ti1 +dwv,177.65 +ti1 +dwv,166.18 +ti1 +dwv,154.03 +ti1 +dwv,142.21 +ti1 +dwv,131.51 +ti1 +dwv,121.28 +ti1 +dwv,111.80 +ti1 +dwv,104.47 +ti1 +dwv,98.80 +ti1 +dwv,94.76 +ti1 +dwv,91.81 +ti1 +dwv,89.17 +ti1 +dwv,88.00 +ti1 +ti1 +ti1 +dwv,89.20 +ti1 +dwv,91.17 +ti1 +dwv,94.35 +ti1 +dwv,99.00 +ti1 +dwv,105.43 +ti1 +dwv,109.34 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,194.84 +ti1 +dwv,212.05 +ti1 +dwv,226.30 +ti1 +dwv,239.03 +ti1 +dwv,250.94 +ti1 +dwv,259.73 +ti1 +dwv,266.64 +ti1 +dwv,269.67 +ti1 +dwv,269.03 +ti1 +dwv,265.03 +ti1 +dwv,258.23 +ti1 +dwv,249.32 +ti1 +dwv,238.03 +ti1 +dwv,226.20 +ti1 +dwv,213.46 +ti1 +dwv,200.53 +ti1 +dwv,187.65 +ti1 +dwv,174.89 +ti1 +dwv,163.22 +ti1 +dwv,152.47 +ti1 +dwv,142.65 +ti1 +dwv,133.97 +ti1 +dwv,126.59 +ti1 +dwv,120.52 +ti1 +dwv,115.57 +ti1 +dwv,111.49 +ti1 +dwv,108.03 +ti1 +dwv,106.01 +ti1 +dwv,105.28 +ti1 +ti1 +dwv,106.91 +ti1 +dwv,109.73 +ti1 +dwv,114.91 +ti1 +dwv,120.66 +ti1 +dwv,123.74 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,211.57 +ti1 +dwv,227.06 +ti1 +dwv,240.57 +ti1 +dwv,252.26 +ti1 +dwv,262.67 +ti1 +dwv,270.66 +ti1 +dwv,273.40 +ti1 +dwv,270.25 +ti1 +dwv,263.76 +ti1 +dwv,256.03 +ti1 +dwv,246.87 +ti1 +dwv,237.10 +ti1 +dwv,225.11 +ti1 +dwv,211.53 +ti1 +dwv,197.77 +ti1 +dwv,185.75 +ti1 +dwv,173.00 +ti1 +dwv,159.31 +ti1 +dwv,147.18 +ti1 +dwv,134.84 +ti1 +dwv,125.07 +ti1 +dwv,115.82 +ti1 +dwv,107.33 +ti1 +dwv,100.07 +ti1 +dwv,93.55 +ti1 +dwv,87.60 +ti1 +dwv,81.75 +ti1 +dwv,77.03 +ti1 +dwv,73.39 +ti1 +dwv,70.97 +ti1 +dwv,67.94 +ti1 +dwv,66.64 +ti1 +dwv,65.80 +ti1 +ti1 +dwv,66.85 +ti1 +dwv,68.78 +ti1 +dwv,71.47 +ti1 +dwv,74.20 +ti1 +dwv,78.68 +ti1 +dwv,85.08 +ti1 +dwv,87.47 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,185.81 +ti1 +dwv,201.66 +ti1 +dwv,215.07 +ti1 +dwv,227.26 +ti1 +dwv,238.00 +ti1 +dwv,247.64 +ti1 +dwv,255.03 +ti1 +dwv,257.12 +ti1 +dwv,256.17 +ti1 +dwv,253.47 +ti1 +dwv,248.93 +ti1 +dwv,241.39 +ti1 +dwv,231.45 +ti1 +dwv,220.49 +ti1 +dwv,208.48 +ti1 +dwv,196.04 +ti1 +dwv,182.73 +ti1 +dwv,169.40 +ti1 +dwv,157.24 +ti1 +dwv,145.56 +ti1 +dwv,133.54 +ti1 +dwv,124.01 +ti1 +dwv,114.55 +ti1 +dwv,105.75 +ti1 +dwv,98.32 +ti1 +dwv,91.91 +ti1 +dwv,86.08 +ti1 +dwv,81.35 +ti1 +dwv,77.78 +ti1 +dwv,73.85 +ti1 +dwv,71.12 +ti1 +dwv,68.53 +ti1 +dwv,67.09 +ti1 +dwv,66.34 +ti1 +ti1 +ti1 +dwv,67.92 +ti1 +dwv,70.08 +ti1 +dwv,73.78 +ti1 +dwv,78.68 +ti1 +dwv,84.33 +ti1 +dwv,90.25 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,183.19 +ti1 +dwv,198.96 +ti1 +dwv,213.55 +ti1 +dwv,225.91 +ti1 +dwv,237.33 +ti1 +dwv,246.66 +ti1 +dwv,254.98 +ti1 +dwv,259.46 +ti1 +dwv,261.02 +ti1 +dwv,260.02 +ti1 +dwv,255.96 +ti1 +dwv,249.08 +ti1 +dwv,240.15 +ti1 +dwv,229.51 +ti1 +dwv,217.21 +ti1 +dwv,205.06 +ti1 +dwv,192.62 +ti1 +dwv,177.43 +ti1 +dwv,165.06 +ti1 +dwv,152.36 +ti1 +dwv,142.35 +ti1 +dwv,134.58 +ti1 +dwv,126.20 +ti1 +dwv,119.86 +ti1 +dwv,113.67 +ti1 +dwv,108.20 +ti1 +dwv,104.71 +ti1 +dwv,100.83 +ti1 +dwv,98.96 +ti1 +dwv,98.38 +ti1 +ti1 +dwv,100.29 +ti1 +dwv,103.47 +ti1 +dwv,107.73 +ti1 +dwv,113.04 +ti1 +dwv,118.90 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,200.70 +ti1 +dwv,217.77 +ti1 +dwv,232.45 +ti1 +dwv,244.28 +ti1 +dwv,256.61 +ti1 +dwv,265.93 +ti1 +dwv,272.01 +ti1 +ti1 +dwv,268.67 +ti1 +dwv,260.53 +ti1 +dwv,252.09 +ti1 +dwv,243.72 +ti1 +dwv,232.68 +ti1 +dwv,220.49 +ti1 +dwv,206.88 +ti1 +dwv,193.98 +ti1 +dwv,181.33 +ti1 +dwv,168.61 +ti1 +dwv,156.50 +ti1 +dwv,145.54 +ti1 +dwv,136.43 +ti1 +dwv,125.95 +ti1 +dwv,117.26 +ti1 +dwv,109.81 +ti1 +dwv,103.36 +ti1 +dwv,97.15 +ti1 +dwv,92.86 +ti1 +dwv,89.02 +ti1 +dwv,86.39 +ti1 +dwv,84.44 +ti1 +dwv,83.72 +ti1 +ti1 +dwv,85.89 +ti1 +dwv,88.39 +ti1 +dwv,92.31 +ti1 +dwv,96.00 +ti1 +dwv,100.24 +ti1 +dwv,102.55 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,197.15 +ti1 +dwv,212.33 +ti1 +dwv,225.48 +ti1 +dwv,236.75 +ti1 +dwv,247.52 +ti1 +dwv,255.21 +ti1 +dwv,260.74 +ti1 +dwv,262.81 +ti1 +dwv,262.09 +ti1 +dwv,258.08 +ti1 +dwv,250.83 +ti1 +dwv,242.39 +ti1 +dwv,230.86 +ti1 +dwv,219.62 +ti1 +dwv,206.80 +ti1 +dwv,193.41 +ti1 +dwv,180.60 +ti1 +dwv,168.20 +ti1 +dwv,157.77 +ti1 +dwv,145.25 +ti1 +dwv,136.23 +ti1 +dwv,126.28 +ti1 +dwv,118.10 +ti1 +dwv,110.74 +ti1 +dwv,105.29 +ti1 +dwv,99.75 +ti1 +dwv,95.61 +ti1 +dwv,92.16 +ti1 +dwv,89.93 +ti1 +dwv,88.45 +ti1 +ti1 +dwv,89.11 +ti1 +dwv,90.87 +ti1 +dwv,94.21 +ti1 +dwv,98.16 +ti1 +dwv,104.24 +ti1 +dwv,108.98 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,195.81 +ti1 +dwv,211.95 +ti1 +dwv,226.36 +ti1 +dwv,240.61 +ti1 +dwv,251.93 +ti1 +dwv,259.13 +ti1 +dwv,265.36 +ti1 +dwv,269.71 +ti1 +dwv,270.27 +ti1 +dwv,266.44 +ti1 +dwv,260.44 +ti1 +dwv,251.94 +ti1 +dwv,240.79 +ti1 +dwv,228.95 +ti1 +dwv,215.90 +ti1 +dwv,203.25 +ti1 +dwv,190.01 +ti1 +dwv,177.92 +ti1 +dwv,165.60 +ti1 +dwv,155.49 +ti1 +dwv,144.32 +ti1 +dwv,136.07 +ti1 +dwv,127.64 +ti1 +dwv,120.28 +ti1 +dwv,114.57 +ti1 +dwv,109.99 +ti1 +dwv,106.36 +ti1 +dwv,104.49 +ti1 +dwv,103.84 +ti1 +ti1 +dwv,105.77 +ti1 +dwv,107.83 +ti1 +dwv,112.41 +ti1 +dwv,117.71 +ti1 +dwv,120.66 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,210.13 +ti1 +dwv,225.03 +ti1 +dwv,238.76 +ti1 +dwv,250.50 +ti1 +dwv,261.18 +ti1 +dwv,269.22 +ti1 +dwv,274.18 +ti1 +dwv,272.28 +ti1 +dwv,266.66 +ti1 +dwv,258.68 +ti1 +dwv,249.88 +ti1 +dwv,239.94 +ti1 +dwv,227.14 +ti1 +dwv,213.22 +ti1 +dwv,197.58 +ti1 +dwv,184.86 +ti1 +dwv,172.52 +ti1 +dwv,160.19 +ti1 +dwv,149.20 +ti1 +dwv,137.49 +ti1 +dwv,127.86 +ti1 +dwv,118.91 +ti1 +dwv,110.49 +ti1 +dwv,102.73 +ti1 +dwv,96.33 +ti1 +dwv,90.95 +ti1 +dwv,86.38 +ti1 +dwv,82.72 +ti1 +dwv,79.65 +ti1 +dwv,77.61 +ti1 +dwv,75.70 +ti1 +dwv,74.49 +ti1 +ti1 +ti1 +dwv,76.48 +ti1 +dwv,79.14 +ti1 +dwv,82.84 +ti1 +dwv,87.86 +ti1 +dwv,92.69 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,181.33 +ti1 +dwv,196.86 +ti1 +dwv,210.98 +ti1 +dwv,223.13 +ti1 +dwv,233.90 +ti1 +dwv,243.19 +ti1 +dwv,250.57 +ti1 +dwv,255.00 +ti1 +dwv,256.36 +ti1 +dwv,255.16 +ti1 +dwv,250.15 +ti1 +dwv,242.80 +ti1 +dwv,233.82 +ti1 +dwv,223.41 +ti1 +dwv,210.81 +ti1 +dwv,199.04 +ti1 +dwv,187.39 +ti1 +dwv,174.14 +ti1 +dwv,162.62 +ti1 +dwv,151.39 +ti1 +dwv,139.59 +ti1 +dwv,128.71 +ti1 +dwv,119.17 +ti1 +dwv,111.02 +ti1 +dwv,103.91 +ti1 +dwv,96.78 +ti1 +dwv,91.56 +ti1 +dwv,87.13 +ti1 +dwv,83.22 +ti1 +dwv,80.50 +ti1 +dwv,76.83 +ti1 +dwv,74.24 +ti1 +dwv,70.80 +ti1 +dwv,69.04 +ti1 +dwv,67.12 +ti1 +dwv,66.51 +ti1 +ti1 +dwv,68.77 +ti1 +dwv,72.19 +ti1 +dwv,77.34 +ti1 +dwv,84.04 +ti1 +dwv,88.55 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,190.51 +ti1 +dwv,207.14 +ti1 +dwv,220.57 +ti1 +dwv,232.51 +ti1 +dwv,243.35 +ti1 +dwv,252.41 +ti1 +dwv,258.62 +ti1 +dwv,262.18 +ti1 +ti1 +dwv,259.10 +ti1 +dwv,253.54 +ti1 +dwv,245.44 +ti1 +dwv,235.55 +ti1 +dwv,223.43 +ti1 +dwv,209.91 +ti1 +dwv,197.52 +ti1 +dwv,185.90 +ti1 +dwv,172.13 +ti1 +dwv,161.09 +ti1 +dwv,150.58 +ti1 +dwv,140.37 +ti1 +dwv,130.27 +ti1 +dwv,122.13 +ti1 +dwv,114.99 +ti1 +dwv,108.76 +ti1 +dwv,104.67 +ti1 +dwv,100.36 +ti1 +dwv,97.61 +ti1 +dwv,95.48 +ti1 +dwv,94.83 +ti1 +dwv,95.45 +ti1 +dwv,97.15 +ti1 +dwv,100.73 +ti1 +dwv,105.10 +ti1 +dwv,111.46 +ti1 +dwv,118.27 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,202.92 +ti1 +dwv,220.25 +ti1 +dwv,233.35 +ti1 +dwv,243.48 +ti1 +dwv,254.85 +ti1 +dwv,265.75 +ti1 +dwv,272.62 +ti1 +ti1 +dwv,269.36 +ti1 +dwv,261.82 +ti1 +dwv,252.85 +ti1 +dwv,244.08 +ti1 +dwv,232.96 +ti1 +dwv,219.59 +ti1 +dwv,207.32 +ti1 +dwv,193.87 +ti1 +dwv,181.77 +ti1 +dwv,168.60 +ti1 +dwv,155.76 +ti1 +dwv,144.03 +ti1 +dwv,134.07 +ti1 +dwv,123.46 +ti1 +dwv,114.47 +ti1 +dwv,107.64 +ti1 +dwv,100.46 +ti1 +dwv,94.53 +ti1 +dwv,89.28 +ti1 +dwv,84.59 +ti1 +dwv,80.96 +ti1 +dwv,78.54 +ti1 +dwv,76.28 +ti1 +dwv,75.51 +ti1 +ti1 +dwv,76.55 +ti1 +dwv,78.55 +ti1 +dwv,81.57 +ti1 +dwv,85.18 +ti1 +dwv,90.61 +ti1 +dwv,96.01 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,184.51 +ti1 +dwv,201.57 +ti1 +dwv,216.33 +ti1 +dwv,228.69 +ti1 +dwv,239.90 +ti1 +dwv,250.41 +ti1 +dwv,257.91 +ti1 +dwv,262.29 +ti1 +dwv,263.41 +ti1 +dwv,261.70 +ti1 +dwv,256.75 +ti1 +dwv,246.82 +ti1 +dwv,236.35 +ti1 +dwv,225.17 +ti1 +dwv,212.90 +ti1 +dwv,201.61 +ti1 +dwv,188.42 +ti1 +dwv,175.92 +ti1 +dwv,163.70 +ti1 +dwv,153.18 +ti1 +dwv,142.89 +ti1 +dwv,132.95 +ti1 +dwv,125.18 +ti1 +dwv,117.61 +ti1 +dwv,110.36 +ti1 +dwv,104.56 +ti1 +dwv,100.13 +ti1 +dwv,96.64 +ti1 +dwv,93.52 +ti1 +dwv,91.91 +ti1 +ti1 +ti1 +dwv,93.84 +ti1 +dwv,97.13 +ti1 +dwv,101.08 +ti1 +dwv,107.19 +ti1 +dwv,111.89 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,195.89 +ti1 +dwv,212.65 +ti1 +dwv,226.60 +ti1 +dwv,239.28 +ti1 +dwv,251.28 +ti1 +dwv,259.92 +ti1 +dwv,266.03 +ti1 +dwv,269.76 +ti1 +ti1 +dwv,265.55 +ti1 +dwv,258.92 +ti1 +dwv,250.42 +ti1 +dwv,240.04 +ti1 +dwv,229.03 +ti1 +dwv,216.69 +ti1 +dwv,204.21 +ti1 +dwv,191.25 +ti1 +dwv,178.40 +ti1 +dwv,168.31 +ti1 +dwv,157.47 +ti1 +dwv,148.62 +ti1 +dwv,139.12 +ti1 +dwv,129.54 +ti1 +dwv,121.65 +ti1 +dwv,114.59 +ti1 +dwv,109.30 +ti1 +dwv,106.39 +ti1 +dwv,104.71 +ti1 +ti1 +dwv,106.41 +ti1 +dwv,109.22 +ti1 +dwv,113.62 +ti1 +dwv,118.31 +ti1 +dwv,124.34 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,205.67 +ti1 +dwv,221.25 +ti1 +dwv,235.02 +ti1 +dwv,247.47 +ti1 +dwv,258.37 +ti1 +dwv,267.42 +ti1 +dwv,272.60 +ti1 +dwv,272.00 +ti1 +dwv,267.91 +ti1 +dwv,260.38 +ti1 +dwv,251.10 +ti1 +dwv,241.32 +ti1 +dwv,230.96 +ti1 +dwv,217.34 +ti1 +dwv,204.99 +ti1 +dwv,191.24 +ti1 +dwv,178.58 +ti1 +dwv,164.79 +ti1 +dwv,153.07 +ti1 +dwv,141.06 +ti1 +dwv,129.86 +ti1 +dwv,119.79 +ti1 +dwv,111.13 +ti1 +dwv,103.53 +ti1 +dwv,96.95 +ti1 +dwv,89.42 +ti1 +dwv,85.22 +ti1 +dwv,80.54 +ti1 +dwv,76.85 +ti1 +dwv,74.41 +ti1 +dwv,72.12 +ti1 +dwv,71.21 +ti1 +ti1 +ti1 +dwv,72.13 +ti1 +dwv,74.22 +ti1 +dwv,76.95 +ti1 +dwv,80.65 +ti1 +dwv,85.36 +ti1 +dwv,90.60 +ti1 +dwv,92.36 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,191.27 +ti1 +dwv,205.03 +ti1 +dwv,218.89 +ti1 +dwv,230.87 +ti1 +dwv,241.63 +ti1 +dwv,249.83 +ti1 +dwv,255.42 +ti1 +dwv,257.98 +ti1 +dwv,257.33 +ti1 +dwv,252.87 +ti1 +dwv,245.90 +ti1 +dwv,237.78 +ti1 +dwv,227.14 +ti1 +dwv,214.67 +ti1 +dwv,202.31 +ti1 +dwv,188.68 +ti1 +dwv,175.96 +ti1 +dwv,163.25 +ti1 +dwv,151.43 +ti1 +dwv,139.79 +ti1 +dwv,130.40 +ti1 +dwv,118.92 +ti1 +dwv,110.88 +ti1 +dwv,101.92 +ti1 +dwv,94.45 +ti1 +dwv,88.13 +ti1 +dwv,83.19 +ti1 +dwv,79.11 +ti1 +dwv,74.60 +ti1 +dwv,71.86 +ti1 +dwv,68.77 +ti1 +dwv,66.57 +ti1 +dwv,65.24 +ti1 +dwv,64.41 +ti1 +ti1 +dwv,64.92 +ti1 +dwv,66.62 +ti1 +dwv,68.93 +ti1 +dwv,72.77 +ti1 +dwv,77.76 +ti1 +dwv,83.41 +ti1 +dwv,89.19 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,182.68 +ti1 +dwv,199.88 +ti1 +dwv,214.62 +ti1 +dwv,227.29 +ti1 +dwv,238.62 +ti1 +dwv,249.01 +ti1 +dwv,256.68 +ti1 +dwv,262.71 +ti1 +dwv,263.44 +ti1 +dwv,259.87 +ti1 +dwv,254.66 +ti1 +dwv,248.11 +ti1 +dwv,240.01 +ti1 +dwv,229.30 +ti1 +dwv,216.52 +ti1 +dwv,205.15 +ti1 +dwv,192.49 +ti1 +dwv,179.70 +ti1 +dwv,167.51 +ti1 +dwv,156.31 +ti1 +dwv,145.97 +ti1 +dwv,135.93 +ti1 +dwv,128.06 +ti1 +dwv,119.45 +ti1 +dwv,113.01 +ti1 +dwv,108.31 +ti1 +dwv,103.79 +ti1 +dwv,100.92 +ti1 +dwv,98.90 +ti1 +dwv,98.28 +ti1 +ti1 +dwv,100.12 +ti1 +dwv,102.38 +ti1 +dwv,106.07 +ti1 +dwv,111.06 +ti1 +dwv,117.00 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,202.42 +ti1 +dwv,217.46 +ti1 +dwv,232.83 +ti1 +dwv,245.05 +ti1 +dwv,256.39 +ti1 +dwv,265.28 +ti1 +dwv,271.80 +ti1 +ti1 +dwv,268.63 +ti1 +dwv,261.21 +ti1 +dwv,253.57 +ti1 +dwv,244.41 +ti1 +dwv,233.79 +ti1 +dwv,220.80 +ti1 +dwv,209.24 +ti1 +dwv,196.54 +ti1 +dwv,183.38 +ti1 +dwv,170.14 +ti1 +dwv,157.79 +ti1 +dwv,144.31 +ti1 +dwv,131.53 +ti1 +dwv,122.20 +ti1 +dwv,113.46 +ti1 +dwv,106.57 +ti1 +dwv,100.93 +ti1 +dwv,96.80 +ti1 +dwv,92.10 +ti1 +dwv,88.77 +ti1 +dwv,86.07 +ti1 +dwv,83.75 +ti1 +dwv,82.40 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,84.82 +ti1 +dwv,88.34 +ti1 +dwv,92.06 +ti1 +dwv,98.22 +ti1 +dwv,103.08 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,196.25 +ti1 +dwv,210.62 +ti1 +dwv,223.53 +ti1 +dwv,235.01 +ti1 +dwv,245.30 +ti1 +dwv,253.56 +ti1 +dwv,259.86 +ti1 +dwv,261.87 +ti1 +ti1 +dwv,257.71 +ti1 +dwv,251.10 +ti1 +dwv,242.25 +ti1 +dwv,232.00 +ti1 +dwv,219.62 +ti1 +dwv,207.54 +ti1 +dwv,194.54 +ti1 +dwv,182.85 +ti1 +dwv,170.49 +ti1 +dwv,158.24 +ti1 +dwv,147.54 +ti1 +dwv,137.40 +ti1 +dwv,129.81 +ti1 +dwv,121.07 +ti1 +dwv,114.39 +ti1 +dwv,109.32 +ti1 +dwv,103.67 +ti1 +dwv,99.51 +ti1 +dwv,96.53 +ti1 +dwv,94.67 +ti1 +dwv,93.79 +ti1 +ti1 +dwv,95.31 +ti1 +dwv,98.43 +ti1 +dwv,102.95 +ti1 +dwv,109.01 +ti1 +dwv,115.86 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,209.63 +ti1 +dwv,224.03 +ti1 +dwv,236.93 +ti1 +dwv,249.17 +ti1 +dwv,259.34 +ti1 +dwv,267.41 +ti1 +dwv,271.07 +ti1 +dwv,270.51 +ti1 +dwv,263.93 +ti1 +dwv,255.80 +ti1 +dwv,246.03 +ti1 +dwv,235.96 +ti1 +dwv,223.79 +ti1 +dwv,209.68 +ti1 +dwv,196.98 +ti1 +dwv,184.70 +ti1 +dwv,171.16 +ti1 +dwv,157.06 +ti1 +dwv,145.05 +ti1 +dwv,133.80 +ti1 +dwv,123.45 +ti1 +dwv,114.06 +ti1 +dwv,106.78 +ti1 +dwv,98.12 +ti1 +dwv,91.19 +ti1 +dwv,84.78 +ti1 +dwv,80.10 +ti1 +dwv,74.95 +ti1 +dwv,71.88 +ti1 +dwv,68.51 +ti1 +dwv,66.13 +ti1 +dwv,64.64 +ti1 +dwv,63.65 +ti1 +dwv,63.06 +ti1 +ti1 +dwv,64.29 +ti1 +dwv,66.41 +ti1 +dwv,68.95 +ti1 +dwv,73.12 +ti1 +dwv,78.00 +ti1 +dwv,83.67 +ti1 +dwv,85.55 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,187.86 +ti1 +dwv,202.65 +ti1 +dwv,216.23 +ti1 +dwv,228.24 +ti1 +dwv,239.81 +ti1 +dwv,248.77 +ti1 +dwv,252.97 +ti1 +dwv,254.72 +ti1 +ti1 +dwv,253.22 +ti1 +dwv,247.80 +ti1 +dwv,239.99 +ti1 +dwv,229.87 +ti1 +dwv,218.26 +ti1 +dwv,205.99 +ti1 +dwv,193.09 +ti1 +dwv,180.59 +ti1 +dwv,167.42 +ti1 +dwv,154.33 +ti1 +dwv,142.32 +ti1 +dwv,131.88 +ti1 +dwv,122.32 +ti1 +dwv,112.84 +ti1 +dwv,104.07 +ti1 +dwv,96.62 +ti1 +dwv,90.02 +ti1 +dwv,84.43 +ti1 +dwv,79.90 +ti1 +dwv,74.59 +ti1 +dwv,71.27 +ti1 +dwv,67.37 +ti1 +dwv,64.97 +ti1 +dwv,62.82 +ti1 +dwv,61.60 +ti1 +ti1 +ti1 +dwv,62.99 +ti1 +dwv,64.80 +ti1 +dwv,68.51 +ti1 +dwv,72.70 +ti1 +dwv,77.97 +ti1 +dwv,84.10 +ti1 +dwv,88.07 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +ti1 +dwv,184.25 +ti1 +dwv,199.56 +ti1 +dwv,212.97 +ti1 +dwv,226.37 +ti1 +dwv,237.23 +ti1 +dwv,247.66 +ti1 +dwv,254.97 +ti1 +dwv,259.77 +ti1 +dwv,261.89 +ti1 +dwv,260.39 +ti1 +dwv,255.67 +ti1 +dwv,248.49 +ti1 +dwv,238.75 +ti1 +dwv,228.34 +ti1 +dwv,215.95 +ti1 +dwv,201.71 +ti1 +dwv,187.12 +ti1 +dwv,174.33 +ti1 +dwv,162.05 +ti1 +dwv,151.79 +ti1 +dwv,142.67 +ti1 +dwv,134.03 +ti1 +dwv,126.03 +ti1 +dwv,118.64 +ti1 +dwv,112.00 +ti1 +dwv,107.16 +ti1 +dwv,103.71 +ti1 +dwv,100.06 +ti1 +dwv,98.59 +ti1 +dwv,97.68 +ti1 +ti1 diff --git a/test/rebuf.ok b/test/rebuf.ok new file mode 100644 index 0000000..f452f55 --- /dev/null +++ b/test/rebuf.ok @@ -0,0 +1,1290 @@ +1 0 +2 214.59 +3 230.31 +4 242.64 +5 253.94 +6 264.33 +7 270.94 +8 273.52 +9 270.08 +10 263.19 +11 254.45 +12 244.91 +13 234.55 +14 222.49 +15 209.94 +16 197.17 +17 182.89 +18 169.76 +19 158.59 +20 145.37 +21 135.46 +22 124.77 +23 115.98 +24 108.77 +25 101.12 +26 94.45 +27 89.08 +28 84.63 +29 81.05 +30 78.93 +31 76.65 +32 75.59 +33 75.59 +34 75.59 +35 77.47 +36 80.17 +37 83.90 +38 88.56 +39 95.69 +40 97.48 +41 97.48 +42 97.48 +43 97.48 +44 97.48 +45 97.48 +46 97.48 +47 97.48 +48 203.08 +49 218.22 +50 229.37 +51 238.49 +52 247.43 +53 255.22 +54 261.31 +55 262.36 +56 260.66 +57 256.33 +58 249.34 +59 240.03 +60 228.55 +61 215.42 +62 203.37 +63 190.01 +64 177.81 +65 165.44 +66 152.92 +67 142.03 +68 132.91 +69 124.48 +70 116.45 +71 109.06 +72 103.27 +73 98.87 +74 94.95 +75 92.56 +76 90.47 +77 89.48 +78 89.48 +79 90.53 +80 93.07 +81 97.12 +82 101.82 +83 108.18 +84 109.73 +85 109.73 +86 109.73 +87 109.73 +88 109.73 +89 109.73 +90 109.73 +91 202.97 +92 217.38 +93 231.73 +94 243.11 +95 255.37 +96 264.12 +97 269.64 +98 270.98 +99 269.65 +100 264.55 +101 257.16 +102 246.01 +103 232.88 +104 219.85 +105 208.79 +106 197.00 +107 183.93 +108 172.00 +109 160.55 +110 150.59 +111 141.47 +112 133.02 +113 126.21 +114 120.64 +115 115.79 +116 111.62 +117 108.41 +118 106.41 +119 106.41 +120 106.41 +121 109.08 +122 113.23 +123 118.57 +124 122.57 +125 122.57 +126 122.57 +127 122.57 +128 122.57 +129 122.57 +130 122.57 +131 208.07 +132 224.14 +133 236.28 +134 248.12 +135 258.97 +136 267.74 +137 272.47 +138 271.52 +139 266.80 +140 258.61 +141 249.30 +142 239.19 +143 228.28 +144 215.79 +145 203.86 +146 190.08 +147 177.40 +148 163.81 +149 152.60 +150 141.33 +151 130.98 +152 121.98 +153 114.08 +154 106.61 +155 99.75 +156 93.10 +157 86.57 +158 80.62 +159 76.05 +160 71.52 +161 68.85 +162 67.46 +163 66.86 +164 67.51 +165 69.75 +166 72.85 +167 76.23 +168 82.85 +169 89.33 +170 93.39 +171 93.39 +172 93.39 +173 93.39 +174 93.39 +175 93.39 +176 93.39 +177 93.39 +178 188.37 +179 204.42 +180 217.16 +181 228.89 +182 238.83 +183 247.70 +184 253.59 +185 257.17 +186 257.17 +187 254.00 +188 248.24 +189 240.14 +190 229.42 +191 218.97 +192 205.09 +193 192.61 +194 179.74 +195 166.76 +196 155.36 +197 143.58 +198 131.40 +199 121.84 +200 112.46 +201 105.41 +202 97.15 +203 90.09 +204 84.79 +205 80.52 +206 75.58 +207 72.59 +208 69.39 +209 67.51 +210 66.42 +211 66.42 +212 66.42 +213 67.82 +214 69.76 +215 73.19 +216 77.35 +217 82.36 +218 87.82 +219 93.30 +220 93.30 +221 93.30 +222 93.30 +223 93.30 +224 93.30 +225 93.30 +226 93.30 +227 190.58 +228 203.43 +229 216.48 +230 228.89 +231 241.91 +232 251.60 +233 257.78 +234 262.18 +235 263.13 +236 260.91 +237 255.34 +238 247.17 +239 236.85 +240 225.24 +241 213.39 +242 201.46 +243 187.77 +244 175.31 +245 162.95 +246 152.55 +247 142.56 +248 132.94 +249 125.00 +250 117.69 +251 110.96 +252 105.02 +253 101.78 +254 98.48 +255 97.06 +256 96.50 +257 96.50 +258 98.48 +259 101.18 +260 104.56 +261 109.67 +262 115.86 +263 115.86 +264 115.86 +265 115.86 +266 115.86 +267 115.86 +268 115.86 +269 200.02 +270 217.51 +271 233.21 +272 245.72 +273 258.21 +274 267.24 +275 273.79 +276 273.20 +277 270.38 +278 260.76 +279 250.05 +280 241.32 +281 231.14 +282 219.83 +283 206.13 +284 193.24 +285 180.73 +286 167.82 +287 156.94 +288 144.13 +289 134.40 +290 125.23 +291 116.13 +292 107.34 +293 99.71 +294 94.11 +295 88.91 +296 84.51 +297 81.50 +298 78.66 +299 76.57 +300 75.82 +301 75.82 +302 76.88 +303 79.03 +304 82.12 +305 85.73 +306 91.05 +307 96.31 +308 96.31 +309 96.31 +310 96.31 +311 96.31 +312 96.31 +313 96.31 +314 96.31 +315 184.18 +316 201.10 +317 214.21 +318 226.18 +319 237.72 +320 247.57 +321 254.36 +322 258.34 +323 259.80 +324 257.76 +325 253.17 +326 246.51 +327 237.92 +328 227.09 +329 214.13 +330 202.20 +331 189.21 +332 177.65 +333 166.18 +334 154.03 +335 142.21 +336 131.51 +337 121.28 +338 111.80 +339 104.47 +340 98.80 +341 94.76 +342 91.81 +343 89.17 +344 88.00 +345 88.00 +346 88.00 +347 89.20 +348 91.17 +349 94.35 +350 99.00 +351 105.43 +352 109.34 +353 109.34 +354 109.34 +355 109.34 +356 109.34 +357 109.34 +358 109.34 +359 194.84 +360 212.05 +361 226.30 +362 239.03 +363 250.94 +364 259.73 +365 266.64 +366 269.67 +367 269.03 +368 265.03 +369 258.23 +370 249.32 +371 238.03 +372 226.20 +373 213.46 +374 200.53 +375 187.65 +376 174.89 +377 163.22 +378 152.47 +379 142.65 +380 133.97 +381 126.59 +382 120.52 +383 115.57 +384 111.49 +385 108.03 +386 106.01 +387 105.28 +388 105.28 +389 106.91 +390 109.73 +391 114.91 +392 120.66 +393 123.74 +394 123.74 +395 123.74 +396 123.74 +397 123.74 +398 123.74 +399 123.74 +400 211.57 +401 227.06 +402 240.57 +403 252.26 +404 262.67 +405 270.66 +406 273.40 +407 270.25 +408 263.76 +409 256.03 +410 246.87 +411 237.10 +412 225.11 +413 211.53 +414 197.77 +415 185.75 +416 173.00 +417 159.31 +418 147.18 +419 134.84 +420 125.07 +421 115.82 +422 107.33 +423 100.07 +424 93.55 +425 87.60 +426 81.75 +427 77.03 +428 73.39 +429 70.97 +430 67.94 +431 66.64 +432 65.80 +433 65.80 +434 66.85 +435 68.78 +436 71.47 +437 74.20 +438 78.68 +439 85.08 +440 87.47 +441 87.47 +442 87.47 +443 87.47 +444 87.47 +445 87.47 +446 87.47 +447 87.47 +448 185.81 +449 201.66 +450 215.07 +451 227.26 +452 238.00 +453 247.64 +454 255.03 +455 257.12 +456 256.17 +457 253.47 +458 248.93 +459 241.39 +460 231.45 +461 220.49 +462 208.48 +463 196.04 +464 182.73 +465 169.40 +466 157.24 +467 145.56 +468 133.54 +469 124.01 +470 114.55 +471 105.75 +472 98.32 +473 91.91 +474 86.08 +475 81.35 +476 77.78 +477 73.85 +478 71.12 +479 68.53 +480 67.09 +481 66.34 +482 66.34 +483 66.34 +484 67.92 +485 70.08 +486 73.78 +487 78.68 +488 84.33 +489 90.25 +490 90.25 +491 90.25 +492 90.25 +493 90.25 +494 90.25 +495 90.25 +496 90.25 +497 183.19 +498 198.96 +499 213.55 +500 225.91 +501 237.33 +502 246.66 +503 254.98 +504 259.46 +505 261.02 +506 260.02 +507 255.96 +508 249.08 +509 240.15 +510 229.51 +511 217.21 +512 205.06 +513 192.62 +514 177.43 +515 165.06 +516 152.36 +517 142.35 +518 134.58 +519 126.20 +520 119.86 +521 113.67 +522 108.20 +523 104.71 +524 100.83 +525 98.96 +526 98.38 +527 98.38 +528 100.29 +529 103.47 +530 107.73 +531 113.04 +532 118.90 +533 118.90 +534 118.90 +535 118.90 +536 118.90 +537 118.90 +538 118.90 +539 200.70 +540 217.77 +541 232.45 +542 244.28 +543 256.61 +544 265.93 +545 272.01 +546 272.01 +547 268.67 +548 260.53 +549 252.09 +550 243.72 +551 232.68 +552 220.49 +553 206.88 +554 193.98 +555 181.33 +556 168.61 +557 156.50 +558 145.54 +559 136.43 +560 125.95 +561 117.26 +562 109.81 +563 103.36 +564 97.15 +565 92.86 +566 89.02 +567 86.39 +568 84.44 +569 83.72 +570 83.72 +571 85.89 +572 88.39 +573 92.31 +574 96.00 +575 100.24 +576 102.55 +577 102.55 +578 102.55 +579 102.55 +580 102.55 +581 102.55 +582 102.55 +583 102.55 +584 197.15 +585 212.33 +586 225.48 +587 236.75 +588 247.52 +589 255.21 +590 260.74 +591 262.81 +592 262.09 +593 258.08 +594 250.83 +595 242.39 +596 230.86 +597 219.62 +598 206.80 +599 193.41 +600 180.60 +601 168.20 +602 157.77 +603 145.25 +604 136.23 +605 126.28 +606 118.10 +607 110.74 +608 105.29 +609 99.75 +610 95.61 +611 92.16 +612 89.93 +613 88.45 +614 88.45 +615 89.11 +616 90.87 +617 94.21 +618 98.16 +619 104.24 +620 108.98 +621 108.98 +622 108.98 +623 108.98 +624 108.98 +625 108.98 +626 108.98 +627 195.81 +628 211.95 +629 226.36 +630 240.61 +631 251.93 +632 259.13 +633 265.36 +634 269.71 +635 270.27 +636 266.44 +637 260.44 +638 251.94 +639 240.79 +640 228.95 +641 215.90 +642 203.25 +643 190.01 +644 177.92 +645 165.60 +646 155.49 +647 144.32 +648 136.07 +649 127.64 +650 120.28 +651 114.57 +652 109.99 +653 106.36 +654 104.49 +655 103.84 +656 103.84 +657 105.77 +658 107.83 +659 112.41 +660 117.71 +661 120.66 +662 120.66 +663 120.66 +664 120.66 +665 120.66 +666 120.66 +667 120.66 +668 210.13 +669 225.03 +670 238.76 +671 250.50 +672 261.18 +673 269.22 +674 274.18 +675 272.28 +676 266.66 +677 258.68 +678 249.88 +679 239.94 +680 227.14 +681 213.22 +682 197.58 +683 184.86 +684 172.52 +685 160.19 +686 149.20 +687 137.49 +688 127.86 +689 118.91 +690 110.49 +691 102.73 +692 96.33 +693 90.95 +694 86.38 +695 82.72 +696 79.65 +697 77.61 +698 75.70 +699 74.49 +700 74.49 +701 74.49 +702 76.48 +703 79.14 +704 82.84 +705 87.86 +706 92.69 +707 92.69 +708 92.69 +709 92.69 +710 92.69 +711 92.69 +712 92.69 +713 92.69 +714 181.33 +715 196.86 +716 210.98 +717 223.13 +718 233.90 +719 243.19 +720 250.57 +721 255.00 +722 256.36 +723 255.16 +724 250.15 +725 242.80 +726 233.82 +727 223.41 +728 210.81 +729 199.04 +730 187.39 +731 174.14 +732 162.62 +733 151.39 +734 139.59 +735 128.71 +736 119.17 +737 111.02 +738 103.91 +739 96.78 +740 91.56 +741 87.13 +742 83.22 +743 80.50 +744 76.83 +745 74.24 +746 70.80 +747 69.04 +748 67.12 +749 66.51 +750 66.51 +751 68.77 +752 72.19 +753 77.34 +754 84.04 +755 88.55 +756 88.55 +757 88.55 +758 88.55 +759 88.55 +760 88.55 +761 88.55 +762 88.55 +763 190.51 +764 207.14 +765 220.57 +766 232.51 +767 243.35 +768 252.41 +769 258.62 +770 262.18 +771 262.18 +772 259.10 +773 253.54 +774 245.44 +775 235.55 +776 223.43 +777 209.91 +778 197.52 +779 185.90 +780 172.13 +781 161.09 +782 150.58 +783 140.37 +784 130.27 +785 122.13 +786 114.99 +787 108.76 +788 104.67 +789 100.36 +790 97.61 +791 95.48 +792 94.83 +793 95.45 +794 97.15 +795 100.73 +796 105.10 +797 111.46 +798 118.27 +799 118.27 +800 118.27 +801 118.27 +802 118.27 +803 118.27 +804 118.27 +805 202.92 +806 220.25 +807 233.35 +808 243.48 +809 254.85 +810 265.75 +811 272.62 +812 272.62 +813 269.36 +814 261.82 +815 252.85 +816 244.08 +817 232.96 +818 219.59 +819 207.32 +820 193.87 +821 181.77 +822 168.60 +823 155.76 +824 144.03 +825 134.07 +826 123.46 +827 114.47 +828 107.64 +829 100.46 +830 94.53 +831 89.28 +832 84.59 +833 80.96 +834 78.54 +835 76.28 +836 75.51 +837 75.51 +838 76.55 +839 78.55 +840 81.57 +841 85.18 +842 90.61 +843 96.01 +844 96.01 +845 96.01 +846 96.01 +847 96.01 +848 96.01 +849 96.01 +850 96.01 +851 184.51 +852 201.57 +853 216.33 +854 228.69 +855 239.90 +856 250.41 +857 257.91 +858 262.29 +859 263.41 +860 261.70 +861 256.75 +862 246.82 +863 236.35 +864 225.17 +865 212.90 +866 201.61 +867 188.42 +868 175.92 +869 163.70 +870 153.18 +871 142.89 +872 132.95 +873 125.18 +874 117.61 +875 110.36 +876 104.56 +877 100.13 +878 96.64 +879 93.52 +880 91.91 +881 91.91 +882 91.91 +883 93.84 +884 97.13 +885 101.08 +886 107.19 +887 111.89 +888 111.89 +889 111.89 +890 111.89 +891 111.89 +892 111.89 +893 111.89 +894 195.89 +895 212.65 +896 226.60 +897 239.28 +898 251.28 +899 259.92 +900 266.03 +901 269.76 +902 269.76 +903 265.55 +904 258.92 +905 250.42 +906 240.04 +907 229.03 +908 216.69 +909 204.21 +910 191.25 +911 178.40 +912 168.31 +913 157.47 +914 148.62 +915 139.12 +916 129.54 +917 121.65 +918 114.59 +919 109.30 +920 106.39 +921 104.71 +922 104.71 +923 106.41 +924 109.22 +925 113.62 +926 118.31 +927 124.34 +928 124.34 +929 124.34 +930 124.34 +931 124.34 +932 124.34 +933 124.34 +934 205.67 +935 221.25 +936 235.02 +937 247.47 +938 258.37 +939 267.42 +940 272.60 +941 272.00 +942 267.91 +943 260.38 +944 251.10 +945 241.32 +946 230.96 +947 217.34 +948 204.99 +949 191.24 +950 178.58 +951 164.79 +952 153.07 +953 141.06 +954 129.86 +955 119.79 +956 111.13 +957 103.53 +958 96.95 +959 89.42 +960 85.22 +961 80.54 +962 76.85 +963 74.41 +964 72.12 +965 71.21 +966 71.21 +967 71.21 +968 72.13 +969 74.22 +970 76.95 +971 80.65 +972 85.36 +973 90.60 +974 92.36 +975 92.36 +976 92.36 +977 92.36 +978 92.36 +979 92.36 +980 92.36 +981 92.36 +982 191.27 +983 205.03 +984 218.89 +985 230.87 +986 241.63 +987 249.83 +988 255.42 +989 257.98 +990 257.33 +991 252.87 +992 245.90 +993 237.78 +994 227.14 +995 214.67 +996 202.31 +997 188.68 +998 175.96 +999 163.25 +1000 151.43 +1001 139.79 +1002 130.40 +1003 118.92 +1004 110.88 +1005 101.92 +1006 94.45 +1007 88.13 +1008 83.19 +1009 79.11 +1010 74.60 +1011 71.86 +1012 68.77 +1013 66.57 +1014 65.24 +1015 64.41 +1016 64.41 +1017 64.92 +1018 66.62 +1019 68.93 +1020 72.77 +1021 77.76 +1022 83.41 +1023 89.19 +1024 89.19 +1025 89.19 +1026 89.19 +1027 89.19 +1028 89.19 +1029 89.19 +1030 89.19 +1031 182.68 +1032 199.88 +1033 214.62 +1034 227.29 +1035 238.62 +1036 249.01 +1037 256.68 +1038 262.71 +1039 263.44 +1040 259.87 +1041 254.66 +1042 248.11 +1043 240.01 +1044 229.30 +1045 216.52 +1046 205.15 +1047 192.49 +1048 179.70 +1049 167.51 +1050 156.31 +1051 145.97 +1052 135.93 +1053 128.06 +1054 119.45 +1055 113.01 +1056 108.31 +1057 103.79 +1058 100.92 +1059 98.90 +1060 98.28 +1061 98.28 +1062 100.12 +1063 102.38 +1064 106.07 +1065 111.06 +1066 117.00 +1067 117.00 +1068 117.00 +1069 117.00 +1070 117.00 +1071 117.00 +1072 117.00 +1073 202.42 +1074 217.46 +1075 232.83 +1076 245.05 +1077 256.39 +1078 265.28 +1079 271.80 +1080 271.80 +1081 268.63 +1082 261.21 +1083 253.57 +1084 244.41 +1085 233.79 +1086 220.80 +1087 209.24 +1088 196.54 +1089 183.38 +1090 170.14 +1091 157.79 +1092 144.31 +1093 131.53 +1094 122.20 +1095 113.46 +1096 106.57 +1097 100.93 +1098 96.80 +1099 92.10 +1100 88.77 +1101 86.07 +1102 83.75 +1103 82.40 +1104 82.40 +1105 82.40 +1106 82.40 +1107 82.40 +1108 84.82 +1109 88.34 +1110 92.06 +1111 98.22 +1112 103.08 +1113 103.08 +1114 103.08 +1115 103.08 +1116 103.08 +1117 103.08 +1118 196.25 +1119 210.62 +1120 223.53 +1121 235.01 +1122 245.30 +1123 253.56 +1124 259.86 +1125 261.87 +1126 261.87 +1127 257.71 +1128 251.10 +1129 242.25 +1130 232.00 +1131 219.62 +1132 207.54 +1133 194.54 +1134 182.85 +1135 170.49 +1136 158.24 +1137 147.54 +1138 137.40 +1139 129.81 +1140 121.07 +1141 114.39 +1142 109.32 +1143 103.67 +1144 99.51 +1145 96.53 +1146 94.67 +1147 93.79 +1148 93.79 +1149 95.31 +1150 98.43 +1151 102.95 +1152 109.01 +1153 115.86 +1154 115.86 +1155 115.86 +1156 115.86 +1157 115.86 +1158 115.86 +1159 115.86 +1160 115.86 +1161 209.63 +1162 224.03 +1163 236.93 +1164 249.17 +1165 259.34 +1166 267.41 +1167 271.07 +1168 270.51 +1169 263.93 +1170 255.80 +1171 246.03 +1172 235.96 +1173 223.79 +1174 209.68 +1175 196.98 +1176 184.70 +1177 171.16 +1178 157.06 +1179 145.05 +1180 133.80 +1181 123.45 +1182 114.06 +1183 106.78 +1184 98.12 +1185 91.19 +1186 84.78 +1187 80.10 +1188 74.95 +1189 71.88 +1190 68.51 +1191 66.13 +1192 64.64 +1193 63.65 +1194 63.06 +1195 63.06 +1196 64.29 +1197 66.41 +1198 68.95 +1199 73.12 +1200 78.00 +1201 83.67 +1202 85.55 +1203 85.55 +1204 85.55 +1205 85.55 +1206 85.55 +1207 85.55 +1208 85.55 +1209 85.55 +1210 187.86 +1211 202.65 +1212 216.23 +1213 228.24 +1214 239.81 +1215 248.77 +1216 252.97 +1217 254.72 +1218 254.72 +1219 253.22 +1220 247.80 +1221 239.99 +1222 229.87 +1223 218.26 +1224 205.99 +1225 193.09 +1226 180.59 +1227 167.42 +1228 154.33 +1229 142.32 +1230 131.88 +1231 122.32 +1232 112.84 +1233 104.07 +1234 96.62 +1235 90.02 +1236 84.43 +1237 79.90 +1238 74.59 +1239 71.27 +1240 67.37 +1241 64.97 +1242 62.82 +1243 61.60 +1244 61.60 +1245 61.60 +1246 62.99 +1247 64.80 +1248 68.51 +1249 72.70 +1250 77.97 +1251 84.10 +1252 88.07 +1253 88.07 +1254 88.07 +1255 88.07 +1256 88.07 +1257 88.07 +1258 88.07 +1259 88.07 +1260 184.25 +1261 199.56 +1262 212.97 +1263 226.37 +1264 237.23 +1265 247.66 +1266 254.97 +1267 259.77 +1268 261.89 +1269 260.39 +1270 255.67 +1271 248.49 +1272 238.75 +1273 228.34 +1274 215.95 +1275 201.71 +1276 187.12 +1277 174.33 +1278 162.05 +1279 151.79 +1280 142.67 +1281 134.03 +1282 126.03 +1283 118.64 +1284 112.00 +1285 107.16 +1286 103.71 +1287 100.06 +1288 98.59 +1289 97.68 +1290 97.68 diff --git a/test/redfilnm.awk b/test/redfilnm.awk new file mode 100644 index 0000000..83cb6aa --- /dev/null +++ b/test/redfilnm.awk @@ -0,0 +1,98 @@ +#Date: Tue, 18 May 1999 12:48:07 -0500 (CDT) +#From: Darrel Hankerson +#To: arnold@gnu.org +#Subject: [christopher.procter@bt.com: RE: Getline bug in Gawk 3.0.3] +# +#Here's a reply that came directly to me. --darrel +# +# +#From: christopher.procter@bt.com +#To: hankedr@dms.auburn.edu +#Subject: RE: Getline bug in Gawk 3.0.3 +#Date: Tue, 18 May 1999 18:42:28 +0100 +# +#Sorry that was me getting carried away and cut and pasting the wrong thing +#into my email +# +#The real problem seems to be that : +#BEGIN { +#for (i=1;i<10;i++){ +# while((getline < "hello.txt")>0){ +# print $0 +# } +# close("hello.txt") +# } +#} +#works (printing the contents of hello.txt 9 times), where as:- +# +#END{ +#for (i=1;i<10;i++){ +# while((getline < "hello.txt")>0){ +# print $0 +# } +# close("hello.txt") +# } +#} +# +#doesn't, (it prints out hello.txt once followed by the iteration numbers +#from 1 to 9). +#The only difference is that one is in the BEGIN block and one in the END +#block. +# +#Sorry about the first post, I'm not a bad awk programmer, just a tired one +#:) +# +#chris +# +#> -----Original Message----- +#> From: Darrel Hankerson [SMTP:hankedr@dms.auburn.edu] +#> Sent: 18 May 1999 18:28 +#> To: christopher.procter@bt.com +#> Subject: Re: Getline bug in Gawk 3.0.3 +#> +#> Could you clarify? Your first script uses an apparently undefined +#> variable f. +#> +#> +#> christopher.procter@bt.com writes: +#> +#> BEGIN { +#> for (i=1;i<10;i++){ +#> while((getline < "hello.txt")>0){ +#> print $0 +#> } +#> close(f) +#> } +#> } +#> +#> refuses to close the file and so prints the contents of hello.txt just +#> once. +#> However:- +#> +#> BEGIN { +#> f="hello.txt" +#> for (i=1;i<10;i++){ +#> while((getline < f)>0){ +#> print $0 +#> } +#> close(f) +#> } +#> } +#> +#> works as advertised (printing the contents of hello.txt 9 times) +#> It seems like a bug in the close statement. +#> +#> -- +#> --Darrel Hankerson hankedr@mail.auburn.edu +# + +# srcdir is assigned on command line --- ADR +END { + f = srcdir "/redfilnm.in" + for (i = 1; i < 10; i++){ + while((getline < f) > 0){ + print $0 + } + close(f) + } +} diff --git a/test/redfilnm.in b/test/redfilnm.in new file mode 100644 index 0000000..4b5fa63 --- /dev/null +++ b/test/redfilnm.in @@ -0,0 +1 @@ +hello, world diff --git a/test/redfilnm.ok b/test/redfilnm.ok new file mode 100644 index 0000000..f9e095a --- /dev/null +++ b/test/redfilnm.ok @@ -0,0 +1,9 @@ +hello, world +hello, world +hello, world +hello, world +hello, world +hello, world +hello, world +hello, world +hello, world diff --git a/test/reg/Obsolete/exp.awk b/test/reg/Obsolete/exp.awk new file mode 100644 index 0000000..4e707f8 --- /dev/null +++ b/test/reg/Obsolete/exp.awk @@ -0,0 +1 @@ +BEGIN { print exp(0), exp(1000000), exp(0.5) } diff --git a/test/reg/Obsolete/exp.good b/test/reg/Obsolete/exp.good new file mode 100644 index 0000000..07b8853 --- /dev/null +++ b/test/reg/Obsolete/exp.good @@ -0,0 +1,2 @@ +1 gawk: reg/exp.awk:1: warning: exp argument 1e+06 is out of range +Inf 1.64872 diff --git a/test/reg/Obsolete/exp.in b/test/reg/Obsolete/exp.in new file mode 100644 index 0000000..e69de29 diff --git a/test/reg/Obsolete/log.awk b/test/reg/Obsolete/log.awk new file mode 100644 index 0000000..bcae90b --- /dev/null +++ b/test/reg/Obsolete/log.awk @@ -0,0 +1 @@ +BEGIN { print log(0), log(-1), log(100) } diff --git a/test/reg/Obsolete/log.good b/test/reg/Obsolete/log.good new file mode 100644 index 0000000..857ab77 --- /dev/null +++ b/test/reg/Obsolete/log.good @@ -0,0 +1,4 @@ +log: SING error +-Inf gawk: reg/log.awk:1: warning: log called with negative argument -1 +log: DOMAIN error +NaN 4.60517 diff --git a/test/reg/Obsolete/log.in b/test/reg/Obsolete/log.in new file mode 100644 index 0000000..e69de29 diff --git a/test/reg/exp-eq.awk b/test/reg/exp-eq.awk new file mode 100644 index 0000000..fed6a69 --- /dev/null +++ b/test/reg/exp-eq.awk @@ -0,0 +1 @@ +{ $0 ^= 3 ; print $1} diff --git a/test/reg/exp-eq.good b/test/reg/exp-eq.good new file mode 100644 index 0000000..d8d59aa --- /dev/null +++ b/test/reg/exp-eq.good @@ -0,0 +1,3 @@ +1 +8 +27 diff --git a/test/reg/exp-eq.in b/test/reg/exp-eq.in new file mode 100644 index 0000000..01e79c3 --- /dev/null +++ b/test/reg/exp-eq.in @@ -0,0 +1,3 @@ +1 +2 +3 diff --git a/test/reg/func.awk b/test/reg/func.awk new file mode 100644 index 0000000..e32cd4e --- /dev/null +++ b/test/reg/func.awk @@ -0,0 +1 @@ +BEGIN { print dummy(1) } diff --git a/test/reg/func.good b/test/reg/func.good new file mode 100644 index 0000000..d3c7c71 --- /dev/null +++ b/test/reg/func.good @@ -0,0 +1 @@ +gawk: reg/func.awk:1: fatal: function `dummy' not defined diff --git a/test/reg/func.in b/test/reg/func.in new file mode 100644 index 0000000..e69de29 diff --git a/test/reg/func2.awk b/test/reg/func2.awk new file mode 100644 index 0000000..2abf2c1 --- /dev/null +++ b/test/reg/func2.awk @@ -0,0 +1,2 @@ +function dummy() { ; } +BEGIN { print dummy (1) } diff --git a/test/reg/func2.good b/test/reg/func2.good new file mode 100644 index 0000000..55ea9ac --- /dev/null +++ b/test/reg/func2.good @@ -0,0 +1,2 @@ +gawk: reg/func2.awk:2: error: function `dummy' called with space between name and `(', +or used as a variable or an array diff --git a/test/reg/func2.in b/test/reg/func2.in new file mode 100644 index 0000000..e69de29 diff --git a/test/regeq.awk b/test/regeq.awk new file mode 100644 index 0000000..0208eb2 --- /dev/null +++ b/test/regeq.awk @@ -0,0 +1,29 @@ +#Date: Sat, 8 May 1999 17:42:20 +0200 +#From: Iva Cabric +#To: bug-gnu-utils@gnu.org +#Cc: arnold@gnu.org +#Subject: Problem in gawk with match +# +#Hello, +# +#gawk reports fatal error in match when first character in regexp is "=" : +# +#$ gawk '{ where = match($0, /=a/); print where}' +#gawk: cmd. line:1: { where = match($0, /=a/); print where} +#gawk: cmd. line:1: ^ parse error +#gawk: cmd. line:1: fatal: match() cannot have 0 arguments +# +#Using "\=" instead "=" works without problems : +# +#$ gawk '{ where = match($0, /\=a/); print where}' +#sdgfa +#0 +#asdfds=a +#7 +# +#Other versions of awk have no problems with "/=/" (except oawk on SunOS). +# +#-- +# @ +# +{ where = match($0, /=a/); print where} diff --git a/test/regeq.in b/test/regeq.in new file mode 100644 index 0000000..2428df3 --- /dev/null +++ b/test/regeq.in @@ -0,0 +1,2 @@ +sdgfa +asdfds=a diff --git a/test/regeq.ok b/test/regeq.ok new file mode 100644 index 0000000..4596f88 --- /dev/null +++ b/test/regeq.ok @@ -0,0 +1,2 @@ +0 +7 diff --git a/test/regrange.awk b/test/regrange.awk new file mode 100644 index 0000000..7187931 --- /dev/null +++ b/test/regrange.awk @@ -0,0 +1,30 @@ +# Tests due to John Haque, May 2011 +# +# The following should be fatal; can't catch them inside awk, though +# $> echo 'a' | ./gawk '/[z-a]/ { print }' +# $> echo 'A' | ./gawk '/[+-[:digit:]]/' + +BEGIN { + char[1] = "." + pat[1] = "[--\\/]" + + char[2] = "a" + pat[2] = "[]-c]" + + char[3] = "c" + pat[3] = "[[a-d]" + + char[4] = "\\" + pat[4] = "[\\[-\\]]" + + char[5] = "[.c.]" + pat[5] = "[a-[.e.]]" + + char[6] = "[.d.]" + pat[6] = "[[.c.]-[.z.]]" + + for (i = 1; i in char; i++) { + printf("\"%s\" ~ /%s/ --> %d\n", char[i], pat[i], + char[i] ~ pat[i]) + } +} diff --git a/test/regrange.ok b/test/regrange.ok new file mode 100644 index 0000000..1fa00c7 --- /dev/null +++ b/test/regrange.ok @@ -0,0 +1,6 @@ +"." ~ /[--\/]/ --> 1 +"a" ~ /[]-c]/ --> 1 +"c" ~ /[[a-d]/ --> 1 +"\" ~ /[\[-\]]/ --> 1 +"[.c.]" ~ /[a-[.e.]]/ --> 1 +"[.d.]" ~ /[[.c.]-[.z.]]/ --> 0 diff --git a/test/regtest.sh b/test/regtest.sh new file mode 100755 index 0000000..37472b1 --- /dev/null +++ b/test/regtest.sh @@ -0,0 +1,18 @@ +#! /bin/sh + +case "$AWK" in +"") AWK=../gawk ;; +esac +#AWK=${AWK:-../gawk} + +for i in reg/*.awk +do + it=`basename $i .awk` + $AWK -f $i reg/$it.out 2>&1 + if diff reg/$it.out reg/$it.good + then + rm -f reg/$it.out + else + echo "regtest: $it fails" + fi +done diff --git a/test/regx8bit.awk b/test/regx8bit.awk new file mode 100644 index 0000000..5ecd7eb --- /dev/null +++ b/test/regx8bit.awk @@ -0,0 +1,26 @@ +# The full test will only work in a Swedish localte +# Try things that should work across the board +# BEGIN { +# s = "så är det" +# print match(s,/\yså\y/), s ~ /\yså\y/, "å" ~ /\w/ +# } +BEGIN { + printf "\"å\" = %c\n", "å" + printf "\"ä\" = %c\n", "ä" + s = "så är det" + printf "s = \"%s\"\n", s + printf "match(s,/\\yså/) = %d\n", match(s, /\yså/) +# printf "match(s,/så\\y/) = %d\n", match(s, /så\y/) +# printf "match(s,/\\yså\\y/) = %d\n", match(s, /\yså\y/) + printf "s ~ /å/ = %d\n", s ~ /å/ + printf "s ~ /så/ = %d\n", s ~ /så/ + printf "s ~ /\\yså/ = %d\n", s ~ /\yså/ +# printf "s ~ /så\\y/ = %d\n", s ~ /så\y/ +# printf "s ~ /\\yså\\y/ = %d\n", s ~ /\yså\y/ +# printf "\"å\" ~ /\\w/ = %d\n", "å" ~ /\w/ +# printf "\"ä\" ~ /\\w/ = %d\n", "ä" ~ /\w/ +# printf "\"å\" ~ /\\yä\\y/ = %d\n", "å" ~ /\yå\y/ +# printf "\"ä\" ~ /\\yä\\y/ = %d\n", "ä" ~ /\yä\y/ +# printf "\"å\" ~ /[[:alpha:]]/ = %d\n", "å" ~ /[[:alpha:]]/ +# printf "\"ä\" ~ /[[:alpha:]]/ = %d\n", "ä" ~ /[[:alpha:]]/ +} diff --git a/test/regx8bit.ok b/test/regx8bit.ok new file mode 100644 index 0000000..76e1c0b --- /dev/null +++ b/test/regx8bit.ok @@ -0,0 +1,7 @@ +"å" = å +"ä" = ä +s = "så är det" +match(s,/\yså/) = 1 +s ~ /å/ = 1 +s ~ /så/ = 1 +s ~ /\yså/ = 1 diff --git a/test/reindops.awk b/test/reindops.awk new file mode 100644 index 0000000..13ae657 --- /dev/null +++ b/test/reindops.awk @@ -0,0 +1,6 @@ +{ + if ($1 !~ /^+[2-9]/) + print "gawk is broken" + else + print "gawk is ok" +} diff --git a/test/reindops.in b/test/reindops.in new file mode 100644 index 0000000..b1e5435 --- /dev/null +++ b/test/reindops.in @@ -0,0 +1 @@ ++44 123 456 diff --git a/test/reindops.ok b/test/reindops.ok new file mode 100644 index 0000000..f9605fd --- /dev/null +++ b/test/reindops.ok @@ -0,0 +1 @@ +gawk is ok diff --git a/test/reint.awk b/test/reint.awk new file mode 100644 index 0000000..add0f2a --- /dev/null +++ b/test/reint.awk @@ -0,0 +1 @@ +{ print match($0, /a{3}/) } diff --git a/test/reint.in b/test/reint.in new file mode 100644 index 0000000..43caa2a --- /dev/null +++ b/test/reint.in @@ -0,0 +1 @@ +match this: aaa diff --git a/test/reint.ok b/test/reint.ok new file mode 100644 index 0000000..b1bd38b --- /dev/null +++ b/test/reint.ok @@ -0,0 +1 @@ +13 diff --git a/test/reint2.awk b/test/reint2.awk new file mode 100644 index 0000000..f9269dd --- /dev/null +++ b/test/reint2.awk @@ -0,0 +1 @@ +/^([[:digit:]]+[[:space:]]+){2}/ diff --git a/test/reint2.in b/test/reint2.in new file mode 100644 index 0000000..b85905e --- /dev/null +++ b/test/reint2.in @@ -0,0 +1 @@ +1 2 3 diff --git a/test/reint2.ok b/test/reint2.ok new file mode 100644 index 0000000..b85905e --- /dev/null +++ b/test/reint2.ok @@ -0,0 +1 @@ +1 2 3 diff --git a/test/reparse.awk b/test/reparse.awk new file mode 100644 index 0000000..433ecbb --- /dev/null +++ b/test/reparse.awk @@ -0,0 +1,7 @@ +{ + gsub(/x/, " ") + $0 = $0 + print $1 + print $0 + print $1, $2, $3 +} diff --git a/test/reparse.in b/test/reparse.in new file mode 100644 index 0000000..6f31cde --- /dev/null +++ b/test/reparse.in @@ -0,0 +1 @@ +1 axbxc 2 diff --git a/test/reparse.ok b/test/reparse.ok new file mode 100644 index 0000000..6bdfacf --- /dev/null +++ b/test/reparse.ok @@ -0,0 +1,3 @@ +1 +1 a b c 2 +1 a b diff --git a/test/resplit.awk b/test/resplit.awk new file mode 100644 index 0000000..f75fe39 --- /dev/null +++ b/test/resplit.awk @@ -0,0 +1 @@ +{ FS = ":"; $0 = $0; print $2 } diff --git a/test/resplit.in b/test/resplit.in new file mode 100644 index 0000000..5f06f10 --- /dev/null +++ b/test/resplit.in @@ -0,0 +1 @@ +a:b:c d:e:f diff --git a/test/resplit.ok b/test/resplit.ok new file mode 100644 index 0000000..6178079 --- /dev/null +++ b/test/resplit.ok @@ -0,0 +1 @@ +b diff --git a/test/rri1.awk b/test/rri1.awk new file mode 100644 index 0000000..889dbdc --- /dev/null +++ b/test/rri1.awk @@ -0,0 +1 @@ +/[d-f]/ diff --git a/test/rri1.in b/test/rri1.in new file mode 100644 index 0000000..28b6b40 --- /dev/null +++ b/test/rri1.in @@ -0,0 +1 @@ +no match: è diff --git a/test/rri1.ok b/test/rri1.ok new file mode 100644 index 0000000..e69de29 diff --git a/test/rs.awk b/test/rs.awk new file mode 100644 index 0000000..d3a3cf0 --- /dev/null +++ b/test/rs.awk @@ -0,0 +1,2 @@ +BEGIN { RS = "" } +{ print $1, $2 } diff --git a/test/rs.in b/test/rs.in new file mode 100644 index 0000000..edef835 --- /dev/null +++ b/test/rs.in @@ -0,0 +1,15 @@ + + +a +b + + +c d + + + +e + + + + diff --git a/test/rs.ok b/test/rs.ok new file mode 100644 index 0000000..9dd6bd3 --- /dev/null +++ b/test/rs.ok @@ -0,0 +1,3 @@ +a b +c d +e diff --git a/test/rsnul1nl.awk b/test/rsnul1nl.awk new file mode 100644 index 0000000..d8da7a6 --- /dev/null +++ b/test/rsnul1nl.awk @@ -0,0 +1,2 @@ +BEGIN { RS = "" } +{ print } diff --git a/test/rsnul1nl.in b/test/rsnul1nl.in new file mode 100644 index 0000000..76de96f --- /dev/null +++ b/test/rsnul1nl.in @@ -0,0 +1,3 @@ + +This is... +the first record. diff --git a/test/rsnul1nl.ok b/test/rsnul1nl.ok new file mode 100644 index 0000000..7ce0957 --- /dev/null +++ b/test/rsnul1nl.ok @@ -0,0 +1,2 @@ +This is... +the first record. diff --git a/test/rsnulbig.ok b/test/rsnulbig.ok new file mode 100644 index 0000000..10a5209 --- /dev/null +++ b/test/rsnulbig.ok @@ -0,0 +1 @@ +16386 diff --git a/test/rsnulbig2.ok b/test/rsnulbig2.ok new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/test/rsnulbig2.ok @@ -0,0 +1 @@ +2 diff --git a/test/rsstart1.awk b/test/rsstart1.awk new file mode 100644 index 0000000..53e5b42 --- /dev/null +++ b/test/rsstart1.awk @@ -0,0 +1,32 @@ +# From arnold@f7.net Wed Dec 15 11:32:46 2004 +# Date: Tue, 14 Dec 2004 14:48:58 +0100 +# From: Stepan Kasal +# Subject: gawk bug with RS="^..." +# To: bug-gawk@gnu.org +# Message-id: <20041214134858.GA15490@matsrv.math.cas.cz> +# +# Hello, +# I've noticed a problem with "^" in RS in gawk. In most cases, it seems +# to match only the beginning of the file. But in fact it matches the +# beginning of gawk's internal buffer. +# +# Observe the following example: +# +# $ gawk 'BEGIN{for(i=1;i<=100;i++) print "Axxxxxx"}' >file +# $ gawk 'BEGIN{RS="^A"} END{print NR}' file +# 2 +# $ gawk 'BEGIN{RS="^Ax*\n"} END{print NR}' file +# 100 +# $ head file | gawk 'BEGIN{RS="^Ax*\n"} END{print NR}' +# 10 +# $ +# +# I think this calls for some clarification/fix. But I don't have any +# fixed opinion how the solution should look like. +# +# Have a nice day, +# Stepan Kasal +# +# PS: See also the discussion of the issue in the comp.lang.awk newsgroup. +BEGIN { RS = "^A" } +END { print NR } diff --git a/test/rsstart1.in b/test/rsstart1.in new file mode 100644 index 0000000..aabdf02 --- /dev/null +++ b/test/rsstart1.in @@ -0,0 +1,10000 @@ +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx +Axxxxxx diff --git a/test/rsstart1.ok b/test/rsstart1.ok new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/test/rsstart1.ok @@ -0,0 +1 @@ +2 diff --git a/test/rsstart2.awk b/test/rsstart2.awk new file mode 100644 index 0000000..14c1415 --- /dev/null +++ b/test/rsstart2.awk @@ -0,0 +1,2 @@ +BEGIN { RS = "^Ax*\n" } +END { print NR } diff --git a/test/rsstart2.ok b/test/rsstart2.ok new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/test/rsstart2.ok @@ -0,0 +1 @@ +2 diff --git a/test/rsstart3.ok b/test/rsstart3.ok new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/test/rsstart3.ok @@ -0,0 +1 @@ +2 diff --git a/test/rstest1.awk b/test/rstest1.awk new file mode 100644 index 0000000..3eb8836 --- /dev/null +++ b/test/rstest1.awk @@ -0,0 +1,7 @@ +BEGIN { + RS = "" + FS = ":" + s = "a:b\nc:d" + print split(s,a) + print length(a[2]) +} diff --git a/test/rstest1.ok b/test/rstest1.ok new file mode 100644 index 0000000..a5c8806 --- /dev/null +++ b/test/rstest1.ok @@ -0,0 +1,2 @@ +3 +3 diff --git a/test/rstest2.awk b/test/rstest2.awk new file mode 100644 index 0000000..5ed4701 --- /dev/null +++ b/test/rstest2.awk @@ -0,0 +1,6 @@ +BEGIN { + RS = "" + FS = "\\" + $0 = "a\\b" + print $1 +} diff --git a/test/rstest2.ok b/test/rstest2.ok new file mode 100644 index 0000000..7898192 --- /dev/null +++ b/test/rstest2.ok @@ -0,0 +1 @@ +a diff --git a/test/rstest3.awk b/test/rstest3.awk new file mode 100644 index 0000000..3238ffa --- /dev/null +++ b/test/rstest3.awk @@ -0,0 +1,73 @@ +# From spcecdt@armory.com Tue Apr 15 17:35:01 2003 +# Return-Path: +# Received: from localhost (aahz [127.0.0.1]) +# by skeeve.com (8.12.5/8.12.5) with ESMTP id h3FEYA6o001541 +# for ; Tue, 15 Apr 2003 17:35:01 +0300 +# Received: from actcom.co.il [192.114.47.1] +# by localhost with POP3 (fetchmail-5.9.0) +# for arnold@localhost (single-drop); Tue, 15 Apr 2003 17:35:01 +0300 (IDT) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Tue Apr 15 17:38:46 2003) +# X-From_: spcecdt@armory.com Tue Apr 15 11:09:12 2003 +# Received: from smtp1.actcom.net.il by actcom.co.il with ESMTP +# (8.11.6/actcom-0.2) id h3F88uC19825 for ; +# Tue, 15 Apr 2003 11:09:04 +0300 (EET DST) +# (rfc931-sender: smtp.actcom.co.il [192.114.47.13]) +# Received: from f7.net (consort.superb.net [209.61.216.22]) +# by smtp1.actcom.net.il (8.12.8/8.12.8) with ESMTP id h3F8CgQ7019081 +# for ; Tue, 15 Apr 2003 11:12:47 +0300 +# Received: from fencepost.gnu.org (fencepost.gnu.org [199.232.76.164]) +# by f7.net (8.11.7/8.11.6) with ESMTP id h3F88oW23381 +# for ; Tue, 15 Apr 2003 04:08:50 -0400 +# Received: from monty-python.gnu.org ([199.232.76.173]) +# by fencepost.gnu.org with esmtp (Exim 4.10) +# id 195LUo-0001cv-00 +# for bug-gawk@gnu.org; Tue, 15 Apr 2003 04:08:50 -0400 +# Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) +# id 195LUh-0006n0-00 +# for bug-gawk@gnu.org; Tue, 15 Apr 2003 04:08:44 -0400 +# Received: from deepthought.armory.com ([192.122.209.42] helo=armory.com) +# by monty-python.gnu.org with smtp (Exim 4.10.13) +# id 195LUC-0006JM-00 +# for bug-gawk@gnu.org; Tue, 15 Apr 2003 04:08:13 -0400 +# Date: Tue, 15 Apr 2003 01:08:11 -0700 +# From: "John H. DuBois III" +# To: bug-gawk@gnu.org +# Subject: gawk 3.1.2 fatal bug +# Message-ID: <20030415080811.GA14963@armory.com> +# Mime-Version: 1.0 +# Content-Type: text/plain; charset=us-ascii +# Content-Disposition: inline +# User-Agent: Mutt/1.3.28i +# X-Www: http://www.armory.com./~spcecdt/ +# Sender: spcecdt@armory.com +# X-Spam-Status: No, hits=-7.9 required=5.0 +# tests=SIGNATURE_SHORT_DENSE,SPAM_PHRASE_01_02,USER_AGENT, +# USER_AGENT_MUTT +# version=2.41 +# X-Spam-Level: +# X-SpamBouncer: 1.4 (10/07/01) +# X-SBClass: OK +# Status: RO +# +# This program: +# +# BEGIN { RS = ""; "/bin/echo -n x" | getline } +# +# fails in exactly the same way under SCO OpenServer 5.0.6a using gawk 3.1.2 +# built with gcc 2.95.3 and linux using gawk 3.1.2 built with gcc 3.2.2: +# +# gawk: gawktest:1: fatal error: internal error +# Abort +# +# The same program does not fail with gawk 3.1.1. +# +# John +# -- +# John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/ +# +# +BEGIN { + RS = "" + "echo x | tr -d '\\12'" | getline +} diff --git a/test/rstest3.ok b/test/rstest3.ok new file mode 100644 index 0000000..e69de29 diff --git a/test/rstest4.awk b/test/rstest4.awk new file mode 100644 index 0000000..ddf0691 --- /dev/null +++ b/test/rstest4.awk @@ -0,0 +1,67 @@ +# From spcecdt@armory.com Mon May 5 14:37:09 2003 +# Return-Path: +# Received: from localhost (skeeve [127.0.0.1]) +# by skeeve.com (8.12.5/8.12.5) with ESMTP id h45B1GvT031993 +# for ; Mon, 5 May 2003 14:37:09 +0300 +# Received: from actcom.co.il [192.114.47.1] +# by localhost with POP3 (fetchmail-5.9.0) +# for arnold@localhost (single-drop); Mon, 05 May 2003 14:37:09 +0300 (IDT) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Mon May 5 14:35:11 2003) +# X-From_: spcecdt@armory.com Mon May 5 12:20:20 2003 +# Received: from smtp1.actcom.net.il by actcom.co.il with ESMTP +# (8.11.6/actcom-0.2) id h459KC529186 for ; +# Mon, 5 May 2003 12:20:15 +0300 (EET DST) +# (rfc931-sender: smtp.actcom.co.il [192.114.47.13]) +# Received: from f7.net (consort.superb.net [209.61.216.22]) +# by smtp1.actcom.net.il (8.12.8/8.12.8) with ESMTP id h459LMfl025854 +# for ; Mon, 5 May 2003 12:21:24 +0300 +# Received: from armory.com (deepthought.armory.com [192.122.209.42]) +# by f7.net (8.11.7/8.11.6) with SMTP id h459K9I26841 +# for ; Mon, 5 May 2003 05:20:09 -0400 +# Date: Mon, 5 May 2003 02:20:08 -0700 +# From: "John H. DuBois III" +# To: Aharon Robbins +# Subject: Re: gawk 3.1.2b now available +# Message-ID: <20030505092008.GA15970@armory.com> +# References: <200305041149.h44BnLcm005484@localhost.localdomain> +# Mime-Version: 1.0 +# Content-Type: text/plain; charset=us-ascii +# Content-Disposition: inline +# In-Reply-To: <200305041149.h44BnLcm005484@localhost.localdomain> +# User-Agent: Mutt/1.3.28i +# X-Www: http://www.armory.com./~spcecdt/ +# Sender: spcecdt@armory.com +# X-SpamBouncer: 1.4 (10/07/01) +# X-SBClass: OK +# Status: RO +# +# This is a curious one: +# +# gawk-3.1.2b 'BEGIN { +# while (("echo" | getline) == 1) +# ; +# RS = "" +# "echo \"a\n\nb\"" | getline y +# print x +# }' | hd +# +# The output is: +# +# 0000 00 13 0a ... +# 0003 +# +# (the uninitialized variable 'x' is somehow getting the value ) +# +# John +# -- +# John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/ +# +BEGIN { + while (("echo" | getline) == 1) + ; + RS = "" + "echo \"a\n\nb\"" | getline y + printf "y = <%s>\n", y # ADR + printf "x = <%s>\n", x # ADR +} diff --git a/test/rstest4.ok b/test/rstest4.ok new file mode 100644 index 0000000..430442f --- /dev/null +++ b/test/rstest4.ok @@ -0,0 +1,2 @@ +y = +x = <> diff --git a/test/rstest5.awk b/test/rstest5.awk new file mode 100644 index 0000000..09abb4a --- /dev/null +++ b/test/rstest5.awk @@ -0,0 +1,60 @@ +# From spcecdt@armory.com Tue May 6 13:42:34 2003 +# Return-Path: +# Received: from localhost (aahz [127.0.0.1]) +# by skeeve.com (8.12.5/8.12.5) with ESMTP id h46AgG53003519 +# for ; Tue, 6 May 2003 13:42:34 +0300 +# Received: from actcom.co.il [192.114.47.1] +# by localhost with POP3 (fetchmail-5.9.0) +# for arnold@localhost (single-drop); Tue, 06 May 2003 13:42:34 +0300 (IDT) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Tue May 6 13:48:46 2003) +# X-From_: spcecdt@armory.com Tue May 6 13:26:09 2003 +# Received: from smtp1.actcom.net.il by actcom.co.il with ESMTP +# (8.11.6/actcom-0.2) id h46AQ6520133 for ; +# Tue, 6 May 2003 13:26:07 +0300 (EET DST) +# (rfc931-sender: lmail.actcom.co.il [192.114.47.13]) +# Received: from f7.net (consort.superb.net [209.61.216.22]) +# by smtp1.actcom.net.il (8.12.8/8.12.8) with ESMTP id h46ARSfl010998 +# for ; Tue, 6 May 2003 13:27:31 +0300 +# Received: from armory.com (deepthought.armory.com [192.122.209.42]) +# by f7.net (8.11.7/8.11.6) with SMTP id h46AQ1I18183 +# for ; Tue, 6 May 2003 06:26:01 -0400 +# Date: Tue, 6 May 2003 03:25:59 -0700 +# From: "John H. DuBois III" +# To: Aharon Robbins +# Subject: Re: gawk 3.1.2b now available +# Message-ID: <20030506102559.GA16105@armory.com> +# References: <200305051157.h45Bv4XO003106@localhost.localdomain> +# Mime-Version: 1.0 +# Content-Type: text/plain; charset=us-ascii +# Content-Disposition: inline +# In-Reply-To: <200305051157.h45Bv4XO003106@localhost.localdomain> +# User-Agent: Mutt/1.3.28i +# X-Www: http://www.armory.com./~spcecdt/ +# Sender: spcecdt@armory.com +# X-SpamBouncer: 1.4 (10/07/01) +# X-SBClass: OK +# Status: RO +# +# The patch fixed the previous case, but here's another one - this prints +# : +# +# BEGIN { +# RS = "" +# "echo 'foo\n\nbaz'" | getline +# "echo 'foo\n\nbaz'" | getline +# "echo 'bar\n\nbaz'" | getline +# print x +# } +# +# John +# -- +# John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/ +# +BEGIN { + RS = "" + "echo 'foo\n\nbaz'" | getline ; print + "echo 'foo\n\nbaz'" | getline ; print + "echo 'bar\n\nbaz'" | getline ; print + printf "x = <%s>\n", x +} diff --git a/test/rstest5.ok b/test/rstest5.ok new file mode 100644 index 0000000..bf45151 --- /dev/null +++ b/test/rstest5.ok @@ -0,0 +1,4 @@ +foo +baz +bar +x = <> diff --git a/test/rstest6.awk b/test/rstest6.awk new file mode 100644 index 0000000..3481c0a --- /dev/null +++ b/test/rstest6.awk @@ -0,0 +1,6 @@ +# Wed Jul 14 16:02:45 IDT 2004 +# Test case from John Haque mary1john8@earthlink.net + +BEGIN { RS = "XYZ" } + +{ print } diff --git a/test/rstest6.in b/test/rstest6.in new file mode 100644 index 0000000..a6bddc4 --- /dev/null +++ b/test/rstest6.in @@ -0,0 +1 @@ +ABCD \ No newline at end of file diff --git a/test/rstest6.ok b/test/rstest6.ok new file mode 100644 index 0000000..9ed4614 --- /dev/null +++ b/test/rstest6.ok @@ -0,0 +1 @@ +ABCD diff --git a/test/rswhite.awk b/test/rswhite.awk new file mode 100644 index 0000000..0048765 --- /dev/null +++ b/test/rswhite.awk @@ -0,0 +1,2 @@ +BEGIN { RS = "" } +{ printf("<%s>\n", $0) } diff --git a/test/rswhite.in b/test/rswhite.in new file mode 100644 index 0000000..39f7756 --- /dev/null +++ b/test/rswhite.in @@ -0,0 +1,2 @@ + a b +c d diff --git a/test/rswhite.ok b/test/rswhite.ok new file mode 100644 index 0000000..a029e47 --- /dev/null +++ b/test/rswhite.ok @@ -0,0 +1,2 @@ +< a b +c d> diff --git a/test/rtlen.ok b/test/rtlen.ok new file mode 100644 index 0000000..b8a484d --- /dev/null +++ b/test/rtlen.ok @@ -0,0 +1,3 @@ +3 +5 +2 diff --git a/test/rtlen.sh b/test/rtlen.sh new file mode 100755 index 0000000..4a74045 --- /dev/null +++ b/test/rtlen.sh @@ -0,0 +1,5 @@ +#! /bin/sh + +AWK=${AWK:-../gawk} + +$AWK 'BEGIN {printf "0\n\n\n1\n\n\n\n\n2\n\n"; exit}' | $AWK 'BEGIN {RS=""}; {print length(RT)}' diff --git a/test/rtlen01.ok b/test/rtlen01.ok new file mode 100644 index 0000000..4539bbf --- /dev/null +++ b/test/rtlen01.ok @@ -0,0 +1,3 @@ +0 +1 +2 diff --git a/test/rtlen01.sh b/test/rtlen01.sh new file mode 100755 index 0000000..72156d9 --- /dev/null +++ b/test/rtlen01.sh @@ -0,0 +1,8 @@ +#! /bin/sh + +AWK=${AWK:-../gawk} + +$AWK 'BEGIN {printf "0"; exit}' | $AWK 'BEGIN {RS=""}; {print length(RT)}' +$AWK 'BEGIN {printf "0\n"; exit}' | $AWK 'BEGIN {RS=""}; {print length(RT)}' +$AWK 'BEGIN {printf "0\n\n"; exit}' | $AWK 'BEGIN {RS=""}; {print length(RT)}' + diff --git a/test/scalar.awk b/test/scalar.awk new file mode 100644 index 0000000..9027389 --- /dev/null +++ b/test/scalar.awk @@ -0,0 +1,4 @@ +BEGIN{ + sub(/x/,"",a) + a[1] +} diff --git a/test/scalar.ok b/test/scalar.ok new file mode 100644 index 0000000..99e1fc8 --- /dev/null +++ b/test/scalar.ok @@ -0,0 +1,2 @@ +gawk: scalar.awk:3: fatal: attempt to use scalar `a' as an array +EXIT CODE: 2 diff --git a/test/sclforin.awk b/test/sclforin.awk new file mode 100644 index 0000000..335e854 --- /dev/null +++ b/test/sclforin.awk @@ -0,0 +1 @@ +BEGIN { j = 4; for (i in j) print j[i] } diff --git a/test/sclforin.ok b/test/sclforin.ok new file mode 100644 index 0000000..cbb52be --- /dev/null +++ b/test/sclforin.ok @@ -0,0 +1,2 @@ +gawk: sclforin.awk:1: fatal: attempt to use scalar `j' as an array +EXIT CODE: 2 diff --git a/test/sclifin.awk b/test/sclifin.awk new file mode 100644 index 0000000..64f5d0d --- /dev/null +++ b/test/sclifin.awk @@ -0,0 +1,7 @@ +BEGIN { + j = 4 + if ("foo" in j) + print "ouch" + else + print "ok" +} diff --git a/test/sclifin.ok b/test/sclifin.ok new file mode 100644 index 0000000..ab03eeb --- /dev/null +++ b/test/sclifin.ok @@ -0,0 +1,2 @@ +gawk: sclifin.awk:3: fatal: attempt to use scalar `j' as an array +EXIT CODE: 2 diff --git a/test/shadow.awk b/test/shadow.awk new file mode 100644 index 0000000..9a58720 --- /dev/null +++ b/test/shadow.awk @@ -0,0 +1,21 @@ +function foo() +{ + print "foo" +} + +function bar(A, Z, q) +{ + print "bar" +} + +function baz(C, D) +{ + print "baz" +} + +BEGIN { + A = C = D = Z = y = 1 + foo() + bar() + baz() +} diff --git a/test/shadow.ok b/test/shadow.ok new file mode 100644 index 0000000..552c63e --- /dev/null +++ b/test/shadow.ok @@ -0,0 +1,7 @@ +gawk: shadow.awk:6: warning: function `bar': parameter `A' shadows global variable +gawk: shadow.awk:6: warning: function `bar': parameter `Z' shadows global variable +gawk: shadow.awk:11: warning: function `baz': parameter `C' shadows global variable +gawk: shadow.awk:11: warning: function `baz': parameter `D' shadows global variable +foo +bar +baz diff --git a/test/sort1.awk b/test/sort1.awk new file mode 100644 index 0000000..ef28e9c --- /dev/null +++ b/test/sort1.awk @@ -0,0 +1,127 @@ +BEGIN{ + for (IGNORECASE=0; IGNORECASE <= 1; IGNORECASE++) { + SORT_STR = -1 + + makea(a) + asort1(a, "") + printf("---end asort(a), IGNORECASE = %d---\n", IGNORECASE) + + makea(a) + asort2(a, "") + printf("---end asort(a, b), IGNORECASE = %d---\n", IGNORECASE) + + makea(a) + SORT_STR = "" + asort1(a) + printf("---end asort(a, a), IGNORECASE = %d---\n", IGNORECASE) + + makea(a) + SORT_STR = "@ind_num_asc" + asort2(a, "") + printf("---end asort(a, b, \"%s\"), IGNORECASE = %d---\n", + SORT_STR, IGNORECASE) + + makea(a) + SORT_STR = "@ind_str_desc" + asort1(a, "") + printf("---end asort(a, a, \"%s\"), IGNORECASE = %d---\n", + SORT_STR, IGNORECASE) + + makea(a) + SORT_STR = "@val_str_asc" + proc_sort(a, "") + printf("---end PROCINFO[\"sorted_in\"] = \"%s\", IGNORECASE = %d---\n", + SORT_STR, IGNORECASE) + + makea(a) + SORT_STR = "@val_num_asc" + proc_sort(a, "") + printf("---end PROCINFO[\"sorted_in\"] = \"%s\", IGNORECASE = %d---\n", + SORT_STR, IGNORECASE) + + makea(a) + SORT_STR = "@val_str_desc" + proc_sort(a, "") + printf("---end PROCINFO[\"sorted_in\"] = \"%s\", IGNORECASE = %d---\n", + SORT_STR, IGNORECASE) + + makea(a) + SORT_STR = "@val_num_desc" + proc_sort(a, "") + printf("---end PROCINFO[\"sorted_in\"] = \"%s\", IGNORECASE = %d---\n", + SORT_STR, IGNORECASE) + + makea(a) + SORT_STR = "@val_type_asc" + proc_sort(a, "") + printf("---end PROCINFO[\"sorted_in\"] = \"%s\", IGNORECASE = %d---\n", + SORT_STR, IGNORECASE) + + makea(a) + SORT_STR = "@val_type_desc" + proc_sort(a, "") + printf("---end PROCINFO[\"sorted_in\"] = \"%s\", IGNORECASE = %d---\n", + SORT_STR, IGNORECASE) + } +} + +function makea(aa) +{ + delete aa + aa[1] = "barz"; + aa[2] = "blattt"; + aa[3] = "Zebra"; + aa[4] = 1234; + aa[5] = 234; + aa[6][1] = 4321; +# aa[6][2] = 432; + aa[6][3] = "tttalb"; + aa[6][2] = "arbeZ"; + aa[6][4] = "zrab"; +} + + +# source array != destination array +function asort2(c, s, d, k, m) +{ + if (SORT_STR < 0) + m = asort(c, d); + else + m = asort(c, d, SORT_STR); + for(k=1; k <= m; k++) { + if (isarray(d[k])) + asort2(d[k], s"["k"]") + else + printf("%10s:%10s%10s\n", s"["k"]", c[k], d[k]) + } +} + +# source array == destination array +function asort1(c, s, k, m) +{ + if (SORT_STR < 0) + m = asort(c) + else if (SORT_STR != "") + m = asort(c, c, SORT_STR) + else + m = asort(c, c); + + for(k=1; k <= m; k++) { + if (isarray(c[k])) + asort1(c[k], s"["k"]") + else + printf("%10s:%10s\n", s"["k"]", c[k]) + } +} + + +function proc_sort(c, s, k) +{ + PROCINFO["sorted_in"] = SORT_STR + for(k in c) { + if (isarray(c[k])) + proc_sort(c[k], s"["k"]") + else + printf("%10s:%10s\n", s"["k"]", c[k]) + } +} diff --git a/test/sort1.ok b/test/sort1.ok new file mode 100644 index 0000000..00ed661 --- /dev/null +++ b/test/sort1.ok @@ -0,0 +1,220 @@ + [1]: 234 + [2]: 1234 + [3]: Zebra + [4]: barz + [5]: blattt + [6][1]: 4321 + [6][2]: arbeZ + [6][3]: tttalb + [6][4]: zrab +---end asort(a), IGNORECASE = 0--- + [1]: barz 234 + [2]: blattt 1234 + [3]: Zebra Zebra + [4]: 1234 barz + [5]: 234 blattt + [6][1]: 4321 4321 + [6][2]: arbeZ arbeZ + [6][3]: tttalb tttalb + [6][4]: zrab zrab +---end asort(a, b), IGNORECASE = 0--- + [1]: 234 + [2]: 1234 + [3]: Zebra + [4]: barz + [5]: blattt + [6][1]: 4321 + [6][2]: arbeZ + [6][3]: tttalb + [6][4]: zrab +---end asort(a, a), IGNORECASE = 0--- + [1]: barz barz + [2]: blattt blattt + [3]: Zebra Zebra + [4]: 1234 1234 + [5]: 234 234 + [6][1]: 4321 4321 + [6][2]: arbeZ arbeZ + [6][3]: tttalb tttalb + [6][4]: zrab zrab +---end asort(a, b, "@ind_num_asc"), IGNORECASE = 0--- + [1][1]: zrab + [1][2]: tttalb + [1][3]: arbeZ + [1][4]: 4321 + [2]: 234 + [3]: 1234 + [4]: Zebra + [5]: blattt + [6]: barz +---end asort(a, a, "@ind_str_desc"), IGNORECASE = 0--- + [4]: 1234 + [5]: 234 + [3]: Zebra + [1]: barz + [2]: blattt + [6][1]: 4321 + [6][2]: arbeZ + [6][3]: tttalb + [6][4]: zrab +---end PROCINFO["sorted_in"] = "@val_str_asc", IGNORECASE = 0--- + [3]: Zebra + [1]: barz + [2]: blattt + [5]: 234 + [4]: 1234 + [6][2]: arbeZ + [6][3]: tttalb + [6][4]: zrab + [6][1]: 4321 +---end PROCINFO["sorted_in"] = "@val_num_asc", IGNORECASE = 0--- + [6][4]: zrab + [6][3]: tttalb + [6][2]: arbeZ + [6][1]: 4321 + [2]: blattt + [1]: barz + [3]: Zebra + [5]: 234 + [4]: 1234 +---end PROCINFO["sorted_in"] = "@val_str_desc", IGNORECASE = 0--- + [6][1]: 4321 + [6][4]: zrab + [6][3]: tttalb + [6][2]: arbeZ + [4]: 1234 + [5]: 234 + [2]: blattt + [1]: barz + [3]: Zebra +---end PROCINFO["sorted_in"] = "@val_num_desc", IGNORECASE = 0--- + [5]: 234 + [4]: 1234 + [3]: Zebra + [1]: barz + [2]: blattt + [6][1]: 4321 + [6][2]: arbeZ + [6][3]: tttalb + [6][4]: zrab +---end PROCINFO["sorted_in"] = "@val_type_asc", IGNORECASE = 0--- + [6][4]: zrab + [6][3]: tttalb + [6][2]: arbeZ + [6][1]: 4321 + [2]: blattt + [1]: barz + [3]: Zebra + [4]: 1234 + [5]: 234 +---end PROCINFO["sorted_in"] = "@val_type_desc", IGNORECASE = 0--- + [1]: 234 + [2]: 1234 + [3]: barz + [4]: blattt + [5]: Zebra + [6][1]: 4321 + [6][2]: arbeZ + [6][3]: tttalb + [6][4]: zrab +---end asort(a), IGNORECASE = 1--- + [1]: barz 234 + [2]: blattt 1234 + [3]: Zebra barz + [4]: 1234 blattt + [5]: 234 Zebra + [6][1]: 4321 4321 + [6][2]: arbeZ arbeZ + [6][3]: tttalb tttalb + [6][4]: zrab zrab +---end asort(a, b), IGNORECASE = 1--- + [1]: 234 + [2]: 1234 + [3]: barz + [4]: blattt + [5]: Zebra + [6][1]: 4321 + [6][2]: arbeZ + [6][3]: tttalb + [6][4]: zrab +---end asort(a, a), IGNORECASE = 1--- + [1]: barz barz + [2]: blattt blattt + [3]: Zebra Zebra + [4]: 1234 1234 + [5]: 234 234 + [6][1]: 4321 4321 + [6][2]: arbeZ arbeZ + [6][3]: tttalb tttalb + [6][4]: zrab zrab +---end asort(a, b, "@ind_num_asc"), IGNORECASE = 1--- + [1][1]: zrab + [1][2]: tttalb + [1][3]: arbeZ + [1][4]: 4321 + [2]: 234 + [3]: 1234 + [4]: Zebra + [5]: blattt + [6]: barz +---end asort(a, a, "@ind_str_desc"), IGNORECASE = 1--- + [4]: 1234 + [5]: 234 + [1]: barz + [2]: blattt + [3]: Zebra + [6][1]: 4321 + [6][2]: arbeZ + [6][3]: tttalb + [6][4]: zrab +---end PROCINFO["sorted_in"] = "@val_str_asc", IGNORECASE = 1--- + [1]: barz + [2]: blattt + [3]: Zebra + [5]: 234 + [4]: 1234 + [6][2]: arbeZ + [6][3]: tttalb + [6][4]: zrab + [6][1]: 4321 +---end PROCINFO["sorted_in"] = "@val_num_asc", IGNORECASE = 1--- + [6][4]: zrab + [6][3]: tttalb + [6][2]: arbeZ + [6][1]: 4321 + [3]: Zebra + [2]: blattt + [1]: barz + [5]: 234 + [4]: 1234 +---end PROCINFO["sorted_in"] = "@val_str_desc", IGNORECASE = 1--- + [6][1]: 4321 + [6][4]: zrab + [6][3]: tttalb + [6][2]: arbeZ + [4]: 1234 + [5]: 234 + [3]: Zebra + [2]: blattt + [1]: barz +---end PROCINFO["sorted_in"] = "@val_num_desc", IGNORECASE = 1--- + [5]: 234 + [4]: 1234 + [1]: barz + [2]: blattt + [3]: Zebra + [6][1]: 4321 + [6][2]: arbeZ + [6][3]: tttalb + [6][4]: zrab +---end PROCINFO["sorted_in"] = "@val_type_asc", IGNORECASE = 1--- + [6][4]: zrab + [6][3]: tttalb + [6][2]: arbeZ + [6][1]: 4321 + [3]: Zebra + [2]: blattt + [1]: barz + [4]: 1234 + [5]: 234 +---end PROCINFO["sorted_in"] = "@val_type_desc", IGNORECASE = 1--- diff --git a/test/sortempty.awk b/test/sortempty.awk new file mode 100644 index 0000000..6848d95 --- /dev/null +++ b/test/sortempty.awk @@ -0,0 +1 @@ +BEGIN { print asort(a) } diff --git a/test/sortempty.ok b/test/sortempty.ok new file mode 100644 index 0000000..573541a --- /dev/null +++ b/test/sortempty.ok @@ -0,0 +1 @@ +0 diff --git a/test/sortfor.awk b/test/sortfor.awk new file mode 100644 index 0000000..922b5e8 --- /dev/null +++ b/test/sortfor.awk @@ -0,0 +1,9 @@ +{ a[$0]++ } +END { + PROCINFO["sorted_in"] = "@ind_str_asc" + for (i in a) + print i + PROCINFO["sorted_in"] = "@ind_str_desc" + for (i in a) + print i +} diff --git a/test/sortfor.in b/test/sortfor.in new file mode 100644 index 0000000..f0e4d51 --- /dev/null +++ b/test/sortfor.in @@ -0,0 +1,289 @@ +fsspcoln +ofmtfidl +strtonum +strftime +uninitialized +manyfiles +delarpm2 +wideidx +parseme +paramres +fldchgnf +subslash +intprec +asorti +mbprintf1 +mbprintf2 +synerr1 +mbprintf3 +synerr2 +arynasty +swaplns +asort +patsplit +delarprm +gensub +litoct +opasnidx +clsflnam +fnarydel +uparrfs +argarray +numindex +devfd1 +devfd2 +delfunc +localenl +noeffect +fstabplus +hsprint +fsfwfs +tradanch +fldchg +printfbad1 +unterm +printfbad2 +fmttest +minusstr +posix +arrymem1 +concat1 +reint2 +gnuops2 +concat2 +fsrs +gnuops3 +resplit +concat3 +fnparydl +concat4 +uninit2 +rs +fnarray +uninit3 +paramdup +mmap8k +fieldwdth +devfd +uninit4 +poundbang +uninit5 +nondec2 +switch2 +numsubstr +profile1 +regx8bit +profile2 +getline +membug1 +lint +zeroflag +fnasgnm +widesub2 +widesub3 +reindops +exitval1 +binmode1 +widesub4 +exitval2 +intest +back89 +substr +arynocls +opasnslf +ofmtbig +mbfw1 +zeroe0 +arrayparm +nasty +aasort +sclifin +nofmtch +leadnl +getlnhd +nofile +fflush +printf0 +reparse +printf1 +prtoeval +funsmnam +tweakfld +sclforin +wjposer1 +clobber +iobug1 +fnamedat +leaddig +double1 +double2 +strcat1 +prdupval +messages +space +nlfldsep +posix2008sub +wideidx2 +nfldstr +zero2 +rebt8b1 +onlynl +rebt8b2 +fwtest +anchgsub +beginfile1 +fnmisc +getlndir +rand +fwtest2 +nested +childin +mtchi18n +gsubtest +manglprm +intformat +longwrds +splitarr +arysubnm +rsstart1 +procinfs +argtest +regeq +rsstart2 +rsstart3 +sort1 +fmtspcl +reint +rsnulbig +closebad +strftlng +parse1 +ofmt +ignrcas2 +splitarg4 +range1 +noloop1 +longsub +igncdym +widesub +noloop2 +aadelete1 +subi18n +gsubtst2 +aadelete2 +gsubtst3 +gsubtst4 +convfmt +gsubtst5 +nors +arrayref +gsubtst6 +parsefld +indirectcall +asgext +shadow +octsub +nfneg +backgsub +math +getlnbuf +addcomma +mbstr1 +subsepnm +nulrsend +rsnulbig2 +sprintfc +redfilnm +igncfs +splitwht +fcall_exit +fordel +subamp +paramtyp +nlinstr +eofsplit +fsbs +dumpvars +nlstrina +datanonl +fcall_exit2 +icasers +badargs +nfset +gsubasgn +lc_num1 +aasorti +pipeio1 +pipeio2 +sortempty +inputred +backw +rswhite +awkpath +forsimp +match1 +match2 +splitvar +match3 +aryprm1 +aryprm2 +aryprm3 +getline2 +aarray1 +aryprm4 +fnarray2 +getline3 +ignrcase +aryprm5 +pcntplus +aryprm6 +aryprm7 +ofmts +aryprm8 +dynlj +prec +prmreuse +gensub2 +splitdef +prt1eval +lintold +scalar +fnaryscl +nondec +compare2 +icasefs +rstest1 +getnr2tb +rstest2 +arryref2 +rstest3 +arryref3 +gnureops +rstest4 +arryref4 +funstack +splitargv +rstest5 +arryref5 +rstest6 +clos1way +pid +rsnul1nl +nasty2 +noparms +defref +rebuf +strtod +prmarscl +arrayprm2 +arrayprm3 +getnr2tm +forref +funsemnl +hex +fpat1 +strnum1 +negexp +compare +funlen +nonl diff --git a/test/sortfor.ok b/test/sortfor.ok new file mode 100644 index 0000000..8fc84d0 --- /dev/null +++ b/test/sortfor.ok @@ -0,0 +1,578 @@ +aadelete1 +aadelete2 +aarray1 +aasort +aasorti +addcomma +anchgsub +argarray +argtest +arrayparm +arrayprm2 +arrayprm3 +arrayref +arrymem1 +arryref2 +arryref3 +arryref4 +arryref5 +arynasty +arynocls +aryprm1 +aryprm2 +aryprm3 +aryprm4 +aryprm5 +aryprm6 +aryprm7 +aryprm8 +arysubnm +asgext +asort +asorti +awkpath +back89 +backgsub +backw +badargs +beginfile1 +binmode1 +childin +clobber +clos1way +closebad +clsflnam +compare +compare2 +concat1 +concat2 +concat3 +concat4 +convfmt +datanonl +defref +delarpm2 +delarprm +delfunc +devfd +devfd1 +devfd2 +double1 +double2 +dumpvars +dynlj +eofsplit +exitval1 +exitval2 +fcall_exit +fcall_exit2 +fflush +fieldwdth +fldchg +fldchgnf +fmtspcl +fmttest +fnamedat +fnarray +fnarray2 +fnarydel +fnaryscl +fnasgnm +fnmisc +fnparydl +fordel +forref +forsimp +fpat1 +fsbs +fsfwfs +fsrs +fsspcoln +fstabplus +funlen +funsemnl +funsmnam +funstack +fwtest +fwtest2 +gensub +gensub2 +getline +getline2 +getline3 +getlnbuf +getlndir +getlnhd +getnr2tb +getnr2tm +gnuops2 +gnuops3 +gnureops +gsubasgn +gsubtest +gsubtst2 +gsubtst3 +gsubtst4 +gsubtst5 +gsubtst6 +hex +hsprint +icasefs +icasers +igncdym +igncfs +ignrcas2 +ignrcase +indirectcall +inputred +intest +intformat +intprec +iobug1 +lc_num1 +leaddig +leadnl +lint +lintold +litoct +localenl +longsub +longwrds +manglprm +manyfiles +match1 +match2 +match3 +math +mbfw1 +mbprintf1 +mbprintf2 +mbprintf3 +mbstr1 +membug1 +messages +minusstr +mmap8k +mtchi18n +nasty +nasty2 +negexp +nested +nfldstr +nfneg +nfset +nlfldsep +nlinstr +nlstrina +noeffect +nofile +nofmtch +noloop1 +noloop2 +nondec +nondec2 +nonl +noparms +nors +nulrsend +numindex +numsubstr +octsub +ofmt +ofmtbig +ofmtfidl +ofmts +onlynl +opasnidx +opasnslf +paramdup +paramres +paramtyp +parse1 +parsefld +parseme +patsplit +pcntplus +pid +pipeio1 +pipeio2 +posix +posix2008sub +poundbang +prdupval +prec +printf0 +printf1 +printfbad1 +printfbad2 +prmarscl +prmreuse +procinfs +profile1 +profile2 +prt1eval +prtoeval +rand +range1 +rebt8b1 +rebt8b2 +rebuf +redfilnm +regeq +regx8bit +reindops +reint +reint2 +reparse +resplit +rs +rsnul1nl +rsnulbig +rsnulbig2 +rsstart1 +rsstart2 +rsstart3 +rstest1 +rstest2 +rstest3 +rstest4 +rstest5 +rstest6 +rswhite +scalar +sclforin +sclifin +shadow +sort1 +sortempty +space +splitarg4 +splitargv +splitarr +splitdef +splitvar +splitwht +sprintfc +strcat1 +strftime +strftlng +strnum1 +strtod +strtonum +subamp +subi18n +subsepnm +subslash +substr +swaplns +switch2 +synerr1 +synerr2 +tradanch +tweakfld +uninit2 +uninit3 +uninit4 +uninit5 +uninitialized +unterm +uparrfs +wideidx +wideidx2 +widesub +widesub2 +widesub3 +widesub4 +wjposer1 +zero2 +zeroe0 +zeroflag +zeroflag +zeroe0 +zero2 +wjposer1 +widesub4 +widesub3 +widesub2 +widesub +wideidx2 +wideidx +uparrfs +unterm +uninitialized +uninit5 +uninit4 +uninit3 +uninit2 +tweakfld +tradanch +synerr2 +synerr1 +switch2 +swaplns +substr +subslash +subsepnm +subi18n +subamp +strtonum +strtod +strnum1 +strftlng +strftime +strcat1 +sprintfc +splitwht +splitvar +splitdef +splitarr +splitargv +splitarg4 +space +sortempty +sort1 +shadow +sclifin +sclforin +scalar +rswhite +rstest6 +rstest5 +rstest4 +rstest3 +rstest2 +rstest1 +rsstart3 +rsstart2 +rsstart1 +rsnulbig2 +rsnulbig +rsnul1nl +rs +resplit +reparse +reint2 +reint +reindops +regx8bit +regeq +redfilnm +rebuf +rebt8b2 +rebt8b1 +range1 +rand +prtoeval +prt1eval +profile2 +profile1 +procinfs +prmreuse +prmarscl +printfbad2 +printfbad1 +printf1 +printf0 +prec +prdupval +poundbang +posix2008sub +posix +pipeio2 +pipeio1 +pid +pcntplus +patsplit +parseme +parsefld +parse1 +paramtyp +paramres +paramdup +opasnslf +opasnidx +onlynl +ofmts +ofmtfidl +ofmtbig +ofmt +octsub +numsubstr +numindex +nulrsend +nors +noparms +nonl +nondec2 +nondec +noloop2 +noloop1 +nofmtch +nofile +noeffect +nlstrina +nlinstr +nlfldsep +nfset +nfneg +nfldstr +nested +negexp +nasty2 +nasty +mtchi18n +mmap8k +minusstr +messages +membug1 +mbstr1 +mbprintf3 +mbprintf2 +mbprintf1 +mbfw1 +math +match3 +match2 +match1 +manyfiles +manglprm +longwrds +longsub +localenl +litoct +lintold +lint +leadnl +leaddig +lc_num1 +iobug1 +intprec +intformat +intest +inputred +indirectcall +ignrcase +ignrcas2 +igncfs +igncdym +icasers +icasefs +hsprint +hex +gsubtst6 +gsubtst5 +gsubtst4 +gsubtst3 +gsubtst2 +gsubtest +gsubasgn +gnureops +gnuops3 +gnuops2 +getnr2tm +getnr2tb +getlnhd +getlndir +getlnbuf +getline3 +getline2 +getline +gensub2 +gensub +fwtest2 +fwtest +funstack +funsmnam +funsemnl +funlen +fstabplus +fsspcoln +fsrs +fsfwfs +fsbs +fpat1 +forsimp +forref +fordel +fnparydl +fnmisc +fnasgnm +fnaryscl +fnarydel +fnarray2 +fnarray +fnamedat +fmttest +fmtspcl +fldchgnf +fldchg +fieldwdth +fflush +fcall_exit2 +fcall_exit +exitval2 +exitval1 +eofsplit +dynlj +dumpvars +double2 +double1 +devfd2 +devfd1 +devfd +delfunc +delarprm +delarpm2 +defref +datanonl +convfmt +concat4 +concat3 +concat2 +concat1 +compare2 +compare +clsflnam +closebad +clos1way +clobber +childin +binmode1 +beginfile1 +badargs +backw +backgsub +back89 +awkpath +asorti +asort +asgext +arysubnm +aryprm8 +aryprm7 +aryprm6 +aryprm5 +aryprm4 +aryprm3 +aryprm2 +aryprm1 +arynocls +arynasty +arryref5 +arryref4 +arryref3 +arryref2 +arrymem1 +arrayref +arrayprm3 +arrayprm2 +arrayparm +argtest +argarray +anchgsub +addcomma +aasorti +aasort +aarray1 +aadelete2 +aadelete1 diff --git a/test/sortu.awk b/test/sortu.awk new file mode 100644 index 0000000..508dc07 --- /dev/null +++ b/test/sortu.awk @@ -0,0 +1,118 @@ +# numeric before string, ascending by index +function comp_num_str(s1, v1, s2, v2, n1, n2) { + n1 = s1 + 0 + n2 = s2 + 0 + if (n1 == s1) + return (n2 == s2) ? (n1 - n2) : -1 + else if (n2 == s2) + return 1 + return (s1 < s2) ? -1 : (s1 != s2) +} + +# ascending index number +function comp_idx_num(s1, v1, s2, v2) +{ + return (s1 - s2) +} + +# ascending value number +function comp_val_num(s1, v1, s2, v2, num) +{ + num = "^[-+]?([0-9]+[.]?[0-9]*|[.][0-9]+)([eE][-+]?[0-9]+)?$" + # force stable sort, compare as strings if not numeric + if ((v1 - v2) == 0 && (v1 !~ num || v2 !~ num)) + return comp_val_str(s1, v1, s2, v2) + return (v1 - v2) +} + +# ascending value string +function comp_val_str(s1, v1, s2, v2) +{ + v1 = v1 "" + v2 = v2 "" + return (v1 < v2) ? -1 : (v1 != v2) +} + +# deterministic, by value (and index), descending numeric +function comp_val_idx(s1, v1, s2, v2) +{ + return (v1 != v2) ? (v2 - v1) : (s2 - s1) +} + +BEGIN { + a[1] = 10; a[100] = 1; a[2] = 200 + a["cat"] = "tac"; a["rat"] = "tar";a["bat"] = "tab" + + print "--- number before string, ascending by index ---" + PROCINFO["sorted_in"] = "comp_num_str" + for (i in a) + printf("%-10s%-s\n", i, a[i]) + + delete a + a[11] = 10; a[100] = 5; a[2] = 200 + a[4] = 1; a[20] = 10; a[14] = 10 + print "--- deterministic, by value (index), descending numeric ---" + PROCINFO["sorted_in"] = "comp_val_idx" + for (i in a) + printf("%-10s%-s\n", i, a[i]) + + for (IGNORECASE=0; IGNORECASE <= 1; IGNORECASE++) { + makea(a) + SORT_STR = "comp_val_num" + printf("--- asort(a, b, \"%s\"), IGNORECASE = %d---\n", SORT_STR, IGNORECASE) + asort2(a, "") + + makea(a) + SORT_STR = "comp_val_str" + printf("--- asort(a, b, \"%s\"), IGNORECASE = %d---\n", SORT_STR, IGNORECASE) + asort2(a, "") + + makea(a) + SORT_STR = "comp_val_str" + printf("--- asort(a, a, \"%s\"), IGNORECASE = %d---\n", SORT_STR, IGNORECASE) + asort1(a, "") + } +} + +function makea(aa) +{ + delete aa + aa[1] = "barz"; + aa[2] = "blattt"; + aa[3] = "Zebra"; + aa[4] = 1234; + aa[5] = 234; +} + +# source array != destination array +function asort2(c, s, d, k, m) +{ + if (SORT_STR < 0) + m = asort(c, d); + else + m = asort(c, d, SORT_STR); + for (k=1; k <= m; k++) { + if (isarray(d[k])) + asort2(d[k], s"["k"]") + else + printf("%-10s:%-10s%-10s\n", s"["k"]", c[k], d[k]) + } +} + +# source array == destination array +function asort1(c, s, k, m) +{ + if (SORT_STR < 0) + m = asort(c) + else if (SORT_STR != "") + m = asort(c, c, SORT_STR) + else + m = asort(c, c); + + for (k=1; k <= m; k++) { + if (isarray(c[k])) + asort1(c[k], s"["k"]") + else + printf("%-10s:%-10s\n", s"["k"]", c[k]) + } +} diff --git a/test/sortu.ok b/test/sortu.ok new file mode 100644 index 0000000..06dcd94 --- /dev/null +++ b/test/sortu.ok @@ -0,0 +1,50 @@ +--- number before string, ascending by index --- +1 10 +2 200 +100 1 +bat tab +cat tac +rat tar +--- deterministic, by value (index), descending numeric --- +2 200 +20 10 +14 10 +11 10 +100 5 +4 1 +--- asort(a, b, "comp_val_num"), IGNORECASE = 0--- +[1] :barz Zebra +[2] :blattt barz +[3] :Zebra blattt +[4] :1234 234 +[5] :234 1234 +--- asort(a, b, "comp_val_str"), IGNORECASE = 0--- +[1] :barz 1234 +[2] :blattt 234 +[3] :Zebra Zebra +[4] :1234 barz +[5] :234 blattt +--- asort(a, a, "comp_val_str"), IGNORECASE = 0--- +[1] :1234 +[2] :234 +[3] :Zebra +[4] :barz +[5] :blattt +--- asort(a, b, "comp_val_num"), IGNORECASE = 1--- +[1] :barz barz +[2] :blattt blattt +[3] :Zebra Zebra +[4] :1234 234 +[5] :234 1234 +--- asort(a, b, "comp_val_str"), IGNORECASE = 1--- +[1] :barz 1234 +[2] :blattt 234 +[3] :Zebra barz +[4] :1234 blattt +[5] :234 Zebra +--- asort(a, a, "comp_val_str"), IGNORECASE = 1--- +[1] :1234 +[2] :234 +[3] :barz +[4] :blattt +[5] :Zebra diff --git a/test/space.ok b/test/space.ok new file mode 100644 index 0000000..0f76956 --- /dev/null +++ b/test/space.ok @@ -0,0 +1,2 @@ +gawk: fatal: can't open source file ` ' for reading (No such file or directory) +EXIT CODE: 2 diff --git a/test/splitarg4.awk b/test/splitarg4.awk new file mode 100644 index 0000000..4187460 --- /dev/null +++ b/test/splitarg4.awk @@ -0,0 +1,138 @@ +BEGIN { + split("c: ::ab+", fs_arr, ":") +} +{ + for (i = 1; i in fs_arr; ++i) { + split($0, a, fs_arr[i], seps) + print zipcat(a, seps) + dump_array(seps) + } +} +END { + seps[1] = "123"; seps[5] = 10 + for (i = 1; i in fs_arr; ++i) { + split("", a, fs_arr[i], seps) + dump_array(seps) + } +} +function dump_array(a, i, mini, maxi) +{ + mini = minidx(a) + 0 + maxi = maxidx(a) + 0 + printf "{" + for (i = mini; i <= maxi; ++i) + if (i in a) { + if (i > mini) + printf ", " + printf "%d => \"%s\"", i, a[i] + } + printf "}\n" +} +function zipcat(a, b, c) +{ + zip(a, b, c) + return cat(c) +} + +function cat(a, mini, maxi, i, s) +{ + mini = minidx(a) + 0 + maxi = maxidx(a) + 0 + for (i = mini; i <= maxi; ++i) + if (i in a) + s = s a[i] + return s +} + +function zip(a, b, c, mini, maxi, i) +{ + del(c) + mini = minidx2(a, b) + 0 + maxi = maxidx2(a, b) + 0 + for (i = mini; i <= maxi; ++i) { + if (i in a) + c[i] = a[i] + if (i in b) + c[i] = c[i] b[i] + } +} + +function maxidx2(a, b) +{ + if (emptyarr(a)) + return maxidx(b) + else if (emptyarr(b)) + return maxidx(a) + else + return max(maxidx(a), maxidx(b)) +} + +function minidx2(a, b) +{ + if (emptyarr(a)) + return minidx(b) + else if (emptyarr(b)) + return minidx(a) + else + return min(minidx(a), minidx(b)) +} + +function maxidx(a, i, m) +{ + if (emptyarr(a)) + m = "" + else { + m = choose(a) + 0 + for (i in a) { + i += 0 + if (i > m) + m = i + } + } + return m +} + +function minidx(a, i, m) +{ + if (emptyarr(a)) + m = "" + else { + m = choose(a) + 0 + for (i in a) { + i += 0 + if (i < m) + m = i + } + } + return m +} + +function choose(a, m) +{ + for (m in a) + return m + return "" +} + +function emptyarr(a, k) +{ + for (k in a) + return 0 + return 1 +} + +# portable delete +function del(a) +{ + split("", a) +} + +function max(x, y) +{ + return x > y ? x : y +} + +function min(x, y) +{ + return x < y ? x : y +} diff --git a/test/splitarg4.in b/test/splitarg4.in new file mode 100644 index 0000000..3033acd --- /dev/null +++ b/test/splitarg4.in @@ -0,0 +1,11 @@ +caccbdc +acbcd + + a b def +a b dwf + a b dwf +a b dwf +abc +a +aabaabbabbbaabbb +ab diff --git a/test/splitarg4.ok b/test/splitarg4.ok new file mode 100644 index 0000000..761f284 --- /dev/null +++ b/test/splitarg4.ok @@ -0,0 +1,92 @@ +caccbdc +{1 => "c", 2 => "c", 3 => "c", 4 => "c"} +caccbdc +{} +caccbdc +{1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => ""} +caccbdc +{} +acbcd +{1 => "c", 2 => "c"} +acbcd +{} +acbcd +{1 => "", 2 => "", 3 => "", 4 => ""} +acbcd +{} + +{} + +{} + +{} + +{} + a b def +{} + a b def +{0 => " ", 1 => " ", 2 => " ", 3 => " "} + a b def +{1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => "", 7 => "", 8 => "", 9 => ""} + a b def +{} +a b dwf +{} +a b dwf +{1 => " ", 2 => " "} +a b dwf +{1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => ""} +a b dwf +{} + a b dwf +{} + a b dwf +{0 => " ", 1 => " ", 2 => " "} + a b dwf +{1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => "", 7 => ""} + a b dwf +{} +a b dwf +{} +a b dwf +{1 => " ", 2 => " "} +a b dwf +{1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => ""} +a b dwf +{} +abc +{1 => "c"} +abc +{} +abc +{1 => "", 2 => ""} +abc +{1 => "ab"} +a +{} +a +{} +a +{} +a +{} +aabaabbabbbaabbb +{} +aabaabbabbbaabbb +{} +aabaabbabbbaabbb +{1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => "", 7 => "", 8 => "", 9 => "", 10 => "", 11 => "", 12 => "", 13 => "", 14 => "", 15 => ""} +aabaabbabbbaabbb +{1 => "ab", 2 => "abb", 3 => "abbb", 4 => "abbb"} +ab +{} +ab +{} +ab +{1 => ""} +ab +{1 => "ab"} +{} +{} +{} +{} diff --git a/test/splitargv.awk b/test/splitargv.awk new file mode 100644 index 0000000..10886ef --- /dev/null +++ b/test/splitargv.awk @@ -0,0 +1,7 @@ +BEGIN { + for (idx = 1; idx < ARGC; idx++) + split(ARGV[idx], temp, "."); + } + { + print $0; + } diff --git a/test/splitargv.in b/test/splitargv.in new file mode 100644 index 0000000..10886ef --- /dev/null +++ b/test/splitargv.in @@ -0,0 +1,7 @@ +BEGIN { + for (idx = 1; idx < ARGC; idx++) + split(ARGV[idx], temp, "."); + } + { + print $0; + } diff --git a/test/splitargv.ok b/test/splitargv.ok new file mode 100644 index 0000000..10886ef --- /dev/null +++ b/test/splitargv.ok @@ -0,0 +1,7 @@ +BEGIN { + for (idx = 1; idx < ARGC; idx++) + split(ARGV[idx], temp, "."); + } + { + print $0; + } diff --git a/test/splitarr.awk b/test/splitarr.awk new file mode 100644 index 0000000..c1185a4 --- /dev/null +++ b/test/splitarr.awk @@ -0,0 +1,5 @@ +BEGIN { + a[1] = "elephantie" + a[2] = "e" + print split(a[1],a,a[2]), a[2], a[3], split(a[2],a,a[2]) +} diff --git a/test/splitarr.ok b/test/splitarr.ok new file mode 100644 index 0000000..9402b94 --- /dev/null +++ b/test/splitarr.ok @@ -0,0 +1 @@ +4 l phanti 2 diff --git a/test/splitdef.awk b/test/splitdef.awk new file mode 100644 index 0000000..694db80 --- /dev/null +++ b/test/splitdef.awk @@ -0,0 +1,7 @@ +BEGIN { + data = "abc:easy:as:one:two:three" + FS = ":" + FIELDWIDTHS = "3 1 4 1 2 1 3 1 3 1 5" + n = split(data, a) + printf "n = %d, a[3] = %s\n", n, a[3] +} diff --git a/test/splitdef.ok b/test/splitdef.ok new file mode 100644 index 0000000..5f13505 --- /dev/null +++ b/test/splitdef.ok @@ -0,0 +1 @@ +n = 6, a[3] = as diff --git a/test/splitvar.awk b/test/splitvar.awk new file mode 100644 index 0000000..9e1ac79 --- /dev/null +++ b/test/splitvar.awk @@ -0,0 +1,5 @@ +{ + sep = "=+" + n = split($0, a, sep) + print n +} diff --git a/test/splitvar.in b/test/splitvar.in new file mode 100644 index 0000000..85be8ee --- /dev/null +++ b/test/splitvar.in @@ -0,0 +1 @@ +Here===Is=Some=====Data diff --git a/test/splitvar.ok b/test/splitvar.ok new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/test/splitvar.ok @@ -0,0 +1 @@ +4 diff --git a/test/splitwht.awk b/test/splitwht.awk new file mode 100644 index 0000000..6163d72 --- /dev/null +++ b/test/splitwht.awk @@ -0,0 +1,7 @@ +BEGIN { + str = "a b\t\tc d" + n = split(str, a, " ") + print n + m = split(str, b, / /) + print m +} diff --git a/test/splitwht.ok b/test/splitwht.ok new file mode 100644 index 0000000..61c83cb --- /dev/null +++ b/test/splitwht.ok @@ -0,0 +1,2 @@ +4 +5 diff --git a/test/sprintfc.awk b/test/sprintfc.awk new file mode 100644 index 0000000..ee1e5a7 --- /dev/null +++ b/test/sprintfc.awk @@ -0,0 +1 @@ +{ print sprintf("%c", $1), $1 } diff --git a/test/sprintfc.in b/test/sprintfc.in new file mode 100644 index 0000000..4602d28 --- /dev/null +++ b/test/sprintfc.in @@ -0,0 +1,3 @@ +65 +66 +foo diff --git a/test/sprintfc.ok b/test/sprintfc.ok new file mode 100644 index 0000000..33769a8 --- /dev/null +++ b/test/sprintfc.ok @@ -0,0 +1,3 @@ +A 65 +B 66 +f foo diff --git a/test/strcat1.awk b/test/strcat1.awk new file mode 100644 index 0000000..0d28017 --- /dev/null +++ b/test/strcat1.awk @@ -0,0 +1,6 @@ + +function f1(b) { b = b "c"; print f(b); } + +function f(a) { a = a "b"; return a; } + +BEGIN { A = "a"; f1(A); } diff --git a/test/strcat1.ok b/test/strcat1.ok new file mode 100644 index 0000000..66a2f4b --- /dev/null +++ b/test/strcat1.ok @@ -0,0 +1 @@ +acb diff --git a/test/strftime.awk b/test/strftime.awk new file mode 100644 index 0000000..775cd4e --- /dev/null +++ b/test/strftime.awk @@ -0,0 +1,19 @@ +# strftime.awk ; test the strftime code +# +# input is the output of `date', see Makefile.in +# +# The mucking about with $0 and $N is to avoid problems +# on cygwin, where the timezone field is empty and there +# are two consecutive blanks. + +# Additional mucking about to lop off the seconds field; +# helps decrease chance of difference due to a second boundary + +{ + $3 = sprintf("%02d", $3 + 0) + $4 = substr($4, 1, 5) + print > "strftime.ok" + $0 = strftime("%a %b %d %H:%M %Z %Y") + $NF = $NF + print > OUTPUT +} diff --git a/test/strftlng.awk b/test/strftlng.awk new file mode 100644 index 0000000..0ef8195 --- /dev/null +++ b/test/strftlng.awk @@ -0,0 +1,11 @@ +# test file from Paul Eggert, eggert@twinsun.com +# modified for portability (%c doesn't cut it) + +BEGIN { + BUFSIZ = 1024 + simpleformat = format = "%m/%d/%y %H:%M:%S\n" + clen = length(strftime(format, 0)) + for (i = 1; i < BUFSIZ / clen + 1; i++) + format = format simpleformat + printf "%s", strftime(format, 0) +} diff --git a/test/strftlng.ok b/test/strftlng.ok new file mode 100644 index 0000000..3008aa2 --- /dev/null +++ b/test/strftlng.ok @@ -0,0 +1,58 @@ +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 +01/01/70 00:00:00 diff --git a/test/strnum1.awk b/test/strnum1.awk new file mode 100644 index 0000000..e9cbdaf --- /dev/null +++ b/test/strnum1.awk @@ -0,0 +1,35 @@ +# Date: Tue, 04 Jul 2006 21:06:14 +0200 (MEST) +# From: Heiner Marxen +# Subject: conversion error +# To: bug-gawk@gnu.org +# Message-id: <200607041906.k64J6Eqa019360@drb9.drb.insel.de> +# +# Hello, +# +# The following awk script fails for gawk 3.1.4 and 3.1.5. +# Older versions did not do this, but I cannot say, how old they were. +# +BEGIN { + if( 0 ) { #ok + t = "8" + }else { #fails + t = "" + t = t "8" + } + printf("8 = %d\n", 0+t) # ok without this line + t = t "8" # does not invalidate numeric interpretation + printf("88 = %s\n", 0+t) + ## The above prints "88 = 8" with gawk 3.1.4 and 3.1.5 +} +# +# +# The following one-liner already exhibits the bug: +# +# gawk 'BEGIN{t=""; t=t "8";printf("8=%d\n", 0+t);t=t "8";printf("88=%s\n", 0+t)}' +# +# +# Preliminary observation: under somewhat strange conditions a variable +# does retain its numeric interpretation although something is appended to it. +# -- +# Heiner Marxen http://www.drb.insel.de/~heiner/ +# diff --git a/test/strnum1.ok b/test/strnum1.ok new file mode 100644 index 0000000..804bcfd --- /dev/null +++ b/test/strnum1.ok @@ -0,0 +1,2 @@ +8 = 8 +88 = 88 diff --git a/test/strtod.awk b/test/strtod.awk new file mode 100644 index 0000000..3326478 --- /dev/null +++ b/test/strtod.awk @@ -0,0 +1,5 @@ +{ + x = "0x" $1 ; print x, x + 0 + for (i=1; i<=NF; i++) + if ($i) print $i, "is not zero" +} diff --git a/test/strtod.in b/test/strtod.in new file mode 100644 index 0000000..d7f71aa --- /dev/null +++ b/test/strtod.in @@ -0,0 +1 @@ +345 0 00 0e0 0E1 00E0 000e-5 .0e+0 diff --git a/test/strtod.ok b/test/strtod.ok new file mode 100644 index 0000000..a47a9b1 --- /dev/null +++ b/test/strtod.ok @@ -0,0 +1,2 @@ +0x345 0 +345 is not zero diff --git a/test/strtonum.awk b/test/strtonum.awk new file mode 100644 index 0000000..22ad41e --- /dev/null +++ b/test/strtonum.awk @@ -0,0 +1,6 @@ +BEGIN { + print strtonum("0x13") + print strtonum("013") + print strtonum("13") + print strtonum(13) +} diff --git a/test/strtonum.ok b/test/strtonum.ok new file mode 100644 index 0000000..9d1e557 --- /dev/null +++ b/test/strtonum.ok @@ -0,0 +1,4 @@ +19 +11 +13 +13 diff --git a/test/subamp.awk b/test/subamp.awk new file mode 100644 index 0000000..731726c --- /dev/null +++ b/test/subamp.awk @@ -0,0 +1 @@ +{ sub(/[[:lower:]]/, "&") ; print } diff --git a/test/subamp.in b/test/subamp.in new file mode 100644 index 0000000..72943a1 --- /dev/null +++ b/test/subamp.in @@ -0,0 +1 @@ +aaa diff --git a/test/subamp.ok b/test/subamp.ok new file mode 100644 index 0000000..72943a1 --- /dev/null +++ b/test/subamp.ok @@ -0,0 +1 @@ +aaa diff --git a/test/subi18n.awk b/test/subi18n.awk new file mode 100644 index 0000000..69bfca2 --- /dev/null +++ b/test/subi18n.awk @@ -0,0 +1,68 @@ +# Date: Mon, 27 Feb 2006 12:35:30 +0900 +# From: KIMURA Koichi +# Subject: gawk: sub_common has multi-byte aware bug +# To: bug-gawk@gnu.org +# Message-id: <20060227121045.2198.KIMURA.KOICHI@canon.co.jp> +# +# Hi, +# +# A certain user faced bug of sub builtin function and report to me. +# Then I investigated the bug. +# +# reproduce script is here. + +BEGIN { + str = "type=\"directory\" version=\"1.0\"" + #print "BEGIN:", str + + while (str) { + sub(/^[^=]*/, "", str); + s = substr(str, 2) + print s + sub(/^="[^"]*"/, "", str) + sub(/^[ \t]*/, "", str) + } +} + +# and sample result is here (on GNU/Linux Fedora core 3) +# +# [kbk@skuld gawk-3.1.5]$ LC_ALL=C ./gawk -f subbug.awk +# "directory" version="1.0" +# "1.0" +# [kbk@skuld gawk-3.1.5]$ LC_ALL=en_US.UTF-8 ./gawk -f subbug.awk +# "directory" version="1.0" +# "dire +# [kbk@skuld gawk-3.1.5]$ +# +# In my investigation, this bug is cause by don't release wide-string when +# sub is executed. +# +# patch is here. +# +# --- builtin.c.orig 2005-07-27 03:07:43.000000000 +0900 +# +++ builtin.c 2006-02-26 02:07:52.000000000 +0900 +# @@ -2463,6 +2468,15 @@ sub_common(NODE *tree, long how_many, in +# t->stptr = buf; +# t->stlen = textlen; +# +# +#ifdef MBS_SUPPORT +# + if (t->flags & WSTRCUR) { +# + if (t->wstptr != NULL) +# + free(t->wstptr); +# + t->wstptr = NULL; +# + t->wstlen = 0; +# + t->flags &= ~WSTRCUR; +# + } +# +#endif +# free_temp(s); +# if (matches > 0 && lhs) { +# if (priv) { +# +# +# -- +# KIMURA Koichi +# +# +# ##################################################################################### +# This Mail Was Scanned by 012.net AntiVirus Service1- Powered by TrendMicro Interscan +# diff --git a/test/subi18n.ok b/test/subi18n.ok new file mode 100644 index 0000000..54842cd --- /dev/null +++ b/test/subi18n.ok @@ -0,0 +1,2 @@ +"directory" version="1.0" +"1.0" diff --git a/test/subsepnm.awk b/test/subsepnm.awk new file mode 100644 index 0000000..976eef9 --- /dev/null +++ b/test/subsepnm.awk @@ -0,0 +1 @@ +BEGIN { SUBSEP = 10; a[1, 1] = 100 ; print a[1 SUBSEP 1] } diff --git a/test/subsepnm.ok b/test/subsepnm.ok new file mode 100644 index 0000000..29d6383 --- /dev/null +++ b/test/subsepnm.ok @@ -0,0 +1 @@ +100 diff --git a/test/subslash.awk b/test/subslash.awk new file mode 100644 index 0000000..87ab029 --- /dev/null +++ b/test/subslash.awk @@ -0,0 +1,6 @@ +BEGIN { + i = 2 + a[i] = 5 + a[i] /= 2 + printf "a[%s] = %f\n", i, a[i] +} diff --git a/test/subslash.ok b/test/subslash.ok new file mode 100644 index 0000000..4f3beff --- /dev/null +++ b/test/subslash.ok @@ -0,0 +1 @@ +a[2] = 2.500000 diff --git a/test/substr.awk b/test/substr.awk new file mode 100644 index 0000000..6016369 --- /dev/null +++ b/test/substr.awk @@ -0,0 +1,14 @@ +BEGIN { + x = "A" + printf("%-39s\n", substr(x,1,39)) + print substr("abcdef", 0, 2) + print substr("abcdef", 2.3, 2) + print substr("abcdef", -1, 2) + print substr("abcdef", 1, 0) + print substr("abcdef", 1, -3) + print substr("abcdef", 1, 2.3) + print substr("", 1, 2) + print substr("abcdef", 5, 5) + print substr("abcdef", 7, 2) + exit (0) +} diff --git a/test/substr.ok b/test/substr.ok new file mode 100644 index 0000000..be6889d --- /dev/null +++ b/test/substr.ok @@ -0,0 +1,10 @@ +A +ab +bc +ab + + +ab + +ef + diff --git a/test/swaplns.awk b/test/swaplns.awk new file mode 100644 index 0000000..6bf2240 --- /dev/null +++ b/test/swaplns.awk @@ -0,0 +1,7 @@ +{ + if ((getline tmp) > 0) { + print tmp + print + } else + print +} diff --git a/test/swaplns.in b/test/swaplns.in new file mode 100644 index 0000000..71fb162 --- /dev/null +++ b/test/swaplns.in @@ -0,0 +1,9 @@ +This directory contains some examples/test-cases for different +features of gawk - mostly not present in an old awk. Some are from +"The GAWK Manual", some are original, and some are mixture of the two. +Read header comments before attempting to use. Have fun and remember +that program which consists only of BEGIN block does not need an input +file. + + --mj + diff --git a/test/swaplns.ok b/test/swaplns.ok new file mode 100644 index 0000000..d38b7ca --- /dev/null +++ b/test/swaplns.ok @@ -0,0 +1,9 @@ +features of gawk - mostly not present in an old awk. Some are from +This directory contains some examples/test-cases for different +Read header comments before attempting to use. Have fun and remember +"The GAWK Manual", some are original, and some are mixture of the two. +file. +that program which consists only of BEGIN block does not need an input + --mj + + diff --git a/test/switch2.awk b/test/switch2.awk new file mode 100644 index 0000000..f788edb --- /dev/null +++ b/test/switch2.awk @@ -0,0 +1,59 @@ +# From spcecdt@armory.com Tue Jun 3 11:41:49 2003 +# Return-Path: +# Received: from localhost (skeeve [127.0.0.1]) +# by skeeve.com (8.12.5/8.12.5) with ESMTP id h538fVuW018115 +# for ; Tue, 3 Jun 2003 11:41:49 +0300 +# Received: from actcom.co.il [192.114.47.1] +# by localhost with POP3 (fetchmail-5.9.0) +# for arnold@localhost (single-drop); Tue, 03 Jun 2003 11:41:49 +0300 (IDT) +# Received: by actcom.co.il (mbox arobbins) +# (with Cubic Circle's cucipop (v1.31 1998/05/13) Tue Jun 3 11:41:37 2003) +# X-From_: spcecdt@armory.com Mon Jun 2 20:17:30 2003 +# Received: from smtp1.actcom.net.il by actcom.co.il with ESMTP +# (8.11.6/actcom-0.2) id h52HHNY23516 for ; +# Mon, 2 Jun 2003 20:17:24 +0300 (EET DST) +# (rfc931-sender: mail.actcom.co.il [192.114.47.13]) +# Received: from f7.net (consort.superb.net [209.61.216.22]) +# by smtp1.actcom.net.il (8.12.8/8.12.8) with ESMTP id h52HIHqv028728 +# for ; Mon, 2 Jun 2003 20:18:18 +0300 +# Received: from armory.com (deepthought.armory.com [192.122.209.42]) +# by f7.net (8.11.7/8.11.6) with SMTP id h52HHKl31637 +# for ; Mon, 2 Jun 2003 13:17:20 -0400 +# Date: Mon, 2 Jun 2003 10:17:11 -0700 +# From: "John H. DuBois III" +# To: arnold@skeeve.com +# Subject: gawk 3.1.2c coredump +# Message-ID: <20030602171711.GA3958@armory.com> +# Mime-Version: 1.0 +# Content-Type: text/plain; charset=us-ascii +# Content-Disposition: inline +# User-Agent: Mutt/1.3.28i +# X-Www: http://www.armory.com./~spcecdt/ +# Sender: spcecdt@armory.com +# X-SpamBouncer: 1.4 (10/07/01) +# X-SBClass: OK +# Status: R +# +#!/usr/local/bin/gawk -f +BEGIN { + switch (substr("x",1,1)) { + case /ask.com/: + break + case "google": + break + } +} +# +# The stack says: +# +# #0 0x0806fac2 in r_tree_eval (tree=0x8092000, iscond=0) at eval.c:813 +# #1 0x08070413 in r_tree_eval (tree=0x0, iscond=0) at eval.c:1071 +# #2 0x08070413 in r_tree_eval (tree=0x8092000, iscond=0) at eval.c:1071 +# #3 0x08070413 in r_tree_eval (tree=0x8092000, iscond=0) at eval.c:1071 +# [ this continues on indefinitely - I suppose it ran out of stack eventually ] +# +# John +# -- +# John DuBois spcecdt@armory.com KC6QKZ/AE http://www.armory.com/~spcecdt/ +# +# diff --git a/test/switch2.ok b/test/switch2.ok new file mode 100644 index 0000000..e69de29 diff --git a/test/synerr1.awk b/test/synerr1.awk new file mode 100644 index 0000000..131708d --- /dev/null +++ b/test/synerr1.awk @@ -0,0 +1,4 @@ +# program to make sure we don't infinite +# syntax errors + +print "hi" diff --git a/test/synerr1.ok b/test/synerr1.ok new file mode 100644 index 0000000..e180f13 --- /dev/null +++ b/test/synerr1.ok @@ -0,0 +1,3 @@ +gawk: synerr1.awk:4: print "hi" +gawk: synerr1.awk:4: ^ syntax error +EXIT CODE: 1 diff --git a/test/synerr2.awk b/test/synerr2.awk new file mode 100644 index 0000000..9860f24 --- /dev/null +++ b/test/synerr2.awk @@ -0,0 +1,47 @@ +# From: =?ISO-8859-1?Q?J=FCrgen_Kahrs?= +# Newsgroups: gnu.utils.bug +# Subject: Re: gawk-3.1.5: syntax error, core dump +# Date: Fri, 23 Jun 2006 18:12:07 +0200 +# Lines: 12 +# Approved: bug-gnu-utils@gnu.org +# Message-ID: +# References: +# Reply-To: Juergen.KahrsDELETETHIS@vr-web.de +# NNTP-Posting-Host: lists.gnu.org +# Mime-Version: 1.0 +# Content-Type: text/plain; charset=ISO-8859-1 +# Content-Transfer-Encoding: 7bit +# X-Trace: news.Stanford.EDU 1151079136 27033 199.232.76.165 (23 Jun 2006 16:12:16 GMT) +# X-Complaints-To: news@news.stanford.edu +# To: gnu-utils-bug@moderators.isc.org +# Envelope-to: bug-gnu-utils@gnu.org +# X-Orig-X-Trace: individual.net +# vYX9N7nUUtqHxPyspweN0gZ4Blkl17z/xU01EwbykxB178O8M= +# User-Agent: Thunderbird 1.5 (X11/20060317) +# In-Reply-To: +# X-BeenThere: bug-gnu-utils@gnu.org +# X-Mailman-Version: 2.1.5 +# Precedence: list +# List-Id: Bug reports for the GNU utilities +# List-Unsubscribe: , +# +# List-Archive: +# List-Post: +# List-Help: +# List-Subscribe: , +# +# Path: news.012.net.il!seanews2.seabone.net!newsfeed.albacom.net!news.mailgate.org!newsfeed.stueberl.de!newsfeed.news2me.com!headwall.stanford.edu!newsfeed.stanford.edu!shelby.stanford.edu!individual.net!not-for-mail +# Xref: news.012.net.il gnu.utils.bug:813 +# +# Karel Zak wrote: +# +# > it seems that gawk has problem with "syntax error" reporting: +# > +# > ./gawk '/^include / { system(sprintf("cd /etc; cat %s", [$]2)); skip +# > = 1; } { if (!skip) print $0; skipQuit; }' < /etc/ld.so.conf +# +# This test case can be boiled down to +# +# gawk 'BEGIN {sprintf("%s", $)}' +# +BEGIN { sprintf("%s", $) } diff --git a/test/synerr2.ok b/test/synerr2.ok new file mode 100644 index 0000000..cd30a84 --- /dev/null +++ b/test/synerr2.ok @@ -0,0 +1,3 @@ +gawk: synerr2.awk:47: BEGIN { sprintf("%s", $) } +gawk: synerr2.awk:47: ^ syntax error +EXIT CODE: 1 diff --git a/test/tradanch.awk b/test/tradanch.awk new file mode 100644 index 0000000..0cd45d1 --- /dev/null +++ b/test/tradanch.awk @@ -0,0 +1,2 @@ +/foo^bar/ +/foo$bar/ diff --git a/test/tradanch.in b/test/tradanch.in new file mode 100644 index 0000000..e5c8a09 --- /dev/null +++ b/test/tradanch.in @@ -0,0 +1,2 @@ +foo^bar +foo$bar diff --git a/test/tradanch.ok b/test/tradanch.ok new file mode 100644 index 0000000..e69de29 diff --git a/test/tweakfld.awk b/test/tweakfld.awk new file mode 100644 index 0000000..e7b538f --- /dev/null +++ b/test/tweakfld.awk @@ -0,0 +1,296 @@ +# To: bug-gnu-utils@prep.ai.mit.edu +# Cc: arnold@gnu.ai.mit.edu +# Date: Mon, 20 Nov 1995 11:39:29 -0500 +# From: "R. Hank Donnelly" +# +# Operating system: Linux1.2.13 (Slackware distrib) +# GAWK version: 2.15 (?) +# compiler: GCC (?) +# +# The following enclosed script does not want to fully process the input data +# file. It correctly executes the operations on the first record, and then dies +# on the second one. My true data file is much longer but this is +# representative and it does fail on a file even as short as this one. +# The failure appears to occur in the declared function add2output. Between the +# steps of incrementing NF by one and setting $NF to the passed variable +# the passed variable appears to vanish (i.e. NF does go from 68 to 69 +# and before incrementing it "variable" equals what it should but after +# "variable" has no value at all.) +# +# The scripts have been developed using nawk on a Sun (where they run fine) +# I have tried gawk there but get a different crash which I have not yet traced +# down. Ideally I would like to keep the script the same so that it would run +# on either gawk or nawk (that way I can step back and forth between laptop and +# workstation. +# +# Any ideas why the laptop installation is having problems? +# Hank +# +# +# #!/usr/bin/gawk -f + +BEGIN { + # set a few values + FS = "\t" + OFS = "\t" + pi = atan2(0, -1) +# distance from HRMA to focal plane in mm + fullradius = 10260.54 + + # set locations of parameters on input line + nf_nrg = 1 + nf_order = 3 + nf_item = 4 + nf_suite = 5 + nf_grating = 8 + nf_shutter = 9 + nf_type = 13 + nf_src = 14 + nf_target = 15 + nf_voltage = 16 + nf_flux = 17 + nf_filt1 = 20 + nf_filt1_th = 21 + nf_filt2 = 22 + nf_filt2_th = 23 + nf_bnd = 24 + nf_hrma_polar = 27 + nf_hrma_az = 28 + nf_detector = 30 + nf_acis_read = 32 + nf_acis_proc = 33 + nf_acis_frame = 34 + nf_hxda_aplist = 36 + nf_hxda_y_range = 37 + nf_hxda_z_range = 38 + nf_hxda_y_step = 39 + nf_hxda_z_step = 40 + nf_sim_z = 41 + nf_fam_polar = 43 + nf_fam_az = 44 + nf_fam_dither_type = 45 + nf_mono_init = 51 + nf_mono_range = 52 + nf_mono_step = 53 + nf_defocus = 54 + nf_acis_temp = 55 + nf_tight = 59 + nf_offset_y = 64 + nf_offset_z = 65 + + while( getline < "xrcf_mnemonics.dat" > 0 ) { + mnemonic[$1] = $2 + } + +# "date" | getline date_line +# ADR: use a fixed date so that testing will work + date_line = "Sun Mar 10 23:00:27 EST 1996" + split(date_line, in_date, " ") + out_date = in_date[2] " " in_date[3] ", " in_date[6] +} + +function add2output( variable ) { +#print("hi1") >> "debug" + NF++ +#print("hi2") >> "debug" + $NF = variable +#print("hi3") >> "debug" +} + +function error( ekey, message ) { + print "Error at input line " NR ", anode " ekey >> "errors.cleanup" + print " " message "." >> "errors.cleanup" +} + +function hxda_na() { + $nf_hxda_aplist = $nf_hxda_y_range = $nf_hxda_z_range = "N/A" + $nf_hxda_y_step = $nf_hxda_z_step = "N/A" +} + +function acis_na() { + $nf_acis_read = $nf_acis_proc = $nf_acis_frame = $nf_acis_temp = "N/A" +} + +function hrc_na() { +# print ("hi") >> "debug" +} + +function fpsi_na() { + acis_na() + hrc_na() + $nf_sim_z = $nf_fam_polar = $nf_fam_az = $nf_fam_dither_type = "N/A" +} + +function mono_na() { + $nf_mono_init = $nf_mono_range = $nf_mono_step = "N/A" +} + +# this gives the pitch and yaw of the HRMA and FAM +# positive pitch is facing the source "looking down" +# positive yaw is looking left +# 0 az is north 90 is up +# this also adds in the FAM X,Y,Z positions + +function polaz2yawpitch(polar, az) { + theta = az * pi / 180 + phi = polar * pi / 180 / 60 + + + if( polar == 0 ) { + add2output( 0 ) + add2output( 0 ) + } else { + if(az == 0 || az == 180) + add2output( 0 ) + else + add2output( - polar * sin(theta) ) + + +# x = cos (phi) +# y = sin (phi) * cos (theta) +# add2output( atan2(y,x)*180 / pi * 60 ) + + if(az == 90 || az ==270 ) + add2output( 0 ) + else + add2output( - polar * cos(theta) ) + + } +# x = cos (phi) +# z= sin (phi) * sin (theta) +# add2output( atan2(z,x)*180 / pi * 60 ) + + if(config !~ /HXDA/) { +# negative values of defocus move us farther from the source thus +# increasing radius + radius = fullradius - defocus + +# FAM_x; FAM_y; FAM_z + if((offset_y == 0) && (offset_z == 0)){ + add2output( fullradius - radius * cos (phi) ) + + if (az == 90 || az ==270) + add2output( 0 ) + else + add2output( radius * sin (phi) * cos (theta) ) + + if (az == 0 || az == 180) + add2output( 0 ) + else + add2output( - radius * sin (phi) * sin (theta) ) + } else { +# ******* THIS SEGMENT OF CODE IS NOT MATHEMATICALLY CORRECT FOR **** +# OFF AXIS ANGLES AND IS SUPPLIED AS A WORKAROUND SINCE IT WILL +# PROBABLY ONLY BE USED ON AXIS. + add2output( defocus ) + add2output( offset_y ) + add2output( offset_z ) + } + + } else { + add2output( "N/A" ) + add2output( "N/A" ) + add2output( "N/A" ) + } +} + +# set TIGHT/LOOSE to N/A if it is not one of the two allowed values +function tight_na() { + if( $nf_tight !~ /TIGHT|LOOSE/ ) { + $nf_tight == "N/A" + } +} + +# this entry is used to give certain entries names +{ + type = $nf_type + item = $nf_item + suite = $nf_suite + order = $nf_order + detector = $nf_detector + grating = $nf_grating + offset_y= $nf_offset_y + offset_z= $nf_offset_z + bnd = $nf_bnd + defocus = $nf_defocus +} + +{ + # make configuration parameter + # as well as setting configuration-dependent N/A values + + if( $nf_bnd ~ "SCAN" ) { + # BND is scanning beam + config = "BND" + hxda_na() + fpsi_na() + } else { + if( grating == "NONE" ) { + config = "HRMA" + } else { + if( grating == "HETG" ) { + if( order != "Both" ) { + $nf_shutter = order substr($nf_shutter, \ + index($nf_shutter, ",") ) + } + } else { + order = "N/A" + } + config = "HRMA/" grating + } + + if( detector ~ /ACIS|HRC/ ) { + detsys = detector + nsub = sub("-", ",", detsys) + config = config "/" detsys + hxda_na() + } else { + config = config "/HXDA" + fpsi_na() + if( detector == "HSI" ) { + hxda_na() + } + } + } + + add2output( config ) + + if( $nf_src ~ /EIPS|Penning/ ) mono_na() + + if( $nf_src == "Penning" ) $nf_voltage = "N/A" + + itm = sprintf("%03d", item) + + if(config in mnemonic) { + if( type in mnemonic ) { + ID = mnemonic[config] "-" mnemonic[type] "-" suite "." itm + add2output( ID ) + } else { + error(type, "measurement type not in list") + } + } else { + error(config, "measurement configuration not in list") + } + + # add date to output line + add2output( out_date ) + + # Convert HRMA polar and azimuthal angles to yaw and pitch + polaz2yawpitch($nf_hrma_polar, $nf_hrma_az) + + # set TIGHT/LOOSE to N/A if it is not one of the two allowed values + tight_na() + + # compute number of HXDA apertures + if( config ~ /HXDA/ && $nf_hxda_aplist != "N/A") + add2output( split( $nf_hxda_aplist, dummy, "," ) ) + else + add2output( "N/A" ) + + # make sure the BND value is properly set + if($nf_bnd == "FIXED" && detector ~ /ACIS/) + $nf_bnd =bnd"-SYNC" + else + $nf_bnd = bnd"-FREE" + print +} diff --git a/test/tweakfld.in b/test/tweakfld.in new file mode 100644 index 0000000..e27a9dd --- /dev/null +++ b/test/tweakfld.in @@ -0,0 +1,3 @@ +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 +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 +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 diff --git a/test/tweakfld.ok b/test/tweakfld.ok new file mode 100644 index 0000000..3c4d894 --- /dev/null +++ b/test/tweakfld.ok @@ -0,0 +1,3 @@ +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 +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 +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 diff --git a/test/uninit2.awk b/test/uninit2.awk new file mode 100644 index 0000000..9ded557 --- /dev/null +++ b/test/uninit2.awk @@ -0,0 +1,2 @@ +BEGIN { a = a + 1; x = a; print a} +BEGIN { ++b; x = b; print b} diff --git a/test/uninit2.ok b/test/uninit2.ok new file mode 100644 index 0000000..2001a39 --- /dev/null +++ b/test/uninit2.ok @@ -0,0 +1,4 @@ +gawk: uninit2.awk:1: warning: reference to uninitialized variable `a' +1 +gawk: uninit2.awk:2: warning: reference to uninitialized variable `b' +1 diff --git a/test/uninit3.awk b/test/uninit3.awk new file mode 100644 index 0000000..d0140d5 --- /dev/null +++ b/test/uninit3.awk @@ -0,0 +1,7 @@ +function f(x){ + print x +} + +BEGIN { + f(x) +} diff --git a/test/uninit3.ok b/test/uninit3.ok new file mode 100644 index 0000000..9787672 --- /dev/null +++ b/test/uninit3.ok @@ -0,0 +1,3 @@ +gawk: uninit3.awk:1: warning: function `f': parameter `x' shadows global variable +gawk: uninit3.awk:2: warning: reference to uninitialized argument `x' + diff --git a/test/uninit4.awk b/test/uninit4.awk new file mode 100644 index 0000000..89de732 --- /dev/null +++ b/test/uninit4.awk @@ -0,0 +1,13 @@ +# test whether --lint catches uninitialized fields: +function pr() +{ + print +} + +BEGIN { + pr() + print $0 + print $(1-1) + print $1 + NF=3; print $2 +} diff --git a/test/uninit4.ok b/test/uninit4.ok new file mode 100644 index 0000000..3ea4da3 --- /dev/null +++ b/test/uninit4.ok @@ -0,0 +1,10 @@ +gawk: uninit4.awk:4: warning: reference to uninitialized field `$0' + +gawk: uninit4.awk:9: warning: reference to uninitialized field `$0' + +gawk: uninit4.awk:10: warning: reference to uninitialized field `$0' + +gawk: uninit4.awk:11: warning: reference to uninitialized field `$1' + +gawk: uninit4.awk:12: warning: reference to uninitialized field `$2' + diff --git a/test/uninit5.awk b/test/uninit5.awk new file mode 100644 index 0000000..e63abe1 --- /dev/null +++ b/test/uninit5.awk @@ -0,0 +1,111 @@ +#From gregfjohnson@yahoo.com Sun Aug 30 08:36:36 2009 +#Return-Path: +#Received: from aahz (localhost [127.0.0.1]) +# by skeeve.com (8.14.1/8.14.1) with ESMTP id n7U5WoJ2003836 +# for ; Sun, 30 Aug 2009 08:36:36 +0300 +#X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on server1.f7.net +#X-Spam-Level: +#X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED +# autolearn=ham version=3.2.4 +#X-Envelope-From: gregfjohnson@yahoo.com +#X-Envelope-To: +#Received: from server1.f7.net [64.34.169.74] +# by aahz with IMAP (fetchmail-6.3.7) +# for (single-drop); Sun, 30 Aug 2009 08:36:36 +0300 (IDT) +#Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) +# by f7.net (8.11.7-20030920/8.11.7) with ESMTP id n7U33m709453 +# for ; Sat, 29 Aug 2009 22:03:48 -0500 +#Received: from mail.gnu.org ([199.232.76.166]:42095 helo=mx10.gnu.org) +# by fencepost.gnu.org with esmtp (Exim 4.67) +# (envelope-from ) +# id 1Mhai6-0004Qt-3R +# for bug-gawk@gnu.org; Sat, 29 Aug 2009 23:04:06 -0400 +#Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) +# (envelope-from ) +# id 1Mhai5-00062I-EM +# for bug-gawk@gnu.org; Sat, 29 Aug 2009 23:04:05 -0400 +#Received: from web33507.mail.mud.yahoo.com ([68.142.206.156]:28597) +# by monty-python.gnu.org with smtp (Exim 4.60) +# (envelope-from ) +# id 1Mhai5-00061w-2n +# for bug-gawk@gnu.org; Sat, 29 Aug 2009 23:04:05 -0400 +#Received: (qmail 68722 invoked by uid 60001); 30 Aug 2009 03:04:03 -0000 +#DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1251601443; bh=9h2ZOOgxUh+s8Ow5/ZMWUxcviy2L4rpiaNamPAXxhEk=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=tWxCQq/aTOT5lhtdPc5hxtXzOjDFmLU6Ao0BSlwbeeBsd9Wl6DU3JCR4gTkoL0aVUOTdjMjgRY7I72yCht+YruDiqZrvtSKvUoAvZAKcPG26RE4jzxUlxQklEHZG9mq9h2gpTIiLYehYDiC0975wukwi/e7ePADfkFwg8eTnT44= +#DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; +# s=s1024; d=yahoo.com; +# h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; +# b=LWfhVgxojFG1eYoRrxtrS3YOfH3MTUVTYZle/4utMQEPZQfsmrn6GBwBfThryGqJyZfg38/7JfK9cz/Q3Yt+mf8+xl9/m+Srckc+Xvi42CE0OmoN439vCyhAD8A74XOJsmfKDjJ/+LtioShStUohj1iYDDmRTN4RnnP9X4xnt3c=; +#Message-ID: <410222.68490.qm@web33507.mail.mud.yahoo.com> +#X-YMail-OSG: mfjax.MVM1lI2q5gcl6bChbn6zHgNgj1fByHWJSzB8ZZUmI2QCH6pNwV_IaHxcqecu.VqjKUR6HQhXbziUnX.v5E2nOE61ass9AzqfdVOtKTEAzTPQJ8Z7QB7fq7BMtjn8yohDR6mwOyVTqv3RZh0m1Us7sLit6UmcgeSvJo2rROAmeceq.FBwk2XnEp2_QsljjPHak_WXyvtAK81klDv5qQORWQWqR9q79x7yxORL6fLWwb_x6mZZMSOUaA0p8.ucT453eqT1L8NGkthF.fXmOM3_EYd03zUgr9Sb.zvMvbDC3MCMnVr0JT1uroLmFtVIdTojrFJYFQEDFSB9zT3Ua80ZpGXrjQGx3rZw-- +#Received: from [71.165.246.171] by web33507.mail.mud.yahoo.com via HTTP; Sat, 29 Aug 2009 20:04:03 PDT +#X-Mailer: YahooMailClassic/6.1.2 YahooMailWebService/0.7.338.2 +#Date: Sat, 29 Aug 2009 20:04:03 -0700 (PDT) +#From: Greg Johnson +#Subject: bugs in passing uninitialized array to a function +#To: bug-gawk@gnu.org +#MIME-Version: 1.0 +#Content-Type: multipart/mixed; boundary="0-1690489838-1251601443=:68490" +#X-detected-operating-system: by monty-python.gnu.org: FreeBSD 6.x (1) +#Status: RO +# +#--0-1690489838-1251601443=:68490 +#Content-Type: text/plain; charset=us-ascii +# +#I am using gawk version 3.1.7. +# +#The attached programs illustrate what look to me like two bugs +#in the handling of uninitialized variables to functions that treat +#them as arrays. +# +#Greg Johnson +# +# +# +#--0-1690489838-1251601443=:68490 +#Content-Type: application/octet-stream; name=b1 +#Content-Transfer-Encoding: base64 +#Content-Disposition: attachment; filename="b1" + +# bug? on uninitialized array, length(a) prints as 3, then the loop +# behaves differently, iterating once. so, length() behaves differently +# on two calls to the same variable, which was not changed. + +function prt1(a, len) +{ + print "length: " length(a) + + for (i = 1; i <= length(a); i++) + printf "<" i "," a[i] "> " + + print "\n" +} + +BEGIN { + prt1(zzz) +} + +#--0-1690489838-1251601443=:68490 +#Content-Type: application/octet-stream; name=b2 +#Content-Transfer-Encoding: base64 +#Content-Disposition: attachment; filename="b2" + +# shouldn't an uninitialized array have length zero? +# length is printed as 1, and the loop iterates once. + +function prt(a, len) +{ + len = length(a) + print "length: " len + + for (i = 1; i <= len; i++) + printf "<" i "," a[i] "> " + + print "\n" +} + +BEGIN { + prt(zzz) +} + +#--0-1690489838-1251601443=:68490-- + diff --git a/test/uninit5.ok b/test/uninit5.ok new file mode 100644 index 0000000..1d2a583 --- /dev/null +++ b/test/uninit5.ok @@ -0,0 +1,9 @@ +gawk: uninit5.awk:75: warning: reference to uninitialized argument `a' +length: 0 +gawk: uninit5.awk:77: warning: reference to uninitialized argument `a' + + +gawk: uninit5.awk:97: warning: reference to uninitialized argument `a' +length: 0 + + diff --git a/test/uninitialized.awk b/test/uninitialized.awk new file mode 100644 index 0000000..09bb643 --- /dev/null +++ b/test/uninitialized.awk @@ -0,0 +1,3 @@ +BEGIN { + a += 2 +} diff --git a/test/uninitialized.ok b/test/uninitialized.ok new file mode 100644 index 0000000..86ab474 --- /dev/null +++ b/test/uninitialized.ok @@ -0,0 +1 @@ +gawk: uninitialized.awk:2: warning: reference to uninitialized variable `a' diff --git a/test/unterm.awk b/test/unterm.awk new file mode 100644 index 0000000..c420c47 --- /dev/null +++ b/test/unterm.awk @@ -0,0 +1 @@ +BEGIN{x=".........................................................................................................................................................................................................................................................} \ No newline at end of file diff --git a/test/unterm.ok b/test/unterm.ok new file mode 100644 index 0000000..760d370 --- /dev/null +++ b/test/unterm.ok @@ -0,0 +1,5 @@ +gawk: unterm.awk:1: BEGIN{x=".........................................................................................................................................................................................................................................................} +gawk: unterm.awk:1: ^ unterminated string +gawk: unterm.awk:1: BEGIN{x=".........................................................................................................................................................................................................................................................} +gawk: unterm.awk:1: ^ syntax error +EXIT CODE: 1 diff --git a/test/uparrfs.awk b/test/uparrfs.awk new file mode 100644 index 0000000..8590524 --- /dev/null +++ b/test/uparrfs.awk @@ -0,0 +1,8 @@ +BEGIN { + FS = "(^x+)|( +)" +} + +{ + for (i = 1; i <= NF; i++) + printf "-->%s<--\n", $i +} diff --git a/test/uparrfs.in b/test/uparrfs.in new file mode 100644 index 0000000..8e6b5c0 --- /dev/null +++ b/test/uparrfs.in @@ -0,0 +1 @@ +xxAA xxBxx C diff --git a/test/uparrfs.ok b/test/uparrfs.ok new file mode 100644 index 0000000..944ba9a --- /dev/null +++ b/test/uparrfs.ok @@ -0,0 +1,4 @@ +--><-- +-->AA<-- +-->xxBxx<-- +-->C<-- diff --git a/test/wideidx.awk b/test/wideidx.awk new file mode 100644 index 0000000..9c8a64c --- /dev/null +++ b/test/wideidx.awk @@ -0,0 +1,7 @@ +{ + a=$0 + print index(a,"b") + getline + a = a $0 + print index(a,"b") +} diff --git a/test/wideidx.in b/test/wideidx.in new file mode 100644 index 0000000..3bd1f0e --- /dev/null +++ b/test/wideidx.in @@ -0,0 +1,2 @@ +foo +bar diff --git a/test/wideidx.ok b/test/wideidx.ok new file mode 100644 index 0000000..4f1d7cd --- /dev/null +++ b/test/wideidx.ok @@ -0,0 +1,2 @@ +0 +4 diff --git a/test/wideidx2.awk b/test/wideidx2.awk new file mode 100644 index 0000000..335c29d --- /dev/null +++ b/test/wideidx2.awk @@ -0,0 +1,89 @@ +# Date: Thu, 27 Apr 2006 20:59:03 +0100 +# From: Lee Haywood +# Subject: gawk multi-byte support bugs, assertion bug and fix. +# To: bug-gawk@gnu.org +# Message-id: <60962be00604271259na0d8fdayb9d0c69a853216e8@mail.gmail.com> +# MIME-version: 1.0 +# Content-type: multipart/alternative; +# boundary="----=_Part_10136_920879.1146167943492" +# Status: RO +# +# ------=_Part_10136_920879.1146167943492 +# Content-Type: text/plain; charset=ISO-8859-1 +# Content-Transfer-Encoding: quoted-printable +# Content-Disposition: inline +# +# +# Firstly, I have been getting the following error from version 3.1.5. +# +# awk: node.c:515: unref: Assertion `(tmp->flags & 4096) !=3D 0' failed. +# +# In mk_number() in node.c the MBS_SUPPORT code is inside the GAWKDEBUG +# section - moving it outside explicitly clears the string values, which +# prevents the assertion error from occurring. The corrected version is +# shown at the end of this message. +# +# As an aside, I also noticed that n->wstptr is not cleared by +# set_field() and set_record() in field.c when the flags are set to +# exclude WSTRCUR. However, I do not have a test case to show if +# changing them makes any difference. +# +# A second problem also occurs when gawk 3.1.5 is compiled with +# multi-byte character support (MBS_SUPPORT). The following code should +# change the index of the substring "bc" from 2 to 3, but it gets +# reported as 2 in both cases - which is obviously disastrous. +# +# awk 'BEGIN { +# Value =3D "abc" +# +# print "Before <" Value "> ", +# index( Value, "bc" ) +# +# sub( /bc/, "bbc", Value ) +# +# print "After <" Value ">", +# index( Value, "bc" ) +# }' +# +# Compiling with MBS_SUPPORT undefined makes these problems go away. +# +# /* mk_number --- allocate a node with defined number */ +# +# NODE * +# mk_number(AWKNUM x, unsigned int flags) +# { +# register NODE *r; +# +# getnode(r); +# r->type =3D Node_val; +# r->numbr =3D x; +# r->flags =3D flags; +# #if defined MBS_SUPPORT +# r->wstptr =3D NULL; +# r->wstlen =3D 0; +# #endif /* MBS_SUPPORT */ +# #ifdef GAWKDEBUG +# r->stref =3D 1; +# r->stptr =3D NULL; +# r->stlen =3D 0; +# #if defined MBS_SUPPORT +# r->flags &=3D ~WSTRCUR; +# #endif /* MBS_SUPPORT */ +# #endif /* GAWKDEBUG */ +# return r; +# } +# +# Thanks. +# +# -- +# Lee Haywood. + +BEGIN { + Value = "abc" + + print "Before <" Value "> ", index( Value, "bc" ) + + sub( /bc/, "bbc", Value ) + + print "After <" Value ">", index( Value, "bc" ) +} diff --git a/test/wideidx2.ok b/test/wideidx2.ok new file mode 100644 index 0000000..c0206ec --- /dev/null +++ b/test/wideidx2.ok @@ -0,0 +1,2 @@ +Before 2 +After 3 diff --git a/test/widesub.awk b/test/widesub.awk new file mode 100644 index 0000000..768e715 --- /dev/null +++ b/test/widesub.awk @@ -0,0 +1,12 @@ +BEGIN { + str = "type=\"directory\" version=\"1.0\"" + #print "BEGIN:", str + + while (str) { + sub(/^[^=]*/, "", str); + s = substr(str, 2) + print s + sub(/^="[^"]*"/, "", str) + sub(/^[ \t]*/, "", str) + } +} diff --git a/test/widesub.ok b/test/widesub.ok new file mode 100644 index 0000000..54842cd --- /dev/null +++ b/test/widesub.ok @@ -0,0 +1,2 @@ +"directory" version="1.0" +"1.0" diff --git a/test/widesub2.awk b/test/widesub2.awk new file mode 100644 index 0000000..69383d3 --- /dev/null +++ b/test/widesub2.awk @@ -0,0 +1,9 @@ +BEGIN { + Value = "abc" + + print "Before <" Value "> ", index( Value, "bc" ) + + sub( /bc/, "bbc", Value ) + + print "After <" Value ">", index( Value, "bc" ) +} diff --git a/test/widesub2.ok b/test/widesub2.ok new file mode 100644 index 0000000..c0206ec --- /dev/null +++ b/test/widesub2.ok @@ -0,0 +1,2 @@ +Before 2 +After 3 diff --git a/test/widesub3.awk b/test/widesub3.awk new file mode 100644 index 0000000..48c414a --- /dev/null +++ b/test/widesub3.awk @@ -0,0 +1,6 @@ +{ + if (substr($1,1,1) == substr($0,1,1)) + print "substr matches" + sub(/foo/,"bar") + print nr++ +} diff --git a/test/widesub3.in b/test/widesub3.in new file mode 100644 index 0000000..6357df9 --- /dev/null +++ b/test/widesub3.in @@ -0,0 +1,2 @@ +test +foo diff --git a/test/widesub3.ok b/test/widesub3.ok new file mode 100644 index 0000000..7507261 --- /dev/null +++ b/test/widesub3.ok @@ -0,0 +1,4 @@ +substr matches +0 +substr matches +1 diff --git a/test/widesub4.awk b/test/widesub4.awk new file mode 100644 index 0000000..c917aac --- /dev/null +++ b/test/widesub4.awk @@ -0,0 +1,54 @@ +# Date: Sun, 28 May 2006 11:20:58 +0200 +# From: Frantisek Hanzlik +# Subject: sub() function do'nt alter string length in awk 3.1.5 +# To: bug-gawk@gnu.org +# Message-id: <44796B7A.3050908@hanzlici.cz> +# +# Hello, +# I not know when it is my mistake or gawk bug - in simple example below +# I delete some chars from string variable, and after this string is +# modified, but its length is unchanged. +# +# awk 'BEGIN{A="1234567890abcdef"; +# for (i=1;i<6;i++){print length(A),"A=" A ".";sub("....","",A)} +# }' +# 16 A=1234567890abcdef. +# 16 A=567890abcdef. +# 16 A=90abcdef. +# 16 A=cdef. +# 16 A=. +# +# When I use gensub() instead of sub(), result is as I expected: +# +# awk 'BEGIN{A="1234567890abcdef"; +# for (i=1;i<6;i++){print length(A),"A=" A ".";A=gensub("....","",1,A)} +# }' +# 16 A=1234567890abcdef. +# 12 A=567890abcdef. +# 8 A=90abcdef. +# 4 A=cdef. +# 0 A=. +# +# OS/GAWK versions: +# - GNU/Linux kernel 2.6.16-1.2122_FC5 #1 i686, Fedora Core 5 distro +# - glibc-2.4-8 +# - GNU Awk 3.1.5 +# +# Yours sincerely +# Frantisek Hanzlík +# +# == Lucní 502 Linux/Unix, Novell, Internet Tel: +420-373729699 == +# == 33209 Stenovice e-mail:franta@hanzlici.cz Fax: +420-373729699 == +# == Czech Republic http://hanzlici.cz/ GSM: +420-604117319 == +# +# +# +# ##################################################################################### +# This Mail Was Scanned by 012.net AntiVirus Service3- Powered by TrendMicro Interscan +# +BEGIN{A="1234567890abcdef"; + for (i=1;i<6;i++){print length(A),"A=" A ".";sub("....","",A)} +} +BEGIN{A="1234567890abcdef"; + for (i=1;i<6;i++){print length(A),"A=" A ".";A=gensub("....","",1,A)} +} diff --git a/test/widesub4.ok b/test/widesub4.ok new file mode 100644 index 0000000..d582543 --- /dev/null +++ b/test/widesub4.ok @@ -0,0 +1,10 @@ +16 A=1234567890abcdef. +12 A=567890abcdef. +8 A=90abcdef. +4 A=cdef. +0 A=. +16 A=1234567890abcdef. +12 A=567890abcdef. +8 A=90abcdef. +4 A=cdef. +0 A=. diff --git a/test/wjposer1.awk b/test/wjposer1.awk new file mode 100644 index 0000000..396089b --- /dev/null +++ b/test/wjposer1.awk @@ -0,0 +1,75 @@ +# From arnold@f7.net Sun Sep 5 12:30:53 2004 +# Date: Fri, 3 Sep 2004 00:54:32 -0400 (EDT) +# From: William J Poser +# To: arnold@skeeve.com +# Subject: gawk bug +# Message-ID: <20040903004347.W80049@lorax.ldc.upenn.edu> +# +# Here is a revised version of my previous message, modified to describe +# the accompanying files. +# +# IhSplit.awk should replicate every record with exactly one entry in the +# IH field, delete records lacking an IH field, and produce as many copies +# of records with two or more entries in the IH field as there are entries. +# In the latter case, the original IH field should be relabelled OIH and +# a new IH field be added at the beginning of the record. +# +# This has worked properly for many years, since at least 1997. It worked properly with gawk 3.0.5 +# and possibly later versions. Unfortunately I didn't keep track of exactly what version it +# broke on, but it was whatever came with Mandrake Linux 9.0. It continued to fail with version +# 3.1.2. However, the problem was eliminated with version 3.1.3 and remains +# eliminated in version 3.1.4. +# +# The problem was that an apparently random subset of records would loose some +# or all of their fields. Running the script on the same input always produces +# the same output with the same errors. +# +# The file Input is a subset of a real lexicon that produces errors using +# gawk 3.1.2. GoodOutput is the expected output. BadOutput is the erroneous +# output. A diff will show that there are actually two errors. One record +# has fields stripped as described above. Another is omitted in its entirety. +# +# +# Bill Poser, Linguistics, University of Pennsylvania +# http://www.ling.upenn.edu/~wjposer/ billposer@alum.mit.edu +# ---------------------------------------------------------------------------- +#For each record that contains multiple items in its inverse headword (IH) +#field, generate a set of new records each containing exactly one item +#in the inverse headword field, otherwise copies of the original. + +function CleanUp() #Clean up for next input record. +{ + for(i in rec) delete rec[i]; +} + +BEGIN { +RS = ""; +FS = "\n?%" +} +{ + +# First, create an associative array with the tags as indices. + for(i = 2; i <= NF; i++) { # The leading FS creates an initial empty field + split($i, f, ":"); + rec[f[1]]=substr($i,index($i,":")+1); + } + + if(!("IH" in rec)) next; + +# Parse out the inverse headwords + + items = split(rec["IH"],ihs,"/"); + +# Replace the old IH field. + + sub(/%IH:/,"%OIH:",$0); + +# Generate a new copy of the record for each inverse headword + + for(i = 1; i <= items; i++){ + entries+=1; + printf("%%IH:%s\n",ihs[i]); + printf("%s\n\n",$0); + } + CleanUp(); + } diff --git a/test/wjposer1.in b/test/wjposer1.in new file mode 100644 index 0000000..bdcd4a8 --- /dev/null +++ b/test/wjposer1.in @@ -0,0 +1,1527 @@ +%P:nut'i +%G:exertion +%IH:exertion +%C:N +%SF:abstractions-misc +%S:JOPA/EDFR/VESE +%ES:000088 +%UID:002463 +%MD:1999/03/15 + +%P:ts'iyantsuk t'eooninzun +%G:information +%IH:information +%C:N +%SF:abstractions-misc +%S:JOPA/BRBI +%UID:000986 +%MD:1997/12/17 + +%P:k'et'uk +%G:interval +%IH:interval +%C:N +%SF:abstractions-misc +%S:MAGO +%ES:001077 +%UID:000873 +%MD:1997/12/11 + +%P:khunek +%G:language, word, message +%IH:language/word/message +%POSS:ghunek +%P1p:neghunek +%C:N +%SF:abstractions-misc +%S:MAGO/BRBI/JOPA/EDFR/VESE/JEKO +%UID:000928 +%MD:2001/02/10 + +%P:gal +%G:running +%IH:running +%C:N +%R:Dugal ndesda. He got hurt while running. +%SF:abstractions-misc +%S:JOPA +%ES:000535 +%UID:002462 +%MD:1999/03/15 + +%P:t'en +%G:work +%IH:work +%C:N +%SF:abstractions-misc +%S:VESE/PEJO +%ES:000672 +%UID:003028 +%POCKET:N +%MD:2000/10/04 + +%P:'ut'en +%G:work +%IH:work +%C:N +%SF:abstractions-misc +%P1p:neye'ut'en +%S:JOPA +%ES:001041 +%UID:004264 +%POCKET:Y +%MD:2001/03/15 + +%P:dulkw'ah +%G:Spotted Frog +%IH:Spotted Frog/Frog, Spotted +%SN:Rana pretiosa +%MN:Lives in water and has red markings on the belly. +%PICTURE:/home/poser/Research/Dakelh/Pictures/psfiles/SpottedFrog.ps +%CAPTION:{\qc Tsasdli} --- Spotted Frog +%PICPERMISSION:N +%PICCREDIT:Drawing of Spotted Frog from {\it The Amphibians of British Columbia\/}. +%C:N +%SF:amphibiansandreptiles +%S:EDFR +%UID:004111 +%POCKET:Y +%MD:2001/03/07 + +%P:chunlai +%G:salamander, lizard +%IH:lizard/salamander +%MN:The only species of salamander found in the region is the + Long-toed Salamander {\it Ambystoma macrodactylum\/}. No lizards + are found in the region. However, this term is applied to other + varieties of salamander and to lizards, such as the gekkos sold as + pets. +%FGREF:Corkran \& Thoms (1996;39) +%SN:Ambystoma macrodactylum +%C:N +%SF:amphibiansandreptiles +%S:LITM/JOPA/BRBI +%UID:000157 +%MD:1998/05/16 + +%P:tl'ughus +%G:snake +%IH:snake +%C:N +%MN:The only snake found in the region is the Common Garter Snake + {\it Thamnophis sirtalis\/}. However, the term is applied to all snakes. +%SN:Thamnophis sirtalis +%SF:amphibiansandreptiles +%S:LITM/JOPA/BRBI/MAGO +%UID:000250 +%MD:1998/12/07 + +%P:tsasdli +%G:Western Toad +%SN:Bufo boreas +%IH:Western Toad/Toad, Western +%MN:Lives on land. +%SF:amphibiansandreptiles +%C:N +%S:LITM/JOPA/BRBI/MAGO/STJA/EDFR +%UID:000059 +%MD:2001/03/07 + +%P:lhits'e +%G:bitch, female dog +%IH:bitch/dog, female +%C:N +%SF:animals-domestic +%S:JOPA/EDFR/VESE +%UID:002446 +%MD:1999/03/15 + +%P:musdus +%G:cow +%IH:cow +%C:N +%P2s:nmusdus +%ETYM:Loan from Cree {\qf mostos} ``buffalo''. +%LOANSOURCE:Cree +%SF:animals-domestic +%S:LITM/JOPA/BRBI/MAGO +%UID:000036 +%MD:1997/06/12 + +%P:lhi +%G:dog +%IH:dog +%C:N +%DUOPLURAL:lhike +%SF:animals-domestic +%POSS:lik +%P1s:slik +%P1p:nelik +%DUOPLURAL:lhike +%S:LITM/JOPA/BRBI/STJA/VESE/EDFR/JEKO +%UID:000270 +%MD:2001/02/15 + +%P:budzocho +%G:donkey, mule +%IH:donkey/mule +%SF:animals-domestic +%ETYM:``big ears''. +%C:N +%S:JOPA/BRBI +%UID:000376 +%MD:1997/11/14 + +%P:yeztli +%G:horse +%IH:horse +%SF:animals-domestic +%ETYM:A contraction of {\qc yezihlhi} ``elk dog''. +%C:N +%S:LITM/JOPA/BRBI/PEJO +%UID:000042 +%MD:2000/10/21 + +%P:lhike +%G:Irregular plural of {\qc lhi}, q.v. +%IH:dogs +%C:N +%SF:animals-domestic +%S:LITM/BRBI/JOPA/STJA +%UID:000293 +%MD:1999/01/26 + +%P:sbaiyaz +%G:lamb +%IH:lamb +%C:N +%SF:animals-domestic +%S:LITM +%UID:000254 +%MD:1997/06/16 + +%P:gugoos +%G:pig +%IH:pig +%C:N +%ETYM:Ultimately borrowed from French {\qf coche}, probably via Cree. +%LOANSOURCE:Cree +%SF:animals-domestic +%S:LITM/JOPA/BRBI +%UID:000133 +%MD:1997/06/16 + +%P:'ut'az +%G:bat +%IH:bat +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000390 +%MD:1997/11/14 + +%P:liyabdut'ai +%G:bat +%MN:The only kind of bat found in the region is the Little Brown Myotis. +%IH:bat +%SF:animals-land +%SN:Myotis lucifugus +%ETYM:Literally, ``devil bird'', a compound of {\qc liyab} ``devil'', a loan from + French {\qf le diable}, and {\qc dut'ai} ``bird''. +%LOANSOURCE:French +%C:N +%S:JOPA/BRBI +%UID:000215 +%MD:1997/06/16 + +%P:sus +%G:black bear +%IH:black bear +%C:N +%SF:animals-land +%SN:Ursus americanus +%S:LITM/JOPA/BRBI/STJA/EDFR/VESE/JEKO +%UID:000048 +%MD:1998/12/19 + +%P:musduscho dughai +%G:buffalo +%IH:buffalo +%SF:animals-land +%C:N +%ETYM:``big hairy cow''. +%S:JOPA/EDFR +%UID:003478 +%POCKET:Y +%MD:2000/11/04 + +%P:tl'ok'umusdus +%G:buffalo +%IH:buffalo +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000374 +%MD:2000/11/01 + +%P:jenyo +%G:bull moose +%IH:bull moose/moose, bull +%SF:animals-land +%C:N +%S:MAGO/JOPA/VESE/EDFR/JEKO +%UID:000474 +%MD:1999/05/11 + +%P:denyo +%G:bull moose +%IH:moose, bull +%SF:animals-land +%C:N +%S:LITM/JOPA +%UID:000348 +%MD:1997/06/18 + +%P:tsiyeyaz +%G:calf moose +%IH:calf moose/moose, calf +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000380 +%MD:1997/11/14 + +%P:duniyaz +%G:calf moose +%IH:calf moose/moose, calf +%C:N +%SF:animals-land +%S:LITM/JOPA/BRBI +%UID:000245 +%MD:1997/06/16 + +%P:whudzih +%G:caribou +%IH:caribou +%C:N +%SF:animals-land +%SN:Rangifer tarandus +%S:JOPA/BRBI/MAGO/EDFR/VESE/JEKO +%UID:000274 +%MD:1999/05/11 + +%P:boos +%G:cat +%IH:cat +%C:N +%SN:Felis domesticus +%ETYM:Loan from English {\qf puss}, possibly via Chinook Jargon. +%LOANSOURCE:English +%SF:animals-land +%S:LITM/JOPA/BRBI +%UID:000137 +%MD:1997/12/17 + +%P:ts'uwhuljos +%G:chipmunk +%IH:chipmunk +%C:N +%SF:animals-land +%S:LITM/JOPA/BRBI +%UID:000146 +%MD:1997/06/16 + +%P:booscho +%G:cougar +%IH:cougar +%SF:animals-land +%SN:Felis concolor +%C:N +%ETYM:Literally, ``big cat'', where {\qc boos} ``cat'' is a loan from English + {\qf puss}, possibly via Chinook Jargon. +%S:JOPA/BRBI +%UID:000050 +%MD:1997/11/14 + +%P:duni'at +%G:cow moose +%IH:cow moose/moose, cow +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000377 +%MD:1997/11/14 + +%P:tintulhi +%G:coyote +%IH:coyote +%C:N +%SF:animals-land +%SN:Canis latrans +%S:JOPA/BRBI +%R:LITM has chuntulhi. +%UID:000155 +%MD:1997/06/16 + +%P:yests'e +%G:deer +%IH:deer +%SF:animals-land +%C:N +%S:LITM/JOPA/BRBI/EDFR +%UID:000132 +%MD:1998/12/16 + +%P:dets'it +%G:dry cow moose +%IH:dry cow moose/moose, dry cow +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000378 +%MD:1997/11/14 + +%P:yezih +%G:elk +%IH:elk +%SF:animals-land +%C:N +%R:STJA doesn't use this. +%S:JOPA/BRBI +%UID:000382 +%MD:1997/11/14 + +%P:tsa'at +%G:female beaver +%IH:beaver, female +%C:N +%SF:animals-land +%S:STJA +%UID:001295 +%MD:1998/12/08 + +%P:chunihcho +%G:fisher +%IH:fisher +%ETYM:``big marten''. +%SF:animals-land +%SN:Martes pennanti +%C:N +%S:JOPA/BRBI/MAGO +%UID:000385 +%MD:2000/06/18 + +%P:ts'unalhbuz +%G:flying squirrel +%IH:flying squirrel +%SF:animals-land +%SN:Glaucomys sabrinus alpinus +%PICTURE:/home/poser/Research/Dakelh/Pictures/psfiles/FlyingSquirrel.ps +%CAPTION:{\qc ts'unulhbuz} --- Flying Squirrel +%PICPERMISSION:N +%PICCREDIT:Drawing of Flying Squirrel from {\it The Mammals of British Columbia\/}. +%C:N +%S:JOPA/BRBI +%UID:000389 +%MD:1997/11/14 + +%P:nanguz +%G:fox +%IH:fox +%C:N +%SF:animals-land +%S:MAGO +%UID:000139 +%MD:2001/02/26 + +%P:shas +%G:grizzly bear +%IH:grizzly bear +%C:N +%SF:animals-land +%S:LITM/JOPA/BRBI/VESE/EDFR/JEKO +%UID:000039 +%MD:1997/06/12 + +%P:shasyaz +%G:grizzly bear cub +%IH:grizzly bear cub/cub, grizzly bear +%C:N +%SF:animals-land +%S:STJA +%UID:002114 +%MD:1999/02/20 + +%P:shas'at +%G:grizzly bear sow +%IH:grizzly bear sow/sow, grizzly bear +%C:N +%SF:animals-land +%ETYM:``grizzly bear's wife''. +%S:STJA +%UID:002113 +%MD:1999/02/20 + +%P:-lik +%G:irregular possessed stem of {\qc lhi}, q.v. +%C:N +%SF:animals-land +%S:MAGO +%UID:000564 +%MD:1997/12/11 + +%P:wasi +%G:lynx +%IH:lynx +%C:N +%SF:animals-land +%SN:Felis lynx +%ETYM:Loan from Gitksan {\qf wish}. +%LOANSOURCE:Gitksan +%S:JOPA/BRBI/STJA/EDFR/VESE/JEKO/MAGO +%UID:000049 +%MD:2001/04/20 + +%P:k'ani +%G:woodchuck +%IH:woodchuck +%C:N +%SF:animals-land +%SN:Marmota monax +%S:JOPA/BRBI/PEJO +%R:Clarified with Josie and Peter 2001/05/28. +%UID:000391 +%POCKET:Y +%MD:2001/05/28 + +%P:dutni +%G:marmot +%IH:marmot +%SF:animals-land +%C:N +%SN:Marmota caligata +%R:Josie and Peter are not really familiar with marmots but have heard older + people talk about them. +%S:JOPA/PEJO +%UID:000143 +%MD:1998/02/10 + +%P:chunih +%G:marten +%IH:marten +%SF:animals-land +%SN:Martes americana +%C:N +%S:JOPA/BRBI/VESE/EDFR/JEKO/MAGO +%UID:000016 +%MD:2001/04/20 + +%P:telhjoos +%G:mink +%IH:mink +%C:N +%SF:animals-land +%SN:Mustela vison +%S:LITM/JOPA/BRBI +%UID:000167 +%MD:1997/06/16 + +%P:duni +%G:moose +%IH:moose +%C:N +%SF:animals-land +%SN:Alces alces andersoni +%S:LITM-EDFR/JOPA/BRBI +%UID:000346 +%MD:1997/06/18 + +%P:dats'ooz +%G:mouse +%IH:mouse +%SF:animals-land +%C:N +%S:LITM/JOPA/MAGO/VESE/JEKO +%UID:000156 +%MD:2001/01/22 + +%P:tsek'et +%G:muskrat +%IH:muskrat +%C:N +%SF:animals-land +%SN:Ondatra zibethicus +%S:JOPA/BRBI/STJA/MAGO +%UID:000335 +%MD:1998/12/08 + +%P:chanjo +%G:newly sexually mature cow moose +%IH:moose, newly sexually mature cow +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000379 +%MD:1997/11/14 + +%P:looncho +%G:pack rat +%IH:pack rat +%C:N +%SF:animals-land +%S:VESE/JEKO/MAGO +%UID:000149 +%MD:1999/05/10 + +%P:dlooncho +%G:packrat +%IH:packrat +%C:N +%SF:animals-land +%S:JOPA +%UID:002701 +%MD:1999/05/11 + +%P:duneza +%G:porcupine +%IH:porcupine +%SF:animals-land +%C:N +%S:JOPA/BRBI/MAGO +%UID:000388 +%MD:2001/03/06 + +%P:ts'it +%G:porcupine +%IH:porcupine +%SF:animals-land +%SN:Erethizon dorsatum +%C:N +%ETYM:Perhaps derived from the interjection {\qc ts'it} ``don't touch it!''. +%S:JOPA/BRBI/MAGO/BEMC/STJA +%UID:000387 +%MD:1998/12/08 + +%P:lhiyaz +%G:puppy +%IH:puppy +%C:N +%SF:animals-land +%DUOPLURAL:lhiyazke +%DUOPLURAL:lhikeyaz +%R:Josie prefers {\qc lhikeyaz}. +%S:LITM/BRBI/JOPA/EDFR/MAGO-JEKO +%UID:000182 +%MD:2001/05/26 + +%P:nats'ildelh +%G:Red Squirrel +%IH:squirrel/Red Squirrel +%SN:Tamiasciurus hudsonicus colum. +%C:N +%SF:animals-land +%S:LITM/JOPA/BRBI/STJA +%UID:000034 +%MD:1999/02/17 + +%P:goh +%G:rabbit +%IH:rabbit +%C:N +%SF:animals-land +%S:LITM/JOPA/VESE/EDFR/JEKO +%UID:000023 +%MD:1999/05/11 + +%P:ooch'ainischoot +%G:recently weaned calf moose +%IH:moose, recently weaned calf +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000381 +%MD:1997/11/14 + +%P:sbai +%G:sheep +%IH:sheep +%C:N +%SF:animals-land +%S:MAGO +%UID:001131 +%MD:1998/02/10 + +%P:'usbai +%G:sheep +%IH:sheep +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000375 +%MD:1997/11/14 + +%P:'ulhguk +%G:shrew +%IH:shrew +%SF:animals-land +%C:N +%S:MAGO/VESE/JEKO +%UID:000526 +%MD:2001/01/22 + +%P:hoonliz +%G:skunk +%IH:skunk +%C:N +%P2s:unhoonliz +%SF:animals-land +%S:LITM/JOPA/BRBI/MAGO/VESE/EDFR/JEKO +%UID:000052 +%MD:1997/06/12 + +%P:nohbai +%G:weasel +%IH:weasel +%C:N +%SF:animals-land +%S:JOPA/BRBI/MAGO +%UID:000141 +%MD:1997/06/16 + +%P:yus +%G:wolf +%IH:wolf +%C:N +%SF:animals-land +%SN:Canis lupus +%S:LITM/JOPA/BRBI +%UID:000051 +%MD:1997/06/12 + +%P:noostel +%G:wolverine +%IH:wolverine +%C:N +%SF:animals-land +%SN:Gulo gulo +%S:JOPA/BRBI/MAGO/VESE/EDFR/JEKO +%UID:000140 +%MD:2001/04/20 + +%P:tsatsul +%G:young beaver +%IH:beaver, young +%SF:animals-land +%C:N +%S:JOPA/BRBI/STJA +%UID:000384 +%MD:1998/12/08 + +%P:lht'at +%G:beaver dam +%IH:beaver dam/dam, beaver +%C:N +%SF:animals-misc +%S:STJA +%UID:001287 +%MD:1998/12/08 + +%P:'ulh +%G:beaver dam +%IH:beaver dam/dam, beaver +%C:N +%SF:animals-misc +%S:STJA +%UID:001288 +%MD:1998/12/08 + +%P:tsaken +%G:beaver lodge +%IH:beaver lodge +%C:N +%SF:animals-misc +%S:JOPA/BRBI/STJA +%UID:000405 +%MD:1998/12/08 + +%P:tunyohtsati +%G:beaver path under the ice +%IH:beaver path under the ice +%C:N +%SF:animals-misc +%S:JOPA/EDFR +%UID:003769 +%POCKET:Y +%MD:2001/02/13 + +%P:sus'an +%G:black bear den +%IH:black bear den +%C:N +%SF:animals-misc +%S:LITM/STJA +%UID:000131 +%MD:1998/12/08 + +%P:shask'oh +%G:grizzly bear tracks +%IH:tracks, grizzly bear +%C:N +%SF:animals-misc +%S:MAGO +%UID:001132 +%MD:1998/02/10 + +%P:hoolht'ukw +%G:leech +%IH:leech +%SF:animals-misc +%C:N +%S:JOPA/PEJO/EDFR +%UID:003410 +%POCKET:Y +%MD:2000/11/01 + +%P:hoot'ub +%G:leech +%IH:leech +%SF:bugs +%C:N +%S:JOPA/BRBI/MAGO +%UID:000370 +%MD:2000/11/01 + +%P:dunik'oh +%G:moose tracks +%IH:moose tracks +%C:N +%SF:animals-misc +%S:PEJO/JOPA +%ES:000491 +%UID:003121 +%POCKET:Y +%MD:2000/09/28 + +%P:gohk'oh +%G:rabbit tracks +%IH:tracks, rabbit +%C:N +%SF:animals-misc +%S:LITM +%UID:000073 +%MD:1997/06/12 + +%P:tsa +%G:beaver +%IH:beaver +%C:N +%SN:Castor canadensis +%UID:000044 +%SF:animals-water +%S:JOPA/BRBI/STJA/EDFR/VESE/JEKO/MAGO +%MD:2001/04/18 + +%P:tsayaz +%G:beaver kit +%IH:kit, beaver/beaver, baby +%SF:animals-water +%C:N +%S:STJA +%UID:001294 +%MD:2000/06/18 + +%P:tsati +%G:big beaver, old beaver +%IH:beaver, big/beaver, old +%C:N +%SF:animals-water +%S:LITM/JOPA/BRBI/STJA +%UID:000206 +%MD:1998/12/08 + +%P:tsis +%G:otter +%IH:otter +%SF:animals-water +%SN:Lutra canadensis +%C:N +%S:JOPA/BRBI +%UID:000386 +%MD:1997/11/14 + +%P:datsan +%G:American Crow +%C:N +%SF:bird-gen +%SN:Corvus brachyrhynchos +%IH:crow/American Crow +%S:LITM/PEJO +%UID:000158 +%MD:2000/10/21 + +%P:sewh +%G:American Robin +%IH:Robin, American +%SN:Turdus migratorius +%C:N +%SF:bird-gen +%S:LITM/JOPA/BRBI/PEJO +%UID:000181 +%MD:2000/10/21 + +%P:tsebalyan +%G:Bald Eagle +%IH:Bald Eagle +%C:N +%SF:bird-gen +%SN:Haliaeetus leucocephalus +%S:LITM/JOPA/BRBI +%UID:000150 +%MD:1997/06/16 + +%P:dut'ai +%G:bird, duck +%IH:bird/duck +%C:N +%SF:bird-gen +%S:LITM/JOPA/BRBI/MAGO/STJA/PEJO +%UID:000081 +%MD:2000/09/28 + +%P:delh +%G:crane +%IH:crane +%C:N +%SF:bird-gen +%S:LITM +%UID:000255 +%MD:1997/06/16 + +%P:khoh +%G:goose +%IH:goose +%C:N +%P1s:skhoh +%P2s:nkhoh +%P1p:nekhoh +%POSS:khoh +%SF:bird-gen +%S:JOPA/BRBI/MAGO/VESE/EDFR/JEKO +%UID:000031 +%MD:2001/02/15 + +%P:ts'unalhduz +%G:hummingbird +%IH:hummingbird +%C:N +%SF:bird-gen +%S:LITM/BRBI/JOPA +%UID:000242 +%MD:1997/06/16 + +%P:gagiyaz +%G:little bird +%IH:bird, little +%C:N +%QCHECK:Any little bird? +%SF:bird-gen +%S:PEJO +%UID:003115 +%POCKET:Y +%MD:2000/09/28 + +%P:dut'aiyaz +%G:little bird +%IH:bird, little +%C:N +%SF:bird-gen +%S:STJA/JOPA/EDFR/VESE/PEJO +%UID:001818 +%MD:2000/09/28 + +%P:dadzi +%G:loon +%IH:loon +%SF:bird-gen +%SN:Gavia immer +%C:N +%S:LITM/JOPA/BRBI +%UID:000020 +%MD:1997/06/12 + +%P:t'ugicho +%G:Mallard Duck +%IH:Mallard Duck +%C:N +%SN:Anas platyrhynchos +%SF:bird-gen +%S:LITM/JOPA/BRBI/MAGO/VESE/EDFR/JEKO +%UID:000041 +%MD:1999/05/11 + +%P:musdzoon +%G:owl +%IH:owl +%C:N +%SF:bird-gen +%S:LITM/BRBI/JOPA/MAGO +%UID:000135 +%MD:1997/12/11 + +%P:ts'olh +%G:Red-necked Grebe +%MN:A variety of duck locally known as the Helldiver. +%IH:Red-Necked Grebe/Helldiver/Grebe, Red-Necked +%SN:Podiceps grisegena +%SF:bird-gen +%C:N +%S:BRBI/JOPA +%UID:000263 +%MD:2001/03/08 + +%P:'utsut +%G:Ruffed grouse +%IH:Ruffed grouse +%C:N +%SF:bird-gen +%S:LITM +%UID:000218 +%MD:1997/06/16 + +%P:nat'oh +%G:Spruce Grouse, Fool Hen +%IH:Spruce Grouse/Grouse, Spruce/Fool Hen +%SF:bird-gen +%SN:Dendragapus canadensis +%C:N +%S:MAGO/LITM +%UID:000539 +%MD:1997/12/04 + +%P:tehgwuzeh +%G:Steller's Jay, commonly known locally as ``bluejay''. +%IH:Steller's Jay/jay, Steller's/Bluejay (Steller's Jay) +%SF:bird-gen +%SN:Cyanocitta stelleri +%C:N +%S:JOPA/BRBI +%UID:000356 +%MD:1997/11/14 + +%P:wedlew +%G:sandpiper +%IH:sandpiper +%C:N +%SN:Eremophila alpestris et sim. +%SF:bird-gen +%S:LITM +%UID:000237 +%MD:2002/07/19 + +%P:besk'i +%G:seagull +%IH:seagull +%C:N +%SN:Larus species +%SF:bird-gen +%S:LITM +%UID:000136 +%MD:2002/07/19 + +%P:ts'incho +%G:swan +%IH:swan +%C:N +%SF:bird-gen +%S:LITM +%UID:000222 +%MD:1997/06/16 + +%P:'uschas +%G:Tree Swallow +%IH:Tree Swallow +%SF:bird-gen +%SN:Tachycineta bicolor +%C:N +%S:MAGO +%UID:000535 +%MD:1997/11/22 + +%P:gwuzeh +%G:Whiskey Jack, Gray Jay, Canadian Jay +%IH:Whiskey Jack/Jay, Gray/Jay, Canadian +%C:N +%SN:Perisoreus canadensis +%SF:bird-gen +%S:LITM/JOPA/BRBI/MAGO +%UID:000148 +%MD:1997/11/22 + +%P:chundulkw'uz +%G:woodpecker +%IH:woodpecker +%C:N +%SF:bird-gen +%S:JOPA/BRBI/STJA +%UID:000138 +%MD:1999/03/31 + +%P:-t'o +%G:nest +%IH:nest +%C:N +%Pind:'ut'o +%P3s:but'o +%Pref:dut'o +%SF:bird-misc/bugs +%S:STJA/PEJO/JOPA/BRBI/EDFR +%ES:001353 +%UID:000226 +%MD:2001/03/07 + +%P:-nak'uz +%G:a single eye +%IH:eye, a single +%C:N +%SF:body-ext +%S:JOPA/EDFR +%ES:000457 +%UID:003770 +%POCKET:Y +%MD:2001/02/13 + +%P:-kechunoh +%G:ankle +%IH:ankle +%P1s:skechunoh +%P2s:nkechunoh +%C:N +%S:MAGO/STJA +%SF:body-ext +%UID:000865 +%MD:1999/03/03 + +%P:-de +%G:antler, horn +%IH:antler/horn +%C:N +%SF:body-ext +%P3s:bude +%S:STJA +%UID:002266 +%MD:1999/03/02 + +%P:-de_zu_s +%G:antler velvet +%IH:velvet, antler +%C:N +%SF:body-ext +%P3s:bude_zu_s +%S:STJA +%UID:002267 +%MD:1999/03/02 + +%P:-tsul +%G:anus, asshole +%IH:anus/asshole +%C:N +%P1s:stsul +%SF:body-ext +%S:STJA +%UID:002171 +%MD:1999/02/23 + +%P:-gan +%G:arm +%IH:arm +%P1s:sgan +%P2s:ngan +%Pref:dugan +%C:N +%S:LITM/MAGO/STJA/JOPA/VESE/EDFR/JEKO +%SF:body-ext +%UID:000863 +%MD:1999/02/22 + +%P:-chak'ests'oh +%G:armpit +%IH:armpit +%P1s:schak'ests'oh +%C:N +%S:MAGO +%UID:000859 +%SF:body-ext +%MD:1997/12/11 + +%P:-t'ak +%G:back (of body) +%IH:back (of body) +%P1s:st'ak +%P3s:but'ak +%C:N +%S:MAGO/EDFR/VESE/JEKO +%SF:body-ext +%UID:000899 +%MD:1997/12/11 + +%P:-lat'ak +%G:back of hand +%IH:back of hand +%P1s:slat'ak +%C:N +%S:MAGO +%SF:body-ext +%UID:000871 +%MD:1997/12/11 + +%P:tsake +%G:beaver paws +%IH:beaver paws +%C:N +%SF:body-ext +%S:LITM-EDFR +%UID:000329 +%MD:1997/06/18 + +%P:tsache +%G:beaver tail +%IH:beaver tail +%C:N +%SF:body-ext +%S:LITM +%UID:000207 +%MD:1997/06/16 + +%P:-but +%G:belly +%IH:belly +%P1s:sbut +%C:N +%S:MAGO +%SF:body-ext +%UID:000937 +%MD:1997/12/11 + +%P:-ts'oo +%G:breast +%IH:breast +%P1s:sts'oo +%C:N +%S:MAGO +%UID:000855 +%SF:body-ext +%MD:1997/12/11 + +%P:-tl'a +%G:bum, buttocks +%IH:bum/buttocks +%P1s:stl'a +%C:N +%S:MAGO +%SF:body-ext +%UID:000936 +%MD:1997/12/11 + +%P:-kechunch'ooz +%G:calf of leg +%IH:calf of leg +%C:N +%SF:body-ext +%S:JOPA/EDFR +%UID:004458 +%POCKET:Y +%MD:2001/04/20 + +%P:-nembus +%G:cheek +%IH:cheek +%P1s:snimbus +%C:N +%S:MAGO/JOPA/BRBI +%SF:body-ext +%UID:000889 +%MD:1997/12/11 + +%P:-yoh +%G:chest +%IH:chest +%C:N +%SF:body-ext +%S:JOPA/EDFR +%ES:000660 +%UID:003777 +%POCKET:Y +%MD:2001/02/13 + +%P:-yeda' +%G:chin +%IH:chin +%P1s:syeda' +%C:N +%S:MAGO +%SF:body-ext +%UID:000882 +%MD:1997/12/11 + +%P:-tsidakwhudutle +%G:cranial fontanelle, baby's soft spot +%IH:cranial fontanelle/baby's soft spot +%C:N +%P3s:butsidakwhudutle +%S:MAGO +%SF:body-ext +%UID:000898 +%MD:1997/12/11 + +%P:-dzo +%G:ear +%IH:ear +%MN:This refers to the ear considered as a whole, especially the exterior. + When the canal in particular is referred to, one uses {\qc -dzek}, q.v. +%C:N +%P1s:sdzo +%S:MAGO +%SF:body-ext +%UID:000879 +%MD:1997/12/11 + +%P:-dzobal +%G:earlobe +%IH:earlobe +%C:N +%P1s:sdzobal +%SF:body-ext +%S:BRBI/MAGO +%UID:000641 +%MD:1997/12/17 + +%P:-nints'uzti +%G:elbow +%IH:elbow +%P1s:snints'uzti +%C:N +%S:MAGO +%SF:body-ext +%UID:000916 +%MD:1997/12/11 + +%P:-na +%G:eye +%IH:eye +%P1s:sna +%P3s:buna +%C:N +%S:MAGO/JOPA/EDFR +%SF:body-ext +%UID:000891 +%MD:1998/12/18 + +%P:-nak'et +%G:eye socket +%IH:eye socket +%P1s:snak'et +%C:N +%S:MAGO +%SF:body-ext +%UID:000892 +%MD:1997/12/11 + +%P:-nach'usdooz +%G:eyebrow +%IH:eyebrow +%P1s:snach'usdooz +%C:N +%S:MAGO +%SF:body-ext +%UID:000896 +%MD:1997/12/11 + +%P:-nalusgha +%G:eyelash +%IH:eyelash +%P1s:snalusgha +%C:N +%S:MAGO +%SF:body-ext +%UID:000895 +%MD:1997/12/11 + +%P:-nalus +%G:eyelid +%IH:eyelid +%P1s:snalus +%C:N +%S:MAGO +%SF:body-ext +%UID:000894 +%MD:1997/12/11 + +%P:-nen +%G:face +%IH:face +%P1s:snen +%P2s:nyunen +%P3s:bunen +%C:N +%S:MAGO/PEJO/STJA/JOPA/VESE/EDFR +%SF:body-ext +%ES:000369 +%UID:000890 +%MD:2001/04/20 + +%P:ts'uz +%G:feather, down +%IH:feather/down +%C:N +%SF:body-ext +%S:LITM/STJA/PEJO +%UID:000271 +%MD:2000/10/16 + +%P:dut'aits'uz +%G:feathers, down +%IH:feathers/down +%C:N +%SF:body-ext +%S:STJA +%UID:002647 +%MD:2001/02/27 + +%P:-lasge +%G:finger other than thumb or pinkie +%IH:finger other than thumb or pinkie +%P1s:slasge +%C:N +%S:MAGO/STJA/JOPA/PEJO/EDFR +%SF:body-ext +%UID:000869 +%MD:2000/11/01 + +%P:-lagui +%G:fingernails, claws of forepaws +%IH:fingernails/claws of forepaws +%P1s:slagui +%C:N +%S:MAGO +%SF:body-ext +%UID:000875 +%MD:1997/12/11 + +%P:-ke +%G:foot +%IH:foot +%C:N +%P1s:ske +%Pref:duke +%S:MAGO/STJA/JOPA/VESE/EDFR/JEKO +%UID:000851 +%SF:body-ext +%MD:1999/05/11 + +%P:-gha +%G:hair +%MN:This refers to hair in general and where no more specific term exists, as on the + arms and chest. It is not used to refer to the hair of the head, for which the + more specific term {\qc -tsigha} is always used. +%IH:hair +%C:N +%S:MAGO +%SF:body-ext +%UID:000888 +%MD:1997/12/11 + +%P:-tsigha +%G:hair of the head +%IH:hair of the head +%P1s:stsigha +%P2s:ntsigha +%P3s:butsigha +%C:N +%S:MAGO/LITM/PEJO +%SF:body-ext +%UID:000887 +%MD:2000/10/20 + +%P:-la +%G:hand +%IH:hand +%P1s:sla +%P2s:nla +%C:N +%S:MAGO/STJA +%SF:body-ext +%POCKET:Y +%UID:000866 +%MD:1999/02/17 + +%P:-tsi +%G:head +%IH:head +%Pref:dutsi +%C:N +%SF:body-ext +%S:STJA +%UID:002965 +%POCKET:Y +%MD:1999/06/24 + +%P:-kelatsul +%G:heel +%IH:heel +%P1s:skelatsul +%C:N +%S:MAGO +%SF:body-ext +%UID:000917 +%MD:1997/12/11 + +%P:-k'ui +%G:hip +%IH:hip +%P1s:sk'ui +%C:N +%S:MAGO/JOPA +%SF:body-ext +%UID:000923 +%MD:2001/03/15 + +%P:-gwut +%G:knee +%IH:knee +%P1s:sgwut +%C:N +%S:MAGO +%SF:body-ext +%UID:000933 +%MD:1997/12/11 + +%P:-gwutlasi'ai +%G:kneecap +%IH:kneecap +%P1s:sgwutlasi'ai +%R:has something to do with floating at tip of knee +%C:N +%S:MAGO +%SF:body-ext +%UID:000925 +%MD:1997/12/11 + +%P:-langwut +%G:knuckles at boundary between hand and fingers +%IH:knuckles at boundary between hand and fingers +%P1s:slangwut +%SF:body-ext +%C:N +%S:JOPA/BRBI +%UID:000967 +%MD:1997/12/17 + +%P:-kechun +%G:leg +%IH:leg +%P1s:skechun +%C:N +%S:MAGO +%UID:000852 +%SF:body-ext +%MD:1997/12/11 diff --git a/test/wjposer1.ok b/test/wjposer1.ok new file mode 100644 index 0000000..16cde6a --- /dev/null +++ b/test/wjposer1.ok @@ -0,0 +1,2068 @@ +%IH:exertion +%P:nut'i +%G:exertion +%OIH:exertion +%C:N +%SF:abstractions-misc +%S:JOPA/EDFR/VESE +%ES:000088 +%UID:002463 +%MD:1999/03/15 + +%IH:information +%P:ts'iyantsuk t'eooninzun +%G:information +%OIH:information +%C:N +%SF:abstractions-misc +%S:JOPA/BRBI +%UID:000986 +%MD:1997/12/17 + +%IH:interval +%P:k'et'uk +%G:interval +%OIH:interval +%C:N +%SF:abstractions-misc +%S:MAGO +%ES:001077 +%UID:000873 +%MD:1997/12/11 + +%IH:language +%P:khunek +%G:language, word, message +%OIH:language/word/message +%POSS:ghunek +%P1p:neghunek +%C:N +%SF:abstractions-misc +%S:MAGO/BRBI/JOPA/EDFR/VESE/JEKO +%UID:000928 +%MD:2001/02/10 + +%IH:word +%P:khunek +%G:language, word, message +%OIH:language/word/message +%POSS:ghunek +%P1p:neghunek +%C:N +%SF:abstractions-misc +%S:MAGO/BRBI/JOPA/EDFR/VESE/JEKO +%UID:000928 +%MD:2001/02/10 + +%IH:message +%P:khunek +%G:language, word, message +%OIH:language/word/message +%POSS:ghunek +%P1p:neghunek +%C:N +%SF:abstractions-misc +%S:MAGO/BRBI/JOPA/EDFR/VESE/JEKO +%UID:000928 +%MD:2001/02/10 + +%IH:running +%P:gal +%G:running +%OIH:running +%C:N +%R:Dugal ndesda. He got hurt while running. +%SF:abstractions-misc +%S:JOPA +%ES:000535 +%UID:002462 +%MD:1999/03/15 + +%IH:work +%P:t'en +%G:work +%OIH:work +%C:N +%SF:abstractions-misc +%S:VESE/PEJO +%ES:000672 +%UID:003028 +%POCKET:N +%MD:2000/10/04 + +%IH:work +%P:'ut'en +%G:work +%OIH:work +%C:N +%SF:abstractions-misc +%P1p:neye'ut'en +%S:JOPA +%ES:001041 +%UID:004264 +%POCKET:Y +%MD:2001/03/15 + +%IH:Spotted Frog +%P:dulkw'ah +%G:Spotted Frog +%OIH:Spotted Frog/Frog, Spotted +%SN:Rana pretiosa +%MN:Lives in water and has red markings on the belly. +%PICTURE:/home/poser/Research/Dakelh/Pictures/psfiles/SpottedFrog.ps +%CAPTION:{\qc Tsasdli} --- Spotted Frog +%PICPERMISSION:N +%PICCREDIT:Drawing of Spotted Frog from {\it The Amphibians of British Columbia\/}. +%C:N +%SF:amphibiansandreptiles +%S:EDFR +%UID:004111 +%POCKET:Y +%MD:2001/03/07 + +%IH:Frog, Spotted +%P:dulkw'ah +%G:Spotted Frog +%OIH:Spotted Frog/Frog, Spotted +%SN:Rana pretiosa +%MN:Lives in water and has red markings on the belly. +%PICTURE:/home/poser/Research/Dakelh/Pictures/psfiles/SpottedFrog.ps +%CAPTION:{\qc Tsasdli} --- Spotted Frog +%PICPERMISSION:N +%PICCREDIT:Drawing of Spotted Frog from {\it The Amphibians of British Columbia\/}. +%C:N +%SF:amphibiansandreptiles +%S:EDFR +%UID:004111 +%POCKET:Y +%MD:2001/03/07 + +%IH:lizard +%P:chunlai +%G:salamander, lizard +%OIH:lizard/salamander +%MN:The only species of salamander found in the region is the + Long-toed Salamander {\it Ambystoma macrodactylum\/}. No lizards + are found in the region. However, this term is applied to other + varieties of salamander and to lizards, such as the gekkos sold as + pets. +%FGREF:Corkran \& Thoms (1996;39) +%SN:Ambystoma macrodactylum +%C:N +%SF:amphibiansandreptiles +%S:LITM/JOPA/BRBI +%UID:000157 +%MD:1998/05/16 + +%IH:salamander +%P:chunlai +%G:salamander, lizard +%OIH:lizard/salamander +%MN:The only species of salamander found in the region is the + Long-toed Salamander {\it Ambystoma macrodactylum\/}. No lizards + are found in the region. However, this term is applied to other + varieties of salamander and to lizards, such as the gekkos sold as + pets. +%FGREF:Corkran \& Thoms (1996;39) +%SN:Ambystoma macrodactylum +%C:N +%SF:amphibiansandreptiles +%S:LITM/JOPA/BRBI +%UID:000157 +%MD:1998/05/16 + +%IH:snake +%P:tl'ughus +%G:snake +%OIH:snake +%C:N +%MN:The only snake found in the region is the Common Garter Snake + {\it Thamnophis sirtalis\/}. However, the term is applied to all snakes. +%SN:Thamnophis sirtalis +%SF:amphibiansandreptiles +%S:LITM/JOPA/BRBI/MAGO +%UID:000250 +%MD:1998/12/07 + +%IH:Western Toad +%P:tsasdli +%G:Western Toad +%SN:Bufo boreas +%OIH:Western Toad/Toad, Western +%MN:Lives on land. +%SF:amphibiansandreptiles +%C:N +%S:LITM/JOPA/BRBI/MAGO/STJA/EDFR +%UID:000059 +%MD:2001/03/07 + +%IH:Toad, Western +%P:tsasdli +%G:Western Toad +%SN:Bufo boreas +%OIH:Western Toad/Toad, Western +%MN:Lives on land. +%SF:amphibiansandreptiles +%C:N +%S:LITM/JOPA/BRBI/MAGO/STJA/EDFR +%UID:000059 +%MD:2001/03/07 + +%IH:bitch +%P:lhits'e +%G:bitch, female dog +%OIH:bitch/dog, female +%C:N +%SF:animals-domestic +%S:JOPA/EDFR/VESE +%UID:002446 +%MD:1999/03/15 + +%IH:dog, female +%P:lhits'e +%G:bitch, female dog +%OIH:bitch/dog, female +%C:N +%SF:animals-domestic +%S:JOPA/EDFR/VESE +%UID:002446 +%MD:1999/03/15 + +%IH:cow +%P:musdus +%G:cow +%OIH:cow +%C:N +%P2s:nmusdus +%ETYM:Loan from Cree {\qf mostos} ``buffalo''. +%LOANSOURCE:Cree +%SF:animals-domestic +%S:LITM/JOPA/BRBI/MAGO +%UID:000036 +%MD:1997/06/12 + +%IH:dog +%P:lhi +%G:dog +%OIH:dog +%C:N +%DUOPLURAL:lhike +%SF:animals-domestic +%POSS:lik +%P1s:slik +%P1p:nelik +%DUOPLURAL:lhike +%S:LITM/JOPA/BRBI/STJA/VESE/EDFR/JEKO +%UID:000270 +%MD:2001/02/15 + +%IH:donkey +%P:budzocho +%G:donkey, mule +%OIH:donkey/mule +%SF:animals-domestic +%ETYM:``big ears''. +%C:N +%S:JOPA/BRBI +%UID:000376 +%MD:1997/11/14 + +%IH:mule +%P:budzocho +%G:donkey, mule +%OIH:donkey/mule +%SF:animals-domestic +%ETYM:``big ears''. +%C:N +%S:JOPA/BRBI +%UID:000376 +%MD:1997/11/14 + +%IH:horse +%P:yeztli +%G:horse +%OIH:horse +%SF:animals-domestic +%ETYM:A contraction of {\qc yezihlhi} ``elk dog''. +%C:N +%S:LITM/JOPA/BRBI/PEJO +%UID:000042 +%MD:2000/10/21 + +%IH:dogs +%P:lhike +%G:Irregular plural of {\qc lhi}, q.v. +%OIH:dogs +%C:N +%SF:animals-domestic +%S:LITM/BRBI/JOPA/STJA +%UID:000293 +%MD:1999/01/26 + +%IH:lamb +%P:sbaiyaz +%G:lamb +%OIH:lamb +%C:N +%SF:animals-domestic +%S:LITM +%UID:000254 +%MD:1997/06/16 + +%IH:pig +%P:gugoos +%G:pig +%OIH:pig +%C:N +%ETYM:Ultimately borrowed from French {\qf coche}, probably via Cree. +%LOANSOURCE:Cree +%SF:animals-domestic +%S:LITM/JOPA/BRBI +%UID:000133 +%MD:1997/06/16 + +%IH:bat +%P:'ut'az +%G:bat +%OIH:bat +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000390 +%MD:1997/11/14 + +%IH:bat +%P:liyabdut'ai +%G:bat +%MN:The only kind of bat found in the region is the Little Brown Myotis. +%OIH:bat +%SF:animals-land +%SN:Myotis lucifugus +%ETYM:Literally, ``devil bird'', a compound of {\qc liyab} ``devil'', a loan from + French {\qf le diable}, and {\qc dut'ai} ``bird''. +%LOANSOURCE:French +%C:N +%S:JOPA/BRBI +%UID:000215 +%MD:1997/06/16 + +%IH:black bear +%P:sus +%G:black bear +%OIH:black bear +%C:N +%SF:animals-land +%SN:Ursus americanus +%S:LITM/JOPA/BRBI/STJA/EDFR/VESE/JEKO +%UID:000048 +%MD:1998/12/19 + +%IH:buffalo +%P:musduscho dughai +%G:buffalo +%OIH:buffalo +%SF:animals-land +%C:N +%ETYM:``big hairy cow''. +%S:JOPA/EDFR +%UID:003478 +%POCKET:Y +%MD:2000/11/04 + +%IH:buffalo +%P:tl'ok'umusdus +%G:buffalo +%OIH:buffalo +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000374 +%MD:2000/11/01 + +%IH:bull moose +%P:jenyo +%G:bull moose +%OIH:bull moose/moose, bull +%SF:animals-land +%C:N +%S:MAGO/JOPA/VESE/EDFR/JEKO +%UID:000474 +%MD:1999/05/11 + +%IH:moose, bull +%P:jenyo +%G:bull moose +%OIH:bull moose/moose, bull +%SF:animals-land +%C:N +%S:MAGO/JOPA/VESE/EDFR/JEKO +%UID:000474 +%MD:1999/05/11 + +%IH:moose, bull +%P:denyo +%G:bull moose +%OIH:moose, bull +%SF:animals-land +%C:N +%S:LITM/JOPA +%UID:000348 +%MD:1997/06/18 + +%IH:calf moose +%P:tsiyeyaz +%G:calf moose +%OIH:calf moose/moose, calf +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000380 +%MD:1997/11/14 + +%IH:moose, calf +%P:tsiyeyaz +%G:calf moose +%OIH:calf moose/moose, calf +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000380 +%MD:1997/11/14 + +%IH:calf moose +%P:duniyaz +%G:calf moose +%OIH:calf moose/moose, calf +%C:N +%SF:animals-land +%S:LITM/JOPA/BRBI +%UID:000245 +%MD:1997/06/16 + +%IH:moose, calf +%P:duniyaz +%G:calf moose +%OIH:calf moose/moose, calf +%C:N +%SF:animals-land +%S:LITM/JOPA/BRBI +%UID:000245 +%MD:1997/06/16 + +%IH:caribou +%P:whudzih +%G:caribou +%OIH:caribou +%C:N +%SF:animals-land +%SN:Rangifer tarandus +%S:JOPA/BRBI/MAGO/EDFR/VESE/JEKO +%UID:000274 +%MD:1999/05/11 + +%IH:cat +%P:boos +%G:cat +%OIH:cat +%C:N +%SN:Felis domesticus +%ETYM:Loan from English {\qf puss}, possibly via Chinook Jargon. +%LOANSOURCE:English +%SF:animals-land +%S:LITM/JOPA/BRBI +%UID:000137 +%MD:1997/12/17 + +%IH:chipmunk +%P:ts'uwhuljos +%G:chipmunk +%OIH:chipmunk +%C:N +%SF:animals-land +%S:LITM/JOPA/BRBI +%UID:000146 +%MD:1997/06/16 + +%IH:cougar +%P:booscho +%G:cougar +%OIH:cougar +%SF:animals-land +%SN:Felis concolor +%C:N +%ETYM:Literally, ``big cat'', where {\qc boos} ``cat'' is a loan from English + {\qf puss}, possibly via Chinook Jargon. +%S:JOPA/BRBI +%UID:000050 +%MD:1997/11/14 + +%IH:cow moose +%P:duni'at +%G:cow moose +%OIH:cow moose/moose, cow +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000377 +%MD:1997/11/14 + +%IH:moose, cow +%P:duni'at +%G:cow moose +%OIH:cow moose/moose, cow +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000377 +%MD:1997/11/14 + +%IH:coyote +%P:tintulhi +%G:coyote +%OIH:coyote +%C:N +%SF:animals-land +%SN:Canis latrans +%S:JOPA/BRBI +%R:LITM has chuntulhi. +%UID:000155 +%MD:1997/06/16 + +%IH:deer +%P:yests'e +%G:deer +%OIH:deer +%SF:animals-land +%C:N +%S:LITM/JOPA/BRBI/EDFR +%UID:000132 +%MD:1998/12/16 + +%IH:dry cow moose +%P:dets'it +%G:dry cow moose +%OIH:dry cow moose/moose, dry cow +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000378 +%MD:1997/11/14 + +%IH:moose, dry cow +%P:dets'it +%G:dry cow moose +%OIH:dry cow moose/moose, dry cow +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000378 +%MD:1997/11/14 + +%IH:elk +%P:yezih +%G:elk +%OIH:elk +%SF:animals-land +%C:N +%R:STJA doesn't use this. +%S:JOPA/BRBI +%UID:000382 +%MD:1997/11/14 + +%IH:beaver, female +%P:tsa'at +%G:female beaver +%OIH:beaver, female +%C:N +%SF:animals-land +%S:STJA +%UID:001295 +%MD:1998/12/08 + +%IH:fisher +%P:chunihcho +%G:fisher +%OIH:fisher +%ETYM:``big marten''. +%SF:animals-land +%SN:Martes pennanti +%C:N +%S:JOPA/BRBI/MAGO +%UID:000385 +%MD:2000/06/18 + +%IH:flying squirrel +%P:ts'unalhbuz +%G:flying squirrel +%OIH:flying squirrel +%SF:animals-land +%SN:Glaucomys sabrinus alpinus +%PICTURE:/home/poser/Research/Dakelh/Pictures/psfiles/FlyingSquirrel.ps +%CAPTION:{\qc ts'unulhbuz} --- Flying Squirrel +%PICPERMISSION:N +%PICCREDIT:Drawing of Flying Squirrel from {\it The Mammals of British Columbia\/}. +%C:N +%S:JOPA/BRBI +%UID:000389 +%MD:1997/11/14 + +%IH:fox +%P:nanguz +%G:fox +%OIH:fox +%C:N +%SF:animals-land +%S:MAGO +%UID:000139 +%MD:2001/02/26 + +%IH:grizzly bear +%P:shas +%G:grizzly bear +%OIH:grizzly bear +%C:N +%SF:animals-land +%S:LITM/JOPA/BRBI/VESE/EDFR/JEKO +%UID:000039 +%MD:1997/06/12 + +%IH:grizzly bear cub +%P:shasyaz +%G:grizzly bear cub +%OIH:grizzly bear cub/cub, grizzly bear +%C:N +%SF:animals-land +%S:STJA +%UID:002114 +%MD:1999/02/20 + +%IH:cub, grizzly bear +%P:shasyaz +%G:grizzly bear cub +%OIH:grizzly bear cub/cub, grizzly bear +%C:N +%SF:animals-land +%S:STJA +%UID:002114 +%MD:1999/02/20 + +%IH:grizzly bear sow +%P:shas'at +%G:grizzly bear sow +%OIH:grizzly bear sow/sow, grizzly bear +%C:N +%SF:animals-land +%ETYM:``grizzly bear's wife''. +%S:STJA +%UID:002113 +%MD:1999/02/20 + +%IH:sow, grizzly bear +%P:shas'at +%G:grizzly bear sow +%OIH:grizzly bear sow/sow, grizzly bear +%C:N +%SF:animals-land +%ETYM:``grizzly bear's wife''. +%S:STJA +%UID:002113 +%MD:1999/02/20 + +%IH:lynx +%P:wasi +%G:lynx +%OIH:lynx +%C:N +%SF:animals-land +%SN:Felis lynx +%ETYM:Loan from Gitksan {\qf wish}. +%LOANSOURCE:Gitksan +%S:JOPA/BRBI/STJA/EDFR/VESE/JEKO/MAGO +%UID:000049 +%MD:2001/04/20 + +%IH:woodchuck +%P:k'ani +%G:woodchuck +%OIH:woodchuck +%C:N +%SF:animals-land +%SN:Marmota monax +%S:JOPA/BRBI/PEJO +%R:Clarified with Josie and Peter 2001/05/28. +%UID:000391 +%POCKET:Y +%MD:2001/05/28 + +%IH:marmot +%P:dutni +%G:marmot +%OIH:marmot +%SF:animals-land +%C:N +%SN:Marmota caligata +%R:Josie and Peter are not really familiar with marmots but have heard older + people talk about them. +%S:JOPA/PEJO +%UID:000143 +%MD:1998/02/10 + +%IH:marten +%P:chunih +%G:marten +%OIH:marten +%SF:animals-land +%SN:Martes americana +%C:N +%S:JOPA/BRBI/VESE/EDFR/JEKO/MAGO +%UID:000016 +%MD:2001/04/20 + +%IH:mink +%P:telhjoos +%G:mink +%OIH:mink +%C:N +%SF:animals-land +%SN:Mustela vison +%S:LITM/JOPA/BRBI +%UID:000167 +%MD:1997/06/16 + +%IH:moose +%P:duni +%G:moose +%OIH:moose +%C:N +%SF:animals-land +%SN:Alces alces andersoni +%S:LITM-EDFR/JOPA/BRBI +%UID:000346 +%MD:1997/06/18 + +%IH:mouse +%P:dats'ooz +%G:mouse +%OIH:mouse +%SF:animals-land +%C:N +%S:LITM/JOPA/MAGO/VESE/JEKO +%UID:000156 +%MD:2001/01/22 + +%IH:muskrat +%P:tsek'et +%G:muskrat +%OIH:muskrat +%C:N +%SF:animals-land +%SN:Ondatra zibethicus +%S:JOPA/BRBI/STJA/MAGO +%UID:000335 +%MD:1998/12/08 + +%IH:moose, newly sexually mature cow +%P:chanjo +%G:newly sexually mature cow moose +%OIH:moose, newly sexually mature cow +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000379 +%MD:1997/11/14 + +%IH:pack rat +%P:looncho +%G:pack rat +%OIH:pack rat +%C:N +%SF:animals-land +%S:VESE/JEKO/MAGO +%UID:000149 +%MD:1999/05/10 + +%IH:packrat +%P:dlooncho +%G:packrat +%OIH:packrat +%C:N +%SF:animals-land +%S:JOPA +%UID:002701 +%MD:1999/05/11 + +%IH:porcupine +%P:duneza +%G:porcupine +%OIH:porcupine +%SF:animals-land +%C:N +%S:JOPA/BRBI/MAGO +%UID:000388 +%MD:2001/03/06 + +%IH:porcupine +%P:ts'it +%G:porcupine +%OIH:porcupine +%SF:animals-land +%SN:Erethizon dorsatum +%C:N +%ETYM:Perhaps derived from the interjection {\qc ts'it} ``don't touch it!''. +%S:JOPA/BRBI/MAGO/BEMC/STJA +%UID:000387 +%MD:1998/12/08 + +%IH:puppy +%P:lhiyaz +%G:puppy +%OIH:puppy +%C:N +%SF:animals-land +%DUOPLURAL:lhiyazke +%DUOPLURAL:lhikeyaz +%R:Josie prefers {\qc lhikeyaz}. +%S:LITM/BRBI/JOPA/EDFR/MAGO-JEKO +%UID:000182 +%MD:2001/05/26 + +%IH:squirrel +%P:nats'ildelh +%G:Red Squirrel +%OIH:squirrel/Red Squirrel +%SN:Tamiasciurus hudsonicus colum. +%C:N +%SF:animals-land +%S:LITM/JOPA/BRBI/STJA +%UID:000034 +%MD:1999/02/17 + +%IH:Red Squirrel +%P:nats'ildelh +%G:Red Squirrel +%OIH:squirrel/Red Squirrel +%SN:Tamiasciurus hudsonicus colum. +%C:N +%SF:animals-land +%S:LITM/JOPA/BRBI/STJA +%UID:000034 +%MD:1999/02/17 + +%IH:rabbit +%P:goh +%G:rabbit +%OIH:rabbit +%C:N +%SF:animals-land +%S:LITM/JOPA/VESE/EDFR/JEKO +%UID:000023 +%MD:1999/05/11 + +%IH:moose, recently weaned calf +%P:ooch'ainischoot +%G:recently weaned calf moose +%OIH:moose, recently weaned calf +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000381 +%MD:1997/11/14 + +%IH:sheep +%P:sbai +%G:sheep +%OIH:sheep +%C:N +%SF:animals-land +%S:MAGO +%UID:001131 +%MD:1998/02/10 + +%IH:sheep +%P:'usbai +%G:sheep +%OIH:sheep +%SF:animals-land +%C:N +%S:JOPA/BRBI +%UID:000375 +%MD:1997/11/14 + +%IH:shrew +%P:'ulhguk +%G:shrew +%OIH:shrew +%SF:animals-land +%C:N +%S:MAGO/VESE/JEKO +%UID:000526 +%MD:2001/01/22 + +%IH:skunk +%P:hoonliz +%G:skunk +%OIH:skunk +%C:N +%P2s:unhoonliz +%SF:animals-land +%S:LITM/JOPA/BRBI/MAGO/VESE/EDFR/JEKO +%UID:000052 +%MD:1997/06/12 + +%IH:weasel +%P:nohbai +%G:weasel +%OIH:weasel +%C:N +%SF:animals-land +%S:JOPA/BRBI/MAGO +%UID:000141 +%MD:1997/06/16 + +%IH:wolf +%P:yus +%G:wolf +%OIH:wolf +%C:N +%SF:animals-land +%SN:Canis lupus +%S:LITM/JOPA/BRBI +%UID:000051 +%MD:1997/06/12 + +%IH:wolverine +%P:noostel +%G:wolverine +%OIH:wolverine +%C:N +%SF:animals-land +%SN:Gulo gulo +%S:JOPA/BRBI/MAGO/VESE/EDFR/JEKO +%UID:000140 +%MD:2001/04/20 + +%IH:beaver, young +%P:tsatsul +%G:young beaver +%OIH:beaver, young +%SF:animals-land +%C:N +%S:JOPA/BRBI/STJA +%UID:000384 +%MD:1998/12/08 + +%IH:beaver dam +%P:lht'at +%G:beaver dam +%OIH:beaver dam/dam, beaver +%C:N +%SF:animals-misc +%S:STJA +%UID:001287 +%MD:1998/12/08 + +%IH:dam, beaver +%P:lht'at +%G:beaver dam +%OIH:beaver dam/dam, beaver +%C:N +%SF:animals-misc +%S:STJA +%UID:001287 +%MD:1998/12/08 + +%IH:beaver dam +%P:'ulh +%G:beaver dam +%OIH:beaver dam/dam, beaver +%C:N +%SF:animals-misc +%S:STJA +%UID:001288 +%MD:1998/12/08 + +%IH:dam, beaver +%P:'ulh +%G:beaver dam +%OIH:beaver dam/dam, beaver +%C:N +%SF:animals-misc +%S:STJA +%UID:001288 +%MD:1998/12/08 + +%IH:beaver lodge +%P:tsaken +%G:beaver lodge +%OIH:beaver lodge +%C:N +%SF:animals-misc +%S:JOPA/BRBI/STJA +%UID:000405 +%MD:1998/12/08 + +%IH:beaver path under the ice +%P:tunyohtsati +%G:beaver path under the ice +%OIH:beaver path under the ice +%C:N +%SF:animals-misc +%S:JOPA/EDFR +%UID:003769 +%POCKET:Y +%MD:2001/02/13 + +%IH:black bear den +%P:sus'an +%G:black bear den +%OIH:black bear den +%C:N +%SF:animals-misc +%S:LITM/STJA +%UID:000131 +%MD:1998/12/08 + +%IH:tracks, grizzly bear +%P:shask'oh +%G:grizzly bear tracks +%OIH:tracks, grizzly bear +%C:N +%SF:animals-misc +%S:MAGO +%UID:001132 +%MD:1998/02/10 + +%IH:leech +%P:hoolht'ukw +%G:leech +%OIH:leech +%SF:animals-misc +%C:N +%S:JOPA/PEJO/EDFR +%UID:003410 +%POCKET:Y +%MD:2000/11/01 + +%IH:leech +%P:hoot'ub +%G:leech +%OIH:leech +%SF:bugs +%C:N +%S:JOPA/BRBI/MAGO +%UID:000370 +%MD:2000/11/01 + +%IH:moose tracks +%P:dunik'oh +%G:moose tracks +%OIH:moose tracks +%C:N +%SF:animals-misc +%S:PEJO/JOPA +%ES:000491 +%UID:003121 +%POCKET:Y +%MD:2000/09/28 + +%IH:tracks, rabbit +%P:gohk'oh +%G:rabbit tracks +%OIH:tracks, rabbit +%C:N +%SF:animals-misc +%S:LITM +%UID:000073 +%MD:1997/06/12 + +%IH:beaver +%P:tsa +%G:beaver +%OIH:beaver +%C:N +%SN:Castor canadensis +%UID:000044 +%SF:animals-water +%S:JOPA/BRBI/STJA/EDFR/VESE/JEKO/MAGO +%MD:2001/04/18 + +%IH:kit, beaver +%P:tsayaz +%G:beaver kit +%OIH:kit, beaver/beaver, baby +%SF:animals-water +%C:N +%S:STJA +%UID:001294 +%MD:2000/06/18 + +%IH:beaver, baby +%P:tsayaz +%G:beaver kit +%OIH:kit, beaver/beaver, baby +%SF:animals-water +%C:N +%S:STJA +%UID:001294 +%MD:2000/06/18 + +%IH:beaver, big +%P:tsati +%G:big beaver, old beaver +%OIH:beaver, big/beaver, old +%C:N +%SF:animals-water +%S:LITM/JOPA/BRBI/STJA +%UID:000206 +%MD:1998/12/08 + +%IH:beaver, old +%P:tsati +%G:big beaver, old beaver +%OIH:beaver, big/beaver, old +%C:N +%SF:animals-water +%S:LITM/JOPA/BRBI/STJA +%UID:000206 +%MD:1998/12/08 + +%IH:otter +%P:tsis +%G:otter +%OIH:otter +%SF:animals-water +%SN:Lutra canadensis +%C:N +%S:JOPA/BRBI +%UID:000386 +%MD:1997/11/14 + +%IH:crow +%P:datsan +%G:American Crow +%C:N +%SF:bird-gen +%SN:Corvus brachyrhynchos +%OIH:crow/American Crow +%S:LITM/PEJO +%UID:000158 +%MD:2000/10/21 + +%IH:American Crow +%P:datsan +%G:American Crow +%C:N +%SF:bird-gen +%SN:Corvus brachyrhynchos +%OIH:crow/American Crow +%S:LITM/PEJO +%UID:000158 +%MD:2000/10/21 + +%IH:Robin, American +%P:sewh +%G:American Robin +%OIH:Robin, American +%SN:Turdus migratorius +%C:N +%SF:bird-gen +%S:LITM/JOPA/BRBI/PEJO +%UID:000181 +%MD:2000/10/21 + +%IH:Bald Eagle +%P:tsebalyan +%G:Bald Eagle +%OIH:Bald Eagle +%C:N +%SF:bird-gen +%SN:Haliaeetus leucocephalus +%S:LITM/JOPA/BRBI +%UID:000150 +%MD:1997/06/16 + +%IH:bird +%P:dut'ai +%G:bird, duck +%OIH:bird/duck +%C:N +%SF:bird-gen +%S:LITM/JOPA/BRBI/MAGO/STJA/PEJO +%UID:000081 +%MD:2000/09/28 + +%IH:duck +%P:dut'ai +%G:bird, duck +%OIH:bird/duck +%C:N +%SF:bird-gen +%S:LITM/JOPA/BRBI/MAGO/STJA/PEJO +%UID:000081 +%MD:2000/09/28 + +%IH:crane +%P:delh +%G:crane +%OIH:crane +%C:N +%SF:bird-gen +%S:LITM +%UID:000255 +%MD:1997/06/16 + +%IH:goose +%P:khoh +%G:goose +%OIH:goose +%C:N +%P1s:skhoh +%P2s:nkhoh +%P1p:nekhoh +%POSS:khoh +%SF:bird-gen +%S:JOPA/BRBI/MAGO/VESE/EDFR/JEKO +%UID:000031 +%MD:2001/02/15 + +%IH:hummingbird +%P:ts'unalhduz +%G:hummingbird +%OIH:hummingbird +%C:N +%SF:bird-gen +%S:LITM/BRBI/JOPA +%UID:000242 +%MD:1997/06/16 + +%IH:bird, little +%P:gagiyaz +%G:little bird +%OIH:bird, little +%C:N +%QCHECK:Any little bird? +%SF:bird-gen +%S:PEJO +%UID:003115 +%POCKET:Y +%MD:2000/09/28 + +%IH:bird, little +%P:dut'aiyaz +%G:little bird +%OIH:bird, little +%C:N +%SF:bird-gen +%S:STJA/JOPA/EDFR/VESE/PEJO +%UID:001818 +%MD:2000/09/28 + +%IH:loon +%P:dadzi +%G:loon +%OIH:loon +%SF:bird-gen +%SN:Gavia immer +%C:N +%S:LITM/JOPA/BRBI +%UID:000020 +%MD:1997/06/12 + +%IH:Mallard Duck +%P:t'ugicho +%G:Mallard Duck +%OIH:Mallard Duck +%C:N +%SN:Anas platyrhynchos +%SF:bird-gen +%S:LITM/JOPA/BRBI/MAGO/VESE/EDFR/JEKO +%UID:000041 +%MD:1999/05/11 + +%IH:owl +%P:musdzoon +%G:owl +%OIH:owl +%C:N +%SF:bird-gen +%S:LITM/BRBI/JOPA/MAGO +%UID:000135 +%MD:1997/12/11 + +%IH:Red-Necked Grebe +%P:ts'olh +%G:Red-necked Grebe +%MN:A variety of duck locally known as the Helldiver. +%OIH:Red-Necked Grebe/Helldiver/Grebe, Red-Necked +%SN:Podiceps grisegena +%SF:bird-gen +%C:N +%S:BRBI/JOPA +%UID:000263 +%MD:2001/03/08 + +%IH:Helldiver +%P:ts'olh +%G:Red-necked Grebe +%MN:A variety of duck locally known as the Helldiver. +%OIH:Red-Necked Grebe/Helldiver/Grebe, Red-Necked +%SN:Podiceps grisegena +%SF:bird-gen +%C:N +%S:BRBI/JOPA +%UID:000263 +%MD:2001/03/08 + +%IH:Grebe, Red-Necked +%P:ts'olh +%G:Red-necked Grebe +%MN:A variety of duck locally known as the Helldiver. +%OIH:Red-Necked Grebe/Helldiver/Grebe, Red-Necked +%SN:Podiceps grisegena +%SF:bird-gen +%C:N +%S:BRBI/JOPA +%UID:000263 +%MD:2001/03/08 + +%IH:Ruffed grouse +%P:'utsut +%G:Ruffed grouse +%OIH:Ruffed grouse +%C:N +%SF:bird-gen +%S:LITM +%UID:000218 +%MD:1997/06/16 + +%IH:Spruce Grouse +%P:nat'oh +%G:Spruce Grouse, Fool Hen +%OIH:Spruce Grouse/Grouse, Spruce/Fool Hen +%SF:bird-gen +%SN:Dendragapus canadensis +%C:N +%S:MAGO/LITM +%UID:000539 +%MD:1997/12/04 + +%IH:Grouse, Spruce +%P:nat'oh +%G:Spruce Grouse, Fool Hen +%OIH:Spruce Grouse/Grouse, Spruce/Fool Hen +%SF:bird-gen +%SN:Dendragapus canadensis +%C:N +%S:MAGO/LITM +%UID:000539 +%MD:1997/12/04 + +%IH:Fool Hen +%P:nat'oh +%G:Spruce Grouse, Fool Hen +%OIH:Spruce Grouse/Grouse, Spruce/Fool Hen +%SF:bird-gen +%SN:Dendragapus canadensis +%C:N +%S:MAGO/LITM +%UID:000539 +%MD:1997/12/04 + +%IH:Steller's Jay +%P:tehgwuzeh +%G:Steller's Jay, commonly known locally as ``bluejay''. +%OIH:Steller's Jay/jay, Steller's/Bluejay (Steller's Jay) +%SF:bird-gen +%SN:Cyanocitta stelleri +%C:N +%S:JOPA/BRBI +%UID:000356 +%MD:1997/11/14 + +%IH:jay, Steller's +%P:tehgwuzeh +%G:Steller's Jay, commonly known locally as ``bluejay''. +%OIH:Steller's Jay/jay, Steller's/Bluejay (Steller's Jay) +%SF:bird-gen +%SN:Cyanocitta stelleri +%C:N +%S:JOPA/BRBI +%UID:000356 +%MD:1997/11/14 + +%IH:Bluejay (Steller's Jay) +%P:tehgwuzeh +%G:Steller's Jay, commonly known locally as ``bluejay''. +%OIH:Steller's Jay/jay, Steller's/Bluejay (Steller's Jay) +%SF:bird-gen +%SN:Cyanocitta stelleri +%C:N +%S:JOPA/BRBI +%UID:000356 +%MD:1997/11/14 + +%IH:sandpiper +%P:wedlew +%G:sandpiper +%OIH:sandpiper +%C:N +%SN:Eremophila alpestris et sim. +%SF:bird-gen +%S:LITM +%UID:000237 +%MD:2002/07/19 + +%IH:seagull +%P:besk'i +%G:seagull +%OIH:seagull +%C:N +%SN:Larus species +%SF:bird-gen +%S:LITM +%UID:000136 +%MD:2002/07/19 + +%IH:swan +%P:ts'incho +%G:swan +%OIH:swan +%C:N +%SF:bird-gen +%S:LITM +%UID:000222 +%MD:1997/06/16 + +%IH:Tree Swallow +%P:'uschas +%G:Tree Swallow +%OIH:Tree Swallow +%SF:bird-gen +%SN:Tachycineta bicolor +%C:N +%S:MAGO +%UID:000535 +%MD:1997/11/22 + +%IH:Whiskey Jack +%P:gwuzeh +%G:Whiskey Jack, Gray Jay, Canadian Jay +%OIH:Whiskey Jack/Jay, Gray/Jay, Canadian +%C:N +%SN:Perisoreus canadensis +%SF:bird-gen +%S:LITM/JOPA/BRBI/MAGO +%UID:000148 +%MD:1997/11/22 + +%IH:Jay, Gray +%P:gwuzeh +%G:Whiskey Jack, Gray Jay, Canadian Jay +%OIH:Whiskey Jack/Jay, Gray/Jay, Canadian +%C:N +%SN:Perisoreus canadensis +%SF:bird-gen +%S:LITM/JOPA/BRBI/MAGO +%UID:000148 +%MD:1997/11/22 + +%IH:Jay, Canadian +%P:gwuzeh +%G:Whiskey Jack, Gray Jay, Canadian Jay +%OIH:Whiskey Jack/Jay, Gray/Jay, Canadian +%C:N +%SN:Perisoreus canadensis +%SF:bird-gen +%S:LITM/JOPA/BRBI/MAGO +%UID:000148 +%MD:1997/11/22 + +%IH:woodpecker +%P:chundulkw'uz +%G:woodpecker +%OIH:woodpecker +%C:N +%SF:bird-gen +%S:JOPA/BRBI/STJA +%UID:000138 +%MD:1999/03/31 + +%IH:nest +%P:-t'o +%G:nest +%OIH:nest +%C:N +%Pind:'ut'o +%P3s:but'o +%Pref:dut'o +%SF:bird-misc/bugs +%S:STJA/PEJO/JOPA/BRBI/EDFR +%ES:001353 +%UID:000226 +%MD:2001/03/07 + +%IH:eye, a single +%P:-nak'uz +%G:a single eye +%OIH:eye, a single +%C:N +%SF:body-ext +%S:JOPA/EDFR +%ES:000457 +%UID:003770 +%POCKET:Y +%MD:2001/02/13 + +%IH:ankle +%P:-kechunoh +%G:ankle +%OIH:ankle +%P1s:skechunoh +%P2s:nkechunoh +%C:N +%S:MAGO/STJA +%SF:body-ext +%UID:000865 +%MD:1999/03/03 + +%IH:antler +%P:-de +%G:antler, horn +%OIH:antler/horn +%C:N +%SF:body-ext +%P3s:bude +%S:STJA +%UID:002266 +%MD:1999/03/02 + +%IH:horn +%P:-de +%G:antler, horn +%OIH:antler/horn +%C:N +%SF:body-ext +%P3s:bude +%S:STJA +%UID:002266 +%MD:1999/03/02 + +%IH:velvet, antler +%P:-de_zu_s +%G:antler velvet +%OIH:velvet, antler +%C:N +%SF:body-ext +%P3s:bude_zu_s +%S:STJA +%UID:002267 +%MD:1999/03/02 + +%IH:anus +%P:-tsul +%G:anus, asshole +%OIH:anus/asshole +%C:N +%P1s:stsul +%SF:body-ext +%S:STJA +%UID:002171 +%MD:1999/02/23 + +%IH:asshole +%P:-tsul +%G:anus, asshole +%OIH:anus/asshole +%C:N +%P1s:stsul +%SF:body-ext +%S:STJA +%UID:002171 +%MD:1999/02/23 + +%IH:arm +%P:-gan +%G:arm +%OIH:arm +%P1s:sgan +%P2s:ngan +%Pref:dugan +%C:N +%S:LITM/MAGO/STJA/JOPA/VESE/EDFR/JEKO +%SF:body-ext +%UID:000863 +%MD:1999/02/22 + +%IH:armpit +%P:-chak'ests'oh +%G:armpit +%OIH:armpit +%P1s:schak'ests'oh +%C:N +%S:MAGO +%UID:000859 +%SF:body-ext +%MD:1997/12/11 + +%IH:back (of body) +%P:-t'ak +%G:back (of body) +%OIH:back (of body) +%P1s:st'ak +%P3s:but'ak +%C:N +%S:MAGO/EDFR/VESE/JEKO +%SF:body-ext +%UID:000899 +%MD:1997/12/11 + +%IH:back of hand +%P:-lat'ak +%G:back of hand +%OIH:back of hand +%P1s:slat'ak +%C:N +%S:MAGO +%SF:body-ext +%UID:000871 +%MD:1997/12/11 + +%IH:beaver paws +%P:tsake +%G:beaver paws +%OIH:beaver paws +%C:N +%SF:body-ext +%S:LITM-EDFR +%UID:000329 +%MD:1997/06/18 + +%IH:beaver tail +%P:tsache +%G:beaver tail +%OIH:beaver tail +%C:N +%SF:body-ext +%S:LITM +%UID:000207 +%MD:1997/06/16 + +%IH:belly +%P:-but +%G:belly +%OIH:belly +%P1s:sbut +%C:N +%S:MAGO +%SF:body-ext +%UID:000937 +%MD:1997/12/11 + +%IH:breast +%P:-ts'oo +%G:breast +%OIH:breast +%P1s:sts'oo +%C:N +%S:MAGO +%UID:000855 +%SF:body-ext +%MD:1997/12/11 + +%IH:bum +%P:-tl'a +%G:bum, buttocks +%OIH:bum/buttocks +%P1s:stl'a +%C:N +%S:MAGO +%SF:body-ext +%UID:000936 +%MD:1997/12/11 + +%IH:buttocks +%P:-tl'a +%G:bum, buttocks +%OIH:bum/buttocks +%P1s:stl'a +%C:N +%S:MAGO +%SF:body-ext +%UID:000936 +%MD:1997/12/11 + +%IH:calf of leg +%P:-kechunch'ooz +%G:calf of leg +%OIH:calf of leg +%C:N +%SF:body-ext +%S:JOPA/EDFR +%UID:004458 +%POCKET:Y +%MD:2001/04/20 + +%IH:cheek +%P:-nembus +%G:cheek +%OIH:cheek +%P1s:snimbus +%C:N +%S:MAGO/JOPA/BRBI +%SF:body-ext +%UID:000889 +%MD:1997/12/11 + +%IH:chest +%P:-yoh +%G:chest +%OIH:chest +%C:N +%SF:body-ext +%S:JOPA/EDFR +%ES:000660 +%UID:003777 +%POCKET:Y +%MD:2001/02/13 + +%IH:chin +%P:-yeda' +%G:chin +%OIH:chin +%P1s:syeda' +%C:N +%S:MAGO +%SF:body-ext +%UID:000882 +%MD:1997/12/11 + +%IH:cranial fontanelle +%P:-tsidakwhudutle +%G:cranial fontanelle, baby's soft spot +%OIH:cranial fontanelle/baby's soft spot +%C:N +%P3s:butsidakwhudutle +%S:MAGO +%SF:body-ext +%UID:000898 +%MD:1997/12/11 + +%IH:baby's soft spot +%P:-tsidakwhudutle +%G:cranial fontanelle, baby's soft spot +%OIH:cranial fontanelle/baby's soft spot +%C:N +%P3s:butsidakwhudutle +%S:MAGO +%SF:body-ext +%UID:000898 +%MD:1997/12/11 + +%IH:ear +%P:-dzo +%G:ear +%OIH:ear +%MN:This refers to the ear considered as a whole, especially the exterior. + When the canal in particular is referred to, one uses {\qc -dzek}, q.v. +%C:N +%P1s:sdzo +%S:MAGO +%SF:body-ext +%UID:000879 +%MD:1997/12/11 + +%IH:earlobe +%P:-dzobal +%G:earlobe +%OIH:earlobe +%C:N +%P1s:sdzobal +%SF:body-ext +%S:BRBI/MAGO +%UID:000641 +%MD:1997/12/17 + +%IH:elbow +%P:-nints'uzti +%G:elbow +%OIH:elbow +%P1s:snints'uzti +%C:N +%S:MAGO +%SF:body-ext +%UID:000916 +%MD:1997/12/11 + +%IH:eye +%P:-na +%G:eye +%OIH:eye +%P1s:sna +%P3s:buna +%C:N +%S:MAGO/JOPA/EDFR +%SF:body-ext +%UID:000891 +%MD:1998/12/18 + +%IH:eye socket +%P:-nak'et +%G:eye socket +%OIH:eye socket +%P1s:snak'et +%C:N +%S:MAGO +%SF:body-ext +%UID:000892 +%MD:1997/12/11 + +%IH:eyebrow +%P:-nach'usdooz +%G:eyebrow +%OIH:eyebrow +%P1s:snach'usdooz +%C:N +%S:MAGO +%SF:body-ext +%UID:000896 +%MD:1997/12/11 + +%IH:eyelash +%P:-nalusgha +%G:eyelash +%OIH:eyelash +%P1s:snalusgha +%C:N +%S:MAGO +%SF:body-ext +%UID:000895 +%MD:1997/12/11 + +%IH:eyelid +%P:-nalus +%G:eyelid +%OIH:eyelid +%P1s:snalus +%C:N +%S:MAGO +%SF:body-ext +%UID:000894 +%MD:1997/12/11 + +%IH:face +%P:-nen +%G:face +%OIH:face +%P1s:snen +%P2s:nyunen +%P3s:bunen +%C:N +%S:MAGO/PEJO/STJA/JOPA/VESE/EDFR +%SF:body-ext +%ES:000369 +%UID:000890 +%MD:2001/04/20 + +%IH:feather +%P:ts'uz +%G:feather, down +%OIH:feather/down +%C:N +%SF:body-ext +%S:LITM/STJA/PEJO +%UID:000271 +%MD:2000/10/16 + +%IH:down +%P:ts'uz +%G:feather, down +%OIH:feather/down +%C:N +%SF:body-ext +%S:LITM/STJA/PEJO +%UID:000271 +%MD:2000/10/16 + +%IH:feathers +%P:dut'aits'uz +%G:feathers, down +%OIH:feathers/down +%C:N +%SF:body-ext +%S:STJA +%UID:002647 +%MD:2001/02/27 + +%IH:down +%P:dut'aits'uz +%G:feathers, down +%OIH:feathers/down +%C:N +%SF:body-ext +%S:STJA +%UID:002647 +%MD:2001/02/27 + +%IH:finger other than thumb or pinkie +%P:-lasge +%G:finger other than thumb or pinkie +%OIH:finger other than thumb or pinkie +%P1s:slasge +%C:N +%S:MAGO/STJA/JOPA/PEJO/EDFR +%SF:body-ext +%UID:000869 +%MD:2000/11/01 + +%IH:fingernails +%P:-lagui +%G:fingernails, claws of forepaws +%OIH:fingernails/claws of forepaws +%P1s:slagui +%C:N +%S:MAGO +%SF:body-ext +%UID:000875 +%MD:1997/12/11 + +%IH:claws of forepaws +%P:-lagui +%G:fingernails, claws of forepaws +%OIH:fingernails/claws of forepaws +%P1s:slagui +%C:N +%S:MAGO +%SF:body-ext +%UID:000875 +%MD:1997/12/11 + +%IH:foot +%P:-ke +%G:foot +%OIH:foot +%C:N +%P1s:ske +%Pref:duke +%S:MAGO/STJA/JOPA/VESE/EDFR/JEKO +%UID:000851 +%SF:body-ext +%MD:1999/05/11 + +%IH:hair +%P:-gha +%G:hair +%MN:This refers to hair in general and where no more specific term exists, as on the + arms and chest. It is not used to refer to the hair of the head, for which the + more specific term {\qc -tsigha} is always used. +%OIH:hair +%C:N +%S:MAGO +%SF:body-ext +%UID:000888 +%MD:1997/12/11 + +%IH:hair of the head +%P:-tsigha +%G:hair of the head +%OIH:hair of the head +%P1s:stsigha +%P2s:ntsigha +%P3s:butsigha +%C:N +%S:MAGO/LITM/PEJO +%SF:body-ext +%UID:000887 +%MD:2000/10/20 + +%IH:hand +%P:-la +%G:hand +%OIH:hand +%P1s:sla +%P2s:nla +%C:N +%S:MAGO/STJA +%SF:body-ext +%POCKET:Y +%UID:000866 +%MD:1999/02/17 + +%IH:head +%P:-tsi +%G:head +%OIH:head +%Pref:dutsi +%C:N +%SF:body-ext +%S:STJA +%UID:002965 +%POCKET:Y +%MD:1999/06/24 + +%IH:heel +%P:-kelatsul +%G:heel +%OIH:heel +%P1s:skelatsul +%C:N +%S:MAGO +%SF:body-ext +%UID:000917 +%MD:1997/12/11 + +%IH:hip +%P:-k'ui +%G:hip +%OIH:hip +%P1s:sk'ui +%C:N +%S:MAGO/JOPA +%SF:body-ext +%UID:000923 +%MD:2001/03/15 + +%IH:knee +%P:-gwut +%G:knee +%OIH:knee +%P1s:sgwut +%C:N +%S:MAGO +%SF:body-ext +%UID:000933 +%MD:1997/12/11 + +%IH:kneecap +%P:-gwutlasi'ai +%G:kneecap +%OIH:kneecap +%P1s:sgwutlasi'ai +%R:has something to do with floating at tip of knee +%C:N +%S:MAGO +%SF:body-ext +%UID:000925 +%MD:1997/12/11 + +%IH:knuckles at boundary between hand and fingers +%P:-langwut +%G:knuckles at boundary between hand and fingers +%OIH:knuckles at boundary between hand and fingers +%P1s:slangwut +%SF:body-ext +%C:N +%S:JOPA/BRBI +%UID:000967 +%MD:1997/12/17 + +%IH:leg +%P:-kechun +%G:leg +%OIH:leg +%P1s:skechun +%C:N +%S:MAGO +%UID:000852 +%SF:body-ext +%MD:1997/12/11 + diff --git a/test/xref.awk b/test/xref.awk new file mode 100644 index 0000000..d23a0c8 --- /dev/null +++ b/test/xref.awk @@ -0,0 +1,139 @@ + # xref.awk - cross reference an awk program + + # 12/2010: Modified for gawk test suite to use a variable + # for the sort command and to use `sort -k1' instead of `sort +1' + + BEGIN { + if (sortcmd == "") sortcmd = "sort" # "sort -k1" + + # create array of keywords to be ignored by lexer + asplit("BEGIN:END:atan2:break:close:continue:cos:delete:" \ + "do:else:exit:exp:for:getline:gsub:if:in:index:int:" \ + "length:log:match:next:print:printf:rand:return:sin:" \ + "split:sprintf:sqrt:srand:sub:substr:system:while", + keywords,":") + + # build the symbol-state table + split("00:00:00:00:00:00:00:00:00:00:" \ + "20:10:10:12:12:11:07:00:00:00:" \ + "08:08:08:08:08:33:08:00:00:00:" \ + "08:44:08:36:08:08:08:00:00:00:" \ + "08:44:45:42:42:41:08",machine,":") + + # parse the input and store an intermediate representation + # of the cross-reference information + + # set up the machine + state = 1 + + # run the machine + for (;;) { + + # get next symbol + symb = lex() + nextstate = substr(machine[state symb],1,1) + act = substr(machine[state symb],2,1) + + # perform required action + if ( act == "0" ) + ; # do nothing + else if ( act == "1" ) { + if ( ! inarray(tok,names) ) + names[++nnames] = tok + lines[tok,++xnames[tok]] = NR } + else if ( act == "2" ) { + if ( tok in local ) { + tok = tok "(" funcname ")" + if ( ! inarray(tok,names) ) + names[++nnames] = tok + lines[tok,++xnames[tok]] = NR } + else { + tok = tok "()" + if ( ! inarray(tok,names) ) + names[++nnames] = tok + lines[tok,++xnames[tok]] = NR } } + else if ( act == "3" ) { + funcname = tok + flines[tok] = NR } + else if ( act == "4" ) + braces++ + else if ( act == "5" ) { + braces-- + if ( braces == 0 ) { + for ( temp in local ) + delete local[temp] + funcname = "" + nextstate = 1 } } + else if ( act == "6" ) { + local[tok] = 1 } + else if ( act == "7" ) + break + else if ( act == "8" ) { + print "error: xref.awk: line " NR ": aborting" \ + > "/dev/con" + exit 1 } + + # finished with current token + state = nextstate } + + # finished parsing, now ready to print output + for ( i = 1; i <= nnames; i++ ) { + printf "%d ", xnames[names[i]] | sortcmd + if ( index(names[i],"(") == 0 ) + printf "%s(%d)", names[i], flines[names[i]] | sortcmd + else + printf "%s", names[i] | sortcmd + for ( j = 1; j <= xnames[names[i]]; j++ ) + if ( lines[names[i],j] != lines[names[i],j-1] ) + printf " %d", lines[names[i],j] | sortcmd + printf "\n" | sortcmd } + + close(sortcmd) + } # END OF PROGRAM + + function asplit(str,arr,fs, n) { n = split(str,temp_asplit,fs) + for ( i = 1; i <= n; i++ ) arr[temp_asplit[i]]++ } + + function inarray(val,arr, j, tmp) { + for ( j in arr ) + tmp[arr[j]]++ + return (val in tmp) } + + function lex() { + + for (;;) { + + if ( tok == "(eof)" ) return 7 + + while ( length(line) == 0 ) + if ( getline line == 0 ) { + tok = "(eof)"; return 7 } + + sub(/^[ \t]+/,"",line) # remove white space, + sub(/^"([^"]|\\")*"/,"",line) # quoted strings, + sub(/^\/([^\/]|\\\/)+\//,"",line) # regular expressions, + sub(/^#.*/,"",line) # and comments + + if ( line ~ /^function/ ) { + tok = "function"; line = substr(line,9); return 1 } + else if ( line ~ /^{/ ) { + tok = "{"; line = substr(line,2); return 2 } + else if ( line ~ /^}/ ) { + tok = "}"; line = substr(line,2); return 3 } + # change regexes to use posix character classes + else if ( match(line,/^[[:alpha:]_][[:alnum:]]*\[/) ) { + tok = substr(line,1,RLENGTH-1) + line = substr(line,RLENGTH+1) + return 5 } + else if ( match(line,/^[[:alpha:]_][[:alnum:]]*\(/) ) { + tok = substr(line,1,RLENGTH-1) + line = substr(line,RLENGTH+1) + if ( ! ( tok in keywords ) ) return 6 } + else if ( match(line,/^[[:alpha:]_][[:alnum:]]*/) ) { + tok = substr(line,1,RLENGTH) + line = substr(line,RLENGTH+1) + if ( ! ( tok in keywords ) ) return 4 } + else { + match(line,/^[^[:alpha:]_{}]/) + tok = substr(line,1,RLENGTH) + line = substr(line,RLENGTH+1) } } } diff --git a/test/xref.original b/test/xref.original new file mode 100644 index 0000000..a94de21 --- /dev/null +++ b/test/xref.original @@ -0,0 +1,313 @@ +XREF(AWK) Philip L. Bewig XREF(AWK) + +NAME + + xref(awk) - produce a cross reference listing of an awk program + +SYNOPSIS + + awk -f xref.awk [ file ... ] + +DESCRIPTION + + XREF(AWK) takes as input a valid awk program and produces as out- + put a cross-reference listing of all variables and function calls + which appear in the program. + + For ordinary variables and array variables, a line of the form + + count var(func) lines ... + + is produced, where "count" is the number of times the variable is + used, "var" is the name of the variable, "func" is the function + name to which the variable is local (a null "func" indicates that + the variable is global), and "lines" is the number of each line + where the variable appears. Appearances of the variable in a + function's parameter list are ignored. The number of lines shown + may differ from "count" if the variable appears more than once on + the same line. + + For functions, a line of the form + + count func(define) lines ... + + is produced, where "count" is the number of times the function is + called, "func" is the name of the function, "define" is the lime + number where the function is defined, and "lines" is the number of + each line where the function is called. As for variables, the + number of lines shown may differ from "count." + + Output lines for variables and functions are intermixed and are + sorted by name. Though terse, the output is informative, easy to + read, and amenable to further processing. + +EXAMPLE + + The cross-reference listing produced by running xref.awk against + itself is shown below: + + 5 NR() 39 45 50 53 68 + 8 RLENGTH() 119 120 123 124 127 128 132 133 + 10 act() 31 34 36 40 51 54 56 63 65 67 + 1 arr(asplit) 90 + 2 arr(inarray) 93 94 + 1 asplit(89) 6 + 3 braces() 55 57 58 + 2 flines() 53 79 + 1 fs(asplit) 89 + 3 funcname() 42 52 61 + 16 i() 76 77 78 79 81 82 83 84 90 + 3 inarray(92) 37 43 48 + 6 j() 82 83 84 + 3 j(inarray) 93 94 + 3 keywords() 10 125 129 + 1 lex(97) 29 + 31 line() 103 104 107 108 109 110 112 113 114 115 116 117 118 + 119 120 122 123 124 126 127 128 131 132 133 + 6 lines() 39 45 50 83 84 + 4 local() 41 59 60 64 + 3 machine() 17 30 31 + 2 n(asplit) 89 90 + 15 names() 37 38 43 44 48 49 77 78 79 81 82 83 84 + 3 nextstate() 30 62 73 + 4 nnames() 38 44 49 76 + 4 state() 23 30 31 73 + 1 str(asplit) 89 + 3 symb() 29 30 31 + 2 temp() 59 60 + 2 temp_asplit() 89 90 + 31 tok() 37 38 39 41 42 43 44 45 47 48 49 50 52 53 64 101 105 + 113 115 117 119 123 125 127 129 132 + 1 val(inarray) 94 + 5 xnames() 39 45 50 77 82 + + For readability, some lines have been folded. + +SOURCE CODE + + # xref.awk - cross reference an awk program + + BEGIN { + + # create array of keywords to be ignored by lexer + asplit("BEGIN:END:atan2:break:close:continue:cos:delete:" \ + "do:else:exit:exp:for:getline:gsub:if:in:index:int:" \ + "length:log:match:next:print:printf:rand:return:sin:" \ + "split:sprintf:sqrt:srand:sub:substr:system:while", + keywords,":") + + # build the symbol-state table + split("00:00:00:00:00:00:00:00:00:00:" \ + "20:10:10:12:12:11:07:00:00:00:" \ + "08:08:08:08:08:33:08:00:00:00:" \ + "08:44:08:36:08:08:08:00:00:00:" \ + "08:44:45:42:42:41:08",machine,":") + + # parse the input and store an intermediate representation + # of the cross-reference information + + # set up the machine + state = 1 + + # run the machine + for (;;) { + + # get next symbol + symb = lex() + nextstate = substr(machine[state symb],1,1) + act = substr(machine[state symb],2,1) + + # perform required action + if ( act == "0" ) + ; # do nothing + else if ( act == "1" ) { + if ( ! inarray(tok,names) ) + names[++nnames] = tok + lines[tok,++xnames[tok]] = NR } + else if ( act == "2" ) { + if ( tok in local ) { + tok = tok "(" funcname ")" + if ( ! inarray(tok,names) ) + names[++nnames] = tok + lines[tok,++xnames[tok]] = NR } + else { + tok = tok "()" + if ( ! inarray(tok,names) ) + names[++nnames] = tok + lines[tok,++xnames[tok]] = NR } } + else if ( act == "3" ) { + funcname = tok + flines[tok] = NR } + else if ( act == "4" ) + braces++ + else if ( act == "5" ) { + braces-- + if ( braces == 0 ) { + for ( temp in local ) + delete local[temp] + funcname = "" + nextstate = 1 } } + else if ( act == "6" ) { + local[tok] = 1 } + else if ( act == "7" ) + break + else if ( act == "8" ) { + print "error: xref.awk: line " NR ": aborting" \ + > "/dev/con" + exit 1 } + + # finished with current token + state = nextstate } + + # finished parsing, now ready to print output + for ( i = 1; i <= nnames; i++ ) { + printf "%d ", xnames[names[i]] |"sort +1" + if ( index(names[i],"(") == 0 ) + printf "%s(%d)", names[i], flines[names[i]] |"sort +1" + else + printf "%s", names[i] |"sort +1" + for ( j = 1; j <= xnames[names[i]]; j++ ) + if ( lines[names[i],j] != lines[names[i],j-1] ) + printf " %d", lines[names[i],j] |"sort +1" + printf "\n" |"sort +1" } + + } # END OF PROGRAM + + function asplit(str,arr,fs, n) { n = split(str,temp_asplit,fs) + for ( i = 1; i <= n; i++ ) arr[temp_asplit[i]]++ } + + function inarray(val,arr, j) { + for ( j in arr ) + if ( arr[j] == val ) return j + return "" } + + function lex() { + + for (;;) { + + if ( tok == "(eof)" ) return 7 + + while ( length(line) == 0 ) + if ( getline line == 0 ) { + tok = "(eof)"; return 7 } + + sub(/^[ \t]+/,"",line) # remove white space, + sub(/^"([^"]|\\")*"/,"",line) # quoted strings, + sub(/^\/([^\/]|\\\/)+\//,"",line) # regular expressions, + sub(/^#.*/,"",line) # and comments + + if ( line ~ /^function/ ) { + tok = "function"; line = substr(line,9); return 1 } + else if ( line ~ /^{/ ) { + tok = "{"; line = substr(line,2); return 2 } + else if ( line ~ /^}/ ) { + tok = "}"; line = substr(line,2); return 3 } + else if ( match(line,/^[A-Za-z_][A-Za-z_0-9]*\[/) ) { + tok = substr(line,1,RLENGTH-1) + line = substr(line,RLENGTH+1) + return 5 } + else if ( match(line,/^[A-Za-z_][A-Za-z_0-9]*\(/) ) { + tok = substr(line,1,RLENGTH-1) + line = substr(line,RLENGTH+1) + if ( ! ( tok in keywords ) ) return 6 } + else if ( match(line,/^[A-Za-z_][A-Za-z_0-9]*/) ) { + tok = substr(line,1,RLENGTH) + line = substr(line,RLENGTH+1) + if ( ! ( tok in keywords ) ) return 4 } + else { + match(line,/^[^A-Za-z_{}]/) + tok = substr(line,1,RLENGTH) + line = substr(line,RLENGTH+1) } } } + +TECHNICAL DISCUSSION + + Broadly, XREF(AWK) parses an awk program using a symbol-state + table, in much the same way as a yacc-generated parser. The + lexical analyzer recognizes seven distinct symbols: the word + "function", the left brace, the right brace, identifiers used + as variables, identifiers used as arrays, identifiers used as + functions, and end of file. The type of symbol is returned to + the parser as the value of the "lex" function, and the global + variable "tok" is set to the text of the current token. + + The symbol-state table is stored in the "machine" array. The + table can be represented as follows: + + symbol | 1 2 3 4 5 6 7 + | + state | "function" { } var array func eof + -- -- -- -- -- -- -- -+- -- -- -- -- -- -- -- -- -- -- -- -- -- + 1 any | 20 10 10 12 12 11 07 + 2 "function" | 08 08 08 08 08 33 08 + 3 "function" name | 08 44 08 36 08 08 08 + 4 "function" name "{" | 08 44 45 42 42 41 08 + + where the first digit is the state to be entered after process- + ing the current token and the second digit is an action to be + performed. The actions are listed below: + + 1 found a function call + 2 found a variable or array + 3 found a function definition + 4 found a left brace + 5 found a right brace + 6 found a local variable declaration + 7 found end of file + 8 found an error + + Each of the first six actions causes some information about the + target program to be stored for later processing; the structures + used will be discussed below. The seventh action causes the + parser to exit. The eighth action causes errors to be reported + to standard error and the program to abort. + + Before describing the intermediate data structures, we will + discuss some of the more interesting points in the action calls. + The "braces" variable keeps track of whether we are currently + within a functions; it is positive within a function and zero + without. When the right brace which causes the value of "braces" + to go from one to zero is found, the value of "nextstate" is + changed from four (scanning a function) to one (any) and the + names of local variables are forgotten. The "local" array is + accumulated from the variables found after the function name but + before the opening left brace of the function; action two care- + fully checks whether a variable is global or local before writing + to the intermediate data structure. The variable "funcname" is + the name of the current function when within a function and null + without. + + The following arrays store an intermediate representation of the + variable and function identifiers of the target program: + + names[1..nnames] = list of all identifiers, both variable and + function names; for variables, the name has the form + var(func), but for functions, there are no parentheses + + xnames[names[i]] = number of times names[i] is used + + lines[names[i],1..xnames[names[i]]] = list of line numbers + where names[i] is used + + flines[names[i]] = line number where function names[i] is + defined + + These arrays are created as the parser reads the input; when the + parser is finished, the arrays are output in user-readable form. + +PORTABILITY + + XREF(AWK) will work with any implementation of nawk. The MKS + ToolKit implementation requires the large-model version of awk. + +HISTORY + + Written by Phil Bewig on February 10, 1990. Inspired by + Exercise 3-16 of the book "The Awk Programming Language" by + Alfred V. Aho, Brian W. Kernighan and Peter J. Weinberger + (Addison-Wesley: 1988). + +COPYRIGHT + + This program is placed in the public domain. However, the + author requests credit when distributed. + diff --git a/test/zero2.awk b/test/zero2.awk new file mode 100644 index 0000000..8ecfb2f --- /dev/null +++ b/test/zero2.awk @@ -0,0 +1,5 @@ +BEGIN { + printf "%d\n", -.4 + printf "%d\n", -0.0 + printf "%d\n", -.9 +} diff --git a/test/zero2.ok b/test/zero2.ok new file mode 100644 index 0000000..bb0b1cf --- /dev/null +++ b/test/zero2.ok @@ -0,0 +1,3 @@ +0 +0 +0 diff --git a/test/zeroe0.awk b/test/zeroe0.awk new file mode 100644 index 0000000..5dc9c6b --- /dev/null +++ b/test/zeroe0.awk @@ -0,0 +1,40 @@ +# From sbohdjal@matrox.com Tue Dec 31 11:41:25 2002 +# Return-Path: +# X-From_: sbohdjal@matrox.com Mon Dec 30 17:34:41 2002 +# Message-Id: <4.3.1.1.20021230101824.00fc4bd8@mailbox.matrox.com> +# Date: Mon, 30 Dec 2002 10:33:10 -0500 +# To: bug-gawk@gnu.org +# From: Serge Bohdjalian +# Subject: GAWK 3.1.1 bug, DJGPP port +# +# When I run the following AWK file... +# +BEGIN { + $0 = "00E0"; + print $0 ", " ($0 && 1) ", " ($0 != ""); + $1 = "00E0"; + print $1 ", " ($1 && 1) ", " ($1 != ""); +} +# +# With the SimTel version of GAWK 3.1.1 for Windows (downloadable from +# ftp://ftp.cdrom.com/pub/simtelnet/gnu/djgpp/v2gnu/), I get the following +# output... +# +# 00E0, 0, 1 +# 00E0, 1, 1 +# +# With the Cygwin version of GAWK 3.1.1 for Windows, I get... +# +# 00E0, 1, 1 +# 00E0, 1, 1 +# +# As far as I know, if "$0" isn't blank, the value of "($0 && 1)" should be +# "1" (true). I get the same problem if I substitute "00E0" with "00E1" to +# "00E9". Other strings don't have have this problem (for example, "00EA"). +# The problem occurs whether I use file input or whether I manually assign +# "$0" (as above). +# +# The problem is also discussed in a comp.lang.awk posting ("Bug in GAWK +# 3.1.1?", Dec. 27, 2002). +# +# -Serge diff --git a/test/zeroe0.ok b/test/zeroe0.ok new file mode 100644 index 0000000..cdf28fb --- /dev/null +++ b/test/zeroe0.ok @@ -0,0 +1,2 @@ +00E0, 1, 1 +00E0, 1, 1 diff --git a/test/zeroflag.awk b/test/zeroflag.awk new file mode 100644 index 0000000..526ed0e --- /dev/null +++ b/test/zeroflag.awk @@ -0,0 +1 @@ +BEGIN { printf("%2.1d---%02.1d\n", 2, 2) } diff --git a/test/zeroflag.ok b/test/zeroflag.ok new file mode 100644 index 0000000..937c0ed --- /dev/null +++ b/test/zeroflag.ok @@ -0,0 +1 @@ + 2--- 2 diff --git a/version.c b/version.c new file mode 100644 index 0000000..695a1e3 --- /dev/null +++ b/version.c @@ -0,0 +1,3 @@ +#include "config.h" + +const char *version_string = "GNU Awk 4.0.1"; diff --git a/version.in b/version.in new file mode 100644 index 0000000..a489761 --- /dev/null +++ b/version.in @@ -0,0 +1,3 @@ +#include "config.h" + +const char *version_string = "@PACKAGE_STRING@"; diff --git a/vms/ChangeLog b/vms/ChangeLog new file mode 100644 index 0000000..3a8279e --- /dev/null +++ b/vms/ChangeLog @@ -0,0 +1,59 @@ +2012-03-28 Arnold D. Robbins + + * 4.0.1: Release tar ball made. + +2012-03-28 Arnold D. Robbins + + * vms-conf.h: Update copyright year. + +2012-03-21 Anders Wallin + + * vmstest.com: Make printfbad3 test work. + +2012-03-20 Arnold D. Robbins + + * vmstest.com: Add printfbad3 test. + +2012-02-10 Arnold D. Robbins + + * vmsbuild.com, descrip.mms, vms-conf.h: Update patch level. + +2011-12-31 Arnold D. Robbins + + * vms_misc.c: [STREQ, STREQN]: Change use of macros to call + strcmp, strncmp, directly. + +2011-11-02 Pat Rankin + + * vms-conf.h (HAVE_SETSID, HAVE_SYS_IOCTL): Add but leave undef'd. + (HAVE_ISWCTYPE, HAVE_ISWLOWER, HAVE_ISWUPPER, HAVE_MBRLEN, + HAVE_MBRTOWC, HAVE_TOWLOWER, HAVE_TOWUPPER, HAVE_WCHAR_H, + HAVE_WCRTOMB, HAVE_WCSCOLL, HAVE_WCTYPE, HAVE_WCTYPE_H, + HAVE_WCTYPE_T): Define as 1 since DEC C supports all these. + + * descrip.mms (replace.obj): Add dependencies for missing_d/*.c. + * vmstest.com (unix_tests): Fix typo in spelling of rtlen01. + +2011-10-30 Pat Rankin + + * vmstest.com (fpat3, fwtest3, getline5, gsubtst7, gsubtst8, + pty1, rtlen, rtlen01, rtlenmb): New tests. + (posix2008sub): Revised test. + +2011-10-25 Anders Wallin + + * vmstest.com (posix2008sub): Added as specific test in order to + use --posix option. + +2011-06-24 Arnold D. Robbins + + * vmsbuild.com (REL, PATCHLVL): Move to 4.0.0. + * descrip.mms (REL, PATCHLVL): Move to 4.0.0. + * vms-conf.h (VERSION, PACKAGE_VERSION): Move to 4.0.0. + * 4.0.0: Remake the tar ball. + +2011-06-23 Arnold D. Robbins + + * ChangeLog.0: Rotated ChangeLog into this file. + * ChangeLog: Created anew for gawk 4.0.0 and on. + * 4.0.0: Release tar ball made. diff --git a/vms/ChangeLog.0 b/vms/ChangeLog.0 new file mode 100644 index 0000000..b635ce3 --- /dev/null +++ b/vms/ChangeLog.0 @@ -0,0 +1,699 @@ +Wed Jun 22 18:04:29 2011 Pat Rankin + + * vmstest.com (msg): Display gawk's version at start of test run. + +Mon Jun 20 20:38:35 2011 Arnold D. Robbins + + * vmstest.com (dfastress): New test. + +Mon Jun 20 20:24:34 2011 Pat Rankin + + * descrip.mms: Remove compilation of hard-locale.c. + * vmsbuild.com: Likewise. + +Tue May 31 23:10:35 2011 Arnold D. Robbins + + * vmstest.com (regrange): New test. + +Thu May 26 22:14:06 2011 Arnold D. Robbins + + * vmstest.com (fpat2): New test. + +Wed May 25 01:31:50 2011 Pat Rankin + + * gawk.hlp: Substantial updates, for first time in 8 years! + + * vmstest.com (fpatnull): New test. + +Sun May 15 19:24:22 2011 Pat Rankin + + * vmstest.com (delargv): New test. + +Fri May 13 18:45:35 2011 Pat Rankin + + * vmstest.com (exit, next): Move from basic to gawk extensions. + (exit: do__exit): Define "gawk" in subroutine to make sure PIPE + uses the local definition instead of some other global one. + + * vms_gawk.c (vms_gawk): Convert /OPTIMIZE into "-O" rather than + to "-W optimize". + + * gawk.cld (gen_pot): Fix typo in name. + +Mon May 9 01:43:40 2011 Pat Rankin + + * vmstest.com (arraysort, delsub, exit, next, ofmta, sortu): New + tests. + (paramdup): Merge with other exit_code 1 tests. + {various}: change several instances of "nl:" to "_NL:" so that all + tests which reference the null device spell it the same way. + +Fri Apr 29 18:10:49 2011 Pat Rankin + + * gawkmisc.vms (os_isatty): New routine. + +Sat Feb 26 18:35:01 2011 Pat Rankin + + * vms_gawk.c, gawk.cld: Add support for new command qualifiers: + /extra_commands="text" -e "awk program text" + /profile[=file] --profile [awkprof.out] + /dump_variables[=file] --dump_variables [awkvars.out] + /optimize, /traditional, /re_interval, /sandbox, /non_decimal_data + New but not documented since not useful for present VMS port: + /characters_as_bytes, /use_lc_numeric, /gen_pot + Revamp several existing qualifiers: + /strict was --compat, now synonym for /traditional + /lint=(warn,fatal,invalid,old) + /lint=warn --lint (same as /lint without any value) + /lint=fatal --lint fatal + /lint=old --lint-old + /lint=(warn,fatal) --lint fatal (warn ignored) + /lint=(warn,old) --lint --lint-old + /lint=(fatal,old) --lint fatal --lint-old + /usage, /version, /copyright try harder to make awk program and + data file be optional since these just give messages and then quit. + (vms_usage): Substitute "GAWK", "DGAWK", or "PGAWK" as appropriate + for command name when issuing the VMS-specific usage message. + * vms.h (CLI$_NEGATED): Define macro (from ). + + * vms_cli.c: Add copyright notice. Remove unused P() macro. + (dcl$present, dcl$get_value, dcl$parse_command): Use lowercase + rather than upper for these system routine names. + +Fri Feb 18 19:24:30 2011 Pat Rankin + + * vmstest.com (beginfile1, dumpvars): New tests. + (lintwarn): Add exit_code 1. + +Wed Feb 16 21:09:50 2011 Arnold D. Robbins + + * vmstest.com (lintwarn): New test. + +Sun Feb 13 18:48:29 2011 Pat Rankin + + * gawkmisc.vms (files_are_same): Update to handle new arguments. + + * vmstest.com (profile1, profile2, profile3): New tests. + (pgawk_tests, profile_tests): New test sets. + (iobug1): Clean up spurious extra output file. Sigh. + + * descrip.mms, vmsbuild.com: Include hard-locale.c in build. + +Sun Feb 13 20:23:57 2011 Eli Zaretskii + + * gawkmisc.vms (files_are_same): Change arguments; call `stat' as + part of the body. + +Sat Feb 12 19:29:41 2011 Pat Rankin + + * redirect.h (snprintf): Declare regardless of HAVE_SNPRINTF or + CRTL_VER_V732. + +Mon Feb 7 22:43:37 2011 Arnold Robbins + + * vmstest.com (negrange): Add new test. + +Sun Feb 6 18:54:20 2011 Pat Rankin + + * vmstest.com (psx96sub, whiny): Remove obsolete tests. + (aadelete1, aadelete2, aarray1, aasort, assorti, fpat1, + indirectcall, patsplit, posix2000sub, range1, sortfor, splitarg4, + switch2): Add new tests. + +Tue Jan 18 17:51:07 2011 Pat Rankin + + * vms_args.c (vms_arg_fixup): If AWK_LIBRARY lacks a value, define + it as "SYS$LIBRARY:" so that the default value of AWKPATH ends + with a valid directory. Needed so that gawk -f no-such-file + will report "file not found" or "no such file or directory" + instead of "file specification syntax error". + + * vms-conf.h: Sync with configh.in; define HAVE_STRCOLL as 1. + + * vmstest.com (fnarray, funsmnam, paramres, parseme): Change these + tests to expect EXIT_CODE 1 rather than EXIT_CODE 2. + +Sat Nov 6 16:33:01 2010 Pat Rankin + + * redirect.h, vms.h: Drop use of P() macro in function prototypes. + * vms_misc.c, vms_popen.c: Likewise. + +Wed Aug 11 17:47:57 2010 Pat Rankin + + * redirect.h (vsnprintf): Move #define into !HAVE_SNPRINTF block. + +Tue Aug 10 12:57:40 2010 Pat Rankin + + * redirect.h: Declare vsnprintf and define it to use missing_d one. + * vms-conf.h: Add #undef template for HAVE_SETENV. + +Mon Aug 9 10:58:03 2010 Arnold Robbins + + * redirect.h: Add decls of setenv, unsetenv, and snprintf to + avoid informational warnings from the compiler about undecleared + functions. + +Thu Aug 5 15:01:55 2010 Arnold Robbins + + * vms-build.com: Correctly build dgawk. + * redirect.h (setenv, unsetenv): Define as macros to get the + replacement versions in missing_d/. + +Mon Mar 8 15:17:41 2010 Pat Rankin + + * vmstest.com (space): handle alternate error reason. + (fmtspcl): suppress this test. + +Wed Mar 3 16:29:10 2010 Pat Rankin + + * vms-conf.h: sync with configh.in; reformat a couple of comments. + (PACKAGE_URL): add #undef as placeholder. + +Wed Jan 6 19:05:05 2010 Pat Rankin + + * vms_fwrite.c (tty_fwrite): Check which_gawk, and stick to + ordinary fwrite() when it's exe_debugging because dgawk uses + other stdio calls besides fwrite for terminal output, and that + wouldn't interleave sanely with tty_fwrite()'s terminal output. + +Wed Jan 6 19:05:05 2010 Pat Rankin + + * awk.h (exe_mode): Define new enum: exe_gawking for regular gawk, + exe_debugging for dgawk, and exe_profiling for pgawk. + (which_gawk): Declare new variable. + * eval.c (which_gawk): Define it. + +Thu May 6 20:55:14 2010 Arnold D. Robbins + + * Release 3.1.8: Release tar file made. + +Tue Apr 20 14:54:03 2010 Pat Rankin + + * vms-conf.h (HAVE_LIBSIGSEGV): Add placeholder; leave undefined. + * vmstest.com (manyfiles): keep going even if gawk fails. + +Thu Apr 1 14:04:17 2010 Pat Rankin + + * vmstest.com (uninit5): fix typo in test name. + +Mon Mar 29 16:26:39 2010 Pat Rankin + + * vms-conf.h (HAVE_USLEEP): define. + * vmstest.com (fcall_exit, fcall_exit2, forref, uninit5): new tests. + * descrip.mms (builtin.obj): add floatmagic.h dependency. + +Mon Mar 8 15:17:41 2010 Pat Rankin + + * vmstest.com (space): handle alternate error reason. + (fmtspcl): suppress this test. + +Wed Mar 3 16:29:10 2010 Pat Rankin + + * vms-conf.h: sync with configh.in; reformat a couple of comments. + (PACKAGE_URL): add #undef as placeholder. + +Tue Jul 21 22:28:56 2009 Arnold D. Robbins + + * Release 3.1.7: Release tar file made. + +Wed Jul 8 18:59:22 2009 Pat Rankin + + * vmstest.com (charset_tests): New list; move various tests from + basic and gawk_ext lists. + (fmtspcl): Move to machine_tests list. + (lc_num1, mbfw1, mbprintf1, rsstart3): Skip these failing tests. + (double1, double2): Likewise. + +Mon Jun 22 00:51:17 2009 Pat Rankin + + * vms_misc.c (vms_open): Explicitly specify "rat=cr" to force + carriage-return-carraige-control record attribute along with + stmlf foramt. gawk failed on an internal redirection attempt + (``print anything > file'') if an earlier version of the output + file existed with conflicting attributes and the program was + built using DECC$SHR run-time library rather than VAXCRTL. + + * vmstest.com: Add over 70 new tests. Overhaul how lists of + tests are specified and executed. Make many similar tests run + with shared commands instead of maintaining separate code for + each one. Put output for 'test' into "_'test'.tmp" instead of + "tmp." so that it's easier to investigate if/when multiple test + failures occur in the same run. + (vms_io2): New test to check the ``print anything > file'' fix. + +Wed Mar 18 18:16:50 2009 Pat Rankin + + * vms-conf.h (EXIT_SUCCESS, EXIT_FAILURE): Define #if !HAVE_STDLIB_H. + (EXIT_FATAL): Define. + +Mon Mar 16 19:09:27 2009 Pat Rankin + + * vms-conf.h: Synchronize with configh.in, + (HAVE_ATEXIT): Define. + +Tue Jan 27 21:49:53 2009 Arnold D. Robbins + + Per Pat Rankin based on changes to awk.h and change in main code + to use EXIT_SUCCESS / EXIT_FAILURE from Toni Schilling + . + + * redirect.h (exit): Remove definition. + * vms_misc.c (vms_exit): Remove code. + +Mon Oct 22 08:49:05 2007 Arnold D. Robbins + + * Release 3.1.6: Release tar file made. + +Wed May 16 19:54:00 2007 Pat Rankin + + * vms-conf.h: re-sync with configh.in. + +Sun Apr 29 18:09:17 2007 Pat Rankin + + * redirect.h: declare snprintf() if CRTL_VER_V732 is defined; + redefining __CRTL_VER in config.h causes to suppress it. + + * vmstest.com (fnarray): exit code has changed to 2. + (pid): target values now passed by command line rather than file. + +Fri Apr 20 16:48:30 2007 Pat Rankin + + * vms-conf.h: #define HAVE_SNPRINTF for V7.3-2 and later CRTL. + * redirect.h: #define snprintf to gawk_snprintf if we're using + missing_d/snprintf.c; avoids diagnostic about its declaration. + +Thu Apr 12 18:59:33 2007 Pat Rankin + + * vms-conf.h: Leave HAVE_MKSTEMP undefined; we want tmpfile(). + +Thu Mar 29 19:30:20 2007 Pat Rankin + + * vms-conf.h: reconcile with configh.in. + + * descrip.mms: compile floatcomp.c; add pgawk target and build + pgawk.exe for `make all'. + * vmsbuild.com: compile floatcomp.c; always build pgawk.exe in + addition to gawk.exe. + +Wed Jul 27 21:31:14 2005 Pat Rankin + + * vmstest.com: Format test group feedback differently (append "...") + to distinguish it from individual test feedback. + (manyfiles): Determine the number of files to use dynamically + instead of using hardcoded 300 in case user's open file quota + is generous enough to support more than that. + (longsub): Add error trap so that failure when gawk is built with + VAXCRTL doesn't cause testing to terminate. + (vms_io1): Invoke with normal Unix-style command line syntax. + (vms_cmd): New test; split off DCL-style command line from vms_io1. + +Tue Jul 26 21:46:16 2005 Arnold D. Robbins + + * Release 3.1.5: Release tar file made. + +Mon May 23 20:54:31 2005 Pat Rankin + + * vms_gawk.c [gawk_cmd, #if __ia64__]: Switch from globalvalue + to strict_refdef and then take gawk_cmd's address during use. + + * vmstest.com (concat1, longsub, arrayprm2, arrayprm3, arryref2, + arryref3, arryref4, arryref5, aryprm1, aryprm2, aryprm3, + aryprm4, aryprm5, aryprm6, aryprm7, aryprm8, concat2, concat3, + delarpm2, delfunc, exitval2, fmttest, fnarray2, fnmisc, fordel, + getline3, gsubasgn, gsubtest, gsubtst2, gsubtst4, gsubtst5, + hex, inputred, iobug1, manglprm, nested, nfneg, noloop1, + noloop2, nulrsend, prec, prtoeval, rstest1, rstest2, rstest3, + rstest4, rstest5, scalar, sortempty, splitarr, strcat1, + subsepnm, synerr1, uninit2, uninit3, uninit4, uninitialized, + unterm, wjposer1, zeroe0): New tests. + +Wed May 18 21:22:09 2005 Pat Rankin + + * vms_gawk.c [#if __ia64__]: Use #pragma extern_model globalvalue + for the declaration of gawk_cmd. + +Mon May 9 21:17:33 2005 Pat Rankin + + * vms-conf.h [#if DECC]: Use #pragma to suppress "new feature in C99" + diagnostic for structure field designator style initialization in + regexec.c. + +Thu May 5 21:17:48 2005 Anders Wallin + + * vms_gawk.c [__ia64__]: Change to lower case, then Itanium + VMS is happy. + +Sun May 1 08:20:00 2005 Pat Rankin + + * vms_gawk.c [gawk_cmd]: Declare as ordinary data symbol rather + than as a fake routine for Itanium. (Can't do that for other + configurations without getting tangled up in compiler-specific + details like `#pragma extern_model' and VAX C's `globalref'.) + +Fri Mar 4 20:46:20 2005 Pat Rankin + + * vms-conf.h: Define VAXCRTL when appropriate; used in builtin.c. + +Sat Feb 19 20:13:28 2005 Pat Rankin + + * vms-conf.h [RE_TOKEN_INIT_BUG]: Define for regcomp.c. + +Wed Feb 16 20:45:21 2005 Pat Rankin + + * vms-conf.h [NO_MBSUPPORT]: Define when compiling with VAX C. + [inline]: Define as empty when compiling with VAX C. + +Thu Jan 20 19:09:52 2005 Pat Rankin + + * vms-conf.h: Synchronize with configh.in. + +Mon Aug 2 12:18:15 2004 Arnold D. Robbins + + * Release 3.1.4: Release tar file made. + +Mon Jun 14 18:40:22 2004 Pat Rankin + + * descrip.mms (dfa.c, dfa.h): reinstate these. + (gettext.h, mbsupport.h): add these. + (patchlev.h): remove this. + + * vmstest.com (longwrds): customize it. + (getline, getline2): replace getline with getline2. + +Mon Jul 7 11:01:43 2003 Arnold D. Robbins + + * Release 3.1.3: Release tar file made. + +Mon Jun 9 22:15:40 2003 Pat Rankin + + * vms-conf.h: Synchronize with current configh.in. + ALLOW_SWITCH: Define this to enable new `switch' feature. + +Wed Mar 19 14:10:31 2003 Arnold D. Robbins + + This time for sure. + -- Bullwinkle + + * Release 3.1.2: Release tar file made. + +Thu Feb 27 17:54:33 2003 Pat Rankin + + * descrip.mms: Revert regex compilation to single file. + vmsbuild.com: Likewise. + +Thu Feb 20 18:06:54 2003 Pat Rankin + + * vms_gawk.c (vms_gawk): Don't check for `RUNUSED' status because + it gets a false match when gawk is invoked via fork+exec. + + * gawk.hlp: Limited updates to the release notes section. + +Tue Feb 4 14:28:06 2003 Arnold D. Robbins + + All relevant files: Copyright year updated to 2003. + +Mon Feb 3 20:37:09 2003 Pat Rankin + + * vms-conf.h (ssize_t): Define as int. + (TIME_T_UNSIGNED): New macro; used in strftime. + * vms_cli.c (Cli_Parse_Command): Increase command buffer size + from 2.5Kb to 8Kb. + + From Steve Pitcher: + * vms_gawk.c (vms_gawk): Don't report "missing required element" + for INSFPRM status unless invoked via a native DCL verb. + + From Jouk Jansen: + * vms-conf.h (CRTL_VER_V731): New macro. + * vms_misc.c (getpgrp): Use it. + +Mon Dec 23 16:53:42 2002 Pat Rankin + + * descrip.mms (AWKOBJ1, AWKOBJ2): Split AWKOBJS into pieces to + avoid line length overflow when creating gawk.opt. + (regcomp.obj, regexec.obj, regex_internal.obj): New targets. + * vmsbuild.com: Likewise. + +Thu Nov 21 19:45:08 2002 Pat Rankin + + * descrip.mms: Update to reflect regex changes; eliminate dfa. + + * vmstest.com (exit_code): Hack to add "EXIT CODE n" record to + output for tests that trigger gawk failure. + +Wed May 1 16:41:32 2002 Arnold D. Robbins + + * Release 3.1.1: Release tar file made. + +Wed Apr 17 15:57:30 2002 Pat Rankin + + * vmstest.com (forsimp, concat1, longsub): New Tests. + (strftime): Revamp test to avoid use of defunct %v extension. + +Sat Dec 22 19:18:31 2001 Pat Rankin + + * redirect.h (tzset): Declare. + +Sun Jun 3 13:04:44 2001 Arnold D. Robbins + + * Release 3.1.0: Release tar file made. And there was + rejoicing. + +Thu Apr 12 18:29:50 2001 Pat Rankin + + * vms_misc.c (open): Add handling for /dev/null and /dev/tty. + (vms_devopen): Remove handling for /dev/null and /dev/tty. + + * vms_misc.c (VMS_stat, VMS_fstat): New functions to work + around old VAXCRTL bugs. + * redirect.h (fstat): Define as VMS_fstat for VAX C or GNU C. + + * vms-conf.h (HAVE_UNISTD_H): Avoid for GNU C. + + * descrip.mms: Synchronize with 3.1.0 sources. + + * vmstest.com: Add many new tests. + (fixup_LRL): New subroutine. + +Thu Apr 5 20:31:22 2001 Pat Rankin + + * vms-conf.h: synchronize with current configh.in. + [NO_ALLOCA]: define instead of C_ALLOCA. + * redirect.h (strcoll): substitute strcmp for VAXCRTL config. + (struct timeval): define. + (gettimeofday): substitute vms_gettimeofday; declare. + + * vms_misc.c (vms_gettimeofday): new function. + * vms_fwrite.c [#if NO_ALLOCA]: fix fake alloca's use of free(). + + * vmsbuild.com: synchronize with current sources. + +Sun Jan 28 15:50:02 2001 Eli Zaretskii + + * gawkmisc.vms (os_restore_mode): New function. + +Sun Dec 3 16:53:37 2000 Arnold D. Robbins + + * gawkmisc.vms (os_setbinmode): new function. + +Tue Nov 7 14:09:14 2000 Arnold D. Robbins + + * gawkmisc.vms (os_is_setuid): new function. + +Wed Jul 30 19:53:52 1997 Arnold D. Robbins + + * Close-on-exec changes: + gawkmisc.vms: (os_close_on_exec, os_isdir): new functions. + +Mon Aug 7 15:23:00 2000 Arnold D. Robbins + + * Release 3.0.6: Release tar file made. + +Sat Jul 15 20:52:09 2000 Pat Rankin + + * vmstest.com (printf1, fusmnam, fnamedat, numindex, + subslash, opasnslf, opasnidx, arynocls, getlnbuf, + arysubnm, fnparydl): New basic tests. + (igncdym): New gawk.extensions test. + (nondec): Old gawk.extensions test commented out. + +Sun Jun 25 15:08:19 2000 Arnold D. Robbins + + * Release 3.0.5: Release tar file made. + +Wed Jun 30 16:14:36 1999 Arnold D. Robbins + + * Release 3.0.4: Release tar file made. This time for sure. + +Fri May 7 20:29:04 1999 Pat Rankin + + * vms-conf.h (__CRTL_VER): Add same override as __VMS_VER. + +Wed May 5 19:10:15 1999 Pat Rankin + + * vmstest.com (nasty, zeroflag, getnr2tm, getnr2tb): New tests. + +Wed Nov 25 17:24:26 1998 Pat Rankin + + * vmstest.com (vms_tests): New general target. + (vms_io1): New specific test. + +Thu May 15 12:49:08 1997 Arnold D. Robbins + + * Release 3.0.3: Release tar file made. + +Mon May 12 18:39:30 1997 Pat Rankin + + * vmstest.com (delarprm, prdupval): new `basic' tests. + (nondec): new `gawk.extensions' test (commented out for now). + (reint): move from `basic' to `gawk.extensions'. + +Mon May 5 21:40:07 1997 Pat Rankin + + * vmstest.com (clobber): new `basic' test. + (pid): new test, replacing `specfile'. + (pipeio2): new for `unix-tests'; can't execute this one under VMS. + +Mon May 5 21:23:52 1997 Pat Rankin + + * vms_args.c (vms_arg_fixup): for the 2>&1 case, don't set the + output filename to "sys$error" because that results in an extra + empty file being created. + + * vms_misc.c (vms_open): explicitly specify stream_lf format + when creating files rather than letting DECC$SHR make a new file + inherit its record format from any earlier version of that file. + + Suggested by Pete Cascio : + + * vms_misc.c (vms_open): use full record sharing options when + reading any record-oriented file, regardless of its organization. + +Mon Apr 21 19:22:12 1997 Pat Rankin + + * vmstest.com (funstack): new `basic' test. + (reint): add missing entry to `basic'. + (pipeio1, specfile, strftlng): move from `basic' to `unix-tests'. + (childin): skip due to known failure. + (specfile): skip due to potentially confusing feedback. + +Thu Apr 24 23:18:04 1997 Arnold D. Robbins + + * vms_popen.c, vms_misc.c, vms_gawk.c, vms_fwrite.c, + vms_args.c: moved to generic GPL statement at top. + +Fri Apr 18 07:55:47 1997 Arnold D. Robbins + + * BETA Release 3.0.34: Release tar file made. + +Wed Apr 2 18:17:30 1997 Pat Rankin + + * descrip.mms, vmsbuild.com (PATCHLVL): update to 3. + + * vmstest.com (nlfldsep, splitvar, intest, nfldstr, nors, + fnarydel, noparms, pipeio1): new tests. + +Wed Jan 15 15:21:01 1997 Pat Rankin + + * redirect.h (stat, fstat): do not declare these functions; + rely on to do so. There are too many DEC C version + variants to handle otherwise. + + From Martin Zinser : + + * descrip.mms (gawk.dvi): update to build in [.doc] directory + using texindex.c retained from an earlier gawk 2.x distribution. + (texindex.exe): don't assume VAX C. + +Wed Dec 25 11:25:22 1996 Arnold D. Robbins + + * Release 3.0.2: Release tar file made. + +Mon Dec 23 20:51:27 1996 Pat Rankin + + * vms_misc.c (vms_bcopy): `bcopy' is defined as this in redirect.h. + +Thu Dec 19 17:49:31 1996 Pat Rankin + + * redirect.h (strcasecmp, strncasecmp, tzset, tzname, + daylight, timezone, altzone, bcopy, popen, pclose, unlink): + New macros to avoid conflict with VMS V7.x DECC$SHR symbols. + (close, dup, dup2, read): Declare with full prototypes. + (fstat, stat): Ditto, and guard against conflicting DEC C + declarations (which might have trailing elipsis). + * vms_misc.c (tzset, tzname, daylight, timezone, altzone): + Suppress these if compiled with VMS_V7 defined [not supported]. + +Mon Dec 16 14:32:08 1996 Pat Rankin + + * vms_popen (popen): Delete unprototyped declaration of strcmp() + to avoid conflict with a strcmp macro in DEC C V5.0 header files. + +Tue Dec 10 23:09:26 1996 Arnold D. Robbins + + * Release 3.0.1: Release tar file made. + +Fri Dec 6 20:55:57 1996 Pat Rankin + + * redirect.h, vms-conf.h: Refine Sep 20th change: include + and in redirect.h rather than vms-conf.h + so that it occurs for VMS POSIX as well as for normal VMS. + +Wed Nov 20 15:47:02 1996 Pat Rankin + + * descrip.mms (LIBOBJS): Rename from GNUOBJS; add random.obj. + (LIBSRC): Rename from GNUSRC; add random.c. + (AWKSRC): Add random.h. + (random.obj, builtin.obj): Depend upon random.h. + * vmsbuild.com: compile random.c, link random.obj. + + * vmstest.com (childin): Split message about expected failure + in order to avoid consecutive tick marks in the quoted string. + +Wed Nov 13 15:32:58 1996 Pat Rankin + + * vmstest.com: New file to execute test suite. + +Fri Nov 8 18:29:42 1996 Pat Rankin + + Revise makefiles so that no editing should be needed. + + * descrip.mms: Use DEC C as the default compiler, since + the same compile and link options for it can be used as-is + on both VAX and Alpha. + (GNUC, VAXC): New `make' macros for specifying an alternate + compiler on the MMS or MMK command line. + (PATCHLVL): Update to 1. + * vmsbuild.com: Make the equivalent changes. + +Mon Oct 28 17:02:39 1996 Pat Rankin + + * vms.h (U_Long, U_Short): Replace u_long and u_short typedefs. + * vms_*.c: Use them. + + * vms.h, vms_*.c: Change SYS$ and LIB$ routines to lower case + equivalents; fully prototype sys$ and lib$ routines rather than + just declare them. + +Fri Sep 20 17:33:05 1996 Pat Rankin + + * vms-conf.h: directly include and . + * vms-conf.h (strftime): delete this macro. + * redirect.h (strftime): define it here instead. + +Fri May 17 09:08:16 1996 Arnold Robbins + + * gawkmisc.vms (envsep): Now initialized to ',' instead of ':', + per email from Pat Rankin. + +Thu Jan 11 15:20:14 1996 Pat Rankin + + * vms-conf.h [#if __DECC]: Changes to support V5.x of DEC C. + (_DECC_V4SOURCE, __SOCKET_TYPEDEFS): Define these to avoid + duplicate u_long and u_short typedefs. + (__VMS_VER): If value indicates VMS V6.2 or later, redefine it to + indicate V6.1 in order to avoid conflicting prototype for getopt. + +Wed Jan 10 22:58:55 1996 Arnold D. Robbins + + * ChangeLog created. diff --git a/vms/descrip.mms b/vms/descrip.mms new file mode 100644 index 0000000..f00921e --- /dev/null +++ b/vms/descrip.mms @@ -0,0 +1,322 @@ +# Descrip.MMS -- Makefile for building GNU awk on VMS. +# +# usage: +# $ MMS /Description=[.vms]Descrip.MMS gawk +# possibly add `/Macro=("GNUC=1")' to compile with GNU C, +# or add `/Macro=("GNUC=1","DO_GNUC_SETUP=1")' to compile with GNU C +# on a system where GCC is not installed as a defined command, +# or add `/Macro=("VAXC=1")' to compile with VAX C, +# or add `/Macro=("VAXC=1","CC=cc/VAXC")' to compile with VAX C on +# a system which has DEC C installed as the default compiler. +# +# gawk.exe : +# This is the default target. DEC C has become the default compiler. +# +# pgawk.exe : +# An alternate version which generates some profiling feedback for +# the awk programs it executes. Included with `make all'. +# +# dgawk.exe : +# An alternate version which supports debugging. +# Included with `make all'. +# +# awkgram.c : +# If you don't have bison but do have VMS POSIX or DEC/Shell, +# change the PARSER and PASERINIT macros to use yacc. If you don't +# have either yacc or bison, you'll have to make sure that the +# distributed version of "awkgram.c" has its modification date later +# than the date of "awkgram.y", so that MMS won't try to build that +# target. If you use bison and it is already defined system-wide, +# comment out the PARSERINIT definition. +# +# command.c : +# Similar to awkgram.c; built from command.y with yacc or bison. +# +# install.help : +# You can make the target 'install.help' to load the VMS help text +# into a help library. Modify the HELPLIB macro if you don't want +# to put entry into the regular VMS library. (If you use an alternate +# help library, it must already exist; this target won't create it.) +# +# gawk.dvi : +# If you have TeX, you can make the target 'gawk.dvi' to process +# _The_GAWK_Manual_ from gawk.texi. You'll need to use a device +# specific post-processor on gawk.dvi in order to get printable data. +# The full output is approximately 325 pages. +# + +# location of various source files, relative to the 'main' directory +VMSDIR = [.vms] +DOCDIR = [.doc] +MISSNGD = [.missing_d] +MAKEFILE = $(VMSDIR)Descrip.MMS + +# debugging &c !'ccflags' is an escape to allow external compile flags +#CCFLAGS = /noOpt/Debug + +# a comma separated list of macros to define +CDEFS = "GAWK","HAVE_CONFIG_H" + +.ifdef GNUC +# assumes VAX +CC = gcc +CFLAGS = /Incl=([],$(VMSDIR))/Obj=[]/Def=($(CDEFS)) $(CCFLAGS) +LIBS = gnu_cc:[000000]gcclib.olb/Library,sys$library:vaxcrtl.olb/Library +.ifdef DO_GNUC_SETUP +# in case GCC command verb needs to be manually defined +.first + set command gnu_cc:[000000]gcc +.endif !DO_GNUC_SETUP +.else !!GNUC +.ifdef VAXC +# always VAX; versions of VAX C older than V3.2 won't work +CC = cc +CFLAGS = /Incl=[]/Obj=[]/Opt=noInline/Def=($(CDEFS)) $(CCFLAGS) +LIBS = sys$share:vaxcrtl.exe/Shareable +.else !!VAXC +# neither GNUC nor VAXC, assume DECC (same for either VAX or Alpha) +CC = cc/DECC/Prefix=All +CFLAGS = /Incl=[]/Obj=[]/Def=($(CDEFS)) $(CCFLAGS) +LIBS = # DECC$SHR instead of VAXCRTL, no special link option needed +.endif !VAXC +.endif !GNUC + + +PARSER = bison +PARSERINIT = set command gnu_bison:[000000]bison +#PARSER = yacc +#PARSERINIT = yacc := posix/run/path=posix """/bin/yacc" +#PARSERINIT = yacc := $shell$exe:yacc + +# this is used for optional target 'install.help' +HELPLIB = sys$help:helplib.hlb +#HELPLIB = sys$help:local.hlb + +# +######## nothing below this line should need to be changed ######## +# + +ECHO = write sys$output +NOOP = continue + +# object files +GAWKOBJ = eval.obj,profile.obj +PGAWKOBJ = eval_p.obj,profile_p.obj +DGAWKOBJ = eval_d.obj,profile.obj,command.obj,debug.obj +AWKOBJ1 = array.obj,awkgram.obj,builtin.obj,dfa.obj,ext.obj,\ + field.obj,floatcomp.obj,gawkmisc.obj,getopt.obj,getopt1.obj,\ + io.obj +AWKOBJ2 = main.obj,msg.obj,node.obj,random.obj,re.obj,\ + regex.obj,replace.obj,version.obj +AWKOBJS = $(AWKOBJ1),$(AWKOBJ2) + +# VMSOBJS +# VMS specific stuff +VMSCODE = vms_misc.obj,vms_popen.obj,vms_fwrite.obj,vms_args.obj,\ + vms_gawk.obj,vms_cli.obj +VMSCMD = gawk_cmd.obj # built from .cld file +VMSOBJS = $(VMSCODE),$(VMSCMD) + +# primary source files +AWKSRC = array.c,builtin.c,dfa.c,eval.c,eval_p.c,ext.c,field.c,\ + floatcomp.c,gawkmisc.c,getopt.c,getopt1.c,io.c,main.c,\ + msg.c,node.c,profile.c,profile_p.c,random.c,re.c,regcomp.c,\ + regex.c,regex_internal.c,regexec.c,replace.c,version.c + +DBGSRC = eval_d.c,debug.c,command.y,cmd.h + +ALLSRC = $(AWKSRC),awkgram.y,awk.h,custom.h,dfa.h,getopt.h,\ + gettext.h,mbsupport.h,protos.h,random.h + +VMSSRC = $(VMSDIR)gawkmisc.vms,$(VMSDIR)vms_misc.c,$(VMSDIR)vms_popen.c,\ + $(VMSDIR)vms_fwrite.c,$(VMSDIR)vms_args.c,$(VMSDIR)vms_gawk.c,\ + $(VMSDIR)vms_cli.c +VMSHDRS = $(VMSDIR)redirect.h,$(VMSDIR)vms.h,$(VMSDIR)fcntl.h,\ + $(VMSDIR)varargs.h,$(VMSDIR)unixlib.h +VMSOTHR = $(VMSDIR)descrip.mms,$(VMSDIR)vmsbuild.com,$(VMSDIR)version.com,\ + $(VMSDIR)gawk.hlp + +DOCS= $(DOCDIR)gawk.1,$(DOCDIR)gawk.texi,$(DOCDIR)texinfo.tex + +# Release of gawk +REL=4.0 +PATCHLVL=1 + +# generic target +all : gawk,pgawk,dgawk + $(NOOP) + +# dummy target to allow building "gawk" in addition to explicit "gawk.exe" +gawk : gawk.exe + $(ECHO) " GAWK " +pgawk : pgawk.exe + $(ECHO) " PGAWK " +dgawk : dgawk.exe + $(ECHO) " DGAWK " + +# rules to build gawk +gawk.exe : $(GAWKOBJ) $(AWKOBJS) $(VMSOBJS) gawk.opt + $(LINK) $(LINKFLAGS) gawk.opt/options + +# rules to build pgawk and dgawk +pgawk.exe : $(PGAWKOBJ) $(AWKOBJS) $(VMSOBJS) pgawk.opt + $(LINK) $(LINKFLAGS) pgawk.opt/options +dgawk.exe : $(DGAWKOBJ) $(AWKOBJS) $(VMSOBJS) dgawk.opt + $(LINK) $(LINKFLAGS) dgawk.opt/options + +gawk.opt : $(MAKEFILE) # create linker options file + open/write opt gawk.opt ! ~ 'cat <gawk.opt' + write opt "! GAWK -- GNU awk" + @ write opt "$(GAWKOBJ)" + @ write opt "$(AWKOBJ1)" + @ write opt "$(AWKOBJ2)" + @ write opt "$(VMSOBJS)" + @ write opt "psect_attr=environ,noshr !extern [noshare] char **" + @ write opt "stack=48 !preallocate more pages (default is 20)" + @ write opt "iosegment=128 !ditto (default is 32)" + write opt "$(LIBS)" + write opt "identification=""V$(REL).$(PATCHLVL)""" + close opt + +pgawk.opt : $(MAKEFILE) # create linker options file + open/write opt pgawk.opt + write opt "! PGAWK -- GNU awk w/ run-time profiling" + @ write opt "$(PGAWKOBJ)" + @ write opt "$(AWKOBJ1)" + @ write opt "$(AWKOBJ2)" + @ write opt "$(VMSOBJS)" + @ write opt "psect_attr=environ,noshr !extern [noshare] char **" + @ write opt "stack=48 !preallocate more pages (default is 20)" + @ write opt "iosegment=128 !ditto (default is 32)" + write opt "$(LIBS)" + write opt "identification=""V$(REL).$(PATCHLVL)""" + close opt + +dgawk.opt : $(MAKEFILE) # create linker options file + open/write opt dgawk.opt + write opt "! DGAWK -- GNU awk w/ debugging" + @ write opt "$(DGAWKOBJ)" + @ write opt "$(AWKOBJ1)" + @ write opt "$(AWKOBJ2)" + @ write opt "$(VMSOBJS)" + @ write opt "psect_attr=environ,noshr !extern [noshare] char **" + @ write opt "stack=48 !preallocate more pages (default is 20)" + @ write opt "iosegment=128 !ditto (default is 32)" + write opt "$(LIBS)" + write opt "identification=""V$(REL).$(PATCHLVL)""" + close opt + +vms_misc.obj : $(VMSDIR)vms_misc.c +vms_popen.obj : $(VMSDIR)vms_popen.c +vms_fwrite.obj : $(VMSDIR)vms_fwrite.c +vms_args.obj : $(VMSDIR)vms_args.c +vms_gawk.obj : $(VMSDIR)vms_gawk.c +vms_cli.obj : $(VMSDIR)vms_cli.c +$(VMSCODE) : awk.h config.h $(VMSDIR)redirect.h $(VMSDIR)vms.h + +gawkmisc.obj : gawkmisc.c $(VMSDIR)gawkmisc.vms + +$(AWKOBJS) : awk.h gettext.h mbsupport.h regex.h dfa.h \ + config.h $(VMSDIR)redirect.h +$(GAWKOBJ) : awk.h config.h $(VMSDIR)redirect.h +$(PGAWKOBJ) : awk.h config.h $(VMSDIR)redirect.h +$(DGAWKOBJ) : awk.h config.h $(VMSDIR)redirect.h +random.obj : random.h +builtin.obj : floatmagic.h random.h +awkgram.obj : awkgram.c awk.h +dfa.obj : dfa.c dfa.h +regex.obj : regex.c regcomp.c regex_internal.c regexec.c regex.h regex_internal.h +command.obj,debug.obj : cmd.h +replace.obj : replace.c $(MISSNGD)system.c $(MISSNGD)memcmp.c \ + $(MISSNGD)memcpy.c $(MISSNGD)memset.c $(MISSNGD)memmove.c \ + $(MISSNGD)strncasecmp.c $(MISSNGD)strerror.c \ + $(MISSNGD)strftime.c $(MISSNGD)strchr.c $(MISSNGD)strtod.c \ + $(MISSNGD)strtoul.c $(MISSNGD)tzset.c $(MISSNGD)mktime.c \ + $(MISSNGD)snprintf.c $(MISSNGD)getaddrinfo.c $(MISSNGD)usleep.c \ + $(MISSNGD)setenv.c $(MISSNGD)strcoll.c $(MISSNGD)wcmisc.c + +# bison or yacc required +awkgram.c : awkgram.y # foo.y :: yacc => y[_]tab.c, bison => foo_tab.c + @- if f$search("ytab.c") .nes."" then delete ytab.c;* !POSIX yacc + @- if f$search("y_tab.c") .nes."" then delete y_tab.c;* !DEC/Shell yacc + @- if f$search("awkgram_tab.c").nes."" then delete awkgram_tab.c;* !bison + - $(PARSERINIT) + $(PARSER) $(YFLAGS) $< + @- if f$search("ytab.c") .nes."" then rename/new_vers ytab.c $@ + @- if f$search("y_tab.c") .nes."" then rename/new_vers y_tab.c $@ + @- if f$search("awkgram_tab.c").nes."" then rename/new_vers awkgram_tab.c $@ +command.c : command.y + @- if f$search("ytab.c") .nes."" then delete ytab.c;* + @- if f$search("y_tab.c") .nes."" then delete y_tab.c;* + @- if f$search("command_tab.c").nes."" then delete command_tab.c;* + - $(PARSERINIT) + $(PARSER) $(YFLAGS) $< + @- if f$search("ytab.c") .nes."" then rename/new_vers ytab.c $@ + @- if f$search("y_tab.c") .nes."" then rename/new_vers y_tab.c $@ + @- if f$search("command_tab.c").nes."" then rename/new_vers command_tab.c $@ + +config.h : $(VMSDIR)vms-conf.h + copy $< $@ + +$(VMSCMD) : $(VMSDIR)gawk.cld + set command $(CLDFLAGS)/object=$@ $< + +# special target for loading the help text into a VMS help library +install.help : $(VMS)gawk.hlp + library/help $(HELPLIB) $< /log + +# miscellaneous other targets +tidy : + - if f$search("*.*;-1").nes."" then purge + - if f$search("[.*]*.*;-1").nes."" then purge [.*] + +clean : + - delete *.obj;*,gawk.opt;*,pgawk.opt;*,dgawk.opt;* + +spotless : clean tidy + - if f$search("config.h").nes."" then rename config.h config.h-old/New + - if f$search("gawk.exe").nes."" then delete gawk.exe;* + - if f$search("pgawk.exe").nes."" then delete pgawk.exe;* + - if f$search("dgawk.exe").nes."" then delete dgawk.exe;* + - if f$search("gawk.dvi").nes."" then delete gawk.dvi;* + - if f$search("[.doc]texindex.exe").nes."" then delete [.doc]texindex.exe;* + +# +# Note: this only works if you kept a copy of [.support]texindex.c +# from a gawk 2.x distribution and put it into [.doc]texindex.c. +# Also, depending on the fonts available with the version of TeX +# you have, you might need to edit [.doc]texinfo.tex and change +# the reference to "lcircle10" to be "circle10". +# +# build gawk.dvi from within the 'doc' subdirectory +# +gawk.dvi : [.doc]texindex.exe [.doc]gawk.texi + @ set default [.doc] + @ write sys$output " Warnings from TeX are expected during the first pass" + TeX gawk.texi + mcr []texindex gawk.cp gawk.fn gawk.ky gawk.pg gawk.tp gawk.vr + @ write sys$output " Second pass" + TeX gawk.texi + mcr []texindex gawk.cp gawk.fn gawk.ky gawk.pg gawk.tp gawk.vr + @ write sys$output " Third (final) pass" + TeX gawk.texi + -@ purge + -@ delete gawk.lis;,.aux;,gawk.%%;,.cps;,.fns;,.kys;,.pgs;,.toc;,.tps;,.vrs; + @ rename/new_vers gawk.dvi [-]*.* + @ set default [-] + +# Note: [.doc]texindex.c is not included with the gawk 3.x distribution. +# Expect lots of "implicitly declared function" diagnostics from DEC C. +# +[.doc]texindex.exe : [.doc]texindex.c + @ set default [.doc] + $(CC) /noOpt/noList/Define=("lines=tlines") texindex.c + @ open/Write opt texindex.opt + @ write opt "texindex.obj" + @ write opt "$(LIBS)" + @ close opt + $(LINK) /noMap/Exe=texindex.exe texindex.opt/Options + -@ delete texindex.obj;*,texindex.opt;* + @ set default [-] + +#eof diff --git a/vms/fcntl.h b/vms/fcntl.h new file mode 100644 index 0000000..d975db7 --- /dev/null +++ b/vms/fcntl.h @@ -0,0 +1,10 @@ +/* "fcntl.h" -- constants for BSD-style I/O routines (ala VAX C's ) */ +#define O_RDONLY 0 +#define O_WRONLY 1 +#define O_RDWR 2 +#define O_NDELAY 4 +#define O_NOWAIT 4 +#define O_APPEND 8 +#define O_CREAT 0x0200 +#define O_TRUNC 0x0400 +#define O_EXCL 0x0800 diff --git a/vms/gawk.cld b/vms/gawk.cld new file mode 100644 index 0000000..2848e7e --- /dev/null +++ b/vms/gawk.cld @@ -0,0 +1,79 @@ +! Gawk.Cld -- command defintion for GAWK +! Pat Rankin, Nov'89 +! [ revised for 2.12, May'91 ] +! [ revised for 4.0.0, Feb'11 ] +! +! This command definition is compiled into an object module which is +! linked into all three programs, GAWK, DGAWK, and PGAWK, and it is +! not able to use syntax-switching qualifers to invoke the different +! images gawk.exe, dgawk.exe, and pgawk.exe. To use dgawk or pgawk +! when this command definition is installed as a native command, use +! $ define gawk location:dgawk.exe +! or $ define gawk location:pgawk.exe +! + module Gawk_Cmd +define verb GAWK + synonym AWK +! image gawk !usage $ DEFINE GAWK disk:[directory]GAWK + parameter p1, value(required,list), label=gawk_p1, prompt="data file(s)" + qualifier input, value(required,list,type=$infile), label=progfile + qualifier commands, value(required), label=program + qualifier extra_commands, value(required), label=moreprog + qualifier field_separator, value(required), label=field_sep + qualifier variables, value(required,list) + qualifier usage + qualifier copyright + qualifier version + qualifier lint, value(list,type=lint_keywords) + qualifier posix + qualifier strict, negatable !synonym for /traditional + qualifier traditional, negatable + qualifier re_interval, negatable !only used with /traditional + qualifier sandbox + qualifier debug, negatable !obsolete; debug via separate DGAWK program + qualifier output, value(type=$outfile,default="SYS$OUTPUT") + qualifier optimize, negatable !actually on always; negation is ignored + qualifier profile, value(type=$outfile,default="awkprof.out") + qualifier dump_variables, value(type=$outfile,default="awkvars.out") + qualifier non_decimal_data + qualifier characters_as_bytes + qualifier use_lc_numeric + qualifier gen_pot + qualifier reg_expr, value(type=reg_expr_keywords) !(OBSOLETE) + disallow progfile and program !or not progfile and not program + !disallow lint.warn and (lint.fatal or lint.invalid) +define type lint_keywords + keyword warn, default + keyword fatal !lint warnings terminate execution + keyword invalid !warn about invalid constructs but not extensions + keyword old !warn about constructs not available in original awk +define type reg_expr_keywords + keyword awk + keyword egrep, default !synonym for 'posix' + keyword posix !equivalent to 'egrep' +! +! p1 = data file list (possibly including 'var=value' contructs) +!note: parameter required; use 'sys$input:' to read data from 'stdin' +! /input = program source file ('-f progfile') +! /commands = program source text ('program') +!note: either input or commands, but not both; if neither, usage message given +! /extra_commands = additional program source text; may be combined with /input +! /field_separator = character(s) delimiting record fields; default is "[ \t]" +! /reg_expr = obsolete +! /variables = list of 'var=value' items for assignment prior to BEGIN +! /posix = force POSIX compatability mode operation +! /sandbox = disable I/O redirection and use of system() to execute commands +! /strict = synonym for /traditional +! /traditional = force compatability mode operation (UN*X SYS V, Release 4) +! /re_interval = for /traditional, regular expressions allow interval ranges +! /output = destination for print,printf (default is sys$output: ie, 'stdout') +! /lint = scan the awk program for possible problems and warn about them +! /optimize = parse-time evaluation of constant [sub-]expressions only +! /debug = debugging mode; no-op unless program built using `#define DEBUG' +! /dump_var = at program termination, write out final values for all variables +! /profile = collect all parts of the parsed awk program into awkprof.out +!note: use separate pgawk program to collect run-time execution profiling +! /usage = display 'usage' reminder [describing this VMS command syntax] +! /version = show program version and quit; also shows copyright notice +! /copyright = show abbreviated edition of FSF's copyright notice and quit +! diff --git a/vms/gawk.hlp b/vms/gawk.hlp new file mode 100644 index 0000000..4b82e7e --- /dev/null +++ b/vms/gawk.hlp @@ -0,0 +1,1676 @@ +! Gawk.Hlp +! Pat Rankin, Jun'90 +! revised, Jun'91 +! revised, Jul'92 +! revised, Jan'95 +! revised, Apr'97 +! revised, Jan'03 +! revised, May'11 +! Online help for GAWK. +! +1 GAWK + GAWK is GNU awk, the Free Software Foundation's implementation of + the awk programming language. awk is an interpretive language which + can handle many data-reformatting jobs with just a few lines of code. + It has powerful string manipulation and pattern matching capabilities + built in. This version is compatible with POSIX 1003.2 awk. + + The VMS version of GAWK supports both the original UN*X-style command + interface and a DCL interface. The only setup requirement for GAWK + is to define it as a 'foreign' command: a DCL symbol with a value + which begins with '$'. + $ GAWK :== $disk:[directory]GAWK +2 GNU_syntax + GAWK's UN*X-style interface uses the 'dash' convention for specifying + options and uses spaces to separate multiple arguments. + + There are two main alternatives, depending on how the awk program is + to be passed to GAWK. Both alternatives share most options. + + Usage: $ gawk [-Wopts] [-F fs] [-v var=val] -f progfile [--] file ... + or $ gawk [-Wopts] [-F fs] [-v var=val] [--] "program" file ... + + The options are case-sensitive. On VMS, the DCL command interpreter + converts unquoted text into uppercase before passing it to the running + program. However, GAWK is written in 'C' and the C Run-Time Library + (VAXCRTL or DECC$SHR) converts unquoted text into *lowercase*. + Therefore, the -Fval and -W options must be enclosed in quotes. +3 options + -d[file] dump variable values into file (default is awkvars.out + if not specified) upon program completion + -e program_text additional program text, as a quoted string, for use + in combination with -f + -f file use the specified file as the awk program source; if + more than one instance of -f is used, each file will + be read in succession + -Fstring define a value for the FS variable (field separator) + -O optimize; of limited use + -p[file] write program execution profiling into file (default + is awkprof.out if not specified) + -v var=val assign a value of 'val' to the variable 'var' + -W'options' additional gawk-specific options; multiple values may + be separated by commas, or by spaces if they're quoted, + or mulitple occurrences of -W may be used. + -Wcopyright display an abbreviated version of the GNU copyright + information + -Whelp list command line options (supersedes -Wusage) + -Wlint warn about suspect or non-portable awk program code + -Wlint=fatal treat lint warnings as errors + -Wlint-old warn about constructs not available in original awk + -Wposix traditional mode with additional restrictions + -Wre-interval evaluate '{' and '}' as intervals in regular expressions + -Wtraditional use awk compatibility mode to disable GAWK extensions + and get the behavior of UN*X awk. + -Wversion display program version number + -- don't check further arguments for leading dash +3 program_text + If the '-f file' option is not used on the command line, then the + first "non-dash" argument is assumed to be a string of text containing + the awk source program. Here is a complete sample program: + $ gawk -- "BEGIN {print ""\nHello, World!\n""}" + This program would print a blank line (based on first "\n"), followed + by a line reading "Hello, World!", followed by another blank line + (since awk's 'print' statement includes the trailing 'newline'). + + On VMS, to include a quote character inside of a quoted string, two + successive quotes ("") must be used. +3 data_files + After all dash-options are examined, and after the program text if + there were no occurrences of the -f option, remaining (space separated) + command line arguments are considered to be data files for the awk + program to process. If any of these actually contains an equals sign + (=), then it is interpreted as a variable assignment instead of a data + file. The syntax is 'variable_name=value'. For example, the command + $ gawk -f myprog.awk infile.one flag=2 start=0 infile.two + would read file 'infile.one' for the program in 'myprog.awk', then it + would set 'flag' to 2 and 'start' to 0, and finally it would read file + 'infile.two' for the program. Note that in a case like this, the two + assignments actually occur after the first file has been processed, + not at program startup when the command line is first scanned. +3 IO_redirection + The command parsing in the VMS implementation of GAWK does some + emulation of a UN*X-style shell, where certain characters on the + command line have special meaning. In particular, the symbols '<', + '>', '|', '*', and '?' receive special handling before the main part + of the program has a chance to see them. The symbols '<' and '>' + perform some file manipulation from the command line: + + nfile create 'nfile' as 'stdout' [SYS$OUTPUT], in stream-lf format + >>ofile append to 'ofile' for 'stdout'; create it if necessary + >&efile point 'stderr' [SYS$ERROR] at 'efile', but don't open it yet + >$vfile create 'vfile' as 'stdout', using RMS attributes appropriate + for a standard text file (variable length records with + implied carriage control) + >+bfile create 'bfile' as 'stdout' using binary mode + 2>&1 route error messages into the regular output stream + 1>&2 send output data to the error destination + <- error; closure of stdin or stdout from cmd line not supported + >>$vfile incorrect; would be interpreted as file "$vfile" in stream-lf + format rather than as file "vfile" in RMS 'text' format + | error; command line pipes not supported +3 wildcard_expansion + The command parsing in the VMS implementation of GAWK does some + emulation of a UN*X-style shell, where certain characters on the + command line have special meaning. In particular, the symbols '<', + '>', '*', '%', and '?' receive special handling before the main part + of the program has a chance to see them. The symbols '*', '%' and '?' + are used as wildcards in filenames. '*' and '%' have their usual VMS + meanings of multiple character and single character wildcards, + respectively, and '?' is also treated as a single character wildcard. + Wildcard expansion only works for filenames specified in native VMS + filename syntax (eg, "[-.sibling]*"), not for ones specified pseudo- + Unix syntax (eg, "../sibling/*"). + + When a command line argument that should be a filename contains any + of the wildcard characters, a directory lookup is attempted for files + which match the specified pattern. If one or more matching files are + found, those filenames are put into the command line in place of the + original pattern. If no matching files are found, the original + pattern is left in place. +2 DCL_syntax + GAWK's DCL-style interface is more or less a standard DCL command, with + one required parameter. Multiple values--when present--are separated + by commas. + + There are two main alternatives, depending on how the awk program is + to be passed to GAWK. Both alternatives share most options. + + Usage: GAWK /COMMANDS="awk program text" data_file[,data_file,...] + or GAWK /INPUT=awk_file data_file[,"Var=value",data_file,...] + ( or GAWK /INPUT=(awk_file1,awk_file2,...) data_file[,...] ) +3 Parameter + data_file[,datafile,...] (data_file data_file ...) + data_file[,"Var=value",...,data_file,...] (data_file Var=value &c) + + Data file(s) for the awk program to process. If any of these + actually contains an equals sign (=), then it is interpreted as + a variable assignment instead of a data file. The syntax is + "variable_name=value". Quotes are required for non-file parameters. + + For example, the command + $ gawk/input=myprog.awk infile.one,"flag=2","start=0",infile.two + would read file 'infile.one' for the program in 'myprog.awk', then it + would set 'flag' to 2 and 'start' to 0, and finally it would read file + 'infile.two' for the program. Note that in a case like this, the two + assignments actually occur after the first file has been processed, + not at program startup when the command line is first scanned. + + Wildcard file lookups are attempted on data file specifications. See + subtopic 'GAWK GNU_syntax wildcard_expansion' for details. + + At least one data_file parameter value is required. An exception is + made if /usage, /version, or /copyright is specified *and* if GAWK is + defined as a 'foreign' command rather than a 'native' DCL command. +3 Qualifiers +/COMMANDS + /COMMANDS="awk program text" (-- "awk program text") + + For short programs, it is possible to include the complete program + on the command line. The quotes are required. Here is a complete + sample program: + $ gawk/commands="BEGIN {print ""\nHello, World!\n""}" NL: + This program would print a blank line (based on first "\n"), followed + by a line reading "Hello, World!", followed by another blank line + (since awk's 'print' statement includes the trailing 'newline'). + + To include a quote character inside of a quoted string, two + successive quotes ("") must be used. + + Either /COMMANDS or /INPUT (but not both) must be supplied. +/INPUT + /INPUT=(awk_file1,awk_file2) (-f awk_file1 -f awk_file2) + + Used to specify one or more files containing the source code of + the awk program. If more than one file is used, separate them + with commas and enclose the list in parentheses. + + Multiple source files are processed in order as if they had been + concatenated together. + + Either /INPUT or /COMMANDS (but not both) must be supplied unless + one of /VERSION, /COPYRIGHT, and /USAGE is used. +/EXTRA_COMMANDS + /EXTRA_COMMANDS="awk program text" (-E "awk program text") + + Add more program text, for use in combination with /INPUT. Unlike + Un*x or GNU syntax processing of VMS GAWK where multiple instances of + -f file and -e text can be interspersed, DCL command processing of + VMS GAWK allows only one /EXTRA_COMMANDS="text" qualifier and handles + it before /INPUT=(file,...). +/FIELD_SEPARATOR + /FIELD_SEPARATOR="FS_value" (-F"FS_value") + + Assign a value to the built in variable FS (field separator). +/VARIABLES + /VARIABLES=("Var1=val1","Var2=val2",...) (-v Var1=val1 -v Var2=val2) + + Assign value(s) to the specified variable(s). +/OPTIMIZE + /[NO]OPTIMIZE (-"O" option) + + Perform some relatively minor optimizations on the source code as it + is read in; primarily constant folding. Default is /NOOPTIMIZE but + presently optimization is always enabled and explicitly negating it + has no effect. This may change when/if more elaborate optimizations + are implemented. +/PROFILE + /PROFILE[=file] (-p[file]) + + Write profiling feedback into the specified file. If no file name is + specified, awkprof.out in the current directory is used. +/DUMP_VARIABLES + /DUMP_VARIABLES[=file] (-d[file]) + + Print a sorted list of global variables, their types, and final values + to the specified file. If no file name is specified, awkvars.out in + the current directory is used. +!-/REG_EXPR +!- /REG_EXPR={AWK | EGREP | POSIX} (-a vs -e options [obsolete]) +!- +!- This qualifier is obsolete and has no effect. +/POSIX + /[NO]POSIX (-"Wposix" option) + + Use POSIX compatibility mode (/posix) and suppress GAWK extensions. + The default is /NOPOSIX. Slightly more restrictive than /strict. +/TRADITIONAL + /[NO]TRADITIONAL (-"Wtraditional" option) + + Use strict awk compatibility mode (/traditional) and suppress GAWK + extensions. Supersedes /STRICT. The default is /NOTRADITIONAL. +/STRICT + /[NO]STRICT (-"Wtraditional" option) + + Use strict awk compatibility mode (/strict) and suppress GAWK + extensions. Superseded by /TRADITIONAL. The default is /NOSTRICT. +/RE_INTERVAL + /RE_INTERVAL (-"Wre-interval" option) + + Allow interval expressions in regexps (regular expressions). GAWK + always accepts intervals in normal mode; /RE_INTERVAL can be used to + enable them in strict (/TRADITIONAL) compatability mode. +/SANDBOX + /SANDBOX (-"Wsandbox" option) + + Disables the system() function, input redirections with getline, + output redirections with print and printf, and dynamic extensions. +/NON_DECIMAL_DATA + /NON_DECIMAL_DATA (-"Wnon-decimal-data" option) + + Enable automatic interpretation of octal and hexadecimal values in + input data. Use with care. +/LINT + /[NO]LINT[=(WARN,OLD,FATAL)] (-"Wlint" and -"Wlint-old" options) + + Check the awk program cafefully for potential problems that might + be encountered if it were to be used with other awk implementations, + and print warnings for anything found. The default in /NOLINT. + + /LINT without a value is equivalent to /LINE=WARN. /LINT=OLD warns + about constructs which wouldn't work with /TRADITIONAL. /LINT=FATAL + turns lint warnings into errors which cause GAWK to terminate. +!- /LINT=INVALID is accepted but isn't documented here. +!three undocumented qualifiers; judged not useful for VMS +!- /CHARACTERS_AS_BYTES +!- /CHARACTERS_AS_BYTES (-"Wcharacters-as-bytes" option) +!- /USE_LC_NUMERIC +!- /USE_LC_NUMERIC (-"Wuse-lc-numeric" option) +!- /GEN_POT +!- /GEN_POT (-"Wgen-pot" option) +/VERSION + /VERSION (-"Wversion" option) + + Print GAWK's version number and then terminate. Includes copyright + notice. +/COPYRIGHT + /COPYRIGHT (-"Wcopyright" option) + + Print a brief version of GAWK's copyright notice and then terminate. +/USAGE + /USAGE (comparable to -"Whelp" option) + + Print a compact summary of the command line options. + + After the 'usage' message is printed, GAWK terminates regardless + of any other command line options. +/OUTPUT + /OUTPUT=out_file (>$out_file) + + Write program output into 'out_file'. The default is SYS$OUTPUT. +2 awk_language + An awk program consists of one or more pattern-action pairs, sometimes + referred to as "rules". For each record of an input (data) file, the + rules are checked sequentially. Any pattern which matches the input + record triggers that rule's action. Actions are instructions which + resemble statements in the 'C' programming language. Patterns come + in several varieties, including field comparisons, regular expression + matching, and special cases defined by reserved keywords. + + All awk keywords and variables are case-sensitive. Text matching is + also sensitive to character case unless the builtin variable IGNORECASE + is set to a non-zero value. +3 rules + The syntax for a pattern-action 'rule' is simply + PATTERN { ACTION } + where the braces ({}) are required punctuation for the action. + Semicolons (;) or 'newlines' (ie, having the text on a separate line) + delimit multiple rules and also multiple actions within a given rule. + Either the pattern or the action may be omitted; an empty pattern + matches every record of the input file; a missing action (not an empty + action inside of braces), is an implicit request to print the current + record; an empty action (ie, {}) is legal but not very useful. +3 patterns + There are several types of patterns available for awk rules. + + expression an 'expression' is something to be evaluated (perhaps + a comparison or function call) which will + be considered true if non-zero (for numeric + results) or if non-null (for strings) + /regular_expression/ slashes (/) delimit a regular expression + which is used as a pattern + pattern1, pattern2 a pair of patterns separated by a comma (,), + which causes a range of records to trigger + the associated action; the records which + match the patterns are included in the range + an omitted pattern (in this text, the string '' + is displayed, but in an awk program, it + would really be blank) matches every record + BEGIN keyword for specifying a rule to be executed prior to + reading the 1st record of the 1st input file + END keyword for specifying a rule to be executed after + handling the last input record of last file + BEGINFILE gawk-specific keyword for specifying a rule to be + executed when a file from the command line + has just been opened, before attempting to + read its first record + ENDFILE gawk-specific keyword for specifying a rule to be + executed after the last record of a file + from the command has been processed by any + other patterns and actions +4 BEGINFILE + Normally a file open attempt which fails will generate an error + and cause GAWK to terminate. However, if your program has a + BEGINFILE rule, failed open attempts will set ERRNO to a non-null + value and execute the BEGINFILE rule's actions. You can check + for that condition and use the 'nextfile' statement to skip files + which couldn't be opened. Note that when executing the BEGINFILE + rule for a failed open attempt, allowing the actions to finish + without using 'nextfile' will result in an error just like for a + program which has no BEGINFILE rule. +4 examples + Some example patterns (mostly with the corresponding actions omitted) + + NF > 0 # comparison expression: matches non-null records + $0 # implied comparison: also matches non-null records + $2 > 1000 && sum <= 999999 # slightly more elaborate expression + /x/ # regular expression matching any record with an 'x' in it + /^ / # reg-expr matching records beginning with a space + $1 == "start", $NF == "stop" # range pattern for input in which + some data lines begin with 'start' and/or end with + 'stop' in order to collect groups of records + { sum += $1 } # null pattern: it's action (add field #1 to + variable 'sum') would be executed for every record + BEGIN { sum = 0 } # keyword 'BEGIN': perform this action before + reading the input file (note: initialization to 0 is + unnecessary in awk) + END { print "total =", sum } # keyword 'END': perform this + action after the last input record has been processed + # two different ways to handle the start of an input file: + FNR == 1 { print FILENAME } # print name after reading first record + BEGINFILE { print FILENAME } # print name before reading first record +3 actions + An 'action' is something to do when a given record has matched the + corresponding pattern in a rule. In general, actions resemble 'C' + statements and expressions. The action in a rule must be enclosed + in braces ({}). + + Each action can contain more than one statement or expression to be + executed, provided that they're separated by semicolons (;) and/or + on separate lines. + + An omitted action is equivalent to + { print $0 } + which prints the current record. +3 operators + Relational operators + == compare for equality + != compare for inequality + <, <=, >, >= numerical or lexical comparison (less than, less or + equal, greater than, greater or equal, respectively) + ~ match against a regular expression + !~ match against a regular expression, but accept failed matches + instead of successful ones + Arithmetic operators + + addition + - subtraction + * multiplication + / division + % remainder + ^, ** exponentiation ('**' is a synonym for '^', unless POSIX + compatibility is specified, in which case it's invalid) + Boolean operators (aka Logical operators) + a value is considered false if it's 0 or a null string, + it is true otherwise; the result of a boolean operation + (and also of a comparison operation) will be 0 when false + or 1 when true + || or [expression (a || b) is true if either a is true or b + is true or both a and b are true; it is false otherwise; + b is not evaluated unless a is false (ie, short-circuit)] + && and [expression (a && b) is true if both a and b are true; + it is false otherwise; b is only evaluated if a is true] + ! not [expression (!a) is true if a is false, false otherwise] + in array membership; the keyword 'in' tests whether the value + on the left represents a current subscript in the array + named on the right + Conditional operator + ? : the conditional operator takes three operands; the first is + an expression to evaluate, the second is the expression to + use if the first was true, the third is the expression to + use if it was false [simple example (a < b ? b : a) gives + the maximum of a and b] + Assignment operators + = store the value on the right into the variable or array slot + on the left [expression (a = b) stores the value of b in a] + +=, -=, *=, /=, %=, ^=, **= perform the indicated arithmetic + operation using the current value of the variable or array + element of the left side and the expression on the right + side, then store the result in the left side + ++ increment by 1 [expression (++a) gets the current value of + a and adds 1 to it, stores that back in a, and returns the + new value; expression (a++) gets the current value of a, + adds 1 to it, stores that back in a, but returns the + original value of a] + -- decrement by 1 (analogous to increment) + String operators + there is no explicit operator for string concatenation; + two values and/or variables side-by-side are implicitly + concatenated into a string (numeric values are first + converted into their string equivalents) + Conversion between numeric and string values + there is no explicit operator for conversion; adding 0 + to a string with force it to be converted to a number + (the numeric value will be 0 if the string does not + represent an integer or floating point number); the + reverse, converting a number into a string, is done by + concatenating a null string ("") to it [the expression + (5.75 "") evaluates to "5.75"] + Field 'operator' + $ prefixing a number or variable with a dollar sign ($) + causes the appropriate record field to be returned [($2) + gives the second field of the record, ($NF) gives the + last field (since the builtin variable NF is set to the + number of fields in the current record)] + Array subscript operator + , multi-dimensional arrays are simulated by using comma (,) + separated array indices; the actual index is generated + by replacing commas with the value of builtin SUBSEP, + then concatenating the expression into a string index + [comma is also used to separate arguments in function + calls and user-defined function definitions] + [comma is *also* used to indicate a range pattern in an + awk rule] + Escape 'operator' + \ In quoted character strings, the backslash (\) character + causes the following character to be interpreted in a + special manner [string "one\ntwo" has an embedded newline + character (linefeed on VMS, but treated as if it were both + carriage-return and linefeed); string "\033[" has an ASCII + 'escape' character (which has octal value 033) followed by + a 'right-bracket' character] + Backslash is also used in regular expressions + Redirection operators + < Read-from -- valid with 'getline' + > Write-to (create new file) -- valid with 'print' and 'printf' + >> Append-to (create file if it doesn't already exist) + | Pipe-from/to -- valid with 'getline', 'print', and 'printf' +4 precedence + Operator precedence, listed from highest to lowest. Assignment, + conditional, and exponentiation operators group from right to left; + all others group from left to right. Parentheses may be used to + override the normal order. + + field ($) + increment (++), decrement (--) + exponentiation (^, **) + unary plus (+), unary minus (-), boolean not (!) + multiplication (*), division (/), remainder (%) + addition (+), subtraction (-) + concatenation (no special symbol; implied by context) + relational (==, !=, <, >=, etc), and redirection (<, >, >>, |) + Relational and redirection operators have the same precedence + and use similar symbols; context distinguishes between them + matching (~, !~) + array membership ('in') + boolean and (&&) + boolean or (||) + conditional (? :) + assignment (=, +=, etc) +4 escaped_characters + Inside of a quoted string or constant regular expression, the + backslash (\) character gives special meaning to the character(s) + after it. Special character letters are case sensitive. + \\ results in one backslash in the string + \a is an 'alert' (. the ASCII character) + \b is a backspace (BS, ) + \f is a form feed (FF, ) + \n 'newline' ( [line feed treated as CR+LF] + \r carriage return (CR, [re-positions at the + beginning of the current line] + \t tab (HT, ) + \v vertical tab (VT, ) + \### is an arbitrary character, where '###' represents 1 to 3 + octal (ie, 0 thru 7) digits + \x## is an alternate arbitrary character, where '##' represents + 1 or more hexadecimal (ie, 0 thru 9 and/or A through E + and/or a through e) digits; if more than two digits + follow, the result is undefined; not recognized if POSIX + compatibility mode is specified. + + When a regular expression is represented in string form ("regex" + as opposed to /regex/), backslashes need to be paired. The first + one quotes the second during string processing, and the second one + remains to be used to quote whatever follows in regular expression + processing. For example, to match variable `xxx' against a period + character, use (xxx ~ "\\.") or (xxx ~ /\./); if you tried to use + (xxx ~ "\."), after string processing it would operate as (xxx ~ /./) + and end up matching any single character rather than just a period. +3 statements + A statement refers to a unit of instruction found in the action + part of an awk rule, and also found in the definition of a function. + The distinction between action, statement, and expression usually + won't matter to an awk programmer. + + Compound statements consist of multiple statements separated by + semicolons or newlines and enclosed within braces ({}). They are + sometimes referred to as 'blocks'. +4 expressions + An expression such as 'a = 10' or 'n += i++' is a valid statement. + + Function invocations such as 'reformat_field($3)' are also valid + statements. +4 if-then-else + A conditional statement in awk uses the same syntax as for the 'C' + programming language: the 'if' keyword, followed by an expression + in parentheses, followed by a statement--or block of statements + enclosed within braces ({})--which will be executed if the expression + is true but skipped if it's false. This can optionally be followed + by the 'else' keyword and another statement--or block of statements-- + which will be executed if (and only if) the expression was false. +5 examples + Simple example showing a statement used to control how many numbers + are printed on a given line. + if ( ++i <= 10 ) #check whether this would be the 11th + printf(" %5d", k) #print on current line if not + else { + printf("\n %5d", k) #print on next line if so + i = 1 #and reset the counter + } + Another example ('next' is described under 'action-controls') + if ($1 > $2) { print "rejected"; next } else diff = $2 - $1 +4 switch-case + A gawk extension provides an alternative for conditional execution + to the if-then-else construct. The switch statement takes a value + to use to decide which of one or more case clauses to execute, + similar to the same construct in C and C++. The main difference + is that in those languages, the case values must be constant + integers, whereas in awk they can by numbers, strings, or regular + expressions. Like in C/C++, an optional 'default' clause can be + specified to serve as a catch-all for values which don't match + any of the cases. + + The first case which matches the switch value is the one which + will be executed. If it doesn't use one of 'break', 'continue', + 'next', 'nextfile', 'return', or 'exit', then execution will + continue into the body of the next case. (Note that 'continue' + doesn't operate as an explicit request to do such; rather, it + causes execution of an enclosing for, while, or do-while + statement to jump to the end of its loop.) +5 example + In this example, the value of variable 'x' is examined. It + contains a mistake that someone coming from a background of + programming in Pascal might accidentally make. + + switch (x) { + case 1: print "x is 1"; break; + case 2: print "x is 2" + case "two": print "x is \"two\""; break; + default: print "x is neither 1 nor 2"; break + } + + Note that if the value is '2', after printing "x is 2" it will + continue into the next case and also print "x is \"two\"", which + was probably not intended. The 'break' statement is needed to + jump out of the switch statement instead of falling through + into the subsequent clause. For the very last one, 'default' + in this example, 'break' is optional; reaching the closing + bracket of a switch statement also breaks out of the statement. +4 loops + Three types of loop statements are available in awk. Each uses + the same syntax as 'C'. The simplest of the three is the 'while' + statement. It consists of the 'while' keyword, followed by an + expression enclosed within parentheses, followed by a statement--or + block of statements in braces ({})--which will be executed if the + expression evaluates to true. The expression is evaluated before + attempting to execute the statement; if it's true, the statement is + executed (the entire block of statements if there is a block) and + then the expression is re-evaluated. + + The second type of loop is the do-while loop. It consists of the + 'do' keyword, followed by a statement (usually a block of statements + enclosed within braces), followed by the 'while' keyword, followed + by a test expression enclosed within parentheses. The statement--or + block--is always executed at least once. Then the test expression + is evaluated, and the statement(s) re-executed if the result was + true (followed by re-evaluation of the test, and so on). + + The most complex of the three loops is the 'for' statement, and it + has a second variant that is not found in 'C'. The ordinary for-loop + consists of the 'for' keyword, followed by three semicolon-separated + expressions enclosed within parentheses, followed by a statement or + brace-enclosed block of statements. The first of the three + expressions is an initialization clause; it is done before starting + the loop. The second expression is used as a test, just like the + expression in a while-loop. It is checked before attempting to + execute the statement block, and then re-checked after each execution + (if any) of the block. The third expression is an 'increment' clause; + it is evaluated after an execution of the statement block and before + re-evaluation of the test (2nd) expression. Normally, the increment + clause will change a variable used in the test clause, in such a + fashion that the test clause will eventually evaluate to false and + cause the loop to finish. + + Note to 'C' programmers: the comma (,) operator commonly used in + 'C' for-loop expressions is not valid in awk. + + The awk-specific variant of the for-loop is used for processing + arrays. Its syntax is 'for' keyword, followed by variable_name 'in' + array_name (where 'var in array' is enclosed in parentheses), + followed by a statement (or block). Each valid subscript value for + the array in question is successively placed--in no particular + order--into the specified 'index' variable. Order can optionally + be controlled by assigning a sort mode to PROCINFO["sorted_in"]. +5 while_example + # strip fields from the input record until there's nothing left + while (NF > 0) { + $1 = "" #this will affect the value of $0 + $0 = $0 #this causes $0 and NF to be re-evaluated + print + } +5 do_while_example + # This is a variation of the while_example; it gives a slightly + # different display due to the order of operation. + # echo input record until all fields have been stripped + do { + print #output $0 + $1 = "" #this will affect the value of $0 + $0 = $0 #this causes $0 and NF to be re-evaluated + } while (NF > 0) +5 for_example + # echo command line arguments (won't include option switches) + for ( i = 0; i < ARGC; i++ ) print ARGV[i] + + # display contents of builtin environment array + for (itm in ENVIRON) + print itm, ENVIRON[itm] +5 for_index_in_array_sorting + Normally indices in an array are processed in an arbitrary + order when using the 'for (index in array)' statement, + but a gawk-extension allows you to control that order. + Assign a value to the "sorted_in" element of the PROCINFO[] + array to accomplish this. The value may be a comparison + function which accepts four arguments (index and value of one + element, then index and value of another), or a special value + which specifies one of several built-in comparison functions. + These functions are used to compare pairs of array elements + and their result controls which of each pair comes before the + other. +6 comparison_function + A function assigned to PROCINFO["sorted_in"] should be + prepared to accept four arguments and to return a numeric + value, negative if the element specified by the first two + arguments (its index and its value, respectively) is less + than the element specified the second pair of arguments, + zero if they compare equal, and positive of the first + element is greater than the second. Here's an example: + + function my_compare(idx1, val1, idx2, val2) + { + if (val1 < val2) return -1 + if (val2 > val2) return 1 + # the two values are equal + return (idx1 < idx2) ? -1 : (idx1 > idx2) + } + + This compares the two values and returns either negative + or positive if they're different. If they're the same, + it compares the two indices as a tie-breaker instead of + simply returning zero. + + You can force values to be numeric or to be string, as + needed, and use more elaborate ordering criteria. Just + be sure that the results are consistent; returning a + positive value when idx1,val1 is compared to idx2,val2 + and then also returning a positive value if idx2,val2 + gets compared to idx1,idx2 will likely confuse the sort + routine and produce strange results. + + If you plan to sort arrays which contain sub-arrays (array + elements which contain their own arrays) and you're sorting + by value rather than by index, your compare routine should + use the isarray() function to check for them (test second + and fourth arguments to see whether they're arrays) and + handle them appropriately. The basic comparison operators + like '<' will produce an error if used on arrays. +6 built-in_comparisons + Here is a list of built-in compare routines that can be + assigned to PROCINFO["sorted_in"]. They are strings + and start with '@' so that these names can't be confused + with actual functions. + + "@ind_str_asc" order by indices compared as strings + (all array indices are strings internally, + even when they were assigned as numbers) + "@ind_num_asc" order by indices compared as numbers + (non-numeric ones end up with value 0) + "@val_type_asc" order by values using assigned type + (if a mixture of strings and numbers is + present, numbers come first, then strings) + "@val_str_asc" order by values compared as strings + "@val_num_asc" order by values compared as numbers + "@ind_str_desc" \ + "@ind_num_desc" \ + "@val_type_desc" descending versions of the above + "@val_str_desc" / + "@val_num_desc" / + "@unsorted" explicitly specify arbitrary order + (same as deleting the "sorted_in" element + from the PROCINFO[] array, or never having + assigned it a value in the first place) + + All the ascending sorts put sub-arrays--if any--last, and + descending ones place them first. When multiple sub-arrays + are present, they tie with each other without regard to + their contents; such ties are then disambiguated by + comparing their indices. +6 processing_order + Sorting of the array takes place as the 'for (index in array)' + statement is about to start executing. Changing the value of + PROCINFO["sorted_in"] during the course of the loop will not + affect traversal order, and could be used to control ordering + of sub-arrays using different criteria. + + After the loop finishes, any ordering imposed on the indices + is forgotten. A subsequent 'for (index in array)' traversal + of the same array will yield whatever order is specified by + PROCINFO["sorted_in"] at that time, including reverting to + arbitrary if it no longer has a value. +4 loop-controls + There are two special statements--both from 'C'--for changing the + behavior of loop execution. The 'continue' statement is useful in + a compound (block) statement; when executed, it effectively skips + the rest of the block so that the increment-expression (only for + for-loops) and loop-termination expression can be re-evaluated. + + The 'break' statement, when executed, effectively skips the rest + of the block and also treats the test expression as if it were + false (instead of actually re-evaluating it). In this case, the + increment-expression of a for-loop is also skipped. + + Inside nested loops, both 'break' and 'continue' only apply to the + innermost loop. When in compatibility mode, 'break' or 'continue' + may be used outside of a loop; either will be treated like 'next' + (see action-controls). +4 action-controls + There are two special statements for controlling statement execution. + The 'next' statement, when executed, causes the rest of the current + action and all further pattern-action rules to be skipped, so that + the next input record will be immediately processed. This is useful + if any early action knows that the current record will fail all the + remaining patterns; skipping those rules will reduce processing time. + + A GAWK extension, 'nextfile', is also available. It causes the + remainder of the current file to be skipped, the ENDFILE action, if + applicable, to be performed, and then the next input file will be + processed. If there is no next input file, the END action will be + performed. 'nextfile' is not available in traditional awk. + + The 'exit' statement causes GAWK execution to terminate. All open + files are closed, and no further processing is done. The END rule, + if any, is executed. 'exit' takes an optional numeric value as a + argument which is used as an exit status value, so that some sort + of indication of why execution has stopped can be passed on to the + user's environment. +4 other_statements + The delete statement is used to remove an element from an array. + The syntax is 'delete' keyword followed by array name, followed + by index value enclosed in square brackets ([]). As a gawk + extension, 'delete' may also used on an array name without any + index specified, to delete all its elements in a single operation. + (The array itself will continue to exist as an array, even though + it no longer contains any elements.) + + The return statement is used in user-defined functions. The syntax + is the keyword 'return' optionally followed by a string or numeric + expression. + + See also subtopic 'functions IO_functions' for a description of + 'print', 'printf', and 'getline'. +3 fields + When an input record is read, it is automatically split into fields + based on the current values of FS (builtin variable defining field + separator expression) and RS (builtin variable defining record + separator character). The default value of FS is an expression + which matches one or more spaces and tabs; the default for RS is + newline. If the FIELDWIDTHS variable is set to a space separated + list of numbers (as in ``FIELDWIDTHS = "2 3 2"'') then the input + is treated as if it had fixed-width fields of the indicated sizes + and the FS value will be ignored. + + The field prefix operator ($), is used to reference a particular + field. For example, $3 designates the third field of the current + record. The entire record can be referenced via $0 (and it holds + the actual input record, not the values of $1, $2, ... concatenated + together, so multiple spaces--when present--remain intact, unless + a new value gets assigned). + + The builtin variable NF holds the number of fields in the current + record. $NF is therefore the value of the last field. Attempts to + access fields beyond NF result in null values (if a record contained + 3 fields, the value of $5 would be ""). + + Assigning a new value to $0 causes all the other field values (and NF) + to be re-evaluated. Changing a specific field will cause $0 to receive + a new value once it's re-evaluated, but until then the other existing + fields remain unchanged. +4 field_separation + Three built in variables control separating input lines into fields, + and the most recently assigned of those three is the one which has + effect. PROCINFO["FS"] can be used to determine which one that is. + + FS is a character, string, or regular expression specifying what + separates fields. It is available in all implementations of awk so + is the most widely used. The default value is an explicit space and + behaves as if the value was /[ \t\n]+/ to treat any number of spaces + and tabs (and newlines, if RS isn't using them as record separators) + as the separator. (Explicitly using that regular expression + actually produces different results if the input happens to have + leading and/or trailing whitespace. The default skips such space; + the regexp increases NF by 1 and produces an empty $1 if there is + leading whitespace and it increases NF by 1 and produces an empty $NF + if there is trailing whitespace. To actually force the separator to + be a single space, use the regular expression / /.) + + FIELDWIDTHS is a string containing a space-separated list of numbers + which indicate how wide each field is. It is a gawk-extension and + used to be considered experimental, but it has been in place for many + years without significant changes. There is no default value, nor is + there any way to specify a repeat count the way a Fortran FORMAT + statment could. + + FPAT is a regular expression which specifies field values rather than + the separation between fields. It is also a gawk-extension and is + new with version 4.0.0. + + A gawk-extension makes setting FS to "" force each input character + to be a separate field, similar to FIELDWIDTHS="1 1 1 1 1 1"(...) if + you were able to supply an unlimited number of 1's. +3 variables + Variables in awk can hold both numeric and string values and do not + have to be pre-declared. In fact, there is no way to explicitly + declare them at all. Variable names consist of a leading letter + (either upper or lower case, which are distinct from each other) + or underscore (_) character followed by any number of letters, + digits, or underscores. + + When a variable that didn't previously exist is referenced, it is + created and given a null value. A null value is treated as 0 when + used as a number, and is a string of zero characters in length if + used as a string. +4 builtin_variables + GAWK maintains several 'built-in' variables. All have default values; + some are updated automatically. All the builtins have uppercase-only + names. + + These builtin variables control how awk behaves + FS input field separator; default is a single space, which is + treated as if it were a regular expression for matching + one or more spaces and/or tabs and/or newlines; a value + of " " also has a second special-case side-effect of + causing leading and/or trailing blanks to be ignored + instead of producing a null first and/or last field; + initial value can be specified on the command line with + the -F option (or /field_separator); the value can be a + regular expression; as a gawk extension, if the value is + an empty string (""), every character becomes a separate + field + RS input record separator; default value is a newline ("\n"); + the value can be multiple characters or a regular expression + OFS output field separator; value to place between variables in + a 'print' statement; default is one space; can be arbitrary + string + ORS output record separator; value to implicitly terminate 'print' + statement with; default is newline ("\n"); can be arbitrary + string + OFMT default output format used for printing numbers; default + value is "%.6g" + CONVFMT conversion format used for number-to-string conversions; + default value is also "%.6g", like OFMT; not used when the + number has a value which may be represented internally as + an exact integer (typically within -2147483648 to 2147483647) + SUBSEP subscript separator for array indices; used when an array + subscript is specified as a comma separated list of values: + the comma is replaced by SUBSEP and the resulting index + is a concatenation of the values and SUBSEP(s); default + value is "\034"; value may be arbitrary string + IGNORECASE string and regular expression matching flag; if true + (non-zero) matching ignores differences between upper and + lower case letters; affects the '~' and '!~' operators, + the 'index', 'match', 'split', 'sub', and 'gsub' functions, + and field splitting based on FS; default value is false (0); + has no effect if GAWK is in strict compatibility mode + FIELDWIDTHS space or tab separated list of width sizes; takes + precedence over FS when set, but is cleared if FS has a + value assigned to it; [note: the current implementation + of fixed-field input is considered experimental and is + expected to evolve over time] + FPAT an alternate way to specify fields, with a regexp pattern + which defines field values rather than field separator + [assigning a value to any of FS, FIELDWIDTHS, or FPAT + causes the other two to be deactivated; the value of + PROCINFO["FS"] can be used to determine which one is + currently in use] + BINMODE can be used force input and/or output files to be processed + using binary I/O; a value of 1 or "r" forces binary mode when + reading input, a value of 2 or "w" forces binary mode when + writing output, and a value of 3 or "rw" causes GAWK to use + binary mode for both input and output; BINMODE has no effect + on reading from stdin or writing to stdout; they'll have + already been opened in text mode before you assign a value + LINT setting or unsetting this can dynamically toggle the --lint + command line option on or off + + These builtin variables provide useful information + NF number of fields in the current record + NR record number (accumulated over all files when more than one + input file is processed by the same program) + FNR current record number of the current input file; reset to 0 + each time an input file is completed + RT record terminator, the input text which matched RS; not + available when the `-Wtraditional' option is used + RSTART starting position of substring matched by last invocation + of the 'match' function; set to 0 if a match fails and at + the start of each input record + RLENGTH length of substring matched by the last invocation of the + 'match' function; set to -1 if a match fails + FILENAME name of the input file currently being processed; the + special name "-" is used to represent the standard input + ENVIRON array of miscellaneous user environment values; the VMS + implementation of GAWK provides values for ["USER"] (the + username), ["PATH"] (current default directory), ["HOME"] + (the user's login directory), and "[TERM]" (terminal type + if available) [all info provided by C RTL's environ] + PROCINFO miscellaneous process information and assorted GAWK + extensions which don't fit in elsewhere + ERRNO information about the cause of failure for 'getline' or + 'close' or for file open during a BEGINFILE rule; it is + only set if an error has occurred, it isn't reset when + any subsequent operation succeeds; the only exception is + that it is reset prior to attempting to open a file so + that BEGINFILE rule actions can distinguish between + success and failure + ARGC number of elements in the ARGV array, counting [0] which is + the program name (ie, "gawk") + ARGV array of command-line arguments (in [0] to [ARGC-1]); the + program name (ie, "gawk") in held in ARGV[0]; command line + parameters (data files and "var=value" expressions, but not + program options or the awk program text string if present) + are stored in ARGV[1] through ARGV[ARGC-1]; the awk program + can change values of ARGC and ARGV[] during execution in + order to alter which files are processed or which between- + file assignments are made + ARGIND current index into ARGV[] +4 arrays + awk supports associative arrays to collect data into tables. Array + elements can be either numeric or string, as can the indices used to + access them. Each array must have a unique name, but a given array + can hold both string and numeric elements at the same time. Arrays + are one-dimensional only, but multi-dimensional arrays can be + simulated using comma (,) separated indices, whereby a single index + value gets created by replacing commas with SUBSEP and concatenating + the resulting expression into a single string. + + Referencing an array element is done with the expression + Array[Index] + where 'Array' represents the array's name and 'Index' represents a + value or expression used for a subscript. If the requested array + element did not exist, it will be created and assigned an initial + null value. To check whether an element exists without creating it, + use the 'in' boolean operator. + Index in Array + would check 'Array' for element 'Index' and return 1 if it existed + or 0 otherwise. To remove an element from an array, use the 'delete' + statement + delete Array[Index] + To remove all array elements at once, use + delete Array + Note: the latter is a gawk extension; also, there is no way to + delete an ordinary variable or an entire array; 'delete' only works + on array elements. + + To process all elements of an array (in succession) when their + subscripts might be unknown, use the 'in' variant of the for-loop + for (Index in Array) { ... } + (See the "awk_language statements loops" entry for a way to control + the order of traversal with this construct.) + + Starting with version 4.0.0 array values can contain arrays, sometimes + referred to as sub-arrays. They're created by assigning a value using + multiple instances of subscripting: 'a[1][2] = 3' would create array + a if it didn't already exist, create array element a[1] if it didn't + already exist, create sub-array element a[1][2] if it didn't exist, + then assign that the value 3. You can't directly assign an existing + array to be a subarray: 'a[1] = 2; a[3] = 4; b["a"] = a' would get + rejected. But you can produce the same effect by traversing the array + and assigning it element by element: + 'a[1] = 2; a[3] = 4; for (i in a) b["a"][i] = a[i]'. +3 functions + awk supports both built-in and user-defined functions. A function + may be considered a 'black-box' which accepts zero or more input + parameters, performs some calculations or other manipulations based + on them, and returns a single result. + + The syntax for calling a function consists of the function name + immediately followed by an open parenthesis (left parenthesis '('), + followed by an argument list, followed by a closing parenthesis + (right parenthesis ')'). The argument list is a sequence of values + (numbers, strings, variables, array references, or expressions + involving the above and/or nested function calls), separated by + commas and optional white space. + + The parentheses are required punctuation, except for the 'print' and + 'printf' builtin IO functions, where they're optional, and for the + builtin IO function 'getline', where they're not allowed. Some + functions support optional [trailing] arguments which can be simply + omitted (along with the corresponding comma if applicable). +4 numeric_functions + Builtin numeric functions + int(n) returns the value of 'n' with any fraction truncated + [truncation of negative values is towards 0] + sqrt(n) the square root of n + exp(n) the exponential of n ('e' raised to the 'n'th power) + log(n) natural logarithm of n + sin(n) sine of n (in radians) + cos(n) cosine of n (radians) + atan2(m,n) arctangent of m/n (radians) + rand() random number in the range 0 to 1 (exclusive) + srand(s) sets the random number 'seed' to s, so that a sequence + of 'random' numbers can be repeated; returns the + previous seed value; srand() [argument omitted] sets + the seed to an 'unpredictable' value (based on date + and time, for instance, so should be unrepeatable) +4 string_functions + Builtin string functions + index(s,t) search string s for substring t; result is 1-based + offset of t within s, or 0 if not found + length(s) returns the length of string s; either 'length()' + with its argument omitted or 'length' without any + parenthesized argument list will return length of $0 + match(s,r) search string s for regular expression r; the offset + of the longest, left-most substring which matches + is returned, or 0 if no match was found; the builtin + variables RSTART and RLENGTH are also set [RSTART to + the return value and RLENGTH to the size of the + matching substring, or to -1 if no match was found] + split(s,a,f,x) break string s into components based on field + separator f and store them in array a (into elements + [1], [2], and so on); the third argument is optional, + if omitted, the value of FS is used; the fourth one + is optional too, and is a gawk extension; when + specified it should be an array which will receive + the separators between the corresponding fields; the + return value is the number of components found + patsplit(s,a,p,x) similar to split, but p is a regexp pattern + specifying field contents rather than a separator; + if not specified, the value of FPAT is used; this + function is a gawk extension + sprintf(f,e,...) format expression(s) e using format string f and + return the result as a string; formatting is similar + to the printf function + sub(r,t,s) search string target s for regular expression r, and + if a match is found, replace the matching text with + substring t, then store the result back in s; if s + is omitted, use $0 for the string; the result is + either 1 if a match+substitution was made, or 0 + otherwise; if substring t contains the character + '&', the text which matched the regular expression + is used instead of '&' [to suppress this feature + of '&', 'quote' it with a backslash (\); since this + will be inside a quoted string which will receive + 'backslash' processing before being passed to sub(), + *two* consecutive backslashes will be needed "\\&"] + gsub(r,t,s) similar to sub(), but gsub() replaces all nonoverlapping + substrings instead of just the first, and the return + value is the number of substitutions made + gensub(r,t,n,s) search string s ($0 if omitted) for regexp r and + replace the n'th occurrence with substring t; the + result is the new string and s (or $0) remains + unchanged; if n begins with letter "g" or "G" then + all matches are replaced instead of just the n'th; + if r has parenthesized subexpressions in it, t may + contain the special sequences \\0, \\1, through \\9 + which expand into the value of the corresponding + subexpression; this function is a gawk extension + substr(s,p,l) extract a substring l characters long starting at + offset p in string s; l is optional, if omitted then + the remainder of the string (p thru end) is returned + tolower(s) return a copy of string s in which every uppercase + letter has been converted into lowercase + toupper(s) analogous to tolower(); convert lowercase to uppercase + strtonum(s) convert string s into the corresponding number; if s + begins with "0x", the rest of the string will be + considered to be hexacimal digits, otherwise if it + begins with "0" (not "o"), the rest will be treated + as octal digits; this function is a gawk extension +4 array_functions + isarray(a) returns 1 of a is an array, 0 otherwise; most useful + when traversing an array which might contain array + values (sub-arrays) + split(s,a[,f[,x]]) break string s into components based on field + separator f and store them in array a (into elements + [1], [2], and so on); the third argument is optional, + if omitted, the value of FS is used; the fourth one + is optional too, and is a gawk extension; when + specified it should be an array which will receive + the separators between the corresponding fields; the + return value is the number of components found + patsplit(s,a[,p[,x]]) similar to split, but p is a regexp pattern + specifying field contents rather than a separator; + if not specified, the value of FPAT is used; this + function is a gawk extension + asort(s[,d[,m]]) sort the contents of array s, replacing the index + values with an integer sequence of 1 to N; if d is + specified, leave the indices of s intact and put the + values and sequence index into d; if m is specified, + it should be a string containing "ascending" or + "descending" to control order, or "string" or "number" + to control how comparisons are performed, or a + combination of the two; m can also be a comparison + function similar to ones used by PROCINFO["sorted_in"] + asorti(s[,d[,m]]) sort the indices of array s, replacing the values + with an integer sequence of 1 to N; if d is specified, + leave the values of s intact and put the indices and + sequence values into d; m is the same as for asort() +4 time_functions + Builtin time functions + systime() return the current time of day as the number of seconds + since some reference point; on VMS the reference point + is January 1, 1970, at 12 AM local time (not UTC) + mktime(s) convert string s into number of seconds since the + reference point; s should contain a value of the form + "yyyy mm dd hh mm ss[ dst]" where yyyy is a four digit + year, mm a month number from 1 to 12, dd day-of-month + number from 1 to 31, hh hour 0 to 23, mm minute 0 to + 59, ss second 0 to 60, and [ dst] is an optional flag + to handle daylight savings time: if dst is positive, + then daylight savins time is in effect, if zero, then + it isn't, and if negative or omitted, gawk attempts + to determine whether it was--or will be--at specified + date and time + strftime(f,t,u) format time value t using format f; if it is omitted + then PROCINFO["strftime"] is used; if t is omitted, + the default is systime(); if u is present and non-zero + then t is treated as a UTC value, otherwise it is + considered to be local time +5 time_formats + Formatting directives similar to the 'printf' & 'sprintf' functions + (each is introduced in the format string by preceding it with a + percent sign (%)); the directive is substituted by the corresponding + value + a abbreviated weekday name (Sun,Mon,Tue,Wed,Thu,Fri,Sat) + A full weekday name + b abbreviated month name (Jan,Feb,...) + B full month name + c date and time (Unix-style "aaa bbb dd HH:MM:SS YYYY" format) + C century prefix (19 or 20) [not century number, ie 20th] + d day of month as two digit decimal number (01-31) + D date in mm/dd/yy format + e day of month with leading space instead of leading 0 ( 1-31) + E ignored; following format character used + H hour (24 hour clock) as two digit number (00-23) + h abbreviated month name (Jan,Feb,...) [same as %b] + I hour (12 hour clock) as two digit number (01-12) + j day of year as three digit number (001-366) + m month as two digit number (01-12) + M minute as two digit number (00-59) + n 'newline' (ie, treat %n as \n) + O ignored; following format character used + p AM/PM designation for 12 hour clock + r time in AM/PM format ("II:MM:SS p") + R time without seconds ("HH:MM") + S second as two digit number (00-59) + t tab (ie, treat %t as \t) + T time ("HH:MM:SS") + U week of year (00-53) [first Sunday is first day of week 1] + V date (VMS-style "dd-bbb-YYYY" with 'bbb' forced to uppercase) + w weekday as decimal digit (0 [Sunday] through 6 [Saturday]) + W week of year (00-53) [first _Monday_ is first day of week 1] + x date ("aaa bbb dd YYYY") + X time ("HH:MM:SS") + y year without century (00-99) + Y year with century (19yy-20yy) + Z time zone name (always "local" for VMS) + % literal percent sign (%) +4 IO_functions + Builtin I/O functions + print x,... print the values of one or more expressions; if none + are listed, $0 is used; parentheses are optional; + when multiple values are printed, the current value + of builtin OFS (default is 1 space) is used to + separate them; the print line is implicitly + terminated with the current value of ORS (default + is newline); print does not have a return value + printf(f,x,...) print the values of one or more expressions, using + the specified format string; null strings are used + to supply missing values (if any); no between field + or trailing newline characters are printed, they + should be specified within the format string; the + argument-enclosing parentheses are optional; + printf does not have a return value + getline v read a record into variable v; if v is omitted, $0 is + used (and NF, NR, and FNR are updated); if v is + specified, then field-splitting won't be performed; + note: parentheses around the argument are *not* + allowed; return value is 1 for successful read, 0 + if end of file is encountered, or -1 if some sort + of error occurred; [see 'redirection' for several + variants] + close(s) close a file or pipe specified by the string s; the + string used should have the same value as the one + used in a getline or print/printf redirection + fflush(s) flush output stream s; if s is omitted, stdout is + flushed; if it is specified but its value is an + empty string, all output streams are flushed + system(s) pass string s to executed by the operating system; + the command string is executed in a subprocess +5 redirection + Both getline and print/printf support variant forms which use + redirection and pipes. + + To read from a file (instead of from the primary input file), use + getline var < "file" + or getline < "file" (read into $0) + where the string "file" represents either an actual file name (in + quotes) or a variable which contains a file name string value or an + expression which evaluates to a string filename. + + To create a pipe executing some command and read the result into + a variable (or into $0), use + "command" | getline var + or "command" | getline (read into $0) + where "command" is a literal string containing an operating system + command or a variable with a string value representing such a + command. + + To output into a file other that the primary output, use + print x,... > "file" (or >> "file") + or printf(f,x,...) > "file" (or >> "file") + similar to the 'getline' example above. '>>' causes output to be + appended to an existing file if it exists, or create the file if + it doesn't already exist. '>' always creates a new file. The + alternate redirection method of '>$' (for RMS text file attributes) + is *only* available on the command line, not with 'print' or + 'printf' in the current release. + + To output an error message, use 'print' or 'printf' and redirect + the output to file "/dev/stderr" (or equivalently to "SYS$ERROR:" + on VMS). 'stderr' will normally be the user's terminal, even if + ordinary output is being redirected into a file. + + To feed awk output into another command, use + print x,... | "command" (similarly for 'printf') + similar to the second 'getline' example. In this case, output + from awk will be passed as input to the specified operating system + command. The command must be capable of reading input from 'stdin' + ("SYS$INPUT:" on VMS) in order to receive data in this manner. + + The 'close' function operates on the "file" or "command" argument + specified here (either a literal string or a variable or expression + resulting in a string value). It completely closes the file or + pipe so that further references to the same file or command string + would re-open that file or command at the beginning. Closing a + pipe or redirection also releases some file-oriented resources. + + Note: the VMS implementation of GAWK uses temporary files to + simulate pipes, so a command must finish before 'getline' can get + any input from it, and 'close' must be called for an output pipe + before any data can be passed to the specified command. +5 formats + Formatting characters used by the 'printf' and 'sprintf' functions + (each is introduced in the format string by preceding it with a + percent sign (%)) + % include a literal percent sign (%) in the result + c format the next argument as a single ASCII character + (prints first character of string argument, or corresponding + ASCII character if numeric argument, e.g. 65 is 'A') + s format the next argument as a string (numeric arguments are + converted into strings on demand) + d decimal number (ie, integer value in base 10) + i integer (equivalent to decimal) + o octal number (integer in base 8) + x hexadecimal number (integer in base 16) [lowercase] + X hexadecimal number [digits 'A' thru 'E' in uppercase] + f floating point number (digits, decimal point, fraction digits) + e exponential (scientific notation) number (digit, decimal + point, fraction digits, letter 'e', sign '+' or '-', + exponent digits) + g 'fractional' number in either 'e' or 'f' format, whichever + produces shorter result + + Several optional modifiers can be placed between the initiating + percent sign and the format character (doesn't apply to %%). + - left justify (only matters when width specifier is present) + (space) for numeric specifiers, prefix nonnegative values with + a space and negative values with a minus sign + + for numeric specifiers, prefix nonnegative values with a plus + sign and negative values with a minus sign + # alternate form applicable to several of the format characters + (o, x, X, e, E, f, g, G) + NN width ['NN' represents 1 or more decimal digits]; actually + minimum width to use, longer items will not be truncated; a + leading 0 will cause right-justified numbers to be padded on + the left with zeroes instead of spaces when they're aligned + .MM precision [decimal point followed by 1 or more digits]; used + as maximum width for strings (causing truncation if they're + actually longer) or as number of fraction digits for 'f' or + 'e' numeric formats, or number of significant digits for 'g' + numeric format +4 bitwise_functions + Bitwise functions operate on bits (binary digits) of integer + numeric values. Non-integer numbers are converted into integers + before their bits are accessed. + + and(x,y) x AND y, where result contains 1 for bits that both x + and y have set, 0 for other bits + or(x,y) x OR y, where the result contains 1 for any bits that + either x or y or both have set, 0 for other bits + xor(x,y) x XOR y, where the result contains 1 for bits that x + has set but y has clear or vice versa, 0 for other bits + compl(x) NOT x, where the result contains 1 for bits that x + has clear and 0 for bits that it has set + lshift(x,n) x << n, shift the bits of x by n positions left, + approximately the same as x * 2^n + rshift(x,n) x >> n, shift the bits of x by n positions right, + approximately the same as int(x / 2^n) + + The set of bitwise functions is a gawk extension. +4 user_defined_functions + User-defined functions may be created as needed to simplify awk + programs or to collect commonly used code into one place. The + general syntax of a user-defined function is the 'function' keyword + followed by unique function name, followed by a comma-separated + parameter list enclosed in parentheses, followed by statement(s) + enclosed within braces ({}). A 'return' statement is customary + but is not required. + function FuncName(arg1,arg2) { + # arbitrary statements + return (arg1 + arg2) / 2 + } + If a function does not use 'return' to specify an output value, the + result received by the caller will be unpredictable. + + Functions may be placed in an awk program before, between, or after + the pattern-action rules. The abbreviation 'func' may be used in + place of 'function', unless POSIX compatibility mode is in effect. +4 indirect_function_calls + A gawk extension allows you to assign a string containing the name + of a function to a variable, then call the function by preceding + the variable with @ (at-sign) and following with the parenthesized + argument list. For example + + function my_max(x, y) { return (x > y) ? x : y } + function my_min(x, y) { return (x < y) ? x : y } + ... + max_or_min = some_criterion ? "my_max" : "my_min" + ... + c = @max_or_min(a, b) + + would call either my_max() or my_min() depending upon the value of + some_criterion at the time max_or_min was assigned. + + Indirect function calls only operate on user-defined functions, not + on built-in ones. If you need to use one of the latter, create a + user-defined function to call the built-in function; this if often + referred to as a "wrapper" function. +3 regular_expressions + A regular expression is a shorthand way of specifying a 'wildcard' + type of string comparison. Regular expression matching is very + fundamental to awk's operation. + + Meta symbols + ^ matches beginning of line or beginning of string; note that + embedded newlines ('\n') create multi-line strings, so + beginning of line is not necessarily beginning of string + $ matches end of line or end of string + . any single character (except newline) + [ ] set of characters; [ABC] matches either 'A' or 'B' or 'C'; a + dash (other than first or last of the set) denotes a range + of characters: [A-Z] matches any upper case letter; if the + first character of the set is '^', then the sense of match + is reversed: [^0-9] matches any non-digit; several + characters need to be quoted with backslash (\) if they + occur in a set: '\', ']', '-', and '^'; within sets, + various special character class designations are recognized, + such as [:digit:] and [:punct:], as per POSIX + | alternation (similar to boolean 'or'); match either of two + patterns [for example "^start|stop$" matches leading 'start' + or trailing 'stop'] + ( ) grouping, alter normal precedence [for example, "^(start|stop)$" + matches lines reading either 'start' or 'stop'] + * repeated matching; when placed after a pattern, indicates that + the pattern should match any number of times [for example, + "[a-z][0-9]*" matches a lower case letter followed by zero or + more digits] + + repeated matching; when placed after a pattern, indicates that + the pattern should match one or more times ["[0-9]+" matches + any non-empty sequence of digits] + ? optional matching; indicates that the pattern can match zero or + one times ["[a-z][0-9]?" matches lower case letter alone or + followed by a single digit] + { } interval specification; {n} to match n times or {m,n} to match + at least m but not more than n times; only functional when + either the `-Wposix' or `-Wre-interval' options are used + \ quote; prevent the character which follows from having special + meaning; if the regexp is specified as a string, then the + backslash itself will need to be quoted by preceding it with + another backslash + + A regular expression which matches a string or line will match against + the first (left-most) substring which meets the pattern and include + the longest sequence of characters which still meets that pattern. +3 comments + Comments in awk programs are introduced with '#'. Anything after + '#' on a line is ignored by GAWK. It's a good idea to include an + explanation of what an awk program is doing and also who wrote it + and when. +3 further_information + For complete documentation on GAWK, see "Effective AWK Programming" + by Arnold Robbins. The second edition (ISBN 1-57831-000-8) is jointly + published by SSC and the FSF (http://www.ssc.com). + + Source text for it is present in the file GAWK.TEXI. A postscript + version is available via anonymous FTP from host gnudist.gnu.org in + directory /gnu/gawk, file gawk-{version}-doc.tar.gz where {version} + would be the current version number, such as 3.0.6. + + Another source of documentation is "The AWK Programming Language" + by Aho, Weinberger, and Kernighan (1988), published by Addison-Wesley. + ISBN code is 0-201-07981-X. + + Each of these works contains both a reference on the awk language + and a tutorial on awk's use, with many sample programs. +3 authors + The awk programming language was originally created by Alfred V. Aho, + Peter J. Weinberger, and Brian W. Kernighan in 1977. The language + was revised and enhanced in a new version which was released in 1985. + + GAWK, the GNU implementation of awk, was written in 1986 by Paul Rubin + and Jay Fenlason, with advice from Richard Stallman, and with + contributions from John Woods. In 1988 and 1989, David Trueman and + Arnold Robbins revised GAWK for compatibility with the newer awk. + Arnold Robbins is the current maintainer. + + GAWK version 2.11.1 was ported to VMS by Pat Rankin in November, 1989, + with further revisions in the Spring of 1990. The VMS port was + incorporated into the official GNU distribution of version 2.13 in + Spring 1991. (Version 2.12 was never publically released.) +2 release_notes + GAWK 4.0.0 has many changes from 3.1.8, and these release_notes were + not updated for any of the 3.1.* releases, so some information is + probably missing or out of date. In particular, the known_problems + subtopic hasn't been touched in many years. +3 AWK_LIBRARY + GAWK uses a built in search path when looking for a program file + specified by the -f option (or the /input qualifier) when that file + name does not include a device and/or directory. GAWK will first + look in the current default directory, then if the file wasn't found + it will look in the directory specified by the translation of logical + name "AWK_LIBRARY". +3 known_problems + There are several known problems with GAWK running on VMS. Some can + be ignored, others require work-arounds. +4 file_formats + If a file having the RMS attribute "Fortran carriage control" is + read as input, it will generate an empty first record if the first + actual record begins with a space (leading space becomes a newline). + Also, the last record of the file will give a "record not terminated" + warning. Both of these minor problems are due to the way that the + C Run-Time Library (VAXCRTL) converts record attributes. + + Another poor feature without a work-around is that there's no way to + specify "append if possible, create with RMS text attributes if not" + with the current command line I/O redirection. '>>$' isn't supported. + Ditto for binary output; '>>+' isn't supported. +4 RS_peculiarities + Changing the record separator to something other than newline ('\n') + will produce anomalous results for ordinary files. For example, + using RS = "\f" and FS = "\n" with the following input + |rec 1, line 1 + |rec 1, line 2 + |^L (form feed) + |rec 2, line 1 + |rec 2, line 2 + |^L (form feed) + |rec 3, line 1 + |rec 3, line 2 + |(end of file) + will produce two fields for record 1, but three fields each for + records 2 and 3. This is because the form-feed record delimiter is + on its own line, so awk sees a newline after it. Since newline is + now a field separator, records 2 and 3 will have null first fields. + The following awk code will work-around this problem by inserting + a null first field in the first record, so that all records can be + handled the same by subsequent processing. + # fix up for first record (RS != "\n") + FNR == 1 { if ( $0 == "" ) #leading separator + next #skip its null record + else #otherwise, + $0 = FS $0 #realign fields + } + There is a second problem with this same example. It will always + trigger a "record not terminated" warning when it reaches the end of + file. In the sample shown, there is no final separator; however, if + a trailing form-feed were present, it would produce a spurious final + record with two null fields. This occurs because the I/O system + sees an implicit newline at the end of the last record, so awk sees + a pair of null fields separated by that newline. The following code + fragment will fix that provided there are no null records (in this + case, that would be two consecutive lines containing just form-feeds). + # fix up for last record (RS != "\n") + $0 == FS { next } #drop spurious final record + Note that the "record not terminated" warning will persist. +4 cmd_inconsistency + The DCL qualifier /OUTPUT is internally equivalent to '>$' output + redirection, but the qualifier /INPUT corresponds to the -f option + rather than to '<' input redirection. +4 exit + The exit statement can optionally pass a final status value to the + operating system. GAWK expects a UN*X-style value instead of a + VMS status value, so 0 indicates success and non-zero indicates + failure. The final exit status will be 1 (VMS success) if 0 is + used, or even (VMS non-success) if non-zero is used. +3 changes + Changes between version 4.0.0 and earlier versions + + [This 'changes' section hasn't been updated in many releases. Some + features mentioned here may have become available in versions 3.1.*.] + + General + dgawk.exe does interactive debugging of awk programs + pgawk.exe does comprehensive execution profiling of awk programs + -d[file] and -p[file] options added + -Wcompat and -Wusage options dropped; use -Wtraditional and -Whelp + BEGINFILE and ENDFILE built-in rule patterns + nextfile statement skips remainder of current input file + switch-case statement performs an alternate form of if-then-else + indirect function calls: var="user_function"; @var(args) + + FPAT regexp pattern as alternative to FS field splitting + patsplit() function, FPAT analog to split() + PROCINFO["sorted_in"] can be used to control traversal order for + 'for (index in array)' statement + asort(), asorti() functions, to sort arrays + sub-arrays: array element values can be arrays + isarray() function, to test whether a value is an array + + PROCINFO["strftime"] can be used to supply default format for + date/time formatting by strftime() function + mktime() function, to convert list of separate date and time fields + into single numeric date/time value + and(), or(), xor(), compl(), lshift(), rshift() functions, to + perform bit-wise logic operations on numeric values + strtonum() function, to convert string of digits into number, with + support for radix prefix '0' (octal) and '0x' (hexadecimal) + + VMS-specific + New command qualifiers: /EXTRA_COMMANDS, /PROFILE, /DUMP_VARIABLES, + /OPTIMIZE, /TRADITIONAL, /SANDBOX, /NON_DECIMAL_DATA + Revised qualifier: /LINT, takes optional argument list + Deprecated qualifier: /STRICT, superseded by /TRADITIONAL +3 prior_changes + Changes between version 3.1.8 and [...] and 3.0.6 + + [Someday someone ought to dig up and document this information....] + + Changes between version 3.0.6 and 2.15.6 + + General + RS can contain multiple characters or be a regexp + Regular expression interval support added + gensub() and fflush() functions added + memory leak(s) introduced in 3.0.2 or 3.0.1 fixed + the user manual has been substantially revised + + VMS-specific + Switched to build with DEC C by default + Changes between version 2.15.6 and 2.14 + + General + Many obscure bugs fixed + `delete' may operate on an entire array + ARGIND and ERRNO builtin variables added + + VMS-specific + `>+ file' binary-mode output redirection added + /variable=(foo=42) fixed + Floating point number formatting improved + + Changes between version 2.14 and 2.13.2: + + General + 'next file' construct added + 'continue' outside of any loop is treated as 'next' + Assorted bug fixes and efficiency improvements + _The_GAWK_Manual_ updated + Test suite expanded + + VMS-specific + VMS POSIX support added + Disk I/O throughput enhanced + Pipe emulation improved and incorrect interaction with user-mode + redefinition of SYS$OUTPUT eliminated + + Changes between version 2.13 and 2.11.1: (2.12 was not released) + + General + CONVFMT and FIELDWIDTHS builtin control variables added + systime() and strftime() date/time functions added + 'lint' and 'posix' run-time options added + '-W' command line option syntax supercedes '-c', '-C', and '-V' + '-a' and '-e' regular expression options made obsolete + Various bug fixes and efficiency improvements + More platforms supported ('officially' including VMS) + + VMS-specific + %g printf format fixed + Handling of '\' on command line modified; no longer necessary to + double it up + Problem redirecting stderr (>&efile) at same time as stdin (ofile) has been fixed + ``2>&1'' and ``1>&2'' redirection constructs added + Interaction between command line I/O redirection and gawk pipes + fixed; also, name used for pseudo-pipe temporary file expanded +3 license + GAWK is covered by the "GNU General Public License", the gist of which + is that if you supply this software to a third party, you are expressly + forbidden to prevent them from supplying it to a fourth party, and if + you supply binaries you must make the source code available to them + at no additional cost. Any revisions or modified versions are also + covered by the same license. There is no warranty, express or implied, + for this software. It is provided "as is." + + [Disclaimer: This is just an informal summary with no legal basis; + refer to the actual GNU General Public License for specific details.] +!2 examples +! diff --git a/vms/gawkmisc.vms b/vms/gawkmisc.vms new file mode 100644 index 0000000..346a1e8 --- /dev/null +++ b/vms/gawkmisc.vms @@ -0,0 +1,196 @@ +/* + * gawkmisc.vms --- miscellanious gawk routines that are OS specific. + */ + +/* + * Copyright (C) 1986, 1988, 1989, 1991-1996, 2003, 2011 the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Progamming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +char quote = '\''; +char *defpath = DEFPATH; +char envsep = ','; + +/* gawk_name --- pull out the "gawk" part from how the OS called us */ + +char * +gawk_name(filespec) +const char *filespec; +{ + char *p, *q; + + /* "device:[root.][directory.subdir]GAWK.EXE;n" -> "GAWK" */ + p = strrchr(filespec, ']'); /* directory punctuation */ + q = strrchr(filespec, '>'); /* alternate punct */ + + if (p == NULL || q > p) + p = q; + p = strdup(p == NULL ? filespec : (p + 1)); + if ((q = strrchr(p, '.')) != NULL) + *q = '\0'; /* strip .typ;vers */ + + return p; +} + +/* os_arg_fixup --- fixup the command line */ + +void +os_arg_fixup(argcp, argvp) +int *argcp; +char ***argvp; +{ + (void) vms_arg_fixup(argcp, argvp); +} + +/* os_devopen --- open special per-OS devices */ + +int +os_devopen(name, flag) +const char *name; +int flag; +{ + return vms_devopen(name, flag); +} + +/* optimal_bufsize --- determine optimal buffer size */ + +size_t +optimal_bufsize(fd, stb) +int fd; +struct stat *stb; +{ + + /* force all members to zero in case OS doesn't use all of them. */ + memset(stb, '\0', sizeof(struct stat)); + + /* + * These values correspond with the RMS multi-block count used by + * vms_open() in vms/vms_misc.c. + */ + if (isatty(fd) > 0) + return BUFSIZ; + else if (fstat(fd, stb) < 0) + return 8*512; /* conservative in case of DECnet access */ + else + return 32*512; +} + +/* ispath --- return true if path has directory components */ + +int +ispath(file) +const char *file; +{ + for (; *file; file++) { + switch (*file) { + case ':': + case ']': + case '>': + case '/': + return 1; + } + } + return 0; +} + +/* isdirpunct --- return true if char is a directory separator */ + +int +isdirpunct(c) +int c; +{ + return (strchr(":]>/", c) != NULL); +} + +/* os_close_on_exec --- set close on exec flag, print warning if fails */ + +void +os_close_on_exec(fd, name, what, dir) +int fd; +const char *name, *what, *dir; +{ + /* no-op */ +} + +/* os_isdir --- is this an fd on a directory? */ + +#if ! defined(S_ISDIR) && defined(S_IFDIR) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif + +int +os_isdir(fd) +int fd; +{ + struct stat sbuf; + + return (fstat(fd, &sbuf) == 0 && S_ISDIR(sbuf.st_mode)); +} + +/* os_is_setuid --- true if running setuid root */ + +int +os_is_setuid() +{ + return 0; +} + +/* os_setbinmode --- set binary mode on file */ + +int +os_setbinmode (fd, mode) +int fd, mode; +{ + return 0; +} + +/* os_restore_mode --- restore the original mode of the console device */ + +void +os_restore_mode (fd) +int fd; +{ + /* no-op */ + return; +} + +/* files_are_same --- deal with VMS struct stat */ + +int +files_are_same(char *newfile, SRCFILE *oldfile) +{ + struct stat st, *f1, *f2; + + f1 = &st; + if (stat(newfile, f1) != 0) return 0; + + f2 = &oldfile->sbuf; + /* compare device string */ + return (strcmp(f1->st_dev, f2->st_dev) == 0 + /* and 48-bit file id cookie stored in 3 short ints */ + && f1->st_ino[0] == f2->st_ino[0] + && f1->st_ino[1] == f2->st_ino[1] + && f1->st_ino[2] == f2->st_ino[2]); +} + +int +os_isatty(int fd) +{ + return (isatty(fd) > 0); +} diff --git a/vms/posix-cc.sh b/vms/posix-cc.sh new file mode 100755 index 0000000..6ac7099 --- /dev/null +++ b/vms/posix-cc.sh @@ -0,0 +1,16 @@ +# The VMS POSIX `c89' command writes any/all diagnostic info to stdout +# rather than stderr, confusing configure tests which capture error output. +# +# Also, the VMS linker issues a warning for any undefined symbol, but that +# does not inhibit creation of the final executable file, again confusing +# configure. As an added complication, there's not enough control of the +# linker to put the map file with chosen name into the current directory. +# +if [ -f ~/_posix-cc.map ] ; then rm -f ~/_posix-cc.map* ; fi +c89 -Wc,nowarn -Wl,nodebug -Wl,map=_posix-cc.map $* ; x=$? +if [ -f ~/_posix-cc.map ] ; then + if [ -n "`fgrep LINK-W-USEUNDEF ~/_posix-cc.map`" ] ; then x=1 ; fi + rm -f ~/_posix-cc.map* +fi +if [ x -ne 0 ] ; then echo "c89 reports failure" 1>&2 && exit 1 ; fi +exit 0 diff --git a/vms/redirect.h b/vms/redirect.h new file mode 100644 index 0000000..b7388c9 --- /dev/null +++ b/vms/redirect.h @@ -0,0 +1,133 @@ +/* + * redirect.h --- definitions for functions that are OS specific. + */ + +/* + * Copyright (C) 1986, 1988, 1989, 1991-1993, 1996, 1997, 2007, 2010, 2011 + * the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* This file is included by custom.h for VMS-POSIX, or first + by config.h (vms-conf.h) then again by awk.h for normal VMS. */ + +#if defined(VMS_POSIX) || defined(IN_CONFIG_H) + +#define DEFAULT_FILETYPE ".awk" + +/* some macros to redirect some non-VMS-specific code */ +#define getopt gnu_getopt +#define opterr gnu_opterr +#define optarg gnu_optarg +#define optind gnu_optind +#define optopt gnu_optopt +#define regcomp gnu_regcomp +#define regexec gnu_regexec +#define regfree gnu_regfree +#define regerror gnu_regerror +#define setenv gawk_setenv +#define unsetenv gawk_unsetenv +#ifndef VMS_POSIX +#define strftime gnu_strftime /* always use missing/strftime.c */ +#define strcasecmp gnu_strcasecmp +#define strncasecmp gnu_strncasecmp +#ifndef VMS_V7 +#define tzset fake_tzset +#define tzname fake_tzname +#define daylight fake_daylight +#define timezone fake_timezone +#define altzone fake_altzone +#endif +#if !defined(__DECC) && !defined(VAXC2DECC) && !defined(__alpha) +#define strcoll(s,t) strcmp((s),(t)) /* VAXCRTL lacks locale support */ +#endif +#endif + +#ifdef STDC_HEADERS +/* This is for getopt.c and alloca.c (compiled with HAVE_CONFIG_H defined), + to prevent diagnostics about various implicitly declared functions. */ +#include +#include +#endif +#ifndef VMS_POSIX +/* This if for random.c. */ +#define gettimeofday vms_gettimeofday +#ifndef __TIMEVAL +#define __TIMEVAL 1 +struct timeval { long tv_sec, tv_usec; }; +#endif +extern int gettimeofday(struct timeval *,void *); +#endif + +#else /* awk.h, not POSIX */ + +/* some macros to redirect to code in vms/vms_misc.c */ +#ifndef bcopy +#define bcopy vms_bcopy +#endif +#define open vms_open +#define popen vms_popen +#define pclose vms_pclose +#ifndef HAVE_SNPRINTF +#define snprintf gawk_snprintf /* avoid %CC-I-INTRINSICDECL diagnostic */ +#define vsnprintf gawk_vsnprintf +#endif +/* supply missing or suppressed (due to defines in config.h) declarations */ +extern int snprintf(char *,size_t,const char *,...); +extern int vsnprintf(char *restrict,size_t,const char *,va_list); +extern int setenv(const char *,const char *,int); +extern int unsetenv(const char *); +#define strerror vms_strerror +#define strdup vms_strdup +#define unlink vms_unlink +#if defined(VAXC) || (defined(__GNUC__) && !defined(__alpha)) +#define fstat(fd,sb) VMS_fstat(fd,sb) +#endif +extern void exit(int); +extern int open(const char *,int,...); +extern char *strerror(int); +extern char *strdup(const char *str); +extern int vms_devopen(const char *,int); +# ifndef NO_TTY_FWRITE +#define fwrite tty_fwrite +#define fclose tty_fclose +extern size_t fwrite(const void *,size_t,size_t,FILE *); +extern int fclose(FILE *); +# endif +extern FILE *popen(const char *,const char *); +extern int pclose(FILE *); +extern void vms_arg_fixup(int *,char ***); +/* some things not in STDC_HEADERS */ +extern size_t gnu_strftime(char *,size_t,const char *,const struct tm *); +extern int unlink(const char *); +extern int getopt(int,char **,char *); +extern int isatty(int); +#ifndef fileno +extern int fileno(FILE *); +#endif +extern int close(int); +extern int dup(int); +extern int dup2(int, int); +extern int read(int, void *, int); +extern int getpgrp(void); +extern void tzset(void); + +#endif /* not VMS_POSIX and not IN_CONFIG_H */ + +/*vms/redirect.h*/ diff --git a/vms/unixlib.h b/vms/unixlib.h new file mode 100644 index 0000000..24fadce --- /dev/null +++ b/vms/unixlib.h @@ -0,0 +1,27 @@ +/* "unixlib.h" -- limited substitute for VAX C V3.x's , + * for use with VAX C V2.x and/or GNU C when building gawk. + */ + + +/* declare the global environ[] array */ +#ifdef VAXC +extern char noshare **environ; +#else +# ifdef __GNUC__ +# define environ $$PsectAttributes_NOSHR$$environ +# endif +extern char **environ; +#endif + +/* miscellaneous Unix emulation routines available in VAXCRTL */ +char *getenv(), *getcwd(); + +char *ecvt(), *fcvt(), *gcvt(); + +int getpid(), getppid(); + +unsigned getuid(); +#ifndef _stdlib_h /* gcc's stdlib.h has these with conflicting types */ +unsigned getgid(), getegid(), geteuid(); +#endif +int setgid(), setuid(); /* no-ops */ diff --git a/vms/varargs.h b/vms/varargs.h new file mode 100644 index 0000000..ce66e7d --- /dev/null +++ b/vms/varargs.h @@ -0,0 +1,38 @@ +/* "varargs.h" -- old style variable argument list manipulation (for VAX) */ +#ifndef __GNUC__ + + /* Use the system's macros with the system's compiler. */ +#include + +#else /*__GNUC__*/ + +# if defined(__VAX__) || defined(__vax__) || defined(VAX) || defined(vax) + /* These macros implement traditional (non-ANSI) varargs for GNU C on VAX */ + +# if !defined(_VA_LIST) && !defined(_VA_LIST_) +# define _VA_LIST +# define _VA_LIST_ +typedef char *va_list; +# endif + +# define va_alist _varargs +# define va_dcl int va_alist; +# define va_start(AP) AP = (va_list) &va_alist +# define va_end(AP) + +# define _va_rounded_size(TYPE) \ + (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) + +# define va_arg(AP,TYPE) \ + (AP += _va_rounded_size(TYPE), \ + *((TYPE *) (AP - _va_rounded_size(TYPE)))) + +# if defined(__VMS__) || defined(__vms__) || defined(VMS) || defined(vms) + /* VAX C compatability macros */ +# define va_count(CNT) vaxc$va_count(&CNT) /* rtl routine */ +# define va_start_1(AP,OFFSET) AP = (va_list) (&va_alist + (OFFSET)) +# endif /* VMS */ + +# endif /* VAX */ + +#endif /*__GNUC__*/ diff --git a/vms/vms-conf.h b/vms/vms-conf.h new file mode 100644 index 0000000..b81c20a --- /dev/null +++ b/vms/vms-conf.h @@ -0,0 +1,667 @@ +#ifndef CONFIG_H +#define CONFIG_H +/* + * config.h -- configuration definitions for gawk. + * + * For VMS (assumes V4.6 or later; tested on V7.3-1, V8.3. + */ + +/* + * Copyright (C) 1991-1992, 1995-1996, 1999, 2001-2003, 2005, 2009, 2010, 2011, + * 2012, the Free Software Foundation, Inc. + * + * This file is part of GAWK, the GNU implementation of the + * AWK Programming Language. + * + * GAWK is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * GAWK is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* switch statements are enabled in awk programs */ +#undef ALLOW_SWITCH + +#if 0 /* no longer used */ +/* Define to 1 if using alloca.c. */ +#define C_ALLOCA 1 +#else +#define NO_ALLOCA /* vms/vms_fwrite.c needs this */ +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#define STACK_DIRECTION (-1) +#endif /*0*/ + +/* dynamic loading is possible */ +#undef DYNAMIC + +/* Define to 1 if translation of program messages to the user's native + language is requested. */ +#undef ENABLE_NLS + +/* Define to the type of elements in the array set by `getgroups'. Usually + this is either `int' or `gid_t'. */ +#define GETGROUPS_T int + +/* Define to 1 if the `getpgrp' function requires zero arguments. */ +#define GETPGRP_VOID 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_ARPA_INET_H + +/* Define to 1 if you have the `atexit' function. */ +#define HAVE_ATEXIT 1 + +/* Define to 1 if you have the `btowc' function. */ +#undef HAVE_BTOWC + +/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the + CoreFoundation framework. */ +#undef HAVE_CFLOCALECOPYCURRENT + +/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in + the CoreFoundation framework. */ +#undef HAVE_CFPREFERENCESCOPYAPPVALUE + +/* Define if the GNU dcgettext() function is already present or preinstalled. + */ +#undef HAVE_DCGETTEXT + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +#undef HAVE_DECL_TZNAME + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +#undef HAVE_DOPRNT + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the `fmod' function. */ +#define HAVE_FMOD 1 + +/* have getaddrinfo */ +#undef HAVE_GETADDRINFO + +/* Define to 1 if you have the `getgrent' function. */ +#undef HAVE_GETGRENT + +/* Define to 1 if you have the `getgroups' function. */ +#undef HAVE_GETGROUPS + +/* Define if the GNU gettext() function is already present or preinstalled. */ +#undef HAVE_GETTEXT + +/* Define to 1 if you have the `grantpt' function. */ +#undef HAVE_GRANTPT + +/* Define if you have the iconv() function. */ +#undef HAVE_ICONV + +/* Define if you have the 'intmax_t' type in or . */ +#undef HAVE_INTMAX_T + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define if exists, doesn't clash with , and + declares uintmax_t. */ +#undef HAVE_INTTYPES_H_WITH_UINTMAX + +/* Define to 1 if you have the `isascii' function. */ +#define HAVE_ISASCII 1 + +/* Define to 1 if you have the `iswctype' function. */ +#define HAVE_ISWCTYPE 1 + +/* Define to 1 if you have the `iswlower' function. */ +#define HAVE_ISWLOWER 1 + +/* Define to 1 if you have the `iswupper' function. */ +#define HAVE_ISWUPPER 1 + +/* Define if you have and nl_langinfo(CODESET). */ +#undef HAVE_LANGINFO_CODESET + +/* Define if your file defines LC_MESSAGES. */ +#undef HAVE_LC_MESSAGES + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIBINTL_H + +/* Define if you have the libsigsegv library. */ +#undef HAVE_LIBSIGSEGV + +/* Define to 1 if you have the `m' library (-lm). */ +#undef HAVE_LIBM + +/* Define to 1 if you have a fully functional readline library. */ +#undef HAVE_LIBREADLINE + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_LOCALE_H + +/* Define if you have the 'long long' type. */ +#undef HAVE_LONG_LONG + +/* Define to 1 if the system has the type `long long int'. */ +#undef HAVE_LONG_LONG_INT + +/* Define to 1 if you have the `mbrlen' function. */ +#define HAVE_MBRLEN 1 + +/* Define to 1 if mbrtowc and mbstate_t are properly declared. */ +#define HAVE_MBRTOWC 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_MCHECK_H + +/* Define to 1 if you have the `memcmp' function. */ +#define HAVE_MEMCMP 1 + +/* Define to 1 if you have the `memcpy' function. */ +#define HAVE_MEMCPY 1 + +/* Define to 1 if you have the `memcpy_ulong' function. */ +#undef HAVE_MEMCPY_ULONG + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if you have the `memset_ulong' function. */ +#undef HAVE_MEMSET_ULONG + +/* Define to 1 if you have the `mkstemp' function. */ +#undef HAVE_MKSTEMP + +/* we have the mktime function */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETDB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_IN_H + +/* we'll use the one in [.missing_d] */ +#undef HAVE_SETENV + +/* Define to 1 if you have the `setlocale' function. */ +#undef HAVE_SETLOCALE + +/* Define to 1 if you have the `setsid' function. */ +#undef HAVE_SETSID + +/* Define to 1 if you have the `snprintf' function. */ +#undef HAVE_SNPRINTF + +/* newer systems define this type here */ +#undef HAVE_SOCKADDR_STORAGE + +/* we have sockets on this system */ +#undef HAVE_SOCKETS + +/* Define to 1 if you have the header file. */ +#define HAVE_STDARG_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDDEF_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define if exists, doesn't clash with , and declares + uintmax_t. */ +#undef HAVE_STDINT_H_WITH_UINTMAX + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strchr' function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the `strcoll' function. */ +#define HAVE_STRCOLL 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the `strftime' function. */ +#undef HAVE_STRFTIME /* use the missing_d/strfime.c version */ + +/* Define to 1 if cpp supports the ANSI # stringizing operator. */ +#ifdef VAXC +#undef HAVE_STRINGIZE +#else +#define HAVE_STRINGIZE 1 +#endif + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strncasecmp' function. */ +#undef HAVE_STRNCASECMP + +/* Define to 1 if you have the header file. */ +#undef HAVE_STROPTS_H + +/* Define to 1 if you have the `strtod' function. */ +#define HAVE_STRTOD 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_BLKSIZE + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#undef HAVE_STRUCT_TM_TM_ZONE + +/* Define to 1 if your `struct stat' has `st_blksize'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLKSIZE' instead. */ +#undef HAVE_ST_BLKSIZE + +/* Define to 1 if you have the `system' function. */ +#define HAVE_SYSTEM 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have that is POSIX.1 compatible. */ +#undef HAVE_SYS_WAIT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_TERMIOS_H + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 +/* Force snprintf.c to use tmpfile() instead of mkstemp(). */ +#ifdef HAVE_MKSTEMP +#undef HAVE_MKSTEMP +#endif + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#undef HAVE_TM_ZONE + +/* Define to 1 if you have the `towlower' function. */ +#define HAVE_TOWLOWER 1 + +/* Define to 1 if you have the `towupper' function. */ +#define HAVE_TOWUPPER 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +#define HAVE_TZNAME 1 /* (faked in vms/vms_misc.c) */ + +/* Define to 1 if you have the `tzset' function. */ +#define HAVE_TZSET 1 /* (faked in vms/vms_misc.c) */ + +/* Define if you have the 'uintmax_t' type in or . */ +#undef HAVE_UINTMAX_T + +/* Define to 1 if you have the header file. */ +#ifdef __DECC +#define HAVE_UNISTD_H 1 +#else +#undef HAVE_UNISTD_H +#endif + +/* Define if you have the 'unsigned long long' type. */ +#undef HAVE_UNSIGNED_LONG_LONG + +/* Define to 1 if the system has the type `unsigned long long int'. */ +#undef HAVE_UNSIGNED_LONG_LONG_INT + +/* Define to 1 if you have the `usleep' function. */ +#define HAVE_USLEEP 1 + +/* Define to 1 if you have the `vprintf' function. */ +#define HAVE_VPRINTF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcrtomb' function. */ +#define HAVE_WCRTOMB 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define to 1 if you have the `wctype' function. */ +#define HAVE_WCTYPE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_WCTYPE_H 1 + +/* systems should define this type here */ +#define HAVE_WCTYPE_T 1 + +/* systems should define this type here */ +#undef HAVE_WINT_T + +/* disable fatal errors on directories */ +#undef NO_DIRECTORY_FATAL + +/* disable lint checks */ +#undef NO_LINT + +/* Name of package */ +#define PACKAGE "gawk" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "bug-gawk@gnu.org" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "GNU Awk" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "GNU Awk 3.1.8" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "gawk" + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "4.0.1" + +/* Define to 1 if *printf supports %F format */ +#undef PRINTF_HAS_F_FORMAT + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* The size of a `unsigned int', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_INT 4 + +/* The size of a `unsigned long', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_LONG 4 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* some systems define this type here */ +#undef TIME_T_IN_SYS_TYPES_H + +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Define to 1 if your declares `struct tm'. */ +#undef TM_IN_SYS_TIME + +/* force use of our version of strftime */ +#define USE_INCLUDED_STRFTIME 1 + +/* Version number of package */ +#define VERSION "4.0.1" + +/* Define to 1 if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +#undef _FILE_OFFSET_BITS + +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif + +/* Define for large files, on AIX-style hosts. */ +#undef _LARGE_FILES + +/* Define to 1 if on MINIX. */ +#undef _MINIX + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +#undef _POSIX_1_SOURCE + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +#undef _POSIX_SOURCE + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +# undef __CHAR_UNSIGNED__ +#endif + +/* Enable extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `int' if doesn't define. */ +#undef gid_t + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif + +/* Define to widest signed type if doesn't define. */ +#define intmax_t long int + +/* Define to `int' if doesn't define. */ +#undef pid_t + +/* Define to the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported directly. */ +#define restrict +#if defined(__DECC) && (__DECC_VER >= 60400000) +#undef restrict +#endif + +/* Define to `unsigned' if doesn't define. */ +#undef size_t + +/* type to use in place of socklen_t if not defined */ +#undef socklen_t + +/* Define to `int' if does not define. */ +#define ssize_t int + +/* Define to `int' if doesn't define. */ +#undef uid_t + +/* Define to unsigned long or unsigned long long if and + don't define. */ +#define uintmax_t unsigned long + +#if 0 +#include "custom.h" /* overrides for stuff autoconf can't deal with */ +#else + +/* Whether `time_t' is an unsigned type. */ +#define TIME_T_UNSIGNED 1 + +/*******************************/ +/* Gawk configuration options. */ +/*******************************/ + +#define ALLOW_SWITCH 1 + +/* + * DEFPATH + * VMS: "/AWK_LIBRARY" => "AWK_LIBRARY:" + * The default search path for the -f option of gawk. It is used + * if the AWKPATH environment variable is undefined. + * + * Note: OK even if no AWK_LIBRARY logical name has been defined. + */ + +#define DEFPATH ".,/AWK_LIBRARY" +#define ENVSEP ',' + +/* + * Extended source file access. + */ +#define DEFAULT_FILETYPE ".awk" + +/* + * Pipe handling. + */ +#define PIPES_SIMULATED 1 + +/* + * VAXCRTL is pre-ANSI and does some variations of numeric formatting + * differently than gawk expects. + */ +#if defined(VAX) && !defined(__DECC) +/* '0' format modifier for %e,%f,%g gives wrong results in many cases */ +#define VAXCRTL +/* %g format chooses %e format when should use %f */ +#define GFMT_WORKAROUND 1 +#endif + +/* + * VAX C + * + * As of V3.2, VAX C is not yet ANSI-compliant. But it's close enough + * for GAWK's purposes. Comment this out for VAX C V2.4 and earlier. + * YYDEBUG definition is needed for combination of VAX C V2.x and Bison. + */ +#if defined(VAXC) && !defined(__STDC__) +#define __STDC__ 0 +#define NO_TOKEN_PASTING +#define signed /*empty*/ +#define inline /*empty*/ +#ifndef __DECC /* DEC C does not support #pragma builtins even in VAXC mode */ +#define VAXC_BUILTINS +#endif +/* #define YYDEBUG 0 */ +#define NO_MBSUPPORT /* VAX C's preprocessor can't handle mbsupport.h */ +#define RE_TOKEN_INIT_BUG /* regcomp.c */ +#endif + +/* + * DEC C + * + * Digital's ANSI complier. + */ +#ifdef __DECC + /* DEC C implies DECC$SHR, which doesn't have the %g problem of VAXCRTL */ +#undef GFMT_WORKAROUND + /* DEC C V5.x introduces incompatibilities with prior porting efforts */ +#define _DECC_V4_SOURCE +#define __SOCKET_TYPEDEFS +#if __VMS_VER >= 60200000 +# undef __VMS_VER +# define __VMS_VER 60100000 +#endif +#if __CRTL_VER >= 60200000 +# if __CRTL_VER >= 70320000 +# define CRTL_VER_V732 +# define HAVE_SNPRINTF 1 +# endif +# if __CRTL_VER >= 70301000 +# define CRTL_VER_V731 +# endif +# undef __CRTL_VER +# define __CRTL_VER 60100000 +#endif +#if __DECC_VER >= 60400000 && !defined(DEBUG) +/* disable "new feature in C99" diagnostics (for regex code); + NEWC99 ought to suffice but doesn't (at least in V6.4) */ +#pragma message disable (NEWC99,DESIGNATORUSE) +#endif +#endif /* __DECC */ + +/* + * GNU C + * + * Versions of GCC (actually GAS) earlier than 1.38 don't produce the + * right code for ``extern const'' constructs, and other usages of + * const might not be right either. The old set of include files from + * the gcc-vms distribution did not contain prototypes, and this could + * provoke some const-related compiler warnings. If you've got an old + * version of gcc for VMS, define 'const' out of existance, and by all + * means obtain the most recent version! + * + * Note: old versions of GCC should also avoid defining STDC_HEADERS, + * because most of the ANSI-C required header files are missing. + */ +#ifdef __GNUC__ +/* #define const */ +/* #undef STDC_HEADERS */ +/* #undef HAVE_STDDEF_H */ +#ifndef STDC_HEADERS +#define alloca __builtin_alloca +#define environ $$PsectAttributes_NOSHR$$environ /* awful GAS kludge */ +#endif +#undef REGEX_MALLOC /* use true alloca() in regex.c */ +#endif + +/* EXIT_SUCCESS and EXIT_FAILURE normally come from */ +#ifndef HAVE_STDLIB_H +# define EXIT_SUCCESS 1 /* SYS$_NORMAL */ +# define EXIT_FAILURE 0x10000002 /* STS$M_INHIB_MSG|STS$K_ERROR */ +#endif +/* EXIT_FATAL is specific to gawk, not part of Standard C */ +#define EXIT_FATAL 0x10000004 /* STS$M_INHIB_MSG|STS$K_SEVERE */ + +#define IN_CONFIG_H +#include "vms/redirect.h" +#undef IN_CONFIG_H + +#endif /*"custom.h"*/ + +#endif /*CONFIG_H*/ diff --git a/vms/vms.h b/vms/vms.h new file mode 100644 index 0000000..0fb73d5 --- /dev/null +++ b/vms/vms.h @@ -0,0 +1,88 @@ +/* + * vms.h - miscellaneous definitions for use with VMS system services. + * Pat Rankin, Nov'89 + */ + +#if 0 +#include +#else +#define IO$_WRITEVBLK 48 /* write virtual block */ +#define IO$V_CANCTRLO 6 /* cancel (ie, resume tty output) */ +#define IO$M_CANCTRLO (1 << IO$V_CANCTRLO) +#endif + +#if 0 +#include +#include +#include +#else +#define CLI$K_GETCMD 1 +#define CLI$K_VERB_MCR 33 +#define CLI$K_VERB_RUN 36 +#define FSCN$_FILESPEC 1 +#endif + +#if 0 +#include +#else +#define CLI$_RUNUSED 0x00030000 /* value returned by $CLI for "RUN" */ +#define CLI$_SYNTAX 0x000310FC /* error signalled by CLI$DCL_PARSE */ +#define CLI$_INSFPRM 0x00038048 /* insufficient parameters */ +#define CLI$_VALREQ 0x00038150 /* missing required value */ +#define CLI$_NEGATED 0x000381F8 /* explicitly negated */ +#define CLI$_CONFLICT 0x00038258 /* conflicting qualifiers */ +#define CLI$_NOOPTPRS 0x00038840 /* no option present */ +#endif + +#if 0 +#include +#else +#define PSL$C_USER 3 /* user mode */ +#endif + +/* note: `ulong' and `u_long' end up conflicting with various header files */ +typedef unsigned long U_Long; +typedef unsigned short U_Short; + +typedef struct _dsc { int len; char *adr; } Dsc; /* limited string descriptor */ + /* standard VMS itemlist-3 structure */ +typedef struct _itm { U_Short len, code; void *buffer; U_Short *retlen; } Itm; + +#define vmswork(sts) ((sts)&1) +#define vmsfail(sts) (!vmswork(sts)) +#define CondVal(sts) ((sts)&0x0FFFFFF8) /* strip severity & msg inhibit */ +#define Descrip(strdsc,strbuf) Dsc strdsc = {sizeof strbuf - 1, (char *)strbuf} + +extern int shell$is_shell(void); +extern U_Long lib$find_file(const Dsc *, Dsc *, void *, ...); +extern U_Long lib$find_file_end(void *); +#ifndef NO_TTY_FWRITE +extern U_Long lib$get_ef(long *); +extern U_Long sys$assign(const Dsc *, short *, long, const Dsc *); +extern U_Long sys$dassgn(short); +extern U_Long sys$qio(U_Long, U_Long, U_Long, void *, + void (*)(U_Long), U_Long, + const char *, int, int, U_Long, int, int); +extern U_Long sys$synch(long, void *); +#endif /*!NO_TTY_FWRITE*/ +extern U_Long lib$spawn(const Dsc *,const Dsc *,const Dsc *, + const U_Long *,const Dsc *,U_Long *,U_Long *,...); + /* system services for logical name manipulation */ +extern U_Long sys$trnlnm(const U_Long *,const Dsc *,const Dsc *, + const unsigned char *,Itm *); +extern U_Long sys$crelnm(const U_Long *,const Dsc *,const Dsc *, + const unsigned char *,const Itm *); +extern U_Long sys$crelog(int,const Dsc *,const Dsc *,unsigned char); +extern U_Long sys$dellnm(const Dsc *,const Dsc *,const unsigned char *); + +extern void v_add_arg(int, const char *); +extern void vms_exit(int); +extern char *vms_strerror(int); +extern char *vms_strdup(const char *); +extern int vms_devopen(const char *,int); +extern int vms_execute(const char *, const char *, const char *); +extern int vms_gawk(void); +extern U_Long Cli_Present(const char *); +extern U_Long Cli_Get_Value(const char *, char *, int); +extern U_Long Cli_Parse_Command(const void *, const char *); + diff --git a/vms/vms_args.c b/vms/vms_args.c new file mode 100644 index 0000000..0a29610 --- /dev/null +++ b/vms/vms_args.c @@ -0,0 +1,417 @@ +/* vms_args.c -- command line parsing, to emulate shell i/o redirection. + [ Escape sequence parsing now suppressed. ] + + Copyright (C) 1991-1996, 1997, 2011 the Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* + * [.vms]vms_arg_fixup - emulate shell's command line processing: handle + * stdio redirection, backslash escape sequences, and file wildcard + * expansion. Should be called immediately upon image startup. + * + * Pat Rankin, Nov'89 + * rankin@pactechdata.com + * + * nfile - create 'nfile' as 'stdout' (stream-lf format) + * >>ofile - append to 'ofile' for 'stdout'; create it if necessary + * >&efile - point 'stderr' (SYS$ERROR) at 'efile', but don't open + * >$vfile - create 'vfile' as 'stdout', using rms attributes + * appropriate for a standard text file (variable length + * records with implied carriage control) + * >+vfile - create 'vfile' as 'stdout' in binary mode (using + * variable length records with implied carriage control) + * 2>&1 - special case: direct error messages into output file + * 1>&2 - special case: direct output data to error destination + * <- - error: stdin/stdout closure not implemented + * | anything - error; pipes not implemented + * & - error; background execution not implemented + * + * any\Xany - convert 'X' as appropriate; \000 will not work as + * intended since subsequent processing will misinterpret + * + * any*any - perform wildcard directory lookup to find file(s) + * any%any - " " ('%' is vms wildcard for '?' [ie, /./]) + * any?any - treat like 'any%any' unless no files match + * *, %, ? - if no file(s) match, leave original value in arg list + * + * + * Notes: a redirection operator can have optional white space between it + * and its filename; the operator itself *must* be preceded by white + * space so that it starts a separate argument. '<' is ambiguous + * since "file" is a valid VMS file specification; leading '<' is + * assumed to be stdin--use "\file" to override. '>$' is local + * kludge to force stdout to be created with text file RMS attributes + * instead of stream format; file sharing is disabled for stdout + * regardless. Multiple instances of stdin or stdout or stderr are + * treated as fatal errors rather than using the first or last. If a + * wildcard file specification is detected, it is expanded into a list + * of filenames which match; if there are no matches, the original + * file-spec is left in the argument list rather than having it expand + * into thin air. No attempt is made to identify and make $(var) + * environment substitutions--must draw the line somewhere! + * + * Oct'91, gawk 2.13.3 + * Open '<' with full sharing allowed, so that we can read batch logs + * and other open files. Create record-format output ('>$') with read + * sharing permited, so that others can read our output file to check + * progess. For stream output ('>' or '>>'), sharing is disallowed + * (for performance reasons). + * + * Sep'94, gawk 2.15.6 [pr] + * Add '>+' to force binary mode output, to enable better control + * for the user when the output destination is a mailbox or socket. + * (ORS = "\r\n" for tcp/ip.) Contributed by Per Steinar Iversen. + * + * Jan'11, gawk 4.0.0 [pr] + * If AWK_LIBRARY is undefined, define it to be SYS$LIBRARY: so + * that the default value of AWKPATH ends with a valid directory. + */ + +#include "awk.h" /* really "../awk.h" */ +#include "vms.h" +#include + + void v_add_arg(int, const char *); +static char *skipblanks(const char *); +static void vms_expand_wildcards(const char *); +static U_Long vms_define(const char *, const char *); +static char *t_strstr(const char *, const char *); +#define strstr t_strstr /* strstr() missing from vaxcrtl for V4.x */ + +static int v_argc, v_argz = 0; +static char **v_argv; + +/* vms_arg_fixup() - scan argv[] for i/o redirection and wildcards and also */ +/* rebuild it with those removed or expanded, respectively */ +void +vms_arg_fixup( int *pargc, char ***pargv ) +{ + const char *f_in, *f_out, *f_err, + *out_mode, *rms_rfm, *rms_shr, *rms_mrs; + char **argv = *pargv; + int i, argc = *pargc; + int err_to_out_redirect = 0, out_to_err_redirect = 0; + + /* make sure AWK_LIBRARY has a value */ + if (!getenv("AWK_LIBRARY")) + vms_define("AWK_LIBRARY", "SYS$LIBRARY:"); +#ifdef CHECK_DECSHELL /* don't define this if linking with DECC$SHR */ + if (shell$is_shell()) + return; /* don't do anything if we're running DEC/Shell */ +#endif +#ifndef NO_DCL_CMD + for (i = 1; i < argc ; i++) /* check for dash or other non-VMS args */ + if (strchr("->\\|", *argv[i])) break; /* found => (i < argc) */ + if (i >= argc && (v_argc = vms_gawk()) > 0) { /* vms_gawk => dcl_parse */ + /* if we successfully parsed the command, replace original argv[] */ + argc = v_argc, argv = v_argv; + v_argz = v_argc = 0, v_argv = NULL; + } +#endif + v_add_arg(v_argc = 0, argv[0]); /* store arg #0 (image name) */ + + f_in = f_out = f_err = NULL; /* stdio setup (no filenames yet) */ + out_mode = "w"; /* default access for stdout */ + rms_rfm = "rfm=stmlf"; /* stream_LF format */ + rms_shr = "shr=nil"; /* no sharing (for '>' output file) */ + rms_mrs = "mrs=0"; /* no maximum record size */ + + for (i = 1; i < argc; i++) { + char *p, *fn; + int is_arg; + + is_arg = 0; /* current arg does not begin with dash */ + p = argv[i]; /* current arg */ + switch (*p) { + case '<': /* stdin */ + /*[should try to determine whether this is really a directory + spec using <>; for now, force user to quote them with '\<']*/ + if ( f_in ) { + fatal("multiple specification of '<' for stdin"); + } else if (*++p == '<') { /* '<<' is not supported */ + fatal("'<<' not available for stdin"); + } else { + p = skipblanks(p); + fn = (*p ? p : argv[++i]); /* use next arg if necessary */ + if (i >= argc || *fn == '-') + fatal("invalid i/o redirection, null filespec after '<'"); + else + f_in = fn; /* save filename for stdin */ + } + break; + case '>': { /* stdout or stderr */ + /*[vms-specific kludge '>$' added to force stdout to be created + as record-oriented text file instead of in stream-lf format]*/ + int is_out = 1; /* assume stdout */ + if (*++p == '>') /* '>>' => append */ + out_mode = "a", p++; + else if (*p == '&') /* '>&' => stderr */ + is_out = 0, p++; + else if (*p == '$') /* '>$' => kludge for record format */ + rms_rfm = "rfm=var", rms_shr = "shr=get,upi", + rms_mrs = "mrs=32767", p++; + else if (*p == '+') /* '>+' => kludge for binary output */ + out_mode = "wb", rms_rfm = "rfm=var", + rms_mrs = "mrs=32767", p++; + else /* '>' => create */ + {} /* use default values initialized prior to loop */ + p = skipblanks(p); + fn = (*p ? p : argv[++i]); /* use next arg if necessary */ + if (i >= argc || *fn == '-') { + fatal("invalid i/o redirection, null filespec after '>'"); + } else if (is_out) { + if (out_to_err_redirect) + fatal("conflicting specifications for stdout"); + else if (f_out) + fatal("multiple specification of '>' for stdout"); + else + f_out = fn; /* save filename for stdout */ + } else { + if (err_to_out_redirect) + fatal("conflicting specifications for stderr"); + else if (f_err) + fatal("multiple specification of '>&' for stderr"); + else + f_err = fn; /* save filename for stderr */ + } + } break; + case '2': /* check for ``2>&1'' special case'' */ + if (strcmp(p, "2>&1") != 0) + goto ordinary_arg; + else if (f_err || out_to_err_redirect) + fatal("conflicting specifications for stderr"); + else { + err_to_out_redirect = 1; + f_err = "SYS$OUTPUT:"; + } break; + case '1': /* check for ``1>&2'' special case'' */ + if (strcmp(p, "1>&2") != 0) + goto ordinary_arg; + else if (f_out || err_to_out_redirect) + fatal("conflicting specifications for stdout"); + else { + out_to_err_redirect = 1; + /* f_out = "SYS$ERROR:"; */ + } break; + case '|': /* pipe */ + /* command pipelines are not supported */ + fatal("command pipes not available ('|' encountered)"); + break; + case '&': /* background */ + /*[we could probably spawn or fork ourself--maybe someday]*/ + if (*(p+1) == '\0' && i == argc - 1) { + fatal("background tasks not available ('&' encountered)"); + break; + } else { /* fall through */ + ; /*NOBREAK*/ + } + case '-': /* argument */ + is_arg = 1; /*(=> skip wildcard check)*/ + default: /* other (filespec assumed) */ +ordinary_arg: + /* process escape sequences or expand wildcards */ + v_add_arg(++v_argc, p); /* include this arg */ + p = strchr(p, '\\'); /* look for backslash */ + if (p != NULL) { /* does it have escape sequence(s)? */ +#if 0 /* disable escape parsing; it's now done elsewhere within gawk */ + register int c; + char *q = v_argv[v_argc] + (p - argv[i]); + do { + c = *p++; + if (c == '\\') + c = parse_escape(&p); + *q++ = (c >= 0 ? (char)c : '\\'); + } while (*p != '\0'); + *q = '\0'; +#endif /*0*/ + } else if (!is_arg && strchr(v_argv[v_argc], '=') == NULL) { + vms_expand_wildcards(v_argv[v_argc]); + } + break; + } /* end switch */ + } /* loop */ + + /* + * Now process any/all I/O options encountered above. + */ + + /* must do stderr first, or vaxcrtl init might not see it */ + /*[ catch 22: we'll also redirect errors encountered doing out ]*/ + if (f_err) { /* define logical name but don't open file */ + int len = strlen(f_err); + if (len >= (sizeof "SYS$OUTPUT" - sizeof "") + && strncasecmp(f_err, "SYS$OUTPUT:", len) == 0) + err_to_out_redirect = 1; + else + (void) vms_define("SYS$ERROR", f_err); + } + /* do stdin before stdout, so if we bomb we won't make empty output file */ + if (f_in) { /* [re]open file and define logical name */ + if (freopen(f_in, "r", stdin, + "ctx=rec", "shr=get,put,del,upd", + "mrs=32767", "mbc=32", "mbf=2")) + (void) vms_define("SYS$INPUT", f_in); + else + fatal("<%s (%s)", f_in, strerror(errno)); + } + if (f_out) { + if (freopen(f_out, out_mode, stdout, + rms_rfm, rms_shr, rms_mrs, + "rat=cr", "mbc=32", "mbf=2")) + (void) vms_define("SYS$OUTPUT", f_out); + else + fatal(">%s%s (%s)", (*out_mode == 'a' ? ">" : ""), + f_out, strerror(errno)); + } + if (err_to_out_redirect) { /* special case for ``2>&1'' construct */ + (void) dup2(1, 2); /* make file 2 (stderr) share file 1 (stdout) */ + (void) vms_define("SYS$ERROR", "SYS$OUTPUT:"); + } else if (out_to_err_redirect) { /* ``1>&2'' */ + (void) dup2(2, 1); /* make file 1 (stdout) share file 2 (stderr) */ + (void) vms_define("SYS$OUTPUT", "SYS$ERROR:"); + } + +#ifndef NO_DCL_CMD + /* if we replaced argv[] with our own, we can release it now */ + if (argv != *pargv) + free((void *)argv), argv = NULL; +#endif + *pargc = ++v_argc; /* increment to account for argv[0] */ + *pargv = v_argv; + return; +} + +/* vms_expand_wildcards() - check a string for wildcard punctuation; */ +/* if it has any, attempt a directory lookup */ +/* and store resulting name(s) in argv array */ +static void +vms_expand_wildcards( const char *prospective_filespec ) +{ + char *p, spec_buf[255+1], res_buf[255+1]; + Dsc spec, result; + void *context; + register int len = strlen(prospective_filespec); + + if (len >= sizeof spec_buf) + return; /* can't be valid--or at least we can't handle it */ + strcpy(spec_buf, prospective_filespec); /* copy the arg */ + p = strchr(spec_buf, '?'); + if (p != NULL) /* change '?' single-char wildcard to '%' */ + do *p++ = '%', p = strchr(p, '?'); + while (p != NULL); + else if (strchr(spec_buf, '*') == strchr(spec_buf, '%') /* => both NULL */ + && strstr(spec_buf, "...") == NULL) + return; /* no wildcards present; don't attempt file lookup */ + spec.len = len, spec.adr = spec_buf; + result.len = sizeof res_buf - 1, result.adr = res_buf; + + /* The filespec is already in v_argv[v_argc]; if we fail to match anything, + we'll just leave it there (unlike most shells, where it would evaporate). + */ + len = -1; /* overload 'len' with flag value */ + context = NULL; /* init */ + while (vmswork(lib$find_file(&spec, &result, &context))) { + for (len = sizeof(res_buf)-1; len > 0 && res_buf[len-1] == ' '; len--) ; + res_buf[len] = '\0'; /* terminate after discarding trailing blanks */ + v_add_arg(v_argc++, strdup(res_buf)); /* store result */ + } + (void)lib$find_file_end(&context); + if (len >= 0) /* (still -1 => never entered loop) */ + --v_argc; /* undo final post-increment */ + return; +} + +/* v_add_arg() - store string pointer in v_argv[]; expand array if necessary */ +void +v_add_arg( int idx, const char *val ) +{ +#ifdef DEBUG_VMS + fprintf(stderr, "v_add_arg: v_argv[%d] ", idx); +#endif + if (idx + 1 >= v_argz) { /* 'v_argz' is the current size of v_argv[] */ + int old_size = v_argz; + + v_argz = idx + 10; /* increment by arbitrary amount */ + if (old_size == 0) + v_argv = (char **)malloc((unsigned)(v_argz * sizeof(char **))); + else + v_argv = (char **)realloc((char *)v_argv, + (unsigned)(v_argz * sizeof(char **))); + if (v_argv == NULL) { /* error */ + fatal("%s: %s: can't allocate memory (%s)", "vms_args", + "v_argv", strerror(errno)); + } else { + while (old_size < v_argz) v_argv[old_size++] = NULL; + } + } + v_argv[idx] = (char *)val; +#ifdef DEBUG_VMS + fprintf(stderr, "= \"%s\"\n", val); +#endif +} + +/* skipblanks() - return a pointer to the first non-blank in the string */ +static char * +skipblanks( const char *ptr ) +{ + if (ptr) + while (*ptr == ' ' || *ptr == '\t') + ptr++; + return (char *)ptr; +} + +/* vms_define() - assign a value to a logical name [define/process/user_mode] */ +static U_Long +vms_define( const char *log_name, const char *trans_val ) +{ + Dsc log_dsc; + static Descrip(lnmtable,"LNM$PROCESS_TABLE"); + static U_Long attr = LNM$M_CONFINE; + static Itm itemlist[] = { {0,LNM$_STRING,0,0}, {0,0} }; + static unsigned char acmode = PSL$C_USER; + unsigned len = strlen(log_name); + + /* avoid "define SYS$OUTPUT sys$output:" for redundant ">sys$output:" */ + if (strncasecmp(log_name, trans_val, len) == 0 + && (trans_val[len] == '\0' || trans_val[len] == ':')) + return 0; + + log_dsc.adr = (char *)log_name; + log_dsc.len = len; + itemlist[0].buffer = (char *)trans_val; + itemlist[0].len = strlen(trans_val); + return sys$crelnm(&attr, &lnmtable, &log_dsc, &acmode, itemlist); +} + +/* t_strstr -- strstr() substitute; search 'str' for 'sub' */ +/* [strstr() was not present in VAXCRTL prior to VMS V5.0] */ +static char *t_strstr ( const char *str, const char *sub ) +{ + register const char *s0, *s1, *s2; + + /* special case: empty substring */ + if (!*sub) return (char *)str; + + /* brute force method */ + for (s0 = s1 = str; *s1; s1 = ++s0) { + s2 = sub; + while (*s1++ == *s2++) + if (!*s2) return (char *)s0; /* full match */ + } + return (char *)0; /* not found */ +} diff --git a/vms/vms_cli.c b/vms/vms_cli.c new file mode 100644 index 0000000..ac793c1 --- /dev/null +++ b/vms/vms_cli.c @@ -0,0 +1,109 @@ +/* vms_cli.c -- interface to CLI$xxx routines for fetching command line components + + Copyright (C) 1991-1993, 2003, 2011 the Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + + +/* + * vms_cli.c - command line interface routines. + * Pat Rankin, Nov'89 + * Routines called from vms_gawk.c for DCL parsing. + */ + +#include "config.h" /* in case we want to suppress 'const' &c */ +#include "vms.h" +#ifndef _STRING_H +#include +#endif + +extern U_Long cli$present(const Dsc *); +extern U_Long cli$get_value(const Dsc *, Dsc *, short *); +extern U_Long cli$dcl_parse(const Dsc *, const void *, ...); +extern U_Long sys$cli(void *, ...); +extern U_Long sys$filescan(const Dsc *, void *, long *); +extern void *lib$establish(U_Long (*handler)(void *, void *)); +extern U_Long lib$sig_to_ret(void *, void *); /* condition handler */ + +/* Cli_Present() - call CLI$PRESENT to determine whether a parameter or */ +/* qualifier is present on the [already parsed] command line */ +U_Long +Cli_Present( const char *item ) +{ + Dsc item_dsc; + (void)lib$establish(lib$sig_to_ret); + + item_dsc.len = strlen(item_dsc.adr = (char *)item); + return cli$present(&item_dsc); +} + +/* Cli_Get_Value() - call CLI$GET_VALUE to retreive the value of a */ +/* parameter or qualifier from the command line */ +U_Long +Cli_Get_Value( const char *item, char *result, int size ) +{ + Dsc item_dsc, res_dsc; + U_Long sts; + short len = 0; + (void)lib$establish(lib$sig_to_ret); + + item_dsc.len = strlen(item_dsc.adr = (char *)item); + res_dsc.len = size, res_dsc.adr = result; + sts = cli$get_value(&item_dsc, &res_dsc, &len); + result[len] = '\0'; + return sts; +} + +/* Cli_Parse_Command() - use the $CLI system service (undocumented) to */ +/* retreive the actual command line (which might be */ +/* "run prog" or "mcr prog [params]") and then call */ +/* CLI$DCL_PARSE to parse it using specified tables */ +U_Long +Cli_Parse_Command( const void *cmd_tables, const char *cmd_verb ) +{ + struct { short len, code; void *adr; } fscn[2]; + struct { char rqtype, rqindx, rqflags, rqstat; unsigned :32; + Dsc rdesc; unsigned :32; unsigned :32; unsigned :32; } cmd; + U_Long sts; + int ltmp; + char longbuf[8200]; + (void)lib$establish(lib$sig_to_ret); + + memset(&cmd, 0, sizeof cmd); + cmd.rqtype = CLI$K_GETCMD; /* command line minus the verb */ + sts = sys$cli(&cmd, (void *)0, (void *)0); /* get actual command line */ + + if (vmswork(sts)) { /* ok => cli available & verb wasn't "RUN" */ + /* invoked via symbol => have command line (which might be empty) */ + /* [might also be invoked via mcr or dcl; that's ok] */ + if (cmd.rqstat == CLI$K_VERB_MCR) { + /* need to strip image name from MCR invocation */ + memset(fscn, 0, sizeof fscn); + fscn[0].code = FSCN$_FILESPEC; /* full file specification */ + (void)sys$filescan(&cmd.rdesc, fscn, (long *)0); + cmd.rdesc.len -= fscn[0].len; /* shrink size */ + cmd.rdesc.adr += fscn[0].len; /* advance ptr */ + } + /* prepend verb and then parse the command line */ + strcat(strcpy(longbuf, cmd_verb), " "), ltmp = strlen(longbuf); + if (cmd.rdesc.len + ltmp > sizeof longbuf) + cmd.rdesc.len = sizeof longbuf - ltmp; + strncpy(&longbuf[ltmp], cmd.rdesc.adr, cmd.rdesc.len); + cmd.rdesc.len += ltmp, cmd.rdesc.adr = longbuf; + sts = cli$dcl_parse(&cmd.rdesc, cmd_tables); + } + + return sts; +} diff --git a/vms/vms_fwrite.c b/vms/vms_fwrite.c new file mode 100644 index 0000000..921ac2d --- /dev/null +++ b/vms/vms_fwrite.c @@ -0,0 +1,214 @@ +/* vms_fwrite.c - augmentation for the fwrite() function. + + Copyright (C) 1991-1996, 2010, 2011 the Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#include "awk.h" /* really "../awk.h" */ + +#ifndef NO_TTY_FWRITE +#include "vms.h" +#include +#include + +#ifdef VAXC_BUILTINS +#pragma builtins /* VAXC V3.0 & up */ +# define find_c(s,n,c) ((n) - _LOCC((c),(n),(s))) +#else /*VAXC_BUILTINS*/ +static int find_c( const char *s, int n, char c ) { + register const char *t = (const char *)memchr(s, c, n); + return (t == 0 ? n : t - s); /* 0..n-1, or n if not found */ +} +#endif /*VAXC_BUILTINS*/ +#define is_stdout(file_no) ((file_no) == 1) /* fileno(stdout) */ +#define is_stderr(file_no) ((file_no) == 2) /* fileno(stderr) */ + +#define PREFIX_CR 0x008D0000 /* leading carriage return */ +#define POSTFIX_CR 0x8D000000 /* trailing carriage return (=> lf/cr) */ + +static short channel[_NFILE] = {0}; +static FILE *prev_file = 0; +static int prev_file_num; + + /* + * VAXCRTL's fwrite() seems to flush after every character when + * writing to a terminal. This routine is a limited functionality + * substitute that is *much* faster. However, calls to fwrite() + * should not be mixed with other stdio calls to the same file + * unless fflush() is always called first. Also, this routine + * will not detect that a freopen() call has finished with the + * original terminal; tty_fclose() should be used to close a file. + * + * When running gawk's debugging version we stick with normal + * fwrite because dgawk also uses other stdio calls for output. + */ +#ifdef fwrite +# undef fwrite +#endif +/* tty_fwrite() - performance hack for fwrite() to a terminal */ +size_t +tty_fwrite( const void *buf, size_t size, size_t number, FILE *file ) +{ + static long evfn = -1; + short chan; + int file_num, result; + + if (!size || !number) + return 0; + else if (!file || !*file) + return 0 * (errno = EBADF); /* kludge alert! */ + else if (file == prev_file) + file_num = prev_file_num; + else /* note: VAXCRTL's fileno() is a function, not just a macro */ + prev_file_num = file_num = fileno(file), prev_file = file; + + chan = file_num < _NFILE ? channel[file_num] : -1; + if (chan == 0) { /* if not initialized, need to assign a channel */ + if (isatty(file_num) > 0 /* isatty: 1=yes, 0=no, -1=problem */ + && which_gawk != exe_debugging) { + Dsc device; + char devnam[255+1]; + + fgetname(file, devnam); /* get 'file's name */ + device.len = strlen(device.adr = devnam); /* create descriptor */ + if (vmswork(sys$assign(&device, &chan, 0, (Dsc *)0))) { + /* get an event flag; use #0 if problem */ + if (evfn == -1 && vmsfail(lib$get_ef(&evfn))) evfn = 0; + } else chan = 0; /* $ASSIGN failed */ + } + /* store channel for later use; -1 => don't repeat failed init attempt */ + channel[file_num] = (chan > 0 ? chan : -1); + } + + /* chan > 0 iff 'file' is a terminal and we're not running as dgawk */ + if (chan > 0) { + struct _iosbw { U_Short status, count; U_Long rt_kludge; } iosb; + register U_Long sts = 1; + register char *pt = (char *)buf; + register int offset, pos, count = size * number; + U_Long cc_fmt, io_func = IO$_WRITEVBLK; + int extra = 0; + + result = 0; + if (is_stderr(file_num)) /* if it's SYS$ERROR (stderr)... */ + io_func |= IO$M_CANCTRLO; /* cancel ^O (resume tty output) */ + while (count > 0) { + /* special handling for line-feeds to make them be 'newlines' */ + offset = 0; + if (*pt == '\n') { /* got at least one leading line-feed */ + cc_fmt = PREFIX_CR, extra++; /* precede 1st LF with a CR */ + do offset++; + while (offset < count && *(pt + offset) == '\n'); + } else + cc_fmt = 0; + /* look for another line-feed; if found, break line there */ + pos = offset + find_c(pt + offset, count - offset, '\n'); + if (pos >= BUFSIZ) pos = BUFSIZ - 1; /* throttle quota usage */ + else if (pos < count) pos++, cc_fmt |= POSTFIX_CR, extra++; + /* wait for previous write, if any, to complete */ + if (pt > (char *)buf) { + sts = sys$synch(evfn, &iosb); + if (vmswork(sts)) sts = iosb.status, result += iosb.count; + if (vmsfail(sts)) break; + } + /* queue an asynchronous write */ + sts = sys$qio(evfn, chan, io_func, &iosb, (void (*)(U_Long))0, 0L, + pt, pos, 0, cc_fmt, 0, 0); + if (vmsfail(sts)) break; /*(should never happen)*/ + pt += pos, count -= pos; + } + /* wait for last write to complete */ + if (pt > (char *)buf && vmswork(sts)) { + sts = sys$synch(evfn, &iosb); + if (vmswork(sts)) sts = iosb.status, result += iosb.count; + } + if (vmsfail(sts)) errno = EVMSERR, vaxc$errno = sts; + else if (iosb.rt_kludge == 0) result = number + extra; + result -= extra; /* subtract the additional carriage-returns */ + } else { /* use stdio */ + /* Note: we assume that we're writing text, not binary data. + For stream format files, 'size' and 'number' are effectively + interchangable, and fwrite works fine. However, for record + format files, 'size' governs the maximum record length, so + fwrite(string, size(char), strlen(string), file) + will produce a sequence of 1-byte records, which is hardly + what we want in this (assumed) situation. Line-feeds ('\n') + are converted into newlines (ie, record separators) by the + run-time library, but strings that don't end with a newline + still become separate records. The simplest work around + is just to use fputs() instead of fwrite(); unfortunately, + we have to provide special treatment for NULs ('\0's). + At present, only stdout might be in record format (via + >$'filename' redirection on the command line). + */ + if (size > 1) { /* not used by GAWK */ + result = fwrite((void *)buf, size, number, file); + } else if (*((char *)buf + number - 1) == '\n' || !is_stdout(file_num)) { + result = fwrite((void *)buf, number, size, file); + result = result * number / size; /*(same as 'result = number')*/ + } else { +#ifdef NO_ALLOCA +# define alloca(n) ((n) <= abuf_siz ? abuf : \ + ((abuf_siz > 0 ? (free(abuf),0) : 0), \ + (abuf = malloc(abuf_siz = (n)+20)))) + static void *abuf = 0; + static size_t abuf_siz = 0; +#endif /*NO_ALLOCA*/ + register char *pt = (char *)buf; + register int pos, count = number; + + if (pt[count] != '\0') { /*(out of bounds, but relatively safe)*/ + pt = (char *)alloca(count + 1); + memcpy(pt, buf, count), pt[count] = '\0'; + /* if exiting this block undoes the alloca(), we're hosed :-( */ + } + result = 0; + while (count > 0) { + pos = find_c(pt, count, '\0'); + if (fputs(pt, file) < 0) break; + if (pos < count) { + if (fputc('\0', file) < 0) break; + pos++; /* 0..n-1 -> 1..n */ + } + result += pos, pt += pos, count -= pos; + } + } + } + return result; +} +#define fwrite(b,s,n,f) tty_fwrite((b),(s),(n),(f)) + +#ifdef fclose +# undef fclose +#endif +/* tty_fclose() - keep tty_fwrite() up to date when closing a file */ +int +tty_fclose( FILE *file ) +{ + if (file && *file) { /* note: VAXCRTL stdio has extra level of indirection */ + int file_num = fileno(file); + short chan = file_num < _NFILE ? channel[file_num] : -1; + + if (chan > 0) + (void)sys$dassgn(chan); /* deassign the channel (ie, close) */ + if (file_num < _NFILE) + channel[file_num] = 0; /* clear stale info */ + } + prev_file = 0; /* force tty_fwrite() to reset */ + return fclose(file); +} +#define fclose(f) tty_fclose(f) + +#endif /*!NO_TTY_FWRITE*/ diff --git a/vms/vms_gawk.c b/vms/vms_gawk.c new file mode 100644 index 0000000..222d803 --- /dev/null +++ b/vms/vms_gawk.c @@ -0,0 +1,293 @@ +/* vms_gawk.c -- parse GAWK command line using DCL syntax + + Copyright (C) 1991-1993, 1996, 2003, 2005, 2011 the Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + + +/* + * vms_gawk.c - routines to parse the command line as a native DCL command + * rather than as a foreign command string. + * Pat Rankin, Nov'89 + * [ revised for 2.12, May'91 ] + * [ revised for 4.0.0, Feb'11 ] + */ + +#include "awk.h" +#include "vms.h" + +#define USAGE_PROG_RQRD 1 +#define USAGE_FILE_RQRD 2 +#define USAGE_BAD_COMBO 3 +#define USAGE_RUN_CMD 4 +#define STS$M_INHIB_MSG 0x10000000 + +#define Present(arg) vmswork(Cli_Present(arg)) +#define Get_Value(arg,buf,siz) vmswork(Cli_Get_Value(arg,buf,siz)) + +#ifndef __ia64__ +extern void gawk_cmd(); /* created with $ SET COMMAND/OBJECT */ +#define GAWK_CMD ((const void *)gawk_cmd) +#else /* linker on Itanium is much pickier about such things */ +#pragma extern_model save +#pragma extern_model strict_refdef +/* (could use globalvalue rather than _refdef if we omit GAWK_CMD's `&') */ +extern void *gawk_cmd; +#pragma extern_model restore +#define GAWK_CMD ((const void *)&gawk_cmd) +#endif +extern void _exit(int); +static int vms_usage(int); + +static const char *CmdName; /* "GAWK", "DGAWK", or "PGAWK" */ + +#define ARG_SIZ 250 +union arg_w_prefix { /* structure used to simplify prepending of "-" */ + char value[2+ARG_SIZ+1]; + struct { + char prefix[2]; /* for "-?" */ + char buf[ARG_SIZ]; + char suffix[1]; /* room for '\0' */ + } arg; +}; + +#define chk_option(qualifier,optname) \ + if (Present(qualifier)) \ + strcat(strcat(buf.arg.buf, W_cnt++ ? "," : ""), optname) + + +/* vms_gawk() - parse GAWK command line using DCL and convert it into the */ +/* appropriate "-arg" values for compatability with GNU code */ +int +vms_gawk() +{ + U_Long sts; + union arg_w_prefix buf; + char misc_args[10], *misc_argp; + int argc, W_cnt; + int native_dcl = 1, /* assume true until we know otherwise */ + short_circ; /* some options make P1, /commands, /input superfluous */ + + CmdName = (which_gawk == exe_profiling) ? "PGAWK" + : (which_gawk == exe_debugging) ? "DGAWK" + : "GAWK"; + + /* check "GAWK_P1"--it's required; its presence will tip us off */ + sts = Cli_Present("GAWK_P1"); + if (CondVal(sts) == CondVal(CLI$_SYNTAX)) { + native_dcl = 0; /* not invoked via a native command verb */ + /* syntax error indicates that we weren't invoked as a native DCL + command, so we'll now attempt to generate a command from the + foreign command string and parse that. + */ + sts = Cli_Parse_Command(GAWK_CMD, "GAWK"); /* (*not* CmdName) */ + if (vmswork(sts)) + sts = Cli_Present("GAWK_P1"); + } + short_circ = Present("USAGE") || Present("VERSION") || Present("COPYRIGHT"); + if (vmswork(sts)) /* command parsed successfully */ + v_add_arg(argc = 0, CmdName); /* save "GAWK|DGAWK|PGAWK" as argv[0] */ + else if (CondVal(sts) == CondVal(CLI$_INSFPRM)) + /* vms_usage() will handle /usage, /version, and /copyright */ + return short_circ ? vms_usage(0) + : native_dcl ? vms_usage(USAGE_FILE_RQRD) : 0; /* insufficient parameters */ + else if (CondVal(sts) == CondVal(CLI$_CONFLICT)) + return vms_usage(USAGE_BAD_COMBO); /* conflicting qualifiers (/input+/command) */ +#if 0 /* 3.1.2: removed since this can't distinguish RUN vs fork+exec */ + else if (CondVal(sts) == CondVal(CLI$_RUNUSED)) + return vms_usage(USAGE_RUN_CMD); /* RUN GAWK won't work (no command line) */ +#endif + else + return 0; /* forced to rely on original parsing */ + + if (short_circ) /* give usage message & quit or have main() */ + return vms_usage(0); /* give --version or --copyleft mesg & quit */ + else if (! (Present("PROGRAM") || Present("PROGFILE")) ) + return native_dcl ? vms_usage(USAGE_PROG_RQRD) : 0; /* missing required option */ + + misc_argp = misc_args; + *misc_argp++ = '-'; /* now points at &misc_args[1] */ + if (Present("OPTIMIZE")) + *misc_argp++ = 'O'; + W_cnt = 0, buf.arg.buf[0] = '\0'; + strncpy(buf.arg.prefix, "-W", 2); + if (Present("LINT")) { + if (!Present("LINT.FATAL") && !Present("LINT.INVALID")) + chk_option("LINT.WARN", "lint"); + chk_option("LINT.FATAL", "lint=fatal"); + chk_option("LINT.INVALID", "lint=invalid"); + chk_option("LINT.OLD", "lint-old"); /* distinct option */ + } + chk_option("POSIX", "posix"); + if (CondVal(Cli_Present("TRADITIONAL")) != CondVal(CLI$_NEGATED)) + chk_option("STRICT", "traditional"); /* /strict is synonym for /traditional */ + if (CondVal(Cli_Present("STRICT")) != CondVal(CLI$_NEGATED)) + chk_option("TRADITIONAL", "traditional"); + chk_option("RE_INTERVAL", "re-interval"); /* only used with /traditional */ + chk_option("SANDBOX", "sandbox"); + /* potentially a problem due to leading "NO" */ + chk_option("NON_DECIMAL_DATA", "non-decimal-data"); + /* note: locale and translation stuff is not supported by vms gawk */ + chk_option("CHARACTERS_AS_BYTES", "characters-as-bytes"); + chk_option("USE_LC_NUMERIC", "use-lc-numeric"); + chk_option("GEN_POT", "gen-pot"); +# if 0 + /* /copyright and /version don't reach here anymore (short_circ above) */ + chk_option("COPYRIGHT", "copyright"); /* --copyleft */ + chk_option("VERSION", "version"); +# endif + if (W_cnt > 0) /* got something */ + v_add_arg(++argc, strdup(buf.value)); + +#ifdef DEBUG /* most debugging functionality moved to separate DGAWK program */ + if (Present("DEBUG")) + *misc_argp++ = 'Y'; /* --parsedebug */ +#endif + *misc_argp = '\0'; /* terminate misc_args[] */ + if (misc_argp > &misc_args[1]) /* got something */ + v_add_arg(++argc, misc_args); /* store it/them */ + + if (Present("PROFILE")) { /* /profile[=file] */ + strncpy(buf.arg.prefix, "-p", 2); + if (Get_Value("PROFILE", buf.arg.buf, sizeof buf.arg.buf)) + v_add_arg(++argc, strdup(buf.value)); + } + if (Present("DUMP_VARIABLES")) { /* /dump_variables[=file] */ + strncpy(buf.arg.prefix, "-d", 2); + if (Get_Value("DUMP_VARIABLES", buf.arg.buf, sizeof buf.arg.buf)) + v_add_arg(++argc, strdup(buf.value)); + } + if (Present("FIELD_SEP")) { /* field separator */ + strncpy(buf.arg.prefix, "-F", 2); + if (Get_Value("FIELD_SEP", buf.arg.buf, sizeof buf.arg.buf)) + v_add_arg(++argc, strdup(buf.value)); + } + if (Present("VARIABLES")) { /* variables to init prior to BEGIN */ + strncpy(buf.arg.prefix, "-v", 2); + while (Get_Value("VARIABLES", buf.arg.buf, sizeof buf.arg.buf)) + v_add_arg(++argc, strdup(buf.value)); + } + /* the relative order of -e and -f args matters; unfortunately, + we're losing that here... */ + if (Present("MOREPROG")) { /* /extra_input=text -> -e text */ + strncpy(buf.arg.prefix, "-e", 2); + if (Get_Value("MOREPROG", buf.arg.buf, sizeof buf.arg.buf)) + v_add_arg(++argc, strdup(buf.value)); + } + if (Present("PROGFILE")) { /* program files, /input=file -> -f file */ + strncpy(buf.arg.prefix, "-f", 2); + while (Get_Value("PROGFILE", buf.arg.buf, sizeof buf.arg.buf)) + v_add_arg(++argc, strdup(buf.value)); + v_add_arg(++argc, "--"); + } else if (Present("PROGRAM")) { /* program text, /commands -> 'text' */ + v_add_arg(++argc, "--"); + if (Get_Value("PROGRAM", buf.value, sizeof buf.value)) + v_add_arg(++argc, strdup(buf.value)); + } + + /* we know that "GAWK_P1" is present [data files and/or 'var=value'] */ + while (Get_Value("GAWK_P1", buf.value, sizeof buf.value)) + v_add_arg(++argc, strdup(buf.value)); + + if (Present("OUTPUT")) { /* let other parser treat this as 'stdout' */ + strncpy(buf.arg.prefix, ">$", 2); + if (Get_Value("OUTPUT", buf.arg.buf, sizeof buf.arg.buf)) + v_add_arg(++argc, strdup(buf.value)); + } + + return ++argc; /*(increment to account for arg[0])*/ +} + +/* vms_usage() - display one or more messages and then terminate */ +static int /* note: usually doesn't return */ +vms_usage( int complaint ) +{ + static const char + *usage_txt = "\n\ +usage: %s /COMMANDS=\"awk program text\" data_file[,data_file,...] \n\ + or %s /INPUT=awk_file data_file[,\"Var=value\",data_file,...] \n\ + or %s /INPUT=(awk_file1,awk_file2,...) data_file[,...] \n\ + or %s /INPUT=awk_file /EXTRA_COMMANDS=\"program text\" data_file \n\ +", + *options_txt = "\n\ +options: /FIELD_SEPARATOR=\"FS_value\" \n\ + and /VARIABLES=(\"Var1=value1\",\"Var2=value2\",...) \n\ + and /OPTIMIZE /PROFILE[=file] /DUMP_VARIABLES[=file] \n\ + and /POSIX /[NO]TRADITIONAL /[NO]STRICT /RE_INTERVAL \n\ + and /SANDBOX /NON_DECIMAL_DATA \n\ + and /LINT[=WARN] or /LINT=OLD or /LINT=FATAL \n\ + and /VERSION /COPYRIGHT /USAGE \n\ + and /OUTPUT=out_file \n\ +", /* omitted: /LINT=INVALID /CHARACTERS_AS_BYTES /USE_LC_NUMERIC /GEN_POT */ + *no_prog = "missing required element: /COMMANDS or /INPUT", + *no_file = "missing required element: data_file \n\ + (use \"SYS$INPUT:\" to read data lines from the terminal)", + *bad_combo = "invalid combination of qualifiers \n\ + (/INPUT=awk_file and /COMMANDS=\"awk program\" are mutually exclusive)", + *run_used = "\"RUN\" was used; required command components missing"; + int status, argc; + + /* presence of /usage, /version, or /copyright for feedback+quit + supersedes absence of required program or data file */ + if (Present("USAGE")) { + complaint = 0; /* clean exit */ + } else if (Present("VERSION") || Present("COPYRIGHT")) { + /* construct a truncated Unix-style command line to control main() */ + v_add_arg(argc=0, CmdName); /* save "GAWK",&c as argv[0] */ +#if 0 + v_add_arg(++argc, Present("VERSION") ? "-V" : "-C"); +#else + v_add_arg(++argc, "-W"); + v_add_arg(++argc, Present("VERSION") ? "version" : "copyright"); +#endif + /* kludge to suppress 'usage' message from main() */ + v_add_arg(++argc, "--"); /* no more arguments */ + v_add_arg(++argc, "{}"); /* dummy program text */ + v_add_arg(++argc, "NL:"); /* dummy input file */ + return ++argc; /* count argv[0] too */ + } + + fflush(stdout); + switch (complaint) { + case USAGE_PROG_RQRD: + fprintf(stderr, "\n%%%s-W-%s, %s \n", CmdName, "PROG_RQRD", no_prog); + status = CLI$_VALREQ | STS$M_INHIB_MSG; + break; + case USAGE_FILE_RQRD: + fprintf(stderr, "\n%%%s-W-%s, %s \n", CmdName, "FILE_RQRD", no_file); + status = CLI$_INSFPRM | STS$M_INHIB_MSG; + break; + case USAGE_BAD_COMBO: + fprintf(stderr, "\n%%%s-W-%s, %s \n", CmdName, "BAD_COMBO", bad_combo); + status = CLI$_CONFLICT | STS$M_INHIB_MSG; + break; + case USAGE_RUN_CMD: + fprintf(stderr, "\n%%%s-W-%s, %s \n", CmdName, "RUN_CMD", run_used); + status = CLI$_NOOPTPRS | STS$M_INHIB_MSG; + break; + default: + status = 1; + break; + } + fprintf(stderr, usage_txt, CmdName, CmdName, CmdName, CmdName); + fprintf(stderr, options_txt); + fflush(stderr); + + errno = EVMSERR; + vaxc$errno = status; + _exit(status); + /* NOTREACHED */ + return 0; +} diff --git a/vms/vms_misc.c b/vms/vms_misc.c new file mode 100644 index 0000000..cd92d7e --- /dev/null +++ b/vms/vms_misc.c @@ -0,0 +1,365 @@ +/* vms_misc.c -- sustitute code for missing/different run-time library routines. + + Copyright (C) 1991-1993, 1996-1997, 2001, 2003, 2009, 2010, 2011 + the Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#define creat creat_dummy /* one of gcc-vms's headers has bad prototype */ +#include "awk.h" +#include "vms.h" +#undef creat +#include +#ifndef O_RDONLY +#include +#endif +#include +#include +#include + + /* + * In VMS's VAXCRTL, strerror() takes an optional second argument. + * #define strerror(errnum) strerror(errnum,vaxc$errno) + * is all that's needed, but VAXC can't handle that (gcc can). + * [The 2nd arg is used iff errnum == EVMSERR.] + */ +#ifdef strerror +# undef strerror +#endif +extern char *strerror(int,...); + +/* vms_strerror() -- convert numeric error code into text string */ +char * +vms_strerror( int errnum ) +{ + return ( errnum != EVMSERR ? strerror(errnum) + : strerror(EVMSERR, vaxc$errno) ); +} +# define strerror(v) vms_strerror(v) + + /* + * Miscellaneous utility routine, not part of the run-time library. + */ +/* vms_strdup() - allocate some new memory and copy a string into it */ +char * +vms_strdup( const char *str ) +{ + char *result; + int len = strlen(str); + + emalloc(result, char *, len+1, "strdup"); + return strcpy(result, str); +} + + /* + * VAXCRTL does not contain unlink(). This replacement has limited + * functionality which is sufficient for GAWK's needs. It works as + * desired even when we have the file open. + */ +/* unlink(file) -- delete a file (ignore soft links) */ +int +unlink( const char *file_spec ) { + char tmp[255+1]; /*(should use alloca(len+2+1)) */ + extern int delete(const char *); + + strcpy(tmp, file_spec); /* copy file name */ + if (strchr(tmp, ';') == NULL) + strcat(tmp, ";0"); /* append version number */ + return delete(tmp); +} + + /* + * Work-around an open(O_CREAT+O_TRUNC) bug (screwed up modification + * and creation dates when new version is created), and also use some + * VMS-specific file options. Note: optional 'prot' arg is completely + * ignored; gawk doesn't need it. + */ +#ifdef open +# undef open +#endif +extern int creat(const char *,int,...); +extern int open(const char *,int,unsigned,...); + +/* vms_open() - open a file, possibly creating it */ +int +vms_open( const char *name, int mode, ... ) +{ + int result; + + if (strncmp(name, "/dev/", 5) == 0) { + /* (this used to be handled in vms_devopen(), but that is only + called when opening files for output; we want it for input too) */ + if (strcmp(name + 5, "null") == 0) /* /dev/null -> NL: */ + name = "NL:"; + else if (strcmp(name + 5, "tty") == 0) /* /dev/tty -> TT: */ + name = "TT:"; + } + + if (mode == (O_WRONLY|O_CREAT|O_TRUNC)) { + /* explicitly force stream_lf record format to override DECC$SHR's + defaulting of RFM to earlier file version's when one is present */ + /* 3.1.7 fix: letting record attibutes default resulted in DECC$SHR's + creat() failing with "invalid record attributes" when trying to + make a new version of an existing file which had rfm=vfc,rat=prn + format, so add explicit "rat=cr" to go with rfm=stmlf to force + the usual "carriage return carriage control" setting */ + result = creat(name, 0, "rfm=stmlf", "rat=cr", "shr=nil", "mbc=32"); + } else { + struct stat stb; + const char *mbc, *shr = "shr=get", *ctx = "ctx=stm"; + + if (stat((char *)name, &stb) < 0) { /* assume DECnet */ + mbc = "mbc=8"; + } else { /* ordinary file; allow full sharing iff record format */ + mbc = "mbc=32"; + if ((stb.st_fab_rfm & 0x0F) < FAB$C_STM) shr = "shr=get,put,upd"; + } + result = open(name, mode, 0, shr, mbc, "mbf=2"); + } + + /* This is only approximate; the ACP -> RMS -> VAXCRTL interface + discards too much potentially useful status information... */ + if (result < 0 && errno == EVMSERR + && (vaxc$errno == RMS$_ACC || vaxc$errno == RMS$_CRE)) + errno = EMFILE; /* redirect() should close 1 file & try again */ + + return result; +} + + /* + * Check for attempt to (re-)open known file. + */ +/* vms_devopen() - check for "SYS$INPUT" or "SYS$OUTPUT" or "SYS$ERROR" */ +int +vms_devopen( const char *name, int mode ) +{ + FILE *file = NULL; + + if (strncasecmp(name, "SYS$", 4) == 0) { + name += 4; /* skip "SYS$" */ + if (strncasecmp(name, "INPUT", 5) == 0 && (mode & O_WRONLY) == 0) + file = stdin, name += 5; + else if (strncasecmp(name, "OUTPUT", 6) == 0 && (mode & O_WRONLY) != 0) + file = stdout, name += 6; + else if (strncasecmp(name, "ERROR", 5) == 0 && (mode & O_WRONLY) != 0) + file = stderr, name += 5; + if (*name == ':') name++; /* treat trailing colon as optional */ + } + /* note: VAXCRTL stdio has extra level of indirection (*file) */ + return (file && *file && *name == '\0') ? fileno(file) : -1; +} + + +#define VMS_UNITS_PER_SECOND 10000000L /* hundreds of nanoseconds, 1e-7 */ +#define UNIX_EPOCH "01-JAN-1970 00:00:00.00" + +extern U_Long sys$bintim(), sys$gettim(); +extern U_Long lib$subx(), lib$ediv(); + + /* + * Get current time in microsecond precision. + */ +/* vms_gettimeofday() - get current time in `struct timeval' format */ +int +vms_gettimeofday(struct timeval *tv, void *timezone__not_used) +{ + /* + Emulate unix's gettimeofday call; timezone argument is ignored. + */ + static const Dsc epoch_dsc = { sizeof UNIX_EPOCH - sizeof "", UNIX_EPOCH }; + static long epoch[2] = {0L,0L}; /* needs one time initialization */ + const long thunk = VMS_UNITS_PER_SECOND; + long now[2], quad[2]; + + if (!epoch[0]) sys$bintim(&epoch_dsc, epoch); /* 1 Jan 0:0:0 1970 */ + /* get current time, as VMS quadword time */ + sys$gettim(now); + /* convert the quadword time so that it's relative to Unix epoch */ + lib$subx(now, epoch, quad); /* quad = now - epoch; */ + /* convert 1e-7 units into seconds and fraction of seconds */ + lib$ediv(&thunk, quad, &tv->tv_sec, &tv->tv_usec); + /* convert fraction of seconds into microseconds */ + tv->tv_usec /= (VMS_UNITS_PER_SECOND / 1000000); + + return 0; /* success */ +} + + +#ifndef VMS_V7 + /* + * VMS prior to V7.x has no timezone support unless DECnet/OSI is used. + */ +/* these are global for use by missing/strftime.c */ +char *tzname[2] = { "local", "" }; +int daylight = 0, timezone = 0, altzone = 0; + +/* tzset() -- dummy to satisfy linker */ +void tzset(void) +{ + return; +} +#endif /*VMS_V7*/ + + +#ifndef CRTL_VER_V731 +/* getpgrp() -- there's no such thing as process group under VMS; + * job tree might be close enough to be useful though. + */ +int getpgrp(void) +{ + return 0; +} +#endif + +#ifndef __GNUC__ +void vms_bcopy( const char *src, char *dst, int len ) +{ + (void) memcpy(dst, src, len); +} +#endif /*!__GNUC__*/ + + +/*----------------------------------------------------------------------*/ +#ifdef NO_VMS_ARGS /* real code is in "vms/vms_args.c" */ +void vms_arg_fixup( int *argc, char ***argv ) { return; } /* dummy */ +#endif + +#ifdef NO_VMS_PIPES /* real code is in "vms/vms_popen.c" */ +FILE *popen( const char *command, const char *mode ) { + fatal(" Cannot open pipe `%s' (not implemented)", command); + return NULL; +} +int pclose( FILE *current ) { + fatal(" Cannot close pipe #%d (not implemented)", fileno(current)); + return -1; +} +int fork( void ) { + fatal(" Cannot fork process (not implemented)"); + return -1; +} +#endif /*NO_VMS_PIPES*/ +/*----------------------------------------------------------------------*/ + + +/* + * The following code is taken from the GNU C preprocessor (cccp.c, + * 2.8.1 vintage) where it was used #if VMS. It is only needed for + * VAX C and GNU C on VAX configurations; DEC C's run-time library + * doesn't have the problem described. + * + * VMS_fstat() and VMS_stat() were static in cccp.c but need to be + * accessible to the whole program here. Also, the special handling + * for the null device has been introduced for gawk's benefit, to + * prevent --lint mode from giving spurious warnings about /dev/null + * being empty if it's used as an input file. + */ + +#if defined(VAXC) || (defined(__GNUC__) && !defined(__alpha)) + +/* more VMS hackery */ +#include +#include + +extern unsigned long sys$parse(), sys$search(); + +/* Work around a VAXCRTL bug. If a file is located via a searchlist, + and if the device it's on is not the same device as the one specified + in the first element of that searchlist, then both stat() and fstat() + will fail to return info about it. `errno' will be set to EVMSERR, and + `vaxc$errno' will be set to SS$_NORMAL due yet another bug in stat()! + We can get around this by fully parsing the filename and then passing + that absolute name to stat(). + + Without this fix, we can end up failing to find header files, which is + bad enough, but then compounding the problem by reporting the reason for + failure as "normal successful completion." */ + +#undef fstat /* Get back to the library version. */ + +int +VMS_fstat (fd, statbuf) + int fd; + struct stat *statbuf; +{ + int result = fstat (fd, statbuf); + + if (result < 0) + { + FILE *fp; + char nambuf[NAM$C_MAXRSS+1]; + + if ((fp = fdopen (fd, "r")) != 0 && fgetname (fp, nambuf) != 0) + result = VMS_stat (nambuf, statbuf); + /* No fclose(fp) here; that would close(fd) as well. */ + } + + if (result == 0 /* GAWK addition; fixup /dev/null flags */ + && (statbuf->st_mode & S_IFREG) + && strcmp(statbuf->st_dev, "_NLA0:") == 0) + { + statbuf->st_mode &= ~S_IFREG; + statbuf->st_mode |= S_IFCHR; + } + + return result; +} + +int +VMS_stat (name, statbuf) + const char *name; + struct stat *statbuf; +{ + int result = stat (name, statbuf); + + if (result < 0) + { + struct FAB fab; + struct NAM nam; + char exp_nam[NAM$C_MAXRSS+1], /* expanded name buffer for sys$parse */ + res_nam[NAM$C_MAXRSS+1]; /* resultant name buffer for sys$search */ + + fab = cc$rms_fab; + fab.fab$l_fna = (char *) name; + fab.fab$b_fns = (unsigned char) strlen (name); + fab.fab$l_nam = (void *) &nam; + nam = cc$rms_nam; + nam.nam$l_esa = exp_nam, nam.nam$b_ess = sizeof exp_nam - 1; + nam.nam$l_rsa = res_nam, nam.nam$b_rss = sizeof res_nam - 1; + nam.nam$b_nop = NAM$M_PWD | NAM$M_NOCONCEAL; + if (sys$parse (&fab) & 1) + { + if (sys$search (&fab) & 1) + { + res_nam[nam.nam$b_rsl] = '\0'; + result = stat (res_nam, statbuf); + } + /* Clean up searchlist context cached by the system. */ + nam.nam$b_nop = NAM$M_SYNCHK; + fab.fab$l_fna = 0, fab.fab$b_fns = 0; + (void) sys$parse (&fab); + } + } + + if (result == 0 /* GAWK addition; fixup /dev/null flags */ + && (statbuf->st_mode & S_IFREG) + && strcmp(statbuf->st_dev, "_NLA0:") == 0) + { + statbuf->st_mode &= ~S_IFREG; + statbuf->st_mode |= S_IFCHR; + } + + return result; +} +#endif /* VAXC || (__GNUC__ && !__alpha) */ diff --git a/vms/vms_popen.c b/vms/vms_popen.c new file mode 100644 index 0000000..62f3f71 --- /dev/null +++ b/vms/vms_popen.c @@ -0,0 +1,347 @@ +/* [.vms]vms_popen.c -- substitute routines for missing pipe calls. + + Copyright (C) 1991-1993, 1996, 2010, 2011 the Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef NO_VMS_PIPES + +#include "awk.h" /* really "../awk.h" */ +#include + +#ifndef PIPES_SIMULATED + +FILE * +popen( const char *command, const char *mode ) +{ + fatal(" Cannot open pipe `%s' (not implemented)", command); + /* NOT REACHED */ + return 0; +} + +int +pclose( FILE *current ) +{ + fatal(" Internal error ('pclose' not implemented)"); + /* NOT REACHED */ + return -1; +} + +int +fork( void ) +{ + fatal(" Internal error ('fork' not implemented)"); + /* NOT REACHED */ + return -1; +} + +#else /*PIPES_SIMULATED*/ + /* + * Simulate pipes using temporary files; hope that the user + * doesn't expect pipe i/o to be interleaved with other i/o ;-}. + * + * This was initially based on the MSDOS version, but cannot + * use a static array to hold pipe info, because there's no + * fixed limit on the range of valid 'fileno's. Another + * difference is that redirection is handled using LIB$SPAWN + * rather than constructing a command for system() which uses + * '<' or '>'. + */ +#include "vms.h" +#include +#include /* logical name definitions */ + +#ifndef STDC_HEADERS +extern int strcmp(const char*, const char *); +#endif +extern char *mktemp(char *); + +static void push_logicals(void); +static void pop_logicals(void); +static Itm *save_translation(const Dsc *); +static void restore_translation(const Dsc *, const Itm *); + +typedef enum { unopened = 0, reading, writing } pipemode; +typedef struct pipe_info { + char *command; + char *name; + pipemode pmode; +} PIPE; +static PIPE *pipes; +static int pipes_lim = 0; + +#define psize(n) ((n) * sizeof(PIPE)) +#define expand_pipes(k) do { PIPE *new_p; \ + int new_p_lim = ((k) / _NFILE + 1) * _NFILE; \ + emalloc(new_p, PIPE *, psize(new_p_lim), "expand_pipes"); \ + if (pipes_lim > 0) \ + memcpy(new_p, pipes, psize(pipes_lim)), free(pipes); \ + memset(new_p + psize(pipes_lim), 0, psize(new_p_lim - pipes_lim)); \ + pipes = new_p, pipes_lim = new_p_lim; } while(0) + +FILE * +popen( const char *command, const char *mode ) +{ + FILE *current; + char *name; + int cur; + pipemode curmode; + + if (strcmp(mode, "r") == 0) + curmode = reading; + else if (strcmp(mode, "w") == 0) + curmode = writing; + else + return NULL; + + /* make a name for the temporary file */ + if ((name = mktemp(strdup("sys$scratch:gawk-pipe_XXXXXX.tmp"))) == 0) + return NULL; + + if (curmode == reading) { + /* an input pipe reads a temporary file created by the command */ + vms_execute(command, (char *)0, name); /* 'command >tempfile' */ + } + if ((current = fopen(name, mode, "mbc=24", "mbf=2")) == NULL) { + free(name); + return NULL; + } + cur = fileno(current); + if (cur >= pipes_lim) expand_pipes(cur); + /* assert( cur >= 0 && cur < pipes_lim ); */ + pipes[cur].name = name; + pipes[cur].pmode = curmode; + pipes[cur].command = strdup(command); + return current; +} + +int +pclose( FILE *current ) +{ + int rval, cur = fileno(current); + + /* assert( cur >= 0 && cur < pipes_lim ); */ + if (pipes[cur].pmode == unopened) + return -1; /* should never happen */ + + rval = fclose(current); /* close temp file; if reading, we're done */ + if (pipes[cur].pmode == writing) { + /* an output pipe feeds the temporary file to the other program */ + rval = vms_execute(pipes[cur].command, pipes[cur].name, (char *)0); + } + /* clean up */ + unlink(pipes[cur].name); /* get rid of the temporary file */ + pipes[cur].pmode = unopened; + free(pipes[cur].name), pipes[cur].name = 0; + free(pipes[cur].command), pipes[cur].command = 0; + return rval; +} + + /* + * Create a process and execute a command in it. This is essentially + * the same as system() but allows us to specify SYS$INPUT (stdin) + * and/or SYS$OUTPUT (stdout) for the process. + * [With more work it could truly simulate a pipe using mailboxes.] + */ +int +vms_execute( const char *command, const char *input, const char *output ) +{ + Dsc cmd, in, out, *in_p, *out_p; + U_Long sts, cmpltn_sts; + + cmd.len = strlen(cmd.adr = (char *)command); + if (input) + in.len = strlen(in.adr = (char *)input), in_p = ∈ + else + in_p = 0; + if (output) + out.len = strlen(out.adr = (char *)output), out_p = &out; + else + out_p = 0; + + push_logicals(); /* guard against user-mode definitions of sys$Xput */ + sts = lib$spawn(&cmd, in_p, out_p, (U_Long *)0, + (Dsc *)0, (U_Long *)0, &cmpltn_sts); + pop_logicals(); /* restore environment */ + + if (vmswork(sts) && vmsfail(cmpltn_sts)) sts = cmpltn_sts; + if (vmsfail(sts)) { + errno = EVMSERR, vaxc$errno = sts; + return -1; + } else + return 0; +} + +/*----* + This rigmarole is to guard against interference from the current + environment. User-mode definitions of SYS$INPUT and/or SYS$OUTPUT + will interact with spawned subprocesses--including LIB$SPAWN with + explicit input and/or output arguments specified--if they were + defined without the 'CONFINED' attribute. The definitions created + in vms_args.c as part of command line I/O redirection happened to + fall into this category :-(, but even though that's been fixed, + there's still the possibility of the user doing something like + |$ define/user sys$output foo.out + prior to starting the program. Without ``/name_attr=confine'', + that will really screw up pipe simulation, so we've got to work- + around it here. This is true whether pipes are implemented via + mailboxes or temporary files, as long as lib$spawn() is being used. + + push_logicals() calls save_translation() the first time it's + invoked; the latter allocates some memory to hold a full logical + name translation and uses $trnlnm to fill that in. Then if either + sys$input or sys$output has a user-mode, non-confined translation, + push_logicals() will delete the definition(s) using $dellnm. + After the spawned command has returned, pop_logicals() is called; + it calls restore_translation() for any deleted values; the latter + uses $crllnm or $crelog to recreate the original definition. + + SYS$ERROR is currently ignored; perhaps it should receive the same + treatment... +*----*/ + + /* logical name table, and names of interest; these are all constant */ +static const Descrip(lnmtable,"LNM$PROCESS_TABLE"); +static const Descrip(sys_input,"SYS$INPUT"); +static const Descrip(sys_output,"SYS$OUTPUT"); +static const unsigned char acmode = PSL$C_USER; /* only care about user-mode */ + + /* macros for simplfying the code a bunch */ +#define DelTrans(l) sys$dellnm(&lnmtable, (l), &acmode) +#define GetTrans(l,i) sys$trnlnm((U_Long *)0, &lnmtable, (l), &acmode, (i)) +#define SetTrans(l,i) sys$crelnm((U_Long *)0, &lnmtable, (l), &acmode, (i)) + /* itemlist manipulation macros; separate versions for aggregate and scalar */ +#define SetItmA(i,c,p,r) ((i).code = (c), (i).len = sizeof (p),\ + (i).buffer = (p), (i).retlen = (U_Short *)(r)) +#define SetItmS(i,c,p) ((i).code = (c), (i).len = sizeof *(p),\ + (i).buffer = (p), (i).retlen = (U_Short *)0) +#define EndItm0(i) ((i).code = (i).len = 0) + + /* translate things once, then hold the results here for multiple re-use */ +static Itm *input_definition, *output_definition; + +static void +push_logicals( void ) /* deassign sys$input and/or sys$output */ +{ + static int init_done = 0; + + if (!init_done) { /* do logical name lookups one-time only */ + input_definition = save_translation(&sys_input); + output_definition = save_translation(&sys_output); + init_done = 1; + } + if (input_definition) DelTrans(&sys_input); /* kill sys$input */ + if (output_definition) DelTrans(&sys_output); /* and sys$output */ +} + +static void +pop_logicals( void ) /* redefine sys$input and/or sys$output */ +{ + if (input_definition) restore_translation(&sys_input, input_definition); + if (output_definition) restore_translation(&sys_output, output_definition); +} + +static Itm * +save_translation( const Dsc *logname ) +{ + Itm trans[4], *itmlst; + long trans_attr, max_trans_indx; /* 0-based translation index count */ + unsigned char trans_acmode; /* translation's access mode */ + unsigned itmlst_size; + register int i, j; + + itmlst = 0; + /* Want translation index count for non-confined, user-mode definition; + unfortunately, $trnlnm does not provide that much control. Try to + fetch several values of interest, then decide based on the result. + */ + SetItmS(trans[0], LNM$_MAX_INDEX, &max_trans_indx), max_trans_indx = -1; + SetItmS(trans[1], LNM$_ACMODE, &trans_acmode), trans_acmode = 0; + SetItmS(trans[2], LNM$_ATTRIBUTES, &trans_attr), trans_attr = 0; + EndItm0(trans[3]); + if (vmswork(GetTrans(logname, trans)) && max_trans_indx >= 0 + && trans_acmode == PSL$C_USER && !(trans_attr & LNM$M_CONFINE)) { + /* Now know that definition of interest exists; + allocate and initialize an item list and associated buffers; + use three entries for each translation. + */ + itmlst_size = (3 * (max_trans_indx + 1) + 1) * sizeof(Itm); + emalloc(itmlst, Itm *, itmlst_size, "save_translation"); + for (i = 0; i <= max_trans_indx; i++) { + struct def { U_Long indx, attr; U_Short len; + char str[LNM$C_NAMLENGTH], eos; } *wrk; + emalloc(wrk, struct def *, sizeof (struct def), "save_translation"); + wrk->indx = (U_Long)i; /* this one's an input value for $trnlnm */ + SetItmS(itmlst[3*i+0], LNM$_INDEX, &wrk->indx); + SetItmS(itmlst[3*i+1], LNM$_ATTRIBUTES, &wrk->attr), wrk->attr = 0; + SetItmA(itmlst[3*i+2], LNM$_STRING, &wrk->str, &wrk->len), wrk->len = 0; + } + EndItm0(itmlst[3*i]); /* assert( i == max_trans_indx+1 ); */ + /* Time to perform full logical name translation, + then update item list for subsequent restoration. + If there are any holes [don't know whether that's possible] + collapse them out of the list; don't want them at restore time. + */ + if (vmswork(GetTrans(logname, itmlst))) { + for (i = 0, j = -1; i <= max_trans_indx; i++) { + U_Long *attr_p; + attr_p = itmlst[3*i+1].buffer; /* copy (void *) to true type */ + if (*attr_p & LNM$M_EXISTS) { + *attr_p &= ~LNM$M_EXISTS; /* must clear this bit */ + if (++j < i) itmlst[3*j+0] = itmlst[3*i+0], + itmlst[3*j+1] = itmlst[3*i+1], + itmlst[3*j+2] = itmlst[3*i+2]; + if (itmlst[3*j+2].retlen) { /* fixup buffer length */ + itmlst[3*j+2].len = *itmlst[3*j+2].retlen; + itmlst[3*j+2].retlen = (U_Short *)0; + } + } + } + if (++j < i) EndItm0(itmlst[3*j]); + } else /* should never happen; tolerate potential memory leak */ + free(itmlst), itmlst = 0; /*('wrk' buffer(s) will become lost)*/ + } + return itmlst; +} + +static void +restore_translation( const Dsc *logname, const Itm *itemlist ) +{ + Dsc trans_val; + U_Long *attr_p; +# define LOG_PROCESS_TABLE 2 /* */ +# define LOG_USERMODE PSL$C_USER + + /* assert( itemlist[1].code == LNM$_ATTRIBUTES ); */ + attr_p = itemlist[1].buffer; /* copy (void *) to (U_Long *) */ + if (*attr_p & LNM$M_CRELOG) { /* check original creation method */ + /* $crelog values can have only one translation; + so it'll be the first string entry in the itemlist. + */ + /* assert( itemlist[2].code == LNM$_STRING ); */ + trans_val.adr = itemlist[2].buffer; + trans_val.len = itemlist[2].len; + (void) sys$crelog(LOG_PROCESS_TABLE, logname, &trans_val, LOG_USERMODE); + } else { + /* $crelnm definition; itemlist could specify multiple translations, + but has already been setup properly for use as-is. + */ + (void) SetTrans(logname, itemlist); + } +} + +#endif /*PIPES_SIMULATED*/ + +#endif /*!NO_VMS_PIPES*/ diff --git a/vms/vmsbuild.com b/vms/vmsbuild.com new file mode 100644 index 0000000..047e49a --- /dev/null +++ b/vms/vmsbuild.com @@ -0,0 +1,163 @@ +$! vmsbuild.com -- Commands to build GAWK Pat Rankin, Dec'89 +$! revised, Mar'90 +$! gawk 2.13 revised, Jun'91 +$! gawk 2.14 revised, Sep'92 +$! gawk 2.15 revised, Oct'93 +$! gawk 3.0 revised, Dec'95 +$! gawk 3.0.1 revised, Nov'96 +$! gawk 3.1.0 revised, Mar'01 +$! gawk 3.1.1 revised, Apr'02 +$! gawk 3.1.6 revised, Mar'07 +$! gawk-bytecode revd, Jan'10 +$! gawk 4.0.0 revd, May'11 +$! +$ REL = "4.0" !release version number +$ PATCHLVL = "1" +$! +$! +$ CCFLAGS = "/noList" ! "/noOpt/Debug" +$ CDEFS = "GAWK,HAVE_CONFIG_H" +$! +$ if p1.eqs."" then p1 = "DECC" !default compiler +$ if p1.eqs."GNUC" +$ then +$! assumes VAX +$ CC = "gcc" +$ if f$type(gcc).eqs."STRING" then CC = gcc +$ CFLAGS = "/Incl=([],[.vms])/Obj=[]/Def=(''CDEFS')''CCFLAGS'" +$ LIBS = "gnu_cc:[000000]gcclib.olb/Library,sys$library:vaxcrtl.olb/Library" +$ if p2.eqs."DO_GNUC_SETUP" then set command gnu_cc:[000000]gcc +$ else !!GNUC +$ if p1.eqs."VAXC" +$ then +$! always VAX; version V3.x of VAX C assumed (for V2.x, remove /Opt=noInline) +$ CC = "cc" +$ if f$trnlnm("DECC$CC_DEFAULT").nes."" then CC = "cc/VAXC" +$ CFLAGS = "/Incl=[]/Obj=[]/Opt=noInline/Def=(''CDEFS')''CCFLAGS'" +$ LIBS = "sys$share:vaxcrtl.exe/Shareable" +$ else !!VAXC +$! neither GNUC nor VAXC, assume DECC (same for either VAX or Alpha) +$ CC = "cc/DECC/Prefix=All" +$ CFLAGS = "/Incl=[]/Obj=[]/Def=(''CDEFS')''CCFLAGS'" +$ LIBS = "" ! DECC$SHR instead of VAXCRTL, no special link option needed +$ endif !VAXC +$ endif !GNUC +$! +$ cc = CC + CFLAGS +$ show symbol cc +$! +$ if f$search("config.h").nes."" then - + if f$cvtime(f$file_attr("config.h","RDT")).ges.- + f$cvtime(f$file_attr("[.vms]vms-conf.h","RDT")) then goto config_ok +$ v = f$verify(1) +$ copy [.vms]vms-conf.h []config.h +$! 'f$verify(v)' +$config_ok: +$ if f$search("awkgram.c").nes."" then goto awkgram_ok +$ write sys$output " You must process `awkgram.y' with ""yacc"" or ""bison""" +$ if f$search("awkgram_tab.c").nes."" then - !bison was run manually + write sys$output " or else rename `awkgram_tab.c' to `awkgram.c'." +$ if f$search("ytab.c").nes."" .or. f$search("y_tab.c").nes."" then - !yacc + write sys$output " or else rename `ytab.c' or `y_tab.c' to `awkgram.c'." +$ exit +$awkgram_ok: +$ if f$search("command.c").nes."" then goto command_ok +$ write sys$output " You must process `command.y' with ""yacc"" or ""bison""" +$ if f$search("command_tab.c").nes."" then - !bison was run manually + write sys$output " or else rename `command_tab.c' to `command.c'." +$ if f$search("ytab.c").nes."" .or. f$search("y_tab.c").nes."" then - !yacc + write sys$output " or else rename `ytab.c' or `y_tab.c' to `command.c'." +$ exit +$command_ok: +$ v = f$verify(1) +$ cc array.c +$ cc awkgram.c +$ cc builtin.c +$ cc dfa.c +$ cc ext.c +$ cc field.c +$ cc floatcomp.c +$ cc gawkmisc.c +$ cc getopt.c +$ cc getopt1.c +$ cc io.c +$ cc main.c +$ cc msg.c +$ cc node.c +$ cc random.c +$ cc re.c +$ cc regex.c +$ cc replace.c +$ cc version.c +$ cc eval.c +$ cc eval_p.c +$ cc eval_d.c +$ cc profile.c +$ cc profile_p.c +$ cc command.c +$ cc debug.c +$ cc [.vms]vms_misc.c +$ cc [.vms]vms_popen.c +$ cc [.vms]vms_fwrite.c +$ cc [.vms]vms_args.c +$ cc [.vms]vms_gawk.c +$ cc [.vms]vms_cli.c +$ set command/Object=[]gawk_cmd.obj [.vms]gawk.cld +$! 'f$verify(v)' +$! +$ close/noLog Fopt +$ create gawk.opt +! GAWK -- GNU awk +array.obj,awkgram.obj,builtin.obj,dfa.obj,ext.obj,field.obj,floatcomp.obj +gawkmisc.obj,getopt.obj,getopt1.obj,io.obj +main.obj,msg.obj,node.obj +random.obj,re.obj,regex.obj,replace.obj,version.obj,eval.obj,profile.obj +[]vms_misc.obj,vms_popen.obj,vms_fwrite.obj,vms_args.obj +[]vms_gawk.obj,vms_cli.obj,gawk_cmd.obj +psect_attr=environ,noshr !extern [noshare] char ** +stack=48 !preallocate more pages (default is 20) +iosegment=128 !ditto (default is 32) +$ open/append Fopt gawk.opt +$ write Fopt libs +$ write Fopt "identification=""V''REL'.''PATCHLVL'""" +$ close Fopt +$! +$ create pgawk.opt +! PGAWK -- GNU awk w/ run-time profiling +array.obj,awkgram.obj,builtin.obj,dfa.obj,ext.obj,field.obj,floatcomp.obj +gawkmisc.obj,getopt.obj,getopt1.obj,io.obj +main.obj,msg.obj,node.obj +random.obj,re.obj,regex.obj,replace.obj,version.obj,eval_p.obj,profile_p.obj +[]vms_misc.obj,vms_popen.obj,vms_fwrite.obj,vms_args.obj +[]vms_gawk.obj,vms_cli.obj,gawk_cmd.obj +psect_attr=environ,noshr !extern [noshare] char ** +stack=48 !preallocate more pages (default is 20) +iosegment=128 !ditto (default is 32) +$ open/append Fopt pgawk.opt +$ write Fopt libs +$ write Fopt "identification=""V''REL'.''PATCHLVL'""" +$ close Fopt +$! +$ create dgawk.opt +! DGAWK -- GNU awk w/ debugging +array.obj,awkgram.obj,builtin.obj,dfa.obj,ext.obj,field.obj,floatcomp.obj +gawkmisc.obj,getopt.obj,getopt1.obj,io.obj +main.obj,msg.obj,node.obj +random.obj,re.obj,regex.obj,replace.obj,version.obj +eval_d.obj,profile.obj,command.obj,debug.obj +[]vms_misc.obj,vms_popen.obj,vms_fwrite.obj,vms_args.obj +[]vms_gawk.obj,vms_cli.obj,gawk_cmd.obj +psect_attr=environ,noshr !extern [noshare] char ** +stack=48 !preallocate more pages (default is 20) +iosegment=128 !ditto (default is 32) +$ open/append Fopt dgawk.opt +$ write Fopt libs +$ write Fopt "identification=""V''REL'.''PATCHLVL'""" +$ close Fopt +$! +$ v = f$verify(1) +$ link/exe=gawk.exe gawk.opt/options +$ link/exe=pgawk.exe pgawk.opt/options +$ link/exe=dgawk.exe dgawk.opt/options +$! 'f$verify(v)' +$ exit diff --git a/vms/vmstest.com b/vms/vmstest.com new file mode 100644 index 0000000..ccea871 --- /dev/null +++ b/vms/vmstest.com @@ -0,0 +1,1722 @@ +$! vmstest.com -- DCL script to perform test/Makefile actions for VMS +$! +$! Usage: +$! $ set default [-.test] +$! $ @[-.vms]vmstest.com bigtest +$! This assumes that newly built gawk.exe is in the next directory up. +$ +$! 3.1.7: changed to share code among many common tests, and +$! to put results for test foo into _foo.tmp instead of tmp. +$! +$ echo = "write sys$output" +$ cmp = "diff/Output=_NL:/Maximum=1" +$ igncascmp = "''cmp'/Ignore=Case" +$ sumslp = "edit/Sum" +$ rm = "delete/noConfirm/noLog" +$ mv = "rename/New_Vers" +$ gawk = "$sys$disk:[-]gawk" +$ pgawk = "$sys$disk:[-]pgawk" +$ AWKPATH_srcdir = "define/User AWKPATH sys$disk:[]" +$ +$ listdepth = 0 +$ pipeok = 0 +$ pgawkok = -1 +$ floatmode = -1 ! 0: D_float, 1: G_float, 2: IEEE T_float +$ +$ list = p1+" "+p2+" "+p3+" "+p4+" "+p5+" "+p6+" "+p7+" "+p8 +$ list = f$edit(list,"TRIM,LOWERCASE") +$ if list.eqs."" then list = "all" ! bigtest +$ gosub list_of_tests +$ echo "done." +$ exit +$ +$all: +$bigtest: echo "bigtest..." +$ ! omits "printlang" and "extra" +$ list = "basic unix_tests gawk_ext vms_tests charset_tests" - + + " machine_tests pgawk_tests" +$ gosub list_of_tests +$ return +$ +$basic: echo "basic..." +$ list = "msg addcomma anchgsub argarray arrayparm arrayref" - + + " arrymem1 arrayprm2 arrayprm3 arryref2 arryref3" - + + " arryref4 arryref5 arynasty arynocls aryprm1 aryprm2" - + + " aryprm3 aryprm4 aryprm5 aryprm6 aryprm7 aryprm8" - + + " arysubnm asgext awkpath back89 backgsub childin" - + + " clobber closebad clsflnam compare compare2 concat1" +$ gosub list_of_tests +$ list = "concat2 concat3 concat4 convfmt datanonl defref" - + + " delargv delarprm delarpm2 delfunc dfastress dynlj" - + + " eofsplit exitval1" - + + " exitval2 fcall_exit fcall_exit2 fldchg fldchgnf" - + + " fnamedat fnarray fnarray2 fnaryscl fnasgnm fnmisc" - + + " fordel forref forsimp fsbs fsspcoln fsrs fstabplus" - + + " funsemnl funsmnam funstack getline getline2 getline3" - + + " getline4" +$ gosub list_of_tests +$ list = "getlnbuf getnr2tb getnr2tm gsubasgn gsubtest" - + + " gsubtst2 gsubtst3 gsubtst4 gsubtst5 gsubtst6" - + + " gsubtst7 gsubtst8 hex" - + + " hsprint inputred intest intprec iobug1" - + + " leaddig leadnl litoct longsub longwrds"- + + " manglprm math membug1 messages minusstr mmap8k" - + + " mtchi18n nasty nasty2 negexp negrange nested" - + + " nfldstr nfneg" +$ gosub list_of_tests +$ list = "nfset nlfldsep nlinstr nlstrina noeffect nofile" - + + " nofmtch noloop1 noloop2 nonl noparms nors nulrsend" - + + " numindex numsubstr octsub ofmt ofmtbig ofmtfidl" - + + " ofmta ofmts onlynl opasnidx opasnslf paramdup" - + + " paramres paramtyp parse1 parsefld parseme pcntplus" - + + " posix2008sub prdupval prec printf0 printf1 prmarscl" +$ gosub list_of_tests +$ list = "prmreuse prt1eval prtoeval rand range1 rebt8b1" - + + " redfilnm regeq regrange reindops reparse resplit rs rsnul1nl" - + + " rsnulbig rsnulbig2 rstest1 rstest2 rstest3 rstest4" - + + " rstest5 rswhite scalar sclforin sclifin sortempty" - + + " splitargv splitarr splitdef splitvar splitwht" - + + " strcat1 strtod strnum1 subamp subi18n" +$ gosub list_of_tests +$ list = "subsepnm subslash substr swaplns synerr1 synerr2" - + + " tradanch tweakfld uninit2 uninit3 uninit4 uninit5" - + + " uninitialized unterm uparrfs wideidx wideidx2" - + + " widesub widesub2 widesub3 widesub4 wjposer1 zeroe0" - + + " zeroflag zero2" +$ gosub list_of_tests +$ return +$ +$unix: +$unix_tests: echo "unix_tests..." +$ list = "fflush getlnhd localenl pid pipeio1 pipeio2" - + + " poundbang rtlen rtlen01 space strftlng" +$ gosub list_of_tests +$ return +$ +$gnu: +$gawk_ext: echo "gawk_ext... (gawk.extensions)" +$ list = "aadelete1 aadelete2 aarray1 aasort aasorti" - + + " argtest arraysort backw badargs beginfile1 binmode1" - + + " clos1way delsub devfd devfd1 devfd2 dumpvars exit" - + + " fieldwdth fpat1 fpat2 fpat3 fpatnull funlen fsfwfs" - + + " fwtest fwtest2 fwtest3" - + + " gensub gensub2 getlndir gnuops2 gnuops3 gnureops" - + + " icasefs icasers igncdym igncfs ignrcase ignrcas2" +$ gosub list_of_tests +$ list = "indirectcall lint lintold lintwarn match1" - + + " match2 match3 manyfiles mbprintf3 mbstr1" - + + " nastyparm next nondec" - + + " nondec2 patsplit posix profile1 procinfs printfbad1" - + + " printfbad2 printfbad3 pty1 regx8bit rebuf reint" - + + " reint2 rsstart1 rsstart2 rsstart3 rstest6 shadow" - + + " sortfor sortu splitarg4 strtonum strftime switch2" +$ gosub list_of_tests +$ return +$ +$vms: +$vms_tests: echo "vms_tests..." +$ list = "vms_cmd vms_io1 vms_io2" +$ gosub list_of_tests +$ return +$ +$locale_tests: +$charset_tests: echo "charset_tests..." +$ ! without i18n kit, VMS only supports the C locale +$ ! and several of these fail +$ list = "asort asorti fmttest fnarydel fnparydl lc_num1 mbfw1" - + + " mbprintf1 mbprintf2 rebt8b2 rtlenmb sort1 sprintfc" +$ gosub list_of_tests +$ return +$ +$hardware: +$machine_tests: echo "machine_tests..." +$ ! these depend upon the floating point format in use +$ list = "double1 double2 fmtspcl intformat" +$ gosub list_of_tests +$ return +$ +$ ! pgawk_tests is part of bigtest; profile_tests is a separate subset +$profile_tests: echo "profile_tests..." +$ list = "profile1" +$ gosub list_of_tests +$ ! fall through to pgawk_tests +$pgawk_tests: echo "pgawk_tests..." +$ list = "profile2 profile3" +$ gosub list_of_tests +$ return +$ +$extra: echo "extra..." +$ list = "regtest inftest inet" +$ gosub list_of_tests +$ return +$ +$inet: echo "inet..." +$ type sys$input: + The inet tests only work if gawk has been built with TCP/IP socket + support and your system supports the services "discard" at port 9 + and "daytimed" at port 13. +$ list = "inetechu inetecht inetdayu inetdayt" +$ gosub list_of_tests +$ return +$ +$! list_of_tests: process 'list', a space-separated list of tests. +$! Some tests assign their own 'list' and call us recursively, +$! so we have to emulate a local stack to prevent the current list +$! from being clobbered by nested execution. We do this by making +$! and operating on list1, list2, &c depending upon call depth. +$! Lower level tests access higher numbered entries; the lower +$! entries in use by caller or caller's caller are kept intact. +$list_of_tests: +$ listdepth = listdepth + 1 ! increment calling depth +$ list'listdepth' = f$edit(list,"COMPRESS,TRIM") +$next_test: +$ test = f$element(0," ",list'listdepth') +$ list'listdepth' = list'listdepth' - test - " " +$ gosub 'test' +$ if list'listdepth'.nes."" then goto next_test +$ listdepth = listdepth - 1 ! reset +$ return +$ +$ +$! common tests, not needing special set up: gawk -f 'test'.awk 'test'.in +$addcomma: +$anchgsub: +$arrayprm2: +$arryref2: +$aryprm8: +$asgext: +$backgsub: +$backw: +$concat1: +$concat2: +$concat3: +$datanonl: +$delarpm2: +$fldchg: +$fldchgnf: +$fmttest: +$fordel: +$fpat1: +$fpat3: +$fpatnull: +$fsfwfs: +$fsrs: +$funlen: +$funstack: +$fwtest: +$fwtest2: +$fwtest3: +$gensub: +$getline3: +$getline4: +$getnr2tb: +$getnr2tm: +$gsubtest: +$gsubtst2: +$gsubtst4: +$gsubtst5: +$gsubtst7: +$gsubtst8: +$hex: +$icasers: +$igncfs: +$igncdym: +$indirectcall: +$inputred: +$leadnl: +$manglprm: +$match3: +$membug1: +$nested: +$nfset: +$nlfldsep: +$nlinstr: +$noloop1: +$noloop2: +$nulrsend: +$ofmt: +$ofmtfidl: +$ofmts: +$onlynl: +$parse1: +$parsefld: +$prdupval: +$prec: +$prtoeval: +$range1: +$rebuf: +$regeq: +$reindops: +$reparse: +$rsnul1nl: +$rsstart1: +$rstest1: +$rstest2: +$rstest3: +$rstest6: +$rswhite: +$sortempty: +$sortfor: +$splitarg4: +$splitargv: +$splitarr: +$splitvar: +$sprintfc: +$strcat1: +$strtod: +$subsepnm: +$swaplns: +$uparrfs: +$wjposer1: +$zeroe0: +$! common with 'test'.in +$ echo "''test'" +$ gawk -f 'test'.awk 'test'.in >_'test'.tmp +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp; +$ return +$ +$! more common tests, without a data file: gawk -f 'test'.awk +$aarray1: +$aasort: +$aasorti: +$arrayref: +$arraysort: +$arrymem1: +$arynasty: +$arysubnm: +$asort: +$asorti: +$closebad: +$compare2: +$convfmt: +$delargv: +$delarprm: +$delsub: +$!!double1: +$!!double2: +$dynlj: +$fnarydel: +$fnparydl: +$fpat2: +$forref: +$forsimp: +$funsemnl: +$gensub2: +$gnuops2: +$gnuops3: +$gnureops: +$hsprint: +$icasefs: +$intest: +$match1: +$math: +$minusstr: +$negrange: +$nlstrina: +$nondec: +$octsub: +$ofmta: +$paramtyp: +$patsplit: +$pcntplus: +$printf1: +$procinfs: +$prt1eval: +$rebt8b1: +$rebt8b2: +$regrange: +$regx8bit: +$sort1: +$sortu: +$splitdef: +$splitwht: +$strnum1: +$strtonum: +$substr: +$switch2: +$zero2: +$zeroflag: +$! common without 'test'.in +$ echo "''test'" +$ gawk -f 'test'.awk >_'test'.tmp +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp; +$ return +$ +$double1: +$double2: +$lc_num1: +$mbprintf1: +$ echo "''test' skipped" +$ return +$ +$msg: +$ ! first show gawk's version (without copyright notice) +$ gawk --version >_msg.tmp +$ gawk "FNR == 1 {print; exit}" _msg.tmp +$ rm _msg.tmp; +$ echo "Any output from ""DIF"" is bad news, although some differences" +$ echo "in floating point values are probably benign -- in particular," +$ echo "some systems may omit a leading zero and the floating point" +$ echo "precision may lead to slightly different output in a few cases." +$ echo "" +$ return +$ +$printlang: +$! the default locale is C, with LC_LANG and LC_ALL left empty; +$! showing that at the very beginning may cause some confusion about +$! whether gawk requires those, so we don't run this as the first test +$ gawk -f printlang.awk +$ return +$ +$poundbang: +$pty1: +$ echo "''test': not supported" +$ return +$ +$messages: echo "messages" +$ set noOn +$ gawk -f messages.awk > out2 >& out3 +$ cmp out1.ok out1. +$ if $status then rm out1.; +$ cmp out2.ok out2. +$ if $status then rm out2.; +$ cmp out3.ok out3. +$ if $status then rm out3.; +$ set On +$ return +$ +$argarray: echo "argarray" +$ define/User TEST "test" !this is useless... +$ gawk -f argarray.awk ./argarray.in - >_argarray.tmp +just a test +$ cmp argarray.ok _argarray.tmp +$ if $status then rm _argarray.tmp; +$ return +$ +$fstabplus: echo "fstabplus" +$ gawk -f fstabplus.awk >_fstabplus.tmp +1 2 +$ cmp fstabplus.ok _fstabplus.tmp +$ if $status then rm _fstabplus.tmp; +$ return +$ +$longwrds: echo "longwrds" +$ gawk -v "SORT=sort sys$input: _longwrds.tmp" -f longwrds.awk longwrds.in >_NL: +$ cmp longwrds.ok _longwrds.tmp +$ if $status then rm _longwrds.tmp; +$ return +$ +$fieldwdth: echo "fieldwdth" +$ gawk -v "FIELDWIDTHS=2 3 4" "{ print $2}" >_fieldwdth.tmp +123456789 +$ cmp fieldwdth.ok _fieldwdth.tmp +$ if $status then rm _fieldwdth.tmp; +$ return +$ +$ignrcase: echo "ignrcase" +$ gawk -v "IGNORECASE=1" "{ sub(/y/, """"); print}" >_ignrcase.tmp +xYz +$ cmp ignrcase.ok _ignrcase.tmp +$ if $status then rm _ignrcase.tmp; +$ return +$ +$regtest: +$ if f$search("regtest.com").eqs."" +$ then echo "regtest: not available" +$ else echo "regtest" +$ echo "Some of the output from regtest is very system specific, do not" +$ echo "be distressed if your output differs from that distributed." +$ echo "Manual inspection is called for." +$ @regtest.com +$ endif +$ return +$ +$posix: echo "posix" +$ gawk -f posix.awk >_posix.tmp +1:2,3 4 +$ cmp posix.ok _posix.tmp +$ if $status then rm _posix.tmp; +$ return +$ +$manyfiles: echo "manyfiles" +$!! this used to use a hard-coded value of 300 simultaneously open +$!! files, but if our open file quota is generous enough then that +$!! wouldn't exercise the ability to handle more than the maximum +$!! number allowed at once +$ f_cnt = 300 +$ chnlc = f$getsyi("CHANNELCNT") +$ fillm = f$getjpi("","FILLM") +$ if fillm.ge.chnlc then fillm = chnlc - 1 +$ if fillm.ge.f_cnt then f_cnt = fillm + 10 +$ if f$search("[.junk]*.*").nes."" then rm [.junk]*.*;* +$ if f$parse("[.junk]").eqs."" then create/Dir/Prot=(O:rwed) [.junk] +$ gawk -- "BEGIN {for (i = 1; i <= ''f_cnt'; i++) print i, i}" >_manyfiles.dat +$ echo "(processing ''f_cnt' files; this may take quite a while)" +$ set noOn ! continue even if gawk fails +$ gawk -f manyfiles.awk _manyfiles.dat _manyfiles.dat +$ set On +$ define/User sys$error _NL: +$ define/User sys$output _manyfiles.tmp +$ search/Match=Nor/Output=_NL:/Log [.junk]*.* "" +$!/Log output: "%SEARCH-S-NOMATCH, - <#> records" plus 1 line summary +$ gawk -v "F_CNT=''f_cnt'" -f - _manyfiles.tmp +$deck !some input begins with "$" +$4 != 2 {++count} +END {if (NR != F_CNT+1 || count != 1) {print "\nFailed!"}} +$eod +$ rm _manyfiles.tmp;,_manyfiles.dat;,[.junk]*.*;*,[]junk.dir; +$ return +$ +$compare: echo "compare" +$ gawk -f compare.awk 0 1 compare.in >_compare.tmp +$ cmp compare.ok _compare.tmp +$ if $status then rm _compare.tmp; +$ return +$ +$rs: echo "rs" +$ gawk -v "RS=" "{ print $1, $2}" rs.in >_rs.tmp +$ cmp rs.ok _rs.tmp +$ if $status then rm _rs.tmp; +$ return +$ +$fsbs: echo "fsbs" +$ gawk -v "FS=\" "{ print $1, $2 }" fsbs.in >_fsbs.tmp +$ cmp fsbs.ok _fsbs.tmp +$ if $status then rm _fsbs.tmp; +$ return +$ +$inftest: echo "inftest" +$ !! echo "This test is very machine specific..." +$ set noOn +$ gawk -f inftest.awk >_inftest.tmp +$ !! cmp inftest.ok _inftest.tmp !just care that gawk doesn't crash... +$ if $status then rm _inftest.tmp; +$ set On +$ return +$ +$getline2: echo "getline2" +$ gawk -f getline2.awk getline2.awk getline2.awk >_getline2.tmp +$ cmp getline2.ok _getline2.tmp +$ if $status then rm _getline2.tmp; +$ return +$ +$rand: echo "rand" +$ echo "The following line should just be 19 random numbers between 1 and 100" +$ echo "" +$ gawk -f rand.awk +$ return +$ +$negexp: echo "negexp" +$ gawk "BEGIN { a = -2; print 10^a }" >_negexp.tmp +$ cmp negexp.ok _negexp.tmp +$ if $status then rm _negexp.tmp; +$ return +$ +$awkpath: echo "awkpath" +$ define/User AWK_LIBRARY [],[.lib] +$ gawk -f awkpath.awk >_awkpath.tmp +$ cmp awkpath.ok _awkpath.tmp +$ if $status then rm _awkpath.tmp; +$ return +$ +$argtest: echo "argtest" +$ gawk -f argtest.awk -x -y abc >_argtest.tmp +$ cmp argtest.ok _argtest.tmp +$ if $status then rm _argtest.tmp; +$ return +$ +$badargs: echo "badargs" +$ on error then continue +$ gawk -f 2>&1 >_badargs.too +$! search/Match=Nor _badargs.too "patchlevel" /Output=_badargs.tmp +$ gawk "/patchlevel/{next}; {gsub(""\"""",""'""); print}" <_badargs.too >_badargs.tmp +$ cmp badargs.ok _badargs.tmp +$ if $status then rm _badargs.tmp;,_badargs.too; +$ return +$ +$nonl: echo "nonl" +$ ! This one might fail, depending on the tool used to unpack the +$ ! distribution. Some will add a final newline if the file lacks one. +$ AWKPATH_srcdir +$ gawk --lint -f nonl.awk _NL: >_nonl.tmp 2>&1 +$ cmp nonl.ok _nonl.tmp +$ if $status then rm _nonl.tmp; +$ return +$ +$defref: echo "defref" +$ set noOn +$ AWKPATH_srcdir +$ gawk --lint -f defref.awk >_defref.tmp 2>&1 +$ if .not.$status then call exit_code 2 _defref.tmp +$ set On +$ cmp defref.ok _defref.tmp +$ if $status then rm _defref.tmp; +$ return +$ +$nofmtch: echo "nofmtch" +$ AWKPATH_srcdir +$ gawk --lint -f nofmtch.awk >_nofmtch.tmp 2>&1 +$ cmp nofmtch.ok _nofmtch.tmp +$ if $status then rm _nofmtch.tmp; +$ return +$ +$strftime: echo "strftime" +$ ! this test could fail on slow machines or on a second boundary, +$ ! so if it does, double check the actual results +$!! date | gawk -v "OUTPUT"=_strftime.tmp -f strftime.awk +$ now = f$time() +$ wkd = f$extract(0,3,f$cvtime(now,,"WEEKDAY")) +$ mon = f$cvtime(now,"ABSOLUTE","MONTH") +$ mon = f$extract(0,1,mon) + f$edit(f$extract(1,2,mon),"LOWERCASE") +$ day = f$cvtime(now,,"DAY") +$ tim = f$extract(0,8,f$cvtime(now,,"TIME")) +$ tz = "" +$ yr = f$cvtime(now,,"YEAR") +$ if f$trnlnm("FTMP").nes."" then close/noLog ftmp +$ open/Write ftmp strftime.in +$ write ftmp wkd," ",mon," ",day," ",tim," ",tz," ",yr +$ close ftmp +$ gawk -v "OUTPUT"=_strftime.tmp -f strftime.awk strftime.in +$ set noOn +$ cmp strftime.ok _strftime.tmp +$ if $status then rm _strftime.tmp;,strftime.ok;*,strftime.in;* +$ set On +$ return +$ +$litoct: echo "litoct" +$ gawk --traditional -f litoct.awk >_litoct.tmp +ab +$ cmp litoct.ok _litoct.tmp +$ if $status then rm _litoct.tmp; +$ return +$ +$resplit: echo "resplit" +$ gawk -- "{ FS = "":""; $0 = $0; print $2 }" >_resplit.tmp +a:b:c d:e:f +$ cmp resplit.ok _resplit.tmp +$ if $status then rm _resplit.tmp; +$ return +$ +$intprec: echo "intprec" +$ gawk -f intprec.awk >_intprec.tmp 2>&1 +$ cmp intprec.ok _intprec.tmp +$ if $status then rm _intprec.tmp; +$ return +$ +$childin: echo "childin skipped" +$ return +$! note: this `childin' test currently [gawk 3.0.3] fails for vms +$!!childin: echo "childin" +$ echo "note: type ``hi'",- + "' if testing appears to hang in `childin'" +$!! @echo hi | gawk "BEGIN { ""cat"" | getline; print; close(""cat"") }" >_childin.tmp +$ gawk "BEGIN { ""type sys$input:"" | getline; print; close(""type sys$input:"") }" >_childin.tmp +hi +$ cmp childin.ok _childin.tmp +$ if $status then rm _childin.tmp; +$ return +$ +$noeffect: echo "noeffect" +$ AWKPATH_srcdir +$ gawk --lint -f noeffect.awk >_noeffect.tmp 2>&1 +$ cmp noeffect.ok _noeffect.tmp +$ if $status then rm _noeffect.tmp; +$ return +$ +$numsubstr: echo "numsubstr" +$ AWKPATH_srcdir +$ gawk -f numsubstr.awk numsubstr.in >_numsubstr.tmp +$ cmp numsubstr.ok _numsubstr.tmp +$ if $status then rm _numsubstr.tmp; +$ return +$ +$prmreuse: echo "prmreuse" +$ if f$search("prmreuse.ok").eqs."" then create prmreuse.ok +$ gawk -f prmreuse.awk >_prmreuse.tmp +$ cmp prmreuse.ok _prmreuse.tmp +$ if $status then rm _prmreuse.tmp; +$ return +$ +$fflush: +$ echo "fflush: not supported" +$ return +$!!fflush: echo "fflush" +$ ! hopelessly Unix-specific +$!! @fflush.sh >_fflush.tmp +$ cmp fflush.ok _fflush.tmp +$ if $status then rm _fflush.tmp; +$ return +$ +$getlnhd: +$ echo "getlnhd skipped" +$ return +$!!getlnhd: echo "getlnhd" +$ gawk -f getlnhd.awk >_getlnhd.tmp +$ cmp getlnhd.ok _getlnhd.tmp +$ if $status then rm _getlnhd.tmp; +$ return +$ +$tweakfld: echo "tweakfld" +$ gawk -f tweakfld.awk tweakfld.in >_tweakfld.tmp +$ if f$search("errors.cleanup").nes."" then rm errors.cleanup;* +$ cmp tweakfld.ok _tweakfld.tmp +$ if $status then rm _tweakfld.tmp; +$ return +$ +$clsflnam: echo "clsflnam" +$ if f$search("clsflnam.ok").eqs."" then create clsflnam.ok +$ gawk -f clsflnam.awk clsflnam.in >_clsflnam.tmp 2>&1 +$ cmp clsflnam.ok _clsflnam.tmp +$ if $status then rm _clsflnam.tmp; +$ return +$ +$mmap8k: echo "mmap8k" +$ gawk "{ print }" mmap8k.in >_mmap8k.tmp +$ cmp mmap8k.in _mmap8k.tmp +$ if $status then rm _mmap8k.tmp; +$ return +$ +$eofsplit: echo "eofsplit" +$ if f$search("eofsplit.ok").eqs."" then create eofsplit.ok +$ gawk -f eofsplit.awk >_eofsplit.tmp +$ cmp eofsplit.ok _eofsplit.tmp +$ if $status then rm _eofsplit.tmp; +$ return +$ +$back89: echo "back89" +$ gawk "/a\8b/" back89.in >_back89.tmp +$ cmp back89.ok _back89.tmp +$ if $status then rm _back89.tmp; +$ return +$ +$tradanch: echo "tradanch" +$ if f$search("tradanch.ok").eqs."" then create tradanch.ok +$ gawk --traditional -f tradanch.awk tradanch.in >_tradanch.tmp +$ cmp tradanch.ok _tradanch.tmp +$ if $status then rm _tradanch.tmp; +$ return +$ +$pid: echo "pid" +$ pid = f$integer("%x" + f$getjpi("","PID")) +$ ppid = f$integer("%x" + f$getjpi("","OWNER")) +$ gawk -v "ok_pid=''pid'" -v "ok_ppid=''ppid'" -f pid.awk >_pid.tmp >& _NL: +$ cmp pid.ok _pid.tmp +$ if $status then rm _pid.tmp; +$ return +$ +$strftlng: echo "strftlng" +$ define/User TZ "UTC" !useless +$ gawk -f strftlng.awk >_strftlng.tmp +$ cmp strftlng.ok _strftlng.tmp +$ if $status then rm _strftlng.tmp; +$ return +$ +$nfldstr: echo "nfldstr" +$ if f$search("nfldstr.ok").eqs."" then create nfldstr.ok +$ gawk "$1 == 0 { print ""bug"" }" >_nfldstr.tmp + +$ cmp nfldstr.ok _nfldstr.tmp +$ if $status then rm _nfldstr.tmp; +$ return +$ +$nors: echo "nors" +$!! there's no straightforward way to supply non-terminated input on the fly +$!! @echo A B C D E | tr -d '\12' | $(AWK) '{ print $$NF }' - $(srcdir)/nors.in > _$@ +$!! so just read a line from sys$input instead +$ gawk "{ print $NF }" - nors.in >_nors.tmp +A B C D E +$ cmp nors.ok _nors.tmp +$ if $status then rm _nors.tmp; +$ return +$ +$reint: echo "reint" +$ gawk --re-interval -f reint.awk reint.in >_reint.tmp +$ cmp reint.ok _reint.tmp +$ if $status then rm _reint.tmp; +$ return +$ +$noparms: echo "noparms" +$ set noOn +$ AWKPATH_srcdir +$ gawk -f noparms.awk >_noparms.tmp 2>&1 +$ if .not.$status then call exit_code 1 _noparms.tmp +$ set On +$ cmp noparms.ok _noparms.tmp +$ if $status then rm _noparms.tmp; +$ return +$ +$pipeio1: echo "pipeio1" +$ cat = "TYPE" !close enough, as long as we avoid .LIS default suffix +$ define/User test1 []test1. +$ define/User test2 []test2. +$ gawk -f pipeio1.awk >_pipeio1.tmp +$ rm test1.;,test2.; +$ cmp pipeio1.ok _pipeio1.tmp +$ if $status then rm _pipeio1.tmp; +$ return +$ +$pipeio2: +$ echo "pipeio2 skipped" +$ return +$!!pipeio2: echo "pipeio2" +$ cat = "gawk -- {print}" +$ tr = "??" !unfortunately, no trivial substitution available... +$ gawk -v "SRCDIR=." -f pipeio2.awk >_pipeio2.tmp +$ cmp pipeio2.ok _pipeio2.tmp +$ if $status then rm _pipeio2.tmp; +$ return +$ +$clobber: echo "clobber" +$ gawk -f clobber.awk >_clobber.tmp +$ cmp clobber.ok seq. +$ if $status then rm seq.;* +$ cmp clobber.ok _clobber.tmp +$ if $status then rm _clobber.tmp; +$ return +$ +$nasty: echo "nasty" +$ set noOn +$ gawk -f nasty.awk >_nasty.tmp +$ call fixup_LRL nasty.ok +$ call fixup_LRL _nasty.tmp "purge" +$ cmp nasty.ok _nasty.tmp +$ if $status then rm _nasty.tmp; +$ set On +$ return +$ +$nasty2: echo "nasty2" +$ set noOn +$ gawk -f nasty2.awk >_nasty2.tmp +$ call fixup_LRL nasty2.ok +$ call fixup_LRL _nasty2.tmp "purge" +$ cmp nasty2.ok _nasty2.tmp +$ if $status then rm _nasty2.tmp; +$ set On +$ return +$ +$aadelete1: +$aadelete2: +$arrayparm: +$fnaryscl: +$match2: +$nastyparm: +$opasnslf: +$opasnidx: +$printfbad1: +$prmarscl: +$subslash: +$ echo "''test'" +$ set noOn +$ gawk -f 'test'.awk >_'test'.tmp 2>&1 +$ if .not.$status then call exit_code 2 _'test'.tmp +$ set On +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp; +$ return +$ +$arynocls: echo "arynocls" +$ gawk -v "INPUT"=arynocls.in -f arynocls.awk >_arynocls.tmp +$ cmp arynocls.ok _arynocls.tmp +$ if $status then rm _arynocls.tmp; +$ return +$ +$getlnbuf: echo "getlnbuf" +$ gawk -f getlnbuf.awk getlnbuf.in >_getlnbuf.tmp +$ gawk -f gtlnbufv.awk getlnbuf.in >_getlnbuf.too +$ cmp getlnbuf.ok _getlnbuf.tmp +$ if $status then rm _getlnbuf.tmp; +$ cmp getlnbuf.ok _getlnbuf.too +$ if $status then rm _getlnbuf.too; +$ return +$ +$lint: echo "lint" +$ AWKPATH_srcdir +$ gawk -f lint.awk >_lint.tmp 2>&1 +$ cmp lint.ok _lint.tmp +$ if $status then rm _lint.tmp; +$ return +$ +$lintold: echo "lintold" +$ AWKPATH_srcdir +$ gawk -f lintold.awk --lint-old _lintold.tmp 2>&1 +$ cmp lintold.ok _lintold.tmp +$ if $status then rm _lintold.tmp; +$ return +$ +$ofmtbig: echo "ofmtbig" +$ set noOn +$ gawk -f ofmtbig.awk ofmtbig.in >_ofmtbig.tmp 2>&1 +$ set On +$ cmp ofmtbig.ok _ofmtbig.tmp +$ if $status then rm _ofmtbig.tmp; +$ return +$ +$inetechu: echo "inetechu" +$ echo "this test is for establishing UDP connections" +$ set noOn +$ gawk -- "BEGIN {print """" |& ""/inet/udp/0/127.0.0.1/9""}" +$ set On +$ return +$ +$inetecht: echo "inetecht" +$ echo "this test is for establishing TCP connections" +$ set noOn +$ gawk -- "BEGIN {print """" |& ""/inet/tcp/0/127.0.0.1/9""}" +$ set On +$ return +$ +$inetdayu: echo "inetdayu" +$ echo "this test is for bidirectional UDP transmission" +$ set noOn +$ gawk -f - _NL: +BEGIN { print "" |& "/inet/udp/0/127.0.0.1/13"; + "/inet/udp/0/127.0.0.1/13" |& getline; print $0} +$ set On +$ return +$ +$inetdayt: echo "inetdayt" +$ echo "this test is for bidirectional TCP transmission" +$ set noOn +$ gawk -f - _NL: +BEGIN { print "" |& "/inet/tcp/0/127.0.0.1/13"; + "/inet/tcp/0/127.0.0.1/13" |& getline; print $0} +$ set On +$ return +$ +$redfilnm: echo "redfilnm" +$ gawk -f redfilnm.awk srcdir="." redfilnm.in >_redfilnm.tmp +$ cmp redfilnm.ok _redfilnm.tmp +$ if $status then rm _redfilnm.tmp; +$ return +$ +$leaddig: echo "leaddig" +$ gawk -v "x=2E" -f leaddig.awk >_leaddig.tmp +$ cmp leaddig.ok _leaddig.tmp +$ if $status then rm _leaddig.tmp; +$ return +$ +$clos1way: +$ echo "clos1way: not supported" +$ return +$!!clos1way: echo "clos1way" +$ gawk -f clos1way.awk >_clos1way.tmp +$ cmp clos1way.ok _clos1way.tmp +$ if $status then rm _clos1way.tmp; +$ return +$ +$shadow: echo "shadow" +$ set noOn +$ AWKPATH_srcdir +$ gawk --lint -f shadow.awk >_shadow.tmp 2>&1 +$ set On +$ cmp shadow.ok _shadow.tmp +$ if $status then rm _shadow.tmp; +$ return +$ +$lintwarn: echo "lintwarn" +$ set noOn +$ AWKPATH_srcdir +$ gawk --lint -f lintwarn.awk >_lintwarn.tmp 2>&1 +$ if .not.$status then call exit_code 1 _lintwarn.tmp +$ set On +$ cmp lintwarn.ok _lintwarn.tmp +$ if $status then rm _lintwarn.tmp; +$ return +$ +$longsub: echo "longsub" +$ set noOn +$ gawk -f longsub.awk longsub.in >_longsub.tmp +$!! the records here are too long for DIFF to handle +$!! so assume success as long as gawk doesn't crash +$!! call fixup_LRL longsub.ok +$!! call fixup_LRL _longsub.tmp "purge" +$!! cmp longsub.ok _longsub.tmp +$ if $status then rm _longsub.tmp; +$ set On +$ return +$ +$arrayprm3: echo "arrayprm3" +$ gawk -f arrayprm3.awk arrayprm3.in >_arrayprm3.tmp +$ cmp arrayprm3.ok _arrayprm3.tmp +$ if $status then rm _arrayprm3.tmp; +$ return +$ +$arryref3: +$arryref4: +$arryref5: +$aryprm1: +$aryprm2: +$aryprm3: +$aryprm4: +$aryprm5: +$aryprm6: +$aryprm7: +$delfunc: +$dfastress: +$nfneg: +$numindex: +$scalar: +$sclforin: +$sclifin: +$ echo "''test'" +$ set noOn +$ gawk -f 'test'.awk 'test'.in >_'test'.tmp 2>&1 +$ if .not.$status then call exit_code 2 _'test'.tmp +$ set On +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp; +$ return +$ +$fnamedat: +$fnasgnm: +$ echo "''test'" +$ set noOn +$ gawk -f 'test'.awk <'test'.in >_'test'.tmp 2>&1 +$ if .not.$status then call exit_code 2 _'test'.tmp +$ set On +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp; +$ return +$ +$exitval2: echo "exitval2 skipped" +$ return +$!!exitval2: echo "exitval2" +$ gawk -f exitval2.awk exitval2.in >_exitval2.tmp +$ cmp exitval2.ok _exitval2.tmp +$ if $status then rm _exitval2.tmp; +$ return +$ +$fcall_exit2: +$fnarray2: +$fnmisc: +$gsubasgn: +$unterm: +$ echo "''test'" +$ set noOn +$ gawk -f 'test'.awk 'test'.in >_'test'.tmp 2>&1 +$ if .not.$status then call exit_code 1 _'test'.tmp +$ set On +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp; +$ return +$ +$getline: echo "getline skipped" +$ return +$!!getline: echo "getline" +$ gawk -f getline.awk getline.in >_getline.tmp +$ cmp getline.ok _getline.tmp +$ if $status then rm _getline.tmp; +$ return +$ +$gsubtst3: echo "gsubtst3" +$ gawk --re-interval -f gsubtst3.awk gsubtst3.in >_gsubtst3.tmp +$ cmp gsubtst3.ok _gsubtst3.tmp +$ if $status then rm _gsubtst3.tmp; +$ return +$ +$! FIXME: gawk generates an extra, empty output file while running this test... +$iobug1: echo "iobug1" +$ cat = "TYPE sys$input:" +$ true = "exit 1" !success +$ oldout = f$search("_iobug1.tmp;") +$ gawk -f iobug1.awk iobug1.in >_iobug1.tmp +$ badout = f$search("_iobug1.tmp;-1") +$ if badout.nes."" .and. badout.nes.oldout then rm 'badout' +$ cmp iobug1.ok _iobug1.tmp +$ if $status then rm _iobug1.tmp; +$ return +$ +$rstest4: echo "rstest4 skipped" +$ return +$!!rstest4: echo "rstest4" +$ gawk -f rstest4.awk rstest4.in >_rstest4.tmp +$ cmp rstest4.ok _rstest4.tmp +$ if $status then rm _rstest4.tmp; +$ return +$ +$rstest5: echo "rstest5 skipped" +$ return +$!!rstest5: echo "rstest5" +$ gawk -f rstest5.awk rstest5.in >_rstest5.tmp +$ cmp rstest5.ok _rstest5.tmp +$ if $status then rm _rstest5.tmp; +$ return +$ +$fcall_exit: +$fnarray: +$funsmnam: +$paramdup: +$paramres: +$parseme: +$synerr1: +$synerr2: +$ echo "''test'" +$ set noOn +$ gawk -f 'test'.awk >_'test'.tmp 2>&1 +$ if .not.$status then call exit_code 1 _'test'.tmp +$ set On +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp; +$ return +$ +$uninit2: +$uninit3: +$uninit4: +$uninit5: +$uninitialized: +$ echo "''test'" +$ gawk --lint -f 'test'.awk 'test'.in >_'test'.tmp 2>&1 +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp; +$ return +$ +$space: echo "space" +$ set noOn +$ gawk -f " " space.awk >_space.tmp 2>&1 +$ if .not.$status then call exit_code 2 _space.tmp +$ set On +$! we get a different error from what space.ok expects +$ gawk "{gsub(""file specification syntax error"", ""no such file or directory""); print}" - + _space.tmp >_space.too +$ rm _space.tmp; +$ mv _space.too _space.tmp +$ igncascmp space.ok _space.tmp +$ if $status then rm _space.tmp; +$ return +$ +$posix2008sub: +$printf0: +$ echo "''test'" +$ gawk --posix -f 'test'.awk >_'test'.tmp +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp; +$ return +$ +$rsnulbig: echo "rsnulbig" +$ if .not.pipeok +$ then echo "Without the PIPE command, ''test' can't be run." +$ On warning then return +$ pipe echo "With PIPE, this will probably take quite a while..." +$ On warning then $ +$ pipeok = 1 +$ else echo "This will probably take quite a while too..." +$ endif +$ set noOn +$ pipe - + gawk -- "BEGIN {for (i = 1; i <= 128*64+1; i++) print ""abcdefgh123456\n""}" | - + gawk -- "BEGIN {RS = """"; ORS = ""\n\n""}; {print}" | - + gawk -- "/^[^a]/; END {print NR}" >_rsnulbig.tmp +$ set On +$ cmp rsnulbig.ok _rsnulbig.tmp +$ if $status then rm _rsnulbig.tmp; +$ return +$ +$rsnulbig2: echo "rsnulbig2" +$ if .not.pipeok +$ then echo "Without the PIPE command, ''test' can't be run." +$ On warning then return +$ pipe echo "With PIPE, this will probably take quite a while..." +$ On warning then $ +$ pipeok = 1 +$ else echo "This will probably take quite a while too..." +$ endif +$ set noOn +$ pipe - + gawk -- "BEGIN {ORS=""""; n=""\n""; for (i=1; i<=10; i++) n=(n n); for (i=1; i<=128; i++) print n; print ""abc\n""}" | - + gawk -- "BEGIN {RS=""""; ORS=""\n\n"" }; {print}" | - + gawk -- "/^[^a]/; END {print NR}" >_rsnulbig2.tmp +$ set On +$ cmp rsnulbig2.ok _rsnulbig2.tmp +$ if $status then rm _rsnulbig2.tmp; +$ return +$ +$subamp: +$wideidx: +$widesub2: +$widesub3: +$ echo "''test'" +$ gosub define_gawklocale +$ gawk -f 'test'.awk 'test'.in >_'test'.tmp +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp; +$ return +$ +$ignrcas2: +$!!lc_num1: +$wideidx2: +$widesub: +$widesub4: +$ echo "''test'" +$ gosub define_gawklocale +$ gawk -f 'test'.awk >_'test'.tmp +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp; +$ return +$ +$! This test is somewhat suspect for vms due to exit code manipulation +$exitval1: echo "exitval1" +$ gawk -f exitval1.awk >_exitval1.tmp 2>&1 +$ if $status then call exit_code 0 _exitval1.tmp +$ cmp exitval1.ok _exitval1.tmp +$ if $status then rm _exitval1.tmp; +$ return +$ +$fsspcoln: echo "fsspcoln" +$ gawk -f fsspcoln.awk "FS=[ :]+" fsspcoln.in >_forspcoln.tmp +$ cmp fsspcoln.ok _forspcoln.tmp +$ if $status then rm _forspcoln.tmp; +$ return +$ +$getlndir: echo "getlndir" +$ ! assume we're running in the test subdirectory; we don't want to +$ ! perform a messy conversion of [] into its file specification +$ gawk -v "SRCDIR=[-]test.dir" -f getlndir.awk >_getlndir.tmp +$! getlndir.ok expects "Is a directory", we see "is a directory" +$ igncascmp getlndir.ok _getlndir.tmp +$ if $status then rm _getlndir.tmp; +$ return +$ +$rsstart2: echo "rsstart2" +$ gawk -f rsstart2.awk rsstart1.in >_rsstart2.tmp +$ cmp rsstart2.ok _rsstart2.tmp +$ if $status then rm _rsstart2.tmp; +$ return +$ +$! rsstart3 fails, presumeably due to PIPE's use of print file format +$rsstart3: echo "rsstart3 skipped" +$ return +$!!rsstart3: echo "rsstart3" +$ if .not.pipeok +$ then echo "Without the PIPE command, ''test' can't be run." +$ On warning then return +$ pipe echo "With PIPE, ''test' will finish quickly." +$ On warning then $ +$ pipeok = 1 +$ endif +$ ! head rsstart1.in | gawk -f rsstart2.awk >_rsstart3.tmp +$ ! splitting this into two steps would make it the same as rsstart2 +$ set noOn +$ pipe - + gawk -- "FNR <= 10" rsstart1.in | - + gawk -f rsstart2.awk >_rsstart3.tmp +$ set On +$ cmp rsstart3.ok _rsstart3.tmp +$ if $status then rm _rsstart3.tmp; +$ return +$ +$rtlen: +$rtlen01: +$rtlenmb: +$ echo "''test'" +$ if .not.pipeok +$ then echo "Without the PIPE command, ''test' can't be run." +$ On warning then return +$ pipe echo "With PIPE, ''test' will finish quickly." +$ On warning then $ +$ pipeok = 1 +$ endif +$ f = "''test'.ok" +$ if test.eqs."rtlen" .or. test.eqs."rtlenmb" +$ then +$ if test.eqs."rtlenmb" then GAWKLOCALE = "en_US.UTF-8" +$ pipe - + gawk -- "BEGIN {printf ""0\n\n\n1\n\n\n\n\n2\n\n""; exit}" | - + gawk -- "BEGIN {RS=""""}; {print length(RT)}" >_'test'.tmp +$ if test.eqs."rtlenmb" then delet_/Symbol/Local GAWKLOCALE +$ if test.eqs."rtlenmb" then f = "rtlen.ok" +$ else +$ call/Output=_rtlen01.tmp do__rtlen01 +$ ! first test yields 1 instead of 0 due to forced newline +$ gawk -- "FNR==1 {sub(""1"",""0"")}; {print}" _rtlen01.tmp >_rtlen01.too +$ rm _rtlen01.tmp; +$ mv _rtlen01.too _rtlen01.tmp +$ endif +$ cmp 'f' _'test'.tmp +$ if $status then rm _'test'.tmp; +$ return +$ +$do__rtlen01: subroutine +$ gawk = gawk !PIPE won't propagate local symbols from outer procedure +$ pipe - + gawk -- "BEGIN {printf ""0""; exit}" | - + gawk -- "BEGIN {RS=""""}; {print length(RT)}" +$ pipe - + gawk -- "BEGIN {printf ""0\n""; exit}" | - + gawk -- "BEGIN {RS=""""}; {print length(RT)}" +$ pipe - + gawk -- "BEGIN {printf ""0\n\n""; exit}" | - + gawk -- "BEGIN {RS=""""}; {print length(RT)}" +$ endsubroutine !do__rtlen01 +$ +$nondec2: echo "nondec2" +$ gawk --non-decimal-data -v "a=0x1" -f nondec2.awk >_nondec2.tmp +$ cmp nondec2.ok _nondec2.tmp +$ if $status then rm _nondec2.tmp; +$ return +$ +$nofile: echo "nofile" +$! gawk "{}" no/such/file >_nofile.tmp 2>&1 +$! nofile.ok expects no/such/file, but using that name in the test would +$! yield "file specification syntax error" instead of "no such file..." +$ set noOn +$ gawk "{}" no-such-file >_nofile.tmp 2>&1 +$ if .not.$status then call exit_code 2 _nofile.tmp +$ set On +$! restore altered file name +$ gawk "{gsub(""no-such-file"", ""no/such/file""); print}" _nofile.tmp >_nofile.too +$ rm _nofile.tmp; +$ mv _nofile.too _nofile.tmp +$! nofile.ok expects "No such file ...", we see "no such file ..." +$ igncascmp nofile.ok _nofile.tmp +$ if $status then rm _nofile.tmp; +$ return +$ +$binmode1: echo "binmode1" +$ gawk -v "BINMODE=3" "BEGIN { print BINMODE }" >_binmode1.tmp +$ cmp binmode1.ok _binmode1.tmp +$ if $status then rm _binmode1.tmp; +$ return +$ +$subi18n: echo "subi18n" +$ define/User GAWKLOCALE "en_US.UTF-8" +$ gawk -f subi18n.awk >_subi18n.tmp +$ cmp subi18n.ok _subi18n.tmp +$ if $status then rm _subi18n.tmp; +$ return +$ +$concat4: echo "concat4" +$ define/User GAWKLOCALE "en_US.UTF-8" +$ gawk -f concat4.awk concat4.in >_concat4.tmp +$ cmp concat4.ok _concat4.tmp +$ if $status then rm _concat4.tmp; +$ return +$ +$devfd: echo "devfd: not supported" +$ return +$!!devfd: echo "devfd" +$ gawk 1 /dev/fd/4 /dev/fd/5 4< /devfd.in4 5< devfd.in5 >_devfd.tmp +$ cmp devfd.ok _devfd.tmp +$ if $status then rm _devfd.tmp; +$ return +$ +$devfd1: echo "devfd1: not supported" +$ return +$!!devfd1: echo "devfd1" +$ gawk -f devfd1.awk 4< devfd.in1 5< devfd.in2 >_devfd1.tmp +$ cmp devfd1.ok _devfd1.tmp +$ if $status then rm _devfd1.tmp; +$ return +$ +$devfd2: echo "devfd2: not supported" +$ return +$!!devfd2: echo "devfd2" +$! The program text is the '1' which will print each record. How compact can you get? +$ gawk 1 /dev/fd/4 /dev/fd/5 4< /devfd.in1 5< devfd.in2 >_devfd2.tmp +$ cmp devfd2.ok _devfd2.tmp +$ if $status then rm _devfd2.tmp; +$ return +$ +$mixed1: echo "mixed1" +$ set noOn +$ gawk -f /dev/null --source "BEGIN {return junk}" >_mixed1.tmp 2>&1 +$ if .not.$status then call exit_code 1 _mixed1.tmp +$ set On +$ cmp mixed1.ok _mixed1.tmp +$ if $status then rm _mixed1.tmp; +$ return +$ +$mtchi18n: echo "mtchi18n" +$ define/User GAWKLOCALE "ru_RU.UTF-8" +$ gawk -f mtchi18n.awk mtchi18n.in >_mtchi18n.tmp +$ cmp mtchi18n.ok _mtchi18n.tmp +$ if $status then rm _mtchi18n.tmp; +$ return +$ +$reint2: echo "reint2" +$ gosub define_gawklocale +$ gawk --re-interval -f reint2.awk reint2.in >_reint2.tmp +$ cmp reint2.ok _reint2.tmp +$ if $status then rm _reint2.tmp; +$ return +$ +$localenl: echo "localenl skipped" +$ return +$!!localenl: echo "localenl" +$ @localenl.com /Output=_localenl.tmp ! sh ./localenl.sh >tmp. +$ cmp localenl.ok _localenl.tmp +$ if $status then rm _localenl.tmp; +$ return +$ +$mbprintf1: echo "mbprintf1 skipped" +$ return +$!!mbprintf1: echo "mbprintf1" +$! Makefile test exports this, but we don't want to impact user's environment +$ define/User GAWKLOCALE "en_US.UTF-8" +$ gawk -f mbprintf1.awk mbprintf1.in >_mbprintf1.tmp +$ cmp mbprintf1.ok _mbprintf1.tmp +$ if $status then rm _mbprintf1.tmp; +$ return +$ +$mbprintf2: echo "mbprintf2" +$! Makefile test exports this, ... +$ define/User GAWKLOCALE "ja_JP.UTF-8" +$ gawk -f mbprintf2.awk >_mbprintf2.tmp +$ cmp mbprintf2.ok _mbprintf2.tmp +$ if $status then rm _mbprintf2.tmp; +$ return +$ +$mbprintf3: echo "mbprintf3" +$! Makefile test exports this, ... +$ define/User GAWKLOCALE "en_US.UTF-8" +$ gawk -f mbprintf3.awk mbprintf3.in >_mbprintf2.tmp +$ cmp mbprintf3.ok _mbprintf2.tmp +$ if $status then rm _mbprintf2.tmp; +$ return +$ +$mbfw1: echo "mbfw1 skipped" +$ return +$!!mbfw1: echo "mbfw1" +$! Makefile test exports this, ... +$ define/User GAWKLOCALE "en_US.UTF-8" +$ gawk -f mbfw1.awk mbfw1.in >_mbfw1.tmp +$ cmp mbfw1.ok _mbfw1.tmp +$ if $status then rm _mbfw1.tmp; +$ return +$ +$gsubtst6: echo "gsubtst6" +$ define/User GAWKLOCALE "C" +$ gawk -f gsubtst6.awk >_gsubtst6.tmp +$ cmp gsubtst6.ok _gsubtst6.tmp +$ if $status then rm _gsubtst6.tmp; +$ return +$ +$mbstr1: echo "mbstr1" +$ gosub define_gawklocale +$ AWKPATH_srcdir +$ gawk -f mbstr1.awk >_mbstr1.tmp +$ cmp mbstr1.ok _mbstr1.tmp +$ if $status then rm _mbstr1.tmp; +$ return +$ +$printfbad2: +$printfbad3: +$ echo "''test'" +$ set noOn +$ gawk --lint -f 'test'.awk 'test'.in >_'test'.tmp 2>&1 +$ set On +$ cmp 'test'.ok _'test'.tmp +$ if $status then rm _'test'.tmp; +$ return +$ +$fmtspcl: echo "fmtspcl: not supported" +$ return +$!!fmtspcl: +$! fmtspcl ought to work if gawk was compiled to use IEEE floating point +$ if floatmode.lt.0 then gosub calc_floatmode +$ if floatmode.lt.2 +$ then echo "fmtspcl: not supported" +$ else echo "fmtspcl" +$ gawk -f fmtspcl.awk >_fmtspcl.tmp 2>&1 +$ cmp fmtspcl.ok _fmtspcl.tmp +$ if $status then rm _fmtspcl.tmp; +$ endif +$ return +$ +$intformat: echo "intformat" +$! note: we use the Alpha value for D_float; VAX value is slightly higher +$! due to not losing precision by being processed via G_float +$ huge_0 = "1.70141183460469213e+38" ! D_float +$ huge_1 = "8.98846567431157854e+307" ! G_float +$ huge_2 = "1.79769313486231570e+308" ! IEEE T_float +$ if floatmode.lt.0 then gosub calc_floatmode +$ hugeval = huge_'floatmode' +$ set noOn +$ gawk -v "HUGEVAL=''hugeval'" -f intformat.awk >_intformat.tmp 2>&1 +$ set On +$ cmp intformat.ok _intformat.tmp +$ if $status then rm _intformat.tmp; +$ return +$ +$! ugh... BEGINFILE functionality works fine, but test is heavily Unix-centric +$beginfile1: echo "beginfile1" +$ ! complications: "." is a filename, not the current directory +$ ! (even "[]" is actually "[].", that same filename, but we can +$ ! handle hacking it more easily); +$ ! "no/such/file" yields syntax error rather than no such file +$ ! when subdirectories no/ and no/such/ don't exist; +$ ! vms test suite doesn't generate Makefile; +$ ! "is a directory" and "no such file" aren't capitalized +$ ! gawk -f beginfile1.awk beginfile1.awk . ./no/such/file "Makefile" >_beginfile1.tmp 2>&1 +$ gawk -f beginfile1.awk beginfile1.awk [] ./no-such-file "Makefile.in" >_beginfile1.tmp 2>&1 +$ gawk -f - _beginfile1.tmp >_beginfile1.too +{ if (gsub("\\[\\]",".")) gsub("no such file or directory","is a directory") + gsub("no-such-file","file"); gsub("Makefile.in","Makefile"); print } +$ rm _beginfile1.tmp; +$ mv _beginfile1.too _beginfile1.tmp +$ igncascmp beginfile1.ok _beginfile1.tmp +$ if $status then rm _beginfile1.tmp; +$ return +$ +$dumpvars: echo "dumpvars" +$ gawk --dump-variables 1 _NL: 2>&1 +$ mv awkvars.out _dumpvars.tmp +$ cmp dumpvars.ok _dumpvars.tmp +$ if $status then rm _dumpvars.tmp; +$ return +$ +$profile1: echo "profile1" +$ ! this profile test is run with gawk rather than pgawk +$ ! FIXME: for both gawk invocations which pipe output to SORT, +$ ! two output files get created; the top version has real output +$ ! but there's also an empty lower version. +$ oldout = f$search("_profile1.tmp1") +$ gawk --profile -v "sortcmd=SORT sys$intput: sys$output:" - + -f xref.awk dtdgport.awk > _'test'.tmp1 +$ badout = f$search("_profile1.tmp1;-1") +$ if badout.nes."" .and. badout.nes.oldout then rm 'badout' +$ oldout = f$search("_profile1.tmp2") +$ gawk -v "sortcmd=SORT sys$intput: sys$output:" - + -f awkprof.out dtdgport.awk > _'test'.tmp2 +$ badout = f$search("_profile1.tmp2;-1") +$ if badout.nes."" .and. badout.nes.oldout then rm 'badout' +$ cmp _profile1.tmp1 _profile1.tmp2 +$ if $status then rm _profile1.tmp%;,awkprof.out; +$ return +$ +$ ! pgawk tests; building pgawk is optional so have to check whether it's here +$profile2: +$profile3: +$ if pgawkok.lt.0 +$ then f = f$parse(pgawk,".exe;") +$ ! expect first parse to fail due to leading dollar sign +$ if f.eqs."" then f = f$parse(f$extract(1,999,pgawk),".exe;") +$ if f.nes."" then f = f$search(f) +$ pgawkok = (f.nes."").and.1 ! set to 1 or 0 +$ if .not.pgawkok then - + echo "Can't find pgawk.exe so can't run profiling tests." +$ endif +$ if pgawkok then goto do__'test' +$ echo "''test' skipped" +$ return +$ +$do__profile2: echo "profile2" +$ pgawk -v "sortcmd=SORT sys$input: sys$output:" - + -f xref.awk dtdgport.awk > _NL: +$ ! sed _profile2.tmp +$ sumslp awkprof.out /update=sys$input: /output=_profile2.tmp +-1,2 +/ +$ rm awkprof.out; +$ cmp profile2.ok _profile2.tmp +$ if $status then rm _profile2.tmp;* +$ return +$ +$do__profile3: echo "profile3" +$ pgawk -f profile3.awk > _NL: +$ ! sed _profile3.tmp +$ sumslp awkprof.out /update=sys$input: /output=_profile3.tmp +-1,2 +/ +$ rm awkprof.out; +$ cmp profile3.ok _profile3.tmp +$ if $status then rm _profile3.tmp;* +$ return +$ +$next: echo "next" +$ set noOn +$ gawk "{next}" _NL: > _next.tmp 2>&1 +$ gawk "function f() {next}; {f()}" _NL: >>_next.tmp 2>&1 +$ gawk "function f() {next}; BEGIN{f()}" _NL: >>_next.tmp 2>&1 +$ gawk "function f() {next}; {f()}; END{f()}" _NL: >>_next.tmp 2>&1 +$ gawk "function f() {next}; BEGINFILE{f()}" _NL: >>_next.tmp 2>&1 +$ gawk "function f() {next}; {f()}; ENDFILE{f()}" _NL: >>_next.tmp 2>&1 +$ set On +$ cmp next.ok _next.tmp +$ if $status then rm _next.tmp; +$ return +$ +$exit: echo "exit" +$ if .not.pipeok +$ then echo "Without the PIPE command, ''test' can't be run." +$ On warning then return +$ pipe echo "PIPE command is available; running exit test" +$ On warning then $ +$ pipeok = 1 +$ else echo "PIPE command is available; running exit test" +$ endif +$ set noOn +$ call/Output=_exit.tmp do__exit +$ set On +$ cmp exit.ok _exit.tmp +$ if $status then rm _exit.tmp; +$ return +$ +$do__exit: subroutine +$ gawk = gawk !PIPE won't propagate local symbols from outer procedure +$ x = "BEGIN{print 1; exit; print 2}; NR>1{print}; END{print 3; exit; print 4}" +$ pipe gawk -- "BEGIN { print ""a\nb"" }" | gawk -- "''x'" +$ echo "-- 1" +$ x = "function f(){exit}; END{print NR;f();print NR}" +$ pipe gawk -- "BEGIN { print ""a\nb"" }" | gawk -- "''x'" +$ echo "-- 2" +$ x = "function f(){exit}; NR>1 {f()}; END{print NR; f();print NR}" +$ pipe gawk -- "BEGIN { print ""a\nb"" }" | gawk -- "''x'" +$ echo "-- 3" +$ x = "function f(){exit}; NR>1 {f()}; END{print NR;print NR}" +$ pipe gawk -- "BEGIN { print ""a\nb"" }" | gawk -- "''x'" +$ echo "-- 4" +$ x = "function f(){exit}; BEGINFILE {f()}; NR>1 {f()}; END{print NR}" +$ pipe gawk -- "BEGIN { print ""a\nb"" }" | gawk -- "''x'" +$ echo "-- 5" +$! Ugh; extra quotes are needed here to end up with """" after "''y'" +$! expansion and finally "" when gawk actually sees its command line. +$ y = "function strip(f) { sub(/.*\//, """""""", f); return f };" +$ x = "BEGINFILE{if(++i==1) exit;}; END{print i, strip(FILENAME)}" +$ gawk "''y'''x'" /dev/null exit.sh +$ echo "-- 6" +$ x = "BEGINFILE{if(++i==1) exit;}; ENDFILE{print i++}; END{print i, strip(FILENAME)}" +$ gawk "''y'''x'" /dev/null exit.sh +$ echo "-- 7" +$ x = "function f(){exit}; BEGINFILE{i++ && f()}; END{print NR,strip(FILENAME)}" +$ gawk "''y'''x'" /dev/null exit.sh +$ echo "-- 8" +$ x = "function f(){exit}; BEGINFILE{i++ && f()}; ENDFILE{print i}; END{print NR,strip(FILENAME)}" +$ gawk "''y'''x'" /dev/null exit.sh +$ echo "-- 9" +$ x = "function f(){exit}; BEGINFILE{i++}; ENDFILE{f(); print i}; END{print NR,strip(FILENAME)}" +$ gawk "''y'''x'" /dev/null exit.sh +$ echo "-- 10" +$ x = "function f(){exit}; BEGINFILE{i++}; ENDFILE{i>1 && f(); print i, strip(FILENAME)}" +$ gawk "''y'''x'" /dev/null exit.sh +$ echo "-- 11" +$ endsubroutine !do__exit +$ +$vms_cmd: echo "vms_cmd" +$ if f$search("vms_cmd.ok").eqs."" +$ then create vms_cmd.ok +World! +$ endif +$ gawk /Commands="BEGIN { print ""World!"" }" _NL: /Output=_vms_cmd.tmp +$ cmp vms_cmd.ok _vms_cmd.tmp +$ if $status then rm _vms_cmd.tmp; +$ return +$ +$vms_io1: echo "vms_io1" +$ if f$search("vms_io1.ok").eqs."" +$ then create vms_io1.ok +Hello +$ endif +$ ! define/User dbg$input sys$command: +$ gawk -f - >_vms_io1.tmp +# prior to 3.0.4, gawk crashed doing any redirection after closing stdin +BEGIN { print "Hello" >"/dev/stdout" } +$ cmp vms_io1.ok _vms_io1.tmp +$ if $status then rm _vms_io1.tmp; +$ return +$ +$vms_io2: echo "vms_io2" +$ if f$search("vms_io2.ok").eqs."" +$ then create vms_io2.ok +xyzzy +$ endif +$ ! VAXCRTL created all files in stream_LF format unless explicitly +$ ! overridden by the program; with DECC$SHR, a new version of an +$ ! existing file inherits the previous version's record format; +$ ! for gawk versions older than 3.1.7, that resulted in +$ ! "can't redirect to `File' (invalid record attributes)" +$ ! when an awk program used >"File" (internally, not on command line) +$ ! and File already existed as a batch log file or PIPE output file +$ create /FDL=sys$input: _vms_io2.vfc +file + organization sequential +record + format VFC ! variable with fixed control area (default size 2 bytes) + carriage_control print +$ set noOn +$ ! define/User dbg$input sys$command: +$ gawk -- "BEGIN { print ""xyzzy"" >""_vms_io2.vfc"" }" >_vms_io2.tmp 2>&1 +$ set On +$ cmp _NL: _vms_io2.tmp +$ if $status then rm _vms_io2.tmp; +$ cmp vms_io2.ok _vms_io2.vfc +$ if $status then rm _vms_io2.vfc;* +$ return +$ +$clean: +$ if f$search("_*.*") .nes."" then rm _*.tmp;* +$ if f$search("_*.too") .nes."" then rm _*.too;* +$ if f$search("out%.") .nes."" then rm out%.;* +$ if f$search("strftime.in").nes."" then rm strftime.in;* +$ if f$search("strftime.ok").nes."" then rm strftime.ok;* +$ if f$search("test%.") .nes."" then rm test%.;* +$ if f$search("seq.") .nes."" then rm seq.;* +$ if f$search("_pid.in") .nes."" then rm _pid.in;* +$ if f$search("[.junk]*.*").nes."" then rm [.junk]*.*;* +$ if f$parse("[.junk]") .nes."" then rm []junk.dir;1 +$ if f$search("_vms_io2.vfc") .nes."" then rm _vms_io2.vfc;* +$ return +$ +$! try to determine what type of double precision floating point gawk uses +$calc_floatmode: +$ ! this is fragile; it might break if gawk changes overflow handling +$ Set noOn +$ gawk -- "BEGIN {print 10^308}" >_NL: 2>&1 +$ if $status +$ then floatmode = 2 ! IEEE T_float +$ else gawk -- "BEGIN {print 10^307}" >_NL: 2>&1 +$ if $status +$ then floatmode = 1 ! Alpha/VAX G_float +$ else floatmode = 0 ! VAX D_float +$ endif +$ endif +$ Set On +$ return +$ +$! assign temporary value to logical name GAWKLOCALE unless it already has one +$! [ -z "$GAWKLOCALE" ] && GAWKLOCALE=en_US.UTF-8 +$define_gawklocale: +$ ! gawk uses the C run-time libary's getenv() function to look up +$ ! GAWKLOCALE, so a symbol provides another way to supply the value; +$ ! we don't want to override logical or symbol if either is present +$ if f$trnlnm("GAWKLOCALE").eqs."" +$ then +$ if f$type(gawklocale).nes."STRING" .or. "''gawklocale'".eqs."" +$ then +$ define/User GAWKLOCALE "en_US.UTF-8" +$ endif +$ endif +$ return +$ +$! make sure that the specified file's longest-record-length field is set; +$! otherwise DIFF will choke if any record is longer than 512 bytes +$fixup_LRL: subroutine +$ lrl = 0 !VMS V5.5-2 didn't support the LRL argument yet +$ define/user sys$error _NL: +$ define/user sys$output _NL: +$ lrl = f$file_attribute(p1,"LRL") +$ if lrl.eq.0 then lrl = f$file_attribute(p1,"MRS") +$ if lrl.eq.0 +$ then convert/fdl=sys$input: 'p1' *.* +file + organization sequential +record + format stream_lf + size 32767 +$ if $status .and. p2.eqs."purge" then rm 'p1';-1 +$ else cmp _NL: _NL: !deassign/user sys${error,output} +$ endif +$ endsubroutine !fixup_LRL +$ +$! add a fake "EXIT CODE" record to the end of the temporary output file +$! to simulate the ``|| echo EXIT CODE $$? >>_$@'' shell script usage +$exit_code: subroutine +$ if f$trnlnm("FTMP").nes."" then close/noLog ftmp +$ open/Append ftmp 'p2' +$ write ftmp "EXIT CODE: ",p1 +$ close ftmp +$ endsubroutine !exit_code +$ +$!NOTREACHED +$ exit diff --git a/xalloc.h b/xalloc.h new file mode 100644 index 0000000..5810fc5 --- /dev/null +++ b/xalloc.h @@ -0,0 +1,336 @@ +/* xalloc.h -- malloc with out-of-memory checking + + Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, + 2000, 2003, 2004, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, + Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef XALLOC_H_ +# define XALLOC_H_ + +# include + + +# ifdef __cplusplus +extern "C" { +# endif + + +# ifndef __attribute__ +# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) +# define __attribute__(x) +# endif +# endif + +# ifndef ATTRIBUTE_NORETURN +# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__)) +# endif + +# ifndef ATTRIBUTE_MALLOC +# if __GNUC__ >= 3 +# define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define ATTRIBUTE_MALLOC +# endif +# endif + +/* This function is always triggered when memory is exhausted. + It must be defined by the application, either explicitly + or by using gnulib's xalloc-die module. This is the + function to call when one wants the program to die because of a + memory allocation failure. */ +extern void xalloc_die (void) ATTRIBUTE_NORETURN; + +void *xmalloc (size_t s) ATTRIBUTE_MALLOC; +void *xzalloc (size_t s) ATTRIBUTE_MALLOC; +void *xcalloc (size_t n, size_t s) ATTRIBUTE_MALLOC; +void *xrealloc (void *p, size_t s); +void *x2realloc (void *p, size_t *pn); +void *xmemdup (void const *p, size_t s) ATTRIBUTE_MALLOC; +char *xstrdup (char const *str) ATTRIBUTE_MALLOC; + +/* Return 1 if an array of N objects, each of size S, cannot exist due + to size arithmetic overflow. S must be positive and N must be + nonnegative. This is a macro, not an inline function, so that it + works correctly even when SIZE_MAX < N. + + By gnulib convention, SIZE_MAX represents overflow in size + calculations, so the conservative dividend to use here is + SIZE_MAX - 1, since SIZE_MAX might represent an overflowed value. + However, malloc (SIZE_MAX) fails on all known hosts where + sizeof (ptrdiff_t) <= sizeof (size_t), so do not bother to test for + exactly-SIZE_MAX allocations on such hosts; this avoids a test and + branch when S is known to be 1. */ +# define xalloc_oversized(n, s) \ + ((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n)) + + +/* In the following macros, T must be an elementary or structure/union or + typedef'ed type, or a pointer to such a type. To apply one of the + following macros to a function pointer or array type, you need to typedef + it first and use the typedef name. */ + +/* Allocate an object of type T dynamically, with error checking. */ +/* extern t *XMALLOC (typename t); */ +# define XMALLOC(t) ((t *) xmalloc (sizeof (t))) + +/* Allocate memory for N elements of type T, with error checking. */ +/* extern t *XNMALLOC (size_t n, typename t); */ +# define XNMALLOC(n, t) \ + ((t *) (sizeof (t) == 1 ? xmalloc (n) : xnmalloc (n, sizeof (t)))) + +/* Allocate an object of type T dynamically, with error checking, + and zero it. */ +/* extern t *XZALLOC (typename t); */ +# define XZALLOC(t) ((t *) xzalloc (sizeof (t))) + +/* Allocate memory for N elements of type T, with error checking, + and zero it. */ +/* extern t *XCALLOC (size_t n, typename t); */ +# define XCALLOC(n, t) \ + ((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t)))) + +/* + * Gawk uses this file only to keep dfa.c happy. + * We're therefore safe in manually defining HAVE_INLINE to + * make the !@#$%^&*() thing just work. + */ +#ifdef GAWK +#define HAVE_INLINE 1 /* so there. nyah, nyah, nyah. */ +#endif + +# if HAVE_INLINE +# define static_inline static inline +# else +void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC; +void *xnrealloc (void *p, size_t n, size_t s); +void *x2nrealloc (void *p, size_t *pn, size_t s); +char *xcharalloc (size_t n) ATTRIBUTE_MALLOC; +# endif + +# ifdef static_inline + +/* Allocate an array of N objects, each with S bytes of memory, + dynamically, with error checking. S must be nonzero. */ + +static_inline void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC; +static_inline void * +xnmalloc (size_t n, size_t s) +{ + if (xalloc_oversized (n, s)) + xalloc_die (); + return xmalloc (n * s); +} + +#ifdef GAWK +#include +/* Allocate an array of N objects, each with S bytes of memory, + dynamically, with error checking. S must be nonzero. + Clear the contents afterwards. */ + +void * +xcalloc(size_t nmemb, size_t size) +{ + void *p = xmalloc (nmemb * size); + memset(p, '\0', nmemb * size); + return p; +} + +/* Reallocate a pointer to a new size, with error checking. */ + +void * +xrealloc(void *p, size_t size) +{ + void *new_p = realloc(p, size); + if (new_p == 0) + xalloc_die (); + + return new_p; +} + +/* xalloc_die --- fatal error message when malloc fails, needed by dfa.c */ + +void +xalloc_die (void) +{ + extern void r_fatal(const char *msg, ...) ATTRIBUTE_NORETURN ; + + r_fatal(_("xalloc: malloc failed: %s"), strerror(errno)); +} +#endif + +/* Change the size of an allocated block of memory P to an array of N + objects each of S bytes, with error checking. S must be nonzero. */ + +static_inline void * +xnrealloc (void *p, size_t n, size_t s) +{ + if (xalloc_oversized (n, s)) + xalloc_die (); + return xrealloc (p, n * s); +} + +/* If P is null, allocate a block of at least *PN such objects; + otherwise, reallocate P so that it contains more than *PN objects + each of S bytes. *PN must be nonzero unless P is null, and S must + be nonzero. Set *PN to the new number of objects, and return the + pointer to the new block. *PN is never set to zero, and the + returned pointer is never null. + + Repeated reallocations are guaranteed to make progress, either by + allocating an initial block with a nonzero size, or by allocating a + larger block. + + In the following implementation, nonzero sizes are increased by a + factor of approximately 1.5 so that repeated reallocations have + O(N) overall cost rather than O(N**2) cost, but the + specification for this function does not guarantee that rate. + + Here is an example of use: + + int *p = NULL; + size_t used = 0; + size_t allocated = 0; + + void + append_int (int value) + { + if (used == allocated) + p = x2nrealloc (p, &allocated, sizeof *p); + p[used++] = value; + } + + This causes x2nrealloc to allocate a block of some nonzero size the + first time it is called. + + To have finer-grained control over the initial size, set *PN to a + nonzero value before calling this function with P == NULL. For + example: + + int *p = NULL; + size_t used = 0; + size_t allocated = 0; + size_t allocated1 = 1000; + + void + append_int (int value) + { + if (used == allocated) + { + p = x2nrealloc (p, &allocated1, sizeof *p); + allocated = allocated1; + } + p[used++] = value; + } + + */ + +static_inline void * +x2nrealloc (void *p, size_t *pn, size_t s) +{ + size_t n = *pn; + + if (! p) + { + if (! n) + { + /* The approximate size to use for initial small allocation + requests, when the invoking code specifies an old size of + zero. 64 bytes is the largest "small" request for the + GNU C library malloc. */ + enum { DEFAULT_MXFAST = 64 }; + + n = DEFAULT_MXFAST / s; + n += !n; + } + } + else + { + /* Set N = ceil (1.5 * N) so that progress is made if N == 1. + Check for overflow, so that N * S stays in size_t range. + The check is slightly conservative, but an exact check isn't + worth the trouble. */ + if ((size_t) -1 / 3 * 2 / s <= n) + xalloc_die (); + n += (n + 1) / 2; + } + + *pn = n; + return xrealloc (p, n * s); +} + +/* Return a pointer to a new buffer of N bytes. This is like xmalloc, + except it returns char *. */ + +static_inline char *xcharalloc (size_t n) ATTRIBUTE_MALLOC; +static_inline char * +xcharalloc (size_t n) +{ + return XNMALLOC (n, char); +} + +/* Allocate S bytes of zeroed memory dynamically, with error checking. + There's no need for xnzalloc (N, S), since it would be equivalent + to xcalloc (N, S). */ + +inline void * +xzalloc (size_t s) +{ + return memset (xmalloc (s), 0, s); +} + +# endif + +# ifdef __cplusplus +} + +/* C++ does not allow conversions from void * to other pointer types + without a cast. Use templates to work around the problem when + possible. */ + +template inline T * +xrealloc (T *p, size_t s) +{ + return (T *) xrealloc ((void *) p, s); +} + +template inline T * +xnrealloc (T *p, size_t n, size_t s) +{ + return (T *) xnrealloc ((void *) p, n, s); +} + +template inline T * +x2realloc (T *p, size_t *pn) +{ + return (T *) x2realloc ((void *) p, pn); +} + +template inline T * +x2nrealloc (T *p, size_t *pn, size_t s) +{ + return (T *) x2nrealloc ((void *) p, pn, s); +} + +template inline T * +xmemdup (T const *p, size_t s) +{ + return (T *) xmemdup ((void const *) p, s); +} + +# endif + + +#endif /* !XALLOC_H_ */ diff --git a/ylwrap b/ylwrap new file mode 100644 index 0000000..102bd89 --- /dev/null +++ b/ylwrap @@ -0,0 +1,223 @@ +#! /bin/sh +# ylwrap - wrapper for lex/yacc invocations. + +scriptversion=2005-05-14.22 + +# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# +# Written by Tom Tromey . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +case "$1" in + '') + echo "$0: No files given. Try \`$0 --help' for more information." 1>&2 + exit 1 + ;; + --basedir) + basedir=$2 + shift 2 + ;; + -h|--h*) + cat <<\EOF +Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... + +Wrapper for lex/yacc invocations, renaming files as desired. + + INPUT is the input file + OUTPUT is one file PROG generates + DESIRED is the file we actually want instead of OUTPUT + PROGRAM is program to run + ARGS are passed to PROG + +Any number of OUTPUT,DESIRED pairs may be used. + +Report bugs to . +EOF + exit $? + ;; + -v|--v*) + echo "ylwrap $scriptversion" + exit $? + ;; +esac + + +# The input. +input="$1" +shift +case "$input" in + [\\/]* | ?:[\\/]*) + # Absolute path; do nothing. + ;; + *) + # Relative path. Make it absolute. + input="`pwd`/$input" + ;; +esac + +pairlist= +while test "$#" -ne 0; do + if test "$1" = "--"; then + shift + break + fi + pairlist="$pairlist $1" + shift +done + +# The program to run. +prog="$1" +shift +# Make any relative path in $prog absolute. +case "$prog" in + [\\/]* | ?:[\\/]*) ;; + *[\\/]*) prog="`pwd`/$prog" ;; +esac + +# FIXME: add hostname here for parallel makes that run commands on +# other machines. But that might take us over the 14-char limit. +dirname=ylwrap$$ +trap "cd `pwd`; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15 +mkdir $dirname || exit 1 + +cd $dirname + +case $# in + 0) $prog "$input" ;; + *) $prog "$@" "$input" ;; +esac +ret=$? + +if test $ret -eq 0; then + set X $pairlist + shift + first=yes + # Since DOS filename conventions don't allow two dots, + # the DOS version of Bison writes out y_tab.c instead of y.tab.c + # and y_tab.h instead of y.tab.h. Test to see if this is the case. + y_tab_nodot="no" + if test -f y_tab.c || test -f y_tab.h; then + y_tab_nodot="yes" + fi + + # The directory holding the input. + input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'` + # Quote $INPUT_DIR so we can use it in a regexp. + # FIXME: really we should care about more than `.' and `\'. + input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'` + + while test "$#" -ne 0; do + from="$1" + # Handle y_tab.c and y_tab.h output by DOS + if test $y_tab_nodot = "yes"; then + if test $from = "y.tab.c"; then + from="y_tab.c" + else + if test $from = "y.tab.h"; then + from="y_tab.h" + fi + fi + fi + if test -f "$from"; then + # If $2 is an absolute path name, then just use that, + # otherwise prepend `../'. + case "$2" in + [\\/]* | ?:[\\/]*) target="$2";; + *) target="../$2";; + esac + + # We do not want to overwrite a header file if it hasn't + # changed. This avoid useless recompilations. However the + # parser itself (the first file) should always be updated, + # because it is the destination of the .y.c rule in the + # Makefile. Divert the output of all other files to a temporary + # file so we can compare them to existing versions. + if test $first = no; then + realtarget="$target" + target="tmp-`echo $target | sed s/.*[\\/]//g`" + fi + # Edit out `#line' or `#' directives. + # + # We don't want the resulting debug information to point at + # an absolute srcdir; it is better for it to just mention the + # .y file with no path. + # + # We want to use the real output file name, not yy.lex.c for + # instance. + # + # We want the include guards to be adjusted too. + FROM=`echo "$from" | sed \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ + -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` + TARGET=`echo "$2" | sed \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ + -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` + + sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \ + -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$? + + # Check whether header files must be updated. + if test $first = no; then + if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then + echo "$2" is unchanged + rm -f "$target" + else + echo updating "$2" + mv -f "$target" "$realtarget" + fi + fi + else + # A missing file is only an error for the first file. This + # is a blatant hack to let us support using "yacc -d". If -d + # is not specified, we don't want an error when the header + # file is "missing". + if test $first = yes; then + ret=1 + fi + fi + shift + shift + first=no + done +else + ret=$? +fi + +# Remove the directory. +cd .. +rm -rf $dirname + +exit $ret + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: -- 2.7.4

") + print_line(prefix(3) "") +} + + +function html_begin_pages() +{ + return ((HTML && (BIBFILEURL != "")) ? ("") : "") +} + + +function html_begin_pre() +{ + In_PRE = 1 + print_line("
")
+}
+
+
+function html_begin_title()
+{
+	return ((HTML && (Url != "")) ? ("") : "")
+}
+
+
+function html_begin_toc()
+{
+	html_end_toc()
+	html_begin_pre()
+}
+
+
+function html_body( k)
+{
+	for (k = 1; k <= BodyLines; ++k)
+		print Body[k]
+}
+
+function html_breakpoint(title,maxlength, break_after,k)
+{
+	# Return the largest character position in title AFTER which we
+	# can break the title across lines, without exceeding maxlength
+	# visible characters.
+	if (html_length(title) > maxlength)	# then need to split title across lines
+	{
+		# In the presence of HTML markup, the initialization of
+		# k here is complicated, because we need to advance it
+		# until html_length(title) is at least maxlength,
+		# without invoking the expensive html_length() function
+		# too frequently.  The need to split the title makes the
+		# alternative of delayed insertion of HTML markup much
+		# more complicated.
+		break_after = 0
+		for (k = min(maxlength,length(title)); k < length(title); ++k)
+		{
+			if (substr(title,k+1,1) == " ")
+			{		# could break after position k
+				if (html_length(substr(title,1,k)) <= maxlength)
+					break_after = k
+				else	# advanced too far, retreat back to last break_after
+					break
+			}
+		}
+		if (break_after == 0)		# no breakpoint found by forward scan
+		{				# so switch to backward scan
+			for (k = min(maxlength,length(title)) - 1; \
+				(k > 0) && (substr(title,k+1,1) != " "); --k)
+				;		# find space at which to break title
+			if (k < 1)		# no break point found
+				k = length(title) # so must print entire string
+		}
+		else
+			k = break_after
+	}
+	else					# title fits on one line
+		k = length(title)
+	return (k)
+}
+
+
+
+function html_end_issue()
+{
+	print_line(prefix(3) "")
+	print_line(prefix(2) "